@luckydraw/cumulus 1.0.38 → 1.0.40

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 (46) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/gateway/adapters/webchat.d.ts +3 -0
  3. package/dist/gateway/adapters/webchat.d.ts.map +1 -1
  4. package/dist/gateway/adapters/webchat.js +84 -1
  5. package/dist/gateway/adapters/webchat.js.map +1 -1
  6. package/dist/gateway/config.d.ts +16 -2
  7. package/dist/gateway/config.d.ts.map +1 -1
  8. package/dist/gateway/config.js +12 -6
  9. package/dist/gateway/config.js.map +1 -1
  10. package/dist/gateway/daemon.d.ts +1 -0
  11. package/dist/gateway/daemon.d.ts.map +1 -1
  12. package/dist/gateway/daemon.js +4 -0
  13. package/dist/gateway/daemon.js.map +1 -1
  14. package/dist/gateway/one-shot-model.d.ts +92 -0
  15. package/dist/gateway/one-shot-model.d.ts.map +1 -0
  16. package/dist/gateway/one-shot-model.js +191 -0
  17. package/dist/gateway/one-shot-model.js.map +1 -0
  18. package/dist/gateway/server.d.ts +3 -0
  19. package/dist/gateway/server.d.ts.map +1 -1
  20. package/dist/gateway/server.js +4 -0
  21. package/dist/gateway/server.js.map +1 -1
  22. package/dist/gateway/stall-detection.d.ts +19 -50
  23. package/dist/gateway/stall-detection.d.ts.map +1 -1
  24. package/dist/gateway/stall-detection.js +27 -190
  25. package/dist/gateway/stall-detection.js.map +1 -1
  26. package/dist/gateway/static/widget.js +342 -35
  27. package/dist/gateway/tasks-refresh.d.ts +89 -0
  28. package/dist/gateway/tasks-refresh.d.ts.map +1 -0
  29. package/dist/gateway/tasks-refresh.js +224 -0
  30. package/dist/gateway/tasks-refresh.js.map +1 -0
  31. package/dist/gateway/tasks.d.ts +21 -1
  32. package/dist/gateway/tasks.d.ts.map +1 -1
  33. package/dist/gateway/tasks.js +62 -10
  34. package/dist/gateway/tasks.js.map +1 -1
  35. package/dist/gateway/worker.d.ts +86 -0
  36. package/dist/gateway/worker.d.ts.map +1 -0
  37. package/dist/gateway/worker.js +0 -0
  38. package/dist/gateway/worker.js.map +1 -0
  39. package/dist/lib/tasks-file.d.ts +23 -0
  40. package/dist/lib/tasks-file.d.ts.map +1 -1
  41. package/dist/lib/tasks-file.js +49 -0
  42. package/dist/lib/tasks-file.js.map +1 -1
  43. package/dist/lib/tasks-format.d.ts.map +1 -1
  44. package/dist/lib/tasks-format.js +12 -5
  45. package/dist/lib/tasks-format.js.map +1 -1
  46. package/package.json +1 -1
@@ -16,57 +16,17 @@
16
16
  * the worse failure (Karl, 2026-08-30).
17
17
  *
18
18
  * The classifier runs on WHATEVER model the operator configured
19
- * (`stallClassifierModel`), not just a Claude sub-model (task 165). It routes
20
- * through `resolveModelProvider` — the same single source of truth every other
21
- * model in the gateway uses — and branches: a Claude CLI sub-model runs as a
22
- * one-off `claude --print --model <id>` call; any other catalog model runs as a
23
- * one-shot HTTP `chat()` through the provider the resolver picks. The prompt
24
- * and the fail-closed contract are identical on both branches.
19
+ * (`stallClassifierModel`), not just a Claude sub-model (task 165), via
20
+ * `runOneShotModel` — the one way the gateway itself calls a model (task 179).
21
+ * This module owns the PROMPT and the fail-closed reading of the answer; which
22
+ * provider runs it, and how, lives in `one-shot-model.ts`.
25
23
  */
24
+ import { type OneShotModelContext } from './one-shot-model.js';
26
25
  export declare function hasUncheckedTodo(text: string): boolean;
27
26
  /** Last `n` sentences of a message — the classifier only needs the tail, not the whole thing. */
28
27
  export declare function lastSentences(text: string, n?: number): string;
29
28
  /** The single dangling sentence to quote back in the nudge message. */
30
29
  export declare function extractDanglingSentence(text: string): string;
