@buoy-gg/ask-buoy 7.0.41 → 7.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (313) hide show
  1. package/README.md +13 -98
  2. package/lib/commonjs/blocks/AskBlocks.js +1 -338
  3. package/lib/commonjs/blocks/BlockRenderer.js +1 -262
  4. package/lib/commonjs/blocks/ChromePrototypes.js +1 -514
  5. package/lib/commonjs/blocks/DataBlocks.js +1 -783
  6. package/lib/commonjs/blocks/ExtraBlocks.js +1 -1862
  7. package/lib/commonjs/blocks/MediaBlocks.js +1 -158
  8. package/lib/commonjs/blocks/ReceiptBlocks.js +2 -592
  9. package/lib/commonjs/blocks/blockText.js +1 -60
  10. package/lib/commonjs/blocks/blockText.test.js +1 -53
  11. package/lib/commonjs/blocks/context.js +1 -42
  12. package/lib/commonjs/blocks/icons.js +1 -96
  13. package/lib/commonjs/blocks/index.js +1 -95
  14. package/lib/commonjs/blocks/listRow.test.js +1 -55
  15. package/lib/commonjs/blocks/pageState.js +1 -34
  16. package/lib/commonjs/blocks/pageState.test.js +1 -57
  17. package/lib/commonjs/blocks/primitives.js +1 -457
  18. package/lib/commonjs/blocks/primitivesIndex.js +1 -62
  19. package/lib/commonjs/blocks/ruleStates.js +1 -39
  20. package/lib/commonjs/components/ApprovalCard.js +1 -297
  21. package/lib/commonjs/components/AskBuoyHeader.js +1 -196
  22. package/lib/commonjs/components/AskBuoyIcon.js +1 -19
  23. package/lib/commonjs/components/AskBuoyModal.js +2 -482
  24. package/lib/commonjs/components/AskBuoySettings.js +1 -181
  25. package/lib/commonjs/components/ChangesBar.js +1 -212
  26. package/lib/commonjs/components/Composer.js +1 -255
  27. package/lib/commonjs/components/EmptyState.js +1 -161
  28. package/lib/commonjs/components/KeyboardPad.js +1 -80
  29. package/lib/commonjs/components/Markdown.js +1 -310
  30. package/lib/commonjs/components/MessageList.js +1 -970
  31. package/lib/commonjs/components/QueuedMessages.js +1 -145
  32. package/lib/commonjs/components/ThinkingStrip.js +1 -223
  33. package/lib/commonjs/components/TypingDots.js +1 -63
  34. package/lib/commonjs/components/markdownParse.js +1 -131
  35. package/lib/commonjs/components/markdownParse.test.js +1 -99
  36. package/lib/commonjs/components/useCopyAction.js +1 -50
  37. package/lib/commonjs/index.js +1 -252
  38. package/lib/commonjs/preset.js +1 -91
  39. package/lib/commonjs/store/activityGroups.js +1 -110
  40. package/lib/commonjs/store/activityGroups.test.js +1 -78
  41. package/lib/commonjs/store/askBuoySettings.js +1 -72
  42. package/lib/commonjs/store/askBuoyStore.js +2 -588
  43. package/lib/commonjs/store/blockPlacement.js +1 -64
  44. package/lib/commonjs/store/blockPlacement.test.js +1 -123
  45. package/lib/commonjs/store/queue.test.js +1 -150
  46. package/lib/commonjs/store/resetConversation.js +1 -77
  47. package/lib/commonjs/store/restorePending.test.js +1 -63
  48. package/lib/commonjs/store/restoredIds.test.js +1 -47
  49. package/lib/commonjs/store/suggestions.js +1 -54
  50. package/lib/commonjs/store/suggestions.test.js +1 -58
  51. package/lib/commonjs/store/systemLine.test.js +1 -77
  52. package/lib/commonjs/store/ticketPrompt.js +1 -17
  53. package/lib/commonjs/store/traceText.js +1 -81
  54. package/lib/commonjs/store/traceText.test.js +1 -112
  55. package/lib/commonjs/store/transcriptPersistence.js +1 -297
  56. package/lib/commonjs/store/transcriptPersistence.test.js +1 -333
  57. package/lib/commonjs/store/turnRendering.test.js +1 -151
  58. package/lib/commonjs/store/useAskBuoy.js +1 -651
  59. package/lib/commonjs/store/useAskBuoySettings.js +1 -14
  60. package/lib/commonjs/sync/askBuoySyncAdapter.js +1 -153
  61. package/lib/commonjs/sync/askBuoySyncAdapter.test.js +1 -141
  62. package/lib/commonjs/sync/wire.js +1 -58
  63. package/lib/commonjs/types.js +1 -6
  64. package/lib/module/blocks/AskBlocks.js +1 -331
  65. package/lib/module/blocks/BlockRenderer.js +1 -257
  66. package/lib/module/blocks/ChromePrototypes.js +1 -503
  67. package/lib/module/blocks/DataBlocks.js +1 -769
  68. package/lib/module/blocks/ExtraBlocks.js +1 -1835
  69. package/lib/module/blocks/MediaBlocks.js +1 -153
  70. package/lib/module/blocks/ReceiptBlocks.js +2 -580
  71. package/lib/module/blocks/blockText.js +1 -55
  72. package/lib/module/blocks/blockText.test.js +1 -53
  73. package/lib/module/blocks/context.js +1 -35
  74. package/lib/module/blocks/icons.js +1 -91
  75. package/lib/module/blocks/index.js +1 -8
  76. package/lib/module/blocks/listRow.test.js +1 -56
  77. package/lib/module/blocks/pageState.js +1 -30
  78. package/lib/module/blocks/pageState.test.js +1 -56
  79. package/lib/module/blocks/primitives.js +1 -445
  80. package/lib/module/blocks/primitivesIndex.js +1 -5
  81. package/lib/module/blocks/ruleStates.js +1 -35
  82. package/lib/module/components/ApprovalCard.js +1 -292
  83. package/lib/module/components/AskBuoyHeader.js +1 -193
  84. package/lib/module/components/AskBuoyIcon.js +1 -8
  85. package/lib/module/components/AskBuoyModal.js +2 -477
  86. package/lib/module/components/AskBuoySettings.js +1 -176
  87. package/lib/module/components/ChangesBar.js +1 -206
  88. package/lib/module/components/Composer.js +1 -250
  89. package/lib/module/components/EmptyState.js +1 -156
  90. package/lib/module/components/KeyboardPad.js +1 -75
  91. package/lib/module/components/Markdown.js +1 -305
  92. package/lib/module/components/MessageList.js +1 -964
  93. package/lib/module/components/QueuedMessages.js +1 -140
  94. package/lib/module/components/ThinkingStrip.js +1 -218
  95. package/lib/module/components/TypingDots.js +1 -58
  96. package/lib/module/components/markdownParse.js +1 -125
  97. package/lib/module/components/markdownParse.test.js +1 -98
  98. package/lib/module/components/useCopyAction.js +1 -46
  99. package/lib/module/index.js +1 -34
  100. package/lib/module/preset.js +1 -74
  101. package/lib/module/store/activityGroups.js +1 -103
  102. package/lib/module/store/activityGroups.test.js +1 -77
  103. package/lib/module/store/askBuoySettings.js +1 -67
  104. package/lib/module/store/askBuoyStore.js +2 -582
  105. package/lib/module/store/blockPlacement.js +1 -59
  106. package/lib/module/store/blockPlacement.test.js +1 -122
  107. package/lib/module/store/queue.test.js +1 -149
  108. package/lib/module/store/resetConversation.js +1 -72
  109. package/lib/module/store/restorePending.test.js +1 -62
  110. package/lib/module/store/restoredIds.test.js +1 -46
  111. package/lib/module/store/suggestions.js +1 -49
  112. package/lib/module/store/suggestions.test.js +1 -57
  113. package/lib/module/store/systemLine.test.js +1 -76
  114. package/lib/module/store/ticketPrompt.js +1 -13
  115. package/lib/module/store/traceText.js +1 -75
  116. package/lib/module/store/traceText.test.js +1 -111
  117. package/lib/module/store/transcriptPersistence.js +1 -287
  118. package/lib/module/store/transcriptPersistence.test.js +1 -332
  119. package/lib/module/store/turnRendering.test.js +1 -150
  120. package/lib/module/store/useAskBuoy.js +1 -646
  121. package/lib/module/store/useAskBuoySettings.js +1 -9
  122. package/lib/module/sync/askBuoySyncAdapter.js +1 -148
  123. package/lib/module/sync/askBuoySyncAdapter.test.js +1 -140
  124. package/lib/module/sync/wire.js +1 -47
  125. package/lib/module/types.js +1 -4
  126. package/lib/web/index.mjs +11 -12
  127. package/package.json +8 -12
  128. package/lib/commonjs/blocks/AskBlocks.js.map +0 -1
  129. package/lib/commonjs/blocks/BlockRenderer.js.map +0 -1
  130. package/lib/commonjs/blocks/ChromePrototypes.js.map +0 -1
  131. package/lib/commonjs/blocks/DataBlocks.js.map +0 -1
  132. package/lib/commonjs/blocks/ExtraBlocks.js.map +0 -1
  133. package/lib/commonjs/blocks/MediaBlocks.js.map +0 -1
  134. package/lib/commonjs/blocks/ReceiptBlocks.js.map +0 -1
  135. package/lib/commonjs/blocks/blockText.js.map +0 -1
  136. package/lib/commonjs/blocks/blockText.test.js.map +0 -1
  137. package/lib/commonjs/blocks/context.js.map +0 -1
  138. package/lib/commonjs/blocks/icons.js.map +0 -1
  139. package/lib/commonjs/blocks/index.js.map +0 -1
  140. package/lib/commonjs/blocks/listRow.test.js.map +0 -1
  141. package/lib/commonjs/blocks/pageState.js.map +0 -1
  142. package/lib/commonjs/blocks/pageState.test.js.map +0 -1
  143. package/lib/commonjs/blocks/primitives.js.map +0 -1
  144. package/lib/commonjs/blocks/primitivesIndex.js.map +0 -1
  145. package/lib/commonjs/blocks/ruleStates.js.map +0 -1
  146. package/lib/commonjs/components/ApprovalCard.js.map +0 -1
  147. package/lib/commonjs/components/AskBuoyHeader.js.map +0 -1
  148. package/lib/commonjs/components/AskBuoyIcon.js.map +0 -1
  149. package/lib/commonjs/components/AskBuoyModal.js.map +0 -1
  150. package/lib/commonjs/components/AskBuoySettings.js.map +0 -1
  151. package/lib/commonjs/components/ChangesBar.js.map +0 -1
  152. package/lib/commonjs/components/Composer.js.map +0 -1
  153. package/lib/commonjs/components/EmptyState.js.map +0 -1
  154. package/lib/commonjs/components/KeyboardPad.js.map +0 -1
  155. package/lib/commonjs/components/Markdown.js.map +0 -1
  156. package/lib/commonjs/components/MessageList.js.map +0 -1
  157. package/lib/commonjs/components/QueuedMessages.js.map +0 -1
  158. package/lib/commonjs/components/ThinkingStrip.js.map +0 -1
  159. package/lib/commonjs/components/TypingDots.js.map +0 -1
  160. package/lib/commonjs/components/markdownParse.js.map +0 -1
  161. package/lib/commonjs/components/markdownParse.test.js.map +0 -1
  162. package/lib/commonjs/components/useCopyAction.js.map +0 -1
  163. package/lib/commonjs/index.js.map +0 -1
  164. package/lib/commonjs/preset.js.map +0 -1
  165. package/lib/commonjs/store/activityGroups.js.map +0 -1
  166. package/lib/commonjs/store/activityGroups.test.js.map +0 -1
  167. package/lib/commonjs/store/askBuoySettings.js.map +0 -1
  168. package/lib/commonjs/store/askBuoyStore.js.map +0 -1
  169. package/lib/commonjs/store/blockPlacement.js.map +0 -1
  170. package/lib/commonjs/store/blockPlacement.test.js.map +0 -1
  171. package/lib/commonjs/store/queue.test.js.map +0 -1
  172. package/lib/commonjs/store/resetConversation.js.map +0 -1
  173. package/lib/commonjs/store/restorePending.test.js.map +0 -1
  174. package/lib/commonjs/store/restoredIds.test.js.map +0 -1
  175. package/lib/commonjs/store/suggestions.js.map +0 -1
  176. package/lib/commonjs/store/suggestions.test.js.map +0 -1
  177. package/lib/commonjs/store/systemLine.test.js.map +0 -1
  178. package/lib/commonjs/store/ticketPrompt.js.map +0 -1
  179. package/lib/commonjs/store/traceText.js.map +0 -1
  180. package/lib/commonjs/store/traceText.test.js.map +0 -1
  181. package/lib/commonjs/store/transcriptPersistence.js.map +0 -1
  182. package/lib/commonjs/store/transcriptPersistence.test.js.map +0 -1
  183. package/lib/commonjs/store/turnRendering.test.js.map +0 -1
  184. package/lib/commonjs/store/useAskBuoy.js.map +0 -1
  185. package/lib/commonjs/store/useAskBuoySettings.js.map +0 -1
  186. package/lib/commonjs/sync/askBuoySyncAdapter.js.map +0 -1
  187. package/lib/commonjs/sync/askBuoySyncAdapter.test.js.map +0 -1
  188. package/lib/commonjs/sync/wire.js.map +0 -1
  189. package/lib/commonjs/types.js.map +0 -1
  190. package/lib/module/blocks/AskBlocks.js.map +0 -1
  191. package/lib/module/blocks/BlockRenderer.js.map +0 -1
  192. package/lib/module/blocks/ChromePrototypes.js.map +0 -1
  193. package/lib/module/blocks/DataBlocks.js.map +0 -1
  194. package/lib/module/blocks/ExtraBlocks.js.map +0 -1
  195. package/lib/module/blocks/MediaBlocks.js.map +0 -1
  196. package/lib/module/blocks/ReceiptBlocks.js.map +0 -1
  197. package/lib/module/blocks/blockText.js.map +0 -1
  198. package/lib/module/blocks/blockText.test.js.map +0 -1
  199. package/lib/module/blocks/context.js.map +0 -1
  200. package/lib/module/blocks/icons.js.map +0 -1
  201. package/lib/module/blocks/index.js.map +0 -1
  202. package/lib/module/blocks/listRow.test.js.map +0 -1
  203. package/lib/module/blocks/pageState.js.map +0 -1
  204. package/lib/module/blocks/pageState.test.js.map +0 -1
  205. package/lib/module/blocks/primitives.js.map +0 -1
  206. package/lib/module/blocks/primitivesIndex.js.map +0 -1
  207. package/lib/module/blocks/ruleStates.js.map +0 -1
  208. package/lib/module/components/ApprovalCard.js.map +0 -1
  209. package/lib/module/components/AskBuoyHeader.js.map +0 -1
  210. package/lib/module/components/AskBuoyIcon.js.map +0 -1
  211. package/lib/module/components/AskBuoyModal.js.map +0 -1
  212. package/lib/module/components/AskBuoySettings.js.map +0 -1
  213. package/lib/module/components/ChangesBar.js.map +0 -1
  214. package/lib/module/components/Composer.js.map +0 -1
  215. package/lib/module/components/EmptyState.js.map +0 -1
  216. package/lib/module/components/KeyboardPad.js.map +0 -1
  217. package/lib/module/components/Markdown.js.map +0 -1
  218. package/lib/module/components/MessageList.js.map +0 -1
  219. package/lib/module/components/QueuedMessages.js.map +0 -1
  220. package/lib/module/components/ThinkingStrip.js.map +0 -1
  221. package/lib/module/components/TypingDots.js.map +0 -1
  222. package/lib/module/components/markdownParse.js.map +0 -1
  223. package/lib/module/components/markdownParse.test.js.map +0 -1
  224. package/lib/module/components/useCopyAction.js.map +0 -1
  225. package/lib/module/index.js.map +0 -1
  226. package/lib/module/preset.js.map +0 -1
  227. package/lib/module/store/activityGroups.js.map +0 -1
  228. package/lib/module/store/activityGroups.test.js.map +0 -1
  229. package/lib/module/store/askBuoySettings.js.map +0 -1
  230. package/lib/module/store/askBuoyStore.js.map +0 -1
  231. package/lib/module/store/blockPlacement.js.map +0 -1
  232. package/lib/module/store/blockPlacement.test.js.map +0 -1
  233. package/lib/module/store/queue.test.js.map +0 -1
  234. package/lib/module/store/resetConversation.js.map +0 -1
  235. package/lib/module/store/restorePending.test.js.map +0 -1
  236. package/lib/module/store/restoredIds.test.js.map +0 -1
  237. package/lib/module/store/suggestions.js.map +0 -1
  238. package/lib/module/store/suggestions.test.js.map +0 -1
  239. package/lib/module/store/systemLine.test.js.map +0 -1
  240. package/lib/module/store/ticketPrompt.js.map +0 -1
  241. package/lib/module/store/traceText.js.map +0 -1
  242. package/lib/module/store/traceText.test.js.map +0 -1
  243. package/lib/module/store/transcriptPersistence.js.map +0 -1
  244. package/lib/module/store/transcriptPersistence.test.js.map +0 -1
  245. package/lib/module/store/turnRendering.test.js.map +0 -1
  246. package/lib/module/store/useAskBuoy.js.map +0 -1
  247. package/lib/module/store/useAskBuoySettings.js.map +0 -1
  248. package/lib/module/sync/askBuoySyncAdapter.js.map +0 -1
  249. package/lib/module/sync/askBuoySyncAdapter.test.js.map +0 -1
  250. package/lib/module/sync/wire.js.map +0 -1
  251. package/lib/module/types.js.map +0 -1
  252. package/lib/typescript/blocks/AskBlocks.d.ts.map +0 -1
  253. package/lib/typescript/blocks/BlockRenderer.d.ts.map +0 -1
  254. package/lib/typescript/blocks/ChromePrototypes.d.ts.map +0 -1
  255. package/lib/typescript/blocks/DataBlocks.d.ts.map +0 -1
  256. package/lib/typescript/blocks/ExtraBlocks.d.ts.map +0 -1
  257. package/lib/typescript/blocks/MediaBlocks.d.ts.map +0 -1
  258. package/lib/typescript/blocks/ReceiptBlocks.d.ts.map +0 -1
  259. package/lib/typescript/blocks/blockText.d.ts.map +0 -1
  260. package/lib/typescript/blocks/blockText.test.d.ts.map +0 -1
  261. package/lib/typescript/blocks/context.d.ts.map +0 -1
  262. package/lib/typescript/blocks/icons.d.ts.map +0 -1
  263. package/lib/typescript/blocks/index.d.ts.map +0 -1
  264. package/lib/typescript/blocks/listRow.test.d.ts.map +0 -1
  265. package/lib/typescript/blocks/pageState.d.ts.map +0 -1
  266. package/lib/typescript/blocks/pageState.test.d.ts.map +0 -1
  267. package/lib/typescript/blocks/primitives.d.ts.map +0 -1
  268. package/lib/typescript/blocks/primitivesIndex.d.ts.map +0 -1
  269. package/lib/typescript/blocks/ruleStates.d.ts.map +0 -1
  270. package/lib/typescript/components/ApprovalCard.d.ts.map +0 -1
  271. package/lib/typescript/components/AskBuoyHeader.d.ts.map +0 -1
  272. package/lib/typescript/components/AskBuoyIcon.d.ts.map +0 -1
  273. package/lib/typescript/components/AskBuoyModal.d.ts.map +0 -1
  274. package/lib/typescript/components/AskBuoySettings.d.ts.map +0 -1
  275. package/lib/typescript/components/ChangesBar.d.ts.map +0 -1
  276. package/lib/typescript/components/Composer.d.ts.map +0 -1
  277. package/lib/typescript/components/EmptyState.d.ts.map +0 -1
  278. package/lib/typescript/components/KeyboardPad.d.ts.map +0 -1
  279. package/lib/typescript/components/Markdown.d.ts.map +0 -1
  280. package/lib/typescript/components/MessageList.d.ts.map +0 -1
  281. package/lib/typescript/components/QueuedMessages.d.ts.map +0 -1
  282. package/lib/typescript/components/ThinkingStrip.d.ts.map +0 -1
  283. package/lib/typescript/components/TypingDots.d.ts.map +0 -1
  284. package/lib/typescript/components/markdownParse.d.ts.map +0 -1
  285. package/lib/typescript/components/markdownParse.test.d.ts.map +0 -1
  286. package/lib/typescript/components/useCopyAction.d.ts.map +0 -1
  287. package/lib/typescript/index.d.ts.map +0 -1
  288. package/lib/typescript/preset.d.ts.map +0 -1
  289. package/lib/typescript/store/activityGroups.d.ts.map +0 -1
  290. package/lib/typescript/store/activityGroups.test.d.ts.map +0 -1
  291. package/lib/typescript/store/askBuoySettings.d.ts.map +0 -1
  292. package/lib/typescript/store/askBuoyStore.d.ts.map +0 -1
  293. package/lib/typescript/store/blockPlacement.d.ts.map +0 -1
  294. package/lib/typescript/store/blockPlacement.test.d.ts.map +0 -1
  295. package/lib/typescript/store/queue.test.d.ts.map +0 -1
  296. package/lib/typescript/store/resetConversation.d.ts.map +0 -1
  297. package/lib/typescript/store/restorePending.test.d.ts.map +0 -1
  298. package/lib/typescript/store/restoredIds.test.d.ts.map +0 -1
  299. package/lib/typescript/store/suggestions.d.ts.map +0 -1
  300. package/lib/typescript/store/suggestions.test.d.ts.map +0 -1
  301. package/lib/typescript/store/systemLine.test.d.ts.map +0 -1
  302. package/lib/typescript/store/ticketPrompt.d.ts.map +0 -1
  303. package/lib/typescript/store/traceText.d.ts.map +0 -1
  304. package/lib/typescript/store/traceText.test.d.ts.map +0 -1
  305. package/lib/typescript/store/transcriptPersistence.d.ts.map +0 -1
  306. package/lib/typescript/store/transcriptPersistence.test.d.ts.map +0 -1
  307. package/lib/typescript/store/turnRendering.test.d.ts.map +0 -1
  308. package/lib/typescript/store/useAskBuoy.d.ts.map +0 -1
  309. package/lib/typescript/store/useAskBuoySettings.d.ts.map +0 -1
  310. package/lib/typescript/sync/askBuoySyncAdapter.d.ts.map +0 -1
  311. package/lib/typescript/sync/askBuoySyncAdapter.test.d.ts.map +0 -1
  312. package/lib/typescript/sync/wire.d.ts.map +0 -1
  313. package/lib/typescript/types.d.ts.map +0 -1
