@simulacra-ai/core 0.0.5 → 0.0.8

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/index.cjs CHANGED
@@ -599,6 +599,9 @@ var RETRYABLE_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
599
599
  var RETRYABLE_HTTP_STATUS_CODES = /* @__PURE__ */ new Set([408, 429, 500, 502, 503, 504, 529]);
600
600
  function defaultRetryable(result) {
601
601
  const error = result.error;
602
+ if (error instanceof OperationCanceledError) {
603
+ return false;
604
+ }
602
605
  if (error !== null && error !== void 0 && typeof error === "object" && "status" in error) {
603
606
  const status = error.status;
604
607
  if (typeof status === "number") {
@@ -620,7 +623,7 @@ function defaultRetryable(result) {
620
623
  }
621
624
  if (error instanceof Error) {
622
625
  const msg = error.message.toLowerCase();
623
- if (msg.includes("timeout") || msg.includes("econnreset") || msg.includes("econnrefused") || msg.includes("socket hang up") || msg.includes("network error") || msg.includes("fetch failed")) {
626
+ if (msg.includes("timeout") || msg.includes("econnreset") || msg.includes("econnrefused") || msg.includes("socket hang up") || msg.includes("network error") || msg.includes("fail")) {
624
627
  return true;
625
628
  }
626
629
  }
@@ -666,6 +669,7 @@ var RetryPolicy = class _RetryPolicy extends Policy {
666
669
  metadata
667
670
  };
668
671
  } catch (error) {
672
+ cancellation_token.throw_if_cancellation_requested();
669
673
  metadata.attempts = attempt;
670
674
  const result = {
671
675
  result: false,
@@ -2219,8 +2223,8 @@ function defined_keys(obj) {
2219
2223
  return Object.keys(obj).filter((key) => obj[key] !== void 0);
2220
2224
  }
2221
2225
  function undefined_if_empty(obj) {
2222
- if (!obj) {
2223
- return obj;
2226
+ if (obj === null || obj === void 0) {
2227
+ return void 0;
2224
2228
  }
2225
2229
  if (Array.isArray(obj)) {
2226
2230
  return obj.length === 0 ? void 0 : obj;