31
- /**
32
- * Everything the classifier needs to decide WHICH provider runs the configured
33
- * model and HOW to reach it. Mirrors the fields `server.ts` already threads into
34
- * every turn's `sendMessage`, so the classifier resolves its model exactly the way
35
- * a turn does — no second notion of "how do I run a non-Claude model."
36
- */
37
- export interface StallClassifierContext {
38
- /** Direct-provider catalog (HF / OpenAI / custom entries). */
39
- models?: Array<{
40
- id: string;
41
- provider?: string;
42
- contextWindow?: number;
43
- }>;
44
- /** Claude CLI sub-model catalog (Opus / Sonnet / Haiku variants). */
45
- claudeModels?: Array<{
46
- id: string;
47
- }>;
48
- hfApiKey?: string;
49
- openaiApiKey?: string;
50
- customProviders?: Array<{
51
- id: string;
52
- baseUrl: string;
53
- apiKey?: string;
54
- }>;
55
- }
56
- /**
57
- * Resolve the configured stall-classifier model id against BOTH catalogs.
58
- *
59
- * An id naming a `claudeModels[]` entry runs as a Claude CLI sub-model; an id
60
- * naming a `models[]` entry runs on that entry's direct provider (task 165). An
61
- * id that names nothing in either (absent, blank, or stale after a catalog edit)
62
- * falls back to `"haiku"` rather than failing closed, since the classifier is a
63
- * best-effort fallback signal, not a correctness gate.
64
- */
65
- export declare function resolveStallClassifierModel(stallClassifierModel: string | undefined, claudeModels?: Array<{
66
- id: string;
67
- }>, models?: Array<{
68
- id: string;
69
- }>): string;
70
30
  export interface ClassifyStallOptions {
71
31
  timeoutMs?: number;
72
32
  /**
@@ -80,15 +40,24 @@ export interface ClassifyStallOptions {
80
40
  * routed through `resolveModelProvider` and run on whatever provider that
81
41
  * names — a Claude CLI sub-model or a direct-provider HTTP model (task 165).
82
42
  */
83
- context?: StallClassifierContext;
43
+ context?: OneShotModelContext;
84
44
  }
85
45
  /**
86
46
  * Cheap-model classification for the "trails off with no `<todo>` at all" case.
87
47
  *
88
- * Routes the configured model through `resolveModelProvider` and runs it on
89
- * whatever provider that names: a Claude CLI sub-model as a one-off
90
- * `claude --print --model <id>` call, any other catalog model as a one-shot
91
- * HTTP `chat()` (task 165). Fails closed on every branch.
48
+ * The provider branch lives in `runOneShotModel` (task 179); what stays here is
49
+ * the part that is the classifier's own the prompt, the tail-of-message snippet
50
+ * it runs on, and the fail-closed reading of the answer.
51
+ *
52
+ * `reasoningEffort: 'low'` (task 166) because the classification is a trivial
53
+ * binary read of a few sentences and must not deliberate; `CLASSIFIER_MAX_TOKENS`
54
+ * (task 167) because on both HTTP providers that budget bounds REASONING +
55
+ * CONTENT together, so it has to hold the whole low-effort thinking pass before
56
+ * the one-word verdict can be emitted at all.
57
+ *
58
+ * Fails closed on every branch: a `null` answer (spawn failure, non-zero exit,
59
+ * timeout, provider throw) and a non-"YES" answer are both "no nudge", because
60
+ * prodding a thread that correctly finished is the worse failure.
92
61
  */
93
62
  export declare function classifyStall(text: string, opts?: ClassifyStallOptions): Promise<boolean>;
94
63
  /** Is the last message from the thread's own `<todo>`/classifier signals a stall? */
