@buoy-gg/ask-buoy 7.0.41 → 7.0.43

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 (313) hide show
  1. package/README.md +13 -98
  2. package/lib/commonjs/blocks/AskBlocks.js +1 -338
  3. package/lib/commonjs/blocks/BlockRenderer.js +1 -262
  4. package/lib/commonjs/blocks/ChromePrototypes.js +1 -514
  5. package/lib/commonjs/blocks/DataBlocks.js +1 -783
  6. package/lib/commonjs/blocks/ExtraBlocks.js +1 -1862
  7. package/lib/commonjs/blocks/MediaBlocks.js +1 -158
  8. package/lib/commonjs/blocks/ReceiptBlocks.js +2 -592
  9. package/lib/commonjs/blocks/blockText.js +1 -60
  10. package/lib/commonjs/blocks/blockText.test.js +1 -53
  11. package/lib/commonjs/blocks/context.js +1 -42
  12. package/lib/commonjs/blocks/icons.js +1 -96
  13. package/lib/commonjs/blocks/index.js +1 -95
  14. package/lib/commonjs/blocks/listRow.test.js +1 -55
  15. package/lib/commonjs/blocks/pageState.js +1 -34
  16. package/lib/commonjs/blocks/pageState.test.js +1 -57
  17. package/lib/commonjs/blocks/primitives.js +1 -457
  18. package/lib/commonjs/blocks/primitivesIndex.js +1 -62
  19. package/lib/commonjs/blocks/ruleStates.js +1 -39
  20. package/lib/commonjs/components/ApprovalCard.js +1 -297
  21. package/lib/commonjs/components/AskBuoyHeader.js +1 -196
  22. package/lib/commonjs/components/AskBuoyIcon.js +1 -19
  23. package/lib/commonjs/components/AskBuoyModal.js +2 -482
  24. package/lib/commonjs/components/AskBuoySettings.js +1 -181
  25. package/lib/commonjs/components/ChangesBar.js +1 -212
  26. package/lib/commonjs/components/Composer.js +1 -255
  27. package/lib/commonjs/components/EmptyState.js +1 -161
  28. package/lib/commonjs/components/KeyboardPad.js +1 -80
  29. package/lib/commonjs/components/Markdown.js +1 -310
  30. package/lib/commonjs/components/MessageList.js +1 -970
  31. package/lib/commonjs/components/QueuedMessages.js +1 -145
  32. package/lib/commonjs/components/ThinkingStrip.js +1 -223
  33. package/lib/commonjs/components/TypingDots.js +1 -63
  34. package/lib/commonjs/components/markdownParse.js +1 -131
  35. package/lib/commonjs/components/markdownParse.test.js +1 -99
  36. package/lib/commonjs/components/useCopyAction.js +1 -50
  37. package/lib/commonjs/index.js +1 -252
  38. package/lib/commonjs/preset.js +1 -91
  39. package/lib/commonjs/store/activityGroups.js +1 -110
  40. package/lib/commonjs/store/activityGroups.test.js +1 -78
  41. package/lib/commonjs/store/askBuoySettings.js +1 -72
  42. package/lib/commonjs/store/askBuoyStore.js +2 -588
  43. package/lib/commonjs/store/blockPlacement.js +1 -64
  44. package/lib/commonjs/store/blockPlacement.test.js +1 -123
  45. package/lib/commonjs/store/queue.test.js +1 -150
  46. package/lib/commonjs/store/resetConversation.js +1 -77
  47. package/lib/commonjs/store/restorePending.test.js +1 -63
  48. package/lib/commonjs/store/restoredIds.test.js +1 -47
  49. package/lib/commonjs/store/suggestions.js +1 -54
  50. package/lib/commonjs/store/suggestions.test.js +1 -58
  51. package/lib/commonjs/store/systemLine.test.js +1 -77
  52. package/lib/commonjs/store/ticketPrompt.js +1 -17
  53. package/lib/commonjs/store/traceText.js +1 -81
  54. package/lib/commonjs/store/traceText.test.js +1 -112
  55. package/lib/commonjs/store/transcriptPersistence.js +1 -297
  56. package/lib/commonjs/store/transcriptPersistence.test.js +1 -333
  57. package/lib/commonjs/store/turnRendering.test.js +1 -151
  58. package/lib/commonjs/store/useAskBuoy.js +1 -651
  59. package/lib/commonjs/store/useAskBuoySettings.js +1 -14
  60. package/lib/commonjs/sync/askBuoySyncAdapter.js +1 -153
  61. package/lib/commonjs/sync/askBuoySyncAdapter.test.js +1 -141
  62. package/lib/commonjs/sync/wire.js +1 -58
  63. package/lib/commonjs/types.js +1 -6
  64. package/lib/module/blocks/AskBlocks.js +1 -331
  65. package/lib/module/blocks/BlockRenderer.js +1 -257
  66. package/lib/module/blocks/ChromePrototypes.js +1 -503
  67. package/lib/module/blocks/DataBlocks.js +1 -769
  68. package/lib/module/blocks/ExtraBlocks.js +1 -1835
  69. package/lib/module/blocks/MediaBlocks.js +1 -153
  70. package/lib/module/blocks/ReceiptBlocks.js +2 -580
  71. package/lib/module/blocks/blockText.js +1 -55
  72. package/lib/module/blocks/blockText.test.js +1 -53
  73. package/lib/module/blocks/context.js +1 -35
  74. package/lib/module/blocks/icons.js +1 -91
  75. package/lib/module/blocks/index.js +1 -8
  76. package/lib/module/blocks/listRow.test.js +1 -56
  77. package/lib/module/blocks/pageState.js +1 -30
  78. package/lib/module/blocks/pageState.test.js +1 -56
  79. package/lib/module/blocks/primitives.js +1 -445
  80. package/lib/module/blocks/primitivesIndex.js +1 -5
  81. package/lib/module/blocks/ruleStates.js +1 -35
  82. package/lib/module/components/ApprovalCard.js +1 -292
  83. package/lib/module/components/AskBuoyHeader.js +1 -193
  84. package/lib/module/components/AskBuoyIcon.js +1 -8
  85. package/lib/module/components/AskBuoyModal.js +2 -477
  86. package/lib/module/components/AskBuoySettings.js +1 -176
  87. package/lib/module/components/ChangesBar.js +1 -206
  88. package/lib/module/components/Composer.js +1 -250
  89. package/lib/module/components/EmptyState.js +1 -156
  90. package/lib/module/components/KeyboardPad.js +1 -75
  91. package/lib/module/components/Markdown.js +1 -305
  92. package/lib/module/components/MessageList.js +1 -964
  93. package/lib/module/components/QueuedMessages.js +1 -140
  94. package/lib/module/components/ThinkingStrip.js +1 -218
  95. package/lib/module/components/TypingDots.js +1 -58
  96. package/lib/module/components/markdownParse.js +1 -125
  97. package/lib/module/components/markdownParse.test.js +1 -98
  98. package/lib/module/components/useCopyAction.js +1 -46
  99. package/lib/module/index.js +1 -34
  100. package/lib/module/preset.js +1 -74
  101. package/lib/module/store/activityGroups.js +1 -103
  102. package/lib/module/store/activityGroups.test.js +1 -77
  103. package/lib/module/store/askBuoySettings.js +1 -67
  104. package/lib/module/store/askBuoyStore.js +2 -582
  105. package/lib/module/store/blockPlacement.js +1 -59
  106. package/lib/module/store/blockPlacement.test.js +1 -122
  107. package/lib/module/store/queue.test.js +1 -149
  108. package/lib/module/store/resetConversation.js +1 -72
  109. package/lib/module/store/restorePending.test.js +1 -62
  110. package/lib/module/store/restoredIds.test.js +1 -46
  111. package/lib/module/store/suggestions.js +1 -49
  112. package/lib/module/store/suggestions.test.js +1 -57
  113. package/lib/module/store/systemLine.test.js +1 -76
  114. package/lib/module/store/ticketPrompt.js +1 -13
  115. package/lib/module/store/traceText.js +1 -75
  116. package/lib/module/store/traceText.test.js +1 -111
  117. package/lib/module/store/transcriptPersistence.js +1 -287
  118. package/lib/module/store/transcriptPersistence.test.js +1 -332
  119. package/lib/module/store/turnRendering.test.js +1 -150
  120. package/lib/module/store/useAskBuoy.js +1 -646
  121. package/lib/module/store/useAskBuoySettings.js +1 -9
  122. package/lib/module/sync/askBuoySyncAdapter.js +1 -148
  123. package/lib/module/sync/askBuoySyncAdapter.test.js +1 -140
  124. package/lib/module/sync/wire.js +1 -47
  125. package/lib/module/types.js +1 -4
  126. package/lib/web/index.mjs +11 -12
  127. package/package.json +8 -12
  128. package/lib/commonjs/blocks/AskBlocks.js.map +0 -1
  129. package/lib/commonjs/blocks/BlockRenderer.js.map +0 -1
  130. package/lib/commonjs/blocks/ChromePrototypes.js.map +0 -1
  131. package/lib/commonjs/blocks/DataBlocks.js.map +0 -1
  132. package/lib/commonjs/blocks/ExtraBlocks.js.map +0 -1
  133. package/lib/commonjs/blocks/MediaBlocks.js.map +0 -1
  134. package/lib/commonjs/blocks/ReceiptBlocks.js.map +0 -1
  135. package/lib/commonjs/blocks/blockText.js.map +0 -1
  136. package/lib/commonjs/blocks/blockText.test.js.map +0 -1
  137. package/lib/commonjs/blocks/context.js.map +0 -1
  138. package/lib/commonjs/blocks/icons.js.map +0 -1
  139. package/lib/commonjs/blocks/index.js.map +0 -1
  140. package/lib/commonjs/blocks/listRow.test.js.map +0 -1
  141. package/lib/commonjs/blocks/pageState.js.map +0 -1
  142. package/lib/commonjs/blocks/pageState.test.js.map +0 -1
  143. package/lib/commonjs/blocks/primitives.js.map +0 -1
  144. package/lib/commonjs/blocks/primitivesIndex.js.map +0 -1
  145. package/lib/commonjs/blocks/ruleStates.js.map +0 -1
  146. package/lib/commonjs/components/ApprovalCard.js.map +0 -1
  147. package/lib/commonjs/components/AskBuoyHeader.js.map +0 -1
  148. package/lib/commonjs/components/AskBuoyIcon.js.map +0 -1
  149. package/lib/commonjs/components/AskBuoyModal.js.map +0 -1
  150. package/lib/commonjs/components/AskBuoySettings.js.map +0 -1
  151. package/lib/commonjs/components/ChangesBar.js.map +0 -1
  152. package/lib/commonjs/components/Composer.js.map +0 -1
  153. package/lib/commonjs/components/EmptyState.js.map +0 -1
  154. package/lib/commonjs/components/KeyboardPad.js.map +0 -1
  155. package/lib/commonjs/components/Markdown.js.map +0 -1
  156. package/lib/commonjs/components/MessageList.js.map +0 -1
  157. package/lib/commonjs/components/QueuedMessages.js.map +0 -1
  158. package/lib/commonjs/components/ThinkingStrip.js.map +0 -1
  159. package/lib/commonjs/components/TypingDots.js.map +0 -1
  160. package/lib/commonjs/components/markdownParse.js.map +0 -1
  161. package/lib/commonjs/components/markdownParse.test.js.map +0 -1
  162. package/lib/commonjs/components/useCopyAction.js.map +0 -1
  163. package/lib/commonjs/index.js.map +0 -1
  164. package/lib/commonjs/preset.js.map +0 -1
  165. package/lib/commonjs/store/activityGroups.js.map +0 -1
  166. package/lib/commonjs/store/activityGroups.test.js.map +0 -1
  167. package/lib/commonjs/store/askBuoySettings.js.map +0 -1
  168. package/lib/commonjs/store/askBuoyStore.js.map +0 -1
  169. package/lib/commonjs/store/blockPlacement.js.map +0 -1
  170. package/lib/commonjs/store/blockPlacement.test.js.map +0 -1
  171. package/lib/commonjs/store/queue.test.js.map +0 -1
  172. package/lib/commonjs/store/resetConversation.js.map +0 -1
  173. package/lib/commonjs/store/restorePending.test.js.map +0 -1
  174. package/lib/commonjs/store/restoredIds.test.js.map +0 -1
  175. package/lib/commonjs/store/suggestions.js.map +0 -1
  176. package/lib/commonjs/store/suggestions.test.js.map +0 -1
  177. package/lib/commonjs/store/systemLine.test.js.map +0 -1
  178. package/lib/commonjs/store/ticketPrompt.js.map +0 -1
  179. package/lib/commonjs/store/traceText.js.map +0 -1
  180. package/lib/commonjs/store/traceText.test.js.map +0 -1
  181. package/lib/commonjs/store/transcriptPersistence.js.map +0 -1
  182. package/lib/commonjs/store/transcriptPersistence.test.js.map +0 -1
  183. package/lib/commonjs/store/turnRendering.test.js.map +0 -1
  184. package/lib/commonjs/store/useAskBuoy.js.map +0 -1
  185. package/lib/commonjs/store/useAskBuoySettings.js.map +0 -1
  186. package/lib/commonjs/sync/askBuoySyncAdapter.js.map +0 -1
  187. package/lib/commonjs/sync/askBuoySyncAdapter.test.js.map +0 -1
  188. package/lib/commonjs/sync/wire.js.map +0 -1
  189. package/lib/commonjs/types.js.map +0 -1
  190. package/lib/module/blocks/AskBlocks.js.map +0 -1
  191. package/lib/module/blocks/BlockRenderer.js.map +0 -1
  192. package/lib/module/blocks/ChromePrototypes.js.map +0 -1
  193. package/lib/module/blocks/DataBlocks.js.map +0 -1
  194. package/lib/module/blocks/ExtraBlocks.js.map +0 -1
  195. package/lib/module/blocks/MediaBlocks.js.map +0 -1
  196. package/lib/module/blocks/ReceiptBlocks.js.map +0 -1
  197. package/lib/module/blocks/blockText.js.map +0 -1
  198. package/lib/module/blocks/blockText.test.js.map +0 -1
  199. package/lib/module/blocks/context.js.map +0 -1
  200. package/lib/module/blocks/icons.js.map +0 -1
  201. package/lib/module/blocks/index.js.map +0 -1
  202. package/lib/module/blocks/listRow.test.js.map +0 -1
  203. package/lib/module/blocks/pageState.js.map +0 -1
  204. package/lib/module/blocks/pageState.test.js.map +0 -1
  205. package/lib/module/blocks/primitives.js.map +0 -1
  206. package/lib/module/blocks/primitivesIndex.js.map +0 -1
  207. package/lib/module/blocks/ruleStates.js.map +0 -1
  208. package/lib/module/components/ApprovalCard.js.map +0 -1
  209. package/lib/module/components/AskBuoyHeader.js.map +0 -1
  210. package/lib/module/components/AskBuoyIcon.js.map +0 -1
  211. package/lib/module/components/AskBuoyModal.js.map +0 -1
  212. package/lib/module/components/AskBuoySettings.js.map +0 -1
  213. package/lib/module/components/ChangesBar.js.map +0 -1
  214. package/lib/module/components/Composer.js.map +0 -1
  215. package/lib/module/components/EmptyState.js.map +0 -1
  216. package/lib/module/components/KeyboardPad.js.map +0 -1
  217. package/lib/module/components/Markdown.js.map +0 -1
  218. package/lib/module/components/MessageList.js.map +0 -1
  219. package/lib/module/components/QueuedMessages.js.map +0 -1
  220. package/lib/module/components/ThinkingStrip.js.map +0 -1
  221. package/lib/module/components/TypingDots.js.map +0 -1
  222. package/lib/module/components/markdownParse.js.map +0 -1
  223. package/lib/module/components/markdownParse.test.js.map +0 -1
  224. package/lib/module/components/useCopyAction.js.map +0 -1
  225. package/lib/module/index.js.map +0 -1
  226. package/lib/module/preset.js.map +0 -1
  227. package/lib/module/store/activityGroups.js.map +0 -1
  228. package/lib/module/store/activityGroups.test.js.map +0 -1
  229. package/lib/module/store/askBuoySettings.js.map +0 -1
  230. package/lib/module/store/askBuoyStore.js.map +0 -1
  231. package/lib/module/store/blockPlacement.js.map +0 -1
  232. package/lib/module/store/blockPlacement.test.js.map +0 -1
  233. package/lib/module/store/queue.test.js.map +0 -1
  234. package/lib/module/store/resetConversation.js.map +0 -1
  235. package/lib/module/store/restorePending.test.js.map +0 -1
  236. package/lib/module/store/restoredIds.test.js.map +0 -1
  237. package/lib/module/store/suggestions.js.map +0 -1
  238. package/lib/module/store/suggestions.test.js.map +0 -1
  239. package/lib/module/store/systemLine.test.js.map +0 -1
  240. package/lib/module/store/ticketPrompt.js.map +0 -1
  241. package/lib/module/store/traceText.js.map +0 -1
  242. package/lib/module/store/traceText.test.js.map +0 -1
  243. package/lib/module/store/transcriptPersistence.js.map +0 -1
  244. package/lib/module/store/transcriptPersistence.test.js.map +0 -1
  245. package/lib/module/store/turnRendering.test.js.map +0 -1
  246. package/lib/module/store/useAskBuoy.js.map +0 -1
  247. package/lib/module/store/useAskBuoySettings.js.map +0 -1
  248. package/lib/module/sync/askBuoySyncAdapter.js.map +0 -1
  249. package/lib/module/sync/askBuoySyncAdapter.test.js.map +0 -1
  250. package/lib/module/sync/wire.js.map +0 -1
  251. package/lib/module/types.js.map +0 -1
  252. package/lib/typescript/blocks/AskBlocks.d.ts.map +0 -1
  253. package/lib/typescript/blocks/BlockRenderer.d.ts.map +0 -1
  254. package/lib/typescript/blocks/ChromePrototypes.d.ts.map +0 -1
  255. package/lib/typescript/blocks/DataBlocks.d.ts.map +0 -1
  256. package/lib/typescript/blocks/ExtraBlocks.d.ts.map +0 -1
  257. package/lib/typescript/blocks/MediaBlocks.d.ts.map +0 -1
  258. package/lib/typescript/blocks/ReceiptBlocks.d.ts.map +0 -1
  259. package/lib/typescript/blocks/blockText.d.ts.map +0 -1
  260. package/lib/typescript/blocks/blockText.test.d.ts.map +0 -1
  261. package/lib/typescript/blocks/context.d.ts.map +0 -1
  262. package/lib/typescript/blocks/icons.d.ts.map +0 -1
  263. package/lib/typescript/blocks/index.d.ts.map +0 -1
  264. package/lib/typescript/blocks/listRow.test.d.ts.map +0 -1
  265. package/lib/typescript/blocks/pageState.d.ts.map +0 -1
  266. package/lib/typescript/blocks/pageState.test.d.ts.map +0 -1
  267. package/lib/typescript/blocks/primitives.d.ts.map +0 -1
  268. package/lib/typescript/blocks/primitivesIndex.d.ts.map +0 -1
  269. package/lib/typescript/blocks/ruleStates.d.ts.map +0 -1
  270. package/lib/typescript/components/ApprovalCard.d.ts.map +0 -1
  271. package/lib/typescript/components/AskBuoyHeader.d.ts.map +0 -1
  272. package/lib/typescript/components/AskBuoyIcon.d.ts.map +0 -1
  273. package/lib/typescript/components/AskBuoyModal.d.ts.map +0 -1
  274. package/lib/typescript/components/AskBuoySettings.d.ts.map +0 -1
  275. package/lib/typescript/components/ChangesBar.d.ts.map +0 -1
  276. package/lib/typescript/components/Composer.d.ts.map +0 -1
  277. package/lib/typescript/components/EmptyState.d.ts.map +0 -1
  278. package/lib/typescript/components/KeyboardPad.d.ts.map +0 -1
  279. package/lib/typescript/components/Markdown.d.ts.map +0 -1
  280. package/lib/typescript/components/MessageList.d.ts.map +0 -1
  281. package/lib/typescript/components/QueuedMessages.d.ts.map +0 -1
  282. package/lib/typescript/components/ThinkingStrip.d.ts.map +0 -1
  283. package/lib/typescript/components/TypingDots.d.ts.map +0 -1
  284. package/lib/typescript/components/markdownParse.d.ts.map +0 -1
  285. package/lib/typescript/components/markdownParse.test.d.ts.map +0 -1
  286. package/lib/typescript/components/useCopyAction.d.ts.map +0 -1
  287. package/lib/typescript/index.d.ts.map +0 -1
  288. package/lib/typescript/preset.d.ts.map +0 -1
  289. package/lib/typescript/store/activityGroups.d.ts.map +0 -1
  290. package/lib/typescript/store/activityGroups.test.d.ts.map +0 -1
  291. package/lib/typescript/store/askBuoySettings.d.ts.map +0 -1
  292. package/lib/typescript/store/askBuoyStore.d.ts.map +0 -1
  293. package/lib/typescript/store/blockPlacement.d.ts.map +0 -1
  294. package/lib/typescript/store/blockPlacement.test.d.ts.map +0 -1
  295. package/lib/typescript/store/queue.test.d.ts.map +0 -1
  296. package/lib/typescript/store/resetConversation.d.ts.map +0 -1
  297. package/lib/typescript/store/restorePending.test.d.ts.map +0 -1
  298. package/lib/typescript/store/restoredIds.test.d.ts.map +0 -1
  299. package/lib/typescript/store/suggestions.d.ts.map +0 -1
  300. package/lib/typescript/store/suggestions.test.d.ts.map +0 -1
  301. package/lib/typescript/store/systemLine.test.d.ts.map +0 -1
  302. package/lib/typescript/store/ticketPrompt.d.ts.map +0 -1
  303. package/lib/typescript/store/traceText.d.ts.map +0 -1
  304. package/lib/typescript/store/traceText.test.d.ts.map +0 -1
  305. package/lib/typescript/store/transcriptPersistence.d.ts.map +0 -1
  306. package/lib/typescript/store/transcriptPersistence.test.d.ts.map +0 -1
  307. package/lib/typescript/store/turnRendering.test.d.ts.map +0 -1
  308. package/lib/typescript/store/useAskBuoy.d.ts.map +0 -1
  309. package/lib/typescript/store/useAskBuoySettings.d.ts.map +0 -1
  310. package/lib/typescript/sync/askBuoySyncAdapter.d.ts.map +0 -1
  311. package/lib/typescript/sync/askBuoySyncAdapter.test.d.ts.map +0 -1
  312. package/lib/typescript/sync/wire.d.ts.map +0 -1
  313. package/lib/typescript/types.d.ts.map +0 -1
