@mastra/libsql 1.26.3-alpha.0 → 1.27.0-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.
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-memory-semantic-recall.md +2 -0
- package/dist/index.cjs +59 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +59 -3
- package/dist/index.js.map +1 -1
- package/dist/storage/db/utils.d.ts +5 -0
- package/dist/storage/db/utils.d.ts.map +1 -1
- package/dist/storage/domains/datasets/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/docs/SKILL.md
CHANGED
|
@@ -403,6 +403,8 @@ Memory uses a single embedder for both storing and recalling messages, so pick o
|
|
|
403
403
|
|
|
404
404
|
Multilingual E5 produces 1024-dimensional vectors. Your vector index must be created with matching dimensions, and E5 vectors can't be mixed with vectors from another embedder in the same index.
|
|
405
405
|
|
|
406
|
+
FastEmbed models embed at most 512 tokens per input (roughly 2,000 to 2,500 characters of English text). Longer inputs are truncated, so text past the limit doesn't affect the embedding and can't be found by semantic recall. The AI SDK v3 FastEmbed models return a warning when this happens. The legacy v1 and v2 models don't. If you embed long documents with FastEmbed, chunk them to fit the window, for example with `maxSize: 1500` in `MDocument.chunk()`.
|
|
407
|
+
|
|
406
408
|
## PostgreSQL index optimization
|
|
407
409
|
|
|
408
410
|
When using PostgreSQL as your vector store, you can optimize semantic recall performance by configuring the vector index. This is particularly important for large-scale deployments with thousands of messages.
|
package/dist/index.cjs
CHANGED
|
@@ -1645,6 +1645,27 @@ function buildSelectColumnsWithAlias(tableName, alias) {
|
|
|
1645
1645
|
function isLockError(error) {
|
|
1646
1646
|
return error.code === "SQLITE_BUSY" || error.code === "SQLITE_LOCKED" || error.message?.toLowerCase().includes("database is locked") || error.message?.toLowerCase().includes("database table is locked") || error.message?.toLowerCase().includes("table is locked") || error.constructor.name === "SqliteError" && error.message?.toLowerCase().includes("locked");
|
|
1647
1647
|
}
|
|
1648
|
+
const TRANSIENT_NETWORK_PATTERNS = [
|
|
1649
|
+
"fetch failed",
|
|
1650
|
+
"econnreset",
|
|
1651
|
+
"etimedout",
|
|
1652
|
+
"eai_again",
|
|
1653
|
+
"socket hang up",
|
|
1654
|
+
"und_err_"
|
|
1655
|
+
];
|
|
1656
|
+
/**
|
|
1657
|
+
* Checks if an error (or any error in its `cause` chain) is a transient network failure
|
|
1658
|
+
* such as `fetch failed` from a remote libsql client.
|
|
1659
|
+
*/
|
|
1660
|
+
function isTransientNetworkError(error) {
|
|
1661
|
+
let current = error;
|
|
1662
|
+
for (let depth = 0; current && depth < 5; depth++) {
|
|
1663
|
+
const text = `${current.message ?? ""} ${current.code ?? ""}`.toLowerCase();
|
|
1664
|
+
if (TRANSIENT_NETWORK_PATTERNS.some((pattern) => text.includes(pattern))) return true;
|
|
1665
|
+
current = current.cause;
|
|
1666
|
+
}
|
|
1667
|
+
return false;
|
|
1668
|
+
}
|
|
1648
1669
|
function createExecuteWriteOperationWithRetry({ logger, maxRetries, initialBackoffMs }) {
|
|
1649
1670
|
return async function executeWriteOperationWithRetry(operationFn, operationDescription) {
|
|
1650
1671
|
let attempts = 0;
|
|
@@ -4353,6 +4374,10 @@ var DatasetsLibSQL = class extends _mastra_core_storage.DatasetsStorage {
|
|
|
4353
4374
|
const { page, perPage: perPageInput } = args.pagination;
|
|
4354
4375
|
const filterConditions = [];
|
|
4355
4376
|
const filterParams = [];
|
|
4377
|
+
if (args.filters?.datasetIds !== void 0) {
|
|
4378
|
+
filterConditions.push(args.filters.datasetIds.length > 0 ? `id IN (${args.filters.datasetIds.map(() => "?").join(",")})` : "1 = 0");
|
|
4379
|
+
filterParams.push(...args.filters.datasetIds);
|
|
4380
|
+
}
|
|
4356
4381
|
if (args.filters?.organizationId !== void 0) {
|
|
4357
4382
|
filterConditions.push("organizationId = ?");
|
|
4358
4383
|
filterParams.push(args.filters.organizationId);
|
|
@@ -16580,6 +16605,8 @@ var LibSQLFactoryStorage = class extends _mastra_core_storage.FactoryStorage {
|
|
|
16580
16605
|
};
|
|
16581
16606
|
//#endregion
|
|
16582
16607
|
//#region src/storage/index.ts
|
|
16608
|
+
const REMOTE_INIT_CONCURRENCY = 5;
|
|
16609
|
+
const REMOTE_INIT_MAX_ATTEMPTS = 3;
|
|
16583
16610
|
const DEFAULT_LOCAL_CACHE_SIZE = -16e3;
|
|
16584
16611
|
const DEFAULT_LOCAL_MMAP_SIZE = 134217728;
|
|
16585
16612
|
/**
|
|
@@ -16726,8 +16753,31 @@ var LibSQLStore = class extends _mastra_core_storage.MastraCompositeStore {
|
|
|
16726
16753
|
for (const store of this.getStoresToInit()) await store.init();
|
|
16727
16754
|
return true;
|
|
16728
16755
|
}
|
|
16756
|
+
async initStoreWithRetry(store) {
|
|
16757
|
+
for (let attempt = 1;; attempt++) try {
|
|
16758
|
+
await store.init();
|
|
16759
|
+
return;
|
|
16760
|
+
} catch (error) {
|
|
16761
|
+
if (attempt >= REMOTE_INIT_MAX_ATTEMPTS || !isTransientNetworkError(error)) throw error;
|
|
16762
|
+
const backoff = this.initialBackoffMs * 2 ** (attempt - 1);
|
|
16763
|
+
this.logger.warn(`LibSQLStore: Transient network error during domain init, retrying in ${backoff}ms (attempt ${attempt}/${REMOTE_INIT_MAX_ATTEMPTS}).`, error);
|
|
16764
|
+
await new Promise((resolve) => setTimeout(resolve, backoff));
|
|
16765
|
+
}
|
|
16766
|
+
}
|
|
16729
16767
|
async initDomainsInParallel() {
|
|
16730
|
-
|
|
16768
|
+
const stores = this.getStoresToInit();
|
|
16769
|
+
let next = 0;
|
|
16770
|
+
let failed = false;
|
|
16771
|
+
const worker = async () => {
|
|
16772
|
+
while (!failed && next < stores.length) try {
|
|
16773
|
+
await this.initStoreWithRetry(stores[next++]);
|
|
16774
|
+
} catch (error) {
|
|
16775
|
+
failed = true;
|
|
16776
|
+
throw error;
|
|
16777
|
+
}
|
|
16778
|
+
};
|
|
16779
|
+
const rejected = (await Promise.allSettled(Array.from({ length: Math.min(REMOTE_INIT_CONCURRENCY, stores.length) }, worker))).find((r) => r.status === "rejected");
|
|
16780
|
+
if (rejected) throw rejected.reason;
|
|
16731
16781
|
return true;
|
|
16732
16782
|
}
|
|
16733
16783
|
async init() {
|
|
@@ -16738,7 +16788,10 @@ var LibSQLStore = class extends _mastra_core_storage.MastraCompositeStore {
|
|
|
16738
16788
|
await this.hasInitialized;
|
|
16739
16789
|
return;
|
|
16740
16790
|
}
|
|
16741
|
-
this.hasInitialized = this.initDomainsInParallel()
|
|
16791
|
+
this.hasInitialized = this.initDomainsInParallel().catch((error) => {
|
|
16792
|
+
this.hasInitialized = null;
|
|
16793
|
+
throw error;
|
|
16794
|
+
});
|
|
16742
16795
|
await this.hasInitialized;
|
|
16743
16796
|
return;
|
|
16744
16797
|
}
|
|
@@ -16750,7 +16803,10 @@ var LibSQLStore = class extends _mastra_core_storage.MastraCompositeStore {
|
|
|
16750
16803
|
await this.hasInitialized;
|
|
16751
16804
|
return;
|
|
16752
16805
|
}
|
|
16753
|
-
this.hasInitialized = this.initDomainsSequentially()
|
|
16806
|
+
this.hasInitialized = this.initDomainsSequentially().catch((error) => {
|
|
16807
|
+
this.hasInitialized = null;
|
|
16808
|
+
throw error;
|
|
16809
|
+
});
|
|
16754
16810
|
await this.hasInitialized;
|
|
16755
16811
|
return;
|
|
16756
16812
|
}
|