@mastra/cloudflare 0.11.4 → 0.11.5-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/storage/domains/legacy-evals/index.d.ts +21 -0
- package/dist/storage/domains/legacy-evals/index.d.ts.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +98 -0
- package/dist/storage/domains/memory/index.d.ts.map +1 -0
- package/dist/storage/domains/operations/index.d.ts +83 -0
- package/dist/storage/domains/operations/index.d.ts.map +1 -0
- package/dist/storage/domains/scores/index.d.ts +39 -0
- package/dist/storage/domains/scores/index.d.ts.map +1 -0
- package/dist/storage/domains/traces/index.d.ts +18 -0
- package/dist/storage/domains/traces/index.d.ts.map +1 -0
- package/dist/storage/domains/workflows/index.d.ts +35 -0
- package/dist/storage/domains/workflows/index.d.ts.map +1 -0
- package/dist/storage/index.d.ts +180 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/test-utils.d.ts +25 -0
- package/dist/storage/test-utils.d.ts.map +1 -0
- package/dist/storage/types.d.ts +66 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/package.json +10 -9
- package/dist/_tsup-dts-rollup.d.cts +0 -583
- package/dist/_tsup-dts-rollup.d.ts +0 -583
- package/dist/index.d.cts +0 -1
|
@@ -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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C,IAAI,CAAC;IA0BX,iBAAiB,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,WAAW;YAsCvD,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"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ScoreRowData } 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, pagination, }: {
|
|
17
|
+
scorerId: string;
|
|
18
|
+
pagination: StoragePagination;
|
|
19
|
+
}): Promise<{
|
|
20
|
+
pagination: PaginationInfo;
|
|
21
|
+
scores: ScoreRowData[];
|
|
22
|
+
}>;
|
|
23
|
+
getScoresByRunId({ runId, pagination, }: {
|
|
24
|
+
runId: string;
|
|
25
|
+
pagination: StoragePagination;
|
|
26
|
+
}): Promise<{
|
|
27
|
+
pagination: PaginationInfo;
|
|
28
|
+
scores: ScoreRowData[];
|
|
29
|
+
}>;
|
|
30
|
+
getScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
31
|
+
pagination: StoragePagination;
|
|
32
|
+
entityId: string;
|
|
33
|
+
entityType: string;
|
|
34
|
+
}): Promise<{
|
|
35
|
+
pagination: PaginationInfo;
|
|
36
|
+
scores: ScoreRowData[];
|
|
37
|
+
}>;
|
|
38
|
+
}
|
|
39
|
+
//# 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,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAiB,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAkB/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,IAAI,CAAC;IAuBlE,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,WAAW,GAAG,WAAW,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,YAAY,CAAA;KAAE,CAAC;IA8CjG,mBAAmB,CAAC,EACxB,QAAQ,EACR,UAAU,GACX,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAiD7D,gBAAgB,CAAC,EACrB,KAAK,EACL,UAAU,GACX,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAiD7D,mBAAmB,CAAC,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;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,35 @@
|
|
|
1
|
+
import { WorkflowsStorage } from '@mastra/core/storage';
|
|
2
|
+
import type { WorkflowRun, WorkflowRuns } from '@mastra/core/storage';
|
|
3
|
+
import type { 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
|
+
persistWorkflowSnapshot(params: {
|
|
12
|
+
workflowName: string;
|
|
13
|
+
runId: string;
|
|
14
|
+
snapshot: WorkflowRunState;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
loadWorkflowSnapshot(params: {
|
|
17
|
+
workflowName: string;
|
|
18
|
+
runId: string;
|
|
19
|
+
}): Promise<WorkflowRunState | null>;
|
|
20
|
+
private parseWorkflowRun;
|
|
21
|
+
private buildWorkflowSnapshotPrefix;
|
|
22
|
+
getWorkflowRuns({ workflowName, limit, offset, resourceId, fromDate, toDate, }?: {
|
|
23
|
+
workflowName?: string;
|
|
24
|
+
limit?: number;
|
|
25
|
+
offset?: number;
|
|
26
|
+
resourceId?: string;
|
|
27
|
+
fromDate?: Date;
|
|
28
|
+
toDate?: Date;
|
|
29
|
+
}): Promise<WorkflowRuns>;
|
|
30
|
+
getWorkflowRunById({ runId, workflowName, }: {
|
|
31
|
+
runId: string;
|
|
32
|
+
workflowName: string;
|
|
33
|
+
}): Promise<WorkflowRun | null>;
|
|
34
|
+
}
|
|
35
|
+
//# 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,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,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;IAOxB,uBAAuB,CAAC,MAAM,EAAE;QACpC,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,gBAAgB,CAAC;KAC5B,GAAG,OAAO,CAAC,IAAI,CAAC;IAgCX,oBAAoB,CAAC,MAAM,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAgC7G,OAAO,CAAC,gBAAgB;IAqBxB,OAAO,CAAC,2BAA2B;IAmB7B,eAAe,CAAC,EACpB,YAAY,EACZ,KAAU,EACV,MAAU,EACV,UAAU,EACV,QAAQ,EACR,MAAM,GACP,GAAE;QACD,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,IAAI,CAAC;QAChB,MAAM,CAAC,EAAE,IAAI,CAAC;KACV,GAAG,OAAO,CAAC,YAAY,CAAC;IAsExB,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;CA4ChC"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
2
|
+
import type { StorageThreadType, MastraMessageV1, MastraMessageV2 } from '@mastra/core/memory';
|
|
3
|
+
import type { ScoreRowData } 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 { 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
|
+
persistWorkflowSnapshot(params: {
|
|
73
|
+
workflowName: string;
|
|
74
|
+
runId: string;
|
|
75
|
+
snapshot: WorkflowRunState;
|
|
76
|
+
}): Promise<void>;
|
|
77
|
+
loadWorkflowSnapshot(params: {
|
|
78
|
+
workflowName: string;
|
|
79
|
+
runId: string;
|
|
80
|
+
}): Promise<WorkflowRunState | null>;
|
|
81
|
+
batchInsert<T extends TABLE_NAMES>(input: {
|
|
82
|
+
tableName: T;
|
|
83
|
+
records: Partial<RecordTypes[T]>[];
|
|
84
|
+
}): Promise<void>;
|
|
85
|
+
getTraces({ name, scope, page, perPage, attributes, fromDate, toDate, }: {
|
|
86
|
+
name?: string;
|
|
87
|
+
scope?: string;
|
|
88
|
+
page: number;
|
|
89
|
+
perPage: number;
|
|
90
|
+
attributes?: Record<string, string>;
|
|
91
|
+
fromDate?: Date;
|
|
92
|
+
toDate?: Date;
|
|
93
|
+
}): Promise<any[]>;
|
|
94
|
+
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
95
|
+
getEvals(options: {
|
|
96
|
+
agentName?: string;
|
|
97
|
+
type?: 'test' | 'live';
|
|
98
|
+
dateRange?: {
|
|
99
|
+
start?: Date;
|
|
100
|
+
end?: Date;
|
|
101
|
+
};
|
|
102
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
103
|
+
evals: EvalRow[];
|
|
104
|
+
}>;
|
|
105
|
+
getWorkflowRuns({ workflowName, limit, offset, resourceId, fromDate, toDate, }?: {
|
|
106
|
+
workflowName?: string;
|
|
107
|
+
limit?: number;
|
|
108
|
+
offset?: number;
|
|
109
|
+
resourceId?: string;
|
|
110
|
+
fromDate?: Date;
|
|
111
|
+
toDate?: Date;
|
|
112
|
+
}): Promise<WorkflowRuns>;
|
|
113
|
+
getWorkflowRunById({ runId, workflowName, }: {
|
|
114
|
+
runId: string;
|
|
115
|
+
workflowName: string;
|
|
116
|
+
}): Promise<WorkflowRun | null>;
|
|
117
|
+
getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
|
|
118
|
+
traces: Trace[];
|
|
119
|
+
}>;
|
|
120
|
+
getThreadsByResourceIdPaginated(args: {
|
|
121
|
+
resourceId: string;
|
|
122
|
+
page: number;
|
|
123
|
+
perPage: number;
|
|
124
|
+
}): Promise<PaginationInfo & {
|
|
125
|
+
threads: StorageThreadType[];
|
|
126
|
+
}>;
|
|
127
|
+
getMessagesPaginated(args: StorageGetMessagesArg): Promise<PaginationInfo & {
|
|
128
|
+
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
129
|
+
}>;
|
|
130
|
+
updateMessages(args: {
|
|
131
|
+
messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
132
|
+
id: string;
|
|
133
|
+
content?: {
|
|
134
|
+
metadata?: MastraMessageContentV2['metadata'];
|
|
135
|
+
content?: MastraMessageContentV2['content'];
|
|
136
|
+
};
|
|
137
|
+
}[];
|
|
138
|
+
}): Promise<MastraMessageV2[]>;
|
|
139
|
+
getScoreById({ id }: {
|
|
140
|
+
id: string;
|
|
141
|
+
}): Promise<ScoreRowData | null>;
|
|
142
|
+
saveScore(score: ScoreRowData): Promise<{
|
|
143
|
+
score: ScoreRowData;
|
|
144
|
+
}>;
|
|
145
|
+
getScoresByRunId({ runId, pagination, }: {
|
|
146
|
+
runId: string;
|
|
147
|
+
pagination: StoragePagination;
|
|
148
|
+
}): Promise<{
|
|
149
|
+
pagination: PaginationInfo;
|
|
150
|
+
scores: ScoreRowData[];
|
|
151
|
+
}>;
|
|
152
|
+
getScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
153
|
+
pagination: StoragePagination;
|
|
154
|
+
entityId: string;
|
|
155
|
+
entityType: string;
|
|
156
|
+
}): Promise<{
|
|
157
|
+
pagination: PaginationInfo;
|
|
158
|
+
scores: ScoreRowData[];
|
|
159
|
+
}>;
|
|
160
|
+
getScoresByScorerId({ scorerId, pagination, }: {
|
|
161
|
+
scorerId: string;
|
|
162
|
+
pagination: StoragePagination;
|
|
163
|
+
}): Promise<{
|
|
164
|
+
pagination: PaginationInfo;
|
|
165
|
+
scores: ScoreRowData[];
|
|
166
|
+
}>;
|
|
167
|
+
getResourceById({ resourceId }: {
|
|
168
|
+
resourceId: string;
|
|
169
|
+
}): Promise<StorageResourceType | null>;
|
|
170
|
+
saveResource({ resource }: {
|
|
171
|
+
resource: StorageResourceType;
|
|
172
|
+
}): Promise<StorageResourceType>;
|
|
173
|
+
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
174
|
+
resourceId: string;
|
|
175
|
+
workingMemory?: string;
|
|
176
|
+
metadata?: Record<string, unknown>;
|
|
177
|
+
}): Promise<StorageResourceType>;
|
|
178
|
+
close(): Promise<void>;
|
|
179
|
+
}
|
|
180
|
+
//# 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;AAEj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CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAI7D,mBAAmB,CAAC,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,UAAU,GACX,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,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';
|
|
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,cAAc,CAAC;AAErD,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;;;;CAyB9F,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,66 @@
|
|
|
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 } 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
|
+
};
|
|
62
|
+
export type ListOptions = {
|
|
63
|
+
limit?: number;
|
|
64
|
+
prefix?: string;
|
|
65
|
+
};
|
|
66
|
+
//# 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,EACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/cloudflare",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.5-alpha.0",
|
|
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.
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
19
|
"default": "./dist/index.cjs"
|
|
20
20
|
}
|
|
21
21
|
},
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"cloudflare": "^4.5.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@cloudflare/workers-types": "^4.
|
|
29
|
+
"@cloudflare/workers-types": "^4.20250801.0",
|
|
30
30
|
"@microsoft/api-extractor": "^7.52.8",
|
|
31
31
|
"@types/node": "^20.19.0",
|
|
32
32
|
"dotenv": "^17.0.0",
|
|
@@ -35,16 +35,17 @@
|
|
|
35
35
|
"tsup": "^8.5.0",
|
|
36
36
|
"typescript": "^5.8.3",
|
|
37
37
|
"vitest": "^3.2.4",
|
|
38
|
-
"@internal/storage-test-utils": "0.0.
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
38
|
+
"@internal/storage-test-utils": "0.0.22",
|
|
39
|
+
"@internal/lint": "0.0.26",
|
|
40
|
+
"@mastra/core": "0.13.0-alpha.2",
|
|
41
|
+
"@internal/types-builder": "0.0.1"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|
|
43
|
-
"@mastra/core": ">=0.
|
|
44
|
+
"@mastra/core": ">=0.13.0-0 <0.14.0-0"
|
|
44
45
|
},
|
|
45
46
|
"scripts": {
|
|
46
|
-
"build": "tsup
|
|
47
|
-
"build:watch": "
|
|
47
|
+
"build": "tsup --silent --config tsup.config.ts",
|
|
48
|
+
"build:watch": "tsup --watch --silent --config tsup.config.ts",
|
|
48
49
|
"test": "vitest run",
|
|
49
50
|
"lint": "eslint ."
|
|
50
51
|
}
|