@mastra/convex 0.0.0-bundle-studio-cloud-20251222034739
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 +353 -0
- package/LICENSE.md +15 -0
- package/README.md +123 -0
- package/dist/chunk-BKVR7SL7.cjs +304 -0
- package/dist/chunk-BKVR7SL7.cjs.map +1 -0
- package/dist/chunk-KSAPIIEJ.js +302 -0
- package/dist/chunk-KSAPIIEJ.js.map +1 -0
- package/dist/chunk-PKUUSREO.js +76 -0
- package/dist/chunk-PKUUSREO.js.map +1 -0
- package/dist/chunk-ZBUP3DS6.cjs +93 -0
- package/dist/chunk-ZBUP3DS6.cjs.map +1 -0
- package/dist/index.cjs +1365 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1302 -0
- package/dist/index.js.map +1 -0
- package/dist/schema.cjs +72 -0
- package/dist/schema.cjs.map +1 -0
- package/dist/schema.d.ts +151 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +3 -0
- package/dist/schema.js.map +1 -0
- package/dist/server/index.cjs +65 -0
- package/dist/server/index.cjs.map +1 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +4 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/schema.d.ts +115 -0
- package/dist/server/schema.d.ts.map +1 -0
- package/dist/server/storage.d.ts +7 -0
- package/dist/server/storage.d.ts.map +1 -0
- package/dist/storage/client.d.ts +24 -0
- package/dist/storage/client.d.ts.map +1 -0
- package/dist/storage/db/index.d.ts +57 -0
- package/dist/storage/db/index.d.ts.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +61 -0
- package/dist/storage/domains/memory/index.d.ts.map +1 -0
- package/dist/storage/domains/scores/index.d.ts +44 -0
- package/dist/storage/domains/scores/index.d.ts.map +1 -0
- package/dist/storage/domains/workflows/index.d.ts +44 -0
- package/dist/storage/domains/workflows/index.d.ts.map +1 -0
- package/dist/storage/index.d.ts +178 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/types.d.ts +42 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/vector/index.d.ts +35 -0
- package/dist/vector/index.d.ts.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { TABLE_WORKFLOW_SNAPSHOT, TABLE_MESSAGES, TABLE_THREADS, TABLE_RESOURCES, TABLE_SCORERS } from '@mastra/core/storage';
|
|
2
|
+
/**
|
|
3
|
+
* Threads table - stores conversation threads
|
|
4
|
+
* Schema: TABLE_SCHEMAS[TABLE_THREADS]
|
|
5
|
+
*/
|
|
6
|
+
export declare const mastraThreadsTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
7
|
+
[x: string]: any;
|
|
8
|
+
}, Record<string, any>, "required", string>, {
|
|
9
|
+
by_record_id: ["id", "_creationTime"];
|
|
10
|
+
by_resource: ["resourceId", "_creationTime"];
|
|
11
|
+
by_created: ["createdAt", "_creationTime"];
|
|
12
|
+
by_updated: ["updatedAt", "_creationTime"];
|
|
13
|
+
}, {}, {}>;
|
|
14
|
+
/**
|
|
15
|
+
* Messages table - stores conversation messages
|
|
16
|
+
* Schema: TABLE_SCHEMAS[TABLE_MESSAGES]
|
|
17
|
+
*/
|
|
18
|
+
export declare const mastraMessagesTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
19
|
+
[x: string]: any;
|
|
20
|
+
}, Record<string, any>, "required", string>, {
|
|
21
|
+
by_record_id: ["id", "_creationTime"];
|
|
22
|
+
by_thread: ["thread_id", "_creationTime"];
|
|
23
|
+
by_thread_created: ["thread_id", "createdAt", "_creationTime"];
|
|
24
|
+
by_resource: ["resourceId", "_creationTime"];
|
|
25
|
+
}, {}, {}>;
|
|
26
|
+
/**
|
|
27
|
+
* Resources table - stores resource/user working memory
|
|
28
|
+
* Schema: TABLE_SCHEMAS[TABLE_RESOURCES]
|
|
29
|
+
*/
|
|
30
|
+
export declare const mastraResourcesTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
31
|
+
[x: string]: any;
|
|
32
|
+
}, Record<string, any>, "required", string>, {
|
|
33
|
+
by_record_id: ["id", "_creationTime"];
|
|
34
|
+
by_updated: ["updatedAt", "_creationTime"];
|
|
35
|
+
}, {}, {}>;
|
|
36
|
+
/**
|
|
37
|
+
* Workflow snapshots table - stores workflow execution state
|
|
38
|
+
* Schema: TABLE_SCHEMAS[TABLE_WORKFLOW_SNAPSHOT]
|
|
39
|
+
*/
|
|
40
|
+
export declare const mastraWorkflowSnapshotsTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
41
|
+
[x: string]: any;
|
|
42
|
+
}, Record<string, any>, "required", string>, {
|
|
43
|
+
by_record_id: ["id", "_creationTime"];
|
|
44
|
+
by_workflow_run: ["workflow_name", "run_id", "_creationTime"];
|
|
45
|
+
by_workflow: ["workflow_name", "_creationTime"];
|
|
46
|
+
by_resource: ["resourceId", "_creationTime"];
|
|
47
|
+
by_created: ["createdAt", "_creationTime"];
|
|
48
|
+
}, {}, {}>;
|
|
49
|
+
/**
|
|
50
|
+
* Scores table - stores evaluation scores
|
|
51
|
+
* Schema: TABLE_SCHEMAS[TABLE_SCORERS]
|
|
52
|
+
*/
|
|
53
|
+
export declare const mastraScoresTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
54
|
+
[x: string]: any;
|
|
55
|
+
}, Record<string, any>, "required", string>, {
|
|
56
|
+
by_record_id: ["id", "_creationTime"];
|
|
57
|
+
by_scorer: ["scorerId", "_creationTime"];
|
|
58
|
+
by_entity: ["entityId", "entityType", "_creationTime"];
|
|
59
|
+
by_run: ["runId", "_creationTime"];
|
|
60
|
+
by_created: ["createdAt", "_creationTime"];
|
|
61
|
+
}, {}, {}>;
|
|
62
|
+
/**
|
|
63
|
+
* Vector indexes table - stores metadata about vector indexes
|
|
64
|
+
*/
|
|
65
|
+
export declare const mastraVectorIndexesTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
66
|
+
id: string;
|
|
67
|
+
createdAt: string;
|
|
68
|
+
indexName: string;
|
|
69
|
+
dimension: number;
|
|
70
|
+
metric: string;
|
|
71
|
+
}, {
|
|
72
|
+
id: import("convex/values").VString<string, "required">;
|
|
73
|
+
indexName: import("convex/values").VString<string, "required">;
|
|
74
|
+
dimension: import("convex/values").VFloat64<number, "required">;
|
|
75
|
+
metric: import("convex/values").VString<string, "required">;
|
|
76
|
+
createdAt: import("convex/values").VString<string, "required">;
|
|
77
|
+
}, "required", "id" | "createdAt" | "indexName" | "dimension" | "metric">, {
|
|
78
|
+
by_record_id: ["id", "_creationTime"];
|
|
79
|
+
by_name: ["indexName", "_creationTime"];
|
|
80
|
+
}, {}, {}>;
|
|
81
|
+
/**
|
|
82
|
+
* Vectors table - stores vector embeddings
|
|
83
|
+
* Uses indexName field to support multiple indexes with different dimensions
|
|
84
|
+
*/
|
|
85
|
+
export declare const mastraVectorsTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
86
|
+
metadata?: any;
|
|
87
|
+
id: string;
|
|
88
|
+
indexName: string;
|
|
89
|
+
embedding: number[];
|
|
90
|
+
}, {
|
|
91
|
+
id: import("convex/values").VString<string, "required">;
|
|
92
|
+
indexName: import("convex/values").VString<string, "required">;
|
|
93
|
+
embedding: import("convex/values").VArray<number[], import("convex/values").VFloat64<number, "required">, "required">;
|
|
94
|
+
metadata: import("convex/values").VAny<any, "optional", string>;
|
|
95
|
+
}, "required", "id" | "metadata" | "indexName" | "embedding" | `metadata.${string}`>, {
|
|
96
|
+
by_index_id: ["indexName", "id", "_creationTime"];
|
|
97
|
+
by_index: ["indexName", "_creationTime"];
|
|
98
|
+
}, {}, {}>;
|
|
99
|
+
/**
|
|
100
|
+
* Generic documents table - fallback for unknown table types
|
|
101
|
+
*/
|
|
102
|
+
export declare const mastraDocumentsTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
103
|
+
record: any;
|
|
104
|
+
table: string;
|
|
105
|
+
primaryKey: string;
|
|
106
|
+
}, {
|
|
107
|
+
table: import("convex/values").VString<string, "required">;
|
|
108
|
+
primaryKey: import("convex/values").VString<string, "required">;
|
|
109
|
+
record: import("convex/values").VAny<any, "required", string>;
|
|
110
|
+
}, "required", "record" | "table" | "primaryKey" | `record.${string}`>, {
|
|
111
|
+
by_table: ["table", "_creationTime"];
|
|
112
|
+
by_table_primary: ["table", "primaryKey", "_creationTime"];
|
|
113
|
+
}, {}, {}>;
|
|
114
|
+
export { TABLE_WORKFLOW_SNAPSHOT, TABLE_MESSAGES, TABLE_THREADS, TABLE_RESOURCES, TABLE_SCORERS };
|
|
115
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/server/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,aAAa,EACb,eAAe,EACf,aAAa,EAEd,MAAM,sBAAsB,CAAC;AAkD9B;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;UAIM,CAAC;AAEtC;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;UAIO,CAAC;AAExC;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;UAEI,CAAC;AAEtC;;;GAGG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;UAKJ,CAAC;AAEtC;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;UAKO,CAAC;AAMtC;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;UAQH,CAAC;AAEnC;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;UAOI,CAAC;AAMpC;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;UAMoB,CAAC;AAMtD,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { StorageRequest, StorageResponse } from '../storage/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Main storage mutation handler.
|
|
4
|
+
* Routes operations to the appropriate typed table.
|
|
5
|
+
*/
|
|
6
|
+
export declare const mastraStorage: import("convex/server").RegisteredMutation<"public", StorageRequest, Promise<StorageResponse>>;
|
|
7
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/server/storage.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAkCxE;;;GAGG;AACH,eAAO,MAAM,aAAa,gGAuBxB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { StorageRequest } from './types.js';
|
|
2
|
+
export type ConvexAdminClientConfig = {
|
|
3
|
+
deploymentUrl: string;
|
|
4
|
+
adminAuthToken: string;
|
|
5
|
+
storageFunction?: string;
|
|
6
|
+
};
|
|
7
|
+
/** Response from callStorageRaw that includes batch info */
|
|
8
|
+
export type RawStorageResult<T = any> = {
|
|
9
|
+
result: T;
|
|
10
|
+
hasMore?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare class ConvexAdminClient {
|
|
13
|
+
private readonly deploymentUrl;
|
|
14
|
+
private readonly adminAuthToken;
|
|
15
|
+
private readonly storageFunction;
|
|
16
|
+
constructor({ deploymentUrl, adminAuthToken, storageFunction }: ConvexAdminClientConfig);
|
|
17
|
+
/**
|
|
18
|
+
* Call storage and return the full response including hasMore flag.
|
|
19
|
+
* Use this for operations that may need multiple calls (e.g., clearTable).
|
|
20
|
+
*/
|
|
21
|
+
callStorageRaw<T = any>(request: StorageRequest): Promise<RawStorageResult<T>>;
|
|
22
|
+
callStorage<T = any>(request: StorageRequest): Promise<T>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/storage/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAmB,MAAM,SAAS,CAAC;AAE/D,MAAM,MAAM,uBAAuB,GAAG;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,4DAA4D;AAC5D,MAAM,MAAM,gBAAgB,CAAC,CAAC,GAAG,GAAG,IAAI;IACtC,MAAM,EAAE,CAAC,CAAC;IACV,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAIF,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;gBAE7B,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,EAAE,uBAAuB;IAcvF;;;OAGG;IACG,cAAc,CAAC,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAmD9E,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;CAIhE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { MastraBase } from '@mastra/core/base';
|
|
2
|
+
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
3
|
+
import { ConvexAdminClient } from '../client.js';
|
|
4
|
+
import type { EqualityFilter } from '../types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for standalone domain usage.
|
|
7
|
+
* Accepts either:
|
|
8
|
+
* 1. An existing ConvexAdminClient
|
|
9
|
+
* 2. Config to create a new client internally
|
|
10
|
+
*/
|
|
11
|
+
export type ConvexDomainConfig = ConvexDomainClientConfig | ConvexDomainRestConfig;
|
|
12
|
+
/**
|
|
13
|
+
* Pass an existing ConvexAdminClient
|
|
14
|
+
*/
|
|
15
|
+
export interface ConvexDomainClientConfig {
|
|
16
|
+
client: ConvexAdminClient;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Pass config to create a new ConvexAdminClient internally
|
|
20
|
+
*/
|
|
21
|
+
export interface ConvexDomainRestConfig {
|
|
22
|
+
deploymentUrl: string;
|
|
23
|
+
adminAuthToken: string;
|
|
24
|
+
storageFunction?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Resolves ConvexDomainConfig to a ConvexAdminClient.
|
|
28
|
+
* Handles creating a new client if config is provided.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveConvexConfig(config: ConvexDomainConfig): ConvexAdminClient;
|
|
31
|
+
export declare class ConvexDB extends MastraBase {
|
|
32
|
+
private readonly client;
|
|
33
|
+
constructor(client: ConvexAdminClient);
|
|
34
|
+
hasColumn(_table: string, _column: string): Promise<boolean>;
|
|
35
|
+
clearTable({ tableName }: {
|
|
36
|
+
tableName: TABLE_NAMES;
|
|
37
|
+
}): Promise<void>;
|
|
38
|
+
dropTable({ tableName }: {
|
|
39
|
+
tableName: TABLE_NAMES;
|
|
40
|
+
}): Promise<void>;
|
|
41
|
+
insert({ tableName, record }: {
|
|
42
|
+
tableName: TABLE_NAMES;
|
|
43
|
+
record: Record<string, any>;
|
|
44
|
+
}): Promise<void>;
|
|
45
|
+
batchInsert({ tableName, records }: {
|
|
46
|
+
tableName: TABLE_NAMES;
|
|
47
|
+
records: Record<string, any>[];
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
load<R>({ tableName, keys }: {
|
|
50
|
+
tableName: TABLE_NAMES;
|
|
51
|
+
keys: Record<string, any>;
|
|
52
|
+
}): Promise<R | null>;
|
|
53
|
+
queryTable<R>(tableName: TABLE_NAMES, filters?: EqualityFilter[]): Promise<R[]>;
|
|
54
|
+
deleteMany(tableName: TABLE_NAMES, ids: string[]): Promise<void>;
|
|
55
|
+
private normalizeRecord;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/db/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,wBAAwB,GAAG,sBAAsB,CAAC;AAEnF;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,iBAAiB,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,kBAAkB,GAAG,iBAAiB,CAQjF;AAED,qBAAa,QAAS,SAAQ,UAAU;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,iBAAiB;IAIhD,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI5D,UAAU,CAAC,EAAE,SAAS,EAAE,EAAE;QAAE,SAAS,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAapE,SAAS,CAAC,EAAE,SAAS,EAAE,EAAE;QAAE,SAAS,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAanE,MAAM,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE;QAAE,SAAS,EAAE,WAAW,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAQrG,WAAW,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;QAAE,SAAS,EAAE,WAAW,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAU9G,IAAI,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE;QAAE,SAAS,EAAE,WAAW,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAU/F,UAAU,CAAC,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAQ/E,UAAU,CAAC,SAAS,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAS7E,OAAO,CAAC,eAAe;CAqBxB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
2
|
+
import type { MastraDBMessage, StorageThreadType } from '@mastra/core/memory';
|
|
3
|
+
import { MemoryStorage } from '@mastra/core/storage';
|
|
4
|
+
import type { StorageListMessagesInput, StorageListMessagesOutput, StorageListThreadsByResourceIdInput, StorageListThreadsByResourceIdOutput, StorageResourceType } from '@mastra/core/storage';
|
|
5
|
+
import type { ConvexDomainConfig } from '../../db/index.js';
|
|
6
|
+
export declare class MemoryConvex extends MemoryStorage {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(config: ConvexDomainConfig);
|
|
9
|
+
init(): Promise<void>;
|
|
10
|
+
dangerouslyClearAll(): Promise<void>;
|
|
11
|
+
getThreadById({ threadId }: {
|
|
12
|
+
threadId: string;
|
|
13
|
+
}): Promise<StorageThreadType | null>;
|
|
14
|
+
saveThread({ thread }: {
|
|
15
|
+
thread: StorageThreadType;
|
|
16
|
+
}): Promise<StorageThreadType>;
|
|
17
|
+
updateThread({ id, title, metadata, }: {
|
|
18
|
+
id: string;
|
|
19
|
+
title: string;
|
|
20
|
+
metadata: Record<string, unknown>;
|
|
21
|
+
}): Promise<StorageThreadType>;
|
|
22
|
+
deleteThread({ threadId }: {
|
|
23
|
+
threadId: string;
|
|
24
|
+
}): Promise<void>;
|
|
25
|
+
listThreadsByResourceId(args: StorageListThreadsByResourceIdInput): Promise<StorageListThreadsByResourceIdOutput>;
|
|
26
|
+
listMessages(args: StorageListMessagesInput): Promise<StorageListMessagesOutput>;
|
|
27
|
+
listMessagesById({ messageIds }: {
|
|
28
|
+
messageIds: string[];
|
|
29
|
+
}): Promise<{
|
|
30
|
+
messages: MastraDBMessage[];
|
|
31
|
+
}>;
|
|
32
|
+
saveMessages({ messages }: {
|
|
33
|
+
messages: MastraDBMessage[];
|
|
34
|
+
}): Promise<{
|
|
35
|
+
messages: MastraDBMessage[];
|
|
36
|
+
}>;
|
|
37
|
+
updateMessages({ messages, }: {
|
|
38
|
+
messages: (Partial<Omit<MastraDBMessage, 'createdAt'>> & {
|
|
39
|
+
id: string;
|
|
40
|
+
content?: {
|
|
41
|
+
metadata?: MastraMessageContentV2['metadata'];
|
|
42
|
+
content?: MastraMessageContentV2['content'];
|
|
43
|
+
};
|
|
44
|
+
})[];
|
|
45
|
+
}): Promise<MastraDBMessage[]>;
|
|
46
|
+
deleteMessages(messageIds: string[]): Promise<void>;
|
|
47
|
+
saveResource({ resource }: {
|
|
48
|
+
resource: StorageResourceType;
|
|
49
|
+
}): Promise<StorageResourceType>;
|
|
50
|
+
getResourceById({ resourceId }: {
|
|
51
|
+
resourceId: string;
|
|
52
|
+
}): Promise<StorageResourceType | null>;
|
|
53
|
+
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
54
|
+
resourceId: string;
|
|
55
|
+
workingMemory?: string;
|
|
56
|
+
metadata?: Record<string, unknown>;
|
|
57
|
+
}): Promise<StorageResourceType>;
|
|
58
|
+
private parseStoredMessage;
|
|
59
|
+
private addContextMessages;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/memory/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EACL,aAAa,EAQd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EACzB,mCAAmC,EACnC,oCAAoC,EACpC,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAYnD,qBAAa,YAAa,SAAQ,aAAa;;gBAEjC,MAAM,EAAE,kBAAkB;IAMhC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAMpC,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAkBpF,UAAU,CAAC,EAAE,MAAM,EAAE,EAAE;QAAE,MAAM,EAAE,iBAAiB,CAAA;KAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAWjF,YAAY,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IAInD,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE;QAAE,QAAQ,EAAE,mBAAmB,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAiB3F,eAAe,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAiB5F,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;IA4BhC,OAAO,CAAC,kBAAkB;YAaZ,kBAAkB;CA0CjC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { SaveScorePayload, ScoreRowData, ScoringEntityType, ScoringSource } from '@mastra/core/evals';
|
|
2
|
+
import { ScoresStorage } from '@mastra/core/storage';
|
|
3
|
+
import type { PaginationInfo, StoragePagination } from '@mastra/core/storage';
|
|
4
|
+
import type { ConvexDomainConfig } from '../../db/index.js';
|
|
5
|
+
export declare class ScoresConvex extends ScoresStorage {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(config: ConvexDomainConfig);
|
|
8
|
+
init(): Promise<void>;
|
|
9
|
+
dangerouslyClearAll(): Promise<void>;
|
|
10
|
+
getScoreById({ id }: {
|
|
11
|
+
id: string;
|
|
12
|
+
}): Promise<ScoreRowData | null>;
|
|
13
|
+
saveScore(score: SaveScorePayload): Promise<{
|
|
14
|
+
score: ScoreRowData;
|
|
15
|
+
}>;
|
|
16
|
+
listScoresByScorerId({ scorerId, pagination, entityId, entityType, source, }: {
|
|
17
|
+
scorerId: string;
|
|
18
|
+
pagination: StoragePagination;
|
|
19
|
+
entityId?: string;
|
|
20
|
+
entityType?: ScoringEntityType;
|
|
21
|
+
source?: ScoringSource;
|
|
22
|
+
}): Promise<{
|
|
23
|
+
pagination: PaginationInfo;
|
|
24
|
+
scores: ScoreRowData[];
|
|
25
|
+
}>;
|
|
26
|
+
listScoresByRunId({ runId, pagination, }: {
|
|
27
|
+
runId: string;
|
|
28
|
+
pagination: StoragePagination;
|
|
29
|
+
}): Promise<{
|
|
30
|
+
pagination: PaginationInfo;
|
|
31
|
+
scores: ScoreRowData[];
|
|
32
|
+
}>;
|
|
33
|
+
listScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
34
|
+
entityId: string;
|
|
35
|
+
entityType: ScoringEntityType;
|
|
36
|
+
pagination: StoragePagination;
|
|
37
|
+
}): Promise<{
|
|
38
|
+
pagination: PaginationInfo;
|
|
39
|
+
scores: ScoreRowData[];
|
|
40
|
+
}>;
|
|
41
|
+
private listScores;
|
|
42
|
+
private deserialize;
|
|
43
|
+
}
|
|
44
|
+
//# 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":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC3G,OAAO,EAAiB,aAAa,EAAwB,MAAM,sBAAsB,CAAC;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAOnD,qBAAa,YAAa,SAAQ,aAAa;;gBAEjC,MAAM,EAAE,kBAAkB;IAMhC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIpC,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAQlE,SAAS,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,YAAY,CAAA;KAAE,CAAC;IAiBpE,oBAAoB,CAAC,EACzB,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,UAAU,EACV,MAAM,GACP,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,iBAAiB,CAAC;QAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,iBAAiB,CAAC;QAC/B,MAAM,CAAC,EAAE,aAAa,CAAC;KACxB,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAO7D,iBAAiB,CAAC,EACtB,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;IAO7D,oBAAoB,CAAC,EACzB,QAAQ,EACR,UAAU,EACV,UAAU,GACX,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,iBAAiB,CAAC;QAC9B,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;YAOrD,UAAU;IA4CxB,OAAO,CAAC,WAAW;CAOpB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { WorkflowsStorage } from '@mastra/core/storage';
|
|
2
|
+
import type { StorageListWorkflowRunsInput, WorkflowRun, WorkflowRuns, UpdateWorkflowStateOptions } from '@mastra/core/storage';
|
|
3
|
+
import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
|
|
4
|
+
import type { ConvexDomainConfig } from '../../db/index.js';
|
|
5
|
+
export declare class WorkflowsConvex extends WorkflowsStorage {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(config: ConvexDomainConfig);
|
|
8
|
+
init(): Promise<void>;
|
|
9
|
+
dangerouslyClearAll(): Promise<void>;
|
|
10
|
+
updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, }: {
|
|
11
|
+
workflowName: string;
|
|
12
|
+
runId: string;
|
|
13
|
+
stepId: string;
|
|
14
|
+
result: StepResult<any, any, any, any>;
|
|
15
|
+
requestContext: Record<string, any>;
|
|
16
|
+
}): Promise<Record<string, StepResult<any, any, any, any>>>;
|
|
17
|
+
updateWorkflowState({ workflowName, runId, opts, }: {
|
|
18
|
+
workflowName: string;
|
|
19
|
+
runId: string;
|
|
20
|
+
opts: UpdateWorkflowStateOptions;
|
|
21
|
+
}): Promise<WorkflowRunState | undefined>;
|
|
22
|
+
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, }: {
|
|
23
|
+
workflowName: string;
|
|
24
|
+
runId: string;
|
|
25
|
+
resourceId?: string;
|
|
26
|
+
snapshot: WorkflowRunState;
|
|
27
|
+
}): Promise<void>;
|
|
28
|
+
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
29
|
+
workflowName: string;
|
|
30
|
+
runId: string;
|
|
31
|
+
}): Promise<WorkflowRunState | null>;
|
|
32
|
+
listWorkflowRuns(args?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
|
|
33
|
+
getWorkflowRunById({ runId, workflowName, }: {
|
|
34
|
+
runId: string;
|
|
35
|
+
workflowName?: string;
|
|
36
|
+
}): Promise<WorkflowRun | null>;
|
|
37
|
+
deleteWorkflowRunById({ runId, workflowName }: {
|
|
38
|
+
runId: string;
|
|
39
|
+
workflowName: string;
|
|
40
|
+
}): Promise<void>;
|
|
41
|
+
private getRun;
|
|
42
|
+
private ensureSnapshot;
|
|
43
|
+
}
|
|
44
|
+
//# 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":"AAAA,OAAO,EAA6C,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnG,OAAO,KAAK,EACV,4BAA4B,EAE5B,WAAW,EACX,YAAY,EACZ,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAQnD,qBAAa,eAAgB,SAAQ,gBAAgB;;gBAEvC,MAAM,EAAE,kBAAkB;IAMhC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIpC,qBAAqB,CAAC,EAC1B,YAAY,EACZ,KAAK,EACL,MAAM,EACN,MAAM,EACN,cAAc,GACf,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,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAmBrD,mBAAmB,CAAC,EACxB,YAAY,EACZ,KAAK,EACL,IAAI,GACL,EAAE;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,0BAA0B,CAAC;KAClC,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAiBnC,uBAAuB,CAAC,EAC5B,YAAY,EACZ,KAAK,EACL,UAAU,EACV,QAAQ,GACT,EAAE;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,gBAAgB,CAAC;KAC5B,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBX,oBAAoB,CAAC,EACzB,YAAY,EACZ,KAAK,GACN,EAAE;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAU9B,gBAAgB,CAAC,IAAI,GAAE,4BAAiC,GAAG,OAAO,CAAC,YAAY,CAAC;IAqChF,kBAAkB,CAAC,EACvB,KAAK,EACL,YAAY,GACb,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAezB,qBAAqB,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;YAI9F,MAAM;IAOpB,OAAO,CAAC,cAAc;CAuBvB"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { SaveScorePayload, ScoreRowData, ScoringEntityType, ScoringSource } from '@mastra/core/evals';
|
|
2
|
+
import type { MastraDBMessage, StorageThreadType } from '@mastra/core/memory';
|
|
3
|
+
import type { StorageResourceType, PaginationInfo, StorageListMessagesInput, StorageListMessagesOutput, StorageListThreadsByResourceIdInput, StorageListThreadsByResourceIdOutput, StorageListWorkflowRunsInput, StoragePagination, WorkflowRun, WorkflowRuns, UpdateWorkflowStateOptions } from '@mastra/core/storage';
|
|
4
|
+
import { MastraStorage } from '@mastra/core/storage';
|
|
5
|
+
import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
|
|
6
|
+
import type { ConvexAdminClientConfig } from './client.js';
|
|
7
|
+
import { ConvexAdminClient } from './client.js';
|
|
8
|
+
/**
|
|
9
|
+
* Convex configuration type.
|
|
10
|
+
*
|
|
11
|
+
* Accepts either:
|
|
12
|
+
* - A pre-configured ConvexAdminClient: `{ id, client }`
|
|
13
|
+
* - Deployment config: `{ id, deploymentUrl, adminAuthToken, storageFunction? }`
|
|
14
|
+
*/
|
|
15
|
+
export type ConvexStoreConfig = {
|
|
16
|
+
id: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
/**
|
|
19
|
+
* When true, automatic initialization (table creation/migrations) is disabled.
|
|
20
|
+
* This is useful for CI/CD pipelines where you want to:
|
|
21
|
+
* 1. Run migrations explicitly during deployment (not at runtime)
|
|
22
|
+
* 2. Use different credentials for schema changes vs runtime operations
|
|
23
|
+
*
|
|
24
|
+
* When disableInit is true:
|
|
25
|
+
* - The storage will not automatically create/alter tables on first use
|
|
26
|
+
* - You must call `storage.init()` explicitly in your CI/CD scripts
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // In CI/CD script:
|
|
30
|
+
* const storage = new ConvexStore({ ...config, disableInit: false });
|
|
31
|
+
* await storage.init(); // Explicitly run migrations
|
|
32
|
+
*
|
|
33
|
+
* // In runtime application:
|
|
34
|
+
* const storage = new ConvexStore({ ...config, disableInit: true });
|
|
35
|
+
* // No auto-init, tables must already exist
|
|
36
|
+
*/
|
|
37
|
+
disableInit?: boolean;
|
|
38
|
+
} & ({
|
|
39
|
+
/**
|
|
40
|
+
* Pre-configured ConvexAdminClient.
|
|
41
|
+
* Use this when you need to configure the client before initialization.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* import { ConvexAdminClient } from '@mastra/convex/storage/client';
|
|
46
|
+
*
|
|
47
|
+
* const client = new ConvexAdminClient({
|
|
48
|
+
* deploymentUrl: 'https://your-deployment.convex.cloud',
|
|
49
|
+
* adminAuthToken: 'your-token',
|
|
50
|
+
* storageFunction: 'custom/storage:handle',
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* const store = new ConvexStore({ id: 'my-store', client });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
client: ConvexAdminClient;
|
|
57
|
+
} | ConvexAdminClientConfig);
|
|
58
|
+
export declare class ConvexStore extends MastraStorage {
|
|
59
|
+
private readonly memory;
|
|
60
|
+
private readonly workflows;
|
|
61
|
+
private readonly scores;
|
|
62
|
+
constructor(config: ConvexStoreConfig);
|
|
63
|
+
get supports(): {
|
|
64
|
+
selectByIncludeResourceScope: boolean;
|
|
65
|
+
resourceWorkingMemory: boolean;
|
|
66
|
+
hasColumn: boolean;
|
|
67
|
+
createTable: boolean;
|
|
68
|
+
deleteMessages: boolean;
|
|
69
|
+
observabilityInstance: boolean;
|
|
70
|
+
listScoresBySpan: boolean;
|
|
71
|
+
};
|
|
72
|
+
getThreadById({ threadId }: {
|
|
73
|
+
threadId: string;
|
|
74
|
+
}): Promise<StorageThreadType | null>;
|
|
75
|
+
saveThread({ thread }: {
|
|
76
|
+
thread: StorageThreadType;
|
|
77
|
+
}): Promise<StorageThreadType>;
|
|
78
|
+
updateThread({ id, title, metadata, }: {
|
|
79
|
+
id: string;
|
|
80
|
+
title: string;
|
|
81
|
+
metadata: Record<string, unknown>;
|
|
82
|
+
}): Promise<StorageThreadType>;
|
|
83
|
+
deleteThread({ threadId }: {
|
|
84
|
+
threadId: string;
|
|
85
|
+
}): Promise<void>;
|
|
86
|
+
listMessages(args: StorageListMessagesInput): Promise<StorageListMessagesOutput>;
|
|
87
|
+
listMessagesById({ messageIds }: {
|
|
88
|
+
messageIds: string[];
|
|
89
|
+
}): Promise<{
|
|
90
|
+
messages: MastraDBMessage[];
|
|
91
|
+
}>;
|
|
92
|
+
saveMessages(args: {
|
|
93
|
+
messages: MastraDBMessage[];
|
|
94
|
+
}): Promise<{
|
|
95
|
+
messages: MastraDBMessage[];
|
|
96
|
+
}>;
|
|
97
|
+
updateMessages({ messages, }: {
|
|
98
|
+
messages: (Partial<Omit<MastraDBMessage, 'createdAt'>> & {
|
|
99
|
+
id: string;
|
|
100
|
+
})[];
|
|
101
|
+
}): Promise<MastraDBMessage[]>;
|
|
102
|
+
deleteMessages(messageIds: string[]): Promise<void>;
|
|
103
|
+
listThreadsByResourceId(args: StorageListThreadsByResourceIdInput): Promise<StorageListThreadsByResourceIdOutput>;
|
|
104
|
+
getResourceById({ resourceId }: {
|
|
105
|
+
resourceId: string;
|
|
106
|
+
}): Promise<StorageResourceType | null>;
|
|
107
|
+
saveResource({ resource }: {
|
|
108
|
+
resource: StorageResourceType;
|
|
109
|
+
}): Promise<StorageResourceType>;
|
|
110
|
+
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
111
|
+
resourceId: string;
|
|
112
|
+
workingMemory?: string;
|
|
113
|
+
metadata?: Record<string, unknown>;
|
|
114
|
+
}): Promise<StorageResourceType>;
|
|
115
|
+
updateWorkflowResults(params: {
|
|
116
|
+
workflowName: string;
|
|
117
|
+
runId: string;
|
|
118
|
+
stepId: string;
|
|
119
|
+
result: StepResult<any, any, any, any>;
|
|
120
|
+
requestContext: Record<string, any>;
|
|
121
|
+
}): Promise<Record<string, StepResult<any, any, any, any>>>;
|
|
122
|
+
updateWorkflowState(params: {
|
|
123
|
+
workflowName: string;
|
|
124
|
+
runId: string;
|
|
125
|
+
opts: UpdateWorkflowStateOptions;
|
|
126
|
+
}): Promise<WorkflowRunState | undefined>;
|
|
127
|
+
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, }: {
|
|
128
|
+
workflowName: string;
|
|
129
|
+
runId: string;
|
|
130
|
+
resourceId?: string | undefined;
|
|
131
|
+
snapshot: WorkflowRunState;
|
|
132
|
+
}): Promise<void>;
|
|
133
|
+
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
134
|
+
workflowName: string;
|
|
135
|
+
runId: string;
|
|
136
|
+
}): Promise<WorkflowRunState | null>;
|
|
137
|
+
listWorkflowRuns(args?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
|
|
138
|
+
getWorkflowRunById({ runId, workflowName, }: {
|
|
139
|
+
runId: string;
|
|
140
|
+
workflowName?: string | undefined;
|
|
141
|
+
}): Promise<WorkflowRun | null>;
|
|
142
|
+
deleteWorkflowRunById({ runId, workflowName }: {
|
|
143
|
+
runId: string;
|
|
144
|
+
workflowName: string;
|
|
145
|
+
}): Promise<void>;
|
|
146
|
+
getScoreById({ id }: {
|
|
147
|
+
id: string;
|
|
148
|
+
}): Promise<ScoreRowData | null>;
|
|
149
|
+
saveScore(score: SaveScorePayload): Promise<{
|
|
150
|
+
score: ScoreRowData;
|
|
151
|
+
}>;
|
|
152
|
+
listScoresByScorerId({ scorerId, pagination, entityId, entityType, source, }: {
|
|
153
|
+
scorerId: string;
|
|
154
|
+
pagination: StoragePagination;
|
|
155
|
+
entityId?: string | undefined;
|
|
156
|
+
entityType?: ScoringEntityType | undefined;
|
|
157
|
+
source?: ScoringSource | undefined;
|
|
158
|
+
}): Promise<{
|
|
159
|
+
pagination: PaginationInfo;
|
|
160
|
+
scores: ScoreRowData[];
|
|
161
|
+
}>;
|
|
162
|
+
listScoresByRunId({ runId, pagination, }: {
|
|
163
|
+
runId: string;
|
|
164
|
+
pagination: StoragePagination;
|
|
165
|
+
}): Promise<{
|
|
166
|
+
pagination: PaginationInfo;
|
|
167
|
+
scores: ScoreRowData[];
|
|
168
|
+
}>;
|
|
169
|
+
listScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
170
|
+
pagination: StoragePagination;
|
|
171
|
+
entityId: string;
|
|
172
|
+
entityType: ScoringEntityType;
|
|
173
|
+
}): Promise<{
|
|
174
|
+
pagination: PaginationInfo;
|
|
175
|
+
scores: ScoreRowData[];
|
|
176
|
+
}>;
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|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AAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAI7D,iBAAiB,CAAC,EACtB,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;IAI7D,oBAAoB,CAAC,EACzB,QAAQ,EACR,UAAU,EACV,UAAU,GACX,EAAE;QACD,UAAU,EAAE,iBAAiB,CAAC;QAC9B,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;CAGpE"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
2
|
+
export type EqualityFilter = {
|
|
3
|
+
field: string;
|
|
4
|
+
value: string | number | boolean | null;
|
|
5
|
+
};
|
|
6
|
+
export type StorageRequest = {
|
|
7
|
+
op: 'insert';
|
|
8
|
+
tableName: TABLE_NAMES | string;
|
|
9
|
+
record: Record<string, any>;
|
|
10
|
+
} | {
|
|
11
|
+
op: 'batchInsert';
|
|
12
|
+
tableName: TABLE_NAMES | string;
|
|
13
|
+
records: Record<string, any>[];
|
|
14
|
+
} | {
|
|
15
|
+
op: 'load';
|
|
16
|
+
tableName: TABLE_NAMES | string;
|
|
17
|
+
keys: Record<string, any>;
|
|
18
|
+
} | {
|
|
19
|
+
op: 'clearTable' | 'dropTable';
|
|
20
|
+
tableName: TABLE_NAMES | string;
|
|
21
|
+
} | {
|
|
22
|
+
op: 'queryTable';
|
|
23
|
+
tableName: TABLE_NAMES | string;
|
|
24
|
+
filters?: EqualityFilter[];
|
|
25
|
+
limit?: number;
|
|
26
|
+
} | {
|
|
27
|
+
op: 'deleteMany';
|
|
28
|
+
tableName: TABLE_NAMES | string;
|
|
29
|
+
ids: string[];
|
|
30
|
+
};
|
|
31
|
+
export type StorageResponse = {
|
|
32
|
+
ok: true;
|
|
33
|
+
result?: any;
|
|
34
|
+
/** Indicates more batches remain for bulk operations (e.g., clearTable) */
|
|
35
|
+
hasMore?: boolean;
|
|
36
|
+
} | {
|
|
37
|
+
ok: false;
|
|
38
|
+
error: string;
|
|
39
|
+
code?: string;
|
|
40
|
+
details?: Record<string, any>;
|
|
41
|
+
};
|
|
42
|
+
//# 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,sBAAsB,CAAC;AAExD,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,cAAc,GACtB;IACE,EAAE,EAAE,QAAQ,CAAC;IACb,SAAS,EAAE,WAAW,GAAG,MAAM,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B,GACD;IACE,EAAE,EAAE,aAAa,CAAC;IAClB,SAAS,EAAE,WAAW,GAAG,MAAM,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;CAChC,GACD;IACE,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,WAAW,GAAG,MAAM,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC3B,GACD;IACE,EAAE,EAAE,YAAY,GAAG,WAAW,CAAC;IAC/B,SAAS,EAAE,WAAW,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