@buoy-gg/ask-buoy 7.0.36 → 7.0.38

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 (312) hide show
  1. package/README.md +58 -27
  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 -781
  6. package/lib/commonjs/blocks/ExtraBlocks.js +1 -1860
  7. package/lib/commonjs/blocks/MediaBlocks.js +1 -156
  8. package/lib/commonjs/blocks/ReceiptBlocks.js +1 -586
  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/components/ApprovalCard.js +1 -244
  20. package/lib/commonjs/components/AskBuoyHeader.js +1 -196
  21. package/lib/commonjs/components/AskBuoyIcon.js +1 -19
  22. package/lib/commonjs/components/AskBuoyModal.js +1 -479
  23. package/lib/commonjs/components/AskBuoySettings.js +1 -119
  24. package/lib/commonjs/components/ChangesBar.js +1 -211
  25. package/lib/commonjs/components/Composer.js +1 -255
  26. package/lib/commonjs/components/EmptyState.js +1 -161
  27. package/lib/commonjs/components/KeyboardPad.js +1 -80
  28. package/lib/commonjs/components/Markdown.js +1 -310
  29. package/lib/commonjs/components/MessageList.js +1 -930
  30. package/lib/commonjs/components/QueuedMessages.js +1 -145
  31. package/lib/commonjs/components/ThinkingStrip.js +1 -223
  32. package/lib/commonjs/components/TypingDots.js +1 -63
  33. package/lib/commonjs/components/markdownParse.js +1 -131
  34. package/lib/commonjs/components/markdownParse.test.js +1 -99
  35. package/lib/commonjs/components/useCopyAction.js +1 -50
  36. package/lib/commonjs/index.js +1 -252
  37. package/lib/commonjs/preset.js +1 -90
  38. package/lib/commonjs/store/activityGroups.js +1 -110
  39. package/lib/commonjs/store/activityGroups.test.js +1 -78
  40. package/lib/commonjs/store/askBuoySettings.js +1 -72
  41. package/lib/commonjs/store/askBuoyStore.js +1 -547
  42. package/lib/commonjs/store/blockPlacement.js +1 -64
  43. package/lib/commonjs/store/blockPlacement.test.js +1 -123
  44. package/lib/commonjs/store/queue.test.js +1 -150
  45. package/lib/commonjs/store/resetConversation.js +1 -77
  46. package/lib/commonjs/store/restorePending.test.js +1 -63
  47. package/lib/commonjs/store/restoredIds.test.js +1 -47
  48. package/lib/commonjs/store/suggestions.js +1 -54
  49. package/lib/commonjs/store/suggestions.test.js +1 -58
  50. package/lib/commonjs/store/systemLine.test.js +1 -77
  51. package/lib/commonjs/store/ticketPrompt.js +1 -17
  52. package/lib/commonjs/store/traceText.js +1 -81
  53. package/lib/commonjs/store/traceText.test.js +1 -112
  54. package/lib/commonjs/store/transcriptPersistence.js +1 -297
  55. package/lib/commonjs/store/transcriptPersistence.test.js +1 -333
  56. package/lib/commonjs/store/turnRendering.test.js +1 -151
  57. package/lib/commonjs/store/useAskBuoy.js +1 -622
  58. package/lib/commonjs/store/useAskBuoySettings.js +1 -14
  59. package/lib/commonjs/sync/askBuoySyncAdapter.js +1 -140
  60. package/lib/commonjs/sync/askBuoySyncAdapter.test.js +1 -141
  61. package/lib/commonjs/sync/wire.js +1 -58
  62. package/lib/commonjs/types.js +1 -6
  63. package/lib/module/blocks/AskBlocks.js +1 -331
  64. package/lib/module/blocks/BlockRenderer.js +1 -257
  65. package/lib/module/blocks/ChromePrototypes.js +1 -503
  66. package/lib/module/blocks/DataBlocks.js +1 -767
  67. package/lib/module/blocks/ExtraBlocks.js +1 -1833
  68. package/lib/module/blocks/MediaBlocks.js +1 -151
  69. package/lib/module/blocks/ReceiptBlocks.js +1 -574
  70. package/lib/module/blocks/blockText.js +1 -55
  71. package/lib/module/blocks/blockText.test.js +1 -53
  72. package/lib/module/blocks/context.js +1 -35
  73. package/lib/module/blocks/icons.js +1 -91
  74. package/lib/module/blocks/index.js +1 -8
  75. package/lib/module/blocks/listRow.test.js +1 -56
  76. package/lib/module/blocks/pageState.js +1 -30
  77. package/lib/module/blocks/pageState.test.js +1 -56
  78. package/lib/module/blocks/primitives.js +1 -445
  79. package/lib/module/blocks/primitivesIndex.js +1 -5
  80. package/lib/module/components/ApprovalCard.js +1 -239
  81. package/lib/module/components/AskBuoyHeader.js +1 -193
  82. package/lib/module/components/AskBuoyIcon.js +1 -8
  83. package/lib/module/components/AskBuoyModal.js +1 -474
  84. package/lib/module/components/AskBuoySettings.js +1 -114
  85. package/lib/module/components/ChangesBar.js +1 -206
  86. package/lib/module/components/Composer.js +1 -250
  87. package/lib/module/components/EmptyState.js +1 -156
  88. package/lib/module/components/KeyboardPad.js +1 -75
  89. package/lib/module/components/Markdown.js +1 -305
  90. package/lib/module/components/MessageList.js +1 -924
  91. package/lib/module/components/QueuedMessages.js +1 -140
  92. package/lib/module/components/ThinkingStrip.js +1 -218
  93. package/lib/module/components/TypingDots.js +1 -58
  94. package/lib/module/components/markdownParse.js +1 -125
  95. package/lib/module/components/markdownParse.test.js +1 -98
  96. package/lib/module/components/useCopyAction.js +1 -46
  97. package/lib/module/index.js +1 -34
  98. package/lib/module/preset.js +1 -73
  99. package/lib/module/store/activityGroups.js +1 -103
  100. package/lib/module/store/activityGroups.test.js +1 -77
  101. package/lib/module/store/askBuoySettings.js +1 -67
  102. package/lib/module/store/askBuoyStore.js +1 -541
  103. package/lib/module/store/blockPlacement.js +1 -59
  104. package/lib/module/store/blockPlacement.test.js +1 -122
  105. package/lib/module/store/queue.test.js +1 -149
  106. package/lib/module/store/resetConversation.js +1 -72
  107. package/lib/module/store/restorePending.test.js +1 -62
  108. package/lib/module/store/restoredIds.test.js +1 -46
  109. package/lib/module/store/suggestions.js +1 -49
  110. package/lib/module/store/suggestions.test.js +1 -57
  111. package/lib/module/store/systemLine.test.js +1 -76
  112. package/lib/module/store/ticketPrompt.js +1 -13
  113. package/lib/module/store/traceText.js +1 -75
  114. package/lib/module/store/traceText.test.js +1 -111
  115. package/lib/module/store/transcriptPersistence.js +1 -287
  116. package/lib/module/store/transcriptPersistence.test.js +1 -332
  117. package/lib/module/store/turnRendering.test.js +1 -150
  118. package/lib/module/store/useAskBuoy.js +1 -616
  119. package/lib/module/store/useAskBuoySettings.js +1 -9
  120. package/lib/module/sync/askBuoySyncAdapter.js +1 -135
  121. package/lib/module/sync/askBuoySyncAdapter.test.js +1 -140
  122. package/lib/module/sync/wire.js +1 -47
  123. package/lib/module/types.js +1 -4
  124. package/lib/typescript/components/ApprovalCard.d.ts +9 -1
  125. package/lib/typescript/preset.d.ts +4 -2
  126. package/lib/typescript/store/askBuoyStore.d.ts +32 -4
  127. package/lib/typescript/store/useAskBuoy.d.ts +3 -2
  128. package/lib/typescript/sync/askBuoySyncAdapter.d.ts +3 -0
  129. package/package.json +9 -9
  130. package/lib/commonjs/blocks/AskBlocks.js.map +0 -1
  131. package/lib/commonjs/blocks/BlockRenderer.js.map +0 -1
  132. package/lib/commonjs/blocks/ChromePrototypes.js.map +0 -1
  133. package/lib/commonjs/blocks/DataBlocks.js.map +0 -1
  134. package/lib/commonjs/blocks/ExtraBlocks.js.map +0 -1
  135. package/lib/commonjs/blocks/MediaBlocks.js.map +0 -1
  136. package/lib/commonjs/blocks/ReceiptBlocks.js.map +0 -1
  137. package/lib/commonjs/blocks/blockText.js.map +0 -1
  138. package/lib/commonjs/blocks/blockText.test.js.map +0 -1
  139. package/lib/commonjs/blocks/context.js.map +0 -1
  140. package/lib/commonjs/blocks/icons.js.map +0 -1
  141. package/lib/commonjs/blocks/index.js.map +0 -1
  142. package/lib/commonjs/blocks/listRow.test.js.map +0 -1
  143. package/lib/commonjs/blocks/pageState.js.map +0 -1
  144. package/lib/commonjs/blocks/pageState.test.js.map +0 -1
  145. package/lib/commonjs/blocks/primitives.js.map +0 -1
  146. package/lib/commonjs/blocks/primitivesIndex.js.map +0 -1
  147. package/lib/commonjs/components/ApprovalCard.js.map +0 -1
  148. package/lib/commonjs/components/AskBuoyHeader.js.map +0 -1
  149. package/lib/commonjs/components/AskBuoyIcon.js.map +0 -1
  150. package/lib/commonjs/components/AskBuoyModal.js.map +0 -1
  151. package/lib/commonjs/components/AskBuoySettings.js.map +0 -1
  152. package/lib/commonjs/components/ChangesBar.js.map +0 -1
  153. package/lib/commonjs/components/Composer.js.map +0 -1
  154. package/lib/commonjs/components/EmptyState.js.map +0 -1
  155. package/lib/commonjs/components/KeyboardPad.js.map +0 -1
  156. package/lib/commonjs/components/Markdown.js.map +0 -1
  157. package/lib/commonjs/components/MessageList.js.map +0 -1
  158. package/lib/commonjs/components/QueuedMessages.js.map +0 -1
  159. package/lib/commonjs/components/ThinkingStrip.js.map +0 -1
  160. package/lib/commonjs/components/TypingDots.js.map +0 -1
  161. package/lib/commonjs/components/markdownParse.js.map +0 -1
  162. package/lib/commonjs/components/markdownParse.test.js.map +0 -1
  163. package/lib/commonjs/components/useCopyAction.js.map +0 -1
  164. package/lib/commonjs/index.js.map +0 -1
  165. package/lib/commonjs/preset.js.map +0 -1
  166. package/lib/commonjs/store/activityGroups.js.map +0 -1
  167. package/lib/commonjs/store/activityGroups.test.js.map +0 -1
  168. package/lib/commonjs/store/askBuoySettings.js.map +0 -1
  169. package/lib/commonjs/store/askBuoyStore.js.map +0 -1
  170. package/lib/commonjs/store/blockPlacement.js.map +0 -1
  171. package/lib/commonjs/store/blockPlacement.test.js.map +0 -1
  172. package/lib/commonjs/store/queue.test.js.map +0 -1
  173. package/lib/commonjs/store/resetConversation.js.map +0 -1
  174. package/lib/commonjs/store/restorePending.test.js.map +0 -1
  175. package/lib/commonjs/store/restoredIds.test.js.map +0 -1
  176. package/lib/commonjs/store/suggestions.js.map +0 -1
  177. package/lib/commonjs/store/suggestions.test.js.map +0 -1
  178. package/lib/commonjs/store/systemLine.test.js.map +0 -1
  179. package/lib/commonjs/store/ticketPrompt.js.map +0 -1
  180. package/lib/commonjs/store/traceText.js.map +0 -1
  181. package/lib/commonjs/store/traceText.test.js.map +0 -1
  182. package/lib/commonjs/store/transcriptPersistence.js.map +0 -1
  183. package/lib/commonjs/store/transcriptPersistence.test.js.map +0 -1
  184. package/lib/commonjs/store/turnRendering.test.js.map +0 -1
  185. package/lib/commonjs/store/useAskBuoy.js.map +0 -1
  186. package/lib/commonjs/store/useAskBuoySettings.js.map +0 -1
  187. package/lib/commonjs/sync/askBuoySyncAdapter.js.map +0 -1
  188. package/lib/commonjs/sync/askBuoySyncAdapter.test.js.map +0 -1
  189. package/lib/commonjs/sync/wire.js.map +0 -1
  190. package/lib/commonjs/types.js.map +0 -1
  191. package/lib/module/blocks/AskBlocks.js.map +0 -1
  192. package/lib/module/blocks/BlockRenderer.js.map +0 -1
  193. package/lib/module/blocks/ChromePrototypes.js.map +0 -1
  194. package/lib/module/blocks/DataBlocks.js.map +0 -1
  195. package/lib/module/blocks/ExtraBlocks.js.map +0 -1
  196. package/lib/module/blocks/MediaBlocks.js.map +0 -1
  197. package/lib/module/blocks/ReceiptBlocks.js.map +0 -1
  198. package/lib/module/blocks/blockText.js.map +0 -1
  199. package/lib/module/blocks/blockText.test.js.map +0 -1
  200. package/lib/module/blocks/context.js.map +0 -1
  201. package/lib/module/blocks/icons.js.map +0 -1
  202. package/lib/module/blocks/index.js.map +0 -1
  203. package/lib/module/blocks/listRow.test.js.map +0 -1
  204. package/lib/module/blocks/pageState.js.map +0 -1
  205. package/lib/module/blocks/pageState.test.js.map +0 -1
  206. package/lib/module/blocks/primitives.js.map +0 -1
  207. package/lib/module/blocks/primitivesIndex.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/components/ApprovalCard.d.ts.map +0 -1
  270. package/lib/typescript/components/AskBuoyHeader.d.ts.map +0 -1
  271. package/lib/typescript/components/AskBuoyIcon.d.ts.map +0 -1
  272. package/lib/typescript/components/AskBuoyModal.d.ts.map +0 -1
  273. package/lib/typescript/components/AskBuoySettings.d.ts.map +0 -1
  274. package/lib/typescript/components/ChangesBar.d.ts.map +0 -1
  275. package/lib/typescript/components/Composer.d.ts.map +0 -1
  276. package/lib/typescript/components/EmptyState.d.ts.map +0 -1
  277. package/lib/typescript/components/KeyboardPad.d.ts.map +0 -1
  278. package/lib/typescript/components/Markdown.d.ts.map +0 -1
  279. package/lib/typescript/components/MessageList.d.ts.map +0 -1
  280. package/lib/typescript/components/QueuedMessages.d.ts.map +0 -1
  281. package/lib/typescript/components/ThinkingStrip.d.ts.map +0 -1
  282. package/lib/typescript/components/TypingDots.d.ts.map +0 -1
  283. package/lib/typescript/components/markdownParse.d.ts.map +0 -1
  284. package/lib/typescript/components/markdownParse.test.d.ts.map +0 -1
  285. package/lib/typescript/components/useCopyAction.d.ts.map +0 -1
  286. package/lib/typescript/index.d.ts.map +0 -1
  287. package/lib/typescript/preset.d.ts.map +0 -1
  288. package/lib/typescript/store/activityGroups.d.ts.map +0 -1
  289. package/lib/typescript/store/activityGroups.test.d.ts.map +0 -1
  290. package/lib/typescript/store/askBuoySettings.d.ts.map +0 -1
  291. package/lib/typescript/store/askBuoyStore.d.ts.map +0 -1
  292. package/lib/typescript/store/blockPlacement.d.ts.map +0 -1
  293. package/lib/typescript/store/blockPlacement.test.d.ts.map +0 -1
  294. package/lib/typescript/store/queue.test.d.ts.map +0 -1
  295. package/lib/typescript/store/resetConversation.d.ts.map +0 -1
  296. package/lib/typescript/store/restorePending.test.d.ts.map +0 -1
  297. package/lib/typescript/store/restoredIds.test.d.ts.map +0 -1
  298. package/lib/typescript/store/suggestions.d.ts.map +0 -1
  299. package/lib/typescript/store/suggestions.test.d.ts.map +0 -1
  300. package/lib/typescript/store/systemLine.test.d.ts.map +0 -1
  301. package/lib/typescript/store/ticketPrompt.d.ts.map +0 -1
  302. package/lib/typescript/store/traceText.d.ts.map +0 -1
  303. package/lib/typescript/store/traceText.test.d.ts.map +0 -1
  304. package/lib/typescript/store/transcriptPersistence.d.ts.map +0 -1
  305. package/lib/typescript/store/transcriptPersistence.test.d.ts.map +0 -1
  306. package/lib/typescript/store/turnRendering.test.d.ts.map +0 -1
  307. package/lib/typescript/store/useAskBuoy.d.ts.map +0 -1
  308. package/lib/typescript/store/useAskBuoySettings.d.ts.map +0 -1
  309. package/lib/typescript/sync/askBuoySyncAdapter.d.ts.map +0 -1
  310. package/lib/typescript/sync/askBuoySyncAdapter.test.d.ts.map +0 -1
  311. package/lib/typescript/sync/wire.d.ts.map +0 -1
  312. package/lib/typescript/types.d.ts.map +0 -1
