gemi 0.222.0 → 0.223.0
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.
- package/dist/ai/index.js +1 -1
- package/dist/bin/gemi.js +71 -54
- package/dist/bin/gemi.js.map +6 -5
- package/dist/{chunk-140r27bn.js → chunk-fn166jp3.js} +1 -1
- package/dist/{chunk-4xgjg08e.js → chunk-ke1q6hfm.js} +1 -1
- package/dist/chunk-p1ern8r4.js +577 -0
- package/dist/chunk-p1ern8r4.js.map +27 -0
- package/dist/{chunk-7czgj8ae.js → chunk-qtczhd81.js} +2 -2
- package/dist/{chunk-7czgj8ae.js.map → chunk-qtczhd81.js.map} +1 -1
- package/dist/{chunk-tn8gkch4.js → chunk-qvxs1vjh.js} +1 -1
- package/dist/{chunk-3b68kpz1.js → chunk-rw45xz3f.js} +3 -3
- package/dist/{chunk-3b68kpz1.js.map → chunk-rw45xz3f.js.map} +3 -3
- package/dist/{chunk-073j13t7.js → chunk-sqyf0gey.js} +1 -1
- package/dist/console/run.js +1 -1
- package/dist/kernel/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/services/index.d.ts +2 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/queue/DatabaseQueueDriver.d.ts +16 -0
- package/dist/services/queue/DatabaseQueueDriver.d.ts.map +1 -1
- package/dist/services/queue/DatabaseSlots.d.ts +100 -0
- package/dist/services/queue/DatabaseSlots.d.ts.map +1 -0
- package/dist/services/queue/Job.d.ts +20 -3
- package/dist/services/queue/Job.d.ts.map +1 -1
- package/dist/services/queue/MemoryQueueDriver.d.ts +11 -1
- package/dist/services/queue/MemoryQueueDriver.d.ts.map +1 -1
- package/dist/services/queue/QueueDriver.d.ts +24 -0
- package/dist/services/queue/QueueDriver.d.ts.map +1 -1
- package/dist/services/queue/QueueManager.d.ts +71 -8
- package/dist/services/queue/QueueManager.d.ts.map +1 -1
- package/dist/services/queue/slots.d.ts +111 -0
- package/dist/services/queue/slots.d.ts.map +1 -0
- package/dist/services/queue/work.js +1 -1
- package/dist/services/queue/workflow/MemoryWorkflowStore.d.ts +2 -0
- package/dist/services/queue/workflow/MemoryWorkflowStore.d.ts.map +1 -1
- package/dist/services/queue/workflow/Workflow.d.ts +16 -0
- package/dist/services/queue/workflow/Workflow.d.ts.map +1 -1
- package/dist/services/queue/workflow/WorkflowRuntime.d.ts +10 -0
- package/dist/services/queue/workflow/WorkflowRuntime.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-wcj7rjfe.js +0 -517
- package/dist/chunk-wcj7rjfe.js.map +0 -25
- /package/dist/{chunk-140r27bn.js.map → chunk-fn166jp3.js.map} +0 -0
- /package/dist/{chunk-4xgjg08e.js.map → chunk-ke1q6hfm.js.map} +0 -0
- /package/dist/{chunk-tn8gkch4.js.map → chunk-qvxs1vjh.js.map} +0 -0
- /package/dist/{chunk-073j13t7.js.map → chunk-sqyf0gey.js.map} +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Concurrency slots (#1319): at most `limit` holders per key, handed out in
|
|
3
|
+
* the order the work first asked, with waiting work parked rather than
|
|
4
|
+
* polling.
|
|
5
|
+
*
|
|
6
|
+
* ### The model
|
|
7
|
+
*
|
|
8
|
+
* Each key has a **line**: the holders of its slots and, behind them, the
|
|
9
|
+
* waiters, ordered by when each first asked (`order`, then the holder's id).
|
|
10
|
+
* A request is granted when the holders plus the waiters ahead of it are
|
|
11
|
+
* fewer than the limit, so work that asked later never overtakes work that
|
|
12
|
+
* asked earlier, however often either is re-admitted. A waiter keeps its
|
|
13
|
+
* place until it is granted or ends.
|
|
14
|
+
*
|
|
15
|
+
* A **holder** is a job (by its id) or a workflow (`workflow:<id>`). Several
|
|
16
|
+
* keys are taken in the order given and all are needed; a waiter for a later
|
|
17
|
+
* key keeps the earlier ones, since it is first in their lines anyway.
|
|
18
|
+
*
|
|
19
|
+
* ### Nothing waits in a process
|
|
20
|
+
*
|
|
21
|
+
* A request that cannot be granted parks its job: the claim goes back to
|
|
22
|
+
* waiting, its attempt taken back, due after `recheckMs` — `near` for a
|
|
23
|
+
* waiter among the first `limit` of its line (at least the first one), `far`
|
|
24
|
+
* for the rest — and in
|
|
25
|
+
* the same atomic step as the decision, so a slot freed a moment later is
|
|
26
|
+
* not missed. Whenever a line has free slots (a holder released, a limit
|
|
27
|
+
* was raised, a holder turned out to be gone), the step that sees it makes
|
|
28
|
+
* the first waiters due at once. The rechecks are only a safety net for a
|
|
29
|
+
* process that died between ending its work and handing its slot on.
|
|
30
|
+
*
|
|
31
|
+
* ### Holders that are gone
|
|
32
|
+
*
|
|
33
|
+
* A slot is never leased. A job's is valid while its job is still waiting
|
|
34
|
+
* or claimed (a crashed holder's job is reclaimed and takes its own slot
|
|
35
|
+
* back), and a workflow's while the workflow is neither ended nor paused.
|
|
36
|
+
* Every step on a line first drops the holders that are no longer valid, so
|
|
37
|
+
* a slot whose release was lost frees itself at the line's next step.
|
|
38
|
+
*/
|
|
39
|
+
import type { ClaimedJob } from "./QueueDriver";
|
|
40
|
+
/** One limit: at most `limit` holders of `key` at once. */
|
|
41
|
+
export type SlotLimit = {
|
|
42
|
+
key: string;
|
|
43
|
+
limit: number;
|
|
44
|
+
};
|
|
45
|
+
export type SlotRequest = {
|
|
46
|
+
/** A job's id, or `workflow:<id>` for a workflow's slots. */
|
|
47
|
+
holder: string;
|
|
48
|
+
/** For a workflow's slots: the workflow, whose status decides whether its slots are still held. */
|
|
49
|
+
workflowId?: string;
|
|
50
|
+
/** The claim that asks: parked when the request is not granted, and woken when its turn comes. */
|
|
51
|
+
job: ClaimedJob;
|
|
52
|
+
/** The limits, taken in this order. */
|
|
53
|
+
slots: SlotLimit[];
|
|
54
|
+
/** When a parked request is claimed again to re-check, in milliseconds. */
|
|
55
|
+
recheckMs: {
|
|
56
|
+
near: number;
|
|
57
|
+
far: number;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
/** The holder a workflow's slots are kept under. */
|
|
61
|
+
export declare function workflowHolder(workflowId: string): string;
|
|
62
|
+
/** The longest key a slot may have: it is a VARCHAR(191) column on MySQL. */
|
|
63
|
+
export declare const SLOT_KEY_LIMIT = 191;
|
|
64
|
+
/**
|
|
65
|
+
* What a job's or a workflow's `concurrency` returned, checked: one limit or
|
|
66
|
+
* a list, `undefined` or `null` for none. Throws, on the caller's attempt,
|
|
67
|
+
* for a key or a limit the line could not hold.
|
|
68
|
+
*/
|
|
69
|
+
export declare function slotLimits(value: unknown, owner: string): SlotLimit[];
|
|
70
|
+
/** What `MemorySlots` needs from the memory driver, all synchronous. */
|
|
71
|
+
export type MemorySlotHost = {
|
|
72
|
+
/** Whether the job is still waiting or claimed. */
|
|
73
|
+
jobAlive(id: string): boolean;
|
|
74
|
+
/** Whether the workflow exists and is neither ended nor paused. */
|
|
75
|
+
workflowAlive(id: string): boolean;
|
|
76
|
+
/** Puts a current claim back to waiting, due after `ms`, its attempt taken back. */
|
|
77
|
+
park(job: ClaimedJob, ms: number): void;
|
|
78
|
+
/** Makes a waiting job due now; `false` when there is no such job. */
|
|
79
|
+
wake(id: string): boolean;
|
|
80
|
+
/** Enqueues a tick for the workflow, and returns its job id. */
|
|
81
|
+
tick(workflowId: string): string;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* The lines in this process's memory, for the memory driver: the same
|
|
85
|
+
* order, parking and waking as the database driver's, and like everything
|
|
86
|
+
* on that driver, per process.
|
|
87
|
+
*/
|
|
88
|
+
export declare class MemorySlots {
|
|
89
|
+
private readonly host;
|
|
90
|
+
private lines;
|
|
91
|
+
private keysOf;
|
|
92
|
+
private order;
|
|
93
|
+
constructor(host: MemorySlotHost);
|
|
94
|
+
/** Holders and waiters of `key`, for tests. */
|
|
95
|
+
line(key: string): {
|
|
96
|
+
holding: string[];
|
|
97
|
+
waiting: string[];
|
|
98
|
+
};
|
|
99
|
+
acquire(request: SlotRequest): boolean;
|
|
100
|
+
release(holder: string): void;
|
|
101
|
+
private sorted;
|
|
102
|
+
private holders;
|
|
103
|
+
private ahead;
|
|
104
|
+
private alive;
|
|
105
|
+
/** Drops holders whose job or workflow is gone. */
|
|
106
|
+
private prune;
|
|
107
|
+
/** Makes the first waiters due, as many as the line has free slots, dropping dead ones. */
|
|
108
|
+
private wake;
|
|
109
|
+
private forget;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=slots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slots.d.ts","sourceRoot":"","sources":["../../../services/queue/slots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,2DAA2D;AAC3D,MAAM,MAAM,SAAS,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvD,MAAM,MAAM,WAAW,GAAG;IACxB,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,mGAAmG;IACnG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kGAAkG;IAClG,GAAG,EAAE,UAAU,CAAC;IAChB,uCAAuC;IACvC,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,2EAA2E;IAC3E,SAAS,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1C,CAAC;AAEF,oDAAoD;AACpD,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,6EAA6E;AAC7E,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,CA2BrE;AAED,wEAAwE;AACxE,MAAM,MAAM,cAAc,GAAG;IAC3B,mDAAmD;IACnD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9B,mEAAmE;IACnE,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IACnC,oFAAoF;IACpF,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,sEAAsE;IACtE,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,gEAAgE;IAChE,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;CAClC,CAAC;AAYF;;;;GAIG;AACH,qBAAa,WAAW;IAKV,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJjC,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,KAAK,CAAK;gBAEW,IAAI,EAAE,cAAc;IAEjD,+CAA+C;IAC/C,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE;IAS3D,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO;IAmDtC,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAc7B,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,OAAO;IAMf,OAAO,CAAC,KAAK;IAcb,OAAO,CAAC,KAAK;IAMb,mDAAmD;IACnD,OAAO,CAAC,KAAK;IAMb,2FAA2F;IAC3F,OAAO,CAAC,IAAI;IAqBZ,OAAO,CAAC,MAAM;CAMf"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ke as J,Ne as A}from"../../chunk-
|
|
2
|
+
import{Ke as J,Ne as A}from"../../chunk-p1ern8r4.js";import{Mk as V}from"../../chunk-wy82t7mz.js";import"../../chunk-tac25cnj.js";import"../../chunk-0k2r6bep.js";import"../../chunk-0av1gyns.js";import"../../chunk-zmt5kdpb.js";import"../../chunk-37209psn.js";import"../../chunk-fqhkkpq3.js";import{Am as _,Em as I,vm as Y,ym as N,zm as Z}from"../../chunk-6r7956dh.js";import{Im as x}from"../../chunk-5mrtgr7q.js";import"../../chunk-3dkv4989.js";import $ from"path";function X(z){if(!z.config.get("route.channels"))return null;let C=z.config.get("broadcast",{}).driver;if(!(C===void 0||C==="memory"||C instanceof V))return null;return'[gemi] Broadcasts from this worker reach no one: the broadcast driver is "memory", which delivers to the sockets of the process that emits, and a worker has none. Set `driver: "redis"` in app/config/broadcast.ts.'}class L extends Error{name="QueueWorkerRefused"}class O{kernel;stopping;keepAlive;settings;constructor(z,C={}){this.kernel=z;this.settings={..._(),...C}}async start(){if(await this.kernel.waitForBoot(),this.stopping)return;let z=this.kernel.app;if(!z.bound(J))throw new L("[gemi] `gemi queue:work` has no queue to claim from: this application does not register QueueServiceProvider.");let C=z.make(J);if(!C.durable)throw new L('[gemi] `gemi queue:work` refuses to start: the queue uses the memory driver, which keeps each job in the process that dispatched it, so a worker never sees one. Set `driver: "database"` (or another driver every process can reach) in app/config/queue.ts, or run jobs in the server and drop the worker.');C.start(),this.keepAlive=setInterval(()=>{},1073741824),console.log(`[gemi] Queue worker started: claiming up to ${C.config.concurrency} job(s) at a time.`);let E=X(z);if(E)console.warn(E)}stop(z={}){return this.stopping??=this.drain({...this.settings,...z}),this.stopping}async drain(z){let C=Date.now()+z.timeoutMs;Y();let E=this.kernel.app,F=E.resolved(J)?E.make(J):void 0;if(F)console.log(`[gemi] Shutting down: waiting for ${F.running} running job(s) (up to ${z.timeoutMs/1000}s).`),await F.drain(z.timeoutMs);let G=N()===0;if(!G){let U=C-Date.now();if(G=U>0&&await Promise.race([Z().then(()=>!0),new Promise((K)=>setTimeout(()=>K(!1),U))]),!G)console.error(`[gemi] Shutdown grace period elapsed with ${N()} held background task(s) still running; abandoning them.`)}let H=await this.kernel.shutdown({timeoutMs:z.providerTimeoutMs});clearInterval(this.keepAlive);let T=G&&(F?.running??0)===0&&H.failed.length===0&&H.timedOut.length===0;return console.log(`[gemi] Shutdown ${T?"complete":"finished with errors"}.`),T?0:1}}async function j(){let z=x();process.env.ROOT_DIR=z,process.env.APP_DIR=$.join(z,"app"),A();let C=$.join(z,"app/kernel/Kernel.ts"),{default:E}=await import(C);if(typeof E!=="function")return console.error(`[gemi] ${C} has no default export to boot the worker from.`),1;let F=new E;F.boot();let G=new O(F);I(()=>G.stop());try{await G.start()}catch(H){if(!(H instanceof L))throw H;return console.error(H.message),1}return}j().then((z)=>{if(z!==void 0)process.exit(z)},(z)=>{console.error("[gemi] The queue worker failed to start:",z),process.exit(1)});
|
|
3
3
|
|
|
4
4
|
//# debugId=07AAF52CEDF447F964756E2164756E21
|
|
@@ -30,6 +30,8 @@ export declare class MemoryWorkflowStore implements WorkflowStore {
|
|
|
30
30
|
}): Promise<WorkflowState | null>;
|
|
31
31
|
acquire(id: string, owner: string, leaseMs: number): Promise<AcquireResult>;
|
|
32
32
|
renew(id: string, owner: string, leaseMs: number): Promise<boolean>;
|
|
33
|
+
/** The workflow's status, synchronously, for the memory driver's slots. */
|
|
34
|
+
statusOf(id: string): WorkflowRecord["status"] | undefined;
|
|
33
35
|
update<T>(id: string, options: UpdateOptions, decide: (snapshot: {
|
|
34
36
|
workflow: WorkflowRecord;
|
|
35
37
|
step: StepRecord | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryWorkflowStore.d.ts","sourceRoot":"","sources":["../../../../services/queue/workflow/MemoryWorkflowStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,aAAa,EAElB,KAAK,cAAc,EAGnB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB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AAM,CAAA;KAAE,GACpE,OAAO,CAAC,UAAU,EAAE,CAAC;IAIxB,OAAO,CAAC,OAAO;IAsBf,OAAO,CAAC,MAAM;IAQd,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,IAAI;CAOb"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { JobConcurrencyResult } from "../Job";
|
|
1
2
|
import type { EachProblem, Step } from "./Step";
|
|
2
3
|
import type { ChangeFeedResponse, StreamOptions } from "../../change-feed/stream";
|
|
3
4
|
import type { WorkflowUpdate } from "./wire";
|
|
@@ -62,6 +63,21 @@ export declare class Workflow {
|
|
|
62
63
|
* `result`. A throw that escapes it fails the workflow.
|
|
63
64
|
*/
|
|
64
65
|
run(_step: Step, ..._args: any[]): unknown;
|
|
66
|
+
/**
|
|
67
|
+
* At most `limit` workflows with this `key` in flight at once, across every
|
|
68
|
+
* process sharing the queue's storage (#1319). Called with the `run`
|
|
69
|
+
* arguments after `step`, before a pass that does not hold its slots yet,
|
|
70
|
+
* so it may be `async` and read the limit from config or the database.
|
|
71
|
+
* Return a list for several limits, narrowest first, as for a job.
|
|
72
|
+
*
|
|
73
|
+
* The slot is held for the whole workflow, not per step: taken before its
|
|
74
|
+
* first step and kept through every pass, sleep, wait and batch, until it
|
|
75
|
+
* completes, fails, is cancelled or is paused. A workflow without a free
|
|
76
|
+
* slot waits its turn, first come first served, holding no queue slot.
|
|
77
|
+
* `onCancel` runs without one. A paused workflow gives its slot up and
|
|
78
|
+
* joins the back of the line when resumed.
|
|
79
|
+
*/
|
|
80
|
+
concurrency(..._args: any[]): JobConcurrencyResult | Promise<JobConcurrencyResult>;
|
|
65
81
|
/**
|
|
66
82
|
* Runs once after `Workflow.cancel`, in place of `run`, with the same
|
|
67
83
|
* arguments: the place to undo what the steps did. Its steps are memoized
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Workflow.d.ts","sourceRoot":"","sources":["../../../../services/queue/workflow/Workflow.ts"],"names":[],"mappings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AAC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI3C;;;;;;;OAOG;IACH,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI1C,yFAAyF;IACzF,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAG5C;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,UAAU,QAAQ,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -95,6 +95,16 @@ export declare class WorkflowRuntime {
|
|
|
95
95
|
tick(id: string, job: Job): Promise<void>;
|
|
96
96
|
/** The tick's last write: the pass's outcome, and letting go. */
|
|
97
97
|
private finish;
|
|
98
|
+
/** What the workflow's `concurrency` returns, checked. */
|
|
99
|
+
private limitsOf;
|
|
100
|
+
/** Hands the workflow's slots on. A failure is logged: the line drops them itself later. */
|
|
101
|
+
private releaseSlots;
|
|
102
|
+
/**
|
|
103
|
+
* `releaseSlots` for a workflow whose `concurrency` is not at hand: when
|
|
104
|
+
* its class declares any, so a queue that uses none never touches the
|
|
105
|
+
* slots table.
|
|
106
|
+
*/
|
|
107
|
+
private releaseSlotsOf;
|
|
98
108
|
/**
|
|
99
109
|
* A tick for a workflow this process has no class for. During a
|
|
100
110
|
* blue/green ramp that is usually one only the other release has, so on a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkflowRuntime.d.ts","sourceRoot":"","sources":["../../../../services/queue/workflow/WorkflowRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAA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