@mastra/convex 1.7.5 → 1.7.6

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,4 +1,3 @@
1
- //#region src/memory/index.d.ts
2
1
  /**
3
2
  * Shared rules for observational memory lifecycle writes. Every storage adapter applies
4
3
  * these inside its own atomic section (lock, transaction, or conditional update), so the
@@ -9,18 +8,18 @@
9
8
  * into the table schema they get from `@mastra/core`, so the columns exist even when the
10
9
  * installed core predates them.
11
10
  */
12
- declare const OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS: {
11
+ export declare const OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS: {
13
12
  readonly supersededBy: {
14
13
  readonly type: 'text';
15
14
  readonly nullable: true;
16
15
  };
17
16
  };
18
17
  /** `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;
18
+ export declare function withObservationalMemoryLifecycleColumns<T extends object>(schema: T | undefined): (T & typeof OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS) | undefined;
20
19
  /**
21
20
  * Result of `commitActiveObservations`.
22
21
  */
23
- interface UpdateActiveObservationsResult {
22
+ export interface UpdateActiveObservationsResult {
24
23
  /** Whether the observations were written. */
25
24
  applied: boolean;
26
25
  /**
@@ -38,14 +37,14 @@ interface UpdateActiveObservationsResult {
38
37
  * the head's cursor. Chunks carry `lastObservedAt = max message time + 1ms`, so a chunk is
39
38
  * wholly covered iff `head.lastObservedAt >= chunk.lastObservedAt - 1ms`.
40
39
  */
41
- interface UpdateBufferedObservationsResult {
40
+ export interface UpdateBufferedObservationsResult {
42
41
  /** Whether the chunk was stored. */
43
42
  persisted: boolean;
44
43
  /** The record the chunk was written to (or would have been written to). */
45
44
  recordId: string;
46
45
  }
47
46
  /** The fields of an observational memory record that decide head order. */
48
- interface ObservationalMemoryHeadOrderFields {
47
+ export interface ObservationalMemoryHeadOrderFields {
49
48
  generationCount: number;
50
49
  createdAt: Date | string;
51
50
  id: string;
@@ -54,16 +53,16 @@ interface ObservationalMemoryHeadOrderFields {
54
53
  * Canonical head order: `generationCount DESC, createdAt ASC, id ASC`.
55
54
  * Returns a negative number when `a` sorts before `b` (i.e. `a` is the better head candidate).
56
55
  */
57
- declare function compareObservationalMemoryHeadOrder(a: ObservationalMemoryHeadOrderFields, b: ObservationalMemoryHeadOrderFields): number;
56
+ export declare function compareObservationalMemoryHeadOrder(a: ObservationalMemoryHeadOrderFields, b: ObservationalMemoryHeadOrderFields): number;
58
57
  /**
59
58
  * A buffered chunk stores `lastObservedAt = max message time + 1ms`. It is wholly covered
60
59
  * (every message it observed is already at or before the cursor) iff
61
60
  * `cursor >= chunk.lastObservedAt - 1ms`.
62
61
  */
63
- declare function isBufferedChunkCoveredByCursor(chunkLastObservedAt: Date | string, cursor: Date | string | null | undefined): boolean;
62
+ export declare function isBufferedChunkCoveredByCursor(chunkLastObservedAt: Date | string, cursor: Date | string | null | undefined): boolean;
64
63
  /** 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 {
64
+ export declare function maxObservationCursor(a: Date | string | null | undefined, b: Date | string | null | undefined): Date | undefined;
65
+ export interface ReflectionTextPlan {
67
66
  /** `equal`: stored text equals the snapshot. `append`: observations were appended after the snapshot. */
68
67
  mode: 'equal' | 'append';
69
68
  observations: string;
@@ -78,7 +77,7 @@ interface ReflectionTextPlan {
78
77
  * after the reflection, and its tokens are added.
79
78
  * - Anything else (a non-append rewrite): `null` — the reflection must not be applied.
80
79
  */
81
- declare function planReflectionGenerationText(input: {
80
+ export declare function planReflectionGenerationText(input: {
82
81
  storedObservations: string;
83
82
  storedObservationTokenCount: number;
84
83
  snapshotObservations: string;
@@ -91,12 +90,10 @@ declare function planReflectionGenerationText(input: {
91
90
  * Callers of `updateActiveObservations` (which resolves `void`) can't see a commit result, so a
92
91
  * write that was not applied throws instead of resolving as if it had committed.
93
92
  */
94
- declare function assertActiveObservationsApplied(result: UpdateActiveObservationsResult, id: string): void;
93
+ export declare function assertActiveObservationsApplied(result: UpdateActiveObservationsResult, id: string): void;
95
94
  /**
96
95
  * Whether the stored text can still accept a reflection built from `snapshot`
97
96
  * (equal, or only appended to since).
98
97
  */
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 };
98
+ export declare function isAppendOnlySince(storedObservations: string, snapshotObservations: string): boolean;
102
99
  //# sourceMappingURL=index.d.ts.map
@@ -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.5"
6
+ version: "1.7.6"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.7.5",
2
+ "version": "1.7.6",
3
3
  "package": "@mastra/convex",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -346,7 +346,7 @@ Query results are returned in this format:
346
346
  interface QueryResult {
347
347
  id: string
348
348
  score: number
349
- metadata: Record<string, any>
349
+ metadata?: Record<string, any>
350
350
  vector?: number[] // Only included if includeVector is true
351
351
  }
352
352
  ```
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_server = require("./server-BxQKtmhb.cjs");
2
+ const require_server = require("./server-BwpzJLxa.cjs");
3
3
  const require_schema = require("./schema.cjs");
4
4
  let _mastra_core_cache = require("@mastra/core/cache");
5
5
  let _mastra_core_storage = require("@mastra/core/storage");
@@ -8,7 +8,7 @@ let _mastra_core_agent = require("@mastra/core/agent");
8
8
  let _mastra_core_error = require("@mastra/core/error");
9
9
  let _mastra_core_vector = require("@mastra/core/vector");
10
10
  let _mastra_core_storage_constants = require("@mastra/core/storage/constants");
11
- //#region src/cache/client.ts
11
+ // src/cache/client.ts
12
12
  const DEFAULT_CACHE_FUNCTION = "mastra/cache:handle";
13
13
  const DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
14
14
  const trimTrailingSlashes = (value) => {
@@ -86,8 +86,7 @@ var ConvexCacheClient = class {
86
86
  return result;
87
87
  }
88
88
  };
89
- //#endregion
90
- //#region src/cache/index.ts
89
+ // src/cache/index.ts
91
90
  const DEFAULT_KEY_PREFIX = "mastra:cache:";
92
91
  const DEFAULT_TTL_MS = 3e5;
93
92
  const MAX_CACHE_OPERATION_BATCHES = 1e3;
@@ -175,8 +174,7 @@ var ConvexServerCache = class extends _mastra_core_cache.MastraServerCache {
175
174
  }));
176
175
  }
177
176
  };
178
- //#endregion
179
- //#region src/storage/client.ts
177
+ // src/storage/client.ts
180
178
  const DEFAULT_STORAGE_FUNCTION = "mastra/storage:handle";
181
179
  var ConvexAdminClient = class {
182
180
  deploymentUrl;
@@ -253,8 +251,7 @@ var ConvexAdminClient = class {
253
251
  return result;
254
252
  }
255
253
  };
256
- //#endregion
257
- //#region src/storage/run-fencing.ts
254
+ // src/storage/run-fencing.ts
258
255
  const READ_OPS = /* @__PURE__ */ new Set([
259
256
  "load",
260
257
  "loadMany",
@@ -412,16 +409,14 @@ async function pruneRunClaims(client, tableName, column, cutoff, limit) {
412
409
  }, "prune");
413
410
  return result;
414
411
  }
415
- //#endregion
416
- //#region src/storage/types.ts
412
+ // src/storage/types.ts
417
413
  /**
418
414
  * Observational memory table name. Defined locally (not value-imported from
419
415
  * core) following the mongodb/pg convention: core exports the constant, but
420
416
  * OM is optional and the constant is absent from older cores in the peer range.
421
417
  */
422
418
  const TABLE_OBSERVATIONAL_MEMORY$1 = "mastra_observational_memory";
423
- //#endregion
424
- //#region src/storage/db/index.ts
419
+ // src/storage/db/index.ts
425
420
  const LOAD_MANY_REQUEST_BATCH_SIZE = 10;
426
421
  /**
427
422
  * Resolves ConvexDomainConfig to a ConvexAdminClient.
@@ -741,8 +736,7 @@ var ConvexDB = class ConvexDB extends _mastra_core_base.MastraBase {
741
736
  return normalized;
742
737
  }
743
738
  };
744
- //#endregion
745
- //#region src/storage/domains/background-tasks/index.ts
739
+ // src/storage/domains/background-tasks/index.ts
746
740
  function serializeJson$1(v) {
747
741
  if (v === void 0 || v === null) return null;
748
742
  return JSON.stringify(v);
@@ -956,8 +950,7 @@ var BackgroundTasksConvex = class extends _mastra_core_storage.BackgroundTasksSt
956
950
  return total;
957
951
  }
958
952
  };
959
- //#endregion
960
- //#region src/storage/domains/channels/index.ts
953
+ // src/storage/domains/channels/index.ts
961
954
  const statusPriority = {
962
955
  active: 0,
963
956
  pending: 1,
@@ -1094,8 +1087,7 @@ var ChannelsConvex = class extends _mastra_core_storage.ChannelsStorage {
1094
1087
  await this.#db.deleteMany(_mastra_core_storage.TABLE_CHANNEL_CONFIG, [platform]);
1095
1088
  }
1096
1089
  };
1097
- //#endregion
1098
- //#region ../../packages/_internal-core/dist/memory/index.js
1090
+ // ../../packages/_internal-core/dist/memory/index.js
1099
1091
  /**
1100
1092
  * Backs `updateActiveObservations` in adapters that implement `commitActiveObservations`.
1101
1093
  * Callers of `updateActiveObservations` (which resolves `void`) can't see a commit result, so a
@@ -1105,8 +1097,7 @@ function assertActiveObservationsApplied(result, id) {
1105
1097
  if (result.applied) return;
1106
1098
  throw new Error(result.reason === "retired" ? `Observational memory record ${id} was superseded by a newer generation; observations were not written` : `Observational memory record ${id} changed since the observations were composed; observations were not written`);
1107
1099
  }
1108
- //#endregion
1109
- //#region src/storage/domains/memory/index.ts
1100
+ // src/storage/domains/memory/index.ts
1110
1101
  function parseStoredThread(row) {
1111
1102
  return {
1112
1103
  ...row,
@@ -1993,8 +1984,7 @@ var MemoryConvex = class MemoryConvex extends _mastra_core_storage.MemoryStorage
1993
1984
  });
1994
1985
  }
1995
1986
  };
1996
- //#endregion
1997
- //#region src/storage/domains/schedules/index.ts
1987
+ // src/storage/domains/schedules/index.ts
1998
1988
  const SCHEDULE_LIST_LIMIT = 8e3;
1999
1989
  function serializeJson(value) {
2000
1990
  return JSON.stringify(value);
@@ -2211,8 +2201,7 @@ var SchedulesConvex = class extends _mastra_core_storage.SchedulesStorage {
2211
2201
  })).map(recordToTrigger);
2212
2202
  }
2213
2203
  };
2214
- //#endregion
2215
- //#region src/storage/domains/scores/index.ts
2204
+ // src/storage/domains/scores/index.ts
2216
2205
  var ScoresConvex = class extends _mastra_core_storage.ScoresStorage {
2217
2206
  #db;
2218
2207
  constructor(config) {
@@ -2306,8 +2295,7 @@ var ScoresConvex = class extends _mastra_core_storage.ScoresStorage {
2306
2295
  };
2307
2296
  }
2308
2297
  };
2309
- //#endregion
2310
- //#region src/storage/domains/workflows/index.ts
2298
+ // src/storage/domains/workflows/index.ts
2311
2299
  var WorkflowsConvex = class WorkflowsConvex extends _mastra_core_storage.WorkflowsStorage {
2312
2300
  /**
2313
2301
  * Tables `prune()` can clean up. Run ownership records anchor on `updatedAt` (epoch ms), which every
@@ -2501,8 +2489,7 @@ var WorkflowsConvex = class WorkflowsConvex extends _mastra_core_storage.Workflo
2501
2489
  return JSON.parse(JSON.stringify(run.snapshot));
2502
2490
  }
2503
2491
  };
2504
- //#endregion
2505
- //#region src/storage/index.ts
2492
+ // src/storage/index.ts
2506
2493
  /**
2507
2494
  * Type guard for pre-configured client config
2508
2495
  */
@@ -2548,8 +2535,7 @@ var ConvexStore = class extends _mastra_core_storage.MastraCompositeStore {
2548
2535
  };
2549
2536
  }
2550
2537
  };
2551
- //#endregion
2552
- //#region src/vector/index.ts
2538
+ // src/vector/index.ts
2553
2539
  const INDEX_METADATA_TABLE = "mastra_vector_indexes";
2554
2540
  const VECTOR_QUERY_PAGE_SIZE = 256;
2555
2541
  var ConvexVector = class extends _mastra_core_vector.MastraVector {
@@ -2817,8 +2803,7 @@ function cosineSimilarity(a, b) {
2817
2803
  if (magA === 0 || magB === 0) return -1;
2818
2804
  return dot / (Math.sqrt(magA) * Math.sqrt(magB));
2819
2805
  }
2820
- //#endregion
2821
- //#region src/vector/native.ts
2806
+ // src/vector/native.ts
2822
2807
  const DEFAULT_VECTOR_INDEX = "by_embedding";
2823
2808
  const DEFAULT_ID_FIELD = "id";
2824
2809
  const DEFAULT_ID_INDEX = "by_record_id";
@@ -3003,7 +2988,6 @@ var ConvexNativeVector = class extends _mastra_core_vector.MastraVector {
3003
2988
  return typeof metadata === "object" && metadata !== null && !Array.isArray(metadata);
3004
2989
  }
3005
2990
  };
3006
- //#endregion
3007
2991
  exports.ConvexCacheClient = ConvexCacheClient;
3008
2992
  exports.ConvexNativeVector = ConvexNativeVector;
3009
2993
  exports.ConvexServerCache = ConvexServerCache;