@buoy-gg/agent-core 7.0.35 → 7.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/README.md +21 -14
  2. package/lib/commonjs/blocks/receipts.js +57 -1
  3. package/lib/commonjs/blocks/receipts.js.map +1 -1
  4. package/lib/commonjs/blocks/types.js +23 -2
  5. package/lib/commonjs/blocks/types.js.map +1 -1
  6. package/lib/commonjs/blocks/uiTool.js +423 -10
  7. package/lib/commonjs/blocks/uiTool.js.map +1 -1
  8. package/lib/commonjs/catalog/catalog.g.js +213 -48
  9. package/lib/commonjs/catalog/catalog.g.js.map +1 -1
  10. package/lib/commonjs/catalog/catalog.source.json +226 -48
  11. package/lib/commonjs/catalog/catalog.types.g.js +44 -0
  12. package/lib/commonjs/catalog/catalog.types.g.js.map +1 -0
  13. package/lib/commonjs/catalog/normalizeParams.js +333 -0
  14. package/lib/commonjs/catalog/normalizeParams.js.map +1 -0
  15. package/lib/commonjs/catalog/signature.js +68 -0
  16. package/lib/commonjs/catalog/signature.js.map +1 -0
  17. package/lib/commonjs/catalog/snapshotReads.js +13 -6
  18. package/lib/commonjs/catalog/snapshotReads.js.map +1 -1
  19. package/lib/commonjs/catalog/toProviderTools.js +44 -6
  20. package/lib/commonjs/catalog/toProviderTools.js.map +1 -1
  21. package/lib/commonjs/context/buildContextPack.js +367 -19
  22. package/lib/commonjs/context/buildContextPack.js.map +1 -1
  23. package/lib/commonjs/effects/digest.js +34 -0
  24. package/lib/commonjs/effects/digest.js.map +1 -0
  25. package/lib/commonjs/effects/ledger.js +98 -2
  26. package/lib/commonjs/effects/ledger.js.map +1 -1
  27. package/lib/commonjs/engine/askGate.js +287 -0
  28. package/lib/commonjs/engine/askGate.js.map +1 -0
  29. package/lib/commonjs/engine/effectFor.js +82 -1
  30. package/lib/commonjs/engine/effectFor.js.map +1 -1
  31. package/lib/commonjs/engine/evidence.js +113 -0
  32. package/lib/commonjs/engine/evidence.js.map +1 -0
  33. package/lib/commonjs/engine/historyBudget.js +363 -0
  34. package/lib/commonjs/engine/historyBudget.js.map +1 -0
  35. package/lib/commonjs/engine/retrieve.js +214 -0
  36. package/lib/commonjs/engine/retrieve.js.map +1 -0
  37. package/lib/commonjs/engine/runAgentTurn.js +1231 -120
  38. package/lib/commonjs/engine/runAgentTurn.js.map +1 -1
  39. package/lib/commonjs/engine/systemPrompt.js +103 -9
  40. package/lib/commonjs/engine/systemPrompt.js.map +1 -1
  41. package/lib/commonjs/engine/textToolCalls.js +276 -0
  42. package/lib/commonjs/engine/textToolCalls.js.map +1 -0
  43. package/lib/commonjs/engine/tokenCalibration.js +81 -0
  44. package/lib/commonjs/engine/tokenCalibration.js.map +1 -0
  45. package/lib/commonjs/engine/verify.js +300 -0
  46. package/lib/commonjs/engine/verify.js.map +1 -0
  47. package/lib/commonjs/index.js +74 -0
  48. package/lib/commonjs/index.js.map +1 -1
  49. package/lib/commonjs/policy/labels.js +19 -3
  50. package/lib/commonjs/policy/labels.js.map +1 -1
  51. package/lib/commonjs/policy/policy.js +6 -1
  52. package/lib/commonjs/policy/policy.js.map +1 -1
  53. package/lib/commonjs/policy/redact.js +42 -5
  54. package/lib/commonjs/policy/redact.js.map +1 -1
  55. package/lib/commonjs/providers/anthropic.js +340 -208
  56. package/lib/commonjs/providers/anthropic.js.map +1 -1
  57. package/lib/commonjs/providers/openai.js +237 -103
  58. package/lib/commonjs/providers/openai.js.map +1 -1
  59. package/lib/commonjs/providers/problem.js +98 -0
  60. package/lib/commonjs/providers/problem.js.map +1 -0
  61. package/lib/commonjs/providers/sse.js +170 -34
  62. package/lib/commonjs/providers/sse.js.map +1 -1
  63. package/lib/commonjs/providers/streamTimer.js +123 -0
  64. package/lib/commonjs/providers/streamTimer.js.map +1 -0
  65. package/lib/commonjs/providers/transport.js +123 -0
  66. package/lib/commonjs/providers/transport.js.map +1 -0
  67. package/lib/commonjs/providers/xhrStream.js +212 -0
  68. package/lib/commonjs/providers/xhrStream.js.map +1 -0
  69. package/lib/commonjs/session.js +242 -58
  70. package/lib/commonjs/session.js.map +1 -1
  71. package/lib/module/blocks/receipts.js +57 -1
  72. package/lib/module/blocks/receipts.js.map +1 -1
  73. package/lib/module/blocks/types.js +23 -2
  74. package/lib/module/blocks/types.js.map +1 -1
  75. package/lib/module/blocks/uiTool.js +421 -10
  76. package/lib/module/blocks/uiTool.js.map +1 -1
  77. package/lib/module/catalog/catalog.g.js +213 -48
  78. package/lib/module/catalog/catalog.g.js.map +1 -1
  79. package/lib/module/catalog/catalog.source.json +226 -48
  80. package/lib/module/catalog/catalog.types.g.js +40 -0
  81. package/lib/module/catalog/catalog.types.g.js.map +1 -0
  82. package/lib/module/catalog/normalizeParams.js +327 -0
  83. package/lib/module/catalog/normalizeParams.js.map +1 -0
  84. package/lib/module/catalog/signature.js +63 -0
  85. package/lib/module/catalog/signature.js.map +1 -0
  86. package/lib/module/catalog/snapshotReads.js +13 -6
  87. package/lib/module/catalog/snapshotReads.js.map +1 -1
  88. package/lib/module/catalog/toProviderTools.js +44 -6
  89. package/lib/module/catalog/toProviderTools.js.map +1 -1
  90. package/lib/module/context/buildContextPack.js +366 -19
  91. package/lib/module/context/buildContextPack.js.map +1 -1
  92. package/lib/module/effects/digest.js +29 -0
  93. package/lib/module/effects/digest.js.map +1 -0
  94. package/lib/module/effects/ledger.js +98 -2
  95. package/lib/module/effects/ledger.js.map +1 -1
  96. package/lib/module/engine/askGate.js +280 -0
  97. package/lib/module/engine/askGate.js.map +1 -0
  98. package/lib/module/engine/effectFor.js +83 -1
  99. package/lib/module/engine/effectFor.js.map +1 -1
  100. package/lib/module/engine/evidence.js +107 -0
  101. package/lib/module/engine/evidence.js.map +1 -0
  102. package/lib/module/engine/historyBudget.js +355 -0
  103. package/lib/module/engine/historyBudget.js.map +1 -0
  104. package/lib/module/engine/retrieve.js +210 -0
  105. package/lib/module/engine/retrieve.js.map +1 -0
  106. package/lib/module/engine/runAgentTurn.js +1227 -121
  107. package/lib/module/engine/runAgentTurn.js.map +1 -1
  108. package/lib/module/engine/systemPrompt.js +101 -9
  109. package/lib/module/engine/systemPrompt.js.map +1 -1
  110. package/lib/module/engine/textToolCalls.js +270 -0
  111. package/lib/module/engine/textToolCalls.js.map +1 -0
  112. package/lib/module/engine/tokenCalibration.js +75 -0
  113. package/lib/module/engine/tokenCalibration.js.map +1 -0
  114. package/lib/module/engine/verify.js +292 -0
  115. package/lib/module/engine/verify.js.map +1 -0
  116. package/lib/module/index.js +7 -3
  117. package/lib/module/index.js.map +1 -1
  118. package/lib/module/policy/labels.js +19 -3
  119. package/lib/module/policy/labels.js.map +1 -1
  120. package/lib/module/policy/policy.js +6 -1
  121. package/lib/module/policy/policy.js.map +1 -1
  122. package/lib/module/policy/redact.js +42 -5
  123. package/lib/module/policy/redact.js.map +1 -1
  124. package/lib/module/providers/anthropic.js +341 -209
  125. package/lib/module/providers/anthropic.js.map +1 -1
  126. package/lib/module/providers/openai.js +238 -104
  127. package/lib/module/providers/openai.js.map +1 -1
  128. package/lib/module/providers/problem.js +92 -0
  129. package/lib/module/providers/problem.js.map +1 -0
  130. package/lib/module/providers/sse.js +166 -34
  131. package/lib/module/providers/sse.js.map +1 -1
  132. package/lib/module/providers/streamTimer.js +118 -0
  133. package/lib/module/providers/streamTimer.js.map +1 -0
  134. package/lib/module/providers/transport.js +119 -0
  135. package/lib/module/providers/transport.js.map +1 -0
  136. package/lib/module/providers/xhrStream.js +207 -0
  137. package/lib/module/providers/xhrStream.js.map +1 -0
  138. package/lib/module/session.js +226 -60
  139. package/lib/module/session.js.map +1 -1
  140. package/lib/typescript/blocks/receipts.d.ts +5 -0
  141. package/lib/typescript/blocks/receipts.d.ts.map +1 -1
  142. package/lib/typescript/blocks/types.d.ts +23 -2
  143. package/lib/typescript/blocks/types.d.ts.map +1 -1
  144. package/lib/typescript/blocks/uiTool.d.ts +11 -2
  145. package/lib/typescript/blocks/uiTool.d.ts.map +1 -1
  146. package/lib/typescript/catalog/catalog.g.d.ts +2 -2
  147. package/lib/typescript/catalog/catalog.g.d.ts.map +1 -1
  148. package/lib/typescript/catalog/catalog.types.g.d.ts +40 -0
  149. package/lib/typescript/catalog/catalog.types.g.d.ts.map +1 -0
  150. package/lib/typescript/catalog/normalizeParams.d.ts +43 -0
  151. package/lib/typescript/catalog/normalizeParams.d.ts.map +1 -0
  152. package/lib/typescript/catalog/signature.d.ts +29 -0
  153. package/lib/typescript/catalog/signature.d.ts.map +1 -0
  154. package/lib/typescript/catalog/snapshotReads.d.ts.map +1 -1
  155. package/lib/typescript/catalog/toProviderTools.d.ts +28 -15
  156. package/lib/typescript/catalog/toProviderTools.d.ts.map +1 -1
  157. package/lib/typescript/context/buildContextPack.d.ts +24 -2
  158. package/lib/typescript/context/buildContextPack.d.ts.map +1 -1
  159. package/lib/typescript/effects/digest.d.ts +10 -0
  160. package/lib/typescript/effects/digest.d.ts.map +1 -0
  161. package/lib/typescript/effects/ledger.d.ts +73 -0
  162. package/lib/typescript/effects/ledger.d.ts.map +1 -1
  163. package/lib/typescript/engine/askGate.d.ts +29 -0
  164. package/lib/typescript/engine/askGate.d.ts.map +1 -0
  165. package/lib/typescript/engine/effectFor.d.ts +6 -1
  166. package/lib/typescript/engine/effectFor.d.ts.map +1 -1
  167. package/lib/typescript/engine/evidence.d.ts +67 -0
  168. package/lib/typescript/engine/evidence.d.ts.map +1 -0
  169. package/lib/typescript/engine/historyBudget.d.ts +115 -0
  170. package/lib/typescript/engine/historyBudget.d.ts.map +1 -0
  171. package/lib/typescript/engine/retrieve.d.ts +32 -0
  172. package/lib/typescript/engine/retrieve.d.ts.map +1 -0
  173. package/lib/typescript/engine/runAgentTurn.d.ts +179 -3
  174. package/lib/typescript/engine/runAgentTurn.d.ts.map +1 -1
  175. package/lib/typescript/engine/systemPrompt.d.ts +80 -0
  176. package/lib/typescript/engine/systemPrompt.d.ts.map +1 -1
  177. package/lib/typescript/engine/textToolCalls.d.ts +58 -0
  178. package/lib/typescript/engine/textToolCalls.d.ts.map +1 -0
  179. package/lib/typescript/engine/tokenCalibration.d.ts +46 -0
  180. package/lib/typescript/engine/tokenCalibration.d.ts.map +1 -0
  181. package/lib/typescript/engine/verify.d.ts +67 -0
  182. package/lib/typescript/engine/verify.d.ts.map +1 -0
  183. package/lib/typescript/index.d.ts +7 -3
  184. package/lib/typescript/index.d.ts.map +1 -1
  185. package/lib/typescript/policy/labels.d.ts.map +1 -1
  186. package/lib/typescript/policy/policy.d.ts.map +1 -1
  187. package/lib/typescript/policy/redact.d.ts.map +1 -1
  188. package/lib/typescript/providers/anthropic.d.ts.map +1 -1
  189. package/lib/typescript/providers/openai.d.ts +0 -16
  190. package/lib/typescript/providers/openai.d.ts.map +1 -1
  191. package/lib/typescript/providers/problem.d.ts +50 -0
  192. package/lib/typescript/providers/problem.d.ts.map +1 -0
  193. package/lib/typescript/providers/sse.d.ts +86 -2
  194. package/lib/typescript/providers/sse.d.ts.map +1 -1
  195. package/lib/typescript/providers/streamTimer.d.ts +59 -0
  196. package/lib/typescript/providers/streamTimer.d.ts.map +1 -0
  197. package/lib/typescript/providers/transport.d.ts +48 -0
  198. package/lib/typescript/providers/transport.d.ts.map +1 -0
  199. package/lib/typescript/providers/types.d.ts +105 -3
  200. package/lib/typescript/providers/types.d.ts.map +1 -1
  201. package/lib/typescript/providers/xhrStream.d.ts +45 -0
  202. package/lib/typescript/providers/xhrStream.d.ts.map +1 -0
  203. package/lib/typescript/session.d.ts +55 -4
  204. package/lib/typescript/session.d.ts.map +1 -1
  205. package/lib/typescript/types.d.ts +6 -0
  206. package/lib/typescript/types.d.ts.map +1 -1
  207. package/package.json +10 -10
  208. package/LICENSE +0 -58
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Streaming over `XMLHttpRequest`, for the runtimes where `fetch` cannot.
5
+ *
6
+ * React Native core still has no `response.body`: its `fetch` is the whatwg
7
+ * polyfill over XHR and resolves inside `xhr.onload`, i.e. after the ENTIRE
8
+ * body. Under Expo the global is `expo/fetch`, which does stream — but
9
+ * `EXPO_PUBLIC_USE_RN_FETCH=1` reverts that, and the bare-RN CLI, TV CLI and
10
+ * NativeScript lanes never had it at all. On those, every Ask Buoy answer
11
+ * appeared in one lump, however long the model took.
12
+ *
13
+ * XHR itself has streamed the whole time. `responseText` grows as bytes arrive
14
+ * and `onprogress` fires as it does, so slicing from the last offset gives the
15
+ * same incremental text a reader would. Two conditions, both easy to miss:
16
+ * the progress handler must be installed BEFORE `send()`, and `responseType`
17
+ * must stay text — anything else stops RN emitting progress at all.
18
+ *
19
+ * WHAT THIS IS NOT. It is not a second SSE parser: framing, the truncation
20
+ * rule and the terminal-marker contract all live in `sse.ts` and are shared
21
+ * verbatim. This file only produces text chunks.
22
+ */
23
+ import { framesFrom } from "./sse";
24
+
25
+ /** Beyond this the answer is not an answer any more; stop reading. */
26
+ const MAX_RESPONSE_CHARS = 8_000_000;
27
+ export function xhrAvailable() {
28
+ return typeof XMLHttpRequest === "function";
29
+ }
30
+
31
+ /**
32
+ * Send the request and resolve once the HEADERS are in, so the caller can
33
+ * check the status and content type before deciding to read a stream — the
34
+ * same shape `fetch` offers, and the reason this can slot in beside it.
35
+ */
36
+ export function xhrStream(req) {
37
+ return new Promise((resolveHeaders, rejectHeaders) => {
38
+ const xhr = new XMLHttpRequest();
39
+
40
+ /** Text seen but not yet handed to a consumer. */
41
+ const queue = [];
42
+ /** Resolvers for a consumer parked on an empty queue. */
43
+ const waiters = [];
44
+ let offset = 0;
45
+ let done = false;
46
+ let failure;
47
+ let headersSeen = false;
48
+ let capped = false;
49
+ const wake = () => {
50
+ while (waiters.length) waiters.shift()();
51
+ };
52
+ const pull = () => {
53
+ // `responseText` is the WHOLE body so far, so the delta is everything
54
+ // past what was already taken. RN keeps the full string either way;
55
+ // the offset bounds the work, not the memory.
56
+ let text;
57
+ try {
58
+ text = xhr.responseText ?? "";
59
+ } catch {
60
+ return; // Not readable yet on some runtimes; the next event will do.
61
+ }
62
+ if (text.length <= offset) return;
63
+ if (text.length > MAX_RESPONSE_CHARS) {
64
+ capped = true;
65
+ failure = new Error("The endpoint sent more than this tool will read.");
66
+ done = true;
67
+ try {
68
+ xhr.abort();
69
+ } catch {
70
+ /* already gone */
71
+ }
72
+ wake();
73
+ return;
74
+ }
75
+ queue.push(text.slice(offset));
76
+ offset = text.length;
77
+ wake();
78
+ };
79
+ const settleHeaders = () => {
80
+ if (headersSeen) return;
81
+ headersSeen = true;
82
+ let contentType = "";
83
+ let retryAfter = null;
84
+ try {
85
+ contentType = xhr.getResponseHeader("content-type") ?? "";
86
+ retryAfter = xhr.getResponseHeader("retry-after");
87
+ } catch {
88
+ contentType = "";
89
+ }
90
+ resolveHeaders({
91
+ status: xhr.status,
92
+ ok: xhr.status >= 200 && xhr.status < 300,
93
+ contentType,
94
+ retryAfter,
95
+ async text() {
96
+ // Whatever has arrived. For a non-2xx that is the error body; the
97
+ // request is over by the time anyone asks.
98
+ await new Promise(r => {
99
+ if (done) return r();
100
+ waiters.push(() => r());
101
+ });
102
+ try {
103
+ return xhr.responseText ?? "";
104
+ } catch {
105
+ return "";
106
+ }
107
+ },
108
+ frames(options) {
109
+ return framesFrom(chunks(), options);
110
+ }
111
+ });
112
+ };
113
+ async function* chunks() {
114
+ try {
115
+ for (;;) {
116
+ while (queue.length) yield queue.shift();
117
+ if (done) break;
118
+ await new Promise(r => waiters.push(r));
119
+ }
120
+ while (queue.length) yield queue.shift();
121
+ if (failure) throw failure;
122
+ } finally {
123
+ if (!done) {
124
+ // The consumer left early — a completed turn, a Stop, a timeout.
125
+ // Nothing else will read this socket.
126
+ try {
127
+ xhr.abort();
128
+ } catch {
129
+ /* already gone */
130
+ }
131
+ }
132
+ }
133
+ }
134
+ const onAbort = () => {
135
+ try {
136
+ xhr.abort();
137
+ } catch {
138
+ /* already gone */
139
+ }
140
+ };
141
+ xhr.onreadystatechange = () => {
142
+ // HEADERS_RECEIVED. Status and content type are known here, long before
143
+ // the body finishes — which is the whole point of using XHR directly.
144
+ if (xhr.readyState === 2) settleHeaders();
145
+ };
146
+ xhr.onprogress = () => {
147
+ settleHeaders();
148
+ pull();
149
+ };
150
+ xhr.onload = () => {
151
+ settleHeaders();
152
+ if (!capped) pull();
153
+ done = true;
154
+ wake();
155
+ };
156
+ xhr.onerror = () => {
157
+ failure = new Error("The request failed before it finished.");
158
+ done = true;
159
+ if (!headersSeen) {
160
+ headersSeen = true;
161
+ rejectHeaders(failure);
162
+ }
163
+ wake();
164
+ };
165
+ xhr.onabort = () => {
166
+ const err = new Error("Aborted");
167
+ err.name = "AbortError";
168
+ failure = err;
169
+ done = true;
170
+ if (!headersSeen) {
171
+ headersSeen = true;
172
+ rejectHeaders(err);
173
+ }
174
+ wake();
175
+ };
176
+ xhr.ontimeout = () => {
177
+ failure = new Error("The request timed out.");
178
+ done = true;
179
+ if (!headersSeen) {
180
+ headersSeen = true;
181
+ rejectHeaders(failure);
182
+ }
183
+ wake();
184
+ };
185
+ try {
186
+ xhr.open("POST", req.url, true);
187
+ // Text, and nothing else: RN emits no progress events for any other
188
+ // response type, which turns this back into a buffered read in silence.
189
+ xhr.responseType = "text";
190
+ for (const [k, v] of Object.entries(req.headers)) {
191
+ try {
192
+ xhr.setRequestHeader(k, v);
193
+ } catch {
194
+ /* a header the runtime forbids is not worth failing the turn over */
195
+ }
196
+ }
197
+ if (req.signal) {
198
+ if (req.signal.aborted) onAbort();else req.signal.addEventListener?.("abort", onAbort);
199
+ }
200
+ xhr.send(req.body);
201
+ } catch (err) {
202
+ headersSeen = true;
203
+ rejectHeaders(err instanceof Error ? err : new Error(String(err)));
204
+ }
205
+ });
206
+ }
207
+ //# sourceMappingURL=xhrStream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["framesFrom","MAX_RESPONSE_CHARS","xhrAvailable","XMLHttpRequest","xhrStream","req","Promise","resolveHeaders","rejectHeaders","xhr","queue","waiters","offset","done","failure","headersSeen","capped","wake","length","shift","pull","text","responseText","Error","abort","push","slice","settleHeaders","contentType","retryAfter","getResponseHeader","status","ok","r","frames","options","chunks","onAbort","onreadystatechange","readyState","onprogress","onload","onerror","onabort","err","name","ontimeout","open","url","responseType","k","v","Object","entries","headers","setRequestHeader","signal","aborted","addEventListener","send","body","String"],"sourceRoot":"../../../src","sources":["providers/xhrStream.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAU,QAA4C,OAAO;;AAEtE;AACA,MAAMC,kBAAkB,GAAG,SAAS;AAoBpC,OAAO,SAASC,YAAYA,CAAA,EAAY;EACtC,OAAO,OAAOC,cAAc,KAAK,UAAU;AAC7C;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,SAASA,CAACC,GAAqB,EAA8B;EAC3E,OAAO,IAAIC,OAAO,CAAoB,CAACC,cAAc,EAAEC,aAAa,KAAK;IACvE,MAAMC,GAAG,GAAG,IAAIN,cAAc,CAAC,CAAC;;IAEhC;IACA,MAAMO,KAAe,GAAG,EAAE;IAC1B;IACA,MAAMC,OAA0B,GAAG,EAAE;IACrC,IAAIC,MAAM,GAAG,CAAC;IACd,IAAIC,IAAI,GAAG,KAAK;IAChB,IAAIC,OAA0B;IAC9B,IAAIC,WAAW,GAAG,KAAK;IACvB,IAAIC,MAAM,GAAG,KAAK;IAElB,MAAMC,IAAI,GAAGA,CAAA,KAAM;MACjB,OAAON,OAAO,CAACO,MAAM,EAAEP,OAAO,CAACQ,KAAK,CAAC,CAAC,CAAE,CAAC;IAC3C,CAAC;IAED,MAAMC,IAAI,GAAGA,CAAA,KAAM;MACjB;MACA;MACA;MACA,IAAIC,IAAY;MAChB,IAAI;QACFA,IAAI,GAAGZ,GAAG,CAACa,YAAY,IAAI,EAAE;MAC/B,CAAC,CAAC,MAAM;QACN,OAAO,CAAC;MACV;MACA,IAAID,IAAI,CAACH,MAAM,IAAIN,MAAM,EAAE;MAC3B,IAAIS,I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;QACd,IAAInD,GAAG,CAACmD,MAAM,CAACC,OAAO,EAAEpB,OAAO,CAAC,CAAC,CAAC,KAC7BhC,GAAG,CAACmD,MAAM,CAACE,gBAAgB,GAAG,OAAO,EAAErB,OAAO,CAAC;MACtD;MACA5B,GAAG,CAACkD,IAAI,CAACtD,GAAG,CAACuD,IAAI,CAAC;IACpB,CAAC,CAAC,OAAOhB,GAAG,EAAE;MACZ7B,WAAW,GAAG,IAAI;MAClBP,aAAa,CAACoC,GAAG,YAAYrB,KAAK,GAAGqB,GAAG,GAAG,IAAIrB,KAAK,CAACsC,MAAM,CAACjB,GAAG,CAAC,CAAC,CAAC;IACpE;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -6,51 +6,22 @@
6
6
  * This is the one-call surface the UI packages use. It owns the pieces that
