@buoy-gg/ask-buoy 7.0.38 → 7.0.39

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 (306) hide show
  1. package/lib/commonjs/blocks/AskBlocks.js +338 -1
  2. package/lib/commonjs/blocks/AskBlocks.js.map +1 -0
  3. package/lib/commonjs/blocks/BlockRenderer.js +262 -1
  4. package/lib/commonjs/blocks/BlockRenderer.js.map +1 -0
  5. package/lib/commonjs/blocks/ChromePrototypes.js +514 -1
  6. package/lib/commonjs/blocks/ChromePrototypes.js.map +1 -0
  7. package/lib/commonjs/blocks/DataBlocks.js +781 -1
  8. package/lib/commonjs/blocks/DataBlocks.js.map +1 -0
  9. package/lib/commonjs/blocks/ExtraBlocks.js +1860 -1
  10. package/lib/commonjs/blocks/ExtraBlocks.js.map +1 -0
  11. package/lib/commonjs/blocks/MediaBlocks.js +156 -1
  12. package/lib/commonjs/blocks/MediaBlocks.js.map +1 -0
  13. package/lib/commonjs/blocks/ReceiptBlocks.js +586 -1
  14. package/lib/commonjs/blocks/ReceiptBlocks.js.map +1 -0
  15. package/lib/commonjs/blocks/blockText.js +60 -1
  16. package/lib/commonjs/blocks/blockText.js.map +1 -0
  17. package/lib/commonjs/blocks/blockText.test.js +53 -1
  18. package/lib/commonjs/blocks/blockText.test.js.map +1 -0
  19. package/lib/commonjs/blocks/context.js +42 -1
  20. package/lib/commonjs/blocks/context.js.map +1 -0
  21. package/lib/commonjs/blocks/icons.js +96 -1
  22. package/lib/commonjs/blocks/icons.js.map +1 -0
  23. package/lib/commonjs/blocks/index.js +95 -1
  24. package/lib/commonjs/blocks/index.js.map +1 -0
  25. package/lib/commonjs/blocks/listRow.test.js +55 -1
  26. package/lib/commonjs/blocks/listRow.test.js.map +1 -0
  27. package/lib/commonjs/blocks/pageState.js +34 -1
  28. package/lib/commonjs/blocks/pageState.js.map +1 -0
  29. package/lib/commonjs/blocks/pageState.test.js +57 -1
  30. package/lib/commonjs/blocks/pageState.test.js.map +1 -0
  31. package/lib/commonjs/blocks/primitives.js +457 -1
  32. package/lib/commonjs/blocks/primitives.js.map +1 -0
  33. package/lib/commonjs/blocks/primitivesIndex.js +62 -1
  34. package/lib/commonjs/blocks/primitivesIndex.js.map +1 -0
  35. package/lib/commonjs/components/ApprovalCard.js +297 -1
  36. package/lib/commonjs/components/ApprovalCard.js.map +1 -0
  37. package/lib/commonjs/components/AskBuoyHeader.js +196 -1
  38. package/lib/commonjs/components/AskBuoyHeader.js.map +1 -0
  39. package/lib/commonjs/components/AskBuoyIcon.js +19 -1
  40. package/lib/commonjs/components/AskBuoyIcon.js.map +1 -0
  41. package/lib/commonjs/components/AskBuoyModal.js +479 -1
  42. package/lib/commonjs/components/AskBuoyModal.js.map +1 -0
  43. package/lib/commonjs/components/AskBuoySettings.js +181 -1
  44. package/lib/commonjs/components/AskBuoySettings.js.map +1 -0
  45. package/lib/commonjs/components/ChangesBar.js +211 -1
  46. package/lib/commonjs/components/ChangesBar.js.map +1 -0
  47. package/lib/commonjs/components/Composer.js +255 -1
  48. package/lib/commonjs/components/Composer.js.map +1 -0
  49. package/lib/commonjs/components/EmptyState.js +161 -1
  50. package/lib/commonjs/components/EmptyState.js.map +1 -0
  51. package/lib/commonjs/components/KeyboardPad.js +80 -1
  52. package/lib/commonjs/components/KeyboardPad.js.map +1 -0
  53. package/lib/commonjs/components/Markdown.js +310 -1
  54. package/lib/commonjs/components/Markdown.js.map +1 -0
  55. package/lib/commonjs/components/MessageList.js +970 -1
  56. package/lib/commonjs/components/MessageList.js.map +1 -0
  57. package/lib/commonjs/components/QueuedMessages.js +145 -1
  58. package/lib/commonjs/components/QueuedMessages.js.map +1 -0
  59. package/lib/commonjs/components/ThinkingStrip.js +223 -1
  60. package/lib/commonjs/components/ThinkingStrip.js.map +1 -0
  61. package/lib/commonjs/components/TypingDots.js +63 -1
  62. package/lib/commonjs/components/TypingDots.js.map +1 -0
  63. package/lib/commonjs/components/markdownParse.js +131 -1
  64. package/lib/commonjs/components/markdownParse.js.map +1 -0
  65. package/lib/commonjs/components/markdownParse.test.js +99 -1
  66. package/lib/commonjs/components/markdownParse.test.js.map +1 -0
  67. package/lib/commonjs/components/useCopyAction.js +50 -1
  68. package/lib/commonjs/components/useCopyAction.js.map +1 -0
  69. package/lib/commonjs/index.js +252 -1
  70. package/lib/commonjs/index.js.map +1 -0
  71. package/lib/commonjs/preset.js +91 -1
  72. package/lib/commonjs/preset.js.map +1 -0
  73. package/lib/commonjs/store/activityGroups.js +110 -1
  74. package/lib/commonjs/store/activityGroups.js.map +1 -0
  75. package/lib/commonjs/store/activityGroups.test.js +78 -1
  76. package/lib/commonjs/store/activityGroups.test.js.map +1 -0
  77. package/lib/commonjs/store/askBuoySettings.js +72 -1
  78. package/lib/commonjs/store/askBuoySettings.js.map +1 -0
  79. package/lib/commonjs/store/askBuoyStore.js +589 -1
  80. package/lib/commonjs/store/askBuoyStore.js.map +1 -0
  81. package/lib/commonjs/store/blockPlacement.js +64 -1
  82. package/lib/commonjs/store/blockPlacement.js.map +1 -0
  83. package/lib/commonjs/store/blockPlacement.test.js +123 -1
  84. package/lib/commonjs/store/blockPlacement.test.js.map +1 -0
  85. package/lib/commonjs/store/queue.test.js +150 -1
  86. package/lib/commonjs/store/queue.test.js.map +1 -0
  87. package/lib/commonjs/store/resetConversation.js +77 -1
  88. package/lib/commonjs/store/resetConversation.js.map +1 -0
  89. package/lib/commonjs/store/restorePending.test.js +63 -1
  90. package/lib/commonjs/store/restorePending.test.js.map +1 -0
  91. package/lib/commonjs/store/restoredIds.test.js +47 -1
  92. package/lib/commonjs/store/restoredIds.test.js.map +1 -0
  93. package/lib/commonjs/store/suggestions.js +54 -1
  94. package/lib/commonjs/store/suggestions.js.map +1 -0
  95. package/lib/commonjs/store/suggestions.test.js +58 -1
  96. package/lib/commonjs/store/suggestions.test.js.map +1 -0
  97. package/lib/commonjs/store/systemLine.test.js +77 -1
  98. package/lib/commonjs/store/systemLine.test.js.map +1 -0
  99. package/lib/commonjs/store/ticketPrompt.js +17 -1
  100. package/lib/commonjs/store/ticketPrompt.js.map +1 -0
  101. package/lib/commonjs/store/traceText.js +81 -1
  102. package/lib/commonjs/store/traceText.js.map +1 -0
  103. package/lib/commonjs/store/traceText.test.js +112 -1
  104. package/lib/commonjs/store/traceText.test.js.map +1 -0
  105. package/lib/commonjs/store/transcriptPersistence.js +297 -1
  106. package/lib/commonjs/store/transcriptPersistence.js.map +1 -0
  107. package/lib/commonjs/store/transcriptPersistence.test.js +333 -1
  108. package/lib/commonjs/store/transcriptPersistence.test.js.map +1 -0
  109. package/lib/commonjs/store/turnRendering.test.js +151 -1
  110. package/lib/commonjs/store/turnRendering.test.js.map +1 -0
  111. package/lib/commonjs/store/useAskBuoy.js +651 -1
  112. package/lib/commonjs/store/useAskBuoy.js.map +1 -0
  113. package/lib/commonjs/store/useAskBuoySettings.js +14 -1
  114. package/lib/commonjs/store/useAskBuoySettings.js.map +1 -0
  115. package/lib/commonjs/sync/askBuoySyncAdapter.js +153 -1
  116. package/lib/commonjs/sync/askBuoySyncAdapter.js.map +1 -0
  117. package/lib/commonjs/sync/askBuoySyncAdapter.test.js +141 -1
  118. package/lib/commonjs/sync/askBuoySyncAdapter.test.js.map +1 -0
  119. package/lib/commonjs/sync/wire.js +58 -1
  120. package/lib/commonjs/sync/wire.js.map +1 -0
  121. package/lib/commonjs/types.js +6 -1
  122. package/lib/commonjs/types.js.map +1 -0
  123. package/lib/module/blocks/AskBlocks.js +331 -1
  124. package/lib/module/blocks/AskBlocks.js.map +1 -0
  125. package/lib/module/blocks/BlockRenderer.js +257 -1
  126. package/lib/module/blocks/BlockRenderer.js.map +1 -0
  127. package/lib/module/blocks/ChromePrototypes.js +503 -1
  128. package/lib/module/blocks/ChromePrototypes.js.map +1 -0
  129. package/lib/module/blocks/DataBlocks.js +767 -1
  130. package/lib/module/blocks/DataBlocks.js.map +1 -0
  131. package/lib/module/blocks/ExtraBlocks.js +1833 -1
  132. package/lib/module/blocks/ExtraBlocks.js.map +1 -0
  133. package/lib/module/blocks/MediaBlocks.js +151 -1
  134. package/lib/module/blocks/MediaBlocks.js.map +1 -0
  135. package/lib/module/blocks/ReceiptBlocks.js +574 -1
  136. package/lib/module/blocks/ReceiptBlocks.js.map +1 -0
  137. package/lib/module/blocks/blockText.js +55 -1
  138. package/lib/module/blocks/blockText.js.map +1 -0
  139. package/lib/module/blocks/blockText.test.js +53 -1
  140. package/lib/module/blocks/blockText.test.js.map +1 -0
  141. package/lib/module/blocks/context.js +35 -1
  142. package/lib/module/blocks/context.js.map +1 -0
  143. package/lib/module/blocks/icons.js +91 -1
  144. package/lib/module/blocks/icons.js.map +1 -0
  145. package/lib/module/blocks/index.js +8 -1
  146. package/lib/module/blocks/index.js.map +1 -0
  147. package/lib/module/blocks/listRow.test.js +56 -1
  148. package/lib/module/blocks/listRow.test.js.map +1 -0
  149. package/lib/module/blocks/pageState.js +30 -1
  150. package/lib/module/blocks/pageState.js.map +1 -0
  151. package/lib/module/blocks/pageState.test.js +56 -1
  152. package/lib/module/blocks/pageState.test.js.map +1 -0
  153. package/lib/module/blocks/primitives.js +445 -1
  154. package/lib/module/blocks/primitives.js.map +1 -0
  155. package/lib/module/blocks/primitivesIndex.js +5 -1
  156. package/lib/module/blocks/primitivesIndex.js.map +1 -0
  157. package/lib/module/components/ApprovalCard.js +292 -1
  158. package/lib/module/components/ApprovalCard.js.map +1 -0
  159. package/lib/module/components/AskBuoyHeader.js +193 -1
  160. package/lib/module/components/AskBuoyHeader.js.map +1 -0
  161. package/lib/module/components/AskBuoyIcon.js +8 -1
  162. package/lib/module/components/AskBuoyIcon.js.map +1 -0
  163. package/lib/module/components/AskBuoyModal.js +474 -1
  164. package/lib/module/components/AskBuoyModal.js.map +1 -0
  165. package/lib/module/components/AskBuoySettings.js +176 -1
  166. package/lib/module/components/AskBuoySettings.js.map +1 -0
  167. package/lib/module/components/ChangesBar.js +206 -1
  168. package/lib/module/components/ChangesBar.js.map +1 -0
  169. package/lib/module/components/Composer.js +250 -1
  170. package/lib/module/components/Composer.js.map +1 -0
  171. package/lib/module/components/EmptyState.js +156 -1
  172. package/lib/module/components/EmptyState.js.map +1 -0
  173. package/lib/module/components/KeyboardPad.js +75 -1
  174. package/lib/module/components/KeyboardPad.js.map +1 -0
  175. package/lib/module/components/Markdown.js +305 -1
  176. package/lib/module/components/Markdown.js.map +1 -0
  177. package/lib/module/components/MessageList.js +964 -1
  178. package/lib/module/components/MessageList.js.map +1 -0
  179. package/lib/module/components/QueuedMessages.js +140 -1
  180. package/lib/module/components/QueuedMessages.js.map +1 -0
  181. package/lib/module/components/ThinkingStrip.js +218 -1
  182. package/lib/module/components/ThinkingStrip.js.map +1 -0
  183. package/lib/module/components/TypingDots.js +58 -1
  184. package/lib/module/components/TypingDots.js.map +1 -0
  185. package/lib/module/components/markdownParse.js +125 -1
  186. package/lib/module/components/markdownParse.js.map +1 -0
  187. package/lib/module/components/markdownParse.test.js +98 -1
  188. package/lib/module/components/markdownParse.test.js.map +1 -0
  189. package/lib/module/components/useCopyAction.js +46 -1
  190. package/lib/module/components/useCopyAction.js.map +1 -0
  191. package/lib/module/index.js +34 -1
  192. package/lib/module/index.js.map +1 -0
  193. package/lib/module/preset.js +74 -1
  194. package/lib/module/preset.js.map +1 -0
  195. package/lib/module/store/activityGroups.js +103 -1
  196. package/lib/module/store/activityGroups.js.map +1 -0
  197. package/lib/module/store/activityGroups.test.js +77 -1
  198. package/lib/module/store/activityGroups.test.js.map +1 -0
  199. package/lib/module/store/askBuoySettings.js +67 -1
  200. package/lib/module/store/askBuoySettings.js.map +1 -0
  201. package/lib/module/store/askBuoyStore.js +583 -1
  202. package/lib/module/store/askBuoyStore.js.map +1 -0
  203. package/lib/module/store/blockPlacement.js +59 -1
  204. package/lib/module/store/blockPlacement.js.map +1 -0
  205. package/lib/module/store/blockPlacement.test.js +122 -1
  206. package/lib/module/store/blockPlacement.test.js.map +1 -0
  207. package/lib/module/store/queue.test.js +149 -1
  208. package/lib/module/store/queue.test.js.map +1 -0
  209. package/lib/module/store/resetConversation.js +72 -1
  210. package/lib/module/store/resetConversation.js.map +1 -0
  211. package/lib/module/store/restorePending.test.js +62 -1
  212. package/lib/module/store/restorePending.test.js.map +1 -0
  213. package/lib/module/store/restoredIds.test.js +46 -1
  214. package/lib/module/store/restoredIds.test.js.map +1 -0
  215. package/lib/module/store/suggestions.js +49 -1
  216. package/lib/module/store/suggestions.js.map +1 -0
  217. package/lib/module/store/suggestions.test.js +57 -1
  218. package/lib/module/store/suggestions.test.js.map +1 -0
  219. package/lib/module/store/systemLine.test.js +76 -1
  220. package/lib/module/store/systemLine.test.js.map +1 -0
  221. package/lib/module/store/ticketPrompt.js +13 -1
  222. package/lib/module/store/ticketPrompt.js.map +1 -0
  223. package/lib/module/store/traceText.js +75 -1
  224. package/lib/module/store/traceText.js.map +1 -0
  225. package/lib/module/store/traceText.test.js +111 -1
  226. package/lib/module/store/traceText.test.js.map +1 -0
  227. package/lib/module/store/transcriptPersistence.js +287 -1
  228. package/lib/module/store/transcriptPersistence.js.map +1 -0
  229. package/lib/module/store/transcriptPersistence.test.js +332 -1
  230. package/lib/module/store/transcriptPersistence.test.js.map +1 -0
  231. package/lib/module/store/turnRendering.test.js +150 -1
  232. package/lib/module/store/turnRendering.test.js.map +1 -0
  233. package/lib/module/store/useAskBuoy.js +646 -1
  234. package/lib/module/store/useAskBuoy.js.map +1 -0
  235. package/lib/module/store/useAskBuoySettings.js +9 -1
  236. package/lib/module/store/useAskBuoySettings.js.map +1 -0
  237. package/lib/module/sync/askBuoySyncAdapter.js +148 -1
  238. package/lib/module/sync/askBuoySyncAdapter.js.map +1 -0
  239. package/lib/module/sync/askBuoySyncAdapter.test.js +140 -1
  240. package/lib/module/sync/askBuoySyncAdapter.test.js.map +1 -0
  241. package/lib/module/sync/wire.js +47 -1
  242. package/lib/module/sync/wire.js.map +1 -0
  243. package/lib/module/types.js +4 -1
  244. package/lib/module/types.js.map +1 -0
  245. package/lib/typescript/blocks/AskBlocks.d.ts.map +1 -0
  246. package/lib/typescript/blocks/BlockRenderer.d.ts.map +1 -0
  247. package/lib/typescript/blocks/ChromePrototypes.d.ts.map +1 -0
  248. package/lib/typescript/blocks/DataBlocks.d.ts.map +1 -0
  249. package/lib/typescript/blocks/ExtraBlocks.d.ts.map +1 -0
  250. package/lib/typescript/blocks/MediaBlocks.d.ts.map +1 -0
  251. package/lib/typescript/blocks/ReceiptBlocks.d.ts.map +1 -0
  252. package/lib/typescript/blocks/blockText.d.ts.map +1 -0
  253. package/lib/typescript/blocks/blockText.test.d.ts.map +1 -0
  254. package/lib/typescript/blocks/context.d.ts.map +1 -0
  255. package/lib/typescript/blocks/icons.d.ts.map +1 -0
  256. package/lib/typescript/blocks/index.d.ts.map +1 -0
  257. package/lib/typescript/blocks/listRow.test.d.ts.map +1 -0
  258. package/lib/typescript/blocks/pageState.d.ts.map +1 -0
  259. package/lib/typescript/blocks/pageState.test.d.ts.map +1 -0
  260. package/lib/typescript/blocks/primitives.d.ts.map +1 -0
  261. package/lib/typescript/blocks/primitivesIndex.d.ts.map +1 -0
  262. package/lib/typescript/components/ApprovalCard.d.ts.map +1 -0
  263. package/lib/typescript/components/AskBuoyHeader.d.ts.map +1 -0
  264. package/lib/typescript/components/AskBuoyIcon.d.ts.map +1 -0
  265. package/lib/typescript/components/AskBuoyModal.d.ts.map +1 -0
  266. package/lib/typescript/components/AskBuoySettings.d.ts.map +1 -0
  267. package/lib/typescript/components/ChangesBar.d.ts.map +1 -0
  268. package/lib/typescript/components/Composer.d.ts.map +1 -0
  269. package/lib/typescript/components/EmptyState.d.ts.map +1 -0
  270. package/lib/typescript/components/KeyboardPad.d.ts.map +1 -0
  271. package/lib/typescript/components/Markdown.d.ts.map +1 -0
  272. package/lib/typescript/components/MessageList.d.ts.map +1 -0
  273. package/lib/typescript/components/QueuedMessages.d.ts.map +1 -0
  274. package/lib/typescript/components/ThinkingStrip.d.ts.map +1 -0
  275. package/lib/typescript/components/TypingDots.d.ts.map +1 -0
  276. package/lib/typescript/components/markdownParse.d.ts.map +1 -0
  277. package/lib/typescript/components/markdownParse.test.d.ts.map +1 -0
  278. package/lib/typescript/components/useCopyAction.d.ts.map +1 -0
  279. package/lib/typescript/index.d.ts.map +1 -0
  280. package/lib/typescript/preset.d.ts.map +1 -0
  281. package/lib/typescript/store/activityGroups.d.ts.map +1 -0
  282. package/lib/typescript/store/activityGroups.test.d.ts.map +1 -0
  283. package/lib/typescript/store/askBuoySettings.d.ts.map +1 -0
  284. package/lib/typescript/store/askBuoyStore.d.ts.map +1 -0
  285. package/lib/typescript/store/blockPlacement.d.ts.map +1 -0
  286. package/lib/typescript/store/blockPlacement.test.d.ts.map +1 -0
  287. package/lib/typescript/store/queue.test.d.ts.map +1 -0
  288. package/lib/typescript/store/resetConversation.d.ts.map +1 -0
  289. package/lib/typescript/store/restorePending.test.d.ts.map +1 -0
  290. package/lib/typescript/store/restoredIds.test.d.ts.map +1 -0
  291. package/lib/typescript/store/suggestions.d.ts.map +1 -0
  292. package/lib/typescript/store/suggestions.test.d.ts.map +1 -0
  293. package/lib/typescript/store/systemLine.test.d.ts.map +1 -0
  294. package/lib/typescript/store/ticketPrompt.d.ts.map +1 -0
  295. package/lib/typescript/store/traceText.d.ts.map +1 -0
  296. package/lib/typescript/store/traceText.test.d.ts.map +1 -0
  297. package/lib/typescript/store/transcriptPersistence.d.ts.map +1 -0
  298. package/lib/typescript/store/transcriptPersistence.test.d.ts.map +1 -0
  299. package/lib/typescript/store/turnRendering.test.d.ts.map +1 -0
  300. package/lib/typescript/store/useAskBuoy.d.ts.map +1 -0
  301. package/lib/typescript/store/useAskBuoySettings.d.ts.map +1 -0
  302. package/lib/typescript/sync/askBuoySyncAdapter.d.ts.map +1 -0
  303. package/lib/typescript/sync/askBuoySyncAdapter.test.d.ts.map +1 -0
  304. package/lib/typescript/sync/wire.d.ts.map +1 -0
  305. package/lib/typescript/types.d.ts.map +1 -0
  306. package/package.json +8 -8
