dal-code 1.0.44 → 1.0.45
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 +27 -0
- package/NOTICE +17 -0
- package/PRIVACY.md +159 -102
- package/dal-docs/README.md +1 -1
- package/dal-docs/keybindings.md +1 -0
- package/dal-docs/settings.md +5 -0
- package/dist/cli/credential-print.js +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.js +1 -1
- package/dist/core/agent-session-runtime.js +1 -1
- package/dist/core/agent-session.d.ts +1 -1
- package/dist/core/agent-session.js +5 -5
- package/dist/core/auth-storage.js +1 -1
- package/dist/core/background-processes.js +7 -7
- package/dist/core/export-html/template.js +34 -34
- package/dist/core/extensions/runner.js +1 -1
- package/dist/core/extensions/types.d.ts +5 -1
- package/dist/core/key-id-schema.js +1 -0
- package/dist/core/keybindings-schema.js +1 -0
- package/dist/core/keybindings.d.ts +5 -0
- package/dist/core/keybindings.js +1 -1
- package/dist/core/model-config.d.ts +818 -99
- package/dist/core/model-config.js +5 -5
- package/dist/core/model-resolver.d.ts +30 -10
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-runtime.d.ts +1 -0
- package/dist/core/model-runtime.js +2 -2
- package/dist/core/package-manager.d.ts +5 -0
- package/dist/core/package-manager.js +2 -2
- package/dist/core/permissions/shell-words.d.ts +26 -0
- package/dist/core/project-trust.js +2 -2
- package/dist/core/prompt-templates.js +2 -2
- package/dist/core/remote-catalog-provider.js +1 -1
- package/dist/core/resource-loader.js +1 -1
- package/dist/core/sandbox/libreoffice.js +1 -0
- package/dist/core/sandbox/runtime.d.ts +1 -0
- package/dist/core/sandbox/runtime.js +1 -1
- package/dist/core/sandbox/shell-sandbox.js +6 -6
- package/dist/core/sandbox/windows.js +4 -4
- package/dist/core/session-manager.d.ts +1 -0
- package/dist/core/session-manager.js +12 -12
- package/dist/core/settings-defaults.js +1 -0
- package/dist/core/settings-manager.d.ts +5 -0
- package/dist/core/settings-manager.js +1 -1
- package/dist/core/settings-schema.d.ts +229 -0
- package/dist/core/settings-schema.js +1 -0
- package/dist/core/tools/bash-read-only.d.ts +1 -0
- package/dist/core/tools/read.js +12 -12
- package/dist/core/tools/render-utils.d.ts +40 -0
- package/dist/core/tools/render-utils.js +7 -7
- package/dist/core/tools/renderers/read.js +8 -8
- package/dist/core/trust-manager.js +1 -1
- package/dist/core/workspace-lock.d.ts +6 -2
- package/dist/core/workspace-lock.js +3 -3
- package/dist/dal/extension-compat.js +4 -4
- package/dist/dal/hooks/config.d.ts +5 -1
- package/dist/dal/hooks/config.js +1 -1
- package/dist/dal/hooks/extension.js +3 -3
- package/dist/dal/hooks/index.d.ts +1 -1
- package/dist/dal/hooks/index.js +1 -1
- package/dist/dal/i18n.js +1 -1
- package/dist/dal/manifest.js +1 -1
- package/dist/extensions/codemode/execute.js +14 -13
- package/dist/extensions/codemode/index.js +1 -1
- package/dist/extensions/codemode/renderer.js +6 -6
- package/dist/extensions/codemode/tool.d.ts +2 -3
- package/dist/extensions/codemode/tool.js +9 -12
- package/dist/extensions/mcp/cli.js +4 -4
- package/dist/extensions/mcp/index.js +12 -12
- package/dist/extensions/mcp/resources.d.ts +0 -5
- package/dist/extensions/mcp/resources.js +1 -1
- package/dist/extensions/mcp/runtime.d.ts +1 -4
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/extensions/mcp/tools.js +7 -7
- package/dist/extensions/tool-search/tool.js +3 -3
- package/dist/index.d.ts +5 -2
- package/dist/index.js +1 -1
- package/dist/main.js +3 -3
- package/dist/migrations.js +5 -5
- package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
- package/dist/modes/interactive/components/settings-selector.js +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +1 -1
- package/dist/modes/interactive/components/status-indicator.js +1 -1
- package/dist/modes/interactive/components/tree-selector.js +1 -1
- package/dist/modes/interactive/interactive-mode.js +17 -17
- package/dist/modes/interactive/session-share.js +2 -2
- package/dist/modes/interactive/theme/dark.json +1 -1
- package/dist/modes/interactive/theme/light.json +1 -1
- package/dist/modes/interactive/theme/theme-schema.d.ts +18 -0
- package/dist/modes/interactive/theme/theme-schema.js +12 -0
- package/dist/modes/interactive/theme/theme-tokens.d.ts +255 -0
- package/dist/modes/interactive/theme/theme-tokens.js +1 -0
- package/dist/modes/interactive/theme/theme.d.ts +7 -10
- package/dist/modes/interactive/theme/theme.js +5 -5
- package/dist/modes/rpc/rpc-client.d.ts +5 -1
- package/dist/modes/rpc/rpc-client.js +2 -2
- package/dist/modes/rpc/rpc-mode.js +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +20 -0
- package/dist/node_modules/@dalcode/dal-advisor/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-advisor/src/index.js +8 -8
- package/dist/node_modules/@dalcode/dal-awake/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-capabilities/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-capabilities/src/index.js +10 -10
- package/dist/node_modules/@dalcode/dal-codeindex/package.json +34 -0
- package/dist/node_modules/@dalcode/dal-codeindex/src/extract.js +3 -0
- package/dist/node_modules/@dalcode/dal-codeindex/src/format.js +11 -0
- package/dist/node_modules/@dalcode/dal-codeindex/src/index.js +4 -0
- package/dist/node_modules/@dalcode/dal-codeindex/src/indexer.js +1 -0
- package/dist/node_modules/@dalcode/dal-codeindex/src/languages.js +176 -0
- package/dist/node_modules/@dalcode/dal-codeindex/src/project.js +1 -0
- package/dist/node_modules/@dalcode/dal-codeindex/src/query.js +2 -0
- package/dist/node_modules/@dalcode/dal-codeindex/src/runtime.js +1 -0
- package/dist/node_modules/@dalcode/dal-codeindex/src/scan.js +1 -0
- package/dist/node_modules/@dalcode/dal-codeindex/src/semantic.js +2 -0
- package/dist/node_modules/@dalcode/dal-codeindex/src/sqlite.js +1 -0
- package/dist/node_modules/@dalcode/dal-codeindex/src/store.js +33 -0
- package/dist/node_modules/@dalcode/dal-codeindex/src/worker.js +1 -0
- package/dist/node_modules/@dalcode/dal-compat/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-dap/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-goal/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-guard/src/index.js +4 -2
- package/dist/node_modules/@dalcode/dal-guard/src/mode.js +2 -2
- package/dist/node_modules/@dalcode/dal-guard/src/policy.js +1 -0
- package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-learn/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-lsp/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-lsp/src/index.js +12 -10
- package/dist/node_modules/@dalcode/dal-mcp/package.json +7 -5
- package/dist/node_modules/@dalcode/dal-mcp/src/http-client.d.ts +9 -27
- package/dist/node_modules/@dalcode/dal-mcp/src/http-client.js +1 -2
- package/dist/node_modules/@dalcode/dal-mcp/src/index.js +17 -17
- package/dist/node_modules/@dalcode/dal-mcp/src/protocol-client.d.ts +38 -0
- package/dist/node_modules/@dalcode/dal-mcp/src/protocol-client.js +1 -0
- package/dist/node_modules/@dalcode/dal-mcp/src/proxy.js +6 -6
- package/dist/node_modules/@dalcode/dal-mcp/src/resources.js +1 -0
- package/dist/node_modules/@dalcode/dal-mcp/src/stdio-client.d.ts +9 -18
- package/dist/node_modules/@dalcode/dal-mcp/src/stdio-client.js +4 -5
- package/dist/node_modules/@dalcode/dal-mcp/src/types.d.ts +50 -5
- package/dist/node_modules/@dalcode/dal-mcp/src/types.js +1 -1
- package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-office/src/index.d.ts +2 -2
- package/dist/node_modules/@dalcode/dal-office/src/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-office/src/render/docx.js +1 -1
- package/dist/node_modules/@dalcode/dal-office/src/render/pptx.d.ts +8 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/pptx.js +3 -3
- package/dist/node_modules/@dalcode/dal-office/src/render/xlsx.js +1 -1
- package/dist/node_modules/@dalcode/dal-office/src/themes.d.ts +2 -0
- package/dist/node_modules/@dalcode/dal-office/src/themes.js +1 -1
- package/dist/node_modules/@dalcode/dal-office/src/tools/ppt-generate.js +3 -2
- package/dist/node_modules/@dalcode/dal-office/src/tools/ppt-plan.js +2 -2
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +9 -3
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/session-scope.js +1 -0
- package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +9 -3
- package/dist/node_modules/@dalcode/dal-pi-kit/src/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/src/session-scope.js +1 -0
- package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-plugins/src/brand.js +1 -1
- package/dist/node_modules/@dalcode/dal-plugins/src/index.js +11 -11
- package/dist/node_modules/@dalcode/dal-recall/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-remote/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-rewind/src/core.d.ts +0 -1
- package/dist/node_modules/@dalcode/dal-rewind/src/core.js +8 -8
- package/dist/node_modules/@dalcode/dal-rewind/src/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-router/package.json +9 -5
- package/dist/node_modules/@dalcode/dal-router/src/advisor.js +1 -1
- package/dist/node_modules/@dalcode/dal-router/src/commands.js +8 -7
- package/dist/node_modules/@dalcode/dal-router/src/config.d.ts +11 -0
- package/dist/node_modules/@dalcode/dal-router/src/config.js +2 -2
- package/dist/node_modules/@dalcode/dal-router/src/index.js +4 -4
- package/dist/node_modules/@dalcode/dal-router/src/roles/changes.js +5 -0
- package/dist/node_modules/@dalcode/dal-router/src/roles/index.js +13 -0
- package/dist/node_modules/@dalcode/dal-router/src/roles/models.d.ts +50 -0
- package/dist/node_modules/@dalcode/dal-router/src/roles/models.js +1 -0
- package/dist/node_modules/@dalcode/dal-router/src/roles/prompts.js +40 -0
- package/dist/node_modules/@dalcode/dal-router/src/roles/signals.js +2 -0
- package/dist/node_modules/@dalcode/dal-router/src/runtime.d.ts +3 -0
- package/dist/node_modules/@dalcode/dal-router/src/runtime.js +1 -1
- package/dist/node_modules/@dalcode/dal-router/src/subagent.js +1 -1
- package/dist/node_modules/@dalcode/dal-rtk/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-skills/src/bundled/dal-slides/SKILL.md +74 -0
- package/dist/node_modules/@dalcode/dal-skills/src/bundled.js +1 -1
- package/dist/node_modules/@dalcode/dal-skills/src/client.js +1 -1
- package/dist/node_modules/@dalcode/dal-skills/src/index.js +14 -14
- package/dist/node_modules/@dalcode/dal-skills/src/packages.js +3 -3
- package/dist/node_modules/@dalcode/dal-skills/src/search.js +1 -1
- package/dist/node_modules/@dalcode/dal-statusline/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-structured/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-telemetry/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/src/index.js +4 -4
- package/dist/node_modules/@dalcode/dal-usage/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-workflow/LICENSE +27 -0
- package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-workflow/src/index.js +4 -4
- package/dist/node_modules/@dalcode/dal-workflow/src/plan-mode.js +13 -13
- package/dist/node_modules/@dalcode/dal-workflow/src/todo-snapshot.js +2 -0
- package/dist/node_modules/@dalcode/dal-workflow/src/todo.js +4 -4
- package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-ai/README.md +5 -34
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +5 -5
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +4 -4
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +6 -6
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +2 -2
- package/dist/node_modules/@earendil-works/pi-ai/dist/index.d.ts +0 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.d.ts +359 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.js +1 -0
- 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/amazon-bedrock.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/azure.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/cerebras.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.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/github-copilot.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/groq.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/kimi-coding.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.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/openai.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/radius.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/together.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/xai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.d.ts +90 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-api.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/types.d.ts +5 -146
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-codemode/README.md +195 -11
- package/dist/node_modules/@earendil-works/pi-codemode/dist/cloudflare.js +1 -0
- package/dist/node_modules/@earendil-works/pi-codemode/dist/declarations.d.ts +0 -2
- package/dist/node_modules/@earendil-works/pi-codemode/dist/declarations.js +9 -84
- package/dist/node_modules/@earendil-works/pi-codemode/dist/index.d.ts +5 -2
- package/dist/node_modules/@earendil-works/pi-codemode/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-codemode/dist/portable.js +1 -0
- package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/execution.d.ts +29 -0
- package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/execution.js +1 -0
- package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/host.d.ts +3 -16
- package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/host.js +1 -1
- package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/inline.d.ts +13 -0
- package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/inline.js +1 -0
- package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/prelude-source.js +14 -6
- package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/protocol.d.ts +72 -0
- package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/protocol.js +1 -1
- package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/remote.d.ts +32 -0
- package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/remote.js +1 -0
- package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/vm.js +3 -0
- package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/worker.js +1 -3
- package/dist/node_modules/@earendil-works/pi-codemode/dist/source.js +4 -3
- package/dist/node_modules/@earendil-works/pi-codemode/dist/types.d.ts +51 -1
- package/dist/node_modules/@earendil-works/pi-codemode/package.json +14 -2
- package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/CHANGELOG.md +13 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/client.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/index.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.d.ts +2 -2
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/protocol/content.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/streamable-http.d.ts +2 -2
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/streamable-http.js +4 -4
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/transport.d.ts +4 -1
- package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/README.md +5 -3
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/editor.js +6 -6
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/input.js +2 -2
- package/dist/node_modules/@earendil-works/pi-tui/dist/index.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/keys.js +5 -5
- package/dist/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js +3 -3
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +4 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui.js +2 -2
- package/dist/node_modules/@earendil-works/pi-tui/dist/utils.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/dist/sdk/index.d.ts +3 -3
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/rewind.d.ts +1 -1
- package/dist/sdk/rewind.js +1 -1
- package/dist/utils/clipboard.js +1 -1
- package/dist/utils/output-files.js +1 -1
- package/dist/utils/temp-files.js +1 -0
- package/docs/security.md +24 -7
- package/examples/README.md +0 -3
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/dynamic-resources/dynamic.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/minimal-mode.ts +4 -5
- package/examples/extensions/overlay-test.ts +2 -2
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/subagent/index.ts +4 -6
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +9 -460
- package/package.json +3 -12
- package/dist/modes/interactive/theme/theme-json.d.ts +0 -75
- package/dist/modes/interactive/theme/theme-json.js +0 -12
- package/dist/modes/interactive/theme/theme-schema.json +0 -361
- package/dist/node_modules/@earendil-works/chord/README.md +0 -264
- package/dist/node_modules/@earendil-works/chord/dist/api.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/bundler.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/context/index.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/delta/apply-immutable-trusted.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/delta/diff.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/delta/draft.js +0 -0
- package/dist/node_modules/@earendil-works/chord/dist/delta/index.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/delta/revision-validator.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/delta/tracker.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/facets/host.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/facets/loader.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/index.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/json.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/node/bundle-loader.js +0 -2
- package/dist/node_modules/@earendil-works/chord/dist/node/bundle.js +0 -4
- package/dist/node_modules/@earendil-works/chord/dist/node/manifest.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/node/package.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/node.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/services/consumer.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/services/errors.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/services/handle.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/services/instances.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/services/loopback.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/services/provider.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/services/state-codec.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/services/state-internals.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/services/state.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/services/wire.js +0 -1
- package/dist/node_modules/@earendil-works/chord/dist/types.js +0 -0
- package/dist/node_modules/@earendil-works/chord/package.json +0 -62
- package/dist/node_modules/@earendil-works/chord/src/delta/README.md +0 -191
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/assistant-message-frame.d.ts +0 -63
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/assistant-message-frame.js +0 -1
- package/dist/node_modules/@earendil-works/pi-client/CHANGELOG.md +0 -45
- package/dist/node_modules/@earendil-works/pi-client/LICENSE +0 -21
- package/dist/node_modules/@earendil-works/pi-client/README.md +0 -72
- package/dist/node_modules/@earendil-works/pi-client/dist/client.js +0 -1
- package/dist/node_modules/@earendil-works/pi-client/dist/connection.js +0 -1
- package/dist/node_modules/@earendil-works/pi-client/dist/errors.js +0 -1
- package/dist/node_modules/@earendil-works/pi-client/dist/index.js +0 -1
- package/dist/node_modules/@earendil-works/pi-client/dist/promise.js +0 -1
- package/dist/node_modules/@earendil-works/pi-client/dist/transport.js +0 -0
- package/dist/node_modules/@earendil-works/pi-client/dist/types.js +0 -0
- package/dist/node_modules/@earendil-works/pi-client/dist/unix.js +0 -1
- package/dist/node_modules/@earendil-works/pi-client/package.json +0 -46
- package/dist/node_modules/@earendil-works/pi-protocol/LICENSE +0 -21
- package/dist/node_modules/@earendil-works/pi-protocol/README.md +0 -41
- package/dist/node_modules/@earendil-works/pi-protocol/dist/cbor/decoder.js +0 -1
- package/dist/node_modules/@earendil-works/pi-protocol/dist/cbor/encoder.js +0 -1
- package/dist/node_modules/@earendil-works/pi-protocol/dist/cbor/index.js +0 -1
- package/dist/node_modules/@earendil-works/pi-protocol/dist/cbor/options.js +0 -1
- package/dist/node_modules/@earendil-works/pi-protocol/dist/codec.js +0 -1
- package/dist/node_modules/@earendil-works/pi-protocol/dist/framing.js +0 -1
- package/dist/node_modules/@earendil-works/pi-protocol/dist/index.js +0 -1
- package/dist/node_modules/@earendil-works/pi-protocol/dist/protocol.js +0 -1
- package/dist/node_modules/@earendil-works/pi-protocol/dist/schemas.js +0 -1
- package/dist/node_modules/@earendil-works/pi-protocol/package.json +0 -39
- package/dist/node_modules/@earendil-works/pi-server/CHANGELOG.md +0 -81
- package/dist/node_modules/@earendil-works/pi-server/LICENSE +0 -21
- package/dist/node_modules/@earendil-works/pi-server/README.md +0 -63
- package/dist/node_modules/@earendil-works/pi-server/dist/connection.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/errors.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/index.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/listener.js +0 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/server.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/session-router.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/client.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/host.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/index.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/server.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/address.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/index.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/listener.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/preset.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/types.js +0 -0
- package/dist/node_modules/@earendil-works/pi-server/dist/types.js +0 -0
- package/dist/node_modules/@earendil-works/pi-server/package.json +0 -45
- package/examples/plugins/pi-example-plugin/README.md +0 -38
- package/examples/plugins/pi-example-plugin/package.json +0 -10
- package/examples/plugins/pi-example-plugin/src/contract.ts +0 -13
- package/examples/plugins/pi-example-plugin/src/session.ts +0 -24
- package/examples/plugins/pi-example-plugin/src/tui.ts +0 -31
- /package/dist/node_modules/{@earendil-works/chord → @dalcode/dal-codeindex}/LICENSE +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var a=Object.defineProperty;var s=(t,e)=>a(t,"name",{value:e,configurable:!0});function i(t){return{invoke:s((e,c)=>t.invoke(e,c),"invoke"),subscribe:s(async(e,c,o)=>{const n=t.subscribe(e,c,o);return{snapshot:n.snapshot,activate:s(()=>n.activate(),"activate"),close:s(()=>n.close(),"close")}},"subscribe")}}s(i,"createLoopbackServiceTransport");export{i as createLoopbackServiceTransport};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var g=Object.defineProperty;var f=(i,e)=>g(i,"name",{value:e,configurable:!0});import{RemoteServiceError as a}from"./errors.js";import{serviceDeliveryContext as y}from"./state.js";import{getReplicatedStateInternals as _}from"./state-internals.js";import{decodeServiceControlCall as $}from"./wire.js";class z{static{f(this,"RemoteServiceProvider")}#f;#s=new Map;#c=!1;constructor(e){const t=e.map(n=>"service"in n?n:{service:n,mode:"singleton"});for(const{service:n}of t)if("local"in n&&n.local===!0)throw new TypeError(`Local service ${n.id} cannot be published remotely`);const s=t.map(({service:n})=>n.id);if(new Set(s).size!==s.length)throw new TypeError("Remote service catalogue contains duplicate IDs");this.#f=Object.freeze(t.map(({service:n,mode:r})=>Object.freeze({serviceId:n.id,mode:r})));for(const{service:n,mode:r}of t)this.#s.set(n.id,{serviceId:n.id,mode:r,instances:new Map,generations:new Map,subscribers:new Set})}get catalogue(){return this.#f}provide(e,t){this.#t(),this.#r(e),this.#e(e.id);const s=this.#i(e.id,"singleton");if(s.singleton!==void 0)throw new a("service_mode_mismatch",`Remote service ${e.id} already has a provider`);const n=l(s.serviceId,t),r=p(n.members);this.#d(s,r),s.singleton=this.#a(s,n,void 0),s.singletonShape=r}withdraw(e){this.#t(),this.#r(e),this.#e(e.id);const t=this.#i(e.id,"singleton"),s=t.singleton;if(s!==void 0){s.active=!1;for(const n of s.removeMemberListeners)n();delete t.singleton,this.#n(t,{type:"unavailable"})}}validateReplacement(e,t){this.#t(),this.#r(e),this.#e(e.id);const s=this.#i(e.id,"singleton"),n=l(s.serviceId,t);this.#d(s,p(n.members))}replace(e,t){this.#t(),this.#r(e),this.#e(e.id);const s=this.#i(e.id,"singleton"),n=l(s.serviceId,t),r=p(n.members);this.#d(s,r);const o=this.#a(s,n,void 0),c=s.singleton;if(c!==void 0){c.active=!1;for(const d of c.removeMemberListeners)d()}s.singleton=o,s.singletonShape=r,this.#n(s,{type:"replaced",snapshot:this.#o(o)})}use(e){this.#t(),this.#r(e),this.#e(e.id);const t=this.#s.get(e.id);if(t?.mode!=="singleton"||t.singleton===void 0)throw new a("service_not_found",`Remote service ${e.id} has no local provider`);return t.singleton.implementation}spawn(e,t,s){if(this.#t(),this.#r(e),this.#e(e.id),t.length===0)throw new TypeError("Remote service instance key must not be empty");const n=this.#i(e.id,"keyed");if(n.instances.has(t))throw new a("service_mode_mismatch",`Remote service ${e.id} already has a live instance with key ${t}`);const r=(n.generations.get(t)??0)+1;n.generations.set(t,r);const o={key:t,generation:r},c=l(n.serviceId,s),d=this.#a(n,c,o);n.instances.set(t,d),this.#n(n,{type:"spawned",instance:this.#o(d)});let m=!1;return()=>{if(!m&&(m=!0,n.instances.get(t)===d)){d.active=!1;for(const u of d.removeMemberListeners)u();n.instances.delete(t),this.#n(n,{type:"closed",instance:o})}}}async invoke(e,t){this.#t(),this.#e(e.serviceId);const s=this.#s.get(e.serviceId);if(s===void 0)throw new a("service_not_found",`Unknown remote service ${e.serviceId}`);const n=this.#h(s,e.instance),r=n.members.get(e.member);if(r===void 0)throw new a("service_member_not_found",`Unknown remote service member ${e.serviceId}.${e.member}`);if(r.kind!=="method")throw new a("service_member_mismatch",`Remote service member ${e.serviceId}.${e.member} is not a method`);return await Reflect.apply(r.method,n.implementation,[...e.args,t])}subscribe(e,t,s){this.#t(),this.#e(e);const n=this.#i(e,t);if(n.mode==="singleton"&&n.singleton===void 0)throw new a("service_not_found",`Remote service ${e} has no provider`);const r={listener:s,buffer:[],snapshotSequences:new Map,active:!1,draining:!1,terminated:!1,closed:!1};n.subscribers.add(r);const o=this.#m(n);return h(r.snapshotSequences,o.instances),{snapshot:o,activate:f(()=>{r.closed||r.active||(r.active=!0,w(v(r),"Failed to activate remote service subscription"))},"activate"),close:f(()=>{r.closed||(r.closed=!0,r.buffer.length=0,n.subscribers.delete(r))},"close")}}dispose(){if(this.#c)return;this.#c=!0;const e=[];for(const t of this.#s.values()){const s=t.singleton;if(s!==void 0){s.active=!1;for(const n of s.removeMemberListeners)n();delete t.singleton;try{this.#n(t,{type:"unavailable"})}catch(n){e.push(n)}}for(const[n,r]of[...t.instances]){r.active=!1;for(const o of r.removeMemberListeners)o();t.instances.delete(n);try{this.#n(t,{type:"closed",instance:r.address})}catch(o){e.push(o)}}for(const n of t.subscribers)n.active&&!n.draining?(n.closed=!0,n.buffer.length=0):n.terminated=!0;t.subscribers.clear()}if(this.#s.clear(),e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Failed to dispose remote service provider")}#i(e,t){const s=this.#s.get(e);if(s===void 0)throw new a("service_not_found",`Unknown remote service ${e}`);if(s.mode!==t)throw new a("service_mode_mismatch",`Remote service ${e} is ${s.mode}, not ${t}`);return s}#a(e,t,s){const n=[],r={...s===void 0?{}:{address:s},implementation:t.implementation,members:t.members,removeMemberListeners:n,active:!0};for(const[o,c]of t.members)c.kind==="state"&&n.push(c.state.subscribe((d,m,u)=>{r.active&&this.#n(e,{type:"state",...s===void 0?{}:{instance:s},member:o,sequence:m,ops:d},u)}));return r}#d(e,t){const s=e.singletonShape;if(!(s===void 0||R(s,t)))throw new a("service_member_mismatch",`Remote service ${e.serviceId} replacement must preserve its member shape`)}#h(e,t){if(e.mode==="singleton"){if(t!==void 0)throw new a("service_mode_mismatch",`Remote service ${e.serviceId} is singleton`);if(e.singleton===void 0)throw new a("service_not_found",`Remote service ${e.serviceId} has no provider`);return e.singleton}if(t===void 0)throw new a("service_mode_mismatch",`Remote service ${e.serviceId} is keyed`);const s=e.instances.get(t.key);if(s===void 0)throw new a("service_instance_not_found",`Remote service ${e.serviceId} has no instance ${t.key}`);if(s.address?.generation!==t.generation)throw new a("service_stale_instance",`Remote service ${e.serviceId} instance ${t.key} is stale`);return s}#m(e){const t=e.mode==="singleton"?e.singleton?[this.#o(e.singleton)]:[]:[...e.instances.values()].sort((s,n)=>s.address.key.localeCompare(n.address.key)).map(s=>this.#o(s));return{serviceId:e.serviceId,mode:e.mode,instances:t}}#o(e){const t=[];for(const[s,n]of e.members)if(n.kind==="method")t.push({name:s,kind:"method"});else{const r=n.state.snapshot();t.push({name:s,kind:"state",sequence:r.sequence,ops:[["r",r.value]]})}return{...e.address===void 0?{}:{instance:e.address},members:t}}#n(e,t,s){if(e.subscribers.size===0)return;const n=s??y(),r=[],o=[...e.subscribers];for(const c of o)if(!(c.closed||S(c.snapshotSequences,t)))if(c.buffer.length===100){const d=this.#m(e);c.buffer.length=0,c.snapshotSequences.clear(),h(c.snapshotSequences,d.instances),c.buffer.push({update:{type:"reset",snapshot:d},context:n})}else c.buffer.push({update:t,context:n});for(const c of o)r.push(...v(c));w(r,`Failed to publish remote service ${e.serviceId} update`)}#r(e){if(e.local)throw new a("service_not_allowed",`Service ${e.id} is process-local`)}#e(e){if(!this.#s.has(e))throw new a("service_not_allowed",`Remote service ${e} is not allowlisted`)}#t(){if(this.#c)throw new Error("Remote service provider is disposed")}}function v(i){if(!i.active||i.closed||i.draining)return[];const e=[];i.draining=!0;try{for(;!i.closed;){const t=i.buffer.shift();if(t===void 0)break;try{i.listener(t.update,t.context)}catch(s){e.push(s)}}}finally{i.draining=!1,i.terminated&&(i.closed=!0)}return e}f(v,"drainSubscriber");function h(i,e){for(const t of e)for(const s of t.members)s.kind==="state"&&i.set(b(t.instance,s.name),s.sequence)}f(h,"recordSnapshotSequences");function S(i,e){switch(e.type){case"state":{const t=b(e.instance,e.member),s=i.get(t);return s===void 0?!1:e.sequence<=s?!0:(i.delete(t),!1)}case"reset":return i.clear(),h(i,e.snapshot.instances),!1;case"replaced":return i.clear(),h(i,[e.snapshot]),!1;case"spawned":return h(i,[e.instance]),!1;case"unavailable":return i.clear(),!1;case"closed":{const t=`${JSON.stringify([e.instance.key,e.instance.generation]).slice(0,-1)},`;for(const s of i.keys())s.startsWith(t)&&i.delete(s);return!1}}}f(S,"updateCoveredBySnapshot");function b(i,e){return JSON.stringify(i===void 0?[e]:[i.key,i.generation,e])}f(b,"stateMemberKey");function C(i){const e=new Map;let t=!1;return{async invoke(s,n,r){if(t)throw new Error("Remote service endpoint is disposed");const o=$(s);if(o?.type==="catalogue")return i.catalogue;if(o?.type==="subscribe"){if(e.has(o.subscriptionId))throw new Error("Service subscription ID is already active");const c=i.subscribe(o.serviceId,o.mode,(d,m)=>{Promise.resolve(n(o.subscriptionId,d,m)).catch(()=>{})});return e.set(o.subscriptionId,c),c.activate(),c.snapshot}if(o?.type==="unsubscribe"){const c=e.get(o.subscriptionId);if(c===void 0)throw new Error("Service subscription was not found");c.close(),e.delete(o.subscriptionId);return}return i.invoke(s,r)},dispose(){if(!t){t=!0;for(const s of e.values())s.close();e.clear()}}}}f(C,"createRemoteServiceEndpoint");function L(i,e){l(i,e)}f(L,"validateRemoteServiceImplementation");function l(i,e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError(`Remote service ${i} implementation must be an object`);const t=new Map;for(const s of Object.keys(e).sort()){const n=Object.getOwnPropertyDescriptor(e,s);if(n===void 0||!("value"in n))throw new TypeError(`Remote service member ${i}.${s} must be a data property`);if(typeof n.value=="function"){t.set(s,{kind:"method",method:n.value});continue}const r=_(n.value);if(r!==void 0){t.set(s,{kind:"state",state:r});continue}throw new TypeError(`Remote service member ${i}.${s} is not remotely exposable`)}if(t.size===0)throw new TypeError(`Remote service ${i} has no members`);return{implementation:e,members:t}}f(l,"classifyRemoteServiceImplementation");function w(i,e){if(i.length===1)throw i[0];if(i.length>1)throw new AggregateError(i,e)}f(w,"throwCollectedErrors");function p(i){return new Map([...i].map(([e,t])=>[e,t.kind]))}f(p,"serviceMemberShape");function R(i,e){return i.size===e.size&&[...i].every(([t,s])=>e.get(t)===s)}f(R,"sameServiceMemberShape");export{z as RemoteServiceProvider,C as createRemoteServiceEndpoint,L as validateRemoteServiceImplementation};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var f=Object.defineProperty;var t=(n,e)=>f(n,"name",{value:e,configurable:!0});import{decoder as l,encoder as w}from"../delta/index.js";class i{static{t(this,"StateCodecRegistry")}#n;#e=new Map;constructor(e){this.#n=e}reset(){this.#e.clear()}add(e,s){const r=d(e,s);if(this.#e.has(r))throw new Error(`Duplicate service state ${h(e,s)}`);const a=this.#n();return this.#e.set(r,{instance:e,codec:a}),a}get(e,s){const r=this.#e.get(d(e,s))?.codec;if(r===void 0)throw new Error(`Unknown service state ${h(e,s)}`);return r}removeInstance(e){for(const[s,r]of this.#e)y(r.instance,e)&&this.#e.delete(s)}}function k(){const n=new i(w);return{encodeSnapshot(e){return n.reset(),{...e,instances:e.instances.map(s=>c(s,n))}},encodeUpdate(e){switch(e.type){case"reset":return n.reset(),{...e,snapshot:{...e.snapshot,instances:e.snapshot.instances.map(s=>c(s,n))}};case"state":return{...e,ops:n.get(e.instance,e.member).encode(e.ops)};case"replaced":return n.reset(),{...e,snapshot:c(e.snapshot,n)};case"spawned":return{...e,instance:c(e.instance,n)};case"unavailable":return n.reset(),e;case"closed":return n.removeInstance(e.instance),e}}}}t(k,"createServiceStateEncoder");function p(){const n=new i(l);return{decodeSnapshot(e){return n.reset(),{...e,instances:e.instances.map(s=>o(s,n))}},decodeUpdate(e){switch(e.type){case"reset":return n.reset(),{...e,snapshot:{...e.snapshot,instances:e.snapshot.instances.map(s=>o(s,n))}};case"state":return{...e,ops:n.get(e.instance,e.member).decode(e.ops)};case"replaced":return n.reset(),{...e,snapshot:o(e.snapshot,n)};case"spawned":return{...e,instance:o(e.instance,n)};case"unavailable":return n.reset(),e;case"closed":return n.removeInstance(e.instance),e}}}}t(p,"createServiceStateDecoder");function c(n,e){return{...n,members:n.members.map(s=>s.kind==="state"?{...s,ops:e.add(n.instance,s.name).encode(s.ops)}:s)}}t(c,"encodeInstance");function o(n,e){return{...n,members:n.members.map(s=>s.kind==="state"?{...s,ops:e.add(n.instance,s.name).decode(s.ops)}:s)}}t(o,"decodeInstance");function d(n,e){return JSON.stringify([n?.key??null,n?.generation??null,e])}t(d,"stateKey");function y(n,e){return n?.key===e.key&&n.generation===e.generation}t(y,"sameAddress");function h(n,e){return n===void 0?e:`${n.key}@${n.generation}.${e}`}t(h,"describeState");export{p as createServiceStateDecoder,k as createServiceStateEncoder};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var o=Object.defineProperty;var n=(e,t)=>o(e,"name",{value:t,configurable:!0});const r=new WeakMap;function i(e,t){r.set(e,t)}n(i,"registerReplicatedStateInternals");function s(e){if(!(typeof e!="object"||e===null))return r.get(e)}n(s,"getReplicatedStateInternals");export{s as getReplicatedStateInternals,i as registerReplicatedStateInternals};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var E=Object.defineProperty;var h=(i,t)=>E(i,"name",{value:t,configurable:!0});import{BACKGROUND_CONTEXT as R}from"../context/index.js";import{applyImmutable as l,isBase as m,track as S}from"../delta/index.js";import{JsonRevisionValidator as x}from"../delta/revision-validator.js";import{registerReplicatedStateInternals as d}from"./state-internals.js";class p{static{h(this,"StateSubscriber")}#t;#s;#e=[];#r=!1;#i=!1;#n=!1;constructor(t,e){this.#t=t,this.#s=e}push(t){if(!this.#n){if(this.#e.length===100){const e=this.#i?void 0:this.#e[0];this.#e.length=0,e!==void 0&&this.#e.push(e)}this.#e.push(t)}}drain(){if(!(this.#r||this.#n)){this.#r=!0;for(let t=this.#e.shift();t!==void 0;t=this.#e.shift()){this.#i=!0;try{const e=this.#t(t.value,t.context,t.delivery);if(w(e)){Promise.resolve(e).then(()=>this.#h(),r=>{this.#o(r),this.#h()});return}}catch(e){this.#o(e)}}this.#r=!1}}clear(){this.#e.length=0}close(){this.#n=!0,this.clear()}#h(){this.#r=!1,this.drain()}#o(t){try{this.#s(o(t))}catch(e){c(o(e))}}}class f{static{h(this,"ReplicatedStatePublisher")}#t=new Map;#s;#e=new Set;#r=[];#i;#n=0;#h=!1;constructor(t,e=c){this.#i=t,this.#s=e}get value(){return this.#i}snapshot(){return{value:this.#i,sequence:this.#n}}subscribe(t){const{value:e,sequence:r}=this.snapshot(),s=new p(t,this.#s);return this.#t.set(s,r),s.push({value:e,context:b(),delivery:{kind:"hydrate",sequence:r}}),s.drain(),()=>{s.close(),this.#t.delete(s)}}subscribeSource(t){return this.#e.add(t),()=>this.#e.delete(t)}publish(t,e,r){if(this.#i=t,this.#n+=1,this.#r.push({value:t,ops:e,sequence:this.#n,context:r}),this.#h)return[];this.#h=!0;const s=[];try{for(let n=this.#r.shift();n!==void 0;n=this.#r.shift()){for(const a of[...this.#e])try{a(n.ops,n.sequence,n.context)}catch(u){s.push(u)}const y={kind:"update",sequence:n.sequence};for(const[a,u]of[...this.#t])n.sequence<=u||(a.push({value:n.value,context:n.context,delivery:y}),a.drain())}}finally{this.#h=!1}return s}}class T{static{h(this,"MutableReplicatedStateImpl")}#t;#s;#e=!1;constructor(t){this.#t=S(t),this.#s=new f(this.#t.value),d(this,{snapshot:h(()=>this.#s.snapshot(),"snapshot"),subscribe:h(e=>this.#s.subscribeSource(e),"subscribe")})}get value(){return this.#t.value}change(t,e){if(this.#e)throw new Error("Replicated state cannot be changed reentrantly from a change callback");this.#e=!0;let r;try{const s=this.#t.beginChange();try{const n=e(s.state);if(w(n))throw Promise.resolve(n).catch(()=>{}),new TypeError("Replicated state change callbacks must be synchronous");r=s.prepare()}catch(n){throw s.abort(),n}}finally{this.#e=!1}this.#t.adopt(r),r.ops.length!==0&&v(this.#s.publish(r.value,r.ops,t),"Replicated state listeners failed")}replace(t,e){if(this.#e)throw new Error("Replicated state cannot be replaced from a change callback");const r=this.#t.prepareReplace(e);this.#t.adopt(r),r.ops.length!==0&&v(this.#s.publish(r.value,r.ops,t),"Replicated state listeners failed")}subscribe(t){return this.#s.subscribe(t)}}class k{static{h(this,"AttachedReplicatedStateImpl")}#t;#s;#e;#r;#i=!1;constructor(t,e){const{snapshot:r}=t;g(r.cursor,"snapshot"),this.#s=t,this.#r=r.cursor,this.#e=e.onError??c,this.#t=new f(r.value,s=>this.#o(s)),d(this,{snapshot:h(()=>this.#t.snapshot(),"snapshot"),subscribe:h(s=>this.#t.subscribeSource(s),"subscribe")})}get value(){return this.#t.value}subscribe(t){return this.#t.subscribe(t)}activate(){this.#s.activate(t=>this.#n(t))}dispose(){this.#i||(this.#i=!0,this.#s.dispose())}#n(t){if(!this.#i)try{g(t.cursor,"frame");const e=this.#r+1;if(t.cursor!==e)throw new Error(`Replicated state source cursor has a gap: expected ${e}, received ${t.cursor}`);this.#r=t.cursor;const r=this.#t.publish(t.value,t.ops,t.context);r.length===1?this.#o(r[0]):r.length>1&&this.#o(new AggregateError(r,"Replicated state listeners failed"))}catch(e){this.#h(o(e))}}#h(t){if(!this.#i){this.#i=!0;try{this.#s.dispose()}catch(e){this.#o(new AggregateError([t,e],"Replicated state source contract failed"));return}this.#o(t)}}#o(t){try{this.#e(o(t))}catch(e){c(o(e))}}}function M(i,t={}){const e=i.attach();try{const r=new k(e,t);return r.activate(),r}catch(r){try{e.dispose()}catch(s){throw new AggregateError([r,s],"Failed to attach replicated state source")}throw r}}h(M,"attachReplicatedStateSource");class N{static{h(this,"ReplicatedStateReplica")}#t=new Set;#s;#e=new x;#r;#i;constructor(t){this.#s=t}get value(){return this.#r}subscribe(t){const e=new p(t,this.#s);return this.#t.add(e),this.#r!==void 0&&(e.push({value:this.#r,context:b(),delivery:{kind:"hydrate",sequence:this.#i}}),e.drain()),()=>{e.close(),this.#t.delete(e)}}hydrate(t,e,r){let s;try{if(!m(e))throw new Error("Replicated state snapshot is not a base operation batch");s=this.#e.validate(l(void 0,e))}catch(n){throw this.clear(),n}this.#i=t,this.#r=s,this.#n(r,{kind:"hydrate",sequence:t})}update(t,e,r){if(this.#i===void 0||this.#r===void 0)throw new Error("Replicated state received an update before hydration");if(t!==this.#i+1)throw this.clear(),new Error("Replicated state update sequence has a gap");let s;try{s=this.#e.validate(l(this.#r,e))}catch(n){throw this.clear(),n}this.#i=t,this.#r=s,this.#n(r,{kind:"update",sequence:t})}clear(){this.#r=void 0,this.#i=void 0;for(const t of this.#t)t.clear()}#n(t,e){if(this.#r===void 0)return;const r={value:this.#r,context:t,delivery:e},s=[...this.#t];for(const n of s)n.push(r);for(const n of s)n.drain()}}function b(){return R}h(b,"serviceDeliveryContext");function g(i,t){if(!Number.isSafeInteger(i))throw new TypeError(`Replicated state source ${t} cursor must be a safe integer`)}h(g,"assertCursor");function w(i){return(typeof i=="object"&&i!==null||typeof i=="function")&&typeof i.then=="function"}h(w,"isPromiseLike");function v(i,t){if(i.length===1)throw i[0];if(i.length>1)throw new AggregateError(i,t)}h(v,"throwCollectedErrors");function c(i){queueMicrotask(()=>{throw i})}h(c,"reportErrorAsync");function o(i){return i instanceof Error?i:new Error(String(i))}h(o,"toError");export{T as MutableReplicatedStateImpl,N as ReplicatedStateReplica,M as attachReplicatedStateSource,b as serviceDeliveryContext};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var S=Object.defineProperty;var s=(e,n)=>S(e,"name",{value:n,configurable:!0});import{assertValidOp as y,assertValidWireOp as h}from"../delta/index.js";const d="$chord.service",b="catalogue",I="subscribe",g="unsubscribe";function C(){return{serviceId:d,member:b,args:[]}}s(C,"createServiceCatalogueCall");function T(e,n,r){return{serviceId:d,member:I,args:[e,n,r]}}s(T,"createServiceSubscribeCall");function k(e){return{serviceId:d,member:g,args:[e]}}s(k,"createServiceUnsubscribeCall");function x(e){if(!(e.serviceId!==d||e.instance!==void 0)){if(e.member===b&&e.args.length===0)return{type:"catalogue"};if(e.member===I&&e.args.length===3&&a(e.args[0])&&a(e.args[1])&&(e.args[2]==="singleton"||e.args[2]==="keyed"))return{type:"subscribe",subscriptionId:e.args[0],serviceId:e.args[1],mode:e.args[2]};if(e.member===g&&e.args.length===1&&a(e.args[0]))return{type:"unsubscribe",subscriptionId:e.args[0]}}}s(x,"decodeServiceControlCall");function R(e){const n=p(e,"service call");if(o(n,["serviceId","member","args"],["instance"],"service call"),!a(n.serviceId)||!a(n.member)||!Array.isArray(n.args))throw new TypeError("Invalid service call");return n.instance!==void 0&&u(n.instance),e}s(R,"parseServiceCall");function U(e){if(!Array.isArray(e))throw new TypeError("Invalid service catalogue");const n=new Set;for(const r of e){const t=p(r,"service catalogue entry");if(o(t,["serviceId","mode"],[],"service catalogue entry"),!a(t.serviceId)||!E(t.mode)||n.has(t.serviceId))throw new TypeError("Invalid service catalogue");n.add(t.serviceId)}return e}s(U,"parseServiceCatalogue");function _(e){return f(e,y),e}s(_,"parseServiceSubscriptionSnapshot");function B(e){return f(e,h),e}s(B,"parseWireServiceSubscriptionSnapshot");function M(e){return w(e,y),e}s(M,"parseServiceProviderUpdate");function V(e){return w(e,h),e}s(V,"parseWireServiceProviderUpdate");function f(e,n){const r=p(e,"service subscription snapshot");if(o(r,["serviceId","mode","instances"],[],"service subscription snapshot"),!a(r.serviceId)||!E(r.mode)||!Array.isArray(r.instances))throw new TypeError("Invalid service subscription snapshot");for(const t of r.instances)m(t,n)}s(f,"assertSubscriptionSnapshot");function w(e,n){const r=p(e,"service provider update");switch(r.type){case"state":if(o(r,["type","member","sequence","ops"],["instance"],"state update"),!a(r.member)||!v(r.sequence,1)||!Array.isArray(r.ops))throw new TypeError("Invalid service state update");r.instance!==void 0&&u(r.instance);for(const t of r.ops)n(t);return;case"reset":{o(r,["type","snapshot"],[],"reset update"),f(r.snapshot,n);const t=r.snapshot;for(const i of t.instances)for(const c of i.members)if(c.kind==="state"&&(c.ops.length!==1||c.ops[0]?.[0]!=="r"))throw new TypeError("Service reset must contain full root replacements");return}case"unavailable":o(r,["type"],[],"unavailable update");return;case"replaced":o(r,["type","snapshot"],[],"replacement update"),m(r.snapshot,n);return;case"spawned":o(r,["type","instance"],[],"spawn update"),m(r.instance,n);return;case"closed":o(r,["type","instance"],[],"close update"),u(r.instance);return;default:throw new TypeError("Invalid service provider update")}}s(w,"assertProviderUpdate");function m(e,n){const r=p(e,"service instance snapshot");if(o(r,["members"],["instance"],"service instance snapshot"),r.instance!==void 0&&u(r.instance),!Array.isArray(r.members))throw new TypeError("Invalid service instance snapshot");for(const t of r.members){const i=p(t,"service member snapshot");if(i.kind==="method"){if(o(i,["name","kind"],[],"service method snapshot"),!a(i.name))throw new TypeError("Invalid service method snapshot");continue}if(i.kind==="state"){if(o(i,["name","kind","sequence","ops"],[],"service state snapshot"),!a(i.name)||!v(i.sequence,0)||!Array.isArray(i.ops))throw new TypeError("Invalid service state snapshot");for(const c of i.ops)n(c);continue}throw new TypeError("Invalid service member snapshot")}}s(m,"assertInstance");function u(e){const n=p(e,"service instance address");if(o(n,["key","generation"],[],"service instance address"),!a(n.key)||!v(n.generation,1))throw new TypeError("Invalid service instance address")}s(u,"assertAddress");function p(e,n){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError(`Invalid ${n}`);return e}s(p,"record");function o(e,n,r,t){const i=new Set([...n,...r]);if(n.some(c=>!Object.hasOwn(e,c))||Object.keys(e).some(c=>!i.has(c)))throw new TypeError(`Invalid ${t}`)}s(o,"assertKeys");function a(e){return typeof e=="string"&&e.length>0}s(a,"isId");function E(e){return e==="singleton"||e==="keyed"}s(E,"isMode");function v(e,n){return typeof e=="number"&&Number.isInteger(e)&&e>=n}s(v,"isInteger");export{C as createServiceCatalogueCall,T as createServiceSubscribeCall,k as createServiceUnsubscribeCall,x as decodeServiceControlCall,R as parseServiceCall,U as parseServiceCatalogue,M as parseServiceProviderUpdate,_ as parseServiceSubscriptionSnapshot,V as parseWireServiceProviderUpdate,B as parseWireServiceSubscriptionSnapshot};
|
|
File without changes
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@earendil-works/chord",
|
|
3
|
-
"version": "1.0.44",
|
|
4
|
-
"description": "Application composition runtime for services, replicated state, RPC, and plugins",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./dist/index.js",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"source": "./src/index.ts",
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
|
-
"import": "./dist/index.js"
|
|
13
|
-
},
|
|
14
|
-
"./context": {
|
|
15
|
-
"source": "./src/context/index.ts",
|
|
16
|
-
"types": "./dist/context/index.d.ts",
|
|
17
|
-
"import": "./dist/context/index.js"
|
|
18
|
-
},
|
|
19
|
-
"./delta": {
|
|
20
|
-
"source": "./src/delta/index.ts",
|
|
21
|
-
"types": "./dist/delta/index.d.ts",
|
|
22
|
-
"import": "./dist/delta/index.js"
|
|
23
|
-
},
|
|
24
|
-
"./bundler": {
|
|
25
|
-
"source": "./src/bundler.ts",
|
|
26
|
-
"types": "./dist/bundler.d.ts",
|
|
27
|
-
"import": "./dist/bundler.js"
|
|
28
|
-
},
|
|
29
|
-
"./node": {
|
|
30
|
-
"source": "./src/node.ts",
|
|
31
|
-
"types": "./dist/node.d.ts",
|
|
32
|
-
"import": "./dist/node.js"
|
|
33
|
-
},
|
|
34
|
-
"./package.json": "./package.json"
|
|
35
|
-
},
|
|
36
|
-
"sideEffects": false,
|
|
37
|
-
"files": [
|
|
38
|
-
"dist",
|
|
39
|
-
"README.md",
|
|
40
|
-
"src/delta/README.md"
|
|
41
|
-
],
|
|
42
|
-
"keywords": [
|
|
43
|
-
"application",
|
|
44
|
-
"plugins",
|
|
45
|
-
"rpc",
|
|
46
|
-
"services",
|
|
47
|
-
"state"
|
|
48
|
-
],
|
|
49
|
-
"author": "Earendil Works",
|
|
50
|
-
"license": "MIT",
|
|
51
|
-
"repository": {
|
|
52
|
-
"type": "git",
|
|
53
|
-
"url": "git+https://github.com/earendil-works/pi.git",
|
|
54
|
-
"directory": "packages/chord"
|
|
55
|
-
},
|
|
56
|
-
"engines": {
|
|
57
|
-
"node": ">=22.19.0"
|
|
58
|
-
},
|
|
59
|
-
"dependencies": {
|
|
60
|
-
"esbuild": "0.28.2"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
# Chord Delta
|
|
2
|
-
|
|
3
|
-
Chord Delta produces immutable JSON revisions and exact operation batches for
|
|
4
|
-
ordered replicas. Import it from `@earendil-works/chord/delta`.
|
|
5
|
-
|
|
6
|
-
Immutability is an ownership contract. Nothing is frozen or defensively copied,
|
|
7
|
-
so an illegal mutation is not detected. It silently corrupts state.
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
import { applyImmutable, applyImmutableBatches, track } from "@earendil-works/chord/delta";
|
|
11
|
-
|
|
12
|
-
const initial = { output: "", entries: [] as { id: number }[] };
|
|
13
|
-
const tracker = track(initial); // `initial` is transferred: never mutate it again
|
|
14
|
-
|
|
15
|
-
const change = tracker.beginChange();
|
|
16
|
-
change.state.output += "done\n"; // the draft is mutable only while the change is open
|
|
17
|
-
change.state.entries.push({ id: 1 }); // placed values are cloned; the caller keeps its object
|
|
18
|
-
const prepared = change.prepare(); // draft handles are unusable from here on
|
|
19
|
-
|
|
20
|
-
// tracker.value, prepared.base, prepared.value, and prepared.ops (including paths
|
|
21
|
-
// and payloads) are immutable by contract.
|
|
22
|
-
tracker.adopt(prepared); // tracker.value === prepared.value
|
|
23
|
-
|
|
24
|
-
// Shares containers with prepared.base and the op payloads: never mutate it either.
|
|
25
|
-
const replica = applyImmutable(prepared.base, prepared.ops);
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Mutation rights
|
|
29
|
-
|
|
30
|
-
| Value | May it be mutated? |
|
|
31
|
-
| --- | --- |
|
|
32
|
-
| Root passed to `track()`, `prepareReplace()`, `replicatedState()`, or `replace()` | No. Ownership moved to the tracker. |
|
|
33
|
-
| `change.state` and handles read from it | Yes, only while that change is open. After `prepare()`, `abort()`, or another adoption, every use throws. Writes through a handle whose element was removed from the draft are ignored. |
|
|
34
|
-
| External value after assigning or inserting it into a draft | Yes. The draft stored a validated clone. |
|
|
35
|
-
| `tracker.value`, `prepared.base`, retained older revisions | No. |
|
|
36
|
-
| `prepared.value`, `prepared.ops`, op tuples, paths, permutations, payloads | No. Payloads may be the same objects as parts of `prepared.value`. |
|
|
37
|
-
| `applyImmutable()` / `applyImmutableBatches()` inputs and result | No. The result shares containers with both inputs. |
|
|
38
|
-
| Values from replicated state (`value`, listener values, loopback consumers) | No. In-process consumers may share the provider's containers. |
|
|
39
|
-
| Mutable replica passed to `apply()` | Only through `apply()`, with batches it owns exclusively. Code that edits it between batches breaks convergence. |
|
|
40
|
-
| Batch passed to `apply()` | Consumed. `apply()` adopts payload containers into the replica. Use a detached copy for exactly one replica and never touch it again. |
|
|
41
|
-
|
|
42
|
-
## Replaying batches
|
|
43
|
-
|
|
44
|
-
Immutable replay is the preferred in-process path. One batch can fan out to any
|
|
45
|
-
number of immutable replicas:
|
|
46
|
-
|
|
47
|
-
```ts
|
|
48
|
-
let replica = tracker.value; // shared with authority; never mutated
|
|
49
|
-
// For each adopted batch, in order:
|
|
50
|
-
replica = applyImmutable(replica, prepared.ops); // replica must equal prepared.base
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
When only the final result of an ordered backlog is needed, replay its batches
|
|
54
|
-
without concatenating their operations. One copy-on-write scope is shared across
|
|
55
|
-
the complete call, so no intermediate revision is exposed or safe to retain:
|
|
56
|
-
|
|
57
|
-
```ts
|
|
58
|
-
replica = applyImmutableBatches(
|
|
59
|
-
replica,
|
|
60
|
-
queuedFrames.map((frame) => frame.ops),
|
|
61
|
-
);
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
Use separate `applyImmutable()` calls when every intermediate revision is
|
|
65
|
-
published or retained.
|
|
66
|
-
|
|
67
|
-
Mutable replay needs a detached starting root and a detached copy of every batch
|
|
68
|
-
for every replica. Never apply one in-memory batch to two mutable replicas:
|
|
69
|
-
|
|
70
|
-
```ts
|
|
71
|
-
import { apply } from "@earendil-works/chord/delta";
|
|
72
|
-
|
|
73
|
-
const detach = <T>(value: T): T => JSON.parse(JSON.stringify(value)) as T;
|
|
74
|
-
|
|
75
|
-
let replica = detach(tracker.value); // exclusively owned starting root
|
|
76
|
-
// For each adopted batch, in order:
|
|
77
|
-
replica = apply(replica, detach(prepared.ops)); // fresh copy for this replica only
|
|
78
|
-
// Only apply() may change `replica`; do not edit it in application code.
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
Parsing a separately serialized message per replica is also a valid detachment.
|
|
82
|
-
`decode()` does not copy payloads, so decoding one in-memory `WireOp[]` for two
|
|
83
|
-
mutable replicas makes them alias each other.
|
|
84
|
-
|
|
85
|
-
## Do and don't
|
|
86
|
-
|
|
87
|
-
- Do build a fresh root and then transfer it; validate untrusted roots at your ingestion boundary.
|
|
88
|
-
- Do keep structural sharing between revisions, for example `replace(ctx, { ...state.value, changed })`.
|
|
89
|
-
- Do clone or serialize before handing any published value to code that may mutate it.
|
|
90
|
-
- Do settle every change with `prepare()` or `abort()`.
|
|
91
|
-
- Don't reuse one container at two places in a transferred root.
|
|
92
|
-
- Don't mutate anything the tracker owns, published, or received from a batch.
|
|
93
|
-
- Don't keep draft handles past their change or place a settled handle.
|
|
94
|
-
- Don't infer meaning from op shape. Only the resulting value is contractual.
|
|
95
|
-
|
|
96
|
-
## Roots and placements
|
|
97
|
-
|
|
98
|
-
Full roots are trusted. `track()` and `prepareReplace()` take ownership in O(1)
|
|
99
|
-
and never walk the tree. Roots must be alias-free, acyclic strict JSON: dense
|
|
100
|
-
plain arrays, plain or null-prototype objects with enumerable own data
|
|
101
|
-
properties, strings, booleans, finite numbers, and `null`. Violations have
|
|
102
|
-
unspecified behavior. For example, a container shared by two keys can make
|
|
103
|
-
`prepared.value` diverge from what replicas compute from `prepared.ops`.
|
|
104
|
-
|
|
105
|
-
Draft placements are copied, and that copy walk also validates. Placements come
|
|
106
|
-
from property writes, index writes, `push`, `unshift`, `splice`, `fill`, and
|
|
107
|
-
`copyWithin`. A non-strict value throws `TypeError` before the draft changes;
|
|
108
|
-
for example, `push(valid, invalid)` inserts nothing. Rejected values include:
|
|
109
|
-
cycles, accessors (never invoked), symbol keys, class instances, sparse or
|
|
110
|
-
non-plain arrays, functions, bigint, `NaN`, infinities, and `undefined`.
|
|
111
|
-
Null-prototype objects are accepted and preserved. Placing a draft handle clones
|
|
112
|
-
its current content. Placing one value at several paths yields independent
|
|
113
|
-
containers.
|
|
114
|
-
|
|
115
|
-
`undefined` rules:
|
|
116
|
-
|
|
117
|
-
- `draft.obj.key = undefined` deletes `key`.
|
|
118
|
-
- `arr[i] = undefined`, `push(undefined)`, `unshift`, `splice`, and `fill` with `undefined` throw.
|
|
119
|
-
- `undefined` nested anywhere inside a placed object or array throws. It is not dropped like `JSON.stringify` does.
|
|
120
|
-
|
|
121
|
-
Arrays stay dense. Writing past the next index and deleting an element throw.
|
|
122
|
-
Growing `length` inserts `null`; shrinking it removes elements.
|
|
123
|
-
|
|
124
|
-
## Lifecycle
|
|
125
|
-
|
|
126
|
-
`tracker.value` is the latest adopted revision. `beginChange()` opens an overlay
|
|
127
|
-
draft over it and never modifies it. A draft may stay open across `await`.
|
|
128
|
-
`prepare()` materializes the candidate and ops and does not change authority.
|
|
129
|
-
`adopt()` checks the preparation and swaps the root pointer.
|
|
130
|
-
|
|
131
|
-
Several changes may be open or prepared from one revision. Adopting one makes all
|
|
132
|
-
others stale: open drafts become unusable and their `prepare()` throws, and
|
|
133
|
-
prepared competitors are rejected by `adopt()`. `adopt()` also rejects foreign,
|
|
134
|
-
aborted, and already consumed preparations. `Change.abort()` or
|
|
135
|
-
`Prepared.abort()` after `prepare()` prevents adoption. The candidate stays
|
|
136
|
-
readable.
|
|
137
|
-
|
|
138
|
-
No-op batches:
|
|
139
|
-
|
|
140
|
-
- Empty `ops` means `prepared.value === prepared.base`. Writes restored to their original value and deeply equal container assignments usually normalize to empty.
|
|
141
|
-
- Equality ignores key order and prototype. A deeply equal assignment keeps the previous revision's order and prototype, even if the draft showed the new ones.
|
|
142
|
-
- Structural array edits may emit a nonempty exact batch even when the result is deeply equal.
|
|
143
|
-
- Adopting a no-op still advances `tracker.revision` and stales competitors. Replicated state does not publish no-ops.
|
|
144
|
-
|
|
145
|
-
`prepareReplace(value)` is a whole-root operation, not a diff. If `value` is
|
|
146
|
-
deeply equal to the current root, `ops` is empty and the current root is kept
|
|
147
|
-
(the comparison may traverse both trees). Otherwise `ops` is `[["r", value]]`
|
|
148
|
-
and `prepared.value === value`, so replicas receive the complete root.
|
|
149
|
-
|
|
150
|
-
Array mutators: `push`, `pop`, `shift`, `unshift`, `splice`, `reverse`, `sort`,
|
|
151
|
-
`fill`, and `copyWithin`. Held handles follow elements through reindexing.
|
|
152
|
-
|
|
153
|
-
## Operations
|
|
154
|
-
|
|
155
|
-
Paths contain object keys and non-negative integer array indices.
|
|
156
|
-
|
|
157
|
-
| Tuple | Meaning |
|
|
158
|
-
| --- | --- |
|
|
159
|
-
| `["r", value]` | Replace the complete value. |
|
|
160
|
-
| `["s", path, value]` | Set an object property or array element. |
|
|
161
|
-
| `["d", path]` | Delete an object property or remove an array element. |
|
|
162
|
-
| `["a", path, text]` | Append to a string. |
|
|
163
|
-
| `["t", path, count]` | Remove `count` UTF-16 code units from a string's front. |
|
|
164
|
-
| `["p", path, index, remove, items]` | Splice an array. |
|
|
165
|
-
| `["m", path, permutation]` | Reorder an array: `new[i] = old[permutation[i]]`. |
|
|
166
|
-
|
|
167
|
-
Batches are exact but not canonical. The same change may use different tuples,
|
|
168
|
-
and large edit sets may fold into a region splice, an ancestor `s`, or `r`.
|
|
169
|
-
|
|
170
|
-
Reserved keys: the tracker never emits `__proto__`, `constructor`, or
|
|
171
|
-
`prototype` as a path segment. A mutation at or below such a key is folded into a
|
|
172
|
-
set of the nearest safe ancestor, or `r` at the root. `apply()`, `applyImmutable()`, `applyImmutableBatches()`, and `decoder()` reject
|
|
173
|
-
those segments with `UnsafePathError`.
|
|
174
|
-
The appliers write values as own data properties, never through a prototype setter.
|
|
175
|
-
Appliers check op shape and path safety but not payload strictness. Chord's
|
|
176
|
-
replicated-state replicas validate each resulting revision.
|
|
177
|
-
|
|
178
|
-
`encoder()` interns repeated paths into `WireOp` tuples; `decoder()` validates
|
|
179
|
-
and restores `Op` tuples. Use one encoder/decoder pair per ordered state stream.
|
|
180
|
-
Path IDs span batches and an `r` resets both dictionaries. After a decode or
|
|
181
|
-
apply error, discard the decoder and replica and recover from a later `r`.
|
|
182
|
-
|
|
183
|
-
## Limits and footguns
|
|
184
|
-
|
|
185
|
-
- No freezing. Mutating any immutable value corrupts state silently.
|
|
186
|
-
- Loopback sharing: in-process service consumers may receive the provider's containers. A consumer mutation corrupts authority and makes remote replicas diverge.
|
|
187
|
-
- A change inside a large flat array copies that array's pointer storage for the new revision.
|
|
188
|
-
- Placement validation costs time and memory on bulk inserts. In a benchmark unshifting 100k three-field objects, it added about 19 ms and 20 MiB of transient heap.
|
|
189
|
-
- External proxies as placements, argument coercion callbacks that mutate the draft, non-primitive array indices, and non-numeric comparator results are out of contract. So are sort comparators that mutate, prepare, abort, or adopt. Behavior is unspecified.
|
|
190
|
-
- Object identity is not replicated. Each path is an independent value placement.
|
|
191
|
-
- One tracker is one revision sequence. Delivery order and persistence belong to the surrounding protocol.
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { AssistantMessage, AssistantMessageEvent, TextContent, ThinkingContent, ToolCall } from "../types.ts";
|
|
2
|
-
export type AssistantMessageFrame = {
|
|
3
|
-
type: "start";
|
|
4
|
-
partial: AssistantMessage;
|
|
5
|
-
} | {
|
|
6
|
-
type: "text_start";
|
|
7
|
-
contentIndex: number;
|
|
8
|
-
content: TextContent;
|
|
9
|
-
} | {
|
|
10
|
-
type: "text_delta";
|
|
11
|
-
contentIndex: number;
|
|
12
|
-
delta: string;
|
|
13
|
-
} | {
|
|
14
|
-
type: "text_end";
|
|
15
|
-
contentIndex: number;
|
|
16
|
-
content: string;
|
|
17
|
-
textSignature?: string;
|
|
18
|
-
} | {
|
|
19
|
-
type: "thinking_start";
|
|
20
|
-
contentIndex: number;
|
|
21
|
-
content: ThinkingContent;
|
|
22
|
-
} | {
|
|
23
|
-
type: "thinking_delta";
|
|
24
|
-
contentIndex: number;
|
|
25
|
-
delta: string;
|
|
26
|
-
} | {
|
|
27
|
-
type: "thinking_end";
|
|
28
|
-
contentIndex: number;
|
|
29
|
-
content: string;
|
|
30
|
-
thinkingSignature?: string;
|
|
31
|
-
redacted?: boolean;
|
|
32
|
-
} | {
|
|
33
|
-
type: "toolcall_start";
|
|
34
|
-
contentIndex: number;
|
|
35
|
-
toolCall: ToolCall;
|
|
36
|
-
} | {
|
|
37
|
-
type: "toolcall_checkpoint";
|
|
38
|
-
contentIndex: number;
|
|
39
|
-
json: string;
|
|
40
|
-
} | {
|
|
41
|
-
type: "toolcall_delta";
|
|
42
|
-
contentIndex: number;
|
|
43
|
-
delta: string;
|
|
44
|
-
} | {
|
|
45
|
-
type: "toolcall_end";
|
|
46
|
-
contentIndex: number;
|
|
47
|
-
id: string;
|
|
48
|
-
name: string;
|
|
49
|
-
arguments: ToolCall["arguments"];
|
|
50
|
-
thoughtSignature?: string;
|
|
51
|
-
namespace?: string;
|
|
52
|
-
};
|
|
53
|
-
export declare class AssistantMessageFrameEncoder {
|
|
54
|
-
private started;
|
|
55
|
-
private terminal;
|
|
56
|
-
private readonly blocks;
|
|
57
|
-
encode(event: AssistantMessageEvent): AssistantMessageFrame | undefined;
|
|
58
|
-
private startBlock;
|
|
59
|
-
private block;
|
|
60
|
-
private endBlock;
|
|
61
|
-
private encodeTextDelta;
|
|
62
|
-
}
|
|
63
|
-
export declare function reduceAssistantMessageFrames(frames: Iterable<AssistantMessageFrame>): AssistantMessage | undefined;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var k=Object.defineProperty;var s=(o,t)=>k(o,"name",{value:t,configurable:!0});import{parseStreamingJson as d}from"./json-parse.js";function x(o){return{type:"text",text:o.text,...o.textSignature===void 0?{}:{textSignature:o.textSignature}}}s(x,"cloneTextContent");function w(o){return{type:"thinking",thinking:o.thinking,...o.thinkingSignature===void 0?{}:{thinkingSignature:o.thinkingSignature},...o.redacted===void 0?{}:{redacted:o.redacted}}}s(w,"cloneThinkingContent");function m(o){return{type:"toolCall",id:o.id,name:o.name,arguments:structuredClone(o.arguments),...o.thoughtSignature===void 0?{}:{thoughtSignature:o.thoughtSignature},...o.namespace===void 0?{}:{namespace:o.namespace}}}s(m,"cloneToolCall");function y(o){return{role:"assistant",content:[],api:o.api,provider:o.provider,model:o.model,...o.responseModel===void 0?{}:{responseModel:o.responseModel},...o.responseId===void 0?{}:{responseId:o.responseId},...o.providerThinkingLevel===void 0?{}:{providerThinkingLevel:o.providerThinkingLevel},...o.diagnostics===void 0?{}:{diagnostics:structuredClone(o.diagnostics)},usage:structuredClone(o.usage),stopReason:"pending",timestamp:o.timestamp}}s(y,"cloneStartMessage");function h(o){if(!Number.isSafeInteger(o)||o<0)throw new Error(`Invalid assistant message frame contentIndex: ${o}`)}s(h,"assertContentIndex");function c(o){h(o.contentIndex);const t=o.partial.content[o.contentIndex];if(!t)throw new Error(`${o.type} event has no content block at index ${o.contentIndex}`);return t}s(c,"eventBlock");function u(o){const t=JSON.stringify(o);if(t===void 0)throw new Error("Tool-call arguments are not JSON-serializable");return t}s(u,"serializedArguments");const b=u(d(""));function f(o,t){if(typeof o=="string")return typeof t=="string"&&t.startsWith(o);if(Array.isArray(o))return Array.isArray(t)&&o.length<=t.length&&o.every((a,n)=>f(a,t[n]));if(typeof o!="object"||o===null)return Object.is(o,t);if(typeof t!="object"||t===null||Array.isArray(t))return!1;const e=t;return Object.entries(o).every(([a,n])=>Object.hasOwn(e,a)&&f(n,e[a]))}s(f,"isJsonPrefix");class E{static{s(this,"AssistantMessageFrameEncoder")}started=!1;terminal=!1;blocks=new Map;encode(t){if(this.terminal)throw new Error(`Assistant message event ${t.type} follows a terminal event`);switch(t.type){case"start":if(this.started)throw new Error("Assistant message stream contains more than one start event");return this.started=!0,{type:"start",partial:y(t.partial)};case"done":if(!this.started)throw new Error("Assistant message done event appears before start");this.terminal=!0;return;case"error":this.terminal=!0;return}if(!this.started)throw new Error(`Assistant message ${t.type} event appears before start`);switch(t.type){case"text_start":{const e=c(t);if(e.type!=="text")throw new Error(`text_start event points to ${e.type} block at index ${t.contentIndex}`);return this.startBlock(t.contentIndex,{kind:"text",coveredChars:e.text.length,deltaChars:0}),{type:"text_start",contentIndex:t.contentIndex,content:x(e)}}case"text_delta":return this.encodeTextDelta(t.contentIndex,t.delta,"text");case"text_end":{const e=c(t);if(e.type!=="text")throw new Error(`text_end event points to ${e.type} block at index ${t.contentIndex}`);return this.endBlock(t.contentIndex,"text"),{type:"text_end",contentIndex:t.contentIndex,content:t.content,...e.textSignature===void 0?{}:{textSignature:e.textSignature}}}case"thinking_start":{const e=c(t);if(e.type!=="thinking")throw new Error(`thinking_start event points to ${e.type} block at index ${t.contentIndex}`);return this.startBlock(t.contentIndex,{kind:"thinking",coveredChars:e.thinking.length,deltaChars:0}),{type:"thinking_start",contentIndex:t.contentIndex,content:w(e)}}case"thinking_delta":return this.encodeTextDelta(t.contentIndex,t.delta,"thinking");case"thinking_end":{const e=c(t);if(e.type!=="thinking")throw new Error(`thinking_end event points to ${e.type} block at index ${t.contentIndex}`);return this.endBlock(t.contentIndex,"thinking"),{type:"thinking_end",contentIndex:t.contentIndex,content:t.content,...e.thinkingSignature===void 0?{}:{thinkingSignature:e.thinkingSignature},...e.redacted===void 0?{}:{redacted:e.redacted}}}case"toolcall_start":{const e=c(t);if(e.type!=="toolCall")throw new Error(`toolcall_start event points to ${e.type} block at index ${t.contentIndex}`);const a=u(e.arguments),n=a===b;return this.startBlock(t.contentIndex,{kind:"toolCall",caughtUp:n,catchupJson:"",snapshotArguments:n?"":a}),{type:"toolcall_start",contentIndex:t.contentIndex,toolCall:m(e)}}case"toolcall_delta":{const e=this.block(t.contentIndex,"toolCall");if(e.kind!=="toolCall")throw new Error("Unreachable tool-call encoder state");if(e.caughtUp)return t.delta.length===0?void 0:{type:"toolcall_delta",contentIndex:t.contentIndex,delta:t.delta};e.catchupJson+=t.delta;const a=d(e.catchupJson);if(u(a)!==e.snapshotArguments){const r=d(e.snapshotArguments);if(!f(r,a))return}e.caughtUp=!0,e.snapshotArguments="";const n=e.catchupJson;return e.catchupJson="",n.length===0?void 0:{type:"toolcall_checkpoint",contentIndex:t.contentIndex,json:n}}case"toolcall_end":{const e=c(t);if(e.type!=="toolCall")throw new Error(`toolcall_end event points to ${e.type} block at index ${t.contentIndex}`);if(t.toolCall.type!=="toolCall")throw new Error(`toolcall_end event has invalid tool call at index ${t.contentIndex}`);return this.endBlock(t.contentIndex,"toolCall"),{type:"toolcall_end",contentIndex:t.contentIndex,id:t.toolCall.id,name:t.toolCall.name,arguments:structuredClone(t.toolCall.arguments),...t.toolCall.thoughtSignature===void 0?{}:{thoughtSignature:t.toolCall.thoughtSignature},...t.toolCall.namespace===void 0?{}:{namespace:t.toolCall.namespace}}}}}startBlock(t,e){if(h(t),this.blocks.has(t))throw new Error(`Assistant message block ${t} starts more than once`);this.blocks.set(t,e)}block(t,e){h(t);const a=this.blocks.get(t);if(a===void 0)throw new Error(`Assistant message ${e} block ${t} has not started`);if(a.kind!==e)throw new Error(`Assistant message block ${t} is ${a.kind}, not ${e}`);return a}endBlock(t,e){this.block(t,e),this.blocks.delete(t)}encodeTextDelta(t,e,a){const n=this.block(t,a);if(n.kind==="toolCall")throw new Error("Unreachable text encoder state");const r=n.deltaChars;n.deltaChars+=e.length;const i=Math.max(0,n.coveredChars-r);if(i>=e.length)return;const p=i===0?e:e.slice(i);return a==="text"?{type:"text_delta",contentIndex:t,delta:p}:{type:"thinking_delta",contentIndex:t,delta:p}}}function g(o,t,e,a,n){if(h(e),e!==o.content.length){const r=e<o.content.length?"already exists":"would leave a gap";throw new Error(`Cannot start assistant message block at index ${e}: ${r}`)}o.content.push(structuredClone(a)),t.set(e,n)}s(g,"appendBlock");function l(o,t,e,a,n){h(e);const r=t.get(e),i=o.content[e];if(!r||!i)throw new Error(`${n} frame has no started block at index ${e}`);if(r.kind!==a||i.type!==a)throw new Error(`${n} frame expected ${a} block at index ${e}, found ${i.type}`);if(r.ended)throw new Error(`${n} frame follows the end of block at index ${e}`);return{block:i,state:r}}s(l,"activeBlock");function S(o){let t,e;const a=new Map;for(const n of o){if(n.type==="start"){if(t)throw new Error("Assistant message frame sequence contains more than one start frame");if(e!==void 0)throw new Error(`${e} frame appears before the start frame`);t=structuredClone(n.partial);continue}if(!t){e??=n.type;continue}switch(n.type){case"text_start":if(n.content.type!=="text")throw new Error(`text_start frame contains ${n.content.type} content`);g(t,a,n.contentIndex,n.content,{kind:"text",ended:!1});break;case"text_delta":{const{block:r}=l(t,a,n.contentIndex,"text",n.type);if(r.type!=="text")throw new Error("Unreachable text frame state");r.text+=n.delta;break}case"text_end":{const{block:r,state:i}=l(t,a,n.contentIndex,"text",n.type);if(r.type!=="text")throw new Error("Unreachable text frame state");r.text=n.content,delete r.textSignature,n.textSignature!==void 0&&(r.textSignature=n.textSignature),i.ended=!0;break}case"thinking_start":if(n.content.type!=="thinking")throw new Error(`thinking_start frame contains ${n.content.type} content`);g(t,a,n.contentIndex,n.content,{kind:"thinking",ended:!1});break;case"thinking_delta":{const{block:r}=l(t,a,n.contentIndex,"thinking",n.type);if(r.type!=="thinking")throw new Error("Unreachable thinking frame state");r.thinking+=n.delta;break}case"thinking_end":{const{block:r,state:i}=l(t,a,n.contentIndex,"thinking",n.type);if(r.type!=="thinking")throw new Error("Unreachable thinking frame state");r.thinking=n.content,delete r.thinkingSignature,delete r.redacted,n.thinkingSignature!==void 0&&(r.thinkingSignature=n.thinkingSignature),n.redacted!==void 0&&(r.redacted=n.redacted),i.ended=!0;break}case"toolcall_start":if(n.toolCall.type!=="toolCall")throw new Error(`toolcall_start frame contains ${n.toolCall.type} content`);g(t,a,n.contentIndex,n.toolCall,{kind:"toolCall",ended:!1,json:""});break;case"toolcall_checkpoint":{const{block:r,state:i}=l(t,a,n.contentIndex,"toolCall",n.type);if(r.type!=="toolCall"||i.kind!=="toolCall")throw new Error("Unreachable tool-call checkpoint state");i.json=n.json,r.arguments=d(n.json);break}case"toolcall_delta":{const{block:r,state:i}=l(t,a,n.contentIndex,"toolCall",n.type);if(r.type!=="toolCall"||i.kind!=="toolCall")throw new Error("Unreachable tool-call frame state");i.json+=n.delta;break}case"toolcall_end":{const{block:r,state:i}=l(t,a,n.contentIndex,"toolCall",n.type);if(r.type!=="toolCall")throw new Error("Unreachable tool-call frame state");r.id=n.id,r.name=n.name,r.arguments=structuredClone(n.arguments),delete r.thoughtSignature,delete r.namespace,n.thoughtSignature!==void 0&&(r.thoughtSignature=n.thoughtSignature),n.namespace!==void 0&&(r.namespace=n.namespace),i.ended=!0;break}}}if(t){for(const[n,r]of a){if(r.kind!=="toolCall"||r.ended||r.json.length===0)continue;const i=t.content[n];if(i?.type!=="toolCall")throw new Error("Unreachable tool-call frame state");i.arguments=d(r.json)}return t}}s(S,"reduceAssistantMessageFrames");export{E as AssistantMessageFrameEncoder,S as reduceAssistantMessageFrames};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
`0.84.x` headings are inherited Pi history. DAL Code product version is `0.1.0`.
|
|
4
|
-
|
|
5
|
-
## [1.1.0] - 2026-10-07
|
|
6
|
-
|
|
7
|
-
## [1.0.4] - 2026-10-05
|
|
8
|
-
|
|
9
|
-
## [1.0.3] - 2026-10-05
|
|
10
|
-
|
|
11
|
-
## [1.0.2] - 2026-10-04
|
|
12
|
-
|
|
13
|
-
## [1.0.1] - 2026-10-03
|
|
14
|
-
|
|
15
|
-
## [1.0.0] - 2026-10-01
|
|
16
|
-
|
|
17
|
-
## [0.99.2] - 2026-09-30
|
|
18
|
-
|
|
19
|
-
## [0.99.1] - 2026-09-29
|
|
20
|
-
|
|
21
|
-
## [0.99.0] - 2026-09-29
|
|
22
|
-
|
|
23
|
-
## [0.87.1] - 2026-09-22
|
|
24
|
-
|
|
25
|
-
## [Unreleased]
|
|
26
|
-
|
|
27
|
-
### Added
|
|
28
|
-
|
|
29
|
-
- `PiSessionHandle.subscribeExtensionUi()` and `answerExtensionUi()`. `onEvent` now routes `extension_ui` events to the session.
|
|
30
|
-
|
|
31
|
-
## [0.84.3] - 2026-08-24
|
|
32
|
-
|
|
33
|
-
## [0.84.2] - 2026-08-14
|
|
34
|
-
|
|
35
|
-
## [0.84.1] - 2026-08-07
|
|
36
|
-
|
|
37
|
-
## [0.84.0] - 2026-08-06
|
|
38
|
-
|
|
39
|
-
### Breaking Changes
|
|
40
|
-
|
|
41
|
-
- Replaced `SessionSummary` with durable `SessionMetadata` for `PiClient.listSessions()` and server snapshots; runtime state is available only from acquired session snapshots ([#7708](https://github.com/earendil-works/pi/pull/7708)).
|
|
42
|
-
|
|
43
|
-
### Added
|
|
44
|
-
|
|
45
|
-
- Added the experimental transport-neutral `PiClient` and multi-session `PiSessionHandle` APIs with structured `PiServerError` responses.
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Mario Zechner
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# @earendil-works/pi-client
|
|
2
|
-
|
|
3
|
-
Transport-neutral client for the experimental Pi service protocol.
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
import { Client, type ByteTransportFactory } from "@earendil-works/pi-client";
|
|
7
|
-
|
|
8
|
-
const transportFactory: ByteTransportFactory = async (handlers) => {
|
|
9
|
-
// Connect using WebSocket, Unix socket, or another ordered byte transport.
|
|
10
|
-
return {
|
|
11
|
-
async send(chunk) {
|
|
12
|
-
// Deliver bytes in invocation order and honor backpressure.
|
|
13
|
-
},
|
|
14
|
-
close() {},
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const client = await Client.connect({
|
|
19
|
-
serverId: "01234567-89ab-4def-8123-456789abcdef",
|
|
20
|
-
transportFactory,
|
|
21
|
-
});
|
|
22
|
-
const result = await client.request(
|
|
23
|
-
{ serverId: client.hello.serverId },
|
|
24
|
-
{ serviceId: "example.service", member: "read", args: [] },
|
|
25
|
-
);
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
The client verifies that the physical endpoint reports the expected logical `serverId`. Server-wide requests carry that ID, and every Session request carries the full live target `{ serverId, sessionId, attachmentId }`. The combined durable address prevents cross-server or cross-session misrouting; the server-generated attachment ID rejects delayed frames after switching or reattaching.
|
|
29
|
-
|
|
30
|
-
Typed server and Session APIs are provided by Chord service bindings owned by the application. `createClientServiceTransport()` adapts a lazily resolved server or Session route to a Chord transport; `request()` and `subscribeService()` remain its low-level primitives. The client uses Chord's service-control parsers and per-subscription state decoder; `pi-protocol` only validates the routed envelope and strict-JSON boundary. A service subscription returns a complete provider snapshot; the binding installs it and then calls `start()` to release updates buffered during hydration. `Client` applies ordered out-of-band attachment changes but deliberately does not construct typed service proxies or interpret application contracts.
|
|
31
|
-
|
|
32
|
-
Application observation APIs such as the coding agent's `Transcript` are ordinary Chord services. The client does not interpret their snapshots or updates.
|
|
33
|
-
|
|
34
|
-
On disconnect or disposal, pending requests reject locally, but accepted work may still complete remotely before the attachment is released. The client clears its live attachment route. It never reconnects or replays requests automatically. After disconnection, call `reconnect()`, attach through the application's management service again, and explicitly repeat only operations known to be safe.
|
|
35
|
-
|
|
36
|
-
The experimental local coordinator only provides a stable endpoint and relays traffic. Replaceable server processes own Session and worker lifecycle outside the public client protocol.
|
|
37
|
-
|
|
38
|
-
Call transport handlers as follows:
|
|
39
|
-
|
|
40
|
-
- `handlers.onData(chunk)` for inbound bytes;
|
|
41
|
-
- `handlers.onClose()` for an orderly terminal close;
|
|
42
|
-
- `handlers.onError(error)` for transport failures.
|
|
43
|
-
|
|
44
|
-
A transport factory creates a fresh authenticated connection for each attempt. Requests are correlated by ID, and server failures are exposed as `ServerError`.
|
|
45
|
-
|
|
46
|
-
## Unix-domain sockets
|
|
47
|
-
|
|
48
|
-
Node.js and Bun consumers can use the separate Unix transport:
|
|
49
|
-
|
|
50
|
-
```ts
|
|
51
|
-
import { Client } from "@earendil-works/pi-client";
|
|
52
|
-
import { createUnixTransportFactory } from "@earendil-works/pi-client/unix";
|
|
53
|
-
|
|
54
|
-
const client = new Client({
|
|
55
|
-
serverId: "01234567-89ab-4def-8123-456789abcdef",
|
|
56
|
-
transportFactory: createUnixTransportFactory({ path: "/tmp/pi.sock" }),
|
|
57
|
-
});
|
|
58
|
-
await client.connect();
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
Unix discovery scans an explicit physical-route directory, derives each expected server ID from its filename, and verifies it through the existing handshake:
|
|
62
|
-
|
|
63
|
-
```ts
|
|
64
|
-
import { discoverUnixServers } from "@earendil-works/pi-client/unix";
|
|
65
|
-
|
|
66
|
-
const routes = await discoverUnixServers({ directory: "/run/user/1000/pi" });
|
|
67
|
-
// [{ serverId: "...", path: "/run/user/1000/pi/<serverId>.sock" }]
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Malformed entries, non-sockets, stale or unresponsive endpoints, and server-ID mismatches are ignored. Discovery is read-only and probes at most 16 sockets concurrently. Unexpected filesystem and socket errors reject discovery. Pass `timeoutMs` to override the default probe timeout.
|
|
71
|
-
|
|
72
|
-
`ClientOptions.maxFrameLength` bounds protocol payloads. `maxPendingBytes` bounds queued Unix transport output. Configure matching limits on both peers.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var L=Object.defineProperty;var i=(h,e)=>L(h,"name",{value:e,configurable:!0});import{createServiceCatalogueCall as P,createServiceStateDecoder as U,createServiceSubscribeCall as j,createServiceUnsubscribeCall as x,parseServiceCall as T,parseServiceCatalogue as D,parseWireServiceProviderUpdate as q,parseWireServiceSubscriptionSnapshot as F}from"@earendil-works/chord";import{BACKGROUND_CONTEXT as R}from"@earendil-works/chord/context";import{encodeClientMessage as C,isServerId as A,ProtocolValidationError as p}from"@earendil-works/pi-protocol";import{Connection as M}from"./connection.js";import{ClientDisposedError as m,DisconnectedError as w,ServerError as W,toError as y}from"./errors.js";import{createPromiseResolvers as k}from"./promise.js";class g{static{i(this,"Client")}#s;#e;#n=new Map;#o=new Set;#c=new Set;#t=new Map;#w=0;#y=0;#r;#a;#i=!1;#d;constructor(e){if(!A(e.serverId))throw new TypeError("serverId must be a canonical lowercase UUIDv4");this.#s=e,this.#e=new M({transportFactory:e.transportFactory,serverId:e.serverId,maxFrameLength:e.maxFrameLength,onHandshake:i(t=>{this.#r=t},"onHandshake"),onMessage:i(t=>this.#S(t),"onMessage"),onStateChange:i(t=>this.#I(t),"onStateChange")})}get disposed(){return this.#i}get connectionState(){return this.#e.state}get connected(){return this.#e.state==="connected"}get serverId(){return this.#s.serverId}get hello(){return this.#r}get attachment(){return this.#a}static async connect(e){const t=new g(e);try{return await t.connect(),t}catch(r){throw await t.dispose(),r}}connect(){return this.#i?Promise.reject(new m):(this.#r=void 0,this.#e.connect())}reconnect(){return this.connect()}disconnect(e="Client disconnected"){this.#e.disconnect(e)}onConnectionStateChange(e){return this.#m(),this.#o.add(e),()=>this.#o.delete(e)}onAttachmentChange(e){return this.#m(),this.#c.add(e),()=>this.#c.delete(e)}request(e,t,r){return this.#h(e,t,r)}async serviceCatalogue(e,t){const r=await this.#h(e,P(),t);try{return D(r)}catch(n){const o=new p(n instanceof Error?n.message:"Invalid service catalogue");throw this.#e.fail(o),o}}async subscribeService(e,t,r,n,o){const c=`service-${++this.#y}`,s={target:e,listener:n,decoder:U(),queuedWireUpdates:[],queued:[],deliveryTail:Promise.resolve(),hydrated:!1,ready:!1};this.#t.set(c,s);let d;try{d=await this.#h(e,j(c,t,r),o,a=>{const l=s.decoder.decodeSnapshot(F(a));s.hydrated=!0;for(const v of s.queuedWireUpdates.splice(0))s.queued.push(s.decoder.decodeUpdate(q(v)));return l})}catch(a){throw this.#t.get(c)===s&&this.#t.delete(c),a}if(this.#t.get(c)!==s)throw new w;let u=!1;return{id:c,target:e,snapshot:d,start:i(()=>{if(!(u||s.ready)){s.ready=!0;for(const a of s.queued.splice(0))this.#v(s,a)}},"start"),dispose:i(async()=>{if(!u){u=!0,this.#t.get(c)===s&&this.#t.delete(c);try{this.connected&&this.#b(e)&&await this.#h(e,x(c)),await s.deliveryTail}finally{s.queuedWireUpdates.length=0,s.queued.length=0}}},"dispose")}}#h(e,t,r,n){if(this.#i)return Promise.reject(new m);if(!this.connected)return Promise.reject(new w);if(r?.aborted)return Promise.reject(E(r));const o=`request-${++this.#w}`,{promise:c,resolve:s,reject:d}=k();let u=!1,a=!1,l;const v=i(()=>{if(!(!u||!this.connected))try{this.#e.send(C({type:"cancel",id:o,target:e},{maxFrameLength:this.#e.maxFrameLength}))}catch(f){this.#e.fail(y(f))}},"sendCancel");r!==void 0&&(l=i(()=>{a||(a=!0,d(E(r)),v())},"onAbort"),r.addEventListener("abort",l,{once:!0})),this.#n.set(o,{resolve:i(f=>{try{s(n===void 0?f:n(f))}catch(I){const b=new p(I instanceof Error?I.message:"Invalid service operation stream");this.#e.fail(b),d(b)}},"resolve"),reject:d,cleanup:i(()=>{r!==void 0&&l!==void 0&&r.removeEventListener("abort",l)},"cleanup")});let S;try{S=C({type:"request",id:o,target:e,call:T(t)},{maxFrameLength:this.#e.maxFrameLength})}catch(f){return this.#f(o)?.reject(y(f)),c}return this.#e.send(S),u=!0,a&&v(),c}#S(e){if(e.type==="attachment"){if(e.attachment!==null&&e.attachment.serverId!==this.#s.serverId){this.#e.fail(new p("Attachment update belongs to another server"));return}this.#u(e.attachment??void 0);return}if(e.type==="service_update"){const r=this.#t.get(e.subscriptionId);if(r===void 0)return;if(!r.hydrated){r.queuedWireUpdates.push(e.update);return}let n;try{n=r.decoder.decodeUpdate(q(e.update))}catch(o){this.#e.fail(new p(o instanceof Error?o.message:"Invalid service operation stream"));return}r.ready?this.#v(r,n):r.queued.push(n);return}const t=this.#f(e.id);if(!t){this.#e.fail(new p("Response has no matching request"));return}if(!e.ok){t.reject(new W(e.error));return}t.resolve(e.result)}#I(e){e.state==="disconnected"&&(this.#r=void 0,this.#u(void 0),this.#p(e.error??new w),this.#t.clear());for(const t of this.#o)try{t(e)}catch(r){this.#l(r)}}#f(e){const t=this.#n.get(e);return t&&(this.#n.delete(e),t.cleanup()),t}#p(e){const t=[...this.#n.values()];this.#n.clear();for(const r of t)r.cleanup(),r.reject(e)}dispose(){if(this.#d)return this.#d;this.#i=!0,this.#d=Promise.resolve();const e=new m;return this.#p(e),this.#e.disconnect(e),this.#r=void 0,this.#u(void 0),this.#o.clear(),this.#c.clear(),this.#t.clear(),this.#d}[Symbol.asyncDispose](){return this.dispose()}#u(e){const t=this.#a;if(!(t?.serverId===e?.serverId&&t?.sessionId===e?.sessionId&&t?.attachmentId===e?.attachmentId)){this.#a=e;for(const r of this.#c)try{r(e)}catch(n){this.#l(n)}}}#v(e,t){e.deliveryTail=e.deliveryTail.then(()=>e.listener(t)).catch(r=>this.#l(r))}#b(e){if(!("sessionId"in e))return this.#r?.serverId===e.serverId;const t=this.#a;return t?.serverId===e.serverId&&t.sessionId===e.sessionId&&t.attachmentId===e.attachmentId}#m(){if(this.#i)throw new m}#l(e){if(this.#s.onListenerError)try{this.#s.onListenerError(y(e))}catch{}}}function V(h,e){const t=i(()=>{const r=e();if(r===void 0)throw new Error("Remote service target is unavailable");return r},"target");return{invoke:i(async(r,n)=>h.request(t(),r,n.abortSignal),"invoke"),async subscribe(r,n,o,c){const s=await h.subscribeService(t(),r,n,d=>o(d,R),c.abortSignal);return{snapshot:s.snapshot,activate:i(()=>s.start(),"activate"),close:i(()=>s.dispose(),"close")}}}}i(V,"createClientServiceTransport");function E(h){const e=h.reason;return e instanceof Error?e:new DOMException("The operation was aborted","AbortError")}i(E,"abortError");export{g as Client,V as createClientServiceTransport};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var f=Object.defineProperty;var i=(d,e)=>f(d,"name",{value:e,configurable:!0});import{DEFAULT_MAX_FRAME_LENGTH as u,encodeClientMessage as p,PROTOCOL_VERSION as y,ProtocolValidationError as o,ServerMessageDecoder as g}from"@earendil-works/pi-protocol";import{DisconnectedError as h,ServerError as m,toDisconnectedError as c,toError as a}from"./errors.js";import{createPromiseResolvers as w}from"./promise.js";const l=4294967295;class F{static{i(this,"Connection")}#r;#n;#e={state:"disconnected"};#o=0;constructor(e){if(this.#r=e,this.#n=e.maxFrameLength??u,!Number.isSafeInteger(this.#n)||this.#n<=0||this.#n>l)throw new TypeError(`Client maxFrameLength must be an integer between 1 and ${l}`)}get state(){return this.#e.state}get maxFrameLength(){return this.#n}connect(){if(this.#e.state!=="disconnected")return Promise.reject(new h(`Client is already ${this.#e.state}`));const e=++this.#o,t=w();this.#e={state:"connecting",id:e,decoder:new g({maxFrameLength:this.#n}),handshake:t},this.#r.onStateChange({state:"connecting"});const r={onData:i(n=>this.#h(e,n),"onData"),onClose:i(()=>{this.#s(e)&&this.#d()},"onClose"),onError:i(n=>{this.#s(e)&&this.#t(c(n))},"onError")};return this.#c(e,r),t.promise}disconnect(e="Client disconnected"){this.#e.state!=="disconnected"&&this.#t(typeof e=="string"?new h(e):e)}fail(e){this.#t(e)}send(e){const t=this.#e;if(t.state!=="connected")throw new h;let r;try{r=t.transport.send(e)}catch(n){this.#t(c(n));return}r.catch(n=>{const s=this.#e;s.state!=="disconnected"&&s.transport===t.transport&&this.#t(c(n))})}async#c(e,t){let r;try{r=await this.#r.transportFactory(t)}catch(s){this.#s(e)&&this.#i(c(s));return}const n=this.#e;if(n.state!=="connecting"||n.id!==e){r.close();return}this.#e={...n,transport:r};try{await r.send(p({type:"hello",version:y},{maxFrameLength:this.#n}))}catch(s){this.#s(e)&&this.#t(c(s))}}#h(e,t){const r=this.#e;if(r.state==="disconnected"||r.id!==e)return;if(r.state==="connecting"&&!r.transport){this.#t(new o("Received server data before the client hello was sent"));return}let n;try{n=r.decoder.push(t)}catch(s){this.#t(a(s));return}for(const s of n){if(this.#e.state==="disconnected")return;this.#a(s)}}#a(e){const t=this.#e;if(t.state==="connecting"){if(e.type==="hello_error"){this.#t(new m(e.error));return}if(e.type!=="hello"){this.#t(new o("Expected server hello as first message"));return}if(e.serverId!==this.#r.serverId){this.#t(new o(`Connected server ${JSON.stringify(e.serverId)} does not match ${JSON.stringify(this.#r.serverId)}`));return}if(!t.transport){this.#t(new o("Received server hello before the client hello was sent"));return}const r={state:"connected",id:t.id,decoder:t.decoder,transport:t.transport,handshake:t.handshake};this.#e=r;try{this.#r.onHandshake(e)}catch(n){this.#e===r&&this.#t(a(n));return}if(this.#e!==r||(this.#r.onStateChange({state:"connected"}),this.#e!==r))return;this.#e={...r,handshake:void 0},t.handshake.resolve(e);return}if(t.state==="connected"){if(e.type==="hello"||e.type==="hello_error"){this.#t(new o("Unexpected handshake message"));return}this.#r.onMessage(e)}}#d(){const e=this.#e;if(e.state==="disconnected")return;let t=new h("Byte transport closed");try{e.decoder.end()}catch(r){t=a(r)}this.#i(t)}#t(e){const t=this.#e,r=t.state==="disconnected"?void 0:t.transport;this.#i(e),r?.close()}#i(e){const t=this.#e;t.state!=="disconnected"&&(this.#e={state:"disconnected"},t.handshake?.reject(e),this.#r.onStateChange({state:"disconnected",error:e}))}#s(e){return this.#e.state!=="disconnected"&&this.#e.id===e}}export{F as Connection};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t=Object.defineProperty;var n=(e,r)=>t(e,"name",{value:r,configurable:!0});class d extends Error{static{n(this,"ServerError")}code;constructor(r){super(r.message),this.name="ServerError",this.code=r.code}}class s extends Error{static{n(this,"DisconnectedError")}constructor(r="Client is disconnected",o){super(r,o===void 0?void 0:{cause:o}),this.name="DisconnectedError"}}class E extends Error{static{n(this,"ClientDisposedError")}constructor(){super("Client is disposed"),this.name="ClientDisposedError"}}function c(e){return e instanceof Error?e:new Error(String(e))}n(c,"toError");function u(e){const r=c(e);return r instanceof s?r:new s(r.message,r)}n(u,"toDisconnectedError");export{E as ClientDisposedError,s as DisconnectedError,d as ServerError,u as toDisconnectedError,c as toError};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Client as o,createClientServiceTransport as t}from"./client.js";import{ClientDisposedError as n,DisconnectedError as c,ServerError as p}from"./errors.js";export{o as Client,n as ClientDisposedError,c as DisconnectedError,p as ServerError,t as createClientServiceTransport};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var i=Object.defineProperty;var o=(e,r)=>i(e,"name",{value:r,configurable:!0});function l(){let e,r;return{promise:new Promise((s,t)=>{e=s,r=t}),resolve:e,reject:r}}o(l,"createPromiseResolvers");export{l as createPromiseResolvers};
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var g=Object.defineProperty;var a=(n,r)=>g(n,"name",{value:r,configurable:!0});import{lstat as P,readdir as S}from"node:fs/promises";import{createConnection as b}from"node:net";import{join as _}from"node:path";import{DEFAULT_MAX_FRAME_LENGTH as v,isServerId as C,ProtocolValidationError as I}from"@earendil-works/pi-protocol";import{Client as N}from"./client.js";import{DisconnectedError as M,ServerError as O}from"./errors.js";const D=1e3,E=2147483647,y=".sock",A=16;async function Y(n){if(process.platform==="win32")throw new Error("Unix transport is not supported on Windows");const r=n.directory,t=n.timeoutMs??D;if(!Number.isSafeInteger(t)||t<=0||t>E)throw new TypeError(`Unix discovery timeoutMs must be an integer between 1 and ${E}`);let c;try{c=await S(r)}catch(s){if(u(s,"ENOENT"))return[];throw s}const f=c.flatMap(s=>{if(!s.endsWith(y))return[];const o=s.slice(0,-y.length);return C(o)?[{serverId:o,path:_(r,s)}]:[]}),l=[];let e=0,i;const d=Math.min(A,f.length);if(await Promise.all(Array.from({length:d},async()=>{for(;!i;){const s=f[e++];if(!s)return;try{try{if(!(await P(s.path)).isSocket())continue}catch(h){if(u(h,"ENOENT"))continue;throw h}const o=await L(s,t);o&&l.push(o)}catch(o){i??={error:o}}}})),i)throw i.error;return l.sort((s,o)=>s.serverId.localeCompare(o.serverId))}a(Y,"discoverUnixServers");function q(n){const r=x(n);return t=>U(n.path,r,t)}a(q,"createUnixTransportFactory");function x(n){if(n.path.length===0)throw new TypeError("Unix transport path must not be empty");const r=n.maxPendingBytes??v*4;if(!Number.isSafeInteger(r)||r<=0)throw new TypeError("Unix transport maxPendingBytes must be a positive safe integer");if(process.platform==="win32")throw new Error("Unix transport is not supported on Windows");return r}a(x,"validateUnixTransportOptions");function U(n,r,t,c){return new Promise((f,l)=>{const e=b(n);c?.(e);let i=!1,d=!1;const s=a(()=>{d||(d=!0,e.destroy(),i?t.onClose():l(new Error("Unix transport closed before connecting")))},"close");e.once("connect",()=>{d||(i=!0,f(new B(e,r,()=>{d=!0})))}),e.on("data",o=>{d||t.onData(new Uint8Array(o.buffer,o.byteOffset,o.byteLength))}),e.once("end",s),e.once("close",s),e.once("error",o=>{d||(d=!0,e.destroy(),i?t.onError(o):l(o))})})}a(U,"connectUnixSocket");class B{static{a(this,"UnixByteTransport")}#e;#n;#o;#t=!1;#r=0;#i=Promise.resolve();constructor(r,t,c){this.#e=r,this.#n=t,this.#o=c}send(r){if(!(r instanceof Uint8Array))return Promise.reject(new TypeError("Unix transport chunks must be Uint8Array"));if(this.#t)return Promise.reject(new Error("Unix transport is closed"));if(this.#r+r.byteLength>this.#n)return Promise.reject(new Error("Unix transport exceeded its pending byte limit"));this.#r+=r.byteLength;const t=r.slice(),f=this.#i.then(()=>this.#s(t)).finally(()=>{this.#r-=t.byteLength});return this.#i=f.catch(()=>{}),f}close(){this.#t||(this.#t=!0,this.#o(),this.#e.destroy())}#s(r){return this.#t||!this.#e.writable?Promise.reject(new Error("Unix transport is closed")):new Promise((t,c)=>{let f=!1,l=!1,e,i=!1;const d=a(()=>{l=!0,h()},"onDrain"),s=a(()=>{this.#e.off("drain",d),this.#e.off("close",m)},"cleanup"),o=a(p=>{i||(i=!0,s(),c(p))},"fail"),h=a(()=>{i||!f||e===void 0||e&&!l||(i=!0,s(),t())},"finish"),m=a(()=>o(new Error("Unix transport closed during write")),"onClose");try{this.#e.once("close",m),e=!this.#e.write(r,w=>{if(w){o(w);return}f=!0,h()}),e&&this.#e.once("drain",d),h()}catch(p){o(p instanceof Error?p:new Error(String(p)))}})}}async function L(n,r){const t=x({path:n.path});let c;const f=new N({serverId:n.serverId,transportFactory:a(e=>U(n.path,t,e,i=>{c=i}),"transportFactory")});let l;try{return await Promise.race([f.connect(),new Promise((e,i)=>{l=setTimeout(()=>{c?.destroy(),i(new T)},r),l.unref()})]),n}catch(e){if(e instanceof T||e instanceof I||e instanceof M&&e.cause===void 0||e instanceof O&&e.code==="version"||u(e,"ENOENT")||u(e,"ECONNREFUSED")||u(e,"ECONNRESET")||u(e,"EPIPE")||u(e,"ETIMEDOUT"))return;throw e}finally{l&&clearTimeout(l),await f.dispose();const e=c;e&&!e.destroyed&&e.destroy(),e&&!e.closed&&await new Promise(i=>e.once("close",i))}}a(L,"probeUnixServer");class T extends Error{static{a(this,"UnixDiscoveryTimeoutError")}}function u(n,r){let t=n;const c=new Set;for(;t instanceof Error&&!c.has(t);){if(c.add(t),"code"in t&&t.code===r)return!0;t=t.cause}return!1}a(u,"isErrorCode");export{q as createUnixTransportFactory,Y as discoverUnixServers};
|