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