@humain/terminal 0.0.6 → 0.0.7
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 +52 -0
- package/README.md +10 -4
- package/dist/bundle/chunks/anthropic-messages-GDMGYAZB.js +6 -0
- package/dist/bundle/chunks/anthropic.js +75 -0
- package/dist/bundle/chunks/azure-openai-responses-ZN52D6YC.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +77 -0
- package/dist/bundle/chunks/chunk-3D3G2X5U.js +6 -0
- package/dist/bundle/chunks/chunk-3VI4HD7D.js +31 -0
- package/dist/bundle/chunks/chunk-6R7UI4IY.js +2 -0
- package/dist/bundle/chunks/chunk-72KO4OMP.js +2 -0
- package/dist/bundle/chunks/chunk-7DDKXS2Q.js +2 -0
- package/dist/bundle/chunks/chunk-ARF4OE6X.js +105 -0
- package/dist/bundle/chunks/chunk-BOW22LW6.js +42 -0
- package/dist/bundle/chunks/chunk-BZQ53VGE.js +70 -0
- package/dist/bundle/chunks/chunk-CBHC6EL7.js +133 -0
- package/dist/bundle/chunks/chunk-D7XAASZM.js +4 -0
- package/dist/bundle/chunks/chunk-ECWELYBH.js +17 -0
- package/dist/bundle/chunks/chunk-GMWCTUPB.js +2 -0
- package/dist/bundle/chunks/chunk-H2O6VOXT.js +11 -0
- package/dist/bundle/chunks/chunk-HNVPY4LZ.js +5995 -0
- package/dist/bundle/chunks/chunk-JUUC5AZY.js +2 -0
- package/dist/bundle/chunks/chunk-JXWJOIH4.js +2 -0
- package/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
- package/dist/bundle/chunks/chunk-LVVZS2NO.js +12 -0
- package/dist/bundle/chunks/chunk-M2GYSCCG.js +44 -0
- package/dist/bundle/chunks/chunk-MA4UUCYX.js +18 -0
- package/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
- package/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
- package/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
- package/dist/bundle/chunks/chunk-SGTGQNNP.js +4 -0
- package/dist/bundle/chunks/chunk-TEPMHNKQ.js +2 -0
- package/dist/bundle/chunks/chunk-TXBQIIIO.js +2 -0
- package/dist/bundle/chunks/chunk-WJZ4KLGL.js +2 -0
- package/dist/bundle/chunks/chunk-XNGRGP62.js +2 -0
- package/dist/bundle/chunks/dist-7DSXV2TY.js +9 -0
- package/dist/bundle/chunks/dist-BXEVYJIO.js +7 -0
- package/dist/bundle/chunks/es-P2KNSZYR.js +9 -0
- package/dist/bundle/chunks/es5-FGTJ7ZFW.js +2 -0
- package/dist/bundle/chunks/event-streams-JOSQQSII.js +2 -0
- package/dist/bundle/chunks/extract-2L7ZVN7F.js +106 -0
- package/dist/bundle/chunks/github-copilot.js +2 -0
- package/dist/bundle/chunks/google-generative-ai-XT7NQJ2E.js +2 -0
- package/dist/bundle/chunks/google-vertex-IDQ6Z53W.js +2 -0
- package/dist/bundle/chunks/image-resize-worker.js +2 -0
- package/dist/bundle/chunks/kimi-coding.js +2 -0
- package/dist/bundle/chunks/mistral-conversations-HHDZ4FHR.js +5 -0
- package/dist/bundle/chunks/multipart-parser-FMGQ7342.js +3 -0
- package/dist/bundle/chunks/node-XY3CBY3C.js +294 -0
- package/dist/bundle/chunks/node-ZHY4LHC7.js +15 -0
- package/dist/bundle/chunks/openai-codex-responses-HRVCDY54.js +8 -0
- package/dist/bundle/chunks/openai-codex.js +75 -0
- package/dist/bundle/chunks/openai-completions-6QBYTBXY.js +7 -0
- package/dist/bundle/chunks/openai-responses-4MWLJHIK.js +2 -0
- package/dist/bundle/chunks/openrouter-images-Y2PCWAQH.js +2 -0
- package/dist/bundle/chunks/openrouter.js +75 -0
- package/dist/bundle/chunks/pdfjs-UKQT3OWY.js +107 -0
- package/dist/bundle/chunks/pi-messages-57K43J6J.js +8 -0
- package/dist/bundle/chunks/promise-J5TGSM32.js +2 -0
- package/dist/bundle/chunks/radius.js +75 -0
- package/dist/bundle/chunks/src-QKGKDFSU.js +4 -0
- package/dist/bundle/chunks/undici-D6ABF53Q.js +2 -0
- package/dist/bundle/chunks/webapi-AFS5FDJJ.js +5 -0
- package/dist/bundle/chunks/xai.js +2 -0
- package/dist/bundle/cli.js +3 -0
- package/dist/bundle/client.js +2 -0
- package/dist/bundle/index.js +2 -0
- package/dist/bundle/rpc-entry.js +3 -0
- package/dist/cli/args.d.ts +1 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +29 -9
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +2 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +19 -11
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +50 -14
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +163 -95
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +6 -7
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +3 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +4 -3
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +41 -32
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/defaults.d.ts +1 -0
- package/dist/core/defaults.d.ts.map +1 -1
- package/dist/core/defaults.js +9 -0
- package/dist/core/defaults.js.map +1 -1
- package/dist/core/extensions/index.d.ts +2 -2
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +115 -48
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/types.d.ts +38 -9
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js +3 -0
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +1 -1
- package/dist/core/footer-data-provider.js +1 -1
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/keybindings.d.ts +20 -19
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +26 -5
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-config.d.ts +5 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +3 -1
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -0
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +14 -8
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/models-store.d.ts.map +1 -1
- package/dist/core/models-store.js +2 -1
- package/dist/core/models-store.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +22 -14
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-manifest.d.ts.map +1 -1
- package/dist/core/pi-manifest.js +2 -1
- package/dist/core/pi-manifest.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +2 -1
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +3 -2
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +2 -2
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +10 -3
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-export.d.ts +4 -0
- package/dist/core/session-export.d.ts.map +1 -0
- package/dist/core/session-export.js +32 -0
- package/dist/core/session-export.js.map +1 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +2 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-diagnostics.d.ts +9 -0
- package/dist/core/settings-diagnostics.d.ts.map +1 -0
- package/dist/core/settings-diagnostics.js +21 -0
- package/dist/core/settings-diagnostics.js.map +1 -0
- package/dist/core/settings-manager.d.ts +9 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +51 -10
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +51 -33
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +2 -1
- 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 +11 -2
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +16 -3
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +62 -29
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +0 -5
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +2 -5
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +20 -4
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/index.d.ts +4 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +19 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +16 -0
- package/dist/core/tools/powershell.d.ts.map +1 -0
- package/dist/core/tools/powershell.js +39 -0
- package/dist/core/tools/powershell.js.map +1 -0
- package/dist/core/tools/subagent.d.ts.map +1 -1
- package/dist/core/tools/subagent.js +4 -1
- package/dist/core/tools/subagent.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +2 -1
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/extensions/llama/index.d.ts.map +1 -1
- package/dist/extensions/llama/index.js +2 -0
- package/dist/extensions/llama/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +6 -2
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/humain/agent-execution-protocol.d.ts +1 -217
- package/dist/humain/agent-execution-protocol.d.ts.map +1 -1
- package/dist/humain/agent-execution-protocol.js +1 -203
- package/dist/humain/agent-execution-protocol.js.map +1 -1
- package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +107 -16
- package/dist/humain/mcp-adapter/vendor/CHANGELOG.md +82 -0
- package/dist/humain/mcp-adapter/vendor/README.md +47 -15
- package/dist/humain/mcp-adapter/vendor/cli.js +4 -4
- package/dist/humain/mcp-adapter/vendor/commands.ts +5 -3
- package/dist/humain/mcp-adapter/vendor/config.ts +46 -5
- package/dist/humain/mcp-adapter/vendor/direct-tools.ts +103 -92
- package/dist/humain/mcp-adapter/vendor/dist/agent-dir.d.ts +10 -0
- package/dist/humain/mcp-adapter/vendor/dist/agent-dir.js +63 -0
- package/dist/humain/mcp-adapter/vendor/dist/agent-dir.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/agent-plugin-loader.d.ts +8 -0
- package/dist/humain/mcp-adapter/vendor/dist/agent-plugin-loader.js +356 -0
- package/dist/humain/mcp-adapter/vendor/dist/agent-plugin-loader.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/config.d.ts +123 -0
- package/dist/humain/mcp-adapter/vendor/dist/config.js +1088 -0
- package/dist/humain/mcp-adapter/vendor/dist/config.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/mcp-bearer-store.d.ts +24 -0
- package/dist/humain/mcp-adapter/vendor/dist/mcp-bearer-store.js +336 -0
- package/dist/humain/mcp-adapter/vendor/dist/mcp-bearer-store.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/metadata-cache.d.ts +19 -0
- package/dist/humain/mcp-adapter/vendor/dist/metadata-cache.js +319 -0
- package/dist/humain/mcp-adapter/vendor/dist/metadata-cache.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/package-mcp-loader.d.ts +2 -0
- package/dist/humain/mcp-adapter/vendor/dist/package-mcp-loader.js +156 -0
- package/dist/humain/mcp-adapter/vendor/dist/package-mcp-loader.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/resource-tools.d.ts +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/resource-tools.js +15 -0
- package/dist/humain/mcp-adapter/vendor/dist/resource-tools.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/types.d.ts +566 -0
- package/dist/humain/mcp-adapter/vendor/dist/types.js +287 -0
- package/dist/humain/mcp-adapter/vendor/dist/types.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-app-bridge-helpers.d.ts +6 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-app-bridge-helpers.js +37 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-app-bridge-helpers.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-stream-types.d.ts +104 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-stream-types.js +59 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-stream-types.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-tool-visibility.d.ts +4 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-tool-visibility.js +27 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-tool-visibility.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/utils.d.ts +32 -0
- package/dist/humain/mcp-adapter/vendor/dist/utils.js +338 -0
- package/dist/humain/mcp-adapter/vendor/dist/utils.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/failure-backoff.ts +23 -0
- package/dist/humain/mcp-adapter/vendor/index.bundle.mjs +4870 -3878
- package/dist/humain/mcp-adapter/vendor/index.ts +294 -88
- package/dist/humain/mcp-adapter/vendor/init.ts +41 -30
- package/dist/humain/mcp-adapter/vendor/lifecycle.ts +16 -8
- package/dist/humain/mcp-adapter/vendor/mcp-auth-flow.ts +124 -32
- package/dist/humain/mcp-adapter/vendor/mcp-bearer-store.ts +0 -2
- package/dist/humain/mcp-adapter/vendor/mcp-code.ts +2 -0
- package/dist/humain/mcp-adapter/vendor/mcp-oauth-provider.ts +155 -16
- package/dist/humain/mcp-adapter/vendor/mcp-output-guard.ts +95 -7
- package/dist/humain/mcp-adapter/vendor/mcp-probe.ts +18 -4
- package/dist/humain/mcp-adapter/vendor/mcp-references.ts +376 -0
- package/dist/humain/mcp-adapter/vendor/mcp-status.ts +8 -19
- package/dist/humain/mcp-adapter/vendor/metadata-cache.ts +20 -12
- package/dist/humain/mcp-adapter/vendor/namespace-tools.ts +276 -0
- package/dist/humain/mcp-adapter/vendor/package.json +26 -8
- package/dist/humain/mcp-adapter/vendor/proxy-modes.ts +128 -32
- package/dist/humain/mcp-adapter/vendor/request-headers-command.ts +1 -1
- package/dist/humain/mcp-adapter/vendor/search-ranking.ts +2 -0
- package/dist/humain/mcp-adapter/vendor/server-manager.ts +69 -12
- package/dist/humain/mcp-adapter/vendor/state.ts +1 -3
- package/dist/humain/mcp-adapter/vendor/tool-result-renderer.ts +16 -2
- package/dist/humain/mcp-adapter/vendor/types.ts +51 -2
- package/dist/humain/mcp-adapter/vendor/ui-server.ts +3 -19
- package/dist/humain/mcp-adapter/vendor/ui-session.ts +2 -1
- package/dist/humain/mcp-adapter/vendor/utils.ts +21 -19
- package/dist/humain/mcp-adapter.d.ts.map +1 -1
- package/dist/humain/mcp-adapter.js +4 -0
- package/dist/humain/mcp-adapter.js.map +1 -1
- package/dist/humain/web-access/vendor/chrome-cookies.d.ts +14 -0
- package/dist/humain/web-access/vendor/chrome-cookies.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/chrome-cookies.js +85 -33
- package/dist/humain/web-access/vendor/chrome-cookies.js.map +1 -1
- package/dist/humain/web-access/vendor/credential-source.d.ts +1 -1
- package/dist/humain/web-access/vendor/credential-source.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/credential-source.js +3 -1
- package/dist/humain/web-access/vendor/credential-source.js.map +1 -1
- package/dist/humain/web-access/vendor/curator-page.d.ts +2 -29
- package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/curator-page.js +10 -1
- package/dist/humain/web-access/vendor/curator-page.js.map +1 -1
- package/dist/humain/web-access/vendor/curator-server.d.ts +2 -29
- package/dist/humain/web-access/vendor/curator-server.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/curator-server.js +4 -0
- package/dist/humain/web-access/vendor/curator-server.js.map +1 -1
- package/dist/humain/web-access/vendor/extract.d.ts +11 -0
- package/dist/humain/web-access/vendor/extract.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/extract.js +163 -20
- package/dist/humain/web-access/vendor/extract.js.map +1 -1
- package/dist/humain/web-access/vendor/fetch-params.d.ts +2 -0
- package/dist/humain/web-access/vendor/fetch-params.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/fetch-params.js +11 -0
- package/dist/humain/web-access/vendor/fetch-params.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-adc.d.ts +10 -0
- package/dist/humain/web-access/vendor/gemini-adc.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/gemini-adc.js +268 -0
- package/dist/humain/web-access/vendor/gemini-adc.js.map +1 -0
- package/dist/humain/web-access/vendor/gemini-api.d.ts +7 -1
- package/dist/humain/web-access/vendor/gemini-api.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-api.js +51 -15
- package/dist/humain/web-access/vendor/gemini-api.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-search.d.ts +9 -4
- package/dist/humain/web-access/vendor/gemini-search.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-search.js +63 -21
- package/dist/humain/web-access/vendor/gemini-search.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-url-context.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-url-context.js +3 -2
- package/dist/humain/web-access/vendor/gemini-url-context.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-web-config.d.ts +8 -1
- package/dist/humain/web-access/vendor/gemini-web-config.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-web-config.js +49 -4
- package/dist/humain/web-access/vendor/gemini-web-config.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-web.d.ts +2 -1
- package/dist/humain/web-access/vendor/gemini-web.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-web.js +8 -3
- package/dist/humain/web-access/vendor/gemini-web.js.map +1 -1
- package/dist/humain/web-access/vendor/github-api.d.ts +1 -1
- package/dist/humain/web-access/vendor/github-api.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/github-api.js +6 -4
- package/dist/humain/web-access/vendor/github-api.js.map +1 -1
- package/dist/humain/web-access/vendor/github-extract.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/github-extract.js +50 -3
- package/dist/humain/web-access/vendor/github-extract.js.map +1 -1
- package/dist/humain/web-access/vendor/github-issue-pr.d.ts +27 -0
- package/dist/humain/web-access/vendor/github-issue-pr.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/github-issue-pr.js +701 -0
- package/dist/humain/web-access/vendor/github-issue-pr.js.map +1 -0
- package/dist/humain/web-access/vendor/index.d.ts +3 -31
- package/dist/humain/web-access/vendor/index.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/index.js +643 -530
- package/dist/humain/web-access/vendor/index.js.map +1 -1
- package/dist/humain/web-access/vendor/kimi-search.d.ts +5 -0
- package/dist/humain/web-access/vendor/kimi-search.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/kimi-search.js +228 -0
- package/dist/humain/web-access/vendor/kimi-search.js.map +1 -0
- package/dist/humain/web-access/vendor/openai-search.d.ts +3 -0
- package/dist/humain/web-access/vendor/openai-search.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/openai-search.js +89 -16
- package/dist/humain/web-access/vendor/openai-search.js.map +1 -1
- package/dist/humain/web-access/vendor/page-query.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/page-query.js +56 -8
- package/dist/humain/web-access/vendor/page-query.js.map +1 -1
- package/dist/humain/web-access/vendor/ssrf-protection.js +6 -1
- package/dist/humain/web-access/vendor/ssrf-protection.js.map +1 -1
- package/dist/humain/web-access/vendor/utils.d.ts +12 -0
- package/dist/humain/web-access/vendor/utils.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/utils.js +343 -1
- package/dist/humain/web-access/vendor/utils.js.map +1 -1
- package/dist/humain/web-access/vendor/xcrawl.d.ts +4 -0
- package/dist/humain/web-access/vendor/xcrawl.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/xcrawl.js +251 -0
- package/dist/humain/web-access/vendor/xcrawl.js.map +1 -0
- package/dist/humain/web-access/vendor/youtube-extract.js +2 -2
- package/dist/humain/web-access/vendor/youtube-extract.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +17 -14
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +4 -3
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +9 -3
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +53 -10
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +7 -2
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +118 -55
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts +72 -0
- package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-submenu.js +151 -0
- package/dist/modes/interactive/components/settings-submenu.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +15 -3
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +68 -17
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +2 -1
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +11 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +176 -106
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/session-share.d.ts +16 -0
- package/dist/modes/interactive/session-share.d.ts.map +1 -0
- package/dist/modes/interactive/session-share.js +188 -0
- package/dist/modes/interactive/session-share.js.map +1 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +6 -5
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/json-event.d.ts +16 -13
- package/dist/modes/json-event.d.ts.map +1 -1
- package/dist/modes/json-event.js +20 -6
- package/dist/modes/json-event.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +3 -2
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +2 -7
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts +1 -0
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +189 -3
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/changelog.d.ts +1 -1
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js +12 -2
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js +2 -1
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/management-http.d.ts +5 -3
- package/dist/utils/management-http.d.ts.map +1 -1
- package/dist/utils/management-http.js +14 -10
- package/dist/utils/management-http.js.map +1 -1
- package/dist/utils/shell.d.ts +3 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +17 -5
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts +1 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +64 -1
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/text.d.ts +8 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/text.js +9 -0
- package/dist/utils/text.js.map +1 -0
- package/dist/utils/version-check.js +4 -4
- package/dist/utils/version-check.js.map +1 -1
- package/docs/compaction.md +15 -0
- package/docs/custom-provider.md +5 -2
- package/docs/environment-variables.md +7 -7
- package/docs/extensions.md +17 -7
- package/docs/json.md +7 -2
- package/docs/keybindings.md +8 -8
- package/docs/llama-cpp.md +2 -0
- package/docs/models.md +8 -2
- package/docs/packages.md +2 -2
- package/docs/rpc.md +9 -3
- package/docs/sdk.md +7 -2
- package/docs/settings.md +11 -3
- package/docs/skills.md +3 -2
- package/docs/terminal-setup.md +8 -0
- package/docs/usage.md +10 -7
- package/docs/windows.md +15 -1
- package/examples/extensions/border-status-editor.ts +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +70 -8
- package/examples/extensions/custom-provider-anthropic/package.json +2 -2
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/git-checkpoint.ts +2 -2
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/notify.ts +3 -1
- package/examples/extensions/sandbox/package-lock.json +14 -40
- package/examples/extensions/sandbox/package.json +2 -2
- package/examples/extensions/titlebar-spinner.ts +1 -1
- package/examples/extensions/with-deps/package-lock.json +4 -4
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/rpc-extension-ui.ts +1 -1
- package/examples/sdk/06-extensions.ts +1 -1
- package/examples/sdk/README.md +1 -1
- package/npm-shrinkwrap.json +293 -221
- package/package.json +21 -18
- package/src/humain/mcp-adapter/UPSTREAM.md +15 -5
- package/src/humain/mcp-adapter/upstream.json +4 -3
- package/src/humain/mcp-adapter/vendor/CHANGELOG.md +82 -0
- package/src/humain/web-access/UPSTREAM.md +1 -1
- package/src/humain/web-access/upstream.json +6 -4
|
@@ -12,26 +12,26 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Modes use this class and add their own I/O layer on top.
|
|
14
14
|
*/
|
|
15
|
-
import {
|
|
15
|
+
import { readFileSync } from "node:fs";
|
|
16
16
|
import { basename, dirname } from "node:path";
|
|
17
17
|
import { contentText } from "@earendil-works/pi-ai";
|
|
18
18
|
import { clampThinkingLevel, cleanupSessionResources, getSupportedThinkingLevels, isContextOverflow, isRecoverableLength, isRetryableAssistantError, modelsAreEqual, resetApiProviders, streamSimple, } from "@earendil-works/pi-ai/compat";
|
|
19
19
|
import { getThemeByName, theme } from "../modes/interactive/theme/theme.js";
|
|
20
20
|
import { stripFrontmatter } from "../utils/frontmatter.js";
|
|
21
|
-
import { resolvePath } from "../utils/paths.js";
|
|
22
21
|
import { sleep } from "../utils/sleep.js";
|
|
23
22
|
import { normalizeToolResultImages } from "../utils/tool-result-images.js";
|
|
24
23
|
import { formatNoApiKeyFoundMessage, formatNoModelSelectedMessage } from "./auth-guidance.js";
|
|
25
24
|
import { executeBashWithOperations } from "./bash-executor.js";
|
|
26
25
|
import { calculateContextTokens, collectEntriesForBranchSummary, compact, estimateContextTokens, estimateTokens, generateBranchSummary, prepareCompaction, shouldCompact, } from "./compaction/index.js";
|
|
27
|
-
import { DEFAULT_THINKING_LEVEL } from "./defaults.js";
|
|
26
|
+
import { DEFAULT_THINKING_LEVEL, THINKING_LEVEL_OPTIONS } from "./defaults.js";
|
|
28
27
|
import { exportSessionToHtml } from "./export-html/index.js";
|
|
29
28
|
import { createToolHtmlRenderer } from "./export-html/tool-renderer.js";
|
|
30
29
|
import { ExtensionRunner, wrapRegisteredTools, } from "./extensions/index.js";
|
|
31
30
|
import { emitSessionShutdownEvent } from "./extensions/runner.js";
|
|
32
31
|
import { ModelRegistry } from "./model-registry.js";
|
|
33
32
|
import { expandPromptTemplate } from "./prompt-templates.js";
|
|
34
|
-
import {
|
|
33
|
+
import { exportSessionToJsonl } from "./session-export.js";
|
|
34
|
+
import { getLatestCompactionEntry } from "./session-manager.js";
|
|
35
35
|
import { createSyntheticSourceInfo } from "./source-info.js";
|
|
36
36
|
import { buildSystemPrompt } from "./system-prompt.js";
|
|
37
37
|
import { createLocalBashOperations } from "./tools/bash.js";
|
|
@@ -71,8 +71,6 @@ function estimateMessagesTokens(messages) {
|
|
|
71
71
|
// ============================================================================
|
|
72
72
|
// Constants
|
|
73
73
|
// ============================================================================
|
|
74
|
-
/** Standard thinking levels */
|
|
75
|
-
const THINKING_LEVELS = ["off", "minimal", "low", "medium", "high"];
|
|
76
74
|
// ============================================================================
|
|
77
75
|
// AgentSession Class
|
|
78
76
|
// ============================================================================
|
|
@@ -343,6 +341,11 @@ export class AgentSession {
|
|
|
343
341
|
followUp: [...this._followUpMessages],
|
|
344
342
|
});
|
|
345
343
|
}
|
|
344
|
+
async _emitSessionCompactFailed(event) {
|
|
345
|
+
if (this._extensionRunner.hasHandlers("session_compact_failed")) {
|
|
346
|
+
await this._extensionRunner.emit({ type: "session_compact_failed", ...event });
|
|
347
|
+
}
|
|
348
|
+
}
|
|
346
349
|
_getIdleWaitPromise() {
|
|
347
350
|
if (!this._idleWaitPromise) {
|
|
348
351
|
this._idleWaitPromise = new Promise((resolve) => {
|
|
@@ -1169,19 +1172,24 @@ export class AgentSession {
|
|
|
1169
1172
|
}
|
|
1170
1173
|
/**
|
|
1171
1174
|
* Set model directly.
|
|
1172
|
-
* Validates that auth is configured
|
|
1175
|
+
* Validates that auth is configured and saves to the session transcript.
|
|
1176
|
+
* Persists to global defaults only when options.persist is true.
|
|
1173
1177
|
* @throws Error if no auth is configured for the model
|
|
1174
1178
|
*/
|
|
1175
|
-
async setModel(model) {
|
|
1179
|
+
async setModel(model, options = {}) {
|
|
1176
1180
|
if (!(await this._modelRuntime.checkAuth(model.provider))) {
|
|
1177
1181
|
throw new Error(`No API key for ${model.provider}/${model.id}`);
|
|
1178
1182
|
}
|
|
1179
1183
|
const previousModel = this.model;
|
|
1180
|
-
const thinkingLevel = this._getThinkingLevelForModelSwitch();
|
|
1184
|
+
const thinkingLevel = this._getThinkingLevelForModelSwitch(model);
|
|
1181
1185
|
this.agent.state.model = model;
|
|
1182
1186
|
this.sessionManager.appendModelChange(model.provider, model.id);
|
|
1183
|
-
|
|
1184
|
-
|
|
1187
|
+
if (options.persist) {
|
|
1188
|
+
this.settingsManager.setDefaultModelAndProvider(model.provider, model.id);
|
|
1189
|
+
}
|
|
1190
|
+
// Apply thinking level for the new model.
|
|
1191
|
+
// Per-model thinking level overrides take priority over the global default.
|
|
1192
|
+
// Model persistence does not implicitly rewrite the global thinking default.
|
|
1185
1193
|
this.setThinkingLevel(thinkingLevel);
|
|
1186
1194
|
await this._emitModelSelect(model, previousModel, "set");
|
|
1187
1195
|
}
|
|
@@ -1191,13 +1199,13 @@ export class AgentSession {
|
|
|
1191
1199
|
* @param direction - "forward" (default) or "backward"
|
|
1192
1200
|
* @returns The new model info, or undefined if only one model available
|
|
1193
1201
|
*/
|
|
1194
|
-
async cycleModel(direction = "forward") {
|
|
1202
|
+
async cycleModel(direction = "forward", options = {}) {
|
|
1195
1203
|
if (this._scopedModels.length > 0) {
|
|
1196
|
-
return this._cycleScopedModel(direction);
|
|
1204
|
+
return this._cycleScopedModel(direction, options);
|
|
1197
1205
|
}
|
|
1198
|
-
return this._cycleAvailableModel(direction);
|
|
1206
|
+
return this._cycleAvailableModel(direction, options);
|
|
1199
1207
|
}
|
|
1200
|
-
async _cycleScopedModel(direction) {
|
|
1208
|
+
async _cycleScopedModel(direction, options) {
|
|
1201
1209
|
const availableIds = new Set(this._modelRuntime.getAvailableSnapshot().map((model) => `${model.provider}\0${model.id}`));
|
|
1202
1210
|
const scopedModels = this._scopedModels.filter((scoped) => availableIds.has(`${scoped.model.provider}\0${scoped.model.id}`));
|
|
1203
1211
|
if (scopedModels.length <= 1)
|
|
@@ -1209,20 +1217,23 @@ export class AgentSession {
|
|
|
1209
1217
|
const len = scopedModels.length;
|
|
1210
1218
|
const nextIndex = direction === "forward" ? (currentIndex + 1) % len : (currentIndex - 1 + len) % len;
|
|
1211
1219
|
const next = scopedModels[nextIndex];
|
|
1212
|
-
const thinkingLevel = this._getThinkingLevelForModelSwitch(next.thinkingLevel);
|
|
1220
|
+
const thinkingLevel = this._getThinkingLevelForModelSwitch(next.model, next.thinkingLevel);
|
|
1213
1221
|
// Apply model
|
|
1214
1222
|
this.agent.state.model = next.model;
|
|
1215
1223
|
this.sessionManager.appendModelChange(next.model.provider, next.model.id);
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
//
|
|
1224
|
+
if (options.persist) {
|
|
1225
|
+
this.settingsManager.setDefaultModelAndProvider(next.model.provider, next.model.id);
|
|
1226
|
+
}
|
|
1227
|
+
// Apply thinking level for the new model.
|
|
1228
|
+
// - Explicit scoped model thinking level overrides defaults
|
|
1229
|
+
// - Per-model thinking level overrides take priority over the global default
|
|
1220
1230
|
// setThinkingLevel clamps to model capabilities.
|
|
1231
|
+
// Model persistence does not implicitly rewrite the global thinking default.
|
|
1221
1232
|
this.setThinkingLevel(thinkingLevel);
|
|
1222
1233
|
await this._emitModelSelect(next.model, currentModel, "cycle");
|
|
1223
1234
|
return { model: next.model, thinkingLevel: this.thinkingLevel, isScoped: true };
|
|
1224
1235
|
}
|
|
1225
|
-
async _cycleAvailableModel(direction) {
|
|
1236
|
+
async _cycleAvailableModel(direction, options) {
|
|
1226
1237
|
const availableModels = this._modelRuntime.getAvailableSnapshot();
|
|
1227
1238
|
if (availableModels.length <= 1)
|
|
1228
1239
|
return undefined;
|
|
@@ -1233,11 +1244,14 @@ export class AgentSession {
|
|
|
1233
1244
|
const len = availableModels.length;
|
|
1234
1245
|
const nextIndex = direction === "forward" ? (currentIndex + 1) % len : (currentIndex - 1 + len) % len;
|
|
1235
1246
|
const nextModel = availableModels[nextIndex];
|
|
1236
|
-
const thinkingLevel = this._getThinkingLevelForModelSwitch();
|
|
1247
|
+
const thinkingLevel = this._getThinkingLevelForModelSwitch(nextModel);
|
|
1237
1248
|
this.agent.state.model = nextModel;
|
|
1238
1249
|
this.sessionManager.appendModelChange(nextModel.provider, nextModel.id);
|
|
1239
|
-
|
|
1240
|
-
|
|
1250
|
+
if (options.persist) {
|
|
1251
|
+
this.settingsManager.setDefaultModelAndProvider(nextModel.provider, nextModel.id);
|
|
1252
|
+
}
|
|
1253
|
+
// Apply thinking level for the new model.
|
|
1254
|
+
// Model persistence does not implicitly rewrite the global thinking default.
|
|
1241
1255
|
this.setThinkingLevel(thinkingLevel);
|
|
1242
1256
|
await this._emitModelSelect(nextModel, currentModel, "cycle");
|
|
1243
1257
|
return { model: nextModel, thinkingLevel: this.thinkingLevel, isScoped: false };
|
|
@@ -1248,20 +1262,21 @@ export class AgentSession {
|
|
|
1248
1262
|
/**
|
|
1249
1263
|
* Set thinking level.
|
|
1250
1264
|
* Clamps to model capabilities based on available thinking levels.
|
|
1251
|
-
* Saves to session
|
|
1265
|
+
* Saves the clamped level to the session transcript only if the level actually changes.
|
|
1266
|
+
* Persists the requested level to global defaults only when options.persist is true.
|
|
1252
1267
|
*/
|
|
1253
|
-
setThinkingLevel(level) {
|
|
1268
|
+
setThinkingLevel(level, options = {}) {
|
|
1254
1269
|
const availableLevels = this.getAvailableThinkingLevels();
|
|
1255
1270
|
const effectiveLevel = availableLevels.includes(level) ? level : this._clampThinkingLevel(level, availableLevels);
|
|
1256
1271
|
// Only persist if actually changing
|
|
1257
1272
|
const previousLevel = this.agent.state.thinkingLevel;
|
|
1258
1273
|
const isChanging = effectiveLevel !== previousLevel;
|
|
1259
1274
|
this.agent.state.thinkingLevel = effectiveLevel;
|
|
1275
|
+
if (options.persist) {
|
|
1276
|
+
this.settingsManager.setDefaultThinkingLevel(level);
|
|
1277
|
+
}
|
|
1260
1278
|
if (isChanging) {
|
|
1261
1279
|
this.sessionManager.appendThinkingLevelChange(effectiveLevel);
|
|
1262
|
-
if (this.supportsThinking() || effectiveLevel !== "off") {
|
|
1263
|
-
this.settingsManager.setDefaultThinkingLevel(effectiveLevel);
|
|
1264
|
-
}
|
|
1265
1280
|
this._emit({ type: "thinking_level_changed", level: effectiveLevel });
|
|
1266
1281
|
void this._extensionRunner.emit({
|
|
1267
1282
|
type: "thinking_level_select",
|
|
@@ -1274,14 +1289,14 @@ export class AgentSession {
|
|
|
1274
1289
|
* Cycle to next thinking level.
|
|
1275
1290
|
* @returns New level, or undefined if model doesn't support thinking
|
|
1276
1291
|
*/
|
|
1277
|
-
cycleThinkingLevel() {
|
|
1292
|
+
cycleThinkingLevel(options = {}) {
|
|
1278
1293
|
if (!this.supportsThinking())
|
|
1279
1294
|
return undefined;
|
|
1280
1295
|
const levels = this.getAvailableThinkingLevels();
|
|
1281
1296
|
const currentIndex = levels.indexOf(this.thinkingLevel);
|
|
1282
1297
|
const nextIndex = (currentIndex + 1) % levels.length;
|
|
1283
1298
|
const nextLevel = levels[nextIndex];
|
|
1284
|
-
this.setThinkingLevel(nextLevel);
|
|
1299
|
+
this.setThinkingLevel(nextLevel, options);
|
|
1285
1300
|
return nextLevel;
|
|
1286
1301
|
}
|
|
1287
1302
|
/**
|
|
@@ -1290,7 +1305,7 @@ export class AgentSession {
|
|
|
1290
1305
|
*/
|
|
1291
1306
|
getAvailableThinkingLevels() {
|
|
1292
1307
|
if (!this.model)
|
|
1293
|
-
return
|
|
1308
|
+
return [...THINKING_LEVEL_OPTIONS];
|
|
1294
1309
|
return getSupportedThinkingLevels(this.model);
|
|
1295
1310
|
}
|
|
1296
1311
|
/**
|
|
@@ -1299,14 +1314,18 @@ export class AgentSession {
|
|
|
1299
1314
|
supportsThinking() {
|
|
1300
1315
|
return !!this.model?.reasoning;
|
|
1301
1316
|
}
|
|
1302
|
-
_getThinkingLevelForModelSwitch(explicitLevel) {
|
|
1317
|
+
_getThinkingLevelForModelSwitch(targetModel, explicitLevel) {
|
|
1303
1318
|
if (explicitLevel !== undefined) {
|
|
1304
1319
|
return explicitLevel;
|
|
1305
1320
|
}
|
|
1306
|
-
|
|
1307
|
-
|
|
1321
|
+
// Per-model default takes priority when switching to a model that has one
|
|
1322
|
+
if (targetModel) {
|
|
1323
|
+
const perModel = this.settingsManager.getModelThinkingLevel(targetModel.provider, targetModel.id);
|
|
1324
|
+
if (perModel !== undefined) {
|
|
1325
|
+
return perModel;
|
|
1326
|
+
}
|
|
1308
1327
|
}
|
|
1309
|
-
return this.thinkingLevel;
|
|
1328
|
+
return this.settingsManager.getDefaultThinkingLevel() ?? this.thinkingLevel ?? DEFAULT_THINKING_LEVEL;
|
|
1310
1329
|
}
|
|
1311
1330
|
_clampThinkingLevel(level, _availableLevels) {
|
|
1312
1331
|
return this.model ? clampThinkingLevel(this.model, level) : "off";
|
|
@@ -1337,15 +1356,30 @@ export class AgentSession {
|
|
|
1337
1356
|
// =========================================================================
|
|
1338
1357
|
// Compaction
|
|
1339
1358
|
// =========================================================================
|
|
1359
|
+
/** Generate Pi's built-in compaction summary for manual and automatic compaction. */
|
|
1360
|
+
async _runDefaultCompaction(preparation, requestModel, apiKey, headers, customInstructions, signal, env, reason) {
|
|
1361
|
+
return compact(preparation, requestModel, apiKey, headers, customInstructions, signal, this.thinkingLevel, this.agent.streamFunction, env, this.settingsManager.getRetrySettings(), this._summarizationRetryCallbacks({ source: "compaction", reason }), undefined);
|
|
1362
|
+
}
|
|
1340
1363
|
/**
|
|
1341
1364
|
* Manually compact the session context.
|
|
1342
|
-
*
|
|
1365
|
+
*
|
|
1366
|
+
* This is the manual entry point used by `/compact`, RPC, and extensions. It is
|
|
1367
|
+
* separate from automatic threshold/overflow compaction, which enters through
|
|
1368
|
+
* `_checkCompaction()` and `_runAutoCompaction()`. After preparation and the
|
|
1369
|
+
* `session_before_compact` hook, both paths call the lower-level `compact()`
|
|
1370
|
+
* function imported from `./compaction/index.ts`, unless the hook cancels or
|
|
1371
|
+
* supplies a custom result.
|
|
1372
|
+
*
|
|
1373
|
+
* Aborts the current agent operation first. Manual compaction never retries or
|
|
1374
|
+
* continues the interrupted agent turn.
|
|
1375
|
+
*
|
|
1343
1376
|
* @param customInstructions Optional instructions for the compaction summary
|
|
1344
1377
|
*/
|
|
1345
1378
|
async compact(customInstructions) {
|
|
1346
1379
|
await this.abort();
|
|
1347
1380
|
this._compactionAbortController = new AbortController();
|
|
1348
1381
|
this._emit({ type: "compaction_start", reason: "manual" });
|
|
1382
|
+
let fromExtension = false;
|
|
1349
1383
|
try {
|
|
1350
1384
|
if (!this.model) {
|
|
1351
1385
|
throw new Error(formatNoModelSelectedMessage());
|
|
@@ -1363,7 +1397,6 @@ export class AgentSession {
|
|
|
1363
1397
|
throw new Error("Nothing to compact (session too small)");
|
|
1364
1398
|
}
|
|
1365
1399
|
let extensionCompaction;
|
|
1366
|
-
let fromExtension = false;
|
|
1367
1400
|
if (this._extensionRunner.hasHandlers("session_before_compact")) {
|
|
1368
1401
|
const result = (await this._extensionRunner.emit({
|
|
1369
1402
|
type: "session_before_compact",
|
|
@@ -1396,8 +1429,8 @@ export class AgentSession {
|
|
|
1396
1429
|
details = extensionCompaction.details;
|
|
1397
1430
|
}
|
|
1398
1431
|
else {
|
|
1399
|
-
//
|
|
1400
|
-
const result = await
|
|
1432
|
+
// Shared default summary generator, also used by automatic compaction.
|
|
1433
|
+
const result = await this._runDefaultCompaction(preparation, requestModel, apiKey, headers, customInstructions, this._compactionAbortController.signal, env, "manual");
|
|
1401
1434
|
summary = result.summary;
|
|
1402
1435
|
firstKeptEntryId = result.firstKeptEntryId;
|
|
1403
1436
|
tokensBefore = result.tokensBefore;
|
|
@@ -1445,6 +1478,7 @@ export class AgentSession {
|
|
|
1445
1478
|
catch (error) {
|
|
1446
1479
|
const message = error instanceof Error ? error.message : String(error);
|
|
1447
1480
|
const aborted = message === "Compaction cancelled" || (error instanceof Error && error.name === "AbortError");
|
|
1481
|
+
const errorMessage = aborted ? undefined : `Compaction failed: ${message}`;
|
|
1448
1482
|
this._compactionAbortController = undefined;
|
|
1449
1483
|
this._emit({
|
|
1450
1484
|
type: "compaction_end",
|
|
@@ -1452,7 +1486,14 @@ export class AgentSession {
|
|
|
1452
1486
|
result: undefined,
|
|
1453
1487
|
aborted,
|
|
1454
1488
|
willRetry: false,
|
|
1455
|
-
errorMessage
|
|
1489
|
+
errorMessage,
|
|
1490
|
+
});
|
|
1491
|
+
await this._emitSessionCompactFailed({
|
|
1492
|
+
reason: "manual",
|
|
1493
|
+
errorMessage,
|
|
1494
|
+
aborted,
|
|
1495
|
+
willRetry: false,
|
|
1496
|
+
fromExtension,
|
|
1456
1497
|
});
|
|
1457
1498
|
throw error;
|
|
1458
1499
|
}
|
|
@@ -1474,16 +1515,25 @@ export class AgentSession {
|
|
|
1474
1515
|
this._branchSummaryAbortController?.abort();
|
|
1475
1516
|
}
|
|
1476
1517
|
/**
|
|
1477
|
-
*
|
|
1478
|
-
*
|
|
1518
|
+
* Dispatch automatic compaction after `agent_end` or before prompt submission.
|
|
1519
|
+
* Manual compaction does not call this method; it enters through `compact()`.
|
|
1520
|
+
*
|
|
1521
|
+
* Automatic cases:
|
|
1522
|
+
* 1. Overflow with retry: a context-overflow error or recoverable length stop;
|
|
1523
|
+
* remove the failed assistant message, compact, and retry the turn once.
|
|
1524
|
+
* 2. Overflow without retry: a successful response exceeded the configured
|
|
1525
|
+
* context window; compact but preserve the completed response.
|
|
1526
|
+
* 3. Threshold without retry: valid or estimated context usage crossed the
|
|
1527
|
+
* configured threshold; compact without retrying the completed response.
|
|
1479
1528
|
*
|
|
1480
|
-
*
|
|
1481
|
-
*
|
|
1482
|
-
*
|
|
1483
|
-
*
|
|
1529
|
+
* Each case calls `_runAutoCompaction()`. After preparation and the
|
|
1530
|
+
* `session_before_compact` hook, that method calls the lower-level `compact()`
|
|
1531
|
+
* function imported from `./compaction/index.ts`, unless the hook cancels or
|
|
1532
|
+
* supplies a custom result.
|
|
1484
1533
|
*
|
|
1485
1534
|
* @param assistantMessage The assistant message to check
|
|
1486
1535
|
* @param skipAbortedCheck If false, include aborted messages (for pre-prompt check). Default: true
|
|
1536
|
+
* @returns Whether the post-run loop should call `agent.continue()` for overflow recovery or queued messages
|
|
1487
1537
|
*/
|
|
1488
1538
|
async _checkCompaction(assistantMessage, skipAbortedCheck = true) {
|
|
1489
1539
|
const settings = this.settingsManager.getCompactionSettings();
|
|
@@ -1506,38 +1556,49 @@ export class AgentSession {
|
|
|
1506
1556
|
if (assistantIsFromBeforeCompaction) {
|
|
1507
1557
|
return false;
|
|
1508
1558
|
}
|
|
1509
|
-
//
|
|
1559
|
+
// Automatic cases 1 and 2: context overflow.
|
|
1510
1560
|
// A length stop is recoverable when output ended below the model's original desired limit,
|
|
1511
1561
|
// independent of the configured context size or any context-clamped provider request limit.
|
|
1512
|
-
|
|
1513
|
-
// assistant answer already completed and agent.continue() cannot continue from an assistant.
|
|
1562
|
+
const contextOverflow = sameModel && isContextOverflow(assistantMessage, contextWindow);
|
|
1514
1563
|
const recoverableLength = sameModel && isRecoverableLength(assistantMessage, this.model?.maxTokens ?? 0);
|
|
1515
|
-
if (
|
|
1564
|
+
if (contextOverflow || recoverableLength) {
|
|
1516
1565
|
const willRetry = assistantMessage.stopReason !== "stop";
|
|
1566
|
+
// Case 2: the response completed successfully. Compact, but do not retry because
|
|
1567
|
+
// agent.continue() cannot continue from a completed assistant response.
|
|
1517
1568
|
if (!willRetry) {
|
|
1518
1569
|
return await this._runAutoCompaction("overflow", false);
|
|
1519
1570
|
}
|
|
1520
1571
|
if (this._overflowRecoveryAttempted) {
|
|
1572
|
+
const errorMessage = contextOverflow
|
|
1573
|
+
? "Context overflow recovery failed after one compact-and-retry attempt. Try reducing context or switching to a larger-context model."
|
|
1574
|
+
: "Truncated response recovery failed after one compact-and-retry attempt.";
|
|
1521
1575
|
this._emit({
|
|
1522
1576
|
type: "compaction_end",
|
|
1523
1577
|
reason: "overflow",
|
|
1524
1578
|
result: undefined,
|
|
1525
1579
|
aborted: false,
|
|
1526
1580
|
willRetry: false,
|
|
1527
|
-
errorMessage
|
|
1581
|
+
errorMessage,
|
|
1582
|
+
});
|
|
1583
|
+
await this._emitSessionCompactFailed({
|
|
1584
|
+
reason: "overflow",
|
|
1585
|
+
errorMessage,
|
|
1586
|
+
aborted: false,
|
|
1587
|
+
willRetry: false,
|
|
1588
|
+
fromExtension: false,
|
|
1528
1589
|
});
|
|
1529
1590
|
return false;
|
|
1530
1591
|
}
|
|
1592
|
+
// Case 1: remove the failed or truncated message from agent state, compact, and
|
|
1593
|
+
// retry once. The message remains in session history but is excluded from retry context.
|
|
1531
1594
|
this._overflowRecoveryAttempted = true;
|
|
1532
|
-
// Remove the failed or truncated message from agent state. It remains in session history,
|
|
1533
|
-
// but must not be included in the compact-and-retry context.
|
|
1534
1595
|
const messages = this.agent.state.messages;
|
|
1535
1596
|
if (messages.length > 0 && messages[messages.length - 1].role === "assistant") {
|
|
1536
1597
|
this.agent.state.messages = messages.slice(0, -1);
|
|
1537
1598
|
}
|
|
1538
1599
|
return await this._runAutoCompaction("overflow", willRetry);
|
|
1539
1600
|
}
|
|
1540
|
-
// Case
|
|
1601
|
+
// Case 3: threshold compaction without retry.
|
|
1541
1602
|
// For error messages or all-zero usage messages, estimate from the last valid response.
|
|
1542
1603
|
// This ensures sessions that hit persistent API errors (e.g. 529) or malformed zero-usage
|
|
1543
1604
|
// responses can still compact and do not reset context accounting.
|
|
@@ -1546,16 +1607,18 @@ export class AgentSession {
|
|
|
1546
1607
|
if (assistantMessage.stopReason === "error" || directContextTokens === 0) {
|
|
1547
1608
|
const messages = this.agent.state.messages;
|
|
1548
1609
|
const estimate = estimateContextTokens(messages);
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1610
|
+
// Without provider usage, estimate.tokens is the pure message-size estimate.
|
|
1611
|
+
// Only usage-backed estimates need the stale pre-compaction check.
|
|
1612
|
+
if (estimate.lastUsageIndex !== null) {
|
|
1613
|
+
// Verify the usage source is post-compaction. Kept pre-compaction messages
|
|
1614
|
+
// have stale usage reflecting the old (larger) context and would falsely
|
|
1615
|
+
// trigger compaction right after one just finished.
|
|
1616
|
+
const usageMsg = messages[estimate.lastUsageIndex];
|
|
1617
|
+
if (compactionEntry &&
|
|
1618
|
+
usageMsg.role === "assistant" &&
|
|
1619
|
+
usageMsg.timestamp <= new Date(compactionEntry.timestamp).getTime()) {
|
|
1620
|
+
return false;
|
|
1621
|
+
}
|
|
1559
1622
|
}
|
|
1560
1623
|
contextTokens = estimate.tokens;
|
|
1561
1624
|
}
|
|
@@ -1568,11 +1631,19 @@ export class AgentSession {
|
|
|
1568
1631
|
return false;
|
|
1569
1632
|
}
|
|
1570
1633
|
/**
|
|
1571
|
-
*
|
|
1634
|
+
* Execute threshold or overflow compaction. Manual compaction uses
|
|
1635
|
+
* `AgentSession.compact()` instead. Both paths call the lower-level `compact()`
|
|
1636
|
+
* function imported from `./compaction/index.ts` after preparation and extension
|
|
1637
|
+
* interception.
|
|
1638
|
+
*
|
|
1639
|
+
* @param reason Automatic trigger selected by `_checkCompaction()`
|
|
1640
|
+
* @param willRetry Whether to continue the interrupted turn after overflow compaction
|
|
1641
|
+
* @returns Whether the post-run loop should call `agent.continue()`
|
|
1572
1642
|
*/
|
|
1573
1643
|
async _runAutoCompaction(reason, willRetry) {
|
|
1574
1644
|
const settings = this.settingsManager.getCompactionSettings();
|
|
1575
1645
|
let started = false;
|
|
1646
|
+
let fromExtension = false;
|
|
1576
1647
|
try {
|
|
1577
1648
|
if (!this.model) {
|
|
1578
1649
|
return false;
|
|
@@ -1587,7 +1658,6 @@ export class AgentSession {
|
|
|
1587
1658
|
this._autoCompactionAbortController = new AbortController();
|
|
1588
1659
|
started = true;
|
|
1589
1660
|
let extensionCompaction;
|
|
1590
|
-
let fromExtension = false;
|
|
1591
1661
|
if (this._extensionRunner.hasHandlers("session_before_compact")) {
|
|
1592
1662
|
const extensionResult = (await this._extensionRunner.emit({
|
|
1593
1663
|
type: "session_before_compact",
|
|
@@ -1606,6 +1676,12 @@ export class AgentSession {
|
|
|
1606
1676
|
aborted: true,
|
|
1607
1677
|
willRetry: false,
|
|
1608
1678
|
});
|
|
1679
|
+
await this._emitSessionCompactFailed({
|
|
1680
|
+
reason,
|
|
1681
|
+
aborted: true,
|
|
1682
|
+
willRetry: false,
|
|
1683
|
+
fromExtension: false,
|
|
1684
|
+
});
|
|
1609
1685
|
return false;
|
|
1610
1686
|
}
|
|
1611
1687
|
if (extensionResult?.compaction) {
|
|
@@ -1627,8 +1703,8 @@ export class AgentSession {
|
|
|
1627
1703
|
details = extensionCompaction.details;
|
|
1628
1704
|
}
|
|
1629
1705
|
else {
|
|
1630
|
-
//
|
|
1631
|
-
const compactResult = await
|
|
1706
|
+
// Shared default summary generator, also used by manual compaction.
|
|
1707
|
+
const compactResult = await this._runDefaultCompaction(preparation, requestModel, apiKey, headers, undefined, this._autoCompactionAbortController.signal, env, reason);
|
|
1632
1708
|
summary = compactResult.summary;
|
|
1633
1709
|
firstKeptEntryId = compactResult.firstKeptEntryId;
|
|
1634
1710
|
tokensBefore = compactResult.tokensBefore;
|
|
@@ -1643,6 +1719,12 @@ export class AgentSession {
|
|
|
1643
1719
|
aborted: true,
|
|
1644
1720
|
willRetry: false,
|
|
1645
1721
|
});
|
|
1722
|
+
await this._emitSessionCompactFailed({
|
|
1723
|
+
reason,
|
|
1724
|
+
aborted: true,
|
|
1725
|
+
willRetry: false,
|
|
1726
|
+
fromExtension,
|
|
1727
|
+
});
|
|
1646
1728
|
return false;
|
|
1647
1729
|
}
|
|
1648
1730
|
this.sessionManager.appendCompaction(summary, firstKeptEntryId, tokensBefore, details, fromExtension, usage);
|
|
@@ -1689,15 +1771,23 @@ export class AgentSession {
|
|
|
1689
1771
|
catch (error) {
|
|
1690
1772
|
const errorMessage = error instanceof Error ? error.message : "compaction failed";
|
|
1691
1773
|
if (started) {
|
|
1774
|
+
const formattedErrorMessage = reason === "overflow"
|
|
1775
|
+
? `Context overflow recovery failed: ${errorMessage}`
|
|
1776
|
+
: `Auto-compaction failed: ${errorMessage}`;
|
|
1692
1777
|
this._emit({
|
|
1693
1778
|
type: "compaction_end",
|
|
1694
1779
|
reason,
|
|
1695
1780
|
result: undefined,
|
|
1696
1781
|
aborted: false,
|
|
1697
1782
|
willRetry: false,
|
|
1698
|
-
errorMessage:
|
|
1699
|
-
|
|
1700
|
-
|
|
1783
|
+
errorMessage: formattedErrorMessage,
|
|
1784
|
+
});
|
|
1785
|
+
await this._emitSessionCompactFailed({
|
|
1786
|
+
reason,
|
|
1787
|
+
errorMessage: formattedErrorMessage,
|
|
1788
|
+
aborted: false,
|
|
1789
|
+
willRetry: false,
|
|
1790
|
+
fromExtension,
|
|
1701
1791
|
});
|
|
1702
1792
|
}
|
|
1703
1793
|
return false;
|
|
@@ -2585,29 +2675,7 @@ export class AgentSession {
|
|
|
2585
2675
|
* @returns The resolved output file path.
|
|
2586
2676
|
*/
|
|
2587
2677
|
exportToJsonl(outputPath) {
|
|
2588
|
-
|
|
2589
|
-
const dir = dirname(filePath);
|
|
2590
|
-
if (!existsSync(dir)) {
|
|
2591
|
-
mkdirSync(dir, { recursive: true });
|
|
2592
|
-
}
|
|
2593
|
-
const header = {
|
|
2594
|
-
type: "session",
|
|
2595
|
-
version: CURRENT_SESSION_VERSION,
|
|
2596
|
-
id: this.sessionManager.getSessionId(),
|
|
2597
|
-
timestamp: new Date().toISOString(),
|
|
2598
|
-
cwd: this.sessionManager.getCwd(),
|
|
2599
|
-
};
|
|
2600
|
-
const branchEntries = this.sessionManager.getBranch();
|
|
2601
|
-
const lines = [JSON.stringify(header)];
|
|
2602
|
-
// Re-chain parentIds to form a linear sequence
|
|
2603
|
-
let prevId = null;
|
|
2604
|
-
for (const entry of branchEntries) {
|
|
2605
|
-
const linear = { ...entry, parentId: prevId };
|
|
2606
|
-
lines.push(JSON.stringify(linear));
|
|
2607
|
-
prevId = entry.id;
|
|
2608
|
-
}
|
|
2609
|
-
writeFileSync(filePath, `${lines.join("\n")}\n`);
|
|
2610
|
-
return filePath;
|
|
2678
|
+
return exportSessionToJsonl(this.sessionManager, outputPath);
|
|
2611
2679
|
}
|
|
2612
2680
|
// =========================================================================
|
|
2613
2681
|
// Utilities
|