7
7
  * have to agree with each other across a whole session — the provider, the
8
8
  * catalog filtered to what this device can actually do, the system prompt
9
- * (built once, after grounding), the effect ledger, and the message history —
9
+ * (the stable part built once after grounding, the RIGHT NOW part re-read every
10
+ * turn), the effect ledger, and the message history —
10
11
  * so a chat UI is a message list plus a text box rather than an orchestrator.
11
12
  */
12
13
  import { CATALOG } from "./catalog/catalog.g";
13
- import { buildContextDigest } from "./context/buildContextPack";
14
+ import { buildContextDigest, buildLiveContext } from "./context/buildContextPack";
14
15
  import { runAgentTurn } from "./engine/runAgentTurn";
15
- import { buildSystemPrompt } from "./engine/systemPrompt";
16
+ import { buildLiveBlock, buildSystemPrompt, listableProcedures } from "./engine/systemPrompt";
16
17
  import { EffectLedger } from "./effects/ledger";
18
+ import { EvidenceStore } from "./engine/evidence";
19
+ import { TokenCalibration } from "./engine/tokenCalibration";
20
+ import { compressConsumed, trimHistory, trimHistoryReport } from "./engine/historyBudget";
17
21
  import { createAnthropicProvider } from "./providers/anthropic";
