@buoy-gg/ask-buoy 7.0.38 → 7.0.40

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":["idFactory","nextId","MAX_PARAM_CHARS","encodeParams","params","Object","keys","length","undefined","json","JSON","stringify","slice","nextQueuedId","state","messages","busy","stopping","pending","trusted","notice","configured","answers","awaitingBlockId","actionState","queued","draft","usage","input","output","requests","meta","listeners","Set","ledgerRef","heldSession","set","next","fn","askBuoyStore","getState","subscribe","add","delete","setLedger","ledger","getLedger","holdSession","session","signature","getHeldSession","setNotice","setConfigured","setMeta","same","every","k","addUser","text","id","role","toolCalls","blocks","beginTurn","enqueue","item","removeQueued","some","q","filter","shiftQueued","rest","takeQueuedToDraft","find","requestStop","clearDraft","removeMessage","m","recordAnswer","answer","blockId","setActionState","key","value","startAssistant","streaming","startedAt","Date","now","applyEvent","messageId","ev","type","at","findIndex","line","system","droppedRounds","droppedPinned","endedAt","splice","map","secs","Math","max","round","inMs","waiting","reason","attempt","maxAttempts","breakBeforeNextText","breakBefore","trimEnd","delta","reasoning","afterCalls","toolId","action","label","description","status","effect","c","ok","summary","durationMs","result","verification","block","forToolCallId","error","message","markStopped","stopped","finishAssistant","askApproval","Promise","resolve","answerApproval","approved","trust","t","untrust","restorePending","restored","addNote","hydrate","reset","turnPhaseOf","s","queuePauseReason","phase","last"],"sourceRoot":"../../../src","sources":["store/askBuoyStore.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,qBAAqB;;AAG/C;;AAiDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA8FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAsDA;AACA;AACA;AACA;AACA;AACA,MAAMC,MAAM,GAAGD,SAAS,CAAC,GAAG,CAAC;;AAE7B;AACA;AACA;AACA;AACA;AACA,MAAME,eAAe,GAAG,GAAG;AAE3B,SAASC,YAAYA,CAACC,MAA+B,EAAsB;EACzE,IAAI,C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K,KAAK,SAAS,IAAIA,KAAK,KAAK,UAAU,EAAE,OAAO,IAAI;EAC5D,IAAIA,KAAK,KAAK,kBAAkB,EAAE,OAAO,2CAA2C;EACpF,IAAIA,KAAK,KAAK,gBAAgB,EAAE,OAAO,2CAA2C;EAClF,MAAMC,IAAI,GAAGH,CAAC,CAACvI,QAAQ,CAACuI,CAAC,CAACvI,QAAQ,CAACR,MAAM,GAAG,CAAC,CAAC;EAC9C,IAAIkJ,IAAI,EAAE7F,IAAI,KAAK,WAAW,IAAI6F,IAAI,CAACtB,KAAK,EAAE,OAAO,gCAAgC;EACrF,IAAIsB,IAAI,EAAE7F,IAAI,KAAK,WAAW,IAAI6F,IAAI,CAACnB,OAAO,EAAE,OAAO,qCAAqC;EAC5F,OAAO,IAAI;AACb","ignoreList":[]}
@@ -1 +1,59 @@
1
- "use strict";import{isAskBlock}from"@buoy-gg/agent-core";function nestsUnderStep({block:o,forToolCallId:e}){if(!e)return!1;const s="source"in o?o.source:void 0;return"live"===s||"mocked"===s}export function placeBlocks(o,e){const s=new Set(e),t=new Map,l=[],r=[];for(const e of o)if(isAskBlock(e.block))r.push(e);else if(nestsUnderStep(e)&&s.has(e.forToolCallId)){const o=t.get(e.forToolCallId)??[];o.push(e.block),t.set(e.forToolCallId,o)}else l.push(e);return{nested:t,afterText:l,ask:r}}
1
+ "use strict";
2
+
3
+ /**
4
+ * Where each block of a turn is drawn: inside a step row, after the prose as
5
+ * the answer itself, or last of all as the thing being asked.
6
+ *
7
+ * Pure and separate from MessageList because the rule is subtle and the cost
8
+ * of getting it wrong is silent — a block that lands in no bucket renders
9
+ * nowhere at all, and nothing in the UI says so. That is exactly what
10
+ * happened: "show me the shop as pictures" built its imageGrid, the engine
11
+ * accepted it, and the sheet dropped it on the floor twice while the model
12
+ * narrated the artwork in prose.
13
+ */
14
+ import { isAskBlock } from "@buoy-gg/agent-core";
15
+ /**
16
+ * A receipt that belongs inside its step row rather than in the answer: it
17
+ * came from a tool call, and it reports what was READ, not what was changed.
18
+ *
19
+ * ONLY a receipt nests, which is why this tests for the receipt provenances
20
+ * rather than for "not changed". A model-authored block (`buoy_ui`, source
21
+ * "model") also carries the id of the call that produced it — but `buoy_ui`
22
+ * emits no activity row, so there was no step for it to nest under.
23
+ */
24
+ function nestsUnderStep({
25
+ block,
26
+ forToolCallId
27
+ }) {
28
+ if (!forToolCallId) return false;
29
+ const source = "source" in block ? block.source : undefined;
30
+ return source === "live" || source === "mocked";
31
+ }
32
+ export function placeBlocks(blocks, stepIds) {
33
+ const steps = new Set(stepIds);
34
+ const nested = new Map();
35
+ const afterText = [];
36
+ const ask = [];
37
+ for (const placed of blocks) {
38
+ if (isAskBlock(placed.block)) {
39
+ ask.push(placed);
40
+ continue;
41
+ }
42
+ // A block may only nest under a step that actually has a row. Anything
43
+ // pointing at a call the activity list never drew renders with the answer
44
+ // — never nowhere.
45
+ if (nestsUnderStep(placed) && steps.has(placed.forToolCallId)) {
46
+ const list = nested.get(placed.forToolCallId) ?? [];
47
+ list.push(placed.block);
48
+ nested.set(placed.forToolCallId, list);
49
+ } else {
50
+ afterText.push(placed);
51
+ }
52
+ }
53
+ return {
54
+ nested,
55
+ afterText,
56
+ ask
57
+ };
58
+ }
59
+ //# sourceMappingURL=blockPlacement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isAskBlock","nestsUnderStep","block","forToolCallId","source","undefined","placeBlocks","blocks","stepIds","steps","Set","nested","Map","afterText","ask","placed","push","has","list","get","set"],"sourceRoot":"../../../src","sources":["store/blockPlacement.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAU,QAAoB,qBAAqB;AAoB5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,cAAcA,CAAC;EAAEC,KAAK;EAAEC;AAA2B,CAAC,EAAW;EACtE,IAAI,CAACA,aAAa,EAAE,OAAO,KAAK;EAChC,MAAMC,MAAM,GAAG,QAAQ,IAAIF,KAAK,GAAGA,KAAK,CAACE,MAAM,GAAGC,SAAS;EAC3D,OAAOD,MAAM,KAAK,MAAM,IAAIA,MAAM,KAAK,QAAQ;AACjD;AAEA,OAAO,SAASE,WAAWA,CAACC,MAAqB,EAAEC,OAAyB,EAAkB;EAC5F,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAACF,OAAO,CAAC;EAC9B,MAAMG,MAAM,GAAG,IAAIC,GAAG,CAAkB,CAAC;EACzC,MAAMC,SAAwB,GAAG,EAAE;EACnC,MAAMC,GAAkB,GAAG,EAAE;EAE7B,KAAK,MAAMC,MAAM,IAAIR,MAAM,EAAE;IAC3B,IAAIP,UAAU,CAACe,MAAM,CAACb,KAAK,CAAC,EAAE;MAC5BY,GAAG,CAACE,IAAI,CAACD,MAAM,CAAC;MAChB;IACF;IACA;IACA;IACA;IACA,IAAId,cAAc,CAACc,MAAM,CAAC,IAAIN,KAAK,CAACQ,GAAG,CAACF,MAAM,CAACZ,aAAc,CAAC,EAAE;MAC9D,MAAMe,IAAI,GAAGP,MAAM,CAACQ,GAAG,CAACJ,MAAM,CAACZ,aAAc,CAAC,IAAI,EAAE;MACpDe,IAAI,CAACF,IAAI,CAACD,MAAM,CAACb,KAAK,CAAC;MACvBS,MAAM,CAACS,GAAG,CAACL,MAAM,CAACZ,aAAa,EAAGe,IAAI,CAAC;IACzC,CAAC,MAAM;MACLL,SAAS,CAACG,IAAI,CAACD,MAAM,CAAC;IACxB;EACF;EAEA,OAAO;IAAEJ,MAAM;IAAEE,SAAS;IAAEC;EAAI,CAAC;AACnC","ignoreList":[]}
@@ -1 +1,122 @@
1
- "use strict";import{describe,expect,it}from"vitest";import{placeBlocks}from"./blockPlacement";const placed=(e,t)=>({block:e,forToolCallId:t}),grid=(e="ui1")=>placed({id:e,kind:"imageGrid",source:"model",images:[{url:"https://cdn.example.com/25.png",alt:"Pikachu"}]},"call-ui");describe("model-authored blocks",()=>{it("renders in the answer, never nested under a step that has no row",()=>{const{afterText:e,nested:t}=placeBlocks([grid()],["c1"]);expect(e.map(e=>e.block.id)).toEqual(["ui1"]),expect(t.size).toBe(0)}),it("still renders even when a step with that id somehow exists",()=>{const{afterText:e}=placeBlocks([grid()],["call-ui"]);expect(e.map(e=>e.block.id)).toEqual(["ui1"])})}),describe("receipts",()=>{it("folds a read receipt into its own step row",()=>{const e=placed({id:"r1",kind:"keyValue",source:"live",pairs:[]},"c1"),{nested:t,afterText:c}=placeBlocks([e],["c1"]);expect(c).toEqual([]),expect(t.get("c1")?.map(e=>e.id)).toEqual(["r1"])}),it("keeps a write receipt afterText — the user must see it without asking",()=>{const e=placed({id:"w1",kind:"diff",source:"changed",changes:[]},"c1"),{nested:t,afterText:c}=placeBlocks([e],["c1"]);expect(t.size).toBe(0),expect(c.map(e=>e.block.id)).toEqual(["w1"])}),it("falls back to afterText when its step row was never drawn",()=>{const e=placed({id:"r2",kind:"keyValue",source:"live",pairs:[]},"gone"),{afterText:t}=placeBlocks([e],[]);expect(t.map(e=>e.block.id)).toEqual(["r2"])})}),describe("ask blocks",()=>{it("come out in their own bucket, after the answer",()=>{const e=placed({id:"a1",kind:"confirm",source:"model",change:"Wipe storage"},"call-ui"),{ask:t,afterText:c,nested:a}=placeBlocks([e,grid("ui2")],["c1"]);expect(t.map(e=>e.block.id)).toEqual(["a1"]),expect(c.map(e=>e.block.id)).toEqual(["ui2"]),expect(a.size).toBe(0)})}),describe("the answer comes after the prose",()=>{it("puts a model-authored card in the after-text bucket, never before it",()=>{const e=placeBlocks([grid()],["c1"]);expect(e.afterText.map(e=>e.block.id)).toEqual(["ui1"]),expect(e.nested.size).toBe(0)})});
1
+ "use strict";
2
+
3
+ /**
4
+ * The bug this file exists for: a model-authored block carries the id of the
5
+ * `buoy_ui` call that made it, `buoy_ui` never draws an activity row, and the
6
+ * nesting rule ("anything from a call, unless it's a write receipt") swept it
7
+ * into a bucket keyed by a row that does not exist. Two consecutive asks for
8
+ * pictures of a shop came back as prose.
9
+ */
10
+ import { describe, expect, it } from "vitest";
11
+ import { placeBlocks } from "./blockPlacement";
12
+ const placed = (b, forToolCallId) => ({
13
+ block: b,
14
+ forToolCallId
15
+ });
16
+ const grid = (id = "ui1") => placed({
17
+ id,
18
+ kind: "imageGrid",
19
+ source: "model",
20
+ images: [{
21
+ url: "https://cdn.example.com/25.png",
22
+ alt: "Pikachu"
23
+ }]
24
+ }, "call-ui");
25
+ describe("model-authored blocks", () => {
26
+ it("renders in the answer, never nested under a step that has no row", () => {
27
+ const {
28
+ afterText,
29
+ nested
30
+ } = placeBlocks([grid()], ["c1"]);
31
+ expect(afterText.map(p => p.block.id)).toEqual(["ui1"]);
32
+ expect(nested.size).toBe(0);
33
+ });
34
+ it("still renders even when a step with that id somehow exists", () => {
35
+ const {
36
+ afterText
37
+ } = placeBlocks([grid()], ["call-ui"]);
38
+ expect(afterText.map(p => p.block.id)).toEqual(["ui1"]);
39
+ });
40
+ });
41
+ describe("receipts", () => {
42
+ it("folds a read receipt into its own step row", () => {
43
+ const read = placed({
44
+ id: "r1",
45
+ kind: "keyValue",
46
+ source: "live",
47
+ pairs: []
48
+ }, "c1");
49
+ const {
50
+ nested,
51
+ afterText
52
+ } = placeBlocks([read], ["c1"]);
53
+ expect(afterText).toEqual([]);
54
+ expect(nested.get("c1")?.map(b => b.id)).toEqual(["r1"]);
55
+ });
56
+ it("keeps a write receipt afterText — the user must see it without asking", () => {
57
+ const write = placed({
58
+ id: "w1",
59
+ kind: "diff",
60
+ source: "changed",
61
+ changes: []
62
+ }, "c1");
63
+ const {
64
+ nested,
65
+ afterText
66
+ } = placeBlocks([write], ["c1"]);
67
+ expect(nested.size).toBe(0);
68
+ expect(afterText.map(p => p.block.id)).toEqual(["w1"]);
69
+ });
70
+ it("falls back to afterText when its step row was never drawn", () => {
71
+ const orphan = placed({
72
+ id: "r2",
73
+ kind: "keyValue",
74
+ source: "live",
75
+ pairs: []
76
+ }, "gone");
77
+ const {
78
+ afterText
79
+ } = placeBlocks([orphan], []);
80
+ expect(afterText.map(p => p.block.id)).toEqual(["r2"]);
81
+ });
82
+ });
83
+ describe("ask blocks", () => {
84
+ it("come out in their own bucket, after the answer", () => {
85
+ const confirm = placed({
86
+ id: "a1",
87
+ kind: "confirm",
88
+ source: "model",
89
+ change: "Wipe storage"
90
+ }, "call-ui");
91
+ const {
92
+ ask,
93
+ afterText,
94
+ nested
95
+ } = placeBlocks([confirm, grid("ui2")], ["c1"]);
96
+ expect(ask.map(p => p.block.id)).toEqual(["a1"]);
97
+ expect(afterText.map(p => p.block.id)).toEqual(["ui2"]);
98
+ expect(nested.size).toBe(0);
99
+ });
100
+ });
101
+
102
+ /**
103
+ * The order the transcript draws these in, asserted here rather than left to
104
+ * MessageList's JSX.
105
+ *
106
+ * Off a real device: "show me all the pokemon from our poke mart shop". The
107
+ * agent navigated to /shop, paged through 28 menu items and built the grid —
108
+ * and the grid rendered at the TOP of the bubble with five paragraphs of
109
+ * narration beneath it, so the finished answer arrived before the sentence
110
+ * introducing it. The bucket is named for its position so a future edit has
111
+ * to contradict the name to put it back.
112
+ */
113
+ describe("the answer comes after the prose", () => {
114
+ it("puts a model-authored card in the after-text bucket, never before it", () => {
115
+ const placed = placeBlocks([grid()], ["c1"]);
116
+ expect(placed.afterText.map(p => p.block.id)).toEqual(["ui1"]);
117
+ // `nested` is the only bucket that draws ABOVE the text (inside the
118
+ // activity card's step rows), and only read receipts belong there.
119
+ expect(placed.nested.size).toBe(0);
120
+ });
121
+ });
122
+ //# sourceMappingURL=blockPlacement.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["describe","expect","it","placeBlocks","placed","b","forToolCallId","block","grid","id","kind","source","images","url","alt","afterText","nested","map","p","toEqual","size","toBe","read","pairs","get","write","changes","orphan","confirm","change","ask"],"sourceRoot":"../../../src","sources":["store/blockPlacement.test.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;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,EAAE,MAAM;EACjDE,EAAE,CAAC,sEAAsE,EAAE,MAAM;IAC/E,MAAME,MAAM,GAAGD,WAAW,CAAC,CAACK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAC5CP,MAAM,CAACG,MAAM,CAACW,SAAS,CAACE,GAAG,CAAEC,CAAC,IAAKA,CAAC,CAACX,KAAK,CAACE,EAAE,CAAC,CAAC,CAACU,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC;IAChE;IACA;IACAlB,MAAM,CAACG,MAAM,CAACY,MAAM,CAACI,IAAI,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC;EACpC,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -1 +1,149 @@
1
- "use strict";import{beforeEach,describe,expect,it}from"vitest";import{askBuoyStore,queuePauseReason,turnPhaseOf}from"./askBuoyStore";beforeEach(()=>askBuoyStore.reset());const texts=()=>askBuoyStore.getState().queued.map(e=>e.text);describe("queue",()=>{it("keeps every message, in the order typed",()=>{askBuoyStore.enqueue("then set points to 1500"),askBuoyStore.enqueue("and clear the cart after"),expect(texts()).toEqual(["then set points to 1500","and clear the cart after"])}),it("gives identical requests distinct ids",()=>{const e=askBuoyStore.enqueue("again"),t=askBuoyStore.enqueue("again");expect(e.id).not.toBe(t.id),askBuoyStore.removeQueued(e.id),expect(texts()).toEqual(["again"])}),it("delivers from the front, one at a time",()=>{askBuoyStore.enqueue("one"),askBuoyStore.enqueue("two"),expect(askBuoyStore.shiftQueued()?.text).toBe("one"),expect(texts()).toEqual(["two"]),expect(askBuoyStore.shiftQueued()?.text).toBe("two"),expect(askBuoyStore.shiftQueued()).toBeUndefined()}),it("comes back from disk as unsent rows",()=>{const e=askBuoyStore.hydrate({messages:[{id:"m1",role:"user",text:"hi",toolCalls:[],blocks:[]}],answers:{},usage:{input:0,output:0,requests:0},queued:[{id:"q1",text:"still waiting"}]});expect(e).toBe(!0),expect(texts()).toEqual(["still waiting"]),expect(turnPhaseOf(askBuoyStore.getState())).toBe("idle")}),it("is emptied by a new conversation",()=>{askBuoyStore.enqueue("gone"),askBuoyStore.reset(),expect(texts()).toEqual([])})}),describe("turnPhase",()=>{it("is idle with nothing going on",()=>{expect(turnPhaseOf(askBuoyStore.getState())).toBe("idle")}),it("is running during a turn, and stopping once Stop is pressed",()=>{askBuoyStore.addUser("go"),askBuoyStore.startAssistant(),expect(turnPhaseOf(askBuoyStore.getState())).toBe("running"),askBuoyStore.requestStop(),expect(turnPhaseOf(askBuoyStore.getState())).toBe("stopping")}),it("is awaitingApproval while a card is up, even though the turn is busy",()=>{askBuoyStore.addUser("wipe it"),askBuoyStore.startAssistant(),askBuoyStore.askApproval({id:"c1",toolId:"storage",action:"clearAll",label:"Clear all saved app data",reason:"Wipes everything"}),expect(turnPhaseOf(askBuoyStore.getState())).toBe("awaitingApproval")}),it("is awaitingAnswer after a turn ends on an Ask block",()=>{const e=askBuoyStore.startAssistant();askBuoyStore.applyEvent(e,{type:"awaiting-user",blockId:"b1"}),askBuoyStore.finishAssistant(e),expect(turnPhaseOf(askBuoyStore.getState())).toBe("awaitingAnswer")})}),describe("when the queue holds",()=>{it("delivers when idle and the last turn was fine",()=>{askBuoyStore.addUser("hi");const e=askBuoyStore.startAssistant();askBuoyStore.applyEvent(e,{type:"text",delta:"Hello."}),askBuoyStore.finishAssistant(e),expect(queuePauseReason(askBuoyStore.getState())).toBeNull()}),it("holds after an error, and says so",()=>{askBuoyStore.addUser("hi");const e=askBuoyStore.startAssistant();askBuoyStore.applyEvent(e,{type:"error",message:"fetch failed"}),askBuoyStore.finishAssistant(e),expect(queuePauseReason(askBuoyStore.getState())).toMatch(/failed/)}),it("holds while an approval card is up",()=>{askBuoyStore.addUser("wipe"),askBuoyStore.startAssistant(),askBuoyStore.askApproval({id:"c1",toolId:"storage",action:"clearAll",label:"Clear all saved app data",reason:"Wipes everything"}),expect(queuePauseReason(askBuoyStore.getState())).toMatch(/approval/)}),it("holds while a question is unanswered — a queued task is not the answer",()=>{const e=askBuoyStore.startAssistant();askBuoyStore.applyEvent(e,{type:"awaiting-user",blockId:"b1"}),askBuoyStore.finishAssistant(e),expect(queuePauseReason(askBuoyStore.getState())).toMatch(/question/)}),it("says nothing while a turn is still running — the queue is simply waiting",()=>{askBuoyStore.addUser("go"),askBuoyStore.startAssistant(),expect(queuePauseReason(askBuoyStore.getState())).toBeNull()})});
1
+ "use strict";
2
+
3
+ /**
4
+ * The queue is a list, and it knows when to hold.
5
+ *
6
+ * Both rules were written from a defect: the single slot this replaced
7
+ * OVERWROTE — type two things mid-turn and the first vanished — and its flush
8
+ * ran on `!busy` alone, so a parked message fired into a dead connection after
9
+ * an error and was sent as the answer to an open choice block.
10
+ */
11
+ import { beforeEach, describe, expect, it } from "vitest";
12
+ import { askBuoyStore, queuePauseReason, turnPhaseOf } from "./askBuoyStore";
13
+ beforeEach(() => askBuoyStore.reset());
14
+ const texts = () => askBuoyStore.getState().queued.map(q => q.text);
15
+ describe("queue", () => {
16
+ it("keeps every message, in the order typed", () => {
17
+ askBuoyStore.enqueue("then set points to 1500");
18
+ askBuoyStore.enqueue("and clear the cart after");
19
+ expect(texts()).toEqual(["then set points to 1500", "and clear the cart after"]);
20
+ });
21
+ it("gives identical requests distinct ids", () => {
22
+ const a = askBuoyStore.enqueue("again");
23
+ const b = askBuoyStore.enqueue("again");
24
+ expect(a.id).not.toBe(b.id);
25
+ askBuoyStore.removeQueued(a.id);
26
+ expect(texts()).toEqual(["again"]);
27
+ });
28
+ it("delivers from the front, one at a time", () => {
29
+ askBuoyStore.enqueue("one");
30
+ askBuoyStore.enqueue("two");
31
+ expect(askBuoyStore.shiftQueued()?.text).toBe("one");
32
+ expect(texts()).toEqual(["two"]);
33
+ expect(askBuoyStore.shiftQueued()?.text).toBe("two");
34
+ expect(askBuoyStore.shiftQueued()).toBeUndefined();
35
+ });
36
+ it("comes back from disk as unsent rows", () => {
37
+ const ok = askBuoyStore.hydrate({
38
+ messages: [{
39
+ id: "m1",
40
+ role: "user",
41
+ text: "hi",
42
+ toolCalls: [],
43
+ blocks: []
44
+ }],
45
+ answers: {},
46
+ usage: {
47
+ input: 0,
48
+ output: 0,
49
+ requests: 0
50
+ },
51
+ queued: [{
52
+ id: "q1",
53
+ text: "still waiting"
54
+ }]
55
+ });
56
+ expect(ok).toBe(true);
57
+ expect(texts()).toEqual(["still waiting"]);
58
+ // Idle with nothing wrong — but hydrate itself never sends; the flush
59
+ // effect in the hook does, and only once the user is looking.
60
+ expect(turnPhaseOf(askBuoyStore.getState())).toBe("idle");
61
+ });
62
+ it("is emptied by a new conversation", () => {
63
+ askBuoyStore.enqueue("gone");
64
+ askBuoyStore.reset();
65
+ expect(texts()).toEqual([]);
66
+ });
67
+ });
68
+ describe("turnPhase", () => {
69
+ it("is idle with nothing going on", () => {
70
+ expect(turnPhaseOf(askBuoyStore.getState())).toBe("idle");
71
+ });
72
+ it("is running during a turn, and stopping once Stop is pressed", () => {
73
+ askBuoyStore.addUser("go");
74
+ askBuoyStore.startAssistant();
75
+ expect(turnPhaseOf(askBuoyStore.getState())).toBe("running");
76
+ askBuoyStore.requestStop();
77
+ expect(turnPhaseOf(askBuoyStore.getState())).toBe("stopping");
78
+ });
79
+ it("is awaitingApproval while a card is up, even though the turn is busy", () => {
80
+ askBuoyStore.addUser("wipe it");
81
+ askBuoyStore.startAssistant();
82
+ void askBuoyStore.askApproval({
83
+ id: "c1",
84
+ toolId: "storage",
85
+ action: "clearAll",
86
+ label: "Clear all saved app data",
87
+ reason: "Wipes everything"
88
+ });
89
+ expect(turnPhaseOf(askBuoyStore.getState())).toBe("awaitingApproval");
90
+ });
91
+ it("is awaitingAnswer after a turn ends on an Ask block", () => {
92
+ const id = askBuoyStore.startAssistant();
93
+ askBuoyStore.applyEvent(id, {
94
+ type: "awaiting-user",
95
+ blockId: "b1"
96
+ });
97
+ askBuoyStore.finishAssistant(id);
98
+ expect(turnPhaseOf(askBuoyStore.getState())).toBe("awaitingAnswer");
99
+ });
100
+ });
101
+ describe("when the queue holds", () => {
102
+ it("delivers when idle and the last turn was fine", () => {
103
+ askBuoyStore.addUser("hi");
104
+ const id = askBuoyStore.startAssistant();
105
+ askBuoyStore.applyEvent(id, {
106
+ type: "text",
107
+ delta: "Hello."
108
+ });
109
+ askBuoyStore.finishAssistant(id);
110
+ expect(queuePauseReason(askBuoyStore.getState())).toBeNull();
111
+ });
112
+ it("holds after an error, and says so", () => {
113
+ askBuoyStore.addUser("hi");
114
+ const id = askBuoyStore.startAssistant();
115
+ askBuoyStore.applyEvent(id, {
116
+ type: "error",
117
+ message: "fetch failed"
118
+ });
119
+ askBuoyStore.finishAssistant(id);
120
+ expect(queuePauseReason(askBuoyStore.getState())).toMatch(/failed/);
121
+ });
122
+ it("holds while an approval card is up", () => {
123
+ askBuoyStore.addUser("wipe");
124
+ askBuoyStore.startAssistant();
125
+ void askBuoyStore.askApproval({
126
+ id: "c1",
127
+ toolId: "storage",
128
+ action: "clearAll",
129
+ label: "Clear all saved app data",
130
+ reason: "Wipes everything"
131
+ });
132
+ expect(queuePauseReason(askBuoyStore.getState())).toMatch(/approval/);
133
+ });
134
+ it("holds while a question is unanswered — a queued task is not the answer", () => {
135
+ const id = askBuoyStore.startAssistant();
136
+ askBuoyStore.applyEvent(id, {
137
+ type: "awaiting-user",
138
+ blockId: "b1"
139
+ });
140
+ askBuoyStore.finishAssistant(id);
141
+ expect(queuePauseReason(askBuoyStore.getState())).toMatch(/question/);
142
+ });
143
+ it("says nothing while a turn is still running — the queue is simply waiting", () => {
144
+ askBuoyStore.addUser("go");
145
+ askBuoyStore.startAssistant();
146
+ expect(queuePauseReason(askBuoyStore.getState())).toBeNull();
147
+ });
148
+ });
149
+ //# sourceMappingURL=queue.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["beforeEach","describe","expect","it","askBuoyStore","queuePauseReason","turnPhaseOf","reset","texts","getState","queued","map","q","text","enqueue","toEqual","a","b","id","not","toBe","removeQueued","shiftQueued","toBeUndefined","ok","hydrate","messages","role","toolCalls","blocks","answers","usage","input","output","requests","addUser","startAssistant","requestStop","askApproval","toolId","action","label","reason","applyEvent","type","blockId","finishAssistant","delta","toBeNull","message","toMatch"],"sourceRoot":"../../../src","sources":["store/queue.test.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAEzD,SAASC,YAAY,EAAEC,gBAAgB,EAAEC,WAAW,QAAQ,gBAAgB;AAE5EN,UAAU,CAAC,MAAMI,YAAY,CAACG,KAAK,CAAC,CAAC,CAAC;AAEtC,MAAMC,KAAK,GAAGA,CAAA,KAAMJ,YAAY,CAACK,QAAQ,CAAC,CAAC,CAACC,MAAM,CAACC,GAAG,CAAEC,CAAC,IAAKA,CAAC,CAACC,IAAI,CAAC;AAErEZ,QAAQ,CAAC,OAAO,EAAE,MAAM;EACtBE,EAAE,CAAC,yCAAyC,EAAE,MAAM;IAClDC,YAAY,CAACU,OAAO,CAAC,yBAAyB,CAAC;IAC/CV,YAAY,CAACU,OAAO,CAAC,0BAA0B,CAAC;IAChDZ,MAAM,CAACM,KAAK,CAAC,CAAC,CAAC,CAACO,OAAO,CAAC,CAAC,yBAAyB,EAAE,0BAA0B,CAAC,CAAC;EAClF,CAAC,CAAC;EAEFZ,EAAE,CAAC,uCAAuC,EAAE,MAAM;IAChD,MAAMa,CAAC,GAAGZ,YAAY,CAACU,OAAO,CAAC,OAAO,CAAC;IACvC,MAAMG,CAAC,GAAGb,YAAY,CAACU,OAAO,CAAC,OAAO,CAAC;IACvCZ,MAAM,CAACc,CAAC,CAACE,EAAE,CAAC,CAACC,GAAG,CAACC,IAAI,CAACH,CAAC,CAACC,EAAE,CAAC;IAC3Bd,YAAY,CAACiB,YAAY,CAACL,CAAC,CAACE,EAAE,CAAC;IAC/BhB,MAAM,CAACM,KAAK,CAAC,CAAC,CAAC,CAACO,OAAO,CAAC,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CAAC,CAAC,CAAC,CAAC,CAACuC,QAAQ,CAAC,CAAC;EAC9D,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -1 +1,72 @@
1
- "use strict";import{askBuoyStore}from"./askBuoyStore";import{clearTranscript}from"./transcriptPersistence";export function clearConversation(){askBuoyStore.getHeldSession()?.session.reset(),askBuoyStore.reset(),clearTranscript()}export async function resetConversation(e){if(askBuoyStore.getState().busy)return{cleared:!1,reverted:0,failed:[{label:"A turn is running",error:"Stop it first."}]};const r=askBuoyStore.getLedger();if(e.undoFirst&&r){const t=await r.revertAll(e.dispatch);return t.failed.length>0?{cleared:!1,reverted:t.reverted,failed:t.failed}:(clearConversation(),{cleared:!0,reverted:t.reverted,failed:[]})}return clearConversation(),{cleared:!0,reverted:0,failed:[]}}
1
+ "use strict";
2
+
3
+ /**
4
+ * "New conversation" — the ONE way a conversation is cleared.
5
+ *
6
+ * Clearing drops the effect ledger, which is the only undo surface, while the
7
+ * agent's changes stay live in the app. So the path that clears has to be the
8
+ * path that knows whether undo succeeded — and there used to be two paths
9
+ * that did not: the sheet's "Undo, then clear" awaited `revertAll` and reset
10
+ * without reading the outcome (two of five reverts fail, the conversation
11
+ * clears anyway, two changes stay applied with no record), and the desktop's
12
+ * `reset` action skipped the question entirely.
13
+ *
14
+ * Both now come through here. A failed revert does NOT clear: the caller gets
15
+ * the list of what is still applied and clearing becomes a second, explicit
16
+ * choice.
17
+ */
18
+
19
+ import { askBuoyStore } from "./askBuoyStore";
20
+ import { clearTranscript } from "./transcriptPersistence";
21
+ /** Clear everything, unconditionally. The caller has already decided. */
22
+ export function clearConversation() {
23
+ // All three, or the conversation this said it had cleared comes straight
24
+ // back on the next reload with its undo bar intact.
25
+ askBuoyStore.getHeldSession()?.session.reset();
26
+ askBuoyStore.reset();
27
+ void clearTranscript();
28
+ }
29
+
30
+ /**
31
+ * Undo what can be undone, then clear — unless something would not go back.
32
+ *
33
+ * Refuses while a turn is running: the ledger is being written to, and a
34
+ * revert racing a dispatch is how "changed since Ask Buoy wrote it" happens
35
+ * to our own write.
36
+ */
37
+ export async function resetConversation(input) {
38
+ if (askBuoyStore.getState().busy) {
39
+ return {
40
+ cleared: false,
41
+ reverted: 0,
42
+ failed: [{
43
+ label: "A turn is running",
44
+ error: "Stop it first."
45
+ }]
46
+ };
47
+ }
48
+ const ledger = askBuoyStore.getLedger();
49
+ if (input.undoFirst && ledger) {
50
+ const outcome = await ledger.revertAll(input.dispatch);
51
+ if (outcome.failed.length > 0) {
52
+ return {
53
+ cleared: false,
54
+ reverted: outcome.reverted,
55
+ failed: outcome.failed
56
+ };
57
+ }
58
+ clearConversation();
59
+ return {
60
+ cleared: true,
61
+ reverted: outcome.reverted,
62
+ failed: []
63
+ };
64
+ }
65
+ clearConversation();
66
+ return {
67
+ cleared: true,
68
+ reverted: 0,
69
+ failed: []
70
+ };
71
+ }
72
+ //# sourceMappingURL=resetConversation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["askBuoyStore","clearTranscript","clearConversation","getHeldSession","session","reset","resetConversation","input","getState","busy","cleared","reverted","failed","label","error","ledger","getLedger","undoFirst","outcome","revertAll","dispatch","length"],"sourceRoot":"../../../src","sources":["store/resetConversation.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,eAAe,QAAQ,yBAAyB;AAWzD;AACA,OAAO,SAASC,iBAAiBA,CAAA,EAAS;EACxC;EACA;EACAF,YAAY,CAACG,cAAc,CAAC,CAAC,EAAEC,OAAO,CAACC,KAAK,CAAC,CAAC;EAC9CL,YAAY,CAACK,KAAK,CAAC,CAAC;EACpB,KAAKJ,eAAe,CAAC,CAAC;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeK,iBAAiBA,CAACC,KAGvC,EAAyB;EACxB,IAAIP,YAAY,CAACQ,QAAQ,CAAC,CAAC,CAACC,IAAI,EAAE;IAChC,OAAO;MAAEC,OAAO,EAAE,KAAK;MAAEC,QAAQ,EAAE,CAAC;MAAEC,MAAM,EAAE,CAAC;QAAEC,KAAK,EAAE,mBAAmB;QAAEC,KAAK,EAAE;MAAiB,CAAC;IAAE,CAAC;EAC3G;EACA,MAAMC,MAAM,GAAGf,YAAY,CAACgB,SAAS,CAAC,CAAC;EACvC,IAAIT,KAAK,CAACU,SAAS,IAAIF,MAAM,EAAE;IAC7B,MAAMG,OAAO,GAAG,MAAMH,MAAM,CAACI,SAAS,CAACZ,KAAK,CAACa,QAAQ,CAAC;IACtD,IAAIF,OAAO,CAACN,MAAM,CAACS,MAAM,GAAG,CAAC,EAAE;MAC7B,OAAO;QAAEX,OAAO,EAAE,KAAK;QAAEC,QAAQ,EAAEO,OAAO,CAACP,QAAQ;QAAEC,MAAM,EAAEM,OAAO,CAACN;MAAO,CAAC;IAC/E;IACAV,iBAAiB,CAAC,CAAC;IACnB,OAAO;MAAEQ,OAAO,EAAE,IAAI;MAAEC,QAAQ,EAAEO,OAAO,CAACP,QAAQ;MAAEC,MAAM,EAAE;IAAG,CAAC;EAClE;EACAV,iBAAiB,CAAC,CAAC;EACnB,OAAO;IAAEQ,OAAO,EAAE,IAAI;IAAEC,QAAQ,EAAE,CAAC;IAAEC,MAAM,EAAE;EAAG,CAAC;AACnD","ignoreList":[]}
@@ -1 +1,62 @@
1
- "use strict";import{beforeEach,describe,expect,it}from"vitest";import{askBuoyStore}from"./askBuoyStore";const card={id:"c1",toolId:"zustand",action:"setState",label:"Update the Poké Mart bag store",reason:"This will change the app's state.",params:{storeName:"bag"}};beforeEach(()=>askBuoyStore.reset()),describe("restorePending",()=>{it("puts the card back on screen",()=>{expect(askBuoyStore.restorePending(card)).toBe(!0),expect(askBuoyStore.getState().pending).toMatchObject({toolId:"zustand",action:"setState",params:{storeName:"bag"}})}),it("marks it restored, so Allow runs the call instead of answering a dead promise",()=>{askBuoyStore.restorePending(card),expect(askBuoyStore.getState().pending?.restored).toBe(!0)}),it("refuses once a turn is under way",()=>{askBuoyStore.beginTurn(),expect(askBuoyStore.restorePending(card)).toBe(!1),expect(askBuoyStore.getState().pending).toBeNull()}),it("refuses when a live card is already asking",()=>{askBuoyStore.askApproval(card),expect(askBuoyStore.restorePending({...card,id:"c2"})).toBe(!1),expect(askBuoyStore.getState().pending?.id).toBe("c1")}),it("answers without throwing, though nothing is waiting on it",()=>{askBuoyStore.restorePending(card),expect(()=>askBuoyStore.answerApproval(!0)).not.toThrow(),expect(askBuoyStore.getState().pending).toBeNull()})});
1
+ "use strict";
2
+
3
+ /**
4
+ * Putting an unanswered approval back after a restart.
5
+ *
6
+ * The rule this encodes: a question the user never answered is not the app's
7
+ * to drop. Nothing was tapped, so the change is still waiting as far as they
8
+ * know — and a card that vanishes on reload reads as consent nobody gave.
9
+ *
10
+ * The guards matter as much as the restore. The disk read races the tool
11
+ * registry (see the note at the restore site), so it can land late, and an old
12
+ * question shoved in front of a live conversation would be worse than losing
13
+ * it.
14
+ */
15
+ import { beforeEach, describe, expect, it } from "vitest";
16
+ import { askBuoyStore } from "./askBuoyStore";
17
+ const card = {
18
+ id: "c1",
19
+ toolId: "zustand",
20
+ action: "setState",
21
+ label: "Update the Poké Mart bag store",
22
+ reason: "This will change the app's state.",
23
+ params: {
24
+ storeName: "bag"
25
+ }
26
+ };
27
+ beforeEach(() => askBuoyStore.reset());
28
+ describe("restorePending", () => {
29
+ it("puts the card back on screen", () => {
30
+ expect(askBuoyStore.restorePending(card)).toBe(true);
31
+ expect(askBuoyStore.getState().pending).toMatchObject({
32
+ toolId: "zustand",
33
+ action: "setState",
34
+ params: {
35
+ storeName: "bag"
36
+ }
37
+ });
38
+ });
39
+ it("marks it restored, so Allow runs the call instead of answering a dead promise", () => {
40
+ askBuoyStore.restorePending(card);
41
+ expect(askBuoyStore.getState().pending?.restored).toBe(true);
42
+ });
43
+ it("refuses once a turn is under way", () => {
44
+ askBuoyStore.beginTurn();
45
+ expect(askBuoyStore.restorePending(card)).toBe(false);
46
+ expect(askBuoyStore.getState().pending).toBeNull();
47
+ });
48
+ it("refuses when a live card is already asking", () => {
49
+ void askBuoyStore.askApproval(card);
50
+ expect(askBuoyStore.restorePending({
51
+ ...card,
52
+ id: "c2"
53
+ })).toBe(false);
54
+ expect(askBuoyStore.getState().pending?.id).toBe("c1");
55
+ });
56
+ it("answers without throwing, though nothing is waiting on it", () => {
57
+ askBuoyStore.restorePending(card);
58
+ expect(() => askBuoyStore.answerApproval(true)).not.toThrow();
59
+ expect(askBuoyStore.getState().pending).toBeNull();
60
+ });
61
+ });
62
+ //# sourceMappingURL=restorePending.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["beforeEach","describe","expect","it","askBuoyStore","card","id","toolId","action","label","reason","params","storeName","reset","restorePending","toBe","getState","pending","toMatchObject","restored","beginTurn","toBeNull","askApproval","answerApproval","not","toThrow"],"sourceRoot":"../../../src","sources":["store/restorePending.test.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAEzD,SAASC,YAAY,QAAQ,gBAAgB;AAE7C,MAAMC,IAAI,GAAG;EACXC,EAAE,EAAE,IAAI;EACRC,MAAM,EAAE,SAAS;EACjBC,MAAM,EAAE,UAAU;EAClBC,KAAK,EAAE,gCAAgC;EACvCC,MAAM,EAAE,mCAAmC;EAC3CC,MAAM,EAAE;IAAEC,SAAS,EAAE;EAAM;AAC7B,CAAC;AAEDZ,UAAU,CAAC,MAAMI,YAAY,CAACS,KAAK,CAAC,CAAC,CAAC;AAEtCZ,QAAQ,CAAC,gBAAgB,EAAE,MAAM;EAC/BE,EAAE,CAAC,8BAA8B,EAAE,MAAM;IACvCD,MAAM,CAACE,YAAY,CAACU,cAAc,CAACT,IAAI,CAAC,CAAC,CAACU,IAAI,CAA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I,CAAC,CAAC,CAACC,GAAG,CAACC,OAAO,CAAC,CAAC;IAC7DvB,MAAM,CAACE,YAAY,CAACY,QAAQ,CAAC,CAAC,CAACC,OAAO,CAAC,CAACI,QAAQ,CAAC,CAAC;EACpD,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -1 +1,46 @@
1
- "use strict";import{describe,expect,it}from"vitest";import{idFactory,RUN_ID}from"@buoy-gg/agent-core";describe("ids across a restart",()=>{it("never reissues an id a restored transcript already holds",()=>{const t=["rcOLDRUN-1","rcOLDRUN-2","uiOLDRUN-1","mOLDRUN-1"],e=idFactory("rc"),r=idFactory("ui"),o=idFactory("m"),i=[e(),e(),r(),o()];for(const e of i)expect(t).not.toContain(e)}),it("still counts up within one run",()=>{const t=idFactory("rc"),e=[t(),t(),t()];expect(new Set(e).size).toBe(3)}),it("keeps two prefixes apart even at the same count",()=>{const t=idFactory("rc"),e=idFactory("ui");expect(t()).not.toBe(e())}),it("stamps a run token that is not a fixed string",()=>{expect(RUN_ID).toMatch(/^[a-z0-9]{4,8}$/),expect(idFactory("rc")()).toBe(`rc${RUN_ID}-1`)})});
1
+ "use strict";
2
+
3
+ /**
4
+ * Ids from a RESTORED transcript must never collide with a fresh run's.
5
+ *
6
+ * The bug this covers, in full: every id counter restarted at 1 with the
7
+ * process, which was harmless until the transcript started outliving a reload.
8
+ * A restored conversation came back holding `rc1`, `ui1` and `m1`; the next
9
+ * turn minted `rc1` again; React saw two children with one key and rendered
10
+ * one of them twice while dropping the other. On screen that was the same
11
+ * store card appearing twice after a reload.
12
+ *
13
+ * Simulating a restart in one process is the whole difficulty — the module
14
+ * caches its counter. `idFactory` is the seam: a second factory stands in for
15
+ * the second run, and the shared RUN_ID is what has to differ between them.
16
+ */
17
+ import { describe, expect, it } from "vitest";
18
+ import { idFactory, RUN_ID } from "@buoy-gg/agent-core";
19
+ describe("ids across a restart", () => {
20
+ it("never reissues an id a restored transcript already holds", () => {
21
+ // What a saved transcript carries, from a previous launch.
22
+ const restored = ["rcOLDRUN-1", "rcOLDRUN-2", "uiOLDRUN-1", "mOLDRUN-1"];
23
+ const rc = idFactory("rc");
24
+ const ui = idFactory("ui");
25
+ const m = idFactory("m");
26
+ const fresh = [rc(), rc(), ui(), m()];
27
+ for (const id of fresh) expect(restored).not.toContain(id);
28
+ });
29
+ it("still counts up within one run", () => {
30
+ // The counter is what keeps two blocks in the SAME turn apart.
31
+ const rc = idFactory("rc");
32
+ const ids = [rc(), rc(), rc()];
33
+ expect(new Set(ids).size).toBe(3);
34
+ });
35
+ it("keeps two prefixes apart even at the same count", () => {
36
+ const rc = idFactory("rc");
37
+ const ui = idFactory("ui");
38
+ expect(rc()).not.toBe(ui());
39
+ });
40
+ it("stamps a run token that is not a fixed string", () => {
41
+ // A constant here would put every install back where it started.
42
+ expect(RUN_ID).toMatch(/^[a-z0-9]{4,8}$/);
43
+ expect(idFactory("rc")()).toBe(`rc${RUN_ID}-1`);
44
+ });
45
+ });
46
+ //# sourceMappingURL=restoredIds.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["describe","expect","it","idFactory","RUN_ID","restored","rc","ui","m","fresh","id","not","toContain","ids","Set","size","toBe","toMatch"],"sourceRoot":"../../../src","sources":["store/restoredIds.test.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,SAAS,EAAEC,MAAM,QAAQ,qBAAqB;AAEvDJ,QAAQ,CAAC,sBAAsB,EAAE,MAAM;EACrCE,EAAE,CAAC,0DAA0D,EAAE,MAAM;IACnE;IACA,MAAMG,QAAQ,GAAG,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,CAAC;IACxE,MAAMC,EAAE,GAAGH,SAAS,CAAC,IAAI,CAAC;IAC1B,MAAMI,EAAE,GAAGJ,SAAS,CAAC,IAA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