@tangle-network/agent-app 0.61.3 → 0.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. package/dist/{DesignCanvas-L6J72JQ2.js → DesignCanvas-IQKYAEC4.js} +3 -2
  2. package/dist/{DesignCanvasEditor-QFQD63MR.js → DesignCanvasEditor-O7OCZTGC.js} +5 -4
  3. package/dist/{TimelineEditor-7KBPJQLT.js → TimelineEditor-VB2UJ34D.js} +4 -2
  4. package/dist/VaultPane-AYW7CO33.js +8 -0
  5. package/dist/agent-profiles/d1.js +1 -1
  6. package/dist/agent-profiles/index.d.ts +0 -82
  7. package/dist/agent-profiles/index.js +1 -21
  8. package/dist/agent-profiles/self-management.d.ts +0 -55
  9. package/dist/alerting/index.d.ts +1 -1
  10. package/dist/alerting/index.js +1 -3
  11. package/dist/alerting/slack.d.ts +6 -79
  12. package/dist/app-auth/drizzle.d.ts +17 -271
  13. package/dist/app-auth/drizzle.js +6 -2
  14. package/dist/app-auth/drizzle.js.map +1 -1
  15. package/dist/app-auth/index.js +3 -3
  16. package/dist/assets/types.d.ts +2 -1
  17. package/dist/assistant/AssistantPanel.d.ts +1 -1
  18. package/dist/assistant/index.js +635 -392
  19. package/dist/assistant/index.js.map +1 -1
  20. package/dist/billing/identity-locks.d.ts +5 -0
  21. package/dist/billing/index.js +1 -1
  22. package/dist/brand-extraction/index.js.map +1 -1
  23. package/dist/brand-extraction/types.d.ts +2 -1
  24. package/dist/chat-react/index.js +6 -5
  25. package/dist/chat-routes/attachment-write-safety.d.ts +4 -0
  26. package/dist/chat-routes/draft-persistence.d.ts +2 -14
  27. package/dist/chat-routes/index.d.ts +1 -0
  28. package/dist/chat-routes/index.js +853 -773
  29. package/dist/chat-routes/index.js.map +1 -1
  30. package/dist/chat-routes/sandbox-model-source.d.ts +20 -0
  31. package/dist/chat-routes/stored-attachments.d.ts +18 -0
  32. package/dist/chat-routes/turn-admission.d.ts +1 -1
  33. package/dist/chat-routes/turn-execution.d.ts +2 -2
  34. package/dist/chat-routes/turn-route-contracts.d.ts +3 -29
  35. package/dist/chat-store/core.d.ts +19 -1
  36. package/dist/chat-store/index.js.map +1 -1
  37. package/dist/chat-store/store.d.ts +3 -29
  38. package/dist/{chunk-ATQQCG4I.js → chunk-2VJLLRVV.js} +2 -2
  39. package/dist/{chunk-R4X5474U.js → chunk-52SDU43B.js} +12 -27
  40. package/dist/chunk-52SDU43B.js.map +1 -0
  41. package/dist/{chunk-MDRH3SDA.js → chunk-54YIL7WM.js} +3 -3
  42. package/dist/{chunk-6QJ3GB3A.js → chunk-5GSZGTPJ.js} +2 -2
  43. package/dist/{chunk-5IM2CLYX.js → chunk-6JEDSKFH.js} +232 -218
  44. package/dist/chunk-6JEDSKFH.js.map +1 -0
  45. package/dist/{chunk-6PRQ45QE.js → chunk-6OG4244Y.js} +1 -1
  46. package/dist/chunk-6OG4244Y.js.map +1 -0
  47. package/dist/{chunk-ZDPUC6CM.js → chunk-6ZVSMA4T.js} +3 -3
  48. package/dist/{chunk-TXUAGSFR.js → chunk-76MPX7JQ.js} +47 -1
  49. package/dist/chunk-76MPX7JQ.js.map +1 -0
  50. package/dist/{chunk-BOQ4HVVH.js → chunk-7ISHKBAD.js} +61 -52
  51. package/dist/chunk-7ISHKBAD.js.map +1 -0
  52. package/dist/chunk-7PULOECS.js +22 -0
  53. package/dist/chunk-7PULOECS.js.map +1 -0
  54. package/dist/{chunk-KJODHPWM.js → chunk-CPVGRQ43.js} +511 -339
  55. package/dist/chunk-CPVGRQ43.js.map +1 -0
  56. package/dist/{chunk-LO6VQ35O.js → chunk-CQZVJVME.js} +2 -2
  57. package/dist/{chunk-Y43PXON2.js → chunk-EFQUAWWF.js} +577 -546
  58. package/dist/chunk-EFQUAWWF.js.map +1 -0
  59. package/dist/{chunk-FPNZMIAW.js → chunk-ELX5YITO.js} +1 -1
  60. package/dist/chunk-ELX5YITO.js.map +1 -0
  61. package/dist/chunk-FGAROAUF.js +19 -0
  62. package/dist/chunk-FGAROAUF.js.map +1 -0
  63. package/dist/{chunk-HN6MZ2XL.js → chunk-FTNGGR37.js} +641 -466
  64. package/dist/chunk-FTNGGR37.js.map +1 -0
  65. package/dist/{chunk-G4F2NWZH.js → chunk-FZ3ZFVAC.js} +4 -4
  66. package/dist/{chunk-UCCSJX64.js → chunk-GIEUZBQQ.js} +1112 -644
  67. package/dist/chunk-GIEUZBQQ.js.map +1 -0
  68. package/dist/{chunk-MEKOWH5E.js → chunk-IVBREL7A.js} +785 -526
  69. package/dist/chunk-IVBREL7A.js.map +1 -0
  70. package/dist/{chunk-WSEXFTN4.js → chunk-JBXNU5WD.js} +26 -26
  71. package/dist/chunk-JBXNU5WD.js.map +1 -0
  72. package/dist/{chunk-F2VX6TTJ.js → chunk-JRCZHDRG.js} +2 -41
  73. package/dist/chunk-JRCZHDRG.js.map +1 -0
  74. package/dist/{chunk-LXYQOOXU.js → chunk-JRW6LCIA.js} +552 -302
  75. package/dist/chunk-JRW6LCIA.js.map +1 -0
  76. package/dist/{chunk-TVPH5T4F.js → chunk-KS4I7KVC.js} +16 -22
  77. package/dist/{chunk-TVPH5T4F.js.map → chunk-KS4I7KVC.js.map} +1 -1
  78. package/dist/{chunk-J2BBYVGF.js → chunk-MRZP65DZ.js} +1 -117
  79. package/dist/chunk-MRZP65DZ.js.map +1 -0
  80. package/dist/{chunk-4ZSLX3LY.js → chunk-OODZCBSM.js} +1 -1
  81. package/dist/chunk-OODZCBSM.js.map +1 -0
  82. package/dist/chunk-P4RRC4AO.js +47 -0
  83. package/dist/chunk-P4RRC4AO.js.map +1 -0
  84. package/dist/{chunk-ORQD4AUO.js → chunk-PCAY23GS.js} +1 -6
  85. package/dist/chunk-PCAY23GS.js.map +1 -0
  86. package/dist/{chunk-NMZUW6VJ.js → chunk-PEJ5OP5B.js} +3 -3
  87. package/dist/chunk-PEJ5OP5B.js.map +1 -0
  88. package/dist/{chunk-NHYRIM4I.js → chunk-PIPNDZ6H.js} +304 -194
  89. package/dist/chunk-PIPNDZ6H.js.map +1 -0
  90. package/dist/{chunk-DJIN3YUJ.js → chunk-TCJ4TMOW.js} +83 -47
  91. package/dist/{chunk-DJIN3YUJ.js.map → chunk-TCJ4TMOW.js.map} +1 -1
  92. package/dist/chunk-UHSUY6H6.js +79 -0
  93. package/dist/chunk-UHSUY6H6.js.map +1 -0
  94. package/dist/{chunk-PDD5A43Y.js → chunk-UTL6TEN6.js} +3 -3
  95. package/dist/{chunk-VJBFCNAU.js → chunk-UW2DKTEM.js} +123 -130
  96. package/dist/chunk-UW2DKTEM.js.map +1 -0
  97. package/dist/{chunk-S27DKRI6.js → chunk-VDYEVCQQ.js} +2 -2
  98. package/dist/{chunk-UFQM46NV.js → chunk-VK3F4N4U.js} +2 -2
  99. package/dist/{chunk-6ZIC6OG5.js → chunk-VYBTQK25.js} +126 -122
  100. package/dist/chunk-VYBTQK25.js.map +1 -0
  101. package/dist/{chunk-RL3Z747H.js → chunk-W2BV2XOC.js} +1491 -700
  102. package/dist/chunk-W2BV2XOC.js.map +1 -0
  103. package/dist/{chunk-FUZETA6Z.js → chunk-X6SZGQTK.js} +2 -2
  104. package/dist/{chunk-CD2LQXY6.js → chunk-XOHE6SKU.js} +14 -16
  105. package/dist/{chunk-CD2LQXY6.js.map → chunk-XOHE6SKU.js.map} +1 -1
  106. package/dist/{chunk-ZBB5KQ6B.js → chunk-Y3GO6SG3.js} +73 -66
  107. package/dist/chunk-Y3GO6SG3.js.map +1 -0
  108. package/dist/chunk-ZAMHLXNS.js +56 -0
  109. package/dist/chunk-ZAMHLXNS.js.map +1 -0
  110. package/dist/{chunk-RHFN7TUV.js → chunk-ZDHCV462.js} +47 -44
  111. package/dist/{chunk-RHFN7TUV.js.map → chunk-ZDHCV462.js.map} +1 -1
  112. package/dist/chunk-ZOS3D26Z.js +72 -0
  113. package/dist/chunk-ZOS3D26Z.js.map +1 -0
  114. package/dist/design-canvas/index.js +32 -32
  115. package/dist/design-canvas/index.js.map +1 -1
  116. package/dist/design-canvas-react/components/DesignCanvas.d.ts +1 -1
  117. package/dist/design-canvas-react/components/Workspace.d.ts +1 -1
  118. package/dist/design-canvas-react/components/glyphs.d.ts +31 -40
  119. package/dist/design-canvas-react/components/transform-math.d.ts +0 -8
  120. package/dist/design-canvas-react/components/use-workspace-keyboard.d.ts +2 -2
  121. package/dist/design-canvas-react/contracts.d.ts +2 -2
  122. package/dist/design-canvas-react/engine.js +1 -1
  123. package/dist/design-canvas-react/index.js +9 -7
  124. package/dist/design-canvas-react/index.js.map +1 -1
  125. package/dist/design-canvas-react/lazy.js +1 -1
  126. package/dist/eval/calibration.d.ts +1 -38
  127. package/dist/eval/index.d.ts +2 -4
  128. package/dist/eval/index.js +0 -84
  129. package/dist/eval/index.js.map +1 -1
  130. package/dist/harness/index.d.ts +1 -1
  131. package/dist/harness/index.js +1 -1
  132. package/dist/harness/session-selection.d.ts +2 -2
  133. package/dist/hub-approvals/index.js +1 -1
  134. package/dist/hub-approvals/result.d.ts +1 -1
  135. package/dist/hub-approvals-react/index.js +4 -4
  136. package/dist/hub-approvals-react/index.js.map +1 -1
  137. package/dist/hub-approvals-react/parts.d.ts +1 -1
  138. package/dist/launch-invariants/cli.js +4 -4
  139. package/dist/launch-invariants/index.js +3 -3
  140. package/dist/launch-invariants/testing.js +4 -4
  141. package/dist/legibility/cli.js +1 -1
  142. package/dist/legibility/index.js +1 -1
  143. package/dist/{mention-editor-B23OMFT2.js → mention-editor-4BKBMWIK.js} +83 -57
  144. package/dist/mention-editor-4BKBMWIK.js.map +1 -0
  145. package/dist/missions/index.js +144 -137
  146. package/dist/missions/index.js.map +1 -1
  147. package/dist/operator/index.js +1 -1
  148. package/dist/peer-floors/check.js +1 -1
  149. package/dist/peer-floors/cli.js +6 -14
  150. package/dist/peer-floors/cli.js.map +1 -1
  151. package/dist/peer-floors/source-entries.d.ts +6 -0
  152. package/dist/platform/index.js +10 -10
  153. package/dist/preset-cloudflare/index.js +1 -1
  154. package/dist/profile/index.d.ts +0 -1
  155. package/dist/profile/index.js +1 -422
  156. package/dist/profile/index.js.map +1 -1
  157. package/dist/profile-editor/server.d.ts +0 -1
  158. package/dist/profile-editor/server.js +0 -1
  159. package/dist/profile-editor/server.js.map +1 -1
  160. package/dist/public-consultation/index.d.ts +2 -2
  161. package/dist/public-consultation/index.js +6 -6
  162. package/dist/record/drizzle.js +156 -148
  163. package/dist/record/drizzle.js.map +1 -1
  164. package/dist/runtime/index.js +4 -4
  165. package/dist/runtime/router-turn.js +3 -3
  166. package/dist/sandbox/box-health.d.ts +1 -1
  167. package/dist/sandbox/index.js +5 -5
  168. package/dist/sequences/drizzle.js +5 -15
  169. package/dist/sequences/drizzle.js.map +1 -1
  170. package/dist/sequences/index.d.ts +1 -0
  171. package/dist/sequences/index.js +18 -14
  172. package/dist/sequences/index.js.map +1 -1
  173. package/dist/sequences/row-mapping.d.ts +7 -0
  174. package/dist/sequences-react/components/TimelineEditor.d.ts +0 -40
  175. package/dist/sequences-react/components/TimelineHistory.d.ts +31 -0
  176. package/dist/sequences-react/components/glyphs.d.ts +12 -21
  177. package/dist/sequences-react/components/index.d.ts +0 -2
  178. package/dist/sequences-react/components/interaction-math.d.ts +3 -3
  179. package/dist/sequences-react/contracts.d.ts +1 -1
  180. package/dist/sequences-react/engine/snap.d.ts +2 -2
  181. package/dist/sequences-react/index.js +4 -4
  182. package/dist/sequences-react/index.js.map +1 -1
  183. package/dist/settings-react/index.js +13 -30
  184. package/dist/settings-react/index.js.map +1 -1
  185. package/dist/settings-react/timezone-picker.d.ts +0 -6
  186. package/dist/signoff/browser-budget.d.ts +6 -1
  187. package/dist/signoff/cli.d.ts +0 -7
  188. package/dist/signoff/cli.js +1 -2
  189. package/dist/signoff/cli.js.map +1 -1
  190. package/dist/signoff/index.js +1 -1
  191. package/dist/skills/index.d.ts +1 -1
  192. package/dist/skills/index.js +5 -25
  193. package/dist/skills/marketplace.d.ts +1 -75
  194. package/dist/skills-placement/box.js +3 -4
  195. package/dist/skills-placement/box.js.map +1 -1
  196. package/dist/skills-placement/index.js +3 -4
  197. package/dist/spend/cli-args.d.ts +1 -1
  198. package/dist/spend/cli.js +3 -3
  199. package/dist/spend/cli.js.map +1 -1
  200. package/dist/spend/index.js +1 -1
  201. package/dist/stories/design-canvas/fixtures.d.ts +1 -14
  202. package/dist/stream/index.js +17 -17
  203. package/dist/studio/generation.d.ts +1 -1
  204. package/dist/studio/index.js +1 -1
  205. package/dist/studio-react/index.js +353 -184
  206. package/dist/studio-react/index.js.map +1 -1
  207. package/dist/studio-react/studio-composer.d.ts +1 -5
  208. package/dist/studio-react/studio-history-screen.d.ts +1 -1
  209. package/dist/teams/invitations-api.d.ts +3 -3
  210. package/dist/teams/invitations-api.js +74 -72
  211. package/dist/teams/invitations-api.js.map +1 -1
  212. package/dist/teams/member-sync.d.ts +2 -0
  213. package/dist/teams/members-api.d.ts +2 -2
  214. package/dist/teams/members-api.js +1 -1
  215. package/dist/teams-react/index.js +28 -45
  216. package/dist/teams-react/index.js.map +1 -1
  217. package/dist/tools/index.js +1 -1
  218. package/dist/tools/mcp-arguments.d.ts +1 -1
  219. package/dist/trace/index.d.ts +1 -18
  220. package/dist/trace/index.js +1 -36
  221. package/dist/trace/index.js.map +1 -1
  222. package/dist/trace/mission-flow.d.ts +1 -59
  223. package/dist/turn-health/index.d.ts +1 -1
  224. package/dist/turn-health/index.js +2 -2
  225. package/dist/turn-health/sink.d.ts +2 -1
  226. package/dist/turn-trace/index.js +2 -4
  227. package/dist/turn-trace/recorder.d.ts +0 -2
  228. package/dist/vault/VaultPane.d.ts +0 -20
  229. package/dist/vault/VaultPaneOperations.d.ts +318 -0
  230. package/dist/vault/index.js +2 -1
  231. package/dist/vault/index.js.map +1 -1
  232. package/dist/vault/lazy.js +1 -1
  233. package/dist/web-react/agent-profile-editor.d.ts +1 -2
  234. package/dist/web-react/agent-profile-editor.js +6 -5
  235. package/dist/web-react/chat-composer.d.ts +1 -1
  236. package/dist/web-react/durable-plan-flow.d.ts +6 -1
  237. package/dist/web-react/editor-glyphs.d.ts +12 -0
  238. package/dist/web-react/focus-navigation.d.ts +12 -0
  239. package/dist/web-react/history-controls.d.ts +37 -0
  240. package/dist/web-react/index.js +36 -34
  241. package/dist/web-react/interaction-question-card.d.ts +1 -1
  242. package/dist/web-react/record-grid-writes.d.ts +31 -0
  243. package/dist/web-react/record-grid.d.ts +1 -48
  244. package/dist/web-react/session-history-panel.d.ts +1 -9
  245. package/dist/web-react/use-document-dark.d.ts +1 -0
  246. package/dist/workspace-export/engine.d.ts +1 -6
  247. package/dist/workspace-export/index.js +198 -185
  248. package/dist/workspace-export/index.js.map +1 -1
  249. package/dist/workspace-export/routes.d.ts +1 -1
  250. package/dist/workspace-react/index.js +9 -8
  251. package/dist/workspace-react/index.js.map +1 -1
  252. package/package.json +7 -17
  253. package/dist/VaultPane-RXL3WLA2.js +0 -7
  254. package/dist/agent-profiles/reaper.d.ts +0 -31
  255. package/dist/agent-profiles/reaper.js +0 -29
  256. package/dist/agent-profiles/reaper.js.map +0 -1
  257. package/dist/chunk-4ZSLX3LY.js.map +0 -1
  258. package/dist/chunk-5IM2CLYX.js.map +0 -1
  259. package/dist/chunk-6OSJNJA2.js +0 -251
  260. package/dist/chunk-6OSJNJA2.js.map +0 -1
  261. package/dist/chunk-6PRQ45QE.js.map +0 -1
  262. package/dist/chunk-6ZIC6OG5.js.map +0 -1
  263. package/dist/chunk-BDEBQ4WO.js +0 -38
  264. package/dist/chunk-BDEBQ4WO.js.map +0 -1
  265. package/dist/chunk-BOQ4HVVH.js.map +0 -1
  266. package/dist/chunk-F2VX6TTJ.js.map +0 -1
  267. package/dist/chunk-FPNZMIAW.js.map +0 -1
  268. package/dist/chunk-HN6MZ2XL.js.map +0 -1
  269. package/dist/chunk-J2BBYVGF.js.map +0 -1
  270. package/dist/chunk-KJODHPWM.js.map +0 -1
  271. package/dist/chunk-LTWJYNEC.js +0 -100
  272. package/dist/chunk-LTWJYNEC.js.map +0 -1
  273. package/dist/chunk-LXYQOOXU.js.map +0 -1
  274. package/dist/chunk-MEKOWH5E.js.map +0 -1
  275. package/dist/chunk-NHYRIM4I.js.map +0 -1
  276. package/dist/chunk-NMZUW6VJ.js.map +0 -1
  277. package/dist/chunk-ORQD4AUO.js.map +0 -1
  278. package/dist/chunk-R4X5474U.js.map +0 -1
  279. package/dist/chunk-RL3Z747H.js.map +0 -1
  280. package/dist/chunk-TXUAGSFR.js.map +0 -1
  281. package/dist/chunk-UCCSJX64.js.map +0 -1
  282. package/dist/chunk-VJBFCNAU.js.map +0 -1
  283. package/dist/chunk-WSEXFTN4.js.map +0 -1
  284. package/dist/chunk-Y43PXON2.js.map +0 -1
  285. package/dist/chunk-ZBB5KQ6B.js.map +0 -1
  286. package/dist/eval/parity.d.ts +0 -74
  287. package/dist/mention-editor-B23OMFT2.js.map +0 -1
  288. package/dist/profile/humanizer-skill.d.ts +0 -23
  289. package/dist/profile/humanizer-skill.vendored.d.ts +0 -4
  290. package/dist/sequences-react/components/BrandMark.d.ts +0 -10
  291. package/dist/skills/marketplace-drizzle.d.ts +0 -121
  292. package/dist/skills/marketplace-drizzle.js +0 -34
  293. package/dist/skills/marketplace-drizzle.js.map +0 -1
  294. package/dist/teams-react/components/BrandMark.d.ts +0 -10
  295. /package/dist/{DesignCanvas-L6J72JQ2.js.map → DesignCanvas-IQKYAEC4.js.map} +0 -0
  296. /package/dist/{DesignCanvasEditor-QFQD63MR.js.map → DesignCanvasEditor-O7OCZTGC.js.map} +0 -0
  297. /package/dist/{TimelineEditor-7KBPJQLT.js.map → TimelineEditor-VB2UJ34D.js.map} +0 -0
  298. /package/dist/{VaultPane-RXL3WLA2.js.map → VaultPane-AYW7CO33.js.map} +0 -0
  299. /package/dist/{chunk-ATQQCG4I.js.map → chunk-2VJLLRVV.js.map} +0 -0
  300. /package/dist/{chunk-MDRH3SDA.js.map → chunk-54YIL7WM.js.map} +0 -0
  301. /package/dist/{chunk-6QJ3GB3A.js.map → chunk-5GSZGTPJ.js.map} +0 -0
  302. /package/dist/{chunk-ZDPUC6CM.js.map → chunk-6ZVSMA4T.js.map} +0 -0
  303. /package/dist/{chunk-LO6VQ35O.js.map → chunk-CQZVJVME.js.map} +0 -0
  304. /package/dist/{chunk-G4F2NWZH.js.map → chunk-FZ3ZFVAC.js.map} +0 -0
  305. /package/dist/{chunk-PDD5A43Y.js.map → chunk-UTL6TEN6.js.map} +0 -0
  306. /package/dist/{chunk-S27DKRI6.js.map → chunk-VDYEVCQQ.js.map} +0 -0
  307. /package/dist/{chunk-UFQM46NV.js.map → chunk-VK3F4N4U.js.map} +0 -0
  308. /package/dist/{chunk-FUZETA6Z.js.map → chunk-X6SZGQTK.js.map} +0 -0
