@mastra/libsql 1.6.2 → 1.6.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @mastra/libsql
2
2
 
3
+ ## 1.6.3-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Added atomic `updateWorkflowResults` and `updateWorkflowState` to safely merge concurrent step results into workflow snapshots. ([#12575](https://github.com/mastra-ai/mastra/pull/12575))
8
+
9
+ - Added `insertObservationalMemoryRecord()` to PostgreSQL, LibSQL, MongoDB, and Upstash adapters for OM cloning support. ([#13569](https://github.com/mastra-ai/mastra/pull/13569))
10
+
11
+ - Updated dependencies [[`504fc8b`](https://github.com/mastra-ai/mastra/commit/504fc8b9d0ddab717577ad3bf9c95ea4bd5377bd), [`f9c150b`](https://github.com/mastra-ai/mastra/commit/f9c150b7595ad05ad9cc9a11098e2944361e8c22), [`88de7e8`](https://github.com/mastra-ai/mastra/commit/88de7e8dfe4b7e1951a9e441bb33136e705ce24e), [`edee4b3`](https://github.com/mastra-ai/mastra/commit/edee4b37dff0af515fc7cc0e8d71ee39e6a762f0), [`3790c75`](https://github.com/mastra-ai/mastra/commit/3790c7578cc6a47d854eb12d89e6b1912867fe29), [`e7a235b`](https://github.com/mastra-ai/mastra/commit/e7a235be6472e0c870ed6c791ddb17c492dc188b), [`d51d298`](https://github.com/mastra-ai/mastra/commit/d51d298953967aab1f58ec965b644d109214f085), [`6dbeeb9`](https://github.com/mastra-ai/mastra/commit/6dbeeb94a8b1eebb727300d1a98961f882180794), [`d5f0d8d`](https://github.com/mastra-ai/mastra/commit/d5f0d8d6a03e515ddaa9b5da19b7e44b8357b07b), [`09c3b18`](https://github.com/mastra-ai/mastra/commit/09c3b1802ff14e243a8a8baea327440bc8cc2e32), [`b896379`](https://github.com/mastra-ai/mastra/commit/b8963791c6afa79484645fcec596a201f936b9a2), [`85c84eb`](https://github.com/mastra-ai/mastra/commit/85c84ebb78aebfcba9d209c8e152b16d7a00cb71), [`a89272a`](https://github.com/mastra-ai/mastra/commit/a89272a5d71939b9fcd284e6a6dc1dd091a6bdcf), [`ee9c8df`](https://github.com/mastra-ai/mastra/commit/ee9c8df644f19d055af5f496bf4942705f5a47b7), [`77b4a25`](https://github.com/mastra-ai/mastra/commit/77b4a254e51907f8ff3a3ba95596a18e93ae4b35), [`276246e`](https://github.com/mastra-ai/mastra/commit/276246e0b9066a1ea48bbc70df84dbe528daaf99), [`08ecfdb`](https://github.com/mastra-ai/mastra/commit/08ecfdbdad6fb8285deef86a034bdf4a6047cfca), [`d5f628c`](https://github.com/mastra-ai/mastra/commit/d5f628ca86c6f6f3ff1035d52f635df32dd81cab), [`524c0f3`](https://github.com/mastra-ai/mastra/commit/524c0f3c434c3d9d18f66338dcef383d6161b59c), [`c18a0e9`](https://github.com/mastra-ai/mastra/commit/c18a0e9cef1e4ca004b2963d35e4cfc031971eac), [`4bd21ea`](https://github.com/mastra-ai/mastra/commit/4bd21ea43d44d0a0427414fc047577f9f0aa3bec), [`115a7a4`](https://github.com/mastra-ai/mastra/commit/115a7a47db5e9896fec12ae6507501adb9ec89bf), [`22a48ae`](https://github.com/mastra-ai/mastra/commit/22a48ae2513eb54d8d79dad361fddbca97a155e8), [`3c6ef79`](https://github.com/mastra-ai/mastra/commit/3c6ef798481e00d6d22563be2de98818fd4dd5e0), [`9311c17`](https://github.com/mastra-ai/mastra/commit/9311c17d7a0640d9c4da2e71b814dc67c57c6369), [`7edf78f`](https://github.com/mastra-ai/mastra/commit/7edf78f80422c43e84585f08ba11df0d4d0b73c5), [`1c4221c`](https://github.com/mastra-ai/mastra/commit/1c4221cf6032ec98d0e094d4ee11da3e48490d96), [`d25b9ea`](https://github.com/mastra-ai/mastra/commit/d25b9eabd400167255a97b690ffbc4ee4097ded5), [`fe1ce5c`](https://github.com/mastra-ai/mastra/commit/fe1ce5c9211c03d561606fda95cbfe7df1d9a9b5), [`b03c0e0`](https://github.com/mastra-ai/mastra/commit/b03c0e0389a799523929a458b0509c9e4244d562), [`0a8366b`](https://github.com/mastra-ai/mastra/commit/0a8366b0a692fcdde56c4d526e4cf03c502ae4ac), [`85664e9`](https://github.com/mastra-ai/mastra/commit/85664e9fd857320fbc245e301f764f45f66f32a3), [`bc79650`](https://github.com/mastra-ai/mastra/commit/bc796500c6e0334faa158a96077e3fb332274869), [`9257d01`](https://github.com/mastra-ai/mastra/commit/9257d01d1366d81f84c582fe02b5e200cf9621f4), [`3a3a59e`](https://github.com/mastra-ai/mastra/commit/3a3a59e8ffaa6a985fe3d9a126a3f5ade11a6724), [`3108d4e`](https://github.com/mastra-ai/mastra/commit/3108d4e649c9fddbf03253a6feeb388a5fa9fa5a), [`0c33b2c`](https://github.com/mastra-ai/mastra/commit/0c33b2c9db537f815e1c59e2c898ffce2e395a79), [`191e5bd`](https://github.com/mastra-ai/mastra/commit/191e5bd29b82f5bda35243945790da7bc7b695c2), [`f77cd94`](https://github.com/mastra-ai/mastra/commit/f77cd94c44eabed490384e7d19232a865e13214c), [`e8135c7`](https://github.com/mastra-ai/mastra/commit/e8135c7e300dac5040670eec7eab896ac6092e30), [`daca48f`](https://github.com/mastra-ai/mastra/commit/daca48f0fb17b7ae0b62a2ac40cf0e491b2fd0b7), [`257d14f`](https://github.com/mastra-ai/mastra/commit/257d14faca5931f2e4186fc165b6f0b1f915deee), [`352f25d`](https://github.com/mastra-ai/mastra/commit/352f25da316b24cdd5b410fd8dddf6a8b763da2a), [`93477d0`](https://github.com/mastra-ai/mastra/commit/93477d0769b8a13ea5ed73d508d967fb23eaeed9), [`31c78b3`](https://github.com/mastra-ai/mastra/commit/31c78b3eb28f58a8017f1dcc795c33214d87feac), [`0bc0720`](https://github.com/mastra-ai/mastra/commit/0bc07201095791858087cc56f353fcd65e87ab54), [`36516ac`](https://github.com/mastra-ai/mastra/commit/36516aca1021cbeb42e74751b46a2614101f37c8), [`e947652`](https://github.com/mastra-ai/mastra/commit/e9476527fdecb4449e54570e80dfaf8466901254), [`3c6ef79`](https://github.com/mastra-ai/mastra/commit/3c6ef798481e00d6d22563be2de98818fd4dd5e0), [`9257d01`](https://github.com/mastra-ai/mastra/commit/9257d01d1366d81f84c582fe02b5e200cf9621f4), [`ec248f6`](https://github.com/mastra-ai/mastra/commit/ec248f6b56e8a037c066c49b2178e2507471d988)]:
12
+ - @mastra/core@1.9.0-alpha.0
13
+
3
14
  ## 1.6.2
4
15
 
5
16
  ### Patch Changes
package/LICENSE.md CHANGED
@@ -1,3 +1,18 @@
1
+ Portions of this software are licensed as follows:
2
+
3
+ - All content that resides under any directory named "ee/" within this
4
+ repository, including but not limited to:
5
+ - `packages/core/src/auth/ee/`
6
+ - `packages/server/src/server/auth/ee/`
7
+ is licensed under the license defined in `ee/LICENSE`.
8
+
9
+ - All third-party components incorporated into the Mastra Software are
10
+ licensed under the original license provided by the owner of the
11
+ applicable component.
12
+
13
+ - Content outside of the above-mentioned directories or restrictions is
14
+ available under the "Apache License 2.0" as defined below.
15
+
1
16
  # Apache License 2.0
2
17
 
3
18
  Copyright (c) 2025 Kepler Software, Inc.
@@ -3,7 +3,7 @@ name: mastra-libsql
3
3
  description: Documentation for @mastra/libsql. Use when working with @mastra/libsql APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/libsql"
6
- version: "1.6.2"
6
+ version: "1.6.3-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.6.2",
2
+ "version": "1.6.3-alpha.0",
3
3
  "package": "@mastra/libsql",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -5168,7 +5168,8 @@ var MemoryLibSQL = class extends storage.MemoryStorage {
5168
5168
  "isBufferingObservation",
5169
5169
  "isBufferingReflection",
5170
5170
  "lastBufferedAtTokens",
5171
- "lastBufferedAtTime"
5171
+ "lastBufferedAtTime",
5172
+ "metadata"
5172
5173
  ]
5173
5174
  });
5174
5175
  }
@@ -6138,9 +6139,11 @@ var MemoryLibSQL = class extends storage.MemoryStorage {
6138
6139
  ]
6139
6140
  });
