@buoy-gg/ask-buoy 7.0.38 → 7.0.39

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 (306) hide show
  1. package/lib/commonjs/blocks/AskBlocks.js +338 -1
  2. package/lib/commonjs/blocks/AskBlocks.js.map +1 -0
  3. package/lib/commonjs/blocks/BlockRenderer.js +262 -1
  4. package/lib/commonjs/blocks/BlockRenderer.js.map +1 -0
  5. package/lib/commonjs/blocks/ChromePrototypes.js +514 -1
  6. package/lib/commonjs/blocks/ChromePrototypes.js.map +1 -0
  7. package/lib/commonjs/blocks/DataBlocks.js +781 -1
  8. package/lib/commonjs/blocks/DataBlocks.js.map +1 -0
  9. package/lib/commonjs/blocks/ExtraBlocks.js +1860 -1
  10. package/lib/commonjs/blocks/ExtraBlocks.js.map +1 -0
  11. package/lib/commonjs/blocks/MediaBlocks.js +156 -1
  12. package/lib/commonjs/blocks/MediaBlocks.js.map +1 -0
  13. package/lib/commonjs/blocks/ReceiptBlocks.js +586 -1
  14. package/lib/commonjs/blocks/ReceiptBlocks.js.map +1 -0
  15. package/lib/commonjs/blocks/blockText.js +60 -1
  16. package/lib/commonjs/blocks/blockText.js.map +1 -0
  17. package/lib/commonjs/blocks/blockText.test.js +53 -1
  18. package/lib/commonjs/blocks/blockText.test.js.map +1 -0
  19. package/lib/commonjs/blocks/context.js +42 -1
  20. package/lib/commonjs/blocks/context.js.map +1 -0
  21. package/lib/commonjs/blocks/icons.js +96 -1
  22. package/lib/commonjs/blocks/icons.js.map +1 -0
  23. package/lib/commonjs/blocks/index.js +95 -1
  24. package/lib/commonjs/blocks/index.js.map +1 -0
  25. package/lib/commonjs/blocks/listRow.test.js +55 -1
  26. package/lib/commonjs/blocks/listRow.test.js.map +1 -0
  27. package/lib/commonjs/blocks/pageState.js +34 -1
  28. package/lib/commonjs/blocks/pageState.js.map +1 -0
  29. package/lib/commonjs/blocks/pageState.test.js +57 -1
  30. package/lib/commonjs/blocks/pageState.test.js.map +1 -0
  31. package/lib/commonjs/blocks/primitives.js +457 -1
  32. package/lib/commonjs/blocks/primitives.js.map +1 -0
  33. package/lib/commonjs/blocks/primitivesIndex.js +62 -1
  34. package/lib/commonjs/blocks/primitivesIndex.js.map +1 -0
  35. package/lib/commonjs/components/ApprovalCard.js +297 -1
  36. package/lib/commonjs/components/ApprovalCard.js.map +1 -0
  37. package/lib/commonjs/components/AskBuoyHeader.js +196 -1
  38. package/lib/commonjs/components/AskBuoyHeader.js.map +1 -0
  39. package/lib/commonjs/components/AskBuoyIcon.js +19 -1
  40. package/lib/commonjs/components/AskBuoyIcon.js.map +1 -0
  41. package/lib/commonjs/components/AskBuoyModal.js +479 -1
  42. package/lib/commonjs/components/AskBuoyModal.js.map +1 -0
  43. package/lib/commonjs/components/AskBuoySettings.js +181 -1
  44. package/lib/commonjs/components/AskBuoySettings.js.map +1 -0
  45. package/lib/commonjs/components/ChangesBar.js +211 -1
  46. package/lib/commonjs/components/ChangesBar.js.map +1 -0
  47. package/lib/commonjs/components/Composer.js +255 -1
  48. package/lib/commonjs/components/Composer.js.map +1 -0
  49. package/lib/commonjs/components/EmptyState.js +161 -1
  50. package/lib/commonjs/components/EmptyState.js.map +1 -0
  51. package/lib/commonjs/components/KeyboardPad.js +80 -1
  52. package/lib/commonjs/components/KeyboardPad.js.map +1 -0
  53. package/lib/commonjs/components/Markdown.js +310 -1
  54. package/lib/commonjs/components/Markdown.js.map +1 -0
  55. package/lib/commonjs/components/MessageList.js +970 -1
  56. package/lib/commonjs/components/MessageList.js.map +1 -0
  57. package/lib/commonjs/components/QueuedMessages.js +145 -1
  58. package/lib/commonjs/components/QueuedMessages.js.map +1 -0
  59. package/lib/commonjs/components/ThinkingStrip.js +223 -1
  60. package/lib/commonjs/components/ThinkingStrip.js.map +1 -0
  61. package/lib/commonjs/components/TypingDots.js +63 -1
  62. package/lib/commonjs/components/TypingDots.js.map +1 -0
  63. package/lib/commonjs/components/markdownParse.js +131 -1
  64. package/lib/commonjs/components/markdownParse.js.map +1 -0
  65. package/lib/commonjs/components/markdownParse.test.js +99 -1
  66. package/lib/commonjs/components/markdownParse.test.js.map +1 -0
  67. package/lib/commonjs/components/useCopyAction.js +50 -1
  68. package/lib/commonjs/components/useCopyAction.js.map +1 -0
  69. package/lib/commonjs/index.js +252 -1
  70. package/lib/commonjs/index.js.map +1 -0
  71. package/lib/commonjs/preset.js +91 -1
  72. package/lib/commonjs/preset.js.map +1 -0
  73. package/lib/commonjs/store/activityGroups.js +110 -1
  74. package/lib/commonjs/store/activityGroups.js.map +1 -0
  75. package/lib/commonjs/store/activityGroups.test.js +78 -1
  76. package/lib/commonjs/store/activityGroups.test.js.map +1 -0
  77. package/lib/commonjs/store/askBuoySettings.js +72 -1
  78. package/lib/commonjs/store/askBuoySettings.js.map +1 -0
  79. package/lib/commonjs/store/askBuoyStore.js +589 -1
  80. package/lib/commonjs/store/askBuoyStore.js.map +1 -0
  81. package/lib/commonjs/store/blockPlacement.js +64 -1
  82. package/lib/commonjs/store/blockPlacement.js.map +1 -0
  83. package/lib/commonjs/store/blockPlacement.test.js +123 -1
  84. package/lib/commonjs/store/blockPlacement.test.js.map +1 -0
  85. package/lib/commonjs/store/queue.test.js +150 -1
  86. package/lib/commonjs/store/queue.test.js.map +1 -0
  87. package/lib/commonjs/store/resetConversation.js +77 -1
  88. package/lib/commonjs/store/resetConversation.js.map +1 -0
  89. package/lib/commonjs/store/restorePending.test.js +63 -1
  90. package/lib/commonjs/store/restorePending.test.js.map +1 -0
  91. package/lib/commonjs/store/restoredIds.test.js +47 -1
  92. package/lib/commonjs/store/restoredIds.test.js.map +1 -0
  93. package/lib/commonjs/store/suggestions.js +54 -1
  94. package/lib/commonjs/store/suggestions.js.map +1 -0
  95. package/lib/commonjs/store/suggestions.test.js +58 -1
  96. package/lib/commonjs/store/suggestions.test.js.map +1 -0
  97. package/lib/commonjs/store/systemLine.test.js +77 -1
  98. package/lib/commonjs/store/systemLine.test.js.map +1 -0
  99. package/lib/commonjs/store/ticketPrompt.js +17 -1
  100. package/lib/commonjs/store/ticketPrompt.js.map +1 -0
  101. package/lib/commonjs/store/traceText.js +81 -1
  102. package/lib/commonjs/store/traceText.js.map +1 -0
  103. package/lib/commonjs/store/traceText.test.js +112 -1
  104. package/lib/commonjs/store/traceText.test.js.map +1 -0
  105. package/lib/commonjs/store/transcriptPersistence.js +297 -1
  106. package/lib/commonjs/store/transcriptPersistence.js.map +1 -0
  107. package/lib/commonjs/store/transcriptPersistence.test.js +333 -1
  108. package/lib/commonjs/store/transcriptPersistence.test.js.map +1 -0
  109. package/lib/commonjs/store/turnRendering.test.js +151 -1
  110. package/lib/commonjs/store/turnRendering.test.js.map +1 -0
  111. package/lib/commonjs/store/useAskBuoy.js +651 -1
  112. package/lib/commonjs/store/useAskBuoy.js.map +1 -0
  113. package/lib/commonjs/store/useAskBuoySettings.js +14 -1
  114. package/lib/commonjs/store/useAskBuoySettings.js.map +1 -0
  115. package/lib/commonjs/sync/askBuoySyncAdapter.js +153 -1
  116. package/lib/commonjs/sync/askBuoySyncAdapter.js.map +1 -0
  117. package/lib/commonjs/sync/askBuoySyncAdapter.test.js +141 -1
  118. package/lib/commonjs/sync/askBuoySyncAdapter.test.js.map +1 -0
  119. package/lib/commonjs/sync/wire.js +58 -1
  120. package/lib/commonjs/sync/wire.js.map +1 -0
  121. package/lib/commonjs/types.js +6 -1
  122. package/lib/commonjs/types.js.map +1 -0
  123. package/lib/module/blocks/AskBlocks.js +331 -1
  124. package/lib/module/blocks/AskBlocks.js.map +1 -0
  125. package/lib/module/blocks/BlockRenderer.js +257 -1
  126. package/lib/module/blocks/BlockRenderer.js.map +1 -0
  127. package/lib/module/blocks/ChromePrototypes.js +503 -1
  128. package/lib/module/blocks/ChromePrototypes.js.map +1 -0
  129. package/lib/module/blocks/DataBlocks.js +767 -1
  130. package/lib/module/blocks/DataBlocks.js.map +1 -0
  131. package/lib/module/blocks/ExtraBlocks.js +1833 -1
  132. package/lib/module/blocks/ExtraBlocks.js.map +1 -0
  133. package/lib/module/blocks/MediaBlocks.js +151 -1
  134. package/lib/module/blocks/MediaBlocks.js.map +1 -0
  135. package/lib/module/blocks/ReceiptBlocks.js +574 -1
  136. package/lib/module/blocks/ReceiptBlocks.js.map +1 -0
  137. package/lib/module/blocks/blockText.js +55 -1
  138. package/lib/module/blocks/blockText.js.map +1 -0
  139. package/lib/module/blocks/blockText.test.js +53 -1
  140. package/lib/module/blocks/blockText.test.js.map +1 -0
  141. package/lib/module/blocks/context.js +35 -1
  142. package/lib/module/blocks/context.js.map +1 -0
  143. package/lib/module/blocks/icons.js +91 -1
  144. package/lib/module/blocks/icons.js.map +1 -0
  145. package/lib/module/blocks/index.js +8 -1
  146. package/lib/module/blocks/index.js.map +1 -0
  147. package/lib/module/blocks/listRow.test.js +56 -1
  148. package/lib/module/blocks/listRow.test.js.map +1 -0
  149. package/lib/module/blocks/pageState.js +30 -1
  150. package/lib/module/blocks/pageState.js.map +1 -0
  151. package/lib/module/blocks/pageState.test.js +56 -1
  152. package/lib/module/blocks/pageState.test.js.map +1 -0
  153. package/lib/module/blocks/primitives.js +445 -1
  154. package/lib/module/blocks/primitives.js.map +1 -0
  155. package/lib/module/blocks/primitivesIndex.js +5 -1
  156. package/lib/module/blocks/primitivesIndex.js.map +1 -0
  157. package/lib/module/components/ApprovalCard.js +292 -1
  158. package/lib/module/components/ApprovalCard.js.map +1 -0
  159. package/lib/module/components/AskBuoyHeader.js +193 -1
  160. package/lib/module/components/AskBuoyHeader.js.map +1 -0
  161. package/lib/module/components/AskBuoyIcon.js +8 -1
  162. package/lib/module/components/AskBuoyIcon.js.map +1 -0
  163. package/lib/module/components/AskBuoyModal.js +474 -1
  164. package/lib/module/components/AskBuoyModal.js.map +1 -0
  165. package/lib/module/components/AskBuoySettings.js +176 -1
  166. package/lib/module/components/AskBuoySettings.js.map +1 -0
  167. package/lib/module/components/ChangesBar.js +206 -1
  168. package/lib/module/components/ChangesBar.js.map +1 -0
  169. package/lib/module/components/Composer.js +250 -1
  170. package/lib/module/components/Composer.js.map +1 -0
  171. package/lib/module/components/EmptyState.js +156 -1
  172. package/lib/module/components/EmptyState.js.map +1 -0
  173. package/lib/module/components/KeyboardPad.js +75 -1
  174. package/lib/module/components/KeyboardPad.js.map +1 -0
  175. package/lib/module/components/Markdown.js +305 -1
  176. package/lib/module/components/Markdown.js.map +1 -0
  177. package/lib/module/components/MessageList.js +964 -1
  178. package/lib/module/components/MessageList.js.map +1 -0
  179. package/lib/module/components/QueuedMessages.js +140 -1
  180. package/lib/module/components/QueuedMessages.js.map +1 -0
  181. package/lib/module/components/ThinkingStrip.js +218 -1
  182. package/lib/module/components/ThinkingStrip.js.map +1 -0
  183. package/lib/module/components/TypingDots.js +58 -1
  184. package/lib/module/components/TypingDots.js.map +1 -0
  185. package/lib/module/components/markdownParse.js +125 -1
  186. package/lib/module/components/markdownParse.js.map +1 -0
  187. package/lib/module/components/markdownParse.test.js +98 -1
  188. package/lib/module/components/markdownParse.test.js.map +1 -0
  189. package/lib/module/components/useCopyAction.js +46 -1
  190. package/lib/module/components/useCopyAction.js.map +1 -0
  191. package/lib/module/index.js +34 -1
  192. package/lib/module/index.js.map +1 -0
  193. package/lib/module/preset.js +74 -1
  194. package/lib/module/preset.js.map +1 -0
  195. package/lib/module/store/activityGroups.js +103 -1
  196. package/lib/module/store/activityGroups.js.map +1 -0
  197. package/lib/module/store/activityGroups.test.js +77 -1
  198. package/lib/module/store/activityGroups.test.js.map +1 -0
  199. package/lib/module/store/askBuoySettings.js +67 -1
  200. package/lib/module/store/askBuoySettings.js.map +1 -0
  201. package/lib/module/store/askBuoyStore.js +583 -1
  202. package/lib/module/store/askBuoyStore.js.map +1 -0
  203. package/lib/module/store/blockPlacement.js +59 -1
  204. package/lib/module/store/blockPlacement.js.map +1 -0
  205. package/lib/module/store/blockPlacement.test.js +122 -1
  206. package/lib/module/store/blockPlacement.test.js.map +1 -0
  207. package/lib/module/store/queue.test.js +149 -1
  208. package/lib/module/store/queue.test.js.map +1 -0
  209. package/lib/module/store/resetConversation.js +72 -1
  210. package/lib/module/store/resetConversation.js.map +1 -0
  211. package/lib/module/store/restorePending.test.js +62 -1
  212. package/lib/module/store/restorePending.test.js.map +1 -0
  213. package/lib/module/store/restoredIds.test.js +46 -1
  214. package/lib/module/store/restoredIds.test.js.map +1 -0
  215. package/lib/module/store/suggestions.js +49 -1
  216. package/lib/module/store/suggestions.js.map +1 -0
  217. package/lib/module/store/suggestions.test.js +57 -1
  218. package/lib/module/store/suggestions.test.js.map +1 -0
  219. package/lib/module/store/systemLine.test.js +76 -1
  220. package/lib/module/store/systemLine.test.js.map +1 -0
  221. package/lib/module/store/ticketPrompt.js +13 -1
  222. package/lib/module/store/ticketPrompt.js.map +1 -0
  223. package/lib/module/store/traceText.js +75 -1
  224. package/lib/module/store/traceText.js.map +1 -0
  225. package/lib/module/store/traceText.test.js +111 -1
  226. package/lib/module/store/traceText.test.js.map +1 -0
  227. package/lib/module/store/transcriptPersistence.js +287 -1
  228. package/lib/module/store/transcriptPersistence.js.map +1 -0
  229. package/lib/module/store/transcriptPersistence.test.js +332 -1
  230. package/lib/module/store/transcriptPersistence.test.js.map +1 -0
  231. package/lib/module/store/turnRendering.test.js +150 -1
  232. package/lib/module/store/turnRendering.test.js.map +1 -0
  233. package/lib/module/store/useAskBuoy.js +646 -1
  234. package/lib/module/store/useAskBuoy.js.map +1 -0
  235. package/lib/module/store/useAskBuoySettings.js +9 -1
  236. package/lib/module/store/useAskBuoySettings.js.map +1 -0
  237. package/lib/module/sync/askBuoySyncAdapter.js +148 -1
  238. package/lib/module/sync/askBuoySyncAdapter.js.map +1 -0
  239. package/lib/module/sync/askBuoySyncAdapter.test.js +140 -1
  240. package/lib/module/sync/askBuoySyncAdapter.test.js.map +1 -0
  241. package/lib/module/sync/wire.js +47 -1
  242. package/lib/module/sync/wire.js.map +1 -0
  243. package/lib/module/types.js +4 -1
  244. package/lib/module/types.js.map +1 -0
  245. package/lib/typescript/blocks/AskBlocks.d.ts.map +1 -0
  246. package/lib/typescript/blocks/BlockRenderer.d.ts.map +1 -0
  247. package/lib/typescript/blocks/ChromePrototypes.d.ts.map +1 -0
  248. package/lib/typescript/blocks/DataBlocks.d.ts.map +1 -0
  249. package/lib/typescript/blocks/ExtraBlocks.d.ts.map +1 -0
  250. package/lib/typescript/blocks/MediaBlocks.d.ts.map +1 -0
  251. package/lib/typescript/blocks/ReceiptBlocks.d.ts.map +1 -0
  252. package/lib/typescript/blocks/blockText.d.ts.map +1 -0
  253. package/lib/typescript/blocks/blockText.test.d.ts.map +1 -0
  254. package/lib/typescript/blocks/context.d.ts.map +1 -0
  255. package/lib/typescript/blocks/icons.d.ts.map +1 -0
  256. package/lib/typescript/blocks/index.d.ts.map +1 -0
  257. package/lib/typescript/blocks/listRow.test.d.ts.map +1 -0
  258. package/lib/typescript/blocks/pageState.d.ts.map +1 -0
  259. package/lib/typescript/blocks/pageState.test.d.ts.map +1 -0
  260. package/lib/typescript/blocks/primitives.d.ts.map +1 -0
  261. package/lib/typescript/blocks/primitivesIndex.d.ts.map +1 -0
  262. package/lib/typescript/components/ApprovalCard.d.ts.map +1 -0
  263. package/lib/typescript/components/AskBuoyHeader.d.ts.map +1 -0
  264. package/lib/typescript/components/AskBuoyIcon.d.ts.map +1 -0
  265. package/lib/typescript/components/AskBuoyModal.d.ts.map +1 -0
  266. package/lib/typescript/components/AskBuoySettings.d.ts.map +1 -0
  267. package/lib/typescript/components/ChangesBar.d.ts.map +1 -0
  268. package/lib/typescript/components/Composer.d.ts.map +1 -0
  269. package/lib/typescript/components/EmptyState.d.ts.map +1 -0
  270. package/lib/typescript/components/KeyboardPad.d.ts.map +1 -0
  271. package/lib/typescript/components/Markdown.d.ts.map +1 -0
  272. package/lib/typescript/components/MessageList.d.ts.map +1 -0
  273. package/lib/typescript/components/QueuedMessages.d.ts.map +1 -0
  274. package/lib/typescript/components/ThinkingStrip.d.ts.map +1 -0
  275. package/lib/typescript/components/TypingDots.d.ts.map +1 -0
  276. package/lib/typescript/components/markdownParse.d.ts.map +1 -0
  277. package/lib/typescript/components/markdownParse.test.d.ts.map +1 -0
  278. package/lib/typescript/components/useCopyAction.d.ts.map +1 -0
  279. package/lib/typescript/index.d.ts.map +1 -0
  280. package/lib/typescript/preset.d.ts.map +1 -0
  281. package/lib/typescript/store/activityGroups.d.ts.map +1 -0
  282. package/lib/typescript/store/activityGroups.test.d.ts.map +1 -0
  283. package/lib/typescript/store/askBuoySettings.d.ts.map +1 -0
  284. package/lib/typescript/store/askBuoyStore.d.ts.map +1 -0
  285. package/lib/typescript/store/blockPlacement.d.ts.map +1 -0
  286. package/lib/typescript/store/blockPlacement.test.d.ts.map +1 -0
  287. package/lib/typescript/store/queue.test.d.ts.map +1 -0
  288. package/lib/typescript/store/resetConversation.d.ts.map +1 -0
  289. package/lib/typescript/store/restorePending.test.d.ts.map +1 -0
  290. package/lib/typescript/store/restoredIds.test.d.ts.map +1 -0
  291. package/lib/typescript/store/suggestions.d.ts.map +1 -0
  292. package/lib/typescript/store/suggestions.test.d.ts.map +1 -0
  293. package/lib/typescript/store/systemLine.test.d.ts.map +1 -0
  294. package/lib/typescript/store/ticketPrompt.d.ts.map +1 -0
  295. package/lib/typescript/store/traceText.d.ts.map +1 -0
  296. package/lib/typescript/store/traceText.test.d.ts.map +1 -0
  297. package/lib/typescript/store/transcriptPersistence.d.ts.map +1 -0
  298. package/lib/typescript/store/transcriptPersistence.test.d.ts.map +1 -0
  299. package/lib/typescript/store/turnRendering.test.d.ts.map +1 -0
  300. package/lib/typescript/store/useAskBuoy.d.ts.map +1 -0
  301. package/lib/typescript/store/useAskBuoySettings.d.ts.map +1 -0
  302. package/lib/typescript/sync/askBuoySyncAdapter.d.ts.map +1 -0
  303. package/lib/typescript/sync/askBuoySyncAdapter.test.d.ts.map +1 -0
  304. package/lib/typescript/sync/wire.d.ts.map +1 -0
  305. package/lib/typescript/types.d.ts.map +1 -0
  306. package/package.json +8 -8
