@ashx-j/lunr 0.2.22 → 0.2.24
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 +16 -1
- package/README.md +15 -13
- package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-tui.js +2 -2
- package/dist/builtin-extensions/ashxj-tui.js.map +1 -1
- package/dist/builtin-extensions/lunr-browser.d.ts +7 -1
- package/dist/builtin-extensions/lunr-browser.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-browser.js +116 -3
- package/dist/builtin-extensions/lunr-browser.js.map +1 -1
- package/dist/builtin-extensions/lunr-plan-tools.d.ts +7 -7
- package/dist/builtin-extensions/lunr-plan-tools.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-plan-tools.js +12 -12
- package/dist/builtin-extensions/lunr-plan-tools.js.map +1 -1
- package/dist/builtin-extensions/pi-intercom/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-intercom/index.js +2 -0
- package/dist/builtin-extensions/pi-intercom/index.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.js +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts +4 -4
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js +6 -4
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.d.ts +2 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js +6 -3
- package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js +7 -2
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts +2 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js +4 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts +2 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js +9 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js +41 -3
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js +5 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js +3 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +23 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts +2 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js +17 -15
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js +3 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js +2 -2
- package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/communication.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/communication.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/communication.js +3 -2
- package/dist/builtin-extensions/pi-subagents/src/tui/communication.js.map +1 -1
- package/dist/core/agent-session.d.ts +20 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +235 -107
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/browser/schema.d.ts +1 -1
- package/dist/core/browser/schema.d.ts.map +1 -1
- package/dist/core/browser/schema.js +1 -1
- package/dist/core/browser/schema.js.map +1 -1
- package/dist/core/catalog-cache-scope.d.ts.map +1 -1
- package/dist/core/catalog-cache-scope.js +3 -1
- package/dist/core/catalog-cache-scope.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +3 -2
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/permissions.d.ts +16 -23
- package/dist/core/permissions.d.ts.map +1 -1
- package/dist/core/permissions.js +66 -141
- package/dist/core/permissions.js.map +1 -1
- package/dist/core/plan-mode.d.ts +10 -12
- package/dist/core/plan-mode.d.ts.map +1 -1
- package/dist/core/plan-mode.js +16 -18
- package/dist/core/plan-mode.js.map +1 -1
- package/dist/core/runtime-bridges.d.ts.map +1 -1
- package/dist/core/runtime-bridges.js +2 -0
- package/dist/core/runtime-bridges.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +13 -6
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +9 -2
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +13 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +49 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +4 -4
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/subagent-permission-inherit.d.ts +6 -10
- package/dist/core/subagent-permission-inherit.d.ts.map +1 -1
- package/dist/core/subagent-permission-inherit.js +14 -14
- package/dist/core/subagent-permission-inherit.js.map +1 -1
- package/dist/core/subagent-wait-interruption.d.ts +11 -0
- package/dist/core/subagent-wait-interruption.d.ts.map +1 -0
- package/dist/core/subagent-wait-interruption.js +19 -0
- package/dist/core/subagent-wait-interruption.js.map +1 -0
- package/dist/core/system-prompt.d.ts +2 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +11 -4
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +3 -3
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +3 -3
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/gateway/adapters/discord.d.ts.map +1 -1
- package/dist/gateway/adapters/discord.js +1 -1
- package/dist/gateway/adapters/discord.js.map +1 -1
- package/dist/gateway/approval.d.ts +2 -6
- package/dist/gateway/approval.d.ts.map +1 -1
- package/dist/gateway/approval.js +3 -7
- package/dist/gateway/approval.js.map +1 -1
- package/dist/gateway/mobile-commands.d.ts.map +1 -1
- package/dist/gateway/mobile-commands.js +12 -11
- package/dist/gateway/mobile-commands.js.map +1 -1
- package/dist/gateway/router.d.ts.map +1 -1
- package/dist/gateway/router.js +1 -1
- package/dist/gateway/router.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +1 -2
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +10 -2
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +29 -5
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/copyable-text.d.ts +2 -6
- package/dist/modes/interactive/components/copyable-text.d.ts.map +1 -1
- package/dist/modes/interactive/components/copyable-text.js +26 -35
- package/dist/modes/interactive/components/copyable-text.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +7 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +36 -3
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-tail.d.ts +9 -2
- package/dist/modes/interactive/components/thinking-tail.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-tail.js +43 -1
- package/dist/modes/interactive/components/thinking-tail.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +5 -3
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +44 -45
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +7 -2
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +194 -129
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +1 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +23 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/node-runtime/{agent-session-services-NQ6GKOIK.js → agent-session-services-IEF7LQWD.js} +12 -13
- package/dist/node-runtime/{builtin-extensions-GVC6IFDU.js → builtin-extensions-EBAWTH4M.js} +5 -5
- package/dist/node-runtime/{chunk-XLTL257W.js → chunk-2KIPT4HJ.js} +5 -1
- package/dist/node-runtime/{chunk-IWOWXRWU.js → chunk-5Q3EHOHI.js} +21 -21
- package/dist/node-runtime/{chunk-6B2POMK7.js → chunk-6VYZ5UFP.js} +1 -1
- package/dist/node-runtime/{chunk-TQGPP4SC.js → chunk-CDVHZOOK.js} +1 -1
- package/dist/node-runtime/{chunk-TDL7UWJ7.js → chunk-DE2JB6J5.js} +189 -70
- package/dist/node-runtime/{chunk-YJMMG7C6.js → chunk-DSIKTUPW.js} +1 -1
- package/dist/node-runtime/{chunk-IQIEU7SB.js → chunk-F4FLTQKV.js} +2 -2
- package/dist/node-runtime/{chunk-GMHJCCEN.js → chunk-FU6OODRZ.js} +4 -1
- package/dist/node-runtime/{chunk-5BNJ4JUH.js → chunk-GJ2RDBRL.js} +1 -1
- package/dist/node-runtime/{chunk-GNN7H3B7.js → chunk-GS42T6MX.js} +1 -1
- package/dist/node-runtime/{chunk-OFKSVRV7.js → chunk-GYIXXQAO.js} +1 -1
- package/dist/node-runtime/{chunk-BX2RB477.js → chunk-HFVZUPFJ.js} +1 -1
- package/dist/node-runtime/{chunk-PC2Z5TKZ.js → chunk-HMBGROQK.js} +3 -3
- package/dist/node-runtime/{chunk-AZJHNQKQ.js → chunk-I54LGHWM.js} +1 -1
- package/dist/node-runtime/{chunk-IVXYUAJE.js → chunk-IF24A3FH.js} +1 -1
- package/dist/node-runtime/{chunk-VJPTNWAP.js → chunk-IGV54Q5V.js} +3 -3
- package/dist/node-runtime/{chunk-QDGKKKUM.js → chunk-K5AGHH57.js} +18 -13
- package/dist/node-runtime/{chunk-GS66LV4M.js → chunk-KJ6DWS3K.js} +4 -4
- package/dist/node-runtime/{chunk-EQ63ANHL.js → chunk-L3LX4SNR.js} +310 -192
- package/dist/node-runtime/{chunk-VSELYKWU.js → chunk-LWYIVUGV.js} +2 -1
- package/dist/node-runtime/{chunk-JHYKXIMM.js → chunk-MPKSOJBT.js} +1 -1
- package/dist/node-runtime/{chunk-UAFLNHSH.js → chunk-OF7PWMG4.js} +8 -8
- package/dist/node-runtime/{chunk-CSUZVNYE.js → chunk-OVX6X377.js} +10 -6
- package/dist/node-runtime/{chunk-ORH324EP.js → chunk-PCEW76PM.js} +3 -3
- package/dist/node-runtime/{chunk-6427XAWG.js → chunk-QH6YL7VK.js} +3 -3
- package/dist/node-runtime/{chunk-LMBNLFXQ.js → chunk-QM43FEAE.js} +15 -15
- package/dist/node-runtime/{chunk-7QWNYZDI.js → chunk-RDDAZOMU.js} +16 -0
- package/dist/node-runtime/{chunk-WADV2VDS.js → chunk-RORY2HMJ.js} +46 -5
- package/dist/node-runtime/{chunk-H3XF4UVQ.js → chunk-RWTKOC3B.js} +1 -1
- package/dist/node-runtime/{chunk-V2A7CEXK.js → chunk-WHLRAGUQ.js} +13 -12
- package/dist/node-runtime/{chunk-GJSAD4AB.js → chunk-Y73WPE6S.js} +17 -17
- package/dist/node-runtime/{chunk-VSSXXL36.js → chunk-YDO2F2IA.js} +2 -2
- package/dist/node-runtime/{chunk-BFNXONG3.js → chunk-YVI6L6LU.js} +5 -5
- package/dist/node-runtime/{chunk-5D7LC2ZQ.js → chunk-ZXSGTGJ6.js} +54 -85
- package/dist/node-runtime/cli-runtime.js +1 -1
- package/dist/node-runtime/{command-3JHHXOPX.js → command-7BG7VVTS.js} +3 -3
- package/dist/node-runtime/{commands-KAMO2T6P.js → commands-NZLSOHPE.js} +2 -2
- package/dist/node-runtime/{commands-2JVNFGMQ.js → commands-QFDKNQTL.js} +9 -9
- package/dist/node-runtime/{direct-tool-executor-YAVOLDFY.js → direct-tool-executor-77GW4F5P.js} +3 -3
- package/dist/node-runtime/{export-html-KBFVV63J.js → export-html-VM4J2MNR.js} +2 -2
- package/dist/node-runtime/{extension-input-K24TVKVW.js → extension-input-E7BJZ35H.js} +4 -4
- package/dist/node-runtime/{extension-selector-SPNF7EDR.js → extension-selector-WU42XDTU.js} +4 -4
- package/dist/node-runtime/{gateway-VFO6SFKK.js → gateway-TWR3N65G.js} +14 -14
- package/dist/node-runtime/index.js +26 -27
- package/dist/node-runtime/{init-X2LIUB2H.js → init-HS6NQXSK.js} +2 -2
- package/dist/node-runtime/{install-cli-C3CF7O7N.js → install-cli-VAP6KBFN.js} +1 -1
- package/dist/node-runtime/{interactive-mode-LOM6AIF6.js → interactive-mode-6J5VZ2TT.js} +19 -20
- package/dist/node-runtime/{interactive-view-IDSCPPK7.js → interactive-view-NGFAMHPW.js} +7 -7
- package/dist/node-runtime/lunr-browser-J5ZZYVGM.js +174 -0
- package/dist/node-runtime/{lunr-cron-BKHGNBKT.js → lunr-cron-CXOL37AL.js} +7 -7
- package/dist/node-runtime/main.js +22 -23
- package/dist/node-runtime/{mobile-commands-HMP25WBC.js → mobile-commands-VTBM5DSZ.js} +6 -6
- package/dist/node-runtime/{model-runtime-PLQKAG4B.js → model-runtime-OO5HFLWE.js} +1 -1
- package/dist/node-runtime/{package-manager-cli-VCK4E2RC.js → package-manager-cli-ZLW5DZXF.js} +9 -10
- package/dist/node-runtime/{pi-intercom-HBPK5HSJ.js → pi-intercom-QM53RLTS.js} +2 -0
- package/dist/node-runtime/{pi-mcp-adapter-E6WULBKF.js → pi-mcp-adapter-5UKBZP44.js} +7 -6
- package/dist/node-runtime/{pi-subagents-FEUDLJOE.js → pi-subagents-XPCLLKIM.js} +65 -21
- package/dist/node-runtime/{proxy-modes-OSQCWRBI.js → proxy-modes-LGEUYD7R.js} +3 -3
- package/dist/node-runtime/rpc-entry.js +22 -23
- package/dist/node-runtime/{rpc-mode-P5ODXPEG.js → rpc-mode-O3XV4SID.js} +2 -2
- package/dist/node-runtime/{runtime-bridges-3XUQ46XW.js → runtime-bridges-QYXUX2TG.js} +8 -1
- package/dist/node-runtime/{session-handoff-HC7R5E24.js → session-handoff-GWARVEWT.js} +2 -2
- package/dist/node-runtime/{session-manager-CFN4UFM2.js → session-manager-JB5J6XBN.js} +1 -1
- package/dist/node-runtime/{session-selector-LHRMJOKT.js → session-selector-GIM4DHQ2.js} +4 -4
- package/dist/node-runtime/{settings-manager-UUZ6NUXI.js → settings-manager-WCQDUVQB.js} +7 -4
- package/dist/node-runtime/{setup-NRXVZBLJ.js → setup-YRBKH2LD.js} +2 -2
- package/dist/node-runtime/{subagent-executor-MLUMBWCP.js → subagent-executor-OTNISDQU.js} +47 -10
- package/dist/node-runtime/{theme-U7IGOA7O.js → theme-UOO5RVFN.js} +1 -1
- package/dist/node-runtime/{update-cli-4TP25CNW.js → update-cli-VBR2777K.js} +1 -2
- package/dist/startup/interactive-view.d.ts.map +1 -1
- package/dist/startup/interactive-view.js +5 -1
- package/dist/startup/interactive-view.js.map +1 -1
- package/docs/browser.md +1 -1
- package/docs/features.md +17 -14
- package/docs/index.md +1 -1
- package/docs/keybindings.md +1 -1
- package/docs/providers.md +6 -2
- package/docs/quickstart.md +2 -2
- package/docs/settings.md +2 -1
- package/docs/usage.md +6 -6
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/plan-mode/README.md +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/package.json +4 -4
- package/dist/node-runtime/chunk-LISUTZS3.js +0 -19
- package/dist/node-runtime/lunr-browser-YNW7FTYX.js +0 -87
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Component, type MarkdownTheme } from "@ashx-j/lunr-tui";
|
|
1
|
+
import { type Component, Markdown, type MarkdownTheme } from "@ashx-j/lunr-tui";
|
|
2
2
|
/**
|
|
3
3
|
* lunr: rolling window for a still-streaming thinking run. Renders the full
|
|
4
4
|
* Markdown block (same styling as the complete-run branch) but returns only
|
|
@@ -10,7 +10,7 @@ import { type Component, type MarkdownTheme } from "@ashx-j/lunr-tui";
|
|
|
10
10
|
/** Maximum rendered lines shown for a streaming thinking run. */
|
|
11
11
|
export declare const THINKING_TAIL_LINES = 4;
|
|
12
12
|
export declare class ThinkingTailComponent implements Component {
|
|
13
|
-
|
|
13
|
+
protected markdown: Markdown;
|
|
14
14
|
private maxLines;
|
|
15
15
|
constructor(text: string, paddingX: number, paddingY: number, markdownTheme: MarkdownTheme, options?: {
|
|
16
16
|
color?: (text: string) => string;
|
|
@@ -19,4 +19,11 @@ export declare class ThinkingTailComponent implements Component {
|
|
|
19
19
|
invalidate(): void;
|
|
20
20
|
render(width: number): string[];
|
|
21
21
|
}
|
|
22
|
+
export declare class ThinkingLineComponent extends ThinkingTailComponent {
|
|
23
|
+
private readonly startedAt;
|
|
24
|
+
private palette;
|
|
25
|
+
constructor(text: string, paddingX: number, markdownTheme: MarkdownTheme, startedAt: number);
|
|
26
|
+
invalidate(): void;
|
|
27
|
+
render(width: number): string[];
|
|
28
|
+
}
|
|
22
29
|
//# sourceMappingURL=thinking-tail.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thinking-tail.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/thinking-tail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"thinking-tail.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/thinking-tail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAiC,MAAM,wBAAwB,CAAC;AAIrH;;;;;;;GAOG;AAEH,iEAAiE;AACjE,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,qBAAa,qBAAsB,YAAW,SAAS;IACtD,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC7B,OAAO,CAAC,QAAQ,CAAS;IAEzB,YACC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,aAAa,EAC5B,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,EAChE,QAAQ,GAAE,MAA4B,EAItC;IAED,UAAU,IAAI,IAAI,CAEjB;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAG9B;CACD;AAKD,qBAAa,qBAAsB,SAAQ,qBAAqB;IAC/D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,OAAO,CAAoD;IAEnE,YAAY,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAG1F;IAEQ,UAAU,IAAI,IAAI,CAG1B;IAEQ,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAuBvC;CACD","sourcesContent":["import { type Component, Markdown, type MarkdownTheme, truncateToWidth, visibleWidth } from \"@ashx-j/lunr-tui\";\nimport { stripAnsi } from \"../../../utils/ansi.ts\";\nimport { theme } from \"../theme/theme.ts\";\n\n/**\n * lunr: rolling window for a still-streaming thinking run. Renders the full\n * Markdown block (same styling as the complete-run branch) but returns only\n * the last `maxLines` rendered lines, so at most N visual lines of reasoning\n * are on screen at a time and older lines disappear as new ones stream in.\n * Short tails are not padded to `maxLines`. The slot grows 1→4, then rolls.\n * Applied render-time only; the transcript is untouched.\n */\n\n/** Maximum rendered lines shown for a streaming thinking run. */\nexport const THINKING_TAIL_LINES = 4;\n\nexport class ThinkingTailComponent implements Component {\n\tprotected markdown: Markdown;\n\tprivate maxLines: number;\n\n\tconstructor(\n\t\ttext: string,\n\t\tpaddingX: number,\n\t\tpaddingY: number,\n\t\tmarkdownTheme: MarkdownTheme,\n\t\toptions?: { color?: (text: string) => string; italic?: boolean },\n\t\tmaxLines: number = THINKING_TAIL_LINES,\n\t) {\n\t\tthis.maxLines = maxLines;\n\t\tthis.markdown = new Markdown(text, paddingX, paddingY, markdownTheme, options);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.markdown.invalidate();\n\t}\n\n\trender(width: number): string[] {\n\t\tconst lines = this.markdown.render(width);\n\t\treturn lines.length <= this.maxLines ? lines : lines.slice(-this.maxLines);\n\t}\n}\n\nconst shimmerSegmenter = new Intl.Segmenter(undefined, { granularity: \"grapheme\" });\nconst SHIMMER_PERIOD_MS = 2800;\n\nexport class ThinkingLineComponent extends ThinkingTailComponent {\n\tprivate readonly startedAt: number;\n\tprivate palette = theme.getFgGradient(\"thinkingText\", \"white\", 32);\n\n\tconstructor(text: string, paddingX: number, markdownTheme: MarkdownTheme, startedAt: number) {\n\t\tsuper(text, paddingX, 0, markdownTheme);\n\t\tthis.startedAt = startedAt;\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.palette = theme.getFgGradient(\"thinkingText\", \"white\", 32);\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (width <= 0) return [\"\", \"\"];\n\t\tconst lines = this.markdown.render(width);\n\t\tlet latest = \"\";\n\t\tfor (let index = lines.length - 1; index >= 0; index--) {\n\t\t\tlatest = stripAnsi(lines[index]).trimEnd();\n\t\t\tif (latest.trim()) break;\n\t\t}\n\t\tconst text = stripAnsi(truncateToWidth(latest, width, \"\"));\n\t\tconst length = visibleWidth(text);\n\t\tconst band = Math.max(6, Math.min(18, length * 0.3));\n\t\tconst progress = ((performance.now() - this.startedAt) % SHIMMER_PERIOD_MS) / SHIMMER_PERIOD_MS;\n\t\tconst center = -band + progress * (length + band * 2);\n\t\tlet column = 0;\n\t\tlet highlighted = \"\";\n\t\tfor (const { segment } of shimmerSegmenter.segment(text)) {\n\t\t\tconst cells = visibleWidth(segment);\n\t\t\tconst distance = Math.abs(column + cells / 2 - center) / band;\n\t\t\tconst intensity = distance >= 1 ? 0 : (1 + Math.cos(Math.PI * distance)) / 2;\n\t\t\thighlighted += this.palette[Math.round(intensity * (this.palette.length - 1))] + segment;\n\t\t\tcolumn += cells;\n\t\t}\n\t\treturn [\"\", `\\x1b[3m${highlighted}\\x1b[23m\\x1b[39m`];\n\t}\n}\n"]}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { Markdown } from "@ashx-j/lunr-tui";
|
|
1
|
+
import { Markdown, truncateToWidth, visibleWidth } from "@ashx-j/lunr-tui";
|
|
2
|
+
import { stripAnsi } from "../../../utils/ansi.js";
|
|
3
|
+
import { theme } from "../theme/theme.js";
|
|
2
4
|
/**
|
|
3
5
|
* lunr: rolling window for a still-streaming thinking run. Renders the full
|
|
4
6
|
* Markdown block (same styling as the complete-run branch) but returns only
|
|
@@ -24,4 +26,44 @@ export class ThinkingTailComponent {
|
|
|
24
26
|
return lines.length <= this.maxLines ? lines : lines.slice(-this.maxLines);
|
|
25
27
|
}
|
|
26
28
|
}
|
|
29
|
+
const shimmerSegmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
30
|
+
const SHIMMER_PERIOD_MS = 2800;
|
|
31
|
+
export class ThinkingLineComponent extends ThinkingTailComponent {
|
|
32
|
+
startedAt;
|
|
33
|
+
palette = theme.getFgGradient("thinkingText", "white", 32);
|
|
34
|
+
constructor(text, paddingX, markdownTheme, startedAt) {
|
|
35
|
+
super(text, paddingX, 0, markdownTheme);
|
|
36
|
+
this.startedAt = startedAt;
|
|
37
|
+
}
|
|
38
|
+
invalidate() {
|
|
39
|
+
super.invalidate();
|
|
40
|
+
this.palette = theme.getFgGradient("thinkingText", "white", 32);
|
|
41
|
+
}
|
|
42
|
+
render(width) {
|
|
43
|
+
if (width <= 0)
|
|
44
|
+
return ["", ""];
|
|
45
|
+
const lines = this.markdown.render(width);
|
|
46
|
+
let latest = "";
|
|
47
|
+
for (let index = lines.length - 1; index >= 0; index--) {
|
|
48
|
+
latest = stripAnsi(lines[index]).trimEnd();
|
|
49
|
+
if (latest.trim())
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
const text = stripAnsi(truncateToWidth(latest, width, ""));
|
|
53
|
+
const length = visibleWidth(text);
|
|
54
|
+
const band = Math.max(6, Math.min(18, length * 0.3));
|
|
55
|
+
const progress = ((performance.now() - this.startedAt) % SHIMMER_PERIOD_MS) / SHIMMER_PERIOD_MS;
|
|
56
|
+
const center = -band + progress * (length + band * 2);
|
|
57
|
+
let column = 0;
|
|
58
|
+
let highlighted = "";
|
|
59
|
+
for (const { segment } of shimmerSegmenter.segment(text)) {
|
|
60
|
+
const cells = visibleWidth(segment);
|
|
61
|
+
const distance = Math.abs(column + cells / 2 - center) / band;
|
|
62
|
+
const intensity = distance >= 1 ? 0 : (1 + Math.cos(Math.PI * distance)) / 2;
|
|
63
|
+
highlighted += this.palette[Math.round(intensity * (this.palette.length - 1))] + segment;
|
|
64
|
+
column += cells;
|
|
65
|
+
}
|
|
66
|
+
return ["", `\x1b[3m${highlighted}\x1b[23m\x1b[39m`];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
27
69
|
//# sourceMappingURL=thinking-tail.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thinking-tail.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/thinking-tail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,QAAQ,EAAsB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"thinking-tail.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/thinking-tail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,QAAQ,EAAsB,eAAe,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACrH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C;;;;;;;GAOG;AAEH,iEAAiE;AACjE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAErC,MAAM,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,EAAE,IAAI,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1D,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;YACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,KAAK,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC;YAC9D,MAAM,SAAS,GAAG,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC;YAC7E,WAAW,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;YACzF,MAAM,IAAI,KAAK,CAAC;QACjB,CAAC;QACD,OAAO,CAAC,EAAE,EAAE,UAAU,WAAW,kBAAkB,CAAC,CAAC;IAAA,CACrD;CACD","sourcesContent":["import { type Component, Markdown, type MarkdownTheme, truncateToWidth, visibleWidth } from \"@ashx-j/lunr-tui\";\nimport { stripAnsi } from \"../../../utils/ansi.ts\";\nimport { theme } from \"../theme/theme.ts\";\n\n/**\n * lunr: rolling window for a still-streaming thinking run. Renders the full\n * Markdown block (same styling as the complete-run branch) but returns only\n * the last `maxLines` rendered lines, so at most N visual lines of reasoning\n * are on screen at a time and older lines disappear as new ones stream in.\n * Short tails are not padded to `maxLines`. The slot grows 1→4, then rolls.\n * Applied render-time only; the transcript is untouched.\n */\n\n/** Maximum rendered lines shown for a streaming thinking run. */\nexport const THINKING_TAIL_LINES = 4;\n\nexport class ThinkingTailComponent implements Component {\n\tprotected markdown: Markdown;\n\tprivate maxLines: number;\n\n\tconstructor(\n\t\ttext: string,\n\t\tpaddingX: number,\n\t\tpaddingY: number,\n\t\tmarkdownTheme: MarkdownTheme,\n\t\toptions?: { color?: (text: string) => string; italic?: boolean },\n\t\tmaxLines: number = THINKING_TAIL_LINES,\n\t) {\n\t\tthis.maxLines = maxLines;\n\t\tthis.markdown = new Markdown(text, paddingX, paddingY, markdownTheme, options);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.markdown.invalidate();\n\t}\n\n\trender(width: number): string[] {\n\t\tconst lines = this.markdown.render(width);\n\t\treturn lines.length <= this.maxLines ? lines : lines.slice(-this.maxLines);\n\t}\n}\n\nconst shimmerSegmenter = new Intl.Segmenter(undefined, { granularity: \"grapheme\" });\nconst SHIMMER_PERIOD_MS = 2800;\n\nexport class ThinkingLineComponent extends ThinkingTailComponent {\n\tprivate readonly startedAt: number;\n\tprivate palette = theme.getFgGradient(\"thinkingText\", \"white\", 32);\n\n\tconstructor(text: string, paddingX: number, markdownTheme: MarkdownTheme, startedAt: number) {\n\t\tsuper(text, paddingX, 0, markdownTheme);\n\t\tthis.startedAt = startedAt;\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.palette = theme.getFgGradient(\"thinkingText\", \"white\", 32);\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (width <= 0) return [\"\", \"\"];\n\t\tconst lines = this.markdown.render(width);\n\t\tlet latest = \"\";\n\t\tfor (let index = lines.length - 1; index >= 0; index--) {\n\t\t\tlatest = stripAnsi(lines[index]).trimEnd();\n\t\t\tif (latest.trim()) break;\n\t\t}\n\t\tconst text = stripAnsi(truncateToWidth(latest, width, \"\"));\n\t\tconst length = visibleWidth(text);\n\t\tconst band = Math.max(6, Math.min(18, length * 0.3));\n\t\tconst progress = ((performance.now() - this.startedAt) % SHIMMER_PERIOD_MS) / SHIMMER_PERIOD_MS;\n\t\tconst center = -band + progress * (length + band * 2);\n\t\tlet column = 0;\n\t\tlet highlighted = \"\";\n\t\tfor (const { segment } of shimmerSegmenter.segment(text)) {\n\t\t\tconst cells = visibleWidth(segment);\n\t\t\tconst distance = Math.abs(column + cells / 2 - center) / band;\n\t\t\tconst intensity = distance >= 1 ? 0 : (1 + Math.cos(Math.PI * distance)) / 2;\n\t\t\thighlighted += this.palette[Math.round(intensity * (this.palette.length - 1))] + segment;\n\t\t\tcolumn += cells;\n\t\t}\n\t\treturn [\"\", `\\x1b[3m${highlighted}\\x1b[23m\\x1b[39m`];\n\t}\n}\n"]}
|
|
@@ -32,7 +32,6 @@ export declare class ToolExecutionComponent extends Container {
|
|
|
32
32
|
private hideComponent;
|
|
33
33
|
private groupContinuation;
|
|
34
34
|
private groupFollowed;
|
|
35
|
-
private groupPrev?;
|
|
36
35
|
private groupNext?;
|
|
37
36
|
constructor(toolName: string, toolCallId: string, args: any, options: ToolExecutionOptions | undefined, toolDefinition: ToolDefinition<any, any> | undefined, ui: TUI, cwd: string);
|
|
38
37
|
private getCallRenderer;
|
|
@@ -41,6 +40,7 @@ export declare class ToolExecutionComponent extends Container {
|
|
|
41
40
|
private getRenderShell;
|
|
42
41
|
private getRenderContext;
|
|
43
42
|
private getStatusDot;
|
|
43
|
+
private getWaitDuration;
|
|
44
44
|
private createCallFallback;
|
|
45
45
|
private createResultFallback;
|
|
46
46
|
updateArgs(args: any): void;
|
|
@@ -59,14 +59,16 @@ export declare class ToolExecutionComponent extends Container {
|
|
|
59
59
|
private maybeConvertImagesForKitty;
|
|
60
60
|
setExpanded(expanded: boolean): void;
|
|
61
61
|
handleClick(_localY: number, _width: number): boolean;
|
|
62
|
+
beginNextExecution(toolCallId: string, args: any): void;
|
|
63
|
+
dispose(): void;
|
|
64
|
+
private disposeComponent;
|
|
62
65
|
getToolName(): string;
|
|
66
|
+
matchesToolCall(toolCallId: string): boolean;
|
|
63
67
|
setGroupContinuation(on: boolean): void;
|
|
64
68
|
setGroupFollowed(on: boolean): void;
|
|
65
69
|
linkGroupNext(next: ToolExecutionComponent): void;
|
|
66
70
|
private applyGroupPadding;
|
|
67
|
-
private shouldHideGroupedErrorBody;
|
|
68
71
|
private shouldSkipCompactResult;
|
|
69
|
-
private formatHoistedGroupErrors;
|
|
70
72
|
private refreshGroupTail;
|
|
71
73
|
setShowImages(show: boolean): void;
|
|
72
74
|
setImageWidthCells(width: number): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-execution.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,SAAS,EAAwC,KAAK,GAAG,EAAE,MAAM,wBAAwB,CAAC;AACxH,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,mCAAmC,CAAC;AAY3F,MAAM,WAAW,oBAAoB;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,sBAAuB,SAAQ,SAAS;IACpD,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,WAAW,CAAO;IAC1B,OAAO,CAAC,mBAAmB,CAAY;IAGvC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,qBAAqB,CAAC,CAAY;IAC1C,OAAO,CAAC,uBAAuB,CAAC,CAAY;IAC5C,OAAO,CAAC,aAAa,CAAW;IAChC,OAAO,CAAC,eAAe,CAAe;IACtC,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,IAAI,CAAM;IAClB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,cAAc,CAAC,CAA2B;IAClD,OAAO,CAAC,qBAAqB,CAAC,CAA2B;IACzD,OAAO,CAAC,EAAE,CAAM;IAChB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,YAAY,CAAS;I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MAAM,EAAE,MAAM,GAAG,OAAO,CAMpD;IAID,WAAW,IAAI,MAAM,CAEpB;IAKD,oBAAoB,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAKtC;IAID,gBAAgB,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAIlC;IAID,aAAa,CAAC,IAAI,EAAE,sBAAsB,GAAG,IAAI,CAGhD;IAED,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,0BAA0B;IAYlC,OAAO,CAAC,uBAAuB;IAqB/B,OAAO,CAAC,wBAAwB;IAchC,OAAO,CAAC,gBAAgB;IASxB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAGjC;IAED,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAGtC;IAEQ,UAAU,IAAI,IAAI,CAG1B;IAEQ,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAgCvC;IAED,OAAO,CAAC,aAAa;IA0HrB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,mBAAmB;CA0B3B;AAED,+EAA+E;AAC/E,wBAAgB,qBAAqB,CACpC,QAAQ,EAAE,sBAAsB,GAAG,SAAS,EAC5C,IAAI,EAAE,sBAAsB,GAC1B,IAAI,CAMN","sourcesContent":["import { Box, type Component, Container, getCapabilities, Image, Spacer, Text, type TUI } from \"@ashx-j/lunr-tui\";\nimport type { ToolDefinition, ToolRenderContext } from \"../../../core/extensions/types.ts\";\nimport { createAllToolDefinitions, type ToolName } from \"../../../core/tools/index.ts\";\nimport {\n\tformatGroupedCall,\n\tgetTextOutput as getRenderedTextOutput,\n\ttoolGroupRole,\n\ttoolGroupTree,\n\ttoolStatusDot,\n} from \"../../../core/tools/render-utils.ts\";\nimport { convertToPng } from \"../../../utils/image-convert.ts\";\nimport { theme } from \"../theme/theme.ts\";\n\nexport interface ToolExecutionOptions {\n\tshowImages?: boolean;\n\timageWidthCells?: number;\n}\n\nexport class ToolExecutionComponent extends Container {\n\tprivate contentBox: Box;\n\tprivate contentText: Text;\n\tprivate selfRenderContainer: Container;\n\t// lunr: top spacer kept as a field so consecutive same-tool calls can be\n\t// grouped into one continuous background by zeroing it (setGroupContinuation).\n\tprivate topSpacer: Spacer;\n\tprivate callRendererComponent?: Component;\n\tprivate resultRendererComponent?: Component;\n\tprivate rendererState: any = {};\n\tprivate imageComponents: Image[] = [];\n\tprivate imageSpacers: Spacer[] = [];\n\tprivate toolName: string;\n\tprivate toolCallId: string;\n\tprivate args: any;\n\tprivate expanded = false;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\tprivate isPartial = true;\n\tprivate toolDefinition?: ToolDefinition<any, any>;\n\tprivate builtInToolDefinition?: ToolDefinition<any, any>;\n\tprivate ui: TUI;\n\tprivate cwd: string;\n\tprivate executionStarted = false;\n\tprivate argsComplete = false;\n\tprivate result?: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tisError: boolean;\n\t\tdetails?: any;\n\t};\n\tprivate convertedImages: Map<number, { data: string; mimeType: string }> = new Map();\n\tprivate hideComponent = false;\n\tprivate groupContinuation = false;\n\tprivate groupFollowed = false;\n\tprivate groupPrev?: ToolExecutionComponent;\n\tprivate groupNext?: ToolExecutionComponent;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\toptions: ToolExecutionOptions = {},\n\t\ttoolDefinition: ToolDefinition<any, any> | undefined,\n\t\tui: TUI,\n\t\tcwd: string,\n\t) {\n\t\tsuper();\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.toolDefinition = toolDefinition;\n\t\tthis.builtInToolDefinition = createAllToolDefinitions(cwd)[toolName as ToolName];\n\t\tthis.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.ui = ui;\n\t\tthis.cwd = cwd;\n\n\t\tthis.topSpacer = new Spacer(1);\n\t\tthis.addChild(this.topSpacer);\n\n\t\t// Always create all shell variants. contentBox is used for default renderer-based composition.\n\t\t// selfRenderContainer is used when the tool renders its own framing.\n\t\t// contentText is reserved for generic fallback rendering when no tool definition exists.\n\t\t// lunr: default Box(1, 1). Same-name neighbors collapse facing pad only\n\t\t// (setGroupContinuation / setGroupFollowed); mixed and lone cards keep air.\n\t\tthis.contentBox = new Box(1, 1, (text: string) => theme.bg(\"toolPendingBg\", text));\n\t\tthis.contentText = new Text(\"\", 1, 1, (text: string) => theme.bg(\"toolPendingBg\", text));\n\t\tthis.selfRenderContainer = new Container();\n\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tthis.addChild(this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox);\n\t\t} else {\n\t\t\tthis.addChild(this.contentText);\n\t\t}\n\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate getCallRenderer(): ToolDefinition<any, any>[\"renderCall\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderCall;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderCall;\n\t\t}\n\t\treturn this.toolDefinition.renderCall ?? this.builtInToolDefinition.renderCall;\n\t}\n\n\tprivate getResultRenderer(): ToolDefinition<any, any>[\"renderResult\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderResult;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderResult;\n\t\t}\n\t\treturn this.toolDefinition.renderResult ?? this.builtInToolDefinition.renderResult;\n\t}\n\n\tprivate hasRendererDefinition(): boolean {\n\t\treturn this.builtInToolDefinition !== undefined || this.toolDefinition !== undefined;\n\t}\n\n\tprivate getRenderShell(): \"default\" | \"self\" {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderShell ?? \"default\";\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderShell ?? \"default\";\n\t\t}\n\t\treturn this.toolDefinition.renderShell ?? this.builtInToolDefinition.renderShell ?? \"default\";\n\t}\n\n\tprivate getRenderContext(lastComponent: Component | undefined): ToolRenderContext {\n\t\treturn {\n\t\t\targs: this.args,\n\t\t\ttoolCallId: this.toolCallId,\n\t\t\tinvalidate: () => {\n\t\t\t\tthis.invalidate();\n\t\t\t\tthis.ui.requestRender();\n\t\t\t},\n\t\t\trequestRender: () => {\n\t\t\t\tthis.ui.requestRender();\n\t\t\t},\n\t\t\tlastComponent,\n\t\t\tstate: this.rendererState,\n\t\t\tcwd: this.cwd,\n\t\t\texecutionStarted: this.executionStarted,\n\t\t\targsComplete: this.argsComplete,\n\t\t\tisPartial: this.isPartial,\n\t\t\texpanded: this.expanded,\n\t\t\tshowImages: this.showImages,\n\t\t\tisError: this.result?.isError ?? false,\n\t\t\tresult: this.result,\n\t\t\tgroupRole: toolGroupRole(this.groupContinuation, this.groupFollowed),\n\t\t};\n\t}\n\n\tprivate getStatusDot(): string {\n\t\tconst state = this.isPartial ? \"pending\" : this.result?.isError ? \"error\" : \"success\";\n\t\treturn toolStatusDot(state, theme);\n\t}\n\n\tprivate createCallFallback(): Component {\n\t\treturn new Text(\n\t\t\tformatGroupedCall({\n\t\t\t\trole: toolGroupRole(this.groupContinuation, this.groupFollowed),\n\t\t\t\tcompact: !this.isPartial && !this.expanded && !this.result?.isError,\n\t\t\t\ttree: toolGroupTree({ expanded: this.expanded, isError: this.result?.isError }),\n\t\t\t\tdot: this.getStatusDot(),\n\t\t\t\ttitle: theme.fg(\"toolTitle\", theme.bold(this.toolName)),\n\t\t\t}),\n\t\t\t0,\n\t\t\t0,\n\t\t);\n\t}\n\n\tprivate createResultFallback(): Component | undefined {\n\t\tconst output = this.getTextOutput();\n\t\tif (!output) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn new Text(theme.fg(\"toolOutput\", output), 0, 0);\n\t}\n\n\tupdateArgs(args: any): void {\n\t\tthis.args = args;\n\t\tthis.updateDisplay();\n\t}\n\n\tmarkExecutionStarted(): void {\n\t\tthis.executionStarted = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tsetArgsComplete(): void {\n\t\tthis.argsComplete = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tupdateResult(\n\t\tresult: {\n\t\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\t\tdetails?: any;\n\t\t\tisError: boolean;\n\t\t},\n\t\tisPartial = false,\n\t): void {\n\t\tthis.result = result;\n\t\tthis.isPartial = isPartial;\n\t\tthis.updateDisplay();\n\t\tthis.refreshGroupTail();\n\t\tthis.maybeConvertImagesForKitty();\n\t}\n\n\tprivate maybeConvertImagesForKitty(): void {\n\t\tconst caps = getCapabilities();\n\t\tif (caps.images !== \"kitty\") return;\n\t\tif (!this.result) return;\n\n\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\tconst img = imageBlocks[i];\n\t\t\tif (!img.data || !img.mimeType) continue;\n\t\t\tif (img.mimeType === \"image/png\") continue;\n\t\t\tif (this.convertedImages.has(i)) continue;\n\n\t\t\tconst index = i;\n\t\t\tconvertToPng(img.data, img.mimeType).then((converted) => {\n\t\t\t\tif (converted) {\n\t\t\t\t\tthis.convertedImages.set(index, converted);\n\t\t\t\t\tthis.updateDisplay();\n\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.updateDisplay();\n\t\tthis.refreshGroupTail();\n\t}\n\n\thandleClick(_localY: number, _width: number): boolean {\n\t\tif (this.isPartial) return false;\n\t\tif (this.toolName === \"subagent\" || this.toolName === \"subagent_wait\") return false;\n\t\tthis.setExpanded(!this.expanded);\n\t\tthis.ui.requestRender();\n\t\treturn true;\n\t}\n\n\t// lunr: consecutive same-tool grouping — exposes the tool name so the caller\n\t// can detect adjacency.\n\tgetToolName(): string {\n\t\treturn this.toolName;\n\t}\n\n\t// lunr: consecutive same-tool grouping — continuation calls hide the top\n\t// spacer and top box pad so adjacent same-bg boxes read as one continuous\n\t// background; the last card in a run keeps its bottom pad.\n\tsetGroupContinuation(on: boolean): void {\n\t\tthis.groupContinuation = on;\n\t\tthis.topSpacer.setLines(on ? 0 : 1);\n\t\tthis.applyGroupPadding();\n\t\tthis.invalidate();\n\t}\n\n\t// lunr: previous card in a same-name run drops its bottom pad so the next\n\t// header sits flush. Singletons and mixed neighbors keep paddingBottom = 1.\n\tsetGroupFollowed(on: boolean): void {\n\t\tthis.groupFollowed = on;\n\t\tthis.applyGroupPadding();\n\t\tthis.invalidate();\n\t}\n\n\t// lunr: same-name run link so a later card can hoist earlier error bodies\n\t// under the last leaf instead of splitting the tree.\n\tlinkGroupNext(next: ToolExecutionComponent): void {\n\t\tthis.groupNext = next;\n\t\tnext.groupPrev = this;\n\t}\n\n\tprivate applyGroupPadding(): void {\n\t\tconst top = this.groupContinuation ? 0 : 1;\n\t\tconst bottom = this.groupFollowed ? 0 : 1;\n\t\tthis.contentBox.setPaddingTop(top);\n\t\tthis.contentBox.setPaddingBottom(bottom);\n\t\tthis.contentText.setPaddingTop(top);\n\t\tthis.contentText.setPaddingBottom(bottom);\n\t\tif (this.getRenderShell() === \"self\" && this.callRendererComponent instanceof Box) {\n\t\t\tthis.callRendererComponent.setPaddingTop(top);\n\t\t\tthis.callRendererComponent.setPaddingBottom(bottom);\n\t\t}\n\t}\n\n\tprivate shouldHideGroupedErrorBody(): boolean {\n\t\treturn (\n\t\t\tBoolean(this.result?.isError) &&\n\t\t\tthis.groupFollowed &&\n\t\t\t!this.expanded &&\n\t\t\t!this.isPartial &&\n\t\t\tthis.getRenderShell() === \"default\" &&\n\t\t\tthis.toolName !== \"subagent\" &&\n\t\t\tthis.toolName !== \"subagent_wait\"\n\t\t);\n\t}\n\n\tprivate shouldSkipCompactResult(): boolean {\n\t\tif (this.result === undefined || this.isPartial || this.expanded) {\n\t\t\treturn false;\n\t\t}\n\t\t// lunr: collapsed finished subagent cards still show the compact row when a child\n\t\t// result exists. Async launch receipts (empty results) stay header-only.\n\t\tif (this.toolName === \"subagent\") {\n\t\t\tconst details = this.result.details as { mode?: string; results?: unknown[] } | undefined;\n\t\t\tif (this.result.isError) return false;\n\t\t\tif (Array.isArray(details?.results) && details.results.length > 0) return false;\n\t\t\tif (details?.mode === \"management\") return false;\n\t\t\treturn true;\n\t\t}\n\t\t// lunr: collapsed mid-group errors stay header-only so the same-name\n\t\t// tree is not split; the last card hoists those bodies underneath.\n\t\tif (this.result.isError) {\n\t\t\treturn this.shouldHideGroupedErrorBody();\n\t\t}\n\t\treturn this.getRenderShell() === \"default\";\n\t}\n\n\tprivate formatHoistedGroupErrors(): string | undefined {\n\t\tif (this.groupFollowed || this.expanded) return undefined;\n\t\tconst texts: string[] = [];\n\t\tlet prev = this.groupPrev;\n\t\twhile (prev) {\n\t\t\tif (prev.shouldHideGroupedErrorBody()) {\n\t\t\t\tconst output = prev.getTextOutput().trim();\n\t\t\t\tif (output) texts.unshift(output);\n\t\t\t}\n\t\t\tprev = prev.groupPrev;\n\t\t}\n\t\treturn texts.length > 0 ? `\\n${texts.join(\"\\n\")}` : undefined;\n\t}\n\n\tprivate refreshGroupTail(): void {\n\t\tlet next = this.groupNext;\n\t\twhile (next) {\n\t\t\tconst card = next;\n\t\t\tnext = next.groupNext;\n\t\t\tif (!next) card.updateDisplay();\n\t\t}\n\t}\n\n\tsetShowImages(show: boolean): void {\n\t\tthis.showImages = show;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetImageWidthCells(width: number): void {\n\t\tthis.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.updateDisplay();\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (this.hideComponent) {\n\t\t\treturn [];\n\t\t}\n\n\t\tif (this.hasRendererDefinition() && this.getRenderShell() === \"self\") {\n\t\t\tconst contentLines = this.selfRenderContainer.render(width);\n\t\t\tif (contentLines.length === 0 && this.imageComponents.length === 0) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tconst lines: string[] = [];\n\t\t\tif (contentLines.length > 0) {\n\t\t\t\tif (!this.groupContinuation) {\n\t\t\t\t\tlines.push(\"\");\n\t\t\t\t}\n\t\t\t\tlines.push(...contentLines);\n\t\t\t}\n\t\t\tfor (let i = 0; i < this.imageComponents.length; i++) {\n\t\t\t\tconst spacer = this.imageSpacers[i];\n\t\t\t\tif (spacer) {\n\t\t\t\t\tlines.push(...spacer.render(width));\n\t\t\t\t}\n\t\t\t\tconst imageComponent = this.imageComponents[i];\n\t\t\t\tif (imageComponent) {\n\t\t\t\t\tlines.push(...imageComponent.render(width));\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn lines;\n\t\t}\n\n\t\treturn super.render(width);\n\t}\n\n\tprivate updateDisplay(): void {\n\t\tconst bgFn = this.isPartial\n\t\t\t? (text: string) => theme.bg(\"toolPendingBg\", text)\n\t\t\t: this.result?.isError\n\t\t\t\t? (text: string) => theme.bg(\"toolErrorBg\", text)\n\t\t\t\t: (text: string) => theme.bg(\"toolSuccessBg\", text);\n\n\t\tlet hasContent = false;\n\t\tthis.hideComponent = false;\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tconst renderContainer = this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox;\n\t\t\tif (renderContainer instanceof Box) {\n\t\t\t\trenderContainer.setBgFn(bgFn);\n\t\t\t}\n\t\t\trenderContainer.clear();\n\n\t\t\tconst callRenderer = this.getCallRenderer();\n\t\t\tif (!callRenderer) {\n\t\t\t\trenderContainer.addChild(this.createCallFallback());\n\t\t\t\thasContent = true;\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tconst component = callRenderer(this.args, theme, this.getRenderContext(this.callRendererComponent));\n\t\t\t\t\tthis.callRendererComponent = component;\n\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\thasContent = true;\n\t\t\t\t} catch {\n\t\t\t\t\tthis.callRendererComponent = undefined;\n\t\t\t\t\trenderContainer.addChild(this.createCallFallback());\n\t\t\t\t\thasContent = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.result) {\n\t\t\t\tconst skipCompactBody = this.shouldSkipCompactResult();\n\t\t\t\tconst resultRenderer = this.getResultRenderer();\n\t\t\t\tif (!resultRenderer) {\n\t\t\t\t\tif (!skipCompactBody) {\n\t\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst component = resultRenderer(\n\t\t\t\t\t\t\t{ content: this.result.content as any, details: this.result.details },\n\t\t\t\t\t\t\t{ expanded: this.expanded, isPartial: this.isPartial },\n\t\t\t\t\t\t\ttheme,\n\t\t\t\t\t\t\tthis.getRenderContext(this.resultRendererComponent),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.resultRendererComponent = component;\n\t\t\t\t\t\tif (!skipCompactBody) {\n\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthis.resultRendererComponent = undefined;\n\t\t\t\t\t\tif (!skipCompactBody) {\n\t\t\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst hoisted = this.formatHoistedGroupErrors();\n\t\t\t\tif (hoisted) {\n\t\t\t\t\trenderContainer.addChild(new Text(theme.fg(\"toolOutput\", hoisted), 0, 0));\n\t\t\t\t\thasContent = true;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthis.contentText.setCustomBgFn(bgFn);\n\t\t\tthis.contentText.setText(this.formatToolExecution());\n\t\t\thasContent = true;\n\t\t}\n\n\t\tfor (const img of this.imageComponents) {\n\t\t\tthis.removeChild(img);\n\t\t}\n\t\tthis.imageComponents = [];\n\t\tfor (const spacer of this.imageSpacers) {\n\t\t\tthis.removeChild(spacer);\n\t\t}\n\t\tthis.imageSpacers = [];\n\n\t\tif (this.result) {\n\t\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\t\tconst caps = getCapabilities();\n\t\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\t\tconst img = imageBlocks[i];\n\t\t\t\tif (caps.images && this.showImages && img.data && img.mimeType) {\n\t\t\t\t\tconst converted = this.convertedImages.get(i);\n\t\t\t\t\tconst imageData = converted?.data ?? img.data;\n\t\t\t\t\tconst imageMimeType = converted?.mimeType ?? img.mimeType;\n\t\t\t\t\tif (caps.images === \"kitty\" && imageMimeType !== \"image/png\") continue;\n\n\t\t\t\t\tconst spacer = new Spacer(1);\n\t\t\t\t\tthis.addChild(spacer);\n\t\t\t\t\tthis.imageSpacers.push(spacer);\n\t\t\t\t\tconst imageComponent = new Image(\n\t\t\t\t\t\timageData,\n\t\t\t\t\t\timageMimeType,\n\t\t\t\t\t\t{ fallbackColor: (s: string) => theme.fg(\"toolOutput\", s) },\n\t\t\t\t\t\t{ maxWidthCells: this.imageWidthCells },\n\t\t\t\t\t);\n\t\t\t\t\tthis.imageComponents.push(imageComponent);\n\t\t\t\t\tthis.addChild(imageComponent);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (this.hasRendererDefinition() && !hasContent && this.imageComponents.length === 0) {\n\t\t\tthis.hideComponent = true;\n\t\t}\n\n\t\tthis.applyGroupPadding();\n\t}\n\n\tprivate getTextOutput(): string {\n\t\treturn getRenderedTextOutput(this.result, this.showImages);\n\t}\n\n\tprivate formatToolExecution(): string {\n\t\tconst hideGroupedErrorBody = Boolean(this.result?.isError && this.groupFollowed && !this.expanded);\n\t\tconst compact = !this.isPartial && !this.expanded && (!this.result?.isError || hideGroupedErrorBody);\n\t\tlet text = formatGroupedCall({\n\t\t\trole: toolGroupRole(this.groupContinuation, this.groupFollowed),\n\t\t\tcompact,\n\t\t\ttree: toolGroupTree({ expanded: this.expanded, isError: this.result?.isError }),\n\t\t\tdot: this.getStatusDot(),\n\t\t\ttitle: theme.fg(\"toolTitle\", theme.bold(this.toolName)),\n\t\t});\n\t\tif (!compact) {\n\t\t\tconst content = JSON.stringify(this.args, null, 2);\n\t\t\tif (content) {\n\t\t\t\ttext += `\\n\\n${content}`;\n\t\t\t}\n\t\t\tconst output = this.getTextOutput();\n\t\t\tif (output) {\n\t\t\t\ttext += `\\n${output}`;\n\t\t\t}\n\t\t}\n\t\tconst hoisted = this.formatHoistedGroupErrors();\n\t\tif (hoisted) {\n\t\t\ttext += hoisted;\n\t\t}\n\t\treturn text;\n\t}\n}\n\n/** Collapse facing pad when `next` is appended after a same-name tool card. */\nexport function applySameToolGrouping(\n\tprevious: ToolExecutionComponent | undefined,\n\tnext: ToolExecutionComponent,\n): void {\n\tif (previous && previous.getToolName() === next.getToolName()) {\n\t\tprevious.linkGroupNext(next);\n\t\tprevious.setGroupFollowed(true);\n\t\tnext.setGroupContinuation(true);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tool-execution.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,SAAS,EAAwC,KAAK,GAAG,EAAE,MAAM,wBAAwB,CAAC;AACxH,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,mCAAmC,CAAC;AAY3F,MAAM,WAAW,oB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,GAAG,IAAI,CAEhD;IAED,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,uBAAuB;IAmB/B,OAAO,CAAC,gBAAgB;IASxB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAGjC;IAED,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAGtC;IAEQ,UAAU,IAAI,IAAI,CAG1B;IAEQ,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAgCvC;IAED,OAAO,CAAC,aAAa;IAqHrB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,mBAAmB;CAuB3B;AAED,+EAA+E;AAC/E,wBAAgB,qBAAqB,CACpC,QAAQ,EAAE,sBAAsB,GAAG,SAAS,EAC5C,IAAI,EAAE,sBAAsB,GAC1B,IAAI,CAMN","sourcesContent":["import { Box, type Component, Container, getCapabilities, Image, Spacer, Text, type TUI } from \"@ashx-j/lunr-tui\";\nimport type { ToolDefinition, ToolRenderContext } from \"../../../core/extensions/types.ts\";\nimport { createAllToolDefinitions, type ToolName } from \"../../../core/tools/index.ts\";\nimport {\n\tformatGroupedCall,\n\tgetTextOutput as getRenderedTextOutput,\n\ttoolGroupRole,\n\ttoolGroupTree,\n\ttoolStatusDot,\n} from \"../../../core/tools/render-utils.ts\";\nimport { convertToPng } from \"../../../utils/image-convert.ts\";\nimport { theme } from \"../theme/theme.ts\";\n\nexport interface ToolExecutionOptions {\n\tshowImages?: boolean;\n\timageWidthCells?: number;\n}\n\nexport class ToolExecutionComponent extends Container {\n\tprivate contentBox: Box;\n\tprivate contentText: Text;\n\tprivate selfRenderContainer: Container;\n\t// lunr: top spacer kept as a field so consecutive same-tool calls can be\n\t// grouped into one continuous background by zeroing it (setGroupContinuation).\n\tprivate topSpacer: Spacer;\n\tprivate callRendererComponent?: Component;\n\tprivate resultRendererComponent?: Component;\n\tprivate rendererState: any = {};\n\tprivate imageComponents: Image[] = [];\n\tprivate imageSpacers: Spacer[] = [];\n\tprivate toolName: string;\n\tprivate toolCallId: string;\n\tprivate args: any;\n\tprivate expanded = false;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\tprivate isPartial = true;\n\tprivate toolDefinition?: ToolDefinition<any, any>;\n\tprivate builtInToolDefinition?: ToolDefinition<any, any>;\n\tprivate ui: TUI;\n\tprivate cwd: string;\n\tprivate executionStarted = false;\n\tprivate argsComplete = false;\n\tprivate result?: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tisError: boolean;\n\t\tdetails?: any;\n\t};\n\tprivate convertedImages: Map<number, { data: string; mimeType: string }> = new Map();\n\tprivate hideComponent = false;\n\tprivate groupContinuation = false;\n\tprivate groupFollowed = false;\n\tprivate groupNext?: ToolExecutionComponent;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\toptions: ToolExecutionOptions = {},\n\t\ttoolDefinition: ToolDefinition<any, any> | undefined,\n\t\tui: TUI,\n\t\tcwd: string,\n\t) {\n\t\tsuper();\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.toolDefinition = toolDefinition;\n\t\tthis.builtInToolDefinition = createAllToolDefinitions(cwd)[toolName as ToolName];\n\t\tthis.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.ui = ui;\n\t\tthis.cwd = cwd;\n\n\t\tthis.topSpacer = new Spacer(1);\n\t\tthis.addChild(this.topSpacer);\n\n\t\t// Always create all shell variants. contentBox is used for default renderer-based composition.\n\t\t// selfRenderContainer is used when the tool renders its own framing.\n\t\t// contentText is reserved for generic fallback rendering when no tool definition exists.\n\t\t// lunr: default Box(1, 1). Same-name neighbors collapse facing pad only\n\t\t// (setGroupContinuation / setGroupFollowed); mixed and lone cards keep air.\n\t\tthis.contentBox = new Box(1, 1, (text: string) => theme.bg(\"toolPendingBg\", text));\n\t\tthis.contentText = new Text(\"\", 1, 1, (text: string) => theme.bg(\"toolPendingBg\", text));\n\t\tthis.selfRenderContainer = new Container();\n\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tthis.addChild(this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox);\n\t\t} else {\n\t\t\tthis.addChild(this.contentText);\n\t\t}\n\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate getCallRenderer(): ToolDefinition<any, any>[\"renderCall\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderCall;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderCall;\n\t\t}\n\t\treturn this.toolDefinition.renderCall ?? this.builtInToolDefinition.renderCall;\n\t}\n\n\tprivate getResultRenderer(): ToolDefinition<any, any>[\"renderResult\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderResult;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderResult;\n\t\t}\n\t\treturn this.toolDefinition.renderResult ?? this.builtInToolDefinition.renderResult;\n\t}\n\n\tprivate hasRendererDefinition(): boolean {\n\t\treturn this.builtInToolDefinition !== undefined || this.toolDefinition !== undefined;\n\t}\n\n\tprivate getRenderShell(): \"default\" | \"self\" {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderShell ?? \"default\";\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderShell ?? \"default\";\n\t\t}\n\t\treturn this.toolDefinition.renderShell ?? this.builtInToolDefinition.renderShell ?? \"default\";\n\t}\n\n\tprivate getRenderContext(lastComponent: Component | undefined): ToolRenderContext {\n\t\treturn {\n\t\t\targs: this.args,\n\t\t\ttoolCallId: this.toolCallId,\n\t\t\tinvalidate: () => {\n\t\t\t\tthis.invalidate();\n\t\t\t\tthis.ui.requestRender();\n\t\t\t},\n\t\t\trequestRender: () => {\n\t\t\t\tthis.ui.requestRender();\n\t\t\t},\n\t\t\tlastComponent,\n\t\t\tstate: this.rendererState,\n\t\t\tcwd: this.cwd,\n\t\t\texecutionStarted: this.executionStarted,\n\t\t\targsComplete: this.argsComplete,\n\t\t\tisPartial: this.isPartial,\n\t\t\texpanded: this.expanded,\n\t\t\tshowImages: this.showImages,\n\t\t\tisError: this.result?.isError ?? false,\n\t\t\tresult: this.result,\n\t\t\tgroupRole: toolGroupRole(this.groupContinuation, this.groupFollowed),\n\t\t};\n\t}\n\n\tprivate getStatusDot(): string {\n\t\tconst state = this.isPartial ? \"pending\" : this.result?.isError ? \"error\" : \"success\";\n\t\treturn toolStatusDot(state, theme);\n\t}\n\n\tprivate getWaitDuration(): string | undefined {\n\t\tif (this.toolName !== \"subagent_wait\" || this.isPartial || this.expanded) return undefined;\n\t\tconst match = /^(?:Waited |Wait (?:timed out|aborted) after )(\\d+(?:ms|[smhd])(?:\\d+[smhd])*)\\b/.exec(\n\t\t\tthis.getTextOutput(),\n\t\t);\n\t\treturn match?.[1];\n\t}\n\n\tprivate createCallFallback(): Component {\n\t\tconst waitDuration = this.getWaitDuration();\n\t\treturn new Text(\n\t\t\tformatGroupedCall({\n\t\t\t\trole: toolGroupRole(this.groupContinuation, this.groupFollowed),\n\t\t\t\tcompact: !this.isPartial && !this.expanded && !this.result?.isError,\n\t\t\t\ttree: toolGroupTree({ expanded: this.expanded, isError: this.result?.isError }),\n\t\t\t\tdot: this.getStatusDot(),\n\t\t\t\ttitle: theme.fg(\"toolTitle\", theme.bold(this.toolName)),\n\t\t\t\tdetail: waitDuration && theme.fg(\"toolOutput\", waitDuration),\n\t\t\t}),\n\t\t\t0,\n\t\t\t0,\n\t\t);\n\t}\n\n\tprivate createResultFallback(): Component | undefined {\n\t\tconst output = this.getTextOutput();\n\t\tif (!output) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn new Text(theme.fg(\"toolOutput\", output), 0, 0);\n\t}\n\n\tupdateArgs(args: any): void {\n\t\tthis.args = args;\n\t\tthis.updateDisplay();\n\t}\n\n\tmarkExecutionStarted(): void {\n\t\tthis.executionStarted = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tsetArgsComplete(): void {\n\t\tthis.argsComplete = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tupdateResult(\n\t\tresult: {\n\t\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\t\tdetails?: any;\n\t\t\tisError: boolean;\n\t\t},\n\t\tisPartial = false,\n\t): void {\n\t\tthis.result = result;\n\t\tthis.isPartial = isPartial;\n\t\tthis.updateDisplay();\n\t\tthis.refreshGroupTail();\n\t\tthis.maybeConvertImagesForKitty();\n\t}\n\n\tprivate maybeConvertImagesForKitty(): void {\n\t\tconst caps = getCapabilities();\n\t\tif (caps.images !== \"kitty\") return;\n\t\tif (!this.result) return;\n\n\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\tconst img = imageBlocks[i];\n\t\t\tif (!img.data || !img.mimeType) continue;\n\t\t\tif (img.mimeType === \"image/png\") continue;\n\t\t\tif (this.convertedImages.has(i)) continue;\n\n\t\t\tconst index = i;\n\t\t\tconvertToPng(img.data, img.mimeType).then((converted) => {\n\t\t\t\tif (converted) {\n\t\t\t\t\tthis.convertedImages.set(index, converted);\n\t\t\t\t\tthis.updateDisplay();\n\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tif (this.toolName === \"browser\") return;\n\t\tthis.expanded = expanded;\n\t\tthis.updateDisplay();\n\t\tthis.refreshGroupTail();\n\t}\n\n\thandleClick(_localY: number, _width: number): boolean {\n\t\tif (this.isPartial) return false;\n\t\tif (this.toolName === \"browser\" || this.toolName === \"subagent\") return false;\n\t\tthis.setExpanded(!this.expanded);\n\t\tthis.ui.requestRender();\n\t\treturn true;\n\t}\n\n\tbeginNextExecution(toolCallId: string, args: any): void {\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.result = undefined;\n\t\tthis.isPartial = true;\n\t\tthis.executionStarted = false;\n\t\tthis.argsComplete = false;\n\t\tthis.expanded = false;\n\t\tthis.disposeComponent(this.resultRendererComponent);\n\t\tthis.resultRendererComponent = undefined;\n\t\tthis.updateDisplay();\n\t}\n\n\tdispose(): void {\n\t\tconst components = new Set([this.callRendererComponent, this.resultRendererComponent]);\n\t\tfor (const component of components) this.disposeComponent(component);\n\t}\n\n\tprivate disposeComponent(component: Component | undefined): void {\n\t\t(component as (Component & { dispose?: () => void }) | undefined)?.dispose?.();\n\t}\n\n\t// lunr: consecutive same-tool grouping — exposes the tool name so the caller\n\t// can detect adjacency.\n\tgetToolName(): string {\n\t\treturn this.toolName;\n\t}\n\n\tmatchesToolCall(toolCallId: string): boolean {\n\t\treturn this.toolCallId === toolCallId;\n\t}\n\n\t// lunr: consecutive same-tool grouping — continuation calls hide the top\n\t// spacer and top box pad so adjacent same-bg boxes read as one continuous\n\t// background; the last card in a run keeps its bottom pad.\n\tsetGroupContinuation(on: boolean): void {\n\t\tthis.groupContinuation = on;\n\t\tthis.topSpacer.setLines(on ? 0 : 1);\n\t\tthis.applyGroupPadding();\n\t\tthis.invalidate();\n\t}\n\n\t// lunr: previous card in a same-name run drops its bottom pad so the next\n\t// header sits flush. Singletons and mixed neighbors keep paddingBottom = 1.\n\tsetGroupFollowed(on: boolean): void {\n\t\tthis.groupFollowed = on;\n\t\tthis.applyGroupPadding();\n\t\tthis.invalidate();\n\t}\n\n\t// lunr: same-name run link keeps the final card refreshed as earlier calls settle.\n\tlinkGroupNext(next: ToolExecutionComponent): void {\n\t\tthis.groupNext = next;\n\t}\n\n\tprivate applyGroupPadding(): void {\n\t\tconst top = this.groupContinuation ? 0 : 1;\n\t\tconst bottom = this.groupFollowed ? 0 : 1;\n\t\tthis.contentBox.setPaddingTop(top);\n\t\tthis.contentBox.setPaddingBottom(bottom);\n\t\tthis.contentText.setPaddingTop(top);\n\t\tthis.contentText.setPaddingBottom(bottom);\n\t\tif (this.getRenderShell() === \"self\" && this.callRendererComponent instanceof Box) {\n\t\t\tthis.callRendererComponent.setPaddingTop(top);\n\t\t\tthis.callRendererComponent.setPaddingBottom(bottom);\n\t\t}\n\t}\n\n\tprivate shouldSkipCompactResult(): boolean {\n\t\tif (this.result === undefined || this.isPartial || this.expanded) {\n\t\t\treturn false;\n\t\t}\n\t\t// lunr: collapsed finished subagent cards still show the compact row when a child\n\t\t// result exists. Async launch receipts (empty results) stay header-only.\n\t\tif (this.toolName === \"subagent\") {\n\t\t\tconst details = this.result.details as { mode?: string; results?: unknown[] } | undefined;\n\t\t\tif (!this.result.isError && this.args?.action === \"steer\") return true;\n\t\t\tif (this.result.isError) return false;\n\t\t\tif (Array.isArray(details?.results) && details.results.length > 0) return false;\n\t\t\tif (details?.mode === \"management\") return false;\n\t\t\treturn true;\n\t\t}\n\t\tif (this.toolName === \"subagent_wait\") return true;\n\t\tif (this.result.isError) return true;\n\t\treturn this.getRenderShell() === \"default\";\n\t}\n\n\tprivate refreshGroupTail(): void {\n\t\tlet next = this.groupNext;\n\t\twhile (next) {\n\t\t\tconst card = next;\n\t\t\tnext = next.groupNext;\n\t\t\tif (!next) card.updateDisplay();\n\t\t}\n\t}\n\n\tsetShowImages(show: boolean): void {\n\t\tthis.showImages = show;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetImageWidthCells(width: number): void {\n\t\tthis.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.updateDisplay();\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (this.hideComponent) {\n\t\t\treturn [];\n\t\t}\n\n\t\tif (this.hasRendererDefinition() && this.getRenderShell() === \"self\") {\n\t\t\tconst contentLines = this.selfRenderContainer.render(width);\n\t\t\tif (contentLines.length === 0 && this.imageComponents.length === 0) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tconst lines: string[] = [];\n\t\t\tif (contentLines.length > 0) {\n\t\t\t\tif (!this.groupContinuation) {\n\t\t\t\t\tlines.push(\"\");\n\t\t\t\t}\n\t\t\t\tlines.push(...contentLines);\n\t\t\t}\n\t\t\tfor (let i = 0; i < this.imageComponents.length; i++) {\n\t\t\t\tconst spacer = this.imageSpacers[i];\n\t\t\t\tif (spacer) {\n\t\t\t\t\tlines.push(...spacer.render(width));\n\t\t\t\t}\n\t\t\t\tconst imageComponent = this.imageComponents[i];\n\t\t\t\tif (imageComponent) {\n\t\t\t\t\tlines.push(...imageComponent.render(width));\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn lines;\n\t\t}\n\n\t\treturn super.render(width);\n\t}\n\n\tprivate updateDisplay(): void {\n\t\tconst bgFn = this.isPartial\n\t\t\t? (text: string) => theme.bg(\"toolPendingBg\", text)\n\t\t\t: this.result?.isError\n\t\t\t\t? (text: string) => theme.bg(\"toolErrorBg\", text)\n\t\t\t\t: (text: string) => theme.bg(\"toolSuccessBg\", text);\n\n\t\tlet hasContent = false;\n\t\tthis.hideComponent = false;\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tconst renderContainer = this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox;\n\t\t\tif (renderContainer instanceof Box) {\n\t\t\t\trenderContainer.setBgFn(bgFn);\n\t\t\t}\n\t\t\trenderContainer.clear();\n\n\t\t\tconst callRenderer = this.getCallRenderer();\n\t\t\tif (!callRenderer) {\n\t\t\t\trenderContainer.addChild(this.createCallFallback());\n\t\t\t\thasContent = true;\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tconst component = callRenderer(this.args, theme, this.getRenderContext(this.callRendererComponent));\n\t\t\t\t\tthis.callRendererComponent = component;\n\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\thasContent = true;\n\t\t\t\t} catch {\n\t\t\t\t\tthis.callRendererComponent = undefined;\n\t\t\t\t\trenderContainer.addChild(this.createCallFallback());\n\t\t\t\t\thasContent = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.result) {\n\t\t\t\tconst skipCompactBody = this.shouldSkipCompactResult();\n\t\t\t\tconst resultRenderer = this.getResultRenderer();\n\t\t\t\tif (!resultRenderer) {\n\t\t\t\t\tif (!skipCompactBody) {\n\t\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst component = resultRenderer(\n\t\t\t\t\t\t\t{ content: this.result.content as any, details: this.result.details },\n\t\t\t\t\t\t\t{ expanded: this.expanded, isPartial: this.isPartial },\n\t\t\t\t\t\t\ttheme,\n\t\t\t\t\t\t\tthis.getRenderContext(this.resultRendererComponent),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.resultRendererComponent = component;\n\t\t\t\t\t\tif (!skipCompactBody) {\n\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthis.resultRendererComponent = undefined;\n\t\t\t\t\t\tif (!skipCompactBody) {\n\t\t\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthis.contentText.setCustomBgFn(bgFn);\n\t\t\tthis.contentText.setText(this.formatToolExecution());\n\t\t\thasContent = true;\n\t\t}\n\n\t\tfor (const img of this.imageComponents) {\n\t\t\tthis.removeChild(img);\n\t\t}\n\t\tthis.imageComponents = [];\n\t\tfor (const spacer of this.imageSpacers) {\n\t\t\tthis.removeChild(spacer);\n\t\t}\n\t\tthis.imageSpacers = [];\n\n\t\tif (this.result) {\n\t\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\t\tconst caps = getCapabilities();\n\t\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\t\tconst img = imageBlocks[i];\n\t\t\t\tif (caps.images && this.showImages && img.data && img.mimeType) {\n\t\t\t\t\tconst converted = this.convertedImages.get(i);\n\t\t\t\t\tconst imageData = converted?.data ?? img.data;\n\t\t\t\t\tconst imageMimeType = converted?.mimeType ?? img.mimeType;\n\t\t\t\t\tif (caps.images === \"kitty\" && imageMimeType !== \"image/png\") continue;\n\n\t\t\t\t\tconst spacer = new Spacer(1);\n\t\t\t\t\tthis.addChild(spacer);\n\t\t\t\t\tthis.imageSpacers.push(spacer);\n\t\t\t\t\tconst imageComponent = new Image(\n\t\t\t\t\t\timageData,\n\t\t\t\t\t\timageMimeType,\n\t\t\t\t\t\t{ fallbackColor: (s: string) => theme.fg(\"toolOutput\", s) },\n\t\t\t\t\t\t{ maxWidthCells: this.imageWidthCells },\n\t\t\t\t\t);\n\t\t\t\t\tthis.imageComponents.push(imageComponent);\n\t\t\t\t\tthis.addChild(imageComponent);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (this.hasRendererDefinition() && !hasContent && this.imageComponents.length === 0) {\n\t\t\tthis.hideComponent = true;\n\t\t}\n\n\t\tthis.applyGroupPadding();\n\t}\n\n\tprivate getTextOutput(): string {\n\t\treturn getRenderedTextOutput(this.result, this.showImages);\n\t}\n\n\tprivate formatToolExecution(): string {\n\t\tconst compact = !this.isPartial && !this.expanded;\n\t\tconst waitDuration = this.getWaitDuration();\n\t\tlet text = formatGroupedCall({\n\t\t\trole: toolGroupRole(this.groupContinuation, this.groupFollowed),\n\t\t\tcompact,\n\t\t\ttree: toolGroupTree({ expanded: this.expanded, isError: this.result?.isError }),\n\t\t\tdot: this.getStatusDot(),\n\t\t\ttitle: theme.fg(\"toolTitle\", theme.bold(this.toolName)),\n\t\t\tdetail: waitDuration && theme.fg(\"toolOutput\", waitDuration),\n\t\t});\n\t\tif (!compact) {\n\t\t\tconst content = JSON.stringify(this.args, null, 2);\n\t\t\tif (content) {\n\t\t\t\ttext += `\\n\\n${content}`;\n\t\t\t}\n\t\t\tconst output = this.getTextOutput();\n\t\t\tif (output) {\n\t\t\t\ttext += `\\n${output}`;\n\t\t\t}\n\t\t}\n\t\treturn text;\n\t}\n}\n\n/** Collapse facing pad when `next` is appended after a same-name tool card. */\nexport function applySameToolGrouping(\n\tprevious: ToolExecutionComponent | undefined,\n\tnext: ToolExecutionComponent,\n): void {\n\tif (previous && previous.getToolName() === next.getToolName()) {\n\t\tprevious.linkGroupNext(next);\n\t\tprevious.setGroupFollowed(true);\n\t\tnext.setGroupContinuation(true);\n\t}\n}\n"]}
|
|
@@ -33,7 +33,6 @@ export class ToolExecutionComponent extends Container {
|
|
|
33
33
|
hideComponent = false;
|
|
34
34
|
groupContinuation = false;
|
|
35
35
|
groupFollowed = false;
|
|
36
|
-
groupPrev;
|
|
37
36
|
groupNext;
|
|
38
37
|
constructor(toolName, toolCallId, args, options = {}, toolDefinition, ui, cwd) {
|
|
39
38
|
super();
|
|
@@ -122,13 +121,21 @@ export class ToolExecutionComponent extends Container {
|
|
|
122
121
|
const state = this.isPartial ? "pending" : this.result?.isError ? "error" : "success";
|
|
123
122
|
return toolStatusDot(state, theme);
|
|
124
123
|
}
|
|
124
|
+
getWaitDuration() {
|
|
125
|
+
if (this.toolName !== "subagent_wait" || this.isPartial || this.expanded)
|
|
126
|
+
return undefined;
|
|
127
|
+
const match = /^(?:Waited |Wait (?:timed out|aborted) after )(\d+(?:ms|[smhd])(?:\d+[smhd])*)\b/.exec(this.getTextOutput());
|
|
128
|
+
return match?.[1];
|
|
129
|
+
}
|
|
125
130
|
createCallFallback() {
|
|
131
|
+
const waitDuration = this.getWaitDuration();
|
|
126
132
|
return new Text(formatGroupedCall({
|
|
127
133
|
role: toolGroupRole(this.groupContinuation, this.groupFollowed),
|
|
128
134
|
compact: !this.isPartial && !this.expanded && !this.result?.isError,
|
|
129
135
|
tree: toolGroupTree({ expanded: this.expanded, isError: this.result?.isError }),
|
|
130
136
|
dot: this.getStatusDot(),
|
|
131
137
|
title: theme.fg("toolTitle", theme.bold(this.toolName)),
|
|
138
|
+
detail: waitDuration && theme.fg("toolOutput", waitDuration),
|
|
132
139
|
}), 0, 0);
|
|
133
140
|
}
|
|
134
141
|
createResultFallback() {
|
|
@@ -185,6 +192,8 @@ export class ToolExecutionComponent extends Container {
|
|
|
185
192
|
}
|
|
186
193
|
}
|
|
187
194
|
setExpanded(expanded) {
|
|
195
|
+
if (this.toolName === "browser")
|
|
196
|
+
return;
|
|
188
197
|
this.expanded = expanded;
|
|
189
198
|
this.updateDisplay();
|
|
190
199
|
this.refreshGroupTail();
|
|
@@ -192,17 +201,40 @@ export class ToolExecutionComponent extends Container {
|
|
|
192
201
|
handleClick(_localY, _width) {
|
|
193
202
|
if (this.isPartial)
|
|
194
203
|
return false;
|
|
195
|
-
if (this.toolName === "
|
|
204
|
+
if (this.toolName === "browser" || this.toolName === "subagent")
|
|
196
205
|
return false;
|
|
197
206
|
this.setExpanded(!this.expanded);
|
|
198
207
|
this.ui.requestRender();
|
|
199
208
|
return true;
|
|
200
209
|
}
|
|
210
|
+
beginNextExecution(toolCallId, args) {
|
|
211
|
+
this.toolCallId = toolCallId;
|
|
212
|
+
this.args = args;
|
|
213
|
+
this.result = undefined;
|
|
214
|
+
this.isPartial = true;
|
|
215
|
+
this.executionStarted = false;
|
|
216
|
+
this.argsComplete = false;
|
|
217
|
+
this.expanded = false;
|
|
218
|
+
this.disposeComponent(this.resultRendererComponent);
|
|
219
|
+
this.resultRendererComponent = undefined;
|
|
220
|
+
this.updateDisplay();
|
|
221
|
+
}
|
|
222
|
+
dispose() {
|
|
223
|
+
const components = new Set([this.callRendererComponent, this.resultRendererComponent]);
|
|
224
|
+
for (const component of components)
|
|
225
|
+
this.disposeComponent(component);
|
|
226
|
+
}
|
|
227
|
+
disposeComponent(component) {
|
|
228
|
+
component?.dispose?.();
|
|
229
|
+
}
|
|
201
230
|
// lunr: consecutive same-tool grouping — exposes the tool name so the caller
|
|
202
231
|
// can detect adjacency.
|
|
203
232
|
getToolName() {
|
|
204
233
|
return this.toolName;
|
|
205
234
|
}
|
|
235
|
+
matchesToolCall(toolCallId) {
|
|
236
|
+
return this.toolCallId === toolCallId;
|
|
237
|
+
}
|
|
206
238
|
// lunr: consecutive same-tool grouping — continuation calls hide the top
|
|
207
239
|
// spacer and top box pad so adjacent same-bg boxes read as one continuous
|
|
208
240
|
// background; the last card in a run keeps its bottom pad.
|
|
@@ -219,11 +251,9 @@ export class ToolExecutionComponent extends Container {
|
|
|
219
251
|
this.applyGroupPadding();
|
|
220
252
|
this.invalidate();
|
|
221
253
|
}
|
|
222
|
-
// lunr: same-name run link
|
|
223
|
-
// under the last leaf instead of splitting the tree.
|
|
254
|
+
// lunr: same-name run link keeps the final card refreshed as earlier calls settle.
|
|
224
255
|
linkGroupNext(next) {
|
|
225
256
|
this.groupNext = next;
|
|
226
|
-
next.groupPrev = this;
|
|
227
257
|
}
|
|
228
258
|
applyGroupPadding() {
|
|
229
259
|
const top = this.groupContinuation ? 0 : 1;
|
|
@@ -237,15 +267,6 @@ export class ToolExecutionComponent extends Container {
|
|
|
237
267
|
this.callRendererComponent.setPaddingBottom(bottom);
|
|
238
268
|
}
|
|
239
269
|
}
|
|
240
|
-
shouldHideGroupedErrorBody() {
|
|
241
|
-
return (Boolean(this.result?.isError) &&
|
|
242
|
-
this.groupFollowed &&
|
|
243
|
-
!this.expanded &&
|
|
244
|
-
!this.isPartial &&
|
|
245
|
-
this.getRenderShell() === "default" &&
|
|
246
|
-
this.toolName !== "subagent" &&
|
|
247
|
-
this.toolName !== "subagent_wait");
|
|
248
|
-
}
|
|
249
270
|
shouldSkipCompactResult() {
|
|
250
271
|
if (this.result === undefined || this.isPartial || this.expanded) {
|
|
251
272
|
return false;
|
|
@@ -254,6 +275,8 @@ export class ToolExecutionComponent extends Container {
|
|
|
254
275
|
// result exists. Async launch receipts (empty results) stay header-only.
|
|
255
276
|
if (this.toolName === "subagent") {
|
|
256
277
|
const details = this.result.details;
|
|
278
|
+
if (!this.result.isError && this.args?.action === "steer")
|
|
279
|
+
return true;
|
|
257
280
|
if (this.result.isError)
|
|
258
281
|
return false;
|
|
259
282
|
if (Array.isArray(details?.results) && details.results.length > 0)
|
|
@@ -262,28 +285,12 @@ export class ToolExecutionComponent extends Container {
|
|
|
262
285
|
return false;
|
|
263
286
|
return true;
|
|
264
287
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
if (this.result.isError)
|
|
268
|
-
return
|
|
269
|
-
}
|
|
288
|
+
if (this.toolName === "subagent_wait")
|
|
289
|
+
return true;
|
|
290
|
+
if (this.result.isError)
|
|
291
|
+
return true;
|
|
270
292
|
return this.getRenderShell() === "default";
|
|
271
293
|
}
|
|
272
|
-
formatHoistedGroupErrors() {
|
|
273
|
-
if (this.groupFollowed || this.expanded)
|
|
274
|
-
return undefined;
|
|
275
|
-
const texts = [];
|
|
276
|
-
let prev = this.groupPrev;
|
|
277
|
-
while (prev) {
|
|
278
|
-
if (prev.shouldHideGroupedErrorBody()) {
|
|
279
|
-
const output = prev.getTextOutput().trim();
|
|
280
|
-
if (output)
|
|
281
|
-
texts.unshift(output);
|
|
282
|
-
}
|
|
283
|
-
prev = prev.groupPrev;
|
|
284
|
-
}
|
|
285
|
-
return texts.length > 0 ? `\n${texts.join("\n")}` : undefined;
|
|
286
|
-
}
|
|
287
294
|
refreshGroupTail() {
|
|
288
295
|
let next = this.groupNext;
|
|
289
296
|
while (next) {
|
|
@@ -399,11 +406,6 @@ export class ToolExecutionComponent extends Container {
|
|
|
399
406
|
}
|
|
400
407
|
}
|
|
401
408
|
}
|
|
402
|
-
const hoisted = this.formatHoistedGroupErrors();
|
|
403
|
-
if (hoisted) {
|
|
404
|
-
renderContainer.addChild(new Text(theme.fg("toolOutput", hoisted), 0, 0));
|
|
405
|
-
hasContent = true;
|
|
406
|
-
}
|
|
407
409
|
}
|
|
408
410
|
}
|
|
409
411
|
else {
|
|
@@ -448,14 +450,15 @@ export class ToolExecutionComponent extends Container {
|
|
|
448
450
|
return getRenderedTextOutput(this.result, this.showImages);
|
|
449
451
|
}
|
|
450
452
|
formatToolExecution() {
|
|
451
|
-
const
|
|
452
|
-
const
|
|
453
|
+
const compact = !this.isPartial && !this.expanded;
|
|
454
|
+
const waitDuration = this.getWaitDuration();
|
|
453
455
|
let text = formatGroupedCall({
|
|
454
456
|
role: toolGroupRole(this.groupContinuation, this.groupFollowed),
|
|
455
457
|
compact,
|
|
456
458
|
tree: toolGroupTree({ expanded: this.expanded, isError: this.result?.isError }),
|
|
457
459
|
dot: this.getStatusDot(),
|
|
458
460
|
title: theme.fg("toolTitle", theme.bold(this.toolName)),
|
|
461
|
+
detail: waitDuration && theme.fg("toolOutput", waitDuration),
|
|
459
462
|
});
|
|
460
463
|
if (!compact) {
|
|
461
464
|
const content = JSON.stringify(this.args, null, 2);
|
|
@@ -467,10 +470,6 @@ export class ToolExecutionComponent extends Container {
|
|
|
467
470
|
text += `\n${output}`;
|
|
468
471
|
}
|
|
469
472
|
}
|
|
470
|
-
const hoisted = this.formatHoistedGroupErrors();
|
|
471
|
-
if (hoisted) {
|
|
472
|
-
text += hoisted;
|
|
473
|
-
}
|
|
474
473
|
return text;
|
|
475
474
|
}
|
|
476
475
|
}
|