18
22
  import { createOpenAIProvider } from "./providers/openai";
19
23
  import { resolveRequireApproval } from "./policy/policy";
20
24
  import { registerSelfEndpoint } from "./policy/redact";
21
- /**
22
- * A long QA session must not die on the provider's context limit with an
23
- * opaque error — the transcript grows without bound (tool results are the
24
- * heavy part), so the OLDEST rounds are dropped once the history passes a
25
- * budget. Rounds are dropped whole — a round starts at a user message — so
26
- * the assistant/tool-result pairing every provider requires stays intact and
27
- * the history still begins with a user message.
28
- */
29
- const MAX_HISTORY_CHARS = 150_000;
30
- const MIN_KEEP_MESSAGES = 4;
31
- function messageSize(m) {
32
- try {
33
- return JSON.stringify(m).length;
34
- } catch {
35
- return 0;
36
- }
37
- }
38
- function trimHistory(messages) {
39
- let total = 0;
40
- for (const m of messages) total += messageSize(m);
41
- if (total <= MAX_HISTORY_CHARS) return messages;
42
- const out = [...messages];
43
- while (out.length > MIN_KEEP_MESSAGES && total > MAX_HISTORY_CHARS) {
44
- total -= messageSize(out[0]);
45
- out.shift();
46
- while (out.length > MIN_KEEP_MESSAGES && out[0].role !== "user") {
47
- total -= messageSize(out[0]);
48
- out.shift();
49
- }
50
- }
51
- return out;
52
- }
53
-
54
25
  /**
55
26
  * A stored history, made safe to send as the start of a new request.
56
27
  *
@@ -67,6 +38,9 @@ function trimHistory(messages) {
67
38
  * always resumes with a fresh user message instead, so their signatures are
68
39
  * dead weight at best and a stale-signature 400 at worst.
69
40
  */
