@celljs/ta 4.9.0 → 4.10.0
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/dist/cli.mjs +69 -15
- package/dist/gateway.mjs +170 -28
- package/dist/pi/CHANGELOG.md +11 -0
- package/dist/pi/dist/bundle/chunks/anthropic-messages-CA3HHOL3.js +6 -0
- package/dist/pi/dist/bundle/chunks/{azure-openai-responses-FSC6BAW3.js → azure-openai-responses-76TWS6DT.js} +1 -1
- package/dist/pi/dist/bundle/chunks/bedrock-converse-stream.js +3 -3
- package/dist/pi/dist/bundle/chunks/chunk-4KSTFUIK.js +19 -0
- package/dist/pi/dist/bundle/chunks/chunk-4UNPP53I.js +55 -0
- package/dist/pi/dist/bundle/chunks/chunk-AUUCDC7R.js +4 -0
- package/dist/pi/dist/bundle/chunks/{chunk-V6KH5QG4.js → chunk-BAC3QPNW.js} +1 -1
- package/dist/pi/dist/bundle/chunks/{chunk-4EYXVSA5.js → chunk-FF6XOTWB.js} +9 -9
- package/dist/pi/dist/bundle/chunks/chunk-FMPAMX2W.js +82 -0
- package/dist/pi/dist/bundle/chunks/chunk-GFUN2N5K.js +2 -0
- package/dist/pi/dist/bundle/chunks/chunk-IEBK4HQA.js +2 -0
- package/dist/pi/dist/bundle/chunks/{chunk-C2WU32PX.js → chunk-IQUU5XIT.js} +1 -1
- package/dist/pi/dist/bundle/chunks/{chunk-EBFHJFEE.js → chunk-LQLJ7CDW.js} +1 -1
- package/dist/pi/dist/bundle/chunks/chunk-MMDXLZVS.js +30 -0
- package/dist/pi/dist/bundle/chunks/{chunk-GN3QYODH.js → chunk-QN4TOIZN.js} +1 -1
- package/dist/pi/dist/bundle/chunks/chunk-RKNK4Y6L.js +2 -0
- package/dist/pi/dist/bundle/chunks/{chunk-B46VJEHW.js → chunk-V7SLUK6A.js} +1 -1
- package/dist/pi/dist/bundle/chunks/chunk-VEJDBY3O.js +1237 -0
- package/dist/pi/dist/bundle/chunks/chunk-VKJQ6CME.js +8 -0
- package/dist/pi/dist/bundle/chunks/{chunk-3TGLJEWK.js → chunk-WL4TUXY7.js} +1 -1
- package/dist/pi/dist/bundle/chunks/{chunk-YZKQS34S.js → chunk-Y55SJART.js} +5 -1
- package/dist/pi/dist/bundle/chunks/{chunk-EOO47QGR.js → chunk-ZBIZYD6W.js} +1 -1
- package/dist/pi/dist/bundle/chunks/chunk-ZG74NES2.js +2 -0
- package/dist/pi/dist/bundle/chunks/chunk-ZGYS4UTC.js +2 -0
- package/dist/pi/dist/bundle/chunks/{cli-MCOUW5WS.js → cli-7RHMDOHL.js} +7 -7
- package/dist/pi/dist/bundle/chunks/{cloudflare-workers-ai-system-one-WLAFJSP6.js → cloudflare-workers-ai-system-one-U4J7D646.js} +1 -1
- package/dist/pi/dist/bundle/chunks/codemode-worker.js +2 -0
- package/dist/pi/dist/bundle/chunks/{easter-egg-3d-WMBNSJ4M.js → easter-egg-3d-GEVPKQF6.js} +1 -1
- package/dist/pi/dist/bundle/chunks/{execute-4CEBORGZ.js → execute-L2EEDV3L.js} +5 -3
- package/dist/pi/dist/bundle/chunks/github-copilot.js +1 -1
- package/dist/pi/dist/bundle/chunks/{google-generative-ai-INGKNW72.js → google-generative-ai-D5B6W47J.js} +1 -1
- package/dist/pi/dist/bundle/chunks/{google-vertex-IBTX6MBF.js → google-vertex-U4H5YDEW.js} +1 -1
- package/dist/pi/dist/bundle/chunks/{llama-cpp-classify-V5U3QKXI.js → llama-cpp-classify-EJXCQRUQ.js} +1 -1
- package/dist/pi/dist/bundle/chunks/{mistral-conversations-S4OWXIXQ.js → mistral-conversations-S277EKLB.js} +1 -1
- package/dist/pi/dist/bundle/chunks/openai-codex-responses-TEQRB65N.js +10 -0
- package/dist/pi/dist/bundle/chunks/{openai-completions-EJNYB6IX.js → openai-completions-HRZOSLBO.js} +3 -3
- package/dist/pi/dist/bundle/chunks/{openai-decisions-IXI34BYG.js → openai-decisions-F66BDLOM.js} +1 -1
- package/dist/pi/dist/bundle/chunks/openai-responses-BAKFWTGE.js +4 -0
- package/dist/pi/dist/bundle/chunks/{openrouter-images-PISKSFMS.js → openrouter-images-VXF5TVIK.js} +1 -1
- package/dist/pi/dist/bundle/chunks/{pi-messages-NORUKF4E.js → pi-messages-UBJKNDRN.js} +1 -1
- package/dist/pi/dist/bundle/chunks/{runtime-FQB7RU7U.js → runtime-J5ZSBGTX.js} +1 -1
- package/dist/pi/dist/bundle/chunks/{typesafe-system-one-CHVC2UUI.js → typesafe-system-one-56TEMIHL.js} +1 -1
- package/dist/pi/dist/bundle/chunks/virtual-modules-KITQRTYM.js +2 -0
- package/dist/pi/dist/bundle/cli-runtime.js +1 -1
- package/dist/pi/dist/bundle/index.js +1 -1
- package/dist/pi/dist/bundle/rpc-entry.js +1 -1
- package/dist/pi/docs/cli.md +14 -1
- package/dist/pi/docs/extensions.md +27 -7
- package/dist/pi/docs/keybindings.md +1 -1
- package/dist/pi/docs/llama-cpp.md +5 -8
- package/dist/pi/docs/models-configuration.md +6 -1
- package/dist/pi/docs/models.md +2 -1
- package/dist/pi/docs/prompt-templates.md +1 -1
- package/dist/pi/docs/providers.md +1 -1
- package/dist/pi/docs/rpc.md +4 -2
- package/dist/pi/docs/sessions.md +7 -1
- package/dist/pi/docs/settings.md +1 -1
- package/dist/pi/docs/tui.md +1 -1
- package/dist/pi/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/dist/pi/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/dist/pi/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/dist/pi/examples/extensions/gondolin/package-lock.json +2 -2
- package/dist/pi/examples/extensions/gondolin/package.json +1 -1
- package/dist/pi/examples/extensions/plan-mode/index.ts +23 -13
- package/dist/pi/examples/extensions/plan-mode/utils.ts +42 -16
- package/dist/pi/examples/extensions/subagent/README.md +14 -11
- package/dist/pi/examples/extensions/subagent/index.ts +392 -171
- package/dist/pi/examples/extensions/with-deps/package-lock.json +2 -2
- package/dist/pi/examples/extensions/with-deps/package.json +1 -1
- package/dist/pi/examples/tsconfig.json +63 -35
- package/dist/pi/package.json +1 -1
- package/dist/pi/packages/ta-agents/README.en.md +2 -2
- package/dist/pi/packages/ta-agents/README.md +2 -2
- package/dist/pi/packages/ta-agents/extension/index.mjs +69 -13
- package/dist/pi/packages/ta-agents/lib/agent-bindings.d.ts +19 -4
- package/dist/pi/packages/ta-agents/lib/agent-bindings.js +43 -9
- package/dist/pi/packages/ta-agents/lib/agent-catalog.d.ts +2 -0
- package/dist/pi/packages/ta-agents/lib/agent-catalog.js +3 -0
- package/dist/pi/packages/ta-agents/lib/extension.d.ts +2 -1
- package/dist/pi/packages/ta-agents/lib/extension.js +26 -4
- package/dist/pi/packages/ta-agents/lib/json-rpc.js +7 -1
- package/dist/pi/packages/ta-agents/lib/texts.d.ts +4 -0
- package/dist/pi/packages/ta-agents/lib/texts.js +4 -0
- package/dist/pi/packages/ta-agents/package.json +3 -3
- package/dist/pi/packages/ta-bots/extension/index.mjs +46 -0
- package/dist/pi/packages/ta-bots/host/index.mjs +46 -0
- package/dist/pi/packages/ta-bots/package.json +1 -1
- package/dist/pi/packages/ta-changes/package.json +1 -1
- package/dist/pi/packages/ta-channels/README.en.md +2 -2
- package/dist/pi/packages/ta-channels/README.md +2 -2
- package/dist/pi/packages/ta-channels/host/index.mjs +50 -0
- package/dist/pi/packages/ta-channels/lib/create.js +11 -3
- package/dist/pi/packages/ta-channels/lib/faces.js +1 -1
- package/dist/pi/packages/ta-channels/lib/i18n.d.ts +6 -9
- package/dist/pi/packages/ta-channels/lib/i18n.js +12 -18
- package/dist/pi/packages/ta-channels/lib/more-menu.d.ts +3 -2
- package/dist/pi/packages/ta-channels/lib/more-menu.js +21 -29
- package/dist/pi/packages/ta-channels/lib/room.js +13 -8
- package/dist/pi/packages/ta-channels/lib/sidebar.js +241 -79
- package/dist/pi/packages/ta-channels/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-channels/lib/style.js +83 -37
- package/dist/pi/packages/ta-channels/lib/tasks.d.ts +2 -0
- package/dist/pi/packages/ta-channels/lib/tasks.js +22 -12
- package/dist/pi/packages/ta-channels/lib/views.d.ts +49 -1
- package/dist/pi/packages/ta-channels/lib/views.js +100 -1
- package/dist/pi/packages/ta-channels/package.json +1 -1
- package/dist/pi/packages/ta-channels/web/index.js +482 -259
- package/dist/pi/packages/ta-computer-use/package.json +2 -2
- package/dist/pi/packages/ta-cron/README.en.md +2 -2
- package/dist/pi/packages/ta-cron/README.md +2 -2
- package/dist/pi/packages/ta-cron/host/index.mjs +6 -0
- package/dist/pi/packages/ta-cron/lib/editor.js +60 -27
- package/dist/pi/packages/ta-cron/lib/i18n.d.ts +12 -1
- package/dist/pi/packages/ta-cron/lib/i18n.js +24 -2
- package/dist/pi/packages/ta-cron/lib/page.d.ts +33 -3
- package/dist/pi/packages/ta-cron/lib/page.js +119 -4
- package/dist/pi/packages/ta-cron/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-cron/lib/style.js +166 -46
- package/dist/pi/packages/ta-cron/lib/task-extension.d.ts +15 -0
- package/dist/pi/packages/ta-cron/lib/task-extension.js +56 -0
- package/dist/pi/packages/ta-cron/lib/task-util.d.ts +2 -0
- package/dist/pi/packages/ta-cron/lib/task-util.js +11 -0
- package/dist/pi/packages/ta-cron/lib/tasks-view.d.ts +4 -1
- package/dist/pi/packages/ta-cron/lib/tasks-view.js +102 -66
- package/dist/pi/packages/ta-cron/package.json +1 -1
- package/dist/pi/packages/ta-cron/web/index.js +928 -404
- package/dist/pi/packages/ta-extensions/README.en.md +3 -1
- package/dist/pi/packages/ta-extensions/README.md +3 -1
- package/dist/pi/packages/ta-extensions/lib/actions.js +3 -1
- package/dist/pi/packages/ta-extensions/lib/composer.d.ts +17 -0
- package/dist/pi/packages/ta-extensions/lib/composer.js +84 -0
- package/dist/pi/packages/ta-extensions/lib/i18n.d.ts +9 -0
- package/dist/pi/packages/ta-extensions/lib/i18n.js +18 -0
- package/dist/pi/packages/ta-extensions/lib/index.js +4 -0
- package/dist/pi/packages/ta-extensions/lib/make-model.d.ts +20 -0
- package/dist/pi/packages/ta-extensions/lib/make-model.js +43 -0
- package/dist/pi/packages/ta-extensions/lib/page.js +42 -18
- package/dist/pi/packages/ta-extensions/lib/settings.d.ts +4 -0
- package/dist/pi/packages/ta-extensions/lib/settings.js +44 -0
- package/dist/pi/packages/ta-extensions/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-extensions/lib/style.js +10 -4
- package/dist/pi/packages/ta-extensions/package.json +1 -1
- package/dist/pi/packages/ta-extensions/skills/ta-package/SKILL.md +7 -3
- package/dist/pi/packages/ta-extensions/web/index.js +269 -26
- package/dist/pi/packages/ta-launcher/package.json +1 -1
- package/dist/pi/packages/ta-workspace/README.md +1 -1
- package/dist/pi/packages/ta-workspace/README.zh-cn.md +1 -1
- package/dist/pi/packages/ta-workspace/lib/bytes.d.ts +11 -0
- package/dist/pi/packages/ta-workspace/lib/bytes.js +40 -0
- package/dist/pi/packages/ta-workspace/lib/common.d.ts +2 -1
- package/dist/pi/packages/ta-workspace/lib/common.js +15 -37
- package/dist/pi/packages/ta-workspace/lib/editors.js +12 -3
- package/dist/pi/packages/ta-workspace/lib/i18n.d.ts +1 -2
- package/dist/pi/packages/ta-workspace/lib/i18n.js +2 -4
- package/dist/pi/packages/ta-workspace/lib/index.js +17 -1
- package/dist/pi/packages/ta-workspace/lib/launcher.d.ts +9 -0
- package/dist/pi/packages/ta-workspace/lib/launcher.js +39 -0
- package/dist/pi/packages/ta-workspace/lib/preview.d.ts +13 -3
- package/dist/pi/packages/ta-workspace/lib/preview.js +17 -14
- package/dist/pi/packages/ta-workspace/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-workspace/lib/style.js +20 -7
- package/dist/pi/packages/ta-workspace/lib/terminal-sessions.d.ts +51 -0
- package/dist/pi/packages/ta-workspace/lib/terminal-sessions.js +226 -0
- package/dist/pi/packages/ta-workspace/lib/terminal.d.ts +0 -39
- package/dist/pi/packages/ta-workspace/lib/terminal.js +28 -240
- package/dist/pi/packages/ta-workspace/lib/util/keys.d.ts +18 -0
- package/dist/pi/packages/ta-workspace/lib/util/keys.js +23 -0
- package/dist/pi/packages/ta-workspace/lib/util/preview.d.ts +19 -0
- package/dist/pi/packages/ta-workspace/lib/util/preview.js +32 -1
- package/dist/pi/packages/ta-workspace/package.json +1 -1
- package/dist/pi/packages/ta-workspace/web/index.js +238 -68
- package/dist/public/assets/{abnfDiagram-S7VZAUFO-C1tb6dM5.js → abnfDiagram-S7VZAUFO-BmIko5tV.js} +1 -1
- package/dist/public/assets/{architecture-WOLXFQ4H-DN1Va8BF.js → architecture-WOLXFQ4H-XgsdQ7ul.js} +1 -1
- package/dist/public/assets/{architectureDiagram-YGSQEFNW-BmK2SYtQ.js → architectureDiagram-YGSQEFNW--sVhMS03.js} +1 -1
- package/dist/public/assets/{blockDiagram-APKKGZFW-DvLrLzTm.js → blockDiagram-APKKGZFW-8f9b-9k2.js} +1 -1
- package/dist/public/assets/browser-DOHZ0JCf.js +12 -0
- package/dist/public/assets/{c4Diagram-KJ2TOQU5-CrQlWwrG.js → c4Diagram-KJ2TOQU5-CwYQ0Jfy.js} +1 -1
- package/dist/public/assets/{chunk-6MUBBAK2-CHKMsuY_.js → chunk-6MUBBAK2-7Y9ezehi.js} +1 -1
- package/dist/public/assets/{chunk-AXFCVDMN-CWJ7Np6s.js → chunk-AXFCVDMN-CZIH4pWz.js} +1 -1
- package/dist/public/assets/{chunk-BG4553SI-3v5XbQGM.js → chunk-BG4553SI-DsNATY2m.js} +1 -1
- package/dist/public/assets/{chunk-DQASFODM-2CC-yiCz.js → chunk-DQASFODM-CoXkfYE-.js} +1 -1
- package/dist/public/assets/{chunk-HFQBQIA3-D2hzQPAy.js → chunk-HFQBQIA3-C5OLqki8.js} +1 -1
- package/dist/public/assets/{chunk-KQLB2F66-SifAZs2r.js → chunk-KQLB2F66-DMHuYGEF.js} +1 -1
- package/dist/public/assets/{chunk-KS47KZWR-BP0C0VCC.js → chunk-KS47KZWR-BKeOttO1.js} +1 -1
- package/dist/public/assets/{chunk-LEVMRMFU-B1f5vw5b.js → chunk-LEVMRMFU-D6zCwkk7.js} +1 -1
- package/dist/public/assets/{chunk-M57EVK23-B2MCJt7Y.js → chunk-M57EVK23-B5-QqcZg.js} +1 -1
- package/dist/public/assets/{chunk-OY52VR5R-cDpZJMk4.js → chunk-OY52VR5R-DQrq3n0T.js} +1 -1
- package/dist/public/assets/{chunk-QB3YPZ4I-BE0we2xc.js → chunk-QB3YPZ4I-j6ZT7EDR.js} +1 -1
- package/dist/public/assets/{chunk-R3KSYZAL-D9wOfqqH.js → chunk-R3KSYZAL-D5MXUO36.js} +1 -1
- package/dist/public/assets/{chunk-STOXU5M4-BIaVsc0K.js → chunk-STOXU5M4-DaBkw4dD.js} +1 -1
- package/dist/public/assets/{chunk-TU62E6Q5-BZc0OZEM.js → chunk-TU62E6Q5-vXcRfGci.js} +1 -1
- package/dist/public/assets/{chunk-X4PVCEUW-Bngfwwzm.js → chunk-X4PVCEUW-CIh6H4Y2.js} +1 -1
- package/dist/public/assets/{chunk-XXDRQBXY-C5FQ6XHK.js → chunk-XXDRQBXY-C_Vwv1FM.js} +1 -1
- package/dist/public/assets/{classDiagram-v2-L25IHNXF-_om54nmt.js → classDiagram-v2-L25IHNXF-DccDWEJn.js} +1 -1
- package/dist/public/assets/{cose-bilkent-JH36ORCC-Dwpeee_6.js → cose-bilkent-JH36ORCC-BX47lumZ.js} +1 -1
- package/dist/public/assets/cynefin-EF2NZ3EQ-MaI-3dMQ.js +1 -0
- package/dist/public/assets/{cynefinDiagram-L36ESFBY-DP5_y9Dq.js → cynefinDiagram-L36ESFBY-BE6WOGxW.js} +1 -1
- package/dist/public/assets/{d3-selection-DFiMlEmn.js → d3-selection-ZcE6yRN5.js} +1 -1
- package/dist/public/assets/{dagre-SPEB5RXH-DYwsk6gk.js → dagre-SPEB5RXH-CE6SOOcN.js} +1 -1
- package/dist/public/assets/{diagram-3B7GL73J-Dq_nT3AZ.js → diagram-3B7GL73J-xC8VtiYL.js} +1 -1
- package/dist/public/assets/{diagram-DNEMPZML-ChURW6y9.js → diagram-DNEMPZML-4dmcBbjL.js} +1 -1
- package/dist/public/assets/{diagram-L3MUGCDN-CgVp4Rto.js → diagram-L3MUGCDN-D14Yn3sQ.js} +1 -1
- package/dist/public/assets/{diagram-LA4NIPWU-vrqLMDby.js → diagram-LA4NIPWU-GxSXIhsK.js} +1 -1
- package/dist/public/assets/{diagram-MHCOC4E2-lvfOr5ij.js → diagram-MHCOC4E2-Cm7Prlpc.js} +1 -1
- package/dist/public/assets/{diagram-XPFHEONP-oQ18TeVp.js → diagram-XPFHEONP-mkUnnKFu.js} +1 -1
- package/dist/public/assets/{dist-BOxxmveI.js → dist-acJS-BlA.js} +1 -1
- package/dist/public/assets/{ebnfDiagram-UZSYDL2S-C7_tlZCS.js → ebnfDiagram-UZSYDL2S-m77ua3UQ.js} +1 -1
- package/dist/public/assets/{editor.api-CoZ8MEuz.js → editor.api-CljTm-EQ.js} +1 -1
- package/dist/public/assets/{elk-XV6XMXQE-Dkt5-ikg.js → elk-XV6XMXQE-DsQY1hw9.js} +1 -1
- package/dist/public/assets/{erDiagram-EYBAPDEH-27kh3zlx.js → erDiagram-EYBAPDEH-CV8gJM0P.js} +1 -1
- package/dist/public/assets/{eventmodeling-K75KTNOO-CxVEejjN.js → eventmodeling-K75KTNOO-C1pymbUr.js} +1 -1
- package/dist/public/assets/flowDiagram-MALGAFMO-shBnAQFk.js +1 -0
- package/dist/public/assets/{freemarker2-D6CwPIXh.js → freemarker2-DYJXaMHN.js} +1 -1
- package/dist/public/assets/{ganttDiagram-23REXITY-C-amlwpX.js → ganttDiagram-23REXITY-CppxOWRh.js} +1 -1
- package/dist/public/assets/gitGraph-VSP46ZUC-BtQWboBz.js +1 -0
- package/dist/public/assets/{gitGraphDiagram-STJD7YCW-DKhzI0Xz.js → gitGraphDiagram-STJD7YCW-CrQrZhcP.js} +1 -1
- package/dist/public/assets/{handlebars-mxNr68Gm.js → handlebars-DZCnH9e2.js} +1 -1
- package/dist/public/assets/{html-Bze6s9R9.js → html-DuzouNES.js} +1 -1
- package/dist/public/assets/{index-BhQUc9PU.js → index-B7OYKvCE.js} +2 -2
- package/dist/public/assets/info-OHQRW6UA-CDSLjba_.js +1 -0
- package/dist/public/assets/{infoDiagram-KBXO4MBG-WHuWjEDO.js → infoDiagram-KBXO4MBG-6pby19tQ.js} +1 -1
- package/dist/public/assets/{ishikawaDiagram-M35NCXHK-DFHUwD0J.js → ishikawaDiagram-M35NCXHK-Duf8c8rQ.js} +1 -1
- package/dist/public/assets/{javascript-4NMPu7y1.js → javascript-2d_L6cVd.js} +1 -1
- package/dist/public/assets/{journeyDiagram-OPLOXDXO-C7gV6zEr.js → journeyDiagram-OPLOXDXO-Dvv-xzNo.js} +1 -1
- package/dist/public/assets/{jsonMode-B1JEHPMp.js → jsonMode-CFadYXyI.js} +1 -1
- package/dist/public/assets/{kanban-definition-BZKZHSQY-DlRu_d2Q.js → kanban-definition-BZKZHSQY-Dsk6F-TT.js} +1 -1
- package/dist/public/assets/{liquid-B7sIf4NX.js → liquid-Din4CF34.js} +1 -1
- package/dist/public/assets/{mdx-CAN0qez6.js → mdx-DivDuCWI.js} +1 -1
- package/dist/public/assets/{mermaid-parser.core-BGmotBhf.js → mermaid-parser.core-BfCv4CYZ.js} +3 -3
- package/dist/public/assets/{mermaid.core-Cl6SS3cM.js → mermaid.core-DC20ZwJj.js} +4 -4
- package/dist/public/assets/{mindmap-definition-I2QAS2VK-DiQ8Feqr.js → mindmap-definition-I2QAS2VK-DRZRrJU_.js} +1 -1
- package/dist/public/assets/module-BAQaY56j.js +1 -0
- package/dist/public/assets/module-DxRGg3ED.js +1947 -0
- package/dist/public/assets/{monaco-CwCjTWAO.js → monaco-D1d6MOPe.js} +3 -3
- package/dist/public/assets/packet-JDAUHWVQ-dYb4P9eU.js +1 -0
- package/dist/public/assets/{pegDiagram-FD4XPPHP-XhCpv6BX.js → pegDiagram-FD4XPPHP-DcGr3Tbk.js} +1 -1
- package/dist/public/assets/pie-XZMESJXO-CIompBnc.js +1 -0
- package/dist/public/assets/{pieDiagram-J4AKIIQI-DUVzuXUd.js → pieDiagram-J4AKIIQI-GF7pu6ch.js} +1 -1
- package/dist/public/assets/{python-DsoF66Sp.js → python-BQbTTTT5.js} +1 -1
- package/dist/public/assets/{quadrantDiagram-XTYBLID2-Ddobf0z0.js → quadrantDiagram-XTYBLID2-D-bcu7Ey.js} +1 -1
- package/dist/public/assets/radar-ABXABTNO-DiJl7BtK.js +1 -0
- package/dist/public/assets/railroad-I3PHUGI6-B5cRBukM.js +1 -0
- package/dist/public/assets/{railroad-abnf-LNEFI6M7-DkrNo-Gf.js → railroad-abnf-LNEFI6M7-BiBHsI-K.js} +1 -1
- package/dist/public/assets/{railroad-ebnf-DWYD2UWJ-DaB7gY8P.js → railroad-ebnf-DWYD2UWJ-zKjrfkHs.js} +1 -1
- package/dist/public/assets/{railroad-peg-JR7BVNR7-D_QG87QV.js → railroad-peg-JR7BVNR7-DKuVn0GT.js} +1 -1
- package/dist/public/assets/{railroadDiagram-MRQ6NCDL-x-nUoBjv.js → railroadDiagram-MRQ6NCDL-Cyn-16mJ.js} +1 -1
- package/dist/public/assets/{razor-DSrcJyQe.js → razor-DiLk54O0.js} +1 -1
- package/dist/public/assets/{requirementDiagram-Y7LWUY3S-kNNcbsty.js → requirementDiagram-Y7LWUY3S-CwU2EBkW.js} +1 -1
- package/dist/public/assets/{sankeyDiagram-WGJFYUXA-ClC12Odk.js → sankeyDiagram-WGJFYUXA-ajf00HyW.js} +1 -1
- package/dist/public/assets/{sequenceDiagram-5NDRBG5M-DDQITP2g.js → sequenceDiagram-5NDRBG5M-DiX_OIAw.js} +1 -1
- package/dist/public/assets/{stateDiagram-v2-FJ4FJNEA-N1t_36oh.js → stateDiagram-v2-FJ4FJNEA-CV5bRqB7.js} +1 -1
- package/dist/public/assets/{swimlanes-UMQ2AFYF-DSt9fFYE.js → swimlanes-UMQ2AFYF-BGQKSlj7.js} +1 -1
- package/dist/public/assets/swimlanesDiagram-OMPLPG4O-DxXlavVT.js +8 -0
- package/dist/public/assets/{timeline-definition-SEUHKTQE-CfymOw_s.js → timeline-definition-SEUHKTQE-DhQoApff.js} +1 -1
- package/dist/public/assets/treeView-D4JQ5SDB-BOP6mkZC.js +1 -0
- package/dist/public/assets/treemap-SAJKECNS-BJxuPMz3.js +1 -0
- package/dist/public/assets/{typescript-J7rF-zX8.js → typescript-COQ1g-up.js} +1 -1
- package/dist/public/assets/{usecaseDiagram-AFA6YXN4-CK_mRc2_.js → usecaseDiagram-AFA6YXN4-CmLFzjie.js} +1 -1
- package/dist/public/assets/{vennDiagram-NNMJR3RB-DW8xR6IJ.js → vennDiagram-NNMJR3RB-DOa6JR5K.js} +1 -1
- package/dist/public/assets/wardley-7MLQ67FV-jqlowjVL.js +1 -0
- package/dist/public/assets/{wardleyDiagram-S7YFUSEH-Css55Zq5.js → wardleyDiagram-S7YFUSEH-BV7EEShp.js} +1 -1
- package/dist/public/assets/{xml-CJeviG_a.js → xml-BbvtjuaG.js} +1 -1
- package/dist/public/assets/{xychartDiagram-GGNKY7IX-BnhK9cFS.js → xychartDiagram-GGNKY7IX-DtMpPbsq.js} +1 -1
- package/dist/public/assets/{yaml-Gw3uo6rF.js → yaml-Bw8NFga9.js} +1 -1
- package/dist/public/index.html +1 -1
- package/dist/public/launch.svg +46 -42
- package/dist/serve/index.mjs +1367 -560
- package/package.json +25 -25
- package/dist/pi/dist/bundle/chunks/anthropic-messages-BWGCKOF4.js +0 -6
- package/dist/pi/dist/bundle/chunks/chunk-44DLKSKE.js +0 -1232
- package/dist/pi/dist/bundle/chunks/chunk-62VOPMLK.js +0 -65
- package/dist/pi/dist/bundle/chunks/chunk-7O7QKK6A.js +0 -2
- package/dist/pi/dist/bundle/chunks/chunk-CHWNPHIS.js +0 -82
- package/dist/pi/dist/bundle/chunks/chunk-NL4X6LBY.js +0 -4
- package/dist/pi/dist/bundle/chunks/chunk-NZY7EIPA.js +0 -4
- package/dist/pi/dist/bundle/chunks/chunk-R2EGYMOO.js +0 -7
- package/dist/pi/dist/bundle/chunks/chunk-UKVNB6C4.js +0 -2
- package/dist/pi/dist/bundle/chunks/chunk-USJZMAIR.js +0 -2
- package/dist/pi/dist/bundle/chunks/chunk-VOLAXWGI.js +0 -2
- package/dist/pi/dist/bundle/chunks/openai-codex-responses-QAWLOQSN.js +0 -10
- package/dist/pi/dist/bundle/chunks/openai-responses-MD3562FB.js +0 -4
- package/dist/pi/dist/bundle/chunks/virtual-modules-O76XM3OB.js +0 -2
- package/dist/public/assets/browser-DAv3ly6M.js +0 -12
- package/dist/public/assets/cynefin-EF2NZ3EQ-CW_93VVD.js +0 -1
- package/dist/public/assets/flowDiagram-MALGAFMO-BRowRdve.js +0 -1
- package/dist/public/assets/gitGraph-VSP46ZUC-BGmojXlx.js +0 -1
- package/dist/public/assets/info-OHQRW6UA-CRRVgGj2.js +0 -1
- package/dist/public/assets/module-1nDbf1AK.js +0 -1761
- package/dist/public/assets/module-BkKfSTDV.js +0 -1
- package/dist/public/assets/packet-JDAUHWVQ-DUlqTCWQ.js +0 -1
- package/dist/public/assets/pie-XZMESJXO-2RgP4ScO.js +0 -1
- package/dist/public/assets/radar-ABXABTNO-Dap8k-yH.js +0 -1
- package/dist/public/assets/railroad-I3PHUGI6-Ds10NBze.js +0 -1
- package/dist/public/assets/swimlanesDiagram-OMPLPG4O-BHAN4SQO.js +0 -8
- package/dist/public/assets/treeView-D4JQ5SDB-f1hLUBjI.js +0 -1
- package/dist/public/assets/treemap-SAJKECNS-_NPRpuUC.js +0 -1
- package/dist/public/assets/wardley-7MLQ67FV-CLBqtefx.js +0 -1
|
@@ -21,10 +21,14 @@ import type { Message } from "@earendil-works/pi-ai";
|
|
|
21
21
|
import { StringEnum } from "@earendil-works/pi-ai";
|
|
22
22
|
import {
|
|
23
23
|
CONFIG_DIR_NAME,
|
|
24
|
+
DEFAULT_MAX_BYTES,
|
|
25
|
+
DEFAULT_MAX_LINES,
|
|
24
26
|
type ExtensionAPI,
|
|
25
27
|
formatReadLineRange,
|
|
26
28
|
getAgentDir,
|
|
27
29
|
getMarkdownTheme,
|
|
30
|
+
type JsonAgentSessionEvent,
|
|
31
|
+
truncateHead,
|
|
28
32
|
withFileMutationQueue,
|
|
29
33
|
} from "@earendil-works/pi-coding-agent";
|
|
30
34
|
import { Container, Markdown, Spacer, Text } from "@earendil-works/pi-tui";
|
|
@@ -35,6 +39,7 @@ const MAX_PARALLEL_TASKS = 8;
|
|
|
35
39
|
const MAX_CONCURRENCY = 4;
|
|
36
40
|
const COLLAPSED_ITEM_COUNT = 10;
|
|
37
41
|
const PER_TASK_OUTPUT_CAP = 50 * 1024;
|
|
42
|
+
const TRUNCATION_NOTICE_RESERVE = 256;
|
|
38
43
|
|
|
39
44
|
function formatTokens(count: number): string {
|
|
40
45
|
if (count < 1000) return count.toString();
|
|
@@ -144,25 +149,28 @@ interface UsageStats {
|
|
|
144
149
|
turns: number;
|
|
145
150
|
}
|
|
146
151
|
|
|
152
|
+
type ChildStatus = "pending" | "running" | "completed" | "failed" | "aborted";
|
|
153
|
+
|
|
147
154
|
interface SingleResult {
|
|
148
155
|
agent: string;
|
|
149
156
|
agentSource: "user" | "project" | "unknown";
|
|
150
157
|
task: string;
|
|
151
|
-
|
|
158
|
+
status: ChildStatus;
|
|
159
|
+
exitCode: number | null;
|
|
152
160
|
messages: Message[];
|
|
153
161
|
stderr: string;
|
|
154
162
|
usage: UsageStats;
|
|
155
163
|
model?: string;
|
|
156
164
|
stopReason?: string;
|
|
157
165
|
errorMessage?: string;
|
|
166
|
+
terminationSignal?: NodeJS.Signals;
|
|
158
167
|
step?: number;
|
|
159
168
|
}
|
|
160
169
|
|
|
161
170
|
interface SubagentDetails {
|
|
162
171
|
mode: "single" | "parallel" | "chain";
|
|
163
|
-
agentScope: AgentScope;
|
|
164
|
-
projectAgentsDir: string | null;
|
|
165
172
|
results: SingleResult[];
|
|
173
|
+
isError: boolean;
|
|
166
174
|
}
|
|
167
175
|
|
|
168
176
|
function getFinalOutput(messages: Message[]): string {
|
|
@@ -178,14 +186,38 @@ function getFinalOutput(messages: Message[]): string {
|
|
|
178
186
|
}
|
|
179
187
|
|
|
180
188
|
function isFailedResult(result: SingleResult): boolean {
|
|
181
|
-
return result.
|
|
189
|
+
return result.status === "failed" || result.status === "aborted";
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function getFailureEvidence(result: SingleResult): string {
|
|
193
|
+
const evidence: string[] = [];
|
|
194
|
+
const seen = new Set<string>();
|
|
195
|
+
const add = (label: string, value: string | undefined) => {
|
|
196
|
+
const text = value?.trim();
|
|
197
|
+
if (!text || seen.has(text)) return;
|
|
198
|
+
seen.add(text);
|
|
199
|
+
evidence.push(`${label}: ${text}`);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
add("Error", result.errorMessage);
|
|
203
|
+
add("Signal", result.terminationSignal);
|
|
204
|
+
add("stderr", result.stderr);
|
|
205
|
+
add("Assistant output", getFinalOutput(result.messages));
|
|
206
|
+
return evidence.join("\n\n") || "(no output)";
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function getFailureSummary(result: SingleResult): string {
|
|
210
|
+
return (
|
|
211
|
+
result.errorMessage?.trim() ||
|
|
212
|
+
(result.terminationSignal ? `Terminated by signal ${result.terminationSignal}` : "") ||
|
|
213
|
+
result.stderr.trim() ||
|
|
214
|
+
getFinalOutput(result.messages) ||
|
|
215
|
+
"(no output)"
|
|
216
|
+
);
|
|
182
217
|
}
|
|
183
218
|
|
|
184
219
|
function getResultOutput(result: SingleResult): string {
|
|
185
|
-
|
|
186
|
-
return result.errorMessage || result.stderr || getFinalOutput(result.messages) || "(no output)";
|
|
187
|
-
}
|
|
188
|
-
return getFinalOutput(result.messages) || "(no output)";
|
|
220
|
+
return isFailedResult(result) ? getFailureEvidence(result) : getFinalOutput(result.messages) || "(no output)";
|
|
189
221
|
}
|
|
190
222
|
|
|
191
223
|
function truncateParallelOutput(output: string): string {
|
|
@@ -199,6 +231,19 @@ function truncateParallelOutput(output: string): string {
|
|
|
199
231
|
return `${truncated}\n\n[Output truncated: ${byteLength - Buffer.byteLength(truncated, "utf8")} bytes omitted. Full output preserved in tool details.]`;
|
|
200
232
|
}
|
|
201
233
|
|
|
234
|
+
function truncateModelOutput(output: string): string {
|
|
235
|
+
const initial = truncateHead(output);
|
|
236
|
+
if (!initial.truncated) return output;
|
|
237
|
+
|
|
238
|
+
const body = truncateHead(output, {
|
|
239
|
+
maxLines: DEFAULT_MAX_LINES - 2,
|
|
240
|
+
maxBytes: DEFAULT_MAX_BYTES - TRUNCATION_NOTICE_RESERVE,
|
|
241
|
+
});
|
|
242
|
+
const omittedBytes = initial.totalBytes - body.outputBytes;
|
|
243
|
+
const notice = `[Output truncated: ${omittedBytes} bytes omitted. Full output preserved in tool details.]`;
|
|
244
|
+
return body.content ? `${body.content}\n\n${notice}` : notice;
|
|
245
|
+
}
|
|
246
|
+
|
|
202
247
|
type DisplayItem = { type: "text"; text: string } | { type: "toolCall"; name: string; args: Record<string, any> };
|
|
203
248
|
|
|
204
249
|
function getDisplayItems(messages: Message[]): DisplayItem[] {
|
|
@@ -246,7 +291,11 @@ async function writePromptToTempFile(agentName: string, prompt: string): Promise
|
|
|
246
291
|
|
|
247
292
|
function getPiInvocation(args: string[]): { command: string; args: string[] } {
|
|
248
293
|
const currentScript = process.argv[1];
|
|
249
|
-
|
|
294
|
+
// Bun-compiled binaries report their embedded entry as argv[1]: "/$bunfs/root/..." on
|
|
295
|
+
// POSIX and "B:/~BUN/root/..." on Windows. fs.existsSync() resolves these inside Bun.
|
|
296
|
+
const isBunVirtualScript =
|
|
297
|
+
currentScript !== undefined &&
|
|
298
|
+
(currentScript.startsWith("/$bunfs/root/") || /^[A-Za-z]:[\\/]~BUN[\\/]root[\\/]/.test(currentScript));
|
|
250
299
|
if (currentScript && !isBunVirtualScript && fs.existsSync(currentScript)) {
|
|
251
300
|
return { command: process.execPath, args: [currentScript, ...args] };
|
|
252
301
|
}
|
|
@@ -267,32 +316,74 @@ interface DispatchDefaults {
|
|
|
267
316
|
thinkingLevel?: ThinkingLevel;
|
|
268
317
|
}
|
|
269
318
|
|
|
319
|
+
interface ProcessOutcome {
|
|
320
|
+
code: number | null;
|
|
321
|
+
signal: NodeJS.Signals | null;
|
|
322
|
+
spawnError?: Error;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
interface ResolvedAgent {
|
|
326
|
+
agent?: AgentConfig;
|
|
327
|
+
available: AgentConfig[];
|
|
328
|
+
cwd: string;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function resolveAgent(defaultCwd: string, scope: AgentScope, name: string, cwd?: string): ResolvedAgent {
|
|
332
|
+
const effectiveCwd = path.resolve(defaultCwd, cwd ?? ".");
|
|
333
|
+
const discovery = discoverAgents(effectiveCwd, scope);
|
|
334
|
+
return {
|
|
335
|
+
agent: discovery.agents.find((candidate) => candidate.name === name),
|
|
336
|
+
available: discovery.agents,
|
|
337
|
+
cwd: effectiveCwd,
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function createUnstartedResult(
|
|
342
|
+
agent: string,
|
|
343
|
+
task: string,
|
|
344
|
+
step: number | undefined,
|
|
345
|
+
status: "aborted" | "failed",
|
|
346
|
+
errorMessage?: string,
|
|
347
|
+
): SingleResult {
|
|
348
|
+
return {
|
|
349
|
+
agent,
|
|
350
|
+
agentSource: "unknown",
|
|
351
|
+
task,
|
|
352
|
+
status,
|
|
353
|
+
exitCode: null,
|
|
354
|
+
messages: [],
|
|
355
|
+
stderr: "",
|
|
356
|
+
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, contextTokens: 0, turns: 0 },
|
|
357
|
+
errorMessage,
|
|
358
|
+
step,
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
|
|
270
362
|
async function runSingleAgent(
|
|
271
|
-
defaultCwd: string,
|
|
272
363
|
dispatchDefaults: DispatchDefaults,
|
|
273
|
-
|
|
364
|
+
resolvedAgent: ResolvedAgent,
|
|
274
365
|
agentName: string,
|
|
275
366
|
task: string,
|
|
276
|
-
cwd: string | undefined,
|
|
277
367
|
step: number | undefined,
|
|
278
368
|
signal: AbortSignal | undefined,
|
|
279
369
|
onUpdate: OnUpdateCallback | undefined,
|
|
280
370
|
makeDetails: (results: SingleResult[]) => SubagentDetails,
|
|
281
371
|
): Promise<SingleResult> {
|
|
282
|
-
|
|
372
|
+
if (signal?.aborted) {
|
|
373
|
+
return createUnstartedResult(agentName, task, step, "aborted", "Subagent was aborted before starting");
|
|
374
|
+
}
|
|
283
375
|
|
|
376
|
+
const effectiveCwd = resolvedAgent.cwd;
|
|
377
|
+
const agent = resolvedAgent.agent;
|
|
284
378
|
if (!agent) {
|
|
285
|
-
const available =
|
|
286
|
-
return
|
|
287
|
-
|
|
288
|
-
agentSource: "unknown",
|
|
379
|
+
const available = resolvedAgent.available.map((candidate) => `"${candidate.name}"`).join(", ") || "none";
|
|
380
|
+
return createUnstartedResult(
|
|
381
|
+
agentName,
|
|
289
382
|
task,
|
|
290
|
-
exitCode: 1,
|
|
291
|
-
messages: [],
|
|
292
|
-
stderr: `Unknown agent: "${agentName}". Available agents: ${available}.`,
|
|
293
|
-
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, contextTokens: 0, turns: 0 },
|
|
294
383
|
step,
|
|
295
|
-
|
|
384
|
+
"failed",
|
|
385
|
+
`Unknown agent: "${agentName}". Available agents: ${available}.`,
|
|
386
|
+
);
|
|
296
387
|
}
|
|
297
388
|
|
|
298
389
|
const args: string[] = ["--mode", "json", "-p", "--no-session"];
|
|
@@ -306,12 +397,12 @@ async function runSingleAgent(
|
|
|
306
397
|
|
|
307
398
|
let tmpPromptDir: string | null = null;
|
|
308
399
|
let tmpPromptPath: string | null = null;
|
|
309
|
-
|
|
310
400
|
const currentResult: SingleResult = {
|
|
311
401
|
agent: agentName,
|
|
312
402
|
agentSource: agent.source,
|
|
313
403
|
task,
|
|
314
|
-
|
|
404
|
+
status: "running",
|
|
405
|
+
exitCode: null,
|
|
315
406
|
messages: [],
|
|
316
407
|
stderr: "",
|
|
317
408
|
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, contextTokens: 0, turns: 0 },
|
|
@@ -320,12 +411,10 @@ async function runSingleAgent(
|
|
|
320
411
|
};
|
|
321
412
|
|
|
322
413
|
const emitUpdate = () => {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
});
|
|
328
|
-
}
|
|
414
|
+
onUpdate?.({
|
|
415
|
+
content: [{ type: "text", text: getFinalOutput(currentResult.messages) || "(running...)" }],
|
|
416
|
+
details: makeDetails([currentResult]),
|
|
417
|
+
});
|
|
329
418
|
};
|
|
330
419
|
|
|
331
420
|
try {
|
|
@@ -336,104 +425,154 @@ async function runSingleAgent(
|
|
|
336
425
|
args.push("--append-system-prompt", tmpPromptPath);
|
|
337
426
|
}
|
|
338
427
|
|
|
428
|
+
if (signal?.aborted) {
|
|
429
|
+
currentResult.status = "aborted";
|
|
430
|
+
currentResult.errorMessage = "Subagent was aborted before starting";
|
|
431
|
+
return currentResult;
|
|
432
|
+
}
|
|
433
|
+
|
|
339
434
|
args.push(`Task: ${task}`);
|
|
435
|
+
emitUpdate();
|
|
340
436
|
let wasAborted = false;
|
|
341
|
-
|
|
342
|
-
const exitCode = await new Promise<number>((resolve) => {
|
|
437
|
+
const outcome = await new Promise<ProcessOutcome>((resolve) => {
|
|
343
438
|
const invocation = getPiInvocation(args);
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
});
|
|
439
|
+
let settled = false;
|
|
440
|
+
let exited = false;
|
|
441
|
+
let closed = false;
|
|
442
|
+
let killTimer: ReturnType<typeof setTimeout> | undefined;
|
|
349
443
|
let buffer = "";
|
|
350
444
|
|
|
351
445
|
const processLine = (line: string) => {
|
|
352
446
|
if (!line.trim()) return;
|
|
353
|
-
let event:
|
|
447
|
+
let event: JsonAgentSessionEvent;
|
|
354
448
|
try {
|
|
355
|
-
event = JSON.parse(line);
|
|
449
|
+
event = JSON.parse(line) as JsonAgentSessionEvent;
|
|
356
450
|
} catch {
|
|
357
451
|
return;
|
|
358
452
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
if (usage) {
|
|
368
|
-
currentResult.usage.input += usage.input || 0;
|
|
369
|
-
currentResult.usage.output += usage.output || 0;
|
|
370
|
-
currentResult.usage.cacheRead += usage.cacheRead || 0;
|
|
371
|
-
currentResult.usage.cacheWrite += usage.cacheWrite || 0;
|
|
372
|
-
currentResult.usage.cost += usage.cost?.total || 0;
|
|
373
|
-
currentResult.usage.contextTokens = usage.totalTokens || 0;
|
|
374
|
-
}
|
|
375
|
-
if (!currentResult.model && msg.model) currentResult.model = msg.model;
|
|
376
|
-
if (msg.stopReason) currentResult.stopReason = msg.stopReason;
|
|
377
|
-
if (msg.errorMessage) currentResult.errorMessage = msg.errorMessage;
|
|
378
|
-
}
|
|
379
|
-
emitUpdate();
|
|
453
|
+
if (event.type !== "message_end") return;
|
|
454
|
+
const eventMessage = event.message;
|
|
455
|
+
if (
|
|
456
|
+
eventMessage.role !== "user" &&
|
|
457
|
+
eventMessage.role !== "assistant" &&
|
|
458
|
+
eventMessage.role !== "toolResult"
|
|
459
|
+
) {
|
|
460
|
+
return;
|
|
380
461
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
462
|
+
const message = eventMessage as Message;
|
|
463
|
+
currentResult.messages.push(message);
|
|
464
|
+
if (message.role === "assistant") {
|
|
465
|
+
currentResult.usage.turns++;
|
|
466
|
+
currentResult.usage.input += message.usage.input;
|
|
467
|
+
currentResult.usage.output += message.usage.output;
|
|
468
|
+
currentResult.usage.cacheRead += message.usage.cacheRead;
|
|
469
|
+
currentResult.usage.cacheWrite += message.usage.cacheWrite;
|
|
470
|
+
currentResult.usage.cost += message.usage.cost.total;
|
|
471
|
+
currentResult.usage.contextTokens = message.usage.totalTokens;
|
|
472
|
+
if (!currentResult.model) currentResult.model = message.model;
|
|
473
|
+
currentResult.stopReason = message.stopReason;
|
|
474
|
+
currentResult.errorMessage = message.errorMessage;
|
|
385
475
|
}
|
|
476
|
+
emitUpdate();
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
let proc: ReturnType<typeof spawn>;
|
|
480
|
+
const finish = (result: ProcessOutcome) => {
|
|
481
|
+
if (settled) return;
|
|
482
|
+
settled = true;
|
|
483
|
+
closed = true;
|
|
484
|
+
if (killTimer) clearTimeout(killTimer);
|
|
485
|
+
if (signal) signal.removeEventListener("abort", abortProcess);
|
|
486
|
+
resolve(result);
|
|
386
487
|
};
|
|
488
|
+
const abortProcess = () => {
|
|
489
|
+
if (closed || exited || proc.exitCode !== null || proc.signalCode !== null) return;
|
|
490
|
+
if (!proc.kill("SIGTERM")) return;
|
|
491
|
+
wasAborted = true;
|
|
492
|
+
killTimer = setTimeout(() => {
|
|
493
|
+
if (!closed && !exited) proc.kill("SIGKILL");
|
|
494
|
+
}, 5000);
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
try {
|
|
498
|
+
proc = spawn(invocation.command, invocation.args, {
|
|
499
|
+
cwd: effectiveCwd,
|
|
500
|
+
shell: false,
|
|
501
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
502
|
+
});
|
|
503
|
+
} catch (error) {
|
|
504
|
+
finish({
|
|
505
|
+
code: null,
|
|
506
|
+
signal: null,
|
|
507
|
+
spawnError: error instanceof Error ? error : new Error(String(error)),
|
|
508
|
+
});
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
387
511
|
|
|
388
|
-
proc.stdout
|
|
512
|
+
proc.stdout?.on("data", (data) => {
|
|
389
513
|
buffer += data.toString();
|
|
390
514
|
const lines = buffer.split("\n");
|
|
391
515
|
buffer = lines.pop() || "";
|
|
392
516
|
for (const line of lines) processLine(line);
|
|
393
517
|
});
|
|
394
|
-
|
|
395
|
-
proc.stderr.on("data", (data) => {
|
|
518
|
+
proc.stderr?.on("data", (data) => {
|
|
396
519
|
currentResult.stderr += data.toString();
|
|
397
520
|
});
|
|
398
|
-
|
|
399
|
-
|
|
521
|
+
proc.on("exit", () => {
|
|
522
|
+
exited = true;
|
|
523
|
+
});
|
|
524
|
+
proc.on("close", (code, terminationSignal) => {
|
|
400
525
|
if (buffer.trim()) processLine(buffer);
|
|
401
|
-
|
|
526
|
+
finish({ code, signal: terminationSignal });
|
|
402
527
|
});
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
resolve(1);
|
|
528
|
+
proc.on("error", (error) => {
|
|
529
|
+
finish({ code: null, signal: null, spawnError: error });
|
|
406
530
|
});
|
|
407
531
|
|
|
408
532
|
if (signal) {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
proc.kill("SIGTERM");
|
|
412
|
-
setTimeout(() => {
|
|
413
|
-
if (!proc.killed) proc.kill("SIGKILL");
|
|
414
|
-
}, 5000);
|
|
415
|
-
};
|
|
416
|
-
if (signal.aborted) killProc();
|
|
417
|
-
else signal.addEventListener("abort", killProc, { once: true });
|
|
533
|
+
if (signal.aborted) abortProcess();
|
|
534
|
+
else signal.addEventListener("abort", abortProcess, { once: true });
|
|
418
535
|
}
|
|
419
536
|
});
|
|
420
537
|
|
|
421
|
-
currentResult.exitCode =
|
|
422
|
-
|
|
538
|
+
currentResult.exitCode = outcome.code;
|
|
539
|
+
currentResult.terminationSignal = outcome.signal ?? undefined;
|
|
540
|
+
|
|
541
|
+
if (wasAborted) {
|
|
542
|
+
currentResult.status = "aborted";
|
|
543
|
+
currentResult.errorMessage ||= "Subagent was aborted";
|
|
544
|
+
} else if (outcome.spawnError) {
|
|
545
|
+
currentResult.status = "failed";
|
|
546
|
+
currentResult.errorMessage = `Failed to spawn subagent: ${outcome.spawnError.message}`;
|
|
547
|
+
} else if (outcome.signal) {
|
|
548
|
+
currentResult.status = "failed";
|
|
549
|
+
currentResult.errorMessage ||= `Subagent terminated by signal ${outcome.signal}`;
|
|
550
|
+
} else if (outcome.code !== 0) {
|
|
551
|
+
currentResult.status = "failed";
|
|
552
|
+
currentResult.errorMessage ||= `Subagent exited with code ${outcome.code}`;
|
|
553
|
+
} else if (currentResult.stopReason === "aborted") {
|
|
554
|
+
currentResult.status = "aborted";
|
|
555
|
+
} else if (currentResult.stopReason === "error") {
|
|
556
|
+
currentResult.status = "failed";
|
|
557
|
+
} else {
|
|
558
|
+
currentResult.status = "completed";
|
|
559
|
+
}
|
|
423
560
|
return currentResult;
|
|
424
561
|
} finally {
|
|
425
|
-
if (tmpPromptPath)
|
|
562
|
+
if (tmpPromptPath) {
|
|
426
563
|
try {
|
|
427
564
|
fs.unlinkSync(tmpPromptPath);
|
|
428
565
|
} catch {
|
|
429
566
|
/* ignore */
|
|
430
567
|
}
|
|
431
|
-
|
|
568
|
+
}
|
|
569
|
+
if (tmpPromptDir) {
|
|
432
570
|
try {
|
|
433
571
|
fs.rmdirSync(tmpPromptDir);
|
|
434
572
|
} catch {
|
|
435
573
|
/* ignore */
|
|
436
574
|
}
|
|
575
|
+
}
|
|
437
576
|
}
|
|
438
577
|
}
|
|
439
578
|
|
|
@@ -467,6 +606,13 @@ const SubagentParams = Type.Object({
|
|
|
467
606
|
});
|
|
468
607
|
|
|
469
608
|
export default function (pi: ExtensionAPI) {
|
|
609
|
+
// Tool execute results cannot set runtime error state directly, so patch it through the result hook.
|
|
610
|
+
pi.on("tool_result", (event) => {
|
|
611
|
+
if (event.toolName !== "subagent") return;
|
|
612
|
+
const details = event.details as SubagentDetails | undefined;
|
|
613
|
+
if (details?.isError) return { isError: true };
|
|
614
|
+
});
|
|
615
|
+
|
|
470
616
|
pi.registerTool({
|
|
471
617
|
name: "subagent",
|
|
472
618
|
label: "Subagent",
|
|
@@ -494,12 +640,11 @@ export default function (pi: ExtensionAPI) {
|
|
|
494
640
|
const modeCount = Number(hasChain) + Number(hasTasks) + Number(hasSingle);
|
|
495
641
|
|
|
496
642
|
const makeDetails =
|
|
497
|
-
(mode: "single" | "parallel" | "chain") =>
|
|
643
|
+
(mode: "single" | "parallel" | "chain", forceError = false) =>
|
|
498
644
|
(results: SingleResult[]): SubagentDetails => ({
|
|
499
645
|
mode,
|
|
500
|
-
agentScope,
|
|
501
|
-
projectAgentsDir: discovery.projectAgentsDir,
|
|
502
646
|
results,
|
|
647
|
+
isError: forceError || results.some(isFailedResult),
|
|
503
648
|
});
|
|
504
649
|
|
|
505
650
|
if (modeCount !== 1) {
|
|
@@ -511,37 +656,50 @@ export default function (pi: ExtensionAPI) {
|
|
|
511
656
|
text: `Invalid parameters. Provide exactly one mode.\nAvailable agents: ${available}`,
|
|
512
657
|
},
|
|
513
658
|
],
|
|
514
|
-
details: makeDetails("single")([]),
|
|
659
|
+
details: makeDetails("single", true)([]),
|
|
515
660
|
};
|
|
516
661
|
}
|
|
517
662
|
|
|
518
|
-
|
|
519
|
-
(
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
)
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
663
|
+
const resolvedChain = (params.chain ?? []).map((step) =>
|
|
664
|
+
resolveAgent(ctx.cwd, agentScope, step.agent, step.cwd),
|
|
665
|
+
);
|
|
666
|
+
const resolvedTasks = (params.tasks ?? []).map((task) =>
|
|
667
|
+
resolveAgent(ctx.cwd, agentScope, task.agent, task.cwd),
|
|
668
|
+
);
|
|
669
|
+
const resolvedSingle = params.agent ? resolveAgent(ctx.cwd, agentScope, params.agent, params.cwd) : undefined;
|
|
670
|
+
|
|
671
|
+
if ((agentScope === "project" || agentScope === "both") && confirmProjectAgents && ctx.hasUI) {
|
|
672
|
+
let selectedAgents: ResolvedAgent[] = [];
|
|
673
|
+
if (hasChain) selectedAgents = resolvedChain;
|
|
674
|
+
else if (hasTasks) selectedAgents = resolvedTasks;
|
|
675
|
+
else if (resolvedSingle) selectedAgents = [resolvedSingle];
|
|
676
|
+
const projectAgentsByPath = new Map<string, AgentConfig>();
|
|
677
|
+
for (const resolved of selectedAgents) {
|
|
678
|
+
if (resolved.agent?.source === "project") {
|
|
679
|
+
projectAgentsByPath.set(resolved.agent.filePath, resolved.agent);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
532
682
|
|
|
683
|
+
const trustedProjectAgentsDir =
|
|
684
|
+
ctx.isProjectTrusted() && discovery.projectAgentsDir
|
|
685
|
+
? fs.realpathSync(discovery.projectAgentsDir)
|
|
686
|
+
: undefined;
|
|
687
|
+
const projectAgentsRequested = Array.from(projectAgentsByPath.values()).filter(
|
|
688
|
+
(agent) =>
|
|
689
|
+
!trustedProjectAgentsDir || fs.realpathSync(path.dirname(agent.filePath)) !== trustedProjectAgentsDir,
|
|
690
|
+
);
|
|
533
691
|
if (projectAgentsRequested.length > 0) {
|
|
534
|
-
const
|
|
535
|
-
const dir = discovery.projectAgentsDir ?? "(unknown)";
|
|
692
|
+
const sources = projectAgentsRequested.map((agent) => `- ${agent.name}: ${agent.filePath}`).join("\n");
|
|
536
693
|
const ok = await ctx.ui.confirm(
|
|
537
694
|
"Run project-local agents?",
|
|
538
|
-
`
|
|
695
|
+
`Sources:\n${sources}\n\nProject agents are repo-controlled. Only continue for trusted repositories.`,
|
|
539
696
|
);
|
|
540
|
-
if (!ok)
|
|
697
|
+
if (!ok) {
|
|
541
698
|
return {
|
|
542
699
|
content: [{ type: "text", text: "Canceled: project-local agents not approved." }],
|
|
543
700
|
details: makeDetails(hasChain ? "chain" : hasTasks ? "parallel" : "single")([]),
|
|
544
701
|
};
|
|
702
|
+
}
|
|
545
703
|
}
|
|
546
704
|
}
|
|
547
705
|
|
|
@@ -569,12 +727,10 @@ export default function (pi: ExtensionAPI) {
|
|
|
569
727
|
: undefined;
|
|
570
728
|
|
|
571
729
|
const result = await runSingleAgent(
|
|
572
|
-
ctx.cwd,
|
|
573
730
|
dispatchDefaults,
|
|
574
|
-
|
|
731
|
+
resolvedChain[i],
|
|
575
732
|
step.agent,
|
|
576
733
|
taskWithContext,
|
|
577
|
-
step.cwd,
|
|
578
734
|
i + 1,
|
|
579
735
|
signal,
|
|
580
736
|
chainUpdate,
|
|
@@ -586,15 +742,24 @@ export default function (pi: ExtensionAPI) {
|
|
|
586
742
|
if (isError) {
|
|
587
743
|
const errorMsg = getResultOutput(result);
|
|
588
744
|
return {
|
|
589
|
-
content: [
|
|
745
|
+
content: [
|
|
746
|
+
{
|
|
747
|
+
type: "text",
|
|
748
|
+
text: truncateModelOutput(`Chain stopped at step ${i + 1} (${step.agent}): ${errorMsg}`),
|
|
749
|
+
},
|
|
750
|
+
],
|
|
590
751
|
details: makeDetails("chain")(results),
|
|
591
|
-
isError: true,
|
|
592
752
|
};
|
|
593
753
|
}
|
|
594
754
|
previousOutput = getFinalOutput(result.messages);
|
|
595
755
|
}
|
|
596
756
|
return {
|
|
597
|
-
content: [
|
|
757
|
+
content: [
|
|
758
|
+
{
|
|
759
|
+
type: "text",
|
|
760
|
+
text: truncateModelOutput(getFinalOutput(results[results.length - 1].messages) || "(no output)"),
|
|
761
|
+
},
|
|
762
|
+
],
|
|
598
763
|
details: makeDetails("chain")(results),
|
|
599
764
|
};
|
|
600
765
|
}
|
|
@@ -608,7 +773,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
608
773
|
text: `Too many parallel tasks (${params.tasks.length}). Max is ${MAX_PARALLEL_TASKS}.`,
|
|
609
774
|
},
|
|
610
775
|
],
|
|
611
|
-
details: makeDetails("parallel")([]),
|
|
776
|
+
details: makeDetails("parallel", true)([]),
|
|
612
777
|
};
|
|
613
778
|
|
|
614
779
|
// Track all results for streaming updates
|
|
@@ -620,7 +785,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
620
785
|
agent: params.tasks[i].agent,
|
|
621
786
|
agentSource: "unknown",
|
|
622
787
|
task: params.tasks[i].task,
|
|
623
|
-
|
|
788
|
+
status: "pending",
|
|
789
|
+
exitCode: null,
|
|
624
790
|
messages: [],
|
|
625
791
|
stderr: "",
|
|
626
792
|
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, contextTokens: 0, turns: 0 },
|
|
@@ -629,11 +795,15 @@ export default function (pi: ExtensionAPI) {
|
|
|
629
795
|
|
|
630
796
|
const emitParallelUpdate = () => {
|
|
631
797
|
if (onUpdate) {
|
|
632
|
-
const running = allResults.filter((
|
|
633
|
-
const
|
|
798
|
+
const running = allResults.filter((result) => result.status === "running").length;
|
|
799
|
+
const pending = allResults.filter((result) => result.status === "pending").length;
|
|
800
|
+
const done = allResults.length - running - pending;
|
|
634
801
|
onUpdate({
|
|
635
802
|
content: [
|
|
636
|
-
{
|
|
803
|
+
{
|
|
804
|
+
type: "text",
|
|
805
|
+
text: `Parallel: ${done}/${allResults.length} done, ${running} running, ${pending} pending...`,
|
|
806
|
+
},
|
|
637
807
|
],
|
|
638
808
|
details: makeDetails("parallel")([...allResults]),
|
|
639
809
|
});
|
|
@@ -642,12 +812,10 @@ export default function (pi: ExtensionAPI) {
|
|
|
642
812
|
|
|
643
813
|
const results = await mapWithConcurrencyLimit(params.tasks, MAX_CONCURRENCY, async (t, index) => {
|
|
644
814
|
const result = await runSingleAgent(
|
|
645
|
-
ctx.cwd,
|
|
646
815
|
dispatchDefaults,
|
|
647
|
-
|
|
816
|
+
resolvedTasks[index],
|
|
648
817
|
t.agent,
|
|
649
818
|
t.task,
|
|
650
|
-
t.cwd,
|
|
651
819
|
undefined,
|
|
652
820
|
signal,
|
|
653
821
|
// Per-task update callback
|
|
@@ -667,9 +835,10 @@ export default function (pi: ExtensionAPI) {
|
|
|
667
835
|
const successCount = results.filter((r) => !isFailedResult(r)).length;
|
|
668
836
|
const summaries = results.map((r) => {
|
|
669
837
|
const output = truncateParallelOutput(getResultOutput(r));
|
|
670
|
-
const status =
|
|
671
|
-
|
|
672
|
-
|
|
838
|
+
const status =
|
|
839
|
+
isFailedResult(r) && r.stopReason && r.stopReason !== "end"
|
|
840
|
+
? `${r.status} (${r.stopReason})`
|
|
841
|
+
: r.status;
|
|
673
842
|
return `### [${r.agent}] ${status}\n\n${output}`;
|
|
674
843
|
});
|
|
675
844
|
return {
|
|
@@ -683,14 +852,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
683
852
|
};
|
|
684
853
|
}
|
|
685
854
|
|
|
686
|
-
if (params.agent && params.task) {
|
|
855
|
+
if (params.agent && params.task && resolvedSingle) {
|
|
687
856
|
const result = await runSingleAgent(
|
|
688
|
-
ctx.cwd,
|
|
689
857
|
dispatchDefaults,
|
|
690
|
-
|
|
858
|
+
resolvedSingle,
|
|
691
859
|
params.agent,
|
|
692
860
|
params.task,
|
|
693
|
-
params.cwd,
|
|
694
861
|
undefined,
|
|
695
862
|
signal,
|
|
696
863
|
onUpdate,
|
|
@@ -700,13 +867,22 @@ export default function (pi: ExtensionAPI) {
|
|
|
700
867
|
if (isError) {
|
|
701
868
|
const errorMsg = getResultOutput(result);
|
|
702
869
|
return {
|
|
703
|
-
content: [
|
|
870
|
+
content: [
|
|
871
|
+
{
|
|
872
|
+
type: "text",
|
|
873
|
+
text: truncateModelOutput(`Agent ${result.stopReason || result.status}: ${errorMsg}`),
|
|
874
|
+
},
|
|
875
|
+
],
|
|
704
876
|
details: makeDetails("single")([result]),
|
|
705
|
-
isError: true,
|
|
706
877
|
};
|
|
707
878
|
}
|
|
708
879
|
return {
|
|
709
|
-
content: [
|
|
880
|
+
content: [
|
|
881
|
+
{
|
|
882
|
+
type: "text",
|
|
883
|
+
text: truncateModelOutput(getFinalOutput(result.messages) || "(no output)"),
|
|
884
|
+
},
|
|
885
|
+
],
|
|
710
886
|
details: makeDetails("single")([result]),
|
|
711
887
|
};
|
|
712
888
|
}
|
|
@@ -714,7 +890,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
714
890
|
const available = agents.map((a) => `${a.name} (${a.source})`).join(", ") || "none";
|
|
715
891
|
return {
|
|
716
892
|
content: [{ type: "text", text: `Invalid parameters. Available agents: ${available}` }],
|
|
717
|
-
details: makeDetails("single")([]),
|
|
893
|
+
details: makeDetails("single", true)([]),
|
|
718
894
|
};
|
|
719
895
|
},
|
|
720
896
|
|
|
@@ -787,20 +963,33 @@ export default function (pi: ExtensionAPI) {
|
|
|
787
963
|
return text.trimEnd();
|
|
788
964
|
};
|
|
789
965
|
|
|
966
|
+
const resultIcon = (child: SingleResult): string => {
|
|
967
|
+
if (child.status === "pending" || child.status === "running") {
|
|
968
|
+
return theme.fg("warning", "⏳");
|
|
969
|
+
}
|
|
970
|
+
if (isFailedResult(child)) return theme.fg("error", "✗");
|
|
971
|
+
return theme.fg("success", "✓");
|
|
972
|
+
};
|
|
973
|
+
|
|
790
974
|
if (details.mode === "single" && details.results.length === 1) {
|
|
791
975
|
const r = details.results[0];
|
|
792
976
|
const isError = isFailedResult(r);
|
|
793
|
-
const
|
|
977
|
+
const isRunning = r.status === "pending" || r.status === "running";
|
|
978
|
+
const icon = resultIcon(r);
|
|
794
979
|
const displayItems = getDisplayItems(r.messages);
|
|
795
980
|
const finalOutput = getFinalOutput(r.messages);
|
|
796
981
|
|
|
797
982
|
if (expanded) {
|
|
798
983
|
const container = new Container();
|
|
799
984
|
let header = `${icon} ${theme.fg("toolTitle", theme.bold(r.agent))}${theme.fg("muted", ` (${r.agentSource})`)}`;
|
|
800
|
-
if (
|
|
985
|
+
if (isRunning) header += ` ${theme.fg("warning", `[${r.status}]`)}`;
|
|
986
|
+
else if (isError) header += ` ${theme.fg("error", `[${r.stopReason ?? r.status}]`)}`;
|
|
801
987
|
container.addChild(new Text(header, 0, 0));
|
|
802
988
|
if (isError && r.errorMessage)
|
|
803
989
|
container.addChild(new Text(theme.fg("error", `Error: ${r.errorMessage}`), 0, 0));
|
|
990
|
+
if (r.terminationSignal)
|
|
991
|
+
container.addChild(new Text(theme.fg("error", `Signal: ${r.terminationSignal}`), 0, 0));
|
|
992
|
+
if (r.stderr.trim()) container.addChild(new Text(theme.fg("error", `stderr: ${r.stderr.trim()}`), 0, 0));
|
|
804
993
|
container.addChild(new Spacer(1));
|
|
805
994
|
container.addChild(new Text(theme.fg("muted", "─── Task ───"), 0, 0));
|
|
806
995
|
container.addChild(new Text(theme.fg("dim", r.task), 0, 0));
|
|
@@ -833,7 +1022,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
833
1022
|
}
|
|
834
1023
|
|
|
835
1024
|
let text = `${icon} ${theme.fg("toolTitle", theme.bold(r.agent))}${theme.fg("muted", ` (${r.agentSource})`)}`;
|
|
836
|
-
if (
|
|
1025
|
+
if (isRunning) text += ` ${theme.fg("warning", `[${r.status}]`)}`;
|
|
1026
|
+
else if (isError) text += ` ${theme.fg("error", `[${r.stopReason ?? r.status}]`)}`;
|
|
837
1027
|
if (isError && r.errorMessage) text += `\n${theme.fg("error", `Error: ${r.errorMessage}`)}`;
|
|
838
1028
|
else if (displayItems.length === 0) text += `\n${theme.fg("muted", "(no output)")}`;
|
|
839
1029
|
else {
|
|
@@ -845,22 +1035,35 @@ export default function (pi: ExtensionAPI) {
|
|
|
845
1035
|
return new Text(text, 0, 0);
|
|
846
1036
|
}
|
|
847
1037
|
|
|
848
|
-
const aggregateUsage = (results: SingleResult[]) => {
|
|
849
|
-
const total = {
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
1038
|
+
const aggregateUsage = (results: SingleResult[]): UsageStats => {
|
|
1039
|
+
const total: UsageStats = {
|
|
1040
|
+
input: 0,
|
|
1041
|
+
output: 0,
|
|
1042
|
+
cacheRead: 0,
|
|
1043
|
+
cacheWrite: 0,
|
|
1044
|
+
cost: 0,
|
|
1045
|
+
contextTokens: 0,
|
|
1046
|
+
turns: 0,
|
|
1047
|
+
};
|
|
1048
|
+
for (const result of results) {
|
|
1049
|
+
total.input += result.usage.input;
|
|
1050
|
+
total.output += result.usage.output;
|
|
1051
|
+
total.cacheRead += result.usage.cacheRead;
|
|
1052
|
+
total.cacheWrite += result.usage.cacheWrite;
|
|
1053
|
+
total.cost += result.usage.cost;
|
|
1054
|
+
total.turns += result.usage.turns;
|
|
857
1055
|
}
|
|
858
1056
|
return total;
|
|
859
1057
|
};
|
|
860
1058
|
|
|
861
1059
|
if (details.mode === "chain") {
|
|
862
|
-
const successCount = details.results.filter((
|
|
863
|
-
const
|
|
1060
|
+
const successCount = details.results.filter((result) => result.status === "completed").length;
|
|
1061
|
+
const hasActive = details.results.some(
|
|
1062
|
+
(result) => result.status === "pending" || result.status === "running",
|
|
1063
|
+
);
|
|
1064
|
+
let icon = theme.fg("error", "✗");
|
|
1065
|
+
if (hasActive) icon = theme.fg("warning", "⏳");
|
|
1066
|
+
else if (successCount === details.results.length) icon = theme.fg("success", "✓");
|
|
864
1067
|
|
|
865
1068
|
if (expanded) {
|
|
866
1069
|
const container = new Container();
|
|
@@ -876,7 +1079,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
876
1079
|
);
|
|
877
1080
|
|
|
878
1081
|
for (const r of details.results) {
|
|
879
|
-
const rIcon = r
|
|
1082
|
+
const rIcon = resultIcon(r);
|
|
880
1083
|
const displayItems = getDisplayItems(r.messages);
|
|
881
1084
|
const finalOutput = getFinalOutput(r.messages);
|
|
882
1085
|
|
|
@@ -889,6 +1092,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
889
1092
|
),
|
|
890
1093
|
);
|
|
891
1094
|
container.addChild(new Text(theme.fg("muted", "Task: ") + theme.fg("dim", r.task), 0, 0));
|
|
1095
|
+
if (isFailedResult(r) && r.errorMessage)
|
|
1096
|
+
container.addChild(new Text(theme.fg("error", `Error: ${r.errorMessage}`), 0, 0));
|
|
1097
|
+
if (r.terminationSignal)
|
|
1098
|
+
container.addChild(new Text(theme.fg("error", `Signal: ${r.terminationSignal}`), 0, 0));
|
|
1099
|
+
if (r.stderr.trim())
|
|
1100
|
+
container.addChild(new Text(theme.fg("error", `stderr: ${r.stderr.trim()}`), 0, 0));
|
|
892
1101
|
|
|
893
1102
|
// Show tool calls
|
|
894
1103
|
for (const item of displayItems) {
|
|
@@ -928,11 +1137,16 @@ export default function (pi: ExtensionAPI) {
|
|
|
928
1137
|
theme.fg("toolTitle", theme.bold("chain ")) +
|
|
929
1138
|
theme.fg("accent", `${successCount}/${details.results.length} steps`);
|
|
930
1139
|
for (const r of details.results) {
|
|
931
|
-
const rIcon = r
|
|
1140
|
+
const rIcon = resultIcon(r);
|
|
932
1141
|
const displayItems = getDisplayItems(r.messages);
|
|
933
1142
|
text += `\n\n${theme.fg("muted", `─── Step ${r.step}: `)}${theme.fg("accent", r.agent)} ${rIcon}`;
|
|
934
|
-
if (displayItems.length === 0)
|
|
935
|
-
|
|
1143
|
+
if (displayItems.length === 0) {
|
|
1144
|
+
const failed = isFailedResult(r);
|
|
1145
|
+
const summary = failed ? getFailureSummary(r) : "(no output)";
|
|
1146
|
+
text += `\n${theme.fg(failed ? "error" : "muted", summary)}`;
|
|
1147
|
+
} else {
|
|
1148
|
+
text += `\n${renderDisplayItems(displayItems, 5)}`;
|
|
1149
|
+
}
|
|
936
1150
|
}
|
|
937
1151
|
const usageStr = formatUsageStats(aggregateUsage(details.results));
|
|
938
1152
|
if (usageStr) text += `\n\n${theme.fg("dim", `Total: ${usageStr}`)}`;
|
|
@@ -941,17 +1155,16 @@ export default function (pi: ExtensionAPI) {
|
|
|
941
1155
|
}
|
|
942
1156
|
|
|
943
1157
|
if (details.mode === "parallel") {
|
|
944
|
-
const running = details.results.filter((
|
|
945
|
-
const
|
|
946
|
-
const
|
|
947
|
-
const
|
|
948
|
-
const
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
: theme.fg("success", "✓");
|
|
1158
|
+
const running = details.results.filter((result) => result.status === "running").length;
|
|
1159
|
+
const pending = details.results.filter((result) => result.status === "pending").length;
|
|
1160
|
+
const successCount = details.results.filter((result) => result.status === "completed").length;
|
|
1161
|
+
const failCount = details.results.filter(isFailedResult).length;
|
|
1162
|
+
const isRunning = running > 0 || pending > 0;
|
|
1163
|
+
let icon = theme.fg("success", "✓");
|
|
1164
|
+
if (isRunning) icon = theme.fg("warning", "⏳");
|
|
1165
|
+
else if (failCount > 0) icon = theme.fg("warning", "◐");
|
|
953
1166
|
const status = isRunning
|
|
954
|
-
? `${successCount + failCount}/${details.results.length} done, ${running} running`
|
|
1167
|
+
? `${successCount + failCount}/${details.results.length} done, ${running} running, ${pending} pending`
|
|
955
1168
|
: `${successCount}/${details.results.length} tasks`;
|
|
956
1169
|
|
|
957
1170
|
if (expanded && !isRunning) {
|
|
@@ -965,7 +1178,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
965
1178
|
);
|
|
966
1179
|
|
|
967
1180
|
for (const r of details.results) {
|
|
968
|
-
const rIcon =
|
|
1181
|
+
const rIcon = resultIcon(r);
|
|
969
1182
|
const displayItems = getDisplayItems(r.messages);
|
|
970
1183
|
const finalOutput = getFinalOutput(r.messages);
|
|
971
1184
|
|
|
@@ -974,6 +1187,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
974
1187
|
new Text(`${theme.fg("muted", "─── ") + theme.fg("accent", r.agent)} ${rIcon}`, 0, 0),
|
|
975
1188
|
);
|
|
976
1189
|
container.addChild(new Text(theme.fg("muted", "Task: ") + theme.fg("dim", r.task), 0, 0));
|
|
1190
|
+
if (isFailedResult(r) && r.errorMessage)
|
|
1191
|
+
container.addChild(new Text(theme.fg("error", `Error: ${r.errorMessage}`), 0, 0));
|
|
1192
|
+
if (r.terminationSignal)
|
|
1193
|
+
container.addChild(new Text(theme.fg("error", `Signal: ${r.terminationSignal}`), 0, 0));
|
|
1194
|
+
if (r.stderr.trim())
|
|
1195
|
+
container.addChild(new Text(theme.fg("error", `stderr: ${r.stderr.trim()}`), 0, 0));
|
|
977
1196
|
|
|
978
1197
|
// Show tool calls
|
|
979
1198
|
for (const item of displayItems) {
|
|
@@ -1009,17 +1228,19 @@ export default function (pi: ExtensionAPI) {
|
|
|
1009
1228
|
// Collapsed view (or still running)
|
|
1010
1229
|
let text = `${icon} ${theme.fg("toolTitle", theme.bold("parallel "))}${theme.fg("accent", status)}`;
|
|
1011
1230
|
for (const r of details.results) {
|
|
1012
|
-
const rIcon =
|
|
1013
|
-
r.exitCode === -1
|
|
1014
|
-
? theme.fg("warning", "⏳")
|
|
1015
|
-
: isFailedResult(r)
|
|
1016
|
-
? theme.fg("error", "✗")
|
|
1017
|
-
: theme.fg("success", "✓");
|
|
1231
|
+
const rIcon = resultIcon(r);
|
|
1018
1232
|
const displayItems = getDisplayItems(r.messages);
|
|
1019
1233
|
text += `\n\n${theme.fg("muted", "─── ")}${theme.fg("accent", r.agent)} ${rIcon}`;
|
|
1020
|
-
if (displayItems.length === 0)
|
|
1021
|
-
|
|
1022
|
-
|
|
1234
|
+
if (displayItems.length === 0) {
|
|
1235
|
+
const failed = isFailedResult(r);
|
|
1236
|
+
let summary = "(no output)";
|
|
1237
|
+
if (r.status === "pending") summary = "(pending...)";
|
|
1238
|
+
else if (r.status === "running") summary = "(running...)";
|
|
1239
|
+
else if (failed) summary = getFailureSummary(r);
|
|
1240
|
+
text += `\n${theme.fg(failed ? "error" : "muted", summary)}`;
|
|
1241
|
+
} else {
|
|
1242
|
+
text += `\n${renderDisplayItems(displayItems, 5)}`;
|
|
1243
|
+
}
|
|
1023
1244
|
}
|
|
1024
1245
|
if (!isRunning) {
|
|
1025
1246
|
const usageStr = formatUsageStats(aggregateUsage(details.results));
|