@gaodefa/daocore 2026.5.25 → 2026.5.26
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/abort-By0wxKlI.js +277 -0
- package/dist/abort.runtime-C7zfjxBp.js +2 -0
- package/dist/abort.runtime.js +1 -1
- package/dist/account-inspect-DTeLlJz-.js +173 -0
- package/dist/accounts-B776XBaL.js +119 -0
- package/dist/accounts-CLyZILFF.js +107 -0
- package/dist/accounts-DiXgq14W.js +107 -0
- package/dist/accounts-iTlRLYN8.js +2 -0
- package/dist/acp/control-plane/manager.d.ts +2 -1
- package/dist/acp-runtime-D9YQyGax.js +26 -0
- package/dist/acp-spawn-CWciV70C.js +1275 -0
- package/dist/acp-spawn-DjaS4O_V.js +2 -0
- package/dist/acp-stateful-target-driver-ByvGCj_i.js +89 -0
- package/dist/action-kill-DXeOA6YH.js +33 -0
- package/dist/action-runtime-BjQnG6qb.js +469 -0
- package/dist/action-runtime-api-a73ODsYk.js +2 -0
- package/dist/action-send-B_F3xwIu.js +39 -0
- package/dist/action-spawn-BFiW7gZJ.js +47 -0
- package/dist/actions-Bi7eE2I6.js +161 -0
- package/dist/actions.runtime-DmtbCLld.js +5 -0
- package/dist/agent-BOI4AdYK.js +3 -0
- package/dist/agent-DQPyDWP5.js +2 -0
- package/dist/agent-command-ClCxEw82.js +1367 -0
- package/dist/agent-command-DKqx29vm.d.ts +105 -0
- package/dist/agent-components.runtime-C5wxy4D_.js +10 -0
- package/dist/agent-components.runtime.js +1 -1
- package/dist/agent-harness-BsBVO7nU.d.ts +146 -0
- package/dist/agent-harness-runtime-CkdXIMHI.js +180 -0
- package/dist/agent-harness-runtime-KHFO733B.d.ts +691 -0
- package/dist/agent-harness-task-runtime-CDtn5RjX.js +140 -0
- package/dist/agent-runner-execution-lXW8y0i2.js +1713 -0
- package/dist/agent-runner-utils-OdM9hLGt.js +266 -0
- package/dist/agent-runner.runtime-fZnfhCJI.js +3455 -0
- package/dist/agent-runner.runtime.js +1 -1
- package/dist/agent-runtime-Dp0RDnX1.js +229 -0
- package/dist/agent-via-gateway-vsBf3nqZ.js +463 -0
- package/dist/agents/pi-embedded-runner/tool-split.d.ts +1 -1
- package/dist/agents.commands.add-C94vGOFH.js +304 -0
- package/dist/agents.commands.delete-D-p2NL4v.js +128 -0
- package/dist/api-BZ2QC7WM.js +2 -0
- package/dist/api-BmYK5Dge.js +6 -0
- package/dist/api-CGdlHCIH.js +3 -0
- package/dist/api-CGjlsXii.js +134 -0
- package/dist/api-DGqp6wZo.js +2 -0
- package/dist/api-DKpE-zdY.js +639 -0
- package/dist/api-DNyivJXK.d.ts +52 -0
- package/dist/apply-GK4z5lYw.js +54 -0
- package/dist/apply-_yxsBkiR.js +41 -0
- package/dist/approval-handler.runtime-C7d9p3DG.js +130 -0
- package/dist/assistant-B-h25aRy.js +291 -0
- package/dist/attachment-normalize-DWZ4Nrn-.js +225 -0
- package/dist/attempt-execution-BY9C1EOu.js +558 -0
- package/dist/attempt-execution.runtime-SR7eolDa.js +3 -0
- package/dist/attempt-execution.runtime.js +1 -1
- package/dist/attempt-execution.shared-h6uYmkJz.js +38 -0
- package/dist/attempt.prompt-helpers-COc5m_TZ.js +475 -0
- package/dist/attempt.tool-run-context-CAtfgOqC.js +2094 -0
- package/dist/auth-BdkNYTYU.js +541 -0
- package/dist/banner-0TOO6XHd.js +397 -0
- package/dist/banner-DTHug6Ey.js +2 -0
- package/dist/binding-routing-BJ_A83Nl.js +113 -0
- package/dist/binding-targets-D5dmPh4R.js +121 -0
- package/dist/bot-DX1uG3P-.js +7894 -0
- package/dist/bot-deps-BpaYejaN.js +2 -0
- package/dist/bot-deps-CKFDy5y3.js +747 -0
- package/dist/bot-message-context.runtime-BKOeRg34.js +7 -0
- package/dist/bot-message-context.runtime.js +1 -1
- package/dist/bot-message-context.session.runtime-xgZdFv6P.js +12 -0
- package/dist/bot-message-context.session.runtime.js +1 -1
- package/dist/bot-native-commands.delivery.runtime-DDMQrRfJ.js +4 -0
- package/dist/bot-native-commands.delivery.runtime.js +1 -1
- package/dist/bot-native-commands.runtime-CVVvUz0h.js +13 -0
- package/dist/bot-native-commands.runtime.js +1 -1
- package/dist/bridge-server-37OWsDZc.js +113 -0
- package/dist/browser-cli-BC_6aZJV.js +2 -0
- package/dist/browser-cli-Dg1ipmgf.js +230 -0
- package/dist/browser-cli-actions-input-B0QuzzSW.js +473 -0
- package/dist/browser-cli-actions-observe-C246bas5.js +81 -0
- package/dist/browser-cli-debug-F64e_v4B.js +137 -0
- package/dist/browser-cli-inspect-Srn6eWjO.js +104 -0
- package/dist/browser-cli-manage-CaZ97-Me.js +443 -0
- package/dist/browser-cli-resize-CUR20fvZ.js +26 -0
- package/dist/browser-cli-shared-BhphnFVo.js +50 -0
- package/dist/browser-cli-state-CzaNXNWF.js +337 -0
- package/dist/browser-control-auth-DTY0Wx2B.js +2 -0
- package/dist/browser-profiles-BDGPPDJ7.js +2 -0
- package/dist/browser-runtime-aqBKI8Oi.js +384 -0
- package/dist/build-CG7aTzO9.js +257 -0
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +2 -2
- package/dist/bundled/session-memory/handler.js +1 -1
- package/dist/bundled-channel-config-schema-vrKpzJVf.d.ts +3163 -0
- package/dist/call-Za47o1YZ.d.ts +43 -0
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/capability-cli-BhF26gVm.js +1782 -0
- package/dist/channel-5RHqx1Ge.d.ts +26 -0
- package/dist/channel-5_XS0Mss.js +508 -0
- package/dist/channel-7L-vyWOO.js +362 -0
- package/dist/channel-B07xPK0L.d.ts +114 -0
- package/dist/channel-B9b-GX-e.d.ts +14 -0
- package/dist/channel-BBWX_bA0.d.ts +7 -0
- package/dist/channel-BVxTyJ0I.js +376 -0
- package/dist/channel-BWIsr1r-.js +808 -0
- package/dist/channel-Ba0p4xM-.js +1134 -0
- package/dist/channel-Bi2nTop1.js +481 -0
- package/dist/channel-Bj29iFgF.js +740 -0
- package/dist/channel-Bl8tKAuG.d.ts +427 -0
- package/dist/channel-Bqy7BYGm.d.ts +28 -0
- package/dist/channel-BvzHMdKo.d.ts +8 -0
- package/dist/channel-C6G6-tH6.js +562 -0
- package/dist/channel-CBhuuq-_.js +2126 -0
- package/dist/channel-CMmVpcnl.js +867 -0
- package/dist/channel-COc7idAe.js +653 -0
- package/dist/channel-CcsuLAYt.d.ts +49 -0
- package/dist/channel-CjfuHhSU.js +1556 -0
- package/dist/channel-Cquy73C-.js +1249 -0
- package/dist/channel-Cu7Jxm_X.d.ts +104 -0
- package/dist/channel-CzvuskEn.js +955 -0
- package/dist/channel-D6u-243v.js +1777 -0
- package/dist/channel-DId5JNlc.d.ts +47 -0
- package/dist/channel-DR8PbP31.js +238 -0
- package/dist/channel-DUYRu5km.d.ts +7 -0
- package/dist/channel-DUZ0s98I.js +1496 -0
- package/dist/channel-DXelghSl.d.ts +8 -0
- package/dist/channel-FhfE8D-t.d.ts +6 -0
- package/dist/channel-PEX_yYEO.d.ts +64 -0
- package/dist/channel-aWqPl-K4.d.ts +106 -0
- package/dist/channel-actions.runtime-BzEqt_Va.js +265 -0
- package/dist/channel-actions.runtime.js +1 -1
- package/dist/channel-cSdO0kAq.d.ts +8 -0
- package/dist/channel-core-ClgodQav.d.ts +6 -0
- package/dist/channel-core-DDZnTvT6.js +5 -0
- package/dist/channel-entry-contract-Bzkb_oJX.d.ts +112 -0
- package/dist/channel-inbound-C2wLEE7Q.js +80 -0
- package/dist/channel-lifecycle-DCTZ2J_8.d.ts +126 -0
- package/dist/channel-pairing-pKisqGWj.d.ts +58 -0
- package/dist/channel-plugin-runtime-B8AWkA0i.js +998 -0
- package/dist/channel-plugin-runtime-ntEeH9SC.d.ts +7 -0
- package/dist/channel-runtime-CciKN6E5.js +408 -0
- package/dist/channel-za2kUUnL.d.ts +12 -0
- package/dist/channel.runtime-BQN8Bkb0.js +254 -0
- package/dist/channel.runtime-BXeGEvv7.js +21009 -0
- package/dist/channel.runtime-C40ILulM.js +1008 -0
- package/dist/channel.runtime-CJ2DSojv.js +733 -0
- package/dist/channel.runtime-CUaygROD.js +652 -0
- package/dist/channel.runtime-CcCbJhDb.js +88 -0
- package/dist/channel.runtime-DJbKu9D3.js +4 -0
- package/dist/channel.runtime-DgRuSo5T.js +109 -0
- package/dist/channel.runtime-tRXUD2p2.js +2528 -0
- package/dist/channel.setup-3aVku-g-.js +1098 -0
- package/dist/channel.setup-Cau-V9UT.d.ts +7 -0
- package/dist/channel.setup-DT7Z9egu.js +343 -0
- package/dist/channel.setup-DhlkGTJV.js +10 -0
- package/dist/channel.setup-P5V7jWHY.d.ts +6 -0
- package/dist/channel.setup-x333W0eZ.d.ts +8 -0
- package/dist/chat-D3LWYymW.js +2666 -0
- package/dist/chrome--ATU1T0X.js +1503 -0
- package/dist/cli/run-main.js +9 -9
- package/dist/cli-D8hIXnS1.js +1341 -0
- package/dist/cli-backend-C1JA33SE.d.ts +5 -0
- package/dist/cli-backend-D8WmqNqJ.d.ts +5 -0
- package/dist/cli-compaction-jmi3u2HG.js +347 -0
- package/dist/cli-daS2Mzjd.d.ts +20 -0
- package/dist/cli-metadata-Cy9MEdPv.js +22 -0
- package/dist/cli-runner-DuT8oeZF.js +540 -0
- package/dist/cli-runner-DvKgnkCL.js +2 -0
- package/dist/cli-runner.runtime-B-aD16MD.js +4 -0
- package/dist/cli-runner.runtime-DofcKX1U.js +3 -0
- package/dist/cli-runner.runtime.js +1 -1
- package/dist/cli-shared-BFZytJBA.d.ts +20 -0
- package/dist/cli-startup-metadata.json +13 -13
- package/dist/client-B5IcAlfB.js +650 -0
- package/dist/client-adapter-CXA67h2E.js +897 -0
- package/dist/client-factory-aY6TuKfQ.js +9 -0
- package/dist/command-auth-DS9XgXEG.js +135 -0
- package/dist/command-execution-startup-DQOLt5Sz.js +87 -0
- package/dist/command-handlers-DqxF-IM9.js +1609 -0
- package/dist/command-registry-BSVx1oOc.js +4 -0
- package/dist/command-registry-CsPIOiQ3.js +9 -0
- package/dist/command-registry-core-Bzu5ff5F.js +110 -0
- package/dist/command-status.runtime-MKsizBC-.js +90 -0
- package/dist/command-status.runtime.js +1 -1
- package/dist/commands-B6Y6rqal.d.ts +113 -0
- package/dist/commands-acp-ClJofWty.js +74 -0
- package/dist/commands-compact.runtime-7VqYX4tS.js +10 -0
- package/dist/commands-compact.runtime.js +1 -1
- package/dist/commands-handlers.runtime-Dfqf_Oyp.js +6154 -0
- package/dist/commands-handlers.runtime.js +1 -1
- package/dist/commands-status-CRaEj9Vf.js +16 -0
- package/dist/commands-status-uDaqCP2F.js +3 -0
- package/dist/commands-status.runtime-uDaqCP2F.js +3 -0
- package/dist/commands-status.runtime.js +1 -1
- package/dist/commands-subagents-control.runtime-BaYcGLtc.js +2 -0
- package/dist/commands-subagents-control.runtime-C4xMpLed.js +3 -0
- package/dist/commands-subagents-control.runtime.js +1 -1
- package/dist/commands-system-prompt-C3lzz7wW.js +162 -0
- package/dist/commands-system-prompt-DpiW5FkQ.js +2 -0
- package/dist/commands.runtime-l4fGcB5c.js +176 -0
- package/dist/commands.runtime.js +1 -1
- package/dist/commitments/runtime.js +1 -1
- package/dist/compact-Dq0mi-y_.js +480 -0
- package/dist/compact-voJdoXm-.js +1141 -0
- package/dist/compact.runtime-BNLPSDQQ.js +12 -0
- package/dist/compact.runtime.js +1 -1
- package/dist/completion-cli-qHUelvvd.js +315 -0
- package/dist/computer-use-dP3FCUtq.js +367 -0
- package/dist/config-BDGPPDJ7.js +2 -0
- package/dist/config-Dg3sgjXu.js +373 -0
- package/dist/config-cli-INHPnZOG.js +1633 -0
- package/dist/config-mutations-CAgnXnDt.js +159 -0
- package/dist/config-schema-BkkovNaj.d.ts +20 -0
- package/dist/configure-M1VU0h9O.js +3 -0
- package/dist/configure.commands-CM8RXyn3.js +1251 -0
- package/dist/configure.commands-PvOJd4nu.js +2 -0
- package/dist/context-engine-host-compat-D7I7Q63Z.js +288 -0
- package/dist/context-engine-host-compat-DGHUiQUV.js +2 -0
- package/dist/context-engine-lifecycle-Zsi-S6qy.js +1274 -0
- package/dist/contracts-testkit-Ch7UfUw6.d.ts +145 -0
- package/dist/control-auth-BKUTwIvH.js +114 -0
- package/dist/control-service-CKUzEAa0.js +145 -0
- package/dist/control-ui/assets/agents-CUjpwxUf.js +1008 -0
- package/dist/control-ui/assets/channel-config-extras-Dd4z5RQ8.js +2 -0
- package/dist/control-ui/assets/channels-554ojNKp.js +367 -0
- package/dist/control-ui/assets/cron-BAd2PXq5.js +1013 -0
- package/dist/control-ui/assets/debug-BGCb3cT4.js +97 -0
- package/dist/control-ui/assets/index-BXico1DI.js +7370 -0
- package/dist/control-ui/assets/instances-EkBPy6m3.js +57 -0
- package/dist/control-ui/assets/logs-zcOeZekZ.js +74 -0
- package/dist/control-ui/assets/nodes-BymRwDa6.js +436 -0
- package/dist/control-ui/assets/sessions-C_oSuy7x.js +399 -0
- package/dist/control-ui/assets/skills-BVjEetcV.js +314 -0
- package/dist/control-ui/assets/skills-shared-weS2ZYM5.js +11 -0
- package/dist/control-ui/index.html +1 -1
- package/dist/control-ui/sw.js +1 -1
- package/dist/conversation-binding-runtime-rXAYUZyM.js +4 -0
- package/dist/conversation-runtime-CV0pSg81.js +31 -0
- package/dist/core-BV0irASW.js +282 -0
- package/dist/core-DIjsbXou.d.ts +224 -0
- package/dist/core-api-CyhjZVzn.js +5 -0
- package/dist/core-api-YdHGjff8.js +2 -0
- package/dist/crestodian/crestodian.js +1 -1
- package/dist/crestodian/rescue-message.js +1 -1
- package/dist/crestodian-n5FVHIW5.js +55 -0
- package/dist/daocore-runtime-DhfJoXrT.d.ts +151 -0
- package/dist/daocore-tools-CXDZ1Xhe.js +11727 -0
- package/dist/dashboard-CeQV6L1K.js +263 -0
- package/dist/delivery-D7LfafSk.js +1002 -0
- package/dist/dev-BSY4rs1s.js +97 -0
- package/dist/dialogue-DWFnjTiN.js +37 -0
- package/dist/dir-fetch-tool-BnlEyfZh.js +565 -0
- package/dist/dir-list-tool-Blhg_vTH.js +100 -0
- package/dist/direct-dm-DJPIaf5J.js +64 -0
- package/dist/directive-handling.fast-lane-DGV6PZYZ.js +68 -0
- package/dist/directive-handling.impl-CTDwclQa.js +818 -0
- package/dist/directive-handling.impl-_zI0_GsT.js +2 -0
- package/dist/directive-handling.model-selection-C8lG4FHQ.js +122 -0
- package/dist/directive-handling.persist.runtime-CmLb1evR.js +263 -0
- package/dist/directive-handling.persist.runtime.js +1 -1
- package/dist/dispatch-DvZRbIrc.js +1640 -0
- package/dist/dispatch-acp-transcript.runtime-PehNIsnR.js +40 -0
- package/dist/dispatch-acp-transcript.runtime.js +1 -1
- package/dist/dispatch-acp.runtime-Dg8ft-Ve.js +18 -0
- package/dist/dispatch-acp.runtime.js +1 -1
- package/dist/doctor-DJFM3lrT.js +6 -0
- package/dist/doctor-_ob4EiVf.js +2 -0
- package/dist/doctor-config-flow-D6iEk-en.js +1741 -0
- package/dist/doctor-core-checks-CCfWWL1-.js +573 -0
- package/dist/doctor-core-checks-CqkHUVcZ.js +2 -0
- package/dist/doctor-health-CrNPft4G.js +65 -0
- package/dist/doctor-health-contributions-Bwu5M_GQ.js +696 -0
- package/dist/doctor-lint-B2Wb_jEn.js +94 -0
- package/dist/doctor-prompter-cXq7RExi.js +58 -0
- package/dist/doctor-state-integrity-DfYyVFbQ.js +1231 -0
- package/dist/dynamic-tools-CbHsYkuk.js +486 -0
- package/dist/embedded-backend-IYuqoxzv.js +579 -0
- package/dist/embedded-gateway-stub.runtime-BjJ_93Pp.js +12 -0
- package/dist/embedded-gateway-stub.runtime.js +1 -1
- package/dist/embedding-provider-B50jxKn8.d.ts +65 -0
- package/dist/embedding-provider-DOktf4gm.d.ts +21 -0
- package/dist/embedding-provider-DZOjws8e.d.ts +16 -0
- package/dist/entry.d.ts +1 -1
- package/dist/entry.js +1 -1
- package/dist/exec-approvals-VjIKwFog.js +149 -0
- package/dist/extensionAPI.js +1 -1
- package/dist/extensions/active-memory/index.d.ts +1 -1
- package/dist/extensions/active-memory/index.js +1 -1
- package/dist/extensions/admin-http-rpc/index.d.ts +1 -1
- package/dist/extensions/admin-http-rpc/index.js +1 -1
- package/dist/extensions/alibaba/index.d.ts +1 -1
- package/dist/extensions/anthropic/api.d.ts +3 -3
- package/dist/extensions/anthropic/cli-backend-api.d.ts +2 -2
- package/dist/extensions/anthropic/cli-backend.d.ts +1 -1
- package/dist/extensions/anthropic/cli-migration.d.ts +1 -1
- package/dist/extensions/anthropic/cli-shared.d.ts +1 -1
- package/dist/extensions/anthropic/contract-api.d.ts +1 -1
- package/dist/extensions/anthropic/index.d.ts +1 -1
- package/dist/extensions/anthropic/provider-contract-api.d.ts +1 -1
- package/dist/extensions/anthropic/provider-discovery.d.ts +1 -1
- package/dist/extensions/anthropic/provider-policy-api.d.ts +1 -1
- package/dist/extensions/anthropic/register.runtime.d.ts +1 -1
- package/dist/extensions/anthropic/replay-policy.d.ts +1 -1
- package/dist/extensions/anthropic/setup-api.d.ts +1 -1
- package/dist/extensions/anthropic/stream-wrappers.d.ts +1 -1
- package/dist/extensions/anthropic/test-api.d.ts +2 -2
- package/dist/extensions/arcee/index.d.ts +1 -1
- package/dist/extensions/azure-speech/index.d.ts +1 -1
- package/dist/extensions/azure-speech/speech-provider.d.ts +1 -1
- package/dist/extensions/bonjour/index.d.ts +1 -1
- package/dist/extensions/browser/browser-bridge.js +1 -1
- package/dist/extensions/browser/browser-config.js +4 -4
- package/dist/extensions/browser/browser-control-auth.js +2 -2
- package/dist/extensions/browser/browser-doctor.js +2 -2
- package/dist/extensions/browser/browser-maintenance.js +1 -1
- package/dist/extensions/browser/browser-profiles.js +2 -2
- package/dist/extensions/browser/browser-runtime-api.js +11 -11
- package/dist/extensions/browser/cli-metadata.d.ts +1 -1
- package/dist/extensions/browser/cli-metadata.js +1 -1
- package/dist/extensions/browser/index.d.ts +1 -1
- package/dist/extensions/browser/index.js +1 -1
- package/dist/extensions/browser/plugin-registration.d.ts +1 -1
- package/dist/extensions/browser/plugin-registration.js +1 -1
- package/dist/extensions/browser/register.runtime.d.ts +2 -2
- package/dist/extensions/browser/register.runtime.js +4 -4
- package/dist/extensions/browser/runtime-api.d.ts +3 -3
- package/dist/extensions/browser/runtime-api.js +13 -13
- package/dist/extensions/browser/setup-api.d.ts +1 -1
- package/dist/extensions/byteplus/index.d.ts +1 -1
- package/dist/extensions/byteplus/provider-discovery.d.ts +1 -1
- package/dist/extensions/canvas/cli-metadata.d.ts +1 -1
- package/dist/extensions/canvas/index.d.ts +1 -1
- package/dist/extensions/canvas/index.js +1 -1
- package/dist/extensions/canvas/runtime-api.d.ts +2 -2
- package/dist/extensions/canvas/setup-api.d.ts +1 -1
- package/dist/extensions/cerebras/index.d.ts +1 -1
- package/dist/extensions/chutes/index.d.ts +1 -1
- package/dist/extensions/clickclack/api.d.ts +2 -2
- package/dist/extensions/clickclack/api.js +2 -2
- package/dist/extensions/clickclack/channel-plugin-api.d.ts +1 -1
- package/dist/extensions/clickclack/channel-plugin-api.js +1 -1
- package/dist/extensions/clickclack/index.d.ts +2 -2
- package/dist/extensions/clickclack/runtime-api.d.ts +2 -2
- package/dist/extensions/clickclack/runtime-api.js +2 -2
- package/dist/extensions/cloudflare-ai-gateway/index.d.ts +1 -1
- package/dist/extensions/cloudflare-ai-gateway/stream-wrappers.d.ts +1 -1
- package/dist/extensions/comfy/index.d.ts +1 -1
- package/dist/extensions/copilot-proxy/index.d.ts +1 -1
- package/dist/extensions/copilot-proxy/runtime-api.d.ts +2 -2
- package/dist/extensions/deepgram/index.d.ts +1 -1
- package/dist/extensions/deepgram/realtime-transcription-provider.d.ts +1 -1
- package/dist/extensions/deepgram/test-api.d.ts +1 -1
- package/dist/extensions/deepinfra/api.d.ts +2 -2
- package/dist/extensions/deepinfra/embedding-provider.d.ts +1 -1
- package/dist/extensions/deepinfra/index.d.ts +1 -1
- package/dist/extensions/deepinfra/memory-embedding-adapter.d.ts +1 -1
- package/dist/extensions/deepinfra/speech-provider.d.ts +1 -1
- package/dist/extensions/deepseek/api.d.ts +1 -1
- package/dist/extensions/deepseek/index.d.ts +1 -1
- package/dist/extensions/deepseek/provider-discovery.d.ts +1 -1
- package/dist/extensions/deepseek/provider-policy-api.d.ts +1 -1
- package/dist/extensions/deepseek/stream.d.ts +1 -1
- package/dist/extensions/deepseek/thinking.d.ts +1 -1
- package/dist/extensions/device-pair/api.d.ts +3 -3
- package/dist/extensions/device-pair/api.js +1 -1
- package/dist/extensions/device-pair/index.d.ts +1 -1
- package/dist/extensions/device-pair/notify.d.ts +1 -1
- package/dist/extensions/device-pair/pair-command-approve.js +1 -1
- package/dist/extensions/document-extract/index.d.ts +1 -1
- package/dist/extensions/duckduckgo/index.d.ts +1 -1
- package/dist/extensions/elevenlabs/index.d.ts +1 -1
- package/dist/extensions/elevenlabs/realtime-transcription-provider.d.ts +1 -1
- package/dist/extensions/elevenlabs/setup-api.d.ts +1 -1
- package/dist/extensions/elevenlabs/speech-provider.d.ts +1 -1
- package/dist/extensions/elevenlabs/test-api.d.ts +2 -2
- package/dist/extensions/exa/index.d.ts +1 -1
- package/dist/extensions/fal/index.d.ts +1 -1
- package/dist/extensions/fal/provider-contract-api.d.ts +1 -1
- package/dist/extensions/fal/provider-registration.d.ts +1 -1
- package/dist/extensions/file-transfer/index.d.ts +1 -1
- package/dist/extensions/file-transfer/index.js +4 -4
- package/dist/extensions/firecrawl/index.d.ts +1 -1
- package/dist/extensions/fireworks/index.d.ts +1 -1
- package/dist/extensions/fireworks/provider-policy-api.d.ts +1 -1
- package/dist/extensions/fireworks/stream.d.ts +1 -1
- package/dist/extensions/fireworks/thinking-policy.d.ts +1 -1
- package/dist/extensions/github-copilot/embeddings.d.ts +1 -1
- package/dist/extensions/github-copilot/index.d.ts +1 -1
- package/dist/extensions/github-copilot/models.d.ts +1 -1
- package/dist/extensions/github-copilot/register.runtime.d.ts +2 -2
- package/dist/extensions/github-copilot/stream.d.ts +1 -1
- package/dist/extensions/google/api.d.ts +5 -5
- package/dist/extensions/google/cli-backend.d.ts +1 -1
- package/dist/extensions/google/embedding-batch.d.ts +1 -1
- package/dist/extensions/google/embedding-provider.d.ts +1 -1
- package/dist/extensions/google/gemini-cli-provider.d.ts +1 -1
- package/dist/extensions/google/index.d.ts +1 -1
- package/dist/extensions/google/memory-embedding-adapter.d.ts +1 -1
- package/dist/extensions/google/provider-contract-api.d.ts +1 -1
- package/dist/extensions/google/provider-hooks.d.ts +2 -2
- package/dist/extensions/google/provider-models.d.ts +1 -1
- package/dist/extensions/google/provider-policy-api.d.ts +1 -1
- package/dist/extensions/google/provider-policy.d.ts +1 -1
- package/dist/extensions/google/provider-registration.d.ts +1 -1
- package/dist/extensions/google/realtime-voice-provider.d.ts +1 -1
- package/dist/extensions/google/runtime-api.d.ts +3 -3
- package/dist/extensions/google/setup-api.d.ts +1 -1
- package/dist/extensions/google/speech-provider.d.ts +1 -1
- package/dist/extensions/google/test-api.d.ts +2 -2
- package/dist/extensions/google/thinking-api.d.ts +1 -1
- package/dist/extensions/google/thinking.d.ts +1 -1
- package/dist/extensions/google/transport-stream.d.ts +1 -1
- package/dist/extensions/gradium/index.d.ts +1 -1
- package/dist/extensions/gradium/speech-provider.d.ts +1 -1
- package/dist/extensions/groq/index.d.ts +1 -1
- package/dist/extensions/huggingface/index.d.ts +1 -1
- package/dist/extensions/image-generation-core/api.d.ts +4 -4
- package/dist/extensions/image-generation-core/runtime-api.d.ts +1 -1
- package/dist/extensions/imessage/api.d.ts +2 -2
- package/dist/extensions/imessage/api.js +2 -2
- package/dist/extensions/imessage/channel-plugin-api.d.ts +1 -1
- package/dist/extensions/imessage/channel-plugin-api.js +1 -1
- package/dist/extensions/imessage/index.d.ts +2 -2
- package/dist/extensions/imessage/message-tool-api.d.ts +1 -1
- package/dist/extensions/imessage/runtime-api.d.ts +4 -4
- package/dist/extensions/imessage/runtime-api.js +3 -3
- package/dist/extensions/imessage/setup-entry.d.ts +2 -2
- package/dist/extensions/imessage/test-api.d.ts +1 -1
- package/dist/extensions/inworld/index.d.ts +1 -1
- package/dist/extensions/inworld/speech-provider.d.ts +1 -1
- package/dist/extensions/irc/api.d.ts +1 -1
- package/dist/extensions/irc/api.js +2 -2
- package/dist/extensions/irc/channel-plugin-api.d.ts +1 -1
- package/dist/extensions/irc/channel-plugin-api.js +1 -1
- package/dist/extensions/irc/index.d.ts +2 -2
- package/dist/extensions/irc/setup-entry.d.ts +2 -2
- package/dist/extensions/kilocode/index.d.ts +1 -1
- package/dist/extensions/kimi-coding/index.d.ts +1 -1
- package/dist/extensions/kimi-coding/stream.d.ts +1 -1
- package/dist/extensions/litellm/index.d.ts +1 -1
- package/dist/extensions/llm-task/api.d.ts +2 -2
- package/dist/extensions/llm-task/index.d.ts +1 -1
- package/dist/extensions/llm-task/index.js +1 -1
- package/dist/extensions/lmstudio/api.d.ts +1 -1
- package/dist/extensions/lmstudio/index.d.ts +1 -1
- package/dist/extensions/lmstudio/memory-embedding-adapter.d.ts +1 -1
- package/dist/extensions/mattermost/api.js +1 -1
- package/dist/extensions/mattermost/channel-plugin-api.d.ts +2 -2
- package/dist/extensions/mattermost/channel-plugin-api.js +1 -1
- package/dist/extensions/mattermost/channel-plugin-runtime.d.ts +1 -1
- package/dist/extensions/mattermost/channel-plugin-runtime.js +1 -1
- package/dist/extensions/mattermost/index.d.ts +2 -2
- package/dist/extensions/mattermost/policy-api.js +1 -1
- package/dist/extensions/mattermost/runtime-api.d.ts +9 -9
- package/dist/extensions/mattermost/runtime-api.js +2 -2
- package/dist/extensions/mattermost/setup-entry.d.ts +2 -2
- package/dist/extensions/mattermost/slash-route-api.d.ts +1 -1
- package/dist/extensions/mattermost/slash-route-api.js +1 -1
- package/dist/extensions/memory-core/api.d.ts +1 -1
- package/dist/extensions/memory-core/cli-metadata.d.ts +1 -1
- package/dist/extensions/memory-core/cli-metadata.js +1 -1
- package/dist/extensions/memory-core/index.d.ts +1 -1
- package/dist/extensions/memory-core/manager-runtime.d.ts +1 -1
- package/dist/extensions/memory-core/runtime-api.d.ts +2 -2
- package/dist/extensions/memory-wiki/api.d.ts +3 -3
- package/dist/extensions/memory-wiki/cli-metadata.d.ts +1 -1
- package/dist/extensions/memory-wiki/index.d.ts +1 -1
- package/dist/extensions/memory-wiki/setup-api.d.ts +1 -1
- package/dist/extensions/microsoft/index.d.ts +1 -1
- package/dist/extensions/microsoft/speech-provider.d.ts +1 -1
- package/dist/extensions/microsoft/test-api.d.ts +1 -1
- package/dist/extensions/microsoft-foundry/auth.d.ts +1 -1
- package/dist/extensions/microsoft-foundry/cli.d.ts +1 -1
- package/dist/extensions/microsoft-foundry/index.d.ts +1 -1
- package/dist/extensions/microsoft-foundry/onboard.d.ts +3 -3
- package/dist/extensions/microsoft-foundry/provider.d.ts +1 -1
- package/dist/extensions/microsoft-foundry/runtime.d.ts +1 -1
- package/dist/extensions/microsoft-foundry/shared-runtime.d.ts +1 -1
- package/dist/extensions/microsoft-foundry/shared.d.ts +1 -1
- package/dist/extensions/migrate-claude/apply.d.ts +1 -1
- package/dist/extensions/migrate-claude/apply.js +1 -1
- package/dist/extensions/migrate-claude/config.d.ts +1 -1
- package/dist/extensions/migrate-claude/helpers.d.ts +1 -1
- package/dist/extensions/migrate-claude/index.d.ts +1 -1
- package/dist/extensions/migrate-claude/index.js +1 -1
- package/dist/extensions/migrate-claude/memory.d.ts +2 -2
- package/dist/extensions/migrate-claude/plan.d.ts +1 -1
- package/dist/extensions/migrate-claude/plan.js +1 -1
- package/dist/extensions/migrate-claude/provider.d.ts +1 -1
- package/dist/extensions/migrate-claude/provider.js +1 -1
- package/dist/extensions/migrate-claude/skills.d.ts +2 -2
- package/dist/extensions/migrate-claude/targets.d.ts +1 -1
- package/dist/extensions/migrate-claude/targets.js +1 -1
- package/dist/extensions/migrate-hermes/apply.d.ts +1 -1
- package/dist/extensions/migrate-hermes/apply.js +1 -1
- package/dist/extensions/migrate-hermes/config.d.ts +1 -1
- package/dist/extensions/migrate-hermes/helpers.d.ts +1 -1
- package/dist/extensions/migrate-hermes/index.d.ts +1 -1
- package/dist/extensions/migrate-hermes/index.js +1 -1
- package/dist/extensions/migrate-hermes/items.d.ts +1 -1
- package/dist/extensions/migrate-hermes/model.d.ts +1 -1
- package/dist/extensions/migrate-hermes/model.js +1 -1
- package/dist/extensions/migrate-hermes/plan.d.ts +1 -1
- package/dist/extensions/migrate-hermes/plan.js +1 -1
- package/dist/extensions/migrate-hermes/provider.d.ts +1 -1
- package/dist/extensions/migrate-hermes/provider.js +1 -1
- package/dist/extensions/migrate-hermes/secrets.d.ts +2 -2
- package/dist/extensions/migrate-hermes/secrets.js +1 -1
- package/dist/extensions/migrate-hermes/skills.d.ts +2 -2
- package/dist/extensions/migrate-hermes/targets.d.ts +1 -1
- package/dist/extensions/migrate-hermes/targets.js +1 -1
- package/dist/extensions/minimax/index.d.ts +1 -1
- package/dist/extensions/minimax/provider-contract-api.d.ts +1 -1
- package/dist/extensions/minimax/provider-registration.d.ts +1 -1
- package/dist/extensions/minimax/speech-provider.d.ts +1 -1
- package/dist/extensions/mistral/embedding-provider.d.ts +1 -1
- package/dist/extensions/mistral/index.d.ts +1 -1
- package/dist/extensions/mistral/memory-embedding-adapter.d.ts +1 -1
- package/dist/extensions/mistral/realtime-transcription-provider.d.ts +1 -1
- package/dist/extensions/mistral/test-api.d.ts +1 -1
- package/dist/extensions/moonshot/index.d.ts +1 -1
- package/dist/extensions/moonshot/provider-contract-api.d.ts +1 -1
- package/dist/extensions/moonshot/provider-discovery.d.ts +1 -1
- package/dist/extensions/nvidia/index.d.ts +1 -1
- package/dist/extensions/oc-path/cli-metadata.d.ts +1 -1
- package/dist/extensions/oc-path/cli-registration.d.ts +1 -1
- package/dist/extensions/oc-path/index.d.ts +1 -1
- package/dist/extensions/ollama/api.d.ts +1 -1
- package/dist/extensions/ollama/index.d.ts +1 -1
- package/dist/extensions/ollama/provider-discovery.d.ts +1 -1
- package/dist/extensions/ollama/provider-policy-api.d.ts +1 -1
- package/dist/extensions/ollama/runtime-api.d.ts +1 -1
- package/dist/extensions/open-prose/index.d.ts +1 -1
- package/dist/extensions/open-prose/runtime-api.d.ts +2 -2
- package/dist/extensions/openai/api.d.ts +4 -4
- package/dist/extensions/openai/embedding-batch.d.ts +1 -1
- package/dist/extensions/openai/embedding-provider.d.ts +1 -1
- package/dist/extensions/openai/index.d.ts +1 -1
- package/dist/extensions/openai/memory-embedding-adapter.d.ts +1 -1
- package/dist/extensions/openai/openai-codex-oauth.runtime.d.ts +1 -1
- package/dist/extensions/openai/openai-codex-provider.d.ts +1 -1
- package/dist/extensions/openai/openai-provider.d.ts +1 -1
- package/dist/extensions/openai/prompt-overlay.d.ts +1 -1
- package/dist/extensions/openai/provider-contract-api.d.ts +1 -1
- package/dist/extensions/openai/provider-policy-api.d.ts +1 -1
- package/dist/extensions/openai/realtime-transcription-provider.d.ts +1 -1
- package/dist/extensions/openai/realtime-voice-provider.d.ts +1 -1
- package/dist/extensions/openai/register.runtime.d.ts +6 -6
- package/dist/extensions/openai/replay-policy.d.ts +1 -1
- package/dist/extensions/openai/setup-api.d.ts +1 -1
- package/dist/extensions/openai/shared.d.ts +3 -3
- package/dist/extensions/openai/speech-provider.d.ts +1 -1
- package/dist/extensions/openai/test-api.d.ts +3 -3
- package/dist/extensions/openai/thinking-policy.d.ts +1 -1
- package/dist/extensions/openai/transport-policy.d.ts +1 -1
- package/dist/extensions/opencode/index.d.ts +1 -1
- package/dist/extensions/opencode/provider-policy-api.d.ts +1 -1
- package/dist/extensions/opencode-go/index.d.ts +1 -1
- package/dist/extensions/opencode-go/provider-catalog.d.ts +1 -1
- package/dist/extensions/opencode-go/stream.d.ts +1 -1
- package/dist/extensions/openrouter/api.d.ts +1 -1
- package/dist/extensions/openrouter/index.d.ts +1 -1
- package/dist/extensions/openrouter/provider-contract-api.d.ts +1 -1
- package/dist/extensions/openrouter/provider-policy-api.d.ts +1 -1
- package/dist/extensions/openrouter/speech-provider.d.ts +1 -1
- package/dist/extensions/openrouter/stream.d.ts +1 -1
- package/dist/extensions/openrouter/test-api.d.ts +1 -1
- package/dist/extensions/openrouter/thinking-policy.d.ts +1 -1
- package/dist/extensions/openrouter/video-generation-provider.d.ts +1 -1
- package/dist/extensions/openrouter/video-model-catalog.d.ts +1 -1
- package/dist/extensions/perplexity/index.d.ts +1 -1
- package/dist/extensions/phone-control/index.d.ts +1 -1
- package/dist/extensions/phone-control/runtime-api.d.ts +2 -2
- package/dist/extensions/policy/api.js +1 -1
- package/dist/extensions/policy/index.d.ts +1 -1
- package/dist/extensions/policy/index.js +2 -2
- package/dist/extensions/qianfan/index.d.ts +1 -1
- package/dist/extensions/qwen/api.d.ts +1 -1
- package/dist/extensions/qwen/index.d.ts +1 -1
- package/dist/extensions/qwen/stream.d.ts +1 -1
- package/dist/extensions/runway/index.d.ts +1 -1
- package/dist/extensions/searxng/index.d.ts +1 -1
- package/dist/extensions/senseaudio/index.d.ts +1 -1
- package/dist/extensions/sglang/index.d.ts +1 -1
- package/dist/extensions/signal/api.d.ts +3 -3
- package/dist/extensions/signal/api.js +6 -6
- package/dist/extensions/signal/channel-entry.d.ts +2 -2
- package/dist/extensions/signal/channel-plugin-api.d.ts +1 -1
- package/dist/extensions/signal/channel-plugin-api.js +1 -1
- package/dist/extensions/signal/index.d.ts +2 -2
- package/dist/extensions/signal/reaction-runtime-api.js +1 -1
- package/dist/extensions/signal/runtime-api.d.ts +7 -7
- package/dist/extensions/signal/runtime-api.js +7 -7
- package/dist/extensions/signal/setup-entry.d.ts +2 -2
- package/dist/extensions/skill-workshop/api.d.ts +2 -2
- package/dist/extensions/skill-workshop/api.js +1 -1
- package/dist/extensions/skill-workshop/index.d.ts +1 -1
- package/dist/extensions/skill-workshop/index.js +2 -2
- package/dist/extensions/speech-core/api.d.ts +3 -3
- package/dist/extensions/speech-core/runtime-api.d.ts +2 -2
- package/dist/extensions/stepfun/index.d.ts +1 -1
- package/dist/extensions/synthetic/index.d.ts +1 -1
- package/dist/extensions/talk-voice/api.d.ts +2 -2
- package/dist/extensions/talk-voice/index.d.ts +1 -1
- package/dist/extensions/tavily/index.d.ts +1 -1
- package/dist/extensions/telegram/account-inspect-api.js +1 -1
- package/dist/extensions/telegram/api.d.ts +4 -4
- package/dist/extensions/telegram/api.js +11 -11
- package/dist/extensions/telegram/channel-plugin-api.d.ts +2 -2
- package/dist/extensions/telegram/channel-plugin-api.js +2 -2
- package/dist/extensions/telegram/contract-api.d.ts +1 -1
- package/dist/extensions/telegram/contract-api.js +3 -3
- package/dist/extensions/telegram/index.d.ts +2 -2
- package/dist/extensions/telegram/runtime-api.d.ts +4 -4
- package/dist/extensions/telegram/runtime-api.js +7 -7
- package/dist/extensions/telegram/security-audit-contract-api.js +1 -1
- package/dist/extensions/telegram/setup-entry.d.ts +2 -2
- package/dist/extensions/telegram/setup-plugin-api.d.ts +1 -1
- package/dist/extensions/telegram/setup-plugin-api.js +1 -1
- package/dist/extensions/telegram/test-api.js +2 -2
- package/dist/extensions/tencent/index.d.ts +1 -1
- package/dist/extensions/tencent/provider-discovery.d.ts +1 -1
- package/dist/extensions/thread-ownership/api.d.ts +2 -2
- package/dist/extensions/thread-ownership/index.d.ts +1 -1
- package/dist/extensions/together/index.d.ts +1 -1
- package/dist/extensions/tokenjuice/index.d.ts +1 -1
- package/dist/extensions/tokenjuice/tool-result-middleware.d.ts +1 -1
- package/dist/extensions/tts-local-cli/index.d.ts +1 -1
- package/dist/extensions/tts-local-cli/speech-provider.d.ts +1 -1
- package/dist/extensions/venice/index.d.ts +1 -1
- package/dist/extensions/venice/stream.d.ts +1 -1
- package/dist/extensions/vercel-ai-gateway/index.d.ts +1 -1
- package/dist/extensions/vercel-ai-gateway/thinking.d.ts +1 -1
- package/dist/extensions/video-generation-core/api.d.ts +3 -3
- package/dist/extensions/video-generation-core/runtime-api.d.ts +1 -1
- package/dist/extensions/vllm/api.d.ts +1 -1
- package/dist/extensions/vllm/index.d.ts +1 -1
- package/dist/extensions/vllm/stream.d.ts +1 -1
- package/dist/extensions/volcengine/index.d.ts +1 -1
- package/dist/extensions/volcengine/provider-discovery.d.ts +1 -1
- package/dist/extensions/volcengine/speech-provider.d.ts +1 -1
- package/dist/extensions/voyage/embedding-batch.d.ts +1 -1
- package/dist/extensions/voyage/embedding-provider.d.ts +1 -1
- package/dist/extensions/voyage/index.d.ts +1 -1
- package/dist/extensions/voyage/memory-embedding-adapter.d.ts +1 -1
- package/dist/extensions/vydra/index.d.ts +1 -1
- package/dist/extensions/vydra/speech-provider.d.ts +1 -1
- package/dist/extensions/web-readability/index.d.ts +1 -1
- package/dist/extensions/webhooks/api.d.ts +2 -2
- package/dist/extensions/webhooks/api.js +1 -1
- package/dist/extensions/webhooks/index.d.ts +1 -1
- package/dist/extensions/webhooks/index.js +1 -1
- package/dist/extensions/webhooks/runtime-api.d.ts +2 -2
- package/dist/extensions/xai/api.d.ts +1 -1
- package/dist/extensions/xai/index.d.ts +1 -1
- package/dist/extensions/xai/index.js +4 -4
- package/dist/extensions/xai/provider-contract-api.d.ts +1 -1
- package/dist/extensions/xai/provider-discovery.d.ts +1 -1
- package/dist/extensions/xai/provider-models.d.ts +1 -1
- package/dist/extensions/xai/provider-policy-api.d.ts +1 -1
- package/dist/extensions/xai/realtime-transcription-provider.d.ts +1 -1
- package/dist/extensions/xai/realtime-transcription-provider.js +1 -1
- package/dist/extensions/xai/setup-api.d.ts +1 -1
- package/dist/extensions/xai/speech-provider.d.ts +1 -1
- package/dist/extensions/xai/speech-provider.js +1 -1
- package/dist/extensions/xai/stream.d.ts +1 -1
- package/dist/extensions/xai/test-api.js +1 -1
- package/dist/extensions/xai/tts.js +1 -1
- package/dist/extensions/xai/web-search.js +1 -1
- package/dist/extensions/xai/xai-oauth.d.ts +1 -1
- package/dist/extensions/xai/xai-oauth.js +1 -1
- package/dist/extensions/xiaomi/index.d.ts +1 -1
- package/dist/extensions/xiaomi/speech-provider.d.ts +1 -1
- package/dist/extensions/xiaomi/stream.d.ts +1 -1
- package/dist/extensions/xiaomi/thinking.d.ts +1 -1
- package/dist/extensions/zai/index.d.ts +1 -1
- package/dist/file-fetch-tool-smMykVXl.js +124 -0
- package/dist/file-write-tool-yEYLZ2hU.js +127 -0
- package/dist/format-DyREJP5V.js +1145 -0
- package/dist/gateway/protocol/index.d.ts +1 -1
- package/dist/gateway-cli-D4yhwJa8.js +435 -0
- package/dist/gateway-method-runtime-B8AOnwqD.js +21 -0
- package/dist/gateway-runtime-BqKz92h9.d.ts +163 -0
- package/dist/gemini-cli-provider-wUxyeRzT.d.ts +6 -0
- package/dist/get-reply-Co-_Qlr-.js +4689 -0
- package/dist/get-reply-from-config.runtime-BcbRKxzJ.js +2 -0
- package/dist/get-reply-from-config.runtime.js +1 -1
- package/dist/graph-users-CF7Dlee2.js +1419 -0
- package/dist/group-access-BTU-w5S5.js +112 -0
- package/dist/group-keys-B_lbVBmI.d.ts +17 -0
- package/dist/handle-action.guild-admin-DS29y_6h.js +288 -0
- package/dist/harness-d9YmZWA3.js +61 -0
- package/dist/health-Cov1Kryj.js +4 -0
- package/dist/heartbeat-runner-B2wo_xDj.js +5 -0
- package/dist/heartbeat-runner.runtime-DrHZD-P2.js +4 -0
- package/dist/heartbeat-runner.runtime.js +1 -1
- package/dist/help-BgDd1atJ.js +136 -0
- package/dist/hook-runtime-UU80d5qW.d.ts +108 -0
- package/dist/hooks-CgXKCJSD.js +534 -0
- package/dist/http-registry-CBDAGRJy.d.ts +23 -0
- package/dist/image-generation-runtime-BFOnMPYD.d.ts +21 -0
- package/dist/inbound-direct-dm-runtime-DjOHl6c_.js +2 -0
- package/dist/inbound-reply-dispatch-BCTiM2jm.js +148 -0
- package/dist/index-D7Vsu6c4.d.ts +3971 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/init-CreYGHpp.js +59 -0
- package/dist/inline-buttons-C94TOhmL.js +40 -0
- package/dist/interactive-dispatch-AIMj_vt7.d.ts +143 -0
- package/dist/interactive-dispatch-Bh_T3uZG.d.ts +56 -0
- package/dist/internal-events-B6D5bqsn.js +90 -0
- package/dist/isolated-agent-9faqxl7c.js +1118 -0
- package/dist/isolated-agent-CaY4uTcE.js +2 -0
- package/dist/lifecycle-pTz4liUn.js +571 -0
- package/dist/list.probe-B8pt-DOd.js +449 -0
- package/dist/list.status-command-Wgmt361J.js +789 -0
- package/dist/llm-slug-generator-Do4oXnXl.js +78 -0
- package/dist/llm-slug-generator.js +1 -1
- package/dist/loader-BFBzvUK_.d.ts +142 -0
- package/dist/local-dispatch.runtime-7keeuHHm.js +9 -0
- package/dist/local-dispatch.runtime.js +1 -1
- package/dist/manager-D058VQAp.d.ts +10 -0
- package/dist/manager-DerRaxsV.d.ts +356 -0
- package/dist/manager.core-DKeUsAcV.d.ts +198 -0
- package/dist/manager.runtime-B3nVh8Nl.js +2714 -0
- package/dist/manager.runtime.js +1 -1
- package/dist/markdown-to-line-CZLeX0SL.js +811 -0
- package/dist/mcp-http-LaAmzBev.js +2 -0
- package/dist/mcp-http-M4GjuKFd.js +555 -0
- package/dist/media-understanding-provider-DLA6VsQZ.js +339 -0
- package/dist/memory-core-host-engine-storage-MF-67Z8w.d.ts +54 -0
- package/dist/memory-embedding-adapter-CEwgurWU.d.ts +5 -0
- package/dist/message-actions-Dlv-B5yk.js +145 -0
- package/dist/message-handler-2HSbEoAi.js +384 -0
- package/dist/message-handler-XiApv_iS.js +1715 -0
- package/dist/message-handler.preflight-CN-g4nxs.js +1125 -0
- package/dist/message-handler.process-BzVq3Lq_.js +1484 -0
- package/dist/migration-BXmTbRk9.d.ts +45 -0
- package/dist/model-Ci5kQ7PA.d.ts +33 -0
- package/dist/model-Sqz99RFi.js +74 -0
- package/dist/model-selection-Bh9QtqlJ.js +272 -0
- package/dist/models-C_dD1FNN.js +2 -0
- package/dist/models-CtpB-fi2.js +104 -0
- package/dist/models-Cxa7r3rl.d.ts +24 -0
- package/dist/models-cli-I2sJE5tg.js +256 -0
- package/dist/monitor-B4J6Kn4-.js +60 -0
- package/dist/monitor-BIFxJ3Ql.js +2788 -0
- package/dist/monitor-BTkcXHvw.js +834 -0
- package/dist/monitor-BX7Encm5.js +1657 -0
- package/dist/monitor-CZsJ4D3J.js +4377 -0
- package/dist/monitor-CvKt9k7P.js +2 -0
- package/dist/monitor-Dy9phiVJ.js +1370 -0
- package/dist/monitor-auth-CjtJPc9C.js +179 -0
- package/dist/monitor-jQpVHEky.js +715 -0
- package/dist/monitor-polling.runtime-Li4-3e2G.js +883 -0
- package/dist/monitor-polling.runtime.js +1 -1
- package/dist/monitor-webhook.runtime-CQ2kN5ya.js +387 -0
- package/dist/monitor-webhook.runtime.js +1 -1
- package/dist/monitor.account-CFdazLEm.js +5233 -0
- package/dist/monitor.runtime-B774iFU_.js +2 -0
- package/dist/monitor.runtime.js +1 -1
- package/dist/monitor.webhook-NNrWA5P9.js +180 -0
- package/dist/node-cli-sessions-Ct-6bGab.js +1228 -0
- package/dist/onboard-DEUA1HCQ.js +733 -0
- package/dist/onboard-helpers-Cupkjkec.js +251 -0
- package/dist/onboard-helpers-D1Pvowo1.js +6 -0
- package/dist/onboard-remote-BN_7wNqG.js +2 -0
- package/dist/onboard-remote-BqYAK5dF.js +212 -0
- package/dist/onboard-skills-BM40qOkc.js +160 -0
- package/dist/onboard-skills-rSLgDOzB.js +2 -0
- package/dist/openai-codex-provider-Fo-TKiyf.d.ts +5 -0
- package/dist/openai-http-BRnxRJ_y.js +824 -0
- package/dist/openai-provider-BqDrspuV.d.ts +5 -0
- package/dist/openresponses-http-Dg3OL0qA.js +1173 -0
- package/dist/operations-jvr0A8cu.js +805 -0
- package/dist/outbound-adapter-BJej9JpO.js +543 -0
- package/dist/outbound-session-route-D3QVwFKr.js +45 -0
- package/dist/outbound.runtime-gdOoPtOh.js +2 -0
- package/dist/outbound.runtime.js +1 -1
- package/dist/pairing-store-C-WQTUHq.d.ts +87 -0
- package/dist/pi-embedded-CwD_xrGP.js +3796 -0
- package/dist/pi-embedded-DL6l8KBl.js +4 -0
- package/dist/pi-embedded.runtime-DyGCj24d.js +4 -0
- package/dist/pi-embedded.runtime.js +1 -1
- package/dist/pi-tools-BzbgexEG.js +2413 -0
- package/dist/plan-HWBV2Rhq.js +112 -0
- package/dist/plan-iN77JYw-.js +81 -0
- package/dist/plugin-BbOOGgCS.d.ts +17 -0
- package/dist/plugin-CbNvjum_.js +12396 -0
- package/dist/plugin-app-cache-key-CHpwYM0e.js +46 -0
- package/dist/plugin-enabled-DjbDhNRG.js +233 -0
- package/dist/plugin-entry-B3_M6paP.d.ts +47 -0
- package/dist/plugin-registration-BM_Iko3e.js +88 -0
- package/dist/plugin-runtime-QzTPitsy.d.ts +117 -0
- package/dist/plugin-sdk/.boundary-entry-shims.stamp +1 -1
- package/dist/plugin-sdk/acp-runtime-backend.js +1 -1
- package/dist/plugin-sdk/acp-runtime.js +2 -2
- package/dist/plugin-sdk/agent-harness-runtime.js +6 -6
- package/dist/plugin-sdk/agent-harness-task-runtime.js +1 -1
- package/dist/plugin-sdk/agent-harness.js +7 -7
- package/dist/plugin-sdk/agent-runtime.js +2 -2
- package/dist/plugin-sdk/channel-core.js +2 -2
- package/dist/plugin-sdk/channel-inbound.js +2 -2
- package/dist/plugin-sdk/channel-test-helpers.js +1 -1
- package/dist/plugin-sdk/command-auth.js +1 -1
- package/dist/plugin-sdk/command-status-runtime.js +1 -1
- package/dist/plugin-sdk/compat.js +1 -1
- package/dist/plugin-sdk/conversation-binding-runtime.js +2 -2
- package/dist/plugin-sdk/conversation-runtime.js +3 -3
- package/dist/plugin-sdk/core.js +2 -2
- package/dist/plugin-sdk/direct-dm.js +1 -1
- package/dist/plugin-sdk/gateway-method-runtime.js +1 -1
- package/dist/plugin-sdk/health.js +2 -2
- package/dist/plugin-sdk/inbound-reply-dispatch.js +1 -1
- package/dist/plugin-sdk/index.js +1 -1
- package/dist/plugin-sdk/mattermost.js +1 -1
- package/dist/plugin-sdk/plugin-test-contracts.js +2 -2
- package/dist/plugin-sdk/provider-test-contracts.js +4 -4
- package/dist/plugin-sdk/reply-runtime.js +4 -4
- package/dist/plugin-sdk/testing.js +2 -2
- package/dist/plugin-sdk/zalouser.js +1 -1
- package/dist/plugin-service-CVyMm03C.js +1229 -0
- package/dist/plugin-service-bHD8oLfO.d.ts +24 -0
- package/dist/plugins/build-smoke-entry.d.ts +2 -2
- package/dist/plugins/loader.d.ts +1 -1
- package/dist/plugins/provider-discovery.runtime.d.ts +1 -1
- package/dist/plugins/provider-runtime.runtime.d.ts +1 -1
- package/dist/plugins/runtime/index.js +4 -4
- package/dist/policy-B2lTxn8H.js +680 -0
- package/dist/policy-Bp9GYcSZ.js +138 -0
- package/dist/prepare.runtime-CxhQeo9l.js +732 -0
- package/dist/prepare.runtime.js +1 -1
- package/dist/preview-warnings-FVRS7Mcs.js +392 -0
- package/dist/probe-BRLc43oX.js +47 -0
- package/dist/probe-C1eD9yG7.js +2204 -0
- package/dist/probe-C1giMJtz.js +682 -0
- package/dist/probe-rIUNPFef.js +2 -0
- package/dist/program-DfIqBXRH.js +131 -0
- package/dist/prompt-overlay-Bq3sUpDV.d.ts +23 -0
- package/dist/provider-BCxvG42s.js +152 -0
- package/dist/provider-BHPMcHk-.js +32 -0
- package/dist/provider-CIAQ8D7q.js +32 -0
- package/dist/provider-api-key-auth-BsEQw2pm.d.ts +27 -0
- package/dist/provider-auth-result-B204hPXB.d.ts +21 -0
- package/dist/provider-catalog-runtime-Dcyw8skT.d.ts +23 -0
- package/dist/provider-catalog-shared-qfgsIQS-.d.ts +62 -0
- package/dist/provider-dispatcher-DyJDef6y.js +22 -0
- package/dist/provider-dispatcher.runtime.js +1 -1
- package/dist/provider-hook-runtime-NiAPyKFa.d.ts +61 -0
- package/dist/provider-j7cYms68.js +8735 -0
- package/dist/provider-model-shared-BwE02tDa.d.ts +143 -0
- package/dist/provider-models-hfm5XTTN.d.ts +12 -0
- package/dist/provider-policy-BB7uTrIp.d.ts +30 -0
- package/dist/provider-registration-DEjYSu9M.d.ts +6 -0
- package/dist/provider-registry-D5hn-VAM.d.ts +8 -0
- package/dist/provider-registry-DHIsMEbc.d.ts +8 -0
- package/dist/provider-registry-VyHjmzoh.d.ts +30 -0
- package/dist/provider-runtime-CdtuIOgf.d.ts +359 -0
- package/dist/provider-self-hosted-setup-xR0Nsu7L.d.ts +74 -0
- package/dist/provider-session.runtime-CmNY15Mr.js +9 -0
- package/dist/provider-session.runtime.js +1 -1
- package/dist/provider-stream-CxVko1CO.d.ts +140 -0
- package/dist/provider-stream-shared-BxFPKFGe.d.ts +128 -0
- package/dist/provider.runtime-DJO3dwrX.js +2 -0
- package/dist/provider.runtime.js +1 -1
- package/dist/providers.runtime-CJOUbS2S.d.ts +25 -0
- package/dist/public-surface-loader-CgBnme5n.js +114 -0
- package/dist/pw-ai-UeRWGzcL.js +3029 -0
- package/dist/pw-role-snapshot-BtlutwlO.js +333 -0
- package/dist/reaction-level-DWOV-qJM.js +19 -0
- package/dist/reaction-runtime-api-5ZiPcbGJ.js +116 -0
- package/dist/realtime-transcription-CZadifvk.d.ts +43 -0
- package/dist/realtime-transcription-provider-BF9HxM3d.d.ts +5 -0
- package/dist/realtime-transcription-provider-Bcj92hEI.d.ts +32 -0
- package/dist/realtime-transcription-provider-DKZ9iHkc.d.ts +28 -0
- package/dist/realtime-transcription-provider-DcsAmQEp.js +205 -0
- package/dist/realtime-transcription-provider-DhjVTTqb.d.ts +37 -0
- package/dist/realtime-voice-B2W34yTP.d.ts +333 -0
- package/dist/realtime-voice-provider-CgNNrGwQ.d.ts +5 -0
- package/dist/register-Dga1nJRL.js +2178 -0
- package/dist/register.agent-VIgyZLKG.js +156 -0
- package/dist/register.configure-C21zJ4Qb.js +16 -0
- package/dist/register.crestodian-Bam6mUXr.js +24 -0
- package/dist/register.maintenance-D9E-Hh90.js +83 -0
- package/dist/register.onboard-BnUcaZsb.js +113 -0
- package/dist/register.runtime-BdRAp4xz.js +54 -0
- package/dist/register.runtime-D3abILg7.d.ts +6 -0
- package/dist/register.setup-Bq-9IQdV.js +40 -0
- package/dist/register.subclis-DubBtg8Z.js +31 -0
- package/dist/register.subclis-H_qmmDFx.js +3 -0
- package/dist/register.subclis-core-fg3DalSH.js +273 -0
- package/dist/registry-CPtiHUu_.d.ts +91 -0
- package/dist/registry-types-XtFJDNYl.d.ts +392 -0
- package/dist/repair-sequencing-Dn0sDvBE.js +640 -0
- package/dist/reply-delivery-DZGfRh-W.js +196 -0
- package/dist/reply-runtime-BdCPL-OF.js +11 -0
- package/dist/reply-runtime-DuaOZ9MH.d.ts +34 -0
- package/dist/reply.runtime-BcbRKxzJ.js +2 -0
- package/dist/reply.runtime.js +1 -1
- package/dist/request-Ca681Kt1.js +54 -0
- package/dist/resolve-allowlist-DWjCzDq1.js +220 -0
- package/dist/result-fallback-classifier-BWIh0wzc.js +79 -0
- package/dist/root-help-8a3TWleF.js +43 -0
- package/dist/route-BsWREv6-.js +469 -0
- package/dist/route-resolution-D8FyF30I.js +274 -0
- package/dist/routes-BxkaJuyM.js +3602 -0
- package/dist/routes-DdwFgSv9.js +2 -0
- package/dist/run-attempt-Ca7HP1Nd.js +7704 -0
- package/dist/run-command-JwrnqCIB.js +2 -0
- package/dist/run-command-wWvfXyIf.js +23 -0
- package/dist/run-embedded.runtime-0QIAc8PG.js +4 -0
- package/dist/run-embedded.runtime.js +1 -1
- package/dist/run-execution-cli.runtime-LhD-S0h_.js +4 -0
- package/dist/run-execution-cli.runtime.js +1 -1
- package/dist/run-executor.runtime.js +1 -1
- package/dist/run-prKMVvM2.js +1162 -0
- package/dist/run-subagent-registry.runtime-C07jSlV2.js +2 -0
- package/dist/run-subagent-registry.runtime.js +1 -1
- package/dist/runtime-3PDZU_1b.d.ts +17 -0
- package/dist/runtime-7Xhj2T8S.js +6179 -0
- package/dist/runtime-CXUwJU3q.js +438 -0
- package/dist/runtime-DeQypuDs.js +1287 -0
- package/dist/runtime-api-0djTIsuz.js +13 -0
- package/dist/runtime-api-9CEihqK3.d.ts +3151 -0
- package/dist/runtime-api-Bz1h0p3i.js +17 -0
- package/dist/runtime-api-CLcJZKu2.js +13 -0
- package/dist/runtime-api-Ce7axAAW.js +24 -0
- package/dist/runtime-api-CoAsju8a.js +4 -0
- package/dist/runtime-api-DEuynhDr.js +3 -0
- package/dist/runtime-api-oZFIOS9l.js +21 -0
- package/dist/runtime-api.actions-Blt2bAHw.d.ts +23 -0
- package/dist/runtime-api.actions-DWLRlSej.js +3 -0
- package/dist/runtime-api.monitor-DtXB3_sf.js +6 -0
- package/dist/runtime-api.send-BU586hbs.js +4 -0
- package/dist/runtime-api.send-BygcWA7R.d.ts +38 -0
- package/dist/runtime-api.threads-Djhr5AJy.js +2 -0
- package/dist/runtime-channel-BIgBTs_X.js +2 -0
- package/dist/runtime-channel-CsUTBjYU.js +150 -0
- package/dist/runtime-embedded-pi.runtime-Rszd_KCt.js +2 -0
- package/dist/runtime-embedded-pi.runtime.js +1 -1
- package/dist/runtime-taskflow-s80xQc2H.d.ts +435 -0
- package/dist/sanitize-outbound-2umQeW_U.js +127 -0
- package/dist/sdk-setup-tools-TiaNam05.js +8 -0
- package/dist/secrets-BmyFSkt-.js +113 -0
- package/dist/secrets-cli-DPAwFvtH.js +149 -0
- package/dist/security-audit-BR9FBcLD.js +122 -0
- package/dist/security-audit-RKut1lWG.js +118 -0
- package/dist/security-audit.runtime-Pe7YbS9P.js +2 -0
- package/dist/security-audit.runtime.js +1 -1
- package/dist/selection-Cqhmjpyl.js +16157 -0
- package/dist/selection-xFFMaq92.js +3 -0
- package/dist/send-BDHagrwl.js +1631 -0
- package/dist/send-BETlETJ5.d.ts +231 -0
- package/dist/send-BV_O_Ljd.js +192 -0
- package/dist/send-CpcmWYrM.d.ts +104 -0
- package/dist/send-W-DVyil6.js +2 -0
- package/dist/send-jUp2-szO.js +143 -0
- package/dist/send.components-BR_yPtKv.js +500 -0
- package/dist/send.components-CK7UbpRP.js +2 -0
- package/dist/send.runtime-DHLfdHbS.js +2 -0
- package/dist/send.runtime.js +1 -1
- package/dist/send.types-D_3tsfSL.d.ts +159 -0
- package/dist/server-DRcdRu6J.js +73 -0
- package/dist/server-Ddv-oAKv.js +24 -0
- package/dist/server-close.runtime.d.ts +1 -1
- package/dist/server-close.runtime.js +1 -1
- package/dist/server-context-9rW0Cvdw.js +2 -0
- package/dist/server-context-uRD5N8_D.js +955 -0
- package/dist/server-cron-BClEPtbv.js +2 -0
- package/dist/server-cron-CNGar45o.js +2989 -0
- package/dist/server-methods-CAMhJf7g.js +16494 -0
- package/dist/server-node-events-DW5DoAxk.js +596 -0
- package/dist/server-plugin-bootstrap-CqX4dDcN.js +70 -0
- package/dist/server-plugins-BIhs3eCz.js +432 -0
- package/dist/server-reload-handlers-54HSfSr7.js +714 -0
- package/dist/server-restart-sentinel-C47-O08k.js +747 -0
- package/dist/server-restart-sentinel-Cx-3Rzl0.js +2 -0
- package/dist/server-runtime-services-D-SWzUww.js +267 -0
- package/dist/server-runtime-services-D0GOFPFq.js +2 -0
- package/dist/server-startup-plugins-C8pzVvkb.js +113 -0
- package/dist/server-startup-post-attach-2xoGJJts.js +716 -0
- package/dist/server-ws-runtime-Dywo6GC-.js +349 -0
- package/dist/server.impl-xK22fZyJ.js +2586 -0
- package/dist/service-Ci8roOZn.js +1446 -0
- package/dist/session-binding-BsdbGBhb.js +219 -0
- package/dist/session-binding-D42jROcb.js +2 -0
- package/dist/session-kill-http-kU4rUj1_.js +121 -0
- package/dist/session-reset-service-DkCGElAA.js +625 -0
- package/dist/session-route-hmQSEijy.js +93 -0
- package/dist/session-status.runtime-Dsz-54he.js +2 -0
- package/dist/session-status.runtime.js +1 -1
- package/dist/session-subagent-reactivation.runtime-CYJIkiW8.js +2 -0
- package/dist/session-subagent-reactivation.runtime.js +1 -1
- package/dist/session-tab-registry-YfQve--K.js +521 -0
- package/dist/sessions-history-http-DeuZSSGj.js +430 -0
- package/dist/sessions.runtime-wAccC8Lk.js +2 -0
- package/dist/sessions.runtime.js +1 -1
- package/dist/setup-B8caUFIZ.js +586 -0
- package/dist/setup-CgHGdMpV.js +2 -0
- package/dist/setup-api-Uew7qBry.js +29 -0
- package/dist/setup-core-BP_fjsmA.js +174 -0
- package/dist/setup-onboard-configure-help-fast-path-ykLp2JqU.js +64 -0
- package/dist/setup-surface-BgEGrdZ3.js +320 -0
- package/dist/setup-surface-BvSqsFEu.js +221 -0
- package/dist/setup-surface-CHzMJ7_T.js +405 -0
- package/dist/setup-surface-DYm3Xvgt.js +288 -0
- package/dist/setup.finalize-BgLIjblM.js +582 -0
- package/dist/setup.gateway-config-BBguRpIc.js +281 -0
- package/dist/setup.migration-import-BY06brv-.js +200 -0
- package/dist/setup.migration-import-Igj5NMey.js +2 -0
- package/dist/shared-client-GL2KQ2Eu.js +2 -0
- package/dist/shared-client-Mc7bTBoQ.js +629 -0
- package/dist/shared-moi7PK0C.js +121 -0
- package/dist/shared-rlOyTpAw.d.ts +115 -0
- package/dist/side-question-BEHswpGw.js +683 -0
- package/dist/simple-completion-runtime-CsXJkjY5.d.ts +73 -0
- package/dist/skill-tool-dispatch.runtime-O5uXeees.js +143 -0
- package/dist/skill-tool-dispatch.runtime.js +1 -1
- package/dist/slash-state-BAYUTcHl.js +2166 -0
- package/dist/speech-BAP4NgqI.d.ts +47 -0
- package/dist/speech-core-DZmhKq_b.d.ts +36 -0
- package/dist/speech-provider-22oDk8Tz.js +184 -0
- package/dist/speech-provider-79S_bTlE.d.ts +8 -0
- package/dist/speech-provider-BYJna1nq.d.ts +5 -0
- package/dist/speech-provider-BvKhsuyg.d.ts +5 -0
- package/dist/speech-provider-CdVIHtT6.d.ts +5 -0
- package/dist/speech-provider-OiRKJFwo.d.ts +8 -0
- package/dist/speech-provider-xUDd1kmD.d.ts +34 -0
- package/dist/src-C8wkJgE6.js +4256 -0
- package/dist/startup-context-BhLJufFU.js +313 -0
- package/dist/status-C20LHDLA.js +73 -0
- package/dist/status-message-CmzgS8zM.js +484 -0
- package/dist/status-message.runtime-iG6qi7wn.js +6 -0
- package/dist/status-message.runtime.js +1 -1
- package/dist/status-subagents.runtime-D49P_RIr.js +18 -0
- package/dist/status-subagents.runtime.js +1 -1
- package/dist/status-text-BI7Q1z4U.js +296 -0
- package/dist/status.runtime-RQes0TI5.js +2 -0
- package/dist/sticker-cache-Dh4joqan.js +206 -0
- package/dist/sticker-vision.runtime-5SRgpo_k.js +17 -0
- package/dist/sticker-vision.runtime.js +1 -1
- package/dist/stream-BrMwI7HV.d.ts +10 -0
- package/dist/stream-Bx_akKgo.d.ts +16 -0
- package/dist/stream-D094UIVI.d.ts +5 -0
- package/dist/stream-D5DoOmTT.d.ts +19 -0
- package/dist/stream-Tt9cSOCl.d.ts +120 -0
- package/dist/stream-wrappers-CUkNtyZK.d.ts +21 -0
- package/dist/subagent-announce-BEPlkjCS.js +354 -0
- package/dist/subagent-announce-delivery-jcxPIfNG.js +958 -0
- package/dist/subagent-control-DdMWVJXs.js +508 -0
- package/dist/subagent-hooks-BsTVb6ur.js +2 -0
- package/dist/subagent-hooks-CBlMBrss.js +2 -0
- package/dist/subagent-hooks-Ch5oDUxb.js +116 -0
- package/dist/subagent-hooks-DmUeAwY3.js +146 -0
- package/dist/subagent-hooks-PNuPbYEl.js +2 -0
- package/dist/subagent-hooks-api-BQ051dF0.js +23 -0
- package/dist/subagent-hooks-api-DcVS0aJZ.js +22 -0
- package/dist/subagent-hooks-api-Dlbc5Mtd.js +23 -0
- package/dist/subagent-hooks-dwsegI07.js +230 -0
- package/dist/subagent-orphan-recovery-Cl_y6Poi.js +352 -0
- package/dist/subagent-registry-BVVgDSdq.d.ts +1 -0
- package/dist/subagent-registry-BosUdBW6.js +2351 -0
- package/dist/subagent-registry-Bxd6vaAO.js +3 -0
- package/dist/subagent-registry-read-BVVgDSdq.d.ts +1 -0
- package/dist/subagent-registry.runtime.js +1 -1
- package/dist/subagent-session-cleanup-Bd6d93qi.js +525 -0
- package/dist/subagent-spawn-ViO3XAR1.js +1164 -0
- package/dist/target-id-Bje_v2Ax.js +107 -0
- package/dist/targets-9q_q5M9n.d.ts +10 -0
- package/dist/targets-C4byiOgQ.js +19 -0
- package/dist/targets-J0MVE-dD.js +44 -0
- package/dist/targets-ZMEvyNa8.js +19 -0
- package/dist/targets-qBcfKetP.d.ts +10 -0
- package/dist/task-registry-control.runtime.d.ts +1 -1
- package/dist/task-registry-control.runtime.js +1 -1
- package/dist/telegram/token.js +1 -1
- package/dist/testing-Dk757Ggg.js +267 -0
- package/dist/thinking-policy-DO6T8IfK.d.ts +5 -0
- package/dist/thread-bindings-CYrmTzFY.js +232 -0
- package/dist/thread-bindings-Cf7fkXxk.js +571 -0
- package/dist/thread-bindings-DI6LNGbW.js +8 -0
- package/dist/thread-bindings-DdmuKtVD.js +228 -0
- package/dist/thread-bindings.discord-api-C01V3kFk.js +187 -0
- package/dist/thread-bindings.manager--WOGVrL-.js +2 -0
- package/dist/thread-bindings.manager-HzjqZNiL.js +536 -0
- package/dist/thread-lifecycle-CJKTxWnQ.js +1614 -0
- package/dist/token-D-FQ8AQz.js +134 -0
- package/dist/tool-DTCfs0DU.js +139 -0
- package/dist/tool-actions.runtime-Cb3iA3Os.js +534 -0
- package/dist/tool-actions.runtime.js +1 -1
- package/dist/tool-plugin-CbbLM31f.d.ts +77 -0
- package/dist/tool-resolution-CbqzNutV.js +149 -0
- package/dist/tool-split-bLqMPHTZ.d.ts +19 -0
- package/dist/tools-effective-inventory-BsAax-ML.js +204 -0
- package/dist/tools-invoke-http-DAqZxikd.js +67 -0
- package/dist/tools-invoke-shared-CsVRemTL.js +200 -0
- package/dist/transport-stream-DOXZsjVL.d.ts +42 -0
- package/dist/tts-Ckj6MJNr.js +66 -0
- package/dist/tui-CwwCXMCq.js +2 -0
- package/dist/tui-DpJn3v2D.js +4709 -0
- package/dist/tui-backend-DQ9wF5es.js +256 -0
- package/dist/tui-cli-k3AYPBn3.js +37 -0
- package/dist/types--0xYmMG9.d.ts +786 -0
- package/dist/types-CMDl9l_P2.d.ts +3650 -0
- package/dist/types.public-DvhPzYJi.d.ts +70 -0
- package/dist/update-cli-DB5Doqld.js +3664 -0
- package/dist/video-generation-runtime-CTQN-4SI.d.ts +21 -0
- package/dist/video-model-catalog-CTyt4dXa.d.ts +16 -0
- package/dist/vision-tools-Dp0JrLRi.js +1409 -0
- package/dist/web-search-B0yvxuiq.js +62 -0
- package/dist/web-search-provider.runtime-B-cNT-5J.js +2 -0
- package/dist/web-search-provider.runtime-HhmIlk_Z.js +328 -0
- package/dist/web-search-provider.runtime.js +1 -1
- package/dist/webhook-targets-3u4hOqRl.d.ts +99 -0
- package/dist/xai-oauth-cZGjnEjh.js +479 -0
- package/dist/xai-user-agent-DA8le6vP.js +32 -0
- package/dist/zod-schema.core-i5HaY1T4.d.ts +166 -0
- package/package.json +1 -1
- package/dist/abort-CvuLeqr1.js +0 -277
- package/dist/abort.runtime-DNoavlKn.js +0 -2
- package/dist/account-inspect-ByX21U_z.js +0 -173
- package/dist/accounts-B0sjdn0w.js +0 -119
- package/dist/accounts-BF_AfTED.js +0 -107
- package/dist/accounts-DX1c8NKM.js +0 -107
- package/dist/accounts-EA2GGTep.js +0 -2
- package/dist/acp-runtime-BC8oA7xM.js +0 -26
- package/dist/acp-spawn-CPYDCZ95.js +0 -2
- package/dist/acp-spawn-Cqi47GCL.js +0 -1275
- package/dist/acp-stateful-target-driver-CcWMRAQ2.js +0 -89
- package/dist/action-kill-CZrPfOIS.js +0 -33
- package/dist/action-runtime-DuhVKLRJ.js +0 -469
- package/dist/action-runtime-api-BKaUWi7b.js +0 -2
- package/dist/action-send-_NpIHMwj.js +0 -39
- package/dist/action-spawn-Dymn4rUo.js +0 -47
- package/dist/actions-Bk_WaEAa.js +0 -161
- package/dist/actions.runtime-Hh7HYOlJ.js +0 -5
- package/dist/agent-CQzGVmy1.js +0 -2
- package/dist/agent-ClmYyW81.js +0 -3
- package/dist/agent-command-D5KxwCVS.d.ts +0 -141
- package/dist/agent-command-DbU2fo-p.js +0 -1367
- package/dist/agent-components.runtime-BpXJmJXk.js +0 -10
- package/dist/agent-harness-D8c6PLE_.d.ts +0 -146
- package/dist/agent-harness-runtime-AHXS4Jj3.d.ts +0 -691
- package/dist/agent-harness-runtime-TzbK9YTz.js +0 -180
- package/dist/agent-harness-task-runtime-CZWJEsKk.js +0 -140
- package/dist/agent-runner-execution-CmHT78Vr.js +0 -1713
- package/dist/agent-runner-utils-B0i1PW18.js +0 -266
- package/dist/agent-runner.runtime-B6Ah_MlB.js +0 -3455
- package/dist/agent-runtime-BOMioAX6.js +0 -229
- package/dist/agent-via-gateway-DfxQCPit.js +0 -463
- package/dist/agents.commands.add-CszEBxoJ.js +0 -304
- package/dist/agents.commands.delete-ulnJ7RH9.js +0 -128
- package/dist/api-6SmEQDkK.js +0 -134
- package/dist/api-B7QdoMF5.js +0 -2
- package/dist/api-BBgby6ck.js +0 -639
- package/dist/api-DwKV-xfM.d.ts +0 -52
- package/dist/api-RfjCqA7Y.js +0 -6
- package/dist/api-VDkFlOiv.js +0 -2
- package/dist/api-We4xoZFr.js +0 -3
- package/dist/apply-Cgtzilem.js +0 -41
- package/dist/apply-Csp3U8cA.js +0 -54
- package/dist/approval-handler.runtime-aQaSBbpF.js +0 -130
- package/dist/assistant-UMyirSUH.js +0 -291
- package/dist/attachment-normalize-BupK-_Ox.js +0 -225
- package/dist/attempt-execution-oLlyFjHk.js +0 -558
- package/dist/attempt-execution.runtime-Cq8RE0x_.js +0 -3
- package/dist/attempt-execution.shared-DyBzUJGB.js +0 -38
- package/dist/attempt.prompt-helpers-CVBP6t5J.js +0 -475
- package/dist/attempt.tool-run-context-UU1BUUC9.js +0 -2094
- package/dist/auth-BDaK_y-g.js +0 -541
- package/dist/banner-VbID973v.js +0 -2
- package/dist/banner-W77piyz6.js +0 -397
- package/dist/binding-routing-DahKvjr3.js +0 -113
- package/dist/binding-targets-C3mqUdUT.js +0 -121
- package/dist/bot-DonUKEuy.js +0 -7894
- package/dist/bot-deps-CroXwZeM.js +0 -747
- package/dist/bot-deps-DKoy3x0l.js +0 -2
- package/dist/bot-message-context.runtime-BI_zyqDu.js +0 -7
- package/dist/bot-message-context.session.runtime-Cpy2H9Ez.js +0 -12
- package/dist/bot-native-commands.delivery.runtime-CsHg3h1O.js +0 -4
- package/dist/bot-native-commands.runtime-rmoBpwZY.js +0 -13
- package/dist/bridge-server-BmDNWgHD.js +0 -113
- package/dist/browser-cli-BQLwmLw3.js +0 -2
- package/dist/browser-cli-CHHIN-of.js +0 -230
- package/dist/browser-cli-actions-input-DBZ7uwag.js +0 -473
- package/dist/browser-cli-actions-observe-BdH2-WTk.js +0 -81
- package/dist/browser-cli-debug-C82Apbgb.js +0 -137
- package/dist/browser-cli-inspect-CrO1qca7.js +0 -104
- package/dist/browser-cli-manage-Dgm1IUZT.js +0 -443
- package/dist/browser-cli-resize-DqgMr3DY.js +0 -26
- package/dist/browser-cli-shared-BTnXMCKA.js +0 -50
- package/dist/browser-cli-state-DT3bVOtg.js +0 -337
- package/dist/browser-control-auth-BRwKCt45.js +0 -2
- package/dist/browser-profiles-DhGtxK9v.js +0 -2
- package/dist/browser-runtime-BL6b-qtr.js +0 -384
- package/dist/build-33AnG55F.js +0 -257
- package/dist/bundled-channel-config-schema-4eXcH-RE.d.ts +0 -3163
- package/dist/call-dct8amtn.d.ts +0 -43
- package/dist/capability-cli-D-KoVyyP.js +0 -1782
- package/dist/channel-0tgrzPag.js +0 -867
- package/dist/channel-4g20sJKJ.d.ts +0 -104
- package/dist/channel-6tG8jWsw.d.ts +0 -8
- package/dist/channel-7OEbQ8xS.d.ts +0 -6
- package/dist/channel-7rVapSdN.d.ts +0 -8
- package/dist/channel-B1fZN0iI.d.ts +0 -427
- package/dist/channel-B5Q7fRiN.js +0 -1134
- package/dist/channel-BEg_0h_C.d.ts +0 -12
- package/dist/channel-BNp1J_eZ.js +0 -376
- package/dist/channel-BP6RWm-M.d.ts +0 -47
- package/dist/channel-BRjqrJfj.d.ts +0 -49
- package/dist/channel-BUoyH_tP.d.ts +0 -114
- package/dist/channel-BVBG4Tmn.d.ts +0 -28
- package/dist/channel-Bap23sAx.js +0 -481
- package/dist/channel-BhZ7x0SB.d.ts +0 -26
- package/dist/channel-Bxod9CjX.js +0 -508
- package/dist/channel-C6LASGjS.js +0 -808
- package/dist/channel-COWZEKCw.js +0 -1249
- package/dist/channel-CRAIreZ3.js +0 -238
- package/dist/channel-CVY2hnJh.js +0 -1556
- package/dist/channel-CgKdh_Jd.d.ts +0 -106
- package/dist/channel-Cxo62btA.js +0 -1496
- package/dist/channel-D5SzoyWI.js +0 -562
- package/dist/channel-DE4vIsYF.d.ts +0 -64
- package/dist/channel-DOdRHxJg.js +0 -1777
- package/dist/channel-DZygtXdy.js +0 -362
- package/dist/channel-DfhOnM71.d.ts +0 -7
- package/dist/channel-DhZiptRe.d.ts +0 -8
- package/dist/channel-DqPZviVV.js +0 -2126
- package/dist/channel-Dssy3NQA.js +0 -740
- package/dist/channel-actions.runtime-CDaMC9SV.js +0 -265
- package/dist/channel-buMY8xZQ.d.ts +0 -7
- package/dist/channel-core-CBhC_PNR.js +0 -5
- package/dist/channel-core-x9b94azO.d.ts +0 -6
- package/dist/channel-cvGHll3-.js +0 -955
- package/dist/channel-entry-contract-BfZdcgTS.d.ts +0 -112
- package/dist/channel-inbound-CNdyzYlz.js +0 -80
- package/dist/channel-l8amaSI9.js +0 -653
- package/dist/channel-lifecycle-DCl2GbRW.d.ts +0 -125
- package/dist/channel-pairing-BRqfYy30.d.ts +0 -58
- package/dist/channel-plugin-runtime-CvcVGjj4.js +0 -998
- package/dist/channel-plugin-runtime-D5n9A86n.d.ts +0 -7
- package/dist/channel-runtime-BAbg8Dcv.js +0 -408
- package/dist/channel-sWtDTVwd.d.ts +0 -14
- package/dist/channel.runtime-9o-iF8zm.js +0 -2528
- package/dist/channel.runtime-BotO7RD0.js +0 -21009
- package/dist/channel.runtime-BrDb4cP8.js +0 -88
- package/dist/channel.runtime-C1cLfrDt.js +0 -254
- package/dist/channel.runtime-CTM3VO2E.js +0 -4
- package/dist/channel.runtime-CnodqvCJ.js +0 -733
- package/dist/channel.runtime-Dmr8503H.js +0 -1008
- package/dist/channel.runtime-DqzR3Gd9.js +0 -109
- package/dist/channel.runtime-LOf0PHu_.js +0 -652
- package/dist/channel.setup-1leD5F5B.js +0 -343
- package/dist/channel.setup-D9UyWhXM.js +0 -1098
- package/dist/channel.setup-DkVld-9Z.d.ts +0 -7
- package/dist/channel.setup-DxT4prSl.d.ts +0 -8
- package/dist/channel.setup-IHNFkdUD.js +0 -10
- package/dist/channel.setup-YwXqilBB.d.ts +0 -6
- package/dist/chat-DrycI6KH.js +0 -2666
- package/dist/chrome-CgGY9FsG.js +0 -1503
- package/dist/cli-backend-B3aNoTD4.d.ts +0 -5
- package/dist/cli-backend-BVUFOLXj.d.ts +0 -5
- package/dist/cli-compaction-DPmSHZx7.js +0 -347
- package/dist/cli-metadata-eFfCoGmY.js +0 -22
- package/dist/cli-nmYmL8lb.js +0 -1341
- package/dist/cli-runner-BTOYShgV.js +0 -2
- package/dist/cli-runner-DgXAxJVr.js +0 -540
- package/dist/cli-runner.runtime-BeMsKcaS.js +0 -4
- package/dist/cli-runner.runtime-DMD8X8-h.js +0 -3
- package/dist/cli-shared-BAuePn3e.d.ts +0 -20
- package/dist/cli-v6XF4hHd.d.ts +0 -20
- package/dist/client-CKLZqMCW.js +0 -650
- package/dist/client-adapter-B_0W-6Fx.js +0 -897
- package/dist/client-factory-CdMLQFeA.js +0 -9
- package/dist/command-auth-BxYfnQzs.js +0 -135
- package/dist/command-execution-startup-CiV5yFW1.js +0 -87
- package/dist/command-handlers-BAWROGlt.js +0 -1609
- package/dist/command-registry-BqTMebZr.js +0 -4
- package/dist/command-registry-C2Y8GeJl.js +0 -9
- package/dist/command-registry-core-Bi-d0-WH.js +0 -110
- package/dist/command-status.runtime-BSXHZzOq.js +0 -90
- package/dist/commands-Z6AfrJar.d.ts +0 -113
- package/dist/commands-acp-BYWOkjAx.js +0 -74
- package/dist/commands-compact.runtime-Cyb7Pu12.js +0 -10
- package/dist/commands-handlers.runtime-DdJ20XTn.js +0 -6154
- package/dist/commands-status-6uhiUw13.js +0 -3
- package/dist/commands-status-BJ5AnkOG.js +0 -16
- package/dist/commands-status.runtime-6uhiUw13.js +0 -3
- package/dist/commands-subagents-control.runtime-DZrrLjSk.js +0 -2
- package/dist/commands-subagents-control.runtime-_R3XgUpp.js +0 -3
- package/dist/commands-system-prompt-CHGtJPnx.js +0 -162
- package/dist/commands-system-prompt-CM23NlDu.js +0 -2
- package/dist/commands.runtime-DUEbtHG1.js +0 -176
- package/dist/compact-BA6lVtLj.js +0 -480
- package/dist/compact-BfC-utPW.js +0 -1141
- package/dist/compact.runtime-BRL2wCqh.js +0 -12
- package/dist/completion-cli-CYKoLZLl.js +0 -315
- package/dist/computer-use-BWgYktaW.js +0 -367
- package/dist/config-B_HanwOV.js +0 -373
- package/dist/config-DhGtxK9v.js +0 -2
- package/dist/config-cli-CI5UtWr-.js +0 -1633
- package/dist/config-mutations-D2GtlLMA.js +0 -159
- package/dist/config-schema-BKOfHz23.d.ts +0 -20
- package/dist/configure-CuPwIiwW.js +0 -3
- package/dist/configure.commands-BWpwrafi.js +0 -1251
- package/dist/configure.commands-qzipmoDP.js +0 -2
- package/dist/context-engine-host-compat-D246ZMR2.js +0 -2
- package/dist/context-engine-host-compat-KMl-oqCw.js +0 -288
- package/dist/context-engine-lifecycle-DvEDHkQz.js +0 -1274
- package/dist/contracts-testkit-Ym3exIK5.d.ts +0 -145
- package/dist/control-auth-B_RiUaHt.js +0 -114
- package/dist/control-service-DcQFx6_O.js +0 -145
- package/dist/control-ui/assets/agents-Bc8cIfWF.js +0 -1008
- package/dist/control-ui/assets/channel-config-extras-DQru4ECs.js +0 -2
- package/dist/control-ui/assets/channels-BfncerPV.js +0 -367
- package/dist/control-ui/assets/cron-DHLcga_r.js +0 -1013
- package/dist/control-ui/assets/debug-DprDzDn1.js +0 -97
- package/dist/control-ui/assets/index-XTZKpkBL.js +0 -7370
- package/dist/control-ui/assets/instances-D1_lOT13.js +0 -57
- package/dist/control-ui/assets/logs-DINx8syb.js +0 -74
- package/dist/control-ui/assets/nodes-BH4XOUmD.js +0 -436
- package/dist/control-ui/assets/sessions-D5Xt25SY.js +0 -399
- package/dist/control-ui/assets/skills-BmayrBHY.js +0 -314
- package/dist/control-ui/assets/skills-shared-CHaYSJ_s.js +0 -11
- package/dist/conversation-binding-runtime-_jhzwiiC.js +0 -4
- package/dist/conversation-runtime-F5kCN0Sj.js +0 -31
- package/dist/core-BpeKfqbI.d.ts +0 -224
- package/dist/core-DE71gncT.js +0 -282
- package/dist/core-api-B4L5WkKc.js +0 -5
- package/dist/core-api-Q9oM19yY.js +0 -2
- package/dist/crestodian-DLpxYmzP.js +0 -55
- package/dist/daocore-runtime-BnYtDbMC.d.ts +0 -151
- package/dist/daocore-tools-wNTIZIO3.js +0 -11727
- package/dist/dashboard-SHmcCcnT.js +0 -263
- package/dist/delivery-BA4di5Tw.js +0 -1002
- package/dist/dev-Cr2Dhgoc.js +0 -97
- package/dist/dialogue-xI4qAuLY.js +0 -37
- package/dist/dir-fetch-tool-6d4yElM4.js +0 -565
- package/dist/dir-list-tool-D2k-hax6.js +0 -100
- package/dist/direct-dm-eGyFHTug.js +0 -64
- package/dist/directive-handling.fast-lane-Ci1l6GN_.js +0 -68
- package/dist/directive-handling.impl-Co3i_YQ4.js +0 -818
- package/dist/directive-handling.impl-DHKC0TrU.js +0 -2
- package/dist/directive-handling.model-selection-bv5KrHOw.js +0 -122
- package/dist/directive-handling.persist.runtime-CPLg-YHh.js +0 -263
- package/dist/dispatch-CdvERWY-.js +0 -1640
- package/dist/dispatch-acp-transcript.runtime-BhQo1XEg.js +0 -40
- package/dist/dispatch-acp.runtime-Dtiu2EgE.js +0 -18
- package/dist/doctor-BzsPHvLP.js +0 -2
- package/dist/doctor-Cg4FWB15.js +0 -6
- package/dist/doctor-config-flow-SYjHcyu4.js +0 -1741
- package/dist/doctor-core-checks-75amkN-e.js +0 -2
- package/dist/doctor-core-checks-B1fu7KDm.js +0 -573
- package/dist/doctor-health-contributions-BMdJKStr.js +0 -696
- package/dist/doctor-health-vLyDQqfq.js +0 -65
- package/dist/doctor-lint-DfvFyBgL.js +0 -94
- package/dist/doctor-prompter-C-dTuOnw.js +0 -58
- package/dist/doctor-state-integrity-Cv-ECLuv.js +0 -1231
- package/dist/dynamic-tools-BG8ijDFH.js +0 -486
- package/dist/embedded-backend-bRfALCWz.js +0 -579
- package/dist/embedded-gateway-stub.runtime-CAh3IhtZ.js +0 -12
- package/dist/embedding-provider-B7kg9IhC.d.ts +0 -16
- package/dist/embedding-provider-jB1zjkZy.d.ts +0 -65
- package/dist/embedding-provider-sea2CddJ.d.ts +0 -21
- package/dist/exec-approvals-BBa28Sct.js +0 -149
- package/dist/file-fetch-tool-DRIsI7eQ.js +0 -124
- package/dist/file-write-tool-vTMh7eW6.js +0 -127
- package/dist/format-nrhTS41q.js +0 -1145
- package/dist/gateway-cli-CCgw11Ik.js +0 -435
- package/dist/gateway-method-runtime-BNAVGCC_.js +0 -21
- package/dist/gateway-runtime-DGdJumdK.d.ts +0 -163
- package/dist/gemini-cli-provider-Bbpd5lx5.d.ts +0 -6
- package/dist/get-reply-DGFCqKen.js +0 -4689
- package/dist/get-reply-from-config.runtime-l7NTyCh5.js +0 -2
- package/dist/graph-users-CGpakgek.js +0 -1419
- package/dist/group-access-D095jQ78.js +0 -112
- package/dist/group-keys-DnxWQtll.d.ts +0 -17
- package/dist/handle-action.guild-admin-B3pALmMq.js +0 -288
- package/dist/harness-Bs-sPbOD.js +0 -61
- package/dist/health-4gWMIKHu.js +0 -4
- package/dist/heartbeat-runner-Sky_Rjw7.js +0 -5
- package/dist/heartbeat-runner.runtime-CRZ-NbrW.js +0 -4
- package/dist/help-B68Ov4LD.js +0 -136
- package/dist/hook-runtime-Cm73yH0T.d.ts +0 -107
- package/dist/hooks-DWSdYas_.js +0 -534
- package/dist/http-registry-CHKiFHCC.d.ts +0 -23
- package/dist/image-generation-runtime-p-dfXZTf.d.ts +0 -21
- package/dist/inbound-direct-dm-runtime-5z3W9Oqn.js +0 -2
- package/dist/inbound-reply-dispatch-D7NeeFC1.js +0 -148
- package/dist/index-CKAHTIU4.d.ts +0 -3971
- package/dist/init-BXF3o80o.js +0 -59
- package/dist/inline-buttons-DsHwKEVU.js +0 -40
- package/dist/interactive-dispatch-BsKWomnh.d.ts +0 -143
- package/dist/interactive-dispatch-CItEYOu3.d.ts +0 -56
- package/dist/internal-events-TAN9dPEj.js +0 -90
- package/dist/isolated-agent-CTrVGI6q.js +0 -2
- package/dist/isolated-agent-DPyibJ8B.js +0 -1118
- package/dist/lifecycle-BwTg0Djv.js +0 -571
- package/dist/list.probe-BpM4PKu7.js +0 -449
- package/dist/list.status-command-BbcloYBd.js +0 -789
- package/dist/llm-slug-generator-UG7Bhj_y.js +0 -78
- package/dist/loader-D6z2PEKl.d.ts +0 -142
- package/dist/local-dispatch.runtime-CU6Y-BDa.js +0 -9
- package/dist/manager-C3AVKMSl.d.ts +0 -356
- package/dist/manager-CSN9j9hh.d.ts +0 -205
- package/dist/manager.runtime-Da5LiiaQ.js +0 -2714
- package/dist/markdown-to-line-BnESmsY4.js +0 -811
- package/dist/mcp-http-C38KS7On.js +0 -2
- package/dist/mcp-http-CcGhAZcF.js +0 -555
- package/dist/media-understanding-provider-BCz5dVl6.js +0 -339
- package/dist/memory-core-host-engine-storage-sWQlfr8J.d.ts +0 -54
- package/dist/memory-embedding-adapter-BrGY0ecB.d.ts +0 -5
- package/dist/message-actions-CQURSOZH.js +0 -145
- package/dist/message-handler-C2U3bt-X.js +0 -1715
- package/dist/message-handler-CwZfuHhP.js +0 -384
- package/dist/message-handler.preflight-Cosa3kg0.js +0 -1125
- package/dist/message-handler.process-BlKFMYXw.js +0 -1484
- package/dist/migration-hAtbc95i.d.ts +0 -45
- package/dist/model-B8M2deNL.js +0 -74
- package/dist/model-Ck-vNyGd.d.ts +0 -33
- package/dist/model-selection-v2wQWgsT.js +0 -272
- package/dist/models-B7IiQBWY.js +0 -104
- package/dist/models-CnWFsPX6.d.ts +0 -24
- package/dist/models-DMNzBNgt.js +0 -2
- package/dist/models-cli-CQaOg02d.js +0 -256
- package/dist/monitor-Bd9kOezJ.js +0 -1370
- package/dist/monitor-Cy6D6MyS.js +0 -715
- package/dist/monitor-DStY23C4.js +0 -834
- package/dist/monitor-DnF8eltK.js +0 -1657
- package/dist/monitor-DrFJ63I1.js +0 -4377
- package/dist/monitor-J8jOsDaJ.js +0 -60
- package/dist/monitor-auth-DKkbt_CR.js +0 -179
- package/dist/monitor-jp3H9Ri_.js +0 -2
- package/dist/monitor-polling.runtime-DPCAacPc.js +0 -883
- package/dist/monitor-tBNmyf1s.js +0 -2788
- package/dist/monitor-webhook.runtime-BnjEsLRS.js +0 -387
- package/dist/monitor.account-Gh8FuMEq.js +0 -5233
- package/dist/monitor.runtime-Bdh6dxyq.js +0 -2
- package/dist/monitor.webhook-BosT2ylg.js +0 -180
- package/dist/node-cli-sessions-B0_DtIxz.js +0 -1228
- package/dist/onboard-CiTp3HuT.js +0 -733
- package/dist/onboard-helpers-6NgX4RkW.js +0 -251
- package/dist/onboard-helpers-BwxJT_0T.js +0 -6
- package/dist/onboard-remote-CNCFouj7.js +0 -212
- package/dist/onboard-remote-DXzWgH_H.js +0 -2
- package/dist/onboard-skills-Dx58zrXg.js +0 -160
- package/dist/onboard-skills-qaynAMqw.js +0 -2
- package/dist/openai-codex-provider-Bj9cyh4I.d.ts +0 -5
- package/dist/openai-http-Dp0cp01u.js +0 -824
- package/dist/openai-provider-Dm3YkkWf.d.ts +0 -5
- package/dist/openresponses-http-acbxr5UW.js +0 -1173
- package/dist/operations-BZVuEl9E.js +0 -805
- package/dist/outbound-adapter-BKGzT1Rl.js +0 -543
- package/dist/outbound-session-route-mWVuRF9I.js +0 -45
- package/dist/outbound.runtime-BTjY78St.js +0 -2
- package/dist/pairing-challenge-DD0D0sfM.d.ts +0 -87
- package/dist/pi-embedded-CFP2IrYS.js +0 -3796
- package/dist/pi-embedded-D8caT0Nm.js +0 -4
- package/dist/pi-embedded.runtime-eBik36nq.js +0 -4
- package/dist/pi-tools-DOiFN8QJ.js +0 -2413
- package/dist/plan-Cq2-YWkv.js +0 -112
- package/dist/plan-DZacZ3Zv.js +0 -81
- package/dist/plugin-BcNkVMQf.d.ts +0 -17
- package/dist/plugin-app-cache-key-CBK84hKp.js +0 -46
- package/dist/plugin-enabled-CMfz3hfi.js +0 -233
- package/dist/plugin-entry-BS5QKDoz.d.ts +0 -47
- package/dist/plugin-k9ChkvvX.js +0 -12396
- package/dist/plugin-registration-DzPoDboh.js +0 -88
- package/dist/plugin-runtime-BNGhLQ-_.d.ts +0 -117
- package/dist/plugin-service-BynKHNHj.d.ts +0 -24
- package/dist/plugin-service-Ckp9CgP5.js +0 -1229
- package/dist/policy-CBa8yH5k.js +0 -680
- package/dist/policy-Dlam-IbU.js +0 -138
- package/dist/prepare.runtime-B8h04--2.js +0 -732
- package/dist/preview-warnings-DPDK9HPk.js +0 -392
- package/dist/probe-Bts3wK7l.js +0 -682
- package/dist/probe-ByHrOECy.js +0 -47
- package/dist/probe-CXqCx5yV.js +0 -2204
- package/dist/probe-fhhJ0LMx.js +0 -2
- package/dist/program-DfNLP_PI.js +0 -131
- package/dist/prompt-overlay-qKGGXVs-.d.ts +0 -23
- package/dist/provider-CeG5mirD.js +0 -8735
- package/dist/provider-D_TXf9b1.js +0 -152
- package/dist/provider-Fb0fhEC5.js +0 -32
- package/dist/provider-api-key-auth-BIph5btg.d.ts +0 -27
- package/dist/provider-auth-result-BFvMZrH6.d.ts +0 -21
- package/dist/provider-catalog-runtime-Du74RUel.d.ts +0 -23
- package/dist/provider-catalog-shared-B3nN3sf2.d.ts +0 -62
- package/dist/provider-dispatcher-DQ0FP7Oj.js +0 -22
- package/dist/provider-hook-runtime-CRpS8VJ_.d.ts +0 -61
- package/dist/provider-model-shared-GrPEK3SY.d.ts +0 -143
- package/dist/provider-models-iUJVn9QI.d.ts +0 -12
- package/dist/provider-policy-DliVEM__.d.ts +0 -30
- package/dist/provider-registration-BxzmE1yB.d.ts +0 -6
- package/dist/provider-registry-B4AQXjYK.d.ts +0 -8
- package/dist/provider-registry-BHyB46kI.d.ts +0 -30
- package/dist/provider-registry-CnfpUSqh.d.ts +0 -8
- package/dist/provider-runtime-D3j0VBbF.d.ts +0 -359
- package/dist/provider-self-hosted-setup-_11XAmRH.d.ts +0 -74
- package/dist/provider-session.runtime-CIMJ-7ay.js +0 -9
- package/dist/provider-stream-mWxYXsAm.d.ts +0 -140
- package/dist/provider-stream-shared-QayId-fm.d.ts +0 -128
- package/dist/provider-xNaUQ5Lv.js +0 -32
- package/dist/provider.runtime-CGsYbZGk.js +0 -2
- package/dist/providers.runtime-fmZQlSRt.d.ts +0 -25
- package/dist/public-surface-loader-CuVkM64A.js +0 -114
- package/dist/pw-ai-BDGftH9e.js +0 -3029
- package/dist/pw-role-snapshot-C_P091Iv.js +0 -333
- package/dist/reaction-level-DKxiNfWB.js +0 -19
- package/dist/reaction-runtime-api-TY4aPHui.js +0 -116
- package/dist/realtime-transcription-CmRx7wX7.d.ts +0 -43
- package/dist/realtime-transcription-provider-BNca2pAl.js +0 -205
- package/dist/realtime-transcription-provider-Csl2NRiB.d.ts +0 -5
- package/dist/realtime-transcription-provider-CtUTdTS4.d.ts +0 -37
- package/dist/realtime-transcription-provider-DKd69ns6.d.ts +0 -28
- package/dist/realtime-transcription-provider-DPj1VZIg.d.ts +0 -32
- package/dist/realtime-voice-CVgV9cqF.d.ts +0 -333
- package/dist/realtime-voice-provider-CmtxwZon.d.ts +0 -5
- package/dist/register-DLjqO2vR.js +0 -2178
- package/dist/register.agent-FV7a6yzo.js +0 -156
- package/dist/register.configure-DrkSyKW3.js +0 -16
- package/dist/register.crestodian-CQGAa8z2.js +0 -24
- package/dist/register.maintenance-tocHfiS3.js +0 -83
- package/dist/register.onboard-BomHnBGE.js +0 -113
- package/dist/register.runtime-6AmV3Vgs.js +0 -54
- package/dist/register.runtime-CSz0gVBB.d.ts +0 -6
- package/dist/register.setup-ENYtNAA5.js +0 -40
- package/dist/register.subclis-BC6TefAM.js +0 -31
- package/dist/register.subclis-DZdEZgSS.js +0 -3
- package/dist/register.subclis-core-C-EfowrU.js +0 -273
- package/dist/registry-VitXYFE8.d.ts +0 -91
- package/dist/registry-types-C4eAzEgQ.d.ts +0 -392
- package/dist/repair-sequencing-l8dFaytn.js +0 -640
- package/dist/reply-delivery-DdeUWVuk.js +0 -196
- package/dist/reply-runtime-Bd91JEZL.js +0 -11
- package/dist/reply.runtime-l7NTyCh5.js +0 -2
- package/dist/request-BY_4UukN.js +0 -54
- package/dist/resolve-allowlist-C4lmxl4V.js +0 -220
- package/dist/result-fallback-classifier-XORMMp30.js +0 -79
- package/dist/root-help-CTW0Wyrf.js +0 -43
- package/dist/route-dOf1WMkJ.js +0 -469
- package/dist/route-resolution-BddNYZEI.js +0 -274
- package/dist/routes-D0xw72Lf.js +0 -3602
- package/dist/routes-TXSPQFWS.js +0 -2
- package/dist/run-DpvUuaWB.js +0 -1162
- package/dist/run-attempt-Bet0PiSc.js +0 -7704
- package/dist/run-command-C5vMVqMt.js +0 -23
- package/dist/run-command-pNDd7NqP.js +0 -2
- package/dist/run-embedded.runtime-CBZV6YWj.js +0 -4
- package/dist/run-execution-cli.runtime-DTQLV8tA.js +0 -4
- package/dist/run-subagent-registry.runtime-DJCvSdhY.js +0 -2
- package/dist/runtime-CNXeG8vX.js +0 -1287
- package/dist/runtime-DEOSWxv9.js +0 -438
- package/dist/runtime-DbTiSX85.d.ts +0 -17
- package/dist/runtime-api-BCM7T4WV.js +0 -17
- package/dist/runtime-api-BTnMvj8L.js +0 -13
- package/dist/runtime-api-By6LEySM.js +0 -3
- package/dist/runtime-api-Cd0b5LPQ.js +0 -4
- package/dist/runtime-api-CtuDiikz.js +0 -21
- package/dist/runtime-api-DjySILXC.js +0 -13
- package/dist/runtime-api-XJTq_pyQ.js +0 -24
- package/dist/runtime-api-k3v6Q0lb2.d.ts +0 -3151
- package/dist/runtime-api.actions-BmsSg8Ai.js +0 -3
- package/dist/runtime-api.actions-C2-n4QQ5.d.ts +0 -23
- package/dist/runtime-api.monitor-DSk7Pd5H.js +0 -6
- package/dist/runtime-api.send-D3sPncy9.js +0 -4
- package/dist/runtime-api.send-t0FX9tXf.d.ts +0 -38
- package/dist/runtime-api.threads-BK9cB4L1.js +0 -2
- package/dist/runtime-channel--Wjr2ePx.js +0 -150
- package/dist/runtime-channel-WdTa9hHZ.js +0 -2
- package/dist/runtime-embedded-pi.runtime-BNYBvaxo.js +0 -2
- package/dist/runtime-r3jS5wSq.js +0 -6179
- package/dist/runtime-taskflow-DMBY6o56.d.ts +0 -435
- package/dist/sanitize-outbound-D6IBCCpn.js +0 -127
- package/dist/sdk-setup-tools-DcDrd8tW.js +0 -8
- package/dist/secrets-OV1uTwRt.js +0 -113
- package/dist/secrets-cli-llC7t41S.js +0 -149
- package/dist/security-audit-BM_fypcl.js +0 -118
- package/dist/security-audit-CQ2yKgF8.js +0 -122
- package/dist/security-audit.runtime-CRgJUegH.js +0 -2
- package/dist/selection-DkJ7MaPC.js +0 -16157
- package/dist/selection-LeUiOSn0.js +0 -3
- package/dist/send-B5TXXeBz.d.ts +0 -231
- package/dist/send-C0ZHzB6o.js +0 -1631
- package/dist/send-CXL3cM-w.js +0 -192
- package/dist/send-CuDA29HM.js +0 -2
- package/dist/send-D7qhwK7Z.js +0 -143
- package/dist/send-DEMaBWpw.d.ts +0 -105
- package/dist/send.components-BNeg1zrc.js +0 -2
- package/dist/send.components-DwRyC_Hc.js +0 -500
- package/dist/send.runtime-DBIUdxpO.js +0 -2
- package/dist/send.types-DywwIqYK.d.ts +0 -160
- package/dist/server-DGcm6Swr.js +0 -24
- package/dist/server-DPvleC-x.js +0 -73
- package/dist/server-context-BWBM4f-_.js +0 -955
- package/dist/server-context-CFgwcLlu.js +0 -2
- package/dist/server-cron-C1kChsjw.js +0 -2989
- package/dist/server-cron-CS1EP5Li.js +0 -2
- package/dist/server-methods-BcIlC8iD.js +0 -16494
- package/dist/server-node-events-BAZCvZOy.js +0 -596
- package/dist/server-plugin-bootstrap-cQUi21Uu.js +0 -70
- package/dist/server-plugins-BRFre223.js +0 -432
- package/dist/server-reload-handlers-DfcsAX-5.js +0 -714
- package/dist/server-restart-sentinel-CFX5zQkM.js +0 -747
- package/dist/server-restart-sentinel-DUvs77Q0.js +0 -2
- package/dist/server-runtime-services-0vm5XmvV.js +0 -2
- package/dist/server-runtime-services-CLz_vkLy.js +0 -267
- package/dist/server-startup-plugins-CPXqqIRV.js +0 -113
- package/dist/server-startup-post-attach-BkNe1Z6g.js +0 -716
- package/dist/server-ws-runtime-rcJeRHFO.js +0 -349
- package/dist/server.impl-a6knQ-N8.js +0 -2586
- package/dist/service-H-BcELwS.js +0 -1446
- package/dist/session-binding-BQliaqL7.js +0 -2
- package/dist/session-binding-DPvZil_F.js +0 -219
- package/dist/session-kill-http-DJMipluP.js +0 -121
- package/dist/session-reset-service-Dn9FU5wA.js +0 -625
- package/dist/session-route-JLWNmJxD.js +0 -93
- package/dist/session-status.runtime-D0OptHcW.js +0 -2
- package/dist/session-subagent-reactivation.runtime-BUmf1vNS.js +0 -2
- package/dist/session-tab-registry-CoBvJVRj.js +0 -521
- package/dist/sessions-history-http-B8CkLDAn.js +0 -430
- package/dist/sessions.runtime-DbNqS_Gy.js +0 -2
- package/dist/setup-CTZUUn1s.js +0 -586
- package/dist/setup-D6fXOEjD.js +0 -2
- package/dist/setup-api-DLPEXHCv.js +0 -29
- package/dist/setup-core-DLXb29jm.js +0 -174
- package/dist/setup-onboard-configure-help-fast-path-CrcZmKPI.js +0 -64
- package/dist/setup-surface--Cct-rCt.js +0 -288
- package/dist/setup-surface-CW8YN207.js +0 -320
- package/dist/setup-surface-DIxcfqD0.js +0 -221
- package/dist/setup-surface-IJ6kmKgi.js +0 -405
- package/dist/setup.finalize-gWpWnCCk.js +0 -582
- package/dist/setup.gateway-config-D_DaSfpW.js +0 -281
- package/dist/setup.migration-import-CYZjCkle.js +0 -2
- package/dist/setup.migration-import-CZJU4scH.js +0 -200
- package/dist/shared-Bp_Fgv6B.js +0 -121
- package/dist/shared-CLqPY0yv.d.ts +0 -115
- package/dist/shared-client-OQdg8NGC.js +0 -629
- package/dist/shared-client-dk1ICVBm.js +0 -2
- package/dist/side-question-CbhRW3UI.js +0 -683
- package/dist/simple-completion-runtime-XIF65b47.d.ts +0 -73
- package/dist/skill-tool-dispatch.runtime-EcycYnWE.js +0 -143
- package/dist/slash-state-BoX6WwB5.js +0 -2166
- package/dist/speech-CvkJG5Mt.d.ts +0 -47
- package/dist/speech-core-MG83lB3i.d.ts +0 -36
- package/dist/speech-provider-1EN9hT-3.d.ts +0 -8
- package/dist/speech-provider-67ebyEcs.js +0 -184
- package/dist/speech-provider-B6tb45De.d.ts +0 -5
- package/dist/speech-provider-C74wAyBX.d.ts +0 -5
- package/dist/speech-provider-CYJoZZpj.d.ts +0 -8
- package/dist/speech-provider-DavEMdKC.d.ts +0 -34
- package/dist/speech-provider-DvFtveg6.d.ts +0 -5
- package/dist/src-CbfOifft.js +0 -4256
- package/dist/startup-context-YF24NARp.js +0 -313
- package/dist/status-message-CcrZdfCO.js +0 -484
- package/dist/status-message.runtime-Cptt1EPV.js +0 -6
- package/dist/status-subagents.runtime-v2eijc4R.js +0 -18
- package/dist/status-text-BWwar3Yc.js +0 -296
- package/dist/status-tn3uQDY7.js +0 -73
- package/dist/status.runtime-BFjTHLiQ.js +0 -2
- package/dist/sticker-cache-Cs7LV_3a.js +0 -206
- package/dist/sticker-vision.runtime-CyPMpoCs.js +0 -17
- package/dist/stream-1rWKMSqV.d.ts +0 -16
- package/dist/stream-Bk9TnoRV.d.ts +0 -10
- package/dist/stream-DZeY9rhs.d.ts +0 -120
- package/dist/stream-DgCoKjcL.d.ts +0 -19
- package/dist/stream-exnufPSG.d.ts +0 -5
- package/dist/stream-wrappers-D2EuY1tP.d.ts +0 -21
- package/dist/subagent-announce-CRjGGxSB.js +0 -354
- package/dist/subagent-announce-delivery-CbfRRdwt.js +0 -958
- package/dist/subagent-control-VTsWynTB.js +0 -508
- package/dist/subagent-hooks-BB__aHul.js +0 -2
- package/dist/subagent-hooks-Cb5fJ2H0.js +0 -146
- package/dist/subagent-hooks-CwVBMhp_.js +0 -2
- package/dist/subagent-hooks-Cx9_GAMF.js +0 -116
- package/dist/subagent-hooks-DOJhvTDx.js +0 -230
- package/dist/subagent-hooks-DUMqhB3r.js +0 -2
- package/dist/subagent-hooks-api-BDGmCxB2.js +0 -22
- package/dist/subagent-hooks-api-CcTdPqP1.js +0 -23
- package/dist/subagent-hooks-api-D18tQta6.js +0 -23
- package/dist/subagent-orphan-recovery-6bNIX25Q.js +0 -352
- package/dist/subagent-registry-DokIxoQ6.js +0 -2351
- package/dist/subagent-registry-tlyJE0hN.js +0 -3
- package/dist/subagent-session-cleanup-BWHQ6rcm.js +0 -525
- package/dist/subagent-spawn-BUdUAwoc.js +0 -1164
- package/dist/target-id-CI1U3MSO.js +0 -107
- package/dist/targets-CbBORUXB.d.ts +0 -10
- package/dist/targets-CgmlXrhv.js +0 -44
- package/dist/targets-D-jSrLUN.js +0 -19
- package/dist/targets-DPDu8x6v.js +0 -19
- package/dist/targets-D_fXvxrg.d.ts +0 -10
- package/dist/testing-D-48HuIK.js +0 -267
- package/dist/thinking-policy-CY16OlCs.d.ts +0 -5
- package/dist/thread-bindings-B9J0nGG7.js +0 -232
- package/dist/thread-bindings-BByWvFZq.js +0 -8
- package/dist/thread-bindings-Cxjm2mLg.js +0 -571
- package/dist/thread-bindings-DQWmglaO.js +0 -228
- package/dist/thread-bindings.discord-api-DWWDvMgL.js +0 -187
- package/dist/thread-bindings.manager-CQW6bNs5.js +0 -2
- package/dist/thread-bindings.manager-DpBYBs9s.js +0 -536
- package/dist/thread-lifecycle-PpB8gTx1.js +0 -1614
- package/dist/token-CBy6YYM_.js +0 -134
- package/dist/tool-BCHcwX9p.js +0 -139
- package/dist/tool-actions.runtime-Cwxr2NmB.js +0 -534
- package/dist/tool-plugin-DHZYdwyJ.d.ts +0 -77
- package/dist/tool-resolution-DQpf531V.js +0 -149
- package/dist/tool-split-ClZW5eN5.d.ts +0 -19
- package/dist/tools-effective-inventory-BHxeIAri.js +0 -204
- package/dist/tools-invoke-http-Bv2LES5Q.js +0 -67
- package/dist/tools-invoke-shared-Cf_ifab9.js +0 -200
- package/dist/transport-stream-D_pZ9Qwv.d.ts +0 -42
- package/dist/tts-CjTcF0YS.js +0 -66
- package/dist/tui-D3_WpyGV.js +0 -2
- package/dist/tui-Y8IezK6P.js +0 -4709
- package/dist/tui-backend-BIJbrfDK.js +0 -256
- package/dist/tui-cli-YVLQJGLU.js +0 -37
- package/dist/types-CnKegQ41.d.ts +0 -786
- package/dist/types-Dyry5PA_2.d.ts +0 -3650
- package/dist/types.public-AUFnQi6j.d.ts +0 -70
- package/dist/update-cli-B7MOXy4Y.js +0 -3664
- package/dist/video-generation-runtime-Cc8klYNS.d.ts +0 -21
- package/dist/video-model-catalog-XG42YlJS.d.ts +0 -16
- package/dist/vision-tools-kEwnV2UO.js +0 -1409
- package/dist/web-search-DH1W_lfx.js +0 -62
- package/dist/web-search-provider.runtime-BX9TezsY.js +0 -328
- package/dist/web-search-provider.runtime-BhRjYeyp.js +0 -2
- package/dist/webhook-targets--wGRjxMd.d.ts +0 -99
- package/dist/xai-oauth-BZQ--94U.js +0 -479
- package/dist/xai-user-agent-SpZaKTGR.js +0 -32
- package/dist/zod-schema.core-BhLPa6BF.d.ts +0 -166
- /package/dist/{accounts-CqgATPC-2.d.ts → accounts-CqgATPC-.d.ts} +0 -0
- /package/dist/{acp-runtime-backend-DU5R8SXu.js → acp-runtime-backend-DHyoMnZY.js} +0 -0
- /package/dist/{channel-actions-Ce2Sna1a.js → channel-actions-B5OPAiNK.js} +0 -0
- /package/dist/{command-status-runtime-Cj5vB8lc.js → command-status-runtime-BqQvv1BR.js} +0 -0
- /package/dist/{delegate-BeKeQwNR.js → delegate-B1QIF1j8.js} +0 -0
- /package/dist/{dispatch-acp-DXlzEM_A.js → dispatch-acp-Ch9ZmM4b.js} +0 -0
- /package/dist/{heartbeat-runner-Dncw_0KS.js → heartbeat-runner-BkgH94IS.js} +0 -0
- /package/dist/{library-6cU4n1-c.js → library-DP1oARlw.js} +0 -0
- /package/dist/{run-executor.runtime-DjwaphFT.js → run-executor.runtime-Czk4Lxkj.js} +0 -0
- /package/dist/{video-generation-core-BVVgDSdq.d.ts → server-plugins-BVVgDSdq.d.ts} +0 -0
- /package/dist/{shared-BE5PSFeb.js → shared-SiM6kZAE.js} +0 -0
- /package/dist/{model-ref-mtPT-mlX.d.ts → video-generation-core-mtPT-mlX.d.ts} +0 -0
|
@@ -0,0 +1,4709 @@
|
|
|
1
|
+
import { a as normalizeLowercaseStringOrEmpty, c as normalizeOptionalString, s as normalizeOptionalLowercaseString } from "./string-coerce-DyL154ka.js";
|
|
2
|
+
import { i as visibleWidth, r as stripAnsi$1 } from "./ansi-4r6vVvJt.js";
|
|
3
|
+
import { v as resolveStateDir } from "./paths-ZwPDM6zn.js";
|
|
4
|
+
import { i as formatErrorMessage } from "./errors-DCgU20d6.js";
|
|
5
|
+
import { u as registerUncaughtExceptionHandler } from "./unhandled-rejections-DaM3WNc4.js";
|
|
6
|
+
import { n as VERSION } from "./version-j6aVEPCK.js";
|
|
7
|
+
import { c as resolveAgentIdByWorkspacePath } from "./agent-scope-BvhOCChS.js";
|
|
8
|
+
import { c as parseAgentSessionKey } from "./session-key-utils-Ce_xWkNq.js";
|
|
9
|
+
import { l as normalizeAgentId, r as buildAgentMainSessionKey, u as normalizeMainKey } from "./session-key-Bte0mmcq.js";
|
|
10
|
+
import { c as resolveDefaultAgentId } from "./agent-scope-config-JLvcfwLC.js";
|
|
11
|
+
import { t as privateFileStore } from "./private-file-store-C_5ZwE9L.js";
|
|
12
|
+
import { n as assertExplicitGatewayAuthModeWhenBothConfigured } from "./auth-mode-policy-S5pkoxko.js";
|
|
13
|
+
import { t as loggingState } from "./state-CHRYWIGY.js";
|
|
14
|
+
import { s as setConsoleSubsystemFilter } from "./console-WMlb-CoN.js";
|
|
15
|
+
import { i as isLoopbackHost } from "./net-DCUMtgJy.js";
|
|
16
|
+
import { i as getRuntimeConfig } from "./io-CcynUC5m.js";
|
|
17
|
+
import { n as modelKey } from "./model-ref-shared-aYu6YNuy.js";
|
|
18
|
+
import { _ as resolveResponseUsageMode, h as normalizeUsageDisplay, r as listThinkingLevelLabels, t as formatThinkingLevels } from "./thinking-CC4kQtft.js";
|
|
19
|
+
import "./config-D3mxUrDI.js";
|
|
20
|
+
import { i as GATEWAY_CLIENT_NAMES, r as GATEWAY_CLIENT_MODES, t as GATEWAY_CLIENT_CAPS } from "./client-info-B56HGdh-.js";
|
|
21
|
+
import { t as startGatewayClientWhenEventLoopReady } from "./client-start-readiness-CWhUx1E4.js";
|
|
22
|
+
import { n as GatewayClient, r as GatewayClientRequestError } from "./client-f5o8kwz6.js";
|
|
23
|
+
import "./protocol-BqIJbb8x.js";
|
|
24
|
+
import "./version-DDqbebEG.js";
|
|
25
|
+
import { d as resolveExplicitGatewayAuth, n as buildGatewayConnectionDetails, s as ensureExplicitGatewayAuth } from "./call-CWafXuDK.js";
|
|
26
|
+
import { n as extractAssistantVisibleText } from "./chat-message-content-DN9xEd6w.js";
|
|
27
|
+
import { r as stripLeadingInboundMetadata } from "./strip-inbound-meta-BavI3j3K.js";
|
|
28
|
+
import { r as formatRawAssistantErrorForUi } from "./assistant-error-format-B2ijqfp6.js";
|
|
29
|
+
import { t as isAuthErrorMessage } from "./failover-matches-C-tab7FS.js";
|
|
30
|
+
import { n as formatTokenCount } from "./usage-format-DiJOjMsY.js";
|
|
31
|
+
import "./pi-embedded-helpers-CsYU9hpC.js";
|
|
32
|
+
import { r as resolveToolDisplay, t as formatToolDetail } from "./tool-display-BmtV5FVZ.js";
|
|
33
|
+
import { r as resolveSessionInfoModelSelection } from "./model-selection-display-BOUwZcnd.js";
|
|
34
|
+
import { n as listChatCommands, r as listChatCommandsForConfig } from "./commands-registry-list-DNCKB5Km.js";
|
|
35
|
+
import "./commands-registry-DN9DcGL_.js";
|
|
36
|
+
import { n as formatTimeAgo, t as formatRelativeTimestamp } from "./format-relative-Bjc3l98W.js";
|
|
37
|
+
import { t as normalizeGroupActivation } from "./group-activation-BxkIP-sT.js";
|
|
38
|
+
import { t as resolveGatewayInteractiveSurfaceAuth } from "./auth-surface-resolution-CJKj0ejJ.js";
|
|
39
|
+
import { n as TUI_SETUP_AUTH_SOURCE_ENV, t as TUI_SETUP_AUTH_SOURCE_CONFIG } from "./setup-launch-env-CVLaOzVA.js";
|
|
40
|
+
import { t as resolveLocalRunShutdownGraceMs } from "./local-run-shutdown-BUy2Prpp.js";
|
|
41
|
+
import { fileURLToPath } from "node:url";
|
|
42
|
+
import { existsSync } from "node:fs";
|
|
43
|
+
import path from "node:path";
|
|
44
|
+
import { execFileSync, spawn } from "node:child_process";
|
|
45
|
+
import chalk from "chalk";
|
|
46
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
47
|
+
import { Box, CombinedAutocompleteProvider, Container, Editor, Input, Key, Loader, Markdown, ProcessTerminal, SelectList, SettingsList, Spacer, TUI, Text, isKeyRelease, matchesKey, truncateToWidth } from "@earendil-works/pi-tui";
|
|
48
|
+
//#region src/tui/commands.ts
|
|
49
|
+
const VERBOSE_LEVELS = ["on", "off"];
|
|
50
|
+
const TRACE_LEVELS = ["on", "off"];
|
|
51
|
+
const FAST_LEVELS = [
|
|
52
|
+
"status",
|
|
53
|
+
"on",
|
|
54
|
+
"off"
|
|
55
|
+
];
|
|
56
|
+
const REASONING_LEVELS = ["on", "off"];
|
|
57
|
+
const ELEVATED_LEVELS = [
|
|
58
|
+
"on",
|
|
59
|
+
"off",
|
|
60
|
+
"ask",
|
|
61
|
+
"full"
|
|
62
|
+
];
|
|
63
|
+
const ACTIVATION_LEVELS = ["mention", "always"];
|
|
64
|
+
const USAGE_FOOTER_LEVELS = [
|
|
65
|
+
"off",
|
|
66
|
+
"tokens",
|
|
67
|
+
"full"
|
|
68
|
+
];
|
|
69
|
+
const COMMAND_ALIASES = {
|
|
70
|
+
elev: "elevated",
|
|
71
|
+
gwstatus: "gateway-status"
|
|
72
|
+
};
|
|
73
|
+
function createLevelCompletion(levels) {
|
|
74
|
+
return (prefix) => levels.filter((value) => value.startsWith(normalizeLowercaseStringOrEmpty(prefix))).map((value) => ({
|
|
75
|
+
value,
|
|
76
|
+
label: value
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
function normalizeSlashCommandName(value) {
|
|
80
|
+
return value.replace(/^\//, "").trim();
|
|
81
|
+
}
|
|
82
|
+
function appendSlashCommand(commands, seen, name, description) {
|
|
83
|
+
const normalizedName = normalizeSlashCommandName(name);
|
|
84
|
+
if (!normalizedName || seen.has(normalizedName)) return;
|
|
85
|
+
seen.add(normalizedName);
|
|
86
|
+
commands.push({
|
|
87
|
+
name: normalizedName,
|
|
88
|
+
description
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function parseCommand(input) {
|
|
92
|
+
const trimmed = input.replace(/^\//, "").trim();
|
|
93
|
+
if (!trimmed) return {
|
|
94
|
+
name: "",
|
|
95
|
+
args: ""
|
|
96
|
+
};
|
|
97
|
+
const [name, ...rest] = trimmed.split(/\s+/);
|
|
98
|
+
const normalized = normalizeLowercaseStringOrEmpty(name);
|
|
99
|
+
return {
|
|
100
|
+
name: COMMAND_ALIASES[normalized] ?? normalized,
|
|
101
|
+
args: rest.join(" ").trim()
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function getSlashCommands(options = {}) {
|
|
105
|
+
const thinkLevels = options.thinkingLevels?.length ? options.thinkingLevels.map((level) => level.label) : listThinkingLevelLabels(options.provider, options.model);
|
|
106
|
+
const verboseCompletions = createLevelCompletion(VERBOSE_LEVELS);
|
|
107
|
+
const traceCompletions = createLevelCompletion(TRACE_LEVELS);
|
|
108
|
+
const fastCompletions = createLevelCompletion(FAST_LEVELS);
|
|
109
|
+
const reasoningCompletions = createLevelCompletion(REASONING_LEVELS);
|
|
110
|
+
const usageCompletions = createLevelCompletion(USAGE_FOOTER_LEVELS);
|
|
111
|
+
const elevatedCompletions = createLevelCompletion(ELEVATED_LEVELS);
|
|
112
|
+
const activationCompletions = createLevelCompletion(ACTIVATION_LEVELS);
|
|
113
|
+
const commands = [
|
|
114
|
+
{
|
|
115
|
+
name: "help",
|
|
116
|
+
description: "Show slash command help"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "gateway-status",
|
|
120
|
+
description: "Show gateway status summary"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: "gwstatus",
|
|
124
|
+
description: "Alias for /gateway-status"
|
|
125
|
+
},
|
|
126
|
+
...options.local ? [{
|
|
127
|
+
name: "auth",
|
|
128
|
+
description: "Run provider auth/login flow"
|
|
129
|
+
}] : [],
|
|
130
|
+
{
|
|
131
|
+
name: "agent",
|
|
132
|
+
description: "Switch agent (or open picker)"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "agents",
|
|
136
|
+
description: "Open agent picker"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "crestodian",
|
|
140
|
+
description: "Return to Crestodian"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: "session",
|
|
144
|
+
description: "Switch session (or open picker)"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "sessions",
|
|
148
|
+
description: "Open session picker"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: "model",
|
|
152
|
+
description: "Set model (or open picker)"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "models",
|
|
156
|
+
description: "Open model picker"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: "think",
|
|
160
|
+
description: "Set thinking level",
|
|
161
|
+
getArgumentCompletions: (prefix) => thinkLevels.filter((v) => v.startsWith(normalizeLowercaseStringOrEmpty(prefix))).map((value) => ({
|
|
162
|
+
value,
|
|
163
|
+
label: value
|
|
164
|
+
}))
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: "fast",
|
|
168
|
+
description: "Set fast mode on/off",
|
|
169
|
+
getArgumentCompletions: fastCompletions
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: "verbose",
|
|
173
|
+
description: "Set verbose on/off",
|
|
174
|
+
getArgumentCompletions: verboseCompletions
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: "trace",
|
|
178
|
+
description: "Set trace on/off",
|
|
179
|
+
getArgumentCompletions: traceCompletions
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
name: "reasoning",
|
|
183
|
+
description: "Set reasoning on/off",
|
|
184
|
+
getArgumentCompletions: reasoningCompletions
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: "usage",
|
|
188
|
+
description: "Toggle per-response usage line",
|
|
189
|
+
getArgumentCompletions: usageCompletions
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: "elevated",
|
|
193
|
+
description: "Set elevated on/off/ask/full",
|
|
194
|
+
getArgumentCompletions: elevatedCompletions
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
name: "elev",
|
|
198
|
+
description: "Alias for /elevated",
|
|
199
|
+
getArgumentCompletions: elevatedCompletions
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
name: "activation",
|
|
203
|
+
description: "Set group activation",
|
|
204
|
+
getArgumentCompletions: activationCompletions
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: "abort",
|
|
208
|
+
description: "Abort active run"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
name: "new",
|
|
212
|
+
description: "Reset the session"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: "reset",
|
|
216
|
+
description: "Reset the session"
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
name: "settings",
|
|
220
|
+
description: "Open settings"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
name: "exit",
|
|
224
|
+
description: "Exit the TUI"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
name: "quit",
|
|
228
|
+
description: "Exit the TUI"
|
|
229
|
+
}
|
|
230
|
+
];
|
|
231
|
+
const seen = new Set(commands.map((command) => command.name));
|
|
232
|
+
const gatewayCommands = options.cfg ? listChatCommandsForConfig(options.cfg) : listChatCommands();
|
|
233
|
+
for (const command of gatewayCommands) {
|
|
234
|
+
const aliases = command.textAliases.length > 0 ? command.textAliases : [`/${command.key}`];
|
|
235
|
+
for (const alias of aliases) appendSlashCommand(commands, seen, alias, command.description);
|
|
236
|
+
}
|
|
237
|
+
for (const command of options.dynamicCommands ?? []) {
|
|
238
|
+
const aliases = command.textAliases?.length ? command.textAliases : [command.name];
|
|
239
|
+
for (const alias of aliases) appendSlashCommand(commands, seen, alias, command.description);
|
|
240
|
+
}
|
|
241
|
+
return commands;
|
|
242
|
+
}
|
|
243
|
+
function helpText(options = {}) {
|
|
244
|
+
const thinkLevels = formatThinkingLevels(options.provider, options.model, "|");
|
|
245
|
+
return [
|
|
246
|
+
"Slash commands:",
|
|
247
|
+
"/help",
|
|
248
|
+
"/commands",
|
|
249
|
+
"/status",
|
|
250
|
+
"/gateway-status",
|
|
251
|
+
"/gwstatus",
|
|
252
|
+
...options.local ? ["/auth [provider]"] : [],
|
|
253
|
+
"/agent <id> (or /agents)",
|
|
254
|
+
"/crestodian [request]",
|
|
255
|
+
"/session <key> (or /sessions)",
|
|
256
|
+
"/model <provider/model> (or /models)",
|
|
257
|
+
`/think <${thinkLevels}>`,
|
|
258
|
+
"/fast <status|on|off>",
|
|
259
|
+
"/verbose <on|off>",
|
|
260
|
+
"/trace <on|off>",
|
|
261
|
+
"/reasoning <on|off>",
|
|
262
|
+
"/usage <off|tokens|full>",
|
|
263
|
+
"/elevated <on|off|ask|full>",
|
|
264
|
+
"/elev <on|off|ask|full>",
|
|
265
|
+
"/activation <mention|always>",
|
|
266
|
+
"/new or /reset",
|
|
267
|
+
"/abort",
|
|
268
|
+
"/settings",
|
|
269
|
+
"/exit"
|
|
270
|
+
].join("\n");
|
|
271
|
+
}
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region src/tui/theme/theme.ts
|
|
274
|
+
const DARK_TEXT = "#E8E3D5";
|
|
275
|
+
const LIGHT_TEXT = "#1E1E1E";
|
|
276
|
+
const XTERM_LEVELS = [
|
|
277
|
+
0,
|
|
278
|
+
95,
|
|
279
|
+
135,
|
|
280
|
+
175,
|
|
281
|
+
215,
|
|
282
|
+
255
|
|
283
|
+
];
|
|
284
|
+
function channelToSrgb(value) {
|
|
285
|
+
const normalized = value / 255;
|
|
286
|
+
return normalized <= .03928 ? normalized / 12.92 : ((normalized + .055) / 1.055) ** 2.4;
|
|
287
|
+
}
|
|
288
|
+
function relativeLuminanceRgb(r, g, b) {
|
|
289
|
+
const red = channelToSrgb(r);
|
|
290
|
+
const green = channelToSrgb(g);
|
|
291
|
+
const blue = channelToSrgb(b);
|
|
292
|
+
return .2126 * red + .7152 * green + .0722 * blue;
|
|
293
|
+
}
|
|
294
|
+
function relativeLuminanceHex(hex) {
|
|
295
|
+
return relativeLuminanceRgb(Number.parseInt(hex.slice(1, 3), 16), Number.parseInt(hex.slice(3, 5), 16), Number.parseInt(hex.slice(5, 7), 16));
|
|
296
|
+
}
|
|
297
|
+
function contrastRatio(background, foregroundHex) {
|
|
298
|
+
const foreground = relativeLuminanceHex(foregroundHex);
|
|
299
|
+
const lighter = Math.max(background, foreground);
|
|
300
|
+
const darker = Math.min(background, foreground);
|
|
301
|
+
return (lighter + .05) / (darker + .05);
|
|
302
|
+
}
|
|
303
|
+
function pickHigherContrastText(r, g, b) {
|
|
304
|
+
const background = relativeLuminanceRgb(r, g, b);
|
|
305
|
+
return contrastRatio(background, LIGHT_TEXT) >= contrastRatio(background, DARK_TEXT);
|
|
306
|
+
}
|
|
307
|
+
function isLightBackground() {
|
|
308
|
+
const explicit = normalizeOptionalLowercaseString(process.env.DAOCORE_THEME);
|
|
309
|
+
if (explicit === "light") return true;
|
|
310
|
+
if (explicit === "dark") return false;
|
|
311
|
+
const colorfgbg = process.env.COLORFGBG;
|
|
312
|
+
if (colorfgbg && colorfgbg.length <= 64) {
|
|
313
|
+
const sep = colorfgbg.lastIndexOf(";");
|
|
314
|
+
const bg = Number.parseInt(sep >= 0 ? colorfgbg.slice(sep + 1) : colorfgbg, 10);
|
|
315
|
+
if (bg >= 0 && bg <= 255) {
|
|
316
|
+
if (bg <= 15) return bg === 7 || bg === 15;
|
|
317
|
+
if (bg >= 232) return bg >= 244;
|
|
318
|
+
const cubeIndex = bg - 16;
|
|
319
|
+
const bVal = XTERM_LEVELS[cubeIndex % 6];
|
|
320
|
+
const gVal = XTERM_LEVELS[Math.floor(cubeIndex / 6) % 6];
|
|
321
|
+
const rVal = XTERM_LEVELS[Math.floor(cubeIndex / 36)];
|
|
322
|
+
return pickHigherContrastText(rVal, gVal, bVal);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
const palette = isLightBackground() ? {
|
|
328
|
+
text: "#1E1E1E",
|
|
329
|
+
dim: "#5B6472",
|
|
330
|
+
accent: "#B45309",
|
|
331
|
+
accentSoft: "#C2410C",
|
|
332
|
+
border: "#5B6472",
|
|
333
|
+
userBg: "#F3F0E8",
|
|
334
|
+
userText: "#1E1E1E",
|
|
335
|
+
systemText: "#4B5563",
|
|
336
|
+
toolPendingBg: "#EFF6FF",
|
|
337
|
+
toolSuccessBg: "#ECFDF5",
|
|
338
|
+
toolErrorBg: "#FEF2F2",
|
|
339
|
+
toolTitle: "#B45309",
|
|
340
|
+
toolOutput: "#374151",
|
|
341
|
+
quote: "#1D4ED8",
|
|
342
|
+
quoteBorder: "#2563EB",
|
|
343
|
+
code: "#92400E",
|
|
344
|
+
codeBlock: "#F9FAFB",
|
|
345
|
+
codeBorder: "#92400E",
|
|
346
|
+
link: "#047857",
|
|
347
|
+
error: "#DC2626",
|
|
348
|
+
success: "#047857"
|
|
349
|
+
} : {
|
|
350
|
+
text: "#E8E3D5",
|
|
351
|
+
dim: "#7B7F87",
|
|
352
|
+
accent: "#F6C453",
|
|
353
|
+
accentSoft: "#F2A65A",
|
|
354
|
+
border: "#3C414B",
|
|
355
|
+
userBg: "#2B2F36",
|
|
356
|
+
userText: "#F3EEE0",
|
|
357
|
+
systemText: "#9BA3B2",
|
|
358
|
+
toolPendingBg: "#1F2A2F",
|
|
359
|
+
toolSuccessBg: "#1E2D23",
|
|
360
|
+
toolErrorBg: "#2F1F1F",
|
|
361
|
+
toolTitle: "#F6C453",
|
|
362
|
+
toolOutput: "#E1DACB",
|
|
363
|
+
quote: "#8CC8FF",
|
|
364
|
+
quoteBorder: "#3B4D6B",
|
|
365
|
+
code: "#F0C987",
|
|
366
|
+
codeBlock: "#1E232A",
|
|
367
|
+
codeBorder: "#343A45",
|
|
368
|
+
link: "#7DD3A5",
|
|
369
|
+
error: "#F97066",
|
|
370
|
+
success: "#7DD3A5"
|
|
371
|
+
};
|
|
372
|
+
const fg = (hex) => (text) => chalk.hex(hex)(text);
|
|
373
|
+
const bg = (hex) => (text) => chalk.bgHex(hex)(text);
|
|
374
|
+
/**
|
|
375
|
+
* Render code blocks with the theme code color without pulling a parser into the base TUI path.
|
|
376
|
+
* Returns an array of lines with ANSI escape codes.
|
|
377
|
+
*/
|
|
378
|
+
function highlightCode(code) {
|
|
379
|
+
return code.split("\n").map((line) => fg(palette.code)(line));
|
|
380
|
+
}
|
|
381
|
+
const theme = {
|
|
382
|
+
fg: fg(palette.text),
|
|
383
|
+
assistantText: (text) => text,
|
|
384
|
+
dim: fg(palette.dim),
|
|
385
|
+
accent: fg(palette.accent),
|
|
386
|
+
accentSoft: fg(palette.accentSoft),
|
|
387
|
+
success: fg(palette.success),
|
|
388
|
+
error: fg(palette.error),
|
|
389
|
+
header: (text) => chalk.bold(fg(palette.accent)(text)),
|
|
390
|
+
system: fg(palette.systemText),
|
|
391
|
+
userBg: bg(palette.userBg),
|
|
392
|
+
userText: fg(palette.userText),
|
|
393
|
+
toolTitle: fg(palette.toolTitle),
|
|
394
|
+
toolOutput: fg(palette.toolOutput),
|
|
395
|
+
toolPendingBg: bg(palette.toolPendingBg),
|
|
396
|
+
toolSuccessBg: bg(palette.toolSuccessBg),
|
|
397
|
+
toolErrorBg: bg(palette.toolErrorBg),
|
|
398
|
+
border: fg(palette.border),
|
|
399
|
+
bold: (text) => chalk.bold(text),
|
|
400
|
+
italic: (text) => chalk.italic(text)
|
|
401
|
+
};
|
|
402
|
+
const markdownTheme = {
|
|
403
|
+
heading: (text) => chalk.bold(fg(palette.accent)(text)),
|
|
404
|
+
link: (text) => fg(palette.link)(text),
|
|
405
|
+
linkUrl: (text) => chalk.dim(text),
|
|
406
|
+
code: (text) => fg(palette.code)(text),
|
|
407
|
+
codeBlock: (text) => fg(palette.code)(text),
|
|
408
|
+
codeBlockBorder: (text) => fg(palette.codeBorder)(text),
|
|
409
|
+
quote: (text) => fg(palette.quote)(text),
|
|
410
|
+
quoteBorder: (text) => fg(palette.quoteBorder)(text),
|
|
411
|
+
hr: (text) => fg(palette.border)(text),
|
|
412
|
+
listBullet: (text) => fg(palette.accentSoft)(text),
|
|
413
|
+
bold: (text) => chalk.bold(text),
|
|
414
|
+
italic: (text) => chalk.italic(text),
|
|
415
|
+
strikethrough: (text) => chalk.strikethrough(text),
|
|
416
|
+
underline: (text) => chalk.underline(text),
|
|
417
|
+
highlightCode
|
|
418
|
+
};
|
|
419
|
+
const baseSelectListTheme = {
|
|
420
|
+
selectedPrefix: (text) => fg(palette.accent)(text),
|
|
421
|
+
selectedText: (text) => chalk.bold(fg(palette.accent)(text)),
|
|
422
|
+
description: (text) => fg(palette.dim)(text),
|
|
423
|
+
scrollInfo: (text) => fg(palette.dim)(text),
|
|
424
|
+
noMatch: (text) => fg(palette.dim)(text)
|
|
425
|
+
};
|
|
426
|
+
const selectListTheme = baseSelectListTheme;
|
|
427
|
+
const filterableSelectListTheme = {
|
|
428
|
+
...baseSelectListTheme,
|
|
429
|
+
filterLabel: (text) => fg(palette.dim)(text)
|
|
430
|
+
};
|
|
431
|
+
const settingsListTheme = {
|
|
432
|
+
label: (text, selected) => selected ? chalk.bold(fg(palette.accent)(text)) : fg(palette.text)(text),
|
|
433
|
+
value: (text, selected) => selected ? fg(palette.accentSoft)(text) : fg(palette.dim)(text),
|
|
434
|
+
description: (text) => fg(palette.systemText)(text),
|
|
435
|
+
cursor: fg(palette.accent)("→ "),
|
|
436
|
+
hint: (text) => fg(palette.dim)(text)
|
|
437
|
+
};
|
|
438
|
+
const editorTheme = {
|
|
439
|
+
borderColor: (text) => fg(palette.border)(text),
|
|
440
|
+
selectList: selectListTheme
|
|
441
|
+
};
|
|
442
|
+
const searchableSelectListTheme = {
|
|
443
|
+
...baseSelectListTheme,
|
|
444
|
+
searchPrompt: (text) => fg(palette.accentSoft)(text),
|
|
445
|
+
searchInput: (text) => fg(palette.text)(text),
|
|
446
|
+
matchHighlight: (text) => chalk.bold(fg(palette.accent)(text))
|
|
447
|
+
};
|
|
448
|
+
//#endregion
|
|
449
|
+
//#region src/tui/osc8-hyperlinks.ts
|
|
450
|
+
const SGR_PATTERN = "\\x1b\\[[0-9;]*m";
|
|
451
|
+
const OSC8_PATTERN = "\\x1b\\]8;;.*?(?:\\x07|\\x1b\\\\)";
|
|
452
|
+
const ANSI_RE = new RegExp(`${SGR_PATTERN}|${OSC8_PATTERN}`, "g");
|
|
453
|
+
const SGR_START_RE = new RegExp(`^${SGR_PATTERN}`);
|
|
454
|
+
const OSC8_START_RE = new RegExp(`^${OSC8_PATTERN}`);
|
|
455
|
+
/**
|
|
456
|
+
* Extract all unique URLs from raw markdown text.
|
|
457
|
+
* Finds both bare URLs and markdown link hrefs [text](url).
|
|
458
|
+
*/
|
|
459
|
+
function extractUrls(markdown) {
|
|
460
|
+
const urls = /* @__PURE__ */ new Set();
|
|
461
|
+
const mdLinkRe = /\[(?:[^\]]*)\]\(\s*<?(https?:\/\/[^)\s>]+)>?(?:\s+["'][^"']*["'])?\s*\)/g;
|
|
462
|
+
let m;
|
|
463
|
+
while ((m = mdLinkRe.exec(markdown)) !== null) urls.add(m[1]);
|
|
464
|
+
const stripped = markdown.replace(/\[(?:[^\]]*)\]\(\s*<?https?:\/\/[^)\s>]+>?(?:\s+["'][^"']*["'])?\s*\)/g, "");
|
|
465
|
+
const bareRe = /https?:\/\/[^\s)\]>]+/g;
|
|
466
|
+
while ((m = bareRe.exec(stripped)) !== null) urls.add(m[0]);
|
|
467
|
+
return [...urls];
|
|
468
|
+
}
|
|
469
|
+
/** Strip ANSI SGR and OSC 8 sequences to get visible text. */
|
|
470
|
+
function stripAnsi(input) {
|
|
471
|
+
return input.replace(ANSI_RE, "");
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Find URL ranges in a line's visible text, handling cross-line URL splits.
|
|
475
|
+
*/
|
|
476
|
+
function findUrlRanges(visibleText, knownUrls, pending) {
|
|
477
|
+
const ranges = [];
|
|
478
|
+
let newPending = null;
|
|
479
|
+
let searchFrom = 0;
|
|
480
|
+
if (pending) {
|
|
481
|
+
const remaining = pending.url.slice(pending.consumed);
|
|
482
|
+
const trimmed = visibleText.trimStart();
|
|
483
|
+
const leadingSpaces = visibleText.length - trimmed.length;
|
|
484
|
+
let matchLen = 0;
|
|
485
|
+
for (let j = 0; j < remaining.length && j < trimmed.length; j++) if (remaining[j] === trimmed[j]) matchLen++;
|
|
486
|
+
else break;
|
|
487
|
+
if (matchLen > 0) {
|
|
488
|
+
ranges.push({
|
|
489
|
+
start: leadingSpaces,
|
|
490
|
+
end: leadingSpaces + matchLen,
|
|
491
|
+
url: pending.url
|
|
492
|
+
});
|
|
493
|
+
searchFrom = leadingSpaces + matchLen;
|
|
494
|
+
if (pending.consumed + matchLen < pending.url.length) newPending = {
|
|
495
|
+
url: pending.url,
|
|
496
|
+
consumed: pending.consumed + matchLen
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
const urlRe = /https?:\/\/[^\s)\]>]+/g;
|
|
501
|
+
urlRe.lastIndex = searchFrom;
|
|
502
|
+
let match;
|
|
503
|
+
while ((match = urlRe.exec(visibleText)) !== null) {
|
|
504
|
+
const fragment = match[0];
|
|
505
|
+
const start = match.index;
|
|
506
|
+
let resolvedUrl = fragment;
|
|
507
|
+
let found = false;
|
|
508
|
+
for (const known of knownUrls) if (known === fragment) {
|
|
509
|
+
resolvedUrl = known;
|
|
510
|
+
found = true;
|
|
511
|
+
break;
|
|
512
|
+
}
|
|
513
|
+
if (!found) {
|
|
514
|
+
let bestLen = 0;
|
|
515
|
+
for (const known of knownUrls) if (known.startsWith(fragment) && known.length > bestLen) {
|
|
516
|
+
resolvedUrl = known;
|
|
517
|
+
bestLen = known.length;
|
|
518
|
+
found = true;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
if (!found) {
|
|
522
|
+
let bestLen = 0;
|
|
523
|
+
for (const known of knownUrls) if (fragment.startsWith(known) && known.length > bestLen) {
|
|
524
|
+
resolvedUrl = known;
|
|
525
|
+
bestLen = known.length;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
ranges.push({
|
|
529
|
+
start,
|
|
530
|
+
end: start + fragment.length,
|
|
531
|
+
url: resolvedUrl
|
|
532
|
+
});
|
|
533
|
+
if (resolvedUrl.length > fragment.length && resolvedUrl.startsWith(fragment)) newPending = {
|
|
534
|
+
url: resolvedUrl,
|
|
535
|
+
consumed: fragment.length
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
return {
|
|
539
|
+
ranges,
|
|
540
|
+
pending: newPending
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Apply OSC 8 hyperlink sequences to a line based on visible-text URL ranges.
|
|
545
|
+
* Walks through the raw string character by character, inserting OSC 8
|
|
546
|
+
* open/close sequences at URL range boundaries while preserving ANSI codes.
|
|
547
|
+
*/
|
|
548
|
+
function applyOsc8Ranges(line, ranges) {
|
|
549
|
+
if (ranges.length === 0) return line;
|
|
550
|
+
const urlAt = /* @__PURE__ */ new Map();
|
|
551
|
+
for (const r of ranges) for (let p = r.start; p < r.end; p++) urlAt.set(p, r.url);
|
|
552
|
+
let result = "";
|
|
553
|
+
let visiblePos = 0;
|
|
554
|
+
let activeUrl = null;
|
|
555
|
+
let i = 0;
|
|
556
|
+
while (i < line.length) {
|
|
557
|
+
if (line.charCodeAt(i) === 27) {
|
|
558
|
+
const sgr = line.slice(i).match(SGR_START_RE);
|
|
559
|
+
if (sgr) {
|
|
560
|
+
result += sgr[0];
|
|
561
|
+
i += sgr[0].length;
|
|
562
|
+
continue;
|
|
563
|
+
}
|
|
564
|
+
const osc = line.slice(i).match(OSC8_START_RE);
|
|
565
|
+
if (osc) {
|
|
566
|
+
result += osc[0];
|
|
567
|
+
i += osc[0].length;
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
const targetUrl = urlAt.get(visiblePos) ?? null;
|
|
572
|
+
if (targetUrl !== activeUrl) {
|
|
573
|
+
if (activeUrl !== null) result += "\x1B]8;;\x07";
|
|
574
|
+
if (targetUrl !== null) result += `\x1b]8;;${targetUrl}\x07`;
|
|
575
|
+
activeUrl = targetUrl;
|
|
576
|
+
}
|
|
577
|
+
result += line[i];
|
|
578
|
+
visiblePos++;
|
|
579
|
+
i++;
|
|
580
|
+
}
|
|
581
|
+
if (activeUrl !== null) result += "\x1B]8;;\x07";
|
|
582
|
+
return result;
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Add OSC 8 hyperlinks to rendered lines using a pre-extracted URL list.
|
|
586
|
+
*
|
|
587
|
+
* For each line, finds URL-like substrings in the visible text, matches them
|
|
588
|
+
* against known URLs, and wraps each fragment with OSC 8 escape sequences.
|
|
589
|
+
* Handles URLs broken across multiple lines by pi-tui's word wrapping.
|
|
590
|
+
*/
|
|
591
|
+
function addOsc8Hyperlinks(lines, urls) {
|
|
592
|
+
if (urls.length === 0) return lines;
|
|
593
|
+
let pending = null;
|
|
594
|
+
return lines.map((line) => {
|
|
595
|
+
const result = findUrlRanges(stripAnsi(line), urls, pending);
|
|
596
|
+
pending = result.pending;
|
|
597
|
+
return applyOsc8Ranges(line, result.ranges);
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
//#endregion
|
|
601
|
+
//#region src/tui/components/hyperlink-markdown.ts
|
|
602
|
+
/**
|
|
603
|
+
* Wrapper around pi-tui's Markdown component that adds OSC 8 terminal
|
|
604
|
+
* hyperlinks to rendered output, making URLs clickable even when broken
|
|
605
|
+
* across multiple lines by word wrapping.
|
|
606
|
+
*/
|
|
607
|
+
var HyperlinkMarkdown = class {
|
|
608
|
+
constructor(text, paddingX, paddingY, theme, options) {
|
|
609
|
+
this.inner = new Markdown(text, paddingX, paddingY, theme, options);
|
|
610
|
+
this.urls = extractUrls(text);
|
|
611
|
+
}
|
|
612
|
+
render(width) {
|
|
613
|
+
return addOsc8Hyperlinks(this.inner.render(width), this.urls);
|
|
614
|
+
}
|
|
615
|
+
setText(text) {
|
|
616
|
+
this.inner.setText(text);
|
|
617
|
+
this.urls = extractUrls(text);
|
|
618
|
+
}
|
|
619
|
+
invalidate() {
|
|
620
|
+
this.inner.invalidate();
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
//#endregion
|
|
624
|
+
//#region src/tui/components/assistant-message.ts
|
|
625
|
+
var AssistantMessageComponent = class extends Container {
|
|
626
|
+
constructor(text) {
|
|
627
|
+
super();
|
|
628
|
+
this.body = new HyperlinkMarkdown(text, 0, 0, markdownTheme, { color: (line) => theme.assistantText(line) });
|
|
629
|
+
this.addChild(new Spacer(1));
|
|
630
|
+
this.addChild(this.body);
|
|
631
|
+
}
|
|
632
|
+
setText(text) {
|
|
633
|
+
this.body.setText(text);
|
|
634
|
+
}
|
|
635
|
+
};
|
|
636
|
+
//#endregion
|
|
637
|
+
//#region src/tui/components/btw-inline-message.ts
|
|
638
|
+
var BtwInlineMessage = class extends Container {
|
|
639
|
+
constructor(params) {
|
|
640
|
+
super();
|
|
641
|
+
this.setResult(params);
|
|
642
|
+
}
|
|
643
|
+
setResult(params) {
|
|
644
|
+
this.clear();
|
|
645
|
+
this.addChild(new Spacer(1));
|
|
646
|
+
this.addChild(new Text(theme.header(`BTW: ${params.question}`), 1, 0));
|
|
647
|
+
if (params.isError) this.addChild(new Text(theme.error(params.text), 1, 0));
|
|
648
|
+
else this.addChild(new AssistantMessageComponent(params.text));
|
|
649
|
+
this.addChild(new Text(theme.dim("Press Enter or Esc to dismiss"), 1, 0));
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
//#endregion
|
|
653
|
+
//#region src/tui/tui-formatters.ts
|
|
654
|
+
const REPLACEMENT_CHAR_RE = /\uFFFD/g;
|
|
655
|
+
const MAX_TOKEN_CHARS = 32;
|
|
656
|
+
const LONG_TOKEN_RE = /\S{33,}/g;
|
|
657
|
+
const LONG_TOKEN_TEST_RE = /\S{33,}/;
|
|
658
|
+
const BINARY_LINE_REPLACEMENT_THRESHOLD = 12;
|
|
659
|
+
const URL_PREFIX_RE = /^(https?:\/\/|file:\/\/)/i;
|
|
660
|
+
const WINDOWS_DRIVE_RE = /^[a-zA-Z]:[\\/]/;
|
|
661
|
+
const FILE_LIKE_RE = /^[a-zA-Z0-9._-]+$/;
|
|
662
|
+
const EDGE_PUNCTUATION_RE = /^[`"'([{<]+|[`"')\]}>.,:;!?]+$/g;
|
|
663
|
+
const ALPHANUMERIC_RE = /[A-Za-z0-9]/;
|
|
664
|
+
const TOKENISH_MIN_LENGTH = 24;
|
|
665
|
+
const RTL_SCRIPT_RE = /[\u0590-\u08ff\ufb1d-\ufdff\ufe70-\ufefc]/;
|
|
666
|
+
const BIDI_CONTROL_RE = /[\u202a-\u202e\u2066-\u2069]/;
|
|
667
|
+
const RTL_ISOLATE_START = "";
|
|
668
|
+
const RTL_ISOLATE_END = "";
|
|
669
|
+
const FENCED_CODE_RE = /(```|~~~)[^\n]*\n[\s\S]*?\n\1[^\n]*/g;
|
|
670
|
+
const INLINE_CODE_RE = /(`+)(?:(?!\1).)+?\1/g;
|
|
671
|
+
function hasControlChars(text) {
|
|
672
|
+
for (const char of text) {
|
|
673
|
+
const code = char.charCodeAt(0);
|
|
674
|
+
if (code <= 31 && code !== 9 && code !== 10 && code !== 13 || code >= 127 && code <= 159) return true;
|
|
675
|
+
}
|
|
676
|
+
return false;
|
|
677
|
+
}
|
|
678
|
+
function stripControlChars(text) {
|
|
679
|
+
if (!hasControlChars(text)) return text;
|
|
680
|
+
let sanitized = "";
|
|
681
|
+
for (const char of text) {
|
|
682
|
+
const code = char.charCodeAt(0);
|
|
683
|
+
if (!(code <= 31 && code !== 9 && code !== 10 && code !== 13) && !(code >= 127 && code <= 159)) sanitized += char;
|
|
684
|
+
}
|
|
685
|
+
return sanitized;
|
|
686
|
+
}
|
|
687
|
+
function chunkToken(token, maxChars) {
|
|
688
|
+
if (token.length <= maxChars) return [token];
|
|
689
|
+
const chunks = [];
|
|
690
|
+
for (let i = 0; i < token.length; i += maxChars) chunks.push(token.slice(i, i + maxChars));
|
|
691
|
+
return chunks;
|
|
692
|
+
}
|
|
693
|
+
function isCopySensitiveToken(token) {
|
|
694
|
+
const candidate = token.replace(EDGE_PUNCTUATION_RE, "") || token;
|
|
695
|
+
if (URL_PREFIX_RE.test(candidate)) return true;
|
|
696
|
+
if (candidate.startsWith("/") || candidate.startsWith("~/") || candidate.startsWith("./") || candidate.startsWith("../")) return true;
|
|
697
|
+
if (WINDOWS_DRIVE_RE.test(candidate) || candidate.startsWith("\\\\")) return true;
|
|
698
|
+
if (candidate.includes("/") || candidate.includes("\\")) return true;
|
|
699
|
+
if (FILE_LIKE_RE.test(candidate) && (candidate.includes("_") || candidate.includes("-") || candidate.includes("."))) return true;
|
|
700
|
+
if (candidate.length >= TOKENISH_MIN_LENGTH && /[a-z]/i.test(candidate) && /\d/.test(candidate)) return true;
|
|
701
|
+
return false;
|
|
702
|
+
}
|
|
703
|
+
function normalizeLongTokenForDisplay(token) {
|
|
704
|
+
if (isCopySensitiveToken(token)) return token;
|
|
705
|
+
if (!ALPHANUMERIC_RE.test(token)) return token;
|
|
706
|
+
return chunkToken(token, MAX_TOKEN_CHARS).join(" ");
|
|
707
|
+
}
|
|
708
|
+
function partitionByRegex(text, re) {
|
|
709
|
+
const parts = [];
|
|
710
|
+
let lastIndex = 0;
|
|
711
|
+
for (const match of text.matchAll(re)) {
|
|
712
|
+
const start = match.index ?? 0;
|
|
713
|
+
if (start > lastIndex) parts.push({
|
|
714
|
+
kind: "prose",
|
|
715
|
+
text: text.slice(lastIndex, start)
|
|
716
|
+
});
|
|
717
|
+
parts.push({
|
|
718
|
+
kind: "code",
|
|
719
|
+
text: match[0]
|
|
720
|
+
});
|
|
721
|
+
lastIndex = start + match[0].length;
|
|
722
|
+
}
|
|
723
|
+
if (lastIndex < text.length) parts.push({
|
|
724
|
+
kind: "prose",
|
|
725
|
+
text: text.slice(lastIndex)
|
|
726
|
+
});
|
|
727
|
+
return parts;
|
|
728
|
+
}
|
|
729
|
+
function transformOutsideCode(text, transform) {
|
|
730
|
+
return partitionByRegex(text, FENCED_CODE_RE).map((seg) => {
|
|
731
|
+
if (seg.kind === "code") return seg.text;
|
|
732
|
+
return partitionByRegex(seg.text, INLINE_CODE_RE).map((s) => s.kind === "code" ? s.text : transform(s.text)).join("");
|
|
733
|
+
}).join("");
|
|
734
|
+
}
|
|
735
|
+
function redactBinaryLikeLine(line) {
|
|
736
|
+
const replacementCount = (line.match(REPLACEMENT_CHAR_RE) || []).length;
|
|
737
|
+
if (replacementCount >= BINARY_LINE_REPLACEMENT_THRESHOLD && replacementCount * 2 >= line.length) return "[binary data omitted]";
|
|
738
|
+
return line;
|
|
739
|
+
}
|
|
740
|
+
function isolateRtlLine(line) {
|
|
741
|
+
if (!RTL_SCRIPT_RE.test(line) || BIDI_CONTROL_RE.test(line)) return line;
|
|
742
|
+
return `${RTL_ISOLATE_START}${line}${RTL_ISOLATE_END}`;
|
|
743
|
+
}
|
|
744
|
+
function applyRtlIsolation(text) {
|
|
745
|
+
if (!RTL_SCRIPT_RE.test(text)) return text;
|
|
746
|
+
return text.split("\n").map((line) => isolateRtlLine(line)).join("\n");
|
|
747
|
+
}
|
|
748
|
+
function sanitizeRenderableText(text) {
|
|
749
|
+
if (!text) return text;
|
|
750
|
+
const hasAnsi = text.includes("\x1B");
|
|
751
|
+
const hasReplacementChars = text.includes("�");
|
|
752
|
+
const hasLongTokens = LONG_TOKEN_TEST_RE.test(text);
|
|
753
|
+
const hasControls = hasControlChars(text);
|
|
754
|
+
if (!hasAnsi && !hasReplacementChars && !hasLongTokens && !hasControls) return applyRtlIsolation(text);
|
|
755
|
+
const withoutAnsi = hasAnsi ? stripAnsi$1(text) : text;
|
|
756
|
+
const withoutControlChars = hasControls ? stripControlChars(withoutAnsi) : withoutAnsi;
|
|
757
|
+
const redacted = hasReplacementChars ? withoutControlChars.split("\n").map((line) => redactBinaryLikeLine(line)).join("\n") : withoutControlChars;
|
|
758
|
+
return applyRtlIsolation(LONG_TOKEN_TEST_RE.test(redacted) ? transformOutsideCode(redacted, (segment) => LONG_TOKEN_TEST_RE.test(segment) ? segment.replace(LONG_TOKEN_RE, normalizeLongTokenForDisplay) : segment) : redacted);
|
|
759
|
+
}
|
|
760
|
+
function resolveFinalAssistantText(params) {
|
|
761
|
+
const finalText = params.finalText ?? "";
|
|
762
|
+
if (finalText.trim()) return finalText;
|
|
763
|
+
const streamedText = params.streamedText ?? "";
|
|
764
|
+
if (streamedText.trim()) return streamedText;
|
|
765
|
+
const errorMessage = params.errorMessage ?? "";
|
|
766
|
+
if (errorMessage.trim()) return formatRawAssistantErrorForUi(errorMessage);
|
|
767
|
+
return "(no output)";
|
|
768
|
+
}
|
|
769
|
+
function composeThinkingAndContent(params) {
|
|
770
|
+
const thinkingText = params.thinkingText?.trim() ?? "";
|
|
771
|
+
const contentText = params.contentText?.trim() ?? "";
|
|
772
|
+
const parts = [];
|
|
773
|
+
if (params.showThinking && thinkingText) parts.push(`[thinking]\n${thinkingText}`);
|
|
774
|
+
if (contentText) parts.push(contentText);
|
|
775
|
+
return parts.join("\n\n").trim();
|
|
776
|
+
}
|
|
777
|
+
function asMessageRecord(message) {
|
|
778
|
+
if (!message || typeof message !== "object") return;
|
|
779
|
+
return message;
|
|
780
|
+
}
|
|
781
|
+
function resolveMessageRecord(message) {
|
|
782
|
+
const record = asMessageRecord(message);
|
|
783
|
+
if (!record) return;
|
|
784
|
+
return {
|
|
785
|
+
record,
|
|
786
|
+
content: record.content
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
function formatAssistantErrorFromRecord(record) {
|
|
790
|
+
if ((typeof record.stopReason === "string" ? record.stopReason : "") !== "error") return "";
|
|
791
|
+
return formatRawAssistantErrorForUi(typeof record.errorMessage === "string" ? record.errorMessage : "");
|
|
792
|
+
}
|
|
793
|
+
function collectSanitizedBlockStrings(params) {
|
|
794
|
+
if (!Array.isArray(params.content)) return [];
|
|
795
|
+
const parts = [];
|
|
796
|
+
for (const block of params.content) {
|
|
797
|
+
if (!block || typeof block !== "object") continue;
|
|
798
|
+
const rec = block;
|
|
799
|
+
if (rec.type === params.blockType && typeof rec[params.valueKey] === "string") parts.push(sanitizeRenderableText(rec[params.valueKey]));
|
|
800
|
+
}
|
|
801
|
+
return parts;
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Extract ONLY thinking blocks from message content.
|
|
805
|
+
* Model-agnostic: returns empty string if no thinking blocks exist.
|
|
806
|
+
*/
|
|
807
|
+
function extractThinkingFromMessage(message) {
|
|
808
|
+
const resolved = resolveMessageRecord(message);
|
|
809
|
+
if (!resolved) return "";
|
|
810
|
+
const { content } = resolved;
|
|
811
|
+
if (typeof content === "string") return "";
|
|
812
|
+
return collectSanitizedBlockStrings({
|
|
813
|
+
content,
|
|
814
|
+
blockType: "thinking",
|
|
815
|
+
valueKey: "thinking"
|
|
816
|
+
}).join("\n").trim();
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* Extract ONLY text content blocks from message (excludes thinking).
|
|
820
|
+
* Model-agnostic: works for any model with text content blocks.
|
|
821
|
+
*/
|
|
822
|
+
function extractContentFromMessage(message) {
|
|
823
|
+
const resolved = resolveMessageRecord(message);
|
|
824
|
+
if (!resolved) return "";
|
|
825
|
+
const { record, content } = resolved;
|
|
826
|
+
if (record.role === "assistant") {
|
|
827
|
+
if (typeof content === "string") return sanitizeRenderableText(content).trim();
|
|
828
|
+
if (Array.isArray(content)) return extractAssistantRenderableContent(record);
|
|
829
|
+
}
|
|
830
|
+
if (typeof content === "string") return sanitizeRenderableText(content).trim();
|
|
831
|
+
const parts = collectSanitizedBlockStrings({
|
|
832
|
+
content,
|
|
833
|
+
blockType: "text",
|
|
834
|
+
valueKey: "text"
|
|
835
|
+
});
|
|
836
|
+
if (parts.length > 0) return parts.join("\n").trim();
|
|
837
|
+
return formatAssistantErrorFromRecord(record);
|
|
838
|
+
}
|
|
839
|
+
function extractAssistantRenderableContent(record) {
|
|
840
|
+
const visible = sanitizeRenderableText(extractAssistantVisibleText(record) ?? "").trim();
|
|
841
|
+
if (visible) return visible;
|
|
842
|
+
return formatAssistantErrorFromRecord(record);
|
|
843
|
+
}
|
|
844
|
+
function extractTextBlocks(content, opts) {
|
|
845
|
+
if (typeof content === "string") return sanitizeRenderableText(content).trim();
|
|
846
|
+
if (!Array.isArray(content)) return "";
|
|
847
|
+
const textParts = collectSanitizedBlockStrings({
|
|
848
|
+
content,
|
|
849
|
+
blockType: "text",
|
|
850
|
+
valueKey: "text"
|
|
851
|
+
});
|
|
852
|
+
return composeThinkingAndContent({
|
|
853
|
+
thinkingText: (opts?.includeThinking === true ? collectSanitizedBlockStrings({
|
|
854
|
+
content,
|
|
855
|
+
blockType: "thinking",
|
|
856
|
+
valueKey: "thinking"
|
|
857
|
+
}) : []).join("\n").trim(),
|
|
858
|
+
contentText: textParts.join("\n").trim(),
|
|
859
|
+
showThinking: opts?.includeThinking ?? false
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
function extractTextFromMessage(message, opts) {
|
|
863
|
+
const record = asMessageRecord(message);
|
|
864
|
+
if (!record) return "";
|
|
865
|
+
if (record.role === "assistant") return composeThinkingAndContent({
|
|
866
|
+
thinkingText: extractThinkingFromMessage(record),
|
|
867
|
+
contentText: extractAssistantRenderableContent(record),
|
|
868
|
+
showThinking: opts?.includeThinking ?? false
|
|
869
|
+
});
|
|
870
|
+
const text = extractTextBlocks(record.content, opts);
|
|
871
|
+
if (text) {
|
|
872
|
+
if (record.role === "user" || record.command === true) return stripLeadingInboundMetadata(text);
|
|
873
|
+
return text;
|
|
874
|
+
}
|
|
875
|
+
const errorText = formatAssistantErrorFromRecord(record);
|
|
876
|
+
if (!errorText) return "";
|
|
877
|
+
return errorText;
|
|
878
|
+
}
|
|
879
|
+
function isCommandMessage(message) {
|
|
880
|
+
if (!message || typeof message !== "object") return false;
|
|
881
|
+
return message.command === true;
|
|
882
|
+
}
|
|
883
|
+
function formatTokens(total, context) {
|
|
884
|
+
if (total == null && context == null) return "tokens ?";
|
|
885
|
+
const totalLabel = total == null ? "?" : formatTokenCount(total);
|
|
886
|
+
if (context == null) return `tokens ${totalLabel}`;
|
|
887
|
+
const pct = typeof total === "number" && context > 0 ? Math.min(999, Math.round(total / context * 100)) : null;
|
|
888
|
+
return `tokens ${totalLabel}/${formatTokenCount(context)}${pct !== null ? ` (${pct}%)` : ""}`;
|
|
889
|
+
}
|
|
890
|
+
function formatContextUsageLine(params) {
|
|
891
|
+
const totalLabel = typeof params.total === "number" ? formatTokenCount(params.total) : "?";
|
|
892
|
+
const ctxLabel = typeof params.context === "number" ? formatTokenCount(params.context) : "?";
|
|
893
|
+
const pct = typeof params.percent === "number" ? Math.min(999, Math.round(params.percent)) : null;
|
|
894
|
+
const extra = [typeof params.remaining === "number" ? `${formatTokenCount(params.remaining)} left` : null, pct !== null ? `${pct}%` : null].filter(Boolean).join(", ");
|
|
895
|
+
return `tokens ${totalLabel}/${ctxLabel}${extra ? ` (${extra})` : ""}`;
|
|
896
|
+
}
|
|
897
|
+
function asString(value, fallback = "") {
|
|
898
|
+
if (typeof value === "string") return value;
|
|
899
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
900
|
+
return fallback;
|
|
901
|
+
}
|
|
902
|
+
//#endregion
|
|
903
|
+
//#region src/tui/components/tool-execution.ts
|
|
904
|
+
const PREVIEW_LINES = 12;
|
|
905
|
+
function formatArgs(toolName, args) {
|
|
906
|
+
const detail = formatToolDetail(resolveToolDisplay({
|
|
907
|
+
name: toolName,
|
|
908
|
+
args
|
|
909
|
+
}));
|
|
910
|
+
if (detail) return sanitizeRenderableText(detail);
|
|
911
|
+
if (!args || typeof args !== "object") return "";
|
|
912
|
+
try {
|
|
913
|
+
return sanitizeRenderableText(JSON.stringify(args));
|
|
914
|
+
} catch {
|
|
915
|
+
return "";
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
function extractText(result) {
|
|
919
|
+
if (!result?.content) return "";
|
|
920
|
+
const lines = [];
|
|
921
|
+
for (const entry of result.content) if (entry.type === "text" && entry.text) lines.push(sanitizeRenderableText(entry.text));
|
|
922
|
+
else if (entry.type === "image") {
|
|
923
|
+
const mime = entry.mimeType ?? "image";
|
|
924
|
+
const size = entry.bytes ? ` ${Math.round(entry.bytes / 1024)}kb` : "";
|
|
925
|
+
const omitted = entry.omitted ? " (omitted)" : "";
|
|
926
|
+
lines.push(`[${mime}${size}${omitted}]`);
|
|
927
|
+
}
|
|
928
|
+
return lines.join("\n").trim();
|
|
929
|
+
}
|
|
930
|
+
var ToolExecutionComponent = class extends Container {
|
|
931
|
+
constructor(toolName, args) {
|
|
932
|
+
super();
|
|
933
|
+
this.expanded = false;
|
|
934
|
+
this.isError = false;
|
|
935
|
+
this.isPartial = true;
|
|
936
|
+
this.toolName = toolName;
|
|
937
|
+
this.args = args;
|
|
938
|
+
this.box = new Box(1, 1, (line) => theme.toolPendingBg(line));
|
|
939
|
+
this.header = new Text("", 0, 0);
|
|
940
|
+
this.argsLine = new Text("", 0, 0);
|
|
941
|
+
this.output = new Markdown("", 0, 0, markdownTheme, { color: (line) => theme.toolOutput(line) });
|
|
942
|
+
this.addChild(new Spacer(1));
|
|
943
|
+
this.addChild(this.box);
|
|
944
|
+
this.box.addChild(this.header);
|
|
945
|
+
this.box.addChild(this.argsLine);
|
|
946
|
+
this.box.addChild(this.output);
|
|
947
|
+
this.refresh();
|
|
948
|
+
}
|
|
949
|
+
setArgs(args) {
|
|
950
|
+
this.args = args;
|
|
951
|
+
this.refresh();
|
|
952
|
+
}
|
|
953
|
+
setExpanded(expanded) {
|
|
954
|
+
this.expanded = expanded;
|
|
955
|
+
this.refresh();
|
|
956
|
+
}
|
|
957
|
+
setResult(result, opts) {
|
|
958
|
+
this.result = result;
|
|
959
|
+
this.isPartial = false;
|
|
960
|
+
this.isError = Boolean(opts?.isError);
|
|
961
|
+
this.refresh();
|
|
962
|
+
}
|
|
963
|
+
setPartialResult(result) {
|
|
964
|
+
this.result = result;
|
|
965
|
+
this.isPartial = true;
|
|
966
|
+
this.refresh();
|
|
967
|
+
}
|
|
968
|
+
refresh() {
|
|
969
|
+
const bg = this.isPartial ? theme.toolPendingBg : this.isError ? theme.toolErrorBg : theme.toolSuccessBg;
|
|
970
|
+
this.box.setBgFn((line) => bg(line));
|
|
971
|
+
const display = resolveToolDisplay({
|
|
972
|
+
name: this.toolName,
|
|
973
|
+
args: this.args
|
|
974
|
+
});
|
|
975
|
+
const title = `${display.emoji} ${display.label}${this.isPartial ? " (running)" : ""}`;
|
|
976
|
+
this.header.setText(theme.toolTitle(theme.bold(title)));
|
|
977
|
+
const argLine = formatArgs(this.toolName, this.args);
|
|
978
|
+
this.argsLine.setText(argLine ? theme.dim(argLine) : theme.dim(" "));
|
|
979
|
+
const text = extractText(this.result) || (this.isPartial ? "…" : "");
|
|
980
|
+
if (!this.expanded && text) {
|
|
981
|
+
const lines = text.split("\n");
|
|
982
|
+
const preview = lines.length > PREVIEW_LINES ? `${lines.slice(0, PREVIEW_LINES).join("\n")}\n…` : text;
|
|
983
|
+
this.output.setText(preview);
|
|
984
|
+
} else this.output.setText(text);
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
//#endregion
|
|
988
|
+
//#region src/tui/components/markdown-message.ts
|
|
989
|
+
var MarkdownMessageComponent = class extends Container {
|
|
990
|
+
constructor(text, y, options) {
|
|
991
|
+
super();
|
|
992
|
+
this.body = new HyperlinkMarkdown(text, 0, y, markdownTheme, options);
|
|
993
|
+
this.addChild(new Spacer(1));
|
|
994
|
+
this.addChild(this.body);
|
|
995
|
+
}
|
|
996
|
+
setText(text) {
|
|
997
|
+
this.body.setText(text);
|
|
998
|
+
}
|
|
999
|
+
};
|
|
1000
|
+
//#endregion
|
|
1001
|
+
//#region src/tui/components/user-message.ts
|
|
1002
|
+
var UserMessageComponent = class extends MarkdownMessageComponent {
|
|
1003
|
+
constructor(text) {
|
|
1004
|
+
super(text, 1, {
|
|
1005
|
+
bgColor: (line) => theme.userBg(line),
|
|
1006
|
+
color: (line) => theme.userText(line)
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
};
|
|
1010
|
+
//#endregion
|
|
1011
|
+
//#region src/tui/components/chat-log.ts
|
|
1012
|
+
const PENDING_HISTORY_CLOCK_SKEW_TOLERANCE_MS = 6e4;
|
|
1013
|
+
var ChatLog = class extends Container {
|
|
1014
|
+
constructor(maxComponents = 180) {
|
|
1015
|
+
super();
|
|
1016
|
+
this.toolById = /* @__PURE__ */ new Map();
|
|
1017
|
+
this.streamingRuns = /* @__PURE__ */ new Map();
|
|
1018
|
+
this.pendingUsers = /* @__PURE__ */ new Map();
|
|
1019
|
+
this.pendingSystemNotices = /* @__PURE__ */ new Map();
|
|
1020
|
+
this.btwMessage = null;
|
|
1021
|
+
this.toolsExpanded = false;
|
|
1022
|
+
this.repeatableSystemMessage = null;
|
|
1023
|
+
this.maxComponents = Math.max(20, Math.floor(maxComponents));
|
|
1024
|
+
}
|
|
1025
|
+
dropComponentReferences(component) {
|
|
1026
|
+
for (const [toolId, tool] of this.toolById.entries()) if (tool === component) this.toolById.delete(toolId);
|
|
1027
|
+
for (const [runId, message] of this.streamingRuns.entries()) if (message === component) this.streamingRuns.delete(runId);
|
|
1028
|
+
for (const [runId, entry] of this.pendingUsers.entries()) if (entry.component === component) this.pendingUsers.delete(runId);
|
|
1029
|
+
for (const [runId, entry] of this.pendingSystemNotices.entries()) if (entry === component) this.pendingSystemNotices.delete(runId);
|
|
1030
|
+
if (this.btwMessage === component) this.btwMessage = null;
|
|
1031
|
+
if (this.repeatableSystemMessage?.component === component) this.repeatableSystemMessage = null;
|
|
1032
|
+
}
|
|
1033
|
+
pruneOverflow() {
|
|
1034
|
+
while (this.children.length > this.maxComponents) {
|
|
1035
|
+
const oldest = this.children[0];
|
|
1036
|
+
if (!oldest) return;
|
|
1037
|
+
this.removeChild(oldest);
|
|
1038
|
+
this.dropComponentReferences(oldest);
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
append(component) {
|
|
1042
|
+
this.addChild(component);
|
|
1043
|
+
this.pruneOverflow();
|
|
1044
|
+
}
|
|
1045
|
+
appendNonSystem(component) {
|
|
1046
|
+
this.repeatableSystemMessage = null;
|
|
1047
|
+
this.append(component);
|
|
1048
|
+
}
|
|
1049
|
+
clearAll(opts) {
|
|
1050
|
+
this.clear();
|
|
1051
|
+
this.toolById.clear();
|
|
1052
|
+
this.streamingRuns.clear();
|
|
1053
|
+
this.pendingSystemNotices.clear();
|
|
1054
|
+
this.btwMessage = null;
|
|
1055
|
+
this.repeatableSystemMessage = null;
|
|
1056
|
+
if (!opts?.preservePendingUsers) this.pendingUsers.clear();
|
|
1057
|
+
}
|
|
1058
|
+
restorePendingUsers() {
|
|
1059
|
+
for (const entry of this.pendingUsers.values()) {
|
|
1060
|
+
if (this.children.includes(entry.component)) continue;
|
|
1061
|
+
this.appendNonSystem(entry.component);
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
clearPendingUsers() {
|
|
1065
|
+
for (const entry of this.pendingUsers.values()) this.removeChild(entry.component);
|
|
1066
|
+
this.pendingUsers.clear();
|
|
1067
|
+
}
|
|
1068
|
+
formatRepeatedSystemText(text, count) {
|
|
1069
|
+
return count > 1 ? `${text} x${count}` : text;
|
|
1070
|
+
}
|
|
1071
|
+
createSystemMessage(text) {
|
|
1072
|
+
const entry = new Container();
|
|
1073
|
+
const textNode = new Text(theme.system(text), 1, 0);
|
|
1074
|
+
entry.addChild(new Spacer(1));
|
|
1075
|
+
entry.addChild(textNode);
|
|
1076
|
+
return {
|
|
1077
|
+
component: entry,
|
|
1078
|
+
textNode,
|
|
1079
|
+
baseText: text,
|
|
1080
|
+
count: 1
|
|
1081
|
+
};
|
|
1082
|
+
}
|
|
1083
|
+
addSystem(text, opts) {
|
|
1084
|
+
if (opts?.coalesceConsecutive && this.repeatableSystemMessage?.baseText === text && this.children[this.children.length - 1] === this.repeatableSystemMessage.component) {
|
|
1085
|
+
this.repeatableSystemMessage.count += 1;
|
|
1086
|
+
this.repeatableSystemMessage.textNode.setText(theme.system(this.formatRepeatedSystemText(text, this.repeatableSystemMessage.count)));
|
|
1087
|
+
return;
|
|
1088
|
+
}
|
|
1089
|
+
const message = this.createSystemMessage(text);
|
|
1090
|
+
this.append(message.component);
|
|
1091
|
+
this.repeatableSystemMessage = opts?.coalesceConsecutive ? message : null;
|
|
1092
|
+
}
|
|
1093
|
+
addPendingSystem(runId, text) {
|
|
1094
|
+
const existing = this.pendingSystemNotices.get(runId);
|
|
1095
|
+
if (existing) this.removeChild(existing);
|
|
1096
|
+
const message = this.createSystemMessage(text);
|
|
1097
|
+
this.pendingSystemNotices.set(runId, message.component);
|
|
1098
|
+
this.append(message.component);
|
|
1099
|
+
}
|
|
1100
|
+
dismissPendingSystem(runId) {
|
|
1101
|
+
const existing = this.pendingSystemNotices.get(runId);
|
|
1102
|
+
if (!existing) return false;
|
|
1103
|
+
this.removeChild(existing);
|
|
1104
|
+
this.pendingSystemNotices.delete(runId);
|
|
1105
|
+
return true;
|
|
1106
|
+
}
|
|
1107
|
+
addUser(text) {
|
|
1108
|
+
this.appendNonSystem(new UserMessageComponent(text));
|
|
1109
|
+
}
|
|
1110
|
+
addPendingUser(runId, text, createdAt = Date.now()) {
|
|
1111
|
+
const existing = this.pendingUsers.get(runId);
|
|
1112
|
+
if (existing) {
|
|
1113
|
+
existing.text = text;
|
|
1114
|
+
existing.createdAt = createdAt;
|
|
1115
|
+
existing.component.setText(text);
|
|
1116
|
+
return existing.component;
|
|
1117
|
+
}
|
|
1118
|
+
const component = new UserMessageComponent(text);
|
|
1119
|
+
this.pendingUsers.set(runId, {
|
|
1120
|
+
component,
|
|
1121
|
+
text,
|
|
1122
|
+
createdAt
|
|
1123
|
+
});
|
|
1124
|
+
this.appendNonSystem(component);
|
|
1125
|
+
return component;
|
|
1126
|
+
}
|
|
1127
|
+
commitPendingUser(runId) {
|
|
1128
|
+
return this.pendingUsers.delete(runId);
|
|
1129
|
+
}
|
|
1130
|
+
dropPendingUser(runId) {
|
|
1131
|
+
const existing = this.pendingUsers.get(runId);
|
|
1132
|
+
if (!existing) return false;
|
|
1133
|
+
this.removeChild(existing.component);
|
|
1134
|
+
this.pendingUsers.delete(runId);
|
|
1135
|
+
return true;
|
|
1136
|
+
}
|
|
1137
|
+
hasPendingUser(runId) {
|
|
1138
|
+
return this.pendingUsers.has(runId);
|
|
1139
|
+
}
|
|
1140
|
+
reconcilePendingUsers(historyUsers) {
|
|
1141
|
+
const normalizedHistory = historyUsers.map((entry) => ({
|
|
1142
|
+
text: entry.text.trim(),
|
|
1143
|
+
timestamp: typeof entry.timestamp === "number" ? entry.timestamp : null
|
|
1144
|
+
})).filter((entry) => entry.text.length > 0 && entry.timestamp !== null);
|
|
1145
|
+
const clearedRunIds = [];
|
|
1146
|
+
for (const [runId, entry] of this.pendingUsers.entries()) {
|
|
1147
|
+
const pendingText = entry.text.trim();
|
|
1148
|
+
if (!pendingText) continue;
|
|
1149
|
+
const matchIndex = normalizedHistory.findIndex((historyEntry) => historyEntry.text === pendingText && (historyEntry.timestamp ?? 0) >= entry.createdAt - PENDING_HISTORY_CLOCK_SKEW_TOLERANCE_MS);
|
|
1150
|
+
if (matchIndex === -1) continue;
|
|
1151
|
+
if (this.children.includes(entry.component)) this.removeChild(entry.component);
|
|
1152
|
+
this.pendingUsers.delete(runId);
|
|
1153
|
+
clearedRunIds.push(runId);
|
|
1154
|
+
normalizedHistory.splice(matchIndex, 1);
|
|
1155
|
+
}
|
|
1156
|
+
return clearedRunIds;
|
|
1157
|
+
}
|
|
1158
|
+
countPendingUsers() {
|
|
1159
|
+
return this.pendingUsers.size;
|
|
1160
|
+
}
|
|
1161
|
+
resolveRunId(runId) {
|
|
1162
|
+
return runId ?? "default";
|
|
1163
|
+
}
|
|
1164
|
+
startAssistant(text, runId) {
|
|
1165
|
+
const effectiveRunId = this.resolveRunId(runId);
|
|
1166
|
+
const existing = this.streamingRuns.get(effectiveRunId);
|
|
1167
|
+
if (existing) {
|
|
1168
|
+
existing.setText(text);
|
|
1169
|
+
return existing;
|
|
1170
|
+
}
|
|
1171
|
+
const component = new AssistantMessageComponent(text);
|
|
1172
|
+
this.streamingRuns.set(effectiveRunId, component);
|
|
1173
|
+
this.appendNonSystem(component);
|
|
1174
|
+
return component;
|
|
1175
|
+
}
|
|
1176
|
+
updateAssistant(text, runId) {
|
|
1177
|
+
const effectiveRunId = this.resolveRunId(runId);
|
|
1178
|
+
const existing = this.streamingRuns.get(effectiveRunId);
|
|
1179
|
+
if (!existing) {
|
|
1180
|
+
this.startAssistant(text, runId);
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
existing.setText(text);
|
|
1184
|
+
}
|
|
1185
|
+
finalizeAssistant(text, runId) {
|
|
1186
|
+
const effectiveRunId = this.resolveRunId(runId);
|
|
1187
|
+
const existing = this.streamingRuns.get(effectiveRunId);
|
|
1188
|
+
if (existing) {
|
|
1189
|
+
existing.setText(text);
|
|
1190
|
+
this.streamingRuns.delete(effectiveRunId);
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1193
|
+
this.appendNonSystem(new AssistantMessageComponent(text));
|
|
1194
|
+
}
|
|
1195
|
+
dropAssistant(runId) {
|
|
1196
|
+
const effectiveRunId = this.resolveRunId(runId);
|
|
1197
|
+
const existing = this.streamingRuns.get(effectiveRunId);
|
|
1198
|
+
if (!existing) return;
|
|
1199
|
+
this.removeChild(existing);
|
|
1200
|
+
this.streamingRuns.delete(effectiveRunId);
|
|
1201
|
+
}
|
|
1202
|
+
showBtw(params) {
|
|
1203
|
+
if (this.btwMessage) {
|
|
1204
|
+
this.btwMessage.setResult(params);
|
|
1205
|
+
if (this.children[this.children.length - 1] !== this.btwMessage) {
|
|
1206
|
+
this.removeChild(this.btwMessage);
|
|
1207
|
+
this.appendNonSystem(this.btwMessage);
|
|
1208
|
+
}
|
|
1209
|
+
return this.btwMessage;
|
|
1210
|
+
}
|
|
1211
|
+
const component = new BtwInlineMessage(params);
|
|
1212
|
+
this.btwMessage = component;
|
|
1213
|
+
this.appendNonSystem(component);
|
|
1214
|
+
return component;
|
|
1215
|
+
}
|
|
1216
|
+
dismissBtw() {
|
|
1217
|
+
if (!this.btwMessage) return;
|
|
1218
|
+
this.removeChild(this.btwMessage);
|
|
1219
|
+
this.btwMessage = null;
|
|
1220
|
+
}
|
|
1221
|
+
hasVisibleBtw() {
|
|
1222
|
+
return this.btwMessage !== null;
|
|
1223
|
+
}
|
|
1224
|
+
startTool(toolCallId, toolName, args) {
|
|
1225
|
+
const existing = this.toolById.get(toolCallId);
|
|
1226
|
+
if (existing) {
|
|
1227
|
+
existing.setArgs(args);
|
|
1228
|
+
return existing;
|
|
1229
|
+
}
|
|
1230
|
+
const component = new ToolExecutionComponent(toolName, args);
|
|
1231
|
+
component.setExpanded(this.toolsExpanded);
|
|
1232
|
+
this.toolById.set(toolCallId, component);
|
|
1233
|
+
this.appendNonSystem(component);
|
|
1234
|
+
return component;
|
|
1235
|
+
}
|
|
1236
|
+
updateToolArgs(toolCallId, args) {
|
|
1237
|
+
const existing = this.toolById.get(toolCallId);
|
|
1238
|
+
if (!existing) return;
|
|
1239
|
+
existing.setArgs(args);
|
|
1240
|
+
}
|
|
1241
|
+
updateToolResult(toolCallId, result, opts) {
|
|
1242
|
+
const existing = this.toolById.get(toolCallId);
|
|
1243
|
+
if (!existing) return;
|
|
1244
|
+
if (opts?.partial) {
|
|
1245
|
+
existing.setPartialResult(result);
|
|
1246
|
+
return;
|
|
1247
|
+
}
|
|
1248
|
+
existing.setResult(result, { isError: opts?.isError });
|
|
1249
|
+
}
|
|
1250
|
+
setToolsExpanded(expanded) {
|
|
1251
|
+
this.toolsExpanded = expanded;
|
|
1252
|
+
for (const tool of this.toolById.values()) tool.setExpanded(expanded);
|
|
1253
|
+
}
|
|
1254
|
+
};
|
|
1255
|
+
//#endregion
|
|
1256
|
+
//#region src/tui/components/custom-editor.ts
|
|
1257
|
+
var CustomEditor = class extends Editor {
|
|
1258
|
+
handleInput(data) {
|
|
1259
|
+
if (matchesKey(data, Key.alt("enter")) && this.onAltEnter) {
|
|
1260
|
+
this.onAltEnter();
|
|
1261
|
+
return;
|
|
1262
|
+
}
|
|
1263
|
+
if (matchesKey(data, Key.alt("up")) && this.onAltUp) {
|
|
1264
|
+
this.onAltUp();
|
|
1265
|
+
return;
|
|
1266
|
+
}
|
|
1267
|
+
if (matchesKey(data, Key.ctrl("l")) && this.onCtrlL) {
|
|
1268
|
+
this.onCtrlL();
|
|
1269
|
+
return;
|
|
1270
|
+
}
|
|
1271
|
+
if (matchesKey(data, Key.ctrl("o")) && this.onCtrlO) {
|
|
1272
|
+
this.onCtrlO();
|
|
1273
|
+
return;
|
|
1274
|
+
}
|
|
1275
|
+
if (matchesKey(data, Key.ctrl("p")) && this.onCtrlP) {
|
|
1276
|
+
this.onCtrlP();
|
|
1277
|
+
return;
|
|
1278
|
+
}
|
|
1279
|
+
if (matchesKey(data, Key.ctrl("g")) && this.onCtrlG) {
|
|
1280
|
+
this.onCtrlG();
|
|
1281
|
+
return;
|
|
1282
|
+
}
|
|
1283
|
+
if (matchesKey(data, Key.ctrl("t")) && this.onCtrlT) {
|
|
1284
|
+
this.onCtrlT();
|
|
1285
|
+
return;
|
|
1286
|
+
}
|
|
1287
|
+
if (matchesKey(data, Key.shift("tab")) && this.onShiftTab) {
|
|
1288
|
+
this.onShiftTab();
|
|
1289
|
+
return;
|
|
1290
|
+
}
|
|
1291
|
+
if (matchesKey(data, Key.escape) && this.onEscape && !this.isShowingAutocomplete()) {
|
|
1292
|
+
this.onEscape();
|
|
1293
|
+
return;
|
|
1294
|
+
}
|
|
1295
|
+
if (matchesKey(data, Key.ctrl("c")) && this.onCtrlC) {
|
|
1296
|
+
this.onCtrlC();
|
|
1297
|
+
return;
|
|
1298
|
+
}
|
|
1299
|
+
if (matchesKey(data, Key.ctrl("d"))) {
|
|
1300
|
+
if (this.getText().length === 0 && this.onCtrlD) this.onCtrlD();
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
super.handleInput(data);
|
|
1304
|
+
}
|
|
1305
|
+
};
|
|
1306
|
+
//#endregion
|
|
1307
|
+
//#region src/tui/gateway-chat.ts
|
|
1308
|
+
const STARTUP_CHAT_HISTORY_RETRY_TIMEOUT_MS = 6e4;
|
|
1309
|
+
const STARTUP_CHAT_HISTORY_DEFAULT_RETRY_MS = 500;
|
|
1310
|
+
const STARTUP_CHAT_HISTORY_MAX_RETRY_MS = 5e3;
|
|
1311
|
+
function throwGatewayAuthResolutionError(reason) {
|
|
1312
|
+
throw new Error([
|
|
1313
|
+
reason,
|
|
1314
|
+
"Fix: set DAOCORE_GATEWAY_TOKEN/DAOCORE_GATEWAY_PASSWORD, pass --token/--password,",
|
|
1315
|
+
"or resolve the configured secret provider for this credential."
|
|
1316
|
+
].join("\n"));
|
|
1317
|
+
}
|
|
1318
|
+
function isRetryableStartupUnavailable(err, method) {
|
|
1319
|
+
if (!(err instanceof GatewayClientRequestError)) return false;
|
|
1320
|
+
if (err.gatewayCode !== "UNAVAILABLE" || !err.retryable) return false;
|
|
1321
|
+
const details = err.details;
|
|
1322
|
+
if (!details || typeof details !== "object") return true;
|
|
1323
|
+
const detailMethod = details.method;
|
|
1324
|
+
return typeof detailMethod !== "string" || detailMethod === method;
|
|
1325
|
+
}
|
|
1326
|
+
function resolveStartupRetryDelayMs(err) {
|
|
1327
|
+
const retryAfterMs = typeof err.retryAfterMs === "number" ? err.retryAfterMs : STARTUP_CHAT_HISTORY_DEFAULT_RETRY_MS;
|
|
1328
|
+
return Math.min(Math.max(retryAfterMs, 100), STARTUP_CHAT_HISTORY_MAX_RETRY_MS);
|
|
1329
|
+
}
|
|
1330
|
+
function sleep(ms) {
|
|
1331
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1332
|
+
}
|
|
1333
|
+
var GatewayChatClient = class GatewayChatClient {
|
|
1334
|
+
constructor(connection) {
|
|
1335
|
+
this.connection = connection;
|
|
1336
|
+
this.readyPromise = new Promise((resolve) => {
|
|
1337
|
+
this.resolveReady = resolve;
|
|
1338
|
+
});
|
|
1339
|
+
this.client = new GatewayClient({
|
|
1340
|
+
url: connection.url,
|
|
1341
|
+
token: connection.token,
|
|
1342
|
+
password: connection.password,
|
|
1343
|
+
preauthHandshakeTimeoutMs: connection.preauthHandshakeTimeoutMs,
|
|
1344
|
+
clientName: GATEWAY_CLIENT_NAMES.TUI,
|
|
1345
|
+
clientDisplayName: "daocore-tui",
|
|
1346
|
+
clientVersion: VERSION,
|
|
1347
|
+
platform: process.platform,
|
|
1348
|
+
mode: GATEWAY_CLIENT_MODES.UI,
|
|
1349
|
+
deviceIdentity: connection.allowInsecureLocalOperatorUi ? null : void 0,
|
|
1350
|
+
caps: [GATEWAY_CLIENT_CAPS.TOOL_EVENTS],
|
|
1351
|
+
instanceId: randomUUID(),
|
|
1352
|
+
minProtocol: 4,
|
|
1353
|
+
maxProtocol: 4,
|
|
1354
|
+
onHelloOk: (hello) => {
|
|
1355
|
+
this.hello = hello;
|
|
1356
|
+
this.resolveReady?.();
|
|
1357
|
+
this.onConnected?.();
|
|
1358
|
+
},
|
|
1359
|
+
onEvent: (evt) => {
|
|
1360
|
+
this.onEvent?.({
|
|
1361
|
+
event: evt.event,
|
|
1362
|
+
payload: evt.payload,
|
|
1363
|
+
seq: evt.seq
|
|
1364
|
+
});
|
|
1365
|
+
},
|
|
1366
|
+
onClose: (_code, reason) => {
|
|
1367
|
+
this.readyPromise = new Promise((resolve) => {
|
|
1368
|
+
this.resolveReady = resolve;
|
|
1369
|
+
});
|
|
1370
|
+
this.onDisconnected?.(reason);
|
|
1371
|
+
},
|
|
1372
|
+
onGap: (info) => {
|
|
1373
|
+
this.onGap?.(info);
|
|
1374
|
+
}
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
static async connect(opts) {
|
|
1378
|
+
return new GatewayChatClient(await resolveGatewayConnection(opts));
|
|
1379
|
+
}
|
|
1380
|
+
start() {
|
|
1381
|
+
startGatewayClientWhenEventLoopReady(this.client, { clientOptions: { preauthHandshakeTimeoutMs: this.connection.preauthHandshakeTimeoutMs } }).then((readiness) => {
|
|
1382
|
+
if (!readiness.ready && !readiness.aborted) this.onDisconnected?.("gateway event loop readiness timeout");
|
|
1383
|
+
}).catch((err) => {
|
|
1384
|
+
this.onDisconnected?.(err instanceof Error ? err.message : String(err));
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
stop() {
|
|
1388
|
+
this.client.stop();
|
|
1389
|
+
}
|
|
1390
|
+
async waitForReady() {
|
|
1391
|
+
await this.readyPromise;
|
|
1392
|
+
}
|
|
1393
|
+
async sendChat(opts) {
|
|
1394
|
+
const runId = opts.runId ?? randomUUID();
|
|
1395
|
+
await this.client.request("chat.send", {
|
|
1396
|
+
sessionKey: opts.sessionKey,
|
|
1397
|
+
...opts.sessionId ? { sessionId: opts.sessionId } : {},
|
|
1398
|
+
message: opts.message,
|
|
1399
|
+
thinking: opts.thinking,
|
|
1400
|
+
deliver: opts.deliver,
|
|
1401
|
+
timeoutMs: opts.timeoutMs,
|
|
1402
|
+
idempotencyKey: runId
|
|
1403
|
+
});
|
|
1404
|
+
return { runId };
|
|
1405
|
+
}
|
|
1406
|
+
async abortChat(opts) {
|
|
1407
|
+
return await this.client.request("chat.abort", {
|
|
1408
|
+
sessionKey: opts.sessionKey,
|
|
1409
|
+
runId: opts.runId
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
async loadHistory(opts) {
|
|
1413
|
+
const startedAt = Date.now();
|
|
1414
|
+
for (;;) try {
|
|
1415
|
+
return await this.client.request("chat.history", {
|
|
1416
|
+
sessionKey: opts.sessionKey,
|
|
1417
|
+
limit: opts.limit
|
|
1418
|
+
});
|
|
1419
|
+
} catch (err) {
|
|
1420
|
+
if (Date.now() - startedAt < STARTUP_CHAT_HISTORY_RETRY_TIMEOUT_MS && isRetryableStartupUnavailable(err, "chat.history")) {
|
|
1421
|
+
await sleep(resolveStartupRetryDelayMs(err));
|
|
1422
|
+
continue;
|
|
1423
|
+
}
|
|
1424
|
+
throw err;
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
async listSessions(opts) {
|
|
1428
|
+
return await this.client.request("sessions.list", opts ?? {});
|
|
1429
|
+
}
|
|
1430
|
+
async listAgents() {
|
|
1431
|
+
return await this.client.request("agents.list", {});
|
|
1432
|
+
}
|
|
1433
|
+
async patchSession(opts) {
|
|
1434
|
+
return await this.client.request("sessions.patch", opts);
|
|
1435
|
+
}
|
|
1436
|
+
async resetSession(key, reason) {
|
|
1437
|
+
return await this.client.request("sessions.reset", {
|
|
1438
|
+
key,
|
|
1439
|
+
...reason ? { reason } : {}
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
async getGatewayStatus() {
|
|
1443
|
+
return await this.client.request("status");
|
|
1444
|
+
}
|
|
1445
|
+
async listModels() {
|
|
1446
|
+
const res = await this.client.request("models.list");
|
|
1447
|
+
return Array.isArray(res?.models) ? res.models : [];
|
|
1448
|
+
}
|
|
1449
|
+
async listCommands(opts) {
|
|
1450
|
+
const res = await this.client.request("commands.list", opts ?? {});
|
|
1451
|
+
return Array.isArray(res?.commands) ? res.commands : [];
|
|
1452
|
+
}
|
|
1453
|
+
};
|
|
1454
|
+
async function resolveGatewayConnection(opts) {
|
|
1455
|
+
const config = getRuntimeConfig();
|
|
1456
|
+
const env = process.env;
|
|
1457
|
+
const gatewayAuthMode = config.gateway?.auth?.mode;
|
|
1458
|
+
const isRemoteMode = config.gateway?.mode === "remote";
|
|
1459
|
+
const preferConfiguredAuth = env[TUI_SETUP_AUTH_SOURCE_ENV] === TUI_SETUP_AUTH_SOURCE_CONFIG;
|
|
1460
|
+
const urlOverride = typeof opts.url === "string" && opts.url.trim().length > 0 ? opts.url.trim() : void 0;
|
|
1461
|
+
const explicitAuth = resolveExplicitGatewayAuth({
|
|
1462
|
+
token: opts.token,
|
|
1463
|
+
password: opts.password
|
|
1464
|
+
});
|
|
1465
|
+
ensureExplicitGatewayAuth({
|
|
1466
|
+
urlOverride,
|
|
1467
|
+
urlOverrideSource: "cli",
|
|
1468
|
+
explicitAuth,
|
|
1469
|
+
errorHint: "Fix: pass --token or --password when using --url."
|
|
1470
|
+
});
|
|
1471
|
+
const url = buildGatewayConnectionDetails({
|
|
1472
|
+
config,
|
|
1473
|
+
...urlOverride ? { url: urlOverride } : {}
|
|
1474
|
+
}).url;
|
|
1475
|
+
const allowInsecureLocalOperatorUi = (() => {
|
|
1476
|
+
if (config.gateway?.controlUi?.allowInsecureAuth !== true) return false;
|
|
1477
|
+
try {
|
|
1478
|
+
return isLoopbackHost(new URL(url).hostname);
|
|
1479
|
+
} catch {
|
|
1480
|
+
return false;
|
|
1481
|
+
}
|
|
1482
|
+
})();
|
|
1483
|
+
if (urlOverride) return {
|
|
1484
|
+
url,
|
|
1485
|
+
token: explicitAuth.token,
|
|
1486
|
+
password: explicitAuth.password,
|
|
1487
|
+
preauthHandshakeTimeoutMs: config.gateway?.handshakeTimeoutMs,
|
|
1488
|
+
allowInsecureLocalOperatorUi
|
|
1489
|
+
};
|
|
1490
|
+
if (isRemoteMode) {
|
|
1491
|
+
const resolved = await resolveGatewayInteractiveSurfaceAuth({
|
|
1492
|
+
config,
|
|
1493
|
+
env,
|
|
1494
|
+
explicitAuth,
|
|
1495
|
+
surface: "remote"
|
|
1496
|
+
});
|
|
1497
|
+
if (resolved.failureReason) throwGatewayAuthResolutionError(resolved.failureReason);
|
|
1498
|
+
return {
|
|
1499
|
+
url,
|
|
1500
|
+
token: resolved.token,
|
|
1501
|
+
password: resolved.password,
|
|
1502
|
+
preauthHandshakeTimeoutMs: config.gateway?.handshakeTimeoutMs,
|
|
1503
|
+
allowInsecureLocalOperatorUi: false
|
|
1504
|
+
};
|
|
1505
|
+
}
|
|
1506
|
+
if (gatewayAuthMode === "none" || gatewayAuthMode === "trusted-proxy") {
|
|
1507
|
+
const resolved = await resolveGatewayInteractiveSurfaceAuth({
|
|
1508
|
+
config,
|
|
1509
|
+
env,
|
|
1510
|
+
explicitAuth,
|
|
1511
|
+
surface: "local"
|
|
1512
|
+
});
|
|
1513
|
+
return {
|
|
1514
|
+
url,
|
|
1515
|
+
token: resolved.token,
|
|
1516
|
+
password: resolved.password,
|
|
1517
|
+
preauthHandshakeTimeoutMs: config.gateway?.handshakeTimeoutMs,
|
|
1518
|
+
allowInsecureLocalOperatorUi
|
|
1519
|
+
};
|
|
1520
|
+
}
|
|
1521
|
+
try {
|
|
1522
|
+
assertExplicitGatewayAuthModeWhenBothConfigured(config);
|
|
1523
|
+
} catch (err) {
|
|
1524
|
+
throwGatewayAuthResolutionError(formatErrorMessage(err));
|
|
1525
|
+
}
|
|
1526
|
+
const resolved = await resolveGatewayInteractiveSurfaceAuth({
|
|
1527
|
+
config,
|
|
1528
|
+
env,
|
|
1529
|
+
explicitAuth,
|
|
1530
|
+
suppressEnvAuthFallback: preferConfiguredAuth,
|
|
1531
|
+
surface: "local"
|
|
1532
|
+
});
|
|
1533
|
+
if (resolved.failureReason) throwGatewayAuthResolutionError(resolved.failureReason);
|
|
1534
|
+
return {
|
|
1535
|
+
url,
|
|
1536
|
+
token: resolved.token,
|
|
1537
|
+
password: resolved.password,
|
|
1538
|
+
preauthHandshakeTimeoutMs: config.gateway?.handshakeTimeoutMs,
|
|
1539
|
+
allowInsecureLocalOperatorUi
|
|
1540
|
+
};
|
|
1541
|
+
}
|
|
1542
|
+
//#endregion
|
|
1543
|
+
//#region src/tui/components/fuzzy-filter.ts
|
|
1544
|
+
/**
|
|
1545
|
+
* Shared fuzzy filtering utilities for select list components.
|
|
1546
|
+
*/
|
|
1547
|
+
/**
|
|
1548
|
+
* Word boundary characters for matching.
|
|
1549
|
+
*/
|
|
1550
|
+
const WORD_BOUNDARY_CHARS = /[\s\-_./:#@]/;
|
|
1551
|
+
/**
|
|
1552
|
+
* Check if position is at a word boundary.
|
|
1553
|
+
*/
|
|
1554
|
+
function isWordBoundary(text, index) {
|
|
1555
|
+
return index === 0 || WORD_BOUNDARY_CHARS.test(text[index - 1] ?? "");
|
|
1556
|
+
}
|
|
1557
|
+
/**
|
|
1558
|
+
* Find index where query matches at a word boundary in text.
|
|
1559
|
+
* Returns null if no match.
|
|
1560
|
+
*/
|
|
1561
|
+
function findWordBoundaryIndex(text, query) {
|
|
1562
|
+
if (!query) return null;
|
|
1563
|
+
const textLower = normalizeLowercaseStringOrEmpty(text);
|
|
1564
|
+
const queryLower = normalizeLowercaseStringOrEmpty(query);
|
|
1565
|
+
const maxIndex = textLower.length - queryLower.length;
|
|
1566
|
+
if (maxIndex < 0) return null;
|
|
1567
|
+
for (let i = 0; i <= maxIndex; i++) if (textLower.startsWith(queryLower, i) && isWordBoundary(textLower, i)) return i;
|
|
1568
|
+
return null;
|
|
1569
|
+
}
|
|
1570
|
+
/**
|
|
1571
|
+
* Fuzzy match with pre-lowercased inputs (avoids toLowerCase on every keystroke).
|
|
1572
|
+
* Returns score (lower = better) or null if no match.
|
|
1573
|
+
*/
|
|
1574
|
+
function fuzzyMatchLower(queryLower, textLower) {
|
|
1575
|
+
if (queryLower.length === 0) return 0;
|
|
1576
|
+
if (queryLower.length > textLower.length) return null;
|
|
1577
|
+
let queryIndex = 0;
|
|
1578
|
+
let score = 0;
|
|
1579
|
+
let lastMatchIndex = -1;
|
|
1580
|
+
let consecutiveMatches = 0;
|
|
1581
|
+
for (let i = 0; i < textLower.length && queryIndex < queryLower.length; i++) if (textLower[i] === queryLower[queryIndex]) {
|
|
1582
|
+
const isAtWordBoundary = isWordBoundary(textLower, i);
|
|
1583
|
+
if (lastMatchIndex === i - 1) {
|
|
1584
|
+
consecutiveMatches++;
|
|
1585
|
+
score -= consecutiveMatches * 5;
|
|
1586
|
+
} else {
|
|
1587
|
+
consecutiveMatches = 0;
|
|
1588
|
+
if (lastMatchIndex >= 0) score += (i - lastMatchIndex - 1) * 2;
|
|
1589
|
+
}
|
|
1590
|
+
if (isAtWordBoundary) score -= 10;
|
|
1591
|
+
score += i * .1;
|
|
1592
|
+
lastMatchIndex = i;
|
|
1593
|
+
queryIndex++;
|
|
1594
|
+
}
|
|
1595
|
+
return queryIndex < queryLower.length ? null : score;
|
|
1596
|
+
}
|
|
1597
|
+
/**
|
|
1598
|
+
* Filter items using pre-lowercased searchTextLower field.
|
|
1599
|
+
* Supports space-separated tokens (all must match).
|
|
1600
|
+
*/
|
|
1601
|
+
function fuzzyFilterLower(items, queryLower) {
|
|
1602
|
+
const trimmed = queryLower.trim();
|
|
1603
|
+
if (!trimmed) return items;
|
|
1604
|
+
const tokens = trimmed.split(/\s+/).filter((t) => t.length > 0);
|
|
1605
|
+
if (tokens.length === 0) return items;
|
|
1606
|
+
const results = [];
|
|
1607
|
+
for (const item of items) {
|
|
1608
|
+
const text = item.searchTextLower ?? "";
|
|
1609
|
+
let totalScore = 0;
|
|
1610
|
+
let allMatch = true;
|
|
1611
|
+
for (const token of tokens) {
|
|
1612
|
+
const score = fuzzyMatchLower(token, text);
|
|
1613
|
+
if (score !== null) totalScore += score;
|
|
1614
|
+
else {
|
|
1615
|
+
allMatch = false;
|
|
1616
|
+
break;
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
if (allMatch) results.push({
|
|
1620
|
+
item,
|
|
1621
|
+
score: totalScore
|
|
1622
|
+
});
|
|
1623
|
+
}
|
|
1624
|
+
results.sort((a, b) => a.score - b.score);
|
|
1625
|
+
return results.map((r) => r.item);
|
|
1626
|
+
}
|
|
1627
|
+
/**
|
|
1628
|
+
* Prepare items for fuzzy filtering by pre-computing lowercase search text.
|
|
1629
|
+
*/
|
|
1630
|
+
function prepareSearchItems(items) {
|
|
1631
|
+
return items.map((item) => {
|
|
1632
|
+
const parts = [];
|
|
1633
|
+
if (item.label) parts.push(item.label);
|
|
1634
|
+
if (item.description) parts.push(item.description);
|
|
1635
|
+
if (item.searchText) parts.push(item.searchText);
|
|
1636
|
+
return {
|
|
1637
|
+
...item,
|
|
1638
|
+
searchTextLower: normalizeLowercaseStringOrEmpty(parts.join(" "))
|
|
1639
|
+
};
|
|
1640
|
+
});
|
|
1641
|
+
}
|
|
1642
|
+
//#endregion
|
|
1643
|
+
//#region src/tui/components/filterable-select-list.ts
|
|
1644
|
+
/**
|
|
1645
|
+
* Combines text input filtering with a select list.
|
|
1646
|
+
* User types to filter, arrows/j/k to navigate, Enter to select, Escape to clear/cancel.
|
|
1647
|
+
*/
|
|
1648
|
+
var FilterableSelectList = class {
|
|
1649
|
+
constructor(items, maxVisible, theme) {
|
|
1650
|
+
this.filterText = "";
|
|
1651
|
+
this.allItems = prepareSearchItems(items);
|
|
1652
|
+
this.maxVisible = maxVisible;
|
|
1653
|
+
this.theme = theme;
|
|
1654
|
+
this.input = new Input();
|
|
1655
|
+
this.selectList = new SelectList(this.allItems, maxVisible, theme);
|
|
1656
|
+
}
|
|
1657
|
+
applyFilter() {
|
|
1658
|
+
const queryLower = normalizeLowercaseStringOrEmpty(this.filterText);
|
|
1659
|
+
if (!queryLower.trim()) {
|
|
1660
|
+
this.selectList = new SelectList(this.allItems, this.maxVisible, this.theme);
|
|
1661
|
+
return;
|
|
1662
|
+
}
|
|
1663
|
+
const filtered = fuzzyFilterLower(this.allItems, queryLower);
|
|
1664
|
+
this.selectList = new SelectList(filtered, this.maxVisible, this.theme);
|
|
1665
|
+
}
|
|
1666
|
+
invalidate() {
|
|
1667
|
+
this.input.invalidate();
|
|
1668
|
+
this.selectList.invalidate();
|
|
1669
|
+
}
|
|
1670
|
+
render(width) {
|
|
1671
|
+
const lines = [];
|
|
1672
|
+
const filterLabel = this.theme.filterLabel("Filter: ");
|
|
1673
|
+
const inputText = this.input.render(width - 8)[0] ?? "";
|
|
1674
|
+
lines.push(filterLabel + inputText);
|
|
1675
|
+
lines.push(chalk.dim("─".repeat(Math.max(0, width))));
|
|
1676
|
+
const listLines = this.selectList.render(width);
|
|
1677
|
+
lines.push(...listLines);
|
|
1678
|
+
return lines;
|
|
1679
|
+
}
|
|
1680
|
+
handleInput(keyData) {
|
|
1681
|
+
const allowVimNav = !this.filterText.trim();
|
|
1682
|
+
if (matchesKey(keyData, "up") || matchesKey(keyData, "ctrl+p") || allowVimNav && keyData === "k") {
|
|
1683
|
+
this.selectList.handleInput("\x1B[A");
|
|
1684
|
+
return;
|
|
1685
|
+
}
|
|
1686
|
+
if (matchesKey(keyData, "down") || matchesKey(keyData, "ctrl+n") || allowVimNav && keyData === "j") {
|
|
1687
|
+
this.selectList.handleInput("\x1B[B");
|
|
1688
|
+
return;
|
|
1689
|
+
}
|
|
1690
|
+
if (matchesKey(keyData, "enter")) {
|
|
1691
|
+
const selected = this.selectList.getSelectedItem();
|
|
1692
|
+
if (selected) this.onSelect?.(selected);
|
|
1693
|
+
return;
|
|
1694
|
+
}
|
|
1695
|
+
if (matchesKey(keyData, "escape") || keyData === "") {
|
|
1696
|
+
if (this.filterText) {
|
|
1697
|
+
this.filterText = "";
|
|
1698
|
+
this.input.setValue("");
|
|
1699
|
+
this.applyFilter();
|
|
1700
|
+
} else this.onCancel?.();
|
|
1701
|
+
return;
|
|
1702
|
+
}
|
|
1703
|
+
const prevValue = this.input.getValue();
|
|
1704
|
+
this.input.handleInput(keyData);
|
|
1705
|
+
const newValue = this.input.getValue();
|
|
1706
|
+
if (newValue !== prevValue) {
|
|
1707
|
+
this.filterText = newValue;
|
|
1708
|
+
this.applyFilter();
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
getSelectedItem() {
|
|
1712
|
+
return this.selectList.getSelectedItem();
|
|
1713
|
+
}
|
|
1714
|
+
getFilterText() {
|
|
1715
|
+
return this.filterText;
|
|
1716
|
+
}
|
|
1717
|
+
};
|
|
1718
|
+
//#endregion
|
|
1719
|
+
//#region src/tui/components/searchable-select-list.ts
|
|
1720
|
+
const ANSI_SGR_REGEX = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g");
|
|
1721
|
+
/**
|
|
1722
|
+
* A select list with a search input at the top for fuzzy filtering.
|
|
1723
|
+
*/
|
|
1724
|
+
var SearchableSelectList = class SearchableSelectList {
|
|
1725
|
+
static {
|
|
1726
|
+
this.DESCRIPTION_LAYOUT_MIN_WIDTH = 40;
|
|
1727
|
+
}
|
|
1728
|
+
static {
|
|
1729
|
+
this.DESCRIPTION_MIN_WIDTH = 12;
|
|
1730
|
+
}
|
|
1731
|
+
static {
|
|
1732
|
+
this.DESCRIPTION_SPACING_WIDTH = 2;
|
|
1733
|
+
}
|
|
1734
|
+
static {
|
|
1735
|
+
this.RIGHT_MARGIN_WIDTH = 2;
|
|
1736
|
+
}
|
|
1737
|
+
constructor(items, maxVisible, theme) {
|
|
1738
|
+
this.selectedIndex = 0;
|
|
1739
|
+
this.regexCache = /* @__PURE__ */ new Map();
|
|
1740
|
+
this.compareByScore = (a, b) => {
|
|
1741
|
+
if (a.tier !== b.tier) return a.tier - b.tier;
|
|
1742
|
+
if (a.score !== b.score) return a.score - b.score;
|
|
1743
|
+
return this.getItemLabel(a.item).localeCompare(this.getItemLabel(b.item));
|
|
1744
|
+
};
|
|
1745
|
+
this.items = items;
|
|
1746
|
+
this.filteredItems = items;
|
|
1747
|
+
this.maxVisible = maxVisible;
|
|
1748
|
+
this.theme = theme;
|
|
1749
|
+
this.searchInput = new Input();
|
|
1750
|
+
}
|
|
1751
|
+
getCachedRegex(pattern) {
|
|
1752
|
+
let regex = this.regexCache.get(pattern);
|
|
1753
|
+
if (!regex) {
|
|
1754
|
+
regex = new RegExp(this.escapeRegex(pattern), "gi");
|
|
1755
|
+
this.regexCache.set(pattern, regex);
|
|
1756
|
+
}
|
|
1757
|
+
return regex;
|
|
1758
|
+
}
|
|
1759
|
+
updateFilter() {
|
|
1760
|
+
const query = this.searchInput.getValue().trim();
|
|
1761
|
+
if (!query) this.filteredItems = this.items;
|
|
1762
|
+
else this.filteredItems = this.smartFilter(query);
|
|
1763
|
+
this.selectedIndex = 0;
|
|
1764
|
+
this.notifySelectionChange();
|
|
1765
|
+
}
|
|
1766
|
+
/**
|
|
1767
|
+
* Smart filtering that prioritizes:
|
|
1768
|
+
* 1. Exact substring match in label (highest priority)
|
|
1769
|
+
* 2. Word-boundary prefix match in label
|
|
1770
|
+
* 3. Exact substring in description
|
|
1771
|
+
* 4. Fuzzy match (lowest priority)
|
|
1772
|
+
*/
|
|
1773
|
+
smartFilter(query) {
|
|
1774
|
+
const q = normalizeLowercaseStringOrEmpty(query);
|
|
1775
|
+
const scoredItems = [];
|
|
1776
|
+
const fuzzyCandidates = [];
|
|
1777
|
+
for (const item of this.items) {
|
|
1778
|
+
const rawLabel = this.getItemLabel(item);
|
|
1779
|
+
const rawDesc = item.description ?? "";
|
|
1780
|
+
const label = normalizeLowercaseStringOrEmpty(stripAnsi$1(rawLabel));
|
|
1781
|
+
const desc = normalizeLowercaseStringOrEmpty(stripAnsi$1(rawDesc));
|
|
1782
|
+
const labelIndex = label.indexOf(q);
|
|
1783
|
+
if (labelIndex !== -1) {
|
|
1784
|
+
scoredItems.push({
|
|
1785
|
+
item,
|
|
1786
|
+
tier: 0,
|
|
1787
|
+
score: labelIndex
|
|
1788
|
+
});
|
|
1789
|
+
continue;
|
|
1790
|
+
}
|
|
1791
|
+
const wordBoundaryIndex = findWordBoundaryIndex(label, q);
|
|
1792
|
+
if (wordBoundaryIndex !== null) {
|
|
1793
|
+
scoredItems.push({
|
|
1794
|
+
item,
|
|
1795
|
+
tier: 1,
|
|
1796
|
+
score: wordBoundaryIndex
|
|
1797
|
+
});
|
|
1798
|
+
continue;
|
|
1799
|
+
}
|
|
1800
|
+
const descIndex = desc.indexOf(q);
|
|
1801
|
+
if (descIndex !== -1) {
|
|
1802
|
+
scoredItems.push({
|
|
1803
|
+
item,
|
|
1804
|
+
tier: 2,
|
|
1805
|
+
score: descIndex
|
|
1806
|
+
});
|
|
1807
|
+
continue;
|
|
1808
|
+
}
|
|
1809
|
+
const searchText = item.searchText ?? "";
|
|
1810
|
+
fuzzyCandidates.push({
|
|
1811
|
+
item,
|
|
1812
|
+
searchTextLower: normalizeLowercaseStringOrEmpty([
|
|
1813
|
+
rawLabel,
|
|
1814
|
+
rawDesc,
|
|
1815
|
+
searchText
|
|
1816
|
+
].map((value) => stripAnsi$1(value)).filter(Boolean).join(" "))
|
|
1817
|
+
});
|
|
1818
|
+
}
|
|
1819
|
+
scoredItems.sort(this.compareByScore);
|
|
1820
|
+
const fuzzyMatches = fuzzyFilterLower(fuzzyCandidates, q);
|
|
1821
|
+
return [...scoredItems.map((s) => s.item), ...fuzzyMatches.map((entry) => entry.item)];
|
|
1822
|
+
}
|
|
1823
|
+
escapeRegex(str) {
|
|
1824
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1825
|
+
}
|
|
1826
|
+
getItemLabel(item) {
|
|
1827
|
+
return item.label || item.value;
|
|
1828
|
+
}
|
|
1829
|
+
splitAnsiParts(text) {
|
|
1830
|
+
const parts = [];
|
|
1831
|
+
ANSI_SGR_REGEX.lastIndex = 0;
|
|
1832
|
+
let lastIndex = 0;
|
|
1833
|
+
let match;
|
|
1834
|
+
while ((match = ANSI_SGR_REGEX.exec(text)) !== null) {
|
|
1835
|
+
if (match.index > lastIndex) parts.push({
|
|
1836
|
+
text: text.slice(lastIndex, match.index),
|
|
1837
|
+
isAnsi: false
|
|
1838
|
+
});
|
|
1839
|
+
parts.push({
|
|
1840
|
+
text: match[0],
|
|
1841
|
+
isAnsi: true
|
|
1842
|
+
});
|
|
1843
|
+
lastIndex = match.index + match[0].length;
|
|
1844
|
+
}
|
|
1845
|
+
if (lastIndex < text.length) parts.push({
|
|
1846
|
+
text: text.slice(lastIndex),
|
|
1847
|
+
isAnsi: false
|
|
1848
|
+
});
|
|
1849
|
+
return parts;
|
|
1850
|
+
}
|
|
1851
|
+
highlightMatch(text, query) {
|
|
1852
|
+
const tokens = query.trim().split(/\s+/).map((token) => normalizeLowercaseStringOrEmpty(token)).filter((token) => token.length > 0);
|
|
1853
|
+
if (tokens.length === 0) return text;
|
|
1854
|
+
const uniqueTokens = Array.from(new Set(tokens)).toSorted((a, b) => b.length - a.length);
|
|
1855
|
+
let parts = this.splitAnsiParts(text);
|
|
1856
|
+
for (const token of uniqueTokens) {
|
|
1857
|
+
const regex = this.getCachedRegex(token);
|
|
1858
|
+
const nextParts = [];
|
|
1859
|
+
for (const part of parts) {
|
|
1860
|
+
if (part.isAnsi) {
|
|
1861
|
+
nextParts.push(part);
|
|
1862
|
+
continue;
|
|
1863
|
+
}
|
|
1864
|
+
regex.lastIndex = 0;
|
|
1865
|
+
const replaced = part.text.replace(regex, (match) => this.theme.matchHighlight(match));
|
|
1866
|
+
if (replaced === part.text) {
|
|
1867
|
+
nextParts.push(part);
|
|
1868
|
+
continue;
|
|
1869
|
+
}
|
|
1870
|
+
nextParts.push(...this.splitAnsiParts(replaced));
|
|
1871
|
+
}
|
|
1872
|
+
parts = nextParts;
|
|
1873
|
+
}
|
|
1874
|
+
return parts.map((part) => part.text).join("");
|
|
1875
|
+
}
|
|
1876
|
+
setSelectedIndex(index) {
|
|
1877
|
+
this.selectedIndex = Math.max(0, Math.min(index, this.filteredItems.length - 1));
|
|
1878
|
+
}
|
|
1879
|
+
invalidate() {
|
|
1880
|
+
this.searchInput.invalidate();
|
|
1881
|
+
}
|
|
1882
|
+
render(width) {
|
|
1883
|
+
const lines = [];
|
|
1884
|
+
const prompt = this.theme.searchPrompt("search: ");
|
|
1885
|
+
const inputWidth = Math.max(1, width - visibleWidth(prompt));
|
|
1886
|
+
const inputText = this.searchInput.render(inputWidth)[0] ?? "";
|
|
1887
|
+
lines.push(`${prompt}${this.theme.searchInput(inputText)}`);
|
|
1888
|
+
lines.push("");
|
|
1889
|
+
const query = this.searchInput.getValue().trim();
|
|
1890
|
+
if (this.filteredItems.length === 0) {
|
|
1891
|
+
lines.push(this.theme.noMatch(" No matches"));
|
|
1892
|
+
return lines;
|
|
1893
|
+
}
|
|
1894
|
+
const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(this.maxVisible / 2), this.filteredItems.length - this.maxVisible));
|
|
1895
|
+
const endIndex = Math.min(startIndex + this.maxVisible, this.filteredItems.length);
|
|
1896
|
+
for (let i = startIndex; i < endIndex; i++) {
|
|
1897
|
+
const item = this.filteredItems[i];
|
|
1898
|
+
if (!item) continue;
|
|
1899
|
+
const isSelected = i === this.selectedIndex;
|
|
1900
|
+
lines.push(this.renderItemLine(item, isSelected, width, query));
|
|
1901
|
+
}
|
|
1902
|
+
if (this.filteredItems.length > this.maxVisible) {
|
|
1903
|
+
const scrollInfo = `${this.selectedIndex + 1}/${this.filteredItems.length}`;
|
|
1904
|
+
lines.push(this.theme.scrollInfo(` ${scrollInfo}`));
|
|
1905
|
+
}
|
|
1906
|
+
return lines;
|
|
1907
|
+
}
|
|
1908
|
+
renderItemLine(item, isSelected, width, query) {
|
|
1909
|
+
const prefix = isSelected ? "→ " : " ";
|
|
1910
|
+
const prefixWidth = prefix.length;
|
|
1911
|
+
const displayValue = this.getItemLabel(item);
|
|
1912
|
+
const description = item.description;
|
|
1913
|
+
if (description) {
|
|
1914
|
+
const descriptionLayout = this.getDescriptionLayout(width, prefixWidth);
|
|
1915
|
+
if (descriptionLayout) {
|
|
1916
|
+
const truncatedValue = truncateToWidth(displayValue, descriptionLayout.maxValueWidth, "");
|
|
1917
|
+
const valueText = this.highlightMatch(truncatedValue, query);
|
|
1918
|
+
const usedByValue = visibleWidth(valueText);
|
|
1919
|
+
const descriptionWidth = descriptionLayout.availableWidth - usedByValue - descriptionLayout.spacingWidth;
|
|
1920
|
+
if (descriptionWidth >= SearchableSelectList.DESCRIPTION_MIN_WIDTH) {
|
|
1921
|
+
const spacing = " ".repeat(descriptionLayout.spacingWidth);
|
|
1922
|
+
const truncatedDesc = truncateToWidth(description, descriptionWidth, "");
|
|
1923
|
+
const highlightedDesc = this.highlightMatch(truncatedDesc, query);
|
|
1924
|
+
const line = `${prefix}${valueText}${spacing}${isSelected ? highlightedDesc : this.theme.description(highlightedDesc)}`;
|
|
1925
|
+
return isSelected ? this.theme.selectedText(line) : line;
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
const truncatedValue = truncateToWidth(displayValue, width - prefixWidth - 2, "");
|
|
1930
|
+
const line = `${prefix}${this.highlightMatch(truncatedValue, query)}`;
|
|
1931
|
+
return isSelected ? this.theme.selectedText(line) : line;
|
|
1932
|
+
}
|
|
1933
|
+
getDescriptionLayout(width, prefixWidth) {
|
|
1934
|
+
if (width <= SearchableSelectList.DESCRIPTION_LAYOUT_MIN_WIDTH) return null;
|
|
1935
|
+
const availableWidth = Math.max(1, width - prefixWidth - SearchableSelectList.RIGHT_MARGIN_WIDTH);
|
|
1936
|
+
const maxValueWidth = availableWidth - SearchableSelectList.DESCRIPTION_MIN_WIDTH - SearchableSelectList.DESCRIPTION_SPACING_WIDTH;
|
|
1937
|
+
if (maxValueWidth < 1) return null;
|
|
1938
|
+
return {
|
|
1939
|
+
availableWidth,
|
|
1940
|
+
maxValueWidth,
|
|
1941
|
+
spacingWidth: SearchableSelectList.DESCRIPTION_SPACING_WIDTH
|
|
1942
|
+
};
|
|
1943
|
+
}
|
|
1944
|
+
handleInput(keyData) {
|
|
1945
|
+
if (isKeyRelease(keyData)) return;
|
|
1946
|
+
if (matchesKey(keyData, "up") || matchesKey(keyData, "ctrl+p")) {
|
|
1947
|
+
this.selectedIndex = Math.max(0, this.selectedIndex - 1);
|
|
1948
|
+
this.notifySelectionChange();
|
|
1949
|
+
return;
|
|
1950
|
+
}
|
|
1951
|
+
if (matchesKey(keyData, "down") || matchesKey(keyData, "ctrl+n")) {
|
|
1952
|
+
this.selectedIndex = Math.min(this.filteredItems.length - 1, this.selectedIndex + 1);
|
|
1953
|
+
this.notifySelectionChange();
|
|
1954
|
+
return;
|
|
1955
|
+
}
|
|
1956
|
+
if (matchesKey(keyData, "enter")) {
|
|
1957
|
+
const item = this.filteredItems[this.selectedIndex];
|
|
1958
|
+
if (item && this.onSelect) this.onSelect(item);
|
|
1959
|
+
return;
|
|
1960
|
+
}
|
|
1961
|
+
if (matchesKey(keyData, "escape") || keyData === "") {
|
|
1962
|
+
if (this.onCancel) this.onCancel();
|
|
1963
|
+
return;
|
|
1964
|
+
}
|
|
1965
|
+
const prevValue = this.searchInput.getValue();
|
|
1966
|
+
this.searchInput.handleInput(keyData);
|
|
1967
|
+
if (prevValue !== this.searchInput.getValue()) this.updateFilter();
|
|
1968
|
+
}
|
|
1969
|
+
notifySelectionChange() {
|
|
1970
|
+
const item = this.filteredItems[this.selectedIndex];
|
|
1971
|
+
if (item && this.onSelectionChange) this.onSelectionChange(item);
|
|
1972
|
+
}
|
|
1973
|
+
getSelectedItem() {
|
|
1974
|
+
return this.filteredItems[this.selectedIndex] ?? null;
|
|
1975
|
+
}
|
|
1976
|
+
};
|
|
1977
|
+
//#endregion
|
|
1978
|
+
//#region src/tui/components/selectors.ts
|
|
1979
|
+
function createSearchableSelectList(items, maxVisible = 7) {
|
|
1980
|
+
return new SearchableSelectList(items, maxVisible, searchableSelectListTheme);
|
|
1981
|
+
}
|
|
1982
|
+
function createFilterableSelectList(items, maxVisible = 7) {
|
|
1983
|
+
return new FilterableSelectList(items, maxVisible, filterableSelectListTheme);
|
|
1984
|
+
}
|
|
1985
|
+
function createSettingsList(items, onChange, onCancel, maxVisible = 7) {
|
|
1986
|
+
return new SettingsList(items, maxVisible, settingsListTheme, onChange, onCancel);
|
|
1987
|
+
}
|
|
1988
|
+
//#endregion
|
|
1989
|
+
//#region src/tui/tui-session-list-policy.ts
|
|
1990
|
+
const TUI_RECENT_SESSIONS_ACTIVE_MINUTES = 10080;
|
|
1991
|
+
//#endregion
|
|
1992
|
+
//#region src/tui/tui-status-summary.ts
|
|
1993
|
+
function formatStatusSummary(summary) {
|
|
1994
|
+
const lines = [];
|
|
1995
|
+
lines.push("Gateway status");
|
|
1996
|
+
if (summary.runtimeVersion) lines.push(`Version: ${summary.runtimeVersion}`);
|
|
1997
|
+
if (!summary.linkChannel) lines.push("Link channel: unknown");
|
|
1998
|
+
else {
|
|
1999
|
+
const linkLabel = summary.linkChannel.label ?? "Link channel";
|
|
2000
|
+
const linked = summary.linkChannel.linked === true;
|
|
2001
|
+
const authAge = linked && typeof summary.linkChannel.authAgeMs === "number" ? ` (last refreshed ${formatTimeAgo(summary.linkChannel.authAgeMs)})` : "";
|
|
2002
|
+
lines.push(`${linkLabel}: ${linked ? "linked" : "not linked"}${authAge}`);
|
|
2003
|
+
}
|
|
2004
|
+
const providerSummary = Array.isArray(summary.providerSummary) ? summary.providerSummary : [];
|
|
2005
|
+
if (providerSummary.length > 0) {
|
|
2006
|
+
lines.push("");
|
|
2007
|
+
lines.push("System:");
|
|
2008
|
+
for (const line of providerSummary) lines.push(` ${line}`);
|
|
2009
|
+
}
|
|
2010
|
+
const heartbeatAgents = summary.heartbeat?.agents ?? [];
|
|
2011
|
+
if (heartbeatAgents.length > 0) {
|
|
2012
|
+
const heartbeatParts = heartbeatAgents.map((agent) => {
|
|
2013
|
+
const agentId = agent.agentId ?? "unknown";
|
|
2014
|
+
if (!agent.enabled || !agent.everyMs) return `disabled (${agentId})`;
|
|
2015
|
+
return `${agent.every ?? "unknown"} (${agentId})`;
|
|
2016
|
+
});
|
|
2017
|
+
lines.push("");
|
|
2018
|
+
lines.push(`Heartbeat: ${heartbeatParts.join(", ")}`);
|
|
2019
|
+
}
|
|
2020
|
+
const sessionPaths = summary.sessions?.paths ?? [];
|
|
2021
|
+
if (sessionPaths.length === 1) lines.push(`Session store: ${sessionPaths[0]}`);
|
|
2022
|
+
else if (sessionPaths.length > 1) lines.push(`Session stores: ${sessionPaths.length}`);
|
|
2023
|
+
const defaults = summary.sessions?.defaults;
|
|
2024
|
+
const defaultModel = defaults?.model ?? "unknown";
|
|
2025
|
+
const defaultCtx = typeof defaults?.contextTokens === "number" ? ` (${formatTokenCount(defaults.contextTokens)} ctx)` : "";
|
|
2026
|
+
lines.push(`Default model: ${defaultModel}${defaultCtx}`);
|
|
2027
|
+
const sessionCount = summary.sessions?.count ?? 0;
|
|
2028
|
+
lines.push(`Active sessions: ${sessionCount}`);
|
|
2029
|
+
const recent = Array.isArray(summary.sessions?.recent) ? summary.sessions?.recent : [];
|
|
2030
|
+
if (recent.length > 0) {
|
|
2031
|
+
lines.push("Recent sessions:");
|
|
2032
|
+
for (const entry of recent) {
|
|
2033
|
+
const ageLabel = typeof entry.age === "number" ? formatTimeAgo(entry.age) : "no activity";
|
|
2034
|
+
const model = entry.model ?? "unknown";
|
|
2035
|
+
const usage = formatContextUsageLine({
|
|
2036
|
+
total: entry.totalTokens ?? null,
|
|
2037
|
+
context: entry.contextTokens ?? null,
|
|
2038
|
+
remaining: entry.remainingTokens ?? null,
|
|
2039
|
+
percent: entry.percentUsed ?? null
|
|
2040
|
+
});
|
|
2041
|
+
const flags = entry.flags?.length ? ` | flags: ${entry.flags.join(", ")}` : "";
|
|
2042
|
+
lines.push(`- ${entry.key}${entry.kind ? ` [${entry.kind}]` : ""} | ${ageLabel} | model ${model} | ${usage}${flags}`);
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
const queued = Array.isArray(summary.queuedSystemEvents) ? summary.queuedSystemEvents : [];
|
|
2046
|
+
if (queued.length > 0) {
|
|
2047
|
+
const preview = queued.slice(0, 3).join(" | ");
|
|
2048
|
+
lines.push(`Queued system events (${queued.length}): ${preview}`);
|
|
2049
|
+
}
|
|
2050
|
+
return lines;
|
|
2051
|
+
}
|
|
2052
|
+
//#endregion
|
|
2053
|
+
//#region src/tui/tui-command-handlers.ts
|
|
2054
|
+
function isBtwCommand(text) {
|
|
2055
|
+
return /^\/(?:btw|side)(?::|\s|$)/i.test(text.trim());
|
|
2056
|
+
}
|
|
2057
|
+
function createCommandHandlers(context) {
|
|
2058
|
+
const { client, chatLog, tui, opts, state, deliverDefault, openOverlay, closeOverlay, refreshSessionInfo, loadHistory, setSession, refreshAgents, abortActive, setActivityStatus, formatSessionKey, applySessionInfoFromPatch, noteLocalBtwRunId, forgetLocalRunId, forgetLocalBtwRunId, runAuthFlow, requestExit } = context;
|
|
2059
|
+
const setAgent = async (id) => {
|
|
2060
|
+
state.currentAgentId = normalizeAgentId(id);
|
|
2061
|
+
await setSession("");
|
|
2062
|
+
chatLog.addSystem(`agent set to ${state.currentAgentId}; use /crestodian to return`);
|
|
2063
|
+
};
|
|
2064
|
+
const closeOverlayAndRender = () => {
|
|
2065
|
+
closeOverlay();
|
|
2066
|
+
tui.requestRender();
|
|
2067
|
+
};
|
|
2068
|
+
const openSelector = (selector, onSelect) => {
|
|
2069
|
+
selector.onSelect = (item) => {
|
|
2070
|
+
(async () => {
|
|
2071
|
+
await onSelect(item.value);
|
|
2072
|
+
closeOverlayAndRender();
|
|
2073
|
+
})();
|
|
2074
|
+
};
|
|
2075
|
+
selector.onCancel = closeOverlayAndRender;
|
|
2076
|
+
openOverlay(selector);
|
|
2077
|
+
tui.requestRender();
|
|
2078
|
+
};
|
|
2079
|
+
const openModelSelector = async () => {
|
|
2080
|
+
try {
|
|
2081
|
+
const models = await client.listModels();
|
|
2082
|
+
if (models.length === 0) {
|
|
2083
|
+
chatLog.addSystem("no models available");
|
|
2084
|
+
tui.requestRender();
|
|
2085
|
+
return;
|
|
2086
|
+
}
|
|
2087
|
+
openSelector(createSearchableSelectList(models.map((model) => {
|
|
2088
|
+
const ref = modelKey(model.provider, model.id);
|
|
2089
|
+
return {
|
|
2090
|
+
value: ref,
|
|
2091
|
+
label: ref,
|
|
2092
|
+
description: model.name && model.name !== model.id ? model.name : ""
|
|
2093
|
+
};
|
|
2094
|
+
}), 9), async (value) => {
|
|
2095
|
+
try {
|
|
2096
|
+
const result = await client.patchSession({
|
|
2097
|
+
key: state.currentSessionKey,
|
|
2098
|
+
model: value
|
|
2099
|
+
});
|
|
2100
|
+
chatLog.addSystem(`model set to ${value}`);
|
|
2101
|
+
applySessionInfoFromPatch(result);
|
|
2102
|
+
await refreshSessionInfo();
|
|
2103
|
+
} catch (err) {
|
|
2104
|
+
chatLog.addSystem(`model set failed: ${String(err)}`);
|
|
2105
|
+
}
|
|
2106
|
+
});
|
|
2107
|
+
} catch (err) {
|
|
2108
|
+
chatLog.addSystem(`model list failed: ${String(err)}`);
|
|
2109
|
+
tui.requestRender();
|
|
2110
|
+
}
|
|
2111
|
+
};
|
|
2112
|
+
const openAgentSelector = async () => {
|
|
2113
|
+
await refreshAgents();
|
|
2114
|
+
if (state.agents.length === 0) {
|
|
2115
|
+
chatLog.addSystem("no agents found");
|
|
2116
|
+
tui.requestRender();
|
|
2117
|
+
return;
|
|
2118
|
+
}
|
|
2119
|
+
openSelector(createSearchableSelectList(state.agents.map((agent) => ({
|
|
2120
|
+
value: agent.id,
|
|
2121
|
+
label: agent.name ? `${agent.id} (${agent.name})` : agent.id,
|
|
2122
|
+
description: agent.id === state.agentDefaultId ? "default" : ""
|
|
2123
|
+
})), 9), async (value) => {
|
|
2124
|
+
await setAgent(value);
|
|
2125
|
+
});
|
|
2126
|
+
};
|
|
2127
|
+
const openContextModeSelector = () => {
|
|
2128
|
+
openSelector(createSearchableSelectList([
|
|
2129
|
+
{
|
|
2130
|
+
value: "list",
|
|
2131
|
+
label: "list",
|
|
2132
|
+
description: "Short context breakdown"
|
|
2133
|
+
},
|
|
2134
|
+
{
|
|
2135
|
+
value: "detail",
|
|
2136
|
+
label: "detail",
|
|
2137
|
+
description: "Per-file, per-tool, per-skill, and system prompt size"
|
|
2138
|
+
},
|
|
2139
|
+
{
|
|
2140
|
+
value: "json",
|
|
2141
|
+
label: "json",
|
|
2142
|
+
description: "Machine-readable context report"
|
|
2143
|
+
}
|
|
2144
|
+
], 9), async (value) => {
|
|
2145
|
+
await sendMessage(`/context ${value}`);
|
|
2146
|
+
});
|
|
2147
|
+
};
|
|
2148
|
+
const openSessionSelector = async () => {
|
|
2149
|
+
try {
|
|
2150
|
+
openSelector(createFilterableSelectList((await client.listSessions({
|
|
2151
|
+
limit: 50,
|
|
2152
|
+
activeMinutes: TUI_RECENT_SESSIONS_ACTIVE_MINUTES,
|
|
2153
|
+
includeGlobal: false,
|
|
2154
|
+
includeUnknown: false,
|
|
2155
|
+
includeDerivedTitles: true,
|
|
2156
|
+
includeLastMessage: true,
|
|
2157
|
+
agentId: state.currentAgentId
|
|
2158
|
+
})).sessions.map((session) => {
|
|
2159
|
+
const title = session.derivedTitle ?? session.displayName;
|
|
2160
|
+
const formattedKey = formatSessionKey(session.key);
|
|
2161
|
+
const label = title && title !== formattedKey ? `${title} (${formattedKey})` : formattedKey;
|
|
2162
|
+
const timePart = session.updatedAt ? formatRelativeTimestamp(session.updatedAt, {
|
|
2163
|
+
dateFallback: true,
|
|
2164
|
+
fallback: ""
|
|
2165
|
+
}) : "";
|
|
2166
|
+
const preview = session.lastMessagePreview?.replace(/\s+/g, " ").trim();
|
|
2167
|
+
const description = timePart && preview ? `${timePart} · ${preview}` : preview ?? timePart;
|
|
2168
|
+
return {
|
|
2169
|
+
value: session.key,
|
|
2170
|
+
label,
|
|
2171
|
+
description,
|
|
2172
|
+
searchText: [
|
|
2173
|
+
session.displayName,
|
|
2174
|
+
session.label,
|
|
2175
|
+
session.subject,
|
|
2176
|
+
session.sessionId,
|
|
2177
|
+
session.key,
|
|
2178
|
+
session.lastMessagePreview
|
|
2179
|
+
].filter(Boolean).join(" ")
|
|
2180
|
+
};
|
|
2181
|
+
}), 9), async (value) => {
|
|
2182
|
+
await setSession(value);
|
|
2183
|
+
});
|
|
2184
|
+
} catch (err) {
|
|
2185
|
+
chatLog.addSystem(`sessions list failed: ${String(err)}`);
|
|
2186
|
+
tui.requestRender();
|
|
2187
|
+
}
|
|
2188
|
+
};
|
|
2189
|
+
const openSettings = () => {
|
|
2190
|
+
openOverlay(createSettingsList([{
|
|
2191
|
+
id: "tools",
|
|
2192
|
+
label: "Tool output",
|
|
2193
|
+
currentValue: state.toolsExpanded ? "expanded" : "collapsed",
|
|
2194
|
+
values: ["collapsed", "expanded"]
|
|
2195
|
+
}, {
|
|
2196
|
+
id: "thinking",
|
|
2197
|
+
label: "Show thinking",
|
|
2198
|
+
currentValue: state.showThinking ? "on" : "off",
|
|
2199
|
+
values: ["off", "on"]
|
|
2200
|
+
}], (id, value) => {
|
|
2201
|
+
if (id === "tools") {
|
|
2202
|
+
state.toolsExpanded = value === "expanded";
|
|
2203
|
+
chatLog.setToolsExpanded(state.toolsExpanded);
|
|
2204
|
+
}
|
|
2205
|
+
if (id === "thinking") {
|
|
2206
|
+
state.showThinking = value === "on";
|
|
2207
|
+
loadHistory();
|
|
2208
|
+
}
|
|
2209
|
+
tui.requestRender();
|
|
2210
|
+
}, () => {
|
|
2211
|
+
closeOverlay();
|
|
2212
|
+
tui.requestRender();
|
|
2213
|
+
}));
|
|
2214
|
+
tui.requestRender();
|
|
2215
|
+
};
|
|
2216
|
+
const handleCommand = async (raw) => {
|
|
2217
|
+
const { name, args } = parseCommand(raw);
|
|
2218
|
+
if (!name) return;
|
|
2219
|
+
switch (name) {
|
|
2220
|
+
case "help":
|
|
2221
|
+
chatLog.addSystem(helpText({
|
|
2222
|
+
local: opts.local,
|
|
2223
|
+
provider: state.sessionInfo.modelProvider,
|
|
2224
|
+
model: state.sessionInfo.model
|
|
2225
|
+
}));
|
|
2226
|
+
break;
|
|
2227
|
+
case "auth": {
|
|
2228
|
+
if (!runAuthFlow) {
|
|
2229
|
+
chatLog.addSystem("auth login is only available in local embedded mode");
|
|
2230
|
+
break;
|
|
2231
|
+
}
|
|
2232
|
+
if (state.activeChatRunId || state.pendingOptimisticUserMessage) {
|
|
2233
|
+
chatLog.addSystem("abort the current run before /auth");
|
|
2234
|
+
break;
|
|
2235
|
+
}
|
|
2236
|
+
const provider = args.trim() || state.sessionInfo.modelProvider || void 0;
|
|
2237
|
+
chatLog.addSystem(provider ? `opening auth flow for ${provider}; TUI will resume when it exits` : "opening auth flow; TUI will resume when it exits");
|
|
2238
|
+
tui.requestRender();
|
|
2239
|
+
setActivityStatus("auth");
|
|
2240
|
+
try {
|
|
2241
|
+
const result = await runAuthFlow({ provider });
|
|
2242
|
+
await refreshSessionInfo();
|
|
2243
|
+
if (result.exitCode === 0 && !result.signal) {
|
|
2244
|
+
chatLog.addSystem(provider ? `auth flow finished for ${provider}` : "auth flow finished");
|
|
2245
|
+
setActivityStatus("idle");
|
|
2246
|
+
} else {
|
|
2247
|
+
const failureSuffix = result.signal ? ` (signal ${result.signal})` : typeof result.exitCode === "number" ? ` (exit ${String(result.exitCode)})` : "";
|
|
2248
|
+
chatLog.addSystem(`auth flow failed${failureSuffix}`);
|
|
2249
|
+
setActivityStatus("error");
|
|
2250
|
+
}
|
|
2251
|
+
} catch (err) {
|
|
2252
|
+
chatLog.addSystem(`auth flow failed: ${sanitizeRenderableText(String(err))}`);
|
|
2253
|
+
setActivityStatus("error");
|
|
2254
|
+
}
|
|
2255
|
+
break;
|
|
2256
|
+
}
|
|
2257
|
+
case "gateway-status":
|
|
2258
|
+
try {
|
|
2259
|
+
const status = await client.getGatewayStatus();
|
|
2260
|
+
if (typeof status === "string") {
|
|
2261
|
+
chatLog.addSystem(status);
|
|
2262
|
+
break;
|
|
2263
|
+
}
|
|
2264
|
+
if (status && typeof status === "object") {
|
|
2265
|
+
const lines = formatStatusSummary(status);
|
|
2266
|
+
for (const line of lines) chatLog.addSystem(line);
|
|
2267
|
+
break;
|
|
2268
|
+
}
|
|
2269
|
+
chatLog.addSystem("status: unknown response");
|
|
2270
|
+
} catch (err) {
|
|
2271
|
+
chatLog.addSystem(`status failed: ${String(err)}`);
|
|
2272
|
+
}
|
|
2273
|
+
break;
|
|
2274
|
+
case "agent":
|
|
2275
|
+
if (!args) await openAgentSelector();
|
|
2276
|
+
else await setAgent(args);
|
|
2277
|
+
break;
|
|
2278
|
+
case "agents":
|
|
2279
|
+
await openAgentSelector();
|
|
2280
|
+
break;
|
|
2281
|
+
case "context":
|
|
2282
|
+
if (!args) openContextModeSelector();
|
|
2283
|
+
else await sendMessage(raw);
|
|
2284
|
+
break;
|
|
2285
|
+
case "crestodian":
|
|
2286
|
+
chatLog.addSystem(args ? `returning to Crestodian with request: ${args}` : "returning to Crestodian");
|
|
2287
|
+
requestExit({
|
|
2288
|
+
exitReason: "return-to-crestodian",
|
|
2289
|
+
...args ? { crestodianMessage: args } : {}
|
|
2290
|
+
});
|
|
2291
|
+
break;
|
|
2292
|
+
case "session":
|
|
2293
|
+
if (!args) await openSessionSelector();
|
|
2294
|
+
else await setSession(args);
|
|
2295
|
+
break;
|
|
2296
|
+
case "sessions":
|
|
2297
|
+
await openSessionSelector();
|
|
2298
|
+
break;
|
|
2299
|
+
case "model":
|
|
2300
|
+
if (!args) await openModelSelector();
|
|
2301
|
+
else try {
|
|
2302
|
+
const result = await client.patchSession({
|
|
2303
|
+
key: state.currentSessionKey,
|
|
2304
|
+
model: args
|
|
2305
|
+
});
|
|
2306
|
+
chatLog.addSystem(`model set to ${args}`);
|
|
2307
|
+
applySessionInfoFromPatch(result);
|
|
2308
|
+
await refreshSessionInfo();
|
|
2309
|
+
} catch (err) {
|
|
2310
|
+
chatLog.addSystem(`model set failed: ${String(err)}`);
|
|
2311
|
+
}
|
|
2312
|
+
break;
|
|
2313
|
+
case "models":
|
|
2314
|
+
await openModelSelector();
|
|
2315
|
+
break;
|
|
2316
|
+
case "think":
|
|
2317
|
+
if (!args) {
|
|
2318
|
+
const levels = state.sessionInfo.thinkingLevels?.map((level) => level.label).join("|") || formatThinkingLevels(state.sessionInfo.modelProvider, state.sessionInfo.model, "|");
|
|
2319
|
+
chatLog.addSystem(`usage: /think <${levels}>`);
|
|
2320
|
+
break;
|
|
2321
|
+
}
|
|
2322
|
+
try {
|
|
2323
|
+
const result = await client.patchSession({
|
|
2324
|
+
key: state.currentSessionKey,
|
|
2325
|
+
thinkingLevel: args
|
|
2326
|
+
});
|
|
2327
|
+
chatLog.addSystem(`thinking set to ${args}`);
|
|
2328
|
+
applySessionInfoFromPatch(result);
|
|
2329
|
+
await refreshSessionInfo();
|
|
2330
|
+
} catch (err) {
|
|
2331
|
+
chatLog.addSystem(`think failed: ${String(err)}`);
|
|
2332
|
+
}
|
|
2333
|
+
break;
|
|
2334
|
+
case "verbose":
|
|
2335
|
+
if (!args) {
|
|
2336
|
+
chatLog.addSystem("usage: /verbose <on|off>");
|
|
2337
|
+
break;
|
|
2338
|
+
}
|
|
2339
|
+
try {
|
|
2340
|
+
const result = await client.patchSession({
|
|
2341
|
+
key: state.currentSessionKey,
|
|
2342
|
+
verboseLevel: args
|
|
2343
|
+
});
|
|
2344
|
+
chatLog.addSystem(`verbose set to ${args}`);
|
|
2345
|
+
applySessionInfoFromPatch(result);
|
|
2346
|
+
await loadHistory();
|
|
2347
|
+
} catch (err) {
|
|
2348
|
+
chatLog.addSystem(`verbose failed: ${String(err)}`);
|
|
2349
|
+
}
|
|
2350
|
+
break;
|
|
2351
|
+
case "trace":
|
|
2352
|
+
if (!args) {
|
|
2353
|
+
chatLog.addSystem("usage: /trace <on|off>");
|
|
2354
|
+
break;
|
|
2355
|
+
}
|
|
2356
|
+
try {
|
|
2357
|
+
const result = await client.patchSession({
|
|
2358
|
+
key: state.currentSessionKey,
|
|
2359
|
+
traceLevel: args
|
|
2360
|
+
});
|
|
2361
|
+
chatLog.addSystem(`trace set to ${args}`);
|
|
2362
|
+
applySessionInfoFromPatch(result);
|
|
2363
|
+
await loadHistory();
|
|
2364
|
+
} catch (err) {
|
|
2365
|
+
chatLog.addSystem(`trace failed: ${String(err)}`);
|
|
2366
|
+
}
|
|
2367
|
+
break;
|
|
2368
|
+
case "fast":
|
|
2369
|
+
if (!args || args === "status") {
|
|
2370
|
+
chatLog.addSystem(`fast mode: ${state.sessionInfo.fastMode ? "on" : "off"}`);
|
|
2371
|
+
break;
|
|
2372
|
+
}
|
|
2373
|
+
if (args !== "on" && args !== "off") {
|
|
2374
|
+
chatLog.addSystem("usage: /fast <status|on|off>");
|
|
2375
|
+
break;
|
|
2376
|
+
}
|
|
2377
|
+
try {
|
|
2378
|
+
const result = await client.patchSession({
|
|
2379
|
+
key: state.currentSessionKey,
|
|
2380
|
+
fastMode: args === "on"
|
|
2381
|
+
});
|
|
2382
|
+
chatLog.addSystem(`fast mode ${args === "on" ? "enabled" : "disabled"}`);
|
|
2383
|
+
applySessionInfoFromPatch(result);
|
|
2384
|
+
await refreshSessionInfo();
|
|
2385
|
+
} catch (err) {
|
|
2386
|
+
chatLog.addSystem(`fast failed: ${String(err)}`);
|
|
2387
|
+
}
|
|
2388
|
+
break;
|
|
2389
|
+
case "reasoning":
|
|
2390
|
+
if (!args) {
|
|
2391
|
+
chatLog.addSystem("usage: /reasoning <on|off>");
|
|
2392
|
+
break;
|
|
2393
|
+
}
|
|
2394
|
+
try {
|
|
2395
|
+
const result = await client.patchSession({
|
|
2396
|
+
key: state.currentSessionKey,
|
|
2397
|
+
reasoningLevel: args
|
|
2398
|
+
});
|
|
2399
|
+
chatLog.addSystem(`reasoning set to ${args}`);
|
|
2400
|
+
applySessionInfoFromPatch(result);
|
|
2401
|
+
await refreshSessionInfo();
|
|
2402
|
+
} catch (err) {
|
|
2403
|
+
chatLog.addSystem(`reasoning failed: ${String(err)}`);
|
|
2404
|
+
}
|
|
2405
|
+
break;
|
|
2406
|
+
case "usage": {
|
|
2407
|
+
const normalized = args ? normalizeUsageDisplay(args) : void 0;
|
|
2408
|
+
if (args && !normalized) {
|
|
2409
|
+
chatLog.addSystem("usage: /usage <off|tokens|full>");
|
|
2410
|
+
break;
|
|
2411
|
+
}
|
|
2412
|
+
const currentRaw = state.sessionInfo.responseUsage;
|
|
2413
|
+
const current = resolveResponseUsageMode(currentRaw);
|
|
2414
|
+
const next = normalized ?? (current === "off" ? "tokens" : current === "tokens" ? "full" : "off");
|
|
2415
|
+
try {
|
|
2416
|
+
const result = await client.patchSession({
|
|
2417
|
+
key: state.currentSessionKey,
|
|
2418
|
+
responseUsage: next === "off" ? null : next
|
|
2419
|
+
});
|
|
2420
|
+
chatLog.addSystem(`usage footer: ${next}`);
|
|
2421
|
+
applySessionInfoFromPatch(result);
|
|
2422
|
+
await refreshSessionInfo();
|
|
2423
|
+
} catch (err) {
|
|
2424
|
+
chatLog.addSystem(`usage failed: ${String(err)}`);
|
|
2425
|
+
}
|
|
2426
|
+
break;
|
|
2427
|
+
}
|
|
2428
|
+
case "elevated":
|
|
2429
|
+
if (!args) {
|
|
2430
|
+
chatLog.addSystem("usage: /elevated <on|off|ask|full>");
|
|
2431
|
+
break;
|
|
2432
|
+
}
|
|
2433
|
+
if (![
|
|
2434
|
+
"on",
|
|
2435
|
+
"off",
|
|
2436
|
+
"ask",
|
|
2437
|
+
"full"
|
|
2438
|
+
].includes(args)) {
|
|
2439
|
+
chatLog.addSystem("usage: /elevated <on|off|ask|full>");
|
|
2440
|
+
break;
|
|
2441
|
+
}
|
|
2442
|
+
try {
|
|
2443
|
+
const result = await client.patchSession({
|
|
2444
|
+
key: state.currentSessionKey,
|
|
2445
|
+
elevatedLevel: args
|
|
2446
|
+
});
|
|
2447
|
+
chatLog.addSystem(`elevated set to ${args}`);
|
|
2448
|
+
applySessionInfoFromPatch(result);
|
|
2449
|
+
await refreshSessionInfo();
|
|
2450
|
+
} catch (err) {
|
|
2451
|
+
chatLog.addSystem(`elevated failed: ${String(err)}`);
|
|
2452
|
+
}
|
|
2453
|
+
break;
|
|
2454
|
+
case "activation": {
|
|
2455
|
+
if (!args) {
|
|
2456
|
+
chatLog.addSystem("usage: /activation <mention|always>");
|
|
2457
|
+
break;
|
|
2458
|
+
}
|
|
2459
|
+
const activation = normalizeGroupActivation(args);
|
|
2460
|
+
if (!activation) {
|
|
2461
|
+
chatLog.addSystem("usage: /activation <mention|always>");
|
|
2462
|
+
break;
|
|
2463
|
+
}
|
|
2464
|
+
try {
|
|
2465
|
+
const result = await client.patchSession({
|
|
2466
|
+
key: state.currentSessionKey,
|
|
2467
|
+
groupActivation: activation
|
|
2468
|
+
});
|
|
2469
|
+
chatLog.addSystem(`activation set to ${activation}`);
|
|
2470
|
+
applySessionInfoFromPatch(result);
|
|
2471
|
+
await refreshSessionInfo();
|
|
2472
|
+
} catch (err) {
|
|
2473
|
+
chatLog.addSystem(`activation failed: ${String(err)}`);
|
|
2474
|
+
}
|
|
2475
|
+
break;
|
|
2476
|
+
}
|
|
2477
|
+
case "new":
|
|
2478
|
+
try {
|
|
2479
|
+
state.sessionInfo.inputTokens = null;
|
|
2480
|
+
state.sessionInfo.outputTokens = null;
|
|
2481
|
+
state.sessionInfo.totalTokens = null;
|
|
2482
|
+
tui.requestRender();
|
|
2483
|
+
const uniqueKey = `tui-${randomUUID()}`;
|
|
2484
|
+
await setSession(uniqueKey);
|
|
2485
|
+
chatLog.addSystem(`new session: ${uniqueKey}`);
|
|
2486
|
+
} catch (err) {
|
|
2487
|
+
chatLog.addSystem(`new session failed: ${sanitizeRenderableText(String(err))}`);
|
|
2488
|
+
}
|
|
2489
|
+
break;
|
|
2490
|
+
case "reset":
|
|
2491
|
+
try {
|
|
2492
|
+
state.sessionInfo.inputTokens = null;
|
|
2493
|
+
state.sessionInfo.outputTokens = null;
|
|
2494
|
+
state.sessionInfo.totalTokens = null;
|
|
2495
|
+
tui.requestRender();
|
|
2496
|
+
await client.resetSession(state.currentSessionKey, name);
|
|
2497
|
+
chatLog.addSystem(`session ${state.currentSessionKey} reset`);
|
|
2498
|
+
await loadHistory();
|
|
2499
|
+
} catch (err) {
|
|
2500
|
+
chatLog.addSystem(`reset failed: ${sanitizeRenderableText(String(err))}`);
|
|
2501
|
+
}
|
|
2502
|
+
break;
|
|
2503
|
+
case "abort":
|
|
2504
|
+
await abortActive();
|
|
2505
|
+
break;
|
|
2506
|
+
case "settings":
|
|
2507
|
+
openSettings();
|
|
2508
|
+
break;
|
|
2509
|
+
case "exit":
|
|
2510
|
+
case "quit":
|
|
2511
|
+
requestExit();
|
|
2512
|
+
break;
|
|
2513
|
+
default:
|
|
2514
|
+
await sendMessage(raw);
|
|
2515
|
+
break;
|
|
2516
|
+
}
|
|
2517
|
+
tui.requestRender();
|
|
2518
|
+
};
|
|
2519
|
+
const sendMessage = async (text) => {
|
|
2520
|
+
if (!state.isConnected) {
|
|
2521
|
+
chatLog.addSystem(opts.local ? "local runtime not ready — message not sent" : "not connected to gateway — message not sent");
|
|
2522
|
+
setActivityStatus("disconnected");
|
|
2523
|
+
tui.requestRender();
|
|
2524
|
+
return;
|
|
2525
|
+
}
|
|
2526
|
+
const isBtw = isBtwCommand(text);
|
|
2527
|
+
const canQueueBehindLocalFinishingTurn = opts.local === true && state.activityStatus === "finishing context";
|
|
2528
|
+
if (!isBtw && (!canQueueBehindLocalFinishingTurn || state.pendingChatRunId || state.pendingOptimisticUserMessage) && (state.activeChatRunId || state.pendingChatRunId || state.pendingOptimisticUserMessage)) {
|
|
2529
|
+
chatLog.addSystem("agent is busy — press Esc to abort before sending a new message");
|
|
2530
|
+
tui.requestRender();
|
|
2531
|
+
return;
|
|
2532
|
+
}
|
|
2533
|
+
const runId = randomUUID();
|
|
2534
|
+
try {
|
|
2535
|
+
if (!isBtw) {
|
|
2536
|
+
chatLog.addUser(text);
|
|
2537
|
+
state.pendingOptimisticUserMessage = true;
|
|
2538
|
+
setActivityStatus("sending");
|
|
2539
|
+
} else noteLocalBtwRunId?.(runId);
|
|
2540
|
+
tui.requestRender();
|
|
2541
|
+
await client.sendChat({
|
|
2542
|
+
sessionKey: state.currentSessionKey,
|
|
2543
|
+
sessionId: state.currentSessionId,
|
|
2544
|
+
message: text,
|
|
2545
|
+
thinking: opts.thinking,
|
|
2546
|
+
deliver: deliverDefault,
|
|
2547
|
+
timeoutMs: opts.timeoutMs,
|
|
2548
|
+
runId
|
|
2549
|
+
});
|
|
2550
|
+
if (!isBtw) {
|
|
2551
|
+
state.pendingChatRunId = runId;
|
|
2552
|
+
setActivityStatus("waiting");
|
|
2553
|
+
tui.requestRender();
|
|
2554
|
+
}
|
|
2555
|
+
} catch (err) {
|
|
2556
|
+
if (isBtw) forgetLocalBtwRunId?.(runId);
|
|
2557
|
+
if (!isBtw && state.activeChatRunId) forgetLocalRunId?.(state.activeChatRunId);
|
|
2558
|
+
if (!isBtw) {
|
|
2559
|
+
state.pendingOptimisticUserMessage = false;
|
|
2560
|
+
state.pendingChatRunId = null;
|
|
2561
|
+
state.activeChatRunId = null;
|
|
2562
|
+
}
|
|
2563
|
+
chatLog.addSystem(`${isBtw ? "btw failed" : "send failed"}: ${String(err)}`);
|
|
2564
|
+
if (!isBtw) setActivityStatus("error");
|
|
2565
|
+
tui.requestRender();
|
|
2566
|
+
}
|
|
2567
|
+
};
|
|
2568
|
+
return {
|
|
2569
|
+
handleCommand,
|
|
2570
|
+
sendMessage,
|
|
2571
|
+
openModelSelector,
|
|
2572
|
+
openAgentSelector,
|
|
2573
|
+
openSessionSelector,
|
|
2574
|
+
openSettings,
|
|
2575
|
+
setAgent
|
|
2576
|
+
};
|
|
2577
|
+
}
|
|
2578
|
+
//#endregion
|
|
2579
|
+
//#region src/tui/tui-stream-assembler.ts
|
|
2580
|
+
function extractTextBlocksAndSignals(message) {
|
|
2581
|
+
if (!message || typeof message !== "object") return {
|
|
2582
|
+
textBlocks: [],
|
|
2583
|
+
sawNonTextContentBlocks: false
|
|
2584
|
+
};
|
|
2585
|
+
const content = message.content;
|
|
2586
|
+
if (typeof content === "string") {
|
|
2587
|
+
const text = content.trim();
|
|
2588
|
+
return {
|
|
2589
|
+
textBlocks: text ? [text] : [],
|
|
2590
|
+
sawNonTextContentBlocks: false
|
|
2591
|
+
};
|
|
2592
|
+
}
|
|
2593
|
+
if (!Array.isArray(content)) return {
|
|
2594
|
+
textBlocks: [],
|
|
2595
|
+
sawNonTextContentBlocks: false
|
|
2596
|
+
};
|
|
2597
|
+
const textBlocks = [];
|
|
2598
|
+
let sawNonTextContentBlocks = false;
|
|
2599
|
+
for (const block of content) {
|
|
2600
|
+
if (!block || typeof block !== "object") continue;
|
|
2601
|
+
const rec = block;
|
|
2602
|
+
if (rec.type === "text" && typeof rec.text === "string") {
|
|
2603
|
+
const text = rec.text.trim();
|
|
2604
|
+
if (text) textBlocks.push(text);
|
|
2605
|
+
continue;
|
|
2606
|
+
}
|
|
2607
|
+
if (typeof rec.type === "string" && rec.type !== "thinking") sawNonTextContentBlocks = true;
|
|
2608
|
+
}
|
|
2609
|
+
return {
|
|
2610
|
+
textBlocks,
|
|
2611
|
+
sawNonTextContentBlocks
|
|
2612
|
+
};
|
|
2613
|
+
}
|
|
2614
|
+
function isDroppedBoundaryTextBlockSubset(params) {
|
|
2615
|
+
const { streamedTextBlocks, finalTextBlocks } = params;
|
|
2616
|
+
if (finalTextBlocks.length === 0 || finalTextBlocks.length >= streamedTextBlocks.length) return false;
|
|
2617
|
+
if (finalTextBlocks.every((block, index) => streamedTextBlocks[index] === block)) return true;
|
|
2618
|
+
const suffixStart = streamedTextBlocks.length - finalTextBlocks.length;
|
|
2619
|
+
return finalTextBlocks.every((block, index) => streamedTextBlocks[suffixStart + index] === block);
|
|
2620
|
+
}
|
|
2621
|
+
function shouldPreserveBoundaryDroppedText(params) {
|
|
2622
|
+
if (params.boundaryDropMode === "off") return false;
|
|
2623
|
+
if (!(params.boundaryDropMode === "streamed-or-incoming" ? params.streamedSawNonTextContentBlocks || params.incomingSawNonTextContentBlocks : params.streamedSawNonTextContentBlocks)) return false;
|
|
2624
|
+
return isDroppedBoundaryTextBlockSubset({
|
|
2625
|
+
streamedTextBlocks: params.streamedTextBlocks,
|
|
2626
|
+
finalTextBlocks: params.nextContentBlocks
|
|
2627
|
+
});
|
|
2628
|
+
}
|
|
2629
|
+
var TuiStreamAssembler = class {
|
|
2630
|
+
constructor() {
|
|
2631
|
+
this.runs = /* @__PURE__ */ new Map();
|
|
2632
|
+
}
|
|
2633
|
+
getOrCreateRun(runId) {
|
|
2634
|
+
let state = this.runs.get(runId);
|
|
2635
|
+
if (!state) {
|
|
2636
|
+
state = {
|
|
2637
|
+
thinkingText: "",
|
|
2638
|
+
contentText: "",
|
|
2639
|
+
contentBlocks: [],
|
|
2640
|
+
sawNonTextContentBlocks: false,
|
|
2641
|
+
displayText: ""
|
|
2642
|
+
};
|
|
2643
|
+
this.runs.set(runId, state);
|
|
2644
|
+
}
|
|
2645
|
+
return state;
|
|
2646
|
+
}
|
|
2647
|
+
updateRunState(state, message, showThinking, opts) {
|
|
2648
|
+
const thinkingText = extractThinkingFromMessage(message);
|
|
2649
|
+
const contentText = extractContentFromMessage(message);
|
|
2650
|
+
const { textBlocks, sawNonTextContentBlocks } = extractTextBlocksAndSignals(message);
|
|
2651
|
+
if (thinkingText) state.thinkingText = thinkingText;
|
|
2652
|
+
if (contentText) {
|
|
2653
|
+
const nextContentBlocks = textBlocks.length > 0 ? textBlocks : [contentText];
|
|
2654
|
+
if (!shouldPreserveBoundaryDroppedText({
|
|
2655
|
+
boundaryDropMode: opts?.boundaryDropMode ?? "off",
|
|
2656
|
+
streamedSawNonTextContentBlocks: state.sawNonTextContentBlocks,
|
|
2657
|
+
incomingSawNonTextContentBlocks: sawNonTextContentBlocks,
|
|
2658
|
+
streamedTextBlocks: state.contentBlocks,
|
|
2659
|
+
nextContentBlocks
|
|
2660
|
+
})) {
|
|
2661
|
+
state.contentText = contentText;
|
|
2662
|
+
state.contentBlocks = nextContentBlocks;
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
if (sawNonTextContentBlocks) state.sawNonTextContentBlocks = true;
|
|
2666
|
+
state.displayText = composeThinkingAndContent({
|
|
2667
|
+
thinkingText: state.thinkingText,
|
|
2668
|
+
contentText: state.contentText,
|
|
2669
|
+
showThinking
|
|
2670
|
+
});
|
|
2671
|
+
}
|
|
2672
|
+
ingestDelta(runId, message, showThinking) {
|
|
2673
|
+
const state = this.getOrCreateRun(runId);
|
|
2674
|
+
const previousDisplayText = state.displayText;
|
|
2675
|
+
this.updateRunState(state, message, showThinking, { boundaryDropMode: "streamed-or-incoming" });
|
|
2676
|
+
if (!state.displayText || state.displayText === previousDisplayText) return null;
|
|
2677
|
+
return state.displayText;
|
|
2678
|
+
}
|
|
2679
|
+
finalize(runId, message, showThinking, errorMessage) {
|
|
2680
|
+
const state = this.getOrCreateRun(runId);
|
|
2681
|
+
const streamedDisplayText = state.displayText;
|
|
2682
|
+
const streamedTextBlocks = [...state.contentBlocks];
|
|
2683
|
+
const streamedSawNonTextContentBlocks = state.sawNonTextContentBlocks;
|
|
2684
|
+
this.updateRunState(state, message, showThinking, { boundaryDropMode: "streamed-only" });
|
|
2685
|
+
const finalComposed = state.displayText;
|
|
2686
|
+
const finalText = resolveFinalAssistantText({
|
|
2687
|
+
finalText: streamedSawNonTextContentBlocks && isDroppedBoundaryTextBlockSubset({
|
|
2688
|
+
streamedTextBlocks,
|
|
2689
|
+
finalTextBlocks: state.contentBlocks
|
|
2690
|
+
}) ? streamedDisplayText : finalComposed,
|
|
2691
|
+
streamedText: streamedDisplayText,
|
|
2692
|
+
errorMessage
|
|
2693
|
+
});
|
|
2694
|
+
this.runs.delete(runId);
|
|
2695
|
+
return finalText;
|
|
2696
|
+
}
|
|
2697
|
+
drop(runId) {
|
|
2698
|
+
this.runs.delete(runId);
|
|
2699
|
+
}
|
|
2700
|
+
};
|
|
2701
|
+
//#endregion
|
|
2702
|
+
//#region src/tui/tui-event-handlers.ts
|
|
2703
|
+
const DEFAULT_STREAMING_WATCHDOG_MS = 3e4;
|
|
2704
|
+
const STREAMING_WATCHDOG_USER_MESSAGE = "This response is taking longer than expected. Send another message to continue.";
|
|
2705
|
+
function createEventHandlers(context) {
|
|
2706
|
+
const { chatLog, btw, tui, state, setActivityStatus, refreshSessionInfo, loadHistory, noteLocalRunId, isLocalRunId, forgetLocalRunId, clearLocalRunIds, isLocalBtwRunId, forgetLocalBtwRunId, clearLocalBtwRunIds, localMode } = context;
|
|
2707
|
+
const finalizedRuns = /* @__PURE__ */ new Map();
|
|
2708
|
+
const sessionRuns = /* @__PURE__ */ new Map();
|
|
2709
|
+
const postFinalizingRuns = /* @__PURE__ */ new Map();
|
|
2710
|
+
let streamAssembler = new TuiStreamAssembler();
|
|
2711
|
+
let lastSessionKey = state.currentSessionKey;
|
|
2712
|
+
let pendingHistoryRefresh = false;
|
|
2713
|
+
let reconnectPendingRunId = null;
|
|
2714
|
+
const streamingWatchdogMs = typeof context.streamingWatchdogMs === "number" && Number.isFinite(context.streamingWatchdogMs) && context.streamingWatchdogMs >= 0 ? Math.floor(context.streamingWatchdogMs) : DEFAULT_STREAMING_WATCHDOG_MS;
|
|
2715
|
+
let streamingWatchdogTimer = null;
|
|
2716
|
+
let streamingWatchdogRunId = null;
|
|
2717
|
+
const flushPendingHistoryRefreshIfIdle = () => {
|
|
2718
|
+
if (!pendingHistoryRefresh || state.activeChatRunId) return;
|
|
2719
|
+
pendingHistoryRefresh = false;
|
|
2720
|
+
loadHistory?.();
|
|
2721
|
+
};
|
|
2722
|
+
const clearStreamingWatchdog = () => {
|
|
2723
|
+
if (streamingWatchdogTimer) {
|
|
2724
|
+
clearTimeout(streamingWatchdogTimer);
|
|
2725
|
+
streamingWatchdogTimer = null;
|
|
2726
|
+
}
|
|
2727
|
+
streamingWatchdogRunId = null;
|
|
2728
|
+
};
|
|
2729
|
+
const pauseStreamingWatchdog = () => {
|
|
2730
|
+
clearStreamingWatchdog();
|
|
2731
|
+
};
|
|
2732
|
+
const armStreamingWatchdog = (runId) => {
|
|
2733
|
+
if (streamingWatchdogMs <= 0) return;
|
|
2734
|
+
if (streamingWatchdogTimer) clearTimeout(streamingWatchdogTimer);
|
|
2735
|
+
streamingWatchdogRunId = runId;
|
|
2736
|
+
streamingWatchdogTimer = setTimeout(() => {
|
|
2737
|
+
streamingWatchdogTimer = null;
|
|
2738
|
+
if (streamingWatchdogRunId !== runId || state.activeChatRunId !== runId) return;
|
|
2739
|
+
streamingWatchdogRunId = null;
|
|
2740
|
+
state.activeChatRunId = null;
|
|
2741
|
+
state.activityStatus = "idle";
|
|
2742
|
+
setActivityStatus("idle");
|
|
2743
|
+
if (reconnectPendingRunId === runId) {
|
|
2744
|
+
reconnectPendingRunId = null;
|
|
2745
|
+
pendingHistoryRefresh = false;
|
|
2746
|
+
loadHistory?.();
|
|
2747
|
+
tui.requestRender();
|
|
2748
|
+
return;
|
|
2749
|
+
}
|
|
2750
|
+
flushPendingHistoryRefreshIfIdle();
|
|
2751
|
+
chatLog.addPendingSystem(runId, STREAMING_WATCHDOG_USER_MESSAGE);
|
|
2752
|
+
tui.requestRender();
|
|
2753
|
+
}, streamingWatchdogMs);
|
|
2754
|
+
const maybeUnref = streamingWatchdogTimer.unref;
|
|
2755
|
+
if (typeof maybeUnref === "function") maybeUnref.call(streamingWatchdogTimer);
|
|
2756
|
+
};
|
|
2757
|
+
const pruneRunMap = (runs) => {
|
|
2758
|
+
if (runs.size <= 200) return;
|
|
2759
|
+
const keepUntil = Date.now() - 600 * 1e3;
|
|
2760
|
+
for (const [key, ts] of runs) {
|
|
2761
|
+
if (runs.size <= 150) break;
|
|
2762
|
+
if (ts < keepUntil) runs.delete(key);
|
|
2763
|
+
}
|
|
2764
|
+
if (runs.size > 200) for (const key of runs.keys()) {
|
|
2765
|
+
runs.delete(key);
|
|
2766
|
+
if (runs.size <= 150) break;
|
|
2767
|
+
}
|
|
2768
|
+
};
|
|
2769
|
+
const syncSessionKey = () => {
|
|
2770
|
+
if (state.currentSessionKey === lastSessionKey) return;
|
|
2771
|
+
lastSessionKey = state.currentSessionKey;
|
|
2772
|
+
finalizedRuns.clear();
|
|
2773
|
+
sessionRuns.clear();
|
|
2774
|
+
postFinalizingRuns.clear();
|
|
2775
|
+
streamAssembler = new TuiStreamAssembler();
|
|
2776
|
+
pendingHistoryRefresh = false;
|
|
2777
|
+
state.pendingOptimisticUserMessage = false;
|
|
2778
|
+
state.pendingChatRunId = null;
|
|
2779
|
+
reconnectPendingRunId = null;
|
|
2780
|
+
clearLocalRunIds?.();
|
|
2781
|
+
clearLocalBtwRunIds?.();
|
|
2782
|
+
btw.clear();
|
|
2783
|
+
clearStreamingWatchdog();
|
|
2784
|
+
};
|
|
2785
|
+
const resolveAuthErrorHint = (errorMessage) => {
|
|
2786
|
+
if (!localMode || !isAuthErrorMessage(errorMessage)) return;
|
|
2787
|
+
const provider = state.sessionInfo.modelProvider?.trim();
|
|
2788
|
+
return provider ? `auth or provider access failed for ${provider}. Run /auth ${provider} to refresh credentials; if you already re-authed, switch models/providers because this account may still be blocked for inference.` : "auth or provider access failed for the current provider. Run /auth to refresh credentials; if you already re-authed, switch models/providers because this account may still be blocked for inference.";
|
|
2789
|
+
};
|
|
2790
|
+
const parseProviderModelRef = (modelRef) => {
|
|
2791
|
+
if (typeof modelRef !== "string") return;
|
|
2792
|
+
const trimmed = modelRef.trim();
|
|
2793
|
+
const separator = trimmed.indexOf("/");
|
|
2794
|
+
if (separator <= 0 || separator >= trimmed.length - 1) return;
|
|
2795
|
+
const provider = trimmed.slice(0, separator).trim();
|
|
2796
|
+
const model = trimmed.slice(separator + 1).trim();
|
|
2797
|
+
return provider && model ? {
|
|
2798
|
+
provider,
|
|
2799
|
+
model
|
|
2800
|
+
} : void 0;
|
|
2801
|
+
};
|
|
2802
|
+
const applyFallbackStepModelUpdate = (evt) => {
|
|
2803
|
+
const data = evt.data ?? {};
|
|
2804
|
+
if (evt.stream !== "lifecycle" || asString(data.phase, "") !== "fallback_step") return false;
|
|
2805
|
+
const target = parseProviderModelRef(data.fallbackStepToModel);
|
|
2806
|
+
if (!target) return false;
|
|
2807
|
+
state.sessionInfo.modelProvider = target.provider;
|
|
2808
|
+
state.sessionInfo.model = target.model;
|
|
2809
|
+
return true;
|
|
2810
|
+
};
|
|
2811
|
+
const noteSessionRun = (runId) => {
|
|
2812
|
+
sessionRuns.set(runId, Date.now());
|
|
2813
|
+
pruneRunMap(sessionRuns);
|
|
2814
|
+
};
|
|
2815
|
+
const noteFinalizedRun = (runId) => {
|
|
2816
|
+
finalizedRuns.set(runId, Date.now());
|
|
2817
|
+
sessionRuns.delete(runId);
|
|
2818
|
+
streamAssembler.drop(runId);
|
|
2819
|
+
pruneRunMap(finalizedRuns);
|
|
2820
|
+
};
|
|
2821
|
+
const notePostFinalizingRun = (runId) => {
|
|
2822
|
+
postFinalizingRuns.set(runId, Date.now());
|
|
2823
|
+
pruneRunMap(postFinalizingRuns);
|
|
2824
|
+
};
|
|
2825
|
+
const clearActiveRunIfMatch = (runId) => {
|
|
2826
|
+
if (state.activeChatRunId === runId) state.activeChatRunId = null;
|
|
2827
|
+
};
|
|
2828
|
+
const clearStaleStreamingIfNoTrackedRunRemains = () => {
|
|
2829
|
+
const activeRunId = state.activeChatRunId;
|
|
2830
|
+
const activeRunIsStillTracked = activeRunId ? sessionRuns.has(activeRunId) : false;
|
|
2831
|
+
if (state.activityStatus !== "streaming" || activeRunIsStillTracked || sessionRuns.size > 0) return;
|
|
2832
|
+
state.activeChatRunId = null;
|
|
2833
|
+
state.activityStatus = "idle";
|
|
2834
|
+
setActivityStatus("idle");
|
|
2835
|
+
clearStreamingWatchdog();
|
|
2836
|
+
flushPendingHistoryRefreshIfIdle();
|
|
2837
|
+
};
|
|
2838
|
+
const reconnectStreamingWatchdog = () => {
|
|
2839
|
+
clearStreamingWatchdog();
|
|
2840
|
+
const activeRunId = state.activeChatRunId;
|
|
2841
|
+
if (!activeRunId) {
|
|
2842
|
+
reconnectPendingRunId = null;
|
|
2843
|
+
clearStaleStreamingIfNoTrackedRunRemains();
|
|
2844
|
+
return;
|
|
2845
|
+
}
|
|
2846
|
+
if (!sessionRuns.has(activeRunId)) {
|
|
2847
|
+
reconnectPendingRunId = null;
|
|
2848
|
+
state.activeChatRunId = null;
|
|
2849
|
+
state.activityStatus = "idle";
|
|
2850
|
+
setActivityStatus("idle");
|
|
2851
|
+
flushPendingHistoryRefreshIfIdle();
|
|
2852
|
+
return;
|
|
2853
|
+
}
|
|
2854
|
+
reconnectPendingRunId = activeRunId;
|
|
2855
|
+
setActivityStatus("streaming");
|
|
2856
|
+
armStreamingWatchdog(activeRunId);
|
|
2857
|
+
};
|
|
2858
|
+
const finalizeRun = (params) => {
|
|
2859
|
+
noteFinalizedRun(params.runId);
|
|
2860
|
+
clearActiveRunIfMatch(params.runId);
|
|
2861
|
+
flushPendingHistoryRefreshIfIdle();
|
|
2862
|
+
if (params.wasActiveRun) {
|
|
2863
|
+
setActivityStatus(params.status);
|
|
2864
|
+
clearStreamingWatchdog();
|
|
2865
|
+
} else {
|
|
2866
|
+
if (streamingWatchdogRunId === params.runId) clearStreamingWatchdog();
|
|
2867
|
+
clearStaleStreamingIfNoTrackedRunRemains();
|
|
2868
|
+
}
|
|
2869
|
+
refreshSessionInfo?.();
|
|
2870
|
+
};
|
|
2871
|
+
const terminateRun = (params) => {
|
|
2872
|
+
streamAssembler.drop(params.runId);
|
|
2873
|
+
sessionRuns.delete(params.runId);
|
|
2874
|
+
clearActiveRunIfMatch(params.runId);
|
|
2875
|
+
flushPendingHistoryRefreshIfIdle();
|
|
2876
|
+
if (params.wasActiveRun) {
|
|
2877
|
+
setActivityStatus(params.status);
|
|
2878
|
+
clearStreamingWatchdog();
|
|
2879
|
+
} else if (streamingWatchdogRunId === params.runId) clearStreamingWatchdog();
|
|
2880
|
+
refreshSessionInfo?.();
|
|
2881
|
+
};
|
|
2882
|
+
const hasConcurrentActiveRun = (runId) => {
|
|
2883
|
+
const activeRunId = state.activeChatRunId;
|
|
2884
|
+
if (!activeRunId || activeRunId === runId) return false;
|
|
2885
|
+
return sessionRuns.has(activeRunId);
|
|
2886
|
+
};
|
|
2887
|
+
const maybeRefreshHistoryForRun = (runId, opts) => {
|
|
2888
|
+
if (isLocalRunId?.(runId) ?? false) {
|
|
2889
|
+
forgetLocalRunId?.(runId);
|
|
2890
|
+
if (!opts?.allowLocalWithoutDisplayableFinal) return;
|
|
2891
|
+
if (state.activeChatRunId && state.activeChatRunId !== runId) {
|
|
2892
|
+
pendingHistoryRefresh = true;
|
|
2893
|
+
return;
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
if (hasConcurrentActiveRun(runId)) return;
|
|
2897
|
+
pendingHistoryRefresh = false;
|
|
2898
|
+
loadHistory?.();
|
|
2899
|
+
};
|
|
2900
|
+
const isSameSessionKey = (left, right) => {
|
|
2901
|
+
const normalizedLeft = normalizeLowercaseStringOrEmpty(left);
|
|
2902
|
+
const normalizedRight = normalizeLowercaseStringOrEmpty(right);
|
|
2903
|
+
if (!normalizedLeft || !normalizedRight) return false;
|
|
2904
|
+
if (normalizedLeft === normalizedRight) return true;
|
|
2905
|
+
const parsedLeft = parseAgentSessionKey(normalizedLeft);
|
|
2906
|
+
const parsedRight = parseAgentSessionKey(normalizedRight);
|
|
2907
|
+
if (parsedLeft && parsedRight) return parsedLeft.agentId === parsedRight.agentId && parsedLeft.rest === parsedRight.rest;
|
|
2908
|
+
if (parsedLeft) return parsedLeft.rest === normalizedRight;
|
|
2909
|
+
if (parsedRight) return normalizedLeft === parsedRight.rest;
|
|
2910
|
+
return false;
|
|
2911
|
+
};
|
|
2912
|
+
const handleChatEvent = (payload) => {
|
|
2913
|
+
if (!payload || typeof payload !== "object") return;
|
|
2914
|
+
const evt = payload;
|
|
2915
|
+
syncSessionKey();
|
|
2916
|
+
if (!isSameSessionKey(evt.sessionKey, state.currentSessionKey)) return;
|
|
2917
|
+
if (finalizedRuns.has(evt.runId)) {
|
|
2918
|
+
if (evt.state === "delta") return;
|
|
2919
|
+
if (evt.state === "final") {
|
|
2920
|
+
clearStaleStreamingIfNoTrackedRunRemains();
|
|
2921
|
+
return;
|
|
2922
|
+
}
|
|
2923
|
+
}
|
|
2924
|
+
if (reconnectPendingRunId === evt.runId) reconnectPendingRunId = null;
|
|
2925
|
+
chatLog.dismissPendingSystem(evt.runId);
|
|
2926
|
+
noteSessionRun(evt.runId);
|
|
2927
|
+
if (!state.activeChatRunId && !isLocalBtwRunId?.(evt.runId)) {
|
|
2928
|
+
state.activeChatRunId = evt.runId;
|
|
2929
|
+
if (state.pendingOptimisticUserMessage) {
|
|
2930
|
+
noteLocalRunId?.(evt.runId);
|
|
2931
|
+
state.pendingOptimisticUserMessage = false;
|
|
2932
|
+
}
|
|
2933
|
+
}
|
|
2934
|
+
if (state.pendingChatRunId === evt.runId) state.pendingChatRunId = null;
|
|
2935
|
+
if (evt.state === "delta") {
|
|
2936
|
+
setActivityStatus("streaming");
|
|
2937
|
+
if (state.activeChatRunId === evt.runId) armStreamingWatchdog(evt.runId);
|
|
2938
|
+
const displayText = streamAssembler.ingestDelta(evt.runId, evt.message, state.showThinking);
|
|
2939
|
+
if (!displayText) return;
|
|
2940
|
+
chatLog.updateAssistant(displayText, evt.runId);
|
|
2941
|
+
}
|
|
2942
|
+
if (evt.state === "final") {
|
|
2943
|
+
const isLocalBtwRun = isLocalBtwRunId?.(evt.runId) ?? false;
|
|
2944
|
+
const wasActiveRun = state.activeChatRunId === evt.runId;
|
|
2945
|
+
if (!evt.message && isLocalBtwRun) {
|
|
2946
|
+
forgetLocalBtwRunId?.(evt.runId);
|
|
2947
|
+
noteFinalizedRun(evt.runId);
|
|
2948
|
+
clearStaleStreamingIfNoTrackedRunRemains();
|
|
2949
|
+
tui.requestRender();
|
|
2950
|
+
return;
|
|
2951
|
+
}
|
|
2952
|
+
if (!evt.message) {
|
|
2953
|
+
maybeRefreshHistoryForRun(evt.runId, { allowLocalWithoutDisplayableFinal: true });
|
|
2954
|
+
chatLog.dropAssistant(evt.runId);
|
|
2955
|
+
finalizeRun({
|
|
2956
|
+
runId: evt.runId,
|
|
2957
|
+
wasActiveRun,
|
|
2958
|
+
status: "idle"
|
|
2959
|
+
});
|
|
2960
|
+
tui.requestRender();
|
|
2961
|
+
return;
|
|
2962
|
+
}
|
|
2963
|
+
if (isCommandMessage(evt.message)) {
|
|
2964
|
+
maybeRefreshHistoryForRun(evt.runId);
|
|
2965
|
+
const text = extractTextFromMessage(evt.message);
|
|
2966
|
+
if (text) chatLog.addSystem(text);
|
|
2967
|
+
finalizeRun({
|
|
2968
|
+
runId: evt.runId,
|
|
2969
|
+
wasActiveRun,
|
|
2970
|
+
status: "idle"
|
|
2971
|
+
});
|
|
2972
|
+
tui.requestRender();
|
|
2973
|
+
return;
|
|
2974
|
+
}
|
|
2975
|
+
maybeRefreshHistoryForRun(evt.runId);
|
|
2976
|
+
const stopReason = evt.message && typeof evt.message === "object" && !Array.isArray(evt.message) ? typeof evt.message.stopReason === "string" ? evt.message.stopReason : "" : "";
|
|
2977
|
+
const finalText = streamAssembler.finalize(evt.runId, evt.message, state.showThinking, evt.errorMessage);
|
|
2978
|
+
if (finalText === "(no output)" && !isLocalRunId?.(evt.runId)) chatLog.dropAssistant(evt.runId);
|
|
2979
|
+
else chatLog.finalizeAssistant(finalText, evt.runId);
|
|
2980
|
+
finalizeRun({
|
|
2981
|
+
runId: evt.runId,
|
|
2982
|
+
wasActiveRun,
|
|
2983
|
+
status: stopReason === "error" ? "error" : "idle"
|
|
2984
|
+
});
|
|
2985
|
+
}
|
|
2986
|
+
if (evt.state === "aborted") {
|
|
2987
|
+
forgetLocalBtwRunId?.(evt.runId);
|
|
2988
|
+
const wasActiveRun = state.activeChatRunId === evt.runId;
|
|
2989
|
+
chatLog.addSystem("run aborted");
|
|
2990
|
+
terminateRun({
|
|
2991
|
+
runId: evt.runId,
|
|
2992
|
+
wasActiveRun,
|
|
2993
|
+
status: "aborted"
|
|
2994
|
+
});
|
|
2995
|
+
maybeRefreshHistoryForRun(evt.runId);
|
|
2996
|
+
}
|
|
2997
|
+
if (evt.state === "error") {
|
|
2998
|
+
forgetLocalBtwRunId?.(evt.runId);
|
|
2999
|
+
const wasActiveRun = state.activeChatRunId === evt.runId;
|
|
3000
|
+
const errorMessage = evt.errorMessage ?? "unknown";
|
|
3001
|
+
const renderedError = formatRawAssistantErrorForUi(errorMessage);
|
|
3002
|
+
chatLog.addSystem(resolveAuthErrorHint(errorMessage) ?? `run error: ${renderedError}`);
|
|
3003
|
+
terminateRun({
|
|
3004
|
+
runId: evt.runId,
|
|
3005
|
+
wasActiveRun,
|
|
3006
|
+
status: "error"
|
|
3007
|
+
});
|
|
3008
|
+
maybeRefreshHistoryForRun(evt.runId);
|
|
3009
|
+
}
|
|
3010
|
+
tui.requestRender();
|
|
3011
|
+
};
|
|
3012
|
+
const handleAgentEvent = (payload) => {
|
|
3013
|
+
if (!payload || typeof payload !== "object") return;
|
|
3014
|
+
const evt = payload;
|
|
3015
|
+
syncSessionKey();
|
|
3016
|
+
const isActiveRun = evt.runId === state.activeChatRunId;
|
|
3017
|
+
const isPendingRun = evt.runId === state.pendingChatRunId;
|
|
3018
|
+
const isSessionRun = sessionRuns.has(evt.runId);
|
|
3019
|
+
if ((isActiveRun || isPendingRun || isSessionRun) && applyFallbackStepModelUpdate(evt)) {
|
|
3020
|
+
if (isActiveRun) armStreamingWatchdog(evt.runId);
|
|
3021
|
+
tui.requestRender();
|
|
3022
|
+
return;
|
|
3023
|
+
}
|
|
3024
|
+
if (!(isActiveRun || isPendingRun || isSessionRun || finalizedRuns.has(evt.runId))) return;
|
|
3025
|
+
if (evt.stream === "tool") {
|
|
3026
|
+
if (isActiveRun) armStreamingWatchdog(evt.runId);
|
|
3027
|
+
const verbose = state.sessionInfo.verboseLevel ?? "off";
|
|
3028
|
+
const allowToolEvents = verbose !== "off";
|
|
3029
|
+
const allowToolOutput = verbose === "full";
|
|
3030
|
+
if (!allowToolEvents) return;
|
|
3031
|
+
const data = evt.data ?? {};
|
|
3032
|
+
const phase = asString(data.phase, "");
|
|
3033
|
+
const toolCallId = asString(data.toolCallId, "");
|
|
3034
|
+
const toolName = asString(data.name, "tool");
|
|
3035
|
+
if (!toolCallId) return;
|
|
3036
|
+
if (phase === "start") chatLog.startTool(toolCallId, toolName, data.args);
|
|
3037
|
+
else if (phase === "update") {
|
|
3038
|
+
if (!allowToolOutput) return;
|
|
3039
|
+
chatLog.updateToolResult(toolCallId, data.partialResult, { partial: true });
|
|
3040
|
+
} else if (phase === "result") if (allowToolOutput) chatLog.updateToolResult(toolCallId, data.result, { isError: Boolean(data.isError) });
|
|
3041
|
+
else chatLog.updateToolResult(toolCallId, { content: [] }, { isError: Boolean(data.isError) });
|
|
3042
|
+
tui.requestRender();
|
|
3043
|
+
return;
|
|
3044
|
+
}
|
|
3045
|
+
if (evt.stream === "lifecycle") {
|
|
3046
|
+
if (isPendingRun) {
|
|
3047
|
+
noteSessionRun(evt.runId);
|
|
3048
|
+
state.activeChatRunId = evt.runId;
|
|
3049
|
+
state.pendingChatRunId = null;
|
|
3050
|
+
if (state.pendingOptimisticUserMessage) {
|
|
3051
|
+
if (localMode) noteLocalRunId?.(evt.runId);
|
|
3052
|
+
state.pendingOptimisticUserMessage = false;
|
|
3053
|
+
}
|
|
3054
|
+
}
|
|
3055
|
+
const phase = typeof evt.data?.phase === "string" ? evt.data.phase : "";
|
|
3056
|
+
const isPostFinalTerminalPhase = postFinalizingRuns.has(evt.runId) && (phase === "end" || phase === "error");
|
|
3057
|
+
if (!isActiveRun && !isPendingRun && phase !== "finishing" && !isPostFinalTerminalPhase) return;
|
|
3058
|
+
const canUpdateActivityStatus = !hasConcurrentActiveRun(evt.runId);
|
|
3059
|
+
if (phase && phase !== "end" && phase !== "error" && phase !== "finishing") armStreamingWatchdog(evt.runId);
|
|
3060
|
+
if (phase === "start") {
|
|
3061
|
+
if (!canUpdateActivityStatus) return;
|
|
3062
|
+
setActivityStatus("running");
|
|
3063
|
+
}
|
|
3064
|
+
if (phase === "finishing") {
|
|
3065
|
+
notePostFinalizingRun(evt.runId);
|
|
3066
|
+
if (!canUpdateActivityStatus) return;
|
|
3067
|
+
clearStreamingWatchdog();
|
|
3068
|
+
setActivityStatus("finishing context");
|
|
3069
|
+
}
|
|
3070
|
+
if (phase === "end") {
|
|
3071
|
+
postFinalizingRuns.delete(evt.runId);
|
|
3072
|
+
if (!canUpdateActivityStatus) return;
|
|
3073
|
+
setActivityStatus("idle");
|
|
3074
|
+
}
|
|
3075
|
+
if (phase === "error") {
|
|
3076
|
+
postFinalizingRuns.delete(evt.runId);
|
|
3077
|
+
if (!canUpdateActivityStatus) return;
|
|
3078
|
+
setActivityStatus("error");
|
|
3079
|
+
}
|
|
3080
|
+
tui.requestRender();
|
|
3081
|
+
}
|
|
3082
|
+
};
|
|
3083
|
+
const handleBtwEvent = (payload) => {
|
|
3084
|
+
if (!payload || typeof payload !== "object") return;
|
|
3085
|
+
const evt = payload;
|
|
3086
|
+
syncSessionKey();
|
|
3087
|
+
if (!isSameSessionKey(evt.sessionKey, state.currentSessionKey)) return;
|
|
3088
|
+
if (evt.kind !== "btw") return;
|
|
3089
|
+
const question = evt.question.trim();
|
|
3090
|
+
const text = evt.text.trim();
|
|
3091
|
+
if (!question || !text) return;
|
|
3092
|
+
btw.showResult({
|
|
3093
|
+
question,
|
|
3094
|
+
text,
|
|
3095
|
+
isError: evt.isError
|
|
3096
|
+
});
|
|
3097
|
+
tui.requestRender();
|
|
3098
|
+
};
|
|
3099
|
+
const dispose = () => {
|
|
3100
|
+
clearStreamingWatchdog();
|
|
3101
|
+
};
|
|
3102
|
+
return {
|
|
3103
|
+
handleChatEvent,
|
|
3104
|
+
handleAgentEvent,
|
|
3105
|
+
handleBtwEvent,
|
|
3106
|
+
pauseStreamingWatchdog,
|
|
3107
|
+
reconnectStreamingWatchdog,
|
|
3108
|
+
dispose
|
|
3109
|
+
};
|
|
3110
|
+
}
|
|
3111
|
+
//#endregion
|
|
3112
|
+
//#region src/tui/tui-last-session.ts
|
|
3113
|
+
function resolveTuiLastSessionStatePath(stateDir = resolveStateDir()) {
|
|
3114
|
+
return path.join(stateDir, "tui", "last-session.json");
|
|
3115
|
+
}
|
|
3116
|
+
function buildTuiLastSessionScopeKey(params) {
|
|
3117
|
+
const agentId = normalizeAgentId(params.agentId);
|
|
3118
|
+
const connectionUrl = params.connectionUrl.trim() || "local";
|
|
3119
|
+
return createHash("sha256").update(`${params.sessionScope}\n${agentId}\n${connectionUrl}`).digest("hex").slice(0, 32);
|
|
3120
|
+
}
|
|
3121
|
+
async function readStore(filePath) {
|
|
3122
|
+
try {
|
|
3123
|
+
const parsed = await privateFileStore(path.dirname(filePath)).readJsonIfExists(path.basename(filePath));
|
|
3124
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
3125
|
+
} catch {
|
|
3126
|
+
return {};
|
|
3127
|
+
}
|
|
3128
|
+
}
|
|
3129
|
+
function normalizeMarker(value) {
|
|
3130
|
+
return typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
3131
|
+
}
|
|
3132
|
+
function isHeartbeatSessionKey(sessionKey) {
|
|
3133
|
+
return normalizeMarker(sessionKey).endsWith(":heartbeat");
|
|
3134
|
+
}
|
|
3135
|
+
function isHeartbeatLikeTuiSession(session) {
|
|
3136
|
+
if (isHeartbeatSessionKey(session.key)) return true;
|
|
3137
|
+
return [
|
|
3138
|
+
session.provider,
|
|
3139
|
+
session.lastProvider,
|
|
3140
|
+
session.lastChannel,
|
|
3141
|
+
session.lastTo,
|
|
3142
|
+
session.origin?.provider,
|
|
3143
|
+
session.origin?.surface,
|
|
3144
|
+
session.origin?.label
|
|
3145
|
+
].some((marker) => normalizeMarker(marker) === "heartbeat");
|
|
3146
|
+
}
|
|
3147
|
+
async function readTuiLastSessionKey(params) {
|
|
3148
|
+
const value = (await readStore(resolveTuiLastSessionStatePath(params.stateDir)))[params.scopeKey]?.sessionKey;
|
|
3149
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
3150
|
+
}
|
|
3151
|
+
async function writeTuiLastSessionKey(params) {
|
|
3152
|
+
const sessionKey = params.sessionKey.trim();
|
|
3153
|
+
if (!sessionKey || sessionKey === "unknown" || isHeartbeatSessionKey(sessionKey)) return;
|
|
3154
|
+
const filePath = resolveTuiLastSessionStatePath(params.stateDir);
|
|
3155
|
+
const store = await readStore(filePath);
|
|
3156
|
+
store[params.scopeKey] = {
|
|
3157
|
+
sessionKey,
|
|
3158
|
+
updatedAt: Date.now()
|
|
3159
|
+
};
|
|
3160
|
+
await privateFileStore(path.dirname(filePath)).writeJson(path.basename(filePath), store, { trailingNewline: true });
|
|
3161
|
+
}
|
|
3162
|
+
function resolveRememberedTuiSessionKey(params) {
|
|
3163
|
+
const rememberedKey = params.rememberedKey?.trim();
|
|
3164
|
+
if (!rememberedKey) return null;
|
|
3165
|
+
if (isHeartbeatSessionKey(rememberedKey)) return null;
|
|
3166
|
+
const currentAgentId = normalizeAgentId(params.currentAgentId);
|
|
3167
|
+
const parsed = parseAgentSessionKey(rememberedKey);
|
|
3168
|
+
if (parsed && normalizeAgentId(parsed.agentId) !== currentAgentId) return null;
|
|
3169
|
+
const rememberedRest = parsed?.rest ?? rememberedKey;
|
|
3170
|
+
return params.sessions.find((session) => {
|
|
3171
|
+
if (isHeartbeatLikeTuiSession(session)) return false;
|
|
3172
|
+
if (session.key === rememberedKey) return true;
|
|
3173
|
+
return parseAgentSessionKey(session.key)?.rest === rememberedRest;
|
|
3174
|
+
})?.key ?? null;
|
|
3175
|
+
}
|
|
3176
|
+
//#endregion
|
|
3177
|
+
//#region src/tui/tui-local-shell.ts
|
|
3178
|
+
function createLocalShellRunner(deps) {
|
|
3179
|
+
let localExecAsked = false;
|
|
3180
|
+
let localExecAllowed = false;
|
|
3181
|
+
const createSelector = deps.createSelector ?? createSearchableSelectList;
|
|
3182
|
+
const spawnCommand = deps.spawnCommand ?? spawn;
|
|
3183
|
+
const getCwd = deps.getCwd ?? (() => process.cwd());
|
|
3184
|
+
const env = deps.env ?? process.env;
|
|
3185
|
+
const maxChars = deps.maxOutputChars ?? 4e4;
|
|
3186
|
+
const ensureLocalExecAllowed = async () => {
|
|
3187
|
+
if (localExecAllowed) return true;
|
|
3188
|
+
if (localExecAsked) return false;
|
|
3189
|
+
localExecAsked = true;
|
|
3190
|
+
return await new Promise((resolve) => {
|
|
3191
|
+
deps.chatLog.addSystem("Allow local shell commands for this session?");
|
|
3192
|
+
deps.chatLog.addSystem("This runs commands on YOUR machine (not the gateway) and may delete files or reveal secrets.");
|
|
3193
|
+
deps.chatLog.addSystem("Select Yes/No (arrows + Enter), Esc to cancel.");
|
|
3194
|
+
const selector = createSelector([{
|
|
3195
|
+
value: "no",
|
|
3196
|
+
label: "No"
|
|
3197
|
+
}, {
|
|
3198
|
+
value: "yes",
|
|
3199
|
+
label: "Yes"
|
|
3200
|
+
}], 2);
|
|
3201
|
+
selector.onSelect = (item) => {
|
|
3202
|
+
deps.closeOverlay();
|
|
3203
|
+
if (item.value === "yes") {
|
|
3204
|
+
localExecAllowed = true;
|
|
3205
|
+
deps.chatLog.addSystem("local shell: enabled for this session");
|
|
3206
|
+
resolve(true);
|
|
3207
|
+
} else {
|
|
3208
|
+
deps.chatLog.addSystem("local shell: not enabled");
|
|
3209
|
+
resolve(false);
|
|
3210
|
+
}
|
|
3211
|
+
deps.tui.requestRender();
|
|
3212
|
+
};
|
|
3213
|
+
selector.onCancel = () => {
|
|
3214
|
+
deps.closeOverlay();
|
|
3215
|
+
deps.chatLog.addSystem("local shell: cancelled");
|
|
3216
|
+
deps.tui.requestRender();
|
|
3217
|
+
resolve(false);
|
|
3218
|
+
};
|
|
3219
|
+
deps.openOverlay(selector);
|
|
3220
|
+
deps.tui.requestRender();
|
|
3221
|
+
});
|
|
3222
|
+
};
|
|
3223
|
+
const runLocalShellLine = async (line) => {
|
|
3224
|
+
const cmd = line.slice(1);
|
|
3225
|
+
if (cmd === "") return;
|
|
3226
|
+
if (localExecAsked && !localExecAllowed) {
|
|
3227
|
+
deps.chatLog.addSystem("local shell: not enabled for this session");
|
|
3228
|
+
deps.tui.requestRender();
|
|
3229
|
+
return;
|
|
3230
|
+
}
|
|
3231
|
+
if (!await ensureLocalExecAllowed()) return;
|
|
3232
|
+
deps.chatLog.addSystem(`[local] $ ${cmd}`);
|
|
3233
|
+
deps.tui.requestRender();
|
|
3234
|
+
const appendWithCap = (text, chunk) => {
|
|
3235
|
+
const combined = text + chunk;
|
|
3236
|
+
return combined.length > maxChars ? combined.slice(-maxChars) : combined;
|
|
3237
|
+
};
|
|
3238
|
+
await new Promise((resolve) => {
|
|
3239
|
+
const child = spawnCommand(cmd, {
|
|
3240
|
+
shell: true,
|
|
3241
|
+
cwd: getCwd(),
|
|
3242
|
+
env: {
|
|
3243
|
+
...env,
|
|
3244
|
+
DAOCORE_SHELL: "tui-local"
|
|
3245
|
+
}
|
|
3246
|
+
});
|
|
3247
|
+
let stdout = "";
|
|
3248
|
+
let stderr = "";
|
|
3249
|
+
child.stdout.on("data", (buf) => {
|
|
3250
|
+
stdout = appendWithCap(stdout, buf.toString("utf8"));
|
|
3251
|
+
});
|
|
3252
|
+
child.stderr.on("data", (buf) => {
|
|
3253
|
+
stderr = appendWithCap(stderr, buf.toString("utf8"));
|
|
3254
|
+
});
|
|
3255
|
+
child.on("close", (code, signal) => {
|
|
3256
|
+
const combined = (stdout + (stderr ? (stdout ? "\n" : "") + stderr : "")).slice(0, maxChars).trimEnd();
|
|
3257
|
+
if (combined) for (const line of combined.split("\n")) deps.chatLog.addSystem(`[local] ${line}`);
|
|
3258
|
+
deps.chatLog.addSystem(`[local] exit ${code ?? "?"}${signal ? ` (signal ${signal})` : ""}`);
|
|
3259
|
+
deps.tui.requestRender();
|
|
3260
|
+
resolve();
|
|
3261
|
+
});
|
|
3262
|
+
child.on("error", (err) => {
|
|
3263
|
+
deps.chatLog.addSystem(`[local] error: ${String(err)}`);
|
|
3264
|
+
deps.tui.requestRender();
|
|
3265
|
+
resolve();
|
|
3266
|
+
});
|
|
3267
|
+
});
|
|
3268
|
+
};
|
|
3269
|
+
return { runLocalShellLine };
|
|
3270
|
+
}
|
|
3271
|
+
//#endregion
|
|
3272
|
+
//#region src/tui/tui-overlays.ts
|
|
3273
|
+
function createOverlayHandlers(host, fallbackFocus) {
|
|
3274
|
+
const openOverlay = (component) => {
|
|
3275
|
+
host.showOverlay(component);
|
|
3276
|
+
};
|
|
3277
|
+
const closeOverlay = () => {
|
|
3278
|
+
if (host.hasOverlay()) {
|
|
3279
|
+
host.hideOverlay();
|
|
3280
|
+
return;
|
|
3281
|
+
}
|
|
3282
|
+
host.setFocus(fallbackFocus);
|
|
3283
|
+
};
|
|
3284
|
+
return {
|
|
3285
|
+
openOverlay,
|
|
3286
|
+
closeOverlay
|
|
3287
|
+
};
|
|
3288
|
+
}
|
|
3289
|
+
//#endregion
|
|
3290
|
+
//#region src/tui/tui-session-actions.ts
|
|
3291
|
+
function createSessionActions(context) {
|
|
3292
|
+
const { client, chatLog, btw, tui, opts, state, agentNames, initialSessionInput, initialSessionAgentId, resolveSessionKey, updateHeader, updateFooter, updateAutocompleteProvider, setActivityStatus, clearLocalRunIds, rememberSessionKey } = context;
|
|
3293
|
+
let refreshSessionInfoPromise = Promise.resolve();
|
|
3294
|
+
let lastSessionDefaults = null;
|
|
3295
|
+
const applyAgentsResult = (result) => {
|
|
3296
|
+
state.agentDefaultId = normalizeAgentId(result.defaultId);
|
|
3297
|
+
state.sessionMainKey = normalizeMainKey(result.mainKey);
|
|
3298
|
+
state.sessionScope = result.scope ?? state.sessionScope;
|
|
3299
|
+
state.agents = result.agents.map((agent) => ({
|
|
3300
|
+
id: normalizeAgentId(agent.id),
|
|
3301
|
+
name: normalizeOptionalString(agent.name)
|
|
3302
|
+
}));
|
|
3303
|
+
agentNames.clear();
|
|
3304
|
+
for (const agent of state.agents) if (agent.name) agentNames.set(agent.id, agent.name);
|
|
3305
|
+
if (!state.initialSessionApplied) {
|
|
3306
|
+
if (initialSessionAgentId) {
|
|
3307
|
+
if (state.agents.some((agent) => agent.id === initialSessionAgentId)) state.currentAgentId = initialSessionAgentId;
|
|
3308
|
+
} else if (!state.agents.some((agent) => agent.id === state.currentAgentId)) state.currentAgentId = state.agents[0]?.id ?? normalizeAgentId(result.defaultId ?? state.currentAgentId);
|
|
3309
|
+
const nextSessionKey = resolveSessionKey(initialSessionInput);
|
|
3310
|
+
if (nextSessionKey !== state.currentSessionKey) state.currentSessionKey = nextSessionKey;
|
|
3311
|
+
state.initialSessionApplied = true;
|
|
3312
|
+
} else if (!state.agents.some((agent) => agent.id === state.currentAgentId)) state.currentAgentId = state.agents[0]?.id ?? normalizeAgentId(result.defaultId ?? state.currentAgentId);
|
|
3313
|
+
updateHeader();
|
|
3314
|
+
updateFooter();
|
|
3315
|
+
};
|
|
3316
|
+
const refreshAgents = async () => {
|
|
3317
|
+
try {
|
|
3318
|
+
applyAgentsResult(await client.listAgents());
|
|
3319
|
+
} catch (err) {
|
|
3320
|
+
chatLog.addSystem(`agents list failed: ${String(err)}`);
|
|
3321
|
+
}
|
|
3322
|
+
};
|
|
3323
|
+
const updateAgentFromSessionKey = (key) => {
|
|
3324
|
+
const parsed = parseAgentSessionKey(key);
|
|
3325
|
+
if (!parsed) return;
|
|
3326
|
+
const next = normalizeAgentId(parsed.agentId);
|
|
3327
|
+
if (next !== state.currentAgentId) state.currentAgentId = next;
|
|
3328
|
+
};
|
|
3329
|
+
const resolveModelSelection = (entry) => {
|
|
3330
|
+
return resolveSessionInfoModelSelection({
|
|
3331
|
+
currentProvider: state.sessionInfo.modelProvider,
|
|
3332
|
+
currentModel: state.sessionInfo.model,
|
|
3333
|
+
defaultProvider: lastSessionDefaults?.modelProvider,
|
|
3334
|
+
defaultModel: lastSessionDefaults?.model,
|
|
3335
|
+
entryProvider: entry?.modelProvider,
|
|
3336
|
+
entryModel: entry?.model,
|
|
3337
|
+
overrideProvider: entry?.providerOverride,
|
|
3338
|
+
overrideModel: entry?.modelOverride
|
|
3339
|
+
});
|
|
3340
|
+
};
|
|
3341
|
+
const applySessionInfo = (params) => {
|
|
3342
|
+
const entry = params.entry ?? void 0;
|
|
3343
|
+
const defaults = params.defaults ?? lastSessionDefaults ?? void 0;
|
|
3344
|
+
const previousDefaults = lastSessionDefaults;
|
|
3345
|
+
const defaultsChanged = params.defaults ? previousDefaults?.model !== params.defaults.model || previousDefaults?.modelProvider !== params.defaults.modelProvider || previousDefaults?.contextTokens !== params.defaults.contextTokens : false;
|
|
3346
|
+
if (params.defaults) lastSessionDefaults = params.defaults;
|
|
3347
|
+
const entryUpdatedAt = entry?.updatedAt ?? null;
|
|
3348
|
+
const currentUpdatedAt = state.sessionInfo.updatedAt ?? null;
|
|
3349
|
+
if (!params.force && entryUpdatedAt !== null && currentUpdatedAt !== null && entryUpdatedAt < currentUpdatedAt && !defaultsChanged) return;
|
|
3350
|
+
const next = { ...state.sessionInfo };
|
|
3351
|
+
if (entry?.thinkingLevel !== void 0) next.thinkingLevel = entry.thinkingLevel;
|
|
3352
|
+
if (entry?.thinkingLevels !== void 0 || defaults?.thinkingLevels !== void 0) next.thinkingLevels = entry?.thinkingLevels ?? defaults?.thinkingLevels;
|
|
3353
|
+
if (entry?.fastMode !== void 0) next.fastMode = entry.fastMode;
|
|
3354
|
+
if (entry?.verboseLevel !== void 0) next.verboseLevel = entry.verboseLevel;
|
|
3355
|
+
if (entry?.traceLevel !== void 0) next.traceLevel = entry.traceLevel;
|
|
3356
|
+
if (entry?.reasoningLevel !== void 0) next.reasoningLevel = entry.reasoningLevel;
|
|
3357
|
+
if (entry?.responseUsage !== void 0) next.responseUsage = entry.responseUsage;
|
|
3358
|
+
if (entry?.inputTokens !== void 0) next.inputTokens = entry.inputTokens;
|
|
3359
|
+
if (entry?.outputTokens !== void 0) next.outputTokens = entry.outputTokens;
|
|
3360
|
+
if (entry?.totalTokens !== void 0) next.totalTokens = entry.totalTokens;
|
|
3361
|
+
if (entry?.contextTokens !== void 0 || defaults?.contextTokens !== void 0) next.contextTokens = entry?.contextTokens ?? defaults?.contextTokens ?? state.sessionInfo.contextTokens;
|
|
3362
|
+
if (entry?.displayName !== void 0) next.displayName = entry.displayName;
|
|
3363
|
+
if (entry?.updatedAt !== void 0) next.updatedAt = entry.updatedAt;
|
|
3364
|
+
const selection = resolveModelSelection(entry);
|
|
3365
|
+
if (selection.modelProvider !== void 0) next.modelProvider = selection.modelProvider;
|
|
3366
|
+
if (selection.model !== void 0) next.model = selection.model;
|
|
3367
|
+
state.sessionInfo = next;
|
|
3368
|
+
updateAutocompleteProvider();
|
|
3369
|
+
updateFooter();
|
|
3370
|
+
tui.requestRender();
|
|
3371
|
+
};
|
|
3372
|
+
const runRefreshSessionInfo = async () => {
|
|
3373
|
+
try {
|
|
3374
|
+
const resolveListAgentId = () => {
|
|
3375
|
+
if (state.currentSessionKey === "global" || state.currentSessionKey === "unknown") return;
|
|
3376
|
+
const parsed = parseAgentSessionKey(state.currentSessionKey);
|
|
3377
|
+
return parsed?.agentId ? normalizeAgentId(parsed.agentId) : state.currentAgentId;
|
|
3378
|
+
};
|
|
3379
|
+
const listAgentId = resolveListAgentId();
|
|
3380
|
+
const result = await client.listSessions({
|
|
3381
|
+
limit: 5,
|
|
3382
|
+
search: state.currentSessionKey,
|
|
3383
|
+
includeGlobal: false,
|
|
3384
|
+
includeUnknown: false,
|
|
3385
|
+
agentId: listAgentId
|
|
3386
|
+
});
|
|
3387
|
+
const normalizeMatchKey = (key) => parseAgentSessionKey(key)?.rest ?? key;
|
|
3388
|
+
const currentMatchKey = normalizeMatchKey(state.currentSessionKey);
|
|
3389
|
+
const entry = result.sessions.find((row) => {
|
|
3390
|
+
if (row.key === state.currentSessionKey) return true;
|
|
3391
|
+
return normalizeMatchKey(row.key) === currentMatchKey;
|
|
3392
|
+
});
|
|
3393
|
+
if (entry?.key && entry.key !== state.currentSessionKey) {
|
|
3394
|
+
updateAgentFromSessionKey(entry.key);
|
|
3395
|
+
state.currentSessionKey = entry.key;
|
|
3396
|
+
updateHeader();
|
|
3397
|
+
}
|
|
3398
|
+
applySessionInfo({
|
|
3399
|
+
entry,
|
|
3400
|
+
defaults: result.defaults
|
|
3401
|
+
});
|
|
3402
|
+
} catch (err) {
|
|
3403
|
+
chatLog.addSystem(`sessions list failed: ${String(err)}`);
|
|
3404
|
+
}
|
|
3405
|
+
};
|
|
3406
|
+
const refreshSessionInfo = async () => {
|
|
3407
|
+
refreshSessionInfoPromise = refreshSessionInfoPromise.then(runRefreshSessionInfo, runRefreshSessionInfo);
|
|
3408
|
+
await refreshSessionInfoPromise;
|
|
3409
|
+
};
|
|
3410
|
+
const applySessionInfoFromPatch = (result) => {
|
|
3411
|
+
if (!result?.entry) return;
|
|
3412
|
+
if (result.key && result.key !== state.currentSessionKey) {
|
|
3413
|
+
updateAgentFromSessionKey(result.key);
|
|
3414
|
+
state.currentSessionKey = result.key;
|
|
3415
|
+
updateHeader();
|
|
3416
|
+
}
|
|
3417
|
+
const resolved = result.resolved;
|
|
3418
|
+
applySessionInfo({
|
|
3419
|
+
entry: resolved && (resolved.modelProvider || resolved.model) ? {
|
|
3420
|
+
...result.entry,
|
|
3421
|
+
modelProvider: resolved.modelProvider ?? result.entry.modelProvider,
|
|
3422
|
+
model: resolved.model ?? result.entry.model
|
|
3423
|
+
} : result.entry,
|
|
3424
|
+
force: true
|
|
3425
|
+
});
|
|
3426
|
+
};
|
|
3427
|
+
const loadHistory = async () => {
|
|
3428
|
+
try {
|
|
3429
|
+
const record = await client.loadHistory({
|
|
3430
|
+
sessionKey: state.currentSessionKey,
|
|
3431
|
+
limit: opts.historyLimit ?? 200
|
|
3432
|
+
});
|
|
3433
|
+
state.currentSessionId = typeof record.sessionId === "string" ? record.sessionId : null;
|
|
3434
|
+
state.sessionInfo.thinkingLevel = record.thinkingLevel ?? state.sessionInfo.thinkingLevel;
|
|
3435
|
+
state.sessionInfo.fastMode = record.fastMode ?? state.sessionInfo.fastMode;
|
|
3436
|
+
state.sessionInfo.verboseLevel = record.verboseLevel ?? state.sessionInfo.verboseLevel;
|
|
3437
|
+
state.sessionInfo.traceLevel = record.traceLevel ?? state.sessionInfo.traceLevel;
|
|
3438
|
+
const showTools = (state.sessionInfo.verboseLevel ?? "off") !== "off";
|
|
3439
|
+
chatLog.clearAll();
|
|
3440
|
+
btw.clear();
|
|
3441
|
+
chatLog.addSystem(`session ${state.currentSessionKey}`);
|
|
3442
|
+
for (const entry of record.messages ?? []) {
|
|
3443
|
+
if (!entry || typeof entry !== "object") continue;
|
|
3444
|
+
const message = entry;
|
|
3445
|
+
if (isCommandMessage(message)) {
|
|
3446
|
+
const text = extractTextFromMessage(message);
|
|
3447
|
+
if (text) chatLog.addSystem(text);
|
|
3448
|
+
continue;
|
|
3449
|
+
}
|
|
3450
|
+
if (message.role === "user") {
|
|
3451
|
+
const text = extractTextFromMessage(message);
|
|
3452
|
+
if (text) chatLog.addUser(text);
|
|
3453
|
+
continue;
|
|
3454
|
+
}
|
|
3455
|
+
if (message.role === "assistant") {
|
|
3456
|
+
const text = extractTextFromMessage(message, { includeThinking: state.showThinking });
|
|
3457
|
+
if (text) chatLog.finalizeAssistant(text);
|
|
3458
|
+
continue;
|
|
3459
|
+
}
|
|
3460
|
+
if (message.role === "toolResult") {
|
|
3461
|
+
if (!showTools) continue;
|
|
3462
|
+
const toolCallId = asString(message.toolCallId, "");
|
|
3463
|
+
const toolName = asString(message.toolName, "tool");
|
|
3464
|
+
chatLog.startTool(toolCallId, toolName, {}).setResult({
|
|
3465
|
+
content: Array.isArray(message.content) ? message.content : [],
|
|
3466
|
+
details: typeof message.details === "object" && message.details ? message.details : void 0
|
|
3467
|
+
}, { isError: Boolean(message.isError) });
|
|
3468
|
+
}
|
|
3469
|
+
}
|
|
3470
|
+
state.historyLoaded = true;
|
|
3471
|
+
rememberSessionKey?.(state.currentSessionKey);
|
|
3472
|
+
} catch (err) {
|
|
3473
|
+
chatLog.addSystem(`history failed: ${String(err)}`);
|
|
3474
|
+
}
|
|
3475
|
+
await refreshSessionInfo();
|
|
3476
|
+
tui.requestRender();
|
|
3477
|
+
};
|
|
3478
|
+
const setSession = async (rawKey) => {
|
|
3479
|
+
const nextKey = resolveSessionKey(rawKey);
|
|
3480
|
+
updateAgentFromSessionKey(nextKey);
|
|
3481
|
+
state.currentSessionKey = nextKey;
|
|
3482
|
+
state.activeChatRunId = null;
|
|
3483
|
+
state.pendingChatRunId = null;
|
|
3484
|
+
setActivityStatus("idle");
|
|
3485
|
+
state.currentSessionId = null;
|
|
3486
|
+
state.sessionInfo.updatedAt = null;
|
|
3487
|
+
state.historyLoaded = false;
|
|
3488
|
+
clearLocalRunIds?.();
|
|
3489
|
+
btw.clear();
|
|
3490
|
+
updateHeader();
|
|
3491
|
+
updateFooter();
|
|
3492
|
+
await loadHistory();
|
|
3493
|
+
};
|
|
3494
|
+
const abortActive = async () => {
|
|
3495
|
+
if (opts.local === true && state.activityStatus === "finishing context" && !state.pendingChatRunId) {
|
|
3496
|
+
chatLog.addSystem("agent is finishing context; wait for it to finish before aborting");
|
|
3497
|
+
tui.requestRender();
|
|
3498
|
+
return;
|
|
3499
|
+
}
|
|
3500
|
+
const runId = opts.local === true && state.activeChatRunId && state.pendingChatRunId ? state.pendingChatRunId : state.activeChatRunId ?? state.pendingChatRunId ?? null;
|
|
3501
|
+
if (!runId) {
|
|
3502
|
+
chatLog.addSystem("no active run", { coalesceConsecutive: true });
|
|
3503
|
+
tui.requestRender();
|
|
3504
|
+
return;
|
|
3505
|
+
}
|
|
3506
|
+
try {
|
|
3507
|
+
await client.abortChat({
|
|
3508
|
+
sessionKey: state.currentSessionKey,
|
|
3509
|
+
runId
|
|
3510
|
+
});
|
|
3511
|
+
state.pendingChatRunId = null;
|
|
3512
|
+
setActivityStatus("aborted");
|
|
3513
|
+
} catch (err) {
|
|
3514
|
+
chatLog.addSystem(`abort failed: ${String(err)}`);
|
|
3515
|
+
setActivityStatus("abort failed");
|
|
3516
|
+
}
|
|
3517
|
+
tui.requestRender();
|
|
3518
|
+
};
|
|
3519
|
+
return {
|
|
3520
|
+
applyAgentsResult,
|
|
3521
|
+
refreshAgents,
|
|
3522
|
+
refreshSessionInfo,
|
|
3523
|
+
applySessionInfoFromPatch,
|
|
3524
|
+
loadHistory,
|
|
3525
|
+
setSession,
|
|
3526
|
+
abortActive
|
|
3527
|
+
};
|
|
3528
|
+
}
|
|
3529
|
+
//#endregion
|
|
3530
|
+
//#region src/tui/tui-submit.ts
|
|
3531
|
+
function createEditorSubmitHandler(params) {
|
|
3532
|
+
return (text) => {
|
|
3533
|
+
const raw = text;
|
|
3534
|
+
const value = raw.trim();
|
|
3535
|
+
if (!value) {
|
|
3536
|
+
params.editor.setText("");
|
|
3537
|
+
return;
|
|
3538
|
+
}
|
|
3539
|
+
if (raw.startsWith("!") && raw !== "!") {
|
|
3540
|
+
params.editor.setText("");
|
|
3541
|
+
params.editor.addToHistory(raw);
|
|
3542
|
+
params.handleBangLine(raw);
|
|
3543
|
+
return;
|
|
3544
|
+
}
|
|
3545
|
+
if (value.startsWith("/")) {
|
|
3546
|
+
params.editor.setText("");
|
|
3547
|
+
params.editor.addToHistory(value);
|
|
3548
|
+
params.handleCommand(value);
|
|
3549
|
+
return;
|
|
3550
|
+
}
|
|
3551
|
+
if (params.canSubmitMessage && !params.canSubmitMessage()) {
|
|
3552
|
+
params.editor.setText(value);
|
|
3553
|
+
params.onBlockedMessageSubmit?.(value);
|
|
3554
|
+
return;
|
|
3555
|
+
}
|
|
3556
|
+
params.editor.setText("");
|
|
3557
|
+
params.editor.addToHistory(value);
|
|
3558
|
+
params.sendMessage(value);
|
|
3559
|
+
};
|
|
3560
|
+
}
|
|
3561
|
+
function shouldEnableWindowsGitBashPasteFallback(params) {
|
|
3562
|
+
const platform = params?.platform ?? process.platform;
|
|
3563
|
+
const env = params?.env ?? process.env;
|
|
3564
|
+
const termProgram = normalizeLowercaseStringOrEmpty(env.TERM_PROGRAM);
|
|
3565
|
+
if (platform === "darwin") {
|
|
3566
|
+
if (termProgram.includes("iterm") || termProgram.includes("apple_terminal")) return true;
|
|
3567
|
+
return false;
|
|
3568
|
+
}
|
|
3569
|
+
if (platform !== "win32") return false;
|
|
3570
|
+
const msystem = (env.MSYSTEM ?? "").toUpperCase();
|
|
3571
|
+
const shell = env.SHELL ?? "";
|
|
3572
|
+
if (msystem.startsWith("MINGW") || msystem.startsWith("MSYS")) return true;
|
|
3573
|
+
if (normalizeLowercaseStringOrEmpty(shell).includes("bash")) return true;
|
|
3574
|
+
return termProgram.includes("mintty");
|
|
3575
|
+
}
|
|
3576
|
+
function createSubmitBurstCoalescer(params) {
|
|
3577
|
+
const windowMs = Math.max(1, params.burstWindowMs ?? 50);
|
|
3578
|
+
const now = params.now ?? (() => Date.now());
|
|
3579
|
+
const setTimer = params.setTimer ?? setTimeout;
|
|
3580
|
+
const clearTimer = params.clearTimer ?? clearTimeout;
|
|
3581
|
+
let pending = null;
|
|
3582
|
+
let pendingAt = 0;
|
|
3583
|
+
let flushTimer = null;
|
|
3584
|
+
const clearFlushTimer = () => {
|
|
3585
|
+
if (!flushTimer) return;
|
|
3586
|
+
clearTimer(flushTimer);
|
|
3587
|
+
flushTimer = null;
|
|
3588
|
+
};
|
|
3589
|
+
const flushPending = () => {
|
|
3590
|
+
if (pending === null) return;
|
|
3591
|
+
const value = pending;
|
|
3592
|
+
pending = null;
|
|
3593
|
+
pendingAt = 0;
|
|
3594
|
+
clearFlushTimer();
|
|
3595
|
+
params.submit(value);
|
|
3596
|
+
};
|
|
3597
|
+
const scheduleFlush = () => {
|
|
3598
|
+
clearFlushTimer();
|
|
3599
|
+
flushTimer = setTimer(() => {
|
|
3600
|
+
flushPending();
|
|
3601
|
+
}, windowMs);
|
|
3602
|
+
};
|
|
3603
|
+
return (value) => {
|
|
3604
|
+
if (!params.enabled) {
|
|
3605
|
+
params.submit(value);
|
|
3606
|
+
return;
|
|
3607
|
+
}
|
|
3608
|
+
if (value.includes("\n")) {
|
|
3609
|
+
flushPending();
|
|
3610
|
+
params.submit(value);
|
|
3611
|
+
return;
|
|
3612
|
+
}
|
|
3613
|
+
const ts = now();
|
|
3614
|
+
if (pending === null) {
|
|
3615
|
+
pending = value;
|
|
3616
|
+
pendingAt = ts;
|
|
3617
|
+
scheduleFlush();
|
|
3618
|
+
return;
|
|
3619
|
+
}
|
|
3620
|
+
if (ts - pendingAt <= windowMs) {
|
|
3621
|
+
pending = `${pending}\n${value}`;
|
|
3622
|
+
pendingAt = ts;
|
|
3623
|
+
scheduleFlush();
|
|
3624
|
+
return;
|
|
3625
|
+
}
|
|
3626
|
+
flushPending();
|
|
3627
|
+
pending = value;
|
|
3628
|
+
pendingAt = ts;
|
|
3629
|
+
scheduleFlush();
|
|
3630
|
+
};
|
|
3631
|
+
}
|
|
3632
|
+
//#endregion
|
|
3633
|
+
//#region src/tui/tui-waiting.ts
|
|
3634
|
+
const defaultWaitingPhrases = [
|
|
3635
|
+
"flibbertigibbeting",
|
|
3636
|
+
"kerfuffling",
|
|
3637
|
+
"dillydallying",
|
|
3638
|
+
"twiddling thumbs",
|
|
3639
|
+
"noodling",
|
|
3640
|
+
"bamboozling",
|
|
3641
|
+
"moseying",
|
|
3642
|
+
"hobnobbing",
|
|
3643
|
+
"pondering",
|
|
3644
|
+
"conjuring"
|
|
3645
|
+
];
|
|
3646
|
+
function pickWaitingPhrase(tick, phrases = defaultWaitingPhrases) {
|
|
3647
|
+
return phrases[Math.floor(tick / 10) % phrases.length] ?? phrases[0] ?? "waiting";
|
|
3648
|
+
}
|
|
3649
|
+
function shimmerText(theme, text, tick) {
|
|
3650
|
+
const width = 6;
|
|
3651
|
+
const hi = (ch) => theme.bold(theme.accentSoft(ch));
|
|
3652
|
+
const pos = tick % (text.length + width);
|
|
3653
|
+
const start = Math.max(0, pos - width);
|
|
3654
|
+
const end = Math.min(text.length - 1, pos);
|
|
3655
|
+
let out = "";
|
|
3656
|
+
for (let i = 0; i < text.length; i++) {
|
|
3657
|
+
const ch = text[i];
|
|
3658
|
+
out += i >= start && i <= end ? hi(ch) : theme.dim(ch);
|
|
3659
|
+
}
|
|
3660
|
+
return out;
|
|
3661
|
+
}
|
|
3662
|
+
function buildWaitingStatusMessage(params) {
|
|
3663
|
+
const phrase = pickWaitingPhrase(params.tick, params.phrases);
|
|
3664
|
+
return `${shimmerText(params.theme, `${phrase}…`, params.tick)} • ${params.elapsed} | ${params.connectionStatus}`;
|
|
3665
|
+
}
|
|
3666
|
+
//#endregion
|
|
3667
|
+
//#region src/tui/tui.ts
|
|
3668
|
+
const DAOCORE_CLI_WRAPPER_PATH = fileURLToPath(new URL("../../daocore.mjs", import.meta.url));
|
|
3669
|
+
const DAOCORE_RUN_NODE_SCRIPT_PATH = fileURLToPath(new URL("../../scripts/run-node.mjs", import.meta.url));
|
|
3670
|
+
const DAOCORE_DIST_ENTRY_JS_PATH = fileURLToPath(new URL("../../dist/entry.js", import.meta.url));
|
|
3671
|
+
const DAOCORE_DIST_ENTRY_MJS_PATH = fileURLToPath(new URL("../../dist/entry.mjs", import.meta.url));
|
|
3672
|
+
const OPENAI_CODEX_PROVIDER = "openai-codex";
|
|
3673
|
+
/** Resolve the absolute path to the `codex` CLI binary, or `null` if not installed. */
|
|
3674
|
+
function resolveCodexCliBin() {
|
|
3675
|
+
try {
|
|
3676
|
+
return execFileSync(process.platform === "win32" ? "where" : "which", ["codex"], { encoding: "utf8" }).trim().split(/\r?\n/)[0] || null;
|
|
3677
|
+
} catch {
|
|
3678
|
+
return null;
|
|
3679
|
+
}
|
|
3680
|
+
}
|
|
3681
|
+
function resolveLocalAuthCliInvocation(params) {
|
|
3682
|
+
const hasDistEntry = params?.hasDistEntry ?? (existsSync(DAOCORE_DIST_ENTRY_JS_PATH) || existsSync(DAOCORE_DIST_ENTRY_MJS_PATH));
|
|
3683
|
+
const hasRunNodeScript = params?.hasRunNodeScript ?? existsSync(DAOCORE_RUN_NODE_SCRIPT_PATH);
|
|
3684
|
+
const command = params?.execPath ?? process.execPath;
|
|
3685
|
+
const wrapperPath = params?.wrapperPath ?? DAOCORE_CLI_WRAPPER_PATH;
|
|
3686
|
+
const runNodePath = params?.runNodePath ?? DAOCORE_RUN_NODE_SCRIPT_PATH;
|
|
3687
|
+
return hasDistEntry || !hasRunNodeScript ? {
|
|
3688
|
+
command,
|
|
3689
|
+
args: [
|
|
3690
|
+
wrapperPath,
|
|
3691
|
+
"models",
|
|
3692
|
+
"auth",
|
|
3693
|
+
"login"
|
|
3694
|
+
]
|
|
3695
|
+
} : {
|
|
3696
|
+
command,
|
|
3697
|
+
args: [
|
|
3698
|
+
runNodePath,
|
|
3699
|
+
"models",
|
|
3700
|
+
"auth",
|
|
3701
|
+
"login"
|
|
3702
|
+
]
|
|
3703
|
+
};
|
|
3704
|
+
}
|
|
3705
|
+
function resolveLocalAuthSpawnOptions(params) {
|
|
3706
|
+
return (params.platform ?? process.platform) === "win32" && /\.(cmd|bat)$/iu.test(params.command.trim()) ? { shell: true } : {};
|
|
3707
|
+
}
|
|
3708
|
+
function resolveLocalAuthSpawnCwd(params) {
|
|
3709
|
+
const defaultCwd = params.defaultCwd ?? process.cwd();
|
|
3710
|
+
const entryArg = params.args[0]?.trim();
|
|
3711
|
+
if (!entryArg) return defaultCwd;
|
|
3712
|
+
const entryBase = path.basename(entryArg).toLowerCase();
|
|
3713
|
+
if (entryBase === "daocore.mjs") return path.dirname(entryArg);
|
|
3714
|
+
if (entryBase === "run-node.mjs") return path.dirname(path.dirname(entryArg));
|
|
3715
|
+
return defaultCwd;
|
|
3716
|
+
}
|
|
3717
|
+
function resolveTuiSessionKey(params) {
|
|
3718
|
+
const trimmed = (params.raw ?? "").trim();
|
|
3719
|
+
if (!trimmed) {
|
|
3720
|
+
if (params.sessionScope === "global") return "global";
|
|
3721
|
+
return buildAgentMainSessionKey({
|
|
3722
|
+
agentId: params.currentAgentId,
|
|
3723
|
+
mainKey: params.sessionMainKey
|
|
3724
|
+
});
|
|
3725
|
+
}
|
|
3726
|
+
if (trimmed === "global" || trimmed === "unknown") return trimmed;
|
|
3727
|
+
if (trimmed.startsWith("agent:")) return normalizeLowercaseStringOrEmpty(trimmed);
|
|
3728
|
+
return `agent:${params.currentAgentId}:${normalizeLowercaseStringOrEmpty(trimmed)}`;
|
|
3729
|
+
}
|
|
3730
|
+
function resolveInitialTuiAgentId(params) {
|
|
3731
|
+
const parsed = parseAgentSessionKey((params.initialSessionInput ?? "").trim());
|
|
3732
|
+
if (parsed?.agentId) return normalizeAgentId(parsed.agentId);
|
|
3733
|
+
const inferredFromWorkspace = resolveAgentIdByWorkspacePath(params.cfg, params.cwd ?? process.cwd());
|
|
3734
|
+
if (inferredFromWorkspace) return inferredFromWorkspace;
|
|
3735
|
+
return normalizeAgentId(params.fallbackAgentId);
|
|
3736
|
+
}
|
|
3737
|
+
function resolveGatewayDisconnectState(reason) {
|
|
3738
|
+
const reasonLabel = reason?.trim() ? reason.trim() : "closed";
|
|
3739
|
+
if (/pairing required/i.test(reasonLabel)) return {
|
|
3740
|
+
connectionStatus: `gateway disconnected: ${reasonLabel}`,
|
|
3741
|
+
activityStatus: "pairing required: run daocore devices list",
|
|
3742
|
+
pairingHint: "Pairing required. Run `daocore devices list`, approve your request ID, then reconnect."
|
|
3743
|
+
};
|
|
3744
|
+
return {
|
|
3745
|
+
connectionStatus: `gateway disconnected: ${reasonLabel}`,
|
|
3746
|
+
activityStatus: "idle"
|
|
3747
|
+
};
|
|
3748
|
+
}
|
|
3749
|
+
function createBackspaceDeduper(params) {
|
|
3750
|
+
const dedupeWindowMs = Math.max(0, Math.floor(params?.dedupeWindowMs ?? 8));
|
|
3751
|
+
const now = params?.now ?? (() => Date.now());
|
|
3752
|
+
let lastBackspaceAt = -1;
|
|
3753
|
+
return (data) => {
|
|
3754
|
+
if (data !== "\b" && !matchesKey(data, Key.backspace)) return data;
|
|
3755
|
+
const ts = now();
|
|
3756
|
+
if (lastBackspaceAt >= 0 && ts - lastBackspaceAt <= dedupeWindowMs) return "";
|
|
3757
|
+
lastBackspaceAt = ts;
|
|
3758
|
+
return data;
|
|
3759
|
+
};
|
|
3760
|
+
}
|
|
3761
|
+
function isIgnorableTuiStopError(error) {
|
|
3762
|
+
if (!error || typeof error !== "object") return false;
|
|
3763
|
+
const err = error;
|
|
3764
|
+
const code = typeof err.code === "string" ? err.code : "";
|
|
3765
|
+
const syscall = typeof err.syscall === "string" ? err.syscall : "";
|
|
3766
|
+
const message = typeof err.message === "string" ? err.message : "";
|
|
3767
|
+
if (code === "EBADF" && syscall === "setRawMode") return true;
|
|
3768
|
+
return /setRawMode/i.test(message) && /EBADF/i.test(message);
|
|
3769
|
+
}
|
|
3770
|
+
function stopTuiSafely(stop) {
|
|
3771
|
+
try {
|
|
3772
|
+
stop();
|
|
3773
|
+
} catch (error) {
|
|
3774
|
+
if (!isIgnorableTuiStopError(error)) throw error;
|
|
3775
|
+
}
|
|
3776
|
+
}
|
|
3777
|
+
function isTuiTerminalLossError(error) {
|
|
3778
|
+
if (!error || typeof error !== "object") return false;
|
|
3779
|
+
const err = error;
|
|
3780
|
+
const code = typeof err.code === "string" ? err.code : "";
|
|
3781
|
+
const message = typeof err.message === "string" ? err.message : "";
|
|
3782
|
+
const syscall = typeof err.syscall === "string" ? err.syscall : "";
|
|
3783
|
+
if (code === "EIO" || code === "EPIPE") return true;
|
|
3784
|
+
return /\b(EIO|EPIPE)\b/i.test(message) && /\b(read|write|TTY|stdin|stdout)\b/i.test(message + syscall);
|
|
3785
|
+
}
|
|
3786
|
+
function installTuiTerminalLossExitHandler(requestExit, targets = {
|
|
3787
|
+
stdin: process.stdin,
|
|
3788
|
+
stdout: process.stdout
|
|
3789
|
+
}) {
|
|
3790
|
+
let requested = false;
|
|
3791
|
+
const requestOnce = () => {
|
|
3792
|
+
if (requested) return;
|
|
3793
|
+
requested = true;
|
|
3794
|
+
requestExit();
|
|
3795
|
+
};
|
|
3796
|
+
const removeUncaughtExceptionHandler = registerUncaughtExceptionHandler((error) => {
|
|
3797
|
+
if (!isTuiTerminalLossError(error)) return false;
|
|
3798
|
+
requestOnce();
|
|
3799
|
+
return true;
|
|
3800
|
+
});
|
|
3801
|
+
const onClose = () => requestOnce();
|
|
3802
|
+
targets.stdin?.on("end", onClose);
|
|
3803
|
+
targets.stdin?.on("close", onClose);
|
|
3804
|
+
targets.stdout?.on("close", onClose);
|
|
3805
|
+
return () => {
|
|
3806
|
+
removeUncaughtExceptionHandler();
|
|
3807
|
+
targets.stdin?.off("end", onClose);
|
|
3808
|
+
targets.stdin?.off("close", onClose);
|
|
3809
|
+
targets.stdout?.off("close", onClose);
|
|
3810
|
+
};
|
|
3811
|
+
}
|
|
3812
|
+
function createDeferredTuiFinish() {
|
|
3813
|
+
let finishTui = null;
|
|
3814
|
+
let finishRequested = false;
|
|
3815
|
+
return {
|
|
3816
|
+
requestFinish: () => {
|
|
3817
|
+
const finish = finishTui;
|
|
3818
|
+
if (finish) {
|
|
3819
|
+
finish();
|
|
3820
|
+
return;
|
|
3821
|
+
}
|
|
3822
|
+
finishRequested = true;
|
|
3823
|
+
},
|
|
3824
|
+
setFinish: (finish) => {
|
|
3825
|
+
finishTui = finish;
|
|
3826
|
+
if (finishRequested) finish();
|
|
3827
|
+
},
|
|
3828
|
+
clearFinish: () => {
|
|
3829
|
+
finishTui = null;
|
|
3830
|
+
}
|
|
3831
|
+
};
|
|
3832
|
+
}
|
|
3833
|
+
const TUI_SHUTDOWN_DRAIN_MAX_MS = 500;
|
|
3834
|
+
const TUI_SHUTDOWN_DRAIN_IDLE_MS = 100;
|
|
3835
|
+
const TUI_SHUTDOWN_HARD_EXIT_MS = 2e3;
|
|
3836
|
+
const TUI_PROCESS_EXIT_AFTER_RETURN_MS = 2e3;
|
|
3837
|
+
async function drainAndStopTuiSafely(tui) {
|
|
3838
|
+
if (typeof tui.terminal?.drainInput === "function") try {
|
|
3839
|
+
await tui.terminal.drainInput(TUI_SHUTDOWN_DRAIN_MAX_MS, TUI_SHUTDOWN_DRAIN_IDLE_MS);
|
|
3840
|
+
} catch {}
|
|
3841
|
+
stopTuiSafely(() => tui.stop());
|
|
3842
|
+
}
|
|
3843
|
+
function canSubmitTuiChatMessage(params) {
|
|
3844
|
+
const pending = Boolean(params.pendingChatRunId) || params.pendingOptimisticUserMessage === true;
|
|
3845
|
+
if (params.activeChatRunId) return params.local === true && params.activityStatus === "finishing context" && !pending;
|
|
3846
|
+
return !pending;
|
|
3847
|
+
}
|
|
3848
|
+
const TUI_BUSY_ACTIVITY_STATUSES = new Set([
|
|
3849
|
+
"sending",
|
|
3850
|
+
"waiting",
|
|
3851
|
+
"streaming",
|
|
3852
|
+
"running",
|
|
3853
|
+
"finishing context"
|
|
3854
|
+
]);
|
|
3855
|
+
function isTuiBusyActivityStatus(status) {
|
|
3856
|
+
return TUI_BUSY_ACTIVITY_STATUSES.has(status);
|
|
3857
|
+
}
|
|
3858
|
+
function resolveTuiShutdownHardExitMs(params = {}) {
|
|
3859
|
+
return TUI_SHUTDOWN_HARD_EXIT_MS + (params.localMode ? resolveLocalRunShutdownGraceMs() : 0);
|
|
3860
|
+
}
|
|
3861
|
+
function scheduleProcessExitAfterTuiReturn(params = {}) {
|
|
3862
|
+
const delayMs = Math.max(0, Math.floor(params.delayMs ?? TUI_PROCESS_EXIT_AFTER_RETURN_MS));
|
|
3863
|
+
const setTimeoutFn = params.setTimeoutFn ?? ((callback, timeoutMs) => setTimeout(callback, timeoutMs));
|
|
3864
|
+
const exit = params.exit ?? ((code) => process.exit(code));
|
|
3865
|
+
const writeStderr = params.writeStderr ?? ((text) => {
|
|
3866
|
+
process.stderr.write(text);
|
|
3867
|
+
});
|
|
3868
|
+
const timer = setTimeoutFn(() => {
|
|
3869
|
+
try {
|
|
3870
|
+
writeStderr("daocore tui forcing process exit after return\n");
|
|
3871
|
+
} catch {}
|
|
3872
|
+
exit(0);
|
|
3873
|
+
}, delayMs);
|
|
3874
|
+
timer.unref?.();
|
|
3875
|
+
return timer;
|
|
3876
|
+
}
|
|
3877
|
+
function resolveCtrlCAction(params) {
|
|
3878
|
+
const exitWindowMs = Math.max(1, Math.floor(params.exitWindowMs ?? 1e3));
|
|
3879
|
+
if (params.hasInput) return {
|
|
3880
|
+
action: "clear",
|
|
3881
|
+
nextLastCtrlCAt: params.now
|
|
3882
|
+
};
|
|
3883
|
+
if (params.now - params.lastCtrlCAt <= exitWindowMs) return {
|
|
3884
|
+
action: "exit",
|
|
3885
|
+
nextLastCtrlCAt: params.lastCtrlCAt
|
|
3886
|
+
};
|
|
3887
|
+
return {
|
|
3888
|
+
action: "warn",
|
|
3889
|
+
nextLastCtrlCAt: params.now
|
|
3890
|
+
};
|
|
3891
|
+
}
|
|
3892
|
+
function resolveTuiCtrlCAction(params) {
|
|
3893
|
+
if (params.exitRequested === true) return {
|
|
3894
|
+
action: "force-exit",
|
|
3895
|
+
nextLastCtrlCAt: params.lastCtrlCAt
|
|
3896
|
+
};
|
|
3897
|
+
if (params.wasDisconnected === true) return {
|
|
3898
|
+
action: "exit",
|
|
3899
|
+
nextLastCtrlCAt: params.lastCtrlCAt
|
|
3900
|
+
};
|
|
3901
|
+
return resolveCtrlCAction(params);
|
|
3902
|
+
}
|
|
3903
|
+
async function runTui(opts) {
|
|
3904
|
+
const isLocalMode = opts.local === true || opts.backend !== void 0;
|
|
3905
|
+
const config = opts.config ?? getRuntimeConfig({ skipPluginValidation: !isLocalMode });
|
|
3906
|
+
const initialSessionInput = (opts.session ?? "").trim();
|
|
3907
|
+
let sessionScope = config.session?.scope ?? "per-sender";
|
|
3908
|
+
let sessionMainKey = normalizeMainKey(config.session?.mainKey);
|
|
3909
|
+
let agentDefaultId = resolveDefaultAgentId(config);
|
|
3910
|
+
let currentAgentId = resolveInitialTuiAgentId({
|
|
3911
|
+
cfg: config,
|
|
3912
|
+
fallbackAgentId: agentDefaultId,
|
|
3913
|
+
initialSessionInput,
|
|
3914
|
+
cwd: process.cwd()
|
|
3915
|
+
});
|
|
3916
|
+
let agents = [];
|
|
3917
|
+
const agentNames = /* @__PURE__ */ new Map();
|
|
3918
|
+
let currentSessionKey = "";
|
|
3919
|
+
let initialSessionApplied = false;
|
|
3920
|
+
let rememberedSessionApplied = false;
|
|
3921
|
+
let currentSessionId = null;
|
|
3922
|
+
let activeChatRunId = null;
|
|
3923
|
+
let pendingOptimisticUserMessage = false;
|
|
3924
|
+
let pendingChatRunId = null;
|
|
3925
|
+
let historyLoaded = false;
|
|
3926
|
+
let isConnected = false;
|
|
3927
|
+
let wasDisconnected = false;
|
|
3928
|
+
let toolsExpanded = false;
|
|
3929
|
+
let showThinking = false;
|
|
3930
|
+
let pairingHintShown = false;
|
|
3931
|
+
const localRunIds = /* @__PURE__ */ new Set();
|
|
3932
|
+
const localBtwRunIds = /* @__PURE__ */ new Set();
|
|
3933
|
+
const deliverDefault = opts.deliver ?? false;
|
|
3934
|
+
const autoMessage = opts.message?.trim();
|
|
3935
|
+
let autoMessageSent = false;
|
|
3936
|
+
let sessionInfo = {};
|
|
3937
|
+
let dynamicSlashCommands = [];
|
|
3938
|
+
let dynamicSlashCommandsKey = null;
|
|
3939
|
+
let dynamicSlashCommandsInFlightKey = null;
|
|
3940
|
+
let dynamicSlashCommandsRequestId = 0;
|
|
3941
|
+
let lastCtrlCAt = 0;
|
|
3942
|
+
let exitRequested = false;
|
|
3943
|
+
let exitResult = { exitReason: "exit" };
|
|
3944
|
+
let activityStatus = "idle";
|
|
3945
|
+
let connectionStatus = isLocalMode ? "starting local runtime" : "connecting";
|
|
3946
|
+
let statusTimeout = null;
|
|
3947
|
+
let statusTimer = null;
|
|
3948
|
+
let statusStartedAt = null;
|
|
3949
|
+
let lastActivityStatus = activityStatus;
|
|
3950
|
+
const state = {
|
|
3951
|
+
get agentDefaultId() {
|
|
3952
|
+
return agentDefaultId;
|
|
3953
|
+
},
|
|
3954
|
+
set agentDefaultId(value) {
|
|
3955
|
+
agentDefaultId = value;
|
|
3956
|
+
},
|
|
3957
|
+
get sessionMainKey() {
|
|
3958
|
+
return sessionMainKey;
|
|
3959
|
+
},
|
|
3960
|
+
set sessionMainKey(value) {
|
|
3961
|
+
sessionMainKey = value;
|
|
3962
|
+
},
|
|
3963
|
+
get sessionScope() {
|
|
3964
|
+
return sessionScope;
|
|
3965
|
+
},
|
|
3966
|
+
set sessionScope(value) {
|
|
3967
|
+
sessionScope = value;
|
|
3968
|
+
},
|
|
3969
|
+
get agents() {
|
|
3970
|
+
return agents;
|
|
3971
|
+
},
|
|
3972
|
+
set agents(value) {
|
|
3973
|
+
agents = value;
|
|
3974
|
+
},
|
|
3975
|
+
get currentAgentId() {
|
|
3976
|
+
return currentAgentId;
|
|
3977
|
+
},
|
|
3978
|
+
set currentAgentId(value) {
|
|
3979
|
+
currentAgentId = value;
|
|
3980
|
+
},
|
|
3981
|
+
get currentSessionKey() {
|
|
3982
|
+
return currentSessionKey;
|
|
3983
|
+
},
|
|
3984
|
+
set currentSessionKey(value) {
|
|
3985
|
+
currentSessionKey = value;
|
|
3986
|
+
},
|
|
3987
|
+
get currentSessionId() {
|
|
3988
|
+
return currentSessionId;
|
|
3989
|
+
},
|
|
3990
|
+
set currentSessionId(value) {
|
|
3991
|
+
currentSessionId = value;
|
|
3992
|
+
},
|
|
3993
|
+
get activeChatRunId() {
|
|
3994
|
+
return activeChatRunId;
|
|
3995
|
+
},
|
|
3996
|
+
set activeChatRunId(value) {
|
|
3997
|
+
activeChatRunId = value;
|
|
3998
|
+
},
|
|
3999
|
+
get pendingOptimisticUserMessage() {
|
|
4000
|
+
return pendingOptimisticUserMessage;
|
|
4001
|
+
},
|
|
4002
|
+
set pendingOptimisticUserMessage(value) {
|
|
4003
|
+
pendingOptimisticUserMessage = value;
|
|
4004
|
+
},
|
|
4005
|
+
get pendingChatRunId() {
|
|
4006
|
+
return pendingChatRunId;
|
|
4007
|
+
},
|
|
4008
|
+
set pendingChatRunId(value) {
|
|
4009
|
+
pendingChatRunId = value ?? null;
|
|
4010
|
+
},
|
|
4011
|
+
get historyLoaded() {
|
|
4012
|
+
return historyLoaded;
|
|
4013
|
+
},
|
|
4014
|
+
set historyLoaded(value) {
|
|
4015
|
+
historyLoaded = value;
|
|
4016
|
+
},
|
|
4017
|
+
get sessionInfo() {
|
|
4018
|
+
return sessionInfo;
|
|
4019
|
+
},
|
|
4020
|
+
set sessionInfo(value) {
|
|
4021
|
+
sessionInfo = value;
|
|
4022
|
+
},
|
|
4023
|
+
get initialSessionApplied() {
|
|
4024
|
+
return initialSessionApplied;
|
|
4025
|
+
},
|
|
4026
|
+
set initialSessionApplied(value) {
|
|
4027
|
+
initialSessionApplied = value;
|
|
4028
|
+
},
|
|
4029
|
+
get isConnected() {
|
|
4030
|
+
return isConnected;
|
|
4031
|
+
},
|
|
4032
|
+
set isConnected(value) {
|
|
4033
|
+
isConnected = value;
|
|
4034
|
+
},
|
|
4035
|
+
get autoMessageSent() {
|
|
4036
|
+
return autoMessageSent;
|
|
4037
|
+
},
|
|
4038
|
+
set autoMessageSent(value) {
|
|
4039
|
+
autoMessageSent = value;
|
|
4040
|
+
},
|
|
4041
|
+
get toolsExpanded() {
|
|
4042
|
+
return toolsExpanded;
|
|
4043
|
+
},
|
|
4044
|
+
set toolsExpanded(value) {
|
|
4045
|
+
toolsExpanded = value;
|
|
4046
|
+
},
|
|
4047
|
+
get showThinking() {
|
|
4048
|
+
return showThinking;
|
|
4049
|
+
},
|
|
4050
|
+
set showThinking(value) {
|
|
4051
|
+
showThinking = value;
|
|
4052
|
+
},
|
|
4053
|
+
get connectionStatus() {
|
|
4054
|
+
return connectionStatus;
|
|
4055
|
+
},
|
|
4056
|
+
set connectionStatus(value) {
|
|
4057
|
+
connectionStatus = value;
|
|
4058
|
+
},
|
|
4059
|
+
get activityStatus() {
|
|
4060
|
+
return activityStatus;
|
|
4061
|
+
},
|
|
4062
|
+
set activityStatus(value) {
|
|
4063
|
+
activityStatus = value;
|
|
4064
|
+
},
|
|
4065
|
+
get statusTimeout() {
|
|
4066
|
+
return statusTimeout;
|
|
4067
|
+
},
|
|
4068
|
+
set statusTimeout(value) {
|
|
4069
|
+
statusTimeout = value;
|
|
4070
|
+
},
|
|
4071
|
+
get lastCtrlCAt() {
|
|
4072
|
+
return lastCtrlCAt;
|
|
4073
|
+
},
|
|
4074
|
+
set lastCtrlCAt(value) {
|
|
4075
|
+
lastCtrlCAt = value;
|
|
4076
|
+
}
|
|
4077
|
+
};
|
|
4078
|
+
const noteLocalRunId = (runId) => {
|
|
4079
|
+
if (!runId) return;
|
|
4080
|
+
localRunIds.add(runId);
|
|
4081
|
+
if (localRunIds.size > 200) {
|
|
4082
|
+
const [first] = localRunIds;
|
|
4083
|
+
if (first) localRunIds.delete(first);
|
|
4084
|
+
}
|
|
4085
|
+
};
|
|
4086
|
+
const forgetLocalRunId = (runId) => {
|
|
4087
|
+
localRunIds.delete(runId);
|
|
4088
|
+
};
|
|
4089
|
+
const isLocalRunId = (runId) => localRunIds.has(runId);
|
|
4090
|
+
const clearLocalRunIds = () => {
|
|
4091
|
+
localRunIds.clear();
|
|
4092
|
+
};
|
|
4093
|
+
const noteLocalBtwRunId = (runId) => {
|
|
4094
|
+
if (!runId) return;
|
|
4095
|
+
localBtwRunIds.add(runId);
|
|
4096
|
+
if (localBtwRunIds.size > 200) {
|
|
4097
|
+
const [first] = localBtwRunIds;
|
|
4098
|
+
if (first) localBtwRunIds.delete(first);
|
|
4099
|
+
}
|
|
4100
|
+
};
|
|
4101
|
+
const forgetLocalBtwRunId = (runId) => {
|
|
4102
|
+
localBtwRunIds.delete(runId);
|
|
4103
|
+
};
|
|
4104
|
+
const isLocalBtwRunId = (runId) => localBtwRunIds.has(runId);
|
|
4105
|
+
const clearLocalBtwRunIds = () => {
|
|
4106
|
+
localBtwRunIds.clear();
|
|
4107
|
+
};
|
|
4108
|
+
let client;
|
|
4109
|
+
if (opts.backend) client = opts.backend;
|
|
4110
|
+
else if (opts.local) {
|
|
4111
|
+
const { EmbeddedTuiBackend } = await import("./embedded-backend-IYuqoxzv.js");
|
|
4112
|
+
client = new EmbeddedTuiBackend();
|
|
4113
|
+
} else client = await GatewayChatClient.connect({
|
|
4114
|
+
url: opts.url,
|
|
4115
|
+
token: opts.token,
|
|
4116
|
+
password: opts.password
|
|
4117
|
+
});
|
|
4118
|
+
const previousConsoleSubsystemFilter = isLocalMode ? loggingState.consoleSubsystemFilter ? [...loggingState.consoleSubsystemFilter] : null : null;
|
|
4119
|
+
if (isLocalMode) setConsoleSubsystemFilter(["__daocore_tui_quiet__"]);
|
|
4120
|
+
const tui = new TUI(new ProcessTerminal());
|
|
4121
|
+
const dedupeBackspace = createBackspaceDeduper();
|
|
4122
|
+
tui.addInputListener((data) => {
|
|
4123
|
+
const next = dedupeBackspace(data);
|
|
4124
|
+
if (next.length === 0) return { consume: true };
|
|
4125
|
+
return { data: next };
|
|
4126
|
+
});
|
|
4127
|
+
const header = new Text("", 1, 0);
|
|
4128
|
+
const statusContainer = new Container();
|
|
4129
|
+
const footer = new Text("", 1, 0);
|
|
4130
|
+
const chatLog = new ChatLog();
|
|
4131
|
+
const editor = new CustomEditor(tui, editorTheme);
|
|
4132
|
+
const root = new Container();
|
|
4133
|
+
root.addChild(header);
|
|
4134
|
+
root.addChild(chatLog);
|
|
4135
|
+
root.addChild(statusContainer);
|
|
4136
|
+
root.addChild(footer);
|
|
4137
|
+
root.addChild(editor);
|
|
4138
|
+
const resolveDynamicSlashCommandsKey = () => currentAgentId;
|
|
4139
|
+
const applyAutocompleteProvider = () => {
|
|
4140
|
+
const dynamicKey = resolveDynamicSlashCommandsKey();
|
|
4141
|
+
editor.setAutocompleteProvider(new CombinedAutocompleteProvider(getSlashCommands({
|
|
4142
|
+
cfg: config,
|
|
4143
|
+
local: isLocalMode,
|
|
4144
|
+
provider: sessionInfo.modelProvider,
|
|
4145
|
+
model: sessionInfo.model,
|
|
4146
|
+
thinkingLevels: sessionInfo.thinkingLevels,
|
|
4147
|
+
dynamicCommands: dynamicSlashCommandsKey === dynamicKey ? dynamicSlashCommands : []
|
|
4148
|
+
}), process.cwd()));
|
|
4149
|
+
};
|
|
4150
|
+
const refreshDynamicSlashCommands = () => {
|
|
4151
|
+
const key = resolveDynamicSlashCommandsKey();
|
|
4152
|
+
if (!isConnected || !client.listCommands || dynamicSlashCommandsKey === key || dynamicSlashCommandsInFlightKey === key) return;
|
|
4153
|
+
dynamicSlashCommandsInFlightKey = key;
|
|
4154
|
+
const requestId = ++dynamicSlashCommandsRequestId;
|
|
4155
|
+
const agentId = currentAgentId;
|
|
4156
|
+
client.listCommands({
|
|
4157
|
+
agentId,
|
|
4158
|
+
scope: "text",
|
|
4159
|
+
includeArgs: false
|
|
4160
|
+
}).then((commands) => {
|
|
4161
|
+
if (requestId !== dynamicSlashCommandsRequestId || key !== resolveDynamicSlashCommandsKey()) return;
|
|
4162
|
+
dynamicSlashCommands = commands;
|
|
4163
|
+
dynamicSlashCommandsKey = key;
|
|
4164
|
+
applyAutocompleteProvider();
|
|
4165
|
+
}).catch(() => void 0).finally(() => {
|
|
4166
|
+
if (dynamicSlashCommandsInFlightKey === key) dynamicSlashCommandsInFlightKey = null;
|
|
4167
|
+
});
|
|
4168
|
+
};
|
|
4169
|
+
const updateAutocompleteProvider = () => {
|
|
4170
|
+
applyAutocompleteProvider();
|
|
4171
|
+
refreshDynamicSlashCommands();
|
|
4172
|
+
};
|
|
4173
|
+
tui.addChild(root);
|
|
4174
|
+
tui.setFocus(editor);
|
|
4175
|
+
const formatSessionKey = (key) => {
|
|
4176
|
+
if (key === "global" || key === "unknown") return key;
|
|
4177
|
+
return parseAgentSessionKey(key)?.rest ?? key;
|
|
4178
|
+
};
|
|
4179
|
+
const formatAgentLabel = (id) => {
|
|
4180
|
+
const name = agentNames.get(id);
|
|
4181
|
+
return name ? `${id} (${name})` : id;
|
|
4182
|
+
};
|
|
4183
|
+
const resolveSessionKey = (raw) => {
|
|
4184
|
+
return resolveTuiSessionKey({
|
|
4185
|
+
raw,
|
|
4186
|
+
sessionScope,
|
|
4187
|
+
currentAgentId,
|
|
4188
|
+
sessionMainKey
|
|
4189
|
+
});
|
|
4190
|
+
};
|
|
4191
|
+
currentSessionKey = resolveSessionKey(initialSessionInput);
|
|
4192
|
+
const buildLastSessionScopeKeyFor = (sessionKey = currentSessionKey) => {
|
|
4193
|
+
const parsed = parseAgentSessionKey(sessionKey);
|
|
4194
|
+
return buildTuiLastSessionScopeKey({
|
|
4195
|
+
connectionUrl: client.connection.url,
|
|
4196
|
+
agentId: parsed?.agentId ?? currentAgentId,
|
|
4197
|
+
sessionScope
|
|
4198
|
+
});
|
|
4199
|
+
};
|
|
4200
|
+
const rememberCurrentSessionKey = (sessionKey) => {
|
|
4201
|
+
const trimmed = sessionKey.trim();
|
|
4202
|
+
if (!trimmed || trimmed === "unknown") return;
|
|
4203
|
+
writeTuiLastSessionKey({
|
|
4204
|
+
scopeKey: buildLastSessionScopeKeyFor(trimmed),
|
|
4205
|
+
sessionKey: trimmed
|
|
4206
|
+
}).catch(() => void 0);
|
|
4207
|
+
};
|
|
4208
|
+
const restoreRememberedSession = async () => {
|
|
4209
|
+
if (initialSessionInput || rememberedSessionApplied) return;
|
|
4210
|
+
rememberedSessionApplied = true;
|
|
4211
|
+
const remembered = await readTuiLastSessionKey({ scopeKey: buildLastSessionScopeKeyFor() });
|
|
4212
|
+
const rememberedKey = remembered ? resolveSessionKey(remembered) : null;
|
|
4213
|
+
if (!rememberedKey || rememberedKey === currentSessionKey) return;
|
|
4214
|
+
const rememberedAgent = parseAgentSessionKey(rememberedKey)?.agentId;
|
|
4215
|
+
if (rememberedAgent && normalizeAgentId(rememberedAgent) !== currentAgentId) return;
|
|
4216
|
+
const sessions = await client.listSessions({
|
|
4217
|
+
limit: 5,
|
|
4218
|
+
search: rememberedKey,
|
|
4219
|
+
includeGlobal: false,
|
|
4220
|
+
includeUnknown: false,
|
|
4221
|
+
agentId: currentAgentId
|
|
4222
|
+
}).catch(() => null);
|
|
4223
|
+
if (!sessions) return;
|
|
4224
|
+
const restored = resolveRememberedTuiSessionKey({
|
|
4225
|
+
rememberedKey,
|
|
4226
|
+
currentAgentId,
|
|
4227
|
+
sessions: sessions.sessions
|
|
4228
|
+
});
|
|
4229
|
+
if (!restored || restored === currentSessionKey) return;
|
|
4230
|
+
currentSessionKey = restored;
|
|
4231
|
+
updateHeader();
|
|
4232
|
+
updateFooter();
|
|
4233
|
+
};
|
|
4234
|
+
const updateHeader = () => {
|
|
4235
|
+
const sessionLabel = formatSessionKey(currentSessionKey);
|
|
4236
|
+
const agentLabel = formatAgentLabel(currentAgentId);
|
|
4237
|
+
const title = opts.title ?? "daocore tui";
|
|
4238
|
+
header.setText(theme.header(`${title} - ${client.connection.url} - agent ${agentLabel} - session ${sessionLabel}`));
|
|
4239
|
+
};
|
|
4240
|
+
let statusText = null;
|
|
4241
|
+
let statusLoader = null;
|
|
4242
|
+
const formatElapsed = (startMs) => {
|
|
4243
|
+
const totalSeconds = Math.max(0, Math.floor((Date.now() - startMs) / 1e3));
|
|
4244
|
+
if (totalSeconds < 60) return `${totalSeconds}s`;
|
|
4245
|
+
return `${Math.floor(totalSeconds / 60)}m ${totalSeconds % 60}s`;
|
|
4246
|
+
};
|
|
4247
|
+
const ensureStatusText = () => {
|
|
4248
|
+
if (statusText) return;
|
|
4249
|
+
statusContainer.clear();
|
|
4250
|
+
statusLoader?.stop();
|
|
4251
|
+
statusLoader = null;
|
|
4252
|
+
statusText = new Text("", 1, 0);
|
|
4253
|
+
statusContainer.addChild(statusText);
|
|
4254
|
+
};
|
|
4255
|
+
const ensureStatusLoader = () => {
|
|
4256
|
+
if (statusLoader) return;
|
|
4257
|
+
statusContainer.clear();
|
|
4258
|
+
statusText = null;
|
|
4259
|
+
statusLoader = new Loader(tui, (spinner) => theme.accent(spinner), (text) => theme.bold(theme.accentSoft(text)), "");
|
|
4260
|
+
statusContainer.addChild(statusLoader);
|
|
4261
|
+
};
|
|
4262
|
+
let waitingTick = 0;
|
|
4263
|
+
let waitingTimer = null;
|
|
4264
|
+
let waitingPhrase = null;
|
|
4265
|
+
const updateBusyStatusMessage = () => {
|
|
4266
|
+
if (!statusLoader || !statusStartedAt) return;
|
|
4267
|
+
const elapsed = formatElapsed(statusStartedAt);
|
|
4268
|
+
if (activityStatus === "waiting") {
|
|
4269
|
+
waitingTick++;
|
|
4270
|
+
statusLoader.setMessage(buildWaitingStatusMessage({
|
|
4271
|
+
theme,
|
|
4272
|
+
tick: waitingTick,
|
|
4273
|
+
elapsed,
|
|
4274
|
+
connectionStatus,
|
|
4275
|
+
phrases: waitingPhrase ? [waitingPhrase] : void 0
|
|
4276
|
+
}));
|
|
4277
|
+
return;
|
|
4278
|
+
}
|
|
4279
|
+
statusLoader.setMessage(`${activityStatus} • ${elapsed} | ${connectionStatus}`);
|
|
4280
|
+
};
|
|
4281
|
+
const startStatusTimer = () => {
|
|
4282
|
+
if (statusTimer) return;
|
|
4283
|
+
statusTimer = setInterval(() => {
|
|
4284
|
+
if (!isTuiBusyActivityStatus(activityStatus)) return;
|
|
4285
|
+
updateBusyStatusMessage();
|
|
4286
|
+
}, 1e3);
|
|
4287
|
+
};
|
|
4288
|
+
const stopStatusTimer = () => {
|
|
4289
|
+
if (!statusTimer) return;
|
|
4290
|
+
clearInterval(statusTimer);
|
|
4291
|
+
statusTimer = null;
|
|
4292
|
+
};
|
|
4293
|
+
const startWaitingTimer = () => {
|
|
4294
|
+
if (waitingTimer) return;
|
|
4295
|
+
if (!waitingPhrase) waitingPhrase = defaultWaitingPhrases[Math.floor(Math.random() * defaultWaitingPhrases.length)] ?? defaultWaitingPhrases[0] ?? "waiting";
|
|
4296
|
+
waitingTick = 0;
|
|
4297
|
+
waitingTimer = setInterval(() => {
|
|
4298
|
+
if (activityStatus !== "waiting") return;
|
|
4299
|
+
updateBusyStatusMessage();
|
|
4300
|
+
}, 120);
|
|
4301
|
+
};
|
|
4302
|
+
const stopWaitingTimer = () => {
|
|
4303
|
+
if (!waitingTimer) return;
|
|
4304
|
+
clearInterval(waitingTimer);
|
|
4305
|
+
waitingTimer = null;
|
|
4306
|
+
waitingPhrase = null;
|
|
4307
|
+
};
|
|
4308
|
+
const renderStatus = () => {
|
|
4309
|
+
if (isTuiBusyActivityStatus(activityStatus)) {
|
|
4310
|
+
if (!statusStartedAt || lastActivityStatus !== activityStatus) statusStartedAt = Date.now();
|
|
4311
|
+
ensureStatusLoader();
|
|
4312
|
+
if (activityStatus === "waiting") {
|
|
4313
|
+
stopStatusTimer();
|
|
4314
|
+
startWaitingTimer();
|
|
4315
|
+
} else {
|
|
4316
|
+
stopWaitingTimer();
|
|
4317
|
+
startStatusTimer();
|
|
4318
|
+
}
|
|
4319
|
+
updateBusyStatusMessage();
|
|
4320
|
+
} else {
|
|
4321
|
+
statusStartedAt = null;
|
|
4322
|
+
stopStatusTimer();
|
|
4323
|
+
stopWaitingTimer();
|
|
4324
|
+
statusLoader?.stop();
|
|
4325
|
+
statusLoader = null;
|
|
4326
|
+
ensureStatusText();
|
|
4327
|
+
const text = activityStatus ? `${connectionStatus} | ${activityStatus}` : connectionStatus;
|
|
4328
|
+
statusText?.setText(theme.dim(text));
|
|
4329
|
+
}
|
|
4330
|
+
lastActivityStatus = activityStatus;
|
|
4331
|
+
};
|
|
4332
|
+
const setConnectionStatus = (text, ttlMs) => {
|
|
4333
|
+
connectionStatus = text;
|
|
4334
|
+
renderStatus();
|
|
4335
|
+
if (statusTimeout) clearTimeout(statusTimeout);
|
|
4336
|
+
if (ttlMs && ttlMs > 0) statusTimeout = setTimeout(() => {
|
|
4337
|
+
connectionStatus = isConnected ? isLocalMode ? "local ready" : "connected" : isLocalMode ? "local stopped" : "disconnected";
|
|
4338
|
+
renderStatus();
|
|
4339
|
+
}, ttlMs);
|
|
4340
|
+
};
|
|
4341
|
+
const setActivityStatus = (text) => {
|
|
4342
|
+
activityStatus = text;
|
|
4343
|
+
renderStatus();
|
|
4344
|
+
};
|
|
4345
|
+
const withTuiSuspended = async (work) => {
|
|
4346
|
+
await drainAndStopTuiSafely(tui);
|
|
4347
|
+
if (isLocalMode) setConsoleSubsystemFilter(previousConsoleSubsystemFilter);
|
|
4348
|
+
try {
|
|
4349
|
+
return await work();
|
|
4350
|
+
} finally {
|
|
4351
|
+
if (isLocalMode) setConsoleSubsystemFilter(["__daocore_tui_quiet__"]);
|
|
4352
|
+
tui.start();
|
|
4353
|
+
tui.setFocus(editor);
|
|
4354
|
+
updateHeader();
|
|
4355
|
+
updateFooter();
|
|
4356
|
+
tui.requestRender(true);
|
|
4357
|
+
}
|
|
4358
|
+
};
|
|
4359
|
+
const runAuthFlow = isLocalMode ? async (params) => await withTuiSuspended(async () => await new Promise((resolve, reject) => {
|
|
4360
|
+
const provider = params.provider?.trim() || void 0;
|
|
4361
|
+
const codexBin = provider === OPENAI_CODEX_PROVIDER || !provider && sessionInfo.modelProvider === OPENAI_CODEX_PROVIDER ? resolveCodexCliBin() : null;
|
|
4362
|
+
let command;
|
|
4363
|
+
let args;
|
|
4364
|
+
if (codexBin) {
|
|
4365
|
+
command = codexBin;
|
|
4366
|
+
args = ["login"];
|
|
4367
|
+
} else {
|
|
4368
|
+
({command, args} = resolveLocalAuthCliInvocation());
|
|
4369
|
+
if (provider) args.push("--provider", provider);
|
|
4370
|
+
}
|
|
4371
|
+
const child = spawn(command, args, {
|
|
4372
|
+
cwd: resolveLocalAuthSpawnCwd({
|
|
4373
|
+
args,
|
|
4374
|
+
defaultCwd: process.cwd()
|
|
4375
|
+
}),
|
|
4376
|
+
env: process.env,
|
|
4377
|
+
stdio: "inherit",
|
|
4378
|
+
...resolveLocalAuthSpawnOptions({ command })
|
|
4379
|
+
});
|
|
4380
|
+
child.once("error", reject);
|
|
4381
|
+
child.once("exit", (exitCode, signal) => {
|
|
4382
|
+
resolve({
|
|
4383
|
+
exitCode,
|
|
4384
|
+
signal
|
|
4385
|
+
});
|
|
4386
|
+
});
|
|
4387
|
+
})) : void 0;
|
|
4388
|
+
const updateFooter = () => {
|
|
4389
|
+
const sessionKeyLabel = formatSessionKey(currentSessionKey);
|
|
4390
|
+
const sessionLabel = sessionInfo.displayName ? `${sessionKeyLabel} (${sessionInfo.displayName})` : sessionKeyLabel;
|
|
4391
|
+
const agentLabel = formatAgentLabel(currentAgentId);
|
|
4392
|
+
const modelLabel = sessionInfo.model ? sessionInfo.modelProvider ? `${sessionInfo.modelProvider}/${sessionInfo.model}` : sessionInfo.model : "unknown";
|
|
4393
|
+
const tokens = formatTokens(sessionInfo.totalTokens ?? null, sessionInfo.contextTokens ?? null);
|
|
4394
|
+
const think = sessionInfo.thinkingLevel ?? "off";
|
|
4395
|
+
const fast = sessionInfo.fastMode === true;
|
|
4396
|
+
const verbose = sessionInfo.verboseLevel ?? "off";
|
|
4397
|
+
const reasoning = sessionInfo.reasoningLevel ?? "off";
|
|
4398
|
+
const reasoningLabel = reasoning === "on" ? "reasoning" : reasoning === "stream" ? "reasoning:stream" : null;
|
|
4399
|
+
const footerParts = [
|
|
4400
|
+
`agent ${agentLabel}`,
|
|
4401
|
+
`session ${sessionLabel}`,
|
|
4402
|
+
modelLabel,
|
|
4403
|
+
think !== "off" ? `think ${think}` : null,
|
|
4404
|
+
fast ? "fast" : null,
|
|
4405
|
+
verbose !== "off" ? `verbose ${verbose}` : null,
|
|
4406
|
+
reasoningLabel,
|
|
4407
|
+
tokens
|
|
4408
|
+
].filter(Boolean);
|
|
4409
|
+
footer.setText(theme.dim(footerParts.join(" | ")));
|
|
4410
|
+
};
|
|
4411
|
+
const { openOverlay, closeOverlay } = createOverlayHandlers(tui, editor);
|
|
4412
|
+
const btw = {
|
|
4413
|
+
showResult: (params) => {
|
|
4414
|
+
chatLog.showBtw(params);
|
|
4415
|
+
},
|
|
4416
|
+
clear: () => {
|
|
4417
|
+
chatLog.dismissBtw();
|
|
4418
|
+
}
|
|
4419
|
+
};
|
|
4420
|
+
const initialSessionAgentId = (() => {
|
|
4421
|
+
if (!initialSessionInput) return null;
|
|
4422
|
+
const parsed = parseAgentSessionKey(initialSessionInput);
|
|
4423
|
+
return parsed ? normalizeAgentId(parsed.agentId) : null;
|
|
4424
|
+
})();
|
|
4425
|
+
const { refreshAgents, refreshSessionInfo, applySessionInfoFromPatch, loadHistory, setSession, abortActive } = createSessionActions({
|
|
4426
|
+
client,
|
|
4427
|
+
chatLog,
|
|
4428
|
+
btw,
|
|
4429
|
+
tui,
|
|
4430
|
+
opts,
|
|
4431
|
+
state,
|
|
4432
|
+
agentNames,
|
|
4433
|
+
initialSessionInput,
|
|
4434
|
+
initialSessionAgentId,
|
|
4435
|
+
resolveSessionKey,
|
|
4436
|
+
updateHeader,
|
|
4437
|
+
updateFooter,
|
|
4438
|
+
updateAutocompleteProvider,
|
|
4439
|
+
setActivityStatus,
|
|
4440
|
+
clearLocalRunIds,
|
|
4441
|
+
rememberSessionKey: rememberCurrentSessionKey
|
|
4442
|
+
});
|
|
4443
|
+
const { handleChatEvent, handleAgentEvent, handleBtwEvent, pauseStreamingWatchdog, reconnectStreamingWatchdog } = createEventHandlers({
|
|
4444
|
+
chatLog,
|
|
4445
|
+
btw,
|
|
4446
|
+
tui,
|
|
4447
|
+
state,
|
|
4448
|
+
localMode: isLocalMode,
|
|
4449
|
+
setActivityStatus,
|
|
4450
|
+
refreshSessionInfo,
|
|
4451
|
+
loadHistory,
|
|
4452
|
+
noteLocalRunId,
|
|
4453
|
+
isLocalRunId,
|
|
4454
|
+
forgetLocalRunId,
|
|
4455
|
+
clearLocalRunIds,
|
|
4456
|
+
isLocalBtwRunId,
|
|
4457
|
+
forgetLocalBtwRunId,
|
|
4458
|
+
clearLocalBtwRunIds
|
|
4459
|
+
});
|
|
4460
|
+
const deferredFinish = createDeferredTuiFinish();
|
|
4461
|
+
const forceExit = () => {
|
|
4462
|
+
try {
|
|
4463
|
+
process.stderr.write("daocore tui forcing exit\n");
|
|
4464
|
+
} catch {}
|
|
4465
|
+
process.exit(130);
|
|
4466
|
+
};
|
|
4467
|
+
const requestExit = (result) => {
|
|
4468
|
+
if (exitRequested) {
|
|
4469
|
+
forceExit();
|
|
4470
|
+
return;
|
|
4471
|
+
}
|
|
4472
|
+
exitRequested = true;
|
|
4473
|
+
exitResult = {
|
|
4474
|
+
exitReason: result?.exitReason ?? "exit",
|
|
4475
|
+
...result?.crestodianMessage ? { crestodianMessage: result.crestodianMessage } : {}
|
|
4476
|
+
};
|
|
4477
|
+
const hardExitTimer = setTimeout(forceExit, resolveTuiShutdownHardExitMs({ localMode: isLocalMode }));
|
|
4478
|
+
hardExitTimer.unref?.();
|
|
4479
|
+
Promise.resolve().then(() => client.stop()).then(() => drainAndStopTuiSafely(tui)).finally(() => {
|
|
4480
|
+
clearTimeout(hardExitTimer);
|
|
4481
|
+
}).catch((err) => {
|
|
4482
|
+
if (!isTuiTerminalLossError(err)) try {
|
|
4483
|
+
process.stderr.write(`daocore tui shutdown failed: ${String(err)}\n`);
|
|
4484
|
+
} catch {}
|
|
4485
|
+
}).finally(() => {
|
|
4486
|
+
deferredFinish.requestFinish();
|
|
4487
|
+
});
|
|
4488
|
+
};
|
|
4489
|
+
client.setRequestExitHandler?.(() => requestExit());
|
|
4490
|
+
const { handleCommand, sendMessage, openModelSelector, openAgentSelector, openSessionSelector } = createCommandHandlers({
|
|
4491
|
+
client,
|
|
4492
|
+
chatLog,
|
|
4493
|
+
tui,
|
|
4494
|
+
opts,
|
|
4495
|
+
state,
|
|
4496
|
+
deliverDefault,
|
|
4497
|
+
openOverlay,
|
|
4498
|
+
closeOverlay,
|
|
4499
|
+
refreshSessionInfo,
|
|
4500
|
+
applySessionInfoFromPatch,
|
|
4501
|
+
loadHistory,
|
|
4502
|
+
setSession,
|
|
4503
|
+
refreshAgents,
|
|
4504
|
+
abortActive,
|
|
4505
|
+
setActivityStatus,
|
|
4506
|
+
formatSessionKey,
|
|
4507
|
+
noteLocalRunId,
|
|
4508
|
+
noteLocalBtwRunId,
|
|
4509
|
+
forgetLocalRunId,
|
|
4510
|
+
forgetLocalBtwRunId,
|
|
4511
|
+
runAuthFlow,
|
|
4512
|
+
requestExit
|
|
4513
|
+
});
|
|
4514
|
+
const { runLocalShellLine } = createLocalShellRunner({
|
|
4515
|
+
chatLog,
|
|
4516
|
+
tui,
|
|
4517
|
+
openOverlay,
|
|
4518
|
+
closeOverlay
|
|
4519
|
+
});
|
|
4520
|
+
updateAutocompleteProvider();
|
|
4521
|
+
const canSubmitChatMessage = () => canSubmitTuiChatMessage({
|
|
4522
|
+
local: opts.local,
|
|
4523
|
+
activityStatus: state.activityStatus,
|
|
4524
|
+
activeChatRunId: state.activeChatRunId,
|
|
4525
|
+
pendingChatRunId: state.pendingChatRunId,
|
|
4526
|
+
pendingOptimisticUserMessage: state.pendingOptimisticUserMessage
|
|
4527
|
+
});
|
|
4528
|
+
const notifyBlockedChatSubmit = () => {
|
|
4529
|
+
chatLog.addSystem("agent is busy — press Esc to abort before sending a new message");
|
|
4530
|
+
tui.requestRender();
|
|
4531
|
+
};
|
|
4532
|
+
editor.onSubmit = createSubmitBurstCoalescer({
|
|
4533
|
+
submit: createEditorSubmitHandler({
|
|
4534
|
+
editor,
|
|
4535
|
+
handleCommand,
|
|
4536
|
+
sendMessage,
|
|
4537
|
+
handleBangLine: runLocalShellLine,
|
|
4538
|
+
canSubmitMessage: canSubmitChatMessage,
|
|
4539
|
+
onBlockedMessageSubmit: notifyBlockedChatSubmit
|
|
4540
|
+
}),
|
|
4541
|
+
enabled: shouldEnableWindowsGitBashPasteFallback()
|
|
4542
|
+
});
|
|
4543
|
+
editor.onEscape = () => {
|
|
4544
|
+
if (chatLog.hasVisibleBtw()) {
|
|
4545
|
+
chatLog.dismissBtw();
|
|
4546
|
+
tui.requestRender();
|
|
4547
|
+
return;
|
|
4548
|
+
}
|
|
4549
|
+
abortActive();
|
|
4550
|
+
};
|
|
4551
|
+
const handleCtrlC = () => {
|
|
4552
|
+
const now = Date.now();
|
|
4553
|
+
const decision = resolveTuiCtrlCAction({
|
|
4554
|
+
hasInput: editor.getText().trim().length > 0,
|
|
4555
|
+
now,
|
|
4556
|
+
lastCtrlCAt,
|
|
4557
|
+
exitRequested,
|
|
4558
|
+
wasDisconnected
|
|
4559
|
+
});
|
|
4560
|
+
if (decision.action === "force-exit") {
|
|
4561
|
+
forceExit();
|
|
4562
|
+
return;
|
|
4563
|
+
}
|
|
4564
|
+
lastCtrlCAt = decision.nextLastCtrlCAt;
|
|
4565
|
+
if (decision.action === "clear") {
|
|
4566
|
+
editor.setText("");
|
|
4567
|
+
setActivityStatus("cleared input; press ctrl+c again to exit");
|
|
4568
|
+
tui.requestRender();
|
|
4569
|
+
return;
|
|
4570
|
+
}
|
|
4571
|
+
if (decision.action === "exit") {
|
|
4572
|
+
requestExit();
|
|
4573
|
+
return;
|
|
4574
|
+
}
|
|
4575
|
+
setActivityStatus("press ctrl+c again to exit");
|
|
4576
|
+
tui.requestRender();
|
|
4577
|
+
};
|
|
4578
|
+
editor.onCtrlC = () => {
|
|
4579
|
+
handleCtrlC();
|
|
4580
|
+
};
|
|
4581
|
+
editor.onCtrlD = () => {
|
|
4582
|
+
requestExit();
|
|
4583
|
+
};
|
|
4584
|
+
editor.onCtrlO = () => {
|
|
4585
|
+
toolsExpanded = !toolsExpanded;
|
|
4586
|
+
chatLog.setToolsExpanded(toolsExpanded);
|
|
4587
|
+
setActivityStatus(toolsExpanded ? "tools expanded" : "tools collapsed");
|
|
4588
|
+
tui.requestRender();
|
|
4589
|
+
};
|
|
4590
|
+
editor.onCtrlL = () => {
|
|
4591
|
+
openModelSelector();
|
|
4592
|
+
};
|
|
4593
|
+
editor.onCtrlG = () => {
|
|
4594
|
+
openAgentSelector();
|
|
4595
|
+
};
|
|
4596
|
+
editor.onCtrlP = () => {
|
|
4597
|
+
openSessionSelector();
|
|
4598
|
+
};
|
|
4599
|
+
editor.onCtrlT = () => {
|
|
4600
|
+
showThinking = !showThinking;
|
|
4601
|
+
loadHistory();
|
|
4602
|
+
};
|
|
4603
|
+
tui.addInputListener((data) => {
|
|
4604
|
+
if (!chatLog.hasVisibleBtw()) return;
|
|
4605
|
+
if (editor.getText().length > 0) return;
|
|
4606
|
+
if (matchesKey(data, "enter")) {
|
|
4607
|
+
chatLog.dismissBtw();
|
|
4608
|
+
tui.requestRender();
|
|
4609
|
+
return { consume: true };
|
|
4610
|
+
}
|
|
4611
|
+
});
|
|
4612
|
+
client.onEvent = (evt) => {
|
|
4613
|
+
if (evt.event === "chat") handleChatEvent(evt.payload);
|
|
4614
|
+
if (evt.event === "chat.side_result") handleBtwEvent(evt.payload);
|
|
4615
|
+
if (evt.event === "agent") handleAgentEvent(evt.payload);
|
|
4616
|
+
};
|
|
4617
|
+
client.onConnected = () => {
|
|
4618
|
+
isConnected = true;
|
|
4619
|
+
pairingHintShown = false;
|
|
4620
|
+
const reconnected = wasDisconnected;
|
|
4621
|
+
wasDisconnected = false;
|
|
4622
|
+
if (reconnected) reconnectStreamingWatchdog();
|
|
4623
|
+
setConnectionStatus(isLocalMode ? "local ready" : "connected");
|
|
4624
|
+
(async () => {
|
|
4625
|
+
await refreshAgents();
|
|
4626
|
+
await restoreRememberedSession();
|
|
4627
|
+
updateHeader();
|
|
4628
|
+
updateAutocompleteProvider();
|
|
4629
|
+
await loadHistory();
|
|
4630
|
+
setConnectionStatus(isLocalMode ? "local ready" : reconnected ? "gateway reconnected" : "gateway connected", 4e3);
|
|
4631
|
+
tui.requestRender();
|
|
4632
|
+
if (!autoMessageSent && autoMessage) {
|
|
4633
|
+
autoMessageSent = true;
|
|
4634
|
+
await sendMessage(autoMessage);
|
|
4635
|
+
}
|
|
4636
|
+
updateFooter();
|
|
4637
|
+
tui.requestRender();
|
|
4638
|
+
})().catch((err) => {
|
|
4639
|
+
chatLog.addSystem(`startup failed: ${String(err)}`);
|
|
4640
|
+
setConnectionStatus("startup failed", 5e3);
|
|
4641
|
+
tui.requestRender();
|
|
4642
|
+
});
|
|
4643
|
+
};
|
|
4644
|
+
client.onDisconnected = (reason) => {
|
|
4645
|
+
isConnected = false;
|
|
4646
|
+
wasDisconnected = true;
|
|
4647
|
+
historyLoaded = false;
|
|
4648
|
+
dynamicSlashCommands = [];
|
|
4649
|
+
dynamicSlashCommandsKey = null;
|
|
4650
|
+
dynamicSlashCommandsInFlightKey = null;
|
|
4651
|
+
dynamicSlashCommandsRequestId += 1;
|
|
4652
|
+
updateAutocompleteProvider();
|
|
4653
|
+
pauseStreamingWatchdog();
|
|
4654
|
+
const disconnectState = isLocalMode ? {
|
|
4655
|
+
connectionStatus: `local runtime stopped${reason ? `: ${reason}` : ""}`,
|
|
4656
|
+
activityStatus: "idle",
|
|
4657
|
+
pairingHint: void 0
|
|
4658
|
+
} : resolveGatewayDisconnectState(reason);
|
|
4659
|
+
setConnectionStatus(disconnectState.connectionStatus, 5e3);
|
|
4660
|
+
setActivityStatus(disconnectState.activityStatus);
|
|
4661
|
+
if (disconnectState.pairingHint && !pairingHintShown) {
|
|
4662
|
+
pairingHintShown = true;
|
|
4663
|
+
chatLog.addSystem(disconnectState.pairingHint);
|
|
4664
|
+
}
|
|
4665
|
+
updateFooter();
|
|
4666
|
+
tui.requestRender();
|
|
4667
|
+
};
|
|
4668
|
+
client.onGap = (info) => {
|
|
4669
|
+
setConnectionStatus(`event gap: expected ${info.expected}, got ${info.received}`, 5e3);
|
|
4670
|
+
tui.requestRender();
|
|
4671
|
+
};
|
|
4672
|
+
updateHeader();
|
|
4673
|
+
setConnectionStatus(isLocalMode ? "starting local runtime" : "connecting");
|
|
4674
|
+
updateFooter();
|
|
4675
|
+
const sigintHandler = () => {
|
|
4676
|
+
handleCtrlC();
|
|
4677
|
+
};
|
|
4678
|
+
const sigtermHandler = () => {
|
|
4679
|
+
requestExit();
|
|
4680
|
+
};
|
|
4681
|
+
const sighupHandler = () => {
|
|
4682
|
+
requestExit();
|
|
4683
|
+
};
|
|
4684
|
+
process.on("SIGINT", sigintHandler);
|
|
4685
|
+
process.on("SIGTERM", sigtermHandler);
|
|
4686
|
+
process.on("SIGHUP", sighupHandler);
|
|
4687
|
+
let cleanupTerminalLossHandler = installTuiTerminalLossExitHandler(() => requestExit());
|
|
4688
|
+
tui.start();
|
|
4689
|
+
client.start();
|
|
4690
|
+
await new Promise((resolve) => {
|
|
4691
|
+
const finish = () => {
|
|
4692
|
+
if (isLocalMode) setConsoleSubsystemFilter(previousConsoleSubsystemFilter);
|
|
4693
|
+
cleanupTerminalLossHandler?.();
|
|
4694
|
+
cleanupTerminalLossHandler = null;
|
|
4695
|
+
process.removeListener("SIGINT", sigintHandler);
|
|
4696
|
+
process.removeListener("SIGTERM", sigtermHandler);
|
|
4697
|
+
process.removeListener("SIGHUP", sighupHandler);
|
|
4698
|
+
process.removeListener("exit", finish);
|
|
4699
|
+
deferredFinish.clearFinish();
|
|
4700
|
+
resolve();
|
|
4701
|
+
};
|
|
4702
|
+
process.once("exit", finish);
|
|
4703
|
+
deferredFinish.setFinish(finish);
|
|
4704
|
+
});
|
|
4705
|
+
if (opts.forceProcessExitOnReturn === true) scheduleProcessExitAfterTuiReturn();
|
|
4706
|
+
return exitResult;
|
|
4707
|
+
}
|
|
4708
|
+
//#endregion
|
|
4709
|
+
export { createSubmitBurstCoalescer as C, createEditorSubmitHandler as S, resolveFinalAssistantText as T, resolveTuiSessionKey as _, installTuiTerminalLossExitHandler as a, scheduleProcessExitAfterTuiReturn as b, isTuiTerminalLossError as c, resolveGatewayDisconnectState as d, resolveInitialTuiAgentId as f, resolveTuiCtrlCAction as g, resolveLocalAuthSpawnOptions as h, drainAndStopTuiSafely as i, resolveCodexCliBin as l, resolveLocalAuthSpawnCwd as m, createBackspaceDeduper as n, isIgnorableTuiStopError as o, resolveLocalAuthCliInvocation as p, createDeferredTuiFinish as r, isTuiBusyActivityStatus as s, canSubmitTuiChatMessage as t, resolveCtrlCAction as u, resolveTuiShutdownHardExitMs as v, shouldEnableWindowsGitBashPasteFallback as w, stopTuiSafely as x, runTui as y };
|