@@ -1,332 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * What a saved conversation is allowed to contain, and what it looks like on
5
- * the way back in.
6
- *
7
- * The transcript is on disk under a `@react_buoy` key now, which the Storage
8
- * tool can read and the unauthenticated broker mirrors. Everything below is a
9
- * property that keeps that trade bounded: no tool-result payloads, no
10
- * credentials, no unbounded growth, and nothing that comes back claiming to
11
- * still be running.
12
- */
13
- import { describe, expect, it } from "vitest";
14
- import { buildPayload, fitToCaps, parsePayload } from "./transcriptPersistence";
15
- const msg = (over = {}) => ({
16
- id: "m1",
17
- role: "assistant",
18
- text: "ok",
19
- toolCalls: [],
20
- blocks: [],
21
- ...over
22
- });
23
- const build = (messages, history = []) => buildPayload({
24
- messages,
25
- history,
26
- answers: {},
27
- usage: {
28
- input: 0,
29
- output: 0,
30
- requests: 0
31
- }
32
- });
33
- describe("what reaches the disk", () => {
34
- it("never writes a tool result", () => {
35
- // The payloads are the sensitive half: storage values, response bodies, a
36
- // customer's record. The ROUND survives so the model can resume; what it
37
- // saw does not.
38
- const history = [{
39
- role: "user",
40
- text: "what's in the bag?"
41
- }, {
42
- role: "assistant",
43
- text: "",
44
- toolCalls: [{
45
- id: "c1",
46
- name: "buoy_zustand",
47
- input: {}
48
- }]
49
- }, {
50
- role: "tool-results",
51
- results: [{
52
- toolCallId: "c1",
53
- content: '{"lines":[{"card":"4111111111111111"}]}'
54
- }]
55
- }, {
56
- role: "assistant",
57
- text: "Five items."
58
- }];
59
- const saved = build([msg()], history);
60
- const json = JSON.stringify(saved);
61
- expect(json).not.toContain("4111111111111111");
62
- // The round itself is intact, so the pairing every provider requires holds.
63
- expect(saved.history.map(m => m.role)).toEqual(["user", "assistant", "tool-results", "assistant"]);
64
- });
65
- it("never writes a step's result, even when it writes the step", () => {
66
- // The step survives so the trace still reads; the payload is the thing the
67
- // no-tool-results-on-disk promise is about.
68
- const saved = build([msg({
69
- toolCalls: [{
70
- id: "c1",
71
- toolId: "zustand",
72
- action: "getStoreState",
73
- label: "Read the bag",
74
- status: "ok",
75
- summary: "Done",
76
- params: '{"storeName":"bag"}',
77
- result: '{"card":"4111111111111111"}'
78
- }]
79
- })]);
80
- expect(JSON.stringify(saved)).not.toContain("4111111111111111");
81
- expect(saved.messages[0].toolCalls[0].result).toBeUndefined();
82
- expect(saved.messages[0].toolCalls[0].action).toBe("getStoreState");
83
- });
84
- it("scrubs credential shapes out of what the agent said", () => {
85
- const saved = build([msg({
86
- text: "The header was Bearer abcdefghijklmnop123456"
87
- })]);
88
- expect(saved.messages[0].text).not.toContain("abcdefghijklmnop123456");
89
- });
90
- it("caps a long session instead of growing a file forever", () => {
91
- const many = Array.from({
92
- length: 400
93
- }, (_, i) => msg({
94
- id: `m${i}`,
95
- text: `answer ${i}`
96
- }));
97
- const saved = build(many);
98
- expect(saved.messages.length).toBeLessThanOrEqual(60);
99
- // Newest kept, oldest dropped — the end of a session is the useful end.
100
- expect(saved.messages[saved.messages.length - 1].text).toBe("answer 399");
101
- });
102
- it("drops from the oldest end until a heavy transcript fits", () => {
103
- const heavy = Array.from({
104
- length: 20
105
- }, (_, i) => msg({
106
- id: `m${i}`,
107
- text: "x".repeat(40_000)
108
- }));
109
- const saved = fitToCaps({
110
- v: 1,
111
- savedAt: 0,
112
- messages: heavy,
113
- history: [],
114
- answers: {},
115
- usage: {
116
- input: 0,
117
- output: 0,
118
- requests: 0
119
- }
120
- });
121
- expect(JSON.stringify(saved).length).toBeLessThanOrEqual(256_000);
122
- expect(saved.messages.length).toBeGreaterThan(0);
123
- });
124
- });
125
- describe("what comes back", () => {
126
- it("marks a turn the app died in as interrupted rather than blank", () => {
127
- // The crash case this feature exists for. An empty bubble with no
128
- // explanation reads as the model having nothing to say.
129
- const saved = build([msg({
130
- text: "",
131
- streaming: true
132
- })]);
133
- expect(saved.messages[0].streaming).toBe(false);
134
- expect(saved.messages[0].error).toMatch(/interrupted/i);
135
- });
136
- it("never restores a tool call still claiming to run", () => {
137
- const saved = build([msg({
138
- streaming: true,
139
- toolCalls: [{
140
- id: "c1",
141
- toolId: "storage",
142
- action: "set",
143
- label: "Write a key",
144
- status: "running"
145
- }]
146
- })]);
147
- expect(saved.messages[0].toolCalls[0].status).toBe("failed");
148
- expect(saved.messages[0].toolCalls[0].summary).toBe("Interrupted");
149
- });
150
- it("keeps an answer that already finished exactly as it was", () => {
151
- const saved = build([msg({
152
- text: "Five items.",
153
- streaming: false
154
- })]);
155
- expect(saved.messages[0].error).toBeUndefined();
156
- expect(saved.messages[0].text).toBe("Five items.");
157
- });
158
- it("treats anything it cannot trust as no transcript at all", () => {
159
- expect(parsePayload(null)).toBeNull();
160
- expect(parsePayload("not json")).toBeNull();
161
- // An older shape is dropped, not coerced — a half-read transcript is worse
162
- // than a missing one.
163
- expect(parsePayload(JSON.stringify({
164
- v: 0,
165
- messages: [msg()]
166
- }))).toBeNull();
167
- expect(parsePayload(JSON.stringify({
168
- v: 1,
169
- messages: []
170
- }))).toBeNull();
171
- });
172
- it("round-trips a real conversation", () => {
173
- const saved = build([msg({
174
- role: "user",
175
- text: "hi"
176
- }), msg({
177
- id: "m2",
178
- text: "hello"
179
- })]);
180
- const back = parsePayload(JSON.stringify(saved));
181
- expect(back?.messages.map(m => m.text)).toEqual(["hi", "hello"]);
182
- });
183
- });
184
-
185
- /**
186
- * The card the user never answered.
187
- *
188
- * An unanswered question that disappears on reload reads as consent nobody
189
- * gave — nothing was tapped, so as far as the user is concerned the change is
190
- * still waiting for them.
191
- */
192
- describe("an unanswered approval", () => {
193
- const pending = {
194
- id: "c1",
195
- toolId: "zustand",
196
- action: "setState",
197
- label: "Update the Poké Mart bag store",
198
- description: "Change a live zustand store.",
199
- reason: "This will change the app's state.",
200
- params: {
201
- storeName: "bag",
202
- data: {
203
- lines: []
204
- }
205
- },
206
- resolve: () => {}
207
- };
208
- const withPending = (over = {}) => buildPayload({
209
- messages: [msg()],
210
- history: [],
211
- answers: {},
212
- usage: {
213
- input: 0,
214
- output: 0,
215
- requests: 0
216
- },
217
- pending: {
218
- ...pending,
219
- ...over
220
- }
221
- });
222
- it("survives the round trip with the exact call it asked about", () => {
223
- const back = parsePayload(JSON.stringify(withPending()));
224
- // The params are what makes the restored card answerable at all: the turn
225
- // that asked is gone, so Allow has to re-dispatch this itself.
226
- expect(back?.pending).toMatchObject({
227
- toolId: "zustand",
228
- action: "setState",
229
- label: "Update the Poké Mart bag store",
230
- params: {
231
- storeName: "bag",
232
- data: {
233
- lines: []
234
- }
235
- }
236
- });
237
- });
238
- it("is saved again after it has already been restored once", () => {
239
- // Reloading twice without answering must not be the thing that finally
240
- // loses the question.
241
- expect(withPending({
242
- restored: true
243
- }).pending).toBeTruthy();
244
- });
245
- it("is dropped rather than scrubbed when the call carries a credential", () => {
246
- // Scrubbing would change the call: a redacted token written back is not
247
- // the change the user was shown. So the card is lost instead — an action
248
- // carrying a credential is the one that must not re-run itself unattended.
249
- const saved = withPending({
250
- params: {
251
- key: "auth",
252
- value: "Bearer abcdefghijklmnop123456"
253
- }
254
- });
255
- expect(saved.pending).toBeNull();
256
- expect(JSON.stringify(saved)).not.toContain("abcdefghijklmnop123456");
257
- });
258
- it("reads back as absent from a transcript written before it existed", () => {
259
- const old = build([msg()]);
260
- expect(parsePayload(JSON.stringify(old))?.pending).toBeNull();
261
- });
262
- it("refuses a malformed one rather than restoring half a question", () => {
263
- const raw = JSON.stringify({
264
- ...build([msg()]),
265
- pending: {
266
- toolId: "zustand"
267
- }
268
- });
269
- expect(parsePayload(raw)?.pending).toBeNull();
270
- });
271
- });
272
-
273
- /**
274
- * The undo bar, across a restart.
275
- *
276
- * The ledger is the ONLY undo surface and it used to die with the JS context:
277
- * the transcript came back with its "saved" lines and receipt cards intact
278
- * while the bar vanished and the changes stayed applied.
279
- */
280
- describe("the effect ledger", () => {
281
- const entry = {
282
- id: "fx-1-1",
283
- at: 1,
284
- toolId: "storage",
285
- action: "async.setItem",
286
- effect: {
287
- kind: "storage-write",
288
- toolId: "storage",
289
- action: "async.setItem",
290
- label: "Save @qa/key",
291
- key: "@qa/key",
292
- had: true,
293
- previous: "old value"
294
- }
295
- };
296
- const withLedger = entries => buildPayload({
297
- messages: [msg()],
298
- history: [],
299
- answers: {},
300
- usage: {
301
- input: 0,
302
- output: 0,
303
- requests: 0
304
- },
305
- ledger: entries
306
- });
307
- it("survives the round trip with the prior value an undo needs", () => {
308
- const back = parsePayload(JSON.stringify(withLedger([entry])));
309
- expect(back?.ledger).toHaveLength(1);
310
- expect(back?.ledger?.[0]).toMatchObject({
311
- toolId: "storage",
312
- action: "async.setItem"
313
- });
314
- });
315
- it("drops an entry holding a credential rather than rewriting it", () => {
316
- // Scrubbing would make the undo restore "[redacted]" over the real value.
317
- const secret = {
318
- ...entry,
319
- effect: {
320
- ...entry.effect,
321
- previous: "Bearer abcdefghijklmnop123456"
322
- }
323
- };
324
- const saved = withLedger([secret]);
325
- expect(saved.ledger).toBeUndefined();
326
- expect(JSON.stringify(saved)).not.toContain("abcdefghijklmnop123456");
327
- });
328
- it("reads back as absent from a transcript written before it existed", () => {
329
- expect(parsePayload(JSON.stringify(build([msg()])))?.ledger).toBeUndefined();
330
- });
331
- });
332
- //# sourceMappingURL=transcriptPersistence.test.js.map
1
+ "use strict";import{describe as d,expect as t,it as o}from"vitest";import{buildPayload as g,fitToCaps as c,parsePayload as i}from"./transcriptPersistence";const n=(e={})=>({id:"m1",role:"assistant",text:"ok",toolCalls:[],blocks:[],...e});const r=(e,a=[])=>g({messages:e,history:a,answers:{},usage:{input:0,output:0,requests:0}});d("what reaches the disk",()=>{o("never writes a tool result",()=>{const e=[{role:"user",text:"what's in the bag?"},{role:"assistant",text:"",toolCalls:[{id:"c1",name:"buoy_zustand",input:{}}]},{role:"tool-results",results:[{toolCallId:"c1",content:'{"lines":[{"card":"4111111111111111"}]}'}]},{role:"assistant",text:"Five items."}];const a=r([n()],e);const s=JSON.stringify(a);t(s).not.toContain("4111111111111111");t(a.history.map(l=>l.role)).toEqual(["user","assistant","tool-results","assistant"])});o("never writes a step's result, even when it writes the step",()=>{const e=r([n({toolCalls:[{id:"c1",toolId:"zustand",action:"getStoreState",label:"Read the bag",status:"ok",summary:"Done",params:'{"storeName":"bag"}',result:'{"card":"4111111111111111"}'}]})]);t(JSON.stringify(e)).not.toContain("4111111111111111");t(e.messages[0].toolCalls[0].result).toBeUndefined();t(e.messages[0].toolCalls[0].action).toBe("getStoreState")});o("scrubs credential shapes out of what the agent said",()=>{const e=r([n({text:"The header was Bearer abcdefghijklmnop123456"})]);t(e.messages[0].text).not.toContain("abcdefghijklmnop123456")});o("caps a long session instead of growing a file forever",()=>{const e=Array.from({length:400},(s,l)=>n({id:`m${l}`,text:`answer ${l}`}));const a=r(e);t(a.messages.length).toBeLessThanOrEqual(60);t(a.messages[a.messages.length-1].text).toBe("answer 399")});o("drops from the oldest end until a heavy transcript fits",()=>{const e=Array.from({length:20},(s,l)=>n({id:`m${l}`,text:"x".repeat(4e4)}));const a=c({v:1,savedAt:0,messages:e,history:[],answers:{},usage:{input:0,output:0,requests:0}});t(JSON.stringify(a).length).toBeLessThanOrEqual(256e3);t(a.messages.length).toBeGreaterThan(0)})});d("what comes back",()=>{o("marks a turn the app died in as interrupted rather than blank",()=>{const e=r([n({text:"",streaming:true})]);t(e.messages[0].streaming).toBe(false);t(e.messages[0].error).toMatch(/interrupted/i)});o("never restores a tool call still claiming to run",()=>{const e=r([n({streaming:true,toolCalls:[{id:"c1",toolId:"storage",action:"set",label:"Write a key",status:"running"}]})]);t(e.messages[0].toolCalls[0].status).toBe("failed");t(e.messages[0].toolCalls[0].summary).toBe("Interrupted")});o("keeps an answer that already finished exactly as it was",()=>{const e=r([n({text:"Five items.",streaming:false})]);t(e.messages[0].error).toBeUndefined();t(e.messages[0].text).toBe("Five items.")});o("treats anything it cannot trust as no transcript at all",()=>{t(i(null)).toBeNull();t(i("not json")).toBeNull();t(i(JSON.stringify({v:0,messages:[n()]}))).toBeNull();t(i(JSON.stringify({v:1,messages:[]}))).toBeNull()});o("round-trips a real conversation",()=>{const e=r([n({role:"user",text:"hi"}),n({id:"m2",text:"hello"})]);const a=i(JSON.stringify(e));t(a?.messages.map(s=>s.text)).toEqual(["hi","hello"])})});d("an unanswered approval",()=>{const e={id:"c1",toolId:"zustand",action:"setState",label:"Update the Pok\xE9 Mart bag store",description:"Change a live zustand store.",reason:"This will change the app's state.",params:{storeName:"bag",data:{lines:[]}},resolve:()=>{}};const a=(s={})=>g({messages:[n()],history:[],answers:{},usage:{input:0,output:0,requests:0},pending:{...e,...s}});o("survives the round trip with the exact call it asked about",()=>{const s=i(JSON.stringify(a()));t(s?.pending).toMatchObject({toolId:"zustand",action:"setState",label:"Update the Pok\xE9 Mart bag store",params:{storeName:"bag",data:{lines:[]}}})});o("is saved again after it has already been restored once",()=>{t(a({restored:true}).pending).toBeTruthy()});o("is dropped rather than scrubbed when the call carries a credential",()=>{const s=a({params:{key:"auth",value:"Bearer abcdefghijklmnop123456"}});t(s.pending).toBeNull();t(JSON.stringify(s)).not.toContain("abcdefghijklmnop123456")});o("reads back as absent from a transcript written before it existed",()=>{const s=r([n()]);t(i(JSON.stringify(s))?.pending).toBeNull()});o("refuses a malformed one rather than restoring half a question",()=>{const s=JSON.stringify({...r([n()]),pending:{toolId:"zustand"}});t(i(s)?.pending).toBeNull()})});d("the effect ledger",()=>{const e={id:"fx-1-1",at:1,toolId:"storage",action:"async.setItem",effect:{kind:"storage-write",toolId:"storage",action:"async.setItem",label:"Save @qa/key",key:"@qa/key",had:true,previous:"old value"}};const a=s=>g({messages:[n()],history:[],answers:{},usage:{input:0,output:0,requests:0},ledger:s});o("survives the round trip with the prior value an undo needs",()=>{const s=i(JSON.stringify(a([e])));t(s?.ledger).toHaveLength(1);t(s?.ledger?.[0]).toMatchObject({toolId:"storage",action:"async.setItem"})});o("drops an entry holding a credential rather than rewriting it",()=>{const s={...e,effect:{...e.effect,previous:"Bearer abcdefghijklmnop123456"}};const l=a([s]);t(l.ledger).toBeUndefined();t(JSON.stringify(l)).not.toContain("abcdefghijklmnop123456")});o("reads back as absent from a transcript written before it existed",()=>{t(i(JSON.stringify(r([n()])))?.ledger).toBeUndefined()})});
@@ -1,150 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * How the store folds a turn into one bubble.
5
- *
6
- * Both rules here were written from a real transcript: rounds of an answer
7
- * arriving as separate text events were concatenated into
8
- * "…resets every launch.Here's the full picture…", and a turn the user
9
- * stopped was reported as "Couldn't reach your AI endpoint."
10
- */
11
- import { beforeEach, describe, expect, it } from "vitest";
12
- import { askBuoyStore, queuePauseReason } from "./askBuoyStore";
13
- beforeEach(() => askBuoyStore.reset());
14
- const lastText = () => askBuoyStore.getState().messages.at(-1)?.text ?? "";
15
- describe("round boundaries", () => {
16
- it("opens a paragraph when the engine says a new round began", () => {
17
- const id = askBuoyStore.startAssistant();
18
- askBuoyStore.applyEvent(id, {
19
- type: "text",
20
- delta: "Wiping storage now."
21
- });
22
- askBuoyStore.applyEvent(id, {
23
- type: "text",
24
- delta: "No problem — I left it alone.",
25
- breakBefore: true
26
- });
27
- expect(lastText()).toBe("Wiping storage now.\n\nNo problem — I left it alone.");
28
- });
29
- it("still streams deltas within one round straight together", () => {
30
- const id = askBuoyStore.startAssistant();
31
- askBuoyStore.applyEvent(id, {
32
- type: "text",
33
- delta: "Hello"
34
- });
35
- askBuoyStore.applyEvent(id, {
36
- type: "text",
37
- delta: " there."
38
- });
39
- expect(lastText()).toBe("Hello there.");
40
- });
41
- it("never opens with a blank line", () => {
42
- const id = askBuoyStore.startAssistant();
43
- askBuoyStore.applyEvent(id, {
44
- type: "text",
45
- delta: "First words.",
46
- breakBefore: true
47
- });
48
- expect(lastText()).toBe("First words.");
49
- });
50
- });
51
- describe("a declined call", () => {
52
- it("keeps its row and reads as declined, not failed", () => {
53
- const id = askBuoyStore.startAssistant();
54
- askBuoyStore.applyEvent(id, {
55
- type: "tool-start",
56
- id: "c1",
57
- toolId: "storage",
58
- action: "clearAll",
59
- label: "Clear all saved app data",
60
- description: "Wipe every stored key",
61
- params: {},
62
- effect: "destructive"
63
- });
64
- askBuoyStore.applyEvent(id, {
65
- type: "tool-end",
66
- id: "c1",
67
- ok: false,
68
- summary: "declined",
69
- durationMs: 0
70
- });
71
- expect(askBuoyStore.getState().messages.at(-1)?.toolCalls[0]).toMatchObject({
72
- label: "Clear all saved app data",
73
- status: "declined"
74
- });
75
- });
76
- });
77
- describe("stop", () => {
78
- it("marks the turn stopped and leaves no error on it", () => {
79
- const id = askBuoyStore.startAssistant();
80
- askBuoyStore.applyEvent(id, {
81
- type: "text",
82
- delta: "Looking…"
83
- });
84
- askBuoyStore.markStopped(id);
85
- const m = askBuoyStore.getState().messages.at(-1);
86
- expect(m?.stopped).toBe(true);
87
- expect(m?.error).toBeUndefined();
88
- });
89
- });
90
-
91
- /**
92
- * Stop must not launch the messages parked behind it.
93
- *
94
- * Ending a turn is exactly what flushes the queue, so Stop used to send the
95
- * parked message and start a NEW turn — pressing Stop made the agent start
96
- * talking again. The queue now HOLDS after a stop (see `queuePauseReason`),
97
- * and the words stay visible as rows rather than being dumped into the
98
- * composer.
99
- */
100
- describe("stop and the queue", () => {
101
- it("keeps parked messages parked, and says why", () => {
102
- askBuoyStore.addUser("first");
103
- const id = askBuoyStore.startAssistant();
104
- askBuoyStore.enqueue("do this next");
105
- askBuoyStore.requestStop();
106
- askBuoyStore.markStopped(id);
107
- askBuoyStore.finishAssistant(id);
108
- const s = askBuoyStore.getState();
109
- expect(s.queued.map(q => q.text)).toEqual(["do this next"]);
110
- expect(queuePauseReason(s)).toMatch(/stopped/);
111
- });
112
- it("hands one parked message back to the composer to edit", () => {
113
- const item = askBuoyStore.enqueue("words");
114
- askBuoyStore.takeQueuedToDraft(item.id);
115
- expect(askBuoyStore.getState().queued).toEqual([]);
116
- expect(askBuoyStore.getState().draft).toBe("words");
117
- askBuoyStore.clearDraft();
118
- expect(askBuoyStore.getState().draft).toBeNull();
119
- });
120
- });
121
-
122
- /**
123
- * A restored bubble is marked, because the MODEL does not remember it the way
124
- * the screen does — see `ChatMessage.restored`.
125
- */
126
- describe("hydrate", () => {
127
- it("marks what it puts back", () => {
128
- askBuoyStore.hydrate({
129
- messages: [{
130
- id: "m1",
131
- role: "assistant",
132
- text: "hi",
133
- toolCalls: [],
134
- blocks: []
135
- }],
136
- answers: {},
137
- usage: {
138
- input: 0,
139
- output: 0,
140
- requests: 0
141
- }
142
- });
143
- expect(askBuoyStore.getState().messages[0]?.restored).toBe(true);
144
- });
145
- it("leaves a live message unmarked", () => {
146
- askBuoyStore.addUser("live one");
147
- expect(askBuoyStore.getState().messages[0]?.restored).toBeUndefined();
148
- });
149
- });
150
- //# sourceMappingURL=turnRendering.test.js.map
1
+ "use strict";import{beforeEach as l,describe as r,expect as a,it as s}from"vitest";import{askBuoyStore as e,queuePauseReason as i}from"./askBuoyStore";l(()=>e.reset());const n=()=>e.getState().messages.at(-1)?.text??"";r("round boundaries",()=>{s("opens a paragraph when the engine says a new round began",()=>{const t=e.startAssistant();e.applyEvent(t,{type:"text",delta:"Wiping storage now."});e.applyEvent(t,{type:"text",delta:"No problem \u2014 I left it alone.",breakBefore:true});a(n()).toBe("Wiping storage now.\n\nNo problem \u2014 I left it alone.")});s("still streams deltas within one round straight together",()=>{const t=e.startAssistant();e.applyEvent(t,{type:"text",delta:"Hello"});e.applyEvent(t,{type:"text",delta:" there."});a(n()).toBe("Hello there.")});s("never opens with a blank line",()=>{const t=e.startAssistant();e.applyEvent(t,{type:"text",delta:"First words.",breakBefore:true});a(n()).toBe("First words.")})});r("a declined call",()=>{s("keeps its row and reads as declined, not failed",()=>{const t=e.startAssistant();e.applyEvent(t,{type:"tool-start",id:"c1",toolId:"storage",action:"clearAll",label:"Clear all saved app data",description:"Wipe every stored key",params:{},effect:"destructive"});e.applyEvent(t,{type:"tool-end",id:"c1",ok:false,summary:"declined",durationMs:0});a(e.getState().messages.at(-1)?.toolCalls[0]).toMatchObject({label:"Clear all saved app data",status:"declined"})})});r("stop",()=>{s("marks the turn stopped and leaves no error on it",()=>{const t=e.startAssistant();e.applyEvent(t,{type:"text",delta:"Looking\u2026"});e.markStopped(t);const o=e.getState().messages.at(-1);a(o?.stopped).toBe(true);a(o?.error).toBeUndefined()})});r("stop and the queue",()=>{s("keeps parked messages parked, and says why",()=>{e.addUser("first");const t=e.startAssistant();e.enqueue("do this next");e.requestStop();e.markStopped(t);e.finishAssistant(t);const o=e.getState();a(o.queued.map(d=>d.text)).toEqual(["do this next"]);a(i(o)).toMatch(/stopped/)});s("hands one parked message back to the composer to edit",()=>{const t=e.enqueue("words");e.takeQueuedToDraft(t.id);a(e.getState().queued).toEqual([]);a(e.getState().draft).toBe("words");e.clearDraft();a(e.getState().draft).toBeNull()})});r("hydrate",()=>{s("marks what it puts back",()=>{e.hydrate({messages:[{id:"m1",role:"assistant",text:"hi",toolCalls:[],blocks:[]}],answers:{},usage:{input:0,output:0,requests:0}});a(e.getState().messages[0]?.restored).toBe(true)});s("leaves a live message unmarked",()=>{e.addUser("live one");a(e.getState().messages[0]?.restored).toBeUndefined()})});