@ai-agent-forge/agent-forge 0.88.0 → 0.88.2
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 +73 -0
- 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 +143 -56
- 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 +109 -155
- 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-44I47ACN.js +13 -0
- package/dist/bundle/chunks/chunk-6F5JWGKE.js +4 -0
- 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-HTC5K5SM.js +866 -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-LSP24WNH.js +665 -0
- package/dist/bundle/chunks/{chunk-7ZY7IXZD.js → chunk-TRDNDS6A.js} +1 -1
- 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 +4 -4
- 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-MRXD3RWG.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/plugin-command.d.ts.map +1 -1
- package/dist/cli/plugin-command.js +25 -3
- 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 +2 -4
- 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.map +1 -1
- package/dist/core/agent-session-compaction.js +14 -1
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-internal.d.ts +3 -1
- 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 -3
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +2 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +31 -9
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-store.d.ts.map +1 -1
- package/dist/core/agent-session-store.js +6 -1
- package/dist/core/agent-session-store.js.map +1 -1
- package/dist/core/agent-session-tools.d.ts.map +1 -1
- package/dist/core/agent-session-tools.js +18 -1
- package/dist/core/agent-session-tools.js.map +1 -1
- package/dist/core/agent-session.d.ts +34 -11
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +114 -38
- 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 -1
- package/dist/core/facade/coding-agent-facade.d.ts.map +1 -1
- 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 +2 -0
- 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/index.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/index.js +2 -0
- package/dist/core/i18n/locales/zh-cn/index.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 +5 -0
- package/dist/core/i18n/locales/zh-cn/interactive-mode.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/session-cleanup.d.ts +7 -0
- package/dist/core/i18n/locales/zh-cn/session-cleanup.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/session-cleanup.js +15 -0
- package/dist/core/i18n/locales/zh-cn/session-cleanup.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/slash-commands.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/slash-commands.js +1 -0
- package/dist/core/i18n/locales/zh-cn/slash-commands.js.map +1 -1
- package/dist/core/sdk.d.ts +10 -3
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +287 -78
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-cleanup.d.ts +49 -0
- package/dist/core/session-cleanup.d.ts.map +1 -0
- package/dist/core/session-cleanup.js +159 -0
- package/dist/core/session-cleanup.js.map +1 -0
- package/dist/core/session-index.d.ts +75 -0
- package/dist/core/session-index.d.ts.map +1 -0
- package/dist/core/session-index.js +455 -0
- package/dist/core/session-index.js.map +1 -0
- package/dist/core/session-manager.d.ts +9 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +202 -47
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +5 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +12 -1
- package/dist/core/system-prompt.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/capability-mount.d.ts +40 -0
- package/dist/core/tools/capability-mount.d.ts.map +1 -0
- package/dist/core/tools/capability-mount.js +112 -0
- package/dist/core/tools/capability-mount.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 +1 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +3 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +27 -5
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.js +5 -1
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +9 -0
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +17 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +52 -25
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-run-group.d.ts +44 -0
- package/dist/modes/interactive/components/tool-run-group.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-run-group.js +121 -0
- package/dist/modes/interactive/components/tool-run-group.js.map +1 -0
- package/dist/modes/interactive/interactive-commands.d.ts +2 -0
- package/dist/modes/interactive/interactive-commands.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-commands.js +7 -0
- package/dist/modes/interactive/interactive-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +18 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +85 -3
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/plugins/ecosystem/cli.d.ts.map +1 -1
- package/dist/plugins/ecosystem/cli.js +20 -5
- 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 +7 -1
- package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-bootstrap.js +50 -3
- package/dist/plugins/ecosystem/node-plugin-bootstrap.js.map +1 -1
- package/dist/plugins/ecosystem/plugin-bootstrap.d.ts +28 -16
- package/dist/plugins/ecosystem/plugin-bootstrap.d.ts.map +1 -1
- package/dist/plugins/ecosystem/plugin-bootstrap.js +35 -33
- package/dist/plugins/ecosystem/plugin-bootstrap.js.map +1 -1
- package/dist/profile/plugin-profiles.d.ts +1 -1
- package/dist/profile/plugin-profiles.d.ts.map +1 -1
- package/dist/profile/plugin-profiles.js +18 -0
- package/dist/profile/plugin-profiles.js.map +1 -1
- package/dist/profiles/builtin-suites.d.ts +19 -5
- package/dist/profiles/builtin-suites.d.ts.map +1 -1
- package/dist/profiles/builtin-suites.js +26 -6
- package/dist/profiles/builtin-suites.js.map +1 -1
- package/docs/settings.md +354 -354
- package/docs/usage.md +292 -292
- 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/package.json +3 -2
- package/dist/bundle/chunks/chunk-6ZKDNZHA.js +0 -145
- package/dist/bundle/chunks/chunk-HLJEVRWP.js +0 -13
- package/dist/bundle/chunks/chunk-YGHQME4V.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 -48
- 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/provider-failover.d.ts +0 -110
- 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/examples/extensions/mcp-stdio/index.d.ts +0 -64
- package/examples/extensions/mcp-stdio/index.d.ts.map +0 -1
- package/examples/extensions/mcp-stdio/index.js +0 -292
- package/examples/extensions/mcp-stdio/index.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;;;;;;;;GA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,CAAC,aAAa,KAAK,KAAK,CAAC,QAAQ,CAAC,aAAa;oBAC9D,MAAM,CAAC,QAAQ,CAAC,cAAc,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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A,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 === \"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"]}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { PluginBootstrapFactoryEntryV1 } from "./bootstrap-factory-manifest.ts";
|
|
17
17
|
import { type NodeZipPackageLimitsV1 } from "./node-package-install-host.ts";
|
|
18
|
-
import { type PluginBootstrapDepsV1, type PluginBootstrapResultV1 } from "./plugin-bootstrap.ts";
|
|
18
|
+
import { type PluginBootstrapActionV1, type PluginBootstrapDepsV1, type PluginBootstrapResultV1 } from "./plugin-bootstrap.ts";
|
|
19
19
|
/** Environment variable disabling the startup bootstrap entirely (`off`). */
|
|
20
20
|
export declare const AGENT_FORGE_PLUGIN_BOOTSTRAP_ENV_V1 = "AGENT_FORGE_PLUGIN_BOOTSTRAP";
|
|
21
21
|
export interface NodePluginBootstrapOptionsV1 {
|
|
@@ -35,6 +35,12 @@ export interface NodePluginBootstrapOptionsV1 {
|
|
|
35
35
|
readonly deps?: PluginBootstrapDepsV1;
|
|
36
36
|
/** Overrides the first-run progress line (stderr) for tests and hosts. */
|
|
37
37
|
readonly onPendingInstalls?: (count: number) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Overrides the per-plugin progress renderer (stderr) for tests and hosts.
|
|
40
|
+
* The default prints one line per installed/aligned/failed entry and stays
|
|
41
|
+
* silent for satisfied entries.
|
|
42
|
+
*/
|
|
43
|
+
readonly onAction?: (action: PluginBootstrapActionV1) => void;
|
|
38
44
|
}
|
|
39
45
|
export type NodePluginBootstrapResultV1 = PluginBootstrapResultV1 & {
|
|
40
46
|
/**
|
|
@@ -1 +1 @@
|
|
|
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"]}
|
|
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,EACN,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAE5B,MAAM,uBAAuB,CAAC;AAG/B,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;IACrD;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,uBAAuB,KAAK,IAAI,CAAC;CAC9D;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,CAuPtC","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 {\n\ttype PluginBootstrapActionV1,\n\ttype PluginBootstrapDepsV1,\n\ttype PluginBootstrapResultV1,\n\trunPluginBootstrapV1,\n} 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\t/**\n\t * Overrides the per-plugin progress renderer (stderr) for tests and hosts.\n\t * The default prints one line per installed/aligned/failed entry and stays\n\t * silent for satisfied entries.\n\t */\n\treadonly onAction?: (action: PluginBootstrapActionV1) => 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\t...(options.onAction === undefined ? {} : { onAction: options.onAction }),\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\t// Download retry (设计 §4.4 下载重试, 2026-10-04): transient registry\n\t\t\t// failures retried with backoff at this wiring layer so the decision\n\t\t\t// loop stays pure. Abort propagates immediately between attempts.\n\t\t\tlet lastError: unknown;\n\t\t\tfor (let attempt = 1; attempt <= 3; attempt++) {\n\t\t\t\tif (signal?.aborted === true) throw lastError ?? new Error(\"install aborted\");\n\t\t\t\ttry {\n\t\t\t\t\treturn await installFromNpmOnce({ npmName, range, signal });\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlastError = error;\n\t\t\t\t\t// Abort during the attempt surfaces as the attempt's own error;\n\t\t\t\t\t// the loop-top check and the backoff listener cover the pauses.\n\t\t\t\t\tif (attempt === 3) throw error;\n\t\t\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\t\t\tconst timer = setTimeout(resolve, 400 * 2 ** (attempt - 1));\n\t\t\t\t\t\tsignal?.addEventListener(\n\t\t\t\t\t\t\t\"abort\",\n\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\t\t\t\treject(lastError);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ once: true },\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow lastError;\n\t\t},\n\t\t...(options.signal === undefined ? {} : { signal: options.signal }),\n\t};\n\tconst installFromNpmOnce = async (input: {\n\t\treadonly npmName: string;\n\t\treadonly range?: string;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<{ readonly pluginVersion: string; readonly source: string }> => {\n\t\tconst { npmName, range, signal } = input;\n\t\t{\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};\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\t// Per-plugin progress (设计 §4.4 逐插件进度, 2026-10-04): one stderr\n\t\t\t// line per installed/aligned/failed entry; satisfied entries stay\n\t\t\t// silent so an all-green startup prints nothing extra.\n\t\t\tonAction:\n\t\t\t\toptions.onAction ??\n\t\t\t\t((action: PluginBootstrapActionV1) => {\n\t\t\t\t\tif (action.status === \"installed\") {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\tt(\"{pluginId}: installed {version}\", {\n\t\t\t\t\t\t\t\tpluginId: action.pluginId,\n\t\t\t\t\t\t\t\tversion: action.installedVersion ?? \"\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if (action.status === \"failed\") {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\tt(\n\t\t\t\t\t\t\t\t\"{pluginId}: install failed ({code}) — startup continues; the next startup retries automatically\",\n\t\t\t\t\t\t\t\t{ pluginId: action.pluginId, code: action.errorCode ?? \"install_failed\" },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\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"]}
|
|
@@ -22,7 +22,7 @@ import { DEFAULT_PLUGIN_STATE_FILE_V1, defaultPluginHostFactsV1, defaultPluginIn
|
|
|
22
22
|
import { createPluginInstallerV1, DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1 } from "./installer.js";
|
|
23
23
|
import { createNodePackageInstallHostV1, } from "./node-package-install-host.js";
|
|
24
24
|
import { createNodePluginAcquisitionHostV1 } from "./node-plugin-acquisition-host.js";
|
|
25
|
-
import { runPluginBootstrapV1 } from "./plugin-bootstrap.js";
|
|
25
|
+
import { runPluginBootstrapV1, } from "./plugin-bootstrap.js";
|
|
26
26
|
import { createPluginStateStoreV1 } from "./state.js";
|
|
27
27
|
/** Environment variable disabling the startup bootstrap entirely (`off`). */
|
|
28
28
|
export const AGENT_FORGE_PLUGIN_BOOTSTRAP_ENV_V1 = "AGENT_FORGE_PLUGIN_BOOTSTRAP";
|
|
@@ -86,6 +86,7 @@ export async function runNodePluginBootstrapV1(options) {
|
|
|
86
86
|
manifest: options.manifest ?? BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1,
|
|
87
87
|
deps: options.deps,
|
|
88
88
|
...(options.onPendingInstalls === undefined ? {} : { onPendingInstalls: options.onPendingInstalls }),
|
|
89
|
+
...(options.onAction === undefined ? {} : { onAction: options.onAction }),
|
|
89
90
|
});
|
|
90
91
|
}
|
|
91
92
|
let session;
|
|
@@ -123,6 +124,38 @@ export async function runNodePluginBootstrapV1(options) {
|
|
|
123
124
|
return new Map([...globalResult, ...projectResult]);
|
|
124
125
|
},
|
|
125
126
|
installFromNpm: async ({ npmName, range, signal }) => {
|
|
127
|
+
// Download retry (设计 §4.4 下载重试, 2026-10-04): transient registry
|
|
128
|
+
// failures retried with backoff at this wiring layer so the decision
|
|
129
|
+
// loop stays pure. Abort propagates immediately between attempts.
|
|
130
|
+
let lastError;
|
|
131
|
+
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
132
|
+
if (signal?.aborted === true)
|
|
133
|
+
throw lastError ?? new Error("install aborted");
|
|
134
|
+
try {
|
|
135
|
+
return await installFromNpmOnce({ npmName, range, signal });
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
lastError = error;
|
|
139
|
+
// Abort during the attempt surfaces as the attempt's own error;
|
|
140
|
+
// the loop-top check and the backoff listener cover the pauses.
|
|
141
|
+
if (attempt === 3)
|
|
142
|
+
throw error;
|
|
143
|
+
await new Promise((resolve, reject) => {
|
|
144
|
+
const timer = setTimeout(resolve, 400 * 2 ** (attempt - 1));
|
|
145
|
+
signal?.addEventListener("abort", () => {
|
|
146
|
+
clearTimeout(timer);
|
|
147
|
+
reject(lastError);
|
|
148
|
+
}, { once: true });
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
throw lastError;
|
|
153
|
+
},
|
|
154
|
+
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
155
|
+
};
|
|
156
|
+
const installFromNpmOnce = async (input) => {
|
|
157
|
+
const { npmName, range, signal } = input;
|
|
158
|
+
{
|
|
126
159
|
const active = await ensureSession();
|
|
127
160
|
// npm refs only (§0.7): scoped or plain names with the shared minimal
|
|
128
161
|
// range subset; no github/gitee/url/local ref can be expressed here.
|
|
@@ -203,8 +236,7 @@ export async function runNodePluginBootstrapV1(options) {
|
|
|
203
236
|
finally {
|
|
204
237
|
await release();
|
|
205
238
|
}
|
|
206
|
-
}
|
|
207
|
-
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
239
|
+
}
|
|
208
240
|
};
|
|
209
241
|
try {
|
|
210
242
|
return await runPluginBootstrapV1({
|
|
@@ -216,6 +248,21 @@ export async function runNodePluginBootstrapV1(options) {
|
|
|
216
248
|
((count) => {
|
|
217
249
|
console.error(t("First run: installing {count} factory plugins…", { count }));
|
|
218
250
|
}),
|
|
251
|
+
// Per-plugin progress (设计 §4.4 逐插件进度, 2026-10-04): one stderr
|
|
252
|
+
// line per installed/aligned/failed entry; satisfied entries stay
|
|
253
|
+
// silent so an all-green startup prints nothing extra.
|
|
254
|
+
onAction: options.onAction ??
|
|
255
|
+
((action) => {
|
|
256
|
+
if (action.status === "installed") {
|
|
257
|
+
console.error(t("{pluginId}: installed {version}", {
|
|
258
|
+
pluginId: action.pluginId,
|
|
259
|
+
version: action.installedVersion ?? "",
|
|
260
|
+
}));
|
|
261
|
+
}
|
|
262
|
+
else if (action.status === "failed") {
|
|
263
|
+
console.error(t("{pluginId}: install failed ({code}) — startup continues; the next startup retries automatically", { pluginId: action.pluginId, code: action.errorCode ?? "install_failed" }));
|
|
264
|
+
}
|
|
265
|
+
}),
|
|
219
266
|
});
|
|
220
267
|
}
|
|
221
268
|
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;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;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;AAuCjD,SAAS,kBAAkB,CAC1B,KAAyB,EACzB,KAA2B,EAC3B,QAAgB,EAChB,MAA+B,EACQ;IACvC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;QACnB,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CA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a,EAAE,SAAS,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;YACzF,CAAC;oBAAS,CAAC;gBACV,MAAM,OAAO,EAAE,CAAC;YACjB,CAAC;QAAA,CACD;QACD,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;KACnE,CAAC;IACF,IAAI,CAAC;QACJ,OAAO,MAAM,oBAAoB,CAAC;YACjC,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,oCAAoC;YAClE,IAAI;YACJ,yEAAoE;YACpE,yDAAyD;YACzD,iBAAiB,EAChB,OAAO,CAAC,iBAAiB;gBACzB,CAAC,CAAC,KAAa,EAAE,EAAE,CAAC;oBACnB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,kDAAgD,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;gBAAA,CAC9E,CAAC;SACH,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 { 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"]}
|
|
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,uB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AAC;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 {\n\ttype PluginBootstrapActionV1,\n\ttype PluginBootstrapDepsV1,\n\ttype PluginBootstrapResultV1,\n\trunPluginBootstrapV1,\n} 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\t/**\n\t * Overrides the per-plugin progress renderer (stderr) for tests and hosts.\n\t * The default prints one line per installed/aligned/failed entry and stays\n\t * silent for satisfied entries.\n\t */\n\treadonly onAction?: (action: PluginBootstrapActionV1) => 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\t...(options.onAction === undefined ? {} : { onAction: options.onAction }),\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\t// Download retry (设计 §4.4 下载重试, 2026-10-04): transient registry\n\t\t\t// failures retried with backoff at this wiring layer so the decision\n\t\t\t// loop stays pure. Abort propagates immediately between attempts.\n\t\t\tlet lastError: unknown;\n\t\t\tfor (let attempt = 1; attempt <= 3; attempt++) {\n\t\t\t\tif (signal?.aborted === true) throw lastError ?? new Error(\"install aborted\");\n\t\t\t\ttry {\n\t\t\t\t\treturn await installFromNpmOnce({ npmName, range, signal });\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlastError = error;\n\t\t\t\t\t// Abort during the attempt surfaces as the attempt's own error;\n\t\t\t\t\t// the loop-top check and the backoff listener cover the pauses.\n\t\t\t\t\tif (attempt === 3) throw error;\n\t\t\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\t\t\tconst timer = setTimeout(resolve, 400 * 2 ** (attempt - 1));\n\t\t\t\t\t\tsignal?.addEventListener(\n\t\t\t\t\t\t\t\"abort\",\n\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\t\t\t\treject(lastError);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ once: true },\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow lastError;\n\t\t},\n\t\t...(options.signal === undefined ? {} : { signal: options.signal }),\n\t};\n\tconst installFromNpmOnce = async (input: {\n\t\treadonly npmName: string;\n\t\treadonly range?: string;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<{ readonly pluginVersion: string; readonly source: string }> => {\n\t\tconst { npmName, range, signal } = input;\n\t\t{\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};\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\t// Per-plugin progress (设计 §4.4 逐插件进度, 2026-10-04): one stderr\n\t\t\t// line per installed/aligned/failed entry; satisfied entries stay\n\t\t\t// silent so an all-green startup prints nothing extra.\n\t\t\tonAction:\n\t\t\t\toptions.onAction ??\n\t\t\t\t((action: PluginBootstrapActionV1) => {\n\t\t\t\t\tif (action.status === \"installed\") {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\tt(\"{pluginId}: installed {version}\", {\n\t\t\t\t\t\t\t\tpluginId: action.pluginId,\n\t\t\t\t\t\t\t\tversion: action.installedVersion ?? \"\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if (action.status === \"failed\") {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\tt(\n\t\t\t\t\t\t\t\t\"{pluginId}: install failed ({code}) — startup continues; the next startup retries automatically\",\n\t\t\t\t\t\t\t\t{ pluginId: action.pluginId, code: action.errorCode ?? \"install_failed\" },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\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"]}
|
|
@@ -2,17 +2,22 @@
|
|
|
2
2
|
* Startup plugin bootstrap orchestrator (design
|
|
3
3
|
* `插件独立分发与启动装配设计.md` §4.4, §0.7). Pure injectable decision loop
|
|
4
4
|
* over the frozen factory manifest: every entry is compared against the
|
|
5
|
-
* locally resolved active installations
|
|
6
|
-
*
|
|
5
|
+
* locally resolved active installations; missing plugins and factory entries
|
|
6
|
+
* whose active version no longer satisfies the factory range are handed to
|
|
7
|
+
* the npm install dependency — bootstrap never acquires through any other
|
|
7
8
|
* source.
|
|
8
9
|
*
|
|
9
|
-
* Coverage rules (G5
|
|
10
|
-
* satisfied range is skipped silently (zero acquisition calls, G3);
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
10
|
+
* Coverage rules (G5, with the 2026-10-04 install-and-use exception): a
|
|
11
|
+
* satisfied range is skipped silently (zero acquisition calls, G3); a factory
|
|
12
|
+
* entry whose range is unsatisfied is automatically realigned by installing
|
|
13
|
+
* the factory range — factory plugins are version-locked to the running
|
|
14
|
+
* framework, so an unsatisfied range is a broken compatibility state, not a
|
|
15
|
+
* user preference to protect. User-installed third-party plugins are not in
|
|
16
|
+
* the factory manifest and stay untouched. Failure semantics (G4): one
|
|
17
|
+
* plugin's install failure is recorded and the loop continues; the run itself
|
|
18
|
+
* never throws, and a failed entry self-heals on the next startup because it
|
|
19
|
+
* stays unsatisfied. All effects live behind the injected dependencies, so
|
|
20
|
+
* the loop is fully deterministic under mocks.
|
|
16
21
|
*/
|
|
17
22
|
import type { PluginBootstrapFactoryEntryV1 } from "./bootstrap-factory-manifest.ts";
|
|
18
23
|
export declare const PLUGIN_BOOTSTRAP_VERSION_V1: 1;
|
|
@@ -37,8 +42,8 @@ export interface PluginBootstrapDepsV1 {
|
|
|
37
42
|
/** Cooperative cancellation; checked before each manifest entry. */
|
|
38
43
|
readonly signal?: AbortSignal;
|
|
39
44
|
}
|
|
40
|
-
export type PluginBootstrapActionStatusV1 = "skipped" | "
|
|
41
|
-
export type PluginBootstrapActionReasonV1 = "satisfies_range" | "
|
|
45
|
+
export type PluginBootstrapActionStatusV1 = "skipped" | "installed" | "failed";
|
|
46
|
+
export type PluginBootstrapActionReasonV1 = "satisfies_range" | "installed" | "range_aligned" | "install_failed" | "align_failed";
|
|
42
47
|
/** One per-entry outcome; the version fields carry what each status observed. */
|
|
43
48
|
export interface PluginBootstrapActionV1 {
|
|
44
49
|
readonly pluginId: string;
|
|
@@ -46,7 +51,7 @@ export interface PluginBootstrapActionV1 {
|
|
|
46
51
|
readonly reason: PluginBootstrapActionReasonV1;
|
|
47
52
|
readonly npmName: string;
|
|
48
53
|
readonly range?: string;
|
|
49
|
-
/** Active version that decided a skipped
|
|
54
|
+
/** Active version that decided a skipped outcome. */
|
|
50
55
|
readonly activeVersion?: string;
|
|
51
56
|
/** Version reported by the install action. */
|
|
52
57
|
readonly installedVersion?: string;
|
|
@@ -55,22 +60,22 @@ export interface PluginBootstrapActionV1 {
|
|
|
55
60
|
/** Acquisition or install failure code for failed actions. */
|
|
56
61
|
readonly errorCode?: string;
|
|
57
62
|
}
|
|
58
|
-
export type PluginBootstrapDiagnosticCodeV1 = "
|
|
63
|
+
export type PluginBootstrapDiagnosticCodeV1 = "install_failed" | "list_active_failed" | "cancelled" | "bootstrap_failed" | "bootstrap_skipped_offline";
|
|
59
64
|
export interface PluginBootstrapDiagnosticV1 {
|
|
60
65
|
readonly code: PluginBootstrapDiagnosticCodeV1;
|
|
61
66
|
readonly message: string;
|
|
62
67
|
readonly pluginId?: string;
|
|
63
68
|
}
|
|
64
|
-
export type PluginBootstrapStatusV1 = "succeeded" | "
|
|
69
|
+
export type PluginBootstrapStatusV1 = "succeeded" | "failed";
|
|
65
70
|
export interface PluginBootstrapResultV1 {
|
|
66
71
|
readonly version: typeof PLUGIN_BOOTSTRAP_VERSION_V1;
|
|
67
|
-
/** Aggregated outcome: failed
|
|
72
|
+
/** Aggregated outcome: failed (any failed entry) > succeeded. */
|
|
68
73
|
readonly status: PluginBootstrapStatusV1;
|
|
69
74
|
readonly actions: readonly PluginBootstrapActionV1[];
|
|
70
75
|
readonly diagnostics: readonly PluginBootstrapDiagnosticV1[];
|
|
71
76
|
readonly durationMs: number;
|
|
72
77
|
}
|
|
73
|
-
/** Executable repair command for diagnostics (G4
|
|
78
|
+
/** Executable repair command for diagnostics (G4 remediation hint). */
|
|
74
79
|
export declare function pluginBootstrapInstallCommandV1(entry: {
|
|
75
80
|
readonly npmName: string;
|
|
76
81
|
readonly range?: string;
|
|
@@ -91,5 +96,12 @@ export declare function runPluginBootstrapV1(input: {
|
|
|
91
96
|
* itself stays free of console I/O.
|
|
92
97
|
*/
|
|
93
98
|
readonly onPendingInstalls?: (count: number) => void;
|
|
99
|
+
/**
|
|
100
|
+
* Fired after every per-entry action (设计 §4.4 逐插件进度, 2026-10-04):
|
|
101
|
+
* the host renders one line per install/align/failure so the waiting user
|
|
102
|
+
* sees live state; skipped entries stay silent at the host's discretion.
|
|
103
|
+
* Injected effect, the loop itself stays free of console I/O.
|
|
104
|
+
*/
|
|
105
|
+
readonly onAction?: (action: PluginBootstrapActionV1) => void;
|
|
94
106
|
}): Promise<PluginBootstrapResultV1>;
|
|
95
107
|
//# sourceMappingURL=plugin-bootstrap.d.ts.map
|