@mastra/libsql 1.27.0-alpha.1 → 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 +55 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +55 -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/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;
|
|
@@ -16584,6 +16605,8 @@ var LibSQLFactoryStorage = class extends _mastra_core_storage.FactoryStorage {
|
|
|
16584
16605
|
};
|
|
16585
16606
|
//#endregion
|
|
16586
16607
|
//#region src/storage/index.ts
|
|
16608
|
+
const REMOTE_INIT_CONCURRENCY = 5;
|
|
16609
|
+
const REMOTE_INIT_MAX_ATTEMPTS = 3;
|
|
16587
16610
|
const DEFAULT_LOCAL_CACHE_SIZE = -16e3;
|
|
16588
16611
|
const DEFAULT_LOCAL_MMAP_SIZE = 134217728;
|
|
16589
16612
|
/**
|
|
@@ -16730,8 +16753,31 @@ var LibSQLStore = class extends _mastra_core_storage.MastraCompositeStore {
|
|
|
16730
16753
|
for (const store of this.getStoresToInit()) await store.init();
|
|
16731
16754
|
return true;
|
|
16732
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
|
+
}
|
|
16733
16767
|
async initDomainsInParallel() {
|
|
16734
|
-
|
|
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;
|
|
16735
16781
|
return true;
|
|
16736
16782
|
}
|
|
16737
16783
|
async init() {
|
|
@@ -16742,7 +16788,10 @@ var LibSQLStore = class extends _mastra_core_storage.MastraCompositeStore {
|
|
|
16742
16788
|
await this.hasInitialized;
|
|
16743
16789
|
return;
|
|
16744
16790
|
}
|
|
16745
|
-
this.hasInitialized = this.initDomainsInParallel()
|
|
16791
|
+
this.hasInitialized = this.initDomainsInParallel().catch((error) => {
|
|
16792
|
+
this.hasInitialized = null;
|
|
16793
|
+
throw error;
|
|
16794
|
+
});
|
|
16746
16795
|
await this.hasInitialized;
|
|
16747
16796
|
return;
|
|
16748
16797
|
}
|
|
@@ -16754,7 +16803,10 @@ var LibSQLStore = class extends _mastra_core_storage.MastraCompositeStore {
|
|
|
16754
16803
|
await this.hasInitialized;
|
|
16755
16804
|
return;
|
|
16756
16805
|
}
|
|
16757
|
-
this.hasInitialized = this.initDomainsSequentially()
|
|
16806
|
+
this.hasInitialized = this.initDomainsSequentially().catch((error) => {
|
|
16807
|
+
this.hasInitialized = null;
|
|
16808
|
+
throw error;
|
|
16809
|
+
});
|
|
16758
16810
|
await this.hasInitialized;
|
|
16759
16811
|
return;
|
|
16760
16812
|
}
|