@ai-agent-forge/agent-forge 0.87.0 → 0.88.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/README.md +2 -2
- package/bundled-plugins/agent-loop-policy/agent-forge.json +19 -0
- package/bundled-plugins/agent-loop-policy/dist/entry.d.ts +28 -0
- package/bundled-plugins/agent-loop-policy/dist/entry.d.ts.map +1 -0
- package/bundled-plugins/agent-loop-policy/dist/entry.js +69 -0
- package/bundled-plugins/agent-loop-policy/dist/entry.js.map +1 -0
- package/bundled-plugins/agent-loop-policy/dist/loop-guard.d.ts +199 -0
- package/bundled-plugins/agent-loop-policy/dist/loop-guard.d.ts.map +1 -0
- package/bundled-plugins/agent-loop-policy/dist/loop-guard.js +208 -0
- package/bundled-plugins/agent-loop-policy/dist/loop-guard.js.map +1 -0
- package/bundled-plugins/agent-loop-policy/dist/run-loop-strategy.d.ts +17 -0
- package/bundled-plugins/agent-loop-policy/dist/run-loop-strategy.d.ts.map +1 -0
- package/bundled-plugins/agent-loop-policy/dist/run-loop-strategy.js +18 -0
- package/bundled-plugins/agent-loop-policy/dist/run-loop-strategy.js.map +1 -0
- package/bundled-plugins/agent-loop-policy/plugin.json +7 -0
- package/bundled-plugins/coding-tools/agent-forge.json +19 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/bash.d.ts +5 -44
- package/bundled-plugins/coding-tools/dist/bash.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/bash.js +15 -119
- package/bundled-plugins/coding-tools/dist/bash.js.map +1 -0
- package/bundled-plugins/coding-tools/dist/capability.d.ts +25 -0
- package/bundled-plugins/coding-tools/dist/capability.d.ts.map +1 -0
- package/bundled-plugins/coding-tools/dist/capability.js +98 -0
- package/bundled-plugins/coding-tools/dist/capability.js.map +1 -0
- package/bundled-plugins/coding-tools/dist/config.d.ts +8 -0
- package/bundled-plugins/coding-tools/dist/config.d.ts.map +1 -0
- package/bundled-plugins/coding-tools/dist/config.js +8 -0
- package/bundled-plugins/coding-tools/dist/config.js.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/edit.d.ts +3 -3
- package/bundled-plugins/coding-tools/dist/edit.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/edit.js +12 -10
- package/bundled-plugins/coding-tools/dist/edit.js.map +1 -0
- package/bundled-plugins/coding-tools/dist/entry.d.ts +14 -0
- package/bundled-plugins/coding-tools/dist/entry.d.ts.map +1 -0
- package/bundled-plugins/coding-tools/dist/entry.js +23 -0
- package/bundled-plugins/coding-tools/dist/entry.js.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/find.d.ts +4 -4
- package/bundled-plugins/coding-tools/dist/find.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/find.js +10 -8
- package/bundled-plugins/coding-tools/dist/find.js.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/grep.d.ts +3 -3
- package/bundled-plugins/coding-tools/dist/grep.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/grep.js +10 -8
- package/bundled-plugins/coding-tools/dist/grep.js.map +1 -0
- package/bundled-plugins/coding-tools/dist/index.d.ts +17 -0
- package/bundled-plugins/coding-tools/dist/index.d.ts.map +1 -0
- package/bundled-plugins/coding-tools/dist/index.js +17 -0
- package/bundled-plugins/coding-tools/dist/index.js.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/ls.d.ts +3 -3
- package/bundled-plugins/coding-tools/dist/ls.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/ls.js +8 -6
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/ls.js.map +1 -1
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/powershell.d.ts +2 -1
- package/bundled-plugins/coding-tools/dist/powershell.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/powershell.js +6 -3
- package/bundled-plugins/coding-tools/dist/powershell.js.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/read.d.ts +3 -3
- package/bundled-plugins/coding-tools/dist/read.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/read.js +15 -13
- package/bundled-plugins/coding-tools/dist/read.js.map +1 -0
- package/bundled-plugins/coding-tools/dist/types.d.ts +74 -0
- package/bundled-plugins/coding-tools/dist/types.d.ts.map +1 -0
- package/bundled-plugins/coding-tools/dist/types.js +28 -0
- package/bundled-plugins/coding-tools/dist/types.js.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/write.d.ts +2 -2
- package/bundled-plugins/coding-tools/dist/write.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/write.js +11 -9
- package/bundled-plugins/coding-tools/dist/write.js.map +1 -0
- package/bundled-plugins/coding-tools/plugin.json +10 -0
- package/bundled-plugins/compaction-policy/agent-forge.json +19 -0
- package/bundled-plugins/compaction-policy/dist/branch-summary-policy.d.ts +6 -0
- package/bundled-plugins/compaction-policy/dist/branch-summary-policy.d.ts.map +1 -0
- package/bundled-plugins/compaction-policy/dist/branch-summary-policy.js +19 -0
- package/bundled-plugins/compaction-policy/dist/branch-summary-policy.js.map +1 -0
- package/bundled-plugins/compaction-policy/dist/compaction-policy.d.ts +6 -0
- package/bundled-plugins/compaction-policy/dist/compaction-policy.d.ts.map +1 -0
- package/bundled-plugins/compaction-policy/dist/compaction-policy.js +38 -0
- package/bundled-plugins/compaction-policy/dist/compaction-policy.js.map +1 -0
- package/bundled-plugins/compaction-policy/dist/entry.d.ts +13 -0
- package/bundled-plugins/compaction-policy/dist/entry.d.ts.map +1 -0
- package/bundled-plugins/compaction-policy/dist/entry.js +23 -0
- package/bundled-plugins/compaction-policy/dist/entry.js.map +1 -0
- package/bundled-plugins/compaction-policy/plugin.json +10 -0
- package/bundled-plugins/mcp-http/dist/index.d.ts +8 -0
- package/bundled-plugins/mcp-http/dist/index.d.ts.map +1 -0
- package/bundled-plugins/mcp-http/dist/index.js +8 -0
- package/bundled-plugins/mcp-http/dist/index.js.map +1 -0
- package/bundled-plugins/mcp-http/dist/mcp-http.d.ts.map +1 -0
- package/{dist/plugins → bundled-plugins/mcp-http/dist}/mcp-http.js +1 -1
- package/bundled-plugins/mcp-http/dist/mcp-http.js.map +1 -0
- package/bundled-plugins/overflow-policy/agent-forge.json +19 -0
- package/bundled-plugins/overflow-policy/dist/entry.d.ts +16 -0
- package/bundled-plugins/overflow-policy/dist/entry.d.ts.map +1 -0
- package/bundled-plugins/overflow-policy/dist/entry.js +35 -0
- package/bundled-plugins/overflow-policy/dist/entry.js.map +1 -0
- package/bundled-plugins/overflow-policy/plugin.json +10 -0
- package/bundled-plugins/provider-failover/agent-forge.json +19 -0
- package/bundled-plugins/provider-failover/dist/entry.d.ts +8 -0
- package/bundled-plugins/provider-failover/dist/entry.d.ts.map +1 -0
- package/bundled-plugins/provider-failover/dist/entry.js +8 -0
- package/bundled-plugins/provider-failover/dist/entry.js.map +1 -0
- package/bundled-plugins/provider-failover/dist/provider-failover.d.ts +122 -0
- package/bundled-plugins/provider-failover/dist/provider-failover.d.ts.map +1 -0
- package/{dist/core/extensions → bundled-plugins/provider-failover/dist}/provider-failover.js +149 -61
- package/bundled-plugins/provider-failover/dist/provider-failover.js.map +1 -0
- package/bundled-plugins/provider-failover/plugin.json +7 -0
- package/bundled-plugins/retry-policy/agent-forge.json +19 -0
- package/bundled-plugins/retry-policy/dist/entry.d.ts +16 -0
- package/bundled-plugins/retry-policy/dist/entry.d.ts.map +1 -0
- package/bundled-plugins/retry-policy/dist/entry.js +34 -0
- package/bundled-plugins/retry-policy/dist/entry.js.map +1 -0
- package/bundled-plugins/retry-policy/plugin.json +10 -0
- package/dist/bundle/.build-manifest.json +105 -183
- package/dist/bundle/chunks/{anthropic-messages-ALDZBUKI.js → anthropic-messages-PLAKXR73.js} +1 -1
- package/dist/bundle/chunks/{azure-openai-responses-A2WJWZFB.js → azure-openai-responses-OUWQ2AZD.js} +1 -1
- package/dist/bundle/chunks/{chunk-CIX3FSBK.js → chunk-A3JYRWB6.js} +1 -1
- package/dist/bundle/chunks/{chunk-SQFG22WN.js → chunk-AC2FIS4G.js} +1 -1
- package/dist/bundle/chunks/chunk-AQLNTW2B.js +664 -0
- package/dist/bundle/chunks/chunk-D3ARGZFR.js +13 -0
- package/dist/bundle/chunks/{chunk-YJCQVXW5.js → chunk-HTEVUY7F.js} +1 -1
- package/dist/bundle/chunks/{chunk-Y7HXTASS.js → chunk-HV64ASMT.js} +1 -1
- package/dist/bundle/chunks/chunk-LZOEQITZ.js +855 -0
- package/dist/bundle/chunks/{chunk-7ZY7IXZD.js → chunk-TRDNDS6A.js} +1 -1
- package/dist/bundle/chunks/chunk-Z72JWUZ4.js +4 -0
- package/dist/bundle/chunks/{google-generative-ai-NIB4WONV.js → google-generative-ai-DLII6DAT.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-DCPYUEUO.js → google-vertex-G7BZL7GM.js} +1 -1
- package/dist/bundle/chunks/image-resize-worker.js +3 -3
- package/dist/bundle/chunks/{mistral-conversations-OC6LA5XL.js → mistral-conversations-JXUK24ID.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-IO2X4Y7L.js → openai-codex-responses-5GSGFIPG.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-XYQQHETU.js → openai-completions-EI2I6DTG.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-DLIRN3CI.js → openai-responses-AUJQ3NWT.js} +1 -1
- package/dist/bundle/chunks/{pi-messages-E6RRYBO7.js → pi-messages-PWU2VJMR.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-WF6WRHP7.js +5 -0
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/client.js +1 -1
- package/dist/bundle/index.js +3 -3
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/capabilities/builtin.d.ts +1 -1
- package/dist/capabilities/builtin.d.ts.map +1 -1
- package/dist/capabilities/builtin.js +5 -0
- package/dist/capabilities/builtin.js.map +1 -1
- package/dist/cli/auth-check.d.ts.map +1 -1
- package/dist/cli/auth-check.js +14 -2
- package/dist/cli/auth-check.js.map +1 -1
- package/dist/cli/auth-command.d.ts.map +1 -1
- package/dist/cli/auth-command.js +1 -1
- package/dist/cli/auth-command.js.map +1 -1
- package/dist/cli/plugin-command.d.ts.map +1 -1
- package/dist/cli/plugin-command.js +17 -1
- package/dist/cli/plugin-command.js.map +1 -1
- package/dist/config.d.ts +2 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -6
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts +1 -1
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +1 -1
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts +6 -10
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +21 -112
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-internal.d.ts +1 -7
- package/dist/core/agent-session-internal.d.ts.map +1 -1
- package/dist/core/agent-session-internal.js.map +1 -1
- package/dist/core/agent-session-loop.d.ts +4 -3
- package/dist/core/agent-session-loop.d.ts.map +1 -1
- package/dist/core/agent-session-loop.js +9 -6
- package/dist/core/agent-session-loop.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts +1 -1
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +32 -4
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +30 -9
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-tools.d.ts.map +1 -1
- package/dist/core/agent-session-tools.js +5 -1
- package/dist/core/agent-session-tools.js.map +1 -1
- package/dist/core/agent-session.d.ts +12 -33
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +61 -67
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/extensions/bootstrap-agent-loop.d.ts +23 -151
- package/dist/core/extensions/bootstrap-agent-loop.d.ts.map +1 -1
- package/dist/core/extensions/bootstrap-agent-loop.js +28 -290
- package/dist/core/extensions/bootstrap-agent-loop.js.map +1 -1
- package/dist/core/extensions/capability-runtime-types.d.ts +5 -3
- package/dist/core/extensions/capability-runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/capability-runtime-types.js.map +1 -1
- package/dist/core/extensions/capability-runtime.d.ts.map +1 -1
- package/dist/core/extensions/capability-runtime.js +42 -6
- package/dist/core/extensions/capability-runtime.js.map +1 -1
- package/dist/core/extensions/index.d.ts +12 -5
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +12 -5
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/virtual-modules.js +65 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -1
- package/dist/core/facade/coding-agent-facade.d.ts +1 -7
- package/dist/core/facade/coding-agent-facade.d.ts.map +1 -1
- package/dist/core/facade/coding-agent-facade.js +0 -3
- package/dist/core/facade/coding-agent-facade.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/cli.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/cli.js +3 -1
- package/dist/core/i18n/locales/zh-cn/cli.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-core.d.ts +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-core.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-core.js +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-core.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-extensions.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-extensions.js +2 -4
- package/dist/core/i18n/locales/zh-cn/core-contract-extensions.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-errors.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-errors.js +3 -1
- package/dist/core/i18n/locales/zh-cn/core-errors.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/interactive-mode.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/interactive-mode.js +2 -0
- package/dist/core/i18n/locales/zh-cn/interactive-mode.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/tui-components-selectors.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/tui-components-selectors.js +0 -2
- package/dist/core/i18n/locales/zh-cn/tui-components-selectors.js.map +1 -1
- package/dist/core/model-config.d.ts +0 -1
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +9 -1
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +3 -3
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/provider-composer.d.ts +2 -2
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +7 -8
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/sdk.d.ts +18 -3
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +267 -76
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager.d.ts +9 -20
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +20 -54
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/tools/bash-operations.d.ts +41 -0
- package/dist/core/tools/bash-operations.d.ts.map +1 -0
- package/dist/core/tools/bash-operations.js +113 -0
- package/dist/core/tools/bash-operations.js.map +1 -0
- package/dist/core/tools/index.d.ts +12 -36
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +1 -117
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/readme-path.d.ts +3 -0
- package/dist/core/tools/readme-path.d.ts.map +1 -0
- package/dist/core/tools/readme-path.js +15 -0
- package/dist/core/tools/readme-path.js.map +1 -0
- package/dist/index.d.ts +3 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -39
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +3 -2
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +0 -2
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +2 -7
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +2 -6
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +6 -28
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +0 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +9 -25
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +0 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +23 -36
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +0 -8
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +0 -12
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +0 -9
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +0 -19
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/plugins/ecosystem/cli.d.ts.map +1 -1
- package/dist/plugins/ecosystem/cli.js +14 -2
- package/dist/plugins/ecosystem/cli.js.map +1 -1
- package/dist/plugins/ecosystem/node-npm-registry-source.d.ts +7 -2
- package/dist/plugins/ecosystem/node-npm-registry-source.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-npm-registry-source.js +64 -9
- package/dist/plugins/ecosystem/node-npm-registry-source.js.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-acquisition-host.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-acquisition-host.js +6 -0
- package/dist/plugins/ecosystem/node-plugin-acquisition-host.js.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts +9 -2
- package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-bootstrap.js +23 -0
- package/dist/plugins/ecosystem/node-plugin-bootstrap.js.map +1 -1
- package/dist/plugins/ecosystem/plugin-bootstrap.d.ts +9 -1
- package/dist/plugins/ecosystem/plugin-bootstrap.d.ts.map +1 -1
- package/dist/plugins/ecosystem/plugin-bootstrap.js +5 -0
- package/dist/plugins/ecosystem/plugin-bootstrap.js.map +1 -1
- package/dist/profiles/builtin-suites.d.ts +5 -1
- package/dist/profiles/builtin-suites.d.ts.map +1 -1
- package/dist/profiles/builtin-suites.js +6 -1
- package/dist/profiles/builtin-suites.js.map +1 -1
- package/dist/utils/photon.d.ts +2 -2
- package/dist/utils/photon.d.ts.map +1 -1
- package/dist/utils/photon.js +2 -2
- package/dist/utils/photon.js.map +1 -1
- package/docs/compaction.md +1 -3
- package/docs/docs.json +4 -0
- package/docs/index.md +1 -0
- package/docs/mcp.md +103 -0
- package/docs/models.md +14 -22
- package/docs/providers.md +0 -1
- package/docs/rpc.md +1 -26
- package/docs/sdk.md +4 -6
- package/docs/settings.md +9 -12
- package/docs/skills.md +1 -9
- package/docs/usage.md +1 -1
- package/examples/extensions/bash-spawn-hook/index.ts +7 -2
- package/examples/extensions/built-in-tool-renderer/index.ts +4 -2
- package/examples/extensions/minimal-mode/index.ts +2 -2
- package/examples/extensions/truncated-tool/index.ts +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/extensions/with-deps/plugin.json +1 -1
- package/examples/sdk/10-settings.ts +2 -4
- package/examples/sdk/12-full-control.ts +1 -2
- package/package.json +3 -4
- package/dist/bundle/chunks/chunk-6ZKDNZHA.js +0 -145
- package/dist/bundle/chunks/chunk-BFC2BDVJ.js +0 -13
- package/dist/bundle/chunks/chunk-MOHOLL3F.js +0 -1456
- package/dist/bundle/chunks/virtual-modules-KZ5DRH7Q.js +0 -2
- package/dist/core/extensions/bootstrap-branch-summary-policy.d.ts +0 -7
- package/dist/core/extensions/bootstrap-branch-summary-policy.d.ts.map +0 -1
- package/dist/core/extensions/bootstrap-branch-summary-policy.js +0 -28
- package/dist/core/extensions/bootstrap-branch-summary-policy.js.map +0 -1
- package/dist/core/extensions/bootstrap-compaction-policy.d.ts +0 -7
- package/dist/core/extensions/bootstrap-compaction-policy.d.ts.map +0 -1
- package/dist/core/extensions/bootstrap-compaction-policy.js +0 -82
- package/dist/core/extensions/bootstrap-compaction-policy.js.map +0 -1
- package/dist/core/extensions/bootstrap-overflow-policy.d.ts +0 -7
- package/dist/core/extensions/bootstrap-overflow-policy.d.ts.map +0 -1
- package/dist/core/extensions/bootstrap-overflow-policy.js +0 -30
- package/dist/core/extensions/bootstrap-overflow-policy.js.map +0 -1
- package/dist/core/extensions/bootstrap-retry-policy.d.ts +0 -7
- package/dist/core/extensions/bootstrap-retry-policy.d.ts.map +0 -1
- package/dist/core/extensions/bootstrap-retry-policy.js +0 -29
- package/dist/core/extensions/bootstrap-retry-policy.js.map +0 -1
- package/dist/core/extensions/bootstrap-tools.d.ts +0 -20
- package/dist/core/extensions/bootstrap-tools.d.ts.map +0 -1
- package/dist/core/extensions/bootstrap-tools.js +0 -36
- package/dist/core/extensions/bootstrap-tools.js.map +0 -1
- package/dist/core/extensions/microcompact.d.ts +0 -80
- package/dist/core/extensions/microcompact.d.ts.map +0 -1
- package/dist/core/extensions/microcompact.js +0 -134
- package/dist/core/extensions/microcompact.js.map +0 -1
- package/dist/core/extensions/provider-failover.d.ts +0 -106
- package/dist/core/extensions/provider-failover.d.ts.map +0 -1
- package/dist/core/extensions/provider-failover.js.map +0 -1
- package/dist/core/tools/bash.d.ts.map +0 -1
- package/dist/core/tools/bash.js.map +0 -1
- package/dist/core/tools/edit.d.ts.map +0 -1
- package/dist/core/tools/edit.js.map +0 -1
- package/dist/core/tools/find.d.ts.map +0 -1
- package/dist/core/tools/find.js.map +0 -1
- package/dist/core/tools/grep.d.ts.map +0 -1
- package/dist/core/tools/grep.js.map +0 -1
- package/dist/core/tools/ls.d.ts.map +0 -1
- package/dist/core/tools/powershell.d.ts.map +0 -1
- package/dist/core/tools/powershell.js.map +0 -1
- package/dist/core/tools/read.d.ts.map +0 -1
- package/dist/core/tools/read.js.map +0 -1
- package/dist/core/tools/write.d.ts.map +0 -1
- package/dist/core/tools/write.js.map +0 -1
- package/dist/plugins/mcp-http.d.ts.map +0 -1
- package/dist/plugins/mcp-http.js.map +0 -1
- package/dist/profile/child-facade.d.ts +0 -44
- package/dist/profile/child-facade.d.ts.map +0 -1
- package/dist/profile/child-facade.js +0 -56
- package/dist/profile/child-facade.js.map +0 -1
- package/dist/profile/dependency-wiring.d.ts +0 -48
- package/dist/profile/dependency-wiring.d.ts.map +0 -1
- package/dist/profile/dependency-wiring.js +0 -56
- package/dist/profile/dependency-wiring.js.map +0 -1
- package/dist/profile/domain-recovery.d.ts +0 -60
- package/dist/profile/domain-recovery.d.ts.map +0 -1
- package/dist/profile/domain-recovery.js +0 -94
- package/dist/profile/domain-recovery.js.map +0 -1
- package/dist/profile/first-roles.d.ts +0 -30
- package/dist/profile/first-roles.d.ts.map +0 -1
- package/dist/profile/first-roles.js +0 -83
- package/dist/profile/first-roles.js.map +0 -1
- package/dist/profile/goal-plugin.d.ts +0 -38
- package/dist/profile/goal-plugin.d.ts.map +0 -1
- package/dist/profile/goal-plugin.js +0 -132
- package/dist/profile/goal-plugin.js.map +0 -1
- package/dist/profile/plan-plugin.d.ts +0 -44
- package/dist/profile/plan-plugin.d.ts.map +0 -1
- package/dist/profile/plan-plugin.js +0 -157
- package/dist/profile/plan-plugin.js.map +0 -1
- package/dist/profile/policy-manifest.d.ts +0 -53
- package/dist/profile/policy-manifest.d.ts.map +0 -1
- package/dist/profile/policy-manifest.js +0 -53
- package/dist/profile/policy-manifest.js.map +0 -1
- package/dist/profile/role-assembly.d.ts +0 -47
- package/dist/profile/role-assembly.d.ts.map +0 -1
- package/dist/profile/role-assembly.js +0 -31
- package/dist/profile/role-assembly.js.map +0 -1
- package/dist/profile/role-catalog.d.ts +0 -43
- package/dist/profile/role-catalog.d.ts.map +0 -1
- package/dist/profile/role-catalog.js +0 -132
- package/dist/profile/role-catalog.js.map +0 -1
- package/dist/profile/role-orchestrator.d.ts +0 -123
- package/dist/profile/role-orchestrator.d.ts.map +0 -1
- package/dist/profile/role-orchestrator.js +0 -195
- package/dist/profile/role-orchestrator.js.map +0 -1
- package/dist/profile/role-runner.d.ts +0 -99
- package/dist/profile/role-runner.d.ts.map +0 -1
- package/dist/profile/role-runner.js +0 -79
- package/dist/profile/role-runner.js.map +0 -1
- package/dist/profile/root-facade.d.ts +0 -36
- package/dist/profile/root-facade.d.ts.map +0 -1
- package/dist/profile/root-facade.js +0 -49
- package/dist/profile/root-facade.js.map +0 -1
- package/dist/profile/skill-discovery-wiring.d.ts +0 -58
- package/dist/profile/skill-discovery-wiring.d.ts.map +0 -1
- package/dist/profile/skill-discovery-wiring.js +0 -80
- package/dist/profile/skill-discovery-wiring.js.map +0 -1
- package/dist/profile/state-store.d.ts +0 -62
- package/dist/profile/state-store.d.ts.map +0 -1
- package/dist/profile/state-store.js +0 -144
- package/dist/profile/state-store.js.map +0 -1
- package/dist/profile/todo-plugin.d.ts +0 -37
- package/dist/profile/todo-plugin.d.ts.map +0 -1
- package/dist/profile/todo-plugin.js +0 -137
- package/dist/profile/todo-plugin.js.map +0 -1
- package/dist/server/create-harness.d.ts +0 -26
- package/dist/server/create-harness.d.ts.map +0 -1
- package/dist/server/create-harness.js +0 -106
- package/dist/server/create-harness.js.map +0 -1
- /package/{dist/plugins → bundled-plugins/mcp-http/dist}/mcp-http.d.ts +0 -0
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import{build_exports,dist_exports,require_undici,session_lineage_exports,subagent_exports,value_exports2 as value_exports}from"./chunk-6ZKDNZHA.js";import{__toESM}from"./chunk-4L3WN2XY.js";var undici=__toESM(require_undici(),1),VIRTUAL_MODULES={"@agent-forge/plugin-sdk":dist_exports,"@agent-forge/plugin-sdk/session-lineage":session_lineage_exports,"@agent-forge/protocol/subagent":subagent_exports,typebox:build_exports,"typebox/value":value_exports,undici};export{VIRTUAL_MODULES};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type CapabilityPluginHandle } from "./capability-plugin.ts";
|
|
2
|
-
import type { CapabilityRuntime } from "./capability-runtime.ts";
|
|
3
|
-
export declare const BOOTSTRAP_BRANCH_SUMMARY_PLUGIN_ID = "agent-forge.bootstrap-branch-summary";
|
|
4
|
-
export declare const DEFAULT_BRANCH_SUMMARY_POLICY_NAME = "default";
|
|
5
|
-
/** First-party adapter that keeps the legacy branch summarizer replaceable. */
|
|
6
|
-
export declare function installBootstrapBranchSummaryPolicy(runtime: CapabilityRuntime): CapabilityPluginHandle;
|
|
7
|
-
//# sourceMappingURL=bootstrap-branch-summary-policy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap-branch-summary-policy.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/bootstrap-branch-summary-policy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,sBAAsB,EAA4B,MAAM,wBAAwB,CAAC;AAC/F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAGjE,eAAO,MAAM,kCAAkC,yCAAyC,CAAC;AACzF,eAAO,MAAM,kCAAkC,YAAY,CAAC;AAE5D,+EAA+E;AAC/E,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,iBAAiB,GAAG,sBAAsB,CAwBtG","sourcesContent":["import { generateBranchSummary } from \"../compaction/branch-summarization.ts\";\nimport { type CapabilityPluginHandle, loadCapabilityPluginSync } from \"./capability-plugin.ts\";\nimport type { CapabilityRuntime } from \"./capability-runtime.ts\";\nimport { type BranchSummaryRequest, EXPERIMENTAL_PUBLIC_API_VERSION } from \"./public-api.ts\";\n\nexport const BOOTSTRAP_BRANCH_SUMMARY_PLUGIN_ID = \"agent-forge.bootstrap-branch-summary\";\nexport const DEFAULT_BRANCH_SUMMARY_POLICY_NAME = \"default\";\n\n/** First-party adapter that keeps the legacy branch summarizer replaceable. */\nexport function installBootstrapBranchSummaryPolicy(runtime: CapabilityRuntime): CapabilityPluginHandle {\n\treturn loadCapabilityPluginSync(\n\t\truntime,\n\t\t{\n\t\t\tid: BOOTSTRAP_BRANCH_SUMMARY_PLUGIN_ID,\n\t\t\tversion: \"1.0.0\",\n\t\t\tapiVersion: EXPERIMENTAL_PUBLIC_API_VERSION,\n\t\t\tentry: \"<bootstrap>\",\n\t\t},\n\t\t(api) => {\n\t\t\tapi.registerBranchSummaryPolicy(DEFAULT_BRANCH_SUMMARY_POLICY_NAME, {\n\t\t\t\tasync summarize(request: BranchSummaryRequest) {\n\t\t\t\t\treturn generateBranchSummary(request.entries as Parameters<typeof generateBranchSummary>[0], {\n\t\t\t\t\t\tinvocation: request.invocation,\n\t\t\t\t\t\tmodel: request.model,\n\t\t\t\t\t\tsignal: request.signal,\n\t\t\t\t\t\tcustomInstructions: request.customInstructions,\n\t\t\t\t\t\treplaceInstructions: request.replaceInstructions,\n\t\t\t\t\t\treserveTokens: request.reserveTokens,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t);\n}\n"]}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { generateBranchSummary } from "../compaction/branch-summarization.js";
|
|
2
|
-
import { loadCapabilityPluginSync } from "./capability-plugin.js";
|
|
3
|
-
import { EXPERIMENTAL_PUBLIC_API_VERSION } from "./public-api.js";
|
|
4
|
-
export const BOOTSTRAP_BRANCH_SUMMARY_PLUGIN_ID = "agent-forge.bootstrap-branch-summary";
|
|
5
|
-
export const DEFAULT_BRANCH_SUMMARY_POLICY_NAME = "default";
|
|
6
|
-
/** First-party adapter that keeps the legacy branch summarizer replaceable. */
|
|
7
|
-
export function installBootstrapBranchSummaryPolicy(runtime) {
|
|
8
|
-
return loadCapabilityPluginSync(runtime, {
|
|
9
|
-
id: BOOTSTRAP_BRANCH_SUMMARY_PLUGIN_ID,
|
|
10
|
-
version: "1.0.0",
|
|
11
|
-
apiVersion: EXPERIMENTAL_PUBLIC_API_VERSION,
|
|
12
|
-
entry: "<bootstrap>",
|
|
13
|
-
}, (api) => {
|
|
14
|
-
api.registerBranchSummaryPolicy(DEFAULT_BRANCH_SUMMARY_POLICY_NAME, {
|
|
15
|
-
async summarize(request) {
|
|
16
|
-
return generateBranchSummary(request.entries, {
|
|
17
|
-
invocation: request.invocation,
|
|
18
|
-
model: request.model,
|
|
19
|
-
signal: request.signal,
|
|
20
|
-
customInstructions: request.customInstructions,
|
|
21
|
-
replaceInstructions: request.replaceInstructions,
|
|
22
|
-
reserveTokens: request.reserveTokens,
|
|
23
|
-
});
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=bootstrap-branch-summary-policy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap-branch-summary-policy.js","sourceRoot":"","sources":["../../../src/core/extensions/bootstrap-branch-summary-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAA+B,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAE/F,OAAO,EAA6B,+BAA+B,EAAE,MAAM,iBAAiB,CAAC;AAE7F,MAAM,CAAC,MAAM,kCAAkC,GAAG,sCAAsC,CAAC;AACzF,MAAM,CAAC,MAAM,kCAAkC,GAAG,SAAS,CAAC;AAE5D,+EAA+E;AAC/E,MAAM,UAAU,mCAAmC,CAAC,OAA0B,EAA0B;IACvG,OAAO,wBAAwB,CAC9B,OAAO,EACP;QACC,EAAE,EAAE,kCAAkC;QACtC,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,+BAA+B;QAC3C,KAAK,EAAE,aAAa;KACpB,EACD,CAAC,GAAG,EAAE,EAAE,CAAC;QACR,GAAG,CAAC,2BAA2B,CAAC,kCAAkC,EAAE;YACnE,KAAK,CAAC,SAAS,CAAC,OAA6B,EAAE;gBAC9C,OAAO,qBAAqB,CAAC,OAAO,CAAC,OAAsD,EAAE;oBAC5F,UAAU,EAAE,OAAO,CAAC,UAAU;oBAC9B,KAAK,EAAE,OAAO,CAAC,KAAK;oBACpB,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;oBAC9C,mBAAmB,EAAE,OAAO,CAAC,mBAAmB;oBAChD,aAAa,EAAE,OAAO,CAAC,aAAa;iBACpC,CAAC,CAAC;YAAA,CACH;SACD,CAAC,CAAC;IAAA,CACH,CACD,CAAC;AAAA,CACF","sourcesContent":["import { generateBranchSummary } from \"../compaction/branch-summarization.ts\";\nimport { type CapabilityPluginHandle, loadCapabilityPluginSync } from \"./capability-plugin.ts\";\nimport type { CapabilityRuntime } from \"./capability-runtime.ts\";\nimport { type BranchSummaryRequest, EXPERIMENTAL_PUBLIC_API_VERSION } from \"./public-api.ts\";\n\nexport const BOOTSTRAP_BRANCH_SUMMARY_PLUGIN_ID = \"agent-forge.bootstrap-branch-summary\";\nexport const DEFAULT_BRANCH_SUMMARY_POLICY_NAME = \"default\";\n\n/** First-party adapter that keeps the legacy branch summarizer replaceable. */\nexport function installBootstrapBranchSummaryPolicy(runtime: CapabilityRuntime): CapabilityPluginHandle {\n\treturn loadCapabilityPluginSync(\n\t\truntime,\n\t\t{\n\t\t\tid: BOOTSTRAP_BRANCH_SUMMARY_PLUGIN_ID,\n\t\t\tversion: \"1.0.0\",\n\t\t\tapiVersion: EXPERIMENTAL_PUBLIC_API_VERSION,\n\t\t\tentry: \"<bootstrap>\",\n\t\t},\n\t\t(api) => {\n\t\t\tapi.registerBranchSummaryPolicy(DEFAULT_BRANCH_SUMMARY_POLICY_NAME, {\n\t\t\t\tasync summarize(request: BranchSummaryRequest) {\n\t\t\t\t\treturn generateBranchSummary(request.entries as Parameters<typeof generateBranchSummary>[0], {\n\t\t\t\t\t\tinvocation: request.invocation,\n\t\t\t\t\t\tmodel: request.model,\n\t\t\t\t\t\tsignal: request.signal,\n\t\t\t\t\t\tcustomInstructions: request.customInstructions,\n\t\t\t\t\t\treplaceInstructions: request.replaceInstructions,\n\t\t\t\t\t\treserveTokens: request.reserveTokens,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t);\n}\n"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type CapabilityPluginHandle } from "./capability-plugin.ts";
|
|
2
|
-
import type { CapabilityRuntime } from "./capability-runtime.ts";
|
|
3
|
-
export declare const BOOTSTRAP_COMPACTION_PLUGIN_ID = "agent-forge.bootstrap-compaction";
|
|
4
|
-
export declare const DEFAULT_COMPACTION_POLICY_NAME = "default";
|
|
5
|
-
/** Register the current automatic-compaction decision as a replaceable first-party policy. */
|
|
6
|
-
export declare function installBootstrapCompactionPolicy(runtime: CapabilityRuntime): CapabilityPluginHandle;
|
|
7
|
-
//# sourceMappingURL=bootstrap-compaction-policy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap-compaction-policy.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/bootstrap-compaction-policy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,sBAAsB,EAA4B,MAAM,wBAAwB,CAAC;AAC/F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAUjE,eAAO,MAAM,8BAA8B,qCAAqC,CAAC;AACjF,eAAO,MAAM,8BAA8B,YAAY,CAAC;AASxD,8FAA8F;AAC9F,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,iBAAiB,GAAG,sBAAsB,CAkFnG","sourcesContent":["import { type CompactionPreparation, compact, prepareCompaction } from \"../compaction/index.ts\";\nimport { type CapabilityPluginHandle, loadCapabilityPluginSync } from \"./capability-plugin.ts\";\nimport type { CapabilityRuntime } from \"./capability-runtime.ts\";\nimport {\n\tapplyMicrocompactElision,\n\tDEFAULT_MIN_ELIDE_CHARS,\n\tMICROCOMPACT_CUSTOM_TYPE,\n\tplanMicrocompact,\n} from \"./microcompact.ts\";\nimport type { CompactionPolicyRequest, CompactionSummaryRequest } from \"./public-api.ts\";\nimport { EXPERIMENTAL_PUBLIC_API_VERSION } from \"./public-api.ts\";\n\nexport const BOOTSTRAP_COMPACTION_PLUGIN_ID = \"agent-forge.bootstrap-compaction\";\nexport const DEFAULT_COMPACTION_POLICY_NAME = \"default\";\n\n/**\n * 会话宿主经 threshold decide 请求透传的 microcompact 门控事实(settings 的\n * `compaction.microcompactEnabled` 与会话冷却的合取)。请求缺省视为 false,\n * 与 2026-10-01 默认值裁决一致:relief 为 opt-in experimental。\n */\ntype DecisionRequestWithMicrocompact = CompactionPolicyRequest & { microcompactEnabled?: boolean };\n\n/** Register the current automatic-compaction decision as a replaceable first-party policy. */\nexport function installBootstrapCompactionPolicy(runtime: CapabilityRuntime): CapabilityPluginHandle {\n\treturn loadCapabilityPluginSync(\n\t\truntime,\n\t\t{\n\t\t\tid: BOOTSTRAP_COMPACTION_PLUGIN_ID,\n\t\t\tversion: \"0.0.0\",\n\t\t\tapiVersion: EXPERIMENTAL_PUBLIC_API_VERSION,\n\t\t\tentry: \"<embedded:bootstrap-compaction>\",\n\t\t\trequiredCapabilities: [\"compaction-policy\"],\n\t\t},\n\t\t(api) => {\n\t\t\t// Microcompact 投影(宪法 §4/§5):经公共 registerEntryProjection 通道\n\t\t\t// 注册——内核按注册顺序应用投影、不解释语义;第三方上下文策略走同一\n\t\t\t// 通道。策略被禁用/替换时,本投影随插件卸载一并消失。\n\t\t\tapi.registerEntryProjection({\n\t\t\t\tcustomType: MICROCOMPACT_CUSTOM_TYPE,\n\t\t\t\tproject: (entries) => applyMicrocompactElision(entries as never) as never,\n\t\t\t});\n\t\t\tapi.registerCompactionPolicy(DEFAULT_COMPACTION_POLICY_NAME, {\n\t\t\t\tprepare: (request) =>\n\t\t\t\t\tprepareCompaction(\n\t\t\t\t\t\trequest.entries as Parameters<typeof prepareCompaction>[0],\n\t\t\t\t\t\trequest.settings as Parameters<typeof prepareCompaction>[1],\n\t\t\t\t\t),\n\t\t\t\tdecide: (request) => {\n\t\t\t\t\tif (!request.enabled) return { compact: false };\n\t\t\t\t\tif (request.reason === \"threshold\") {\n\t\t\t\t\t\tconst usage = request.contextUsage;\n\t\t\t\t\t\tconst overBudget =\n\t\t\t\t\t\t\tusage !== undefined &&\n\t\t\t\t\t\t\tusage.contextWindow > 0 &&\n\t\t\t\t\t\t\tusage.contextTokens > usage.contextWindow - usage.reserveTokens;\n\t\t\t\t\t\t// 便宜缓解优先(microcompact):阈值命中先尝试零成本的本地\n\t\t\t\t\t\t// 变换——把老的粗大 tool result 从模型可见上下文中替换为占位\n\t\t\t\t\t\t// 符——释放达标则以 relief 条目落地并跳过 LLM 摘要;不足则照常\n\t\t\t\t\t\t// 走全量压缩。条目语义完全属于本策略,投影也由本策略注册。\n\t\t\t\t\t\t// 宿主在设置关闭或会话冷却期内传 microcompactEnabled:false,\n\t\t\t\t\t\t// planMicrocompact 据此拒绝规划,自然落到下方全量压缩分支。\n\t\t\t\t\t\tif (overBudget && request.branchEntries !== undefined) {\n\t\t\t\t\t\t\tconst plan = planMicrocompact(request.branchEntries as Parameters<typeof planMicrocompact>[0], {\n\t\t\t\t\t\t\t\tenabled: (request as DecisionRequestWithMicrocompact).microcompactEnabled === true,\n\t\t\t\t\t\t\t\tkeepRecentTokens: request.keepRecentTokens ?? 0,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (plan) {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tcompact: false,\n\t\t\t\t\t\t\t\t\trelief: {\n\t\t\t\t\t\t\t\t\t\tcustomType: MICROCOMPACT_CUSTOM_TYPE,\n\t\t\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t\t\telideBeforeEntryId: plan.elideBeforeEntryId,\n\t\t\t\t\t\t\t\t\t\t\tminChars: DEFAULT_MIN_ELIDE_CHARS,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn { compact: overBudget, retry: false };\n\t\t\t\t\t}\n\t\t\t\t\tif (request.recoveryAttempted) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcompact: false,\n\t\t\t\t\t\t\tfailureMessage: request.contextOverflow\n\t\t\t\t\t\t\t\t? \"Context overflow recovery failed after one compact-and-retry attempt. Try reducing context or switching to a larger-context model.\"\n\t\t\t\t\t\t\t\t: \"Truncated response recovery failed after one compact-and-retry attempt.\",\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcompact: request.contextOverflow || request.recoverableLength,\n\t\t\t\t\t\tretry: request.canContinue,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\tsummarize: async (request: CompactionSummaryRequest) =>\n\t\t\t\t\tcompact(request.preparation as CompactionPreparation, {\n\t\t\t\t\t\tinvocation: request.invocation,\n\t\t\t\t\t\tmodel: request.model,\n\t\t\t\t\t\tcustomInstructions: request.customInstructions,\n\t\t\t\t\t\tthinkingLevel: request.thinkingLevel,\n\t\t\t\t\t\tsignal: request.signal,\n\t\t\t\t\t}),\n\t\t\t});\n\t\t},\n\t);\n}\n"]}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { compact, prepareCompaction } from "../compaction/index.js";
|
|
2
|
-
import { loadCapabilityPluginSync } from "./capability-plugin.js";
|
|
3
|
-
import { applyMicrocompactElision, DEFAULT_MIN_ELIDE_CHARS, MICROCOMPACT_CUSTOM_TYPE, planMicrocompact, } from "./microcompact.js";
|
|
4
|
-
import { EXPERIMENTAL_PUBLIC_API_VERSION } from "./public-api.js";
|
|
5
|
-
export const BOOTSTRAP_COMPACTION_PLUGIN_ID = "agent-forge.bootstrap-compaction";
|
|
6
|
-
export const DEFAULT_COMPACTION_POLICY_NAME = "default";
|
|
7
|
-
/** Register the current automatic-compaction decision as a replaceable first-party policy. */
|
|
8
|
-
export function installBootstrapCompactionPolicy(runtime) {
|
|
9
|
-
return loadCapabilityPluginSync(runtime, {
|
|
10
|
-
id: BOOTSTRAP_COMPACTION_PLUGIN_ID,
|
|
11
|
-
version: "0.0.0",
|
|
12
|
-
apiVersion: EXPERIMENTAL_PUBLIC_API_VERSION,
|
|
13
|
-
entry: "<embedded:bootstrap-compaction>",
|
|
14
|
-
requiredCapabilities: ["compaction-policy"],
|
|
15
|
-
}, (api) => {
|
|
16
|
-
// Microcompact 投影(宪法 §4/§5):经公共 registerEntryProjection 通道
|
|
17
|
-
// 注册——内核按注册顺序应用投影、不解释语义;第三方上下文策略走同一
|
|
18
|
-
// 通道。策略被禁用/替换时,本投影随插件卸载一并消失。
|
|
19
|
-
api.registerEntryProjection({
|
|
20
|
-
customType: MICROCOMPACT_CUSTOM_TYPE,
|
|
21
|
-
project: (entries) => applyMicrocompactElision(entries),
|
|
22
|
-
});
|
|
23
|
-
api.registerCompactionPolicy(DEFAULT_COMPACTION_POLICY_NAME, {
|
|
24
|
-
prepare: (request) => prepareCompaction(request.entries, request.settings),
|
|
25
|
-
decide: (request) => {
|
|
26
|
-
if (!request.enabled)
|
|
27
|
-
return { compact: false };
|
|
28
|
-
if (request.reason === "threshold") {
|
|
29
|
-
const usage = request.contextUsage;
|
|
30
|
-
const overBudget = usage !== undefined &&
|
|
31
|
-
usage.contextWindow > 0 &&
|
|
32
|
-
usage.contextTokens > usage.contextWindow - usage.reserveTokens;
|
|
33
|
-
// 便宜缓解优先(microcompact):阈值命中先尝试零成本的本地
|
|
34
|
-
// 变换——把老的粗大 tool result 从模型可见上下文中替换为占位
|
|
35
|
-
// 符——释放达标则以 relief 条目落地并跳过 LLM 摘要;不足则照常
|
|
36
|
-
// 走全量压缩。条目语义完全属于本策略,投影也由本策略注册。
|
|
37
|
-
// 宿主在设置关闭或会话冷却期内传 microcompactEnabled:false,
|
|
38
|
-
// planMicrocompact 据此拒绝规划,自然落到下方全量压缩分支。
|
|
39
|
-
if (overBudget && request.branchEntries !== undefined) {
|
|
40
|
-
const plan = planMicrocompact(request.branchEntries, {
|
|
41
|
-
enabled: request.microcompactEnabled === true,
|
|
42
|
-
keepRecentTokens: request.keepRecentTokens ?? 0,
|
|
43
|
-
});
|
|
44
|
-
if (plan) {
|
|
45
|
-
return {
|
|
46
|
-
compact: false,
|
|
47
|
-
relief: {
|
|
48
|
-
customType: MICROCOMPACT_CUSTOM_TYPE,
|
|
49
|
-
data: {
|
|
50
|
-
elideBeforeEntryId: plan.elideBeforeEntryId,
|
|
51
|
-
minChars: DEFAULT_MIN_ELIDE_CHARS,
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return { compact: overBudget, retry: false };
|
|
58
|
-
}
|
|
59
|
-
if (request.recoveryAttempted) {
|
|
60
|
-
return {
|
|
61
|
-
compact: false,
|
|
62
|
-
failureMessage: request.contextOverflow
|
|
63
|
-
? "Context overflow recovery failed after one compact-and-retry attempt. Try reducing context or switching to a larger-context model."
|
|
64
|
-
: "Truncated response recovery failed after one compact-and-retry attempt.",
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
compact: request.contextOverflow || request.recoverableLength,
|
|
69
|
-
retry: request.canContinue,
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
summarize: async (request) => compact(request.preparation, {
|
|
73
|
-
invocation: request.invocation,
|
|
74
|
-
model: request.model,
|
|
75
|
-
customInstructions: request.customInstructions,
|
|
76
|
-
thinkingLevel: request.thinkingLevel,
|
|
77
|
-
signal: request.signal,
|
|
78
|
-
}),
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
//# sourceMappingURL=bootstrap-compaction-policy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap-compaction-policy.js","sourceRoot":"","sources":["../../../src/core/extensions/bootstrap-compaction-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChG,OAAO,EAA+B,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAE/F,OAAO,EACN,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,GAChB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,+BAA+B,EAAE,MAAM,iBAAiB,CAAC;AAElE,MAAM,CAAC,MAAM,8BAA8B,GAAG,kCAAkC,CAAC;AACjF,MAAM,CAAC,MAAM,8BAA8B,GAAG,SAAS,CAAC;AASxD,8FAA8F;AAC9F,MAAM,UAAU,gCAAgC,CAAC,OAA0B,EAA0B;IACpG,OAAO,wBAAwB,CAC9B,OAAO,EACP;QACC,EAAE,EAAE,8BAA8B;QAClC,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,+BAA+B;QAC3C,KAAK,EAAE,iCAAiC;QACxC,oBAAoB,EAAE,CAAC,mBAAmB,CAAC;KAC3C,EACD,CAAC,GAAG,EAAE,EAAE,CAAC;QACR,qFAA2D;QAC3D,sGAAoC;QACpC,+EAA6B;QAC7B,GAAG,CAAC,uBAAuB,CAAC;YAC3B,UAAU,EAAE,wBAAwB;YACpC,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,wBAAwB,CAAC,OAAgB,CAAU;SACzE,CAAC,CAAC;QACH,GAAG,CAAC,wBAAwB,CAAC,8BAA8B,EAAE;YAC5D,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,CACpB,iBAAiB,CAChB,OAAO,CAAC,OAAkD,EAC1D,OAAO,CAAC,QAAmD,CAC3D;YACF,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC;gBACpB,IAAI,CAAC,OAAO,CAAC,OAAO;oBAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;gBAChD,IAAI,OAAO,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;oBACpC,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC;oBACnC,MAAM,UAAU,GACf,KAAK,KAAK,SAAS;wBACnB,KAAK,CAAC,aAAa,GAAG,CAAC;wBACvB,KAAK,CAAC,aAAa,GAAG,KAAK,CAAC,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC;oBACjE,iFAAqC;oBACrC,qFAAuC;oBACvC,wFAAwC;oBACxC,uFAA+B;oBAC/B,6EAA6C;oBAC7C,gFAAwC;oBACxC,IAAI,UAAU,IAAI,OAAO,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;wBACvD,MAAM,IAAI,GAAG,gBAAgB,CAAC,OAAO,CAAC,aAAuD,EAAE;4BAC9F,OAAO,EAAG,OAA2C,CAAC,mBAAmB,KAAK,IAAI;4BAClF,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,IAAI,CAAC;yBAC/C,CAAC,CAAC;wBACH,IAAI,IAAI,EAAE,CAAC;4BACV,OAAO;gCACN,OAAO,EAAE,KAAK;gCACd,MAAM,EAAE;oCACP,UAAU,EAAE,wBAAwB;oCACpC,IAAI,EAAE;wCACL,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;wCAC3C,QAAQ,EAAE,uBAAuB;qCACjC;iCACD;6BACD,CAAC;wBACH,CAAC;oBACF,CAAC;oBACD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;gBAC9C,CAAC;gBACD,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;oBAC/B,OAAO;wBACN,OAAO,EAAE,KAAK;wBACd,cAAc,EAAE,OAAO,CAAC,eAAe;4BACtC,CAAC,CAAC,oIAAoI;4BACtI,CAAC,CAAC,yEAAyE;qBAC5E,CAAC;gBACH,CAAC;gBACD,OAAO;oBACN,OAAO,EAAE,OAAO,CAAC,eAAe,IAAI,OAAO,CAAC,iBAAiB;oBAC7D,KAAK,EAAE,OAAO,CAAC,WAAW;iBAC1B,CAAC;YAAA,CACF;YACD,SAAS,EAAE,KAAK,EAAE,OAAiC,EAAE,EAAE,CACtD,OAAO,CAAC,OAAO,CAAC,WAAoC,EAAE;gBACrD,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;gBAC9C,aAAa,EAAE,OAAO,CAAC,aAAa;gBACpC,MAAM,EAAE,OAAO,CAAC,MAAM;aACtB,CAAC;SACH,CAAC,CAAC;IAAA,CACH,CACD,CAAC;AAAA,CACF","sourcesContent":["import { type CompactionPreparation, compact, prepareCompaction } from \"../compaction/index.ts\";\nimport { type CapabilityPluginHandle, loadCapabilityPluginSync } from \"./capability-plugin.ts\";\nimport type { CapabilityRuntime } from \"./capability-runtime.ts\";\nimport {\n\tapplyMicrocompactElision,\n\tDEFAULT_MIN_ELIDE_CHARS,\n\tMICROCOMPACT_CUSTOM_TYPE,\n\tplanMicrocompact,\n} from \"./microcompact.ts\";\nimport type { CompactionPolicyRequest, CompactionSummaryRequest } from \"./public-api.ts\";\nimport { EXPERIMENTAL_PUBLIC_API_VERSION } from \"./public-api.ts\";\n\nexport const BOOTSTRAP_COMPACTION_PLUGIN_ID = \"agent-forge.bootstrap-compaction\";\nexport const DEFAULT_COMPACTION_POLICY_NAME = \"default\";\n\n/**\n * 会话宿主经 threshold decide 请求透传的 microcompact 门控事实(settings 的\n * `compaction.microcompactEnabled` 与会话冷却的合取)。请求缺省视为 false,\n * 与 2026-10-01 默认值裁决一致:relief 为 opt-in experimental。\n */\ntype DecisionRequestWithMicrocompact = CompactionPolicyRequest & { microcompactEnabled?: boolean };\n\n/** Register the current automatic-compaction decision as a replaceable first-party policy. */\nexport function installBootstrapCompactionPolicy(runtime: CapabilityRuntime): CapabilityPluginHandle {\n\treturn loadCapabilityPluginSync(\n\t\truntime,\n\t\t{\n\t\t\tid: BOOTSTRAP_COMPACTION_PLUGIN_ID,\n\t\t\tversion: \"0.0.0\",\n\t\t\tapiVersion: EXPERIMENTAL_PUBLIC_API_VERSION,\n\t\t\tentry: \"<embedded:bootstrap-compaction>\",\n\t\t\trequiredCapabilities: [\"compaction-policy\"],\n\t\t},\n\t\t(api) => {\n\t\t\t// Microcompact 投影(宪法 §4/§5):经公共 registerEntryProjection 通道\n\t\t\t// 注册——内核按注册顺序应用投影、不解释语义;第三方上下文策略走同一\n\t\t\t// 通道。策略被禁用/替换时,本投影随插件卸载一并消失。\n\t\t\tapi.registerEntryProjection({\n\t\t\t\tcustomType: MICROCOMPACT_CUSTOM_TYPE,\n\t\t\t\tproject: (entries) => applyMicrocompactElision(entries as never) as never,\n\t\t\t});\n\t\t\tapi.registerCompactionPolicy(DEFAULT_COMPACTION_POLICY_NAME, {\n\t\t\t\tprepare: (request) =>\n\t\t\t\t\tprepareCompaction(\n\t\t\t\t\t\trequest.entries as Parameters<typeof prepareCompaction>[0],\n\t\t\t\t\t\trequest.settings as Parameters<typeof prepareCompaction>[1],\n\t\t\t\t\t),\n\t\t\t\tdecide: (request) => {\n\t\t\t\t\tif (!request.enabled) return { compact: false };\n\t\t\t\t\tif (request.reason === \"threshold\") {\n\t\t\t\t\t\tconst usage = request.contextUsage;\n\t\t\t\t\t\tconst overBudget =\n\t\t\t\t\t\t\tusage !== undefined &&\n\t\t\t\t\t\t\tusage.contextWindow > 0 &&\n\t\t\t\t\t\t\tusage.contextTokens > usage.contextWindow - usage.reserveTokens;\n\t\t\t\t\t\t// 便宜缓解优先(microcompact):阈值命中先尝试零成本的本地\n\t\t\t\t\t\t// 变换——把老的粗大 tool result 从模型可见上下文中替换为占位\n\t\t\t\t\t\t// 符——释放达标则以 relief 条目落地并跳过 LLM 摘要;不足则照常\n\t\t\t\t\t\t// 走全量压缩。条目语义完全属于本策略,投影也由本策略注册。\n\t\t\t\t\t\t// 宿主在设置关闭或会话冷却期内传 microcompactEnabled:false,\n\t\t\t\t\t\t// planMicrocompact 据此拒绝规划,自然落到下方全量压缩分支。\n\t\t\t\t\t\tif (overBudget && request.branchEntries !== undefined) {\n\t\t\t\t\t\t\tconst plan = planMicrocompact(request.branchEntries as Parameters<typeof planMicrocompact>[0], {\n\t\t\t\t\t\t\t\tenabled: (request as DecisionRequestWithMicrocompact).microcompactEnabled === true,\n\t\t\t\t\t\t\t\tkeepRecentTokens: request.keepRecentTokens ?? 0,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (plan) {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tcompact: false,\n\t\t\t\t\t\t\t\t\trelief: {\n\t\t\t\t\t\t\t\t\t\tcustomType: MICROCOMPACT_CUSTOM_TYPE,\n\t\t\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t\t\telideBeforeEntryId: plan.elideBeforeEntryId,\n\t\t\t\t\t\t\t\t\t\t\tminChars: DEFAULT_MIN_ELIDE_CHARS,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn { compact: overBudget, retry: false };\n\t\t\t\t\t}\n\t\t\t\t\tif (request.recoveryAttempted) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcompact: false,\n\t\t\t\t\t\t\tfailureMessage: request.contextOverflow\n\t\t\t\t\t\t\t\t? \"Context overflow recovery failed after one compact-and-retry attempt. Try reducing context or switching to a larger-context model.\"\n\t\t\t\t\t\t\t\t: \"Truncated response recovery failed after one compact-and-retry attempt.\",\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcompact: request.contextOverflow || request.recoverableLength,\n\t\t\t\t\t\tretry: request.canContinue,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\tsummarize: async (request: CompactionSummaryRequest) =>\n\t\t\t\t\tcompact(request.preparation as CompactionPreparation, {\n\t\t\t\t\t\tinvocation: request.invocation,\n\t\t\t\t\t\tmodel: request.model,\n\t\t\t\t\t\tcustomInstructions: request.customInstructions,\n\t\t\t\t\t\tthinkingLevel: request.thinkingLevel,\n\t\t\t\t\t\tsignal: request.signal,\n\t\t\t\t\t}),\n\t\t\t});\n\t\t},\n\t);\n}\n"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type CapabilityPluginHandle } from "./capability-plugin.ts";
|
|
2
|
-
import type { CapabilityRuntime } from "./capability-runtime.ts";
|
|
3
|
-
export declare const BOOTSTRAP_OVERFLOW_PLUGIN_ID = "agent-forge.bootstrap-overflow";
|
|
4
|
-
export declare const DEFAULT_OVERFLOW_POLICY_NAME = "default";
|
|
5
|
-
/** Register the current provider classification as a replaceable first-party policy. */
|
|
6
|
-
export declare function installBootstrapOverflowPolicy(runtime: CapabilityRuntime): CapabilityPluginHandle;
|
|
7
|
-
//# sourceMappingURL=bootstrap-overflow-policy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap-overflow-policy.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/bootstrap-overflow-policy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,sBAAsB,EAA4B,MAAM,wBAAwB,CAAC;AAC/F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAIjE,eAAO,MAAM,4BAA4B,mCAAmC,CAAC;AAC7E,eAAO,MAAM,4BAA4B,YAAY,CAAC;AAEtD,wFAAwF;AACxF,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,iBAAiB,GAAG,sBAAsB,CAyBjG","sourcesContent":["import { type AssistantMessage, isContextOverflow, isRecoverableLength } from \"@agent-forge/ai/compat\";\nimport { t } from \"../i18n/index.ts\";\nimport { type CapabilityPluginHandle, loadCapabilityPluginSync } from \"./capability-plugin.ts\";\nimport type { CapabilityRuntime } from \"./capability-runtime.ts\";\nimport type { OverflowPolicyRequest } from \"./public-api.ts\";\nimport { EXPERIMENTAL_PUBLIC_API_VERSION } from \"./public-api.ts\";\n\nexport const BOOTSTRAP_OVERFLOW_PLUGIN_ID = \"agent-forge.bootstrap-overflow\";\nexport const DEFAULT_OVERFLOW_POLICY_NAME = \"default\";\n\n/** Register the current provider classification as a replaceable first-party policy. */\nexport function installBootstrapOverflowPolicy(runtime: CapabilityRuntime): CapabilityPluginHandle {\n\treturn loadCapabilityPluginSync(\n\t\truntime,\n\t\t{\n\t\t\tid: BOOTSTRAP_OVERFLOW_PLUGIN_ID,\n\t\t\tversion: \"0.0.0\",\n\t\t\tapiVersion: EXPERIMENTAL_PUBLIC_API_VERSION,\n\t\t\tentry: \"<embedded:bootstrap-overflow>\",\n\t\t\trequiredCapabilities: [\"overflow-policy\"],\n\t\t},\n\t\t(api) => {\n\t\t\tapi.registerOverflowPolicy(DEFAULT_OVERFLOW_POLICY_NAME, {\n\t\t\t\tdecide: (request: OverflowPolicyRequest) => {\n\t\t\t\t\tif (!request.message || typeof request.message !== \"object\") {\n\t\t\t\t\t\tthrow new Error(t(\"Overflow policy requires an assistant message object\"));\n\t\t\t\t\t}\n\t\t\t\t\tconst message = request.message as AssistantMessage;\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontextOverflow: isContextOverflow(message, request.contextWindow),\n\t\t\t\t\t\trecoverableLength: isRecoverableLength(message, request.desiredMaxOutput),\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t);\n}\n"]}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { isContextOverflow, isRecoverableLength } from "@agent-forge/ai/compat";
|
|
2
|
-
import { t } from "../i18n/index.js";
|
|
3
|
-
import { loadCapabilityPluginSync } from "./capability-plugin.js";
|
|
4
|
-
import { EXPERIMENTAL_PUBLIC_API_VERSION } from "./public-api.js";
|
|
5
|
-
export const BOOTSTRAP_OVERFLOW_PLUGIN_ID = "agent-forge.bootstrap-overflow";
|
|
6
|
-
export const DEFAULT_OVERFLOW_POLICY_NAME = "default";
|
|
7
|
-
/** Register the current provider classification as a replaceable first-party policy. */
|
|
8
|
-
export function installBootstrapOverflowPolicy(runtime) {
|
|
9
|
-
return loadCapabilityPluginSync(runtime, {
|
|
10
|
-
id: BOOTSTRAP_OVERFLOW_PLUGIN_ID,
|
|
11
|
-
version: "0.0.0",
|
|
12
|
-
apiVersion: EXPERIMENTAL_PUBLIC_API_VERSION,
|
|
13
|
-
entry: "<embedded:bootstrap-overflow>",
|
|
14
|
-
requiredCapabilities: ["overflow-policy"],
|
|
15
|
-
}, (api) => {
|
|
16
|
-
api.registerOverflowPolicy(DEFAULT_OVERFLOW_POLICY_NAME, {
|
|
17
|
-
decide: (request) => {
|
|
18
|
-
if (!request.message || typeof request.message !== "object") {
|
|
19
|
-
throw new Error(t("Overflow policy requires an assistant message object"));
|
|
20
|
-
}
|
|
21
|
-
const message = request.message;
|
|
22
|
-
return {
|
|
23
|
-
contextOverflow: isContextOverflow(message, request.contextWindow),
|
|
24
|
-
recoverableLength: isRecoverableLength(message, request.desiredMaxOutput),
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=bootstrap-overflow-policy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap-overflow-policy.js","sourceRoot":"","sources":["../../../src/core/extensions/bootstrap-overflow-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AACvG,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAC;AACrC,OAAO,EAA+B,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAG/F,OAAO,EAAE,+BAA+B,EAAE,MAAM,iBAAiB,CAAC;AAElE,MAAM,CAAC,MAAM,4BAA4B,GAAG,gCAAgC,CAAC;AAC7E,MAAM,CAAC,MAAM,4BAA4B,GAAG,SAAS,CAAC;AAEtD,wFAAwF;AACxF,MAAM,UAAU,8BAA8B,CAAC,OAA0B,EAA0B;IAClG,OAAO,wBAAwB,CAC9B,OAAO,EACP;QACC,EAAE,EAAE,4BAA4B;QAChC,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,+BAA+B;QAC3C,KAAK,EAAE,+BAA+B;QACtC,oBAAoB,EAAE,CAAC,iBAAiB,CAAC;KACzC,EACD,CAAC,GAAG,EAAE,EAAE,CAAC;QACR,GAAG,CAAC,sBAAsB,CAAC,4BAA4B,EAAE;YACxD,MAAM,EAAE,CAAC,OAA8B,EAAE,EAAE,CAAC;gBAC3C,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;oBAC7D,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,sDAAsD,CAAC,CAAC,CAAC;gBAC5E,CAAC;gBACD,MAAM,OAAO,GAAG,OAAO,CAAC,OAA2B,CAAC;gBACpD,OAAO;oBACN,eAAe,EAAE,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC;oBAClE,iBAAiB,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC;iBACzE,CAAC;YAAA,CACF;SACD,CAAC,CAAC;IAAA,CACH,CACD,CAAC;AAAA,CACF","sourcesContent":["import { type AssistantMessage, isContextOverflow, isRecoverableLength } from \"@agent-forge/ai/compat\";\nimport { t } from \"../i18n/index.ts\";\nimport { type CapabilityPluginHandle, loadCapabilityPluginSync } from \"./capability-plugin.ts\";\nimport type { CapabilityRuntime } from \"./capability-runtime.ts\";\nimport type { OverflowPolicyRequest } from \"./public-api.ts\";\nimport { EXPERIMENTAL_PUBLIC_API_VERSION } from \"./public-api.ts\";\n\nexport const BOOTSTRAP_OVERFLOW_PLUGIN_ID = \"agent-forge.bootstrap-overflow\";\nexport const DEFAULT_OVERFLOW_POLICY_NAME = \"default\";\n\n/** Register the current provider classification as a replaceable first-party policy. */\nexport function installBootstrapOverflowPolicy(runtime: CapabilityRuntime): CapabilityPluginHandle {\n\treturn loadCapabilityPluginSync(\n\t\truntime,\n\t\t{\n\t\t\tid: BOOTSTRAP_OVERFLOW_PLUGIN_ID,\n\t\t\tversion: \"0.0.0\",\n\t\t\tapiVersion: EXPERIMENTAL_PUBLIC_API_VERSION,\n\t\t\tentry: \"<embedded:bootstrap-overflow>\",\n\t\t\trequiredCapabilities: [\"overflow-policy\"],\n\t\t},\n\t\t(api) => {\n\t\t\tapi.registerOverflowPolicy(DEFAULT_OVERFLOW_POLICY_NAME, {\n\t\t\t\tdecide: (request: OverflowPolicyRequest) => {\n\t\t\t\t\tif (!request.message || typeof request.message !== \"object\") {\n\t\t\t\t\t\tthrow new Error(t(\"Overflow policy requires an assistant message object\"));\n\t\t\t\t\t}\n\t\t\t\t\tconst message = request.message as AssistantMessage;\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontextOverflow: isContextOverflow(message, request.contextWindow),\n\t\t\t\t\t\trecoverableLength: isRecoverableLength(message, request.desiredMaxOutput),\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t);\n}\n"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type CapabilityPluginHandle } from "./capability-plugin.ts";
|
|
2
|
-
import type { CapabilityRuntime } from "./capability-runtime.ts";
|
|
3
|
-
export declare const BOOTSTRAP_RETRY_PLUGIN_ID = "agent-forge.bootstrap-retry";
|
|
4
|
-
export declare const DEFAULT_RETRY_POLICY_NAME = "default";
|
|
5
|
-
/** Register the built-in retry decision as a replaceable first-party policy. */
|
|
6
|
-
export declare function installBootstrapRetryPolicy(runtime: CapabilityRuntime): CapabilityPluginHandle;
|
|
7
|
-
//# sourceMappingURL=bootstrap-retry-policy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap-retry-policy.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/bootstrap-retry-policy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,sBAAsB,EAA4B,MAAM,wBAAwB,CAAC;AAC/F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAGjE,eAAO,MAAM,yBAAyB,gCAAgC,CAAC;AACvE,eAAO,MAAM,yBAAyB,YAAY,CAAC;AAEnD,gFAAgF;AAChF,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,iBAAiB,GAAG,sBAAsB,CAwB9F","sourcesContent":["import { isRetryableAssistantError } from \"@agent-forge/ai/compat\";\nimport { t } from \"../i18n/index.ts\";\nimport { type CapabilityPluginHandle, loadCapabilityPluginSync } from \"./capability-plugin.ts\";\nimport type { CapabilityRuntime } from \"./capability-runtime.ts\";\nimport { EXPERIMENTAL_PUBLIC_API_VERSION } from \"./public-api.ts\";\n\nexport const BOOTSTRAP_RETRY_PLUGIN_ID = \"agent-forge.bootstrap-retry\";\nexport const DEFAULT_RETRY_POLICY_NAME = \"default\";\n\n/** Register the built-in retry decision as a replaceable first-party policy. */\nexport function installBootstrapRetryPolicy(runtime: CapabilityRuntime): CapabilityPluginHandle {\n\treturn loadCapabilityPluginSync(\n\t\truntime,\n\t\t{\n\t\t\tid: BOOTSTRAP_RETRY_PLUGIN_ID,\n\t\t\tversion: \"0.0.0\",\n\t\t\tapiVersion: EXPERIMENTAL_PUBLIC_API_VERSION,\n\t\t\tentry: \"<embedded:bootstrap-retry>\",\n\t\t\trequiredCapabilities: [\"retry-policy\"],\n\t\t},\n\t\t(api) => {\n\t\t\tapi.registerRetryPolicy(DEFAULT_RETRY_POLICY_NAME, {\n\t\t\t\tclassify: ({ message }) => {\n\t\t\t\t\tif (!message || typeof message !== \"object\")\n\t\t\t\t\t\tthrow new Error(t(\"Retry classification requires an assistant message object\"));\n\t\t\t\t\treturn isRetryableAssistantError(message as Parameters<typeof isRetryableAssistantError>[0]);\n\t\t\t\t},\n\t\t\t\tdecide: ({ retryable, enabled, attempt, maxAttempts, baseDelayMs }) => ({\n\t\t\t\t\tretry: enabled && retryable && attempt <= maxAttempts,\n\t\t\t\t\tdelayMs: baseDelayMs * 2 ** Math.max(0, attempt - 1),\n\t\t\t\t}),\n\t\t\t});\n\t\t},\n\t);\n}\n"]}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { isRetryableAssistantError } from "@agent-forge/ai/compat";
|
|
2
|
-
import { t } from "../i18n/index.js";
|
|
3
|
-
import { loadCapabilityPluginSync } from "./capability-plugin.js";
|
|
4
|
-
import { EXPERIMENTAL_PUBLIC_API_VERSION } from "./public-api.js";
|
|
5
|
-
export const BOOTSTRAP_RETRY_PLUGIN_ID = "agent-forge.bootstrap-retry";
|
|
6
|
-
export const DEFAULT_RETRY_POLICY_NAME = "default";
|
|
7
|
-
/** Register the built-in retry decision as a replaceable first-party policy. */
|
|
8
|
-
export function installBootstrapRetryPolicy(runtime) {
|
|
9
|
-
return loadCapabilityPluginSync(runtime, {
|
|
10
|
-
id: BOOTSTRAP_RETRY_PLUGIN_ID,
|
|
11
|
-
version: "0.0.0",
|
|
12
|
-
apiVersion: EXPERIMENTAL_PUBLIC_API_VERSION,
|
|
13
|
-
entry: "<embedded:bootstrap-retry>",
|
|
14
|
-
requiredCapabilities: ["retry-policy"],
|
|
15
|
-
}, (api) => {
|
|
16
|
-
api.registerRetryPolicy(DEFAULT_RETRY_POLICY_NAME, {
|
|
17
|
-
classify: ({ message }) => {
|
|
18
|
-
if (!message || typeof message !== "object")
|
|
19
|
-
throw new Error(t("Retry classification requires an assistant message object"));
|
|
20
|
-
return isRetryableAssistantError(message);
|
|
21
|
-
},
|
|
22
|
-
decide: ({ retryable, enabled, attempt, maxAttempts, baseDelayMs }) => ({
|
|
23
|
-
retry: enabled && retryable && attempt <= maxAttempts,
|
|
24
|
-
delayMs: baseDelayMs * 2 ** Math.max(0, attempt - 1),
|
|
25
|
-
}),
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=bootstrap-retry-policy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap-retry-policy.js","sourceRoot":"","sources":["../../../src/core/extensions/bootstrap-retry-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAC;AACrC,OAAO,EAA+B,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAE/F,OAAO,EAAE,+BAA+B,EAAE,MAAM,iBAAiB,CAAC;AAElE,MAAM,CAAC,MAAM,yBAAyB,GAAG,6BAA6B,CAAC;AACvE,MAAM,CAAC,MAAM,yBAAyB,GAAG,SAAS,CAAC;AAEnD,gFAAgF;AAChF,MAAM,UAAU,2BAA2B,CAAC,OAA0B,EAA0B;IAC/F,OAAO,wBAAwB,CAC9B,OAAO,EACP;QACC,EAAE,EAAE,yBAAyB;QAC7B,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,+BAA+B;QAC3C,KAAK,EAAE,4BAA4B;QACnC,oBAAoB,EAAE,CAAC,cAAc,CAAC;KACtC,EACD,CAAC,GAAG,EAAE,EAAE,CAAC;QACR,GAAG,CAAC,mBAAmB,CAAC,yBAAyB,EAAE;YAClD,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;gBAC1B,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ;oBAC1C,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,2DAA2D,CAAC,CAAC,CAAC;gBACjF,OAAO,yBAAyB,CAAC,OAA0D,CAAC,CAAC;YAAA,CAC7F;YACD,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;gBACvE,KAAK,EAAE,OAAO,IAAI,SAAS,IAAI,OAAO,IAAI,WAAW;gBACrD,OAAO,EAAE,WAAW,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC;aACpD,CAAC;SACF,CAAC,CAAC;IAAA,CACH,CACD,CAAC;AAAA,CACF","sourcesContent":["import { isRetryableAssistantError } from \"@agent-forge/ai/compat\";\nimport { t } from \"../i18n/index.ts\";\nimport { type CapabilityPluginHandle, loadCapabilityPluginSync } from \"./capability-plugin.ts\";\nimport type { CapabilityRuntime } from \"./capability-runtime.ts\";\nimport { EXPERIMENTAL_PUBLIC_API_VERSION } from \"./public-api.ts\";\n\nexport const BOOTSTRAP_RETRY_PLUGIN_ID = \"agent-forge.bootstrap-retry\";\nexport const DEFAULT_RETRY_POLICY_NAME = \"default\";\n\n/** Register the built-in retry decision as a replaceable first-party policy. */\nexport function installBootstrapRetryPolicy(runtime: CapabilityRuntime): CapabilityPluginHandle {\n\treturn loadCapabilityPluginSync(\n\t\truntime,\n\t\t{\n\t\t\tid: BOOTSTRAP_RETRY_PLUGIN_ID,\n\t\t\tversion: \"0.0.0\",\n\t\t\tapiVersion: EXPERIMENTAL_PUBLIC_API_VERSION,\n\t\t\tentry: \"<embedded:bootstrap-retry>\",\n\t\t\trequiredCapabilities: [\"retry-policy\"],\n\t\t},\n\t\t(api) => {\n\t\t\tapi.registerRetryPolicy(DEFAULT_RETRY_POLICY_NAME, {\n\t\t\t\tclassify: ({ message }) => {\n\t\t\t\t\tif (!message || typeof message !== \"object\")\n\t\t\t\t\t\tthrow new Error(t(\"Retry classification requires an assistant message object\"));\n\t\t\t\t\treturn isRetryableAssistantError(message as Parameters<typeof isRetryableAssistantError>[0]);\n\t\t\t\t},\n\t\t\t\tdecide: ({ retryable, enabled, attempt, maxAttempts, baseDelayMs }) => ({\n\t\t\t\t\tretry: enabled && retryable && attempt <= maxAttempts,\n\t\t\t\t\tdelayMs: baseDelayMs * 2 ** Math.max(0, attempt - 1),\n\t\t\t\t}),\n\t\t\t});\n\t\t},\n\t);\n}\n"]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { AgentTool } from "@agent-forge/agent-core";
|
|
2
|
-
import { type ToolsOptions } from "../tools/index.ts";
|
|
3
|
-
import type { ToolDefinition } from "../tools/tool-definition.ts";
|
|
4
|
-
import { type CapabilityPluginHandle } from "./capability-plugin.ts";
|
|
5
|
-
import type { CapabilityRuntime } from "./capability-runtime.ts";
|
|
6
|
-
import { type HostMode } from "./public-api.ts";
|
|
7
|
-
export declare const BOOTSTRAP_TOOLS_PLUGIN_ID = "agent-forge.bootstrap-tools";
|
|
8
|
-
export interface BootstrapToolsOptions {
|
|
9
|
-
version?: string;
|
|
10
|
-
}
|
|
11
|
-
export interface SessionBootstrapToolsOptions extends BootstrapToolsOptions {
|
|
12
|
-
read?: ToolsOptions["read"];
|
|
13
|
-
bash?: ToolsOptions["bash"];
|
|
14
|
-
mode?: HostMode;
|
|
15
|
-
}
|
|
16
|
-
/** Install the default coding tools through the same facade available to users. */
|
|
17
|
-
export declare function installBootstrapTools(runtime: CapabilityRuntime, definitions: readonly ToolDefinition[], options?: BootstrapToolsOptions): CapabilityPluginHandle;
|
|
18
|
-
/** Build and install the standard coding tools without exposing their construction to AgentSession. */
|
|
19
|
-
export declare function installSessionBootstrapTools(runtime: CapabilityRuntime, cwd: string, options?: SessionBootstrapToolsOptions, baseToolsOverride?: Record<string, AgentTool>): CapabilityPluginHandle;
|
|
20
|
-
//# sourceMappingURL=bootstrap-tools.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap-tools.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/bootstrap-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAA2D,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC/G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,EAAE,KAAK,sBAAsB,EAA4B,MAAM,wBAAwB,CAAC;AAC/F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAmC,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEjF,eAAO,MAAM,yBAAyB,gCAAgC,CAAC;AAEvE,MAAM,WAAW,qBAAqB;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,4BAA6B,SAAQ,qBAAqB;IAC1E,IAAI,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAC5B,IAAI,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAC5B,IAAI,CAAC,EAAE,QAAQ,CAAC;CAChB;AAkBD,mFAAmF;AACnF,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,iBAAiB,EAC1B,WAAW,EAAE,SAAS,cAAc,EAAE,EACtC,OAAO,GAAE,qBAA0B,GACjC,sBAAsB,CAcxB;AAED,uGAAuG;AACvG,wBAAgB,4BAA4B,CAC3C,OAAO,EAAE,iBAAiB,EAC1B,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,4BAAiC,EAC1C,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAC3C,sBAAsB,CAGxB","sourcesContent":["import type { AgentTool } from \"@agent-forge/agent-core\";\nimport { t } from \"../i18n/index.ts\";\nimport { createAllToolDefinitions, createReadOnlyToolDefinitions, type ToolsOptions } from \"../tools/index.ts\";\nimport type { ToolDefinition } from \"../tools/tool-definition.ts\";\nimport { createToolDefinitionFromAgentTool } from \"../tools/tool-definition-wrapper.ts\";\nimport { type CapabilityPluginHandle, loadCapabilityPluginSync } from \"./capability-plugin.ts\";\nimport type { CapabilityRuntime } from \"./capability-runtime.ts\";\nimport { EXPERIMENTAL_PUBLIC_API_VERSION, type HostMode } from \"./public-api.ts\";\n\nexport const BOOTSTRAP_TOOLS_PLUGIN_ID = \"agent-forge.bootstrap-tools\";\n\nexport interface BootstrapToolsOptions {\n\tversion?: string;\n}\n\nexport interface SessionBootstrapToolsOptions extends BootstrapToolsOptions {\n\tread?: ToolsOptions[\"read\"];\n\tbash?: ToolsOptions[\"bash\"];\n\tmode?: HostMode;\n}\n\nfunction resolveSessionToolDefinitions(\n\tcwd: string,\n\toptions: SessionBootstrapToolsOptions,\n\tbaseToolsOverride?: Record<string, AgentTool>,\n): readonly ToolDefinition[] {\n\tif (!baseToolsOverride) {\n\t\treturn options.mode === \"readonly\"\n\t\t\t? createReadOnlyToolDefinitions(cwd, { read: options.read })\n\t\t\t: Object.values(createAllToolDefinitions(cwd, { read: options.read, bash: options.bash }));\n\t}\n\tif (options.mode === \"readonly\") {\n\t\tthrow new Error(t(\"Readonly mode does not allow base tool overrides\"));\n\t}\n\treturn Object.values(baseToolsOverride).map((tool) => createToolDefinitionFromAgentTool(tool));\n}\n\n/** Install the default coding tools through the same facade available to users. */\nexport function installBootstrapTools(\n\truntime: CapabilityRuntime,\n\tdefinitions: readonly ToolDefinition[],\n\toptions: BootstrapToolsOptions = {},\n): CapabilityPluginHandle {\n\treturn loadCapabilityPluginSync(\n\t\truntime,\n\t\t{\n\t\t\tid: BOOTSTRAP_TOOLS_PLUGIN_ID,\n\t\t\tversion: options.version ?? \"0.0.0\",\n\t\t\tapiVersion: EXPERIMENTAL_PUBLIC_API_VERSION,\n\t\t\tentry: \"<embedded:bootstrap-tools>\",\n\t\t\trequiredCapabilities: [\"tools\"],\n\t\t},\n\t\t(api) => {\n\t\t\tfor (const definition of definitions) api.registerTool(definition);\n\t\t},\n\t);\n}\n\n/** Build and install the standard coding tools without exposing their construction to AgentSession. */\nexport function installSessionBootstrapTools(\n\truntime: CapabilityRuntime,\n\tcwd: string,\n\toptions: SessionBootstrapToolsOptions = {},\n\tbaseToolsOverride?: Record<string, AgentTool>,\n): CapabilityPluginHandle {\n\tconst definitions = resolveSessionToolDefinitions(cwd, options, baseToolsOverride);\n\treturn installBootstrapTools(runtime, definitions, options);\n}\n"]}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { t } from "../i18n/index.js";
|
|
2
|
-
import { createAllToolDefinitions, createReadOnlyToolDefinitions } from "../tools/index.js";
|
|
3
|
-
import { createToolDefinitionFromAgentTool } from "../tools/tool-definition-wrapper.js";
|
|
4
|
-
import { loadCapabilityPluginSync } from "./capability-plugin.js";
|
|
5
|
-
import { EXPERIMENTAL_PUBLIC_API_VERSION } from "./public-api.js";
|
|
6
|
-
export const BOOTSTRAP_TOOLS_PLUGIN_ID = "agent-forge.bootstrap-tools";
|
|
7
|
-
function resolveSessionToolDefinitions(cwd, options, baseToolsOverride) {
|
|
8
|
-
if (!baseToolsOverride) {
|
|
9
|
-
return options.mode === "readonly"
|
|
10
|
-
? createReadOnlyToolDefinitions(cwd, { read: options.read })
|
|
11
|
-
: Object.values(createAllToolDefinitions(cwd, { read: options.read, bash: options.bash }));
|
|
12
|
-
}
|
|
13
|
-
if (options.mode === "readonly") {
|
|
14
|
-
throw new Error(t("Readonly mode does not allow base tool overrides"));
|
|
15
|
-
}
|
|
16
|
-
return Object.values(baseToolsOverride).map((tool) => createToolDefinitionFromAgentTool(tool));
|
|
17
|
-
}
|
|
18
|
-
/** Install the default coding tools through the same facade available to users. */
|
|
19
|
-
export function installBootstrapTools(runtime, definitions, options = {}) {
|
|
20
|
-
return loadCapabilityPluginSync(runtime, {
|
|
21
|
-
id: BOOTSTRAP_TOOLS_PLUGIN_ID,
|
|
22
|
-
version: options.version ?? "0.0.0",
|
|
23
|
-
apiVersion: EXPERIMENTAL_PUBLIC_API_VERSION,
|
|
24
|
-
entry: "<embedded:bootstrap-tools>",
|
|
25
|
-
requiredCapabilities: ["tools"],
|
|
26
|
-
}, (api) => {
|
|
27
|
-
for (const definition of definitions)
|
|
28
|
-
api.registerTool(definition);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
/** Build and install the standard coding tools without exposing their construction to AgentSession. */
|
|
32
|
-
export function installSessionBootstrapTools(runtime, cwd, options = {}, baseToolsOverride) {
|
|
33
|
-
const definitions = resolveSessionToolDefinitions(cwd, options, baseToolsOverride);
|
|
34
|
-
return installBootstrapTools(runtime, definitions, options);
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=bootstrap-tools.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap-tools.js","sourceRoot":"","sources":["../../../src/core/extensions/bootstrap-tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,6BAA6B,EAAqB,MAAM,mBAAmB,CAAC;AAE/G,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAA+B,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAE/F,OAAO,EAAE,+BAA+B,EAAiB,MAAM,iBAAiB,CAAC;AAEjF,MAAM,CAAC,MAAM,yBAAyB,GAAG,6BAA6B,CAAC;AAYvE,SAAS,6BAA6B,CACrC,GAAW,EACX,OAAqC,EACrC,iBAA6C,EACjB;IAC5B,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACxB,OAAO,OAAO,CAAC,IAAI,KAAK,UAAU;YACjC,CAAC,CAAC,6BAA6B,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;YAC5D,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,wBAAwB,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC7F,CAAC;IACD,IAAI,OAAO,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,kDAAkD,CAAC,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,iCAAiC,CAAC,IAAI,CAAC,CAAC,CAAC;AAAA,CAC/F;AAED,mFAAmF;AACnF,MAAM,UAAU,qBAAqB,CACpC,OAA0B,EAC1B,WAAsC,EACtC,OAAO,GAA0B,EAAE,EACV;IACzB,OAAO,wBAAwB,CAC9B,OAAO,EACP;QACC,EAAE,EAAE,yBAAyB;QAC7B,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,OAAO;QACnC,UAAU,EAAE,+BAA+B;QAC3C,KAAK,EAAE,4BAA4B;QACnC,oBAAoB,EAAE,CAAC,OAAO,CAAC;KAC/B,EACD,CAAC,GAAG,EAAE,EAAE,CAAC;QACR,KAAK,MAAM,UAAU,IAAI,WAAW;YAAE,GAAG,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAAA,CACnE,CACD,CAAC;AAAA,CACF;AAED,uGAAuG;AACvG,MAAM,UAAU,4BAA4B,CAC3C,OAA0B,EAC1B,GAAW,EACX,OAAO,GAAiC,EAAE,EAC1C,iBAA6C,EACpB;IACzB,MAAM,WAAW,GAAG,6BAA6B,CAAC,GAAG,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;IACnF,OAAO,qBAAqB,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAAA,CAC5D","sourcesContent":["import type { AgentTool } from \"@agent-forge/agent-core\";\nimport { t } from \"../i18n/index.ts\";\nimport { createAllToolDefinitions, createReadOnlyToolDefinitions, type ToolsOptions } from \"../tools/index.ts\";\nimport type { ToolDefinition } from \"../tools/tool-definition.ts\";\nimport { createToolDefinitionFromAgentTool } from \"../tools/tool-definition-wrapper.ts\";\nimport { type CapabilityPluginHandle, loadCapabilityPluginSync } from \"./capability-plugin.ts\";\nimport type { CapabilityRuntime } from \"./capability-runtime.ts\";\nimport { EXPERIMENTAL_PUBLIC_API_VERSION, type HostMode } from \"./public-api.ts\";\n\nexport const BOOTSTRAP_TOOLS_PLUGIN_ID = \"agent-forge.bootstrap-tools\";\n\nexport interface BootstrapToolsOptions {\n\tversion?: string;\n}\n\nexport interface SessionBootstrapToolsOptions extends BootstrapToolsOptions {\n\tread?: ToolsOptions[\"read\"];\n\tbash?: ToolsOptions[\"bash\"];\n\tmode?: HostMode;\n}\n\nfunction resolveSessionToolDefinitions(\n\tcwd: string,\n\toptions: SessionBootstrapToolsOptions,\n\tbaseToolsOverride?: Record<string, AgentTool>,\n): readonly ToolDefinition[] {\n\tif (!baseToolsOverride) {\n\t\treturn options.mode === \"readonly\"\n\t\t\t? createReadOnlyToolDefinitions(cwd, { read: options.read })\n\t\t\t: Object.values(createAllToolDefinitions(cwd, { read: options.read, bash: options.bash }));\n\t}\n\tif (options.mode === \"readonly\") {\n\t\tthrow new Error(t(\"Readonly mode does not allow base tool overrides\"));\n\t}\n\treturn Object.values(baseToolsOverride).map((tool) => createToolDefinitionFromAgentTool(tool));\n}\n\n/** Install the default coding tools through the same facade available to users. */\nexport function installBootstrapTools(\n\truntime: CapabilityRuntime,\n\tdefinitions: readonly ToolDefinition[],\n\toptions: BootstrapToolsOptions = {},\n): CapabilityPluginHandle {\n\treturn loadCapabilityPluginSync(\n\t\truntime,\n\t\t{\n\t\t\tid: BOOTSTRAP_TOOLS_PLUGIN_ID,\n\t\t\tversion: options.version ?? \"0.0.0\",\n\t\t\tapiVersion: EXPERIMENTAL_PUBLIC_API_VERSION,\n\t\t\tentry: \"<embedded:bootstrap-tools>\",\n\t\t\trequiredCapabilities: [\"tools\"],\n\t\t},\n\t\t(api) => {\n\t\t\tfor (const definition of definitions) api.registerTool(definition);\n\t\t},\n\t);\n}\n\n/** Build and install the standard coding tools without exposing their construction to AgentSession. */\nexport function installSessionBootstrapTools(\n\truntime: CapabilityRuntime,\n\tcwd: string,\n\toptions: SessionBootstrapToolsOptions = {},\n\tbaseToolsOverride?: Record<string, AgentTool>,\n): CapabilityPluginHandle {\n\tconst definitions = resolveSessionToolDefinitions(cwd, options, baseToolsOverride);\n\treturn installBootstrapTools(runtime, definitions, options);\n}\n"]}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Microcompact (P1 context hygiene): before spending an LLM summarization
|
|
3
|
-
* call, elide the BULKY OLD tool results from the LLM context — a pure local
|
|
4
|
-
* history transform with zero model cost (the codex/ZCode "microcompact"
|
|
5
|
-
* layer). The session file keeps every byte (append-only marker + logical
|
|
6
|
-
* transform at context build); only the model-visible context shrinks.
|
|
7
|
-
*
|
|
8
|
-
* Contract: the marker is a `custom` session entry (`MICROCOMPACT_CUSTOM_TYPE`)
|
|
9
|
-
* whose data names the elision point. The projection registered by the
|
|
10
|
-
* bootstrap compaction policy plugin (via the PUBLIC
|
|
11
|
-
* `api.registerEntryProjection` channel) replaces eligible tool-result
|
|
12
|
-
* contents older than that point with a fixed placeholder, so reload and
|
|
13
|
-
* token estimation stay consistent with live turns. The kernel applies
|
|
14
|
-
* registered projections verbatim and knows nothing about microcompact.
|
|
15
|
-
*/
|
|
16
|
-
import type { AgentMessage } from "@agent-forge/agent-core";
|
|
17
|
-
import type { SessionEntry } from "../session-manager.ts";
|
|
18
|
-
/** Custom entry type carrying the microcompact elision point. */
|
|
19
|
-
export declare const MICROCOMPACT_CUSTOM_TYPE = "microcompact.v1";
|
|
20
|
-
/** Replacement content for an elided tool result. */
|
|
21
|
-
export declare const MICROCOMPACT_ELIDED_PLACEHOLDER = "[earlier tool result elided by microcompact]";
|
|
22
|
-
/** Tool results shorter than this are not worth eliding (noise, not bulk). */
|
|
23
|
-
export declare const DEFAULT_MIN_ELIDE_CHARS = 200;
|
|
24
|
-
/**
|
|
25
|
-
* Minimum estimated token relief for a microcompact to fire: below this the
|
|
26
|
-
* churn (marker entry + context transition) cannot pay for itself and the
|
|
27
|
-
* caller falls through to full LLM compaction.
|
|
28
|
-
*/
|
|
29
|
-
export declare const MIN_MICROCOMPACT_FREED_TOKENS = 2048;
|
|
30
|
-
/** Data carried by a {@link MICROCOMPACT_CUSTOM_TYPE} custom entry. */
|
|
31
|
-
export interface MicrocompactMarkerData {
|
|
32
|
-
/** Entries strictly BEFORE this entry id (path order) are elision candidates. */
|
|
33
|
-
readonly elideBeforeEntryId: string;
|
|
34
|
-
/** Tool results whose serialized content is shorter are kept verbatim. */
|
|
35
|
-
readonly minChars: number;
|
|
36
|
-
}
|
|
37
|
-
export interface MicrocompactPlan {
|
|
38
|
-
readonly elideBeforeEntryId: string;
|
|
39
|
-
/** Estimated tokens freed by eliding the eligible tool results. */
|
|
40
|
-
readonly freedTokens: number;
|
|
41
|
-
readonly elidedCount: number;
|
|
42
|
-
}
|
|
43
|
-
/** Explicit plan options: `enabled` gates THIS mechanism only (microcompact relief), not compaction. */
|
|
44
|
-
export interface MicrocompactPlanOptions {
|
|
45
|
-
/** Whether microcompact relief may fire at all (settings switch AND session cooldown). */
|
|
46
|
-
enabled: boolean;
|
|
47
|
-
/** Verbatim-protected recent tail budget (estimated tokens). */
|
|
48
|
-
keepRecentTokens: number;
|
|
49
|
-
/** Tool results shorter than this are not worth eliding. */
|
|
50
|
-
minElideChars?: number;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Plan one microcompact over the branch path: protect the most recent
|
|
54
|
-
* `keepRecentTokens` (estimated) as the verbatim tail, and elide the eligible
|
|
55
|
-
* old tool results before that cut. Returns undefined when the caller disabled
|
|
56
|
-
* the mechanism (`options.enabled === false`), when there is nothing to elide,
|
|
57
|
-
* or when the relief cannot reach the minimum. Deliberately does NOT reuse
|
|
58
|
-
* `CompactionSettings`: its `enabled` is the compaction master switch — a
|
|
59
|
-
* different gate.
|
|
60
|
-
*/
|
|
61
|
-
export declare function planMicrocompact(pathEntries: readonly {
|
|
62
|
-
readonly id?: string;
|
|
63
|
-
readonly type: string;
|
|
64
|
-
readonly message?: AgentMessage;
|
|
65
|
-
}[], options: MicrocompactPlanOptions): MicrocompactPlan | undefined;
|
|
66
|
-
/** Resolve the marker data of the LAST microcompact marker in path order. */
|
|
67
|
-
export declare function lastMicrocompactMarker(pathEntries: readonly {
|
|
68
|
-
readonly type: string;
|
|
69
|
-
readonly customType?: string;
|
|
70
|
-
readonly data?: unknown;
|
|
71
|
-
}[]): MicrocompactMarkerData | undefined;
|
|
72
|
-
/**
|
|
73
|
-
* The entry projection backing microcompact: replaces the CONTENT of eligible
|
|
74
|
-
* tool results before the marker's cut point with the fixed placeholder, and
|
|
75
|
-
* keeps everything else verbatim. Registered through the public
|
|
76
|
-
* `api.registerEntryProjection` channel — the same channel any third-party
|
|
77
|
-
* context policy uses; the kernel applies it without interpretation.
|
|
78
|
-
*/
|
|
79
|
-
export declare function applyMicrocompactElision(path: SessionEntry[]): SessionEntry[];
|
|
80
|
-
//# sourceMappingURL=microcompact.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"microcompact.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/microcompact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAG5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,iEAAiE;AACjE,eAAO,MAAM,wBAAwB,oBAAoB,CAAC;AAE1D,qDAAqD;AACrD,eAAO,MAAM,+BAA+B,iDAAiD,CAAC;AAE9F,8EAA8E;AAC9E,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,OAAO,CAAC;AAElD,uEAAuE;AACvE,MAAM,WAAW,sBAAsB;IACtC,iFAAiF;IACjF,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,mEAAmE;IACnE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC7B;AAgBD,wGAAwG;AACxG,MAAM,WAAW,uBAAuB;IACvC,0FAA0F;IAC1F,OAAO,EAAE,OAAO,CAAC;IACjB,gEAAgE;IAChE,gBAAgB,EAAE,MAAM,CAAC;IACzB,4DAA4D;IAC5D,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC/B,WAAW,EAAE,SAAS;IAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,YAAY,CAAA;CAAE,EAAE,EACxG,OAAO,EAAE,uBAAuB,GAC9B,gBAAgB,GAAG,SAAS,CAqC9B;AAED,6EAA6E;AAC7E,wBAAgB,sBAAsB,CACrC,WAAW,EAAE,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,EAAE,GACtG,sBAAsB,GAAG,SAAS,CAapC;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CAgB7E","sourcesContent":["/**\n * Microcompact (P1 context hygiene): before spending an LLM summarization\n * call, elide the BULKY OLD tool results from the LLM context — a pure local\n * history transform with zero model cost (the codex/ZCode \"microcompact\"\n * layer). The session file keeps every byte (append-only marker + logical\n * transform at context build); only the model-visible context shrinks.\n *\n * Contract: the marker is a `custom` session entry (`MICROCOMPACT_CUSTOM_TYPE`)\n * whose data names the elision point. The projection registered by the\n * bootstrap compaction policy plugin (via the PUBLIC\n * `api.registerEntryProjection` channel) replaces eligible tool-result\n * contents older than that point with a fixed placeholder, so reload and\n * token estimation stay consistent with live turns. The kernel applies\n * registered projections verbatim and knows nothing about microcompact.\n */\n\nimport type { AgentMessage } from \"@agent-forge/agent-core\";\nimport { contentText } from \"@agent-forge/ai\";\nimport { estimateTokens } from \"../compaction/index.ts\";\nimport type { SessionEntry } from \"../session-manager.ts\";\n\n/** Custom entry type carrying the microcompact elision point. */\nexport const MICROCOMPACT_CUSTOM_TYPE = \"microcompact.v1\";\n\n/** Replacement content for an elided tool result. */\nexport const MICROCOMPACT_ELIDED_PLACEHOLDER = \"[earlier tool result elided by microcompact]\";\n\n/** Tool results shorter than this are not worth eliding (noise, not bulk). */\nexport const DEFAULT_MIN_ELIDE_CHARS = 200;\n\n/**\n * Minimum estimated token relief for a microcompact to fire: below this the\n * churn (marker entry + context transition) cannot pay for itself and the\n * caller falls through to full LLM compaction.\n */\nexport const MIN_MICROCOMPACT_FREED_TOKENS = 2048;\n\n/** Data carried by a {@link MICROCOMPACT_CUSTOM_TYPE} custom entry. */\nexport interface MicrocompactMarkerData {\n\t/** Entries strictly BEFORE this entry id (path order) are elision candidates. */\n\treadonly elideBeforeEntryId: string;\n\t/** Tool results whose serialized content is shorter are kept verbatim. */\n\treadonly minChars: number;\n}\n\nexport interface MicrocompactPlan {\n\treadonly elideBeforeEntryId: string;\n\t/** Estimated tokens freed by eliding the eligible tool results. */\n\treadonly freedTokens: number;\n\treadonly elidedCount: number;\n}\n\nfunction isElidableToolResult(\n\tmessage: AgentMessage,\n\tminChars: number,\n): message is Extract<AgentMessage, { role: \"toolResult\" }> {\n\tif (message.role !== \"toolResult\") return false;\n\t// 媒体保护:含非 text part(image 等)的 tool result 不 elide——占位符替换会\n\t// 把模型可见上下文中的原图数据抹掉(会话文件虽保真,但投影按 marker 重放,\n\t// 图像不会自行回来),保持\"原图常驻直到全量压缩\"的现行裁决。\n\tif (Array.isArray(message.content) && message.content.some((part) => part.type !== \"text\")) {\n\t\treturn false;\n\t}\n\treturn contentText(message.content, \"\").length >= minChars;\n}\n\n/** Explicit plan options: `enabled` gates THIS mechanism only (microcompact relief), not compaction. */\nexport interface MicrocompactPlanOptions {\n\t/** Whether microcompact relief may fire at all (settings switch AND session cooldown). */\n\tenabled: boolean;\n\t/** Verbatim-protected recent tail budget (estimated tokens). */\n\tkeepRecentTokens: number;\n\t/** Tool results shorter than this are not worth eliding. */\n\tminElideChars?: number;\n}\n\n/**\n * Plan one microcompact over the branch path: protect the most recent\n * `keepRecentTokens` (estimated) as the verbatim tail, and elide the eligible\n * old tool results before that cut. Returns undefined when the caller disabled\n * the mechanism (`options.enabled === false`), when there is nothing to elide,\n * or when the relief cannot reach the minimum. Deliberately does NOT reuse\n * `CompactionSettings`: its `enabled` is the compaction master switch — a\n * different gate.\n */\nexport function planMicrocompact(\n\tpathEntries: readonly { readonly id?: string; readonly type: string; readonly message?: AgentMessage }[],\n\toptions: MicrocompactPlanOptions,\n): MicrocompactPlan | undefined {\n\tif (!options.enabled) return undefined;\n\tconst minChars = options.minElideChars ?? DEFAULT_MIN_ELIDE_CHARS;\n\n\t// Protect the recent tail: walk backwards accumulating estimated tokens,\n\t// cutting before the entry that crosses the budget (same walk as\n\t// findCutPoint, but without turn-boundary subtleties — elision never\n\t// removes entries, only replaces contents, so any cut point is safe).\n\tlet accumulated = 0;\n\tlet cutIndex = 0;\n\tfor (let i = pathEntries.length - 1; i >= 0; i--) {\n\t\tconst entry = pathEntries[i];\n\t\tconst messageTokens = entry.message ? estimateTokens(entry.message) : 0;\n\t\tif (messageTokens === 0) continue;\n\t\taccumulated += messageTokens;\n\t\tif (accumulated >= options.keepRecentTokens) {\n\t\t\tcutIndex = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tlet freedTokens = 0;\n\tlet elidedCount = 0;\n\tfor (let i = 0; i < cutIndex; i++) {\n\t\tconst message = pathEntries[i].message;\n\t\tif (!message || !isElidableToolResult(message, minChars)) continue;\n\t\tfreedTokens +=\n\t\t\testimateTokens(message) -\n\t\t\testimateTokens({ ...message, content: [{ type: \"text\", text: MICROCOMPACT_ELIDED_PLACEHOLDER }] });\n\t\telidedCount += 1;\n\t}\n\n\tconst elideBefore = pathEntries[cutIndex];\n\tif (elidedCount === 0 || freedTokens < MIN_MICROCOMPACT_FREED_TOKENS) return undefined;\n\tconst elideBeforeEntryId = elideBefore?.id;\n\tif (!elideBeforeEntryId) return undefined;\n\treturn { elideBeforeEntryId, freedTokens, elidedCount };\n}\n\n/** Resolve the marker data of the LAST microcompact marker in path order. */\nexport function lastMicrocompactMarker(\n\tpathEntries: readonly { readonly type: string; readonly customType?: string; readonly data?: unknown }[],\n): MicrocompactMarkerData | undefined {\n\tlet marker: MicrocompactMarkerData | undefined;\n\tfor (const entry of pathEntries) {\n\t\tif (entry.type !== \"custom\" || entry.customType !== MICROCOMPACT_CUSTOM_TYPE) continue;\n\t\tconst data = entry.data as Partial<MicrocompactMarkerData> | undefined;\n\t\tif (typeof data?.elideBeforeEntryId === \"string\") {\n\t\t\tmarker = {\n\t\t\t\telideBeforeEntryId: data.elideBeforeEntryId,\n\t\t\t\tminChars: typeof data.minChars === \"number\" && data.minChars >= 0 ? data.minChars : DEFAULT_MIN_ELIDE_CHARS,\n\t\t\t};\n\t\t}\n\t}\n\treturn marker;\n}\n\n/**\n * The entry projection backing microcompact: replaces the CONTENT of eligible\n * tool results before the marker's cut point with the fixed placeholder, and\n * keeps everything else verbatim. Registered through the public\n * `api.registerEntryProjection` channel — the same channel any third-party\n * context policy uses; the kernel applies it without interpretation.\n */\nexport function applyMicrocompactElision(path: SessionEntry[]): SessionEntry[] {\n\tconst marker = lastMicrocompactMarker(path);\n\tif (marker === undefined) return path;\n\tconst cutIndex = path.findIndex((entry) => entry.id === marker.elideBeforeEntryId);\n\tif (cutIndex <= 0) return path;\n\treturn path.map((entry, index) => {\n\t\tif (index >= cutIndex || entry.type !== \"message\") return entry;\n\t\tconst message = entry.message;\n\t\t// 与 planMicrocompact 同一判定(长度阈值 + 媒体保护):投影只 elide 规划\n\t\t// 时认定为可省的 tool result,否则计划与投影对同一历史给出不同结果。\n\t\tif (!isElidableToolResult(message, marker.minChars)) return entry;\n\t\treturn {\n\t\t\t...entry,\n\t\t\tmessage: { ...message, content: [{ type: \"text\", text: MICROCOMPACT_ELIDED_PLACEHOLDER }] },\n\t\t};\n\t});\n}\n"]}
|