@mindstudio-ai/remy 0.1.281 → 0.1.282
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/headless.js +14 -3
- package/dist/index.js +15 -4
- package/package.json +1 -1
package/dist/headless.js
CHANGED
|
@@ -281,8 +281,19 @@ async function* streamChat(params) {
|
|
|
281
281
|
}
|
|
282
282
|
var MAX_RETRIES = 5;
|
|
283
283
|
var INITIAL_BACKOFF_MS = 1e3;
|
|
284
|
-
|
|
285
|
-
|
|
284
|
+
var RETRYABLE_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
285
|
+
"api_error",
|
|
286
|
+
// Anthropic's 500-equivalent ("The server had an error…")
|
|
287
|
+
"overloaded_error"
|
|
288
|
+
// Anthropic's 529-equivalent
|
|
289
|
+
]);
|
|
290
|
+
function isRetryableError(error, code) {
|
|
291
|
+
if (code && RETRYABLE_ERROR_CODES.has(code)) {
|
|
292
|
+
return true;
|
|
293
|
+
}
|
|
294
|
+
return /Network error/i.test(error) || /HTTP 5\d\d/i.test(error) || /Stream stalled/i.test(error) || /overloaded/i.test(error) || /terminated/i.test(error) || // The API's friendly mapping of a provider 500 — belt-and-suspenders for
|
|
295
|
+
// pods that don't send a machine-readable code.
|
|
296
|
+
/Internal API error/i.test(error) || // Anthropic fetches url-source image blocks server-side on every call;
|
|
286
297
|
// a transient failure anywhere in that chain (S3 signing edge, resize
|
|
287
298
|
// proxy, their fetcher) surfaces as this message. The images themselves
|
|
288
299
|
// are fine — the same URLs typically succeed on the next attempt.
|
|
@@ -297,7 +308,7 @@ async function* streamChatWithRetry(params, options) {
|
|
|
297
308
|
let retryableFailure = false;
|
|
298
309
|
for await (const event of streamChat(params)) {
|
|
299
310
|
if (event.type === "error") {
|
|
300
|
-
if (isRetryableError(event.error) && attempt < MAX_RETRIES - 1) {
|
|
311
|
+
if (isRetryableError(event.error, event.code) && attempt < MAX_RETRIES - 1) {
|
|
301
312
|
options?.onRetry?.(attempt, event.error);
|
|
302
313
|
retryableFailure = true;
|
|
303
314
|
break;
|
package/dist/index.js
CHANGED
|
@@ -262,8 +262,13 @@ async function* streamChat(params) {
|
|
|
262
262
|
};
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
function isRetryableError(error) {
|
|
266
|
-
|
|
265
|
+
function isRetryableError(error, code) {
|
|
266
|
+
if (code && RETRYABLE_ERROR_CODES.has(code)) {
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
return /Network error/i.test(error) || /HTTP 5\d\d/i.test(error) || /Stream stalled/i.test(error) || /overloaded/i.test(error) || /terminated/i.test(error) || // The API's friendly mapping of a provider 500 — belt-and-suspenders for
|
|
270
|
+
// pods that don't send a machine-readable code.
|
|
271
|
+
/Internal API error/i.test(error) || // Anthropic fetches url-source image blocks server-side on every call;
|
|
267
272
|
// a transient failure anywhere in that chain (S3 signing edge, resize
|
|
268
273
|
// proxy, their fetcher) surfaces as this message. The images themselves
|
|
269
274
|
// are fine — the same URLs typically succeed on the next attempt.
|
|
@@ -278,7 +283,7 @@ async function* streamChatWithRetry(params, options) {
|
|
|
278
283
|
let retryableFailure = false;
|
|
279
284
|
for await (const event of streamChat(params)) {
|
|
280
285
|
if (event.type === "error") {
|
|
281
|
-
if (isRetryableError(event.error) && attempt < MAX_RETRIES - 1) {
|
|
286
|
+
if (isRetryableError(event.error, event.code) && attempt < MAX_RETRIES - 1) {
|
|
282
287
|
options?.onRetry?.(attempt, event.error);
|
|
283
288
|
retryableFailure = true;
|
|
284
289
|
break;
|
|
@@ -360,7 +365,7 @@ async function fetchRemyContext(config) {
|
|
|
360
365
|
return null;
|
|
361
366
|
}
|
|
362
367
|
}
|
|
363
|
-
var log, MAX_RETRIES, INITIAL_BACKOFF_MS, FALLBACK_ACK;
|
|
368
|
+
var log, MAX_RETRIES, INITIAL_BACKOFF_MS, RETRYABLE_ERROR_CODES, FALLBACK_ACK;
|
|
364
369
|
var init_api = __esm({
|
|
365
370
|
"src/api.ts"() {
|
|
366
371
|
"use strict";
|
|
@@ -368,6 +373,12 @@ var init_api = __esm({
|
|
|
368
373
|
log = createLogger("api");
|
|
369
374
|
MAX_RETRIES = 5;
|
|
370
375
|
INITIAL_BACKOFF_MS = 1e3;
|
|
376
|
+
RETRYABLE_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
377
|
+
"api_error",
|
|
378
|
+
// Anthropic's 500-equivalent ("The server had an error…")
|
|
379
|
+
"overloaded_error"
|
|
380
|
+
// Anthropic's 529-equivalent
|
|
381
|
+
]);
|
|
371
382
|
FALLBACK_ACK = "[Message sent to agent. Agent is working in the background and will report back with its results when finished.]";
|
|
372
383
|
}
|
|
373
384
|
});
|