@mastra/convex 1.7.2 → 1.7.3-alpha.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.
Files changed (42) hide show
  1. package/dist/_types/@internal_core/dist/memory/index.d.ts +102 -0
  2. package/dist/_types/@internal_core/package.json +1 -0
  3. package/dist/docs/SKILL.md +1 -1
  4. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  5. package/dist/docs/references/reference-vectors-convex.md +1 -3
  6. package/dist/index.cjs +370 -161
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.js +371 -162
  9. package/dist/index.js.map +1 -1
  10. package/dist/schema.cjs +1 -0
  11. package/dist/schema.cjs.map +1 -1
  12. package/dist/schema.d.ts +3 -1
  13. package/dist/schema.d.ts.map +1 -1
  14. package/dist/schema.js +1 -0
  15. package/dist/schema.js.map +1 -1
  16. package/dist/server/index.cjs +1 -1
  17. package/dist/server/index.js +1 -1
  18. package/dist/server/observational-memory.d.ts +26 -1
  19. package/dist/server/observational-memory.d.ts.map +1 -1
  20. package/dist/server/run-fencing.d.ts +14 -0
  21. package/dist/server/run-fencing.d.ts.map +1 -0
  22. package/dist/server/storage.d.ts +2 -2
  23. package/dist/server/storage.d.ts.map +1 -1
  24. package/dist/{server-D3SG5LQf.js → server-B8RSiOmu.js} +454 -56
  25. package/dist/server-B8RSiOmu.js.map +1 -0
  26. package/dist/{server-D_scBUwi.cjs → server-Bcgr5CcA.cjs} +454 -56
  27. package/dist/server-Bcgr5CcA.cjs.map +1 -0
  28. package/dist/storage/client.d.ts +3 -3
  29. package/dist/storage/client.d.ts.map +1 -1
  30. package/dist/storage/db/index.d.ts +33 -6
  31. package/dist/storage/db/index.d.ts.map +1 -1
  32. package/dist/storage/domains/memory/index.d.ts +20 -7
  33. package/dist/storage/domains/memory/index.d.ts.map +1 -1
  34. package/dist/storage/domains/workflows/index.d.ts +16 -5
  35. package/dist/storage/domains/workflows/index.d.ts.map +1 -1
  36. package/dist/storage/run-fencing.d.ts +28 -0
  37. package/dist/storage/run-fencing.d.ts.map +1 -0
  38. package/dist/storage/types.d.ts +114 -1
  39. package/dist/storage/types.d.ts.map +1 -1
  40. package/package.json +5 -4
  41. package/dist/server-D3SG5LQf.js.map +0 -1
  42. package/dist/server-D_scBUwi.cjs.map +0 -1
