@ai-agent-forge/agent-forge 0.88.1 → 0.88.3
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 +71 -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 +283 -263
- 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-Z72JWUZ4.js → chunk-32YDZI4J.js} +1 -1
- package/dist/bundle/chunks/{chunk-AQLNTW2B.js → chunk-755VNWIF.js} +17 -16
- package/dist/bundle/chunks/{chunk-LZOEQITZ.js → chunk-B42Y2VME.js} +120 -104
- package/dist/bundle/chunks/{chunk-DRQDKNXA.js → chunk-BVVSHK6W.js} +1 -1
- package/dist/bundle/chunks/{chunk-6R7UI4IY.js → chunk-QDLOMKF6.js} +1 -1
- package/dist/bundle/chunks/{chunk-D3ARGZFR.js → chunk-V3ACW7VD.js} +3 -3
- 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 +3 -3
- 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/plugin-command.d.ts.map +1 -1
- package/dist/cli/plugin-command.js +8 -2
- package/dist/cli/plugin-command.js.map +1 -1
- 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-internal.d.ts +2 -0
- package/dist/core/agent-session-internal.d.ts.map +1 -1
- package/dist/core/agent-session-internal.js.map +1 -1
- package/dist/core/agent-session-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 +3 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +2 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-store.d.ts.map +1 -1
- package/dist/core/agent-session-store.js +6 -1
- package/dist/core/agent-session-store.js.map +1 -1
- package/dist/core/agent-session-tools.d.ts.map +1 -1
- package/dist/core/agent-session-tools.js +13 -0
- package/dist/core/agent-session-tools.js.map +1 -1
- package/dist/core/agent-session.d.ts +24 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +58 -4
- package/dist/core/agent-session.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-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 +6 -1
- 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/cli.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/cli.js +2 -0
- package/dist/core/i18n/locales/zh-cn/cli.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-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/index.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/index.js +2 -0
- package/dist/core/i18n/locales/zh-cn/index.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/interactive-mode.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/interactive-mode.js +5 -0
- package/dist/core/i18n/locales/zh-cn/interactive-mode.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/session-cleanup.d.ts +7 -0
- package/dist/core/i18n/locales/zh-cn/session-cleanup.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/session-cleanup.js +15 -0
- package/dist/core/i18n/locales/zh-cn/session-cleanup.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/slash-commands.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/slash-commands.js +1 -0
- package/dist/core/i18n/locales/zh-cn/slash-commands.js.map +1 -1
- package/dist/core/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 +30 -8
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-cleanup.d.ts +49 -0
- package/dist/core/session-cleanup.d.ts.map +1 -0
- package/dist/core/session-cleanup.js +159 -0
- package/dist/core/session-cleanup.js.map +1 -0
- package/dist/core/session-index.d.ts +75 -0
- package/dist/core/session-index.d.ts.map +1 -0
- package/dist/core/session-index.js +455 -0
- package/dist/core/session-index.js.map +1 -0
- package/dist/core/session-manager.d.ts +9 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +206 -51
- 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/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +5 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +12 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/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/capability-mount.d.ts +40 -0
- package/dist/core/tools/capability-mount.d.ts.map +1 -0
- package/dist/core/tools/capability-mount.js +112 -0
- package/dist/core/tools/capability-mount.js.map +1 -0
- package/dist/core/tools/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 +26 -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 +6 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +108 -27
- 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-search.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.js +5 -1
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +11 -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 +19 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +139 -4
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-run-group.d.ts +44 -0
- package/dist/modes/interactive/components/tool-run-group.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-run-group.js +121 -0
- package/dist/modes/interactive/components/tool-run-group.js.map +1 -0
- package/dist/modes/interactive/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 +125 -6
- package/dist/modes/interactive/interactive-commands.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-commands.js +698 -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 +254 -129
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +275 -2101
- 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/cli.d.ts.map +1 -1
- package/dist/plugins/ecosystem/cli.js +6 -3
- package/dist/plugins/ecosystem/cli.js.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts +7 -1
- package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-bootstrap.js +50 -3
- package/dist/plugins/ecosystem/node-plugin-bootstrap.js.map +1 -1
- package/dist/plugins/ecosystem/plugin-bootstrap.d.ts +28 -16
- package/dist/plugins/ecosystem/plugin-bootstrap.d.ts.map +1 -1
- package/dist/plugins/ecosystem/plugin-bootstrap.js +35 -33
- package/dist/plugins/ecosystem/plugin-bootstrap.js.map +1 -1
- package/dist/profile/plugin-profiles.d.ts +1 -1
- package/dist/profile/plugin-profiles.d.ts.map +1 -1
- package/dist/profile/plugin-profiles.js +18 -0
- package/dist/profile/plugin-profiles.js.map +1 -1
- package/dist/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/{profiles → suites}/builtin-suites.d.ts +14 -4
- package/dist/suites/builtin-suites.d.ts.map +1 -0
- package/dist/{profiles → suites}/builtin-suites.js +20 -5
- 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 +368 -354
- 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/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/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-WF6WRHP7.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}/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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAexE,YAAY,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEhG,kEAAkE;AAClE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,MAAM,CA0L3E","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport type { BuildSystemPromptOptions } from \"@agent-forge/plugin-sdk\";\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.ts\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.ts\";\n\n// Capability tool guides (memory / task management) moved to their owning\n// plugins in D-071 (the memory capability itself moved to the\n// @agent-forge/plugin-memory package in D-075 S4-4): the plugin's\n// MEMORY_TOOLS_GUIDE rides memory_recall's promptGuidelines and the goal\n// plugin's TASK_TOOLS_GUIDE rides goal_set's (宪法 §3 — prompt text lives with\n// the plugin that owns the tools). The kernel composes whatever the active\n// tools declare.\n\n// BuildSystemPromptOptions authority moved to @agent-forge/plugin-sdk\n// (D-075 S2); re-exported here so existing consumers keep resolving. The SDK\n// type projects skills structurally; hosts always pass their full Skill objects.\nexport type { BuildSystemPromptOptions, BuildSystemPromptSkill } from \"@agent-forge/plugin-sdk\";\n\n/** Build the system prompt with tools, guidelines, and context */\nexport function buildSystemPrompt(options: BuildSystemPromptOptions): string {\n\tconst {\n\t\tcustomPrompt,\n\t\torientationPrompt,\n\t\tpreferenceCard,\n\t\tselectedTools,\n\t\ttoolSnippets,\n\t\tpromptGuidelines,\n\t\tappendSystemPrompt,\n\t\tcwd,\n\t\tcontextFiles: providedContextFiles,\n\t\tskills: providedSkills,\n\t} = options;\n\tconst promptCwd = cwd.replace(/\\\\/g, \"/\");\n\n\tconst appendSection = appendSystemPrompt ? `\\n\\n${appendSystemPrompt}` : \"\";\n\tconst orientationSection = orientationPrompt ? `\\n\\n${orientationPrompt}` : \"\";\n\tconst preferenceCardSection = preferenceCard ? `\\n\\n${preferenceCard}` : \"\";\n\n\tconst contextFiles = providedContextFiles ?? [];\n\t// SDK options type projects skills structurally; narrow to the host Skill\n\t// for the formatter (D-075 S2 move).\n\tconst skills = (providedSkills as Skill[] | undefined) ?? [];\n\tconst tools = selectedTools || [\"read\", \"bash\", \"edit\", \"write\"];\n\tconst skillFileReadTool = ([\"read\", \"bash\"] as const).find((tool) => tools.includes(tool));\n\n\tif (customPrompt) {\n\t\tlet prompt = customPrompt;\n\n\t\t// The orientation is a session-nature declaration (设计 §6.2): it rides\n\t\t// the customPrompt branch too, ahead of the appended extras. The\n\t\t// preference card follows it (H2: same M2 injection pattern).\n\t\tif (orientationSection) {\n\t\t\tprompt += orientationSection;\n\t\t}\n\t\tif (preferenceCardSection) {\n\t\t\tprompt += preferenceCardSection;\n\t\t}\n\n\t\tif (appendSection) {\n\t\t\tprompt += appendSection;\n\t\t}\n\n\t\t// Append project context files\n\t\tif (contextFiles.length > 0) {\n\t\t\tprompt += \"\\n\\n<project_context>\\n\\n\";\n\t\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\n\t\t\tfor (const { path: filePath, content } of contextFiles) {\n\t\t\t\tprompt += `<project_instructions path=\"${filePath}\">\\n${content}\\n</project_instructions>\\n\\n`;\n\t\t\t}\n\t\t\tprompt += \"</project_context>\\n\";\n\t\t}\n\n\t\t// Append skills when a tool capable of reading their files is available.\n\t\tif (skillFileReadTool && skills.length > 0) {\n\t\t\tprompt += formatSkillsForPrompt(skills, skillFileReadTool);\n\t\t}\n\n\t\tprompt += `\\nCurrent working directory: ${promptCwd}\\n`;\n\n\t\treturn prompt;\n\t}\n\n\t// Get absolute paths to documentation and examples\n\tconst readmePath = getReadmePath();\n\tconst docsPath = getDocsPath();\n\tconst examplesPath = getExamplesPath();\n\n\t// Build tools list based on selected tools.\n\t// A tool appears in Available tools only when the caller provides a one-line snippet.\n\tconst visibleTools = tools.filter((name) => !!toolSnippets?.[name]);\n\tconst toolsList =\n\t\tvisibleTools.length > 0 ? visibleTools.map((name) => `- ${name}: ${toolSnippets![name]}`).join(\"\\n\") : \"(none)\";\n\n\t// Read-only tool surface (提示词设计宪法 §6 2026-10-02): when no known\n\t// mutating tool is active (--tools narrowing, readonly embeds), the intro\n\t// must not promise file editing and a work rule reframes execution requests\n\t// as change-plan requests. New mutating capability tools must be added here.\n\tconst MUTATING_TOOL_NAMES = new Set([\n\t\t\"write\",\n\t\t\"edit\",\n\t\t\"bash\",\n\t\t\"powershell\",\n\t\t\"process_exec\",\n\t\t\"workspace_write\",\n\t\t\"test_run\",\n\t\t\"formatter_linter_check\",\n\t\t\"desktop_execute\",\n\t\t\"image_edit\",\n\t]);\n\tconst readOnlySession = !tools.some((name) => MUTATING_TOOL_NAMES.has(name));\n\tconst introScope = readOnlySession\n\t\t? \"you complete the user's task in the current working directory by reading code and running non-mutating commands. This session has no tools that modify files or run state-changing commands, so you cannot make changes here\"\n\t\t: \"you complete the user's task in the current working directory by reading code, running commands, and editing or creating files\";\n\tconst readOnlyWorkRule = readOnlySession\n\t\t? \"\\n- Treat execution requests as requests for a change plan: this session cannot make changes, so when the task needs them, delivering the exact plan — which files, what edits, how to verify — completes the task; do not attempt workarounds for the missing tools.\"\n\t\t: \"\";\n\n\t// Build guidelines based on which tools are actually available\n\tconst guidelinesList: string[] = [];\n\tconst guidelinesSet = new Set<string>();\n\tconst addGuideline = (guideline: string): void => {\n\t\tif (guidelinesSet.has(guideline)) {\n\t\t\treturn;\n\t\t}\n\t\tguidelinesSet.add(guideline);\n\t\tguidelinesList.push(guideline);\n\t};\n\n\tconst hasBash = tools.includes(\"bash\");\n\tconst hasPowerShell = tools.includes(\"powershell\");\n\tconst hasGrep = tools.includes(\"grep\");\n\tconst hasFind = tools.includes(\"find\");\n\tconst hasLs = tools.includes(\"ls\");\n\n\t// File exploration guidelines\n\tif ((hasBash || hasPowerShell) && !hasGrep && !hasFind && !hasLs) {\n\t\tif (hasBash && hasPowerShell) {\n\t\t\taddGuideline(\"Use bash or PowerShell for file operations like listing, searching, and finding files\");\n\t\t} else if (hasPowerShell) {\n\t\t\taddGuideline(\"Use PowerShell for file operations like listing, searching, and finding files\");\n\t\t} else {\n\t\t\taddGuideline(\"Use bash for file operations like ls, rg, find\");\n\t\t}\n\t}\n\n\tfor (const guideline of promptGuidelines ?? []) {\n\t\tconst normalized = guideline.trim();\n\t\tif (normalized.length > 0) {\n\t\t\taddGuideline(normalized);\n\t\t}\n\t}\n\n\t// Always include this\n\taddGuideline(\"Show file paths clearly when working with files\");\n\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\n\n\tlet prompt = `You are Agent Forge, a coding agent: ${introScope}. Agent Forge is a minimal, extensible runtime: capabilities beyond the built-in tools come from installed plugins, skills, MCP servers, and CLI bridges — choose and compose them yourself when they serve the goal. The runtime defines only the readonly and full-control host modes; approval and safety policy belongs to the user's installed extensions, not to you.\n\nWork rules:\n- Work toward the stated outcome: start multi-step requests with a tool call, keep working through tools until the task is complete, and end with a summary of results — never with a plan or a promise of future work.\n- Make the smallest change that fully satisfies the task; add nothing unsolicited — no extra features, refactors, warnings, or disclaimers.\n- Report outcomes faithfully: failures with their output, skipped steps as skipped, finished and verified work as finished.\n- Lead replies with the outcome and keep only the evidence needed to assess it; drop filler.${readOnlyWorkRule}\n- The user's instructions and project context files take precedence over these defaults.${orientationSection}${preferenceCardSection}\n\nAvailable tools:\n${toolsList}\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.\n\nGuidelines:\n${guidelines}\n\nAgent Forge documentation (read only when the user asks about Agent Forge itself, its SDK, extensions, themes, skills, or TUI):\n- Main documentation: ${readmePath}\n- Additional docs: ${docsPath}\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\n- When reading Agent Forge docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), packages (docs/packages.md), environment variables (docs/environment-variables.md)\n- When working on Agent Forge topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read the relevant .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\n\n\tif (appendSection) {\n\t\tprompt += appendSection;\n\t}\n\n\t// Append project context files\n\tif (contextFiles.length > 0) {\n\t\tprompt += \"\\n\\n<project_context>\\n\\n\";\n\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\n\t\tfor (const { path: filePath, content } of contextFiles) {\n\t\t\tprompt += `<project_instructions path=\"${filePath}\">\\n${content}\\n</project_instructions>\\n\\n`;\n\t\t}\n\t\tprompt += \"</project_context>\\n\";\n\t}\n\n\t// Append skills when a tool capable of reading their files is available.\n\tif (skillFileReadTool && skills.length > 0) {\n\t\tprompt += formatSkillsForPrompt(skills, skillFileReadTool);\n\t}\n\n\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\treturn prompt;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAexE,YAAY,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEhG,kEAAkE;AAClE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,MAAM,CAuM3E","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport type { BuildSystemPromptOptions } from \"@agent-forge/plugin-sdk\";\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.ts\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.ts\";\n\n// Capability tool guides (memory / task management) moved to their owning\n// plugins in D-071 (the memory capability itself moved to the\n// @agent-forge/plugin-memory package in D-075 S4-4): the plugin's\n// MEMORY_TOOLS_GUIDE rides memory_recall's promptGuidelines and the goal\n// plugin's TASK_TOOLS_GUIDE rides goal_set's (宪法 §3 — prompt text lives with\n// the plugin that owns the tools). The kernel composes whatever the active\n// tools declare.\n\n// BuildSystemPromptOptions authority moved to @agent-forge/plugin-sdk\n// (D-075 S2); re-exported here so existing consumers keep resolving. The SDK\n// type projects skills structurally; hosts always pass their full Skill objects.\nexport type { BuildSystemPromptOptions, BuildSystemPromptSkill } from \"@agent-forge/plugin-sdk\";\n\n/** Build the system prompt with tools, guidelines, and context */\nexport function buildSystemPrompt(options: BuildSystemPromptOptions): string {\n\tconst {\n\t\tcustomPrompt,\n\t\torientationPrompt,\n\t\tpreferenceCard,\n\t\tselectedTools,\n\t\ttoolSnippets,\n\t\tpromptGuidelines,\n\t\tcapabilityCards,\n\t\tappendSystemPrompt,\n\t\tcwd,\n\t\tcontextFiles: providedContextFiles,\n\t\tskills: providedSkills,\n\t} = options;\n\tconst promptCwd = cwd.replace(/\\\\/g, \"/\");\n\n\tconst appendSection = appendSystemPrompt ? `\\n\\n${appendSystemPrompt}` : \"\";\n\tconst orientationSection = orientationPrompt ? `\\n\\n${orientationPrompt}` : \"\";\n\tconst preferenceCardSection = preferenceCard ? `\\n\\n${preferenceCard}` : \"\";\n\t// Mountable capability cards (插件按需挂载与能力手册设计 §4): one line per\n\t// deferred on-demand plugin. capability_mount loads the full tool set and\n\t// returns the plugin's manual; mounted capabilities drop off this section\n\t// on the next prompt rebuild.\n\tconst capabilityCardsSection =\n\t\tcapabilityCards === undefined || capabilityCards.length === 0\n\t\t\t? \"\"\n\t\t\t: `\\n\\nMountable capabilities (deferred plugins; call capability_mount with the plugin id to load the full tool set and its usage manual):\\n${capabilityCards\n\t\t\t\t\t.map((card) => `- ${card.pluginId}${card.description ? `: ${card.description}` : \"\"}`)\n\t\t\t\t\t.join(\"\\n\")}`;\n\n\tconst contextFiles = providedContextFiles ?? [];\n\t// SDK options type projects skills structurally; narrow to the host Skill\n\t// for the formatter (D-075 S2 move).\n\tconst skills = (providedSkills as Skill[] | undefined) ?? [];\n\tconst tools = selectedTools || [\"read\", \"bash\", \"edit\", \"write\"];\n\tconst skillFileReadTool = ([\"read\", \"bash\"] as const).find((tool) => tools.includes(tool));\n\n\tif (customPrompt) {\n\t\tlet prompt = customPrompt;\n\n\t\t// The orientation is a session-nature declaration (设计 §6.2): it rides\n\t\t// the customPrompt branch too, ahead of the appended extras. The\n\t\t// preference card follows it (H2: same M2 injection pattern).\n\t\tif (orientationSection) {\n\t\t\tprompt += orientationSection;\n\t\t}\n\t\tif (preferenceCardSection) {\n\t\t\tprompt += preferenceCardSection;\n\t\t}\n\n\t\tif (appendSection) {\n\t\t\tprompt += appendSection;\n\t\t}\n\t\tprompt += capabilityCardsSection;\n\n\t\t// Append project context files\n\t\tif (contextFiles.length > 0) {\n\t\t\tprompt += \"\\n\\n<project_context>\\n\\n\";\n\t\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\n\t\t\tfor (const { path: filePath, content } of contextFiles) {\n\t\t\t\tprompt += `<project_instructions path=\"${filePath}\">\\n${content}\\n</project_instructions>\\n\\n`;\n\t\t\t}\n\t\t\tprompt += \"</project_context>\\n\";\n\t\t}\n\n\t\t// Append skills when a tool capable of reading their files is available.\n\t\tif (skillFileReadTool && skills.length > 0) {\n\t\t\tprompt += formatSkillsForPrompt(skills, skillFileReadTool);\n\t\t}\n\n\t\tprompt += `\\nCurrent working directory: ${promptCwd}\\n`;\n\n\t\treturn prompt;\n\t}\n\n\t// Get absolute paths to documentation and examples\n\tconst readmePath = getReadmePath();\n\tconst docsPath = getDocsPath();\n\tconst examplesPath = getExamplesPath();\n\n\t// Build tools list based on selected tools.\n\t// A tool appears in Available tools only when the caller provides a one-line snippet.\n\tconst visibleTools = tools.filter((name) => !!toolSnippets?.[name]);\n\tconst toolsList =\n\t\tvisibleTools.length > 0 ? visibleTools.map((name) => `- ${name}: ${toolSnippets![name]}`).join(\"\\n\") : \"(none)\";\n\n\t// Read-only tool surface (提示词设计宪法 §6 2026-10-02): when no known\n\t// mutating tool is active (--tools narrowing, readonly embeds), the intro\n\t// must not promise file editing and a work rule reframes execution requests\n\t// as change-plan requests. New mutating capability tools must be added here.\n\tconst MUTATING_TOOL_NAMES = new Set([\n\t\t\"write\",\n\t\t\"edit\",\n\t\t\"bash\",\n\t\t\"powershell\",\n\t\t\"process_exec\",\n\t\t\"workspace_write\",\n\t\t\"test_run\",\n\t\t\"formatter_linter_check\",\n\t\t\"desktop_execute\",\n\t\t\"image_edit\",\n\t]);\n\tconst readOnlySession = !tools.some((name) => MUTATING_TOOL_NAMES.has(name));\n\tconst introScope = readOnlySession\n\t\t? \"you complete the user's task in the current working directory by reading code and running non-mutating commands. This session has no tools that modify files or run state-changing commands, so you cannot make changes here\"\n\t\t: \"you complete the user's task in the current working directory by reading code, running commands, and editing or creating files\";\n\tconst readOnlyWorkRule = readOnlySession\n\t\t? \"\\n- Treat execution requests as requests for a change plan: this session cannot make changes, so when the task needs them, delivering the exact plan — which files, what edits, how to verify — completes the task; do not attempt workarounds for the missing tools.\"\n\t\t: \"\";\n\n\t// Build guidelines based on which tools are actually available\n\tconst guidelinesList: string[] = [];\n\tconst guidelinesSet = new Set<string>();\n\tconst addGuideline = (guideline: string): void => {\n\t\tif (guidelinesSet.has(guideline)) {\n\t\t\treturn;\n\t\t}\n\t\tguidelinesSet.add(guideline);\n\t\tguidelinesList.push(guideline);\n\t};\n\n\tconst hasBash = tools.includes(\"bash\");\n\tconst hasPowerShell = tools.includes(\"powershell\");\n\tconst hasGrep = tools.includes(\"grep\");\n\tconst hasFind = tools.includes(\"find\");\n\tconst hasLs = tools.includes(\"ls\");\n\n\t// File exploration guidelines\n\tif ((hasBash || hasPowerShell) && !hasGrep && !hasFind && !hasLs) {\n\t\tif (hasBash && hasPowerShell) {\n\t\t\taddGuideline(\"Use bash or PowerShell for file operations like listing, searching, and finding files\");\n\t\t} else if (hasPowerShell) {\n\t\t\taddGuideline(\"Use PowerShell for file operations like listing, searching, and finding files\");\n\t\t} else {\n\t\t\taddGuideline(\"Use bash for file operations like ls, rg, find\");\n\t\t}\n\t}\n\n\tfor (const guideline of promptGuidelines ?? []) {\n\t\tconst normalized = guideline.trim();\n\t\tif (normalized.length > 0) {\n\t\t\taddGuideline(normalized);\n\t\t}\n\t}\n\n\t// Always include this\n\taddGuideline(\"Show file paths clearly when working with files\");\n\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\n\n\tlet prompt = `You are Agent Forge, a coding agent: ${introScope}. Agent Forge is a minimal, extensible runtime: capabilities beyond the built-in tools come from installed plugins, skills, MCP servers, and CLI bridges — choose and compose them yourself when they serve the goal. The runtime defines only the readonly and full-control host modes; approval and safety policy belongs to the user's installed extensions, not to you.\n\nWork rules:\n- Work toward the stated outcome: start multi-step requests with a tool call, keep working through tools until the task is complete, and end with a summary of results — never with a plan or a promise of future work.\n- Make the smallest change that fully satisfies the task; add nothing unsolicited — no extra features, refactors, warnings, or disclaimers.\n- Report outcomes faithfully: failures with their output, skipped steps as skipped, finished and verified work as finished.\n- Lead replies with the outcome and keep only the evidence needed to assess it; drop filler.${readOnlyWorkRule}\n- The user's instructions and project context files take precedence over these defaults.${orientationSection}${preferenceCardSection}\n\nAvailable tools:\n${toolsList}\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.\n\nGuidelines:\n${guidelines}\n\nAgent Forge documentation (read only when the user asks about Agent Forge itself, its SDK, extensions, themes, skills, or TUI):\n- Main documentation: ${readmePath}\n- Additional docs: ${docsPath}\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\n- When reading Agent Forge docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), packages (docs/packages.md), environment variables (docs/environment-variables.md)\n- When working on Agent Forge topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read the relevant .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\n\n\tif (appendSection) {\n\t\tprompt += appendSection;\n\t}\n\tprompt += capabilityCardsSection;\n\n\t// Append project context files\n\tif (contextFiles.length > 0) {\n\t\tprompt += \"\\n\\n<project_context>\\n\\n\";\n\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\n\t\tfor (const { path: filePath, content } of contextFiles) {\n\t\t\tprompt += `<project_instructions path=\"${filePath}\">\\n${content}\\n</project_instructions>\\n\\n`;\n\t\t}\n\t\tprompt += \"</project_context>\\n\";\n\t}\n\n\t// Append skills when a tool capable of reading their files is available.\n\tif (skillFileReadTool && skills.length > 0) {\n\t\tprompt += formatSkillsForPrompt(skills, skillFileReadTool);\n\t}\n\n\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\treturn prompt;\n}\n"]}
|
|
@@ -5,11 +5,20 @@ import { getDocsPath, getExamplesPath, getReadmePath } from "../config.js";
|
|
|
5
5
|
import { formatSkillsForPrompt } from "./skills.js";
|
|
6
6
|
/** Build the system prompt with tools, guidelines, and context */
|
|
7
7
|
export function buildSystemPrompt(options) {
|
|
8
|
-
const { customPrompt, orientationPrompt, preferenceCard, selectedTools, toolSnippets, promptGuidelines, appendSystemPrompt, cwd, contextFiles: providedContextFiles, skills: providedSkills, } = options;
|
|
8
|
+
const { customPrompt, orientationPrompt, preferenceCard, selectedTools, toolSnippets, promptGuidelines, capabilityCards, appendSystemPrompt, cwd, contextFiles: providedContextFiles, skills: providedSkills, } = options;
|
|
9
9
|
const promptCwd = cwd.replace(/\\/g, "/");
|
|
10
10
|
const appendSection = appendSystemPrompt ? `\n\n${appendSystemPrompt}` : "";
|
|
11
11
|
const orientationSection = orientationPrompt ? `\n\n${orientationPrompt}` : "";
|
|
12
12
|
const preferenceCardSection = preferenceCard ? `\n\n${preferenceCard}` : "";
|
|
13
|
+
// Mountable capability cards (插件按需挂载与能力手册设计 §4): one line per
|
|
14
|
+
// deferred on-demand plugin. capability_mount loads the full tool set and
|
|
15
|
+
// returns the plugin's manual; mounted capabilities drop off this section
|
|
16
|
+
// on the next prompt rebuild.
|
|
17
|
+
const capabilityCardsSection = capabilityCards === undefined || capabilityCards.length === 0
|
|
18
|
+
? ""
|
|
19
|
+
: `\n\nMountable capabilities (deferred plugins; call capability_mount with the plugin id to load the full tool set and its usage manual):\n${capabilityCards
|
|
20
|
+
.map((card) => `- ${card.pluginId}${card.description ? `: ${card.description}` : ""}`)
|
|
21
|
+
.join("\n")}`;
|
|
13
22
|
const contextFiles = providedContextFiles ?? [];
|
|
14
23
|
// SDK options type projects skills structurally; narrow to the host Skill
|
|
15
24
|
// for the formatter (D-075 S2 move).
|
|
@@ -30,6 +39,7 @@ export function buildSystemPrompt(options) {
|
|
|
30
39
|
if (appendSection) {
|
|
31
40
|
prompt += appendSection;
|
|
32
41
|
}
|
|
42
|
+
prompt += capabilityCardsSection;
|
|
33
43
|
// Append project context files
|
|
34
44
|
if (contextFiles.length > 0) {
|
|
35
45
|
prompt += "\n\n<project_context>\n\n";
|
|
@@ -141,6 +151,7 @@ Agent Forge documentation (read only when the user asks about Agent Forge itself
|
|
|
141
151
|
if (appendSection) {
|
|
142
152
|
prompt += appendSection;
|
|
143
153
|
}
|
|
154
|
+
prompt += capabilityCardsSection;
|
|
144
155
|
// Append project context files
|
|
145
156
|
if (contextFiles.length > 0) {
|
|
146
157
|
prompt += "\n\n<project_context>\n\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAc,MAAM,aAAa,CAAC;AAehE,kEAAkE;AAClE,MAAM,UAAU,iBAAiB,CAAC,OAAiC,EAAU;IAC5E,MAAM,EACL,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,GAAG,E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AAC;IAClC,CAAC;IAED,yEAAyE;IACzE,IAAI,iBAAiB,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,qBAAqB,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,IAAI,gCAAgC,SAAS,EAAE,CAAC;IAEtD,OAAO,MAAM,CAAC;AAAA,CACd","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport type { BuildSystemPromptOptions } from \"@agent-forge/plugin-sdk\";\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.ts\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.ts\";\n\n// Capability tool guides (memory / task management) moved to their owning\n// plugins in D-071 (the memory capability itself moved to the\n// @agent-forge/plugin-memory package in D-075 S4-4): the plugin's\n// MEMORY_TOOLS_GUIDE rides memory_recall's promptGuidelines and the goal\n// plugin's TASK_TOOLS_GUIDE rides goal_set's (宪法 §3 — prompt text lives with\n// the plugin that owns the tools). The kernel composes whatever the active\n// tools declare.\n\n// BuildSystemPromptOptions authority moved to @agent-forge/plugin-sdk\n// (D-075 S2); re-exported here so existing consumers keep resolving. The SDK\n// type projects skills structurally; hosts always pass their full Skill objects.\nexport type { BuildSystemPromptOptions, BuildSystemPromptSkill } from \"@agent-forge/plugin-sdk\";\n\n/** Build the system prompt with tools, guidelines, and context */\nexport function buildSystemPrompt(options: BuildSystemPromptOptions): string {\n\tconst {\n\t\tcustomPrompt,\n\t\torientationPrompt,\n\t\tpreferenceCard,\n\t\tselectedTools,\n\t\ttoolSnippets,\n\t\tpromptGuidelines,\n\t\tappendSystemPrompt,\n\t\tcwd,\n\t\tcontextFiles: providedContextFiles,\n\t\tskills: providedSkills,\n\t} = options;\n\tconst promptCwd = cwd.replace(/\\\\/g, \"/\");\n\n\tconst appendSection = appendSystemPrompt ? `\\n\\n${appendSystemPrompt}` : \"\";\n\tconst orientationSection = orientationPrompt ? `\\n\\n${orientationPrompt}` : \"\";\n\tconst preferenceCardSection = preferenceCard ? `\\n\\n${preferenceCard}` : \"\";\n\n\tconst contextFiles = providedContextFiles ?? [];\n\t// SDK options type projects skills structurally; narrow to the host Skill\n\t// for the formatter (D-075 S2 move).\n\tconst skills = (providedSkills as Skill[] | undefined) ?? [];\n\tconst tools = selectedTools || [\"read\", \"bash\", \"edit\", \"write\"];\n\tconst skillFileReadTool = ([\"read\", \"bash\"] as const).find((tool) => tools.includes(tool));\n\n\tif (customPrompt) {\n\t\tlet prompt = customPrompt;\n\n\t\t// The orientation is a session-nature declaration (设计 §6.2): it rides\n\t\t// the customPrompt branch too, ahead of the appended extras. The\n\t\t// preference card follows it (H2: same M2 injection pattern).\n\t\tif (orientationSection) {\n\t\t\tprompt += orientationSection;\n\t\t}\n\t\tif (preferenceCardSection) {\n\t\t\tprompt += preferenceCardSection;\n\t\t}\n\n\t\tif (appendSection) {\n\t\t\tprompt += appendSection;\n\t\t}\n\n\t\t// Append project context files\n\t\tif (contextFiles.length > 0) {\n\t\t\tprompt += \"\\n\\n<project_context>\\n\\n\";\n\t\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\n\t\t\tfor (const { path: filePath, content } of contextFiles) {\n\t\t\t\tprompt += `<project_instructions path=\"${filePath}\">\\n${content}\\n</project_instructions>\\n\\n`;\n\t\t\t}\n\t\t\tprompt += \"</project_context>\\n\";\n\t\t}\n\n\t\t// Append skills when a tool capable of reading their files is available.\n\t\tif (skillFileReadTool && skills.length > 0) {\n\t\t\tprompt += formatSkillsForPrompt(skills, skillFileReadTool);\n\t\t}\n\n\t\tprompt += `\\nCurrent working directory: ${promptCwd}\\n`;\n\n\t\treturn prompt;\n\t}\n\n\t// Get absolute paths to documentation and examples\n\tconst readmePath = getReadmePath();\n\tconst docsPath = getDocsPath();\n\tconst examplesPath = getExamplesPath();\n\n\t// Build tools list based on selected tools.\n\t// A tool appears in Available tools only when the caller provides a one-line snippet.\n\tconst visibleTools = tools.filter((name) => !!toolSnippets?.[name]);\n\tconst toolsList =\n\t\tvisibleTools.length > 0 ? visibleTools.map((name) => `- ${name}: ${toolSnippets![name]}`).join(\"\\n\") : \"(none)\";\n\n\t// Read-only tool surface (提示词设计宪法 §6 2026-10-02): when no known\n\t// mutating tool is active (--tools narrowing, readonly embeds), the intro\n\t// must not promise file editing and a work rule reframes execution requests\n\t// as change-plan requests. New mutating capability tools must be added here.\n\tconst MUTATING_TOOL_NAMES = new Set([\n\t\t\"write\",\n\t\t\"edit\",\n\t\t\"bash\",\n\t\t\"powershell\",\n\t\t\"process_exec\",\n\t\t\"workspace_write\",\n\t\t\"test_run\",\n\t\t\"formatter_linter_check\",\n\t\t\"desktop_execute\",\n\t\t\"image_edit\",\n\t]);\n\tconst readOnlySession = !tools.some((name) => MUTATING_TOOL_NAMES.has(name));\n\tconst introScope = readOnlySession\n\t\t? \"you complete the user's task in the current working directory by reading code and running non-mutating commands. This session has no tools that modify files or run state-changing commands, so you cannot make changes here\"\n\t\t: \"you complete the user's task in the current working directory by reading code, running commands, and editing or creating files\";\n\tconst readOnlyWorkRule = readOnlySession\n\t\t? \"\\n- Treat execution requests as requests for a change plan: this session cannot make changes, so when the task needs them, delivering the exact plan — which files, what edits, how to verify — completes the task; do not attempt workarounds for the missing tools.\"\n\t\t: \"\";\n\n\t// Build guidelines based on which tools are actually available\n\tconst guidelinesList: string[] = [];\n\tconst guidelinesSet = new Set<string>();\n\tconst addGuideline = (guideline: string): void => {\n\t\tif (guidelinesSet.has(guideline)) {\n\t\t\treturn;\n\t\t}\n\t\tguidelinesSet.add(guideline);\n\t\tguidelinesList.push(guideline);\n\t};\n\n\tconst hasBash = tools.includes(\"bash\");\n\tconst hasPowerShell = tools.includes(\"powershell\");\n\tconst hasGrep = tools.includes(\"grep\");\n\tconst hasFind = tools.includes(\"find\");\n\tconst hasLs = tools.includes(\"ls\");\n\n\t// File exploration guidelines\n\tif ((hasBash || hasPowerShell) && !hasGrep && !hasFind && !hasLs) {\n\t\tif (hasBash && hasPowerShell) {\n\t\t\taddGuideline(\"Use bash or PowerShell for file operations like listing, searching, and finding files\");\n\t\t} else if (hasPowerShell) {\n\t\t\taddGuideline(\"Use PowerShell for file operations like listing, searching, and finding files\");\n\t\t} else {\n\t\t\taddGuideline(\"Use bash for file operations like ls, rg, find\");\n\t\t}\n\t}\n\n\tfor (const guideline of promptGuidelines ?? []) {\n\t\tconst normalized = guideline.trim();\n\t\tif (normalized.length > 0) {\n\t\t\taddGuideline(normalized);\n\t\t}\n\t}\n\n\t// Always include this\n\taddGuideline(\"Show file paths clearly when working with files\");\n\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\n\n\tlet prompt = `You are Agent Forge, a coding agent: ${introScope}. Agent Forge is a minimal, extensible runtime: capabilities beyond the built-in tools come from installed plugins, skills, MCP servers, and CLI bridges — choose and compose them yourself when they serve the goal. The runtime defines only the readonly and full-control host modes; approval and safety policy belongs to the user's installed extensions, not to you.\n\nWork rules:\n- Work toward the stated outcome: start multi-step requests with a tool call, keep working through tools until the task is complete, and end with a summary of results — never with a plan or a promise of future work.\n- Make the smallest change that fully satisfies the task; add nothing unsolicited — no extra features, refactors, warnings, or disclaimers.\n- Report outcomes faithfully: failures with their output, skipped steps as skipped, finished and verified work as finished.\n- Lead replies with the outcome and keep only the evidence needed to assess it; drop filler.${readOnlyWorkRule}\n- The user's instructions and project context files take precedence over these defaults.${orientationSection}${preferenceCardSection}\n\nAvailable tools:\n${toolsList}\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.\n\nGuidelines:\n${guidelines}\n\nAgent Forge documentation (read only when the user asks about Agent Forge itself, its SDK, extensions, themes, skills, or TUI):\n- Main documentation: ${readmePath}\n- Additional docs: ${docsPath}\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\n- When reading Agent Forge docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), packages (docs/packages.md), environment variables (docs/environment-variables.md)\n- When working on Agent Forge topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read the relevant .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\n\n\tif (appendSection) {\n\t\tprompt += appendSection;\n\t}\n\n\t// Append project context files\n\tif (contextFiles.length > 0) {\n\t\tprompt += \"\\n\\n<project_context>\\n\\n\";\n\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\n\t\tfor (const { path: filePath, content } of contextFiles) {\n\t\t\tprompt += `<project_instructions path=\"${filePath}\">\\n${content}\\n</project_instructions>\\n\\n`;\n\t\t}\n\t\tprompt += \"</project_context>\\n\";\n\t}\n\n\t// Append skills when a tool capable of reading their files is available.\n\tif (skillFileReadTool && skills.length > 0) {\n\t\tprompt += formatSkillsForPrompt(skills, skillFileReadTool);\n\t}\n\n\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\treturn prompt;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAc,MAAM,aAAa,CAAC;AAehE,kEAAkE;AAClE,MAAM,UAAU,iBAAiB,CAAC,OAAiC,EAAU;IAC5E,MAAM,EACL,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,GAAG,EACH,YAAY,EAAE,oBAAoB,EAClC,MAAM,EAAE,cAAc,GACtB,GAAG,OAAO,CAAC;IACZ,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,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,MAAM,IAAI,sBAAsB,CAAC;IAEjC,+BAA+B;IAC/B,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,2BAA2B,CAAC;QACtC,MAAM,IAAI,mDAAmD,CAAC;QAC9D,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,YAAY,EAAE,CAAC;YACxD,MAAM,IAAI,+BAA+B,QAAQ,OAAO,OAAO,+BAA+B,CAAC;QAChG,CAAC;QACD,MAAM,IAAI,sBAAsB,CAAC;IAClC,CAAC;IAED,yEAAyE;IACzE,IAAI,iBAAiB,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,qBAAqB,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,IAAI,gCAAgC,SAAS,EAAE,CAAC;IAEtD,OAAO,MAAM,CAAC;AAAA,CACd","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport type { BuildSystemPromptOptions } from \"@agent-forge/plugin-sdk\";\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.ts\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.ts\";\n\n// Capability tool guides (memory / task management) moved to their owning\n// plugins in D-071 (the memory capability itself moved to the\n// @agent-forge/plugin-memory package in D-075 S4-4): the plugin's\n// MEMORY_TOOLS_GUIDE rides memory_recall's promptGuidelines and the goal\n// plugin's TASK_TOOLS_GUIDE rides goal_set's (宪法 §3 — prompt text lives with\n// the plugin that owns the tools). The kernel composes whatever the active\n// tools declare.\n\n// BuildSystemPromptOptions authority moved to @agent-forge/plugin-sdk\n// (D-075 S2); re-exported here so existing consumers keep resolving. The SDK\n// type projects skills structurally; hosts always pass their full Skill objects.\nexport type { BuildSystemPromptOptions, BuildSystemPromptSkill } from \"@agent-forge/plugin-sdk\";\n\n/** Build the system prompt with tools, guidelines, and context */\nexport function buildSystemPrompt(options: BuildSystemPromptOptions): string {\n\tconst {\n\t\tcustomPrompt,\n\t\torientationPrompt,\n\t\tpreferenceCard,\n\t\tselectedTools,\n\t\ttoolSnippets,\n\t\tpromptGuidelines,\n\t\tcapabilityCards,\n\t\tappendSystemPrompt,\n\t\tcwd,\n\t\tcontextFiles: providedContextFiles,\n\t\tskills: providedSkills,\n\t} = options;\n\tconst promptCwd = cwd.replace(/\\\\/g, \"/\");\n\n\tconst appendSection = appendSystemPrompt ? `\\n\\n${appendSystemPrompt}` : \"\";\n\tconst orientationSection = orientationPrompt ? `\\n\\n${orientationPrompt}` : \"\";\n\tconst preferenceCardSection = preferenceCard ? `\\n\\n${preferenceCard}` : \"\";\n\t// Mountable capability cards (插件按需挂载与能力手册设计 §4): one line per\n\t// deferred on-demand plugin. capability_mount loads the full tool set and\n\t// returns the plugin's manual; mounted capabilities drop off this section\n\t// on the next prompt rebuild.\n\tconst capabilityCardsSection =\n\t\tcapabilityCards === undefined || capabilityCards.length === 0\n\t\t\t? \"\"\n\t\t\t: `\\n\\nMountable capabilities (deferred plugins; call capability_mount with the plugin id to load the full tool set and its usage manual):\\n${capabilityCards\n\t\t\t\t\t.map((card) => `- ${card.pluginId}${card.description ? `: ${card.description}` : \"\"}`)\n\t\t\t\t\t.join(\"\\n\")}`;\n\n\tconst contextFiles = providedContextFiles ?? [];\n\t// SDK options type projects skills structurally; narrow to the host Skill\n\t// for the formatter (D-075 S2 move).\n\tconst skills = (providedSkills as Skill[] | undefined) ?? [];\n\tconst tools = selectedTools || [\"read\", \"bash\", \"edit\", \"write\"];\n\tconst skillFileReadTool = ([\"read\", \"bash\"] as const).find((tool) => tools.includes(tool));\n\n\tif (customPrompt) {\n\t\tlet prompt = customPrompt;\n\n\t\t// The orientation is a session-nature declaration (设计 §6.2): it rides\n\t\t// the customPrompt branch too, ahead of the appended extras. The\n\t\t// preference card follows it (H2: same M2 injection pattern).\n\t\tif (orientationSection) {\n\t\t\tprompt += orientationSection;\n\t\t}\n\t\tif (preferenceCardSection) {\n\t\t\tprompt += preferenceCardSection;\n\t\t}\n\n\t\tif (appendSection) {\n\t\t\tprompt += appendSection;\n\t\t}\n\t\tprompt += capabilityCardsSection;\n\n\t\t// Append project context files\n\t\tif (contextFiles.length > 0) {\n\t\t\tprompt += \"\\n\\n<project_context>\\n\\n\";\n\t\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\n\t\t\tfor (const { path: filePath, content } of contextFiles) {\n\t\t\t\tprompt += `<project_instructions path=\"${filePath}\">\\n${content}\\n</project_instructions>\\n\\n`;\n\t\t\t}\n\t\t\tprompt += \"</project_context>\\n\";\n\t\t}\n\n\t\t// Append skills when a tool capable of reading their files is available.\n\t\tif (skillFileReadTool && skills.length > 0) {\n\t\t\tprompt += formatSkillsForPrompt(skills, skillFileReadTool);\n\t\t}\n\n\t\tprompt += `\\nCurrent working directory: ${promptCwd}\\n`;\n\n\t\treturn prompt;\n\t}\n\n\t// Get absolute paths to documentation and examples\n\tconst readmePath = getReadmePath();\n\tconst docsPath = getDocsPath();\n\tconst examplesPath = getExamplesPath();\n\n\t// Build tools list based on selected tools.\n\t// A tool appears in Available tools only when the caller provides a one-line snippet.\n\tconst visibleTools = tools.filter((name) => !!toolSnippets?.[name]);\n\tconst toolsList =\n\t\tvisibleTools.length > 0 ? visibleTools.map((name) => `- ${name}: ${toolSnippets![name]}`).join(\"\\n\") : \"(none)\";\n\n\t// Read-only tool surface (提示词设计宪法 §6 2026-10-02): when no known\n\t// mutating tool is active (--tools narrowing, readonly embeds), the intro\n\t// must not promise file editing and a work rule reframes execution requests\n\t// as change-plan requests. New mutating capability tools must be added here.\n\tconst MUTATING_TOOL_NAMES = new Set([\n\t\t\"write\",\n\t\t\"edit\",\n\t\t\"bash\",\n\t\t\"powershell\",\n\t\t\"process_exec\",\n\t\t\"workspace_write\",\n\t\t\"test_run\",\n\t\t\"formatter_linter_check\",\n\t\t\"desktop_execute\",\n\t\t\"image_edit\",\n\t]);\n\tconst readOnlySession = !tools.some((name) => MUTATING_TOOL_NAMES.has(name));\n\tconst introScope = readOnlySession\n\t\t? \"you complete the user's task in the current working directory by reading code and running non-mutating commands. This session has no tools that modify files or run state-changing commands, so you cannot make changes here\"\n\t\t: \"you complete the user's task in the current working directory by reading code, running commands, and editing or creating files\";\n\tconst readOnlyWorkRule = readOnlySession\n\t\t? \"\\n- Treat execution requests as requests for a change plan: this session cannot make changes, so when the task needs them, delivering the exact plan — which files, what edits, how to verify — completes the task; do not attempt workarounds for the missing tools.\"\n\t\t: \"\";\n\n\t// Build guidelines based on which tools are actually available\n\tconst guidelinesList: string[] = [];\n\tconst guidelinesSet = new Set<string>();\n\tconst addGuideline = (guideline: string): void => {\n\t\tif (guidelinesSet.has(guideline)) {\n\t\t\treturn;\n\t\t}\n\t\tguidelinesSet.add(guideline);\n\t\tguidelinesList.push(guideline);\n\t};\n\n\tconst hasBash = tools.includes(\"bash\");\n\tconst hasPowerShell = tools.includes(\"powershell\");\n\tconst hasGrep = tools.includes(\"grep\");\n\tconst hasFind = tools.includes(\"find\");\n\tconst hasLs = tools.includes(\"ls\");\n\n\t// File exploration guidelines\n\tif ((hasBash || hasPowerShell) && !hasGrep && !hasFind && !hasLs) {\n\t\tif (hasBash && hasPowerShell) {\n\t\t\taddGuideline(\"Use bash or PowerShell for file operations like listing, searching, and finding files\");\n\t\t} else if (hasPowerShell) {\n\t\t\taddGuideline(\"Use PowerShell for file operations like listing, searching, and finding files\");\n\t\t} else {\n\t\t\taddGuideline(\"Use bash for file operations like ls, rg, find\");\n\t\t}\n\t}\n\n\tfor (const guideline of promptGuidelines ?? []) {\n\t\tconst normalized = guideline.trim();\n\t\tif (normalized.length > 0) {\n\t\t\taddGuideline(normalized);\n\t\t}\n\t}\n\n\t// Always include this\n\taddGuideline(\"Show file paths clearly when working with files\");\n\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\n\n\tlet prompt = `You are Agent Forge, a coding agent: ${introScope}. Agent Forge is a minimal, extensible runtime: capabilities beyond the built-in tools come from installed plugins, skills, MCP servers, and CLI bridges — choose and compose them yourself when they serve the goal. The runtime defines only the readonly and full-control host modes; approval and safety policy belongs to the user's installed extensions, not to you.\n\nWork rules:\n- Work toward the stated outcome: start multi-step requests with a tool call, keep working through tools until the task is complete, and end with a summary of results — never with a plan or a promise of future work.\n- Make the smallest change that fully satisfies the task; add nothing unsolicited — no extra features, refactors, warnings, or disclaimers.\n- Report outcomes faithfully: failures with their output, skipped steps as skipped, finished and verified work as finished.\n- Lead replies with the outcome and keep only the evidence needed to assess it; drop filler.${readOnlyWorkRule}\n- The user's instructions and project context files take precedence over these defaults.${orientationSection}${preferenceCardSection}\n\nAvailable tools:\n${toolsList}\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.\n\nGuidelines:\n${guidelines}\n\nAgent Forge documentation (read only when the user asks about Agent Forge itself, its SDK, extensions, themes, skills, or TUI):\n- Main documentation: ${readmePath}\n- Additional docs: ${docsPath}\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\n- When reading Agent Forge docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), packages (docs/packages.md), environment variables (docs/environment-variables.md)\n- When working on Agent Forge topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read the relevant .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\n\n\tif (appendSection) {\n\t\tprompt += appendSection;\n\t}\n\tprompt += capabilityCardsSection;\n\n\t// Append project context files\n\tif (contextFiles.length > 0) {\n\t\tprompt += \"\\n\\n<project_context>\\n\\n\";\n\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\n\t\tfor (const { path: filePath, content } of contextFiles) {\n\t\t\tprompt += `<project_instructions path=\"${filePath}\">\\n${content}\\n</project_instructions>\\n\\n`;\n\t\t}\n\t\tprompt += \"</project_context>\\n\";\n\t}\n\n\t// Append skills when a tool capable of reading their files is available.\n\tif (skillFileReadTool && skills.length > 0) {\n\t\tprompt += formatSkillsForPrompt(skills, skillFileReadTool);\n\t}\n\n\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\treturn prompt;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timings.d.ts","sourceRoot":"","sources":["../../src/core/timings.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wBAAgB,iBAAiB,IAAI,OAAO,
|
|
1
|
+
{"version":3,"file":"timings.d.ts","sourceRoot":"","sources":["../../src/core/timings.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAQD,KAAK,WAAW,GAAG,MAAM,GAAG,YAAY,CAAC;AAIzC,wBAAgB,YAAY,CAAC,SAAS,GAAE,WAAoB,GAAG,IAAI,CAGlE;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,GAAE,WAAoB,GAAG,IAAI,CAWzE;AAaD,wBAAgB,YAAY,IAAI,IAAI,CAKnC","sourcesContent":["/**\n * Central timing instrumentation for startup profiling.\n * Enable with AGENT_FORGE_TIMING=1 environment variable.\n */\n\nexport function areTimingsEnabled(): boolean {\n\treturn process.env.AGENT_FORGE_TIMING === \"1\";\n}\n\nconst ENABLED = areTimingsEnabled();\ninterface TimingNamespace {\n\ttimings: Array<{ label: string; ms: number }>;\n\tlastTime: number;\n}\n\ntype TimingLabel = \"main\" | \"extensions\";\n\nconst timingNamespaces = new Map<TimingLabel, TimingNamespace>();\n\nexport function resetTimings(namespace: TimingLabel = \"main\"): void {\n\tif (!ENABLED) return;\n\ttimingNamespaces.set(namespace, { timings: [], lastTime: Date.now() });\n}\n\nexport function time(label: string, namespace: TimingLabel = \"main\"): void {\n\tif (!ENABLED) return;\n\tconst now = Date.now();\n\n\tif (!timingNamespaces.has(namespace)) {\n\t\tresetTimings(namespace);\n\t}\n\n\tconst timingNamespace = timingNamespaces.get(namespace)!;\n\ttimingNamespace.timings.push({ label, ms: now - timingNamespace.lastTime });\n\ttimingNamespace.lastTime = now;\n}\n\nfunction printTimingGroup(title: string, timings: TimingNamespace[\"timings\"]): void {\n\tconst printableTimings = timings.filter((timing) => timing.ms >= 0);\n\tif (printableTimings.length === 0) return;\n\tconsole.error(`\\n--- ${title} ---`);\n\tfor (const t of printableTimings) {\n\t\tconsole.error(` ${t.label}: ${t.ms}ms`);\n\t}\n\tconsole.error(` TOTAL: ${printableTimings.reduce((a, b) => a + b.ms, 0)}ms`);\n\tconsole.error(`${\"-\".repeat(title.length + 8)}\\n`);\n}\n\nexport function printTimings(): void {\n\tif (!ENABLED) return;\n\tfor (const [namespace, timingNamespace] of timingNamespaces) {\n\t\tprintTimingGroup(`Startup Timings: ${namespace}`, timingNamespace.timings);\n\t}\n}\n"]}
|
package/dist/core/timings.js
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
* Enable with AGENT_FORGE_TIMING=1 environment variable.
|
|
4
4
|
*/
|
|
5
5
|
export function areTimingsEnabled() {
|
|
6
|
-
|
|
7
|
-
// Legacy fallback for installations configured before the Agent Forge rename.
|
|
8
|
-
return configuredValue === undefined ? process.env.PI_TIMING === "1" : configuredValue === "1";
|
|
6
|
+
return process.env.AGENT_FORGE_TIMING === "1";
|
|
9
7
|
}
|
|
10
8
|
const ENABLED = areTimingsEnabled();
|
|
11
9
|
const timingNamespaces = new Map();
|
package/dist/core/timings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timings.js","sourceRoot":"","sources":["../../src/core/timings.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,UAAU,iBAAiB,GAAY;IAC5C,
|
|
1
|
+
{"version":3,"file":"timings.js","sourceRoot":"","sources":["../../src/core/timings.ts"],"names":[],"mappings":"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AK,CAAC,SAAS,KAAK,MAAM,CAAC,CAAC;IACpC,KAAK,MAAM,CAAC,IAAI,gBAAgB,EAAE,CAAC;QAClC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,YAAY,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IAC9E,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;AAAA,CACnD;AAED,MAAM,UAAU,YAAY,GAAS;IACpC,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,KAAK,MAAM,CAAC,SAAS,EAAE,eAAe,CAAC,IAAI,gBAAgB,EAAE,CAAC;QAC7D,gBAAgB,CAAC,oBAAoB,SAAS,EAAE,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;IAC5E,CAAC;AAAA,CACD","sourcesContent":["/**\n * Central timing instrumentation for startup profiling.\n * Enable with AGENT_FORGE_TIMING=1 environment variable.\n */\n\nexport function areTimingsEnabled(): boolean {\n\treturn process.env.AGENT_FORGE_TIMING === \"1\";\n}\n\nconst ENABLED = areTimingsEnabled();\ninterface TimingNamespace {\n\ttimings: Array<{ label: string; ms: number }>;\n\tlastTime: number;\n}\n\ntype TimingLabel = \"main\" | \"extensions\";\n\nconst timingNamespaces = new Map<TimingLabel, TimingNamespace>();\n\nexport function resetTimings(namespace: TimingLabel = \"main\"): void {\n\tif (!ENABLED) return;\n\ttimingNamespaces.set(namespace, { timings: [], lastTime: Date.now() });\n}\n\nexport function time(label: string, namespace: TimingLabel = \"main\"): void {\n\tif (!ENABLED) return;\n\tconst now = Date.now();\n\n\tif (!timingNamespaces.has(namespace)) {\n\t\tresetTimings(namespace);\n\t}\n\n\tconst timingNamespace = timingNamespaces.get(namespace)!;\n\ttimingNamespace.timings.push({ label, ms: now - timingNamespace.lastTime });\n\ttimingNamespace.lastTime = now;\n}\n\nfunction printTimingGroup(title: string, timings: TimingNamespace[\"timings\"]): void {\n\tconst printableTimings = timings.filter((timing) => timing.ms >= 0);\n\tif (printableTimings.length === 0) return;\n\tconsole.error(`\\n--- ${title} ---`);\n\tfor (const t of printableTimings) {\n\t\tconsole.error(` ${t.label}: ${t.ms}ms`);\n\t}\n\tconsole.error(` TOTAL: ${printableTimings.reduce((a, b) => a + b.ms, 0)}ms`);\n\tconsole.error(`${\"-\".repeat(title.length + 8)}\\n`);\n}\n\nexport function printTimings(): void {\n\tif (!ENABLED) return;\n\tfor (const [namespace, timingNamespace] of timingNamespaces) {\n\t\tprintTimingGroup(`Startup Timings: ${namespace}`, timingNamespace.timings);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* capability_mount / capability_unmount: plugin-granular on-demand tool
|
|
3
|
+
* loading (插件按需挂载与能力手册设计 §5.2).
|
|
4
|
+
*
|
|
5
|
+
* Manifests declaring `activation: "on-demand"` register their tools into the
|
|
6
|
+
* registry but keep them out of the active set; the model sees a one-line
|
|
7
|
+
* capability card in the system prompt instead. `capability_mount` pulls the
|
|
8
|
+
* plugin's full tool set into the active surface (next request) and returns
|
|
9
|
+
* the plugin's AI manual; `capability_unmount` removes it from the active
|
|
10
|
+
* surface without touching any runtime state — session teardown remains the
|
|
11
|
+
* primary cleanup path. Kernel mechanism only: no plugin-specific branches.
|
|
12
|
+
*/
|
|
13
|
+
import { Type } from "typebox";
|
|
14
|
+
import type { ToolDefinition } from "./tool-definition.ts";
|
|
15
|
+
export interface DeferredCapabilityCardV1 {
|
|
16
|
+
readonly pluginId: string;
|
|
17
|
+
/** One-line capability summary from the manifest `description` field. */
|
|
18
|
+
readonly description?: string;
|
|
19
|
+
/** Absolute path to the plugin's AI manual (manifest `manual`, resolved). */
|
|
20
|
+
readonly manualPath?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface CapabilityMountDeps {
|
|
23
|
+
getCards(): readonly DeferredCapabilityCardV1[];
|
|
24
|
+
/** Registry tool names whose source is this plugin id. */
|
|
25
|
+
toolNamesForPlugin(pluginId: string): string[];
|
|
26
|
+
getActiveToolNames(): readonly string[];
|
|
27
|
+
setActiveToolsByName(toolNames: string[]): void;
|
|
28
|
+
readManual(path: string): Promise<string>;
|
|
29
|
+
}
|
|
30
|
+
export declare const CAPABILITY_MOUNT_TOOL_NAME = "capability_mount";
|
|
31
|
+
export declare const CAPABILITY_UNMOUNT_TOOL_NAME = "capability_unmount";
|
|
32
|
+
declare const mountParameters: Type.TObject<{
|
|
33
|
+
plugin: Type.TString;
|
|
34
|
+
}>;
|
|
35
|
+
declare const unmountParameters: Type.TObject<{
|
|
36
|
+
plugin: Type.TString;
|
|
37
|
+
}>;
|
|
38
|
+
export declare function createCapabilityMountTools(deps: CapabilityMountDeps): readonly [ToolDefinition<typeof mountParameters>, ToolDefinition<typeof unmountParameters>];
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=capability-mount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability-mount.d.ts","sourceRoot":"","sources":["../../../src/core/tools/capability-mount.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,yEAAyE;IACzE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,mBAAmB;IACnC,QAAQ,IAAI,SAAS,wBAAwB,EAAE,CAAC;IAChD,0DAA0D;IAC1D,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC/C,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAAC;IACxC,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAChD,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC1C;AAID,eAAO,MAAM,0BAA0B,qBAAqB,CAAC;AAC7D,eAAO,MAAM,4BAA4B,uBAAuB,CAAC;AAEjE,QAAA,MAAM,eAAe;;EAInB,CAAC;AAEH,QAAA,MAAM,iBAAiB;;EAErB,CAAC;AAEH,wBAAgB,0BAA0B,CACzC,IAAI,EAAE,mBAAmB,GACvB,SAAS,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,EAAE,cAAc,CAAC,OAAO,iBAAiB,CAAC,CAAC,CA+F7F","sourcesContent":["/**\n * capability_mount / capability_unmount: plugin-granular on-demand tool\n * loading (插件按需挂载与能力手册设计 §5.2).\n *\n * Manifests declaring `activation: \"on-demand\"` register their tools into the\n * registry but keep them out of the active set; the model sees a one-line\n * capability card in the system prompt instead. `capability_mount` pulls the\n * plugin's full tool set into the active surface (next request) and returns\n * the plugin's AI manual; `capability_unmount` removes it from the active\n * surface without touching any runtime state — session teardown remains the\n * primary cleanup path. Kernel mechanism only: no plugin-specific branches.\n */\n\nimport { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"./tool-definition.ts\";\n\nexport interface DeferredCapabilityCardV1 {\n\treadonly pluginId: string;\n\t/** One-line capability summary from the manifest `description` field. */\n\treadonly description?: string;\n\t/** Absolute path to the plugin's AI manual (manifest `manual`, resolved). */\n\treadonly manualPath?: string;\n}\n\nexport interface CapabilityMountDeps {\n\tgetCards(): readonly DeferredCapabilityCardV1[];\n\t/** Registry tool names whose source is this plugin id. */\n\ttoolNamesForPlugin(pluginId: string): string[];\n\tgetActiveToolNames(): readonly string[];\n\tsetActiveToolsByName(toolNames: string[]): void;\n\treadManual(path: string): Promise<string>;\n}\n\nconst MANUAL_MAX_CHARS = 16_000;\n\nexport const CAPABILITY_MOUNT_TOOL_NAME = \"capability_mount\";\nexport const CAPABILITY_UNMOUNT_TOOL_NAME = \"capability_unmount\";\n\nconst mountParameters = Type.Object({\n\tplugin: Type.String({\n\t\tdescription: \"Plugin id from the mountable-capabilities card, e.g. agent-forge.plugin.browser-playwright\",\n\t}),\n});\n\nconst unmountParameters = Type.Object({\n\tplugin: Type.String({ description: \"Plugin id to unmount, e.g. agent-forge.plugin.browser-playwright\" }),\n});\n\nexport function createCapabilityMountTools(\n\tdeps: CapabilityMountDeps,\n): readonly [ToolDefinition<typeof mountParameters>, ToolDefinition<typeof unmountParameters>] {\n\tconst mountTool: ToolDefinition<typeof mountParameters> = {\n\t\tname: CAPABILITY_MOUNT_TOOL_NAME,\n\t\tlabel: \"Capability mount\",\n\t\tdescription:\n\t\t\t\"Load a deferred plugin capability on demand: activates all of its tools for subsequent turns and returns \" +\n\t\t\t\"the plugin's usage manual. Mountable capabilities are listed in the system prompt's mountable-capabilities section.\",\n\t\tpromptSnippet:\n\t\t\t\"Activate a deferred plugin capability (browser tools, desktop control, image generation, ...) when its one-line card in the mountable-capabilities section matches the task\",\n\t\tparameters: mountParameters,\n\t\texecute: async (_toolCallId, params: Static<typeof mountParameters>) => {\n\t\t\tconst pluginId = params.plugin.trim();\n\t\t\tconst card = deps.getCards().find((entry) => entry.pluginId === pluginId);\n\t\t\tif (card === undefined) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `Unknown capability \"${pluginId}\". Mountable capabilities are listed in the system prompt's mountable-capabilities section.`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: { activated: false },\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst toolNames = deps.toolNamesForPlugin(pluginId);\n\t\t\tif (toolNames.length === 0) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: `Capability \"${pluginId}\" has no registered tools to activate.` }],\n\t\t\t\t\tdetails: { activated: false },\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst active = new Set(deps.getActiveToolNames());\n\t\t\tconst missing = toolNames.filter((name) => !active.has(name));\n\t\t\tif (missing.length > 0) {\n\t\t\t\tdeps.setActiveToolsByName([...deps.getActiveToolNames(), ...toolNames]);\n\t\t\t}\n\t\t\tconst manual =\n\t\t\t\tcard.manualPath === undefined ? undefined : await deps.readManual(card.manualPath).catch(() => undefined);\n\t\t\tconst activationLine =\n\t\t\t\tmissing.length === 0\n\t\t\t\t\t? `Capability \"${pluginId}\" is already active (${toolNames.length} tool(s)).`\n\t\t\t\t\t: `Activated ${missing.length} tool(s) for \"${pluginId}\": ${toolNames.join(\", \")}. They are available from the next turn.`;\n\t\t\tconst manualBlock =\n\t\t\t\tmanual === undefined\n\t\t\t\t\t? \"\"\n\t\t\t\t\t: `\\n\\n---\\n\\n${manual.slice(0, MANUAL_MAX_CHARS)}${manual.length > MANUAL_MAX_CHARS ? \"\\n\\n(manual truncated)\" : \"\"}`;\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: `${activationLine}${manualBlock}` }],\n\t\t\t\tdetails: { activated: missing.length > 0 },\n\t\t\t};\n\t\t},\n\t};\n\n\tconst unmountTool: ToolDefinition<typeof unmountParameters> = {\n\t\tname: CAPABILITY_UNMOUNT_TOOL_NAME,\n\t\tlabel: \"Capability unmount\",\n\t\tdescription:\n\t\t\t\"Remove a mounted plugin capability's tools from the active surface when the task that needed them is done. \" +\n\t\t\t\"Runtime state (e.g. an open browser session) is not torn down; it follows the plugin's own idle timeout. \" +\n\t\t\t\"Session teardown clears all mounts anyway, so unmounting is an optional long-session optimization.\",\n\t\tpromptSnippet:\n\t\t\t\"Deactivate a mounted plugin capability after finishing the task that needed it (optional; sessions clear mounts on teardown)\",\n\t\tparameters: unmountParameters,\n\t\texecute: async (_toolCallId, params: Static<typeof unmountParameters>) => {\n\t\t\tconst pluginId = params.plugin.trim();\n\t\t\tconst card = deps.getCards().find((entry) => entry.pluginId === pluginId);\n\t\t\tif (card === undefined) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: `Unknown capability \"${pluginId}\".` }],\n\t\t\t\t\tdetails: { unmounted: false },\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst toolNames = deps.toolNamesForPlugin(pluginId);\n\t\t\tconst active = new Set(deps.getActiveToolNames());\n\t\t\tconst mountedNames = toolNames.filter((name) => active.has(name));\n\t\t\tif (mountedNames.length === 0) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: `Capability \"${pluginId}\" is not mounted.` }],\n\t\t\t\t\tdetails: { unmounted: false },\n\t\t\t\t};\n\t\t\t}\n\t\t\tdeps.setActiveToolsByName(deps.getActiveToolNames().filter((name) => !mountedNames.includes(name)));\n\t\t\treturn {\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: `Unmounted \"${pluginId}\": removed ${mountedNames.length} tool(s) from the active surface. Runtime state was not touched.`,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdetails: { unmounted: true },\n\t\t\t};\n\t\t},\n\t};\n\n\treturn [mountTool, unmountTool] as const;\n}\n"]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* capability_mount / capability_unmount: plugin-granular on-demand tool
|
|
3
|
+
* loading (插件按需挂载与能力手册设计 §5.2).
|
|
4
|
+
*
|
|
5
|
+
* Manifests declaring `activation: "on-demand"` register their tools into the
|
|
6
|
+
* registry but keep them out of the active set; the model sees a one-line
|
|
7
|
+
* capability card in the system prompt instead. `capability_mount` pulls the
|
|
8
|
+
* plugin's full tool set into the active surface (next request) and returns
|
|
9
|
+
* the plugin's AI manual; `capability_unmount` removes it from the active
|
|
10
|
+
* surface without touching any runtime state — session teardown remains the
|
|
11
|
+
* primary cleanup path. Kernel mechanism only: no plugin-specific branches.
|
|
12
|
+
*/
|
|
13
|
+
import { Type } from "typebox";
|
|
14
|
+
const MANUAL_MAX_CHARS = 16_000;
|
|
15
|
+
export const CAPABILITY_MOUNT_TOOL_NAME = "capability_mount";
|
|
16
|
+
export const CAPABILITY_UNMOUNT_TOOL_NAME = "capability_unmount";
|
|
17
|
+
const mountParameters = Type.Object({
|
|
18
|
+
plugin: Type.String({
|
|
19
|
+
description: "Plugin id from the mountable-capabilities card, e.g. agent-forge.plugin.browser-playwright",
|
|
20
|
+
}),
|
|
21
|
+
});
|
|
22
|
+
const unmountParameters = Type.Object({
|
|
23
|
+
plugin: Type.String({ description: "Plugin id to unmount, e.g. agent-forge.plugin.browser-playwright" }),
|
|
24
|
+
});
|
|
25
|
+
export function createCapabilityMountTools(deps) {
|
|
26
|
+
const mountTool = {
|
|
27
|
+
name: CAPABILITY_MOUNT_TOOL_NAME,
|
|
28
|
+
label: "Capability mount",
|
|
29
|
+
description: "Load a deferred plugin capability on demand: activates all of its tools for subsequent turns and returns " +
|
|
30
|
+
"the plugin's usage manual. Mountable capabilities are listed in the system prompt's mountable-capabilities section.",
|
|
31
|
+
promptSnippet: "Activate a deferred plugin capability (browser tools, desktop control, image generation, ...) when its one-line card in the mountable-capabilities section matches the task",
|
|
32
|
+
parameters: mountParameters,
|
|
33
|
+
execute: async (_toolCallId, params) => {
|
|
34
|
+
const pluginId = params.plugin.trim();
|
|
35
|
+
const card = deps.getCards().find((entry) => entry.pluginId === pluginId);
|
|
36
|
+
if (card === undefined) {
|
|
37
|
+
return {
|
|
38
|
+
content: [
|
|
39
|
+
{
|
|
40
|
+
type: "text",
|
|
41
|
+
text: `Unknown capability "${pluginId}". Mountable capabilities are listed in the system prompt's mountable-capabilities section.`,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
details: { activated: false },
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const toolNames = deps.toolNamesForPlugin(pluginId);
|
|
48
|
+
if (toolNames.length === 0) {
|
|
49
|
+
return {
|
|
50
|
+
content: [{ type: "text", text: `Capability "${pluginId}" has no registered tools to activate.` }],
|
|
51
|
+
details: { activated: false },
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const active = new Set(deps.getActiveToolNames());
|
|
55
|
+
const missing = toolNames.filter((name) => !active.has(name));
|
|
56
|
+
if (missing.length > 0) {
|
|
57
|
+
deps.setActiveToolsByName([...deps.getActiveToolNames(), ...toolNames]);
|
|
58
|
+
}
|
|
59
|
+
const manual = card.manualPath === undefined ? undefined : await deps.readManual(card.manualPath).catch(() => undefined);
|
|
60
|
+
const activationLine = missing.length === 0
|
|
61
|
+
? `Capability "${pluginId}" is already active (${toolNames.length} tool(s)).`
|
|
62
|
+
: `Activated ${missing.length} tool(s) for "${pluginId}": ${toolNames.join(", ")}. They are available from the next turn.`;
|
|
63
|
+
const manualBlock = manual === undefined
|
|
64
|
+
? ""
|
|
65
|
+
: `\n\n---\n\n${manual.slice(0, MANUAL_MAX_CHARS)}${manual.length > MANUAL_MAX_CHARS ? "\n\n(manual truncated)" : ""}`;
|
|
66
|
+
return {
|
|
67
|
+
content: [{ type: "text", text: `${activationLine}${manualBlock}` }],
|
|
68
|
+
details: { activated: missing.length > 0 },
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
const unmountTool = {
|
|
73
|
+
name: CAPABILITY_UNMOUNT_TOOL_NAME,
|
|
74
|
+
label: "Capability unmount",
|
|
75
|
+
description: "Remove a mounted plugin capability's tools from the active surface when the task that needed them is done. " +
|
|
76
|
+
"Runtime state (e.g. an open browser session) is not torn down; it follows the plugin's own idle timeout. " +
|
|
77
|
+
"Session teardown clears all mounts anyway, so unmounting is an optional long-session optimization.",
|
|
78
|
+
promptSnippet: "Deactivate a mounted plugin capability after finishing the task that needed it (optional; sessions clear mounts on teardown)",
|
|
79
|
+
parameters: unmountParameters,
|
|
80
|
+
execute: async (_toolCallId, params) => {
|
|
81
|
+
const pluginId = params.plugin.trim();
|
|
82
|
+
const card = deps.getCards().find((entry) => entry.pluginId === pluginId);
|
|
83
|
+
if (card === undefined) {
|
|
84
|
+
return {
|
|
85
|
+
content: [{ type: "text", text: `Unknown capability "${pluginId}".` }],
|
|
86
|
+
details: { unmounted: false },
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const toolNames = deps.toolNamesForPlugin(pluginId);
|
|
90
|
+
const active = new Set(deps.getActiveToolNames());
|
|
91
|
+
const mountedNames = toolNames.filter((name) => active.has(name));
|
|
92
|
+
if (mountedNames.length === 0) {
|
|
93
|
+
return {
|
|
94
|
+
content: [{ type: "text", text: `Capability "${pluginId}" is not mounted.` }],
|
|
95
|
+
details: { unmounted: false },
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
deps.setActiveToolsByName(deps.getActiveToolNames().filter((name) => !mountedNames.includes(name)));
|
|
99
|
+
return {
|
|
100
|
+
content: [
|
|
101
|
+
{
|
|
102
|
+
type: "text",
|
|
103
|
+
text: `Unmounted "${pluginId}": removed ${mountedNames.length} tool(s) from the active surface. Runtime state was not touched.`,
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
details: { unmounted: true },
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
return [mountTool, unmountTool];
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=capability-mount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability-mount.js","sourceRoot":"","sources":["../../../src/core/tools/capability-mount.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAoB5C,MAAM,gBAAgB,GAAG,MAAM,CAAC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AC,IAAI,CAAC,CAAC,CAAC;YAClE,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC/B,OAAO;oBACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,QAAQ,mBAAmB,EAAE,CAAC;oBAC7E,OAAO,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;iBAC7B,CAAC;YACH,CAAC;YACD,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACpG,OAAO;gBACN,OAAO,EAAE;oBACR;wBACC,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,cAAc,QAAQ,cAAc,YAAY,CAAC,MAAM,kEAAkE;qBAC/H;iBACD;gBACD,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;aAC5B,CAAC;QAAA,CACF;KACD,CAAC;IAEF,OAAO,CAAC,SAAS,EAAE,WAAW,CAAU,CAAC;AAAA,CACzC","sourcesContent":["/**\n * capability_mount / capability_unmount: plugin-granular on-demand tool\n * loading (插件按需挂载与能力手册设计 §5.2).\n *\n * Manifests declaring `activation: \"on-demand\"` register their tools into the\n * registry but keep them out of the active set; the model sees a one-line\n * capability card in the system prompt instead. `capability_mount` pulls the\n * plugin's full tool set into the active surface (next request) and returns\n * the plugin's AI manual; `capability_unmount` removes it from the active\n * surface without touching any runtime state — session teardown remains the\n * primary cleanup path. Kernel mechanism only: no plugin-specific branches.\n */\n\nimport { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"./tool-definition.ts\";\n\nexport interface DeferredCapabilityCardV1 {\n\treadonly pluginId: string;\n\t/** One-line capability summary from the manifest `description` field. */\n\treadonly description?: string;\n\t/** Absolute path to the plugin's AI manual (manifest `manual`, resolved). */\n\treadonly manualPath?: string;\n}\n\nexport interface CapabilityMountDeps {\n\tgetCards(): readonly DeferredCapabilityCardV1[];\n\t/** Registry tool names whose source is this plugin id. */\n\ttoolNamesForPlugin(pluginId: string): string[];\n\tgetActiveToolNames(): readonly string[];\n\tsetActiveToolsByName(toolNames: string[]): void;\n\treadManual(path: string): Promise<string>;\n}\n\nconst MANUAL_MAX_CHARS = 16_000;\n\nexport const CAPABILITY_MOUNT_TOOL_NAME = \"capability_mount\";\nexport const CAPABILITY_UNMOUNT_TOOL_NAME = \"capability_unmount\";\n\nconst mountParameters = Type.Object({\n\tplugin: Type.String({\n\t\tdescription: \"Plugin id from the mountable-capabilities card, e.g. agent-forge.plugin.browser-playwright\",\n\t}),\n});\n\nconst unmountParameters = Type.Object({\n\tplugin: Type.String({ description: \"Plugin id to unmount, e.g. agent-forge.plugin.browser-playwright\" }),\n});\n\nexport function createCapabilityMountTools(\n\tdeps: CapabilityMountDeps,\n): readonly [ToolDefinition<typeof mountParameters>, ToolDefinition<typeof unmountParameters>] {\n\tconst mountTool: ToolDefinition<typeof mountParameters> = {\n\t\tname: CAPABILITY_MOUNT_TOOL_NAME,\n\t\tlabel: \"Capability mount\",\n\t\tdescription:\n\t\t\t\"Load a deferred plugin capability on demand: activates all of its tools for subsequent turns and returns \" +\n\t\t\t\"the plugin's usage manual. Mountable capabilities are listed in the system prompt's mountable-capabilities section.\",\n\t\tpromptSnippet:\n\t\t\t\"Activate a deferred plugin capability (browser tools, desktop control, image generation, ...) when its one-line card in the mountable-capabilities section matches the task\",\n\t\tparameters: mountParameters,\n\t\texecute: async (_toolCallId, params: Static<typeof mountParameters>) => {\n\t\t\tconst pluginId = params.plugin.trim();\n\t\t\tconst card = deps.getCards().find((entry) => entry.pluginId === pluginId);\n\t\t\tif (card === undefined) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `Unknown capability \"${pluginId}\". Mountable capabilities are listed in the system prompt's mountable-capabilities section.`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: { activated: false },\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst toolNames = deps.toolNamesForPlugin(pluginId);\n\t\t\tif (toolNames.length === 0) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: `Capability \"${pluginId}\" has no registered tools to activate.` }],\n\t\t\t\t\tdetails: { activated: false },\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst active = new Set(deps.getActiveToolNames());\n\t\t\tconst missing = toolNames.filter((name) => !active.has(name));\n\t\t\tif (missing.length > 0) {\n\t\t\t\tdeps.setActiveToolsByName([...deps.getActiveToolNames(), ...toolNames]);\n\t\t\t}\n\t\t\tconst manual =\n\t\t\t\tcard.manualPath === undefined ? undefined : await deps.readManual(card.manualPath).catch(() => undefined);\n\t\t\tconst activationLine =\n\t\t\t\tmissing.length === 0\n\t\t\t\t\t? `Capability \"${pluginId}\" is already active (${toolNames.length} tool(s)).`\n\t\t\t\t\t: `Activated ${missing.length} tool(s) for \"${pluginId}\": ${toolNames.join(\", \")}. They are available from the next turn.`;\n\t\t\tconst manualBlock =\n\t\t\t\tmanual === undefined\n\t\t\t\t\t? \"\"\n\t\t\t\t\t: `\\n\\n---\\n\\n${manual.slice(0, MANUAL_MAX_CHARS)}${manual.length > MANUAL_MAX_CHARS ? \"\\n\\n(manual truncated)\" : \"\"}`;\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: `${activationLine}${manualBlock}` }],\n\t\t\t\tdetails: { activated: missing.length > 0 },\n\t\t\t};\n\t\t},\n\t};\n\n\tconst unmountTool: ToolDefinition<typeof unmountParameters> = {\n\t\tname: CAPABILITY_UNMOUNT_TOOL_NAME,\n\t\tlabel: \"Capability unmount\",\n\t\tdescription:\n\t\t\t\"Remove a mounted plugin capability's tools from the active surface when the task that needed them is done. \" +\n\t\t\t\"Runtime state (e.g. an open browser session) is not torn down; it follows the plugin's own idle timeout. \" +\n\t\t\t\"Session teardown clears all mounts anyway, so unmounting is an optional long-session optimization.\",\n\t\tpromptSnippet:\n\t\t\t\"Deactivate a mounted plugin capability after finishing the task that needed it (optional; sessions clear mounts on teardown)\",\n\t\tparameters: unmountParameters,\n\t\texecute: async (_toolCallId, params: Static<typeof unmountParameters>) => {\n\t\t\tconst pluginId = params.plugin.trim();\n\t\t\tconst card = deps.getCards().find((entry) => entry.pluginId === pluginId);\n\t\t\tif (card === undefined) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: `Unknown capability \"${pluginId}\".` }],\n\t\t\t\t\tdetails: { unmounted: false },\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst toolNames = deps.toolNamesForPlugin(pluginId);\n\t\t\tconst active = new Set(deps.getActiveToolNames());\n\t\t\tconst mountedNames = toolNames.filter((name) => active.has(name));\n\t\t\tif (mountedNames.length === 0) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: `Capability \"${pluginId}\" is not mounted.` }],\n\t\t\t\t\tdetails: { unmounted: false },\n\t\t\t\t};\n\t\t\t}\n\t\t\tdeps.setActiveToolsByName(deps.getActiveToolNames().filter((name) => !mountedNames.includes(name)));\n\t\t\treturn {\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: `Unmounted \"${pluginId}\": removed ${mountedNames.length} tool(s) from the active surface. Runtime state was not touched.`,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdetails: { unmounted: true },\n\t\t\t};\n\t\t},\n\t};\n\n\treturn [mountTool, unmountTool] as const;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ImageContent, TextContent } from "@agent-forge/ai";
|
|
2
|
-
import type { Theme } from "../../
|
|
2
|
+
import type { Theme } from "../../theme/theme.ts";
|
|
3
3
|
export declare function shortenPath(path: unknown): string;
|
|
4
4
|
export declare function linkPath(styledText: string, rawPath: string, cwd: string): string;
|
|
5
5
|
export declare function str(value: unknown): string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-utils.d.ts","sourceRoot":"","sources":["../../../src/core/tools/render-utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"render-utils.d.ts","sourceRoot":"","sources":["../../../src/core/tools/render-utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAKlD,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAOjD;AAED,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAIjF;AAED,wBAAgB,GAAG,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAIjD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,wBAAgB,aAAa,CAC5B,MAAM,EAAE;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,GAAG,SAAS,EACzG,UAAU,EAAE,OAAO,GACjB,MAAM,CAsBR;AAED,MAAM,MAAM,oBAAoB,CAAC,QAAQ,IAAI;IAC5C,OAAO,EAAE,CAAC,WAAW,GAAG,YAAY,CAAC,EAAE,CAAC;IACxC,OAAO,EAAE,QAAQ,CAAC;CAClB,CAAC;AAIF;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CAkB5G;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAEnD;AAED,wBAAgB,cAAc,CAC7B,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GAClC,MAAM,CAKR","sourcesContent":["import * as os from \"node:os\";\nimport { pathToFileURL } from \"node:url\";\nimport type { ImageContent, TextContent } from \"@agent-forge/ai\";\nimport { getCapabilities, getImageDimensions, hyperlink, imageFallback } from \"@agent-forge/tui\";\nimport type { Theme } from \"../../theme/theme.ts\";\nimport { stripAnsi } from \"../../utils/ansi.ts\";\nimport { resolvePath } from \"../../utils/paths.ts\";\nimport { sanitizeBinaryOutput } from \"../../utils/shell.ts\";\n\nexport function shortenPath(path: unknown): string {\n\tif (typeof path !== \"string\") return \"\";\n\tconst home = os.homedir();\n\tif (path.startsWith(home)) {\n\t\treturn `~${path.slice(home.length)}`;\n\t}\n\treturn path;\n}\n\nexport function linkPath(styledText: string, rawPath: string, cwd: string): string {\n\tif (!getCapabilities().hyperlinks) return styledText;\n\tconst absolutePath = resolvePath(rawPath, cwd);\n\treturn hyperlink(styledText, pathToFileURL(absolutePath).href);\n}\n\nexport function str(value: unknown): string | null {\n\tif (typeof value === \"string\") return value;\n\tif (value == null) return \"\";\n\treturn null;\n}\n\nexport function replaceTabs(text: string): string {\n\treturn text.replace(/\\t/g, \" \");\n}\n\nexport function normalizeDisplayText(text: string): string {\n\treturn text.replace(/\\r/g, \"\");\n}\n\nexport function getTextOutput(\n\tresult: { content: Array<{ type: string; text?: string; data?: string; mimeType?: string }> } | undefined,\n\tshowImages: boolean,\n): string {\n\tif (!result) return \"\";\n\n\tconst textBlocks = result.content.filter((c) => c.type === \"text\");\n\tconst imageBlocks = result.content.filter((c) => c.type === \"image\");\n\n\tlet output = textBlocks.map((c) => sanitizeBinaryOutput(stripAnsi(c.text || \"\")).replace(/\\r/g, \"\")).join(\"\\n\");\n\n\tconst caps = getCapabilities();\n\tif (imageBlocks.length > 0 && (!caps.images || !showImages)) {\n\t\tconst imageIndicators = imageBlocks\n\t\t\t.map((img) => {\n\t\t\t\tconst mimeType = img.mimeType ?? \"image/unknown\";\n\t\t\t\tconst dims =\n\t\t\t\t\timg.data && img.mimeType ? (getImageDimensions(img.data, img.mimeType) ?? undefined) : undefined;\n\t\t\t\treturn imageFallback(mimeType, dims);\n\t\t\t})\n\t\t\t.join(\"\\n\");\n\t\toutput = output ? `${output}\\n${imageIndicators}` : imageIndicators;\n\t}\n\n\treturn output;\n}\n\nexport type ToolRenderResultLike<TDetails> = {\n\tcontent: (TextContent | ImageContent)[];\n\tdetails: TDetails;\n};\n\nconst COLLAPSED_ARGS_CHARS = 100;\n\n/**\n * Generic tool call header: the title followed by the arguments. Collapsed, they are `key=value`\n * pairs on the title line, cut to {@link COLLAPSED_ARGS_CHARS}. Expanded, each is a `key: value`\n * line below the title, with strings shown raw and continuation lines indented.\n */\nexport function formatToolCallWithArgs(title: string, args: unknown, theme: Theme, expanded: boolean): string {\n\tconst header = theme.fg(\"toolTitle\", theme.bold(title));\n\tif (args == null) return header;\n\tconst entries =\n\t\ttypeof args === \"object\" && !Array.isArray(args)\n\t\t\t? Object.entries(args)\n\t\t\t: ([[\"args\", args]] as [string, unknown][]);\n\tif (entries.length === 0) return header;\n\tif (expanded) {\n\t\tconst lines = entries.map(([key, value]) => {\n\t\t\tconst text = typeof value === \"string\" ? value : (JSON.stringify(value, null, 2) ?? String(value));\n\t\t\treturn ` ${key}: ${replaceTabs(text).replace(/\\r/g, \"\").split(\"\\n\").join(\"\\n \")}`;\n\t\t});\n\t\treturn `${header}\\n${theme.fg(\"muted\", lines.join(\"\\n\"))}`;\n\t}\n\tconst pairs = entries.map(([key, value]) => `${key}=${JSON.stringify(value) ?? String(value)}`).join(\" \");\n\tconst preview = pairs.length > COLLAPSED_ARGS_CHARS ? `${pairs.slice(0, COLLAPSED_ARGS_CHARS - 3)}...` : pairs;\n\treturn `${header} ${theme.fg(\"muted\", preview)}`;\n}\n\nexport function invalidArgText(theme: Theme): string {\n\treturn theme.fg(\"error\", \"[invalid arg]\");\n}\n\nexport function renderToolPath(\n\trawPath: string | null,\n\ttheme: Theme,\n\tcwd: string,\n\toptions?: { emptyFallback?: string },\n): string {\n\tif (rawPath === null) return invalidArgText(theme);\n\tconst value = rawPath || options?.emptyFallback;\n\tif (!value) return theme.fg(\"toolOutput\", \"...\");\n\treturn linkPath(theme.fg(\"accent\", shortenPath(value)), value, cwd);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-utils.js","sourceRoot":"","sources":["../../../src/core/tools/render-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjG,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,UAAU,WAAW,CAAC,IAAa,EAAU;IAClD,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IACxC,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;IAC1B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AAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1G,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,GAAG,oBAAoB,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IAC/G,OAAO,GAAG,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC;AAAA,CACjD;AAED,MAAM,UAAU,cAAc,CAAC,KAAY,EAAU;IACpD,OAAO,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;AAAA,CAC1C;AAED,MAAM,UAAU,cAAc,CAC7B,OAAsB,EACtB,KAAY,EACZ,GAAW,EACX,OAAoC,EAC3B;IACT,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;IACnD,MAAM,KAAK,GAAG,OAAO,IAAI,OAAO,EAAE,aAAa,CAAC;IAChD,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC,EAAE,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IACjD,OAAO,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;AAAA,CACpE","sourcesContent":["import * as os from \"node:os\";\nimport { pathToFileURL } from \"node:url\";\nimport type { ImageContent, TextContent } from \"@agent-forge/ai\";\nimport { getCapabilities, getImageDimensions, hyperlink, imageFallback } from \"@agent-forge/tui\";\nimport type { Theme } from \"../../
|
|
1
|
+
{"version":3,"file":"render-utils.js","sourceRoot":"","sources":["../../../src/core/tools/render-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,U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AC,QAAQ,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;AAAA,CACpE","sourcesContent":["import * as os from \"node:os\";\nimport { pathToFileURL } from \"node:url\";\nimport type { ImageContent, TextContent } from \"@agent-forge/ai\";\nimport { getCapabilities, getImageDimensions, hyperlink, imageFallback } from \"@agent-forge/tui\";\nimport type { Theme } from \"../../theme/theme.ts\";\nimport { stripAnsi } from \"../../utils/ansi.ts\";\nimport { resolvePath } from \"../../utils/paths.ts\";\nimport { sanitizeBinaryOutput } from \"../../utils/shell.ts\";\n\nexport function shortenPath(path: unknown): string {\n\tif (typeof path !== \"string\") return \"\";\n\tconst home = os.homedir();\n\tif (path.startsWith(home)) {\n\t\treturn `~${path.slice(home.length)}`;\n\t}\n\treturn path;\n}\n\nexport function linkPath(styledText: string, rawPath: string, cwd: string): string {\n\tif (!getCapabilities().hyperlinks) return styledText;\n\tconst absolutePath = resolvePath(rawPath, cwd);\n\treturn hyperlink(styledText, pathToFileURL(absolutePath).href);\n}\n\nexport function str(value: unknown): string | null {\n\tif (typeof value === \"string\") return value;\n\tif (value == null) return \"\";\n\treturn null;\n}\n\nexport function replaceTabs(text: string): string {\n\treturn text.replace(/\\t/g, \" \");\n}\n\nexport function normalizeDisplayText(text: string): string {\n\treturn text.replace(/\\r/g, \"\");\n}\n\nexport function getTextOutput(\n\tresult: { content: Array<{ type: string; text?: string; data?: string; mimeType?: string }> } | undefined,\n\tshowImages: boolean,\n): string {\n\tif (!result) return \"\";\n\n\tconst textBlocks = result.content.filter((c) => c.type === \"text\");\n\tconst imageBlocks = result.content.filter((c) => c.type === \"image\");\n\n\tlet output = textBlocks.map((c) => sanitizeBinaryOutput(stripAnsi(c.text || \"\")).replace(/\\r/g, \"\")).join(\"\\n\");\n\n\tconst caps = getCapabilities();\n\tif (imageBlocks.length > 0 && (!caps.images || !showImages)) {\n\t\tconst imageIndicators = imageBlocks\n\t\t\t.map((img) => {\n\t\t\t\tconst mimeType = img.mimeType ?? \"image/unknown\";\n\t\t\t\tconst dims =\n\t\t\t\t\timg.data && img.mimeType ? (getImageDimensions(img.data, img.mimeType) ?? undefined) : undefined;\n\t\t\t\treturn imageFallback(mimeType, dims);\n\t\t\t})\n\t\t\t.join(\"\\n\");\n\t\toutput = output ? `${output}\\n${imageIndicators}` : imageIndicators;\n\t}\n\n\treturn output;\n}\n\nexport type ToolRenderResultLike<TDetails> = {\n\tcontent: (TextContent | ImageContent)[];\n\tdetails: TDetails;\n};\n\nconst COLLAPSED_ARGS_CHARS = 100;\n\n/**\n * Generic tool call header: the title followed by the arguments. Collapsed, they are `key=value`\n * pairs on the title line, cut to {@link COLLAPSED_ARGS_CHARS}. Expanded, each is a `key: value`\n * line below the title, with strings shown raw and continuation lines indented.\n */\nexport function formatToolCallWithArgs(title: string, args: unknown, theme: Theme, expanded: boolean): string {\n\tconst header = theme.fg(\"toolTitle\", theme.bold(title));\n\tif (args == null) return header;\n\tconst entries =\n\t\ttypeof args === \"object\" && !Array.isArray(args)\n\t\t\t? Object.entries(args)\n\t\t\t: ([[\"args\", args]] as [string, unknown][]);\n\tif (entries.length === 0) return header;\n\tif (expanded) {\n\t\tconst lines = entries.map(([key, value]) => {\n\t\t\tconst text = typeof value === \"string\" ? value : (JSON.stringify(value, null, 2) ?? String(value));\n\t\t\treturn ` ${key}: ${replaceTabs(text).replace(/\\r/g, \"\").split(\"\\n\").join(\"\\n \")}`;\n\t\t});\n\t\treturn `${header}\\n${theme.fg(\"muted\", lines.join(\"\\n\"))}`;\n\t}\n\tconst pairs = entries.map(([key, value]) => `${key}=${JSON.stringify(value) ?? String(value)}`).join(\" \");\n\tconst preview = pairs.length > COLLAPSED_ARGS_CHARS ? `${pairs.slice(0, COLLAPSED_ARGS_CHARS - 3)}...` : pairs;\n\treturn `${header} ${theme.fg(\"muted\", preview)}`;\n}\n\nexport function invalidArgText(theme: Theme): string {\n\treturn theme.fg(\"error\", \"[invalid arg]\");\n}\n\nexport function renderToolPath(\n\trawPath: string | null,\n\ttheme: Theme,\n\tcwd: string,\n\toptions?: { emptyFallback?: string },\n): string {\n\tif (rawPath === null) return invalidArgText(theme);\n\tconst value = rawPath || options?.emptyFallback;\n\tif (!value) return theme.fg(\"toolOutput\", \"...\");\n\treturn linkPath(theme.fg(\"accent\", shortenPath(value)), value, cwd);\n}\n"]}
|
|
@@ -11,7 +11,7 @@ import type { AgentToolResult, AgentToolUpdateCallback, ThinkingLevel, ToolExecu
|
|
|
11
11
|
import type { Api, ConstrainedSamplingConfig, Model } from "@agent-forge/ai";
|
|
12
12
|
import type { Component } from "@agent-forge/tui";
|
|
13
13
|
import type { Static, TSchema } from "typebox";
|
|
14
|
-
import type { Theme } from "../../
|
|
14
|
+
import type { Theme } from "../../theme/theme.ts";
|
|
15
15
|
import type { SourceInfo } from "../source-info.ts";
|
|
16
16
|
/** Session-scoped facts handed to a tool's execute. The session resolves the values at call time. */
|
|
17
17
|
export interface ToolExecuteContext {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-definition.d.ts","sourceRoot":"","sources":["../../../src/core/tools/tool-definition.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACX,eAAe,EACf,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,GAAG,EAAE,yBAAyB,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,qGAAqG;AACrG,MAAM,WAAW,kBAAkB;IAClC,iCAAiC;IACjC,GAAG,EAAE,M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CAAC,OAAO,CAAC,CAAC,GACjD,SAAS,CAAC;CACb;AAED,kGAAkG;AAClG,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,aAAa,GAAG,YAAY,GAAG,kBAAkB,CAAC,GAAG;IACzG,UAAU,EAAE,UAAU,CAAC;CACvB,CAAC;AAEF,KAAK,iBAAiB,GAAG,cAAc,CAAC;AAExC;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,SAAS,OAAO,EAAE,QAAQ,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,EACvF,IAAI,EAAE,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,GAC7C,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,iBAAiB,CAE/D","sourcesContent":["/**\n * Tool definition types shared by the built-in coding tools, SDK custom tools,\n * and the capability tool registry projection.\n *\n * This is the tool domain's own type home (D-052 sibling ruling: these types\n * describe product tools, not any host UI). The render types are consumed by\n * the TUI tool components but defined here because the definition carries the\n * renderer contract.\n */\n\nimport type {\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n\tThinkingLevel,\n\tToolExecutionMode,\n} from \"@agent-forge/agent-core\";\nimport type { Api, ConstrainedSamplingConfig, Model } from \"@agent-forge/ai\";\nimport type { Component } from \"@agent-forge/tui\";\nimport type { Static, TSchema } from \"typebox\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport type { SourceInfo } from \"../source-info.ts\";\n\n/** Session-scoped facts handed to a tool's execute. The session resolves the values at call time. */\nexport interface ToolExecuteContext {\n\t/** Current working directory. */\n\tcwd: string;\n\t/** Current model (may be undefined). */\n\tmodel: Model<Api> | undefined;\n\t/** Session identity for env exposure and logging. */\n\tsessionManager: {\n\t\tgetSessionId(): string;\n\t\tgetSessionFile(): string | undefined;\n\t};\n\t/** Current thinking level, when provided by the session runtime. */\n\tthinkingLevel: ThinkingLevel | undefined;\n}\n\n/** Rendering options for tool results */\nexport interface ToolRenderResultOptions {\n\t/** Whether the result view is expanded */\n\texpanded: boolean;\n\t/** Whether this is a partial/streaming result */\n\tisPartial: boolean;\n}\n\n/** Context passed to tool renderers. */\nexport interface ToolRenderContext<TState = unknown, TArgs = unknown> {\n\t/** Current tool call arguments. Shared across call/result renders for the same tool call. */\n\targs: TArgs;\n\t/** Unique id for this tool execution. Stable across call/result renders for the same tool call. */\n\ttoolCallId: string;\n\t/** Invalidate just this tool execution component for redraw. */\n\tinvalidate: () => void;\n\t/** Previously returned component for this render slot, if any. */\n\tlastComponent: Component | undefined;\n\t/** Shared renderer state for this tool row. Initialized by tool-execution.ts. */\n\tstate: TState;\n\t/** Working directory for this tool execution. */\n\tcwd: string;\n\t/** Whether the tool execution has started. */\n\texecutionStarted: boolean;\n\t/** Whether the tool call arguments are complete. */\n\targsComplete: boolean;\n\t/** Whether the tool result is partial/streaming. */\n\tisPartial: boolean;\n\t/** Whether the result view is expanded. */\n\texpanded: boolean;\n\t/** Whether inline images are currently shown in the TUI. */\n\tshowImages: boolean;\n\t/** Whether the current result is an error. */\n\tisError: boolean;\n}\n\n/**\n * Tool definition for the session tool registry (built-in tools, SDK custom\n * tools, and the capability runtime's tool projection).\n */\nexport interface ToolDefinition<TParams extends TSchema = TSchema, TDetails = unknown, TState = unknown> {\n\t/** Tool name (used in LLM tool calls) */\n\tname: string;\n\t/** Human-readable label for UI */\n\tlabel: string;\n\t/** Description for LLM */\n\tdescription: string;\n\t/** Optional one-line snippet for the Available tools section in the default system prompt. Custom tools are omitted from that section when this is not provided. */\n\tpromptSnippet?: string;\n\t/** Optional guideline bullets appended to the default system prompt Guidelines section when this tool is active. */\n\tpromptGuidelines?: string[];\n\t/** Parameter schema (TypeBox) */\n\tparameters: TParams;\n\t/** Optional provider-side constrained sampling request for this tool. Set false to explicitly disable it, equivalent to leaving it undefined. */\n\tconstrainedSampling?: false | ConstrainedSamplingConfig;\n\t/** Controls whether ToolExecutionComponent renders the standard colored shell or the tool renders its own framing. */\n\trenderShell?: \"default\" | \"self\";\n\n\t/** Optional compatibility shim to prepare raw tool call arguments before schema validation. Must return an object conforming to TParams. */\n\tprepareArguments?: (args: unknown) => Static<TParams>;\n\n\t/**\n\t * Per-tool execution mode override.\n\t * - \"sequential\": this tool must execute one at a time with other tool calls.\n\t * - \"parallel\": this tool can execute concurrently with other tool calls.\n\t *\n\t * If omitted, the default execution mode applies.\n\t */\n\texecutionMode?: ToolExecutionMode;\n\n\t/**\n\t * Owning-plugin declaration (宪法 §6): this tool is explicitly safe for the\n\t * `readonly` capability mode. In readonly sessions the kernel keeps only\n\t * first-party (`agent-forge.builtin.*`) tools that declare it on the active\n\t * face; tools from external plugins keep their own semantics regardless.\n\t */\n\treadonlySafe?: boolean;\n\n\t/** Execute the tool. */\n\texecute(\n\t\ttoolCallId: string,\n\t\tparams: Static<TParams>,\n\t\tsignal: AbortSignal | undefined,\n\t\tonUpdate: AgentToolUpdateCallback<TDetails> | undefined,\n\t\tctx: ToolExecuteContext,\n\t): Promise<AgentToolResult<TDetails>>;\n\n\t/**\n\t * Custom rendering for tool call display. Method syntax keeps renderer assignability bivariant in TState.\n\t *\n\t * Hosting boundary: this face returns a host-side `Component`. First-party\n\t * builtin tools render through the `@agent-forge/tui` package; capability\n\t * plugins must NOT import that package (install-store distribution is\n\t * self-contained and cannot resolve workspace deps — a plugin doing this\n\t * fails to load in production while passing workspace-local tests). A\n\t * plugin that wants custom rendering implements the structural shape\n\t * (`{ render(width): string[]; invalidate?(): void }`) without the package,\n\t * or relies on the generic fallback preview.\n\t */\n\trenderCall?(args: Static<TParams>, theme: Theme, context: ToolRenderContext<TState, Static<TParams>>): Component;\n\n\t/**\n\t * Custom rendering for tool result display. Method syntax keeps renderer assignability bivariant in TState/TDetails.\n\t *\n\t * Same hosting boundary as `renderCall`: structural `Component`\n\t * implementations only for capability plugins; no `@agent-forge/tui` import\n\t * (see renderCall for the failure mode). The generic fallback (compact\n\t * single-line JSON preview with an expand hint) covers plugins without a\n\t * renderer.\n\t */\n\trenderResult?(\n\t\tresult: AgentToolResult<TDetails>,\n\t\toptions: ToolRenderResultOptions,\n\t\ttheme: Theme,\n\t\tcontext: ToolRenderContext<TState, Static<TParams>>,\n\t): Component;\n}\n\n/** Tool info with name, description, parameter schema, prompt guidelines, and source metadata. */\nexport type ToolInfo = Pick<ToolDefinition, \"name\" | \"description\" | \"parameters\" | \"promptGuidelines\"> & {\n\tsourceInfo: SourceInfo;\n};\n\ntype AnyToolDefinition = ToolDefinition;\n\n/**\n * Preserve parameter inference for standalone tool definitions.\n *\n * Use this when assigning a tool to a variable or passing it through arrays such\n * as `customTools`, where contextual typing would otherwise widen params to\n * `unknown`.\n */\nexport function defineTool<TParams extends TSchema, TDetails = unknown, TState = unknown>(\n\ttool: ToolDefinition<TParams, TDetails, TState>,\n): ToolDefinition<TParams, TDetails, TState> & AnyToolDefinition {\n\treturn tool as ToolDefinition<TParams, TDetails, TState> & AnyToolDefinition;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tool-definition.d.ts","sourceRoot":"","sources":["../../../src/core/tools/tool-definition.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACX,eAAe,EACf,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,GAAG,EAAE,yBAAyB,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,qGAAqG;AACrG,MAAM,WAAW,kBAAkB;IAClC,iCAAiC;IACjC,GAAG,EAAE,MAAM,CAA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AO,CAAC,CAAC,GACjD,SAAS,CAAC;CACb;AAED,kGAAkG;AAClG,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,aAAa,GAAG,YAAY,GAAG,kBAAkB,CAAC,GAAG;IACzG,UAAU,EAAE,UAAU,CAAC;CACvB,CAAC;AAEF,KAAK,iBAAiB,GAAG,cAAc,CAAC;AAExC;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,SAAS,OAAO,EAAE,QAAQ,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,EACvF,IAAI,EAAE,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,GAC7C,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,iBAAiB,CAE/D","sourcesContent":["/**\n * Tool definition types shared by the built-in coding tools, SDK custom tools,\n * and the capability tool registry projection.\n *\n * This is the tool domain's own type home (D-052 sibling ruling: these types\n * describe product tools, not any host UI). The render types are consumed by\n * the TUI tool components but defined here because the definition carries the\n * renderer contract.\n */\n\nimport type {\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n\tThinkingLevel,\n\tToolExecutionMode,\n} from \"@agent-forge/agent-core\";\nimport type { Api, ConstrainedSamplingConfig, Model } from \"@agent-forge/ai\";\nimport type { Component } from \"@agent-forge/tui\";\nimport type { Static, TSchema } from \"typebox\";\nimport type { Theme } from \"../../theme/theme.ts\";\nimport type { SourceInfo } from \"../source-info.ts\";\n\n/** Session-scoped facts handed to a tool's execute. The session resolves the values at call time. */\nexport interface ToolExecuteContext {\n\t/** Current working directory. */\n\tcwd: string;\n\t/** Current model (may be undefined). */\n\tmodel: Model<Api> | undefined;\n\t/** Session identity for env exposure and logging. */\n\tsessionManager: {\n\t\tgetSessionId(): string;\n\t\tgetSessionFile(): string | undefined;\n\t};\n\t/** Current thinking level, when provided by the session runtime. */\n\tthinkingLevel: ThinkingLevel | undefined;\n}\n\n/** Rendering options for tool results */\nexport interface ToolRenderResultOptions {\n\t/** Whether the result view is expanded */\n\texpanded: boolean;\n\t/** Whether this is a partial/streaming result */\n\tisPartial: boolean;\n}\n\n/** Context passed to tool renderers. */\nexport interface ToolRenderContext<TState = unknown, TArgs = unknown> {\n\t/** Current tool call arguments. Shared across call/result renders for the same tool call. */\n\targs: TArgs;\n\t/** Unique id for this tool execution. Stable across call/result renders for the same tool call. */\n\ttoolCallId: string;\n\t/** Invalidate just this tool execution component for redraw. */\n\tinvalidate: () => void;\n\t/** Previously returned component for this render slot, if any. */\n\tlastComponent: Component | undefined;\n\t/** Shared renderer state for this tool row. Initialized by tool-execution.ts. */\n\tstate: TState;\n\t/** Working directory for this tool execution. */\n\tcwd: string;\n\t/** Whether the tool execution has started. */\n\texecutionStarted: boolean;\n\t/** Whether the tool call arguments are complete. */\n\targsComplete: boolean;\n\t/** Whether the tool result is partial/streaming. */\n\tisPartial: boolean;\n\t/** Whether the result view is expanded. */\n\texpanded: boolean;\n\t/** Whether inline images are currently shown in the TUI. */\n\tshowImages: boolean;\n\t/** Whether the current result is an error. */\n\tisError: boolean;\n}\n\n/**\n * Tool definition for the session tool registry (built-in tools, SDK custom\n * tools, and the capability runtime's tool projection).\n */\nexport interface ToolDefinition<TParams extends TSchema = TSchema, TDetails = unknown, TState = unknown> {\n\t/** Tool name (used in LLM tool calls) */\n\tname: string;\n\t/** Human-readable label for UI */\n\tlabel: string;\n\t/** Description for LLM */\n\tdescription: string;\n\t/** Optional one-line snippet for the Available tools section in the default system prompt. Custom tools are omitted from that section when this is not provided. */\n\tpromptSnippet?: string;\n\t/** Optional guideline bullets appended to the default system prompt Guidelines section when this tool is active. */\n\tpromptGuidelines?: string[];\n\t/** Parameter schema (TypeBox) */\n\tparameters: TParams;\n\t/** Optional provider-side constrained sampling request for this tool. Set false to explicitly disable it, equivalent to leaving it undefined. */\n\tconstrainedSampling?: false | ConstrainedSamplingConfig;\n\t/** Controls whether ToolExecutionComponent renders the standard colored shell or the tool renders its own framing. */\n\trenderShell?: \"default\" | \"self\";\n\n\t/** Optional compatibility shim to prepare raw tool call arguments before schema validation. Must return an object conforming to TParams. */\n\tprepareArguments?: (args: unknown) => Static<TParams>;\n\n\t/**\n\t * Per-tool execution mode override.\n\t * - \"sequential\": this tool must execute one at a time with other tool calls.\n\t * - \"parallel\": this tool can execute concurrently with other tool calls.\n\t *\n\t * If omitted, the default execution mode applies.\n\t */\n\texecutionMode?: ToolExecutionMode;\n\n\t/**\n\t * Owning-plugin declaration (宪法 §6): this tool is explicitly safe for the\n\t * `readonly` capability mode. In readonly sessions the kernel keeps only\n\t * first-party (`agent-forge.builtin.*`) tools that declare it on the active\n\t * face; tools from external plugins keep their own semantics regardless.\n\t */\n\treadonlySafe?: boolean;\n\n\t/** Execute the tool. */\n\texecute(\n\t\ttoolCallId: string,\n\t\tparams: Static<TParams>,\n\t\tsignal: AbortSignal | undefined,\n\t\tonUpdate: AgentToolUpdateCallback<TDetails> | undefined,\n\t\tctx: ToolExecuteContext,\n\t): Promise<AgentToolResult<TDetails>>;\n\n\t/**\n\t * Custom rendering for tool call display. Method syntax keeps renderer assignability bivariant in TState.\n\t *\n\t * Hosting boundary: this face returns a host-side `Component`. First-party\n\t * builtin tools render through the `@agent-forge/tui` package; capability\n\t * plugins must NOT import that package (install-store distribution is\n\t * self-contained and cannot resolve workspace deps — a plugin doing this\n\t * fails to load in production while passing workspace-local tests). A\n\t * plugin that wants custom rendering implements the structural shape\n\t * (`{ render(width): string[]; invalidate?(): void }`) without the package,\n\t * or relies on the generic fallback preview.\n\t */\n\trenderCall?(args: Static<TParams>, theme: Theme, context: ToolRenderContext<TState, Static<TParams>>): Component;\n\n\t/**\n\t * Custom rendering for tool result display. Method syntax keeps renderer assignability bivariant in TState/TDetails.\n\t *\n\t * Same hosting boundary as `renderCall`: structural `Component`\n\t * implementations only for capability plugins; no `@agent-forge/tui` import\n\t * (see renderCall for the failure mode). The generic fallback (compact\n\t * single-line JSON preview with an expand hint) covers plugins without a\n\t * renderer.\n\t */\n\trenderResult?(\n\t\tresult: AgentToolResult<TDetails>,\n\t\toptions: ToolRenderResultOptions,\n\t\ttheme: Theme,\n\t\tcontext: ToolRenderContext<TState, Static<TParams>>,\n\t): Component;\n}\n\n/** Tool info with name, description, parameter schema, prompt guidelines, and source metadata. */\nexport type ToolInfo = Pick<ToolDefinition, \"name\" | \"description\" | \"parameters\" | \"promptGuidelines\"> & {\n\tsourceInfo: SourceInfo;\n};\n\ntype AnyToolDefinition = ToolDefinition;\n\n/**\n * Preserve parameter inference for standalone tool definitions.\n *\n * Use this when assigning a tool to a variable or passing it through arrays such\n * as `customTools`, where contextual typing would otherwise widen params to\n * `unknown`.\n */\nexport function defineTool<TParams extends TSchema, TDetails = unknown, TState = unknown>(\n\ttool: ToolDefinition<TParams, TDetails, TState>,\n): ToolDefinition<TParams, TDetails, TState> & AnyToolDefinition {\n\treturn tool as ToolDefinition<TParams, TDetails, TState> & AnyToolDefinition;\n}\n"]}
|