@mastra/mysql 0.13.1-alpha.0 → 0.13.1
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/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +506 -108
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +507 -109
- package/dist/index.js.map +1 -1
- package/dist/storage/db/run-fencing.d.ts +34 -0
- package/dist/storage/db/run-fencing.d.ts.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +15 -5
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +16 -5
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { RunFence } from '@mastra/core/storage';
|
|
2
|
+
import type { Connection, Pool, PoolConnection } from 'mysql2/promise';
|
|
3
|
+
/** The query method both the pool and a pooled connection offer. */
|
|
4
|
+
export type Queryable = Pick<Connection, 'execute'>;
|
|
5
|
+
/**
|
|
6
|
+
* Epoch milliseconds on the database clock. `UTC_TIMESTAMP` is the time the
|
|
7
|
+
* statement started and doesn't depend on the session time zone. Every lease
|
|
8
|
+
* comparison runs in a statement that already holds the run's owner row, so
|
|
9
|
+
* no lock wait sits between that start time and the comparison.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DB_NOW_MS = "(TIMESTAMPDIFF(MICROSECOND, '1970-01-01 00:00:00', UTC_TIMESTAMP(3)) DIV 1000)";
|
|
12
|
+
/**
|
|
13
|
+
* The check half of a fenced write; call it first inside the write's
|
|
14
|
+
* transaction. The shared lock holds the claim row until commit, so a claim
|
|
15
|
+
* that updates the row waits for the write to finish, and every later write
|
|
16
|
+
* sees the new claim.
|
|
17
|
+
*/
|
|
18
|
+
export declare function assertRunFence(q: Queryable, claimsTable: string, fence: RunFence, operation: string): Promise<void>;
|
|
19
|
+
/** Runs `fn` in a transaction on its own pooled connection. */
|
|
20
|
+
export declare function inTransaction<T>(pool: Pool, fn: (connection: PoolConnection) => Promise<T>): Promise<T>;
|
|
21
|
+
/**
|
|
22
|
+
* Runs `write` directly when it carries no fence, or in a transaction behind
|
|
23
|
+
* the fence check when it does.
|
|
24
|
+
*/
|
|
25
|
+
export declare function withRunFence<T>(pool: Pool, claimsTable: string, fence: RunFence | undefined, operation: string, write: (q: Queryable) => Promise<T>): Promise<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Runs a transaction that creates or updates a run's claim row, retrying when
|
|
28
|
+
* two first claims race to insert it. Under REPEATABLE READ both lock the gap
|
|
29
|
+
* where the row would go and one is chosen as a deadlock victim; under READ
|
|
30
|
+
* COMMITTED the later insert hits the duplicate key. On retry the row exists
|
|
31
|
+
* and the claim serializes behind its row lock.
|
|
32
|
+
*/
|
|
33
|
+
export declare function claimTransaction<T>(pool: Pool, fn: (connection: PoolConnection) => Promise<T>): Promise<T>;
|
|
34
|
+
//# sourceMappingURL=run-fencing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-fencing.d.ts","sourceRoot":"","sources":["../../../src/storage/db/run-fencing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,cAAc,EAAiB,MAAM,gBAAgB,CAAC;AAGtF,oEAAoE;AACpE,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,SAAS,mFAAmF,CAAC;AAM1G;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,CAAC,EAAE,SAAS,EACZ,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,QAAQ,EACf,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAWf;AAED,+DAA+D;AAC/D,wBAAsB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,UAAU,EAAE,cAAc,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAa7G;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,QAAQ,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,CAAC,CAAC,EAAE,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,GAClC,OAAO,CAAC,CAAC,CAAC,CAMZ;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,UAAU,EAAE,cAAc,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAShH"}
|
|
@@ -2,7 +2,7 @@ import { type UpdateActiveObservationsResult, type UpdateBufferedObservationsRes
|
|
|
2
2
|
import type { MastraDBMessage, MastraMessageContentV2 } from '@mastra/core/agent';
|
|
3
3
|
import type { StorageThreadType } from '@mastra/core/memory';
|
|
4
4
|
import { MemoryStorage } from '@mastra/core/storage';
|
|
5
|
-
import type { CreateIndexOptions, CreateObservationalMemoryInput, CreateReflectionGenerationInput, ObservationalMemoryHistoryOptions, ObservationalMemoryRecord, PaginationArgs, PaginationInfo, StorageCloneThreadInput, StorageCloneThreadOutput, StorageListMessagesByResourceIdInput, StorageListMessagesInput, StorageListMessagesOutput, StorageListThreadsInput, StorageListThreadsOutput, StorageResourceType, SwapBufferedReflectionToActiveInput, SwapBufferedToActiveInput, SwapBufferedToActiveResult, ThreadSortOptions, UpdateActiveObservationsInput, UpdateBufferedObservationsInput, UpdateBufferedReflectionInput } from '@mastra/core/storage';
|
|
5
|
+
import type { CreateIndexOptions, CreateObservationalMemoryInput, CreateReflectionGenerationInput, ObservationalMemoryHistoryOptions, ObservationalMemoryRecord, PaginationArgs, PaginationInfo, RunFence, StorageCloneThreadInput, StorageCloneThreadOutput, StorageListMessagesByResourceIdInput, StorageListMessagesInput, StorageListMessagesOutput, StorageListThreadsInput, StorageListThreadsOutput, StorageResourceType, SwapBufferedReflectionToActiveInput, SwapBufferedToActiveInput, SwapBufferedToActiveResult, ThreadSortOptions, UpdateActiveObservationsInput, UpdateBufferedObservationsInput, UpdateBufferedReflectionInput } from '@mastra/core/storage';
|
|
6
6
|
import type { Pool } from 'mysql2/promise';
|
|
7
7
|
import type { StoreOperationsMySQL } from '../operations/index.js';
|
|
8
8
|
export declare class MemoryMySQL extends MemoryStorage {
|
|
@@ -19,6 +19,9 @@ export declare class MemoryMySQL extends MemoryStorage {
|
|
|
19
19
|
skipDefaultIndexes?: boolean;
|
|
20
20
|
indexes?: CreateIndexOptions[];
|
|
21
21
|
});
|
|
22
|
+
supportsRunFencing(): boolean;
|
|
23
|
+
raiseRunFence(fence: RunFence): Promise<boolean>;
|
|
24
|
+
retireRunFence(fence: RunFence): Promise<boolean>;
|
|
22
25
|
init(): Promise<void>;
|
|
23
26
|
static getDefaultIndexDefs(prefix?: string): CreateIndexOptions[];
|
|
24
27
|
static getExportDDL(): string[];
|
|
@@ -83,13 +86,15 @@ export declare class MemoryMySQL extends MemoryStorage {
|
|
|
83
86
|
} & PaginationArgs & ThreadSortOptions): Promise<PaginationInfo & {
|
|
84
87
|
threads: StorageThreadType[];
|
|
85
88
|
}>;
|
|
86
|
-
saveThread({ thread }: {
|
|
89
|
+
saveThread({ thread, fence }: {
|
|
87
90
|
thread: StorageThreadType;
|
|
91
|
+
fence?: RunFence;
|
|
88
92
|
}): Promise<StorageThreadType>;
|
|
89
|
-
updateThread({ id, title, metadata, }: {
|
|
93
|
+
updateThread({ id, title, metadata, fence, }: {
|
|
90
94
|
id: string;
|
|
91
95
|
title?: string;
|
|
92
96
|
metadata?: Record<string, unknown>;
|
|
97
|
+
fence?: RunFence;
|
|
93
98
|
}): Promise<StorageThreadType>;
|
|
94
99
|
deleteThread({ threadId }: {
|
|
95
100
|
threadId: string;
|
|
@@ -101,6 +106,7 @@ export declare class MemoryMySQL extends MemoryStorage {
|
|
|
101
106
|
}>;
|
|
102
107
|
saveMessages(args: {
|
|
103
108
|
messages: MastraDBMessage[];
|
|
109
|
+
fence?: RunFence;
|
|
104
110
|
}): Promise<{
|
|
105
111
|
messages: MastraDBMessage[];
|
|
106
112
|
}>;
|
|
@@ -109,8 +115,11 @@ export declare class MemoryMySQL extends MemoryStorage {
|
|
|
109
115
|
id: string;
|
|
110
116
|
content?: Partial<MastraMessageContentV2>;
|
|
111
117
|
})[];
|
|
118
|
+
fence?: RunFence;
|
|
112
119
|
}): Promise<MastraDBMessage[]>;
|
|
113
|
-
deleteMessages(messageIds: string[]
|
|
120
|
+
deleteMessages(messageIds: string[], options?: {
|
|
121
|
+
fence?: RunFence;
|
|
122
|
+
}): Promise<void>;
|
|
114
123
|
cloneThread(args: StorageCloneThreadInput): Promise<StorageCloneThreadOutput>;
|
|
115
124
|
listMessages(args: StorageListMessagesInput): Promise<StorageListMessagesOutput>;
|
|
116
125
|
listMessagesByResourceId(args: StorageListMessagesByResourceIdInput): Promise<StorageListMessagesOutput>;
|
|
@@ -120,10 +129,11 @@ export declare class MemoryMySQL extends MemoryStorage {
|
|
|
120
129
|
saveResource({ resource }: {
|
|
121
130
|
resource: StorageResourceType;
|
|
122
131
|
}): Promise<StorageResourceType>;
|
|
123
|
-
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
132
|
+
updateResource({ resourceId, workingMemory, metadata, fence, }: {
|
|
124
133
|
resourceId: string;
|
|
125
134
|
workingMemory?: string;
|
|
126
135
|
metadata?: Record<string, unknown>;
|
|
136
|
+
fence?: RunFence;
|
|
127
137
|
}): Promise<StorageResourceType>;
|
|
128
138
|
getObservationalMemory(threadId: string | null, resourceId: string): Promise<ObservationalMemoryRecord | null>;
|
|
129
139
|
getObservationalMemoryHistory(threadId: string | null, resourceId: string, limit?: number, options?: ObservationalMemoryHistoryOptions): Promise<ObservationalMemoryRecord[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/memory/index.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,8BAA8B,EACnC,KAAK,gCAAgC,EAEtC,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAElF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EACL,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/memory/index.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,8BAA8B,EACnC,KAAK,gCAAgC,EAEtC,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAElF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EACL,aAAa,EAcd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAEV,kBAAkB,EAClB,8BAA8B,EAC9B,+BAA+B,EAC/B,iCAAiC,EACjC,yBAAyB,EACzB,cAAc,EACd,cAAc,EACd,QAAQ,EACR,uBAAuB,EACvB,wBAAwB,EACxB,oCAAoC,EACpC,wBAAwB,EACxB,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EAExB,mBAAmB,EACnB,mCAAmC,EACnC,yBAAyB,EACzB,0BAA0B,EAG1B,iBAAiB,EACjB,6BAA6B,EAC7B,+BAA+B,EAC/B,6BAA6B,EAC9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,IAAI,EAAkD,MAAM,gBAAgB,CAAC;AAI3F,OAAO,KAAK,EAAE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exOptions, StorageListWorkflowRunsInput, UpdateWorkflowStateOptions, WorkflowRun, WorkflowRuns } from '@mastra/core/storage';
|
|
2
|
+
import type { ClaimRunOwnershipInput, ClaimRunOwnershipResult, CreateIndexOptions, RenewRunOwnershipInput, RenewRunOwnershipResult, RunFence, RunOwnershipRecord, StorageListWorkflowRunsInput, UpdateWorkflowStateOptions, WorkflowRun, WorkflowRuns } from '@mastra/core/storage';
|
|
3
3
|
import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
|
|
4
4
|
import type { Pool } from 'mysql2/promise';
|
|
5
5
|
import type { StoreOperationsMySQL } from '../operations/index.js';
|
|
@@ -40,30 +40,41 @@ export declare class WorkflowsMySQL extends WorkflowsStorage {
|
|
|
40
40
|
createCustomIndexes(): Promise<void>;
|
|
41
41
|
init(): Promise<void>;
|
|
42
42
|
dangerouslyClearAll(): Promise<void>;
|
|
43
|
-
|
|
43
|
+
supportsRunFencing(): boolean;
|
|
44
|
+
claimRunOwnership({ runId, ownerId, leaseMs, force, expectedGeneration, }: ClaimRunOwnershipInput): Promise<ClaimRunOwnershipResult>;
|
|
45
|
+
renewRunOwnership({ leaseMs, ...fence }: RenewRunOwnershipInput): Promise<RenewRunOwnershipResult>;
|
|
46
|
+
releaseRunOwnership(fence: RunFence): Promise<boolean>;
|
|
47
|
+
getRunOwnership({ runId }: {
|
|
48
|
+
runId: string;
|
|
49
|
+
}): Promise<RunOwnershipRecord | null>;
|
|
50
|
+
deleteWorkflowRunById({ runId, workflowName, fence, }: {
|
|
44
51
|
runId: string;
|
|
45
52
|
workflowName: string;
|
|
53
|
+
fence?: RunFence;
|
|
46
54
|
}): Promise<void>;
|
|
47
|
-
updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, state, }: {
|
|
55
|
+
updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, state, fence: explicitFence, }: {
|
|
48
56
|
workflowName: string;
|
|
49
57
|
runId: string;
|
|
50
58
|
stepId: string;
|
|
51
59
|
result: StepResult<any, any, any, any>;
|
|
52
60
|
requestContext?: Record<string, any>;
|
|
53
61
|
state?: Record<string, any>;
|
|
62
|
+
fence?: RunFence;
|
|
54
63
|
}): Promise<Record<string, StepResult<any, any, any, any>>>;
|
|
55
|
-
updateWorkflowState({ workflowName, runId, opts, }: {
|
|
64
|
+
updateWorkflowState({ workflowName, runId, opts, fence: explicitFence, }: {
|
|
56
65
|
workflowName: string;
|
|
57
66
|
runId: string;
|
|
58
67
|
opts: UpdateWorkflowStateOptions;
|
|
68
|
+
fence?: RunFence;
|
|
59
69
|
}): Promise<WorkflowRunState | undefined>;
|
|
60
|
-
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, createdAt, updatedAt, }: {
|
|
70
|
+
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, createdAt, updatedAt, fence, }: {
|
|
61
71
|
workflowName: string;
|
|
62
72
|
runId: string;
|
|
63
73
|
resourceId?: string;
|
|
64
74
|
snapshot: WorkflowRunState;
|
|
65
75
|
createdAt?: Date;
|
|
66
76
|
updatedAt?: Date;
|
|
77
|
+
fence?: RunFence;
|
|
67
78
|
}): Promise<void>;
|
|
68
79
|
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
69
80
|
workflowName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/index.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/index.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,gBAAgB,EAOjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,QAAQ,EACR,kBAAkB,EAClB,4BAA4B,EAE5B,0BAA0B,EAC1B,WAAW,EACX,YAAY,EACb,MAAM,sBAAsB,CAAC;AAC9B,O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AM,CAAC;QACd,IAAI,EAAE,0BAA0B,CAAC;QACjC,KAAK,CAAC,EAAE,QAAQ,CAAC;KAClB,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAgDxC;IAEK,uBAAuB,CAAC,EAC5B,YAAY,EACZ,KAAK,EACL,UAAU,EACV,QAAQ,EACR,SAAS,EACT,SAAS,EACT,KAAK,GACN,EAAE;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,gBAAgB,CAAC;QAC3B,SAAS,CAAC,EAAE,IAAI,CAAC;QACjB,SAAS,CAAC,EAAE,IAAI,CAAC;QACjB,KAAK,CAAC,EAAE,QAAQ,CAAC;KAClB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoDhB;IAEK,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,CAkBnC;IAEK,gBAAgB,CAAC,IAAI,GAAE,4BAAiC,GAAG,OAAO,CAAC,YAAY,CAAC,CA2ErF;IAEK,eAAe,CAAC,IAAI,GAAE,4BAAiC,GAAG,OAAO,CAAC,YAAY,CAAC,CAEpF;IAEK,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,CAwB9B;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mysql",
|
|
3
|
-
"version": "0.13.1
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "MySQL provider for Mastra - db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"typescript": "^7.0.2",
|
|
33
33
|
"vitest": "4.1.11",
|
|
34
34
|
"@internal/core": "0.1.2",
|
|
35
|
-
"@internal/lint": "0.0.
|
|
36
|
-
"@internal/storage-test-utils": "0.0.
|
|
37
|
-
"@internal/types-builder": "0.0.
|
|
38
|
-
"@mastra/core": "1.77.0
|
|
35
|
+
"@internal/lint": "0.0.143",
|
|
36
|
+
"@internal/storage-test-utils": "0.0.139",
|
|
37
|
+
"@internal/types-builder": "0.0.118",
|
|
38
|
+
"@mastra/core": "1.77.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@mastra/core": ">=1.
|
|
41
|
+
"@mastra/core": ">=1.76.0-0 <2.0.0-0"
|
|
42
42
|
},
|
|
43
43
|
"files": [
|
|
44
44
|
"dist"
|