@anuma/sdk 1.1.4 → 1.1.6
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/expo/{chunk-RYLI53HN.mjs → chunk-OZ357R4P.mjs} +94 -46
- package/dist/expo/index.cjs +124 -49
- package/dist/expo/index.d.mts +15 -0
- package/dist/expo/index.d.ts +15 -0
- package/dist/expo/index.mjs +30 -3
- package/dist/expo/{recall-U6SVHL5Q.mjs → recall-EMFBX3WU.mjs} +1 -1
- package/dist/index.cjs +13 -6
- package/dist/index.mjs +13 -6
- package/dist/react/{chunk-DVGJ5NBT.mjs → chunk-DC6J5RX5.mjs} +94 -46
- package/dist/react/index.cjs +124 -49
- package/dist/react/index.d.mts +15 -0
- package/dist/react/index.d.ts +15 -0
- package/dist/react/index.mjs +30 -3
- package/dist/react/{recall-6AQ4WFJO.mjs → recall-RGKS2OIP.mjs} +1 -1
- package/dist/server/{chunk-RCNBXNOI.mjs → chunk-MKRSHU4S.mjs} +20 -7
- package/dist/server/index.cjs +49 -9
- package/dist/server/index.d.mts +15 -0
- package/dist/server/index.d.ts +15 -0
- package/dist/server/index.mjs +30 -3
- package/dist/server/{recall-2XUT7CCN.mjs → recall-V4763HKS.mjs} +1 -1
- package/package.json +1 -1
package/dist/server/index.cjs
CHANGED
|
@@ -18224,6 +18224,13 @@ async function withEmbeddingRetry(call) {
|
|
|
18224
18224
|
if (threw) throw lastThrown;
|
|
18225
18225
|
return last;
|
|
18226
18226
|
}
|
|
18227
|
+
function isFatalEmbeddingError(err) {
|
|
18228
|
+
return err instanceof EmbeddingHttpError && (err.status === 401 || err.status === 402 || err.status === 403);
|
|
18229
|
+
}
|
|
18230
|
+
function embeddingErrorFrom(response) {
|
|
18231
|
+
const message = typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed";
|
|
18232
|
+
return new EmbeddingHttpError(message, response.response?.status);
|
|
18233
|
+
}
|
|
18227
18234
|
async function generateEmbedding(text11, options) {
|
|
18228
18235
|
const { baseUrl = BASE_URL, getToken, apiKey, model, cache } = options;
|
|
18229
18236
|
if (cache) {
|
|
@@ -18255,9 +18262,7 @@ async function generateEmbedding(text11, options) {
|
|
|
18255
18262
|
})
|
|
18256
18263
|
);
|
|
18257
18264
|
if (response.error) {
|
|
18258
|
-
throw
|
|
18259
|
-
typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed"
|
|
18260
|
-
);
|
|
18265
|
+
throw embeddingErrorFrom(response);
|
|
18261
18266
|
}
|
|
18262
18267
|
if (!response.data?.data?.[0]?.embedding) {
|
|
18263
18268
|
throw new Error("No embedding returned from API");
|
|
@@ -18284,9 +18289,7 @@ async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage,
|
|
|
18284
18289
|
})
|
|
18285
18290
|
);
|
|
18286
18291
|
if (response.error) {
|
|
18287
|
-
throw
|
|
18288
|
-
typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed"
|
|
18289
|
-
);
|
|
18292
|
+
throw embeddingErrorFrom(response);
|
|
18290
18293
|
}
|
|
18291
18294
|
if (!response.data?.data) {
|
|
18292
18295
|
throw new Error("No embeddings returned from API");
|
|
@@ -18422,6 +18425,7 @@ async function embedAllMessages(ctx, options, filter) {
|
|
|
18422
18425
|
await updateMessageEmbeddingOp(ctx, message.uniqueId, embedding, embeddingModel);
|
|
18423
18426
|
embeddedCount++;
|
|
18424
18427
|
} catch (error) {
|
|
18428
|
+
if (isFatalEmbeddingError(error)) throw error;
|
|
18425
18429
|
getLogger().error(`Failed to embed message ${message.uniqueId}:`, error);
|
|
18426
18430
|
}
|
|
18427
18431
|
}
|
|
@@ -18509,6 +18513,7 @@ async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
|
18509
18513
|
}
|
|
18510
18514
|
}
|
|
18511
18515
|
} catch (error) {
|
|
18516
|
+
if (isFatalEmbeddingError(error)) throw error;
|
|
18512
18517
|
getLogger().error("Failed to batch-embed short messages:", error);
|
|
18513
18518
|
}
|
|
18514
18519
|
}
|
|
@@ -18525,12 +18530,13 @@ async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
|
18525
18530
|
await updateMessageChunksOp(ctx, msg.uniqueId, messageChunks, embeddingModel);
|
|
18526
18531
|
embeddedCount++;
|
|
18527
18532
|
} catch (error) {
|
|
18533
|
+
if (isFatalEmbeddingError(error)) throw error;
|
|
18528
18534
|
getLogger().error(`Failed to embed message ${msg.uniqueId}:`, error);
|
|
18529
18535
|
}
|
|
18530
18536
|
}
|
|
18531
18537
|
return embeddedCount;
|
|
18532
18538
|
}
|
|
18533
|
-
var DEFAULT_MIN_CONTENT_LENGTH, EMBED_MAX_ATTEMPTS, DEFAULT_EMBEDDING_BATCH_SIZE, DEFAULT_EMBEDDING_BATCH_CONCURRENCY;
|
|
18539
|
+
var DEFAULT_MIN_CONTENT_LENGTH, EMBED_MAX_ATTEMPTS, EmbeddingHttpError, DEFAULT_EMBEDDING_BATCH_SIZE, DEFAULT_EMBEDDING_BATCH_CONCURRENCY;
|
|
18534
18540
|
var init_embeddings = __esm({
|
|
18535
18541
|
"src/lib/memoryEngine/embeddings.ts"() {
|
|
18536
18542
|
"use strict";
|
|
@@ -18542,6 +18548,13 @@ var init_embeddings = __esm({
|
|
|
18542
18548
|
init_constants();
|
|
18543
18549
|
DEFAULT_MIN_CONTENT_LENGTH = 10;
|
|
18544
18550
|
EMBED_MAX_ATTEMPTS = 4;
|
|
18551
|
+
EmbeddingHttpError = class extends Error {
|
|
18552
|
+
constructor(message, status) {
|
|
18553
|
+
super(message);
|
|
18554
|
+
this.name = "EmbeddingHttpError";
|
|
18555
|
+
this.status = status;
|
|
18556
|
+
}
|
|
18557
|
+
};
|
|
18545
18558
|
DEFAULT_EMBEDDING_BATCH_SIZE = 100;
|
|
18546
18559
|
DEFAULT_EMBEDDING_BATCH_CONCURRENCY = 3;
|
|
18547
18560
|
}
|
|
@@ -22864,6 +22877,7 @@ var DatabaseManager = class {
|
|
|
22864
22877
|
from: this.currentWalletAddress,
|
|
22865
22878
|
to: walletAddress
|
|
22866
22879
|
});
|
|
22880
|
+
void this.disposeAdapter(this.database);
|
|
22867
22881
|
this.database = null;
|
|
22868
22882
|
}
|
|
22869
22883
|
if (this.database) {
|
|
@@ -22893,11 +22907,37 @@ var DatabaseManager = class {
|
|
|
22893
22907
|
async resetDatabase() {
|
|
22894
22908
|
const db = this.database;
|
|
22895
22909
|
if (db) {
|
|
22910
|
+
this.database = null;
|
|
22911
|
+
this.currentWalletAddress = void 0;
|
|
22896
22912
|
await db.write(async () => {
|
|
22897
22913
|
await db.unsafeResetDatabase();
|
|
22898
22914
|
});
|
|
22899
|
-
this.
|
|
22900
|
-
|
|
22915
|
+
await this.disposeAdapter(db);
|
|
22916
|
+
}
|
|
22917
|
+
}
|
|
22918
|
+
/**
|
|
22919
|
+
* Best-effort dispose of the adapter backing a Database, if it exposes one.
|
|
22920
|
+
*
|
|
22921
|
+
* OPFS/SQLite adapters use this to terminate their dedicated worker and release
|
|
22922
|
+
* the exclusive SAHPool (+ WASM heap) they hold. The SDK only sees a generic
|
|
22923
|
+
* `DatabaseAdapter`, so we probe `adapter.underlyingAdapter.dispose` rather than
|
|
22924
|
+
* type it. Client-side implementations are refcounted + idempotent, so calling
|
|
22925
|
+
* this is safe even when the adapter factory also disposes.
|
|
22926
|
+
*
|
|
22927
|
+
* Awaitable and never rejects: a sync throw or async rejection from `dispose`
|
|
22928
|
+
* is caught + logged. Awaited on the async `resetDatabase` path so teardown
|
|
22929
|
+
* completes before the caller reopens; fire-and-forget on the synchronous
|
|
22930
|
+
* `getDatabase` path (which cannot block).
|
|
22931
|
+
*/
|
|
22932
|
+
async disposeAdapter(db) {
|
|
22933
|
+
try {
|
|
22934
|
+
const underlying = db.adapter?.underlyingAdapter;
|
|
22935
|
+
await underlying?.dispose?.();
|
|
22936
|
+
} catch (error) {
|
|
22937
|
+
this.logger.warn?.("Adapter dispose failed", {
|
|
22938
|
+
component: "DatabaseManager",
|
|
22939
|
+
error
|
|
22940
|
+
});
|
|
22901
22941
|
}
|
|
22902
22942
|
}
|
|
22903
22943
|
/**
|
package/dist/server/index.d.mts
CHANGED
|
@@ -274,6 +274,21 @@ declare class DatabaseManager {
|
|
|
274
274
|
* Reset the current database (useful for logout or testing).
|
|
275
275
|
*/
|
|
276
276
|
resetDatabase(): Promise<void>;
|
|
277
|
+
/**
|
|
278
|
+
* Best-effort dispose of the adapter backing a Database, if it exposes one.
|
|
279
|
+
*
|
|
280
|
+
* OPFS/SQLite adapters use this to terminate their dedicated worker and release
|
|
281
|
+
* the exclusive SAHPool (+ WASM heap) they hold. The SDK only sees a generic
|
|
282
|
+
* `DatabaseAdapter`, so we probe `adapter.underlyingAdapter.dispose` rather than
|
|
283
|
+
* type it. Client-side implementations are refcounted + idempotent, so calling
|
|
284
|
+
* this is safe even when the adapter factory also disposes.
|
|
285
|
+
*
|
|
286
|
+
* Awaitable and never rejects: a sync throw or async rejection from `dispose`
|
|
287
|
+
* is caught + logged. Awaited on the async `resetDatabase` path so teardown
|
|
288
|
+
* completes before the caller reopens; fire-and-forget on the synchronous
|
|
289
|
+
* `getDatabase` path (which cannot block).
|
|
290
|
+
*/
|
|
291
|
+
private disposeAdapter;
|
|
277
292
|
/**
|
|
278
293
|
* Check and handle schema migrations for a specific wallet.
|
|
279
294
|
* Returns true if a destructive migration is in progress.
|
package/dist/server/index.d.ts
CHANGED
|
@@ -274,6 +274,21 @@ declare class DatabaseManager {
|
|
|
274
274
|
* Reset the current database (useful for logout or testing).
|
|
275
275
|
*/
|
|
276
276
|
resetDatabase(): Promise<void>;
|
|
277
|
+
/**
|
|
278
|
+
* Best-effort dispose of the adapter backing a Database, if it exposes one.
|
|
279
|
+
*
|
|
280
|
+
* OPFS/SQLite adapters use this to terminate their dedicated worker and release
|
|
281
|
+
* the exclusive SAHPool (+ WASM heap) they hold. The SDK only sees a generic
|
|
282
|
+
* `DatabaseAdapter`, so we probe `adapter.underlyingAdapter.dispose` rather than
|
|
283
|
+
* type it. Client-side implementations are refcounted + idempotent, so calling
|
|
284
|
+
* this is safe even when the adapter factory also disposes.
|
|
285
|
+
*
|
|
286
|
+
* Awaitable and never rejects: a sync throw or async rejection from `dispose`
|
|
287
|
+
* is caught + logged. Awaited on the async `resetDatabase` path so teardown
|
|
288
|
+
* completes before the caller reopens; fire-and-forget on the synchronous
|
|
289
|
+
* `getDatabase` path (which cannot block).
|
|
290
|
+
*/
|
|
291
|
+
private disposeAdapter;
|
|
277
292
|
/**
|
|
278
293
|
* Check and handle schema migrations for a specific wallet.
|
|
279
294
|
* Returns true if a destructive migration is in progress.
|
package/dist/server/index.mjs
CHANGED
|
@@ -95,7 +95,7 @@ import {
|
|
|
95
95
|
updateVaultMemoryEmbeddingOp,
|
|
96
96
|
updateVaultMemoryOp,
|
|
97
97
|
upsertMessageOp
|
|
98
|
-
} from "./chunk-
|
|
98
|
+
} from "./chunk-MKRSHU4S.mjs";
|
|
99
99
|
import {
|
|
100
100
|
createStreamingDeAnonymizer,
|
|
101
101
|
resolvePiiRedactor
|
|
@@ -1984,6 +1984,7 @@ var DatabaseManager = class {
|
|
|
1984
1984
|
from: this.currentWalletAddress,
|
|
1985
1985
|
to: walletAddress
|
|
1986
1986
|
});
|
|
1987
|
+
void this.disposeAdapter(this.database);
|
|
1987
1988
|
this.database = null;
|
|
1988
1989
|
}
|
|
1989
1990
|
if (this.database) {
|
|
@@ -2013,11 +2014,37 @@ var DatabaseManager = class {
|
|
|
2013
2014
|
async resetDatabase() {
|
|
2014
2015
|
const db = this.database;
|
|
2015
2016
|
if (db) {
|
|
2017
|
+
this.database = null;
|
|
2018
|
+
this.currentWalletAddress = void 0;
|
|
2016
2019
|
await db.write(async () => {
|
|
2017
2020
|
await db.unsafeResetDatabase();
|
|
2018
2021
|
});
|
|
2019
|
-
this.
|
|
2020
|
-
|
|
2022
|
+
await this.disposeAdapter(db);
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
/**
|
|
2026
|
+
* Best-effort dispose of the adapter backing a Database, if it exposes one.
|
|
2027
|
+
*
|
|
2028
|
+
* OPFS/SQLite adapters use this to terminate their dedicated worker and release
|
|
2029
|
+
* the exclusive SAHPool (+ WASM heap) they hold. The SDK only sees a generic
|
|
2030
|
+
* `DatabaseAdapter`, so we probe `adapter.underlyingAdapter.dispose` rather than
|
|
2031
|
+
* type it. Client-side implementations are refcounted + idempotent, so calling
|
|
2032
|
+
* this is safe even when the adapter factory also disposes.
|
|
2033
|
+
*
|
|
2034
|
+
* Awaitable and never rejects: a sync throw or async rejection from `dispose`
|
|
2035
|
+
* is caught + logged. Awaited on the async `resetDatabase` path so teardown
|
|
2036
|
+
* completes before the caller reopens; fire-and-forget on the synchronous
|
|
2037
|
+
* `getDatabase` path (which cannot block).
|
|
2038
|
+
*/
|
|
2039
|
+
async disposeAdapter(db) {
|
|
2040
|
+
try {
|
|
2041
|
+
const underlying = db.adapter?.underlyingAdapter;
|
|
2042
|
+
await underlying?.dispose?.();
|
|
2043
|
+
} catch (error) {
|
|
2044
|
+
this.logger.warn?.("Adapter dispose failed", {
|
|
2045
|
+
component: "DatabaseManager",
|
|
2046
|
+
error
|
|
2047
|
+
});
|
|
2021
2048
|
}
|
|
2022
2049
|
}
|
|
2023
2050
|
/**
|