@simulacra-ai/core 0.0.6 → 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.d.cts CHANGED
@@ -1597,7 +1597,7 @@ declare class TokenLimitPolicy extends Policy {
1597
1597
  * @param obj - The value to check.
1598
1598
  * @returns The value if non-empty, otherwise undefined.
1599
1599
  */
1600
- declare function undefined_if_empty<T = unknown>(obj: T): T | undefined;
1600
+ declare function undefined_if_empty<T = unknown>(obj: T): (T & {}) | undefined;
1601
1601
  /**
1602
1602
  * Recursively merges two values together.
1603
1603
  *
package/dist/index.d.ts CHANGED
@@ -1597,7 +1597,7 @@ declare class TokenLimitPolicy extends Policy {
1597
1597
  * @param obj - The value to check.
1598
1598
  * @returns The value if non-empty, otherwise undefined.
1599
1599
  */
1600
- declare function undefined_if_empty<T = unknown>(obj: T): T | undefined;
1600
+ declare function undefined_if_empty<T = unknown>(obj: T): (T & {}) | undefined;
1601
1601
  /**
1602
1602
  * Recursively merges two values together.
1603
1603
  *
package/dist/index.js CHANGED
@@ -540,6 +540,9 @@ var RETRYABLE_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
540
540
  var RETRYABLE_HTTP_STATUS_CODES = /* @__PURE__ */ new Set([408, 429, 500, 502, 503, 504, 529]);
541
541
  function defaultRetryable(result) {
542
542
  const error = result.error;
543
+ if (error instanceof OperationCanceledError) {
544
+ return false;
545
+ }
543
546
  if (error !== null && error !== void 0 && typeof error === "object" && "status" in error) {
544
547
  const status = error.status;
545
548
  if (typeof status === "number") {
@@ -561,7 +564,7 @@ function defaultRetryable(result) {
561
564
  }
562
565
  if (error instanceof Error) {
563
566
  const msg = error.message.toLowerCase();
564
- if (msg.includes("timeout") || msg.includes("econnreset") || msg.includes("econnrefused") || msg.includes("socket hang up") || msg.includes("network error") || msg.includes("fetch failed")) {
567
+ if (msg.includes("timeout") || msg.includes("econnreset") || msg.includes("econnrefused") || msg.includes("socket hang up") || msg.includes("network error") || msg.includes("fail")) {
565
568
  return true;
566
569
  }
567
570
  }
@@ -607,6 +610,7 @@ var RetryPolicy = class _RetryPolicy extends Policy {
607
610
  metadata
608
611
  };
609
612
  } catch (error) {
613
+ cancellation_token.throw_if_cancellation_requested();
610
614
  metadata.attempts = attempt;
611
615
  const result = {
612
616
  result: false,
@@ -2160,8 +2164,8 @@ function defined_keys(obj) {
2160
2164
  return Object.keys(obj).filter((key) => obj[key] !== void 0);
2161
2165
  }
2162
2166
  function undefined_if_empty(obj) {
2163
- if (!obj) {
2164
- return obj;
2167
+ if (obj === null || obj === void 0) {
2168
+ return void 0;
2165
2169
  }
2166
2170
  if (Array.isArray(obj)) {
2167
2171
  return obj.length === 0 ? void 0 : obj;