@@ -1 +1,287 @@
1
- "use strict";import{persistentStorage,devToolsStorageKeys}from"@buoy-gg/shared-ui";import{redactForWire}from"../sync/wire";export const TRANSCRIPT_KEY=`${devToolsStorageKeys.base}_ask_buoy_transcript`;const VERSION=1,MAX_MESSAGES=60,MAX_BYTES=256e3,DROPPED_RESULT="[not kept across a restart — read it again if you need it]";function scrub(t){return t?redactForWire(t):t}function settle(t){const e=!0===t.streaming;return{...t,text:scrub(t.text),streaming:!1,reasoning:t.reasoning?.map(t=>({...t,text:scrub(t.text)})),toolCalls:t.toolCalls.map(t=>{const e=t.params?scrub(t.params):void 0,{result:r,...s}=t;return"running"===t.status?{...s,params:e,status:"failed",summary:"Interrupted"}:{...s,params:e}}),error:t.error??(e&&!t.text?"This answer was interrupted — the app restarted mid-turn.":void 0)}}function withoutResults(t){return t.map(t=>"tool-results"===t.role?{...t,results:t.results.map(t=>({...t,content:DROPPED_RESULT}))}:(t.role,{...t,text:scrub(t.text)}))}export function fitToCaps(t){let e={...t,messages:t.messages.slice(-60),history:t.history.slice(-120)},r=JSON.stringify(e);for(;r.length>256e3&&e.messages.length>1;)e={...e,messages:e.messages.slice(1),history:e.history.slice(Math.min(2,e.history.length))},r=JSON.stringify(e);return e}function storableApproval(t){if(!t)return null;const e=t.params;if(!e)return null;let r;try{r=JSON.stringify(e)}catch{return null}return redactForWire(r)!==r?null:{id:t.id,toolId:t.toolId,action:t.action,label:scrub(t.label),description:t.description?scrub(t.description):void 0,reason:scrub(t.reason),params:e,targetDigest:t.targetDigest}}function isStoredApproval(t){if("object"!=typeof t||null===t)return!1;const e=t;return"string"==typeof e.id&&"string"==typeof e.toolId&&"string"==typeof e.action&&"string"==typeof e.label&&"string"==typeof e.reason&&"object"==typeof e.params&&null!==e.params}function storableLedger(t){if(!t?.length)return;const e=t.filter(t=>{try{const e=JSON.stringify(t);return redactForWire(e)===e}catch{return!1}});return e.length?e:void 0}export function buildPayload(t){return fitToCaps({v:1,savedAt:Date.now(),messages:t.messages.map(settle),history:withoutResults(t.history),answers:t.answers,usage:t.usage,pending:storableApproval(t.pending),ledger:storableLedger(t.ledger),queued:t.queued?.length?t.queued.map(t=>({id:t.id,text:scrub(t.text)})):void 0})}export function parsePayload(t){if(!t)return null;try{const e=JSON.parse(t);return 1===e?.v&&Array.isArray(e.messages)?0===e.messages.length?null:{v:1,savedAt:"number"==typeof e.savedAt?e.savedAt:0,messages:e.messages,history:Array.isArray(e.history)?e.history:[],answers:e.answers??{},usage:e.usage??{input:0,output:0,requests:0},pending:isStoredApproval(e.pending)?e.pending:null,ledger:Array.isArray(e.ledger)?e.ledger.filter(t=>"object"==typeof t&&null!==t&&"string"==typeof t.id):void 0,queued:Array.isArray(e.queued)?e.queued.filter(t=>"object"==typeof t&&null!==t&&"string"==typeof t.id&&"string"==typeof t.text):void 0}:null}catch{return null}}export async function readTranscript(){try{return parsePayload(await persistentStorage.getItem(TRANSCRIPT_KEY))}catch{return null}}export async function writeTranscript(t){try{await persistentStorage.setItem(TRANSCRIPT_KEY,JSON.stringify(t))}catch{}}export async function clearTranscript(){try{await persistentStorage.removeItem(TRANSCRIPT_KEY)}catch{}}
1
+ "use strict";
2
+
3
+ /**
4
+ * The conversation, across a reload or a crash.
5
+ *
6
+ * This reverses a deliberate earlier decision, so the reasoning is worth
7
+ * stating. The transcript used to live only in memory because it can quote
8
+ * anything the agent read — a storage value, a response body, a customer
9
+ * record — and a Buoy key on disk is readable by the Storage tool, which the
10
+ * unauthenticated broker mirrors to every connected dashboard. That risk did
11
+ * not go away; it is now a trade the host app makes knowingly, and can decline
12
+ * with `askBuoy={{ persistTranscript: false }}`.
13
+ *
14
+ * What lowers it:
15
+ * - Tool RESULTS are never written. The model's saved history keeps the shape
16
+ * of each round (which tool ran, what it was asked) and replaces every result
17
+ * payload with a placeholder — so the agent resumes knowing what it did, not
18
+ * what it saw. Raw payloads are the sensitive part and they stay in memory.
19
+ * - Everything written passes `redactForWire`, the same credential scrubber the
20
+ * broker wire uses.
21
+ * - It is capped, oldest-first, so a long QA session cannot grow a file without
22
+ * bound.
23
+ * - "New conversation" deletes it, rather than leaving the last chat on disk.
24
+ */
25
+ import { persistentStorage, devToolsStorageKeys } from "@buoy-gg/shared-ui";
26
+ import { redactForWire } from "../sync/wire";
27
+
28
+ /** `@react_buoy` prefix, so the Storage tool treats it as one of its own. */
29
+ export const TRANSCRIPT_KEY = `${devToolsStorageKeys.base}_ask_buoy_transcript`;
30
+
31
+ /**
32
+ * Bumped when the saved shape changes; an older payload is dropped, not parsed.
33
+ *
34
+ * Purely ADDITIVE optional fields do not bump it — `pending` reads back as
35
+ * absent from a v1 file written before it existed, and throwing away someone's
36
+ * conversation to add a field they did not have is a worse trade than the one
37
+ * this version number exists to make.
38
+ */
39
+ const VERSION = 1;
40
+
41
+ /** Newest N bubbles. Beyond this a reader is scrolling history, not testing. */
42
+ const MAX_MESSAGES = 60;
43
+
44
+ /**
45
+ * Hard ceiling on the file. Blocks carry image URLs and table rows, so a
46
+ * message is not a small object; this is checked AFTER the message cap and
47
+ * drops from the oldest end until it fits.
48
+ */
49
+ const MAX_BYTES = 256_000;
50
+
51
+ /** What replaces a tool result. Addressed to the model, which will read it. */
52
+ const DROPPED_RESULT = "[not kept across a restart — read it again if you need it]";
53
+
54
+ /**
55
+ * An approval the user never answered.
56
+ *
57
+ * Saved with the conversation because an unanswered question is exactly the
58
+ * state a reload must not quietly resolve for them: nothing was tapped, so the
59
+ * change is still pending as far as they know. `params` is the real call —
60
+ * after a restart there is no turn left to resume, so Allow re-dispatches it.
61
+ */
62
+
63
+ function scrub(text) {
64
+ return text ? redactForWire(text) : text;
65
+ }
66
+
67
+ /**
68
+ * A bubble as it should look after a restart.
69
+ *
70
+ * `streaming` is cleared because nothing is streaming into a bubble the app
71
+ * has just rebuilt, and a message caught mid-turn is marked as interrupted
72
+ * rather than left looking like a silent, empty answer — which is exactly the
73
+ * crash case this feature exists for. `actionState` is not saved at all: a
74
+ * button stuck on "running" would be a lie about work that died with the
75
+ * process.
76
+ */
77
+ function settle(m) {
78
+ const cutOff = m.streaming === true;
79
+ return {
80
+ ...m,
81
+ text: scrub(m.text),
82
+ streaming: false,
83
+ // The thinking view's payloads go through the same scrubber as the answer:
84
+ // step parameters carry whatever the model passed a tool, which is exactly
85
+ // where a token ends up when the agent has been asked to set one.
86
+ reasoning: m.reasoning?.map(r => ({
87
+ ...r,
88
+ text: scrub(r.text)
89
+ })),
90
+ toolCalls: m.toolCalls.map(c => {
91
+ const params = c.params ? scrub(c.params) : undefined;
92
+ // `result` is dropped, never scrubbed. It is the tool payload itself —
93
+ // a store's whole state, a response body — and "tool results are never
94
+ // written to disk" is the promise this file is built on. It stays in
95
+ // memory for the thinking view and the JSON export.
96
+ const {
97
+ result: _dropped,
98
+ ...rest
99
+ } = c;
100
+ return c.status === "running" ? {
101
+ ...rest,
102
+ params,
103
+ status: "failed",
104
+ summary: "Interrupted"
105
+ } : {
106
+ ...rest,
107
+ params
108
+ };
109
+ }),
110
+ error: m.error ?? (cutOff && !m.text ? "This answer was interrupted — the app restarted mid-turn." : undefined)
111
+ };
112
+ }
113
+
114
+ /** Model history with every tool result replaced by a placeholder. */
115
+ function withoutResults(history) {
116
+ return history.map(m => {
117
+ if (m.role === "tool-results") {
118
+ return {
119
+ ...m,
120
+ results: m.results.map(r => ({
121
+ ...r,
122
+ content: DROPPED_RESULT
123
+ }))
124
+ };
125
+ }
126
+ if (m.role === "assistant") return {
127
+ ...m,
128
+ text: scrub(m.text)
129
+ };
130
+ return {
131
+ ...m,
132
+ text: scrub(m.text)
133
+ };
134
+ });
135
+ }
136
+
137
+ /**
138
+ * Trim to the caps. Messages and history are trimmed together and from the
139
+ * same end, so what the user sees and what the model remembers stay the same
140
+ * conversation rather than drifting apart across restarts.
141
+ */
142
+ export function fitToCaps(payload) {
143
+ let out = {
144
+ ...payload,
145
+ messages: payload.messages.slice(-MAX_MESSAGES),
146
+ history: payload.history.slice(-MAX_MESSAGES * 2)
147
+ };
148
+ let json = JSON.stringify(out);
149
+ while (json.length > MAX_BYTES && out.messages.length > 1) {
150
+ out = {
151
+ ...out,
152
+ messages: out.messages.slice(1),
153
+ history: out.history.slice(Math.min(2, out.history.length))
154
+ };
155
+ json = JSON.stringify(out);
156
+ }
157
+ return out;
158
+ }
159
+
160
+ /**
161
+ * The pending approval, if it is safe to bring back.
162
+ *
163
+ * Params are NOT scrubbed on the way out, and that is the point of the check:
164
+ * a redacted token written back into the call is no longer the change the user
165
+ * was asked about, so re-running it would apply something they never saw. A
166
+ * call the wire scrubber touches at all is therefore not persisted — an action
167
+ * carrying a credential is precisely the one that should not come back after a
168
+ * restart and run itself. The card is lost in that case, which is the same
169
+ * behaviour as before this existed.
170
+ */
171
+ function storableApproval(pending) {
172
+ // A RESTORED card is saved again too: reloading twice without answering must
173
+ // not be the thing that finally loses the question.
174
+ if (!pending) return null;
175
+ const params = pending.params;
176
+ if (!params) return null;
177
+ let json;
178
+ try {
179
+ json = JSON.stringify(params);
180
+ } catch {
181
+ return null;
182
+ }
183
+ if (redactForWire(json) !== json) return null;
184
+ return {
185
+ id: pending.id,
186
+ toolId: pending.toolId,
187
+ action: pending.action,
188
+ label: scrub(pending.label),
189
+ description: pending.description ? scrub(pending.description) : undefined,
190
+ reason: scrub(pending.reason),
191
+ params,
192
+ targetDigest: pending.targetDigest
193
+ };
194
+ }
195
+ function isStoredApproval(value) {
196
+ if (typeof value !== "object" || value === null) return false;
197
+ const v = value;
198
+ return typeof v.id === "string" && typeof v.toolId === "string" && typeof v.action === "string" && typeof v.label === "string" && typeof v.reason === "string" && typeof v.params === "object" && v.params !== null;
199
+ }
200
+
201
+ /**
202
+ * Ledger entries safe to write.
203
+ *
204
+ * Same rule as `storableApproval`: an entry the wire scrubber would touch
205
+ * carries a credential in the value it is holding for the undo, and scrubbing
206
+ * it would make the undo restore a redacted string over the real one. Such an
207
+ * entry is dropped rather than rewritten — losing an undo is recoverable,
208
+ * writing "[redacted]" into the user's storage is not.
209
+ */
210
+ function storableLedger(entries) {
211
+ if (!entries?.length) return undefined;
212
+ const kept = entries.filter(e => {
213
+ try {
214
+ const json = JSON.stringify(e);
215
+ return redactForWire(json) === json;
216
+ } catch {
217
+ return false;
218
+ }
219
+ });
220
+ return kept.length ? kept : undefined;
221
+ }
222
+ export function buildPayload(input) {
223
+ return fitToCaps({
224
+ v: VERSION,
225
+ savedAt: Date.now(),
226
+ messages: input.messages.map(settle),
227
+ history: withoutResults(input.history),
228
+ answers: input.answers,
229
+ usage: input.usage,
230
+ pending: storableApproval(input.pending),
231
+ ledger: storableLedger(input.ledger),
232
+ queued: input.queued?.length ? input.queued.map(q => ({
233
+ id: q.id,
234
+ text: scrub(q.text)
235
+ })) : undefined
236
+ });
237
+ }
238
+
239
+ /** Anything unparseable, or from an older shape, is treated as "no transcript". */
240
+ export function parsePayload(raw) {
241
+ if (!raw) return null;
242
+ try {
243
+ const parsed = JSON.parse(raw);
244
+ if (parsed?.v !== VERSION || !Array.isArray(parsed.messages)) return null;
245
+ if (parsed.messages.length === 0) return null;
246
+ return {
247
+ v: VERSION,
248
+ savedAt: typeof parsed.savedAt === "number" ? parsed.savedAt : 0,
249
+ messages: parsed.messages,
250
+ history: Array.isArray(parsed.history) ? parsed.history : [],
251
+ answers: parsed.answers ?? {},
252
+ usage: parsed.usage ?? {
253
+ input: 0,
254
+ output: 0,
255
+ requests: 0
256
+ },
257
+ pending: isStoredApproval(parsed.pending) ? parsed.pending : null,
258
+ ledger: Array.isArray(parsed.ledger) ? parsed.ledger.filter(e => typeof e === "object" && e !== null && typeof e.id === "string") : undefined,
259
+ queued: Array.isArray(parsed.queued) ? parsed.queued.filter(q => typeof q === "object" && q !== null && typeof q.id === "string" && typeof q.text === "string") : undefined
260
+ };
261
+ } catch {
262
+ return null;
263
+ }
264
+ }
265
+ export async function readTranscript() {
266
+ try {
267
+ return parsePayload(await persistentStorage.getItem(TRANSCRIPT_KEY));
268
+ } catch {
269
+ return null;
270
+ }
271
+ }
272
+ export async function writeTranscript(payload) {
273
+ try {
274
+ await persistentStorage.setItem(TRANSCRIPT_KEY, JSON.stringify(payload));
275
+ } catch {
276
+ // A transcript that cannot be saved must never break the chat that
277
+ // produced it.
278
+ }
279
+ }
280
+ export async function clearTranscript() {
281
+ try {
282
+ await persistentStorage.removeItem(TRANSCRIPT_KEY);
283
+ } catch {
284
+ /* nothing to do — see writeTranscript */
285
+ }
286
+ }
287
+ //# sourceMappingURL=transcriptPersistence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["persistentStorage","devToolsStorageKeys","redactForWire","TRANSCRIPT_KEY","base","VERSION","MAX_MESSAGES","MAX_BYTES","DROPPED_RESULT","scrub","text","settle","m","cutOff","streaming","reasoning","map","r","toolCalls","c","params","undefined","result","_dropped","rest","status","summary","error","withoutResults","history","role","results","content","fitToCaps","payload","out","messages","slice","json","JSON","stringify","length","Math","min","storableApproval","pending","id","toolId","action","label","description","reason","targetDigest","isStoredApproval","value","v","storableLedger","entries","kept","filter","e","buildPayload","input","savedAt","Date","now","answers","usage","ledger","queued","q","parsePayload","raw","parsed","parse","Array","isArray","output","requests","readTranscript","getItem","writeTranscript","setItem","clearTranscript","removeItem"],"sourceRoot":"../../../src","sources":["store/transcriptPersistence.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,iBAAiB,EAAEC,mBAAmB,QAAQ,oBAAoB;AAI3E,SAASC,aAAa,QAAQ,cAAc;;AAE5C;AACA,OAAO,MAAMC,cAAc,GAAG,GAAGF,mBAAmB,CAACG,IAAI,sBAAsB;;AAE/E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,OAAO,GAAG,CAAC;;AAEjB;AACA,MAAMC,YAAY,GAAG,EAAE;;AAEvB;AACA;AACA;AACA;AACA;AACA,MAAMC,SAAS,GAAG,OAAO;;AAEzB;AACA,MAAMC,cAAc,GAAG,4DAA4D;;AAEnF;AAC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K,MAAM,CAACL,MAAM,CAACT,MAAM,CACjBC,CAAC,IACA,OAAOA,CAAC,KAAK,QAAQ,IAAIA,CAAC,KAAK,IAAI,IAAI,OAAQA,CAAC,CAAiBd,EAAE,KAAK,QAC5E,CAAC,GACDzB,SAAS;MACbgD,MAAM,EAAEM,KAAK,CAACC,OAAO,CAACH,MAAM,CAACJ,MAAM,CAAC,GAChCI,MAAM,CAACJ,MAAM,CAACV,MAAM,CACjBW,CAAC,IACA,OAAOA,CAAC,KAAK,QAAQ,IACrBA,CAAC,KAAK,IAAI,IACV,OAAQA,CAAC,CAAmBxB,EAAE,KAAK,QAAQ,IAC3C,OAAQwB,CAAC,CAAmB5D,IAAI,KAAK,QACzC,CAAC,GACDW;IACN,CAAC;EACH,CAAC,CAAC,MAAM;IACN,OAAO,IAAI;EACb;AACF;AAEA,OAAO,eAAe0D,cAAcA,CAAA,EAAqC;EACvE,IAAI;IACF,OAAOR,YAAY,CAAC,MAAMvE,iBAAiB,CAACgF,OAAO,CAAC7E,cAAc,CAAC,CAAC;EACtE,CAAC,CAAC,MAAM;IACN,OAAO,IAAI;EACb;AACF;AAEA,OAAO,eAAe8E,eAAeA,CAAC/C,OAAyB,EAAiB;EAC9E,IAAI;IACF,MAAMlC,iBAAiB,CAACkF,OAAO,CAAC/E,cAAc,EAAEoC,IAAI,CAACC,SAAS,CAACN,OAAO,CAAC,CAAC;EAC1E,CAAC,CAAC,MAAM;IACN;IACA;EAAA;AAEJ;AAEA,OAAO,eAAeiD,eAAeA,CAAA,EAAkB;EACrD,IAAI;IACF,MAAMnF,iBAAiB,CAACoF,UAAU,CAACjF,cAAc,CAAC;EACpD,CAAC,CAAC,MAAM;IACN;EAAA;AAEJ","ignoreList":[]}
@@ -1 +1,332 @@
1
- "use strict";import{describe,expect,it}from"vitest";import{buildPayload,fitToCaps,parsePayload}from"./transcriptPersistence";const msg=(e={})=>({id:"m1",role:"assistant",text:"ok",toolCalls:[],blocks:[],...e}),build=(e,t=[])=>buildPayload({messages:e,history:t,answers:{},usage:{input:0,output:0,requests:0}});describe("what reaches the disk",()=>{it("never writes a tool result",()=>{const e=build([msg()],[{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."}]),t=JSON.stringify(e);expect(t).not.toContain("4111111111111111"),expect(e.history.map(e=>e.role)).toEqual(["user","assistant","tool-results","assistant"])}),it("never writes a step's result, even when it writes the step",()=>{const e=build([msg({toolCalls:[{id:"c1",toolId:"zustand",action:"getStoreState",label:"Read the bag",status:"ok",summary:"Done",params:'{"storeName":"bag"}',result:'{"card":"4111111111111111"}'}]})]);expect(JSON.stringify(e)).not.toContain("4111111111111111"),expect(e.messages[0].toolCalls[0].result).toBeUndefined(),expect(e.messages[0].toolCalls[0].action).toBe("getStoreState")}),it("scrubs credential shapes out of what the agent said",()=>{const e=build([msg({text:"The header was Bearer abcdefghijklmnop123456"})]);expect(e.messages[0].text).not.toContain("abcdefghijklmnop123456")}),it("caps a long session instead of growing a file forever",()=>{const e=Array.from({length:400},(e,t)=>msg({id:`m${t}`,text:`answer ${t}`})),t=build(e);expect(t.messages.length).toBeLessThanOrEqual(60),expect(t.messages[t.messages.length-1].text).toBe("answer 399")}),it("drops from the oldest end until a heavy transcript fits",()=>{const e=Array.from({length:20},(e,t)=>msg({id:`m${t}`,text:"x".repeat(4e4)})),t=fitToCaps({v:1,savedAt:0,messages:e,history:[],answers:{},usage:{input:0,output:0,requests:0}});expect(JSON.stringify(t).length).toBeLessThanOrEqual(256e3),expect(t.messages.length).toBeGreaterThan(0)})}),describe("what comes back",()=>{it("marks a turn the app died in as interrupted rather than blank",()=>{const e=build([msg({text:"",streaming:!0})]);expect(e.messages[0].streaming).toBe(!1),expect(e.messages[0].error).toMatch(/interrupted/i)}),it("never restores a tool call still claiming to run",()=>{const e=build([msg({streaming:!0,toolCalls:[{id:"c1",toolId:"storage",action:"set",label:"Write a key",status:"running"}]})]);expect(e.messages[0].toolCalls[0].status).toBe("failed"),expect(e.messages[0].toolCalls[0].summary).toBe("Interrupted")}),it("keeps an answer that already finished exactly as it was",()=>{const e=build([msg({text:"Five items.",streaming:!1})]);expect(e.messages[0].error).toBeUndefined(),expect(e.messages[0].text).toBe("Five items.")}),it("treats anything it cannot trust as no transcript at all",()=>{expect(parsePayload(null)).toBeNull(),expect(parsePayload("not json")).toBeNull(),expect(parsePayload(JSON.stringify({v:0,messages:[msg()]}))).toBeNull(),expect(parsePayload(JSON.stringify({v:1,messages:[]}))).toBeNull()}),it("round-trips a real conversation",()=>{const e=build([msg({role:"user",text:"hi"}),msg({id:"m2",text:"hello"})]),t=parsePayload(JSON.stringify(e));expect(t?.messages.map(e=>e.text)).toEqual(["hi","hello"])})}),describe("an unanswered approval",()=>{const e={id:"c1",toolId:"zustand",action:"setState",label:"Update the Poké Mart bag store",description:"Change a live zustand store.",reason:"This will change the app's state.",params:{storeName:"bag",data:{lines:[]}},resolve:()=>{}},t=(t={})=>buildPayload({messages:[msg()],history:[],answers:{},usage:{input:0,output:0,requests:0},pending:{...e,...t}});it("survives the round trip with the exact call it asked about",()=>{const e=parsePayload(JSON.stringify(t()));expect(e?.pending).toMatchObject({toolId:"zustand",action:"setState",label:"Update the Poké Mart bag store",params:{storeName:"bag",data:{lines:[]}}})}),it("is saved again after it has already been restored once",()=>{expect(t({restored:!0}).pending).toBeTruthy()}),it("is dropped rather than scrubbed when the call carries a credential",()=>{const e=t({params:{key:"auth",value:"Bearer abcdefghijklmnop123456"}});expect(e.pending).toBeNull(),expect(JSON.stringify(e)).not.toContain("abcdefghijklmnop123456")}),it("reads back as absent from a transcript written before it existed",()=>{const e=build([msg()]);expect(parsePayload(JSON.stringify(e))?.pending).toBeNull()}),it("refuses a malformed one rather than restoring half a question",()=>{const e=JSON.stringify({...build([msg()]),pending:{toolId:"zustand"}});expect(parsePayload(e)?.pending).toBeNull()})}),describe("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:!0,previous:"old value"}},t=e=>buildPayload({messages:[msg()],history:[],answers:{},usage:{input:0,output:0,requests:0},ledger:e});it("survives the round trip with the prior value an undo needs",()=>{const s=parsePayload(JSON.stringify(t([e])));expect(s?.ledger).toHaveLength(1),expect(s?.ledger?.[0]).toMatchObject({toolId:"storage",action:"async.setItem"})}),it("drops an entry holding a credential rather than rewriting it",()=>{const s={...e,effect:{...e.effect,previous:"Bearer abcdefghijklmnop123456"}},a=t([s]);expect(a.ledger).toBeUndefined(),expect(JSON.stringify(a)).not.toContain("abcdefghijklmnop123456")}),it("reads back as absent from a transcript written before it existed",()=>{expect(parsePayload(JSON.stringify(build([msg()])))?.ledger).toBeUndefined()})});
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
@@ -0,0 +1 @@
1
+ {"version":3,"names":["describe","expect","it","buildPayload","fitToCaps","parsePayload","msg","over","id","role","text","toolCalls","blocks","build","messages","history","answers","usage","input","output","requests","name","results","toolCallId","content","saved","json","JSON","stringify","not","toContain","map","m","toEqual","toolId","action","label","status","summary","params","result","toBeUndefined","toBe","many","Array","from","length","_","i","toBeLessThanOrEqual","heavy","repeat","v","savedAt","toBeGreaterThan","streaming","error","toMatch","toBeNull","back","pending","description","reason","storeName","data","lines","resolve","withPending","toMatchObject","restored","toBeTruthy","key","value","old","raw","entry","at","effect","kind","had","previous","withLedger","entries","ledger","toHaveLength","secret"],"sourceRoot":"../../../src","sources":["store/transcriptPersistence.test.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAG7C,SAASC,YAAY,EAAEC,SAAS,EAAEC,YAAY,QAAQ,yBAAyB;AAG/E,MAAMC,GAAG,GAAGA,CAACC,IAA0B,GAAG,CAAC,CAAC,MAAmB;EAC7DC,EAAE,EAAE,IAAI;EACRC,IAAI,EAAE,WAAW;EACjBC,IAAI,EAAE,IAAI;EACVC,SAAS,EAAE,EAAE;EACbC,MAAM,EAAE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