@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,122 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * The bug this file exists for: a model-authored block carries the id of the
5
- * `buoy_ui` call that made it, `buoy_ui` never draws an activity row, and the
6
- * nesting rule ("anything from a call, unless it's a write receipt") swept it
7
- * into a bucket keyed by a row that does not exist. Two consecutive asks for
8
- * pictures of a shop came back as prose.
9
- */
10
- import { describe, expect, it } from "vitest";
11
- import { placeBlocks } from "./blockPlacement";
12
- const placed = (b, forToolCallId) => ({
13
- block: b,
14
- forToolCallId
15
- });
16
- const grid = (id = "ui1") => placed({
17
- id,
18
- kind: "imageGrid",
19
- source: "model",
20
- images: [{
21
- url: "https://cdn.example.com/25.png",
22
- alt: "Pikachu"
23
- }]
24
- }, "call-ui");
25
- describe("model-authored blocks", () => {
26
- it("renders in the answer, never nested under a step that has no row", () => {
27
- const {
28
- afterText,
29
- nested
30
- } = placeBlocks([grid()], ["c1"]);
31
- expect(afterText.map(p => p.block.id)).toEqual(["ui1"]);
32
- expect(nested.size).toBe(0);
33
- });
34
- it("still renders even when a step with that id somehow exists", () => {
35
- const {
36
- afterText
37
- } = placeBlocks([grid()], ["call-ui"]);
38
- expect(afterText.map(p => p.block.id)).toEqual(["ui1"]);
39
- });
40
- });
41
- describe("receipts", () => {
42
- it("folds a read receipt into its own step row", () => {
43
- const read = placed({
44
- id: "r1",
45
- kind: "keyValue",
46
- source: "live",
47
- pairs: []
48
- }, "c1");
49
- const {
50
- nested,
51
- afterText
52
- } = placeBlocks([read], ["c1"]);
53
- expect(afterText).toEqual([]);
54
- expect(nested.get("c1")?.map(b => b.id)).toEqual(["r1"]);
55
- });
56
- it("keeps a write receipt afterText — the user must see it without asking", () => {
57
- const write = placed({
58
- id: "w1",
59
- kind: "diff",
60
- source: "changed",
61
- changes: []
62
- }, "c1");
63
- const {
64
- nested,
65
- afterText
66
- } = placeBlocks([write], ["c1"]);
67
- expect(nested.size).toBe(0);
68
- expect(afterText.map(p => p.block.id)).toEqual(["w1"]);
69
- });
70
- it("falls back to afterText when its step row was never drawn", () => {
71
- const orphan = placed({
72
- id: "r2",
73
- kind: "keyValue",
74
- source: "live",
75
- pairs: []
76
- }, "gone");
77
- const {
78
- afterText
79
- } = placeBlocks([orphan], []);
80
- expect(afterText.map(p => p.block.id)).toEqual(["r2"]);
81
- });
82
- });
83
- describe("ask blocks", () => {
84
- it("come out in their own bucket, after the answer", () => {
85
- const confirm = placed({
86
- id: "a1",
87
- kind: "confirm",
88
- source: "model",
89
- change: "Wipe storage"
90
- }, "call-ui");
91
- const {
92
- ask,
93
- afterText,
94
- nested
95
- } = placeBlocks([confirm, grid("ui2")], ["c1"]);
96
- expect(ask.map(p => p.block.id)).toEqual(["a1"]);
97
- expect(afterText.map(p => p.block.id)).toEqual(["ui2"]);
98
- expect(nested.size).toBe(0);
99
- });
100
- });
101
-
102
- /**
103
- * The order the transcript draws these in, asserted here rather than left to
104
- * MessageList's JSX.
105
- *
106
- * Off a real device: "show me all the pokemon from our poke mart shop". The
107
- * agent navigated to /shop, paged through 28 menu items and built the grid —
108
- * and the grid rendered at the TOP of the bubble with five paragraphs of
109
- * narration beneath it, so the finished answer arrived before the sentence
110
- * introducing it. The bucket is named for its position so a future edit has
111
- * to contradict the name to put it back.
112
- */
113
- describe("the answer comes after the prose", () => {
114
- it("puts a model-authored card in the after-text bucket, never before it", () => {
115
- const placed = placeBlocks([grid()], ["c1"]);
116
- expect(placed.afterText.map(p => p.block.id)).toEqual(["ui1"]);
117
- // `nested` is the only bucket that draws ABOVE the text (inside the
118
- // activity card's step rows), and only read receipts belong there.
119
- expect(placed.nested.size).toBe(0);
120
- });
121
- });
122
- //# sourceMappingURL=blockPlacement.test.js.map
1
+ "use strict";import{describe,expect,it}from"vitest";import{placeBlocks}from"./blockPlacement";const placed=(e,t)=>({block:e,forToolCallId:t}),grid=(e="ui1")=>placed({id:e,kind:"imageGrid",source:"model",images:[{url:"https://cdn.example.com/25.png",alt:"Pikachu"}]},"call-ui");describe("model-authored blocks",()=>{it("renders in the answer, never nested under a step that has no row",()=>{const{afterText:e,nested:t}=placeBlocks([grid()],["c1"]);expect(e.map(e=>e.block.id)).toEqual(["ui1"]),expect(t.size).toBe(0)}),it("still renders even when a step with that id somehow exists",()=>{const{afterText:e}=placeBlocks([grid()],["call-ui"]);expect(e.map(e=>e.block.id)).toEqual(["ui1"])})}),describe("receipts",()=>{it("folds a read receipt into its own step row",()=>{const e=placed({id:"r1",kind:"keyValue",source:"live",pairs:[]},"c1"),{nested:t,afterText:c}=placeBlocks([e],["c1"]);expect(c).toEqual([]),expect(t.get("c1")?.map(e=>e.id)).toEqual(["r1"])}),it("keeps a write receipt afterText — the user must see it without asking",()=>{const e=placed({id:"w1",kind:"diff",source:"changed",changes:[]},"c1"),{nested:t,afterText:c}=placeBlocks([e],["c1"]);expect(t.size).toBe(0),expect(c.map(e=>e.block.id)).toEqual(["w1"])}),it("falls back to afterText when its step row was never drawn",()=>{const e=placed({id:"r2",kind:"keyValue",source:"live",pairs:[]},"gone"),{afterText:t}=placeBlocks([e],[]);expect(t.map(e=>e.block.id)).toEqual(["r2"])})}),describe("ask blocks",()=>{it("come out in their own bucket, after the answer",()=>{const e=placed({id:"a1",kind:"confirm",source:"model",change:"Wipe storage"},"call-ui"),{ask:t,afterText:c,nested:a}=placeBlocks([e,grid("ui2")],["c1"]);expect(t.map(e=>e.block.id)).toEqual(["a1"]),expect(c.map(e=>e.block.id)).toEqual(["ui2"]),expect(a.size).toBe(0)})}),describe("the answer comes after the prose",()=>{it("puts a model-authored card in the after-text bucket, never before it",()=>{const e=placeBlocks([grid()],["c1"]);expect(e.afterText.map(e=>e.block.id)).toEqual(["ui1"]),expect(e.nested.size).toBe(0)})});
@@ -1,149 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * The queue is a list, and it knows when to hold.
5
- *
6
- * Both rules were written from a defect: the single slot this replaced
7
- * OVERWROTE — type two things mid-turn and the first vanished — and its flush
8
- * ran on `!busy` alone, so a parked message fired into a dead connection after
9
- * an error and was sent as the answer to an open choice block.
10
- */
11
- import { beforeEach, describe, expect, it } from "vitest";
12
- import { askBuoyStore, queuePauseReason, turnPhaseOf } from "./askBuoyStore";
13
- beforeEach(() => askBuoyStore.reset());
14
- const texts = () => askBuoyStore.getState().queued.map(q => q.text);
15
- describe("queue", () => {
16
- it("keeps every message, in the order typed", () => {
17
- askBuoyStore.enqueue("then set points to 1500");
18
- askBuoyStore.enqueue("and clear the cart after");
19
- expect(texts()).toEqual(["then set points to 1500", "and clear the cart after"]);
20
- });
21
- it("gives identical requests distinct ids", () => {
22
- const a = askBuoyStore.enqueue("again");
23
- const b = askBuoyStore.enqueue("again");
24
- expect(a.id).not.toBe(b.id);
25
- askBuoyStore.removeQueued(a.id);
26
- expect(texts()).toEqual(["again"]);
27
- });
28
- it("delivers from the front, one at a time", () => {
29
- askBuoyStore.enqueue("one");
30
- askBuoyStore.enqueue("two");
31
- expect(askBuoyStore.shiftQueued()?.text).toBe("one");
32
- expect(texts()).toEqual(["two"]);
33
- expect(askBuoyStore.shiftQueued()?.text).toBe("two");
34
- expect(askBuoyStore.shiftQueued()).toBeUndefined();
35
- });
36
- it("comes back from disk as unsent rows", () => {
37
- const ok = askBuoyStore.hydrate({
38
- messages: [{
39
- id: "m1",
40
- role: "user",
41
- text: "hi",
42
- toolCalls: [],
43
- blocks: []
44
- }],
45
- answers: {},
46
- usage: {
47
- input: 0,
48
- output: 0,
49
- requests: 0
50
- },
51
- queued: [{
52
- id: "q1",
53
- text: "still waiting"
54
- }]
55
- });
56
- expect(ok).toBe(true);
57
- expect(texts()).toEqual(["still waiting"]);
58
- // Idle with nothing wrong — but hydrate itself never sends; the flush
59
- // effect in the hook does, and only once the user is looking.
60
- expect(turnPhaseOf(askBuoyStore.getState())).toBe("idle");
61
- });
62
- it("is emptied by a new conversation", () => {
63
- askBuoyStore.enqueue("gone");
64
- askBuoyStore.reset();
65
- expect(texts()).toEqual([]);
66
- });
67
- });
68
- describe("turnPhase", () => {
69
- it("is idle with nothing going on", () => {
70
- expect(turnPhaseOf(askBuoyStore.getState())).toBe("idle");
71
- });
72
- it("is running during a turn, and stopping once Stop is pressed", () => {
73
- askBuoyStore.addUser("go");
74
- askBuoyStore.startAssistant();
75
- expect(turnPhaseOf(askBuoyStore.getState())).toBe("running");
76
- askBuoyStore.requestStop();
77
- expect(turnPhaseOf(askBuoyStore.getState())).toBe("stopping");
78
- });
79
- it("is awaitingApproval while a card is up, even though the turn is busy", () => {
80
- askBuoyStore.addUser("wipe it");
81
- askBuoyStore.startAssistant();
82
- void askBuoyStore.askApproval({
83
- id: "c1",
84
- toolId: "storage",
85
- action: "clearAll",
86
- label: "Clear all saved app data",
87
- reason: "Wipes everything"
88
- });
89
- expect(turnPhaseOf(askBuoyStore.getState())).toBe("awaitingApproval");
90
- });
91
- it("is awaitingAnswer after a turn ends on an Ask block", () => {
92
- const id = askBuoyStore.startAssistant();
93
- askBuoyStore.applyEvent(id, {
94
- type: "awaiting-user",
95
- blockId: "b1"
96
- });
97
- askBuoyStore.finishAssistant(id);
98
- expect(turnPhaseOf(askBuoyStore.getState())).toBe("awaitingAnswer");
99
- });
100
- });
101
- describe("when the queue holds", () => {
102
- it("delivers when idle and the last turn was fine", () => {
103
- askBuoyStore.addUser("hi");
104
- const id = askBuoyStore.startAssistant();
105
- askBuoyStore.applyEvent(id, {
106
- type: "text",
107
- delta: "Hello."
108
- });
109
- askBuoyStore.finishAssistant(id);
110
- expect(queuePauseReason(askBuoyStore.getState())).toBeNull();
111
- });
112
- it("holds after an error, and says so", () => {
113
- askBuoyStore.addUser("hi");
114
- const id = askBuoyStore.startAssistant();
115
- askBuoyStore.applyEvent(id, {
116
- type: "error",
117
- message: "fetch failed"
118
- });
119
- askBuoyStore.finishAssistant(id);
120
- expect(queuePauseReason(askBuoyStore.getState())).toMatch(/failed/);
121
- });
122
- it("holds while an approval card is up", () => {
123
- askBuoyStore.addUser("wipe");
124
- askBuoyStore.startAssistant();
125
- void askBuoyStore.askApproval({
126
- id: "c1",
127
- toolId: "storage",
128
- action: "clearAll",
129
- label: "Clear all saved app data",
130
- reason: "Wipes everything"
131
- });
132
- expect(queuePauseReason(askBuoyStore.getState())).toMatch(/approval/);
133
- });
134
- it("holds while a question is unanswered — a queued task is not the answer", () => {
135
- const id = askBuoyStore.startAssistant();
136
- askBuoyStore.applyEvent(id, {
137
- type: "awaiting-user",
138
- blockId: "b1"
139
- });
140
- askBuoyStore.finishAssistant(id);
141
- expect(queuePauseReason(askBuoyStore.getState())).toMatch(/question/);
142
- });
143
- it("says nothing while a turn is still running — the queue is simply waiting", () => {
144
- askBuoyStore.addUser("go");
145
- askBuoyStore.startAssistant();
146
- expect(queuePauseReason(askBuoyStore.getState())).toBeNull();
147
- });
148
- });
149
- //# sourceMappingURL=queue.test.js.map
1
+ "use strict";import{beforeEach,describe,expect,it}from"vitest";import{askBuoyStore,queuePauseReason,turnPhaseOf}from"./askBuoyStore";beforeEach(()=>askBuoyStore.reset());const texts=()=>askBuoyStore.getState().queued.map(e=>e.text);describe("queue",()=>{it("keeps every message, in the order typed",()=>{askBuoyStore.enqueue("then set points to 1500"),askBuoyStore.enqueue("and clear the cart after"),expect(texts()).toEqual(["then set points to 1500","and clear the cart after"])}),it("gives identical requests distinct ids",()=>{const e=askBuoyStore.enqueue("again"),t=askBuoyStore.enqueue("again");expect(e.id).not.toBe(t.id),askBuoyStore.removeQueued(e.id),expect(texts()).toEqual(["again"])}),it("delivers from the front, one at a time",()=>{askBuoyStore.enqueue("one"),askBuoyStore.enqueue("two"),expect(askBuoyStore.shiftQueued()?.text).toBe("one"),expect(texts()).toEqual(["two"]),expect(askBuoyStore.shiftQueued()?.text).toBe("two"),expect(askBuoyStore.shiftQueued()).toBeUndefined()}),it("comes back from disk as unsent rows",()=>{const e=askBuoyStore.hydrate({messages:[{id:"m1",role:"user",text:"hi",toolCalls:[],blocks:[]}],answers:{},usage:{input:0,output:0,requests:0},queued:[{id:"q1",text:"still waiting"}]});expect(e).toBe(!0),expect(texts()).toEqual(["still waiting"]),expect(turnPhaseOf(askBuoyStore.getState())).toBe("idle")}),it("is emptied by a new conversation",()=>{askBuoyStore.enqueue("gone"),askBuoyStore.reset(),expect(texts()).toEqual([])})}),describe("turnPhase",()=>{it("is idle with nothing going on",()=>{expect(turnPhaseOf(askBuoyStore.getState())).toBe("idle")}),it("is running during a turn, and stopping once Stop is pressed",()=>{askBuoyStore.addUser("go"),askBuoyStore.startAssistant(),expect(turnPhaseOf(askBuoyStore.getState())).toBe("running"),askBuoyStore.requestStop(),expect(turnPhaseOf(askBuoyStore.getState())).toBe("stopping")}),it("is awaitingApproval while a card is up, even though the turn is busy",()=>{askBuoyStore.addUser("wipe it"),askBuoyStore.startAssistant(),askBuoyStore.askApproval({id:"c1",toolId:"storage",action:"clearAll",label:"Clear all saved app data",reason:"Wipes everything"}),expect(turnPhaseOf(askBuoyStore.getState())).toBe("awaitingApproval")}),it("is awaitingAnswer after a turn ends on an Ask block",()=>{const e=askBuoyStore.startAssistant();askBuoyStore.applyEvent(e,{type:"awaiting-user",blockId:"b1"}),askBuoyStore.finishAssistant(e),expect(turnPhaseOf(askBuoyStore.getState())).toBe("awaitingAnswer")})}),describe("when the queue holds",()=>{it("delivers when idle and the last turn was fine",()=>{askBuoyStore.addUser("hi");const e=askBuoyStore.startAssistant();askBuoyStore.applyEvent(e,{type:"text",delta:"Hello."}),askBuoyStore.finishAssistant(e),expect(queuePauseReason(askBuoyStore.getState())).toBeNull()}),it("holds after an error, and says so",()=>{askBuoyStore.addUser("hi");const e=askBuoyStore.startAssistant();askBuoyStore.applyEvent(e,{type:"error",message:"fetch failed"}),askBuoyStore.finishAssistant(e),expect(queuePauseReason(askBuoyStore.getState())).toMatch(/failed/)}),it("holds while an approval card is up",()=>{askBuoyStore.addUser("wipe"),askBuoyStore.startAssistant(),askBuoyStore.askApproval({id:"c1",toolId:"storage",action:"clearAll",label:"Clear all saved app data",reason:"Wipes everything"}),expect(queuePauseReason(askBuoyStore.getState())).toMatch(/approval/)}),it("holds while a question is unanswered — a queued task is not the answer",()=>{const e=askBuoyStore.startAssistant();askBuoyStore.applyEvent(e,{type:"awaiting-user",blockId:"b1"}),askBuoyStore.finishAssistant(e),expect(queuePauseReason(askBuoyStore.getState())).toMatch(/question/)}),it("says nothing while a turn is still running — the queue is simply waiting",()=>{askBuoyStore.addUser("go"),askBuoyStore.startAssistant(),expect(queuePauseReason(askBuoyStore.getState())).toBeNull()})});
@@ -1,72 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * "New conversation" — the ONE way a conversation is cleared.
5
- *
6
- * Clearing drops the effect ledger, which is the only undo surface, while the
7
- * agent's changes stay live in the app. So the path that clears has to be the
8
- * path that knows whether undo succeeded — and there used to be two paths
9
- * that did not: the sheet's "Undo, then clear" awaited `revertAll` and reset
10
- * without reading the outcome (two of five reverts fail, the conversation
11
- * clears anyway, two changes stay applied with no record), and the desktop's
12
- * `reset` action skipped the question entirely.
13
- *
14
- * Both now come through here. A failed revert does NOT clear: the caller gets
15
- * the list of what is still applied and clearing becomes a second, explicit
16
- * choice.
17
- */
18
-
19
- import { askBuoyStore } from "./askBuoyStore";
20
- import { clearTranscript } from "./transcriptPersistence";
21
- /** Clear everything, unconditionally. The caller has already decided. */
22
- export function clearConversation() {
23
- // All three, or the conversation this said it had cleared comes straight
24
- // back on the next reload with its undo bar intact.
25
- askBuoyStore.getHeldSession()?.session.reset();
26
- askBuoyStore.reset();
27
- void clearTranscript();
28
- }
29
-
30
- /**
31
- * Undo what can be undone, then clear — unless something would not go back.
32
- *
33
- * Refuses while a turn is running: the ledger is being written to, and a
34
- * revert racing a dispatch is how "changed since Ask Buoy wrote it" happens
35
- * to our own write.
36
- */
37
- export async function resetConversation(input) {
38
- if (askBuoyStore.getState().busy) {
39
- return {
40
- cleared: false,
41
- reverted: 0,
42
- failed: [{
43
- label: "A turn is running",
44
- error: "Stop it first."
45
- }]
46
- };
47
- }
48
- const ledger = askBuoyStore.getLedger();
49
- if (input.undoFirst && ledger) {
50
- const outcome = await ledger.revertAll(input.dispatch);
51
- if (outcome.failed.length > 0) {
52
- return {
53
- cleared: false,
54
- reverted: outcome.reverted,
55
- failed: outcome.failed
56
- };
57
- }
58
- clearConversation();
59
- return {
60
- cleared: true,
61
- reverted: outcome.reverted,
62
- failed: []
63
- };
64
- }
65
- clearConversation();
66
- return {
67
- cleared: true,
68
- reverted: 0,
69
- failed: []
70
- };
71
- }
72
- //# sourceMappingURL=resetConversation.js.map
1
+ "use strict";import{askBuoyStore}from"./askBuoyStore";import{clearTranscript}from"./transcriptPersistence";export function clearConversation(){askBuoyStore.getHeldSession()?.session.reset(),askBuoyStore.reset(),clearTranscript()}export async function resetConversation(e){if(askBuoyStore.getState().busy)return{cleared:!1,reverted:0,failed:[{label:"A turn is running",error:"Stop it first."}]};const r=askBuoyStore.getLedger();if(e.undoFirst&&r){const t=await r.revertAll(e.dispatch);return t.failed.length>0?{cleared:!1,reverted:t.reverted,failed:t.failed}:(clearConversation(),{cleared:!0,reverted:t.reverted,failed:[]})}return clearConversation(),{cleared:!0,reverted:0,failed:[]}}
@@ -1,62 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * Putting an unanswered approval back after a restart.
5
- *
6
- * The rule this encodes: a question the user never answered is not the app's
7
- * to drop. Nothing was tapped, so the change is still waiting as far as they
8
- * know — and a card that vanishes on reload reads as consent nobody gave.
9
- *
10
- * The guards matter as much as the restore. The disk read races the tool
11
- * registry (see the note at the restore site), so it can land late, and an old
12
- * question shoved in front of a live conversation would be worse than losing
13
- * it.
14
- */
15
- import { beforeEach, describe, expect, it } from "vitest";
16
- import { askBuoyStore } from "./askBuoyStore";
17
- const card = {
18
- id: "c1",
19
- toolId: "zustand",
20
- action: "setState",
21
- label: "Update the Poké Mart bag store",
22
- reason: "This will change the app's state.",
23
- params: {
24
- storeName: "bag"
25
- }
26
- };
27
- beforeEach(() => askBuoyStore.reset());
28
- describe("restorePending", () => {
29
- it("puts the card back on screen", () => {
30
- expect(askBuoyStore.restorePending(card)).toBe(true);
31
- expect(askBuoyStore.getState().pending).toMatchObject({
32
- toolId: "zustand",
33
- action: "setState",
34
- params: {
35
- storeName: "bag"
36
- }
37
- });
38
- });
39
- it("marks it restored, so Allow runs the call instead of answering a dead promise", () => {
40
- askBuoyStore.restorePending(card);
41
- expect(askBuoyStore.getState().pending?.restored).toBe(true);
42
- });
43
- it("refuses once a turn is under way", () => {
44
- askBuoyStore.beginTurn();
45
- expect(askBuoyStore.restorePending(card)).toBe(false);
46
- expect(askBuoyStore.getState().pending).toBeNull();
47
- });
48
- it("refuses when a live card is already asking", () => {
49
- void askBuoyStore.askApproval(card);
50
- expect(askBuoyStore.restorePending({
51
- ...card,
52
- id: "c2"
53
- })).toBe(false);
54
- expect(askBuoyStore.getState().pending?.id).toBe("c1");
55
- });
56
- it("answers without throwing, though nothing is waiting on it", () => {
57
- askBuoyStore.restorePending(card);
58
- expect(() => askBuoyStore.answerApproval(true)).not.toThrow();
59
- expect(askBuoyStore.getState().pending).toBeNull();
60
- });
61
- });
62
- //# sourceMappingURL=restorePending.test.js.map
1
+ "use strict";import{beforeEach,describe,expect,it}from"vitest";import{askBuoyStore}from"./askBuoyStore";const card={id:"c1",toolId:"zustand",action:"setState",label:"Update the Poké Mart bag store",reason:"This will change the app's state.",params:{storeName:"bag"}};beforeEach(()=>askBuoyStore.reset()),describe("restorePending",()=>{it("puts the card back on screen",()=>{expect(askBuoyStore.restorePending(card)).toBe(!0),expect(askBuoyStore.getState().pending).toMatchObject({toolId:"zustand",action:"setState",params:{storeName:"bag"}})}),it("marks it restored, so Allow runs the call instead of answering a dead promise",()=>{askBuoyStore.restorePending(card),expect(askBuoyStore.getState().pending?.restored).toBe(!0)}),it("refuses once a turn is under way",()=>{askBuoyStore.beginTurn(),expect(askBuoyStore.restorePending(card)).toBe(!1),expect(askBuoyStore.getState().pending).toBeNull()}),it("refuses when a live card is already asking",()=>{askBuoyStore.askApproval(card),expect(askBuoyStore.restorePending({...card,id:"c2"})).toBe(!1),expect(askBuoyStore.getState().pending?.id).toBe("c1")}),it("answers without throwing, though nothing is waiting on it",()=>{askBuoyStore.restorePending(card),expect(()=>askBuoyStore.answerApproval(!0)).not.toThrow(),expect(askBuoyStore.getState().pending).toBeNull()})});
@@ -1,46 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * Ids from a RESTORED transcript must never collide with a fresh run's.
5
- *
6
- * The bug this covers, in full: every id counter restarted at 1 with the
7
- * process, which was harmless until the transcript started outliving a reload.
8
- * A restored conversation came back holding `rc1`, `ui1` and `m1`; the next
9
- * turn minted `rc1` again; React saw two children with one key and rendered
10
- * one of them twice while dropping the other. On screen that was the same
11
- * store card appearing twice after a reload.
12
- *
13
- * Simulating a restart in one process is the whole difficulty — the module
14
- * caches its counter. `idFactory` is the seam: a second factory stands in for
15
- * the second run, and the shared RUN_ID is what has to differ between them.
16
- */
17
- import { describe, expect, it } from "vitest";
18
- import { idFactory, RUN_ID } from "@buoy-gg/agent-core";
19
- describe("ids across a restart", () => {
20
- it("never reissues an id a restored transcript already holds", () => {
21
- // What a saved transcript carries, from a previous launch.
22
- const restored = ["rcOLDRUN-1", "rcOLDRUN-2", "uiOLDRUN-1", "mOLDRUN-1"];
23
- const rc = idFactory("rc");
24
- const ui = idFactory("ui");
25
- const m = idFactory("m");
26
- const fresh = [rc(), rc(), ui(), m()];
27
- for (const id of fresh) expect(restored).not.toContain(id);
28
- });
29
- it("still counts up within one run", () => {
30
- // The counter is what keeps two blocks in the SAME turn apart.
31
- const rc = idFactory("rc");
32
- const ids = [rc(), rc(), rc()];
33
- expect(new Set(ids).size).toBe(3);
34
- });
35
- it("keeps two prefixes apart even at the same count", () => {
36
- const rc = idFactory("rc");
37
- const ui = idFactory("ui");
38
- expect(rc()).not.toBe(ui());
39
- });
40
- it("stamps a run token that is not a fixed string", () => {
41
- // A constant here would put every install back where it started.
42
- expect(RUN_ID).toMatch(/^[a-z0-9]{4,8}$/);
43
- expect(idFactory("rc")()).toBe(`rc${RUN_ID}-1`);
44
- });
45
- });
46
- //# sourceMappingURL=restoredIds.test.js.map
1
+ "use strict";import{describe,expect,it}from"vitest";import{idFactory,RUN_ID}from"@buoy-gg/agent-core";describe("ids across a restart",()=>{it("never reissues an id a restored transcript already holds",()=>{const t=["rcOLDRUN-1","rcOLDRUN-2","uiOLDRUN-1","mOLDRUN-1"],e=idFactory("rc"),r=idFactory("ui"),o=idFactory("m"),i=[e(),e(),r(),o()];for(const e of i)expect(t).not.toContain(e)}),it("still counts up within one run",()=>{const t=idFactory("rc"),e=[t(),t(),t()];expect(new Set(e).size).toBe(3)}),it("keeps two prefixes apart even at the same count",()=>{const t=idFactory("rc"),e=idFactory("ui");expect(t()).not.toBe(e())}),it("stamps a run token that is not a fixed string",()=>{expect(RUN_ID).toMatch(/^[a-z0-9]{4,8}$/),expect(idFactory("rc")()).toBe(`rc${RUN_ID}-1`)})});
@@ -1,49 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * The empty state's "try asking" chips, filtered to what will actually work.
5
- *
6
- * The list was static, so a release build offered "Make the next request fail
7
- * with a 500" directly above a line saying simulations need a dev build — and
8
- * the agent then refused the very thing the screen had just suggested. First
9
- * impression: broken. Each chip now says what it needs; the empty state keeps
10
- * the ones this device, build and policy can honour.
11
- *
12
- * Deterministic on purpose: no model call, no navigation, no guessed route
13
- * names or account ids. When the tool registry has not reported yet (it fills
14
- * in a frame or two after open) only the chips that need nothing are shown —
15
- * a short list that grows beats a long one that shrinks.
16
- */
17
-
18
- export const SUGGESTIONS = [{
19
- text: "Why is this screen empty?"
20
- }, {
21
- text: "What did the last few network calls return?",
22
- needs: "network"
23
- }, {
24
- text: "Show me what's saved for this user",
25
- needs: "storage"
26
- }, {
27
- text: "Make the next request to this screen fail with a 500",
28
- needs: "network",
29
- write: true,
30
- devOnly: true
31
- }, {
32
- text: "Who am I signed in as right now?"
33
- }, {
34
- text: "Did anything crash or log an error recently?",
35
- needs: "console"
36
- }];
37
-
38
- /** At most this many chips — the rest of the screen is the point. */
39
- export const MAX_SUGGESTIONS = 4;
40
- export function pickSuggestions(input) {
41
- const known = input.availableToolIds.length > 0;
42
- return SUGGESTIONS.filter(s => {
43
- if (s.write && input.readOnly) return false;
44
- if (s.devOnly && input.isRelease) return false;
45
- if (s.needs) return known && input.availableToolIds.includes(s.needs);
46
- return true;
47
- }).slice(0, MAX_SUGGESTIONS).map(s => s.text);
48
- }
49
- //# sourceMappingURL=suggestions.js.map
1
+ "use strict";export const SUGGESTIONS=[{text:"Why is this screen empty?"},{text:"What did the last few network calls return?",needs:"network"},{text:"Show me what's saved for this user",needs:"storage"},{text:"Make the next request to this screen fail with a 500",needs:"network",write:!0,devOnly:!0},{text:"Who am I signed in as right now?"},{text:"Did anything crash or log an error recently?",needs:"console"}];export const MAX_SUGGESTIONS=4;export function pickSuggestions(e){const t=e.availableToolIds.length>0;return SUGGESTIONS.filter(s=>(!s.write||!e.readOnly)&&(!s.devOnly||!e.isRelease)&&(!s.needs||t&&e.availableToolIds.includes(s.needs))).slice(0,4).map(e=>e.text)}
@@ -1,57 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * Chips promise things; only promise what this device can keep.
5
- */
6
- import { describe, expect, it } from "vitest";
7
- import { MAX_SUGGESTIONS, pickSuggestions } from "./suggestions";
8
- const all = ["network", "storage", "console", "query"];
9
- describe("pickSuggestions", () => {
10
- it("offers the simulation only on a dev build that may write", () => {
11
- const dev = pickSuggestions({
12
- availableToolIds: all,
13
- readOnly: false,
14
- isRelease: false
15
- });
16
- expect(dev).toContain("Make the next request to this screen fail with a 500");
17
- const release = pickSuggestions({
18
- availableToolIds: all,
19
- readOnly: false,
20
- isRelease: true
21
- });
22
- expect(release).not.toContain("Make the next request to this screen fail with a 500");
23
- const readOnly = pickSuggestions({
24
- availableToolIds: all,
25
- readOnly: true,
26
- isRelease: false
27
- });
28
- expect(readOnly).not.toContain("Make the next request to this screen fail with a 500");
29
- });
30
- it("drops chips whose tool is not on this device", () => {
31
- const noNetwork = pickSuggestions({
32
- availableToolIds: ["storage"],
33
- readOnly: false,
34
- isRelease: false
35
- });
36
- expect(noNetwork).not.toContain("What did the last few network calls return?");
37
- expect(noNetwork).toContain("Show me what's saved for this user");
38
- });
39
- it("shows only tool-free chips until the registry has reported", () => {
40
- const early = pickSuggestions({
41
- availableToolIds: [],
42
- readOnly: false,
43
- isRelease: false
44
- });
45
- expect(early).toEqual(["Why is this screen empty?", "Who am I signed in as right now?"]);
46
- });
47
- it("never exceeds the cap and keeps the order", () => {
48
- const out = pickSuggestions({
49
- availableToolIds: all,
50
- readOnly: false,
51
- isRelease: false
52
- });
53
- expect(out.length).toBeLessThanOrEqual(MAX_SUGGESTIONS);
54
- expect(out[0]).toBe("Why is this screen empty?");
55
- });
56
- });
57
- //# sourceMappingURL=suggestions.test.js.map
1
+ "use strict";import{describe,expect,it}from"vitest";import{MAX_SUGGESTIONS,pickSuggestions}from"./suggestions";const all=["network","storage","console","query"];describe("pickSuggestions",()=>{it("offers the simulation only on a dev build that may write",()=>{const e=pickSuggestions({availableToolIds:all,readOnly:!1,isRelease:!1});expect(e).toContain("Make the next request to this screen fail with a 500");const t=pickSuggestions({availableToolIds:all,readOnly:!1,isRelease:!0});expect(t).not.toContain("Make the next request to this screen fail with a 500");const s=pickSuggestions({availableToolIds:all,readOnly:!0,isRelease:!1});expect(s).not.toContain("Make the next request to this screen fail with a 500")}),it("drops chips whose tool is not on this device",()=>{const e=pickSuggestions({availableToolIds:["storage"],readOnly:!1,isRelease:!1});expect(e).not.toContain("What did the last few network calls return?"),expect(e).toContain("Show me what's saved for this user")}),it("shows only tool-free chips until the registry has reported",()=>{const e=pickSuggestions({availableToolIds:[],readOnly:!1,isRelease:!1});expect(e).toEqual(["Why is this screen empty?","Who am I signed in as right now?"])}),it("never exceeds the cap and keeps the order",()=>{const e=pickSuggestions({availableToolIds:all,readOnly:!1,isRelease:!1});expect(e.length).toBeLessThanOrEqual(MAX_SUGGESTIONS),expect(e[0]).toBe("Why is this screen empty?")})});
@@ -1,76 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * Buoy's own lines in the transcript — today, the memory-trim notice.
5
- */
6
- import { beforeEach, describe, expect, it } from "vitest";
7
- import { askBuoyStore } from "./askBuoyStore";
8
- import { buildPayload, parsePayload } from "./transcriptPersistence";
9
- beforeEach(() => askBuoyStore.reset());
10
- describe("history-trimmed", () => {
11
- it("inserts a system line before the answer it affects", () => {
12
- askBuoyStore.addUser("turn off that override");
13
- const id = askBuoyStore.startAssistant();
14
- askBuoyStore.applyEvent(id, {
15
- type: "history-trimmed",
16
- droppedRounds: 3
17
- });
18
- askBuoyStore.applyEvent(id, {
19
- type: "text",
20
- delta: "Turning it off."
21
- });
22
- const roles = askBuoyStore.getState().messages.map(m => m.system ? "system" : m.role);
23
- expect(roles).toEqual(["user", "system", "assistant"]);
24
- const line = askBuoyStore.getState().messages[1];
25
- expect(line.text).toMatch(/3 exchanges/);
26
- expect(line.text).toMatch(/changes bar still lists/);
27
- });
28
- it("singular for one round", () => {
29
- const id = askBuoyStore.startAssistant();
30
- askBuoyStore.applyEvent(id, {
31
- type: "history-trimmed",
32
- droppedRounds: 1
33
- });
34
- expect(askBuoyStore.getState().messages[0].text).toMatch(/1 exchange\)/);
35
- });
36
- });
37
- describe("restored approval freshness", () => {
38
- it("carries the target digest to disk and back, never the target", () => {
39
- const payload = buildPayload({
40
- messages: [{
41
- id: "m1",
42
- role: "user",
43
- text: "set it",
44
- toolCalls: [],
45
- blocks: []
46
- }],
47
- history: [],
48
- answers: {},
49
- usage: {
50
- input: 0,
51
- output: 0,
52
- requests: 0
53
- },
54
- pending: {
55
- id: "c1",
56
- toolId: "zustand",
57
- action: "setState",
58
- label: "Update the bag store",
59
- reason: "Replaces part of the store",
60
- params: {
61
- storeName: "bag",
62
- state: {
63
- qty: 14
64
- }
65
- },
66
- targetDigest: "1a2b3c:512",
67
- resolve: () => {}
68
- }
69
- });
70
- const json = JSON.stringify(payload);
71
- expect(json).toContain("1a2b3c:512");
72
- const back = parsePayload(json);
73
- expect(back?.pending?.targetDigest).toBe("1a2b3c:512");
74
- });
75
- });
76
- //# sourceMappingURL=systemLine.test.js.map
1
+ "use strict";import{beforeEach,describe,expect,it}from"vitest";import{askBuoyStore}from"./askBuoyStore";import{buildPayload,parsePayload}from"./transcriptPersistence";beforeEach(()=>askBuoyStore.reset()),describe("history-trimmed",()=>{it("inserts a system line before the answer it affects",()=>{askBuoyStore.addUser("turn off that override");const t=askBuoyStore.startAssistant();askBuoyStore.applyEvent(t,{type:"history-trimmed",droppedRounds:3}),askBuoyStore.applyEvent(t,{type:"text",delta:"Turning it off."});const e=askBuoyStore.getState().messages.map(t=>t.system?"system":t.role);expect(e).toEqual(["user","system","assistant"]);const s=askBuoyStore.getState().messages[1];expect(s.text).toMatch(/3 exchanges/),expect(s.text).toMatch(/changes bar still lists/)}),it("singular for one round",()=>{const t=askBuoyStore.startAssistant();askBuoyStore.applyEvent(t,{type:"history-trimmed",droppedRounds:1}),expect(askBuoyStore.getState().messages[0].text).toMatch(/1 exchange\)/)})}),describe("restored approval freshness",()=>{it("carries the target digest to disk and back, never the target",()=>{const t=buildPayload({messages:[{id:"m1",role:"user",text:"set it",toolCalls:[],blocks:[]}],history:[],answers:{},usage:{input:0,output:0,requests:0},pending:{id:"c1",toolId:"zustand",action:"setState",label:"Update the bag store",reason:"Replaces part of the store",params:{storeName:"bag",state:{qty:14}},targetDigest:"1a2b3c:512",resolve:()=>{}}}),e=JSON.stringify(t);expect(e).toContain("1a2b3c:512");const s=parsePayload(e);expect(s?.pending?.targetDigest).toBe("1a2b3c:512")})});