@mastra/cloudflare 0.0.0-toolOptionTypes-20250917085558 → 0.0.0-top-level-fix-20251211111608
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 +769 -3
- package/README.md +37 -15
- package/dist/index.cjs +465 -590
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +466 -591
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +54 -36
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/operations/index.d.ts +0 -1
- package/dist/storage/domains/operations/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +13 -5
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +7 -10
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +44 -77
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/test-utils.d.ts.map +1 -1
- package/dist/storage/types.d.ts +35 -8
- package/dist/storage/types.d.ts.map +1 -1
- package/package.json +16 -11
- package/dist/storage/domains/legacy-evals/index.d.ts +0 -21
- package/dist/storage/domains/legacy-evals/index.d.ts.map +0 -1
- package/dist/storage/domains/traces/index.d.ts +0 -18
- package/dist/storage/domains/traces/index.d.ts.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { MastraDBMessage, StorageThreadType } from '@mastra/core/memory';
|
|
3
|
+
import type { StorageResourceType, StorageListMessagesInput, StorageListMessagesOutput, StorageListThreadsByResourceIdInput, StorageListThreadsByResourceIdOutput } from '@mastra/core/storage';
|
|
4
4
|
import { MemoryStorage } from '@mastra/core/storage';
|
|
5
5
|
import type { StoreOperationsCloudflare } from '../operations/index.js';
|
|
6
6
|
export declare class MemoryStorageCloudflare extends MemoryStorage {
|
|
@@ -9,19 +9,15 @@ export declare class MemoryStorageCloudflare extends MemoryStorage {
|
|
|
9
9
|
operations: StoreOperationsCloudflare;
|
|
10
10
|
});
|
|
11
11
|
private ensureMetadata;
|
|
12
|
+
/**
|
|
13
|
+
* Summarizes message content without exposing raw data (for logging).
|
|
14
|
+
* Returns type, length, and keys only to prevent PII leakage.
|
|
15
|
+
*/
|
|
16
|
+
private summarizeMessageContent;
|
|
12
17
|
getThreadById({ threadId }: {
|
|
13
18
|
threadId: string;
|
|
14
19
|
}): Promise<StorageThreadType | null>;
|
|
15
|
-
|
|
16
|
-
resourceId: string;
|
|
17
|
-
}): Promise<StorageThreadType[]>;
|
|
18
|
-
getThreadsByResourceIdPaginated(args: {
|
|
19
|
-
resourceId: string;
|
|
20
|
-
page?: number;
|
|
21
|
-
perPage?: number;
|
|
22
|
-
}): Promise<PaginationInfo & {
|
|
23
|
-
threads: StorageThreadType[];
|
|
24
|
-
}>;
|
|
20
|
+
listThreadsByResourceId(args: StorageListThreadsByResourceIdInput): Promise<StorageListThreadsByResourceIdOutput>;
|
|
25
21
|
saveThread({ thread }: {
|
|
26
22
|
thread: StorageThreadType;
|
|
27
23
|
}): Promise<StorageThreadType>;
|
|
@@ -35,6 +31,17 @@ export declare class MemoryStorageCloudflare extends MemoryStorage {
|
|
|
35
31
|
deleteThread({ threadId }: {
|
|
36
32
|
threadId: string;
|
|
37
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
|
+
*/
|
|
38
45
|
private findMessageInAnyThread;
|
|
39
46
|
/**
|
|
40
47
|
* Queue for serializing sorted order updates.
|
|
@@ -51,39 +58,50 @@ export declare class MemoryStorageCloudflare extends MemoryStorage {
|
|
|
51
58
|
private getSortedMessages;
|
|
52
59
|
private migrateMessage;
|
|
53
60
|
saveMessages(args: {
|
|
54
|
-
messages:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
messages: MastraMessageV2[];
|
|
59
|
-
format: 'v2';
|
|
60
|
-
}): Promise<MastraMessageV2[]>;
|
|
61
|
+
messages: MastraDBMessage[];
|
|
62
|
+
}): Promise<{
|
|
63
|
+
messages: MastraDBMessage[];
|
|
64
|
+
}>;
|
|
61
65
|
private getRank;
|
|
62
66
|
private getRange;
|
|
63
67
|
private getLastN;
|
|
64
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
|
+
*/
|
|
65
79
|
private getIncludedMessagesWithContext;
|
|
66
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
|
+
*/
|
|
67
88
|
private fetchAndParseMessagesFromMultipleThreads;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}): Promise<MastraMessageV1[]>;
|
|
78
|
-
getMessagesById({ messageIds, format, }: {
|
|
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
|
+
*/
|
|
97
|
+
listMessagesById({ messageIds }: {
|
|
79
98
|
messageIds: string[];
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
getMessagesPaginated(args: StorageGetMessagesArg): Promise<PaginationInfo & {
|
|
83
|
-
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
99
|
+
}): Promise<{
|
|
100
|
+
messages: MastraDBMessage[];
|
|
84
101
|
}>;
|
|
102
|
+
listMessages(args: StorageListMessagesInput): Promise<StorageListMessagesOutput>;
|
|
85
103
|
updateMessages(args: {
|
|
86
|
-
messages: (Partial<Omit<
|
|
104
|
+
messages: (Partial<Omit<MastraDBMessage, 'createdAt'>> & {
|
|
87
105
|
id: string;
|
|
88
106
|
threadId?: string;
|
|
89
107
|
content?: {
|
|
@@ -91,7 +109,7 @@ export declare class MemoryStorageCloudflare extends MemoryStorage {
|
|
|
91
109
|
content?: MastraMessageContentV2['content'];
|
|
92
110
|
};
|
|
93
111
|
})[];
|
|
94
|
-
}): Promise<
|
|
112
|
+
}): Promise<MastraDBMessage[]>;
|
|
95
113
|
getResourceById({ resourceId }: {
|
|
96
114
|
resourceId: string;
|
|
97
115
|
}): Promise<StorageResourceType | null>;
|
|
@@ -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,KAA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AAC,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;CA4BjC"}
|
|
@@ -49,7 +49,6 @@ export declare class StoreOperationsCloudflare extends StoreOperations {
|
|
|
49
49
|
tableName: TABLE_NAMES;
|
|
50
50
|
record: Record<string, any>;
|
|
51
51
|
}): Promise<void>;
|
|
52
|
-
private ensureMetadata;
|
|
53
52
|
load<R>({ tableName, keys }: {
|
|
54
53
|
tableName: TABLE_NAMES;
|
|
55
54
|
keys: Record<string, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/operations/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/operations/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,EAEL,eAAe,EAMhB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EA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,OAAO,CAAC,EAAE,WAAW;YAoCvD,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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ScoreRowData, ScoringSource } from '@mastra/core/
|
|
1
|
+
import type { SaveScorePayload, ScoreRowData, ScoringSource } from '@mastra/core/evals';
|
|
2
2
|
import { ScoresStorage } from '@mastra/core/storage';
|
|
3
3
|
import type { StoragePagination, PaginationInfo } from '@mastra/core/storage';
|
|
4
4
|
import type { StoreOperationsCloudflare } from '../operations/index.js';
|
|
@@ -10,10 +10,10 @@ export declare class ScoresStorageCloudflare extends ScoresStorage {
|
|
|
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, }: {
|
|
17
17
|
scorerId: string;
|
|
18
18
|
entityId?: string;
|
|
19
19
|
entityType?: string;
|
|
@@ -23,14 +23,14 @@ export declare class ScoresStorageCloudflare extends ScoresStorage {
|
|
|
23
23
|
pagination: PaginationInfo;
|
|
24
24
|
scores: ScoreRowData[];
|
|
25
25
|
}>;
|
|
26
|
-
|
|
26
|
+
listScoresByRunId({ runId, pagination, }: {
|
|
27
27
|
runId: string;
|
|
28
28
|
pagination: StoragePagination;
|
|
29
29
|
}): Promise<{
|
|
30
30
|
pagination: PaginationInfo;
|
|
31
31
|
scores: ScoreRowData[];
|
|
32
32
|
}>;
|
|
33
|
-
|
|
33
|
+
listScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
34
34
|
pagination: StoragePagination;
|
|
35
35
|
entityId: string;
|
|
36
36
|
entityType: string;
|
|
@@ -38,5 +38,13 @@ export declare class ScoresStorageCloudflare extends ScoresStorage {
|
|
|
38
38
|
pagination: PaginationInfo;
|
|
39
39
|
scores: ScoreRowData[];
|
|
40
40
|
}>;
|
|
41
|
+
listScoresBySpan({ traceId, spanId, pagination, }: {
|
|
42
|
+
traceId: string;
|
|
43
|
+
spanId: string;
|
|
44
|
+
pagination: StoragePagination;
|
|
45
|
+
}): Promise<{
|
|
46
|
+
pagination: PaginationInfo;
|
|
47
|
+
scores: ScoreRowData[];
|
|
48
|
+
}>;
|
|
41
49
|
}
|
|
42
50
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/scores/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/scores/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAA6B,MAAM,oBAAoB,CAAC;AACnH,OAAO,EAEL,aAAa,EAKd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAU/D,qBAAa,uBAAwB,SAAQ,aAAa;IACxD,OAAO,CAAC,UAAU,CAA4B;gBAElC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,yBAAyB,CAAA;KAAE;IAK/D,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,GAAG,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E"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WorkflowsStorage } from '@mastra/core/storage';
|
|
2
|
-
import type { WorkflowRun, WorkflowRuns } from '@mastra/core/storage';
|
|
2
|
+
import type { WorkflowRun, WorkflowRuns, StorageListWorkflowRunsInput } from '@mastra/core/storage';
|
|
3
3
|
import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
|
|
4
4
|
import type { StoreOperationsCloudflare } from '../operations/index.js';
|
|
5
5
|
export declare class WorkflowsStorageCloudflare extends WorkflowsStorage {
|
|
@@ -13,7 +13,7 @@ export declare class WorkflowsStorageCloudflare extends WorkflowsStorage {
|
|
|
13
13
|
runId: string;
|
|
14
14
|
stepId: string;
|
|
15
15
|
result: StepResult<any, any, any, any>;
|
|
16
|
-
|
|
16
|
+
requestContext: Record<string, any>;
|
|
17
17
|
}): Promise<Record<string, StepResult<any, any, any, any>>>;
|
|
18
18
|
updateWorkflowState({}: {
|
|
19
19
|
workflowName: string;
|
|
@@ -38,17 +38,14 @@ export declare class WorkflowsStorageCloudflare extends WorkflowsStorage {
|
|
|
38
38
|
}): Promise<WorkflowRunState | null>;
|
|
39
39
|
private parseWorkflowRun;
|
|
40
40
|
private buildWorkflowSnapshotPrefix;
|
|
41
|
-
|
|
42
|
-
workflowName?: string;
|
|
43
|
-
limit?: number;
|
|
44
|
-
offset?: number;
|
|
45
|
-
resourceId?: string;
|
|
46
|
-
fromDate?: Date;
|
|
47
|
-
toDate?: Date;
|
|
48
|
-
}): Promise<WorkflowRuns>;
|
|
41
|
+
listWorkflowRuns({ workflowName, page, perPage, resourceId, fromDate, toDate, status, }?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
|
|
49
42
|
getWorkflowRunById({ runId, workflowName, }: {
|
|
50
43
|
runId: string;
|
|
51
44
|
workflowName: string;
|
|
52
45
|
}): Promise<WorkflowRun | null>;
|
|
46
|
+
deleteWorkflowRunById({ runId, workflowName }: {
|
|
47
|
+
runId: string;
|
|
48
|
+
workflowName: string;
|
|
49
|
+
}): Promise<void>;
|
|
53
50
|
}
|
|
54
51
|
//# 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,EAAE,WAAW,EAAE,YAAY,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpG,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE/D,qBAAa,0BAA2B,SAAQ,gBAAgB;IAC9D,OAAO,CAAC,UAAU,CAA4B;gBAElC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,yBAAyB,CAAA;KAAE;IAKrE,OAAO,CAAC,sBAAsB;IAO9B,qBAAqB,CACnB,EAMC,EAAE;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QACvC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACrC,GACA,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAG1D,mBAAmB,CACjB,EAIC,EAAE;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE;YACJ,MAAM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
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { SaveScorePayload, ScoreRowData, ScoringSource } from '@mastra/core/evals';
|
|
3
|
+
import type { StorageThreadType, MastraDBMessage } from '@mastra/core/memory';
|
|
4
4
|
import { MastraStorage } from '@mastra/core/storage';
|
|
5
|
-
import type { TABLE_NAMES, StorageColumn,
|
|
6
|
-
import type { Trace } from '@mastra/core/telemetry';
|
|
5
|
+
import type { TABLE_NAMES, StorageColumn, WorkflowRuns, WorkflowRun, PaginationInfo, StoragePagination, StorageDomains, StorageResourceType, StorageListWorkflowRunsInput } from '@mastra/core/storage';
|
|
7
6
|
import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
|
|
8
7
|
import type { CloudflareStoreConfig, RecordTypes } from './types.js';
|
|
9
8
|
export declare class CloudflareStore extends MastraStorage {
|
|
@@ -14,6 +13,17 @@ export declare class CloudflareStore extends MastraStorage {
|
|
|
14
13
|
private bindings?;
|
|
15
14
|
private validateWorkersConfig;
|
|
16
15
|
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
|
+
agents?: boolean;
|
|
26
|
+
};
|
|
17
27
|
constructor(config: CloudflareStoreConfig);
|
|
18
28
|
createTable({ tableName, schema, }: {
|
|
19
29
|
tableName: TABLE_NAMES;
|
|
@@ -41,9 +51,6 @@ export declare class CloudflareStore extends MastraStorage {
|
|
|
41
51
|
getThreadById({ threadId }: {
|
|
42
52
|
threadId: string;
|
|
43
53
|
}): Promise<StorageThreadType | null>;
|
|
44
|
-
getThreadsByResourceId({ resourceId }: {
|
|
45
|
-
resourceId: string;
|
|
46
|
-
}): Promise<StorageThreadType[]>;
|
|
47
54
|
saveThread({ thread }: {
|
|
48
55
|
thread: StorageThreadType;
|
|
49
56
|
}): Promise<StorageThreadType>;
|
|
@@ -56,25 +63,16 @@ export declare class CloudflareStore extends MastraStorage {
|
|
|
56
63
|
threadId: string;
|
|
57
64
|
}): Promise<void>;
|
|
58
65
|
saveMessages(args: {
|
|
59
|
-
messages:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
format: 'v2';
|
|
65
|
-
}): Promise<MastraMessageV2[]>;
|
|
66
|
-
getMessages(args: StorageGetMessagesArg & {
|
|
67
|
-
format?: 'v1';
|
|
68
|
-
}): Promise<MastraMessageV1[]>;
|
|
69
|
-
getMessages(args: StorageGetMessagesArg & {
|
|
70
|
-
format: 'v2';
|
|
71
|
-
}): Promise<MastraMessageV2[]>;
|
|
72
|
-
updateWorkflowResults({ workflowName, runId, stepId, result, runtimeContext, }: {
|
|
66
|
+
messages: MastraDBMessage[];
|
|
67
|
+
}): Promise<{
|
|
68
|
+
messages: MastraDBMessage[];
|
|
69
|
+
}>;
|
|
70
|
+
updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, }: {
|
|
73
71
|
workflowName: string;
|
|
74
72
|
runId: string;
|
|
75
73
|
stepId: string;
|
|
76
74
|
result: StepResult<any, any, any, any>;
|
|
77
|
-
|
|
75
|
+
requestContext: Record<string, any>;
|
|
78
76
|
}): Promise<Record<string, StepResult<any, any, any, any>>>;
|
|
79
77
|
updateWorkflowState({ workflowName, runId, opts, }: {
|
|
80
78
|
workflowName: string;
|
|
@@ -87,14 +85,11 @@ export declare class CloudflareStore extends MastraStorage {
|
|
|
87
85
|
waitingPaths?: Record<string, number[]>;
|
|
88
86
|
};
|
|
89
87
|
}): Promise<WorkflowRunState | undefined>;
|
|
90
|
-
|
|
91
|
-
messageIds: string[];
|
|
92
|
-
format: 'v1';
|
|
93
|
-
}): Promise<MastraMessageV1[]>;
|
|
94
|
-
getMessagesById({ messageIds, format }: {
|
|
88
|
+
listMessagesById({ messageIds }: {
|
|
95
89
|
messageIds: string[];
|
|
96
|
-
|
|
97
|
-
|
|
90
|
+
}): Promise<{
|
|
91
|
+
messages: MastraDBMessage[];
|
|
92
|
+
}>;
|
|
98
93
|
persistWorkflowSnapshot(params: {
|
|
99
94
|
workflowName: string;
|
|
100
95
|
runId: string;
|
|
@@ -109,74 +104,38 @@ export declare class CloudflareStore extends MastraStorage {
|
|
|
109
104
|
tableName: T;
|
|
110
105
|
records: Partial<RecordTypes[T]>[];
|
|
111
106
|
}): Promise<void>;
|
|
112
|
-
|
|
113
|
-
name?: string;
|
|
114
|
-
scope?: string;
|
|
115
|
-
page: number;
|
|
116
|
-
perPage: number;
|
|
117
|
-
attributes?: Record<string, string>;
|
|
118
|
-
fromDate?: Date;
|
|
119
|
-
toDate?: Date;
|
|
120
|
-
}): Promise<any[]>;
|
|
121
|
-
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
122
|
-
getEvals(options: {
|
|
123
|
-
agentName?: string;
|
|
124
|
-
type?: 'test' | 'live';
|
|
125
|
-
dateRange?: {
|
|
126
|
-
start?: Date;
|
|
127
|
-
end?: Date;
|
|
128
|
-
};
|
|
129
|
-
} & PaginationArgs): Promise<PaginationInfo & {
|
|
130
|
-
evals: EvalRow[];
|
|
131
|
-
}>;
|
|
132
|
-
getWorkflowRuns({ workflowName, limit, offset, resourceId, fromDate, toDate, }?: {
|
|
133
|
-
workflowName?: string;
|
|
134
|
-
limit?: number;
|
|
135
|
-
offset?: number;
|
|
136
|
-
resourceId?: string;
|
|
137
|
-
fromDate?: Date;
|
|
138
|
-
toDate?: Date;
|
|
139
|
-
}): Promise<WorkflowRuns>;
|
|
107
|
+
listWorkflowRuns({ workflowName, perPage, page, resourceId, fromDate, toDate, status, }?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
|
|
140
108
|
getWorkflowRunById({ runId, workflowName, }: {
|
|
141
109
|
runId: string;
|
|
142
110
|
workflowName: string;
|
|
143
111
|
}): Promise<WorkflowRun | null>;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
resourceId: string;
|
|
149
|
-
page: number;
|
|
150
|
-
perPage: number;
|
|
151
|
-
}): Promise<PaginationInfo & {
|
|
152
|
-
threads: StorageThreadType[];
|
|
153
|
-
}>;
|
|
154
|
-
getMessagesPaginated(args: StorageGetMessagesArg): Promise<PaginationInfo & {
|
|
155
|
-
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
156
|
-
}>;
|
|
112
|
+
deleteWorkflowRunById({ runId, workflowName }: {
|
|
113
|
+
runId: string;
|
|
114
|
+
workflowName: string;
|
|
115
|
+
}): Promise<void>;
|
|
157
116
|
updateMessages(args: {
|
|
158
|
-
messages: Partial<Omit<
|
|
117
|
+
messages: (Partial<Omit<MastraDBMessage, 'createdAt'>> & {
|
|
159
118
|
id: string;
|
|
160
119
|
content?: {
|
|
161
120
|
metadata?: MastraMessageContentV2['metadata'];
|
|
162
121
|
content?: MastraMessageContentV2['content'];
|
|
163
122
|
};
|
|
164
|
-
}[];
|
|
165
|
-
}): Promise<
|
|
123
|
+
})[];
|
|
124
|
+
}): Promise<MastraDBMessage[]>;
|
|
166
125
|
getScoreById({ id }: {
|
|
167
126
|
id: string;
|
|
168
127
|
}): Promise<ScoreRowData | null>;
|
|
169
|
-
saveScore(score:
|
|
128
|
+
saveScore(score: SaveScorePayload): Promise<{
|
|
170
129
|
score: ScoreRowData;
|
|
171
130
|
}>;
|
|
172
|
-
|
|
131
|
+
listScoresByRunId({ runId, pagination, }: {
|
|
173
132
|
runId: string;
|
|
174
133
|
pagination: StoragePagination;
|
|
175
134
|
}): Promise<{
|
|
176
135
|
pagination: PaginationInfo;
|
|
177
136
|
scores: ScoreRowData[];
|
|
178
137
|
}>;
|
|
179
|
-
|
|
138
|
+
listScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
180
139
|
pagination: StoragePagination;
|
|
181
140
|
entityId: string;
|
|
182
141
|
entityType: string;
|
|
@@ -184,7 +143,7 @@ export declare class CloudflareStore extends MastraStorage {
|
|
|
184
143
|
pagination: PaginationInfo;
|
|
185
144
|
scores: ScoreRowData[];
|
|
186
145
|
}>;
|
|
187
|
-
|
|
146
|
+
listScoresByScorerId({ scorerId, entityId, entityType, source, pagination, }: {
|
|
188
147
|
scorerId: string;
|
|
189
148
|
entityId?: string;
|
|
190
149
|
entityType?: string;
|
|
@@ -194,6 +153,14 @@ export declare class CloudflareStore extends MastraStorage {
|
|
|
194
153
|
pagination: PaginationInfo;
|
|
195
154
|
scores: ScoreRowData[];
|
|
196
155
|
}>;
|
|
156
|
+
listScoresBySpan({ traceId, spanId, pagination, }: {
|
|
157
|
+
traceId: string;
|
|
158
|
+
spanId: string;
|
|
159
|
+
pagination: StoragePagination;
|
|
160
|
+
}): Promise<{
|
|
161
|
+
pagination: PaginationInfo;
|
|
162
|
+
scores: ScoreRowData[];
|
|
163
|
+
}>;
|
|
197
164
|
getResourceById({ resourceId }: {
|
|
198
165
|
resourceId: string;
|
|
199
166
|
}): Promise<StorageResourceType | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxF,OAAO,KAAK,EAAE,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AE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAI7D,eAAe,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAI5F,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE;QAAE,QAAQ,EAAE,mBAAmB,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAI3F,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;IAI1B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../src/storage/test-utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,EAAE,QAAQ,MAAM,EAAE,aAAa,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;;;;;;;;;;;CAejG,CAAC;AAEH,eAAO,MAAM,4BAA4B,GAAI,UAAU,MAAM,EAAE,QAAQ,MAAM,EAAE,YAAY,IAAI;;;;
|
|
1
|
+
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../src/storage/test-utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,EAAE,QAAQ,MAAM,EAAE,aAAa,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;;;;;;;;;;;CAejG,CAAC;AAEH,eAAO,MAAM,4BAA4B,GAAI,UAAU,MAAM,EAAE,QAAQ,MAAM,EAAE,YAAY,IAAI;;;;CA4B9F,CAAC;AAGF,eAAO,MAAM,UAAU,GAAU,CAAC,EAChC,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,WAAW,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,EACjC,gBAAe,EAAE,sDAAsD;AACvE,iBAAe,KACd,OAAO,CAAC,CAAC,CAYX,CAAC"}
|
package/dist/storage/types.d.ts
CHANGED
|
@@ -1,12 +1,39 @@
|
|
|
1
1
|
import type { KVNamespace } from '@cloudflare/workers-types';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type { TABLE_MESSAGES, TABLE_THREADS, TABLE_WORKFLOW_SNAPSHOT,
|
|
2
|
+
import type { ScoreRowData } from '@mastra/core/evals';
|
|
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, TABLE_AGENTS, SpanRecord, StorageAgentType } from '@mastra/core/storage';
|
|
5
5
|
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
6
|
+
/**
|
|
7
|
+
* Base configuration options shared across Cloudflare configurations
|
|
8
|
+
*/
|
|
9
|
+
export interface CloudflareBaseConfig {
|
|
10
|
+
/** Storage instance ID */
|
|
11
|
+
id: string;
|
|
12
|
+
/**
|
|
13
|
+
* When true, automatic initialization (table creation/migrations) is disabled.
|
|
14
|
+
* This is useful for CI/CD pipelines where you want to:
|
|
15
|
+
* 1. Run migrations explicitly during deployment (not at runtime)
|
|
16
|
+
* 2. Use different credentials for schema changes vs runtime operations
|
|
17
|
+
*
|
|
18
|
+
* When disableInit is true:
|
|
19
|
+
* - The storage will not automatically create/alter tables on first use
|
|
20
|
+
* - You must call `storage.init()` explicitly in your CI/CD scripts
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // In CI/CD script:
|
|
24
|
+
* const storage = new CloudflareStore({ ...config, disableInit: false });
|
|
25
|
+
* await storage.init(); // Explicitly run migrations
|
|
26
|
+
*
|
|
27
|
+
* // In runtime application:
|
|
28
|
+
* const storage = new CloudflareStore({ ...config, disableInit: true });
|
|
29
|
+
* // No auto-init, tables must already exist
|
|
30
|
+
*/
|
|
31
|
+
disableInit?: boolean;
|
|
32
|
+
}
|
|
6
33
|
/**
|
|
7
34
|
* Configuration for Cloudflare KV using REST API
|
|
8
35
|
*/
|
|
9
|
-
export interface CloudflareRestConfig {
|
|
36
|
+
export interface CloudflareRestConfig extends CloudflareBaseConfig {
|
|
10
37
|
/** Cloudflare account ID */
|
|
11
38
|
accountId: string;
|
|
12
39
|
/** Cloudflare API token with KV access */
|
|
@@ -21,7 +48,7 @@ export interface CloudflareRestConfig {
|
|
|
21
48
|
/**
|
|
22
49
|
* Configuration for Cloudflare KV using Workers Binding API
|
|
23
50
|
*/
|
|
24
|
-
export interface CloudflareWorkersConfig {
|
|
51
|
+
export interface CloudflareWorkersConfig extends CloudflareBaseConfig {
|
|
25
52
|
/** KV namespace bindings from Workers environment */
|
|
26
53
|
bindings: {
|
|
27
54
|
[key in TABLE_NAMES]: KVNamespace;
|
|
@@ -52,13 +79,13 @@ export interface KVOperation {
|
|
|
52
79
|
export declare function isWorkersConfig(config: CloudflareStoreConfig): config is CloudflareWorkersConfig;
|
|
53
80
|
export type RecordTypes = {
|
|
54
81
|
[TABLE_THREADS]: StorageThreadType;
|
|
55
|
-
[TABLE_MESSAGES]:
|
|
82
|
+
[TABLE_MESSAGES]: MastraDBMessage;
|
|
56
83
|
[TABLE_WORKFLOW_SNAPSHOT]: WorkflowRunState;
|
|
57
|
-
[TABLE_EVALS]: EvalRow;
|
|
58
84
|
[TABLE_SCORERS]: ScoreRowData;
|
|
59
85
|
[TABLE_TRACES]: any;
|
|
60
86
|
[TABLE_RESOURCES]: StorageResourceType;
|
|
61
|
-
[
|
|
87
|
+
[TABLE_SPANS]: SpanRecord;
|
|
88
|
+
[TABLE_AGENTS]: StorageAgentType;
|
|
62
89
|
};
|
|
63
90
|
export type ListOptions = {
|
|
64
91
|
limit?: number;
|
|
@@ -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,
|
|
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,CAAC;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,0BAA0B;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX;;;;;;;;;;;;;;;;;;OAkBG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,oBAAoB;IAChE,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,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