@mastra/upstash 1.5.2 → 1.5.3

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.
@@ -1,32 +1,38 @@
1
1
  import type { MastraMessageContentV2 } from '@mastra/core/agent';
2
2
  import type { MastraDBMessage, StorageThreadType } from '@mastra/core/memory';
3
3
  import { MemoryStorage } from '@mastra/core/storage';
4
- import type { StorageResourceType, StorageListMessagesInput, StorageListMessagesOutput, StorageListThreadsInput, StorageListThreadsOutput, StorageCloneThreadInput, StorageCloneThreadOutput } from '@mastra/core/storage';
4
+ import type { RunFence, StorageResourceType, StorageListMessagesInput, StorageListMessagesOutput, StorageListThreadsInput, StorageListThreadsOutput, StorageCloneThreadInput, StorageCloneThreadOutput } from '@mastra/core/storage';
5
5
  import type { UpstashDomainConfig } from '../../db/index.js';
6
6
  export declare class StoreMemoryUpstash extends MemoryStorage {
7
7
  #private;
8
8
  readonly supportsPartialThreadUpdate = true;
9
9
  private client;
10
10
  constructor(config: UpstashDomainConfig);
11
+ supportsRunFencing(): boolean;
12
+ raiseRunFence(fence: RunFence): Promise<boolean>;
13
+ retireRunFence(fence: RunFence): Promise<boolean>;
11
14
  dangerouslyClearAll(): Promise<void>;
12
15
  getThreadById({ threadId, resourceId, }: {
13
16
  threadId: string;
14
17
  resourceId?: string;
15
18
  }): Promise<StorageThreadType | null>;
16
19
  listThreads(args: StorageListThreadsInput): Promise<StorageListThreadsOutput>;
17
- saveThread({ thread }: {
20
+ saveThread({ thread, fence }: {
18
21
  thread: StorageThreadType;
22
+ fence?: RunFence;
19
23
  }): Promise<StorageThreadType>;
20
- updateThread({ id, title, metadata, }: {
24
+ updateThread({ id, title, metadata, fence, }: {
21
25
  id: string;
22
26
  title?: string;
23
27
  metadata?: Record<string, unknown>;
28
+ fence?: RunFence;
24
29
  }): Promise<StorageThreadType>;
25
30
  deleteThread({ threadId }: {
26
31
  threadId: string;
27
32
  }): Promise<void>;
28
33
  saveMessages(args: {
29
34
  messages: MastraDBMessage[];
35
+ fence?: RunFence;
30
36
  }): Promise<{
31
37
  messages: MastraDBMessage[];
32
38
  }>;
@@ -56,10 +62,11 @@ export declare class StoreMemoryUpstash extends MemoryStorage {
56
62
  saveResource({ resource }: {
57
63
  resource: StorageResourceType;
58
64
  }): Promise<StorageResourceType>;
59
- updateResource({ resourceId, workingMemory, metadata, }: {
65
+ updateResource({ resourceId, workingMemory, metadata, fence, }: {
60
66
  resourceId: string;
61
67
  workingMemory?: string;
62
68
  metadata?: Record<string, unknown>;
69
+ fence?: RunFence;
63
70
  }): Promise<StorageResourceType>;
64
71
  updateMessages(args: {
65
72
  messages: (Partial<Omit<MastraDBMessage, 'createdAt'>> & {
@@ -69,8 +76,11 @@ export declare class StoreMemoryUpstash extends MemoryStorage {
69
76
  content?: MastraMessageContentV2['content'];
70
77
  };
71
78
  })[];
79
+ fence?: RunFence;
72
80
  }): Promise<MastraDBMessage[]>;
73
- deleteMessages(messageIds: string[]): Promise<void>;
81
+ deleteMessages(messageIds: string[], options?: {
82
+ fence?: RunFence;
83
+ }): Promise<void>;
74
84
  private sortThreads;
75
85
  cloneThread(args: StorageCloneThreadInput): Promise<StorageCloneThreadOutput>;
76
86
  }
@@ -1 +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,EAWd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EAGxB,uBAAuB,EACvB,wBAAwB,EAEzB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,C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BAAmB,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAEhG;IAuBK,cAAc,CAAC,EACnB,UAAU,EACV,aAAa,EACb,QAAQ,EACR,KAAK,GACN,EAAE;QACD,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACnC,KAAK,CAAC,EAAE,QAAQ,CAAC;KAClB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAiC/B;IAEK,cAAc,CAAC,IAAI,EAAE;QACzB,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC,GAAG;YACvD,EAAE,EAAE,MAAM,CAAC;YACX,OAAO,CAAC,EAAE;gBAAE,QAAQ,CAAC,EAAE,sBAAsB,CAAC,UAAU,CAAC,CAAC;gBAAC,OAAO,CAAC,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAA;aAAE,CAAC;SAC1G,CAAC,EAAE,CAAC;QACL,KAAK,CAAC,EAAE,QAAQ,CAAC;KAClB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CA+P7B;IAEK,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsGxF;IAED,OAAO,CAAC,WAAW;IAiBb,WAAW,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAiKlF;CACF"}
@@ -0,0 +1,44 @@
1
+ import { TABLE_MEMORY_RUN_FENCES, TABLE_WORKFLOW_RUN_OWNERS } from '@mastra/core/storage';
2
+ import type { ClaimRunOwnershipInput, ClaimRunOwnershipResult, RenewRunOwnershipInput, RenewRunOwnershipResult, RunFence, RunOwnershipRecord } from '@mastra/core/storage';
3
+ import type { Redis } from '@upstash/redis';
4
+ /** Table holding a run's current claim: its ownership hash (workflows) or raised fence (memory). */
5
+ export type RunClaimTable = typeof TABLE_WORKFLOW_RUN_OWNERS | typeof TABLE_MEMORY_RUN_FENCES;
6
+ /** A write's fence, and the table holding the run's current claim to check it against. */
7
+ export interface RunFenceCheck {
8
+ claims: RunClaimTable;
9
+ fence: RunFence;
10
+ operation: string;
11
+ }
12
+ /** The subset of a pipeline the domains write through. */
13
+ export interface WriteBatch {
14
+ set(key: string, value: unknown): unknown;
15
+ del(key: string): unknown;
16
+ zadd(key: string, member: {
17
+ score: number;
18
+ member: string;
19
+ }): unknown;
20
+ zrem(key: string, member: string): unknown;
21
+ exec(): Promise<unknown>;
22
+ }
23
+ export declare function runClaimKey(claims: RunClaimTable, runId: string): string;
24
+ export declare const RUN_CLAIM_RETENTION_MS: number;
25
+ /**
26
+ * Runs `script`, first checking the run's claim against `check`'s fence in
27
+ * the same script when `check` is set. A stale fence throws
28
+ * `RunFenceConflictError` before the script does anything.
29
+ */
30
+ export declare function evalFenced(client: Redis, script: string, keys: string[], args: string[], check: RunFenceCheck | undefined): Promise<unknown>;
31
+ export declare function claimRunOwnership(client: Redis, { runId, ownerId, leaseMs, force, expectedGeneration }: ClaimRunOwnershipInput): Promise<ClaimRunOwnershipResult>;
32
+ export declare function renewRunOwnership(client: Redis, { leaseMs, ...fence }: RenewRunOwnershipInput): Promise<RenewRunOwnershipResult>;
33
+ export declare function releaseRunOwnership(client: Redis, fence: RunFence): Promise<boolean>;
34
+ export declare function getRunOwnership(client: Redis, runId: string): Promise<RunOwnershipRecord | null>;
35
+ export declare function raiseRunFence(client: Redis, fence: RunFence): Promise<boolean>;
36
+ export declare function retireRunFence(client: Redis, fence: RunFence): Promise<boolean>;
37
+ /** A pipeline, or a fenced batch when `check` is set. */
38
+ export declare function writeBatch(client: Redis, check: RunFenceCheck | undefined): WriteBatch;
39
+ /**
40
+ * Rejects a fenced write that turns out to have nothing to write when its
41
+ * fence is no longer current, as the write itself would have been rejected.
42
+ */
43
+ export declare function assertRunFence(client: Redis, check: RunFenceCheck | undefined): Promise<void>;
44
+ //# sourceMappingURL=run-fencing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-fencing.d.ts","sourceRoot":"","sources":["../../../src/storage/domains/run-fencing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjH,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,QAAQ,EACR,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,oGAAoG;AACpG,MAAM,MAAM,aAAa,GAAG,OAAO,yBAAyB,GAAG,OAAO,uBAAuB,CAAC;AAE9F,0FAA0F;AAC1F,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,QAAQ,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,0DAA0D;AAC1D,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;IAC1C,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;IACtE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3C,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1B;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAExE;AAYD,eAAO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AAI,CAAC,CAEnG"}
@@ -1,5 +1,5 @@
1
1
  import { WorkflowsStorage } from '@mastra/core/storage';
2
- import type { StorageListWorkflowRunsInput, WorkflowRun, WorkflowRuns, UpdateWorkflowStateOptions } from '@mastra/core/storage';
2
+ import type { ClaimRunOwnershipInput, ClaimRunOwnershipResult, RenewRunOwnershipInput, RenewRunOwnershipResult, RunFence, RunOwnershipRecord, StorageListWorkflowRunsInput, WorkflowRun, WorkflowRuns, UpdateWorkflowStateOptions } from '@mastra/core/storage';
3
3
  import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
4
4
  import type { UpstashDomainConfig } from '../../db/index.js';
5
5
  export declare class WorkflowsUpstash extends WorkflowsStorage {
@@ -8,20 +8,29 @@ export declare class WorkflowsUpstash extends WorkflowsStorage {
8
8
  constructor(config: UpstashDomainConfig);
9
9
  supportsConcurrentUpdates(): boolean;
10
10
  private parseWorkflowRun;
11
+ supportsRunFencing(): boolean;
11
12
  dangerouslyClearAll(): Promise<void>;
13
+ claimRunOwnership(args: ClaimRunOwnershipInput): Promise<ClaimRunOwnershipResult>;
14
+ renewRunOwnership(args: RenewRunOwnershipInput): Promise<RenewRunOwnershipResult>;
15
+ releaseRunOwnership(fence: RunFence): Promise<boolean>;
16
+ getRunOwnership({ runId }: {
17
+ runId: string;
18
+ }): Promise<RunOwnershipRecord | null>;
12
19
  private getWorkflowRunRecord;
13
- updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, state, }: {
20
+ updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, state, fence, }: {
14
21
  workflowName: string;
15
22
  runId: string;
16
23
  stepId: string;
17
24
  result: StepResult<any, any, any, any>;
18
25
  requestContext: Record<string, any>;
19
26
  state?: Record<string, any>;
27
+ fence?: RunFence;
20
28
  }): Promise<Record<string, StepResult<any, any, any, any>>>;
21
- updateWorkflowState({ workflowName, runId, opts, }: {
29
+ updateWorkflowState({ workflowName, runId, opts, fence, }: {
22
30
  workflowName: string;
23
31
  runId: string;
24
32
  opts: UpdateWorkflowStateOptions;
33
+ fence?: RunFence;
25
34
  }): Promise<WorkflowRunState | undefined>;
26
35
  persistWorkflowSnapshot(params: {
27
36
  namespace?: string;
@@ -31,6 +40,7 @@ export declare class WorkflowsUpstash extends WorkflowsStorage {
31
40
  snapshot: WorkflowRunState;
32
41
  createdAt?: Date;
33
42
  updatedAt?: Date;
43
+ fence?: RunFence;
34
44
  }): Promise<void>;
35
45
  loadWorkflowSnapshot(params: {
36
46
  namespace: string;
@@ -41,9 +51,10 @@ export declare class WorkflowsUpstash extends WorkflowsStorage {
41
51
  runId: string;
42
52
  workflowName?: string;
43
53
  }): Promise<WorkflowRun | null>;
44
- deleteWorkflowRunById({ runId, workflowName }: {
54
+ deleteWorkflowRunById({ runId, workflowName, fence, }: {
45
55
  runId: string;
46
56
  workflowName: string;
57
+ fence?: RunFence;
47
58
  }): Promise<void>;
48
59
  listWorkflowRuns({ workflowName, fromDate, toDate, perPage, page, resourceId, status, }?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
49
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/index.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,gBAAgB,EAEjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,4BAA4B,EAC5B,WAAW,EACX,YAAY,EACZ,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAYpD,qBAAa,gBAAiB,SAAQ,gBAAgB;;IACpD,OAAO,CAAC,MAAM,CAAQ;IAGtB,YAAY,MAAM,EAAE,mBAAmB,EAKtC;IAED,yBAAyB,IAAI,OAAO,CAEnC;IAED,OAAO,CAAC,gBAAgB;IAoBlB,mBAAmB,IAAI,OAAO,CAAC,I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A6GxC;IAEK,uBAAuB,CAAC,MAAM,EAAE;QACpC,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,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,CAwDhB;IAEK,oBAAoB,CAAC,MAAM,EAAE;QACjC,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAqBnC;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,CAoB9B;IAEK,qBAAqB,CAAC,EAC1B,KAAK,EACL,YAAY,EACZ,KAAK,GACN,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,QAAQ,CAAC;KAClB,GAAG,OAAO,CAAC,IAAI,CAAC,CA6BhB;IAEK,gBAAgB,CAAC,EACrB,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,OAAO,EACP,IAAI,EACJ,UAAU,EACV,MAAM,GACP,GAAE,4BAAiC,GAAG,OAAO,CAAC,YAAY,CAAC,CAqF3D;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/upstash",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "Upstash provider for Mastra - includes both vector and db storage capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -22,7 +22,7 @@
22
22
  "dependencies": {
23
23
  "@upstash/redis": "^1.37.0",
24
24
  "@upstash/vector": "^1.2.3",
25
- "@mastra/redis": "1.4.9"
25
+ "@mastra/redis": "1.4.10"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "22.20.1",
@@ -34,13 +34,13 @@
34
34
  "tsx": "^4.23.1",
35
35
  "typescript": "^7.0.2",
36
36
  "vitest": "4.1.11",
37
- "@internal/lint": "0.0.142",
38
- "@internal/storage-test-utils": "0.0.138",
39
- "@mastra/core": "1.76.0",
40
- "@internal/types-builder": "0.0.117"
37
+ "@internal/lint": "0.0.143",
38
+ "@internal/storage-test-utils": "0.0.139",
39
+ "@internal/types-builder": "0.0.118",
40
+ "@mastra/core": "1.77.0"
41
41
  },
42
42
  "peerDependencies": {
43
- "@mastra/core": ">=1.61.0-0 <2.0.0-0"
43
+ "@mastra/core": ">=1.76.0-0 <2.0.0-0"
44
44
  },
45
45
  "files": [
46
46
  "dist"