@anuma/sdk 1.1.4 → 1.1.5
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-IKPPX3GY.mjs} +20 -7
- package/dist/expo/index.cjs +20 -7
- package/dist/expo/index.mjs +1 -1
- package/dist/expo/{recall-U6SVHL5Q.mjs → recall-4JTNZBAW.mjs} +1 -1
- package/dist/index.cjs +13 -6
- package/dist/index.mjs +13 -6
- package/dist/react/{chunk-DVGJ5NBT.mjs → chunk-KQZ4KVYY.mjs} +20 -7
- package/dist/react/index.cjs +20 -7
- package/dist/react/index.mjs +1 -1
- package/dist/react/{recall-6AQ4WFJO.mjs → recall-Z2HUBS2Y.mjs} +1 -1
- package/dist/server/{chunk-RCNBXNOI.mjs → chunk-KLJBJWWI.mjs} +20 -7
- package/dist/server/index.cjs +20 -7
- package/dist/server/index.mjs +1 -1
- package/dist/server/{recall-2XUT7CCN.mjs → recall-IF2HX7ZA.mjs} +1 -1
- package/package.json +1 -1
|
@@ -3170,6 +3170,20 @@ async function withEmbeddingRetry(call) {
|
|
|
3170
3170
|
if (threw) throw lastThrown;
|
|
3171
3171
|
return last;
|
|
3172
3172
|
}
|
|
3173
|
+
var EmbeddingHttpError = class extends Error {
|
|
3174
|
+
constructor(message, status) {
|
|
3175
|
+
super(message);
|
|
3176
|
+
this.name = "EmbeddingHttpError";
|
|
3177
|
+
this.status = status;
|
|
3178
|
+
}
|
|
3179
|
+
};
|
|
3180
|
+
function isFatalEmbeddingError(err) {
|
|
3181
|
+
return err instanceof EmbeddingHttpError && (err.status === 401 || err.status === 402 || err.status === 403);
|
|
3182
|
+
}
|
|
3183
|
+
function embeddingErrorFrom(response) {
|
|
3184
|
+
const message = typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed";
|
|
3185
|
+
return new EmbeddingHttpError(message, response.response?.status);
|
|
3186
|
+
}
|
|
3173
3187
|
async function generateEmbedding(text, options) {
|
|
3174
3188
|
const { baseUrl = BASE_URL, getToken, apiKey, model, cache } = options;
|
|
3175
3189
|
if (cache) {
|
|
@@ -3201,9 +3215,7 @@ async function generateEmbedding(text, options) {
|
|
|
3201
3215
|
})
|
|
3202
3216
|
);
|
|
3203
3217
|
if (response.error) {
|
|
3204
|
-
throw
|
|
3205
|
-
typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed"
|
|
3206
|
-
);
|
|
3218
|
+
throw embeddingErrorFrom(response);
|
|
3207
3219
|
}
|
|
3208
3220
|
if (!response.data?.data?.[0]?.embedding) {
|
|
3209
3221
|
throw new Error("No embedding returned from API");
|
|
@@ -3232,9 +3244,7 @@ async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage,
|
|
|
3232
3244
|
})
|
|
3233
3245
|
);
|
|
3234
3246
|
if (response.error) {
|
|
3235
|
-
throw
|
|
3236
|
-
typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed"
|
|
3237
|
-
);
|
|
3247
|
+
throw embeddingErrorFrom(response);
|
|
3238
3248
|
}
|
|
3239
3249
|
if (!response.data?.data) {
|
|
3240
3250
|
throw new Error("No embeddings returned from API");
|
|
@@ -3370,6 +3380,7 @@ async function embedAllMessages(ctx, options, filter) {
|
|
|
3370
3380
|
await updateMessageEmbeddingOp(ctx, message.uniqueId, embedding, embeddingModel);
|
|
3371
3381
|
embeddedCount++;
|
|
3372
3382
|
} catch (error) {
|
|
3383
|
+
if (isFatalEmbeddingError(error)) throw error;
|
|
3373
3384
|
getLogger().error(`Failed to embed message ${message.uniqueId}:`, error);
|
|
3374
3385
|
}
|
|
3375
3386
|
}
|
|
@@ -3457,6 +3468,7 @@ async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
|
3457
3468
|
}
|
|
3458
3469
|
}
|
|
3459
3470
|
} catch (error) {
|
|
3471
|
+
if (isFatalEmbeddingError(error)) throw error;
|
|
3460
3472
|
getLogger().error("Failed to batch-embed short messages:", error);
|
|
3461
3473
|
}
|
|
3462
3474
|
}
|
|
@@ -3473,6 +3485,7 @@ async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
|
3473
3485
|
await updateMessageChunksOp(ctx, msg.uniqueId, messageChunks, embeddingModel);
|
|
3474
3486
|
embeddedCount++;
|
|
3475
3487
|
} catch (error) {
|
|
3488
|
+
if (isFatalEmbeddingError(error)) throw error;
|
|
3476
3489
|
getLogger().error(`Failed to embed message ${msg.uniqueId}:`, error);
|
|
3477
3490
|
}
|
|
3478
3491
|
}
|
|
@@ -4667,7 +4680,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
4667
4680
|
legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
|
|
4668
4681
|
);
|
|
4669
4682
|
}
|
|
4670
|
-
const { recall: recall2 } = await import("./recall-
|
|
4683
|
+
const { recall: recall2 } = await import("./recall-4JTNZBAW.mjs");
|
|
4671
4684
|
const result = await recall2(
|
|
4672
4685
|
query,
|
|
4673
4686
|
{ vaultCtx, embeddingOptions, vaultCache: cache },
|
package/dist/expo/index.cjs
CHANGED
|
@@ -2837,6 +2837,13 @@ async function withEmbeddingRetry(call) {
|
|
|
2837
2837
|
if (threw) throw lastThrown;
|
|
2838
2838
|
return last;
|
|
2839
2839
|
}
|
|
2840
|
+
function isFatalEmbeddingError(err) {
|
|
2841
|
+
return err instanceof EmbeddingHttpError && (err.status === 401 || err.status === 402 || err.status === 403);
|
|
2842
|
+
}
|
|
2843
|
+
function embeddingErrorFrom(response) {
|
|
2844
|
+
const message = typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed";
|
|
2845
|
+
return new EmbeddingHttpError(message, response.response?.status);
|
|
2846
|
+
}
|
|
2840
2847
|
async function generateEmbedding(text11, options) {
|
|
2841
2848
|
const { baseUrl = BASE_URL, getToken, apiKey, model, cache } = options;
|
|
2842
2849
|
if (cache) {
|
|
@@ -2868,9 +2875,7 @@ async function generateEmbedding(text11, options) {
|
|
|
2868
2875
|
})
|
|
2869
2876
|
);
|
|
2870
2877
|
if (response.error) {
|
|
2871
|
-
throw
|
|
2872
|
-
typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed"
|
|
2873
|
-
);
|
|
2878
|
+
throw embeddingErrorFrom(response);
|
|
2874
2879
|
}
|
|
2875
2880
|
if (!response.data?.data?.[0]?.embedding) {
|
|
2876
2881
|
throw new Error("No embedding returned from API");
|
|
@@ -2897,9 +2902,7 @@ async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage,
|
|
|
2897
2902
|
})
|
|
2898
2903
|
);
|
|
2899
2904
|
if (response.error) {
|
|
2900
|
-
throw
|
|
2901
|
-
typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed"
|
|
2902
|
-
);
|
|
2905
|
+
throw embeddingErrorFrom(response);
|
|
2903
2906
|
}
|
|
2904
2907
|
if (!response.data?.data) {
|
|
2905
2908
|
throw new Error("No embeddings returned from API");
|
|
@@ -3035,6 +3038,7 @@ async function embedAllMessages(ctx, options, filter) {
|
|
|
3035
3038
|
await updateMessageEmbeddingOp(ctx, message.uniqueId, embedding, embeddingModel);
|
|
3036
3039
|
embeddedCount++;
|
|
3037
3040
|
} catch (error) {
|
|
3041
|
+
if (isFatalEmbeddingError(error)) throw error;
|
|
3038
3042
|
getLogger().error(`Failed to embed message ${message.uniqueId}:`, error);
|
|
3039
3043
|
}
|
|
3040
3044
|
}
|
|
@@ -3122,6 +3126,7 @@ async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
|
3122
3126
|
}
|
|
3123
3127
|
}
|
|
3124
3128
|
} catch (error) {
|
|
3129
|
+
if (isFatalEmbeddingError(error)) throw error;
|
|
3125
3130
|
getLogger().error("Failed to batch-embed short messages:", error);
|
|
3126
3131
|
}
|
|
3127
3132
|
}
|
|
@@ -3138,12 +3143,13 @@ async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
|
3138
3143
|
await updateMessageChunksOp(ctx, msg.uniqueId, messageChunks, embeddingModel);
|
|
3139
3144
|
embeddedCount++;
|
|
3140
3145
|
} catch (error) {
|
|
3146
|
+
if (isFatalEmbeddingError(error)) throw error;
|
|
3141
3147
|
getLogger().error(`Failed to embed message ${msg.uniqueId}:`, error);
|
|
3142
3148
|
}
|
|
3143
3149
|
}
|
|
3144
3150
|
return embeddedCount;
|
|
3145
3151
|
}
|
|
3146
|
-
var DEFAULT_MIN_CONTENT_LENGTH, EMBED_MAX_ATTEMPTS, DEFAULT_EMBEDDING_BATCH_SIZE, DEFAULT_EMBEDDING_BATCH_CONCURRENCY;
|
|
3152
|
+
var DEFAULT_MIN_CONTENT_LENGTH, EMBED_MAX_ATTEMPTS, EmbeddingHttpError, DEFAULT_EMBEDDING_BATCH_SIZE, DEFAULT_EMBEDDING_BATCH_CONCURRENCY;
|
|
3147
3153
|
var init_embeddings = __esm({
|
|
3148
3154
|
"src/lib/memoryEngine/embeddings.ts"() {
|
|
3149
3155
|
"use strict";
|
|
@@ -3155,6 +3161,13 @@ var init_embeddings = __esm({
|
|
|
3155
3161
|
init_constants();
|
|
3156
3162
|
DEFAULT_MIN_CONTENT_LENGTH = 10;
|
|
3157
3163
|
EMBED_MAX_ATTEMPTS = 4;
|
|
3164
|
+
EmbeddingHttpError = class extends Error {
|
|
3165
|
+
constructor(message, status) {
|
|
3166
|
+
super(message);
|
|
3167
|
+
this.name = "EmbeddingHttpError";
|
|
3168
|
+
this.status = status;
|
|
3169
|
+
}
|
|
3170
|
+
};
|
|
3158
3171
|
DEFAULT_EMBEDDING_BATCH_SIZE = 100;
|
|
3159
3172
|
DEFAULT_EMBEDDING_BATCH_CONCURRENCY = 3;
|
|
3160
3173
|
}
|
package/dist/expo/index.mjs
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -2095,6 +2095,17 @@ async function withEmbeddingRetry(call) {
|
|
|
2095
2095
|
if (threw) throw lastThrown;
|
|
2096
2096
|
return last;
|
|
2097
2097
|
}
|
|
2098
|
+
var EmbeddingHttpError = class extends Error {
|
|
2099
|
+
constructor(message, status) {
|
|
2100
|
+
super(message);
|
|
2101
|
+
this.name = "EmbeddingHttpError";
|
|
2102
|
+
this.status = status;
|
|
2103
|
+
}
|
|
2104
|
+
};
|
|
2105
|
+
function embeddingErrorFrom(response) {
|
|
2106
|
+
const message = typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed";
|
|
2107
|
+
return new EmbeddingHttpError(message, response.response?.status);
|
|
2108
|
+
}
|
|
2098
2109
|
async function generateEmbedding(text, options) {
|
|
2099
2110
|
const { baseUrl = BASE_URL, getToken, apiKey, model, cache } = options;
|
|
2100
2111
|
if (cache) {
|
|
@@ -2126,9 +2137,7 @@ async function generateEmbedding(text, options) {
|
|
|
2126
2137
|
})
|
|
2127
2138
|
);
|
|
2128
2139
|
if (response.error) {
|
|
2129
|
-
throw
|
|
2130
|
-
typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed"
|
|
2131
|
-
);
|
|
2140
|
+
throw embeddingErrorFrom(response);
|
|
2132
2141
|
}
|
|
2133
2142
|
if (!response.data?.data?.[0]?.embedding) {
|
|
2134
2143
|
throw new Error("No embedding returned from API");
|
|
@@ -2157,9 +2166,7 @@ async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage,
|
|
|
2157
2166
|
})
|
|
2158
2167
|
);
|
|
2159
2168
|
if (response.error) {
|
|
2160
|
-
throw
|
|
2161
|
-
typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed"
|
|
2162
|
-
);
|
|
2169
|
+
throw embeddingErrorFrom(response);
|
|
2163
2170
|
}
|
|
2164
2171
|
if (!response.data?.data) {
|
|
2165
2172
|
throw new Error("No embeddings returned from API");
|
package/dist/index.mjs
CHANGED
|
@@ -1904,6 +1904,17 @@ async function withEmbeddingRetry(call) {
|
|
|
1904
1904
|
if (threw) throw lastThrown;
|
|
1905
1905
|
return last;
|
|
1906
1906
|
}
|
|
1907
|
+
var EmbeddingHttpError = class extends Error {
|
|
1908
|
+
constructor(message, status) {
|
|
1909
|
+
super(message);
|
|
1910
|
+
this.name = "EmbeddingHttpError";
|
|
1911
|
+
this.status = status;
|
|
1912
|
+
}
|
|
1913
|
+
};
|
|
1914
|
+
function embeddingErrorFrom(response) {
|
|
1915
|
+
const message = typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed";
|
|
1916
|
+
return new EmbeddingHttpError(message, response.response?.status);
|
|
1917
|
+
}
|
|
1907
1918
|
async function generateEmbedding(text, options) {
|
|
1908
1919
|
const { baseUrl = BASE_URL, getToken, apiKey, model, cache } = options;
|
|
1909
1920
|
if (cache) {
|
|
@@ -1935,9 +1946,7 @@ async function generateEmbedding(text, options) {
|
|
|
1935
1946
|
})
|
|
1936
1947
|
);
|
|
1937
1948
|
if (response.error) {
|
|
1938
|
-
throw
|
|
1939
|
-
typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed"
|
|
1940
|
-
);
|
|
1949
|
+
throw embeddingErrorFrom(response);
|
|
1941
1950
|
}
|
|
1942
1951
|
if (!response.data?.data?.[0]?.embedding) {
|
|
1943
1952
|
throw new Error("No embedding returned from API");
|
|
@@ -1966,9 +1975,7 @@ async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage,
|
|
|
1966
1975
|
})
|
|
1967
1976
|
);
|
|
1968
1977
|
if (response.error) {
|
|
1969
|
-
throw
|
|
1970
|
-
typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed"
|
|
1971
|
-
);
|
|
1978
|
+
throw embeddingErrorFrom(response);
|
|
1972
1979
|
}
|
|
1973
1980
|
if (!response.data?.data) {
|
|
1974
1981
|
throw new Error("No embeddings returned from API");
|
|
@@ -3501,6 +3501,20 @@ async function withEmbeddingRetry(call) {
|
|
|
3501
3501
|
if (threw) throw lastThrown;
|
|
3502
3502
|
return last;
|
|
3503
3503
|
}
|
|
3504
|
+
var EmbeddingHttpError = class extends Error {
|
|
3505
|
+
constructor(message, status) {
|
|
3506
|
+
super(message);
|
|
3507
|
+
this.name = "EmbeddingHttpError";
|
|
3508
|
+
this.status = status;
|
|
3509
|
+
}
|
|
3510
|
+
};
|
|
3511
|
+
function isFatalEmbeddingError(err) {
|
|
3512
|
+
return err instanceof EmbeddingHttpError && (err.status === 401 || err.status === 402 || err.status === 403);
|
|
3513
|
+
}
|
|
3514
|
+
function embeddingErrorFrom(response) {
|
|
3515
|
+
const message = typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed";
|
|
3516
|
+
return new EmbeddingHttpError(message, response.response?.status);
|
|
3517
|
+
}
|
|
3504
3518
|
async function generateEmbedding(text, options) {
|
|
3505
3519
|
const { baseUrl = BASE_URL, getToken, apiKey, model, cache } = options;
|
|
3506
3520
|
if (cache) {
|
|
@@ -3532,9 +3546,7 @@ async function generateEmbedding(text, options) {
|
|
|
3532
3546
|
})
|
|
3533
3547
|
);
|
|
3534
3548
|
if (response.error) {
|
|
3535
|
-
throw
|
|
3536
|
-
typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed"
|
|
3537
|
-
);
|
|
3549
|
+
throw embeddingErrorFrom(response);
|
|
3538
3550
|
}
|
|
3539
3551
|
if (!response.data?.data?.[0]?.embedding) {
|
|
3540
3552
|
throw new Error("No embedding returned from API");
|
|
@@ -3563,9 +3575,7 @@ async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage,
|
|
|
3563
3575
|
})
|
|
3564
3576
|
);
|
|
3565
3577
|
if (response.error) {
|
|
3566
|
-
throw
|
|
3567
|
-
typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed"
|
|
3568
|
-
);
|
|
3578
|
+
throw embeddingErrorFrom(response);
|
|
3569
3579
|
}
|
|
3570
3580
|
if (!response.data?.data) {
|
|
3571
3581
|
throw new Error("No embeddings returned from API");
|
|
@@ -3701,6 +3711,7 @@ async function embedAllMessages(ctx, options, filter) {
|
|
|
3701
3711
|
await updateMessageEmbeddingOp(ctx, message.uniqueId, embedding, embeddingModel);
|
|
3702
3712
|
embeddedCount++;
|
|
3703
3713
|
} catch (error) {
|
|
3714
|
+
if (isFatalEmbeddingError(error)) throw error;
|
|
3704
3715
|
getLogger().error(`Failed to embed message ${message.uniqueId}:`, error);
|
|
3705
3716
|
}
|
|
3706
3717
|
}
|
|
@@ -3788,6 +3799,7 @@ async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
|
3788
3799
|
}
|
|
3789
3800
|
}
|
|
3790
3801
|
} catch (error) {
|
|
3802
|
+
if (isFatalEmbeddingError(error)) throw error;
|
|
3791
3803
|
getLogger().error("Failed to batch-embed short messages:", error);
|
|
3792
3804
|
}
|
|
3793
3805
|
}
|
|
@@ -3804,6 +3816,7 @@ async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
|
3804
3816
|
await updateMessageChunksOp(ctx, msg.uniqueId, messageChunks, embeddingModel);
|
|
3805
3817
|
embeddedCount++;
|
|
3806
3818
|
} catch (error) {
|
|
3819
|
+
if (isFatalEmbeddingError(error)) throw error;
|
|
3807
3820
|
getLogger().error(`Failed to embed message ${msg.uniqueId}:`, error);
|
|
3808
3821
|
}
|
|
3809
3822
|
}
|
|
@@ -4998,7 +5011,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
4998
5011
|
legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
|
|
4999
5012
|
);
|
|
5000
5013
|
}
|
|
5001
|
-
const { recall: recall2 } = await import("./recall-
|
|
5014
|
+
const { recall: recall2 } = await import("./recall-Z2HUBS2Y.mjs");
|
|
5002
5015
|
const result = await recall2(
|
|
5003
5016
|
query,
|
|
5004
5017
|
{ vaultCtx, embeddingOptions, vaultCache: cache },
|
package/dist/react/index.cjs
CHANGED
|
@@ -3093,6 +3093,13 @@ async function withEmbeddingRetry(call) {
|
|
|
3093
3093
|
if (threw) throw lastThrown;
|
|
3094
3094
|
return last;
|
|
3095
3095
|
}
|
|
3096
|
+
function isFatalEmbeddingError(err) {
|
|
3097
|
+
return err instanceof EmbeddingHttpError && (err.status === 401 || err.status === 402 || err.status === 403);
|
|
3098
|
+
}
|
|
3099
|
+
function embeddingErrorFrom(response) {
|
|
3100
|
+
const message = typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed";
|
|
3101
|
+
return new EmbeddingHttpError(message, response.response?.status);
|
|
3102
|
+
}
|
|
3096
3103
|
async function generateEmbedding(text11, options) {
|
|
3097
3104
|
const { baseUrl = BASE_URL, getToken, apiKey, model, cache } = options;
|
|
3098
3105
|
if (cache) {
|
|
@@ -3124,9 +3131,7 @@ async function generateEmbedding(text11, options) {
|
|
|
3124
3131
|
})
|
|
3125
3132
|
);
|
|
3126
3133
|
if (response.error) {
|
|
3127
|
-
throw
|
|
3128
|
-
typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed"
|
|
3129
|
-
);
|
|
3134
|
+
throw embeddingErrorFrom(response);
|
|
3130
3135
|
}
|
|
3131
3136
|
if (!response.data?.data?.[0]?.embedding) {
|
|
3132
3137
|
throw new Error("No embedding returned from API");
|
|
@@ -3153,9 +3158,7 @@ async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage,
|
|
|
3153
3158
|
})
|
|
3154
3159
|
);
|
|
3155
3160
|
if (response.error) {
|
|
3156
|
-
throw
|
|
3157
|
-
typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed"
|
|
3158
|
-
);
|
|
3161
|
+
throw embeddingErrorFrom(response);
|
|
3159
3162
|
}
|
|
3160
3163
|
if (!response.data?.data) {
|
|
3161
3164
|
throw new Error("No embeddings returned from API");
|
|
@@ -3291,6 +3294,7 @@ async function embedAllMessages(ctx, options, filter) {
|
|
|
3291
3294
|
await updateMessageEmbeddingOp(ctx, message.uniqueId, embedding, embeddingModel);
|
|
3292
3295
|
embeddedCount++;
|
|
3293
3296
|
} catch (error) {
|
|
3297
|
+
if (isFatalEmbeddingError(error)) throw error;
|
|
3294
3298
|
getLogger().error(`Failed to embed message ${message.uniqueId}:`, error);
|
|
3295
3299
|
}
|
|
3296
3300
|
}
|
|
@@ -3378,6 +3382,7 @@ async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
|
3378
3382
|
}
|
|
3379
3383
|
}
|
|
3380
3384
|
} catch (error) {
|
|
3385
|
+
if (isFatalEmbeddingError(error)) throw error;
|
|
3381
3386
|
getLogger().error("Failed to batch-embed short messages:", error);
|
|
3382
3387
|
}
|
|
3383
3388
|
}
|
|
@@ -3394,12 +3399,13 @@ async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
|
3394
3399
|
await updateMessageChunksOp(ctx, msg.uniqueId, messageChunks, embeddingModel);
|
|
3395
3400
|
embeddedCount++;
|
|
3396
3401
|
} catch (error) {
|
|
3402
|
+
if (isFatalEmbeddingError(error)) throw error;
|
|
3397
3403
|
getLogger().error(`Failed to embed message ${msg.uniqueId}:`, error);
|
|
3398
3404
|
}
|
|
3399
3405
|
}
|
|
3400
3406
|
return embeddedCount;
|
|
3401
3407
|
}
|
|
3402
|
-
var DEFAULT_MIN_CONTENT_LENGTH, EMBED_MAX_ATTEMPTS, DEFAULT_EMBEDDING_BATCH_SIZE, DEFAULT_EMBEDDING_BATCH_CONCURRENCY;
|
|
3408
|
+
var DEFAULT_MIN_CONTENT_LENGTH, EMBED_MAX_ATTEMPTS, EmbeddingHttpError, DEFAULT_EMBEDDING_BATCH_SIZE, DEFAULT_EMBEDDING_BATCH_CONCURRENCY;
|
|
3403
3409
|
var init_embeddings = __esm({
|
|
3404
3410
|
"src/lib/memoryEngine/embeddings.ts"() {
|
|
3405
3411
|
"use strict";
|
|
@@ -3411,6 +3417,13 @@ var init_embeddings = __esm({
|
|
|
3411
3417
|
init_constants();
|
|
3412
3418
|
DEFAULT_MIN_CONTENT_LENGTH = 10;
|
|
3413
3419
|
EMBED_MAX_ATTEMPTS = 4;
|
|
3420
|
+
EmbeddingHttpError = class extends Error {
|
|
3421
|
+
constructor(message, status) {
|
|
3422
|
+
super(message);
|
|
3423
|
+
this.name = "EmbeddingHttpError";
|
|
3424
|
+
this.status = status;
|
|
3425
|
+
}
|
|
3426
|
+
};
|
|
3414
3427
|
DEFAULT_EMBEDDING_BATCH_SIZE = 100;
|
|
3415
3428
|
DEFAULT_EMBEDDING_BATCH_CONCURRENCY = 3;
|
|
3416
3429
|
}
|
package/dist/react/index.mjs
CHANGED
|
@@ -17328,6 +17328,20 @@ async function withEmbeddingRetry(call) {
|
|
|
17328
17328
|
if (threw) throw lastThrown;
|
|
17329
17329
|
return last;
|
|
17330
17330
|
}
|
|
17331
|
+
var EmbeddingHttpError = class extends Error {
|
|
17332
|
+
constructor(message, status) {
|
|
17333
|
+
super(message);
|
|
17334
|
+
this.name = "EmbeddingHttpError";
|
|
17335
|
+
this.status = status;
|
|
17336
|
+
}
|
|
17337
|
+
};
|
|
17338
|
+
function isFatalEmbeddingError(err) {
|
|
17339
|
+
return err instanceof EmbeddingHttpError && (err.status === 401 || err.status === 402 || err.status === 403);
|
|
17340
|
+
}
|
|
17341
|
+
function embeddingErrorFrom(response) {
|
|
17342
|
+
const message = typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed";
|
|
17343
|
+
return new EmbeddingHttpError(message, response.response?.status);
|
|
17344
|
+
}
|
|
17331
17345
|
async function generateEmbedding(text, options) {
|
|
17332
17346
|
const { baseUrl = BASE_URL, getToken, apiKey, model, cache } = options;
|
|
17333
17347
|
if (cache) {
|
|
@@ -17359,9 +17373,7 @@ async function generateEmbedding(text, options) {
|
|
|
17359
17373
|
})
|
|
17360
17374
|
);
|
|
17361
17375
|
if (response.error) {
|
|
17362
|
-
throw
|
|
17363
|
-
typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed"
|
|
17364
|
-
);
|
|
17376
|
+
throw embeddingErrorFrom(response);
|
|
17365
17377
|
}
|
|
17366
17378
|
if (!response.data?.data?.[0]?.embedding) {
|
|
17367
17379
|
throw new Error("No embedding returned from API");
|
|
@@ -17390,9 +17402,7 @@ async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage,
|
|
|
17390
17402
|
})
|
|
17391
17403
|
);
|
|
17392
17404
|
if (response.error) {
|
|
17393
|
-
throw
|
|
17394
|
-
typeof response.error === "object" && response.error && "error" in response.error ? response.error.error : "API embedding failed"
|
|
17395
|
-
);
|
|
17405
|
+
throw embeddingErrorFrom(response);
|
|
17396
17406
|
}
|
|
17397
17407
|
if (!response.data?.data) {
|
|
17398
17408
|
throw new Error("No embeddings returned from API");
|
|
@@ -17528,6 +17538,7 @@ async function embedAllMessages(ctx, options, filter) {
|
|
|
17528
17538
|
await updateMessageEmbeddingOp(ctx, message.uniqueId, embedding, embeddingModel);
|
|
17529
17539
|
embeddedCount++;
|
|
17530
17540
|
} catch (error) {
|
|
17541
|
+
if (isFatalEmbeddingError(error)) throw error;
|
|
17531
17542
|
getLogger().error(`Failed to embed message ${message.uniqueId}:`, error);
|
|
17532
17543
|
}
|
|
17533
17544
|
}
|
|
@@ -17615,6 +17626,7 @@ async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
|
17615
17626
|
}
|
|
17616
17627
|
}
|
|
17617
17628
|
} catch (error) {
|
|
17629
|
+
if (isFatalEmbeddingError(error)) throw error;
|
|
17618
17630
|
getLogger().error("Failed to batch-embed short messages:", error);
|
|
17619
17631
|
}
|
|
17620
17632
|
}
|
|
@@ -17631,6 +17643,7 @@ async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
|
17631
17643
|
await updateMessageChunksOp(ctx, msg.uniqueId, messageChunks, embeddingModel);
|
|
17632
17644
|
embeddedCount++;
|
|
17633
17645
|
} catch (error) {
|
|
17646
|
+
if (isFatalEmbeddingError(error)) throw error;
|
|
17634
17647
|
getLogger().error(`Failed to embed message ${msg.uniqueId}:`, error);
|
|
17635
17648
|
}
|
|
17636
17649
|
}
|
|
@@ -18825,7 +18838,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
18825
18838
|
legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
|
|
18826
18839
|
);
|
|
18827
18840
|
}
|
|
18828
|
-
const { recall: recall2 } = await import("./recall-
|
|
18841
|
+
const { recall: recall2 } = await import("./recall-IF2HX7ZA.mjs");
|
|
18829
18842
|
const result = await recall2(
|
|
18830
18843
|
query,
|
|
18831
18844
|
{ vaultCtx, embeddingOptions, vaultCache: cache },
|
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
|
}
|
package/dist/server/index.mjs
CHANGED