dal-code 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -53
- package/dist/core/keybindings.d.ts +1 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +1 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-config.d.ts +85 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +19 -14
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/session-manager.d.ts +7 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +28 -0
- package/dist/core/session-manager.js.map +1 -1
- package/dist/extensions/llama/client.d.ts +2 -0
- package/dist/extensions/llama/client.d.ts.map +1 -1
- package/dist/extensions/llama/client.js +7 -3
- package/dist/extensions/llama/client.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +20 -5
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +5 -6
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +2 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +31 -21
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/node_modules/@dalcode/dal-bridge/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-gateway/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-guard/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-halo/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-lang/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-lsp/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-mcp/package.json +6 -6
- package/dist/node_modules/@dalcode/dal-office/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-skills/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-subagent/package.json +6 -6
- package/dist/node_modules/@dalcode/dal-telemetry/package.json +3 -3
- package/dist/node_modules/@dalcode/deepailab/package.json +4 -4
- package/dist/node_modules/@earendil-works/chord/LICENSE +21 -0
- package/dist/node_modules/@earendil-works/chord/README.md +205 -0
- package/dist/node_modules/@earendil-works/chord/dist/api.d.ts +15 -0
- package/dist/node_modules/@earendil-works/chord/dist/api.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/api.js +72 -0
- package/dist/node_modules/@earendil-works/chord/dist/api.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/bundler.d.ts +6 -0
- package/dist/node_modules/@earendil-works/chord/dist/bundler.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/bundler.js +3 -0
- package/dist/node_modules/@earendil-works/chord/dist/bundler.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/context/index.d.ts +24 -0
- package/dist/node_modules/@earendil-works/chord/dist/context/index.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/context/index.js +97 -0
- package/dist/node_modules/@earendil-works/chord/dist/context/index.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/delta/index.d.ts +119 -0
- package/dist/node_modules/@earendil-works/chord/dist/delta/index.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/delta/index.js +1906 -0
- package/dist/node_modules/@earendil-works/chord/dist/delta/index.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/facets/host.d.ts +12 -0
- package/dist/node_modules/@earendil-works/chord/dist/facets/host.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/facets/host.js +763 -0
- package/dist/node_modules/@earendil-works/chord/dist/facets/host.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/facets/loader.d.ts +3 -0
- package/dist/node_modules/@earendil-works/chord/dist/facets/loader.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/facets/loader.js +5 -0
- package/dist/node_modules/@earendil-works/chord/dist/facets/loader.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/index.d.ts +11 -0
- package/dist/node_modules/@earendil-works/chord/dist/index.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/index.js +10 -0
- package/dist/node_modules/@earendil-works/chord/dist/index.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/json.d.ts +4 -0
- package/dist/node_modules/@earendil-works/chord/dist/json.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/json.js +57 -0
- package/dist/node_modules/@earendil-works/chord/dist/json.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/node/bundle-loader.d.ts +30 -0
- package/dist/node_modules/@earendil-works/chord/dist/node/bundle-loader.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/node/bundle-loader.js +377 -0
- package/dist/node_modules/@earendil-works/chord/dist/node/bundle-loader.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/node/bundle.d.ts +26 -0
- package/dist/node_modules/@earendil-works/chord/dist/node/bundle.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/node/bundle.js +183 -0
- package/dist/node_modules/@earendil-works/chord/dist/node/bundle.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/node/manifest.d.ts +36 -0
- package/dist/node_modules/@earendil-works/chord/dist/node/manifest.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/node/manifest.js +6 -0
- package/dist/node_modules/@earendil-works/chord/dist/node/manifest.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/node/package.d.ts +15 -0
- package/dist/node_modules/@earendil-works/chord/dist/node/package.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/node/package.js +199 -0
- package/dist/node_modules/@earendil-works/chord/dist/node/package.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/node.d.ts +5 -0
- package/dist/node_modules/@earendil-works/chord/dist/node.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/node.js +3 -0
- package/dist/node_modules/@earendil-works/chord/dist/node.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/consumer.d.ts +11 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/consumer.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/consumer.js +537 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/consumer.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/errors.d.ts +8 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/errors.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/errors.js +22 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/errors.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/handle.d.ts +15 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/handle.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/handle.js +99 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/handle.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/instances.d.ts +25 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/instances.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/instances.js +137 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/instances.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/loopback.d.ts +5 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/loopback.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/loopback.js +15 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/loopback.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/provider.d.ts +37 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/provider.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/provider.js +472 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/provider.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/state-codec.d.ts +15 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/state-codec.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/state-codec.js +115 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/state-codec.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/state-internals.d.ts +11 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/state-internals.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/state-internals.js +10 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/state-internals.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/state.d.ts +23 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/state.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/state.js +124 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/state.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/wire.d.ts +60 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/wire.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/wire.js +173 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/wire.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/types.d.ts +203 -0
- package/dist/node_modules/@earendil-works/chord/dist/types.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/chord/dist/types.js +2 -0
- package/dist/node_modules/@earendil-works/chord/dist/types.js.map +1 -0
- package/dist/node_modules/@earendil-works/chord/package.json +62 -0
- package/dist/node_modules/@earendil-works/chord/src/delta/README.md +404 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/README.md +3 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +15 -6
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.d.ts.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +9 -66
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts +12 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +50 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.d.ts.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +13 -58
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.d.ts.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +5 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +6 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +30 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +34 -4
- package/dist/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/deepseek.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/types.d.ts +4 -2
- package/dist/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +8 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-client/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-protocol/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-server/CHANGELOG.md +57 -0
- package/dist/node_modules/@earendil-works/pi-server/LICENSE +21 -0
- package/dist/node_modules/@earendil-works/pi-server/README.md +79 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/cli.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/cli.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/cli.js +136 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/cli.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/config.d.ts +12 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/config.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/config.js +55 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/config.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/connection.d.ts +35 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/connection.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/connection.js +4 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/connection.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/errors.d.ts +25 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/errors.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/errors.js +41 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/errors.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/handler.d.ts +14 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/handler.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/handler.js +105 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/handler.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/index.d.ts +5 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/index.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/index.js +5 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/index.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/ipc/client.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/ipc/client.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/ipc/client.js +56 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/ipc/client.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/ipc/protocol.d.ts +99 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/ipc/protocol.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/ipc/protocol.js +12 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/ipc/protocol.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/ipc/server.d.ts +20 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/ipc/server.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/ipc/server.js +145 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/ipc/server.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/listener.d.ts +8 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/listener.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/listener.js +2 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/listener.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/protocol.d.ts +22 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/protocol.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/protocol.js +266 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/protocol.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/radius.d.ts +36 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/radius.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/radius.js +360 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/radius.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/rpc-process.d.ts +31 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/rpc-process.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/rpc-process.js +168 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/rpc-process.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/serve.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/serve.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/serve.js +70 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/serve.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/server.d.ts +46 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/server.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/server.js +549 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/server.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/session-router.d.ts +40 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/session-router.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/session-router.js +264 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/session-router.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/sessions.d.ts +2195 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/sessions.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/sessions.js +332 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/sessions.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/snapshots.d.ts +24 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/snapshots.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/snapshots.js +39 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/snapshots.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/storage.d.ts +10 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/storage.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/storage.js +58 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/storage.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/supervisor.d.ts +34 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/supervisor.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/supervisor.js +290 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/supervisor.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/client.d.ts +35 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/client.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/client.js +138 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/client.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/host.d.ts +57 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/host.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/host.js +189 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/host.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/index.d.ts +6 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/index.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/index.js +4 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/index.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/server.d.ts +13 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/server.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/server.js +17 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/server.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/service.d.ts +66 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/service.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/service.js +254 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/service.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/address.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/address.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/address.js +9 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/address.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/index.d.ts +5 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/index.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/index.js +4 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/index.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/listener.d.ts +24 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/listener.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/listener.js +421 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/listener.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/preset.d.ts +7 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/preset.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/preset.js +22 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/preset.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/types.d.ts +15 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/types.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/types.js +2 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/types.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/types.d.ts +49 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/types.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/types.js +2 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/types.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-server/package.json +45 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/CHANGELOG.md +46 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/LICENSE +21 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/README.md +33 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/index.d.ts +6 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/index.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/index.js +103 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/index.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/branch-cache.d.ts +6 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/branch-cache.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/branch-cache.js +70 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/branch-cache.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/index.d.ts +5 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/index.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/index.js +4 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/index.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/migrations/001_initial.sql +121 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/migrations.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/migrations.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/migrations.js +7 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/migrations.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/repo.d.ts +41 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/repo.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/repo.js +408 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/repo.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/search-backend.d.ts +14 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/search-backend.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/search-backend.js +153 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/search-backend.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/branch-entries.d.ts +6 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/branch-entries.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/branch-entries.js +213 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/branch-entries.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/entries.d.ts +24 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/entries.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/entries.js +126 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/entries.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/session-row.d.ts +23 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/session-row.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/session-row.js +69 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/session-row.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/session-sequences.d.ts +4 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/session-sequences.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/session-sequences.js +13 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/session-sequences.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/session-stats.d.ts +6 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/session-stats.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/session-stats.js +39 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/session-stats.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/usage-ledger.d.ts +20 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/usage-ledger.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/usage-ledger.js +50 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/usage-ledger.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/values.d.ts +23 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/values.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/values.js +91 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session/values.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session.d.ts +42 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session.js +163 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/session.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/sql.d.ts +19 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/sql.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/sql.js +58 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/sql.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/branch-entries.d.ts +41 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/branch-entries.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/branch-entries.js +112 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/branch-entries.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/branch-tips.d.ts +7 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/branch-tips.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/branch-tips.js +22 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/branch-tips.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/entries.d.ts +34 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/entries.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/entries.js +37 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/entries.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/facts.d.ts +20 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/facts.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/facts.js +38 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/facts.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/lanes.d.ts +35 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/lanes.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/lanes.js +95 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/lanes.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/records.d.ts +38 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/records.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/records.js +49 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/records.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/session-sequences.d.ts +7 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/session-sequences.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/session-sequences.js +22 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/session-sequences.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/session-stats.d.ts +17 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/session-stats.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/session-stats.js +40 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/session-stats.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/sessions.d.ts +26 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/sessions.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/sessions.js +99 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/sessions.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/writer-leases.d.ts +15 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/writer-leases.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/writer-leases.js +31 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/writer-leases.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage.d.ts +38 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage.js +161 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/types.d.ts +29 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/types.d.ts.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/types.js +2 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/types.js.map +1 -0
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/package.json +33 -0
- package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/official/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/plugins/pi-example-plugin/package.json +1 -1
- package/npm-shrinkwrap.json +3 -14
- package/package.json +2 -2
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { createConnection } from "node:net";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { cwd } from "node:process";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { getSocketPath } from "./config.js";
|
|
8
|
+
import { sendIpcRequest } from "./ipc/client.js";
|
|
9
|
+
import { encodeMessage } from "./ipc/protocol.js";
|
|
10
|
+
import { serve } from "./serve.js";
|
|
11
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
+
const __dirname = dirname(__filename);
|
|
13
|
+
const packageJson = JSON.parse(readFileSync(join(__dirname, "../package.json"), "utf-8"));
|
|
14
|
+
function printHelp() {
|
|
15
|
+
console.log(`server v${packageJson.version}\n\nUsage:\n server serve\n server list\n server spawn [--cwd <path>] [--label <label>]\n server status <instance-id>\n server stop <instance-id>\n server rpc <instance-id> <json-command>\n server rpc-stream <instance-id>\n server --help\n server --version\n\nRPC stream stdin expects JSONL RpcCommand or extension_ui_response messages.`);
|
|
16
|
+
}
|
|
17
|
+
function printResponse(response) {
|
|
18
|
+
console.log(JSON.stringify(response, null, 2));
|
|
19
|
+
}
|
|
20
|
+
function getFlagValue(args, flag) {
|
|
21
|
+
const index = args.indexOf(flag);
|
|
22
|
+
if (index === -1 || index + 1 >= args.length) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
return args[index + 1];
|
|
26
|
+
}
|
|
27
|
+
async function rpcStream(instanceId) {
|
|
28
|
+
const socket = createConnection(getSocketPath());
|
|
29
|
+
let stdinBuffer = "";
|
|
30
|
+
process.stdin.setEncoding("utf8");
|
|
31
|
+
await new Promise((resolve, reject) => {
|
|
32
|
+
socket.once("connect", () => {
|
|
33
|
+
socket.write(encodeMessage({ type: "rpc_stream", instanceId }));
|
|
34
|
+
resolve();
|
|
35
|
+
});
|
|
36
|
+
socket.once("error", reject);
|
|
37
|
+
});
|
|
38
|
+
socket.on("data", (chunk) => {
|
|
39
|
+
process.stdout.write(chunk.toString());
|
|
40
|
+
});
|
|
41
|
+
console.error(`connected to rpc stream ${instanceId}; send JSONL RpcCommand or extension_ui_response on stdin`);
|
|
42
|
+
socket.on("error", (error) => {
|
|
43
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
44
|
+
process.exit(1);
|
|
45
|
+
});
|
|
46
|
+
socket.on("end", () => {
|
|
47
|
+
process.exit(0);
|
|
48
|
+
});
|
|
49
|
+
process.stdin.on("data", (chunk) => {
|
|
50
|
+
stdinBuffer += chunk;
|
|
51
|
+
while (true) {
|
|
52
|
+
const newlineIndex = stdinBuffer.indexOf("\n");
|
|
53
|
+
if (newlineIndex === -1) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const line = stdinBuffer.slice(0, newlineIndex).trim();
|
|
57
|
+
stdinBuffer = stdinBuffer.slice(newlineIndex + 1);
|
|
58
|
+
if (!line) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const parsed = JSON.parse(line);
|
|
62
|
+
socket.write(encodeMessage(parsed));
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
async function main() {
|
|
67
|
+
const args = process.argv.slice(2);
|
|
68
|
+
if (args.length === 0 || args[0] === "--help" || args[0] === "-h") {
|
|
69
|
+
printHelp();
|
|
70
|
+
process.exit(0);
|
|
71
|
+
}
|
|
72
|
+
if (args[0] === "--version" || args[0] === "-v") {
|
|
73
|
+
console.log(packageJson.version);
|
|
74
|
+
process.exit(0);
|
|
75
|
+
}
|
|
76
|
+
if (args[0] === "serve") {
|
|
77
|
+
await serve();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (args[0] === "list") {
|
|
81
|
+
printResponse(await sendIpcRequest({ type: "list" }));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (args[0] === "spawn") {
|
|
85
|
+
const spawnCwd = getFlagValue(args, "--cwd") ?? cwd();
|
|
86
|
+
const label = getFlagValue(args, "--label");
|
|
87
|
+
printResponse(await sendIpcRequest({ type: "spawn", cwd: spawnCwd, label }));
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (args[0] === "status") {
|
|
91
|
+
const instanceId = args[1];
|
|
92
|
+
if (!instanceId) {
|
|
93
|
+
console.error("Usage: server status <instance-id>");
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
printResponse(await sendIpcRequest({ type: "status", instanceId }));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (args[0] === "stop") {
|
|
100
|
+
const instanceId = args[1];
|
|
101
|
+
if (!instanceId) {
|
|
102
|
+
console.error("Usage: server stop <instance-id>");
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
printResponse(await sendIpcRequest({ type: "stop", instanceId }));
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (args[0] === "rpc") {
|
|
109
|
+
const instanceId = args[1];
|
|
110
|
+
const commandJson = args[2];
|
|
111
|
+
if (!instanceId || !commandJson) {
|
|
112
|
+
console.error("Usage: server rpc <instance-id> <json-command>");
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
printResponse(await sendIpcRequest({
|
|
116
|
+
type: "rpc",
|
|
117
|
+
instanceId,
|
|
118
|
+
command: JSON.parse(commandJson),
|
|
119
|
+
}));
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (args[0] === "rpc-stream") {
|
|
123
|
+
const instanceId = args[1];
|
|
124
|
+
if (!instanceId) {
|
|
125
|
+
console.error("Usage: server rpc-stream <instance-id>");
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
await rpcStream(instanceId);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
console.error(`Unknown command: ${args[0]}`);
|
|
132
|
+
printHelp();
|
|
133
|
+
process.exit(1);
|
|
134
|
+
}
|
|
135
|
+
await main();
|
|
136
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WA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E,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;QAClE,OAAO;IACR,CAAC;IAED,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC;QACvB,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAC3B,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,CAAC,UAAU,IAAI,CAAC,WAAW,EAAE,CAAC;YACjC,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;YAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC;QACD,aAAa,CACZ,MAAM,cAAc,CAAC;YACpB,IAAI,EAAE,KAAK;YACX,UAAU;YACV,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;SAChC,CAAC,CACF,CAAC;QACF,OAAO;IACR,CAAC;IAED,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,YAAY,EAAE,CAAC;QAC9B,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAC3B,IAAI,CAAC,UAAU,EAAE,CAAC;YACjB,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;YACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC;QACD,MAAM,SAAS,CAAC,UAAU,CAAC,CAAC;QAC5B,OAAO;IACR,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,oBAAoB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC7C,SAAS,EAAE,CAAC;IACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAAA,CAChB;AAED,MAAM,IAAI,EAAE,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { readFileSync } from \"node:fs\";\nimport { createConnection } from \"node:net\";\nimport { dirname, join } from \"node:path\";\nimport { cwd } from \"node:process\";\nimport { fileURLToPath } from \"node:url\";\nimport type { RpcCommand, RpcExtensionUIResponse } from \"@earendil-works/pi-coding-agent\";\nimport { getSocketPath } from \"./config.ts\";\nimport { sendIpcRequest } from \"./ipc/client.ts\";\nimport { encodeMessage } from \"./ipc/protocol.ts\";\nimport { serve } from \"./serve.ts\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst packageJson = JSON.parse(readFileSync(join(__dirname, \"../package.json\"), \"utf-8\")) as {\n\tversion: string;\n};\n\nfunction printHelp(): void {\n\tconsole.log(\n\t\t`server v${packageJson.version}\\n\\nUsage:\\n server serve\\n server list\\n server spawn [--cwd <path>] [--label <label>]\\n server status <instance-id>\\n server stop <instance-id>\\n server rpc <instance-id> <json-command>\\n server rpc-stream <instance-id>\\n server --help\\n server --version\\n\\nRPC stream stdin expects JSONL RpcCommand or extension_ui_response messages.`,\n\t);\n}\n\nfunction printResponse(response: unknown): void {\n\tconsole.log(JSON.stringify(response, null, 2));\n}\n\nfunction getFlagValue(args: string[], flag: string): string | undefined {\n\tconst index = args.indexOf(flag);\n\tif (index === -1 || index + 1 >= args.length) {\n\t\treturn undefined;\n\t}\n\treturn args[index + 1];\n}\n\nasync function rpcStream(instanceId: string): Promise<void> {\n\tconst socket = createConnection(getSocketPath());\n\tlet stdinBuffer = \"\";\n\tprocess.stdin.setEncoding(\"utf8\");\n\n\tawait new Promise<void>((resolve, reject) => {\n\t\tsocket.once(\"connect\", () => {\n\t\t\tsocket.write(encodeMessage({ type: \"rpc_stream\", instanceId }));\n\t\t\tresolve();\n\t\t});\n\t\tsocket.once(\"error\", reject);\n\t});\n\n\tsocket.on(\"data\", (chunk: Buffer | string) => {\n\t\tprocess.stdout.write(chunk.toString());\n\t});\n\tconsole.error(`connected to rpc stream ${instanceId}; send JSONL RpcCommand or extension_ui_response on stdin`);\n\tsocket.on(\"error\", (error) => {\n\t\tconsole.error(error instanceof Error ? error.message : String(error));\n\t\tprocess.exit(1);\n\t});\n\tsocket.on(\"end\", () => {\n\t\tprocess.exit(0);\n\t});\n\tprocess.stdin.on(\"data\", (chunk: string) => {\n\t\tstdinBuffer += chunk;\n\t\twhile (true) {\n\t\t\tconst newlineIndex = stdinBuffer.indexOf(\"\\n\");\n\t\t\tif (newlineIndex === -1) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst line = stdinBuffer.slice(0, newlineIndex).trim();\n\t\t\tstdinBuffer = stdinBuffer.slice(newlineIndex + 1);\n\t\t\tif (!line) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst parsed = JSON.parse(line) as RpcCommand | RpcExtensionUIResponse;\n\t\t\tsocket.write(encodeMessage(parsed));\n\t\t}\n\t});\n}\n\nasync function main(): Promise<void> {\n\tconst args = process.argv.slice(2);\n\n\tif (args.length === 0 || args[0] === \"--help\" || args[0] === \"-h\") {\n\t\tprintHelp();\n\t\tprocess.exit(0);\n\t}\n\n\tif (args[0] === \"--version\" || args[0] === \"-v\") {\n\t\tconsole.log(packageJson.version);\n\t\tprocess.exit(0);\n\t}\n\n\tif (args[0] === \"serve\") {\n\t\tawait serve();\n\t\treturn;\n\t}\n\n\tif (args[0] === \"list\") {\n\t\tprintResponse(await sendIpcRequest({ type: \"list\" }));\n\t\treturn;\n\t}\n\n\tif (args[0] === \"spawn\") {\n\t\tconst spawnCwd = getFlagValue(args, \"--cwd\") ?? cwd();\n\t\tconst label = getFlagValue(args, \"--label\");\n\t\tprintResponse(await sendIpcRequest({ type: \"spawn\", cwd: spawnCwd, label }));\n\t\treturn;\n\t}\n\n\tif (args[0] === \"status\") {\n\t\tconst instanceId = args[1];\n\t\tif (!instanceId) {\n\t\t\tconsole.error(\"Usage: server status <instance-id>\");\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tprintResponse(await sendIpcRequest({ type: \"status\", instanceId }));\n\t\treturn;\n\t}\n\n\tif (args[0] === \"stop\") {\n\t\tconst instanceId = args[1];\n\t\tif (!instanceId) {\n\t\t\tconsole.error(\"Usage: server stop <instance-id>\");\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tprintResponse(await sendIpcRequest({ type: \"stop\", instanceId }));\n\t\treturn;\n\t}\n\n\tif (args[0] === \"rpc\") {\n\t\tconst instanceId = args[1];\n\t\tconst commandJson = args[2];\n\t\tif (!instanceId || !commandJson) {\n\t\t\tconsole.error(\"Usage: server rpc <instance-id> <json-command>\");\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tprintResponse(\n\t\t\tawait sendIpcRequest({\n\t\t\t\ttype: \"rpc\",\n\t\t\t\tinstanceId,\n\t\t\t\tcommand: JSON.parse(commandJson),\n\t\t\t}),\n\t\t);\n\t\treturn;\n\t}\n\n\tif (args[0] === \"rpc-stream\") {\n\t\tconst instanceId = args[1];\n\t\tif (!instanceId) {\n\t\t\tconsole.error(\"Usage: server rpc-stream <instance-id>\");\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tawait rpcStream(instanceId);\n\t\treturn;\n\t}\n\n\tconsole.error(`Unknown command: ${args[0]}`);\n\tprintHelp();\n\tprocess.exit(1);\n}\n\nawait main();\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect if we're running as a Bun compiled binary.
|
|
3
|
+
* Bun binaries have import.meta.url containing "$bunfs", "~BUN", or "%7EBUN" (Bun's virtual filesystem path)
|
|
4
|
+
*/
|
|
5
|
+
export declare const isBunBinary: boolean;
|
|
6
|
+
export declare const VERSION: string;
|
|
7
|
+
export declare function getServerDir(): string;
|
|
8
|
+
export declare function getAuthPath(): string;
|
|
9
|
+
export declare function getMachinePath(): string;
|
|
10
|
+
export declare function getInstancesPath(): string;
|
|
11
|
+
export declare function getSocketPath(): string;
|
|
12
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,eAAO,MAAM,WAAW,SACqF,CAAC;AA0B9G,eAAO,MAAM,OAAO,EAAE,MAA+B,CAAC;AAEtD,wBAAgB,YAAY,IAAI,MAAM,CAQrC;AAED,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,aAAa,IAAI,MAAM,CAEtC","sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst CONFIG_DIR_NAME = \".pi\";\nconst ENV_SERVER_DIR = \"PI_SERVER_DIR\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Detect if we're running as a Bun compiled binary.\n * Bun binaries have import.meta.url containing \"$bunfs\", \"~BUN\", or \"%7EBUN\" (Bun's virtual filesystem path)\n */\nexport const isBunBinary =\n\timport.meta.url.includes(\"$bunfs\") || import.meta.url.includes(\"~BUN\") || import.meta.url.includes(\"%7EBUN\");\n\ninterface PackageJson {\n\tversion?: string;\n}\n\nfunction getPackageJsonPath(): string {\n\tlet dir = __dirname;\n\twhile (dir !== dirname(dir)) {\n\t\tconst packageJsonPath = join(dir, \"package.json\");\n\t\tif (existsSync(packageJsonPath)) {\n\t\t\treturn packageJsonPath;\n\t\t}\n\t\tdir = dirname(dir);\n\t}\n\treturn join(__dirname, \"package.json\");\n}\n\nlet pkg: PackageJson = {};\ntry {\n\tpkg = JSON.parse(readFileSync(getPackageJsonPath(), \"utf-8\")) as PackageJson;\n} catch (e: unknown) {\n\tconst err = e as NodeJS.ErrnoException;\n\tif (err.code !== \"ENOENT\") throw e;\n}\n\nexport const VERSION: string = pkg.version || \"0.0.0\";\n\nexport function getServerDir(): string {\n\tconst envDir = process.env[ENV_SERVER_DIR];\n\tif (envDir) {\n\t\treturn envDir;\n\t}\n\n\tconst piDir = process.env.PI_CONFIG_DIR || join(homedir(), CONFIG_DIR_NAME);\n\treturn join(piDir, \"server\");\n}\n\nexport function getAuthPath(): string {\n\treturn join(getServerDir(), \"auth.json\");\n}\n\nexport function getMachinePath(): string {\n\treturn join(getServerDir(), \"machine.json\");\n}\n\nexport function getInstancesPath(): string {\n\treturn join(getServerDir(), \"instances.json\");\n}\n\nexport function getSocketPath(): string {\n\treturn join(getServerDir(), \"server.sock\");\n}\n"]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
const CONFIG_DIR_NAME = ".pi";
|
|
6
|
+
const ENV_SERVER_DIR = "PI_SERVER_DIR";
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
9
|
+
/**
|
|
10
|
+
* Detect if we're running as a Bun compiled binary.
|
|
11
|
+
* Bun binaries have import.meta.url containing "$bunfs", "~BUN", or "%7EBUN" (Bun's virtual filesystem path)
|
|
12
|
+
*/
|
|
13
|
+
export const isBunBinary = import.meta.url.includes("$bunfs") || import.meta.url.includes("~BUN") || import.meta.url.includes("%7EBUN");
|
|
14
|
+
function getPackageJsonPath() {
|
|
15
|
+
let dir = __dirname;
|
|
16
|
+
while (dir !== dirname(dir)) {
|
|
17
|
+
const packageJsonPath = join(dir, "package.json");
|
|
18
|
+
if (existsSync(packageJsonPath)) {
|
|
19
|
+
return packageJsonPath;
|
|
20
|
+
}
|
|
21
|
+
dir = dirname(dir);
|
|
22
|
+
}
|
|
23
|
+
return join(__dirname, "package.json");
|
|
24
|
+
}
|
|
25
|
+
let pkg = {};
|
|
26
|
+
try {
|
|
27
|
+
pkg = JSON.parse(readFileSync(getPackageJsonPath(), "utf-8"));
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
const err = e;
|
|
31
|
+
if (err.code !== "ENOENT")
|
|
32
|
+
throw e;
|
|
33
|
+
}
|
|
34
|
+
export const VERSION = pkg.version || "0.0.0";
|
|
35
|
+
export function getServerDir() {
|
|
36
|
+
const envDir = process.env[ENV_SERVER_DIR];
|
|
37
|
+
if (envDir) {
|
|
38
|
+
return envDir;
|
|
39
|
+
}
|
|
40
|
+
const piDir = process.env.PI_CONFIG_DIR || join(homedir(), CONFIG_DIR_NAME);
|
|
41
|
+
return join(piDir, "server");
|
|
42
|
+
}
|
|
43
|
+
export function getAuthPath() {
|
|
44
|
+
return join(getServerDir(), "auth.json");
|
|
45
|
+
}
|
|
46
|
+
export function getMachinePath() {
|
|
47
|
+
return join(getServerDir(), "machine.json");
|
|
48
|
+
}
|
|
49
|
+
export function getInstancesPath() {
|
|
50
|
+
return join(getServerDir(), "instances.json");
|
|
51
|
+
}
|
|
52
|
+
export function getSocketPath() {
|
|
53
|
+
return join(getServerDir(), "server.sock");
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,eAAe,GAAG,KAAK,CAAC;AAC9B,MAAM,cAAc,GAAG,eAAe,CAAC;AAEvC,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GACvB,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CA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,CAAC,CAAC;AAAA,CAC7B;AAED,MAAM,UAAU,WAAW,GAAW;IACrC,OAAO,IAAI,CAAC,YAAY,EAAE,EAAE,WAAW,CAAC,CAAC;AAAA,CACzC;AAED,MAAM,UAAU,cAAc,GAAW;IACxC,OAAO,IAAI,CAAC,YAAY,EAAE,EAAE,cAAc,CAAC,CAAC;AAAA,CAC5C;AAED,MAAM,UAAU,gBAAgB,GAAW;IAC1C,OAAO,IAAI,CAAC,YAAY,EAAE,EAAE,gBAAgB,CAAC,CAAC;AAAA,CAC9C;AAED,MAAM,UAAU,aAAa,GAAW;IACvC,OAAO,IAAI,CAAC,YAAY,EAAE,EAAE,aAAa,CAAC,CAAC;AAAA,CAC3C","sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst CONFIG_DIR_NAME = \".pi\";\nconst ENV_SERVER_DIR = \"PI_SERVER_DIR\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Detect if we're running as a Bun compiled binary.\n * Bun binaries have import.meta.url containing \"$bunfs\", \"~BUN\", or \"%7EBUN\" (Bun's virtual filesystem path)\n */\nexport const isBunBinary =\n\timport.meta.url.includes(\"$bunfs\") || import.meta.url.includes(\"~BUN\") || import.meta.url.includes(\"%7EBUN\");\n\ninterface PackageJson {\n\tversion?: string;\n}\n\nfunction getPackageJsonPath(): string {\n\tlet dir = __dirname;\n\twhile (dir !== dirname(dir)) {\n\t\tconst packageJsonPath = join(dir, \"package.json\");\n\t\tif (existsSync(packageJsonPath)) {\n\t\t\treturn packageJsonPath;\n\t\t}\n\t\tdir = dirname(dir);\n\t}\n\treturn join(__dirname, \"package.json\");\n}\n\nlet pkg: PackageJson = {};\ntry {\n\tpkg = JSON.parse(readFileSync(getPackageJsonPath(), \"utf-8\")) as PackageJson;\n} catch (e: unknown) {\n\tconst err = e as NodeJS.ErrnoException;\n\tif (err.code !== \"ENOENT\") throw e;\n}\n\nexport const VERSION: string = pkg.version || \"0.0.0\";\n\nexport function getServerDir(): string {\n\tconst envDir = process.env[ENV_SERVER_DIR];\n\tif (envDir) {\n\t\treturn envDir;\n\t}\n\n\tconst piDir = process.env.PI_CONFIG_DIR || join(homedir(), CONFIG_DIR_NAME);\n\treturn join(piDir, \"server\");\n}\n\nexport function getAuthPath(): string {\n\treturn join(getServerDir(), \"auth.json\");\n}\n\nexport function getMachinePath(): string {\n\treturn join(getServerDir(), \"machine.json\");\n}\n\nexport function getInstancesPath(): string {\n\treturn join(getServerDir(), \"instances.json\");\n}\n\nexport function getSocketPath(): string {\n\treturn join(getServerDir(), \"server.sock\");\n}\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ServiceStateEncoder } from "@earendil-works/chord";
|
|
2
|
+
import type { ClientMessageDecoder, RpcTarget } from "@earendil-works/pi-protocol";
|
|
3
|
+
import type { MaybePromise, RoutedServerServiceAttachment } from "./types.ts";
|
|
4
|
+
/** An established, authorized ordered byte connection. */
|
|
5
|
+
export interface ByteConnection {
|
|
6
|
+
readonly closed: boolean;
|
|
7
|
+
send(chunk: Uint8Array): Promise<void>;
|
|
8
|
+
close(finalChunk?: Uint8Array): MaybePromise<void>;
|
|
9
|
+
}
|
|
10
|
+
export interface ByteConnectionHandler {
|
|
11
|
+
onData(chunk: Uint8Array): void;
|
|
12
|
+
onClose(): void;
|
|
13
|
+
onError(error: Error): void;
|
|
14
|
+
}
|
|
15
|
+
export type ByteConnectionAcceptor = (connection: ByteConnection) => ByteConnectionHandler;
|
|
16
|
+
export type ConnectionStage = "awaitingHello" | "handshaking" | "ready" | "closing" | "closed";
|
|
17
|
+
export interface ConnectionState {
|
|
18
|
+
connection: ByteConnection;
|
|
19
|
+
decoder: ClientMessageDecoder;
|
|
20
|
+
serviceStateEncoders: Map<string, ServiceStateEncoder>;
|
|
21
|
+
sessionIds: Set<string>;
|
|
22
|
+
/** Sessions this connection opted into for extension_ui events. */
|
|
23
|
+
extensionUiSessions: Set<string>;
|
|
24
|
+
stage: ConnectionStage;
|
|
25
|
+
disconnected: boolean;
|
|
26
|
+
handshake?: Promise<void>;
|
|
27
|
+
handshakeTimeout: NodeJS.Timeout;
|
|
28
|
+
serverServices?: RoutedServerServiceAttachment;
|
|
29
|
+
activeRequests: Map<string, {
|
|
30
|
+
controller: AbortController;
|
|
31
|
+
target: RpcTarget;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
|
34
|
+
export declare function isTerminalConnection(state: ConnectionState): boolean;
|
|
35
|
+
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAEnF,OAAO,KAAK,EAAE,YAAY,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAE9E,0DAA0D;AAC1D,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,KAAK,CAAC,UAAU,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,qBAAqB;IACrC,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IAChC,OAAO,IAAI,IAAI,CAAC;IAChB,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,MAAM,sBAAsB,GAAG,CAAC,UAAU,EAAE,cAAc,KAAK,qBAAqB,CAAC;AAE3F,MAAM,MAAM,eAAe,GAAG,eAAe,GAAG,aAAa,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE/F,MAAM,WAAW,eAAe;IAC/B,UAAU,EAAE,cAAc,CAAC;IAC3B,OAAO,EAAE,oBAAoB,CAAC;IAC9B,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACvD,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACxB,mEAAmE;IACnE,mBAAmB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACjC,KAAK,EAAE,eAAe,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC,OAAO,CAAC;IACjC,cAAc,CAAC,EAAE,6BAA6B,CAAC;IAC/C,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,eAAe,CAAC;QAAC,MAAM,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;CAChF;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAEpE","sourcesContent":["import type { ServiceStateEncoder } from \"@earendil-works/chord\";\nimport type { ClientMessageDecoder, RpcTarget } from \"@earendil-works/pi-protocol\";\n\nimport type { MaybePromise, RoutedServerServiceAttachment } from \"./types.ts\";\n\n/** An established, authorized ordered byte connection. */\nexport interface ByteConnection {\n\treadonly closed: boolean;\n\tsend(chunk: Uint8Array): Promise<void>;\n\tclose(finalChunk?: Uint8Array): MaybePromise<void>;\n}\n\nexport interface ByteConnectionHandler {\n\tonData(chunk: Uint8Array): void;\n\tonClose(): void;\n\tonError(error: Error): void;\n}\n\nexport type ByteConnectionAcceptor = (connection: ByteConnection) => ByteConnectionHandler;\n\nexport type ConnectionStage = \"awaitingHello\" | \"handshaking\" | \"ready\" | \"closing\" | \"closed\";\n\nexport interface ConnectionState {\n\tconnection: ByteConnection;\n\tdecoder: ClientMessageDecoder;\n\tserviceStateEncoders: Map<string, ServiceStateEncoder>;\n\tsessionIds: Set<string>;\n\t/** Sessions this connection opted into for extension_ui events. */\n\textensionUiSessions: Set<string>;\n\tstage: ConnectionStage;\n\tdisconnected: boolean;\n\thandshake?: Promise<void>;\n\thandshakeTimeout: NodeJS.Timeout;\n\tserverServices?: RoutedServerServiceAttachment;\n\tactiveRequests: Map<string, { controller: AbortController; target: RpcTarget }>;\n}\n\nexport function isTerminalConnection(state: ConnectionState): boolean {\n\treturn state.disconnected || state.stage === \"closing\" || state.stage === \"closed\";\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAqCA,MAAM,UAAU,oBAAoB,CAAC,KAAsB,EAAW;IACrE,OAAO,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,QAAQ,CAAC;AAAA,CACnF","sourcesContent":["import type { ServiceStateEncoder } from \"@earendil-works/chord\";\nimport type { ClientMessageDecoder, RpcTarget } from \"@earendil-works/pi-protocol\";\n\nimport type { MaybePromise, RoutedServerServiceAttachment } from \"./types.ts\";\n\n/** An established, authorized ordered byte connection. */\nexport interface ByteConnection {\n\treadonly closed: boolean;\n\tsend(chunk: Uint8Array): Promise<void>;\n\tclose(finalChunk?: Uint8Array): MaybePromise<void>;\n}\n\nexport interface ByteConnectionHandler {\n\tonData(chunk: Uint8Array): void;\n\tonClose(): void;\n\tonError(error: Error): void;\n}\n\nexport type ByteConnectionAcceptor = (connection: ByteConnection) => ByteConnectionHandler;\n\nexport type ConnectionStage = \"awaitingHello\" | \"handshaking\" | \"ready\" | \"closing\" | \"closed\";\n\nexport interface ConnectionState {\n\tconnection: ByteConnection;\n\tdecoder: ClientMessageDecoder;\n\tserviceStateEncoders: Map<string, ServiceStateEncoder>;\n\tsessionIds: Set<string>;\n\t/** Sessions this connection opted into for extension_ui events. */\n\textensionUiSessions: Set<string>;\n\tstage: ConnectionStage;\n\tdisconnected: boolean;\n\thandshake?: Promise<void>;\n\thandshakeTimeout: NodeJS.Timeout;\n\tserverServices?: RoutedServerServiceAttachment;\n\tactiveRequests: Map<string, { controller: AbortController; target: RpcTarget }>;\n}\n\nexport function isTerminalConnection(state: ConnectionState): boolean {\n\treturn state.disconnected || state.stage === \"closing\" || state.stage === \"closed\";\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { RemoteServiceErrorCode } from "@earendil-works/chord";
|
|
2
|
+
type ServerOperationErrorCode = RemoteServiceErrorCode | "wrong_server" | "session_not_found" | "session_ambiguous" | "session_not_attached" | "server_draining";
|
|
3
|
+
export declare const INTERNAL_SERVER_ERROR_MESSAGE = "Internal server error";
|
|
4
|
+
/** A host or lifecycle error that can safely cross the protocol boundary. */
|
|
5
|
+
export declare class ServerError extends Error {
|
|
6
|
+
readonly code: ServerOperationErrorCode;
|
|
7
|
+
constructor(code: ServerOperationErrorCode, message: string);
|
|
8
|
+
}
|
|
9
|
+
export declare class WrongServerError extends ServerError {
|
|
10
|
+
constructor();
|
|
11
|
+
}
|
|
12
|
+
export declare class SessionNotFoundError extends ServerError {
|
|
13
|
+
constructor(message?: string);
|
|
14
|
+
}
|
|
15
|
+
export declare class SessionAmbiguousError extends ServerError {
|
|
16
|
+
constructor();
|
|
17
|
+
}
|
|
18
|
+
export declare class SessionNotAttachedError extends ServerError {
|
|
19
|
+
constructor();
|
|
20
|
+
}
|
|
21
|
+
export declare class ServerDrainingError extends ServerError {
|
|
22
|
+
constructor();
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAEpE,KAAK,wBAAwB,GAC1B,sBAAsB,GACtB,cAAc,GACd,mBAAmB,GACnB,mBAAmB,GACnB,sBAAsB,GACtB,iBAAiB,CAAC;AAErB,eAAO,MAAM,6BAA6B,0BAA0B,CAAC;AAErE,6EAA6E;AAC7E,qBAAa,WAAY,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;IAExC,YAAY,IAAI,EAAE,wBAAwB,EAAE,OAAO,EAAE,MAAM,EAI1D;CACD;AAED,qBAAa,gBAAiB,SAAQ,WAAW;IAChD,cAGC;CACD;AAED,qBAAa,oBAAqB,SAAQ,WAAW;IACpD,YAAY,OAAO,SAA0B,EAG5C;CACD;AAED,qBAAa,qBAAsB,SAAQ,WAAW;IACrD,cAGC;CACD;AAED,qBAAa,uBAAwB,SAAQ,WAAW;IACvD,cAGC;CACD;AAED,qBAAa,mBAAoB,SAAQ,WAAW;IACnD,cAGC;CACD","sourcesContent":["import type { RemoteServiceErrorCode } from \"@earendil-works/chord\";\n\ntype ServerOperationErrorCode =\n\t| RemoteServiceErrorCode\n\t| \"wrong_server\"\n\t| \"session_not_found\"\n\t| \"session_ambiguous\"\n\t| \"session_not_attached\"\n\t| \"server_draining\";\n\nexport const INTERNAL_SERVER_ERROR_MESSAGE = \"Internal server error\";\n\n/** A host or lifecycle error that can safely cross the protocol boundary. */\nexport class ServerError extends Error {\n\treadonly code: ServerOperationErrorCode;\n\n\tconstructor(code: ServerOperationErrorCode, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"ServerError\";\n\t\tthis.code = code;\n\t}\n}\n\nexport class WrongServerError extends ServerError {\n\tconstructor() {\n\t\tsuper(\"wrong_server\", \"Request was addressed to another server\");\n\t\tthis.name = \"WrongServerError\";\n\t}\n}\n\nexport class SessionNotFoundError extends ServerError {\n\tconstructor(message = \"Session was not found\") {\n\t\tsuper(\"session_not_found\", message);\n\t\tthis.name = \"SessionNotFoundError\";\n\t}\n}\n\nexport class SessionAmbiguousError extends ServerError {\n\tconstructor() {\n\t\tsuper(\"session_ambiguous\", \"Session ID matches more than one session\");\n\t\tthis.name = \"SessionAmbiguousError\";\n\t}\n}\n\nexport class SessionNotAttachedError extends ServerError {\n\tconstructor() {\n\t\tsuper(\"session_not_attached\", \"Session is not attached to this client\");\n\t\tthis.name = \"SessionNotAttachedError\";\n\t}\n}\n\nexport class ServerDrainingError extends ServerError {\n\tconstructor() {\n\t\tsuper(\"server_draining\", \"Server is draining\");\n\t\tthis.name = \"ServerDrainingError\";\n\t}\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const INTERNAL_SERVER_ERROR_MESSAGE = "Internal server error";
|
|
2
|
+
/** A host or lifecycle error that can safely cross the protocol boundary. */
|
|
3
|
+
export class ServerError extends Error {
|
|
4
|
+
code;
|
|
5
|
+
constructor(code, message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "ServerError";
|
|
8
|
+
this.code = code;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export class WrongServerError extends ServerError {
|
|
12
|
+
constructor() {
|
|
13
|
+
super("wrong_server", "Request was addressed to another server");
|
|
14
|
+
this.name = "WrongServerError";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export class SessionNotFoundError extends ServerError {
|
|
18
|
+
constructor(message = "Session was not found") {
|
|
19
|
+
super("session_not_found", message);
|
|
20
|
+
this.name = "SessionNotFoundError";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export class SessionAmbiguousError extends ServerError {
|
|
24
|
+
constructor() {
|
|
25
|
+
super("session_ambiguous", "Session ID matches more than one session");
|
|
26
|
+
this.name = "SessionAmbiguousError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export class SessionNotAttachedError extends ServerError {
|
|
30
|
+
constructor() {
|
|
31
|
+
super("session_not_attached", "Session is not attached to this client");
|
|
32
|
+
this.name = "SessionNotAttachedError";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export class ServerDrainingError extends ServerError {
|
|
36
|
+
constructor() {
|
|
37
|
+
super("server_draining", "Server is draining");
|
|
38
|
+
this.name = "ServerDrainingError";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,6BAA6B,GAAG,uBAAuB,CAAC;AAErE,6EAA6E;AAC7E,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC5B,IAAI,CAA2B;IAExC,YAAY,IAA8B,EAAE,OAAe,EAAE;QAC5D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAAA,CACjB;CACD;AAED,MAAM,OAAO,gBAAiB,SAAQ,WAAW;IAChD,cAAc;QACb,KAAK,CAAC,cAAc,EAAE,yCAAyC,CAAC,CAAC;QACjE,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IAAA,CAC/B;CACD;AAED,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IACpD,YAAY,OAAO,GAAG,uBAAuB,EAAE;QAC9C,KAAK,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IAAA,CACnC;CACD;AAED,MAAM,OAAO,qBAAsB,SAAQ,WAAW;IACrD,cAAc;QACb,KAAK,CAAC,mBAAmB,EAAE,0CAA0C,CAAC,CAAC;QACvE,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IAAA,CACpC;CACD;AAED,MAAM,OAAO,uBAAwB,SAAQ,WAAW;IACvD,cAAc;QACb,KAAK,CAAC,sBAAsB,EAAE,wCAAwC,CAAC,CAAC;QACxE,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IAAA,CACtC;CACD;AAED,MAAM,OAAO,mBAAoB,SAAQ,WAAW;IACnD,cAAc;QACb,KAAK,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;QAC/C,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IAAA,CAClC;CACD","sourcesContent":["import type { RemoteServiceErrorCode } from \"@earendil-works/chord\";\n\ntype ServerOperationErrorCode =\n\t| RemoteServiceErrorCode\n\t| \"wrong_server\"\n\t| \"session_not_found\"\n\t| \"session_ambiguous\"\n\t| \"session_not_attached\"\n\t| \"server_draining\";\n\nexport const INTERNAL_SERVER_ERROR_MESSAGE = \"Internal server error\";\n\n/** A host or lifecycle error that can safely cross the protocol boundary. */\nexport class ServerError extends Error {\n\treadonly code: ServerOperationErrorCode;\n\n\tconstructor(code: ServerOperationErrorCode, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"ServerError\";\n\t\tthis.code = code;\n\t}\n}\n\nexport class WrongServerError extends ServerError {\n\tconstructor() {\n\t\tsuper(\"wrong_server\", \"Request was addressed to another server\");\n\t\tthis.name = \"WrongServerError\";\n\t}\n}\n\nexport class SessionNotFoundError extends ServerError {\n\tconstructor(message = \"Session was not found\") {\n\t\tsuper(\"session_not_found\", message);\n\t\tthis.name = \"SessionNotFoundError\";\n\t}\n}\n\nexport class SessionAmbiguousError extends ServerError {\n\tconstructor() {\n\t\tsuper(\"session_ambiguous\", \"Session ID matches more than one session\");\n\t\tthis.name = \"SessionAmbiguousError\";\n\t}\n}\n\nexport class SessionNotAttachedError extends ServerError {\n\tconstructor() {\n\t\tsuper(\"session_not_attached\", \"Session is not attached to this client\");\n\t\tthis.name = \"SessionNotAttachedError\";\n\t}\n}\n\nexport class ServerDrainingError extends ServerError {\n\tconstructor() {\n\t\tsuper(\"server_draining\", \"Server is draining\");\n\t\tthis.name = \"ServerDrainingError\";\n\t}\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AgentSessionEvent, RpcCommand, RpcExtensionUIRequest, RpcExtensionUIResponse, RpcResponse } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { ErrorResponse, ListRequest, ListResponse, RpcBridgeResponse, RpcReadyResponse, RpcRequest, RpcStreamRequest, ServerRequest, ServerResponse, SpawnRequest, SpawnResponse, StatusRequest, StatusResponse, StopRequest, StopResponse } from "./ipc/protocol.ts";
|
|
3
|
+
export declare function handleIpcRequest(request: SpawnRequest): Promise<SpawnResponse | ErrorResponse>;
|
|
4
|
+
export declare function handleIpcRequest(request: ListRequest): Promise<ListResponse | ErrorResponse>;
|
|
5
|
+
export declare function handleIpcRequest(request: StopRequest): Promise<StopResponse | ErrorResponse>;
|
|
6
|
+
export declare function handleIpcRequest(request: StatusRequest): Promise<StatusResponse | ErrorResponse>;
|
|
7
|
+
export declare function handleIpcRequest(request: RpcRequest): Promise<RpcBridgeResponse | ErrorResponse>;
|
|
8
|
+
export declare function handleIpcRequest(request: RpcStreamRequest): Promise<RpcReadyResponse | ErrorResponse>;
|
|
9
|
+
export declare function handleIpcRequest(request: ServerRequest): Promise<ServerResponse>;
|
|
10
|
+
export declare function openRpcStream(instanceId: string, onResponse: (response: RpcResponse) => void, onSessionEvent: (event: AgentSessionEvent) => void, onUiRequest: (request: RpcExtensionUIRequest) => void): {
|
|
11
|
+
handleRequest(request: RpcCommand | RpcExtensionUIResponse): Promise<void>;
|
|
12
|
+
close(): void;
|
|
13
|
+
} | undefined;
|
|
14
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,iBAAiB,EACjB,UAAU,EACV,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,EACX,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EACX,aAAa,EAEb,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,aA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,\n} from \"@earendil-works/pi-coding-agent\";\nimport type {\n\tErrorResponse,\n\tInstanceSummary,\n\tListRequest,\n\tListResponse,\n\tRpcBridgeResponse,\n\tRpcReadyResponse,\n\tRpcRequest,\n\tRpcStreamRequest,\n\tServerRequest,\n\tServerResponse,\n\tSpawnRequest,\n\tSpawnResponse,\n\tStatusRequest,\n\tStatusResponse,\n\tStopRequest,\n\tStopResponse,\n} from \"./ipc/protocol.ts\";\nimport { supervisor } from \"./supervisor.ts\";\nimport type { InstanceRecord } from \"./types.ts\";\n\nfunction toInstanceSummary(instance: InstanceRecord): InstanceSummary {\n\treturn {\n\t\tid: instance.id,\n\t\tstatus: instance.status,\n\t\tcwd: instance.cwd,\n\t\tlabel: instance.label,\n\t\tsessionId: instance.sessionId,\n\t\tsessionFile: instance.sessionFile,\n\t\tradiusPiId: instance.radiusPiId,\n\t};\n}\n\nfunction unknownInstanceError(instanceId: string): ErrorResponse {\n\treturn {\n\t\ttype: \"error\",\n\t\tok: false,\n\t\terror: `Unknown instance: ${instanceId}`,\n\t};\n}\n\n// Overhead types\nexport async function handleIpcRequest(request: SpawnRequest): Promise<SpawnResponse | ErrorResponse>;\nexport async function handleIpcRequest(request: ListRequest): Promise<ListResponse | ErrorResponse>;\nexport async function handleIpcRequest(request: StopRequest): Promise<StopResponse | ErrorResponse>;\nexport async function handleIpcRequest(request: StatusRequest): Promise<StatusResponse | ErrorResponse>;\nexport async function handleIpcRequest(request: RpcRequest): Promise<RpcBridgeResponse | ErrorResponse>;\nexport async function handleIpcRequest(request: RpcStreamRequest): Promise<RpcReadyResponse | ErrorResponse>;\nexport async function handleIpcRequest(request: ServerRequest): Promise<ServerResponse>;\nexport async function handleIpcRequest(request: ServerRequest): Promise<ServerResponse> {\n\tswitch (request.type) {\n\t\tcase \"spawn\": {\n\t\t\tconst instance = await supervisor.spawnInstance({\n\t\t\t\tcwd: request.cwd,\n\t\t\t\tlabel: request.label,\n\t\t\t});\n\t\t\treturn {\n\t\t\t\ttype: \"spawn_result\",\n\t\t\t\tok: true,\n\t\t\t\tinstance: toInstanceSummary(instance),\n\t\t\t};\n\t\t}\n\n\t\tcase \"list\": {\n\t\t\treturn {\n\t\t\t\ttype: \"list_result\",\n\t\t\t\tok: true,\n\t\t\t\tinstances: supervisor.listInstances().map(toInstanceSummary),\n\t\t\t};\n\t\t}\n\n\t\tcase \"status\": {\n\t\t\tconst instance = supervisor.getInstance(request.instanceId);\n\t\t\tif (!instance) {\n\t\t\t\treturn unknownInstanceError(request.instanceId);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ttype: \"status_result\",\n\t\t\t\tok: true,\n\t\t\t\tinstance: toInstanceSummary(instance),\n\t\t\t};\n\t\t}\n\n\t\tcase \"stop\": {\n\t\t\tconst instance = await supervisor.stopInstance(request.instanceId);\n\t\t\tif (!instance) {\n\t\t\t\treturn unknownInstanceError(request.instanceId);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ttype: \"stop_result\",\n\t\t\t\tok: true,\n\t\t\t\tinstanceId: request.instanceId,\n\t\t\t};\n\t\t}\n\n\t\tcase \"rpc\": {\n\t\t\tconst response = await supervisor.handleRpc(request.instanceId, request.command);\n\t\t\tif (!response) {\n\t\t\t\treturn unknownInstanceError(request.instanceId);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ttype: \"rpc_result\",\n\t\t\t\tok: true,\n\t\t\t\tresponse,\n\t\t\t};\n\t\t}\n\n\t\tcase \"rpc_stream\": {\n\t\t\tconst instance = supervisor.getInstance(request.instanceId);\n\t\t\tif (!instance) {\n\t\t\t\treturn unknownInstanceError(request.instanceId);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\ttype: \"rpc_ready\",\n\t\t\t\tok: true,\n\t\t\t\tinstance: toInstanceSummary(instance),\n\t\t\t};\n\t\t}\n\t}\n}\n\nexport function openRpcStream(\n\tinstanceId: string,\n\tonResponse: (response: RpcResponse) => void,\n\tonSessionEvent: (event: AgentSessionEvent) => void,\n\tonUiRequest: (request: RpcExtensionUIRequest) => void,\n):\n\t| {\n\t\t\thandleRequest(request: RpcCommand | RpcExtensionUIResponse): Promise<void>;\n\t\t\tclose(): void;\n\t }\n\t| undefined {\n\tconst handle = supervisor.openRpcStream(instanceId, onSessionEvent, onUiRequest);\n\tif (!handle) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tasync handleRequest(request): Promise<void> {\n\t\t\tif (request.type === \"extension_ui_response\") {\n\t\t\t\thandle.handleUiResponse(request);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst response = await handle.handleRpc(request);\n\t\t\tonResponse(response);\n\t\t},\n\t\tclose(): void {\n\t\t\thandle.close();\n\t\t},\n\t};\n}\n"]}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { supervisor } from "./supervisor.js";
|
|
2
|
+
function toInstanceSummary(instance) {
|
|
3
|
+
return {
|
|
4
|
+
id: instance.id,
|
|
5
|
+
status: instance.status,
|
|
6
|
+
cwd: instance.cwd,
|
|
7
|
+
label: instance.label,
|
|
8
|
+
sessionId: instance.sessionId,
|
|
9
|
+
sessionFile: instance.sessionFile,
|
|
10
|
+
radiusPiId: instance.radiusPiId,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function unknownInstanceError(instanceId) {
|
|
14
|
+
return {
|
|
15
|
+
type: "error",
|
|
16
|
+
ok: false,
|
|
17
|
+
error: `Unknown instance: ${instanceId}`,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export async function handleIpcRequest(request) {
|
|
21
|
+
switch (request.type) {
|
|
22
|
+
case "spawn": {
|
|
23
|
+
const instance = await supervisor.spawnInstance({
|
|
24
|
+
cwd: request.cwd,
|
|
25
|
+
label: request.label,
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
type: "spawn_result",
|
|
29
|
+
ok: true,
|
|
30
|
+
instance: toInstanceSummary(instance),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
case "list": {
|
|
34
|
+
return {
|
|
35
|
+
type: "list_result",
|
|
36
|
+
ok: true,
|
|
37
|
+
instances: supervisor.listInstances().map(toInstanceSummary),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
case "status": {
|
|
41
|
+
const instance = supervisor.getInstance(request.instanceId);
|
|
42
|
+
if (!instance) {
|
|
43
|
+
return unknownInstanceError(request.instanceId);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
type: "status_result",
|
|
47
|
+
ok: true,
|
|
48
|
+
instance: toInstanceSummary(instance),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
case "stop": {
|
|
52
|
+
const instance = await supervisor.stopInstance(request.instanceId);
|
|
53
|
+
if (!instance) {
|
|
54
|
+
return unknownInstanceError(request.instanceId);
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
type: "stop_result",
|
|
58
|
+
ok: true,
|
|
59
|
+
instanceId: request.instanceId,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
case "rpc": {
|
|
63
|
+
const response = await supervisor.handleRpc(request.instanceId, request.command);
|
|
64
|
+
if (!response) {
|
|
65
|
+
return unknownInstanceError(request.instanceId);
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
type: "rpc_result",
|
|
69
|
+
ok: true,
|
|
70
|
+
response,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
case "rpc_stream": {
|
|
74
|
+
const instance = supervisor.getInstance(request.instanceId);
|
|
75
|
+
if (!instance) {
|
|
76
|
+
return unknownInstanceError(request.instanceId);
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
type: "rpc_ready",
|
|
80
|
+
ok: true,
|
|
81
|
+
instance: toInstanceSummary(instance),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export function openRpcStream(instanceId, onResponse, onSessionEvent, onUiRequest) {
|
|
87
|
+
const handle = supervisor.openRpcStream(instanceId, onSessionEvent, onUiRequest);
|
|
88
|
+
if (!handle) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
async handleRequest(request) {
|
|
93
|
+
if (request.type === "extension_ui_response") {
|
|
94
|
+
handle.handleUiResponse(request);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const response = await handle.handleRpc(request);
|
|
98
|
+
onResponse(response);
|
|
99
|
+
},
|
|
100
|
+
close() {
|
|
101
|
+
handle.close();
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,SAAS,iBAAiB,CAAC,QAAwB,EAAmB;IACrE,OAAO;QACN,EAAE,EAAE,QAAQ,CAAC,EAAE;QACf,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,GAAG,EAAE,QAAQ,CAAC,GAAG;QACjB,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,UAAU,EAAE,QAAQ,CAAC,UAAU;KAC/B,CAAC;AAAA,CACF;AAED,SAAS,oBAAoB,CAAC,UAAkB,EAAiB;IAChE,OAAO;QACN,IAAI,EAAE,OAAO;QACb,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,qBAAqB,UAAU,EAAE;KACxC,CAAC;AAAA,CACF;AAUD,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAAsB,EAA2B;IACvF,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACtB,KAAK,OAAO,EAAE,CAAC;YACd,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,aAAa,CAAC;gBAC/C,GAAG,EAAE,OAAO,CAAC,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ensionUIRequest,\n\tRpcExtensionUIResponse,\n\tRpcResponse,\n} from \"@earendil-works/pi-coding-agent\";\nimport type {\n\tErrorResponse,\n\tInstanceSummary,\n\tListRequest,\n\tListResponse,\n\tRpcBridgeResponse,\n\tRpcReadyResponse,\n\tRpcRequest,\n\tRpcStreamRequest,\n\tServerRequest,\n\tServerResponse,\n\tSpawnRequest,\n\tSpawnResponse,\n\tStatusRequest,\n\tStatusResponse,\n\tStopRequest,\n\tStopResponse,\n} from \"./ipc/protocol.ts\";\nimport { supervisor } from \"./supervisor.ts\";\nimport type { InstanceRecord } from \"./types.ts\";\n\nfunction toInstanceSummary(instance: InstanceRecord): InstanceSummary {\n\treturn {\n\t\tid: instance.id,\n\t\tstatus: instance.status,\n\t\tcwd: instance.cwd,\n\t\tlabel: instance.label,\n\t\tsessionId: instance.sessionId,\n\t\tsessionFile: instance.sessionFile,\n\t\tradiusPiId: instance.radiusPiId,\n\t};\n}\n\nfunction unknownInstanceError(instanceId: string): ErrorResponse {\n\treturn {\n\t\ttype: \"error\",\n\t\tok: false,\n\t\terror: `Unknown instance: ${instanceId}`,\n\t};\n}\n\n// Overhead types\nexport async function handleIpcRequest(request: SpawnRequest): Promise<SpawnResponse | ErrorResponse>;\nexport async function handleIpcRequest(request: ListRequest): Promise<ListResponse | ErrorResponse>;\nexport async function handleIpcRequest(request: StopRequest): Promise<StopResponse | ErrorResponse>;\nexport async function handleIpcRequest(request: StatusRequest): Promise<StatusResponse | ErrorResponse>;\nexport async function handleIpcRequest(request: RpcRequest): Promise<RpcBridgeResponse | ErrorResponse>;\nexport async function handleIpcRequest(request: RpcStreamRequest): Promise<RpcReadyResponse | ErrorResponse>;\nexport async function handleIpcRequest(request: ServerRequest): Promise<ServerResponse>;\nexport async function handleIpcRequest(request: ServerRequest): Promise<ServerResponse> {\n\tswitch (request.type) {\n\t\tcase \"spawn\": {\n\t\t\tconst instance = await supervisor.spawnInstance({\n\t\t\t\tcwd: request.cwd,\n\t\t\t\tlabel: request.label,\n\t\t\t});\n\t\t\treturn {\n\t\t\t\ttype: \"spawn_result\",\n\t\t\t\tok: true,\n\t\t\t\tinstance: toInstanceSummary(instance),\n\t\t\t};\n\t\t}\n\n\t\tcase \"list\": {\n\t\t\treturn {\n\t\t\t\ttype: \"list_result\",\n\t\t\t\tok: true,\n\t\t\t\tinstances: supervisor.listInstances().map(toInstanceSummary),\n\t\t\t};\n\t\t}\n\n\t\tcase \"status\": {\n\t\t\tconst instance = supervisor.getInstance(request.instanceId);\n\t\t\tif (!instance) {\n\t\t\t\treturn unknownInstanceError(request.instanceId);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ttype: \"status_result\",\n\t\t\t\tok: true,\n\t\t\t\tinstance: toInstanceSummary(instance),\n\t\t\t};\n\t\t}\n\n\t\tcase \"stop\": {\n\t\t\tconst instance = await supervisor.stopInstance(request.instanceId);\n\t\t\tif (!instance) {\n\t\t\t\treturn unknownInstanceError(request.instanceId);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ttype: \"stop_result\",\n\t\t\t\tok: true,\n\t\t\t\tinstanceId: request.instanceId,\n\t\t\t};\n\t\t}\n\n\t\tcase \"rpc\": {\n\t\t\tconst response = await supervisor.handleRpc(request.instanceId, request.command);\n\t\t\tif (!response) {\n\t\t\t\treturn unknownInstanceError(request.instanceId);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ttype: \"rpc_result\",\n\t\t\t\tok: true,\n\t\t\t\tresponse,\n\t\t\t};\n\t\t}\n\n\t\tcase \"rpc_stream\": {\n\t\t\tconst instance = supervisor.getInstance(request.instanceId);\n\t\t\tif (!instance) {\n\t\t\t\treturn unknownInstanceError(request.instanceId);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\ttype: \"rpc_ready\",\n\t\t\t\tok: true,\n\t\t\t\tinstance: toInstanceSummary(instance),\n\t\t\t};\n\t\t}\n\t}\n}\n\nexport function openRpcStream(\n\tinstanceId: string,\n\tonResponse: (response: RpcResponse) => void,\n\tonSessionEvent: (event: AgentSessionEvent) => void,\n\tonUiRequest: (request: RpcExtensionUIRequest) => void,\n):\n\t| {\n\t\t\thandleRequest(request: RpcCommand | RpcExtensionUIResponse): Promise<void>;\n\t\t\tclose(): void;\n\t }\n\t| undefined {\n\tconst handle = supervisor.openRpcStream(instanceId, onSessionEvent, onUiRequest);\n\tif (!handle) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tasync handleRequest(request): Promise<void> {\n\t\t\tif (request.type === \"extension_ui_response\") {\n\t\t\t\thandle.handleUiResponse(request);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst response = await handle.handleRpc(request);\n\t\t\tonResponse(response);\n\t\t},\n\t\tclose(): void {\n\t\t\thandle.close();\n\t\t},\n\t};\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC","sourcesContent":["export * from \"./errors.ts\";\nexport * from \"./listener.ts\";\nexport * from \"./server.ts\";\nexport * from \"./types.ts\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC","sourcesContent":["export * from \"./errors.ts\";\nexport * from \"./listener.ts\";\nexport * from \"./server.ts\";\nexport * from \"./types.ts\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/ipc/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoC,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAE1G,wBAAsB,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CA0DpF","sourcesContent":["import { createConnection } from \"node:net\";\nimport { getSocketPath } from \"../config.ts\";\nimport { encodeMessage, parseResponseLine, type ServerRequest, type ServerResponse } from \"./protocol.ts\";\n\nexport async function sendIpcRequest(request: ServerRequest): Promise<ServerResponse> {\n\tconst socketPath = getSocketPath();\n\n\treturn new Promise<ServerResponse>((resolve, reject) => {\n\t\tconst socket = createConnection(socketPath);\n\t\tlet buffer = \"\";\n\t\tlet settled = false;\n\n\t\tconst cleanup = () => {\n\t\t\tsocket.removeAllListeners();\n\t\t\tsocket.end();\n\t\t};\n\n\t\tsocket.on(\"connect\", () => {\n\t\t\tsocket.write(encodeMessage(request));\n\t\t});\n\n\t\tsocket.on(\"data\", (chunk: Buffer | string) => {\n\t\t\tbuffer += chunk.toString();\n\t\t\tconst newlineIndex = buffer.indexOf(\"\\n\");\n\t\t\tif (newlineIndex === -1) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst line = buffer.slice(0, newlineIndex).trim();\n\t\t\tif (!line) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tsettled = true;\n\t\t\t\tresolve(parseResponseLine(line));\n\t\t\t\tcleanup();\n\t\t\t} catch (error) {\n\t\t\t\tsettled = true;\n\t\t\t\treject(error);\n\t\t\t\tcleanup();\n\t\t\t}\n\t\t});\n\n\t\tsocket.on(\"error\", (error) => {\n\t\t\tif (settled) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsettled = true;\n\t\t\treject(error);\n\t\t\tcleanup();\n\t\t});\n\n\t\tsocket.on(\"end\", () => {\n\t\t\tif (settled) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsettled = true;\n\t\t\treject(new Error(`Server socket closed before a response was received: ${socketPath}`));\n\t\t\tcleanup();\n\t\t});\n\t});\n}\n"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createConnection } from "node:net";
|
|
2
|
+
import { getSocketPath } from "../config.js";
|
|
3
|
+
import { encodeMessage, parseResponseLine } from "./protocol.js";
|
|
4
|
+
export async function sendIpcRequest(request) {
|
|
5
|
+
const socketPath = getSocketPath();
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
const socket = createConnection(socketPath);
|
|
8
|
+
let buffer = "";
|
|
9
|
+
let settled = false;
|
|
10
|
+
const cleanup = () => {
|
|
11
|
+
socket.removeAllListeners();
|
|
12
|
+
socket.end();
|
|
13
|
+
};
|
|
14
|
+
socket.on("connect", () => {
|
|
15
|
+
socket.write(encodeMessage(request));
|
|
16
|
+
});
|
|
17
|
+
socket.on("data", (chunk) => {
|
|
18
|
+
buffer += chunk.toString();
|
|
19
|
+
const newlineIndex = buffer.indexOf("\n");
|
|
20
|
+
if (newlineIndex === -1) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const line = buffer.slice(0, newlineIndex).trim();
|
|
24
|
+
if (!line) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
settled = true;
|
|
29
|
+
resolve(parseResponseLine(line));
|
|
30
|
+
cleanup();
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
settled = true;
|
|
34
|
+
reject(error);
|
|
35
|
+
cleanup();
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
socket.on("error", (error) => {
|
|
39
|
+
if (settled) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
settled = true;
|
|
43
|
+
reject(error);
|
|
44
|
+
cleanup();
|
|
45
|
+
});
|
|
46
|
+
socket.on("end", () => {
|
|
47
|
+
if (settled) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
settled = true;
|
|
51
|
+
reject(new Error(`Server socket closed before a response was received: ${socketPath}`));
|
|
52
|
+
cleanup();
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=client.js.map
|