@@ -1,32 +1,34 @@
1
1
  import {
2
2
  ReasoningRow,
3
3
  chatToolCallPart
4
- } from "../chunk-UCCSJX64.js";
5
- import "../chunk-BDEBQ4WO.js";
4
+ } from "../chunk-GIEUZBQQ.js";
6
5
  import "../chunk-3HUFJ5LO.js";
7
- import "../chunk-6OSJNJA2.js";
8
- import "../chunk-HN6MZ2XL.js";
6
+ import "../chunk-UHSUY6H6.js";
7
+ import "../chunk-7PULOECS.js";
8
+ import "../chunk-ZOS3D26Z.js";
9
9
  import "../chunk-Y6PRDUFJ.js";
10
- import "../chunk-GEYACSFW.js";
11
10
  import {
12
11
  ChatComposer
13
- } from "../chunk-LXYQOOXU.js";
12
+ } from "../chunk-JRW6LCIA.js";
14
13
  import "../chunk-L7MB2LLM.js";
15
- import "../chunk-G4F2NWZH.js";
16
- import "../chunk-ZDPUC6CM.js";
14
+ import "../chunk-6ZVSMA4T.js";
17
15
  import "../chunk-2HQP2CTA.js";
18
- import "../chunk-FUZETA6Z.js";
19
- import {
20
- ModelPicker
21
- } from "../chunk-R4X5474U.js";
22
16
  import "../chunk-E4AY62T2.js";
