@pixelzx/genesis 2026.6.28 → 2026.7.8

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.
Files changed (1767) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/.buildstamp +1 -1
  3. package/dist/abort-cutoff.runtime-Cfv6I4gf.js +20 -0
  4. package/dist/abort-cutoff.runtime.js +1 -1
  5. package/dist/abort-xF_zj8_u.js +201 -0
  6. package/dist/abort.runtime-JUukGuW3.js +2 -0
  7. package/dist/abort.runtime.js +1 -1
  8. package/dist/accounts-C0jW92It.js +104 -0
  9. package/dist/accounts-C2ZexWg6.js +107 -0
  10. package/dist/accounts-tEPx6Fnd.js +2 -0
  11. package/dist/acp-cli-De2oyz3e.js +2217 -0
  12. package/dist/acp-spawn-7VB8ie8I.js +1042 -0
  13. package/dist/acp-spawn-C6VfLE4o.js +2 -0
  14. package/dist/acp-stateful-target-driver-ctUymwnI.js +89 -0
  15. package/dist/action-agents-Dy45TQ9X.js +67 -0
  16. package/dist/action-focus-hzygEAz5.js +132 -0
  17. package/dist/action-help-D1h2Czko.js +7 -0
  18. package/dist/action-info-EDBi7fre.js +101 -0
  19. package/dist/action-kill-CBNgmCsz.js +33 -0
  20. package/dist/action-list-C6KC8Ulv.js +21 -0
  21. package/dist/action-log-C0R9AwnB.js +30 -0
  22. package/dist/action-send-DZw27QoS.js +39 -0
  23. package/dist/action-spawn-BXEOYBEH.js +47 -0
  24. package/dist/action-unfocus-DWFUpr-g.js +29 -0
  25. package/dist/actions.runtime-1HHNbwPa.js +5 -0
  26. package/dist/actions.runtime-GFSX3jST.js +18 -0
  27. package/dist/actions.runtime.js +1 -1
  28. package/dist/agent-CU42dfye.js +2 -0
  29. package/dist/agent-command-Baehh2jJ.js +874 -0
  30. package/dist/agent-harness-runtime-Bmln4mlS.js +144 -0
  31. package/dist/agent-runner-utils-xPwHxFwc.js +239 -0
  32. package/dist/agent-runner.runtime-BBx0eqAs.js +3443 -0
  33. package/dist/agent-runner.runtime.js +1 -1
  34. package/dist/agent-runtime-mKUGZmYk.js +18 -0
  35. package/dist/agents-C_kp6PcN.js +954 -0
  36. package/dist/agents-D7-4l9xG.js +5 -0
  37. package/dist/agents.command-shared-j4Ht1HMt.js +40 -0
  38. package/dist/aliases-BR-85AbT.js +96 -0
  39. package/dist/aliases-DH4MEghL.js +2 -0
  40. package/dist/api-7axT1c4t.js +4 -0
  41. package/dist/api-8dcgPyEO.js +139 -0
  42. package/dist/api-BWV-Ja5Y.js +48 -0
  43. package/dist/api-C6Dl-nsC.js +3 -0
  44. package/dist/api-CeoOTFsR.js +5 -0
  45. package/dist/apply-DFpc3-ic.js +508 -0
  46. package/dist/apply.runtime-BpuwcltB.js +166 -0
  47. package/dist/apply.runtime-CyFkfilC.js +2 -0
  48. package/dist/apply.runtime.js +1 -1
  49. package/dist/approval-gateway-resolver-B5iZVyl3.js +29 -0
  50. package/dist/approval-gateway-runtime-DJMhFL8_.js +2 -0
  51. package/dist/approval-handler-runtime-CvlNyTSd.js +439 -0
  52. package/dist/approval-native-runtime-DIP1UVwF.js +729 -0
  53. package/dist/attempt-execution.runtime-Dnj7Dunz.js +509 -0
  54. package/dist/attempt-execution.runtime.js +1 -1
  55. package/dist/attempt-execution.shared-CJLlmxzq.js +22 -0
  56. package/dist/attempt.prompt-helpers-yXlkhGj_.js +206 -0
  57. package/dist/attempt.tool-run-context-DplnP36r.js +933 -0
  58. package/dist/audit-CP153cHC.js +939 -0
  59. package/dist/audit-channel.collect.runtime.js +1 -1
  60. package/dist/audit-extra.async-B52PswlQ.js +971 -0
  61. package/dist/audit-tool-policy-CMwmd8Xs.js +3 -0
  62. package/dist/audit.deep.runtime-BC4XWNSr.js +2 -0
  63. package/dist/audit.deep.runtime.js +1 -1
  64. package/dist/audit.nondeep.runtime-Dvng3qfA.js +880 -0
  65. package/dist/audit.nondeep.runtime.js +1 -1
  66. package/dist/audit.runtime-BPEAdYYt.js +7 -0
  67. package/dist/audit.runtime.js +1 -1
  68. package/dist/auth-CGB_0fnH.js +550 -0
  69. package/dist/auth-DXk-SISv.js +56 -0
  70. package/dist/auth-_41Zyvnc.js +2 -0
  71. package/dist/auth-bH95QjyV.js +177 -0
  72. package/dist/auth-choice-Bn-ygZZg.js +3 -0
  73. package/dist/auth-choice-CmUhzrUA.js +85 -0
  74. package/dist/auth-order-Cnl7fD4m.js +2 -0
  75. package/dist/auth-order-DTEvHo9G.js +139 -0
  76. package/dist/bash-tools-E5RKIMX4.js +2853 -0
  77. package/dist/bash-tools-n2uf-L6x.js +3 -0
  78. package/dist/bash-tools.exec-runtime-BSErqAOv.js +823 -0
  79. package/dist/binding-routing-MxZZJi7B.js +85 -0
  80. package/dist/binding-targets-DOjf91v9.js +121 -0
  81. package/dist/bridge-server-C9sdVkxe.js +113 -0
  82. package/dist/browser-control-auth-Ds_CXo7-.js +2 -0
  83. package/dist/browser-node-runtime-CrrZhgmT.js +12 -0
  84. package/dist/browser-profiles-DSq_VuWU.js +2 -0
  85. package/dist/browser-runtime-D3bUe2ki.js +387 -0
  86. package/dist/browser-setup-tools-BzBeI9sr.js +13 -0
  87. package/dist/build-BQ7uMjfi.js +550 -0
  88. package/dist/build-info.json +3 -3
  89. package/dist/bundled/boot-md/handler.js +3 -3
  90. package/dist/bundled/session-memory/handler.js +1 -1
  91. package/dist/call-C5EHc2Ve.js +3 -0
  92. package/dist/call-DgFhP0IB.js +330 -0
  93. package/dist/call.runtime-CBWpY5ek.js +2 -0
  94. package/dist/call.runtime.js +1 -1
  95. package/dist/capability-cli-CF-5WxGW.js +1401 -0
  96. package/dist/catalog-provider-BefDFS32.js +40 -0
  97. package/dist/catchup-DEgTzUZf.js +300 -0
  98. package/dist/channel-B9Z1yOBL.js +1100 -0
  99. package/dist/channel-BQalh8q5.js +1320 -0
  100. package/dist/channel-B_D0qB8f.js +297 -0
  101. package/dist/channel-CveiiHEq.js +226 -0
  102. package/dist/channel-DPRWC_X5.js +1802 -0
  103. package/dist/channel-DTNwXKB7.js +350 -0
  104. package/dist/channel-DsWHOdeO.js +840 -0
  105. package/dist/channel-IYn5sG7l.js +453 -0
  106. package/dist/channel-MwEUOERy.js +1174 -0
  107. package/dist/channel-add-wizard-De4DNba-.js +125 -0
  108. package/dist/channel-add-wizard-v9JYw-20.js +2 -0
  109. package/dist/channel-core-C3RFVpjy.js +5 -0
  110. package/dist/channel-geAqqK_e.js +491 -0
  111. package/dist/channel-inbound-BRCAVWH1.js +31 -0
  112. package/dist/channel-plugin-resolution-BYpxL2mS.js +2 -0
  113. package/dist/channel-plugin-resolution-Jy5eA_cD.js +153 -0
  114. package/dist/channel-plugin-runtime-B7guFbbq.js +771 -0
  115. package/dist/channel-runtime-B2HmUto-.js +425 -0
  116. package/dist/channel-selection.runtime.js +1 -1
  117. package/dist/channel-setup-DmnWuvUU.js +1297 -0
  118. package/dist/channel-zfFLswBu.js +595 -0
  119. package/dist/channel.runtime-60XStiek.js +2364 -0
  120. package/dist/channel.runtime-BK8atBx7.js +430 -0
  121. package/dist/channel.runtime-CjfgGDJR.js +576 -0
  122. package/dist/channel.runtime-Cuc72hD3.js +89 -0
  123. package/dist/channel.runtime-D4i6q9PJ.js +4 -0
  124. package/dist/channel.runtime-mLdKu3mE.js +42398 -0
  125. package/dist/channel.runtime.js +1 -1
  126. package/dist/channel.setup-BxdBjfQG.js +10 -0
  127. package/dist/channel2.runtime-DhBM75gc.js +109 -0
  128. package/dist/channel2.runtime.js +1 -1
  129. package/dist/channels-YP0r9T7z.js +733 -0
  130. package/dist/channels-cli-BA8x-0ie.js +268 -0
  131. package/dist/chat-C-K_PnVS.js +2830 -0
  132. package/dist/clawbot-cli-CcTWZznd.js +9 -0
  133. package/dist/clawhub-Dg91MiOl.js +400 -0
  134. package/dist/cli/daemon-cli.js +3 -3
  135. package/dist/cli-B9pz-wec.js +2 -0
  136. package/dist/cli-BDqmMCNa.js +219 -0
  137. package/dist/cli-BnjgRW4w.js +154 -0
  138. package/dist/cli-C6O2LqdN.js +683 -0
  139. package/dist/cli-CFANcv9h.js +2 -0
  140. package/dist/cli-D9yBNX96.js +3726 -0
  141. package/dist/cli-e4V7ix51.js +2 -0
  142. package/dist/cli-oSszUBF4.js +72 -0
  143. package/dist/cli-runner-ziqCSXFY.js +286 -0
  144. package/dist/cli-runner.runtime-B-P8SxLi.js +4 -0
  145. package/dist/cli-runner.runtime-BmqwbMTX.js +3 -0
  146. package/dist/cli-runner.runtime.js +1 -1
  147. package/dist/cli-startup-metadata.json +2 -2
  148. package/dist/cli.runtime-4isBQRbc.js +1261 -0
  149. package/dist/cli.runtime.js +1 -1
  150. package/dist/client-CcimlPth.js +138 -0
  151. package/dist/client-DQsu_IXu.js +723 -0
  152. package/dist/command-auth-BWQO7kca.js +76 -0
  153. package/dist/command-config-resolution-ClTknI2S.js +2 -0
  154. package/dist/command-config-resolution-CrkcVij4.js +23 -0
  155. package/dist/command-config-resolution.runtime-D6B4s-Uv.js +2 -0
  156. package/dist/command-config-resolution.runtime.js +1 -1
  157. package/dist/command-execution-startup-CQcKEDhz.js +324 -0
  158. package/dist/command-registry-B_U-oRjT.js +4 -0
  159. package/dist/command-registry-CJ8y08cJ.js +9 -0
  160. package/dist/command-registry-core-CjYDA5Hb.js +106 -0
  161. package/dist/command-secret-gateway-BN5JN_4V.js +528 -0
  162. package/dist/command-status.runtime-BwGSaGwK.js +87 -0
  163. package/dist/command-status.runtime.js +1 -1
  164. package/dist/commands-acp-Di5EZJSo.js +77 -0
  165. package/dist/commands-compact.runtime-Dm1rBnbf.js +10 -0
  166. package/dist/commands-compact.runtime.js +1 -1
  167. package/dist/commands-core.runtime-DjL6pkWU.js +2 -0
  168. package/dist/commands-core.runtime.js +1 -1
  169. package/dist/commands-handlers.runtime-C8uzW3Za.js +4599 -0
  170. package/dist/commands-handlers.runtime.js +1 -1
  171. package/dist/commands-reset-hooks-7h-poKws.js +135 -0
  172. package/dist/commands-status-D_wsDlQe.js +16 -0
  173. package/dist/commands-status.runtime-BYT0Y8Xk.js +3 -0
  174. package/dist/commands-status.runtime.js +1 -1
  175. package/dist/commands-subagents-control.runtime-BozyiWar.js +3 -0
  176. package/dist/commands-subagents-control.runtime-DDCzt8Ub.js +2 -0
  177. package/dist/commands-subagents-control.runtime.js +1 -1
  178. package/dist/commands-system-prompt-ClkTGvNr.js +157 -0
  179. package/dist/commands-system-prompt-qRoqhQKL.js +2 -0
  180. package/dist/commands.runtime-DdZErCma.js +167 -0
  181. package/dist/commands.runtime.js +1 -1
  182. package/dist/compact-BCs9ORLb.js +1096 -0
  183. package/dist/compact.runtime-DvG7GWYV.js +12 -0
  184. package/dist/compact.runtime.js +1 -1
  185. package/dist/completion-cli-C4J7V5YR.js +328 -0
  186. package/dist/config-B0uPLzV0.js +252 -0
  187. package/dist/config-cli-Bt8euI41.js +1078 -0
  188. package/dist/config-guard-DUDovz1_.js +96 -0
  189. package/dist/config-runtime-BnYU3hOw.js +32 -0
  190. package/dist/configure-BIB6QKXD.js +2 -0
  191. package/dist/configure-DuXRvaw-.js +1252 -0
  192. package/dist/connect-options-DdLRs3mC.js +699 -0
  193. package/dist/control-auth-BboB6-Q9.js +125 -0
  194. package/dist/control-service-zISWiuJ_.js +156 -0
  195. package/dist/control-ui/assets/agents-JC5PtqrV.js +1125 -0
  196. package/dist/control-ui/assets/canvas-BOLwH2XE.js +274 -0
  197. package/dist/control-ui/assets/channel-config-extras-DndsWi2n.js +2 -0
  198. package/dist/control-ui/assets/channels-DehEkmqb.js +198 -0
  199. package/dist/control-ui/assets/contacts-CuFuG0IF.js +49 -0
  200. package/dist/control-ui/assets/cron-DOmGA0e5.js +250 -0
  201. package/dist/control-ui/assets/de-CJg8xmlK.js +2 -0
  202. package/dist/control-ui/assets/debug-BmuUKCSJ.js +94 -0
  203. package/dist/control-ui/assets/es-C4Q-2wY3.js +2 -0
  204. package/dist/control-ui/assets/fr-C8HMIYz8.js +2 -0
  205. package/dist/control-ui/assets/i18n-Cc8tlfvD.js +3 -0
  206. package/dist/control-ui/assets/id-Cfarvm3I.js +2 -0
  207. package/dist/control-ui/assets/index-rW3Q6M8T.js +5981 -0
  208. package/dist/control-ui/assets/instances-Cx7hEWzW.js +57 -0
  209. package/dist/control-ui/assets/ja-JP-F9ReJBkI.js +2 -0
  210. package/dist/control-ui/assets/ko-COLp1JKa.js +2 -0
  211. package/dist/control-ui/assets/logs-DB-Z5vcW.js +74 -0
  212. package/dist/control-ui/assets/mcp-Cpcduudl.js +417 -0
  213. package/dist/control-ui/assets/memory-DnzEGr6j.js +50 -0
  214. package/dist/control-ui/assets/memory-graph-DyR9Uhz0.js +30 -0
  215. package/dist/control-ui/assets/models-DiDA_80_.js +86 -0
  216. package/dist/control-ui/assets/nodes-DBKCXfee.js +654 -0
  217. package/dist/control-ui/assets/pl-BYPzLeb4.js +2 -0
  218. package/dist/control-ui/assets/plugins-CwfOfaNX.js +259 -0
  219. package/dist/control-ui/assets/presenter-5bq6-zJE.js +2 -0
  220. package/dist/control-ui/assets/pt-BR-DTBFbuCo.js +2 -0
  221. package/dist/control-ui/assets/sessions-B32pl2IK.js +56 -0
  222. package/dist/control-ui/assets/skills-UF7TyQK4.js +294 -0
  223. package/dist/control-ui/assets/skills-shared-B74z1P-E.js +11 -0
  224. package/dist/control-ui/assets/th-CIjDBcNT.js +2 -0
  225. package/dist/control-ui/assets/tr-NCpkXtTg.js +2 -0
  226. package/dist/control-ui/assets/uk-DvS1vsmH.js +2 -0
  227. package/dist/control-ui/assets/wallet-RKPn2MRs.js +302 -0
  228. package/dist/control-ui/assets/zh-CN-SfnMOQr0.js +2 -0
  229. package/dist/control-ui/assets/zh-TW-CkQgNjXi.js +2 -0
  230. package/dist/control-ui/index.html +2 -2
  231. package/dist/control-ui-CKQ17fcd.js +1043 -0
  232. package/dist/conversation-id-BzYtax7n.js +235 -0
  233. package/dist/conversation-id-HBz3v6j3.js +38 -0
  234. package/dist/conversation-runtime-CkcxSb_S.js +31 -0
  235. package/dist/core-DxVEjt5f.js +275 -0
  236. package/dist/create-B9OOGa90.js +80 -0
  237. package/dist/cron-cli-CAkqablA.js +713 -0
  238. package/dist/daemon-cli-CCC_5IkN.js +12 -0
  239. package/dist/dashboard-Bqpn6xD_.js +81 -0
  240. package/dist/dashboard-Cd6TkhpW.js +2 -0
  241. package/dist/delegate-D7D8iTtT.js +64 -0
  242. package/dist/deliver-I8Ifd1yR.js +3 -0
  243. package/dist/deliver-Zphc65zr.js +747 -0
  244. package/dist/deliver-runtime-DQyfYkCs.js +2 -0
  245. package/dist/delivery-outbound.runtime-Bs9x6LSS.js +6 -0
  246. package/dist/delivery-outbound.runtime.js +1 -1
  247. package/dist/delivery.runtime-Cx3qn7Hc.js +253 -0
  248. package/dist/delivery.runtime.js +1 -1
  249. package/dist/detached-task-runtime-D2jixP5C.js +73 -0
  250. package/dist/devices-cli-CMnaKl01.js +498 -0
  251. package/dist/diagnostics-B8Z9UWlG.js +154 -0
  252. package/dist/direct-dm-c4Qb2Nzg.js +64 -0
  253. package/dist/directive-handling.fast-lane-DuuCgCI2.js +66 -0
  254. package/dist/directive-handling.impl-BiJain1b.js +2 -0
  255. package/dist/directive-handling.impl-CYw76-Ag.js +703 -0
  256. package/dist/directive-handling.model-selection-BNnOIh0D.js +114 -0
  257. package/dist/directive-handling.persist.runtime-DWnMoAjn.js +215 -0
  258. package/dist/directive-handling.persist.runtime.js +1 -1
  259. package/dist/directory-cli-CinbUxv4.js +240 -0
  260. package/dist/dispatch-acp-BL2QahHP.js +981 -0
  261. package/dist/dispatch-acp-manager.runtime-CynWPlJS.js +3 -0
  262. package/dist/dispatch-acp-manager.runtime.js +1 -1
  263. package/dist/dispatch-acp-media.runtime-CrC5nXXy.js +4 -0
  264. package/dist/dispatch-acp-media.runtime.js +1 -1
  265. package/dist/dispatch-acp-session.runtime-C_GFMR0r.js +2 -0
  266. package/dist/dispatch-acp-session.runtime.js +1 -1
  267. package/dist/dispatch-acp.runtime-OwR8G8Qt.js +19 -0
  268. package/dist/dispatch-acp.runtime.js +1 -1
  269. package/dist/dispatch-r6Uv7puk.js +1131 -0
  270. package/dist/doctor-config-flow-BQjLEW5b.js +420 -0
  271. package/dist/doctor-config-preflight-B3VVSleh.js +63 -0
  272. package/dist/doctor-config-preflight-BBOEq7ti.js +2 -0
  273. package/dist/doctor-device-pairing-GsLelCah.js +307 -0
  274. package/dist/doctor-gateway-daemon-flow-Bj6Y5WoB.js +250 -0
  275. package/dist/doctor-gateway-health-D7WY6zgb.js +63 -0
  276. package/dist/doctor-health-C9GRQaPA.js +59 -0
  277. package/dist/doctor-health-contributions-Dk9ho6TO.js +493 -0
  278. package/dist/doctor-prompter-Ct6Jv52M.js +56 -0
  279. package/dist/doctor-sandbox-DAb-mQpy.js +194 -0
  280. package/dist/doctor-state-migrations-36dXc9ct.js +2 -0
  281. package/dist/doctor-workspace-status-CJCfWEI6.js +75 -0
  282. package/dist/dreaming-_hTKF5lN.js +1582 -0
  283. package/dist/dreaming-narrative-D5XTDttN.js +596 -0
  284. package/dist/embedded-gateway-stub.runtime-CEmoodA9.js +9 -0
  285. package/dist/embedded-gateway-stub.runtime.js +1 -1
  286. package/dist/embedding-provider-B9F-kCH3.js +118 -0
  287. package/dist/embeddings-BCVqTyaZ.js +215 -0
  288. package/dist/embeddings-http-CCsd7vWB.js +205 -0
  289. package/dist/entry.js +2 -2
  290. package/dist/exec-approval-forwarder.runtime-CMniJyXX.js +3 -0
  291. package/dist/exec-approval-forwarder.runtime.js +1 -1
  292. package/dist/exec-approvals-cli-ClDMlOmM.js +498 -0
  293. package/dist/exec-defaults-BWb7bhoE.js +2 -0
  294. package/dist/exec-defaults-CE8PArh-.js +67 -0
  295. package/dist/execute.runtime-Bhup95bB.js +1359 -0
  296. package/dist/execute.runtime.js +1 -1
  297. package/dist/extensionAPI.js +3 -3
  298. package/dist/extensions/active-memory/index.js +3 -3
  299. package/dist/extensions/alibaba/index.js +1 -1
  300. package/dist/extensions/alibaba/video-generation-provider.js +1 -1
  301. package/dist/extensions/arcee/index.js +2 -2
  302. package/dist/extensions/bluebubbles/api.js +3 -3
  303. package/dist/extensions/bluebubbles/channel-plugin-api.js +1 -1
  304. package/dist/extensions/browser/browser-bridge.js +1 -1
  305. package/dist/extensions/browser/browser-config.js +4 -4
  306. package/dist/extensions/browser/browser-control-auth.js +2 -2
  307. package/dist/extensions/browser/browser-doctor.js +2 -2
  308. package/dist/extensions/browser/browser-maintenance.js +2 -2
  309. package/dist/extensions/browser/browser-profiles.js +2 -2
  310. package/dist/extensions/browser/browser-runtime-api.js +10 -10
  311. package/dist/extensions/browser/index.js +1 -1
  312. package/dist/extensions/browser/plugin-registration.js +1 -1
  313. package/dist/extensions/browser/register.runtime.js +3 -3
  314. package/dist/extensions/browser/runtime-api.js +11 -11
  315. package/dist/extensions/browser/test-support.js +1 -1
  316. package/dist/extensions/byteplus/index.js +3 -3
  317. package/dist/extensions/byteplus/video-generation-provider.js +1 -1
  318. package/dist/extensions/chutes/index.js +4 -4
  319. package/dist/extensions/cloudflare-ai-gateway/api.js +1 -1
  320. package/dist/extensions/cloudflare-ai-gateway/catalog-provider.js +1 -1
  321. package/dist/extensions/cloudflare-ai-gateway/index.js +2 -2
  322. package/dist/extensions/comfy/image-generation-provider.js +2 -2
  323. package/dist/extensions/comfy/index.js +5 -5
  324. package/dist/extensions/comfy/music-generation-provider.js +1 -1
  325. package/dist/extensions/comfy/video-generation-provider.js +2 -2
  326. package/dist/extensions/comfy/workflow-runtime.js +1 -1
  327. package/dist/extensions/deepseek/index.js +1 -1
  328. package/dist/extensions/device-pair/api.js +2 -2
  329. package/dist/extensions/device-pair/index.js +4 -4
  330. package/dist/extensions/device-pair/notify.js +1 -1
  331. package/dist/extensions/device-pair/pair-command-approve.js +1 -1
  332. package/dist/extensions/device-pair/qr-image.js +2 -2
  333. package/dist/extensions/fal/image-generation-provider.js +1 -1
  334. package/dist/extensions/fal/index.js +3 -3
  335. package/dist/extensions/fal/provider-registration.js +1 -1
  336. package/dist/extensions/fal/test-api.js +2 -2
  337. package/dist/extensions/fal/video-generation-provider.js +1 -1
  338. package/dist/extensions/fireworks/index.js +1 -1
  339. package/dist/extensions/github-copilot/api.js +1 -1
  340. package/dist/extensions/github-copilot/auth.js +1 -1
  341. package/dist/extensions/github-copilot/embeddings.js +1 -1
  342. package/dist/extensions/github-copilot/index.js +4 -4
  343. package/dist/extensions/github-copilot/login.js +1 -1
  344. package/dist/extensions/github-copilot/register.runtime.js +2 -2
  345. package/dist/extensions/google-meet/index.js +6 -6
  346. package/dist/extensions/groq/index.js +1 -1
  347. package/dist/extensions/groq/media-understanding-provider.js +1 -1
  348. package/dist/extensions/groq/test-api.js +1 -1
  349. package/dist/extensions/huggingface/index.js +1 -1
  350. package/dist/extensions/image-generation-core/api.js +2 -2
  351. package/dist/extensions/imessage/api.js +4 -4
  352. package/dist/extensions/imessage/channel-plugin-api.js +1 -1
  353. package/dist/extensions/imessage/runtime-api.js +5 -5
  354. package/dist/extensions/imessage/test-api.js +1 -1
  355. package/dist/extensions/irc/api.js +2 -2
  356. package/dist/extensions/irc/channel-plugin-api.js +1 -1
  357. package/dist/extensions/kilocode/index.js +1 -1
  358. package/dist/extensions/kimi-coding/index.js +2 -2
  359. package/dist/extensions/line/api.js +2 -2
  360. package/dist/extensions/line/channel-plugin-api.js +1 -1
  361. package/dist/extensions/line/contract-api.js +1 -1
  362. package/dist/extensions/line/runtime-api.js +4 -4
  363. package/dist/extensions/line/setup-api.js +1 -1
  364. package/dist/extensions/litellm/index.js +1 -1
  365. package/dist/extensions/lmstudio/api.js +2 -2
  366. package/dist/extensions/lmstudio/index.js +3 -3
  367. package/dist/extensions/lmstudio/memory-embedding-adapter.js +1 -1
  368. package/dist/extensions/lmstudio/runtime-api.js +1 -1
  369. package/dist/extensions/lobster/runtime-api.js +1 -1
  370. package/dist/extensions/mattermost/api.js +1 -1
  371. package/dist/extensions/mattermost/channel-plugin-api.js +1 -1
  372. package/dist/extensions/mattermost/channel-plugin-runtime.js +1 -1
  373. package/dist/extensions/mattermost/policy-api.js +1 -1
  374. package/dist/extensions/mattermost/runtime-api.js +7 -7
  375. package/dist/extensions/mattermost/slash-route-api.js +1 -1
  376. package/dist/extensions/media-understanding-core/runtime-api.js +2 -2
  377. package/dist/extensions/memory-core/api.js +1 -1
  378. package/dist/extensions/memory-core/cli-metadata.js +2 -2
  379. package/dist/extensions/memory-core/index.js +3 -3
  380. package/dist/extensions/memory-lancedb/cli-metadata.js +1 -1
  381. package/dist/extensions/memory-lancedb/index.js +1 -1
  382. package/dist/extensions/memory-wiki/cli-metadata.js +1 -1
  383. package/dist/extensions/memory-wiki/index.js +1 -1
  384. package/dist/extensions/microsoft/index.js +1 -1
  385. package/dist/extensions/microsoft/speech-provider.js +1 -1
  386. package/dist/extensions/microsoft/test-api.js +1 -1
  387. package/dist/extensions/microsoft-foundry/auth.js +1 -1
  388. package/dist/extensions/microsoft-foundry/cli.js +1 -1
  389. package/dist/extensions/microsoft-foundry/index.js +1 -1
  390. package/dist/extensions/microsoft-foundry/onboard.js +2 -2
  391. package/dist/extensions/microsoft-foundry/provider.js +1 -1
  392. package/dist/extensions/microsoft-foundry/runtime.js +1 -1
  393. package/dist/extensions/microsoft-foundry/shared-runtime.js +2 -2
  394. package/dist/extensions/microsoft-foundry/shared.js +1 -1
  395. package/dist/extensions/minimax/image-generation-provider.js +1 -1
  396. package/dist/extensions/minimax/index.js +6 -6
  397. package/dist/extensions/minimax/media-understanding-provider.js +1 -1
  398. package/dist/extensions/minimax/music-generation-provider.js +1 -1
  399. package/dist/extensions/minimax/oauth.js +1 -1
  400. package/dist/extensions/minimax/oauth.runtime.js +1 -1
  401. package/dist/extensions/minimax/provider-registration.js +1 -1
  402. package/dist/extensions/minimax/speech-provider.js +1 -1
  403. package/dist/extensions/minimax/test-api.js +4 -4
  404. package/dist/extensions/minimax/video-generation-provider.js +1 -1
  405. package/dist/extensions/mistral/index.js +2 -2
  406. package/dist/extensions/mistral/media-understanding-provider.js +1 -1
  407. package/dist/extensions/mistral/test-api.js +1 -1
  408. package/dist/extensions/moonshot/index.js +2 -2
  409. package/dist/extensions/moonshot/media-understanding-provider.js +1 -1
  410. package/dist/extensions/moonshot/test-api.js +1 -1
  411. package/dist/extensions/msteams/api.js +1 -1
  412. package/dist/extensions/msteams/channel-plugin-api.js +1 -1
  413. package/dist/extensions/msteams/runtime-api.js +4 -4
  414. package/dist/extensions/msteams/test-api.js +1 -1
  415. package/dist/extensions/nextcloud-talk/api.js +1 -1
  416. package/dist/extensions/nextcloud-talk/channel-plugin-api.js +1 -1
  417. package/dist/extensions/nextcloud-talk/runtime-api.js +2 -2
  418. package/dist/extensions/nvidia/index.js +1 -1
  419. package/dist/extensions/ollama/api.js +3 -3
  420. package/dist/extensions/ollama/index.js +9 -9
  421. package/dist/extensions/ollama/runtime-api.js +2 -2
  422. package/dist/extensions/ollama/web-search-provider.js +1 -1
  423. package/dist/extensions/openai/api.js +2 -2
  424. package/dist/extensions/openai/image-generation-provider.js +1 -1
  425. package/dist/extensions/openai/index.js +6 -6
  426. package/dist/extensions/openai/media-understanding-provider.js +1 -1
  427. package/dist/extensions/openai/openai-codex-provider.js +1 -1
  428. package/dist/extensions/openai/openai-provider.js +1 -1
  429. package/dist/extensions/openai/register.runtime.js +4 -4
  430. package/dist/extensions/openai/test-api.js +3 -3
  431. package/dist/extensions/openai/video-generation-provider.js +1 -1
  432. package/dist/extensions/opencode/index.js +2 -2
  433. package/dist/extensions/opencode/media-understanding-provider.js +1 -1
  434. package/dist/extensions/opencode-go/index.js +2 -2
  435. package/dist/extensions/opencode-go/media-understanding-provider.js +1 -1
  436. package/dist/extensions/openrouter/api.js +1 -1
  437. package/dist/extensions/openrouter/image-generation-provider.js +1 -1
  438. package/dist/extensions/openrouter/index.js +4 -4
  439. package/dist/extensions/openrouter/media-understanding-provider.js +1 -1
  440. package/dist/extensions/openrouter/register.runtime.js +3 -3
  441. package/dist/extensions/openrouter/test-api.js +2 -2
  442. package/dist/extensions/openshell/index.js +3 -3
  443. package/dist/extensions/qianfan/index.js +1 -1
  444. package/dist/extensions/qwen/index.js +3 -3
  445. package/dist/extensions/qwen/media-understanding-provider.js +1 -1
  446. package/dist/extensions/qwen/test-api.js +2 -2
  447. package/dist/extensions/qwen/video-generation-provider.js +1 -1
  448. package/dist/extensions/runway/index.js +1 -1
  449. package/dist/extensions/runway/video-generation-provider.js +1 -1
  450. package/dist/extensions/signal/api.js +6 -6
  451. package/dist/extensions/signal/channel-plugin-api.js +1 -1
  452. package/dist/extensions/signal/reaction-runtime-api.js +1 -1
  453. package/dist/extensions/signal/runtime-api.js +9 -9
  454. package/dist/extensions/skill-workshop/api.js +1 -1
  455. package/dist/extensions/skill-workshop/index.js +2 -2
  456. package/dist/extensions/speech-core/runtime-api.js +1 -1
  457. package/dist/extensions/stepfun/index.js +2 -2
  458. package/dist/extensions/synology-chat/api.js +1 -1
  459. package/dist/extensions/synology-chat/channel-plugin-api.js +1 -1
  460. package/dist/extensions/synthetic/index.js +1 -1
  461. package/dist/extensions/talk-voice/index.js +1 -1
  462. package/dist/extensions/tencent/index.js +2 -2
  463. package/dist/extensions/thread-ownership/index.js +1 -1
  464. package/dist/extensions/tlon/api.js +2 -2
  465. package/dist/extensions/tlon/channel-plugin-api.js +1 -1
  466. package/dist/extensions/tlon/runtime-api.js +1 -1
  467. package/dist/extensions/tlon/test-api.js +1 -1
  468. package/dist/extensions/together/index.js +2 -2
  469. package/dist/extensions/together/video-generation-provider.js +1 -1
  470. package/dist/extensions/twitch/api.js +1 -1
  471. package/dist/extensions/twitch/channel-plugin-api.js +1 -1
  472. package/dist/extensions/twitch/setup-plugin-api.js +1 -1
  473. package/dist/extensions/venice/index.js +1 -1
  474. package/dist/extensions/vercel-ai-gateway/index.js +1 -1
  475. package/dist/extensions/voice-call/index.js +1 -1
  476. package/dist/extensions/voice-call/runtime-entry.js +1 -1
  477. package/dist/extensions/volcengine/index.js +2 -2
  478. package/dist/extensions/vydra/image-generation-provider.js +1 -1
  479. package/dist/extensions/vydra/index.js +4 -4
  480. package/dist/extensions/vydra/video-generation-provider.js +1 -1
  481. package/dist/extensions/xai/api.js +2 -2
  482. package/dist/extensions/xai/code-execution.js +2 -2
  483. package/dist/extensions/xai/image-generation-provider.js +1 -1
  484. package/dist/extensions/xai/index.js +6 -6
  485. package/dist/extensions/xai/speech-provider.js +1 -1
  486. package/dist/extensions/xai/tts.js +1 -1
  487. package/dist/extensions/xai/video-generation-provider.js +1 -1
  488. package/dist/extensions/xai/x-search.js +2 -2
  489. package/dist/extensions/xiaomi/index.js +1 -1
  490. package/dist/extensions/zai/index.js +2 -2
  491. package/dist/extensions/zai/media-understanding-provider.js +1 -1
  492. package/dist/extensions/zai/test-api.js +1 -1
  493. package/dist/extensions/zalo/api.js +3 -3
  494. package/dist/extensions/zalo/channel-plugin-api.js +1 -1
  495. package/dist/extensions/zalo/runtime-api.js +2 -2
  496. package/dist/extensions/zalo/setup-api.js +2 -2
  497. package/dist/extensions/zalouser/api.js +3 -3
  498. package/dist/extensions/zalouser/channel-plugin-api.js +1 -1
  499. package/dist/extensions/zalouser/runtime-api.js +7 -7
  500. package/dist/extensions/zalouser/setup-plugin-api.js +1 -1
  501. package/dist/extensions/zalouser/test-api.js +1 -1
  502. package/dist/fallbacks-7zSQjTV3.js +31 -0
  503. package/dist/fallbacks-CZiqVR5O.js +2 -0
  504. package/dist/fallbacks-shared-ChkX-wC9.js +111 -0
  505. package/dist/gateway-CHyZ16Py.js +115 -0
  506. package/dist/gateway-cli-Ddf-bjxV.js +1283 -0
  507. package/dist/gateway-rpc-DksPpMA7.js +14 -0
  508. package/dist/gateway-rpc.runtime-BKaQsdOu.js +23 -0
  509. package/dist/gateway-rpc.runtime.js +1 -1
  510. package/dist/gateway-runtime-Ca4l5F_e.js +15 -0
  511. package/dist/gateway-status-CTPWttLS.js +584 -0
  512. package/dist/genesis-tools-Bkxp7zlI.js +9435 -0
  513. package/dist/genesis-tools.runtime-BCkQJQBx.js +2 -0
  514. package/dist/genesis-tools.runtime.js +1 -1
  515. package/dist/get-reply-HzKdsGO7.js +3946 -0
  516. package/dist/get-reply-from-config.runtime-C5ISSvQ1.js +2 -0
  517. package/dist/get-reply-from-config.runtime.js +1 -1
  518. package/dist/gmail-watcher-lifecycle-BYRHDXCT.js +2 -0
  519. package/dist/graph-users-BVVUU02O.js +1337 -0
  520. package/dist/health-3Ot3RyLe.js +420 -0
  521. package/dist/health-B1Ww7M60.js +3 -0
  522. package/dist/health-route--L24U5vY.js +2 -0
  523. package/dist/health-route-DQ3RbNHQ.js +41 -0
  524. package/dist/hooks-cli-CsJbTM0O.js +433 -0
  525. package/dist/http-endpoint-helpers-D5HkMFwp.js +41 -0
  526. package/dist/http-utils-LFOvdepz.js +924 -0
  527. package/dist/image-fallbacks--ElXneWp.js +31 -0
  528. package/dist/image-fallbacks-D3vJILOu.js +2 -0
  529. package/dist/image-generation-core-DasXukAP.js +18 -0
  530. package/dist/image-generation-core.auth.runtime.js +1 -1
  531. package/dist/image-generation-provider-BUYDznhO.js +157 -0
  532. package/dist/image-generation-provider-CZsEm9qP.js +137 -0
  533. package/dist/image-generation-provider-DfAtOfEj.js +95 -0
  534. package/dist/image-generation-provider-Dksuo9OZ.js +529 -0
  535. package/dist/image-generation-provider-TlVk_XqK.js +63 -0
  536. package/dist/image-generation-provider-YwugArNw.js +274 -0
  537. package/dist/image-generation-provider-bWlq5yUE.js +228 -0
  538. package/dist/image-runtime-CswgJNvs.js +9 -0
  539. package/dist/inbound-reply-dispatch-B7wRXjgc.js +73 -0
  540. package/dist/inbound.runtime-Bw0JSbxR.js +4 -0
  541. package/dist/inbound.runtime-DjvZZHXI.js +3 -0
  542. package/dist/inbound.runtime.js +1 -1
  543. package/dist/index.js +2 -2
  544. package/dist/infra-runtime-CBfd1WMP.js +38 -0
  545. package/dist/init-D0hOJH3x.js +59 -0
  546. package/dist/install-CYvCH-s3.js +726 -0
  547. package/dist/install-security-scan-B7ZoC2Vw.js +26 -0
  548. package/dist/install-security-scan.runtime-iZsF-J1u.js +671 -0
  549. package/dist/install-security-scan.runtime.js +1 -1
  550. package/dist/install.runtime-BAqg9YWO.js +27 -0
  551. package/dist/install.runtime-Cc9Bf7A6.js +12 -0
  552. package/dist/install.runtime.js +1 -1
  553. package/dist/jobs-BIi6klWl.js +729 -0
  554. package/dist/library-oLeJ7WB2.js +45 -0
  555. package/dist/lifecycle-CeE5vcbI.js +571 -0
  556. package/dist/lifecycle-CqOQyQkN.js +229 -0
  557. package/dist/lifecycle.runtime-3bkEDR0o.js +2 -0
  558. package/dist/lifecycle.runtime.js +1 -1
  559. package/dist/list-C3cLeCpB.js +2 -0
  560. package/dist/list-CcZ_ONLT.js +2 -0
  561. package/dist/list-DUXsFAZJ.js +1212 -0
  562. package/dist/list-gnrIqPtd.js +131 -0
  563. package/dist/list.probe-BwRgShwM.js +419 -0
  564. package/dist/live-model-switch-CWgg2Ggb.js +336 -0
  565. package/dist/llm-slug-generator-BkDTThCe.js +79 -0
  566. package/dist/llm-slug-generator.js +1 -1
  567. package/dist/load-config-CfZQrUUz.js +35 -0
  568. package/dist/loader-DsEya2Rd.js +222 -0
  569. package/dist/local-dispatch.runtime-CtXGZ70F.js +8 -0
  570. package/dist/local-dispatch.runtime.js +1 -1
  571. package/dist/login-M0JiZwmc.js +108 -0
  572. package/dist/logs-cli-zd_9yCKn.js +265 -0
  573. package/dist/logs-cli.runtime-BWvHh5zg.js +2 -0
  574. package/dist/logs-cli.runtime.js +1 -1
  575. package/dist/main-session-restart-recovery-Bnvjo9E1.js +206 -0
  576. package/dist/managed-image-attachments-Cib67JTY.js +2 -0
  577. package/dist/managed-image-attachments-Pl-_Wh-s.js +635 -0
  578. package/dist/manager-CfFNGdWA.js +2057 -0
  579. package/dist/manager-TXSNaq3B.js +2 -0
  580. package/dist/markdown-to-line-C83mDLjZ.js +790 -0
  581. package/dist/mcp/plugin-tools-serve.js +1 -1
  582. package/dist/mcp-cli-CNy5N1fa.js +725 -0
  583. package/dist/mcp-http-Cp3nlyRC.js +529 -0
  584. package/dist/mcp-oauth-embedded.runtime-Bg_5jTnW.js +111 -0
  585. package/dist/mcp-oauth-embedded.runtime.js +1 -0
  586. package/dist/media-runtime-BetXjDy_.js +329 -0
  587. package/dist/media-understanding-PrCTBqs6.js +85 -0
  588. package/dist/media-understanding-provider-BOJyh6FF.js +85 -0
  589. package/dist/media-understanding-provider-BQqWS6FP.js +18 -0
  590. package/dist/media-understanding-provider-BVI5_wpJ.js +12 -0
  591. package/dist/media-understanding-provider-BvANUUsD.js +37 -0
  592. package/dist/media-understanding-provider-CmJsqky4.js +69 -0
  593. package/dist/media-understanding-provider-D160isav.js +28 -0
  594. package/dist/media-understanding-provider-DLdtS2i0.js +12 -0
  595. package/dist/media-understanding-provider-DbYma1pc.js +21 -0
  596. package/dist/media-understanding-provider-DgKlDcus.js +18 -0
  597. package/dist/media-understanding-provider-Dt4kGn2a.js +13 -0
  598. package/dist/media-understanding-runtime-7Pt0cFob.js +2 -0
  599. package/dist/memory-core-host-runtime-cli-BegfMQ60.js +9 -0
  600. package/dist/memory-embedding-adapter-bqPa42NQ.js +123 -0
  601. package/dist/memory-host-search-595fbsH5.js +12 -0
  602. package/dist/memory-host-search.runtime.js +1 -1
  603. package/dist/message-BEIYueeC.js +232 -0
  604. package/dist/message-action-runner-BMAw7gfU.js +2 -0
  605. package/dist/message-action-runner-DbqkVVXA.js +1407 -0
  606. package/dist/message-actions-CagfUya_.js +143 -0
  607. package/dist/message.config.runtime.js +1 -1
  608. package/dist/message.gateway.runtime-8N00rzUd.js +2 -0
  609. package/dist/message.gateway.runtime.js +1 -1
  610. package/dist/method-scopes-TWVLEUXZ.js +239 -0
  611. package/dist/model-picker-DJQ_lN5J.js +3 -0
  612. package/dist/model-picker-f_kmCGgt.js +559 -0
  613. package/dist/model-picker.runtime-Bua1ZV3T.js +15 -0
  614. package/dist/model-picker.runtime.js +1 -1
  615. package/dist/model-selection-DRe0f5zo.js +212 -0
  616. package/dist/models-auth-status-dUVFT_f1.js +217 -0
  617. package/dist/models-cli-VqeddndJ.js +271 -0
  618. package/dist/models-http-PC5-c2lS.js +92 -0
  619. package/dist/models.fetch-CsIbuvYn.js +518 -0
  620. package/dist/monitor-BgwZHXAs.js +2 -0
  621. package/dist/monitor-BrGXztev.js +1661 -0
  622. package/dist/monitor-DXqHkIkY.js +788 -0
  623. package/dist/monitor-DoS0pnRS.js +671 -0
  624. package/dist/monitor-SUo0OdqH.js +1459 -0
  625. package/dist/monitor-auth-BjLpAGxu.js +207 -0
  626. package/dist/monitor-hVTP1bQv.js +1237 -0
  627. package/dist/monitor-processing-CIokCAUz.js +1974 -0
  628. package/dist/monitor.runtime-BU4RKNXx.js +2 -0
  629. package/dist/monitor.runtime.js +1 -1
  630. package/dist/monitor.webhook-DaTTjWrL.js +180 -0
  631. package/dist/msteams-CmdWCuQl.js +35 -0
  632. package/dist/music-generation-provider-D1C-gv82.js +63 -0
  633. package/dist/music-generation-provider-Da4aNlMi.js +170 -0
  634. package/dist/native-hook-relay-Crk4McKb.js +519 -0
  635. package/dist/nextcloud-talk-D23cNPfx.js +17 -0
  636. package/dist/node-cli-DQ2FAUD5.js +2276 -0
  637. package/dist/nodes-cli-rSfhRw3_.js +1046 -0
  638. package/dist/nodes-utils-DlayGjaD.js +84 -0
  639. package/dist/nodes.helpers-DDUs18Tb.js +34 -0
  640. package/dist/notify-BSOvLWmd.js +315 -0
  641. package/dist/oauth-CMgJwuws.js +2 -0
  642. package/dist/oauth-CkVdnYWF.js +152 -0
  643. package/dist/oauth-DyK5hAZs.js +139 -0
  644. package/dist/oauth-OBOUymgi.js +75 -0
  645. package/dist/oauth.flow-BLoyN3lV.js +3 -0
  646. package/dist/oauth.flow-DH06lWCO.js +45 -0
  647. package/dist/onboard-C-WpjREP.js +316 -0
  648. package/dist/onboard-CpNpQ0N8.js +70 -0
  649. package/dist/onboard-channels-BeLqCc-3.js +2 -0
  650. package/dist/onboard-channels-DvKo0QB_.js +3 -0
  651. package/dist/onboard-custom-BXb7qIWz.js +3 -0
  652. package/dist/onboard-custom-ClkyPqIy.js +271 -0
  653. package/dist/onboard-helpers-BSqq4yEX.js +204 -0
  654. package/dist/onboard-helpers-Cw8cHMwk.js +6 -0
  655. package/dist/onboard-interactive-CIJMPUNi.js +24 -0
  656. package/dist/onboard-non-interactive-CCGFunM1.js +635 -0
  657. package/dist/onboard-remote-BIFjzB0v.js +193 -0
  658. package/dist/onboard-remote-DdfKS44K.js +2 -0
  659. package/dist/onboard-skills-C9Oz7pMM.js +134 -0
  660. package/dist/onboard-skills-DFZIuIBM.js +2 -0
  661. package/dist/onboard-ygfHgwjs.js +2 -0
  662. package/dist/onboarding-plugin-install-CSJX8VZv.js +406 -0
  663. package/dist/openai-codex-provider-ChrCVEw6.js +472 -0
  664. package/dist/openai-http-V8-EZ-Tx.js +500 -0
  665. package/dist/openai-provider-CBFc7f3l.js +313 -0
  666. package/dist/opencode-D8fX4akZ.js +35 -0
  667. package/dist/openresponses-http-B2Z5eD7p.js +1128 -0
  668. package/dist/operator-approvals-client-DcLaJSYz.js +68 -0
  669. package/dist/outbound-runtime-BcayPyTD.js +5 -0
  670. package/dist/outbound.runtime-BioZr0Xk.js +2 -0
  671. package/dist/outbound.runtime.js +1 -1
  672. package/dist/pair-command-approve-CKQ5PFPa.js +44 -0
  673. package/dist/persistent-bindings.lifecycle-Cc3nJyXl.js +2 -0
  674. package/dist/persistent-bindings.lifecycle-DMUm3wFX.js +85 -0
  675. package/dist/pi-bundle-mcp-runtime-BxuXFq8N.js +2 -0
  676. package/dist/pi-bundle-mcp-runtime-ZvnA7GLK.js +854 -0
  677. package/dist/pi-bundle-mcp-tools-Cq0oKMGx.js +108 -0
  678. package/dist/pi-embedded-DLQZrdL6.js +2905 -0
  679. package/dist/pi-embedded-kfFiSGXN.js +4 -0
  680. package/dist/pi-embedded-subscribe.handlers.compaction.runtime-DRkY_7mg.js +23 -0
  681. package/dist/pi-embedded-subscribe.handlers.compaction.runtime.js +1 -1
  682. package/dist/pi-embedded.runtime-DXAilonb.js +4 -0
  683. package/dist/pi-embedded.runtime.js +1 -1
  684. package/dist/pi-tool-definition-adapter-D5M4iVmd.js +229 -0
  685. package/dist/pi-tools-CymfaKhy.js +1118 -0
  686. package/dist/pi-tools.before-tool-call-CBjigYgQ.js +2 -0
  687. package/dist/pi-tools.before-tool-call-CrhLIm2q.js +433 -0
  688. package/dist/plugin-DJ_g-ddv.js +12195 -0
  689. package/dist/plugin-enabled-CqvTLQjg.js +140 -0
  690. package/dist/plugin-install-DwdyYiEf.js +115 -0
  691. package/dist/plugin-install-config-policy-BGQ3WzJO.js +137 -0
  692. package/dist/plugin-install-ldcXmOz8.js +2 -0
  693. package/dist/plugin-install-plan-DXvNElN2.js +50 -0
  694. package/dist/plugin-registration-awDDNZjN.js +23 -0
  695. package/dist/plugin-sdk/.boundary-entry-shims.stamp +1 -1
  696. package/dist/plugin-sdk/acp-binding-runtime.js +1 -1
  697. package/dist/plugin-sdk/acp-runtime.js +3 -3
  698. package/dist/plugin-sdk/agent-harness-runtime.js +6 -6
  699. package/dist/plugin-sdk/agent-harness.js +7 -7
  700. package/dist/plugin-sdk/agent-runtime.js +2 -2
  701. package/dist/plugin-sdk/approval-gateway-runtime.js +2 -2
  702. package/dist/plugin-sdk/approval-handler-runtime.js +3 -3
  703. package/dist/plugin-sdk/approval-runtime.js +1 -1
  704. package/dist/plugin-sdk/browser-node-runtime.js +4 -4
  705. package/dist/plugin-sdk/browser-setup-tools.js +3 -3
  706. package/dist/plugin-sdk/browser-support.js +7 -7
  707. package/dist/plugin-sdk/channel-core.js +2 -2
  708. package/dist/plugin-sdk/channel-inbound.js +3 -3
  709. package/dist/plugin-sdk/command-auth.js +2 -2
  710. package/dist/plugin-sdk/command-status-runtime.js +1 -1
  711. package/dist/plugin-sdk/compat.js +1 -1
  712. package/dist/plugin-sdk/config-runtime.js +3 -3
  713. package/dist/plugin-sdk/conversation-binding-runtime.js +1 -1
  714. package/dist/plugin-sdk/conversation-runtime.js +4 -4
  715. package/dist/plugin-sdk/core.js +2 -2
  716. package/dist/plugin-sdk/direct-dm.js +1 -1
  717. package/dist/plugin-sdk/gateway-runtime.js +3 -3
  718. package/dist/plugin-sdk/image-generation-core.js +2 -2
  719. package/dist/plugin-sdk/inbound-reply-dispatch.js +1 -1
  720. package/dist/plugin-sdk/index.js +1 -1
  721. package/dist/plugin-sdk/infra-runtime.js +2 -2
  722. package/dist/plugin-sdk/irc.js +2 -2
  723. package/dist/plugin-sdk/matrix.js +1 -1
  724. package/dist/plugin-sdk/mattermost.js +2 -2
  725. package/dist/plugin-sdk/media-runtime.js +5 -5
  726. package/dist/plugin-sdk/media-understanding-runtime.js +2 -2
  727. package/dist/plugin-sdk/media-understanding.js +2 -2
  728. package/dist/plugin-sdk/memory-core-host-runtime-cli.js +2 -2
  729. package/dist/plugin-sdk/memory-core.js +2 -2
  730. package/dist/plugin-sdk/memory-host-search.js +1 -1
  731. package/dist/plugin-sdk/msteams.js +3 -3
  732. package/dist/plugin-sdk/nextcloud-talk.js +2 -2
  733. package/dist/plugin-sdk/nostr.js +1 -1
  734. package/dist/plugin-sdk/opencode.js +1 -1
  735. package/dist/plugin-sdk/outbound-runtime.js +2 -2
  736. package/dist/plugin-sdk/provider-auth-api-key.js +2 -2
  737. package/dist/plugin-sdk/provider-auth-login.js +1 -1
  738. package/dist/plugin-sdk/provider-auth.js +2 -2
  739. package/dist/plugin-sdk/provider-entry.js +1 -1
  740. package/dist/plugin-sdk/reply-dispatch-runtime.js +1 -1
  741. package/dist/plugin-sdk/reply-runtime.js +4 -4
  742. package/dist/plugin-sdk/runtime-doctor.js +1 -1
  743. package/dist/plugin-sdk/runtime-secret-resolution.js +1 -1
  744. package/dist/plugin-sdk/runtime.js +3 -3
  745. package/dist/plugin-sdk/sandbox.js +1 -1
  746. package/dist/plugin-sdk/session-store-runtime.js +1 -1
  747. package/dist/plugin-sdk/session-visibility.js +1 -1
  748. package/dist/plugin-sdk/skill-commands-runtime.js +1 -1
  749. package/dist/plugin-sdk/src/config/types.mcp.d.ts +13 -0
  750. package/dist/plugin-sdk/src/gateway/protocol/index.d.ts +29 -3
  751. package/dist/plugin-sdk/src/gateway/protocol/schema/mcp.d.ts +52 -0
  752. package/dist/plugin-sdk/src/gateway/protocol/schema/protocol-schemas.d.ts +52 -0
  753. package/dist/plugin-sdk/src/gateway/protocol/schema/types.d.ts +8 -0
  754. package/dist/plugin-sdk/testing.js +4 -4
  755. package/dist/plugin-sdk/tlon.js +1 -1
  756. package/dist/plugin-sdk/zalo.js +1 -1
  757. package/dist/plugin-sdk/zalouser.js +1 -1
  758. package/dist/plugin-service-Bcg-shsL.js +2893 -0
  759. package/dist/plugins/runtime/index.js +1 -1
  760. package/dist/plugins-cli-CUZMkYFB.js +584 -0
  761. package/dist/plugins-command-helpers-BGFL7yp7.js +107 -0
  762. package/dist/plugins-install-persist-Cp8tSsno.js +133 -0
  763. package/dist/plugins-update-command-Ds_N9qES.js +1057 -0
  764. package/dist/policy-DIf26_n6.js +328 -0
  765. package/dist/postinstall-inventory.json +711 -709
  766. package/dist/prepare.runtime-DCLXK1uq.js +807 -0
  767. package/dist/prepare.runtime.js +1 -1
  768. package/dist/probe-0w9S79sF.js +45 -0
  769. package/dist/probe-B1L2nZVS.js +243 -0
  770. package/dist/probe-BQT29JH7.js +74 -0
  771. package/dist/probe-CB6KR9ri.js +240 -0
  772. package/dist/probe-CWtFr2jl.js +2 -0
  773. package/dist/probe-CcBuLmYT.js +2205 -0
  774. package/dist/probe-DYqlJBSk.js +2 -0
  775. package/dist/probe-_IUalbC8.js +1443 -0
  776. package/dist/program-sXJs6Lyj.js +111 -0
  777. package/dist/prompt-select-styled-jucMgA5f.js +20 -0
  778. package/dist/protocol-DgMCJAA_.js +2586 -0
  779. package/dist/provider-BSqWTcoz.js +70 -0
  780. package/dist/provider-api-key-auth-C92t3JTu.js +131 -0
  781. package/dist/provider-api-key-auth.runtime.js +1 -1
  782. package/dist/provider-auth-api-key-zf0PU9U_.js +5 -0
  783. package/dist/provider-auth-choice-palZRKPG.js +228 -0
  784. package/dist/provider-auth-hCEy91hA.js +46 -0
  785. package/dist/provider-auth-login-D4MC4bs_.js +8 -0
  786. package/dist/provider-auth-login.runtime.js +1 -1
  787. package/dist/provider-dispatcher-9z9Dw59_.js +2 -0
  788. package/dist/provider-dispatcher-DyQNST2Z.js +22 -0
  789. package/dist/provider-entry-DZDgzWTU.js +106 -0
  790. package/dist/provider-model-defaults-DC1PMV0H.js +6 -0
  791. package/dist/provider-registration-BSHUosM7.js +218 -0
  792. package/dist/provider-registration-CA9-PRDk.js +37 -0
  793. package/dist/qr-cli-Dwc3sjiV.js +2 -0
  794. package/dist/qr-cli-hTiyQbbK.js +349 -0
  795. package/dist/qr-image-BDoVY1GF.js +2 -0
  796. package/dist/queue-BljsBBtU.js +409 -0
  797. package/dist/reaction-runtime-api-Q9NHKbpw.js +116 -0
  798. package/dist/reactions-DGczAFsd.js +998 -0
  799. package/dist/read-capability-YFf_CDLF.js +412 -0
  800. package/dist/register-service-commands-Dxwl01rR.js +71 -0
  801. package/dist/register.agent-Drovpr_f.js +248 -0
  802. package/dist/register.configure-BzQtmjqp.js +15 -0
  803. package/dist/register.maintenance-PRykY6qq.js +363 -0
  804. package/dist/register.message-Dw6OLnap.js +329 -0
  805. package/dist/register.onboard-CB7aqo8I.js +88 -0
  806. package/dist/register.runtime-5QpZP1PI.js +81 -0
  807. package/dist/register.runtime.js +1 -1
  808. package/dist/register.setup-GLc__3H1.js +150 -0
  809. package/dist/register.status-health-sessions-DuQnS6V7.js +1215 -0
  810. package/dist/register.subclis-Bupq6ckp.js +3 -0
  811. package/dist/register.subclis-Df0YvsXg.js +29 -0
  812. package/dist/register.subclis-core-CK63Nor4.js +249 -0
  813. package/dist/reply-dispatch-runtime-D63ANCTQ.js +13 -0
  814. package/dist/reply-media-paths.runtime-C6-V86g1.js +146 -0
  815. package/dist/reply-media-paths.runtime-Cmms8y5S.js +2 -0
  816. package/dist/reply-media-paths.runtime.js +1 -1
  817. package/dist/reply-runtime-CLq8xugv.js +10 -0
  818. package/dist/reply.runtime-FitoWYiX.js +2 -0
  819. package/dist/reply.runtime.js +1 -1
  820. package/dist/resolve-BHmKuinY.js +259 -0
  821. package/dist/response-generator-BxzbAKHi.js +175 -0
  822. package/dist/restart-health-CNE6ENF8.js +202 -0
  823. package/dist/restart-health-DriNCEEo.js +2 -0
  824. package/dist/root-help-BsG62TUK.js +44 -0
  825. package/dist/route-reply-EPkWewCQ.js +162 -0
  826. package/dist/route-reply.runtime-Rem8ixbJ.js +2 -0
  827. package/dist/route-reply.runtime.js +1 -1
  828. package/dist/routes-B8SmZM_C.js +3341 -0
  829. package/dist/routes-CVtIuQaj.js +2 -0
  830. package/dist/rpc-AJw8-VEF.js +61 -0
  831. package/dist/rpc.runtime-NzXXr3IH.js +21 -0
  832. package/dist/rpc.runtime.js +1 -1
  833. package/dist/run-auth-profile.runtime-DrFMFMa5.js +2 -0
  834. package/dist/run-auth-profile.runtime.js +1 -1
  835. package/dist/run-delivery.runtime-DDc5pTuc.js +530 -0
  836. package/dist/run-delivery.runtime.js +1 -1
  837. package/dist/run-embedded.runtime-BlLE0DKl.js +4 -0
  838. package/dist/run-embedded.runtime.js +1 -1
  839. package/dist/run-execution-cli.runtime-Dx9bn2nL.js +4 -0
  840. package/dist/run-execution-cli.runtime.js +1 -1
  841. package/dist/run-executor.runtime-Bx0-xr66.js +277 -0
  842. package/dist/run-executor.runtime.js +1 -1
  843. package/dist/run-main-Q7WXDun9.js +567 -0
  844. package/dist/run-subagent-registry.runtime-DN441nGA.js +2 -0
  845. package/dist/run-subagent-registry.runtime.js +1 -1
  846. package/dist/run-wait-DOOBZLr5.js +135 -0
  847. package/dist/runner-B8D0Coak.js +966 -0
  848. package/dist/runner.entries-DZUGr24v.js +604 -0
  849. package/dist/runtime-B56xKFjA.js +9 -0
  850. package/dist/runtime-BshnyUPo.js +116 -0
  851. package/dist/runtime-CnTeeNB7.js +72 -0
  852. package/dist/runtime-D--xK0Me.js +961 -0
  853. package/dist/runtime-DFBduVee.js +2 -0
  854. package/dist/runtime-api-BGOAhjcp.js +9 -0
  855. package/dist/runtime-api-CcUMXjjy.js +14 -0
  856. package/dist/runtime-api-L9lB-rDz.js +4 -0
  857. package/dist/runtime-api-ap0gPIKQ.js +9 -0
  858. package/dist/runtime-co7Um4tt.js +263 -0
  859. package/dist/runtime-embedded-pi.runtime-CQ5TsVlh.js +2 -0
  860. package/dist/runtime-embedded-pi.runtime.js +1 -1
  861. package/dist/runtime-entry-g38-J35c.js +2769 -0
  862. package/dist/runtime-internal-DwAoh64o.js +2 -0
  863. package/dist/runtime-manifest.runtime.js +1 -1
  864. package/dist/runtime-options-CtF_gotz.js +275 -0
  865. package/dist/runtime-prepare.runtime-DAaAh4tU.js +80 -0
  866. package/dist/runtime-prepare.runtime.js +1 -1
  867. package/dist/runtime-schema-7aqYdEly.js +28599 -0
  868. package/dist/runtime-web-tools-DpTEm5uJ.js +1477 -0
  869. package/dist/runtime-web-tools-fallback.runtime.js +1 -1
  870. package/dist/runtime-web-tools-manifest.runtime.js +1 -1
  871. package/dist/runtime-web-tools-public-artifacts.runtime.js +1 -1
  872. package/dist/sandbox-DjUUwvID.js +3 -0
  873. package/dist/sandbox-IL2pQunA.js +1156 -0
  874. package/dist/sandbox-cli-C75oWfKU.js +450 -0
  875. package/dist/scan-BmfJ_GUd.js +2 -0
  876. package/dist/scan-BwUXPVa4.js +523 -0
  877. package/dist/secrets-cli-Byrmt5p3.js +2101 -0
  878. package/dist/security-cli-Cb_qzWSU.js +486 -0
  879. package/dist/selection-BaZ-7Sz6.js +2 -0
  880. package/dist/selection-C8rwxPqg.js +7743 -0
  881. package/dist/send-C3Ht9Buu.js +102 -0
  882. package/dist/send-NpRBz3rn.js +156 -0
  883. package/dist/send.runtime-Buvd_P2p.js +2 -0
  884. package/dist/send.runtime.js +1 -1
  885. package/dist/server-B8tim7RO.js +13 -0
  886. package/dist/server-ClAvfJJm.js +77 -0
  887. package/dist/server-context-Dl7OQ56d.js +2 -0
  888. package/dist/server-context-F2Jh0JBO.js +847 -0
  889. package/dist/server-node-events-Db8SbNO0.js +474 -0
  890. package/dist/server-plugin-bootstrap-DxpFA7AU.js +13703 -0
  891. package/dist/server-plugin-bootstrap-t6Z_tN0J.js +2 -0
  892. package/dist/server-restart-sentinel-VLhFJOy5.js +684 -0
  893. package/dist/server.impl-BNDZK6Lv.js +12804 -0
  894. package/dist/session-BThNEh5u.js +48 -0
  895. package/dist/session-archive.runtime.js +1 -1
  896. package/dist/session-envelope-tBfpcRRu.js +18 -0
  897. package/dist/session-key-De2wQZ8k.js +65 -0
  898. package/dist/session-kill-http-C35_XMK_.js +110 -0
  899. package/dist/session-meta-Bpv85XpZ.js +109 -0
  900. package/dist/session-override-dIx8boay.js +106 -0
  901. package/dist/session-reset-model.runtime-BY5KYxcY.js +133 -0
  902. package/dist/session-reset-model.runtime.js +1 -1
  903. package/dist/session-reset-service-Cs7o8vTZ.js +497 -0
  904. package/dist/session-route-DwjrtcvV.js +93 -0
  905. package/dist/session-status.runtime-Cp9hECfs.js +2 -0
  906. package/dist/session-status.runtime.js +1 -1
  907. package/dist/session-store-DT5H5NRv.js +126 -0
  908. package/dist/session-store.runtime-CoRuKMfZ.js +2 -0
  909. package/dist/session-store.runtime.js +1 -1
  910. package/dist/session-subagent-reactivation.runtime-3hC6cwVh.js +2 -0
  911. package/dist/session-subagent-reactivation.runtime.js +1 -1
  912. package/dist/session-tab-registry-BHn1P3lZ.js +581 -0
  913. package/dist/session-updates-CHKrFM9H.js +236 -0
  914. package/dist/session-updates.runtime-CqylTFnb.js +2 -0
  915. package/dist/session-updates.runtime.js +1 -1
  916. package/dist/session-utils-otyfumhD.js +1009 -0
  917. package/dist/session-visibility-C5yhLdDZ.js +147 -0
  918. package/dist/sessions-BjHLgqjt.js +2 -0
  919. package/dist/sessions-C1_80mqv.js +48 -0
  920. package/dist/sessions-DjIcw5uP.js +281 -0
  921. package/dist/sessions-helpers-C_xGZAo7.js +305 -0
  922. package/dist/sessions-history-http-CQ-Ga5H3.js +371 -0
  923. package/dist/sessions-patch-XzBTc4fY.js +309 -0
  924. package/dist/sessions-resolve-CF4QOXiX.js +174 -0
  925. package/dist/sessions-w6UJYMea.js +16 -0
  926. package/dist/sessions.runtime-CEV3VtEH.js +2 -0
  927. package/dist/sessions.runtime.js +1 -1
  928. package/dist/setup-BrkQiUrj.js +421 -0
  929. package/dist/setup-D218KRK6.js +636 -0
  930. package/dist/setup-api-BvHlVezg.js +29 -0
  931. package/dist/setup-core-BjceveVY.js +171 -0
  932. package/dist/setup-core-CxDIk2Qq.js +176 -0
  933. package/dist/setup-surface-6hnrFGJ3.js +286 -0
  934. package/dist/setup-surface-BBDyg26_.js +219 -0
  935. package/dist/setup-surface-HREO9zEo.js +403 -0
  936. package/dist/setup.finalize-CAJxf_Mm.js +547 -0
  937. package/dist/setup.gateway-config-g6JfCjT4.js +250 -0
  938. package/dist/shared-CJ2_38Ar.js +198 -0
  939. package/dist/shared-CecRnN5i.js +76 -0
  940. package/dist/shared-G254rWzJ.js +217 -0
  941. package/dist/shared-Zan1S92i.js +121 -0
  942. package/dist/shared-runtime-CKzUXuwN.js +7 -0
  943. package/dist/skill-commands-DWC_vZ-J.js +83 -0
  944. package/dist/skill-commands.runtime-BMmD4lyW.js +2 -0
  945. package/dist/skill-commands.runtime.js +1 -1
  946. package/dist/skills-install-Bpfq1PgX.js +605 -0
  947. package/dist/skills-snapshot.runtime-uSs9vmlj.js +7 -0
  948. package/dist/skills-snapshot.runtime.js +1 -1
  949. package/dist/slash-state-EXy1B2EX.js +1911 -0
  950. package/dist/speech-provider-CcbYv8ap.js +216 -0
  951. package/dist/speech-provider-Cr1h-_-X.js +170 -0
  952. package/dist/speech-provider-Gif_hcpc.js +209 -0
  953. package/dist/src-Dda8Fvmo.js +3974 -0
  954. package/dist/stage-sandbox-media.runtime-_FkeTCA0.js +232 -0
  955. package/dist/stage-sandbox-media.runtime.js +1 -1
  956. package/dist/startup-context-BLtyYbKu.js +312 -0
  957. package/dist/state-migrations-BXYrr3Hc.js +820 -0
  958. package/dist/status-B1RXiDvc.js +3 -0
  959. package/dist/status-B4tnoXkV.js +2 -0
  960. package/dist/status-BWXZC-dF.js +2 -0
  961. package/dist/status-CUZkKe39.js +62 -0
  962. package/dist/status-DNnTegVL.js +395 -0
  963. package/dist/status-G3Z29Cb_.js +190 -0
  964. package/dist/status-all-pjolmMGB.js +498 -0
  965. package/dist/status-json-BKR5uVlE.js +14 -0
  966. package/dist/status-json-command-DuIQ8dNz.js +82 -0
  967. package/dist/status-message-CZyHmUQr.js +466 -0
  968. package/dist/status-message.runtime-C1I59_ay.js +6 -0
  969. package/dist/status-message.runtime.js +1 -1
  970. package/dist/status-n2SrcSeP.js +209 -0
  971. package/dist/status-queue.runtime-k2kdii3C.js +2 -0
  972. package/dist/status-queue.runtime.js +1 -1
  973. package/dist/status-runtime-shared-9akPh3OB.js +241 -0
  974. package/dist/status-subagents.runtime-C-2-94r7.js +18 -0
  975. package/dist/status-subagents.runtime.js +1 -1
  976. package/dist/status-text-DY-AMW7D.js +237 -0
  977. package/dist/status.gateway-connection.runtime-CGwlyVSQ.js +2 -0
  978. package/dist/status.gateway-connection.runtime.js +1 -1
  979. package/dist/status.gather-C17tVkff.js +2 -0
  980. package/dist/status.gather-CGXwFKnq.js +292 -0
  981. package/dist/status.runtime-DdcRs0mC.js +2 -0
  982. package/dist/status.runtime-L3R8cOql.js +2 -0
  983. package/dist/status.runtime.js +1 -1
  984. package/dist/status.scan-BSIqJF_S.js +65 -0
  985. package/dist/status.scan-overview-CbwLYoIT.js +379 -0
  986. package/dist/status.scan.fast-json-BnpfFSN8.js +2 -0
  987. package/dist/status.scan.fast-json-W54JDFUy.js +132 -0
  988. package/dist/status.summary-CeaTG93y.js +2 -0
  989. package/dist/status.summary-LPaYBiqB.js +200 -0
  990. package/dist/store-BtHVDH2Q.js +910 -0
  991. package/dist/store-Qn6Vf7Ma.js +4 -0
  992. package/dist/store.runtime-Dd3L_GjJ.js +2 -0
  993. package/dist/store.runtime.js +1 -1
  994. package/dist/stream-CImPPcyN.js +664 -0
  995. package/dist/subagent-announce-Dn5xl49E.js +351 -0
  996. package/dist/subagent-announce-delivery-CpVHT0KZ.js +726 -0
  997. package/dist/subagent-announce-output-Ba8GDqQZ.js +364 -0
  998. package/dist/subagent-capabilities-DN1kjzNE.js +251 -0
  999. package/dist/subagent-control-Clm3gsra.js +506 -0
  1000. package/dist/subagent-control.runtime-D9vrLexA.js +3 -0
  1001. package/dist/subagent-control.runtime.js +1 -1
  1002. package/dist/subagent-followup.runtime-OlILj5hg.js +68 -0
  1003. package/dist/subagent-followup.runtime.js +1 -1
  1004. package/dist/subagent-orphan-recovery-Dqi7ktSy.js +305 -0
  1005. package/dist/subagent-registry-BfT1dA_H.js +3 -0
  1006. package/dist/subagent-registry-DsOeyo6i.js +1753 -0
  1007. package/dist/subagent-registry.runtime.js +1 -1
  1008. package/dist/subagent-spawn-IMKDJ_Ai.js +1005 -0
  1009. package/dist/supervisor-DgpKTzey.js +704 -0
  1010. package/dist/supervisor-log.runtime.js +1 -1
  1011. package/dist/system-cli-QcbUPgUP.js +43 -0
  1012. package/dist/targets-rJXMe19f.js +67 -0
  1013. package/dist/targets.runtime.js +1 -1
  1014. package/dist/task-executor-CT_QfGPJ.js +360 -0
  1015. package/dist/task-owner-access-Bm14vxJa.js +74 -0
  1016. package/dist/task-registry-D6gK7iIt.js +2357 -0
  1017. package/dist/task-registry-delivery-runtime-CDAeASdU.js +2 -0
  1018. package/dist/task-registry-delivery-runtime-CeWw5kdc.js +3 -0
  1019. package/dist/task-registry.maintenance-B5hpULqB.js +416 -0
  1020. package/dist/task-registry.maintenance-DZFQCCjc.js +2 -0
  1021. package/dist/telegram/token.js +2 -2
  1022. package/dist/testing-B2Y0vJ76.js +575 -0
  1023. package/dist/text-report-0Q8c04if.js +549 -0
  1024. package/dist/tool-auth-shared-Ca0wddYT.js +90 -0
  1025. package/dist/tool-policy-pipeline-BLtvEs31.js +109 -0
  1026. package/dist/tool-resolution-CHcj9HdC.js +90 -0
  1027. package/dist/tools-effective-inventory-Giuks2Dt.js +152 -0
  1028. package/dist/tools-invoke-http-FlaWbmCS.js +206 -0
  1029. package/dist/transcript-resolve.runtime-wnJiuCEb.js +2 -0
  1030. package/dist/transcript-resolve.runtime.js +1 -1
  1031. package/dist/transcript-yKXsllQ2.js +312 -0
  1032. package/dist/transcript.runtime-CmcFZQq0.js +2 -0
  1033. package/dist/transcript.runtime.js +1 -1
  1034. package/dist/trash-BzlpkaUi.js +24 -0
  1035. package/dist/tts-BG_1G2S6.js +64 -0
  1036. package/dist/tui-cli-B9Emgd5Q.js +4585 -0
  1037. package/dist/uninstall-B6U2msaD.js +185 -0
  1038. package/dist/update-BjKPsXUk.js +1282 -0
  1039. package/dist/update-cli-ln47pDmA.js +1759 -0
  1040. package/dist/update-startup-Xs6Edz-d.js +2 -0
  1041. package/dist/upgrade-Ctu4zfU3.js +1226 -0
  1042. package/dist/video-generation-provider-B0W1RcQj.js +264 -0
  1043. package/dist/video-generation-provider-B2XcJK8B.js +221 -0
  1044. package/dist/video-generation-provider-BJt8-Jzh.js +254 -0
  1045. package/dist/video-generation-provider-Bsz88Y8I.js +78 -0
  1046. package/dist/video-generation-provider-CmN0n1aP.js +271 -0
  1047. package/dist/video-generation-provider-DKFpHGWz.js +64 -0
  1048. package/dist/video-generation-provider-LgYMFJAm.js +281 -0
  1049. package/dist/video-generation-provider-j1OQMvjr2.js +77 -0
  1050. package/dist/video-generation-provider-lI_tgIiA.js +287 -0
  1051. package/dist/video-generation-provider-uVzVbp2s.js +118 -0
  1052. package/dist/video-generation-provider-xQ4AZkeK.js +187 -0
  1053. package/dist/video-generation-task-status-AzBxxMK4.js +163 -0
  1054. package/dist/wait-for-idle-before-flush-D4a3dGVX.js +6025 -0
  1055. package/dist/web-search-provider-Bt8NRG25.js +163 -0
  1056. package/dist/wizard-models-DpLispoG.js +334 -0
  1057. package/dist/workflow-runtime-C0jGj382.js +485 -0
  1058. package/package.json +1 -1
  1059. package/dist/abort-DUTWX49H.js +0 -201
  1060. package/dist/abort-cutoff.runtime-oLWHRfE6.js +0 -20
  1061. package/dist/abort.runtime-B1CZPj3m.js +0 -2
  1062. package/dist/accounts-DFJuQd32.js +0 -107
  1063. package/dist/accounts-VbCry_MV.js +0 -104
  1064. package/dist/accounts-ZduaK0fO.js +0 -2
  1065. package/dist/acp-cli-Cyqn8a7z.js +0 -2217
  1066. package/dist/acp-spawn-B1O0qwkN.js +0 -2
  1067. package/dist/acp-spawn-C2eEj7wR.js +0 -1042
  1068. package/dist/acp-stateful-target-driver-BKL2flGw.js +0 -89
  1069. package/dist/action-agents-C9zs0A_N.js +0 -67
  1070. package/dist/action-focus-Dj2trHbP.js +0 -132
  1071. package/dist/action-help-ENFS-VRC.js +0 -7
  1072. package/dist/action-info-IKxta-Me.js +0 -101
  1073. package/dist/action-kill-CJGjsHX-.js +0 -33
  1074. package/dist/action-list-ChLdMXon.js +0 -21
  1075. package/dist/action-log-CdeugqCO.js +0 -30
  1076. package/dist/action-send-BvUjnmVw.js +0 -39
  1077. package/dist/action-spawn-Xq0DpbW7.js +0 -47
  1078. package/dist/action-unfocus-DfcihOhT.js +0 -29
  1079. package/dist/actions.runtime-CTjuTpQ1.js +0 -18
  1080. package/dist/actions.runtime-Dp93aqpg.js +0 -5
  1081. package/dist/agent-DQZeYp3u.js +0 -2
  1082. package/dist/agent-command-CynPQd5_.js +0 -874
  1083. package/dist/agent-harness-runtime-D9PrghSe.js +0 -144
  1084. package/dist/agent-runner-utils-CwDT31Pp.js +0 -239
  1085. package/dist/agent-runner.runtime-kH3GCoKg.js +0 -3443
  1086. package/dist/agent-runtime-BSwK1sup.js +0 -18
  1087. package/dist/agents-C9BmPj-C.js +0 -954
  1088. package/dist/agents-CQQ7cNF9.js +0 -5
  1089. package/dist/agents.command-shared-cZa4UKga.js +0 -40
  1090. package/dist/aliases-B92uAzO2.js +0 -2
  1091. package/dist/aliases-BZsZGqVQ.js +0 -96
  1092. package/dist/api-CU22wCTp.js +0 -139
  1093. package/dist/api-DD_eTeli.js +0 -5
  1094. package/dist/api-DIKi1Ni8.js +0 -4
  1095. package/dist/api-i4W2Wwd4.js +0 -48
  1096. package/dist/api-sngIL0OQ.js +0 -3
  1097. package/dist/apply-oUSa2Pf0.js +0 -508
  1098. package/dist/apply.runtime-BLCi2Ivv.js +0 -166
  1099. package/dist/apply.runtime-D_hTG_Y0.js +0 -2
  1100. package/dist/approval-gateway-resolver-KouhItZO.js +0 -29
  1101. package/dist/approval-gateway-runtime-D7CzOIgq.js +0 -2
  1102. package/dist/approval-handler-runtime-CFvI_pZS.js +0 -439
  1103. package/dist/approval-native-runtime-rl6s6chH.js +0 -729
  1104. package/dist/attempt-execution.runtime-Ba87IenS.js +0 -509
  1105. package/dist/attempt-execution.shared-BY_ARPh1.js +0 -22
  1106. package/dist/attempt.prompt-helpers-BbBNMjqU.js +0 -206
  1107. package/dist/attempt.tool-run-context-CLlg_9Gq.js +0 -933
  1108. package/dist/audit-CQJwJFWH.js +0 -939
  1109. package/dist/audit-extra.async-BbZcluVr.js +0 -971
  1110. package/dist/audit-tool-policy-C0lIM9Fp.js +0 -3
  1111. package/dist/audit.deep.runtime-CXjulrWI.js +0 -2
  1112. package/dist/audit.nondeep.runtime-nu5XTu7N.js +0 -880
  1113. package/dist/audit.runtime-CW5CY88A.js +0 -7
  1114. package/dist/auth-CzjcgD0-.js +0 -177
  1115. package/dist/auth-DFhah4e4.js +0 -2
  1116. package/dist/auth-DQw5zHDJ.js +0 -56
  1117. package/dist/auth-choice-CXWHXiQK.js +0 -3
  1118. package/dist/auth-choice-DGMF0dBk.js +0 -85
  1119. package/dist/auth-order-CMWxvLX4.js +0 -2
  1120. package/dist/auth-order-D6mEMqD7.js +0 -139
  1121. package/dist/auth-s-3q__5n.js +0 -550
  1122. package/dist/bash-tools-BCSXSkhx.js +0 -2853
  1123. package/dist/bash-tools-D2NO8-ph.js +0 -3
  1124. package/dist/bash-tools.exec-runtime-CVOp5fHn.js +0 -823
  1125. package/dist/binding-routing-DROXsDQk.js +0 -85
  1126. package/dist/binding-targets-D33MkugL.js +0 -121
  1127. package/dist/bridge-server-3gO7JmL_.js +0 -113
  1128. package/dist/browser-control-auth-DS3Wwm1z.js +0 -2
  1129. package/dist/browser-node-runtime-DkVkb3tt.js +0 -12
  1130. package/dist/browser-profiles-Bk9dcXzv.js +0 -2
  1131. package/dist/browser-runtime-dGM3ZeLa.js +0 -387
  1132. package/dist/browser-setup-tools-DSgChJEe.js +0 -13
  1133. package/dist/build-CjLf_jQl.js +0 -550
  1134. package/dist/call-BxIEVH5N.js +0 -3
  1135. package/dist/call-Dwj7PrNe.js +0 -330
  1136. package/dist/call.runtime-mZvFxL4G.js +0 -2
  1137. package/dist/capability-cli-C-6omBAD.js +0 -1401
  1138. package/dist/catalog-provider-RQJYkKkq.js +0 -40
  1139. package/dist/catchup-Dfw4DEMS.js +0 -300
  1140. package/dist/channel-4YVnFcIj.js +0 -297
  1141. package/dist/channel-BajDSspb.js +0 -1320
  1142. package/dist/channel-BcS5ghfF.js +0 -840
  1143. package/dist/channel-BlU_cVm0.js +0 -491
  1144. package/dist/channel-BmZ19q9d.js +0 -453
  1145. package/dist/channel-C4KfOdTm.js +0 -226
  1146. package/dist/channel-C7LNJi1M.js +0 -595
  1147. package/dist/channel-CFxTIjzU.js +0 -1174
  1148. package/dist/channel-CYDnIh3Z.js +0 -350
  1149. package/dist/channel-DBUj2Ysq.js +0 -1802
  1150. package/dist/channel-DwWdEu7o.js +0 -1100
  1151. package/dist/channel-add-wizard-BLjklZ70.js +0 -2
  1152. package/dist/channel-add-wizard-C3BysW2-.js +0 -125
  1153. package/dist/channel-core-VlXrdyfV.js +0 -5
  1154. package/dist/channel-inbound-BzALE-tz.js +0 -31
  1155. package/dist/channel-plugin-resolution-BNbz8s_s.js +0 -153
  1156. package/dist/channel-plugin-resolution-Bey1o2RL.js +0 -2
  1157. package/dist/channel-plugin-runtime-BMmEKuoC.js +0 -771
  1158. package/dist/channel-runtime-BZXgyMUr.js +0 -425
  1159. package/dist/channel-setup-BzbhDDrt.js +0 -1297
  1160. package/dist/channel.runtime-2Kw88P7w.js +0 -576
  1161. package/dist/channel.runtime-Bwnky7Bn.js +0 -2364
  1162. package/dist/channel.runtime-CDvvT7UR.js +0 -4
  1163. package/dist/channel.runtime-CgP4n1an.js +0 -430
  1164. package/dist/channel.runtime-MJe9DoSG.js +0 -89
  1165. package/dist/channel.runtime-f0WEEj3o.js +0 -42398
  1166. package/dist/channel.setup-DaZBK_2E.js +0 -10
  1167. package/dist/channel2.runtime-CfVIjEhU.js +0 -109
  1168. package/dist/channels-Bq1GXmZX.js +0 -733
  1169. package/dist/channels-cli-DzbssQ5L.js +0 -268
  1170. package/dist/chat-CNZDzOWR.js +0 -2830
  1171. package/dist/clawbot-cli-UIo3UVaj.js +0 -9
  1172. package/dist/clawhub-DRNYT4Ih.js +0 -400
  1173. package/dist/cli-2nlB-dHJ.js +0 -154
  1174. package/dist/cli-7dTpJC3M.js +0 -2
  1175. package/dist/cli-BGMFTnb1.js +0 -683
  1176. package/dist/cli-BVKDWfwH.js +0 -72
  1177. package/dist/cli-Bp52OQjs.js +0 -219
  1178. package/dist/cli-C26tWLBw.js +0 -3726
  1179. package/dist/cli-C_289Xdv.js +0 -2
  1180. package/dist/cli-kOop_NSN.js +0 -2
  1181. package/dist/cli-runner-CP51WTPf.js +0 -286
  1182. package/dist/cli-runner.runtime-BtArNV63.js +0 -4
  1183. package/dist/cli-runner.runtime-Dy1IJ7UX.js +0 -3
  1184. package/dist/cli.runtime-2ilydgLb.js +0 -1261
  1185. package/dist/client-BN8cDQr7.js +0 -723
  1186. package/dist/client-Doc6u1up.js +0 -138
  1187. package/dist/command-auth-oo_Iz0oe.js +0 -76
  1188. package/dist/command-config-resolution-BNQbV_C6.js +0 -23
  1189. package/dist/command-config-resolution-DIvkjwvj.js +0 -2
  1190. package/dist/command-config-resolution.runtime-Dlk7LIJ8.js +0 -2
  1191. package/dist/command-execution-startup-DtBNBU06.js +0 -324
  1192. package/dist/command-registry-Dm8ohcSP.js +0 -4
  1193. package/dist/command-registry-core-BxyHXEQ3.js +0 -106
  1194. package/dist/command-registry-xVmA85-_.js +0 -9
  1195. package/dist/command-secret-gateway-Dej2E5rP.js +0 -528
  1196. package/dist/command-status.runtime-CWgNMJi1.js +0 -87
  1197. package/dist/commands-acp-Ca0l7esb.js +0 -77
  1198. package/dist/commands-compact.runtime-DBN1EALw.js +0 -10
  1199. package/dist/commands-core.runtime-CXYQlfla.js +0 -2
  1200. package/dist/commands-handlers.runtime-BrCljWio.js +0 -4599
  1201. package/dist/commands-reset-hooks-C-P5vfWa.js +0 -135
  1202. package/dist/commands-status-C0WYf99K.js +0 -16
  1203. package/dist/commands-status.runtime-Czim-9LY.js +0 -3
  1204. package/dist/commands-subagents-control.runtime-CgiW2mpD.js +0 -3
  1205. package/dist/commands-subagents-control.runtime-oCqEcwa7.js +0 -2
  1206. package/dist/commands-system-prompt-BQHZNtSZ.js +0 -157
  1207. package/dist/commands-system-prompt-ClJDN8rr.js +0 -2
  1208. package/dist/commands.runtime-DwmtsbUc.js +0 -167
  1209. package/dist/compact-DDf0xr2o.js +0 -1096
  1210. package/dist/compact.runtime-C4BZuDjJ.js +0 -12
  1211. package/dist/completion-cli-85iaysB7.js +0 -328
  1212. package/dist/config-CHPRDFh1.js +0 -252
  1213. package/dist/config-cli-DSZ7DNtq.js +0 -1078
  1214. package/dist/config-guard-Ca-1hhke.js +0 -96
  1215. package/dist/config-runtime-AtYct3A3.js +0 -32
  1216. package/dist/configure-BR6m0uoi.js +0 -1252
  1217. package/dist/configure-CC09fyLr.js +0 -2
  1218. package/dist/connect-options-HotLjDKX.js +0 -699
  1219. package/dist/control-auth-CBtOUnsz.js +0 -125
  1220. package/dist/control-service-D2A1PyZC.js +0 -156
  1221. package/dist/control-ui/assets/agents-7cSPVJV0.js +0 -1125
  1222. package/dist/control-ui/assets/canvas-IIhBIoAa.js +0 -274
  1223. package/dist/control-ui/assets/channel-config-extras-sj_UXv9J.js +0 -2
  1224. package/dist/control-ui/assets/channels-B4MTYg8u.js +0 -198
  1225. package/dist/control-ui/assets/contacts-CSch1ckf.js +0 -49
  1226. package/dist/control-ui/assets/cron-B548qeSj.js +0 -250
  1227. package/dist/control-ui/assets/de-DOykxjSu.js +0 -2
  1228. package/dist/control-ui/assets/debug-DERT6TQG.js +0 -94
  1229. package/dist/control-ui/assets/es-BTwWEPGm.js +0 -2
  1230. package/dist/control-ui/assets/fr-DVRwR98L.js +0 -2
  1231. package/dist/control-ui/assets/i18n-BPOQLrbx.js +0 -3
  1232. package/dist/control-ui/assets/id-BSBAUAzK.js +0 -2
  1233. package/dist/control-ui/assets/index-C2CxJps0.js +0 -5981
  1234. package/dist/control-ui/assets/instances-DwteyRRi.js +0 -57
  1235. package/dist/control-ui/assets/ja-JP-BiD5eOfG.js +0 -2
  1236. package/dist/control-ui/assets/ko-BNgLBJdW.js +0 -2
  1237. package/dist/control-ui/assets/logs-GdE34D7D.js +0 -74
  1238. package/dist/control-ui/assets/mcp-z76x2vB5.js +0 -380
  1239. package/dist/control-ui/assets/memory-CsTbP2T4.js +0 -50
  1240. package/dist/control-ui/assets/memory-graph-DbZEkTHJ.js +0 -30
  1241. package/dist/control-ui/assets/models-j_tXq7Pe.js +0 -86
  1242. package/dist/control-ui/assets/nodes-cxO9Enln.js +0 -654
  1243. package/dist/control-ui/assets/pl-DrVcqC4t.js +0 -2
  1244. package/dist/control-ui/assets/plugins-Rt--bQFn.js +0 -259
  1245. package/dist/control-ui/assets/presenter-BiJsRhTg.js +0 -2
  1246. package/dist/control-ui/assets/pt-BR-BXlBG1WX.js +0 -2
  1247. package/dist/control-ui/assets/sessions-CP6r0JAQ.js +0 -56
  1248. package/dist/control-ui/assets/skills-CMy2whFb.js +0 -294
  1249. package/dist/control-ui/assets/skills-shared-B-3kgWg3.js +0 -11
  1250. package/dist/control-ui/assets/th-DjtYmyBR.js +0 -2
  1251. package/dist/control-ui/assets/tr-I0LYx0Ew.js +0 -2
  1252. package/dist/control-ui/assets/uk-xilwRRzQ.js +0 -2
  1253. package/dist/control-ui/assets/wallet-geRdfgso.js +0 -302
  1254. package/dist/control-ui/assets/zh-CN-DHz_bYy_.js +0 -2
  1255. package/dist/control-ui/assets/zh-TW-LvBbVYeU.js +0 -2
  1256. package/dist/control-ui-Djt0XDNa.js +0 -1043
  1257. package/dist/conversation-id-BwNpVXFJ.js +0 -235
  1258. package/dist/conversation-id-CTAeVE9E.js +0 -38
  1259. package/dist/conversation-runtime-D6miDW4s.js +0 -31
  1260. package/dist/core-CYaV0wrq.js +0 -275
  1261. package/dist/create-DN7NWqCZ.js +0 -80
  1262. package/dist/cron-cli-BZacbTRu.js +0 -713
  1263. package/dist/daemon-cli-BXtGpvAS.js +0 -12
  1264. package/dist/dashboard-Ds7c6TJm.js +0 -2
  1265. package/dist/dashboard-s1prqGuB.js +0 -81
  1266. package/dist/delegate-nycMaKrd.js +0 -64
  1267. package/dist/deliver-BedUVIQP.js +0 -747
  1268. package/dist/deliver-DPvG5Qo8.js +0 -3
  1269. package/dist/deliver-runtime-DZlx42y2.js +0 -2
  1270. package/dist/delivery-outbound.runtime-Dyo6zcqN.js +0 -6
  1271. package/dist/delivery.runtime-CmuJYXg1.js +0 -253
  1272. package/dist/detached-task-runtime-DXFEjX_Y.js +0 -73
  1273. package/dist/devices-cli-B2T4Rk-c.js +0 -498
  1274. package/dist/diagnostics-669Ookpz.js +0 -154
  1275. package/dist/direct-dm-Bwx0l0B5.js +0 -64
  1276. package/dist/directive-handling.fast-lane-Vuy-nG2-.js +0 -66
  1277. package/dist/directive-handling.impl-DrE_GeZR.js +0 -2
  1278. package/dist/directive-handling.impl-KH2zUp6M.js +0 -703
  1279. package/dist/directive-handling.model-selection-BiW8QHW-.js +0 -114
  1280. package/dist/directive-handling.persist.runtime-VLCtMqO5.js +0 -215
  1281. package/dist/directory-cli-DQRcL8xw.js +0 -240
  1282. package/dist/dispatch-CVFq_KHF.js +0 -1131
  1283. package/dist/dispatch-acp-AeVrqG1P.js +0 -981
  1284. package/dist/dispatch-acp-manager.runtime-t90xTijh.js +0 -3
  1285. package/dist/dispatch-acp-media.runtime-Bq9nReBk.js +0 -4
  1286. package/dist/dispatch-acp-session.runtime-CKts6zqY.js +0 -2
  1287. package/dist/dispatch-acp.runtime-CLS-txJr.js +0 -19
  1288. package/dist/doctor-config-flow-C1S8B_sg.js +0 -420
  1289. package/dist/doctor-config-preflight-DH_iBFHQ.js +0 -2
  1290. package/dist/doctor-config-preflight-nRntMTIC.js +0 -63
  1291. package/dist/doctor-device-pairing-rAiSum7F.js +0 -307
  1292. package/dist/doctor-gateway-daemon-flow-BYlbRkfE.js +0 -250
  1293. package/dist/doctor-gateway-health-DGaad6OP.js +0 -63
  1294. package/dist/doctor-health-contributions-CYangAn3.js +0 -493
  1295. package/dist/doctor-health-woICf2XW.js +0 -59
  1296. package/dist/doctor-prompter-oNxd62XO.js +0 -56
  1297. package/dist/doctor-sandbox-C9h2a5Uu.js +0 -194
  1298. package/dist/doctor-state-migrations-BPuF54_Y.js +0 -2
  1299. package/dist/doctor-workspace-status-DrOqBwKh.js +0 -75
  1300. package/dist/dreaming-narrative-SeHukrla.js +0 -596
  1301. package/dist/dreaming-qiznoCiH.js +0 -1582
  1302. package/dist/embedded-gateway-stub.runtime-BiCMn9tm.js +0 -9
  1303. package/dist/embedding-provider-QRMp19Ph.js +0 -118
  1304. package/dist/embeddings-Cwg0dHC_.js +0 -215
  1305. package/dist/embeddings-http-DbBwgwsH.js +0 -205
  1306. package/dist/exec-approval-forwarder.runtime-BNGZQkhU.js +0 -3
  1307. package/dist/exec-approvals-cli-BK9WM7tB.js +0 -498
  1308. package/dist/exec-defaults-B5NE8OtM.js +0 -2
  1309. package/dist/exec-defaults-Dy3ej-Rk.js +0 -67
  1310. package/dist/execute.runtime-cy0XQXc7.js +0 -1359
  1311. package/dist/fallbacks-BHahSac7.js +0 -31
  1312. package/dist/fallbacks-CDP89dtv.js +0 -2
  1313. package/dist/fallbacks-shared-h_ZN8Ugk.js +0 -111
  1314. package/dist/gateway-ClYGJe6R.js +0 -115
  1315. package/dist/gateway-cli-D5OEgdCv.js +0 -1283
  1316. package/dist/gateway-rpc-Dk_z0RTG.js +0 -14
  1317. package/dist/gateway-rpc.runtime-DcDI0Hq7.js +0 -23
  1318. package/dist/gateway-runtime-BpOf_2ps.js +0 -15
  1319. package/dist/gateway-status-BfT8gHrq.js +0 -584
  1320. package/dist/genesis-tools-Dn3v15Cu.js +0 -9435
  1321. package/dist/genesis-tools.runtime-BUKXOBx4.js +0 -2
  1322. package/dist/get-reply-BOvlxgUu.js +0 -3946
  1323. package/dist/get-reply-from-config.runtime-Cl8vSh_k.js +0 -2
  1324. package/dist/gmail-watcher-lifecycle-JbKGb-1A.js +0 -2
  1325. package/dist/graph-users-DvflifYV.js +0 -1337
  1326. package/dist/health-B2xJjrkJ.js +0 -3
  1327. package/dist/health-CWa-e_Y6.js +0 -420
  1328. package/dist/health-route-CzxBmoPR.js +0 -41
  1329. package/dist/health-route-Dhbg2HGJ.js +0 -2
  1330. package/dist/hooks-cli-B08Wk2kj.js +0 -433
  1331. package/dist/http-endpoint-helpers-CG3AcjuK.js +0 -41
  1332. package/dist/http-utils-L02eBAVo.js +0 -924
  1333. package/dist/image-fallbacks-DPTpHhw_.js +0 -2
  1334. package/dist/image-fallbacks-DrcfSUln.js +0 -31
  1335. package/dist/image-generation-core-CEg4KACr.js +0 -18
  1336. package/dist/image-generation-provider-B4tW_Kj3.js +0 -274
  1337. package/dist/image-generation-provider-B72nmoos.js +0 -157
  1338. package/dist/image-generation-provider-D9v0PADz.js +0 -63
  1339. package/dist/image-generation-provider-DLYGDzST.js +0 -228
  1340. package/dist/image-generation-provider-DYu8ZWBs.js +0 -529
  1341. package/dist/image-generation-provider-jp6l2Jls.js +0 -95
  1342. package/dist/image-generation-provider-qr08iqKe.js +0 -137
  1343. package/dist/image-runtime-DRQcRKzy.js +0 -9
  1344. package/dist/inbound-reply-dispatch-D2K6Anyc.js +0 -73
  1345. package/dist/inbound.runtime-CCnJwfdz.js +0 -3
  1346. package/dist/inbound.runtime-DwsGti2x.js +0 -4
  1347. package/dist/infra-runtime-Pu3jXc5f.js +0 -38
  1348. package/dist/init-B2qJ52Z_.js +0 -59
  1349. package/dist/install-DwDt01Fk.js +0 -726
  1350. package/dist/install-security-scan-Cq0N2AQi.js +0 -26
  1351. package/dist/install-security-scan.runtime-DWlSCQbQ.js +0 -671
  1352. package/dist/install.runtime-CWnOXdy4.js +0 -27
  1353. package/dist/install.runtime-DPA5lA9o.js +0 -12
  1354. package/dist/jobs-D9IyaUDB.js +0 -729
  1355. package/dist/library-JmPoINsm.js +0 -45
  1356. package/dist/lifecycle-BRey6jez.js +0 -229
  1357. package/dist/lifecycle-CvJT6tH9.js +0 -571
  1358. package/dist/lifecycle.runtime-DJuQgwAu.js +0 -2
  1359. package/dist/list-0KYh_6xs.js +0 -131
  1360. package/dist/list-B1iP8wTX.js +0 -2
  1361. package/dist/list-CewinhHi.js +0 -1212
  1362. package/dist/list-DPm9exQP.js +0 -2
  1363. package/dist/list.probe-M4jUIgk8.js +0 -419
  1364. package/dist/live-model-switch-DqJLIA4J.js +0 -336
  1365. package/dist/llm-slug-generator-CQiB4f0s.js +0 -79
  1366. package/dist/load-config-oEWSSW5T.js +0 -35
  1367. package/dist/loader-DlmWqYuM.js +0 -222
  1368. package/dist/local-dispatch.runtime-rI2L9gZz.js +0 -8
  1369. package/dist/login-DX18Qaag.js +0 -108
  1370. package/dist/logs-cli-qUQbKPpd.js +0 -265
  1371. package/dist/logs-cli.runtime-DZwxYUL2.js +0 -2
  1372. package/dist/main-session-restart-recovery-Dw8zndAD.js +0 -206
  1373. package/dist/managed-image-attachments-B_835Hjd.js +0 -635
  1374. package/dist/managed-image-attachments-Dp_0diDL.js +0 -2
  1375. package/dist/manager-CRmLomjS.js +0 -2
  1376. package/dist/manager-yTOglQEH.js +0 -2057
  1377. package/dist/markdown-to-line-D6Y5rN1y.js +0 -790
  1378. package/dist/mcp-cli-DZi-FzRz.js +0 -725
  1379. package/dist/mcp-http-DaXlqh6n.js +0 -529
  1380. package/dist/media-runtime-awxrKlof.js +0 -329
  1381. package/dist/media-understanding-CYk-TBlo.js +0 -85
  1382. package/dist/media-understanding-provider-BFl9PvK0.js +0 -18
  1383. package/dist/media-understanding-provider-BbHedlHI.js +0 -69
  1384. package/dist/media-understanding-provider-C4hkphxA.js +0 -28
  1385. package/dist/media-understanding-provider-CIJApc3Q.js +0 -85
  1386. package/dist/media-understanding-provider-CMRfrvoW.js +0 -37
  1387. package/dist/media-understanding-provider-D8MwbDYK.js +0 -12
  1388. package/dist/media-understanding-provider-DPZ3M0zL.js +0 -21
  1389. package/dist/media-understanding-provider-DnFHplle.js +0 -13
  1390. package/dist/media-understanding-provider-O3o8RDTO.js +0 -12
  1391. package/dist/media-understanding-provider-WmKhdAeP.js +0 -18
  1392. package/dist/media-understanding-runtime-DiWkY8O9.js +0 -2
  1393. package/dist/memory-core-host-runtime-cli-K2SeZLMj.js +0 -9
  1394. package/dist/memory-embedding-adapter-Ll4TtjDC.js +0 -123
  1395. package/dist/memory-host-search-BzpJFHpD.js +0 -12
  1396. package/dist/message-Bk0q8DmN.js +0 -232
  1397. package/dist/message-action-runner-BIi8DCoo.js +0 -2
  1398. package/dist/message-action-runner-CmhjNg6K.js +0 -1407
  1399. package/dist/message-actions-BDXFXc2E.js +0 -143
  1400. package/dist/message.gateway.runtime-fPnMn6QV.js +0 -2
  1401. package/dist/method-scopes-D_AZ7OsK.js +0 -235
  1402. package/dist/model-picker-D20JpfyM.js +0 -559
  1403. package/dist/model-picker-Dpin9dw4.js +0 -3
  1404. package/dist/model-picker.runtime-B19j-xJa.js +0 -15
  1405. package/dist/model-selection-BDK7dEju.js +0 -212
  1406. package/dist/models-auth-status-0xcMbBhB.js +0 -217
  1407. package/dist/models-cli-DuQZ09TC.js +0 -271
  1408. package/dist/models-http-DruY6N81.js +0 -92
  1409. package/dist/models.fetch-2geG13AQ.js +0 -518
  1410. package/dist/monitor-2KbmBvHU.js +0 -2
  1411. package/dist/monitor-B2yQJkAh.js +0 -1459
  1412. package/dist/monitor-CD4mrtqF.js +0 -1661
  1413. package/dist/monitor-CJ6A4Ro2.js +0 -788
  1414. package/dist/monitor-D19pDt5p.js +0 -1237
  1415. package/dist/monitor-GQtwMpZn.js +0 -671
  1416. package/dist/monitor-auth-DJ9S4EQV.js +0 -207
  1417. package/dist/monitor-processing-BMv5voti.js +0 -1974
  1418. package/dist/monitor.runtime-GizvASio.js +0 -2
  1419. package/dist/monitor.webhook-DzvH3io8.js +0 -180
  1420. package/dist/msteams-7Jx25GW4.js +0 -35
  1421. package/dist/music-generation-provider-Bac-UFIO.js +0 -63
  1422. package/dist/music-generation-provider-fPGrO1gg.js +0 -170
  1423. package/dist/native-hook-relay-DwgVW-el.js +0 -519
  1424. package/dist/nextcloud-talk-gXnN0EKl.js +0 -17
  1425. package/dist/node-cli-Bd8iT-US.js +0 -2276
  1426. package/dist/nodes-cli-xAd3vxyV.js +0 -1046
  1427. package/dist/nodes-utils-qg-Bmmy5.js +0 -84
  1428. package/dist/nodes.helpers-B42Vi8VW.js +0 -34
  1429. package/dist/notify-DArpzHFF.js +0 -315
  1430. package/dist/oauth-B9WR0gWL.js +0 -75
  1431. package/dist/oauth-BpJKd6mz.js +0 -2
  1432. package/dist/oauth-BqiriUcs.js +0 -139
  1433. package/dist/oauth-Dl3zSXWU.js +0 -152
  1434. package/dist/oauth.flow-CIweZ0Wo.js +0 -45
  1435. package/dist/oauth.flow-YT9WcJAP.js +0 -3
  1436. package/dist/onboard-DKr9c-h5.js +0 -70
  1437. package/dist/onboard-DrfmoxpG.js +0 -316
  1438. package/dist/onboard-channels-B-jq5k4w.js +0 -2
  1439. package/dist/onboard-channels-Dg4UVNnl.js +0 -3
  1440. package/dist/onboard-custom-DDY7T8Mb.js +0 -3
  1441. package/dist/onboard-custom-buJ3Vz5C.js +0 -271
  1442. package/dist/onboard-f_tqlGVL.js +0 -2
  1443. package/dist/onboard-helpers-Begz93UO.js +0 -6
  1444. package/dist/onboard-helpers-Di14BUn2.js +0 -204
  1445. package/dist/onboard-interactive-DjJo_FLY.js +0 -24
  1446. package/dist/onboard-non-interactive-CgxwxSiw.js +0 -635
  1447. package/dist/onboard-remote-BhcRxYvn.js +0 -2
  1448. package/dist/onboard-remote-CEeT7hEZ.js +0 -193
  1449. package/dist/onboard-skills-CTTUg6pf.js +0 -134
  1450. package/dist/onboard-skills-DWTbOfH1.js +0 -2
  1451. package/dist/onboarding-plugin-install-CNIcGqAI.js +0 -406
  1452. package/dist/openai-codex-provider-6aTYk3jp.js +0 -472
  1453. package/dist/openai-http-C2-8VSih.js +0 -500
  1454. package/dist/openai-provider-w1PV_KGr.js +0 -313
  1455. package/dist/opencode-SEOw9RYv.js +0 -35
  1456. package/dist/openresponses-http-DgsTPUc1.js +0 -1128
  1457. package/dist/operator-approvals-client-D1R6aLFV.js +0 -68
  1458. package/dist/outbound-runtime-D7qdGq1B.js +0 -5
  1459. package/dist/outbound.runtime-DDAlqr2n.js +0 -2
  1460. package/dist/pair-command-approve-BqXU_u3_.js +0 -44
  1461. package/dist/persistent-bindings.lifecycle-0cee5HeB.js +0 -85
  1462. package/dist/persistent-bindings.lifecycle-DTgwTu9k.js +0 -2
  1463. package/dist/pi-bundle-mcp-runtime-CEwlOt28.js +0 -2
  1464. package/dist/pi-bundle-mcp-runtime-DS32_bKh.js +0 -829
  1465. package/dist/pi-bundle-mcp-tools-MVePSeQp.js +0 -108
  1466. package/dist/pi-embedded-BMKZLrrD.js +0 -2905
  1467. package/dist/pi-embedded-C1_8L609.js +0 -4
  1468. package/dist/pi-embedded-subscribe.handlers.compaction.runtime-61zYwcVi.js +0 -23
  1469. package/dist/pi-embedded.runtime-CEcUCfnu.js +0 -4
  1470. package/dist/pi-tool-definition-adapter-B1q4cAB_.js +0 -229
  1471. package/dist/pi-tools-CE3UX10v.js +0 -1118
  1472. package/dist/pi-tools.before-tool-call-BsMfbO7W.js +0 -433
  1473. package/dist/pi-tools.before-tool-call-DGY-rj-6.js +0 -2
  1474. package/dist/plugin-dDMX1n9i.js +0 -12195
  1475. package/dist/plugin-enabled-CCcxlblr.js +0 -140
  1476. package/dist/plugin-install-D9RUigrW.js +0 -2
  1477. package/dist/plugin-install-DRc2KTWx.js +0 -115
  1478. package/dist/plugin-install-config-policy-CtKZaMAw.js +0 -137
  1479. package/dist/plugin-install-plan-BeNfwB5V.js +0 -50
  1480. package/dist/plugin-registration-CTIg2xi-.js +0 -23
  1481. package/dist/plugin-service-Byv2yfiX.js +0 -2893
  1482. package/dist/plugins-cli-qkT7VGd9.js +0 -584
  1483. package/dist/plugins-command-helpers-DvRgKfV0.js +0 -107
  1484. package/dist/plugins-install-persist-CZWXaz5s.js +0 -133
  1485. package/dist/plugins-update-command-qKTcfS44.js +0 -1057
  1486. package/dist/policy-BK0iZFZM.js +0 -328
  1487. package/dist/prepare.runtime-BMtgLZl1.js +0 -807
  1488. package/dist/probe-Bj3sjcpc.js +0 -2205
  1489. package/dist/probe-C6wNv6c4.js +0 -74
  1490. package/dist/probe-CM5o3wKp.js +0 -240
  1491. package/dist/probe-D3D0RoQl.js +0 -45
  1492. package/dist/probe-DlY3dg7v.js +0 -2
  1493. package/dist/probe-TN3P-dCa.js +0 -2
  1494. package/dist/probe-pLHVFHK6.js +0 -243
  1495. package/dist/probe-pZ61Idl1.js +0 -1443
  1496. package/dist/program-TZ54mZzH.js +0 -111
  1497. package/dist/prompt-select-styled-DFXPq9zJ.js +0 -20
  1498. package/dist/protocol-CWEBsZbG.js +0 -2515
  1499. package/dist/provider-D4RPFEas.js +0 -70
  1500. package/dist/provider-api-key-auth-DxE3Ubaz.js +0 -131
  1501. package/dist/provider-auth-94YJgYBI.js +0 -46
  1502. package/dist/provider-auth-api-key-D9d3vpbu.js +0 -5
  1503. package/dist/provider-auth-choice-C1kxCG8d.js +0 -228
  1504. package/dist/provider-auth-login-DSy_0CmF.js +0 -8
  1505. package/dist/provider-dispatcher-9FnI26kR.js +0 -2
  1506. package/dist/provider-dispatcher-D30lsDyd.js +0 -22
  1507. package/dist/provider-entry-CR0Z4V2Y.js +0 -106
  1508. package/dist/provider-model-defaults-CY1F7Q3c.js +0 -6
  1509. package/dist/provider-registration-C3cLloFb.js +0 -37
  1510. package/dist/provider-registration-CU67AJCU.js +0 -218
  1511. package/dist/qr-cli-CoEq74Fu.js +0 -2
  1512. package/dist/qr-cli-DxaXK8T4.js +0 -349
  1513. package/dist/qr-image-BQnl-2Hz.js +0 -2
  1514. package/dist/queue-IehGWtWc.js +0 -409
  1515. package/dist/reaction-runtime-api-CGWfmWqF.js +0 -116
  1516. package/dist/reactions-D1tny1P_.js +0 -998
  1517. package/dist/read-capability-w1W5sKua.js +0 -412
  1518. package/dist/register-service-commands-D5181r0Q.js +0 -71
  1519. package/dist/register.agent-DWwOD6q5.js +0 -248
  1520. package/dist/register.configure-CZx6uXuU.js +0 -15
  1521. package/dist/register.maintenance-1yV569VU.js +0 -363
  1522. package/dist/register.message-DqosH9zI.js +0 -329
  1523. package/dist/register.onboard-DBa5bh4F.js +0 -88
  1524. package/dist/register.runtime-AUXvOvfy.js +0 -81
  1525. package/dist/register.setup-1k0y27Bf.js +0 -150
  1526. package/dist/register.status-health-sessions-3SuqckJe.js +0 -1215
  1527. package/dist/register.subclis-1vwiREuy.js +0 -3
  1528. package/dist/register.subclis-core-CoUcH7R2.js +0 -249
  1529. package/dist/register.subclis-d6Uoake0.js +0 -29
  1530. package/dist/reply-dispatch-runtime-B2jwG-ti.js +0 -13
  1531. package/dist/reply-media-paths.runtime-Bv-VQY1O.js +0 -2
  1532. package/dist/reply-media-paths.runtime-qZYIzFEg.js +0 -146
  1533. package/dist/reply-runtime-BvyACHP_.js +0 -10
  1534. package/dist/reply.runtime-B76FIMUm.js +0 -2
  1535. package/dist/resolve-DxTN302S.js +0 -259
  1536. package/dist/response-generator-Be1_-xjF.js +0 -175
  1537. package/dist/restart-health-C1m4VgKE.js +0 -2
  1538. package/dist/restart-health-CSxm-1Te.js +0 -202
  1539. package/dist/root-help-Cw7ovqRO.js +0 -44
  1540. package/dist/route-reply-Dn9zmIdM.js +0 -162
  1541. package/dist/route-reply.runtime-DkwtG2qY.js +0 -2
  1542. package/dist/routes-B9j5MeTj.js +0 -2
  1543. package/dist/routes-BCJWRxzD.js +0 -3341
  1544. package/dist/rpc-_zAZRj2-.js +0 -61
  1545. package/dist/rpc.runtime-C3rwvN8O.js +0 -21
  1546. package/dist/run-auth-profile.runtime-Bflh0AxI.js +0 -2
  1547. package/dist/run-delivery.runtime-CXmj98lV.js +0 -530
  1548. package/dist/run-embedded.runtime-yli8ukW0.js +0 -4
  1549. package/dist/run-execution-cli.runtime-CjDLajis.js +0 -4
  1550. package/dist/run-executor.runtime-SwHBKuy1.js +0 -277
  1551. package/dist/run-main-DPHpfv1y.js +0 -567
  1552. package/dist/run-subagent-registry.runtime-CWv2s5wn.js +0 -2
  1553. package/dist/run-wait-CpSEiESO.js +0 -135
  1554. package/dist/runner-Vhfg_kYp.js +0 -966
  1555. package/dist/runner.entries-DWptWo_Q.js +0 -604
  1556. package/dist/runtime-CMHLmvAl.js +0 -961
  1557. package/dist/runtime-COXB-OZq.js +0 -263
  1558. package/dist/runtime-Cfcvlsp1.js +0 -2
  1559. package/dist/runtime-D9CBb5Na.js +0 -72
  1560. package/dist/runtime-api-CLkOuqkP.js +0 -4
  1561. package/dist/runtime-api-DgKObkOQ.js +0 -9
  1562. package/dist/runtime-api-bWUB21Eg.js +0 -9
  1563. package/dist/runtime-api-rryD3LXE.js +0 -14
  1564. package/dist/runtime-embedded-pi.runtime-DuHPAbVt.js +0 -2
  1565. package/dist/runtime-entry-BaLt5V4d.js +0 -2769
  1566. package/dist/runtime-fF-k_rB8.js +0 -9
  1567. package/dist/runtime-internal-By95Az_F.js +0 -2
  1568. package/dist/runtime-l0B7QFL3.js +0 -116
  1569. package/dist/runtime-options-BsxnM5Yt.js +0 -275
  1570. package/dist/runtime-prepare.runtime-D6bMmoTn.js +0 -80
  1571. package/dist/runtime-schema-P9TAqWy1.js +0 -28599
  1572. package/dist/runtime-web-tools-DlattYEh.js +0 -1477
  1573. package/dist/sandbox-B0HW_QP3.js +0 -1156
  1574. package/dist/sandbox-D2w77M7D.js +0 -3
  1575. package/dist/sandbox-cli-DhrLokzO.js +0 -450
  1576. package/dist/scan-CKfozblZ.js +0 -2
  1577. package/dist/scan-CVwpGz6x.js +0 -523
  1578. package/dist/secrets-cli-pXjlA7bi.js +0 -2101
  1579. package/dist/security-cli-ChIBksL4.js +0 -486
  1580. package/dist/selection-CIX2NWC3.js +0 -7743
  1581. package/dist/selection-FiKxtpP7.js +0 -2
  1582. package/dist/send-13tmI7yl.js +0 -102
  1583. package/dist/send-BudgB3Xv.js +0 -156
  1584. package/dist/send.runtime-CWWkq3eQ.js +0 -2
  1585. package/dist/server-CRbNiI2L.js +0 -13
  1586. package/dist/server-DPwckotj.js +0 -77
  1587. package/dist/server-context-DnmrGIHL.js +0 -847
  1588. package/dist/server-context-GFvl1Fa1.js +0 -2
  1589. package/dist/server-node-events-Boy823tY.js +0 -474
  1590. package/dist/server-plugin-bootstrap-BEm4d2by.js +0 -2
  1591. package/dist/server-plugin-bootstrap-BLp3Ri_D.js +0 -13355
  1592. package/dist/server-restart-sentinel-D1dhBlz5.js +0 -684
  1593. package/dist/server.impl-CuEQ_ANR.js +0 -12790
  1594. package/dist/session-DQK4G2N-.js +0 -48
  1595. package/dist/session-envelope-uG-4XV0X.js +0 -18
  1596. package/dist/session-key-CTestOWs.js +0 -65
  1597. package/dist/session-kill-http-CKkRPXTD.js +0 -110
  1598. package/dist/session-meta-B_6JKgd3.js +0 -109
  1599. package/dist/session-override-BJXIc7UA.js +0 -106
  1600. package/dist/session-reset-model.runtime-DFT-FJW1.js +0 -133
  1601. package/dist/session-reset-service-BI9uiJ1F.js +0 -497
  1602. package/dist/session-route-Dy5b9CbY.js +0 -93
  1603. package/dist/session-status.runtime-HByTPp-H.js +0 -2
  1604. package/dist/session-store-COzyfYG2.js +0 -126
  1605. package/dist/session-store.runtime-CQHXgM_Z.js +0 -2
  1606. package/dist/session-subagent-reactivation.runtime-BOWBAfyc.js +0 -2
  1607. package/dist/session-tab-registry-Ce31KjnI.js +0 -581
  1608. package/dist/session-updates-Dl4GafMW.js +0 -236
  1609. package/dist/session-updates.runtime-bHYRFXxm.js +0 -2
  1610. package/dist/session-utils-Dkaj_4dZ.js +0 -1009
  1611. package/dist/session-visibility-BB6i8ptT.js +0 -147
  1612. package/dist/sessions-D3eFfsPH.js +0 -281
  1613. package/dist/sessions-DAup1AeE.js +0 -16
  1614. package/dist/sessions-helpers-DYP9dapI.js +0 -305
  1615. package/dist/sessions-history-http-j8ZxsBAn.js +0 -371
  1616. package/dist/sessions-kO7Dit6B.js +0 -48
  1617. package/dist/sessions-patch-D4ye8mVh.js +0 -309
  1618. package/dist/sessions-resolve-Bi2bj6c-.js +0 -174
  1619. package/dist/sessions-uVaHa5mC.js +0 -2
  1620. package/dist/sessions.runtime-VkodyiYI.js +0 -2
  1621. package/dist/setup-DX-d8t6q.js +0 -421
  1622. package/dist/setup-api-6GX_eeAs.js +0 -29
  1623. package/dist/setup-core-BGUg4eV0.js +0 -171
  1624. package/dist/setup-core-CpfGqHuS.js +0 -176
  1625. package/dist/setup-hFAlSbTL.js +0 -636
  1626. package/dist/setup-surface-DSvYQ0Mf.js +0 -219
  1627. package/dist/setup-surface-DT8l0x7M.js +0 -403
  1628. package/dist/setup-surface-gdmDKJFO.js +0 -286
  1629. package/dist/setup.finalize-m_UzKyZ2.js +0 -547
  1630. package/dist/setup.gateway-config-DHQ8eaxx.js +0 -250
  1631. package/dist/shared-BY5yIWjE.js +0 -198
  1632. package/dist/shared-BtY5n-4U.js +0 -76
  1633. package/dist/shared-C-DELFhh.js +0 -217
  1634. package/dist/shared-DPf8cDHL.js +0 -121
  1635. package/dist/shared-runtime-lVwJld87.js +0 -7
  1636. package/dist/skill-commands-Crg6g_xc.js +0 -83
  1637. package/dist/skill-commands.runtime-Dx9JZPVm.js +0 -2
  1638. package/dist/skills-install-B1RJkjel.js +0 -605
  1639. package/dist/skills-snapshot.runtime-1fnPk6SF.js +0 -7
  1640. package/dist/slash-state-j62N8ife.js +0 -1911
  1641. package/dist/speech-provider-BEjGmdRi.js +0 -170
  1642. package/dist/speech-provider-DU0xib0M.js +0 -209
  1643. package/dist/speech-provider-jexKB2Fl.js +0 -216
  1644. package/dist/src-BYHA6DRU.js +0 -3974
  1645. package/dist/stage-sandbox-media.runtime-BzOf-LsJ.js +0 -232
  1646. package/dist/startup-context-DZml_gZY.js +0 -312
  1647. package/dist/state-migrations-DlUY4b3i.js +0 -820
  1648. package/dist/status-BCr0D4CJ.js +0 -2
  1649. package/dist/status-Bi8EbpXB.js +0 -395
  1650. package/dist/status-CPAE20nX.js +0 -209
  1651. package/dist/status-D-wIma3c.js +0 -3
  1652. package/dist/status-DLmFJkIX.js +0 -2
  1653. package/dist/status-DhpFLjkt.js +0 -190
  1654. package/dist/status-Dql1aIFE.js +0 -62
  1655. package/dist/status-all-AuiqtGQ-.js +0 -498
  1656. package/dist/status-json-BUhA_seV.js +0 -14
  1657. package/dist/status-json-command-Dk8RVvC9.js +0 -82
  1658. package/dist/status-message-DuKO-hzh.js +0 -466
  1659. package/dist/status-message.runtime-BnLXbVHh.js +0 -6
  1660. package/dist/status-queue.runtime-DXdIwJaQ.js +0 -2
  1661. package/dist/status-runtime-shared-BK7fklEl.js +0 -241
  1662. package/dist/status-subagents.runtime-DkMpqnmP.js +0 -18
  1663. package/dist/status-text-D71CoS-s.js +0 -237
  1664. package/dist/status.gateway-connection.runtime-wWu8Kvt4.js +0 -2
  1665. package/dist/status.gather-BlSA6D3i.js +0 -292
  1666. package/dist/status.gather-akCtNgln.js +0 -2
  1667. package/dist/status.runtime-BwFzOfxj.js +0 -2
  1668. package/dist/status.runtime-tPHKyqSk.js +0 -2
  1669. package/dist/status.scan-GF1UDZAB.js +0 -65
  1670. package/dist/status.scan-overview-D1tTMWSi.js +0 -379
  1671. package/dist/status.scan.fast-json-CoLBFhFk.js +0 -132
  1672. package/dist/status.scan.fast-json-K69bqOGh.js +0 -2
  1673. package/dist/status.summary-Bxh5WwsL.js +0 -200
  1674. package/dist/status.summary-Cyr9PxeP.js +0 -2
  1675. package/dist/store-DgajP9Em.js +0 -4
  1676. package/dist/store-tuisxHpf.js +0 -910
  1677. package/dist/store.runtime-Bw5wLKnD.js +0 -2
  1678. package/dist/stream-CWqBQkS6.js +0 -664
  1679. package/dist/subagent-announce-Dw7-i1-9.js +0 -351
  1680. package/dist/subagent-announce-delivery-HYpoItCd.js +0 -726
  1681. package/dist/subagent-announce-output-C7rcYYEc.js +0 -364
  1682. package/dist/subagent-capabilities-DFXCYxt0.js +0 -251
  1683. package/dist/subagent-control-Ds2GYpWL.js +0 -506
  1684. package/dist/subagent-control.runtime-CgBRjo3Q.js +0 -3
  1685. package/dist/subagent-followup.runtime-Cd8hCztp.js +0 -68
  1686. package/dist/subagent-orphan-recovery-BgjubPqf.js +0 -305
  1687. package/dist/subagent-registry-CgpGD3GV.js +0 -1753
  1688. package/dist/subagent-registry-DxdVLcdG.js +0 -3
  1689. package/dist/subagent-spawn-BWBNndsp.js +0 -1005
  1690. package/dist/supervisor-DaRbw4Gw.js +0 -704
  1691. package/dist/system-cli-DyBkQUQb.js +0 -43
  1692. package/dist/targets-BadrXaG2.js +0 -67
  1693. package/dist/task-executor-C7Wi33fD.js +0 -360
  1694. package/dist/task-owner-access-yQv8xMco.js +0 -74
  1695. package/dist/task-registry-W5mFPlZX.js +0 -2357
  1696. package/dist/task-registry-delivery-runtime-cBNSvuGT.js +0 -3
  1697. package/dist/task-registry-delivery-runtime-cJvq2BuY.js +0 -2
  1698. package/dist/task-registry.maintenance-Buzo501v.js +0 -2
  1699. package/dist/task-registry.maintenance-pJMW_7Am.js +0 -416
  1700. package/dist/testing-Dw49ltmR.js +0 -575
  1701. package/dist/text-report-CtyXY05r.js +0 -549
  1702. package/dist/tool-auth-shared-DWrecN7g.js +0 -90
  1703. package/dist/tool-policy-pipeline-CA61tNc_.js +0 -109
  1704. package/dist/tool-resolution-BcUPtTtu.js +0 -90
  1705. package/dist/tools-effective-inventory-CL0grjv4.js +0 -152
  1706. package/dist/tools-invoke-http-BZ8xqe0f.js +0 -206
  1707. package/dist/transcript-CEK104A6.js +0 -312
  1708. package/dist/transcript-resolve.runtime-D4I8B--1.js +0 -2
  1709. package/dist/transcript.runtime-ClNMqLSP.js +0 -2
  1710. package/dist/trash-B6l1GwX9.js +0 -24
  1711. package/dist/tts-vEtIfdGN.js +0 -64
  1712. package/dist/tui-cli-BCn5UWwT.js +0 -4585
  1713. package/dist/uninstall-BQ_d8nQ4.js +0 -185
  1714. package/dist/update-D8foEnSw.js +0 -1282
  1715. package/dist/update-cli-D8bMov5W.js +0 -1759
  1716. package/dist/update-startup-D-n1C8A0.js +0 -2
  1717. package/dist/upgrade-iRXz6ZP4.js +0 -1226
  1718. package/dist/video-generation-provider-5v5lTL00.js +0 -287
  1719. package/dist/video-generation-provider-BGtbUYJd.js +0 -64
  1720. package/dist/video-generation-provider-BlOdvaLh.js +0 -118
  1721. package/dist/video-generation-provider-CR_fRJ8m.js +0 -187
  1722. package/dist/video-generation-provider-CVUs00hp.js +0 -264
  1723. package/dist/video-generation-provider-CtstiCCO.js +0 -271
  1724. package/dist/video-generation-provider-DDQjPRYO.js +0 -254
  1725. package/dist/video-generation-provider-DLy7AvTJ.js +0 -281
  1726. package/dist/video-generation-provider-DNnNMvS9.js +0 -221
  1727. package/dist/video-generation-provider-vzf0PQXj2.js +0 -77
  1728. package/dist/video-generation-provider-zINiw3aL.js +0 -78
  1729. package/dist/video-generation-task-status-ESf4kR6F.js +0 -163
  1730. package/dist/wait-for-idle-before-flush-C-_kVutK.js +0 -5985
  1731. package/dist/web-search-provider-BkIzoc2Y.js +0 -163
  1732. package/dist/wizard-models-jPGu0o7K.js +0 -334
  1733. package/dist/workflow-runtime-tvBeQSK9.js +0 -485
  1734. /package/dist/{audit-channel.collect.runtime-BAKyzn52.js → audit-channel.collect.runtime-CevlIQ6K.js} +0 -0
  1735. /package/dist/{audit-tool-policy-Ftr0W8Wl.js → audit-tool-policy-DTodxIZf.js} +0 -0
  1736. /package/dist/{channel-selection.runtime-CsQ0qN21.js → channel-selection.runtime-DAkF_DgO.js} +0 -0
  1737. /package/dist/{close-reason-DNwBM4qe.js → close-reason-BPuKI4th.js} +0 -0
  1738. /package/dist/{configured-B8XGIYz-.js → configured-C-0r4Pk2.js} +0 -0
  1739. /package/dist/{diagnostic-support-export-CuIJulCK.js → diagnostic-support-export-C8cpJRWi.js} +0 -0
  1740. /package/dist/{gmail-watcher-lifecycle-BoWMgpeT.js → gmail-watcher-lifecycle-DrTbIr0m.js} +0 -0
  1741. /package/dist/{image-BwAofy0f.js → image-LNALiqnF.js} +0 -0
  1742. /package/dist/{image-generation-core.auth.runtime-B6BpHP6V.js → image-generation-core.auth.runtime-hzZbX1YD.js} +0 -0
  1743. /package/dist/{input-allowlist-zDKNs6OG.js → input-allowlist-Bn8hssyM.js} +0 -0
  1744. /package/dist/{install-target-FXMkL80i.js → install-target-C0Dg_4Un.js} +0 -0
  1745. /package/dist/{memory-host-search.runtime-Vfck_NLf.js → memory-host-search.runtime-CAejVWZB.js} +0 -0
  1746. /package/dist/{message.config.runtime-Df8nVSE4.js → message.config.runtime-CAG3eLmF.js} +0 -0
  1747. /package/dist/{paths-BdDCK0XP.js → paths-BrPnd-v6.js} +0 -0
  1748. /package/dist/{provider-api-key-auth.runtime-fT4D2dQt.js → provider-api-key-auth.runtime-YLpiRoM3.js} +0 -0
  1749. /package/dist/{provider-auth-login.runtime-EnfK3WTr.js → provider-auth-login.runtime-BwDEPbY4.js} +0 -0
  1750. /package/dist/{push-apns-DoMbCgqq.js → push-apns-UUwkJMxt.js} +0 -0
  1751. /package/dist/{runtime-manifest.runtime-CuqWbJ5G.js → runtime-manifest.runtime-D8BuqQCR.js} +0 -0
  1752. /package/dist/{runtime-web-channel-plugin-ChmPPl7a.js → runtime-web-channel-plugin-Dx1GGPSD.js} +0 -0
  1753. /package/dist/{runtime-web-tools-fallback.runtime-B3fmu7s0.js → runtime-web-tools-fallback.runtime-_nNCUNAT.js} +0 -0
  1754. /package/dist/{runtime-web-tools-manifest.runtime-CpiYM000.js → runtime-web-tools-manifest.runtime-BaeloEzn.js} +0 -0
  1755. /package/dist/{runtime-web-tools-public-artifacts.runtime-BBNdsUv5.js → runtime-web-tools-public-artifacts.runtime-DOdl6CAd.js} +0 -0
  1756. /package/dist/{server-startup-log-DXJn1EgH.js → server-startup-log-BUk3dEm6.js} +0 -0
  1757. /package/dist/{server-startup-memory-C4d9ImgC.js → server-startup-memory-C3gdaomJ.js} +0 -0
  1758. /package/dist/{server-tailscale-DeNCXYBr.js → server-tailscale-C0DsqL5N.js} +0 -0
  1759. /package/dist/{services-m8_503l9.js → services-CiBabvAX.js} +0 -0
  1760. /package/dist/{session-archive.runtime-DDhx1bOA.js → session-archive.runtime-BIqBKdzI.js} +0 -0
  1761. /package/dist/{setup.node-config-BXET5GZk.js → setup.node-config-BlJDbu4T.js} +0 -0
  1762. /package/dist/{setup.plugin-config-CgBJMtZ8.js → setup.plugin-config-CCP7nrfy.js} +0 -0
  1763. /package/dist/{skill-scanner-cEm04-3B.js → skill-scanner-DnqZE6Fh.js} +0 -0
  1764. /package/dist/{ssh-config-BfxhRhPu.js → ssh-config-wfp8-I37.js} +0 -0
  1765. /package/dist/{supervisor-log.runtime-BdagMpUZ.js → supervisor-log.runtime-DYzbopV7.js} +0 -0
  1766. /package/dist/{targets.runtime-BS4UWyk2.js → targets.runtime-1fn-rTlI.js} +0 -0
  1767. /package/dist/{update-startup-D69inLEd.js → update-startup-DW61ftJW.js} +0 -0
@@ -0,0 +1,4585 @@
1
+ import { i as formatErrorMessage } from "./errors-CufR9eHH.js";
2
+ import { a as normalizeLowercaseStringOrEmpty, c as normalizeOptionalString, s as normalizeOptionalLowercaseString } from "./string-coerce-DPP_aYVc.js";
3
+ import { h as loggingState } from "./logger-BRmjL88V.js";
4
+ import { n as defaultRuntime } from "./runtime-DDkDH9fa.js";
5
+ import { i as visibleWidth, r as stripAnsi$1 } from "./ansi-cSbP14w0.js";
6
+ import { u as setConsoleSubsystemFilter } from "./subsystem-CNq69MoE.js";
7
+ import { t as formatDocsLink } from "./links-C1-jbHJx.js";
8
+ import { r as theme$1 } from "./theme-DD6pQv2_.js";
9
+ import { n as VERSION } from "./version-qod78efn.js";
10
+ import { n as assertExplicitGatewayAuthModeWhenBothConfigured } from "./auth-mode-policy-DNpWBcwq.js";
11
+ import { a as isLoopbackHost } from "./net-BzaeD_3Q.js";
12
+ import { a as loadConfig } from "./io-Cy5vajWd.js";
13
+ import { s as parseAgentSessionKey } from "./session-key-utils-DDwuwYKT.js";
14
+ import { c as normalizeAgentId, l as normalizeMainKey, r as buildAgentMainSessionKey } from "./session-key-CI3KvTQC.js";
15
+ import { r as DEFAULT_PROVIDER } from "./defaults-Dg3aovOH.js";
16
+ import { a as resolveAgentIdByWorkspacePath, p as resolveSessionAgentId, x as resolveDefaultAgentId } from "./agent-scope-BUYwVohk.js";
17
+ import "./config-DYHZ3jG1.js";
18
+ import { n as GatewayClientRequestError, t as GatewayClient } from "./client-DQsu_IXu.js";
19
+ import { i as GATEWAY_CLIENT_NAMES, r as GATEWAY_CLIENT_MODES, t as GATEWAY_CLIENT_CAPS } from "./client-info-CjxzJxIU.js";
20
+ import { r as INTERNAL_MESSAGE_CHANNEL } from "./message-channel-core-BsSExTA7.js";
21
+ import "./message-channel-8hna3ogc.js";
22
+ import "./protocol-DgMCJAA_.js";
23
+ import { g as resolveResponseUsageMode, m as normalizeUsageDisplay, r as listThinkingLevelLabels, t as formatThinkingLevels } from "./thinking-BxrysYYp.js";
24
+ import { p as resolveThinkingDefault, t as buildAllowedModelSet } from "./model-selection-D-mV4REq.js";
25
+ import { t as loadCombinedSessionStoreForGateway } from "./combined-store-gateway-CZ0lKQMU.js";
26
+ import { o as updateSessionStore } from "./store-BtHVDH2Q.js";
27
+ import "./sessions-C1_80mqv.js";
28
+ import { l as onAgentEvent } from "./agent-events-DxDJre6N.js";
29
+ import { r as formatTokenCount } from "./usage-format-DlUyhc8n.js";
30
+ import { c as stripEnvelopeFromMessages, i as readSessionMessages, n as capArrayByJsonBytes } from "./session-utils.fs-moBTdnuM.js";
31
+ import { r as extractAssistantVisibleText } from "./chat-message-content-BJIvXbdD.js";
32
+ import { i as stripInlineDirectiveTagsForDisplay } from "./directive-tags-DoksNPSD.js";
33
+ import { r as stripLeadingInboundMetadata } from "./strip-inbound-meta-Bk4Y0lw3.js";
34
+ import { a as loadSessionEntry, d as resolveGatewaySessionStoreTarget, n as listAgentsForGateway, o as migrateAndPruneGatewaySessionStoreKey, p as resolveSessionModelRef, r as listSessionsFromStore } from "./session-utils-otyfumhD.js";
35
+ import { v as setEmbeddedMode } from "./genesis-tools-Bkxp7zlI.js";
36
+ import "./pi-embedded-helpers-DNexwzyg.js";
37
+ import { D as formatRawAssistantErrorForUi, m as isAuthErrorMessage } from "./sanitize-user-facing-text-DKqUCgHB.js";
38
+ import { a as isSilentReplyText, n as SILENT_REPLY_TOKEN } from "./tokens-DUMwK-9w.js";
39
+ import { r as resolveToolDisplay, t as formatToolDetail } from "./tool-display-D7v2v3qV.js";
40
+ import { l as resolveExplicitGatewayAuth, n as buildGatewayConnectionDetails, s as ensureExplicitGatewayAuth } from "./call-DgFhP0IB.js";
41
+ import { t as parseTimeoutMs } from "./parse-timeout-XtJqYUc8.js";
42
+ import { r as resolveSessionInfoModelSelection } from "./model-selection-display-BiU1dZp5.js";
43
+ import { n as listChatCommands, r as listChatCommandsForConfig } from "./commands-registry-list-CINBp5YN.js";
44
+ import "./commands-registry-B5egnRQ_.js";
45
+ import { n as formatTimeAgo, t as formatRelativeTimestamp } from "./format-relative-B39tx_LC.js";
46
+ import { t as normalizeGroupActivation } from "./group-activation-BiaHgDAZ.js";
47
+ import { r as agentCommandFromIngress } from "./agent-command-Baehh2jJ.js";
48
+ import { t as createDefaultDeps } from "./deps-CMhJYvQj.js";
49
+ import { _ as loadGatewayModelCatalog } from "./http-utils-LFOvdepz.js";
50
+ import { T as augmentChatHistoryWithCliSessionImports, a as enforceChatHistoryFinalBudget, c as sanitizeChatHistoryMessages, o as replaceOversizedChatHistoryMessages, r as augmentChatHistoryWithCanvasBlocks, s as resolveEffectiveChatHistoryMaxChars, t as CHAT_HISTORY_MAX_SINGLE_MESSAGE_BYTES, w as getMaxChatHistoryMessagesBytes } from "./chat-C-K_PnVS.js";
51
+ import { n as timestampOptsFromConfig, t as injectTimestamp } from "./agent-timestamp-LCcsN9SL.js";
52
+ import { a as performGatewaySessionReset } from "./session-reset-service-Cs7o8vTZ.js";
53
+ import { t as applySessionsPatchToStore } from "./sessions-patch-XzBTc4fY.js";
54
+ import { t as resolveGatewayInteractiveSurfaceAuth } from "./auth-surface-resolution-DKXlV4bg.js";
55
+ import { n as TUI_SETUP_AUTH_SOURCE_ENV, t as TUI_SETUP_AUTH_SOURCE_CONFIG } from "./setup-launch-env-UVaxdANl.js";
56
+ import { fileURLToPath } from "node:url";
57
+ import { existsSync } from "node:fs";
58
+ import path from "node:path";
59
+ import { execFileSync, spawn } from "node:child_process";
60
+ import chalk from "chalk";
61
+ import { randomUUID } from "node:crypto";
62
+ import { Box, CombinedAutocompleteProvider, Container, Editor, Input, Key, Loader, Markdown, ProcessTerminal, SelectList, SettingsList, Spacer, TUI, Text, isKeyRelease, matchesKey, truncateToWidth } from "@earendil-works/pi-tui";
63
+ //#region src/tui/commands.ts
64
+ const VERBOSE_LEVELS = ["on", "off"];
65
+ const TRACE_LEVELS = ["on", "off"];
66
+ const FAST_LEVELS = [
67
+ "status",
68
+ "on",
69
+ "off"
70
+ ];
71
+ const REASONING_LEVELS = ["on", "off"];
72
+ const ELEVATED_LEVELS = [
73
+ "on",
74
+ "off",
75
+ "ask",
76
+ "full"
77
+ ];
78
+ const ACTIVATION_LEVELS = ["mention", "always"];
79
+ const USAGE_FOOTER_LEVELS = [
80
+ "off",
81
+ "tokens",
82
+ "full"
83
+ ];
84
+ const COMMAND_ALIASES = {
85
+ elev: "elevated",
86
+ gwstatus: "gateway-status"
87
+ };
88
+ function createLevelCompletion(levels) {
89
+ return (prefix) => levels.filter((value) => value.startsWith(normalizeLowercaseStringOrEmpty(prefix))).map((value) => ({
90
+ value,
91
+ label: value
92
+ }));
93
+ }
94
+ function parseCommand(input) {
95
+ const trimmed = input.replace(/^\//, "").trim();
96
+ if (!trimmed) return {
97
+ name: "",
98
+ args: ""
99
+ };
100
+ const [name, ...rest] = trimmed.split(/\s+/);
101
+ const normalized = normalizeLowercaseStringOrEmpty(name);
102
+ return {
103
+ name: COMMAND_ALIASES[normalized] ?? normalized,
104
+ args: rest.join(" ").trim()
105
+ };
106
+ }
107
+ function getSlashCommands(options = {}) {
108
+ const thinkLevels = listThinkingLevelLabels(options.provider, options.model);
109
+ const verboseCompletions = createLevelCompletion(VERBOSE_LEVELS);
110
+ const traceCompletions = createLevelCompletion(TRACE_LEVELS);
111
+ const fastCompletions = createLevelCompletion(FAST_LEVELS);
112
+ const reasoningCompletions = createLevelCompletion(REASONING_LEVELS);
113
+ const usageCompletions = createLevelCompletion(USAGE_FOOTER_LEVELS);
114
+ const elevatedCompletions = createLevelCompletion(ELEVATED_LEVELS);
115
+ const activationCompletions = createLevelCompletion(ACTIVATION_LEVELS);
116
+ const commands = [
117
+ {
118
+ name: "help",
119
+ description: "Show slash command help"
120
+ },
121
+ {
122
+ name: "gateway-status",
123
+ description: "Show gateway status summary"
124
+ },
125
+ {
126
+ name: "gwstatus",
127
+ description: "Alias for /gateway-status"
128
+ },
129
+ ...options.local ? [{
130
+ name: "auth",
131
+ description: "Run provider auth/login flow"
132
+ }] : [],
133
+ {
134
+ name: "agent",
135
+ description: "Switch agent (or open picker)"
136
+ },
137
+ {
138
+ name: "agents",
139
+ description: "Open agent picker"
140
+ },
141
+ {
142
+ name: "session",
143
+ description: "Switch session (or open picker)"
144
+ },
145
+ {
146
+ name: "sessions",
147
+ description: "Open session picker"
148
+ },
149
+ {
150
+ name: "model",
151
+ description: "Set model (or open picker)"
152
+ },
153
+ {
154
+ name: "models",
155
+ description: "Open model picker"
156
+ },
157
+ {
158
+ name: "think",
159
+ description: "Set thinking level",
160
+ getArgumentCompletions: (prefix) => thinkLevels.filter((v) => v.startsWith(normalizeLowercaseStringOrEmpty(prefix))).map((value) => ({
161
+ value,
162
+ label: value
163
+ }))
164
+ },
165
+ {
166
+ name: "fast",
167
+ description: "Set fast mode on/off",
168
+ getArgumentCompletions: fastCompletions
169
+ },
170
+ {
171
+ name: "verbose",
172
+ description: "Set verbose on/off",
173
+ getArgumentCompletions: verboseCompletions
174
+ },
175
+ {
176
+ name: "trace",
177
+ description: "Set trace on/off",
178
+ getArgumentCompletions: traceCompletions
179
+ },
180
+ {
181
+ name: "reasoning",
182
+ description: "Set reasoning on/off",
183
+ getArgumentCompletions: reasoningCompletions
184
+ },
185
+ {
186
+ name: "usage",
187
+ description: "Toggle per-response usage line",
188
+ getArgumentCompletions: usageCompletions
189
+ },
190
+ {
191
+ name: "elevated",
192
+ description: "Set elevated on/off/ask/full",
193
+ getArgumentCompletions: elevatedCompletions
194
+ },
195
+ {
196
+ name: "elev",
197
+ description: "Alias for /elevated",
198
+ getArgumentCompletions: elevatedCompletions
199
+ },
200
+ {
201
+ name: "activation",
202
+ description: "Set group activation",
203
+ getArgumentCompletions: activationCompletions
204
+ },
205
+ {
206
+ name: "abort",
207
+ description: "Abort active run"
208
+ },
209
+ {
210
+ name: "new",
211
+ description: "Reset the session"
212
+ },
213
+ {
214
+ name: "reset",
215
+ description: "Reset the session"
216
+ },
217
+ {
218
+ name: "settings",
219
+ description: "Open settings"
220
+ },
221
+ {
222
+ name: "exit",
223
+ description: "Exit the TUI"
224
+ },
225
+ {
226
+ name: "quit",
227
+ description: "Exit the TUI"
228
+ }
229
+ ];
230
+ const seen = new Set(commands.map((command) => command.name));
231
+ const gatewayCommands = options.cfg ? listChatCommandsForConfig(options.cfg) : listChatCommands();
232
+ for (const command of gatewayCommands) {
233
+ const aliases = command.textAliases.length > 0 ? command.textAliases : [`/${command.key}`];
234
+ for (const alias of aliases) {
235
+ const name = alias.replace(/^\//, "").trim();
236
+ if (!name || seen.has(name)) continue;
237
+ seen.add(name);
238
+ commands.push({
239
+ name,
240
+ description: command.description
241
+ });
242
+ }
243
+ }
244
+ return commands;
245
+ }
246
+ function helpText(options = {}) {
247
+ const thinkLevels = formatThinkingLevels(options.provider, options.model, "|");
248
+ return [
249
+ "Slash commands:",
250
+ "/help",
251
+ "/commands",
252
+ "/status",
253
+ "/gateway-status",
254
+ "/gwstatus",
255
+ ...options.local ? ["/auth [provider]"] : [],
256
+ "/agent <id> (or /agents)",
257
+ "/session <key> (or /sessions)",
258
+ "/model <provider/model> (or /models)",
259
+ `/think <${thinkLevels}>`,
260
+ "/fast <status|on|off>",
261
+ "/verbose <on|off>",
262
+ "/trace <on|off>",
263
+ "/reasoning <on|off>",
264
+ "/usage <off|tokens|full>",
265
+ "/elevated <on|off|ask|full>",
266
+ "/elev <on|off|ask|full>",
267
+ "/activation <mention|always>",
268
+ "/new or /reset",
269
+ "/abort",
270
+ "/settings",
271
+ "/exit"
272
+ ].join("\n");
273
+ }
274
+ //#endregion
275
+ //#region src/tui/theme/theme.ts
276
+ const DARK_TEXT = "#E8E3D5";
277
+ const LIGHT_TEXT = "#1E1E1E";
278
+ const XTERM_LEVELS = [
279
+ 0,
280
+ 95,
281
+ 135,
282
+ 175,
283
+ 215,
284
+ 255
285
+ ];
286
+ function channelToSrgb(value) {
287
+ const normalized = value / 255;
288
+ return normalized <= .03928 ? normalized / 12.92 : ((normalized + .055) / 1.055) ** 2.4;
289
+ }
290
+ function relativeLuminanceRgb(r, g, b) {
291
+ const red = channelToSrgb(r);
292
+ const green = channelToSrgb(g);
293
+ const blue = channelToSrgb(b);
294
+ return .2126 * red + .7152 * green + .0722 * blue;
295
+ }
296
+ function relativeLuminanceHex(hex) {
297
+ return relativeLuminanceRgb(Number.parseInt(hex.slice(1, 3), 16), Number.parseInt(hex.slice(3, 5), 16), Number.parseInt(hex.slice(5, 7), 16));
298
+ }
299
+ function contrastRatio(background, foregroundHex) {
300
+ const foreground = relativeLuminanceHex(foregroundHex);
301
+ const lighter = Math.max(background, foreground);
302
+ const darker = Math.min(background, foreground);
303
+ return (lighter + .05) / (darker + .05);
304
+ }
305
+ function pickHigherContrastText(r, g, b) {
306
+ const background = relativeLuminanceRgb(r, g, b);
307
+ return contrastRatio(background, LIGHT_TEXT) >= contrastRatio(background, DARK_TEXT);
308
+ }
309
+ function isLightBackground() {
310
+ const explicit = normalizeOptionalLowercaseString(process.env.GENESIS_THEME);
311
+ if (explicit === "light") return true;
312
+ if (explicit === "dark") return false;
313
+ const colorfgbg = process.env.COLORFGBG;
314
+ if (colorfgbg && colorfgbg.length <= 64) {
315
+ const sep = colorfgbg.lastIndexOf(";");
316
+ const bg = Number.parseInt(sep >= 0 ? colorfgbg.slice(sep + 1) : colorfgbg, 10);
317
+ if (bg >= 0 && bg <= 255) {
318
+ if (bg <= 15) return bg === 7 || bg === 15;
319
+ if (bg >= 232) return bg >= 244;
320
+ const cubeIndex = bg - 16;
321
+ const bVal = XTERM_LEVELS[cubeIndex % 6];
322
+ const gVal = XTERM_LEVELS[Math.floor(cubeIndex / 6) % 6];
323
+ const rVal = XTERM_LEVELS[Math.floor(cubeIndex / 36)];
324
+ return pickHigherContrastText(rVal, gVal, bVal);
325
+ }
326
+ }
327
+ return false;
328
+ }
329
+ const palette = isLightBackground() ? {
330
+ text: "#1E1E1E",
331
+ dim: "#5B6472",
332
+ accent: "#B45309",
333
+ accentSoft: "#C2410C",
334
+ border: "#5B6472",
335
+ userBg: "#F3F0E8",
336
+ userText: "#1E1E1E",
337
+ systemText: "#4B5563",
338
+ toolPendingBg: "#EFF6FF",
339
+ toolSuccessBg: "#ECFDF5",
340
+ toolErrorBg: "#FEF2F2",
341
+ toolTitle: "#B45309",
342
+ toolOutput: "#374151",
343
+ quote: "#1D4ED8",
344
+ quoteBorder: "#2563EB",
345
+ code: "#92400E",
346
+ codeBlock: "#F9FAFB",
347
+ codeBorder: "#92400E",
348
+ link: "#047857",
349
+ error: "#DC2626",
350
+ success: "#047857"
351
+ } : {
352
+ text: "#E8E3D5",
353
+ dim: "#7B7F87",
354
+ accent: "#F6C453",
355
+ accentSoft: "#F2A65A",
356
+ border: "#3C414B",
357
+ userBg: "#2B2F36",
358
+ userText: "#F3EEE0",
359
+ systemText: "#9BA3B2",
360
+ toolPendingBg: "#1F2A2F",
361
+ toolSuccessBg: "#1E2D23",
362
+ toolErrorBg: "#2F1F1F",
363
+ toolTitle: "#F6C453",
364
+ toolOutput: "#E1DACB",
365
+ quote: "#8CC8FF",
366
+ quoteBorder: "#3B4D6B",
367
+ code: "#F0C987",
368
+ codeBlock: "#1E232A",
369
+ codeBorder: "#343A45",
370
+ link: "#7DD3A5",
371
+ error: "#F97066",
372
+ success: "#7DD3A5"
373
+ };
374
+ const fg = (hex) => (text) => chalk.hex(hex)(text);
375
+ const bg = (hex) => (text) => chalk.bgHex(hex)(text);
376
+ /**
377
+ * Render code blocks with the theme code color without pulling a parser into the base TUI path.
378
+ * Returns an array of lines with ANSI escape codes.
379
+ */
380
+ function highlightCode(code) {
381
+ return code.split("\n").map((line) => fg(palette.code)(line));
382
+ }
383
+ const theme = {
384
+ fg: fg(palette.text),
385
+ assistantText: (text) => text,
386
+ dim: fg(palette.dim),
387
+ accent: fg(palette.accent),
388
+ accentSoft: fg(palette.accentSoft),
389
+ success: fg(palette.success),
390
+ error: fg(palette.error),
391
+ header: (text) => chalk.bold(fg(palette.accent)(text)),
392
+ system: fg(palette.systemText),
393
+ userBg: bg(palette.userBg),
394
+ userText: fg(palette.userText),
395
+ toolTitle: fg(palette.toolTitle),
396
+ toolOutput: fg(palette.toolOutput),
397
+ toolPendingBg: bg(palette.toolPendingBg),
398
+ toolSuccessBg: bg(palette.toolSuccessBg),
399
+ toolErrorBg: bg(palette.toolErrorBg),
400
+ border: fg(palette.border),
401
+ bold: (text) => chalk.bold(text),
402
+ italic: (text) => chalk.italic(text)
403
+ };
404
+ const markdownTheme = {
405
+ heading: (text) => chalk.bold(fg(palette.accent)(text)),
406
+ link: (text) => fg(palette.link)(text),
407
+ linkUrl: (text) => chalk.dim(text),
408
+ code: (text) => fg(palette.code)(text),
409
+ codeBlock: (text) => fg(palette.code)(text),
410
+ codeBlockBorder: (text) => fg(palette.codeBorder)(text),
411
+ quote: (text) => fg(palette.quote)(text),
412
+ quoteBorder: (text) => fg(palette.quoteBorder)(text),
413
+ hr: (text) => fg(palette.border)(text),
414
+ listBullet: (text) => fg(palette.accentSoft)(text),
415
+ bold: (text) => chalk.bold(text),
416
+ italic: (text) => chalk.italic(text),
417
+ strikethrough: (text) => chalk.strikethrough(text),
418
+ underline: (text) => chalk.underline(text),
419
+ highlightCode
420
+ };
421
+ const baseSelectListTheme = {
422
+ selectedPrefix: (text) => fg(palette.accent)(text),
423
+ selectedText: (text) => chalk.bold(fg(palette.accent)(text)),
424
+ description: (text) => fg(palette.dim)(text),
425
+ scrollInfo: (text) => fg(palette.dim)(text),
426
+ noMatch: (text) => fg(palette.dim)(text)
427
+ };
428
+ const selectListTheme = baseSelectListTheme;
429
+ const filterableSelectListTheme = {
430
+ ...baseSelectListTheme,
431
+ filterLabel: (text) => fg(palette.dim)(text)
432
+ };
433
+ const settingsListTheme = {
434
+ label: (text, selected) => selected ? chalk.bold(fg(palette.accent)(text)) : fg(palette.text)(text),
435
+ value: (text, selected) => selected ? fg(palette.accentSoft)(text) : fg(palette.dim)(text),
436
+ description: (text) => fg(palette.systemText)(text),
437
+ cursor: fg(palette.accent)("→ "),
438
+ hint: (text) => fg(palette.dim)(text)
439
+ };
440
+ const editorTheme = {
441
+ borderColor: (text) => fg(palette.border)(text),
442
+ selectList: selectListTheme
443
+ };
444
+ const searchableSelectListTheme = {
445
+ ...baseSelectListTheme,
446
+ searchPrompt: (text) => fg(palette.accentSoft)(text),
447
+ searchInput: (text) => fg(palette.text)(text),
448
+ matchHighlight: (text) => chalk.bold(fg(palette.accent)(text))
449
+ };
450
+ //#endregion
451
+ //#region src/tui/osc8-hyperlinks.ts
452
+ const SGR_PATTERN = "\\x1b\\[[0-9;]*m";
453
+ const OSC8_PATTERN = "\\x1b\\]8;;.*?(?:\\x07|\\x1b\\\\)";
454
+ const ANSI_RE = new RegExp(`${SGR_PATTERN}|${OSC8_PATTERN}`, "g");
455
+ const SGR_START_RE = new RegExp(`^${SGR_PATTERN}`);
456
+ const OSC8_START_RE = new RegExp(`^${OSC8_PATTERN}`);
457
+ /**
458
+ * Extract all unique URLs from raw markdown text.
459
+ * Finds both bare URLs and markdown link hrefs [text](url).
460
+ */
461
+ function extractUrls(markdown) {
462
+ const urls = /* @__PURE__ */ new Set();
463
+ const mdLinkRe = /\[(?:[^\]]*)\]\(\s*<?(https?:\/\/[^)\s>]+)>?(?:\s+["'][^"']*["'])?\s*\)/g;
464
+ let m;
465
+ while ((m = mdLinkRe.exec(markdown)) !== null) urls.add(m[1]);
466
+ const stripped = markdown.replace(/\[(?:[^\]]*)\]\(\s*<?https?:\/\/[^)\s>]+>?(?:\s+["'][^"']*["'])?\s*\)/g, "");
467
+ const bareRe = /https?:\/\/[^\s)\]>]+/g;
468
+ while ((m = bareRe.exec(stripped)) !== null) urls.add(m[0]);
469
+ return [...urls];
470
+ }
471
+ /** Strip ANSI SGR and OSC 8 sequences to get visible text. */
472
+ function stripAnsi(input) {
473
+ return input.replace(ANSI_RE, "");
474
+ }
475
+ /**
476
+ * Find URL ranges in a line's visible text, handling cross-line URL splits.
477
+ */
478
+ function findUrlRanges(visibleText, knownUrls, pending) {
479
+ const ranges = [];
480
+ let newPending = null;
481
+ let searchFrom = 0;
482
+ if (pending) {
483
+ const remaining = pending.url.slice(pending.consumed);
484
+ const trimmed = visibleText.trimStart();
485
+ const leadingSpaces = visibleText.length - trimmed.length;
486
+ let matchLen = 0;
487
+ for (let j = 0; j < remaining.length && j < trimmed.length; j++) if (remaining[j] === trimmed[j]) matchLen++;
488
+ else break;
489
+ if (matchLen > 0) {
490
+ ranges.push({
491
+ start: leadingSpaces,
492
+ end: leadingSpaces + matchLen,
493
+ url: pending.url
494
+ });
495
+ searchFrom = leadingSpaces + matchLen;
496
+ if (pending.consumed + matchLen < pending.url.length) newPending = {
497
+ url: pending.url,
498
+ consumed: pending.consumed + matchLen
499
+ };
500
+ }
501
+ }
502
+ const urlRe = /https?:\/\/[^\s)\]>]+/g;
503
+ urlRe.lastIndex = searchFrom;
504
+ let match;
505
+ while ((match = urlRe.exec(visibleText)) !== null) {
506
+ const fragment = match[0];
507
+ const start = match.index;
508
+ let resolvedUrl = fragment;
509
+ let found = false;
510
+ for (const known of knownUrls) if (known === fragment) {
511
+ resolvedUrl = known;
512
+ found = true;
513
+ break;
514
+ }
515
+ if (!found) {
516
+ let bestLen = 0;
517
+ for (const known of knownUrls) if (known.startsWith(fragment) && known.length > bestLen) {
518
+ resolvedUrl = known;
519
+ bestLen = known.length;
520
+ found = true;
521
+ }
522
+ }
523
+ if (!found) {
524
+ let bestLen = 0;
525
+ for (const known of knownUrls) if (fragment.startsWith(known) && known.length > bestLen) {
526
+ resolvedUrl = known;
527
+ bestLen = known.length;
528
+ }
529
+ }
530
+ ranges.push({
531
+ start,
532
+ end: start + fragment.length,
533
+ url: resolvedUrl
534
+ });
535
+ if (resolvedUrl.length > fragment.length && resolvedUrl.startsWith(fragment)) newPending = {
536
+ url: resolvedUrl,
537
+ consumed: fragment.length
538
+ };
539
+ }
540
+ return {
541
+ ranges,
542
+ pending: newPending
543
+ };
544
+ }
545
+ /**
546
+ * Apply OSC 8 hyperlink sequences to a line based on visible-text URL ranges.
547
+ * Walks through the raw string character by character, inserting OSC 8
548
+ * open/close sequences at URL range boundaries while preserving ANSI codes.
549
+ */
550
+ function applyOsc8Ranges(line, ranges) {
551
+ if (ranges.length === 0) return line;
552
+ const urlAt = /* @__PURE__ */ new Map();
553
+ for (const r of ranges) for (let p = r.start; p < r.end; p++) urlAt.set(p, r.url);
554
+ let result = "";
555
+ let visiblePos = 0;
556
+ let activeUrl = null;
557
+ let i = 0;
558
+ while (i < line.length) {
559
+ if (line.charCodeAt(i) === 27) {
560
+ const sgr = line.slice(i).match(SGR_START_RE);
561
+ if (sgr) {
562
+ result += sgr[0];
563
+ i += sgr[0].length;
564
+ continue;
565
+ }
566
+ const osc = line.slice(i).match(OSC8_START_RE);
567
+ if (osc) {
568
+ result += osc[0];
569
+ i += osc[0].length;
570
+ continue;
571
+ }
572
+ }
573
+ const targetUrl = urlAt.get(visiblePos) ?? null;
574
+ if (targetUrl !== activeUrl) {
575
+ if (activeUrl !== null) result += "\x1B]8;;\x07";
576
+ if (targetUrl !== null) result += `\x1b]8;;${targetUrl}\x07`;
577
+ activeUrl = targetUrl;
578
+ }
579
+ result += line[i];
580
+ visiblePos++;
581
+ i++;
582
+ }
583
+ if (activeUrl !== null) result += "\x1B]8;;\x07";
584
+ return result;
585
+ }
586
+ /**
587
+ * Add OSC 8 hyperlinks to rendered lines using a pre-extracted URL list.
588
+ *
589
+ * For each line, finds URL-like substrings in the visible text, matches them
590
+ * against known URLs, and wraps each fragment with OSC 8 escape sequences.
591
+ * Handles URLs broken across multiple lines by pi-tui's word wrapping.
592
+ */
593
+ function addOsc8Hyperlinks(lines, urls) {
594
+ if (urls.length === 0) return lines;
595
+ let pending = null;
596
+ return lines.map((line) => {
597
+ const result = findUrlRanges(stripAnsi(line), urls, pending);
598
+ pending = result.pending;
599
+ return applyOsc8Ranges(line, result.ranges);
600
+ });
601
+ }
602
+ //#endregion
603
+ //#region src/tui/components/hyperlink-markdown.ts
604
+ /**
605
+ * Wrapper around pi-tui's Markdown component that adds OSC 8 terminal
606
+ * hyperlinks to rendered output, making URLs clickable even when broken
607
+ * across multiple lines by word wrapping.
608
+ */
609
+ var HyperlinkMarkdown = class {
610
+ constructor(text, paddingX, paddingY, theme, options) {
611
+ this.inner = new Markdown(text, paddingX, paddingY, theme, options);
612
+ this.urls = extractUrls(text);
613
+ }
614
+ render(width) {
615
+ return addOsc8Hyperlinks(this.inner.render(width), this.urls);
616
+ }
617
+ setText(text) {
618
+ this.inner.setText(text);
619
+ this.urls = extractUrls(text);
620
+ }
621
+ invalidate() {
622
+ this.inner.invalidate();
623
+ }
624
+ };
625
+ //#endregion
626
+ //#region src/tui/components/assistant-message.ts
627
+ var AssistantMessageComponent = class extends Container {
628
+ constructor(text) {
629
+ super();
630
+ this.body = new HyperlinkMarkdown(text, 0, 0, markdownTheme, { color: (line) => theme.assistantText(line) });
631
+ this.addChild(new Spacer(1));
632
+ this.addChild(this.body);
633
+ }
634
+ setText(text) {
635
+ this.body.setText(text);
636
+ }
637
+ };
638
+ //#endregion
639
+ //#region src/tui/components/btw-inline-message.ts
640
+ var BtwInlineMessage = class extends Container {
641
+ constructor(params) {
642
+ super();
643
+ this.setResult(params);
644
+ }
645
+ setResult(params) {
646
+ this.clear();
647
+ this.addChild(new Spacer(1));
648
+ this.addChild(new Text(theme.header(`BTW: ${params.question}`), 1, 0));
649
+ if (params.isError) this.addChild(new Text(theme.error(params.text), 1, 0));
650
+ else this.addChild(new AssistantMessageComponent(params.text));
651
+ this.addChild(new Text(theme.dim("Press Enter or Esc to dismiss"), 1, 0));
652
+ }
653
+ };
654
+ //#endregion
655
+ //#region src/tui/tui-formatters.ts
656
+ const REPLACEMENT_CHAR_RE = /\uFFFD/g;
657
+ const MAX_TOKEN_CHARS = 32;
658
+ const LONG_TOKEN_RE = /\S{33,}/g;
659
+ const LONG_TOKEN_TEST_RE = /\S{33,}/;
660
+ const BINARY_LINE_REPLACEMENT_THRESHOLD = 12;
661
+ const URL_PREFIX_RE = /^(https?:\/\/|file:\/\/)/i;
662
+ const WINDOWS_DRIVE_RE = /^[a-zA-Z]:[\\/]/;
663
+ const FILE_LIKE_RE = /^[a-zA-Z0-9._-]+$/;
664
+ const EDGE_PUNCTUATION_RE = /^[`"'([{<]+|[`"')\]}>.,:;!?]+$/g;
665
+ const TOKENISH_MIN_LENGTH = 24;
666
+ const RTL_SCRIPT_RE = /[\u0590-\u08ff\ufb1d-\ufdff\ufe70-\ufefc]/;
667
+ const BIDI_CONTROL_RE = /[\u202a-\u202e\u2066-\u2069]/;
668
+ const RTL_ISOLATE_START = "⁧";
669
+ const RTL_ISOLATE_END = "⁩";
670
+ function hasControlChars(text) {
671
+ for (const char of text) {
672
+ const code = char.charCodeAt(0);
673
+ if (code <= 31 && code !== 9 && code !== 10 && code !== 13 || code >= 127 && code <= 159) return true;
674
+ }
675
+ return false;
676
+ }
677
+ function stripControlChars(text) {
678
+ if (!hasControlChars(text)) return text;
679
+ let sanitized = "";
680
+ for (const char of text) {
681
+ const code = char.charCodeAt(0);
682
+ if (!(code <= 31 && code !== 9 && code !== 10 && code !== 13) && !(code >= 127 && code <= 159)) sanitized += char;
683
+ }
684
+ return sanitized;
685
+ }
686
+ function chunkToken(token, maxChars) {
687
+ if (token.length <= maxChars) return [token];
688
+ const chunks = [];
689
+ for (let i = 0; i < token.length; i += maxChars) chunks.push(token.slice(i, i + maxChars));
690
+ return chunks;
691
+ }
692
+ function isCopySensitiveToken(token) {
693
+ const candidate = token.replace(EDGE_PUNCTUATION_RE, "") || token;
694
+ if (URL_PREFIX_RE.test(token)) return true;
695
+ if (token.startsWith("/") || token.startsWith("~/") || token.startsWith("./") || token.startsWith("../")) return true;
696
+ if (WINDOWS_DRIVE_RE.test(token) || token.startsWith("\\\\")) return true;
697
+ if (token.includes("/") || token.includes("\\")) return true;
698
+ if (token.includes("_") && FILE_LIKE_RE.test(token)) return true;
699
+ if (candidate.length >= TOKENISH_MIN_LENGTH && /[a-z]/i.test(candidate) && /\d/.test(candidate)) return true;
700
+ return false;
701
+ }
702
+ function normalizeLongTokenForDisplay(token) {
703
+ if (isCopySensitiveToken(token)) return token;
704
+ return chunkToken(token, MAX_TOKEN_CHARS).join(" ");
705
+ }
706
+ function redactBinaryLikeLine(line) {
707
+ const replacementCount = (line.match(REPLACEMENT_CHAR_RE) || []).length;
708
+ if (replacementCount >= BINARY_LINE_REPLACEMENT_THRESHOLD && replacementCount * 2 >= line.length) return "[binary data omitted]";
709
+ return line;
710
+ }
711
+ function isolateRtlLine(line) {
712
+ if (!RTL_SCRIPT_RE.test(line) || BIDI_CONTROL_RE.test(line)) return line;
713
+ return `${RTL_ISOLATE_START}${line}${RTL_ISOLATE_END}`;
714
+ }
715
+ function applyRtlIsolation(text) {
716
+ if (!RTL_SCRIPT_RE.test(text)) return text;
717
+ return text.split("\n").map((line) => isolateRtlLine(line)).join("\n");
718
+ }
719
+ function sanitizeRenderableText(text) {
720
+ if (!text) return text;
721
+ const hasAnsi = text.includes("\x1B");
722
+ const hasReplacementChars = text.includes("�");
723
+ const hasLongTokens = LONG_TOKEN_TEST_RE.test(text);
724
+ const hasControls = hasControlChars(text);
725
+ if (!hasAnsi && !hasReplacementChars && !hasLongTokens && !hasControls) return applyRtlIsolation(text);
726
+ const withoutAnsi = hasAnsi ? stripAnsi$1(text) : text;
727
+ const withoutControlChars = hasControls ? stripControlChars(withoutAnsi) : withoutAnsi;
728
+ const redacted = hasReplacementChars ? withoutControlChars.split("\n").map((line) => redactBinaryLikeLine(line)).join("\n") : withoutControlChars;
729
+ return applyRtlIsolation(LONG_TOKEN_TEST_RE.test(redacted) ? redacted.replace(LONG_TOKEN_RE, normalizeLongTokenForDisplay) : redacted);
730
+ }
731
+ function resolveFinalAssistantText(params) {
732
+ const finalText = params.finalText ?? "";
733
+ if (finalText.trim()) return finalText;
734
+ const streamedText = params.streamedText ?? "";
735
+ if (streamedText.trim()) return streamedText;
736
+ const errorMessage = params.errorMessage ?? "";
737
+ if (errorMessage.trim()) return formatRawAssistantErrorForUi(errorMessage);
738
+ return "(no output)";
739
+ }
740
+ function composeThinkingAndContent(params) {
741
+ const thinkingText = params.thinkingText?.trim() ?? "";
742
+ const contentText = params.contentText?.trim() ?? "";
743
+ const parts = [];
744
+ if (params.showThinking && thinkingText) parts.push(`[thinking]\n${thinkingText}`);
745
+ if (contentText) parts.push(contentText);
746
+ return parts.join("\n\n").trim();
747
+ }
748
+ function asMessageRecord(message) {
749
+ if (!message || typeof message !== "object") return;
750
+ return message;
751
+ }
752
+ function resolveMessageRecord(message) {
753
+ const record = asMessageRecord(message);
754
+ if (!record) return;
755
+ return {
756
+ record,
757
+ content: record.content
758
+ };
759
+ }
760
+ function formatAssistantErrorFromRecord(record) {
761
+ if ((typeof record.stopReason === "string" ? record.stopReason : "") !== "error") return "";
762
+ return formatRawAssistantErrorForUi(typeof record.errorMessage === "string" ? record.errorMessage : "");
763
+ }
764
+ function collectSanitizedBlockStrings(params) {
765
+ if (!Array.isArray(params.content)) return [];
766
+ const parts = [];
767
+ for (const block of params.content) {
768
+ if (!block || typeof block !== "object") continue;
769
+ const rec = block;
770
+ if (rec.type === params.blockType && typeof rec[params.valueKey] === "string") parts.push(sanitizeRenderableText(rec[params.valueKey]));
771
+ }
772
+ return parts;
773
+ }
774
+ /**
775
+ * Extract ONLY thinking blocks from message content.
776
+ * Model-agnostic: returns empty string if no thinking blocks exist.
777
+ */
778
+ function extractThinkingFromMessage(message) {
779
+ const resolved = resolveMessageRecord(message);
780
+ if (!resolved) return "";
781
+ const { content } = resolved;
782
+ if (typeof content === "string") return "";
783
+ return collectSanitizedBlockStrings({
784
+ content,
785
+ blockType: "thinking",
786
+ valueKey: "thinking"
787
+ }).join("\n").trim();
788
+ }
789
+ /**
790
+ * Extract ONLY text content blocks from message (excludes thinking).
791
+ * Model-agnostic: works for any model with text content blocks.
792
+ */
793
+ function extractContentFromMessage(message) {
794
+ const resolved = resolveMessageRecord(message);
795
+ if (!resolved) return "";
796
+ const { record, content } = resolved;
797
+ if (record.role === "assistant") {
798
+ if (typeof content === "string") return sanitizeRenderableText(content).trim();
799
+ if (Array.isArray(content)) return extractAssistantRenderableContent(record);
800
+ }
801
+ if (typeof content === "string") return sanitizeRenderableText(content).trim();
802
+ const parts = collectSanitizedBlockStrings({
803
+ content,
804
+ blockType: "text",
805
+ valueKey: "text"
806
+ });
807
+ if (parts.length > 0) return parts.join("\n").trim();
808
+ return formatAssistantErrorFromRecord(record);
809
+ }
810
+ function extractAssistantRenderableContent(record) {
811
+ const visible = sanitizeRenderableText(extractAssistantVisibleText(record) ?? "").trim();
812
+ if (visible) return visible;
813
+ return formatAssistantErrorFromRecord(record);
814
+ }
815
+ function extractTextBlocks(content, opts) {
816
+ if (typeof content === "string") return sanitizeRenderableText(content).trim();
817
+ if (!Array.isArray(content)) return "";
818
+ const textParts = collectSanitizedBlockStrings({
819
+ content,
820
+ blockType: "text",
821
+ valueKey: "text"
822
+ });
823
+ return composeThinkingAndContent({
824
+ thinkingText: (opts?.includeThinking === true ? collectSanitizedBlockStrings({
825
+ content,
826
+ blockType: "thinking",
827
+ valueKey: "thinking"
828
+ }) : []).join("\n").trim(),
829
+ contentText: textParts.join("\n").trim(),
830
+ showThinking: opts?.includeThinking ?? false
831
+ });
832
+ }
833
+ function extractTextFromMessage(message, opts) {
834
+ const record = asMessageRecord(message);
835
+ if (!record) return "";
836
+ if (record.role === "assistant") return composeThinkingAndContent({
837
+ thinkingText: extractThinkingFromMessage(record),
838
+ contentText: extractAssistantRenderableContent(record),
839
+ showThinking: opts?.includeThinking ?? false
840
+ });
841
+ const text = extractTextBlocks(record.content, opts);
842
+ if (text) {
843
+ if (record.role === "user" || record.command === true) return stripLeadingInboundMetadata(text);
844
+ return text;
845
+ }
846
+ const errorText = formatAssistantErrorFromRecord(record);
847
+ if (!errorText) return "";
848
+ return errorText;
849
+ }
850
+ function isCommandMessage(message) {
851
+ if (!message || typeof message !== "object") return false;
852
+ return message.command === true;
853
+ }
854
+ function formatTokens(total, context) {
855
+ if (total == null && context == null) return "tokens ?";
856
+ const totalLabel = total == null ? "?" : formatTokenCount(total);
857
+ if (context == null) return `tokens ${totalLabel}`;
858
+ const pct = typeof total === "number" && context > 0 ? Math.min(999, Math.round(total / context * 100)) : null;
859
+ return `tokens ${totalLabel}/${formatTokenCount(context)}${pct !== null ? ` (${pct}%)` : ""}`;
860
+ }
861
+ function formatContextUsageLine(params) {
862
+ const totalLabel = typeof params.total === "number" ? formatTokenCount(params.total) : "?";
863
+ const ctxLabel = typeof params.context === "number" ? formatTokenCount(params.context) : "?";
864
+ const pct = typeof params.percent === "number" ? Math.min(999, Math.round(params.percent)) : null;
865
+ const extra = [typeof params.remaining === "number" ? `${formatTokenCount(params.remaining)} left` : null, pct !== null ? `${pct}%` : null].filter(Boolean).join(", ");
866
+ return `tokens ${totalLabel}/${ctxLabel}${extra ? ` (${extra})` : ""}`;
867
+ }
868
+ function asString(value, fallback = "") {
869
+ if (typeof value === "string") return value;
870
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
871
+ return fallback;
872
+ }
873
+ //#endregion
874
+ //#region src/tui/components/tool-execution.ts
875
+ const PREVIEW_LINES = 12;
876
+ function formatArgs(toolName, args) {
877
+ const detail = formatToolDetail(resolveToolDisplay({
878
+ name: toolName,
879
+ args
880
+ }));
881
+ if (detail) return sanitizeRenderableText(detail);
882
+ if (!args || typeof args !== "object") return "";
883
+ try {
884
+ return sanitizeRenderableText(JSON.stringify(args));
885
+ } catch {
886
+ return "";
887
+ }
888
+ }
889
+ function extractText(result) {
890
+ if (!result?.content) return "";
891
+ const lines = [];
892
+ for (const entry of result.content) if (entry.type === "text" && entry.text) lines.push(sanitizeRenderableText(entry.text));
893
+ else if (entry.type === "image") {
894
+ const mime = entry.mimeType ?? "image";
895
+ const size = entry.bytes ? ` ${Math.round(entry.bytes / 1024)}kb` : "";
896
+ const omitted = entry.omitted ? " (omitted)" : "";
897
+ lines.push(`[${mime}${size}${omitted}]`);
898
+ }
899
+ return lines.join("\n").trim();
900
+ }
901
+ var ToolExecutionComponent = class extends Container {
902
+ constructor(toolName, args) {
903
+ super();
904
+ this.expanded = false;
905
+ this.isError = false;
906
+ this.isPartial = true;
907
+ this.toolName = toolName;
908
+ this.args = args;
909
+ this.box = new Box(1, 1, (line) => theme.toolPendingBg(line));
910
+ this.header = new Text("", 0, 0);
911
+ this.argsLine = new Text("", 0, 0);
912
+ this.output = new Markdown("", 0, 0, markdownTheme, { color: (line) => theme.toolOutput(line) });
913
+ this.addChild(new Spacer(1));
914
+ this.addChild(this.box);
915
+ this.box.addChild(this.header);
916
+ this.box.addChild(this.argsLine);
917
+ this.box.addChild(this.output);
918
+ this.refresh();
919
+ }
920
+ setArgs(args) {
921
+ this.args = args;
922
+ this.refresh();
923
+ }
924
+ setExpanded(expanded) {
925
+ this.expanded = expanded;
926
+ this.refresh();
927
+ }
928
+ setResult(result, opts) {
929
+ this.result = result;
930
+ this.isPartial = false;
931
+ this.isError = Boolean(opts?.isError);
932
+ this.refresh();
933
+ }
934
+ setPartialResult(result) {
935
+ this.result = result;
936
+ this.isPartial = true;
937
+ this.refresh();
938
+ }
939
+ refresh() {
940
+ const bg = this.isPartial ? theme.toolPendingBg : this.isError ? theme.toolErrorBg : theme.toolSuccessBg;
941
+ this.box.setBgFn((line) => bg(line));
942
+ const display = resolveToolDisplay({
943
+ name: this.toolName,
944
+ args: this.args
945
+ });
946
+ const title = `${display.emoji} ${display.label}${this.isPartial ? " (running)" : ""}`;
947
+ this.header.setText(theme.toolTitle(theme.bold(title)));
948
+ const argLine = formatArgs(this.toolName, this.args);
949
+ this.argsLine.setText(argLine ? theme.dim(argLine) : theme.dim(" "));
950
+ const text = extractText(this.result) || (this.isPartial ? "…" : "");
951
+ if (!this.expanded && text) {
952
+ const lines = text.split("\n");
953
+ const preview = lines.length > PREVIEW_LINES ? `${lines.slice(0, PREVIEW_LINES).join("\n")}\n…` : text;
954
+ this.output.setText(preview);
955
+ } else this.output.setText(text);
956
+ }
957
+ };
958
+ //#endregion
959
+ //#region src/tui/components/markdown-message.ts
960
+ var MarkdownMessageComponent = class extends Container {
961
+ constructor(text, y, options) {
962
+ super();
963
+ this.body = new HyperlinkMarkdown(text, 0, y, markdownTheme, options);
964
+ this.addChild(new Spacer(1));
965
+ this.addChild(this.body);
966
+ }
967
+ setText(text) {
968
+ this.body.setText(text);
969
+ }
970
+ };
971
+ //#endregion
972
+ //#region src/tui/components/user-message.ts
973
+ var UserMessageComponent = class extends MarkdownMessageComponent {
974
+ constructor(text) {
975
+ super(text, 1, {
976
+ bgColor: (line) => theme.userBg(line),
977
+ color: (line) => theme.userText(line)
978
+ });
979
+ }
980
+ };
981
+ //#endregion
982
+ //#region src/tui/components/chat-log.ts
983
+ const PENDING_HISTORY_CLOCK_SKEW_TOLERANCE_MS = 6e4;
984
+ var ChatLog = class extends Container {
985
+ constructor(maxComponents = 180) {
986
+ super();
987
+ this.toolById = /* @__PURE__ */ new Map();
988
+ this.streamingRuns = /* @__PURE__ */ new Map();
989
+ this.pendingUsers = /* @__PURE__ */ new Map();
990
+ this.btwMessage = null;
991
+ this.toolsExpanded = false;
992
+ this.maxComponents = Math.max(20, Math.floor(maxComponents));
993
+ }
994
+ dropComponentReferences(component) {
995
+ for (const [toolId, tool] of this.toolById.entries()) if (tool === component) this.toolById.delete(toolId);
996
+ for (const [runId, message] of this.streamingRuns.entries()) if (message === component) this.streamingRuns.delete(runId);
997
+ for (const [runId, entry] of this.pendingUsers.entries()) if (entry.component === component) this.pendingUsers.delete(runId);
998
+ if (this.btwMessage === component) this.btwMessage = null;
999
+ }
1000
+ pruneOverflow() {
1001
+ while (this.children.length > this.maxComponents) {
1002
+ const oldest = this.children[0];
1003
+ if (!oldest) return;
1004
+ this.removeChild(oldest);
1005
+ this.dropComponentReferences(oldest);
1006
+ }
1007
+ }
1008
+ append(component) {
1009
+ this.addChild(component);
1010
+ this.pruneOverflow();
1011
+ }
1012
+ clearAll(opts) {
1013
+ this.clear();
1014
+ this.toolById.clear();
1015
+ this.streamingRuns.clear();
1016
+ this.btwMessage = null;
1017
+ if (!opts?.preservePendingUsers) this.pendingUsers.clear();
1018
+ }
1019
+ restorePendingUsers() {
1020
+ for (const entry of this.pendingUsers.values()) {
1021
+ if (this.children.includes(entry.component)) continue;
1022
+ this.append(entry.component);
1023
+ }
1024
+ }
1025
+ clearPendingUsers() {
1026
+ for (const entry of this.pendingUsers.values()) this.removeChild(entry.component);
1027
+ this.pendingUsers.clear();
1028
+ }
1029
+ createSystemMessage(text) {
1030
+ const entry = new Container();
1031
+ entry.addChild(new Spacer(1));
1032
+ entry.addChild(new Text(theme.system(text), 1, 0));
1033
+ return entry;
1034
+ }
1035
+ addSystem(text) {
1036
+ this.append(this.createSystemMessage(text));
1037
+ }
1038
+ addUser(text) {
1039
+ this.append(new UserMessageComponent(text));
1040
+ }
1041
+ addPendingUser(runId, text, createdAt = Date.now()) {
1042
+ const existing = this.pendingUsers.get(runId);
1043
+ if (existing) {
1044
+ existing.text = text;
1045
+ existing.createdAt = createdAt;
1046
+ existing.component.setText(text);
1047
+ return existing.component;
1048
+ }
1049
+ const component = new UserMessageComponent(text);
1050
+ this.pendingUsers.set(runId, {
1051
+ component,
1052
+ text,
1053
+ createdAt
1054
+ });
1055
+ this.append(component);
1056
+ return component;
1057
+ }
1058
+ commitPendingUser(runId) {
1059
+ return this.pendingUsers.delete(runId);
1060
+ }
1061
+ dropPendingUser(runId) {
1062
+ const existing = this.pendingUsers.get(runId);
1063
+ if (!existing) return false;
1064
+ this.removeChild(existing.component);
1065
+ this.pendingUsers.delete(runId);
1066
+ return true;
1067
+ }
1068
+ hasPendingUser(runId) {
1069
+ return this.pendingUsers.has(runId);
1070
+ }
1071
+ reconcilePendingUsers(historyUsers) {
1072
+ const normalizedHistory = historyUsers.map((entry) => ({
1073
+ text: entry.text.trim(),
1074
+ timestamp: typeof entry.timestamp === "number" ? entry.timestamp : null
1075
+ })).filter((entry) => entry.text.length > 0 && entry.timestamp !== null);
1076
+ const clearedRunIds = [];
1077
+ for (const [runId, entry] of this.pendingUsers.entries()) {
1078
+ const pendingText = entry.text.trim();
1079
+ if (!pendingText) continue;
1080
+ const matchIndex = normalizedHistory.findIndex((historyEntry) => historyEntry.text === pendingText && (historyEntry.timestamp ?? 0) >= entry.createdAt - PENDING_HISTORY_CLOCK_SKEW_TOLERANCE_MS);
1081
+ if (matchIndex === -1) continue;
1082
+ if (this.children.includes(entry.component)) this.removeChild(entry.component);
1083
+ this.pendingUsers.delete(runId);
1084
+ clearedRunIds.push(runId);
1085
+ normalizedHistory.splice(matchIndex, 1);
1086
+ }
1087
+ return clearedRunIds;
1088
+ }
1089
+ countPendingUsers() {
1090
+ return this.pendingUsers.size;
1091
+ }
1092
+ resolveRunId(runId) {
1093
+ return runId ?? "default";
1094
+ }
1095
+ startAssistant(text, runId) {
1096
+ const effectiveRunId = this.resolveRunId(runId);
1097
+ const existing = this.streamingRuns.get(effectiveRunId);
1098
+ if (existing) {
1099
+ existing.setText(text);
1100
+ return existing;
1101
+ }
1102
+ const component = new AssistantMessageComponent(text);
1103
+ this.streamingRuns.set(effectiveRunId, component);
1104
+ this.append(component);
1105
+ return component;
1106
+ }
1107
+ updateAssistant(text, runId) {
1108
+ const effectiveRunId = this.resolveRunId(runId);
1109
+ const existing = this.streamingRuns.get(effectiveRunId);
1110
+ if (!existing) {
1111
+ this.startAssistant(text, runId);
1112
+ return;
1113
+ }
1114
+ existing.setText(text);
1115
+ }
1116
+ finalizeAssistant(text, runId) {
1117
+ const effectiveRunId = this.resolveRunId(runId);
1118
+ const existing = this.streamingRuns.get(effectiveRunId);
1119
+ if (existing) {
1120
+ existing.setText(text);
1121
+ this.streamingRuns.delete(effectiveRunId);
1122
+ return;
1123
+ }
1124
+ this.append(new AssistantMessageComponent(text));
1125
+ }
1126
+ dropAssistant(runId) {
1127
+ const effectiveRunId = this.resolveRunId(runId);
1128
+ const existing = this.streamingRuns.get(effectiveRunId);
1129
+ if (!existing) return;
1130
+ this.removeChild(existing);
1131
+ this.streamingRuns.delete(effectiveRunId);
1132
+ }
1133
+ showBtw(params) {
1134
+ if (this.btwMessage) {
1135
+ this.btwMessage.setResult(params);
1136
+ if (this.children[this.children.length - 1] !== this.btwMessage) {
1137
+ this.removeChild(this.btwMessage);
1138
+ this.append(this.btwMessage);
1139
+ }
1140
+ return this.btwMessage;
1141
+ }
1142
+ const component = new BtwInlineMessage(params);
1143
+ this.btwMessage = component;
1144
+ this.append(component);
1145
+ return component;
1146
+ }
1147
+ dismissBtw() {
1148
+ if (!this.btwMessage) return;
1149
+ this.removeChild(this.btwMessage);
1150
+ this.btwMessage = null;
1151
+ }
1152
+ hasVisibleBtw() {
1153
+ return this.btwMessage !== null;
1154
+ }
1155
+ startTool(toolCallId, toolName, args) {
1156
+ const existing = this.toolById.get(toolCallId);
1157
+ if (existing) {
1158
+ existing.setArgs(args);
1159
+ return existing;
1160
+ }
1161
+ const component = new ToolExecutionComponent(toolName, args);
1162
+ component.setExpanded(this.toolsExpanded);
1163
+ this.toolById.set(toolCallId, component);
1164
+ this.append(component);
1165
+ return component;
1166
+ }
1167
+ updateToolArgs(toolCallId, args) {
1168
+ const existing = this.toolById.get(toolCallId);
1169
+ if (!existing) return;
1170
+ existing.setArgs(args);
1171
+ }
1172
+ updateToolResult(toolCallId, result, opts) {
1173
+ const existing = this.toolById.get(toolCallId);
1174
+ if (!existing) return;
1175
+ if (opts?.partial) {
1176
+ existing.setPartialResult(result);
1177
+ return;
1178
+ }
1179
+ existing.setResult(result, { isError: opts?.isError });
1180
+ }
1181
+ setToolsExpanded(expanded) {
1182
+ this.toolsExpanded = expanded;
1183
+ for (const tool of this.toolById.values()) tool.setExpanded(expanded);
1184
+ }
1185
+ };
1186
+ //#endregion
1187
+ //#region src/tui/components/custom-editor.ts
1188
+ var CustomEditor = class extends Editor {
1189
+ handleInput(data) {
1190
+ if (matchesKey(data, Key.alt("enter")) && this.onAltEnter) {
1191
+ this.onAltEnter();
1192
+ return;
1193
+ }
1194
+ if (matchesKey(data, Key.alt("up")) && this.onAltUp) {
1195
+ this.onAltUp();
1196
+ return;
1197
+ }
1198
+ if (matchesKey(data, Key.ctrl("l")) && this.onCtrlL) {
1199
+ this.onCtrlL();
1200
+ return;
1201
+ }
1202
+ if (matchesKey(data, Key.ctrl("o")) && this.onCtrlO) {
1203
+ this.onCtrlO();
1204
+ return;
1205
+ }
1206
+ if (matchesKey(data, Key.ctrl("p")) && this.onCtrlP) {
1207
+ this.onCtrlP();
1208
+ return;
1209
+ }
1210
+ if (matchesKey(data, Key.ctrl("g")) && this.onCtrlG) {
1211
+ this.onCtrlG();
1212
+ return;
1213
+ }
1214
+ if (matchesKey(data, Key.ctrl("t")) && this.onCtrlT) {
1215
+ this.onCtrlT();
1216
+ return;
1217
+ }
1218
+ if (matchesKey(data, Key.shift("tab")) && this.onShiftTab) {
1219
+ this.onShiftTab();
1220
+ return;
1221
+ }
1222
+ if (matchesKey(data, Key.escape) && this.onEscape && !this.isShowingAutocomplete()) {
1223
+ this.onEscape();
1224
+ return;
1225
+ }
1226
+ if (matchesKey(data, Key.ctrl("c")) && this.onCtrlC) {
1227
+ this.onCtrlC();
1228
+ return;
1229
+ }
1230
+ if (matchesKey(data, Key.ctrl("d"))) {
1231
+ if (this.getText().length === 0 && this.onCtrlD) this.onCtrlD();
1232
+ return;
1233
+ }
1234
+ super.handleInput(data);
1235
+ }
1236
+ };
1237
+ //#endregion
1238
+ //#region src/tui/embedded-backend.ts
1239
+ const silentRuntime = {
1240
+ log: (..._args) => void 0,
1241
+ error: (..._args) => void 0,
1242
+ exit: (code) => {
1243
+ throw new Error(`embedded tui runtime exit ${String(code)}`);
1244
+ }
1245
+ };
1246
+ function isSilentReplyLeadFragment(text) {
1247
+ const normalized = text.trim().toUpperCase();
1248
+ if (!normalized) return false;
1249
+ if (!/^[A-Z_]+$/.test(normalized)) return false;
1250
+ if (normalized === "NO_REPLY") return false;
1251
+ return SILENT_REPLY_TOKEN.startsWith(normalized);
1252
+ }
1253
+ function appendUniqueSuffix(base, suffix) {
1254
+ if (!suffix) return base;
1255
+ if (!base) return suffix;
1256
+ if (base.endsWith(suffix)) return base;
1257
+ const maxOverlap = Math.min(base.length, suffix.length);
1258
+ for (let overlap = maxOverlap; overlap > 0; overlap -= 1) if (base.slice(-overlap) === suffix.slice(0, overlap)) return base + suffix.slice(overlap);
1259
+ return base + suffix;
1260
+ }
1261
+ function resolveMergedAssistantText(params) {
1262
+ const previous = params.previousText;
1263
+ const next = params.nextText;
1264
+ const delta = params.nextDelta;
1265
+ if (!previous) return next || delta;
1266
+ if (next && next.startsWith(previous)) return next;
1267
+ if (delta) return appendUniqueSuffix(previous, delta);
1268
+ return appendUniqueSuffix(previous, next);
1269
+ }
1270
+ function resolveBtwQuestion(message) {
1271
+ const question = /^\/btw(?::|\s)+(.*)$/i.exec(message.trim())?.[1]?.trim();
1272
+ return question ? question : void 0;
1273
+ }
1274
+ function payloadText(parts) {
1275
+ if (!Array.isArray(parts)) return "";
1276
+ return parts.map((part) => {
1277
+ if (!part || typeof part !== "object") return "";
1278
+ const payload = part;
1279
+ return typeof payload.text === "string" ? payload.text.trim() : "";
1280
+ }).filter(Boolean).join("\n\n").trim();
1281
+ }
1282
+ function timeoutSecondsFromMs(timeoutMs) {
1283
+ if (typeof timeoutMs !== "number" || !Number.isFinite(timeoutMs) || timeoutMs < 0) return;
1284
+ return String(Math.max(0, Math.ceil(timeoutMs / 1e3)));
1285
+ }
1286
+ var EmbeddedTuiBackend = class {
1287
+ constructor() {
1288
+ this.connection = { url: "local embedded" };
1289
+ this.deps = createDefaultDeps();
1290
+ this.runs = /* @__PURE__ */ new Map();
1291
+ this.seq = 0;
1292
+ }
1293
+ start() {
1294
+ if (this.unsubscribe) return;
1295
+ setEmbeddedMode(true);
1296
+ this.previousRuntimeLog = defaultRuntime.log;
1297
+ this.previousRuntimeError = defaultRuntime.error;
1298
+ defaultRuntime.log = silentRuntime.log;
1299
+ defaultRuntime.error = silentRuntime.error;
1300
+ this.unsubscribe = onAgentEvent((evt) => {
1301
+ this.handleAgentEvent(evt);
1302
+ });
1303
+ queueMicrotask(() => {
1304
+ this.onConnected?.();
1305
+ });
1306
+ }
1307
+ stop() {
1308
+ this.unsubscribe?.();
1309
+ this.unsubscribe = void 0;
1310
+ for (const run of this.runs.values()) run.controller.abort();
1311
+ this.runs.clear();
1312
+ defaultRuntime.log = this.previousRuntimeLog ?? defaultRuntime.log;
1313
+ defaultRuntime.error = this.previousRuntimeError ?? defaultRuntime.error;
1314
+ this.previousRuntimeLog = void 0;
1315
+ this.previousRuntimeError = void 0;
1316
+ setEmbeddedMode(false);
1317
+ }
1318
+ async sendChat(opts) {
1319
+ const runId = opts.runId ?? randomUUID();
1320
+ const question = resolveBtwQuestion(opts.message);
1321
+ if (!question) this.abortSessionRuns(opts.sessionKey);
1322
+ const controller = new AbortController();
1323
+ this.runs.set(runId, {
1324
+ sessionKey: opts.sessionKey,
1325
+ controller,
1326
+ buffer: "",
1327
+ isBtw: Boolean(question),
1328
+ question,
1329
+ finalSent: false,
1330
+ registered: false
1331
+ });
1332
+ this.runTurn({
1333
+ runId,
1334
+ sessionKey: opts.sessionKey,
1335
+ message: opts.message,
1336
+ thinking: opts.thinking,
1337
+ deliver: opts.deliver,
1338
+ timeoutMs: opts.timeoutMs,
1339
+ controller
1340
+ });
1341
+ return { runId };
1342
+ }
1343
+ async abortChat(opts) {
1344
+ const run = this.runs.get(opts.runId);
1345
+ if (!run || run.sessionKey !== opts.sessionKey) return {
1346
+ ok: true,
1347
+ aborted: false
1348
+ };
1349
+ run.controller.abort();
1350
+ return {
1351
+ ok: true,
1352
+ aborted: true
1353
+ };
1354
+ }
1355
+ async loadHistory(opts) {
1356
+ const { cfg, storePath, entry } = loadSessionEntry(opts.sessionKey);
1357
+ const sessionId = entry?.sessionId;
1358
+ const resolvedSessionModel = resolveSessionModelRef(cfg, entry, resolveSessionAgentId({
1359
+ sessionKey: opts.sessionKey,
1360
+ config: cfg
1361
+ }));
1362
+ const localMessages = sessionId && storePath ? readSessionMessages(sessionId, storePath, entry?.sessionFile) : [];
1363
+ const rawMessages = augmentChatHistoryWithCliSessionImports({
1364
+ entry,
1365
+ provider: resolvedSessionModel.provider,
1366
+ localMessages
1367
+ });
1368
+ const max = Math.min(1e3, typeof opts.limit === "number" ? opts.limit : 200);
1369
+ const sliced = rawMessages.length > max ? rawMessages.slice(-max) : rawMessages;
1370
+ const effectiveMaxChars = resolveEffectiveChatHistoryMaxChars(cfg);
1371
+ const normalized = augmentChatHistoryWithCanvasBlocks(sanitizeChatHistoryMessages(stripEnvelopeFromMessages(sliced), effectiveMaxChars));
1372
+ const maxHistoryBytes = getMaxChatHistoryMessagesBytes();
1373
+ const capped = capArrayByJsonBytes(replaceOversizedChatHistoryMessages({
1374
+ messages: normalized,
1375
+ maxSingleMessageBytes: Math.min(CHAT_HISTORY_MAX_SINGLE_MESSAGE_BYTES, maxHistoryBytes)
1376
+ }).messages, maxHistoryBytes).items;
1377
+ const messages = enforceChatHistoryFinalBudget({
1378
+ messages: capped,
1379
+ maxBytes: maxHistoryBytes
1380
+ }).messages;
1381
+ let thinkingLevel = entry?.thinkingLevel;
1382
+ if (!thinkingLevel) {
1383
+ const catalog = await loadGatewayModelCatalog();
1384
+ thinkingLevel = resolveThinkingDefault({
1385
+ cfg,
1386
+ provider: resolvedSessionModel.provider,
1387
+ model: resolvedSessionModel.model,
1388
+ catalog
1389
+ });
1390
+ }
1391
+ return {
1392
+ sessionKey: opts.sessionKey,
1393
+ sessionId,
1394
+ messages,
1395
+ thinkingLevel,
1396
+ fastMode: entry?.fastMode,
1397
+ verboseLevel: entry?.verboseLevel ?? cfg.agents?.defaults?.verboseDefault
1398
+ };
1399
+ }
1400
+ async listSessions(opts) {
1401
+ const cfg = loadConfig();
1402
+ const { storePath, store } = loadCombinedSessionStoreForGateway(cfg);
1403
+ return listSessionsFromStore({
1404
+ cfg,
1405
+ storePath,
1406
+ store,
1407
+ opts: opts ?? {}
1408
+ });
1409
+ }
1410
+ async listAgents() {
1411
+ return listAgentsForGateway(loadConfig());
1412
+ }
1413
+ async patchSession(opts) {
1414
+ const cfg = loadConfig();
1415
+ const target = resolveGatewaySessionStoreTarget({
1416
+ cfg,
1417
+ key: opts.key
1418
+ });
1419
+ const applied = await updateSessionStore(target.storePath, async (store) => {
1420
+ const { primaryKey } = migrateAndPruneGatewaySessionStoreKey({
1421
+ cfg,
1422
+ key: opts.key,
1423
+ store
1424
+ });
1425
+ return await applySessionsPatchToStore({
1426
+ cfg,
1427
+ store,
1428
+ storeKey: primaryKey,
1429
+ patch: opts,
1430
+ loadGatewayModelCatalog
1431
+ });
1432
+ });
1433
+ if (!applied.ok) throw new Error(applied.error.message);
1434
+ const agentId = resolveSessionAgentId({
1435
+ sessionKey: target.canonicalKey ?? opts.key,
1436
+ config: cfg
1437
+ });
1438
+ const resolved = resolveSessionModelRef(cfg, applied.entry, agentId);
1439
+ return {
1440
+ ok: true,
1441
+ path: target.storePath,
1442
+ key: target.canonicalKey ?? opts.key,
1443
+ entry: applied.entry,
1444
+ resolved: {
1445
+ modelProvider: resolved.provider,
1446
+ model: resolved.model
1447
+ }
1448
+ };
1449
+ }
1450
+ async resetSession(key, reason) {
1451
+ const result = await performGatewaySessionReset({
1452
+ key,
1453
+ reason: reason === "new" ? "new" : "reset",
1454
+ commandSource: "tui:embedded"
1455
+ });
1456
+ if (!result.ok) throw new Error(result.error.message);
1457
+ return {
1458
+ ok: true,
1459
+ key: result.key,
1460
+ entry: result.entry
1461
+ };
1462
+ }
1463
+ async getGatewayStatus() {
1464
+ return `local embedded mode${this.runs.size > 0 ? ` (${String(this.runs.size)} active run${this.runs.size === 1 ? "" : "s"})` : ""}`;
1465
+ }
1466
+ async listModels() {
1467
+ const catalog = await loadGatewayModelCatalog();
1468
+ const { allowedCatalog } = buildAllowedModelSet({
1469
+ cfg: loadConfig(),
1470
+ catalog,
1471
+ defaultProvider: DEFAULT_PROVIDER
1472
+ });
1473
+ return (allowedCatalog.length > 0 ? allowedCatalog : catalog).map((entry) => ({
1474
+ id: entry.id,
1475
+ name: entry.name ?? entry.id,
1476
+ provider: entry.provider,
1477
+ contextWindow: entry.contextWindow,
1478
+ reasoning: entry.reasoning
1479
+ }));
1480
+ }
1481
+ abortSessionRuns(sessionKey) {
1482
+ for (const run of this.runs.values()) if (run.sessionKey === sessionKey && !run.isBtw) run.controller.abort();
1483
+ }
1484
+ nextSeq() {
1485
+ this.seq += 1;
1486
+ return this.seq;
1487
+ }
1488
+ emit(event, payload) {
1489
+ this.onEvent?.({
1490
+ event,
1491
+ payload,
1492
+ seq: this.nextSeq()
1493
+ });
1494
+ }
1495
+ emitChatDelta(runId, run) {
1496
+ const text = run.buffer.trim();
1497
+ if (!text || isSilentReplyText(text, "NO_REPLY") || isSilentReplyLeadFragment(text)) return;
1498
+ run.registered = true;
1499
+ this.emit("chat", {
1500
+ runId,
1501
+ sessionKey: run.sessionKey,
1502
+ state: "delta",
1503
+ message: {
1504
+ role: "assistant",
1505
+ content: [{
1506
+ type: "text",
1507
+ text
1508
+ }],
1509
+ timestamp: Date.now()
1510
+ }
1511
+ });
1512
+ }
1513
+ emitChatFinal(runId, run, stopReason) {
1514
+ if (run.finalSent) return;
1515
+ run.finalSent = true;
1516
+ run.registered = true;
1517
+ const text = run.buffer.trim();
1518
+ const shouldIncludeMessage = Boolean(text) && !isSilentReplyText(text, "NO_REPLY") && !isSilentReplyLeadFragment(text);
1519
+ this.emit("chat", {
1520
+ runId,
1521
+ sessionKey: run.sessionKey,
1522
+ state: "final",
1523
+ ...stopReason ? { stopReason } : {},
1524
+ ...shouldIncludeMessage ? { message: {
1525
+ role: "assistant",
1526
+ content: [{
1527
+ type: "text",
1528
+ text
1529
+ }],
1530
+ timestamp: Date.now()
1531
+ } } : {}
1532
+ });
1533
+ }
1534
+ emitChatAborted(runId, run) {
1535
+ if (run.finalSent) return;
1536
+ run.finalSent = true;
1537
+ run.registered = true;
1538
+ this.emit("chat", {
1539
+ runId,
1540
+ sessionKey: run.sessionKey,
1541
+ state: "aborted"
1542
+ });
1543
+ }
1544
+ emitChatError(runId, run, errorMessage) {
1545
+ if (run.finalSent) return;
1546
+ run.finalSent = true;
1547
+ run.registered = true;
1548
+ this.emit("chat", {
1549
+ runId,
1550
+ sessionKey: run.sessionKey,
1551
+ state: "error",
1552
+ ...errorMessage ? { errorMessage } : {}
1553
+ });
1554
+ }
1555
+ ensureRunRegistered(runId, run) {
1556
+ if (run.registered || run.isBtw) return;
1557
+ run.registered = true;
1558
+ this.emit("chat", {
1559
+ runId,
1560
+ sessionKey: run.sessionKey,
1561
+ state: "delta",
1562
+ message: {
1563
+ role: "assistant",
1564
+ content: [{
1565
+ type: "text",
1566
+ text: ""
1567
+ }],
1568
+ timestamp: Date.now()
1569
+ }
1570
+ });
1571
+ }
1572
+ async handleAgentEvent(evt) {
1573
+ const run = this.runs.get(evt.runId);
1574
+ if (!run) return;
1575
+ if (evt.stream !== "assistant") this.ensureRunRegistered(evt.runId, run);
1576
+ this.emit("agent", {
1577
+ runId: evt.runId,
1578
+ stream: evt.stream,
1579
+ data: evt.data
1580
+ });
1581
+ if (evt.stream === "assistant" && !run.isBtw && typeof evt.data?.text === "string") {
1582
+ const nextText = stripInlineDirectiveTagsForDisplay(evt.data.text).text;
1583
+ const nextDelta = typeof evt.data?.delta === "string" ? stripInlineDirectiveTagsForDisplay(evt.data.delta).text : "";
1584
+ run.buffer = resolveMergedAssistantText({
1585
+ previousText: run.buffer,
1586
+ nextText,
1587
+ nextDelta
1588
+ });
1589
+ this.emitChatDelta(evt.runId, run);
1590
+ return;
1591
+ }
1592
+ if (evt.stream !== "lifecycle") return;
1593
+ const phase = typeof evt.data?.phase === "string" ? evt.data.phase : "";
1594
+ const aborted = evt.data?.aborted === true || run.controller.signal.aborted;
1595
+ if (phase === "end") {
1596
+ if (aborted) {
1597
+ this.emitChatAborted(evt.runId, run);
1598
+ return;
1599
+ }
1600
+ if (!run.isBtw) {
1601
+ const stopReason = typeof evt.data?.stopReason === "string" ? evt.data.stopReason : void 0;
1602
+ this.emitChatFinal(evt.runId, run, stopReason);
1603
+ }
1604
+ return;
1605
+ }
1606
+ if (phase === "error") {
1607
+ if (aborted) {
1608
+ this.emitChatAborted(evt.runId, run);
1609
+ return;
1610
+ }
1611
+ const errorMessage = typeof evt.data?.error === "string" ? evt.data.error : void 0;
1612
+ this.emitChatError(evt.runId, run, errorMessage);
1613
+ }
1614
+ }
1615
+ async runTurn(params) {
1616
+ try {
1617
+ const { cfg, canonicalKey, entry } = loadSessionEntry(params.sessionKey);
1618
+ const result = await agentCommandFromIngress({
1619
+ message: injectTimestamp(params.message, timestampOptsFromConfig(cfg)),
1620
+ sessionKey: canonicalKey,
1621
+ ...entry?.sessionId ? { sessionId: entry.sessionId } : {},
1622
+ thinking: params.thinking,
1623
+ deliver: params.deliver,
1624
+ channel: INTERNAL_MESSAGE_CHANNEL,
1625
+ runContext: { messageChannel: INTERNAL_MESSAGE_CHANNEL },
1626
+ timeout: timeoutSecondsFromMs(params.timeoutMs),
1627
+ runId: params.runId,
1628
+ abortSignal: params.controller.signal,
1629
+ senderIsOwner: true,
1630
+ allowModelOverride: false
1631
+ }, silentRuntime, this.deps);
1632
+ const run = this.runs.get(params.runId);
1633
+ if (!run) return;
1634
+ if (run.isBtw) {
1635
+ const text = payloadText(result?.payloads);
1636
+ if (run.question && text) this.emit("chat.side_result", {
1637
+ kind: "btw",
1638
+ runId: params.runId,
1639
+ sessionKey: run.sessionKey,
1640
+ question: run.question,
1641
+ text
1642
+ });
1643
+ this.emitChatFinal(params.runId, run);
1644
+ return;
1645
+ }
1646
+ if (!run.finalSent) {
1647
+ const normalizedText = payloadText(result?.payloads);
1648
+ if (normalizedText && !run.buffer) run.buffer = normalizedText;
1649
+ this.emitChatFinal(params.runId, run);
1650
+ }
1651
+ } catch (error) {
1652
+ const run = this.runs.get(params.runId);
1653
+ if (!run) return;
1654
+ if (params.controller.signal.aborted) {
1655
+ this.emitChatAborted(params.runId, run);
1656
+ return;
1657
+ }
1658
+ const errorMessage = error instanceof Error ? error.message : String(error);
1659
+ this.emitChatError(params.runId, run, errorMessage);
1660
+ } finally {
1661
+ this.runs.delete(params.runId);
1662
+ }
1663
+ }
1664
+ };
1665
+ //#endregion
1666
+ //#region src/tui/gateway-chat.ts
1667
+ const STARTUP_CHAT_HISTORY_RETRY_TIMEOUT_MS = 6e4;
1668
+ const STARTUP_CHAT_HISTORY_DEFAULT_RETRY_MS = 500;
1669
+ const STARTUP_CHAT_HISTORY_MAX_RETRY_MS = 5e3;
1670
+ function throwGatewayAuthResolutionError(reason) {
1671
+ throw new Error([
1672
+ reason,
1673
+ "Fix: set GENESIS_GATEWAY_TOKEN/GENESIS_GATEWAY_PASSWORD, pass --token/--password,",
1674
+ "or resolve the configured secret provider for this credential."
1675
+ ].join("\n"));
1676
+ }
1677
+ function isRetryableStartupUnavailable(err, method) {
1678
+ if (!(err instanceof GatewayClientRequestError)) return false;
1679
+ if (err.gatewayCode !== "UNAVAILABLE" || !err.retryable) return false;
1680
+ const details = err.details;
1681
+ if (!details || typeof details !== "object") return true;
1682
+ const detailMethod = details.method;
1683
+ return typeof detailMethod !== "string" || detailMethod === method;
1684
+ }
1685
+ function resolveStartupRetryDelayMs(err) {
1686
+ const retryAfterMs = typeof err.retryAfterMs === "number" ? err.retryAfterMs : STARTUP_CHAT_HISTORY_DEFAULT_RETRY_MS;
1687
+ return Math.min(Math.max(retryAfterMs, 100), STARTUP_CHAT_HISTORY_MAX_RETRY_MS);
1688
+ }
1689
+ function sleep(ms) {
1690
+ return new Promise((resolve) => setTimeout(resolve, ms));
1691
+ }
1692
+ var GatewayChatClient = class GatewayChatClient {
1693
+ constructor(connection) {
1694
+ this.connection = connection;
1695
+ this.readyPromise = new Promise((resolve) => {
1696
+ this.resolveReady = resolve;
1697
+ });
1698
+ this.client = new GatewayClient({
1699
+ url: connection.url,
1700
+ token: connection.token,
1701
+ password: connection.password,
1702
+ clientName: GATEWAY_CLIENT_NAMES.TUI,
1703
+ clientDisplayName: "genesis-tui",
1704
+ clientVersion: VERSION,
1705
+ platform: process.platform,
1706
+ mode: GATEWAY_CLIENT_MODES.UI,
1707
+ deviceIdentity: connection.allowInsecureLocalOperatorUi ? null : void 0,
1708
+ caps: [GATEWAY_CLIENT_CAPS.TOOL_EVENTS, GATEWAY_CLIENT_CAPS.CHAT_INCREMENTAL],
1709
+ instanceId: randomUUID(),
1710
+ minProtocol: 4,
1711
+ maxProtocol: 4,
1712
+ onHelloOk: (hello) => {
1713
+ this.hello = hello;
1714
+ this.resolveReady?.();
1715
+ this.onConnected?.();
1716
+ },
1717
+ onEvent: (evt) => {
1718
+ this.onEvent?.({
1719
+ event: evt.event,
1720
+ payload: evt.payload,
1721
+ seq: evt.seq
1722
+ });
1723
+ },
1724
+ onClose: (_code, reason) => {
1725
+ this.readyPromise = new Promise((resolve) => {
1726
+ this.resolveReady = resolve;
1727
+ });
1728
+ this.onDisconnected?.(reason);
1729
+ },
1730
+ onGap: (info) => {
1731
+ this.onGap?.(info);
1732
+ }
1733
+ });
1734
+ }
1735
+ static async connect(opts) {
1736
+ return new GatewayChatClient(await resolveGatewayConnection(opts));
1737
+ }
1738
+ start() {
1739
+ this.client.start();
1740
+ }
1741
+ stop() {
1742
+ this.client.stop();
1743
+ }
1744
+ async waitForReady() {
1745
+ await this.readyPromise;
1746
+ }
1747
+ async sendChat(opts) {
1748
+ const runId = opts.runId ?? randomUUID();
1749
+ await this.client.request("chat.send", {
1750
+ sessionKey: opts.sessionKey,
1751
+ message: opts.message,
1752
+ thinking: opts.thinking,
1753
+ deliver: opts.deliver,
1754
+ timeoutMs: opts.timeoutMs,
1755
+ idempotencyKey: runId
1756
+ });
1757
+ return { runId };
1758
+ }
1759
+ async abortChat(opts) {
1760
+ return await this.client.request("chat.abort", {
1761
+ sessionKey: opts.sessionKey,
1762
+ runId: opts.runId
1763
+ });
1764
+ }
1765
+ async loadHistory(opts) {
1766
+ const startedAt = Date.now();
1767
+ for (;;) try {
1768
+ return await this.client.request("chat.history", {
1769
+ sessionKey: opts.sessionKey,
1770
+ limit: opts.limit
1771
+ });
1772
+ } catch (err) {
1773
+ if (Date.now() - startedAt < STARTUP_CHAT_HISTORY_RETRY_TIMEOUT_MS && isRetryableStartupUnavailable(err, "chat.history")) {
1774
+ await sleep(resolveStartupRetryDelayMs(err));
1775
+ continue;
1776
+ }
1777
+ throw err;
1778
+ }
1779
+ }
1780
+ async listSessions(opts) {
1781
+ return await this.client.request("sessions.list", {
1782
+ limit: opts?.limit,
1783
+ activeMinutes: opts?.activeMinutes,
1784
+ includeGlobal: opts?.includeGlobal,
1785
+ includeUnknown: opts?.includeUnknown,
1786
+ includeDerivedTitles: opts?.includeDerivedTitles,
1787
+ includeLastMessage: opts?.includeLastMessage,
1788
+ agentId: opts?.agentId
1789
+ });
1790
+ }
1791
+ async listAgents() {
1792
+ return await this.client.request("agents.list", {});
1793
+ }
1794
+ async patchSession(opts) {
1795
+ return await this.client.request("sessions.patch", opts);
1796
+ }
1797
+ async resetSession(key, reason) {
1798
+ return await this.client.request("sessions.reset", {
1799
+ key,
1800
+ ...reason ? { reason } : {}
1801
+ });
1802
+ }
1803
+ async getGatewayStatus() {
1804
+ return await this.client.request("status");
1805
+ }
1806
+ async listModels() {
1807
+ const res = await this.client.request("models.list");
1808
+ return Array.isArray(res?.models) ? res.models : [];
1809
+ }
1810
+ };
1811
+ async function resolveGatewayConnection(opts) {
1812
+ const config = loadConfig();
1813
+ const env = process.env;
1814
+ const gatewayAuthMode = config.gateway?.auth?.mode;
1815
+ const isRemoteMode = config.gateway?.mode === "remote";
1816
+ const preferConfiguredAuth = env[TUI_SETUP_AUTH_SOURCE_ENV] === TUI_SETUP_AUTH_SOURCE_CONFIG;
1817
+ const urlOverride = typeof opts.url === "string" && opts.url.trim().length > 0 ? opts.url.trim() : void 0;
1818
+ const explicitAuth = resolveExplicitGatewayAuth({
1819
+ token: opts.token,
1820
+ password: opts.password
1821
+ });
1822
+ ensureExplicitGatewayAuth({
1823
+ urlOverride,
1824
+ urlOverrideSource: "cli",
1825
+ explicitAuth,
1826
+ errorHint: "Fix: pass --token or --password when using --url."
1827
+ });
1828
+ const url = buildGatewayConnectionDetails({
1829
+ config,
1830
+ ...urlOverride ? { url: urlOverride } : {}
1831
+ }).url;
1832
+ const allowInsecureLocalOperatorUi = (() => {
1833
+ if (config.gateway?.controlUi?.allowInsecureAuth !== true) return false;
1834
+ try {
1835
+ return isLoopbackHost(new URL(url).hostname);
1836
+ } catch {
1837
+ return false;
1838
+ }
1839
+ })();
1840
+ if (urlOverride) return {
1841
+ url,
1842
+ token: explicitAuth.token,
1843
+ password: explicitAuth.password,
1844
+ allowInsecureLocalOperatorUi
1845
+ };
1846
+ if (isRemoteMode) {
1847
+ const resolved = await resolveGatewayInteractiveSurfaceAuth({
1848
+ config,
1849
+ env,
1850
+ explicitAuth,
1851
+ surface: "remote"
1852
+ });
1853
+ if (resolved.failureReason) throwGatewayAuthResolutionError(resolved.failureReason);
1854
+ return {
1855
+ url,
1856
+ token: resolved.token,
1857
+ password: resolved.password,
1858
+ allowInsecureLocalOperatorUi: false
1859
+ };
1860
+ }
1861
+ if (gatewayAuthMode === "none" || gatewayAuthMode === "trusted-proxy") {
1862
+ const resolved = await resolveGatewayInteractiveSurfaceAuth({
1863
+ config,
1864
+ env,
1865
+ explicitAuth,
1866
+ surface: "local"
1867
+ });
1868
+ return {
1869
+ url,
1870
+ token: resolved.token,
1871
+ password: resolved.password,
1872
+ allowInsecureLocalOperatorUi
1873
+ };
1874
+ }
1875
+ try {
1876
+ assertExplicitGatewayAuthModeWhenBothConfigured(config);
1877
+ } catch (err) {
1878
+ throwGatewayAuthResolutionError(formatErrorMessage(err));
1879
+ }
1880
+ const resolved = await resolveGatewayInteractiveSurfaceAuth({
1881
+ config,
1882
+ env,
1883
+ explicitAuth,
1884
+ suppressEnvAuthFallback: preferConfiguredAuth,
1885
+ surface: "local"
1886
+ });
1887
+ if (resolved.failureReason) throwGatewayAuthResolutionError(resolved.failureReason);
1888
+ return {
1889
+ url,
1890
+ token: resolved.token,
1891
+ password: resolved.password,
1892
+ allowInsecureLocalOperatorUi
1893
+ };
1894
+ }
1895
+ //#endregion
1896
+ //#region src/tui/components/fuzzy-filter.ts
1897
+ /**
1898
+ * Shared fuzzy filtering utilities for select list components.
1899
+ */
1900
+ /**
1901
+ * Word boundary characters for matching.
1902
+ */
1903
+ const WORD_BOUNDARY_CHARS = /[\s\-_./:#@]/;
1904
+ /**
1905
+ * Check if position is at a word boundary.
1906
+ */
1907
+ function isWordBoundary(text, index) {
1908
+ return index === 0 || WORD_BOUNDARY_CHARS.test(text[index - 1] ?? "");
1909
+ }
1910
+ /**
1911
+ * Find index where query matches at a word boundary in text.
1912
+ * Returns null if no match.
1913
+ */
1914
+ function findWordBoundaryIndex(text, query) {
1915
+ if (!query) return null;
1916
+ const textLower = normalizeLowercaseStringOrEmpty(text);
1917
+ const queryLower = normalizeLowercaseStringOrEmpty(query);
1918
+ const maxIndex = textLower.length - queryLower.length;
1919
+ if (maxIndex < 0) return null;
1920
+ for (let i = 0; i <= maxIndex; i++) if (textLower.startsWith(queryLower, i) && isWordBoundary(textLower, i)) return i;
1921
+ return null;
1922
+ }
1923
+ /**
1924
+ * Fuzzy match with pre-lowercased inputs (avoids toLowerCase on every keystroke).
1925
+ * Returns score (lower = better) or null if no match.
1926
+ */
1927
+ function fuzzyMatchLower(queryLower, textLower) {
1928
+ if (queryLower.length === 0) return 0;
1929
+ if (queryLower.length > textLower.length) return null;
1930
+ let queryIndex = 0;
1931
+ let score = 0;
1932
+ let lastMatchIndex = -1;
1933
+ let consecutiveMatches = 0;
1934
+ for (let i = 0; i < textLower.length && queryIndex < queryLower.length; i++) if (textLower[i] === queryLower[queryIndex]) {
1935
+ const isAtWordBoundary = isWordBoundary(textLower, i);
1936
+ if (lastMatchIndex === i - 1) {
1937
+ consecutiveMatches++;
1938
+ score -= consecutiveMatches * 5;
1939
+ } else {
1940
+ consecutiveMatches = 0;
1941
+ if (lastMatchIndex >= 0) score += (i - lastMatchIndex - 1) * 2;
1942
+ }
1943
+ if (isAtWordBoundary) score -= 10;
1944
+ score += i * .1;
1945
+ lastMatchIndex = i;
1946
+ queryIndex++;
1947
+ }
1948
+ return queryIndex < queryLower.length ? null : score;
1949
+ }
1950
+ /**
1951
+ * Filter items using pre-lowercased searchTextLower field.
1952
+ * Supports space-separated tokens (all must match).
1953
+ */
1954
+ function fuzzyFilterLower(items, queryLower) {
1955
+ const trimmed = queryLower.trim();
1956
+ if (!trimmed) return items;
1957
+ const tokens = trimmed.split(/\s+/).filter((t) => t.length > 0);
1958
+ if (tokens.length === 0) return items;
1959
+ const results = [];
1960
+ for (const item of items) {
1961
+ const text = item.searchTextLower ?? "";
1962
+ let totalScore = 0;
1963
+ let allMatch = true;
1964
+ for (const token of tokens) {
1965
+ const score = fuzzyMatchLower(token, text);
1966
+ if (score !== null) totalScore += score;
1967
+ else {
1968
+ allMatch = false;
1969
+ break;
1970
+ }
1971
+ }
1972
+ if (allMatch) results.push({
1973
+ item,
1974
+ score: totalScore
1975
+ });
1976
+ }
1977
+ results.sort((a, b) => a.score - b.score);
1978
+ return results.map((r) => r.item);
1979
+ }
1980
+ /**
1981
+ * Prepare items for fuzzy filtering by pre-computing lowercase search text.
1982
+ */
1983
+ function prepareSearchItems(items) {
1984
+ return items.map((item) => {
1985
+ const parts = [];
1986
+ if (item.label) parts.push(item.label);
1987
+ if (item.description) parts.push(item.description);
1988
+ if (item.searchText) parts.push(item.searchText);
1989
+ return {
1990
+ ...item,
1991
+ searchTextLower: normalizeLowercaseStringOrEmpty(parts.join(" "))
1992
+ };
1993
+ });
1994
+ }
1995
+ //#endregion
1996
+ //#region src/tui/components/filterable-select-list.ts
1997
+ /**
1998
+ * Combines text input filtering with a select list.
1999
+ * User types to filter, arrows/j/k to navigate, Enter to select, Escape to clear/cancel.
2000
+ */
2001
+ var FilterableSelectList = class {
2002
+ constructor(items, maxVisible, theme) {
2003
+ this.filterText = "";
2004
+ this.allItems = prepareSearchItems(items);
2005
+ this.maxVisible = maxVisible;
2006
+ this.theme = theme;
2007
+ this.input = new Input();
2008
+ this.selectList = new SelectList(this.allItems, maxVisible, theme);
2009
+ }
2010
+ applyFilter() {
2011
+ const queryLower = normalizeLowercaseStringOrEmpty(this.filterText);
2012
+ if (!queryLower.trim()) {
2013
+ this.selectList = new SelectList(this.allItems, this.maxVisible, this.theme);
2014
+ return;
2015
+ }
2016
+ const filtered = fuzzyFilterLower(this.allItems, queryLower);
2017
+ this.selectList = new SelectList(filtered, this.maxVisible, this.theme);
2018
+ }
2019
+ invalidate() {
2020
+ this.input.invalidate();
2021
+ this.selectList.invalidate();
2022
+ }
2023
+ render(width) {
2024
+ const lines = [];
2025
+ const filterLabel = this.theme.filterLabel("Filter: ");
2026
+ const inputText = this.input.render(width - 8)[0] ?? "";
2027
+ lines.push(filterLabel + inputText);
2028
+ lines.push(chalk.dim("─".repeat(Math.max(0, width))));
2029
+ const listLines = this.selectList.render(width);
2030
+ lines.push(...listLines);
2031
+ return lines;
2032
+ }
2033
+ handleInput(keyData) {
2034
+ const allowVimNav = !this.filterText.trim();
2035
+ if (matchesKey(keyData, "up") || matchesKey(keyData, "ctrl+p") || allowVimNav && keyData === "k") {
2036
+ this.selectList.handleInput("\x1B[A");
2037
+ return;
2038
+ }
2039
+ if (matchesKey(keyData, "down") || matchesKey(keyData, "ctrl+n") || allowVimNav && keyData === "j") {
2040
+ this.selectList.handleInput("\x1B[B");
2041
+ return;
2042
+ }
2043
+ if (matchesKey(keyData, "enter")) {
2044
+ const selected = this.selectList.getSelectedItem();
2045
+ if (selected) this.onSelect?.(selected);
2046
+ return;
2047
+ }
2048
+ if (matchesKey(keyData, "escape") || keyData === "") {
2049
+ if (this.filterText) {
2050
+ this.filterText = "";
2051
+ this.input.setValue("");
2052
+ this.applyFilter();
2053
+ } else this.onCancel?.();
2054
+ return;
2055
+ }
2056
+ const prevValue = this.input.getValue();
2057
+ this.input.handleInput(keyData);
2058
+ const newValue = this.input.getValue();
2059
+ if (newValue !== prevValue) {
2060
+ this.filterText = newValue;
2061
+ this.applyFilter();
2062
+ }
2063
+ }
2064
+ getSelectedItem() {
2065
+ return this.selectList.getSelectedItem();
2066
+ }
2067
+ getFilterText() {
2068
+ return this.filterText;
2069
+ }
2070
+ };
2071
+ //#endregion
2072
+ //#region src/tui/components/searchable-select-list.ts
2073
+ const ANSI_SGR_REGEX = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g");
2074
+ /**
2075
+ * A select list with a search input at the top for fuzzy filtering.
2076
+ */
2077
+ var SearchableSelectList = class SearchableSelectList {
2078
+ static {
2079
+ this.DESCRIPTION_LAYOUT_MIN_WIDTH = 40;
2080
+ }
2081
+ static {
2082
+ this.DESCRIPTION_MIN_WIDTH = 12;
2083
+ }
2084
+ static {
2085
+ this.DESCRIPTION_SPACING_WIDTH = 2;
2086
+ }
2087
+ static {
2088
+ this.RIGHT_MARGIN_WIDTH = 2;
2089
+ }
2090
+ constructor(items, maxVisible, theme) {
2091
+ this.selectedIndex = 0;
2092
+ this.regexCache = /* @__PURE__ */ new Map();
2093
+ this.compareByScore = (a, b) => {
2094
+ if (a.tier !== b.tier) return a.tier - b.tier;
2095
+ if (a.score !== b.score) return a.score - b.score;
2096
+ return this.getItemLabel(a.item).localeCompare(this.getItemLabel(b.item));
2097
+ };
2098
+ this.items = items;
2099
+ this.filteredItems = items;
2100
+ this.maxVisible = maxVisible;
2101
+ this.theme = theme;
2102
+ this.searchInput = new Input();
2103
+ }
2104
+ getCachedRegex(pattern) {
2105
+ let regex = this.regexCache.get(pattern);
2106
+ if (!regex) {
2107
+ regex = new RegExp(this.escapeRegex(pattern), "gi");
2108
+ this.regexCache.set(pattern, regex);
2109
+ }
2110
+ return regex;
2111
+ }
2112
+ updateFilter() {
2113
+ const query = this.searchInput.getValue().trim();
2114
+ if (!query) this.filteredItems = this.items;
2115
+ else this.filteredItems = this.smartFilter(query);
2116
+ this.selectedIndex = 0;
2117
+ this.notifySelectionChange();
2118
+ }
2119
+ /**
2120
+ * Smart filtering that prioritizes:
2121
+ * 1. Exact substring match in label (highest priority)
2122
+ * 2. Word-boundary prefix match in label
2123
+ * 3. Exact substring in description
2124
+ * 4. Fuzzy match (lowest priority)
2125
+ */
2126
+ smartFilter(query) {
2127
+ const q = normalizeLowercaseStringOrEmpty(query);
2128
+ const scoredItems = [];
2129
+ const fuzzyCandidates = [];
2130
+ for (const item of this.items) {
2131
+ const rawLabel = this.getItemLabel(item);
2132
+ const rawDesc = item.description ?? "";
2133
+ const label = normalizeLowercaseStringOrEmpty(stripAnsi$1(rawLabel));
2134
+ const desc = normalizeLowercaseStringOrEmpty(stripAnsi$1(rawDesc));
2135
+ const labelIndex = label.indexOf(q);
2136
+ if (labelIndex !== -1) {
2137
+ scoredItems.push({
2138
+ item,
2139
+ tier: 0,
2140
+ score: labelIndex
2141
+ });
2142
+ continue;
2143
+ }
2144
+ const wordBoundaryIndex = findWordBoundaryIndex(label, q);
2145
+ if (wordBoundaryIndex !== null) {
2146
+ scoredItems.push({
2147
+ item,
2148
+ tier: 1,
2149
+ score: wordBoundaryIndex
2150
+ });
2151
+ continue;
2152
+ }
2153
+ const descIndex = desc.indexOf(q);
2154
+ if (descIndex !== -1) {
2155
+ scoredItems.push({
2156
+ item,
2157
+ tier: 2,
2158
+ score: descIndex
2159
+ });
2160
+ continue;
2161
+ }
2162
+ const searchText = item.searchText ?? "";
2163
+ fuzzyCandidates.push({
2164
+ item,
2165
+ searchTextLower: normalizeLowercaseStringOrEmpty([
2166
+ rawLabel,
2167
+ rawDesc,
2168
+ searchText
2169
+ ].map((value) => stripAnsi$1(value)).filter(Boolean).join(" "))
2170
+ });
2171
+ }
2172
+ scoredItems.sort(this.compareByScore);
2173
+ const fuzzyMatches = fuzzyFilterLower(fuzzyCandidates, q);
2174
+ return [...scoredItems.map((s) => s.item), ...fuzzyMatches.map((entry) => entry.item)];
2175
+ }
2176
+ escapeRegex(str) {
2177
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2178
+ }
2179
+ getItemLabel(item) {
2180
+ return item.label || item.value;
2181
+ }
2182
+ splitAnsiParts(text) {
2183
+ const parts = [];
2184
+ ANSI_SGR_REGEX.lastIndex = 0;
2185
+ let lastIndex = 0;
2186
+ let match;
2187
+ while ((match = ANSI_SGR_REGEX.exec(text)) !== null) {
2188
+ if (match.index > lastIndex) parts.push({
2189
+ text: text.slice(lastIndex, match.index),
2190
+ isAnsi: false
2191
+ });
2192
+ parts.push({
2193
+ text: match[0],
2194
+ isAnsi: true
2195
+ });
2196
+ lastIndex = match.index + match[0].length;
2197
+ }
2198
+ if (lastIndex < text.length) parts.push({
2199
+ text: text.slice(lastIndex),
2200
+ isAnsi: false
2201
+ });
2202
+ return parts;
2203
+ }
2204
+ highlightMatch(text, query) {
2205
+ const tokens = query.trim().split(/\s+/).map((token) => normalizeLowercaseStringOrEmpty(token)).filter((token) => token.length > 0);
2206
+ if (tokens.length === 0) return text;
2207
+ const uniqueTokens = Array.from(new Set(tokens)).toSorted((a, b) => b.length - a.length);
2208
+ let parts = this.splitAnsiParts(text);
2209
+ for (const token of uniqueTokens) {
2210
+ const regex = this.getCachedRegex(token);
2211
+ const nextParts = [];
2212
+ for (const part of parts) {
2213
+ if (part.isAnsi) {
2214
+ nextParts.push(part);
2215
+ continue;
2216
+ }
2217
+ regex.lastIndex = 0;
2218
+ const replaced = part.text.replace(regex, (match) => this.theme.matchHighlight(match));
2219
+ if (replaced === part.text) {
2220
+ nextParts.push(part);
2221
+ continue;
2222
+ }
2223
+ nextParts.push(...this.splitAnsiParts(replaced));
2224
+ }
2225
+ parts = nextParts;
2226
+ }
2227
+ return parts.map((part) => part.text).join("");
2228
+ }
2229
+ setSelectedIndex(index) {
2230
+ this.selectedIndex = Math.max(0, Math.min(index, this.filteredItems.length - 1));
2231
+ }
2232
+ invalidate() {
2233
+ this.searchInput.invalidate();
2234
+ }
2235
+ render(width) {
2236
+ const lines = [];
2237
+ const prompt = this.theme.searchPrompt("search: ");
2238
+ const inputWidth = Math.max(1, width - visibleWidth(prompt));
2239
+ const inputText = this.searchInput.render(inputWidth)[0] ?? "";
2240
+ lines.push(`${prompt}${this.theme.searchInput(inputText)}`);
2241
+ lines.push("");
2242
+ const query = this.searchInput.getValue().trim();
2243
+ if (this.filteredItems.length === 0) {
2244
+ lines.push(this.theme.noMatch(" No matches"));
2245
+ return lines;
2246
+ }
2247
+ const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(this.maxVisible / 2), this.filteredItems.length - this.maxVisible));
2248
+ const endIndex = Math.min(startIndex + this.maxVisible, this.filteredItems.length);
2249
+ for (let i = startIndex; i < endIndex; i++) {
2250
+ const item = this.filteredItems[i];
2251
+ if (!item) continue;
2252
+ const isSelected = i === this.selectedIndex;
2253
+ lines.push(this.renderItemLine(item, isSelected, width, query));
2254
+ }
2255
+ if (this.filteredItems.length > this.maxVisible) {
2256
+ const scrollInfo = `${this.selectedIndex + 1}/${this.filteredItems.length}`;
2257
+ lines.push(this.theme.scrollInfo(` ${scrollInfo}`));
2258
+ }
2259
+ return lines;
2260
+ }
2261
+ renderItemLine(item, isSelected, width, query) {
2262
+ const prefix = isSelected ? "→ " : " ";
2263
+ const prefixWidth = prefix.length;
2264
+ const displayValue = this.getItemLabel(item);
2265
+ const description = item.description;
2266
+ if (description) {
2267
+ const descriptionLayout = this.getDescriptionLayout(width, prefixWidth);
2268
+ if (descriptionLayout) {
2269
+ const truncatedValue = truncateToWidth(displayValue, descriptionLayout.maxValueWidth, "");
2270
+ const valueText = this.highlightMatch(truncatedValue, query);
2271
+ const usedByValue = visibleWidth(valueText);
2272
+ const descriptionWidth = descriptionLayout.availableWidth - usedByValue - descriptionLayout.spacingWidth;
2273
+ if (descriptionWidth >= SearchableSelectList.DESCRIPTION_MIN_WIDTH) {
2274
+ const spacing = " ".repeat(descriptionLayout.spacingWidth);
2275
+ const truncatedDesc = truncateToWidth(description, descriptionWidth, "");
2276
+ const highlightedDesc = this.highlightMatch(truncatedDesc, query);
2277
+ const line = `${prefix}${valueText}${spacing}${isSelected ? highlightedDesc : this.theme.description(highlightedDesc)}`;
2278
+ return isSelected ? this.theme.selectedText(line) : line;
2279
+ }
2280
+ }
2281
+ }
2282
+ const truncatedValue = truncateToWidth(displayValue, width - prefixWidth - 2, "");
2283
+ const line = `${prefix}${this.highlightMatch(truncatedValue, query)}`;
2284
+ return isSelected ? this.theme.selectedText(line) : line;
2285
+ }
2286
+ getDescriptionLayout(width, prefixWidth) {
2287
+ if (width <= SearchableSelectList.DESCRIPTION_LAYOUT_MIN_WIDTH) return null;
2288
+ const availableWidth = Math.max(1, width - prefixWidth - SearchableSelectList.RIGHT_MARGIN_WIDTH);
2289
+ const maxValueWidth = availableWidth - SearchableSelectList.DESCRIPTION_MIN_WIDTH - SearchableSelectList.DESCRIPTION_SPACING_WIDTH;
2290
+ if (maxValueWidth < 1) return null;
2291
+ return {
2292
+ availableWidth,
2293
+ maxValueWidth,
2294
+ spacingWidth: SearchableSelectList.DESCRIPTION_SPACING_WIDTH
2295
+ };
2296
+ }
2297
+ handleInput(keyData) {
2298
+ if (isKeyRelease(keyData)) return;
2299
+ if (matchesKey(keyData, "up") || matchesKey(keyData, "ctrl+p")) {
2300
+ this.selectedIndex = Math.max(0, this.selectedIndex - 1);
2301
+ this.notifySelectionChange();
2302
+ return;
2303
+ }
2304
+ if (matchesKey(keyData, "down") || matchesKey(keyData, "ctrl+n")) {
2305
+ this.selectedIndex = Math.min(this.filteredItems.length - 1, this.selectedIndex + 1);
2306
+ this.notifySelectionChange();
2307
+ return;
2308
+ }
2309
+ if (matchesKey(keyData, "enter")) {
2310
+ const item = this.filteredItems[this.selectedIndex];
2311
+ if (item && this.onSelect) this.onSelect(item);
2312
+ return;
2313
+ }
2314
+ if (matchesKey(keyData, "escape") || keyData === "") {
2315
+ if (this.onCancel) this.onCancel();
2316
+ return;
2317
+ }
2318
+ const prevValue = this.searchInput.getValue();
2319
+ this.searchInput.handleInput(keyData);
2320
+ if (prevValue !== this.searchInput.getValue()) this.updateFilter();
2321
+ }
2322
+ notifySelectionChange() {
2323
+ const item = this.filteredItems[this.selectedIndex];
2324
+ if (item && this.onSelectionChange) this.onSelectionChange(item);
2325
+ }
2326
+ getSelectedItem() {
2327
+ return this.filteredItems[this.selectedIndex] ?? null;
2328
+ }
2329
+ };
2330
+ //#endregion
2331
+ //#region src/tui/components/selectors.ts
2332
+ function createSearchableSelectList(items, maxVisible = 7) {
2333
+ return new SearchableSelectList(items, maxVisible, searchableSelectListTheme);
2334
+ }
2335
+ function createFilterableSelectList(items, maxVisible = 7) {
2336
+ return new FilterableSelectList(items, maxVisible, filterableSelectListTheme);
2337
+ }
2338
+ function createSettingsList(items, onChange, onCancel, maxVisible = 7) {
2339
+ return new SettingsList(items, maxVisible, settingsListTheme, onChange, onCancel);
2340
+ }
2341
+ //#endregion
2342
+ //#region src/tui/tui-status-summary.ts
2343
+ function formatStatusSummary(summary) {
2344
+ const lines = [];
2345
+ lines.push("Gateway status");
2346
+ if (summary.runtimeVersion) lines.push(`Version: ${summary.runtimeVersion}`);
2347
+ if (!summary.linkChannel) lines.push("Link channel: unknown");
2348
+ else {
2349
+ const linkLabel = summary.linkChannel.label ?? "Link channel";
2350
+ const linked = summary.linkChannel.linked === true;
2351
+ const authAge = linked && typeof summary.linkChannel.authAgeMs === "number" ? ` (last refreshed ${formatTimeAgo(summary.linkChannel.authAgeMs)})` : "";
2352
+ lines.push(`${linkLabel}: ${linked ? "linked" : "not linked"}${authAge}`);
2353
+ }
2354
+ const providerSummary = Array.isArray(summary.providerSummary) ? summary.providerSummary : [];
2355
+ if (providerSummary.length > 0) {
2356
+ lines.push("");
2357
+ lines.push("System:");
2358
+ for (const line of providerSummary) lines.push(` ${line}`);
2359
+ }
2360
+ const sessionPaths = summary.sessions?.paths ?? [];
2361
+ if (sessionPaths.length === 1) lines.push(`Session store: ${sessionPaths[0]}`);
2362
+ else if (sessionPaths.length > 1) lines.push(`Session stores: ${sessionPaths.length}`);
2363
+ const defaults = summary.sessions?.defaults;
2364
+ const defaultModel = defaults?.model ?? "unknown";
2365
+ const defaultCtx = typeof defaults?.contextTokens === "number" ? ` (${formatTokenCount(defaults.contextTokens)} ctx)` : "";
2366
+ lines.push(`Default model: ${defaultModel}${defaultCtx}`);
2367
+ const sessionCount = summary.sessions?.count ?? 0;
2368
+ lines.push(`Active sessions: ${sessionCount}`);
2369
+ const recent = Array.isArray(summary.sessions?.recent) ? summary.sessions?.recent : [];
2370
+ if (recent.length > 0) {
2371
+ lines.push("Recent sessions:");
2372
+ for (const entry of recent) {
2373
+ const ageLabel = typeof entry.age === "number" ? formatTimeAgo(entry.age) : "no activity";
2374
+ const model = entry.model ?? "unknown";
2375
+ const usage = formatContextUsageLine({
2376
+ total: entry.totalTokens ?? null,
2377
+ context: entry.contextTokens ?? null,
2378
+ remaining: entry.remainingTokens ?? null,
2379
+ percent: entry.percentUsed ?? null
2380
+ });
2381
+ const flags = entry.flags?.length ? ` | flags: ${entry.flags.join(", ")}` : "";
2382
+ lines.push(`- ${entry.key}${entry.kind ? ` [${entry.kind}]` : ""} | ${ageLabel} | model ${model} | ${usage}${flags}`);
2383
+ }
2384
+ }
2385
+ const queued = Array.isArray(summary.queuedSystemEvents) ? summary.queuedSystemEvents : [];
2386
+ if (queued.length > 0) {
2387
+ const preview = queued.slice(0, 3).join(" | ");
2388
+ lines.push(`Queued system events (${queued.length}): ${preview}`);
2389
+ }
2390
+ return lines;
2391
+ }
2392
+ //#endregion
2393
+ //#region src/tui/tui-command-handlers.ts
2394
+ function isBtwCommand(text) {
2395
+ return /^\/btw(?::|\s|$)/i.test(text.trim());
2396
+ }
2397
+ function createCommandHandlers(context) {
2398
+ const { client, chatLog, tui, opts, state, deliverDefault, openOverlay, closeOverlay, refreshSessionInfo, loadHistory, setSession, refreshAgents, abortActive, setActivityStatus, formatSessionKey, applySessionInfoFromPatch, noteLocalBtwRunId, forgetLocalRunId, forgetLocalBtwRunId, runAuthFlow, requestExit } = context;
2399
+ const setAgent = async (id) => {
2400
+ state.currentAgentId = normalizeAgentId(id);
2401
+ await setSession("");
2402
+ };
2403
+ const closeOverlayAndRender = () => {
2404
+ closeOverlay();
2405
+ tui.requestRender();
2406
+ };
2407
+ const openSelector = (selector, onSelect) => {
2408
+ selector.onSelect = (item) => {
2409
+ (async () => {
2410
+ await onSelect(item.value);
2411
+ closeOverlayAndRender();
2412
+ })();
2413
+ };
2414
+ selector.onCancel = closeOverlayAndRender;
2415
+ openOverlay(selector);
2416
+ tui.requestRender();
2417
+ };
2418
+ const openModelSelector = async () => {
2419
+ try {
2420
+ const models = await client.listModels();
2421
+ if (models.length === 0) {
2422
+ chatLog.addSystem("no models available");
2423
+ tui.requestRender();
2424
+ return;
2425
+ }
2426
+ openSelector(createSearchableSelectList(models.map((model) => ({
2427
+ value: `${model.provider}/${model.id}`,
2428
+ label: `${model.provider}/${model.id}`,
2429
+ description: model.name && model.name !== model.id ? model.name : ""
2430
+ })), 9), async (value) => {
2431
+ try {
2432
+ const result = await client.patchSession({
2433
+ key: state.currentSessionKey,
2434
+ model: value
2435
+ });
2436
+ chatLog.addSystem(`model set to ${value}`);
2437
+ applySessionInfoFromPatch(result);
2438
+ await refreshSessionInfo();
2439
+ } catch (err) {
2440
+ chatLog.addSystem(`model set failed: ${String(err)}`);
2441
+ }
2442
+ });
2443
+ } catch (err) {
2444
+ chatLog.addSystem(`model list failed: ${String(err)}`);
2445
+ tui.requestRender();
2446
+ }
2447
+ };
2448
+ const openAgentSelector = async () => {
2449
+ await refreshAgents();
2450
+ if (state.agents.length === 0) {
2451
+ chatLog.addSystem("no agents found");
2452
+ tui.requestRender();
2453
+ return;
2454
+ }
2455
+ openSelector(createSearchableSelectList(state.agents.map((agent) => ({
2456
+ value: agent.id,
2457
+ label: agent.name ? `${agent.id} (${agent.name})` : agent.id,
2458
+ description: agent.id === state.agentDefaultId ? "default" : ""
2459
+ })), 9), async (value) => {
2460
+ await setAgent(value);
2461
+ });
2462
+ };
2463
+ const openSessionSelector = async () => {
2464
+ try {
2465
+ openSelector(createFilterableSelectList((await client.listSessions({
2466
+ includeGlobal: false,
2467
+ includeUnknown: false,
2468
+ includeDerivedTitles: true,
2469
+ includeLastMessage: true,
2470
+ agentId: state.currentAgentId
2471
+ })).sessions.map((session) => {
2472
+ const title = session.derivedTitle ?? session.displayName;
2473
+ const formattedKey = formatSessionKey(session.key);
2474
+ const label = title && title !== formattedKey ? `${title} (${formattedKey})` : formattedKey;
2475
+ const timePart = session.updatedAt ? formatRelativeTimestamp(session.updatedAt, {
2476
+ dateFallback: true,
2477
+ fallback: ""
2478
+ }) : "";
2479
+ const preview = session.lastMessagePreview?.replace(/\s+/g, " ").trim();
2480
+ const description = timePart && preview ? `${timePart} · ${preview}` : preview ?? timePart;
2481
+ return {
2482
+ value: session.key,
2483
+ label,
2484
+ description,
2485
+ searchText: [
2486
+ session.displayName,
2487
+ session.label,
2488
+ session.subject,
2489
+ session.sessionId,
2490
+ session.key,
2491
+ session.lastMessagePreview
2492
+ ].filter(Boolean).join(" ")
2493
+ };
2494
+ }), 9), async (value) => {
2495
+ await setSession(value);
2496
+ });
2497
+ } catch (err) {
2498
+ chatLog.addSystem(`sessions list failed: ${String(err)}`);
2499
+ tui.requestRender();
2500
+ }
2501
+ };
2502
+ const openSettings = () => {
2503
+ openOverlay(createSettingsList([{
2504
+ id: "tools",
2505
+ label: "Tool output",
2506
+ currentValue: state.toolsExpanded ? "expanded" : "collapsed",
2507
+ values: ["collapsed", "expanded"]
2508
+ }, {
2509
+ id: "thinking",
2510
+ label: "Show thinking",
2511
+ currentValue: state.showThinking ? "on" : "off",
2512
+ values: ["off", "on"]
2513
+ }], (id, value) => {
2514
+ if (id === "tools") {
2515
+ state.toolsExpanded = value === "expanded";
2516
+ chatLog.setToolsExpanded(state.toolsExpanded);
2517
+ }
2518
+ if (id === "thinking") {
2519
+ state.showThinking = value === "on";
2520
+ loadHistory();
2521
+ }
2522
+ tui.requestRender();
2523
+ }, () => {
2524
+ closeOverlay();
2525
+ tui.requestRender();
2526
+ }));
2527
+ tui.requestRender();
2528
+ };
2529
+ const handleCommand = async (raw) => {
2530
+ const { name, args } = parseCommand(raw);
2531
+ if (!name) return;
2532
+ switch (name) {
2533
+ case "help":
2534
+ chatLog.addSystem(helpText({
2535
+ local: opts.local,
2536
+ provider: state.sessionInfo.modelProvider,
2537
+ model: state.sessionInfo.model
2538
+ }));
2539
+ break;
2540
+ case "auth": {
2541
+ if (!runAuthFlow) {
2542
+ chatLog.addSystem("auth login is only available in local embedded mode");
2543
+ break;
2544
+ }
2545
+ if (state.activeChatRunId || state.pendingOptimisticUserMessage) {
2546
+ chatLog.addSystem("abort the current run before /auth");
2547
+ break;
2548
+ }
2549
+ const provider = args.trim() || state.sessionInfo.modelProvider || void 0;
2550
+ chatLog.addSystem(provider ? `opening auth flow for ${provider}; TUI will resume when it exits` : "opening auth flow; TUI will resume when it exits");
2551
+ tui.requestRender();
2552
+ setActivityStatus("auth");
2553
+ try {
2554
+ const result = await runAuthFlow({ provider });
2555
+ await refreshSessionInfo();
2556
+ if (result.exitCode === 0 && !result.signal) {
2557
+ chatLog.addSystem(provider ? `auth flow finished for ${provider}` : "auth flow finished");
2558
+ setActivityStatus("idle");
2559
+ } else {
2560
+ const failureSuffix = result.signal ? ` (signal ${result.signal})` : typeof result.exitCode === "number" ? ` (exit ${String(result.exitCode)})` : "";
2561
+ chatLog.addSystem(`auth flow failed${failureSuffix}`);
2562
+ setActivityStatus("error");
2563
+ }
2564
+ } catch (err) {
2565
+ chatLog.addSystem(`auth flow failed: ${sanitizeRenderableText(String(err))}`);
2566
+ setActivityStatus("error");
2567
+ }
2568
+ break;
2569
+ }
2570
+ case "gateway-status":
2571
+ try {
2572
+ const status = await client.getGatewayStatus();
2573
+ if (typeof status === "string") {
2574
+ chatLog.addSystem(status);
2575
+ break;
2576
+ }
2577
+ if (status && typeof status === "object") {
2578
+ const lines = formatStatusSummary(status);
2579
+ for (const line of lines) chatLog.addSystem(line);
2580
+ break;
2581
+ }
2582
+ chatLog.addSystem("status: unknown response");
2583
+ } catch (err) {
2584
+ chatLog.addSystem(`status failed: ${String(err)}`);
2585
+ }
2586
+ break;
2587
+ case "agent":
2588
+ if (!args) await openAgentSelector();
2589
+ else await setAgent(args);
2590
+ break;
2591
+ case "agents":
2592
+ await openAgentSelector();
2593
+ break;
2594
+ case "session":
2595
+ if (!args) await openSessionSelector();
2596
+ else await setSession(args);
2597
+ break;
2598
+ case "sessions":
2599
+ await openSessionSelector();
2600
+ break;
2601
+ case "model":
2602
+ if (!args) await openModelSelector();
2603
+ else try {
2604
+ const result = await client.patchSession({
2605
+ key: state.currentSessionKey,
2606
+ model: args
2607
+ });
2608
+ chatLog.addSystem(`model set to ${args}`);
2609
+ applySessionInfoFromPatch(result);
2610
+ await refreshSessionInfo();
2611
+ } catch (err) {
2612
+ chatLog.addSystem(`model set failed: ${String(err)}`);
2613
+ }
2614
+ break;
2615
+ case "models":
2616
+ await openModelSelector();
2617
+ break;
2618
+ case "think":
2619
+ if (!args) {
2620
+ const levels = formatThinkingLevels(state.sessionInfo.modelProvider, state.sessionInfo.model, "|");
2621
+ chatLog.addSystem(`usage: /think <${levels}>`);
2622
+ break;
2623
+ }
2624
+ try {
2625
+ const result = await client.patchSession({
2626
+ key: state.currentSessionKey,
2627
+ thinkingLevel: args
2628
+ });
2629
+ chatLog.addSystem(`thinking set to ${args}`);
2630
+ applySessionInfoFromPatch(result);
2631
+ await refreshSessionInfo();
2632
+ } catch (err) {
2633
+ chatLog.addSystem(`think failed: ${String(err)}`);
2634
+ }
2635
+ break;
2636
+ case "verbose":
2637
+ if (!args) {
2638
+ chatLog.addSystem("usage: /verbose <on|off>");
2639
+ break;
2640
+ }
2641
+ try {
2642
+ const result = await client.patchSession({
2643
+ key: state.currentSessionKey,
2644
+ verboseLevel: args
2645
+ });
2646
+ chatLog.addSystem(`verbose set to ${args}`);
2647
+ applySessionInfoFromPatch(result);
2648
+ await loadHistory();
2649
+ } catch (err) {
2650
+ chatLog.addSystem(`verbose failed: ${String(err)}`);
2651
+ }
2652
+ break;
2653
+ case "trace":
2654
+ if (!args) {
2655
+ chatLog.addSystem("usage: /trace <on|off>");
2656
+ break;
2657
+ }
2658
+ try {
2659
+ const result = await client.patchSession({
2660
+ key: state.currentSessionKey,
2661
+ traceLevel: args
2662
+ });
2663
+ chatLog.addSystem(`trace set to ${args}`);
2664
+ applySessionInfoFromPatch(result);
2665
+ await loadHistory();
2666
+ } catch (err) {
2667
+ chatLog.addSystem(`trace failed: ${String(err)}`);
2668
+ }
2669
+ break;
2670
+ case "fast":
2671
+ if (!args || args === "status") {
2672
+ chatLog.addSystem(`fast mode: ${state.sessionInfo.fastMode ? "on" : "off"}`);
2673
+ break;
2674
+ }
2675
+ if (args !== "on" && args !== "off") {
2676
+ chatLog.addSystem("usage: /fast <status|on|off>");
2677
+ break;
2678
+ }
2679
+ try {
2680
+ const result = await client.patchSession({
2681
+ key: state.currentSessionKey,
2682
+ fastMode: args === "on"
2683
+ });
2684
+ chatLog.addSystem(`fast mode ${args === "on" ? "enabled" : "disabled"}`);
2685
+ applySessionInfoFromPatch(result);
2686
+ await refreshSessionInfo();
2687
+ } catch (err) {
2688
+ chatLog.addSystem(`fast failed: ${String(err)}`);
2689
+ }
2690
+ break;
2691
+ case "reasoning":
2692
+ if (!args) {
2693
+ chatLog.addSystem("usage: /reasoning <on|off>");
2694
+ break;
2695
+ }
2696
+ try {
2697
+ const result = await client.patchSession({
2698
+ key: state.currentSessionKey,
2699
+ reasoningLevel: args
2700
+ });
2701
+ chatLog.addSystem(`reasoning set to ${args}`);
2702
+ applySessionInfoFromPatch(result);
2703
+ await refreshSessionInfo();
2704
+ } catch (err) {
2705
+ chatLog.addSystem(`reasoning failed: ${String(err)}`);
2706
+ }
2707
+ break;
2708
+ case "usage": {
2709
+ const normalized = args ? normalizeUsageDisplay(args) : void 0;
2710
+ if (args && !normalized) {
2711
+ chatLog.addSystem("usage: /usage <off|tokens|full>");
2712
+ break;
2713
+ }
2714
+ const currentRaw = state.sessionInfo.responseUsage;
2715
+ const current = resolveResponseUsageMode(currentRaw);
2716
+ const next = normalized ?? (current === "off" ? "tokens" : current === "tokens" ? "full" : "off");
2717
+ try {
2718
+ const result = await client.patchSession({
2719
+ key: state.currentSessionKey,
2720
+ responseUsage: next === "off" ? null : next
2721
+ });
2722
+ chatLog.addSystem(`usage footer: ${next}`);
2723
+ applySessionInfoFromPatch(result);
2724
+ await refreshSessionInfo();
2725
+ } catch (err) {
2726
+ chatLog.addSystem(`usage failed: ${String(err)}`);
2727
+ }
2728
+ break;
2729
+ }
2730
+ case "elevated":
2731
+ if (!args) {
2732
+ chatLog.addSystem("usage: /elevated <on|off|ask|full>");
2733
+ break;
2734
+ }
2735
+ if (![
2736
+ "on",
2737
+ "off",
2738
+ "ask",
2739
+ "full"
2740
+ ].includes(args)) {
2741
+ chatLog.addSystem("usage: /elevated <on|off|ask|full>");
2742
+ break;
2743
+ }
2744
+ try {
2745
+ const result = await client.patchSession({
2746
+ key: state.currentSessionKey,
2747
+ elevatedLevel: args
2748
+ });
2749
+ chatLog.addSystem(`elevated set to ${args}`);
2750
+ applySessionInfoFromPatch(result);
2751
+ await refreshSessionInfo();
2752
+ } catch (err) {
2753
+ chatLog.addSystem(`elevated failed: ${String(err)}`);
2754
+ }
2755
+ break;
2756
+ case "activation": {
2757
+ if (!args) {
2758
+ chatLog.addSystem("usage: /activation <mention|always>");
2759
+ break;
2760
+ }
2761
+ const activation = normalizeGroupActivation(args);
2762
+ if (!activation) {
2763
+ chatLog.addSystem("usage: /activation <mention|always>");
2764
+ break;
2765
+ }
2766
+ try {
2767
+ const result = await client.patchSession({
2768
+ key: state.currentSessionKey,
2769
+ groupActivation: activation
2770
+ });
2771
+ chatLog.addSystem(`activation set to ${activation}`);
2772
+ applySessionInfoFromPatch(result);
2773
+ await refreshSessionInfo();
2774
+ } catch (err) {
2775
+ chatLog.addSystem(`activation failed: ${String(err)}`);
2776
+ }
2777
+ break;
2778
+ }
2779
+ case "new":
2780
+ try {
2781
+ state.sessionInfo.inputTokens = null;
2782
+ state.sessionInfo.outputTokens = null;
2783
+ state.sessionInfo.totalTokens = null;
2784
+ tui.requestRender();
2785
+ const uniqueKey = `tui-${randomUUID()}`;
2786
+ await setSession(uniqueKey);
2787
+ chatLog.addSystem(`new session: ${uniqueKey}`);
2788
+ } catch (err) {
2789
+ chatLog.addSystem(`new session failed: ${sanitizeRenderableText(String(err))}`);
2790
+ }
2791
+ break;
2792
+ case "reset":
2793
+ try {
2794
+ state.sessionInfo.inputTokens = null;
2795
+ state.sessionInfo.outputTokens = null;
2796
+ state.sessionInfo.totalTokens = null;
2797
+ tui.requestRender();
2798
+ await client.resetSession(state.currentSessionKey, name);
2799
+ chatLog.addSystem(`session ${state.currentSessionKey} reset`);
2800
+ await loadHistory();
2801
+ } catch (err) {
2802
+ chatLog.addSystem(`reset failed: ${sanitizeRenderableText(String(err))}`);
2803
+ }
2804
+ break;
2805
+ case "abort":
2806
+ await abortActive();
2807
+ break;
2808
+ case "settings":
2809
+ openSettings();
2810
+ break;
2811
+ case "exit":
2812
+ case "quit":
2813
+ requestExit();
2814
+ break;
2815
+ default:
2816
+ await sendMessage(raw);
2817
+ break;
2818
+ }
2819
+ tui.requestRender();
2820
+ };
2821
+ const sendMessage = async (text) => {
2822
+ if (!state.isConnected) {
2823
+ chatLog.addSystem(opts.local ? "local runtime not ready — message not sent" : "not connected to gateway — message not sent");
2824
+ setActivityStatus("disconnected");
2825
+ tui.requestRender();
2826
+ return;
2827
+ }
2828
+ const isBtw = isBtwCommand(text);
2829
+ const runId = randomUUID();
2830
+ try {
2831
+ if (!isBtw) {
2832
+ chatLog.addUser(text);
2833
+ state.pendingOptimisticUserMessage = true;
2834
+ setActivityStatus("sending");
2835
+ } else noteLocalBtwRunId?.(runId);
2836
+ tui.requestRender();
2837
+ await client.sendChat({
2838
+ sessionKey: state.currentSessionKey,
2839
+ message: text,
2840
+ thinking: opts.thinking,
2841
+ deliver: deliverDefault,
2842
+ timeoutMs: opts.timeoutMs,
2843
+ runId
2844
+ });
2845
+ if (!isBtw) {
2846
+ setActivityStatus("waiting");
2847
+ tui.requestRender();
2848
+ }
2849
+ } catch (err) {
2850
+ if (isBtw) forgetLocalBtwRunId?.(runId);
2851
+ if (!isBtw && state.activeChatRunId) forgetLocalRunId?.(state.activeChatRunId);
2852
+ if (!isBtw) {
2853
+ state.pendingOptimisticUserMessage = false;
2854
+ state.activeChatRunId = null;
2855
+ }
2856
+ chatLog.addSystem(`${isBtw ? "btw failed" : "send failed"}: ${String(err)}`);
2857
+ if (!isBtw) setActivityStatus("error");
2858
+ tui.requestRender();
2859
+ }
2860
+ };
2861
+ return {
2862
+ handleCommand,
2863
+ sendMessage,
2864
+ openModelSelector,
2865
+ openAgentSelector,
2866
+ openSessionSelector,
2867
+ openSettings,
2868
+ setAgent
2869
+ };
2870
+ }
2871
+ //#endregion
2872
+ //#region src/tui/tui-stream-assembler.ts
2873
+ function extractTextBlocksAndSignals(message) {
2874
+ if (!message || typeof message !== "object") return {
2875
+ textBlocks: [],
2876
+ sawNonTextContentBlocks: false
2877
+ };
2878
+ const content = message.content;
2879
+ if (typeof content === "string") {
2880
+ const text = content.trim();
2881
+ return {
2882
+ textBlocks: text ? [text] : [],
2883
+ sawNonTextContentBlocks: false
2884
+ };
2885
+ }
2886
+ if (!Array.isArray(content)) return {
2887
+ textBlocks: [],
2888
+ sawNonTextContentBlocks: false
2889
+ };
2890
+ const textBlocks = [];
2891
+ let sawNonTextContentBlocks = false;
2892
+ for (const block of content) {
2893
+ if (!block || typeof block !== "object") continue;
2894
+ const rec = block;
2895
+ if (rec.type === "text" && typeof rec.text === "string") {
2896
+ const text = rec.text.trim();
2897
+ if (text) textBlocks.push(text);
2898
+ continue;
2899
+ }
2900
+ if (typeof rec.type === "string" && rec.type !== "thinking") sawNonTextContentBlocks = true;
2901
+ }
2902
+ return {
2903
+ textBlocks,
2904
+ sawNonTextContentBlocks
2905
+ };
2906
+ }
2907
+ function isDroppedBoundaryTextBlockSubset(params) {
2908
+ const { streamedTextBlocks, finalTextBlocks } = params;
2909
+ if (finalTextBlocks.length === 0 || finalTextBlocks.length >= streamedTextBlocks.length) return false;
2910
+ if (finalTextBlocks.every((block, index) => streamedTextBlocks[index] === block)) return true;
2911
+ const suffixStart = streamedTextBlocks.length - finalTextBlocks.length;
2912
+ return finalTextBlocks.every((block, index) => streamedTextBlocks[suffixStart + index] === block);
2913
+ }
2914
+ function shouldPreserveBoundaryDroppedText(params) {
2915
+ if (params.boundaryDropMode === "off") return false;
2916
+ if (!(params.boundaryDropMode === "streamed-or-incoming" ? params.streamedSawNonTextContentBlocks || params.incomingSawNonTextContentBlocks : params.streamedSawNonTextContentBlocks)) return false;
2917
+ return isDroppedBoundaryTextBlockSubset({
2918
+ streamedTextBlocks: params.streamedTextBlocks,
2919
+ finalTextBlocks: params.nextContentBlocks
2920
+ });
2921
+ }
2922
+ var TuiStreamAssembler = class {
2923
+ constructor() {
2924
+ this.runs = /* @__PURE__ */ new Map();
2925
+ }
2926
+ getOrCreateRun(runId) {
2927
+ let state = this.runs.get(runId);
2928
+ if (!state) {
2929
+ state = {
2930
+ thinkingText: "",
2931
+ contentText: "",
2932
+ contentBlocks: [],
2933
+ sawNonTextContentBlocks: false,
2934
+ displayText: ""
2935
+ };
2936
+ this.runs.set(runId, state);
2937
+ }
2938
+ return state;
2939
+ }
2940
+ updateRunState(state, message, showThinking, opts) {
2941
+ const thinkingText = extractThinkingFromMessage(message);
2942
+ const contentText = extractContentFromMessage(message);
2943
+ const { textBlocks, sawNonTextContentBlocks } = extractTextBlocksAndSignals(message);
2944
+ if (thinkingText) state.thinkingText = thinkingText;
2945
+ if (contentText) {
2946
+ const nextContentBlocks = textBlocks.length > 0 ? textBlocks : [contentText];
2947
+ if (!shouldPreserveBoundaryDroppedText({
2948
+ boundaryDropMode: opts?.boundaryDropMode ?? "off",
2949
+ streamedSawNonTextContentBlocks: state.sawNonTextContentBlocks,
2950
+ incomingSawNonTextContentBlocks: sawNonTextContentBlocks,
2951
+ streamedTextBlocks: state.contentBlocks,
2952
+ nextContentBlocks
2953
+ })) {
2954
+ state.contentText = contentText;
2955
+ state.contentBlocks = nextContentBlocks;
2956
+ }
2957
+ }
2958
+ if (sawNonTextContentBlocks) state.sawNonTextContentBlocks = true;
2959
+ state.displayText = composeThinkingAndContent({
2960
+ thinkingText: state.thinkingText,
2961
+ contentText: state.contentText,
2962
+ showThinking
2963
+ });
2964
+ }
2965
+ ingestDelta(runId, message, showThinking) {
2966
+ const state = this.getOrCreateRun(runId);
2967
+ const previousDisplayText = state.displayText;
2968
+ this.updateRunState(state, message, showThinking, { boundaryDropMode: "streamed-or-incoming" });
2969
+ if (!state.displayText || state.displayText === previousDisplayText) return null;
2970
+ return state.displayText;
2971
+ }
2972
+ /**
2973
+ * Ingest an incremental assistant-text suffix (gateway `chat-incremental`
2974
+ * capability). Appends to the accumulated content (or replaces it on `reset`)
2975
+ * and recomposes the display text. Chat deltas carry assistant text only, so
2976
+ * accumulated thinking state is left untouched.
2977
+ */
2978
+ ingestAppendText(runId, appendText, reset, showThinking) {
2979
+ const state = this.getOrCreateRun(runId);
2980
+ const previousDisplayText = state.displayText;
2981
+ const nextContentText = reset ? appendText : state.contentText + appendText;
2982
+ state.contentText = nextContentText;
2983
+ state.contentBlocks = nextContentText ? [nextContentText] : [];
2984
+ state.displayText = composeThinkingAndContent({
2985
+ thinkingText: state.thinkingText,
2986
+ contentText: state.contentText,
2987
+ showThinking
2988
+ });
2989
+ if (!state.displayText || state.displayText === previousDisplayText) return null;
2990
+ return state.displayText;
2991
+ }
2992
+ finalize(runId, message, showThinking, errorMessage) {
2993
+ const state = this.getOrCreateRun(runId);
2994
+ const streamedDisplayText = state.displayText;
2995
+ const streamedTextBlocks = [...state.contentBlocks];
2996
+ const streamedSawNonTextContentBlocks = state.sawNonTextContentBlocks;
2997
+ this.updateRunState(state, message, showThinking, { boundaryDropMode: "streamed-only" });
2998
+ const finalComposed = state.displayText;
2999
+ const finalText = resolveFinalAssistantText({
3000
+ finalText: streamedSawNonTextContentBlocks && isDroppedBoundaryTextBlockSubset({
3001
+ streamedTextBlocks,
3002
+ finalTextBlocks: state.contentBlocks
3003
+ }) ? streamedDisplayText : finalComposed,
3004
+ streamedText: streamedDisplayText,
3005
+ errorMessage
3006
+ });
3007
+ this.runs.delete(runId);
3008
+ return finalText;
3009
+ }
3010
+ drop(runId) {
3011
+ this.runs.delete(runId);
3012
+ }
3013
+ };
3014
+ //#endregion
3015
+ //#region src/tui/tui-event-handlers.ts
3016
+ const DEFAULT_STREAMING_WATCHDOG_MS = 3e4;
3017
+ function createEventHandlers(context) {
3018
+ const { chatLog, btw, tui, state, setActivityStatus, refreshSessionInfo, loadHistory, noteLocalRunId, isLocalRunId, forgetLocalRunId, clearLocalRunIds, isLocalBtwRunId, forgetLocalBtwRunId, clearLocalBtwRunIds, localMode } = context;
3019
+ const finalizedRuns = /* @__PURE__ */ new Map();
3020
+ const sessionRuns = /* @__PURE__ */ new Map();
3021
+ let streamAssembler = new TuiStreamAssembler();
3022
+ let lastSessionKey = state.currentSessionKey;
3023
+ let pendingHistoryRefresh = false;
3024
+ const streamingWatchdogMs = typeof context.streamingWatchdogMs === "number" && Number.isFinite(context.streamingWatchdogMs) && context.streamingWatchdogMs >= 0 ? Math.floor(context.streamingWatchdogMs) : DEFAULT_STREAMING_WATCHDOG_MS;
3025
+ let streamingWatchdogTimer = null;
3026
+ let streamingWatchdogRunId = null;
3027
+ const clearStreamingWatchdog = () => {
3028
+ if (streamingWatchdogTimer) {
3029
+ clearTimeout(streamingWatchdogTimer);
3030
+ streamingWatchdogTimer = null;
3031
+ }
3032
+ streamingWatchdogRunId = null;
3033
+ };
3034
+ const armStreamingWatchdog = (runId) => {
3035
+ if (streamingWatchdogMs <= 0) return;
3036
+ if (streamingWatchdogTimer) clearTimeout(streamingWatchdogTimer);
3037
+ streamingWatchdogRunId = runId;
3038
+ streamingWatchdogTimer = setTimeout(() => {
3039
+ streamingWatchdogTimer = null;
3040
+ if (streamingWatchdogRunId !== runId || state.activeChatRunId !== runId) return;
3041
+ streamingWatchdogRunId = null;
3042
+ state.activeChatRunId = null;
3043
+ setActivityStatus("idle");
3044
+ chatLog.addSystem(`streaming watchdog: no stream updates for ${Math.round(streamingWatchdogMs / 1e3)}s; resetting status. The backend may have dropped this run silently — send a new message to resync.`);
3045
+ tui.requestRender();
3046
+ }, streamingWatchdogMs);
3047
+ const maybeUnref = streamingWatchdogTimer.unref;
3048
+ if (typeof maybeUnref === "function") maybeUnref.call(streamingWatchdogTimer);
3049
+ };
3050
+ const pruneRunMap = (runs) => {
3051
+ if (runs.size <= 200) return;
3052
+ const keepUntil = Date.now() - 600 * 1e3;
3053
+ for (const [key, ts] of runs) {
3054
+ if (runs.size <= 150) break;
3055
+ if (ts < keepUntil) runs.delete(key);
3056
+ }
3057
+ if (runs.size > 200) for (const key of runs.keys()) {
3058
+ runs.delete(key);
3059
+ if (runs.size <= 150) break;
3060
+ }
3061
+ };
3062
+ const syncSessionKey = () => {
3063
+ if (state.currentSessionKey === lastSessionKey) return;
3064
+ lastSessionKey = state.currentSessionKey;
3065
+ finalizedRuns.clear();
3066
+ sessionRuns.clear();
3067
+ streamAssembler = new TuiStreamAssembler();
3068
+ pendingHistoryRefresh = false;
3069
+ state.pendingOptimisticUserMessage = false;
3070
+ clearLocalRunIds?.();
3071
+ clearLocalBtwRunIds?.();
3072
+ btw.clear();
3073
+ clearStreamingWatchdog();
3074
+ };
3075
+ const flushPendingHistoryRefreshIfIdle = () => {
3076
+ if (!pendingHistoryRefresh || state.activeChatRunId) return;
3077
+ pendingHistoryRefresh = false;
3078
+ loadHistory?.();
3079
+ };
3080
+ const resolveAuthErrorHint = (errorMessage) => {
3081
+ if (!localMode || !isAuthErrorMessage(errorMessage)) return;
3082
+ const provider = state.sessionInfo.modelProvider?.trim();
3083
+ 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.";
3084
+ };
3085
+ const noteSessionRun = (runId) => {
3086
+ sessionRuns.set(runId, Date.now());
3087
+ pruneRunMap(sessionRuns);
3088
+ };
3089
+ const noteFinalizedRun = (runId) => {
3090
+ finalizedRuns.set(runId, Date.now());
3091
+ sessionRuns.delete(runId);
3092
+ streamAssembler.drop(runId);
3093
+ pruneRunMap(finalizedRuns);
3094
+ };
3095
+ const clearActiveRunIfMatch = (runId) => {
3096
+ if (state.activeChatRunId === runId) state.activeChatRunId = null;
3097
+ };
3098
+ const finalizeRun = (params) => {
3099
+ noteFinalizedRun(params.runId);
3100
+ clearActiveRunIfMatch(params.runId);
3101
+ flushPendingHistoryRefreshIfIdle();
3102
+ if (params.wasActiveRun) {
3103
+ setActivityStatus(params.status);
3104
+ clearStreamingWatchdog();
3105
+ } else if (streamingWatchdogRunId === params.runId) clearStreamingWatchdog();
3106
+ refreshSessionInfo?.();
3107
+ };
3108
+ const terminateRun = (params) => {
3109
+ streamAssembler.drop(params.runId);
3110
+ sessionRuns.delete(params.runId);
3111
+ clearActiveRunIfMatch(params.runId);
3112
+ flushPendingHistoryRefreshIfIdle();
3113
+ if (params.wasActiveRun) {
3114
+ setActivityStatus(params.status);
3115
+ clearStreamingWatchdog();
3116
+ } else if (streamingWatchdogRunId === params.runId) clearStreamingWatchdog();
3117
+ refreshSessionInfo?.();
3118
+ };
3119
+ const hasConcurrentActiveRun = (runId) => {
3120
+ const activeRunId = state.activeChatRunId;
3121
+ if (!activeRunId || activeRunId === runId) return false;
3122
+ return sessionRuns.has(activeRunId);
3123
+ };
3124
+ const maybeRefreshHistoryForRun = (runId, opts) => {
3125
+ if (isLocalRunId?.(runId) ?? false) {
3126
+ forgetLocalRunId?.(runId);
3127
+ if (!opts?.allowLocalWithoutDisplayableFinal) return;
3128
+ if (state.activeChatRunId && state.activeChatRunId !== runId) {
3129
+ pendingHistoryRefresh = true;
3130
+ return;
3131
+ }
3132
+ }
3133
+ if (hasConcurrentActiveRun(runId)) return;
3134
+ pendingHistoryRefresh = false;
3135
+ loadHistory?.();
3136
+ };
3137
+ const isSameSessionKey = (left, right) => {
3138
+ const normalizedLeft = normalizeLowercaseStringOrEmpty(left);
3139
+ const normalizedRight = normalizeLowercaseStringOrEmpty(right);
3140
+ if (!normalizedLeft || !normalizedRight) return false;
3141
+ if (normalizedLeft === normalizedRight) return true;
3142
+ const parsedLeft = parseAgentSessionKey(normalizedLeft);
3143
+ const parsedRight = parseAgentSessionKey(normalizedRight);
3144
+ if (parsedLeft && parsedRight) return parsedLeft.agentId === parsedRight.agentId && parsedLeft.rest === parsedRight.rest;
3145
+ if (parsedLeft) return parsedLeft.rest === normalizedRight;
3146
+ if (parsedRight) return normalizedLeft === parsedRight.rest;
3147
+ return false;
3148
+ };
3149
+ const handleChatEvent = (payload) => {
3150
+ if (!payload || typeof payload !== "object") return;
3151
+ const evt = payload;
3152
+ syncSessionKey();
3153
+ if (!isSameSessionKey(evt.sessionKey, state.currentSessionKey)) return;
3154
+ if (finalizedRuns.has(evt.runId)) {
3155
+ if (evt.state === "delta") return;
3156
+ if (evt.state === "final") return;
3157
+ }
3158
+ noteSessionRun(evt.runId);
3159
+ if (!state.activeChatRunId && !isLocalBtwRunId?.(evt.runId)) {
3160
+ state.activeChatRunId = evt.runId;
3161
+ if (state.pendingOptimisticUserMessage) {
3162
+ noteLocalRunId?.(evt.runId);
3163
+ state.pendingOptimisticUserMessage = false;
3164
+ }
3165
+ }
3166
+ if (evt.state === "delta") {
3167
+ setActivityStatus("streaming");
3168
+ if (state.activeChatRunId === evt.runId) armStreamingWatchdog(evt.runId);
3169
+ const displayText = typeof evt.appendText === "string" ? streamAssembler.ingestAppendText(evt.runId, evt.appendText, evt.reset === true, state.showThinking) : streamAssembler.ingestDelta(evt.runId, evt.message, state.showThinking);
3170
+ if (!displayText) return;
3171
+ chatLog.updateAssistant(displayText, evt.runId);
3172
+ }
3173
+ if (evt.state === "final") {
3174
+ const isLocalBtwRun = isLocalBtwRunId?.(evt.runId) ?? false;
3175
+ const wasActiveRun = state.activeChatRunId === evt.runId;
3176
+ if (!evt.message && isLocalBtwRun) {
3177
+ forgetLocalBtwRunId?.(evt.runId);
3178
+ noteFinalizedRun(evt.runId);
3179
+ tui.requestRender();
3180
+ return;
3181
+ }
3182
+ if (!evt.message) {
3183
+ maybeRefreshHistoryForRun(evt.runId, { allowLocalWithoutDisplayableFinal: true });
3184
+ chatLog.dropAssistant(evt.runId);
3185
+ finalizeRun({
3186
+ runId: evt.runId,
3187
+ wasActiveRun,
3188
+ status: "idle"
3189
+ });
3190
+ tui.requestRender();
3191
+ return;
3192
+ }
3193
+ if (isCommandMessage(evt.message)) {
3194
+ maybeRefreshHistoryForRun(evt.runId);
3195
+ const text = extractTextFromMessage(evt.message);
3196
+ if (text) chatLog.addSystem(text);
3197
+ finalizeRun({
3198
+ runId: evt.runId,
3199
+ wasActiveRun,
3200
+ status: "idle"
3201
+ });
3202
+ tui.requestRender();
3203
+ return;
3204
+ }
3205
+ maybeRefreshHistoryForRun(evt.runId);
3206
+ const stopReason = evt.message && typeof evt.message === "object" && !Array.isArray(evt.message) ? typeof evt.message.stopReason === "string" ? evt.message.stopReason : "" : "";
3207
+ const finalText = streamAssembler.finalize(evt.runId, evt.message, state.showThinking, evt.errorMessage);
3208
+ if (finalText === "(no output)" && !isLocalRunId?.(evt.runId)) chatLog.dropAssistant(evt.runId);
3209
+ else chatLog.finalizeAssistant(finalText, evt.runId);
3210
+ finalizeRun({
3211
+ runId: evt.runId,
3212
+ wasActiveRun,
3213
+ status: stopReason === "error" ? "error" : "idle"
3214
+ });
3215
+ }
3216
+ if (evt.state === "aborted") {
3217
+ forgetLocalBtwRunId?.(evt.runId);
3218
+ const wasActiveRun = state.activeChatRunId === evt.runId;
3219
+ chatLog.addSystem("run aborted");
3220
+ terminateRun({
3221
+ runId: evt.runId,
3222
+ wasActiveRun,
3223
+ status: "aborted"
3224
+ });
3225
+ maybeRefreshHistoryForRun(evt.runId);
3226
+ }
3227
+ if (evt.state === "error") {
3228
+ forgetLocalBtwRunId?.(evt.runId);
3229
+ const wasActiveRun = state.activeChatRunId === evt.runId;
3230
+ const errorMessage = evt.errorMessage ?? "unknown";
3231
+ chatLog.addSystem(resolveAuthErrorHint(errorMessage) ?? `run error: ${errorMessage}`);
3232
+ terminateRun({
3233
+ runId: evt.runId,
3234
+ wasActiveRun,
3235
+ status: "error"
3236
+ });
3237
+ maybeRefreshHistoryForRun(evt.runId);
3238
+ }
3239
+ tui.requestRender();
3240
+ };
3241
+ const handleAgentEvent = (payload) => {
3242
+ if (!payload || typeof payload !== "object") return;
3243
+ const evt = payload;
3244
+ syncSessionKey();
3245
+ const isActiveRun = evt.runId === state.activeChatRunId;
3246
+ if (!(isActiveRun || sessionRuns.has(evt.runId) || finalizedRuns.has(evt.runId))) return;
3247
+ if (evt.stream === "tool") {
3248
+ const verbose = state.sessionInfo.verboseLevel ?? "off";
3249
+ const allowToolEvents = verbose !== "off";
3250
+ const allowToolOutput = verbose === "full";
3251
+ if (!allowToolEvents) return;
3252
+ const data = evt.data ?? {};
3253
+ const phase = asString(data.phase, "");
3254
+ const toolCallId = asString(data.toolCallId, "");
3255
+ const toolName = asString(data.name, "tool");
3256
+ if (!toolCallId) return;
3257
+ if (phase === "start") chatLog.startTool(toolCallId, toolName, data.args);
3258
+ else if (phase === "update") {
3259
+ if (!allowToolOutput) return;
3260
+ chatLog.updateToolResult(toolCallId, data.partialResult, { partial: true });
3261
+ } else if (phase === "result") if (allowToolOutput) chatLog.updateToolResult(toolCallId, data.result, { isError: Boolean(data.isError) });
3262
+ else chatLog.updateToolResult(toolCallId, { content: [] }, { isError: Boolean(data.isError) });
3263
+ tui.requestRender();
3264
+ return;
3265
+ }
3266
+ if (evt.stream === "lifecycle") {
3267
+ if (!isActiveRun) return;
3268
+ const phase = typeof evt.data?.phase === "string" ? evt.data.phase : "";
3269
+ if (phase === "start") setActivityStatus("running");
3270
+ if (phase === "end") setActivityStatus("idle");
3271
+ if (phase === "error") setActivityStatus("error");
3272
+ tui.requestRender();
3273
+ }
3274
+ };
3275
+ const handleBtwEvent = (payload) => {
3276
+ if (!payload || typeof payload !== "object") return;
3277
+ const evt = payload;
3278
+ syncSessionKey();
3279
+ if (!isSameSessionKey(evt.sessionKey, state.currentSessionKey)) return;
3280
+ if (evt.kind !== "btw") return;
3281
+ const question = evt.question.trim();
3282
+ const text = evt.text.trim();
3283
+ if (!question || !text) return;
3284
+ btw.showResult({
3285
+ question,
3286
+ text,
3287
+ isError: evt.isError
3288
+ });
3289
+ tui.requestRender();
3290
+ };
3291
+ const dispose = () => {
3292
+ clearStreamingWatchdog();
3293
+ };
3294
+ return {
3295
+ handleChatEvent,
3296
+ handleAgentEvent,
3297
+ handleBtwEvent,
3298
+ dispose
3299
+ };
3300
+ }
3301
+ //#endregion
3302
+ //#region src/tui/tui-local-shell.ts
3303
+ function createLocalShellRunner(deps) {
3304
+ let localExecAsked = false;
3305
+ let localExecAllowed = false;
3306
+ const createSelector = deps.createSelector ?? createSearchableSelectList;
3307
+ const spawnCommand = deps.spawnCommand ?? spawn;
3308
+ const getCwd = deps.getCwd ?? (() => process.cwd());
3309
+ const env = deps.env ?? process.env;
3310
+ const maxChars = deps.maxOutputChars ?? 4e4;
3311
+ const ensureLocalExecAllowed = async () => {
3312
+ if (localExecAllowed) return true;
3313
+ if (localExecAsked) return false;
3314
+ localExecAsked = true;
3315
+ return await new Promise((resolve) => {
3316
+ deps.chatLog.addSystem("Allow local shell commands for this session?");
3317
+ deps.chatLog.addSystem("This runs commands on YOUR machine (not the gateway) and may delete files or reveal secrets.");
3318
+ deps.chatLog.addSystem("Select Yes/No (arrows + Enter), Esc to cancel.");
3319
+ const selector = createSelector([{
3320
+ value: "no",
3321
+ label: "No"
3322
+ }, {
3323
+ value: "yes",
3324
+ label: "Yes"
3325
+ }], 2);
3326
+ selector.onSelect = (item) => {
3327
+ deps.closeOverlay();
3328
+ if (item.value === "yes") {
3329
+ localExecAllowed = true;
3330
+ deps.chatLog.addSystem("local shell: enabled for this session");
3331
+ resolve(true);
3332
+ } else {
3333
+ deps.chatLog.addSystem("local shell: not enabled");
3334
+ resolve(false);
3335
+ }
3336
+ deps.tui.requestRender();
3337
+ };
3338
+ selector.onCancel = () => {
3339
+ deps.closeOverlay();
3340
+ deps.chatLog.addSystem("local shell: cancelled");
3341
+ deps.tui.requestRender();
3342
+ resolve(false);
3343
+ };
3344
+ deps.openOverlay(selector);
3345
+ deps.tui.requestRender();
3346
+ });
3347
+ };
3348
+ const runLocalShellLine = async (line) => {
3349
+ const cmd = line.slice(1);
3350
+ if (cmd === "") return;
3351
+ if (localExecAsked && !localExecAllowed) {
3352
+ deps.chatLog.addSystem("local shell: not enabled for this session");
3353
+ deps.tui.requestRender();
3354
+ return;
3355
+ }
3356
+ if (!await ensureLocalExecAllowed()) return;
3357
+ deps.chatLog.addSystem(`[local] $ ${cmd}`);
3358
+ deps.tui.requestRender();
3359
+ const appendWithCap = (text, chunk) => {
3360
+ const combined = text + chunk;
3361
+ return combined.length > maxChars ? combined.slice(-maxChars) : combined;
3362
+ };
3363
+ await new Promise((resolve) => {
3364
+ const child = spawnCommand(cmd, {
3365
+ shell: true,
3366
+ cwd: getCwd(),
3367
+ env: {
3368
+ ...env,
3369
+ GENESIS_SHELL: "tui-local"
3370
+ }
3371
+ });
3372
+ let stdout = "";
3373
+ let stderr = "";
3374
+ child.stdout.on("data", (buf) => {
3375
+ stdout = appendWithCap(stdout, buf.toString("utf8"));
3376
+ });
3377
+ child.stderr.on("data", (buf) => {
3378
+ stderr = appendWithCap(stderr, buf.toString("utf8"));
3379
+ });
3380
+ child.on("close", (code, signal) => {
3381
+ const combined = (stdout + (stderr ? (stdout ? "\n" : "") + stderr : "")).slice(0, maxChars).trimEnd();
3382
+ if (combined) for (const line of combined.split("\n")) deps.chatLog.addSystem(`[local] ${line}`);
3383
+ deps.chatLog.addSystem(`[local] exit ${code ?? "?"}${signal ? ` (signal ${signal})` : ""}`);
3384
+ deps.tui.requestRender();
3385
+ resolve();
3386
+ });
3387
+ child.on("error", (err) => {
3388
+ deps.chatLog.addSystem(`[local] error: ${String(err)}`);
3389
+ deps.tui.requestRender();
3390
+ resolve();
3391
+ });
3392
+ });
3393
+ };
3394
+ return { runLocalShellLine };
3395
+ }
3396
+ //#endregion
3397
+ //#region src/tui/tui-overlays.ts
3398
+ function createOverlayHandlers(host, fallbackFocus) {
3399
+ const openOverlay = (component) => {
3400
+ host.showOverlay(component);
3401
+ };
3402
+ const closeOverlay = () => {
3403
+ if (host.hasOverlay()) {
3404
+ host.hideOverlay();
3405
+ return;
3406
+ }
3407
+ host.setFocus(fallbackFocus);
3408
+ };
3409
+ return {
3410
+ openOverlay,
3411
+ closeOverlay
3412
+ };
3413
+ }
3414
+ //#endregion
3415
+ //#region src/tui/tui-session-actions.ts
3416
+ function createSessionActions(context) {
3417
+ const { client, chatLog, btw, tui, opts, state, agentNames, initialSessionInput, initialSessionAgentId, resolveSessionKey, updateHeader, updateFooter, updateAutocompleteProvider, setActivityStatus, clearLocalRunIds } = context;
3418
+ let refreshSessionInfoPromise = Promise.resolve();
3419
+ let lastSessionDefaults = null;
3420
+ const applyAgentsResult = (result) => {
3421
+ state.agentDefaultId = normalizeAgentId(result.defaultId);
3422
+ state.sessionMainKey = normalizeMainKey(result.mainKey);
3423
+ state.sessionScope = result.scope ?? state.sessionScope;
3424
+ state.agents = result.agents.map((agent) => ({
3425
+ id: normalizeAgentId(agent.id),
3426
+ name: normalizeOptionalString(agent.name)
3427
+ }));
3428
+ agentNames.clear();
3429
+ for (const agent of state.agents) if (agent.name) agentNames.set(agent.id, agent.name);
3430
+ if (!state.initialSessionApplied) {
3431
+ if (initialSessionAgentId) {
3432
+ if (state.agents.some((agent) => agent.id === initialSessionAgentId)) state.currentAgentId = initialSessionAgentId;
3433
+ } else if (!state.agents.some((agent) => agent.id === state.currentAgentId)) state.currentAgentId = state.agents[0]?.id ?? normalizeAgentId(result.defaultId ?? state.currentAgentId);
3434
+ const nextSessionKey = resolveSessionKey(initialSessionInput);
3435
+ if (nextSessionKey !== state.currentSessionKey) state.currentSessionKey = nextSessionKey;
3436
+ state.initialSessionApplied = true;
3437
+ } else if (!state.agents.some((agent) => agent.id === state.currentAgentId)) state.currentAgentId = state.agents[0]?.id ?? normalizeAgentId(result.defaultId ?? state.currentAgentId);
3438
+ updateHeader();
3439
+ updateFooter();
3440
+ };
3441
+ const refreshAgents = async () => {
3442
+ try {
3443
+ applyAgentsResult(await client.listAgents());
3444
+ } catch (err) {
3445
+ chatLog.addSystem(`agents list failed: ${String(err)}`);
3446
+ }
3447
+ };
3448
+ const updateAgentFromSessionKey = (key) => {
3449
+ const parsed = parseAgentSessionKey(key);
3450
+ if (!parsed) return;
3451
+ const next = normalizeAgentId(parsed.agentId);
3452
+ if (next !== state.currentAgentId) state.currentAgentId = next;
3453
+ };
3454
+ const resolveModelSelection = (entry) => {
3455
+ return resolveSessionInfoModelSelection({
3456
+ currentProvider: state.sessionInfo.modelProvider,
3457
+ currentModel: state.sessionInfo.model,
3458
+ defaultProvider: lastSessionDefaults?.modelProvider,
3459
+ defaultModel: lastSessionDefaults?.model,
3460
+ entryProvider: entry?.modelProvider,
3461
+ entryModel: entry?.model,
3462
+ overrideProvider: entry?.providerOverride,
3463
+ overrideModel: entry?.modelOverride
3464
+ });
3465
+ };
3466
+ const applySessionInfo = (params) => {
3467
+ const entry = params.entry ?? void 0;
3468
+ const defaults = params.defaults ?? lastSessionDefaults ?? void 0;
3469
+ const previousDefaults = lastSessionDefaults;
3470
+ const defaultsChanged = params.defaults ? previousDefaults?.model !== params.defaults.model || previousDefaults?.modelProvider !== params.defaults.modelProvider || previousDefaults?.contextTokens !== params.defaults.contextTokens : false;
3471
+ if (params.defaults) lastSessionDefaults = params.defaults;
3472
+ const entryUpdatedAt = entry?.updatedAt ?? null;
3473
+ const currentUpdatedAt = state.sessionInfo.updatedAt ?? null;
3474
+ if (!params.force && entryUpdatedAt !== null && currentUpdatedAt !== null && entryUpdatedAt < currentUpdatedAt && !defaultsChanged) return;
3475
+ const next = { ...state.sessionInfo };
3476
+ if (entry?.thinkingLevel !== void 0) next.thinkingLevel = entry.thinkingLevel;
3477
+ if (entry?.fastMode !== void 0) next.fastMode = entry.fastMode;
3478
+ if (entry?.verboseLevel !== void 0) next.verboseLevel = entry.verboseLevel;
3479
+ if (entry?.traceLevel !== void 0) next.traceLevel = entry.traceLevel;
3480
+ if (entry?.reasoningLevel !== void 0) next.reasoningLevel = entry.reasoningLevel;
3481
+ if (entry?.responseUsage !== void 0) next.responseUsage = entry.responseUsage;
3482
+ if (entry?.inputTokens !== void 0) next.inputTokens = entry.inputTokens;
3483
+ if (entry?.outputTokens !== void 0) next.outputTokens = entry.outputTokens;
3484
+ if (entry?.totalTokens !== void 0) next.totalTokens = entry.totalTokens;
3485
+ if (entry?.contextTokens !== void 0 || defaults?.contextTokens !== void 0) next.contextTokens = entry?.contextTokens ?? defaults?.contextTokens ?? state.sessionInfo.contextTokens;
3486
+ if (entry?.displayName !== void 0) next.displayName = entry.displayName;
3487
+ if (entry?.updatedAt !== void 0) next.updatedAt = entry.updatedAt;
3488
+ const selection = resolveModelSelection(entry);
3489
+ if (selection.modelProvider !== void 0) next.modelProvider = selection.modelProvider;
3490
+ if (selection.model !== void 0) next.model = selection.model;
3491
+ state.sessionInfo = next;
3492
+ updateAutocompleteProvider();
3493
+ updateFooter();
3494
+ tui.requestRender();
3495
+ };
3496
+ const runRefreshSessionInfo = async () => {
3497
+ try {
3498
+ const resolveListAgentId = () => {
3499
+ if (state.currentSessionKey === "global" || state.currentSessionKey === "unknown") return;
3500
+ const parsed = parseAgentSessionKey(state.currentSessionKey);
3501
+ return parsed?.agentId ? normalizeAgentId(parsed.agentId) : state.currentAgentId;
3502
+ };
3503
+ const listAgentId = resolveListAgentId();
3504
+ const result = await client.listSessions({
3505
+ includeGlobal: false,
3506
+ includeUnknown: false,
3507
+ agentId: listAgentId
3508
+ });
3509
+ const normalizeMatchKey = (key) => parseAgentSessionKey(key)?.rest ?? key;
3510
+ const currentMatchKey = normalizeMatchKey(state.currentSessionKey);
3511
+ const entry = result.sessions.find((row) => {
3512
+ if (row.key === state.currentSessionKey) return true;
3513
+ return normalizeMatchKey(row.key) === currentMatchKey;
3514
+ });
3515
+ if (entry?.key && entry.key !== state.currentSessionKey) {
3516
+ updateAgentFromSessionKey(entry.key);
3517
+ state.currentSessionKey = entry.key;
3518
+ updateHeader();
3519
+ }
3520
+ applySessionInfo({
3521
+ entry,
3522
+ defaults: result.defaults
3523
+ });
3524
+ } catch (err) {
3525
+ chatLog.addSystem(`sessions list failed: ${String(err)}`);
3526
+ }
3527
+ };
3528
+ const refreshSessionInfo = async () => {
3529
+ refreshSessionInfoPromise = refreshSessionInfoPromise.then(runRefreshSessionInfo, runRefreshSessionInfo);
3530
+ await refreshSessionInfoPromise;
3531
+ };
3532
+ const applySessionInfoFromPatch = (result) => {
3533
+ if (!result?.entry) return;
3534
+ if (result.key && result.key !== state.currentSessionKey) {
3535
+ updateAgentFromSessionKey(result.key);
3536
+ state.currentSessionKey = result.key;
3537
+ updateHeader();
3538
+ }
3539
+ const resolved = result.resolved;
3540
+ applySessionInfo({
3541
+ entry: resolved && (resolved.modelProvider || resolved.model) ? {
3542
+ ...result.entry,
3543
+ modelProvider: resolved.modelProvider ?? result.entry.modelProvider,
3544
+ model: resolved.model ?? result.entry.model
3545
+ } : result.entry,
3546
+ force: true
3547
+ });
3548
+ };
3549
+ const loadHistory = async () => {
3550
+ try {
3551
+ const record = await client.loadHistory({
3552
+ sessionKey: state.currentSessionKey,
3553
+ limit: opts.historyLimit ?? 200
3554
+ });
3555
+ state.currentSessionId = typeof record.sessionId === "string" ? record.sessionId : null;
3556
+ state.sessionInfo.thinkingLevel = record.thinkingLevel ?? state.sessionInfo.thinkingLevel;
3557
+ state.sessionInfo.fastMode = record.fastMode ?? state.sessionInfo.fastMode;
3558
+ state.sessionInfo.verboseLevel = record.verboseLevel ?? state.sessionInfo.verboseLevel;
3559
+ state.sessionInfo.traceLevel = record.traceLevel ?? state.sessionInfo.traceLevel;
3560
+ const showTools = (state.sessionInfo.verboseLevel ?? "off") !== "off";
3561
+ chatLog.clearAll();
3562
+ btw.clear();
3563
+ chatLog.addSystem(`session ${state.currentSessionKey}`);
3564
+ for (const entry of record.messages ?? []) {
3565
+ if (!entry || typeof entry !== "object") continue;
3566
+ const message = entry;
3567
+ if (isCommandMessage(message)) {
3568
+ const text = extractTextFromMessage(message);
3569
+ if (text) chatLog.addSystem(text);
3570
+ continue;
3571
+ }
3572
+ if (message.role === "user") {
3573
+ const text = extractTextFromMessage(message);
3574
+ if (text) chatLog.addUser(text);
3575
+ continue;
3576
+ }
3577
+ if (message.role === "assistant") {
3578
+ const text = extractTextFromMessage(message, { includeThinking: state.showThinking });
3579
+ if (text) chatLog.finalizeAssistant(text);
3580
+ continue;
3581
+ }
3582
+ if (message.role === "toolResult") {
3583
+ if (!showTools) continue;
3584
+ const toolCallId = asString(message.toolCallId, "");
3585
+ const toolName = asString(message.toolName, "tool");
3586
+ chatLog.startTool(toolCallId, toolName, {}).setResult({
3587
+ content: Array.isArray(message.content) ? message.content : [],
3588
+ details: typeof message.details === "object" && message.details ? message.details : void 0
3589
+ }, { isError: Boolean(message.isError) });
3590
+ }
3591
+ }
3592
+ state.historyLoaded = true;
3593
+ } catch (err) {
3594
+ chatLog.addSystem(`history failed: ${String(err)}`);
3595
+ }
3596
+ await refreshSessionInfo();
3597
+ tui.requestRender();
3598
+ };
3599
+ const setSession = async (rawKey) => {
3600
+ const nextKey = resolveSessionKey(rawKey);
3601
+ updateAgentFromSessionKey(nextKey);
3602
+ state.currentSessionKey = nextKey;
3603
+ state.activeChatRunId = null;
3604
+ setActivityStatus("idle");
3605
+ state.currentSessionId = null;
3606
+ state.sessionInfo.updatedAt = null;
3607
+ state.historyLoaded = false;
3608
+ clearLocalRunIds?.();
3609
+ btw.clear();
3610
+ updateHeader();
3611
+ updateFooter();
3612
+ await loadHistory();
3613
+ };
3614
+ const abortActive = async () => {
3615
+ if (!state.activeChatRunId) {
3616
+ chatLog.addSystem("no active run");
3617
+ tui.requestRender();
3618
+ return;
3619
+ }
3620
+ try {
3621
+ await client.abortChat({
3622
+ sessionKey: state.currentSessionKey,
3623
+ runId: state.activeChatRunId
3624
+ });
3625
+ setActivityStatus("aborted");
3626
+ } catch (err) {
3627
+ chatLog.addSystem(`abort failed: ${String(err)}`);
3628
+ setActivityStatus("abort failed");
3629
+ }
3630
+ tui.requestRender();
3631
+ };
3632
+ return {
3633
+ applyAgentsResult,
3634
+ refreshAgents,
3635
+ refreshSessionInfo,
3636
+ applySessionInfoFromPatch,
3637
+ loadHistory,
3638
+ setSession,
3639
+ abortActive
3640
+ };
3641
+ }
3642
+ //#endregion
3643
+ //#region src/tui/tui-submit.ts
3644
+ function createEditorSubmitHandler(params) {
3645
+ return (text) => {
3646
+ const raw = text;
3647
+ const value = raw.trim();
3648
+ params.editor.setText("");
3649
+ if (!value) return;
3650
+ if (raw.startsWith("!") && raw !== "!") {
3651
+ params.editor.addToHistory(raw);
3652
+ params.handleBangLine(raw);
3653
+ return;
3654
+ }
3655
+ params.editor.addToHistory(value);
3656
+ if (value.startsWith("/")) {
3657
+ params.handleCommand(value);
3658
+ return;
3659
+ }
3660
+ params.sendMessage(value);
3661
+ };
3662
+ }
3663
+ function shouldEnableWindowsGitBashPasteFallback(params) {
3664
+ const platform = params?.platform ?? process.platform;
3665
+ const env = params?.env ?? process.env;
3666
+ const termProgram = normalizeLowercaseStringOrEmpty(env.TERM_PROGRAM);
3667
+ if (platform === "darwin") {
3668
+ if (termProgram.includes("iterm") || termProgram.includes("apple_terminal")) return true;
3669
+ return false;
3670
+ }
3671
+ if (platform !== "win32") return false;
3672
+ const msystem = (env.MSYSTEM ?? "").toUpperCase();
3673
+ const shell = env.SHELL ?? "";
3674
+ if (msystem.startsWith("MINGW") || msystem.startsWith("MSYS")) return true;
3675
+ if (normalizeLowercaseStringOrEmpty(shell).includes("bash")) return true;
3676
+ return termProgram.includes("mintty");
3677
+ }
3678
+ function createSubmitBurstCoalescer(params) {
3679
+ const windowMs = Math.max(1, params.burstWindowMs ?? 50);
3680
+ const now = params.now ?? (() => Date.now());
3681
+ const setTimer = params.setTimer ?? setTimeout;
3682
+ const clearTimer = params.clearTimer ?? clearTimeout;
3683
+ let pending = null;
3684
+ let pendingAt = 0;
3685
+ let flushTimer = null;
3686
+ const clearFlushTimer = () => {
3687
+ if (!flushTimer) return;
3688
+ clearTimer(flushTimer);
3689
+ flushTimer = null;
3690
+ };
3691
+ const flushPending = () => {
3692
+ if (pending === null) return;
3693
+ const value = pending;
3694
+ pending = null;
3695
+ pendingAt = 0;
3696
+ clearFlushTimer();
3697
+ params.submit(value);
3698
+ };
3699
+ const scheduleFlush = () => {
3700
+ clearFlushTimer();
3701
+ flushTimer = setTimer(() => {
3702
+ flushPending();
3703
+ }, windowMs);
3704
+ };
3705
+ return (value) => {
3706
+ if (!params.enabled) {
3707
+ params.submit(value);
3708
+ return;
3709
+ }
3710
+ if (value.includes("\n")) {
3711
+ flushPending();
3712
+ params.submit(value);
3713
+ return;
3714
+ }
3715
+ const ts = now();
3716
+ if (pending === null) {
3717
+ pending = value;
3718
+ pendingAt = ts;
3719
+ scheduleFlush();
3720
+ return;
3721
+ }
3722
+ if (ts - pendingAt <= windowMs) {
3723
+ pending = `${pending}\n${value}`;
3724
+ pendingAt = ts;
3725
+ scheduleFlush();
3726
+ return;
3727
+ }
3728
+ flushPending();
3729
+ pending = value;
3730
+ pendingAt = ts;
3731
+ scheduleFlush();
3732
+ };
3733
+ }
3734
+ //#endregion
3735
+ //#region src/tui/tui-waiting.ts
3736
+ const defaultWaitingPhrases = [
3737
+ "flibbertigibbeting",
3738
+ "kerfuffling",
3739
+ "dillydallying",
3740
+ "twiddling thumbs",
3741
+ "noodling",
3742
+ "bamboozling",
3743
+ "moseying",
3744
+ "hobnobbing",
3745
+ "pondering",
3746
+ "conjuring"
3747
+ ];
3748
+ function pickWaitingPhrase(tick, phrases = defaultWaitingPhrases) {
3749
+ return phrases[Math.floor(tick / 10) % phrases.length] ?? phrases[0] ?? "waiting";
3750
+ }
3751
+ function shimmerText(theme, text, tick) {
3752
+ const width = 6;
3753
+ const hi = (ch) => theme.bold(theme.accentSoft(ch));
3754
+ const pos = tick % (text.length + width);
3755
+ const start = Math.max(0, pos - width);
3756
+ const end = Math.min(text.length - 1, pos);
3757
+ let out = "";
3758
+ for (let i = 0; i < text.length; i++) {
3759
+ const ch = text[i];
3760
+ out += i >= start && i <= end ? hi(ch) : theme.dim(ch);
3761
+ }
3762
+ return out;
3763
+ }
3764
+ function buildWaitingStatusMessage(params) {
3765
+ const phrase = pickWaitingPhrase(params.tick, params.phrases);
3766
+ return `${shimmerText(params.theme, `${phrase}…`, params.tick)} • ${params.elapsed} | ${params.connectionStatus}`;
3767
+ }
3768
+ //#endregion
3769
+ //#region src/tui/tui.ts
3770
+ const GENESIS_CLI_WRAPPER_PATH = fileURLToPath(new URL("../../genesis.mjs", import.meta.url));
3771
+ const GENESIS_RUN_NODE_SCRIPT_PATH = fileURLToPath(new URL("../../scripts/run-node.mjs", import.meta.url));
3772
+ const GENESIS_DIST_ENTRY_JS_PATH = fileURLToPath(new URL("../../dist/entry.js", import.meta.url));
3773
+ const GENESIS_DIST_ENTRY_MJS_PATH = fileURLToPath(new URL("../../dist/entry.mjs", import.meta.url));
3774
+ const OPENAI_CODEX_PROVIDER = "openai-codex";
3775
+ /** Resolve the absolute path to the `codex` CLI binary, or `null` if not installed. */
3776
+ function resolveCodexCliBin() {
3777
+ try {
3778
+ return execFileSync(process.platform === "win32" ? "where" : "which", ["codex"], { encoding: "utf8" }).trim().split(/\r?\n/)[0] || null;
3779
+ } catch {
3780
+ return null;
3781
+ }
3782
+ }
3783
+ function resolveLocalAuthCliInvocation(params) {
3784
+ const hasDistEntry = params?.hasDistEntry ?? (existsSync(GENESIS_DIST_ENTRY_JS_PATH) || existsSync(GENESIS_DIST_ENTRY_MJS_PATH));
3785
+ const hasRunNodeScript = params?.hasRunNodeScript ?? existsSync(GENESIS_RUN_NODE_SCRIPT_PATH);
3786
+ const command = params?.execPath ?? process.execPath;
3787
+ const wrapperPath = params?.wrapperPath ?? GENESIS_CLI_WRAPPER_PATH;
3788
+ const runNodePath = params?.runNodePath ?? GENESIS_RUN_NODE_SCRIPT_PATH;
3789
+ return hasDistEntry || !hasRunNodeScript ? {
3790
+ command,
3791
+ args: [
3792
+ wrapperPath,
3793
+ "models",
3794
+ "auth",
3795
+ "login"
3796
+ ]
3797
+ } : {
3798
+ command,
3799
+ args: [
3800
+ runNodePath,
3801
+ "models",
3802
+ "auth",
3803
+ "login"
3804
+ ]
3805
+ };
3806
+ }
3807
+ function resolveLocalAuthSpawnOptions(params) {
3808
+ return (params.platform ?? process.platform) === "win32" && /\.(cmd|bat)$/iu.test(params.command.trim()) ? { shell: true } : {};
3809
+ }
3810
+ function resolveLocalAuthSpawnCwd(params) {
3811
+ const defaultCwd = params.defaultCwd ?? process.cwd();
3812
+ const entryArg = params.args[0]?.trim();
3813
+ if (!entryArg) return defaultCwd;
3814
+ const entryBase = path.basename(entryArg).toLowerCase();
3815
+ if (entryBase === "genesis.mjs") return path.dirname(entryArg);
3816
+ if (entryBase === "run-node.mjs") return path.dirname(path.dirname(entryArg));
3817
+ return defaultCwd;
3818
+ }
3819
+ function resolveTuiSessionKey(params) {
3820
+ const trimmed = (params.raw ?? "").trim();
3821
+ if (!trimmed) {
3822
+ if (params.sessionScope === "global") return "global";
3823
+ return buildAgentMainSessionKey({
3824
+ agentId: params.currentAgentId,
3825
+ mainKey: params.sessionMainKey
3826
+ });
3827
+ }
3828
+ if (trimmed === "global" || trimmed === "unknown") return trimmed;
3829
+ if (trimmed.startsWith("agent:")) return normalizeLowercaseStringOrEmpty(trimmed);
3830
+ return `agent:${params.currentAgentId}:${normalizeLowercaseStringOrEmpty(trimmed)}`;
3831
+ }
3832
+ function resolveInitialTuiAgentId(params) {
3833
+ const parsed = parseAgentSessionKey((params.initialSessionInput ?? "").trim());
3834
+ if (parsed?.agentId) return normalizeAgentId(parsed.agentId);
3835
+ const inferredFromWorkspace = resolveAgentIdByWorkspacePath(params.cfg, params.cwd ?? process.cwd());
3836
+ if (inferredFromWorkspace) return inferredFromWorkspace;
3837
+ return normalizeAgentId(params.fallbackAgentId);
3838
+ }
3839
+ function resolveGatewayDisconnectState(reason) {
3840
+ const reasonLabel = reason?.trim() ? reason.trim() : "closed";
3841
+ if (/pairing required/i.test(reasonLabel)) return {
3842
+ connectionStatus: `gateway disconnected: ${reasonLabel}`,
3843
+ activityStatus: "pairing required: run genesis devices list",
3844
+ pairingHint: "Pairing required. Run `genesis devices list`, approve your request ID, then reconnect."
3845
+ };
3846
+ return {
3847
+ connectionStatus: `gateway disconnected: ${reasonLabel}`,
3848
+ activityStatus: "idle"
3849
+ };
3850
+ }
3851
+ function createBackspaceDeduper(params) {
3852
+ const dedupeWindowMs = Math.max(0, Math.floor(params?.dedupeWindowMs ?? 8));
3853
+ const now = params?.now ?? (() => Date.now());
3854
+ let lastBackspaceAt = -1;
3855
+ return (data) => {
3856
+ if (!matchesKey(data, Key.backspace)) return data;
3857
+ const ts = now();
3858
+ if (lastBackspaceAt >= 0 && ts - lastBackspaceAt <= dedupeWindowMs) return "";
3859
+ lastBackspaceAt = ts;
3860
+ return data;
3861
+ };
3862
+ }
3863
+ function isIgnorableTuiStopError(error) {
3864
+ if (!error || typeof error !== "object") return false;
3865
+ const err = error;
3866
+ const code = typeof err.code === "string" ? err.code : "";
3867
+ const syscall = typeof err.syscall === "string" ? err.syscall : "";
3868
+ const message = typeof err.message === "string" ? err.message : "";
3869
+ if (code === "EBADF" && syscall === "setRawMode") return true;
3870
+ return /setRawMode/i.test(message) && /EBADF/i.test(message);
3871
+ }
3872
+ function stopTuiSafely(stop) {
3873
+ try {
3874
+ stop();
3875
+ } catch (error) {
3876
+ if (!isIgnorableTuiStopError(error)) throw error;
3877
+ }
3878
+ }
3879
+ async function drainAndStopTuiSafely(tui) {
3880
+ if (typeof tui.terminal?.drainInput === "function") try {
3881
+ await tui.terminal.drainInput();
3882
+ } catch {}
3883
+ stopTuiSafely(() => tui.stop());
3884
+ }
3885
+ function resolveCtrlCAction(params) {
3886
+ const exitWindowMs = Math.max(1, Math.floor(params.exitWindowMs ?? 1e3));
3887
+ if (params.hasInput) return {
3888
+ action: "clear",
3889
+ nextLastCtrlCAt: params.now
3890
+ };
3891
+ if (params.now - params.lastCtrlCAt <= exitWindowMs) return {
3892
+ action: "exit",
3893
+ nextLastCtrlCAt: params.lastCtrlCAt
3894
+ };
3895
+ return {
3896
+ action: "warn",
3897
+ nextLastCtrlCAt: params.now
3898
+ };
3899
+ }
3900
+ async function runTui(opts) {
3901
+ const isLocalMode = opts.local === true;
3902
+ const config = loadConfig();
3903
+ const initialSessionInput = (opts.session ?? "").trim();
3904
+ let sessionScope = config.session?.scope ?? "per-sender";
3905
+ let sessionMainKey = normalizeMainKey(config.session?.mainKey);
3906
+ let agentDefaultId = resolveDefaultAgentId(config);
3907
+ let currentAgentId = resolveInitialTuiAgentId({
3908
+ cfg: config,
3909
+ fallbackAgentId: agentDefaultId,
3910
+ initialSessionInput,
3911
+ cwd: process.cwd()
3912
+ });
3913
+ let agents = [];
3914
+ const agentNames = /* @__PURE__ */ new Map();
3915
+ let currentSessionKey = "";
3916
+ let initialSessionApplied = false;
3917
+ let currentSessionId = null;
3918
+ let activeChatRunId = null;
3919
+ let pendingOptimisticUserMessage = false;
3920
+ let historyLoaded = false;
3921
+ let isConnected = false;
3922
+ let wasDisconnected = false;
3923
+ let toolsExpanded = false;
3924
+ let showThinking = false;
3925
+ let pairingHintShown = false;
3926
+ const localRunIds = /* @__PURE__ */ new Set();
3927
+ const localBtwRunIds = /* @__PURE__ */ new Set();
3928
+ const deliverDefault = opts.deliver ?? false;
3929
+ const autoMessage = opts.message?.trim();
3930
+ let autoMessageSent = false;
3931
+ let sessionInfo = {};
3932
+ let lastCtrlCAt = 0;
3933
+ let exitRequested = false;
3934
+ let activityStatus = "idle";
3935
+ let connectionStatus = isLocalMode ? "starting local runtime" : "connecting";
3936
+ let statusTimeout = null;
3937
+ let statusTimer = null;
3938
+ let statusStartedAt = null;
3939
+ let lastActivityStatus = activityStatus;
3940
+ const state = {
3941
+ get agentDefaultId() {
3942
+ return agentDefaultId;
3943
+ },
3944
+ set agentDefaultId(value) {
3945
+ agentDefaultId = value;
3946
+ },
3947
+ get sessionMainKey() {
3948
+ return sessionMainKey;
3949
+ },
3950
+ set sessionMainKey(value) {
3951
+ sessionMainKey = value;
3952
+ },
3953
+ get sessionScope() {
3954
+ return sessionScope;
3955
+ },
3956
+ set sessionScope(value) {
3957
+ sessionScope = value;
3958
+ },
3959
+ get agents() {
3960
+ return agents;
3961
+ },
3962
+ set agents(value) {
3963
+ agents = value;
3964
+ },
3965
+ get currentAgentId() {
3966
+ return currentAgentId;
3967
+ },
3968
+ set currentAgentId(value) {
3969
+ currentAgentId = value;
3970
+ },
3971
+ get currentSessionKey() {
3972
+ return currentSessionKey;
3973
+ },
3974
+ set currentSessionKey(value) {
3975
+ currentSessionKey = value;
3976
+ },
3977
+ get currentSessionId() {
3978
+ return currentSessionId;
3979
+ },
3980
+ set currentSessionId(value) {
3981
+ currentSessionId = value;
3982
+ },
3983
+ get activeChatRunId() {
3984
+ return activeChatRunId;
3985
+ },
3986
+ set activeChatRunId(value) {
3987
+ activeChatRunId = value;
3988
+ },
3989
+ get pendingOptimisticUserMessage() {
3990
+ return pendingOptimisticUserMessage;
3991
+ },
3992
+ set pendingOptimisticUserMessage(value) {
3993
+ pendingOptimisticUserMessage = value;
3994
+ },
3995
+ get historyLoaded() {
3996
+ return historyLoaded;
3997
+ },
3998
+ set historyLoaded(value) {
3999
+ historyLoaded = value;
4000
+ },
4001
+ get sessionInfo() {
4002
+ return sessionInfo;
4003
+ },
4004
+ set sessionInfo(value) {
4005
+ sessionInfo = value;
4006
+ },
4007
+ get initialSessionApplied() {
4008
+ return initialSessionApplied;
4009
+ },
4010
+ set initialSessionApplied(value) {
4011
+ initialSessionApplied = value;
4012
+ },
4013
+ get isConnected() {
4014
+ return isConnected;
4015
+ },
4016
+ set isConnected(value) {
4017
+ isConnected = value;
4018
+ },
4019
+ get autoMessageSent() {
4020
+ return autoMessageSent;
4021
+ },
4022
+ set autoMessageSent(value) {
4023
+ autoMessageSent = value;
4024
+ },
4025
+ get toolsExpanded() {
4026
+ return toolsExpanded;
4027
+ },
4028
+ set toolsExpanded(value) {
4029
+ toolsExpanded = value;
4030
+ },
4031
+ get showThinking() {
4032
+ return showThinking;
4033
+ },
4034
+ set showThinking(value) {
4035
+ showThinking = value;
4036
+ },
4037
+ get connectionStatus() {
4038
+ return connectionStatus;
4039
+ },
4040
+ set connectionStatus(value) {
4041
+ connectionStatus = value;
4042
+ },
4043
+ get activityStatus() {
4044
+ return activityStatus;
4045
+ },
4046
+ set activityStatus(value) {
4047
+ activityStatus = value;
4048
+ },
4049
+ get statusTimeout() {
4050
+ return statusTimeout;
4051
+ },
4052
+ set statusTimeout(value) {
4053
+ statusTimeout = value;
4054
+ },
4055
+ get lastCtrlCAt() {
4056
+ return lastCtrlCAt;
4057
+ },
4058
+ set lastCtrlCAt(value) {
4059
+ lastCtrlCAt = value;
4060
+ }
4061
+ };
4062
+ const noteLocalRunId = (runId) => {
4063
+ if (!runId) return;
4064
+ localRunIds.add(runId);
4065
+ if (localRunIds.size > 200) {
4066
+ const [first] = localRunIds;
4067
+ if (first) localRunIds.delete(first);
4068
+ }
4069
+ };
4070
+ const forgetLocalRunId = (runId) => {
4071
+ localRunIds.delete(runId);
4072
+ };
4073
+ const isLocalRunId = (runId) => localRunIds.has(runId);
4074
+ const clearLocalRunIds = () => {
4075
+ localRunIds.clear();
4076
+ };
4077
+ const noteLocalBtwRunId = (runId) => {
4078
+ if (!runId) return;
4079
+ localBtwRunIds.add(runId);
4080
+ if (localBtwRunIds.size > 200) {
4081
+ const [first] = localBtwRunIds;
4082
+ if (first) localBtwRunIds.delete(first);
4083
+ }
4084
+ };
4085
+ const forgetLocalBtwRunId = (runId) => {
4086
+ localBtwRunIds.delete(runId);
4087
+ };
4088
+ const isLocalBtwRunId = (runId) => localBtwRunIds.has(runId);
4089
+ const clearLocalBtwRunIds = () => {
4090
+ localBtwRunIds.clear();
4091
+ };
4092
+ const client = opts.local ? new EmbeddedTuiBackend() : await GatewayChatClient.connect({
4093
+ url: opts.url,
4094
+ token: opts.token,
4095
+ password: opts.password
4096
+ });
4097
+ const previousConsoleSubsystemFilter = isLocalMode ? loggingState.consoleSubsystemFilter ? [...loggingState.consoleSubsystemFilter] : null : null;
4098
+ if (isLocalMode) setConsoleSubsystemFilter(["__genesis_tui_quiet__"]);
4099
+ const tui = new TUI(new ProcessTerminal());
4100
+ const dedupeBackspace = createBackspaceDeduper();
4101
+ tui.addInputListener((data) => {
4102
+ const next = dedupeBackspace(data);
4103
+ if (next.length === 0) return { consume: true };
4104
+ return { data: next };
4105
+ });
4106
+ const header = new Text("", 1, 0);
4107
+ const statusContainer = new Container();
4108
+ const footer = new Text("", 1, 0);
4109
+ const chatLog = new ChatLog();
4110
+ const editor = new CustomEditor(tui, editorTheme);
4111
+ const root = new Container();
4112
+ root.addChild(header);
4113
+ root.addChild(chatLog);
4114
+ root.addChild(statusContainer);
4115
+ root.addChild(footer);
4116
+ root.addChild(editor);
4117
+ const updateAutocompleteProvider = () => {
4118
+ editor.setAutocompleteProvider(new CombinedAutocompleteProvider(getSlashCommands({
4119
+ cfg: config,
4120
+ local: isLocalMode,
4121
+ provider: sessionInfo.modelProvider,
4122
+ model: sessionInfo.model
4123
+ }), process.cwd()));
4124
+ };
4125
+ tui.addChild(root);
4126
+ tui.setFocus(editor);
4127
+ const formatSessionKey = (key) => {
4128
+ if (key === "global" || key === "unknown") return key;
4129
+ return parseAgentSessionKey(key)?.rest ?? key;
4130
+ };
4131
+ const formatAgentLabel = (id) => {
4132
+ const name = agentNames.get(id);
4133
+ return name ? `${id} (${name})` : id;
4134
+ };
4135
+ const resolveSessionKey = (raw) => {
4136
+ return resolveTuiSessionKey({
4137
+ raw,
4138
+ sessionScope,
4139
+ currentAgentId,
4140
+ sessionMainKey
4141
+ });
4142
+ };
4143
+ currentSessionKey = resolveSessionKey(initialSessionInput);
4144
+ const updateHeader = () => {
4145
+ const sessionLabel = formatSessionKey(currentSessionKey);
4146
+ const agentLabel = formatAgentLabel(currentAgentId);
4147
+ header.setText(theme.header(`genesis tui - ${client.connection.url} - agent ${agentLabel} - session ${sessionLabel}`));
4148
+ };
4149
+ const busyStates = new Set([
4150
+ "sending",
4151
+ "waiting",
4152
+ "streaming",
4153
+ "running"
4154
+ ]);
4155
+ let statusText = null;
4156
+ let statusLoader = null;
4157
+ const formatElapsed = (startMs) => {
4158
+ const totalSeconds = Math.max(0, Math.floor((Date.now() - startMs) / 1e3));
4159
+ if (totalSeconds < 60) return `${totalSeconds}s`;
4160
+ return `${Math.floor(totalSeconds / 60)}m ${totalSeconds % 60}s`;
4161
+ };
4162
+ const ensureStatusText = () => {
4163
+ if (statusText) return;
4164
+ statusContainer.clear();
4165
+ statusLoader?.stop();
4166
+ statusLoader = null;
4167
+ statusText = new Text("", 1, 0);
4168
+ statusContainer.addChild(statusText);
4169
+ };
4170
+ const ensureStatusLoader = () => {
4171
+ if (statusLoader) return;
4172
+ statusContainer.clear();
4173
+ statusText = null;
4174
+ statusLoader = new Loader(tui, (spinner) => theme.accent(spinner), (text) => theme.bold(theme.accentSoft(text)), "");
4175
+ statusContainer.addChild(statusLoader);
4176
+ };
4177
+ let waitingTick = 0;
4178
+ let waitingTimer = null;
4179
+ let waitingPhrase = null;
4180
+ const updateBusyStatusMessage = () => {
4181
+ if (!statusLoader || !statusStartedAt) return;
4182
+ const elapsed = formatElapsed(statusStartedAt);
4183
+ if (activityStatus === "waiting") {
4184
+ waitingTick++;
4185
+ statusLoader.setMessage(buildWaitingStatusMessage({
4186
+ theme,
4187
+ tick: waitingTick,
4188
+ elapsed,
4189
+ connectionStatus,
4190
+ phrases: waitingPhrase ? [waitingPhrase] : void 0
4191
+ }));
4192
+ return;
4193
+ }
4194
+ statusLoader.setMessage(`${activityStatus} • ${elapsed} | ${connectionStatus}`);
4195
+ };
4196
+ const startStatusTimer = () => {
4197
+ if (statusTimer) return;
4198
+ statusTimer = setInterval(() => {
4199
+ if (!busyStates.has(activityStatus)) return;
4200
+ updateBusyStatusMessage();
4201
+ }, 1e3);
4202
+ };
4203
+ const stopStatusTimer = () => {
4204
+ if (!statusTimer) return;
4205
+ clearInterval(statusTimer);
4206
+ statusTimer = null;
4207
+ };
4208
+ const startWaitingTimer = () => {
4209
+ if (waitingTimer) return;
4210
+ if (!waitingPhrase) waitingPhrase = defaultWaitingPhrases[Math.floor(Math.random() * defaultWaitingPhrases.length)] ?? defaultWaitingPhrases[0] ?? "waiting";
4211
+ waitingTick = 0;
4212
+ waitingTimer = setInterval(() => {
4213
+ if (activityStatus !== "waiting") return;
4214
+ updateBusyStatusMessage();
4215
+ }, 120);
4216
+ };
4217
+ const stopWaitingTimer = () => {
4218
+ if (!waitingTimer) return;
4219
+ clearInterval(waitingTimer);
4220
+ waitingTimer = null;
4221
+ waitingPhrase = null;
4222
+ };
4223
+ const renderStatus = () => {
4224
+ if (busyStates.has(activityStatus)) {
4225
+ if (!statusStartedAt || lastActivityStatus !== activityStatus) statusStartedAt = Date.now();
4226
+ ensureStatusLoader();
4227
+ if (activityStatus === "waiting") {
4228
+ stopStatusTimer();
4229
+ startWaitingTimer();
4230
+ } else {
4231
+ stopWaitingTimer();
4232
+ startStatusTimer();
4233
+ }
4234
+ updateBusyStatusMessage();
4235
+ } else {
4236
+ statusStartedAt = null;
4237
+ stopStatusTimer();
4238
+ stopWaitingTimer();
4239
+ statusLoader?.stop();
4240
+ statusLoader = null;
4241
+ ensureStatusText();
4242
+ const text = activityStatus ? `${connectionStatus} | ${activityStatus}` : connectionStatus;
4243
+ statusText?.setText(theme.dim(text));
4244
+ }
4245
+ lastActivityStatus = activityStatus;
4246
+ };
4247
+ const setConnectionStatus = (text, ttlMs) => {
4248
+ connectionStatus = text;
4249
+ renderStatus();
4250
+ if (statusTimeout) clearTimeout(statusTimeout);
4251
+ if (ttlMs && ttlMs > 0) statusTimeout = setTimeout(() => {
4252
+ connectionStatus = isConnected ? isLocalMode ? "local ready" : "connected" : isLocalMode ? "local stopped" : "disconnected";
4253
+ renderStatus();
4254
+ }, ttlMs);
4255
+ };
4256
+ const setActivityStatus = (text) => {
4257
+ activityStatus = text;
4258
+ renderStatus();
4259
+ };
4260
+ const withTuiSuspended = async (work) => {
4261
+ await drainAndStopTuiSafely(tui);
4262
+ if (isLocalMode) setConsoleSubsystemFilter(previousConsoleSubsystemFilter);
4263
+ try {
4264
+ return await work();
4265
+ } finally {
4266
+ if (isLocalMode) setConsoleSubsystemFilter(["__genesis_tui_quiet__"]);
4267
+ tui.start();
4268
+ tui.setFocus(editor);
4269
+ updateHeader();
4270
+ updateFooter();
4271
+ tui.requestRender(true);
4272
+ }
4273
+ };
4274
+ const runAuthFlow = isLocalMode ? async (params) => await withTuiSuspended(async () => await new Promise((resolve, reject) => {
4275
+ const provider = params.provider?.trim() || void 0;
4276
+ const codexBin = provider === OPENAI_CODEX_PROVIDER || !provider && sessionInfo.modelProvider === OPENAI_CODEX_PROVIDER ? resolveCodexCliBin() : null;
4277
+ let command;
4278
+ let args;
4279
+ if (codexBin) {
4280
+ command = codexBin;
4281
+ args = ["login"];
4282
+ } else {
4283
+ ({command, args} = resolveLocalAuthCliInvocation());
4284
+ if (provider) args.push("--provider", provider);
4285
+ }
4286
+ const child = spawn(command, args, {
4287
+ cwd: resolveLocalAuthSpawnCwd({
4288
+ args,
4289
+ defaultCwd: process.cwd()
4290
+ }),
4291
+ env: process.env,
4292
+ stdio: "inherit",
4293
+ ...resolveLocalAuthSpawnOptions({ command })
4294
+ });
4295
+ child.once("error", reject);
4296
+ child.once("exit", (exitCode, signal) => {
4297
+ resolve({
4298
+ exitCode,
4299
+ signal
4300
+ });
4301
+ });
4302
+ })) : void 0;
4303
+ const updateFooter = () => {
4304
+ const sessionKeyLabel = formatSessionKey(currentSessionKey);
4305
+ const sessionLabel = sessionInfo.displayName ? `${sessionKeyLabel} (${sessionInfo.displayName})` : sessionKeyLabel;
4306
+ const agentLabel = formatAgentLabel(currentAgentId);
4307
+ const modelLabel = sessionInfo.model ? sessionInfo.modelProvider ? `${sessionInfo.modelProvider}/${sessionInfo.model}` : sessionInfo.model : "unknown";
4308
+ const tokens = formatTokens(sessionInfo.totalTokens ?? null, sessionInfo.contextTokens ?? null);
4309
+ const think = sessionInfo.thinkingLevel ?? "off";
4310
+ const fast = sessionInfo.fastMode === true;
4311
+ const verbose = sessionInfo.verboseLevel ?? "off";
4312
+ const reasoning = sessionInfo.reasoningLevel ?? "off";
4313
+ const reasoningLabel = reasoning === "on" ? "reasoning" : reasoning === "stream" ? "reasoning:stream" : null;
4314
+ const footerParts = [
4315
+ `agent ${agentLabel}`,
4316
+ `session ${sessionLabel}`,
4317
+ modelLabel,
4318
+ think !== "off" ? `think ${think}` : null,
4319
+ fast ? "fast" : null,
4320
+ verbose !== "off" ? `verbose ${verbose}` : null,
4321
+ reasoningLabel,
4322
+ tokens
4323
+ ].filter(Boolean);
4324
+ footer.setText(theme.dim(footerParts.join(" | ")));
4325
+ };
4326
+ const { openOverlay, closeOverlay } = createOverlayHandlers(tui, editor);
4327
+ const btw = {
4328
+ showResult: (params) => {
4329
+ chatLog.showBtw(params);
4330
+ },
4331
+ clear: () => {
4332
+ chatLog.dismissBtw();
4333
+ }
4334
+ };
4335
+ const { refreshAgents, refreshSessionInfo, applySessionInfoFromPatch, loadHistory, setSession, abortActive } = createSessionActions({
4336
+ client,
4337
+ chatLog,
4338
+ btw,
4339
+ tui,
4340
+ opts,
4341
+ state,
4342
+ agentNames,
4343
+ initialSessionInput,
4344
+ initialSessionAgentId: (() => {
4345
+ if (!initialSessionInput) return null;
4346
+ const parsed = parseAgentSessionKey(initialSessionInput);
4347
+ return parsed ? normalizeAgentId(parsed.agentId) : null;
4348
+ })(),
4349
+ resolveSessionKey,
4350
+ updateHeader,
4351
+ updateFooter,
4352
+ updateAutocompleteProvider,
4353
+ setActivityStatus,
4354
+ clearLocalRunIds
4355
+ });
4356
+ const { handleChatEvent, handleAgentEvent, handleBtwEvent } = createEventHandlers({
4357
+ chatLog,
4358
+ btw,
4359
+ tui,
4360
+ state,
4361
+ localMode: isLocalMode,
4362
+ setActivityStatus,
4363
+ refreshSessionInfo,
4364
+ loadHistory,
4365
+ noteLocalRunId,
4366
+ isLocalRunId,
4367
+ forgetLocalRunId,
4368
+ clearLocalRunIds,
4369
+ isLocalBtwRunId,
4370
+ forgetLocalBtwRunId,
4371
+ clearLocalBtwRunIds
4372
+ });
4373
+ const requestExit = () => {
4374
+ if (exitRequested) return;
4375
+ exitRequested = true;
4376
+ client.stop();
4377
+ drainAndStopTuiSafely(tui).then(() => {
4378
+ process.exit(0);
4379
+ });
4380
+ };
4381
+ const { handleCommand, sendMessage, openModelSelector, openAgentSelector, openSessionSelector } = createCommandHandlers({
4382
+ client,
4383
+ chatLog,
4384
+ tui,
4385
+ opts,
4386
+ state,
4387
+ deliverDefault,
4388
+ openOverlay,
4389
+ closeOverlay,
4390
+ refreshSessionInfo,
4391
+ applySessionInfoFromPatch,
4392
+ loadHistory,
4393
+ setSession,
4394
+ refreshAgents,
4395
+ abortActive,
4396
+ setActivityStatus,
4397
+ formatSessionKey,
4398
+ noteLocalRunId,
4399
+ noteLocalBtwRunId,
4400
+ forgetLocalRunId,
4401
+ forgetLocalBtwRunId,
4402
+ runAuthFlow,
4403
+ requestExit
4404
+ });
4405
+ const { runLocalShellLine } = createLocalShellRunner({
4406
+ chatLog,
4407
+ tui,
4408
+ openOverlay,
4409
+ closeOverlay
4410
+ });
4411
+ updateAutocompleteProvider();
4412
+ editor.onSubmit = createSubmitBurstCoalescer({
4413
+ submit: createEditorSubmitHandler({
4414
+ editor,
4415
+ handleCommand,
4416
+ sendMessage,
4417
+ handleBangLine: runLocalShellLine
4418
+ }),
4419
+ enabled: shouldEnableWindowsGitBashPasteFallback()
4420
+ });
4421
+ editor.onEscape = () => {
4422
+ if (chatLog.hasVisibleBtw()) {
4423
+ chatLog.dismissBtw();
4424
+ tui.requestRender();
4425
+ return;
4426
+ }
4427
+ abortActive();
4428
+ };
4429
+ const handleCtrlC = () => {
4430
+ const now = Date.now();
4431
+ const decision = resolveCtrlCAction({
4432
+ hasInput: editor.getText().trim().length > 0,
4433
+ now,
4434
+ lastCtrlCAt
4435
+ });
4436
+ lastCtrlCAt = decision.nextLastCtrlCAt;
4437
+ if (decision.action === "clear") {
4438
+ editor.setText("");
4439
+ setActivityStatus("cleared input; press ctrl+c again to exit");
4440
+ tui.requestRender();
4441
+ return;
4442
+ }
4443
+ if (decision.action === "exit") {
4444
+ requestExit();
4445
+ return;
4446
+ }
4447
+ setActivityStatus("press ctrl+c again to exit");
4448
+ tui.requestRender();
4449
+ };
4450
+ editor.onCtrlC = () => {
4451
+ handleCtrlC();
4452
+ };
4453
+ editor.onCtrlD = () => {
4454
+ requestExit();
4455
+ };
4456
+ editor.onCtrlO = () => {
4457
+ toolsExpanded = !toolsExpanded;
4458
+ chatLog.setToolsExpanded(toolsExpanded);
4459
+ setActivityStatus(toolsExpanded ? "tools expanded" : "tools collapsed");
4460
+ tui.requestRender();
4461
+ };
4462
+ editor.onCtrlL = () => {
4463
+ openModelSelector();
4464
+ };
4465
+ editor.onCtrlG = () => {
4466
+ openAgentSelector();
4467
+ };
4468
+ editor.onCtrlP = () => {
4469
+ openSessionSelector();
4470
+ };
4471
+ editor.onCtrlT = () => {
4472
+ showThinking = !showThinking;
4473
+ loadHistory();
4474
+ };
4475
+ tui.addInputListener((data) => {
4476
+ if (!chatLog.hasVisibleBtw()) return;
4477
+ if (editor.getText().length > 0) return;
4478
+ if (matchesKey(data, "enter")) {
4479
+ chatLog.dismissBtw();
4480
+ tui.requestRender();
4481
+ return { consume: true };
4482
+ }
4483
+ });
4484
+ client.onEvent = (evt) => {
4485
+ if (evt.event === "chat") handleChatEvent(evt.payload);
4486
+ if (evt.event === "chat.side_result") handleBtwEvent(evt.payload);
4487
+ if (evt.event === "agent") handleAgentEvent(evt.payload);
4488
+ };
4489
+ client.onConnected = () => {
4490
+ isConnected = true;
4491
+ pairingHintShown = false;
4492
+ const reconnected = wasDisconnected;
4493
+ wasDisconnected = false;
4494
+ setConnectionStatus(isLocalMode ? "local ready" : "connected");
4495
+ (async () => {
4496
+ await refreshAgents();
4497
+ updateHeader();
4498
+ await loadHistory();
4499
+ setConnectionStatus(isLocalMode ? "local ready" : reconnected ? "gateway reconnected" : "gateway connected", 4e3);
4500
+ tui.requestRender();
4501
+ if (!autoMessageSent && autoMessage) {
4502
+ autoMessageSent = true;
4503
+ await sendMessage(autoMessage);
4504
+ }
4505
+ updateFooter();
4506
+ tui.requestRender();
4507
+ })();
4508
+ };
4509
+ client.onDisconnected = (reason) => {
4510
+ isConnected = false;
4511
+ wasDisconnected = true;
4512
+ historyLoaded = false;
4513
+ const disconnectState = isLocalMode ? {
4514
+ connectionStatus: `local runtime stopped${reason ? `: ${reason}` : ""}`,
4515
+ activityStatus: "idle",
4516
+ pairingHint: void 0
4517
+ } : resolveGatewayDisconnectState(reason);
4518
+ setConnectionStatus(disconnectState.connectionStatus, 5e3);
4519
+ setActivityStatus(disconnectState.activityStatus);
4520
+ if (disconnectState.pairingHint && !pairingHintShown) {
4521
+ pairingHintShown = true;
4522
+ chatLog.addSystem(disconnectState.pairingHint);
4523
+ }
4524
+ updateFooter();
4525
+ tui.requestRender();
4526
+ };
4527
+ client.onGap = (info) => {
4528
+ setConnectionStatus(`event gap: expected ${info.expected}, got ${info.received}`, 5e3);
4529
+ tui.requestRender();
4530
+ };
4531
+ updateHeader();
4532
+ setConnectionStatus(isLocalMode ? "starting local runtime" : "connecting");
4533
+ updateFooter();
4534
+ const sigintHandler = () => {
4535
+ handleCtrlC();
4536
+ };
4537
+ const sigtermHandler = () => {
4538
+ requestExit();
4539
+ };
4540
+ process.on("SIGINT", sigintHandler);
4541
+ process.on("SIGTERM", sigtermHandler);
4542
+ tui.start();
4543
+ client.start();
4544
+ await new Promise((resolve) => {
4545
+ const finish = () => {
4546
+ if (isLocalMode) setConsoleSubsystemFilter(previousConsoleSubsystemFilter);
4547
+ process.removeListener("SIGINT", sigintHandler);
4548
+ process.removeListener("SIGTERM", sigtermHandler);
4549
+ resolve();
4550
+ };
4551
+ process.once("exit", finish);
4552
+ });
4553
+ }
4554
+ //#endregion
4555
+ //#region src/cli/tui-cli.ts
4556
+ function registerTuiCli(program) {
4557
+ program.command("tui").alias("terminal").alias("chat").description("Open a terminal UI connected to the Gateway").option("--local", "Run against the local embedded agent runtime", false).option("--url <url>", "Gateway WebSocket URL (defaults to gateway.remote.url when configured)").option("--token <token>", "Gateway token (if required)").option("--password <password>", "Gateway password (if required)").option("--session <key>", "Session key (default: \"main\", or \"global\" when scope is global)").option("--deliver", "Deliver assistant replies", false).option("--thinking <level>", "Thinking level override").option("--message <text>", "Send an initial message after connecting").option("--timeout-ms <ms>", "Agent timeout in ms (defaults to agents.defaults.timeoutSeconds)").option("--history-limit <n>", "History entries to load", "200").addHelpText("after", () => `\n${theme$1.muted("Docs:")} ${formatDocsLink("/cli/tui", "genesis.pixelzx.com/docs/cli/tui")}\n`).action(async (opts, cmd) => {
4558
+ try {
4559
+ const invokedSubcommand = cmd.parent?.args[0];
4560
+ const invokedAsLocalAlias = invokedSubcommand === "terminal" || invokedSubcommand === "chat";
4561
+ const isLocal = Boolean(opts.local) || invokedAsLocalAlias;
4562
+ if (isLocal && (opts.url || opts.token || opts.password)) throw new Error("--local cannot be combined with --url, --token, or --password");
4563
+ const timeoutMs = parseTimeoutMs(opts.timeoutMs);
4564
+ if (opts.timeoutMs !== void 0 && timeoutMs === void 0) defaultRuntime.error(`warning: invalid --timeout-ms "${String(opts.timeoutMs)}"; ignoring`);
4565
+ const historyLimit = Number.parseInt(String(opts.historyLimit ?? "200"), 10);
4566
+ await runTui({
4567
+ local: isLocal,
4568
+ url: opts.url,
4569
+ token: opts.token,
4570
+ password: opts.password,
4571
+ session: opts.session,
4572
+ deliver: Boolean(opts.deliver),
4573
+ thinking: opts.thinking,
4574
+ message: opts.message,
4575
+ timeoutMs,
4576
+ historyLimit: Number.isNaN(historyLimit) ? void 0 : historyLimit
4577
+ });
4578
+ } catch (err) {
4579
+ defaultRuntime.error(String(err));
4580
+ defaultRuntime.exit(1);
4581
+ }
4582
+ });
4583
+ }
4584
+ //#endregion
4585
+ export { registerTuiCli };