@buoy-gg/agent-core 7.0.34 → 7.0.36

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 (181) hide show
  1. package/README.md +10 -7
  2. package/lib/commonjs/blocks/receipts.js +83 -24
  3. package/lib/commonjs/blocks/receipts.js.map +1 -1
  4. package/lib/commonjs/blocks/runId.js +31 -0
  5. package/lib/commonjs/blocks/runId.js.map +1 -0
  6. package/lib/commonjs/blocks/types.js +23 -2
  7. package/lib/commonjs/blocks/types.js.map +1 -1
  8. package/lib/commonjs/blocks/uiTool.js +426 -12
  9. package/lib/commonjs/blocks/uiTool.js.map +1 -1
  10. package/lib/commonjs/catalog/catalog.g.js +121 -43
  11. package/lib/commonjs/catalog/catalog.g.js.map +1 -1
  12. package/lib/commonjs/catalog/catalog.source.json +121 -45
  13. package/lib/commonjs/catalog/catalog.types.g.js +44 -0
  14. package/lib/commonjs/catalog/catalog.types.g.js.map +1 -0
  15. package/lib/commonjs/catalog/normalizeParams.js +333 -0
  16. package/lib/commonjs/catalog/normalizeParams.js.map +1 -0
  17. package/lib/commonjs/catalog/signature.js +68 -0
  18. package/lib/commonjs/catalog/signature.js.map +1 -0
  19. package/lib/commonjs/catalog/snapshotReads.js +13 -6
  20. package/lib/commonjs/catalog/snapshotReads.js.map +1 -1
  21. package/lib/commonjs/catalog/toProviderTools.js +41 -5
  22. package/lib/commonjs/catalog/toProviderTools.js.map +1 -1
  23. package/lib/commonjs/context/buildContextPack.js +367 -19
  24. package/lib/commonjs/context/buildContextPack.js.map +1 -1
  25. package/lib/commonjs/effects/digest.js +34 -0
  26. package/lib/commonjs/effects/digest.js.map +1 -0
  27. package/lib/commonjs/effects/ledger.js +85 -1
  28. package/lib/commonjs/effects/ledger.js.map +1 -1
  29. package/lib/commonjs/engine/askGate.js +287 -0
  30. package/lib/commonjs/engine/askGate.js.map +1 -0
  31. package/lib/commonjs/engine/effectFor.js +82 -1
  32. package/lib/commonjs/engine/effectFor.js.map +1 -1
  33. package/lib/commonjs/engine/historyBudget.js +260 -0
  34. package/lib/commonjs/engine/historyBudget.js.map +1 -0
  35. package/lib/commonjs/engine/runAgentTurn.js +958 -88
  36. package/lib/commonjs/engine/runAgentTurn.js.map +1 -1
  37. package/lib/commonjs/engine/systemPrompt.js +72 -8
  38. package/lib/commonjs/engine/systemPrompt.js.map +1 -1
  39. package/lib/commonjs/engine/textToolCalls.js +276 -0
  40. package/lib/commonjs/engine/textToolCalls.js.map +1 -0
  41. package/lib/commonjs/index.js +81 -1
  42. package/lib/commonjs/index.js.map +1 -1
  43. package/lib/commonjs/policy/labels.js +19 -3
  44. package/lib/commonjs/policy/labels.js.map +1 -1
  45. package/lib/commonjs/policy/policy.js +6 -1
  46. package/lib/commonjs/policy/policy.js.map +1 -1
  47. package/lib/commonjs/policy/redact.js +42 -5
  48. package/lib/commonjs/policy/redact.js.map +1 -1
  49. package/lib/commonjs/providers/anthropic.js +340 -174
  50. package/lib/commonjs/providers/anthropic.js.map +1 -1
  51. package/lib/commonjs/providers/openai.js +229 -103
  52. package/lib/commonjs/providers/openai.js.map +1 -1
  53. package/lib/commonjs/providers/sse.js +164 -29
  54. package/lib/commonjs/providers/sse.js.map +1 -1
  55. package/lib/commonjs/providers/streamTimer.js +123 -0
  56. package/lib/commonjs/providers/streamTimer.js.map +1 -0
  57. package/lib/commonjs/providers/transport.js +107 -0
  58. package/lib/commonjs/providers/transport.js.map +1 -0
  59. package/lib/commonjs/providers/xhrStream.js +209 -0
  60. package/lib/commonjs/providers/xhrStream.js.map +1 -0
  61. package/lib/commonjs/session.js +245 -52
  62. package/lib/commonjs/session.js.map +1 -1
  63. package/lib/module/blocks/receipts.js +83 -24
  64. package/lib/module/blocks/receipts.js.map +1 -1
  65. package/lib/module/blocks/runId.js +26 -0
  66. package/lib/module/blocks/runId.js.map +1 -0
  67. package/lib/module/blocks/types.js +23 -2
  68. package/lib/module/blocks/types.js.map +1 -1
  69. package/lib/module/blocks/uiTool.js +424 -12
  70. package/lib/module/blocks/uiTool.js.map +1 -1
  71. package/lib/module/catalog/catalog.g.js +121 -43
  72. package/lib/module/catalog/catalog.g.js.map +1 -1
  73. package/lib/module/catalog/catalog.source.json +121 -45
  74. package/lib/module/catalog/catalog.types.g.js +40 -0
  75. package/lib/module/catalog/catalog.types.g.js.map +1 -0
  76. package/lib/module/catalog/normalizeParams.js +327 -0
  77. package/lib/module/catalog/normalizeParams.js.map +1 -0
  78. package/lib/module/catalog/signature.js +63 -0
  79. package/lib/module/catalog/signature.js.map +1 -0
  80. package/lib/module/catalog/snapshotReads.js +13 -6
  81. package/lib/module/catalog/snapshotReads.js.map +1 -1
  82. package/lib/module/catalog/toProviderTools.js +41 -5
  83. package/lib/module/catalog/toProviderTools.js.map +1 -1
  84. package/lib/module/context/buildContextPack.js +366 -19
  85. package/lib/module/context/buildContextPack.js.map +1 -1
  86. package/lib/module/effects/digest.js +29 -0
  87. package/lib/module/effects/digest.js.map +1 -0
  88. package/lib/module/effects/ledger.js +85 -1
  89. package/lib/module/effects/ledger.js.map +1 -1
  90. package/lib/module/engine/askGate.js +280 -0
  91. package/lib/module/engine/askGate.js.map +1 -0
  92. package/lib/module/engine/effectFor.js +83 -1
  93. package/lib/module/engine/effectFor.js.map +1 -1
  94. package/lib/module/engine/historyBudget.js +251 -0
  95. package/lib/module/engine/historyBudget.js.map +1 -0
  96. package/lib/module/engine/runAgentTurn.js +954 -88
  97. package/lib/module/engine/runAgentTurn.js.map +1 -1
  98. package/lib/module/engine/systemPrompt.js +71 -8
  99. package/lib/module/engine/systemPrompt.js.map +1 -1
  100. package/lib/module/engine/textToolCalls.js +270 -0
  101. package/lib/module/engine/textToolCalls.js.map +1 -0
  102. package/lib/module/index.js +7 -4
  103. package/lib/module/index.js.map +1 -1
  104. package/lib/module/policy/labels.js +19 -3
  105. package/lib/module/policy/labels.js.map +1 -1
  106. package/lib/module/policy/policy.js +6 -1
  107. package/lib/module/policy/policy.js.map +1 -1
  108. package/lib/module/policy/redact.js +42 -5
  109. package/lib/module/policy/redact.js.map +1 -1
  110. package/lib/module/providers/anthropic.js +341 -175
  111. package/lib/module/providers/anthropic.js.map +1 -1
  112. package/lib/module/providers/openai.js +230 -104
  113. package/lib/module/providers/openai.js.map +1 -1
  114. package/lib/module/providers/sse.js +160 -29
  115. package/lib/module/providers/sse.js.map +1 -1
  116. package/lib/module/providers/streamTimer.js +118 -0
  117. package/lib/module/providers/streamTimer.js.map +1 -0
  118. package/lib/module/providers/transport.js +103 -0
  119. package/lib/module/providers/transport.js.map +1 -0
  120. package/lib/module/providers/xhrStream.js +204 -0
  121. package/lib/module/providers/xhrStream.js.map +1 -0
  122. package/lib/module/session.js +228 -54
  123. package/lib/module/session.js.map +1 -1
  124. package/lib/typescript/blocks/receipts.d.ts +5 -10
  125. package/lib/typescript/blocks/receipts.d.ts.map +1 -1
  126. package/lib/typescript/blocks/runId.d.ts +20 -0
  127. package/lib/typescript/blocks/runId.d.ts.map +1 -0
  128. package/lib/typescript/blocks/types.d.ts +23 -2
  129. package/lib/typescript/blocks/types.d.ts.map +1 -1
  130. package/lib/typescript/blocks/uiTool.d.ts +11 -2
  131. package/lib/typescript/blocks/uiTool.d.ts.map +1 -1
  132. package/lib/typescript/catalog/catalog.g.d.ts.map +1 -1
  133. package/lib/typescript/catalog/catalog.types.g.d.ts +40 -0
  134. package/lib/typescript/catalog/catalog.types.g.d.ts.map +1 -0
  135. package/lib/typescript/catalog/normalizeParams.d.ts +43 -0
  136. package/lib/typescript/catalog/normalizeParams.d.ts.map +1 -0
  137. package/lib/typescript/catalog/signature.d.ts +29 -0
  138. package/lib/typescript/catalog/signature.d.ts.map +1 -0
  139. package/lib/typescript/catalog/snapshotReads.d.ts.map +1 -1
  140. package/lib/typescript/catalog/toProviderTools.d.ts +28 -15
  141. package/lib/typescript/catalog/toProviderTools.d.ts.map +1 -1
  142. package/lib/typescript/context/buildContextPack.d.ts +24 -2
  143. package/lib/typescript/context/buildContextPack.d.ts.map +1 -1
  144. package/lib/typescript/effects/digest.d.ts +10 -0
  145. package/lib/typescript/effects/digest.d.ts.map +1 -0
  146. package/lib/typescript/effects/ledger.d.ts +55 -0
  147. package/lib/typescript/effects/ledger.d.ts.map +1 -1
  148. package/lib/typescript/engine/askGate.d.ts +29 -0
  149. package/lib/typescript/engine/askGate.d.ts.map +1 -0
  150. package/lib/typescript/engine/effectFor.d.ts +6 -1
  151. package/lib/typescript/engine/effectFor.d.ts.map +1 -1
  152. package/lib/typescript/engine/historyBudget.d.ts +92 -0
  153. package/lib/typescript/engine/historyBudget.d.ts.map +1 -0
  154. package/lib/typescript/engine/runAgentTurn.d.ts +115 -1
  155. package/lib/typescript/engine/runAgentTurn.d.ts.map +1 -1
  156. package/lib/typescript/engine/systemPrompt.d.ts +41 -0
  157. package/lib/typescript/engine/systemPrompt.d.ts.map +1 -1
  158. package/lib/typescript/engine/textToolCalls.d.ts +58 -0
  159. package/lib/typescript/engine/textToolCalls.d.ts.map +1 -0
  160. package/lib/typescript/index.d.ts +8 -5
  161. package/lib/typescript/index.d.ts.map +1 -1
  162. package/lib/typescript/policy/labels.d.ts.map +1 -1
  163. package/lib/typescript/policy/policy.d.ts.map +1 -1
  164. package/lib/typescript/policy/redact.d.ts.map +1 -1
  165. package/lib/typescript/providers/anthropic.d.ts +5 -0
  166. package/lib/typescript/providers/anthropic.d.ts.map +1 -1
  167. package/lib/typescript/providers/openai.d.ts +0 -16
  168. package/lib/typescript/providers/openai.d.ts.map +1 -1
  169. package/lib/typescript/providers/sse.d.ts +82 -1
  170. package/lib/typescript/providers/sse.d.ts.map +1 -1
  171. package/lib/typescript/providers/streamTimer.d.ts +59 -0
  172. package/lib/typescript/providers/streamTimer.d.ts.map +1 -0
  173. package/lib/typescript/providers/transport.d.ts +40 -0
  174. package/lib/typescript/providers/transport.d.ts.map +1 -0
  175. package/lib/typescript/providers/types.d.ts +116 -3
  176. package/lib/typescript/providers/types.d.ts.map +1 -1
  177. package/lib/typescript/providers/xhrStream.d.ts +43 -0
  178. package/lib/typescript/providers/xhrStream.d.ts.map +1 -0
  179. package/lib/typescript/session.d.ts +63 -2
  180. package/lib/typescript/session.d.ts.map +1 -1
  181. package/package.json +2 -2
