@humain/humain-code 0.5.3 → 0.6.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 +180 -0
- package/README.md +2 -2
- package/dist/bundle/agent-monitor.js +1 -1
- package/dist/bundle/chunks/anthropic-messages-FGFIMZUF.js +66 -0
- package/dist/bundle/chunks/azure-openai-responses-6JNTC7KO.js +15 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +261 -237
- package/dist/bundle/chunks/chunk-2H3LUS62.js +1966 -0
- package/dist/bundle/chunks/{chunk-GEISZXXH.js → chunk-4ZBGTJJM.js} +1 -1
- package/dist/bundle/chunks/{chunk-QWXPGBAG.js → chunk-5JSLXC2A.js} +1 -1
- package/dist/bundle/chunks/{chunk-L2VKM23Q.js → chunk-6DE7LJKV.js} +21 -21
- package/dist/bundle/chunks/{chunk-V62QBESW.js → chunk-6E6RHNOU.js} +11 -10
- package/dist/bundle/chunks/chunk-7RZ5BS7U.js +2 -0
- package/dist/bundle/chunks/chunk-AHSNQWZU.js +24 -0
- package/dist/bundle/chunks/{chunk-UJLCKIMZ.js → chunk-AOH2O5CP.js} +3469 -3133
- package/dist/bundle/chunks/{chunk-ODJUBJK2.js → chunk-B7NJMF7B.js} +11 -11
- package/dist/bundle/chunks/chunk-BQ3TMEWD.js +7 -0
- package/dist/bundle/chunks/{chunk-KKCMWB63.js → chunk-C6VERWRZ.js} +1 -1
- package/dist/bundle/chunks/{chunk-CN3Q5UNB.js → chunk-CFHOPLW5.js} +658 -574
- package/dist/bundle/chunks/chunk-CVC2GV26.js +1986 -0
- package/dist/bundle/chunks/{chunk-DU6POZ7E.js → chunk-DHW3REC5.js} +1 -1
- package/dist/bundle/chunks/{chunk-UTNHGOFS.js → chunk-EDONIPUJ.js} +38 -38
- package/dist/bundle/chunks/{chunk-FO2NYB6O.js → chunk-FDGW5ZTG.js} +1147 -1110
- package/dist/bundle/chunks/{chunk-XQX7S3GM.js → chunk-GICL5V54.js} +1 -1
- package/dist/bundle/chunks/chunk-H7Y4QY7K.js +11 -0
- package/dist/bundle/chunks/chunk-HW6HMUXS.js +188 -0
- package/dist/bundle/chunks/chunk-I6AQOITY.js +53 -0
- package/dist/bundle/chunks/{chunk-ZI7TK7HM.js → chunk-IADQJFNH.js} +21 -17
- package/dist/bundle/chunks/chunk-J7AP2BUJ.js +3 -0
- package/dist/bundle/chunks/chunk-JFE52VSN.js +120 -0
- package/dist/bundle/chunks/{chunk-MIJHJNNQ.js → chunk-LDGCU6PD.js} +127 -3
- package/dist/bundle/chunks/{chunk-PS7DGA7B.js → chunk-M4CHQBAI.js} +1 -1
- package/dist/bundle/chunks/{chunk-YDBNMIA3.js → chunk-NN53K2QQ.js} +19 -1
- package/dist/bundle/chunks/{chunk-RTXDU3AA.js → chunk-ONR6Q3II.js} +255 -195
- package/dist/bundle/chunks/{chunk-Y3OPKKDR.js → chunk-P4P7OZ7R.js} +34 -32
- package/dist/bundle/chunks/{chunk-OZNC2W4B.js → chunk-PCTLFSQG.js} +444 -411
- package/dist/bundle/chunks/{chunk-YFBDR4IW.js → chunk-PNGNZXOI.js} +3 -3
- package/dist/bundle/chunks/{chunk-UDB6NI4G.js → chunk-RGUZULEE.js} +593 -481
- package/dist/bundle/chunks/chunk-RO5YPAJH.js +23 -0
- package/dist/bundle/chunks/{chunk-A6B2QMA7.js → chunk-RU7ADKA7.js} +176 -162
- package/dist/bundle/chunks/{chunk-JCXXRCP6.js → chunk-T3KDZFM4.js} +16 -16
- package/dist/bundle/chunks/{chunk-HT5YN3LX.js → chunk-TEOMXMW6.js} +3 -3
- package/dist/bundle/chunks/{chunk-HIZWUSPN.js → chunk-VEGJT52D.js} +77 -77
- package/dist/bundle/chunks/{chunk-IDU5BNNI.js → chunk-XMZGB3H4.js} +12 -3
- package/dist/bundle/chunks/chunk-YEPHPMQC.js +647 -0
- package/dist/bundle/chunks/{chunk-XA7CJAYH.js → chunk-YRUIJ5AH.js} +48 -42
- package/dist/bundle/chunks/{cli-ENEFJH2B.js → cli-BNCWK54K.js} +21 -17
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-T7TPP7SQ.js → cloudflare-workers-ai-system-one-KI6W3USX.js} +1 -1
- package/dist/bundle/chunks/codemode-worker.js +81 -75
- package/dist/bundle/chunks/compat-I5VPOXFT.js +13 -0
- package/dist/bundle/chunks/dist-J5IUPLMH.js +37 -0
- package/dist/bundle/chunks/{dist-RKNCFFGM.js → dist-SKBR3C7C.js} +720 -696
- package/dist/bundle/chunks/dist-TVRQXUY6.js +8 -0
- package/dist/bundle/chunks/{dist-cjs-HTASUQXQ.js → dist-cjs-2SKN226B.js} +77 -77
- package/dist/bundle/chunks/{easter-egg-3d-YOPLCOVW.js → easter-egg-3d-673VRP6Y.js} +1 -1
- package/dist/bundle/chunks/{esm-R6HJ4QEG.js → esm-WPALMLUO.js} +3 -3
- package/dist/bundle/chunks/{event-streams-BR2IL6C5.js → event-streams-7YGFEPBZ.js} +1 -1
- package/dist/bundle/chunks/{execute-2JXEKQ2X.js → execute-PIUR5MUV.js} +23 -23
- package/dist/bundle/chunks/{extract-OTCGZGTL.js → extract-4O5Z5725.js} +74 -71
- package/dist/bundle/chunks/github-copilot.js +50 -51
- package/dist/bundle/chunks/google-generative-ai-635YZEHN.js +22 -0
- package/dist/bundle/chunks/google-vertex-I3ZJ3SB2.js +26 -0
- package/dist/bundle/chunks/host-OQOEIWHK.js +2 -0
- package/dist/bundle/chunks/image-resize-worker.js +3 -2
- package/dist/bundle/chunks/kimi-coding.js +13 -14
- package/dist/bundle/chunks/{llama-cpp-classify-B3G57LVR.js → llama-cpp-classify-PP63BYDF.js} +1 -1
- package/dist/bundle/chunks/meta.js +10 -10
- package/dist/bundle/chunks/mistral-conversations-OKG5GKXR.js +42 -0
- package/dist/bundle/chunks/{node-VSA4ZN7D.js → node-UGQUSQE6.js} +1 -1
- package/dist/bundle/chunks/{node-SJPZTR4K.js → node-UNHECG4X.js} +168 -157
- package/dist/bundle/chunks/openai-codex-responses-6JYZIFT4.js +100 -0
- package/dist/bundle/chunks/openai-completions-YBNI6CAP.js +82 -0
- package/dist/bundle/chunks/{openai-decisions-WOWUC65P.js → openai-decisions-5G5YBFRQ.js} +1 -1
- package/dist/bundle/chunks/openai-responses-C3APJ6MK.js +27 -0
- package/dist/bundle/chunks/{openrouter-images-5K47HDAT.js → openrouter-images-FCJT7C7I.js} +2 -2
- package/dist/bundle/chunks/{pdfjs-EK6K7CXX.js → pdfjs-AKD6EBKN.js} +196 -175
- package/dist/bundle/chunks/pdfjs-decoders-OFXX4HDZ.js +2 -0
- package/dist/bundle/chunks/pdfjs-jbig2-TXR26KRI.js +278 -0
- package/dist/bundle/chunks/pdfjs-jbig2_nowasm_fallback-FH3KJM4H.js +326 -0
- package/dist/bundle/chunks/pdfjs-openjpeg-SKR7C34X.js +671 -0
- package/dist/bundle/chunks/pdfjs-openjpeg_nowasm_fallback-VUBL7UEE.js +974 -0
- package/dist/bundle/chunks/pi-messages-UHYZYEOC.js +25 -0
- package/dist/bundle/chunks/radius.js +8 -8
- package/dist/bundle/chunks/{runtime-K3F2QDQP.js → runtime-KE3HDSRT.js} +1 -1
- package/dist/bundle/chunks/{turndown.cjs-U7XOXH4O.js → turndown.cjs-WKGZX7NZ.js} +1 -1
- package/dist/bundle/chunks/{typesafe-system-one-43OCHGKP.js → typesafe-system-one-VYVAMWQV.js} +1 -1
- package/dist/bundle/chunks/{undici-EK3EUI2E.js → undici-C6S56CGI.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-KDUZIB3W.js +23 -0
- package/dist/bundle/cli-runtime.js +3 -3
- package/dist/bundle/flow/package.json +5 -5
- package/dist/bundle/index.js +10 -10
- package/dist/bundle/rpc-entry.js +3 -3
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +9 -8
- package/dist/cli/args.js.map +1 -1
- package/dist/config.d.ts +12 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +29 -5
- package/dist/config.js.map +1 -1
- package/dist/coordination/adapter/tool.d.ts +8 -5
- package/dist/coordination/adapter/tool.d.ts.map +1 -1
- package/dist/coordination/adapter/tool.js +32 -6
- package/dist/coordination/adapter/tool.js.map +1 -1
- package/dist/coordination/client/client.d.ts.map +1 -1
- package/dist/coordination/client/client.js +19 -1
- package/dist/coordination/client/client.js.map +1 -1
- package/dist/core/agent-session-runtime.js +3 -3
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +23 -3
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +142 -39
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/anthropic-subscription-usage.d.ts +4 -0
- package/dist/core/anthropic-subscription-usage.d.ts.map +1 -1
- package/dist/core/anthropic-subscription-usage.js +71 -1
- package/dist/core/anthropic-subscription-usage.js.map +1 -1
- package/dist/core/bug-report.d.ts +4 -4
- package/dist/core/codex-reset.d.ts +45 -0
- package/dist/core/codex-reset.d.ts.map +1 -0
- package/dist/core/codex-reset.js +190 -0
- package/dist/core/codex-reset.js.map +1 -0
- package/dist/core/codex-usage.d.ts +4 -2
- package/dist/core/codex-usage.d.ts.map +1 -1
- package/dist/core/codex-usage.js +9 -4
- package/dist/core/codex-usage.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +3 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +25 -10
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +37 -3
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +274 -65
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/utils.d.ts +19 -6
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +49 -11
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/exec.d.ts +9 -1
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +105 -61
- package/dist/core/exec.js.map +1 -1
- package/dist/core/export-html/template.css +9 -0
- package/dist/core/export-html/template.html +2 -0
- package/dist/core/export-html/template.js +200 -62
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js +3 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +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 +7 -6
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/pi-ai-extension-view.d.ts +19 -0
- package/dist/core/extensions/pi-ai-extension-view.d.ts.map +1 -0
- package/dist/core/extensions/pi-ai-extension-view.js +22 -0
- package/dist/core/extensions/pi-ai-extension-view.js.map +1 -0
- package/dist/core/extensions/types.d.ts +27 -4
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/virtual-modules.js +8 -7
- package/dist/core/extensions/virtual-modules.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts +7 -0
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +107 -0
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/keybindings.d.ts +56 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +14 -2
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/mcp-servers.d.ts +9 -4
- package/dist/core/mcp-servers.d.ts.map +1 -1
- package/dist/core/mcp-servers.js +15 -5
- package/dist/core/mcp-servers.js.map +1 -1
- package/dist/core/model-config.d.ts +1691 -2042
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +2 -3
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +35 -4
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +70 -8
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +16 -10
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +21 -17
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/package-manager.d.ts +29 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +311 -60
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-ai-schemas.d.ts +164 -0
- package/dist/core/pi-ai-schemas.d.ts.map +1 -0
- package/dist/core/pi-ai-schemas.js +21 -0
- package/dist/core/pi-ai-schemas.js.map +1 -0
- package/dist/core/pi-manifest.d.ts +1 -0
- package/dist/core/pi-manifest.d.ts.map +1 -1
- package/dist/core/pi-manifest.js +4 -0
- package/dist/core/pi-manifest.js.map +1 -1
- package/dist/core/project-trust.js +1 -1
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/resource-loader.d.ts +4 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +38 -23
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +4 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +7 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +66 -26
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-defaults.d.ts +2 -0
- package/dist/core/settings-defaults.d.ts.map +1 -1
- package/dist/core/settings-defaults.js +2 -0
- package/dist/core/settings-defaults.js.map +1 -1
- package/dist/core/settings-manager.d.ts +19 -8
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +70 -16
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-schema.d.ts +15 -2
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +37 -3
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +6 -14
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.js +2 -2
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/source-info.d.ts +9 -0
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js +13 -0
- package/dist/core/source-info.js.map +1 -1
- package/dist/core/subscription-credits.d.ts +14 -0
- package/dist/core/subscription-credits.d.ts.map +1 -0
- package/dist/core/subscription-credits.js +10 -0
- package/dist/core/subscription-credits.js.map +1 -0
- package/dist/core/subscription-reset-status.d.ts +10 -0
- package/dist/core/subscription-reset-status.d.ts.map +1 -0
- package/dist/core/subscription-reset-status.js +2 -0
- package/dist/core/subscription-reset-status.js.map +1 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +5 -6
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -2
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts +3 -3
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +2 -4
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts +2 -2
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +2 -2
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +7 -3
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/ls.d.ts +2 -2
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/read.d.ts +2 -2
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +4 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +42 -12
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/renderers/edit.d.ts.map +1 -1
- package/dist/core/tools/renderers/edit.js +3 -3
- package/dist/core/tools/renderers/edit.js.map +1 -1
- package/dist/core/tools/renderers/write.d.ts.map +1 -1
- package/dist/core/tools/renderers/write.js +37 -29
- package/dist/core/tools/renderers/write.js.map +1 -1
- package/dist/core/tools/subagent.d.ts +9 -8
- package/dist/core/tools/subagent.d.ts.map +1 -1
- package/dist/core/tools/subagent.js +8 -5
- package/dist/core/tools/subagent.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts +11 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/write.d.ts +2 -2
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +14 -8
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/usage-totals.d.ts.map +1 -1
- package/dist/core/usage-totals.js +2 -0
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/extensions/codemode/renderer.d.ts.map +1 -1
- package/dist/extensions/codemode/renderer.js +17 -9
- package/dist/extensions/codemode/renderer.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts +2 -1
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +33 -8
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/llama/ui.d.ts.map +1 -1
- package/dist/extensions/llama/ui.js +16 -4
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/extensions/mcp/cli.d.ts.map +1 -1
- package/dist/extensions/mcp/cli.js +34 -8
- package/dist/extensions/mcp/cli.js.map +1 -1
- package/dist/extensions/mcp/index.js +4 -3
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/oauth.d.ts +1 -1
- package/dist/extensions/mcp/oauth.d.ts.map +1 -1
- package/dist/extensions/mcp/oauth.js +7 -3
- package/dist/extensions/mcp/oauth.js.map +1 -1
- package/dist/extensions/mcp/ui.d.ts +1 -0
- package/dist/extensions/mcp/ui.d.ts.map +1 -1
- package/dist/extensions/mcp/ui.js +56 -28
- package/dist/extensions/mcp/ui.js.map +1 -1
- package/dist/extensions/tool-search/tool.d.ts +21 -6
- package/dist/extensions/tool-search/tool.d.ts.map +1 -1
- package/dist/extensions/tool-search/tool.js +104 -36
- package/dist/extensions/tool-search/tool.js.map +1 -1
- package/dist/extensions/usage/confirmation.d.ts +40 -0
- package/dist/extensions/usage/confirmation.d.ts.map +1 -0
- package/dist/extensions/usage/confirmation.js +198 -0
- package/dist/extensions/usage/confirmation.js.map +1 -0
- package/dist/extensions/usage/index.d.ts +4 -4
- package/dist/extensions/usage/index.d.ts.map +1 -1
- package/dist/extensions/usage/index.js +352 -33
- package/dist/extensions/usage/index.js.map +1 -1
- package/dist/extensions/usage/overview.d.ts +8 -1
- package/dist/extensions/usage/overview.d.ts.map +1 -1
- package/dist/extensions/usage/overview.js +54 -11
- package/dist/extensions/usage/overview.js.map +1 -1
- package/dist/extensions/usage/popup.d.ts +37 -6
- package/dist/extensions/usage/popup.d.ts.map +1 -1
- package/dist/extensions/usage/popup.js +396 -45
- package/dist/extensions/usage/popup.js.map +1 -1
- package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +564 -130
- package/dist/humain/node-provider.d.ts.map +1 -1
- package/dist/humain/node-provider.js +1 -0
- package/dist/humain/node-provider.js.map +1 -1
- package/dist/humain/web-access/host.d.ts +2 -1
- package/dist/humain/web-access/host.d.ts.map +1 -1
- package/dist/humain/web-access/host.js +1 -1
- package/dist/humain/web-access/host.js.map +1 -1
- package/dist/humain/web-access/vendor/brave-rate-limit.d.ts +2 -0
- package/dist/humain/web-access/vendor/brave-rate-limit.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/brave-rate-limit.js +2 -2
- package/dist/humain/web-access/vendor/brave-rate-limit.js.map +1 -1
- package/dist/humain/web-access/vendor/cloudflare-search.d.ts +5 -0
- package/dist/humain/web-access/vendor/cloudflare-search.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/cloudflare-search.js +230 -0
- package/dist/humain/web-access/vendor/cloudflare-search.js.map +1 -0
- package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/curator-page.js +18 -1
- package/dist/humain/web-access/vendor/curator-page.js.map +1 -1
- package/dist/humain/web-access/vendor/curator-server.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/curator-server.js +12 -0
- package/dist/humain/web-access/vendor/curator-server.js.map +1 -1
- package/dist/humain/web-access/vendor/duckduckgo-rate-limit.d.ts +33 -0
- package/dist/humain/web-access/vendor/duckduckgo-rate-limit.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/duckduckgo-rate-limit.js +84 -0
- package/dist/humain/web-access/vendor/duckduckgo-rate-limit.js.map +1 -0
- package/dist/humain/web-access/vendor/duckduckgo.d.ts +3 -0
- package/dist/humain/web-access/vendor/duckduckgo.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/duckduckgo.js +54 -49
- package/dist/humain/web-access/vendor/duckduckgo.js.map +1 -1
- package/dist/humain/web-access/vendor/exa.d.ts +8 -3
- package/dist/humain/web-access/vendor/exa.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/exa.js +129 -14
- package/dist/humain/web-access/vendor/exa.js.map +1 -1
- package/dist/humain/web-access/vendor/extract.d.ts +1 -1
- package/dist/humain/web-access/vendor/extract.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/extract.js +68 -10
- package/dist/humain/web-access/vendor/extract.js.map +1 -1
- package/dist/humain/web-access/vendor/fetch-params.d.ts +2 -1
- package/dist/humain/web-access/vendor/fetch-params.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/fetch-params.js +2 -2
- package/dist/humain/web-access/vendor/fetch-params.js.map +1 -1
- package/dist/humain/web-access/vendor/field-extract.d.ts +38 -0
- package/dist/humain/web-access/vendor/field-extract.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/field-extract.js +350 -0
- package/dist/humain/web-access/vendor/field-extract.js.map +1 -0
- package/dist/humain/web-access/vendor/gemini-search.d.ts +15 -4
- package/dist/humain/web-access/vendor/gemini-search.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-search.js +198 -16
- package/dist/humain/web-access/vendor/gemini-search.js.map +1 -1
- package/dist/humain/web-access/vendor/github-api.js +1 -1
- 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 +3 -2
- package/dist/humain/web-access/vendor/github-extract.js.map +1 -1
- package/dist/humain/web-access/vendor/index.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/index.js +137 -118
- package/dist/humain/web-access/vendor/index.js.map +1 -1
- package/dist/humain/web-access/vendor/mistral-search.js +1 -1
- package/dist/humain/web-access/vendor/mistral-search.js.map +1 -1
- package/dist/humain/web-access/vendor/ninerouter.d.ts +4 -0
- package/dist/humain/web-access/vendor/ninerouter.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/ninerouter.js +110 -0
- package/dist/humain/web-access/vendor/ninerouter.js.map +1 -0
- package/dist/humain/web-access/vendor/offtopic-judge.d.ts +27 -0
- package/dist/humain/web-access/vendor/offtopic-judge.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/offtopic-judge.js +61 -0
- package/dist/humain/web-access/vendor/offtopic-judge.js.map +1 -0
- package/dist/humain/web-access/vendor/openai-search.d.ts +1 -1
- package/dist/humain/web-access/vendor/openai-search.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/openai-search.js +39 -13
- package/dist/humain/web-access/vendor/openai-search.js.map +1 -1
- package/dist/humain/web-access/vendor/outcrawl.d.ts +4 -0
- package/dist/humain/web-access/vendor/outcrawl.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/outcrawl.js +196 -0
- package/dist/humain/web-access/vendor/outcrawl.js.map +1 -0
- package/dist/humain/web-access/vendor/page-query.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/page-query.js +13 -3
- package/dist/humain/web-access/vendor/page-query.js.map +1 -1
- package/dist/humain/web-access/vendor/pdf-extract.d.ts +1 -3
- package/dist/humain/web-access/vendor/pdf-extract.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/pdf-extract.js +0 -2
- package/dist/humain/web-access/vendor/pdf-extract.js.map +1 -1
- package/dist/humain/web-access/vendor/perplexity.d.ts +3 -0
- package/dist/humain/web-access/vendor/perplexity.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/perplexity.js.map +1 -1
- package/dist/humain/web-access/vendor/query-rewrite.d.ts +2 -2
- package/dist/humain/web-access/vendor/query-rewrite.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/query-rewrite.js +39 -13
- package/dist/humain/web-access/vendor/query-rewrite.js.map +1 -1
- package/dist/humain/web-access/vendor/searchapi.d.ts +4 -0
- package/dist/humain/web-access/vendor/searchapi.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/searchapi.js +195 -0
- package/dist/humain/web-access/vendor/searchapi.js.map +1 -0
- package/dist/humain/web-access/vendor/sofya.d.ts +4 -0
- package/dist/humain/web-access/vendor/sofya.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/sofya.js +193 -0
- package/dist/humain/web-access/vendor/sofya.js.map +1 -0
- package/dist/humain/web-access/vendor/source-check.d.ts +5 -1
- package/dist/humain/web-access/vendor/source-check.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/source-check.js +34 -16
- package/dist/humain/web-access/vendor/source-check.js.map +1 -1
- package/dist/humain/web-access/vendor/ssrf-protection.d.ts +7 -0
- package/dist/humain/web-access/vendor/ssrf-protection.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/ssrf-protection.js +24 -1
- package/dist/humain/web-access/vendor/ssrf-protection.js.map +1 -1
- package/dist/humain/web-access/vendor/summary-model-scope.d.ts +8 -3
- package/dist/humain/web-access/vendor/summary-model-scope.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/summary-model-scope.js +15 -1
- package/dist/humain/web-access/vendor/summary-model-scope.js.map +1 -1
- package/dist/humain/web-access/vendor/summary-review.d.ts +7 -2
- package/dist/humain/web-access/vendor/summary-review.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/summary-review.js +32 -28
- package/dist/humain/web-access/vendor/summary-review.js.map +1 -1
- package/dist/humain/web-access/vendor/tabstack.d.ts +6 -0
- package/dist/humain/web-access/vendor/tabstack.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/tabstack.js +236 -0
- package/dist/humain/web-access/vendor/tabstack.js.map +1 -0
- package/dist/humain/web-access/vendor/tool-arguments.js +1 -1
- package/dist/humain/web-access/vendor/tool-arguments.js.map +1 -1
- package/dist/humain/web-access/vendor/upgrade-notice.d.ts +8 -0
- package/dist/humain/web-access/vendor/upgrade-notice.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/upgrade-notice.js +46 -0
- package/dist/humain/web-access/vendor/upgrade-notice.js.map +1 -0
- package/dist/humain/web-access/vendor/utils.d.ts +9 -0
- package/dist/humain/web-access/vendor/utils.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/utils.js +113 -27
- package/dist/humain/web-access/vendor/utils.js.map +1 -1
- package/dist/humain/web-access/vendor/web-tool-contract.d.ts +4 -0
- package/dist/humain/web-access/vendor/web-tool-contract.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/web-tool-contract.js.map +1 -1
- package/dist/humain/web-access/vendor/web-tool-core.d.ts +17 -1
- package/dist/humain/web-access/vendor/web-tool-core.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/web-tool-core.js +99 -22
- package/dist/humain/web-access/vendor/web-tool-core.js.map +1 -1
- package/dist/humain/web-access/vendor/xai-search.d.ts +1 -1
- package/dist/humain/web-access/vendor/xai-search.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/xai-search.js +6 -5
- package/dist/humain/web-access/vendor/xai-search.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +20 -9
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-code-block.d.ts +34 -0
- package/dist/modes/interactive/components/assistant-code-block.d.ts.map +1 -0
- package/dist/modes/interactive/components/assistant-code-block.js +160 -0
- package/dist/modes/interactive/components/assistant-code-block.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +31 -10
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +276 -73
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +2 -1
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +4 -17
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +7 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js +2 -1
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +2 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/diff.d.ts.map +1 -1
- package/dist/modes/interactive/components/diff.js +3 -1
- package/dist/modes/interactive/components/diff.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +2 -0
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +4 -0
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +4 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +6 -5
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +5 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +107 -11
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts +2 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -1
- package/dist/modes/interactive/components/markdown-transform.js +3 -2
- package/dist/modes/interactive/components/markdown-transform.js.map +1 -1
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
- package/dist/modes/interactive/components/mermaid.js +18 -6
- package/dist/modes/interactive/components/mermaid.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +17 -6
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +1 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +13 -4
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +14 -3
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.d.ts +4 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.js +86 -22
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +2 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +16 -24
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.js +2 -0
- package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +2 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +15 -5
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +5 -6
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +9 -1
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +4 -3
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +20 -18
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts +1 -0
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +16 -4
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +6 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +259 -83
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/model-search.d.ts +10 -0
- package/dist/modes/interactive/model-search.d.ts.map +1 -1
- package/dist/modes/interactive/model-search.js +21 -0
- package/dist/modes/interactive/model-search.js.map +1 -1
- package/dist/modes/interactive/oauth-account-format.d.ts +10 -1
- package/dist/modes/interactive/oauth-account-format.d.ts.map +1 -1
- package/dist/modes/interactive/oauth-account-format.js +42 -0
- package/dist/modes/interactive/oauth-account-format.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +10 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +28 -24
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +3 -2
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +55 -4
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/ansi.d.ts.map +1 -1
- package/dist/utils/ansi.js +5 -2
- package/dist/utils/ansi.js.map +1 -1
- package/dist/utils/clipboard-command.d.ts.map +1 -1
- package/dist/utils/clipboard-command.js +4 -0
- package/dist/utils/clipboard-command.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts +8 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +31 -1
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/git.d.ts +1 -1
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/image-resize-core.d.ts.map +1 -1
- package/dist/utils/image-resize-core.js +5 -3
- package/dist/utils/image-resize-core.js.map +1 -1
- package/dist/utils/open-browser.d.ts.map +1 -1
- package/dist/utils/open-browser.js +96 -6
- package/dist/utils/open-browser.js.map +1 -1
- package/dist/utils/paths.d.ts +17 -0
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +42 -1
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/shell.d.ts +2 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +12 -2
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts +5 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +156 -11
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +30 -35
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/assets/humain-code-logo.svg +8 -0
- package/docs/cli.md +22 -12
- package/docs/compaction.md +32 -8
- package/docs/coordination.md +2 -0
- package/docs/custom-provider.md +4 -2
- package/docs/environment-variables.md +2 -0
- package/docs/extensions.md +3169 -229
- package/docs/flow.md +2 -0
- package/docs/keybindings.md +24 -2
- package/docs/llama-cpp.md +30 -19
- package/docs/mcp.md +4 -2
- package/docs/message-types.md +7 -7
- package/docs/packages.md +27 -1
- package/docs/sessions.md +11 -3
- package/docs/settings.md +21 -9
- package/docs/slash-commands.md +51 -11
- package/docs/terminal-setup.md +3 -1
- package/docs/tmux.md +6 -0
- package/docs/tui.md +3 -1
- package/docs/windows.md +27 -0
- package/examples/extensions/README.md +2 -1
- package/examples/extensions/custom-provider-anthropic/index.ts +27 -31
- package/examples/extensions/custom-provider-anthropic/package-lock.json +7 -7
- package/examples/extensions/custom-provider-anthropic/package.json +2 -2
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/debug-provider.ts +2 -2
- package/examples/extensions/gondolin/package-lock.json +14 -24
- package/examples/extensions/gondolin/package.json +2 -2
- package/examples/extensions/preset.ts +2 -0
- package/examples/extensions/reload-runtime.ts +17 -5
- package/examples/extensions/todo.ts +7 -0
- package/examples/extensions/tools.ts +2 -0
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/tsconfig.json +252 -0
- package/npm-shrinkwrap.json +289 -277
- package/package.json +29 -29
- package/schemas/keybindings.schema.json +28 -0
- package/schemas/models.schema.json +36 -36
- package/schemas/settings.schema.json +49 -0
- package/src/humain/ponytail/UPSTREAM.md +16 -2
- package/src/humain/ponytail/upstream.json +4 -4
- package/src/humain/web-access/UPSTREAM.md +48 -1
- package/src/humain/web-access/upstream.json +9 -6
- package/src/humain/web-access/vendor/CHANGELOG.md +1223 -0
- package/dist/bundle/chunks/anthropic-messages-ZP5KUK52.js +0 -67
- package/dist/bundle/chunks/azure-openai-responses-QJFYQ3DF.js +0 -15
- package/dist/bundle/chunks/chunk-2GCMACT4.js +0 -1956
- package/dist/bundle/chunks/chunk-AO6FF5JL.js +0 -21
- package/dist/bundle/chunks/chunk-EY3LZOUP.js +0 -1963
- package/dist/bundle/chunks/chunk-M74U5X4S.js +0 -119
- package/dist/bundle/chunks/chunk-N7CQ3UV3.js +0 -80
- package/dist/bundle/chunks/chunk-OR25QDSS.js +0 -365
- package/dist/bundle/chunks/chunk-PH7UP57J.js +0 -6
- package/dist/bundle/chunks/chunk-QW6PTCAB.js +0 -10
- package/dist/bundle/chunks/chunk-ROZV2IYD.js +0 -125
- package/dist/bundle/chunks/chunk-YFOLLX5D.js +0 -23
- package/dist/bundle/chunks/chunk-ZR4GF4WU.js +0 -54
- package/dist/bundle/chunks/compat-CJBWWYHE.js +0 -13
- package/dist/bundle/chunks/dist-IBUWEKEE.js +0 -24
- package/dist/bundle/chunks/dist-YFMJEHPH.js +0 -8
- package/dist/bundle/chunks/google-generative-ai-HVPCGIZ6.js +0 -21
- package/dist/bundle/chunks/google-vertex-UM5MAALA.js +0 -25
- package/dist/bundle/chunks/host-ZHEL5XQW.js +0 -2
- package/dist/bundle/chunks/mistral-conversations-AH72RLXK.js +0 -44
- package/dist/bundle/chunks/openai-codex-responses-L366637C.js +0 -98
- package/dist/bundle/chunks/openai-completions-ZP62QXJX.js +0 -83
- package/dist/bundle/chunks/openai-responses-DXUGSUTN.js +0 -26
- package/dist/bundle/chunks/pi-messages-MOQQDZBK.js +0 -23
- package/dist/bundle/chunks/virtual-modules-5D6QIJPN.js +0 -5
- package/examples/extensions/sandbox/index.ts +0 -321
- package/examples/extensions/sandbox/package-lock.json +0 -66
- package/examples/extensions/sandbox/package.json +0 -19
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* and after compaction the session is reloaded.
|
|
6
6
|
*/
|
|
7
7
|
import { calculateCost, contentText, getCurrentSystemMessage, hasApi, normalizeContext, retryAssistantCall, uuidv7, } from "@earendil-works/pi-ai";
|
|
8
|
-
import { completeSimple } from "@earendil-works/pi-ai/compat";
|
|
8
|
+
import { completeSimple, isContextOverflow } from "@earendil-works/pi-ai/compat";
|
|
9
9
|
import { convertToLlm } from "../messages.js";
|
|
10
10
|
import { buildSessionProjection, sessionEntryToContextMessages, } from "../session-manager.js";
|
|
11
11
|
import { combineUsage } from "../usage-totals.js";
|
|
@@ -50,10 +50,16 @@ function getMessagesFromProjectedEntryForCompaction(entry) {
|
|
|
50
50
|
// System messages are prompt state, not conversation; the compaction entry carries their replay.
|
|
51
51
|
return entry.messages.filter((message) => message.role !== "system");
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Built-in defaults. `keepRecentTokens` is the minimum: the settings manager raises it to 5% of the
|
|
55
|
+
* context window when the setting is unset.
|
|
56
|
+
*/
|
|
53
57
|
export const DEFAULT_COMPACTION_SETTINGS = {
|
|
54
58
|
enabled: true,
|
|
55
59
|
reserveTokens: 16384,
|
|
56
60
|
keepRecentTokens: 20000,
|
|
61
|
+
thresholdPercent: 90,
|
|
62
|
+
scaleSummaryWithContextWindow: true,
|
|
57
63
|
};
|
|
58
64
|
// ============================================================================
|
|
59
65
|
// Token calculation
|
|
@@ -167,13 +173,23 @@ export function estimateProjectedContextTokens(projection, branchEntries) {
|
|
|
167
173
|
}
|
|
168
174
|
return { tokens, usageTokens: 0, trailingTokens: tokens, lastUsageIndex: null };
|
|
169
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Context size above which compaction triggers: `contextWindow - reserveTokens`, or
|
|
178
|
+
* `thresholdPercent` of the window when that is lower.
|
|
179
|
+
*/
|
|
180
|
+
export function getCompactionThreshold(contextWindow, settings) {
|
|
181
|
+
const reserveThreshold = contextWindow - settings.reserveTokens;
|
|
182
|
+
if (settings.thresholdPercent === undefined)
|
|
183
|
+
return reserveThreshold;
|
|
184
|
+
return Math.min(reserveThreshold, Math.floor((contextWindow * settings.thresholdPercent) / 100));
|
|
185
|
+
}
|
|
170
186
|
/**
|
|
171
187
|
* Check if compaction should trigger based on context usage.
|
|
172
188
|
*/
|
|
173
189
|
export function shouldCompact(contextTokens, contextWindow, settings) {
|
|
174
190
|
if (!settings.enabled)
|
|
175
191
|
return false;
|
|
176
|
-
return contextTokens > contextWindow
|
|
192
|
+
return contextTokens > getCompactionThreshold(contextWindow, settings);
|
|
177
193
|
}
|
|
178
194
|
// ============================================================================
|
|
179
195
|
// Cut point detection
|
|
@@ -250,6 +266,28 @@ export function estimateTokens(message) {
|
|
|
250
266
|
}
|
|
251
267
|
return 0;
|
|
252
268
|
}
|
|
269
|
+
/** Keep the start and end of `text` within `maxChars`, with a marker for the omitted middle. */
|
|
270
|
+
function truncateMiddle(text, maxChars) {
|
|
271
|
+
const half = Math.floor(maxChars / 2);
|
|
272
|
+
const head = splitIndex(text, half);
|
|
273
|
+
const tail = tailStart(text, half);
|
|
274
|
+
return `${text.slice(0, head)}\n\n[... ${tail - head} characters omitted to fit the model's context window ...]\n\n${text.slice(tail)}`;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Shorten message content to about `maxChars` estimated characters for context overflow recovery.
|
|
278
|
+
* Text keeps its start and end around a marker; images become text markers. Returns undefined
|
|
279
|
+
* when the content already fits.
|
|
280
|
+
*/
|
|
281
|
+
export function truncateContentForContext(content, maxChars) {
|
|
282
|
+
if (estimateTextAndImageContentChars(content) <= maxChars)
|
|
283
|
+
return undefined;
|
|
284
|
+
if (typeof content === "string")
|
|
285
|
+
return truncateMiddle(content, maxChars);
|
|
286
|
+
const text = content
|
|
287
|
+
.map((block) => (block.type === "text" ? block.text : "[image omitted to fit the model's context window]"))
|
|
288
|
+
.join("\n");
|
|
289
|
+
return [{ type: "text", text: text.length > maxChars ? truncateMiddle(text, maxChars) : text }];
|
|
290
|
+
}
|
|
253
291
|
function isCutPointMessage(message) {
|
|
254
292
|
switch (message.role) {
|
|
255
293
|
case "user":
|
|
@@ -460,8 +498,31 @@ export function getSummarizationFailure(response, label) {
|
|
|
460
498
|
}
|
|
461
499
|
return undefined;
|
|
462
500
|
}
|
|
463
|
-
|
|
464
|
-
|
|
501
|
+
/** Smallest summary output budget, so a zero or tiny `reserveTokens` still allows a summary. */
|
|
502
|
+
const MIN_SUMMARY_OUTPUT_TOKENS = 4096;
|
|
503
|
+
/**
|
|
504
|
+
* Output cap of a summary, capped by the model's output limit. An explicit `summaryMaxTokens` is used
|
|
505
|
+
* as set (half of it for a split turn's prefix). Otherwise the cap is 80% of `reserveTokens` (50% for
|
|
506
|
+
* the prefix), at least the minimum, and with `scaleSummaryWithContextWindow` at least 3.2% of the
|
|
507
|
+
* model's context window (1.6% for the prefix).
|
|
508
|
+
*/
|
|
509
|
+
export function getSummaryMaxTokens(model, settings, part = "summary") {
|
|
510
|
+
let budget;
|
|
511
|
+
if (settings.summaryMaxTokens !== undefined) {
|
|
512
|
+
budget = part === "summary" ? settings.summaryMaxTokens : Math.ceil(settings.summaryMaxTokens / 2);
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
515
|
+
const share = part === "summary" ? 0.8 : 0.5;
|
|
516
|
+
budget = Math.max(Math.floor(share * settings.reserveTokens), MIN_SUMMARY_OUTPUT_TOKENS);
|
|
517
|
+
if (settings.scaleSummaryWithContextWindow && model.contextWindow > 0) {
|
|
518
|
+
const perMille = part === "summary" ? 32 : 16;
|
|
519
|
+
budget = Math.max(budget, Math.floor((model.contextWindow * perMille) / 1000));
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
return model.maxTokens > 0 ? Math.min(budget, model.maxTokens) : budget;
|
|
523
|
+
}
|
|
524
|
+
function createSummarizationOptions(model, maxTokens, apiKey, headers, env, signal, thinkingLevel, sessionId) {
|
|
525
|
+
const options = { maxTokens, signal, apiKey, headers, env, sessionId };
|
|
465
526
|
if (model.reasoning && thinkingLevel && thinkingLevel !== "off") {
|
|
466
527
|
options.reasoning = thinkingLevel;
|
|
467
528
|
}
|
|
@@ -486,15 +547,15 @@ export async function completeSummarization(model, context, options, streamFn, r
|
|
|
486
547
|
sessionId: options.sessionId ?? uuidv7(),
|
|
487
548
|
};
|
|
488
549
|
let aggregate;
|
|
489
|
-
const produce = async () => {
|
|
550
|
+
const produce = async (options) => {
|
|
490
551
|
let response;
|
|
491
552
|
let submissions = 0;
|
|
492
553
|
try {
|
|
493
554
|
const attemptOptions = {
|
|
494
|
-
...
|
|
555
|
+
...options,
|
|
495
556
|
onRequest: async (request) => {
|
|
496
557
|
submissions++;
|
|
497
|
-
await
|
|
558
|
+
await options.onRequest?.(request);
|
|
498
559
|
},
|
|
499
560
|
};
|
|
500
561
|
response = streamFn
|
|
@@ -556,7 +617,7 @@ export async function completeSummarization(model, context, options, streamFn, r
|
|
|
556
617
|
(tokens > 0 || Object.values(pricingModel.cost).every((rate) => rate === 0))) {
|
|
557
618
|
const reportedCost = { ...usage.cost };
|
|
558
619
|
calculateCost(pricingModel, usage);
|
|
559
|
-
if (!Object.values(usage.cost).every((value) => Number.isFinite(value) && value >= 0)) {
|
|
620
|
+
if (!Object.values(usage.cost).every((value) => typeof value === "boolean" || (Number.isFinite(value) && value >= 0))) {
|
|
560
621
|
usage.cost = reportedCost;
|
|
561
622
|
valid = false;
|
|
562
623
|
}
|
|
@@ -568,7 +629,13 @@ export async function completeSummarization(model, context, options, streamFn, r
|
|
|
568
629
|
callbacks?.onUsage?.(usage, provider, responseModel);
|
|
569
630
|
}
|
|
570
631
|
};
|
|
571
|
-
|
|
632
|
+
let response = await retryAssistantCall(() => produce(requestOptions), retry, requestOptions.signal, callbacks);
|
|
633
|
+
// Reasoning shares the summary's output cap on some providers and can use all of it (#9512).
|
|
634
|
+
// Summarize once more without reasoning instead of failing the compaction (Pi-Bolt 3ecd6fdb0).
|
|
635
|
+
if (response.stopReason === "length" && requestOptions.reasoning) {
|
|
636
|
+
const { reasoning: _reasoning, ...withoutReasoning } = requestOptions;
|
|
637
|
+
response = await retryAssistantCall(() => produce(withoutReasoning), retry, requestOptions.signal, callbacks);
|
|
638
|
+
}
|
|
572
639
|
// Backoff cancellation relabels the last response; it is not another provider attempt.
|
|
573
640
|
return { ...response, usage: aggregate ?? response.usage };
|
|
574
641
|
}
|
|
@@ -576,10 +643,8 @@ export async function completeSummarization(model, context, options, streamFn, r
|
|
|
576
643
|
* Generate a summary of the conversation using the LLM.
|
|
577
644
|
* If previousSummary is provided, uses the update prompt to merge.
|
|
578
645
|
*/
|
|
579
|
-
export async function generateSummary(currentMessages, model,
|
|
580
|
-
|
|
581
|
-
_reserveTokens, apiKey, headers, signal, customInstructions, previousSummary, thinkingLevel, streamFn, env, retry, callbacks, sessionId) {
|
|
582
|
-
return (await generateSummaryWithUsage(currentMessages, model, _reserveTokens, apiKey, headers, signal, customInstructions, previousSummary, thinkingLevel, streamFn, env, retry, callbacks, sessionId)).text;
|
|
646
|
+
export async function generateSummary(currentMessages, model, reserveTokens, apiKey, headers, signal, customInstructions, previousSummary, thinkingLevel, streamFn, env, retry, callbacks, sessionId) {
|
|
647
|
+
return (await generateSummaryWithUsage(currentMessages, model, reserveTokens, apiKey, headers, signal, customInstructions, previousSummary, thinkingLevel, streamFn, env, retry, callbacks, sessionId)).text;
|
|
583
648
|
}
|
|
584
649
|
/** Build the provider context for a standalone summary request. */
|
|
585
650
|
function buildSummarizationContext(promptText) {
|
|
@@ -595,37 +660,185 @@ function buildSummarizationContext(promptText) {
|
|
|
595
660
|
});
|
|
596
661
|
}
|
|
597
662
|
/** Generate or update a conversation summary and return its provider usage. */
|
|
598
|
-
export async function generateSummaryWithUsage(currentMessages, model,
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
663
|
+
export async function generateSummaryWithUsage(currentMessages, model, reserveTokens, apiKey, headers, signal, customInstructions, previousSummary, thinkingLevel, streamFn, env, retry, callbacks, sessionId) {
|
|
664
|
+
return generateHistorySummary(currentMessages, model, getSummaryMaxTokens(model, { reserveTokens: reserveTokens ?? DEFAULT_COMPACTION_SETTINGS.reserveTokens }), apiKey, headers, signal, customInstructions, previousSummary, thinkingLevel, streamFn, env, retry, callbacks, sessionId);
|
|
665
|
+
}
|
|
666
|
+
/** Generate or update a conversation summary with an output cap of `maxTokens`. */
|
|
667
|
+
async function generateHistorySummary(currentMessages, model, maxTokens, apiKey, headers, signal, customInstructions, previousSummary, thinkingLevel, streamFn, env, retry, callbacks, sessionId) {
|
|
668
|
+
const completionOptions = createSummarizationOptions(model, maxTokens, apiKey, headers, env, signal, thinkingLevel, sessionId);
|
|
669
|
+
return summarizeWithinWindow(currentMessages, previousSummary, model, maxTokens, {
|
|
670
|
+
label: "Summarization",
|
|
671
|
+
signal,
|
|
672
|
+
buildPrompt: (conversationText, summary) => {
|
|
673
|
+
// Use update prompt if we have a previous summary, otherwise initial prompt
|
|
674
|
+
let basePrompt = summary ? UPDATE_SUMMARIZATION_PROMPT : SUMMARIZATION_PROMPT;
|
|
675
|
+
if (customInstructions) {
|
|
676
|
+
basePrompt = `${basePrompt}\n\nAdditional focus: ${customInstructions}`;
|
|
677
|
+
}
|
|
678
|
+
// Build the prompt with conversation wrapped in tags
|
|
679
|
+
let promptText = `<conversation>\n${conversationText}\n</conversation>\n\n`;
|
|
680
|
+
if (summary) {
|
|
681
|
+
promptText += `<previous-summary>\n${summary}\n</previous-summary>\n\n`;
|
|
682
|
+
}
|
|
683
|
+
return promptText + basePrompt;
|
|
684
|
+
},
|
|
685
|
+
send: (promptText) => completeSummarization(model, buildSummarizationContext(promptText), completionOptions, streamFn, retry, callbacks),
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* Below this many tokens of room for conversation text, a summary request is not split any
|
|
690
|
+
* further and summarization fails.
|
|
691
|
+
*/
|
|
692
|
+
const MIN_SUMMARY_CHUNK_TOKENS = 1024;
|
|
693
|
+
/** Smallest input budget a summary request is split for; below it, the single request is sent as before. */
|
|
694
|
+
const MIN_SUMMARY_SPLIT_TOKENS = 8192;
|
|
695
|
+
/** Most requests a split summary makes. Older history beyond them is omitted with a marker. */
|
|
696
|
+
const MAX_SUMMARY_CHUNKS = 12;
|
|
697
|
+
/** Most times a split summary halves its budget because the provider still reports an overflow. */
|
|
698
|
+
const MAX_SUMMARY_BUDGET_HALVINGS = 6;
|
|
699
|
+
/** Estimated input tokens of a summary request: system prompt plus prompt text, chars/4 like {@link estimateTokens}. */
|
|
700
|
+
function estimateSummaryRequestTokens(promptText) {
|
|
701
|
+
return Math.ceil((SUMMARIZATION_SYSTEM_PROMPT.length + promptText.length) / 4);
|
|
702
|
+
}
|
|
703
|
+
function readSummary(response, label) {
|
|
618
704
|
if (response.stopReason === "aborted")
|
|
619
|
-
throw new SummarizationAbortedError(
|
|
620
|
-
const failure = getSummarizationFailure(response,
|
|
705
|
+
throw new SummarizationAbortedError(`${label} aborted`, "AbortError");
|
|
706
|
+
const failure = getSummarizationFailure(response, label);
|
|
621
707
|
if (failure) {
|
|
622
708
|
throw new Error(failure);
|
|
623
709
|
}
|
|
624
710
|
if (response.content.some((block) => block.type === "toolCall")) {
|
|
625
|
-
throw new Error(
|
|
711
|
+
throw new Error(`${label} attempted to call a tool`);
|
|
712
|
+
}
|
|
713
|
+
return { text: contentText(response.content), usage: response.usage };
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Summarize messages in one request when it fits the summarizer's context window, as before.
|
|
717
|
+
* A request that is estimated not to fit, or that the provider rejects as too long, is split
|
|
718
|
+
* into smaller requests by {@link foldSummary} instead of failing (earendil-works/pi#11281).
|
|
719
|
+
*/
|
|
720
|
+
async function summarizeWithinWindow(messages, previousSummary, model, maxTokens, request) {
|
|
721
|
+
// Serialize conversation to text so model doesn't try to continue it
|
|
722
|
+
// Convert to LLM messages first (handles custom types like bashExecution, custom, etc.)
|
|
723
|
+
const llmMessages = convertToLlm(messages);
|
|
724
|
+
const promptText = request.buildPrompt(serializeConversation(llmMessages), previousSummary);
|
|
725
|
+
const requestTokens = estimateSummaryRequestTokens(promptText);
|
|
726
|
+
const windowBudget = model.contextWindow > 0 ? model.contextWindow - maxTokens : undefined;
|
|
727
|
+
if (windowBudget !== undefined && windowBudget >= MIN_SUMMARY_SPLIT_TOKENS && requestTokens > windowBudget) {
|
|
728
|
+
return foldSummary(llmMessages, previousSummary, windowBudget, request);
|
|
729
|
+
}
|
|
730
|
+
const response = await request.send(promptText);
|
|
731
|
+
if (!isContextOverflow(response)) {
|
|
732
|
+
return readSummary(response, request.label);
|
|
733
|
+
}
|
|
734
|
+
// The summarizer's real limit is below this request: a declared window can be larger than the
|
|
735
|
+
// served one, and chars/4 underestimates some text (for example CJK). Retrying the same request
|
|
736
|
+
// cannot succeed, so split it into requests of at most half its estimated size.
|
|
737
|
+
const budget = Math.floor(requestTokens / 2);
|
|
738
|
+
if (budget < MIN_SUMMARY_SPLIT_TOKENS)
|
|
739
|
+
return readSummary(response, request.label);
|
|
740
|
+
const folded = await foldSummary(llmMessages, previousSummary, budget, request);
|
|
741
|
+
return { text: folded.text, usage: combineUsage(response.usage, folded.usage) };
|
|
742
|
+
}
|
|
743
|
+
/** Index at most `maxChars` into `text` that does not split a surrogate pair. */
|
|
744
|
+
function splitIndex(text, maxChars) {
|
|
745
|
+
const index = Math.max(1, Math.min(maxChars, text.length));
|
|
746
|
+
const code = text.charCodeAt(index - 1);
|
|
747
|
+
return code >= 0xd800 && code <= 0xdbff && index > 1 ? index - 1 : index;
|
|
748
|
+
}
|
|
749
|
+
/** Start index of the last `maxChars` of `text` that does not split a surrogate pair. */
|
|
750
|
+
function tailStart(text, maxChars) {
|
|
751
|
+
const start = Math.max(0, text.length - maxChars);
|
|
752
|
+
const code = text.charCodeAt(start);
|
|
753
|
+
return code >= 0xdc00 && code <= 0xdfff ? start + 1 : start;
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Summarize messages in consecutive requests that each fit `budget` input tokens, folding each
|
|
757
|
+
* request's summary into the next one as its previous summary. A message larger than one request
|
|
758
|
+
* is split across requests. A previous summary too large to carry is summarized as history. When
|
|
759
|
+
* more than {@link MAX_SUMMARY_CHUNKS} requests would be needed, the oldest messages are omitted
|
|
760
|
+
* with a marker. A request the provider still rejects as too long is retried with half the budget.
|
|
761
|
+
*/
|
|
762
|
+
async function foldSummary(messages, previousSummary, initialBudget, request) {
|
|
763
|
+
let budget = initialBudget;
|
|
764
|
+
let pieces = messages.map((message) => serializeConversation([message])).filter((piece) => piece.length > 0);
|
|
765
|
+
let summary = previousSummary || undefined;
|
|
766
|
+
if (summary && estimateSummaryRequestTokens(request.buildPrompt("", summary)) > budget / 2) {
|
|
767
|
+
pieces = [`[Previous summary]:\n${summary}`, ...pieces];
|
|
768
|
+
summary = undefined;
|
|
769
|
+
}
|
|
770
|
+
let usage;
|
|
771
|
+
let requests = 0;
|
|
772
|
+
let halvings = 0;
|
|
773
|
+
let omitted = 0;
|
|
774
|
+
while (pieces.length > 0) {
|
|
775
|
+
request.signal?.throwIfAborted();
|
|
776
|
+
const roomTokens = budget - estimateSummaryRequestTokens(request.buildPrompt("", summary));
|
|
777
|
+
if (roomTokens < MIN_SUMMARY_CHUNK_TOKENS) {
|
|
778
|
+
throw new Error(`${request.label} failed: the summary request does not fit the model's context window`);
|
|
779
|
+
}
|
|
780
|
+
const roomChars = roomTokens * 4;
|
|
781
|
+
// Omit the oldest messages that the remaining requests cannot cover.
|
|
782
|
+
const allowedChars = (MAX_SUMMARY_CHUNKS - requests) * roomChars;
|
|
783
|
+
let keptChars = 0;
|
|
784
|
+
let keepFrom = pieces.length;
|
|
785
|
+
while (keepFrom > 0 && keptChars + pieces[keepFrom - 1].length + 2 <= allowedChars) {
|
|
786
|
+
keepFrom--;
|
|
787
|
+
keptChars += pieces[keepFrom].length + 2;
|
|
788
|
+
}
|
|
789
|
+
if (keepFrom === pieces.length) {
|
|
790
|
+
// The newest message alone needs more requests than remain: keep its end.
|
|
791
|
+
const newest = pieces[pieces.length - 1];
|
|
792
|
+
const start = tailStart(newest, allowedChars);
|
|
793
|
+
pieces[pieces.length - 1] = `[... ${start} earlier characters omitted]\n${newest.slice(start)}`;
|
|
794
|
+
keepFrom = pieces.length - 1;
|
|
795
|
+
}
|
|
796
|
+
if (keepFrom > 0) {
|
|
797
|
+
omitted += keepFrom;
|
|
798
|
+
pieces = pieces.slice(keepFrom);
|
|
799
|
+
}
|
|
800
|
+
const marker = omitted > 0
|
|
801
|
+
? `[${omitted} earlier messages omitted: they did not fit the summarizer's context window]`
|
|
802
|
+
: undefined;
|
|
803
|
+
const parts = marker ? [marker] : [];
|
|
804
|
+
let usedChars = marker ? marker.length : 0;
|
|
805
|
+
let taken = 0;
|
|
806
|
+
let remainder;
|
|
807
|
+
for (const piece of pieces) {
|
|
808
|
+
const separator = parts.length > 0 ? 2 : 0;
|
|
809
|
+
if (usedChars + separator + piece.length <= roomChars) {
|
|
810
|
+
parts.push(piece);
|
|
811
|
+
usedChars += separator + piece.length;
|
|
812
|
+
taken++;
|
|
813
|
+
continue;
|
|
814
|
+
}
|
|
815
|
+
if (taken === 0) {
|
|
816
|
+
// A message larger than one request: send its start now and the rest next.
|
|
817
|
+
const cut = splitIndex(piece, roomChars - usedChars - separator);
|
|
818
|
+
parts.push(piece.slice(0, cut));
|
|
819
|
+
remainder = `[... continued]: ${piece.slice(cut)}`;
|
|
820
|
+
taken = 1;
|
|
821
|
+
}
|
|
822
|
+
break;
|
|
823
|
+
}
|
|
824
|
+
const response = await request.send(request.buildPrompt(parts.join("\n\n"), summary));
|
|
825
|
+
usage = usage ? combineUsage(usage, response.usage) : response.usage;
|
|
826
|
+
if (isContextOverflow(response)) {
|
|
827
|
+
if (++halvings > MAX_SUMMARY_BUDGET_HALVINGS) {
|
|
828
|
+
throw new Error(getSummarizationFailure(response, request.label));
|
|
829
|
+
}
|
|
830
|
+
budget = Math.floor(budget / 2);
|
|
831
|
+
continue;
|
|
832
|
+
}
|
|
833
|
+
summary = readSummary(response, request.label).text;
|
|
834
|
+
pieces = remainder === undefined ? pieces.slice(taken) : [remainder, ...pieces.slice(taken)];
|
|
835
|
+
requests++;
|
|
836
|
+
omitted = 0;
|
|
837
|
+
}
|
|
838
|
+
if (summary === undefined || usage === undefined) {
|
|
839
|
+
throw new Error(`${request.label} failed: nothing to summarize`);
|
|
626
840
|
}
|
|
627
|
-
|
|
628
|
-
return { text: textContent, usage: response.usage };
|
|
841
|
+
return { text: summary, usage };
|
|
629
842
|
}
|
|
630
843
|
function isProjectedTurnStart(entry) {
|
|
631
844
|
if (entry.sourceEntry.type === "compaction")
|
|
@@ -773,7 +986,7 @@ Only summarize information explicitly present above. Do not infer or recreate la
|
|
|
773
986
|
* @param sessionId - Optional routing session ID forwarded without enabling prompt caching
|
|
774
987
|
*/
|
|
775
988
|
export async function compact(preparation, model, apiKey, headers, customInstructions, signal, thinkingLevel, streamFn, env, retry, callbacks, sessionId) {
|
|
776
|
-
const { firstKeptEntryId, messagesToSummarize, turnPrefixMessages, isSplitTurn, tokensBefore, previousSummary, fileOps, } = preparation;
|
|
989
|
+
const { firstKeptEntryId, messagesToSummarize, turnPrefixMessages, isSplitTurn, tokensBefore, previousSummary, fileOps, settings, } = preparation;
|
|
777
990
|
// Generate summaries and merge into one
|
|
778
991
|
let summary;
|
|
779
992
|
let summaryUsage;
|
|
@@ -781,24 +994,24 @@ export async function compact(preparation, model, apiKey, headers, customInstruc
|
|
|
781
994
|
let historyText = previousSummary ?? "No prior history.";
|
|
782
995
|
let historyUsage;
|
|
783
996
|
if (messagesToSummarize.length > 0) {
|
|
784
|
-
const historyResult = await
|
|
997
|
+
const historyResult = await generateHistorySummary(messagesToSummarize, model, getSummaryMaxTokens(model, settings), apiKey, headers, signal, customInstructions, previousSummary, thinkingLevel, streamFn, env, retry, callbacks, sessionId);
|
|
785
998
|
historyText = historyResult.text;
|
|
786
999
|
historyUsage = historyResult.usage;
|
|
787
1000
|
}
|
|
788
|
-
const turnPrefixResult = await generateTurnPrefixSummary(turnPrefixMessages, model, apiKey, headers, env, signal, thinkingLevel, streamFn, retry, callbacks, sessionId, customInstructions);
|
|
1001
|
+
const turnPrefixResult = await generateTurnPrefixSummary(turnPrefixMessages, model, getSummaryMaxTokens(model, settings, "turnPrefix"), apiKey, headers, env, signal, thinkingLevel, streamFn, retry, callbacks, sessionId, customInstructions);
|
|
789
1002
|
// Merge into single summary
|
|
790
1003
|
summary = `${historyText}\n\n---\n\n**Turn Context (split turn):**\n\n${turnPrefixResult.text}`;
|
|
791
1004
|
summaryUsage = historyUsage ? combineUsage(historyUsage, turnPrefixResult.usage) : turnPrefixResult.usage;
|
|
792
1005
|
}
|
|
793
1006
|
else {
|
|
794
1007
|
// Just generate history summary
|
|
795
|
-
const result = await
|
|
1008
|
+
const result = await generateHistorySummary(messagesToSummarize, model, getSummaryMaxTokens(model, settings), apiKey, headers, signal, customInstructions, previousSummary, thinkingLevel, streamFn, env, retry, callbacks, sessionId);
|
|
796
1009
|
summary = result.text;
|
|
797
1010
|
summaryUsage = result.usage;
|
|
798
1011
|
}
|
|
799
1012
|
// Compute file lists and append to summary
|
|
800
|
-
const { readFiles, modifiedFiles } = computeFileLists(fileOps);
|
|
801
|
-
summary += formatFileOperations(readFiles, modifiedFiles);
|
|
1013
|
+
const { readFiles, modifiedFiles, omittedReadFiles, omittedModifiedFiles } = computeFileLists(fileOps);
|
|
1014
|
+
summary += formatFileOperations(readFiles, modifiedFiles, omittedReadFiles, omittedModifiedFiles);
|
|
802
1015
|
if (!firstKeptEntryId) {
|
|
803
1016
|
throw new Error("First kept entry has no UUID - session may need migration");
|
|
804
1017
|
}
|
|
@@ -813,26 +1026,22 @@ export async function compact(preparation, model, apiKey, headers, customInstruc
|
|
|
813
1026
|
/**
|
|
814
1027
|
* Generate a summary for a turn prefix (when splitting a turn).
|
|
815
1028
|
*/
|
|
816
|
-
async function generateTurnPrefixSummary(messages, model, apiKey, headers, env, signal, thinkingLevel, streamFn, retry, callbacks, sessionId, customInstructions) {
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
}
|
|
833
|
-
return {
|
|
834
|
-
text: contentText(response.content),
|
|
835
|
-
usage: response.usage,
|
|
836
|
-
};
|
|
1029
|
+
async function generateTurnPrefixSummary(messages, model, maxTokens, apiKey, headers, env, signal, thinkingLevel, streamFn, retry, callbacks, sessionId, customInstructions) {
|
|
1030
|
+
const options = createSummarizationOptions(model, maxTokens, apiKey, headers, env, signal, thinkingLevel, sessionId);
|
|
1031
|
+
return summarizeWithinWindow(messages, undefined, model, maxTokens, {
|
|
1032
|
+
label: "Turn prefix summarization",
|
|
1033
|
+
signal,
|
|
1034
|
+
buildPrompt: (conversationText, checkpoint) => {
|
|
1035
|
+
// A split request carries the checkpoint of the turn's earlier messages forward.
|
|
1036
|
+
let promptText = checkpoint
|
|
1037
|
+
? `# Earlier checkpoint\n${checkpoint}\n\n# Conversation\n${conversationText}\n\n# Instructions\n${TURN_PREFIX_SUMMARIZATION_PROMPT}\n\nThe earlier checkpoint covers the messages before the ones above. Update it with the messages above, in the same format.`
|
|
1038
|
+
: `# Conversation\n${conversationText}\n\n# Instructions\n${TURN_PREFIX_SUMMARIZATION_PROMPT}`;
|
|
1039
|
+
if (customInstructions) {
|
|
1040
|
+
promptText = `${promptText}\n\nAdditional focus: ${customInstructions}`;
|
|
1041
|
+
}
|
|
1042
|
+
return promptText;
|
|
1043
|
+
},
|
|
1044
|
+
send: (promptText) => completeSummarization(model, buildSummarizationContext(promptText), options, streamFn, retry, callbacks),
|
|
1045
|
+
});
|
|
837
1046
|
}
|
|
838
1047
|
//# sourceMappingURL=compaction.js.map
|