@mastra/convex 1.7.2-alpha.0 → 1.7.3-alpha.0

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.
@@ -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-alpha.0"
6
+ version: "1.7.3-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.7.2-alpha.0",
2
+ "version": "1.7.3-alpha.0",
3
3
  "package": "@mastra/convex",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_server = require("./server-D_scBUwi.cjs");
2
+ const require_server = require("./server-cdXFJzWz.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");
@@ -489,15 +489,43 @@ var ConvexDB = class extends _mastra_core_base.MastraBase {
489
489
  ...args
490
490
  });
491
491
  }
492
- async omUpdateActive(args) {
492
+ async omInitialize(record) {
493
+ return this.client.callStorage({
494
+ op: "omInitialize",
495
+ tableName: TABLE_OBSERVATIONAL_MEMORY$1,
496
+ record
497
+ });
498
+ }
499
+ async omCreateReflectionGeneration(args) {
500
+ return this.client.callStorage({
501
+ op: "omCreateReflectionGeneration",
502
+ tableName: TABLE_OBSERVATIONAL_MEMORY$1,
503
+ ...args
504
+ });
505
+ }
506
+ async omSetPendingMessageTokens(args) {
507
+ await this.client.callStorage({
508
+ op: "omSetPendingMessageTokens",
509
+ tableName: TABLE_OBSERVATIONAL_MEMORY$1,
510
+ ...args
511
+ });
512
+ }
513
+ async omSetBufferingObservationFlag(args) {
493
514
  await this.client.callStorage({
515
+ op: "omSetBufferingObservationFlag",
516
+ tableName: TABLE_OBSERVATIONAL_MEMORY$1,
517
+ ...args
518
+ });
519
+ }
520
+ async omUpdateActive(args) {
521
+ return this.client.callStorage({
494
522
  op: "omUpdateActive",
495
523
  tableName: TABLE_OBSERVATIONAL_MEMORY$1,
496
524
  ...args
497
525
  });
498
526
  }
499
527
  async omAppendBufferedChunk(args) {
500
- await this.client.callStorage({
528
+ return this.client.callStorage({
501
529
  op: "omAppendBufferedChunk",
502
530
  tableName: TABLE_OBSERVATIONAL_MEMORY$1,
503
531
  ...args
@@ -902,6 +930,17 @@ var ChannelsConvex = class extends _mastra_core_storage.ChannelsStorage {
902
930
  }
903
931
  };
904
932
  //#endregion
933
+ //#region ../../packages/_internal-core/dist/memory/index.js
934
+ /**
935
+ * Backs `updateActiveObservations` in adapters that implement `commitActiveObservations`.
936
+ * Callers of `updateActiveObservations` (which resolves `void`) can't see a commit result, so a
937
+ * write that was not applied throws instead of resolving as if it had committed.
938
+ */
939
+ function assertActiveObservationsApplied(result, id) {
940
+ if (result.applied) return;
941
+ 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`);
942
+ }
943
+ //#endregion
905
944
  //#region src/storage/domains/memory/index.ts
906
945
  function parseStoredThread(row) {
907
946
  return {
@@ -977,7 +1016,8 @@ function parseStoredOMRecord(doc) {
977
1016
  config: config ?? {},
978
1017
  metadata: metadata ?? void 0,
979
1018
  observedMessageIds: doc.observedMessageIds || void 0,
980
- observedTimezone: doc.observedTimezone || void 0
1019
+ observedTimezone: doc.observedTimezone || void 0,
1020
+ supersededBy: doc.supersededBy ?? null
981
1021
  };
982
1022
  }
983
1023
  var MemoryConvex = class extends _mastra_core_storage.MemoryStorage {
@@ -1465,9 +1505,9 @@ var MemoryConvex = class extends _mastra_core_storage.MemoryStorage {
1465
1505
  })).map((doc) => parseStoredOMRecord(doc));
1466
1506
  }
1467
1507
  async initializeObservationalMemory(input) {
1468
- const id = crypto.randomUUID();
1469
1508
  const now = /* @__PURE__ */ new Date();
1470
1509
  const lookupKey = this.getOMKey(input.threadId, input.resourceId);
1510
+ const id = crypto.randomUUID();
1471
1511
  const record = {
1472
1512
  id,
1473
1513
  scope: input.scope,
@@ -1489,38 +1529,36 @@ var MemoryConvex = class extends _mastra_core_storage.MemoryStorage {
1489
1529
  lastBufferedAtTokens: 0,
1490
1530
  lastBufferedAtTime: null,
1491
1531
  config: input.config,
1492
- observedTimezone: input.observedTimezone
1532
+ observedTimezone: input.observedTimezone,
1533
+ supersededBy: null
1493
1534
  };
1494
- await this.#db.insert({
1495
- tableName: TABLE_OBSERVATIONAL_MEMORY$1,
1496
- record: {
1497
- id,
1498
- lookupKey,
1499
- scope: input.scope,
1500
- resourceId: input.resourceId,
1501
- threadId: input.threadId || null,
1502
- activeObservations: "",
1503
- activeObservationsPendingUpdate: null,
1504
- originType: "initial",
1505
- config: JSON.stringify(input.config ?? {}),
1506
- generationCount: 0,
1507
- lastObservedAt: null,
1508
- lastReflectionAt: null,
1509
- pendingMessageTokens: 0,
1510
- totalTokensObserved: 0,
1511
- observationTokenCount: 0,
1512
- isObserving: false,
1513
- isReflecting: false,
1514
- isBufferingObservation: false,
1515
- isBufferingReflection: false,
1516
- lastBufferedAtTokens: 0,
1517
- lastBufferedAtTime: null,
1518
- observedTimezone: input.observedTimezone || null,
1519
- createdAt: now.toISOString(),
1520
- updatedAt: now.toISOString()
1521
- }
1535
+ const doc = await this.#db.omInitialize({
1536
+ id,
1537
+ lookupKey,
1538
+ scope: input.scope,
1539
+ resourceId: input.resourceId,
1540
+ threadId: input.threadId || null,
1541
+ activeObservations: "",
1542
+ activeObservationsPendingUpdate: null,
1543
+ originType: "initial",
1544
+ config: JSON.stringify(input.config ?? {}),
1545
+ generationCount: 0,
1546
+ lastObservedAt: null,
1547
+ lastReflectionAt: null,
1548
+ pendingMessageTokens: 0,
1549
+ totalTokensObserved: 0,
1550
+ observationTokenCount: 0,
1551
+ isObserving: false,
1552
+ isReflecting: false,
1553
+ isBufferingObservation: false,
1554
+ isBufferingReflection: false,
1555
+ lastBufferedAtTokens: 0,
1556
+ lastBufferedAtTime: null,
1557
+ observedTimezone: input.observedTimezone || null,
1558
+ createdAt: now.toISOString(),
1559
+ updatedAt: now.toISOString()
1522
1560
  });
1523
- return record;
1561
+ return doc ? parseStoredOMRecord(doc) : record;
1524
1562
  }
1525
1563
  async insertObservationalMemoryRecord(record) {
1526
1564
  const lookupKey = this.getOMKey(record.threadId, record.resourceId);
@@ -1556,22 +1594,30 @@ var MemoryConvex = class extends _mastra_core_storage.MemoryStorage {
1556
1594
  lastBufferedAtTime: record.lastBufferedAtTime ? toISO(record.lastBufferedAtTime) : null,
1557
1595
  observedTimezone: record.observedTimezone || null,
1558
1596
  metadata: record.metadata ? JSON.stringify(record.metadata) : null,
1597
+ supersededBy: record.supersededBy ?? null,
1559
1598
  createdAt: toISO(record.createdAt),
1560
1599
  updatedAt: toISO(record.updatedAt)
1561
1600
  }
1562
1601
  });
1563
1602
  }
1564
1603
  async updateActiveObservations(input) {
1565
- await this.#db.omUpdateActive({
1604
+ assertActiveObservationsApplied(await this.commitActiveObservations(input), input.id);
1605
+ }
1606
+ async commitActiveObservations(input) {
1607
+ return await this.#db.omUpdateActive({
1566
1608
  id: input.id,
1567
1609
  observations: input.observations,
1568
1610
  tokenCount: input.tokenCount,
1569
1611
  lastObservedAt: toISO(input.lastObservedAt),
1570
1612
  observedMessageIds: input.observedMessageIds ?? null,
1571
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1572
- });
1613
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
1614
+ ...input.expectedActiveObservations !== void 0 ? { expectedActiveObservations: input.expectedActiveObservations } : {}
1615
+ }) ?? { applied: true };
1573
1616
  }
1574
1617
  async updateBufferedObservations(input) {
1618
+ await this.appendBufferedObservations(input);
1619
+ }
1620
+ async appendBufferedObservations(input) {
1575
1621
  const chunk = {
1576
1622
  id: `ombuf-${crypto.randomUUID()}`,
1577
1623
  cycleId: input.chunk.cycleId,
@@ -1587,12 +1633,15 @@ var MemoryConvex = class extends _mastra_core_storage.MemoryStorage {
1587
1633
  extractedValues: input.chunk.extractedValues,
1588
1634
  extractionFailures: input.chunk.extractionFailures
1589
1635
  };
1590
- await this.#db.omAppendBufferedChunk({
1636
+ return await this.#db.omAppendBufferedChunk({
1591
1637
  id: input.id,
1592
1638
  chunk,
1593
1639
  lastBufferedAtTime: input.lastBufferedAtTime ? toISO(input.lastBufferedAtTime) : void 0,
1594
1640
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1595
- });
1641
+ }) ?? {
1642
+ persisted: true,
1643
+ recordId: input.id
1644
+ };
1596
1645
  }
1597
1646
  async swapBufferedToActive(input) {
1598
1647
  return this.#db.omSwapBuffered({
@@ -1606,65 +1655,33 @@ var MemoryConvex = class extends _mastra_core_storage.MemoryStorage {
1606
1655
  now: (/* @__PURE__ */ new Date()).toISOString()
1607
1656
  });
1608
1657
  }
1609
- async createReflectionGeneration(input) {
1610
- const id = crypto.randomUUID();
1611
- const now = /* @__PURE__ */ new Date();
1612
- const lookupKey = this.getOMKey(input.currentRecord.threadId, input.currentRecord.resourceId);
1613
- const record = {
1614
- id,
1615
- scope: input.currentRecord.scope,
1616
- threadId: input.currentRecord.threadId,
1617
- resourceId: input.currentRecord.resourceId,
1618
- createdAt: now,
1619
- updatedAt: now,
1620
- lastObservedAt: input.currentRecord.lastObservedAt,
1621
- originType: "reflection",
1622
- generationCount: input.currentRecord.generationCount + 1,
1623
- activeObservations: input.reflection,
1624
- totalTokensObserved: input.currentRecord.totalTokensObserved,
1625
- observationTokenCount: input.tokenCount,
1626
- pendingMessageTokens: 0,
1627
- isReflecting: false,
1628
- isObserving: false,
1629
- isBufferingObservation: false,
1630
- isBufferingReflection: false,
1631
- lastBufferedAtTokens: 0,
1632
- lastBufferedAtTime: null,
1633
- config: input.currentRecord.config,
1634
- metadata: input.currentRecord.metadata,
1635
- observedTimezone: input.currentRecord.observedTimezone
1658
+ /** The caller's snapshot as the server's rollover ops expect it. */
1659
+ #serializeCurrentRecord(currentRecord) {
1660
+ return {
1661
+ id: currentRecord.id,
1662
+ lookupKey: this.getOMKey(currentRecord.threadId, currentRecord.resourceId),
1663
+ scope: currentRecord.scope,
1664
+ threadId: currentRecord.threadId || null,
1665
+ resourceId: currentRecord.resourceId,
1666
+ config: JSON.stringify(currentRecord.config ?? {}),
1667
+ metadata: currentRecord.metadata ? JSON.stringify(currentRecord.metadata) : null,
1668
+ observedTimezone: currentRecord.observedTimezone || null,
1669
+ lastObservedAt: currentRecord.lastObservedAt ? toISO(currentRecord.lastObservedAt) : null,
1670
+ totalTokensObserved: currentRecord.totalTokensObserved,
1671
+ generationCount: currentRecord.generationCount,
1672
+ activeObservations: currentRecord.activeObservations ?? "",
1673
+ observationTokenCount: currentRecord.observationTokenCount ?? 0
1636
1674
  };
1637
- await this.#db.insert({
1638
- tableName: TABLE_OBSERVATIONAL_MEMORY$1,
1639
- record: {
1640
- id,
1641
- lookupKey,
1642
- scope: record.scope,
1643
- resourceId: record.resourceId,
1644
- threadId: record.threadId || null,
1645
- activeObservations: input.reflection,
1646
- activeObservationsPendingUpdate: null,
1647
- originType: "reflection",
1648
- config: JSON.stringify(record.config ?? {}),
1649
- generationCount: record.generationCount,
1650
- lastObservedAt: record.lastObservedAt ? toISO(record.lastObservedAt) : null,
1651
- lastReflectionAt: now.toISOString(),
1652
- pendingMessageTokens: 0,
1653
- totalTokensObserved: record.totalTokensObserved,
1654
- observationTokenCount: record.observationTokenCount,
1655
- isObserving: false,
1656
- isReflecting: false,
1657
- isBufferingObservation: false,
1658
- isBufferingReflection: false,
1659
- lastBufferedAtTokens: 0,
1660
- lastBufferedAtTime: null,
1661
- observedTimezone: record.observedTimezone || null,
1662
- metadata: record.metadata ? JSON.stringify(record.metadata) : null,
1663
- createdAt: now.toISOString(),
1664
- updatedAt: now.toISOString()
1665
- }
1675
+ }
1676
+ async createReflectionGeneration(input) {
1677
+ const doc = await this.#db.omCreateReflectionGeneration({
1678
+ currentRecord: this.#serializeCurrentRecord(input.currentRecord),
1679
+ newId: input.newRecordId ?? crypto.randomUUID(),
1680
+ reflection: input.reflection,
1681
+ tokenCount: input.tokenCount,
1682
+ now: (/* @__PURE__ */ new Date()).toISOString()
1666
1683
  });
1667
- return record;
1684
+ return doc ? parseStoredOMRecord(doc) : input.currentRecord;
1668
1685
  }
1669
1686
  async updateBufferedReflection(input) {
1670
1687
  await this.#db.omUpdateBufferedReflection({
@@ -1677,26 +1694,13 @@ var MemoryConvex = class extends _mastra_core_storage.MemoryStorage {
1677
1694
  });
1678
1695
  }
1679
1696
  async swapBufferedReflectionToActive(input) {
1680
- const { currentRecord } = input;
1681
- const serializedCurrentRecord = {
1682
- id: currentRecord.id,
1683
- lookupKey: this.getOMKey(currentRecord.threadId, currentRecord.resourceId),
1684
- scope: currentRecord.scope,
1685
- threadId: currentRecord.threadId || null,
1686
- resourceId: currentRecord.resourceId,
1687
- config: JSON.stringify(currentRecord.config ?? {}),
1688
- metadata: currentRecord.metadata ? JSON.stringify(currentRecord.metadata) : null,
1689
- observedTimezone: currentRecord.observedTimezone || null,
1690
- lastObservedAt: currentRecord.lastObservedAt ? toISO(currentRecord.lastObservedAt) : null,
1691
- totalTokensObserved: currentRecord.totalTokensObserved,
1692
- generationCount: currentRecord.generationCount
1693
- };
1694
- return parseStoredOMRecord(await this.#db.omSwapBufferedReflection({
1695
- currentRecord: serializedCurrentRecord,
1696
- newId: crypto.randomUUID(),
1697
+ const doc = await this.#db.omSwapBufferedReflection({
1698
+ currentRecord: this.#serializeCurrentRecord(input.currentRecord),
1699
+ newId: input.newRecordId ?? crypto.randomUUID(),
1697
1700
  tokenCount: input.tokenCount,
1698
1701
  now: (/* @__PURE__ */ new Date()).toISOString()
1699
- }));
1702
+ });
1703
+ return doc ? parseStoredOMRecord(doc) : input.currentRecord;
1700
1704
  }
1701
1705
  async setReflectingFlag(id, isReflecting) {
1702
1706
  if (!await this.#db.patch({
@@ -1719,15 +1723,12 @@ var MemoryConvex = class extends _mastra_core_storage.MemoryStorage {
1719
1723
  })) throw this.omRecordNotFound("SET_OBSERVING_FLAG", id);
1720
1724
  }
1721
1725
  async setBufferingObservationFlag(id, isBuffering, lastBufferedAtTokens) {
1722
- if (!await this.#db.patch({
1723
- tableName: "mastra_observational_memory",
1726
+ await this.#db.omSetBufferingObservationFlag({
1724
1727
  id,
1725
- record: {
1726
- isBufferingObservation: isBuffering,
1727
- ...lastBufferedAtTokens !== void 0 ? { lastBufferedAtTokens } : {},
1728
- updatedAt: /* @__PURE__ */ new Date()
1729
- }
1730
- })) throw this.omRecordNotFound("SET_BUFFERING_OBSERVATION_FLAG", id);
1728
+ isBuffering,
1729
+ ...lastBufferedAtTokens !== void 0 ? { lastBufferedAtTokens } : {},
1730
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1731
+ });
1731
1732
  }
1732
1733
  async setBufferingReflectionFlag(id, isBuffering) {
1733
1734
  if (!await this.#db.patch({
@@ -1750,14 +1751,11 @@ var MemoryConvex = class extends _mastra_core_storage.MemoryStorage {
1750
1751
  tokenCount
1751
1752
  }
1752
1753
  });
1753
- if (!await this.#db.patch({
1754
- tableName: "mastra_observational_memory",
1754
+ await this.#db.omSetPendingMessageTokens({
1755
1755
  id,
1756
- record: {
1757
- pendingMessageTokens: tokenCount,
1758
- updatedAt: /* @__PURE__ */ new Date()
1759
- }
1760
- })) throw this.omRecordNotFound("SET_PENDING_MESSAGE_TOKENS", id);
1756
+ tokenCount,
1757
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1758
+ });
1761
1759
  }
1762
1760
  async clearObservationalMemory(threadId, resourceId) {
1763
1761
  const lookupKey = this.getOMKey(threadId, resourceId);