@@ -0,0 +1,102 @@
1
+ //#region src/memory/index.d.ts
2
+ /**
3
+ * Shared rules for observational memory lifecycle writes. Every storage adapter applies
4
+ * these inside its own atomic section (lock, transaction, or conditional update), so the
5
+ * decisions are identical across adapters.
6
+ */
7
+ /**
8
+ * Observational memory columns that lifecycle writes depend on. Storage adapters merge these
9
+ * into the table schema they get from `@mastra/core`, so the columns exist even when the
10
+ * installed core predates them.
11
+ */
12
+ declare const OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS: {
13
+ readonly supersededBy: {
14
+ readonly type: 'text';
15
+ readonly nullable: true;
16
+ };
17
+ };
18
+ /** `schema` plus {@link OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS}; `undefined` when `schema` is. */
19
+ declare function withObservationalMemoryLifecycleColumns<T extends object>(schema: T | undefined): (T & typeof OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS) | undefined;
20
+ /**
21
+ * Result of `commitActiveObservations`.
22
+ */
23
+ interface UpdateActiveObservationsResult {
24
+ /** Whether the observations were written. */
25
+ applied: boolean;
26
+ /**
27
+ * Why nothing was written: `retired` — the target record was superseded by a newer
28
+ * generation; `conflict` — `expectedActiveObservations` no longer matches the stored text.
29
+ */
30
+ reason?: 'retired' | 'conflict';
31
+ }
32
+ /**
33
+ * Result of `appendBufferedObservations`.
34
+ *
35
+ * The append targets the head generation: when `input.id` was superseded, the chunk is
36
+ * appended to the current head instead. The append is skipped (`persisted: false`) when the
37
+ * head already holds a chunk with the same `cycleId`, or when the chunk is wholly covered by
38
+ * the head's cursor. Chunks carry `lastObservedAt = max message time + 1ms`, so a chunk is
39
+ * wholly covered iff `head.lastObservedAt >= chunk.lastObservedAt - 1ms`.
40
+ */
41
+ interface UpdateBufferedObservationsResult {
42
+ /** Whether the chunk was stored. */
43
+ persisted: boolean;
44
+ /** The record the chunk was written to (or would have been written to). */
45
+ recordId: string;
46
+ }
47
+ /** The fields of an observational memory record that decide head order. */
48
+ interface ObservationalMemoryHeadOrderFields {
49
+ generationCount: number;
50
+ createdAt: Date | string;
51
+ id: string;
52
+ }
53
+ /**
54
+ * Canonical head order: `generationCount DESC, createdAt ASC, id ASC`.
55
+ * Returns a negative number when `a` sorts before `b` (i.e. `a` is the better head candidate).
56
+ */
57
+ declare function compareObservationalMemoryHeadOrder(a: ObservationalMemoryHeadOrderFields, b: ObservationalMemoryHeadOrderFields): number;
58
+ /**
59
+ * A buffered chunk stores `lastObservedAt = max message time + 1ms`. It is wholly covered
60
+ * (every message it observed is already at or before the cursor) iff
61
+ * `cursor >= chunk.lastObservedAt - 1ms`.
62
+ */
63
+ declare function isBufferedChunkCoveredByCursor(chunkLastObservedAt: Date | string, cursor: Date | string | null | undefined): boolean;
64
+ /** The later of two cursors; `undefined` only when both are absent. */
65
+ declare function maxObservationCursor(a: Date | string | null | undefined, b: Date | string | null | undefined): Date | undefined;
66
+ interface ReflectionTextPlan {
67
+ /** `equal`: stored text equals the snapshot. `append`: observations were appended after the snapshot. */
68
+ mode: 'equal' | 'append';
69
+ observations: string;
70
+ tokenCount: number;
71
+ }
72
+ /**
73
+ * Decide the new generation's text when a reflection built from `snapshot` commits against
74
+ * the stored record.
75
+ *
76
+ * - Stored text equals the snapshot: the reflection replaces it.
77
+ * - Stored text extends the snapshot (activation only appends): the appended tail is kept
78
+ * after the reflection, and its tokens are added.
79
+ * - Anything else (a non-append rewrite): `null` — the reflection must not be applied.
80
+ */
81
+ declare function planReflectionGenerationText(input: {
82
+ storedObservations: string;
83
+ storedObservationTokenCount: number;
84
+ snapshotObservations: string;
85
+ snapshotObservationTokenCount: number;
86
+ reflection: string;
87
+ tokenCount: number;
88
+ }): ReflectionTextPlan | null;
89
+ /**
90
+ * Backs `updateActiveObservations` in adapters that implement `commitActiveObservations`.
91
+ * Callers of `updateActiveObservations` (which resolves `void`) can't see a commit result, so a
92
+ * write that was not applied throws instead of resolving as if it had committed.
93
+ */
94
+ declare function assertActiveObservationsApplied(result: UpdateActiveObservationsResult, id: string): void;
95
+ /**
96
+ * Whether the stored text can still accept a reflection built from `snapshot`
97
+ * (equal, or only appended to since).
98
+ */
99
+ declare function isAppendOnlySince(storedObservations: string, snapshotObservations: string): boolean;
100
+ //#endregion
101
+ export { OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS, ObservationalMemoryHeadOrderFields, ReflectionTextPlan, UpdateActiveObservationsResult, UpdateBufferedObservationsResult, assertActiveObservationsApplied, compareObservationalMemoryHeadOrder, isAppendOnlySince, isBufferedChunkCoveredByCursor, maxObservationCursor, planReflectionGenerationText, withObservationalMemoryLifecycleColumns };
102
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -3,7 +3,7 @@ name: mastra-convex
3
3
  description: Documentation for @mastra/convex. Use when working with @mastra/convex APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/convex"
6
- version: "1.7.2"
6
+ version: "1.7.3-alpha.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.7.2",
2
+ "version": "1.7.3-alpha.1",
3
3
  "package": "@mastra/convex",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -387,7 +387,6 @@ const results = await vectorStore.query({
387
387
 
388
388
  | Operator | Description |
389
389
  | -------- | --------------------- |
390
- | `$eq` | Equal to |
391
390
  | `$ne` | Not equal to |
392
391
  | `$gt` | Greater than |
393
392
  | `$gte` | Greater than or equal |
@@ -400,10 +399,9 @@ const results = await vectorStore.query({
400
399
 
401
400
  ## Architecture
402
401
 
403
- `ConvexVector` stores vectors in the `mastra_vectors` table with the following structure:
402
+ `ConvexVector` stores each index in its own table named `mastra_vector_{indexName}`. Each record has the following structure:
404
403
 
405
404
  - `id`: Unique vector identifier
406
- - `indexName`: Name of the index
407
405
  - `embedding`: The vector data (array of floats)
408
406
  - `metadata`: Optional JSON metadata
409
407