This commit is contained in:
Raven Scott
2026-07-10 20:04:47 -04:00
parent 448087a583
commit d6ce72af66
37 changed files with 3071 additions and 2788 deletions
+20
View File
@@ -0,0 +1,20 @@
/**
* Value encodings for protomux-rpc.
* Uses compact-encoding JSON for structured payloads.
*/
import c from 'compact-encoding'
/** Default encoding for all peardock RPC methods and pushes. */
export const json = c.json
/** Raw buffer passthrough when needed. */
export const raw = c.raw
/** Empty / none encoding. */
export const none = c.none
export const encodings = {
valueEncoding: json,
requestEncoding: json,
responseEncoding: json,
}
+105
View File
@@ -0,0 +1,105 @@
/**
* peardock P2P protocol constants.
* Shared by the HyperDHT server and Pear client.
*/
export const PROTOCOL = 'peardock/rpc'
export const PROTOCOL_VERSION = 1
/** Request/response RPC methods (client → server). */
export const Methods = Object.freeze({
// Containers
listContainers: 'listContainers',
inspectContainer: 'inspectContainer',
startContainer: 'startContainer',
stopContainer: 'stopContainer',
restartContainer: 'restartContainer',
pauseContainer: 'pauseContainer',
unpauseContainer: 'unpauseContainer',
removeContainer: 'removeContainer',
renameContainer: 'renameContainer',
commitContainer: 'commitContainer',
exportContainer: 'exportContainer',
execContainer: 'execContainer',
duplicateContainer: 'duplicateContainer',
deployContainer: 'deployContainer',
updateContainer: 'updateContainer',
bulkContainerOperation: 'bulkContainerOperation',
// Images
listImages: 'listImages',
pullImage: 'pullImage',
removeImage: 'removeImage',
inspectImage: 'inspectImage',
buildImage: 'buildImage',
tagImage: 'tagImage',
// Networks
listNetworks: 'listNetworks',
createNetwork: 'createNetwork',
removeNetwork: 'removeNetwork',
inspectNetwork: 'inspectNetwork',
connectNetwork: 'connectNetwork',
disconnectNetwork: 'disconnectNetwork',
// Volumes
listVolumes: 'listVolumes',
createVolume: 'createVolume',
removeVolume: 'removeVolume',
inspectVolume: 'inspectVolume',
// Stacks / compose
deployStack: 'deployStack',
listStacks: 'listStacks',
removeStack: 'removeStack',
// System / host
getSystemInfo: 'getSystemInfo',
getDockerEvents: 'getDockerEvents',
browseDirectory: 'browseDirectory',
dockerCommand: 'dockerCommand',
// Terminal / streams (control plane)
startTerminal: 'startTerminal',
killTerminal: 'killTerminal',
terminalInput: 'terminalInput',
terminalResize: 'terminalResize',
startLogs: 'startLogs',
stopLogs: 'stopLogs',
execInput: 'execInput',
dockerTerminalResize: 'dockerTerminalResize',
// Health
ping: 'ping',
})
/**
* Server → client push channels (registered as respond handlers on the client,
* fired with rpc.event on the server).
*/
export const Pushes = Object.freeze({
containers: 'push:containers',
volumes: 'push:volumes',
allStats: 'push:allStats',
logs: 'push:logs',
terminalOutput: 'push:terminalOutput',
terminalErrorOutput: 'push:terminalErrorOutput',
execOutput: 'push:execOutput',
execErrorOutput: 'push:execErrorOutput',
dockerOutput: 'push:dockerOutput',
error: 'push:error',
})
/** Map legacy response `type` field → push channel (for UI handlers). */
export const PushToType = Object.freeze({
[Pushes.containers]: 'containers',
[Pushes.volumes]: 'volumes',
[Pushes.allStats]: 'allStats',
[Pushes.logs]: 'logs',
[Pushes.terminalOutput]: 'terminalOutput',
[Pushes.terminalErrorOutput]: 'terminalErrorOutput',
[Pushes.execOutput]: 'execOutput',
[Pushes.execErrorOutput]: 'execErrorOutput',
[Pushes.dockerOutput]: 'dockerOutput',
[Pushes.error]: 'error',
})