@mastra/cloudflare 1.7.2 → 1.7.3-alpha.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/do/index.cjs +1 -1
- package/dist/do/index.js +1 -1
- package/dist/do/storage/db/index.d.ts +4 -1
- package/dist/do/storage/db/index.d.ts.map +1 -1
- package/dist/do/storage/db/run-fencing.d.ts +35 -0
- package/dist/do/storage/db/run-fencing.d.ts.map +1 -0
- package/dist/do/storage/domains/memory/index.d.ts +15 -5
- package/dist/do/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/do/storage/domains/workflows/index.d.ts +12 -3
- package/dist/do/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/do/storage/sql-builder.d.ts +7 -1
- package/dist/do/storage/sql-builder.d.ts.map +1 -1
- package/dist/{do-BW5eeWN7.js → do-BJ_DMVV0.js} +372 -74
- package/dist/do-BJ_DMVV0.js.map +1 -0
- package/dist/{do-zOdIsGy9.cjs → do-Uemcag89.cjs} +371 -73
- package/dist/do-Uemcag89.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -3
- package/dist/do-BW5eeWN7.js.map +0 -1
- package/dist/do-zOdIsGy9.cjs.map +0 -1
package/dist/do/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_do = require("../do-
|
|
2
|
+
const require_do = require("../do-Uemcag89.cjs");
|
|
3
3
|
exports.BackgroundTasksStorageDO = require_do.BackgroundTasksStorageDO;
|
|
4
4
|
exports.CloudflareDOStorage = require_do.CloudflareDOStorage;
|
|
5
5
|
exports.DODB = require_do.DODB;
|
package/dist/do/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as MemoryStorageDO, i as ScoresStorageDO, n as DOStore, o as BackgroundTasksStorageDO, r as WorkflowsStorageDO, s as DODB, t as CloudflareDOStorage } from "../do-
|
|
1
|
+
import { a as MemoryStorageDO, i as ScoresStorageDO, n as DOStore, o as BackgroundTasksStorageDO, r as WorkflowsStorageDO, s as DODB, t as CloudflareDOStorage } from "../do-BJ_DMVV0.js";
|
|
2
2
|
export { BackgroundTasksStorageDO, CloudflareDOStorage, DODB, DOStore, MemoryStorageDO, ScoresStorageDO, WorkflowsStorageDO };
|
|
@@ -2,6 +2,7 @@ import type { SqlStorage } from '@cloudflare/workers-types';
|
|
|
2
2
|
import { MastraBase } from '@mastra/core/base';
|
|
3
3
|
import type { TABLE_NAMES, StorageColumn } from '@mastra/core/storage';
|
|
4
4
|
import type { SqlQueryOptions } from '../sql-builder.js';
|
|
5
|
+
import type { RunFenceCheck } from './run-fencing.js';
|
|
5
6
|
export interface DODBConfig {
|
|
6
7
|
sql: SqlStorage;
|
|
7
8
|
tablePrefix?: string;
|
|
@@ -66,11 +67,13 @@ export declare class DODB extends MastraBase {
|
|
|
66
67
|
* @param tableName The table to insert into
|
|
67
68
|
* @param records The records to insert
|
|
68
69
|
* @param conflictKeys The columns to use for conflict detection (defaults to ['id'])
|
|
70
|
+
* @param check Run fence every upsert must hold; a refused upsert throws and stops the batch
|
|
69
71
|
*/
|
|
70
|
-
batchUpsert({ tableName, records, conflictKeys, }: {
|
|
72
|
+
batchUpsert({ tableName, records, conflictKeys, check, }: {
|
|
71
73
|
tableName: TABLE_NAMES;
|
|
72
74
|
records: Record<string, unknown>[];
|
|
73
75
|
conflictKeys?: string[];
|
|
76
|
+
check?: RunFenceCheck;
|
|
74
77
|
}): Promise<void>;
|
|
75
78
|
}
|
|
76
79
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/do/storage/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,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AI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC7B,OAAO,CAAC,EAAE;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,KAAK,GAAG,MAAM,CAAA;SAAE,CAAC;KACzD,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAgDpB;IAEK,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAMrF;IAED;;;;;;OAMG;IACG,WAAW,CAAC,EAChB,SAAS,EACT,OAAO,EACP,YAAqB,EACrB,KAAK,GACN,EAAE;QACD,SAAS,EAAE,WAAW,CAAC;QACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;QACnC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QACxB,KAAK,CAAC,EAAE,aAAa,CAAC;KACvB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0EhB;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { RunFence } from '@mastra/core/storage';
|
|
2
|
+
import type { SqlCondition, SqlQueryOptions } from '../sql-builder.js';
|
|
3
|
+
import type { DODB } from './index.js';
|
|
4
|
+
/** A write's fence, and the table holding the run's current claim to check it against. */
|
|
5
|
+
export interface RunFenceCheck {
|
|
6
|
+
claimsTable: string;
|
|
7
|
+
fence: RunFence;
|
|
8
|
+
operation: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Epoch milliseconds on the database clock. `julianday('now')` rather than
|
|
12
|
+
* `unixepoch('subsec')`, which needs SQLite 3.42.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DB_NOW_MS = "CAST(ROUND((julianday('now') - 2440587.5) * 86400000) AS INTEGER)";
|
|
15
|
+
/**
|
|
16
|
+
* The condition a fenced statement writes under: the check's fence is the
|
|
17
|
+
* run's current claim. A Durable Object serves other requests whenever it
|
|
18
|
+
* awaits I/O, so a fenced write can't check the claim first and write later; each of its statements carries this condition instead, and
|
|
19
|
+
* SQLite evaluates it atomically with the write.
|
|
20
|
+
*/
|
|
21
|
+
export declare function runFenceGuard(check: RunFenceCheck | undefined): SqlCondition | undefined;
|
|
22
|
+
/** Throws `RunFenceConflictError` unless the check's fence is the run's current claim. */
|
|
23
|
+
export declare function assertRunFence(db: DODB, { claimsTable, fence, operation }: RunFenceCheck): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Runs one statement of a fenced write. With a check, `statement` must carry
|
|
26
|
+
* `runFenceGuard(check)`. A guarded statement that changes no row either
|
|
27
|
+
* found no target or was refused by its guard; re-reading the claim tells
|
|
28
|
+
* which, and a refusal throws `RunFenceConflictError`.
|
|
29
|
+
*
|
|
30
|
+
* A write made of several statements stops at the first refused one, so a
|
|
31
|
+
* takeover that lands between them leaves the earlier statements applied.
|
|
32
|
+
* None of the refused writer's statements land after the takeover.
|
|
33
|
+
*/
|
|
34
|
+
export declare function executeFenced(db: DODB, check: RunFenceCheck | undefined, { sql, params }: SqlQueryOptions): Promise<void>;
|
|
35
|
+
//# sourceMappingURL=run-fencing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-fencing.d.ts","sourceRoot":"","sources":["../../../../src/do/storage/db/run-fencing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,0FAA0F;AAC1F,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,QAAQ,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,sEAAsE,CAAC;AAE7F;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAOxF;AAED,0FAA0F;AAC1F,wBAAsB,cAAc,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAU9G;AAED;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CACjC,EAAE,EAAE,IAAI,EACR,KAAK,EAAE,aAAa,GAAG,SAAS,EAChC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,eAAe,GAC/B,OAAO,CAAC,IAAI,CAAC,CASf"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
2
2
|
import type { MastraDBMessage, StorageThreadType } from '@mastra/core/memory';
|
|
3
3
|
import { MemoryStorage } from '@mastra/core/storage';
|
|
4
|
-
import type { StorageResourceType, StorageListMessagesInput, StorageListMessagesOutput, StorageListThreadsInput, StorageListThreadsOutput } from '@mastra/core/storage';
|
|
4
|
+
import type { RunFence, StorageResourceType, StorageListMessagesInput, StorageListMessagesOutput, StorageListThreadsInput, StorageListThreadsOutput } from '@mastra/core/storage';
|
|
5
5
|
import type { DODomainConfig } from '../../db/index.js';
|
|
6
6
|
export declare class MemoryStorageDO extends MemoryStorage {
|
|
7
7
|
#private;
|
|
@@ -9,35 +9,42 @@ export declare class MemoryStorageDO extends MemoryStorage {
|
|
|
9
9
|
constructor(config: DODomainConfig);
|
|
10
10
|
init(): Promise<void>;
|
|
11
11
|
dangerouslyClearAll(): Promise<void>;
|
|
12
|
+
supportsRunFencing(): boolean;
|
|
13
|
+
raiseRunFence(fence: RunFence): Promise<boolean>;
|
|
14
|
+
retireRunFence(fence: RunFence): Promise<boolean>;
|
|
12
15
|
getResourceById({ resourceId }: {
|
|
13
16
|
resourceId: string;
|
|
14
17
|
}): Promise<StorageResourceType | null>;
|
|
15
18
|
saveResource({ resource }: {
|
|
16
19
|
resource: StorageResourceType;
|
|
17
20
|
}): Promise<StorageResourceType>;
|
|
18
|
-
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
21
|
+
updateResource({ resourceId, workingMemory, metadata, fence, }: {
|
|
19
22
|
resourceId: string;
|
|
20
23
|
workingMemory?: string;
|
|
21
24
|
metadata?: Record<string, unknown>;
|
|
25
|
+
fence?: RunFence;
|
|
22
26
|
}): Promise<StorageResourceType>;
|
|
23
27
|
getThreadById({ threadId, resourceId, }: {
|
|
24
28
|
threadId: string;
|
|
25
29
|
resourceId?: string;
|
|
26
30
|
}): Promise<StorageThreadType | null>;
|
|
27
31
|
listThreads(args: StorageListThreadsInput): Promise<StorageListThreadsOutput>;
|
|
28
|
-
saveThread({ thread }: {
|
|
32
|
+
saveThread({ thread, fence }: {
|
|
29
33
|
thread: StorageThreadType;
|
|
34
|
+
fence?: RunFence;
|
|
30
35
|
}): Promise<StorageThreadType>;
|
|
31
|
-
updateThread({ id, title, metadata, }: {
|
|
36
|
+
updateThread({ id, title, metadata, fence, }: {
|
|
32
37
|
id: string;
|
|
33
38
|
title?: string;
|
|
34
39
|
metadata?: Record<string, unknown>;
|
|
40
|
+
fence?: RunFence;
|
|
35
41
|
}): Promise<StorageThreadType>;
|
|
36
42
|
deleteThread({ threadId }: {
|
|
37
43
|
threadId: string;
|
|
38
44
|
}): Promise<void>;
|
|
39
45
|
saveMessages(args: {
|
|
40
46
|
messages: MastraDBMessage[];
|
|
47
|
+
fence?: RunFence;
|
|
41
48
|
}): Promise<{
|
|
42
49
|
messages: MastraDBMessage[];
|
|
43
50
|
}>;
|
|
@@ -63,7 +70,10 @@ export declare class MemoryStorageDO extends MemoryStorage {
|
|
|
63
70
|
content?: MastraMessageContentV2['content'];
|
|
64
71
|
};
|
|
65
72
|
})[];
|
|
73
|
+
fence?: RunFence;
|
|
66
74
|
}): Promise<MastraDBMessage[]>;
|
|
67
|
-
deleteMessages(messageIds: string[]
|
|
75
|
+
deleteMessages(messageIds: string[], options?: {
|
|
76
|
+
fence?: RunFence;
|
|
77
|
+
}): Promise<void>;
|
|
68
78
|
}
|
|
69
79
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/do/storage/domains/memory/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAmB,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/do/storage/domains/memory/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAmB,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAIL,aAAa,EAYd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,QAAQ,EACR,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EAGzB,uBAAuB,EACvB,wBAAwB,EAEzB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAuD/C,qBAAa,eAAgB,SAAQ,aAAa;;IAChD,SAAkB,2BAA2B,QAAQ;IAGrD,YAAY,MAAM,EAAE,cAAc,EAGjC;IAEK,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAc1B;IAEK,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAKzC;IAEQ,kBAAkB,IAAI,OAAO,CAErC;IAMc,aAAa,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CA0B9D;IAEc,cAAc,CAAC,KAAK,EAAE,QA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 +1,4 @@
|
|
|
1
|
-
import type { WorkflowRun, WorkflowRuns, StorageListWorkflowRunsInput, UpdateWorkflowStateOptions } from '@mastra/core/storage';
|
|
1
|
+
import type { ClaimRunOwnershipInput, ClaimRunOwnershipResult, RenewRunOwnershipInput, RenewRunOwnershipResult, RunFence, RunOwnershipRecord, WorkflowRun, WorkflowRuns, StorageListWorkflowRunsInput, UpdateWorkflowStateOptions } from '@mastra/core/storage';
|
|
2
2
|
import { WorkflowsStorage } from '@mastra/core/storage';
|
|
3
3
|
import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
|
|
4
4
|
import type { DODomainConfig } from '../../db/index.js';
|
|
@@ -8,6 +8,13 @@ export declare class WorkflowsStorageDO extends WorkflowsStorage {
|
|
|
8
8
|
supportsConcurrentUpdates(): boolean;
|
|
9
9
|
init(): Promise<void>;
|
|
10
10
|
dangerouslyClearAll(): Promise<void>;
|
|
11
|
+
supportsRunFencing(): boolean;
|
|
12
|
+
claimRunOwnership({ runId, ownerId, leaseMs, force, expectedGeneration, }: ClaimRunOwnershipInput): Promise<ClaimRunOwnershipResult>;
|
|
13
|
+
renewRunOwnership({ leaseMs, ...fence }: RenewRunOwnershipInput): Promise<RenewRunOwnershipResult>;
|
|
14
|
+
releaseRunOwnership(fence: RunFence): Promise<boolean>;
|
|
15
|
+
getRunOwnership({ runId }: {
|
|
16
|
+
runId: string;
|
|
17
|
+
}): Promise<RunOwnershipRecord | null>;
|
|
11
18
|
updateWorkflowResults({}: {
|
|
12
19
|
workflowName: string;
|
|
13
20
|
runId: string;
|
|
@@ -20,13 +27,14 @@ export declare class WorkflowsStorageDO extends WorkflowsStorage {
|
|
|
20
27
|
runId: string;
|
|
21
28
|
opts: UpdateWorkflowStateOptions;
|
|
22
29
|
}): Promise<WorkflowRunState | undefined>;
|
|
23
|
-
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, createdAt, updatedAt, }: {
|
|
30
|
+
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, createdAt, updatedAt, fence, }: {
|
|
24
31
|
workflowName: string;
|
|
25
32
|
runId: string;
|
|
26
33
|
resourceId?: string;
|
|
27
34
|
snapshot: WorkflowRunState;
|
|
28
35
|
createdAt?: Date;
|
|
29
36
|
updatedAt?: Date;
|
|
37
|
+
fence?: RunFence;
|
|
30
38
|
}): Promise<void>;
|
|
31
39
|
loadWorkflowSnapshot(params: {
|
|
32
40
|
workflowName: string;
|
|
@@ -38,9 +46,10 @@ export declare class WorkflowsStorageDO extends WorkflowsStorage {
|
|
|
38
46
|
runId: string;
|
|
39
47
|
workflowName?: string;
|
|
40
48
|
}): Promise<WorkflowRun | null>;
|
|
41
|
-
deleteWorkflowRunById({ runId, workflowName }: {
|
|
49
|
+
deleteWorkflowRunById({ runId, workflowName, fence, }: {
|
|
42
50
|
runId: string;
|
|
43
51
|
workflowName: string;
|
|
52
|
+
fence?: RunFence;
|
|
44
53
|
}): Promise<void>;
|
|
45
54
|
}
|
|
46
55
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/do/storage/domains/workflows/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,4BAA4B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/do/storage/domains/workflows/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,QAAQ,EACR,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,4BAA4B,EAE5B,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EASL,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG3E,OAAO,KAAK,EAAE,cAAc,EAA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query parameters
|
|
3
3
|
*/
|
|
4
4
|
export type SqlParam = string | number | boolean | null | undefined;
|
|
5
|
+
/** A SQL boolean expression and the parameters it binds. */
|
|
6
|
+
export interface SqlCondition {
|
|
7
|
+
sql: string;
|
|
8
|
+
params: SqlParam[];
|
|
9
|
+
}
|
|
5
10
|
/**
|
|
6
11
|
* Interface for SQL query options with generic type support
|
|
7
12
|
*/
|
|
@@ -48,8 +53,9 @@ export declare class SqlBuilder {
|
|
|
48
53
|
* @param values Values to insert
|
|
49
54
|
* @param conflictColumns Columns to check for conflict (usually PK or UNIQUE)
|
|
50
55
|
* @param updateMap Object mapping columns to update to their new value (e.g. { name: 'excluded.name' })
|
|
56
|
+
* @param guard Condition the statement writes under: when it is false, neither the insert nor the conflict update happens
|
|
51
57
|
*/
|
|
52
|
-
insert(table: string, columns: string[], values: SqlParam[], conflictColumns?: string[], updateMap?: Record<string, string
|
|
58
|
+
insert(table: string, columns: string[], values: SqlParam[], conflictColumns?: string[], updateMap?: Record<string, string>, guard?: SqlCondition): SqlBuilder;
|
|
53
59
|
update(table: string, columns: string[], values: SqlParam[]): SqlBuilder;
|
|
54
60
|
delete(table: string): SqlBuilder;
|
|
55
61
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql-builder.d.ts","sourceRoot":"","sources":["../../../src/do/storage/sql-builder.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,2BAA2B;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,sCAAsC;IACtC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;IACpB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,GAAG,CAAc;IACzB,OAA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