@@ -0,0 +1 @@
1
+ {"version":3,"names":["describe","expect","it","formatElapsed","groupCalls","turnFooter","call","id","toolId","effect","status","action","label","items","toEqual","kind","objectContaining","toHaveLength","g","toBe","count","map","i","startedAt","endedAt","toolCalls","toBeNull"],"sourceRoot":"../../../src","sources":["store/activityGroups.test.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAE7C,SAASC,aAAa,EAAEC,UAAU,EAAEC,UAAU,QAAQ,kBAAkB;AAGxE,MAAMC,IAAI,GAAGA,CACXC,EAAU,EACVC,MAAc,EACdC,MAA8B,EAC9BC,MAA8B,GAAG,IAAI,MACnB;EAAEH,EAAE;EAAEC,MAAM;EAAEG,MAAM,EAAE,GAAG;EAAEC,KAAK,EAAE,GAAGJ,MAAM,IAAID,EAAE,EAAE;EAAEG,MAAM;EAAED;AAAO,CAAC,CAAC;AAE1FT,QAAQ,CAAC,YAAY,EAAE,MAAM;EAC3BE,EAAE,CAAC,yCAAyC,EAAE,MAAM;IAClD,MAAMW,KAAK,GAAGT,UAAU,CAAC,CAACE,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;IACxDL,MAAM,CAACY,KAAK,CAAC,CAACC,OAAO,CAAC,CAAC;MAAEC,IAAI,EAAE,MAAM;MAAET,IAAI,EAAEL,MAAM,CAACe,gBAAgB,CAAC;QAAET,EAAE,EAAE;MAAI,CAAC;IAAE,CAAC,CAAC,CAAC;EACvF,CAAC,CAAC;EAEFL,EAAE,CAAC,kEAAkE,EAAE,MAAM;IAC3E,MAAMW,KAAK,GAAGT,UAAU,CAAC,CACvBE,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,EAC5BA,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,EAC5BA,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,CAC7B,CAAC;IACFL,MAAM,CAACY,KAAK,CAAC,CAACI,YAAY,CAAC,CAAC,CAAC;IAC7B,MAAMC,CAAC,GAAGL,KAAK,CAAC,CAAC,CAAE;IACnBZ,MAAM,CAACiB,CAAC,CAACH,IAAI,CAAC,CAACI,IAAI,CAAC,OAAO,CAAC;IAC5BlB,MAAM,CAACiB,CAAC,CAACH,IAAI,KAAK,OAAO,IAAIG,CAAC,CAACE,KAAK,CAAC,CAACD,IAAI,CAAC,CAAC,CAAC;IAC7ClB,MAAM,CAACiB,CAAC,CAACH,IAAI,KAAK,OAAO,IAAIG,CAAC,CAACN,KAAK,CAAC,CAACO,IAAI,CAAC,+BAA+B,CAAC;EAC7E,CAAC,CAAC;EAEFjB,EAAE,CAAC,uDAAuD,EAAE,MAAM;IAChE,MAAMW,KAAK,GAAGT,UAAU,CAAC,CACvBE,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,EAC5BA,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,EAC5BA,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,EAC7BA,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,EAC5BA,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,CAC7B,CAAC;IACFL,MAAM,CAACY,KAAK,CAACQ,GAAG,CAAEC,CAAC,IAAMA,CAAC,CAACP,IAAI,KAAK,OAAO,GAAG,SAASO,CAAC,CAACF,KAAK,EAAE,GAAG,QAAQE,CAAC,CAAChB,IAAI,CAACC,EAAE,EAAG,CAAC,CAAC,CAACO,OAAO,CAAC,CAChG,SAAS,EACT,QAAQ,EACR,SAAS,CACV,CAAC;EACJ,CAAC,CAAC;EAEFZ,EAAE,CAAC,8EAA8E,EAAE,MAAM;IACvF,MAAMW,KAAK,GAAGT,UAAU,CAAC,CACvBE,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,EAC5BA,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EACtCA,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,EAC5BA,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,CACxC,CAAC;IACFL,MAAM,CAACY,KAAK,CAACQ,GAAG,CAAEC,CAAC,IAAKA,CAAC,CAACP,IAAI,CAAC,CAAC,CAACD,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;EAC5E,CAAC,CAAC;AACJ,CAAC,CAAC;AAEFd,QAAQ,CAAC,YAAY,EAAE,MAAM;EAC3BE,EAAE,CAAC,mCAAmC,EAAE,MAAM;IAC5CD,MAAM,CACJI,UAAU,CAAC;MAAEkB,SAAS,EAAE,KAAK;MAAEC,OAAO,EAAE,MAAM;MAAEC,SAAS,EAAE,CAACnB,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,EAAEA,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC;IAAE,CAAC,CAC5H,CAAC,CAACa,IAAI,CAAC,iBAAiB,CAAC;EAC3B,CAAC,CAAC;EAEFjB,EAAE,CAAC,sDAAsD,EAAE,MAAM;IAC/DD,MAAM,CACJI,UAAU,CAAC;MACTkB,SAAS,EAAE,CAAC;MACZC,OAAO,EAAE,MAAM;MACfC,SAAS,EAAE,CACTnB,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,EAC5BA,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,EACvCA,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,CAAC,EAC/CA,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC;IAE5C,CAAC,CACH,CAAC,CAACa,IAAI,CAAC,qDAAqD,CAAC;EAC/D,CAAC,CAAC;EAEFjB,EAAE,CAAC,mDAAmD,EAAE,MAAM;IAC5DD,MAAM,CAACI,UAAU,CAAC;MAAEmB,OAAO,EAAE,KAAK;MAAEC,SAAS,EAAE;IAAG,CAAC,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;IAChEzB,MAAM,CAACI,UAAU,CAAC;MAAEmB,OAAO,EAAE,KAAK;MAAEC,SAAS,EAAE,CAACnB,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC;IAAE,CAAC,CAAC,CAAC,CAACa,IAAI,CAAC,UAAU,CAAC;EACpG,CAAC,CAAC;AACJ,CAAC,CAAC;AAEFnB,QAAQ,CAAC,eAAe,EAAE,MAAM;EAC9BE,EAAE,CAAC,YAAY,EAAE,MAAM;IACrBD,MAAM,CAACE,aAAa,CAAC,KAAK,CAAC,CAAC,CAACgB,IAAI,CAAC,IAAI,CAAC;IACvClB,MAAM,CAACE,aAAa,CAAC,MAAM,CAAC,CAAC,CAACgB,IAAI,CAAC,QAAQ,CAAC;IAC5ClB,MAAM,CAACE,aAAa,CAAC,SAAS,CAAC,CAAC,CAACgB,IAAI,CAAC,QAAQ,CAAC;EACjD,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -1 +1,67 @@
1
- "use strict";import{definePersistedSetting,devToolsStorageKeys}from"@buoy-gg/shared-ui";export const DEFAULT_SETTINGS={showThinking:!1,bypassApprovals:!1,readOnly:!1};const store=definePersistedSetting(`${devToolsStorageKeys.base}_ask_buoy_settings`,DEFAULT_SETTINGS,{sanitize:e=>({showThinking:!0===e.showThinking,bypassApprovals:!0===e.bypassApprovals,readOnly:!0===e.readOnly})});let current=DEFAULT_SETTINGS,loaded=!1;const listeners=new Set;function emit(){for(const e of listeners)try{e()}catch{}}export const askBuoySettings={get:()=>current,subscribe:e=>(listeners.add(e),loaded||(loaded=!0,store.load().then(e=>{current=e,emit()})),()=>listeners.delete(e)),set(e,s){current[e]!==s&&(current={...current,[e]:s},emit(),store.save(current))},reset(){current=DEFAULT_SETTINGS,loaded=!1,store.clear()}};
1
+ "use strict";
2
+
3
+ /**
4
+ * Ask Buoy's own preferences — the things a tester sets on the sheet, not the
5
+ * things a developer sets in `askBuoy={{ … }}`.
6
+ *
7
+ * Module-level and subscribable for the same reason the transcript is: the
8
+ * sheet unmounts whenever the tool is closed or minimised, and a preference
9
+ * that reset on every close would not be a preference.
10
+ */
11
+ import { definePersistedSetting, devToolsStorageKeys } from "@buoy-gg/shared-ui";
12
+ export const DEFAULT_SETTINGS = {
13
+ showThinking: false,
14
+ bypassApprovals: false,
15
+ readOnly: false
16
+ };
17
+ const store = definePersistedSetting(`${devToolsStorageKeys.base}_ask_buoy_settings`, DEFAULT_SETTINGS, {
18
+ sanitize: merged => ({
19
+ showThinking: merged.showThinking === true,
20
+ // Fails closed: anything but a literal `true` on disk means "ask me".
21
+ bypassApprovals: merged.bypassApprovals === true,
22
+ readOnly: merged.readOnly === true
23
+ })
24
+ });
25
+ let current = DEFAULT_SETTINGS;
26
+ let loaded = false;
27
+ const listeners = new Set();
28
+ function emit() {
29
+ for (const fn of listeners) {
30
+ try {
31
+ fn();
32
+ } catch {
33
+ // A throwing subscriber must not take the sheet down.
34
+ }
35
+ }
36
+ }
37
+ export const askBuoySettings = {
38
+ get: () => current,
39
+ subscribe(fn) {
40
+ listeners.add(fn);
41
+ // First subscriber pays for the read; everyone after gets the cached value.
42
+ if (!loaded) {
43
+ loaded = true;
44
+ void store.load().then(value => {
45
+ current = value;
46
+ emit();
47
+ });
48
+ }
49
+ return () => listeners.delete(fn);
50
+ },
51
+ set(key, value) {
52
+ if (current[key] === value) return;
53
+ current = {
54
+ ...current,
55
+ [key]: value
56
+ };
57
+ emit();
58
+ void store.save(current);
59
+ },
60
+ /** Tests only — the module cache would otherwise leak between them. */
61
+ reset() {
62
+ current = DEFAULT_SETTINGS;
63
+ loaded = false;
64
+ void store.clear();
65
+ }
66
+ };
67
+ //# sourceMappingURL=askBuoySettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["definePersistedSetting","devToolsStorageKeys","DEFAULT_SETTINGS","showThinking","bypassApprovals","readOnly","store","base","sanitize","merged","current","loaded","listeners","Set","emit","fn","askBuoySettings","get","subscribe","add","load","then","value","delete","set","key","save","reset","clear"],"sourceRoot":"../../../src","sources":["store/askBuoySettings.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,sBAAsB,EAAEC,mBAAmB,QAAQ,oBAAoB;AAwChF,OAAO,MAAMC,gBAAiC,GAAG;EAC/CC,YAAY,EAAE,KAAK;EACnBC,eAAe,EAAE,KAAK;EACtBC,QAAQ,EAAE;AACZ,CAAC;AAED,MAAMC,KAAK,GAAGN,sBAAsB,CAClC,GAAGC,mBAAmB,CAACM,IAAI,oBAAoB,EAC/CL,gBAAgB,EAChB;EACEM,QAAQ,EAAGC,MAAM,KAAM;IACrBN,YAAY,EAAEM,MAAM,CAACN,YAAY,KAAK,IAAI;IAC1C;IACAC,eAAe,EAAEK,MAAM,CAACL,eAAe,KAAK,IAAI;IAChDC,QAAQ,EAAEI,MAAM,CAACJ,QAAQ,KAAK;EAChC,CAAC;AACH,CACF,CAAC;AAED,IAAIK,OAAwB,GAAGR,gBAAgB;AAC/C,IAAIS,MAAM,GAAG,KAAK;AAClB,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAa,CAAC;AAEvC,SAASC,IAAIA,CAAA,EAAS;EACpB,KAAK,MAAMC,EAAE,IAAIH,SAAS,EAAE;IAC1B,IAAI;MACFG,EAAE,CAAC,CAAC;IACN,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ;AACF;AAEA,OAAO,MAAMC,eAAe,GAAG;EAC7BC,GAAG,EAAEA,CAAA,KAAuBP,OAAO;EAEnCQ,SAASA,CAACH,EAAc,EAAc;IACpCH,SAAS,CAACO,GAAG,CAACJ,EAAE,CAAC;IACjB;IACA,IAAI,CAACJ,MAAM,EAAE;MACXA,MAAM,GAAG,IAAI;MACb,KAAKL,KAAK,CAACc,IAAI,CAAC,CAAC,CAACC,IAAI,CAAEC,KAAK,IAAK;QAChCZ,OAAO,GAAGY,KAAK;QACfR,IAAI,CAAC,CAAC;MACR,CAAC,CAAC;IACJ;IACA,OAAO,MAAMF,SAAS,CAACW,MAAM,CAACR,EAAE,CAAC;EACnC,CAAC;EAEDS,GAAGA,CAAkCC,GAAM,EAAEH,KAAyB,EAAQ;IAC5E,IAAIZ,OAAO,CAACe,GAAG,CAAC,KAAKH,KAAK,EAAE;IAC5BZ,OAAO,GAAG;MAAE,GAAGA,OAAO;MAAE,CAACe,GAAG,GAAGH;IAAM,CAAC;IACtCR,IAAI,CAAC,CAAC;IACN,KAAKR,KAAK,CAACoB,IAAI,CAAChB,OAAO,CAAC;EAC1B,CAAC;EAED;EACAiB,KAAKA,CAAA,EAAS;IACZjB,OAAO,GAAGR,gBAAgB;IAC1BS,MAAM,GAAG,KAAK;IACd,KAAKL,KAAK,CAACsB,KAAK,CAAC,CAAC;EACpB;AACF,CAAC","ignoreList":[]}
@@ -1 +1,583 @@
1
- "use strict";import{idFactory}from"@buoy-gg/agent-core";const nextId=idFactory("m"),MAX_PARAM_CHARS=400;function encodeParams(e){if(e&&0!==Object.keys(e).length)try{const t=JSON.stringify(e);return t.length>400?`${t.slice(0,400)}…`:t}catch{return}}const nextQueuedId=idFactory("q");let state={messages:[],busy:!1,stopping:!1,pending:null,trusted:[],notice:null,configured:!1,answers:{},awaitingBlockId:null,actionState:{},queued:[],draft:null,usage:{input:0,output:0,requests:0},meta:{}};const listeners=new Set;let ledgerRef=null,heldSession=null;function set(e){state={...state,...e};for(const e of listeners)try{e()}catch{}}export const askBuoyStore={getState:()=>state,subscribe:e=>(listeners.add(e),()=>listeners.delete(e)),setLedger(e){ledgerRef=e},getLedger:()=>ledgerRef,holdSession(e,t){heldSession={session:e,signature:t}},getHeldSession:()=>heldSession,setNotice(e){set({notice:e})},setConfigured(e){e!==state.configured&&set({configured:e})},setMeta(e){Object.keys(e).every(t=>state.meta[t]===e[t])||set({meta:{...state.meta,...e}})},addUser(e){set({messages:[...state.messages,{id:nextId(),role:"user",text:e,toolCalls:[],blocks:[]}],busy:!0})},beginTurn(){set({busy:!0})},enqueue(e){const t={id:nextQueuedId(),text:e};return set({queued:[...state.queued,t]}),t},removeQueued(e){state.queued.some(t=>t.id===e)&&set({queued:state.queued.filter(t=>t.id!==e)})},shiftQueued(){const[e,...t]=state.queued;if(e)return set({queued:t}),e},takeQueuedToDraft(e){const t=state.queued.find(t=>t.id===e);t&&set({queued:state.queued.filter(t=>t.id!==e),draft:t.text})},requestStop(){state.busy&&!state.stopping&&set({stopping:!0})},clearDraft(){null!==state.draft&&set({draft:null})},removeMessage(e){set({messages:state.messages.filter(t=>t.id!==e)})},recordAnswer(e){set({answers:{...state.answers,[e.blockId]:e},awaitingBlockId:state.awaitingBlockId===e.blockId?null:state.awaitingBlockId})},setActionState(e,t){const s={...state.actionState};null===t?delete s[e]:s[e]=t,set({actionState:s})},startAssistant(){const e=nextId();return set({messages:[...state.messages,{id:e,role:"assistant",text:"",toolCalls:[],blocks:[],streaming:!0,startedAt:Date.now()}]}),e},applyEvent(e,t){if("history-trimmed"===t.type){const s=state.messages.findIndex(t=>t.id===e),a={id:nextId(),role:"assistant",system:!0,text:`Older messages were trimmed from the agent's memory (${t.droppedRounds} exchange${1===t.droppedRounds?"":"s"}).`+(t.droppedPinned?` ${1===t.droppedPinned?"One of them made a change that is":`${t.droppedPinned} of them made changes that are`} still applied — the changes bar still lists ${1===t.droppedPinned?"it":"them"}, but the agent no longer remembers making ${1===t.droppedPinned?"it":"them"}.`:" It may not recall setup from earlier in this chat — the changes bar still lists what is applied."),toolCalls:[],blocks:[],endedAt:Date.now()},n=[...state.messages];return n.splice(s<0?n.length:s,0,a),void set({messages:n})}set({messages:state.messages.map(s=>{if(s.id!==e)return s;switch(t.type){case"retrying":{const e=Math.max(1,Math.round(t.inMs/1e3));return{...s,waiting:"throttled"===t.reason?`Endpoint busy — retrying in ${e}s (${t.attempt} of ${t.maxAttempts})`:"Request too large — trimming older messages and retrying"}}case"text":return{...s,waiting:void 0,text:(s.breakBeforeNextText||t.breakBefore)&&s.text?`${s.text.trimEnd()}\n\n${t.delta}`:s.text+t.delta,breakBeforeNextText:!1};case"reasoning":return{...s,breakBeforeNextText:!0,reasoning:[...s.reasoning??[],{text:t.text,afterCalls:s.toolCalls.length}]};case"tool-start":return{...s,waiting:void 0,toolCalls:[...s.toolCalls,{id:t.id,toolId:t.toolId,action:t.action,label:t.label,description:t.description,status:"running",params:encodeParams(t.params),effect:t.effect,startedAt:Date.now()}]};case"tool-end":return{...s,breakBeforeNextText:!0,toolCalls:s.toolCalls.map(e=>e.id===t.id?{...e,status:t.ok||"refused"!==t.summary?t.ok||"declined"!==t.summary?t.ok||"stopped"!==t.summary?t.ok?"ok":"failed":"stopped":"declined":"refused",summary:t.summary,durationMs:t.durationMs,result:t.result}:e)};case"tool-verified":return{...s,toolCalls:s.toolCalls.map(e=>e.id===t.id?{...e,verification:t.verification}:e)};case"block":return{...s,breakBeforeNextText:!0,blocks:[...s.blocks,{block:t.block,forToolCallId:t.forToolCallId}]};case"usage":return{...s,usage:{input:(s.usage?.input??0)+t.input,output:(s.usage?.output??0)+t.output,requests:(s.usage?.requests??0)+1}};case"error":return{...s,waiting:void 0,error:t.message};default:return s}}),..."awaiting-user"===t.type?{awaitingBlockId:t.blockId}:{},..."usage"===t.type?{usage:{input:state.usage.input+t.input,output:state.usage.output+t.output,requests:state.usage.requests+1}}:{}})},markStopped(e){set({messages:state.messages.map(t=>t.id===e?{...t,stopped:!0}:t)})},finishAssistant(e){set({messages:state.messages.map(t=>t.id===e?{...t,streaming:!1,endedAt:Date.now()}:t),busy:!1,stopping:!1})},askApproval:e=>new Promise(t=>{set({pending:{...e,resolve:t}})}),answerApproval(e){const t=state.pending,s="boolean"==typeof e?e:e.approved,a="boolean"!=typeof e&&!0===e.trust&&s,n=t?`${t.toolId}.${t.action}`:"";set({pending:null,...a&&t&&!state.trusted.some(e=>e.key===n)?{trusted:[...state.trusted,{key:n,label:t.label}]}:{}}),t?.resolve(e)},untrust(e){heldSession?.session.untrust(e),set({trusted:state.trusted.filter(t=>t.key!==e)})},restorePending:e=>!state.pending&&!state.busy&&(set({pending:{...e,restored:!0,resolve:()=>{}}}),!0),addNote(e){set({messages:[...state.messages,{id:nextId(),role:"assistant",text:e,toolCalls:[],blocks:[],endedAt:Date.now()}]})},hydrate:e=>!(state.messages.length>0||state.busy||(set({messages:e.messages.map(e=>({...e,restored:!0})),answers:e.answers,usage:e.usage,queued:e.queued??[]}),0)),reset(){state.pending?.resolve(!1),set({messages:[],busy:!1,stopping:!1,pending:null,trusted:[],notice:null,answers:{},awaitingBlockId:null,actionState:{},queued:[],draft:null,usage:{input:0,output:0,requests:0}})}};export function turnPhaseOf(e){return e.pending?"awaitingApproval":e.busy?e.stopping?"stopping":"running":e.awaitingBlockId?"awaitingAnswer":"idle"}export function queuePauseReason(e){const t=turnPhaseOf(e);if("running"===t||"stopping"===t)return null;if("awaitingApproval"===t)return"Paused — answer the approval above first.";if("awaitingAnswer"===t)return"Paused — answer the question above first.";const s=e.messages[e.messages.length-1];return"assistant"===s?.role&&s.error?"Paused — the last turn failed.":"assistant"===s?.role&&s.stopped?"Paused — you stopped the last turn.":null}
1
+ "use strict";
2
+
3
+ /**
4
+ * Conversation state for the sheet.
5
+ *
6
+ * A module-level store rather than component state for two reasons: the sheet
7
+ * is unmounted whenever the tool is closed or minimised (and a conversation
8
+ * that vanished because someone tapped away would be maddening), and the sync
9
+ * adapter needs to read the same transcript to show it on the desktop.
10
+ *
11
+ * Persisted across restarts, on purpose, with the payloads left out — see
12
+ * `transcriptPersistence.ts` for what is written and what that costs. The
13
+ * store itself stays a plain in-memory store; saving is a subscriber, and
14
+ * `hydrate` is the one way anything comes back in.
15
+ */
16
+ import { idFactory } from "@buoy-gg/agent-core";
17
+
18
+ /** A block in a message, and (for receipts) the tool call that produced it. */
19
+
20
+ /**
21
+ * A stretch of the model's own reasoning, and where it fell.
22
+ *
23
+ * `afterCalls` is how many tool calls this message had already made when the
24
+ * thought arrived, so the thinking view can lay reasoning and steps out in the
25
+ * order they actually happened. One assistant bubble spans every turn of a
26
+ * multi-step run, so "think, act, think, act" is the normal shape and showing
27
+ * all the thoughts in a lump at the top would misreport it.
28
+ */
29
+
30
+ /**
31
+ * A message typed while a turn was running.
32
+ *
33
+ * A list with ids, not a string: the single slot it replaced OVERWROTE — type
34
+ * two things mid-turn and the first vanished, which is precisely the loss the
35
+ * queue exists to prevent. Ids so two identical requests stay distinguishable
36
+ * and the list can be edited by row.
37
+ */
38
+
39
+ /**
40
+ * The one word every component reads to know what the chat is doing.
41
+ *
42
+ * Presentation state (minimised, settings open) is NOT in here on purpose —
43
+ * it sits on top. This exists because the header, the composer, the queue
44
+ * flush and the modal each used to derive their own answer from five
45
+ * overlapping booleans, and disagreed: the queue fired after an error because
46
+ * "not busy" looked like "idle" to it.
47
+ */
48
+
49
+ /**
50
+ * Message ids carry this run's token — see agent-core's `runId`. A plain `m1`
51
+ * collided head-on with the `m1` in a restored transcript, and the message
52
+ * list keys on it.
53
+ */
54
+ const nextId = idFactory("m");
55
+
56
+ /**
57
+ * Params, as one readable line. Capped because a step can carry a whole
58
+ * response body or a store's full state, and this is chrome inside a chat
59
+ * bubble — the full value is a tool read away.
60
+ */
61
+ const MAX_PARAM_CHARS = 400;
62
+ function encodeParams(params) {
63
+ if (!params || Object.keys(params).length === 0) return undefined;
64
+ try {
65
+ const json = JSON.stringify(params);
66
+ return json.length > MAX_PARAM_CHARS ? `${json.slice(0, MAX_PARAM_CHARS)}…` : json;
67
+ } catch {
68
+ return undefined;
69
+ }
70
+ }
71
+
72
+ /** Queue ids carry the run token too — a restored queue keys on them. */
73
+ const nextQueuedId = idFactory("q");
74
+ let state = {
75
+ messages: [],
76
+ busy: false,
77
+ stopping: false,
78
+ pending: null,
79
+ trusted: [],
80
+ notice: null,
81
+ configured: false,
82
+ answers: {},
83
+ awaitingBlockId: null,
84
+ actionState: {},
85
+ queued: [],
86
+ draft: null,
87
+ usage: {
88
+ input: 0,
89
+ output: 0,
90
+ requests: 0
91
+ },
92
+ meta: {}
93
+ };
94
+ const listeners = new Set();
95
+ let ledgerRef = null;
96
+
97
+ /**
98
+ * The session outlives the sheet the same way the transcript does. Session and
99
+ * ledger used to be per-mount: closing and reopening the tool kept the visible
100
+ * conversation but silently swapped in an empty ledger and a blank model
101
+ * memory — the undo bar vanished while the agent's changes stayed live in the
102
+ * app. Held here, keyed by a config signature so a real reconfiguration
103
+ * (different endpoint/model/tool set) still rebuilds.
104
+ */
105
+ let heldSession = null;
106
+ function set(next) {
107
+ state = {
108
+ ...state,
109
+ ...next
110
+ };
111
+ for (const fn of listeners) {
112
+ try {
113
+ fn();
114
+ } catch {
115
+ // A throwing subscriber must not take the transcript down mid-answer.
116
+ }
117
+ }
118
+ }
119
+ export const askBuoyStore = {
120
+ getState: () => state,
121
+ subscribe(fn) {
122
+ listeners.add(fn);
123
+ return () => listeners.delete(fn);
124
+ },
125
+ setLedger(ledger) {
126
+ ledgerRef = ledger;
127
+ },
128
+ getLedger() {
129
+ return ledgerRef;
130
+ },
131
+ holdSession(session, signature) {
132
+ heldSession = {
133
+ session,
134
+ signature
135
+ };
136
+ },
137
+ getHeldSession() {
138
+ return heldSession;
139
+ },
140
+ setNotice(notice) {
141
+ set({
142
+ notice
143
+ });
144
+ },
145
+ setConfigured(configured) {
146
+ if (configured !== state.configured) set({
147
+ configured
148
+ });
149
+ },
150
+ setMeta(meta) {
151
+ const same = Object.keys(meta).every(k => state.meta[k] === meta[k]);
152
+ if (!same) set({
153
+ meta: {
154
+ ...state.meta,
155
+ ...meta
156
+ }
157
+ });
158
+ },
159
+ addUser(text) {
160
+ set({
161
+ messages: [...state.messages, {
162
+ id: nextId(),
163
+ role: "user",
164
+ text,
165
+ toolCalls: [],
166
+ blocks: []
167
+ }],
168
+ busy: true
169
+ });
170
+ },
171
+ /** Mark a turn as running without adding a bubble — the retry path. */
172
+ beginTurn() {
173
+ set({
174
+ busy: true
175
+ });
176
+ },
177
+ /** Park a message typed mid-turn, behind whatever is already parked. */
178
+ enqueue(text) {
179
+ const item = {
180
+ id: nextQueuedId(),
181
+ text
182
+ };
183
+ set({
184
+ queued: [...state.queued, item]
185
+ });
186
+ return item;
187
+ },
188
+ /** Drop one parked message — the ✕ on its row. */
189
+ removeQueued(id) {
190
+ if (!state.queued.some(q => q.id === id)) return;
191
+ set({
192
+ queued: state.queued.filter(q => q.id !== id)
193
+ });
194
+ },
195
+ /** Take the FIRST parked message off the queue — the flush path. */
196
+ shiftQueued() {
197
+ const [next, ...rest] = state.queued;
198
+ if (!next) return undefined;
199
+ set({
200
+ queued: rest
201
+ });
202
+ return next;
203
+ },
204
+ /** Hand one parked message back to the composer to edit. See `draft`. */
205
+ takeQueuedToDraft(id) {
206
+ const item = state.queued.find(q => q.id === id);
207
+ if (!item) return;
208
+ set({
209
+ queued: state.queued.filter(q => q.id !== id),
210
+ draft: item.text
211
+ });
212
+ },
213
+ /**
214
+ * The user pressed Stop. The turn is still winding down — the abort is only
215
+ * read between calls — so the phase is `stopping`, not `idle`, until
216
+ * `finishAssistant` lands.
217
+ */
218
+ requestStop() {
219
+ if (!state.busy || state.stopping) return;
220
+ set({
221
+ stopping: true
222
+ });
223
+ },
224
+ /** The composer has taken the draft into its input. */
225
+ clearDraft() {
226
+ if (state.draft === null) return;
227
+ set({
228
+ draft: null
229
+ });
230
+ },
231
+ /** Drop one message — the failed assistant bubble a retry replaces. */
232
+ removeMessage(id) {
233
+ set({
234
+ messages: state.messages.filter(m => m.id !== id)
235
+ });
236
+ },
237
+ /** The user answered (or skipped) an Ask block. */
238
+ recordAnswer(answer) {
239
+ set({
240
+ answers: {
241
+ ...state.answers,
242
+ [answer.blockId]: answer
243
+ },
244
+ awaitingBlockId: state.awaitingBlockId === answer.blockId ? null : state.awaitingBlockId
245
+ });
246
+ },
247
+ setActionState(key, value) {
248
+ const next = {
249
+ ...state.actionState
250
+ };
251
+ if (value === null) delete next[key];else next[key] = value;
252
+ set({
253
+ actionState: next
254
+ });
255
+ },
256
+ /** Open a new assistant bubble for the turn that is about to stream. */
257
+ startAssistant() {
258
+ const id = nextId();
259
+ set({
260
+ messages: [...state.messages, {
261
+ id,
262
+ role: "assistant",
263
+ text: "",
264
+ toolCalls: [],
265
+ blocks: [],
266
+ streaming: true,
267
+ startedAt: Date.now()
268
+ }]
269
+ });
270
+ return id;
271
+ },
272
+ /**
273
+ * Fold one engine event into the open assistant message.
274
+ *
275
+ * Tool calls render as rows inside the bubble rather than as raw payloads:
276
+ * the label is already domain-flavoured ("Set points to 1500"), which is the
277
+ * only form a non-developer can actually check.
278
+ */
279
+ applyEvent(messageId, ev) {
280
+ if (ev.type === "history-trimmed") {
281
+ // Before the answer it affects, so it reads as a caption on the gap
282
+ // rather than as part of the reply.
283
+ const at = state.messages.findIndex(m => m.id === messageId);
284
+ const line = {
285
+ id: nextId(),
286
+ role: "assistant",
287
+ system: true,
288
+ text: `Older messages were trimmed from the agent's memory (${ev.droppedRounds} exchange${ev.droppedRounds === 1 ? "" : "s"}).` + (ev.droppedPinned ? ` ${ev.droppedPinned === 1 ? "One of them made a change that is" : `${ev.droppedPinned} of them made changes that are`} still applied — the changes bar still lists ${ev.droppedPinned === 1 ? "it" : "them"}, but the agent no longer remembers making ${ev.droppedPinned === 1 ? "it" : "them"}.` : " It may not recall setup from earlier in this chat — the changes bar still lists what is applied."),
289
+ toolCalls: [],
290
+ blocks: [],
291
+ endedAt: Date.now()
292
+ };
293
+ const next = [...state.messages];
294
+ next.splice(at < 0 ? next.length : at, 0, line);
295
+ set({
296
+ messages: next
297
+ });
298
+ return;
299
+ }
300
+ const messages = state.messages.map(m => {
301
+ if (m.id !== messageId) return m;
302
+ switch (ev.type) {
303
+ case "retrying":
304
+ {
305
+ const secs = Math.max(1, Math.round(ev.inMs / 1000));
306
+ return {
307
+ ...m,
308
+ waiting: ev.reason === "throttled" ? `Endpoint busy — retrying in ${secs}s (${ev.attempt} of ${ev.maxAttempts})` : `Request too large — trimming older messages and retrying`
309
+ };
310
+ }
311
+ case "text":
312
+ return {
313
+ ...m,
314
+ waiting: undefined,
315
+ text: (m.breakBeforeNextText || ev.breakBefore) && m.text ? `${m.text.trimEnd()}\n\n${ev.delta}` : m.text + ev.delta,
316
+ breakBeforeNextText: false
317
+ };
318
+ case "reasoning":
319
+ return {
320
+ ...m,
321
+ breakBeforeNextText: true,
322
+ reasoning: [...(m.reasoning ?? []), {
323
+ text: ev.text,
324
+ afterCalls: m.toolCalls.length
325
+ }]
326
+ };
327
+ case "tool-start":
328
+ return {
329
+ ...m,
330
+ waiting: undefined,
331
+ toolCalls: [...m.toolCalls, {
332
+ id: ev.id,
333
+ toolId: ev.toolId,
334
+ action: ev.action,
335
+ label: ev.label,
336
+ description: ev.description,
337
+ status: "running",
338
+ params: encodeParams(ev.params),
339
+ effect: ev.effect,
340
+ startedAt: Date.now()
341
+ }]
342
+ };
343
+ case "tool-end":
344
+ return {
345
+ ...m,
346
+ breakBeforeNextText: true,
347
+ toolCalls: m.toolCalls.map(c => c.id === ev.id ? {
348
+ ...c,
349
+ status: !ev.ok && ev.summary === "refused" ? "refused" : !ev.ok && ev.summary === "declined" ? "declined" : !ev.ok && ev.summary === "stopped" ? "stopped" : ev.ok ? "ok" : "failed",
350
+ summary: ev.summary,
351
+ durationMs: ev.durationMs,
352
+ result: ev.result
353
+ } : c)
354
+ };
355
+ case "tool-verified":
356
+ return {
357
+ ...m,
358
+ toolCalls: m.toolCalls.map(c => c.id === ev.id ? {
359
+ ...c,
360
+ verification: ev.verification
361
+ } : c)
362
+ };
363
+ case "block":
364
+ return {
365
+ ...m,
366
+ breakBeforeNextText: true,
367
+ blocks: [...m.blocks, {
368
+ block: ev.block,
369
+ forToolCallId: ev.forToolCallId
370
+ }]
371
+ };
372
+ case "usage":
373
+ // Also folded into the session total below. Per MESSAGE as well,
374
+ // because "which answer cost 40k tokens" is the question you ask
375
+ // when a bill looks wrong, and a session total cannot answer it.
376
+ return {
377
+ ...m,
378
+ usage: {
379
+ input: (m.usage?.input ?? 0) + ev.input,
380
+ output: (m.usage?.output ?? 0) + ev.output,
381
+ requests: (m.usage?.requests ?? 0) + 1
382
+ }
383
+ };
384
+ case "error":
385
+ return {
386
+ ...m,
387
+ waiting: undefined,
388
+ error: ev.message
389
+ };
390
+ default:
391
+ return m;
392
+ }
393
+ });
394
+ set({
395
+ messages,
396
+ ...(ev.type === "awaiting-user" ? {
397
+ awaitingBlockId: ev.blockId
398
+ } : {}),
399
+ ...(ev.type === "usage" ? {
400
+ usage: {
401
+ input: state.usage.input + ev.input,
402
+ output: state.usage.output + ev.output,
403
+ requests: state.usage.requests + 1
404
+ }
405
+ } : {})
406
+ });
407
+ },
408
+ /** The user pressed Stop on this turn. See `ChatMessage.stopped`. */
409
+ markStopped(messageId) {
410
+ set({
411
+ messages: state.messages.map(m => m.id === messageId ? {
412
+ ...m,
413
+ stopped: true
414
+ } : m)
415
+ });
416
+ },
417
+ finishAssistant(messageId) {
418
+ set({
419
+ messages: state.messages.map(m => m.id === messageId ? {
420
+ ...m,
421
+ streaming: false,
422
+ endedAt: Date.now()
423
+ } : m),
424
+ busy: false,
425
+ stopping: false
426
+ });
427
+ },
428
+ askApproval(input) {
429
+ return new Promise(resolve => {
430
+ set({
431
+ pending: {
432
+ ...input,
433
+ resolve
434
+ }
435
+ });
436
+ });
437
+ },
438
+ /**
439
+ * The user's answer, in full: yes/no, an optional note on a no (it goes to
440
+ * the model verbatim), and on a yes whether to stop asking about this
441
+ * action for the rest of the conversation. A bare boolean still works.
442
+ */
443
+ answerApproval(answer) {
444
+ const pending = state.pending;
445
+ const approved = typeof answer === "boolean" ? answer : answer.approved;
446
+ const trust = typeof answer !== "boolean" && answer.trust === true && approved;
447
+ const key = pending ? `${pending.toolId}.${pending.action}` : "";
448
+ set({
449
+ pending: null,
450
+ ...(trust && pending && !state.trusted.some(t => t.key === key) ? {
451
+ trusted: [...state.trusted, {
452
+ key,
453
+ label: pending.label
454
+ }]
455
+ } : {})
456
+ });
457
+ pending?.resolve(answer);
458
+ },
459
+ /** Ask again for this action. Removes it from the session's waiver set too. */
460
+ untrust(key) {
461
+ heldSession?.session.untrust(key);
462
+ set({
463
+ trusted: state.trusted.filter(t => t.key !== key)
464
+ });
465
+ },
466
+ /**
467
+ * Put an unanswered approval back after a restart.
468
+ *
469
+ * A question the app asked and then forgot is worse than not asking: the
470
+ * user tapped nothing, so as far as they are concerned the change is still
471
+ * waiting for them. `resolve` is a no-op because nothing is waiting on this
472
+ * one any more; `restored` is what tells the sheet to run the call rather
473
+ * than answer a dead promise.
474
+ *
475
+ * Refused once a turn is under way, for the same reason `hydrate` is: a slow
476
+ * disk read must not shove an old question in front of a live conversation.
477
+ */
478
+ restorePending(input) {
479
+ if (state.pending || state.busy) return false;
480
+ set({
481
+ pending: {
482
+ ...input,
483
+ restored: true,
484
+ resolve: () => {}
485
+ }
486
+ });
487
+ return true;
488
+ },
489
+ /**
490
+ * A line in the transcript from Buoy itself rather than from the model.
491
+ *
492
+ * It wears the assistant's bubble because that is the only shape the list
493
+ * renders, but nothing is sent to the model and nothing lands in its
494
+ * history — it exists so an approval answered after a restart leaves a
495
+ * trace, instead of the card silently vanishing a second time.
496
+ */
497
+ addNote(text) {
498
+ set({
499
+ messages: [...state.messages, {
500
+ id: nextId(),
501
+ role: "assistant",
502
+ text,
503
+ toolCalls: [],
504
+ blocks: [],
505
+ endedAt: Date.now()
506
+ }]
507
+ });
508
+ },
509
+ /**
510
+ * Put a saved conversation back, once, at open.
511
+ *
512
+ * Refuses if anything has been said already: a slow disk read landing after
513
+ * the user has started typing must not shove an old chat in front of them.
514
+ */
515
+ hydrate(input) {
516
+ if (state.messages.length > 0 || state.busy) return false;
517
+ set({
518
+ messages: input.messages.map(m => ({
519
+ ...m,
520
+ restored: true
521
+ })),
522
+ answers: input.answers,
523
+ usage: input.usage,
524
+ queued: input.queued ?? []
525
+ });
526
+ return true;
527
+ },
528
+ reset() {
529
+ // Reject anything still waiting, or the turn hangs forever on a promise
530
+ // whose only resolver just left the screen.
531
+ state.pending?.resolve(false);
532
+ set({
533
+ messages: [],
534
+ busy: false,
535
+ stopping: false,
536
+ pending: null,
537
+ trusted: [],
538
+ notice: null,
539
+ answers: {},
540
+ awaitingBlockId: null,
541
+ actionState: {},
542
+ queued: [],
543
+ draft: null,
544
+ usage: {
545
+ input: 0,
546
+ output: 0,
547
+ requests: 0
548
+ }
549
+ // `meta` survives: it describes the app and the endpoint, not the
550
+ // conversation, and re-deriving it would need another render pass.
551
+ });
552
+ }
553
+ };
554
+
555
+ /** See TurnPhase. Pure, so every component and the flush effect agree. */
556
+ export function turnPhaseOf(s) {
557
+ if (s.pending) return "awaitingApproval";
558
+ if (s.busy) return s.stopping ? "stopping" : "running";
559
+ if (s.awaitingBlockId) return "awaitingAnswer";
560
+ return "idle";
561
+ }
562
+
563
+ /**
564
+ * Why parked messages are NOT being sent right now, in the user's words — or
565
+ * null when the queue may deliver.
566
+ *
567
+ * A queued message is a next TASK, not an answer. It used to go the moment
568
+ * `busy` dropped: after an error it fired into the same dead connection, and
569
+ * with a choice block open it was sent as the reply to the question. So the
570
+ * queue holds on error, Stop, an approval and an unanswered Ask block, and
571
+ * says which.
572
+ */
573
+ export function queuePauseReason(s) {
574
+ const phase = turnPhaseOf(s);
575
+ if (phase === "running" || phase === "stopping") return null;
576
+ if (phase === "awaitingApproval") return "Paused — answer the approval above first.";
577
+ if (phase === "awaitingAnswer") return "Paused — answer the question above first.";
578
+ const last = s.messages[s.messages.length - 1];
579
+ if (last?.role === "assistant" && last.error) return "Paused — the last turn failed.";
580
+ if (last?.role === "assistant" && last.stopped) return "Paused — you stopped the last turn.";
581
+ return null;
582
+ }
583
+ //# sourceMappingURL=askBuoyStore.js.map