@mastra/libsql 1.13.0 → 1.13.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 +26 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-agent-builder-deploying.md +10 -10
- package/dist/docs/references/docs-agent-builder-overview.md +21 -12
- package/dist/index.cjs +27 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -10
- package/dist/index.js.map +1 -1
- package/dist/storage/db/index.d.ts +15 -0
- package/dist/storage/db/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/skills/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +14 -0
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { MastraBase } from '@mastra/core/base';
|
|
|
8
8
|
import { randomUUID } from 'crypto';
|
|
9
9
|
import { MessageList } from '@mastra/core/agent';
|
|
10
10
|
import { saveScorePayloadSchema } from '@mastra/core/evals';
|
|
11
|
+
import { skillSnapshotFieldValuesEqual } from '@mastra/core/storage/domains/skills';
|
|
11
12
|
|
|
12
13
|
// src/vector/index.ts
|
|
13
14
|
var LibSQLFilterTranslator = class extends BaseFilterTranslator {
|
|
@@ -1440,13 +1441,19 @@ function withClientWriteLock(client, fn) {
|
|
|
1440
1441
|
}
|
|
1441
1442
|
|
|
1442
1443
|
// src/storage/db/index.ts
|
|
1444
|
+
var DEFAULT_CONNECTION_TIMEOUT_MS = 5e3;
|
|
1443
1445
|
function resolveClient(config) {
|
|
1444
1446
|
if ("client" in config) {
|
|
1445
1447
|
return config.client;
|
|
1446
1448
|
}
|
|
1449
|
+
const isLocal = config.url.startsWith("file:") || config.url.includes(":memory:");
|
|
1450
|
+
const timeout = config.connectionTimeoutMs ?? DEFAULT_CONNECTION_TIMEOUT_MS;
|
|
1447
1451
|
return createClient({
|
|
1448
1452
|
url: config.url,
|
|
1449
|
-
...config.authToken ? { authToken: config.authToken } : {}
|
|
1453
|
+
...config.authToken ? { authToken: config.authToken } : {},
|
|
1454
|
+
// Only local sqlite3 connections honor `busy_timeout`; remote contention is
|
|
1455
|
+
// resolved server-side, so passing it there is meaningless.
|
|
1456
|
+
...isLocal ? { timeout } : {}
|
|
1450
1457
|
});
|
|
1451
1458
|
}
|
|
1452
1459
|
var LibSQLDB = class extends MastraBase {
|
|
@@ -2270,8 +2277,6 @@ Note: This migration may take some time for large tables.
|
|
|
2270
2277
|
}
|
|
2271
2278
|
}
|
|
2272
2279
|
};
|
|
2273
|
-
|
|
2274
|
-
// src/storage/domains/agents/index.ts
|
|
2275
2280
|
var AgentsLibSQL = class extends AgentsStorage {
|
|
2276
2281
|
#db;
|
|
2277
2282
|
#client;
|
|
@@ -7355,18 +7360,20 @@ var MemoryLibSQL = class extends MemoryStorage {
|
|
|
7355
7360
|
}
|
|
7356
7361
|
});
|
|
7357
7362
|
}
|
|
7363
|
+
const now = /* @__PURE__ */ new Date();
|
|
7358
7364
|
const updatedThread = {
|
|
7359
7365
|
...thread,
|
|
7360
7366
|
title,
|
|
7361
7367
|
metadata: {
|
|
7362
7368
|
...thread.metadata,
|
|
7363
7369
|
...metadata
|
|
7364
|
-
}
|
|
7370
|
+
},
|
|
7371
|
+
updatedAt: now
|
|
7365
7372
|
};
|
|
7366
7373
|
try {
|
|
7367
7374
|
await this.#client.execute({
|
|
7368
|
-
sql: `UPDATE ${TABLE_THREADS} SET title = ?, metadata = jsonb(?) WHERE id = ?`,
|
|
7369
|
-
args: [title, JSON.stringify(updatedThread.metadata), id]
|
|
7375
|
+
sql: `UPDATE ${TABLE_THREADS} SET title = ?, metadata = jsonb(?), updatedAt = ? WHERE id = ?`,
|
|
7376
|
+
args: [title, JSON.stringify(updatedThread.metadata), now.toISOString(), id]
|
|
7370
7377
|
});
|
|
7371
7378
|
return updatedThread;
|
|
7372
7379
|
} catch (error) {
|
|
@@ -10997,7 +11004,10 @@ var SkillsLibSQL = class extends SkillsStorage {
|
|
|
10997
11004
|
} = latestVersion;
|
|
10998
11005
|
const newConfig = { ...latestConfig, ...configFields };
|
|
10999
11006
|
const changedFields = configFieldNames.filter(
|
|
11000
|
-
(field) => field in configFields &&
|
|
11007
|
+
(field) => field in configFields && !skillSnapshotFieldValuesEqual(
|
|
11008
|
+
configFields[field],
|
|
11009
|
+
latestConfig[field]
|
|
11010
|
+
)
|
|
11001
11011
|
);
|
|
11002
11012
|
if (changedFields.length > 0) {
|
|
11003
11013
|
const newVersionId = crypto.randomUUID();
|
|
@@ -12599,6 +12609,7 @@ var LibSQLStore = class extends MastraCompositeStore {
|
|
|
12599
12609
|
client;
|
|
12600
12610
|
maxRetries;
|
|
12601
12611
|
initialBackoffMs;
|
|
12612
|
+
connectionTimeoutMs;
|
|
12602
12613
|
pragmasReady;
|
|
12603
12614
|
isLocalDb;
|
|
12604
12615
|
localPragmas;
|
|
@@ -12610,6 +12621,7 @@ var LibSQLStore = class extends MastraCompositeStore {
|
|
|
12610
12621
|
super({ id: config.id, name: `LibSQLStore`, disableInit: config.disableInit });
|
|
12611
12622
|
this.maxRetries = config.maxRetries ?? 5;
|
|
12612
12623
|
this.initialBackoffMs = config.initialBackoffMs ?? 100;
|
|
12624
|
+
this.connectionTimeoutMs = config.connectionTimeoutMs ?? DEFAULT_CONNECTION_TIMEOUT_MS;
|
|
12613
12625
|
this.localPragmas = {
|
|
12614
12626
|
cacheSize: config.localPragmas?.cacheSize ?? DEFAULT_LOCAL_CACHE_SIZE,
|
|
12615
12627
|
mmapSize: config.localPragmas?.mmapSize ?? DEFAULT_LOCAL_MMAP_SIZE
|
|
@@ -12618,11 +12630,14 @@ var LibSQLStore = class extends MastraCompositeStore {
|
|
|
12618
12630
|
if (config.url.includes(":memory:")) {
|
|
12619
12631
|
this.shouldCacheInit = false;
|
|
12620
12632
|
}
|
|
12633
|
+
this.isLocalDb = config.url.startsWith("file:") || config.url.includes(":memory:");
|
|
12621
12634
|
this.client = createClient({
|
|
12622
12635
|
url: config.url,
|
|
12623
|
-
...config.authToken ? { authToken: config.authToken } : {}
|
|
12636
|
+
...config.authToken ? { authToken: config.authToken } : {},
|
|
12637
|
+
// `busy_timeout` only applies to local sqlite3 connections; remote
|
|
12638
|
+
// contention is handled server-side. See libsql-client-ts#288/#345.
|
|
12639
|
+
...this.isLocalDb ? { timeout: this.connectionTimeoutMs } : {}
|
|
12624
12640
|
});
|
|
12625
|
-
this.isLocalDb = config.url.startsWith("file:") || config.url.includes(":memory:");
|
|
12626
12641
|
this.pragmasReady = this.isLocalDb ? this.applyLocalPragmas() : Promise.resolve();
|
|
12627
12642
|
} else {
|
|
12628
12643
|
this.client = config.client;
|
|
@@ -12684,7 +12699,9 @@ var LibSQLStore = class extends MastraCompositeStore {
|
|
|
12684
12699
|
async applyLocalPragmas() {
|
|
12685
12700
|
const pragmas = [
|
|
12686
12701
|
["journal_mode=WAL", "PRAGMA journal_mode=WAL;"],
|
|
12687
|
-
|
|
12702
|
+
// Keep in sync with the connection-level `timeout` passed to createClient
|
|
12703
|
+
// so a custom connectionTimeoutMs isn't clobbered back to a hardcoded value.
|
|
12704
|
+
[`busy_timeout=${this.connectionTimeoutMs}`, `PRAGMA busy_timeout=${this.connectionTimeoutMs};`],
|
|
12688
12705
|
["synchronous=NORMAL", "PRAGMA synchronous=NORMAL;"],
|
|
12689
12706
|
["temp_store=MEMORY", "PRAGMA temp_store=MEMORY;"],
|
|
12690
12707
|
[`cache_size=${this.localPragmas.cacheSize}`, `PRAGMA cache_size=${this.localPragmas.cacheSize};`],
|