@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
|
@@ -21,6 +21,42 @@ import { NodeHttpHandler } from "@smithy/node-http-handler";
|
|
|
21
21
|
import { HttpProxyAgent } from "http-proxy-agent";
|
|
22
22
|
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
23
23
|
|
|
24
|
+
// packages/ai/src/utils/diagnostics.ts
|
|
25
|
+
var streamProgress = /* @__PURE__ */ new WeakMap();
|
|
26
|
+
var streamProgressKey = /* @__PURE__ */ Symbol.for("@humain/pi-ai/private-stream-progress");
|
|
27
|
+
function getStreamProgress(signal) {
|
|
28
|
+
if (!signal) return void 0;
|
|
29
|
+
const local = streamProgress.get(signal);
|
|
30
|
+
if (local) return local;
|
|
31
|
+
try {
|
|
32
|
+
const reference = Object.getOwnPropertyDescriptor(signal, streamProgressKey)?.value;
|
|
33
|
+
const state = WeakRef.prototype.deref.call(reference);
|
|
34
|
+
if (state === null || typeof state !== "object") return void 0;
|
|
35
|
+
const onContent = Object.getOwnPropertyDescriptor(state, "onContent");
|
|
36
|
+
const retryAt = Object.getOwnPropertyDescriptor(state, "retryAt");
|
|
37
|
+
if (typeof onContent?.value !== "function") return void 0;
|
|
38
|
+
if (retryAt && (typeof retryAt.value !== "number" || !Number.isFinite(retryAt.value) || retryAt.value <= 0))
|
|
39
|
+
return void 0;
|
|
40
|
+
return state;
|
|
41
|
+
} catch {
|
|
42
|
+
return void 0;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function reportContentProgress(signal) {
|
|
46
|
+
const progress = getStreamProgress(signal);
|
|
47
|
+
if (!progress) return;
|
|
48
|
+
let onContent;
|
|
49
|
+
try {
|
|
50
|
+
onContent = Object.getOwnPropertyDescriptor(progress, "onContent")?.value;
|
|
51
|
+
} catch {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (typeof onContent === "function") onContent();
|
|
55
|
+
}
|
|
56
|
+
function appendAssistantMessageDiagnostic(message, diagnostic) {
|
|
57
|
+
message.diagnostics = [...message.diagnostics ?? [], diagnostic];
|
|
58
|
+
}
|
|
59
|
+
|
|
24
60
|
// packages/ai/src/utils/event-stream.ts
|
|
25
61
|
var FifoQueue = class {
|
|
26
62
|
incoming = [];
|
|
@@ -140,22 +176,6 @@ var AssistantMessageEventStream = class extends EventStream {
|
|
|
140
176
|
}
|
|
141
177
|
};
|
|
142
178
|
|
|
143
|
-
// packages/ai/src/utils/diagnostics.ts
|
|
144
|
-
function appendAssistantMessageDiagnostic(message, diagnostic) {
|
|
145
|
-
message.diagnostics = [...message.diagnostics ?? [], diagnostic];
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// packages/ai/src/utils/version.ts
|
|
149
|
-
var PI_AI_VERSION = "1.4.0";
|
|
150
|
-
|
|
151
|
-
// packages/ai/src/utils/identity.ts
|
|
152
|
-
function getClientVersion(identity) {
|
|
153
|
-
return identity?.version ?? PI_AI_VERSION;
|
|
154
|
-
}
|
|
155
|
-
function getClientProduct(identity) {
|
|
156
|
-
return identity?.product ?? "pi";
|
|
157
|
-
}
|
|
158
|
-
|
|
159
179
|
// packages/ai/src/utils/text.ts
|
|
160
180
|
function contentText(content, separator = "\n") {
|
|
161
181
|
if (typeof content === "string") return content;
|
|
@@ -168,6 +188,20 @@ function getSystemMessageText(message) {
|
|
|
168
188
|
}
|
|
169
189
|
return parts.filter((part) => part.length > 0).join("\n\n");
|
|
170
190
|
}
|
|
191
|
+
function ownedSlice(text, start, end = text.length) {
|
|
192
|
+
return `${text.slice(start, end)} `.slice(0, -1);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// packages/ai/src/utils/version.ts
|
|
196
|
+
var PI_AI_VERSION = "1.5.0";
|
|
197
|
+
|
|
198
|
+
// packages/ai/src/utils/identity.ts
|
|
199
|
+
function getClientVersion(identity) {
|
|
200
|
+
return identity?.version ?? PI_AI_VERSION;
|
|
201
|
+
}
|
|
202
|
+
function getClientProduct(identity) {
|
|
203
|
+
return identity?.product ?? "pi";
|
|
204
|
+
}
|
|
171
205
|
|
|
172
206
|
// packages/ai/src/utils/transcript.ts
|
|
173
207
|
function isSystemMessage(message) {
|
|
@@ -237,6 +271,7 @@ function calculateCost(model, usage) {
|
|
|
237
271
|
usage.cost.cacheRead = rates.cacheRead / 1e6 * usage.cacheRead;
|
|
238
272
|
usage.cost.cacheWrite = (rates.cacheWrite * shortWrite + rates.input * 2 * longWrite) / 1e6;
|
|
239
273
|
usage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;
|
|
274
|
+
usage.cost.totalFromProvider = false;
|
|
240
275
|
return usage.cost;
|
|
241
276
|
}
|
|
242
277
|
var EXTENDED_THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
@@ -365,7 +400,7 @@ function truncateErrorText(text, maxChars) {
|
|
|
365
400
|
}
|
|
366
401
|
}
|
|
367
402
|
const suffix = "... [truncated]";
|
|
368
|
-
return cap < suffix.length ? suffix.slice(0, cap) : `${clean
|
|
403
|
+
return cap < suffix.length ? suffix.slice(0, cap) : `${ownedSlice(clean, 0, cap - suffix.length).replace(/\[[^\]]*$/, "")}${suffix}`;
|
|
369
404
|
}
|
|
370
405
|
function safeJsonStringify(value) {
|
|
371
406
|
try {
|
|
@@ -945,24 +980,6 @@ function parsePartialJsonPrefix(scan, text) {
|
|
|
945
980
|
return void 0;
|
|
946
981
|
}
|
|
947
982
|
}
|
|
948
|
-
var lengthsParsedWhileStreaming = /* @__PURE__ */ new WeakMap();
|
|
949
|
-
var textsParsedWhileStreaming = /* @__PURE__ */ new WeakMap();
|
|
950
|
-
var scansWhileStreaming = /* @__PURE__ */ new WeakMap();
|
|
951
|
-
function parseStreamingJsonWhileStreaming(block, partialJson, current) {
|
|
952
|
-
const length = partialJson?.length ?? 0;
|
|
953
|
-
const parsed = lengthsParsedWhileStreaming.get(block);
|
|
954
|
-
if (current !== void 0 && parsed !== void 0 && (length > parsed || partialJson === textsParsedWhileStreaming.get(block)) && length - parsed < (parsed < 1024 ? 1 : parsed >> 3)) {
|
|
955
|
-
return current;
|
|
956
|
-
}
|
|
957
|
-
lengthsParsedWhileStreaming.set(block, length);
|
|
958
|
-
textsParsedWhileStreaming.set(block, partialJson);
|
|
959
|
-
let scan = scansWhileStreaming.get(block);
|
|
960
|
-
if (!scan) {
|
|
961
|
-
scan = createPartialJsonScan();
|
|
962
|
-
scansWhileStreaming.set(block, scan);
|
|
963
|
-
}
|
|
964
|
-
return parseStreamingJsonWith(partialJson, scan);
|
|
965
|
-
}
|
|
966
983
|
|
|
967
984
|
// packages/ai/src/utils/provider-env.ts
|
|
968
985
|
var procEnvCache = null;
|
|
@@ -1185,6 +1202,402 @@ function sanitizeSurrogates(text) {
|
|
|
1185
1202
|
return text.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g, "");
|
|
1186
1203
|
}
|
|
1187
1204
|
|
|
1205
|
+
// packages/ai/src/utils/streaming-json.ts
|
|
1206
|
+
var MAX_REPORTED_DEPTH = 32;
|
|
1207
|
+
var ROOT_SLOT = { kind: "root" };
|
|
1208
|
+
var CREDIT_PER_APPEND = 256;
|
|
1209
|
+
var CREDIT_PER_CHARACTER = 8;
|
|
1210
|
+
var MAX_PENDING_SCALAR_LENGTH = 64;
|
|
1211
|
+
var NUMBER2 = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
|
|
1212
|
+
var NUMBER_WITHOUT_EXPONENT_DIGITS = /^(-?(?:0|[1-9]\d*)(?:\.\d+)?)[eE][+-]?$/;
|
|
1213
|
+
var LITERALS = [
|
|
1214
|
+
["true", true],
|
|
1215
|
+
["false", false],
|
|
1216
|
+
["null", null]
|
|
1217
|
+
];
|
|
1218
|
+
var QUOTE = 34;
|
|
1219
|
+
var BACKSLASH = 92;
|
|
1220
|
+
var StreamingJsonParser = class {
|
|
1221
|
+
#root = void 0;
|
|
1222
|
+
#done = false;
|
|
1223
|
+
#stack = [];
|
|
1224
|
+
#string = void 0;
|
|
1225
|
+
#scalar = "";
|
|
1226
|
+
#scalarSlot = void 0;
|
|
1227
|
+
/** Sum of `size + 1` over the open path: what a fresh snapshot copies. */
|
|
1228
|
+
#pathCost = 0;
|
|
1229
|
+
#credit = 0;
|
|
1230
|
+
#dirty = false;
|
|
1231
|
+
#snapshot = void 0;
|
|
1232
|
+
/** Changes of the piece being read. */
|
|
1233
|
+
#changes = [];
|
|
1234
|
+
/**
|
|
1235
|
+
* Read the next piece of text; returns the changes it made, in order. Costs time linear in `text.length`.
|
|
1236
|
+
*/
|
|
1237
|
+
append(text) {
|
|
1238
|
+
this.#credit += CREDIT_PER_APPEND + CREDIT_PER_CHARACTER * text.length;
|
|
1239
|
+
this.#changes = [];
|
|
1240
|
+
if (this.#string !== void 0) this.#string.change = void 0;
|
|
1241
|
+
let index = 0;
|
|
1242
|
+
while (index < text.length && !this.#done) {
|
|
1243
|
+
const open = this.#string;
|
|
1244
|
+
if (open !== void 0) index = this.#readString(open, text, index);
|
|
1245
|
+
else if (this.#scalar !== "") index = this.#readScalar(text, index);
|
|
1246
|
+
else this.#structural(text[index++]);
|
|
1247
|
+
}
|
|
1248
|
+
return this.#changes;
|
|
1249
|
+
}
|
|
1250
|
+
/**
|
|
1251
|
+
* The value of the text read so far: `undefined` before a value starts, otherwise a plain JSON value that never
|
|
1252
|
+
* changes afterwards. Returns the previous snapshot while the text read since did not change the value, or while a
|
|
1253
|
+
* fresh copy of the open path is not yet paid for (see the module comment).
|
|
1254
|
+
*/
|
|
1255
|
+
snapshot() {
|
|
1256
|
+
if (!this.#dirty) return this.#snapshot;
|
|
1257
|
+
const pending = this.#pendingScalar();
|
|
1258
|
+
const cost = this.#pathCost + (pending === void 0 ? 0 : 1);
|
|
1259
|
+
if (cost > this.#credit) return this.#snapshot;
|
|
1260
|
+
this.#credit -= cost;
|
|
1261
|
+
this.#dirty = false;
|
|
1262
|
+
this.#snapshot = this.#copyOpenPath(pending);
|
|
1263
|
+
return this.#snapshot;
|
|
1264
|
+
}
|
|
1265
|
+
/** Read string characters from `start` until the string ends or the text does; returns the next index. */
|
|
1266
|
+
#readString(open, text, start) {
|
|
1267
|
+
let runStart = start;
|
|
1268
|
+
for (let index = start; index < text.length; index++) {
|
|
1269
|
+
const code = text.charCodeAt(index);
|
|
1270
|
+
if (open.escape !== "") {
|
|
1271
|
+
if (this.#continueEscape(open, text[index])) {
|
|
1272
|
+
runStart = index + 1;
|
|
1273
|
+
continue;
|
|
1274
|
+
}
|
|
1275
|
+
runStart = index;
|
|
1276
|
+
}
|
|
1277
|
+
if (code === QUOTE) {
|
|
1278
|
+
if (index > runStart) this.#appendString(open, text.slice(runStart, index));
|
|
1279
|
+
this.#endString(open);
|
|
1280
|
+
return index + 1;
|
|
1281
|
+
}
|
|
1282
|
+
if (code === BACKSLASH) {
|
|
1283
|
+
if (index > runStart) this.#appendString(open, text.slice(runStart, index));
|
|
1284
|
+
open.escape = "\\";
|
|
1285
|
+
runStart = index + 1;
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
if (text.length > runStart) this.#appendString(open, text.slice(runStart));
|
|
1289
|
+
return text.length;
|
|
1290
|
+
}
|
|
1291
|
+
/** Read number or literal characters from `start` up to the next delimiter; returns the delimiter's index. */
|
|
1292
|
+
#readScalar(text, start) {
|
|
1293
|
+
let end = start;
|
|
1294
|
+
while (end < text.length && !isDelimiter(text[end])) end++;
|
|
1295
|
+
if (end > start) {
|
|
1296
|
+
this.#scalar += text.slice(start, end);
|
|
1297
|
+
if (this.#scalarSlot !== void 0) this.#dirty = true;
|
|
1298
|
+
}
|
|
1299
|
+
if (end < text.length) this.#endScalar();
|
|
1300
|
+
return end;
|
|
1301
|
+
}
|
|
1302
|
+
/** Handle one character outside strings. */
|
|
1303
|
+
#structural(char) {
|
|
1304
|
+
switch (char) {
|
|
1305
|
+
case " ":
|
|
1306
|
+
case " ":
|
|
1307
|
+
case "\n":
|
|
1308
|
+
case "\r":
|
|
1309
|
+
return;
|
|
1310
|
+
case '"':
|
|
1311
|
+
this.#startString();
|
|
1312
|
+
return;
|
|
1313
|
+
case "{":
|
|
1314
|
+
case "[":
|
|
1315
|
+
this.#openContainer(char === "{" ? {} : []);
|
|
1316
|
+
return;
|
|
1317
|
+
case "}":
|
|
1318
|
+
case "]":
|
|
1319
|
+
this.#closeContainer();
|
|
1320
|
+
return;
|
|
1321
|
+
case ":": {
|
|
1322
|
+
const frame = this.#stack.at(-1);
|
|
1323
|
+
if (frame !== void 0 && !Array.isArray(frame.container) && frame.phase === "colon")
|
|
1324
|
+
frame.phase = "value";
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
case ",": {
|
|
1328
|
+
const frame = this.#stack.at(-1);
|
|
1329
|
+
if (frame !== void 0) frame.phase = Array.isArray(frame.container) ? "value" : "key";
|
|
1330
|
+
return;
|
|
1331
|
+
}
|
|
1332
|
+
default:
|
|
1333
|
+
this.#scalar = char;
|
|
1334
|
+
this.#scalarSlot = this.#valueSlot();
|
|
1335
|
+
if (this.#scalarSlot !== void 0) this.#dirty = true;
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
/** Where a value starting now goes, or `undefined` when this position takes no value. */
|
|
1339
|
+
#valueSlot() {
|
|
1340
|
+
const frame = this.#stack.at(-1);
|
|
1341
|
+
if (frame === void 0) return this.#root === void 0 ? ROOT_SLOT : void 0;
|
|
1342
|
+
if (Array.isArray(frame.container)) return { kind: "element", index: frame.container.length };
|
|
1343
|
+
if ((frame.phase === "value" || frame.phase === "colon") && frame.key !== void 0) {
|
|
1344
|
+
return { kind: "member", key: frame.key };
|
|
1345
|
+
}
|
|
1346
|
+
return void 0;
|
|
1347
|
+
}
|
|
1348
|
+
#startString() {
|
|
1349
|
+
const frame = this.#stack.at(-1);
|
|
1350
|
+
if (frame !== void 0 && !Array.isArray(frame.container) && (frame.phase === "key" || frame.phase === "comma")) {
|
|
1351
|
+
this.#string = { target: "key", slot: void 0, text: "", escape: "", path: void 0, change: void 0 };
|
|
1352
|
+
return;
|
|
1353
|
+
}
|
|
1354
|
+
const slot = this.#valueSlot();
|
|
1355
|
+
const path = this.#reportedPath(slot);
|
|
1356
|
+
this.#string = { target: "value", slot, text: "", escape: "", path, change: void 0 };
|
|
1357
|
+
this.#place(slot, "");
|
|
1358
|
+
if (path !== void 0) this.#string.change = this.#report({ kind: "set", path, value: "" });
|
|
1359
|
+
}
|
|
1360
|
+
/** The path of a value at `slot` in the innermost open container, when its changes are reported. */
|
|
1361
|
+
#reportedPath(slot) {
|
|
1362
|
+
if (slot === void 0) return void 0;
|
|
1363
|
+
if (slot.kind === "root") return [];
|
|
1364
|
+
const frame = this.#stack.at(-1);
|
|
1365
|
+
if (!frame.reportsInside) return void 0;
|
|
1366
|
+
return [...frame.path, slot.kind === "member" ? slot.key : slot.index];
|
|
1367
|
+
}
|
|
1368
|
+
#report(change) {
|
|
1369
|
+
this.#changes.push(change);
|
|
1370
|
+
return change;
|
|
1371
|
+
}
|
|
1372
|
+
/** Continue an escape with `char`; returns false when `char` is not part of it and must be read normally. */
|
|
1373
|
+
#continueEscape(open, char) {
|
|
1374
|
+
if (open.escape === "\\") {
|
|
1375
|
+
const decoded = SIMPLE_ESCAPES[char];
|
|
1376
|
+
if (decoded !== void 0) {
|
|
1377
|
+
open.escape = "";
|
|
1378
|
+
this.#appendString(open, decoded);
|
|
1379
|
+
return true;
|
|
1380
|
+
}
|
|
1381
|
+
if (char === "u") {
|
|
1382
|
+
open.escape = "\\u";
|
|
1383
|
+
return true;
|
|
1384
|
+
}
|
|
1385
|
+
open.escape = "";
|
|
1386
|
+
this.#appendString(open, "\\");
|
|
1387
|
+
return false;
|
|
1388
|
+
}
|
|
1389
|
+
if (isHexDigit2(char)) {
|
|
1390
|
+
open.escape += char;
|
|
1391
|
+
if (open.escape.length < 6) return true;
|
|
1392
|
+
const decoded = String.fromCharCode(Number.parseInt(open.escape.slice(2), 16));
|
|
1393
|
+
open.escape = "";
|
|
1394
|
+
this.#appendString(open, decoded);
|
|
1395
|
+
return true;
|
|
1396
|
+
}
|
|
1397
|
+
const literal = open.escape;
|
|
1398
|
+
open.escape = "";
|
|
1399
|
+
this.#appendString(open, literal);
|
|
1400
|
+
return false;
|
|
1401
|
+
}
|
|
1402
|
+
#appendString(open, text) {
|
|
1403
|
+
open.text += text;
|
|
1404
|
+
if (open.target !== "value") return;
|
|
1405
|
+
this.#place(open.slot, open.text);
|
|
1406
|
+
if (open.path === void 0) return;
|
|
1407
|
+
const change = open.change;
|
|
1408
|
+
if (change !== void 0 && this.#changes.at(-1) === change) {
|
|
1409
|
+
if (change.kind === "set") change.value = change.value + text;
|
|
1410
|
+
else change.text += text;
|
|
1411
|
+
return;
|
|
1412
|
+
}
|
|
1413
|
+
open.change = this.#report({ kind: "append", path: open.path, text });
|
|
1414
|
+
}
|
|
1415
|
+
#endString(open) {
|
|
1416
|
+
this.#string = void 0;
|
|
1417
|
+
const frame = this.#stack.at(-1);
|
|
1418
|
+
if (open.target === "key") {
|
|
1419
|
+
if (frame === void 0) return;
|
|
1420
|
+
frame.key = open.text;
|
|
1421
|
+
frame.phase = "colon";
|
|
1422
|
+
return;
|
|
1423
|
+
}
|
|
1424
|
+
this.#valueEnded(frame);
|
|
1425
|
+
}
|
|
1426
|
+
#endScalar() {
|
|
1427
|
+
const token = this.#scalar;
|
|
1428
|
+
const slot = this.#scalarSlot;
|
|
1429
|
+
this.#scalar = "";
|
|
1430
|
+
this.#scalarSlot = void 0;
|
|
1431
|
+
const value = scalarValue(token);
|
|
1432
|
+
if (value !== void 0) {
|
|
1433
|
+
this.#place(slot, value);
|
|
1434
|
+
const path = this.#reportedPath(slot);
|
|
1435
|
+
if (path !== void 0) this.#report({ kind: "set", path, value });
|
|
1436
|
+
}
|
|
1437
|
+
this.#valueEnded(this.#stack.at(-1));
|
|
1438
|
+
}
|
|
1439
|
+
/** The value of the unterminated scalar at the end of the text, if it shows. */
|
|
1440
|
+
#pendingScalar() {
|
|
1441
|
+
const slot = this.#scalarSlot;
|
|
1442
|
+
const token = this.#scalar;
|
|
1443
|
+
if (slot === void 0 || token === "" || token.length > MAX_PENDING_SCALAR_LENGTH) return void 0;
|
|
1444
|
+
const value = pendingScalarValue(token);
|
|
1445
|
+
return value === void 0 ? void 0 : { slot, value };
|
|
1446
|
+
}
|
|
1447
|
+
#openContainer(container) {
|
|
1448
|
+
const slot = this.#valueSlot();
|
|
1449
|
+
const path = this.#reportedPath(slot);
|
|
1450
|
+
this.#place(slot, container);
|
|
1451
|
+
this.#stack.push({
|
|
1452
|
+
container,
|
|
1453
|
+
slot,
|
|
1454
|
+
path,
|
|
1455
|
+
reportsInside: path !== void 0 && path.length < MAX_REPORTED_DEPTH,
|
|
1456
|
+
size: 0,
|
|
1457
|
+
key: void 0,
|
|
1458
|
+
phase: Array.isArray(container) ? "value" : "key"
|
|
1459
|
+
});
|
|
1460
|
+
this.#pathCost += 1;
|
|
1461
|
+
this.#dirty = true;
|
|
1462
|
+
if (path !== void 0) this.#report({ kind: "set", path, value: Array.isArray(container) ? [] : {} });
|
|
1463
|
+
}
|
|
1464
|
+
#closeContainer() {
|
|
1465
|
+
const frame = this.#stack.pop();
|
|
1466
|
+
if (frame === void 0) return;
|
|
1467
|
+
this.#pathCost -= frame.size + 1;
|
|
1468
|
+
this.#dirty = true;
|
|
1469
|
+
if (frame.path !== void 0 && !frame.reportsInside) {
|
|
1470
|
+
this.#report({ kind: "set", path: frame.path, value: frame.container });
|
|
1471
|
+
}
|
|
1472
|
+
this.#valueEnded(this.#stack.at(-1));
|
|
1473
|
+
}
|
|
1474
|
+
/** A value in `frame`, or the root value when there is no frame, has ended. */
|
|
1475
|
+
#valueEnded(frame) {
|
|
1476
|
+
if (frame === void 0) {
|
|
1477
|
+
if (this.#root !== void 0) this.#done = true;
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
frame.phase = "comma";
|
|
1481
|
+
}
|
|
1482
|
+
/** Set the value at `slot` in the open path; nothing for a value in an invalid position. */
|
|
1483
|
+
#place(slot, value) {
|
|
1484
|
+
if (slot === void 0) return;
|
|
1485
|
+
this.#dirty = true;
|
|
1486
|
+
if (slot.kind === "root") {
|
|
1487
|
+
this.#root = value;
|
|
1488
|
+
return;
|
|
1489
|
+
}
|
|
1490
|
+
const frame = this.#stack.at(-1);
|
|
1491
|
+
if (slot.kind === "element") {
|
|
1492
|
+
const elements = frame.container;
|
|
1493
|
+
if (slot.index === elements.length) {
|
|
1494
|
+
frame.size++;
|
|
1495
|
+
this.#pathCost++;
|
|
1496
|
+
}
|
|
1497
|
+
elements[slot.index] = value;
|
|
1498
|
+
return;
|
|
1499
|
+
}
|
|
1500
|
+
const members = frame.container;
|
|
1501
|
+
if (!Object.hasOwn(members, slot.key)) {
|
|
1502
|
+
frame.size++;
|
|
1503
|
+
this.#pathCost++;
|
|
1504
|
+
}
|
|
1505
|
+
setMember(members, slot.key, value);
|
|
1506
|
+
}
|
|
1507
|
+
/** A fresh snapshot: copies of the open containers, innermost first, each holding the copy of its open child. */
|
|
1508
|
+
#copyOpenPath(pending) {
|
|
1509
|
+
if (this.#stack.length === 0) return pending?.slot.kind === "root" ? pending.value : this.#root;
|
|
1510
|
+
let child;
|
|
1511
|
+
let childSlot;
|
|
1512
|
+
for (let depth = this.#stack.length - 1; depth >= 0; depth--) {
|
|
1513
|
+
const frame = this.#stack[depth];
|
|
1514
|
+
const copy = Array.isArray(frame.container) ? frame.container.slice() : { ...frame.container };
|
|
1515
|
+
if (depth === this.#stack.length - 1 && pending !== void 0) setSlot(copy, pending.slot, pending.value);
|
|
1516
|
+
if (child !== void 0 && childSlot !== void 0) setSlot(copy, childSlot, child);
|
|
1517
|
+
child = copy;
|
|
1518
|
+
childSlot = frame.slot;
|
|
1519
|
+
}
|
|
1520
|
+
return childSlot?.kind === "root" ? child : this.#root;
|
|
1521
|
+
}
|
|
1522
|
+
};
|
|
1523
|
+
var ToolCallArgumentsStream = class {
|
|
1524
|
+
#text = "";
|
|
1525
|
+
#parser = new StreamingJsonParser();
|
|
1526
|
+
#snapshot = void 0;
|
|
1527
|
+
#arguments = {};
|
|
1528
|
+
/** The raw argument text received so far. */
|
|
1529
|
+
get text() {
|
|
1530
|
+
return this.#text;
|
|
1531
|
+
}
|
|
1532
|
+
/** Append a piece of argument text; returns the partial arguments, a new object whenever they changed. */
|
|
1533
|
+
append(delta) {
|
|
1534
|
+
this.#text += delta;
|
|
1535
|
+
this.#parser.append(delta);
|
|
1536
|
+
return this.#partial();
|
|
1537
|
+
}
|
|
1538
|
+
/**
|
|
1539
|
+
* Take the provider's complete argument text. When it continues the text so far, returns the missing piece as
|
|
1540
|
+
* `delta`; otherwise starts over with `text`. Either way returns the partial arguments of `text`.
|
|
1541
|
+
*/
|
|
1542
|
+
replace(text) {
|
|
1543
|
+
if (text.startsWith(this.#text)) {
|
|
1544
|
+
const delta = text.slice(this.#text.length);
|
|
1545
|
+
return { delta, arguments: delta === "" ? this.#partial() : this.append(delta) };
|
|
1546
|
+
}
|
|
1547
|
+
this.#text = "";
|
|
1548
|
+
this.#parser = new StreamingJsonParser();
|
|
1549
|
+
return { delta: void 0, arguments: this.append(text) };
|
|
1550
|
+
}
|
|
1551
|
+
/** The final arguments: one full parse of the complete text, which reports malformed arguments. */
|
|
1552
|
+
finish() {
|
|
1553
|
+
return parseToolCallArguments(this.#text);
|
|
1554
|
+
}
|
|
1555
|
+
#partial() {
|
|
1556
|
+
const snapshot = this.#parser.snapshot();
|
|
1557
|
+
if (snapshot === this.#snapshot) return this.#arguments;
|
|
1558
|
+
this.#snapshot = snapshot;
|
|
1559
|
+
this.#arguments = typeof snapshot === "object" && snapshot !== null && !Array.isArray(snapshot) ? snapshot : {};
|
|
1560
|
+
return this.#arguments;
|
|
1561
|
+
}
|
|
1562
|
+
};
|
|
1563
|
+
var SIMPLE_ESCAPES = {
|
|
1564
|
+
'"': '"',
|
|
1565
|
+
"\\": "\\",
|
|
1566
|
+
"/": "/",
|
|
1567
|
+
b: "\b",
|
|
1568
|
+
f: "\f",
|
|
1569
|
+
n: "\n",
|
|
1570
|
+
r: "\r",
|
|
1571
|
+
t: " "
|
|
1572
|
+
};
|
|
1573
|
+
function isDelimiter(char) {
|
|
1574
|
+
return char === " " || char === " " || char === "\n" || char === "\r" || char === "," || char === ":" || char === "{" || char === "}" || char === "[" || char === "]" || char === '"';
|
|
1575
|
+
}
|
|
1576
|
+
function isHexDigit2(char) {
|
|
1577
|
+
return char >= "0" && char <= "9" || char >= "a" && char <= "f" || char >= "A" && char <= "F";
|
|
1578
|
+
}
|
|
1579
|
+
function scalarValue(token) {
|
|
1580
|
+
for (const [literal, value] of LITERALS) if (token === literal) return value;
|
|
1581
|
+
return NUMBER2.test(token) ? Number(token) : void 0;
|
|
1582
|
+
}
|
|
1583
|
+
function pendingScalarValue(token) {
|
|
1584
|
+
for (const [literal, value] of LITERALS) if (literal.startsWith(token)) return value;
|
|
1585
|
+
if (NUMBER2.test(token)) return Number(token);
|
|
1586
|
+
const mantissa = NUMBER_WITHOUT_EXPONENT_DIGITS.exec(token);
|
|
1587
|
+
return mantissa === null ? void 0 : Number(mantissa[1]);
|
|
1588
|
+
}
|
|
1589
|
+
function setSlot(container, slot, value) {
|
|
1590
|
+
if (slot.kind === "element") container[slot.index] = value;
|
|
1591
|
+
else if (slot.kind === "member") setMember(container, slot.key, value);
|
|
1592
|
+
}
|
|
1593
|
+
function setMember(members, key, value) {
|
|
1594
|
+
if (key === "__proto__") {
|
|
1595
|
+
Object.defineProperty(members, key, { value, writable: true, enumerable: true, configurable: true });
|
|
1596
|
+
} else {
|
|
1597
|
+
members[key] = value;
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1188
1601
|
// packages/ai/src/utils/usage.ts
|
|
1189
1602
|
function hasIncompleteUsage(required, optional = []) {
|
|
1190
1603
|
return [...required, ...optional.filter((value) => value !== void 0)].some(
|
|
@@ -1192,6 +1605,12 @@ function hasIncompleteUsage(required, optional = []) {
|
|
|
1192
1605
|
);
|
|
1193
1606
|
}
|
|
1194
1607
|
|
|
1608
|
+
// packages/ai/src/api/anthropic-thinking.ts
|
|
1609
|
+
function supportsDisabledAnthropicThinking(model) {
|
|
1610
|
+
const name = `${model.id} ${model.name}`.toLowerCase().replace(/[.\s]+/g, "-");
|
|
1611
|
+
return model.thinkingLevelMap?.off !== null && !/(?:fable-5|mythos-(?:5|preview)|opus-5-5|sonnet-5-5)(?:-|$)/.test(name);
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1195
1614
|
// packages/ai/src/api/constrained-sampling.ts
|
|
1196
1615
|
var UnsupportedStrictJsonSchemaError = class extends Error {
|
|
1197
1616
|
};
|
|
@@ -1300,6 +1719,10 @@ function makeStrictJsonSchema(schema, isUnsupportedKeyword) {
|
|
|
1300
1719
|
}
|
|
1301
1720
|
return cloned;
|
|
1302
1721
|
}
|
|
1722
|
+
function prefersJsonSchemaStrictSampling(tool) {
|
|
1723
|
+
const config = tool.constrainedSampling;
|
|
1724
|
+
return !!config && config.type === "json_schema" && config.strict === "prefer";
|
|
1725
|
+
}
|
|
1303
1726
|
function getJsonSchemaToolParameters(tool, strict) {
|
|
1304
1727
|
return strict === true ? makeStrictJsonSchema(tool.parameters) : tool.parameters;
|
|
1305
1728
|
}
|
|
@@ -1405,11 +1828,15 @@ function estimateToolsTokens(tools) {
|
|
|
1405
1828
|
|
|
1406
1829
|
// packages/ai/src/api/simple-options.ts
|
|
1407
1830
|
var CONTEXT_SAFETY_TOKENS = 4096;
|
|
1831
|
+
var ESTIMATE_SAFETY_RATIO = 0.2;
|
|
1832
|
+
var MIN_CLAMPED_MAX_TOKENS = CONTEXT_SAFETY_TOKENS;
|
|
1408
1833
|
var MIN_MAX_TOKENS = 1;
|
|
1409
1834
|
function clampMaxTokensToContext(model, context, maxTokens) {
|
|
1410
1835
|
if (model.contextWindow <= 0) return Math.max(MIN_MAX_TOKENS, maxTokens);
|
|
1411
|
-
const
|
|
1412
|
-
|
|
1836
|
+
const estimate = estimateContextTokens(context);
|
|
1837
|
+
const margin = Math.max(CONTEXT_SAFETY_TOKENS, Math.ceil(estimate.trailingTokens * ESTIMATE_SAFETY_RATIO));
|
|
1838
|
+
const available = model.contextWindow - estimate.tokens - margin;
|
|
1839
|
+
return Math.min(maxTokens, Math.max(MIN_CLAMPED_MAX_TOKENS, available));
|
|
1413
1840
|
}
|
|
1414
1841
|
function resolveSamplingParams(model, thinkingLevel, requestParams) {
|
|
1415
1842
|
const effectiveThinkingLevel = clampThinkingLevel(model, thinkingLevel);
|
|
@@ -1665,7 +2092,7 @@ var stream = (model, context, options = {}) => {
|
|
|
1665
2092
|
stopReason: "pending",
|
|
1666
2093
|
timestamp: Date.now()
|
|
1667
2094
|
};
|
|
1668
|
-
const
|
|
2095
|
+
const openBlocks = /* @__PURE__ */ new Map();
|
|
1669
2096
|
const optionsProfile = options.profile || options.env?.AWS_PROFILE;
|
|
1670
2097
|
const config = {
|
|
1671
2098
|
profile: optionsProfile || getProviderEnvValue("AWS_PROFILE", options.env),
|
|
@@ -1741,13 +2168,25 @@ var stream = (model, context, options = {}) => {
|
|
|
1741
2168
|
if (customHeaders) {
|
|
1742
2169
|
addCustomHeadersMiddleware(client, customHeaders);
|
|
1743
2170
|
}
|
|
2171
|
+
if (options.onRequest) {
|
|
2172
|
+
addFinalRequestObserverMiddleware(
|
|
2173
|
+
client,
|
|
2174
|
+
createRequestObserver(options, {
|
|
2175
|
+
api: model.api,
|
|
2176
|
+
provider: model.provider,
|
|
2177
|
+
model: model.id,
|
|
2178
|
+
operation: "chat"
|
|
2179
|
+
})
|
|
2180
|
+
);
|
|
2181
|
+
}
|
|
1744
2182
|
const cacheRetention = resolveCacheRetention(options.cacheRetention, options.env);
|
|
1745
2183
|
const inferenceMaxTokens = options.maxTokens ?? (isAnthropicClaudeModel(model) ? model.maxTokens : void 0);
|
|
2184
|
+
const messages = convertMessages(normalizedContext, model, cacheRetention, options.env);
|
|
1746
2185
|
const initialSystemMessage = getInitialSystemMessage(normalizedContext.messages);
|
|
1747
2186
|
const initialSystemPrompt = initialSystemMessage ? getSystemMessageText(initialSystemMessage) : void 0;
|
|
1748
2187
|
let commandInput = {
|
|
1749
2188
|
modelId: model.id,
|
|
1750
|
-
messages
|
|
2189
|
+
messages,
|
|
1751
2190
|
system: buildSystemPrompt(initialSystemPrompt, model, cacheRetention, options.env),
|
|
1752
2191
|
inferenceConfig: {
|
|
1753
2192
|
...inferenceMaxTokens !== void 0 && { maxTokens: inferenceMaxTokens },
|
|
@@ -1758,26 +2197,14 @@ var stream = (model, context, options = {}) => {
|
|
|
1758
2197
|
options.toolChoice,
|
|
1759
2198
|
supportsStrictMode
|
|
1760
2199
|
),
|
|
1761
|
-
additionalModelRequestFields: buildAdditionalModelRequestFields(model, options),
|
|
2200
|
+
additionalModelRequestFields: buildAdditionalModelRequestFields(model, options, messages),
|
|
1762
2201
|
...options.requestMetadata !== void 0 && { requestMetadata: options.requestMetadata }
|
|
1763
2202
|
};
|
|
1764
2203
|
const nextCommandInput = await options?.onPayload?.(commandInput, model);
|
|
1765
2204
|
if (nextCommandInput !== void 0) {
|
|
1766
2205
|
commandInput = nextCommandInput;
|
|
1767
2206
|
}
|
|
1768
|
-
|
|
1769
|
-
addFinalRequestObserverMiddleware(
|
|
1770
|
-
client,
|
|
1771
|
-
createRequestObserver(options, {
|
|
1772
|
-
api: model.api,
|
|
1773
|
-
provider: model.provider,
|
|
1774
|
-
model: model.id,
|
|
1775
|
-
operation: "chat"
|
|
1776
|
-
})
|
|
1777
|
-
);
|
|
1778
|
-
}
|
|
1779
|
-
const command = new ConverseStreamCommand(commandInput);
|
|
1780
|
-
const response = await client.send(command, { abortSignal: options.signal });
|
|
2207
|
+
const response = await client.send(new ConverseStreamCommand(commandInput), { abortSignal: options.signal });
|
|
1781
2208
|
responseRequestId = normalizeDiagnosticValue(response.$metadata.requestId);
|
|
1782
2209
|
if (!observedRawResponse && response.$metadata.httpStatusCode !== void 0) {
|
|
1783
2210
|
const responseHeaders = {};
|
|
@@ -1794,11 +2221,11 @@ var stream = (model, context, options = {}) => {
|
|
|
1794
2221
|
}
|
|
1795
2222
|
stream2.push({ type: "start", partial: output });
|
|
1796
2223
|
} else if (item.contentBlockStart) {
|
|
1797
|
-
handleContentBlockStart(item.contentBlockStart,
|
|
2224
|
+
handleContentBlockStart(item.contentBlockStart, openBlocks, output, stream2);
|
|
1798
2225
|
} else if (item.contentBlockDelta) {
|
|
1799
|
-
handleContentBlockDelta(item.contentBlockDelta,
|
|
2226
|
+
handleContentBlockDelta(item.contentBlockDelta, openBlocks, output, stream2, options.signal);
|
|
1800
2227
|
} else if (item.contentBlockStop) {
|
|
1801
|
-
handleContentBlockStop(item.contentBlockStop,
|
|
2228
|
+
handleContentBlockStop(item.contentBlockStop, openBlocks, output, stream2);
|
|
1802
2229
|
} else if (item.messageStop) {
|
|
1803
2230
|
output.rawStopReason = item.messageStop.stopReason;
|
|
1804
2231
|
const { stopReason, errorMessage } = mapStopReason(item.messageStop.stopReason);
|
|
@@ -1829,13 +2256,11 @@ var stream = (model, context, options = {}) => {
|
|
|
1829
2256
|
if (output.stopReason === "error" || output.stopReason === "aborted") {
|
|
1830
2257
|
throw new Error(output.errorMessage || "An unknown error occurred");
|
|
1831
2258
|
}
|
|
1832
|
-
|
|
2259
|
+
flushOpenBlocks(openBlocks, output);
|
|
1833
2260
|
stream2.push({ type: "done", reason: output.stopReason, message: output });
|
|
1834
2261
|
stream2.end();
|
|
1835
2262
|
} catch (error) {
|
|
1836
|
-
|
|
1837
|
-
finalizeStreamingBlock(block);
|
|
1838
|
-
}
|
|
2263
|
+
flushOpenBlocks(openBlocks, output);
|
|
1839
2264
|
output.stopReason = options.signal?.aborted ? "aborted" : "error";
|
|
1840
2265
|
output.errorMessage = formatBedrockError(error);
|
|
1841
2266
|
appendProviderTransportDiagnostic(output, normalizeProviderError(error));
|
|
@@ -2092,56 +2517,57 @@ var streamSimple = (model, context, options) => {
|
|
|
2092
2517
|
thinkingBudgets: options.thinkingBudgets
|
|
2093
2518
|
});
|
|
2094
2519
|
};
|
|
2095
|
-
function handleContentBlockStart(event,
|
|
2096
|
-
const index = event.contentBlockIndex;
|
|
2520
|
+
function handleContentBlockStart(event, openBlocks, output, stream2) {
|
|
2097
2521
|
const start = event.start;
|
|
2098
2522
|
if (start?.toolUse) {
|
|
2099
|
-
|
|
2523
|
+
output.content.push({
|
|
2100
2524
|
type: "toolCall",
|
|
2101
2525
|
id: start.toolUse.toolUseId || "",
|
|
2102
2526
|
name: start.toolUse.name || "",
|
|
2103
|
-
arguments: {}
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
};
|
|
2107
|
-
|
|
2108
|
-
stream2.push({ type: "toolcall_start", contentIndex: blocks.length - 1, partial: output });
|
|
2527
|
+
arguments: {}
|
|
2528
|
+
});
|
|
2529
|
+
const contentIndex = output.content.length - 1;
|
|
2530
|
+
openBlocks.set(event.contentBlockIndex, { contentIndex, arguments: new ToolCallArgumentsStream() });
|
|
2531
|
+
stream2.push({ type: "toolcall_start", contentIndex, partial: output });
|
|
2109
2532
|
}
|
|
2110
2533
|
}
|
|
2111
|
-
function handleContentBlockDelta(event,
|
|
2534
|
+
function handleContentBlockDelta(event, openBlocks, output, stream2, signal) {
|
|
2112
2535
|
const contentBlockIndex = event.contentBlockIndex;
|
|
2113
2536
|
const delta = event.delta;
|
|
2114
|
-
let
|
|
2115
|
-
let block =
|
|
2537
|
+
let open = openBlocks.get(contentBlockIndex);
|
|
2538
|
+
let block = open === void 0 ? void 0 : output.content[open.contentIndex];
|
|
2116
2539
|
if (delta?.text !== void 0) {
|
|
2117
|
-
if (!
|
|
2118
|
-
|
|
2119
|
-
output.content.
|
|
2120
|
-
|
|
2121
|
-
block =
|
|
2122
|
-
stream2.push({ type: "text_start", contentIndex:
|
|
2123
|
-
}
|
|
2124
|
-
if (block
|
|
2540
|
+
if (!open) {
|
|
2541
|
+
output.content.push({ type: "text", text: "" });
|
|
2542
|
+
open = { contentIndex: output.content.length - 1 };
|
|
2543
|
+
openBlocks.set(contentBlockIndex, open);
|
|
2544
|
+
block = output.content[open.contentIndex];
|
|
2545
|
+
stream2.push({ type: "text_start", contentIndex: open.contentIndex, partial: output });
|
|
2546
|
+
}
|
|
2547
|
+
if (block?.type === "text") {
|
|
2125
2548
|
block.text += delta.text;
|
|
2126
|
-
stream2.push({ type: "text_delta", contentIndex:
|
|
2127
|
-
}
|
|
2128
|
-
} else if (delta?.toolUse && block?.type === "toolCall") {
|
|
2129
|
-
block.
|
|
2130
|
-
|
|
2131
|
-
|
|
2549
|
+
stream2.push({ type: "text_delta", contentIndex: open.contentIndex, delta: delta.text, partial: output });
|
|
2550
|
+
}
|
|
2551
|
+
} else if (delta?.toolUse && block?.type === "toolCall" && open?.arguments !== void 0) {
|
|
2552
|
+
block.arguments = open.arguments.append(delta.toolUse.input || "");
|
|
2553
|
+
stream2.push({
|
|
2554
|
+
type: "toolcall_delta",
|
|
2555
|
+
contentIndex: open.contentIndex,
|
|
2556
|
+
delta: delta.toolUse.input || "",
|
|
2557
|
+
partial: output
|
|
2558
|
+
});
|
|
2132
2559
|
} else if (delta?.reasoningContent) {
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
output.content.
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
if (thinkingBlock?.type === "thinking") {
|
|
2560
|
+
if (!open) {
|
|
2561
|
+
output.content.push({ type: "thinking", thinking: "", thinkingSignature: "" });
|
|
2562
|
+
open = { contentIndex: output.content.length - 1 };
|
|
2563
|
+
openBlocks.set(contentBlockIndex, open);
|
|
2564
|
+
block = output.content[open.contentIndex];
|
|
2565
|
+
stream2.push({ type: "thinking_start", contentIndex: open.contentIndex, partial: output });
|
|
2566
|
+
}
|
|
2567
|
+
if (block?.type === "thinking") {
|
|
2568
|
+
const thinkingIndex = open.contentIndex;
|
|
2143
2569
|
if (delta.reasoningContent.text) {
|
|
2144
|
-
|
|
2570
|
+
block.thinking += delta.reasoningContent.text;
|
|
2145
2571
|
stream2.push({
|
|
2146
2572
|
type: "thinking_delta",
|
|
2147
2573
|
contentIndex: thinkingIndex,
|
|
@@ -2149,14 +2575,15 @@ function handleContentBlockDelta(event, blocks, output, stream2) {
|
|
|
2149
2575
|
partial: output
|
|
2150
2576
|
});
|
|
2151
2577
|
}
|
|
2152
|
-
if (delta.reasoningContent.signature && !
|
|
2153
|
-
|
|
2578
|
+
if (delta.reasoningContent.signature && !block.redacted) {
|
|
2579
|
+
block.thinkingSignature = (block.thinkingSignature || "") + delta.reasoningContent.signature;
|
|
2580
|
+
reportContentProgress(signal);
|
|
2154
2581
|
}
|
|
2155
2582
|
if (delta.reasoningContent.redactedContent?.length) {
|
|
2156
|
-
if (!
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2583
|
+
if (!block.redacted) {
|
|
2584
|
+
block.redacted = true;
|
|
2585
|
+
block.thinkingSignature = "";
|
|
2586
|
+
block.thinking += REDACTED_THINKING_PLACEHOLDER;
|
|
2160
2587
|
stream2.push({
|
|
2161
2588
|
type: "thinking_delta",
|
|
2162
2589
|
contentIndex: thinkingIndex,
|
|
@@ -2164,24 +2591,22 @@ function handleContentBlockDelta(event, blocks, output, stream2) {
|
|
|
2164
2591
|
partial: output
|
|
2165
2592
|
});
|
|
2166
2593
|
}
|
|
2167
|
-
|
|
2168
|
-
|
|
2594
|
+
open.redactedChunks ??= [];
|
|
2595
|
+
open.redactedChunks.push(delta.reasoningContent.redactedContent);
|
|
2596
|
+
reportContentProgress(signal);
|
|
2169
2597
|
}
|
|
2170
2598
|
}
|
|
2171
2599
|
}
|
|
2172
2600
|
}
|
|
2173
|
-
function flushRedactedContent(
|
|
2174
|
-
|
|
2175
|
-
block
|
|
2176
|
-
|
|
2601
|
+
function flushRedactedContent(open, output) {
|
|
2602
|
+
const block = output.content[open.contentIndex];
|
|
2603
|
+
if (block?.type !== "thinking" || !open.redactedChunks) return;
|
|
2604
|
+
block.thinkingSignature = bytesToBase64(open.redactedChunks);
|
|
2605
|
+
open.redactedChunks = void 0;
|
|
2177
2606
|
}
|
|
2178
|
-
function
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
block.arguments = parseStreamingJson(block.partialJson);
|
|
2182
|
-
}
|
|
2183
|
-
delete block.partialJson;
|
|
2184
|
-
flushRedactedContent(block);
|
|
2607
|
+
function flushOpenBlocks(openBlocks, output) {
|
|
2608
|
+
for (const open of openBlocks.values()) flushRedactedContent(open, output);
|
|
2609
|
+
openBlocks.clear();
|
|
2185
2610
|
}
|
|
2186
2611
|
function handleMetadata(event, model, output) {
|
|
2187
2612
|
if (event.usage) {
|
|
@@ -2207,22 +2632,22 @@ function handleMetadata(event, model, output) {
|
|
|
2207
2632
|
calculateCost(model, output.usage);
|
|
2208
2633
|
}
|
|
2209
2634
|
}
|
|
2210
|
-
function handleContentBlockStop(event,
|
|
2211
|
-
const
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2635
|
+
function handleContentBlockStop(event, openBlocks, output, stream2) {
|
|
2636
|
+
const open = openBlocks.get(event.contentBlockIndex);
|
|
2637
|
+
if (!open) return;
|
|
2638
|
+
openBlocks.delete(event.contentBlockIndex);
|
|
2639
|
+
const index = open.contentIndex;
|
|
2640
|
+
const block = output.content[index];
|
|
2215
2641
|
switch (block.type) {
|
|
2216
2642
|
case "text":
|
|
2217
2643
|
stream2.push({ type: "text_end", contentIndex: index, content: block.text, partial: output });
|
|
2218
2644
|
break;
|
|
2219
2645
|
case "thinking":
|
|
2220
|
-
flushRedactedContent(
|
|
2646
|
+
flushRedactedContent(open, output);
|
|
2221
2647
|
stream2.push({ type: "thinking_end", contentIndex: index, content: block.thinking, partial: output });
|
|
2222
2648
|
break;
|
|
2223
2649
|
case "toolCall":
|
|
2224
|
-
Object.assign(block,
|
|
2225
|
-
delete block.partialJson;
|
|
2650
|
+
if (open.arguments !== void 0) Object.assign(block, open.arguments.finish());
|
|
2226
2651
|
stream2.push({ type: "toolcall_end", contentIndex: index, toolCall: block, partial: output });
|
|
2227
2652
|
break;
|
|
2228
2653
|
}
|
|
@@ -2407,7 +2832,8 @@ function convertMessages(context, model, cacheRetention, env) {
|
|
|
2407
2832
|
continue;
|
|
2408
2833
|
}
|
|
2409
2834
|
const thinking = sanitizeSurrogates(c.thinking);
|
|
2410
|
-
if (thinking.trim().length === 0)
|
|
2835
|
+
if (thinking.trim().length === 0 && !(supportsThinkingSignature(model) && c.thinkingSignature?.trim()))
|
|
2836
|
+
continue;
|
|
2411
2837
|
if (supportsThinkingSignature(model)) {
|
|
2412
2838
|
if (!c.thinkingSignature || c.thinkingSignature.trim().length === 0) {
|
|
2413
2839
|
contentBlocks.push({ text: thinking });
|
|
@@ -2487,11 +2913,9 @@ function convertMessages(context, model, cacheRetention, env) {
|
|
|
2487
2913
|
return result;
|
|
2488
2914
|
}
|
|
2489
2915
|
function convertToolConfig(tools, toolChoice, supportsStrictMode) {
|
|
2490
|
-
if (!tools?.length) return void 0;
|
|
2491
|
-
if (toolChoice === "none") return void 0;
|
|
2916
|
+
if (!tools?.length || toolChoice === "none") return void 0;
|
|
2492
2917
|
const bedrockTools = tools.map((tool) => {
|
|
2493
|
-
const
|
|
2494
|
-
const strict = sampling && sampling.type === "json_schema" && sampling.strict === "prefer" ? void 0 : resolveJsonSchemaStrictSampling(tool, supportsStrictMode);
|
|
2918
|
+
const strict = prefersJsonSchemaStrictSampling(tool) ? void 0 : resolveJsonSchemaStrictSampling(tool, supportsStrictMode);
|
|
2495
2919
|
return {
|
|
2496
2920
|
toolSpec: {
|
|
2497
2921
|
name: tool.name,
|
|
@@ -2600,7 +3024,17 @@ function isGovCloudBedrockTarget(model, options) {
|
|
|
2600
3024
|
const modelId = model.id.toLowerCase();
|
|
2601
3025
|
return modelId.startsWith("us-gov.") || modelId.startsWith("arn:aws-us-gov:");
|
|
2602
3026
|
}
|
|
2603
|
-
function buildAdditionalModelRequestFields(model, options) {
|
|
3027
|
+
function buildAdditionalModelRequestFields(model, options, messages) {
|
|
3028
|
+
if (!options.reasoning && isAnthropicClaudeModel(model) && supportsDisabledAnthropicThinking(model)) {
|
|
3029
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
3030
|
+
const message = messages[i];
|
|
3031
|
+
if (message.role === "user" && !message.content?.some((block) => block.toolResult)) break;
|
|
3032
|
+
if (message.role === "assistant" && message.content?.some((block) => block.reasoningContent)) {
|
|
3033
|
+
return void 0;
|
|
3034
|
+
}
|
|
3035
|
+
}
|
|
3036
|
+
return { thinking: { type: "disabled" } };
|
|
3037
|
+
}
|
|
2604
3038
|
if (!options.reasoning || !model.reasoning) {
|
|
2605
3039
|
return void 0;
|
|
2606
3040
|
}
|