@mastra/cloudflare 0.0.0-trigger-playground-ui-package-20250506151043 → 0.0.0-tsconfig-compile-20250703214351
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/_tsup-dts-rollup.d.cts +71 -24
- package/dist/_tsup-dts-rollup.d.ts +71 -24
- package/dist/index.cjs +432 -118
- package/dist/index.js +411 -97
- package/package.json +17 -13
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
import type { EvalRow } from '@mastra/core/storage';
|
|
2
2
|
import type { KVNamespace as KVNamespace_2 } from '@cloudflare/workers-types';
|
|
3
3
|
import { KVNamespaceListKey as KVNamespaceListKey_2 } from '@cloudflare/workers-types';
|
|
4
|
+
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
5
|
+
import type { MastraMessageV1 } from '@mastra/core/memory';
|
|
6
|
+
import type { MastraMessageV2 } from '@mastra/core/memory';
|
|
4
7
|
import { MastraStorage } from '@mastra/core/storage';
|
|
5
|
-
import type {
|
|
6
|
-
import type { MessageType as MessageType_2 } from '@mastra/core';
|
|
8
|
+
import type { PaginationInfo } from '@mastra/core/storage';
|
|
7
9
|
import type { StorageColumn } from '@mastra/core/storage';
|
|
8
10
|
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
11
|
+
import type { StorageGetTracesArg } from '@mastra/core/storage';
|
|
12
|
+
import type { StorageResourceType } from '@mastra/core/storage';
|
|
9
13
|
import type { StorageThreadType } from '@mastra/core/memory';
|
|
10
14
|
import type { TABLE_EVALS } from '@mastra/core/storage';
|
|
11
15
|
import type { TABLE_MESSAGES } from '@mastra/core/storage';
|
|
12
16
|
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
17
|
+
import type { TABLE_RESOURCES } from '@mastra/core/storage';
|
|
13
18
|
import type { TABLE_THREADS } from '@mastra/core/storage';
|
|
14
19
|
import type { TABLE_TRACES } from '@mastra/core/storage';
|
|
15
20
|
import type { TABLE_WORKFLOW_SNAPSHOT } from '@mastra/core/storage';
|
|
21
|
+
import type { Trace } from '@mastra/core/telemetry';
|
|
16
22
|
import type { WorkflowRun } from '@mastra/core/storage';
|
|
17
23
|
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
18
24
|
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
19
25
|
import type { WorkflowRunState as WorkflowRunState_2 } from '@mastra/core';
|
|
20
26
|
|
|
21
|
-
export declare const checkWorkflowSnapshot: (snapshot: WorkflowRunState_2 | string, stepId: string, status: string) => void;
|
|
22
|
-
|
|
23
27
|
/**
|
|
24
28
|
* Configuration for Cloudflare KV using REST API
|
|
25
29
|
*/
|
|
@@ -55,6 +59,20 @@ declare class CloudflareStore extends MastraStorage {
|
|
|
55
59
|
private createNamespace;
|
|
56
60
|
private getOrCreateNamespaceId;
|
|
57
61
|
private getNamespaceId;
|
|
62
|
+
private LEGACY_NAMESPACE_MAP;
|
|
63
|
+
/**
|
|
64
|
+
* There were a few legacy mappings for tables such as
|
|
65
|
+
* - messages -> threads
|
|
66
|
+
* - workflow_snapshot -> mastra_workflows
|
|
67
|
+
* - traces -> evals
|
|
68
|
+
* This has been updated to use dedicated namespaces for each table.
|
|
69
|
+
* In the case of data for a table existing in the legacy namespace, warn the user to migrate to the new namespace.
|
|
70
|
+
*
|
|
71
|
+
* @param tableName The table name to check for legacy data
|
|
72
|
+
* @param prefix The namespace prefix
|
|
73
|
+
* @returns The legacy namespace ID if data exists; otherwise, null
|
|
74
|
+
*/
|
|
75
|
+
private checkLegacyNamespace;
|
|
58
76
|
/**
|
|
59
77
|
* Helper to safely serialize data for KV storage
|
|
60
78
|
*/
|
|
@@ -93,13 +111,22 @@ declare class CloudflareStore extends MastraStorage {
|
|
|
93
111
|
private validateColumnValue;
|
|
94
112
|
private validateAgainstSchema;
|
|
95
113
|
private validateRecord;
|
|
96
|
-
private ensureDate;
|
|
97
|
-
private serializeDate;
|
|
98
114
|
private ensureMetadata;
|
|
99
115
|
createTable({ tableName, schema, }: {
|
|
100
116
|
tableName: TABLE_NAMES;
|
|
101
117
|
schema: Record<string, StorageColumn>;
|
|
102
118
|
}): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* No-op: This backend is schemaless and does not require schema changes.
|
|
121
|
+
* @param tableName Name of the table
|
|
122
|
+
* @param schema Schema of the table
|
|
123
|
+
* @param ifNotExists Array of column names to add if they don't exist
|
|
124
|
+
*/
|
|
125
|
+
alterTable(_args: {
|
|
126
|
+
tableName: TABLE_NAMES;
|
|
127
|
+
schema: Record<string, StorageColumn>;
|
|
128
|
+
ifNotExists: string[];
|
|
129
|
+
}): Promise<void>;
|
|
103
130
|
clearTable({ tableName }: {
|
|
104
131
|
tableName: TABLE_NAMES;
|
|
105
132
|
}): Promise<void>;
|
|
@@ -130,10 +157,20 @@ declare class CloudflareStore extends MastraStorage {
|
|
|
130
157
|
}): Promise<void>;
|
|
131
158
|
private getMessageKey;
|
|
132
159
|
private getThreadMessagesKey;
|
|
133
|
-
saveMessages(
|
|
134
|
-
messages:
|
|
135
|
-
|
|
136
|
-
|
|
160
|
+
saveMessages(args: {
|
|
161
|
+
messages: MastraMessageV1[];
|
|
162
|
+
format?: undefined | 'v1';
|
|
163
|
+
}): Promise<MastraMessageV1[]>;
|
|
164
|
+
saveMessages(args: {
|
|
165
|
+
messages: MastraMessageV2[];
|
|
166
|
+
format: 'v2';
|
|
167
|
+
}): Promise<MastraMessageV2[]>;
|
|
168
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
169
|
+
format?: 'v1';
|
|
170
|
+
}): Promise<MastraMessageV1[]>;
|
|
171
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
172
|
+
format: 'v2';
|
|
173
|
+
}): Promise<MastraMessageV2[]>;
|
|
137
174
|
private validateWorkflowParams;
|
|
138
175
|
private validateWorkflowState;
|
|
139
176
|
private normalizeSteps;
|
|
@@ -180,7 +217,29 @@ declare class CloudflareStore extends MastraStorage {
|
|
|
180
217
|
runId: string;
|
|
181
218
|
workflowName: string;
|
|
182
219
|
}): Promise<WorkflowRun | null>;
|
|
220
|
+
getTracesPaginated(_args: StorageGetTracesArg): Promise<PaginationInfo & {
|
|
221
|
+
traces: Trace[];
|
|
222
|
+
}>;
|
|
223
|
+
getThreadsByResourceIdPaginated(_args: {
|
|
224
|
+
resourceId: string;
|
|
225
|
+
page?: number;
|
|
226
|
+
perPage?: number;
|
|
227
|
+
}): Promise<PaginationInfo & {
|
|
228
|
+
threads: StorageThreadType[];
|
|
229
|
+
}>;
|
|
230
|
+
getMessagesPaginated(_args: StorageGetMessagesArg): Promise<PaginationInfo & {
|
|
231
|
+
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
232
|
+
}>;
|
|
183
233
|
close(): Promise<void>;
|
|
234
|
+
updateMessages(_args: {
|
|
235
|
+
messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
236
|
+
id: string;
|
|
237
|
+
content?: {
|
|
238
|
+
metadata?: MastraMessageContentV2['metadata'];
|
|
239
|
+
content?: MastraMessageContentV2['content'];
|
|
240
|
+
};
|
|
241
|
+
}[];
|
|
242
|
+
}): Promise<MastraMessageV2[]>;
|
|
184
243
|
}
|
|
185
244
|
export { CloudflareStore }
|
|
186
245
|
export { CloudflareStore as CloudflareStore_alias_1 }
|
|
@@ -202,19 +261,6 @@ export declare interface CloudflareWorkersConfig {
|
|
|
202
261
|
keyPrefix?: string;
|
|
203
262
|
}
|
|
204
263
|
|
|
205
|
-
export declare const createSampleMessage: (threadId: string) => MessageType_2;
|
|
206
|
-
|
|
207
|
-
export declare const createSampleThread: () => {
|
|
208
|
-
id: string;
|
|
209
|
-
resourceId: string;
|
|
210
|
-
title: string;
|
|
211
|
-
createdAt: Date;
|
|
212
|
-
updatedAt: Date;
|
|
213
|
-
metadata: {
|
|
214
|
-
key: string;
|
|
215
|
-
};
|
|
216
|
-
};
|
|
217
|
-
|
|
218
264
|
export declare const createSampleTrace: (name: string, scope?: string, attributes?: Record<string, string>) => {
|
|
219
265
|
id: string;
|
|
220
266
|
parentSpanId: string;
|
|
@@ -264,10 +310,11 @@ export declare type ListOptions = {
|
|
|
264
310
|
|
|
265
311
|
export declare type RecordTypes = {
|
|
266
312
|
[TABLE_THREADS]: StorageThreadType;
|
|
267
|
-
[TABLE_MESSAGES]:
|
|
313
|
+
[TABLE_MESSAGES]: MastraMessageV2;
|
|
268
314
|
[TABLE_WORKFLOW_SNAPSHOT]: WorkflowRunState;
|
|
269
315
|
[TABLE_EVALS]: EvalRow;
|
|
270
316
|
[TABLE_TRACES]: any;
|
|
317
|
+
[TABLE_RESOURCES]: StorageResourceType;
|
|
271
318
|
};
|
|
272
319
|
|
|
273
320
|
export declare const retryUntil: <T>(fn: () => Promise<T>, condition: (result: T) => boolean, timeout?: number, // REST API needs longer timeout due to higher latency
|
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
import type { EvalRow } from '@mastra/core/storage';
|
|
2
2
|
import type { KVNamespace as KVNamespace_2 } from '@cloudflare/workers-types';
|
|
3
3
|
import { KVNamespaceListKey as KVNamespaceListKey_2 } from '@cloudflare/workers-types';
|
|
4
|
+
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
5
|
+
import type { MastraMessageV1 } from '@mastra/core/memory';
|
|
6
|
+
import type { MastraMessageV2 } from '@mastra/core/memory';
|
|
4
7
|
import { MastraStorage } from '@mastra/core/storage';
|
|
5
|
-
import type {
|
|
6
|
-
import type { MessageType as MessageType_2 } from '@mastra/core';
|
|
8
|
+
import type { PaginationInfo } from '@mastra/core/storage';
|
|
7
9
|
import type { StorageColumn } from '@mastra/core/storage';
|
|
8
10
|
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
11
|
+
import type { StorageGetTracesArg } from '@mastra/core/storage';
|
|
12
|
+
import type { StorageResourceType } from '@mastra/core/storage';
|
|
9
13
|
import type { StorageThreadType } from '@mastra/core/memory';
|
|
10
14
|
import type { TABLE_EVALS } from '@mastra/core/storage';
|
|
11
15
|
import type { TABLE_MESSAGES } from '@mastra/core/storage';
|
|
12
16
|
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
17
|
+
import type { TABLE_RESOURCES } from '@mastra/core/storage';
|
|
13
18
|
import type { TABLE_THREADS } from '@mastra/core/storage';
|
|
14
19
|
import type { TABLE_TRACES } from '@mastra/core/storage';
|
|
15
20
|
import type { TABLE_WORKFLOW_SNAPSHOT } from '@mastra/core/storage';
|
|
21
|
+
import type { Trace } from '@mastra/core/telemetry';
|
|
16
22
|
import type { WorkflowRun } from '@mastra/core/storage';
|
|
17
23
|
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
18
24
|
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
19
25
|
import type { WorkflowRunState as WorkflowRunState_2 } from '@mastra/core';
|
|
20
26
|
|
|
21
|
-
export declare const checkWorkflowSnapshot: (snapshot: WorkflowRunState_2 | string, stepId: string, status: string) => void;
|
|
22
|
-
|
|
23
27
|
/**
|
|
24
28
|
* Configuration for Cloudflare KV using REST API
|
|
25
29
|
*/
|
|
@@ -55,6 +59,20 @@ declare class CloudflareStore extends MastraStorage {
|
|
|
55
59
|
private createNamespace;
|
|
56
60
|
private getOrCreateNamespaceId;
|
|
57
61
|
private getNamespaceId;
|
|
62
|
+
private LEGACY_NAMESPACE_MAP;
|
|
63
|
+
/**
|
|
64
|
+
* There were a few legacy mappings for tables such as
|
|
65
|
+
* - messages -> threads
|
|
66
|
+
* - workflow_snapshot -> mastra_workflows
|
|
67
|
+
* - traces -> evals
|
|
68
|
+
* This has been updated to use dedicated namespaces for each table.
|
|
69
|
+
* In the case of data for a table existing in the legacy namespace, warn the user to migrate to the new namespace.
|
|
70
|
+
*
|
|
71
|
+
* @param tableName The table name to check for legacy data
|
|
72
|
+
* @param prefix The namespace prefix
|
|
73
|
+
* @returns The legacy namespace ID if data exists; otherwise, null
|
|
74
|
+
*/
|
|
75
|
+
private checkLegacyNamespace;
|
|
58
76
|
/**
|
|
59
77
|
* Helper to safely serialize data for KV storage
|
|
60
78
|
*/
|
|
@@ -93,13 +111,22 @@ declare class CloudflareStore extends MastraStorage {
|
|
|
93
111
|
private validateColumnValue;
|
|
94
112
|
private validateAgainstSchema;
|
|
95
113
|
private validateRecord;
|
|
96
|
-
private ensureDate;
|
|
97
|
-
private serializeDate;
|
|
98
114
|
private ensureMetadata;
|
|
99
115
|
createTable({ tableName, schema, }: {
|
|
100
116
|
tableName: TABLE_NAMES;
|
|
101
117
|
schema: Record<string, StorageColumn>;
|
|
102
118
|
}): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* No-op: This backend is schemaless and does not require schema changes.
|
|
121
|
+
* @param tableName Name of the table
|
|
122
|
+
* @param schema Schema of the table
|
|
123
|
+
* @param ifNotExists Array of column names to add if they don't exist
|
|
124
|
+
*/
|
|
125
|
+
alterTable(_args: {
|
|
126
|
+
tableName: TABLE_NAMES;
|
|
127
|
+
schema: Record<string, StorageColumn>;
|
|
128
|
+
ifNotExists: string[];
|
|
129
|
+
}): Promise<void>;
|
|
103
130
|
clearTable({ tableName }: {
|
|
104
131
|
tableName: TABLE_NAMES;
|
|
105
132
|
}): Promise<void>;
|
|
@@ -130,10 +157,20 @@ declare class CloudflareStore extends MastraStorage {
|
|
|
130
157
|
}): Promise<void>;
|
|
131
158
|
private getMessageKey;
|
|
132
159
|
private getThreadMessagesKey;
|
|
133
|
-
saveMessages(
|
|
134
|
-
messages:
|
|
135
|
-
|
|
136
|
-
|
|
160
|
+
saveMessages(args: {
|
|
161
|
+
messages: MastraMessageV1[];
|
|
162
|
+
format?: undefined | 'v1';
|
|
163
|
+
}): Promise<MastraMessageV1[]>;
|
|
164
|
+
saveMessages(args: {
|
|
165
|
+
messages: MastraMessageV2[];
|
|
166
|
+
format: 'v2';
|
|
167
|
+
}): Promise<MastraMessageV2[]>;
|
|
168
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
169
|
+
format?: 'v1';
|
|
170
|
+
}): Promise<MastraMessageV1[]>;
|
|
171
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
172
|
+
format: 'v2';
|
|
173
|
+
}): Promise<MastraMessageV2[]>;
|
|
137
174
|
private validateWorkflowParams;
|
|
138
175
|
private validateWorkflowState;
|
|
139
176
|
private normalizeSteps;
|
|
@@ -180,7 +217,29 @@ declare class CloudflareStore extends MastraStorage {
|
|
|
180
217
|
runId: string;
|
|
181
218
|
workflowName: string;
|
|
182
219
|
}): Promise<WorkflowRun | null>;
|
|
220
|
+
getTracesPaginated(_args: StorageGetTracesArg): Promise<PaginationInfo & {
|
|
221
|
+
traces: Trace[];
|
|
222
|
+
}>;
|
|
223
|
+
getThreadsByResourceIdPaginated(_args: {
|
|
224
|
+
resourceId: string;
|
|
225
|
+
page?: number;
|
|
226
|
+
perPage?: number;
|
|
227
|
+
}): Promise<PaginationInfo & {
|
|
228
|
+
threads: StorageThreadType[];
|
|
229
|
+
}>;
|
|
230
|
+
getMessagesPaginated(_args: StorageGetMessagesArg): Promise<PaginationInfo & {
|
|
231
|
+
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
232
|
+
}>;
|
|
183
233
|
close(): Promise<void>;
|
|
234
|
+
updateMessages(_args: {
|
|
235
|
+
messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
236
|
+
id: string;
|
|
237
|
+
content?: {
|
|
238
|
+
metadata?: MastraMessageContentV2['metadata'];
|
|
239
|
+
content?: MastraMessageContentV2['content'];
|
|
240
|
+
};
|
|
241
|
+
}[];
|
|
242
|
+
}): Promise<MastraMessageV2[]>;
|
|
184
243
|
}
|
|
185
244
|
export { CloudflareStore }
|
|
186
245
|
export { CloudflareStore as CloudflareStore_alias_1 }
|
|
@@ -202,19 +261,6 @@ export declare interface CloudflareWorkersConfig {
|
|
|
202
261
|
keyPrefix?: string;
|
|
203
262
|
}
|
|
204
263
|
|
|
205
|
-
export declare const createSampleMessage: (threadId: string) => MessageType_2;
|
|
206
|
-
|
|
207
|
-
export declare const createSampleThread: () => {
|
|
208
|
-
id: string;
|
|
209
|
-
resourceId: string;
|
|
210
|
-
title: string;
|
|
211
|
-
createdAt: Date;
|
|
212
|
-
updatedAt: Date;
|
|
213
|
-
metadata: {
|
|
214
|
-
key: string;
|
|
215
|
-
};
|
|
216
|
-
};
|
|
217
|
-
|
|
218
264
|
export declare const createSampleTrace: (name: string, scope?: string, attributes?: Record<string, string>) => {
|
|
219
265
|
id: string;
|
|
220
266
|
parentSpanId: string;
|
|
@@ -264,10 +310,11 @@ export declare type ListOptions = {
|
|
|
264
310
|
|
|
265
311
|
export declare type RecordTypes = {
|
|
266
312
|
[TABLE_THREADS]: StorageThreadType;
|
|
267
|
-
[TABLE_MESSAGES]:
|
|
313
|
+
[TABLE_MESSAGES]: MastraMessageV2;
|
|
268
314
|
[TABLE_WORKFLOW_SNAPSHOT]: WorkflowRunState;
|
|
269
315
|
[TABLE_EVALS]: EvalRow;
|
|
270
316
|
[TABLE_TRACES]: any;
|
|
317
|
+
[TABLE_RESOURCES]: StorageResourceType;
|
|
271
318
|
};
|
|
272
319
|
|
|
273
320
|
export declare const retryUntil: <T>(fn: () => Promise<T>, condition: (result: T) => boolean, timeout?: number, // REST API needs longer timeout due to higher latency
|