@@ -1 +1 @@
1
- {"version":3,"file":"stall-detection.d.ts","sourceRoot":"","sources":["../../src/gateway/stall-detection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAYH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAUtD;AAkCD,iGAAiG;AACjG,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,SAAI,GAAG,MAAM,CAEzD;AAED,uEAAuE;AACvE,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG5D;AAeD;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACrC,8DAA8D;IAC9D,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1E,qEAAqE;IACrE,YAAY,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CA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AAO,CAAC;IAClB,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAMD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,GAAG,aAAa,CAKhB;AAID,6FAA6F;AAC7F,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,qEAAqE;AACrE,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,cAAc,EAAE,GAAG,SAAS,EAClC,SAAS,EAAE,mBAAmB,EAAE,GAAG,SAAS,EAC5C,GAAG,GAAE,MAAmB,GACvB,MAAM,GAAG,IAAI,CAgBf"}
@@ -16,17 +16,12 @@
16
16
  * the worse failure (Karl, 2026-08-30).
17
17
  *
18
18
  * The classifier runs on WHATEVER model the operator configured
19
- * (`stallClassifierModel`), not just a Claude sub-model (task 165). It routes
20
- * through `resolveModelProvider` — the same single source of truth every other
21
- * model in the gateway uses — and branches: a Claude CLI sub-model runs as a
22
- * one-off `claude --print --model <id>` call; any other catalog model runs as a
23
- * one-shot HTTP `chat()` through the provider the resolver picks. The prompt
24
- * and the fail-closed contract are identical on both branches.
19
+ * (`stallClassifierModel`), not just a Claude sub-model (task 165), via
20
+ * `runOneShotModel` — the one way the gateway itself calls a model (task 179).
21
+ * This module owns the PROMPT and the fail-closed reading of the answer; which
22
+ * provider runs it, and how, lives in `one-shot-model.ts`.
25
23
  */
26
- import { spawn } from 'child_process';
27
- import { resolveModelProvider } from '../lib/gateway.js';
28
- import { HuggingFaceProvider } from '../lib/huggingface-provider.js';
29
- import { OpenAIResponsesProvider } from '../lib/openai-responses-provider.js';
24
+ import { runOneShotModel } from './one-shot-model.js';
30
25
  /** Last (authoritative, full-replacement) `<todo>` block still has an open `[ ]` item. */
31
26
  const TODO_BLOCK_RE = /<todo>([\s\S]*?)<\/todo>/g;
32
27
  const UNCHECKED_ITEM_RE = /\[\s\]/;
@@ -95,25 +90,6 @@ const STALL_CLASSIFIER_PROMPT = (snippet) => `You are checking whether an AI ass
95
90
  `message reads as a completed thought, a finished answer, a question back to the user, an ` +
96
91
  `offer awaiting the user's decision, or anything you are not certain about, answer NO.\n\n` +
97
92
  `Respond with exactly one word: YES or NO.`;
98
- /**
99
- * Resolve the configured stall-classifier model id against BOTH catalogs.
100
- *
101
- * An id naming a `claudeModels[]` entry runs as a Claude CLI sub-model; an id
102
- * naming a `models[]` entry runs on that entry's direct provider (task 165). An
103
- * id that names nothing in either (absent, blank, or stale after a catalog edit)
104
- * falls back to `"haiku"` rather than failing closed, since the classifier is a
105
- * best-effort fallback signal, not a correctness gate.
106
- */
107
- export function resolveStallClassifierModel(stallClassifierModel, claudeModels, models) {
108
- const id = stallClassifierModel?.trim();
109
- if (!id)
110
- return 'haiku';
111
- if (claudeModels?.some(entry => entry.id === id))
112
- return id;
113
- if (models?.some(entry => entry.id === id))
114
- return id;
115
- return 'haiku';
116
- }
117
93
  // ─── Classifier execution ───────────────────────────────────────────────────────
118
94
  /**
119
95
  * Output budget for the HTTP classifier call (task 167).
@@ -131,175 +107,36 @@ export function resolveStallClassifierModel(stallClassifierModel, claudeModels,
131
107
  */
132
108
  const CLASSIFIER_MAX_TOKENS = 512;
133
109
  /**
134
- * The Claude CLI branch: a one-off `claude --print --model <model>` call, not a
135
- * full agentic turn. Fails closed: any error, non-zero exit, timeout, or
136
- * non-"YES" response resolves to `false` (no nudge).
110
+ * Cheap-model classification for the "trails off with no `<todo>` at all" case.
137
111
  *
138
- * The prompt goes in as PLAIN TEXT on stdin not `--input-format stream-json`.
139
- * That flag requires a matching `--output-format stream-json --verbose`, and without
140
- * it the CLI errors before reaching the model (`Error: --input-format=stream-json
141
- * requires output-format=stream-json.`), so the classifier would fail closed on every
142
- * call and the fallback signal would be dead. Plain text on stdin is the form that
143
- * actually works and sidesteps ARG_MAX for long prompts.
144
- */
145
- async function classifyViaClaudeCli(text, model, timeoutMs) {
146
- const snippet = lastSentences(text, 6);
147
- if (!snippet)
148
- return false;
149
- return new Promise(resolve => {
150
- const args = ['--print', '--model', model];
151
- const cleanEnv = Object.fromEntries(Object.entries(process.env).filter(([key]) => !key.startsWith('CLAUDE') && key !== 'CLAUDECODE'));
152
- let claude;
153
- try {
154
- claude = spawn('claude', args, {
155
- stdio: ['pipe', 'pipe', 'pipe'],
156
- env: cleanEnv,
157
- shell: process.platform === 'win32',
158
- windowsHide: true,
159
- });
160
- }
161
- catch {
162
- resolve(false);
163
- return;
164
- }
165
- // Plain text on stdin (see doc comment) — no JSON envelope, no --input-format.
166
- claude.stdin?.write(STALL_CLASSIFIER_PROMPT(snippet));
167
- claude.stdin?.end();
168
- let stdout = '';
169
- let settled = false;
170
- const finish = (result) => {
171
- if (settled)
172
- return;
173
- settled = true;
174
- clearTimeout(timer);
175
- resolve(result);
176
- };
177
- const timer = setTimeout(() => {
178
- claude.kill();
179
- finish(false);
180
- }, timeoutMs);
181
- timer.unref?.();
182
- claude.stdout?.on('data', (data) => {
183
- stdout += data.toString();
184
- });
185
- claude.on('close', code => {
186
- if (code !== 0) {
187
- finish(false);
188
- return;
189
- }
190
- finish(/^YES\b/i.test(stdout.trim()));
191
- });
192
- claude.on('error', () => finish(false));
193
- });
194
- }
195
- /**
196
- * The direct-provider branch (task 165): a one-shot HTTP `chat()` through the
197
- * provider `resolveModelProvider` picked for the configured model. No tools, no
198
- * system prompt beyond the classifier prompt. The answer is one word, but the
199
- * `maxTokens` budget must be large enough to hold a reasoning model's thinking pass
200
- * first (task 167). Fails closed exactly like the CLI branch: any throw, timeout, or
201
- * non-"YES" response resolves to `false`.
112
+ * The provider branch lives in `runOneShotModel` (task 179); what stays here is
113
+ * the part that is the classifier's own the prompt, the tail-of-message snippet
114
+ * it runs on, and the fail-closed reading of the answer.
202
115
  *
203
- * Task 166 two changes so a REASONING model can actually emit the verdict:
204
- * - `reasoningEffort: 'low'`. The classification is a trivial binary read of a
205
- * few sentences; it must not deliberate. At the default effort a reasoning
206
- * model spends its whole output budget thinking and never reaches the content
207
- * phase, so the answer is empty and this fails closed on every call — the
208
- * detector was structurally dead for reasoning models.
209
- * - The verdict is parsed from the streamed `text` events, not `response.content`.
210
- * Both HTTP providers emit `text` events for CONTENT only — reasoning is
211
- * accumulated separately and never streamed as a `text` event. But
212
- * `response.content` folds reasoning in as a last-resort text block
213
- * (`fullText || reasoningText`), so reading the blocks can hand the parser the
214
- * model's private scratch paper. The `text` events are the channel that is
215
- * guaranteed to be the actual answer; if none ever arrive, the answer is empty
216
- * and we fail closed, exactly as before.
116
+ * `reasoningEffort: 'low'` (task 166) because the classification is a trivial
117
+ * binary read of a few sentences and must not deliberate; `CLASSIFIER_MAX_TOKENS`
118
+ * (task 167) because on both HTTP providers that budget bounds REASONING +
119
+ * CONTENT together, so it has to hold the whole low-effort thinking pass before
120
+ * the one-word verdict can be emitted at all.
217
121
  *
218
- * Task 167 the third, load-bearing half. `reasoningEffort: 'low'` alone was NOT
219
- * sufficient: on both HTTP providers `maxTokens` bounds REASONING + CONTENT together,
220
- * and the pre-167 value (16) was smaller than even a low-effort thinking pass, so the
221
- * model still ran out of budget mid-reasoning and emitted no `text` event. The budget
222
- * had to grow to `CLASSIFIER_MAX_TOKENS` (512) to hold the thinking pass AND the
223
- * verdict. (The 166 comment originally claimed capping effort at `low` was what let
224
- * the model "finish thinking inside `maxTokens`" — it did not; the budget was the
225
- * binding constraint all along.)
122
+ * Fails closed on every branch: a `null` answer (spawn failure, non-zero exit,
123
+ * timeout, provider throw) and a non-"YES" answer are both "no nudge", because
124
+ * prodding a thread that correctly finished is the worse failure.
226
125
  */
227
- async function classifyViaHttp(text, modelId, resolved, timeoutMs) {
126
+ export async function classifyStall(text, opts = {}) {
228
127
  const snippet = lastSentences(text, 6);
229
128
  if (!snippet)
230
129
  return false;
231
- const provider = resolved.wireProtocol === 'openai-responses'
232
- ? new OpenAIResponsesProvider(resolved.apiKey, resolved.baseUrl)
233
- : new HuggingFaceProvider(resolved.apiKey, modelId, resolved.baseUrl);
234
- const controller = new AbortController();
235
- const timer = setTimeout(() => controller.abort(), timeoutMs);
236
- timer.unref?.();
237
- let answer = '';
238
- try {
239
- await provider.chat({
240
- model: modelId,
241
- system: [],
242
- messages: [{ role: 'user', content: STALL_CLASSIFIER_PROMPT(snippet) }],
243
- tools: [],
244
- maxTokens: CLASSIFIER_MAX_TOKENS,
245
- reasoningEffort: 'low',
246
- signal: controller.signal,
247
- onEvent: event => {
248
- if (event.type === 'text' && event.text)
249
- answer += event.text;
250
- },
251
- });
252
- return /^YES\b/i.test(answer.trim());
253
- }
254
- catch {
255
- // Any provider error, abort, or malformed response fails closed to "no nudge".
256
- return false;
257
- }
258
- finally {
259
- clearTimeout(timer);
260
- }
261
- }
262
- /**
263
- * Cheap-model classification for the "trails off with no `<todo>` at all" case.
264
- *
265
- * Routes the configured model through `resolveModelProvider` and runs it on
266
- * whatever provider that names: a Claude CLI sub-model as a one-off
267
- * `claude --print --model <id>` call, any other catalog model as a one-shot
268
- * HTTP `chat()` (task 165). Fails closed on every branch.
269
- */
270
- export async function classifyStall(text, opts = {}) {
271
- const timeoutMs = opts.timeoutMs ?? 10000;
272
- const ctx = opts.context;
273
- // No context: preserve the task-164 behavior — the configured id (or "haiku")
274
- // runs directly as a Claude CLI sub-model. This is what unit tests and any
275
- // caller without a catalog rely on.
276
- if (!ctx) {
277
- const model = opts.model?.trim() || 'haiku';
278
- return classifyViaClaudeCli(text, model, timeoutMs);
279
- }
280
- const modelId = resolveStallClassifierModel(opts.model, ctx.claudeModels, ctx.models);
281
- // A Claude CLI sub-model runs on the CLI — detected by membership in claudeModels[],
282
- // plus the "haiku" fallback (a valid CLI alias). These are NEVER passed to
283
- // resolveModelProvider: that resolver's contract is "claude" or a direct-provider id,
284
- // and feeding it a Claude sub-model id would fall through to the HF branch and
285
- // misroute a Claude model over HTTP when an HF key is present.
286
- const isClaudeSub = modelId === 'haiku' || ctx.claudeModels?.some(entry => entry.id === modelId);
287
- if (isClaudeSub) {
288
- return classifyViaClaudeCli(text, modelId, timeoutMs);
289
- }
290
- // A direct-provider model: route through the same single source of truth every turn
291
- // uses (task 118/147). No second notion of "how do I run a non-Claude model."
292
- const resolved = resolveModelProvider(modelId, ctx.models, {
293
- hfApiKey: ctx.hfApiKey,
294
- openaiApiKey: ctx.openaiApiKey,
295
- customProviders: ctx.customProviders,
130
+ const answer = await runOneShotModel(STALL_CLASSIFIER_PROMPT(snippet), {
131
+ model: opts.model,
132
+ context: opts.context,
133
+ timeoutMs: opts.timeoutMs ?? 10000,
134
+ maxTokens: CLASSIFIER_MAX_TOKENS,
135
+ reasoningEffort: 'low',
296
136
  });
297
- if (!resolved.isAgentic) {
298
- // Gate closed (no credential for the resolved provider) — degrade to the default
299
- // Claude sub-model rather than spawning a doomed HTTP loop.
300
- return classifyViaClaudeCli(text, 'haiku', timeoutMs);
301
- }
302
- return classifyViaHttp(text, modelId, resolved, timeoutMs);
137
+ if (answer === null)
138
+ return false;
139
+ return /^YES\b/i.test(answer.trim());
303
140
  }
304
141
  /** Is the last message from the thread's own `<todo>`/classifier signals a stall? */
305
142
  export async function isStalled(text, opts = {}) {
@@ -1 +1 @@
1
- {"version":3,"file":"stall-detection.js","sourceRoot":"","sources":["../../src/gateway/stall-detection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,oBAAoB,EAA8B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