@buoy-gg/ask-buoy 7.0.41 → 7.0.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (313) hide show
  1. package/README.md +13 -98
  2. package/lib/commonjs/blocks/AskBlocks.js +1 -338
  3. package/lib/commonjs/blocks/BlockRenderer.js +1 -262
  4. package/lib/commonjs/blocks/ChromePrototypes.js +1 -514
  5. package/lib/commonjs/blocks/DataBlocks.js +1 -783
  6. package/lib/commonjs/blocks/ExtraBlocks.js +1 -1862
  7. package/lib/commonjs/blocks/MediaBlocks.js +1 -158
  8. package/lib/commonjs/blocks/ReceiptBlocks.js +2 -592
  9. package/lib/commonjs/blocks/blockText.js +1 -60
  10. package/lib/commonjs/blocks/blockText.test.js +1 -53
  11. package/lib/commonjs/blocks/context.js +1 -42
  12. package/lib/commonjs/blocks/icons.js +1 -96
  13. package/lib/commonjs/blocks/index.js +1 -95
  14. package/lib/commonjs/blocks/listRow.test.js +1 -55
  15. package/lib/commonjs/blocks/pageState.js +1 -34
  16. package/lib/commonjs/blocks/pageState.test.js +1 -57
  17. package/lib/commonjs/blocks/primitives.js +1 -457
  18. package/lib/commonjs/blocks/primitivesIndex.js +1 -62
  19. package/lib/commonjs/blocks/ruleStates.js +1 -39
  20. package/lib/commonjs/components/ApprovalCard.js +1 -297
  21. package/lib/commonjs/components/AskBuoyHeader.js +1 -196
  22. package/lib/commonjs/components/AskBuoyIcon.js +1 -19
  23. package/lib/commonjs/components/AskBuoyModal.js +2 -482
  24. package/lib/commonjs/components/AskBuoySettings.js +1 -181
  25. package/lib/commonjs/components/ChangesBar.js +1 -212
  26. package/lib/commonjs/components/Composer.js +1 -255
  27. package/lib/commonjs/components/EmptyState.js +1 -161
  28. package/lib/commonjs/components/KeyboardPad.js +1 -80
  29. package/lib/commonjs/components/Markdown.js +1 -310
  30. package/lib/commonjs/components/MessageList.js +1 -970
  31. package/lib/commonjs/components/QueuedMessages.js +1 -145
  32. package/lib/commonjs/components/ThinkingStrip.js +1 -223
  33. package/lib/commonjs/components/TypingDots.js +1 -63
  34. package/lib/commonjs/components/markdownParse.js +1 -131
  35. package/lib/commonjs/components/markdownParse.test.js +1 -99
  36. package/lib/commonjs/components/useCopyAction.js +1 -50
  37. package/lib/commonjs/index.js +1 -252
  38. package/lib/commonjs/preset.js +1 -91
  39. package/lib/commonjs/store/activityGroups.js +1 -110
  40. package/lib/commonjs/store/activityGroups.test.js +1 -78
  41. package/lib/commonjs/store/askBuoySettings.js +1 -72
  42. package/lib/commonjs/store/askBuoyStore.js +2 -588
  43. package/lib/commonjs/store/blockPlacement.js +1 -64
  44. package/lib/commonjs/store/blockPlacement.test.js +1 -123
  45. package/lib/commonjs/store/queue.test.js +1 -150
  46. package/lib/commonjs/store/resetConversation.js +1 -77
  47. package/lib/commonjs/store/restorePending.test.js +1 -63
  48. package/lib/commonjs/store/restoredIds.test.js +1 -47
  49. package/lib/commonjs/store/suggestions.js +1 -54
  50. package/lib/commonjs/store/suggestions.test.js +1 -58
  51. package/lib/commonjs/store/systemLine.test.js +1 -77
  52. package/lib/commonjs/store/ticketPrompt.js +1 -17
  53. package/lib/commonjs/store/traceText.js +1 -81
  54. package/lib/commonjs/store/traceText.test.js +1 -112
  55. package/lib/commonjs/store/transcriptPersistence.js +1 -297
  56. package/lib/commonjs/store/transcriptPersistence.test.js +1 -333
  57. package/lib/commonjs/store/turnRendering.test.js +1 -151
  58. package/lib/commonjs/store/useAskBuoy.js +1 -651
  59. package/lib/commonjs/store/useAskBuoySettings.js +1 -14
  60. package/lib/commonjs/sync/askBuoySyncAdapter.js +1 -153
  61. package/lib/commonjs/sync/askBuoySyncAdapter.test.js +1 -141
  62. package/lib/commonjs/sync/wire.js +1 -58
  63. package/lib/commonjs/types.js +1 -6
  64. package/lib/module/blocks/AskBlocks.js +1 -331
  65. package/lib/module/blocks/BlockRenderer.js +1 -257
  66. package/lib/module/blocks/ChromePrototypes.js +1 -503
  67. package/lib/module/blocks/DataBlocks.js +1 -769
  68. package/lib/module/blocks/ExtraBlocks.js +1 -1835
  69. package/lib/module/blocks/MediaBlocks.js +1 -153
  70. package/lib/module/blocks/ReceiptBlocks.js +2 -580
  71. package/lib/module/blocks/blockText.js +1 -55
  72. package/lib/module/blocks/blockText.test.js +1 -53
  73. package/lib/module/blocks/context.js +1 -35
  74. package/lib/module/blocks/icons.js +1 -91
  75. package/lib/module/blocks/index.js +1 -8
  76. package/lib/module/blocks/listRow.test.js +1 -56
  77. package/lib/module/blocks/pageState.js +1 -30
  78. package/lib/module/blocks/pageState.test.js +1 -56
  79. package/lib/module/blocks/primitives.js +1 -445
  80. package/lib/module/blocks/primitivesIndex.js +1 -5
  81. package/lib/module/blocks/ruleStates.js +1 -35
  82. package/lib/module/components/ApprovalCard.js +1 -292
  83. package/lib/module/components/AskBuoyHeader.js +1 -193
  84. package/lib/module/components/AskBuoyIcon.js +1 -8
  85. package/lib/module/components/AskBuoyModal.js +2 -477
  86. package/lib/module/components/AskBuoySettings.js +1 -176
  87. package/lib/module/components/ChangesBar.js +1 -206
  88. package/lib/module/components/Composer.js +1 -250
  89. package/lib/module/components/EmptyState.js +1 -156
  90. package/lib/module/components/KeyboardPad.js +1 -75
  91. package/lib/module/components/Markdown.js +1 -305
  92. package/lib/module/components/MessageList.js +1 -964
  93. package/lib/module/components/QueuedMessages.js +1 -140
  94. package/lib/module/components/ThinkingStrip.js +1 -218
  95. package/lib/module/components/TypingDots.js +1 -58
  96. package/lib/module/components/markdownParse.js +1 -125
  97. package/lib/module/components/markdownParse.test.js +1 -98
  98. package/lib/module/components/useCopyAction.js +1 -46
  99. package/lib/module/index.js +1 -34
  100. package/lib/module/preset.js +1 -74
  101. package/lib/module/store/activityGroups.js +1 -103
  102. package/lib/module/store/activityGroups.test.js +1 -77
  103. package/lib/module/store/askBuoySettings.js +1 -67
  104. package/lib/module/store/askBuoyStore.js +2 -582
  105. package/lib/module/store/blockPlacement.js +1 -59
  106. package/lib/module/store/blockPlacement.test.js +1 -122
  107. package/lib/module/store/queue.test.js +1 -149
  108. package/lib/module/store/resetConversation.js +1 -72
  109. package/lib/module/store/restorePending.test.js +1 -62
  110. package/lib/module/store/restoredIds.test.js +1 -46
  111. package/lib/module/store/suggestions.js +1 -49
  112. package/lib/module/store/suggestions.test.js +1 -57
  113. package/lib/module/store/systemLine.test.js +1 -76
  114. package/lib/module/store/ticketPrompt.js +1 -13
  115. package/lib/module/store/traceText.js +1 -75
  116. package/lib/module/store/traceText.test.js +1 -111
  117. package/lib/module/store/transcriptPersistence.js +1 -287
  118. package/lib/module/store/transcriptPersistence.test.js +1 -332
  119. package/lib/module/store/turnRendering.test.js +1 -150
  120. package/lib/module/store/useAskBuoy.js +1 -646
  121. package/lib/module/store/useAskBuoySettings.js +1 -9
  122. package/lib/module/sync/askBuoySyncAdapter.js +1 -148
  123. package/lib/module/sync/askBuoySyncAdapter.test.js +1 -140
  124. package/lib/module/sync/wire.js +1 -47
  125. package/lib/module/types.js +1 -4
  126. package/lib/web/index.mjs +11 -12
  127. package/package.json +8 -8
  128. package/lib/commonjs/blocks/AskBlocks.js.map +0 -1
  129. package/lib/commonjs/blocks/BlockRenderer.js.map +0 -1
  130. package/lib/commonjs/blocks/ChromePrototypes.js.map +0 -1
  131. package/lib/commonjs/blocks/DataBlocks.js.map +0 -1
  132. package/lib/commonjs/blocks/ExtraBlocks.js.map +0 -1
  133. package/lib/commonjs/blocks/MediaBlocks.js.map +0 -1
  134. package/lib/commonjs/blocks/ReceiptBlocks.js.map +0 -1
  135. package/lib/commonjs/blocks/blockText.js.map +0 -1
  136. package/lib/commonjs/blocks/blockText.test.js.map +0 -1
  137. package/lib/commonjs/blocks/context.js.map +0 -1
  138. package/lib/commonjs/blocks/icons.js.map +0 -1
  139. package/lib/commonjs/blocks/index.js.map +0 -1
  140. package/lib/commonjs/blocks/listRow.test.js.map +0 -1
  141. package/lib/commonjs/blocks/pageState.js.map +0 -1
  142. package/lib/commonjs/blocks/pageState.test.js.map +0 -1
  143. package/lib/commonjs/blocks/primitives.js.map +0 -1
  144. package/lib/commonjs/blocks/primitivesIndex.js.map +0 -1
  145. package/lib/commonjs/blocks/ruleStates.js.map +0 -1
  146. package/lib/commonjs/components/ApprovalCard.js.map +0 -1
  147. package/lib/commonjs/components/AskBuoyHeader.js.map +0 -1
  148. package/lib/commonjs/components/AskBuoyIcon.js.map +0 -1
  149. package/lib/commonjs/components/AskBuoyModal.js.map +0 -1
  150. package/lib/commonjs/components/AskBuoySettings.js.map +0 -1
  151. package/lib/commonjs/components/ChangesBar.js.map +0 -1
  152. package/lib/commonjs/components/Composer.js.map +0 -1
  153. package/lib/commonjs/components/EmptyState.js.map +0 -1
  154. package/lib/commonjs/components/KeyboardPad.js.map +0 -1
  155. package/lib/commonjs/components/Markdown.js.map +0 -1
  156. package/lib/commonjs/components/MessageList.js.map +0 -1
  157. package/lib/commonjs/components/QueuedMessages.js.map +0 -1
  158. package/lib/commonjs/components/ThinkingStrip.js.map +0 -1
  159. package/lib/commonjs/components/TypingDots.js.map +0 -1
  160. package/lib/commonjs/components/markdownParse.js.map +0 -1
  161. package/lib/commonjs/components/markdownParse.test.js.map +0 -1
  162. package/lib/commonjs/components/useCopyAction.js.map +0 -1
  163. package/lib/commonjs/index.js.map +0 -1
  164. package/lib/commonjs/preset.js.map +0 -1
  165. package/lib/commonjs/store/activityGroups.js.map +0 -1
  166. package/lib/commonjs/store/activityGroups.test.js.map +0 -1
  167. package/lib/commonjs/store/askBuoySettings.js.map +0 -1
  168. package/lib/commonjs/store/askBuoyStore.js.map +0 -1
  169. package/lib/commonjs/store/blockPlacement.js.map +0 -1
  170. package/lib/commonjs/store/blockPlacement.test.js.map +0 -1
  171. package/lib/commonjs/store/queue.test.js.map +0 -1
  172. package/lib/commonjs/store/resetConversation.js.map +0 -1
  173. package/lib/commonjs/store/restorePending.test.js.map +0 -1
  174. package/lib/commonjs/store/restoredIds.test.js.map +0 -1
  175. package/lib/commonjs/store/suggestions.js.map +0 -1
  176. package/lib/commonjs/store/suggestions.test.js.map +0 -1
  177. package/lib/commonjs/store/systemLine.test.js.map +0 -1
  178. package/lib/commonjs/store/ticketPrompt.js.map +0 -1
  179. package/lib/commonjs/store/traceText.js.map +0 -1
  180. package/lib/commonjs/store/traceText.test.js.map +0 -1
  181. package/lib/commonjs/store/transcriptPersistence.js.map +0 -1
  182. package/lib/commonjs/store/transcriptPersistence.test.js.map +0 -1
  183. package/lib/commonjs/store/turnRendering.test.js.map +0 -1
  184. package/lib/commonjs/store/useAskBuoy.js.map +0 -1
  185. package/lib/commonjs/store/useAskBuoySettings.js.map +0 -1
  186. package/lib/commonjs/sync/askBuoySyncAdapter.js.map +0 -1
  187. package/lib/commonjs/sync/askBuoySyncAdapter.test.js.map +0 -1
  188. package/lib/commonjs/sync/wire.js.map +0 -1
  189. package/lib/commonjs/types.js.map +0 -1
  190. package/lib/module/blocks/AskBlocks.js.map +0 -1
  191. package/lib/module/blocks/BlockRenderer.js.map +0 -1
  192. package/lib/module/blocks/ChromePrototypes.js.map +0 -1
  193. package/lib/module/blocks/DataBlocks.js.map +0 -1
  194. package/lib/module/blocks/ExtraBlocks.js.map +0 -1
  195. package/lib/module/blocks/MediaBlocks.js.map +0 -1
  196. package/lib/module/blocks/ReceiptBlocks.js.map +0 -1
  197. package/lib/module/blocks/blockText.js.map +0 -1
  198. package/lib/module/blocks/blockText.test.js.map +0 -1
  199. package/lib/module/blocks/context.js.map +0 -1
  200. package/lib/module/blocks/icons.js.map +0 -1
  201. package/lib/module/blocks/index.js.map +0 -1
  202. package/lib/module/blocks/listRow.test.js.map +0 -1
  203. package/lib/module/blocks/pageState.js.map +0 -1
  204. package/lib/module/blocks/pageState.test.js.map +0 -1
  205. package/lib/module/blocks/primitives.js.map +0 -1
  206. package/lib/module/blocks/primitivesIndex.js.map +0 -1
  207. package/lib/module/blocks/ruleStates.js.map +0 -1
  208. package/lib/module/components/ApprovalCard.js.map +0 -1
  209. package/lib/module/components/AskBuoyHeader.js.map +0 -1
  210. package/lib/module/components/AskBuoyIcon.js.map +0 -1
  211. package/lib/module/components/AskBuoyModal.js.map +0 -1
  212. package/lib/module/components/AskBuoySettings.js.map +0 -1
  213. package/lib/module/components/ChangesBar.js.map +0 -1
  214. package/lib/module/components/Composer.js.map +0 -1
  215. package/lib/module/components/EmptyState.js.map +0 -1
  216. package/lib/module/components/KeyboardPad.js.map +0 -1
  217. package/lib/module/components/Markdown.js.map +0 -1
  218. package/lib/module/components/MessageList.js.map +0 -1
  219. package/lib/module/components/QueuedMessages.js.map +0 -1
  220. package/lib/module/components/ThinkingStrip.js.map +0 -1
  221. package/lib/module/components/TypingDots.js.map +0 -1
  222. package/lib/module/components/markdownParse.js.map +0 -1
  223. package/lib/module/components/markdownParse.test.js.map +0 -1
  224. package/lib/module/components/useCopyAction.js.map +0 -1
  225. package/lib/module/index.js.map +0 -1
  226. package/lib/module/preset.js.map +0 -1
  227. package/lib/module/store/activityGroups.js.map +0 -1
  228. package/lib/module/store/activityGroups.test.js.map +0 -1
  229. package/lib/module/store/askBuoySettings.js.map +0 -1
  230. package/lib/module/store/askBuoyStore.js.map +0 -1
  231. package/lib/module/store/blockPlacement.js.map +0 -1
  232. package/lib/module/store/blockPlacement.test.js.map +0 -1
  233. package/lib/module/store/queue.test.js.map +0 -1
  234. package/lib/module/store/resetConversation.js.map +0 -1
  235. package/lib/module/store/restorePending.test.js.map +0 -1
  236. package/lib/module/store/restoredIds.test.js.map +0 -1
  237. package/lib/module/store/suggestions.js.map +0 -1
  238. package/lib/module/store/suggestions.test.js.map +0 -1
  239. package/lib/module/store/systemLine.test.js.map +0 -1
  240. package/lib/module/store/ticketPrompt.js.map +0 -1
  241. package/lib/module/store/traceText.js.map +0 -1
  242. package/lib/module/store/traceText.test.js.map +0 -1
  243. package/lib/module/store/transcriptPersistence.js.map +0 -1
  244. package/lib/module/store/transcriptPersistence.test.js.map +0 -1
  245. package/lib/module/store/turnRendering.test.js.map +0 -1
  246. package/lib/module/store/useAskBuoy.js.map +0 -1
  247. package/lib/module/store/useAskBuoySettings.js.map +0 -1
  248. package/lib/module/sync/askBuoySyncAdapter.js.map +0 -1
  249. package/lib/module/sync/askBuoySyncAdapter.test.js.map +0 -1
  250. package/lib/module/sync/wire.js.map +0 -1
  251. package/lib/module/types.js.map +0 -1
  252. package/lib/typescript/blocks/AskBlocks.d.ts.map +0 -1
  253. package/lib/typescript/blocks/BlockRenderer.d.ts.map +0 -1
  254. package/lib/typescript/blocks/ChromePrototypes.d.ts.map +0 -1
  255. package/lib/typescript/blocks/DataBlocks.d.ts.map +0 -1
  256. package/lib/typescript/blocks/ExtraBlocks.d.ts.map +0 -1
  257. package/lib/typescript/blocks/MediaBlocks.d.ts.map +0 -1
  258. package/lib/typescript/blocks/ReceiptBlocks.d.ts.map +0 -1
  259. package/lib/typescript/blocks/blockText.d.ts.map +0 -1
  260. package/lib/typescript/blocks/blockText.test.d.ts.map +0 -1
  261. package/lib/typescript/blocks/context.d.ts.map +0 -1
  262. package/lib/typescript/blocks/icons.d.ts.map +0 -1
  263. package/lib/typescript/blocks/index.d.ts.map +0 -1
  264. package/lib/typescript/blocks/listRow.test.d.ts.map +0 -1
  265. package/lib/typescript/blocks/pageState.d.ts.map +0 -1
  266. package/lib/typescript/blocks/pageState.test.d.ts.map +0 -1
  267. package/lib/typescript/blocks/primitives.d.ts.map +0 -1
  268. package/lib/typescript/blocks/primitivesIndex.d.ts.map +0 -1
  269. package/lib/typescript/blocks/ruleStates.d.ts.map +0 -1
  270. package/lib/typescript/components/ApprovalCard.d.ts.map +0 -1
  271. package/lib/typescript/components/AskBuoyHeader.d.ts.map +0 -1
  272. package/lib/typescript/components/AskBuoyIcon.d.ts.map +0 -1
  273. package/lib/typescript/components/AskBuoyModal.d.ts.map +0 -1
  274. package/lib/typescript/components/AskBuoySettings.d.ts.map +0 -1
  275. package/lib/typescript/components/ChangesBar.d.ts.map +0 -1
  276. package/lib/typescript/components/Composer.d.ts.map +0 -1
  277. package/lib/typescript/components/EmptyState.d.ts.map +0 -1
  278. package/lib/typescript/components/KeyboardPad.d.ts.map +0 -1
  279. package/lib/typescript/components/Markdown.d.ts.map +0 -1
  280. package/lib/typescript/components/MessageList.d.ts.map +0 -1
  281. package/lib/typescript/components/QueuedMessages.d.ts.map +0 -1
  282. package/lib/typescript/components/ThinkingStrip.d.ts.map +0 -1
  283. package/lib/typescript/components/TypingDots.d.ts.map +0 -1
  284. package/lib/typescript/components/markdownParse.d.ts.map +0 -1
  285. package/lib/typescript/components/markdownParse.test.d.ts.map +0 -1
  286. package/lib/typescript/components/useCopyAction.d.ts.map +0 -1
  287. package/lib/typescript/index.d.ts.map +0 -1
  288. package/lib/typescript/preset.d.ts.map +0 -1
  289. package/lib/typescript/store/activityGroups.d.ts.map +0 -1
  290. package/lib/typescript/store/activityGroups.test.d.ts.map +0 -1
  291. package/lib/typescript/store/askBuoySettings.d.ts.map +0 -1
  292. package/lib/typescript/store/askBuoyStore.d.ts.map +0 -1
  293. package/lib/typescript/store/blockPlacement.d.ts.map +0 -1
  294. package/lib/typescript/store/blockPlacement.test.d.ts.map +0 -1
  295. package/lib/typescript/store/queue.test.d.ts.map +0 -1
  296. package/lib/typescript/store/resetConversation.d.ts.map +0 -1
  297. package/lib/typescript/store/restorePending.test.d.ts.map +0 -1
  298. package/lib/typescript/store/restoredIds.test.d.ts.map +0 -1
  299. package/lib/typescript/store/suggestions.d.ts.map +0 -1
  300. package/lib/typescript/store/suggestions.test.d.ts.map +0 -1
  301. package/lib/typescript/store/systemLine.test.d.ts.map +0 -1
  302. package/lib/typescript/store/ticketPrompt.d.ts.map +0 -1
  303. package/lib/typescript/store/traceText.d.ts.map +0 -1
  304. package/lib/typescript/store/traceText.test.d.ts.map +0 -1
  305. package/lib/typescript/store/transcriptPersistence.d.ts.map +0 -1
  306. package/lib/typescript/store/transcriptPersistence.test.d.ts.map +0 -1
  307. package/lib/typescript/store/turnRendering.test.d.ts.map +0 -1
  308. package/lib/typescript/store/useAskBuoy.d.ts.map +0 -1
  309. package/lib/typescript/store/useAskBuoySettings.d.ts.map +0 -1
  310. package/lib/typescript/sync/askBuoySyncAdapter.d.ts.map +0 -1
  311. package/lib/typescript/sync/askBuoySyncAdapter.test.d.ts.map +0 -1
  312. package/lib/typescript/sync/wire.d.ts.map +0 -1
  313. package/lib/typescript/types.d.ts.map +0 -1