@@ -1,583 +1,3 @@
1
- "use strict";
1
+ "use strict";import{idFactory as p}from"@buoy-gg/agent-core";import{realNow as i}from"@buoy-gg/shared-ui";const l=p("m");const f=400;function b(t){if(!t||Object.keys(t).length===0)return void 0;try{const e=JSON.stringify(t);return e.length>f?`${e.slice(0,f)}\u2026`:e}catch{return void 0}}const h=p("q");let s={messages:[],busy:false,stopping:false,pending:null,trusted:[],notice:null,configured:false,answers:{},awaitingBlockId:null,actionState:{},queued:[],draft:null,usage:{input:0,output:0,requests:0},meta:{}};const d=new Set;let c=null;let g=null;function r(t){s={...s,...t};for(const e of d){try{e()}catch{}}}export const askBuoyStore={getState:()=>s,subscribe(t){d.add(t);return()=>d.delete(t)},setLedger(t){c=t},getLedger(){return c},holdSession(t,e){g={session:t,signature:e}},getHeldSession(){return g},setNotice(t){r({notice:t})},setConfigured(t){if(t!==s.configured)r({configured:t})},setMeta(t){const e=Object.keys(t).every(a=>s.meta[a]===t[a]);if(!e)r({meta:{...s.meta,...t}})},addUser(t){r({messages:[...s.messages,{id:l(),role:"user",text:t,toolCalls:[],blocks:[]}],busy:true})},beginTurn(){r({busy:true})},enqueue(t){const e={id:h(),text:t};r({queued:[...s.queued,e]});return e},removeQueued(t){if(!s.queued.some(e=>e.id===t))return;r({queued:s.queued.filter(e=>e.id!==t)})},shiftQueued(){const[t,...e]=s.queued;if(!t)return void 0;r({queued:e});return t},takeQueuedToDraft(t){const e=s.queued.find(a=>a.id===t);if(!e)return;r({queued:s.queued.filter(a=>a.id!==t),draft:e.text})},requestStop(){if(!s.busy||s.stopping)return;r({stopping:true})},clearDraft(){if(s.draft===null)return;r({draft:null})},removeMessage(t){r({messages:s.messages.filter(e=>e.id!==t)})},recordAnswer(t){r({answers:{...s.answers,[t.blockId]:t},awaitingBlockId:s.awaitingBlockId===t.blockId?null:s.awaitingBlockId})},setActionState(t,e){const a={...s.actionState};if(e===null)delete a[t];else a[t]=e;r({actionState:a})},startAssistant(){const t=l();r({messages:[...s.messages,{id:t,role:"assistant",text:"",toolCalls:[],blocks:[],streaming:true,startedAt:i()}]});return t},applyEvent(t,e){if(e.type==="history-trimmed"){const n=s.messages.findIndex(m=>m.id===t);const o={id:l(),role:"assistant",system:true,text:`Older messages were trimmed from the agent's memory (${e.droppedRounds} exchange${e.droppedRounds===1?"":"s"}).`+(e.droppedPinned?` ${e.droppedPinned===1?"One of them made a change that is":`${e.droppedPinned} of them made changes that are`} still applied \u2014 the changes bar still lists ${e.droppedPinned===1?"it":"them"}, but the agent no longer remembers making ${e.droppedPinned===1?"it":"them"}.`:" It may not recall setup from earlier in this chat \u2014 the changes bar still lists what is applied."),toolCalls:[],blocks:[],endedAt:i()};const u=[...s.messages];u.splice(n<0?u.length:n,0,o);r({messages:u});return}const a=s.messages.map(n=>{if(n.id!==t)return n;switch(e.type){case"retrying":{const o=Math.max(1,Math.round(e.inMs/1e3));return{...n,waiting:e.reason==="throttled"?`Endpoint busy \u2014 retrying in ${o}s (${e.attempt} of ${e.maxAttempts})`:`Request too large \u2014 trimming older messages and retrying`}}case"text":return{...n,waiting:void 0,text:(n.breakBeforeNextText||e.breakBefore)&&n.text?`${n.text.trimEnd()}
2
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
3
+ ${e.delta}`:n.text+e.delta,breakBeforeNextText:false};case"reasoning":return{...n,breakBeforeNextText:true,reasoning:[...n.reasoning??[],{text:e.text,afterCalls:n.toolCalls.length}]};case"tool-start":return{...n,waiting:void 0,toolCalls:[...n.toolCalls,{id:e.id,toolId:e.toolId,action:e.action,label:e.label,description:e.description,status:"running",params:b(e.params),effect:e.effect,startedAt:i()}]};case"tool-end":return{...n,breakBeforeNextText:true,toolCalls:n.toolCalls.map(o=>o.id===e.id?{...o,status:!e.ok&&e.summary==="refused"?"refused":!e.ok&&e.summary==="declined"?"declined":!e.ok&&e.summary==="stopped"?"stopped":e.ok?"ok":"failed",summary:e.summary,durationMs:e.durationMs,result:e.result}:o)};case"tool-verified":return{...n,toolCalls:n.toolCalls.map(o=>o.id===e.id?{...o,verification:e.verification}:o)};case"block":return{...n,breakBeforeNextText:true,blocks:[...n.blocks,{block:e.block,forToolCallId:e.forToolCallId}]};case"usage":return{...n,usage:{input:(n.usage?.input??0)+e.input,output:(n.usage?.output??0)+e.output,requests:(n.usage?.requests??0)+1}};case"error":return{...n,waiting:void 0,error:e.message};default:return n}});r({messages:a,...e.type==="awaiting-user"?{awaitingBlockId:e.blockId}:{},...e.type==="usage"?{usage:{input:s.usage.input+e.input,output:s.usage.output+e.output,requests:s.usage.requests+1}}:{}})},markStopped(t){r({messages:s.messages.map(e=>e.id===t?{...e,stopped:true}:e)})},finishAssistant(t){r({messages:s.messages.map(e=>e.id===t?{...e,streaming:false,endedAt:i()}:e),busy:false,stopping:false})},askApproval(t){return new Promise(e=>{r({pending:{...t,resolve:e}})})},answerApproval(t){const e=s.pending;const a=typeof t==="boolean"?t:t.approved;const n=typeof t!=="boolean"&&t.trust===true&&a;const o=e?`${e.toolId}.${e.action}`:"";r({pending:null,...n&&e&&!s.trusted.some(u=>u.key===o)?{trusted:[...s.trusted,{key:o,label:e.label}]}:{}});e?.resolve(t)},untrust(t){g?.session.untrust(t);r({trusted:s.trusted.filter(e=>e.key!==t)})},restorePending(t){if(s.pending||s.busy)return false;r({pending:{...t,restored:true,resolve:()=>{}}});return true},addNote(t){r({messages:[...s.messages,{id:l(),role:"assistant",text:t,toolCalls:[],blocks:[],endedAt:i()}]})},hydrate(t){if(s.messages.length>0||s.busy)return false;r({messages:t.messages.map(e=>({...e,restored:true})),answers:t.answers,usage:t.usage,queued:t.queued??[]});return true},reset(){s.pending?.resolve(false);r({messages:[],busy:false,stopping:false,pending:null,trusted:[],notice:null,answers:{},awaitingBlockId:null,actionState:{},queued:[],draft:null,usage:{input:0,output:0,requests:0}})}};export function turnPhaseOf(t){if(t.pending)return"awaitingApproval";if(t.busy)return t.stopping?"stopping":"running";if(t.awaitingBlockId)return"awaitingAnswer";return"idle"}export function queuePauseReason(t){const e=turnPhaseOf(t);if(e==="running"||e==="stopping")return null;if(e==="awaitingApproval")return"Paused \u2014 answer the approval above first.";if(e==="awaitingAnswer")return"Paused \u2014 answer the question above first.";const a=t.messages[t.messages.length-1];if(a?.role==="assistant"&&a.error)return"Paused \u2014 the last turn failed.";if(a?.role==="assistant"&&a.stopped)return"Paused \u2014 you stopped the last turn.";return null}
@@ -1,59 +1 @@
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
1
+ "use strict";import{isAskBlock as f}from"@buoy-gg/agent-core";function u({block:o,forToolCallId:t}){if(!t)return false;const s="source"in o?o.source:void 0;return s==="live"||s==="mocked"}export function placeBlocks(o,t){const s=new Set(t);const n=new Map;const c=[];const r=[];for(const e of o){if(f(e.block)){r.push(e);continue}if(u(e)&&s.has(e.forToolCallId)){const l=n.get(e.forToolCallId)??[];l.push(e.block);n.set(e.forToolCallId,l)}else{c.push(e)}}return{nested:n,afterText:c,ask:r}}