@mastra/libsql 0.10.1-alpha.1 → 0.10.1-alpha.2

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,23 +1,23 @@
1
1
 
2
- > @mastra/libsql@0.10.1-alpha.1 build /home/runner/work/mastra/mastra/stores/libsql
2
+ > @mastra/libsql@0.10.1-alpha.2 build /home/runner/work/mastra/mastra/stores/libsql
3
3
  > tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
4
4
 
5
5
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v8.4.0
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 9697ms
9
+ TSC ⚡️ Build success in 7809ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.8.3
13
13
  Writing package typings: /home/runner/work/mastra/mastra/stores/libsql/dist/_tsup-dts-rollup.d.ts
14
14
  Analysis will use the bundled TypeScript version 5.8.3
15
15
  Writing package typings: /home/runner/work/mastra/mastra/stores/libsql/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 9670ms
16
+ DTS ⚡️ Build success in 9677ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- CJS dist/index.cjs 48.56 KB
21
- CJS ⚡️ Build success in 1141ms
22
- ESM dist/index.js 48.36 KB
23
- ESM ⚡️ Build success in 1142ms
20
+ ESM dist/index.js 48.69 KB
21
+ ESM ⚡️ Build success in 1039ms
22
+ CJS dist/index.cjs 48.90 KB
23
+ CJS ⚡️ Build success in 1048ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @mastra/libsql
2
2
 
3
+ ## 0.10.1-alpha.2
4
+
5
+ ### Patch Changes
6
+
7
+ - c5bf1ce: Add backwards compat code for new MessageList in storage
8
+ - Updated dependencies [c5bf1ce]
9
+ - Updated dependencies [12b7002]
10
+ - @mastra/core@0.10.2-alpha.4
11
+
3
12
  ## 0.10.1-alpha.1
4
13
 
5
14
  ### Patch Changes
@@ -6,6 +6,7 @@ import type { DescribeIndexParams } from '@mastra/core/vector';
6
6
  import type { EvalRow } from '@mastra/core/storage';
7
7
  import type { IndexStats } from '@mastra/core/vector';
8
8
  import type { InValue } from '@libsql/client';
9
+ import type { MastraMessageV1 } from '@mastra/core/memory';
9
10
  import type { MastraMessageV2 } from '@mastra/core/agent';
10
11
  import { MastraStorage } from '@mastra/core/storage';
11
12
  import { MastraVector } from '@mastra/core/vector';
@@ -122,9 +123,19 @@ declare class LibSQLStore extends MastraStorage {
122
123
  threadId: string;
123
124
  }): Promise<void>;
124
125
  private parseRow;