@@ -1,547 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.askBuoyStore = void 0;
7
- exports.queuePauseReason = queuePauseReason;
8
- exports.turnPhaseOf = turnPhaseOf;
9
- var _agentCore = require("@buoy-gg/agent-core");
10
- /**
11
- * Conversation state for the sheet.
12
- *
13
- * A module-level store rather than component state for two reasons: the sheet
14
- * is unmounted whenever the tool is closed or minimised (and a conversation
15
- * that vanished because someone tapped away would be maddening), and the sync
16
- * adapter needs to read the same transcript to show it on the desktop.
17
- *
18
- * Persisted across restarts, on purpose, with the payloads left out — see
19
- * `transcriptPersistence.ts` for what is written and what that costs. The
20
- * store itself stays a plain in-memory store; saving is a subscriber, and
21
- * `hydrate` is the one way anything comes back in.
22
- */
23
-
24
- /** A block in a message, and (for receipts) the tool call that produced it. */
25
-
26
- /**
27
- * A stretch of the model's own reasoning, and where it fell.
28
- *
29
- * `afterCalls` is how many tool calls this message had already made when the
30
- * thought arrived, so the thinking view can lay reasoning and steps out in the
31
- * order they actually happened. One assistant bubble spans every turn of a
32
- * multi-step run, so "think, act, think, act" is the normal shape and showing
33
- * all the thoughts in a lump at the top would misreport it.
34
- */
35
-
36
- /**
37
- * A message typed while a turn was running.
38
- *
39
- * A list with ids, not a string: the single slot it replaced OVERWROTE — type
40
- * two things mid-turn and the first vanished, which is precisely the loss the
41
- * queue exists to prevent. Ids so two identical requests stay distinguishable
42
- * and the list can be edited by row.
43
- */
44
-
45
- /**
46
- * The one word every component reads to know what the chat is doing.
47
- *
48
- * Presentation state (minimised, settings open) is NOT in here on purpose —
49
- * it sits on top. This exists because the header, the composer, the queue
50
- * flush and the modal each used to derive their own answer from five
51
- * overlapping booleans, and disagreed: the queue fired after an error because
52
- * "not busy" looked like "idle" to it.
53
- */
54
-
55
- /**
56
- * Message ids carry this run's token — see agent-core's `runId`. A plain `m1`
57
- * collided head-on with the `m1` in a restored transcript, and the message
58
- * list keys on it.
59
- */
60
- const nextId = (0, _agentCore.idFactory)("m");
61
-
62
- /**
63
- * Params, as one readable line. Capped because a step can carry a whole
64
- * response body or a store's full state, and this is chrome inside a chat
65
- * bubble — the full value is a tool read away.
66
- */
67
- const MAX_PARAM_CHARS = 400;
68
- function encodeParams(params) {
69
- if (!params || Object.keys(params).length === 0) return undefined;
70
- try {
71
- const json = JSON.stringify(params);
72
- return json.length > MAX_PARAM_CHARS ? `${json.slice(0, MAX_PARAM_CHARS)}…` : json;
73
- } catch {
74
- return undefined;
75
- }
76
- }
77
-
78
- /** Queue ids carry the run token too — a restored queue keys on them. */
79
- const nextQueuedId = (0, _agentCore.idFactory)("q");
80
- let state = {
81
- messages: [],
82
- busy: false,
83
- stopping: false,
84
- pending: null,
85
- notice: null,
86
- configured: false,
87
- answers: {},
88
- awaitingBlockId: null,
89
- actionState: {},
90
- queued: [],
91
- draft: null,
92
- usage: {
93
- input: 0,
94
- output: 0,
95
- requests: 0
96
- },
97
- meta: {}
98
- };
99
- const listeners = new Set();
100
- let ledgerRef = null;
101
-
102
- /**
103
- * The session outlives the sheet the same way the transcript does. Session and
104
- * ledger used to be per-mount: closing and reopening the tool kept the visible
105
- * conversation but silently swapped in an empty ledger and a blank model
106
- * memory — the undo bar vanished while the agent's changes stayed live in the
107
- * app. Held here, keyed by a config signature so a real reconfiguration
108
- * (different endpoint/model/tool set) still rebuilds.
109
- */
110
- let heldSession = null;
111
- function set(next) {
112
- state = {
113
- ...state,
114
- ...next
115
- };
116
- for (const fn of listeners) {
117
- try {
118
- fn();
119
- } catch {
120
- // A throwing subscriber must not take the transcript down mid-answer.
121
- }
122
- }
123
- }
124
- const askBuoyStore = exports.askBuoyStore = {
125
- getState: () => state,
126
- subscribe(fn) {
127
- listeners.add(fn);
128
- return () => listeners.delete(fn);
129
- },
130
- setLedger(ledger) {
131
- ledgerRef = ledger;
132
- },
133
- getLedger() {
134
- return ledgerRef;
135
- },
136
- holdSession(session, signature) {
137
- heldSession = {
138
- session,
139
- signature
140
- };
141
- },
142
- getHeldSession() {
143
- return heldSession;
144
- },
145
- setNotice(notice) {
146
- set({
147
- notice
148
- });
149
- },
150
- setConfigured(configured) {
151
- if (configured !== state.configured) set({
152
- configured
153
- });
154
- },
155
- setMeta(meta) {
156
- const same = Object.keys(meta).every(k => state.meta[k] === meta[k]);
157
- if (!same) set({
158
- meta: {
159
- ...state.meta,
160
- ...meta
161
- }
162
- });
163
- },
164
- addUser(text) {
165
- set({
166
- messages: [...state.messages, {
167
- id: nextId(),
168
- role: "user",
169
- text,
170
- toolCalls: [],
171
- blocks: []
172
- }],
173
- busy: true
174
- });
175
- },
176
- /** Mark a turn as running without adding a bubble — the retry path. */
177
- beginTurn() {
178
- set({
179
- busy: true
180
- });
181
- },
182
- /** Park a message typed mid-turn, behind whatever is already parked. */
183
- enqueue(text) {
184
- const item = {
185
- id: nextQueuedId(),
186
- text
187
- };
188
- set({
189
- queued: [...state.queued, item]
190
- });
191
- return item;
192
- },
193
- /** Drop one parked message — the ✕ on its row. */
194
- removeQueued(id) {
195
- if (!state.queued.some(q => q.id === id)) return;
196
- set({
197
- queued: state.queued.filter(q => q.id !== id)
198
- });
199
- },
200
- /** Take the FIRST parked message off the queue — the flush path. */
201
- shiftQueued() {
202
- const [next, ...rest] = state.queued;
203
- if (!next) return undefined;
204
- set({
205
- queued: rest
206
- });
207
- return next;
208
- },
209
- /** Hand one parked message back to the composer to edit. See `draft`. */
210
- takeQueuedToDraft(id) {
211
- const item = state.queued.find(q => q.id === id);
212
- if (!item) return;
213
- set({
214
- queued: state.queued.filter(q => q.id !== id),
215
- draft: item.text
216
- });
217
- },
218
- /**
219
- * The user pressed Stop. The turn is still winding down — the abort is only
220
- * read between calls — so the phase is `stopping`, not `idle`, until
221
- * `finishAssistant` lands.
222
- */
223
- requestStop() {
224
- if (!state.busy || state.stopping) return;
225
- set({
226
- stopping: true
227
- });
228
- },
229
- /** The composer has taken the draft into its input. */
230
- clearDraft() {
231
- if (state.draft === null) return;
232
- set({
233
- draft: null
234
- });
235
- },
236
- /** Drop one message — the failed assistant bubble a retry replaces. */
237
- removeMessage(id) {
238
- set({
239
- messages: state.messages.filter(m => m.id !== id)
240
- });
241
- },
242
- /** The user answered (or skipped) an Ask block. */
243
- recordAnswer(answer) {
244
- set({
245
- answers: {
246
- ...state.answers,
247
- [answer.blockId]: answer
248
- },
249
- awaitingBlockId: state.awaitingBlockId === answer.blockId ? null : state.awaitingBlockId
250
- });
251
- },
252
- setActionState(key, value) {
253
- const next = {
254
- ...state.actionState
255
- };
256
- if (value === null) delete next[key];else next[key] = value;
257
- set({
258
- actionState: next
259
- });
260
- },
261
- /** Open a new assistant bubble for the turn that is about to stream. */
262
- startAssistant() {
263
- const id = nextId();
264
- set({
265
- messages: [...state.messages, {
266
- id,
267
- role: "assistant",
268
- text: "",
269
- toolCalls: [],
270
- blocks: [],
271
- streaming: true,
272
- startedAt: Date.now()
273
- }]
274
- });
275
- return id;
276
- },
277
- /**
278
- * Fold one engine event into the open assistant message.
279
- *
280
- * Tool calls render as rows inside the bubble rather than as raw payloads:
281
- * the label is already domain-flavoured ("Set points to 1500"), which is the
282
- * only form a non-developer can actually check.
283
- */
284
- applyEvent(messageId, ev) {
285
- if (ev.type === "history-trimmed") {
286
- // Before the answer it affects, so it reads as a caption on the gap
287
- // rather than as part of the reply.
288
- const at = state.messages.findIndex(m => m.id === messageId);
289
- const line = {
290
- id: nextId(),
291
- role: "assistant",
292
- system: true,
293
- text: `Older messages were trimmed from the agent's memory (${ev.droppedRounds} exchange${ev.droppedRounds === 1 ? "" : "s"}). It may not recall setup from earlier in this chat — the changes bar still lists what is applied.`,
294
- toolCalls: [],
295
- blocks: [],
296
- endedAt: Date.now()
297
- };
298
- const next = [...state.messages];
299
- next.splice(at < 0 ? next.length : at, 0, line);
300
- set({
301
- messages: next
302
- });
303
- return;
304
- }
305
- const messages = state.messages.map(m => {
306
- if (m.id !== messageId) return m;
307
- switch (ev.type) {
308
- case "text":
309
- return {
310
- ...m,
311
- text: (m.breakBeforeNextText || ev.breakBefore) && m.text ? `${m.text.trimEnd()}\n\n${ev.delta}` : m.text + ev.delta,
312
- breakBeforeNextText: false
313
- };
314
- case "reasoning":
315
- return {
316
- ...m,
317
- breakBeforeNextText: true,
318
- reasoning: [...(m.reasoning ?? []), {
319
- text: ev.text,
320
- afterCalls: m.toolCalls.length
321
- }]
322
- };
323
- case "tool-start":
324
- return {
325
- ...m,
326
- toolCalls: [...m.toolCalls, {
327
- id: ev.id,
328
- toolId: ev.toolId,
329
- action: ev.action,
330
- label: ev.label,
331
- description: ev.description,
332
- status: "running",
333
- params: encodeParams(ev.params),
334
- effect: ev.effect,
335
- startedAt: Date.now()
336
- }]
337
- };
338
- case "tool-end":
339
- return {
340
- ...m,
341
- breakBeforeNextText: true,
342
- toolCalls: m.toolCalls.map(c => c.id === ev.id ? {
343
- ...c,
344
- status: !ev.ok && ev.summary === "refused" ? "refused" : !ev.ok && ev.summary === "declined" ? "declined" : !ev.ok && ev.summary === "stopped" ? "stopped" : ev.ok ? "ok" : "failed",
345
- summary: ev.summary,
346
- durationMs: ev.durationMs,
347
- result: ev.result
348
- } : c)
349
- };
350
- case "block":
351
- return {
352
- ...m,
353
- breakBeforeNextText: true,
354
- blocks: [...m.blocks, {
355
- block: ev.block,
356
- forToolCallId: ev.forToolCallId
357
- }]
358
- };
359
- case "usage":
360
- // Also folded into the session total below. Per MESSAGE as well,
361
- // because "which answer cost 40k tokens" is the question you ask
362
- // when a bill looks wrong, and a session total cannot answer it.
363
- return {
364
- ...m,
365
- usage: {
366
- input: (m.usage?.input ?? 0) + ev.input,
367
- output: (m.usage?.output ?? 0) + ev.output,
368
- requests: (m.usage?.requests ?? 0) + 1
369
- }
370
- };
371
- case "error":
372
- return {
373
- ...m,
374
- error: ev.message
375
- };
376
- default:
377
- return m;
378
- }
379
- });
380
- set({
381
- messages,
382
- ...(ev.type === "awaiting-user" ? {
383
- awaitingBlockId: ev.blockId
384
- } : {}),
385
- ...(ev.type === "usage" ? {
386
- usage: {
387
- input: state.usage.input + ev.input,
388
- output: state.usage.output + ev.output,
389
- requests: state.usage.requests + 1
390
- }
391
- } : {})
392
- });
393
- },
394
- /** The user pressed Stop on this turn. See `ChatMessage.stopped`. */
395
- markStopped(messageId) {
396
- set({
397
- messages: state.messages.map(m => m.id === messageId ? {
398
- ...m,
399
- stopped: true
400
- } : m)
401
- });
402
- },
403
- finishAssistant(messageId) {
404
- set({
405
- messages: state.messages.map(m => m.id === messageId ? {
406
- ...m,
407
- streaming: false,
408
- endedAt: Date.now()
409
- } : m),
410
- busy: false,
411
- stopping: false
412
- });
413
- },
414
- askApproval(input) {
415
- return new Promise(resolve => {
416
- set({
417
- pending: {
418
- ...input,
419
- resolve
420
- }
421
- });
422
- });
423
- },
424
- answerApproval(approved) {
425
- const pending = state.pending;
426
- set({
427
- pending: null
428
- });
429
- pending?.resolve(approved);
430
- },
431
- /**
432
- * Put an unanswered approval back after a restart.
433
- *
434
- * A question the app asked and then forgot is worse than not asking: the
435
- * user tapped nothing, so as far as they are concerned the change is still
436
- * waiting for them. `resolve` is a no-op because nothing is waiting on this
437
- * one any more; `restored` is what tells the sheet to run the call rather
438
- * than answer a dead promise.
439
- *
440
- * Refused once a turn is under way, for the same reason `hydrate` is: a slow
441
- * disk read must not shove an old question in front of a live conversation.
442
- */
443
- restorePending(input) {
444
- if (state.pending || state.busy) return false;
445
- set({
446
- pending: {
447
- ...input,
448
- restored: true,
449
- resolve: () => {}
450
- }
451
- });
452
- return true;
453
- },
454
- /**
455
- * A line in the transcript from Buoy itself rather than from the model.
456
- *
457
- * It wears the assistant's bubble because that is the only shape the list
458
- * renders, but nothing is sent to the model and nothing lands in its
459
- * history — it exists so an approval answered after a restart leaves a
460
- * trace, instead of the card silently vanishing a second time.
461
- */
462
- addNote(text) {
463
- set({
464
- messages: [...state.messages, {
465
- id: nextId(),
466
- role: "assistant",
467
- text,
468
- toolCalls: [],
469
- blocks: [],
470
- endedAt: Date.now()
471
- }]
472
- });
473
- },
474
- /**
475
- * Put a saved conversation back, once, at open.
476
- *
477
- * Refuses if anything has been said already: a slow disk read landing after
478
- * the user has started typing must not shove an old chat in front of them.
479
- */
480
- hydrate(input) {
481
- if (state.messages.length > 0 || state.busy) return false;
482
- set({
483
- messages: input.messages.map(m => ({
484
- ...m,
485
- restored: true
486
- })),
487
- answers: input.answers,
488
- usage: input.usage,
489
- queued: input.queued ?? []
490
- });
491
- return true;
492
- },
493
- reset() {
494
- // Reject anything still waiting, or the turn hangs forever on a promise
495
- // whose only resolver just left the screen.
496
- state.pending?.resolve(false);
497
- set({
498
- messages: [],
499
- busy: false,
500
- stopping: false,
501
- pending: null,
502
- notice: null,
503
- answers: {},
504
- awaitingBlockId: null,
505
- actionState: {},
506
- queued: [],
507
- draft: null,
508
- usage: {
509
- input: 0,
510
- output: 0,
511
- requests: 0
512
- }
513
- // `meta` survives: it describes the app and the endpoint, not the
514
- // conversation, and re-deriving it would need another render pass.
515
- });
516
- }
517
- };
518
-
519
- /** See TurnPhase. Pure, so every component and the flush effect agree. */
520
- function turnPhaseOf(s) {
521
- if (s.pending) return "awaitingApproval";
522
- if (s.busy) return s.stopping ? "stopping" : "running";
523
- if (s.awaitingBlockId) return "awaitingAnswer";
524
- return "idle";
525
- }
526
-
527
- /**
528
- * Why parked messages are NOT being sent right now, in the user's words — or
529
- * null when the queue may deliver.
530
- *
531
- * A queued message is a next TASK, not an answer. It used to go the moment
532
- * `busy` dropped: after an error it fired into the same dead connection, and
533
- * with a choice block open it was sent as the reply to the question. So the
534
- * queue holds on error, Stop, an approval and an unanswered Ask block, and
535
- * says which.
536
- */
537
- function queuePauseReason(s) {
538
- const phase = turnPhaseOf(s);
539
- if (phase === "running" || phase === "stopping") return null;
540
- if (phase === "awaitingApproval") return "Paused — answer the approval above first.";
541
- if (phase === "awaitingAnswer") return "Paused — answer the question above first.";
542
- const last = s.messages[s.messages.length - 1];
543
- if (last?.role === "assistant" && last.error) return "Paused — the last turn failed.";
544
- if (last?.role === "assistant" && last.stopped) return "Paused — you stopped the last turn.";
545
- return null;
546
- }
547
- //# sourceMappingURL=askBuoyStore.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.askBuoyStore=void 0,exports.queuePauseReason=queuePauseReason,exports.turnPhaseOf=turnPhaseOf;var _agentCore=require("@buoy-gg/agent-core");const nextId=(0,_agentCore.idFactory)("m"),MAX_PARAM_CHARS=400;function encodeParams(e){if(e&&0!==Object.keys(e).length)try{const t=JSON.stringify(e);return t.length>400?`${t.slice(0,400)}…`:t}catch{return}}const nextQueuedId=(0,_agentCore.idFactory)("q");let state={messages:[],busy:!1,stopping:!1,pending:null,trusted:[],notice:null,configured:!1,answers:{},awaitingBlockId:null,actionState:{},queued:[],draft:null,usage:{input:0,output:0,requests:0},meta:{}};const listeners=new Set;let ledgerRef=null,heldSession=null;function set(e){state={...state,...e};for(const e of listeners)try{e()}catch{}}const askBuoyStore=exports.askBuoyStore={getState:()=>state,subscribe:e=>(listeners.add(e),()=>listeners.delete(e)),setLedger(e){ledgerRef=e},getLedger:()=>ledgerRef,holdSession(e,t){heldSession={session:e,signature:t}},getHeldSession:()=>heldSession,setNotice(e){set({notice:e})},setConfigured(e){e!==state.configured&&set({configured:e})},setMeta(e){Object.keys(e).every(t=>state.meta[t]===e[t])||set({meta:{...state.meta,...e}})},addUser(e){set({messages:[...state.messages,{id:nextId(),role:"user",text:e,toolCalls:[],blocks:[]}],busy:!0})},beginTurn(){set({busy:!0})},enqueue(e){const t={id:nextQueuedId(),text:e};return set({queued:[...state.queued,t]}),t},removeQueued(e){state.queued.some(t=>t.id===e)&&set({queued:state.queued.filter(t=>t.id!==e)})},shiftQueued(){const[e,...t]=state.queued;if(e)return set({queued:t}),e},takeQueuedToDraft(e){const t=state.queued.find(t=>t.id===e);t&&set({queued:state.queued.filter(t=>t.id!==e),draft:t.text})},requestStop(){state.busy&&!state.stopping&&set({stopping:!0})},clearDraft(){null!==state.draft&&set({draft:null})},removeMessage(e){set({messages:state.messages.filter(t=>t.id!==e)})},recordAnswer(e){set({answers:{...state.answers,[e.blockId]:e},awaitingBlockId:state.awaitingBlockId===e.blockId?null:state.awaitingBlockId})},setActionState(e,t){const s={...state.actionState};null===t?delete s[e]:s[e]=t,set({actionState:s})},startAssistant(){const e=nextId();return set({messages:[...state.messages,{id:e,role:"assistant",text:"",toolCalls:[],blocks:[],streaming:!0,startedAt:Date.now()}]}),e},applyEvent(e,t){if("history-trimmed"===t.type){const s=state.messages.findIndex(t=>t.id===e),a={id:nextId(),role:"assistant",system:!0,text:`Older messages were trimmed from the agent's memory (${t.droppedRounds} exchange${1===t.droppedRounds?"":"s"}).`+(t.droppedPinned?` ${1===t.droppedPinned?"One of them made a change that is":`${t.droppedPinned} of them made changes that are`} still applied — the changes bar still lists ${1===t.droppedPinned?"it":"them"}, but the agent no longer remembers making ${1===t.droppedPinned?"it":"them"}.`:" It may not recall setup from earlier in this chat — the changes bar still lists what is applied."),toolCalls:[],blocks:[],endedAt:Date.now()},n=[...state.messages];return n.splice(s<0?n.length:s,0,a),void set({messages:n})}set({messages:state.messages.map(s=>{if(s.id!==e)return s;switch(t.type){case"retrying":{const e=Math.max(1,Math.round(t.inMs/1e3));return{...s,waiting:"throttled"===t.reason?`Endpoint busy — retrying in ${e}s (${t.attempt} of ${t.maxAttempts})`:"Request too large — trimming older messages and retrying"}}case"text":return{...s,waiting:void 0,text:(s.breakBeforeNextText||t.breakBefore)&&s.text?`${s.text.trimEnd()}\n\n${t.delta}`:s.text+t.delta,breakBeforeNextText:!1};case"reasoning":return{...s,breakBeforeNextText:!0,reasoning:[...s.reasoning??[],{text:t.text,afterCalls:s.toolCalls.length}]};case"tool-start":return{...s,waiting:void 0,toolCalls:[...s.toolCalls,{id:t.id,toolId:t.toolId,action:t.action,label:t.label,description:t.description,status:"running",params:encodeParams(t.params),effect:t.effect,startedAt:Date.now()}]};case"tool-end":return{...s,breakBeforeNextText:!0,toolCalls:s.toolCalls.map(e=>e.id===t.id?{...e,status:t.ok||"refused"!==t.summary?t.ok||"declined"!==t.summary?t.ok||"stopped"!==t.summary?t.ok?"ok":"failed":"stopped":"declined":"refused",summary:t.summary,durationMs:t.durationMs,result:t.result}:e)};case"tool-verified":return{...s,toolCalls:s.toolCalls.map(e=>e.id===t.id?{...e,verification:t.verification}:e)};case"block":return{...s,breakBeforeNextText:!0,blocks:[...s.blocks,{block:t.block,forToolCallId:t.forToolCallId}]};case"usage":return{...s,usage:{input:(s.usage?.input??0)+t.input,output:(s.usage?.output??0)+t.output,requests:(s.usage?.requests??0)+1}};case"error":return{...s,waiting:void 0,error:t.message};default:return s}}),..."awaiting-user"===t.type?{awaitingBlockId:t.blockId}:{},..."usage"===t.type?{usage:{input:state.usage.input+t.input,output:state.usage.output+t.output,requests:state.usage.requests+1}}:{}})},markStopped(e){set({messages:state.messages.map(t=>t.id===e?{...t,stopped:!0}:t)})},finishAssistant(e){set({messages:state.messages.map(t=>t.id===e?{...t,streaming:!1,endedAt:Date.now()}:t),busy:!1,stopping:!1})},askApproval:e=>new Promise(t=>{set({pending:{...e,resolve:t}})}),answerApproval(e){const t=state.pending,s="boolean"==typeof e?e:e.approved,a="boolean"!=typeof e&&!0===e.trust&&s,n=t?`${t.toolId}.${t.action}`:"";set({pending:null,...a&&t&&!state.trusted.some(e=>e.key===n)?{trusted:[...state.trusted,{key:n,label:t.label}]}:{}}),t?.resolve(e)},untrust(e){heldSession?.session.untrust(e),set({trusted:state.trusted.filter(t=>t.key!==e)})},restorePending:e=>!state.pending&&!state.busy&&(set({pending:{...e,restored:!0,resolve:()=>{}}}),!0),addNote(e){set({messages:[...state.messages,{id:nextId(),role:"assistant",text:e,toolCalls:[],blocks:[],endedAt:Date.now()}]})},hydrate:e=>!(state.messages.length>0||state.busy||(set({messages:e.messages.map(e=>({...e,restored:!0})),answers:e.answers,usage:e.usage,queued:e.queued??[]}),0)),reset(){state.pending?.resolve(!1),set({messages:[],busy:!1,stopping:!1,pending:null,trusted:[],notice:null,answers:{},awaitingBlockId:null,actionState:{},queued:[],draft:null,usage:{input:0,output:0,requests:0}})}};function turnPhaseOf(e){return e.pending?"awaitingApproval":e.busy?e.stopping?"stopping":"running":e.awaitingBlockId?"awaitingAnswer":"idle"}function queuePauseReason(e){const t=turnPhaseOf(e);if("running"===t||"stopping"===t)return null;if("awaitingApproval"===t)return"Paused — answer the approval above first.";if("awaitingAnswer"===t)return"Paused — answer the question above first.";const s=e.messages[e.messages.length-1];return"assistant"===s?.role&&s.error?"Paused — the last turn failed.":"assistant"===s?.role&&s.stopped?"Paused — you stopped the last turn.":null}
@@ -1,64 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.placeBlocks = placeBlocks;
7
- var _agentCore = require("@buoy-gg/agent-core");
8
- /**
9
- * Where each block of a turn is drawn: inside a step row, after the prose as
10
- * the answer itself, or last of all as the thing being asked.
11
- *
12
- * Pure and separate from MessageList because the rule is subtle and the cost
13
- * of getting it wrong is silent — a block that lands in no bucket renders
14
- * nowhere at all, and nothing in the UI says so. That is exactly what
15
- * happened: "show me the shop as pictures" built its imageGrid, the engine
16
- * accepted it, and the sheet dropped it on the floor twice while the model
17
- * narrated the artwork in prose.
18
- */
19
-
20
- /**
21
- * A receipt that belongs inside its step row rather than in the answer: it
22
- * came from a tool call, and it reports what was READ, not what was changed.
23
- *
24
- * ONLY a receipt nests, which is why this tests for the receipt provenances
25
- * rather than for "not changed". A model-authored block (`buoy_ui`, source
26
- * "model") also carries the id of the call that produced it — but `buoy_ui`
27
- * emits no activity row, so there was no step for it to nest under.
28
- */
29
- function nestsUnderStep({
30
- block,
31
- forToolCallId
32
- }) {
33
- if (!forToolCallId) return false;
34
- const source = "source" in block ? block.source : undefined;
35
- return source === "live" || source === "mocked";
36
- }
37
- function placeBlocks(blocks, stepIds) {
38
- const steps = new Set(stepIds);
39
- const nested = new Map();
40
- const afterText = [];
41
- const ask = [];
42
- for (const placed of blocks) {
43
- if ((0, _agentCore.isAskBlock)(placed.block)) {
44
- ask.push(placed);
45
- continue;
46
- }
47
- // A block may only nest under a step that actually has a row. Anything
48
- // pointing at a call the activity list never drew renders with the answer
49
- // — never nowhere.
50
- if (nestsUnderStep(placed) && steps.has(placed.forToolCallId)) {
51
- const list = nested.get(placed.forToolCallId) ?? [];
52
- list.push(placed.block);
53
- nested.set(placed.forToolCallId, list);
54
- } else {
55
- afterText.push(placed);
56
- }
57
- }
58
- return {
59
- nested,
60
- afterText,
61
- ask
62
- };
63
- }
64
- //# sourceMappingURL=blockPlacement.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.placeBlocks=placeBlocks;var _agentCore=require("@buoy-gg/agent-core");function nestsUnderStep({block:e,forToolCallId:o}){if(!o)return!1;const s="source"in e?e.source:void 0;return"live"===s||"mocked"===s}function placeBlocks(e,o){const s=new Set(o),t=new Map,l=[],r=[];for(const o of e)if((0,_agentCore.isAskBlock)(o.block))r.push(o);else if(nestsUnderStep(o)&&s.has(o.forToolCallId)){const e=t.get(o.forToolCallId)??[];e.push(o.block),t.set(o.forToolCallId,e)}else l.push(o);return{nested:t,afterText:l,ask:r}}