@humain/humain-code 0.5.4 → 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 +170 -0
- 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/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
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Container, LiveLineArray, Markdown, MouseRegion, markLiveRender, markReportsChanges, reportRenderChange, Spacer, Text, } from "@earendil-works/pi-tui";
|
|
2
|
-
import { getMarkdownTheme, theme } from "../theme/theme.js";
|
|
1
|
+
import { Container, LiveLineArray, Markdown, MouseRegion, markLiveRender, markReportsChanges, reportRenderChange, Spacer, sanitizeTerminalText, startsWithText, Text, } from "@earendil-works/pi-tui";
|
|
2
|
+
import { getMarkdownTheme, getThemeInstance, theme } from "../theme/theme.js";
|
|
3
|
+
import { AssistantCodeBlock } from "./assistant-code-block.js";
|
|
3
4
|
import { createMarkdownTransform } from "./markdown-transform.js";
|
|
4
5
|
const OSC133_ZONE_START = "\x1b]133;A\x07";
|
|
5
6
|
const OSC133_ZONE_END = "\x1b]133;B\x07";
|
|
@@ -17,6 +18,82 @@ export function mentionsAny(text, names) {
|
|
|
17
18
|
}
|
|
18
19
|
return false;
|
|
19
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* A text or thinking block of a message streaming in, trimmed without reading all of it for each chunk. A provider adds each
|
|
23
|
+
* delta to the text (`text += delta`), and the engine keeps the result as the two strings joined until it is read; reading
|
|
24
|
+
* it (trim(), a regular expression) then copies all of it into one string, a copy of the whole reply for each chunk. Here
|
|
25
|
+
* each text the block is seen with (updateContent(), for each delta) is compared with the one seen before as a part of it
|
|
26
|
+
* (startsWithText(): the text before is that part, so this reads neither), and what it adds is kept. Trimming then reads
|
|
27
|
+
* the text added only: the result is the text trimmed before with what was added (and the white space before it) after
|
|
28
|
+
* it, the same strings joined, which the Markdown component it is given reads in the same way. The comparisons are real:
|
|
29
|
+
* a text that is not the one before with more after it is trimmed in full.
|
|
30
|
+
*/
|
|
31
|
+
class BlockText {
|
|
32
|
+
/** The text as it was seen last. */
|
|
33
|
+
raw;
|
|
34
|
+
/** The text as it was trimmed last (trim()). */
|
|
35
|
+
trimmed;
|
|
36
|
+
/** What `raw` adds to `trimmed.raw`, when it is that text with more after it. */
|
|
37
|
+
added;
|
|
38
|
+
constructor(raw) {
|
|
39
|
+
this.raw = raw;
|
|
40
|
+
}
|
|
41
|
+
/** The block's text is now `raw`. */
|
|
42
|
+
follow(raw) {
|
|
43
|
+
if (raw === this.raw)
|
|
44
|
+
return;
|
|
45
|
+
const before = this.raw;
|
|
46
|
+
this.raw = raw;
|
|
47
|
+
if (this.added !== undefined && raw.length > before.length && startsWithText(raw, before)) {
|
|
48
|
+
this.added += raw.slice(before.length);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
this.added = undefined;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** raw.trim(), whether it is not empty, from what was trimmed last and what was added since (follow()). */
|
|
55
|
+
trim() {
|
|
56
|
+
const previous = this.trimmed;
|
|
57
|
+
const raw = this.raw;
|
|
58
|
+
const added = this.added;
|
|
59
|
+
let result;
|
|
60
|
+
if (previous === undefined || added === undefined) {
|
|
61
|
+
const trimmed = raw.trim();
|
|
62
|
+
const visible = trimmed.length > 0;
|
|
63
|
+
result = { raw, trimmed, visible, pending: visible ? raw.slice(raw.trimEnd().length) : "" };
|
|
64
|
+
}
|
|
65
|
+
else if (added === "") {
|
|
66
|
+
result = previous;
|
|
67
|
+
}
|
|
68
|
+
else if (!previous.visible) {
|
|
69
|
+
// (White space is what trim() removes, which is what /\s/ matches.)
|
|
70
|
+
const start = added.search(/\S/);
|
|
71
|
+
if (start < 0) {
|
|
72
|
+
result = { raw, trimmed: "", visible: false, pending: "" };
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
const rest = added.slice(start);
|
|
76
|
+
const trimmed = rest.trimEnd();
|
|
77
|
+
result = { raw, trimmed, visible: true, pending: rest.slice(trimmed.length) };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const visibleAdded = added.trimEnd();
|
|
82
|
+
result =
|
|
83
|
+
visibleAdded.length === 0
|
|
84
|
+
? { raw, trimmed: previous.trimmed, visible: true, pending: previous.pending + added }
|
|
85
|
+
: {
|
|
86
|
+
raw,
|
|
87
|
+
trimmed: previous.trimmed + (previous.pending + visibleAdded),
|
|
88
|
+
visible: true,
|
|
89
|
+
pending: added.slice(visibleAdded.length),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
this.trimmed = result;
|
|
93
|
+
this.added = "";
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
20
97
|
/**
|
|
21
98
|
* Component that renders a complete assistant message
|
|
22
99
|
*/
|
|
@@ -29,27 +106,39 @@ export class AssistantMessageComponent extends Container {
|
|
|
29
106
|
markdownTransformers;
|
|
30
107
|
lastMessage;
|
|
31
108
|
hasToolCalls = false;
|
|
32
|
-
isStreaming = false;
|
|
33
|
-
contentIsStale = false;
|
|
34
|
-
thinkingVisibilityOverrides = new Map();
|
|
35
|
-
/** The children's lines with the prompt markers added, and the lines they were added to. */
|
|
36
109
|
markedFrom;
|
|
37
110
|
markedLines = [];
|
|
38
|
-
/** renderLive()'s lines: the children's live lines with the prompt markers added, and what they were made from. */
|
|
39
111
|
markedLive;
|
|
112
|
+
isStreaming = false;
|
|
113
|
+
contentIsStale = false;
|
|
114
|
+
thinkingVisibilityOverrides = new Map();
|
|
115
|
+
messageId;
|
|
116
|
+
timestamp;
|
|
40
117
|
/**
|
|
41
118
|
* The Markdown components of the content, with what they were made from. A rebuild with the same text takes the
|
|
42
119
|
* component again instead of making a new one, which would parse its text again and render it from nothing: on
|
|
43
120
|
* invalidate() (theme changes), and while a reply streams, for every block but the one growing.
|
|
44
121
|
*/
|
|
45
122
|
markdownBlocks = [];
|
|
46
|
-
|
|
123
|
+
requestRender;
|
|
124
|
+
copyError;
|
|
125
|
+
/**
|
|
126
|
+
* What the content was last built for while the reply streamed in (buildContent()): the plan's key and the theme. Dropped
|
|
127
|
+
* when anything the components were made with may have changed (invalidate() and the setters).
|
|
128
|
+
*/
|
|
129
|
+
built;
|
|
130
|
+
/** The text and thinking blocks of the message, by index (BlockText). */
|
|
131
|
+
blockTexts = [];
|
|
132
|
+
constructor(message, hideThinkingBlock = false, markdownTheme = getMarkdownTheme(), hiddenThinkingLabel = "Thinking...", outputPad = 1, markdownTransformers = [], requestRender, messageId, timestamp) {
|
|
47
133
|
super();
|
|
48
134
|
this.hideThinkingBlock = hideThinkingBlock;
|
|
49
135
|
this.markdownTheme = markdownTheme;
|
|
50
136
|
this.hiddenThinkingLabel = hiddenThinkingLabel;
|
|
51
137
|
this.outputPad = outputPad;
|
|
52
138
|
this.markdownTransformers = markdownTransformers;
|
|
139
|
+
this.requestRender = requestRender;
|
|
140
|
+
this.messageId = messageId;
|
|
141
|
+
this.timestamp = timestamp;
|
|
53
142
|
// Container for text/thinking content
|
|
54
143
|
this.contentContainer = new Container();
|
|
55
144
|
this.addChild(this.contentContainer);
|
|
@@ -59,6 +148,7 @@ export class AssistantMessageComponent extends Container {
|
|
|
59
148
|
}
|
|
60
149
|
invalidate() {
|
|
61
150
|
super.invalidate();
|
|
151
|
+
this.built = undefined;
|
|
62
152
|
if (this.lastMessage) {
|
|
63
153
|
this.updateContent(this.lastMessage);
|
|
64
154
|
}
|
|
@@ -76,7 +166,17 @@ export class AssistantMessageComponent extends Container {
|
|
|
76
166
|
return mentionsAny(text, languages);
|
|
77
167
|
});
|
|
78
168
|
}
|
|
169
|
+
/** Copy targets come from native fenced components, never rendered lines or thinking blocks. */
|
|
170
|
+
getCodeBlocks() {
|
|
171
|
+
if (this.contentIsStale && this.lastMessage)
|
|
172
|
+
this.buildContent(this.lastMessage);
|
|
173
|
+
return this.markdownBlocks
|
|
174
|
+
.filter((block) => block.kind === "text")
|
|
175
|
+
.flatMap((block) => block.component.getCodeBlockComponents())
|
|
176
|
+
.filter((component) => component instanceof AssistantCodeBlock);
|
|
177
|
+
}
|
|
79
178
|
setHideThinkingBlock(hide) {
|
|
179
|
+
this.built = undefined;
|
|
80
180
|
this.hideThinkingBlock = hide;
|
|
81
181
|
this.thinkingVisibilityOverrides.clear();
|
|
82
182
|
if (this.lastMessage) {
|
|
@@ -84,12 +184,14 @@ export class AssistantMessageComponent extends Container {
|
|
|
84
184
|
}
|
|
85
185
|
}
|
|
86
186
|
setHiddenThinkingLabel(label) {
|
|
187
|
+
this.built = undefined;
|
|
87
188
|
this.hiddenThinkingLabel = label;
|
|
88
189
|
if (this.lastMessage) {
|
|
89
190
|
this.updateContent(this.lastMessage);
|
|
90
191
|
}
|
|
91
192
|
}
|
|
92
193
|
setOutputPad(padding) {
|
|
194
|
+
this.built = undefined;
|
|
93
195
|
this.outputPad = padding;
|
|
94
196
|
if (this.lastMessage) {
|
|
95
197
|
this.updateContent(this.lastMessage);
|
|
@@ -99,10 +201,9 @@ export class AssistantMessageComponent extends Container {
|
|
|
99
201
|
if (this.contentIsStale && this.lastMessage)
|
|
100
202
|
this.buildContent(this.lastMessage);
|
|
101
203
|
const lines = super.renderShared(width);
|
|
102
|
-
if (this.hasToolCalls || lines.length === 0)
|
|
204
|
+
if (this.hasToolCalls || lines.length === 0)
|
|
103
205
|
return lines;
|
|
104
|
-
|
|
105
|
-
// The marked lines are kept with the lines they were made from: same lines, same array (renderShared()).
|
|
206
|
+
// Fullscreen prompt navigation needs markers, but shared child lines must stay untouched.
|
|
106
207
|
if (lines !== this.markedFrom) {
|
|
107
208
|
const marked = lines.slice();
|
|
108
209
|
marked[0] = OSC133_ZONE_START + marked[0];
|
|
@@ -112,25 +213,21 @@ export class AssistantMessageComponent extends Container {
|
|
|
112
213
|
}
|
|
113
214
|
return this.markedLines;
|
|
114
215
|
}
|
|
115
|
-
/**
|
|
116
|
-
* renderShared()'s lines as LiveLines (renderLiveLines()): the children's live lines with the prompt markers added,
|
|
117
|
-
* changed from the first line the children's lines changed from (and the line that was last before).
|
|
118
|
-
*/
|
|
216
|
+
/** Render the latest streamed content through the children's live lines. */
|
|
119
217
|
renderLive(width) {
|
|
120
218
|
if (this.contentIsStale && this.lastMessage)
|
|
121
219
|
this.buildContent(this.lastMessage);
|
|
122
220
|
const children = this.renderLiveChildren(width);
|
|
123
221
|
const count = children.lines.length;
|
|
124
|
-
if (this.hasToolCalls || count === 0)
|
|
222
|
+
if (this.hasToolCalls || count === 0)
|
|
125
223
|
return children;
|
|
126
|
-
}
|
|
127
224
|
let marked = this.markedLive;
|
|
128
225
|
let start = 0;
|
|
129
226
|
if (marked?.from === children) {
|
|
130
227
|
const changed = children.changedSince(marked.revision);
|
|
131
228
|
if (changed === Number.POSITIVE_INFINITY)
|
|
132
229
|
return marked.lines;
|
|
133
|
-
//
|
|
230
|
+
// The former last line loses its end marker, and the new last line gets it.
|
|
134
231
|
start = Math.min(changed, marked.length - 1, count - 1);
|
|
135
232
|
}
|
|
136
233
|
else {
|
|
@@ -154,6 +251,7 @@ export class AssistantMessageComponent extends Container {
|
|
|
154
251
|
updateContent(message, isStreaming = this.isStreaming) {
|
|
155
252
|
this.lastMessage = message;
|
|
156
253
|
this.isStreaming = isStreaming;
|
|
254
|
+
this.followTexts(message);
|
|
157
255
|
reportRenderChange(this);
|
|
158
256
|
// While a reply streams, every delta of it comes here, and the screen is drawn a few dozen times a second at most: the
|
|
159
257
|
// components are made when it is (render()), from the latest message, not for each delta (and its text trimmed, a
|
|
@@ -182,40 +280,66 @@ export class AssistantMessageComponent extends Container {
|
|
|
182
280
|
this.markdownBlocks.push({ kind, text, isStreaming: this.isStreaming, outputPad: this.outputPad, component });
|
|
183
281
|
return component;
|
|
184
282
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
283
|
+
/** The texts of the text and thinking blocks of `message` (BlockText.follow(): for each delta, while a reply streams in). */
|
|
284
|
+
followTexts(message) {
|
|
285
|
+
const content = message.content;
|
|
286
|
+
const blockTexts = this.blockTexts;
|
|
287
|
+
blockTexts.length = content.length;
|
|
288
|
+
for (let i = 0; i < content.length; i++) {
|
|
289
|
+
const block = content[i];
|
|
290
|
+
const raw = block.type === "text" ? block.text : block.type === "thinking" ? block.thinking : undefined;
|
|
291
|
+
if (raw === undefined) {
|
|
292
|
+
blockTexts[i] = undefined;
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
const known = blockTexts[i];
|
|
296
|
+
if (known === undefined)
|
|
297
|
+
blockTexts[i] = new BlockText(raw);
|
|
298
|
+
else
|
|
299
|
+
known.follow(raw);
|
|
300
|
+
}
|
|
195
301
|
}
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* What buildContent() adds to the content container for `message`, in order. While a reply streams in, a chunk usually
|
|
305
|
+
* changes only the texts of its Markdown components: the same plan but for those texts (planKey()).
|
|
306
|
+
*/
|
|
307
|
+
planContent(message) {
|
|
308
|
+
const parts = [];
|
|
309
|
+
const content = message.content;
|
|
310
|
+
// Each text and thinking block trimmed (BlockText).
|
|
311
|
+
this.followTexts(message);
|
|
312
|
+
const trimmedTexts = [];
|
|
313
|
+
for (let i = 0; i < content.length; i++) {
|
|
314
|
+
const trimmed = this.blockTexts[i]?.trim();
|
|
315
|
+
trimmedTexts.push(trimmed);
|
|
316
|
+
}
|
|
317
|
+
// Spacers are added lazily, right before the next visible content block. This puts a blank
|
|
318
|
+
// line before the first visible block and after each visible thinking run that is followed
|
|
319
|
+
// by more visible content, while hidden thinking runs without a label contribute nothing.
|
|
320
|
+
let needsSpacer = true;
|
|
196
321
|
// Render content in order
|
|
197
322
|
let thinkingRunIndex = 0;
|
|
198
|
-
for (let i = 0; i <
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
323
|
+
for (let i = 0; i < content.length; i++) {
|
|
324
|
+
const block = content[i];
|
|
325
|
+
const trimmed = trimmedTexts[i];
|
|
326
|
+
if (block.type === "text" && trimmed?.visible) {
|
|
327
|
+
// Assistant text has no background; keep trailing whitespace for unfinished fenced blocks.
|
|
202
328
|
// Set paddingY=0 to avoid extra spacing before tool executions
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
})));
|
|
329
|
+
if (needsSpacer)
|
|
330
|
+
parts.push({ kind: "spacer" });
|
|
331
|
+
needsSpacer = false;
|
|
332
|
+
parts.push({ kind: "text", text: trimmed.trimmed + trimmed.pending });
|
|
208
333
|
}
|
|
209
|
-
else if (
|
|
334
|
+
else if (block.type === "thinking") {
|
|
210
335
|
const thinkingBlocks = [];
|
|
211
|
-
for (; i <
|
|
212
|
-
|
|
213
|
-
if (thinkingContent.type !== "thinking") {
|
|
336
|
+
for (; i < content.length; i++) {
|
|
337
|
+
if (content[i].type !== "thinking") {
|
|
214
338
|
break;
|
|
215
339
|
}
|
|
216
|
-
const thinking =
|
|
217
|
-
if (thinking) {
|
|
218
|
-
thinkingBlocks.push(thinking);
|
|
340
|
+
const thinking = trimmedTexts[i];
|
|
341
|
+
if (thinking?.visible) {
|
|
342
|
+
thinkingBlocks.push(thinking.trimmed);
|
|
219
343
|
}
|
|
220
344
|
}
|
|
221
345
|
i--;
|
|
@@ -224,19 +348,117 @@ export class AssistantMessageComponent extends Container {
|
|
|
224
348
|
}
|
|
225
349
|
// Add spacing only when another visible assistant content block follows.
|
|
226
350
|
// This avoids a superfluous blank line before separately-rendered tool execution blocks.
|
|
227
|
-
const hasVisibleContentAfter = message.content
|
|
228
|
-
.slice(i + 1)
|
|
229
|
-
.some((c) => (c.type === "text" && c.text.trim()) || (c.type === "thinking" && c.thinking.trim()));
|
|
230
351
|
const runIndex = thinkingRunIndex++;
|
|
231
352
|
const hidden = this.thinkingVisibilityOverrides.get(runIndex) ?? this.hideThinkingBlock;
|
|
232
|
-
|
|
353
|
+
// A hidden run with an empty label renders nothing, including no spacing.
|
|
354
|
+
if (hidden && !this.hiddenThinkingLabel.trim())
|
|
355
|
+
continue;
|
|
356
|
+
if (needsSpacer)
|
|
357
|
+
parts.push({ kind: "spacer" });
|
|
358
|
+
// (One block's text as it is: the same text as joined, and the strings it was trimmed to, see BlockText.)
|
|
359
|
+
const text = hidden ? "" : thinkingBlocks.length === 1 ? thinkingBlocks[0] : thinkingBlocks.join("\n\n");
|
|
360
|
+
parts.push({ kind: "thinking", runIndex, hidden, text });
|
|
361
|
+
needsSpacer = true;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
// Check if incomplete/failed - show after partial content.
|
|
365
|
+
// For aborted/error tool calls, tool execution components show the error.
|
|
366
|
+
// Length stops can happen before a tool call is complete, so surface them here too.
|
|
367
|
+
if (this.copyError) {
|
|
368
|
+
parts.push({ kind: "spacer" });
|
|
369
|
+
parts.push({ kind: "error", text: `Copy failed: ${this.copyError}` });
|
|
370
|
+
}
|
|
371
|
+
const hasToolCalls = message.content.some((c) => c.type === "toolCall");
|
|
372
|
+
parts.push({ kind: "toolCalls", present: hasToolCalls });
|
|
373
|
+
if (message.stopReason === "length") {
|
|
374
|
+
parts.push({ kind: "spacer" });
|
|
375
|
+
parts.push({ kind: "error", text: "Response was truncated before completion." });
|
|
376
|
+
}
|
|
377
|
+
else if (!hasToolCalls) {
|
|
378
|
+
if (message.stopReason === "aborted") {
|
|
379
|
+
const abortMessage = message.errorMessage && message.errorMessage !== "Request was aborted"
|
|
380
|
+
? message.errorMessage
|
|
381
|
+
: "Operation aborted";
|
|
382
|
+
parts.push({ kind: "spacer" });
|
|
383
|
+
parts.push({ kind: "error", text: abortMessage });
|
|
384
|
+
}
|
|
385
|
+
else if (message.stopReason === "error") {
|
|
386
|
+
const errorMsg = message.errorMessage || "Unknown error";
|
|
387
|
+
parts.push({ kind: "spacer" });
|
|
388
|
+
parts.push({ kind: "error", text: `Error: ${errorMsg}` });
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return parts;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Everything the components buildContent() makes for `parts` depend on but the texts of the Markdown components: two
|
|
395
|
+
* plans with the same key give the same components, but for the text each Markdown component is given.
|
|
396
|
+
*/
|
|
397
|
+
planKey(parts) {
|
|
398
|
+
let key = `${this.isStreaming}|${this.outputPad}|${this.hiddenThinkingLabel}`;
|
|
399
|
+
for (const part of parts) {
|
|
400
|
+
if (part.kind === "thinking")
|
|
401
|
+
key += `|thinking:${part.runIndex}:${part.hidden}`;
|
|
402
|
+
else if (part.kind === "toolCalls")
|
|
403
|
+
key += `|toolCalls:${part.present}`;
|
|
404
|
+
else if (part.kind === "error")
|
|
405
|
+
key += `|error:${part.text}`;
|
|
406
|
+
else
|
|
407
|
+
key += `|${part.kind}`;
|
|
408
|
+
}
|
|
409
|
+
return key;
|
|
410
|
+
}
|
|
411
|
+
buildContent(message) {
|
|
412
|
+
this.contentIsStale = false;
|
|
413
|
+
const parts = this.planContent(message);
|
|
414
|
+
const key = this.planKey(parts);
|
|
415
|
+
// A reply streaming in, built the last time with the same plan, the same theme and nothing invalidated since: the same
|
|
416
|
+
// components, each Markdown component given its text as markdownFor() gives it (the text changed, or none).
|
|
417
|
+
const built = this.built;
|
|
418
|
+
if (this.isStreaming && built !== undefined && built.key === key && built.theme === getThemeInstance()) {
|
|
419
|
+
let index = 0;
|
|
420
|
+
for (const part of parts) {
|
|
421
|
+
if (part.kind !== "text" && (part.kind !== "thinking" || part.hidden))
|
|
422
|
+
continue;
|
|
423
|
+
const block = this.markdownBlocks[index++];
|
|
424
|
+
if (block.text !== part.text) {
|
|
425
|
+
block.text = part.text;
|
|
426
|
+
block.component.setText(part.text);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
this.built = this.isStreaming ? { key, theme: getThemeInstance() } : undefined;
|
|
432
|
+
const previousBlocks = this.markdownBlocks;
|
|
433
|
+
this.markdownBlocks = [];
|
|
434
|
+
// Clear content container
|
|
435
|
+
this.contentContainer.clear();
|
|
436
|
+
for (const part of parts) {
|
|
437
|
+
if (part.kind === "spacer") {
|
|
438
|
+
this.contentContainer.addChild(new Spacer(1));
|
|
439
|
+
}
|
|
440
|
+
else if (part.kind === "text") {
|
|
441
|
+
const text = part.text;
|
|
442
|
+
this.contentContainer.addChild(this.markdownFor("text", text, previousBlocks, () => new Markdown(text, this.outputPad, 0, this.markdownTheme, undefined, {
|
|
443
|
+
transform: createMarkdownTransform("assistant", () => this.isStreaming, this.markdownTransformers, this.messageId, this.timestamp),
|
|
444
|
+
complete: !this.isStreaming,
|
|
445
|
+
renderCodeBlock: AssistantCodeBlock.renderer(this.markdownTheme, () => {
|
|
446
|
+
this.invalidate();
|
|
447
|
+
this.requestRender?.();
|
|
448
|
+
}, (error) => {
|
|
449
|
+
this.copyError = error;
|
|
450
|
+
}),
|
|
451
|
+
})));
|
|
452
|
+
}
|
|
453
|
+
else if (part.kind === "thinking") {
|
|
454
|
+
const { runIndex, hidden, text: thinkingText } = part;
|
|
233
455
|
const thinkingComponent = hidden
|
|
234
456
|
? new Text(theme.italic(theme.fg("thinkingText", this.hiddenThinkingLabel)), this.outputPad, 0)
|
|
235
457
|
: this.markdownFor("thinking", thinkingText, previousBlocks, () => new Markdown(thinkingText, this.outputPad, 0, this.markdownTheme, {
|
|
236
458
|
color: thinkingTextColor,
|
|
237
459
|
italic: true,
|
|
238
460
|
}, {
|
|
239
|
-
transform: createMarkdownTransform("assistant-thinking", this.isStreaming, this.markdownTransformers),
|
|
461
|
+
transform: createMarkdownTransform("assistant-thinking", () => this.isStreaming, this.markdownTransformers, this.messageId, this.timestamp),
|
|
240
462
|
complete: !this.isStreaming,
|
|
241
463
|
}));
|
|
242
464
|
this.contentContainer.addChild(new MouseRegion(thinkingComponent, (event) => {
|
|
@@ -247,32 +469,13 @@ export class AssistantMessageComponent extends Container {
|
|
|
247
469
|
this.updateContent(this.lastMessage);
|
|
248
470
|
return { handled: true };
|
|
249
471
|
}));
|
|
250
|
-
if (hasVisibleContentAfter) {
|
|
251
|
-
this.contentContainer.addChild(new Spacer(1));
|
|
252
|
-
}
|
|
253
472
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
// For aborted/error tool calls, tool execution components show the error.
|
|
257
|
-
// Length stops can happen before a tool call is complete, so surface them here too.
|
|
258
|
-
const hasToolCalls = message.content.some((c) => c.type === "toolCall");
|
|
259
|
-
this.hasToolCalls = hasToolCalls;
|
|
260
|
-
if (message.stopReason === "length") {
|
|
261
|
-
this.contentContainer.addChild(new Spacer(1));
|
|
262
|
-
this.contentContainer.addChild(new Text(theme.fg("error", "Response was truncated before completion."), this.outputPad, 0));
|
|
263
|
-
}
|
|
264
|
-
else if (!hasToolCalls) {
|
|
265
|
-
if (message.stopReason === "aborted") {
|
|
266
|
-
const abortMessage = message.errorMessage && message.errorMessage !== "Request was aborted"
|
|
267
|
-
? message.errorMessage
|
|
268
|
-
: "Operation aborted";
|
|
269
|
-
this.contentContainer.addChild(new Spacer(1));
|
|
270
|
-
this.contentContainer.addChild(new Text(theme.fg("error", abortMessage), this.outputPad, 0));
|
|
473
|
+
else if (part.kind === "toolCalls") {
|
|
474
|
+
this.hasToolCalls = part.present;
|
|
271
475
|
}
|
|
272
|
-
else if (
|
|
273
|
-
|
|
274
|
-
this.contentContainer.addChild(new
|
|
275
|
-
this.contentContainer.addChild(new Text(theme.fg("error", `Error: ${errorMsg}`), this.outputPad, 0));
|
|
476
|
+
else if (part.kind === "error") {
|
|
477
|
+
// (An error's text can come from the provider's response: escape sequences in it would act on the terminal.)
|
|
478
|
+
this.contentContainer.addChild(new Text(theme.fg("error", sanitizeTerminalText(part.text)), this.outputPad, 0));
|
|
276
479
|
}
|
|
277
480
|
}
|
|
278
481
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant-message.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/assistant-message.ts"],"names":[],"mappings":"AAEA,OAAO,EAEN,SAAS,EACT,aAAa,EAEb,QAAQ,EAER,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,MAAM,EACN,IAAI,GACJ,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EA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AAY,IAAI,eAAe,CAAC;gBACzD,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC9C,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,QAAQ,EAAE,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;YACtG,CAAC;QACF,CAAC;IACF,CAAC;CACD;AAED,kBAAkB,CAAC,yBAAyB,CAAC,CAAC;AAC9C,cAAc,CAAC,yBAAyB,CAAC,SAAS,CAAC,YAAY,EAAE,UAA2B,KAAa;IACxG,OAAQ,IAAkC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC,CAAC,CAAC","sourcesContent":["// Derived from Pi-Bolt (MIT, Copyright (c) 2026 OpenSec (Pi-Bolt)), commits b93895d2, a6df6a2c; modified for HUMAIN Code CLI.\nimport type { AssistantMessage } from \"@earendil-works/pi-ai\";\nimport {\n\ttype Component,\n\tContainer,\n\tLiveLineArray,\n\ttype LiveLines,\n\tMarkdown,\n\ttype MarkdownTheme,\n\tMouseRegion,\n\tmarkLiveRender,\n\tmarkReportsChanges,\n\treportRenderChange,\n\tSpacer,\n\tText,\n} from \"@earendil-works/pi-tui\";\nimport type { MarkdownTransformer } from \"../../../core/extensions/types.ts\";\nimport { getMarkdownTheme, theme } from \"../theme/theme.ts\";\nimport { createMarkdownTransform } from \"./markdown-transform.ts\";\n\nconst OSC133_ZONE_START = \"\\x1b]133;A\\x07\";\nconst OSC133_ZONE_END = \"\\x1b]133;B\\x07\";\nconst OSC133_ZONE_FINAL = \"\\x1b]133;C\\x07\";\n\n// One function for every render: the Markdown component keeps what it rendered for as long as its style is the same.\nconst thinkingTextColor = (text: string): string => theme.fg(\"thinkingText\", text);\n\n/** Whether `text` contains one of `names` (lowercase), ignoring case. */\nexport function mentionsAny(text: string, names: ReadonlySet<string>): boolean {\n\tif (names.size === 0 || text === \"\") return false;\n\tconst lower = text.toLowerCase();\n\tfor (const name of names) {\n\t\tif (lower.includes(name)) return true;\n\t}\n\treturn false;\n}\n\n/** A Markdown component of an assistant message, with what it was made from (AssistantMessageComponent.markdownFor()). */\ninterface MarkdownBlock {\n\tkind: \"text\" | \"thinking\";\n\ttext: string;\n\tisStreaming: boolean;\n\toutputPad: number;\n\tcomponent: Markdown;\n}\n\n/**\n * Component that renders a complete assistant message\n */\nexport class AssistantMessageComponent extends Container {\n\tprivate contentContainer: Container;\n\tprivate hideThinkingBlock: boolean;\n\tprivate markdownTheme: MarkdownTheme;\n\tprivate hiddenThinkingLabel: string;\n\tprivate outputPad: number;\n\tprivate markdownTransformers: readonly MarkdownTransformer[];\n\tprivate lastMessage?: AssistantMessage;\n\tprivate hasToolCalls = false;\n\tprivate isStreaming = false;\n\tprivate contentIsStale = false;\n\tprivate thinkingVisibilityOverrides = new Map<number, boolean>();\n\t/** The children's lines with the prompt markers added, and the lines they were added to. */\n\tprivate markedFrom?: string[];\n\tprivate markedLines: string[] = [];\n\t/** renderLive()'s lines: the children's live lines with the prompt markers added, and what they were made from. */\n\tprivate markedLive?: { from: LiveLines; revision: number; length: number; lines: LiveLineArray };\n\t/**\n\t * The Markdown components of the content, with what they were made from. A rebuild with the same text takes the\n\t * component again instead of making a new one, which would parse its text again and render it from nothing: on\n\t * invalidate() (theme changes), and while a reply streams, for every block but the one growing.\n\t */\n\tprivate markdownBlocks: MarkdownBlock[] = [];\n\n\tconstructor(\n\t\tmessage?: AssistantMessage,\n\t\thideThinkingBlock = false,\n\t\tmarkdownTheme: MarkdownTheme = getMarkdownTheme(),\n\t\thiddenThinkingLabel = \"Thinking...\",\n\t\toutputPad = 1,\n\t\tmarkdownTransformers: readonly MarkdownTransformer[] = [],\n\t) {\n\t\tsuper();\n\n\t\tthis.hideThinkingBlock = hideThinkingBlock;\n\t\tthis.markdownTheme = markdownTheme;\n\t\tthis.hiddenThinkingLabel = hiddenThinkingLabel;\n\t\tthis.outputPad = outputPad;\n\t\tthis.markdownTransformers = markdownTransformers;\n\n\t\t// Container for text/thinking content\n\t\tthis.contentContainer = new Container();\n\t\tthis.addChild(this.contentContainer);\n\n\t\tif (message) {\n\t\t\tthis.updateContent(message);\n\t\t}\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\t/**\n\t * Whether this message may show code highlighted in one of `languages` (lowercase names): whether its text names one\n\t * of them anywhere, which every code block in that language does. Markdown transformers (extensions) may add any.\n\t */\n\tmayHighlight(languages: ReadonlySet<string>): boolean {\n\t\tif (this.markdownTransformers.length > 0) return true;\n\t\tconst content = this.lastMessage?.content ?? [];\n\t\treturn content.some((block) => {\n\t\t\tconst text = block.type === \"text\" ? block.text : block.type === \"thinking\" ? block.thinking : \"\";\n\t\t\treturn mentionsAny(text, languages);\n\t\t});\n\t}\n\n\tsetHideThinkingBlock(hide: boolean): void {\n\t\tthis.hideThinkingBlock = hide;\n\t\tthis.thinkingVisibilityOverrides.clear();\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\tsetHiddenThinkingLabel(label: string): void {\n\t\tthis.hiddenThinkingLabel = label;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\tsetOutputPad(padding: number): void {\n\t\tthis.outputPad = padding;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\toverride renderShared(width: number): string[] {\n\t\tif (this.contentIsStale && this.lastMessage) this.buildContent(this.lastMessage);\n\t\tconst lines = super.renderShared(width);\n\t\tif (this.hasToolCalls || lines.length === 0) {\n\t\t\treturn lines;\n\t\t}\n\t\t// The marked lines are kept with the lines they were made from: same lines, same array (renderShared()).\n\t\tif (lines !== this.markedFrom) {\n\t\t\tconst marked = lines.slice();\n\t\t\tmarked[0] = OSC133_ZONE_START + marked[0];\n\t\t\tmarked[marked.length - 1] = OSC133_ZONE_END + OSC133_ZONE_FINAL + marked[marked.length - 1];\n\t\t\tthis.markedFrom = lines;\n\t\t\tthis.markedLines = marked;\n\t\t}\n\t\treturn this.markedLines;\n\t}\n\n\t/**\n\t * renderShared()'s lines as LiveLines (renderLiveLines()): the children's live lines with the prompt markers added,\n\t * changed from the first line the children's lines changed from (and the line that was last before).\n\t */\n\trenderLive(width: number): LiveLines {\n\t\tif (this.contentIsStale && this.lastMessage) this.buildContent(this.lastMessage);\n\t\tconst children = this.renderLiveChildren(width);\n\t\tconst count = children.lines.length;\n\t\tif (this.hasToolCalls || count === 0) {\n\t\t\treturn children;\n\t\t}\n\t\tlet marked = this.markedLive;\n\t\tlet start = 0;\n\t\tif (marked?.from === children) {\n\t\t\tconst changed = children.changedSince(marked.revision);\n\t\t\tif (changed === Number.POSITIVE_INFINITY) return marked.lines;\n\t\t\t// (The line that was last loses its end marker, and the line now last gets it.)\n\t\t\tstart = Math.min(changed, marked.length - 1, count - 1);\n\t\t} else {\n\t\t\tmarked = { from: children, revision: 0, length: 0, lines: new LiveLineArray() };\n\t\t\tthis.markedLive = marked;\n\t\t}\n\t\tstart = Math.max(0, start);\n\t\tmarked.lines.edit(start);\n\t\tfor (let index = start; index < count; index++) {\n\t\t\tlet line = children.lines[index]!;\n\t\t\tif (index === 0) line = OSC133_ZONE_START + line;\n\t\t\tif (index === count - 1) line = OSC133_ZONE_END + OSC133_ZONE_FINAL + line;\n\t\t\tmarked.lines.lines.push(line);\n\t\t}\n\t\tmarked.revision = children.revision;\n\t\tmarked.length = count;\n\t\treturn marked.lines;\n\t}\n\n\tupdateContent(message: AssistantMessage, isStreaming = this.isStreaming): void {\n\t\tthis.lastMessage = message;\n\t\tthis.isStreaming = isStreaming;\n\t\treportRenderChange(this);\n\t\t// While a reply streams, every delta of it comes here, and the screen is drawn a few dozen times a second at most: the\n\t\t// components are made when it is (render()), from the latest message, not for each delta (and its text trimmed, a\n\t\t// copy of all of it so far, each time).\n\t\tif (isStreaming) {\n\t\t\tthis.contentIsStale = true;\n\t\t\treturn;\n\t\t}\n\t\tthis.buildContent(message);\n\t}\n\n\t/**\n\t * A Markdown component for `text`: the one built for it before when nothing it was made with has changed. While the\n\t * message streams, one of the same kind built before is given the text instead of making a new one (it is made with the\n\t * same theme, style and options): the text that grows is rendered from what that component rendered for it the time\n\t * before (Markdown.renderLive()).\n\t */\n\tprivate markdownFor(\n\t\tkind: MarkdownBlock[\"kind\"],\n\t\ttext: string,\n\t\tprevious: MarkdownBlock[],\n\t\tcreate: () => Markdown,\n\t): Markdown {\n\t\tconst matches = (block: MarkdownBlock) =>\n\t\t\tblock.kind === kind && block.isStreaming === this.isStreaming && block.outputPad === this.outputPad;\n\t\tlet index = previous.findIndex((block) => matches(block) && block.text === text);\n\t\tif (index === -1 && this.isStreaming) {\n\t\t\tindex = previous.findIndex(matches);\n\t\t\tif (index !== -1) previous[index]!.component.setText(text);\n\t\t}\n\t\tconst component = index === -1 ? create() : previous.splice(index, 1)[0]!.component;\n\t\tthis.markdownBlocks.push({ kind, text, isStreaming: this.isStreaming, outputPad: this.outputPad, component });\n\t\treturn component;\n\t}\n\n\tprivate buildContent(message: AssistantMessage): void {\n\t\tthis.contentIsStale = false;\n\t\tconst previousBlocks = this.markdownBlocks;\n\t\tthis.markdownBlocks = [];\n\t\t// Clear content container\n\t\tthis.contentContainer.clear();\n\n\t\t// (/\\S/ finds what trim() leaves without copying the text: both take the same characters for white space.)\n\t\tconst hasVisibleContent = message.content.some(\n\t\t\t(c) => (c.type === \"text\" && /\\S/.test(c.text)) || (c.type === \"thinking\" && /\\S/.test(c.thinking)),\n\t\t);\n\n\t\tif (hasVisibleContent) {\n\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t}\n\n\t\t// Render content in order\n\t\tlet thinkingRunIndex = 0;\n\t\tfor (let i = 0; i < message.content.length; i++) {\n\t\t\tconst content = message.content[i];\n\t\t\tif (content.type === \"text\" && content.text.trim()) {\n\t\t\t\t// Assistant text messages with no background - trim the text\n\t\t\t\t// Set paddingY=0 to avoid extra spacing before tool executions\n\t\t\t\tconst text = content.text.trim();\n\t\t\t\tthis.contentContainer.addChild(\n\t\t\t\t\tthis.markdownFor(\n\t\t\t\t\t\t\"text\",\n\t\t\t\t\t\ttext,\n\t\t\t\t\t\tpreviousBlocks,\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\tnew Markdown(text, this.outputPad, 0, this.markdownTheme, undefined, {\n\t\t\t\t\t\t\t\ttransform: createMarkdownTransform(\"assistant\", this.isStreaming, this.markdownTransformers),\n\t\t\t\t\t\t\t\tcomplete: !this.isStreaming,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} else if (content.type === \"thinking\") {\n\t\t\t\tconst thinkingBlocks: string[] = [];\n\t\t\t\tfor (; i < message.content.length; i++) {\n\t\t\t\t\tconst thinkingContent = message.content[i];\n\t\t\t\t\tif (thinkingContent.type !== \"thinking\") {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tconst thinking = thinkingContent.thinking.trim();\n\t\t\t\t\tif (thinking) {\n\t\t\t\t\t\tthinkingBlocks.push(thinking);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ti--;\n\n\t\t\t\tif (thinkingBlocks.length === 0) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Add spacing only when another visible assistant content block follows.\n\t\t\t\t// This avoids a superfluous blank line before separately-rendered tool execution blocks.\n\t\t\t\tconst hasVisibleContentAfter = message.content\n\t\t\t\t\t.slice(i + 1)\n\t\t\t\t\t.some((c) => (c.type === \"text\" && c.text.trim()) || (c.type === \"thinking\" && c.thinking.trim()));\n\n\t\t\t\tconst runIndex = thinkingRunIndex++;\n\t\t\t\tconst hidden = this.thinkingVisibilityOverrides.get(runIndex) ?? this.hideThinkingBlock;\n\t\t\t\tconst thinkingText = hidden ? \"\" : thinkingBlocks.join(\"\\n\\n\");\n\t\t\t\tconst thinkingComponent = hidden\n\t\t\t\t\t? new Text(theme.italic(theme.fg(\"thinkingText\", this.hiddenThinkingLabel)), this.outputPad, 0)\n\t\t\t\t\t: this.markdownFor(\n\t\t\t\t\t\t\t\"thinking\",\n\t\t\t\t\t\t\tthinkingText,\n\t\t\t\t\t\t\tpreviousBlocks,\n\t\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\t\tnew Markdown(\n\t\t\t\t\t\t\t\t\tthinkingText,\n\t\t\t\t\t\t\t\t\tthis.outputPad,\n\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\tthis.markdownTheme,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcolor: thinkingTextColor,\n\t\t\t\t\t\t\t\t\t\titalic: true,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttransform: createMarkdownTransform(\n\t\t\t\t\t\t\t\t\t\t\t\"assistant-thinking\",\n\t\t\t\t\t\t\t\t\t\t\tthis.isStreaming,\n\t\t\t\t\t\t\t\t\t\t\tthis.markdownTransformers,\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\tcomplete: !this.isStreaming,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\tthis.contentContainer.addChild(\n\t\t\t\t\tnew MouseRegion(thinkingComponent, (event) => {\n\t\t\t\t\t\tif (event.type !== \"click\" || event.button !== \"left\") return undefined;\n\t\t\t\t\t\tthis.thinkingVisibilityOverrides.set(runIndex, !hidden);\n\t\t\t\t\t\tif (this.lastMessage) this.updateContent(this.lastMessage);\n\t\t\t\t\t\treturn { handled: true };\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\tif (hasVisibleContentAfter) {\n\t\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Check if incomplete/failed - show after partial content.\n\t\t// For aborted/error tool calls, tool execution components show the error.\n\t\t// Length stops can happen before a tool call is complete, so surface them here too.\n\t\tconst hasToolCalls = message.content.some((c) => c.type === \"toolCall\");\n\t\tthis.hasToolCalls = hasToolCalls;\n\t\tif (message.stopReason === \"length\") {\n\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\tthis.contentContainer.addChild(\n\t\t\t\tnew Text(theme.fg(\"error\", \"Response was truncated before completion.\"), this.outputPad, 0),\n\t\t\t);\n\t\t} else if (!hasToolCalls) {\n\t\t\tif (message.stopReason === \"aborted\") {\n\t\t\t\tconst abortMessage =\n\t\t\t\t\tmessage.errorMessage && message.errorMessage !== \"Request was aborted\"\n\t\t\t\t\t\t? message.errorMessage\n\t\t\t\t\t\t: \"Operation aborted\";\n\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t\tthis.contentContainer.addChild(new Text(theme.fg(\"error\", abortMessage), this.outputPad, 0));\n\t\t\t} else if (message.stopReason === \"error\") {\n\t\t\t\tconst errorMsg = message.errorMessage || \"Unknown error\";\n\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t\tthis.contentContainer.addChild(new Text(theme.fg(\"error\", `Error: ${errorMsg}`), this.outputPad, 0));\n\t\t\t}\n\t\t}\n\t}\n}\n\nmarkReportsChanges(AssistantMessageComponent);\nmarkLiveRender(AssistantMessageComponent.prototype.renderShared, function (this: Component, width: number) {\n\treturn (this as AssistantMessageComponent).renderLive(width);\n});\n"]}
|
|
1
|
+
{"version":3,"file":"assistant-message.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/assistant-message.ts"],"names":[],"mappings":"AAEA,OAAO,EAEN,SAAS,EACT,aAAa,EAEb,QAAQ,EAER,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,MAAM,EACN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AC,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE;oBAC5C,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM;wBAAE,OAAO,SAAS,CAAC;oBACxE,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC;oBACxD,IAAI,IAAI,CAAC,WAAW;wBAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;oBAC3D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gBAC1B,CAAC,CAAC,CACF,CAAC;YACH,CAAC;iBAAM,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBACtC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;YAClC,CAAC;iBAAM,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;gBAClC,6GAA6G;gBAC7G,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAC7B,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAC/E,CAAC;YACH,CAAC;QACF,CAAC;IACF,CAAC;CACD;AAED,kBAAkB,CAAC,yBAAyB,CAAC,CAAC;AAC9C,cAAc,CAAC,yBAAyB,CAAC,SAAS,CAAC,YAAY,EAAE,UAA2B,KAAa;IACxG,OAAQ,IAAkC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC,CAAC,CAAC","sourcesContent":["// Derived from Pi-Bolt (MIT, Copyright (c) 2026 OpenSec (Pi-Bolt)), commits b93895d2, a6df6a2c, e851bfde, fb3ae99a; modified for HUMAIN Code CLI.\nimport type { AssistantMessage } from \"@earendil-works/pi-ai\";\nimport {\n\ttype Component,\n\tContainer,\n\tLiveLineArray,\n\ttype LiveLines,\n\tMarkdown,\n\ttype MarkdownTheme,\n\tMouseRegion,\n\tmarkLiveRender,\n\tmarkReportsChanges,\n\treportRenderChange,\n\tSpacer,\n\tsanitizeTerminalText,\n\tstartsWithText,\n\tText,\n} from \"@earendil-works/pi-tui\";\nimport type { MarkdownTransformer } from \"../../../core/extensions/types.ts\";\nimport { getMarkdownTheme, getThemeInstance, theme } from \"../theme/theme.ts\";\nimport { AssistantCodeBlock } from \"./assistant-code-block.ts\";\nimport { createMarkdownTransform } from \"./markdown-transform.ts\";\n\nconst OSC133_ZONE_START = \"\\x1b]133;A\\x07\";\nconst OSC133_ZONE_END = \"\\x1b]133;B\\x07\";\nconst OSC133_ZONE_FINAL = \"\\x1b]133;C\\x07\";\n\n// One function for every render: the Markdown component keeps what it rendered for as long as its style is the same.\nconst thinkingTextColor = (text: string): string => theme.fg(\"thinkingText\", text);\n\n/** Whether `text` contains one of `names` (lowercase), ignoring case. */\nexport function mentionsAny(text: string, names: ReadonlySet<string>): boolean {\n\tif (names.size === 0 || text === \"\") return false;\n\tconst lower = text.toLowerCase();\n\tfor (const name of names) {\n\t\tif (lower.includes(name)) return true;\n\t}\n\treturn false;\n}\n\n/** A text or thinking block's text, trimmed (BlockText.trim()). */\ninterface TrimmedText {\n\t/** The text. */\n\traw: string;\n\t/** raw.trim(). */\n\ttrimmed: string;\n\t/** Whether `raw` has a character that is not white space: `trimmed` is not empty. */\n\tvisible: boolean;\n\t/** The white space `raw` ends with after its last visible character, when it has one. */\n\tpending: string;\n}\n\n/**\n * A text or thinking block of a message streaming in, trimmed without reading all of it for each chunk. A provider adds each\n * delta to the text (`text += delta`), and the engine keeps the result as the two strings joined until it is read; reading\n * it (trim(), a regular expression) then copies all of it into one string, a copy of the whole reply for each chunk. Here\n * each text the block is seen with (updateContent(), for each delta) is compared with the one seen before as a part of it\n * (startsWithText(): the text before is that part, so this reads neither), and what it adds is kept. Trimming then reads\n * the text added only: the result is the text trimmed before with what was added (and the white space before it) after\n * it, the same strings joined, which the Markdown component it is given reads in the same way. The comparisons are real:\n * a text that is not the one before with more after it is trimmed in full.\n */\nclass BlockText {\n\t/** The text as it was seen last. */\n\traw: string;\n\t/** The text as it was trimmed last (trim()). */\n\tprivate trimmed?: TrimmedText;\n\t/** What `raw` adds to `trimmed.raw`, when it is that text with more after it. */\n\tprivate added?: string;\n\n\tconstructor(raw: string) {\n\t\tthis.raw = raw;\n\t}\n\n\t/** The block's text is now `raw`. */\n\tfollow(raw: string): void {\n\t\tif (raw === this.raw) return;\n\t\tconst before = this.raw;\n\t\tthis.raw = raw;\n\t\tif (this.added !== undefined && raw.length > before.length && startsWithText(raw, before)) {\n\t\t\tthis.added += raw.slice(before.length);\n\t\t} else {\n\t\t\tthis.added = undefined;\n\t\t}\n\t}\n\n\t/** raw.trim(), whether it is not empty, from what was trimmed last and what was added since (follow()). */\n\ttrim(): TrimmedText {\n\t\tconst previous = this.trimmed;\n\t\tconst raw = this.raw;\n\t\tconst added = this.added;\n\t\tlet result: TrimmedText;\n\t\tif (previous === undefined || added === undefined) {\n\t\t\tconst trimmed = raw.trim();\n\t\t\tconst visible = trimmed.length > 0;\n\t\t\tresult = { raw, trimmed, visible, pending: visible ? raw.slice(raw.trimEnd().length) : \"\" };\n\t\t} else if (added === \"\") {\n\t\t\tresult = previous;\n\t\t} else if (!previous.visible) {\n\t\t\t// (White space is what trim() removes, which is what /\\s/ matches.)\n\t\t\tconst start = added.search(/\\S/);\n\t\t\tif (start < 0) {\n\t\t\t\tresult = { raw, trimmed: \"\", visible: false, pending: \"\" };\n\t\t\t} else {\n\t\t\t\tconst rest = added.slice(start);\n\t\t\t\tconst trimmed = rest.trimEnd();\n\t\t\t\tresult = { raw, trimmed, visible: true, pending: rest.slice(trimmed.length) };\n\t\t\t}\n\t\t} else {\n\t\t\tconst visibleAdded = added.trimEnd();\n\t\t\tresult =\n\t\t\t\tvisibleAdded.length === 0\n\t\t\t\t\t? { raw, trimmed: previous.trimmed, visible: true, pending: previous.pending + added }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\traw,\n\t\t\t\t\t\t\ttrimmed: previous.trimmed + (previous.pending + visibleAdded),\n\t\t\t\t\t\t\tvisible: true,\n\t\t\t\t\t\t\tpending: added.slice(visibleAdded.length),\n\t\t\t\t\t\t};\n\t\t}\n\t\tthis.trimmed = result;\n\t\tthis.added = \"\";\n\t\treturn result;\n\t}\n}\n\n/** A Markdown component of an assistant message, with what it was made from (AssistantMessageComponent.markdownFor()). */\ninterface MarkdownBlock {\n\tkind: \"text\" | \"thinking\";\n\ttext: string;\n\tisStreaming: boolean;\n\toutputPad: number;\n\tcomponent: Markdown;\n}\n\n/** A part of what buildContent() adds to the content container (planContent()). */\ntype ContentPart =\n\t| { kind: \"spacer\" }\n\t| { kind: \"text\"; text: string }\n\t| { kind: \"thinking\"; runIndex: number; hidden: boolean; text: string }\n\t| { kind: \"toolCalls\"; present: boolean }\n\t| { kind: \"error\"; text: string };\n\n/**\n * Component that renders a complete assistant message\n */\nexport class AssistantMessageComponent extends Container {\n\tprivate contentContainer: Container;\n\tprivate hideThinkingBlock: boolean;\n\tprivate markdownTheme: MarkdownTheme;\n\tprivate hiddenThinkingLabel: string;\n\tprivate outputPad: number;\n\tprivate markdownTransformers: readonly MarkdownTransformer[];\n\tprivate lastMessage?: AssistantMessage;\n\tprivate hasToolCalls = false;\n\tprivate markedFrom?: string[];\n\tprivate markedLines: string[] = [];\n\tprivate markedLive?: { from: LiveLines; revision: number; length: number; lines: LiveLineArray };\n\tprivate isStreaming = false;\n\tprivate contentIsStale = false;\n\tprivate thinkingVisibilityOverrides = new Map<number, boolean>();\n\tprivate messageId?: string;\n\tprivate timestamp?: string;\n\t/**\n\t * The Markdown components of the content, with what they were made from. A rebuild with the same text takes the\n\t * component again instead of making a new one, which would parse its text again and render it from nothing: on\n\t * invalidate() (theme changes), and while a reply streams, for every block but the one growing.\n\t */\n\tprivate markdownBlocks: MarkdownBlock[] = [];\n\tprivate requestRender?: () => void;\n\tprivate copyError?: string;\n\t/**\n\t * What the content was last built for while the reply streamed in (buildContent()): the plan's key and the theme. Dropped\n\t * when anything the components were made with may have changed (invalidate() and the setters).\n\t */\n\tprivate built?: { key: string; theme: unknown };\n\t/** The text and thinking blocks of the message, by index (BlockText). */\n\tprivate blockTexts: Array<BlockText | undefined> = [];\n\n\tconstructor(\n\t\tmessage?: AssistantMessage,\n\t\thideThinkingBlock = false,\n\t\tmarkdownTheme: MarkdownTheme = getMarkdownTheme(),\n\t\thiddenThinkingLabel = \"Thinking...\",\n\t\toutputPad = 1,\n\t\tmarkdownTransformers: readonly MarkdownTransformer[] = [],\n\t\trequestRender?: () => void,\n\t\tmessageId?: string,\n\t\ttimestamp?: string,\n\t) {\n\t\tsuper();\n\n\t\tthis.hideThinkingBlock = hideThinkingBlock;\n\t\tthis.markdownTheme = markdownTheme;\n\t\tthis.hiddenThinkingLabel = hiddenThinkingLabel;\n\t\tthis.outputPad = outputPad;\n\t\tthis.markdownTransformers = markdownTransformers;\n\t\tthis.requestRender = requestRender;\n\t\tthis.messageId = messageId;\n\t\tthis.timestamp = timestamp;\n\n\t\t// Container for text/thinking content\n\t\tthis.contentContainer = new Container();\n\t\tthis.addChild(this.contentContainer);\n\n\t\tif (message) {\n\t\t\tthis.updateContent(message);\n\t\t}\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.built = undefined;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\t/**\n\t * Whether this message may show code highlighted in one of `languages` (lowercase names): whether its text names one\n\t * of them anywhere, which every code block in that language does. Markdown transformers (extensions) may add any.\n\t */\n\tmayHighlight(languages: ReadonlySet<string>): boolean {\n\t\tif (this.markdownTransformers.length > 0) return true;\n\t\tconst content = this.lastMessage?.content ?? [];\n\t\treturn content.some((block) => {\n\t\t\tconst text = block.type === \"text\" ? block.text : block.type === \"thinking\" ? block.thinking : \"\";\n\t\t\treturn mentionsAny(text, languages);\n\t\t});\n\t}\n\n\t/** Copy targets come from native fenced components, never rendered lines or thinking blocks. */\n\tgetCodeBlocks(): readonly AssistantCodeBlock[] {\n\t\tif (this.contentIsStale && this.lastMessage) this.buildContent(this.lastMessage);\n\t\treturn this.markdownBlocks\n\t\t\t.filter((block) => block.kind === \"text\")\n\t\t\t.flatMap((block) => block.component.getCodeBlockComponents())\n\t\t\t.filter((component): component is AssistantCodeBlock => component instanceof AssistantCodeBlock);\n\t}\n\n\tsetHideThinkingBlock(hide: boolean): void {\n\t\tthis.built = undefined;\n\t\tthis.hideThinkingBlock = hide;\n\t\tthis.thinkingVisibilityOverrides.clear();\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\tsetHiddenThinkingLabel(label: string): void {\n\t\tthis.built = undefined;\n\t\tthis.hiddenThinkingLabel = label;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\tsetOutputPad(padding: number): void {\n\t\tthis.built = undefined;\n\t\tthis.outputPad = padding;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\toverride renderShared(width: number): string[] {\n\t\tif (this.contentIsStale && this.lastMessage) this.buildContent(this.lastMessage);\n\t\tconst lines = super.renderShared(width);\n\t\tif (this.hasToolCalls || lines.length === 0) return lines;\n\t\t// Fullscreen prompt navigation needs markers, but shared child lines must stay untouched.\n\t\tif (lines !== this.markedFrom) {\n\t\t\tconst marked = lines.slice();\n\t\t\tmarked[0] = OSC133_ZONE_START + marked[0];\n\t\t\tmarked[marked.length - 1] = OSC133_ZONE_END + OSC133_ZONE_FINAL + marked[marked.length - 1];\n\t\t\tthis.markedFrom = lines;\n\t\t\tthis.markedLines = marked;\n\t\t}\n\t\treturn this.markedLines;\n\t}\n\n\t/** Render the latest streamed content through the children's live lines. */\n\trenderLive(width: number): LiveLines {\n\t\tif (this.contentIsStale && this.lastMessage) this.buildContent(this.lastMessage);\n\t\tconst children = this.renderLiveChildren(width);\n\t\tconst count = children.lines.length;\n\t\tif (this.hasToolCalls || count === 0) return children;\n\t\tlet marked = this.markedLive;\n\t\tlet start = 0;\n\t\tif (marked?.from === children) {\n\t\t\tconst changed = children.changedSince(marked.revision);\n\t\t\tif (changed === Number.POSITIVE_INFINITY) return marked.lines;\n\t\t\t// The former last line loses its end marker, and the new last line gets it.\n\t\t\tstart = Math.min(changed, marked.length - 1, count - 1);\n\t\t} else {\n\t\t\tmarked = { from: children, revision: 0, length: 0, lines: new LiveLineArray() };\n\t\t\tthis.markedLive = marked;\n\t\t}\n\t\tstart = Math.max(0, start);\n\t\tmarked.lines.edit(start);\n\t\tfor (let index = start; index < count; index++) {\n\t\t\tlet line = children.lines[index]!;\n\t\t\tif (index === 0) line = OSC133_ZONE_START + line;\n\t\t\tif (index === count - 1) line = OSC133_ZONE_END + OSC133_ZONE_FINAL + line;\n\t\t\tmarked.lines.lines.push(line);\n\t\t}\n\t\tmarked.revision = children.revision;\n\t\tmarked.length = count;\n\t\treturn marked.lines;\n\t}\n\n\tupdateContent(message: AssistantMessage, isStreaming = this.isStreaming): void {\n\t\tthis.lastMessage = message;\n\t\tthis.isStreaming = isStreaming;\n\t\tthis.followTexts(message);\n\t\treportRenderChange(this);\n\t\t// While a reply streams, every delta of it comes here, and the screen is drawn a few dozen times a second at most: the\n\t\t// components are made when it is (render()), from the latest message, not for each delta (and its text trimmed, a\n\t\t// copy of all of it so far, each time).\n\t\tif (isStreaming) {\n\t\t\tthis.contentIsStale = true;\n\t\t\treturn;\n\t\t}\n\t\tthis.buildContent(message);\n\t}\n\n\t/**\n\t * A Markdown component for `text`: the one built for it before when nothing it was made with has changed. While the\n\t * message streams, one of the same kind built before is given the text instead of making a new one (it is made with the\n\t * same theme, style and options): the text that grows is rendered from what that component rendered for it the time\n\t * before (Markdown.renderLive()).\n\t */\n\tprivate markdownFor(\n\t\tkind: MarkdownBlock[\"kind\"],\n\t\ttext: string,\n\t\tprevious: MarkdownBlock[],\n\t\tcreate: () => Markdown,\n\t): Markdown {\n\t\tconst matches = (block: MarkdownBlock) =>\n\t\t\tblock.kind === kind && block.isStreaming === this.isStreaming && block.outputPad === this.outputPad;\n\t\tlet index = previous.findIndex((block) => matches(block) && block.text === text);\n\t\tif (index === -1 && this.isStreaming) {\n\t\t\tindex = previous.findIndex(matches);\n\t\t\tif (index !== -1) previous[index]!.component.setText(text);\n\t\t}\n\t\tconst component = index === -1 ? create() : previous.splice(index, 1)[0]!.component;\n\t\tthis.markdownBlocks.push({ kind, text, isStreaming: this.isStreaming, outputPad: this.outputPad, component });\n\t\treturn component;\n\t}\n\n\t/** The texts of the text and thinking blocks of `message` (BlockText.follow(): for each delta, while a reply streams in). */\n\tprivate followTexts(message: AssistantMessage): void {\n\t\tconst content = message.content;\n\t\tconst blockTexts = this.blockTexts;\n\t\tblockTexts.length = content.length;\n\t\tfor (let i = 0; i < content.length; i++) {\n\t\t\tconst block = content[i];\n\t\t\tconst raw = block.type === \"text\" ? block.text : block.type === \"thinking\" ? block.thinking : undefined;\n\t\t\tif (raw === undefined) {\n\t\t\t\tblockTexts[i] = undefined;\n\t\t\t} else {\n\t\t\t\tconst known = blockTexts[i];\n\t\t\t\tif (known === undefined) blockTexts[i] = new BlockText(raw);\n\t\t\t\telse known.follow(raw);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * What buildContent() adds to the content container for `message`, in order. While a reply streams in, a chunk usually\n\t * changes only the texts of its Markdown components: the same plan but for those texts (planKey()).\n\t */\n\tprivate planContent(message: AssistantMessage): ContentPart[] {\n\t\tconst parts: ContentPart[] = [];\n\t\tconst content = message.content;\n\t\t// Each text and thinking block trimmed (BlockText).\n\t\tthis.followTexts(message);\n\t\tconst trimmedTexts: Array<TrimmedText | undefined> = [];\n\t\tfor (let i = 0; i < content.length; i++) {\n\t\t\tconst trimmed = this.blockTexts[i]?.trim();\n\t\t\ttrimmedTexts.push(trimmed);\n\t\t}\n\n\t\t// Spacers are added lazily, right before the next visible content block. This puts a blank\n\t\t// line before the first visible block and after each visible thinking run that is followed\n\t\t// by more visible content, while hidden thinking runs without a label contribute nothing.\n\t\tlet needsSpacer = true;\n\n\t\t// Render content in order\n\t\tlet thinkingRunIndex = 0;\n\t\tfor (let i = 0; i < content.length; i++) {\n\t\t\tconst block = content[i];\n\t\t\tconst trimmed = trimmedTexts[i];\n\t\t\tif (block.type === \"text\" && trimmed?.visible) {\n\t\t\t\t// Assistant text has no background; keep trailing whitespace for unfinished fenced blocks.\n\t\t\t\t// Set paddingY=0 to avoid extra spacing before tool executions\n\t\t\t\tif (needsSpacer) parts.push({ kind: \"spacer\" });\n\t\t\t\tneedsSpacer = false;\n\t\t\t\tparts.push({ kind: \"text\", text: trimmed.trimmed + trimmed.pending });\n\t\t\t} else if (block.type === \"thinking\") {\n\t\t\t\tconst thinkingBlocks: string[] = [];\n\t\t\t\tfor (; i < content.length; i++) {\n\t\t\t\t\tif (content[i].type !== \"thinking\") {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tconst thinking = trimmedTexts[i];\n\t\t\t\t\tif (thinking?.visible) {\n\t\t\t\t\t\tthinkingBlocks.push(thinking.trimmed);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ti--;\n\n\t\t\t\tif (thinkingBlocks.length === 0) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Add spacing only when another visible assistant content block follows.\n\t\t\t\t// This avoids a superfluous blank line before separately-rendered tool execution blocks.\n\t\t\t\tconst runIndex = thinkingRunIndex++;\n\t\t\t\tconst hidden = this.thinkingVisibilityOverrides.get(runIndex) ?? this.hideThinkingBlock;\n\t\t\t\t// A hidden run with an empty label renders nothing, including no spacing.\n\t\t\t\tif (hidden && !this.hiddenThinkingLabel.trim()) continue;\n\t\t\t\tif (needsSpacer) parts.push({ kind: \"spacer\" });\n\t\t\t\t// (One block's text as it is: the same text as joined, and the strings it was trimmed to, see BlockText.)\n\t\t\t\tconst text = hidden ? \"\" : thinkingBlocks.length === 1 ? thinkingBlocks[0] : thinkingBlocks.join(\"\\n\\n\");\n\t\t\t\tparts.push({ kind: \"thinking\", runIndex, hidden, text });\n\t\t\t\tneedsSpacer = true;\n\t\t\t}\n\t\t}\n\n\t\t// Check if incomplete/failed - show after partial content.\n\t\t// For aborted/error tool calls, tool execution components show the error.\n\t\t// Length stops can happen before a tool call is complete, so surface them here too.\n\t\tif (this.copyError) {\n\t\t\tparts.push({ kind: \"spacer\" });\n\t\t\tparts.push({ kind: \"error\", text: `Copy failed: ${this.copyError}` });\n\t\t}\n\n\t\tconst hasToolCalls = message.content.some((c) => c.type === \"toolCall\");\n\t\tparts.push({ kind: \"toolCalls\", present: hasToolCalls });\n\t\tif (message.stopReason === \"length\") {\n\t\t\tparts.push({ kind: \"spacer\" });\n\t\t\tparts.push({ kind: \"error\", text: \"Response was truncated before completion.\" });\n\t\t} else if (!hasToolCalls) {\n\t\t\tif (message.stopReason === \"aborted\") {\n\t\t\t\tconst abortMessage =\n\t\t\t\t\tmessage.errorMessage && message.errorMessage !== \"Request was aborted\"\n\t\t\t\t\t\t? message.errorMessage\n\t\t\t\t\t\t: \"Operation aborted\";\n\t\t\t\tparts.push({ kind: \"spacer\" });\n\t\t\t\tparts.push({ kind: \"error\", text: abortMessage });\n\t\t\t} else if (message.stopReason === \"error\") {\n\t\t\t\tconst errorMsg = message.errorMessage || \"Unknown error\";\n\t\t\t\tparts.push({ kind: \"spacer\" });\n\t\t\t\tparts.push({ kind: \"error\", text: `Error: ${errorMsg}` });\n\t\t\t}\n\t\t}\n\t\treturn parts;\n\t}\n\n\t/**\n\t * Everything the components buildContent() makes for `parts` depend on but the texts of the Markdown components: two\n\t * plans with the same key give the same components, but for the text each Markdown component is given.\n\t */\n\tprivate planKey(parts: readonly ContentPart[]): string {\n\t\tlet key = `${this.isStreaming}|${this.outputPad}|${this.hiddenThinkingLabel}`;\n\t\tfor (const part of parts) {\n\t\t\tif (part.kind === \"thinking\") key += `|thinking:${part.runIndex}:${part.hidden}`;\n\t\t\telse if (part.kind === \"toolCalls\") key += `|toolCalls:${part.present}`;\n\t\t\telse if (part.kind === \"error\") key += `|error:${part.text}`;\n\t\t\telse key += `|${part.kind}`;\n\t\t}\n\t\treturn key;\n\t}\n\n\tprivate buildContent(message: AssistantMessage): void {\n\t\tthis.contentIsStale = false;\n\t\tconst parts = this.planContent(message);\n\t\tconst key = this.planKey(parts);\n\t\t// A reply streaming in, built the last time with the same plan, the same theme and nothing invalidated since: the same\n\t\t// components, each Markdown component given its text as markdownFor() gives it (the text changed, or none).\n\t\tconst built = this.built;\n\t\tif (this.isStreaming && built !== undefined && built.key === key && built.theme === getThemeInstance()) {\n\t\t\tlet index = 0;\n\t\t\tfor (const part of parts) {\n\t\t\t\tif (part.kind !== \"text\" && (part.kind !== \"thinking\" || part.hidden)) continue;\n\t\t\t\tconst block = this.markdownBlocks[index++]!;\n\t\t\t\tif (block.text !== part.text) {\n\t\t\t\t\tblock.text = part.text;\n\t\t\t\t\tblock.component.setText(part.text);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tthis.built = this.isStreaming ? { key, theme: getThemeInstance() } : undefined;\n\n\t\tconst previousBlocks = this.markdownBlocks;\n\t\tthis.markdownBlocks = [];\n\t\t// Clear content container\n\t\tthis.contentContainer.clear();\n\n\t\tfor (const part of parts) {\n\t\t\tif (part.kind === \"spacer\") {\n\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t} else if (part.kind === \"text\") {\n\t\t\t\tconst text = part.text;\n\t\t\t\tthis.contentContainer.addChild(\n\t\t\t\t\tthis.markdownFor(\n\t\t\t\t\t\t\"text\",\n\t\t\t\t\t\ttext,\n\t\t\t\t\t\tpreviousBlocks,\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\tnew Markdown(text, this.outputPad, 0, this.markdownTheme, undefined, {\n\t\t\t\t\t\t\t\ttransform: createMarkdownTransform(\n\t\t\t\t\t\t\t\t\t\"assistant\",\n\t\t\t\t\t\t\t\t\t() => this.isStreaming,\n\t\t\t\t\t\t\t\t\tthis.markdownTransformers,\n\t\t\t\t\t\t\t\t\tthis.messageId,\n\t\t\t\t\t\t\t\t\tthis.timestamp,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tcomplete: !this.isStreaming,\n\t\t\t\t\t\t\t\trenderCodeBlock: AssistantCodeBlock.renderer(\n\t\t\t\t\t\t\t\t\tthis.markdownTheme,\n\t\t\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\t\t\tthis.invalidate();\n\t\t\t\t\t\t\t\t\t\tthis.requestRender?.();\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t(error) => {\n\t\t\t\t\t\t\t\t\t\tthis.copyError = error;\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} else if (part.kind === \"thinking\") {\n\t\t\t\tconst { runIndex, hidden, text: thinkingText } = part;\n\t\t\t\tconst thinkingComponent = hidden\n\t\t\t\t\t? new Text(theme.italic(theme.fg(\"thinkingText\", this.hiddenThinkingLabel)), this.outputPad, 0)\n\t\t\t\t\t: this.markdownFor(\n\t\t\t\t\t\t\t\"thinking\",\n\t\t\t\t\t\t\tthinkingText,\n\t\t\t\t\t\t\tpreviousBlocks,\n\t\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\t\tnew Markdown(\n\t\t\t\t\t\t\t\t\tthinkingText,\n\t\t\t\t\t\t\t\t\tthis.outputPad,\n\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\tthis.markdownTheme,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcolor: thinkingTextColor,\n\t\t\t\t\t\t\t\t\t\titalic: true,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttransform: createMarkdownTransform(\n\t\t\t\t\t\t\t\t\t\t\t\"assistant-thinking\",\n\t\t\t\t\t\t\t\t\t\t\t() => this.isStreaming,\n\t\t\t\t\t\t\t\t\t\t\tthis.markdownTransformers,\n\t\t\t\t\t\t\t\t\t\t\tthis.messageId,\n\t\t\t\t\t\t\t\t\t\t\tthis.timestamp,\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\tcomplete: !this.isStreaming,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\tthis.contentContainer.addChild(\n\t\t\t\t\tnew MouseRegion(thinkingComponent, (event) => {\n\t\t\t\t\t\tif (event.type !== \"click\" || event.button !== \"left\") return undefined;\n\t\t\t\t\t\tthis.thinkingVisibilityOverrides.set(runIndex, !hidden);\n\t\t\t\t\t\tif (this.lastMessage) this.updateContent(this.lastMessage);\n\t\t\t\t\t\treturn { handled: true };\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t} else if (part.kind === \"toolCalls\") {\n\t\t\t\tthis.hasToolCalls = part.present;\n\t\t\t} else if (part.kind === \"error\") {\n\t\t\t\t// (An error's text can come from the provider's response: escape sequences in it would act on the terminal.)\n\t\t\t\tthis.contentContainer.addChild(\n\t\t\t\t\tnew Text(theme.fg(\"error\", sanitizeTerminalText(part.text)), this.outputPad, 0),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\nmarkReportsChanges(AssistantMessageComponent);\nmarkLiveRender(AssistantMessageComponent.prototype.renderShared, function (this: Component, width: number) {\n\treturn (this as AssistantMessageComponent).renderLive(width);\n});\n"]}
|