125
- getMessages<T extends MastraMessageV2[]>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T>;
126
- saveMessages({ messages }: {
126
+ getMessages(args: StorageGetMessagesArg & {
127
+ format?: 'v1';
128
+ }): Promise<MastraMessageV1[]>;
129
+ getMessages(args: StorageGetMessagesArg & {
130
+ format: 'v2';
131
+ }): Promise<MastraMessageV2[]>;
132
+ saveMessages(args: {
133
+ messages: MastraMessageV1[];
134
+ format?: undefined | 'v1';
135
+ }): Promise<MastraMessageV1[]>;
136
+ saveMessages(args: {
127
137
  messages: MastraMessageV2[];
138
+ format: 'v2';
128
139
  }): Promise<MastraMessageV2[]>;
129
140
  private transformEvalRow;
130
141
  getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
@@ -6,6 +6,7 @@ import type { DescribeIndexParams } from '@mastra/core/vector';
6
6
  import type { EvalRow } from '@mastra/core/storage';
7
7
  import type { IndexStats } from '@mastra/core/vector';
8
8
  import type { InValue } from '@libsql/client';
9
+ import type { MastraMessageV1 } from '@mastra/core/memory';
9
10
  import type { MastraMessageV2 } from '@mastra/core/agent';
10
11
  import { MastraStorage } from '@mastra/core/storage';
11
12
  import { MastraVector } from '@mastra/core/vector';
@@ -122,9 +123,19 @@ declare class LibSQLStore extends MastraStorage {
122
123
  threadId: string;
123
124
  }): Promise<void>;
124
125
  private parseRow;
125
- getMessages<T extends MastraMessageV2[]>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T>;
126
- saveMessages({ messages }: {
126
+ getMessages(args: StorageGetMessagesArg & {
127
+ format?: 'v1';
128
+ }): Promise<MastraMessageV1[]>;
129
+ getMessages(args: StorageGetMessagesArg & {
130
+ format: 'v2';
131
+ }): Promise<MastraMessageV2[]>;
132
+ saveMessages(args: {
133
+ messages: MastraMessageV1[];
134
+ format?: undefined | 'v1';
135
+ }): Promise<MastraMessageV1[]>;
136
+ saveMessages(args: {
127
137
  messages: MastraMessageV2[];
138
+ format: 'v2';
128
139
  }): Promise<MastraMessageV2[]>;
129
140
  private transformEvalRow;
130
141
  getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
package/dist/index.cjs CHANGED
@@ -4,6 +4,7 @@ var client = require('@libsql/client');
4
4
  var utils = require('@mastra/core/utils');
5
5
  var vector = require('@mastra/core/vector');
6
6
  var filter = require('@mastra/core/vector/filter');
7
+ var agent = require('@mastra/core/agent');
7
8
  var storage = require('@mastra/core/storage');
8
9
 
9
10
  // src/vector/index.ts
@@ -1035,7 +1036,11 @@ var LibSQLStore = class extends storage.MastraStorage {
1035
1036
  if (row.type && row.type !== `v2`) result.type = row.type;
1036
1037
  return result;
1037
1038
  }
1038
- async getMessages({ threadId, selectBy }) {
1039
+ async getMessages({
1040
+ threadId,
1041
+ selectBy,
1042
+ format
1043
+ }) {
1039
1044
  try {
1040
1045
  const messages = [];
1041
1046
  const limit = typeof selectBy?.last === `number` ? selectBy.last : 40;
@@ -1098,13 +1103,18 @@ var LibSQLStore = class extends storage.MastraStorage {
1098
1103
  messages.push(...remainingResult.rows.map((row) => this.parseRow(row)));
1099
1104
  }
1100
1105
  messages.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
1101
- return messages;
1106
+ const list = new agent.MessageList().add(messages, "memory");
1107
+ if (format === `v2`) return list.get.all.v2();
1108
+ return list.get.all.v1();
1102
1109
  } catch (error) {
1103
1110
  this.logger.error("Error getting messages:", error);
1104
1111
  throw error;
1105
1112
  }
1106
1113
  }
1107
- async saveMessages({ messages }) {
1114
+ async saveMessages({
1115
+ messages,
1116
+ format
1117
+ }) {
1108
1118
  if (messages.length === 0) return messages;
1109
1119
  try {
1110
1120
  const threadId = messages[0]?.threadId;
@@ -1127,7 +1137,9 @@ var LibSQLStore = class extends storage.MastraStorage {
1127
1137
  };
1128
1138
  });
1129
1139
  await this.client.batch(batchStatements, "write");
1130
- return messages;
1140
+ const list = new agent.MessageList().add(messages, "memory");
1141
+ if (format === `v2`) return list.get.all.v2();
1142
+ return list.get.all.v1();
1131
1143
  } catch (error) {
1132
1144
  this.logger.error("Failed to save messages in database: " + error?.message);
1133
1145
  throw error;
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ import { createClient } from '@libsql/client';
2
2
  import { parseSqlIdentifier, parseFieldKey } from '@mastra/core/utils';
3
3
  import { MastraVector } from '@mastra/core/vector';
4
4
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
5
+ import { MessageList } from '@mastra/core/agent';
5
6
  import { MastraStorage, TABLE_WORKFLOW_SNAPSHOT, TABLE_THREADS, TABLE_MESSAGES, TABLE_EVALS, TABLE_TRACES } from '@mastra/core/storage';
6
7
 
7
8
  // src/vector/index.ts
@@ -1033,7 +1034,11 @@ var LibSQLStore = class extends MastraStorage {
1033
1034
  if (row.type && row.type !== `v2`) result.type = row.type;
1034
1035
  return result;
1035
1036
  }
1036
- async getMessages({ threadId, selectBy }) {
1037
+ async getMessages({
1038
+ threadId,
1039
+ selectBy,
1040
+ format
1041
+ }) {
1037
1042
  try {
1038
1043
  const messages = [];
1039
1044
  const limit = typeof selectBy?.last === `number` ? selectBy.last : 40;
@@ -1096,13 +1101,18 @@ var LibSQLStore = class extends MastraStorage {
1096
1101
  messages.push(...remainingResult.rows.map((row) => this.parseRow(row)));
1097
1102
  }
1098
1103
  messages.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
1099
- return messages;
1104
+ const list = new MessageList().add(messages, "memory");
1105
+ if (format === `v2`) return list.get.all.v2();
1106
+ return list.get.all.v1();
1100
1107
  } catch (error) {
1101
1108
  this.logger.error("Error getting messages:", error);
1102
1109
  throw error;
1103
1110
  }
1104
1111
  }
1105
- async saveMessages({ messages }) {
1112
+ async saveMessages({
1113
+ messages,
1114
+ format
1115
+ }) {
1106
1116
  if (messages.length === 0) return messages;
1107
1117
  try {
1108
1118
  const threadId = messages[0]?.threadId;
@@ -1125,7 +1135,9 @@ var LibSQLStore = class extends MastraStorage {
1125
1135
  };
1126
1136
  });
1127
1137
  await this.client.batch(batchStatements, "write");
1128
- return messages;
1138
+ const list = new MessageList().add(messages, "memory");
1139
+ if (format === `v2`) return list.get.all.v2();
1140
+ return list.get.all.v1();
1129
1141
  } catch (error) {
1130
1142
  this.logger.error("Failed to save messages in database: " + error?.message);
1131
1143
  throw error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/libsql",
3
- "version": "0.10.1-alpha.1",
3
+ "version": "0.10.1-alpha.2",
4
4
  "description": "Libsql provider for Mastra - includes both vector and db storage capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -31,7 +31,7 @@
31
31
  "vitest": "^3.1.2",
32
32
  "@internal/lint": "0.0.7",
33
33
  "@internal/storage-test-utils": "0.0.3",
34
- "@mastra/core": "0.10.2-alpha.2"
34
+ "@mastra/core": "0.10.2-alpha.4"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@mastra/core": "^0.10.0-alpha.0"
@@ -1,8 +1,9 @@
1
1
  import { createClient } from '@libsql/client';
2
2
  import type { Client, InValue } from '@libsql/client';
3
+ import { MessageList } from '@mastra/core/agent';
3
4
  import type { MastraMessageV2 } from '@mastra/core/agent';
4
5
  import type { MetricResult, TestInfo } from '@mastra/core/eval';
5
- import type { StorageThreadType } from '@mastra/core/memory';
6
+ import type { MastraMessageV1, StorageThreadType } from '@mastra/core/memory';
6
7
  import {
7
8
  MastraStorage,
8
9
  TABLE_MESSAGES,
@@ -362,7 +363,13 @@ export class LibSQLStore extends MastraStorage {
362
363
  return result;
363
364
  }
364
365
 
365
- async getMessages<T extends MastraMessageV2[]>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T> {
366
+ public async getMessages(args: StorageGetMessagesArg & { format?: 'v1' }): Promise<MastraMessageV1[]>;
367
+ public async getMessages(args: StorageGetMessagesArg & { format: 'v2' }): Promise<MastraMessageV2[]>;
368
+ public async getMessages({
369
+ threadId,
370
+ selectBy,
371
+ format,
372
+ }: StorageGetMessagesArg & { format?: 'v1' | 'v2' }): Promise<MastraMessageV1[] | MastraMessageV2[]> {
366
373
  try {
367
374
  const messages: MastraMessageV2[] = [];
368
375
  const limit = typeof selectBy?.last === `number` ? selectBy.last : 40;
@@ -437,14 +444,23 @@ export class LibSQLStore extends MastraStorage {
437
444
  // Sort all messages by creation date
438
445
  messages.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
439
446
 
440
- return messages as T;
447
+ const list = new MessageList().add(messages, 'memory');
448
+ if (format === `v2`) return list.get.all.v2();
449
+ return list.get.all.v1();
441
450
  } catch (error) {
442
451
  this.logger.error('Error getting messages:', error as Error);
443
452
  throw error;
444
453
  }
445
454
  }
446
455
 
447
- async saveMessages({ messages }: { messages: MastraMessageV2[] }): Promise<MastraMessageV2[]> {
456
+ async saveMessages(args: { messages: MastraMessageV1[]; format?: undefined | 'v1' }): Promise<MastraMessageV1[]>;
457
+ async saveMessages(args: { messages: MastraMessageV2[]; format: 'v2' }): Promise<MastraMessageV2[]>;
458
+ async saveMessages({
459
+ messages,
460
+ format,
461
+ }:
462
+ | { messages: MastraMessageV1[]; format?: undefined | 'v1' }
463
+ | { messages: MastraMessageV2[]; format: 'v2' }): Promise<MastraMessageV2[] | MastraMessageV1[]> {
448
464
  if (messages.length === 0) return messages;
449
465
 
450
466
  try {
@@ -473,7 +489,9 @@ export class LibSQLStore extends MastraStorage {
473
489
  // Execute all inserts in a single batch
474
490
  await this.client.batch(batchStatements, 'write');
475
491
 
476
- return messages;
492
+ const list = new MessageList().add(messages, 'memory');
493
+ if (format === `v2`) return list.get.all.v2();
494
+ return list.get.all.v1();
477
495
  } catch (error) {
478
496
  this.logger.error('Failed to save messages in database: ' + (error as { message: string })?.message);
479
497
  throw error;