23
17
  import "../chunk-SJWIZT7B.js";
24
- import "../chunk-ATQQCG4I.js";
25
- import "../chunk-WSEXFTN4.js";
18
+ import "../chunk-FTNGGR37.js";
19
+ import "../chunk-FZ3ZFVAC.js";
20
+ import "../chunk-X6SZGQTK.js";
21
+ import {
22
+ ModelPicker
23
+ } from "../chunk-52SDU43B.js";
24
+ import "../chunk-ZAMHLXNS.js";
25
+ import "../chunk-GEYACSFW.js";
26
+ import "../chunk-2VJLLRVV.js";
27
+ import "../chunk-JBXNU5WD.js";
28
+ import "../chunk-RASGKEAL.js";
26
29
  import {
27
30
  AsyncView
28
31
  } from "../chunk-AVP5SNIG.js";
29
- import "../chunk-RASGKEAL.js";
30
32
  import "../chunk-FQYAJYPW.js";
31
33
  import "../chunk-IUVDR3KJ.js";
32
34
  import "../chunk-B7CL7ENS.js";
@@ -36,7 +38,7 @@ import "../chunk-ZVEEWGDK.js";
36
38
  import "../chunk-G7M2C72Q.js";
37
39
  import "../chunk-VUBJZEZB.js";
38
40
  import "../chunk-6VQCFJWP.js";
39
- import "../chunk-FPNZMIAW.js";
41
+ import "../chunk-ELX5YITO.js";
40
42
  import "../chunk-PV33JZKV.js";
