@ai-agent-forge/agent-forge 0.87.0 → 0.88.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/README.md +2 -2
- package/bundled-plugins/agent-loop-policy/agent-forge.json +19 -0
- package/bundled-plugins/agent-loop-policy/dist/entry.d.ts +28 -0
- package/bundled-plugins/agent-loop-policy/dist/entry.d.ts.map +1 -0
- package/bundled-plugins/agent-loop-policy/dist/entry.js +69 -0
- package/bundled-plugins/agent-loop-policy/dist/entry.js.map +1 -0
- package/bundled-plugins/agent-loop-policy/dist/loop-guard.d.ts +199 -0
- package/bundled-plugins/agent-loop-policy/dist/loop-guard.d.ts.map +1 -0
- package/bundled-plugins/agent-loop-policy/dist/loop-guard.js +208 -0
- package/bundled-plugins/agent-loop-policy/dist/loop-guard.js.map +1 -0
- package/bundled-plugins/agent-loop-policy/dist/run-loop-strategy.d.ts +17 -0
- package/bundled-plugins/agent-loop-policy/dist/run-loop-strategy.d.ts.map +1 -0
- package/bundled-plugins/agent-loop-policy/dist/run-loop-strategy.js +18 -0
- package/bundled-plugins/agent-loop-policy/dist/run-loop-strategy.js.map +1 -0
- package/bundled-plugins/agent-loop-policy/plugin.json +7 -0
- package/bundled-plugins/coding-tools/agent-forge.json +19 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/bash.d.ts +5 -44
- package/bundled-plugins/coding-tools/dist/bash.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/bash.js +15 -119
- package/bundled-plugins/coding-tools/dist/bash.js.map +1 -0
- package/bundled-plugins/coding-tools/dist/capability.d.ts +25 -0
- package/bundled-plugins/coding-tools/dist/capability.d.ts.map +1 -0
- package/bundled-plugins/coding-tools/dist/capability.js +98 -0
- package/bundled-plugins/coding-tools/dist/capability.js.map +1 -0
- package/bundled-plugins/coding-tools/dist/config.d.ts +8 -0
- package/bundled-plugins/coding-tools/dist/config.d.ts.map +1 -0
- package/bundled-plugins/coding-tools/dist/config.js +8 -0
- package/bundled-plugins/coding-tools/dist/config.js.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/edit.d.ts +3 -3
- package/bundled-plugins/coding-tools/dist/edit.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/edit.js +12 -10
- package/bundled-plugins/coding-tools/dist/edit.js.map +1 -0
- package/bundled-plugins/coding-tools/dist/entry.d.ts +14 -0
- package/bundled-plugins/coding-tools/dist/entry.d.ts.map +1 -0
- package/bundled-plugins/coding-tools/dist/entry.js +23 -0
- package/bundled-plugins/coding-tools/dist/entry.js.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/find.d.ts +4 -4
- package/bundled-plugins/coding-tools/dist/find.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/find.js +10 -8
- package/bundled-plugins/coding-tools/dist/find.js.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/grep.d.ts +3 -3
- package/bundled-plugins/coding-tools/dist/grep.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/grep.js +10 -8
- package/bundled-plugins/coding-tools/dist/grep.js.map +1 -0
- package/bundled-plugins/coding-tools/dist/index.d.ts +17 -0
- package/bundled-plugins/coding-tools/dist/index.d.ts.map +1 -0
- package/bundled-plugins/coding-tools/dist/index.js +17 -0
- package/bundled-plugins/coding-tools/dist/index.js.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/ls.d.ts +3 -3
- package/bundled-plugins/coding-tools/dist/ls.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/ls.js +8 -6
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/ls.js.map +1 -1
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/powershell.d.ts +2 -1
- package/bundled-plugins/coding-tools/dist/powershell.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/powershell.js +6 -3
- package/bundled-plugins/coding-tools/dist/powershell.js.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/read.d.ts +3 -3
- package/bundled-plugins/coding-tools/dist/read.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/read.js +15 -13
- package/bundled-plugins/coding-tools/dist/read.js.map +1 -0
- package/bundled-plugins/coding-tools/dist/types.d.ts +74 -0
- package/bundled-plugins/coding-tools/dist/types.d.ts.map +1 -0
- package/bundled-plugins/coding-tools/dist/types.js +28 -0
- package/bundled-plugins/coding-tools/dist/types.js.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/write.d.ts +2 -2
- package/bundled-plugins/coding-tools/dist/write.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/write.js +11 -9
- package/bundled-plugins/coding-tools/dist/write.js.map +1 -0
- package/bundled-plugins/coding-tools/plugin.json +10 -0
- package/bundled-plugins/compaction-policy/agent-forge.json +19 -0
- package/bundled-plugins/compaction-policy/dist/branch-summary-policy.d.ts +6 -0
- package/bundled-plugins/compaction-policy/dist/branch-summary-policy.d.ts.map +1 -0
- package/bundled-plugins/compaction-policy/dist/branch-summary-policy.js +19 -0
- package/bundled-plugins/compaction-policy/dist/branch-summary-policy.js.map +1 -0
- package/bundled-plugins/compaction-policy/dist/compaction-policy.d.ts +6 -0
- package/bundled-plugins/compaction-policy/dist/compaction-policy.d.ts.map +1 -0
- package/bundled-plugins/compaction-policy/dist/compaction-policy.js +38 -0
- package/bundled-plugins/compaction-policy/dist/compaction-policy.js.map +1 -0
- package/bundled-plugins/compaction-policy/dist/entry.d.ts +13 -0
- package/bundled-plugins/compaction-policy/dist/entry.d.ts.map +1 -0
- package/bundled-plugins/compaction-policy/dist/entry.js +23 -0
- package/bundled-plugins/compaction-policy/dist/entry.js.map +1 -0
- package/bundled-plugins/compaction-policy/plugin.json +10 -0
- package/bundled-plugins/mcp-http/dist/index.d.ts +8 -0
- package/bundled-plugins/mcp-http/dist/index.d.ts.map +1 -0
- package/bundled-plugins/mcp-http/dist/index.js +8 -0
- package/bundled-plugins/mcp-http/dist/index.js.map +1 -0
- package/bundled-plugins/mcp-http/dist/mcp-http.d.ts.map +1 -0
- package/{dist/plugins → bundled-plugins/mcp-http/dist}/mcp-http.js +1 -1
- package/bundled-plugins/mcp-http/dist/mcp-http.js.map +1 -0
- package/bundled-plugins/overflow-policy/agent-forge.json +19 -0
- package/bundled-plugins/overflow-policy/dist/entry.d.ts +16 -0
- package/bundled-plugins/overflow-policy/dist/entry.d.ts.map +1 -0
- package/bundled-plugins/overflow-policy/dist/entry.js +35 -0
- package/bundled-plugins/overflow-policy/dist/entry.js.map +1 -0
- package/bundled-plugins/overflow-policy/plugin.json +10 -0
- package/bundled-plugins/provider-failover/agent-forge.json +19 -0
- package/bundled-plugins/provider-failover/dist/entry.d.ts +8 -0
- package/bundled-plugins/provider-failover/dist/entry.d.ts.map +1 -0
- package/bundled-plugins/provider-failover/dist/entry.js +8 -0
- package/bundled-plugins/provider-failover/dist/entry.js.map +1 -0
- package/bundled-plugins/provider-failover/dist/provider-failover.d.ts +122 -0
- package/bundled-plugins/provider-failover/dist/provider-failover.d.ts.map +1 -0
- package/{dist/core/extensions → bundled-plugins/provider-failover/dist}/provider-failover.js +149 -61
- package/bundled-plugins/provider-failover/dist/provider-failover.js.map +1 -0
- package/bundled-plugins/provider-failover/plugin.json +7 -0
- package/bundled-plugins/retry-policy/agent-forge.json +19 -0
- package/bundled-plugins/retry-policy/dist/entry.d.ts +16 -0
- package/bundled-plugins/retry-policy/dist/entry.d.ts.map +1 -0
- package/bundled-plugins/retry-policy/dist/entry.js +34 -0
- package/bundled-plugins/retry-policy/dist/entry.js.map +1 -0
- package/bundled-plugins/retry-policy/plugin.json +10 -0
- package/dist/bundle/.build-manifest.json +105 -183
- package/dist/bundle/chunks/{anthropic-messages-ALDZBUKI.js → anthropic-messages-PLAKXR73.js} +1 -1
- package/dist/bundle/chunks/{azure-openai-responses-A2WJWZFB.js → azure-openai-responses-OUWQ2AZD.js} +1 -1
- package/dist/bundle/chunks/{chunk-CIX3FSBK.js → chunk-A3JYRWB6.js} +1 -1
- package/dist/bundle/chunks/{chunk-SQFG22WN.js → chunk-AC2FIS4G.js} +1 -1
- package/dist/bundle/chunks/chunk-AQLNTW2B.js +664 -0
- package/dist/bundle/chunks/chunk-D3ARGZFR.js +13 -0
- package/dist/bundle/chunks/{chunk-YJCQVXW5.js → chunk-HTEVUY7F.js} +1 -1
- package/dist/bundle/chunks/{chunk-Y7HXTASS.js → chunk-HV64ASMT.js} +1 -1
- package/dist/bundle/chunks/chunk-LZOEQITZ.js +855 -0
- package/dist/bundle/chunks/{chunk-7ZY7IXZD.js → chunk-TRDNDS6A.js} +1 -1
- package/dist/bundle/chunks/chunk-Z72JWUZ4.js +4 -0
- package/dist/bundle/chunks/{google-generative-ai-NIB4WONV.js → google-generative-ai-DLII6DAT.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-DCPYUEUO.js → google-vertex-G7BZL7GM.js} +1 -1
- package/dist/bundle/chunks/image-resize-worker.js +3 -3
- package/dist/bundle/chunks/{mistral-conversations-OC6LA5XL.js → mistral-conversations-JXUK24ID.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-IO2X4Y7L.js → openai-codex-responses-5GSGFIPG.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-XYQQHETU.js → openai-completions-EI2I6DTG.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-DLIRN3CI.js → openai-responses-AUJQ3NWT.js} +1 -1
- package/dist/bundle/chunks/{pi-messages-E6RRYBO7.js → pi-messages-PWU2VJMR.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-WF6WRHP7.js +5 -0
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/client.js +1 -1
- package/dist/bundle/index.js +3 -3
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/capabilities/builtin.d.ts +1 -1
- package/dist/capabilities/builtin.d.ts.map +1 -1
- package/dist/capabilities/builtin.js +5 -0
- package/dist/capabilities/builtin.js.map +1 -1
- package/dist/cli/auth-check.d.ts.map +1 -1
- package/dist/cli/auth-check.js +14 -2
- package/dist/cli/auth-check.js.map +1 -1
- package/dist/cli/auth-command.d.ts.map +1 -1
- package/dist/cli/auth-command.js +1 -1
- package/dist/cli/auth-command.js.map +1 -1
- package/dist/cli/plugin-command.d.ts.map +1 -1
- package/dist/cli/plugin-command.js +17 -1
- package/dist/cli/plugin-command.js.map +1 -1
- package/dist/config.d.ts +2 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -6
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts +1 -1
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +1 -1
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts +6 -10
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +21 -112
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-internal.d.ts +1 -7
- package/dist/core/agent-session-internal.d.ts.map +1 -1
- package/dist/core/agent-session-internal.js.map +1 -1
- package/dist/core/agent-session-loop.d.ts +4 -3
- package/dist/core/agent-session-loop.d.ts.map +1 -1
- package/dist/core/agent-session-loop.js +9 -6
- package/dist/core/agent-session-loop.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts +1 -1
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +32 -4
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +30 -9
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-tools.d.ts.map +1 -1
- package/dist/core/agent-session-tools.js +5 -1
- package/dist/core/agent-session-tools.js.map +1 -1
- package/dist/core/agent-session.d.ts +12 -33
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +61 -67
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/extensions/bootstrap-agent-loop.d.ts +23 -151
- package/dist/core/extensions/bootstrap-agent-loop.d.ts.map +1 -1
- package/dist/core/extensions/bootstrap-agent-loop.js +28 -290
- package/dist/core/extensions/bootstrap-agent-loop.js.map +1 -1
- package/dist/core/extensions/capability-runtime-types.d.ts +5 -3
- package/dist/core/extensions/capability-runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/capability-runtime-types.js.map +1 -1
- package/dist/core/extensions/capability-runtime.d.ts.map +1 -1
- package/dist/core/extensions/capability-runtime.js +42 -6
- package/dist/core/extensions/capability-runtime.js.map +1 -1
- package/dist/core/extensions/index.d.ts +12 -5
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +12 -5
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/virtual-modules.js +65 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -1
- package/dist/core/facade/coding-agent-facade.d.ts +1 -7
- package/dist/core/facade/coding-agent-facade.d.ts.map +1 -1
- package/dist/core/facade/coding-agent-facade.js +0 -3
- package/dist/core/facade/coding-agent-facade.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/cli.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/cli.js +3 -1
- package/dist/core/i18n/locales/zh-cn/cli.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-core.d.ts +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-core.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-core.js +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-core.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-extensions.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-extensions.js +2 -4
- package/dist/core/i18n/locales/zh-cn/core-contract-extensions.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-errors.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-errors.js +3 -1
- package/dist/core/i18n/locales/zh-cn/core-errors.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/interactive-mode.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/interactive-mode.js +2 -0
- package/dist/core/i18n/locales/zh-cn/interactive-mode.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/tui-components-selectors.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/tui-components-selectors.js +0 -2
- package/dist/core/i18n/locales/zh-cn/tui-components-selectors.js.map +1 -1
- package/dist/core/model-config.d.ts +0 -1
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +9 -1
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +3 -3
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/provider-composer.d.ts +2 -2
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +7 -8
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/sdk.d.ts +18 -3
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +267 -76
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager.d.ts +9 -20
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +20 -54
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/tools/bash-operations.d.ts +41 -0
- package/dist/core/tools/bash-operations.d.ts.map +1 -0
- package/dist/core/tools/bash-operations.js +113 -0
- package/dist/core/tools/bash-operations.js.map +1 -0
- package/dist/core/tools/index.d.ts +12 -36
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +1 -117
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/readme-path.d.ts +3 -0
- package/dist/core/tools/readme-path.d.ts.map +1 -0
- package/dist/core/tools/readme-path.js +15 -0
- package/dist/core/tools/readme-path.js.map +1 -0
- package/dist/index.d.ts +3 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -39
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +3 -2
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +0 -2
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +2 -7
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +2 -6
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +6 -28
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +0 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +9 -25
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +0 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +23 -36
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +0 -8
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +0 -12
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +0 -9
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +0 -19
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/plugins/ecosystem/cli.d.ts.map +1 -1
- package/dist/plugins/ecosystem/cli.js +14 -2
- package/dist/plugins/ecosystem/cli.js.map +1 -1
- package/dist/plugins/ecosystem/node-npm-registry-source.d.ts +7 -2
- package/dist/plugins/ecosystem/node-npm-registry-source.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-npm-registry-source.js +64 -9
- package/dist/plugins/ecosystem/node-npm-registry-source.js.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-acquisition-host.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-acquisition-host.js +6 -0
- package/dist/plugins/ecosystem/node-plugin-acquisition-host.js.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts +9 -2
- package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-bootstrap.js +23 -0
- package/dist/plugins/ecosystem/node-plugin-bootstrap.js.map +1 -1
- package/dist/plugins/ecosystem/plugin-bootstrap.d.ts +9 -1
- package/dist/plugins/ecosystem/plugin-bootstrap.d.ts.map +1 -1
- package/dist/plugins/ecosystem/plugin-bootstrap.js +5 -0
- package/dist/plugins/ecosystem/plugin-bootstrap.js.map +1 -1
- package/dist/profiles/builtin-suites.d.ts +5 -1
- package/dist/profiles/builtin-suites.d.ts.map +1 -1
- package/dist/profiles/builtin-suites.js +6 -1
- package/dist/profiles/builtin-suites.js.map +1 -1
- package/dist/utils/photon.d.ts +2 -2
- package/dist/utils/photon.d.ts.map +1 -1
- package/dist/utils/photon.js +2 -2
- package/dist/utils/photon.js.map +1 -1
- package/docs/compaction.md +1 -3
- package/docs/docs.json +4 -0
- package/docs/index.md +1 -0
- package/docs/mcp.md +103 -0
- package/docs/models.md +14 -22
- package/docs/providers.md +0 -1
- package/docs/rpc.md +1 -26
- package/docs/sdk.md +4 -6
- package/docs/settings.md +9 -12
- package/docs/skills.md +1 -9
- package/docs/usage.md +1 -1
- package/examples/extensions/bash-spawn-hook/index.ts +7 -2
- package/examples/extensions/built-in-tool-renderer/index.ts +4 -2
- package/examples/extensions/minimal-mode/index.ts +2 -2
- package/examples/extensions/truncated-tool/index.ts +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/extensions/with-deps/plugin.json +1 -1
- package/examples/sdk/10-settings.ts +2 -4
- package/examples/sdk/12-full-control.ts +1 -2
- package/package.json +3 -4
- package/dist/bundle/chunks/chunk-6ZKDNZHA.js +0 -145
- package/dist/bundle/chunks/chunk-BFC2BDVJ.js +0 -13
- package/dist/bundle/chunks/chunk-MOHOLL3F.js +0 -1456
- package/dist/bundle/chunks/virtual-modules-KZ5DRH7Q.js +0 -2
- package/dist/core/extensions/bootstrap-branch-summary-policy.d.ts +0 -7
- package/dist/core/extensions/bootstrap-branch-summary-policy.d.ts.map +0 -1
- package/dist/core/extensions/bootstrap-branch-summary-policy.js +0 -28
- package/dist/core/extensions/bootstrap-branch-summary-policy.js.map +0 -1
- package/dist/core/extensions/bootstrap-compaction-policy.d.ts +0 -7
- package/dist/core/extensions/bootstrap-compaction-policy.d.ts.map +0 -1
- package/dist/core/extensions/bootstrap-compaction-policy.js +0 -82
- package/dist/core/extensions/bootstrap-compaction-policy.js.map +0 -1
- package/dist/core/extensions/bootstrap-overflow-policy.d.ts +0 -7
- package/dist/core/extensions/bootstrap-overflow-policy.d.ts.map +0 -1
- package/dist/core/extensions/bootstrap-overflow-policy.js +0 -30
- package/dist/core/extensions/bootstrap-overflow-policy.js.map +0 -1
- package/dist/core/extensions/bootstrap-retry-policy.d.ts +0 -7
- package/dist/core/extensions/bootstrap-retry-policy.d.ts.map +0 -1
- package/dist/core/extensions/bootstrap-retry-policy.js +0 -29
- package/dist/core/extensions/bootstrap-retry-policy.js.map +0 -1
- package/dist/core/extensions/bootstrap-tools.d.ts +0 -20
- package/dist/core/extensions/bootstrap-tools.d.ts.map +0 -1
- package/dist/core/extensions/bootstrap-tools.js +0 -36
- package/dist/core/extensions/bootstrap-tools.js.map +0 -1
- package/dist/core/extensions/microcompact.d.ts +0 -80
- package/dist/core/extensions/microcompact.d.ts.map +0 -1
- package/dist/core/extensions/microcompact.js +0 -134
- package/dist/core/extensions/microcompact.js.map +0 -1
- package/dist/core/extensions/provider-failover.d.ts +0 -106
- package/dist/core/extensions/provider-failover.d.ts.map +0 -1
- package/dist/core/extensions/provider-failover.js.map +0 -1
- package/dist/core/tools/bash.d.ts.map +0 -1
- package/dist/core/tools/bash.js.map +0 -1
- package/dist/core/tools/edit.d.ts.map +0 -1
- package/dist/core/tools/edit.js.map +0 -1
- package/dist/core/tools/find.d.ts.map +0 -1
- package/dist/core/tools/find.js.map +0 -1
- package/dist/core/tools/grep.d.ts.map +0 -1
- package/dist/core/tools/grep.js.map +0 -1
- package/dist/core/tools/ls.d.ts.map +0 -1
- package/dist/core/tools/powershell.d.ts.map +0 -1
- package/dist/core/tools/powershell.js.map +0 -1
- package/dist/core/tools/read.d.ts.map +0 -1
- package/dist/core/tools/read.js.map +0 -1
- package/dist/core/tools/write.d.ts.map +0 -1
- package/dist/core/tools/write.js.map +0 -1
- package/dist/plugins/mcp-http.d.ts.map +0 -1
- package/dist/plugins/mcp-http.js.map +0 -1
- package/dist/profile/child-facade.d.ts +0 -44
- package/dist/profile/child-facade.d.ts.map +0 -1
- package/dist/profile/child-facade.js +0 -56
- package/dist/profile/child-facade.js.map +0 -1
- package/dist/profile/dependency-wiring.d.ts +0 -48
- package/dist/profile/dependency-wiring.d.ts.map +0 -1
- package/dist/profile/dependency-wiring.js +0 -56
- package/dist/profile/dependency-wiring.js.map +0 -1
- package/dist/profile/domain-recovery.d.ts +0 -60
- package/dist/profile/domain-recovery.d.ts.map +0 -1
- package/dist/profile/domain-recovery.js +0 -94
- package/dist/profile/domain-recovery.js.map +0 -1
- package/dist/profile/first-roles.d.ts +0 -30
- package/dist/profile/first-roles.d.ts.map +0 -1
- package/dist/profile/first-roles.js +0 -83
- package/dist/profile/first-roles.js.map +0 -1
- package/dist/profile/goal-plugin.d.ts +0 -38
- package/dist/profile/goal-plugin.d.ts.map +0 -1
- package/dist/profile/goal-plugin.js +0 -132
- package/dist/profile/goal-plugin.js.map +0 -1
- package/dist/profile/plan-plugin.d.ts +0 -44
- package/dist/profile/plan-plugin.d.ts.map +0 -1
- package/dist/profile/plan-plugin.js +0 -157
- package/dist/profile/plan-plugin.js.map +0 -1
- package/dist/profile/policy-manifest.d.ts +0 -53
- package/dist/profile/policy-manifest.d.ts.map +0 -1
- package/dist/profile/policy-manifest.js +0 -53
- package/dist/profile/policy-manifest.js.map +0 -1
- package/dist/profile/role-assembly.d.ts +0 -47
- package/dist/profile/role-assembly.d.ts.map +0 -1
- package/dist/profile/role-assembly.js +0 -31
- package/dist/profile/role-assembly.js.map +0 -1
- package/dist/profile/role-catalog.d.ts +0 -43
- package/dist/profile/role-catalog.d.ts.map +0 -1
- package/dist/profile/role-catalog.js +0 -132
- package/dist/profile/role-catalog.js.map +0 -1
- package/dist/profile/role-orchestrator.d.ts +0 -123
- package/dist/profile/role-orchestrator.d.ts.map +0 -1
- package/dist/profile/role-orchestrator.js +0 -195
- package/dist/profile/role-orchestrator.js.map +0 -1
- package/dist/profile/role-runner.d.ts +0 -99
- package/dist/profile/role-runner.d.ts.map +0 -1
- package/dist/profile/role-runner.js +0 -79
- package/dist/profile/role-runner.js.map +0 -1
- package/dist/profile/root-facade.d.ts +0 -36
- package/dist/profile/root-facade.d.ts.map +0 -1
- package/dist/profile/root-facade.js +0 -49
- package/dist/profile/root-facade.js.map +0 -1
- package/dist/profile/skill-discovery-wiring.d.ts +0 -58
- package/dist/profile/skill-discovery-wiring.d.ts.map +0 -1
- package/dist/profile/skill-discovery-wiring.js +0 -80
- package/dist/profile/skill-discovery-wiring.js.map +0 -1
- package/dist/profile/state-store.d.ts +0 -62
- package/dist/profile/state-store.d.ts.map +0 -1
- package/dist/profile/state-store.js +0 -144
- package/dist/profile/state-store.js.map +0 -1
- package/dist/profile/todo-plugin.d.ts +0 -37
- package/dist/profile/todo-plugin.d.ts.map +0 -1
- package/dist/profile/todo-plugin.js +0 -137
- package/dist/profile/todo-plugin.js.map +0 -1
- package/dist/server/create-harness.d.ts +0 -26
- package/dist/server/create-harness.d.ts.map +0 -1
- package/dist/server/create-harness.js +0 -106
- package/dist/server/create-harness.js.map +0 -1
- /package/{dist/plugins → bundled-plugins/mcp-http/dist}/mcp-http.d.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-plugin-acquisition-host.js","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-plugin-acquisition-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,OAAO,EAAE,qCAAqC,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAC/G,OAAO,EACN,6BAA6B,EAC7B,4BAA4B,GAE5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,yBAAyB,EAGzB,qBAAqB,GACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EACN,gCAAgC,EAChC,+BAA+B,GAE/B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EACN,wBAAwB,EAIxB,2BAA2B,GAC3B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAItD,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAErG;;;;;;;;GAQG;AAEH,MAAM,uCAAuC,GAAG,CAAU,CAAC;AAC3D,MAAM,6BAA6B,GAAG,EAAE,GAAG,IAAI,CA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KAAK,KAAK,CAAC,QAAQ,CAAC,cAAc;oBAChE,MAAM,CAAC,QAAQ,CAAC,cAAc,KAAK,KAAK,CAAC,QAAQ,CAAC,cAAc;oBAChE,MAAM,CAAC,QAAQ,CAAC,SAAS,KAAK,KAAK,CAAC,QAAQ,CAAC,SAAS;oBAEtD,MAAM,IAAI,yBAAyB,CAAC,kBAAkB,CAAC,CAAC;gBACzD,KAAK,IAAI,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,MAAM,IAAI,uBAAuB,EAAE,CAAC;oBAC1F,IAAI,KAAK,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI;wBAAE,MAAM,IAAI,yBAAyB,CAAC,WAAW,CAAC,CAAC;oBACrF,MAAM,IAAI,UAAU,CACnB,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,uBAAuB,EAAE,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAClG,CAAC;gBACH,CAAC;YAAA,CACD,CAAC,EAAE,CAAC;QAAA,CACL;QACD,eAAe;QACf,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC;QACzD,KAAK,CAAC,KAAK,GAAG;YACb,MAAM,GAAG,IAAI,CAAC;YACd,SAAS,CAAC,KAAK,EAAE,CAAC;QAAA,CAClB;KACD,CAAC;AAAA,CACF","sourcesContent":["import { createHash, randomUUID } from \"node:crypto\";\nimport { lstatSync } from \"node:fs\";\nimport type { PluginDistributionArtifactV1 } from \"./distribution.ts\";\nimport { collectLocalDirectoryPackageEntriesV1, readLocalPackageFileV1 } from \"./node-local-package-source.ts\";\nimport {\n\tcreateNodeNpmRegistrySourceV1,\n\tNodeNpmRegistrySourceErrorV1,\n\ttype NodeNpmRegistrySourceV1,\n} from \"./node-npm-registry-source.ts\";\nimport {\n\tNodePackageInstallErrorV1,\n\ttype NodeZipPackageEntryV1,\n\ttype NodeZipPackageLimitsV1,\n\tparseNodeZipPackageV1,\n} from \"./node-package-install-host.ts\";\nimport { detectPluginPackageMediaTypeV1 } from \"./node-package-media.ts\";\nimport {\n\tcreateNodeReleasePackageSourceV1,\n\tNodeReleasePackageSourceErrorV1,\n\ttype NodeReleasePackageSourceV1,\n} from \"./node-release-package-source.ts\";\nimport { parseNodeTarGzPackageV1 } from \"./node-tar-package.ts\";\nimport { buildNodeTarGzBytesV1 } from \"./node-tar-writer.ts\";\nimport {\n\tPluginAcquisitionErrorV1,\n\ttype PluginAcquisitionLocalProbeV1,\n\ttype PluginAcquisitionPackageV1,\n\ttype PluginAcquisitionRefV1,\n\tparsePluginAcquisitionRefV1,\n} from \"./plugin-acquisition.ts\";\nimport type { PluginManifestV1 } from \"./types.ts\";\nimport { pluginManifestDigestV1 } from \"./updates.ts\";\n\nexport type { PluginAcquisitionPackageV1 } from \"./plugin-acquisition.ts\";\n\nimport { downloadNodeUrlPackageV1, NodeUrlPackageSourceErrorV1 } from \"./node-url-package-source.ts\";\n\n/**\n * Node acquisition orchestration for `plugin install <ref>` (design §4.6).\n * One boundary acquires package bytes for every source (npm packument+tarball,\n * GitHub/Gitee release asset, custom URL, local file, local directory),\n * verifies the source-specific integrity layer (npm SRI > ref digest fragment\n * > sha256 on exchange), discovers the `agent-forge.json` identity through the\n * shared bounded unpackers, and exposes the result as an opaque distribution\n * artifact the existing installer/install-host chain consumes unchanged.\n */\n\nconst NODE_PLUGIN_ACQUISITION_HOST_VERSION_V1 = 1 as const;\nconst MAX_PACKAGE_MANIFEST_BYTES_V1 = 64 * 1024;\nconst ECOSYSTEM_MANIFEST_FILE_V1 = \"agent-forge.json\";\n/** Fixed far-future expiry; the artifact handle is single-transaction and never persisted. */\nconst ACQUISITION_ARTIFACT_EXPIRES_AT_V1 = \"2099-01-01T00:00:00.000Z\";\nconst ARTIFACT_CHUNK_BYTES_V1 = 64 * 1024;\n\n/** Environment variable overriding the npm registry origin (bare http(s) origin). */\nexport const AGENT_FORGE_NPM_REGISTRY_ENV_V1 = \"AGENT_FORGE_NPM_REGISTRY\";\n/** Environment variable carrying the npm registry bearer token. */\nexport const AGENT_FORGE_NPM_TOKEN_ENV_V1 = \"AGENT_FORGE_NPM_TOKEN\";\n/** Environment variable overriding the GitHub release API origin (bare http(s) origin). */\nexport const AGENT_FORGE_GITHUB_API_ENV_V1 = \"AGENT_FORGE_GITHUB_API\";\n/** Environment variable overriding the Gitee release API origin (bare http(s) origin, includes the /api/v5 path). */\nexport const AGENT_FORGE_GITEE_API_ENV_V1 = \"AGENT_FORGE_GITEE_API\";\n/** Environment variable carrying the optional GitHub API token. */\nexport const GITHUB_TOKEN_ENV_V1 = \"GITHUB_TOKEN\";\n/** Environment variable carrying the optional Gitee API token. */\nexport const GITEE_TOKEN_ENV_V1 = \"GITEE_TOKEN\";\n\nexport interface NodePluginAcquisitionHostV1 {\n\treadonly version: typeof NODE_PLUGIN_ACQUISITION_HOST_VERSION_V1;\n\t/** Parse and acquire one ref into a package + artifact pair. */\n\treadonly resolvePackage: (input: {\n\t\treadonly ref: string;\n\t\treadonly signal?: AbortSignal;\n\t}) => Promise<PluginAcquisitionPackageV1>;\n\t/** Private installer-facing reader; mirrors the HTTP distribution host boundary. */\n\treadonly openArtifact: (input: {\n\t\treadonly artifact: PluginDistributionArtifactV1;\n\t\treadonly signal?: AbortSignal;\n\t}) => AsyncIterable<Uint8Array>;\n\treadonly releaseArtifact: (input: { readonly artifact: { readonly artifactRef: string } }) => Promise<void>;\n\t/** Whether this host owns the artifact reference (used to compose artifact readers). */\n\treadonly ownsArtifact: (input: { readonly artifactRef: string }) => boolean;\n\treadonly close: () => Promise<void>;\n}\n\nexport interface NodePluginAcquisitionHostOptionsV1 {\n\t/** Real fetch or a deterministic test replacement. */\n\treadonly fetch?: typeof globalThis.fetch;\n\t/** Bare http(s) npm registry origin; defaults to the environment variable, then the npm public registry. */\n\treadonly npmRegistry?: string;\n\t/** npm registry bearer token; defaults to the environment variable. */\n\treadonly npmToken?: string;\n\t/** Bare http(s) GitHub release API origin; defaults to the environment variable, then api.github.com. */\n\treadonly githubApiOrigin?: string;\n\t/** Bare http(s) Gitee release API origin; defaults to the environment variable, then gitee.com/api/v5. */\n\treadonly giteeApiOrigin?: string;\n\t/** GitHub API token sent as a bearer header; defaults to the environment variable. */\n\treadonly githubToken?: string;\n\t/** Gitee API token sent as an access_token query parameter; defaults to the environment variable. */\n\treadonly giteeToken?: string;\n\treadonly requestTimeoutMs?: number;\n\treadonly maxResponseBytes?: number;\n\treadonly maxTarballBytes?: number;\n\treadonly limits?: NodeZipPackageLimitsV1;\n\treadonly userAgent?: string;\n}\n\ninterface AcquiredBytesV1 {\n\treadonly bytes: Uint8Array;\n\treadonly mediaType: \"application/zip\" | \"application/gzip\";\n\treadonly digest: { readonly algorithm: \"sha256\" | \"sha512\"; readonly hex: string };\n\treadonly source: string;\n}\n\ninterface AcquiredArtifactRecordV1 {\n\treadonly bytes: Uint8Array;\n\treadonly artifact: PluginDistributionArtifactV1;\n}\n\nconst LOCAL_PROBE_V1: PluginAcquisitionLocalProbeV1 = {\n\t// The parser contract is synchronous; one lstat per candidate ref keeps\n\t// this bounded. Symlinks classify as \"other\" so they never install as local.\n\tstatLocalRef: (path) => {\n\t\tconst stats = lstatSync(path, { throwIfNoEntry: false });\n\t\tif (stats === undefined) return \"missing\";\n\t\tif (stats.isSymbolicLink()) return \"other\";\n\t\tif (stats.isDirectory()) return \"directory\";\n\t\tif (stats.isFile()) return \"file\";\n\t\treturn \"other\";\n\t},\n};\n\nfunction mapInstallError(error: unknown): PluginAcquisitionErrorV1 {\n\tif (error instanceof PluginAcquisitionErrorV1) return error;\n\tif (error instanceof NodePackageInstallErrorV1) {\n\t\tif (error.code === \"cancelled\") return new PluginAcquisitionErrorV1(\"cancelled\");\n\t\tif (error.code === \"archive_budget_exceeded\") return new PluginAcquisitionErrorV1(\"budget_exceeded\");\n\t\tif (error.code === \"unsupported_media_type\") return new PluginAcquisitionErrorV1(\"unsupported_media_type\");\n\t\treturn new PluginAcquisitionErrorV1(\"package_invalid\");\n\t}\n\treturn new PluginAcquisitionErrorV1(\"download_failed\");\n}\n\nfunction mapNpmError(error: unknown): PluginAcquisitionErrorV1 {\n\tif (error instanceof PluginAcquisitionErrorV1) return error;\n\tif (error instanceof NodeNpmRegistrySourceErrorV1) {\n\t\tif (error.code === \"package_not_found\") return new PluginAcquisitionErrorV1(\"package_not_found\");\n\t\tif (error.code === \"version_not_found\") return new PluginAcquisitionErrorV1(\"version_not_found\");\n\t\tif (error.code === \"cancelled\") return new PluginAcquisitionErrorV1(\"cancelled\");\n\t\tif (error.code === \"invalid_response\" || error.code === \"integrity_unsupported\")\n\t\t\treturn new PluginAcquisitionErrorV1(\"package_invalid\");\n\t\treturn new PluginAcquisitionErrorV1(\"download_failed\");\n\t}\n\treturn mapInstallError(error);\n}\n\nfunction mapUrlError(error: unknown): PluginAcquisitionErrorV1 {\n\tif (error instanceof PluginAcquisitionErrorV1) return error;\n\tif (error instanceof NodeUrlPackageSourceErrorV1) {\n\t\tif (error.code === \"digest_mismatch\") return new PluginAcquisitionErrorV1(\"digest_mismatch\");\n\t\tif (error.code === \"cancelled\") return new PluginAcquisitionErrorV1(\"cancelled\");\n\t\tif (error.code === \"invalid_url\" || error.code === \"invalid_configuration\")\n\t\t\treturn new PluginAcquisitionErrorV1(\"invalid_ref\");\n\t\tif (error.code === \"response_too_large\") return new PluginAcquisitionErrorV1(\"budget_exceeded\");\n\t\treturn new PluginAcquisitionErrorV1(\"download_failed\");\n\t}\n\treturn mapInstallError(error);\n}\n\nfunction mapReleaseError(error: unknown): PluginAcquisitionErrorV1 {\n\tif (error instanceof PluginAcquisitionErrorV1) return error;\n\tif (error instanceof NodeReleasePackageSourceErrorV1) {\n\t\tif (error.code === \"cancelled\") return new PluginAcquisitionErrorV1(\"cancelled\");\n\t\tif (error.code === \"invalid_configuration\") return new PluginAcquisitionErrorV1(\"invalid_ref\");\n\t\tif (error.code === \"response_too_large\") return new PluginAcquisitionErrorV1(\"budget_exceeded\");\n\t\tif (error.code === \"invalid_response\") return new PluginAcquisitionErrorV1(\"package_invalid\");\n\t\tif (error.code === \"rate_limited\")\n\t\t\treturn new PluginAcquisitionErrorV1(\n\t\t\t\t\"rate_limited\",\n\t\t\t\terror.resetEpochSeconds === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: `rate limit resets at ${new Date(error.resetEpochSeconds * 1000).toISOString()}`,\n\t\t\t);\n\t\tif (\n\t\t\terror.code === \"release_not_found\" ||\n\t\t\terror.code === \"release_asset_not_found\" ||\n\t\t\terror.code === \"release_asset_ambiguous\"\n\t\t)\n\t\t\treturn new PluginAcquisitionErrorV1(error.code, error.message);\n\t\treturn new PluginAcquisitionErrorV1(\"download_failed\");\n\t}\n\t// Asset downloads ride the URL package source; digest and budget errors pass through unchanged.\n\treturn mapUrlError(error);\n}\n\nfunction shaHex(algorithm: \"sha256\" | \"sha512\", bytes: Uint8Array): string {\n\treturn createHash(algorithm).update(bytes).digest(\"hex\");\n}\n\n/** Abort probe as a function so later re-checks are not flow-narrowed away after awaits. */\nfunction signalAborted(signal: AbortSignal | undefined): boolean {\n\treturn signal?.aborted === true;\n}\n\n/** Discover the `agent-forge.json` identity in already-bounded package entries. */\nexport function pluginAcquisitionManifestFromEntriesV1(entries: readonly NodeZipPackageEntryV1[]): {\n\treadonly manifest: PluginManifestV1;\n\treadonly manifestDigest: string;\n} {\n\tconst manifestEntry = entries.find((entry) => entry.name === ECOSYSTEM_MANIFEST_FILE_V1 && !entry.directory);\n\tif (manifestEntry === undefined || manifestEntry.bytes.byteLength > MAX_PACKAGE_MANIFEST_BYTES_V1)\n\t\tthrow new PluginAcquisitionErrorV1(\"package_invalid\");\n\tlet value: unknown;\n\ttry {\n\t\tvalue = JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(manifestEntry.bytes));\n\t} catch {\n\t\tthrow new PluginAcquisitionErrorV1(\"package_invalid\");\n\t}\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value))\n\t\tthrow new PluginAcquisitionErrorV1(\"package_invalid\");\n\tconst record = value as Record<string, unknown>;\n\tconst manifestKeys = new Set([\n\t\t\"id\",\n\t\t\"pluginVersion\",\n\t\t\"apiVersion\",\n\t\t\"minHostVersion\",\n\t\t\"maxHostVersion\",\n\t\t\"capabilityRefs\",\n\t\t\"requires\",\n\t\t\"platform\",\n\t\t\"testOnly\",\n\t]);\n\tif (\n\t\trecord.packageFormatVersion !== 1 ||\n\t\tObject.keys(record).some((key) => key !== \"packageFormatVersion\" && !manifestKeys.has(key))\n\t)\n\t\tthrow new PluginAcquisitionErrorV1(\"package_invalid\");\n\tconst id = record.id;\n\tconst pluginVersion = record.pluginVersion;\n\tconst apiVersion = record.apiVersion;\n\tif (\n\t\ttypeof id !== \"string\" ||\n\t\tid.trim().length === 0 ||\n\t\tid.length > 256 ||\n\t\ttypeof pluginVersion !== \"string\" ||\n\t\tpluginVersion.trim().length === 0 ||\n\t\tpluginVersion.length > 256 ||\n\t\ttypeof apiVersion !== \"string\" ||\n\t\tapiVersion.trim().length === 0 ||\n\t\tapiVersion.length > 256\n\t)\n\t\tthrow new PluginAcquisitionErrorV1(\"package_invalid\");\n\tif (record.minHostVersion === undefined && record.maxHostVersion === undefined)\n\t\tthrow new PluginAcquisitionErrorV1(\"package_invalid\");\n\tconst manifest: PluginManifestV1 = Object.freeze({\n\t\tid,\n\t\tpluginVersion,\n\t\tapiVersion,\n\t\t...(record.minHostVersion === undefined ? {} : { minHostVersion: record.minHostVersion as string }),\n\t\t...(record.maxHostVersion === undefined ? {} : { maxHostVersion: record.maxHostVersion as string }),\n\t\t...(record.capabilityRefs === undefined\n\t\t\t? {}\n\t\t\t: { capabilityRefs: record.capabilityRefs as PluginManifestV1[\"capabilityRefs\"] }),\n\t\t...(record.requires === undefined ? {} : { requires: record.requires as PluginManifestV1[\"requires\"] }),\n\t\t...(record.platform === undefined ? {} : { platform: record.platform as PluginManifestV1[\"platform\"] }),\n\t\t...(record.testOnly === undefined ? {} : { testOnly: record.testOnly as boolean }),\n\t});\n\treturn { manifest, manifestDigest: pluginManifestDigestV1(manifest) };\n}\n\n/**\n * Create the Node acquisition host. All sources share the bounded unpackers,\n * the manifest identity discovery, and the artifact reader contract used by\n * the existing install host. Nothing is downloaded until `resolvePackage`.\n */\nexport function createNodePluginAcquisitionHostV1(\n\toptions: NodePluginAcquisitionHostOptionsV1 = {},\n): NodePluginAcquisitionHostV1 {\n\tconst limits = options.limits ?? {};\n\tconst npmRegistryOption = options.npmRegistry ?? process.env[AGENT_FORGE_NPM_REGISTRY_ENV_V1]?.trim();\n\tconst npmTokenOption = options.npmToken ?? process.env[AGENT_FORGE_NPM_TOKEN_ENV_V1]?.trim();\n\tconst githubApiOriginOption = options.githubApiOrigin ?? process.env[AGENT_FORGE_GITHUB_API_ENV_V1]?.trim();\n\tconst giteeApiOriginOption = options.giteeApiOrigin ?? process.env[AGENT_FORGE_GITEE_API_ENV_V1]?.trim();\n\tconst githubTokenOption = options.githubToken ?? process.env[GITHUB_TOKEN_ENV_V1]?.trim();\n\tconst giteeTokenOption = options.giteeToken ?? process.env[GITEE_TOKEN_ENV_V1]?.trim();\n\tconst npmSource: NodeNpmRegistrySourceV1 = createNodeNpmRegistrySourceV1({\n\t\t...(npmRegistryOption === undefined || npmRegistryOption === \"\" ? {} : { registry: npmRegistryOption }),\n\t\t...(npmTokenOption === undefined || npmTokenOption === \"\" ? {} : { token: npmTokenOption }),\n\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t...(options.requestTimeoutMs === undefined ? {} : { requestTimeoutMs: options.requestTimeoutMs }),\n\t\t...(options.maxResponseBytes === undefined ? {} : { maxResponseBytes: options.maxResponseBytes }),\n\t\t...(options.maxTarballBytes === undefined ? {} : { maxTarballBytes: options.maxTarballBytes }),\n\t\t...(options.userAgent === undefined ? {} : { userAgent: options.userAgent }),\n\t});\n\tconst releaseSource: NodeReleasePackageSourceV1 = createNodeReleasePackageSourceV1({\n\t\t...(githubApiOriginOption === undefined || githubApiOriginOption === \"\"\n\t\t\t? {}\n\t\t\t: { githubApiOrigin: githubApiOriginOption }),\n\t\t...(giteeApiOriginOption === undefined || giteeApiOriginOption === \"\"\n\t\t\t? {}\n\t\t\t: { giteeApiOrigin: giteeApiOriginOption }),\n\t\t...(githubTokenOption === undefined || githubTokenOption === \"\" ? {} : { githubToken: githubTokenOption }),\n\t\t...(giteeTokenOption === undefined || giteeTokenOption === \"\" ? {} : { giteeToken: giteeTokenOption }),\n\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t...(options.requestTimeoutMs === undefined ? {} : { requestTimeoutMs: options.requestTimeoutMs }),\n\t\t...(options.maxResponseBytes === undefined ? {} : { maxResponseBytes: options.maxResponseBytes }),\n\t\t...(options.maxTarballBytes === undefined ? {} : { maxAssetBytes: options.maxTarballBytes }),\n\t\t...(options.userAgent === undefined ? {} : { userAgent: options.userAgent }),\n\t});\n\tconst artifacts = new Map<string, AcquiredArtifactRecordV1>();\n\tlet closed = false;\n\n\tconst acquireBytes = async (\n\t\tref: PluginAcquisitionRefV1,\n\t\tsignal: AbortSignal | undefined,\n\t): Promise<AcquiredBytesV1> => {\n\t\tif (ref.kind === \"github\" || ref.kind === \"gitee\") {\n\t\t\ttry {\n\t\t\t\tconst download = await releaseSource.downloadReleaseAsset({\n\t\t\t\t\tkind: ref.kind,\n\t\t\t\t\towner: ref.owner,\n\t\t\t\t\trepo: ref.repo,\n\t\t\t\t\t...(ref.tag === undefined ? {} : { tag: ref.tag }),\n\t\t\t\t\t...(ref.expectedDigestHex === undefined ? {} : { expectedDigestHex: ref.expectedDigestHex }),\n\t\t\t\t\tsignal,\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tbytes: download.bytes,\n\t\t\t\t\tmediaType: download.mediaType,\n\t\t\t\t\tdigest: { algorithm: \"sha256\", hex: download.sha256Hex },\n\t\t\t\t\tsource: download.sourceLabel,\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tthrow mapReleaseError(error);\n\t\t\t}\n\t\t}\n\t\tif (ref.kind === \"npm\") {\n\t\t\ttry {\n\t\t\t\tconst resolved = await npmSource.resolveNpmPackage({\n\t\t\t\t\tname: ref.name,\n\t\t\t\t\t...(ref.range === undefined ? {} : { range: ref.range }),\n\t\t\t\t\tsignal,\n\t\t\t\t});\n\t\t\t\tconst bytes = await npmSource.fetchTarball({ url: resolved.tarballUrl, signal });\n\t\t\t\tconst hex = shaHex(resolved.integrity.algorithm, bytes);\n\t\t\t\tif (hex !== resolved.integrity.hex) throw new PluginAcquisitionErrorV1(\"digest_mismatch\");\n\t\t\t\treturn {\n\t\t\t\t\tbytes,\n\t\t\t\t\tmediaType: \"application/gzip\",\n\t\t\t\t\tdigest: resolved.integrity,\n\t\t\t\t\tsource: `npm:${new URL(resolved.tarballUrl).host}`,\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tthrow mapNpmError(error);\n\t\t\t}\n\t\t}\n\t\tif (ref.kind === \"url\") {\n\t\t\ttry {\n\t\t\t\tconst download = await downloadNodeUrlPackageV1(\n\t\t\t\t\t{\n\t\t\t\t\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t\t\t\t\t...(options.requestTimeoutMs === undefined ? {} : { requestTimeoutMs: options.requestTimeoutMs }),\n\t\t\t\t\t\t...(options.maxTarballBytes === undefined ? {} : { maxPackageBytes: options.maxTarballBytes }),\n\t\t\t\t\t\t...(options.userAgent === undefined ? {} : { userAgent: options.userAgent }),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\turl: ref.url,\n\t\t\t\t\t\t...(ref.expectedDigestHex === undefined ? {} : { expectedDigestHex: ref.expectedDigestHex }),\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\tbytes: download.bytes,\n\t\t\t\t\tmediaType: download.mediaType,\n\t\t\t\t\tdigest: { algorithm: \"sha256\", hex: download.digestHex },\n\t\t\t\t\tsource: `url:${new URL(ref.url).host}`,\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tthrow mapUrlError(error);\n\t\t\t}\n\t\t}\n\t\tif (ref.kind === \"local-file\") {\n\t\t\ttry {\n\t\t\t\tconst bytes = await readLocalPackageFileV1(ref.path, limits, signal);\n\t\t\t\tconst fileName = ref.path.split(/[\\\\/]/u).pop();\n\t\t\t\tconst mediaType = detectPluginPackageMediaTypeV1(\n\t\t\t\t\tbytes,\n\t\t\t\t\tfileName === undefined || fileName.length === 0 ? undefined : fileName,\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\tbytes,\n\t\t\t\t\tmediaType,\n\t\t\t\t\tdigest: { algorithm: \"sha256\", hex: shaHex(\"sha256\", bytes) },\n\t\t\t\t\tsource: \"local:file\",\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tthrow mapInstallError(error);\n\t\t\t}\n\t\t}\n\t\tif (ref.kind === \"local-path\") {\n\t\t\ttry {\n\t\t\t\tconst entries = await collectLocalDirectoryPackageEntriesV1(ref.path, limits, signal);\n\t\t\t\tconst bytes = buildNodeTarGzBytesV1(\n\t\t\t\t\tentries.map((entry) => ({ name: entry.name, directory: entry.directory, bytes: entry.bytes })),\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\tbytes,\n\t\t\t\t\tmediaType: \"application/gzip\",\n\t\t\t\t\tdigest: { algorithm: \"sha256\", hex: shaHex(\"sha256\", bytes) },\n\t\t\t\t\tsource: \"local:dir\",\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tthrow mapInstallError(error);\n\t\t\t}\n\t\t}\n\t\tthrow new PluginAcquisitionErrorV1(\"invalid_ref\");\n\t};\n\n\tconst releaseArtifact = async (input: { readonly artifact: { readonly artifactRef: string } }): Promise<void> => {\n\t\tif (!artifacts.delete(input.artifact.artifactRef)) throw new NodePackageInstallErrorV1(\"invalid_artifact\");\n\t};\n\n\tconst resolvePackage = async (input: {\n\t\treadonly ref: string;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<PluginAcquisitionPackageV1> => {\n\t\tif (closed || signalAborted(input.signal)) throw new PluginAcquisitionErrorV1(\"cancelled\");\n\t\tlet ref: PluginAcquisitionRefV1;\n\t\ttry {\n\t\t\tref = parsePluginAcquisitionRefV1(input.ref, LOCAL_PROBE_V1);\n\t\t} catch (error) {\n\t\t\tif (error instanceof PluginAcquisitionErrorV1) throw error;\n\t\t\tthrow new PluginAcquisitionErrorV1(\"invalid_ref\");\n\t\t}\n\t\tconst acquired = await acquireBytes(ref, input.signal);\n\t\tif (signalAborted(input.signal)) throw new PluginAcquisitionErrorV1(\"cancelled\");\n\t\tlet entries: readonly NodeZipPackageEntryV1[];\n\t\ttry {\n\t\t\tentries =\n\t\t\t\tacquired.mediaType === \"application/gzip\"\n\t\t\t\t\t? await parseNodeTarGzPackageV1(acquired.bytes, limits)\n\t\t\t\t\t: parseNodeZipPackageV1(acquired.bytes, limits);\n\t\t} catch (error) {\n\t\t\tthrow mapInstallError(error);\n\t\t}\n\t\tconst identity = pluginAcquisitionManifestFromEntriesV1(entries);\n\t\tif (closed) throw new PluginAcquisitionErrorV1(\"cancelled\");\n\t\tconst artifactRef = `plugin-acquisition://node/${randomUUID()}`;\n\t\tconst artifact: PluginDistributionArtifactV1 = Object.freeze({\n\t\t\tversion: 1,\n\t\t\tsource: acquired.source,\n\t\t\tpluginId: identity.manifest.id,\n\t\t\tpluginVersion: identity.manifest.pluginVersion,\n\t\t\tmanifestDigest: identity.manifestDigest,\n\t\t\tartifactDigest:\n\t\t\t\tacquired.digest.algorithm === \"sha512\" ? `sha512:${acquired.digest.hex}` : `sha256:${acquired.digest.hex}`,\n\t\t\texpiresAt: ACQUISITION_ARTIFACT_EXPIRES_AT_V1,\n\t\t\tsizeBytes: acquired.bytes.byteLength,\n\t\t\tmediaType: acquired.mediaType,\n\t\t\tartifactRef,\n\t\t});\n\t\tartifacts.set(artifactRef, { bytes: acquired.bytes, artifact });\n\t\treturn Object.freeze({\n\t\t\tmanifest: identity.manifest,\n\t\t\tmanifestDigest: identity.manifestDigest,\n\t\t\tsource: acquired.source,\n\t\t\tartifact,\n\t\t\trelease: async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait releaseArtifact({ artifact: { artifactRef } });\n\t\t\t\t\treturn true;\n\t\t\t\t} catch {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t};\n\n\treturn {\n\t\tversion: NODE_PLUGIN_ACQUISITION_HOST_VERSION_V1,\n\t\tresolvePackage,\n\t\topenArtifact(input) {\n\t\t\treturn (async function* (): AsyncGenerator<Uint8Array> {\n\t\t\t\tconst record = artifacts.get(input.artifact.artifactRef);\n\t\t\t\tif (record === undefined) throw new NodePackageInstallErrorV1(\"invalid_artifact\");\n\t\t\t\tif (\n\t\t\t\t\trecord.artifact.pluginId !== input.artifact.pluginId ||\n\t\t\t\t\trecord.artifact.pluginVersion !== input.artifact.pluginVersion ||\n\t\t\t\t\trecord.artifact.manifestDigest !== input.artifact.manifestDigest ||\n\t\t\t\t\trecord.artifact.artifactDigest !== input.artifact.artifactDigest ||\n\t\t\t\t\trecord.artifact.sizeBytes !== input.artifact.sizeBytes\n\t\t\t\t)\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"invalid_artifact\");\n\t\t\t\tfor (let offset = 0; offset < record.bytes.byteLength; offset += ARTIFACT_CHUNK_BYTES_V1) {\n\t\t\t\t\tif (input.signal?.aborted === true) throw new NodePackageInstallErrorV1(\"cancelled\");\n\t\t\t\t\tyield new Uint8Array(\n\t\t\t\t\t\trecord.bytes.subarray(offset, Math.min(offset + ARTIFACT_CHUNK_BYTES_V1, record.bytes.byteLength)),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t})();\n\t\t},\n\t\treleaseArtifact,\n\t\townsArtifact: (input) => artifacts.has(input.artifactRef),\n\t\tasync close() {\n\t\t\tclosed = true;\n\t\t\tartifacts.clear();\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"node-plugin-acquisition-host.js","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-plugin-acquisition-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,OAAO,EAAE,qCAAqC,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAC/G,OAAO,EACN,6BAA6B,EAC7B,4BAA4B,GAE5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,yBAAyB,EAGzB,qBAAqB,GACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EACN,gCAAgC,EAChC,+BAA+B,GAE/B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EACN,wBAAwB,EAIxB,2BAA2B,GAC3B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAItD,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAErG;;;;;;;;GAQG;AAEH,MAAM,uCAAuC,GAAG,CAAU,CAAC;AAC3D,MAAM,6BAA6B,GAAG,EAAE,GAAG,IAAI,CAAC;AAChD,MAAM,0BAA0B,GAAG,kBAAkB,CAAC;AACtD,8FAA8F;AAC9F,MAAM,kCAAkC,GAAG,0BAA0B,CAAC;AACtE,MAAM,uBAAuB,GAAG,EAAE,GAAG,IAAI,CAAC;AAE1C,qFAAqF;AACrF,MAAM,CAAC,MAAM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\nimport type { PluginDistributionArtifactV1 } from \"./distribution.ts\";\nimport { collectLocalDirectoryPackageEntriesV1, readLocalPackageFileV1 } from \"./node-local-package-source.ts\";\nimport {\n\tcreateNodeNpmRegistrySourceV1,\n\tNodeNpmRegistrySourceErrorV1,\n\ttype NodeNpmRegistrySourceV1,\n} from \"./node-npm-registry-source.ts\";\nimport {\n\tNodePackageInstallErrorV1,\n\ttype NodeZipPackageEntryV1,\n\ttype NodeZipPackageLimitsV1,\n\tparseNodeZipPackageV1,\n} from \"./node-package-install-host.ts\";\nimport { detectPluginPackageMediaTypeV1 } from \"./node-package-media.ts\";\nimport {\n\tcreateNodeReleasePackageSourceV1,\n\tNodeReleasePackageSourceErrorV1,\n\ttype NodeReleasePackageSourceV1,\n} from \"./node-release-package-source.ts\";\nimport { parseNodeTarGzPackageV1 } from \"./node-tar-package.ts\";\nimport { buildNodeTarGzBytesV1 } from \"./node-tar-writer.ts\";\nimport {\n\tPluginAcquisitionErrorV1,\n\ttype PluginAcquisitionLocalProbeV1,\n\ttype PluginAcquisitionPackageV1,\n\ttype PluginAcquisitionRefV1,\n\tparsePluginAcquisitionRefV1,\n} from \"./plugin-acquisition.ts\";\nimport type { PluginManifestV1 } from \"./types.ts\";\nimport { pluginManifestDigestV1 } from \"./updates.ts\";\n\nexport type { PluginAcquisitionPackageV1 } from \"./plugin-acquisition.ts\";\n\nimport { downloadNodeUrlPackageV1, NodeUrlPackageSourceErrorV1 } from \"./node-url-package-source.ts\";\n\n/**\n * Node acquisition orchestration for `plugin install <ref>` (design §4.6).\n * One boundary acquires package bytes for every source (npm packument+tarball,\n * GitHub/Gitee release asset, custom URL, local file, local directory),\n * verifies the source-specific integrity layer (npm SRI > ref digest fragment\n * > sha256 on exchange), discovers the `agent-forge.json` identity through the\n * shared bounded unpackers, and exposes the result as an opaque distribution\n * artifact the existing installer/install-host chain consumes unchanged.\n */\n\nconst NODE_PLUGIN_ACQUISITION_HOST_VERSION_V1 = 1 as const;\nconst MAX_PACKAGE_MANIFEST_BYTES_V1 = 64 * 1024;\nconst ECOSYSTEM_MANIFEST_FILE_V1 = \"agent-forge.json\";\n/** Fixed far-future expiry; the artifact handle is single-transaction and never persisted. */\nconst ACQUISITION_ARTIFACT_EXPIRES_AT_V1 = \"2099-01-01T00:00:00.000Z\";\nconst ARTIFACT_CHUNK_BYTES_V1 = 64 * 1024;\n\n/** Environment variable overriding the npm registry origin (bare http(s) origin). */\nexport const AGENT_FORGE_NPM_REGISTRY_ENV_V1 = \"AGENT_FORGE_NPM_REGISTRY\";\n/** Environment variable carrying the npm registry bearer token. */\nexport const AGENT_FORGE_NPM_TOKEN_ENV_V1 = \"AGENT_FORGE_NPM_TOKEN\";\n/** Environment variable overriding the GitHub release API origin (bare http(s) origin). */\nexport const AGENT_FORGE_GITHUB_API_ENV_V1 = \"AGENT_FORGE_GITHUB_API\";\n/** Environment variable overriding the Gitee release API origin (bare http(s) origin, includes the /api/v5 path). */\nexport const AGENT_FORGE_GITEE_API_ENV_V1 = \"AGENT_FORGE_GITEE_API\";\n/** Environment variable carrying the optional GitHub API token. */\nexport const GITHUB_TOKEN_ENV_V1 = \"GITHUB_TOKEN\";\n/** Environment variable carrying the optional Gitee API token. */\nexport const GITEE_TOKEN_ENV_V1 = \"GITEE_TOKEN\";\n\nexport interface NodePluginAcquisitionHostV1 {\n\treadonly version: typeof NODE_PLUGIN_ACQUISITION_HOST_VERSION_V1;\n\t/** Parse and acquire one ref into a package + artifact pair. */\n\treadonly resolvePackage: (input: {\n\t\treadonly ref: string;\n\t\treadonly signal?: AbortSignal;\n\t}) => Promise<PluginAcquisitionPackageV1>;\n\t/** Private installer-facing reader; mirrors the HTTP distribution host boundary. */\n\treadonly openArtifact: (input: {\n\t\treadonly artifact: PluginDistributionArtifactV1;\n\t\treadonly signal?: AbortSignal;\n\t}) => AsyncIterable<Uint8Array>;\n\treadonly releaseArtifact: (input: { readonly artifact: { readonly artifactRef: string } }) => Promise<void>;\n\t/** Whether this host owns the artifact reference (used to compose artifact readers). */\n\treadonly ownsArtifact: (input: { readonly artifactRef: string }) => boolean;\n\treadonly close: () => Promise<void>;\n}\n\nexport interface NodePluginAcquisitionHostOptionsV1 {\n\t/** Real fetch or a deterministic test replacement. */\n\treadonly fetch?: typeof globalThis.fetch;\n\t/** Bare http(s) npm registry origin; defaults to the environment variable, then the npm public registry. */\n\treadonly npmRegistry?: string;\n\t/** npm registry bearer token; defaults to the environment variable. */\n\treadonly npmToken?: string;\n\t/** Bare http(s) GitHub release API origin; defaults to the environment variable, then api.github.com. */\n\treadonly githubApiOrigin?: string;\n\t/** Bare http(s) Gitee release API origin; defaults to the environment variable, then gitee.com/api/v5. */\n\treadonly giteeApiOrigin?: string;\n\t/** GitHub API token sent as a bearer header; defaults to the environment variable. */\n\treadonly githubToken?: string;\n\t/** Gitee API token sent as an access_token query parameter; defaults to the environment variable. */\n\treadonly giteeToken?: string;\n\treadonly requestTimeoutMs?: number;\n\treadonly maxResponseBytes?: number;\n\treadonly maxTarballBytes?: number;\n\treadonly limits?: NodeZipPackageLimitsV1;\n\treadonly userAgent?: string;\n}\n\ninterface AcquiredBytesV1 {\n\treadonly bytes: Uint8Array;\n\treadonly mediaType: \"application/zip\" | \"application/gzip\";\n\treadonly digest: { readonly algorithm: \"sha256\" | \"sha512\"; readonly hex: string };\n\treadonly source: string;\n}\n\ninterface AcquiredArtifactRecordV1 {\n\treadonly bytes: Uint8Array;\n\treadonly artifact: PluginDistributionArtifactV1;\n}\n\nconst LOCAL_PROBE_V1: PluginAcquisitionLocalProbeV1 = {\n\t// The parser contract is synchronous; one lstat per candidate ref keeps\n\t// this bounded. Symlinks classify as \"other\" so they never install as local.\n\tstatLocalRef: (path) => {\n\t\tconst stats = lstatSync(path, { throwIfNoEntry: false });\n\t\tif (stats === undefined) return \"missing\";\n\t\tif (stats.isSymbolicLink()) return \"other\";\n\t\tif (stats.isDirectory()) return \"directory\";\n\t\tif (stats.isFile()) return \"file\";\n\t\treturn \"other\";\n\t},\n};\n\nfunction mapInstallError(error: unknown): PluginAcquisitionErrorV1 {\n\tif (error instanceof PluginAcquisitionErrorV1) return error;\n\tif (error instanceof NodePackageInstallErrorV1) {\n\t\tif (error.code === \"cancelled\") return new PluginAcquisitionErrorV1(\"cancelled\");\n\t\tif (error.code === \"archive_budget_exceeded\") return new PluginAcquisitionErrorV1(\"budget_exceeded\");\n\t\tif (error.code === \"unsupported_media_type\") return new PluginAcquisitionErrorV1(\"unsupported_media_type\");\n\t\treturn new PluginAcquisitionErrorV1(\"package_invalid\");\n\t}\n\treturn new PluginAcquisitionErrorV1(\"download_failed\");\n}\n\nfunction mapNpmError(error: unknown): PluginAcquisitionErrorV1 {\n\tif (error instanceof PluginAcquisitionErrorV1) return error;\n\tif (error instanceof NodeNpmRegistrySourceErrorV1) {\n\t\tif (error.code === \"package_not_found\") return new PluginAcquisitionErrorV1(\"package_not_found\");\n\t\tif (error.code === \"version_not_found\") return new PluginAcquisitionErrorV1(\"version_not_found\");\n\t\tif (error.code === \"cancelled\") return new PluginAcquisitionErrorV1(\"cancelled\");\n\t\tif (error.code === \"rate_limited\")\n\t\t\treturn new PluginAcquisitionErrorV1(\n\t\t\t\t\"rate_limited\",\n\t\t\t\terror.retryAfterSeconds === undefined ? undefined : `retry after ${error.retryAfterSeconds}s`,\n\t\t\t);\n\t\tif (error.code === \"response_too_large\") return new PluginAcquisitionErrorV1(\"budget_exceeded\");\n\t\tif (error.code === \"request_timed_out\")\n\t\t\treturn new PluginAcquisitionErrorV1(\"download_failed\", \"request timed out\");\n\t\tif (error.code === \"invalid_response\" || error.code === \"integrity_unsupported\")\n\t\t\treturn new PluginAcquisitionErrorV1(\"package_invalid\");\n\t\treturn new PluginAcquisitionErrorV1(\"download_failed\");\n\t}\n\treturn mapInstallError(error);\n}\n\nfunction mapUrlError(error: unknown): PluginAcquisitionErrorV1 {\n\tif (error instanceof PluginAcquisitionErrorV1) return error;\n\tif (error instanceof NodeUrlPackageSourceErrorV1) {\n\t\tif (error.code === \"digest_mismatch\") return new PluginAcquisitionErrorV1(\"digest_mismatch\");\n\t\tif (error.code === \"cancelled\") return new PluginAcquisitionErrorV1(\"cancelled\");\n\t\tif (error.code === \"invalid_url\" || error.code === \"invalid_configuration\")\n\t\t\treturn new PluginAcquisitionErrorV1(\"invalid_ref\");\n\t\tif (error.code === \"response_too_large\") return new PluginAcquisitionErrorV1(\"budget_exceeded\");\n\t\treturn new PluginAcquisitionErrorV1(\"download_failed\");\n\t}\n\treturn mapInstallError(error);\n}\n\nfunction mapReleaseError(error: unknown): PluginAcquisitionErrorV1 {\n\tif (error instanceof PluginAcquisitionErrorV1) return error;\n\tif (error instanceof NodeReleasePackageSourceErrorV1) {\n\t\tif (error.code === \"cancelled\") return new PluginAcquisitionErrorV1(\"cancelled\");\n\t\tif (error.code === \"invalid_configuration\") return new PluginAcquisitionErrorV1(\"invalid_ref\");\n\t\tif (error.code === \"response_too_large\") return new PluginAcquisitionErrorV1(\"budget_exceeded\");\n\t\tif (error.code === \"invalid_response\") return new PluginAcquisitionErrorV1(\"package_invalid\");\n\t\tif (error.code === \"rate_limited\")\n\t\t\treturn new PluginAcquisitionErrorV1(\n\t\t\t\t\"rate_limited\",\n\t\t\t\terror.resetEpochSeconds === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: `rate limit resets at ${new Date(error.resetEpochSeconds * 1000).toISOString()}`,\n\t\t\t);\n\t\tif (\n\t\t\terror.code === \"release_not_found\" ||\n\t\t\terror.code === \"release_asset_not_found\" ||\n\t\t\terror.code === \"release_asset_ambiguous\"\n\t\t)\n\t\t\treturn new PluginAcquisitionErrorV1(error.code, error.message);\n\t\treturn new PluginAcquisitionErrorV1(\"download_failed\");\n\t}\n\t// Asset downloads ride the URL package source; digest and budget errors pass through unchanged.\n\treturn mapUrlError(error);\n}\n\nfunction shaHex(algorithm: \"sha256\" | \"sha512\", bytes: Uint8Array): string {\n\treturn createHash(algorithm).update(bytes).digest(\"hex\");\n}\n\n/** Abort probe as a function so later re-checks are not flow-narrowed away after awaits. */\nfunction signalAborted(signal: AbortSignal | undefined): boolean {\n\treturn signal?.aborted === true;\n}\n\n/** Discover the `agent-forge.json` identity in already-bounded package entries. */\nexport function pluginAcquisitionManifestFromEntriesV1(entries: readonly NodeZipPackageEntryV1[]): {\n\treadonly manifest: PluginManifestV1;\n\treadonly manifestDigest: string;\n} {\n\tconst manifestEntry = entries.find((entry) => entry.name === ECOSYSTEM_MANIFEST_FILE_V1 && !entry.directory);\n\tif (manifestEntry === undefined || manifestEntry.bytes.byteLength > MAX_PACKAGE_MANIFEST_BYTES_V1)\n\t\tthrow new PluginAcquisitionErrorV1(\"package_invalid\");\n\tlet value: unknown;\n\ttry {\n\t\tvalue = JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(manifestEntry.bytes));\n\t} catch {\n\t\tthrow new PluginAcquisitionErrorV1(\"package_invalid\");\n\t}\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value))\n\t\tthrow new PluginAcquisitionErrorV1(\"package_invalid\");\n\tconst record = value as Record<string, unknown>;\n\tconst manifestKeys = new Set([\n\t\t\"id\",\n\t\t\"pluginVersion\",\n\t\t\"apiVersion\",\n\t\t\"minHostVersion\",\n\t\t\"maxHostVersion\",\n\t\t\"capabilityRefs\",\n\t\t\"requires\",\n\t\t\"platform\",\n\t\t\"testOnly\",\n\t]);\n\tif (\n\t\trecord.packageFormatVersion !== 1 ||\n\t\tObject.keys(record).some((key) => key !== \"packageFormatVersion\" && !manifestKeys.has(key))\n\t)\n\t\tthrow new PluginAcquisitionErrorV1(\"package_invalid\");\n\tconst id = record.id;\n\tconst pluginVersion = record.pluginVersion;\n\tconst apiVersion = record.apiVersion;\n\tif (\n\t\ttypeof id !== \"string\" ||\n\t\tid.trim().length === 0 ||\n\t\tid.length > 256 ||\n\t\ttypeof pluginVersion !== \"string\" ||\n\t\tpluginVersion.trim().length === 0 ||\n\t\tpluginVersion.length > 256 ||\n\t\ttypeof apiVersion !== \"string\" ||\n\t\tapiVersion.trim().length === 0 ||\n\t\tapiVersion.length > 256\n\t)\n\t\tthrow new PluginAcquisitionErrorV1(\"package_invalid\");\n\tif (record.minHostVersion === undefined && record.maxHostVersion === undefined)\n\t\tthrow new PluginAcquisitionErrorV1(\"package_invalid\");\n\tconst manifest: PluginManifestV1 = Object.freeze({\n\t\tid,\n\t\tpluginVersion,\n\t\tapiVersion,\n\t\t...(record.minHostVersion === undefined ? {} : { minHostVersion: record.minHostVersion as string }),\n\t\t...(record.maxHostVersion === undefined ? {} : { maxHostVersion: record.maxHostVersion as string }),\n\t\t...(record.capabilityRefs === undefined\n\t\t\t? {}\n\t\t\t: { capabilityRefs: record.capabilityRefs as PluginManifestV1[\"capabilityRefs\"] }),\n\t\t...(record.requires === undefined ? {} : { requires: record.requires as PluginManifestV1[\"requires\"] }),\n\t\t...(record.platform === undefined ? {} : { platform: record.platform as PluginManifestV1[\"platform\"] }),\n\t\t...(record.testOnly === undefined ? {} : { testOnly: record.testOnly as boolean }),\n\t});\n\treturn { manifest, manifestDigest: pluginManifestDigestV1(manifest) };\n}\n\n/**\n * Create the Node acquisition host. All sources share the bounded unpackers,\n * the manifest identity discovery, and the artifact reader contract used by\n * the existing install host. Nothing is downloaded until `resolvePackage`.\n */\nexport function createNodePluginAcquisitionHostV1(\n\toptions: NodePluginAcquisitionHostOptionsV1 = {},\n): NodePluginAcquisitionHostV1 {\n\tconst limits = options.limits ?? {};\n\tconst npmRegistryOption = options.npmRegistry ?? process.env[AGENT_FORGE_NPM_REGISTRY_ENV_V1]?.trim();\n\tconst npmTokenOption = options.npmToken ?? process.env[AGENT_FORGE_NPM_TOKEN_ENV_V1]?.trim();\n\tconst githubApiOriginOption = options.githubApiOrigin ?? process.env[AGENT_FORGE_GITHUB_API_ENV_V1]?.trim();\n\tconst giteeApiOriginOption = options.giteeApiOrigin ?? process.env[AGENT_FORGE_GITEE_API_ENV_V1]?.trim();\n\tconst githubTokenOption = options.githubToken ?? process.env[GITHUB_TOKEN_ENV_V1]?.trim();\n\tconst giteeTokenOption = options.giteeToken ?? process.env[GITEE_TOKEN_ENV_V1]?.trim();\n\tconst npmSource: NodeNpmRegistrySourceV1 = createNodeNpmRegistrySourceV1({\n\t\t...(npmRegistryOption === undefined || npmRegistryOption === \"\" ? {} : { registry: npmRegistryOption }),\n\t\t...(npmTokenOption === undefined || npmTokenOption === \"\" ? {} : { token: npmTokenOption }),\n\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t...(options.requestTimeoutMs === undefined ? {} : { requestTimeoutMs: options.requestTimeoutMs }),\n\t\t...(options.maxResponseBytes === undefined ? {} : { maxResponseBytes: options.maxResponseBytes }),\n\t\t...(options.maxTarballBytes === undefined ? {} : { maxTarballBytes: options.maxTarballBytes }),\n\t\t...(options.userAgent === undefined ? {} : { userAgent: options.userAgent }),\n\t});\n\tconst releaseSource: NodeReleasePackageSourceV1 = createNodeReleasePackageSourceV1({\n\t\t...(githubApiOriginOption === undefined || githubApiOriginOption === \"\"\n\t\t\t? {}\n\t\t\t: { githubApiOrigin: githubApiOriginOption }),\n\t\t...(giteeApiOriginOption === undefined || giteeApiOriginOption === \"\"\n\t\t\t? {}\n\t\t\t: { giteeApiOrigin: giteeApiOriginOption }),\n\t\t...(githubTokenOption === undefined || githubTokenOption === \"\" ? {} : { githubToken: githubTokenOption }),\n\t\t...(giteeTokenOption === undefined || giteeTokenOption === \"\" ? {} : { giteeToken: giteeTokenOption }),\n\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t...(options.requestTimeoutMs === undefined ? {} : { requestTimeoutMs: options.requestTimeoutMs }),\n\t\t...(options.maxResponseBytes === undefined ? {} : { maxResponseBytes: options.maxResponseBytes }),\n\t\t...(options.maxTarballBytes === undefined ? {} : { maxAssetBytes: options.maxTarballBytes }),\n\t\t...(options.userAgent === undefined ? {} : { userAgent: options.userAgent }),\n\t});\n\tconst artifacts = new Map<string, AcquiredArtifactRecordV1>();\n\tlet closed = false;\n\n\tconst acquireBytes = async (\n\t\tref: PluginAcquisitionRefV1,\n\t\tsignal: AbortSignal | undefined,\n\t): Promise<AcquiredBytesV1> => {\n\t\tif (ref.kind === \"github\" || ref.kind === \"gitee\") {\n\t\t\ttry {\n\t\t\t\tconst download = await releaseSource.downloadReleaseAsset({\n\t\t\t\t\tkind: ref.kind,\n\t\t\t\t\towner: ref.owner,\n\t\t\t\t\trepo: ref.repo,\n\t\t\t\t\t...(ref.tag === undefined ? {} : { tag: ref.tag }),\n\t\t\t\t\t...(ref.expectedDigestHex === undefined ? {} : { expectedDigestHex: ref.expectedDigestHex }),\n\t\t\t\t\tsignal,\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tbytes: download.bytes,\n\t\t\t\t\tmediaType: download.mediaType,\n\t\t\t\t\tdigest: { algorithm: \"sha256\", hex: download.sha256Hex },\n\t\t\t\t\tsource: download.sourceLabel,\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tthrow mapReleaseError(error);\n\t\t\t}\n\t\t}\n\t\tif (ref.kind === \"npm\") {\n\t\t\ttry {\n\t\t\t\tconst resolved = await npmSource.resolveNpmPackage({\n\t\t\t\t\tname: ref.name,\n\t\t\t\t\t...(ref.range === undefined ? {} : { range: ref.range }),\n\t\t\t\t\tsignal,\n\t\t\t\t});\n\t\t\t\tconst bytes = await npmSource.fetchTarball({ url: resolved.tarballUrl, signal });\n\t\t\t\tconst hex = shaHex(resolved.integrity.algorithm, bytes);\n\t\t\t\tif (hex !== resolved.integrity.hex) throw new PluginAcquisitionErrorV1(\"digest_mismatch\");\n\t\t\t\treturn {\n\t\t\t\t\tbytes,\n\t\t\t\t\tmediaType: \"application/gzip\",\n\t\t\t\t\tdigest: resolved.integrity,\n\t\t\t\t\tsource: `npm:${new URL(resolved.tarballUrl).host}`,\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tthrow mapNpmError(error);\n\t\t\t}\n\t\t}\n\t\tif (ref.kind === \"url\") {\n\t\t\ttry {\n\t\t\t\tconst download = await downloadNodeUrlPackageV1(\n\t\t\t\t\t{\n\t\t\t\t\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t\t\t\t\t...(options.requestTimeoutMs === undefined ? {} : { requestTimeoutMs: options.requestTimeoutMs }),\n\t\t\t\t\t\t...(options.maxTarballBytes === undefined ? {} : { maxPackageBytes: options.maxTarballBytes }),\n\t\t\t\t\t\t...(options.userAgent === undefined ? {} : { userAgent: options.userAgent }),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\turl: ref.url,\n\t\t\t\t\t\t...(ref.expectedDigestHex === undefined ? {} : { expectedDigestHex: ref.expectedDigestHex }),\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\tbytes: download.bytes,\n\t\t\t\t\tmediaType: download.mediaType,\n\t\t\t\t\tdigest: { algorithm: \"sha256\", hex: download.digestHex },\n\t\t\t\t\tsource: `url:${new URL(ref.url).host}`,\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tthrow mapUrlError(error);\n\t\t\t}\n\t\t}\n\t\tif (ref.kind === \"local-file\") {\n\t\t\ttry {\n\t\t\t\tconst bytes = await readLocalPackageFileV1(ref.path, limits, signal);\n\t\t\t\tconst fileName = ref.path.split(/[\\\\/]/u).pop();\n\t\t\t\tconst mediaType = detectPluginPackageMediaTypeV1(\n\t\t\t\t\tbytes,\n\t\t\t\t\tfileName === undefined || fileName.length === 0 ? undefined : fileName,\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\tbytes,\n\t\t\t\t\tmediaType,\n\t\t\t\t\tdigest: { algorithm: \"sha256\", hex: shaHex(\"sha256\", bytes) },\n\t\t\t\t\tsource: \"local:file\",\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tthrow mapInstallError(error);\n\t\t\t}\n\t\t}\n\t\tif (ref.kind === \"local-path\") {\n\t\t\ttry {\n\t\t\t\tconst entries = await collectLocalDirectoryPackageEntriesV1(ref.path, limits, signal);\n\t\t\t\tconst bytes = buildNodeTarGzBytesV1(\n\t\t\t\t\tentries.map((entry) => ({ name: entry.name, directory: entry.directory, bytes: entry.bytes })),\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\tbytes,\n\t\t\t\t\tmediaType: \"application/gzip\",\n\t\t\t\t\tdigest: { algorithm: \"sha256\", hex: shaHex(\"sha256\", bytes) },\n\t\t\t\t\tsource: \"local:dir\",\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tthrow mapInstallError(error);\n\t\t\t}\n\t\t}\n\t\tthrow new PluginAcquisitionErrorV1(\"invalid_ref\");\n\t};\n\n\tconst releaseArtifact = async (input: { readonly artifact: { readonly artifactRef: string } }): Promise<void> => {\n\t\tif (!artifacts.delete(input.artifact.artifactRef)) throw new NodePackageInstallErrorV1(\"invalid_artifact\");\n\t};\n\n\tconst resolvePackage = async (input: {\n\t\treadonly ref: string;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<PluginAcquisitionPackageV1> => {\n\t\tif (closed || signalAborted(input.signal)) throw new PluginAcquisitionErrorV1(\"cancelled\");\n\t\tlet ref: PluginAcquisitionRefV1;\n\t\ttry {\n\t\t\tref = parsePluginAcquisitionRefV1(input.ref, LOCAL_PROBE_V1);\n\t\t} catch (error) {\n\t\t\tif (error instanceof PluginAcquisitionErrorV1) throw error;\n\t\t\tthrow new PluginAcquisitionErrorV1(\"invalid_ref\");\n\t\t}\n\t\tconst acquired = await acquireBytes(ref, input.signal);\n\t\tif (signalAborted(input.signal)) throw new PluginAcquisitionErrorV1(\"cancelled\");\n\t\tlet entries: readonly NodeZipPackageEntryV1[];\n\t\ttry {\n\t\t\tentries =\n\t\t\t\tacquired.mediaType === \"application/gzip\"\n\t\t\t\t\t? await parseNodeTarGzPackageV1(acquired.bytes, limits)\n\t\t\t\t\t: parseNodeZipPackageV1(acquired.bytes, limits);\n\t\t} catch (error) {\n\t\t\tthrow mapInstallError(error);\n\t\t}\n\t\tconst identity = pluginAcquisitionManifestFromEntriesV1(entries);\n\t\tif (closed) throw new PluginAcquisitionErrorV1(\"cancelled\");\n\t\tconst artifactRef = `plugin-acquisition://node/${randomUUID()}`;\n\t\tconst artifact: PluginDistributionArtifactV1 = Object.freeze({\n\t\t\tversion: 1,\n\t\t\tsource: acquired.source,\n\t\t\tpluginId: identity.manifest.id,\n\t\t\tpluginVersion: identity.manifest.pluginVersion,\n\t\t\tmanifestDigest: identity.manifestDigest,\n\t\t\tartifactDigest:\n\t\t\t\tacquired.digest.algorithm === \"sha512\" ? `sha512:${acquired.digest.hex}` : `sha256:${acquired.digest.hex}`,\n\t\t\texpiresAt: ACQUISITION_ARTIFACT_EXPIRES_AT_V1,\n\t\t\tsizeBytes: acquired.bytes.byteLength,\n\t\t\tmediaType: acquired.mediaType,\n\t\t\tartifactRef,\n\t\t});\n\t\tartifacts.set(artifactRef, { bytes: acquired.bytes, artifact });\n\t\treturn Object.freeze({\n\t\t\tmanifest: identity.manifest,\n\t\t\tmanifestDigest: identity.manifestDigest,\n\t\t\tsource: acquired.source,\n\t\t\tartifact,\n\t\t\trelease: async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait releaseArtifact({ artifact: { artifactRef } });\n\t\t\t\t\treturn true;\n\t\t\t\t} catch {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t};\n\n\treturn {\n\t\tversion: NODE_PLUGIN_ACQUISITION_HOST_VERSION_V1,\n\t\tresolvePackage,\n\t\topenArtifact(input) {\n\t\t\treturn (async function* (): AsyncGenerator<Uint8Array> {\n\t\t\t\tconst record = artifacts.get(input.artifact.artifactRef);\n\t\t\t\tif (record === undefined) throw new NodePackageInstallErrorV1(\"invalid_artifact\");\n\t\t\t\tif (\n\t\t\t\t\trecord.artifact.pluginId !== input.artifact.pluginId ||\n\t\t\t\t\trecord.artifact.pluginVersion !== input.artifact.pluginVersion ||\n\t\t\t\t\trecord.artifact.manifestDigest !== input.artifact.manifestDigest ||\n\t\t\t\t\trecord.artifact.artifactDigest !== input.artifact.artifactDigest ||\n\t\t\t\t\trecord.artifact.sizeBytes !== input.artifact.sizeBytes\n\t\t\t\t)\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"invalid_artifact\");\n\t\t\t\tfor (let offset = 0; offset < record.bytes.byteLength; offset += ARTIFACT_CHUNK_BYTES_V1) {\n\t\t\t\t\tif (input.signal?.aborted === true) throw new NodePackageInstallErrorV1(\"cancelled\");\n\t\t\t\t\tyield new Uint8Array(\n\t\t\t\t\t\trecord.bytes.subarray(offset, Math.min(offset + ARTIFACT_CHUNK_BYTES_V1, record.bytes.byteLength)),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t})();\n\t\t},\n\t\treleaseArtifact,\n\t\townsArtifact: (input) => artifacts.has(input.artifactRef),\n\t\tasync close() {\n\t\t\tclosed = true;\n\t\t\tartifacts.clear();\n\t\t},\n\t};\n}\n"]}
|
|
@@ -33,10 +33,17 @@ export interface NodePluginBootstrapOptionsV1 {
|
|
|
33
33
|
readonly signal?: AbortSignal;
|
|
34
34
|
/** Full dependency override for deterministic tests; the env switch still applies. */
|
|
35
35
|
readonly deps?: PluginBootstrapDepsV1;
|
|
36
|
+
/** Overrides the first-run progress line (stderr) for tests and hosts. */
|
|
37
|
+
readonly onPendingInstalls?: (count: number) => void;
|
|
36
38
|
}
|
|
37
39
|
export type NodePluginBootstrapResultV1 = PluginBootstrapResultV1 & {
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Present when a posture switch short-circuited the run before any local
|
|
42
|
+
* comparison: the wiring-level env off switch, or the offline posture
|
|
43
|
+
* (设计 §4.4 offline 姿态门, 2026-10-03 — offline installs cannot succeed
|
|
44
|
+
* and would only fail slowly, so the run is skipped immediately).
|
|
45
|
+
*/
|
|
46
|
+
readonly skipped?: "disabled" | "offline";
|
|
40
47
|
};
|
|
41
48
|
/**
|
|
42
49
|
* Run the startup bootstrap for one agent directory. The function resolves
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-plugin-bootstrap.d.ts","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-plugin-bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AASrF,OAAO,EAGN,KAAK,sBAAsB,EAC3B,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,uBAAuB,EAAwB,MAAM,uBAAuB,CAAC;AAGvH,6EAA6E;AAC7E,eAAO,MAAM,mCAAmC,iCAAiC,CAAC;AAKlF,MAAM,WAAW,4BAA4B;IAC5C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,6BAA6B,EAAE,CAAC;IAC7D,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,sBAAsB,CAAC;IACzC,iDAAiD;IACjD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,sFAAsF;IACtF,QAAQ,CAAC,IAAI,CAAC,EAAE,qBAAqB,CAAC;CACtC;AAED,MAAM,MAAM,2BAA2B,GAAG,uBAAuB,GAAG;IACnE,uFAAuF;IACvF,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC;CAC9B,CAAC;AAqCF;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC7C,OAAO,EAAE,4BAA4B,GACnC,OAAO,CAAC,2BAA2B,CAAC,CAmKtC","sourcesContent":["/**\n * Node wiring for the startup plugin bootstrap (design\n * `插件独立分发与启动装配设计.md` §4.4, §0.7).\n *\n * `AGENT_FORGE_PLUGIN_BOOTSTRAP=off` skips everything, including the local\n * comparison. The comparison dependency reads the global and project\n * plugin-state.json stores only — read-only, and it never constructs an HTTP\n * client, so an assembled environment starts offline (G3). Network objects\n * (npm acquisition host, install host) are built lazily inside the install\n * action and closed when the bootstrap finishes. Installs go through the\n * npm acquisition path exclusively and persist the `npm:<host>` source label\n * in the global plugin state (same prepare/install/activate/upsert\n * transaction shape as the CLI install flow, implemented as a library\n * function without going through the CLI layer).\n */\n\nimport { join } from \"node:path\";\nimport { CONFIG_DIR_NAME } from \"../../config.ts\";\nimport { t } from \"../../core/i18n/index.ts\";\nimport type { PluginBootstrapFactoryEntryV1 } from \"./bootstrap-factory-manifest.ts\";\nimport { BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1 } from \"./bootstrap-factory-manifest.ts\";\nimport {\n\tDEFAULT_PLUGIN_STATE_FILE_V1,\n\tdefaultPluginHostFactsV1,\n\tdefaultPluginInstallStoreDirectoryV1,\n\tprojectPluginScopeRefV1,\n} from \"./default-active-bindings.ts\";\nimport { createPluginInstallerV1, DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1, type PluginInstallerV1 } from \"./installer.ts\";\nimport {\n\tcreateNodePackageInstallHostV1,\n\ttype NodePackageInstallHostV1,\n\ttype NodeZipPackageLimitsV1,\n} from \"./node-package-install-host.ts\";\nimport { createNodePluginAcquisitionHostV1, type NodePluginAcquisitionHostV1 } from \"./node-plugin-acquisition-host.ts\";\nimport { type PluginBootstrapDepsV1, type PluginBootstrapResultV1, runPluginBootstrapV1 } from \"./plugin-bootstrap.ts\";\nimport { createPluginStateStoreV1, type PluginStateStoreV1 } from \"./state.ts\";\n\n/** Environment variable disabling the startup bootstrap entirely (`off`). */\nexport const AGENT_FORGE_PLUGIN_BOOTSTRAP_ENV_V1 = \"AGENT_FORGE_PLUGIN_BOOTSTRAP\";\n\n/** The only recognized disabling value; every other value (and absence) keeps bootstrap on. */\nconst PLUGIN_BOOTSTRAP_DISABLED_VALUE_V1 = \"off\";\n\nexport interface NodePluginBootstrapOptionsV1 {\n\treadonly agentDir: string;\n\treadonly cwd: string;\n\t/** Defaults to the frozen factory manifest. */\n\treadonly manifest?: readonly PluginBootstrapFactoryEntryV1[];\n\t/** Bare http(s) npm registry origin; forwarded to the acquisition host. */\n\treadonly npmRegistry?: string;\n\t/** npm registry bearer token; forwarded to the acquisition host. */\n\treadonly npmToken?: string;\n\treadonly limits?: NodeZipPackageLimitsV1;\n\t/** Deterministic fetch replacement for tests. */\n\treadonly fetch?: typeof globalThis.fetch;\n\treadonly signal?: AbortSignal;\n\t/** Full dependency override for deterministic tests; the env switch still applies. */\n\treadonly deps?: PluginBootstrapDepsV1;\n}\n\nexport type NodePluginBootstrapResultV1 = PluginBootstrapResultV1 & {\n\t/** Present when the env switch short-circuited the run before any local comparison. */\n\treadonly skipped?: \"disabled\";\n};\n\n/** Install-scoped boundaries; created lazily by the first install action. */\ninterface InstallSessionV1 {\n\treadonly acquisition: NodePluginAcquisitionHostV1;\n\treadonly installHost: NodePackageInstallHostV1;\n\treadonly installer: PluginInstallerV1;\n\treadonly stateStore: PluginStateStoreV1;\n}\n\nfunction readActiveVersions(\n\tstore: PluginStateStoreV1,\n\tscope: \"global\" | \"project\",\n\tscopeRef: string,\n\tsignal: AbortSignal | undefined,\n): Promise<ReadonlyMap<string, string>> {\n\treturn (async () => {\n\t\tconst result = await store.read({ ...(signal === undefined ? {} : { signal }) });\n\t\tif (result.status !== \"ok\" && result.status !== \"missing\")\n\t\t\tthrow new Error(\n\t\t\t\tt(\"plugin state read failed ({detail}) for the {scope} scope\", {\n\t\t\t\t\tdetail: result.diagnostics[0]?.code ?? result.status,\n\t\t\t\t\tscope,\n\t\t\t\t}),\n\t\t\t);\n\t\tconst versions = new Map<string, string>();\n\t\tfor (const record of result.snapshot.records) {\n\t\t\tif (record.state.scope !== scope || record.state.scopeRef !== scopeRef) continue;\n\t\t\t// Enabled is deliberately not filtered: a disabled plugin still owns\n\t\t\t// its active installation record, and bootstrap never touches it (G5).\n\t\t\tif (record.state.lifecycle !== \"active\") continue;\n\t\t\tversions.set(record.pluginId, record.pluginVersion);\n\t\t}\n\t\treturn versions;\n\t})();\n}\n\n/**\n * Run the startup bootstrap for one agent directory. The function resolves\n * with a structured result and never throws for per-plugin failures; only a\n * wiring-level construction error propagates to the caller (main.ts guards\n * startup with its own catch).\n */\nexport async function runNodePluginBootstrapV1(\n\toptions: NodePluginBootstrapOptionsV1,\n): Promise<NodePluginBootstrapResultV1> {\n\tif (process.env[AGENT_FORGE_PLUGIN_BOOTSTRAP_ENV_V1]?.trim() === PLUGIN_BOOTSTRAP_DISABLED_VALUE_V1) {\n\t\treturn Object.freeze({\n\t\t\tversion: 1,\n\t\t\tstatus: \"succeeded\",\n\t\t\tactions: Object.freeze([]),\n\t\t\tdiagnostics: Object.freeze([]),\n\t\t\tdurationMs: 0,\n\t\t\tskipped: \"disabled\",\n\t\t});\n\t}\n\tif (options.deps !== undefined) {\n\t\treturn await runPluginBootstrapV1({\n\t\t\tmanifest: options.manifest ?? BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1,\n\t\t\tdeps: options.deps,\n\t\t});\n\t}\n\tlet session: InstallSessionV1 | undefined;\n\tconst ensureSession = async (): Promise<InstallSessionV1> => {\n\t\tif (session !== undefined) return session;\n\t\tconst acquisition = createNodePluginAcquisitionHostV1({\n\t\t\t...(options.npmRegistry === undefined ? {} : { npmRegistry: options.npmRegistry }),\n\t\t\t...(options.npmToken === undefined ? {} : { npmToken: options.npmToken }),\n\t\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t\t...(options.limits === undefined ? {} : { limits: options.limits }),\n\t\t});\n\t\tconst installHost = await createNodePackageInstallHostV1({\n\t\t\topenArtifact: (input) => acquisition.openArtifact(input),\n\t\t\tinstallationDirectory: defaultPluginInstallStoreDirectoryV1(options.agentDir),\n\t\t\tpersistence: \"persistent\",\n\t\t\tsupportedScopes: [\"global\", \"project\"],\n\t\t\t...(options.limits === undefined ? {} : { ...options.limits }),\n\t\t});\n\t\tsession = {\n\t\t\tacquisition,\n\t\t\tinstallHost,\n\t\t\tinstaller: createPluginInstallerV1({ host: installHost }),\n\t\t\tstateStore: createPluginStateStoreV1({ filePath: join(options.agentDir, DEFAULT_PLUGIN_STATE_FILE_V1) }),\n\t\t};\n\t\treturn session;\n\t};\n\tconst deps: PluginBootstrapDepsV1 = {\n\t\tlistActive: async ({ signal }) => {\n\t\t\tconst globalVersions = readActiveVersions(\n\t\t\t\tcreatePluginStateStoreV1({ filePath: join(options.agentDir, DEFAULT_PLUGIN_STATE_FILE_V1) }),\n\t\t\t\t\"global\",\n\t\t\t\tDEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\tsignal,\n\t\t\t);\n\t\t\tconst projectVersions = readActiveVersions(\n\t\t\t\tcreatePluginStateStoreV1({ filePath: join(options.cwd, CONFIG_DIR_NAME, DEFAULT_PLUGIN_STATE_FILE_V1) }),\n\t\t\t\t\"project\",\n\t\t\t\tprojectPluginScopeRefV1(options.cwd),\n\t\t\t\tsignal,\n\t\t\t);\n\t\t\tconst [globalResult, projectResult] = await Promise.all([globalVersions, projectVersions]);\n\t\t\t// Project precedence mirrors active-binding resolution: a project\n\t\t\t// installation shadows the same plugin id from the global scope.\n\t\t\treturn new Map([...globalResult, ...projectResult]);\n\t\t},\n\t\tinstallFromNpm: async ({ npmName, range, signal }) => {\n\t\t\tconst active = await ensureSession();\n\t\t\t// npm refs only (§0.7): scoped or plain names with the shared minimal\n\t\t\t// range subset; no github/gitee/url/local ref can be expressed here.\n\t\t\tconst ref = range === undefined ? npmName : `${npmName}@${range}`;\n\t\t\tconst acquired = await active.acquisition.resolvePackage({ ref, ...(signal === undefined ? {} : { signal }) });\n\t\t\tlet released = false;\n\t\t\tconst release = async (): Promise<void> => {\n\t\t\t\tif (released) return;\n\t\t\t\treleased = true;\n\t\t\t\tawait acquired.release();\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tconst verified = active.installer.prepare({\n\t\t\t\t\tmanifest: acquired.manifest,\n\t\t\t\t\tsource: acquired.source,\n\t\t\t\t\thost: defaultPluginHostFactsV1(),\n\t\t\t\t});\n\t\t\t\tif (verified.status !== \"verified\")\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"installer prepare rejected {pluginId}: {reason}\", {\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t\treason: verified.reason,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\tconst installed = await active.installer.install({\n\t\t\t\t\trecord: verified.record,\n\t\t\t\t\tscope: \"global\",\n\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\tartifact: acquired.artifact,\n\t\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t\t});\n\t\t\t\tif (installed.status !== \"succeeded\")\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"plugin install failed ({code}) for {pluginId}\", {\n\t\t\t\t\t\t\tcode: installed.error.code,\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\tconst activated = await active.installer.activate({\n\t\t\t\t\tinstallation: installed.installation,\n\t\t\t\t\trecord: verified.record,\n\t\t\t\t\tscope: \"global\",\n\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t\t});\n\t\t\t\tif (activated.status !== \"succeeded\") {\n\t\t\t\t\tawait active.installer\n\t\t\t\t\t\t.remove({\n\t\t\t\t\t\t\tinstallation: installed.installation,\n\t\t\t\t\t\t\tscope: \"global\",\n\t\t\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch(() => undefined);\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"plugin activation failed ({code}) for {pluginId}\", {\n\t\t\t\t\t\t\tcode: activated.error.code,\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst persisted = await active.stateStore.upsert({\n\t\t\t\t\tinstallation: activated.installation,\n\t\t\t\t\tscope: \"global\",\n\t\t\t\t\tenabled: true,\n\t\t\t\t\tsource: acquired.source,\n\t\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t\t});\n\t\t\t\tif (persisted.status !== \"ok\") {\n\t\t\t\t\tawait active.installer\n\t\t\t\t\t\t.remove({\n\t\t\t\t\t\t\tinstallation: activated.installation,\n\t\t\t\t\t\t\tscope: \"global\",\n\t\t\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch(() => undefined);\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"plugin state persist failed ({status}) for {pluginId}\", {\n\t\t\t\t\t\t\tstatus: persisted.status,\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn { pluginVersion: activated.installation.pluginVersion, source: acquired.source };\n\t\t\t} finally {\n\t\t\t\tawait release();\n\t\t\t}\n\t\t},\n\t\t...(options.signal === undefined ? {} : { signal: options.signal }),\n\t};\n\ttry {\n\t\treturn await runPluginBootstrapV1({\n\t\t\tmanifest: options.manifest ?? BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1,\n\t\t\tdeps,\n\t\t});\n\t} finally {\n\t\tconst active = session;\n\t\tsession = undefined;\n\t\tif (active !== undefined) {\n\t\t\tawait active.installHost.close().catch(() => undefined);\n\t\t\tawait active.acquisition.close().catch(() => undefined);\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"node-plugin-bootstrap.d.ts","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-plugin-bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AASrF,OAAO,EAGN,KAAK,sBAAsB,EAC3B,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,uBAAuB,EAAwB,MAAM,uBAAuB,CAAC;AAGvH,6EAA6E;AAC7E,eAAO,MAAM,mCAAmC,iCAAiC,CAAC;AAKlF,MAAM,WAAW,4BAA4B;IAC5C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,6BAA6B,EAAE,CAAC;IAC7D,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,sBAAsB,CAAC;IACzC,iDAAiD;IACjD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,sFAAsF;IACtF,QAAQ,CAAC,IAAI,CAAC,EAAE,qBAAqB,CAAC;IACtC,0EAA0E;IAC1E,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACrD;AAED,MAAM,MAAM,2BAA2B,GAAG,uBAAuB,GAAG;IACnE;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CAC1C,CAAC;AAqCF;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC7C,OAAO,EAAE,4BAA4B,GACnC,OAAO,CAAC,2BAA2B,CAAC,CA4LtC","sourcesContent":["/**\n * Node wiring for the startup plugin bootstrap (design\n * `插件独立分发与启动装配设计.md` §4.4, §0.7).\n *\n * `AGENT_FORGE_PLUGIN_BOOTSTRAP=off` skips everything, including the local\n * comparison. The comparison dependency reads the global and project\n * plugin-state.json stores only — read-only, and it never constructs an HTTP\n * client, so an assembled environment starts offline (G3). Network objects\n * (npm acquisition host, install host) are built lazily inside the install\n * action and closed when the bootstrap finishes. Installs go through the\n * npm acquisition path exclusively and persist the `npm:<host>` source label\n * in the global plugin state (same prepare/install/activate/upsert\n * transaction shape as the CLI install flow, implemented as a library\n * function without going through the CLI layer).\n */\n\nimport { join } from \"node:path\";\nimport { CONFIG_DIR_NAME } from \"../../config.ts\";\nimport { t } from \"../../core/i18n/index.ts\";\nimport { isOfflineModeEnabled } from \"../../core/package-process-runner.ts\";\nimport type { PluginBootstrapFactoryEntryV1 } from \"./bootstrap-factory-manifest.ts\";\nimport { BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1 } from \"./bootstrap-factory-manifest.ts\";\nimport {\n\tDEFAULT_PLUGIN_STATE_FILE_V1,\n\tdefaultPluginHostFactsV1,\n\tdefaultPluginInstallStoreDirectoryV1,\n\tprojectPluginScopeRefV1,\n} from \"./default-active-bindings.ts\";\nimport { createPluginInstallerV1, DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1, type PluginInstallerV1 } from \"./installer.ts\";\nimport {\n\tcreateNodePackageInstallHostV1,\n\ttype NodePackageInstallHostV1,\n\ttype NodeZipPackageLimitsV1,\n} from \"./node-package-install-host.ts\";\nimport { createNodePluginAcquisitionHostV1, type NodePluginAcquisitionHostV1 } from \"./node-plugin-acquisition-host.ts\";\nimport { type PluginBootstrapDepsV1, type PluginBootstrapResultV1, runPluginBootstrapV1 } from \"./plugin-bootstrap.ts\";\nimport { createPluginStateStoreV1, type PluginStateStoreV1 } from \"./state.ts\";\n\n/** Environment variable disabling the startup bootstrap entirely (`off`). */\nexport const AGENT_FORGE_PLUGIN_BOOTSTRAP_ENV_V1 = \"AGENT_FORGE_PLUGIN_BOOTSTRAP\";\n\n/** The only recognized disabling value; every other value (and absence) keeps bootstrap on. */\nconst PLUGIN_BOOTSTRAP_DISABLED_VALUE_V1 = \"off\";\n\nexport interface NodePluginBootstrapOptionsV1 {\n\treadonly agentDir: string;\n\treadonly cwd: string;\n\t/** Defaults to the frozen factory manifest. */\n\treadonly manifest?: readonly PluginBootstrapFactoryEntryV1[];\n\t/** Bare http(s) npm registry origin; forwarded to the acquisition host. */\n\treadonly npmRegistry?: string;\n\t/** npm registry bearer token; forwarded to the acquisition host. */\n\treadonly npmToken?: string;\n\treadonly limits?: NodeZipPackageLimitsV1;\n\t/** Deterministic fetch replacement for tests. */\n\treadonly fetch?: typeof globalThis.fetch;\n\treadonly signal?: AbortSignal;\n\t/** Full dependency override for deterministic tests; the env switch still applies. */\n\treadonly deps?: PluginBootstrapDepsV1;\n\t/** Overrides the first-run progress line (stderr) for tests and hosts. */\n\treadonly onPendingInstalls?: (count: number) => void;\n}\n\nexport type NodePluginBootstrapResultV1 = PluginBootstrapResultV1 & {\n\t/**\n\t * Present when a posture switch short-circuited the run before any local\n\t * comparison: the wiring-level env off switch, or the offline posture\n\t * (设计 §4.4 offline 姿态门, 2026-10-03 — offline installs cannot succeed\n\t * and would only fail slowly, so the run is skipped immediately).\n\t */\n\treadonly skipped?: \"disabled\" | \"offline\";\n};\n\n/** Install-scoped boundaries; created lazily by the first install action. */\ninterface InstallSessionV1 {\n\treadonly acquisition: NodePluginAcquisitionHostV1;\n\treadonly installHost: NodePackageInstallHostV1;\n\treadonly installer: PluginInstallerV1;\n\treadonly stateStore: PluginStateStoreV1;\n}\n\nfunction readActiveVersions(\n\tstore: PluginStateStoreV1,\n\tscope: \"global\" | \"project\",\n\tscopeRef: string,\n\tsignal: AbortSignal | undefined,\n): Promise<ReadonlyMap<string, string>> {\n\treturn (async () => {\n\t\tconst result = await store.read({ ...(signal === undefined ? {} : { signal }) });\n\t\tif (result.status !== \"ok\" && result.status !== \"missing\")\n\t\t\tthrow new Error(\n\t\t\t\tt(\"plugin state read failed ({detail}) for the {scope} scope\", {\n\t\t\t\t\tdetail: result.diagnostics[0]?.code ?? result.status,\n\t\t\t\t\tscope,\n\t\t\t\t}),\n\t\t\t);\n\t\tconst versions = new Map<string, string>();\n\t\tfor (const record of result.snapshot.records) {\n\t\t\tif (record.state.scope !== scope || record.state.scopeRef !== scopeRef) continue;\n\t\t\t// Enabled is deliberately not filtered: a disabled plugin still owns\n\t\t\t// its active installation record, and bootstrap never touches it (G5).\n\t\t\tif (record.state.lifecycle !== \"active\") continue;\n\t\t\tversions.set(record.pluginId, record.pluginVersion);\n\t\t}\n\t\treturn versions;\n\t})();\n}\n\n/**\n * Run the startup bootstrap for one agent directory. The function resolves\n * with a structured result and never throws for per-plugin failures; only a\n * wiring-level construction error propagates to the caller (main.ts guards\n * startup with its own catch).\n */\nexport async function runNodePluginBootstrapV1(\n\toptions: NodePluginBootstrapOptionsV1,\n): Promise<NodePluginBootstrapResultV1> {\n\tif (process.env[AGENT_FORGE_PLUGIN_BOOTSTRAP_ENV_V1]?.trim() === PLUGIN_BOOTSTRAP_DISABLED_VALUE_V1) {\n\t\treturn Object.freeze({\n\t\t\tversion: 1,\n\t\t\tstatus: \"succeeded\",\n\t\t\tactions: Object.freeze([]),\n\t\t\tdiagnostics: Object.freeze([]),\n\t\t\tdurationMs: 0,\n\t\t\tskipped: \"disabled\",\n\t\t});\n\t}\n\tif (isOfflineModeEnabled()) {\n\t\treturn Object.freeze({\n\t\t\tversion: 1,\n\t\t\tstatus: \"succeeded\",\n\t\t\tactions: Object.freeze([]),\n\t\t\tdiagnostics: Object.freeze([\n\t\t\t\t{\n\t\t\t\t\tcode: \"bootstrap_skipped_offline\",\n\t\t\t\t\tmessage: t(\n\t\t\t\t\t\t\"Offline posture (AGENT_FORGE_OFFLINE) skips the startup plugin bootstrap; run `agent-forge plugin install <package>` explicitly to install plugins.\",\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t] as const),\n\t\t\tdurationMs: 0,\n\t\t\tskipped: \"offline\",\n\t\t});\n\t}\n\tif (options.deps !== undefined) {\n\t\treturn await runPluginBootstrapV1({\n\t\t\tmanifest: options.manifest ?? BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1,\n\t\t\tdeps: options.deps,\n\t\t\t...(options.onPendingInstalls === undefined ? {} : { onPendingInstalls: options.onPendingInstalls }),\n\t\t});\n\t}\n\tlet session: InstallSessionV1 | undefined;\n\tconst ensureSession = async (): Promise<InstallSessionV1> => {\n\t\tif (session !== undefined) return session;\n\t\tconst acquisition = createNodePluginAcquisitionHostV1({\n\t\t\t...(options.npmRegistry === undefined ? {} : { npmRegistry: options.npmRegistry }),\n\t\t\t...(options.npmToken === undefined ? {} : { npmToken: options.npmToken }),\n\t\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t\t...(options.limits === undefined ? {} : { limits: options.limits }),\n\t\t});\n\t\tconst installHost = await createNodePackageInstallHostV1({\n\t\t\topenArtifact: (input) => acquisition.openArtifact(input),\n\t\t\tinstallationDirectory: defaultPluginInstallStoreDirectoryV1(options.agentDir),\n\t\t\tpersistence: \"persistent\",\n\t\t\tsupportedScopes: [\"global\", \"project\"],\n\t\t\t...(options.limits === undefined ? {} : { ...options.limits }),\n\t\t});\n\t\tsession = {\n\t\t\tacquisition,\n\t\t\tinstallHost,\n\t\t\tinstaller: createPluginInstallerV1({ host: installHost }),\n\t\t\tstateStore: createPluginStateStoreV1({ filePath: join(options.agentDir, DEFAULT_PLUGIN_STATE_FILE_V1) }),\n\t\t};\n\t\treturn session;\n\t};\n\tconst deps: PluginBootstrapDepsV1 = {\n\t\tlistActive: async ({ signal }) => {\n\t\t\tconst globalVersions = readActiveVersions(\n\t\t\t\tcreatePluginStateStoreV1({ filePath: join(options.agentDir, DEFAULT_PLUGIN_STATE_FILE_V1) }),\n\t\t\t\t\"global\",\n\t\t\t\tDEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\tsignal,\n\t\t\t);\n\t\t\tconst projectVersions = readActiveVersions(\n\t\t\t\tcreatePluginStateStoreV1({ filePath: join(options.cwd, CONFIG_DIR_NAME, DEFAULT_PLUGIN_STATE_FILE_V1) }),\n\t\t\t\t\"project\",\n\t\t\t\tprojectPluginScopeRefV1(options.cwd),\n\t\t\t\tsignal,\n\t\t\t);\n\t\t\tconst [globalResult, projectResult] = await Promise.all([globalVersions, projectVersions]);\n\t\t\t// Project precedence mirrors active-binding resolution: a project\n\t\t\t// installation shadows the same plugin id from the global scope.\n\t\t\treturn new Map([...globalResult, ...projectResult]);\n\t\t},\n\t\tinstallFromNpm: async ({ npmName, range, signal }) => {\n\t\t\tconst active = await ensureSession();\n\t\t\t// npm refs only (§0.7): scoped or plain names with the shared minimal\n\t\t\t// range subset; no github/gitee/url/local ref can be expressed here.\n\t\t\tconst ref = range === undefined ? npmName : `${npmName}@${range}`;\n\t\t\tconst acquired = await active.acquisition.resolvePackage({ ref, ...(signal === undefined ? {} : { signal }) });\n\t\t\tlet released = false;\n\t\t\tconst release = async (): Promise<void> => {\n\t\t\t\tif (released) return;\n\t\t\t\treleased = true;\n\t\t\t\tawait acquired.release();\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tconst verified = active.installer.prepare({\n\t\t\t\t\tmanifest: acquired.manifest,\n\t\t\t\t\tsource: acquired.source,\n\t\t\t\t\thost: defaultPluginHostFactsV1(),\n\t\t\t\t});\n\t\t\t\tif (verified.status !== \"verified\")\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"installer prepare rejected {pluginId}: {reason}\", {\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t\treason: verified.reason,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\tconst installed = await active.installer.install({\n\t\t\t\t\trecord: verified.record,\n\t\t\t\t\tscope: \"global\",\n\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\tartifact: acquired.artifact,\n\t\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t\t});\n\t\t\t\tif (installed.status !== \"succeeded\")\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"plugin install failed ({code}) for {pluginId}\", {\n\t\t\t\t\t\t\tcode: installed.error.code,\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\tconst activated = await active.installer.activate({\n\t\t\t\t\tinstallation: installed.installation,\n\t\t\t\t\trecord: verified.record,\n\t\t\t\t\tscope: \"global\",\n\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t\t});\n\t\t\t\tif (activated.status !== \"succeeded\") {\n\t\t\t\t\tawait active.installer\n\t\t\t\t\t\t.remove({\n\t\t\t\t\t\t\tinstallation: installed.installation,\n\t\t\t\t\t\t\tscope: \"global\",\n\t\t\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch(() => undefined);\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"plugin activation failed ({code}) for {pluginId}\", {\n\t\t\t\t\t\t\tcode: activated.error.code,\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst persisted = await active.stateStore.upsert({\n\t\t\t\t\tinstallation: activated.installation,\n\t\t\t\t\tscope: \"global\",\n\t\t\t\t\tenabled: true,\n\t\t\t\t\tsource: acquired.source,\n\t\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t\t});\n\t\t\t\tif (persisted.status !== \"ok\") {\n\t\t\t\t\tawait active.installer\n\t\t\t\t\t\t.remove({\n\t\t\t\t\t\t\tinstallation: activated.installation,\n\t\t\t\t\t\t\tscope: \"global\",\n\t\t\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch(() => undefined);\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"plugin state persist failed ({status}) for {pluginId}\", {\n\t\t\t\t\t\t\tstatus: persisted.status,\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn { pluginVersion: activated.installation.pluginVersion, source: acquired.source };\n\t\t\t} finally {\n\t\t\t\tawait release();\n\t\t\t}\n\t\t},\n\t\t...(options.signal === undefined ? {} : { signal: options.signal }),\n\t};\n\ttry {\n\t\treturn await runPluginBootstrapV1({\n\t\t\tmanifest: options.manifest ?? BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1,\n\t\t\tdeps,\n\t\t\t// First-run progress line (设计 §4.4, 2026-10-03): a fresh install is\n\t\t\t// otherwise silent for the whole network install window.\n\t\t\tonPendingInstalls:\n\t\t\t\toptions.onPendingInstalls ??\n\t\t\t\t((count: number) => {\n\t\t\t\t\tconsole.error(t(\"First run: installing {count} factory plugins…\", { count }));\n\t\t\t\t}),\n\t\t});\n\t} finally {\n\t\tconst active = session;\n\t\tsession = undefined;\n\t\tif (active !== undefined) {\n\t\t\tawait active.installHost.close().catch(() => undefined);\n\t\t\tawait active.acquisition.close().catch(() => undefined);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import { join } from "node:path";
|
|
17
17
|
import { CONFIG_DIR_NAME } from "../../config.js";
|
|
18
18
|
import { t } from "../../core/i18n/index.js";
|
|
19
|
+
import { isOfflineModeEnabled } from "../../core/package-process-runner.js";
|
|
19
20
|
import { BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1 } from "./bootstrap-factory-manifest.js";
|
|
20
21
|
import { DEFAULT_PLUGIN_STATE_FILE_V1, defaultPluginHostFactsV1, defaultPluginInstallStoreDirectoryV1, projectPluginScopeRefV1, } from "./default-active-bindings.js";
|
|
21
22
|
import { createPluginInstallerV1, DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1 } from "./installer.js";
|
|
@@ -65,10 +66,26 @@ export async function runNodePluginBootstrapV1(options) {
|
|
|
65
66
|
skipped: "disabled",
|
|
66
67
|
});
|
|
67
68
|
}
|
|
69
|
+
if (isOfflineModeEnabled()) {
|
|
70
|
+
return Object.freeze({
|
|
71
|
+
version: 1,
|
|
72
|
+
status: "succeeded",
|
|
73
|
+
actions: Object.freeze([]),
|
|
74
|
+
diagnostics: Object.freeze([
|
|
75
|
+
{
|
|
76
|
+
code: "bootstrap_skipped_offline",
|
|
77
|
+
message: t("Offline posture (AGENT_FORGE_OFFLINE) skips the startup plugin bootstrap; run `agent-forge plugin install <package>` explicitly to install plugins."),
|
|
78
|
+
},
|
|
79
|
+
]),
|
|
80
|
+
durationMs: 0,
|
|
81
|
+
skipped: "offline",
|
|
82
|
+
});
|
|
83
|
+
}
|
|
68
84
|
if (options.deps !== undefined) {
|
|
69
85
|
return await runPluginBootstrapV1({
|
|
70
86
|
manifest: options.manifest ?? BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1,
|
|
71
87
|
deps: options.deps,
|
|
88
|
+
...(options.onPendingInstalls === undefined ? {} : { onPendingInstalls: options.onPendingInstalls }),
|
|
72
89
|
});
|
|
73
90
|
}
|
|
74
91
|
let session;
|
|
@@ -193,6 +210,12 @@ export async function runNodePluginBootstrapV1(options) {
|
|
|
193
210
|
return await runPluginBootstrapV1({
|
|
194
211
|
manifest: options.manifest ?? BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1,
|
|
195
212
|
deps,
|
|
213
|
+
// First-run progress line (设计 §4.4, 2026-10-03): a fresh install is
|
|
214
|
+
// otherwise silent for the whole network install window.
|
|
215
|
+
onPendingInstalls: options.onPendingInstalls ??
|
|
216
|
+
((count) => {
|
|
217
|
+
console.error(t("First run: installing {count} factory plugins…", { count }));
|
|
218
|
+
}),
|
|
196
219
|
});
|
|
197
220
|
}
|
|
198
221
|
finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-plugin-bootstrap.js","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-plugin-bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,0BAA0B,CAAC;AAE7C,OAAO,EAAE,oCAAoC,EAAE,MAAM,iCAAiC,CAAC;AACvF,OAAO,EACN,4BAA4B,EAC5B,wBAAwB,EACxB,oCAAoC,EACpC,uBAAuB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,uBAAuB,EAAE,kCAAkC,EAA0B,MAAM,gBAAgB,CAAC;AACrH,OAAO,EACN,8BAA8B,GAG9B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,iCAAiC,EAAoC,MAAM,mCAAmC,CAAC;AACxH,OAAO,EAA4D,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACvH,OAAO,EAAE,wBAAwB,EAA2B,MAAM,YAAY,CAAC;AAE/E,6EAA6E;AAC7E,MAAM,CAAC,MAAM,mCAAmC,GAAG,8BAA8B,CAAC;AAElF,+FAA+F;AAC/F,MAAM,kCAAkC,GAAG,KAAK,CAAC;AAgCjD,SAAS,kBAAkB,CAC1B,KAAyB,EACzB,KAA2B,EAC3B,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E,CAAC;IACF,IAAI,CAAC;QACJ,OAAO,MAAM,oBAAoB,CAAC;YACjC,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,oCAAoC;YAClE,IAAI;SACJ,CAAC,CAAC;IACJ,CAAC;YAAS,CAAC;QACV,MAAM,MAAM,GAAG,OAAO,CAAC;QACvB,OAAO,GAAG,SAAS,CAAC;QACpB,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YACxD,MAAM,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACzD,CAAC;IACF,CAAC;AAAA,CACD","sourcesContent":["/**\n * Node wiring for the startup plugin bootstrap (design\n * `插件独立分发与启动装配设计.md` §4.4, §0.7).\n *\n * `AGENT_FORGE_PLUGIN_BOOTSTRAP=off` skips everything, including the local\n * comparison. The comparison dependency reads the global and project\n * plugin-state.json stores only — read-only, and it never constructs an HTTP\n * client, so an assembled environment starts offline (G3). Network objects\n * (npm acquisition host, install host) are built lazily inside the install\n * action and closed when the bootstrap finishes. Installs go through the\n * npm acquisition path exclusively and persist the `npm:<host>` source label\n * in the global plugin state (same prepare/install/activate/upsert\n * transaction shape as the CLI install flow, implemented as a library\n * function without going through the CLI layer).\n */\n\nimport { join } from \"node:path\";\nimport { CONFIG_DIR_NAME } from \"../../config.ts\";\nimport { t } from \"../../core/i18n/index.ts\";\nimport type { PluginBootstrapFactoryEntryV1 } from \"./bootstrap-factory-manifest.ts\";\nimport { BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1 } from \"./bootstrap-factory-manifest.ts\";\nimport {\n\tDEFAULT_PLUGIN_STATE_FILE_V1,\n\tdefaultPluginHostFactsV1,\n\tdefaultPluginInstallStoreDirectoryV1,\n\tprojectPluginScopeRefV1,\n} from \"./default-active-bindings.ts\";\nimport { createPluginInstallerV1, DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1, type PluginInstallerV1 } from \"./installer.ts\";\nimport {\n\tcreateNodePackageInstallHostV1,\n\ttype NodePackageInstallHostV1,\n\ttype NodeZipPackageLimitsV1,\n} from \"./node-package-install-host.ts\";\nimport { createNodePluginAcquisitionHostV1, type NodePluginAcquisitionHostV1 } from \"./node-plugin-acquisition-host.ts\";\nimport { type PluginBootstrapDepsV1, type PluginBootstrapResultV1, runPluginBootstrapV1 } from \"./plugin-bootstrap.ts\";\nimport { createPluginStateStoreV1, type PluginStateStoreV1 } from \"./state.ts\";\n\n/** Environment variable disabling the startup bootstrap entirely (`off`). */\nexport const AGENT_FORGE_PLUGIN_BOOTSTRAP_ENV_V1 = \"AGENT_FORGE_PLUGIN_BOOTSTRAP\";\n\n/** The only recognized disabling value; every other value (and absence) keeps bootstrap on. */\nconst PLUGIN_BOOTSTRAP_DISABLED_VALUE_V1 = \"off\";\n\nexport interface NodePluginBootstrapOptionsV1 {\n\treadonly agentDir: string;\n\treadonly cwd: string;\n\t/** Defaults to the frozen factory manifest. */\n\treadonly manifest?: readonly PluginBootstrapFactoryEntryV1[];\n\t/** Bare http(s) npm registry origin; forwarded to the acquisition host. */\n\treadonly npmRegistry?: string;\n\t/** npm registry bearer token; forwarded to the acquisition host. */\n\treadonly npmToken?: string;\n\treadonly limits?: NodeZipPackageLimitsV1;\n\t/** Deterministic fetch replacement for tests. */\n\treadonly fetch?: typeof globalThis.fetch;\n\treadonly signal?: AbortSignal;\n\t/** Full dependency override for deterministic tests; the env switch still applies. */\n\treadonly deps?: PluginBootstrapDepsV1;\n}\n\nexport type NodePluginBootstrapResultV1 = PluginBootstrapResultV1 & {\n\t/** Present when the env switch short-circuited the run before any local comparison. */\n\treadonly skipped?: \"disabled\";\n};\n\n/** Install-scoped boundaries; created lazily by the first install action. */\ninterface InstallSessionV1 {\n\treadonly acquisition: NodePluginAcquisitionHostV1;\n\treadonly installHost: NodePackageInstallHostV1;\n\treadonly installer: PluginInstallerV1;\n\treadonly stateStore: PluginStateStoreV1;\n}\n\nfunction readActiveVersions(\n\tstore: PluginStateStoreV1,\n\tscope: \"global\" | \"project\",\n\tscopeRef: string,\n\tsignal: AbortSignal | undefined,\n): Promise<ReadonlyMap<string, string>> {\n\treturn (async () => {\n\t\tconst result = await store.read({ ...(signal === undefined ? {} : { signal }) });\n\t\tif (result.status !== \"ok\" && result.status !== \"missing\")\n\t\t\tthrow new Error(\n\t\t\t\tt(\"plugin state read failed ({detail}) for the {scope} scope\", {\n\t\t\t\t\tdetail: result.diagnostics[0]?.code ?? result.status,\n\t\t\t\t\tscope,\n\t\t\t\t}),\n\t\t\t);\n\t\tconst versions = new Map<string, string>();\n\t\tfor (const record of result.snapshot.records) {\n\t\t\tif (record.state.scope !== scope || record.state.scopeRef !== scopeRef) continue;\n\t\t\t// Enabled is deliberately not filtered: a disabled plugin still owns\n\t\t\t// its active installation record, and bootstrap never touches it (G5).\n\t\t\tif (record.state.lifecycle !== \"active\") continue;\n\t\t\tversions.set(record.pluginId, record.pluginVersion);\n\t\t}\n\t\treturn versions;\n\t})();\n}\n\n/**\n * Run the startup bootstrap for one agent directory. The function resolves\n * with a structured result and never throws for per-plugin failures; only a\n * wiring-level construction error propagates to the caller (main.ts guards\n * startup with its own catch).\n */\nexport async function runNodePluginBootstrapV1(\n\toptions: NodePluginBootstrapOptionsV1,\n): Promise<NodePluginBootstrapResultV1> {\n\tif (process.env[AGENT_FORGE_PLUGIN_BOOTSTRAP_ENV_V1]?.trim() === PLUGIN_BOOTSTRAP_DISABLED_VALUE_V1) {\n\t\treturn Object.freeze({\n\t\t\tversion: 1,\n\t\t\tstatus: \"succeeded\",\n\t\t\tactions: Object.freeze([]),\n\t\t\tdiagnostics: Object.freeze([]),\n\t\t\tdurationMs: 0,\n\t\t\tskipped: \"disabled\",\n\t\t});\n\t}\n\tif (options.deps !== undefined) {\n\t\treturn await runPluginBootstrapV1({\n\t\t\tmanifest: options.manifest ?? BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1,\n\t\t\tdeps: options.deps,\n\t\t});\n\t}\n\tlet session: InstallSessionV1 | undefined;\n\tconst ensureSession = async (): Promise<InstallSessionV1> => {\n\t\tif (session !== undefined) return session;\n\t\tconst acquisition = createNodePluginAcquisitionHostV1({\n\t\t\t...(options.npmRegistry === undefined ? {} : { npmRegistry: options.npmRegistry }),\n\t\t\t...(options.npmToken === undefined ? {} : { npmToken: options.npmToken }),\n\t\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t\t...(options.limits === undefined ? {} : { limits: options.limits }),\n\t\t});\n\t\tconst installHost = await createNodePackageInstallHostV1({\n\t\t\topenArtifact: (input) => acquisition.openArtifact(input),\n\t\t\tinstallationDirectory: defaultPluginInstallStoreDirectoryV1(options.agentDir),\n\t\t\tpersistence: \"persistent\",\n\t\t\tsupportedScopes: [\"global\", \"project\"],\n\t\t\t...(options.limits === undefined ? {} : { ...options.limits }),\n\t\t});\n\t\tsession = {\n\t\t\tacquisition,\n\t\t\tinstallHost,\n\t\t\tinstaller: createPluginInstallerV1({ host: installHost }),\n\t\t\tstateStore: createPluginStateStoreV1({ filePath: join(options.agentDir, DEFAULT_PLUGIN_STATE_FILE_V1) }),\n\t\t};\n\t\treturn session;\n\t};\n\tconst deps: PluginBootstrapDepsV1 = {\n\t\tlistActive: async ({ signal }) => {\n\t\t\tconst globalVersions = readActiveVersions(\n\t\t\t\tcreatePluginStateStoreV1({ filePath: join(options.agentDir, DEFAULT_PLUGIN_STATE_FILE_V1) }),\n\t\t\t\t\"global\",\n\t\t\t\tDEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\tsignal,\n\t\t\t);\n\t\t\tconst projectVersions = readActiveVersions(\n\t\t\t\tcreatePluginStateStoreV1({ filePath: join(options.cwd, CONFIG_DIR_NAME, DEFAULT_PLUGIN_STATE_FILE_V1) }),\n\t\t\t\t\"project\",\n\t\t\t\tprojectPluginScopeRefV1(options.cwd),\n\t\t\t\tsignal,\n\t\t\t);\n\t\t\tconst [globalResult, projectResult] = await Promise.all([globalVersions, projectVersions]);\n\t\t\t// Project precedence mirrors active-binding resolution: a project\n\t\t\t// installation shadows the same plugin id from the global scope.\n\t\t\treturn new Map([...globalResult, ...projectResult]);\n\t\t},\n\t\tinstallFromNpm: async ({ npmName, range, signal }) => {\n\t\t\tconst active = await ensureSession();\n\t\t\t// npm refs only (§0.7): scoped or plain names with the shared minimal\n\t\t\t// range subset; no github/gitee/url/local ref can be expressed here.\n\t\t\tconst ref = range === undefined ? npmName : `${npmName}@${range}`;\n\t\t\tconst acquired = await active.acquisition.resolvePackage({ ref, ...(signal === undefined ? {} : { signal }) });\n\t\t\tlet released = false;\n\t\t\tconst release = async (): Promise<void> => {\n\t\t\t\tif (released) return;\n\t\t\t\treleased = true;\n\t\t\t\tawait acquired.release();\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tconst verified = active.installer.prepare({\n\t\t\t\t\tmanifest: acquired.manifest,\n\t\t\t\t\tsource: acquired.source,\n\t\t\t\t\thost: defaultPluginHostFactsV1(),\n\t\t\t\t});\n\t\t\t\tif (verified.status !== \"verified\")\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"installer prepare rejected {pluginId}: {reason}\", {\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t\treason: verified.reason,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\tconst installed = await active.installer.install({\n\t\t\t\t\trecord: verified.record,\n\t\t\t\t\tscope: \"global\",\n\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\tartifact: acquired.artifact,\n\t\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t\t});\n\t\t\t\tif (installed.status !== \"succeeded\")\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"plugin install failed ({code}) for {pluginId}\", {\n\t\t\t\t\t\t\tcode: installed.error.code,\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\tconst activated = await active.installer.activate({\n\t\t\t\t\tinstallation: installed.installation,\n\t\t\t\t\trecord: verified.record,\n\t\t\t\t\tscope: \"global\",\n\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t\t});\n\t\t\t\tif (activated.status !== \"succeeded\") {\n\t\t\t\t\tawait active.installer\n\t\t\t\t\t\t.remove({\n\t\t\t\t\t\t\tinstallation: installed.installation,\n\t\t\t\t\t\t\tscope: \"global\",\n\t\t\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch(() => undefined);\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"plugin activation failed ({code}) for {pluginId}\", {\n\t\t\t\t\t\t\tcode: activated.error.code,\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst persisted = await active.stateStore.upsert({\n\t\t\t\t\tinstallation: activated.installation,\n\t\t\t\t\tscope: \"global\",\n\t\t\t\t\tenabled: true,\n\t\t\t\t\tsource: acquired.source,\n\t\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t\t});\n\t\t\t\tif (persisted.status !== \"ok\") {\n\t\t\t\t\tawait active.installer\n\t\t\t\t\t\t.remove({\n\t\t\t\t\t\t\tinstallation: activated.installation,\n\t\t\t\t\t\t\tscope: \"global\",\n\t\t\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch(() => undefined);\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"plugin state persist failed ({status}) for {pluginId}\", {\n\t\t\t\t\t\t\tstatus: persisted.status,\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn { pluginVersion: activated.installation.pluginVersion, source: acquired.source };\n\t\t\t} finally {\n\t\t\t\tawait release();\n\t\t\t}\n\t\t},\n\t\t...(options.signal === undefined ? {} : { signal: options.signal }),\n\t};\n\ttry {\n\t\treturn await runPluginBootstrapV1({\n\t\t\tmanifest: options.manifest ?? BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1,\n\t\t\tdeps,\n\t\t});\n\t} finally {\n\t\tconst active = session;\n\t\tsession = undefined;\n\t\tif (active !== undefined) {\n\t\t\tawait active.installHost.close().catch(() => undefined);\n\t\t\tawait active.acquisition.close().catch(() => undefined);\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"node-plugin-bootstrap.js","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-plugin-bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,0BAA0B,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAE5E,OAAO,EAAE,oCAAoC,EAAE,MAAM,iCAAiC,CAAC;AACvF,OAAO,EACN,4BAA4B,EAC5B,wBAAwB,EACxB,oCAAoC,EACpC,uBAAuB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,uBAAuB,EAAE,kCAAkC,EAA0B,MAAM,gBAAgB,CAAC;AACrH,OAAO,EACN,8BAA8B,GAG9B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,iCAAiC,EAAoC,MAAM,mCAAmC,CAAC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AAM,GAAG,OAAO,CAAC;QACvB,OAAO,GAAG,SAAS,CAAC;QACpB,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YACxD,MAAM,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACzD,CAAC;IACF,CAAC;AAAA,CACD","sourcesContent":["/**\n * Node wiring for the startup plugin bootstrap (design\n * `插件独立分发与启动装配设计.md` §4.4, §0.7).\n *\n * `AGENT_FORGE_PLUGIN_BOOTSTRAP=off` skips everything, including the local\n * comparison. The comparison dependency reads the global and project\n * plugin-state.json stores only — read-only, and it never constructs an HTTP\n * client, so an assembled environment starts offline (G3). Network objects\n * (npm acquisition host, install host) are built lazily inside the install\n * action and closed when the bootstrap finishes. Installs go through the\n * npm acquisition path exclusively and persist the `npm:<host>` source label\n * in the global plugin state (same prepare/install/activate/upsert\n * transaction shape as the CLI install flow, implemented as a library\n * function without going through the CLI layer).\n */\n\nimport { join } from \"node:path\";\nimport { CONFIG_DIR_NAME } from \"../../config.ts\";\nimport { t } from \"../../core/i18n/index.ts\";\nimport { isOfflineModeEnabled } from \"../../core/package-process-runner.ts\";\nimport type { PluginBootstrapFactoryEntryV1 } from \"./bootstrap-factory-manifest.ts\";\nimport { BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1 } from \"./bootstrap-factory-manifest.ts\";\nimport {\n\tDEFAULT_PLUGIN_STATE_FILE_V1,\n\tdefaultPluginHostFactsV1,\n\tdefaultPluginInstallStoreDirectoryV1,\n\tprojectPluginScopeRefV1,\n} from \"./default-active-bindings.ts\";\nimport { createPluginInstallerV1, DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1, type PluginInstallerV1 } from \"./installer.ts\";\nimport {\n\tcreateNodePackageInstallHostV1,\n\ttype NodePackageInstallHostV1,\n\ttype NodeZipPackageLimitsV1,\n} from \"./node-package-install-host.ts\";\nimport { createNodePluginAcquisitionHostV1, type NodePluginAcquisitionHostV1 } from \"./node-plugin-acquisition-host.ts\";\nimport { type PluginBootstrapDepsV1, type PluginBootstrapResultV1, runPluginBootstrapV1 } from \"./plugin-bootstrap.ts\";\nimport { createPluginStateStoreV1, type PluginStateStoreV1 } from \"./state.ts\";\n\n/** Environment variable disabling the startup bootstrap entirely (`off`). */\nexport const AGENT_FORGE_PLUGIN_BOOTSTRAP_ENV_V1 = \"AGENT_FORGE_PLUGIN_BOOTSTRAP\";\n\n/** The only recognized disabling value; every other value (and absence) keeps bootstrap on. */\nconst PLUGIN_BOOTSTRAP_DISABLED_VALUE_V1 = \"off\";\n\nexport interface NodePluginBootstrapOptionsV1 {\n\treadonly agentDir: string;\n\treadonly cwd: string;\n\t/** Defaults to the frozen factory manifest. */\n\treadonly manifest?: readonly PluginBootstrapFactoryEntryV1[];\n\t/** Bare http(s) npm registry origin; forwarded to the acquisition host. */\n\treadonly npmRegistry?: string;\n\t/** npm registry bearer token; forwarded to the acquisition host. */\n\treadonly npmToken?: string;\n\treadonly limits?: NodeZipPackageLimitsV1;\n\t/** Deterministic fetch replacement for tests. */\n\treadonly fetch?: typeof globalThis.fetch;\n\treadonly signal?: AbortSignal;\n\t/** Full dependency override for deterministic tests; the env switch still applies. */\n\treadonly deps?: PluginBootstrapDepsV1;\n\t/** Overrides the first-run progress line (stderr) for tests and hosts. */\n\treadonly onPendingInstalls?: (count: number) => void;\n}\n\nexport type NodePluginBootstrapResultV1 = PluginBootstrapResultV1 & {\n\t/**\n\t * Present when a posture switch short-circuited the run before any local\n\t * comparison: the wiring-level env off switch, or the offline posture\n\t * (设计 §4.4 offline 姿态门, 2026-10-03 — offline installs cannot succeed\n\t * and would only fail slowly, so the run is skipped immediately).\n\t */\n\treadonly skipped?: \"disabled\" | \"offline\";\n};\n\n/** Install-scoped boundaries; created lazily by the first install action. */\ninterface InstallSessionV1 {\n\treadonly acquisition: NodePluginAcquisitionHostV1;\n\treadonly installHost: NodePackageInstallHostV1;\n\treadonly installer: PluginInstallerV1;\n\treadonly stateStore: PluginStateStoreV1;\n}\n\nfunction readActiveVersions(\n\tstore: PluginStateStoreV1,\n\tscope: \"global\" | \"project\",\n\tscopeRef: string,\n\tsignal: AbortSignal | undefined,\n): Promise<ReadonlyMap<string, string>> {\n\treturn (async () => {\n\t\tconst result = await store.read({ ...(signal === undefined ? {} : { signal }) });\n\t\tif (result.status !== \"ok\" && result.status !== \"missing\")\n\t\t\tthrow new Error(\n\t\t\t\tt(\"plugin state read failed ({detail}) for the {scope} scope\", {\n\t\t\t\t\tdetail: result.diagnostics[0]?.code ?? result.status,\n\t\t\t\t\tscope,\n\t\t\t\t}),\n\t\t\t);\n\t\tconst versions = new Map<string, string>();\n\t\tfor (const record of result.snapshot.records) {\n\t\t\tif (record.state.scope !== scope || record.state.scopeRef !== scopeRef) continue;\n\t\t\t// Enabled is deliberately not filtered: a disabled plugin still owns\n\t\t\t// its active installation record, and bootstrap never touches it (G5).\n\t\t\tif (record.state.lifecycle !== \"active\") continue;\n\t\t\tversions.set(record.pluginId, record.pluginVersion);\n\t\t}\n\t\treturn versions;\n\t})();\n}\n\n/**\n * Run the startup bootstrap for one agent directory. The function resolves\n * with a structured result and never throws for per-plugin failures; only a\n * wiring-level construction error propagates to the caller (main.ts guards\n * startup with its own catch).\n */\nexport async function runNodePluginBootstrapV1(\n\toptions: NodePluginBootstrapOptionsV1,\n): Promise<NodePluginBootstrapResultV1> {\n\tif (process.env[AGENT_FORGE_PLUGIN_BOOTSTRAP_ENV_V1]?.trim() === PLUGIN_BOOTSTRAP_DISABLED_VALUE_V1) {\n\t\treturn Object.freeze({\n\t\t\tversion: 1,\n\t\t\tstatus: \"succeeded\",\n\t\t\tactions: Object.freeze([]),\n\t\t\tdiagnostics: Object.freeze([]),\n\t\t\tdurationMs: 0,\n\t\t\tskipped: \"disabled\",\n\t\t});\n\t}\n\tif (isOfflineModeEnabled()) {\n\t\treturn Object.freeze({\n\t\t\tversion: 1,\n\t\t\tstatus: \"succeeded\",\n\t\t\tactions: Object.freeze([]),\n\t\t\tdiagnostics: Object.freeze([\n\t\t\t\t{\n\t\t\t\t\tcode: \"bootstrap_skipped_offline\",\n\t\t\t\t\tmessage: t(\n\t\t\t\t\t\t\"Offline posture (AGENT_FORGE_OFFLINE) skips the startup plugin bootstrap; run `agent-forge plugin install <package>` explicitly to install plugins.\",\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t] as const),\n\t\t\tdurationMs: 0,\n\t\t\tskipped: \"offline\",\n\t\t});\n\t}\n\tif (options.deps !== undefined) {\n\t\treturn await runPluginBootstrapV1({\n\t\t\tmanifest: options.manifest ?? BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1,\n\t\t\tdeps: options.deps,\n\t\t\t...(options.onPendingInstalls === undefined ? {} : { onPendingInstalls: options.onPendingInstalls }),\n\t\t});\n\t}\n\tlet session: InstallSessionV1 | undefined;\n\tconst ensureSession = async (): Promise<InstallSessionV1> => {\n\t\tif (session !== undefined) return session;\n\t\tconst acquisition = createNodePluginAcquisitionHostV1({\n\t\t\t...(options.npmRegistry === undefined ? {} : { npmRegistry: options.npmRegistry }),\n\t\t\t...(options.npmToken === undefined ? {} : { npmToken: options.npmToken }),\n\t\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t\t...(options.limits === undefined ? {} : { limits: options.limits }),\n\t\t});\n\t\tconst installHost = await createNodePackageInstallHostV1({\n\t\t\topenArtifact: (input) => acquisition.openArtifact(input),\n\t\t\tinstallationDirectory: defaultPluginInstallStoreDirectoryV1(options.agentDir),\n\t\t\tpersistence: \"persistent\",\n\t\t\tsupportedScopes: [\"global\", \"project\"],\n\t\t\t...(options.limits === undefined ? {} : { ...options.limits }),\n\t\t});\n\t\tsession = {\n\t\t\tacquisition,\n\t\t\tinstallHost,\n\t\t\tinstaller: createPluginInstallerV1({ host: installHost }),\n\t\t\tstateStore: createPluginStateStoreV1({ filePath: join(options.agentDir, DEFAULT_PLUGIN_STATE_FILE_V1) }),\n\t\t};\n\t\treturn session;\n\t};\n\tconst deps: PluginBootstrapDepsV1 = {\n\t\tlistActive: async ({ signal }) => {\n\t\t\tconst globalVersions = readActiveVersions(\n\t\t\t\tcreatePluginStateStoreV1({ filePath: join(options.agentDir, DEFAULT_PLUGIN_STATE_FILE_V1) }),\n\t\t\t\t\"global\",\n\t\t\t\tDEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\tsignal,\n\t\t\t);\n\t\t\tconst projectVersions = readActiveVersions(\n\t\t\t\tcreatePluginStateStoreV1({ filePath: join(options.cwd, CONFIG_DIR_NAME, DEFAULT_PLUGIN_STATE_FILE_V1) }),\n\t\t\t\t\"project\",\n\t\t\t\tprojectPluginScopeRefV1(options.cwd),\n\t\t\t\tsignal,\n\t\t\t);\n\t\t\tconst [globalResult, projectResult] = await Promise.all([globalVersions, projectVersions]);\n\t\t\t// Project precedence mirrors active-binding resolution: a project\n\t\t\t// installation shadows the same plugin id from the global scope.\n\t\t\treturn new Map([...globalResult, ...projectResult]);\n\t\t},\n\t\tinstallFromNpm: async ({ npmName, range, signal }) => {\n\t\t\tconst active = await ensureSession();\n\t\t\t// npm refs only (§0.7): scoped or plain names with the shared minimal\n\t\t\t// range subset; no github/gitee/url/local ref can be expressed here.\n\t\t\tconst ref = range === undefined ? npmName : `${npmName}@${range}`;\n\t\t\tconst acquired = await active.acquisition.resolvePackage({ ref, ...(signal === undefined ? {} : { signal }) });\n\t\t\tlet released = false;\n\t\t\tconst release = async (): Promise<void> => {\n\t\t\t\tif (released) return;\n\t\t\t\treleased = true;\n\t\t\t\tawait acquired.release();\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tconst verified = active.installer.prepare({\n\t\t\t\t\tmanifest: acquired.manifest,\n\t\t\t\t\tsource: acquired.source,\n\t\t\t\t\thost: defaultPluginHostFactsV1(),\n\t\t\t\t});\n\t\t\t\tif (verified.status !== \"verified\")\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"installer prepare rejected {pluginId}: {reason}\", {\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t\treason: verified.reason,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\tconst installed = await active.installer.install({\n\t\t\t\t\trecord: verified.record,\n\t\t\t\t\tscope: \"global\",\n\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\tartifact: acquired.artifact,\n\t\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t\t});\n\t\t\t\tif (installed.status !== \"succeeded\")\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"plugin install failed ({code}) for {pluginId}\", {\n\t\t\t\t\t\t\tcode: installed.error.code,\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\tconst activated = await active.installer.activate({\n\t\t\t\t\tinstallation: installed.installation,\n\t\t\t\t\trecord: verified.record,\n\t\t\t\t\tscope: \"global\",\n\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t\t});\n\t\t\t\tif (activated.status !== \"succeeded\") {\n\t\t\t\t\tawait active.installer\n\t\t\t\t\t\t.remove({\n\t\t\t\t\t\t\tinstallation: installed.installation,\n\t\t\t\t\t\t\tscope: \"global\",\n\t\t\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch(() => undefined);\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"plugin activation failed ({code}) for {pluginId}\", {\n\t\t\t\t\t\t\tcode: activated.error.code,\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst persisted = await active.stateStore.upsert({\n\t\t\t\t\tinstallation: activated.installation,\n\t\t\t\t\tscope: \"global\",\n\t\t\t\t\tenabled: true,\n\t\t\t\t\tsource: acquired.source,\n\t\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t\t});\n\t\t\t\tif (persisted.status !== \"ok\") {\n\t\t\t\t\tawait active.installer\n\t\t\t\t\t\t.remove({\n\t\t\t\t\t\t\tinstallation: activated.installation,\n\t\t\t\t\t\t\tscope: \"global\",\n\t\t\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch(() => undefined);\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"plugin state persist failed ({status}) for {pluginId}\", {\n\t\t\t\t\t\t\tstatus: persisted.status,\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn { pluginVersion: activated.installation.pluginVersion, source: acquired.source };\n\t\t\t} finally {\n\t\t\t\tawait release();\n\t\t\t}\n\t\t},\n\t\t...(options.signal === undefined ? {} : { signal: options.signal }),\n\t};\n\ttry {\n\t\treturn await runPluginBootstrapV1({\n\t\t\tmanifest: options.manifest ?? BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1,\n\t\t\tdeps,\n\t\t\t// First-run progress line (设计 §4.4, 2026-10-03): a fresh install is\n\t\t\t// otherwise silent for the whole network install window.\n\t\t\tonPendingInstalls:\n\t\t\t\toptions.onPendingInstalls ??\n\t\t\t\t((count: number) => {\n\t\t\t\t\tconsole.error(t(\"First run: installing {count} factory plugins…\", { count }));\n\t\t\t\t}),\n\t\t});\n\t} finally {\n\t\tconst active = session;\n\t\tsession = undefined;\n\t\tif (active !== undefined) {\n\t\t\tawait active.installHost.close().catch(() => undefined);\n\t\t\tawait active.acquisition.close().catch(() => undefined);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -55,7 +55,7 @@ export interface PluginBootstrapActionV1 {
|
|
|
55
55
|
/** Acquisition or install failure code for failed actions. */
|
|
56
56
|
readonly errorCode?: string;
|
|
57
57
|
}
|
|
58
|
-
export type PluginBootstrapDiagnosticCodeV1 = "range_not_satisfied" | "install_failed" | "list_active_failed" | "cancelled" | "bootstrap_failed";
|
|
58
|
+
export type PluginBootstrapDiagnosticCodeV1 = "range_not_satisfied" | "install_failed" | "list_active_failed" | "cancelled" | "bootstrap_failed" | "bootstrap_skipped_offline";
|
|
59
59
|
export interface PluginBootstrapDiagnosticV1 {
|
|
60
60
|
readonly code: PluginBootstrapDiagnosticCodeV1;
|
|
61
61
|
readonly message: string;
|
|
@@ -83,5 +83,13 @@ export declare function pluginBootstrapInstallCommandV1(entry: {
|
|
|
83
83
|
export declare function runPluginBootstrapV1(input: {
|
|
84
84
|
readonly manifest: readonly PluginBootstrapFactoryEntryV1[];
|
|
85
85
|
readonly deps: PluginBootstrapDepsV1;
|
|
86
|
+
/**
|
|
87
|
+
* Fired once after the local active-state read when at least one factory
|
|
88
|
+
* entry has no active installation — the host's first-run progress line
|
|
89
|
+
* hook (设计 §4.4 首装进度行, 2026-10-03): a fresh install is otherwise
|
|
90
|
+
* silent for the whole network install window. Injected effect, the loop
|
|
91
|
+
* itself stays free of console I/O.
|
|
92
|
+
*/
|
|
93
|
+
readonly onPendingInstalls?: (count: number) => void;
|
|
86
94
|
}): Promise<PluginBootstrapResultV1>;
|
|
87
95
|
//# sourceMappingURL=plugin-bootstrap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-bootstrap.d.ts","sourceRoot":"","sources":["../../../src/plugins/ecosystem/plugin-bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,iCAAiC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,SAAS,6BAA6B,EAAE,CAAC;IAC5D,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;CACrC,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA4FnC","sourcesContent":["/**\n * Startup plugin bootstrap orchestrator (design\n * `插件独立分发与启动装配设计.md` §4.4, §0.7). Pure injectable decision loop\n * over the frozen factory manifest: every entry is compared against the\n * locally resolved active installations and only missing plugins are handed\n * to the npm install dependency — bootstrap never acquires through any other\n * source.\n *\n * Coverage rules (G5): an existing active installation is never replaced. A\n * satisfied range is skipped silently (zero acquisition calls, G3); an\n * unsatisfied one produces a diagnostic with a manual install command and no\n * automatic replacement. Failure semantics (G4): one plugin's install\n * failure is recorded and the loop continues; the run itself never throws.\n * All effects live behind the injected dependencies, so the loop is fully\n * deterministic under mocks.\n */\n\nimport type { PluginBootstrapFactoryEntryV1 } from \"./bootstrap-factory-manifest.ts\";\nimport { selectNpmPackageVersionV1 } from \"./node-npm-registry-source.ts\";\nimport { PluginAcquisitionErrorV1 } from \"./plugin-acquisition.ts\";\n\nexport const PLUGIN_BOOTSTRAP_VERSION_V1 = 1 as const;\n\n/** Read-only local lookup of active installation versions (never networked). */\nexport type PluginBootstrapListActiveV1 = (input: {\n\treadonly signal?: AbortSignal;\n}) => Promise<ReadonlyMap<string, string>>;\n\n/** npm-only install action; resolves with the installed version and source label. */\nexport type PluginBootstrapInstallFromNpmV1 = (input: {\n\treadonly npmName: string;\n\treadonly range?: string;\n\treadonly signal?: AbortSignal;\n}) => Promise<{ readonly pluginVersion: string; readonly source: string }>;\n\nexport interface PluginBootstrapDepsV1 {\n\treadonly listActive: PluginBootstrapListActiveV1;\n\treadonly installFromNpm: PluginBootstrapInstallFromNpmV1;\n\t/** Deterministic clock for the observed duration; defaults to Date.now. */\n\treadonly now?: () => number;\n\t/** Cooperative cancellation; checked before each manifest entry. */\n\treadonly signal?: AbortSignal;\n}\n\nexport type PluginBootstrapActionStatusV1 = \"skipped\" | \"diagnosed\" | \"installed\" | \"failed\";\n\nexport type PluginBootstrapActionReasonV1 = \"satisfies_range\" | \"range_not_satisfied\" | \"installed\" | \"install_failed\";\n\n/** One per-entry outcome; the version fields carry what each status observed. */\nexport interface PluginBootstrapActionV1 {\n\treadonly pluginId: string;\n\treadonly status: PluginBootstrapActionStatusV1;\n\treadonly reason: PluginBootstrapActionReasonV1;\n\treadonly npmName: string;\n\treadonly range?: string;\n\t/** Active version that decided a skipped/diagnosed outcome. */\n\treadonly activeVersion?: string;\n\t/** Version reported by the install action. */\n\treadonly installedVersion?: string;\n\t/** npm source label reported by the install action. */\n\treadonly source?: string;\n\t/** Acquisition or install failure code for failed actions. */\n\treadonly errorCode?: string;\n}\n\nexport type PluginBootstrapDiagnosticCodeV1 =\n\t| \"range_not_satisfied\"\n\t| \"install_failed\"\n\t| \"list_active_failed\"\n\t| \"cancelled\"\n\t| \"bootstrap_failed\";\n\nexport interface PluginBootstrapDiagnosticV1 {\n\treadonly code: PluginBootstrapDiagnosticCodeV1;\n\treadonly message: string;\n\treadonly pluginId?: string;\n}\n\nexport type PluginBootstrapStatusV1 = \"succeeded\" | \"degraded\" | \"failed\";\n\nexport interface PluginBootstrapResultV1 {\n\treadonly version: typeof PLUGIN_BOOTSTRAP_VERSION_V1;\n\t/** Aggregated outcome: failed > degraded (diagnosed entries) > succeeded. */\n\treadonly status: PluginBootstrapStatusV1;\n\treadonly actions: readonly PluginBootstrapActionV1[];\n\treadonly diagnostics: readonly PluginBootstrapDiagnosticV1[];\n\treadonly durationMs: number;\n}\n\n/**\n * A version satisfies a factory range under the same selection semantics npm\n * resolution uses: it is the version that would be picked if it were the only\n * candidate. Keeps local comparison and registry resolution consistent.\n */\nfunction satisfiesRangeV1(version: string, range: string | undefined): boolean {\n\treturn selectNpmPackageVersionV1([version], range) === version;\n}\n\n/** Executable repair command for diagnostics (G4/G5 remediation hint). */\nexport function pluginBootstrapInstallCommandV1(entry: { readonly npmName: string; readonly range?: string }): string {\n\treturn `agent-forge plugin install ${entry.npmName}@${entry.range ?? \"latest\"}`;\n}\n\nfunction errorMessage(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n\nfunction acquireErrorCode(error: unknown): string {\n\treturn error instanceof PluginAcquisitionErrorV1 ? error.code : \"install_failed\";\n}\n\nfunction actionOf(\n\tentry: PluginBootstrapFactoryEntryV1,\n\tstatus: PluginBootstrapActionStatusV1,\n\treason: PluginBootstrapActionReasonV1,\n): PluginBootstrapActionV1 {\n\treturn Object.freeze({\n\t\tpluginId: entry.pluginId,\n\t\tstatus,\n\t\treason,\n\t\tnpmName: entry.npmName,\n\t\t...(entry.range === undefined ? {} : { range: entry.range }),\n\t});\n}\n\n/**\n * Run the bootstrap decision loop. An empty manifest short-circuits before\n * any dependency is touched, so the factory-empty S1-c2 state performs zero\n * reads on real startups.\n */\nexport async function runPluginBootstrapV1(input: {\n\treadonly manifest: readonly PluginBootstrapFactoryEntryV1[];\n\treadonly deps: PluginBootstrapDepsV1;\n}): Promise<PluginBootstrapResultV1> {\n\tconst now = input.deps.now ?? Date.now;\n\tconst startedAt = now();\n\tconst finish = (\n\t\tstatus: PluginBootstrapStatusV1,\n\t\tactions: readonly PluginBootstrapActionV1[],\n\t\tdiagnostics: readonly PluginBootstrapDiagnosticV1[],\n\t): PluginBootstrapResultV1 =>\n\t\tObject.freeze({\n\t\t\tversion: PLUGIN_BOOTSTRAP_VERSION_V1,\n\t\t\tstatus,\n\t\t\tactions: Object.freeze([...actions]),\n\t\t\tdiagnostics: Object.freeze([...diagnostics]),\n\t\t\tdurationMs: Math.max(0, now() - startedAt),\n\t\t});\n\tif (input.manifest.length === 0) return finish(\"succeeded\", [], []);\n\tconst signal = input.deps.signal;\n\tlet active: ReadonlyMap<string, string>;\n\ttry {\n\t\tactive = await input.deps.listActive({ ...(signal === undefined ? {} : { signal }) });\n\t} catch (error) {\n\t\treturn finish(\n\t\t\t\"failed\",\n\t\t\t[],\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tcode: \"list_active_failed\",\n\t\t\t\t\tmessage: `Active plugin state could not be read; bootstrap installed nothing: ${errorMessage(error)}`,\n\t\t\t\t},\n\t\t\t],\n\t\t);\n\t}\n\tconst actions: PluginBootstrapActionV1[] = [];\n\tconst diagnostics: PluginBootstrapDiagnosticV1[] = [];\n\tfor (const entry of input.manifest) {\n\t\tif (signal?.aborted === true) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"cancelled\",\n\t\t\t\tmessage: \"Plugin bootstrap was cancelled before all factory entries were processed\",\n\t\t\t});\n\t\t\tbreak;\n\t\t}\n\t\tconst activeVersion = active.get(entry.pluginId);\n\t\tif (activeVersion !== undefined) {\n\t\t\tif (satisfiesRangeV1(activeVersion, entry.range)) {\n\t\t\t\tactions.push(Object.freeze({ ...actionOf(entry, \"skipped\", \"satisfies_range\"), activeVersion }));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tactions.push(Object.freeze({ ...actionOf(entry, \"diagnosed\", \"range_not_satisfied\"), activeVersion }));\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"range_not_satisfied\",\n\t\t\t\tpluginId: entry.pluginId,\n\t\t\t\tmessage:\n\t\t\t\t\t`Active version ${activeVersion} of ${entry.pluginId} does not satisfy the factory range ` +\n\t\t\t\t\t`${entry.range ?? \"latest\"}; bootstrap never replaces active installations. ` +\n\t\t\t\t\t`Run \\`${pluginBootstrapInstallCommandV1(entry)}\\` to install a matching version, ` +\n\t\t\t\t\t`or \\`agent-forge plugin update --all\\` to upgrade every outdated plugin at once.`,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\ttry {\n\t\t\tconst installed = await input.deps.installFromNpm({\n\t\t\t\tnpmName: entry.npmName,\n\t\t\t\t...(entry.range === undefined ? {} : { range: entry.range }),\n\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t});\n\t\t\tactions.push(\n\t\t\t\tObject.freeze({\n\t\t\t\t\t...actionOf(entry, \"installed\", \"installed\"),\n\t\t\t\t\tinstalledVersion: installed.pluginVersion,\n\t\t\t\t\tsource: installed.source,\n\t\t\t\t}),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tconst errorCode = acquireErrorCode(error);\n\t\t\tactions.push(Object.freeze({ ...actionOf(entry, \"failed\", \"install_failed\"), errorCode }));\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"install_failed\",\n\t\t\t\tpluginId: entry.pluginId,\n\t\t\t\tmessage:\n\t\t\t\t\t`Bootstrap could not install ${entry.pluginId} from npm (${errorCode}: ${errorMessage(error)}). ` +\n\t\t\t\t\t`Startup continues without it; its capabilities stay unavailable until installed. ` +\n\t\t\t\t\t`Run \\`${pluginBootstrapInstallCommandV1(entry)}\\` to install it manually.`,\n\t\t\t});\n\t\t}\n\t}\n\tconst status: PluginBootstrapStatusV1 = actions.some((action) => action.status === \"failed\")\n\t\t? \"failed\"\n\t\t: actions.some((action) => action.status === \"diagnosed\")\n\t\t\t? \"degraded\"\n\t\t\t: \"succeeded\";\n\treturn finish(status, actions, diagnostics);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"plugin-bootstrap.d.ts","sourceRoot":"","sources":["../../../src/plugins/ecosystem/plugin-bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAIrF,eAAO,MAAM,2BAA2B,GAAa,CAAC;AAEtD,gFAAgF;AAChF,MAAM,MAAM,2BAA2B,GAAG,CAAC,KAAK,EAAE;IACjD,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B,KAAK,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE3C,qFAAqF;AACrF,MAAM,MAAM,+BAA+B,GAAG,CAAC,KAAK,EAAE;IACrD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,Q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kBAAkB,GAClB,2BAA2B,CAAC;AAE/B,MAAM,WAAW,2BAA2B;IAC3C,QAAQ,CAAC,IAAI,EAAE,+BAA+B,CAAC;IAC/C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE1E,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,OAAO,EAAE,OAAO,2BAA2B,CAAC;IACrD,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,SAAS,uBAAuB,EAAE,CAAC;IACrD,QAAQ,CAAC,WAAW,EAAE,SAAS,2BAA2B,EAAE,CAAC;IAC7D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AAWD,0EAA0E;AAC1E,wBAAgB,+BAA+B,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAEpH;AAwBD;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE;IACjD,QAAQ,CAAC,QAAQ,EAAE,SAAS,6BAA6B,EAAE,CAAC;IAC5D,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC;;;;;;OAMG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACrD,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAgGnC","sourcesContent":["/**\n * Startup plugin bootstrap orchestrator (design\n * `插件独立分发与启动装配设计.md` §4.4, §0.7). Pure injectable decision loop\n * over the frozen factory manifest: every entry is compared against the\n * locally resolved active installations and only missing plugins are handed\n * to the npm install dependency — bootstrap never acquires through any other\n * source.\n *\n * Coverage rules (G5): an existing active installation is never replaced. A\n * satisfied range is skipped silently (zero acquisition calls, G3); an\n * unsatisfied one produces a diagnostic with a manual install command and no\n * automatic replacement. Failure semantics (G4): one plugin's install\n * failure is recorded and the loop continues; the run itself never throws.\n * All effects live behind the injected dependencies, so the loop is fully\n * deterministic under mocks.\n */\n\nimport type { PluginBootstrapFactoryEntryV1 } from \"./bootstrap-factory-manifest.ts\";\nimport { selectNpmPackageVersionV1 } from \"./node-npm-registry-source.ts\";\nimport { PluginAcquisitionErrorV1 } from \"./plugin-acquisition.ts\";\n\nexport const PLUGIN_BOOTSTRAP_VERSION_V1 = 1 as const;\n\n/** Read-only local lookup of active installation versions (never networked). */\nexport type PluginBootstrapListActiveV1 = (input: {\n\treadonly signal?: AbortSignal;\n}) => Promise<ReadonlyMap<string, string>>;\n\n/** npm-only install action; resolves with the installed version and source label. */\nexport type PluginBootstrapInstallFromNpmV1 = (input: {\n\treadonly npmName: string;\n\treadonly range?: string;\n\treadonly signal?: AbortSignal;\n}) => Promise<{ readonly pluginVersion: string; readonly source: string }>;\n\nexport interface PluginBootstrapDepsV1 {\n\treadonly listActive: PluginBootstrapListActiveV1;\n\treadonly installFromNpm: PluginBootstrapInstallFromNpmV1;\n\t/** Deterministic clock for the observed duration; defaults to Date.now. */\n\treadonly now?: () => number;\n\t/** Cooperative cancellation; checked before each manifest entry. */\n\treadonly signal?: AbortSignal;\n}\n\nexport type PluginBootstrapActionStatusV1 = \"skipped\" | \"diagnosed\" | \"installed\" | \"failed\";\n\nexport type PluginBootstrapActionReasonV1 = \"satisfies_range\" | \"range_not_satisfied\" | \"installed\" | \"install_failed\";\n\n/** One per-entry outcome; the version fields carry what each status observed. */\nexport interface PluginBootstrapActionV1 {\n\treadonly pluginId: string;\n\treadonly status: PluginBootstrapActionStatusV1;\n\treadonly reason: PluginBootstrapActionReasonV1;\n\treadonly npmName: string;\n\treadonly range?: string;\n\t/** Active version that decided a skipped/diagnosed outcome. */\n\treadonly activeVersion?: string;\n\t/** Version reported by the install action. */\n\treadonly installedVersion?: string;\n\t/** npm source label reported by the install action. */\n\treadonly source?: string;\n\t/** Acquisition or install failure code for failed actions. */\n\treadonly errorCode?: string;\n}\n\nexport type PluginBootstrapDiagnosticCodeV1 =\n\t| \"range_not_satisfied\"\n\t| \"install_failed\"\n\t| \"list_active_failed\"\n\t| \"cancelled\"\n\t| \"bootstrap_failed\"\n\t| \"bootstrap_skipped_offline\";\n\nexport interface PluginBootstrapDiagnosticV1 {\n\treadonly code: PluginBootstrapDiagnosticCodeV1;\n\treadonly message: string;\n\treadonly pluginId?: string;\n}\n\nexport type PluginBootstrapStatusV1 = \"succeeded\" | \"degraded\" | \"failed\";\n\nexport interface PluginBootstrapResultV1 {\n\treadonly version: typeof PLUGIN_BOOTSTRAP_VERSION_V1;\n\t/** Aggregated outcome: failed > degraded (diagnosed entries) > succeeded. */\n\treadonly status: PluginBootstrapStatusV1;\n\treadonly actions: readonly PluginBootstrapActionV1[];\n\treadonly diagnostics: readonly PluginBootstrapDiagnosticV1[];\n\treadonly durationMs: number;\n}\n\n/**\n * A version satisfies a factory range under the same selection semantics npm\n * resolution uses: it is the version that would be picked if it were the only\n * candidate. Keeps local comparison and registry resolution consistent.\n */\nfunction satisfiesRangeV1(version: string, range: string | undefined): boolean {\n\treturn selectNpmPackageVersionV1([version], range) === version;\n}\n\n/** Executable repair command for diagnostics (G4/G5 remediation hint). */\nexport function pluginBootstrapInstallCommandV1(entry: { readonly npmName: string; readonly range?: string }): string {\n\treturn `agent-forge plugin install ${entry.npmName}@${entry.range ?? \"latest\"}`;\n}\n\nfunction errorMessage(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n\nfunction acquireErrorCode(error: unknown): string {\n\treturn error instanceof PluginAcquisitionErrorV1 ? error.code : \"install_failed\";\n}\n\nfunction actionOf(\n\tentry: PluginBootstrapFactoryEntryV1,\n\tstatus: PluginBootstrapActionStatusV1,\n\treason: PluginBootstrapActionReasonV1,\n): PluginBootstrapActionV1 {\n\treturn Object.freeze({\n\t\tpluginId: entry.pluginId,\n\t\tstatus,\n\t\treason,\n\t\tnpmName: entry.npmName,\n\t\t...(entry.range === undefined ? {} : { range: entry.range }),\n\t});\n}\n\n/**\n * Run the bootstrap decision loop. An empty manifest short-circuits before\n * any dependency is touched, so the factory-empty S1-c2 state performs zero\n * reads on real startups.\n */\nexport async function runPluginBootstrapV1(input: {\n\treadonly manifest: readonly PluginBootstrapFactoryEntryV1[];\n\treadonly deps: PluginBootstrapDepsV1;\n\t/**\n\t * Fired once after the local active-state read when at least one factory\n\t * entry has no active installation — the host's first-run progress line\n\t * hook (设计 §4.4 首装进度行, 2026-10-03): a fresh install is otherwise\n\t * silent for the whole network install window. Injected effect, the loop\n\t * itself stays free of console I/O.\n\t */\n\treadonly onPendingInstalls?: (count: number) => void;\n}): Promise<PluginBootstrapResultV1> {\n\tconst now = input.deps.now ?? Date.now;\n\tconst startedAt = now();\n\tconst finish = (\n\t\tstatus: PluginBootstrapStatusV1,\n\t\tactions: readonly PluginBootstrapActionV1[],\n\t\tdiagnostics: readonly PluginBootstrapDiagnosticV1[],\n\t): PluginBootstrapResultV1 =>\n\t\tObject.freeze({\n\t\t\tversion: PLUGIN_BOOTSTRAP_VERSION_V1,\n\t\t\tstatus,\n\t\t\tactions: Object.freeze([...actions]),\n\t\t\tdiagnostics: Object.freeze([...diagnostics]),\n\t\t\tdurationMs: Math.max(0, now() - startedAt),\n\t\t});\n\tif (input.manifest.length === 0) return finish(\"succeeded\", [], []);\n\tconst signal = input.deps.signal;\n\tlet active: ReadonlyMap<string, string>;\n\ttry {\n\t\tactive = await input.deps.listActive({ ...(signal === undefined ? {} : { signal }) });\n\t} catch (error) {\n\t\treturn finish(\n\t\t\t\"failed\",\n\t\t\t[],\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tcode: \"list_active_failed\",\n\t\t\t\t\tmessage: `Active plugin state could not be read; bootstrap installed nothing: ${errorMessage(error)}`,\n\t\t\t\t},\n\t\t\t],\n\t\t);\n\t}\n\tconst actions: PluginBootstrapActionV1[] = [];\n\tconst diagnostics: PluginBootstrapDiagnosticV1[] = [];\n\tif (input.onPendingInstalls !== undefined) {\n\t\tconst pending = input.manifest.filter((entry) => !active.has(entry.pluginId)).length;\n\t\tif (pending > 0) input.onPendingInstalls(pending);\n\t}\n\tfor (const entry of input.manifest) {\n\t\tif (signal?.aborted === true) {\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"cancelled\",\n\t\t\t\tmessage: \"Plugin bootstrap was cancelled before all factory entries were processed\",\n\t\t\t});\n\t\t\tbreak;\n\t\t}\n\t\tconst activeVersion = active.get(entry.pluginId);\n\t\tif (activeVersion !== undefined) {\n\t\t\tif (satisfiesRangeV1(activeVersion, entry.range)) {\n\t\t\t\tactions.push(Object.freeze({ ...actionOf(entry, \"skipped\", \"satisfies_range\"), activeVersion }));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tactions.push(Object.freeze({ ...actionOf(entry, \"diagnosed\", \"range_not_satisfied\"), activeVersion }));\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"range_not_satisfied\",\n\t\t\t\tpluginId: entry.pluginId,\n\t\t\t\tmessage:\n\t\t\t\t\t`Active version ${activeVersion} of ${entry.pluginId} does not satisfy the factory range ` +\n\t\t\t\t\t`${entry.range ?? \"latest\"}; bootstrap never replaces active installations. ` +\n\t\t\t\t\t`Run \\`${pluginBootstrapInstallCommandV1(entry)}\\` to install a matching version, ` +\n\t\t\t\t\t`or \\`agent-forge plugin update --all\\` to upgrade every outdated plugin at once.`,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\ttry {\n\t\t\tconst installed = await input.deps.installFromNpm({\n\t\t\t\tnpmName: entry.npmName,\n\t\t\t\t...(entry.range === undefined ? {} : { range: entry.range }),\n\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t});\n\t\t\tactions.push(\n\t\t\t\tObject.freeze({\n\t\t\t\t\t...actionOf(entry, \"installed\", \"installed\"),\n\t\t\t\t\tinstalledVersion: installed.pluginVersion,\n\t\t\t\t\tsource: installed.source,\n\t\t\t\t}),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tconst errorCode = acquireErrorCode(error);\n\t\t\tactions.push(Object.freeze({ ...actionOf(entry, \"failed\", \"install_failed\"), errorCode }));\n\t\t\tdiagnostics.push({\n\t\t\t\tcode: \"install_failed\",\n\t\t\t\tpluginId: entry.pluginId,\n\t\t\t\tmessage:\n\t\t\t\t\t`Bootstrap could not install ${entry.pluginId} from npm (${errorCode}: ${errorMessage(error)}). ` +\n\t\t\t\t\t`Startup continues without it; its capabilities stay unavailable until installed. ` +\n\t\t\t\t\t`Run \\`${pluginBootstrapInstallCommandV1(entry)}\\` to install it manually.`,\n\t\t\t});\n\t\t}\n\t}\n\tconst status: PluginBootstrapStatusV1 = actions.some((action) => action.status === \"failed\")\n\t\t? \"failed\"\n\t\t: actions.some((action) => action.status === \"diagnosed\")\n\t\t\t? \"degraded\"\n\t\t\t: \"succeeded\";\n\treturn finish(status, actions, diagnostics);\n}\n"]}
|
|
@@ -76,6 +76,11 @@ export async function runPluginBootstrapV1(input) {
|
|
|
76
76
|
}
|
|
77
77
|
const actions = [];
|
|
78
78
|
const diagnostics = [];
|
|
79
|
+
if (input.onPendingInstalls !== undefined) {
|
|
80
|
+
const pending = input.manifest.filter((entry) => !active.has(entry.pluginId)).length;
|
|
81
|
+
if (pending > 0)
|
|
82
|
+
input.onPendingInstalls(pending);
|
|
83
|
+
}
|
|
79
84
|
for (const entry of input.manifest) {
|
|
80
85
|
if (signal?.aborted === true) {
|
|
81
86
|
diagnostics.push({
|