@@ -1,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 as n,expect as o,it as s}from"vitest";import{placeBlocks as i}from"./blockPlacement";const c=(e,t)=>({block:e,forToolCallId:t});const d=(e="ui1")=>c({id:e,kind:"imageGrid",source:"model",images:[{url:"https://cdn.example.com/25.png",alt:"Pikachu"}]},"call-ui");n("model-authored blocks",()=>{s("renders in the answer, never nested under a step that has no row",()=>{const{afterText:e,nested:t}=i([d()],["c1"]);o(e.map(a=>a.block.id)).toEqual(["ui1"]);o(t.size).toBe(0)});s("still renders even when a step with that id somehow exists",()=>{const{afterText:e}=i([d()],["call-ui"]);o(e.map(t=>t.block.id)).toEqual(["ui1"])})});n("receipts",()=>{s("folds a read receipt into its own step row",()=>{const e=c({id:"r1",kind:"keyValue",source:"live",pairs:[]},"c1");const{nested:t,afterText:a}=i([e],["c1"]);o(a).toEqual([]);o(t.get("c1")?.map(r=>r.id)).toEqual(["r1"])});s("keeps a write receipt afterText \u2014 the user must see it without asking",()=>{const e=c({id:"w1",kind:"diff",source:"changed",changes:[]},"c1");const{nested:t,afterText:a}=i([e],["c1"]);o(t.size).toBe(0);o(a.map(r=>r.block.id)).toEqual(["w1"])});s("falls back to afterText when its step row was never drawn",()=>{const e=c({id:"r2",kind:"keyValue",source:"live",pairs:[]},"gone");const{afterText:t}=i([e],[]);o(t.map(a=>a.block.id)).toEqual(["r2"])})});n("ask blocks",()=>{s("come out in their own bucket, after the answer",()=>{const e=c({id:"a1",kind:"confirm",source:"model",change:"Wipe storage"},"call-ui");const{ask:t,afterText:a,nested:r}=i([e,d("ui2")],["c1"]);o(t.map(l=>l.block.id)).toEqual(["a1"]);o(a.map(l=>l.block.id)).toEqual(["ui2"]);o(r.size).toBe(0)})});n("the answer comes after the prose",()=>{s("puts a model-authored card in the after-text bucket, never before it",()=>{const e=i([d()],["c1"]);o(e.afterText.map(t=>t.block.id)).toEqual(["ui1"]);o(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 as d,describe as r,expect as t,it as a}from"vitest";import{askBuoyStore as e,queuePauseReason as n,turnPhaseOf as i}from"./askBuoyStore";d(()=>e.reset());const o=()=>e.getState().queued.map(s=>s.text);r("queue",()=>{a("keeps every message, in the order typed",()=>{e.enqueue("then set points to 1500");e.enqueue("and clear the cart after");t(o()).toEqual(["then set points to 1500","and clear the cart after"])});a("gives identical requests distinct ids",()=>{const s=e.enqueue("again");const u=e.enqueue("again");t(s.id).not.toBe(u.id);e.removeQueued(s.id);t(o()).toEqual(["again"])});a("delivers from the front, one at a time",()=>{e.enqueue("one");e.enqueue("two");t(e.shiftQueued()?.text).toBe("one");t(o()).toEqual(["two"]);t(e.shiftQueued()?.text).toBe("two");t(e.shiftQueued()).toBeUndefined()});a("comes back from disk as unsent rows",()=>{const s=e.hydrate({messages:[{id:"m1",role:"user",text:"hi",toolCalls:[],blocks:[]}],answers:{},usage:{input:0,output:0,requests:0},queued:[{id:"q1",text:"still waiting"}]});t(s).toBe(true);t(o()).toEqual(["still waiting"]);t(i(e.getState())).toBe("idle")});a("is emptied by a new conversation",()=>{e.enqueue("gone");e.reset();t(o()).toEqual([])})});r("turnPhase",()=>{a("is idle with nothing going on",()=>{t(i(e.getState())).toBe("idle")});a("is running during a turn, and stopping once Stop is pressed",()=>{e.addUser("go");e.startAssistant();t(i(e.getState())).toBe("running");e.requestStop();t(i(e.getState())).toBe("stopping")});a("is awaitingApproval while a card is up, even though the turn is busy",()=>{e.addUser("wipe it");e.startAssistant();void e.askApproval({id:"c1",toolId:"storage",action:"clearAll",label:"Clear all saved app data",reason:"Wipes everything"});t(i(e.getState())).toBe("awaitingApproval")});a("is awaitingAnswer after a turn ends on an Ask block",()=>{const s=e.startAssistant();e.applyEvent(s,{type:"awaiting-user",blockId:"b1"});e.finishAssistant(s);t(i(e.getState())).toBe("awaitingAnswer")})});r("when the queue holds",()=>{a("delivers when idle and the last turn was fine",()=>{e.addUser("hi");const s=e.startAssistant();e.applyEvent(s,{type:"text",delta:"Hello."});e.finishAssistant(s);t(n(e.getState())).toBeNull()});a("holds after an error, and says so",()=>{e.addUser("hi");const s=e.startAssistant();e.applyEvent(s,{type:"error",message:"fetch failed"});e.finishAssistant(s);t(n(e.getState())).toMatch(/failed/)});a("holds while an approval card is up",()=>{e.addUser("wipe");e.startAssistant();void e.askApproval({id:"c1",toolId:"storage",action:"clearAll",label:"Clear all saved app data",reason:"Wipes everything"});t(n(e.getState())).toMatch(/approval/)});a("holds while a question is unanswered \u2014 a queued task is not the answer",()=>{const s=e.startAssistant();e.applyEvent(s,{type:"awaiting-user",blockId:"b1"});e.finishAssistant(s);t(n(e.getState())).toMatch(/question/)});a("says nothing while a turn is still running \u2014 the queue is simply waiting",()=>{e.addUser("go");e.startAssistant();t(n(e.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 as r}from"./askBuoyStore";import{clearTranscript as a}from"./transcriptPersistence";export function clearConversation(){r.getHeldSession()?.session.reset();r.reset();void a()}export async function resetConversation(t){if(r.getState().busy){return{cleared:false,reverted:0,failed:[{label:"A turn is running",error:"Stop it first."}]}}const i=r.getLedger();if(t.undoFirst&&i){const e=await i.revertAll(t.dispatch);if(e.failed.length>0){return{cleared:false,reverted:e.reverted,failed:e.failed}}clearConversation();return{cleared:true,reverted:e.reverted,failed:[]}}clearConversation();return{cleared:true,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 as o,describe as n,expect as t,it as a}from"vitest";import{askBuoyStore as e}from"./askBuoyStore";const r={id:"c1",toolId:"zustand",action:"setState",label:"Update the Pok\xE9 Mart bag store",reason:"This will change the app's state.",params:{storeName:"bag"}};o(()=>e.reset());n("restorePending",()=>{a("puts the card back on screen",()=>{t(e.restorePending(r)).toBe(true);t(e.getState().pending).toMatchObject({toolId:"zustand",action:"setState",params:{storeName:"bag"}})});a("marks it restored, so Allow runs the call instead of answering a dead promise",()=>{e.restorePending(r);t(e.getState().pending?.restored).toBe(true)});a("refuses once a turn is under way",()=>{e.beginTurn();t(e.restorePending(r)).toBe(false);t(e.getState().pending).toBeNull()});a("refuses when a live card is already asking",()=>{void e.askApproval(r);t(e.restorePending({...r,id:"c2"})).toBe(false);t(e.getState().pending?.id).toBe("c1")});a("answers without throwing, though nothing is waiting on it",()=>{e.restorePending(r);t(()=>e.answerApproval(true)).not.toThrow();t(e.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 as d,expect as o,it as e}from"vitest";import{idFactory as r,RUN_ID as c}from"@buoy-gg/agent-core";d("ids across a restart",()=>{e("never reissues an id a restored transcript already holds",()=>{const t=["rcOLDRUN-1","rcOLDRUN-2","uiOLDRUN-1","mOLDRUN-1"];const s=r("rc");const n=r("ui");const i=r("m");const a=[s(),s(),n(),i()];for(const u of a)o(t).not.toContain(u)});e("still counts up within one run",()=>{const t=r("rc");const s=[t(),t(),t()];o(new Set(s).size).toBe(3)});e("keeps two prefixes apart even at the same count",()=>{const t=r("rc");const s=r("ui");o(t()).not.toBe(s())});e("stamps a run token that is not a fixed string",()=>{o(c).toMatch(/^[a-z0-9]{4,8}$/);o(r("rc")()).toBe(`rc${c}-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:true,devOnly:true},{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(t){const r=t.availableToolIds.length>0;return SUGGESTIONS.filter(e=>{if(e.write&&t.readOnly)return false;if(e.devOnly&&t.isRelease)return false;if(e.needs)return r&&t.availableToolIds.includes(e.needs);return true}).slice(0,MAX_SUGGESTIONS).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 as i,expect as s,it as a}from"vitest";import{MAX_SUGGESTIONS as r,pickSuggestions as t}from"./suggestions";const o=["network","storage","console","query"];i("pickSuggestions",()=>{a("offers the simulation only on a dev build that may write",()=>{const e=t({availableToolIds:o,readOnly:false,isRelease:false});s(e).toContain("Make the next request to this screen fail with a 500");const l=t({availableToolIds:o,readOnly:false,isRelease:true});s(l).not.toContain("Make the next request to this screen fail with a 500");const n=t({availableToolIds:o,readOnly:true,isRelease:false});s(n).not.toContain("Make the next request to this screen fail with a 500")});a("drops chips whose tool is not on this device",()=>{const e=t({availableToolIds:["storage"],readOnly:false,isRelease:false});s(e).not.toContain("What did the last few network calls return?");s(e).toContain("Show me what's saved for this user")});a("shows only tool-free chips until the registry has reported",()=>{const e=t({availableToolIds:[],readOnly:false,isRelease:false});s(e).toEqual(["Why is this screen empty?","Who am I signed in as right now?"])});a("never exceeds the cap and keeps the order",()=>{const e=t({availableToolIds:o,readOnly:false,isRelease:false});s(e.length).toBeLessThanOrEqual(r);s(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 as d,describe as n,expect as s,it as r}from"vitest";import{askBuoyStore as t}from"./askBuoyStore";import{buildPayload as p,parsePayload as c}from"./transcriptPersistence";d(()=>t.reset());n("history-trimmed",()=>{r("inserts a system line before the answer it affects",()=>{t.addUser("turn off that override");const e=t.startAssistant();t.applyEvent(e,{type:"history-trimmed",droppedRounds:3});t.applyEvent(e,{type:"text",delta:"Turning it off."});const a=t.getState().messages.map(i=>i.system?"system":i.role);s(a).toEqual(["user","system","assistant"]);const o=t.getState().messages[1];s(o.text).toMatch(/3 exchanges/);s(o.text).toMatch(/changes bar still lists/)});r("singular for one round",()=>{const e=t.startAssistant();t.applyEvent(e,{type:"history-trimmed",droppedRounds:1});s(t.getState().messages[0].text).toMatch(/1 exchange\)/)})});n("restored approval freshness",()=>{r("carries the target digest to disk and back, never the target",()=>{const e=p({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:()=>{}}});const a=JSON.stringify(e);s(a).toContain("1a2b3c:512");const o=c(a);s(o?.pending?.targetDigest).toBe("1a2b3c:512")})});