@mastra/cloudflare 0.0.0-vector-sources-20250516175436 → 0.0.0-vector-query-tool-provider-options-20250828222356

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.
@@ -0,0 +1,83 @@
1
+ import type { KVNamespace } from '@cloudflare/workers-types';
2
+ import { StoreOperations } from '@mastra/core/storage';
3
+ import type { StorageColumn, TABLE_NAMES } from '@mastra/core/storage';
4
+ import type Cloudflare from 'cloudflare';
5
+ import type { ListOptions, RecordTypes } from '../../types.js';
6
+ export declare class StoreOperationsCloudflare extends StoreOperations {
7
+ private bindings?;
8
+ client?: Cloudflare;
9
+ accountId?: string;
10
+ namespacePrefix: string;
11
+ constructor({ namespacePrefix, bindings, client, accountId, }: {
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>;
29
+ private getBinding;
30
+ getKey<T extends TABLE_NAMES>(tableName: T, record: Record<string, string>): string;
31
+ private getSchemaKey;
32
+ /**
33
+ * Helper to safely parse data from KV storage
34
+ */
35
+ private safeParse;
36
+ private createNamespaceById;
37
+ private createNamespace;
38
+ private listNamespaces;
39
+ private getNamespaceIdByName;
40
+ private getOrCreateNamespaceId;
41
+ private getNamespaceId;
42
+ private getNamespaceValue;
43
+ getKV(tableName: TABLE_NAMES, key: string): Promise<any>;
44
+ private getTableSchema;
45
+ private validateColumnValue;
46
+ private validateAgainstSchema;
47
+ private validateRecord;
48
+ insert({ tableName, record }: {
49
+ tableName: TABLE_NAMES;
50
+ record: Record<string, any>;
51
+ }): Promise<void>;
52
+ private ensureMetadata;
53
+ load<R>({ tableName, keys }: {
54
+ tableName: TABLE_NAMES;
55
+ keys: Record<string, string>;
56
+ }): Promise<R | null>;
57
+ batchInsert<T extends TABLE_NAMES>(input: {
58
+ tableName: T;
59
+ records: Partial<RecordTypes[T]>[];
60
+ }): Promise<void>;
61
+ /**
62
+ * Helper to safely serialize data for KV storage
63
+ */
64
+ private safeSerialize;
65
+ private putNamespaceValue;
66
+ putKV({ tableName, key, value, metadata, }: {
67
+ tableName: TABLE_NAMES;
68
+ key: string;
69
+ value: any;
70
+ metadata?: any;
71
+ }): Promise<void>;
72
+ createTable({ tableName, schema, }: {
73
+ tableName: TABLE_NAMES;
74
+ schema: Record<string, StorageColumn>;
75
+ }): Promise<void>;
76
+ listNamespaceKeys(tableName: TABLE_NAMES, options?: ListOptions): Promise<import("@cloudflare/workers-types").KVNamespaceListKey<unknown, string>[]>;
77
+ private deleteNamespaceValue;
78
+ deleteKV(tableName: TABLE_NAMES, key: string): Promise<void>;
79
+ listKV(tableName: TABLE_NAMES, options?: ListOptions): Promise<Array<{
80
+ name: string;
81
+ }>>;
82
+ }
83
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,EAGL,eAAe,EAOhB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE5D,qBAAa,yBAA0B,SAAQ,eAAe;IAC5D,OAAO,CAAC,QAAQ,CAAC,CAAmC;IACpD,MAAM,CAAC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AO,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"}
@@ -0,0 +1,42 @@
1
+ import type { ScoreRowData, ScoringSource } from '@mastra/core/scores';
2
+ import { ScoresStorage } from '@mastra/core/storage';
3
+ import type { StoragePagination, PaginationInfo } from '@mastra/core/storage';
4
+ import type { StoreOperationsCloudflare } from '../operations/index.js';
5
+ export declare class ScoresStorageCloudflare extends ScoresStorage {
6
+ private operations;
7
+ constructor({ operations }: {
8
+ operations: StoreOperationsCloudflare;
9
+ });
10
+ getScoreById({ id }: {
11
+ id: string;
12
+ }): Promise<ScoreRowData | null>;
13
+ saveScore(score: Omit<ScoreRowData, 'createdAt' | 'updatedAt'>): Promise<{
14
+ score: ScoreRowData;
15
+ }>;
16
+ getScoresByScorerId({ scorerId, entityId, entityType, source, pagination, }: {
17
+ scorerId: string;
18
+ entityId?: string;
19
+ entityType?: string;
20
+ source?: ScoringSource;
21
+ pagination: StoragePagination;
22
+ }): Promise<{
23
+ pagination: PaginationInfo;
24
+ scores: ScoreRowData[];
25
+ }>;
26
+ getScoresByRunId({ runId, pagination, }: {
27
+ runId: string;
28
+ pagination: StoragePagination;
29
+ }): Promise<{
30
+ pagination: PaginationInfo;
31
+ scores: ScoreRowData[];
32
+ }>;
33
+ getScoresByEntityId({ entityId, entityType, pagination, }: {
34
+ pagination: StoragePagination;
35
+ entityId: string;
36
+ entityType: string;
37
+ }): Promise<{
38
+ pagination: PaginationInfo;
39
+ scores: ScoreRowData[];
40
+ }>;
41
+ }
42
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/scores/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EA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,UAAU,EACV,UAAU,GACX,EAAE;QACD,UAAU,EAAE,iBAAiB,CAAC;QAC9B,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;CAgDpE"}
@@ -0,0 +1,18 @@
1
+ import { TracesStorage } from '@mastra/core/storage';
2
+ import type { StorageGetTracesArg, StorageGetTracesPaginatedArg, PaginationInfo } from '@mastra/core/storage';
3
+ import type { Trace } from '@mastra/core/telemetry';
4
+ import type { StoreOperationsCloudflare } from '../operations/index.js';
5
+ export declare class TracesStorageCloudflare extends TracesStorage {
6
+ private operations;
7
+ constructor({ operations }: {
8
+ operations: StoreOperationsCloudflare;
9
+ });
10
+ getTraces(args: StorageGetTracesArg): Promise<Trace[]>;
11
+ getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
12
+ traces: Trace[];
13
+ }>;
14
+ batchTraceInsert({ records }: {
15
+ records: Record<string, any>[];
16
+ }): Promise<void>;
17
+ }
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/traces/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,4BAA4B,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC9G,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE/D,qBAAa,uBAAwB,SAAQ,aAAa;IACxD,OAAO,CAAC,UAAU,CAA4B;gBAElC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,yBAAyB,CAAA;KAAE;IAK/D,SAAS,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAsCtD,kBAAkB,CAAC,IAAI,EAAE,4BAA4B,GAAG,OAAO,CAAC,cAAc,GAAG;QAAE,MAAM,EAAE,KAAK,EAAE,CAAA;KAAE,CAAC;IA+FrG,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAOvF"}
@@ -0,0 +1,53 @@
1
+ import { WorkflowsStorage } from '@mastra/core/storage';
2
+ import type { WorkflowRun, WorkflowRuns } from '@mastra/core/storage';
3
+ import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
4
+ import type { StoreOperationsCloudflare } from '../operations/index.js';
5
+ export declare class WorkflowsStorageCloudflare extends WorkflowsStorage {
6
+ private operations;
7
+ constructor({ operations }: {
8
+ operations: StoreOperationsCloudflare;
9
+ });
10
+ private validateWorkflowParams;
11
+ updateWorkflowResults({}: {
12
+ workflowName: string;
13
+ runId: string;
14
+ stepId: string;
15
+ result: StepResult<any, any, any, any>;
16
+ runtimeContext: Record<string, any>;
17
+ }): Promise<Record<string, StepResult<any, any, any, any>>>;
18
+ updateWorkflowState({}: {
19
+ workflowName: string;
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
+ };
28
+ }): Promise<WorkflowRunState | undefined>;
29
+ persistWorkflowSnapshot(params: {
30
+ workflowName: string;
31
+ runId: string;
32
+ snapshot: WorkflowRunState;
33
+ }): Promise<void>;
34
+ loadWorkflowSnapshot(params: {
35
+ workflowName: string;
36
+ runId: string;
37
+ }): Promise<WorkflowRunState | null>;
38
+ private parseWorkflowRun;
39
+ private buildWorkflowSnapshotPrefix;
40
+ getWorkflowRuns({ workflowName, limit, offset, resourceId, fromDate, toDate, }?: {
41
+ workflowName?: string;
42
+ limit?: number;
43
+ offset?: number;
44
+ resourceId?: string;
45
+ fromDate?: Date;
46
+ toDate?: Date;
47
+ }): Promise<WorkflowRuns>;
48
+ getWorkflowRunById({ runId, workflowName, }: {
49
+ runId: string;
50
+ workflowName: string;
51
+ }): Promise<WorkflowRun | null>;
52
+ }
53
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAuC,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACtE,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;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AC;KACtB,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;CA4ChC"}
@@ -0,0 +1,209 @@
1
+ import type { MastraMessageContentV2 } from '@mastra/core/agent';
2
+ import type { StorageThreadType, MastraMessageV1, MastraMessageV2 } from '@mastra/core/memory';
3
+ import type { ScoreRowData, ScoringSource } from '@mastra/core/scores';
4
+ import { MastraStorage } from '@mastra/core/storage';
5
+ import type { TABLE_NAMES, StorageColumn, StorageGetMessagesArg, EvalRow, WorkflowRuns, WorkflowRun, StorageGetTracesPaginatedArg, PaginationInfo, StoragePagination, PaginationArgs, StorageDomains, StorageResourceType } from '@mastra/core/storage';
6
+ import type { Trace } from '@mastra/core/telemetry';
7
+ import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
8
+ import type { CloudflareStoreConfig, RecordTypes } from './types.js';
9
+ export declare class CloudflareStore extends MastraStorage {
10
+ stores: StorageDomains;
11
+ private client?;
12
+ private accountId?;
13
+ private namespacePrefix;
14
+ private bindings?;
15
+ private validateWorkersConfig;
16
+ private validateRestConfig;
17
+ constructor(config: CloudflareStoreConfig);
18
+ createTable({ tableName, schema, }: {
19
+ tableName: TABLE_NAMES;
20
+ schema: Record<string, StorageColumn>;
21
+ }): Promise<void>;
22
+ alterTable(_args: {
23
+ tableName: TABLE_NAMES;
24
+ schema: Record<string, StorageColumn>;
25
+ ifNotExists: string[];
26
+ }): Promise<void>;
27
+ clearTable({ tableName }: {
28
+ tableName: TABLE_NAMES;
29
+ }): Promise<void>;
30
+ dropTable({ tableName }: {
31
+ tableName: TABLE_NAMES;
32
+ }): Promise<void>;
33
+ insert<T extends TABLE_NAMES>({ tableName, record, }: {
34
+ tableName: T;
35
+ record: Record<string, any>;
36
+ }): Promise<void>;
37
+ load<R>({ tableName, keys }: {
38
+ tableName: TABLE_NAMES;
39
+ keys: Record<string, string>;
40
+ }): Promise<R | null>;
41
+ getThreadById({ threadId }: {
42
+ threadId: string;
43
+ }): Promise<StorageThreadType | null>;
44
+ getThreadsByResourceId({ resourceId }: {
45
+ resourceId: string;
46
+ }): Promise<StorageThreadType[]>;
47
+ saveThread({ thread }: {
48
+ thread: StorageThreadType;
49
+ }): Promise<StorageThreadType>;
50
+ updateThread({ id, title, metadata, }: {
51
+ id: string;
52
+ title: string;
53
+ metadata: Record<string, unknown>;
54
+ }): Promise<StorageThreadType>;
55
+ deleteThread({ threadId }: {
56
+ threadId: string;
57
+ }): Promise<void>;
58
+ saveMessages(args: {
59
+ messages: MastraMessageV1[];
60
+ format?: undefined | 'v1';
61
+ }): Promise<MastraMessageV1[]>;
62
+ saveMessages(args: {
63
+ messages: MastraMessageV2[];
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, }: {
73
+ workflowName: string;
74
+ runId: string;
75
+ stepId: string;
76
+ result: StepResult<any, any, any, any>;
77
+ runtimeContext: Record<string, any>;
78
+ }): Promise<Record<string, StepResult<any, any, any, any>>>;
79
+ updateWorkflowState({ workflowName, runId, opts, }: {
80
+ workflowName: string;
81
+ runId: string;
82
+ opts: {
83
+ status: string;
84
+ result?: StepResult<any, any, any, any>;
85
+ error?: string;
86
+ suspendedPaths?: Record<string, number[]>;
87
+ waitingPaths?: Record<string, number[]>;
88
+ };
89
+ }): Promise<WorkflowRunState | undefined>;
90
+ getMessagesById({ messageIds, format }: {
91
+ messageIds: string[];
92
+ format: 'v1';
93
+ }): Promise<MastraMessageV1[]>;
94
+ getMessagesById({ messageIds, format }: {
95
+ messageIds: string[];
96
+ format?: 'v2';
97
+ }): Promise<MastraMessageV2[]>;
98
+ persistWorkflowSnapshot(params: {
99
+ workflowName: string;
100
+ runId: string;
101
+ snapshot: WorkflowRunState;
102
+ }): Promise<void>;
103
+ loadWorkflowSnapshot(params: {
104
+ workflowName: string;
105
+ runId: string;
106
+ }): Promise<WorkflowRunState | null>;
107
+ batchInsert<T extends TABLE_NAMES>(input: {
108
+ tableName: T;
109
+ records: Partial<RecordTypes[T]>[];
110
+ }): Promise<void>;
111
+ getTraces({ name, scope, page, perPage, attributes, fromDate, toDate, }: {
112
+ name?: string;
113
+ scope?: string;
114
+ page: number;
115
+ perPage: number;
116
+ attributes?: Record<string, string>;
117
+ fromDate?: Date;
118
+ toDate?: Date;
119
+ }): Promise<any[]>;
120
+ getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
121
+ getEvals(options: {
122
+ agentName?: string;
123
+ type?: 'test' | 'live';
124
+ dateRange?: {
125
+ start?: Date;
126
+ end?: Date;
127
+ };
128
+ } & PaginationArgs): Promise<PaginationInfo & {
129
+ evals: EvalRow[];
130
+ }>;
131
+ getWorkflowRuns({ workflowName, limit, offset, resourceId, fromDate, toDate, }?: {
132
+ workflowName?: string;
133
+ limit?: number;
134
+ offset?: number;
135
+ resourceId?: string;
136
+ fromDate?: Date;
137
+ toDate?: Date;
138
+ }): Promise<WorkflowRuns>;
139
+ getWorkflowRunById({ runId, workflowName, }: {
140
+ runId: string;
141
+ workflowName: string;
142
+ }): Promise<WorkflowRun | null>;
143
+ getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
144
+ traces: Trace[];
145
+ }>;
146
+ getThreadsByResourceIdPaginated(args: {
147
+ resourceId: string;
148
+ page: number;
149
+ perPage: number;
150
+ }): Promise<PaginationInfo & {
151
+ threads: StorageThreadType[];
152
+ }>;
153
+ getMessagesPaginated(args: StorageGetMessagesArg): Promise<PaginationInfo & {
154
+ messages: MastraMessageV1[] | MastraMessageV2[];
155
+ }>;
156
+ updateMessages(args: {
157
+ messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
158
+ id: string;
159
+ content?: {
160
+ metadata?: MastraMessageContentV2['metadata'];
161
+ content?: MastraMessageContentV2['content'];
162
+ };
163
+ }[];
164
+ }): Promise<MastraMessageV2[]>;
165
+ getScoreById({ id }: {
166
+ id: string;
167
+ }): Promise<ScoreRowData | null>;
168
+ saveScore(score: ScoreRowData): Promise<{
169
+ score: ScoreRowData;
170
+ }>;
171
+ getScoresByRunId({ runId, pagination, }: {
172
+ runId: string;
173
+ pagination: StoragePagination;
174
+ }): Promise<{
175
+ pagination: PaginationInfo;
176
+ scores: ScoreRowData[];
177
+ }>;
178
+ getScoresByEntityId({ entityId, entityType, pagination, }: {
179
+ pagination: StoragePagination;
180
+ entityId: string;
181
+ entityType: string;
182
+ }): Promise<{
183
+ pagination: PaginationInfo;
184
+ scores: ScoreRowData[];
185
+ }>;
186
+ getScoresByScorerId({ scorerId, entityId, entityType, source, pagination, }: {
187
+ scorerId: string;
188
+ entityId?: string;
189
+ entityType?: string;
190
+ source?: ScoringSource;
191
+ pagination: StoragePagination;
192
+ }): Promise<{
193
+ pagination: PaginationInfo;
194
+ scores: ScoreRowData[];
195
+ }>;
196
+ getResourceById({ resourceId }: {
197
+ resourceId: string;
198
+ }): Promise<StorageResourceType | null>;
199
+ saveResource({ resource }: {
200
+ resource: StorageResourceType;
201
+ }): Promise<StorageResourceType>;
202
+ updateResource({ resourceId, workingMemory, metadata, }: {
203
+ resourceId: string;
204
+ workingMemory?: string;
205
+ metadata?: Record<string, unknown>;
206
+ }): Promise<StorageResourceType>;
207
+ close(): Promise<void>;
208
+ }
209
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,C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,EACxB,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;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAI7D,mBAAmB,CAAC,EACxB,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;QAAE,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"}
@@ -0,0 +1,25 @@
1
+ import type { WorkflowRunState } from '@mastra/core/workflows';
2
+ export declare const createSampleTrace: (name: string, scope?: string, attributes?: Record<string, string>) => {
3
+ id: string;
4
+ parentSpanId: string;
5
+ traceId: string;
6
+ name: string;
7
+ scope: string | undefined;
8
+ kind: string;
9
+ status: string;
10
+ events: string;
11
+ links: string;
12
+ attributes: string | undefined;
13
+ startTime: string;
14
+ endTime: string;
15
+ other: string;
16
+ createdAt: string;
17
+ };
18
+ export declare const createSampleWorkflowSnapshot: (threadId: string, status: string, createdAt?: Date) => {
19
+ snapshot: WorkflowRunState;
20
+ runId: string;
21
+ stepId: string;
22
+ };
23
+ export declare const retryUntil: <T>(fn: () => Promise<T>, condition: (result: T) => boolean, timeout?: number, // REST API needs longer timeout due to higher latency
24
+ interval?: number) => Promise<T>;
25
+ //# sourceMappingURL=test-utils.d.ts.map
@@ -0,0 +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;;;;CA0B9F,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"}
@@ -0,0 +1,67 @@
1
+ import type { KVNamespace } from '@cloudflare/workers-types';
2
+ import type { StorageThreadType, MastraMessageV2 } from '@mastra/core/memory';
3
+ import type { ScoreRowData } from '@mastra/core/scores';
4
+ import type { TABLE_MESSAGES, TABLE_THREADS, TABLE_WORKFLOW_SNAPSHOT, TABLE_EVALS, TABLE_TRACES, TABLE_RESOURCES, TABLE_NAMES, EvalRow, StorageResourceType, TABLE_SCORERS, TABLE_AI_SPANS, AISpanRecord } from '@mastra/core/storage';
5
+ import type { WorkflowRunState } from '@mastra/core/workflows';
6
+ /**
7
+ * Configuration for Cloudflare KV using REST API
8
+ */
9
+ export interface CloudflareRestConfig {
10
+ /** Cloudflare account ID */
11
+ accountId: string;
12
+ /** Cloudflare API token with KV access */
13
+ apiToken: string;
14
+ /**
15
+ * Prefix for KV namespace names.
16
+ * Recommended for production use to ensure data isolation between different instances.
17
+ * If not provided, no prefix will be used
18
+ */
19
+ namespacePrefix?: string;
20
+ }
21
+ /**
22
+ * Configuration for Cloudflare KV using Workers Binding API
23
+ */
24
+ export interface CloudflareWorkersConfig {
25
+ /** KV namespace bindings from Workers environment */
26
+ bindings: {
27
+ [key in TABLE_NAMES]: KVNamespace;
28
+ };
29
+ /** Optional prefix for keys within namespaces */
30
+ keyPrefix?: string;
31
+ }
32
+ /**
33
+ * Combined configuration type supporting both REST API and Workers Binding API
34
+ */
35
+ export type CloudflareStoreConfig = CloudflareRestConfig | CloudflareWorkersConfig;
36
+ /**
37
+ * Interface for KV operations with type support
38
+ */
39
+ export interface KVOperation {
40
+ /** Table/namespace to operate on */
41
+ tableName: TABLE_NAMES;
42
+ /** Key to read/write */
43
+ key: string;
44
+ /** Value to write (for put operations) */
45
+ value?: any;
46
+ /** Optional metadata to associate with the value */
47
+ metadata?: any;
48
+ }
49
+ /**
50
+ * Helper to determine if a config is using Workers bindings
51
+ */
52
+ export declare function isWorkersConfig(config: CloudflareStoreConfig): config is CloudflareWorkersConfig;
53
+ export type RecordTypes = {
54
+ [TABLE_THREADS]: StorageThreadType;
55
+ [TABLE_MESSAGES]: MastraMessageV2;
56
+ [TABLE_WORKFLOW_SNAPSHOT]: WorkflowRunState;
57
+ [TABLE_EVALS]: EvalRow;
58
+ [TABLE_SCORERS]: ScoreRowData;
59
+ [TABLE_TRACES]: any;
60
+ [TABLE_RESOURCES]: StorageResourceType;
61
+ [TABLE_AI_SPANS]: AISpanRecord;
62
+ };
63
+ export type ListOptions = {
64
+ limit?: number;
65
+ prefix?: string;
66
+ };
67
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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,iBAAiB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,uBAAuB,EACvB,WAAW,EACX,YAAY,EACZ,eAAe,EACf,WAAW,EACX,OAAO,EACP,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,YAAY,EACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,qDAAqD;IACrD,QAAQ,EAAE;SACP,GAAG,IAAI,WAAW,GAAG,WAAW;KAClC,CAAC;IACF,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,oBAAoB,GAAG,uBAAuB,CAAC;AAEnF;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,oCAAoC;IACpC,SAAS,EAAE,WAAW,CAAC;IACvB,wBAAwB;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,0CAA0C;IAC1C,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,oDAAoD;IACpD,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,qBAAqB,GAAG,MAAM,IAAI,uBAAuB,CAEhG;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,CAAC,aAAa,CAAC,EAAE,iBAAiB,CAAC;IACnC,CAAC,cAAc,CAAC,EAAE,eAAe,CAAC;IAClC,CAAC,uBAAuB,CAAC,EAAE,gBAAgB,CAAC;IAC5C,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IACvB,CAAC,aAAa,CAAC,EAAE,YAAY,CAAC;IAC9B,CAAC,YAAY,CAAC,EAAE,GAAG,CAAC;IACpB,CAAC,eAAe,CAAC,EAAE,mBAAmB,CAAC;IACvC,CAAC,cAAc,CAAC,EAAE,YAAY,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/cloudflare",
3
- "version": "0.0.0-vector-sources-20250516175436",
3
+ "version": "0.0.0-vector-query-tool-provider-options-20250828222356",
4
4
  "description": "Cloudflare provider for Mastra - includes db storage capabilities",
