zidane 7.2.5 → 8.0.4
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/LICENSE +21 -0
- package/README.md +34 -6
- package/dist/{acp-D-tVyUjw.js → acp-DQDhi2dj.js} +230 -77
- package/dist/acp-DQDhi2dj.js.map +1 -0
- package/dist/acp-cli.d.ts +1 -1
- package/dist/acp-cli.js +9 -66
- package/dist/acp-cli.js.map +1 -1
- package/dist/acp.d.ts +10 -590
- package/dist/acp.d.ts.map +1 -1
- package/dist/acp.js +3 -3
- package/dist/{agent-D0zZnGbt.js → agent-DSLNmBp0.js} +14401 -13214
- package/dist/agent-DSLNmBp0.js.map +1 -0
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +3 -2
- package/dist/aliasing-lVFbm81n.js +217 -0
- package/dist/aliasing-lVFbm81n.js.map +1 -0
- package/dist/{anthropic-C2aole0G.js → anthropic-CD00LhUP.js} +1442 -1264
- package/dist/anthropic-CD00LhUP.js.map +1 -0
- package/dist/artifacts-CV2hUKnL.js.map +1 -1
- package/dist/{atomic-write-B7zr1ddF.js → atomic-write-Ijgf2Mhc.js} +13 -3
- package/dist/atomic-write-Ijgf2Mhc.js.map +1 -0
- package/dist/call-tool-dHlbGOIY.js +70 -0
- package/dist/call-tool-dHlbGOIY.js.map +1 -0
- package/dist/chat/pure.d.ts +372 -6
- package/dist/chat/pure.d.ts.map +1 -1
- package/dist/chat/pure.js +35 -244
- package/dist/chat/pure.js.map +1 -1
- package/dist/{approvals-DKaJZYlm.js → chat-JPJJ8uu5.js} +15879 -14631
- package/dist/chat-JPJJ8uu5.js.map +1 -0
- package/dist/chat.d.ts +4 -6
- package/dist/chat.js +23 -12
- package/dist/cli-shared-C-YCaglL.js +159 -0
- package/dist/cli-shared-C-YCaglL.js.map +1 -0
- package/dist/client-core-BQSyDALT.d.ts +2115 -0
- package/dist/client-core-BQSyDALT.d.ts.map +1 -0
- package/dist/codemode-worker.d.ts +1 -0
- package/dist/codemode-worker.js +155 -0
- package/dist/codemode-worker.js.map +1 -0
- package/dist/codemode.d.ts +352 -0
- package/dist/codemode.d.ts.map +1 -0
- package/dist/codemode.js +5 -0
- package/dist/connection-Dr-Js4yZ.d.ts +28 -0
- package/dist/connection-Dr-Js4yZ.d.ts.map +1 -0
- package/dist/connection-loop-gdh22LTI.js +112 -0
- package/dist/connection-loop-gdh22LTI.js.map +1 -0
- package/dist/context-segments-BHKlagL6.js +1016 -0
- package/dist/context-segments-BHKlagL6.js.map +1 -0
- package/dist/{context-transport-T_6AYIvy.js → context-transport-DSMTUsK1.js} +3 -3
- package/dist/{context-transport-T_6AYIvy.js.map → context-transport-DSMTUsK1.js.map} +1 -1
- package/dist/contexts/daytona.d.ts +19 -8
- package/dist/contexts/daytona.d.ts.map +1 -1
- package/dist/contexts/daytona.js +1 -440
- package/dist/contexts/docker.d.ts +36 -7
- package/dist/contexts/docker.d.ts.map +1 -1
- package/dist/contexts/docker.js +1 -456
- package/dist/contexts/e2b.d.ts +68 -13
- package/dist/contexts/e2b.d.ts.map +1 -1
- package/dist/contexts/e2b.js +1 -382
- package/dist/contexts/sandbox.d.ts +1 -1
- package/dist/contexts/sandbox.js +5 -0
- package/dist/contexts/sandbox.js.map +1 -1
- package/dist/{contexts-CRE9pw07.js → contexts-d7UolYot.js} +1059 -524
- package/dist/contexts-d7UolYot.js.map +1 -0
- package/dist/contexts.d.ts +3 -3
- package/dist/contexts.js +1 -1
- package/dist/cred-keys-GpBg71cP.js +105 -0
- package/dist/cred-keys-GpBg71cP.js.map +1 -0
- package/dist/{auth-BG2rVKSt.js → credentials-JttEuRON.js} +55 -206
- package/dist/credentials-JttEuRON.js.map +1 -0
- package/dist/{cursor-iojRXHF9.js → cursor-CdjaQTBW.js} +3 -3
- package/dist/{cursor-iojRXHF9.js.map → cursor-CdjaQTBW.js.map} +1 -1
- package/dist/daemon-cli.d.ts +1 -1
- package/dist/daemon-cli.js +3 -2
- package/dist/daemon-cli.js.map +1 -1
- package/dist/daytona-DG3omipZ.js +513 -0
- package/dist/daytona-DG3omipZ.js.map +1 -0
- package/dist/defaults-Cx3zvDOV.js +23 -0
- package/dist/defaults-Cx3zvDOV.js.map +1 -0
- package/dist/dispatcher-BMlu2BmZ.js +4941 -0
- package/dist/dispatcher-BMlu2BmZ.js.map +1 -0
- package/dist/docker-BZhMMJUp.js +727 -0
- package/dist/docker-BZhMMJUp.js.map +1 -0
- package/dist/e2b-CEVOdRib.js +480 -0
- package/dist/e2b-CEVOdRib.js.map +1 -0
- package/dist/edit-utils-EGosADZq.js +234 -0
- package/dist/edit-utils-EGosADZq.js.map +1 -0
- package/dist/environment-8wsKE2Ln.js +214 -0
- package/dist/environment-8wsKE2Ln.js.map +1 -0
- package/dist/eval-BNcvle_J.js +1595 -0
- package/dist/eval-BNcvle_J.js.map +1 -0
- package/dist/eval.d.ts +2 -2
- package/dist/eval.js +1 -1489
- package/dist/executor-Cx5-8yqi.js +621 -0
- package/dist/executor-Cx5-8yqi.js.map +1 -0
- package/dist/extension-authoring-DyGGmq9V.js +385 -0
- package/dist/extension-authoring-DyGGmq9V.js.map +1 -0
- package/dist/extensions.d.ts +2 -2
- package/dist/extensions.js +3 -3
- package/dist/{fetch-url-DX75gpL0.js → fetch-url-Ct2TjDWt.js} +4 -4
- package/dist/{fetch-url-DX75gpL0.js.map → fetch-url-Ct2TjDWt.js.map} +1 -1
- package/dist/{format-BF745pLL.js → format-C2NQEVUH.js} +39 -2
- package/dist/format-C2NQEVUH.js.map +1 -0
- package/dist/format-bytes-C7tfc3Zm.js +55 -0
- package/dist/format-bytes-C7tfc3Zm.js.map +1 -0
- package/dist/headless-C_rNUuYC.js +960 -0
- package/dist/headless-C_rNUuYC.js.map +1 -0
- package/dist/headless.d.ts +1 -1
- package/dist/headless.js +1 -413
- package/dist/{history-search-C4bk1Wz_.js → history-search-CcYzF8-0.js} +7 -3
- package/dist/history-search-CcYzF8-0.js.map +1 -0
- package/dist/history-search-worker.d.ts +1 -1
- package/dist/history-search-worker.js +1 -1
- package/dist/host-D7NrI03V.js +378 -0
- package/dist/host-D7NrI03V.js.map +1 -0
- package/dist/host-signals-BcP5QKUD.js +118 -0
- package/dist/host-signals-BcP5QKUD.js.map +1 -0
- package/dist/identity-CwfO8K-t.js +26 -0
- package/dist/identity-CwfO8K-t.js.map +1 -0
- package/dist/{index-BgN1T3lk.d.ts → index-BGe1fQT7.d.ts} +10987 -9320
- package/dist/index-BGe1fQT7.d.ts.map +1 -0
- package/dist/index-BVQsIKGn.d.ts +448 -0
- package/dist/index-BVQsIKGn.d.ts.map +1 -0
- package/dist/{index-C6NEd5y_.d.ts → index-CHABJd-L.d.ts} +3386 -502
- package/dist/index-CHABJd-L.d.ts.map +1 -0
- package/dist/{index-C37_ppWv.d.ts → index-D6a7qXpg.d.ts} +2 -3
- package/dist/index-D6a7qXpg.d.ts.map +1 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +27 -23
- package/dist/{completion-core-BRo86R_L.js → inline-ghost-BVRQeGoL.js} +50 -2
- package/dist/inline-ghost-BVRQeGoL.js.map +1 -0
- package/dist/ipc/remote.d.ts +313 -0
- package/dist/ipc/remote.d.ts.map +1 -0
- package/dist/ipc/remote.js +4 -0
- package/dist/ipc.d.ts +6 -964
- package/dist/ipc.js +403 -4
- package/dist/ipc.js.map +1 -0
- package/dist/{isolation-Kfoof0MM.d.ts → isolation-D9L650W5.d.ts} +100 -15
- package/dist/isolation-D9L650W5.d.ts.map +1 -0
- package/dist/json-rpc--HXQti1E.js +350 -0
- package/dist/json-rpc--HXQti1E.js.map +1 -0
- package/dist/links-j8rED1sR.js +603 -0
- package/dist/links-j8rED1sR.js.map +1 -0
- package/dist/local-terminal-D8QThwo_.js +252 -0
- package/dist/local-terminal-D8QThwo_.js.map +1 -0
- package/dist/{logger--C1VQjwJ.js → logger-Gtqlayx8.js} +199 -173
- package/dist/logger-Gtqlayx8.js.map +1 -0
- package/dist/logs-view-CWG8aUAG.js.map +1 -1
- package/dist/{mcp-CgNd-f3F.js → mcp-_wecH9Qe.js} +608 -562
- package/dist/mcp-_wecH9Qe.js.map +1 -0
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +2 -2
- package/dist/media-sniff-UKijEaiQ.js.map +1 -1
- package/dist/{messages-2jcOA_5R.js → messages-BqiwcD2Q.js} +1017 -1014
- package/dist/messages-BqiwcD2Q.js.map +1 -0
- package/dist/{oauth-DxHO17JE.js → oauth-Px_pBB9W.js} +5 -5
- package/dist/{oauth-DxHO17JE.js.map → oauth-Px_pBB9W.js.map} +1 -1
- package/dist/{openai-compat-Dy56weK8.js → openai-compat-CFrpH7uq.js} +432 -589
- package/dist/openai-compat-CFrpH7uq.js.map +1 -0
- package/dist/orchestration-BCGmB8Ps.js +511 -0
- package/dist/orchestration-BCGmB8Ps.js.map +1 -0
- package/dist/output/stream-json.d.ts +1 -2
- package/dist/output/stream-json.d.ts.map +1 -1
- package/dist/output/stream-json.js +1 -1
- package/dist/output/terminal.d.ts +1 -2
- package/dist/output/terminal.d.ts.map +1 -1
- package/dist/output/terminal.js +13 -7
- package/dist/output/terminal.js.map +1 -1
- package/dist/{plugins-gbI7SBA6.js → plugins-DS7mahzZ.js} +20 -101
- package/dist/plugins-DS7mahzZ.js.map +1 -0
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js +1 -2
- package/dist/prelude-Cxo4t74B.js +517 -0
- package/dist/prelude-Cxo4t74B.js.map +1 -0
- package/dist/presets.d.ts +1 -1
- package/dist/presets.js +1 -2
- package/dist/project-root-B8zADr4o.js +167 -0
- package/dist/project-root-B8zADr4o.js.map +1 -0
- package/dist/project-user-paths-BSgtrRxl.js +58 -0
- package/dist/project-user-paths-BSgtrRxl.js.map +1 -0
- package/dist/{prompts-Pqc3JdW_.d.ts → prompts-DYcvqShf.d.ts} +14 -11
- package/dist/prompts-DYcvqShf.d.ts.map +1 -0
- package/dist/protocol-DnhqqSmE.js +13 -0
- package/dist/protocol-DnhqqSmE.js.map +1 -0
- package/dist/providers/anthropic.d.ts +2 -2
- package/dist/providers/anthropic.js +1 -2
- package/dist/providers/arcee.d.ts +1 -1
- package/dist/providers/arcee.js +1 -1
- package/dist/providers/baseten.d.ts +1 -1
- package/dist/providers/baseten.js +1 -1
- package/dist/providers/cerebras.d.ts +1 -1
- package/dist/providers/cerebras.js +3 -2
- package/dist/providers/cerebras.js.map +1 -1
- package/dist/providers/local.d.ts +1 -1
- package/dist/providers/local.js +1 -1
- package/dist/providers/openai-compat.d.ts +1 -1
- package/dist/providers/openai-compat.js +1 -2
- package/dist/providers/openai.d.ts +1 -1
- package/dist/providers/openai.js +15 -12
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/openrouter.d.ts +1 -1
- package/dist/providers/openrouter.js +3 -2
- package/dist/providers/openrouter.js.map +1 -1
- package/dist/providers/xai.d.ts +1 -1
- package/dist/providers/xai.js +3 -3
- package/dist/{providers-BVhnFyiY.js → providers-XUR7F4Hi.js} +4 -4
- package/dist/{providers-BVhnFyiY.js.map → providers-XUR7F4Hi.js.map} +1 -1
- package/dist/providers.d.ts +1 -1
- package/dist/providers.js +4 -4
- package/dist/registry-D6ShBWJU.js +5234 -0
- package/dist/registry-D6ShBWJU.js.map +1 -0
- package/dist/remote-hosts-BtA_9ZGp.js +97 -0
- package/dist/remote-hosts-BtA_9ZGp.js.map +1 -0
- package/dist/restate.d.ts +2 -3
- package/dist/restate.d.ts.map +1 -1
- package/dist/restate.js +631 -572
- package/dist/restate.js.map +1 -1
- package/dist/run-summary-CklLiZ4y.js +288 -0
- package/dist/run-summary-CklLiZ4y.js.map +1 -0
- package/dist/{sandbox-BH0WQkXn.d.ts → sandbox-C5dR5DwQ.d.ts} +6 -3
- package/dist/sandbox-C5dR5DwQ.d.ts.map +1 -0
- package/dist/session/sqlite.d.ts +1 -2
- package/dist/session/sqlite.d.ts.map +1 -1
- package/dist/session/sqlite.js +1 -616
- package/dist/session-factory-BUGY5P40.js +1576 -0
- package/dist/session-factory-BUGY5P40.js.map +1 -0
- package/dist/{session-BqRP1hS7.js → session-xh9JXu6i.js} +94 -52
- package/dist/session-xh9JXu6i.js.map +1 -0
- package/dist/session.d.ts +1 -1
- package/dist/session.js +2 -2
- package/dist/settings-keys-Ckf29NeM.js +677 -0
- package/dist/settings-keys-Ckf29NeM.js.map +1 -0
- package/dist/shell-path-Dqaoow2J.js +412 -0
- package/dist/shell-path-Dqaoow2J.js.map +1 -0
- package/dist/{skills-BC3dodWp.js → skills-DKqZJm4X.js} +430 -470
- package/dist/skills-DKqZJm4X.js.map +1 -0
- package/dist/skills.d.ts +2 -2
- package/dist/skills.js +1 -2
- package/dist/source-mPExaUm8.js +381 -0
- package/dist/source-mPExaUm8.js.map +1 -0
- package/dist/sqlite-DV1DQzN2.js +698 -0
- package/dist/sqlite-DV1DQzN2.js.map +1 -0
- package/dist/{src-CkNQKFKr.js → src-BRMYRJib.js} +903 -1121
- package/dist/src-BRMYRJib.js.map +1 -0
- package/dist/{stdio-DPpBDPx5.js → stdio-C6YyoW3I.js} +4 -4
- package/dist/{stdio-DPpBDPx5.js.map → stdio-C6YyoW3I.js.map} +1 -1
- package/dist/{stdio-loader-Bbx19dMZ.js → stdio-loader-C830Vg-Z.js} +4 -4
- package/dist/{stdio-loader-Bbx19dMZ.js.map → stdio-loader-C830Vg-Z.js.map} +1 -1
- package/dist/system-prompt-MNVHatSD.d.ts.map +1 -1
- package/dist/timeout-DEaqslLO.d.ts.map +1 -1
- package/dist/todo-edits-Dn251YUP.js +1790 -0
- package/dist/todo-edits-Dn251YUP.js.map +1 -0
- package/dist/{turn-operations-DrbJlpq9.js → tool-formatters-IQFDrdrs.js} +1456 -2120
- package/dist/tool-formatters-IQFDrdrs.js.map +1 -0
- package/dist/tool-state-Dku6YqAB.js +989 -0
- package/dist/tool-state-Dku6YqAB.js.map +1 -0
- package/dist/tools/fetch-url.d.ts +1 -2
- package/dist/tools/fetch-url.d.ts.map +1 -1
- package/dist/tools/fetch-url.js +1 -2
- package/dist/tools/prompts.d.ts +1 -1
- package/dist/tools/prompts.js +7 -7
- package/dist/tools/prompts.js.map +1 -1
- package/dist/tools/web-search.d.ts +1 -2
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +2 -2
- package/dist/tools/web-search.js.map +1 -1
- package/dist/tools-_DnT3AGM.js +578 -0
- package/dist/tools-_DnT3AGM.js.map +1 -0
- package/dist/tools.d.ts +3 -3
- package/dist/tools.js +4 -2
- package/dist/tui.d.ts +534 -517
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +34933 -27243
- package/dist/tui.js.map +1 -1
- package/dist/turn-operations-B8sokwi5.js +333 -0
- package/dist/turn-operations-B8sokwi5.js.map +1 -0
- package/dist/turn-operations-DQX5ZZni.d.ts +3089 -0
- package/dist/turn-operations-DQX5ZZni.d.ts.map +1 -0
- package/dist/types-C7ZFOztE.d.ts +132 -0
- package/dist/types-C7ZFOztE.d.ts.map +1 -0
- package/dist/types-CH5XpIHw.js +114 -0
- package/dist/types-CH5XpIHw.js.map +1 -0
- package/dist/{types-CWgENVLY.js → types-Cu0ZGDu9.js} +10 -6
- package/dist/types-Cu0ZGDu9.js.map +1 -0
- package/dist/types-IqegbJEE.d.ts +624 -0
- package/dist/types-IqegbJEE.d.ts.map +1 -0
- package/dist/types.d.ts +4 -4
- package/dist/types.js +1 -1
- package/dist/url-D8HCl65b.js +1259 -0
- package/dist/url-D8HCl65b.js.map +1 -0
- package/dist/wasm-BVT-j5cl.js +33 -0
- package/dist/wasm-BVT-j5cl.js.map +1 -0
- package/dist/workspace-exec-stream-SV2R9d5S.js +355 -0
- package/dist/workspace-exec-stream-SV2R9d5S.js.map +1 -0
- package/dist/ws-CIHMvlSh.js +952 -0
- package/dist/ws-CIHMvlSh.js.map +1 -0
- package/dist/ws-client-N7NxzvQp.js +230 -0
- package/dist/ws-client-N7NxzvQp.js.map +1 -0
- package/dist/{xai-CazjStOK.js → xai-CvJTeLrI.js} +165 -5
- package/dist/xai-CvJTeLrI.js.map +1 -0
- package/dist/xdg-zweed0-t.js +117 -0
- package/dist/xdg-zweed0-t.js.map +1 -0
- package/docs/ACP.md +52 -0
- package/docs/ARCHITECTURE.md +103 -6
- package/docs/ARTIFACTS.md +8 -4
- package/docs/CHAT.md +165 -14
- package/docs/EXECUTION_CONTEXT.md +8 -0
- package/docs/EXTENSIONS.md +123 -2
- package/docs/HEADLESS.md +2 -0
- package/docs/IPC.md +775 -64
- package/docs/MACHINES.md +456 -0
- package/docs/PANELS.md +3 -0
- package/docs/README.md +4 -0
- package/docs/RESTATE.md +3 -2
- package/docs/RUN_IN_BACKGROUND.md +10 -2
- package/docs/SERVER.md +1085 -0
- package/docs/SKILL.md +6 -1
- package/docs/TERMINAL.md +75 -0
- package/docs/TUI.md +65 -14
- package/package.json +58 -26
- package/scripts/eval.ts +4 -0
- package/dist/acp-D-tVyUjw.js.map +0 -1
- package/dist/agent-D0zZnGbt.js.map +0 -1
- package/dist/anthropic-C2aole0G.js.map +0 -1
- package/dist/approvals-DKaJZYlm.js.map +0 -1
- package/dist/atomic-write-B7zr1ddF.js.map +0 -1
- package/dist/auth-BG2rVKSt.js.map +0 -1
- package/dist/completion-core-BRo86R_L.js.map +0 -1
- package/dist/contexts/daytona.js.map +0 -1
- package/dist/contexts/docker.js.map +0 -1
- package/dist/contexts/e2b.js.map +0 -1
- package/dist/contexts-CRE9pw07.js.map +0 -1
- package/dist/eval.js.map +0 -1
- package/dist/format-BF745pLL.js.map +0 -1
- package/dist/glob-DluQFSw1.js +0 -270
- package/dist/glob-DluQFSw1.js.map +0 -1
- package/dist/headless.js.map +0 -1
- package/dist/history-search-C4bk1Wz_.js.map +0 -1
- package/dist/index-BgN1T3lk.d.ts.map +0 -1
- package/dist/index-C37_ppWv.d.ts.map +0 -1
- package/dist/index-C6NEd5y_.d.ts.map +0 -1
- package/dist/ipc-BKVIIOqH.js +0 -331
- package/dist/ipc-BKVIIOqH.js.map +0 -1
- package/dist/ipc.d.ts.map +0 -1
- package/dist/isolation-Kfoof0MM.d.ts.map +0 -1
- package/dist/json-rpc-rSWMUh9b.js +0 -192
- package/dist/json-rpc-rSWMUh9b.js.map +0 -1
- package/dist/logger--C1VQjwJ.js.map +0 -1
- package/dist/mcp-CgNd-f3F.js.map +0 -1
- package/dist/messages-2jcOA_5R.js.map +0 -1
- package/dist/openai-compat-Dy56weK8.js.map +0 -1
- package/dist/output-cap-C9zukcCj.js +0 -100
- package/dist/output-cap-C9zukcCj.js.map +0 -1
- package/dist/panels-B6gRk4bf.js +0 -789
- package/dist/panels-B6gRk4bf.js.map +0 -1
- package/dist/plugins-gbI7SBA6.js.map +0 -1
- package/dist/prompts-Pqc3JdW_.d.ts.map +0 -1
- package/dist/run-summary-BU_NgwUT.js +0 -269
- package/dist/run-summary-BU_NgwUT.js.map +0 -1
- package/dist/sandbox-BH0WQkXn.d.ts.map +0 -1
- package/dist/session/sqlite.js.map +0 -1
- package/dist/session-BqRP1hS7.js.map +0 -1
- package/dist/shell-path-DfdXrGg9.js +0 -1549
- package/dist/shell-path-DfdXrGg9.js.map +0 -1
- package/dist/skills-BC3dodWp.js.map +0 -1
- package/dist/src-CkNQKFKr.js.map +0 -1
- package/dist/todo-edits-UOwgxGKu.js +0 -528
- package/dist/todo-edits-UOwgxGKu.js.map +0 -1
- package/dist/tool-formatters-DoRLnfuD.d.ts +0 -759
- package/dist/tool-formatters-DoRLnfuD.d.ts.map +0 -1
- package/dist/transcript-anchors-BeudMbXx.d.ts +0 -1762
- package/dist/transcript-anchors-BeudMbXx.d.ts.map +0 -1
- package/dist/turn-operations-C8bMBDl_.d.ts +0 -1258
- package/dist/turn-operations-C8bMBDl_.d.ts.map +0 -1
- package/dist/turn-operations-DrbJlpq9.js.map +0 -1
- package/dist/types-CWgENVLY.js.map +0 -1
- package/dist/xai-CazjStOK.js.map +0 -1
|
@@ -1,1258 +0,0 @@
|
|
|
1
|
-
import { Bv as SkillConfig, Dd as EditOutcome, Jm as CacheBreakInfo, Ld as StreamEvent, Md as Owner, Qu as CompletionReference, U_ as SessionTurn, Zu as CompletionProvider, dv as TurnUsage, kd as EditPayload, nv as ToolResultContent, od as Command, qv as Session, t as Preset } from "./index-BgN1T3lk.js";
|
|
2
|
-
import { V as ApprovalDecision } from "./tool-formatters-DoRLnfuD.js";
|
|
3
|
-
|
|
4
|
-
//#region src/chat/color-gradient.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Blend two hex colors in HSL space with shortest-path hue interpolation.
|
|
7
|
-
* `t` ∈ [0, 1]; `t=0` returns `from`, `t=1` returns `to`.
|
|
8
|
-
*/
|
|
9
|
-
declare function blendHsl(from: string, to: string, t: number): string;
|
|
10
|
-
/**
|
|
11
|
-
* Static gradient ramp of length `n` going from `from` (index 0) to
|
|
12
|
-
* `to` (index n-1) in HSL space. For the cycling A→B→A→B ramp the
|
|
13
|
-
* throbber uses, see `buildCycleRamp` in `src/tui/crush-throbber.tsx`.
|
|
14
|
-
*/
|
|
15
|
-
declare function buildLinearRamp(from: string, to: string, n: number): string[];
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/chat/completion-chats.d.ts
|
|
18
|
-
declare const CHATS_TRIGGER = "#";
|
|
19
|
-
type ChatReferenceScope = 'project' | 'all';
|
|
20
|
-
interface ChatReferenceEntry {
|
|
21
|
-
id: string;
|
|
22
|
-
title: string;
|
|
23
|
-
turnCount: number;
|
|
24
|
-
userMessageCount: number;
|
|
25
|
-
runCount: number;
|
|
26
|
-
projectRoot?: string;
|
|
27
|
-
updatedAt: number;
|
|
28
|
-
/** Optional (store-dependent); shown as a hint when > 0. */
|
|
29
|
-
artifactCount?: number;
|
|
30
|
-
}
|
|
31
|
-
interface ChatReferenceData {
|
|
32
|
-
entry: ChatReferenceEntry;
|
|
33
|
-
token: string;
|
|
34
|
-
}
|
|
35
|
-
declare function createChatsCompletionProvider(opts: {
|
|
36
|
-
getCatalog: () => readonly ChatReferenceEntry[];
|
|
37
|
-
getReferenceCatalog?: () => readonly ChatReferenceEntry[];
|
|
38
|
-
getScope?: () => ChatReferenceScope;
|
|
39
|
-
ensureCatalog?: () => Promise<readonly ChatReferenceEntry[]>;
|
|
40
|
-
limit?: number;
|
|
41
|
-
}): CompletionProvider<ChatReferenceData>;
|
|
42
|
-
declare function uniqueChatIdsFromReferences(references: readonly CompletionReference<unknown>[]): string[];
|
|
43
|
-
declare function chatReferenceTokensFromText(text: string): string[];
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region src/chat/completion-commands.d.ts
|
|
46
|
-
/** Trigger character — shared with skills. */
|
|
47
|
-
declare const COMMANDS_TRIGGER = "/";
|
|
48
|
-
/**
|
|
49
|
-
* Build a commands completion provider against a *live* command list. The
|
|
50
|
-
* getter is re-evaluated per `suggest` so registry toggles / cwd rebuilds
|
|
51
|
-
* take effect without re-instantiating the provider.
|
|
52
|
-
*/
|
|
53
|
-
declare function createCommandsCompletionProvider(opts: {
|
|
54
|
-
getCommands: () => readonly Command[];
|
|
55
|
-
}): CompletionProvider<Command>;
|
|
56
|
-
//#endregion
|
|
57
|
-
//#region src/chat/files-discovery.d.ts
|
|
58
|
-
/**
|
|
59
|
-
* Project file discovery for the `@`-prefixed files completion provider.
|
|
60
|
-
*
|
|
61
|
-
* Primary strategy — `git ls-files --cached --others --exclude-standard`.
|
|
62
|
-
* Git already understands `.gitignore`, `.git/info/exclude`, and global
|
|
63
|
-
* excludes, so we get correctness for free + sub-second performance on
|
|
64
|
-
* even huge monorepos. Falls back to a depth-limited filesystem walk when
|
|
65
|
-
* git isn't available or the directory isn't a repo.
|
|
66
|
-
*
|
|
67
|
-
* Pure: callers cache the returned list (e.g. in App state) and pass it
|
|
68
|
-
* into the provider's `getCatalog`. The list is a snapshot — refresh on
|
|
69
|
-
* cwd change or via a user-driven action.
|
|
70
|
-
*/
|
|
71
|
-
/** One row in the project file catalog. `path` is forward-slashed + relative to `cwd`. */
|
|
72
|
-
interface FileEntry {
|
|
73
|
-
/** Forward-slashed relative path from the discovery cwd. Stable across OSes. No trailing slash for dirs. */
|
|
74
|
-
path: string;
|
|
75
|
-
/** Basename — used for prefix ranking in the completion provider. */
|
|
76
|
-
name: string;
|
|
77
|
-
/** Source — `git` when listed via `git ls-files`, `fs` from the walk fallback. */
|
|
78
|
-
source: 'git' | 'fs';
|
|
79
|
-
/**
|
|
80
|
-
* Entry kind. Directories are derived from the discovered file paths
|
|
81
|
-
* (every ancestor of a listed file), so only directories that contain
|
|
82
|
-
* at least one non-ignored file appear — mirroring `git ls-files`
|
|
83
|
-
* semantics, which never lists empty or fully-ignored dirs.
|
|
84
|
-
*/
|
|
85
|
-
kind: 'file' | 'dir';
|
|
86
|
-
}
|
|
87
|
-
/** Options for `listProjectFiles`. */
|
|
88
|
-
interface ListProjectFilesOptions {
|
|
89
|
-
/** Discovery root. Default: `process.cwd()`. */
|
|
90
|
-
cwd?: string;
|
|
91
|
-
/**
|
|
92
|
-
* Cap on discovered files. Default: 10,000. Bigger lists fall back to
|
|
93
|
-
* a truncated set. Derived directory entries are appended on top with
|
|
94
|
-
* their own equal cap, so the returned array can exceed `maxFiles`
|
|
95
|
-
* (bounded by 2×).
|
|
96
|
-
*/
|
|
97
|
-
maxFiles?: number;
|
|
98
|
-
/** Aborts the scan early. Useful when re-running on rapid project switches. */
|
|
99
|
-
signal?: AbortSignal;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Discover every non-ignored file under `cwd`, plus the directories that
|
|
103
|
-
* contain them (derived from the file paths, `kind: 'dir'`). Tries
|
|
104
|
-
* `git ls-files` first; on failure (no git, not a repo, abort) walks the
|
|
105
|
-
* fs with a hand-rolled skip list.
|
|
106
|
-
*
|
|
107
|
-
* Errors are not thrown — the function always returns an array (possibly
|
|
108
|
-
* empty). Callers wanting failure diagnostics can opt into them via
|
|
109
|
-
* `ZIDANE_DEBUG`.
|
|
110
|
-
*/
|
|
111
|
-
declare function listProjectFiles(opts?: ListProjectFilesOptions): Promise<FileEntry[]>;
|
|
112
|
-
//#endregion
|
|
113
|
-
//#region src/chat/completion-files.d.ts
|
|
114
|
-
/** Trigger character — `@` is the conventional file-mention prefix in chat UIs. */
|
|
115
|
-
declare const FILES_TRIGGER = "@";
|
|
116
|
-
/**
|
|
117
|
-
* Build an `@`-prefixed files completion provider against a *live* catalog.
|
|
118
|
-
*
|
|
119
|
-
* The factory captures a getter so the catalog can be re-scanned (cwd
|
|
120
|
-
* change, manual refresh) without re-instantiating the provider — the
|
|
121
|
-
* App keeps one provider for the lifetime of the prompt block and just
|
|
122
|
-
* mutates the underlying state.
|
|
123
|
-
*
|
|
124
|
-
* `limit` caps the result list so the popover stays bounded on huge
|
|
125
|
-
* monorepos. Filtering is substring on `path` + `name`, case-insensitive,
|
|
126
|
-
* with an fzf-scored basename fuzzy fallback so small typos / omissions
|
|
127
|
-
* (`lop.ts` → `loop.ts`) still surface results; ranking prefers (in
|
|
128
|
-
* order): exact name match, name prefix, name substring, path substring,
|
|
129
|
-
* basename fuzzy match, alphabetical.
|
|
130
|
-
*/
|
|
131
|
-
declare function createFilesCompletionProvider(opts: {
|
|
132
|
-
/** Live file catalog. Re-evaluated per call so refreshes take effect immediately. */getCatalog: () => readonly FileEntry[];
|
|
133
|
-
/**
|
|
134
|
-
* Optional hook called the first time the host needs the catalog —
|
|
135
|
-
* e.g. when the user opens the `@` popover. Hosts wire this to a
|
|
136
|
-
* lazy directory walk so boot doesn't pay for it in monorepos
|
|
137
|
-
* where the popover may never open. Idempotent contract: callers
|
|
138
|
-
* may invoke it on every `suggest`; the host caches internally.
|
|
139
|
-
*
|
|
140
|
-
* When provided, `suggest()` returns a Promise on the very first
|
|
141
|
-
* invocation if the catalog is still empty — the popover's loading
|
|
142
|
-
* state surfaces while the walk completes; subsequent calls are
|
|
143
|
-
* sync because `getCatalog()` then returns the populated state.
|
|
144
|
-
*/
|
|
145
|
-
ensureCatalog?: () => Promise<readonly FileEntry[]>; /** Max items returned to the popover. Default: 50. */
|
|
146
|
-
limit?: number;
|
|
147
|
-
/**
|
|
148
|
-
* Rewrite the catalog's project-root-relative path into the form
|
|
149
|
-
* inserted into the prompt + matched by `parseReferences`. Wire this
|
|
150
|
-
* to `formatPathForCwd` so paths emitted into the buffer line up
|
|
151
|
-
* with the agent's CWD-resolving tools when the TUI launches from a
|
|
152
|
-
* project subdirectory. Default: identity.
|
|
153
|
-
*
|
|
154
|
-
* Stable identity expected — `parseReferences` calls it once per
|
|
155
|
-
* catalog entry per keystroke for the highlight pass; pure
|
|
156
|
-
* pure-function shape keeps the popover responsive on huge repos.
|
|
157
|
-
*/
|
|
158
|
-
formatPath?: (entry: FileEntry) => string;
|
|
159
|
-
}): CompletionProvider<FileEntry>;
|
|
160
|
-
/**
|
|
161
|
-
* Walk a reference list and return the deduplicated set of files in
|
|
162
|
-
* first-mention order — input to "attach these files to the prompt"
|
|
163
|
-
* downstream logic.
|
|
164
|
-
*/
|
|
165
|
-
declare function uniqueFilesFromReferences(references: readonly CompletionReference<unknown>[]): FileEntry[];
|
|
166
|
-
//#endregion
|
|
167
|
-
//#region src/chat/completion-skills.d.ts
|
|
168
|
-
/** Trigger character — slash-commands convention. */
|
|
169
|
-
declare const SKILLS_TRIGGER = "/";
|
|
170
|
-
/**
|
|
171
|
-
* Build a slash-command completion provider against a *live* skills
|
|
172
|
-
* catalog. The factory captures a getter so the catalog can change across
|
|
173
|
-
* renders (toggles, reload) without re-instantiating the provider.
|
|
174
|
-
*
|
|
175
|
-
* Pass `getEnabled` to additionally hide skills the user has toggled off
|
|
176
|
-
* — when undefined, every catalog entry is offered.
|
|
177
|
-
*/
|
|
178
|
-
declare function createSkillsCompletionProvider(opts: {
|
|
179
|
-
/** Live catalog. Re-evaluated per call so toggles take effect immediately. */getCatalog: () => readonly SkillConfig[]; /** Optional enable-set filter; when undefined every catalog skill is offered. */
|
|
180
|
-
getEnabled?: () => readonly string[] | undefined;
|
|
181
|
-
/**
|
|
182
|
-
* Optional hook called the first time the host needs the catalog —
|
|
183
|
-
* typically when the user opens the `/` popover. Mirror of the
|
|
184
|
-
* files provider's `ensureCatalog`; same idempotent contract.
|
|
185
|
-
*
|
|
186
|
-
* Hosts wire this to a lazy SKILL.md scan so the boot path stays
|
|
187
|
-
* free of disk reads in deeply-nested skill trees. Returns a Promise
|
|
188
|
-
* on the very first `suggest()` call when the catalog is still
|
|
189
|
-
* empty so the popover surfaces its loading state.
|
|
190
|
-
*/
|
|
191
|
-
ensureCatalog?: () => Promise<readonly SkillConfig[]>;
|
|
192
|
-
}): CompletionProvider<SkillConfig>;
|
|
193
|
-
/**
|
|
194
|
-
* Walk a parsed prompt for skill references and return the deduplicated
|
|
195
|
-
* list of skill names — input to `agent.activateSkill(name)` calls on
|
|
196
|
-
* submit.
|
|
197
|
-
*/
|
|
198
|
-
declare function uniqueSkillNamesFromReferences(references: readonly CompletionReference<unknown>[]): string[];
|
|
199
|
-
//#endregion
|
|
200
|
-
//#region src/chat/edit-approval.d.ts
|
|
201
|
-
/**
|
|
202
|
-
* Convert a per-hunk approval mask into an `EditOutcome[]`. `true` →
|
|
203
|
-
* `applied`; `false` → `denied` with the supplied reason.
|
|
204
|
-
*
|
|
205
|
-
* Length is `Math.max(mask.length, fallbackLength)` so callers passing a
|
|
206
|
-
* shorter mask still get a fully-populated array — missing entries
|
|
207
|
-
* default to applied, matching the "no decision => keep" convention.
|
|
208
|
-
*/
|
|
209
|
-
declare function maskToOutcomeKinds(mask: readonly boolean[], fallbackLength: number, deniedReason?: string): EditOutcome[];
|
|
210
|
-
/**
|
|
211
|
-
* Apply an `ApprovalDecision` to a payload, returning the resolved
|
|
212
|
-
* per-hunk outcomes + the gate-level verdict.
|
|
213
|
-
*
|
|
214
|
-
* Pure — does not mutate `input` or `payload`. The TUI's `applyGate`
|
|
215
|
-
* consumes the result: stashes `outcomes` in the pending-annotation map
|
|
216
|
-
* (keyed by callId) so `tool:transform` can append the
|
|
217
|
-
* `<edit-outcomes>` block to the tool result, rebinds `ctx.input.edits`
|
|
218
|
-
* to the approved subset for `partial`, and emits the `syntheticEvent`
|
|
219
|
-
* for fully-denied or fully-blocked calls.
|
|
220
|
-
*/
|
|
221
|
-
interface ResolvedApproval {
|
|
222
|
-
/** Final state of every hunk after the decision (1:1 with payload.hunks). */
|
|
223
|
-
outcomes: EditOutcome[];
|
|
224
|
-
/** True when no hunk will be applied — gate should `block` the call. */
|
|
225
|
-
shouldBlock: boolean;
|
|
226
|
-
/**
|
|
227
|
-
* Synthetic `EditPayload` to render in the transcript. Identical to the
|
|
228
|
-
* incoming payload but with `outcomes` set so the renderer can badge
|
|
229
|
-
* each hunk. Only meaningful when at least one hunk was denied —
|
|
230
|
-
* an all-applied decision returns `null` here and the normal
|
|
231
|
-
* `tool:before` event suffices.
|
|
232
|
-
*/
|
|
233
|
-
syntheticEvent: EditPayload | null;
|
|
234
|
-
}
|
|
235
|
-
declare function resolveApprovalForPayload(decision: ApprovalDecision, payload: EditPayload): ResolvedApproval;
|
|
236
|
-
/**
|
|
237
|
-
* Render an `EditOutcome[]` as the wire-format annotation block. Returns
|
|
238
|
-
* the body to APPEND to a tool result; callers join with a leading
|
|
239
|
-
* `\n\n` separator. Idempotent on missing reasons — bare `applied` lines
|
|
240
|
-
* stay terse.
|
|
241
|
-
*/
|
|
242
|
-
declare function buildEditOutcomesAnnotation(outcomes: readonly EditOutcome[]): string;
|
|
243
|
-
/**
|
|
244
|
-
* Parse an `<edit-outcomes>…</edit-outcomes>` annotation block out of a
|
|
245
|
-
* tool result body. Returns the outcomes keyed by 1-based hunk index, or
|
|
246
|
-
* `null` when the block is missing / malformed.
|
|
247
|
-
*
|
|
248
|
-
* Anchored on the explicit tag pair so the parser doesn't false-positive
|
|
249
|
-
* on natural prose that happens to contain `#1 applied`.
|
|
250
|
-
*/
|
|
251
|
-
declare function parseEditOutcomesFromResult(result: string | readonly ToolResultContent[]): EditOutcome[] | null;
|
|
252
|
-
/**
|
|
253
|
-
* Strip the first `<edit-outcomes>…</edit-outcomes>` block out of a tool
|
|
254
|
-
* result body, returning the surrounding text. Used by the
|
|
255
|
-
* `tool:transform` hook to peel a body-emitted annotation before
|
|
256
|
-
* re-appending the merged (approval ∪ body) version — otherwise the
|
|
257
|
-
* result would carry two annotation blocks and
|
|
258
|
-
* {@link parseEditOutcomesFromResult} would only see the first.
|
|
259
|
-
*
|
|
260
|
-
* Anchored on the same `\n<edit-outcomes>\n` / start-of-string newline
|
|
261
|
-
* shape the parser uses, so prose that incidentally mentions
|
|
262
|
-
* `<edit-outcomes>` (e.g. a model summarizing its own format) isn't
|
|
263
|
-
* mistakenly stripped. Trims a single leading `\n\n` separator when
|
|
264
|
-
* present so successive strips don't leave dangling blank lines.
|
|
265
|
-
* Idempotent on inputs that don't contain a properly-anchored block.
|
|
266
|
-
*/
|
|
267
|
-
declare function stripEditOutcomesAnnotation(text: string): string;
|
|
268
|
-
/**
|
|
269
|
-
* Merge body-side outcomes (keyed against the approved subset the tool
|
|
270
|
-
* actually ran on, in subset-position order) into approval-side outcomes
|
|
271
|
-
* (1:1 with the model's ORIGINAL `edits` list, with `denied` entries for
|
|
272
|
-
* every hunk the user dropped).
|
|
273
|
-
*
|
|
274
|
-
* Algorithm: walk the approval array; every `applied` placeholder
|
|
275
|
-
* corresponds to one approved hunk that the body ran. Consume body's
|
|
276
|
-
* outcomes in order against those placeholders. Non-`applied` approval
|
|
277
|
-
* entries (`denied`, `skipped`) stay untouched — they describe gate-
|
|
278
|
-
* level decisions the body never saw.
|
|
279
|
-
*
|
|
280
|
-
* Pure. Returns a fresh array; never mutates either input.
|
|
281
|
-
*
|
|
282
|
-
* Edge cases:
|
|
283
|
-
* - `body` is empty / shorter than the approved count → remaining
|
|
284
|
-
* approval `applied` placeholders stay as `applied` (the body ran
|
|
285
|
-
* happily; absence of a body entry means nothing failed).
|
|
286
|
-
* - `body` longer than approved count → trailing body entries are
|
|
287
|
-
* ignored. Shouldn't happen in practice (body sees the rebound
|
|
288
|
-
* subset), but the guard keeps the merge total-pure.
|
|
289
|
-
*/
|
|
290
|
-
declare function mergeApprovalAndBodyOutcomes(approval: readonly EditOutcome[], body: readonly EditOutcome[] | null): EditOutcome[];
|
|
291
|
-
/**
|
|
292
|
-
* Rewrite a `multi_edit` body header so the totals reflect the model's
|
|
293
|
-
* ORIGINAL edit list (the merged outcomes count) instead of the subset
|
|
294
|
-
* the body actually saw after gate rebinding. Without this, a partially
|
|
295
|
-
* approved call surfaces a misleading `applied 2 of 2 edits` (subset
|
|
296
|
-
* counts) on the wire even when the original was `applied 2 of 3`.
|
|
297
|
-
*
|
|
298
|
-
* Three body-side shapes are handled (matching `multi_edit`'s emit):
|
|
299
|
-
* 1. `Edited <path>: applied N edits (R replacements).`
|
|
300
|
-
* 2. `Edited <path>: applied N of M edits (R replacements).`
|
|
301
|
-
* 3. `multi_edit error: no edits applied to <path> (M attempted).`
|
|
302
|
-
*
|
|
303
|
-
* The replacements count is preserved verbatim — it's a body-side stat
|
|
304
|
-
* the chat layer can't recompute. When the first line doesn't look like
|
|
305
|
-
* any of the three shapes (e.g. an unrelated error preamble bubbled up),
|
|
306
|
-
* the text is returned unchanged.
|
|
307
|
-
*/
|
|
308
|
-
declare function rewriteMultiEditHeader(text: string, merged: readonly EditOutcome[], path: string): string;
|
|
309
|
-
/**
|
|
310
|
-
* Aggregate counts for the transcript's summary badge (`3 applied · 1
|
|
311
|
-
* denied · 1 skipped`). Exported so renderers don't reimplement the
|
|
312
|
-
* tally. Pure / O(n).
|
|
313
|
-
*/
|
|
314
|
-
declare function summarizeOutcomes(outcomes: readonly EditOutcome[] | undefined): {
|
|
315
|
-
applied: number;
|
|
316
|
-
denied: number;
|
|
317
|
-
skipped: number;
|
|
318
|
-
failed: number;
|
|
319
|
-
pending: number;
|
|
320
|
-
total: number;
|
|
321
|
-
};
|
|
322
|
-
//#endregion
|
|
323
|
-
//#region src/tools/edit-utils.d.ts
|
|
324
|
-
/**
|
|
325
|
-
* Locate the actual substring in `haystack` that corresponds to `needle`,
|
|
326
|
-
* recovering from typographical mismatch on six escalating fallbacks:
|
|
327
|
-
*
|
|
328
|
-
* 1. Exact substring match (the happy path — no transformation).
|
|
329
|
-
* 2. Curly-quote normalization on both sides — when the model emits straight
|
|
330
|
-
* quotes but the file has curly ones (or vice versa), the slice of the
|
|
331
|
-
* file at the matched position carries the file's actual typography.
|
|
332
|
-
* 3. Anthropic-sanitization undo on the needle — the model's `<n>` becomes
|
|
333
|
-
* the file's `<name>`, etc.
|
|
334
|
-
* 4. Combined: desanitize + quote normalization on the needle.
|
|
335
|
-
* 5. Line-number-prefix strip — when the model pasted a numbered `read_file`
|
|
336
|
-
* chunk verbatim into `old_string` and the file carries no such prefix.
|
|
337
|
-
* 6. Combined: line-number strip + quote normalization — paste-back of a
|
|
338
|
-
* numbered chunk against a file whose typography differs from the model's.
|
|
339
|
-
*
|
|
340
|
-
* Returns `{ actual, occurrences }` — `actual` is the string that exists in
|
|
341
|
-
* the file (use this to do the actual replace; preserves the file's
|
|
342
|
-
* typography). `occurrences` is the count of those matches in the file.
|
|
343
|
-
*
|
|
344
|
-
* Fallbacks 3-4 (desanitize-class) only fire when the transformed needle is
|
|
345
|
-
* UNIQUE in the file — they rewrite the needle's meaning rather than its
|
|
346
|
-
* typography, so an ambiguous match risks silently retargeting the wrong
|
|
347
|
-
* text (see the inline comment at step 3).
|
|
348
|
-
*
|
|
349
|
-
* Returns `null` when no recovery worked.
|
|
350
|
-
*/
|
|
351
|
-
interface ResolvedMatch {
|
|
352
|
-
actual: string;
|
|
353
|
-
occurrences: number;
|
|
354
|
-
/** Recovery path — `'exact'` when no transformation was applied. */
|
|
355
|
-
via: 'exact' | 'quotes' | 'desanitize' | 'quotes+desanitize' | 'line-numbers' | 'quotes+line-numbers';
|
|
356
|
-
}
|
|
357
|
-
//#endregion
|
|
358
|
-
//#region src/chat/edit-diff.d.ts
|
|
359
|
-
declare function extractEditPayload(name: string, input: Record<string, unknown>, priorContent?: string): EditPayload | undefined;
|
|
360
|
-
type DiffOp = 'context' | 'add' | 'remove';
|
|
361
|
-
interface DiffLine {
|
|
362
|
-
op: DiffOp;
|
|
363
|
-
text: string;
|
|
364
|
-
}
|
|
365
|
-
declare function computeLineDiff(oldString: string, newString: string): DiffLine[];
|
|
366
|
-
/**
|
|
367
|
-
* Split a string into lines preserving empty lines but dropping the
|
|
368
|
-
* implicit trailing `""` produced by a final `\n`. Exported only for
|
|
369
|
-
* its tests — callers should use `computeLineDiff`.
|
|
370
|
-
*/
|
|
371
|
-
declare function splitLines(s: string): string[];
|
|
372
|
-
interface InlineSegment {
|
|
373
|
-
text: string;
|
|
374
|
-
changed: boolean;
|
|
375
|
-
}
|
|
376
|
-
interface InlineDiff {
|
|
377
|
-
oldSegments: InlineSegment[];
|
|
378
|
-
newSegments: InlineSegment[];
|
|
379
|
-
}
|
|
380
|
-
declare function computeInlineDiff(oldLine: string, newLine: string): InlineDiff;
|
|
381
|
-
/**
|
|
382
|
-
* Tokenize on word / non-word boundaries. Each run of `\w+` is one
|
|
383
|
-
* token; each run of `\W+` (whitespace, punctuation) is another. This
|
|
384
|
-
* gives the right granularity for renames (`oldName` → `newName`) and
|
|
385
|
-
* for symbol swaps (`+ → -`) without exploding into per-char segments.
|
|
386
|
-
*
|
|
387
|
-
* Exported only for its tests.
|
|
388
|
-
*/
|
|
389
|
-
declare function tokenize(s: string): string[];
|
|
390
|
-
/**
|
|
391
|
-
* Apply the payload's hunks against `priorContent` and return the
|
|
392
|
-
* resulting file body. Mirrors the agent's tool-side semantics:
|
|
393
|
-
* - `replaceAll === true` → `String.replaceAll`
|
|
394
|
-
* - otherwise → first-occurrence `String.replace`
|
|
395
|
-
*
|
|
396
|
-
* Hunks are applied in order — a `multi_edit` later hunk operates on
|
|
397
|
-
* the output of the earlier ones, just like the actual tool.
|
|
398
|
-
*/
|
|
399
|
-
declare function applyEditPayload(payload: EditPayload, priorContent: string): string;
|
|
400
|
-
/**
|
|
401
|
-
* Like `buildUnifiedDiff` but operating against the full file content
|
|
402
|
-
* so the diff carries *real* file line numbers and configurable
|
|
403
|
-
* surrounding context.
|
|
404
|
-
*
|
|
405
|
-
* Strategy:
|
|
406
|
-
* 1. Apply the payload to `priorContent` → `newContent`.
|
|
407
|
-
* 2. Run `computeLineDiff` over the whole file.
|
|
408
|
-
* 3. Group non-context ops into hunks, padding each with up to
|
|
409
|
-
* `contextLines` of context above and below. Adjacent hunks
|
|
410
|
-
* whose context regions touch are merged so we don't emit two
|
|
411
|
-
* `@@` headers separated by zero context lines.
|
|
412
|
-
*
|
|
413
|
-
* The output line numbers in the `@@` header are 1-based and reflect
|
|
414
|
-
* the change's position in the actual file — what the user expects
|
|
415
|
-
* when reading a diff alongside their editor.
|
|
416
|
-
*
|
|
417
|
-
* For `write_file` creating a new file (priorContent === ''), this
|
|
418
|
-
* falls back to the same `--- /dev/null` convention as
|
|
419
|
-
* `buildUnifiedDiff`.
|
|
420
|
-
*/
|
|
421
|
-
declare function buildContextualDiff(payload: EditPayload, priorContent: string, contextLines?: number): string;
|
|
422
|
-
interface EditHunkSummary {
|
|
423
|
-
/** 1-based line number in the new file where the change starts; undefined when unknown (no priorContent). */
|
|
424
|
-
line?: number;
|
|
425
|
-
/** Number of lines added in this hunk. */
|
|
426
|
-
added: number;
|
|
427
|
-
/** Number of lines removed in this hunk. */
|
|
428
|
-
removed: number;
|
|
429
|
-
/** First removed line preview (trimmed, may be empty for pure additions). */
|
|
430
|
-
firstOld?: string;
|
|
431
|
-
/** First added line preview (trimmed, may be empty for pure deletions). */
|
|
432
|
-
firstNew?: string;
|
|
433
|
-
}
|
|
434
|
-
interface EditSummary {
|
|
435
|
-
totalAdded: number;
|
|
436
|
-
totalRemoved: number;
|
|
437
|
-
hunks: EditHunkSummary[];
|
|
438
|
-
}
|
|
439
|
-
/**
|
|
440
|
-
* Build a per-hunk digest used by the compact diff view.
|
|
441
|
-
*
|
|
442
|
-
* Strategy:
|
|
443
|
-
* - When `priorContent` is present and the payload describes a real
|
|
444
|
-
* file transformation, compute the contextual diff once, then walk
|
|
445
|
-
* the LCS ops splitting at runs of `add` / `remove` to anchor each
|
|
446
|
-
* summary entry to the **real** file line. This guarantees the
|
|
447
|
-
* summary's `L<n>` matches what the user sees in their editor.
|
|
448
|
-
* - Otherwise, fall back to per-hunk LCS over the (oldString,
|
|
449
|
-
* newString) snippet pair. Line numbers are absent because the
|
|
450
|
-
* snippet has no file position.
|
|
451
|
-
*/
|
|
452
|
-
declare function summarizeEditPayload(payload: EditPayload): EditSummary;
|
|
453
|
-
interface HunkResolution {
|
|
454
|
-
/**
|
|
455
|
-
* True when the tool body would find this hunk's `old_string` AND apply
|
|
456
|
-
* it without ambiguity. False when `resolveOldString` returned null OR
|
|
457
|
-
* the match was ambiguous (multiple occurrences and `replace_all` off).
|
|
458
|
-
*/
|
|
459
|
-
resolved: boolean;
|
|
460
|
-
/** Path the resolver took — `'exact'` when no recovery was needed. */
|
|
461
|
-
via?: ResolvedMatch['via'];
|
|
462
|
-
/** Match count in the running content for the hunk. */
|
|
463
|
-
occurrences?: number;
|
|
464
|
-
/** True when the resolver found >1 match without `replace_all`. */
|
|
465
|
-
ambiguous?: boolean;
|
|
466
|
-
}
|
|
467
|
-
interface PreviewResult {
|
|
468
|
-
/** Full unified diff of the (resolvable) hunks against `priorContent`. */
|
|
469
|
-
diffText: string;
|
|
470
|
-
/** 1:1 with `payload.hunks`. */
|
|
471
|
-
resolution: HunkResolution[];
|
|
472
|
-
/**
|
|
473
|
-
* Per-hunk isolated diff text rendered against the cumulative content
|
|
474
|
-
* after applying all earlier resolved hunks. Useful for the modal's
|
|
475
|
-
* focused-hunk view so hunk #N's preview reflects the state hunks
|
|
476
|
-
* 1..N-1 will leave the file in (same as the tool's order).
|
|
477
|
-
*/
|
|
478
|
-
perHunkDiff: string[];
|
|
479
|
-
/**
|
|
480
|
-
* Resolved hunks with `oldString` rewritten to the haystack's actual
|
|
481
|
-
* bytes and `newString` re-styled to preserve curly-quote typography
|
|
482
|
-
* / line-prefix conventions. Pass this to `buildContextualDiff` to
|
|
483
|
-
* paint the unified diff.
|
|
484
|
-
*/
|
|
485
|
-
resolvedPayload: EditPayload;
|
|
486
|
-
}
|
|
487
|
-
declare function previewEditPayload(payload: EditPayload, priorContent: string, contextLines?: number): PreviewResult;
|
|
488
|
-
declare function buildUnifiedDiff(payload: EditPayload): string;
|
|
489
|
-
declare function filetypeFromPath(path: string): string | undefined;
|
|
490
|
-
//#endregion
|
|
491
|
-
//#region src/chat/footer-chips.d.ts
|
|
492
|
-
/**
|
|
493
|
-
* `warn` = a real cache break (a named dimension changed, so it was
|
|
494
|
-
* avoidable); `dim` = ordinary TTL expiry, which is not anyone's fault and
|
|
495
|
-
* should not shout.
|
|
496
|
-
*/
|
|
497
|
-
type CacheChipTone = 'warn' | 'dim';
|
|
498
|
-
interface CacheChipContent {
|
|
499
|
-
tone: CacheChipTone;
|
|
500
|
-
/** Leading glyph. Kept out of `label` so a surface can style it separately. */
|
|
501
|
-
glyph: string;
|
|
502
|
-
label: string;
|
|
503
|
-
}
|
|
504
|
-
/**
|
|
505
|
-
* Build the chip for a cache break.
|
|
506
|
-
*
|
|
507
|
-
* `costUsd` is OPTIONAL and omitted entirely on a rate miss — never rendered
|
|
508
|
-
* as `$0.00`. A fabricated zero would read as "this was free", which is the
|
|
509
|
-
* opposite of what the chip exists to say. When present it is prefixed `~`
|
|
510
|
-
* because it is an estimate (registry rates × re-billed prefix), and clamped
|
|
511
|
-
* to `<0.01` rather than rounding a real charge down to nothing.
|
|
512
|
-
*/
|
|
513
|
-
declare function cacheBreakChip(info: CacheBreakInfo & {
|
|
514
|
-
costUsd?: number;
|
|
515
|
-
}): CacheChipContent;
|
|
516
|
-
/**
|
|
517
|
-
* Transcript-row text for a persisted cache-break notice. Multi-line, one
|
|
518
|
-
* fact per line, so both hosts can show a short headline and fold or list
|
|
519
|
-
* the rest:
|
|
520
|
-
*
|
|
521
|
-
* cache break ↑116.9k tokens ~$0.48
|
|
522
|
-
* messagePrefix: message 16 of 41→43 rewritten
|
|
523
|
-
* likely compaction or history trimming
|
|
524
|
-
*
|
|
525
|
-
* The footer chip stays terse; the row carries the culprit so a break is
|
|
526
|
-
* diagnosable from the transcript. Only the headline on a TTL / eviction
|
|
527
|
-
* break (nothing was done wrong).
|
|
528
|
-
*/
|
|
529
|
-
declare function cacheBreakNoticeText(info: CacheBreakInfo & {
|
|
530
|
-
costUsd?: number;
|
|
531
|
-
}): string;
|
|
532
|
-
/**
|
|
533
|
-
* Provider-retry label — `retrying 2/5`, or `retrying 2/5 · child-3` when the
|
|
534
|
-
* stalled stream belongs to a subagent rather than the parent.
|
|
535
|
-
*
|
|
536
|
-
* Naming the source matters: with subagents in flight, an unattributed
|
|
537
|
-
* "retrying" leaves the user unable to tell whether their own turn is stuck or
|
|
538
|
-
* a delegated worker is.
|
|
539
|
-
*/
|
|
540
|
-
declare function retryLabel(info: {
|
|
541
|
-
attempt: number;
|
|
542
|
-
max: number;
|
|
543
|
-
source: string;
|
|
544
|
-
}): string;
|
|
545
|
-
/**
|
|
546
|
-
* Footer label while a compaction summary is being generated:
|
|
547
|
-
* `Compacting...`, then `~12k` once the loop reports a token estimate, then
|
|
548
|
-
* ` · 8s` once a second has passed. Same rule on every surface so a
|
|
549
|
-
* minutes-long compaction of a large transcript reads as progress — not a
|
|
550
|
-
* hang — identically in the TUI and the GUI.
|
|
551
|
-
*
|
|
552
|
-
* `now` is injectable so callers driving a 1 Hz tick don't have to re-read
|
|
553
|
-
* the clock, and so tests are deterministic.
|
|
554
|
-
*/
|
|
555
|
-
/**
|
|
556
|
-
* Live counter for the parent turn currently streaming: `↓1.2k` when the
|
|
557
|
-
* provider counted the tokens, `↓~1.2k` when it is the character heuristic.
|
|
558
|
-
* Empty until the first token so a tool-only turn shows just the spinner.
|
|
559
|
-
* Tokens-per-second appears after two seconds (`↓1.2k · 41 tok/s`) — earlier
|
|
560
|
-
* the rate is dominated by time-to-first-token and would swing wildly.
|
|
561
|
-
*/
|
|
562
|
-
declare function streamingLabel(progress: {
|
|
563
|
-
outputTokens: number;
|
|
564
|
-
estimated: boolean;
|
|
565
|
-
elapsedMs: number;
|
|
566
|
-
} | null | undefined, opts?: {
|
|
567
|
-
rate?: boolean;
|
|
568
|
-
}): string;
|
|
569
|
-
/**
|
|
570
|
-
* Session cost while a turn streams: settled figure plus the running estimate
|
|
571
|
-
* for the in-flight turn. `estimated` tells the surface to render it dimmed
|
|
572
|
-
* (the number will move, then snap to the settled value at turn end). `null`
|
|
573
|
-
* when there is nothing to show — never `$0.00`.
|
|
574
|
-
*/
|
|
575
|
-
declare function liveSessionCost(settledUsd: number, progress: {
|
|
576
|
-
estCostUsd?: number;
|
|
577
|
-
} | null | undefined): {
|
|
578
|
-
usd: number;
|
|
579
|
-
estimated: boolean;
|
|
580
|
-
} | null;
|
|
581
|
-
declare function compactingLabel(estTokens: number | null | undefined, startedAt: number | null | undefined, now?: number): string;
|
|
582
|
-
//#endregion
|
|
583
|
-
//#region src/chat/format.d.ts
|
|
584
|
-
/** Compact token formatter — 12_415 → "12.4k", 1_234_567 → "1.23M". */
|
|
585
|
-
declare function fmtTokens(n: number): string;
|
|
586
|
-
/**
|
|
587
|
-
* USD cost, dollar-prefixed — 2 decimals, 4 below a cent so tiny spends
|
|
588
|
-
* stay visible (a haiku worker's $0.0007 must not render as $0.00).
|
|
589
|
-
*/
|
|
590
|
-
declare function fmtCost(cost: number): string;
|
|
591
|
-
/** Compact relative-time formatter — "just now / 5m / 3h / 2d". */
|
|
592
|
-
declare function ageString(ts: number, now?: number): string;
|
|
593
|
-
/** Six-char short form of a session id for headers and lists. */
|
|
594
|
-
declare function shortId(id: string): string;
|
|
595
|
-
/**
|
|
596
|
-
* Single-line preview of a multi-line string, capped at `max` chars and
|
|
597
|
-
* ellipsis-terminated when truncated.
|
|
598
|
-
*
|
|
599
|
-
* Whitespace runs (newlines, tabs, multiple spaces) collapse into one
|
|
600
|
-
* space so the rendered output stays on a single visual row no matter
|
|
601
|
-
* how the input was shaped. Used by every transcript "preview" surface
|
|
602
|
-
* (spawn-start task, `tool: shell (background): <command>`,
|
|
603
|
-
* `<task-notification>` summary line, etc.) — without the whitespace
|
|
604
|
-
* collapse, a 60-char `slice` on a string with an inline `\n\n` paints
|
|
605
|
-
* the second paragraph below the first, producing the visible
|
|
606
|
-
* "preview text spills onto multiple lines" bug (and, downstream,
|
|
607
|
-
* misaligned spawn markers when the wrapped lines collide with
|
|
608
|
-
* other events).
|
|
609
|
-
*
|
|
610
|
-
* Reserves one slot for the `…` so the displayed width is exactly
|
|
611
|
-
* `max` when truncation kicks in.
|
|
612
|
-
*/
|
|
613
|
-
declare function previewLine(s: string, max: number): string;
|
|
614
|
-
/**
|
|
615
|
-
* Compact human-readable duration formatter shared by background-task
|
|
616
|
-
* surfaces (the `<task-notification>` summary, the TUI banner, the
|
|
617
|
-
* `shell_kill` tool result, etc.).
|
|
618
|
-
*
|
|
619
|
-
* Format ladder:
|
|
620
|
-
* - `< 1s` → `"Nms"`
|
|
621
|
-
* - `< 10s` → `"N.Ns"` (one decimal)
|
|
622
|
-
* - `< 1m` → `"Ns"` (whole seconds)
|
|
623
|
-
* - `< 1h` → `"NmNs"` / `"Nm"` when seconds round to 0
|
|
624
|
-
* - `≥ 1h` → `"NhNm"` / `"Nh"` when minutes round to 0
|
|
625
|
-
*
|
|
626
|
-
* Single source of truth so a 60s task renders the same across the
|
|
627
|
-
* model-facing XML summary and the user-facing banner. Earlier
|
|
628
|
-
* separate formatters disagreed (XML said `"60.0s"`, banner said `"1m"`)
|
|
629
|
-
* which was confusing to the user reading both side by side.
|
|
630
|
-
*/
|
|
631
|
-
declare function formatDuration(ms: number): string;
|
|
632
|
-
/**
|
|
633
|
-
* Status label for a terminated background task — `"exited <code>"`
|
|
634
|
-
* for natural exits, `"killed"` (with the signal name when known)
|
|
635
|
-
* for our-issued SIGTERMs.
|
|
636
|
-
*
|
|
637
|
-
* Pulled out as its own function so the `<task-notification>` XML
|
|
638
|
-
* summary, the TUI banner header, the `shell_kill` tool result, and
|
|
639
|
-
* future surfaces all read the same string.
|
|
640
|
-
*/
|
|
641
|
-
declare function formatTaskStatus(info: {
|
|
642
|
-
status: 'exited' | 'killed';
|
|
643
|
-
exitCode: number;
|
|
644
|
-
signal?: NodeJS.Signals;
|
|
645
|
-
}): string;
|
|
646
|
-
/**
|
|
647
|
-
* One-line summary of a terminated background task — the shape used by
|
|
648
|
-
* the `<task-notification>` XML's `<summary>` tag AND the TUI banner's
|
|
649
|
-
* `event.text` fallback string. Three dot-separated segments:
|
|
650
|
-
*
|
|
651
|
-
* `<command preview · status · duration>`
|
|
652
|
-
*
|
|
653
|
-
* Centralizes the format so live + replay + wire all agree, and so a
|
|
654
|
-
* future cosmetic tweak (separator glyph, segment ordering) lands in
|
|
655
|
-
* exactly one place.
|
|
656
|
-
*/
|
|
657
|
-
declare function formatTaskSummary(info: {
|
|
658
|
-
command: string;
|
|
659
|
-
status: 'exited' | 'killed';
|
|
660
|
-
exitCode: number;
|
|
661
|
-
signal?: NodeJS.Signals;
|
|
662
|
-
durationMs: number;
|
|
663
|
-
}, maxCommandChars?: number): string;
|
|
664
|
-
/**
|
|
665
|
-
* Compact an absolute path for display: replace the user's `$HOME`
|
|
666
|
-
* prefix with `~` (so `/Users/yael/Code/zidane` → `~/Code/zidane`),
|
|
667
|
-
* and optionally left-truncate with an ellipsis when the result
|
|
668
|
-
* still exceeds `maxWidth` (so the path's *tail* — the part the user
|
|
669
|
-
* recognizes — stays visible: `…/zidane` rather than `/Users/yaeluil…`).
|
|
670
|
-
*
|
|
671
|
-
* `maxWidth` is the maximum *display width* in cells. Omit to skip
|
|
672
|
-
* truncation. Paths outside `$HOME` are returned verbatim modulo
|
|
673
|
-
* truncation. The ellipsis (`…`) counts as one cell.
|
|
674
|
-
*
|
|
675
|
-
* `home` overrides `os.homedir()` for tests; production callers leave
|
|
676
|
-
* it undefined and pay the cheap one-syscall lookup per call.
|
|
677
|
-
*/
|
|
678
|
-
declare function compactPath(path: string, maxWidth?: number, home?: string): string;
|
|
679
|
-
//#endregion
|
|
680
|
-
//#region src/chat/provider-usage-format.d.ts
|
|
681
|
-
/**
|
|
682
|
-
* Node-free half of provider usage: the wire types and the two presentation
|
|
683
|
-
* helpers every surface needs to RENDER a snapshot.
|
|
684
|
-
*
|
|
685
|
-
* Split out of `provider-usage.ts` because that module reads
|
|
686
|
-
* `credentials.json` and so cannot be reached from `zidane/chat/pure`. The
|
|
687
|
-
* Electron renderer receives snapshots over IPC (main does the fetching) and
|
|
688
|
-
* must draw them with the same rounding and the same "which window bites
|
|
689
|
-
* first" rule as the TUI — a renderer that re-derived either would be the
|
|
690
|
-
* duplication that let the TUI and GUI report different facts about one event.
|
|
691
|
-
*
|
|
692
|
-
* `provider-usage.ts` re-exports everything here, so existing importers keep
|
|
693
|
-
* their single import.
|
|
694
|
-
*/
|
|
695
|
-
/** One rate-limit window on a subscription (e.g. "5h", "weekly"). */
|
|
696
|
-
interface ProviderUsageWindow {
|
|
697
|
-
/** Stable id from the provider, used as a React / list key. */
|
|
698
|
-
id: string;
|
|
699
|
-
/** Human label as the provider names it. */
|
|
700
|
-
label: string;
|
|
701
|
-
/** 0..100, may be fractional. */
|
|
702
|
-
usedPercent: number;
|
|
703
|
-
/** Epoch ms when the window resets, or `null` when the provider omits it. */
|
|
704
|
-
resetsAt: number | null;
|
|
705
|
-
}
|
|
706
|
-
/** Remaining credits for pay-as-you-go style providers. */
|
|
707
|
-
interface ProviderUsageCredits {
|
|
708
|
-
remaining: number;
|
|
709
|
-
total: number | null;
|
|
710
|
-
}
|
|
711
|
-
type ProviderUsageStatus = 'ok' | 'unauthorized' | 'unavailable';
|
|
712
|
-
interface ProviderUsageSnapshot {
|
|
713
|
-
/** Registry key (`anthropic`, `openai`, …). */
|
|
714
|
-
providerKey: string;
|
|
715
|
-
/** Display label for the provider. */
|
|
716
|
-
label: string;
|
|
717
|
-
/**
|
|
718
|
-
* Credentials-file key of the credential this snapshot was probed with. A
|
|
719
|
-
* provider holding several OAuth accounts yields one snapshot per account;
|
|
720
|
-
* this is what tells them apart (and the stable list key).
|
|
721
|
-
*/
|
|
722
|
-
credentialKey: string;
|
|
723
|
-
/**
|
|
724
|
-
* Account name for OAuth-backed snapshots (`Default`, `work`, …); `null` for
|
|
725
|
-
* API-key probes. Surfaces show it only when the provider has more than one
|
|
726
|
-
* snapshot, so a single-account provider stays as quiet as before.
|
|
727
|
-
*/
|
|
728
|
-
account: string | null;
|
|
729
|
-
/** True when this credential is the one requests use (the canonical slot). */
|
|
730
|
-
activeCredential: boolean;
|
|
731
|
-
status: ProviderUsageStatus;
|
|
732
|
-
/** Plan name when the provider reports one. */
|
|
733
|
-
plan: string | null;
|
|
734
|
-
windows: readonly ProviderUsageWindow[];
|
|
735
|
-
credits: ProviderUsageCredits | null;
|
|
736
|
-
fetchedAt: number;
|
|
737
|
-
error: string | null;
|
|
738
|
-
}
|
|
739
|
-
/**
|
|
740
|
-
* Whether a snapshot should show its account name: only when another snapshot
|
|
741
|
-
* in the same list belongs to the same provider. One account is the provider.
|
|
742
|
-
*/
|
|
743
|
-
declare function showsAccount(snapshot: ProviderUsageSnapshot, all: readonly ProviderUsageSnapshot[]): boolean;
|
|
744
|
-
/**
|
|
745
|
-
* The snapshot the footer indicator shows for a provider: the one probed with
|
|
746
|
-
* the credential requests use, else the first reported. `null` when none.
|
|
747
|
-
*/
|
|
748
|
-
declare function activeSnapshotFor(all: readonly ProviderUsageSnapshot[], providerKey: string): ProviderUsageSnapshot | null;
|
|
749
|
-
/**
|
|
750
|
-
* The window closest to its ceiling, which is the one that will bite first and
|
|
751
|
-
* the only one a single-line indicator has room for. `null` when the snapshot
|
|
752
|
-
* carries no windows.
|
|
753
|
-
*/
|
|
754
|
-
declare function mostConstrainedWindow(snapshot: ProviderUsageSnapshot): ProviderUsageWindow | null;
|
|
755
|
-
/**
|
|
756
|
-
* Percent for display: integers print bare, fractions keep one decimal (so a
|
|
757
|
-
* status bar never reads `100%` for `99.9`).
|
|
758
|
-
*/
|
|
759
|
-
declare function formatUsagePercent(usedPercent: number): string;
|
|
760
|
-
/**
|
|
761
|
-
* Severity tone for a usage percent. `error` ≥ 85, `warn` ≥ 60, else `ok`.
|
|
762
|
-
* Surfaces map tones to their own palette.
|
|
763
|
-
*/
|
|
764
|
-
type UsageTone = 'ok' | 'warn' | 'error';
|
|
765
|
-
declare function usageTone(usedPercent: number): UsageTone;
|
|
766
|
-
/**
|
|
767
|
-
* Time to reset, coarsened to whole days past 24h. `null` when the provider
|
|
768
|
-
* reported no reset, `resetting` once it is due.
|
|
769
|
-
*
|
|
770
|
-
* Every step rounds DOWN, like the percent: 36h reads as `1d`, not `2d`.
|
|
771
|
-
* Overstating the headroom left on a window is the wrong direction to be
|
|
772
|
-
* wrong in.
|
|
773
|
-
*/
|
|
774
|
-
declare function resetLabel(resetsAt: number | null, now?: number): string | null;
|
|
775
|
-
/**
|
|
776
|
-
* `updated 12s ago` / `updated 3m ago` for the newest snapshot in a list, so a
|
|
777
|
-
* refresh that returns identical numbers is still visibly a refresh. `null`
|
|
778
|
-
* when the list is empty.
|
|
779
|
-
*/
|
|
780
|
-
declare function updatedLabel(snapshots: readonly ProviderUsageSnapshot[], now?: number): string | null;
|
|
781
|
-
/** Balances are dollars for OpenRouter and opaque units elsewhere. */
|
|
782
|
-
declare function formatCredits(value: number): string;
|
|
783
|
-
/** `20.00 / 25.00`, or just the remainder when no total is reported. */
|
|
784
|
-
declare function formatBalance(credits: ProviderUsageCredits): string;
|
|
785
|
-
//#endregion
|
|
786
|
-
//#region src/chat/streaming-pure.d.ts
|
|
787
|
-
/** Flip any trailing streaming markdown blocks (any owner) to finalized. */
|
|
788
|
-
declare function finalizeStreamingMarkdown(events: StreamEvent[]): StreamEvent[];
|
|
789
|
-
/** Flip the trailing streaming markdown block for one specific owner. */
|
|
790
|
-
declare function finalizeStreamingMarkdownForOwner(events: StreamEvent[], owner: Owner): StreamEvent[];
|
|
791
|
-
/**
|
|
792
|
-
* Effective context size for a single turn.
|
|
793
|
-
*
|
|
794
|
-
* `usage.input` is misleading on its own when prompt caching is active: providers
|
|
795
|
-
* (Anthropic, OpenRouter→Anthropic, Gemini) report `input` as the *new uncached*
|
|
796
|
-
* tokens only — the cached prefix shows up in `cacheRead`, and newly-cached
|
|
797
|
-
* tokens in `cacheCreation`. The model still saw all three buckets, so the real
|
|
798
|
-
* context-window utilization is their sum.
|
|
799
|
-
*
|
|
800
|
-
* Non-caching providers leave `cacheRead`/`cacheCreation` undefined, so this
|
|
801
|
-
* collapses to plain `input` for them.
|
|
802
|
-
*/
|
|
803
|
-
declare function turnContextSize(usage: TurnUsage | undefined): number;
|
|
804
|
-
/**
|
|
805
|
-
* Display-layer transcript bounds. Each rendered event holds live React
|
|
806
|
-
* fibers + OpenTUI renderables + native text buffers even when scrolled
|
|
807
|
-
* off-screen — measured at roughly 0.13 MB RSS per markdown-heavy event —
|
|
808
|
-
* so an uncapped multi-thousand-event session (a normal working day with
|
|
809
|
-
* tool calls) climbs into the hundreds of MB and eventually OOM/thrash.
|
|
810
|
-
*
|
|
811
|
-
* The cap bounds ONLY what is materialized on screen: session turns on
|
|
812
|
-
* disk are complete, and switching sessions / re-activating replays the
|
|
813
|
-
* most recent window again. Trimming happens at TURN boundaries so a
|
|
814
|
-
* turn's rows are never orphaned, and re-caps fold into one cumulative
|
|
815
|
-
* marker rather than stacking markers.
|
|
816
|
-
*/
|
|
817
|
-
declare const MAX_TRANSCRIPT_EVENTS = 1500;
|
|
818
|
-
/** Post-trim size — the hysteresis gap keeps re-trims O(rare), not per-append. */
|
|
819
|
-
declare const TRANSCRIPT_TRIM_TO_EVENTS = 1200;
|
|
820
|
-
/**
|
|
821
|
-
* Bound a transcript event array for display. Identity below the cap
|
|
822
|
-
* (no re-render churn on the hot append path); above it, drops the
|
|
823
|
-
* oldest events down to {@link TRANSCRIPT_TRIM_TO_EVENTS} — extended to
|
|
824
|
-
* the next turn boundary — and prepends a cumulative hidden-count
|
|
825
|
-
* marker. Callers: the stream buffer's drain commit and every
|
|
826
|
-
* `eventsFromTurns` replay site.
|
|
827
|
-
*/
|
|
828
|
-
declare function capTranscriptEvents(events: StreamEvent[], max?: number, trimTo?: number): StreamEvent[];
|
|
829
|
-
//#endregion
|
|
830
|
-
//#region src/chat/todos.d.ts
|
|
831
|
-
declare const TODOWRITE_TOOL = "todowrite";
|
|
832
|
-
declare const TODOREAD_TOOL = "todoread";
|
|
833
|
-
/** True when `name` is one of the todo tool canonical names. */
|
|
834
|
-
declare function isTodoTool(name: string): boolean;
|
|
835
|
-
/** `session.metadata[TODOS_METADATA_KEY]: TodosBag` — see {@link TodosBag}. */
|
|
836
|
-
declare const TODOS_METADATA_KEY = "todos";
|
|
837
|
-
/** `session.metadata[TODO_WRITE_COUNTS_METADATA_KEY]: CountsBag` — mirrors `TodosBag` shape. */
|
|
838
|
-
declare const TODO_WRITE_COUNTS_METADATA_KEY = "todoWriteCounts";
|
|
839
|
-
type TodoStatus = 'pending' | 'in_progress' | 'completed' | 'cancelled';
|
|
840
|
-
interface TodoItem {
|
|
841
|
-
/** Stable id — the model picks it. Reusing an id replaces that item. */
|
|
842
|
-
id: string;
|
|
843
|
-
/** One-line task summary (Markdown allowed; renderers may sanitize). */
|
|
844
|
-
content: string;
|
|
845
|
-
status: TodoStatus;
|
|
846
|
-
}
|
|
847
|
-
/**
|
|
848
|
-
* On-disk shape at `session.metadata[TODOS_METADATA_KEY]`.
|
|
849
|
-
*
|
|
850
|
-
* Sub-fields are absent (not empty) when they carry no data — keeps the
|
|
851
|
-
* persisted metadata clean and lets `JSON.stringify` skip empty bags
|
|
852
|
-
* entirely on session save.
|
|
853
|
-
*/
|
|
854
|
-
interface TodosBag {
|
|
855
|
-
/** Top-level slot — shared across runs whose `parentRunId` is unset. */
|
|
856
|
-
session?: TodoItem[];
|
|
857
|
-
/** Per-subagent-run slots, keyed by the child run's id. */
|
|
858
|
-
byRun?: Record<string, TodoItem[]>;
|
|
859
|
-
/**
|
|
860
|
-
* Most-recent non-empty list per slot — sidecar for UI surfaces, NOT
|
|
861
|
-
* visible to `todoread`. Updated on every non-empty write; **preserved**
|
|
862
|
-
* across the auto-clear path. Lets the modal keep showing "what was just
|
|
863
|
-
* completed" after a fully-done batch wipes the live slot. Empty writes
|
|
864
|
-
* never touch the archive — clearing the live list shouldn't erase the
|
|
865
|
-
* audit trail.
|
|
866
|
-
*/
|
|
867
|
-
archive?: {
|
|
868
|
-
session?: TodoItem[];
|
|
869
|
-
byRun?: Record<string, TodoItem[]>;
|
|
870
|
-
};
|
|
871
|
-
}
|
|
872
|
-
/**
|
|
873
|
-
* Default ceiling on a single todo list. Exported so every write boundary caps
|
|
874
|
-
* identically — a boundary with a different cap would let a list through that
|
|
875
|
-
* the tool would have truncated.
|
|
876
|
-
*/
|
|
877
|
-
declare const DEFAULT_MAX_TODO_ITEMS = 100;
|
|
878
|
-
declare const TODO_STATUS_GLYPHS: Readonly<Record<TodoStatus, string>>;
|
|
879
|
-
interface CreateTodoToolsOptions {
|
|
880
|
-
/**
|
|
881
|
-
* Maximum item count per `todowrite`. Excess items are truncated by the
|
|
882
|
-
* recursive validator and reported back to the model in the tool_result.
|
|
883
|
-
*
|
|
884
|
-
* Default: `100`. The default is generous; a planning agent that exceeds
|
|
885
|
-
* 100 items per call is usually flailing.
|
|
886
|
-
*/
|
|
887
|
-
maxItems?: number;
|
|
888
|
-
/**
|
|
889
|
-
* Per-run cap on `todowrite` calls, plumbed into `behavior.toolBudgets`.
|
|
890
|
-
* `onMaxWrites` chooses the reaction (steer / block) — see
|
|
891
|
-
* {@link AgentBehavior.toolBudgets} for the contract.
|
|
892
|
-
*
|
|
893
|
-
* **Default: `0` (no cap).** `todowrite` is a state-transition tool —
|
|
894
|
-
* a legitimate run of an N-item list needs at least `N + 1` calls
|
|
895
|
-
* (initial plan + one transition per item) to complete, so a hard
|
|
896
|
-
* cap punishes the legitimate path. The nudges that DO apply are the
|
|
897
|
-
* `remindAfter` reminder (soft, in-band) and the identical-payload
|
|
898
|
-
* dedup check (silent, structural). Hosts that want a true hard cap
|
|
899
|
-
* can opt in by setting `maxWritesPerRun: N`.
|
|
900
|
-
*
|
|
901
|
-
* **Counting semantics** (when opted in): the budget counts every
|
|
902
|
-
* dispatched call, including dedup substitutes (zidane spec). The
|
|
903
|
-
* {@link remindAfter} counter counts execute-only dispatches —
|
|
904
|
-
* dedup hits replay the prior result and never reach the tool body.
|
|
905
|
-
* Use this budget (not the reminder) as the hard limit.
|
|
906
|
-
*/
|
|
907
|
-
maxWritesPerRun?: number;
|
|
908
|
-
onMaxWrites?: 'steer' | 'block';
|
|
909
|
-
/**
|
|
910
|
-
* Hard stop for **consecutive identical** `todowrite` payloads — the
|
|
911
|
-
* exact loop the in-body `dedupIdentical` check only *whispers* about
|
|
912
|
-
* ("No change — N items already tracked"). Plumbs a run-scoped
|
|
913
|
-
* `behavior.dedupTools.todowrite` entry in `block-after` mode: the
|
|
914
|
-
* gate replays the unchanged result for the first `N - 1` identical
|
|
915
|
-
* calls, then refuses the `N`th (and every subsequent identical one)
|
|
916
|
-
* with a `Blocked: …` tool_result so the model breaks out instead of
|
|
917
|
-
* re-checkpointing forever.
|
|
918
|
-
*
|
|
919
|
-
* This is safe to leave on by default — unlike {@link maxWritesPerRun}
|
|
920
|
-
* it only ever blocks a payload byte-identical to the one already
|
|
921
|
-
* tracked, so a legitimate "finish the N-item plan" run (which writes
|
|
922
|
-
* a *different* list each transition) is never touched. The counter
|
|
923
|
-
* resets the moment the model writes anything different.
|
|
924
|
-
*
|
|
925
|
-
* Run-scoped via `DedupToolConfig.scope: 'run'`, so a parent and a
|
|
926
|
-
* subagent writing the same list never share the counter — the precise
|
|
927
|
-
* conflation that kept `todowrite` off `behavior.dedupTools` before.
|
|
928
|
-
*
|
|
929
|
-
* Set to `0` to opt out (e.g. a host that installs its own loop
|
|
930
|
-
* hardening). Default: `5`. Values `< 2` are clamped to `2` by the
|
|
931
|
-
* dedup middleware (a threshold of 1 would block the first call).
|
|
932
|
-
*/
|
|
933
|
-
maxIdenticalWrites?: number;
|
|
934
|
-
/**
|
|
935
|
-
* Custom refusal text for the {@link maxIdenticalWrites} block. Receives
|
|
936
|
-
* the 1-indexed identical-call count (including the blocked call). Leave
|
|
937
|
-
* unset for the built-in "you've written the same list N times in a
|
|
938
|
-
* row" message.
|
|
939
|
-
*/
|
|
940
|
-
identicalBlockReason?: (count: number) => string;
|
|
941
|
-
/**
|
|
942
|
-
* Append a "you've checkpointed N times — only call this at significant
|
|
943
|
-
* task transitions" nudge to the tool_result once `todowrite` has fired
|
|
944
|
-
* this many times in the current run. The nudge rides on the result
|
|
945
|
-
* string, so the model sees it on its next turn without `system:transform`
|
|
946
|
-
* plumbing.
|
|
947
|
-
*
|
|
948
|
-
* Counts only executed dispatches (dedup hits skip the tool body and so
|
|
949
|
-
* skip the increment). For a hard cap that also covers dedup hits, use
|
|
950
|
-
* {@link maxWritesPerRun}.
|
|
951
|
-
*
|
|
952
|
-
* Set to `0` to opt out. Default: `3`.
|
|
953
|
-
*/
|
|
954
|
-
remindAfter?: number;
|
|
955
|
-
/**
|
|
956
|
-
* Custom reminder text. Receives the post-call count and the items that
|
|
957
|
-
* were just written. Return `''` (or `undefined`) to suppress the reminder
|
|
958
|
-
* for this specific call. Default text nudges towards "back to executing,
|
|
959
|
-
* not re-planning."
|
|
960
|
-
*/
|
|
961
|
-
reminderText?: (count: number, items: readonly TodoItem[]) => string | undefined;
|
|
962
|
-
/**
|
|
963
|
-
* Short-circuit the tool body when the incoming payload is identical to
|
|
964
|
-
* the **current slot** (session-shared for top-level runs, per-run for
|
|
965
|
-
* subagents). The model gets a "No change — N items already tracked."
|
|
966
|
-
* acknowledgment instead of a fresh "Updated N items." line.
|
|
967
|
-
* Default: `true`.
|
|
968
|
-
*
|
|
969
|
-
* Read `session.metadata.todos` via {@link getTodosForRun} for the
|
|
970
|
-
* comparison — so the resolution naturally follows the keying rule
|
|
971
|
-
* (top-level reads the session slot, subagent reads its own). Does
|
|
972
|
-
* NOT plumb through `behavior.dedupTools`: that cache lives at the
|
|
973
|
-
* gate, is keyed per session, and would conflate top-level + subagent
|
|
974
|
-
* re-writes of structurally identical payloads.
|
|
975
|
-
*
|
|
976
|
-
* Counter advances on identical re-writes regardless — the model
|
|
977
|
-
* called the tool, that's a call. Lets the reminder threshold catch
|
|
978
|
-
* spam. Set `false` to skip the check entirely (every call rewrites
|
|
979
|
-
* the slot, useful when state-shape comparisons are pointless for
|
|
980
|
-
* your usage).
|
|
981
|
-
*/
|
|
982
|
-
dedupIdentical?: boolean;
|
|
983
|
-
/**
|
|
984
|
-
* Override the JSON-schema-level descriptions surfaced to the model.
|
|
985
|
-
* Useful for telemetry experiments. Leave unset to inherit the built-in
|
|
986
|
-
* doctrine prose.
|
|
987
|
-
*/
|
|
988
|
-
writeDescription?: string;
|
|
989
|
-
readDescription?: string;
|
|
990
|
-
}
|
|
991
|
-
/**
|
|
992
|
-
* Read the active list for `runId`. Top-level runs see the session-shared
|
|
993
|
-
* slot; subagent runs see their own. Returns a fresh `[]` (not stored in
|
|
994
|
-
* metadata) when no slot exists — the caller can mutate the result
|
|
995
|
-
* without affecting state.
|
|
996
|
-
*/
|
|
997
|
-
declare function getTodosForRun(session: Session, runId: string): TodoItem[];
|
|
998
|
-
/**
|
|
999
|
-
* Replace the active list for `runId`. Routes to the session-shared slot
|
|
1000
|
-
* for top-level runs and to the per-run slot for subagents. Empty arrays
|
|
1001
|
-
* delete the slot entirely so persisted metadata stays clean.
|
|
1002
|
-
*
|
|
1003
|
-
* Side effect: a **non-empty** write also stashes the same list into
|
|
1004
|
-
* `bag.archive` (same routing). Empty writes never touch the archive —
|
|
1005
|
-
* clearing the live list (whether explicitly or via the tool's auto-
|
|
1006
|
-
* clear) preserves the "last shown" snapshot so UI surfaces can keep
|
|
1007
|
-
* rendering what was just completed. See {@link getArchivedTodosForRun}.
|
|
1008
|
-
*
|
|
1009
|
-
* `opts.clearArchive` opts OUT of that preservation, and exists because the
|
|
1010
|
-
* archive is only the right answer for the AUTO-CLEAR path. UI surfaces render
|
|
1011
|
-
* `todos.length > 0 ? todos : archive`, so a user who deletes every todo would
|
|
1012
|
-
* otherwise watch the archive fall straight back into view with the same items
|
|
1013
|
-
* — a destructive action they confirmed, with no visible effect, and the footer
|
|
1014
|
-
* chip still counting the list they just deleted. Pass it for user-initiated
|
|
1015
|
-
* writes; leave it off for the tool.
|
|
1016
|
-
*/
|
|
1017
|
-
declare function setTodosForRun(session: Session, runId: string, items: readonly TodoItem[], opts?: {
|
|
1018
|
-
clearArchive?: boolean;
|
|
1019
|
-
}): void;
|
|
1020
|
-
/**
|
|
1021
|
-
* Read the archived (most-recent non-empty) list for `runId`. Same slot
|
|
1022
|
-
* routing as {@link getTodosForRun}, but reads `bag.archive` instead of
|
|
1023
|
-
* the live slot. Returns a fresh `[]` when no archive exists.
|
|
1024
|
-
*
|
|
1025
|
-
* UI surfaces use this to keep showing "what was just completed" after
|
|
1026
|
-
* the live list auto-clears. The model never sees the archive — it's a
|
|
1027
|
-
* read-only sidecar for human-facing rendering.
|
|
1028
|
-
*/
|
|
1029
|
-
declare function getArchivedTodosForRun(session: Session, runId: string): TodoItem[];
|
|
1030
|
-
/**
|
|
1031
|
-
* Reconcile `session.metadata.todos.byRun` (live + archive) against
|
|
1032
|
-
* `session.runs`. Drops subagent slots whose runId isn't in the run
|
|
1033
|
-
* list. The top-level `session` slot is unaffected — it's session-
|
|
1034
|
-
* scoped, not per-run, so there's no orphan to GC.
|
|
1035
|
-
*
|
|
1036
|
-
* Useful after `session.setRuns()` (fork / restore) or to GC stale
|
|
1037
|
-
* metadata mutated by an external caller. Also prunes the parallel
|
|
1038
|
-
* counter bag so the two don't drift.
|
|
1039
|
-
*
|
|
1040
|
-
* `dropped` reports the live-byRun orphans only (archive-only orphans
|
|
1041
|
-
* are silently swept). The live half is the contract callers actually
|
|
1042
|
-
* observe.
|
|
1043
|
-
*/
|
|
1044
|
-
declare function pruneTodosByRun(session: Session): {
|
|
1045
|
-
dropped: readonly string[];
|
|
1046
|
-
};
|
|
1047
|
-
/**
|
|
1048
|
-
* Build a `Preset` carrying the `{ todowrite, todoread }` tool pair.
|
|
1049
|
-
*
|
|
1050
|
-
* Loop hardening is layered, soft → hard:
|
|
1051
|
-
* 1. **In-body identical dedup** (`dedupIdentical`, on) — resolves
|
|
1052
|
-
* against the active slot (session-shared for top-level runs,
|
|
1053
|
-
* per-run for subagents) and returns "No change — N items already
|
|
1054
|
-
* tracked." Advisory; the model can ignore it.
|
|
1055
|
-
* 2. **In-band reminder** (`remindAfter`, on) — appends a "you've
|
|
1056
|
-
* checkpointed N times" nudge to the result. Also advisory.
|
|
1057
|
-
* 3. **Consecutive-identical hard block** (`maxIdenticalWrites`, ON by
|
|
1058
|
-
* default) — a run-scoped `behavior.dedupTools.todowrite` entry in
|
|
1059
|
-
* `block-after` mode. After N byte-identical writes in a row the
|
|
1060
|
-
* gate refuses with `Blocked: …` and the body never runs. This is
|
|
1061
|
-
* the real loop breaker, and it's safe-by-default precisely because
|
|
1062
|
-
* it only fires on *identical* payloads — a legitimate N-item plan
|
|
1063
|
-
* writes a *different* list each step and never trips it.
|
|
1064
|
-
*
|
|
1065
|
-
* By default the preset adds **no** `toolBudgets` entry — a blanket
|
|
1066
|
-
* per-call cap is the wrong abstraction for a state-transition tool (it
|
|
1067
|
-
* punishes the legitimate "finish the N-item plan" path). Hosts that
|
|
1068
|
-
* want a ceiling on *all* writes (not just identical ones) pass
|
|
1069
|
-
* `maxWritesPerRun: N` explicitly; the factory then also plumbs a
|
|
1070
|
-
* `behavior.toolBudgets.todowrite` entry.
|
|
1071
|
-
*
|
|
1072
|
-
* Returning a `Preset` (not a bare tool map) lets the result flow
|
|
1073
|
-
* through {@link composePresets} unchanged. `behavior.dedupTools` and
|
|
1074
|
-
* `behavior.toolBudgets` are tool-name-keyed records that
|
|
1075
|
-
* `composePresets` deep-merges, so a caller's entries for other tools
|
|
1076
|
-
* survive the layering, and a caller's override for `todowrite` itself
|
|
1077
|
-
* wins by being placed later in the chain.
|
|
1078
|
-
*
|
|
1079
|
-
* ```ts
|
|
1080
|
-
* import { basic, composePresets } from 'zidane/presets'
|
|
1081
|
-
* import { createTodoTools } from 'zidane/chat'
|
|
1082
|
-
*
|
|
1083
|
-
* // Default: soft dedup + reminder + a run-scoped hard block after 5
|
|
1084
|
-
* // identical writes in a row.
|
|
1085
|
-
* createAgent({ ...composePresets(basic, createTodoTools()), provider })
|
|
1086
|
-
*
|
|
1087
|
-
* // Tune (or disable) the identical-write block.
|
|
1088
|
-
* createTodoTools({ maxIdenticalWrites: 3 }) // stricter
|
|
1089
|
-
* createTodoTools({ maxIdenticalWrites: 0 }) // off — soft signals only
|
|
1090
|
-
*
|
|
1091
|
-
* // Opt-in blanket cap on *all* writes (counts distinct ones too).
|
|
1092
|
-
* createAgent({
|
|
1093
|
-
* ...composePresets(basic, createTodoTools({ maxWritesPerRun: 20 })),
|
|
1094
|
-
* provider,
|
|
1095
|
-
* })
|
|
1096
|
-
* ```
|
|
1097
|
-
*
|
|
1098
|
-
* For the trivial "just add the tools to an existing config" case, plain
|
|
1099
|
-
* spread is also fine — the returned `Preset` sets `tools` plus a
|
|
1100
|
-
* `behavior` block (carrying the default identical-write dedup):
|
|
1101
|
-
*
|
|
1102
|
-
* ```ts
|
|
1103
|
-
* createAgent({ ...basic, ...createTodoTools(), provider })
|
|
1104
|
-
* ```
|
|
1105
|
-
*/
|
|
1106
|
-
declare function createTodoTools(options?: CreateTodoToolsOptions): Preset;
|
|
1107
|
-
/**
|
|
1108
|
-
* Validate an untrusted todo list, dropping malformed rows and capping length.
|
|
1109
|
-
*
|
|
1110
|
-
* The single validator for every write/read boundary: model tool input,
|
|
1111
|
-
* persisted metadata on read, and user edits arriving over IPC. Keeping them on
|
|
1112
|
-
* one implementation is what makes "well-formed" mean the same thing at each —
|
|
1113
|
-
* a boundary that only picked fields (as `normalizeItem` does) would admit an
|
|
1114
|
-
* invalid `status` that the read path then silently drops, so the write appears
|
|
1115
|
-
* to succeed and the row vanishes with nothing reported.
|
|
1116
|
-
*/
|
|
1117
|
-
declare function sanitizeTodoItems(raw: readonly unknown[], cap?: number): TodoItem[];
|
|
1118
|
-
interface TodoTally {
|
|
1119
|
-
pending: number;
|
|
1120
|
-
in_progress: number;
|
|
1121
|
-
completed: number;
|
|
1122
|
-
cancelled: number;
|
|
1123
|
-
}
|
|
1124
|
-
interface ActiveTodosState {
|
|
1125
|
-
/** Run the slice came from. `null` ⇒ no session / no runs / no active run. */
|
|
1126
|
-
runId: string | null;
|
|
1127
|
-
/**
|
|
1128
|
-
* Live list — what `todoread` would return. Empty when the slot was
|
|
1129
|
-
* cleared (e.g. auto-clear after every item completed) or never
|
|
1130
|
-
* written. Source of truth for the model's view.
|
|
1131
|
-
*/
|
|
1132
|
-
todos: readonly TodoItem[];
|
|
1133
|
-
/**
|
|
1134
|
-
* Most-recent non-empty list for the active slot, preserved across
|
|
1135
|
-
* auto-clear. Equals `todos` when the live list is non-empty;
|
|
1136
|
-
* otherwise the last batch that was shown (commonly the all-`completed`
|
|
1137
|
-
* close-out). UI surfaces fall back to this when `todos` is empty so
|
|
1138
|
-
* the user can still glance back at "what was just finished" — until
|
|
1139
|
-
* the model writes a new list. Empty array when no list was ever
|
|
1140
|
-
* written for this slot.
|
|
1141
|
-
*/
|
|
1142
|
-
archive: readonly TodoItem[];
|
|
1143
|
-
/**
|
|
1144
|
-
* The first `in_progress` item from `todos` (the **live** list), when
|
|
1145
|
-
* one exists. Drives the inline indicator above the prompt. Always
|
|
1146
|
-
* `null` when the live list is empty — even if the archive carries
|
|
1147
|
-
* an in-progress item, that item is by definition stale.
|
|
1148
|
-
*/
|
|
1149
|
-
inProgress: TodoItem | null;
|
|
1150
|
-
/**
|
|
1151
|
-
* Per-status counts. Computed over `todos` when non-empty, else over
|
|
1152
|
-
* `archive`. Zeros only when both are empty. Lets the modal header
|
|
1153
|
-
* show a meaningful tally for the archived "last batch" view.
|
|
1154
|
-
*/
|
|
1155
|
-
tally: TodoTally;
|
|
1156
|
-
}
|
|
1157
|
-
/**
|
|
1158
|
-
* Pick the "active" run for UI surfaces that show one slot at a time
|
|
1159
|
-
* (todos indicator, todos modal, footer ctx indicator). The resolved
|
|
1160
|
-
* runId then routes through {@link getTodosForRun} — top-level runs
|
|
1161
|
-
* land on the session-shared slot, subagent runs on their own.
|
|
1162
|
-
*
|
|
1163
|
-
* - A currently-running run wins (latest-started one if several).
|
|
1164
|
-
* - Otherwise the most recently appended run wins.
|
|
1165
|
-
* - `null` when the session has no runs.
|
|
1166
|
-
*
|
|
1167
|
-
* Mirrors the "most recent thing that mattered" policy that drives
|
|
1168
|
-
* `lastContextSizeFromTurns` — but walks `session.runs` rather than
|
|
1169
|
-
* `session.turns` because the active todo slot is a function of the
|
|
1170
|
-
* run, not of message history.
|
|
1171
|
-
*/
|
|
1172
|
-
declare function pickActiveRunId(session: Session | null | undefined): string | null;
|
|
1173
|
-
/**
|
|
1174
|
-
* Pure selector — derive the active-todos state from a session snapshot.
|
|
1175
|
-
* Used by {@link useActiveTodos} and directly testable without React.
|
|
1176
|
-
*
|
|
1177
|
-
* Resolves both `todos` (live, model-facing) and `archive` (last
|
|
1178
|
-
* non-empty snapshot for UI fallback). The tally folds over whichever
|
|
1179
|
-
* list is non-empty; `inProgress` is sourced strictly from `todos`
|
|
1180
|
-
* because an archived in-progress item is by definition stale.
|
|
1181
|
-
*/
|
|
1182
|
-
declare function selectActiveTodos(session: Session | null | undefined): ActiveTodosState;
|
|
1183
|
-
/**
|
|
1184
|
-
* React hook — active-todos state for the supplied session. Recomputes
|
|
1185
|
-
* on every parent re-render; the work is O(runs + todos), both bounded
|
|
1186
|
-
* by small constants in practice.
|
|
1187
|
-
*
|
|
1188
|
-
* Why no memoization: `Session.runs` is mutated in place by `completeRun`
|
|
1189
|
-
* / `abortRun` (status flips without changing array length or item
|
|
1190
|
-
* identity), so any memo keyed off length / bag identity would silently
|
|
1191
|
-
* return stale state when e.g. a child subagent run completes and the
|
|
1192
|
-
* "active" run should reflow to the parent. The selector is cheap
|
|
1193
|
-
* enough that running it every parent render is the simpler, correct
|
|
1194
|
-
* answer — see `selectActiveTodos` for the O(n) cost.
|
|
1195
|
-
*
|
|
1196
|
-
* The hook lives in `chat/` so a GUI consumer can mount it verbatim.
|
|
1197
|
-
* Renderer-agnostic — no `@opentui/*` imports.
|
|
1198
|
-
*/
|
|
1199
|
-
declare function useActiveTodos(session: Session | null | undefined): ActiveTodosState;
|
|
1200
|
-
//#endregion
|
|
1201
|
-
//#region src/chat/turn-operations.d.ts
|
|
1202
|
-
/**
|
|
1203
|
-
* Fork — keep every turn up to and including `turnId`, then strip any
|
|
1204
|
-
* `tool_call` blocks left without a matching `tool_result` in the slice.
|
|
1205
|
-
*
|
|
1206
|
-
* Semantics:
|
|
1207
|
-
* - Include the selected turn ("branch from HERE" mental model — the
|
|
1208
|
-
* user wants the selected message to be the latest in the fork).
|
|
1209
|
-
* - If the selected turn is an assistant turn with unresolved
|
|
1210
|
-
* `tool_call` blocks (their `tool_result`s live in turns AFTER the
|
|
1211
|
-
* slice), strip those calls. Otherwise the fork would post an
|
|
1212
|
-
* assistant turn with no matching tool results, breaking the next
|
|
1213
|
-
* provider call.
|
|
1214
|
-
* - Drop turns that become empty (all blocks stripped).
|
|
1215
|
-
*
|
|
1216
|
-
* Returns `null` when `turnId` doesn't exist in `turns` — caller should
|
|
1217
|
-
* surface a "turn not found" error rather than silently no-op.
|
|
1218
|
-
*/
|
|
1219
|
-
declare function truncateTurnsAt(turns: readonly SessionTurn[], turnId: string): SessionTurn[] | null;
|
|
1220
|
-
/**
|
|
1221
|
-
* Delete — remove the turn with `turnId` and any tool blocks left
|
|
1222
|
-
* orphaned by the removal. Returns `null` when `turnId` doesn't exist.
|
|
1223
|
-
*
|
|
1224
|
-
* Strategy:
|
|
1225
|
-
* 1. Drop the target turn.
|
|
1226
|
-
* 2. Scan the remaining turns for `tool_call`s without a matching
|
|
1227
|
-
* `tool_result` (orphaned by removing the user turn that carried
|
|
1228
|
-
* the result), and `tool_result`s without a matching `tool_call`
|
|
1229
|
-
* (orphaned by removing the assistant turn that issued the call).
|
|
1230
|
-
* Strip both sides.
|
|
1231
|
-
* 3. Drop turns whose content is now empty.
|
|
1232
|
-
*
|
|
1233
|
-
* This guarantees the resulting history is protocol-clean — a follow-up
|
|
1234
|
-
* `agent.run()` against the modified session can post turns without the
|
|
1235
|
-
* provider rejecting the history.
|
|
1236
|
-
*/
|
|
1237
|
-
declare function deleteTurnSafely(turns: readonly SessionTurn[], turnId: string): SessionTurn[] | null;
|
|
1238
|
-
/**
|
|
1239
|
-
* Serialize a turn's content to a clean text representation suited for
|
|
1240
|
-
* the clipboard. Joins text + thinking blocks verbatim; tool calls and
|
|
1241
|
-
* tool results get bracketed labels so the user can paste a readable
|
|
1242
|
-
* record of what happened without losing structure.
|
|
1243
|
-
*
|
|
1244
|
-
* Empty turns return `''`.
|
|
1245
|
-
*/
|
|
1246
|
-
declare function turnAsText(turn: SessionTurn): string;
|
|
1247
|
-
/**
|
|
1248
|
-
* Count turns before / after the one identified by `turnId` in the
|
|
1249
|
-
* given list. Returns `null` when the id is missing. Used to label the
|
|
1250
|
-
* turn-details modal with `N before · M after`.
|
|
1251
|
-
*/
|
|
1252
|
-
declare function countNeighbors(turnIds: readonly string[], turnId: string): {
|
|
1253
|
-
before: number;
|
|
1254
|
-
after: number;
|
|
1255
|
-
} | null;
|
|
1256
|
-
//#endregion
|
|
1257
|
-
export { formatTaskSummary as $, chatReferenceTokensFromText as $t, finalizeStreamingMarkdown as A, buildEditOutcomesAnnotation as At, formatCredits as B, uniqueSkillNamesFromReferences as Bt, sanitizeTodoItems as C, extractEditPayload as Ct, MAX_TRANSCRIPT_EVENTS as D, summarizeEditPayload as Dt, useActiveTodos as E, splitLines as Et, ProviderUsageStatus as F, rewriteMultiEditHeader as Ft, updatedLabel as G, ListProjectFilesOptions as Gt, mostConstrainedWindow as H, createFilesCompletionProvider as Ht, ProviderUsageWindow as I, stripEditOutcomesAnnotation as It, compactPath as J, createCommandsCompletionProvider as Jt, usageTone as K, listProjectFiles as Kt, UsageTone as L, summarizeOutcomes as Lt, turnContextSize as M, mergeApprovalAndBodyOutcomes as Mt, ProviderUsageCredits as N, parseEditOutcomesFromResult as Nt, TRANSCRIPT_TRIM_TO_EVENTS as O, tokenize as Ot, ProviderUsageSnapshot as P, resolveApprovalForPayload as Pt, formatTaskStatus as Q, ChatReferenceScope as Qt, activeSnapshotFor as R, SKILLS_TRIGGER as Rt, pruneTodosByRun as S, computeLineDiff as St, setTodosForRun as T, previewEditPayload as Tt, resetLabel as U, uniqueFilesFromReferences as Ut, formatUsagePercent as V, FILES_TRIGGER as Vt, showsAccount as W, FileEntry as Wt, fmtTokens as X, ChatReferenceData as Xt, fmtCost as Y, CHATS_TRIGGER as Yt, formatDuration as Z, ChatReferenceEntry as Zt, createTodoTools as _, PreviewResult as _t, ActiveTodosState as a, cacheBreakNoticeText as at, isTodoTool as b, buildUnifiedDiff as bt, TODOREAD_TOOL as c, retryLabel as ct, TODO_STATUS_GLYPHS as d, DiffOp as dt, createChatsCompletionProvider as en, previewLine as et, TODO_WRITE_COUNTS_METADATA_KEY as f, EditHunkSummary as ft, TodosBag as g, InlineSegment as gt, TodoTally as h, InlineDiff as ht, turnAsText as i, cacheBreakChip as it, finalizeStreamingMarkdownForOwner as j, maskToOutcomeKinds as jt, capTranscriptEvents as k, ResolvedApproval as kt, TODOS_METADATA_KEY as l, streamingLabel as lt, TodoStatus as m, HunkResolution as mt, deleteTurnSafely as n, blendHsl as nn, CacheChipContent as nt, CreateTodoToolsOptions as o, compactingLabel as ot, TodoItem as p, EditSummary as pt, ageString as q, COMMANDS_TRIGGER as qt, truncateTurnsAt as r, buildLinearRamp as rn, CacheChipTone as rt, DEFAULT_MAX_TODO_ITEMS as s, liveSessionCost as st, countNeighbors as t, uniqueChatIdsFromReferences as tn, shortId as tt, TODOWRITE_TOOL as u, DiffLine as ut, getArchivedTodosForRun as v, applyEditPayload as vt, selectActiveTodos as w, filetypeFromPath as wt, pickActiveRunId as x, computeInlineDiff as xt, getTodosForRun as y, buildContextualDiff as yt, formatBalance as z, createSkillsCompletionProvider as zt };
|
|
1258
|
-
//# sourceMappingURL=turn-operations-C8bMBDl_.d.ts.map
|