@harrylabsj/kiwi-merchant-cloud 0.12.4 → 0.12.5
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/app/a2a/node.d.ts +5 -1
- package/app/a2a/node.js +68 -30
- package/app/a2a/node.js.map +1 -1
- package/app/a2a/server/merchant-handler.d.ts +4 -0
- package/app/a2a/server/merchant-handler.js +123 -45
- package/app/a2a/server/merchant-handler.js.map +1 -1
- package/app/a2a/server/merchant-product-facts.d.ts +32 -0
- package/app/a2a/server/merchant-product-facts.js +57 -0
- package/app/a2a/server/merchant-product-facts.js.map +1 -0
- package/app/agent/buyer/buyer-tools.js +285 -3
- package/app/agent/buyer/buyer-tools.js.map +1 -1
- package/app/agent/merchant/types.d.ts +4 -9
- package/app/agent/merchant/types.js +14 -0
- package/app/agent/merchant/types.js.map +1 -1
- package/app/buyer-core/a2a-knp.d.ts +1 -0
- package/app/buyer-core/a2a-knp.js +1 -1
- package/app/buyer-core/a2a-knp.js.map +1 -1
- package/app/buyer-core/a2a-negotiator.d.ts +2 -0
- package/app/buyer-core/a2a-negotiator.js +20 -19
- package/app/buyer-core/a2a-negotiator.js.map +1 -1
- package/app/buyer-core/a2a-quote-fetcher.d.ts +2 -0
- package/app/buyer-core/a2a-quote-fetcher.js +13 -5
- package/app/buyer-core/a2a-quote-fetcher.js.map +1 -1
- package/app/buyer-core/product-summary.d.ts +4 -0
- package/app/buyer-core/product-summary.js +6 -0
- package/app/buyer-core/product-summary.js.map +1 -1
- package/app/buyer-core/protocol-recovery.d.ts +12 -1
- package/app/buyer-core/protocol-recovery.js +59 -19
- package/app/buyer-core/protocol-recovery.js.map +1 -1
- package/app/buyer-core/receive-gate.d.ts +11 -0
- package/app/buyer-core/receive-gate.js +107 -0
- package/app/buyer-core/receive-gate.js.map +1 -0
- package/app/cloud/bootstrap.d.ts +4 -0
- package/app/cloud/bootstrap.js +69 -55
- package/app/cloud/bootstrap.js.map +1 -1
- package/app/cloud/file-listing-publication.js +6 -0
- package/app/cloud/file-listing-publication.js.map +1 -1
- package/app/cloud/main.d.ts +3 -0
- package/app/cloud/main.js +47 -11
- package/app/cloud/main.js.map +1 -1
- package/app/cloud/product-import-tabular.d.ts +1 -1
- package/app/cloud/product-import-tabular.js +263 -36
- package/app/cloud/product-import-tabular.js.map +1 -1
- package/app/cloud/product-source.d.ts +6 -1
- package/app/cloud/product-source.js +47 -15
- package/app/cloud/product-source.js.map +1 -1
- package/app/cloud-sample/products.json +3 -3
- package/app/commerce/data-source.d.ts +4 -0
- package/app/commerce/data-source.js.map +1 -1
- package/app/commerce/shopping-cli-source.js +4 -0
- package/app/commerce/shopping-cli-source.js.map +1 -1
- package/app/discovery/catalog-source/kiwi-source.d.ts +2 -0
- package/app/discovery/catalog-source/kiwi-source.js +4 -0
- package/app/discovery/catalog-source/kiwi-source.js.map +1 -1
- package/app/handoff/index.d.ts +2 -1
- package/app/handoff/index.js +1 -0
- package/app/handoff/index.js.map +1 -1
- package/app/handoff/launch-marketplace-policy.d.ts +149 -0
- package/app/handoff/launch-marketplace-policy.js +301 -0
- package/app/handoff/launch-marketplace-policy.js.map +1 -0
- package/app/handoff/marketplace-product-link.d.ts +18 -0
- package/app/handoff/marketplace-product-link.js +71 -0
- package/app/handoff/marketplace-product-link.js.map +1 -0
- package/app/handoff/transaction.d.ts +30 -0
- package/app/handoff/transaction.js +64 -0
- package/app/handoff/transaction.js.map +1 -1
- package/app/handoff/url-safety.d.ts +3 -0
- package/app/handoff/url-safety.js +4 -0
- package/app/handoff/url-safety.js.map +1 -1
- package/app/http/merchant-management/page.js +176 -45
- package/app/http/merchant-management/page.js.map +1 -1
- package/app/i18n.d.ts +1 -0
- package/app/i18n.js +3 -0
- package/app/i18n.js.map +1 -1
- package/app/lifecycle/close.d.ts +24 -0
- package/app/lifecycle/close.js +131 -0
- package/app/lifecycle/close.js.map +1 -0
- package/app/mcp/merchant-runtime-assembly.js +6 -4
- package/app/mcp/merchant-runtime-assembly.js.map +1 -1
- package/app/mcp/tools.js +17 -16
- package/app/mcp/tools.js.map +1 -1
- package/app/merchant/application/service.d.ts +4 -0
- package/app/merchant/application/service.js.map +1 -1
- package/app/merchant/stats-store.d.ts +3 -0
- package/app/merchant/stats-store.js +15 -1
- package/app/merchant/stats-store.js.map +1 -1
- package/app/merchant-core/rfq/data-source-adapter.d.ts +2 -10
- package/app/merchant-core/rfq/data-source-adapter.js +21 -9
- package/app/merchant-core/rfq/data-source-adapter.js.map +1 -1
- package/app/merchant-gateway/pinned-fetch.js +5 -2
- package/app/merchant-gateway/pinned-fetch.js.map +1 -1
- package/build-manifest.json +2901 -1966
- package/node_modules/@earendil-works/chord/CHANGELOG.md +20 -0
- package/node_modules/@earendil-works/chord/README.md +77 -194
- package/node_modules/@earendil-works/chord/dist/cell.d.ts +101 -0
- package/node_modules/@earendil-works/chord/dist/cell.d.ts.map +1 -0
- package/node_modules/@earendil-works/chord/dist/cell.js +316 -0
- package/node_modules/@earendil-works/chord/dist/cell.js.map +1 -0
- package/node_modules/@earendil-works/chord/dist/cluster.d.ts +26 -0
- package/node_modules/@earendil-works/chord/dist/cluster.d.ts.map +1 -0
- package/node_modules/@earendil-works/chord/dist/cluster.js +214 -0
- package/node_modules/@earendil-works/chord/dist/cluster.js.map +1 -0
- package/node_modules/@earendil-works/chord/dist/connection.d.ts +157 -0
- package/node_modules/@earendil-works/chord/dist/connection.d.ts.map +1 -0
- package/node_modules/@earendil-works/chord/dist/connection.js +757 -0
- package/node_modules/@earendil-works/chord/dist/connection.js.map +1 -0
- package/node_modules/@earendil-works/chord/dist/context/index.d.ts +12 -1
- package/node_modules/@earendil-works/chord/dist/context/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/chord/dist/context/index.js.map +1 -1
- package/node_modules/@earendil-works/chord/dist/contract.d.ts +133 -0
- package/node_modules/@earendil-works/chord/dist/contract.d.ts.map +1 -0
- package/node_modules/@earendil-works/chord/dist/contract.js +157 -0
- package/node_modules/@earendil-works/chord/dist/contract.js.map +1 -0
- package/node_modules/@earendil-works/chord/dist/declare.d.ts +70 -0
- package/node_modules/@earendil-works/chord/dist/declare.d.ts.map +1 -0
- package/node_modules/@earendil-works/chord/dist/declare.js +22 -0
- package/node_modules/@earendil-works/chord/dist/declare.js.map +1 -0
- package/node_modules/@earendil-works/chord/dist/delta/apply-immutable-trusted.js.map +1 -1
- package/node_modules/@earendil-works/chord/dist/delta/diff.d.ts +1 -1
- package/node_modules/@earendil-works/chord/dist/delta/diff.d.ts.map +1 -1
- package/node_modules/@earendil-works/chord/dist/delta/diff.js.map +1 -1
- package/node_modules/@earendil-works/chord/dist/delta/index.d.ts +2 -2
- package/node_modules/@earendil-works/chord/dist/delta/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/chord/dist/delta/index.js +41 -0
- package/node_modules/@earendil-works/chord/dist/delta/index.js.map +1 -1
- package/node_modules/@earendil-works/chord/dist/delta/revision-validator.d.ts +1 -1
- package/node_modules/@earendil-works/chord/dist/delta/revision-validator.d.ts.map +1 -1
- package/node_modules/@earendil-works/chord/dist/delta/revision-validator.js.map +1 -1
- package/node_modules/@earendil-works/chord/dist/delta/tracker.d.ts +1 -1
- package/node_modules/@earendil-works/chord/dist/delta/tracker.d.ts.map +1 -1
- package/node_modules/@earendil-works/chord/dist/delta/tracker.js +40 -4
- package/node_modules/@earendil-works/chord/dist/delta/tracker.js.map +1 -1
- package/node_modules/@earendil-works/chord/dist/errors.d.ts +27 -0
- package/node_modules/@earendil-works/chord/dist/errors.d.ts.map +1 -0
- package/node_modules/@earendil-works/chord/dist/errors.js +44 -0
- package/node_modules/@earendil-works/chord/dist/errors.js.map +1 -0
- package/node_modules/@earendil-works/chord/dist/host.d.ts +254 -0
- package/node_modules/@earendil-works/chord/dist/host.d.ts.map +1 -0
- package/node_modules/@earendil-works/chord/dist/host.js +795 -0
- package/node_modules/@earendil-works/chord/dist/host.js.map +1 -0
- package/node_modules/@earendil-works/chord/dist/index.d.ts +17 -10
- package/node_modules/@earendil-works/chord/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/chord/dist/index.js +8 -8
- package/node_modules/@earendil-works/chord/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/chord/dist/json.d.ts +9 -1
- package/node_modules/@earendil-works/chord/dist/json.d.ts.map +1 -1
- package/node_modules/@earendil-works/chord/dist/json.js.map +1 -1
- package/node_modules/@earendil-works/chord/dist/link.d.ts +72 -0
- package/node_modules/@earendil-works/chord/dist/link.d.ts.map +1 -0
- package/node_modules/@earendil-works/chord/dist/link.js +169 -0
- package/node_modules/@earendil-works/chord/dist/link.js.map +1 -0
- package/node_modules/@earendil-works/chord/dist/loader.d.ts +4 -0
- package/node_modules/@earendil-works/chord/dist/loader.d.ts.map +1 -0
- package/node_modules/@earendil-works/chord/dist/loader.js +68 -0
- package/node_modules/@earendil-works/chord/dist/loader.js.map +1 -0
- package/node_modules/@earendil-works/chord/dist/manager.d.ts +115 -0
- package/node_modules/@earendil-works/chord/dist/manager.d.ts.map +1 -0
- package/node_modules/@earendil-works/chord/dist/manager.js +319 -0
- package/node_modules/@earendil-works/chord/dist/manager.js.map +1 -0
- package/node_modules/@earendil-works/chord/dist/node.d.ts +3 -4
- package/node_modules/@earendil-works/chord/dist/node.d.ts.map +1 -1
- package/node_modules/@earendil-works/chord/dist/node.js +3 -2
- package/node_modules/@earendil-works/chord/dist/node.js.map +1 -1
- package/node_modules/@earendil-works/chord/dist/publish.d.ts +5 -0
- package/node_modules/@earendil-works/chord/dist/publish.d.ts.map +1 -0
- package/node_modules/@earendil-works/chord/dist/publish.js +40 -0
- package/node_modules/@earendil-works/chord/dist/publish.js.map +1 -0
- package/node_modules/@earendil-works/chord/dist/record.d.ts +320 -0
- package/node_modules/@earendil-works/chord/dist/record.d.ts.map +1 -0
- package/node_modules/@earendil-works/chord/dist/record.js +1292 -0
- package/node_modules/@earendil-works/chord/dist/record.js.map +1 -0
- package/node_modules/@earendil-works/chord/dist/registry.d.ts +25 -0
- package/node_modules/@earendil-works/chord/dist/registry.d.ts.map +1 -0
- package/node_modules/@earendil-works/chord/dist/registry.js +6 -0
- package/node_modules/@earendil-works/chord/dist/registry.js.map +1 -0
- package/node_modules/@earendil-works/chord/dist/reload.d.ts +118 -0
- package/node_modules/@earendil-works/chord/dist/reload.d.ts.map +1 -0
- package/node_modules/@earendil-works/chord/dist/reload.js +589 -0
- package/node_modules/@earendil-works/chord/dist/reload.js.map +1 -0
- package/node_modules/@earendil-works/chord/dist/remote.d.ts +70 -0
- package/node_modules/@earendil-works/chord/dist/remote.d.ts.map +1 -0
- package/node_modules/@earendil-works/chord/dist/remote.js +308 -0
- package/node_modules/@earendil-works/chord/dist/remote.js.map +1 -0
- package/node_modules/@earendil-works/chord/dist/schema.d.ts +21 -0
- package/node_modules/@earendil-works/chord/dist/schema.d.ts.map +1 -0
- package/node_modules/@earendil-works/chord/dist/schema.js +228 -0
- package/node_modules/@earendil-works/chord/dist/schema.js.map +1 -0
- package/node_modules/@earendil-works/chord/dist/state.d.ts +92 -0
- package/node_modules/@earendil-works/chord/dist/state.d.ts.map +1 -0
- package/node_modules/@earendil-works/chord/dist/{services/state.js → state.js} +28 -138
- package/node_modules/@earendil-works/chord/dist/state.js.map +1 -0
- package/node_modules/@earendil-works/chord/dist/types.d.ts +62 -262
- package/node_modules/@earendil-works/chord/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/chord/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/chord/dist/websocket.d.ts +16 -0
- package/node_modules/@earendil-works/chord/dist/websocket.d.ts.map +1 -0
- package/node_modules/@earendil-works/chord/dist/websocket.js +15 -0
- package/node_modules/@earendil-works/chord/dist/websocket.js.map +1 -0
- package/node_modules/@earendil-works/chord/dist/wire.d.ts +135 -0
- package/node_modules/@earendil-works/chord/dist/wire.d.ts.map +1 -0
- package/node_modules/@earendil-works/chord/dist/wire.js +112 -0
- package/node_modules/@earendil-works/chord/dist/wire.js.map +1 -0
- package/node_modules/@earendil-works/chord/docs/guide.md +750 -0
- package/node_modules/@earendil-works/chord/docs/spec.md +261 -0
- package/node_modules/@earendil-works/chord/docs/tutorial.md +909 -0
- package/node_modules/@earendil-works/chord/package.json +10 -11
- package/node_modules/@earendil-works/chord/src/delta/README.md +5 -3
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +9 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +2 -5
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +2 -14
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +4 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
- package/node_modules/@earendil-works/pi-ai/README.md +14 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +63 -22
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-config.d.ts +15 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-config.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-config.js +76 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-config.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts +3 -6
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +2 -74
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +33 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/classifier-shared.d.ts +21 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/classifier-shared.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/classifier-shared.js +98 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/classifier-shared.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-workers-ai-system-one.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-workers-ai-system-one.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-workers-ai-system-one.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/lazy.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/lazy.js +4 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/lazy.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/llama-cpp-classify.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/llama-cpp-classify.js +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/llama-cpp-classify.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +31 -14
- package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +7 -4
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-decisions.d.ts +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-decisions.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-decisions.js +162 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-decisions.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-decisions.lazy.d.ts +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-decisions.lazy.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-decisions.lazy.js +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-decisions.lazy.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/system-one-shared.d.ts +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/system-one-shared.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/system-one-shared.js +5 -89
- package/node_modules/@earendil-works/pi-ai/dist/api/system-one-shared.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/typesafe-system-one.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/typesafe-system-one.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/typesafe-system-one.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.js +14 -6
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-chatgpt.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-chatgpt.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js +4 -4
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts +16 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js +51 -27
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts +5 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.d.ts +5 -0
- package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +4 -4
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +4 -4
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.js +7 -8
- package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.js +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure.d.ts +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure.js +46 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure.models.d.ts +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure.models.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure.models.js +8 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure.models.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.d.ts +338 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.js +375 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/meta.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax-cn.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js +25 -8
- package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.d.ts +91 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.js +55 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai.js +12 -3
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-api.d.ts +40 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-api.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-api.js +41 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-api.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.d.ts +11 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.js +52 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/radius.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/radius.js +4 -12
- package/node_modules/@earendil-works/pi-ai/dist/providers/radius.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +22 -305
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/estimate.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/estimate.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.d.ts +10 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js +25 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/model-operations.d.ts +3 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/model-operations.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/model-operations.js +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/model-operations.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.d.ts +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +8 -2
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/node_modules/@earendil-works/pi-codemode/README.md +177 -11
- package/node_modules/@earendil-works/pi-codemode/dist/cloudflare.d.ts +53 -0
- package/node_modules/@earendil-works/pi-codemode/dist/cloudflare.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-codemode/dist/cloudflare.js +64 -0
- package/node_modules/@earendil-works/pi-codemode/dist/cloudflare.js.map +1 -0
- package/node_modules/@earendil-works/pi-codemode/dist/declarations.d.ts +6 -21
- package/node_modules/@earendil-works/pi-codemode/dist/declarations.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-codemode/dist/declarations.js +113 -127
- package/node_modules/@earendil-works/pi-codemode/dist/declarations.js.map +1 -1
- package/node_modules/@earendil-works/pi-codemode/dist/index.d.ts +5 -2
- package/node_modules/@earendil-works/pi-codemode/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-codemode/dist/index.js +4 -1
- package/node_modules/@earendil-works/pi-codemode/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-codemode/dist/portable.d.ts +15 -0
- package/node_modules/@earendil-works/pi-codemode/dist/portable.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-codemode/dist/portable.js +12 -0
- package/node_modules/@earendil-works/pi-codemode/dist/portable.js.map +1 -0
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/execution.d.ts +66 -0
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/execution.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/execution.js +494 -0
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/execution.js.map +1 -0
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/host.d.ts +8 -30
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/host.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/host.js +41 -283
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/host.js.map +1 -1
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/inline.d.ts +63 -0
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/inline.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/inline.js +80 -0
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/inline.js.map +1 -0
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/prelude-source.d.ts +9 -3
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/prelude-source.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/prelude-source.js +122 -12
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/prelude-source.js.map +1 -1
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/protocol.d.ts +47 -6
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/protocol.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/protocol.js +6 -1
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/protocol.js.map +1 -1
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/remote.d.ts +102 -0
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/remote.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/remote.js +175 -0
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/remote.js.map +1 -0
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/vm.d.ts +24 -0
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/vm.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/vm.js +293 -0
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/vm.js.map +1 -0
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/worker.js +11 -110
- package/node_modules/@earendil-works/pi-codemode/dist/runtime/worker.js.map +1 -1
- package/node_modules/@earendil-works/pi-codemode/dist/source.d.ts +2 -1
- package/node_modules/@earendil-works/pi-codemode/dist/source.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-codemode/dist/source.js +8 -2
- package/node_modules/@earendil-works/pi-codemode/dist/source.js.map +1 -1
- package/node_modules/@earendil-works/pi-codemode/dist/types.d.ts +101 -6
- package/node_modules/@earendil-works/pi-codemode/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-codemode/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-codemode/package.json +15 -3
- package/node_modules/@earendil-works/pi-coding-agent/CHANGELOG.md +165 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/anthropic-messages-Q7SXESRX.js +6 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/anthropic.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/azure-openai-responses-LM52U7CK.js +2 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/bedrock-converse-stream.js +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-22CYIUS4.js +2 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-3ZATHNCK.js +9 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-5GTPJSRI.js +7 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-6MWTY2OB.js +130 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-6QGV3IWD.js +6 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{chunk-2KAZSACP.js → chunk-AKJ3ZOR3.js} +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{chunk-G7EDXK4D.js → chunk-CQ3XTLTY.js} +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{chunk-SYF2TF6W.js → chunk-D7PHKNBM.js} +29 -92
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-DOST5PQW.js +82 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-DVQEBGVL.js +2 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{chunk-ZSI3BL5Q.js → chunk-GDR5JFDJ.js} +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-HACVPRBJ.js +11 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-ITZNWD4K.js +2 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-LPXNMA2W.js +2 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{chunk-LD2P6SFZ.js → chunk-PMRZO46Y.js} +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-RDZVAGPR.js +2 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{chunk-ZSBPJAJ2.js → chunk-TJXZSVTD.js} +116 -99
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{chunk-BYB6ZAAQ.js → chunk-TN4NLWHF.js} +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-WBQBCFWG.js +2 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-WJUNYZC5.js +2 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-XIX7LUWI.js +2 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-ZBURYEWF.js +2 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{cli-KILDDGW3.js → cli-SWM4FQ6V.js} +4 -4
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/cloudflare-workers-ai-system-one-UTBL2KOF.js +2 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/codemode-worker.js +117 -14
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/easter-egg-3d-OX6RUCIS.js +2 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/execute-3CFUPDLS.js +499 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/github-copilot.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{google-generative-ai-ZOK6CV7D.js → google-generative-ai-DXKP72HC.js} +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{google-vertex-VKWZQ3AY.js → google-vertex-W6SIDOVV.js} +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/image-resize-worker.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{llama-cpp-classify-XT44PI3C.js → llama-cpp-classify-FYN623RH.js} +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/mistral-conversations-GBMHTSYF.js +5 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/openai-chatgpt.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/openai-codex-responses-RN6B5UPP.js +10 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/openai-codex.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{openai-completions-GWHGMQ3T.js → openai-completions-QW2B4SML.js} +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/openai-decisions-WVPMQ4JD.js +5 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{openai-responses-EZ7FJ2KL.js → openai-responses-KDJUSIU7.js} +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{openrouter-images-ZVXWCSIM.js → openrouter-images-DUPG5DZO.js} +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{pi-messages-TM5SOOIW.js → pi-messages-YHKPQIHC.js} +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/runtime-366HE7CW.js +2 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/typesafe-system-one-ZSK3RN4B.js +2 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/virtual-modules-GI6FRNLG.js +2 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/cli-runtime.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/index.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/rpc-entry.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/cli/args.d.ts +2 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/cli/args.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/cli/args.js +24 -5
- package/node_modules/@earendil-works/pi-coding-agent/dist/cli/args.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/config.d.ts +18 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/config.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/config.js +44 -6
- package/node_modules/@earendil-works/pi-coding-agent/dist/config.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.d.ts +47 -5
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js +148 -78
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-storage.js +20 -13
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-storage.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/bash-executor.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/bash-executor.js +42 -52
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/bash-executor.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/bug-report.d.ts +9 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/bug-report.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/utils.d.ts +6 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/utils.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/utils.js +7 -8
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/utils.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/tool-renderer.js +2 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/tool-renderer.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/index.d.ts +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/runner.d.ts +4 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/runner.js +2 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/types.d.ts +44 -7
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/key-id-schema.d.ts +6 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/key-id-schema.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/key-id-schema.js +16 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/key-id-schema.js.map +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings-schema.d.ts +4 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings-schema.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings-schema.js +16 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings-schema.js.map +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings.d.ts +198 -66
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings.js +26 -23
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/mcp-servers.d.ts +8 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/mcp-servers.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/mcp-servers.js +30 -7
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/mcp-servers.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-config.d.ts +695 -74
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-config.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-config.js +16 -166
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-config.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-resolver.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-resolver.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-runtime.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-runtime.js +13 -7
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-runtime.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/nested-tool-calls.d.ts +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/nested-tool-calls.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/nested-tool-calls.js +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/nested-tool-calls.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js +3 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/project-trust.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/project-trust.js +2 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/project-trust.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/remote-catalog-provider.d.ts +12 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/remote-catalog-provider.js +82 -24
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/remote-catalog-provider.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.d.ts +3 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.js +9 -4
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.d.ts +13 -4
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.js +19 -6
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-defaults.d.ts +65 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-defaults.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-defaults.js +66 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-defaults.js.map +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-manager.d.ts +15 -145
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-manager.js +85 -57
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-schema.d.ts +228 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-schema.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-schema.js +287 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-schema.js.map +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/skills.d.ts +4 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/skills.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/skills.js +6 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/skills.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.d.ts +6 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js +9 -4
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/output-accumulator.js +4 -10
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/output-accumulator.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/read.d.ts +13 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/read.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/read.js +18 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/read.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/render-utils.d.ts +18 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/render-utils.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/render-utils.js +46 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/render-utils.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/renderers/bash.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/renderers/bash.js +7 -35
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/renderers/bash.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/renderers/edit.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/renderers/edit.js +5 -4
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/renderers/edit.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/execute.js +165 -48
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/execute.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/index.js +3 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/renderer.d.ts +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/renderer.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/renderer.js +9 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/renderer.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/tool.d.ts +15 -14
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/tool.js +58 -38
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/tool.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/llama/provider.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/llama/provider.js +34 -11
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/llama/provider.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/cli.js +22 -31
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/cli.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/index.js +188 -84
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/oauth.d.ts +5 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/oauth.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/oauth.js +36 -10
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/oauth.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/resources.d.ts +3 -10
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/resources.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/resources.js +4 -5
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/resources.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/runtime.d.ts +7 -7
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/runtime.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/runtime.js +26 -44
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/runtime.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/tools.d.ts +4 -4
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/tools.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/tools.js +68 -16
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/tools.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/ui.d.ts +3 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/ui.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/ui.js +10 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/ui.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/tool-search/tool.d.ts +0 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/tool-search/tool.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/tool-search/tool.js +2 -4
- package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/tool-search/tool.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/index.d.ts +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/main.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/main.js +4 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/main.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/bash-execution.d.ts +5 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/bash-execution.js +17 -14
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.d.ts +2 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.js +5 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.d.ts +2 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.js +5 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/custom-entry.d.ts +3 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/custom-entry.js +8 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/custom-message.js +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-selector.js +4 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.d.ts +2 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.js +5 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/status-indicator.d.ts +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/status-indicator.js +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +5 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +10 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +9 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js +103 -40
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/program-status-reporter.d.ts +34 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/program-status-reporter.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/program-status-reporter.js +110 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/program-status-reporter.js.map +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/dark.json +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/light.json +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-schema.d.ts +28 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-schema.js +105 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-schema.js.map +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-tokens.d.ts +257 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-tokens.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-tokens.js +94 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-tokens.js.map +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts +13 -16
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js +22 -29
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/print-mode.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/print-mode.js +4 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/print-mode.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js +24 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/ansi.d.ts +8 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/ansi.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/ansi.js +30 -11
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/ansi.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/clipboard.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/clipboard.js +18 -12
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/clipboard.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize-core.d.ts +12 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize-core.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize-core.js +5 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize-core.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize-worker.js +3 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize-worker.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize.js +9 -10
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/output-files.d.ts +15 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/output-files.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/output-files.js +30 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/output-files.js.map +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/syntax-highlight.js +6 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/syntax-highlight.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/docs/cli-integration.md +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/docs/cli.md +19 -7
- package/node_modules/@earendil-works/pi-coding-agent/docs/codemode.md +30 -9
- package/node_modules/@earendil-works/pi-coding-agent/docs/compaction.md +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/docs/environment-variables.md +3 -1
- package/node_modules/@earendil-works/pi-coding-agent/docs/extensions.md +7 -4
- package/node_modules/@earendil-works/pi-coding-agent/docs/json.md +3 -3
- package/node_modules/@earendil-works/pi-coding-agent/docs/keybindings.md +5 -4
- package/node_modules/@earendil-works/pi-coding-agent/docs/llama-cpp.md +8 -1
- package/node_modules/@earendil-works/pi-coding-agent/docs/mcp.md +4 -2
- package/node_modules/@earendil-works/pi-coding-agent/docs/message-types.md +22 -4
- package/node_modules/@earendil-works/pi-coding-agent/docs/models.md +5 -1
- package/node_modules/@earendil-works/pi-coding-agent/docs/providers.md +47 -0
- package/node_modules/@earendil-works/pi-coding-agent/docs/settings.md +6 -4
- package/node_modules/@earendil-works/pi-coding-agent/docs/terminal-setup.md +14 -0
- package/node_modules/@earendil-works/pi-coding-agent/docs/themes.md +4 -2
- package/node_modules/@earendil-works/pi-coding-agent/docs/tui.md +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/examples/README.md +0 -3
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/dynamic-resources/dynamic.json +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/gondolin/package-lock.json +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/gondolin/package.json +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/overlay-test.ts +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/plan-mode/index.ts +6 -2
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/sandbox/package-lock.json +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/sandbox/package.json +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/with-deps/package-lock.json +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/with-deps/package.json +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/package.json +10 -21
- package/node_modules/@earendil-works/pi-coding-agent/schemas/keybindings.schema.json +393 -0
- package/node_modules/@earendil-works/pi-coding-agent/schemas/models.schema.json +1157 -0
- package/node_modules/@earendil-works/pi-coding-agent/schemas/settings.schema.json +765 -0
- package/node_modules/@earendil-works/pi-coding-agent/schemas/theme.schema.json +365 -0
- package/node_modules/@earendil-works/pi-durable/CHANGELOG.md +114 -0
- package/node_modules/@earendil-works/pi-durable/README.md +164 -12
- package/node_modules/@earendil-works/pi-durable/dist/codemode/codemode.d.ts +173 -0
- package/node_modules/@earendil-works/pi-durable/dist/codemode/codemode.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/codemode/codemode.js +886 -0
- package/node_modules/@earendil-works/pi-durable/dist/codemode/codemode.js.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/codemode/describe.d.ts +38 -0
- package/node_modules/@earendil-works/pi-durable/dist/codemode/describe.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/codemode/describe.js +119 -0
- package/node_modules/@earendil-works/pi-durable/dist/codemode/describe.js.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/codemode/index.d.ts +3 -0
- package/node_modules/@earendil-works/pi-durable/dist/codemode/index.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/codemode/index.js +3 -0
- package/node_modules/@earendil-works/pi-durable/dist/codemode/index.js.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/codemode/models.d.ts +28 -0
- package/node_modules/@earendil-works/pi-durable/dist/codemode/models.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/codemode/models.js +231 -0
- package/node_modules/@earendil-works/pi-durable/dist/codemode/models.js.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/codemode/output.d.ts +41 -0
- package/node_modules/@earendil-works/pi-durable/dist/codemode/output.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/codemode/output.js +167 -0
- package/node_modules/@earendil-works/pi-durable/dist/codemode/output.js.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/env/decode.d.ts +16 -0
- package/node_modules/@earendil-works/pi-durable/dist/env/decode.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/env/decode.js +28 -0
- package/node_modules/@earendil-works/pi-durable/dist/env/decode.js.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/env/index.d.ts +197 -3
- package/node_modules/@earendil-works/pi-durable/dist/env/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/env/index.js +2 -0
- package/node_modules/@earendil-works/pi-durable/dist/env/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/env/line-scan.d.ts +13 -0
- package/node_modules/@earendil-works/pi-durable/dist/env/line-scan.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/env/line-scan.js +147 -0
- package/node_modules/@earendil-works/pi-durable/dist/env/line-scan.js.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/env/node-watch.d.ts +29 -0
- package/node_modules/@earendil-works/pi-durable/dist/env/node-watch.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/env/node-watch.js +485 -0
- package/node_modules/@earendil-works/pi-durable/dist/env/node-watch.js.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/env/node.d.ts +11 -2
- package/node_modules/@earendil-works/pi-durable/dist/env/node.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/env/node.js +284 -21
- package/node_modules/@earendil-works/pi-durable/dist/env/node.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/errors.d.ts +20 -3
- package/node_modules/@earendil-works/pi-durable/dist/errors.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/errors.js +34 -5
- package/node_modules/@earendil-works/pi-durable/dist/errors.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/agent.d.ts +7 -3
- package/node_modules/@earendil-works/pi-durable/dist/harness/agent.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/agent.js +81 -25
- package/node_modules/@earendil-works/pi-durable/dist/harness/agent.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/compaction.d.ts +6 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/compaction.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/compaction.js +11 -8
- package/node_modules/@earendil-works/pi-durable/dist/harness/compaction.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/context.d.ts +29 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/context.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/context.js +125 -24
- package/node_modules/@earendil-works/pi-durable/dist/harness/context.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/events.d.ts +35 -15
- package/node_modules/@earendil-works/pi-durable/dist/harness/events.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/events.js +77 -23
- package/node_modules/@earendil-works/pi-durable/dist/harness/events.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/generation.d.ts +2 -0
- package/node_modules/@earendil-works/pi-durable/dist/harness/generation.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/generation.js +40 -16
- package/node_modules/@earendil-works/pi-durable/dist/harness/generation.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/harness.d.ts +7 -0
- package/node_modules/@earendil-works/pi-durable/dist/harness/harness.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/harness.js +56 -28
- package/node_modules/@earendil-works/pi-durable/dist/harness/harness.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/inbox.d.ts +16 -4
- package/node_modules/@earendil-works/pi-durable/dist/harness/inbox.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/inbox.js +26 -3
- package/node_modules/@earendil-works/pi-durable/dist/harness/inbox.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/live.d.ts +74 -17
- package/node_modules/@earendil-works/pi-durable/dist/harness/live.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/live.js +66 -14
- package/node_modules/@earendil-works/pi-durable/dist/harness/live.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/output.d.ts +13 -6
- package/node_modules/@earendil-works/pi-durable/dist/harness/output.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/output.js +75 -18
- package/node_modules/@earendil-works/pi-durable/dist/harness/output.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/scheduler.d.ts +18 -5
- package/node_modules/@earendil-works/pi-durable/dist/harness/scheduler.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/scheduler.js +794 -168
- package/node_modules/@earendil-works/pi-durable/dist/harness/scheduler.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/submissions.d.ts +7 -4
- package/node_modules/@earendil-works/pi-durable/dist/harness/submissions.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/submissions.js +32 -13
- package/node_modules/@earendil-works/pi-durable/dist/harness/submissions.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/task-graph.d.ts +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/task-graph.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/task-graph.js +15 -10
- package/node_modules/@earendil-works/pi-durable/dist/harness/task-graph.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/tool.d.ts +45 -5
- package/node_modules/@earendil-works/pi-durable/dist/harness/tool.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/tool.js +400 -67
- package/node_modules/@earendil-works/pi-durable/dist/harness/tool.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/types.d.ts +194 -17
- package/node_modules/@earendil-works/pi-durable/dist/harness/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/util.d.ts +6 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/util.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/util.js +5 -2
- package/node_modules/@earendil-works/pi-durable/dist/harness/util.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/view.d.ts +6 -2
- package/node_modules/@earendil-works/pi-durable/dist/harness/view.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/harness/view.js +22 -12
- package/node_modules/@earendil-works/pi-durable/dist/harness/view.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/images/cloudflare.d.ts +4 -0
- package/node_modules/@earendil-works/pi-durable/dist/images/cloudflare.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/images/cloudflare.js +9 -0
- package/node_modules/@earendil-works/pi-durable/dist/images/cloudflare.js.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/images/exif.d.ts +3 -0
- package/node_modules/@earendil-works/pi-durable/dist/images/exif.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/images/exif.js +71 -0
- package/node_modules/@earendil-works/pi-durable/dist/images/exif.js.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/images/index.d.ts +18 -0
- package/node_modules/@earendil-works/pi-durable/dist/images/index.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/images/index.js +125 -0
- package/node_modules/@earendil-works/pi-durable/dist/images/index.js.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/images/node-worker.d.ts +17 -0
- package/node_modules/@earendil-works/pi-durable/dist/images/node-worker.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/images/node-worker.js +16 -0
- package/node_modules/@earendil-works/pi-durable/dist/images/node-worker.js.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/images/node.d.ts +21 -0
- package/node_modules/@earendil-works/pi-durable/dist/images/node.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/images/node.js +121 -0
- package/node_modules/@earendil-works/pi-durable/dist/images/node.js.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/index.d.ts +7 -7
- package/node_modules/@earendil-works/pi-durable/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/index.js +4 -4
- package/node_modules/@earendil-works/pi-durable/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/search.d.ts +13 -0
- package/node_modules/@earendil-works/pi-durable/dist/search.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/search.js +85 -0
- package/node_modules/@earendil-works/pi-durable/dist/search.js.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/session/observation.d.ts +10 -3
- package/node_modules/@earendil-works/pi-durable/dist/session/observation.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/session/observation.js +24 -34
- package/node_modules/@earendil-works/pi-durable/dist/session/observation.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/session/session.d.ts +71 -6
- package/node_modules/@earendil-works/pi-durable/dist/session/session.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/session/session.js +463 -50
- package/node_modules/@earendil-works/pi-durable/dist/session/session.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/session/transaction.d.ts +2 -0
- package/node_modules/@earendil-works/pi-durable/dist/session/transaction.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/session/transaction.js +19 -1
- package/node_modules/@earendil-works/pi-durable/dist/session/transaction.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/storage/jsonl/storage.d.ts +8 -0
- package/node_modules/@earendil-works/pi-durable/dist/storage/jsonl/storage.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/storage/jsonl/storage.js +2 -1
- package/node_modules/@earendil-works/pi-durable/dist/storage/jsonl/storage.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/storage/memory.d.ts +2 -0
- package/node_modules/@earendil-works/pi-durable/dist/storage/memory.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/storage/memory.js +79 -27
- package/node_modules/@earendil-works/pi-durable/dist/storage/memory.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/storage/scan.d.ts +18 -0
- package/node_modules/@earendil-works/pi-durable/dist/storage/scan.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/storage/scan.js +29 -0
- package/node_modules/@earendil-works/pi-durable/dist/storage/scan.js.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/storage/sqlite/cloudflare.d.ts +46 -0
- package/node_modules/@earendil-works/pi-durable/dist/storage/sqlite/cloudflare.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/storage/sqlite/cloudflare.js +106 -0
- package/node_modules/@earendil-works/pi-durable/dist/storage/sqlite/cloudflare.js.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/storage/sqlite/storage.d.ts +2 -0
- package/node_modules/@earendil-works/pi-durable/dist/storage/sqlite/storage.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/storage/sqlite/storage.js +77 -27
- package/node_modules/@earendil-works/pi-durable/dist/storage/sqlite/storage.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/testing/env-conformance.d.ts +7 -0
- package/node_modules/@earendil-works/pi-durable/dist/testing/env-conformance.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/testing/env-conformance.js +531 -0
- package/node_modules/@earendil-works/pi-durable/dist/testing/env-conformance.js.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/testing/index.d.ts +3 -2
- package/node_modules/@earendil-works/pi-durable/dist/testing/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/testing/index.js +2 -1
- package/node_modules/@earendil-works/pi-durable/dist/testing/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/testing/runner.d.ts +4 -2
- package/node_modules/@earendil-works/pi-durable/dist/testing/runner.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/testing/runner.js +9 -0
- package/node_modules/@earendil-works/pi-durable/dist/testing/runner.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/testing/storage-conformance.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/testing/storage-conformance.js +61 -2
- package/node_modules/@earendil-works/pi-durable/dist/testing/storage-conformance.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/testing/types.d.ts +20 -0
- package/node_modules/@earendil-works/pi-durable/dist/testing/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/testing/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/tool-search/index.d.ts +2 -0
- package/node_modules/@earendil-works/pi-durable/dist/tool-search/index.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/tool-search/index.js +2 -0
- package/node_modules/@earendil-works/pi-durable/dist/tool-search/index.js.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/tool-search/tool-search.d.ts +23 -0
- package/node_modules/@earendil-works/pi-durable/dist/tool-search/tool-search.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/tool-search/tool-search.js +84 -0
- package/node_modules/@earendil-works/pi-durable/dist/tool-search/tool-search.js.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/tools/bash.d.ts +30 -3
- package/node_modules/@earendil-works/pi-durable/dist/tools/bash.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/tools/bash.js +105 -37
- package/node_modules/@earendil-works/pi-durable/dist/tools/bash.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/tools/edit.js +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/tools/edit.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/tools/image-processor.d.ts +47 -0
- package/node_modules/@earendil-works/pi-durable/dist/tools/image-processor.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/tools/image-processor.js +30 -0
- package/node_modules/@earendil-works/pi-durable/dist/tools/image-processor.js.map +1 -0
- package/node_modules/@earendil-works/pi-durable/dist/tools/image.d.ts +18 -0
- package/node_modules/@earendil-works/pi-durable/dist/tools/image.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/tools/image.js +86 -0
- package/node_modules/@earendil-works/pi-durable/dist/tools/image.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/tools/index.d.ts +26 -3
- package/node_modules/@earendil-works/pi-durable/dist/tools/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/tools/index.js +14 -6
- package/node_modules/@earendil-works/pi-durable/dist/tools/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/tools/read.d.ts +10 -2
- package/node_modules/@earendil-works/pi-durable/dist/tools/read.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/tools/read.js +212 -78
- package/node_modules/@earendil-works/pi-durable/dist/tools/read.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/tools/write.js +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/tools/write.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/truncate.d.ts +9 -0
- package/node_modules/@earendil-works/pi-durable/dist/truncate.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/truncate.js +12 -4
- package/node_modules/@earendil-works/pi-durable/dist/truncate.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/types.d.ts +89 -12
- package/node_modules/@earendil-works/pi-durable/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-durable/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-durable/package.json +50 -5
- package/node_modules/@earendil-works/pi-mcp/CHANGELOG.md +29 -0
- package/node_modules/@earendil-works/pi-mcp/dist/auth-provider.d.ts +4 -0
- package/node_modules/@earendil-works/pi-mcp/dist/auth-provider.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-mcp/dist/auth-provider.js.map +1 -1
- package/node_modules/@earendil-works/pi-mcp/dist/client.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-mcp/dist/client.js +9 -5
- package/node_modules/@earendil-works/pi-mcp/dist/client.js.map +1 -1
- package/node_modules/@earendil-works/pi-mcp/dist/index.d.ts +1 -1
- package/node_modules/@earendil-works/pi-mcp/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-mcp/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-mcp/dist/oauth/discovery.d.ts +3 -0
- package/node_modules/@earendil-works/pi-mcp/dist/oauth/discovery.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-mcp/dist/oauth/discovery.js +8 -5
- package/node_modules/@earendil-works/pi-mcp/dist/oauth/discovery.js.map +1 -1
- package/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.d.ts +3 -2
- package/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.js +3 -1
- package/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.js.map +1 -1
- package/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.d.ts +4 -0
- package/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.js +35 -7
- package/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.js.map +1 -1
- package/node_modules/@earendil-works/pi-mcp/dist/oauth/types.d.ts +5 -0
- package/node_modules/@earendil-works/pi-mcp/dist/oauth/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-mcp/dist/oauth/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-mcp/dist/protocol/content.d.ts +2 -1
- package/node_modules/@earendil-works/pi-mcp/dist/protocol/content.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-mcp/dist/protocol/content.js.map +1 -1
- package/node_modules/@earendil-works/pi-mcp/dist/transports/streamable-http.d.ts +9 -2
- package/node_modules/@earendil-works/pi-mcp/dist/transports/streamable-http.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-mcp/dist/transports/streamable-http.js +28 -19
- package/node_modules/@earendil-works/pi-mcp/dist/transports/streamable-http.js.map +1 -1
- package/node_modules/@earendil-works/pi-mcp/dist/transports/transport.d.ts +9 -1
- package/node_modules/@earendil-works/pi-mcp/dist/transports/transport.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-mcp/dist/transports/transport.js.map +1 -1
- package/node_modules/@earendil-works/pi-mcp/package.json +2 -2
- package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/README.md +5 -3
- package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/box.js +4 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/box.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +3 -3
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/input.js +4 -4
- package/node_modules/@earendil-works/pi-tui/dist/components/input.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/text.js +4 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/text.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +2 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.js +3 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +4 -4
- package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/keybindings.js +4 -4
- package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/keys.js +52 -20
- package/node_modules/@earendil-works/pi-tui/dist/keys.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/program-status.d.ts +23 -0
- package/node_modules/@earendil-works/pi-tui/dist/program-status.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/program-status.js +43 -0
- package/node_modules/@earendil-works/pi-tui/dist/program-status.js.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts +4 -2
- package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js +36 -1
- package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +5 -0
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +17 -0
- package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal.js +46 -2
- package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts +2 -0
- package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js +8 -4
- package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.js +2 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +11 -0
- package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.js +23 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/utils.js +5 -2
- package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/node_modules/@silvia-odwyer/photon/LICENSE.md +201 -0
- package/node_modules/@silvia-odwyer/photon/README.md +158 -0
- package/node_modules/@silvia-odwyer/photon/package.json +23 -0
- package/node_modules/@silvia-odwyer/photon/photon_rs.d.ts +3443 -0
- package/node_modules/@silvia-odwyer/photon/photon_rs.js +4572 -0
- package/node_modules/@silvia-odwyer/photon/photon_rs_bg.wasm +0 -0
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/crypto.d.ts +2 -2
- package/node_modules/@types/node/dgram.d.ts +1 -1
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/node/util.d.ts +6 -3
- package/node_modules/@types/node/zlib.d.ts +6 -0
- package/package.json +7 -8
- package/runtime-package.json +7 -9
- package/scripts/check-install-toolchain.mjs +64 -40
- package/shipping-sbom.cdx.json +126 -160
- package/shipping-source.json +15 -15
- package/node_modules/@earendil-works/chord/dist/api.d.ts +0 -20
- package/node_modules/@earendil-works/chord/dist/api.d.ts.map +0 -1
- package/node_modules/@earendil-works/chord/dist/api.js +0 -77
- package/node_modules/@earendil-works/chord/dist/api.js.map +0 -1
- package/node_modules/@earendil-works/chord/dist/bundler.d.ts +0 -6
- package/node_modules/@earendil-works/chord/dist/bundler.d.ts.map +0 -1
- package/node_modules/@earendil-works/chord/dist/bundler.js +0 -3
- package/node_modules/@earendil-works/chord/dist/bundler.js.map +0 -1
- package/node_modules/@earendil-works/chord/dist/facets/host.d.ts +0 -12
- package/node_modules/@earendil-works/chord/dist/facets/host.d.ts.map +0 -1
- package/node_modules/@earendil-works/chord/dist/facets/host.js +0 -763
- package/node_modules/@earendil-works/chord/dist/facets/host.js.map +0 -1
- package/node_modules/@earendil-works/chord/dist/facets/loader.d.ts +0 -3
- package/node_modules/@earendil-works/chord/dist/facets/loader.d.ts.map +0 -1
- package/node_modules/@earendil-works/chord/dist/facets/loader.js +0 -5
- package/node_modules/@earendil-works/chord/dist/facets/loader.js.map +0 -1
- package/node_modules/@earendil-works/chord/dist/node/bundle-loader.d.ts +0 -30
- package/node_modules/@earendil-works/chord/dist/node/bundle-loader.d.ts.map +0 -1
- package/node_modules/@earendil-works/chord/dist/node/bundle-loader.js +0 -377
- package/node_modules/@earendil-works/chord/dist/node/bundle-loader.js.map +0 -1
- package/node_modules/@earendil-works/chord/dist/node/bundle.d.ts +0 -26
- package/node_modules/@earendil-works/chord/dist/node/bundle.d.ts.map +0 -1
- package/node_modules/@earendil-works/chord/dist/node/bundle.js +0 -183
- package/node_modules/@earendil-works/chord/dist/node/bundle.js.map +0 -1
- package/node_modules/@earendil-works/chord/dist/node/manifest.d.ts +0 -36
- package/node_modules/@earendil-works/chord/dist/node/manifest.d.ts.map +0 -1
- package/node_modules/@earendil-works/chord/dist/node/manifest.js +0 -6
- package/node_modules/@earendil-works/chord/dist/node/manifest.js.map +0 -1
- package/node_modules/@earendil-works/chord/dist/node/package.d.ts +0 -15
- package/node_modules/@earendil-works/chord/dist/node/package.d.ts.map +0 -1
- package/node_modules/@earendil-works/chord/dist/node/package.js +0 -199
- package/node_modules/@earendil-works/chord/dist/node/package.js.map +0 -1
- package/node_modules/@earendil-works/chord/dist/services/consumer.d.ts +0 -11
- package/node_modules/@earendil-works/chord/dist/services/consumer.d.ts.map +0 -1
- package/node_modules/@earendil-works/chord/dist/services/consumer.js +0 -585
- package/node_modules/@earendil-works/chord/dist/services/consumer.js.map +0 -1
- package/node_modules/@earendil-works/chord/dist/services/errors.d.ts +0 -8
- package/node_modules/@earendil-works/chord/dist/services/errors.d.ts.map +0 -1
- package/node_modules/@earendil-works/chord/dist/services/errors.js +0 -22
- package/node_modules/@earendil-works/chord/dist/services/errors.js.map +0 -1
- package/node_modules/@earendil-works/chord/dist/services/handle.d.ts +0 -15
- package/node_modules/@earendil-works/chord/dist/services/handle.d.ts.map +0 -1
- package/node_modules/@earendil-works/chord/dist/services/handle.js +0 -101
- package/node_modules/@earendil-works/chord/dist/services/handle.js.map +0 -1
- package/node_modules/@earendil-works/chord/dist/services/instances.d.ts +0 -26
- package/node_modules/@earendil-works/chord/dist/services/instances.d.ts.map +0 -1
- package/node_modules/@earendil-works/chord/dist/services/instances.js +0 -140
- package/node_modules/@earendil-works/chord/dist/services/instances.js.map +0 -1
- package/node_modules/@earendil-works/chord/dist/services/loopback.d.ts +0 -5
- package/node_modules/@earendil-works/chord/dist/services/loopback.d.ts.map +0 -1
- package/node_modules/@earendil-works/chord/dist/services/loopback.js +0 -15
- package/node_modules/@earendil-works/chord/dist/services/loopback.js.map +0 -1
- package/node_modules/@earendil-works/chord/dist/services/provider.d.ts +0 -37
- package/node_modules/@earendil-works/chord/dist/services/provider.d.ts.map +0 -1
- package/node_modules/@earendil-works/chord/dist/services/provider.js +0 -521
- package/node_modules/@earendil-works/chord/dist/services/provider.js.map +0 -1
- package/node_modules/@earendil-works/chord/dist/services/state-codec.d.ts +0 -15
- package/node_modules/@earendil-works/chord/dist/services/state-codec.d.ts.map +0 -1
- package/node_modules/@earendil-works/chord/dist/services/state-codec.js +0 -133
- package/node_modules/@earendil-works/chord/dist/services/state-codec.js.map +0 -1
- package/node_modules/@earendil-works/chord/dist/services/state-internals.d.ts +0 -13
- package/node_modules/@earendil-works/chord/dist/services/state-internals.d.ts.map +0 -1
- package/node_modules/@earendil-works/chord/dist/services/state-internals.js +0 -10
- package/node_modules/@earendil-works/chord/dist/services/state-internals.js.map +0 -1
- package/node_modules/@earendil-works/chord/dist/services/state.d.ts +0 -28
- package/node_modules/@earendil-works/chord/dist/services/state.d.ts.map +0 -1
- package/node_modules/@earendil-works/chord/dist/services/state.js.map +0 -1
- package/node_modules/@earendil-works/chord/dist/services/wire.d.ts +0 -63
- package/node_modules/@earendil-works/chord/dist/services/wire.d.ts.map +0 -1
- package/node_modules/@earendil-works/chord/dist/services/wire.js +0 -186
- package/node_modules/@earendil-works/chord/dist/services/wire.js.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.d.ts +0 -3
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js +0 -14
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts +0 -6
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js +0 -8
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +0 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/anthropic-messages-MVG2FL56.js +0 -6
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/azure-openai-responses-7AMFUIWJ.js +0 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-6FX7UEPL.js +0 -132
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-7JGR3GZN.js +0 -11
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-A3JYRWB6.js +0 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-IKZJX7ZT.js +0 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-OSKPX3Z5.js +0 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-OYBSLV7Y.js +0 -16
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-PDFMCAOZ.js +0 -19
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-U7B62NSC.js +0 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-VIV3CWXG.js +0 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-WCQZGZ6I.js +0 -82
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/cloudflare-workers-ai-system-one-X5PVWWYJ.js +0 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/easter-egg-3d-T5FFWIBR.js +0 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/execute-RYVK27GT.js +0 -388
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/mistral-conversations-7DAUEE4N.js +0 -5
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/openai-codex-responses-TC3OK7B4.js +0 -10
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/runtime-D5I2NTIF.js +0 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/typesafe-system-one-A4CZTQWZ.js +0 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/virtual-modules-KVWJD3T3.js +0 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-json.d.ts +0 -85
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-json.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-json.js +0 -132
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-json.js.map +0 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-schema.json +0 -361
- package/node_modules/@earendil-works/pi-coding-agent/examples/plugins/pi-example-plugin/README.md +0 -38
- package/node_modules/@earendil-works/pi-coding-agent/examples/plugins/pi-example-plugin/package.json +0 -10
- package/node_modules/@earendil-works/pi-coding-agent/examples/plugins/pi-example-plugin/src/contract.ts +0 -13
- package/node_modules/@earendil-works/pi-coding-agent/examples/plugins/pi-example-plugin/src/session.ts +0 -24
- package/node_modules/@earendil-works/pi-coding-agent/examples/plugins/pi-example-plugin/src/tui.ts +0 -31
- package/node_modules/@esbuild/linux-x64/README.md +0 -3
- package/node_modules/@esbuild/linux-x64/bin/esbuild +0 -0
- package/node_modules/@esbuild/linux-x64/package.json +0 -20
- package/node_modules/esbuild/LICENSE.md +0 -21
- package/node_modules/esbuild/README.md +0 -3
- package/node_modules/esbuild/bin/esbuild +0 -223
- package/node_modules/esbuild/install.js +0 -300
- package/node_modules/esbuild/lib/main.d.ts +0 -720
- package/node_modules/esbuild/lib/main.js +0 -2536
- package/node_modules/esbuild/package.json +0 -74
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.js","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AAaA,6GAA6G;AAC7G,MAAe,QAAQ;IACtB,QAAQ,CAAuC;IAC/C,MAAM,GAAY,EAAE,CAAC;IACZ,cAAc,GAAG,IAAI,GAAG,EAA4B,CAAC;IAC9D,OAAO,GAAG,KAAK,CAAC;IAEhB,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAKD,IAAI,CAAC,KAAY;QAChB,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO;QACzB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IAED,OAAO,CAAC,OAA+B;QACtC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,MAA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KAAY;QAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,KAAK,IAAI;YAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;YACzD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAES,QAAQ;QACjB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI,IAAI;YAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/D,CAAC;CACD;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAqB,EAAiB,EAAE,CAAC,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC","sourcesContent":["import type { Frame } from \"./wire.ts\";\n\n/** An ordered (FIFO), bidirectional frame channel between two hosts. */\nexport interface Link {\n\treadonly closed: boolean;\n\tsend(frame: Frame): void;\n\t/** Sets the single receiver. Frames arriving earlier are queued. */\n\treceive(handler: (frame: Frame) => void): void;\n\tonClose(handler: (reason: string) => void): void;\n\t/** Closes both ends: the peer gets a `bye`. */\n\tclose(reason?: string): void;\n}\n\n/** Shared plumbing: receive queue, close handlers, `bye`. Transports implement `transmit` and `shutdown`. */\nabstract class BaseLink implements Link {\n\t#handler: ((frame: Frame) => void) | undefined;\n\t#queue: Frame[] = [];\n\treadonly #closeHandlers = new Set<(reason: string) => void>();\n\t#closed = false;\n\n\tget closed(): boolean {\n\t\treturn this.#closed;\n\t}\n\n\tprotected abstract transmit(frame: Frame): void;\n\tprotected abstract shutdown(): void;\n\n\tsend(frame: Frame): void {\n\t\tif (this.#closed) return;\n\t\tthis.transmit(frame);\n\t}\n\n\treceive(handler: (frame: Frame) => void): void {\n\t\tthis.#handler = handler;\n\t\tfor (const frame of this.#queue.splice(0)) handler(frame);\n\t}\n\n\tonClose(handler: (reason: string) => void): void {\n\t\tif (this.#closed) handler(\"closed\");\n\t\telse this.#closeHandlers.add(handler);\n\t}\n\n\tclose(reason = \"closed\"): void {\n\t\tif (this.#closed) return;\n\t\ttry {\n\t\t\tthis.transmit({ t: \"bye\", reason });\n\t\t} catch {\n\t\t\t// The transport may already be gone.\n\t\t}\n\t\tthis.ended(reason);\n\t}\n\n\t/** Delivers a parsed frame from the transport. */\n\tprotected deliver(frame: Frame): void {\n\t\tif (this.#closed) return;\n\t\tif (frame.t === \"bye\") {\n\t\t\tthis.ended(frame.reason ?? \"peer closed\");\n\t\t\treturn;\n\t\t}\n\t\tif (this.#handler === undefined) this.#queue.push(frame);\n\t\telse this.#handler(frame);\n\t}\n\n\t/** Marks the link closed (transport ended) and notifies once. */\n\tprotected ended(reason: string): void {\n\t\tif (this.#closed) return;\n\t\tthis.#closed = true;\n\t\tthis.#queue = [];\n\t\ttry {\n\t\t\tthis.shutdown();\n\t\t} finally {\n\t\t\tfor (const handler of this.#closeHandlers) handler(reason);\n\t\t\tthis.#closeHandlers.clear();\n\t\t}\n\t}\n}\n\n/** Parses a JSON frame; anything else is a protocol error. */\nfunction parseFrame(data: string): Frame {\n\tconst frame = JSON.parse(data) as Frame;\n\tif (frame === null || typeof frame !== \"object\" || typeof frame.t !== \"string\") throw new TypeError(\"not a frame\");\n\treturn frame;\n}\n\n// ─── memory ──────────────────────────────────────────────────────────────────\n\nexport class MemoryLink extends BaseLink {\n\tpeer: MemoryLink | undefined;\n\t#severed = false;\n\t#pending = Promise.resolve();\n\n\t/** Simulates a dead network: frames are dropped silently in both directions and no close is signalled. */\n\tsever(): void {\n\t\tthis.#severed = true;\n\t\tif (this.peer) this.peer.#severed = true;\n\t}\n\n\tprotected transmit(frame: Frame): void {\n\t\tif (this.#severed) return;\n\t\t// A JSON round trip detaches the frame (and rejects what JSON would mangle silently, e.g. bigint).\n\t\tconst data = JSON.stringify(frame);\n\t\tconst peer = this.peer;\n\t\t// One promise chain per direction keeps delivery FIFO and asynchronous, like a real transport.\n\t\tthis.#pending = this.#pending.then(() => {\n\t\t\tif (!this.#severed && peer !== undefined) peer.deliver(parseFrame(data));\n\t\t});\n\t}\n\n\tprotected shutdown(): void {\n\t\tconst peer = this.peer;\n\t\tthis.#pending = this.#pending.then(() => peer?.ended(\"peer closed\"));\n\t}\n}\n\n/** Two connected in-memory links (tests). */\nexport function memoryLinkPair(): [MemoryLink, MemoryLink] {\n\tconst a = new MemoryLink();\n\tconst b = new MemoryLink();\n\ta.peer = b;\n\tb.peer = a;\n\treturn [a, b];\n}\n\n// ─── Node IPC ────────────────────────────────────────────────────────────────\n\n/** `process` in a forked child, or the parent's `ChildProcess`. Structural, so Chord needs no Node types here. */\nexport interface IpcChannel {\n\treadonly connected: boolean;\n\tsend(message: unknown): boolean;\n\ton(event: \"message\", listener: (message: unknown) => void): unknown;\n\ton(event: \"disconnect\", listener: () => void): unknown;\n\toff(event: \"message\", listener: (message: unknown) => void): unknown;\n\toff(event: \"disconnect\", listener: () => void): unknown;\n}\n\n/** Chord frames on an IPC channel are wrapped as `{ chord2: frame }`; other messages (control) pass by. */\nexport class IpcLink extends BaseLink {\n\treadonly #channel: IpcChannel;\n\treadonly #onMessage = (message: unknown): void => {\n\t\tconst frame = (message as { chord2?: Frame } | null)?.chord2;\n\t\tif (frame !== undefined) this.deliver(frame);\n\t};\n\treadonly #onDisconnect = (): void => this.ended(\"ipc disconnected\");\n\n\tconstructor(channel: IpcChannel) {\n\t\tsuper();\n\t\tthis.#channel = channel;\n\t\tchannel.on(\"message\", this.#onMessage);\n\t\tchannel.on(\"disconnect\", this.#onDisconnect);\n\t}\n\n\tprotected transmit(frame: Frame): void {\n\t\tif (this.#channel.connected) this.#channel.send({ chord2: frame });\n\t}\n\n\tprotected shutdown(): void {\n\t\tthis.#channel.off(\"message\", this.#onMessage);\n\t\tthis.#channel.off(\"disconnect\", this.#onDisconnect);\n\t}\n}\n\nexport const ipcLink = (channel: IpcChannel): IpcLink => new IpcLink(channel);\n\n// ─── WebSocket ───────────────────────────────────────────────────────────────\n\n/** The WHATWG WebSocket surface: the browser `WebSocket`, Node's global `WebSocket`, and `ws` sockets. */\nexport interface WebSocketLike {\n\treadonly readyState: number;\n\tsend(data: string): void;\n\tclose(code?: number, reason?: string): void;\n\taddEventListener(type: \"message\", listener: (event: { readonly data: unknown }) => void): void;\n\taddEventListener(type: \"open\" | \"close\" | \"error\", listener: () => void): void;\n}\n\nconst OPEN = 1;\n\nexport class WebSocketLink extends BaseLink {\n\treadonly #socket: WebSocketLike;\n\t#outbox: string[] = [];\n\n\tconstructor(socket: WebSocketLike) {\n\t\tsuper();\n\t\tthis.#socket = socket;\n\t\tsocket.addEventListener(\"open\", () => {\n\t\t\tfor (const data of this.#outbox.splice(0)) socket.send(data);\n\t\t});\n\t\tsocket.addEventListener(\"message\", (event) => {\n\t\t\ttry {\n\t\t\t\tthis.deliver(parseFrame(typeof event.data === \"string\" ? event.data : String(event.data)));\n\t\t\t} catch {\n\t\t\t\tthis.close(\"protocol error\");\n\t\t\t}\n\t\t});\n\t\tsocket.addEventListener(\"close\", () => this.ended(\"socket closed\"));\n\t}\n\n\tprotected transmit(frame: Frame): void {\n\t\tconst data = JSON.stringify(frame);\n\t\tif (this.#socket.readyState === OPEN) this.#socket.send(data);\n\t\telse this.#outbox.push(data);\n\t}\n\n\tprotected shutdown(): void {\n\t\tthis.#outbox = [];\n\t\tif (this.#socket.readyState <= OPEN) this.#socket.close(1000);\n\t}\n}\n\nexport const webSocketLink = (socket: WebSocketLike): WebSocketLink => new WebSocketLink(socket);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAA0B,WAAW,EAAE,MAAM,WAAW,CAAC;AAmCrE,iHAAiH;AACjH,eAAO,MAAM,UAAU,EAAE,WAmBxB,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
// Node facet loader: `createHost({ loader: nodeLoader })`. Kept out of index.ts so the core stays browser-safe.
|
|
10
|
+
//
|
|
11
|
+
// TODO(loader): replace with an isolating, evicting loader. Every reload imports fresh module copies under a new
|
|
12
|
+
// query and the old copies are never evicted (they leak until the process exits). TUI plugins need isolation, which
|
|
13
|
+
// this loader does not provide.
|
|
14
|
+
import { registerHooks } from "node:module";
|
|
15
|
+
import { pathToFileURL } from "node:url";
|
|
16
|
+
const PARAM = "chord2-reload";
|
|
17
|
+
/** Directory URLs (trailing slash) of loaded facet modules; their files are re-imported on reload. */
|
|
18
|
+
const roots = new Set();
|
|
19
|
+
let hooked = false;
|
|
20
|
+
let generation = 0;
|
|
21
|
+
/**
|
|
22
|
+
* A query on the entry URL only re-imports the entry module: its relative imports would resolve to cached copies.
|
|
23
|
+
* This hook carries the reload query from a re-imported parent to children inside a facet module's directory.
|
|
24
|
+
* Modules outside (Chord itself, shared code) stay single instances.
|
|
25
|
+
*/
|
|
26
|
+
function hook() {
|
|
27
|
+
if (hooked)
|
|
28
|
+
return;
|
|
29
|
+
hooked = true;
|
|
30
|
+
registerHooks({
|
|
31
|
+
resolve(specifier, context, nextResolve) {
|
|
32
|
+
const result = nextResolve(specifier, context);
|
|
33
|
+
const version = context.parentURL === undefined ? null : new URL(context.parentURL).searchParams.get(PARAM);
|
|
34
|
+
if (version === null || !result.url.startsWith("file:"))
|
|
35
|
+
return result;
|
|
36
|
+
const url = new URL(result.url);
|
|
37
|
+
if (url.searchParams.has(PARAM) || ![...roots].some((root) => url.href.startsWith(root)))
|
|
38
|
+
return result;
|
|
39
|
+
url.searchParams.set(PARAM, version);
|
|
40
|
+
return { ...result, url: url.href };
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const toUrl = (module) => module instanceof URL
|
|
45
|
+
? new URL(module.href)
|
|
46
|
+
: new URL(module.startsWith("file:") ? module : pathToFileURL(module).href);
|
|
47
|
+
/** Imports fresh copies of facet modules (default export: a FacetDefinition); each facet is named by its URL. */
|
|
48
|
+
export const nodeLoader = async (modules) => {
|
|
49
|
+
hook();
|
|
50
|
+
const version = String(++generation);
|
|
51
|
+
const facets = [];
|
|
52
|
+
for (const module of modules) {
|
|
53
|
+
const url = toUrl(module);
|
|
54
|
+
url.search = "";
|
|
55
|
+
const name = url.href;
|
|
56
|
+
roots.add(new URL(".", url).href);
|
|
57
|
+
url.searchParams.set(PARAM, version);
|
|
58
|
+
// Owner-approved exception to the no-dynamic-import rule; see TODO(loader) above.
|
|
59
|
+
const loaded = (await import(__rewriteRelativeImportExtension(url.href)));
|
|
60
|
+
const definition = loaded.default;
|
|
61
|
+
if (definition === undefined || typeof definition.setup !== "function") {
|
|
62
|
+
throw new TypeError(`${name}: default export must be a facet (defineFacet)`);
|
|
63
|
+
}
|
|
64
|
+
facets.push({ name, setup: definition.setup, uses: definition.uses });
|
|
65
|
+
}
|
|
66
|
+
return facets;
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";;;;;;;;AAAA,gHAAgH;AAChH,EAAE;AACF,iHAAiH;AACjH,oHAAoH;AACpH,gCAAgC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC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,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC,CAAC","sourcesContent":["// Node facet loader: `createHost({ loader: nodeLoader })`. Kept out of index.ts so the core stays browser-safe.\n//\n// TODO(loader): replace with an isolating, evicting loader. Every reload imports fresh module copies under a new\n// query and the old copies are never evicted (they leak until the process exits). TUI plugins need isolation, which\n// this loader does not provide.\nimport { registerHooks } from \"node:module\";\nimport { pathToFileURL } from \"node:url\";\nimport type { Facet, FacetDefinition, FacetLoader } from \"./host.ts\";\n\nconst PARAM = \"chord2-reload\";\n\n/** Directory URLs (trailing slash) of loaded facet modules; their files are re-imported on reload. */\nconst roots = new Set<string>();\nlet hooked = false;\nlet generation = 0;\n\n/**\n * A query on the entry URL only re-imports the entry module: its relative imports would resolve to cached copies.\n * This hook carries the reload query from a re-imported parent to children inside a facet module's directory.\n * Modules outside (Chord itself, shared code) stay single instances.\n */\nfunction hook(): void {\n\tif (hooked) return;\n\thooked = true;\n\tregisterHooks({\n\t\tresolve(specifier, context, nextResolve) {\n\t\t\tconst result = nextResolve(specifier, context);\n\t\t\tconst version = context.parentURL === undefined ? null : new URL(context.parentURL).searchParams.get(PARAM);\n\t\t\tif (version === null || !result.url.startsWith(\"file:\")) return result;\n\t\t\tconst url = new URL(result.url);\n\t\t\tif (url.searchParams.has(PARAM) || ![...roots].some((root) => url.href.startsWith(root))) return result;\n\t\t\turl.searchParams.set(PARAM, version);\n\t\t\treturn { ...result, url: url.href };\n\t\t},\n\t});\n}\n\nconst toUrl = (module: string | URL): URL =>\n\tmodule instanceof URL\n\t\t? new URL(module.href)\n\t\t: new URL(module.startsWith(\"file:\") ? module : pathToFileURL(module).href);\n\n/** Imports fresh copies of facet modules (default export: a FacetDefinition); each facet is named by its URL. */\nexport const nodeLoader: FacetLoader = async (modules) => {\n\thook();\n\tconst version = String(++generation);\n\tconst facets: Facet[] = [];\n\tfor (const module of modules) {\n\t\tconst url = toUrl(module);\n\t\turl.search = \"\";\n\t\tconst name = url.href;\n\t\troots.add(new URL(\".\", url).href);\n\t\turl.searchParams.set(PARAM, version);\n\t\t// Owner-approved exception to the no-dynamic-import rule; see TODO(loader) above.\n\t\tconst loaded = (await import(url.href)) as { default?: FacetDefinition };\n\t\tconst definition = loaded.default;\n\t\tif (definition === undefined || typeof definition.setup !== \"function\") {\n\t\t\tthrow new TypeError(`${name}: default export must be a facet (defineFacet)`);\n\t\t}\n\t\tfacets.push({ name, setup: definition.setup, uses: definition.uses });\n\t}\n\treturn facets;\n};\n"]}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { type IpcLink } from "./link.ts";
|
|
2
|
+
/** Control messages share the IPC channel with chord frames: `{ chord2control: message }`. */
|
|
3
|
+
export type ControlMessage = {
|
|
4
|
+
readonly type: "init";
|
|
5
|
+
readonly value: unknown;
|
|
6
|
+
} | {
|
|
7
|
+
readonly type: "ready";
|
|
8
|
+
} | {
|
|
9
|
+
readonly type: "fatal";
|
|
10
|
+
readonly message: string;
|
|
11
|
+
readonly reason?: string;
|
|
12
|
+
} | {
|
|
13
|
+
readonly type: "shutdown";
|
|
14
|
+
} | {
|
|
15
|
+
readonly type: "status";
|
|
16
|
+
readonly activeCalls?: number;
|
|
17
|
+
readonly viewers?: number;
|
|
18
|
+
readonly durableTasks?: number;
|
|
19
|
+
};
|
|
20
|
+
export interface Liveness {
|
|
21
|
+
/** Started but not ready yet. */
|
|
22
|
+
readonly booting: boolean;
|
|
23
|
+
readonly activeCalls: number;
|
|
24
|
+
/** Viewers the child reports (it counts heartbeating subscribers). */
|
|
25
|
+
readonly viewers: number;
|
|
26
|
+
readonly durableTasks: number;
|
|
27
|
+
/** Milliseconds since the child last reported work (calls, viewers or tasks), or since it became ready. */
|
|
28
|
+
readonly idleFor: number;
|
|
29
|
+
}
|
|
30
|
+
export interface Exit {
|
|
31
|
+
readonly code: number | null;
|
|
32
|
+
readonly signal: string | null;
|
|
33
|
+
}
|
|
34
|
+
/** A running child: its link (for `host.accept`) and its exit. */
|
|
35
|
+
export interface Instance {
|
|
36
|
+
readonly pid: number;
|
|
37
|
+
readonly link: IpcLink;
|
|
38
|
+
readonly exited: Promise<Exit>;
|
|
39
|
+
send(message: ControlMessage): void;
|
|
40
|
+
/** Kills the child and everything it spawned. */
|
|
41
|
+
killTree(): void;
|
|
42
|
+
onControl(listener: (message: ControlMessage) => void): void;
|
|
43
|
+
}
|
|
44
|
+
export interface Driver {
|
|
45
|
+
spawn(): Instance;
|
|
46
|
+
}
|
|
47
|
+
export interface ForkDriverOptions {
|
|
48
|
+
/** The child's entry module. */
|
|
49
|
+
readonly entry: string;
|
|
50
|
+
readonly args?: readonly string[];
|
|
51
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
52
|
+
/** Node flags for the child, e.g. `["--import", sourceResolver]` (default: none). */
|
|
53
|
+
readonly execArgv?: readonly string[];
|
|
54
|
+
/** Sent to the child as its first control message (`childControl().init`). */
|
|
55
|
+
readonly init?: unknown;
|
|
56
|
+
/**
|
|
57
|
+
* A lock name: one live process per name, across managers and processes. The child acquires it as a kernel lock
|
|
58
|
+
* (`childControl().lock()`, before opening its storage); a second child fails to start with `unavailable/locked`.
|
|
59
|
+
*/
|
|
60
|
+
readonly lock?: string;
|
|
61
|
+
/** Optional stdout/stderr tap. Streams are still mirrored to the parent's standard output. */
|
|
62
|
+
readonly onOutput?: (stream: "stdout" | "stderr", chunk: Uint8Array) => void;
|
|
63
|
+
/** Optional application metadata tap; control messages and chord frames keep their normal handling. */
|
|
64
|
+
readonly onMessage?: (message: unknown) => void;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A process lock owned by the kernel for the holder's lifetime: an abstract socket (Linux, Android) or a named pipe
|
|
68
|
+
* (Windows) vanishes with its process, so there is no stale state to take over and no race between two would-be
|
|
69
|
+
* owners. Other platforms need a socket file, removed on exit; a leftover one nobody accepts on is taken over.
|
|
70
|
+
* The child acquires it (before opening storage), so the lock follows the process that owns the data.
|
|
71
|
+
*/
|
|
72
|
+
export declare function processLock(name: string): Promise<() => Promise<void>>;
|
|
73
|
+
export declare function forkDriver(options: ForkDriverOptions): Driver;
|
|
74
|
+
export interface HostManagerOptions {
|
|
75
|
+
readonly driver: Driver;
|
|
76
|
+
/** Evaluated every `checkInterval` while running; `false` stops the child. */
|
|
77
|
+
readonly keepAlive?: (liveness: Liveness) => boolean;
|
|
78
|
+
readonly checkInterval?: number;
|
|
79
|
+
/** Milliseconds a child may take to shut down before its process tree is killed (default 5000). */
|
|
80
|
+
readonly grace?: number;
|
|
81
|
+
/** Milliseconds to wait for `ready` (default 30000). */
|
|
82
|
+
readonly readyTimeout?: number;
|
|
83
|
+
/** The child exited on its own (crash, fatal) or after a stop. */
|
|
84
|
+
readonly onExit?: (exit: Exit) => void;
|
|
85
|
+
}
|
|
86
|
+
export interface HostManager {
|
|
87
|
+
readonly status: "stopped" | "starting" | "running" | "stopping";
|
|
88
|
+
readonly instance: Instance | undefined;
|
|
89
|
+
readonly liveness: Liveness;
|
|
90
|
+
/** Starts the child (or returns the running one) once it reported ready. Serialized with stop/replace. */
|
|
91
|
+
start(): Promise<Instance>;
|
|
92
|
+
/** Asks the child to shut down, then kills its process tree after the grace period. */
|
|
93
|
+
stop(): Promise<void>;
|
|
94
|
+
/** Stop, wait for the exit, start. */
|
|
95
|
+
replace(): Promise<Instance>;
|
|
96
|
+
}
|
|
97
|
+
export declare function createHostManager(options: HostManagerOptions): HostManager;
|
|
98
|
+
/** The child side of the control channel (call in the child's entry). */
|
|
99
|
+
export declare function childControl(channel?: NodeJS.Process): {
|
|
100
|
+
readonly init: Promise<unknown>;
|
|
101
|
+
/**
|
|
102
|
+
* Acquires the manager's lock (if one was configured) as a kernel lock held for this process's lifetime. Call it
|
|
103
|
+
* before opening storage. Fails with `unavailable/locked`, also reported to the manager as a fatal start error.
|
|
104
|
+
*/
|
|
105
|
+
lock(): Promise<void>;
|
|
106
|
+
ready(): void;
|
|
107
|
+
fatal(error: unknown): void;
|
|
108
|
+
report(status: {
|
|
109
|
+
activeCalls?: number;
|
|
110
|
+
viewers?: number;
|
|
111
|
+
durableTasks?: number;
|
|
112
|
+
}): void;
|
|
113
|
+
onShutdown(handler: () => void | Promise<void>): void;
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../src/manager.ts"],"names":[],"mappings":"AASA,OAAO,EAAmB,KAAK,OAAO,EAAW,MAAM,WAAW,CAAC;AAEnE,8FAA8F;AAC9F,MAAM,MAAM,cAAc,GACvB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAClD;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC1B;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9E;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GAC7B;IACA,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEL,MAAM,WAAW,QAAQ;IACxB,iCAAiC;IACjC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CA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,wBAAgB,YAAY,CAAC,OAAO,GAAE,MAAM,CAAC,OAAiB,GAAG;IAChE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAChC;;;OAGG;IACH,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,KAAK,IAAI,IAAI,CAAC;IACd,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5B,MAAM,CAAC,MAAM,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACxF,UAAU,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACtD,CAqCA"}
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
// Host manager (Node only): runs a child host process and keeps at most one instance of it alive.
|
|
2
|
+
import { fork } from "node:child_process";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { unlinkSync } from "node:fs";
|
|
5
|
+
import { rm } from "node:fs/promises";
|
|
6
|
+
import { connect, createServer } from "node:net";
|
|
7
|
+
import { tmpdir } from "node:os";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import { ChordError } from "./errors.js";
|
|
10
|
+
import { ipcLink } from "./link.js";
|
|
11
|
+
/**
|
|
12
|
+
* A process lock owned by the kernel for the holder's lifetime: an abstract socket (Linux, Android) or a named pipe
|
|
13
|
+
* (Windows) vanishes with its process, so there is no stale state to take over and no race between two would-be
|
|
14
|
+
* owners. Other platforms need a socket file, removed on exit; a leftover one nobody accepts on is taken over.
|
|
15
|
+
* The child acquires it (before opening storage), so the lock follows the process that owns the data.
|
|
16
|
+
*/
|
|
17
|
+
export async function processLock(name) {
|
|
18
|
+
const key = createHash("sha256").update(name).digest("hex").slice(0, 32);
|
|
19
|
+
const file = process.platform !== "win32" && process.platform !== "linux" && process.platform !== "android";
|
|
20
|
+
const address = process.platform === "win32"
|
|
21
|
+
? `\\\\.\\pipe\\chord2-${key}`
|
|
22
|
+
: file
|
|
23
|
+
? join(tmpdir(), `chord2-${key}.sock`)
|
|
24
|
+
: `\0chord2-${key}`;
|
|
25
|
+
const server = createServer((socket) => socket.end());
|
|
26
|
+
for (;;) {
|
|
27
|
+
try {
|
|
28
|
+
await new Promise((resolve, reject) => {
|
|
29
|
+
server.once("error", reject);
|
|
30
|
+
server.listen(address, () => {
|
|
31
|
+
server.removeListener("error", reject);
|
|
32
|
+
resolve();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error.code !== "EADDRINUSE")
|
|
39
|
+
throw error;
|
|
40
|
+
if (!file || (await accepting(address))) {
|
|
41
|
+
throw new ChordError("unavailable", `lock ${name} is held by another process`, { reason: "locked" });
|
|
42
|
+
}
|
|
43
|
+
await rm(address, { force: true });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const removeFile = () => {
|
|
47
|
+
try {
|
|
48
|
+
unlinkSync(address);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// Already gone.
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
if (file)
|
|
55
|
+
process.once("exit", removeFile);
|
|
56
|
+
return () => new Promise((resolve, reject) => {
|
|
57
|
+
if (file)
|
|
58
|
+
process.removeListener("exit", removeFile);
|
|
59
|
+
server.close((error) => (error ? reject(error) : resolve()));
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function accepting(address) {
|
|
63
|
+
return new Promise((resolve) => {
|
|
64
|
+
const socket = connect(address);
|
|
65
|
+
socket.once("connect", () => {
|
|
66
|
+
socket.destroy();
|
|
67
|
+
resolve(true);
|
|
68
|
+
});
|
|
69
|
+
socket.once("error", (error) => resolve(error.code !== "ECONNREFUSED" && error.code !== "ENOENT"));
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const LOCK_ENV = "CHORD2_LOCK";
|
|
73
|
+
export function forkDriver(options) {
|
|
74
|
+
return {
|
|
75
|
+
spawn() {
|
|
76
|
+
// Detached: the child leads a process group, so the whole tree can be killed.
|
|
77
|
+
const child = fork(options.entry, [...(options.args ?? [])], {
|
|
78
|
+
env: {
|
|
79
|
+
...process.env,
|
|
80
|
+
...options.env,
|
|
81
|
+
...(options.lock === undefined ? {} : { [LOCK_ENV]: options.lock }),
|
|
82
|
+
},
|
|
83
|
+
execArgv: [...(options.execArgv ?? [])],
|
|
84
|
+
detached: true,
|
|
85
|
+
stdio: ["ignore", options.onOutput ? "pipe" : "inherit", options.onOutput ? "pipe" : "inherit", "ipc"],
|
|
86
|
+
});
|
|
87
|
+
if (options.onOutput) {
|
|
88
|
+
for (const stream of ["stdout", "stderr"]) {
|
|
89
|
+
child[stream]?.on("data", (chunk) => {
|
|
90
|
+
options.onOutput(stream, chunk);
|
|
91
|
+
process[stream].write(chunk);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const pid = child.pid ?? -1;
|
|
96
|
+
const killGroup = () => {
|
|
97
|
+
try {
|
|
98
|
+
process.kill(-pid, "SIGKILL");
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
// No group left.
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const exited = new Promise((resolve) => {
|
|
105
|
+
child.once("exit", (code, signal) => {
|
|
106
|
+
// However the leader ended (graceful, crash, kill), nothing it spawned outlives it.
|
|
107
|
+
killGroup();
|
|
108
|
+
resolve({ code, signal });
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
const listeners = new Set();
|
|
112
|
+
child.on("message", (message) => {
|
|
113
|
+
options.onMessage?.(message);
|
|
114
|
+
const control = message?.chord2control;
|
|
115
|
+
if (control !== undefined)
|
|
116
|
+
for (const listener of listeners)
|
|
117
|
+
listener(control);
|
|
118
|
+
});
|
|
119
|
+
const send = (message) => {
|
|
120
|
+
if (child.connected)
|
|
121
|
+
child.send({ chord2control: message });
|
|
122
|
+
};
|
|
123
|
+
if (options.init !== undefined)
|
|
124
|
+
send({ type: "init", value: options.init });
|
|
125
|
+
return {
|
|
126
|
+
pid,
|
|
127
|
+
link: ipcLink(child),
|
|
128
|
+
exited,
|
|
129
|
+
send,
|
|
130
|
+
killTree: () => {
|
|
131
|
+
try {
|
|
132
|
+
process.kill(-pid, "SIGKILL");
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
child.kill("SIGKILL");
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
onControl: (listener) => listeners.add(listener),
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export function createHostManager(options) {
|
|
144
|
+
let status = "stopped";
|
|
145
|
+
let instance;
|
|
146
|
+
let queue = Promise.resolve();
|
|
147
|
+
let report = { activeCalls: 0, viewers: 0, durableTasks: 0 };
|
|
148
|
+
/** When the child last became idle; undefined while it reports work. */
|
|
149
|
+
let idleSince;
|
|
150
|
+
let booting = false;
|
|
151
|
+
let timer;
|
|
152
|
+
const serialized = (step) => {
|
|
153
|
+
const next = queue.then(step, step);
|
|
154
|
+
queue = next.catch(() => { });
|
|
155
|
+
return next;
|
|
156
|
+
};
|
|
157
|
+
const liveness = () => ({
|
|
158
|
+
booting,
|
|
159
|
+
...report,
|
|
160
|
+
idleFor: idleSince === undefined ? 0 : Date.now() - idleSince,
|
|
161
|
+
});
|
|
162
|
+
const doStop = async () => {
|
|
163
|
+
const current = instance;
|
|
164
|
+
if (current === undefined) {
|
|
165
|
+
status = "stopped";
|
|
166
|
+
booting = false;
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
status = "stopping";
|
|
170
|
+
if (timer !== undefined)
|
|
171
|
+
clearInterval(timer);
|
|
172
|
+
current.send({ type: "shutdown" });
|
|
173
|
+
let graceTimer;
|
|
174
|
+
const graceful = await Promise.race([
|
|
175
|
+
current.exited.then(() => true),
|
|
176
|
+
new Promise((resolve) => {
|
|
177
|
+
graceTimer = setTimeout(() => resolve(false), options.grace ?? 5000);
|
|
178
|
+
}),
|
|
179
|
+
]);
|
|
180
|
+
clearTimeout(graceTimer);
|
|
181
|
+
if (!graceful)
|
|
182
|
+
current.killTree();
|
|
183
|
+
await current.exited;
|
|
184
|
+
if (instance === current)
|
|
185
|
+
instance = undefined;
|
|
186
|
+
status = "stopped";
|
|
187
|
+
};
|
|
188
|
+
const doStart = async () => {
|
|
189
|
+
if (instance !== undefined && status === "running")
|
|
190
|
+
return instance;
|
|
191
|
+
status = "starting";
|
|
192
|
+
booting = true;
|
|
193
|
+
report = { activeCalls: 0, viewers: 0, durableTasks: 0 };
|
|
194
|
+
let current;
|
|
195
|
+
try {
|
|
196
|
+
current = options.driver.spawn();
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
status = "stopped";
|
|
200
|
+
booting = false;
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
instance = current;
|
|
204
|
+
current.exited.then((exit) => {
|
|
205
|
+
if (instance === current) {
|
|
206
|
+
instance = undefined;
|
|
207
|
+
status = "stopped";
|
|
208
|
+
if (timer !== undefined)
|
|
209
|
+
clearInterval(timer);
|
|
210
|
+
}
|
|
211
|
+
options.onExit?.(exit);
|
|
212
|
+
});
|
|
213
|
+
await new Promise((resolve, reject) => {
|
|
214
|
+
const timeout = setTimeout(() => reject(new ChordError("unavailable", "child not ready in time")), options.readyTimeout ?? 30_000);
|
|
215
|
+
const settle = (fn) => {
|
|
216
|
+
clearTimeout(timeout);
|
|
217
|
+
fn();
|
|
218
|
+
};
|
|
219
|
+
current.exited.then((exit) => settle(() => reject(new ChordError("unavailable", `child exited before ready (${exit.code ?? exit.signal})`))));
|
|
220
|
+
current.onControl((message) => {
|
|
221
|
+
if (message.type === "ready")
|
|
222
|
+
settle(resolve);
|
|
223
|
+
else if (message.type === "fatal")
|
|
224
|
+
settle(() => reject(new ChordError("unavailable", `child failed: ${message.message}`, { reason: message.reason })));
|
|
225
|
+
else if (message.type === "status") {
|
|
226
|
+
report = {
|
|
227
|
+
activeCalls: message.activeCalls ?? 0,
|
|
228
|
+
viewers: message.viewers ?? 0,
|
|
229
|
+
durableTasks: message.durableTasks ?? 0,
|
|
230
|
+
};
|
|
231
|
+
// The idle clock starts at the busy → idle transition, not at the last busy report.
|
|
232
|
+
if (report.activeCalls + report.viewers + report.durableTasks > 0)
|
|
233
|
+
idleSince = undefined;
|
|
234
|
+
else
|
|
235
|
+
idleSince ??= Date.now();
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
}).catch(async (error) => {
|
|
239
|
+
current.killTree();
|
|
240
|
+
await current.exited;
|
|
241
|
+
throw error;
|
|
242
|
+
});
|
|
243
|
+
booting = false;
|
|
244
|
+
if (report.activeCalls + report.viewers + report.durableTasks === 0)
|
|
245
|
+
idleSince ??= Date.now();
|
|
246
|
+
status = "running";
|
|
247
|
+
if (options.keepAlive !== undefined) {
|
|
248
|
+
const keepAlive = options.keepAlive;
|
|
249
|
+
timer = setInterval(() => {
|
|
250
|
+
if (status === "running" && !keepAlive(liveness()))
|
|
251
|
+
void serialized(doStop);
|
|
252
|
+
}, options.checkInterval ?? 1000);
|
|
253
|
+
timer.unref?.();
|
|
254
|
+
}
|
|
255
|
+
return current;
|
|
256
|
+
};
|
|
257
|
+
return {
|
|
258
|
+
get status() {
|
|
259
|
+
return status;
|
|
260
|
+
},
|
|
261
|
+
get instance() {
|
|
262
|
+
return instance;
|
|
263
|
+
},
|
|
264
|
+
get liveness() {
|
|
265
|
+
return liveness();
|
|
266
|
+
},
|
|
267
|
+
start: () => serialized(doStart),
|
|
268
|
+
stop: () => serialized(doStop),
|
|
269
|
+
replace: () => serialized(async () => {
|
|
270
|
+
await doStop();
|
|
271
|
+
return doStart();
|
|
272
|
+
}),
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
/** The child side of the control channel (call in the child's entry). */
|
|
276
|
+
export function childControl(channel = process) {
|
|
277
|
+
const send = (message) => {
|
|
278
|
+
if (channel.connected)
|
|
279
|
+
channel.send?.({ chord2control: message });
|
|
280
|
+
};
|
|
281
|
+
let resolveInit = () => { };
|
|
282
|
+
const init = new Promise((resolve) => {
|
|
283
|
+
resolveInit = resolve;
|
|
284
|
+
});
|
|
285
|
+
const shutdown = new Set();
|
|
286
|
+
channel.on("message", (message) => {
|
|
287
|
+
const control = message?.chord2control;
|
|
288
|
+
if (control?.type === "init")
|
|
289
|
+
resolveInit(control.value);
|
|
290
|
+
if (control?.type === "shutdown")
|
|
291
|
+
for (const handler of shutdown)
|
|
292
|
+
void handler();
|
|
293
|
+
});
|
|
294
|
+
const fatal = (error) => send({
|
|
295
|
+
type: "fatal",
|
|
296
|
+
message: error instanceof Error ? error.message : String(error),
|
|
297
|
+
...(error instanceof ChordError && error.reason !== undefined ? { reason: error.reason } : {}),
|
|
298
|
+
});
|
|
299
|
+
return {
|
|
300
|
+
init,
|
|
301
|
+
lock: async () => {
|
|
302
|
+
const name = process.env[LOCK_ENV];
|
|
303
|
+
if (name === undefined)
|
|
304
|
+
return;
|
|
305
|
+
try {
|
|
306
|
+
await processLock(name);
|
|
307
|
+
}
|
|
308
|
+
catch (error) {
|
|
309
|
+
fatal(error);
|
|
310
|
+
throw error;
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
ready: () => send({ type: "ready" }),
|
|
314
|
+
fatal,
|
|
315
|
+
report: (status) => send({ type: "status", ...status }),
|
|
316
|
+
onShutdown: (handler) => shutdown.add(handler),
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
//# sourceMappingURL=manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../src/manager.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,OAAO,EAAqB,IAAI,EAAE,MAAM,oBAAoB,CAAC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CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9F,CAAC,CAAC;IACJ,OAAO;QACN,IAAI;QACJ,IAAI,EAAE,KAAK,IAAI,EAAE;YAChB,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACnC,IAAI,IAAI,KAAK,SAAS;gBAAE,OAAO;YAC/B,IAAI,CAAC;gBACJ,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;YACzB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,KAAK,CAAC,KAAK,CAAC,CAAC;gBACb,MAAM,KAAK,CAAC;YACb,CAAC;QACF,CAAC;QACD,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QACpC,KAAK;QACL,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,CAAC;QACvD,UAAU,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC;KAC9C,CAAC;AACH,CAAC","sourcesContent":["// Host manager (Node only): runs a child host process and keeps at most one instance of it alive.\nimport { type ChildProcess, fork } from \"node:child_process\";\nimport { createHash } from \"node:crypto\";\nimport { unlinkSync } from \"node:fs\";\nimport { rm } from \"node:fs/promises\";\nimport { connect, createServer } from \"node:net\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { ChordError } from \"./errors.ts\";\nimport { type IpcChannel, type IpcLink, ipcLink } from \"./link.ts\";\n\n/** Control messages share the IPC channel with chord frames: `{ chord2control: message }`. */\nexport type ControlMessage =\n\t| { readonly type: \"init\"; readonly value: unknown }\n\t| { readonly type: \"ready\" }\n\t| { readonly type: \"fatal\"; readonly message: string; readonly reason?: string }\n\t| { readonly type: \"shutdown\" }\n\t| {\n\t\t\treadonly type: \"status\";\n\t\t\treadonly activeCalls?: number;\n\t\t\treadonly viewers?: number;\n\t\t\treadonly durableTasks?: number;\n\t };\n\nexport interface Liveness {\n\t/** Started but not ready yet. */\n\treadonly booting: boolean;\n\treadonly activeCalls: number;\n\t/** Viewers the child reports (it counts heartbeating subscribers). */\n\treadonly viewers: number;\n\treadonly durableTasks: number;\n\t/** Milliseconds since the child last reported work (calls, viewers or tasks), or since it became ready. */\n\treadonly idleFor: number;\n}\n\nexport interface Exit {\n\treadonly code: number | null;\n\treadonly signal: string | null;\n}\n\n/** A running child: its link (for `host.accept`) and its exit. */\nexport interface Instance {\n\treadonly pid: number;\n\treadonly link: IpcLink;\n\treadonly exited: Promise<Exit>;\n\tsend(message: ControlMessage): void;\n\t/** Kills the child and everything it spawned. */\n\tkillTree(): void;\n\tonControl(listener: (message: ControlMessage) => void): void;\n}\n\nexport interface Driver {\n\tspawn(): Instance;\n}\n\nexport interface ForkDriverOptions {\n\t/** The child's entry module. */\n\treadonly entry: string;\n\treadonly args?: readonly string[];\n\treadonly env?: Readonly<Record<string, string>>;\n\t/** Node flags for the child, e.g. `[\"--import\", sourceResolver]` (default: none). */\n\treadonly execArgv?: readonly string[];\n\t/** Sent to the child as its first control message (`childControl().init`). */\n\treadonly init?: unknown;\n\t/**\n\t * A lock name: one live process per name, across managers and processes. The child acquires it as a kernel lock\n\t * (`childControl().lock()`, before opening its storage); a second child fails to start with `unavailable/locked`.\n\t */\n\treadonly lock?: string;\n\t/** Optional stdout/stderr tap. Streams are still mirrored to the parent's standard output. */\n\treadonly onOutput?: (stream: \"stdout\" | \"stderr\", chunk: Uint8Array) => void;\n\t/** Optional application metadata tap; control messages and chord frames keep their normal handling. */\n\treadonly onMessage?: (message: unknown) => void;\n}\n\n/**\n * A process lock owned by the kernel for the holder's lifetime: an abstract socket (Linux, Android) or a named pipe\n * (Windows) vanishes with its process, so there is no stale state to take over and no race between two would-be\n * owners. Other platforms need a socket file, removed on exit; a leftover one nobody accepts on is taken over.\n * The child acquires it (before opening storage), so the lock follows the process that owns the data.\n */\nexport async function processLock(name: string): Promise<() => Promise<void>> {\n\tconst key = createHash(\"sha256\").update(name).digest(\"hex\").slice(0, 32);\n\tconst file = process.platform !== \"win32\" && process.platform !== \"linux\" && process.platform !== \"android\";\n\tconst address =\n\t\tprocess.platform === \"win32\"\n\t\t\t? `\\\\\\\\.\\\\pipe\\\\chord2-${key}`\n\t\t\t: file\n\t\t\t\t? join(tmpdir(), `chord2-${key}.sock`)\n\t\t\t\t: `\\0chord2-${key}`;\n\tconst server = createServer((socket) => socket.end());\n\tfor (;;) {\n\t\ttry {\n\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\tserver.once(\"error\", reject);\n\t\t\t\tserver.listen(address, () => {\n\t\t\t\t\tserver.removeListener(\"error\", reject);\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\t\t\t});\n\t\t\tbreak;\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code !== \"EADDRINUSE\") throw error;\n\t\t\tif (!file || (await accepting(address))) {\n\t\t\t\tthrow new ChordError(\"unavailable\", `lock ${name} is held by another process`, { reason: \"locked\" });\n\t\t\t}\n\t\t\tawait rm(address, { force: true });\n\t\t}\n\t}\n\tconst removeFile = (): void => {\n\t\ttry {\n\t\t\tunlinkSync(address);\n\t\t} catch {\n\t\t\t// Already gone.\n\t\t}\n\t};\n\tif (file) process.once(\"exit\", removeFile);\n\treturn () =>\n\t\tnew Promise<void>((resolve, reject) => {\n\t\t\tif (file) process.removeListener(\"exit\", removeFile);\n\t\t\tserver.close((error) => (error ? reject(error) : resolve()));\n\t\t});\n}\n\nfunction accepting(address: string): Promise<boolean> {\n\treturn new Promise((resolve) => {\n\t\tconst socket = connect(address);\n\t\tsocket.once(\"connect\", () => {\n\t\t\tsocket.destroy();\n\t\t\tresolve(true);\n\t\t});\n\t\tsocket.once(\"error\", (error: NodeJS.ErrnoException) =>\n\t\t\tresolve(error.code !== \"ECONNREFUSED\" && error.code !== \"ENOENT\"),\n\t\t);\n\t});\n}\n\nconst LOCK_ENV = \"CHORD2_LOCK\";\n\nexport function forkDriver(options: ForkDriverOptions): Driver {\n\treturn {\n\t\tspawn() {\n\t\t\t// Detached: the child leads a process group, so the whole tree can be killed.\n\t\t\tconst child: ChildProcess = fork(options.entry, [...(options.args ?? [])], {\n\t\t\t\tenv: {\n\t\t\t\t\t...process.env,\n\t\t\t\t\t...options.env,\n\t\t\t\t\t...(options.lock === undefined ? {} : { [LOCK_ENV]: options.lock }),\n\t\t\t\t},\n\t\t\t\texecArgv: [...(options.execArgv ?? [])],\n\t\t\t\tdetached: true,\n\t\t\t\tstdio: [\"ignore\", options.onOutput ? \"pipe\" : \"inherit\", options.onOutput ? \"pipe\" : \"inherit\", \"ipc\"],\n\t\t\t});\n\t\t\tif (options.onOutput) {\n\t\t\t\tfor (const stream of [\"stdout\", \"stderr\"] as const) {\n\t\t\t\t\tchild[stream]?.on(\"data\", (chunk: Buffer) => {\n\t\t\t\t\t\toptions.onOutput!(stream, chunk);\n\t\t\t\t\t\tprocess[stream].write(chunk);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst pid = child.pid ?? -1;\n\t\t\tconst killGroup = (): void => {\n\t\t\t\ttry {\n\t\t\t\t\tprocess.kill(-pid, \"SIGKILL\");\n\t\t\t\t} catch {\n\t\t\t\t\t// No group left.\n\t\t\t\t}\n\t\t\t};\n\t\t\tconst exited = new Promise<Exit>((resolve) => {\n\t\t\t\tchild.once(\"exit\", (code, signal) => {\n\t\t\t\t\t// However the leader ended (graceful, crash, kill), nothing it spawned outlives it.\n\t\t\t\t\tkillGroup();\n\t\t\t\t\tresolve({ code, signal });\n\t\t\t\t});\n\t\t\t});\n\t\t\tconst listeners = new Set<(message: ControlMessage) => void>();\n\t\t\tchild.on(\"message\", (message) => {\n\t\t\t\toptions.onMessage?.(message);\n\t\t\t\tconst control = (message as { chord2control?: ControlMessage } | null)?.chord2control;\n\t\t\t\tif (control !== undefined) for (const listener of listeners) listener(control);\n\t\t\t});\n\t\t\tconst send = (message: ControlMessage): void => {\n\t\t\t\tif (child.connected) child.send({ chord2control: message });\n\t\t\t};\n\t\t\tif (options.init !== undefined) send({ type: \"init\", value: options.init });\n\t\t\treturn {\n\t\t\t\tpid,\n\t\t\t\tlink: ipcLink(child as unknown as IpcChannel),\n\t\t\t\texited,\n\t\t\t\tsend,\n\t\t\t\tkillTree: () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tprocess.kill(-pid, \"SIGKILL\");\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tchild.kill(\"SIGKILL\");\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tonControl: (listener) => listeners.add(listener),\n\t\t\t};\n\t\t},\n\t};\n}\n\nexport interface HostManagerOptions {\n\treadonly driver: Driver;\n\t/** Evaluated every `checkInterval` while running; `false` stops the child. */\n\treadonly keepAlive?: (liveness: Liveness) => boolean;\n\treadonly checkInterval?: number;\n\t/** Milliseconds a child may take to shut down before its process tree is killed (default 5000). */\n\treadonly grace?: number;\n\t/** Milliseconds to wait for `ready` (default 30000). */\n\treadonly readyTimeout?: number;\n\t/** The child exited on its own (crash, fatal) or after a stop. */\n\treadonly onExit?: (exit: Exit) => void;\n}\n\nexport interface HostManager {\n\treadonly status: \"stopped\" | \"starting\" | \"running\" | \"stopping\";\n\treadonly instance: Instance | undefined;\n\treadonly liveness: Liveness;\n\t/** Starts the child (or returns the running one) once it reported ready. Serialized with stop/replace. */\n\tstart(): Promise<Instance>;\n\t/** Asks the child to shut down, then kills its process tree after the grace period. */\n\tstop(): Promise<void>;\n\t/** Stop, wait for the exit, start. */\n\treplace(): Promise<Instance>;\n}\n\nexport function createHostManager(options: HostManagerOptions): HostManager {\n\tlet status: HostManager[\"status\"] = \"stopped\";\n\tlet instance: Instance | undefined;\n\tlet queue: Promise<unknown> = Promise.resolve();\n\tlet report = { activeCalls: 0, viewers: 0, durableTasks: 0 };\n\t/** When the child last became idle; undefined while it reports work. */\n\tlet idleSince: number | undefined;\n\tlet booting = false;\n\tlet timer: ReturnType<typeof setInterval> | undefined;\n\n\tconst serialized = <T>(step: () => Promise<T>): Promise<T> => {\n\t\tconst next = queue.then(step, step);\n\t\tqueue = next.catch(() => {});\n\t\treturn next;\n\t};\n\n\tconst liveness = (): Liveness => ({\n\t\tbooting,\n\t\t...report,\n\t\tidleFor: idleSince === undefined ? 0 : Date.now() - idleSince,\n\t});\n\n\tconst doStop = async (): Promise<void> => {\n\t\tconst current = instance;\n\t\tif (current === undefined) {\n\t\t\tstatus = \"stopped\";\n\t\t\tbooting = false;\n\t\t\treturn;\n\t\t}\n\t\tstatus = \"stopping\";\n\t\tif (timer !== undefined) clearInterval(timer);\n\t\tcurrent.send({ type: \"shutdown\" });\n\t\tlet graceTimer: ReturnType<typeof setTimeout> | undefined;\n\t\tconst graceful = await Promise.race([\n\t\t\tcurrent.exited.then(() => true),\n\t\t\tnew Promise<boolean>((resolve) => {\n\t\t\t\tgraceTimer = setTimeout(() => resolve(false), options.grace ?? 5000);\n\t\t\t}),\n\t\t]);\n\t\tclearTimeout(graceTimer);\n\t\tif (!graceful) current.killTree();\n\t\tawait current.exited;\n\t\tif (instance === current) instance = undefined;\n\t\tstatus = \"stopped\";\n\t};\n\n\tconst doStart = async (): Promise<Instance> => {\n\t\tif (instance !== undefined && status === \"running\") return instance;\n\t\tstatus = \"starting\";\n\t\tbooting = true;\n\t\treport = { activeCalls: 0, viewers: 0, durableTasks: 0 };\n\t\tlet current: Instance;\n\t\ttry {\n\t\t\tcurrent = options.driver.spawn();\n\t\t} catch (error) {\n\t\t\tstatus = \"stopped\";\n\t\t\tbooting = false;\n\t\t\tthrow error;\n\t\t}\n\t\tinstance = current;\n\t\tcurrent.exited.then((exit) => {\n\t\t\tif (instance === current) {\n\t\t\t\tinstance = undefined;\n\t\t\t\tstatus = \"stopped\";\n\t\t\t\tif (timer !== undefined) clearInterval(timer);\n\t\t\t}\n\t\t\toptions.onExit?.(exit);\n\t\t});\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\tconst timeout = setTimeout(\n\t\t\t\t() => reject(new ChordError(\"unavailable\", \"child not ready in time\")),\n\t\t\t\toptions.readyTimeout ?? 30_000,\n\t\t\t);\n\t\t\tconst settle = (fn: () => void): void => {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tfn();\n\t\t\t};\n\t\t\tcurrent.exited.then((exit) =>\n\t\t\t\tsettle(() =>\n\t\t\t\t\treject(new ChordError(\"unavailable\", `child exited before ready (${exit.code ?? exit.signal})`)),\n\t\t\t\t),\n\t\t\t);\n\t\t\tcurrent.onControl((message) => {\n\t\t\t\tif (message.type === \"ready\") settle(resolve);\n\t\t\t\telse if (message.type === \"fatal\")\n\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\treject(new ChordError(\"unavailable\", `child failed: ${message.message}`, { reason: message.reason })),\n\t\t\t\t\t);\n\t\t\t\telse if (message.type === \"status\") {\n\t\t\t\t\treport = {\n\t\t\t\t\t\tactiveCalls: message.activeCalls ?? 0,\n\t\t\t\t\t\tviewers: message.viewers ?? 0,\n\t\t\t\t\t\tdurableTasks: message.durableTasks ?? 0,\n\t\t\t\t\t};\n\t\t\t\t\t// The idle clock starts at the busy → idle transition, not at the last busy report.\n\t\t\t\t\tif (report.activeCalls + report.viewers + report.durableTasks > 0) idleSince = undefined;\n\t\t\t\t\telse idleSince ??= Date.now();\n\t\t\t\t}\n\t\t\t});\n\t\t}).catch(async (error: unknown) => {\n\t\t\tcurrent.killTree();\n\t\t\tawait current.exited;\n\t\t\tthrow error;\n\t\t});\n\t\tbooting = false;\n\t\tif (report.activeCalls + report.viewers + report.durableTasks === 0) idleSince ??= Date.now();\n\t\tstatus = \"running\";\n\t\tif (options.keepAlive !== undefined) {\n\t\t\tconst keepAlive = options.keepAlive;\n\t\t\ttimer = setInterval(() => {\n\t\t\t\tif (status === \"running\" && !keepAlive(liveness())) void serialized(doStop);\n\t\t\t}, options.checkInterval ?? 1000);\n\t\t\ttimer.unref?.();\n\t\t}\n\t\treturn current;\n\t};\n\n\treturn {\n\t\tget status() {\n\t\t\treturn status;\n\t\t},\n\t\tget instance() {\n\t\t\treturn instance;\n\t\t},\n\t\tget liveness() {\n\t\t\treturn liveness();\n\t\t},\n\t\tstart: () => serialized(doStart),\n\t\tstop: () => serialized(doStop),\n\t\treplace: () =>\n\t\t\tserialized(async () => {\n\t\t\t\tawait doStop();\n\t\t\t\treturn doStart();\n\t\t\t}),\n\t};\n}\n\n/** The child side of the control channel (call in the child's entry). */\nexport function childControl(channel: NodeJS.Process = process): {\n\treadonly init: Promise<unknown>;\n\t/**\n\t * Acquires the manager's lock (if one was configured) as a kernel lock held for this process's lifetime. Call it\n\t * before opening storage. Fails with `unavailable/locked`, also reported to the manager as a fatal start error.\n\t */\n\tlock(): Promise<void>;\n\tready(): void;\n\tfatal(error: unknown): void;\n\treport(status: { activeCalls?: number; viewers?: number; durableTasks?: number }): void;\n\tonShutdown(handler: () => void | Promise<void>): void;\n} {\n\tconst send = (message: ControlMessage): void => {\n\t\tif (channel.connected) channel.send?.({ chord2control: message });\n\t};\n\tlet resolveInit: (value: unknown) => void = () => {};\n\tconst init = new Promise<unknown>((resolve) => {\n\t\tresolveInit = resolve;\n\t});\n\tconst shutdown = new Set<() => void | Promise<void>>();\n\tchannel.on(\"message\", (message: unknown) => {\n\t\tconst control = (message as { chord2control?: ControlMessage } | null)?.chord2control;\n\t\tif (control?.type === \"init\") resolveInit(control.value);\n\t\tif (control?.type === \"shutdown\") for (const handler of shutdown) void handler();\n\t});\n\tconst fatal = (error: unknown): void =>\n\t\tsend({\n\t\t\ttype: \"fatal\",\n\t\t\tmessage: error instanceof Error ? error.message : String(error),\n\t\t\t...(error instanceof ChordError && error.reason !== undefined ? { reason: error.reason } : {}),\n\t\t});\n\treturn {\n\t\tinit,\n\t\tlock: async () => {\n\t\t\tconst name = process.env[LOCK_ENV];\n\t\t\tif (name === undefined) return;\n\t\t\ttry {\n\t\t\t\tawait processLock(name);\n\t\t\t} catch (error) {\n\t\t\t\tfatal(error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\tready: () => send({ type: \"ready\" }),\n\t\tfatal,\n\t\treport: (status) => send({ type: \"status\", ...status }),\n\t\tonShutdown: (handler) => shutdown.add(handler),\n\t};\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export type
|
|
4
|
-
export { FACET_BUNDLE_ARTIFACT_FORMAT, FACET_BUNDLE_ARTIFACT_FORMAT_VERSION, FACET_BUNDLE_FORMAT, FACET_BUNDLE_FORMAT_VERSION, FACET_BUNDLE_MANIFEST_FILE, } from "./node/manifest.ts";
|
|
1
|
+
/** Node-only parts of Chord: child host processes, their manager, and the facet module loader. */
|
|
2
|
+
export { nodeLoader } from "./loader.ts";
|
|
3
|
+
export { type ControlMessage, childControl, createHostManager, type Driver, type Exit, type ForkDriverOptions, forkDriver, type HostManager, type HostManagerOptions, type Instance, type Liveness, processLock, } from "./manager.ts";
|
|
5
4
|
//# sourceMappingURL=node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,KAAK,cAAc,EACnB,YAAY,EACZ,iBAAiB,EACjB,KAAK,MAAM,EACX,KAAK,IAAI,EACT,KAAK,iBAAiB,EACtB,UAAU,EACV,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,WAAW,GACX,MAAM,cAAc,CAAC"}
|