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