41
43
  import "../chunk-TXD5HXLE.js";
42
44
  import "../chunk-WL7PZK7Q.js";
@@ -1209,69 +1211,36 @@ function useAssistantChat(userId, options) {
1209
1211
  abortRef.current = null;
1210
1212
  }, []);
1211
1213
  const startChatStream = useCallback(
1212
- (text, deliveryMode, model, threadId) => {
1213
- dispatch({
1214
- type: "send",
1215
- messageId: uuid(),
1216
- assistantId: uuid(),
1217
- text
1218
- });
1219
- const seq = ++streamSeqRef.current;
1220
- const ac = new AbortController();
1221
- abortRef.current = ac;
1222
- sendingRef.current = true;
1223
- clientRef.current.streamChat(
1224
- {
1225
- message: text,
1226
- deliveryMode,
1227
- // null → omit, so the server applies its default model.
1228
- model,
1229
- threadId,
1230
- turnKey: uuid(),
1231
- ...contextRef.current ? { context: contextRef.current } : {}
1232
- },
1233
- (event) => {
1234
- if (streamSeqRef.current === seq) dispatch({ type: "stream", event });
1235
- },
1236
- ac.signal
1237
- ).catch((err) => {
1238
- if (ac.signal.aborted || streamSeqRef.current !== seq) return;
1239
- dispatch({
1240
- type: "stream_failed",
1241
- error: {
1242
- code: err instanceof AssistantClientInputError ? err.code : "NETWORK",
1243
- message: err instanceof Error ? err.message : "The connection failed"
1244
- }
1245
- });
1246
- }).finally(() => {
1247
- if (streamSeqRef.current === seq) sendingRef.current = false;
1248
- if (abortRef.current === ac) abortRef.current = null;
1249
- });
1250
- },
1214
+ (text, deliveryMode, model, threadId) => startAssistantChatStream(
1215
+ text,
1216
+ deliveryMode,
1217
+ model,
1218
+ threadId,
1219
+ { dispatch, streamSeqRef, abortRef, sendingRef, clientRef, contextRef }
1220
+ ),
1251
1221
  []
1252
1222
  );
