@mastra/cloudflare 1.0.0-beta.1 → 1.0.0-beta.10
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/CHANGELOG.md +415 -0
- package/dist/docs/README.md +31 -0
- package/dist/docs/SKILL.md +32 -0
- package/dist/docs/SOURCE_MAP.json +6 -0
- package/dist/docs/storage/01-reference.md +62 -0
- package/dist/index.cjs +1431 -1464
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1446 -1482
- package/dist/index.js.map +1 -1
- package/dist/storage/{domains/operations → db}/index.d.ts +22 -25
- package/dist/storage/db/index.d.ts.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +42 -5
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +12 -24
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +13 -13
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +25 -159
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/types.d.ts +63 -6
- package/dist/storage/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/storage/domains/operations/index.d.ts.map +0 -1
|
@@ -1,31 +1,25 @@
|
|
|
1
1
|
import type { KVNamespace } from '@cloudflare/workers-types';
|
|
2
|
-
import {
|
|
2
|
+
import { MastraBase } from '@mastra/core/base';
|
|
3
3
|
import type { StorageColumn, TABLE_NAMES } from '@mastra/core/storage';
|
|
4
|
-
import
|
|
5
|
-
import type { ListOptions, RecordTypes } from '
|
|
6
|
-
export
|
|
4
|
+
import Cloudflare from 'cloudflare';
|
|
5
|
+
import type { CloudflareDomainConfig, ListOptions, RecordTypes } from '../types.js';
|
|
6
|
+
export interface CloudflareKVDBConfig {
|
|
7
|
+
bindings?: Record<TABLE_NAMES, KVNamespace>;
|
|
8
|
+
namespacePrefix?: string;
|
|
9
|
+
client?: Cloudflare;
|
|
10
|
+
accountId?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Resolves CloudflareDomainConfig to CloudflareKVDBConfig.
|
|
14
|
+
* Handles creating a new Cloudflare client if apiToken is provided.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveCloudflareConfig(config: CloudflareDomainConfig): CloudflareKVDBConfig;
|
|
17
|
+
export declare class CloudflareKVDB extends MastraBase {
|
|
7
18
|
private bindings?;
|
|
8
19
|
client?: Cloudflare;
|
|
9
20
|
accountId?: string;
|
|
10
21
|
namespacePrefix: string;
|
|
11
|
-
constructor(
|
|
12
|
-
bindings?: Record<TABLE_NAMES, KVNamespace>;
|
|
13
|
-
namespacePrefix: string;
|
|
14
|
-
client?: Cloudflare;
|
|
15
|
-
accountId?: string;
|
|
16
|
-
});
|
|
17
|
-
hasColumn(): Promise<boolean>;
|
|
18
|
-
alterTable(_args: {
|
|
19
|
-
tableName: TABLE_NAMES;
|
|
20
|
-
schema: Record<string, StorageColumn>;
|
|
21
|
-
ifNotExists: string[];
|
|
22
|
-
}): Promise<void>;
|
|
23
|
-
clearTable({ tableName }: {
|
|
24
|
-
tableName: TABLE_NAMES;
|
|
25
|
-
}): Promise<void>;
|
|
26
|
-
dropTable({ tableName }: {
|
|
27
|
-
tableName: TABLE_NAMES;
|
|
28
|
-
}): Promise<void>;
|
|
22
|
+
constructor(config: CloudflareKVDBConfig);
|
|
29
23
|
private getBinding;
|
|
30
24
|
getKey<T extends TABLE_NAMES>(tableName: T, record: Record<string, string>): string;
|
|
31
25
|
private getSchemaKey;
|
|
@@ -57,9 +51,6 @@ export declare class StoreOperationsCloudflare extends StoreOperations {
|
|
|
57
51
|
tableName: T;
|
|
58
52
|
records: Partial<RecordTypes[T]>[];
|
|
59
53
|
}): Promise<void>;
|
|
60
|
-
/**
|
|
61
|
-
* Helper to safely serialize data for KV storage
|
|
62
|
-
*/
|
|
63
54
|
private safeSerialize;
|
|
64
55
|
private putNamespaceValue;
|
|
65
56
|
putKV({ tableName, key, value, metadata, }: {
|
|
@@ -72,6 +63,12 @@ export declare class StoreOperationsCloudflare extends StoreOperations {
|
|
|
72
63
|
tableName: TABLE_NAMES;
|
|
73
64
|
schema: Record<string, StorageColumn>;
|
|
74
65
|
}): Promise<void>;
|
|
66
|
+
clearTable({ tableName }: {
|
|
67
|
+
tableName: TABLE_NAMES;
|
|
68
|
+
}): Promise<void>;
|
|
69
|
+
dropTable({ tableName }: {
|
|
70
|
+
tableName: TABLE_NAMES;
|
|
71
|
+
}): Promise<void>;
|
|
75
72
|
listNamespaceKeys(tableName: TABLE_NAMES, options?: ListOptions): Promise<import("@cloudflare/workers-types").KVNamespaceListKey<unknown, string>[]>;
|
|
76
73
|
private deleteNamespaceValue;
|
|
77
74
|
deleteKV(tableName: TABLE_NAMES, key: string): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAU/C,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEjF,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IAC5C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,sBAAsB,GAAG,oBAAoB,CAwB5F;AAED,qBAAa,cAAe,SAAQ,UAAU;IAC5C,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BpH,OAAO,CAAC,aAAa;YAIP,iBAAiB;IAiCzB,KAAK,CAAC,EACV,SAAS,EACT,GAAG,EACH,KAAK,EACL,QAAQ,GACT,EAAE;QACD,SAAS,EAAE,WAAW,CAAC;QACvB,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,GAAG,CAAC;QACX,QAAQ,CAAC,EAAE,GAAG,CAAC;KAChB,GAAG,OAAO,CAAC,IAAI,CAAC;IASX,WAAW,CAAC,EAChB,SAAS,EACT,MAAM,GACP,EAAE;QACD,SAAS,EAAE,WAAW,CAAC;QACvB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;KACvC,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBX,UAAU,CAAC,EAAE,SAAS,EAAE,EAAE;QAAE,SAAS,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBpE,SAAS,CAAC,EAAE,SAAS,EAAE,EAAE;QAAE,SAAS,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBnE,iBAAiB,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,WAAW;YAiCvD,oBAAoB;IAY5B,QAAQ,CAAC,SAAS,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS5D,MAAM,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAQ9F"}
|
|
@@ -2,12 +2,12 @@ import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
|
2
2
|
import type { MastraDBMessage, StorageThreadType } from '@mastra/core/memory';
|
|
3
3
|
import type { StorageResourceType, StorageListMessagesInput, StorageListMessagesOutput, StorageListThreadsByResourceIdInput, StorageListThreadsByResourceIdOutput } from '@mastra/core/storage';
|
|
4
4
|
import { MemoryStorage } from '@mastra/core/storage';
|
|
5
|
-
import type {
|
|
5
|
+
import type { CloudflareDomainConfig } from '../../types.js';
|
|
6
6
|
export declare class MemoryStorageCloudflare extends MemoryStorage {
|
|
7
|
-
|
|
8
|
-
constructor(
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
#private;
|
|
8
|
+
constructor(config: CloudflareDomainConfig);
|
|
9
|
+
init(): Promise<void>;
|
|
10
|
+
dangerouslyClearAll(): Promise<void>;
|
|
11
11
|
private ensureMetadata;
|
|
12
12
|
/**
|
|
13
13
|
* Summarizes message content without exposing raw data (for logging).
|
|
@@ -31,6 +31,17 @@ export declare class MemoryStorageCloudflare extends MemoryStorage {
|
|
|
31
31
|
deleteThread({ threadId }: {
|
|
32
32
|
threadId: string;
|
|
33
33
|
}): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Searches all threads in the KV store to find a message by its ID.
|
|
36
|
+
*
|
|
37
|
+
* **Performance Warning**: This method sequentially scans all threads to locate
|
|
38
|
+
* the message. For stores with many threads, this can result in significant
|
|
39
|
+
* latency and API calls. When possible, callers should provide the `threadId`
|
|
40
|
+
* directly to avoid this full scan.
|
|
41
|
+
*
|
|
42
|
+
* @param messageId - The globally unique message ID to search for
|
|
43
|
+
* @returns The message with its threadId if found, null otherwise
|
|
44
|
+
*/
|
|
34
45
|
private findMessageInAnyThread;
|
|
35
46
|
/**
|
|
36
47
|
* Queue for serializing sorted order updates.
|
|
@@ -55,9 +66,34 @@ export declare class MemoryStorageCloudflare extends MemoryStorage {
|
|
|
55
66
|
private getRange;
|
|
56
67
|
private getLastN;
|
|
57
68
|
private getFullOrder;
|
|
69
|
+
/**
|
|
70
|
+
* Retrieves messages specified in the include array along with their surrounding context.
|
|
71
|
+
*
|
|
72
|
+
* **Performance Note**: When `threadId` is not provided in an include entry, this method
|
|
73
|
+
* must call `findMessageInAnyThread` which sequentially scans all threads in the KV store.
|
|
74
|
+
* For optimal performance, callers should provide `threadId` in include entries when known.
|
|
75
|
+
*
|
|
76
|
+
* @param include - Array of message IDs to include, optionally with context windows
|
|
77
|
+
* @param messageIds - Set to accumulate the message IDs that should be fetched
|
|
78
|
+
*/
|
|
58
79
|
private getIncludedMessagesWithContext;
|
|
59
80
|
private getRecentMessages;
|
|
81
|
+
/**
|
|
82
|
+
* Fetches and parses messages from one or more threads.
|
|
83
|
+
*
|
|
84
|
+
* **Performance Note**: When neither `include` entries with `threadId` nor `targetThreadId`
|
|
85
|
+
* are provided, this method falls back to `findMessageInAnyThread` which scans all threads.
|
|
86
|
+
* For optimal performance, provide `threadId` in include entries or specify `targetThreadId`.
|
|
87
|
+
*/
|
|
60
88
|
private fetchAndParseMessagesFromMultipleThreads;
|
|
89
|
+
/**
|
|
90
|
+
* Retrieves messages by their IDs.
|
|
91
|
+
*
|
|
92
|
+
* **Performance Warning**: This method calls `findMessageInAnyThread` for each message ID,
|
|
93
|
+
* which scans all threads in the KV store. For large numbers of messages or threads,
|
|
94
|
+
* this can result in significant latency. Consider using `listMessages` with specific
|
|
95
|
+
* thread IDs when the thread context is known.
|
|
96
|
+
*/
|
|
61
97
|
listMessagesById({ messageIds }: {
|
|
62
98
|
messageIds: string[];
|
|
63
99
|
}): Promise<{
|
|
@@ -85,5 +121,6 @@ export declare class MemoryStorageCloudflare extends MemoryStorage {
|
|
|
85
121
|
workingMemory?: string;
|
|
86
122
|
metadata?: Record<string, unknown>;
|
|
87
123
|
}): Promise<StorageResourceType>;
|
|
124
|
+
deleteMessages(messageIds: string[]): Promise<void>;
|
|
88
125
|
}
|
|
89
126
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/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,qBAA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;gBAC9C,OAAO,CAAC,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC;aAC7C,CAAC;SACH,CAAC,EAAE,CAAC;KACN,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IA2JxB,eAAe,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;IA8B5F,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE;QAAE,QAAQ,EAAE,mBAAmB,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA6B3F,cAAc,CAAC,EACnB,UAAU,EACV,aAAa,EACb,QAAQ,GACT,EAAE;QACD,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA6B1B,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CA4D1D"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { ScoreRowData, ScoringSource } from '@mastra/core/evals';
|
|
1
|
+
import type { ListScoresResponse, SaveScorePayload, ScoreRowData, ScoringSource } from '@mastra/core/evals';
|
|
2
2
|
import { ScoresStorage } from '@mastra/core/storage';
|
|
3
|
-
import type { StoragePagination
|
|
4
|
-
import type {
|
|
3
|
+
import type { StoragePagination } from '@mastra/core/storage';
|
|
4
|
+
import type { CloudflareDomainConfig } from '../../types.js';
|
|
5
5
|
export declare class ScoresStorageCloudflare extends ScoresStorage {
|
|
6
|
-
private
|
|
7
|
-
constructor(
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
#private;
|
|
7
|
+
constructor(config: CloudflareDomainConfig);
|
|
8
|
+
init(): Promise<void>;
|
|
9
|
+
dangerouslyClearAll(): Promise<void>;
|
|
10
10
|
getScoreById({ id }: {
|
|
11
11
|
id: string;
|
|
12
12
|
}): Promise<ScoreRowData | null>;
|
|
13
|
-
saveScore(score:
|
|
13
|
+
saveScore(score: SaveScorePayload): Promise<{
|
|
14
14
|
score: ScoreRowData;
|
|
15
15
|
}>;
|
|
16
16
|
listScoresByScorerId({ scorerId, entityId, entityType, source, pagination, }: {
|
|
@@ -19,32 +19,20 @@ export declare class ScoresStorageCloudflare extends ScoresStorage {
|
|
|
19
19
|
entityType?: string;
|
|
20
20
|
source?: ScoringSource;
|
|
21
21
|
pagination: StoragePagination;
|
|
22
|
-
}): Promise<
|
|
23
|
-
pagination: PaginationInfo;
|
|
24
|
-
scores: ScoreRowData[];
|
|
25
|
-
}>;
|
|
22
|
+
}): Promise<ListScoresResponse>;
|
|
26
23
|
listScoresByRunId({ runId, pagination, }: {
|
|
27
24
|
runId: string;
|
|
28
25
|
pagination: StoragePagination;
|
|
29
|
-
}): Promise<
|
|
30
|
-
pagination: PaginationInfo;
|
|
31
|
-
scores: ScoreRowData[];
|
|
32
|
-
}>;
|
|
26
|
+
}): Promise<ListScoresResponse>;
|
|
33
27
|
listScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
34
28
|
pagination: StoragePagination;
|
|
35
29
|
entityId: string;
|
|
36
30
|
entityType: string;
|
|
37
|
-
}): Promise<
|
|
38
|
-
pagination: PaginationInfo;
|
|
39
|
-
scores: ScoreRowData[];
|
|
40
|
-
}>;
|
|
31
|
+
}): Promise<ListScoresResponse>;
|
|
41
32
|
listScoresBySpan({ traceId, spanId, pagination, }: {
|
|
42
33
|
traceId: string;
|
|
43
34
|
spanId: string;
|
|
44
35
|
pagination: StoragePagination;
|
|
45
|
-
}): Promise<
|
|
46
|
-
pagination: PaginationInfo;
|
|
47
|
-
scores: ScoreRowData[];
|
|
48
|
-
}>;
|
|
36
|
+
}): Promise<ListScoresResponse>;
|
|
49
37
|
}
|
|
50
38
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/scores/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/scores/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC5G,OAAO,EAEL,aAAa,EAKd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAU1D,qBAAa,uBAAwB,SAAQ,aAAa;;gBAG5C,MAAM,EAAE,sBAAsB;IAKpC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIpC,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAuBlE,SAAS,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,YAAY,CAAA;KAAE,CAAC;IAmEpE,oBAAoB,CAAC,EACzB,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,MAAM,EACN,UAAU,GACX,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,aAAa,CAAC;QACvB,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA+DzB,iBAAiB,CAAC,EACtB,KAAK,EACL,UAAU,GACX,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAoDzB,oBAAoB,CAAC,EACzB,QAAQ,EACR,UAAU,EACV,UAAU,GACX,EAAE;QACD,UAAU,EAAE,iBAAiB,CAAC;QAC9B,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAoDzB,gBAAgB,CAAC,EACrB,OAAO,EACP,MAAM,EACN,UAAU,GACX,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAmDhC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { WorkflowsStorage } from '@mastra/core/storage';
|
|
2
|
-
import type { WorkflowRun, WorkflowRuns, StorageListWorkflowRunsInput } from '@mastra/core/storage';
|
|
2
|
+
import type { WorkflowRun, WorkflowRuns, StorageListWorkflowRunsInput, UpdateWorkflowStateOptions } from '@mastra/core/storage';
|
|
3
3
|
import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
|
|
4
|
-
import type {
|
|
4
|
+
import type { CloudflareDomainConfig } from '../../types.js';
|
|
5
5
|
export declare class WorkflowsStorageCloudflare extends WorkflowsStorage {
|
|
6
|
-
private
|
|
7
|
-
constructor(
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
#private;
|
|
7
|
+
constructor(config: CloudflareDomainConfig);
|
|
8
|
+
init(): Promise<void>;
|
|
9
|
+
dangerouslyClearAll(): Promise<void>;
|
|
10
10
|
private validateWorkflowParams;
|
|
11
11
|
updateWorkflowResults({}: {
|
|
12
12
|
workflowName: string;
|
|
@@ -18,19 +18,15 @@ export declare class WorkflowsStorageCloudflare extends WorkflowsStorage {
|
|
|
18
18
|
updateWorkflowState({}: {
|
|
19
19
|
workflowName: string;
|
|
20
20
|
runId: string;
|
|
21
|
-
opts:
|
|
22
|
-
status: string;
|
|
23
|
-
result?: StepResult<any, any, any, any>;
|
|
24
|
-
error?: string;
|
|
25
|
-
suspendedPaths?: Record<string, number[]>;
|
|
26
|
-
waitingPaths?: Record<string, number[]>;
|
|
27
|
-
};
|
|
21
|
+
opts: UpdateWorkflowStateOptions;
|
|
28
22
|
}): Promise<WorkflowRunState | undefined>;
|
|
29
23
|
persistWorkflowSnapshot(params: {
|
|
30
24
|
workflowName: string;
|
|
31
25
|
runId: string;
|
|
32
26
|
resourceId?: string;
|
|
33
27
|
snapshot: WorkflowRunState;
|
|
28
|
+
createdAt?: Date;
|
|
29
|
+
updatedAt?: Date;
|
|
34
30
|
}): Promise<void>;
|
|
35
31
|
loadWorkflowSnapshot(params: {
|
|
36
32
|
workflowName: string;
|
|
@@ -43,5 +39,9 @@ export declare class WorkflowsStorageCloudflare extends WorkflowsStorage {
|
|
|
43
39
|
runId: string;
|
|
44
40
|
workflowName: string;
|
|
45
41
|
}): Promise<WorkflowRun | null>;
|
|
42
|
+
deleteWorkflowRunById({ runId, workflowName }: {
|
|
43
|
+
runId: string;
|
|
44
|
+
workflowName: string;
|
|
45
|
+
}): Promise<void>;
|
|
46
46
|
}
|
|
47
47
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/index.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/index.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,gBAAgB,EAEjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,4BAA4B,EAC5B,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB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IAAI,CAAC;IAgC7G,OAAO,CAAC,gBAAgB;IAqBxB,OAAO,CAAC,2BAA2B;IAmB7B,gBAAgB,CAAC,EACrB,YAAY,EACZ,IAAQ,EACR,OAAY,EACZ,UAAU,EACV,QAAQ,EACR,MAAM,EACN,MAAM,GACP,GAAE,4BAAiC,GAAG,OAAO,CAAC,YAAY,CAAC;IAkFtD,kBAAkB,CAAC,EACvB,KAAK,EACL,YAAY,GACb,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,YAAY,EAAE,MAAM,CAAC;KACtB,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IA6CzB,qBAAqB,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAsB7G"}
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
|
-
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
2
|
-
import type { ScoreRowData, ScoringSource } from '@mastra/core/evals';
|
|
3
|
-
import type { StorageThreadType, MastraDBMessage } from '@mastra/core/memory';
|
|
4
1
|
import { MastraStorage } from '@mastra/core/storage';
|
|
5
|
-
import type {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
2
|
+
import type { StorageDomains } from '@mastra/core/storage';
|
|
3
|
+
import { MemoryStorageCloudflare } from './domains/memory/index.js';
|
|
4
|
+
import { ScoresStorageCloudflare } from './domains/scores/index.js';
|
|
5
|
+
import { WorkflowsStorageCloudflare } from './domains/workflows/index.js';
|
|
6
|
+
export { MemoryStorageCloudflare, ScoresStorageCloudflare, WorkflowsStorageCloudflare };
|
|
7
|
+
export type { CloudflareDomainConfig } from './types.js';
|
|
8
|
+
import type { CloudflareStoreConfig } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Cloudflare KV storage adapter for Mastra.
|
|
11
|
+
*
|
|
12
|
+
* Access domain-specific storage via `getStore()`:
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const storage = new CloudflareStore({ id: 'my-store', accountId: '...', apiToken: '...' });
|
|
17
|
+
*
|
|
18
|
+
* // Access memory domain
|
|
19
|
+
* const memory = await storage.getStore('memory');
|
|
20
|
+
* await memory?.saveThread({ thread });
|
|
21
|
+
*
|
|
22
|
+
* // Access workflows domain
|
|
23
|
+
* const workflows = await storage.getStore('workflows');
|
|
24
|
+
* await workflows?.persistWorkflowSnapshot({ workflowName, runId, snapshot });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
8
27
|
export declare class CloudflareStore extends MastraStorage {
|
|
9
28
|
stores: StorageDomains;
|
|
10
29
|
private client?;
|
|
@@ -13,160 +32,7 @@ export declare class CloudflareStore extends MastraStorage {
|
|
|
13
32
|
private bindings?;
|
|
14
33
|
private validateWorkersConfig;
|
|
15
34
|
private validateRestConfig;
|
|
16
|
-
get supports(): {
|
|
17
|
-
selectByIncludeResourceScope: boolean;
|
|
18
|
-
resourceWorkingMemory: boolean;
|
|
19
|
-
hasColumn: boolean;
|
|
20
|
-
createTable: boolean;
|
|
21
|
-
deleteMessages: boolean;
|
|
22
|
-
observabilityInstance?: boolean;
|
|
23
|
-
indexManagement?: boolean;
|
|
24
|
-
listScoresBySpan?: boolean;
|
|
25
|
-
};
|
|
26
35
|
constructor(config: CloudflareStoreConfig);
|
|
27
|
-
createTable({ tableName, schema, }: {
|
|
28
|
-
tableName: TABLE_NAMES;
|
|
29
|
-
schema: Record<string, StorageColumn>;
|
|
30
|
-
}): Promise<void>;
|
|
31
|
-
alterTable(_args: {
|
|
32
|
-
tableName: TABLE_NAMES;
|
|
33
|
-
schema: Record<string, StorageColumn>;
|
|
34
|
-
ifNotExists: string[];
|
|
35
|
-
}): Promise<void>;
|
|
36
|
-
clearTable({ tableName }: {
|
|
37
|
-
tableName: TABLE_NAMES;
|
|
38
|
-
}): Promise<void>;
|
|
39
|
-
dropTable({ tableName }: {
|
|
40
|
-
tableName: TABLE_NAMES;
|
|
41
|
-
}): Promise<void>;
|
|
42
|
-
insert<T extends TABLE_NAMES>({ tableName, record, }: {
|
|
43
|
-
tableName: T;
|
|
44
|
-
record: Record<string, any>;
|
|
45
|
-
}): Promise<void>;
|
|
46
|
-
load<R>({ tableName, keys }: {
|
|
47
|
-
tableName: TABLE_NAMES;
|
|
48
|
-
keys: Record<string, string>;
|
|
49
|
-
}): Promise<R | null>;
|
|
50
|
-
getThreadById({ threadId }: {
|
|
51
|
-
threadId: string;
|
|
52
|
-
}): Promise<StorageThreadType | null>;
|
|
53
|
-
saveThread({ thread }: {
|
|
54
|
-
thread: StorageThreadType;
|
|
55
|
-
}): Promise<StorageThreadType>;
|
|
56
|
-
updateThread({ id, title, metadata, }: {
|
|
57
|
-
id: string;
|
|
58
|
-
title: string;
|
|
59
|
-
metadata: Record<string, unknown>;
|
|
60
|
-
}): Promise<StorageThreadType>;
|
|
61
|
-
deleteThread({ threadId }: {
|
|
62
|
-
threadId: string;
|
|
63
|
-
}): Promise<void>;
|
|
64
|
-
saveMessages(args: {
|
|
65
|
-
messages: MastraDBMessage[];
|
|
66
|
-
}): Promise<{
|
|
67
|
-
messages: MastraDBMessage[];
|
|
68
|
-
}>;
|
|
69
|
-
updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, }: {
|
|
70
|
-
workflowName: string;
|
|
71
|
-
runId: string;
|
|
72
|
-
stepId: string;
|
|
73
|
-
result: StepResult<any, any, any, any>;
|
|
74
|
-
requestContext: Record<string, any>;
|
|
75
|
-
}): Promise<Record<string, StepResult<any, any, any, any>>>;
|
|
76
|
-
updateWorkflowState({ workflowName, runId, opts, }: {
|
|
77
|
-
workflowName: string;
|
|
78
|
-
runId: string;
|
|
79
|
-
opts: {
|
|
80
|
-
status: string;
|
|
81
|
-
result?: StepResult<any, any, any, any>;
|
|
82
|
-
error?: string;
|
|
83
|
-
suspendedPaths?: Record<string, number[]>;
|
|
84
|
-
waitingPaths?: Record<string, number[]>;
|
|
85
|
-
};
|
|
86
|
-
}): Promise<WorkflowRunState | undefined>;
|
|
87
|
-
listMessagesById({ messageIds }: {
|
|
88
|
-
messageIds: string[];
|
|
89
|
-
}): Promise<{
|
|
90
|
-
messages: MastraDBMessage[];
|
|
91
|
-
}>;
|
|
92
|
-
persistWorkflowSnapshot(params: {
|
|
93
|
-
workflowName: string;
|
|
94
|
-
runId: string;
|
|
95
|
-
resourceId?: string;
|
|
96
|
-
snapshot: WorkflowRunState;
|
|
97
|
-
}): Promise<void>;
|
|
98
|
-
loadWorkflowSnapshot(params: {
|
|
99
|
-
workflowName: string;
|
|
100
|
-
runId: string;
|
|
101
|
-
}): Promise<WorkflowRunState | null>;
|
|
102
|
-
batchInsert<T extends TABLE_NAMES>(input: {
|
|
103
|
-
tableName: T;
|
|
104
|
-
records: Partial<RecordTypes[T]>[];
|
|
105
|
-
}): Promise<void>;
|
|
106
|
-
listWorkflowRuns({ workflowName, perPage, page, resourceId, fromDate, toDate, status, }?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
|
|
107
|
-
getWorkflowRunById({ runId, workflowName, }: {
|
|
108
|
-
runId: string;
|
|
109
|
-
workflowName: string;
|
|
110
|
-
}): Promise<WorkflowRun | null>;
|
|
111
|
-
updateMessages(args: {
|
|
112
|
-
messages: (Partial<Omit<MastraDBMessage, 'createdAt'>> & {
|
|
113
|
-
id: string;
|
|
114
|
-
content?: {
|
|
115
|
-
metadata?: MastraMessageContentV2['metadata'];
|
|
116
|
-
content?: MastraMessageContentV2['content'];
|
|
117
|
-
};
|
|
118
|
-
})[];
|
|
119
|
-
}): Promise<MastraDBMessage[]>;
|
|
120
|
-
getScoreById({ id }: {
|
|
121
|
-
id: string;
|
|
122
|
-
}): Promise<ScoreRowData | null>;
|
|
123
|
-
saveScore(score: ScoreRowData): Promise<{
|
|
124
|
-
score: ScoreRowData;
|
|
125
|
-
}>;
|
|
126
|
-
listScoresByRunId({ runId, pagination, }: {
|
|
127
|
-
runId: string;
|
|
128
|
-
pagination: StoragePagination;
|
|
129
|
-
}): Promise<{
|
|
130
|
-
pagination: PaginationInfo;
|
|
131
|
-
scores: ScoreRowData[];
|
|
132
|
-
}>;
|
|
133
|
-
listScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
134
|
-
pagination: StoragePagination;
|
|
135
|
-
entityId: string;
|
|
136
|
-
entityType: string;
|
|
137
|
-
}): Promise<{
|
|
138
|
-
pagination: PaginationInfo;
|
|
139
|
-
scores: ScoreRowData[];
|
|
140
|
-
}>;
|
|
141
|
-
listScoresByScorerId({ scorerId, entityId, entityType, source, pagination, }: {
|
|
142
|
-
scorerId: string;
|
|
143
|
-
entityId?: string;
|
|
144
|
-
entityType?: string;
|
|
145
|
-
source?: ScoringSource;
|
|
146
|
-
pagination: StoragePagination;
|
|
147
|
-
}): Promise<{
|
|
148
|
-
pagination: PaginationInfo;
|
|
149
|
-
scores: ScoreRowData[];
|
|
150
|
-
}>;
|
|
151
|
-
listScoresBySpan({ traceId, spanId, pagination, }: {
|
|
152
|
-
traceId: string;
|
|
153
|
-
spanId: string;
|
|
154
|
-
pagination: StoragePagination;
|
|
155
|
-
}): Promise<{
|
|
156
|
-
pagination: PaginationInfo;
|
|
157
|
-
scores: ScoreRowData[];
|
|
158
|
-
}>;
|
|
159
|
-
getResourceById({ resourceId }: {
|
|
160
|
-
resourceId: string;
|
|
161
|
-
}): Promise<StorageResourceType | null>;
|
|
162
|
-
saveResource({ resource }: {
|
|
163
|
-
resource: StorageResourceType;
|
|
164
|
-
}): Promise<StorageResourceType>;
|
|
165
|
-
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
166
|
-
resourceId: string;
|
|
167
|
-
workingMemory?: string;
|
|
168
|
-
metadata?: Record<string, unknown>;
|
|
169
|
-
}): Promise<StorageResourceType>;
|
|
170
36
|
close(): Promise<void>;
|
|
171
37
|
}
|
|
172
38
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,aAAa,EAKd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAe,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAIjE,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,CAAC;AACxF,YAAY,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,KAAK,EAAE,qBAAqB,EAAiD,MAAM,SAAS,CAAC;AAEpG;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,eAAgB,SAAQ,aAAa;IAChD,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,CAAC,MAAM,CAAC,CAAa;IAC5B,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,CAAmC;IAEpD,OAAO,CAAC,qBAAqB;IAkB7B,OAAO,CAAC,kBAAkB;gBAYd,MAAM,EAAE,qBAAqB;IAyDnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
package/dist/storage/types.d.ts
CHANGED
|
@@ -1,14 +1,40 @@
|
|
|
1
1
|
import type { KVNamespace } from '@cloudflare/workers-types';
|
|
2
2
|
import type { ScoreRowData } from '@mastra/core/evals';
|
|
3
3
|
import type { StorageThreadType, MastraDBMessage } from '@mastra/core/memory';
|
|
4
|
-
import type { TABLE_MESSAGES, TABLE_THREADS, TABLE_WORKFLOW_SNAPSHOT, TABLE_TRACES, TABLE_RESOURCES, TABLE_NAMES, StorageResourceType, TABLE_SCORERS, TABLE_SPANS, SpanRecord } from '@mastra/core/storage';
|
|
4
|
+
import type { TABLE_MESSAGES, TABLE_THREADS, TABLE_WORKFLOW_SNAPSHOT, TABLE_TRACES, TABLE_RESOURCES, TABLE_NAMES, StorageResourceType, TABLE_SCORERS, TABLE_SPANS, TABLE_AGENTS, SpanRecord, StorageAgentType } from '@mastra/core/storage';
|
|
5
5
|
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
6
|
+
import type Cloudflare from 'cloudflare';
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* Base configuration options shared across Cloudflare configurations
|
|
8
9
|
*/
|
|
9
|
-
export interface
|
|
10
|
+
export interface CloudflareBaseConfig {
|
|
10
11
|
/** Storage instance ID */
|
|
11
12
|
id: string;
|
|
13
|
+
/**
|
|
14
|
+
* When true, automatic initialization (table creation/migrations) is disabled.
|
|
15
|
+
* This is useful for CI/CD pipelines where you want to:
|
|
16
|
+
* 1. Run migrations explicitly during deployment (not at runtime)
|
|
17
|
+
* 2. Use different credentials for schema changes vs runtime operations
|
|
18
|
+
*
|
|
19
|
+
* When disableInit is true:
|
|
20
|
+
* - The storage will not automatically create/alter tables on first use
|
|
21
|
+
* - You must call `storage.init()` explicitly in your CI/CD scripts
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // In CI/CD script:
|
|
25
|
+
* const storage = new CloudflareStore({ ...config, disableInit: false });
|
|
26
|
+
* await storage.init(); // Explicitly run migrations
|
|
27
|
+
*
|
|
28
|
+
* // In runtime application:
|
|
29
|
+
* const storage = new CloudflareStore({ ...config, disableInit: true });
|
|
30
|
+
* // No auto-init, tables must already exist
|
|
31
|
+
*/
|
|
32
|
+
disableInit?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Configuration for Cloudflare KV using REST API
|
|
36
|
+
*/
|
|
37
|
+
export interface CloudflareRestConfig extends CloudflareBaseConfig {
|
|
12
38
|
/** Cloudflare account ID */
|
|
13
39
|
accountId: string;
|
|
14
40
|
/** Cloudflare API token with KV access */
|
|
@@ -23,9 +49,7 @@ export interface CloudflareRestConfig {
|
|
|
23
49
|
/**
|
|
24
50
|
* Configuration for Cloudflare KV using Workers Binding API
|
|
25
51
|
*/
|
|
26
|
-
export interface CloudflareWorkersConfig {
|
|
27
|
-
/** Storage instance ID */
|
|
28
|
-
id: string;
|
|
52
|
+
export interface CloudflareWorkersConfig extends CloudflareBaseConfig {
|
|
29
53
|
/** KV namespace bindings from Workers environment */
|
|
30
54
|
bindings: {
|
|
31
55
|
[key in TABLE_NAMES]: KVNamespace;
|
|
@@ -62,9 +86,42 @@ export type RecordTypes = {
|
|
|
62
86
|
[TABLE_TRACES]: any;
|
|
63
87
|
[TABLE_RESOURCES]: StorageResourceType;
|
|
64
88
|
[TABLE_SPANS]: SpanRecord;
|
|
89
|
+
[TABLE_AGENTS]: StorageAgentType;
|
|
65
90
|
};
|
|
66
91
|
export type ListOptions = {
|
|
67
92
|
limit?: number;
|
|
68
93
|
prefix?: string;
|
|
69
94
|
};
|
|
95
|
+
/**
|
|
96
|
+
* Configuration for standalone domain usage.
|
|
97
|
+
* Accepts either:
|
|
98
|
+
* 1. An existing Cloudflare client (REST API) or bindings (Workers API)
|
|
99
|
+
* 2. Config to create a new client internally
|
|
100
|
+
*/
|
|
101
|
+
export type CloudflareDomainConfig = CloudflareDomainClientConfig | CloudflareDomainBindingsConfig | CloudflareDomainRestConfig;
|
|
102
|
+
/**
|
|
103
|
+
* Pass an existing Cloudflare SDK client (REST API)
|
|
104
|
+
*/
|
|
105
|
+
export interface CloudflareDomainClientConfig {
|
|
106
|
+
client: Cloudflare;
|
|
107
|
+
accountId: string;
|
|
108
|
+
namespacePrefix?: string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Pass existing KV bindings (Workers Binding API)
|
|
112
|
+
*/
|
|
113
|
+
export interface CloudflareDomainBindingsConfig {
|
|
114
|
+
bindings: {
|
|
115
|
+
[key in TABLE_NAMES]: KVNamespace;
|
|
116
|
+
};
|
|
117
|
+
keyPrefix?: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Pass config to create a new Cloudflare client internally (REST API)
|
|
121
|
+
*/
|
|
122
|
+
export interface CloudflareDomainRestConfig {
|
|
123
|
+
accountId: string;
|
|
124
|
+
apiToken: string;
|
|
125
|
+
namespacePrefix?: string;
|
|
126
|
+
}
|
|
70
127
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/storage/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,uBAAuB,EACvB,YAAY,EACZ,eAAe,EACf,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,UAAU,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/storage/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,uBAAuB,EACvB,YAAY,EACZ,eAAe,EACf,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,YAAY,EACZ,UAAU,EACV,gBAAgB,EACjB,MAAM,sBAAsB,CA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