@@ -0,0 +1,251 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * How much conversation the model is allowed to be sent, and what gets cut.
5
+ *
6
+ * Lives here, not in `session.ts`, because it is needed in TWO places and used
7
+ * to run in only one. The session trims once per turn, before the loop starts
8
+ * — and a turn is not one request. A twelve-step investigation appends an
9
+ * assistant message and a tool-results message per step, each result capped at
10
+ * 24,000 characters, so a long read chain could add well over a hundred
11
+ * thousand characters AFTER the only check had already happened and walk
12
+ * straight into the provider's context limit. The engine now applies the same
13
+ * budget before every request; the session still applies it when a turn opens.
14
+ */
15
+
16
+ /**
17
+ * A long QA session must not die on the provider's context limit with an
18
+ * opaque error, so the history is kept under a budget.
19
+ *
20
+ * TWO STAGES, AND THE ORDER IS THE POINT. Dropping the oldest rounds was the
21
+ * only stage, and in a QA session the oldest round is usually the SETUP — the
22
+ * override that was armed, the store that was written, the user someone is
23
+ * impersonating. Drop it and the model can no longer explain the screen it is
24
+ * looking at, or that a "wrong" response is its own mock. The reply gets worse
25
+ * in exactly the sessions long enough to need trimming.
26
+ *
27
+ * So: COMPRESS first, DROP only if that was not enough.
28
+ *
29
+ * A tool result is "consumed" once the model has produced an assistant message
30
+ * after seeing it — it has already been reasoned over, and what remains is
31
+ * bulk. Replacing it with a marker keeps the round, its decision and its
32
+ * ordering while giving back nearly all the bytes. Three exemptions carry
33
+ * their weight:
34
+ *
35
+ * - Errors are never compressed. A failure is the diagnostic value.
36
+ * - The newest tool-results message is never compressed. The model is about
37
+ * to answer from it.
38
+ * - The last read before a WRITE is never compressed: that is the shape the
39
+ * model matched its edit to, and it is the thing it re-reads when the write
40
+ * is refused and it has to correct itself.
41
+ *
42
+ * Only if the history is still over budget do whole rounds get dropped, as
43
+ * before — a round starts at a user message, so the assistant/tool-result
44
+ * pairing every provider requires stays intact.
45
+ */
46
+ export const MAX_HISTORY_CHARS = 150_000;
47
+ /**
48
+ * The ceiling on a WHOLE request: tools, system prompt, messages and the room
49
+ * reserved for the reply. ~100k tokens, which fits the smallest context Ask
50
+ * Buoy is pointed at in practice (a 128k-token gateway) with headroom, and
51
+ * leaves Anthropic's 200k far from the limit.
52
+ */
53
+ export const MAX_REQUEST_CHARS = 400_000;
54
+ const MIN_KEEP_MESSAGES = 4;
55
+ /** Below this a marker costs more than the payload it replaces. */
56
+ const MIN_COMPRESS_CHARS = 400;
57
+ export function messageSize(m) {
58
+ try {
59
+ return JSON.stringify(m).length;
60
+ } catch {
61
+ return 0;
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Replace consumed tool results with a marker. See the note above
67
+ * MAX_HISTORY_CHARS for what "consumed" means and why the exemptions exist.
68
+ */
69
+ export function compressConsumed(messages) {
70
+ // The newest tool-results message: the model is about to answer from it.
71
+ let newest = -1;
72
+ for (let i = messages.length - 1; i >= 0; i--) {
73
+ if (messages[i].role === "tool-results") {
74
+ newest = i;
75
+ break;
76
+ }
77
+ }
78
+ if (newest <= 0) return messages;
79
+
80
+ // The reads a later write depended on. An assistant turn that called a
81
+ // write was matching a shape it read in the round before, and that is the
82
+ // read it goes back to when the write is refused.
83
+ const beforeWrite = new Set();
84
+ for (let i = 0; i < messages.length; i++) {
85
+ const m = messages[i];
86
+ if (m.role !== "assistant" || !m.toolCalls?.length) continue;
87
+ if (!m.toolCalls.some(c => WRITE_ISH.test(JSON.stringify(c.input ?? {}) + c.name))) continue;
88
+ for (let j = i - 1; j >= 0 && j >= i - 3; j--) {
89
+ if (messages[j].role === "tool-results") {
90
+ beforeWrite.add(j);
91
+ break;
92
+ }
93
+ }
94
+ }
95
+ let changed = false;
96
+ const out = messages.map((m, i) => {
97
+ if (m.role !== "tool-results" || i >= newest || beforeWrite.has(i)) return m;
98
+ let touched = false;
99
+ const results = m.results.map(r => {
100
+ if (r.isError || r.content.length < MIN_COMPRESS_CHARS) return r;
101
+ if (r.content.startsWith("[earlier result")) return r;
102
+ touched = true;
103
+ return {
104
+ ...r,
105
+ content: `[earlier result — ${r.content.length} characters, already read. Ask again if you need it.]`
106
+ };
107
+ });
108
+ if (!touched) return m;
109
+ changed = true;
110
+ return {
111
+ ...m,
112
+ results
113
+ };
114
+ });
115
+ return changed ? out : messages;
116
+ }
117
+
118
+ /**
119
+ * Heuristic for "this call changed something". Deliberately loose: the cost of
120
+ * a false positive is one uncompressed read, the cost of a false negative is
121
+ * the model losing the shape it was editing.
122
+ */
123
+ const WRITE_ISH = /set|write|dispatch|navigate|tap|override|restore|delete|remove|clear|save|run|impersonat|reload/i;
124
+
125
+ /**
126
+ * Trim, and say how many whole rounds were dropped — the number the UI turns
127
+ * into "older messages were trimmed from the agent's memory".
128
+ *
129
+ * A round is a user message and everything up to the next one. Once a drop
130
+ * starts it ALWAYS runs to the next user boundary: the inner loop used to stop
131
+ * at `MIN_KEEP_MESSAGES` as well, so a history could come out starting with an
132
+ * assistant or tool-results message — which every provider rejects. The
133
+ * minimum-keep guard belongs on STARTING a drop, not on finishing one.
134
+ */
135
+ export function trimHistoryReport(messages) {
136
+ let total = 0;
137
+ for (const m of messages) total += messageSize(m);
138
+ if (total <= MAX_HISTORY_CHARS) return {
139
+ messages,
140
+ droppedRounds: 0
141
+ };
142
+
143
+ // Compress before dropping — a compressed round still explains the screen.
144
+ const compressed = compressConsumed(messages);
145
+ let after = 0;
146
+ for (const m of compressed) after += messageSize(m);
147
+ if (after <= MAX_HISTORY_CHARS) return {
148
+ messages: compressed,
149
+ droppedRounds: 0
150
+ };
151
+ total = after;
152
+ const out = [...compressed];
153
+ let droppedRounds = 0;
154
+ while (out.length > MIN_KEEP_MESSAGES && total > MAX_HISTORY_CHARS) {
155
+ total -= messageSize(out[0]);
156
+ out.shift();
157
+ while (out.length > 0 && out[0].role !== "user") {
158
+ total -= messageSize(out[0]);
159
+ out.shift();
160
+ }
161
+ droppedRounds += 1;
162
+ }
163
+ return {
164
+ messages: out,
165
+ droppedRounds
166
+ };
167
+ }
168
+
169
+ /** Exported for the history tests; not part of the package surface. */
170
+ export function trimHistory(messages) {
171
+ return trimHistoryReport(messages).messages;
172
+ }
173
+
174
+ /**
175
+ * Trim the working history of a turn that is still running.
176
+ *
177
+ * Differs from `trimHistoryReport` in one way that matters: the CURRENT round
178
+ * is never touched. A turn's own user message and the reads it has taken since
179
+ * are the thing being answered, so compressing or dropping them would make the
180
+ * request cheaper and the answer wrong. Everything before the last user
181
+ * message is fair game, in the same order as always — compress, then drop.
182
+ *
183
+ * `reserve` is what the request costs BEFORE any messages: the tool
184
+ * definitions (~8k tokens for a typical install, ~23k with everything
185
+ * installed), the system prompt, and the reply the model is allowed to write.
186
+ * Budgeting messages alone would leave the biggest fixed cost out of the sum.
187
+ */
188
+ export function budgetForRequest(messages, reserve) {
189
+ /**
190
+ * `MAX_HISTORY_CHARS` is a MESSAGES budget and always was — subtracting the
191
+ * reserve from it is wrong by a wide margin. The tool block alone is ~94,000
192
+ * characters with every tool installed, and the system prompt another
193
+ * ~16,000, so `150,000 - reserve` left about 24,000 characters for the
194
+ * conversation and dropped every earlier round of a two-turn chat. Caught by
195
+ * the bank, which is exactly what it is for.
196
+ *
197
+ * So the messages budget is the smaller of the two ceilings: the one that
198
+ * has always applied, and whatever is left of the whole-request ceiling once
199
+ * the fixed cost is counted. In an ordinary install the first wins and
200
+ * nothing changes; the second only bites when the tools are huge.
201
+ */
202
+ const budget = Math.min(MAX_HISTORY_CHARS, MAX_REQUEST_CHARS - reserve);
203
+ let total = 0;
204
+ for (const m of messages) total += messageSize(m);
205
+ if (total <= budget) return {
206
+ messages,
207
+ droppedRounds: 0
208
+ };
209
+
210
+ // Where the current round begins. Nothing from here on is eligible.
211
+ let currentRound = -1;
212
+ for (let i = messages.length - 1; i >= 0; i--) {
213
+ if (messages[i].role === "user") {
214
+ currentRound = i;
215
+ break;
216
+ }
217
+ }
218
+ if (currentRound <= 0) return {
219
+ messages,
220
+ droppedRounds: 0
221
+ };
222
+ const earlier = messages.slice(0, currentRound);
223
+ const current = messages.slice(currentRound);
224
+ let currentSize = 0;
225
+ for (const m of current) currentSize += messageSize(m);
226
+ const compressed = compressConsumed(earlier);
227
+ let earlierSize = 0;
228
+ for (const m of compressed) earlierSize += messageSize(m);
229
+ if (earlierSize + currentSize <= budget) {
230
+ return {
231
+ messages: [...compressed, ...current],
232
+ droppedRounds: 0
233
+ };
234
+ }
235
+ const out = [...compressed];
236
+ let droppedRounds = 0;
237
+ while (out.length > 0 && earlierSize + currentSize > budget) {
238
+ earlierSize -= messageSize(out[0]);
239
+ out.shift();
240
+ while (out.length > 0 && out[0].role !== "user") {
241
+ earlierSize -= messageSize(out[0]);
242
+ out.shift();
243
+ }
244
+ droppedRounds += 1;
245
+ }
246
+ return {
247
+ messages: [...out, ...current],
248
+ droppedRounds
249
+ };
250
+ }
251
+ //# sourceMappingURL=historyBudget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["MAX_HISTORY_CHARS","MAX_REQUEST_CHARS","MIN_KEEP_MESSAGES","MIN_COMPRESS_CHARS","messageSize","m","JSON","stringify","length","compressConsumed","messages","newest","i","role","beforeWrite","Set","toolCalls","some","c","WRITE_ISH","test","input","name","j","add","changed","out","map","has","touched","results","r","isError","content","startsWith","trimHistoryReport","total","droppedRounds","compressed","after","shift","trimHistory","budgetForRequest","reserve","budget","Math","min","currentRound","earlier","slice","current","currentSize","earlierSize"],"sourceRoot":"../../../src","sources":["engine/historyBudget.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,iBAAiB,GAAG,OAAO;AACxC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO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