@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/index.js
CHANGED
|
@@ -1644,6 +1644,27 @@ function buildSelectColumnsWithAlias(tableName, alias) {
|
|
|
1644
1644
|
function isLockError(error) {
|
|
1645
1645
|
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");
|
|
1646
1646
|
}
|
|
1647
|
+
const TRANSIENT_NETWORK_PATTERNS = [
|
|
1648
|
+
"fetch failed",
|
|
1649
|
+
"econnreset",
|
|
1650
|
+
"etimedout",
|
|
1651
|
+
"eai_again",
|
|
1652
|
+
"socket hang up",
|
|
1653
|
+
"und_err_"
|
|
1654
|
+
];
|
|
1655
|
+
/**
|
|
1656
|
+
* Checks if an error (or any error in its `cause` chain) is a transient network failure
|
|
1657
|
+
* such as `fetch failed` from a remote libsql client.
|
|
1658
|
+
*/
|
|
1659
|
+
function isTransientNetworkError(error) {
|
|
1660
|
+
let current = error;
|
|
1661
|
+
for (let depth = 0; current && depth < 5; depth++) {
|
|
1662
|
+
const text = `${current.message ?? ""} ${current.code ?? ""}`.toLowerCase();
|
|
1663
|
+
if (TRANSIENT_NETWORK_PATTERNS.some((pattern) => text.includes(pattern))) return true;
|
|
1664
|
+
current = current.cause;
|
|
1665
|
+
}
|
|
1666
|
+
return false;
|
|
1667
|
+
}
|
|
1647
1668
|
function createExecuteWriteOperationWithRetry({ logger, maxRetries, initialBackoffMs }) {
|
|
1648
1669
|
return async function executeWriteOperationWithRetry(operationFn, operationDescription) {
|
|
1649
1670
|
let attempts = 0;
|
|
@@ -4352,6 +4373,10 @@ var DatasetsLibSQL = class extends DatasetsStorage {
|
|
|
4352
4373
|
const { page, perPage: perPageInput } = args.pagination;
|
|
4353
4374
|
const filterConditions = [];
|
|
4354
4375
|
const filterParams = [];
|
|
4376
|
+
if (args.filters?.datasetIds !== void 0) {
|
|
4377
|
+
filterConditions.push(args.filters.datasetIds.length > 0 ? `id IN (${args.filters.datasetIds.map(() => "?").join(",")})` : "1 = 0");
|
|
4378
|
+
filterParams.push(...args.filters.datasetIds);
|
|
4379
|
+
}
|
|
4355
4380
|
if (args.filters?.organizationId !== void 0) {
|
|
4356
4381
|
filterConditions.push("organizationId = ?");
|
|
4357
4382
|
filterParams.push(args.filters.organizationId);
|
|
@@ -16579,6 +16604,8 @@ var LibSQLFactoryStorage = class extends FactoryStorage {
|
|
|
16579
16604
|
};
|
|
16580
16605
|
//#endregion
|
|
16581
16606
|
//#region src/storage/index.ts
|
|
16607
|
+
const REMOTE_INIT_CONCURRENCY = 5;
|
|
16608
|
+
const REMOTE_INIT_MAX_ATTEMPTS = 3;
|
|
16582
16609
|
const DEFAULT_LOCAL_CACHE_SIZE = -16e3;
|
|
16583
16610
|
const DEFAULT_LOCAL_MMAP_SIZE = 134217728;
|
|
16584
16611
|
/**
|
|
@@ -16725,8 +16752,31 @@ var LibSQLStore = class extends MastraCompositeStore {
|
|
|
16725
16752
|
for (const store of this.getStoresToInit()) await store.init();
|
|
16726
16753
|
return true;
|
|
16727
16754
|
}
|
|
16755
|
+
async initStoreWithRetry(store) {
|
|
16756
|
+
for (let attempt = 1;; attempt++) try {
|
|
16757
|
+
await store.init();
|
|
16758
|
+
return;
|
|
16759
|
+
} catch (error) {
|
|
16760
|
+
if (attempt >= REMOTE_INIT_MAX_ATTEMPTS || !isTransientNetworkError(error)) throw error;
|
|
16761
|
+
const backoff = this.initialBackoffMs * 2 ** (attempt - 1);
|
|
16762
|
+
this.logger.warn(`LibSQLStore: Transient network error during domain init, retrying in ${backoff}ms (attempt ${attempt}/${REMOTE_INIT_MAX_ATTEMPTS}).`, error);
|
|
16763
|
+
await new Promise((resolve) => setTimeout(resolve, backoff));
|
|
16764
|
+
}
|
|
16765
|
+
}
|
|
16728
16766
|
async initDomainsInParallel() {
|
|
16729
|
-
|
|
16767
|
+
const stores = this.getStoresToInit();
|
|
16768
|
+
let next = 0;
|
|
16769
|
+
let failed = false;
|
|
16770
|
+
const worker = async () => {
|
|
16771
|
+
while (!failed && next < stores.length) try {
|
|
16772
|
+
await this.initStoreWithRetry(stores[next++]);
|
|
16773
|
+
} catch (error) {
|
|
16774
|
+
failed = true;
|
|
16775
|
+
throw error;
|
|
16776
|
+
}
|
|
16777
|
+
};
|
|
16778
|
+
const rejected = (await Promise.allSettled(Array.from({ length: Math.min(REMOTE_INIT_CONCURRENCY, stores.length) }, worker))).find((r) => r.status === "rejected");
|
|
16779
|
+
if (rejected) throw rejected.reason;
|
|
16730
16780
|
return true;
|
|
16731
16781
|
}
|
|
16732
16782
|
async init() {
|
|
@@ -16737,7 +16787,10 @@ var LibSQLStore = class extends MastraCompositeStore {
|
|
|
16737
16787
|
await this.hasInitialized;
|
|
16738
16788
|
return;
|
|
16739
16789
|
}
|
|
16740
|
-
this.hasInitialized = this.initDomainsInParallel()
|
|
16790
|
+
this.hasInitialized = this.initDomainsInParallel().catch((error) => {
|
|
16791
|
+
this.hasInitialized = null;
|
|
16792
|
+
throw error;
|
|
16793
|
+
});
|
|
16741
16794
|
await this.hasInitialized;
|
|
16742
16795
|
return;
|
|
16743
16796
|
}
|
|
@@ -16749,7 +16802,10 @@ var LibSQLStore = class extends MastraCompositeStore {
|
|
|
16749
16802
|
await this.hasInitialized;
|
|
16750
16803
|
return;
|
|
16751
16804
|
}
|
|
16752
|
-
this.hasInitialized = this.initDomainsSequentially()
|
|
16805
|
+
this.hasInitialized = this.initDomainsSequentially().catch((error) => {
|
|
16806
|
+
this.hasInitialized = null;
|
|
16807
|
+
throw error;
|
|
16808
|
+
});
|
|
16753
16809
|
await this.hasInitialized;
|
|
16754
16810
|
return;
|
|
16755
16811
|
}
|