6140
6141
  const clonedMessages = [];
6142
+ const messageIdMap = {};
6141
6143
  const targetResourceId = resourceId || sourceThread.resourceId;
6142
6144
  for (const sourceMsg of sourceMessages) {
6143
6145
  const newMessageId = crypto.randomUUID();
6146
+ messageIdMap[sourceMsg.id] = newMessageId;
6144
6147
  const contentStr = sourceMsg.content;
6145
6148
  let parsedContent;
6146
6149
  try {
@@ -6174,7 +6177,8 @@ var MemoryLibSQL = class extends storage.MemoryStorage {
6174
6177
  await tx.commit();
6175
6178
  return {
6176
6179
  thread: newThread,
6177
- clonedMessages
6180
+ clonedMessages,
6181
+ messageIdMap
6178
6182
  };
6179
6183
  } catch (error) {
6180
6184
  await tx.rollback();
@@ -6364,6 +6368,68 @@ var MemoryLibSQL = class extends storage.MemoryStorage {
6364
6368
  );
6365
6369
  }
6366
6370
  }
6371
+ async insertObservationalMemoryRecord(record) {
6372
+ try {
6373
+ const lookupKey = this.getOMKey(record.threadId, record.resourceId);
6374
+ await this.#client.execute({
6375
+ sql: `INSERT INTO "${OM_TABLE}" (
6376
+ id, "lookupKey", scope, "resourceId", "threadId",
6377
+ "activeObservations", "activeObservationsPendingUpdate",
6378
+ "originType", config, "generationCount", "lastObservedAt", "lastReflectionAt",
6379
+ "pendingMessageTokens", "totalTokensObserved", "observationTokenCount",
6380
+ "observedMessageIds", "bufferedObservationChunks",
6381
+ "bufferedReflection", "bufferedReflectionTokens", "bufferedReflectionInputTokens",
6382
+ "reflectedObservationLineCount",
6383
+ "isObserving", "isReflecting", "isBufferingObservation", "isBufferingReflection",
6384
+ "lastBufferedAtTokens", "lastBufferedAtTime",
6385
+ "observedTimezone", metadata, "createdAt", "updatedAt"
6386
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
6387
+ args: [
6388
+ record.id,
6389
+ lookupKey,
6390
+ record.scope,
6391
+ record.resourceId,
6392
+ record.threadId || null,
6393
+ record.activeObservations || "",
6394
+ null,
6395
+ record.originType || "initial",
6396
+ record.config ? JSON.stringify(record.config) : null,
6397
+ record.generationCount || 0,
6398
+ record.lastObservedAt ? record.lastObservedAt.toISOString() : null,
6399
+ null,
6400
+ record.pendingMessageTokens || 0,
6401
+ record.totalTokensObserved || 0,
6402
+ record.observationTokenCount || 0,
6403
+ record.observedMessageIds ? JSON.stringify(record.observedMessageIds) : null,
6404
+ record.bufferedObservationChunks ? JSON.stringify(record.bufferedObservationChunks) : null,
6405
+ record.bufferedReflection || null,
6406
+ record.bufferedReflectionTokens ?? null,
6407
+ record.bufferedReflectionInputTokens ?? null,
6408
+ record.reflectedObservationLineCount ?? null,
6409
+ record.isObserving || false,
6410
+ record.isReflecting || false,
6411
+ record.isBufferingObservation || false,
6412
+ record.isBufferingReflection || false,
6413
+ record.lastBufferedAtTokens || 0,
6414
+ record.lastBufferedAtTime ? record.lastBufferedAtTime.toISOString() : null,
6415
+ record.observedTimezone || null,
6416
+ record.metadata ? JSON.stringify(record.metadata) : null,
6417
+ record.createdAt.toISOString(),
6418
+ record.updatedAt.toISOString()
6419
+ ]
6420
+ });
6421
+ } catch (error$1) {
6422
+ throw new error.MastraError(
6423
+ {
6424
+ id: storage.createStorageErrorId("LIBSQL", "INSERT_OBSERVATIONAL_MEMORY_RECORD", "FAILED"),
6425
+ domain: error.ErrorDomain.STORAGE,
6426
+ category: error.ErrorCategory.THIRD_PARTY,
6427
+ details: { id: record.id, threadId: record.threadId, resourceId: record.resourceId }
6428
+ },
6429
+ error$1
6430
+ );
6431
+ }
6432
+ }
6367
6433
  async updateActiveObservations(input) {
6368
6434
  try {
6369
6435
  const now = /* @__PURE__ */ new Date();
@@ -6448,8 +6514,8 @@ var MemoryLibSQL = class extends storage.MemoryStorage {
6448
6514
  "originType", config, "generationCount", "lastObservedAt", "lastReflectionAt",
6449
6515
  "pendingMessageTokens", "totalTokensObserved", "observationTokenCount",
6450
6516
  "isObserving", "isReflecting", "isBufferingObservation", "isBufferingReflection", "lastBufferedAtTokens", "lastBufferedAtTime",
6451
- "observedTimezone", "createdAt", "updatedAt"
6452
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
6517
+ "observedTimezone", metadata, "createdAt", "updatedAt"
6518
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
6453
6519
  args: [
6454
6520
  id,
6455
6521
  lookupKey,
@@ -6479,6 +6545,7 @@ var MemoryLibSQL = class extends storage.MemoryStorage {
6479
6545
  null,
6480
6546
  // lastBufferedAtTime
6481
6547
  record.observedTimezone || null,
6548
+ record.metadata ? JSON.stringify(record.metadata) : null,
6482
6549
  now.toISOString(),
6483
6550
  now.toISOString()
6484
6551
  ]
@@ -9276,6 +9343,9 @@ var WorkflowsLibSQL = class extends storage.WorkflowsStorage {
9276
9343
  (err) => this.logger.warn("LibSQL Workflows: Failed to setup PRAGMA settings.", err)
9277
9344
  );
9278
9345
  }
9346
+ supportsConcurrentUpdates() {
9347
+ return true;
9348
+ }
9279
9349
  parseWorkflowRun(row) {
9280
9350
  let parsedSnapshot = row.snapshot;
9281
9351
  if (typeof parsedSnapshot === "string") {