@ai-agent-forge/agent-forge 0.88.2 → 0.88.4
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 +33 -0
- package/README.md +1 -1
- package/bundled-plugins/agent-loop-policy/agent-forge.json +1 -1
- package/bundled-plugins/agent-loop-policy/plugin.json +1 -1
- package/bundled-plugins/coding-tools/agent-forge.json +1 -1
- package/bundled-plugins/coding-tools/plugin.json +1 -1
- package/bundled-plugins/compaction-policy/agent-forge.json +1 -1
- package/bundled-plugins/compaction-policy/plugin.json +1 -1
- package/bundled-plugins/overflow-policy/agent-forge.json +1 -1
- package/bundled-plugins/overflow-policy/plugin.json +1 -1
- package/bundled-plugins/provider-failover/agent-forge.json +1 -1
- package/bundled-plugins/provider-failover/plugin.json +1 -1
- package/bundled-plugins/retry-policy/agent-forge.json +1 -1
- package/bundled-plugins/retry-policy/plugin.json +1 -1
- package/dist/artifacts/paged-read.d.ts +6 -1
- package/dist/artifacts/paged-read.d.ts.map +1 -1
- package/dist/artifacts/paged-read.js.map +1 -1
- package/dist/bundle/.build-manifest.json +244 -234
- package/dist/bundle/chunks/{anthropic-messages-PLAKXR73.js → anthropic-messages-3FJHRAJL.js} +2 -2
- package/dist/bundle/chunks/anthropic.js +1 -1
- package/dist/bundle/chunks/{azure-openai-responses-OUWQ2AZD.js → azure-openai-responses-GCL47IDS.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
- package/dist/bundle/chunks/{chunk-6F5JWGKE.js → chunk-32YDZI4J.js} +1 -1
- package/dist/bundle/chunks/{chunk-LSP24WNH.js → chunk-755VNWIF.js} +12 -12
- package/dist/bundle/chunks/{chunk-DRQDKNXA.js → chunk-BVVSHK6W.js} +1 -1
- package/dist/bundle/chunks/{chunk-HTC5K5SM.js → chunk-HEL6TAWE.js} +95 -90
- package/dist/bundle/chunks/{chunk-6R7UI4IY.js → chunk-QDLOMKF6.js} +1 -1
- package/dist/bundle/chunks/{chunk-44I47ACN.js → chunk-V3ACW7VD.js} +1 -1
- package/dist/bundle/chunks/{google-generative-ai-DLII6DAT.js → google-generative-ai-6BMXWA44.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-G7BZL7GM.js → google-vertex-6H7NLRTK.js} +1 -1
- package/dist/bundle/chunks/image-resize-worker.js +1 -1
- package/dist/bundle/chunks/{mistral-conversations-JXUK24ID.js → mistral-conversations-IXUHSFSJ.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-5GSGFIPG.js → openai-codex-responses-YHUAEVCM.js} +1 -1
- package/dist/bundle/chunks/openai-codex.js +1 -1
- package/dist/bundle/chunks/{openai-completions-EI2I6DTG.js → openai-completions-ULQCFC72.js} +1 -1
- package/dist/bundle/chunks/openai-responses-NLLAJDPS.js +2 -0
- package/dist/bundle/chunks/{openrouter-images-G4GQRUSG.js → openrouter-images-GZZQZXMS.js} +1 -1
- package/dist/bundle/chunks/openrouter.js +1 -1
- package/dist/bundle/chunks/{pi-messages-PWU2VJMR.js → pi-messages-EJTI2EJ3.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-TQWEGNNZ.js +5 -0
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/client.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts +0 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +1 -4
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/experimental/cli.d.ts +3 -3
- package/dist/cli/experimental/cli.d.ts.map +1 -1
- package/dist/cli/experimental/cli.js +2 -2
- package/dist/cli/experimental/cli.js.map +1 -1
- package/dist/cli/experimental/commands/agent-forge.d.ts +15 -0
- package/dist/cli/experimental/commands/agent-forge.d.ts.map +1 -0
- package/dist/cli/experimental/commands/{pi.js → agent-forge.js} +4 -4
- package/dist/cli/experimental/commands/agent-forge.js.map +1 -0
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +1 -1
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/config.d.ts +4 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +7 -7
- package/dist/config.js.map +1 -1
- package/dist/core/agent-forge-manifest.d.ts +7 -0
- package/dist/core/agent-forge-manifest.d.ts.map +1 -0
- package/dist/core/{pi-manifest.js → agent-forge-manifest.js} +4 -4
- package/dist/core/agent-forge-manifest.js.map +1 -0
- package/dist/core/agent-session-compaction.d.ts +1 -1
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +3 -3
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-lifecycle.d.ts.map +1 -1
- package/dist/core/agent-session-lifecycle.js +12 -1
- package/dist/core/agent-session-lifecycle.js.map +1 -1
- package/dist/core/agent-session-projection.d.ts.map +1 -1
- package/dist/core/agent-session-projection.js +3 -3
- package/dist/core/agent-session-projection.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +1 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +1 -1
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/experimental.d.ts.map +1 -1
- package/dist/core/experimental.js +1 -3
- package/dist/core/experimental.js.map +1 -1
- package/dist/core/extensions/capability-plugin.d.ts.map +1 -1
- package/dist/core/extensions/capability-plugin.js +15 -8
- package/dist/core/extensions/capability-plugin.js.map +1 -1
- package/dist/core/extensions/capability-runtime-store.d.ts +20 -1
- package/dist/core/extensions/capability-runtime-store.d.ts.map +1 -1
- package/dist/core/extensions/capability-runtime-store.js +67 -0
- package/dist/core/extensions/capability-runtime-store.js.map +1 -1
- package/dist/core/extensions/capability-runtime-types.d.ts +14 -0
- package/dist/core/extensions/capability-runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/capability-runtime-types.js +7 -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 +144 -42
- package/dist/core/extensions/capability-runtime.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/virtual-modules.js +12 -4
- 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 +1 -1
- package/dist/core/facade/coding-agent-facade.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-final.d.ts +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-final.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-final.js +3 -3
- package/dist/core/i18n/locales/zh-cn/core-contract-final.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-plugins.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-plugins.js +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-plugins.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 +1 -1
- package/dist/core/i18n/locales/zh-cn/core-errors.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/tui-components-misc.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/tui-components-misc.js +2 -0
- package/dist/core/i18n/locales/zh-cn/tui-components-misc.js.map +1 -1
- package/dist/core/model-resolver.d.ts +2 -0
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +4 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/package-resource-collection.d.ts.map +1 -1
- package/dist/core/package-resource-collection.js +5 -5
- package/dist/core/package-resource-collection.js.map +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +3 -3
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +1 -1
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +6 -7
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +4 -4
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +5 -10
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js +1 -3
- package/dist/core/timings.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +1 -1
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/tool-definition.d.ts +1 -1
- package/dist/core/tools/tool-definition.d.ts.map +1 -1
- package/dist/core/tools/tool-definition.js.map +1 -1
- package/dist/core/trace-retention.d.ts +16 -1
- package/dist/core/trace-retention.d.ts.map +1 -1
- package/dist/core/trace-retention.js +43 -20
- package/dist/core/trace-retention.js.map +1 -1
- package/dist/export-html/ansi-to-html.d.ts.map +1 -0
- package/dist/export-html/ansi-to-html.js.map +1 -0
- package/dist/{core/export-html → export-html}/index.d.ts +1 -1
- package/dist/export-html/index.d.ts.map +1 -0
- package/dist/{core/export-html → export-html}/index.js +5 -5
- package/dist/export-html/index.js.map +1 -0
- package/dist/{core/export-html → export-html}/tool-renderer.d.ts +2 -2
- package/dist/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/export-html/tool-renderer.js.map +1 -0
- package/dist/{modes/interactive → host}/model-catalog-refresh.d.ts +1 -1
- package/dist/host/model-catalog-refresh.d.ts.map +1 -0
- package/dist/{modes/interactive → host}/model-catalog-refresh.js +1 -1
- package/dist/host/model-catalog-refresh.js.map +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +25 -14
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/agents-view.d.ts.map +1 -1
- package/dist/modes/interactive/components/agents-view.js +1 -1
- package/dist/modes/interactive/components/agents-view.js.map +1 -1
- package/dist/modes/interactive/components/armin.d.ts.map +1 -1
- package/dist/modes/interactive/components/armin.js +1 -1
- package/dist/modes/interactive/components/armin.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 +83 -24
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +1 -1
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +1 -1
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js +1 -1
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +1 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
- package/dist/modes/interactive/components/daxnuts.js +1 -1
- package/dist/modes/interactive/components/daxnuts.js.map +1 -1
- package/dist/modes/interactive/components/dialog-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/dialog-editor.js +1 -1
- package/dist/modes/interactive/components/dialog-editor.js.map +1 -1
- package/dist/modes/interactive/components/dialog-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/dialog-input.js +1 -1
- package/dist/modes/interactive/components/dialog-input.js.map +1 -1
- package/dist/modes/interactive/components/dialog-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/dialog-selector.js +1 -1
- package/dist/modes/interactive/components/dialog-selector.js.map +1 -1
- package/dist/modes/interactive/components/diff.d.ts.map +1 -1
- package/dist/modes/interactive/components/diff.js +1 -1
- package/dist/modes/interactive/components/diff.js.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js +1 -1
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.js +1 -1
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +1 -1
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/mermaid.d.ts +1 -1
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
- package/dist/modes/interactive/components/mermaid.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +2 -2
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +1 -1
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/plugin-manager-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/plugin-manager-entry.js +1 -1
- package/dist/modes/interactive/components/plugin-manager-entry.js.map +1 -1
- package/dist/modes/interactive/components/plugin-selection-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/plugin-selection-entry.js +1 -1
- package/dist/modes/interactive/components/plugin-selection-entry.js.map +1 -1
- package/dist/modes/interactive/components/queue-manager-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/queue-manager-selector.js +1 -1
- package/dist/modes/interactive/components/queue-manager-selector.js.map +1 -1
- package/dist/modes/interactive/components/render-types.d.ts +1 -1
- package/dist/modes/interactive/components/render-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/render-types.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +2 -2
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +1 -1
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.js +1 -1
- package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.js +1 -1
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +1 -1
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/theme-selector.js +1 -1
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +1 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +2 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +96 -4
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-run-group.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-run-group.js +1 -1
- package/dist/modes/interactive/components/tool-run-group.js.map +1 -1
- package/dist/modes/interactive/components/tree-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-list.js +1 -1
- package/dist/modes/interactive/components/tree-list.js.map +1 -1
- package/dist/modes/interactive/components/tree-render.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-render.js +1 -1
- package/dist/modes/interactive/components/tree-render.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +1 -1
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +1 -1
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +1 -1
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/workflow-view.d.ts.map +1 -1
- package/dist/modes/interactive/components/workflow-view.js +1 -1
- package/dist/modes/interactive/components/workflow-view.js.map +1 -1
- package/dist/modes/interactive/interactive-auth.d.ts +1 -1
- package/dist/modes/interactive/interactive-auth.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-auth.js +1 -1
- package/dist/modes/interactive/interactive-auth.js.map +1 -1
- package/dist/modes/interactive/interactive-commands.d.ts +123 -6
- package/dist/modes/interactive/interactive-commands.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-commands.js +691 -4
- package/dist/modes/interactive/interactive-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-events.d.ts +174 -0
- package/dist/modes/interactive/interactive-events.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-events.js +704 -0
- package/dist/modes/interactive/interactive-events.js.map +1 -0
- package/dist/modes/interactive/interactive-format.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-format.js +1 -1
- package/dist/modes/interactive/interactive-format.js.map +1 -1
- package/dist/modes/interactive/interactive-lifecycle.d.ts +94 -0
- package/dist/modes/interactive/interactive-lifecycle.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-lifecycle.js +177 -0
- package/dist/modes/interactive/interactive-lifecycle.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +240 -133
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +251 -2159
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/interactive-queues.d.ts +96 -0
- package/dist/modes/interactive/interactive-queues.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-queues.js +183 -0
- package/dist/modes/interactive/interactive-queues.js.map +1 -0
- package/dist/modes/interactive/interactive-selectors.d.ts +95 -5
- package/dist/modes/interactive/interactive-selectors.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +517 -6
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/startup-services.d.ts +31 -0
- package/dist/modes/interactive/startup-services.d.ts.map +1 -0
- package/dist/modes/interactive/startup-services.js +123 -0
- package/dist/modes/interactive/startup-services.js.map +1 -0
- package/dist/modes/memory-preheat.d.ts +11 -0
- package/dist/modes/memory-preheat.d.ts.map +1 -0
- package/dist/modes/memory-preheat.js +20 -0
- package/dist/modes/memory-preheat.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +3 -1
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/plugins/ecosystem/node-package-install-host.d.ts +9 -1
- package/dist/plugins/ecosystem/node-package-install-host.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-package-install-host.js +79 -0
- package/dist/plugins/ecosystem/node-package-install-host.js.map +1 -1
- package/dist/remote/server-assembly.d.ts.map +1 -1
- package/dist/remote/server-assembly.js +7 -2
- package/dist/remote/server-assembly.js.map +1 -1
- package/dist/suites/builtin-suites.d.ts.map +1 -0
- package/dist/suites/builtin-suites.js.map +1 -0
- package/dist/suites/resolved-agent-profile.d.ts.map +1 -0
- package/dist/suites/resolved-agent-profile.js.map +1 -0
- package/dist/suites/suite-lifecycle.d.ts.map +1 -0
- package/dist/suites/suite-lifecycle.js.map +1 -0
- package/dist/suites/suite-loader.d.ts.map +1 -0
- package/dist/suites/suite-loader.js.map +1 -0
- package/dist/{modes/interactive/theme → theme}/dark.json +1 -1
- package/dist/{modes/interactive/theme → theme}/light.json +1 -1
- package/dist/{modes/interactive/theme → theme}/theme-controller.d.ts +1 -1
- package/dist/theme/theme-controller.d.ts.map +1 -0
- package/dist/{modes/interactive/theme → theme}/theme-controller.js +1 -1
- package/dist/theme/theme-controller.js.map +1 -0
- package/dist/{modes/interactive/theme → theme}/theme.d.ts +1 -1
- package/dist/theme/theme.d.ts.map +1 -0
- package/dist/{modes/interactive/theme → theme}/theme.js +5 -5
- package/dist/theme/theme.js.map +1 -0
- package/docs/compaction.md +7 -7
- package/docs/environment-variables.md +10 -4
- package/docs/keybindings.md +3 -3
- package/docs/models.md +17 -17
- package/docs/packages.md +1 -1
- package/docs/prompt-templates.md +1 -1
- package/docs/rpc.md +2 -2
- package/docs/sdk.md +5 -5
- package/docs/session-format.md +3 -3
- package/docs/settings.md +15 -1
- package/docs/shell-aliases.md +1 -1
- package/docs/skills.md +1 -1
- package/docs/terminal-setup.md +17 -17
- package/docs/themes.md +5 -5
- package/docs/tmux.md +4 -4
- package/docs/tui.md +1 -1
- package/docs/usage.md +292 -292
- package/docs/windows.md +1 -1
- package/examples/extensions/bash-spawn-hook/index.ts +1 -1
- package/examples/extensions/dynamic-resources/dynamic.json +1 -1
- package/examples/extensions/mcp-stdio/index.d.ts +64 -0
- package/examples/extensions/mcp-stdio/index.d.ts.map +1 -0
- package/examples/extensions/mcp-stdio/index.js +292 -0
- package/examples/extensions/mcp-stdio/index.js.map +1 -0
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -6
- package/examples/extensions/with-deps/plugin.json +1 -1
- package/package.json +2 -2
- package/dist/bundle/chunks/openai-responses-AUJQ3NWT.js +0 -2
- package/dist/bundle/chunks/virtual-modules-MRXD3RWG.js +0 -5
- package/dist/cli/experimental/commands/pi.d.ts +0 -15
- package/dist/cli/experimental/commands/pi.d.ts.map +0 -1
- package/dist/cli/experimental/commands/pi.js.map +0 -1
- package/dist/core/export-html/ansi-to-html.d.ts.map +0 -1
- package/dist/core/export-html/ansi-to-html.js.map +0 -1
- package/dist/core/export-html/index.d.ts.map +0 -1
- package/dist/core/export-html/index.js.map +0 -1
- package/dist/core/export-html/tool-renderer.d.ts.map +0 -1
- package/dist/core/export-html/tool-renderer.js.map +0 -1
- package/dist/core/pi-manifest.d.ts +0 -7
- package/dist/core/pi-manifest.d.ts.map +0 -1
- package/dist/core/pi-manifest.js.map +0 -1
- package/dist/modes/interactive/model-catalog-refresh.d.ts.map +0 -1
- package/dist/modes/interactive/model-catalog-refresh.js.map +0 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +0 -1
- package/dist/modes/interactive/theme/theme-controller.js.map +0 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +0 -1
- package/dist/modes/interactive/theme/theme.js.map +0 -1
- package/dist/profiles/builtin-suites.d.ts.map +0 -1
- package/dist/profiles/builtin-suites.js.map +0 -1
- package/dist/profiles/resolved-agent-profile.d.ts.map +0 -1
- package/dist/profiles/resolved-agent-profile.js.map +0 -1
- package/dist/profiles/suite-lifecycle.d.ts.map +0 -1
- package/dist/profiles/suite-lifecycle.js.map +0 -1
- package/dist/profiles/suite-loader.d.ts.map +0 -1
- package/dist/profiles/suite-loader.js.map +0 -1
- package/dist/utils/deprecation.d.ts +0 -4
- package/dist/utils/deprecation.d.ts.map +0 -1
- package/dist/utils/deprecation.js +0 -13
- package/dist/utils/deprecation.js.map +0 -1
- /package/dist/{core/export-html → export-html}/ansi-to-html.d.ts +0 -0
- /package/dist/{core/export-html → export-html}/ansi-to-html.js +0 -0
- /package/dist/{core/export-html → export-html}/template.css +0 -0
- /package/dist/{core/export-html → export-html}/template.html +0 -0
- /package/dist/{core/export-html → export-html}/template.js +0 -0
- /package/dist/{core/export-html → export-html}/tool-renderer.js +0 -0
- /package/dist/{core/export-html → export-html}/vendor/highlight.min.js +0 -0
- /package/dist/{core/export-html → export-html}/vendor/marked.min.js +0 -0
- /package/dist/{profiles → suites}/builtin-suites.d.ts +0 -0
- /package/dist/{profiles → suites}/builtin-suites.js +0 -0
- /package/dist/{profiles → suites}/resolved-agent-profile.d.ts +0 -0
- /package/dist/{profiles → suites}/resolved-agent-profile.js +0 -0
- /package/dist/{profiles → suites}/suite-lifecycle.d.ts +0 -0
- /package/dist/{profiles → suites}/suite-lifecycle.js +0 -0
- /package/dist/{profiles → suites}/suite-loader.d.ts +0 -0
- /package/dist/{profiles → suites}/suite-loader.js +0 -0
- /package/dist/{modes/interactive/theme → theme}/theme-schema.json +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtin-suites.js","sourceRoot":"","sources":["../../src/suites/builtin-suites.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAEzC,yFAAoF;AACpF,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAEtC,2FAAqF;AACrF,MAAM,CAAC,MAAM,mBAAmB,GAAsB;IACrD,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,IAAI;IACJ,MAAM;IACN,MAAM;IACN,YAAY;CACZ,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAsB;IAC5D,cAAc;IACd,cAAc;IACd,kBAAkB;IAClB,kBAAkB;IAClB,gBAAgB;IAChB,uBAAuB;IACvB,2BAA2B;IAC3B,sBAAsB;CACtB,CAAC;AAKF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAA2C;IAC1E,SAAS,EAAE;;;;;;+HAMmH;IAC9H,MAAM,EAAE;;;;;;;;sGAQ6F;CACrG,CAAC;AA4CF,MAAM,kBAAkB,GAAsB,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAA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;QAC1F,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,OAAO,KAAK,CAAC;AAAA,CACb;AAED,SAAS,cAAc,CAAC,KAAc,EAAE,MAAgB,EAA0B;IACjF,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACvD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACvD,MAAM,CAAC,IAAI,CAAC,yDAAyD,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC9F,OAAO,IAAI,CAAC;IACb,CAAC;IACD,MAAM,MAAM,GAAG,KAAgC,CAAC;IAChD,IACC,OAAO,MAAM,CAAC,EAAE,KAAK,QAAQ;QAC7B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;QAC7B,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ;QACjC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;QACjC,OAAO,MAAM,CAAC,EAAE,KAAK,QAAQ;QAC7B,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,EAC/B,CAAC;QACF,MAAM,CAAC,IAAI,CACV,0FAA0F,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CACjH,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;AAAA,CAC/D","sourcesContent":["/**\n * Builtin suite (方案) declarations and suite.json (schemaVersion 1)\n * serialization, parsing, and validation — 方案系统设计.md v2 §5/§6/§9, M1a.\n *\n * Suites are pure data plus default policy: both builtin suites share the same\n * unrestricted tool surface and differ only in orientation and memory strategy\n * (the orientation persona text is injected into the system prompt, M2).\n * Nothing here touches the packages/agent kernel; association resolution is\n * declaration-only until M1b.\n */\n\nexport const SUITE_SCHEMA_VERSION = 1;\n\n/**\n * Factory contents revision (M4): the revision of the factory builtin\n * declarations, independent of SUITE_SCHEMA_VERSION. Bump it (and update both\n * builtin declarations' `factoryRevision`) whenever the factory contents\n * change; the registry upgrade proposal then offers `--suite-reset` for\n * workspaces still on an older revision. Suite schema evolution keeps using\n * SUITE_SCHEMA_VERSION.\n *\n * Revision 2 (统一修复轮集成收口, 2026-09-08): assistant and coding now share\n * the same active 8-tool surface in full-control — the sdk `suiteToolOverride`\n * DEFAULT_SUITE_ID exemption was removed (方案设计 §5 + user decision). Existing\n * workspaces provisioned at revision 1 receive the upgrade-proposal diagnostic\n * and adopt via `--suite-reset`.\n *\n * Revision 3 (2026-09-18): `builtin.session-share` joins both builtin suites\n * (开发计划 §216: session-share productized from the example plugin into a\n * first-party default-distributed capability) once the agent-dir config\n * channel for embedded capabilities landed\n * (`<agentDir>/capabilities/<short-id>.json`, see capabilities/builtin.ts).\n * Existing workspaces provisioned at revision 2 receive the upgrade-proposal\n * diagnostic and adopt via `--suite-reset`.\n *\n * Revision 4 (2026-09-18): `builtin.subagent-delegate` joins both builtin\n * suites — the first-party subagent delegation tool (`subagent_run`) now ships\n * by default in shared mode (zero extra processes; pooled runner processes stay\n * opt-in through the capability config channel). Existing workspaces\n * provisioned at revision 3 receive the upgrade-proposal diagnostic and adopt\n * via `--suite-reset`.\n *\n * Revision 5 (2026-09-20): subagent role profiles land on disk only\n * (`<agentDir>/roles/<id>.json` — the factory seeds explore/reviewer and never\n * overwrites user edits) and both builtin suites associate them by default via\n * the new `suite.associations.roles` field, with skill/MCP-isomorphic\n * visibility: unassociated roles stay invisible, associated-but-missing files\n * surface as dangling diagnostics. Existing workspaces provisioned at\n * revision 4 receive the upgrade-proposal diagnostic and adopt via\n * `--suite-reset`.\n *\n * Revision 6 (D-077, 2026-10-02): `builtin.workflow` joins both builtin suites\n * — the workflow orchestration plugin enters the factory bootstrap manifest\n * (ninth package) and the suite capability declaration at goal/plan/todo-set\n * parity, keeping its plugin form. Existing workspaces provisioned at revision\n * 5 receive the upgrade-proposal diagnostic and adopt via `--suite-reset`.\n *\n * Revision 7 (视觉保底, 2026-10-04): the two visual baseline roles\n * `design-proposer` / `visual-reviewer` join the factory seeds and the default\n * `associations.roles` (user ruling \"术有专攻、角色隔离\"; role files are\n * disk-only and the seeds never overwrite user edits — see\n * `docs/plans/视觉保底角色设计注记.md`). Existing workspaces provisioned at\n * revision 6 receive the upgrade-proposal diagnostic and adopt via\n * `--suite-reset`.\n */\nexport const FACTORY_CONTENTS_VERSION = 7;\n\n/**\n * Factory default suite used when no suite is configured anywhere (设计 §9).\n * 2026-10-02 user ruling: the product is a coding agent, so the factory\n * default flipped from \"assistant\" to \"coding\"; assistant stays as the\n * explicit-switch fallback suite.\n */\nexport const DEFAULT_SUITE_ID = \"coding\";\n\n/** Suite ids become directory names: lowercase letters, digits, hyphens (设计 §9). */\nexport const SUITE_ID_MAX_LENGTH = 64;\n\n/** The single unrestricted tool surface shared by both builtin suites (设计 §5/§6). */\nexport const BUILTIN_SUITE_TOOLS: readonly string[] = [\n\t\"read\",\n\t\"write\",\n\t\"edit\",\n\t\"bash\",\n\t\"ls\",\n\t\"find\",\n\t\"grep\",\n\t\"powershell\",\n];\n\n/**\n * Builtin capability plugins associated with both suites. Declaration-only\n * data in M1a; the actual plugin wiring is delivered in M3. `builtin.memory`\n * joins in the 统一修复轮 A 路 (方案系统设计 §6.1: both suites share the same\n * memory tool surface; the strategy difference lives in the suiteId domain\n * isolation and the assistant preference card). `builtin.session-share` joins\n * in the session-share productization slice (开发计划 §216); its\n * target/gateway/viewerUrl are configured through the agent-dir config\n * channel (`<agentDir>/capabilities/builtin.session-share.json`), and the\n * unconfigured default answers `/share` with the explicit configuration\n * prompt — never an implicit Radius/Gist fallback. `builtin.workflow` joins\n * at goal/plan/todo-set parity (D-077, 2026-10-02: factory default install\n * plus this suite declaration, plugin form unchanged). `builtin.coding-tools`\n * joins with the D-082 batch-1 tool split (2026-10-03): the default coding\n * tools assemble from the `plugins/coding-tools` package through the bundled\n * distribution channel (插件独立分发与启动装配设计 §4.9), not the install\n * store.\n */\nexport const BUILTIN_SUITE_CAPABILITIES: readonly string[] = [\n\t\"builtin.goal\",\n\t\"builtin.plan\",\n\t\"builtin.todo-set\",\n\t\"builtin.workflow\",\n\t\"builtin.memory\",\n\t\"builtin.session-share\",\n\t\"builtin.subagent-delegate\",\n\t\"builtin.coding-tools\",\n];\n\nexport type SuiteMemoryStrategy = \"assistant\" | \"code\";\nexport type SuiteOrientation = \"assistant\" | \"coding\" | \"custom\";\n\n/**\n * Orientation persona texts injected into the system prompt (设计 §6.2, M2).\n * The strings are verbatim from the design spec: the assistant persona is the\n * companion style, the coding persona is the rigor-first style. Both are\n * session-nature declarations, so they ride every system prompt branch\n * (default and customPrompt). The custom orientation is not in this table: its\n * persona text comes from the suite workspace persona.md (设计 §6.3, resolved\n * by suite-loader).\n */\nexport const ORIENTATION_PROMPTS: Record<\"assistant\" | \"coding\", string> = {\n\tassistant: `You are the user's thoughtful companion — warm, patient, and helpful.\n- Understand the intent behind the question, including the unspoken parts; when something that matters is ambiguous, ask one short clarifying question instead of assuming.\n- Pay attention to detail: notice what the user might have missed and gently point it out.\n- Be proactive and divergent: after answering, offer next steps, related ideas, or creative alternatives — without being pushy.\n- Adapt tone to the user; stay natural and flexible, never robotic or formulaic.\n- When you can help by doing, act through tools autonomously (minimal interruption).\n- Structure longer answers clearly: short paragraphs, lists where they help, and a concrete \"what you can do next\" at the end.`,\n\tcoding: `You are an autonomous software engineering agent with a rigor-first mindset.\n- Never guess. Ground every claim in code you have read, commands you have run, or documented evidence; cite file paths and line numbers. If the evidence is insufficient, investigate, and report what is unverified — or \"unknown\" — instead of a plausible invention.\n- First principles: trace problems to the earliest reasonable root cause and fix that; do not patch symptoms.\n- No over-engineering: add no abstraction, options, or defensive handling for imagined future needs; generalise only when a second concrete case demands it.\n- Tests first: pin expected behavior with a failing or updated test before or alongside the fix, then run the smallest sufficient relevant checks; the work is not done until they pass.\n- Reproducible: prefer deterministic tests and mocks over ad-hoc verification, and report the exact commands and results so others can re-run them.\n- Docs as code: repository documentation is part of the change — keep design docs, READMEs, and changelogs consistent with the behavior they describe.\n- Self-review before finishing: re-check your changes for correctness, edge cases, regressions, and missing tests; prefer a second review pass over shipping the first draft.\n- Cautious: weigh side effects, compatibility, and failure modes; when in doubt, take the safer path.`,\n};\n\nexport interface SuiteAssociations {\n\treadonly skills: readonly string[];\n\treadonly mcp: readonly string[];\n\treadonly plugins: readonly string[];\n\t/**\n\t * 子代理角色关联(D-044 角色机制):关联的是 `<agentDir>/roles/<id>.json` 里的角色 id。\n\t * 角色定义只在磁盘上(工厂仅做种子落盘),方案只决定哪些角色对主代理可见——与\n\t * skill/MCP/插件同构,第一方与第三方角色没有区别。\n\t */\n\treadonly roles: readonly string[];\n}\n\nexport interface SuiteClonedFrom {\n\treadonly id: string;\n\treadonly digest: string;\n\treadonly at: number;\n}\n\n/** The serializable suite definition persisted as suite.json (设计 §5). */\nexport interface SuiteDefinition {\n\treadonly schemaVersion: number;\n\treadonly id: string;\n\treadonly name: string;\n\treadonly builtin: boolean;\n\treadonly tools: readonly string[];\n\treadonly capabilities: readonly string[];\n\treadonly associations: SuiteAssociations;\n\treadonly inheritSystemAgentsMd: boolean;\n\treadonly memory: SuiteMemoryStrategy;\n\treadonly orientation: SuiteOrientation;\n\treadonly model: string | null;\n\treadonly thinking: string | null;\n\treadonly clonedFrom: SuiteClonedFrom | null;\n\t/**\n\t * Factory contents revision this declaration was written at (M4). Builtin\n\t * declarations carry it; on-disk builtin suite.json may omit it (pre-M4\n\t * files parse as FACTORY_CONTENTS_VERSION). User suites are outside factory\n\t * upgrade governance: the key stays optional and may be absent.\n\t */\n\treadonly factoryRevision?: number;\n}\n\nconst EMPTY_ASSOCIATIONS: SuiteAssociations = { skills: [], mcp: [], plugins: [], roles: [] };\n\n/**\n * 默认方案关联的子代理角色(开箱即用):这四个 id 对应工厂种子落盘的四个普通角色文件\n * (`<agentDir>/roles/{explore,reviewer,design-proposer,visual-reviewer}.json`,用户可改可删)。\n * design-proposer / visual-reviewer 是视觉保底角色(2026-10-04 用户裁决\"术有专攻、角色隔离\"),\n * 档案 readonly + 只读工具收窄,与编码角色结构性隔离——见 docs/plans/视觉保底角色设计注记.md。\n * 工厂不在运行期回退到任何编译内的角色定义;删掉文件只会让该关联成为 dangling 诊断。\n */\nexport const DEFAULT_ROLE_ASSOCIATIONS: readonly string[] = [\n\t\"explore\",\n\t\"reviewer\",\n\t\"design-proposer\",\n\t\"visual-reviewer\",\n];\n\nconst assistantSuite: SuiteDefinition = {\n\tschemaVersion: SUITE_SCHEMA_VERSION,\n\tid: \"assistant\",\n\tname: \"Assistant\",\n\tbuiltin: true,\n\ttools: BUILTIN_SUITE_TOOLS,\n\tcapabilities: BUILTIN_SUITE_CAPABILITIES,\n\tassociations: { ...EMPTY_ASSOCIATIONS, roles: DEFAULT_ROLE_ASSOCIATIONS },\n\tinheritSystemAgentsMd: false,\n\tmemory: \"assistant\",\n\torientation: \"assistant\",\n\tmodel: null,\n\tthinking: null,\n\tclonedFrom: null,\n\tfactoryRevision: FACTORY_CONTENTS_VERSION,\n};\n\nconst codingSuite: SuiteDefinition = {\n\tschemaVersion: SUITE_SCHEMA_VERSION,\n\tid: \"coding\",\n\tname: \"Coding\",\n\tbuiltin: true,\n\ttools: BUILTIN_SUITE_TOOLS,\n\tcapabilities: BUILTIN_SUITE_CAPABILITIES,\n\tassociations: { ...EMPTY_ASSOCIATIONS, roles: DEFAULT_ROLE_ASSOCIATIONS },\n\tinheritSystemAgentsMd: false,\n\tmemory: \"code\",\n\torientation: \"coding\",\n\tmodel: null,\n\tthinking: null,\n\tclonedFrom: null,\n\tfactoryRevision: FACTORY_CONTENTS_VERSION,\n};\n\n/** The factory builtin pair: coding (factory default 尖刀) and assistant (fallback). */\nexport const BUILTIN_SUITES: readonly SuiteDefinition[] = [assistantSuite, codingSuite];\n\nexport function getBuiltinSuite(id: string): SuiteDefinition | undefined {\n\treturn BUILTIN_SUITES.find((suite) => suite.id === id);\n}\n\nexport function isBuiltinSuiteId(id: string): boolean {\n\treturn BUILTIN_SUITES.some((suite) => suite.id === id);\n}\n\nconst WINDOWS_RESERVED_IDS = new Set([\n\t\"con\",\n\t\"prn\",\n\t\"aux\",\n\t\"nul\",\n\t\"com1\",\n\t\"com2\",\n\t\"com3\",\n\t\"com4\",\n\t\"com5\",\n\t\"com6\",\n\t\"com7\",\n\t\"com8\",\n\t\"com9\",\n\t\"lpt1\",\n\t\"lpt2\",\n\t\"lpt3\",\n\t\"lpt4\",\n\t\"lpt5\",\n\t\"lpt6\",\n\t\"lpt7\",\n\t\"lpt8\",\n\t\"lpt9\",\n\t\"conin$\",\n\t\"conout$\",\n]);\n\n/** Suite id rule (设计 §9): `a-z0-9-`, no leading/trailing hyphen, no Windows reserved names. */\nexport function isValidSuiteId(id: string): boolean {\n\tif (id.length === 0 || id.length > SUITE_ID_MAX_LENGTH) return false;\n\tif (!/^[a-z0-9-]+$/.test(id)) return false;\n\tif (id.startsWith(\"-\") || id.endsWith(\"-\")) return false;\n\tif (WINDOWS_RESERVED_IDS.has(id)) return false;\n\treturn true;\n}\n\n/** Serializes a suite to the canonical suite.json text (stable field order, trailing newline). */\nexport function serializeSuiteJson(suite: SuiteDefinition): string {\n\tconst ordered = {\n\t\tschemaVersion: suite.schemaVersion,\n\t\tid: suite.id,\n\t\tname: suite.name,\n\t\tbuiltin: suite.builtin,\n\t\ttools: [...suite.tools],\n\t\tcapabilities: [...suite.capabilities],\n\t\tassociations: {\n\t\t\tskills: [...suite.associations.skills],\n\t\t\tmcp: [...suite.associations.mcp],\n\t\t\tplugins: [...suite.associations.plugins],\n\t\t\troles: [...suite.associations.roles],\n\t\t},\n\t\tinheritSystemAgentsMd: suite.inheritSystemAgentsMd,\n\t\tmemory: suite.memory,\n\t\torientation: suite.orientation,\n\t\tmodel: suite.model,\n\t\tthinking: suite.thinking,\n\t\tclonedFrom: suite.clonedFrom\n\t\t\t? { id: suite.clonedFrom.id, digest: suite.clonedFrom.digest, at: suite.clonedFrom.at }\n\t\t\t: null,\n\t\tfactoryRevision: suite.factoryRevision,\n\t};\n\treturn `${JSON.stringify(ordered, null, 2)}\\n`;\n}\n\nexport interface SuiteJsonParseResult {\n\treadonly valid: boolean;\n\treadonly suite?: SuiteDefinition;\n\treadonly errors: readonly string[];\n}\n\n/**\n * Parses suite.json text. Never throws: an invalid result carries every\n * validation error so callers can apply the corruption policy (设计 §9) —\n * builtin suites fall back to factory content, user suites fail fast.\n */\nexport function parseSuiteJson(\n\traw: string,\n\toptions: { expectedBuiltin?: boolean; expectedId?: string },\n): SuiteJsonParseResult {\n\tlet value: unknown;\n\ttry {\n\t\tvalue = JSON.parse(raw);\n\t} catch (error) {\n\t\treturn {\n\t\t\tvalid: false,\n\t\t\terrors: [`invalid JSON: ${error instanceof Error ? error.message : String(error)}`],\n\t\t};\n\t}\n\treturn validateSuiteJson(value, options);\n}\n\nexport function validateSuiteJson(\n\tvalue: unknown,\n\toptions: { expectedBuiltin?: boolean; expectedId?: string } = {},\n): SuiteJsonParseResult {\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n\t\treturn { valid: false, errors: [\"suite.json must be a JSON object\"] };\n\t}\n\tconst record = value as Record<string, unknown>;\n\tconst errors: string[] = [];\n\n\tif (record.schemaVersion !== SUITE_SCHEMA_VERSION) {\n\t\terrors.push(`schemaVersion must be ${SUITE_SCHEMA_VERSION}, found ${JSON.stringify(record.schemaVersion)}`);\n\t}\n\n\t// Each field keeps a typed local: valid values land here, invalid ones only\n\t// contribute errors. The suite below is constructed exclusively when\n\t// `errors` is empty, so the fallbacks/coercions at that point are dead.\n\tconst idValue = record.id;\n\tconst id = typeof idValue === \"string\" && isValidSuiteId(idValue) ? idValue : undefined;\n\tif (id === undefined) {\n\t\terrors.push(\n\t\t\t`id must be a suite id (^[a-z0-9-]+$, no leading/trailing hyphen, Windows reserved names rejected), found ${JSON.stringify(idValue)}`,\n\t\t);\n\t} else if (options.expectedId !== undefined && id !== options.expectedId) {\n\t\terrors.push(`id \"${id}\" does not match the suite workspace directory id \"${options.expectedId}\"`);\n\t}\n\n\tconst nameValue = record.name;\n\tconst name = typeof nameValue === \"string\" && nameValue.trim().length > 0 ? nameValue : undefined;\n\tif (name === undefined) {\n\t\terrors.push(`name must be a non-empty string, found ${JSON.stringify(nameValue)}`);\n\t}\n\n\tconst builtinValue = record.builtin;\n\tconst builtin = typeof builtinValue === \"boolean\" ? builtinValue : undefined;\n\tif (builtin === undefined) {\n\t\terrors.push(`builtin must be a boolean, found ${JSON.stringify(builtinValue)}`);\n\t} else if (options.expectedBuiltin === true && builtin !== true) {\n\t\terrors.push(`builtin must be true for a builtin suite workspace, found ${builtin}`);\n\t}\n\n\tconst tools = readStringArray(record, \"tools\", errors);\n\tconst capabilities = readStringArray(record, \"capabilities\", errors);\n\tconst associations = readAssociations(record.associations, errors);\n\n\tconst inheritValue = record.inheritSystemAgentsMd;\n\tconst inheritSystemAgentsMd = typeof inheritValue === \"boolean\" ? inheritValue : undefined;\n\tif (inheritSystemAgentsMd === undefined) {\n\t\terrors.push(`inheritSystemAgentsMd must be a boolean, found ${JSON.stringify(inheritValue)}`);\n\t}\n\n\tconst memoryValue = record.memory;\n\tconst memory = memoryValue === \"assistant\" || memoryValue === \"code\" ? memoryValue : undefined;\n\tif (memory === undefined) {\n\t\terrors.push(`memory must be \"assistant\" or \"code\", found ${JSON.stringify(memoryValue)}`);\n\t}\n\n\tconst orientationValue = record.orientation;\n\tconst orientation =\n\t\torientationValue === \"assistant\" || orientationValue === \"coding\" || orientationValue === \"custom\"\n\t\t\t? orientationValue\n\t\t\t: undefined;\n\tif (orientationValue !== undefined && orientation === undefined) {\n\t\terrors.push(`orientation must be \"assistant\", \"coding\", or \"custom\", found ${JSON.stringify(orientationValue)}`);\n\t}\n\n\tconst model = readOptionalString(record, \"model\", errors);\n\tconst thinking = readOptionalString(record, \"thinking\", errors);\n\tconst clonedFrom = readClonedFrom(record.clonedFrom, errors);\n\tconst factoryRevision = readFactoryRevision(record.factoryRevision, options.expectedBuiltin === true, errors);\n\n\tif (errors.length > 0) return { valid: false, errors };\n\n\treturn {\n\t\tvalid: true,\n\t\terrors: [],\n\t\tsuite: {\n\t\t\tschemaVersion: SUITE_SCHEMA_VERSION,\n\t\t\tid: id!,\n\t\t\tname: name!,\n\t\t\tbuiltin: builtin!,\n\t\t\ttools,\n\t\t\tcapabilities,\n\t\t\tassociations,\n\t\t\tinheritSystemAgentsMd: inheritSystemAgentsMd!,\n\t\t\tmemory: memory!,\n\t\t\torientation: orientation ?? \"assistant\",\n\t\t\tmodel,\n\t\t\tthinking,\n\t\t\tclonedFrom,\n\t\t\t...(factoryRevision === undefined ? {} : { factoryRevision }),\n\t\t},\n\t};\n}\n\nfunction readStringArray(record: Record<string, unknown>, key: string, errors: string[]): readonly string[] {\n\tconst value = record[key];\n\tif (!Array.isArray(value)) {\n\t\terrors.push(`${key} must be an array of strings, found ${JSON.stringify(value)}`);\n\t\treturn [];\n\t}\n\tconst entries: string[] = [];\n\tconst seen = new Set<string>();\n\tfor (const item of value) {\n\t\tif (typeof item !== \"string\" || item.trim().length === 0) {\n\t\t\terrors.push(`${key} entries must be non-empty strings, found ${JSON.stringify(item)}`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (seen.has(item)) {\n\t\t\terrors.push(`${key} contains duplicate entry \"${item}\"`);\n\t\t\tcontinue;\n\t\t}\n\t\tseen.add(item);\n\t\tentries.push(item);\n\t}\n\treturn entries;\n}\n\nfunction readAssociations(value: unknown, errors: string[]): SuiteAssociations {\n\tif (value === undefined) return { skills: [], mcp: [], plugins: [], roles: [] };\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n\t\terrors.push(\n\t\t\t`associations must be an object with skills/mcp/plugins/roles arrays, found ${JSON.stringify(value)}`,\n\t\t);\n\t\treturn { skills: [], mcp: [], plugins: [], roles: [] };\n\t}\n\tconst record = value as Record<string, unknown>;\n\t// A key left out entirely means an empty list, consistent with a fully\n\t// absent `associations` object; a key that is present but malformed still\n\t// reports its errors. The removed legacy `extensions` kind is ignored on\n\t// read (it lost its loader with the old ExtensionAPI surface).\n\treturn {\n\t\tskills: record.skills === undefined ? [] : readStringArray(record, \"skills\", errors),\n\t\tmcp: record.mcp === undefined ? [] : readStringArray(record, \"mcp\", errors),\n\t\tplugins: record.plugins === undefined ? [] : readStringArray(record, \"plugins\", errors),\n\t\troles: record.roles === undefined ? [] : readStringArray(record, \"roles\", errors),\n\t};\n}\n\nfunction readOptionalString(record: Record<string, unknown>, key: string, errors: string[]): string | null {\n\tconst value = record[key];\n\tif (value === undefined || value === null) return null;\n\tif (typeof value !== \"string\" || value.trim().length === 0) {\n\t\terrors.push(`${key} must be a non-empty string or null, found ${JSON.stringify(value)}`);\n\t\treturn null;\n\t}\n\treturn value;\n}\n\n/**\n * Reads the optional `factoryRevision` key (M4). A missing key means\n * FACTORY_CONTENTS_VERSION for builtin workspaces (pre-M4 on-disk files stay\n * compatible) and stays absent for user suites (outside factory upgrade\n * governance). A present key must be a positive integer.\n */\nfunction readFactoryRevision(value: unknown, expectedBuiltin: boolean, errors: string[]): number | undefined {\n\tif (value === undefined) return expectedBuiltin ? FACTORY_CONTENTS_VERSION : undefined;\n\tif (typeof value !== \"number\" || !Number.isSafeInteger(value) || value <= 0) {\n\t\terrors.push(`factoryRevision must be a positive integer, found ${JSON.stringify(value)}`);\n\t\treturn undefined;\n\t}\n\treturn value;\n}\n\nfunction readClonedFrom(value: unknown, errors: string[]): SuiteClonedFrom | null {\n\tif (value === undefined || value === null) return null;\n\tif (typeof value !== \"object\" || Array.isArray(value)) {\n\t\terrors.push(`clonedFrom must be an object with id/digest/at, found ${JSON.stringify(value)}`);\n\t\treturn null;\n\t}\n\tconst record = value as Record<string, unknown>;\n\tif (\n\t\ttypeof record.id !== \"string\" ||\n\t\trecord.id.trim().length === 0 ||\n\t\ttypeof record.digest !== \"string\" ||\n\t\trecord.digest.trim().length === 0 ||\n\t\ttypeof record.at !== \"number\" ||\n\t\t!Number.isSafeInteger(record.at)\n\t) {\n\t\terrors.push(\n\t\t\t`clonedFrom must be an object with non-empty id/digest strings and an integer at, found ${JSON.stringify(value)}`,\n\t\t);\n\t\treturn null;\n\t}\n\treturn { id: record.id, digest: record.digest, at: record.at };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolved-agent-profile.d.ts","sourceRoot":"","sources":["../../src/suites/resolved-agent-profile.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,MAAM,gCAAgC,GACzC;IACA,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,qFAAqF;IACrF,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC,GACD;IAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAC7D;IAAE,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,G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AS,2BAA2B,EAAE,CAAC;CAC7D;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,cAAc,CAAC;IAC1B,aAAa,CAAC,EAAE,gCAAgC,CAAC;CACjD,GAAG,sBAAsB,CAkDzB","sourcesContent":["/**\n * ResolvedAgentProfile (D-047 S4a, docs/plans/G4-resolved-agent-profile设计注记.md):\n * the immutable per-session aggregate view over the resolved suite profile.\n *\n * S4d first increment: the aggregate additionally carries a build-time\n * `diagnostics` snapshot projected from SuiteWorkspace.diagnostics and the\n * resolved plugin profile's ProfileResolutionV1.diagnostics; the existing five\n * diagnostic channels are untouched and remain the live sources.\n *\n * This is an aggregate VIEW, not a new generation mechanism: every field\n * references an existing authoritative source (字段-权威映射 in the design\n * note), resolution still happens at the existing single point\n * (createAgentSession's suite+pluginProfile assembly, once per session), and\n * the builder only re-projects those sources and deep-freezes the result. The\n * aggregate lives at the resolution layer (session creation result and host\n * references); `AgentSession` stays suite-unaware — it never enters\n * AgentSessionConfig, and the session's persisted identity authority remains\n * the suite custom entry.\n */\nimport { detachedSnapshot } from \"../core/extensions/capability-runtime-snapshot.ts\";\nimport type { PluginDiagnosticCodeV1 } from \"../plugins/ecosystem/types.ts\";\nimport type { ProfileIdentityV1 } from \"../profile/identity.ts\";\nimport type { ProfileLockVerificationV1 } from \"../profile/lock.ts\";\nimport type { BuiltinPluginProfileResolutionV1 } from \"../profile/plugin-profiles.ts\";\nimport type { SuiteWorkspace } from \"./suite-loader.ts\";\n\n/**\n * Bounded summary of the builtin plugin profile resolution: the `resolved`\n * variant carries id/version/digest/pluginIds; every other variant records the\n * variant name with its structured reason fields; an absent resolution is the\n * `none` variant. The full resolution objects stay with their existing\n * channels; the aggregate carries only this bounded projection.\n */\nexport type PluginProfileResolutionSummaryV1 =\n\t| {\n\t\t\treadonly variant: \"resolved\";\n\t\t\treadonly profileId: string;\n\t\t\treadonly profileVersion: string;\n\t\t\t/** Ecosystem resolved-manifests digest (suite-domain digest lives on `identity`). */\n\t\t\treadonly manifestDigest: string;\n\t\t\treadonly pluginIds: readonly string[];\n\t }\n\t| { readonly variant: \"not_found\"; readonly profileId: string }\n\t| { readonly variant: \"host_facts_required\"; readonly profileId: string }\n\t| {\n\t\t\treadonly variant: \"invalid_selection\";\n\t\t\treadonly profileId: string;\n\t\t\treadonly unknownPluginIds: readonly string[];\n\t\t\treadonly duplicatePluginIds: readonly string[];\n\t }\n\t| { readonly variant: \"none\" };\n\n/**\n * Unified diagnostic entry (D-047 S4d): each source keeps its own fidelity\n * behind a `source` tag — suite diagnostics are plain strings, plugin-profile\n * diagnostics keep their structured code/details. No lossy normalization.\n */\nexport type ResolvedProfileDiagnosticV1 =\n\t| { readonly source: \"suite\"; readonly message: string }\n\t| {\n\t\t\treadonly source: \"plugin-profile\";\n\t\t\treadonly code: PluginDiagnosticCodeV1;\n\t\t\treadonly message: string;\n\t\t\treadonly details?: Readonly<Record<string, string>>;\n\t };\n\n/** The immutable, deep-frozen aggregate view of one session's resolved suite profile. */\nexport interface ResolvedAgentProfileV1 {\n\treadonly suiteId: string;\n\t/** Authoritative: workspace.identity (buildSuiteProfileIdentity product, already frozen). */\n\treadonly identity: ProfileIdentityV1;\n\t/** Authoritative: the verifyProfileLock three-state result; undefined when the workspace had no persisted lock. */\n\treadonly lockVerification?: ProfileLockVerificationV1;\n\t/** Bounded summary of the plugin profile resolution; never the live resolution objects. */\n\treadonly pluginProfile: PluginProfileResolutionSummaryV1;\n\t/** Bounded path projection of the suite workspace (no live objects). */\n\treadonly workspace: {\n\t\treadonly suiteDir: string;\n\t\treadonly suiteJsonPath: string;\n\t\treadonly agentsMdPath: string;\n\t\treadonly lockPath: string;\n\t};\n\t/**\n\t * Build-time diagnostic snapshot (D-047 S4d first increment): workspace\n\t * diagnostics (suite source, in order) followed by the resolved plugin\n\t * profile's diagnostics (plugin-profile source, in order). Empty when\n\t * neither source contributed — the common no-diagnostics case.\n\t */\n\treadonly diagnostics: readonly ResolvedProfileDiagnosticV1[];\n}\n\n/**\n * Builds the deep-frozen ResolvedAgentProfileV1 from the existing\n * authoritative sources. Pure function: it assembles from `input` and returns\n * a detached (deep-cloned, recursively frozen) snapshot, so later mutation of\n * the sources can never flow into the aggregate.\n */\nexport function buildResolvedAgentProfileV1(input: {\n\tsuiteId: string;\n\tworkspace: SuiteWorkspace;\n\tpluginProfile?: BuiltinPluginProfileResolutionV1;\n}): ResolvedAgentProfileV1 {\n\tconst { workspace } = input;\n\tconst pluginProfile = input.pluginProfile;\n\tconst summary: PluginProfileResolutionSummaryV1 =\n\t\tpluginProfile === undefined\n\t\t\t? { variant: \"none\" }\n\t\t\t: pluginProfile.status === \"resolved\"\n\t\t\t\t? {\n\t\t\t\t\t\tvariant: \"resolved\",\n\t\t\t\t\t\tprofileId: pluginProfile.profile.id,\n\t\t\t\t\t\tprofileVersion: pluginProfile.profile.version,\n\t\t\t\t\t\tmanifestDigest: pluginProfile.resolution.resolvedManifest.manifestDigest,\n\t\t\t\t\t\tpluginIds: pluginProfile.resolution.resolvedManifest.plugins.map((plugin) => plugin.pluginId),\n\t\t\t\t\t}\n\t\t\t\t: pluginProfile.status === \"invalid_selection\"\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tvariant: \"invalid_selection\",\n\t\t\t\t\t\t\tprofileId: pluginProfile.profileId,\n\t\t\t\t\t\t\tunknownPluginIds: [...pluginProfile.unknownPluginIds],\n\t\t\t\t\t\t\tduplicatePluginIds: [...pluginProfile.duplicatePluginIds],\n\t\t\t\t\t\t}\n\t\t\t\t\t: pluginProfile.status === \"not_found\"\n\t\t\t\t\t\t? { variant: \"not_found\", profileId: pluginProfile.profileId }\n\t\t\t\t\t\t: { variant: \"host_facts_required\", profileId: pluginProfile.profileId };\n\tconst diagnostics: ResolvedProfileDiagnosticV1[] = [\n\t\t...workspace.diagnostics.map((message): ResolvedProfileDiagnosticV1 => ({ source: \"suite\", message })),\n\t\t...(pluginProfile?.status === \"resolved\"\n\t\t\t? pluginProfile.resolution.diagnostics.map(\n\t\t\t\t\t(diagnostic): ResolvedProfileDiagnosticV1 => ({\n\t\t\t\t\t\tsource: \"plugin-profile\",\n\t\t\t\t\t\tcode: diagnostic.code,\n\t\t\t\t\t\tmessage: diagnostic.message,\n\t\t\t\t\t\t...(diagnostic.details === undefined ? {} : { details: diagnostic.details }),\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t: []),\n\t];\n\treturn detachedSnapshot({\n\t\tsuiteId: input.suiteId,\n\t\tidentity: workspace.identity,\n\t\t...(workspace.lockVerification === undefined ? {} : { lockVerification: workspace.lockVerification }),\n\t\tpluginProfile: summary,\n\t\tworkspace: {\n\t\t\tsuiteDir: workspace.suiteDir,\n\t\t\tsuiteJsonPath: workspace.suiteJsonPath,\n\t\t\tagentsMdPath: workspace.agentsMdPath,\n\t\t\tlockPath: workspace.lockPath,\n\t\t},\n\t\tdiagnostics,\n\t});\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolved-agent-profile.js","sourceRoot":"","sources":["../../src/suites/resolved-agent-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;AAwErF;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAC,KAI3C,EAA0B;IAC1B,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IAC5B,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC;IAC1C,MAAM,OAAO,GACZ,aAAa,KAAK,SAAS;QAC1B,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE;QACrB,CAAC,CAAC,aAAa,CAAC,MAAM,KAAK,UAAU;YACpC,CAAC,CAAC;gBACA,OAAO,EAAE,UAAU;gBACnB,SAAS,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE;gBACnC,cAAc,EAAE,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CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC;aAC5E,CAAC,CACF;YACF,CAAC,CAAC,EAAE,CAAC;KACN,CAAC;IACF,OAAO,gBAAgB,CAAC;QACvB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,QAAQ,EAAE,SAAS,CAAC,QAAQ;QAC5B,GAAG,CAAC,SAAS,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,SAAS,CAAC,gBAAgB,EAAE,CAAC;QACrG,aAAa,EAAE,OAAO;QACtB,SAAS,EAAE;YACV,QAAQ,EAAE,SAAS,CAAC,QAAQ;YAC5B,aAAa,EAAE,SAAS,CAAC,aAAa;YACtC,YAAY,EAAE,SAAS,CAAC,YAAY;YACpC,QAAQ,EAAE,SAAS,CAAC,QAAQ;SAC5B;QACD,WAAW;KACX,CAAC,CAAC;AAAA,CACH","sourcesContent":["/**\n * ResolvedAgentProfile (D-047 S4a, docs/plans/G4-resolved-agent-profile设计注记.md):\n * the immutable per-session aggregate view over the resolved suite profile.\n *\n * S4d first increment: the aggregate additionally carries a build-time\n * `diagnostics` snapshot projected from SuiteWorkspace.diagnostics and the\n * resolved plugin profile's ProfileResolutionV1.diagnostics; the existing five\n * diagnostic channels are untouched and remain the live sources.\n *\n * This is an aggregate VIEW, not a new generation mechanism: every field\n * references an existing authoritative source (字段-权威映射 in the design\n * note), resolution still happens at the existing single point\n * (createAgentSession's suite+pluginProfile assembly, once per session), and\n * the builder only re-projects those sources and deep-freezes the result. The\n * aggregate lives at the resolution layer (session creation result and host\n * references); `AgentSession` stays suite-unaware — it never enters\n * AgentSessionConfig, and the session's persisted identity authority remains\n * the suite custom entry.\n */\nimport { detachedSnapshot } from \"../core/extensions/capability-runtime-snapshot.ts\";\nimport type { PluginDiagnosticCodeV1 } from \"../plugins/ecosystem/types.ts\";\nimport type { ProfileIdentityV1 } from \"../profile/identity.ts\";\nimport type { ProfileLockVerificationV1 } from \"../profile/lock.ts\";\nimport type { BuiltinPluginProfileResolutionV1 } from \"../profile/plugin-profiles.ts\";\nimport type { SuiteWorkspace } from \"./suite-loader.ts\";\n\n/**\n * Bounded summary of the builtin plugin profile resolution: the `resolved`\n * variant carries id/version/digest/pluginIds; every other variant records the\n * variant name with its structured reason fields; an absent resolution is the\n * `none` variant. The full resolution objects stay with their existing\n * channels; the aggregate carries only this bounded projection.\n */\nexport type PluginProfileResolutionSummaryV1 =\n\t| {\n\t\t\treadonly variant: \"resolved\";\n\t\t\treadonly profileId: string;\n\t\t\treadonly profileVersion: string;\n\t\t\t/** Ecosystem resolved-manifests digest (suite-domain digest lives on `identity`). */\n\t\t\treadonly manifestDigest: string;\n\t\t\treadonly pluginIds: readonly string[];\n\t }\n\t| { readonly variant: \"not_found\"; readonly profileId: string }\n\t| { readonly variant: \"host_facts_required\"; readonly profileId: string }\n\t| {\n\t\t\treadonly variant: \"invalid_selection\";\n\t\t\treadonly profileId: string;\n\t\t\treadonly unknownPluginIds: readonly string[];\n\t\t\treadonly duplicatePluginIds: readonly string[];\n\t }\n\t| { readonly variant: \"none\" };\n\n/**\n * Unified diagnostic entry (D-047 S4d): each source keeps its own fidelity\n * behind a `source` tag — suite diagnostics are plain strings, plugin-profile\n * diagnostics keep their structured code/details. No lossy normalization.\n */\nexport type ResolvedProfileDiagnosticV1 =\n\t| { readonly source: \"suite\"; readonly message: string }\n\t| {\n\t\t\treadonly source: \"plugin-profile\";\n\t\t\treadonly code: PluginDiagnosticCodeV1;\n\t\t\treadonly message: string;\n\t\t\treadonly details?: Readonly<Record<string, string>>;\n\t };\n\n/** The immutable, deep-frozen aggregate view of one session's resolved suite profile. */\nexport interface ResolvedAgentProfileV1 {\n\treadonly suiteId: string;\n\t/** Authoritative: workspace.identity (buildSuiteProfileIdentity product, already frozen). */\n\treadonly identity: ProfileIdentityV1;\n\t/** Authoritative: the verifyProfileLock three-state result; undefined when the workspace had no persisted lock. */\n\treadonly lockVerification?: ProfileLockVerificationV1;\n\t/** Bounded summary of the plugin profile resolution; never the live resolution objects. */\n\treadonly pluginProfile: PluginProfileResolutionSummaryV1;\n\t/** Bounded path projection of the suite workspace (no live objects). */\n\treadonly workspace: {\n\t\treadonly suiteDir: string;\n\t\treadonly suiteJsonPath: string;\n\t\treadonly agentsMdPath: string;\n\t\treadonly lockPath: string;\n\t};\n\t/**\n\t * Build-time diagnostic snapshot (D-047 S4d first increment): workspace\n\t * diagnostics (suite source, in order) followed by the resolved plugin\n\t * profile's diagnostics (plugin-profile source, in order). Empty when\n\t * neither source contributed — the common no-diagnostics case.\n\t */\n\treadonly diagnostics: readonly ResolvedProfileDiagnosticV1[];\n}\n\n/**\n * Builds the deep-frozen ResolvedAgentProfileV1 from the existing\n * authoritative sources. Pure function: it assembles from `input` and returns\n * a detached (deep-cloned, recursively frozen) snapshot, so later mutation of\n * the sources can never flow into the aggregate.\n */\nexport function buildResolvedAgentProfileV1(input: {\n\tsuiteId: string;\n\tworkspace: SuiteWorkspace;\n\tpluginProfile?: BuiltinPluginProfileResolutionV1;\n}): ResolvedAgentProfileV1 {\n\tconst { workspace } = input;\n\tconst pluginProfile = input.pluginProfile;\n\tconst summary: PluginProfileResolutionSummaryV1 =\n\t\tpluginProfile === undefined\n\t\t\t? { variant: \"none\" }\n\t\t\t: pluginProfile.status === \"resolved\"\n\t\t\t\t? {\n\t\t\t\t\t\tvariant: \"resolved\",\n\t\t\t\t\t\tprofileId: pluginProfile.profile.id,\n\t\t\t\t\t\tprofileVersion: pluginProfile.profile.version,\n\t\t\t\t\t\tmanifestDigest: pluginProfile.resolution.resolvedManifest.manifestDigest,\n\t\t\t\t\t\tpluginIds: pluginProfile.resolution.resolvedManifest.plugins.map((plugin) => plugin.pluginId),\n\t\t\t\t\t}\n\t\t\t\t: pluginProfile.status === \"invalid_selection\"\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tvariant: \"invalid_selection\",\n\t\t\t\t\t\t\tprofileId: pluginProfile.profileId,\n\t\t\t\t\t\t\tunknownPluginIds: [...pluginProfile.unknownPluginIds],\n\t\t\t\t\t\t\tduplicatePluginIds: [...pluginProfile.duplicatePluginIds],\n\t\t\t\t\t\t}\n\t\t\t\t\t: pluginProfile.status === \"not_found\"\n\t\t\t\t\t\t? { variant: \"not_found\", profileId: pluginProfile.profileId }\n\t\t\t\t\t\t: { variant: \"host_facts_required\", profileId: pluginProfile.profileId };\n\tconst diagnostics: ResolvedProfileDiagnosticV1[] = [\n\t\t...workspace.diagnostics.map((message): ResolvedProfileDiagnosticV1 => ({ source: \"suite\", message })),\n\t\t...(pluginProfile?.status === \"resolved\"\n\t\t\t? pluginProfile.resolution.diagnostics.map(\n\t\t\t\t\t(diagnostic): ResolvedProfileDiagnosticV1 => ({\n\t\t\t\t\t\tsource: \"plugin-profile\",\n\t\t\t\t\t\tcode: diagnostic.code,\n\t\t\t\t\t\tmessage: diagnostic.message,\n\t\t\t\t\t\t...(diagnostic.details === undefined ? {} : { details: diagnostic.details }),\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t: []),\n\t];\n\treturn detachedSnapshot({\n\t\tsuiteId: input.suiteId,\n\t\tidentity: workspace.identity,\n\t\t...(workspace.lockVerification === undefined ? {} : { lockVerification: workspace.lockVerification }),\n\t\tpluginProfile: summary,\n\t\tworkspace: {\n\t\t\tsuiteDir: workspace.suiteDir,\n\t\t\tsuiteJsonPath: workspace.suiteJsonPath,\n\t\t\tagentsMdPath: workspace.agentsMdPath,\n\t\t\tlockPath: workspace.lockPath,\n\t\t},\n\t\tdiagnostics,\n\t});\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suite-lifecycle.d.ts","sourceRoot":"","sources":["../../src/suites/suite-lifecycle.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CA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AM,EAChB,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAAO,GACxD,OAAO,CAAC,qBAAqB,CAAC,CA2BhC;AAMD,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,0EAA0E;IAC1E,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CACrC;AAED,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;;;;;;OAQG;IACH,KAAK,IAAI,qBAAqB,CAAC;CAC/B;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAAE,GAAG,cAAc,CA4FxG;AAMD,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,aAAa,EAAE,SAAS,CAAC,SAAS,GAAG,QAAQ,CAAC,EAAE,CAAC;CAC1D;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,eAAe,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,GAAG,oBAAoB,CAW7G","sourcesContent":["/**\n * Suite lifecycle operations (方案系统设计.md v2 §9, M4): create/clone,\n * delete (trash + release + sweep), reset, session reference scan, and\n * dangling settings cleanup.\n *\n * Every operation is deterministic given its inputs (`now` is injectable) and\n * reports refusal reasons as structured errors. Deletion only ever renames\n * the workspace into the trash directory — release and sweep are separate,\n * re-runnable steps — so recovery stays possible until the trash is released.\n * Memory purge is intentionally a hook: the Foundation purge gate lands with\n * M5; before that only suite assets are released.\n */\nimport { randomUUID } from \"node:crypto\";\nimport {\n\tcloseSync,\n\tcpSync,\n\texistsSync,\n\tmkdirSync,\n\topenSync,\n\treaddirSync,\n\treadFileSync,\n\treadSync,\n\trenameSync,\n\tstatSync,\n\twriteFileSync,\n} from \"node:fs\";\nimport { readdir, rm, stat } from \"node:fs/promises\";\nimport { basename, join } from \"node:path\";\nimport { StringDecoder } from \"node:string_decoder\";\nimport type { SettingsManager } from \"../core/settings-manager.ts\";\nimport { generateDiffString } from \"../core/tools/edit-diff.ts\";\nimport type { ProfileLockV1 } from \"../profile/lock.ts\";\nimport { createProfileLock, replaceProfileLock } from \"../profile/lock.ts\";\nimport { createProfileMigrationPolicy } from \"../profile/profile-migration.ts\";\nimport {\n\tBUILTIN_SUITE_CAPABILITIES,\n\tBUILTIN_SUITE_TOOLS,\n\tDEFAULT_ROLE_ASSOCIATIONS,\n\tFACTORY_CONTENTS_VERSION,\n\tgetBuiltinSuite,\n\tisBuiltinSuiteId,\n\tisValidSuiteId,\n\tSUITE_SCHEMA_VERSION,\n\ttype SuiteDefinition,\n\tserializeSuiteJson,\n} from \"./builtin-suites.ts\";\nimport {\n\tbuildSuiteProfileIdentity,\n\tgetSuitesRootDir,\n\tgetSuiteWorkspaceDir,\n\tloadSuiteWorkspace,\n\tparseSuiteProfileLockFile,\n\tSUITE_AGENTS_MD_FILENAME,\n\tSUITE_LOCK_FILENAME,\n\tSUITE_MANIFEST_FILENAME,\n\tSUITE_SESSION_ENTRY_TYPE,\n\tSuiteResolutionError,\n\ttype SuiteWorkspace,\n\tserializeSuiteProfileLockFile,\n\tsuiteManifestDigest,\n} from \"./suite-loader.ts\";\n\nexport const SUITE_TRASH_DIR_NAME = \".trash\";\n/** Trash retention for sweepSuiteTrash (M4 decision record). */\nexport const DEFAULT_SUITE_TRASH_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;\n/**\n * Explicit programmatic authorization token for deleteSuite. The CLI confirms\n * interactively before calling; programmatic callers pass this token to prove\n * intent. Absent keeps the CLI-first flow working.\n */\nexport const SUITE_DELETE_CONFIRM_TOKEN = \"suite-delete\";\n/** lockedBy/authorizedBy stamped onto locks created by --suite-reset (2.7b). */\nexport const SUITE_RESET_AUTHORIZED_BY = \"suite-reset\";\n\nexport type SuiteLifecycleOperation = \"create\" | \"delete\" | \"reset\";\n\n/** Structured lifecycle refusal: operation, suite id, and every reason. */\nexport class SuiteLifecycleError extends Error {\n\treadonly operation: SuiteLifecycleOperation;\n\treadonly suiteId: string;\n\treadonly reasons: readonly string[];\n\n\tconstructor(operation: SuiteLifecycleOperation, suiteId: string, reasons: readonly string[]) {\n\t\tsuper(`Suite ${operation} failed for \"${suiteId}\": ${reasons.join(\"; \")}`);\n\t\tthis.name = \"SuiteLifecycleError\";\n\t\tthis.operation = operation;\n\t\tthis.suiteId = suiteId;\n\t\tthis.reasons = Object.freeze([...reasons]);\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Create / clone (设计 §9 创建)\n// ---------------------------------------------------------------------------\n\nexport interface SuiteCreateOptions {\n\treadonly agentDir: string;\n\treadonly id: string;\n\t/** Clone an existing suite workspace (builtin or user) instead of a fresh skeleton. */\n\treadonly cloneFrom?: string;\n\t/** Display name; defaults to the id (fresh) or \"<source name> clone\" (cloned). */\n\treadonly name?: string;\n\t/** Injectable clock for the clonedFrom timestamp. */\n\treadonly now?: () => number;\n}\n\nexport interface SuiteCreateResult {\n\treadonly suiteId: string;\n\treadonly suiteDir: string;\n\treadonly suiteJsonPath: string;\n\treadonly definition: SuiteDefinition;\n}\n\n/**\n * Creates a user suite workspace (设计 §9): `<agentDir>/suites/<id>/` with a\n * suite.json plus an empty agents.md skeleton, or — with `cloneFrom` — a copy\n * of the source workspace (effective definition, so a corrupted builtin\n * source clones its factory content) with the suite.json identity rewritten:\n * new id, `builtin: false`, and a `clonedFrom` record carrying the source id\n * and the digest of the source's effective suite.json value. The source's\n * `.profile-lock.json` is never copied: the clone is a new profile identity\n * whose lock is created on first assembly.\n */\nexport function createSuite(options: SuiteCreateOptions): SuiteCreateResult {\n\tconst { agentDir, id } = options;\n\tconst suiteDir = getSuiteWorkspaceDir(agentDir, id);\n\tconst suiteJsonPath = join(suiteDir, SUITE_MANIFEST_FILENAME);\n\n\tconst reasons: string[] = [];\n\tif (!isValidSuiteId(id)) {\n\t\treasons.push(\n\t\t\t`id must be a suite id (^[a-z0-9-]+$, no leading/trailing hyphen, Windows reserved names rejected), found ${JSON.stringify(id)}`,\n\t\t);\n\t}\n\tif (isBuiltinSuiteId(id)) {\n\t\treasons.push(\n\t\t\t`\"${id}\" is a builtin suite id; builtin workspaces are provisioned automatically and cannot be created`,\n\t\t);\n\t}\n\tif (existsSync(suiteDir)) {\n\t\treasons.push(`workspace directory ${suiteDir} already exists`);\n\t}\n\tif (reasons.length > 0) throw new SuiteLifecycleError(\"create\", id, reasons);\n\n\tlet definition: SuiteDefinition;\n\tif (options.cloneFrom === undefined) {\n\t\tdefinition = {\n\t\t\tschemaVersion: SUITE_SCHEMA_VERSION,\n\t\t\tid,\n\t\t\tname: options.name ?? id,\n\t\t\tbuiltin: false,\n\t\t\ttools: BUILTIN_SUITE_TOOLS,\n\t\t\tcapabilities: BUILTIN_SUITE_CAPABILITIES,\n\t\t\tassociations: { skills: [], mcp: [], plugins: [], roles: DEFAULT_ROLE_ASSOCIATIONS },\n\t\t\tinheritSystemAgentsMd: false,\n\t\t\tmemory: \"assistant\",\n\t\t\torientation: \"assistant\",\n\t\t\tmodel: null,\n\t\t\tthinking: null,\n\t\t\tclonedFrom: null,\n\t\t\tfactoryRevision: FACTORY_CONTENTS_VERSION,\n\t\t};\n\t\tmkdirSync(suiteDir, { recursive: true });\n\t\twriteFileSync(suiteJsonPath, serializeSuiteJson(definition), \"utf8\");\n\t\twriteFileSync(join(suiteDir, SUITE_AGENTS_MD_FILENAME), \"\", \"utf8\");\n\t} else {\n\t\tconst source = loadEffectiveSourceWorkspace(agentDir, options.cloneFrom);\n\t\tdefinition = {\n\t\t\t...source.suite,\n\t\t\tid,\n\t\t\tname: options.name ?? `${source.suite.name} clone`,\n\t\t\tbuiltin: false,\n\t\t\tclonedFrom: {\n\t\t\t\tid: source.suite.id,\n\t\t\t\tdigest: suiteManifestDigest(source.suite),\n\t\t\t\tat: options.now?.() ?? Date.now(),\n\t\t\t},\n\t\t\tfactoryRevision: FACTORY_CONTENTS_VERSION,\n\t\t};\n\t\t// Copy user assets (agents.md, skills, plugins, ...) but never the\n\t\t// source profile lock: the clone freezes its own identity on first\n\t\t// assembly.\n\t\tcpSync(source.suiteDir, suiteDir, {\n\t\t\trecursive: true,\n\t\t\tfilter: (sourcePath) => basename(sourcePath) !== SUITE_LOCK_FILENAME,\n\t\t});\n\t\twriteFileSync(suiteJsonPath, serializeSuiteJson(definition), \"utf8\");\n\t}\n\n\treturn { suiteId: id, suiteDir, suiteJsonPath, definition };\n}\n\nfunction loadEffectiveSourceWorkspace(agentDir: string, cloneFrom: string): SuiteWorkspace {\n\ttry {\n\t\treturn loadSuiteWorkspace({ agentDir, suiteId: cloneFrom });\n\t} catch (error) {\n\t\tif (error instanceof SuiteResolutionError) {\n\t\t\tthrow new SuiteLifecycleError(\"create\", cloneFrom, [`clone source \"${cloneFrom}\" does not exist`]);\n\t\t}\n\t\tthrow new SuiteLifecycleError(\"create\", cloneFrom, [\n\t\t\t`clone source \"${cloneFrom}\" is unusable: ${error instanceof Error ? error.message : String(error)}`,\n\t\t]);\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Session reference scan (设计 §9 删除前置检查)\n// ---------------------------------------------------------------------------\n\n/** One existing session bound to a suite via its creation-time custom entry. */\nexport interface SuiteSessionRef {\n\treadonly path: string;\n\treadonly sessionId: string;\n\treadonly cwd: string | undefined;\n\treadonly modified: Date;\n}\n\n/** Bounded head-scan window, aligned with the session header reader (1 MB). */\nconst SUITE_REF_SCAN_LIMIT_BYTES = 1024 * 1024;\nconst SUITE_REF_READ_BUFFER_SIZE = 64 * 1024;\n\ninterface SuiteRefScanOutcome {\n\treadonly sessionId: string | undefined;\n\treadonly cwd: string | undefined;\n\treadonly bound: boolean;\n}\n\n/**\n * Scans every session tree under `<agentDir>/sessions/<project>/*.jsonl` for\n * sessions whose creation-time custom entry (customType \"suite\") binds them\n * to `suiteId` (设计 §10.1). The suite entry sits in the first few lines of\n * the file, so a bounded head scan (1 MB, matching the session header reader)\n * is sufficient; a file whose binding line has been seen is decided — later\n * lines cannot change it. Unreadable, oversized, or malformed files are\n * skipped, never fatal. Custom session dirs (--session-dir) are out of scope.\n */\nexport function findSuiteSessionRefs(agentDir: string, suiteId: string): SuiteSessionRef[] {\n\tconst sessionsDir = join(agentDir, \"sessions\");\n\tif (!existsSync(sessionsDir)) return [];\n\tconst refs: SuiteSessionRef[] = [];\n\tfor (const projectEntry of readdirSync(sessionsDir, { withFileTypes: true })) {\n\t\tif (!projectEntry.isDirectory()) continue;\n\t\tconst projectDir = join(sessionsDir, projectEntry.name);\n\t\tlet files: string[];\n\t\ttry {\n\t\t\tfiles = readdirSync(projectDir).filter((file) => file.endsWith(\".jsonl\"));\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const file of files) {\n\t\t\tconst path = join(projectDir, file);\n\t\t\ttry {\n\t\t\t\tconst outcome = scanSessionFileForSuiteBinding(path, suiteId);\n\t\t\t\tif (outcome.bound && outcome.sessionId !== undefined) {\n\t\t\t\t\trefs.push({\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tsessionId: outcome.sessionId,\n\t\t\t\t\t\tcwd: outcome.cwd,\n\t\t\t\t\t\tmodified: statSync(path).mtime,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Skip unreadable files; one bad file must not block deletion.\n\t\t\t}\n\t\t}\n\t}\n\treturn refs;\n}\n\nfunction scanSessionFileForSuiteBinding(path: string, suiteId: string): SuiteRefScanOutcome {\n\tconst fd = openSync(path, \"r\");\n\ttry {\n\t\tconst decoder = new StringDecoder(\"utf8\");\n\t\tconst buffer = Buffer.allocUnsafe(SUITE_REF_READ_BUFFER_SIZE);\n\t\tlet scannedBytes = 0;\n\t\tlet sessionId: string | undefined;\n\t\tlet cwd: string | undefined;\n\t\tlet leftover = \"\";\n\t\tlet bound = false;\n\t\tlet bindingDecided = false;\n\n\t\twhile (scannedBytes < SUITE_REF_SCAN_LIMIT_BYTES && !bindingDecided) {\n\t\t\tconst readLength = Math.min(buffer.length, SUITE_REF_SCAN_LIMIT_BYTES - scannedBytes);\n\t\t\tconst bytesRead = readSync(fd, buffer, 0, readLength, null);\n\t\t\tif (bytesRead === 0) break;\n\t\t\tscannedBytes += bytesRead;\n\t\t\tconst chunk = leftover + decoder.write(buffer.subarray(0, bytesRead));\n\t\t\tconst lines = chunk.split(\"\\n\");\n\t\t\tleftover = lines.pop() ?? \"\";\n\t\t\tfor (const line of lines) {\n\t\t\t\tconst entry = parseSuiteRefLine(line);\n\t\t\t\tif (entry === undefined) continue;\n\t\t\t\tif (entry.header !== undefined && sessionId === undefined) {\n\t\t\t\t\tsessionId = entry.header.id;\n\t\t\t\t\tcwd = entry.header.cwd;\n\t\t\t\t}\n\t\t\t\tif (entry.boundToSuite !== undefined) {\n\t\t\t\t\tbound = entry.boundToSuite === suiteId;\n\t\t\t\t\tbindingDecided = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn { sessionId, cwd, bound };\n\t} finally {\n\t\tcloseSync(fd);\n\t}\n}\n\ninterface SuiteRefLineParseResult {\n\treadonly header?: { readonly id: string; readonly cwd: string | undefined };\n\t/** The suite id this session is bound to, when the line is the suite binding entry. */\n\treadonly boundToSuite?: string;\n}\n\nfunction parseSuiteRefLine(line: string): SuiteRefLineParseResult | undefined {\n\tconst trimmed = line.trim();\n\tif (trimmed.length === 0) return undefined;\n\tlet value: unknown;\n\ttry {\n\t\tvalue = JSON.parse(trimmed);\n\t} catch {\n\t\treturn undefined;\n\t}\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) return undefined;\n\tconst record = value as Record<string, unknown>;\n\tif (record.type === \"session\" && typeof record.id === \"string\") {\n\t\treturn { header: { id: record.id, cwd: typeof record.cwd === \"string\" ? record.cwd : undefined } };\n\t}\n\tif (record.type === \"custom\" && record.customType === SUITE_SESSION_ENTRY_TYPE) {\n\t\tconst data = record.data;\n\t\tconst suiteId =\n\t\t\tdata !== null && typeof data === \"object\" && typeof (data as Record<string, unknown>).suiteId === \"string\"\n\t\t\t\t? ((data as Record<string, unknown>).suiteId as string)\n\t\t\t\t: undefined;\n\t\treturn suiteId === undefined ? {} : { boundToSuite: suiteId };\n\t}\n\treturn {};\n}\n\n// ---------------------------------------------------------------------------\n// Delete: trash rename, release, sweep (设计 §9 删除)\n// ---------------------------------------------------------------------------\n\nexport interface SuiteDeleteOptions {\n\treadonly agentDir: string;\n\treadonly id: string;\n\t/** Session references from findSuiteSessionRefs; a non-empty list refuses the delete. */\n\treadonly refs: readonly SuiteSessionRef[];\n\treadonly now?: () => number;\n\t/** Programmatic authorization; must equal SUITE_DELETE_CONFIRM_TOKEN when provided. */\n\treadonly confirmToken?: string;\n\t/**\n\t * Memory purge hook (M5 wiring point): invoked after the workspace is\n\t * isolated in the trash. M4 releases assets only; memory clearing goes\n\t * through the Foundation purge gate once M5 lands.\n\t */\n\treadonly purgeMemories?: (suiteId: string) => void;\n}\n\nexport interface SuiteDeleteResult {\n\treadonly trashPath: string;\n}\n\n/**\n * Moves a user suite workspace into `<agentDir>/suites/.trash/<id>-<UTC\n * compact timestamp>-<random>/`. Builtin suites are refused; the workspace\n * (directory + suite.json) must exist but does not need to parse; any\n * session reference refuses the delete with the full list. The rename keeps\n * the workspace recoverable; releaseTrashedSuite/sweepSuiteTrash do the\n * actual removal.\n */\nexport function deleteSuite(options: SuiteDeleteOptions): SuiteDeleteResult {\n\tconst { agentDir, id } = options;\n\tif (options.confirmToken !== undefined && options.confirmToken !== SUITE_DELETE_CONFIRM_TOKEN) {\n\t\tthrow new SuiteLifecycleError(\"delete\", id, [\n\t\t\t`confirmToken must be \"${SUITE_DELETE_CONFIRM_TOKEN}\" when provided`,\n\t\t]);\n\t}\n\tconst reasons: string[] = [];\n\tif (isBuiltinSuiteId(id)) {\n\t\treasons.push(`builtin suite \"${id}\" cannot be deleted`);\n\t}\n\tconst suiteDir = getSuiteWorkspaceDir(agentDir, id);\n\tconst suiteJsonPath = join(suiteDir, SUITE_MANIFEST_FILENAME);\n\tif (!existsSync(suiteDir)) {\n\t\treasons.push(`workspace directory ${suiteDir} does not exist`);\n\t} else if (!existsSync(suiteJsonPath)) {\n\t\treasons.push(`${suiteJsonPath} does not exist`);\n\t}\n\tif (reasons.length > 0) throw new SuiteLifecycleError(\"delete\", id, reasons);\n\n\tif (options.refs.length > 0) {\n\t\tthrow new SuiteLifecycleError(\n\t\t\t\"delete\",\n\t\t\tid,\n\t\t\toptions.refs.map((ref) => `session ${ref.sessionId} at ${ref.path} references this suite`),\n\t\t);\n\t}\n\n\tconst trashRoot = join(getSuitesRootDir(agentDir), SUITE_TRASH_DIR_NAME);\n\tmkdirSync(trashRoot, { recursive: true });\n\tconst trashPath = join(\n\t\ttrashRoot,\n\t\t`${id}-${formatTrashTimestamp(options.now?.() ?? Date.now())}-${randomUUID().replaceAll(\"-\", \"\").slice(0, 6)}`,\n\t);\n\trenameSync(suiteDir, trashPath);\n\toptions.purgeMemories?.(id);\n\treturn { trashPath };\n}\n\nfunction formatTrashTimestamp(ms: number): string {\n\t// UTC compact, sortable: \"20260907T123456789Z\".\n\treturn new Date(ms).toISOString().replace(/[-:]/g, \"\").replace(\".\", \"\");\n}\n\n/**\n * Fire-and-forget removal of one trash entry (Node's built-in Windows retry\n * semantics). Failures never throw: the entry simply remains for the next\n * sweepSuiteTrash run.\n */\nexport function releaseTrashedSuite(trashPath: string): void {\n\tvoid rm(trashPath, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 }).catch(() => {\n\t\t// Left for sweepSuiteTrash; release is re-runnable by structure.\n\t});\n}\n\nexport interface SuiteTrashSweepResult {\n\treadonly removed: readonly string[];\n\treadonly kept: readonly string[];\n}\n\n/**\n * Removes trash entries older than `retentionMs` (default 7 days, per the M4\n * decision record). Entries are aged by their mtime; unreadable entries are\n * kept. Deterministic given the injectable clock.\n */\nexport async function sweepSuiteTrash(\n\tagentDir: string,\n\toptions: { retentionMs?: number; now?: () => number } = {},\n): Promise<SuiteTrashSweepResult> {\n\tconst trashRoot = join(getSuitesRootDir(agentDir), SUITE_TRASH_DIR_NAME);\n\tconst retentionMs = options.retentionMs ?? DEFAULT_SUITE_TRASH_RETENTION_MS;\n\tconst cutoffMs = (options.now?.() ?? Date.now()) - retentionMs;\n\tconst removed: string[] = [];\n\tconst kept: string[] = [];\n\tlet entryNames: string[];\n\ttry {\n\t\tentryNames = await readdir(trashRoot);\n\t} catch {\n\t\treturn { removed: Object.freeze(removed), kept: Object.freeze(kept) };\n\t}\n\tfor (const name of entryNames) {\n\t\tconst entryPath = join(trashRoot, name);\n\t\ttry {\n\t\t\tconst stats = await stat(entryPath);\n\t\t\tif (stats.mtimeMs <= cutoffMs) {\n\t\t\t\tawait rm(entryPath, { recursive: true, force: true });\n\t\t\t\tremoved.push(name);\n\t\t\t} else {\n\t\t\t\tkept.push(name);\n\t\t\t}\n\t\t} catch {\n\t\t\tkept.push(name);\n\t\t}\n\t}\n\treturn { removed: Object.freeze(removed), kept: Object.freeze(kept) };\n}\n\n// ---------------------------------------------------------------------------\n// Reset (设计 §9 重置): factory contents + authorized lock migration (2.7b)\n// ---------------------------------------------------------------------------\n\nexport interface SuiteResetApplyResult {\n\treadonly suiteId: string;\n\t/** Whether the on-disk suite.json differed from the factory contents. */\n\treadonly wroteFactory: boolean;\n\t/** The lock now persisted in the workspace. */\n\treadonly lock: ProfileLockV1;\n\t/** Defined when an existing lock was replaced via 2.7b applyMigration. */\n\treadonly previousGeneration?: number;\n}\n\nexport interface SuiteResetPlan {\n\treadonly suiteId: string;\n\treadonly factory: SuiteDefinition;\n\treadonly suiteJsonPath: string;\n\treadonly lockPath: string;\n\t/** Display diff (edit-diff format) of the on-disk file vs the factory contents. */\n\treadonly diffText: string;\n\t/**\n\t * Applies the reset: writes the factory suite.json, then persists the\n\t * factory identity's lock. An existing lock goes through the 2.7b policy:\n\t * `applyMigration` (authorizedBy \"suite-reset\") decides current vs\n\t * non-current; a non-current lock is replaced via `replaceProfileLock`\n\t * (generation increments, `previousGeneration` reports the swap). A missing\n\t * or unreadable lock gets a fresh one. The replacement lock is evaluated\n\t * before any write, so a failure leaves the previous files untouched.\n\t */\n\tapply(): SuiteResetApplyResult;\n}\n\n/**\n * Plans a builtin suite reset (设计 §9 重置): diff the on-disk suite.json\n * against the factory declaration without touching anything. User suites are\n * refused — they have no factory contents to restore; remove them instead.\n */\nexport function resetSuite(options: { agentDir: string; id: string; now?: () => number }): SuiteResetPlan {\n\tconst { agentDir, id } = options;\n\tconst factory = getBuiltinSuite(id);\n\tif (factory === undefined) {\n\t\tthrow new SuiteLifecycleError(\"reset\", id, [\n\t\t\tisBuiltinSuiteId(id)\n\t\t\t\t? `builtin suite \"${id}\" has no factory declaration`\n\t\t\t\t: `suite \"${id}\" is not builtin; only builtin suites can be reset — delete user suites instead`,\n\t\t]);\n\t}\n\tconst suiteDir = getSuiteWorkspaceDir(agentDir, id);\n\tconst suiteJsonPath = join(suiteDir, SUITE_MANIFEST_FILENAME);\n\tconst lockPath = join(suiteDir, SUITE_LOCK_FILENAME);\n\tconst factoryJson = serializeSuiteJson(factory);\n\tconst currentRaw = existsSync(suiteJsonPath) ? readFileSync(suiteJsonPath, \"utf8\") : \"\";\n\n\tconst apply = (): SuiteResetApplyResult => {\n\t\tconst identity = buildSuiteProfileIdentity(factory);\n\t\t// Evaluate the replacement before any write (2.7b): a failure above this\n\t\t// point leaves the previous suite.json and lock untouched.\n\t\tlet previousLock: ProfileLockV1 | undefined;\n\t\tif (existsSync(lockPath)) {\n\t\t\ttry {\n\t\t\t\tpreviousLock = parseSuiteProfileLockFile(readFileSync(lockPath, \"utf8\"));\n\t\t\t} catch {\n\t\t\t\tpreviousLock = undefined;\n\t\t\t}\n\t\t}\n\t\tlet lock: ProfileLockV1;\n\t\tlet previousGeneration: number | undefined;\n\t\tlet replaced = false;\n\t\tif (previousLock !== undefined) {\n\t\t\t// Explicit authorized migration (2.7b): applyMigration decides whether\n\t\t\t// the stored lock is already current; only a non-current outcome\n\t\t\t// replaces the lock, through replaceProfileLock — the lock's only\n\t\t\t// authorized swap primitive (generation increments).\n\t\t\tconst policy = createProfileMigrationPolicy();\n\t\t\tconst migration = policy.applyMigration({\n\t\t\t\tlock: previousLock,\n\t\t\t\tcurrent: identity,\n\t\t\t\tauthorizedBy: SUITE_RESET_AUTHORIZED_BY,\n\t\t\t\t...(options.now === undefined ? {} : { now: options.now }),\n\t\t\t});\n\t\t\tif (migration.status === \"failed\") {\n\t\t\t\tthrow new SuiteLifecycleError(\"reset\", id, [migration.reason]);\n\t\t\t}\n\t\t\tif (migration.status === \"current\") {\n\t\t\t\tlock = previousLock;\n\t\t\t} else {\n\t\t\t\tconst swap = replaceProfileLock(\n\t\t\t\t\tpreviousLock,\n\t\t\t\t\tidentity,\n\t\t\t\t\t{ authorizedBy: SUITE_RESET_AUTHORIZED_BY },\n\t\t\t\t\toptions.now === undefined ? {} : { now: options.now },\n\t\t\t\t);\n\t\t\t\tlock = swap.lock;\n\t\t\t\tpreviousGeneration = swap.previousGeneration;\n\t\t\t\treplaced = true;\n\t\t\t}\n\t\t} else {\n\t\t\tlock = createProfileLock(identity, {\n\t\t\t\tlockedBy: SUITE_RESET_AUTHORIZED_BY,\n\t\t\t\t...(options.now === undefined ? {} : { now: options.now }),\n\t\t\t});\n\t\t\treplaced = true;\n\t\t}\n\t\t// The workspace may never have been assembled (first assembly provisions\n\t\t// it, loadSuiteWorkspace-style); create the directory so a reset of a\n\t\t// never-assembled builtin does not fail with a bare ENOENT.\n\t\tmkdirSync(suiteDir, { recursive: true });\n\t\twriteFileSync(suiteJsonPath, factoryJson, \"utf8\");\n\t\t// D-075 S4 第三批:reset 不再预种角色文件——种子由 subagent-delegate 插件\n\t\t// 注册期的幂等补缺承担(见 entry.ts);方案重置只重写方案自身内容。\n\t\tif (replaced || previousLock === undefined) {\n\t\t\twriteFileSync(lockPath, serializeSuiteProfileLockFile(lock), \"utf8\");\n\t\t}\n\t\treturn {\n\t\t\tsuiteId: id,\n\t\t\twroteFactory: currentRaw !== factoryJson,\n\t\t\tlock,\n\t\t\t...(previousGeneration === undefined ? {} : { previousGeneration }),\n\t\t};\n\t};\n\n\treturn {\n\t\tsuiteId: id,\n\t\tfactory,\n\t\tsuiteJsonPath,\n\t\tlockPath,\n\t\tdiffText: generateDiffString(currentRaw, factoryJson).diff,\n\t\tapply,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Dangling settings cleanup (设计 §9 删除连带)\n// ---------------------------------------------------------------------------\n\nexport interface SuiteSettingsCleanup {\n\treadonly clearedScopes: readonly (\"project\" | \"global\")[];\n}\n\n/**\n * Clears the project/global settings `suite` keys when they point at `id`\n * (设计 §9 删除连带). Keys pointing elsewhere are untouched.\n */\nexport function clearDanglingSuiteSettings(settingsManager: SettingsManager, id: string): SuiteSettingsCleanup {\n\tconst clearedScopes: (\"project\" | \"global\")[] = [];\n\tif (settingsManager.getProjectSettings().suite === id) {\n\t\tsettingsManager.setProjectSuite(undefined);\n\t\tclearedScopes.push(\"project\");\n\t}\n\tif (settingsManager.getGlobalSettings().suite === id) {\n\t\tsettingsManager.setSuite(undefined);\n\t\tclearedScopes.push(\"global\");\n\t}\n\treturn { clearedScopes: Object.freeze(clearedScopes) };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suite-lifecyc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a,EAAE,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;AAAA,CACvD","sourcesContent":["/**\n * Suite lifecycle operations (方案系统设计.md v2 §9, M4): create/clone,\n * delete (trash + release + sweep), reset, session reference scan, and\n * dangling settings cleanup.\n *\n * Every operation is deterministic given its inputs (`now` is injectable) and\n * reports refusal reasons as structured errors. Deletion only ever renames\n * the workspace into the trash directory — release and sweep are separate,\n * re-runnable steps — so recovery stays possible until the trash is released.\n * Memory purge is intentionally a hook: the Foundation purge gate lands with\n * M5; before that only suite assets are released.\n */\nimport { randomUUID } from \"node:crypto\";\nimport {\n\tcloseSync,\n\tcpSync,\n\texistsSync,\n\tmkdirSync,\n\topenSync,\n\treaddirSync,\n\treadFileSync,\n\treadSync,\n\trenameSync,\n\tstatSync,\n\twriteFileSync,\n} from \"node:fs\";\nimport { readdir, rm, stat } from \"node:fs/promises\";\nimport { basename, join } from \"node:path\";\nimport { StringDecoder } from \"node:string_decoder\";\nimport type { SettingsManager } from \"../core/settings-manager.ts\";\nimport { generateDiffString } from \"../core/tools/edit-diff.ts\";\nimport type { ProfileLockV1 } from \"../profile/lock.ts\";\nimport { createProfileLock, replaceProfileLock } from \"../profile/lock.ts\";\nimport { createProfileMigrationPolicy } from \"../profile/profile-migration.ts\";\nimport {\n\tBUILTIN_SUITE_CAPABILITIES,\n\tBUILTIN_SUITE_TOOLS,\n\tDEFAULT_ROLE_ASSOCIATIONS,\n\tFACTORY_CONTENTS_VERSION,\n\tgetBuiltinSuite,\n\tisBuiltinSuiteId,\n\tisValidSuiteId,\n\tSUITE_SCHEMA_VERSION,\n\ttype SuiteDefinition,\n\tserializeSuiteJson,\n} from \"./builtin-suites.ts\";\nimport {\n\tbuildSuiteProfileIdentity,\n\tgetSuitesRootDir,\n\tgetSuiteWorkspaceDir,\n\tloadSuiteWorkspace,\n\tparseSuiteProfileLockFile,\n\tSUITE_AGENTS_MD_FILENAME,\n\tSUITE_LOCK_FILENAME,\n\tSUITE_MANIFEST_FILENAME,\n\tSUITE_SESSION_ENTRY_TYPE,\n\tSuiteResolutionError,\n\ttype SuiteWorkspace,\n\tserializeSuiteProfileLockFile,\n\tsuiteManifestDigest,\n} from \"./suite-loader.ts\";\n\nexport const SUITE_TRASH_DIR_NAME = \".trash\";\n/** Trash retention for sweepSuiteTrash (M4 decision record). */\nexport const DEFAULT_SUITE_TRASH_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;\n/**\n * Explicit programmatic authorization token for deleteSuite. The CLI confirms\n * interactively before calling; programmatic callers pass this token to prove\n * intent. Absent keeps the CLI-first flow working.\n */\nexport const SUITE_DELETE_CONFIRM_TOKEN = \"suite-delete\";\n/** lockedBy/authorizedBy stamped onto locks created by --suite-reset (2.7b). */\nexport const SUITE_RESET_AUTHORIZED_BY = \"suite-reset\";\n\nexport type SuiteLifecycleOperation = \"create\" | \"delete\" | \"reset\";\n\n/** Structured lifecycle refusal: operation, suite id, and every reason. */\nexport class SuiteLifecycleError extends Error {\n\treadonly operation: SuiteLifecycleOperation;\n\treadonly suiteId: string;\n\treadonly reasons: readonly string[];\n\n\tconstructor(operation: SuiteLifecycleOperation, suiteId: string, reasons: readonly string[]) {\n\t\tsuper(`Suite ${operation} failed for \"${suiteId}\": ${reasons.join(\"; \")}`);\n\t\tthis.name = \"SuiteLifecycleError\";\n\t\tthis.operation = operation;\n\t\tthis.suiteId = suiteId;\n\t\tthis.reasons = Object.freeze([...reasons]);\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Create / clone (设计 §9 创建)\n// ---------------------------------------------------------------------------\n\nexport interface SuiteCreateOptions {\n\treadonly agentDir: string;\n\treadonly id: string;\n\t/** Clone an existing suite workspace (builtin or user) instead of a fresh skeleton. */\n\treadonly cloneFrom?: string;\n\t/** Display name; defaults to the id (fresh) or \"<source name> clone\" (cloned). */\n\treadonly name?: string;\n\t/** Injectable clock for the clonedFrom timestamp. */\n\treadonly now?: () => number;\n}\n\nexport interface SuiteCreateResult {\n\treadonly suiteId: string;\n\treadonly suiteDir: string;\n\treadonly suiteJsonPath: string;\n\treadonly definition: SuiteDefinition;\n}\n\n/**\n * Creates a user suite workspace (设计 §9): `<agentDir>/suites/<id>/` with a\n * suite.json plus an empty agents.md skeleton, or — with `cloneFrom` — a copy\n * of the source workspace (effective definition, so a corrupted builtin\n * source clones its factory content) with the suite.json identity rewritten:\n * new id, `builtin: false`, and a `clonedFrom` record carrying the source id\n * and the digest of the source's effective suite.json value. The source's\n * `.profile-lock.json` is never copied: the clone is a new profile identity\n * whose lock is created on first assembly.\n */\nexport function createSuite(options: SuiteCreateOptions): SuiteCreateResult {\n\tconst { agentDir, id } = options;\n\tconst suiteDir = getSuiteWorkspaceDir(agentDir, id);\n\tconst suiteJsonPath = join(suiteDir, SUITE_MANIFEST_FILENAME);\n\n\tconst reasons: string[] = [];\n\tif (!isValidSuiteId(id)) {\n\t\treasons.push(\n\t\t\t`id must be a suite id (^[a-z0-9-]+$, no leading/trailing hyphen, Windows reserved names rejected), found ${JSON.stringify(id)}`,\n\t\t);\n\t}\n\tif (isBuiltinSuiteId(id)) {\n\t\treasons.push(\n\t\t\t`\"${id}\" is a builtin suite id; builtin workspaces are provisioned automatically and cannot be created`,\n\t\t);\n\t}\n\tif (existsSync(suiteDir)) {\n\t\treasons.push(`workspace directory ${suiteDir} already exists`);\n\t}\n\tif (reasons.length > 0) throw new SuiteLifecycleError(\"create\", id, reasons);\n\n\tlet definition: SuiteDefinition;\n\tif (options.cloneFrom === undefined) {\n\t\tdefinition = {\n\t\t\tschemaVersion: SUITE_SCHEMA_VERSION,\n\t\t\tid,\n\t\t\tname: options.name ?? id,\n\t\t\tbuiltin: false,\n\t\t\ttools: BUILTIN_SUITE_TOOLS,\n\t\t\tcapabilities: BUILTIN_SUITE_CAPABILITIES,\n\t\t\tassociations: { skills: [], mcp: [], plugins: [], roles: DEFAULT_ROLE_ASSOCIATIONS },\n\t\t\tinheritSystemAgentsMd: false,\n\t\t\tmemory: \"assistant\",\n\t\t\torientation: \"assistant\",\n\t\t\tmodel: null,\n\t\t\tthinking: null,\n\t\t\tclonedFrom: null,\n\t\t\tfactoryRevision: FACTORY_CONTENTS_VERSION,\n\t\t};\n\t\tmkdirSync(suiteDir, { recursive: true });\n\t\twriteFileSync(suiteJsonPath, serializeSuiteJson(definition), \"utf8\");\n\t\twriteFileSync(join(suiteDir, SUITE_AGENTS_MD_FILENAME), \"\", \"utf8\");\n\t} else {\n\t\tconst source = loadEffectiveSourceWorkspace(agentDir, options.cloneFrom);\n\t\tdefinition = {\n\t\t\t...source.suite,\n\t\t\tid,\n\t\t\tname: options.name ?? `${source.suite.name} clone`,\n\t\t\tbuiltin: false,\n\t\t\tclonedFrom: {\n\t\t\t\tid: source.suite.id,\n\t\t\t\tdigest: suiteManifestDigest(source.suite),\n\t\t\t\tat: options.now?.() ?? Date.now(),\n\t\t\t},\n\t\t\tfactoryRevision: FACTORY_CONTENTS_VERSION,\n\t\t};\n\t\t// Copy user assets (agents.md, skills, plugins, ...) but never the\n\t\t// source profile lock: the clone freezes its own identity on first\n\t\t// assembly.\n\t\tcpSync(source.suiteDir, suiteDir, {\n\t\t\trecursive: true,\n\t\t\tfilter: (sourcePath) => basename(sourcePath) !== SUITE_LOCK_FILENAME,\n\t\t});\n\t\twriteFileSync(suiteJsonPath, serializeSuiteJson(definition), \"utf8\");\n\t}\n\n\treturn { suiteId: id, suiteDir, suiteJsonPath, definition };\n}\n\nfunction loadEffectiveSourceWorkspace(agentDir: string, cloneFrom: string): SuiteWorkspace {\n\ttry {\n\t\treturn loadSuiteWorkspace({ agentDir, suiteId: cloneFrom });\n\t} catch (error) {\n\t\tif (error instanceof SuiteResolutionError) {\n\t\t\tthrow new SuiteLifecycleError(\"create\", cloneFrom, [`clone source \"${cloneFrom}\" does not exist`]);\n\t\t}\n\t\tthrow new SuiteLifecycleError(\"create\", cloneFrom, [\n\t\t\t`clone source \"${cloneFrom}\" is unusable: ${error instanceof Error ? error.message : String(error)}`,\n\t\t]);\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Session reference scan (设计 §9 删除前置检查)\n// ---------------------------------------------------------------------------\n\n/** One existing session bound to a suite via its creation-time custom entry. */\nexport interface SuiteSessionRef {\n\treadonly path: string;\n\treadonly sessionId: string;\n\treadonly cwd: string | undefined;\n\treadonly modified: Date;\n}\n\n/** Bounded head-scan window, aligned with the session header reader (1 MB). */\nconst SUITE_REF_SCAN_LIMIT_BYTES = 1024 * 1024;\nconst SUITE_REF_READ_BUFFER_SIZE = 64 * 1024;\n\ninterface SuiteRefScanOutcome {\n\treadonly sessionId: string | undefined;\n\treadonly cwd: string | undefined;\n\treadonly bound: boolean;\n}\n\n/**\n * Scans every session tree under `<agentDir>/sessions/<project>/*.jsonl` for\n * sessions whose creation-time custom entry (customType \"suite\") binds them\n * to `suiteId` (设计 §10.1). The suite entry sits in the first few lines of\n * the file, so a bounded head scan (1 MB, matching the session header reader)\n * is sufficient; a file whose binding line has been seen is decided — later\n * lines cannot change it. Unreadable, oversized, or malformed files are\n * skipped, never fatal. Custom session dirs (--session-dir) are out of scope.\n */\nexport function findSuiteSessionRefs(agentDir: string, suiteId: string): SuiteSessionRef[] {\n\tconst sessionsDir = join(agentDir, \"sessions\");\n\tif (!existsSync(sessionsDir)) return [];\n\tconst refs: SuiteSessionRef[] = [];\n\tfor (const projectEntry of readdirSync(sessionsDir, { withFileTypes: true })) {\n\t\tif (!projectEntry.isDirectory()) continue;\n\t\tconst projectDir = join(sessionsDir, projectEntry.name);\n\t\tlet files: string[];\n\t\ttry {\n\t\t\tfiles = readdirSync(projectDir).filter((file) => file.endsWith(\".jsonl\"));\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const file of files) {\n\t\t\tconst path = join(projectDir, file);\n\t\t\ttry {\n\t\t\t\tconst outcome = scanSessionFileForSuiteBinding(path, suiteId);\n\t\t\t\tif (outcome.bound && outcome.sessionId !== undefined) {\n\t\t\t\t\trefs.push({\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tsessionId: outcome.sessionId,\n\t\t\t\t\t\tcwd: outcome.cwd,\n\t\t\t\t\t\tmodified: statSync(path).mtime,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Skip unreadable files; one bad file must not block deletion.\n\t\t\t}\n\t\t}\n\t}\n\treturn refs;\n}\n\nfunction scanSessionFileForSuiteBinding(path: string, suiteId: string): SuiteRefScanOutcome {\n\tconst fd = openSync(path, \"r\");\n\ttry {\n\t\tconst decoder = new StringDecoder(\"utf8\");\n\t\tconst buffer = Buffer.allocUnsafe(SUITE_REF_READ_BUFFER_SIZE);\n\t\tlet scannedBytes = 0;\n\t\tlet sessionId: string | undefined;\n\t\tlet cwd: string | undefined;\n\t\tlet leftover = \"\";\n\t\tlet bound = false;\n\t\tlet bindingDecided = false;\n\n\t\twhile (scannedBytes < SUITE_REF_SCAN_LIMIT_BYTES && !bindingDecided) {\n\t\t\tconst readLength = Math.min(buffer.length, SUITE_REF_SCAN_LIMIT_BYTES - scannedBytes);\n\t\t\tconst bytesRead = readSync(fd, buffer, 0, readLength, null);\n\t\t\tif (bytesRead === 0) break;\n\t\t\tscannedBytes += bytesRead;\n\t\t\tconst chunk = leftover + decoder.write(buffer.subarray(0, bytesRead));\n\t\t\tconst lines = chunk.split(\"\\n\");\n\t\t\tleftover = lines.pop() ?? \"\";\n\t\t\tfor (const line of lines) {\n\t\t\t\tconst entry = parseSuiteRefLine(line);\n\t\t\t\tif (entry === undefined) continue;\n\t\t\t\tif (entry.header !== undefined && sessionId === undefined) {\n\t\t\t\t\tsessionId = entry.header.id;\n\t\t\t\t\tcwd = entry.header.cwd;\n\t\t\t\t}\n\t\t\t\tif (entry.boundToSuite !== undefined) {\n\t\t\t\t\tbound = entry.boundToSuite === suiteId;\n\t\t\t\t\tbindingDecided = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn { sessionId, cwd, bound };\n\t} finally {\n\t\tcloseSync(fd);\n\t}\n}\n\ninterface SuiteRefLineParseResult {\n\treadonly header?: { readonly id: string; readonly cwd: string | undefined };\n\t/** The suite id this session is bound to, when the line is the suite binding entry. */\n\treadonly boundToSuite?: string;\n}\n\nfunction parseSuiteRefLine(line: string): SuiteRefLineParseResult | undefined {\n\tconst trimmed = line.trim();\n\tif (trimmed.length === 0) return undefined;\n\tlet value: unknown;\n\ttry {\n\t\tvalue = JSON.parse(trimmed);\n\t} catch {\n\t\treturn undefined;\n\t}\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) return undefined;\n\tconst record = value as Record<string, unknown>;\n\tif (record.type === \"session\" && typeof record.id === \"string\") {\n\t\treturn { header: { id: record.id, cwd: typeof record.cwd === \"string\" ? record.cwd : undefined } };\n\t}\n\tif (record.type === \"custom\" && record.customType === SUITE_SESSION_ENTRY_TYPE) {\n\t\tconst data = record.data;\n\t\tconst suiteId =\n\t\t\tdata !== null && typeof data === \"object\" && typeof (data as Record<string, unknown>).suiteId === \"string\"\n\t\t\t\t? ((data as Record<string, unknown>).suiteId as string)\n\t\t\t\t: undefined;\n\t\treturn suiteId === undefined ? {} : { boundToSuite: suiteId };\n\t}\n\treturn {};\n}\n\n// ---------------------------------------------------------------------------\n// Delete: trash rename, release, sweep (设计 §9 删除)\n// ---------------------------------------------------------------------------\n\nexport interface SuiteDeleteOptions {\n\treadonly agentDir: string;\n\treadonly id: string;\n\t/** Session references from findSuiteSessionRefs; a non-empty list refuses the delete. */\n\treadonly refs: readonly SuiteSessionRef[];\n\treadonly now?: () => number;\n\t/** Programmatic authorization; must equal SUITE_DELETE_CONFIRM_TOKEN when provided. */\n\treadonly confirmToken?: string;\n\t/**\n\t * Memory purge hook (M5 wiring point): invoked after the workspace is\n\t * isolated in the trash. M4 releases assets only; memory clearing goes\n\t * through the Foundation purge gate once M5 lands.\n\t */\n\treadonly purgeMemories?: (suiteId: string) => void;\n}\n\nexport interface SuiteDeleteResult {\n\treadonly trashPath: string;\n}\n\n/**\n * Moves a user suite workspace into `<agentDir>/suites/.trash/<id>-<UTC\n * compact timestamp>-<random>/`. Builtin suites are refused; the workspace\n * (directory + suite.json) must exist but does not need to parse; any\n * session reference refuses the delete with the full list. The rename keeps\n * the workspace recoverable; releaseTrashedSuite/sweepSuiteTrash do the\n * actual removal.\n */\nexport function deleteSuite(options: SuiteDeleteOptions): SuiteDeleteResult {\n\tconst { agentDir, id } = options;\n\tif (options.confirmToken !== undefined && options.confirmToken !== SUITE_DELETE_CONFIRM_TOKEN) {\n\t\tthrow new SuiteLifecycleError(\"delete\", id, [\n\t\t\t`confirmToken must be \"${SUITE_DELETE_CONFIRM_TOKEN}\" when provided`,\n\t\t]);\n\t}\n\tconst reasons: string[] = [];\n\tif (isBuiltinSuiteId(id)) {\n\t\treasons.push(`builtin suite \"${id}\" cannot be deleted`);\n\t}\n\tconst suiteDir = getSuiteWorkspaceDir(agentDir, id);\n\tconst suiteJsonPath = join(suiteDir, SUITE_MANIFEST_FILENAME);\n\tif (!existsSync(suiteDir)) {\n\t\treasons.push(`workspace directory ${suiteDir} does not exist`);\n\t} else if (!existsSync(suiteJsonPath)) {\n\t\treasons.push(`${suiteJsonPath} does not exist`);\n\t}\n\tif (reasons.length > 0) throw new SuiteLifecycleError(\"delete\", id, reasons);\n\n\tif (options.refs.length > 0) {\n\t\tthrow new SuiteLifecycleError(\n\t\t\t\"delete\",\n\t\t\tid,\n\t\t\toptions.refs.map((ref) => `session ${ref.sessionId} at ${ref.path} references this suite`),\n\t\t);\n\t}\n\n\tconst trashRoot = join(getSuitesRootDir(agentDir), SUITE_TRASH_DIR_NAME);\n\tmkdirSync(trashRoot, { recursive: true });\n\tconst trashPath = join(\n\t\ttrashRoot,\n\t\t`${id}-${formatTrashTimestamp(options.now?.() ?? Date.now())}-${randomUUID().replaceAll(\"-\", \"\").slice(0, 6)}`,\n\t);\n\trenameSync(suiteDir, trashPath);\n\toptions.purgeMemories?.(id);\n\treturn { trashPath };\n}\n\nfunction formatTrashTimestamp(ms: number): string {\n\t// UTC compact, sortable: \"20260907T123456789Z\".\n\treturn new Date(ms).toISOString().replace(/[-:]/g, \"\").replace(\".\", \"\");\n}\n\n/**\n * Fire-and-forget removal of one trash entry (Node's built-in Windows retry\n * semantics). Failures never throw: the entry simply remains for the next\n * sweepSuiteTrash run.\n */\nexport function releaseTrashedSuite(trashPath: string): void {\n\tvoid rm(trashPath, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 }).catch(() => {\n\t\t// Left for sweepSuiteTrash; release is re-runnable by structure.\n\t});\n}\n\nexport interface SuiteTrashSweepResult {\n\treadonly removed: readonly string[];\n\treadonly kept: readonly string[];\n}\n\n/**\n * Removes trash entries older than `retentionMs` (default 7 days, per the M4\n * decision record). Entries are aged by their mtime; unreadable entries are\n * kept. Deterministic given the injectable clock.\n */\nexport async function sweepSuiteTrash(\n\tagentDir: string,\n\toptions: { retentionMs?: number; now?: () => number } = {},\n): Promise<SuiteTrashSweepResult> {\n\tconst trashRoot = join(getSuitesRootDir(agentDir), SUITE_TRASH_DIR_NAME);\n\tconst retentionMs = options.retentionMs ?? DEFAULT_SUITE_TRASH_RETENTION_MS;\n\tconst cutoffMs = (options.now?.() ?? Date.now()) - retentionMs;\n\tconst removed: string[] = [];\n\tconst kept: string[] = [];\n\tlet entryNames: string[];\n\ttry {\n\t\tentryNames = await readdir(trashRoot);\n\t} catch {\n\t\treturn { removed: Object.freeze(removed), kept: Object.freeze(kept) };\n\t}\n\tfor (const name of entryNames) {\n\t\tconst entryPath = join(trashRoot, name);\n\t\ttry {\n\t\t\tconst stats = await stat(entryPath);\n\t\t\tif (stats.mtimeMs <= cutoffMs) {\n\t\t\t\tawait rm(entryPath, { recursive: true, force: true });\n\t\t\t\tremoved.push(name);\n\t\t\t} else {\n\t\t\t\tkept.push(name);\n\t\t\t}\n\t\t} catch {\n\t\t\tkept.push(name);\n\t\t}\n\t}\n\treturn { removed: Object.freeze(removed), kept: Object.freeze(kept) };\n}\n\n// ---------------------------------------------------------------------------\n// Reset (设计 §9 重置): factory contents + authorized lock migration (2.7b)\n// ---------------------------------------------------------------------------\n\nexport interface SuiteResetApplyResult {\n\treadonly suiteId: string;\n\t/** Whether the on-disk suite.json differed from the factory contents. */\n\treadonly wroteFactory: boolean;\n\t/** The lock now persisted in the workspace. */\n\treadonly lock: ProfileLockV1;\n\t/** Defined when an existing lock was replaced via 2.7b applyMigration. */\n\treadonly previousGeneration?: number;\n}\n\nexport interface SuiteResetPlan {\n\treadonly suiteId: string;\n\treadonly factory: SuiteDefinition;\n\treadonly suiteJsonPath: string;\n\treadonly lockPath: string;\n\t/** Display diff (edit-diff format) of the on-disk file vs the factory contents. */\n\treadonly diffText: string;\n\t/**\n\t * Applies the reset: writes the factory suite.json, then persists the\n\t * factory identity's lock. An existing lock goes through the 2.7b policy:\n\t * `applyMigration` (authorizedBy \"suite-reset\") decides current vs\n\t * non-current; a non-current lock is replaced via `replaceProfileLock`\n\t * (generation increments, `previousGeneration` reports the swap). A missing\n\t * or unreadable lock gets a fresh one. The replacement lock is evaluated\n\t * before any write, so a failure leaves the previous files untouched.\n\t */\n\tapply(): SuiteResetApplyResult;\n}\n\n/**\n * Plans a builtin suite reset (设计 §9 重置): diff the on-disk suite.json\n * against the factory declaration without touching anything. User suites are\n * refused — they have no factory contents to restore; remove them instead.\n */\nexport function resetSuite(options: { agentDir: string; id: string; now?: () => number }): SuiteResetPlan {\n\tconst { agentDir, id } = options;\n\tconst factory = getBuiltinSuite(id);\n\tif (factory === undefined) {\n\t\tthrow new SuiteLifecycleError(\"reset\", id, [\n\t\t\tisBuiltinSuiteId(id)\n\t\t\t\t? `builtin suite \"${id}\" has no factory declaration`\n\t\t\t\t: `suite \"${id}\" is not builtin; only builtin suites can be reset — delete user suites instead`,\n\t\t]);\n\t}\n\tconst suiteDir = getSuiteWorkspaceDir(agentDir, id);\n\tconst suiteJsonPath = join(suiteDir, SUITE_MANIFEST_FILENAME);\n\tconst lockPath = join(suiteDir, SUITE_LOCK_FILENAME);\n\tconst factoryJson = serializeSuiteJson(factory);\n\tconst currentRaw = existsSync(suiteJsonPath) ? readFileSync(suiteJsonPath, \"utf8\") : \"\";\n\n\tconst apply = (): SuiteResetApplyResult => {\n\t\tconst identity = buildSuiteProfileIdentity(factory);\n\t\t// Evaluate the replacement before any write (2.7b): a failure above this\n\t\t// point leaves the previous suite.json and lock untouched.\n\t\tlet previousLock: ProfileLockV1 | undefined;\n\t\tif (existsSync(lockPath)) {\n\t\t\ttry {\n\t\t\t\tpreviousLock = parseSuiteProfileLockFile(readFileSync(lockPath, \"utf8\"));\n\t\t\t} catch {\n\t\t\t\tpreviousLock = undefined;\n\t\t\t}\n\t\t}\n\t\tlet lock: ProfileLockV1;\n\t\tlet previousGeneration: number | undefined;\n\t\tlet replaced = false;\n\t\tif (previousLock !== undefined) {\n\t\t\t// Explicit authorized migration (2.7b): applyMigration decides whether\n\t\t\t// the stored lock is already current; only a non-current outcome\n\t\t\t// replaces the lock, through replaceProfileLock — the lock's only\n\t\t\t// authorized swap primitive (generation increments).\n\t\t\tconst policy = createProfileMigrationPolicy();\n\t\t\tconst migration = policy.applyMigration({\n\t\t\t\tlock: previousLock,\n\t\t\t\tcurrent: identity,\n\t\t\t\tauthorizedBy: SUITE_RESET_AUTHORIZED_BY,\n\t\t\t\t...(options.now === undefined ? {} : { now: options.now }),\n\t\t\t});\n\t\t\tif (migration.status === \"failed\") {\n\t\t\t\tthrow new SuiteLifecycleError(\"reset\", id, [migration.reason]);\n\t\t\t}\n\t\t\tif (migration.status === \"current\") {\n\t\t\t\tlock = previousLock;\n\t\t\t} else {\n\t\t\t\tconst swap = replaceProfileLock(\n\t\t\t\t\tpreviousLock,\n\t\t\t\t\tidentity,\n\t\t\t\t\t{ authorizedBy: SUITE_RESET_AUTHORIZED_BY },\n\t\t\t\t\toptions.now === undefined ? {} : { now: options.now },\n\t\t\t\t);\n\t\t\t\tlock = swap.lock;\n\t\t\t\tpreviousGeneration = swap.previousGeneration;\n\t\t\t\treplaced = true;\n\t\t\t}\n\t\t} else {\n\t\t\tlock = createProfileLock(identity, {\n\t\t\t\tlockedBy: SUITE_RESET_AUTHORIZED_BY,\n\t\t\t\t...(options.now === undefined ? {} : { now: options.now }),\n\t\t\t});\n\t\t\treplaced = true;\n\t\t}\n\t\t// The workspace may never have been assembled (first assembly provisions\n\t\t// it, loadSuiteWorkspace-style); create the directory so a reset of a\n\t\t// never-assembled builtin does not fail with a bare ENOENT.\n\t\tmkdirSync(suiteDir, { recursive: true });\n\t\twriteFileSync(suiteJsonPath, factoryJson, \"utf8\");\n\t\t// D-075 S4 第三批:reset 不再预种角色文件——种子由 subagent-delegate 插件\n\t\t// 注册期的幂等补缺承担(见 entry.ts);方案重置只重写方案自身内容。\n\t\tif (replaced || previousLock === undefined) {\n\t\t\twriteFileSync(lockPath, serializeSuiteProfileLockFile(lock), \"utf8\");\n\t\t}\n\t\treturn {\n\t\t\tsuiteId: id,\n\t\t\twroteFactory: currentRaw !== factoryJson,\n\t\t\tlock,\n\t\t\t...(previousGeneration === undefined ? {} : { previousGeneration }),\n\t\t};\n\t};\n\n\treturn {\n\t\tsuiteId: id,\n\t\tfactory,\n\t\tsuiteJsonPath,\n\t\tlockPath,\n\t\tdiffText: generateDiffString(currentRaw, factoryJson).diff,\n\t\tapply,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Dangling settings cleanup (设计 §9 删除连带)\n// ---------------------------------------------------------------------------\n\nexport interface SuiteSettingsCleanup {\n\treadonly clearedScopes: readonly (\"project\" | \"global\")[];\n}\n\n/**\n * Clears the project/global settings `suite` keys when they point at `id`\n * (设计 §9 删除连带). Keys pointing elsewhere are untouched.\n */\nexport function clearDanglingSuiteSettings(settingsManager: SettingsManager, id: string): SuiteSettingsCleanup {\n\tconst clearedScopes: (\"project\" | \"global\")[] = [];\n\tif (settingsManager.getProjectSettings().suite === id) {\n\t\tsettingsManager.setProjectSuite(undefined);\n\t\tclearedScopes.push(\"project\");\n\t}\n\tif (settingsManager.getGlobalSettings().suite === id) {\n\t\tsettingsManager.setSuite(undefined);\n\t\tclearedScopes.push(\"global\");\n\t}\n\treturn { clearedScopes: Object.freeze(clearedScopes) };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suite-loader.d.ts","sourceRoot":"","sources":["../../src/suites/suite-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAEnF,OAAO,KAAK,EACX,gCAAgC,EAChC,wBAAwB,EACxB,gCAAgC,EAChC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,KAAK,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAG/F,OAAO,EAEN,gBAAgB,EAQhB,KAAK,eAAe,EAEpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,eAAO,MAAM,eAAe,WAAW,CAAC;AACxC,eAAO,MAAM,uBAAuB,eAAe,CAAC;AACpD,eAAO,MAAM,wBAAwB,cAAc,CAAC;AACpD,eAAO,MAAM,yBAAyB,eAAe,CAAC;AACtD,eAAO,MAAM,aAAa,sBAAsB,CAAC;AACjD,6GAAwG;AACxG,eAAO,MAAM,wBAAwB,UAAU,CAAC;AAChD,iFAA4E;AAC5E,eAAO,MAAM,m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;IAChC,QAAQ,CAAC,aAAa,CAAC,EAAE,gCAAgC,CAAC;IAC1D,QAAQ,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CAC5B,GAAG,sBAAsB,CA6BzB","sourcesContent":["/**\n * Suite workspace location, lazy provisioning, and assembly (方案系统设计.md v2\n * §4/§5/§8/§9/§11/§12, M1a).\n *\n * The loader is the assembler layer of the suite system: it resolves the\n * active suite id (explicit > AGENT_FORGE_SUITE > project settings > global\n * settings > \"assistant\"), provisions the builtin suite workspaces under\n * `<agentDir>/suites/<id>/`, assembles the agents.md three-level chain\n * (system -> suite -> project, 设计 §8), gates the global SYSTEM.md/\n * APPEND_SYSTEM.md system prompt channel by inheritSystemAgentsMd (设计 §4:\n * the project-level `<cwd>/.agent-forge/` layer always passes), and bridges\n * the assembled suite onto the existing ProfileIdentityV1/ProfileLock\n * mechanisms. The project level of the chain is delegated to the existing\n * resource loader — the ancestor chain logic itself is never reimplemented\n * here.\n */\n\nimport { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join, resolve, sep } from \"node:path\";\nimport type { JsonValue } from \"@agent-forge/ai\";\nimport { CONFIG_DIR_NAME } from \"../config.ts\";\nimport type { ResourceDiagnostic } from \"../core/diagnostics.ts\";\nimport { t } from \"../core/i18n/index.ts\";\nimport type { SettingsManager } from \"../core/settings-manager.ts\";\nimport type { Skill } from \"../core/skills.ts\";\nimport { loadSkills } from \"../core/skills.ts\";\nimport type { HostFactsV1 } from \"../plugins/ecosystem/types.ts\";\nimport type { ProfileIdentityV1 } from \"../profile/identity.ts\";\nimport { buildProfileIdentityV1, stableJsonDigest } from \"../profile/identity.ts\";\nimport type { ProfileLockV1, ProfileLockVerificationV1 } from \"../profile/lock.ts\";\nimport { createProfileLock, verifyProfileLock } from \"../profile/lock.ts\";\nimport type {\n\tBuiltinPluginManifestOverridesV1,\n\tBuiltinPluginProfileIdV1,\n\tBuiltinPluginProfileResolutionV1,\n} from \"../profile/plugin-profiles.ts\";\nimport { resolveBuiltinPluginProfileV1 } from \"../profile/plugin-profiles.ts\";\nimport type { VerifiedToolPluginV1 } from \"../profile/profile-assembly.ts\";\nimport type { RegistryProfileEntryV1, RegistrySourceV1 } from \"../profile/profile-registry.ts\";\nimport { createProfileRegistry } from \"../profile/profile-registry.ts\";\nimport { stripBom } from \"../utils/text.ts\";\nimport {\n\tBUILTIN_SUITES,\n\tDEFAULT_SUITE_ID,\n\tFACTORY_CONTENTS_VERSION,\n\tgetBuiltinSuite,\n\tisBuiltinSuiteId,\n\tisValidSuiteId,\n\tORIENTATION_PROMPTS,\n\tparseSuiteJson,\n\tSUITE_SCHEMA_VERSION,\n\ttype SuiteDefinition,\n\tserializeSuiteJson,\n} from \"./builtin-suites.ts\";\n\nexport { DEFAULT_SUITE_ID };\n\nexport const SUITES_DIR_NAME = \"suites\";\nexport const SUITE_MANIFEST_FILENAME = \"suite.json\";\nexport const SUITE_AGENTS_MD_FILENAME = \"agents.md\";\nexport const SUITE_PERSONA_MD_FILENAME = \"persona.md\";\nexport const SUITE_ENV_VAR = \"AGENT_FORGE_SUITE\";\n/** customType of the session custom entry recording the suite a session was created with (设计 §10.1). */\nexport const SUITE_SESSION_ENTRY_TYPE = \"suite\";\n/** Persisted suite profile lock inside the suite workspace (M4, 设计 §12). */\nexport const SUITE_LOCK_FILENAME = \".profile-lock.json\";\n\nexport function getSuitesRootDir(agentDir: string): string {\n\treturn join(agentDir, SUITES_DIR_NAME);\n}\n\nexport function getSuiteWorkspaceDir(agentDir: string, suiteId: string): string {\n\treturn join(getSuitesRootDir(agentDir), suiteId);\n}\n\n/** The suite-local skill layer directory (统一修复轮 B): `<suiteDir>/skills`. */\nexport function getSuiteLocalSkillsDir(agentDir: string, suiteId: string): string {\n\treturn join(getSuiteWorkspaceDir(agentDir, suiteId), \"skills\");\n}\n\n/** The suite-local capability-plugin layer directory (统一修复轮 B): `<suiteDir>/plugins`. */\nexport function getSuiteLocalPluginsDir(agentDir: string, suiteId: string): string {\n\treturn join(getSuiteWorkspaceDir(agentDir, suiteId), \"plugins\");\n}\n\n/** Structured error for unknown suite ids; lists the available ids (设计 §9). */\nexport class SuiteResolutionError extends Error {\n\treadonly requestedId: string;\n\treadonly availableSuiteIds: readonly string[];\n\n\tconstructor(requestedId: string, availableSuiteIds: readonly string[]) {\n\t\tsuper(`Unknown suite \"${requestedId}\". Available suites: ${availableSuiteIds.join(\", \")}`);\n\t\tthis.name = \"SuiteResolutionError\";\n\t\tthis.requestedId = requestedId;\n\t\tthis.availableSuiteIds = Object.freeze([...availableSuiteIds]);\n\t}\n}\n\n/** Structured error for resuming a session under a suite it is not bound to. */\nexport class SuiteRebindError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"SuiteRebindError\";\n\t}\n}\n\n/**\n * Every suite id resolvable on this host: the builtin pair plus user\n * workspaces that already contain a suite.json.\n */\nexport function listSuiteIds(agentDir: string): string[] {\n\tconst ids = new Set(BUILTIN_SUITES.map((suite) => suite.id));\n\tconst rootDir = getSuitesRootDir(agentDir);\n\tif (existsSync(rootDir)) {\n\t\tfor (const entry of readdirSync(rootDir, { withFileTypes: true })) {\n\t\t\tif (!entry.isDirectory()) continue;\n\t\t\tif (!existsSync(join(rootDir, entry.name, SUITE_MANIFEST_FILENAME))) continue;\n\t\t\tids.add(entry.name);\n\t\t}\n\t}\n\treturn [...ids].sort();\n}\n\nexport interface ResolveSuiteIdOptions {\n\t/** Explicit suite id (SDK/CLI parameter); highest priority. */\n\texplicit?: string;\n\t/** Raw AGENT_FORGE_SUITE value; callers pass process.env[SUITE_ENV_VAR]. */\n\tenvSuite?: string;\n\t/** Settings source for the project/global `suite` keys. */\n\tsettings?: Pick<SettingsManager, \"getProjectSettings\" | \"getGlobalSettings\">;\n\t/** Agent dir used for workspace discovery and available-id listing. */\n\tagentDir: string;\n}\n\nfunction normalizeCandidate(value: unknown): string | undefined {\n\tif (typeof value !== \"string\") return undefined;\n\tconst trimmed = value.trim();\n\treturn trimmed.length > 0 ? trimmed : undefined;\n}\n\n/**\n * Resolves the active suite id: explicit > env AGENT_FORGE_SUITE > project\n * settings `suite` > global settings `suite` > \"coding\" (设计 §9). The\n * first configured value wins; an unknown or malformed value is a structured\n * error, never a silent fallback.\n */\nexport function resolveSuiteId(options: ResolveSuiteIdOptions): string {\n\tconst candidate =\n\t\tnormalizeCandidate(options.explicit) ??\n\t\tnormalizeCandidate(options.envSuite) ??\n\t\t(options.settings === undefined ? undefined : normalizeCandidate(options.settings.getProjectSettings().suite)) ??\n\t\t(options.settings === undefined ? undefined : normalizeCandidate(options.settings.getGlobalSettings().suite));\n\tif (candidate === undefined) return DEFAULT_SUITE_ID;\n\tif (!isValidSuiteId(candidate)) throw new SuiteResolutionError(candidate, listSuiteIds(options.agentDir));\n\tif (!isBuiltinSuiteId(candidate)) {\n\t\tconst workspaceManifest = join(getSuiteWorkspaceDir(options.agentDir, candidate), SUITE_MANIFEST_FILENAME);\n\t\tif (!existsSync(workspaceManifest)) throw new SuiteResolutionError(candidate, listSuiteIds(options.agentDir));\n\t}\n\treturn candidate;\n}\n\nexport interface SuiteWorkspace {\n\treadonly suite: SuiteDefinition;\n\treadonly suiteDir: string;\n\treadonly suiteJsonPath: string;\n\treadonly agentsMdPath: string;\n\t/**\n\t * The resolved orientation persona text (设计 §6.2/§6.3): the compiled\n\t * ORIENTATION_PROMPTS text for assistant/coding, the workspace persona.md\n\t * content for custom; a missing or unreadable file degrades to \"\" with a\n\t * diagnostic.\n\t */\n\treadonly orientationPersona: string;\n\treadonly diagnostics: readonly string[];\n\t/** Persisted lock file path inside the workspace (M4). */\n\treadonly lockPath: string;\n\t/**\n\t * The suite profile lock (设计 §12): the persisted lock when one existed, a\n\t * fresh lock frozen over the current identity otherwise.\n\t */\n\treadonly lock: ProfileLockV1;\n\t/** Current resolved identity, including any selected optional domain Profile. */\n\treadonly identity: ProfileIdentityV1;\n\t/** Verify result against the persisted lock; absent when none existed. */\n\treadonly lockVerification?: ProfileLockVerificationV1;\n}\n\n/**\n * Serializes a ProfileLockV1 to the canonical `.profile-lock.json` text\n * (stable field order, trailing newline). Round-trips through\n * parseSuiteProfileLockFile.\n */\nexport function serializeSuiteProfileLockFile(lock: ProfileLockV1): string {\n\tconst ordered = {\n\t\tidentity: {\n\t\t\tprofileId: lock.identity.profileId,\n\t\t\tprofileVersion: lock.identity.profileVersion,\n\t\t\tmanifestDigest: lock.identity.manifestDigest,\n\t\t\tcapabilityVersions: lock.identity.capabilityVersions.map((ref) => ({ id: ref.id, version: ref.version })),\n\t\t},\n\t\tlockedAt: lock.lockedAt,\n\t\tlockedBy: lock.lockedBy,\n\t\tgeneration: lock.generation,\n\t};\n\treturn `${JSON.stringify(ordered, null, 2)}\\n`;\n}\n\n/**\n * Parses `.profile-lock.json` text back into a ProfileLockV1. Throws on any\n * structural mismatch so callers can apply their corruption policy.\n */\nexport function parseSuiteProfileLockFile(text: string): ProfileLockV1 {\n\tconst value: unknown = JSON.parse(text);\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n\t\tthrow new Error(t(\".profile-lock.json must be a JSON object\"));\n\t}\n\tconst record = value as Record<string, unknown>;\n\tconst identityRecord = record.identity;\n\tif (identityRecord === null || typeof identityRecord !== \"object\" || Array.isArray(identityRecord)) {\n\t\tthrow new Error(t(\".profile-lock.json identity must be a JSON object\"));\n\t}\n\tconst identity = identityRecord as Record<string, unknown>;\n\tif (\n\t\ttypeof identity.profileId !== \"string\" ||\n\t\ttypeof identity.profileVersion !== \"string\" ||\n\t\ttypeof identity.manifestDigest !== \"string\" ||\n\t\t!Array.isArray(identity.capabilityVersions)\n\t) {\n\t\tthrow new Error(\n\t\t\tt(\".profile-lock.json identity must carry profileId/profileVersion/manifestDigest/capabilityVersions\"),\n\t\t);\n\t}\n\tconst capabilityVersions = identity.capabilityVersions.map((entry) => {\n\t\tif (entry === null || typeof entry !== \"object\" || Array.isArray(entry)) {\n\t\t\tthrow new Error(t(\".profile-lock.json identity.capabilityVersions entries must be objects\"));\n\t\t}\n\t\tconst capability = entry as Record<string, unknown>;\n\t\tif (typeof capability.id !== \"string\" || typeof capability.version !== \"number\") {\n\t\t\tthrow new Error(t(\".profile-lock.json identity.capabilityVersions entries must carry id/version\"));\n\t\t}\n\t\treturn { id: capability.id, version: capability.version };\n\t});\n\tif (\n\t\ttypeof record.lockedAt !== \"number\" ||\n\t\ttypeof record.lockedBy !== \"string\" ||\n\t\ttypeof record.generation !== \"number\"\n\t) {\n\t\tthrow new Error(t(\".profile-lock.json must carry lockedAt/lockedBy/generation\"));\n\t}\n\treturn Object.freeze({\n\t\tidentity: Object.freeze({\n\t\t\tprofileId: identity.profileId,\n\t\t\tprofileVersion: identity.profileVersion,\n\t\t\tmanifestDigest: identity.manifestDigest,\n\t\t\tcapabilityVersions: Object.freeze(capabilityVersions.map((ref) => Object.freeze({ ...ref }))),\n\t\t}),\n\t\tlockedAt: record.lockedAt,\n\t\tlockedBy: record.lockedBy,\n\t\tgeneration: record.generation,\n\t});\n}\n\n/**\n * Locates and lazily provisions `<agentDir>/suites/<id>/`: the builtin pair\n * gets its factory suite.json plus an empty agents.md skeleton on first start\n * (设计 §5). Corruption policy (设计 §9): builtin suites fall back to factory\n * content with diagnostics; user suites fail fast with the file path.\n */\nexport function loadSuiteWorkspace(options: {\n\tagentDir: string;\n\tsuiteId: string;\n\tpluginProfile?: BuiltinPluginProfileResolutionV1;\n}): SuiteWorkspace {\n\tconst { agentDir, suiteId } = options;\n\tconst suiteDir = getSuiteWorkspaceDir(agentDir, suiteId);\n\tconst suiteJsonPath = join(suiteDir, SUITE_MANIFEST_FILENAME);\n\tconst agentsMdPath = join(suiteDir, SUITE_AGENTS_MD_FILENAME);\n\tconst diagnostics: string[] = [];\n\n\tlet suite: SuiteDefinition;\n\tif (!existsSync(suiteJsonPath)) {\n\t\tconst builtin = getBuiltinSuite(suiteId);\n\t\tif (builtin === undefined) throw new SuiteResolutionError(suiteId, listSuiteIds(agentDir));\n\t\tmkdirSync(suiteDir, { recursive: true });\n\t\twriteFileSync(suiteJsonPath, serializeSuiteJson(builtin), \"utf8\");\n\t\t// D-075 S4 第三批:首启不再预种角色文件——种子移到 subagent-delegate 插件\n\t\t// 注册期(entry 的幂等 seedFactoryRoleCatalog 补缺),插件安装并注册时\n\t\t// `<agentDir>/roles/{explore,reviewer}.json` 自然到位。\n\t\tsuite = builtin;\n\t} else {\n\t\tconst parsed = parseSuiteJson(readFileSync(suiteJsonPath, \"utf8\"), {\n\t\t\texpectedBuiltin: getBuiltinSuite(suiteId) !== undefined,\n\t\t\texpectedId: suiteId,\n\t\t});\n\t\tconst builtin = getBuiltinSuite(suiteId);\n\t\tif (parsed.valid && parsed.suite) {\n\t\t\tsuite = parsed.suite;\n\t\t} else if (builtin !== undefined) {\n\t\t\t// Builtin corruption policy (设计 §9): fall back to factory content\n\t\t\t// with diagnostics instead of locking the user out. The file on disk\n\t\t\t// is left untouched; recovery (reset) is an explicit M4 flow.\n\t\t\tsuite = builtin;\n\t\t\tdiagnostics.push(\n\t\t\t\t`suite.json at ${suiteJsonPath} is invalid; falling back to the factory content for builtin suite \"${suiteId}\". Errors: ${parsed.errors.join(\"; \")}`,\n\t\t\t);\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\tt(\n\t\t\t\t\t\"Invalid suite.json at {path}: {errors}. Fix the file, or delete the suite workspace directory {dir} and recreate it.\",\n\t\t\t\t\t{ path: suiteJsonPath, errors: parsed.errors.join(\"; \"), dir: suiteDir },\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tif (!existsSync(agentsMdPath)) {\n\t\twriteFileSync(agentsMdPath, \"\", \"utf8\");\n\t}\n\n\t// Suite profile lock persistence (M4, 设计 §12): an existing lock file is\n\t// verified against the current identity (drift/migration recorded, never\n\t// blocking and never silently replaced); without one a fresh lock is frozen\n\t// and persisted. A lock file that cannot be parsed is recreated with a\n\t// diagnostic — it carries no openable identity, so nothing is silently\n\t// replaced.\n\tconst lockPath = join(suiteDir, SUITE_LOCK_FILENAME);\n\tlet previousLock: ProfileLockV1 | undefined;\n\tif (existsSync(lockPath)) {\n\t\ttry {\n\t\t\tpreviousLock = parseSuiteProfileLockFile(readFileSync(lockPath, \"utf8\"));\n\t\t} catch (error) {\n\t\t\tdiagnostics.push(\n\t\t\t\t`Profile lock at ${lockPath} is unreadable; recreating it over the current suite identity. Errors: ${\n\t\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t\t}`,\n\t\t\t);\n\t\t}\n\t}\n\tconst bridge = bridgeSuiteProfileLock({\n\t\tsuite,\n\t\t...(options.pluginProfile === undefined ? {} : { pluginProfile: options.pluginProfile }),\n\t\t...(previousLock === undefined ? {} : { previousLock }),\n\t\tlockedBy: \"suite-loader\",\n\t});\n\tdiagnostics.push(...bridge.diagnostics);\n\tif (previousLock === undefined) {\n\t\ttry {\n\t\t\twriteFileSync(lockPath, serializeSuiteProfileLockFile(bridge.lock), \"utf8\");\n\t\t} catch (error) {\n\t\t\tdiagnostics.push(\n\t\t\t\t`Failed to persist the suite profile lock at ${lockPath}: ${\n\t\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t\t}`,\n\t\t\t);\n\t\t}\n\t}\n\n\t// Orientation persona resolution (设计 §6.3): assistant/coding use the\n\t// compiled persona texts; custom reads the workspace persona.md verbatim\n\t// (BOM stripped, never trimmed), degrading to an empty persona with a\n\t// diagnostic instead of silently falling back to a builtin persona.\n\tconst personaPath = join(suiteDir, SUITE_PERSONA_MD_FILENAME);\n\tlet orientationPersona: string;\n\tif (suite.orientation !== \"custom\") {\n\t\torientationPersona = ORIENTATION_PROMPTS[suite.orientation];\n\t} else if (!existsSync(personaPath)) {\n\t\torientationPersona = \"\";\n\t\tdiagnostics.push(\n\t\t\t`Suite \"${suiteId}\" orientation is \"custom\" but ${personaPath} is missing; the orientation prompt stays empty until the file is created`,\n\t\t);\n\t} else {\n\t\ttry {\n\t\t\torientationPersona = stripBom(readFileSync(personaPath, \"utf8\"));\n\t\t} catch (error) {\n\t\t\torientationPersona = \"\";\n\t\t\tdiagnostics.push(\n\t\t\t\t`Persona file at ${personaPath} is unreadable; the orientation prompt stays empty. Errors: ${\n\t\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t\t}`,\n\t\t\t);\n\t\t}\n\t}\n\n\treturn {\n\t\tsuite,\n\t\tsuiteDir,\n\t\tsuiteJsonPath,\n\t\tagentsMdPath,\n\t\torientationPersona,\n\t\tdiagnostics: Object.freeze(diagnostics),\n\t\tlockPath,\n\t\tlock: bridge.lock,\n\t\tidentity: bridge.identity,\n\t\t...(bridge.verification === undefined ? {} : { lockVerification: bridge.verification }),\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// agents.md three-level chain (设计 §8)\n// ---------------------------------------------------------------------------\n\nexport type SuiteAgentsMdSource = \"system\" | \"suite\" | \"project\";\n\nexport interface SuiteAgentsMdEntry {\n\treadonly source: SuiteAgentsMdSource;\n\treadonly path: string;\n\treadonly content: string;\n}\n\nexport interface SuiteAgentsMdAssembly {\n\treadonly chain: readonly SuiteAgentsMdEntry[];\n\treadonly diagnostics: readonly string[];\n}\n\nexport interface AssembleSuiteAgentsMdChainOptions {\n\treadonly suite: SuiteDefinition;\n\treadonly agentDir: string;\n\treadonly suiteJsonPath: string;\n\treadonly suiteAgentsMdPath: string;\n\t/**\n\t * Project-level context files exactly as produced by the existing resource\n\t * loader (`ResourceLoader.getAgentsFiles()`: agentDir global entry first,\n\t * then the AGENTS.md/CLAUDE.md ancestor chain). The ancestor chain logic is\n\t * delegated, never reimplemented; entries under agentDir are classified as\n\t * system-layer candidates.\n\t */\n\treadonly projectAgentsFiles: ReadonlyArray<{ path: string; content: string }>;\n}\n\nfunction readContextFile(path: string): string {\n\ttry {\n\t\treturn stripBom(readFileSync(path, \"utf8\"));\n\t} catch {\n\t\treturn \"\";\n\t}\n}\n\nfunction isUnderDir(path: string, dir: string): boolean {\n\tconst resolvedPath = resolve(path);\n\tconst resolvedDir = resolve(dir);\n\tconst prefix = resolvedDir.endsWith(sep) ? resolvedDir : `${resolvedDir}${sep}`;\n\treturn resolvedPath.startsWith(prefix);\n}\n\n/**\n * Assembles the agents.md three-level chain (设计 §8): system layer (the\n * agentDir context file the resource loader's agentsFiles already carries,\n * e.g. AGENTS.md, gated by inheritSystemAgentsMd) -> suite layer\n * (`suites/<id>/agents.md`) -> project layer (existing ancestor chain, passed\n * in unchanged). The global SYSTEM.md/APPEND_SYSTEM.md never ride the chain:\n * they keep their native system prompt channel and are gated there by\n * createSuiteSystemPromptGate, so both channels stay single-sourced. Every\n * entry carries its source label; missing layers are skipped. Diagnostics\n * record a blocked system layer (one-time migration hint) and the empty\n * association counts (设计 §11.3: 惰性 + 可观测).\n */\nexport function assembleSuiteAgentsMdChain(options: AssembleSuiteAgentsMdChainOptions): SuiteAgentsMdAssembly {\n\tconst { suite, agentDir, suiteJsonPath, suiteAgentsMdPath, projectAgentsFiles } = options;\n\tconst diagnostics: string[] = [];\n\n\t// System-layer candidates are the agentDir entries already present in the\n\t// loader's agentsFiles; they are never read from disk here again.\n\tconst systemCandidates = projectAgentsFiles\n\t\t.filter((entry) => isUnderDir(entry.path, agentDir))\n\t\t.map((entry) => ({ path: entry.path, content: entry.content }));\n\tconst projectEntries = projectAgentsFiles.filter((entry) => !isUnderDir(entry.path, agentDir));\n\n\tconst chain: SuiteAgentsMdEntry[] = [];\n\tif (suite.inheritSystemAgentsMd) {\n\t\tfor (const candidate of systemCandidates) {\n\t\t\tchain.push({ source: \"system\", path: candidate.path, content: candidate.content });\n\t\t}\n\t} else if (systemCandidates.length > 0) {\n\t\tdiagnostics.push(\n\t\t\t`Suite \"${suite.id}\" does not inherit the system agents.md layer (inheritSystemAgentsMd=false); system-layer file(s) kept out of the suite chain: ${systemCandidates\n\t\t\t\t.map((candidate) => candidate.path)\n\t\t\t\t.join(\n\t\t\t\t\t\", \",\n\t\t\t\t)}. Migrate them into ${suiteAgentsMdPath} or set \"inheritSystemAgentsMd\": true in ${suiteJsonPath}.`,\n\t\t);\n\t}\n\n\tchain.push({ source: \"suite\", path: suiteAgentsMdPath, content: readContextFile(suiteAgentsMdPath) });\n\tfor (const entry of projectEntries) {\n\t\tchain.push({ source: \"project\", path: entry.path, content: entry.content });\n\t}\n\n\t// Plugin associations are wired since M3 (the sdk filters the external\n\t// capability plugin pool by associations.plugins); mcp stays\n\t// declaration-only until M4.\n\tdiagnostics.push(\n\t\t`Suite \"${suite.id}\" mcp associations are declaration-only until M4; MCP association filtering is unwired.`,\n\t);\n\n\treturn { chain: Object.freeze(chain), diagnostics: Object.freeze(diagnostics) };\n}\n\n/**\n * Merges the assembled chain with the resource loader's own agentsFiles for\n * the contextFiles injection channel: chain entries are prepended unless they\n * are empty or already present in the base. Entries with empty content inject\n * nothing, so a fresh factory skeleton changes no prompt bytes. Base entries\n * under agentDir are dropped unconditionally (设计 §8): with\n * inheritSystemAgentsMd=false the switch blocks the system layer, with true\n * the chain already carries it at the head — keeping it in the base too would\n * duplicate it and pin it after the suite layer, breaking the\n * system -> suite -> project order.\n */\nexport function mergeSuiteAgentsFiles(\n\tchain: readonly SuiteAgentsMdEntry[],\n\tbase: ReadonlyArray<{ path: string; content: string }>,\n\toptions: { agentDir: string },\n): Array<{ path: string; content: string }> {\n\tconst retainedBase = base.filter((entry) => !isUnderDir(entry.path, options.agentDir));\n\tconst basePathSet = new Set(retainedBase.map((entry) => resolve(entry.path)));\n\tconst merged: Array<{ path: string; content: string }> = [];\n\tfor (const entry of chain) {\n\t\tif (entry.content.trim().length === 0) continue;\n\t\tif (basePathSet.has(resolve(entry.path))) continue;\n\t\tmerged.push({ path: entry.path, content: entry.content });\n\t}\n\tmerged.push(...retainedBase.map((entry) => ({ path: entry.path, content: entry.content })));\n\treturn merged;\n}\n\nexport interface SuiteSystemPromptGate {\n\t/** Gates the loader's main system prompt: the discovered file's content, or undefined. */\n\treadonly systemPromptOverride: (base: string | undefined) => string | undefined;\n\t/** Gates the loader's append system prompt: the discovered file's content array. */\n\treadonly appendSystemPromptOverride: (base: string[]) => string[];\n\t/** Blocked global system-layer files; filled as the overrides run, deduplicated. */\n\treadonly diagnostics: readonly string[];\n}\n\n/**\n * Gates the global SYSTEM.md/APPEND_SYSTEM.md system prompt channel by\n * inheritSystemAgentsMd (设计 §8: the switch governs the whole system layer,\n * not just the agents.md chain). The resource loader feeds both overrides with\n * the resolved content of exactly one discovered file — project-level\n * `<cwd>/.agent-forge/<name>` first, else global `<agentDir>/<name>` — with no\n * path attached, so project-level existence identifies the base origin:\n * present means the project layer, which per 设计 §4 is the third level and\n * always passes the switch; absent means a global source, which passes only\n * when the suite inherits the system layer. Blocked global files are recorded\n * in diagnostics with their paths (one-time migration hint, 设计 §11.3).\n */\nexport function createSuiteSystemPromptGate(\n\tsuite: SuiteDefinition,\n\toptions: { cwd: string; agentDir: string },\n): SuiteSystemPromptGate {\n\tconst diagnostics: string[] = [];\n\tconst passes = (filename: string): boolean => {\n\t\tconst projectPath = join(options.cwd, CONFIG_DIR_NAME, filename);\n\t\tif (existsSync(projectPath)) return true;\n\t\tif (suite.inheritSystemAgentsMd) return true;\n\t\tconst message =\n\t\t\t`Suite \"${suite.id}\" does not inherit the global system layer (inheritSystemAgentsMd=false); ` +\n\t\t\t`global file kept out of the model context: ${join(options.agentDir, filename)}. Move it to the ` +\n\t\t\t`project level (${projectPath}) or set \"inheritSystemAgentsMd\": true in the suite.json.`;\n\t\tif (!diagnostics.includes(message)) diagnostics.push(message);\n\t\treturn false;\n\t};\n\treturn {\n\t\tsystemPromptOverride: (base) => (base === undefined || passes(\"SYSTEM.md\") ? base : undefined),\n\t\tappendSystemPromptOverride: (base) => (base.length === 0 || passes(\"APPEND_SYSTEM.md\") ? base : []),\n\t\tdiagnostics,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Association filtering (设计 §3/§4/§11.3, M1b)\n// ---------------------------------------------------------------------------\n\nexport type SuiteAssociationKind = \"skills\" | \"plugins\" | \"capabilities\";\n\nexport interface SuiteAssociationFilterResult<T> {\n\t/** Entries that pass the filter, in input order. */\n\treadonly kept: T[];\n\t/** Association names that matched no discovered entry (设计 §11.3 dangling). */\n\treadonly dangling: readonly string[];\n}\n\n/**\n * Single-sourced dangling-association diagnostic text (设计 §11.3): reported\n * through the suiteDiagnostics channel, never thrown.\n */\nexport function suiteDanglingAssociationDiagnostic(suiteId: string, kind: SuiteAssociationKind, name: string): string {\n\treturn `Suite \"${suiteId}\" dangling association \"${name}\" (${kind}): not found in the discovered registry; ignored.`;\n}\n\n/**\n * Filters the discovered skills down to the suite's skill associations (设计\n * §3: the filter lives in the assembler; discovery stays untouched). Project\n * scope (`<cwd>/.agent-forge/`) is the third layer (设计 §4) and always passes;\n * every other entry is kept only when its `Skill.name` exactly matches an\n * `associations.skills` entry. Association names that match no discovered\n * skill — including case mismatches — are reported as dangling.\n *\n * `options.localSkillsDir` is the suite-local skill layer (统一修复轮 B:\n * `<agentDir>/suites/<id>/skills`): its entries live inside the active suite\n * workspace, so suite activation is their association and they pass the filter\n * by path — the suite-local layer exemption — instead of requiring an\n * association entry.\n */\nexport function filterSuiteSkills(\n\tsuite: SuiteDefinition,\n\tskills: ReadonlyArray<Skill>,\n\toptions?: { localSkillsDir?: string },\n): SuiteAssociationFilterResult<Skill> {\n\tconst associated = new Set(suite.associations.skills);\n\tconst discovered = new Set(skills.map((skill) => skill.name));\n\tconst dangling = suite.associations.skills.filter((name) => !discovered.has(name));\n\tconst localSkillsDir = options?.localSkillsDir;\n\tconst kept = skills.filter(\n\t\t(skill) =>\n\t\t\tskill.sourceInfo.scope === \"project\" ||\n\t\t\t(localSkillsDir !== undefined && isUnderDir(skill.filePath, localSkillsDir)) ||\n\t\t\tassociated.has(skill.name),\n\t);\n\treturn { kept, dangling: Object.freeze(dangling) };\n}\n\n// ---------------------------------------------------------------------------\n// Capability plugin pool filtering (设计 §10.4, M3)\n// ---------------------------------------------------------------------------\n\n/** One external capability plugin manifest discovered below a plugin pool root. */\nexport interface SuiteCapabilityPluginCandidate {\n\t/** Exact manifest id (`PluginManifest.id`). */\n\treadonly manifestId: string;\n\t/** Resolved manifest path, as it will be reported in diagnostics. */\n\treadonly manifestPath: string;\n}\n\nexport interface SuiteCapabilityPluginDecision {\n\treadonly keep: boolean;\n\t/** Diagnostic for a filtered-out plugin; absent when the plugin passes. */\n\treadonly diagnostic?: string;\n}\n\n/**\n * Decides one external capability plugin manifest against the suite's\n * `associations.plugins` (方案设计 §10.4, M3 双键语义: associations.plugins\n * governs only the external capability plugin pool; suite.capabilities governs\n * the compiled builtin ids). The project-level pool\n * (`<cwd>/.agent-forge/plugins`) is the third layer (设计 §4) and always\n * passes; every other manifest is kept only when its id matches an\n * association exactly. Filtered plugins surface as diagnostics, never as\n * errors.\n */\nexport function decideSuiteCapabilityPlugin(\n\tsuite: SuiteDefinition,\n\tcandidate: SuiteCapabilityPluginCandidate,\n\toptions: { cwd: string },\n): SuiteCapabilityPluginDecision {\n\tif (isUnderDir(candidate.manifestPath, join(options.cwd, CONFIG_DIR_NAME, \"plugins\"))) return { keep: true };\n\tif (suite.associations.plugins.includes(candidate.manifestId)) return { keep: true };\n\treturn {\n\t\tkeep: false,\n\t\tdiagnostic: `Suite \"${suite.id}\" capability plugin \"${candidate.manifestId}\" at ${candidate.manifestPath} is not associated; not loaded.`,\n\t};\n}\n\n/**\n * Dangling `associations.plugins` entries: association ids that matched no\n * candidate capability plugin manifest (设计 §11.3), single-sourced through\n * the shared dangling diagnostic text. The caller decides what counts as a\n * candidate: the sdk assembler passes every manifest id it loads, so explicit\n * capabilityPluginPaths count toward satisfying an association even though\n * they bypass the keep filter; only manifests absent from the passed ids\n * surface as dangling.\n */\nexport function suiteDanglingPluginAssociations(\n\tsuite: SuiteDefinition,\n\tdiscoveredManifestIds: readonly string[],\n): readonly string[] {\n\tconst discovered = new Set(discoveredManifestIds);\n\treturn suite.associations.plugins\n\t\t.filter((id) => !discovered.has(id))\n\t\t.map((id) => suiteDanglingAssociationDiagnostic(suite.id, \"plugins\", id));\n}\n\n// ---------------------------------------------------------------------------\n// Shared suite loader assembly (设计 §3/§4/§8, M2)\n// ---------------------------------------------------------------------------\n\n/**\n * The DefaultResourceLoader override subset that wires a resolved suite into a\n * loader: the agents.md three-level chain, the skill/extension association\n * filters, and the inheritSystemAgentsMd gate on the global SYSTEM.md/\n * APPEND_SYSTEM.md prompt channel. Structurally compatible with the matching\n * DefaultResourceLoaderOptions fields.\n */\nexport interface SuiteLoaderOverrides {\n\tagentsFilesOverride: (base: { agentsFiles: Array<{ path: string; content: string }> }) => {\n\t\tagentsFiles: Array<{ path: string; content: string }>;\n\t};\n\tskillsOverride: (base: { skills: Skill[]; diagnostics: ResourceDiagnostic[] }) => {\n\t\tskills: Skill[];\n\t\tdiagnostics: ResourceDiagnostic[];\n\t};\n\tsystemPromptOverride: (base: string | undefined) => string | undefined;\n\tappendSystemPromptOverride: (base: string[]) => string[];\n}\n\nexport interface SuiteAssembly {\n\treadonly workspace: SuiteWorkspace;\n\t/** Optional domain plugin profile selected for this suite. */\n\treadonly pluginProfile?: BuiltinPluginProfileResolutionV1;\n\t/** Spread into DefaultResourceLoader options to wire the suite in. */\n\treadonly loaderOverrides: SuiteLoaderOverrides;\n\t/**\n\t * The suite-local skill layer directory (统一修复轮 B) when it exists on\n\t * disk; inject it into the loader's skill paths so suites/<id>/skills load\n\t * with the suite itself. Undefined when the directory is absent, so empty\n\t * and missing directories both contribute nothing.\n\t */\n\treadonly localSkillsDir?: string;\n\t/**\n\t * The suite-local capability-plugin layer directory (统一修复轮 B) when it\n\t * exists on disk; discover its manifests into the session's capability\n\t * plugin candidates. Undefined when the directory is absent.\n\t */\n\treadonly localPluginsDir?: string;\n\t/**\n\t * Snapshot of every suite assembly diagnostic collected so far — workspace\n\t * provisioning, agents.md chain, extension/skill filters, system prompt\n\t * gate, context budget — in the canonical suiteDiagnostics order. Overrides\n\t * that have not run yet contribute nothing (the budget line needs the\n\t * assembled agents.md chain).\n\t */\n\tcollectDiagnostics(): readonly string[];\n}\n\n/**\n * Single-sourced assembly-layer context budget estimate (统一修复轮 B): pure\n * chars/4 arithmetic over the assembled agents.md chain (per source layer),\n * the orientation persona text, plus the count of suite-local workspace\n * skills. Diagnostic-only: it never blocks, gates, or degrades anything.\n */\nexport function suiteContextBudgetDiagnostic(\n\tsuiteId: string,\n\tchain: ReadonlyArray<SuiteAgentsMdEntry>,\n\toptions: { personaChars: number; workspaceSkillCount: number },\n): string {\n\tconst layerChars: Record<SuiteAgentsMdSource, number> = { system: 0, suite: 0, project: 0 };\n\tfor (const entry of chain) {\n\t\tlayerChars[entry.source] += entry.content.length;\n\t}\n\tconst tokens = (chars: number): number => Math.round(chars / 4);\n\tconst system = tokens(layerChars.system);\n\tconst suiteLayer = tokens(layerChars.suite);\n\tconst project = tokens(layerChars.project);\n\treturn `Suite \"${suiteId}\" context budget: agents.md ~${system + suiteLayer + project} tok (system ${system}/suite ${suiteLayer}/project ${project}), persona ~${tokens(options.personaChars)} tok, workspace skills ${options.workspaceSkillCount}`;\n}\n\n/**\n * Plugin-profile diagnostics in the canonical suiteDiagnostics order.\n *\n * D-075 S2 soft degradation: a resolved Profile renders structured per-plugin\n * misses (e.g. `manifest_missing` for a package-distributed plugin without an\n * installed active version) as readable diagnostics, so the session keeps\n * starting without the missing plugin's tools and the miss stays visible.\n * Blocked resolutions already render every plugin diagnostic through\n * `resolution.diagnostics`; the per-plugin lines are additive for the\n * non-blocked branches only.\n */\nfunction pluginProfileDiagnosticsV1(profile: BuiltinPluginProfileResolutionV1): readonly string[] {\n\tif (profile.status === \"not_found\") return [`Plugin profile unavailable: ${profile.profileId}`];\n\tif (profile.status === \"host_facts_required\") return [`Plugin profile host facts required: ${profile.profileId}`];\n\tif (profile.status === \"invalid_selection\")\n\t\treturn [\n\t\t\t`Plugin profile invalid selection: ${profile.profileId} (unknown: ${profile.unknownPluginIds.join(\", \") || \"none\"}; duplicates: ${profile.duplicatePluginIds.join(\", \") || \"none\"})`,\n\t\t];\n\tconst pluginMisses =\n\t\tprofile.resolution.status === \"blocked\"\n\t\t\t? []\n\t\t\t: profile.resolution.plugins\n\t\t\t\t\t.filter((plugin) => plugin.status !== \"installed-ready\")\n\t\t\t\t\t.flatMap((plugin) =>\n\t\t\t\t\t\tplugin.diagnostics.map(\n\t\t\t\t\t\t\t(diagnostic) =>\n\t\t\t\t\t\t\t\t`Plugin profile plugin unavailable: ${plugin.pluginId} (${diagnostic.code}): ${diagnostic.message}`,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\tif (profile.resolution.status === \"blocked\")\n\t\treturn profile.resolution.diagnostics.map((diagnostic) => `Plugin profile blocked: ${diagnostic.message}`);\n\tif (profile.assembly?.status === \"unverified\")\n\t\treturn [\n\t\t\t...profile.assembly.unverified.map(\n\t\t\t\t(plugin) => `Plugin profile unverified: ${plugin.pluginId}@${plugin.pluginVersion}`,\n\t\t\t),\n\t\t\t...pluginMisses,\n\t\t];\n\treturn pluginMisses;\n}\n\n/**\n * The single suite assembly used by both first-party entry paths (sdk.ts\n * self-built loader and agent-session-services `suiteAssembly`), so the two\n * cannot drift. Loads the suite workspace, builds the system prompt gate, and\n * returns the loader overrides plus a diagnostics collection channel.\n */\nexport function createSuiteAssembly(options: {\n\tcwd: string;\n\tagentDir: string;\n\tsuiteId: string;\n\tpluginProfileId?: BuiltinPluginProfileIdV1;\n\tselectedPluginIds?: readonly string[];\n\tdisabledPluginIds?: readonly string[];\n\tpluginHost?: HostFactsV1;\n\tverifiedPlugins?: readonly VerifiedToolPluginV1[];\n\t/** Explicit host-owned active installed manifests; never discovered implicitly. */\n\tmanifestOverrides?: BuiltinPluginManifestOverridesV1;\n\tpluginProfile?: BuiltinPluginProfileResolutionV1;\n}): SuiteAssembly {\n\tconst { cwd, agentDir, suiteId } = options;\n\tlet pluginProfile = options.pluginProfile;\n\tif (pluginProfile === undefined && options.pluginProfileId !== undefined) {\n\t\tpluginProfile =\n\t\t\toptions.pluginHost === undefined\n\t\t\t\t? ({ status: \"host_facts_required\", profileId: options.pluginProfileId } as const)\n\t\t\t\t: resolveBuiltinPluginProfileV1({\n\t\t\t\t\t\tprofileId: options.pluginProfileId,\n\t\t\t\t\t\tselectedPluginIds: options.selectedPluginIds,\n\t\t\t\t\t\tdisabledPluginIds: options.disabledPluginIds,\n\t\t\t\t\t\thost: options.pluginHost,\n\t\t\t\t\t\tverifiedPlugins: options.verifiedPlugins,\n\t\t\t\t\t\tmanifestOverrides: options.manifestOverrides,\n\t\t\t\t\t});\n\t}\n\tconst workspace = loadSuiteWorkspace({\n\t\tagentDir,\n\t\tsuiteId,\n\t\t...(pluginProfile === undefined ? {} : { pluginProfile }),\n\t});\n\tconst gate = createSuiteSystemPromptGate(workspace.suite, { cwd, agentDir });\n\t// Suite-local asset layer (统一修复轮 B): present directories only, so\n\t// missing and empty directories both contribute nothing.\n\tconst localSkillsDir = getSuiteLocalSkillsDir(agentDir, suiteId);\n\tconst localPluginsDir = getSuiteLocalPluginsDir(agentDir, suiteId);\n\tconst hasLocalSkillsDir = existsSync(localSkillsDir);\n\tconst hasLocalPluginsDir = existsSync(localPluginsDir);\n\tconst workspaceSkillCount = hasLocalSkillsDir\n\t\t? loadSkills({ cwd, agentDir, skillPaths: [localSkillsDir], includeDefaults: false }).skills.length\n\t\t: 0;\n\tlet chainDiagnostics: readonly string[] = [];\n\tlet skillDiagnostics: readonly string[] = [];\n\t// The assembled chain as far as the agentsFilesOverride has run; the budget\n\t// line is only honest once the real chain is known.\n\tlet assembledChain: readonly SuiteAgentsMdEntry[] | undefined;\n\t// Factory upgrade proposal (M4, 设计 §9 升级合并): an unbounded registry\n\t// resolve only proposes when the factory source wins, i.e. its revision is\n\t// strictly greater than the disk revision. Daily assembly keeps the disk\n\t// contents; adoption is an explicit --suite-reset.\n\tconst upgrade = detectSuiteFactoryUpgrade(workspace.suite);\n\tconst proposalDiagnostics = upgrade === undefined ? [] : [suiteFactoryUpgradeDiagnostic(suiteId, upgrade)];\n\tconst budgetDiagnostics = (): readonly string[] => {\n\t\tif (assembledChain === undefined) return [];\n\t\treturn [\n\t\t\tsuiteContextBudgetDiagnostic(suiteId, assembledChain, {\n\t\t\t\tpersonaChars: workspace.orientationPersona.length,\n\t\t\t\tworkspaceSkillCount,\n\t\t\t}),\n\t\t];\n\t};\n\treturn {\n\t\tworkspace,\n\t\t...(pluginProfile === undefined ? {} : { pluginProfile }),\n\t\t...(hasLocalSkillsDir ? { localSkillsDir } : {}),\n\t\t...(hasLocalPluginsDir ? { localPluginsDir } : {}),\n\t\tloaderOverrides: {\n\t\t\tagentsFilesOverride: (base) => {\n\t\t\t\tconst assembly = assembleSuiteAgentsMdChain({\n\t\t\t\t\tsuite: workspace.suite,\n\t\t\t\t\tagentDir,\n\t\t\t\t\tsuiteJsonPath: workspace.suiteJsonPath,\n\t\t\t\t\tsuiteAgentsMdPath: workspace.agentsMdPath,\n\t\t\t\t\tprojectAgentsFiles: base.agentsFiles,\n\t\t\t\t});\n\t\t\t\tchainDiagnostics = assembly.diagnostics;\n\t\t\t\tassembledChain = assembly.chain;\n\t\t\t\treturn { agentsFiles: mergeSuiteAgentsFiles(assembly.chain, base.agentsFiles, { agentDir }) };\n\t\t\t},\n\t\t\tskillsOverride: (base) => {\n\t\t\t\tconst filtered = filterSuiteSkills(workspace.suite, base.skills, { localSkillsDir });\n\t\t\t\tskillDiagnostics = filtered.dangling.map((name) =>\n\t\t\t\t\tsuiteDanglingAssociationDiagnostic(suiteId, \"skills\", name),\n\t\t\t\t);\n\t\t\t\treturn { skills: filtered.kept, diagnostics: base.diagnostics };\n\t\t\t},\n\t\t\tsystemPromptOverride: gate.systemPromptOverride,\n\t\t\tappendSystemPromptOverride: gate.appendSystemPromptOverride,\n\t\t},\n\t\tcollectDiagnostics: () =>\n\t\t\tObject.freeze([\n\t\t\t\t...workspace.diagnostics,\n\t\t\t\t...(pluginProfile === undefined ? [] : pluginProfileDiagnosticsV1(pluginProfile)),\n\t\t\t\t...proposalDiagnostics,\n\t\t\t\t...chainDiagnostics,\n\t\t\t\t...skillDiagnostics,\n\t\t\t\t...budgetDiagnostics(),\n\t\t\t\t...gate.diagnostics,\n\t\t\t]),\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Session suite binding reader (设计 §10.1, 统一修复轮 B)\n// ---------------------------------------------------------------------------\n\n/**\n * Reads the suite binding recorded as session protocol data (设计 §10.1): the\n * suiteId of the latest `SUITE_SESSION_ENTRY_TYPE` custom entry. Undefined\n * when the session carries no binding — pre-suite sessions, entries without a\n * data payload, or payloads without a non-empty string suiteId.\n */\nexport function readSessionSuiteId(\n\tentries: ReadonlyArray<{ type: string; customType?: string; data?: unknown }>,\n): string | undefined {\n\treturn readSessionSuiteBinding(entries)?.suiteId;\n}\n\nexport interface SessionSuiteBindingV1 {\n\treadonly suiteId: string;\n\treadonly profileIdentity?: ProfileIdentityV1;\n}\n\nfunction sessionProfileIdentity(value: unknown): ProfileIdentityV1 | undefined {\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) return undefined;\n\tconst record = value as Record<string, unknown>;\n\tif (\n\t\ttypeof record.profileId !== \"string\" ||\n\t\trecord.profileId.trim() === \"\" ||\n\t\ttypeof record.profileVersion !== \"string\" ||\n\t\trecord.profileVersion.trim() === \"\" ||\n\t\ttypeof record.manifestDigest !== \"string\" ||\n\t\trecord.manifestDigest.trim() === \"\" ||\n\t\t!Array.isArray(record.capabilityVersions)\n\t) {\n\t\treturn undefined;\n\t}\n\tconst capabilityVersions: { id: string; version: number }[] = [];\n\tfor (const entry of record.capabilityVersions) {\n\t\tif (entry === null || typeof entry !== \"object\" || Array.isArray(entry)) return undefined;\n\t\tconst capability = entry as Record<string, unknown>;\n\t\tif (\n\t\t\ttypeof capability.id !== \"string\" ||\n\t\t\tcapability.id.trim() === \"\" ||\n\t\t\ttypeof capability.version !== \"number\" ||\n\t\t\t!Number.isSafeInteger(capability.version) ||\n\t\t\tcapability.version < 1\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\t\tcapabilityVersions.push({ id: capability.id, version: capability.version });\n\t}\n\treturn Object.freeze({\n\t\tprofileId: record.profileId,\n\t\tprofileVersion: record.profileVersion,\n\t\tmanifestDigest: record.manifestDigest,\n\t\tcapabilityVersions: Object.freeze(capabilityVersions) as readonly {\n\t\t\treadonly id: string;\n\t\t\treadonly version: number;\n\t\t}[],\n\t});\n}\n\n/** Reads the latest suite and optional Profile identity bound to a session. */\nexport function readSessionSuiteBinding(\n\tentries: ReadonlyArray<{ type: string; customType?: string; data?: unknown }>,\n): SessionSuiteBindingV1 | undefined {\n\tfor (let index = entries.length - 1; index >= 0; index--) {\n\t\tconst entry = entries[index];\n\t\tif (entry.type !== \"custom\" || entry.customType !== SUITE_SESSION_ENTRY_TYPE) continue;\n\t\tconst data = entry.data;\n\t\tif (data !== null && typeof data === \"object\" && !Array.isArray(data)) {\n\t\t\tconst suiteId = (data as { suiteId?: unknown }).suiteId;\n\t\t\tif (typeof suiteId === \"string\" && suiteId.length > 0) {\n\t\t\t\tconst profileIdentity = sessionProfileIdentity((data as { profileIdentity?: unknown }).profileIdentity);\n\t\t\t\treturn Object.freeze({\n\t\t\t\t\tsuiteId,\n\t\t\t\t\t...(profileIdentity === undefined ? {} : { profileIdentity }),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\treturn undefined;\n}\n\n// ---------------------------------------------------------------------------\n// Suite -> ProfileIdentityV1 -> lock bridge (设计 §12)\n// ---------------------------------------------------------------------------\n\nfunction suiteToJsonValue(suite: SuiteDefinition): JsonValue {\n\treturn {\n\t\tschemaVersion: suite.schemaVersion,\n\t\tid: suite.id,\n\t\tname: suite.name,\n\t\tbuiltin: suite.builtin,\n\t\ttools: [...suite.tools],\n\t\tcapabilities: [...suite.capabilities],\n\t\tassociations: {\n\t\t\tskills: [...suite.associations.skills],\n\t\t\tmcp: [...suite.associations.mcp],\n\t\t\tplugins: [...suite.associations.plugins],\n\t\t},\n\t\tinheritSystemAgentsMd: suite.inheritSystemAgentsMd,\n\t\tmemory: suite.memory,\n\t\torientation: suite.orientation,\n\t\tmodel: suite.model,\n\t\tthinking: suite.thinking,\n\t\tclonedFrom: suite.clonedFrom\n\t\t\t? { id: suite.clonedFrom.id, digest: suite.clonedFrom.digest, at: suite.clonedFrom.at }\n\t\t\t: null,\n\t\t...(suite.factoryRevision === undefined ? {} : { factoryRevision: suite.factoryRevision }),\n\t};\n}\n\n/** The stable suite.json digest that rides as the suite profile manifest digest. */\nexport function suiteManifestDigest(suite: SuiteDefinition): string {\n\treturn stableJsonDigest(suiteToJsonValue(suite));\n}\n\n/**\n * Builds the ProfileIdentityV1 for an assembled suite. The identity is a pure\n * function of suite.json: the stable suite.json digest rides as the single\n * resolved \"manifest\", and the declared capabilities map to capability\n * references at version 1. No new identity/lock mechanism is introduced.\n */\nexport function buildSuiteProfileIdentity(\n\tsuite: SuiteDefinition,\n\tpluginProfile?: BuiltinPluginProfileResolutionV1,\n): ProfileIdentityV1 {\n\tconst fingerprint = suiteManifestDigest(suite);\n\tconst suiteCapabilityRefs = suite.capabilities.map((id) => ({ id, version: 1 }));\n\tconst pluginRefs =\n\t\tpluginProfile?.status === \"resolved\" && pluginProfile.resolution.status === \"ready\"\n\t\t\t? pluginProfile.resolution.resolvedManifest.plugins\n\t\t\t: [];\n\tconst capabilityRefs = [...suiteCapabilityRefs, ...pluginRefs.flatMap((plugin) => plugin.capabilityRefs)].sort(\n\t\t(left, right) => left.id.localeCompare(right.id) || left.version - right.version,\n\t);\n\treturn buildProfileIdentityV1({\n\t\tprofileId: suiteProfileId(suite.id),\n\t\tprofileVersion: `${SUITE_SCHEMA_VERSION}`,\n\t\tresolvedPlugins: [\n\t\t\t{\n\t\t\t\tpluginId: `${suite.id}/suite.json`,\n\t\t\t\tpluginVersion: fingerprint,\n\t\t\t\tcapabilityRefs: suiteCapabilityRefs,\n\t\t\t},\n\t\t\t...(pluginProfile?.status === \"resolved\" && pluginProfile.resolution.status === \"ready\"\n\t\t\t\t? [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpluginId: `profile:${pluginProfile.profile.id}`,\n\t\t\t\t\t\t\tpluginVersion: pluginProfile.profile.version,\n\t\t\t\t\t\t\tcapabilityRefs: [],\n\t\t\t\t\t\t},\n\t\t\t\t\t\t...pluginRefs,\n\t\t\t\t\t]\n\t\t\t\t: []),\n\t\t],\n\t\tcapabilityVersions: capabilityRefs,\n\t});\n}\n\n// ---------------------------------------------------------------------------\n// ProfileRegistryV1 hookup: factory/disk sources and upgrade proposals (M4)\n// ---------------------------------------------------------------------------\n\n/** Registry profileId namespace for suites (设计 §12). */\nexport function suiteProfileId(suiteId: string): string {\n\treturn `suite:${suiteId}`;\n}\n\nexport const SUITE_FACTORY_REGISTRY_SOURCE_ID = \"suite-factory\";\nexport const SUITE_DISK_REGISTRY_SOURCE_ID = \"suite-disk\";\n/** Lower priority wins same-version ties: the disk contents beat the factory. */\nconst SUITE_FACTORY_REGISTRY_PRIORITY = 10;\nconst SUITE_DISK_REGISTRY_PRIORITY = 0;\n\n/** The effective on-disk revision: absent key means FACTORY_CONTENTS_VERSION. */\nfunction suiteDiskRevision(suite: SuiteDefinition): number {\n\treturn suite.factoryRevision ?? FACTORY_CONTENTS_VERSION;\n}\n\n/** Builds the registry entry of one suite definition (version = factoryRevision). */\nexport function buildSuiteRegistryEntry(suite: SuiteDefinition): RegistryProfileEntryV1 {\n\treturn {\n\t\tprofileId: suiteProfileId(suite.id),\n\t\tprofileVersion: String(suiteDiskRevision(suite)),\n\t\tmanifestDigest: suiteManifestDigest(suite),\n\t};\n}\n\n/** Factory source over the builtin declarations (priority 10). */\nexport function buildSuiteFactoryRegistrySource(): RegistrySourceV1 {\n\treturn {\n\t\tsourceId: SUITE_FACTORY_REGISTRY_SOURCE_ID,\n\t\tpriority: SUITE_FACTORY_REGISTRY_PRIORITY,\n\t\tprofiles: BUILTIN_SUITES.map(buildSuiteRegistryEntry),\n\t};\n}\n\n/** Disk source over workspace-effective definitions (priority 0; wins ties). */\nexport function buildSuiteDiskRegistrySource(suites: readonly SuiteDefinition[]): RegistrySourceV1 {\n\treturn {\n\t\tsourceId: SUITE_DISK_REGISTRY_SOURCE_ID,\n\t\tpriority: SUITE_DISK_REGISTRY_PRIORITY,\n\t\tprofiles: suites.map(buildSuiteRegistryEntry),\n\t};\n}\n\nexport interface SuiteFactoryUpgrade {\n\t/** Revision the factory builtin declaration carries. */\n\treadonly factoryRevision: number;\n\t/** Revision effective on disk. */\n\treadonly diskRevision: number;\n}\n\n/** Single-sourced upgrade-proposal diagnostic text (设计 §9 升级合并). */\nexport function suiteFactoryUpgradeDiagnostic(suiteId: string, upgrade: SuiteFactoryUpgrade): string {\n\treturn `Suite \"${suiteId}\": factory revision ${upgrade.factoryRevision} available (disk has ${upgrade.diskRevision}); run \"--suite-reset ${suiteId}\" to review and adopt.`;\n}\n\n/**\n * Detects a factory upgrade proposal for one disk-effective suite: an\n * unbounded registry resolve over the factory source (all builtins) plus a\n * disk source carrying exactly the effective definition. The factory source\n * wins only when its revision is strictly greater — same-version resolves\n * keep the disk contents (priority 0), so no proposal is emitted for\n * unchanged suites, and user suites (no factory entry) never resolve to the\n * factory. Pure function; the caller decides what to do with the proposal.\n */\nexport function detectSuiteFactoryUpgrade(diskSuite: SuiteDefinition): SuiteFactoryUpgrade | undefined {\n\tconst registry = createProfileRegistry();\n\tregistry.registerSource(buildSuiteFactoryRegistrySource());\n\tregistry.registerSource(buildSuiteDiskRegistrySource([diskSuite]));\n\tconst resolution = registry.resolve({ profileId: suiteProfileId(diskSuite.id) });\n\tif (resolution.status !== \"resolved\" || resolution.sourceId !== SUITE_FACTORY_REGISTRY_SOURCE_ID) {\n\t\treturn undefined;\n\t}\n\treturn {\n\t\tfactoryRevision: Number.parseInt(resolution.profileVersion, 10),\n\t\tdiskRevision: suiteDiskRevision(diskSuite),\n\t};\n}\n\nexport interface SuiteProfileLockBridge {\n\treadonly identity: ProfileIdentityV1;\n\t/**\n\t * The lock for this assembly. When a previous lock exists it is kept as-is\n\t * (a lock is never silently replaced); without one, a fresh lock freezes\n\t * the current identity.\n\t */\n\treadonly lock: ProfileLockV1;\n\treadonly verification?: ProfileLockVerificationV1;\n\t/** Drift/migration findings; recorded, never blocking in M1a (设计 §12). */\n\treadonly diagnostics: readonly string[];\n}\n\n/** Bridges an assembled suite onto the existing lock create/verify trio. */\nexport function bridgeSuiteProfileLock(options: {\n\treadonly suite: SuiteDefinition;\n\treadonly pluginProfile?: BuiltinPluginProfileResolutionV1;\n\treadonly previousLock?: ProfileLockV1;\n\treadonly lockedBy?: string;\n\treadonly now?: () => number;\n}): SuiteProfileLockBridge {\n\tconst identity = buildSuiteProfileIdentity(options.suite, options.pluginProfile);\n\tconst diagnostics: string[] = [];\n\tlet verification: ProfileLockVerificationV1 | undefined;\n\tif (options.previousLock !== undefined) {\n\t\tverification = verifyProfileLock(options.previousLock, identity);\n\t\tif (verification.status === \"drift\") {\n\t\t\t// 2026-10-01 dogfood finding: the bare drift reason left no recovery\n\t\t\t// path. Deleting the lock file and restarting rebuilds it from the\n\t\t\t// resolved manifest (loadSuiteWorkspace re-freezes a fresh lock).\n\t\t\tdiagnostics.push(\n\t\t\t\t`Suite \"${options.suite.id}\" profile lock drift: ${verification.reason}; to recover, delete <agentDir>/suites/${options.suite.id}/${SUITE_LOCK_FILENAME} and restart (the lock rebuilds from the resolved manifest)`,\n\t\t\t);\n\t\t} else if (verification.status === \"migration_required\") {\n\t\t\tdiagnostics.push(`Suite \"${options.suite.id}\" profile lock migration required: ${verification.reason}`);\n\t\t}\n\t}\n\tconst lock =\n\t\toptions.previousLock ??\n\t\tcreateProfileLock(identity, {\n\t\t\tlockedBy: options.lockedBy ?? \"suite-loader\",\n\t\t\t...(options.now === undefined ? {} : { now: options.now }),\n\t\t});\n\treturn {\n\t\tidentity,\n\t\tlock,\n\t\t...(verification === undefined ? {} : { verification }),\n\t\tdiagnostics: Object.freeze(diagnostics),\n\t};\n}\n"]}
|