1253
- useEffect(() => {
1254
- if (hydratedUserRef.current === userId) return;
1255
- streamSeqRef.current += 1;
1256
- confirmSeqRef.current += 1;
1257
- abortActiveStream();
1258
- clearPendingQueuedSend();
1259
- historyAbortRef.current?.abort();
1260
- setRestoringBoth(false);
1261
- sendingRef.current = false;
1262
- confirmingRef.current.clear();
1263
- setConfirmingIds(EMPTY_IDS);
1264
- hydratedUserRef.current = userId;
1265
- const nextModel = loadThread(userId).model;
1266
- selectedModelRef.current = nextModel;
1267
- setSelectedModel(nextModel);
1268
- dispatch({
1269
- type: "hydrate",
1270
- ownerId: userId,
1271
- threadId: loadThread(userId).threadId,
1272
- messages: []
1273
- });
1274
- }, [userId, abortActiveStream, clearPendingQueuedSend, setRestoringBoth]);
1223
+ useEffect(() => hydrateAssistantChatOwner({
1224
+ hydratedUserRef,
1225
+ userId,
1226
+ streamSeqRef,
1227
+ confirmSeqRef,
1228
+ abortActiveStream,
1229
+ clearPendingQueuedSend,
1230
+ historyAbortRef,
1231
+ setRestoringBoth,
1232
+ sendingRef,
1233
+ confirmingRef,
1234
+ setConfirmingIds,
1235
+ selectedModelRef,
1236
+ setSelectedModel,
1237
+ dispatch
1238
+ }), [
1239
+ userId,
1240
+ abortActiveStream,
1241
+ clearPendingQueuedSend,
1242
+ setRestoringBoth
1243
+ ]);
1275
1244
  useEffect(() => {
1276
1245
  const pending = pendingQueuedSendRef.current;
1277
1246
  if (!pending || state.status === "streaming") return;
@@ -1292,67 +1261,25 @@ function useAssistantChat(userId, options) {
1292
1261
  const ac = new AbortController();
1293
1262
  historyAbortRef.current?.abort();
1294
1263
  historyAbortRef.current = ac;
1295
- void clientRef.current.fetchThreadHistory(threadId, ac.signal).then((result) => {
1296
- if (ac.signal.aborted) return;
1297
- if (result.status === "ok") {
1298
- if (result.messages.length > 0 || result.proposals.length > 0) {
1299
- dispatch({
1300
- type: "restore_history",
1301
- ownerId: userId,
1302
- threadId,
1303
- messages: result.messages,
1304
- proposals: result.proposals
1305
- });
1306
- }
1307
- } else if (result.status === "gone") {
1308
- dispatch({ type: "thread_gone", ownerId: userId, threadId });
1309
- }
1310
- }).catch(() => {
1311
- });
1264
+ restoreAssistantThreadHistory(clientRef.current, userId, threadId, ac, dispatch);
1312
1265
  return () => ac.abort();
1313
1266
  }, [userId]);
1314
- useEffect(() => {
1315
- if (state.status === "streaming") return;
1316
- if (state.ownerId !== userIdRef.current) return;
1317
- saveThread(state.ownerId, {
1318
- threadId: state.threadId,
1319
- model: selectedModelRef.current
1320
- });
1321
- }, [state.ownerId, state.threadId, state.status]);
1267
+ useEffect(() => persistAssistantChatSelection({ state, userIdRef, selectedModelRef }), [state.ownerId, state.threadId, state.status]);
1322
1268
  useEffect(() => {
1323
1269
  return () => {
1324
1270
  abortActiveStream();
1325
1271
  clearPendingQueuedSend();
1326
1272
  };
1327
1273
  }, [abortActiveStream, clearPendingQueuedSend]);
1328
- const send = useCallback((message, options2) => {
1329
- const deliveryMode = options2?.deliveryMode;
1330
- const shouldQueue = deliveryMode === "queue";
1331
- if (sendingRef.current && !shouldQueue) return;
1332
- if (!shouldQueue && pendingQueuedSendRef.current) return;
1333
- if (shouldQueue && pendingQueuedSendRef.current) return;
1334
- const text = message.trim();
1335
- const current = stateRef.current;
1336
- if (current.ownerId !== userIdRef.current) return;
1337
- if (restoringRef.current) return;
1338
- if (!text) return;
1339
- if (current.pendingProposals.length > 0) return;
1340
- if (current.status === "streaming") {
1341
- if (!shouldQueue) return;
1342
- pendingQueuedSendRef.current = {
1343
- ownerId: current.ownerId,
1344
- text,
1345
- model: selectedModelRef.current ?? void 0
1346
- };
1347
- return;
1348
- }
1349
- startChatStream(
1350
- text,
1351
- deliveryMode,
1352
- selectedModelRef.current ?? void 0,
1353
- current.threadId ?? void 0
1354
- );
1355
- }, [startChatStream]);
1274
+ const send = useCallback((message, options2) => sendAssistantChatMessage(message, options2, {
1275
+ sendingRef,
1276
+ pendingQueuedSendRef,
1277
+ stateRef,
1278
+ userIdRef,
1279
+ restoringRef,
1280
+ selectedModelRef,
1281
+ startChatStream
1282
+ }), [startChatStream]);
1356
1283
  const stop = useCallback(() => {
1357
1284
  streamSeqRef.current += 1;
1358
1285
  abortActiveStream();
@@ -1360,184 +1287,51 @@ function useAssistantChat(userId, options) {
1360
1287
  sendingRef.current = false;
1361
1288
  dispatch({ type: "stopped" });
1362
1289
  }, [abortActiveStream, clearPendingQueuedSend]);
1363
- const confirm = useCallback(async (proposal) => {
1364
- const pid = proposal.proposalId;
1365
- if (!pid) {
1366
- dispatch({
1367
- type: "proposal_resolved",
1368
- callId: proposal.callId,
1369
- status: null,
1370
- error: {
1371
- code: "TOOL_FAILED",
1372
- message: "This action can no longer be confirmed."
1373
- }
1374
- });
1375
- return;
1376
- }
1377
- if (confirmingRef.current.has(pid)) return;
1378
- confirmingRef.current.add(pid);
1379
- setConfirmingIds(new Set(confirmingRef.current));
1380
- const seq = confirmSeqRef.current;
1381
- try {
1382
- const result = await clientRef.current.confirmProposal(pid);
1383
- if (confirmSeqRef.current !== seq) return;
1384
- if (result.ok && result.retryable) {
1385
- const { error: error2 } = resolveConfirmation(proposal.name, result);
1386
- dispatch({
1387
- type: "proposal_retry_failed",
1388
- callId: proposal.callId,
1389
- message: error2?.message ?? "Connect the required integration, then confirm again."
1390
- });
1391
- return;
1392
- }
1393
- const { statusText, error } = resolveConfirmation(proposal.name, result);
1394
- const status = statusText ? statusMessage(statusText) : null;
1395
- if (status && result.ok && !error) {
1396
- const confirmed = {
1397
- name: proposal.name,
1398
- output: result.output,
1399
- args: proposal.args
1400
- };
1401
- status.result = confirmed;
1402
- }
1403
- dispatch({
1404
- type: "proposal_resolved",
1405
- callId: proposal.callId,
1406
- status,
1407
- error
1408
- });
1409
- if (!error && WORKFLOW_MUTATING_TOOLS.has(proposal.name)) {
1410
- onWorkflowMutationRef.current?.();
1411
- }
1412
- } catch (err) {
1413
- if (confirmSeqRef.current !== seq) return;
1414
- dispatch({
1415
- type: "proposal_resolved",
1416
- callId: proposal.callId,
1417
- status: null,
1418
- error: {
1419
- code: "TOOL_FAILED",
1420
- message: err instanceof Error ? err.message : "The action could not be completed"
1421
- }
1422
- });
1423
- } finally {
1424
- if (confirmSeqRef.current === seq) {
1425
- confirmingRef.current.delete(pid);
1426
- setConfirmingIds(new Set(confirmingRef.current));
1427
- }
1428
- }
1429
- }, []);
1430
- const cancel = useCallback((proposal) => {
1431
- if (proposal.proposalId && confirmingRef.current.has(proposal.proposalId)) {
1432
- return;
1433
- }
1434
- dispatch({
1435
- type: "proposal_resolved",
1436
- callId: proposal.callId,
1437
- status: statusMessage("Action cancelled."),
1438
- error: null
1439
- });
1440
- }, []);
1290
+ const confirm = useCallback((proposal) => confirmAssistantChatProposal(
1291
+ proposal,
1292
+ { dispatch, confirmingRef, setConfirmingIds, confirmSeqRef, clientRef, onWorkflowMutationRef }
1293
+ ), []);
1294
+ const cancel = useCallback((proposal) => cancelAssistantChatProposal(proposal, { confirmingRef, dispatch }), []);
1441
1295
  const connectRequirement = useCallback(
1442
- async (proposal, requirement) => {
1443
- const handler = onConnectRequirementRef.current;
1444
- if (!handler) return;
1445
- const seq = confirmSeqRef.current;
1446
- let result;
1447
- try {
1448
- result = await handler(requirement);
1449
- } catch {
1450
- return;
1451
- }
1452
- if (confirmSeqRef.current !== seq) return;
1453
- if (result?.connected) {
1454
- dispatch({
1455
- type: "requirement_connected",
1456
- callId: proposal.callId,
1457
- provider: requirement.provider,
1458
- kind: requirement.kind
1459
- });
1460
- }
1461
- },
1296
+ (proposal, requirement) => connectAssistantChatRequirement(
1297
+ proposal,
1298
+ requirement,
1299
+ { onConnectRequirementRef, confirmSeqRef, dispatch }
1300
+ ),
1462
1301
  []
1463
1302
  );
1464
- const reset = useCallback(() => {
1465
- streamSeqRef.current += 1;
1466
- confirmSeqRef.current += 1;
1467
- abortActiveStream();
1468
- clearPendingQueuedSend();
1469
- historyAbortRef.current?.abort();
1470
- setRestoringBoth(false);
1471
- sendingRef.current = false;
1472
- confirmingRef.current.clear();
1473
- setConfirmingIds(EMPTY_IDS);
1474
- dispatch({ type: "reset" });
1475
- }, [abortActiveStream, clearPendingQueuedSend, setRestoringBoth]);
1303
+ const reset = useCallback(() => resetAssistantChat({
1304
+ streamSeqRef,
1305
+ confirmSeqRef,
1306
+ abortActiveStream,
1307
+ clearPendingQueuedSend,
1308
+ historyAbortRef,
1309
+ setRestoringBoth,
1310
+ sendingRef,
1311
+ confirmingRef,
1312
+ setConfirmingIds,
1313
+ dispatch
1314
+ }), [abortActiveStream, clearPendingQueuedSend, setRestoringBoth]);
1476
1315
  const switchThread = useCallback(
1477
- (threadId) => {
1478
- const current = stateRef.current;
1479
- const uid = userIdRef.current;
1480
- if (current.ownerId !== uid) return;
1481
- if (threadId === current.threadId) return;
1482
- if (current.status === "streaming" || current.pendingProposals.length > 0) {
1483
- return;
1484
- }
1485
- streamSeqRef.current += 1;
1486
- confirmSeqRef.current += 1;
1487
- abortActiveStream();
1488
- clearPendingQueuedSend();
1489
- sendingRef.current = false;
1490
- confirmingRef.current.clear();
1491
- setConfirmingIds(EMPTY_IDS);
1492
- dispatch({ type: "switch_thread", threadId });
1493
- setRestoringBoth(true);
1494
- saveThread(uid, { threadId, model: selectedModelRef.current });
1495
- const ac = new AbortController();
1496
- historyAbortRef.current?.abort();
1497
- historyAbortRef.current = ac;
1498
- void clientRef.current.fetchThreadHistory(threadId, ac.signal).then((result) => {
1499
- if (ac.signal.aborted) return;
1500
- if (result.status === "ok") {
1501
- if (result.messages.length > 0 || result.proposals.length > 0) {
1502
- dispatch({
1503
- type: "restore_history",
1504
- ownerId: uid,
1505
- threadId,
1506
- messages: result.messages,
1507
- proposals: result.proposals
1508
- });
1509
- }
1510
- } else if (result.status === "gone") {
1511
- dispatch({ type: "thread_gone", ownerId: uid, threadId });
1512
- } else {
1513
- dispatch({
1514
- type: "history_failed",
1515
- ownerId: uid,
1516
- threadId,
1517
- error: {
1518
- code: "HISTORY_LOAD_FAILED",
1519
- message: "Couldn't load that conversation. You're in a new chat \u2014 reopen it from history to try again."
1520
- }
1521
- });
1522
- }
1523
- setRestoringBoth(false);
1524
- }).catch(() => {
1525
- if (!ac.signal.aborted) setRestoringBoth(false);
1526
- });
1527
- },
1316
+ (threadId) => switchAssistantChatThread(threadId, {
1317
+ stateRef,
1318
+ userIdRef,
1319
+ streamSeqRef,
1320
+ confirmSeqRef,
1321
+ abortActiveStream,
1322
+ clearPendingQueuedSend,
1323
+ sendingRef,
1324
+ confirmingRef,
1325
+ setConfirmingIds,
1326
+ dispatch,
1327
+ setRestoringBoth,
1328
+ selectedModelRef,
1329
+ historyAbortRef,
1330
+ clientRef
1331
+ }),
1528
1332
  [abortActiveStream, clearPendingQueuedSend, setRestoringBoth]
1529
1333
  );
1530
- const setModel = useCallback((model) => {
1531
- selectedModelRef.current = model;
1532
- setSelectedModel(model);
1533
- const currentUserId = userIdRef.current;
1534
- if (stateRef.current.ownerId === currentUserId) {
1535
- saveThread(currentUserId, {
1536
- threadId: stateRef.current.threadId,
1537
- model
1538
- });
1539
- }
1540
- }, []);
1334
+ const setModel = useCallback((model) => selectAssistantChatModel(model, { selectedModelRef, setSelectedModel, userIdRef, stateRef }), []);
1541
1335
  useEffect(() => {
1542
1336
  if (state.error?.code === "MODEL_NOT_ALLOWED" && state.ownerId === userIdRef.current && selectedModelRef.current !== null) {
1543
1337
  setModel(null);
@@ -1560,6 +1354,350 @@ function useAssistantChat(userId, options) {
1560
1354
  restoring
1561
1355
  };
1562
1356
  }
1357
+ function startAssistantChatStream(text, deliveryMode, model, threadId, {
1358
+ dispatch,
1359
+ streamSeqRef,
1360
+ abortRef,
1361
+ sendingRef,
1362
+ clientRef,
1363
+ contextRef
1364
+ }) {
1365
+ dispatch({
1366
+ type: "send",
1367
+ messageId: uuid(),
1368
+ assistantId: uuid(),
1369
+ text
1370
+ });
1371
+ const seq = ++streamSeqRef.current;
1372
+ const ac = new AbortController();
1373
+ abortRef.current = ac;
1374
+ sendingRef.current = true;
1375
+ clientRef.current.streamChat(
1376
+ {
1377
+ message: text,
1378
+ deliveryMode,
1379
+ // null → omit, so the server applies its default model.
1380
+ model,
1381
+ threadId,
1382
+ turnKey: uuid(),
1383
+ ...contextRef.current ? { context: contextRef.current } : {}
1384
+ },
1385
+ (event) => {
1386
+ if (streamSeqRef.current === seq) dispatch({ type: "stream", event });
1387
+ },
1388
+ ac.signal
1389
+ ).catch((err) => {
1390
+ if (ac.signal.aborted || streamSeqRef.current !== seq) return;
1391
+ dispatch({
1392
+ type: "stream_failed",
1393
+ error: {
1394
+ code: err instanceof AssistantClientInputError ? err.code : "NETWORK",
1395
+ message: err instanceof Error ? err.message : "The connection failed"
1396
+ }
1397
+ });
1398
+ }).finally(() => {
1399
+ if (streamSeqRef.current === seq) sendingRef.current = false;
1400
+ if (abortRef.current === ac) abortRef.current = null;
1401
+ });
1402
+ }
1403
+ async function confirmAssistantChatProposal(proposal, {
1404
+ dispatch,
1405
+ confirmingRef,
1406
+ setConfirmingIds,
1407
+ confirmSeqRef,
1408
+ clientRef,
1409
+ onWorkflowMutationRef
1410
+ }) {
1411
+ const pid = proposal.proposalId;
1412
+ if (!pid) {
1413
+ dispatch({
1414
+ type: "proposal_resolved",
1415
+ callId: proposal.callId,
1416
+ status: null,
1417
+ error: {
1418
+ code: "TOOL_FAILED",
1419
+ message: "This action can no longer be confirmed."
1420
+ }
1421
+ });
1422
+ return;
1423
+ }
1424
+ if (confirmingRef.current.has(pid)) return;
1425
+ confirmingRef.current.add(pid);
1426
+ setConfirmingIds(new Set(confirmingRef.current));
1427
+ const seq = confirmSeqRef.current;
1428
+ try {
1429
+ const result = await clientRef.current.confirmProposal(pid);
1430
+ if (confirmSeqRef.current !== seq) return;
1431
+ if (result.ok && result.retryable) {
1432
+ const { error: error2 } = resolveConfirmation(proposal.name, result);
1433
+ dispatch({
1434
+ type: "proposal_retry_failed",
1435
+ callId: proposal.callId,
1436
+ message: error2?.message ?? "Connect the required integration, then confirm again."
1437
+ });
1438
+ return;
1439
+ }
1440
+ const { statusText, error } = resolveConfirmation(proposal.name, result);
1441
+ const status = statusText ? statusMessage(statusText) : null;
1442
+ if (status && result.ok && !error) {
1443
+ const confirmed = {
1444
+ name: proposal.name,
1445
+ output: result.output,
1446
+ args: proposal.args
1447
+ };
1448
+ status.result = confirmed;
1449
+ }
1450
+ dispatch({
1451
+ type: "proposal_resolved",
1452
+ callId: proposal.callId,
1453
+ status,
1454
+ error
1455
+ });
1456
+ if (!error && WORKFLOW_MUTATING_TOOLS.has(proposal.name)) {
1457
+ onWorkflowMutationRef.current?.();
1458
+ }
1459
+ } catch (err) {
1460
+ if (confirmSeqRef.current !== seq) return;
1461
+ dispatch({
1462
+ type: "proposal_resolved",
1463
+ callId: proposal.callId,
1464
+ status: null,
1465
+ error: {
1466
+ code: "TOOL_FAILED",
1467
+ message: err instanceof Error ? err.message : "The action could not be completed"
1468
+ }
1469
+ });
1470
+ } finally {
1471
+ if (confirmSeqRef.current === seq) {
1472
+ confirmingRef.current.delete(pid);
1473
+ setConfirmingIds(new Set(confirmingRef.current));
1474
+ }
1475
+ }
1476
+ }
1477
+ async function connectAssistantChatRequirement(proposal, requirement, {
1478
+ onConnectRequirementRef,
1479
+ confirmSeqRef,
1480
+ dispatch
1481
+ }) {
1482
+ const handler = onConnectRequirementRef.current;
1483
+ if (!handler) return;
1484
+ const seq = confirmSeqRef.current;
1485
+ let result;
1486
+ try {
1487
+ result = await handler(requirement);
1488
+ } catch {
1489
+ return;
1490
+ }
1491
+ if (confirmSeqRef.current !== seq) return;
1492
+ if (result?.connected) {
1493
+ dispatch({
1494
+ type: "requirement_connected",
1495
+ callId: proposal.callId,
1496
+ provider: requirement.provider,
1497
+ kind: requirement.kind
1498
+ });
1499
+ }
1500
+ }
1501
+ function switchAssistantChatThread(threadId, {
1502
+ stateRef,
1503
+ userIdRef,
1504
+ streamSeqRef,
1505
+ confirmSeqRef,
1506
+ abortActiveStream,
1507
+ clearPendingQueuedSend,
1508
+ sendingRef,
1509
+ confirmingRef,
1510
+ setConfirmingIds,
1511
+ dispatch,
1512
+ setRestoringBoth,
1513
+ selectedModelRef,
1514
+ historyAbortRef,
1515
+ clientRef
1516
+ }) {
1517
+ const current = stateRef.current;
1518
+ const uid = userIdRef.current;
1519
+ if (current.ownerId !== uid) return;
1520
+ if (threadId === current.threadId) return;
1521
+ if (current.status === "streaming" || current.pendingProposals.length > 0) {
1522
+ return;
1523
+ }
1524
+ streamSeqRef.current += 1;
1525
+ confirmSeqRef.current += 1;
1526
+ abortActiveStream();
1527
+ clearPendingQueuedSend();
1528
+ sendingRef.current = false;
1529
+ confirmingRef.current.clear();
1530
+ setConfirmingIds(EMPTY_IDS);
1531
+ dispatch({ type: "switch_thread", threadId });
1532
+ setRestoringBoth(true);
1533
+ saveThread(uid, { threadId, model: selectedModelRef.current });
1534
+ const ac = new AbortController();
1535
+ historyAbortRef.current?.abort();
1536
+ historyAbortRef.current = ac;
1537
+ restoreAssistantThreadHistory(clientRef.current, uid, threadId, ac, dispatch, () => {
1538
+ dispatch({
1539
+ type: "history_failed",
1540
+ ownerId: uid,
1541
+ threadId,
1542
+ error: { code: "HISTORY_LOAD_FAILED", message: "Couldn't load that conversation. You're in a new chat \u2014 reopen it from history to try again." }
1543
+ });
1544
+ }, () => setRestoringBoth(false));
1545
+ }
1546
+ function sendAssistantChatMessage(message, options, {
1547
+ sendingRef,
1548
+ pendingQueuedSendRef,
1549
+ stateRef,
1550
+ userIdRef,
1551
+ restoringRef,
1552
+ selectedModelRef,
1553
+ startChatStream
1554
+ }) {
1555
+ const deliveryMode = options?.deliveryMode;
1556
+ const shouldQueue = deliveryMode === "queue";
1557
+ if (sendingRef.current && !shouldQueue) return;
1558
+ if (!shouldQueue && pendingQueuedSendRef.current) return;
1559
+ if (shouldQueue && pendingQueuedSendRef.current) return;
1560
+ const text = message.trim();
1561
+ const current = stateRef.current;
1562
+ if (current.ownerId !== userIdRef.current) return;
1563
+ if (restoringRef.current) return;
1564
+ if (!text) return;
1565
+ if (current.pendingProposals.length > 0) return;
1566
+ if (current.status === "streaming") {
1567
+ if (!shouldQueue) return;
1568
+ pendingQueuedSendRef.current = {
1569
+ ownerId: current.ownerId,
1570
+ text,
1571
+ model: selectedModelRef.current ?? void 0
1572
+ };
1573
+ return;
1574
+ }
1575
+ startChatStream(
1576
+ text,
1577
+ deliveryMode,
1578
+ selectedModelRef.current ?? void 0,
1579
+ current.threadId ?? void 0
1580
+ );
1581
+ }
1582
+ function restoreAssistantThreadHistory(client, ownerId, threadId, ac, dispatch, onLoadError, onSettled) {
1583
+ void client.fetchThreadHistory(threadId, ac.signal).then((result) => {
1584
+ if (ac.signal.aborted) return;
1585
+ if (result.status === "ok") {
1586
+ if (result.messages.length > 0 || result.proposals.length > 0) {
1587
+ dispatch({ type: "restore_history", ownerId, threadId, messages: result.messages, proposals: result.proposals });
1588
+ }
1589
+ } else if (result.status === "gone") {
1590
+ dispatch({ type: "thread_gone", ownerId, threadId });
1591
+ } else {
1592
+ onLoadError?.();
1593
+ }
1594
+ onSettled?.();
1595
+ }).catch(() => {
1596
+ if (!ac.signal.aborted) onSettled?.();
1597
+ });
1598
+ }
1599
+ function resetAssistantChat({
1600
+ streamSeqRef,
1601
+ confirmSeqRef,
1602
+ abortActiveStream,
1603
+ clearPendingQueuedSend,
1604
+ historyAbortRef,
1605
+ setRestoringBoth,
1606
+ sendingRef,
1607
+ confirmingRef,
1608
+ setConfirmingIds,
1609
+ dispatch
1610
+ }) {
1611
+ streamSeqRef.current += 1;
1612
+ confirmSeqRef.current += 1;
1613
+ abortActiveStream();
1614
+ clearPendingQueuedSend();
1615
+ historyAbortRef.current?.abort();
1616
+ setRestoringBoth(false);
1617
+ sendingRef.current = false;
1618
+ confirmingRef.current.clear();
1619
+ setConfirmingIds(EMPTY_IDS);
1620
+ dispatch({ type: "reset" });
1621
+ }
1622
+ function selectAssistantChatModel(model, {
1623
+ selectedModelRef,
1624
+ setSelectedModel,
1625
+ userIdRef,
1626
+ stateRef
1627
+ }) {
1628
+ selectedModelRef.current = model;
1629
+ setSelectedModel(model);
1630
+ const currentUserId = userIdRef.current;
1631
+ if (stateRef.current.ownerId === currentUserId) {
1632
+ saveThread(currentUserId, {
1633
+ threadId: stateRef.current.threadId,
1634
+ model
1635
+ });
1636
+ }
1637
+ }
1638
+ function hydrateAssistantChatOwner({
1639
+ hydratedUserRef,
1640
+ userId,
1641
+ streamSeqRef,
1642
+ confirmSeqRef,
1643
+ abortActiveStream,
1644
+ clearPendingQueuedSend,
1645
+ historyAbortRef,
1646
+ setRestoringBoth,
1647
+ sendingRef,
1648
+ confirmingRef,
1649
+ setConfirmingIds,
1650
+ selectedModelRef,
1651
+ setSelectedModel,
1652
+ dispatch
1653
+ }) {
1654
+ if (hydratedUserRef.current === userId) return;
1655
+ streamSeqRef.current += 1;
1656
+ confirmSeqRef.current += 1;
1657
+ abortActiveStream();
1658
+ clearPendingQueuedSend();
1659
+ historyAbortRef.current?.abort();
1660
+ setRestoringBoth(false);
1661
+ sendingRef.current = false;
1662
+ confirmingRef.current.clear();
1663
+ setConfirmingIds(EMPTY_IDS);
1664
+ hydratedUserRef.current = userId;
1665
+ const nextModel = loadThread(userId).model;
1666
+ selectedModelRef.current = nextModel;
1667
+ setSelectedModel(nextModel);
1668
+ dispatch({
1669
+ type: "hydrate",
1670
+ ownerId: userId,
1671
+ threadId: loadThread(userId).threadId,
1672
+ messages: []
1673
+ });
1674
+ }
1675
+ function persistAssistantChatSelection({
1676
+ state,
1677
+ userIdRef,
1678
+ selectedModelRef
1679
+ }) {
1680
+ if (state.status === "streaming") return;
1681
+ if (state.ownerId !== userIdRef.current) return;
1682
+ saveThread(state.ownerId, {
1683
+ threadId: state.threadId,
1684
+ model: selectedModelRef.current
1685
+ });
1686
+ }
1687
+ function cancelAssistantChatProposal(proposal, {
1688
+ confirmingRef,
1689
+ dispatch
1690
+ }) {
1691
+ if (proposal.proposalId && confirmingRef.current.has(proposal.proposalId)) {
1692
+ return;
1693
+ }
1694
+ dispatch({
1695
+ type: "proposal_resolved",
1696
+ callId: proposal.callId,
1697
+ status: statusMessage("Action cancelled."),
1698
+ error: null
1699
+ });
1700
+ }
1563
1701
 
1564
1702
  // src/assistant/useAssistantModels.ts
1565
1703
  import { useEffect as useEffect2, useReducer as useReducer2 } from "react";
@@ -2100,24 +2238,7 @@ function AssistantLauncherProvider({
2100
2238
  setOpen(true);
2101
2239
  }
2102
2240
  }, [userId, storedOpen, docked]);
2103
- const openAssistant = useCallback4(
2104
- (next) => {
2105
- if (next != null) setSeed(next);
2106
- setOpenedOnLoad(false);
2107
- setOpen(true);
2108
- persistOpen(true);
2109
- },
2110
- [persistOpen]
2111
- );
2112
- const closeAssistant = useCallback4(() => {
2113
- setOpen(false);
2114
- persistOpen(false);
2115
- }, [persistOpen]);
2116
- const toggleAssistant = useCallback4(() => {
2117
- setOpenedOnLoad(false);
2118
- setOpen(!open);
2119
- persistOpen(!open);
2120
- }, [open, persistOpen]);
2241
+ const actions = useAssistantVisibilityActions({ setSeed, setOpenedOnLoad, setOpen, persistOpen, open });
2121
2242
  const clearSeed = useCallback4(() => setSeed(null), []);
2122
2243
  const setPageLabel = useCallback4(
2123
2244
  (update) => setPageLabelState(update),
@@ -2133,9 +2254,7 @@ function AssistantLauncherProvider({
2133
2254
  () => ({
2134
2255
  open,
2135
2256
  seed,
2136
- openAssistant,
2137
- closeAssistant,
2138
- toggleAssistant,
2257
+ ...actions,
2139
2258
  clearSeed,
2140
2259
  layout,
2141
2260
  openedOnLoad,
@@ -2147,9 +2266,7 @@ function AssistantLauncherProvider({
2147
2266
  [
2148
2267
  open,
2149
2268
  seed,
2150
- openAssistant,
2151
- closeAssistant,
2152
- toggleAssistant,
2269
+ actions,
2153
2270
  clearSeed,
2154
2271
  layout,
2155
2272
  openedOnLoad,
@@ -2182,6 +2299,27 @@ function useAssistantPageLabel(label) {
2182
2299
  return () => setPageLabel((current) => current === trimmed ? null : current);
2183
2300
  }, [setPageLabel, trimmed]);
2184
2301
  }
2302
+ function useAssistantVisibilityActions({ setSeed, setOpenedOnLoad, setOpen, persistOpen, open }) {
2303
+ const openAssistant = useCallback4(
2304
+ (next) => {
2305
+ if (next != null) setSeed(next);
2306
+ setOpenedOnLoad(false);
2307
+ setOpen(true);
2308
+ persistOpen(true);
2309
+ },
2310
+ [persistOpen]
2311
+ );
2312
+ const closeAssistant = useCallback4(() => {
2313
+ setOpen(false);
2314
+ persistOpen(false);
2315
+ }, [persistOpen]);
2316
+ const toggleAssistant = useCallback4(() => {
2317
+ setOpenedOnLoad(false);
2318
+ setOpen(!open);
2319
+ persistOpen(!open);
2320
+ }, [open, persistOpen]);
2321
+ return useMemo2(() => ({ openAssistant, closeAssistant, toggleAssistant }), [openAssistant, closeAssistant, toggleAssistant]);
2322
+ }
2185
2323
 
2186
2324
  // src/assistant/panel-toggle.tsx
2187
2325
  import { jsx as jsx4 } from "react/jsx-runtime";
@@ -2765,7 +2903,7 @@ function nextModelSelection(id, defaultSlug) {
2765
2903
  if (defaultSlug != null && id === defaultSlug) return null;
2766
2904
  return id || null;
2767
2905
  }
2768
- function AssistantPanel({
2906
+ function useAssistantPanelViewState({
2769
2907
  chat,
2770
2908
  userId,
2771
2909
  onClose,
@@ -2893,72 +3031,98 @@ function AssistantPanel({
2893
3031
  chatRef.current.reset();
2894
3032
  }
2895
3033
  };
3034
+ return {
3035
+ layout,
3036
+ onClose,
3037
+ toggleRef,
3038
+ effectiveBalance,
3039
+ formatMoney,
3040
+ context,
3041
+ chat,
3042
+ setView,
3043
+ historyButtonRef,
3044
+ toggleHistory,
3045
+ view,
3046
+ logRef,
3047
+ handleConversationScroll,
3048
+ threads,
3049
+ state,
3050
+ deleteThread,
3051
+ transcriptView,
3052
+ toolRenderers,
3053
+ renderConfirmedResult,
3054
+ setStarterSeed,
3055
+ errorView,
3056
+ navigate,
3057
+ low,
3058
+ showContinue,
3059
+ onComposerSend,
3060
+ streaming,
3061
+ starterSeed,
3062
+ composerSeed,
3063
+ onComposerSeedApplied,
3064
+ composerAttachments,
3065
+ pickerModels,
3066
+ pickerValue,
3067
+ models
3068
+ };
3069
+ }
3070
+ function AssistantPanel(props) {
3071
+ const view = useAssistantPanelViewState(props);
3072
+ return /* @__PURE__ */ jsx7(AssistantPanelView, { ...view });
3073
+ }
3074
+ function AssistantPanelView({
3075
+ layout,
3076
+ onClose,
3077
+ toggleRef,
3078
+ effectiveBalance,
3079
+ formatMoney,
3080
+ context,
3081
+ chat,
3082
+ setView,
3083
+ historyButtonRef,
3084
+ toggleHistory,
3085
+ view,
3086
+ logRef,
3087
+ handleConversationScroll,
3088
+ threads,
3089
+ state,
3090
+ deleteThread,
3091
+ transcriptView,
3092
+ toolRenderers,
3093
+ renderConfirmedResult,
3094
+ setStarterSeed,
3095
+ errorView,
3096
+ navigate,
3097
+ low,
3098
+ showContinue,
3099
+ onComposerSend,
3100
+ streaming,
3101
+ starterSeed,
3102
+ composerSeed,
3103
+ onComposerSeedApplied,
3104
+ composerAttachments,
3105
+ pickerModels,
3106
+ pickerValue,
3107
+ models
3108
+ }) {
2896
3109
  return /* @__PURE__ */ jsxs4("div", { className: "relative flex h-full min-h-0 flex-col bg-card", children: [
2897
- /* @__PURE__ */ jsxs4(ShellHeader, { as: "header", className: "gap-2 bg-transparent", children: [
2898
- layout === "docked" && /* @__PURE__ */ jsx7(AssistantPanelToggle, { open: true, onToggle: onClose, buttonRef: toggleRef }),
2899
- /* @__PURE__ */ jsxs4("div", { className: "flex min-w-0 flex-1 flex-col justify-center", children: [
2900
- /* @__PURE__ */ jsxs4("div", { className: "flex min-w-0 items-baseline gap-2", children: [
2901
- /* @__PURE__ */ jsx7("h2", { className: "truncate font-semibold text-[length:var(--font-size-base)] text-foreground leading-tight", children: "Assistant" }),
2902
- effectiveBalance != null && /* @__PURE__ */ jsx7(
2903
- "span",
2904
- {
2905
- "aria-label": "Your credit balance",
2906
- className: "shrink-0 text-muted-foreground text-xs tabular-nums",
2907
- children: formatMoney(effectiveBalance)
2908
- }
2909
- )
2910
- ] }),
2911
- context && /* @__PURE__ */ jsxs4(
2912
- "p",
2913
- {
2914
- className: "truncate text-muted-foreground text-xs leading-snug",
2915
- title: `The assistant sees ${context.path}`,
2916
- children: [
2917
- /* @__PURE__ */ jsx7("span", { className: "sr-only", children: "Looking at " }),
2918
- context.label
2919
- ]
2920
- }
2921
- )
2922
- ] }),
2923
- /* @__PURE__ */ jsx7(
2924
- "button",
2925
- {
2926
- type: "button",
2927
- onClick: () => {
2928
- chat.reset();
2929
- setView("chat");
2930
- },
2931
- "aria-label": "New chat",
2932
- title: "New chat",
2933
- className: HEADER_BUTTON,
2934
- children: /* @__PURE__ */ jsx7(MessageSquarePlus, { "aria-hidden": "true", className: "h-[18px] w-[18px]" })
2935
- }
2936
- ),
2937
- /* @__PURE__ */ jsx7(
2938
- "button",
2939
- {
2940
- ref: historyButtonRef,
2941
- type: "button",
2942
- onClick: toggleHistory,
2943
- "aria-label": "Chat history",
2944
- "aria-pressed": view === "history",
2945
- title: "Chat history",
2946
- className: `${HEADER_BUTTON} ${view === "history" ? "bg-[var(--accent-surface-soft)] text-foreground" : ""}`,
2947
- children: /* @__PURE__ */ jsx7(History, { "aria-hidden": "true", className: "h-[18px] w-[18px]" })
2948
- }
2949
- ),
2950
- layout === "sheet" && /* @__PURE__ */ jsx7(
2951
- "button",
2952
- {
2953
- type: "button",
2954
- onClick: onClose,
2955
- "aria-label": "Close assistant",
2956
- title: "Close assistant",
2957
- className: HEADER_BUTTON,
2958
- children: /* @__PURE__ */ jsx7(X, { "aria-hidden": "true", className: "h-[18px] w-[18px]" })
2959
- }
2960
- )
2961
- ] }),
3110
+ /* @__PURE__ */ jsx7(
3111
+ AssistantPanelHeader,
3112
+ {
3113
+ layout,
3114
+ onClose,
3115
+ toggleRef,
3116
+ effectiveBalance,
3117
+ formatMoney,
3118
+ context,
3119
+ chat,
3120
+ setView,
3121
+ historyButtonRef,
3122
+ toggleHistory,
3123
+ view
3124
+ }
3125
+ ),
2962
3126
  /* @__PURE__ */ jsx7(
2963
3127
  "div",
2964
3128
  {
@@ -3067,6 +3231,85 @@ function AssistantPanel({
3067
3231
  ] })
3068
3232
  ] });
3069
3233
  }
3234
+ function AssistantPanelHeader({
3235
+ layout,
3236
+ onClose,
3237
+ toggleRef,
3238
+ effectiveBalance,
3239
+ formatMoney,
3240
+ context,
3241
+ chat,
3242
+ setView,
3243
+ historyButtonRef,
3244
+ toggleHistory,
3245
+ view
3246
+ }) {
3247
+ return /* @__PURE__ */ jsxs4(ShellHeader, { as: "header", className: "gap-2 bg-transparent", children: [
3248
+ layout === "docked" && /* @__PURE__ */ jsx7(AssistantPanelToggle, { open: true, onToggle: onClose, buttonRef: toggleRef }),
3249
+ /* @__PURE__ */ jsxs4("div", { className: "flex min-w-0 flex-1 flex-col justify-center", children: [
3250
+ /* @__PURE__ */ jsxs4("div", { className: "flex min-w-0 items-baseline gap-2", children: [
3251
+ /* @__PURE__ */ jsx7("h2", { className: "truncate font-semibold text-[length:var(--font-size-base)] text-foreground leading-tight", children: "Assistant" }),
3252
+ effectiveBalance != null && /* @__PURE__ */ jsx7(
3253
+ "span",
3254
+ {
3255
+ "aria-label": "Your credit balance",
3256
+ className: "shrink-0 text-muted-foreground text-xs tabular-nums",
3257
+ children: formatMoney(effectiveBalance)
3258
+ }
3259
+ )
3260
+ ] }),
3261
+ context && /* @__PURE__ */ jsxs4(
3262
+ "p",
3263
+ {
3264
+ className: "truncate text-muted-foreground text-xs leading-snug",
3265
+ title: `The assistant sees ${context.path}`,
3266
+ children: [
3267
+ /* @__PURE__ */ jsx7("span", { className: "sr-only", children: "Looking at " }),
3268
+ context.label
3269
+ ]
3270
+ }
3271
+ )
3272
+ ] }),
3273
+ /* @__PURE__ */ jsx7(
3274
+ "button",
3275
+ {
3276
+ type: "button",
3277
+ onClick: () => {
3278
+ chat.reset();
3279
+ setView("chat");
3280
+ },
3281
+ "aria-label": "New chat",
3282
+ title: "New chat",
3283
+ className: HEADER_BUTTON,
3284
+ children: /* @__PURE__ */ jsx7(MessageSquarePlus, { "aria-hidden": "true", className: "h-[18px] w-[18px]" })
3285
+ }
3286
+ ),
3287
+ /* @__PURE__ */ jsx7(
3288
+ "button",
3289
+ {
3290
+ ref: historyButtonRef,
3291
+ type: "button",
3292
+ onClick: toggleHistory,
3293
+ "aria-label": "Chat history",
3294
+ "aria-pressed": view === "history",
3295
+ title: "Chat history",
3296
+ className: `${HEADER_BUTTON} ${view === "history" ? "bg-[var(--accent-surface-soft)] text-foreground" : ""}`,
3297
+ children: /* @__PURE__ */ jsx7(History, { "aria-hidden": "true", className: "h-[18px] w-[18px]" })
3298
+ }
3299
+ ),
3300
+ layout === "sheet" && /* @__PURE__ */ jsx7(
3301
+ "button",
3302
+ {
3303
+ type: "button",
3304
+ onClick: onClose,
3305
+ "aria-label": "Close assistant",
3306
+ title: "Close assistant",
3307
+ className: HEADER_BUTTON,
3308
+ children: /* @__PURE__ */ jsx7(X, { "aria-hidden": "true", className: "h-[18px] w-[18px]" })
3309
+ }
3310
+ )
3311
+ ] });
3312
+ }
3070
3313
 
3071
3314
  // src/assistant/ResizeHandle.tsx
3072
3315
  import { useRef as useRef8 } from "react";