41
+ // Re-exported: these were defined here before the engine needed them too, and
42
+ // the tests and the package surface still reach them through this module.
43
+ export { compressConsumed, trimHistory, trimHistoryReport };
70
44
  export function resumableHistory(history) {
71
45
  let end = history.length;
72
46
  while (end > 0) {
@@ -84,8 +58,60 @@ export function createAskBuoySession(config) {
84
58
  const ledger = new EffectLedger();
85
59
  const policy = config.policy ?? {};
86
60
  let messages = [];
61
+ /**
62
+ * Image-URL provenance for the whole conversation, not one turn of it.
63
+ *
64
+ * "Show me the shop as pictures" and "no, actually render them" are two
65
+ * turns; the second has no tool calls of its own, so a per-turn set held
66
+ * nothing and every image was stripped out from under the model. It kept
67
+ * describing artwork that was not on screen. The rule is unchanged — a URL
68
+ * still has to have been READ — the window is just the conversation. Reset
69
+ * with the conversation.
70
+ */
71
+ const seenUrls = new Set();
72
+ /**
73
+ * Every result's full text, for `ask-buoy.retrieve` — see engine/evidence.ts.
74
+ * Conversation-scoped like `seenUrls`: "what were the stats in that response"
75
+ * is a normal second message. Cleared with the conversation; never persisted.
76
+ */
77
+ const evidence = new EvidenceStore();
78
+ /** Chars-per-token as measured on THIS session's provider — see engine/tokenCalibration.ts. */
79
+ const calibration = new TokenCalibration();
87
80
  let system;
88
81
  let primed = false;
82
+ /** See `setApprovalBypass`. Consulted per turn, never captured. */
83
+ let bypassApproval = false;
84
+ /** Actions the user waived the card for in this conversation — see RunTurnInput.trusted. */
85
+ const trusted = new Set();
86
+ /** See `setReadOnly`. */
87
+ let deviceReadOnly = false;
88
+ /**
89
+ * Rounds dropped by `restore` — reported on the first send, because there is
90
+ * no open turn to carry the event when the restore happens.
91
+ */
92
+ let trimmedOnRestore = 0;
93
+ /**
94
+ * Which conversation is live. Bumped by `reset`.
95
+ *
96
+ * A turn's history is committed when its generator drains, and a turn does
97
+ * not stop the moment Stop is pressed — an in-flight dispatch has to settle
98
+ * first, and nothing can pull a store write back out of an adapter. So the
99
+ * sequence Stop -> "New conversation" -> the write finishes used to end with
100
+ * the OLD turn assigning its whole history over the empty one: a chat the
101
+ * user had just cleared came back, carrying a change they never saw made.
102
+ * The turn still finishes and its effect still lands in the app; it simply
103
+ * no longer owns a conversation that has moved on.
104
+ */
105
+ let generation = 0;
106
+ /**
107
+ * The grounding probe's result, held past `prime`.
108
+ *
109
+ * The system prompt is a pure function of this plus the policy, and the
110
+ * approval paragraph changes when the device toggle does — holding the
111
+ * digest lets the prompt be rebuilt without re-probing the app for state it
112
+ * already read.
113
+ */
114
+ let digest = {};
89
115
  /**
90
116
  * `storage key -> the live store that owns it`, derived from the grounding.
91
117
  *
@@ -99,16 +125,63 @@ export function createAskBuoySession(config) {
99
125
  // So the agent's own requests to the model endpoint never come back to it
100
126
  // out of the network tool — that would feed it its own auth headers.
101
127
  registerSelfEndpoint(config.endpoint);
102
- const provider = config.protocol === "openai" ? createOpenAIProvider(config) : createAnthropicProvider(config);
128
+ const provider = config.provider ?? (config.protocol === "openai" ? createOpenAIProvider(config) : createAnthropicProvider(config));
103
129
 
104
130
  // Mutable: the device's tool list fills in over the first frames and can
105
131
  // change while the sheet is open. See setAvailableActions.
106
132
  let availableActions = config.availableActions;
107
133
  let availableToolIds = Object.keys(availableActions);
134
+
135
+ /**
136
+ * THE policy object the engine reads, mutated in place.
137
+ *
138
+ * One object for the life of the session, not a fresh one per turn: the
139
+ * engine reads `policy.readOnly` and the approval lists at each call, so a
140
+ * toggle flipped mid-turn lands on the very next call of that turn. A new
141
+ * object per turn would leave a running turn on the old rules until it
142
+ * finished — "Read only" switched on while the agent was writing would let
143
+ * the rest of the batch through.
144
+ */
145
+ const live = {
146
+ ...policy
147
+ };
148
+ function refreshLive() {
149
+ for (const k of Object.keys(live)) delete live[k];
150
+ Object.assign(live, policy);
151
+ if (bypassApproval) {
152
+ live.requireApproval = [];
153
+ live.requireApprovalFor = [];
154
+ }
155
+ // OR, never override: the device can narrow, the app's own read-only stands.
156
+ if (deviceReadOnly) live.readOnly = true;
157
+ }
158
+ function activePolicy() {
159
+ return live;
160
+ }
161
+ function composeSystem() {
162
+ system = buildSystemPrompt({
163
+ catalog,
164
+ context: {
165
+ ...config.context,
166
+ digest: {
167
+ ...digest,
168
+ ...config.context?.digest
169
+ }
170
+ },
171
+ isRelease: config.isRelease,
172
+ readOnly: live.readOnly ?? false,
173
+ readOnlySource: policy.readOnly ? "app" : deviceReadOnly ? "device" : undefined,
174
+ requireApproval: resolveRequireApproval(live),
175
+ approvalsBypassed: bypassApproval,
176
+ appName: config.appName,
177
+ platform: config.platform,
178
+ availableToolIds
179
+ });
180
+ }
108
181
  async function prime() {
109
182
  if (primed) return;
110
183
  primed = true;
111
- let digest = {};
184
+ digest = {};
112
185
  try {
113
186
  digest = await buildContextDigest({
114
187
  dispatch: config.dispatch,
@@ -125,24 +198,16 @@ export function createAskBuoySession(config) {
125
198
  const store = raw;
126
199
  if (store?.persistsTo && store.name) storeKeyOwners[store.persistsTo] = store.name;
127
200
  }
128
- system = buildSystemPrompt({
129
- catalog,
130
- context: {
131
- ...config.context,
132
- digest: {
133
- ...digest,
134
- ...config.context?.digest
135
- }
136
- },
137
- isRelease: config.isRelease,
138
- readOnly: policy.readOnly ?? false,
139
- requireApproval: resolveRequireApproval(policy),
140
- appName: config.appName,
141
- platform: config.platform
142
- });
201
+ composeSystem();
143
202
  }
144
203
  return {
145
204
  ledger,
205
+ evidence,
206
+ calibration,
207
+ trustedActions: () => [...trusted],
208
+ untrust: key => {
209
+ trusted.delete(key);
210
+ },
146
211
  get messages() {
147
212
  return messages;
148
213
  },
@@ -151,35 +216,128 @@ export function createAskBuoySession(config) {
151
216
  availableActions = actions;
152
217
  availableToolIds = Object.keys(actions);
153
218
  },
219
+ setApprovalBypass(enabled) {
220
+ if (bypassApproval === enabled) return;
221
+ bypassApproval = enabled;
222
+ refreshLive();
223
+ // The prompt tells the model whether a card will appear before its
224
+ // change lands; leaving that paragraph stale would have it announce an
225
+ // approval step that no longer exists. Rebuilt from the held digest, so
226
+ // toggling mid-conversation costs nothing and re-reads nothing.
227
+ if (system) composeSystem();
228
+ },
229
+ setReadOnly(enabled) {
230
+ if (deviceReadOnly === enabled) return;
231
+ deviceReadOnly = enabled;
232
+ refreshLive();
233
+ if (system) composeSystem();
234
+ },
154
235
  restore(history) {
155
236
  // Only into a session that has not been talked to. Restoring over a live
156
237
  // conversation would drop whatever was said since the app started.
157
238
  if (messages.length > 0) return;
158
- messages = trimHistory(resumableHistory(history));
239
+ const report = trimHistoryReport(resumableHistory(history), calibration.charsPerToken, ledger.liveCallIds());
240
+ messages = report.messages;
241
+ trimmedOnRestore = report.droppedRounds;
159
242
  },
160
243
  async *send(text, signal) {
244
+ /**
245
+ * Captured FIRST, before any await.
246
+ *
247
+ * Priming and the live-context probes are awaits like any other, and a
248
+ * reset can land inside them. Reading the generation after them would
249
+ * pick up the NEW conversation's value and let this turn commit into it —
250
+ * the precise bug this guards against, reintroduced one line lower.
251
+ */
252
+ const myGeneration = generation;
161
253
  await prime();
162
- messages.push({
254
+ // The RIGHT NOW block: re-read on EVERY turn, not once at open. The
255
+ // stable digest above was once the whole picture, and it was built
256
+ // before the user had navigated anywhere — so the query that owned the
257
+ // screen they were looking at was simply not in the prompt. This is the
258
+ // uncached tail of the system prompt (see ProviderRequest.systemVolatile).
259
+ let live;
260
+ try {
261
+ live = await buildLiveContext({
262
+ dispatch: config.dispatch,
263
+ readSnapshot: config.readSnapshot,
264
+ availableToolIds,
265
+ availableActions
266
+ });
267
+ } catch {
268
+ live = undefined;
269
+ }
270
+ /**
271
+ * The conversation was cleared while this turn was still getting ready.
272
+ *
273
+ * Priming and the live probes take real time, so "New conversation"
274
+ * lands here often enough to matter. Abandoning now costs nothing: the
275
+ * model has not been asked anything yet.
276
+ */
277
+ if (myGeneration !== generation) {
278
+ yield {
279
+ type: "done",
280
+ stopReason: "superseded"
281
+ };
282
+ return;
283
+ }
284
+
285
+ /**
286
+ * The turn works on its OWN array, and `messages` is assigned in exactly
287
+ * one place — the commit at the bottom.
288
+ *
289
+ * `runAgentTurn` pushes each round into the array it is handed. Handing
290
+ * it the session's own array made every push a live edit of session
291
+ * state, so a turn racing a reset wrote its whole history into the new
292
+ * conversation one push at a time and the commit guard had nothing left
293
+ * to protect. Copying makes ownership checkable in one place instead of
294
+ * spread across the loop.
295
+ */
296
+ const trimmed = trimHistoryReport([...messages, {
163
297
  role: "user",
164
298
  text
165
- });
166
- messages = trimHistory(messages);
299
+ }], calibration.charsPerToken, ledger.liveCallIds());
300
+ const working = trimmed.messages;
301
+ // Said once, before the answer it affects. The screen still shows the
302
+ // rounds the model just lost; this is the only thing that tells the two
303
+ // apart. See the `history-trimmed` event.
304
+ const droppedRounds = trimmed.droppedRounds + trimmedOnRestore;
305
+ trimmedOnRestore = 0;
306
+ if (droppedRounds > 0) yield {
307
+ type: "history-trimmed",
308
+ droppedRounds,
309
+ droppedPinned: trimmed.droppedPinned
310
+ };
167
311
  const gen = runAgentTurn({
168
312
  provider,
169
313
  catalog,
170
- messages,
314
+ messages: working,
171
315
  system: system,
316
+ systemVolatile: buildLiveBlock(live,
317
+ // What this conversation has already done to the app. See
318
+ // buildLiveBlock — without it the model answers "what have you
319
+ // changed?" from memory of its own sentences, and reports a value it
320
+ // overwrote itself as the app's own.
321
+ ledger.list().map(e => ({
322
+ label: `${e.toolId}.${e.action}${e.effect.label ? ` — ${e.effect.label}` : ""}`,
323
+ undone: e.undoneAt !== undefined
324
+ }))),
172
325
  model: config.model,
173
326
  maxTokens: config.maxTokens ?? 4096,
174
327
  dispatch: config.dispatch,
175
328
  readSnapshot: config.readSnapshot,
176
329
  storeKeyOwners,
177
330
  ledger,
178
- policy,
331
+ policy: activePolicy(),
179
332
  isRelease: config.isRelease,
180
333
  availableToolIds,
181
334
  availableActions,
182
335
  requestApproval: config.requestApproval,
336
+ seenUrls,
337
+ evidence,
338
+ calibration,
339
+ trusted,
340
+ procedures: listableProcedures(config.context?.procedures, availableToolIds),
183
341
  signal
184
342
  });
185
343
  let next = await gen.next();
@@ -188,11 +346,19 @@ export function createAskBuoySession(config) {
188
346
  next = await gen.next();
189
347
  }
190
348
  // The generator's return value is the full history including tool turns.
191
- messages = next.value;
349
+ // Committed only if this turn still owns the conversation — see
350
+ // `generation`.
351
+ if (myGeneration === generation) messages = next.value;
192
352
  },
193
353
  reset() {
354
+ // Before anything else: a turn still draining must not commit over this.
355
+ generation += 1;
194
356
  messages = [];
357
+ trimmedOnRestore = 0;
195
358
  ledger.clear();
359
+ seenUrls.clear();
360
+ evidence.clear();
361
+ trusted.clear();
196
362
  // The grounding digest is a snapshot of the app AT OPEN — stores and
197
363
  // routes registered since are invisible to it. A new conversation is
198
364
  // the natural moment to re-read the world.
@@ -1 +1 @@
1
- {"version":3,"names":["CATALOG","buildContextDigest","runAgentTurn","buildSystemPrompt","EffectLedger","createAnthropicProvider","createOpenAIProvider","resolveRequireApproval","registerSelfEndpoint","MAX_HISTORY_CHARS","MIN_KEEP_MESSAGES","messageSize","m","JSON","stringify","length","trimHistory","messages","total","out","shift","role","resumableHistory","history","end","toolCalls","slice","map","thinking","undefined","createAskBuoySession","config","catalog","ledger","policy","system","primed","storeKeyOwners","endpoint","provider","protocol","availableActions","availableToolIds","Object","keys","prime","digest","dispatch","readSnapshot","raw","zustandStores","store","persistsTo","name","context","isRelease","readOnly","requireApproval","appName","platform","setAvailableActions","actions","restore","send","text","signal","push","gen","model","maxTokens","requestApproval","next","done","value","reset","clear"],"sourceRoot":"../../src","sources":["session.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,qBAAqB;AAC7C,SAASC,kBAAkB,QAAQ,4BAA4B;AAC/D,SAASC,YAAY,QAAwB,uBAAuB;AACpE,SAASC,iBAAiB,QAA0B,uBAAuB;AAC3E,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,uBAAuB,QAAQ,uBAAuB;AAC/D,SAASC,oBAAoB,QAAQ,oBAAoB;AAEzD,SAASC,sBAAsB,QAA4B,iBAAiB;AAC5E,SAASC,oBAAoB,QAAQ,iBAAiB;AA6DtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,GAAG,OAAO;AACjC,MAAMC,iBAAiB,GAAG,CAAC;AAE3B,SAASC,WAAWA,CAACC,CAAe,EAAU;EAC5C,IAAI;IACF,OAAOC,IAAI,CAACC,SAAS,CAACF,CAAC,CAAC,CAACG,MAAM;EACjC,CAAC,CAAC,MAAM;IACN,OAAO,CAAC;EACV;AACF;AAEA,SAASC,WAAWA,CAACC,QAAwB,EAAkB;EAC7D,IAAIC,KAAK,GAAG,CAAC;EACb,KAAK,MAAMN,CAAC,IAAIK,QAAQ,EAAEC,KAAK,IAAIP,WAAW,CAACC,CAAC,CAAC;EACjD,IAAIM,KAAK,IAAIT,iBAAiB,EAA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QACnBC,SAAS,EAAEtC,MAAM,CAACsC,SAAS,IAAI,IAAI;QACnCtB,QAAQ,EAAEhB,MAAM,CAACgB,QAAQ;QACzBC,YAAY,EAAEjB,MAAM,CAACiB,YAAY;QACjCX,cAAc;QACdJ,MAAM;QACNC,MAAM;QACNqB,SAAS,EAAExB,MAAM,CAACwB,SAAS;QAC3Bb,gBAAgB;QAChBD,gBAAgB;QAChB6B,eAAe,EAAEvC,MAAM,CAACuC,eAAe;QACvCL;MACF,CAAC,CAAC;MAEF,IAAIM,IAAI,GAAG,MAAMJ,GAAG,CAACI,IAAI,CAAC,CAAC;MAC3B,OAAO,CAACA,IAAI,CAACC,IAAI,EAAE;QACjB,MAAMD,IAAI,CAACE,KAAK;QAChBF,IAAI,GAAG,MAAMJ,GAAG,CAACI,IAAI,CAAC,CAAC;MACzB;MACA;MACAtD,QAAQ,GAAGsD,IAAI,CAACE,KAAK;IACvB,CAAC;IAEDC,KAAKA,CAAA,EAAG;MACNzD,QAAQ,GAAG,EAAE;MACbgB,MAAM,CAAC0C,KAAK,CAAC,CAAC;MACd;MACA;MACA;MACAvC,MAAM,GAAG,KAAK;IAChB;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["CATALOG","buildContextDigest","buildLiveContext","runAgentTurn","buildLiveBlock","buildSystemPrompt","listableProcedures","EffectLedger","EvidenceStore","TokenCalibration","compressConsumed","trimHistory","trimHistoryReport","createAnthropicProvider","createOpenAIProvider","resolveRequireApproval","registerSelfEndpoint","resumableHistory","history","end","length","m","role","toolCalls","slice","map","thinking","undefined","createAskBuoySession","config","catalog","ledger","policy","messages","seenUrls","Set","evidence","calibration","system","primed","bypassApproval","trusted","deviceReadOnly","trimmedOnRestore","generation","digest","storeKeyOwners","endpoint","provider","protocol","availableActions","availableToolIds","Object","keys","live","refreshLive","k","assign","requireApproval","requireApprovalFor","readOnly","activePolicy","composeSystem","context","isRelease","readOnlySource","approvalsBypassed","appName","platform","prime","dispatch","readSnapshot","raw","zustandStores","store","persistsTo","name","trustedActions","untrust","key","delete","setAvailableActions","actions","setApprovalBypass","enabled","setReadOnly","restore","report","charsPerToken","liveCallIds","droppedRounds","send","text","signal","myGeneration","type","stopReason","trimmed","working","droppedPinned","gen","systemVolatile","list","e","label","toolId","action","effect","undone","undoneAt","model","maxTokens","requestApproval","procedures","next","done","value","reset","clear"],"sourceRoot":"../../src","sources":["session.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,qBAAqB;AAC7C,SAASC,kBAAkB,EAAEC,gBAAgB,QAAQ,4BAA4B;AACjF,SAASC,YAAY,QAA6C,uBAAuB;AACzF,SAASC,cAAc,EAAEC,iBAAiB,EAAEC,kBAAkB,QAA0B,uBAAuB;AAC/G,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,SACEC,gBAAgB,EAEhBC,WAAW,EACXC,iBAAiB,QACZ,wBAAwB;AAC/B,SAASC,uBAAuB,QAAQ,uBAAuB;AAC/D,SAASC,oBAAoB,QAAQ,oBAAoB;AAEzD,SAASC,sBAAsB,QAA4B,iBAAiB;AAC5E,SAASC,oBAAoB,QAAQ,iBAAiB;AA+GtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASN,gBAAgB,EAAEC,WAAW,EAAEC,iBAAiB;AAEzD,OAAO,SAASK,gBAAgBA,CAACC,OAAuB,EAAkB;EACxE,IAAIC,GAAG,GAAGD,OAAO,CAACE,MAAM;EACxB,OAAOD,GAAG,GAAG,CAAC,EAAE;IACd,MAAME,CAAC,GAAGH,OAAO,CAACC,GAAG,GAAG,CAAC,CAAE;IAC3B,IAAIE,CAAC,CAACC,IAAI,KAAK,WAAW,IAAI,CAACD,CAAC,CAACE,SAAS,EAAEH,MAAM,E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H","ignoreList":[]}
@@ -12,6 +12,11 @@ export interface ReceiptInput {
12
12
  result: unknown;
13
13
  /** From captureBefore, when the engine read the prior value. */
14
14
  before?: unknown;
15
+ /**
16
+ * The same read taken AFTER the call landed, for the projectors that show a
17
+ * diff. Present only where the engine captures both sides (zustand's store).
18
+ */
19
+ after?: unknown;
15
20
  effect: "read" | "write" | "destructive";
16
21
  }
17
22
  /**