5
5
  "type": "module",
6
6
  "files": [
@@ -15,7 +15,7 @@
15
15
  "default": "./dist/index.js"
16
16
  },
17
17
  "require": {
18
- "types": "./dist/index.d.cts",
18
+ "types": "./dist/index.d.ts",
19
19
  "default": "./dist/index.cjs"
20
20
  }
21
21
  },
@@ -23,24 +23,29 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
- "cloudflare": "^4.1.0",
27
- "@mastra/core": "0.0.0-vector-sources-20250516175436"
26
+ "cloudflare": "^4.5.0"
28
27
  },
29
28
  "devDependencies": {
30
- "@cloudflare/workers-types": "^4.20250313.0",
31
- "@microsoft/api-extractor": "^7.52.5",
32
- "@types/node": "^20.17.27",
33
- "dotenv": "^16.4.7",
34
- "eslint": "^9.23.0",
35
- "miniflare": "^4.20250310.0",
36
- "tsup": "^8.4.0",
37
- "typescript": "^5.8.2",
38
- "vitest": "^3.1.2",
39
- "@internal/lint": "0.0.0-vector-sources-20250516175436"
29
+ "@cloudflare/workers-types": "^4.20250823.0",
30
+ "@microsoft/api-extractor": "^7.52.8",
31
+ "@types/node": "^20.19.0",
32
+ "dotenv": "^17.0.0",
33
+ "eslint": "^9.30.1",
34
+ "miniflare": "^4.20250816.1",
35
+ "tsup": "^8.5.0",
36
+ "typescript": "^5.8.3",
37
+ "vitest": "^3.2.4",
38
+ "@internal/lint": "0.0.0-vector-query-tool-provider-options-20250828222356",
39
+ "@internal/storage-test-utils": "0.0.30",
40
+ "@internal/types-builder": "0.0.0-vector-query-tool-provider-options-20250828222356",
41
+ "@mastra/core": "0.0.0-vector-query-tool-provider-options-20250828222356"
42
+ },
43
+ "peerDependencies": {
44
+ "@mastra/core": "0.0.0-vector-query-tool-provider-options-20250828222356"
40
45
  },
41
46
  "scripts": {
42
- "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
43
- "build:watch": "pnpm build --watch",
47
+ "build": "tsup --silent --config tsup.config.ts",
48
+ "build:watch": "tsup --watch --silent --config tsup.config.ts",
44
49
  "test": "vitest run",
45
50
  "lint": "eslint ."
46
51
  }