@bastani/pi-ai 0.9.74 → 0.9.75-alpha.1

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.
Files changed (82) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +3 -1
  3. package/dist/api/anthropic-messages.d.ts.map +1 -1
  4. package/dist/api/anthropic-messages.js +21 -7
  5. package/dist/api/anthropic-messages.js.map +1 -1
  6. package/dist/api/bedrock-converse-stream.d.ts.map +1 -1
  7. package/dist/api/bedrock-converse-stream.js +4 -2
  8. package/dist/api/bedrock-converse-stream.js.map +1 -1
  9. package/dist/api/constrained-sampling.d.ts +0 -2
  10. package/dist/api/constrained-sampling.d.ts.map +1 -1
  11. package/dist/api/constrained-sampling.js +0 -13
  12. package/dist/api/constrained-sampling.js.map +1 -1
  13. package/dist/api/openai-completions.d.ts.map +1 -1
  14. package/dist/api/openai-completions.js +9 -5
  15. package/dist/api/openai-completions.js.map +1 -1
  16. package/dist/api/openai-images-options.d.ts +18 -5
  17. package/dist/api/openai-images-options.d.ts.map +1 -1
  18. package/dist/api/openai-images-options.js +9 -3
  19. package/dist/api/openai-images-options.js.map +1 -1
  20. package/dist/api/openai-images.d.ts.map +1 -1
  21. package/dist/api/openai-images.js +121 -19
  22. package/dist/api/openai-images.js.map +1 -1
  23. package/dist/api/openai-responses.d.ts.map +1 -1
  24. package/dist/api/openai-responses.js +10 -3
  25. package/dist/api/openai-responses.js.map +1 -1
  26. package/dist/api/strict-tool-limits.d.ts +13 -0
  27. package/dist/api/strict-tool-limits.d.ts.map +1 -0
  28. package/dist/api/strict-tool-limits.js +50 -0
  29. package/dist/api/strict-tool-limits.js.map +1 -0
  30. package/dist/auth/types.d.ts +7 -0
  31. package/dist/auth/types.d.ts.map +1 -1
  32. package/dist/auth/types.js.map +1 -1
  33. package/dist/cache-warming.d.ts +53 -0
  34. package/dist/cache-warming.d.ts.map +1 -0
  35. package/dist/cache-warming.js +82 -0
  36. package/dist/cache-warming.js.map +1 -0
  37. package/dist/image-generation-error.d.ts +10 -3
  38. package/dist/image-generation-error.d.ts.map +1 -1
  39. package/dist/image-generation-error.js +3 -2
  40. package/dist/image-generation-error.js.map +1 -1
  41. package/dist/index.d.ts +3 -1
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +3 -1
  44. package/dist/index.js.map +1 -1
  45. package/dist/models.d.ts +15 -6
  46. package/dist/models.d.ts.map +1 -1
  47. package/dist/models.js +22 -7
  48. package/dist/models.js.map +1 -1
  49. package/dist/providers/data/.manifest.json +1 -1
  50. package/dist/providers/data/amazon-bedrock.json +1 -1
  51. package/dist/providers/data/anthropic.json +1 -1
  52. package/dist/providers/data/azure.json +1 -1
  53. package/dist/providers/data/google.json +1 -1
  54. package/dist/providers/data/meta.json +1 -1
  55. package/dist/providers/data/opencode-go.json +1 -1
  56. package/dist/providers/data/opencode.json +1 -1
  57. package/dist/providers/data/openrouter.json +1 -1
  58. package/dist/providers/data/vercel-ai-gateway.json +1 -1
  59. package/dist/providers/github-copilot-errors.d.ts +17 -5
  60. package/dist/providers/github-copilot-errors.d.ts.map +1 -1
  61. package/dist/providers/github-copilot-errors.js +55 -11
  62. package/dist/providers/github-copilot-errors.js.map +1 -1
  63. package/dist/providers/github-copilot-stream-attempt.d.ts +27 -0
  64. package/dist/providers/github-copilot-stream-attempt.d.ts.map +1 -0
  65. package/dist/providers/github-copilot-stream-attempt.js +45 -0
  66. package/dist/providers/github-copilot-stream-attempt.js.map +1 -0
  67. package/dist/providers/github-copilot.d.ts +10 -2
  68. package/dist/providers/github-copilot.d.ts.map +1 -1
  69. package/dist/providers/github-copilot.js +62 -36
  70. package/dist/providers/github-copilot.js.map +1 -1
  71. package/dist/types.d.ts +2 -0
  72. package/dist/types.d.ts.map +1 -1
  73. package/dist/types.js.map +1 -1
  74. package/dist/utils/stream-deadline.d.ts +6 -2
  75. package/dist/utils/stream-deadline.d.ts.map +1 -1
  76. package/dist/utils/stream-deadline.js +12 -3
  77. package/dist/utils/stream-deadline.js.map +1 -1
  78. package/dist/utils/version.d.ts +1 -1
  79. package/dist/utils/version.d.ts.map +1 -1
  80. package/dist/utils/version.js +1 -1
  81. package/dist/utils/version.js.map +1 -1
  82. package/package.json +3 -3
@@ -125,8 +125,9 @@ export class ImageGenerationError extends Error {
125
125
  }
126
126
  }
127
127
  /**
128
- * The request options or input are invalid. Thrown before any request is sent, so nothing was
129
- * billed and retrying the same request fails the same way.
128
+ * The request options or input are invalid. Found before any request is sent, or reported by the
129
+ * API as a rejected option (`reason` `required-by-api`, `rejected-by-api` or `unsupported-by-api`).
130
+ * Either way nothing was billed and retrying the same request fails the same way.
130
131
  */
131
132
  export class ImageGenerationConfigError extends ImageGenerationError {
132
133
  source = "sdk";
@@ -1 +1 @@
1
- {"version":3,"file":"image-generation-error.js","sourceRoot":"","sources":["../src/image-generation-error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAoCH,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,eAAe,GAAG,iCAAiC,CAAC;AAC1D,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAChC,QAAQ;IACR,YAAY;IACZ,eAAe;IACf,cAAc;IACd,QAAQ;IACR,UAAU;IACV,OAAO;IACP,OAAO;IACP,WAAW;IACX,cAAc;IACd,cAAc;IACd,YAAY;IACZ,cAAc;IACd,QAAQ;IACR,QAAQ;IACR,cAAc;IACd,OAAO;IACP,QAAQ;IACR,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,UAAU;IACV,WAAW;IACX,aAAa;IACb,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,SAAS;IACT,WAAW;IACX,UAAU;IACV,SAAS;IACT,OAAO;IACP,OAAO;IACP,QAAQ;IACR,iBAAiB;IACjB,WAAW;IACX,WAAW;IACX,UAAU;IACV,YAAY;CACZ,CAAC,CAAC;AAEH,SAAS,eAAe,CAAC,IAAa;IACrC,OAA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,KAAK,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAAC,IAA8B;IAC1E,OAAO,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["/**\n * Typed failures of `generateImages()`.\n *\n * One family, {@link ImageGenerationError}, covers every failure the image providers can\n * classify: a rejected request configuration ({@link ImageGenerationConfigError}), an API\n * failure ({@link ImageGenerationApiError} and its subclasses) and a client-side timeout\n * ({@link ImageGenerationTimeoutError}). Branch on the class, its guard or `code`, never on\n * `message`. Cancellation is not a failure: an aborted request resolves with\n * `stopReason: \"aborted\"` and no error.\n */\n\nexport type ImageGenerationErrorFieldValue = string | number | boolean | readonly string[] | undefined;\n\n/** A foreign cause with its name, a safe errno code, and a redacted message. */\nexport interface ImageGenerationForeignCauseData {\n\tname: string;\n\tmessage: string;\n\tcode?: string;\n\tcause?: ImageGenerationErrorData | ImageGenerationForeignCauseData;\n}\n\n/** JSON-safe form of an {@link ImageGenerationError}, for results, IPC and worker boundaries. */\nexport interface ImageGenerationErrorData {\n\tname: string;\n\tcode: string;\n\tmessage: string;\n\thint?: string;\n\tretryable: boolean;\n\tfields: Record<string, ImageGenerationErrorFieldValue>;\n\t/**\n\t * The next link of the `cause` chain. Family errors keep their data; foreign errors keep their\n\t * name and known errno code, with their message redacted. At most eight links are kept.\n\t */\n\tcause?: ImageGenerationErrorData | ImageGenerationForeignCauseData;\n}\n\ninterface ImageGenerationErrorInit {\n\tname: string;\n\tcode: string;\n\tmessage: string;\n\thint?: string;\n\tretryable?: boolean;\n\tcause?: unknown;\n}\n\nconst MAX_CAUSE_DEPTH = 8;\nconst FOREIGN_MESSAGE = \"[foreign error message omitted]\";\nconst SAFE_ERRNO_CODES = new Set([\n\t\"EACCES\",\n\t\"EADDRINUSE\",\n\t\"EADDRNOTAVAIL\",\n\t\"EAFNOSUPPORT\",\n\t\"EAGAIN\",\n\t\"EALREADY\",\n\t\"EBADF\",\n\t\"EBUSY\",\n\t\"ECANCELED\",\n\t\"ECONNABORTED\",\n\t\"ECONNREFUSED\",\n\t\"ECONNRESET\",\n\t\"EDESTADDRREQ\",\n\t\"EEXIST\",\n\t\"EFAULT\",\n\t\"EHOSTUNREACH\",\n\t\"EINTR\",\n\t\"EINVAL\",\n\t\"EIO\",\n\t\"EISDIR\",\n\t\"EMFILE\",\n\t\"EMSGSIZE\",\n\t\"ENETDOWN\",\n\t\"ENETRESET\",\n\t\"ENETUNREACH\",\n\t\"ENFILE\",\n\t\"ENOENT\",\n\t\"ENOMEM\",\n\t\"ENOSPC\",\n\t\"ENOTCONN\",\n\t\"ENOTDIR\",\n\t\"ENOTFOUND\",\n\t\"ENOTSOCK\",\n\t\"ENOTSUP\",\n\t\"EPIPE\",\n\t\"EPERM\",\n\t\"EPROTO\",\n\t\"EPROTONOSUPPORT\",\n\t\"ETIMEDOUT\",\n\t\"EAI_AGAIN\",\n\t\"EAI_FAIL\",\n\t\"EAI_NONAME\",\n]);\n\nfunction safeForeignName(name: unknown): string {\n\treturn typeof name === \"string\" && /^[A-Za-z][A-Za-z0-9_]{0,79}$/.test(name) ? name : \"Error\";\n}\n\nfunction safeErrno(code: unknown): string | undefined {\n\treturn typeof code === \"string\" && SAFE_ERRNO_CODES.has(code) ? code : undefined;\n}\n\nfunction sanitizeCause(cause: unknown, depth: number): Error | undefined {\n\tif (depth > MAX_CAUSE_DEPTH || !(cause instanceof Error)) return undefined;\n\tif (cause instanceof ImageGenerationError) return cause;\n\tconst nested = sanitizeCause(cause.cause, depth + 1);\n\tconst safe = new Error(FOREIGN_MESSAGE, nested ? { cause: nested } : undefined);\n\tsafe.name = safeForeignName(cause.name);\n\tconst code = safeErrno((cause as Error & { code?: unknown }).code);\n\tif (code) Object.assign(safe, { code });\n\treturn safe;\n}\n\n/** Base of every typed image-generation failure. */\nexport class ImageGenerationError extends Error {\n\toverride readonly name: string;\n\treadonly code: string;\n\t/** True when the same request may succeed if sent again unchanged. */\n\treadonly retryable: boolean;\n\treadonly hint?: string;\n\n\tconstructor(init: ImageGenerationErrorInit) {\n\t\tsuper(init.message, { cause: sanitizeCause(init.cause, 2) });\n\t\tthis.name = init.name;\n\t\tthis.code = init.code;\n\t\tthis.retryable = init.retryable ?? false;\n\t\tthis.hint = init.hint;\n\t}\n\n\t/** Safe, JSON-serializable context for this failure. Overridden by classes that carry fields. */\n\tprotected dataFields(): Record<string, ImageGenerationErrorFieldValue> {\n\t\treturn {};\n\t}\n\n\ttoData(): ImageGenerationErrorData {\n\t\treturn this.dataWithCauses(1);\n\t}\n\n\tprivate static causeData(\n\t\tcause: unknown,\n\t\tdepth: number,\n\t): ImageGenerationErrorData | ImageGenerationForeignCauseData | undefined {\n\t\tif (depth > MAX_CAUSE_DEPTH || !(cause instanceof Error)) return undefined;\n\t\tif (cause instanceof ImageGenerationError) return cause.dataWithCauses(depth);\n\t\tconst code = safeErrno((cause as Error & { code?: unknown }).code);\n\t\tconst nested = ImageGenerationError.causeData(cause.cause, depth + 1);\n\t\treturn {\n\t\t\tname: safeForeignName(cause.name),\n\t\t\tmessage: FOREIGN_MESSAGE,\n\t\t\t...(code ? { code } : {}),\n\t\t\t...(nested ? { cause: nested } : {}),\n\t\t};\n\t}\n\n\tprivate dataWithCauses(depth: number): ImageGenerationErrorData {\n\t\tconst causeData = ImageGenerationError.causeData(this.cause, depth + 1);\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tcode: this.code,\n\t\t\tmessage: this.message,\n\t\t\t...(this.hint !== undefined ? { hint: this.hint } : {}),\n\t\t\tretryable: this.retryable,\n\t\t\tfields: this.dataFields(),\n\t\t\t...(causeData ? { cause: causeData } : {}),\n\t\t};\n\t}\n\n\ttoJSON(): ImageGenerationErrorData {\n\t\treturn this.toData();\n\t}\n}\n\nexport type ImageGenerationConfigReason =\n\t| \"out-of-range\"\n\t| \"requires-option\"\n\t| \"conflicts-with-option\"\n\t| \"generation-only\"\n\t| \"unsupported-by-model\"\n\t| \"requires-base-image\"\n\t| \"duplicate-role\";\n\nexport interface ImageGenerationConfigErrorInit {\n\tmodel: string;\n\tfield: string;\n\treason: ImageGenerationConfigReason;\n\t/** The other option or request part that `field` conflicts with or depends on. */\n\trelated?: string;\n\t/** What is wrong, in words. Names options only and never echoes prompt or image content. */\n\tdetail: string;\n\thint: string;\n\tcause?: unknown;\n}\n\n/**\n * The request options or input are invalid. Thrown before any request is sent, so nothing was\n * billed and retrying the same request fails the same way.\n */\nexport class ImageGenerationConfigError extends ImageGenerationError {\n\tdeclare readonly name: \"ImageGenerationConfigError\";\n\tdeclare readonly code: \"invalid-option\";\n\treadonly source = \"sdk\" as const;\n\treadonly model: string;\n\treadonly field: string;\n\treadonly reason: ImageGenerationConfigReason;\n\treadonly related?: string;\n\treadonly detail: string;\n\n\tconstructor(init: ImageGenerationConfigErrorInit) {\n\t\tsuper({\n\t\t\tname: \"ImageGenerationConfigError\",\n\t\t\tcode: \"invalid-option\",\n\t\t\tmessage: `Invalid image generation option: ${init.field} for ${init.model} (invalid-option). ${init.detail}. ${init.hint}`,\n\t\t\thint: init.hint,\n\t\t\tcause: init.cause,\n\t\t});\n\t\tthis.model = init.model;\n\t\tthis.field = init.field;\n\t\tthis.reason = init.reason;\n\t\tthis.related = init.related;\n\t\tthis.detail = init.detail;\n\t}\n\n\tprotected override dataFields(): Record<string, ImageGenerationErrorFieldValue> {\n\t\treturn {\n\t\t\tsource: this.source,\n\t\t\tmodel: this.model,\n\t\t\tfield: this.field,\n\t\t\treason: this.reason,\n\t\t\trelated: this.related,\n\t\t\tdetail: this.detail,\n\t\t};\n\t}\n}\n\nexport type ImageGenerationApiErrorCode =\n\t| \"api-error\"\n\t| \"quota-exceeded\"\n\t| \"rate-limited\"\n\t| \"server-error\"\n\t| \"user-error\"\n\t| \"moderation-blocked\";\n\nexport interface ImageGenerationApiErrorInit {\n\t/**\n\t * A summary built from the HTTP status and the provider's type, code and request ID. Never the\n\t * provider's message, which can quote the prompt.\n\t */\n\tdetail: string;\n\tstatus?: number;\n\t/** The provider's `error.code`, for example `insufficient_quota` or `moderation_blocked`. */\n\tapiCode?: string;\n\t/** The provider's `error.type`, for example `image_generation_user_error`. */\n\tapiType?: string;\n\trequestId?: string;\n\tretryable?: boolean;\n\tcause?: unknown;\n}\n\nconst API_ERROR_HINTS = {\n\t\"api-error\": \"Check the status and provider code, then correct the request or credentials.\",\n\t\"quota-exceeded\": \"Add credit or raise the usage limit on the OpenAI account. Retrying will not help.\",\n\t\"rate-limited\": \"Wait and retry, or set maxRetries to retry automatically.\",\n\t\"server-error\": \"The provider failed. Retry later, or set maxRetries to retry automatically.\",\n\t\"user-error\": \"Change the prompt or the input images before sending the request again.\",\n\t\"moderation-blocked\": \"Revise the prompt or input images. Retrying the same request is blocked again.\",\n} as const satisfies Record<ImageGenerationApiErrorCode, string>;\n\n/** The image API answered with a failure. Subclasses name the cases a caller handles differently. */\nexport class ImageGenerationApiError extends ImageGenerationError {\n\tdeclare readonly name: \"ImageGenerationApiError\" | (typeof API_SUBCLASS_NAMES)[number];\n\tdeclare readonly code: ImageGenerationApiErrorCode;\n\treadonly status?: number;\n\treadonly apiCode?: string;\n\treadonly apiType?: string;\n\treadonly requestId?: string;\n\treadonly detail: string;\n\n\tconstructor(init: ImageGenerationApiErrorInit, identity: ApiErrorIdentity = DEFAULT_API_IDENTITY) {\n\t\tsuper({\n\t\t\tname: identity.name,\n\t\t\tcode: identity.code,\n\t\t\tmessage: `Image generation request failed (${identity.code}): ${init.detail}`,\n\t\t\thint: API_ERROR_HINTS[identity.code],\n\t\t\tretryable: init.retryable ?? identity.retryable,\n\t\t\tcause: init.cause,\n\t\t});\n\t\tthis.detail = init.detail;\n\t\tthis.status = init.status;\n\t\tthis.apiCode = init.apiCode;\n\t\tthis.apiType = init.apiType;\n\t\tthis.requestId = init.requestId;\n\t}\n\n\tprotected override dataFields(): Record<string, ImageGenerationErrorFieldValue> {\n\t\treturn {\n\t\t\tdetail: this.detail,\n\t\t\tstatus: this.status,\n\t\t\tapiCode: this.apiCode,\n\t\t\tapiType: this.apiType,\n\t\t\trequestId: this.requestId,\n\t\t};\n\t}\n}\n\nconst API_SUBCLASS_NAMES = [\n\t\"ImageGenerationQuotaError\",\n\t\"ImageGenerationRateLimitError\",\n\t\"ImageGenerationServerError\",\n\t\"ImageGenerationUserError\",\n\t\"ImageModerationBlockedError\",\n] as const;\n\ninterface ApiErrorIdentity {\n\tname: ImageGenerationApiError[\"name\"];\n\tcode: ImageGenerationApiErrorCode;\n\tretryable: boolean;\n}\n\nconst DEFAULT_API_IDENTITY: ApiErrorIdentity = { name: \"ImageGenerationApiError\", code: \"api-error\", retryable: false };\n\n/** The account is out of quota or credit. Not retryable, even though it arrives as HTTP 429. */\nexport class ImageGenerationQuotaError extends ImageGenerationApiError {\n\tdeclare readonly name: \"ImageGenerationQuotaError\";\n\tdeclare readonly code: \"quota-exceeded\";\n\tconstructor(init: ImageGenerationApiErrorInit) {\n\t\tsuper(init, { name: \"ImageGenerationQuotaError\", code: \"quota-exceeded\", retryable: false });\n\t}\n}\n\n/** The request rate limit was hit. Retryable after a delay. */\nexport class ImageGenerationRateLimitError extends ImageGenerationApiError {\n\tdeclare readonly name: \"ImageGenerationRateLimitError\";\n\tdeclare readonly code: \"rate-limited\";\n\tconstructor(init: ImageGenerationApiErrorInit) {\n\t\tsuper(init, { name: \"ImageGenerationRateLimitError\", code: \"rate-limited\", retryable: true });\n\t}\n}\n\n/** The provider failed with a 5xx status. Retryable. */\nexport class ImageGenerationServerError extends ImageGenerationApiError {\n\tdeclare readonly name: \"ImageGenerationServerError\";\n\tdeclare readonly code: \"server-error\";\n\tconstructor(init: ImageGenerationApiErrorInit) {\n\t\tsuper(init, { name: \"ImageGenerationServerError\", code: \"server-error\", retryable: true });\n\t}\n}\n\n/**\n * The provider rejected the request as user-correctable (`error.type` is\n * `image_generation_user_error`). Not retryable until the prompt or the input images change.\n * `apiCode` is the stable discriminator, for example `moderation_blocked`.\n */\nexport class ImageGenerationUserError extends ImageGenerationApiError {\n\tdeclare readonly name: \"ImageGenerationUserError\" | \"ImageModerationBlockedError\";\n\tdeclare readonly code: \"user-error\" | \"moderation-blocked\";\n\tconstructor(init: ImageGenerationApiErrorInit, identity?: ApiErrorIdentity) {\n\t\tsuper(init, identity ?? { name: \"ImageGenerationUserError\", code: \"user-error\", retryable: false });\n\t}\n}\n\nexport type ImageModerationStage = \"input\" | \"output\" | \"unknown\";\n\nexport interface ImageModerationBlockedErrorInit extends ImageGenerationApiErrorInit {\n\tmoderationStage?: ImageModerationStage;\n\tcategories?: readonly string[];\n}\n\n/** Content moderation blocked the prompt, the input images or the generated image. */\nexport class ImageModerationBlockedError extends ImageGenerationUserError {\n\tdeclare readonly name: \"ImageModerationBlockedError\";\n\tdeclare readonly code: \"moderation-blocked\";\n\t/** Where the block happened, when the provider says. */\n\treadonly moderationStage?: ImageModerationStage;\n\t/** Coarse public category labels such as `harassment` or `violence`. */\n\treadonly categories: readonly string[];\n\n\tconstructor(init: ImageModerationBlockedErrorInit) {\n\t\tsuper(init, { name: \"ImageModerationBlockedError\", code: \"moderation-blocked\", retryable: false });\n\t\tthis.moderationStage = init.moderationStage;\n\t\tthis.categories = init.categories ?? [];\n\t}\n\n\tprotected override dataFields(): Record<string, ImageGenerationErrorFieldValue> {\n\t\treturn { ...super.dataFields(), moderationStage: this.moderationStage, categories: this.categories };\n\t}\n}\n\nexport interface ImageGenerationTimeoutErrorInit {\n\ttimeoutMs: number;\n\telapsedMs: number;\n\tcause?: unknown;\n}\n\n/** The request did not complete within `timeoutMs`. Retryable. */\nexport class ImageGenerationTimeoutError extends ImageGenerationError {\n\tdeclare readonly name: \"ImageGenerationTimeoutError\";\n\tdeclare readonly code: \"timeout\";\n\treadonly timeoutMs: number;\n\treadonly elapsedMs: number;\n\treadonly phase = \"request\" as const;\n\n\tconstructor(init: ImageGenerationTimeoutErrorInit) {\n\t\tsuper({\n\t\t\tname: \"ImageGenerationTimeoutError\",\n\t\t\tcode: \"timeout\",\n\t\t\tmessage: `Image generation timed out: request after ${init.elapsedMs}ms of ${init.timeoutMs}ms (timeout). Raise timeoutMs or lower the image size, count or quality.`,\n\t\t\thint: \"Raise timeoutMs or lower the image size, count or quality.\",\n\t\t\tretryable: true,\n\t\t\tcause: init.cause,\n\t\t});\n\t\tthis.timeoutMs = init.timeoutMs;\n\t\tthis.elapsedMs = init.elapsedMs;\n\t}\n\n\tprotected override dataFields(): Record<string, ImageGenerationErrorFieldValue> {\n\t\treturn { timeoutMs: this.timeoutMs, elapsedMs: this.elapsedMs, phase: this.phase };\n\t}\n}\n\n/** The `code` each concrete family class carries. The family base accepts any code. */\nconst FAMILY_CODES = {\n\tImageGenerationConfigError: \"invalid-option\",\n\tImageGenerationApiError: \"api-error\",\n\tImageGenerationQuotaError: \"quota-exceeded\",\n\tImageGenerationRateLimitError: \"rate-limited\",\n\tImageGenerationServerError: \"server-error\",\n\tImageGenerationUserError: \"user-error\",\n\tImageModerationBlockedError: \"moderation-blocked\",\n\tImageGenerationTimeoutError: \"timeout\",\n} as const;\n\ntype FamilyName = keyof typeof FAMILY_CODES | \"ImageGenerationError\";\n\nfunction hasShape(value: unknown, names: readonly FamilyName[]): boolean {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst { name, code } = value as { name?: unknown; code?: unknown };\n\tif (typeof code !== \"string\" || !(names as readonly unknown[]).includes(name)) return false;\n\treturn name === \"ImageGenerationError\" || FAMILY_CODES[name as keyof typeof FAMILY_CODES] === code;\n}\n\nfunction causeOf(error: unknown): unknown {\n\treturn typeof error === \"object\" && error !== null ? (error as { cause?: unknown }).cause : undefined;\n}\n\n/**\n * Guards check the value itself: an instance of the class, or, across processes and realms, an\n * object whose `name` is the class name and whose `code` is that class's code. Use\n * {@link findImageGenerationError} to search a `cause` chain.\n */\nfunction guard<T extends ImageGenerationError>(\n\ttype: abstract new (...args: never[]) => T,\n\tnames: readonly FamilyName[],\n): (value: unknown) => value is T {\n\treturn (value: unknown): value is T => value instanceof type || hasShape(value, names);\n}\n\nconst API_NAMES = [\"ImageGenerationApiError\", ...API_SUBCLASS_NAMES] as const;\nconst USER_NAMES = [\"ImageGenerationUserError\", \"ImageModerationBlockedError\"] as const;\nconst FAMILY_NAMES = [\n\t\"ImageGenerationError\",\n\t\"ImageGenerationConfigError\",\n\t\"ImageGenerationTimeoutError\",\n\t...API_NAMES,\n] as const;\n\nexport const isImageGenerationError = guard(ImageGenerationError, FAMILY_NAMES);\nexport const isImageGenerationConfigError = guard(ImageGenerationConfigError, [\"ImageGenerationConfigError\"]);\nexport const isImageGenerationApiError = guard(ImageGenerationApiError, API_NAMES);\nexport const isImageGenerationQuotaError = guard(ImageGenerationQuotaError, [\"ImageGenerationQuotaError\"]);\nexport const isImageGenerationRateLimitError = guard(ImageGenerationRateLimitError, [\"ImageGenerationRateLimitError\"]);\nexport const isImageGenerationServerError = guard(ImageGenerationServerError, [\"ImageGenerationServerError\"]);\nexport const isImageGenerationUserError = guard(ImageGenerationUserError, USER_NAMES);\nexport const isImageModerationBlockedError = guard(ImageModerationBlockedError, [\"ImageModerationBlockedError\"]);\nexport const isImageGenerationTimeoutError = guard(ImageGenerationTimeoutError, [\"ImageGenerationTimeoutError\"]);\n\nfunction isImageGenerationErrorInstance(value: unknown): value is ImageGenerationError {\n\treturn value instanceof ImageGenerationError;\n}\n\n/**\n * Search the error and its `cause` chain, at most eight links, for the first value `guard` accepts.\n * Without a guard, returns the nearest {@link ImageGenerationError} instance, for example\n * `findImageGenerationError(error, isImageGenerationQuotaError)`.\n */\nexport function findImageGenerationError(error: unknown): ImageGenerationError | undefined;\nexport function findImageGenerationError<T>(error: unknown, guard: (value: unknown) => value is T): T | undefined;\nexport function findImageGenerationError(\n\terror: unknown,\n\taccept: (value: unknown) => boolean = isImageGenerationErrorInstance,\n): unknown {\n\tlet current: unknown = error;\n\tfor (let depth = 0; depth < MAX_CAUSE_DEPTH; depth++) {\n\t\tif (accept(current)) return current;\n\t\tcurrent = causeOf(current);\n\t}\n\treturn undefined;\n}\n\n/** True when the nearest image-generation error in the `cause` chain says the same request may be retried. */\nexport function isRetryableImageGenerationError(error: unknown): boolean {\n\treturn findImageGenerationError(error, isImageGenerationError)?.retryable === true;\n}\n\nfunction stringField(fields: ImageGenerationErrorData[\"fields\"], key: string): string | undefined {\n\tconst value = fields[key];\n\treturn typeof value === \"string\" ? value : undefined;\n}\n\nfunction numberField(fields: ImageGenerationErrorData[\"fields\"], key: string): number | undefined {\n\tconst value = fields[key];\n\treturn typeof value === \"number\" ? value : undefined;\n}\n\nfunction listField(fields: ImageGenerationErrorData[\"fields\"], key: string): readonly string[] {\n\tconst value = fields[key];\n\treturn Array.isArray(value) ? value.filter((entry): entry is string => typeof entry === \"string\") : [];\n}\n\nfunction apiInit(data: ImageGenerationErrorData, cause: Error | undefined): ImageGenerationApiErrorInit {\n\tconst { fields } = data;\n\treturn {\n\t\tdetail: stringField(fields, \"detail\") ?? data.message,\n\t\tstatus: numberField(fields, \"status\"),\n\t\tapiCode: stringField(fields, \"apiCode\"),\n\t\tapiType: stringField(fields, \"apiType\"),\n\t\trequestId: stringField(fields, \"requestId\"),\n\t\tretryable: data.retryable,\n\t\tcause,\n\t};\n}\n\nfunction createFromData(data: ImageGenerationErrorData, cause: Error | undefined): ImageGenerationError {\n\tconst { fields } = data;\n\tswitch (data.name) {\n\t\tcase \"ImageGenerationConfigError\":\n\t\t\treturn new ImageGenerationConfigError({\n\t\t\t\tmodel: stringField(fields, \"model\") ?? \"\",\n\t\t\t\tfield: stringField(fields, \"field\") ?? \"\",\n\t\t\t\treason: (stringField(fields, \"reason\") ?? \"out-of-range\") as ImageGenerationConfigReason,\n\t\t\t\trelated: stringField(fields, \"related\"),\n\t\t\t\tdetail: stringField(fields, \"detail\") ?? data.message,\n\t\t\t\thint: data.hint ?? \"\",\n\t\t\t\tcause,\n\t\t\t});\n\t\tcase \"ImageGenerationTimeoutError\":\n\t\t\treturn new ImageGenerationTimeoutError({\n\t\t\t\ttimeoutMs: numberField(fields, \"timeoutMs\") ?? 0,\n\t\t\t\telapsedMs: numberField(fields, \"elapsedMs\") ?? 0,\n\t\t\t\tcause,\n\t\t\t});\n\t\tcase \"ImageGenerationApiError\":\n\t\t\treturn new ImageGenerationApiError(apiInit(data, cause));\n\t\tcase \"ImageGenerationQuotaError\":\n\t\t\treturn new ImageGenerationQuotaError(apiInit(data, cause));\n\t\tcase \"ImageGenerationRateLimitError\":\n\t\t\treturn new ImageGenerationRateLimitError(apiInit(data, cause));\n\t\tcase \"ImageGenerationServerError\":\n\t\t\treturn new ImageGenerationServerError(apiInit(data, cause));\n\t\tcase \"ImageGenerationUserError\":\n\t\t\treturn new ImageGenerationUserError(apiInit(data, cause));\n\t\tcase \"ImageModerationBlockedError\": {\n\t\t\tconst stage = stringField(fields, \"moderationStage\");\n\t\t\treturn new ImageModerationBlockedError({\n\t\t\t\t...apiInit(data, cause),\n\t\t\t\tmoderationStage: stage === \"input\" || stage === \"output\" || stage === \"unknown\" ? stage : undefined,\n\t\t\t\tcategories: listField(fields, \"categories\"),\n\t\t\t});\n\t\t}\n\t\tdefault:\n\t\t\treturn new ImageGenerationError({\n\t\t\t\tname: data.name,\n\t\t\t\tcode: data.code,\n\t\t\t\tmessage: data.message,\n\t\t\t\thint: data.hint,\n\t\t\t\tretryable: data.retryable,\n\t\t\t\tcause,\n\t\t\t});\n\t}\n}\n\nfunction isErrorData(value: ImageGenerationErrorData[\"cause\"]): value is ImageGenerationErrorData {\n\tconst { code, retryable, fields } = value as Partial<ImageGenerationErrorData>;\n\treturn typeof code === \"string\" && typeof retryable === \"boolean\" && typeof fields === \"object\" && fields !== null;\n}\n\nfunction causeFromData(cause: ImageGenerationErrorData[\"cause\"], depth: number): Error | undefined {\n\tif (cause === undefined || depth > MAX_CAUSE_DEPTH) return undefined;\n\tif (isErrorData(cause)) return errorFromData(cause, depth);\n\tconst nested = causeFromData(cause.cause, depth + 1);\n\tconst error = new Error(FOREIGN_MESSAGE, nested ? { cause: nested } : undefined);\n\terror.name = safeForeignName(cause.name);\n\tconst code = safeErrno(cause.code);\n\tif (code) Object.assign(error, { code });\n\treturn error;\n}\n\nfunction errorFromData(data: ImageGenerationErrorData, depth: number): ImageGenerationError {\n\tconst error = createFromData(data, causeFromData(data.cause, depth + 1));\n\terror.message = data.message;\n\treturn error;\n}\n\n/**\n * Rebuild a typed error from {@link ImageGenerationErrorData}, for example after a result crossed a\n * worker or process boundary. Family causes come back as their own classes, other causes as plain\n * errors, at most eight links deep. Unknown names become an {@link ImageGenerationError} that keeps\n * the original `name` and `code`.\n */\nexport function imageGenerationErrorFromData(data: ImageGenerationErrorData): ImageGenerationError {\n\treturn errorFromData(data, 1);\n}\n"]}
1
+ {"version":3,"file":"image-generation-error.js","sourceRoot":"","sources":["../src/image-generation-error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAoCH,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,eAAe,GAAG,iCAAiC,CAAC;AAC1D,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAChC,QAAQ;IACR,YAAY;IACZ,eAAe;IACf,cAAc;IACd,QAAQ;IACR,UAAU;IACV,OAAO;IACP,OAAO;IACP,WAAW;IACX,cAAc;IACd,cAAc;IACd,YAAY;IACZ,cAAc;IACd,QAAQ;IACR,QAAQ;IACR,cAAc;IACd,OAAO;IACP,QAAQ;IACR,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,UAAU;IACV,WAAW;IACX,aAAa;IACb,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,SAAS;IACT,WAAW;IACX,UAAU;IACV,SAAS;IACT,OAAO;IACP,OAAO;IACP,QAAQ;IACR,iBAAiB;IACjB,WAAW;IACX,WAAW;IACX,UAAU;IACV,YAAY;CACZ,CAAC,CAAC;AAEH,SAAS,eAAe,CAAC,IAAa;IACrC,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,8BAA8B,CAAC,IAAI,CAAC,IAAI,C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AAC,IAA8B;IAC1E,OAAO,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["/**\n * Typed failures of `generateImages()`.\n *\n * One family, {@link ImageGenerationError}, covers every failure the image providers can\n * classify: a rejected request configuration ({@link ImageGenerationConfigError}), an API\n * failure ({@link ImageGenerationApiError} and its subclasses) and a client-side timeout\n * ({@link ImageGenerationTimeoutError}). Branch on the class, its guard or `code`, never on\n * `message`. Cancellation is not a failure: an aborted request resolves with\n * `stopReason: \"aborted\"` and no error.\n */\n\nexport type ImageGenerationErrorFieldValue = string | number | boolean | readonly string[] | undefined;\n\n/** A foreign cause with its name, a safe errno code, and a redacted message. */\nexport interface ImageGenerationForeignCauseData {\n\tname: string;\n\tmessage: string;\n\tcode?: string;\n\tcause?: ImageGenerationErrorData | ImageGenerationForeignCauseData;\n}\n\n/** JSON-safe form of an {@link ImageGenerationError}, for results, IPC and worker boundaries. */\nexport interface ImageGenerationErrorData {\n\tname: string;\n\tcode: string;\n\tmessage: string;\n\thint?: string;\n\tretryable: boolean;\n\tfields: Record<string, ImageGenerationErrorFieldValue>;\n\t/**\n\t * The next link of the `cause` chain. Family errors keep their data; foreign errors keep their\n\t * name and known errno code, with their message redacted. At most eight links are kept.\n\t */\n\tcause?: ImageGenerationErrorData | ImageGenerationForeignCauseData;\n}\n\ninterface ImageGenerationErrorInit {\n\tname: string;\n\tcode: string;\n\tmessage: string;\n\thint?: string;\n\tretryable?: boolean;\n\tcause?: unknown;\n}\n\nconst MAX_CAUSE_DEPTH = 8;\nconst FOREIGN_MESSAGE = \"[foreign error message omitted]\";\nconst SAFE_ERRNO_CODES = new Set([\n\t\"EACCES\",\n\t\"EADDRINUSE\",\n\t\"EADDRNOTAVAIL\",\n\t\"EAFNOSUPPORT\",\n\t\"EAGAIN\",\n\t\"EALREADY\",\n\t\"EBADF\",\n\t\"EBUSY\",\n\t\"ECANCELED\",\n\t\"ECONNABORTED\",\n\t\"ECONNREFUSED\",\n\t\"ECONNRESET\",\n\t\"EDESTADDRREQ\",\n\t\"EEXIST\",\n\t\"EFAULT\",\n\t\"EHOSTUNREACH\",\n\t\"EINTR\",\n\t\"EINVAL\",\n\t\"EIO\",\n\t\"EISDIR\",\n\t\"EMFILE\",\n\t\"EMSGSIZE\",\n\t\"ENETDOWN\",\n\t\"ENETRESET\",\n\t\"ENETUNREACH\",\n\t\"ENFILE\",\n\t\"ENOENT\",\n\t\"ENOMEM\",\n\t\"ENOSPC\",\n\t\"ENOTCONN\",\n\t\"ENOTDIR\",\n\t\"ENOTFOUND\",\n\t\"ENOTSOCK\",\n\t\"ENOTSUP\",\n\t\"EPIPE\",\n\t\"EPERM\",\n\t\"EPROTO\",\n\t\"EPROTONOSUPPORT\",\n\t\"ETIMEDOUT\",\n\t\"EAI_AGAIN\",\n\t\"EAI_FAIL\",\n\t\"EAI_NONAME\",\n]);\n\nfunction safeForeignName(name: unknown): string {\n\treturn typeof name === \"string\" && /^[A-Za-z][A-Za-z0-9_]{0,79}$/.test(name) ? name : \"Error\";\n}\n\nfunction safeErrno(code: unknown): string | undefined {\n\treturn typeof code === \"string\" && SAFE_ERRNO_CODES.has(code) ? code : undefined;\n}\n\nfunction sanitizeCause(cause: unknown, depth: number): Error | undefined {\n\tif (depth > MAX_CAUSE_DEPTH || !(cause instanceof Error)) return undefined;\n\tif (cause instanceof ImageGenerationError) return cause;\n\tconst nested = sanitizeCause(cause.cause, depth + 1);\n\tconst safe = new Error(FOREIGN_MESSAGE, nested ? { cause: nested } : undefined);\n\tsafe.name = safeForeignName(cause.name);\n\tconst code = safeErrno((cause as Error & { code?: unknown }).code);\n\tif (code) Object.assign(safe, { code });\n\treturn safe;\n}\n\n/** Base of every typed image-generation failure. */\nexport class ImageGenerationError extends Error {\n\toverride readonly name: string;\n\treadonly code: string;\n\t/** True when the same request may succeed if sent again unchanged. */\n\treadonly retryable: boolean;\n\treadonly hint?: string;\n\n\tconstructor(init: ImageGenerationErrorInit) {\n\t\tsuper(init.message, { cause: sanitizeCause(init.cause, 2) });\n\t\tthis.name = init.name;\n\t\tthis.code = init.code;\n\t\tthis.retryable = init.retryable ?? false;\n\t\tthis.hint = init.hint;\n\t}\n\n\t/** Safe, JSON-serializable context for this failure. Overridden by classes that carry fields. */\n\tprotected dataFields(): Record<string, ImageGenerationErrorFieldValue> {\n\t\treturn {};\n\t}\n\n\ttoData(): ImageGenerationErrorData {\n\t\treturn this.dataWithCauses(1);\n\t}\n\n\tprivate static causeData(\n\t\tcause: unknown,\n\t\tdepth: number,\n\t): ImageGenerationErrorData | ImageGenerationForeignCauseData | undefined {\n\t\tif (depth > MAX_CAUSE_DEPTH || !(cause instanceof Error)) return undefined;\n\t\tif (cause instanceof ImageGenerationError) return cause.dataWithCauses(depth);\n\t\tconst code = safeErrno((cause as Error & { code?: unknown }).code);\n\t\tconst nested = ImageGenerationError.causeData(cause.cause, depth + 1);\n\t\treturn {\n\t\t\tname: safeForeignName(cause.name),\n\t\t\tmessage: FOREIGN_MESSAGE,\n\t\t\t...(code ? { code } : {}),\n\t\t\t...(nested ? { cause: nested } : {}),\n\t\t};\n\t}\n\n\tprivate dataWithCauses(depth: number): ImageGenerationErrorData {\n\t\tconst causeData = ImageGenerationError.causeData(this.cause, depth + 1);\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tcode: this.code,\n\t\t\tmessage: this.message,\n\t\t\t...(this.hint !== undefined ? { hint: this.hint } : {}),\n\t\t\tretryable: this.retryable,\n\t\t\tfields: this.dataFields(),\n\t\t\t...(causeData ? { cause: causeData } : {}),\n\t\t};\n\t}\n\n\ttoJSON(): ImageGenerationErrorData {\n\t\treturn this.toData();\n\t}\n}\n\n/**\n * Why an option was rejected. The first seven are found before a request is sent. The last three\n * come from the API's own rejection of an option: `required-by-api` (the API needs an option the\n * request did not carry), `rejected-by-api` (the API refused the option's value) and\n * `unsupported-by-api` (the API does not accept the option for this account or model).\n */\nexport type ImageGenerationConfigReason =\n\t| \"out-of-range\"\n\t| \"requires-option\"\n\t| \"conflicts-with-option\"\n\t| \"generation-only\"\n\t| \"unsupported-by-model\"\n\t| \"requires-base-image\"\n\t| \"duplicate-role\"\n\t| \"required-by-api\"\n\t| \"rejected-by-api\"\n\t| \"unsupported-by-api\";\n\nexport interface ImageGenerationConfigErrorInit {\n\tmodel: string;\n\tfield: string;\n\treason: ImageGenerationConfigReason;\n\t/** The other option or request part that `field` conflicts with or depends on. */\n\trelated?: string;\n\t/** What is wrong, in words. Names options only and never echoes prompt or image content. */\n\tdetail: string;\n\thint: string;\n\tcause?: unknown;\n}\n\n/**\n * The request options or input are invalid. Found before any request is sent, or reported by the\n * API as a rejected option (`reason` `required-by-api`, `rejected-by-api` or `unsupported-by-api`).\n * Either way nothing was billed and retrying the same request fails the same way.\n */\nexport class ImageGenerationConfigError extends ImageGenerationError {\n\tdeclare readonly name: \"ImageGenerationConfigError\";\n\tdeclare readonly code: \"invalid-option\";\n\treadonly source = \"sdk\" as const;\n\treadonly model: string;\n\treadonly field: string;\n\treadonly reason: ImageGenerationConfigReason;\n\treadonly related?: string;\n\treadonly detail: string;\n\n\tconstructor(init: ImageGenerationConfigErrorInit) {\n\t\tsuper({\n\t\t\tname: \"ImageGenerationConfigError\",\n\t\t\tcode: \"invalid-option\",\n\t\t\tmessage: `Invalid image generation option: ${init.field} for ${init.model} (invalid-option). ${init.detail}. ${init.hint}`,\n\t\t\thint: init.hint,\n\t\t\tcause: init.cause,\n\t\t});\n\t\tthis.model = init.model;\n\t\tthis.field = init.field;\n\t\tthis.reason = init.reason;\n\t\tthis.related = init.related;\n\t\tthis.detail = init.detail;\n\t}\n\n\tprotected override dataFields(): Record<string, ImageGenerationErrorFieldValue> {\n\t\treturn {\n\t\t\tsource: this.source,\n\t\t\tmodel: this.model,\n\t\t\tfield: this.field,\n\t\t\treason: this.reason,\n\t\t\trelated: this.related,\n\t\t\tdetail: this.detail,\n\t\t};\n\t}\n}\n\nexport type ImageGenerationApiErrorCode =\n\t| \"api-error\"\n\t| \"quota-exceeded\"\n\t| \"rate-limited\"\n\t| \"server-error\"\n\t| \"user-error\"\n\t| \"moderation-blocked\";\n\nexport interface ImageGenerationApiErrorInit {\n\t/**\n\t * A summary built from the HTTP status and the provider's type, code and request ID. Never the\n\t * provider's message, which can quote the prompt.\n\t */\n\tdetail: string;\n\tstatus?: number;\n\t/** The provider's `error.code`, for example `insufficient_quota` or `moderation_blocked`. */\n\tapiCode?: string;\n\t/** The provider's `error.type`, for example `image_generation_user_error`. */\n\tapiType?: string;\n\trequestId?: string;\n\tretryable?: boolean;\n\tcause?: unknown;\n}\n\nconst API_ERROR_HINTS = {\n\t\"api-error\": \"Check the status and provider code, then correct the request or credentials.\",\n\t\"quota-exceeded\": \"Add credit or raise the usage limit on the OpenAI account. Retrying will not help.\",\n\t\"rate-limited\": \"Wait and retry, or set maxRetries to retry automatically.\",\n\t\"server-error\": \"The provider failed. Retry later, or set maxRetries to retry automatically.\",\n\t\"user-error\": \"Change the prompt or the input images before sending the request again.\",\n\t\"moderation-blocked\": \"Revise the prompt or input images. Retrying the same request is blocked again.\",\n} as const satisfies Record<ImageGenerationApiErrorCode, string>;\n\n/** The image API answered with a failure. Subclasses name the cases a caller handles differently. */\nexport class ImageGenerationApiError extends ImageGenerationError {\n\tdeclare readonly name: \"ImageGenerationApiError\" | (typeof API_SUBCLASS_NAMES)[number];\n\tdeclare readonly code: ImageGenerationApiErrorCode;\n\treadonly status?: number;\n\treadonly apiCode?: string;\n\treadonly apiType?: string;\n\treadonly requestId?: string;\n\treadonly detail: string;\n\n\tconstructor(init: ImageGenerationApiErrorInit, identity: ApiErrorIdentity = DEFAULT_API_IDENTITY) {\n\t\tsuper({\n\t\t\tname: identity.name,\n\t\t\tcode: identity.code,\n\t\t\tmessage: `Image generation request failed (${identity.code}): ${init.detail}`,\n\t\t\thint: API_ERROR_HINTS[identity.code],\n\t\t\tretryable: init.retryable ?? identity.retryable,\n\t\t\tcause: init.cause,\n\t\t});\n\t\tthis.detail = init.detail;\n\t\tthis.status = init.status;\n\t\tthis.apiCode = init.apiCode;\n\t\tthis.apiType = init.apiType;\n\t\tthis.requestId = init.requestId;\n\t}\n\n\tprotected override dataFields(): Record<string, ImageGenerationErrorFieldValue> {\n\t\treturn {\n\t\t\tdetail: this.detail,\n\t\t\tstatus: this.status,\n\t\t\tapiCode: this.apiCode,\n\t\t\tapiType: this.apiType,\n\t\t\trequestId: this.requestId,\n\t\t};\n\t}\n}\n\nconst API_SUBCLASS_NAMES = [\n\t\"ImageGenerationQuotaError\",\n\t\"ImageGenerationRateLimitError\",\n\t\"ImageGenerationServerError\",\n\t\"ImageGenerationUserError\",\n\t\"ImageModerationBlockedError\",\n] as const;\n\ninterface ApiErrorIdentity {\n\tname: ImageGenerationApiError[\"name\"];\n\tcode: ImageGenerationApiErrorCode;\n\tretryable: boolean;\n}\n\nconst DEFAULT_API_IDENTITY: ApiErrorIdentity = { name: \"ImageGenerationApiError\", code: \"api-error\", retryable: false };\n\n/** The account is out of quota or credit. Not retryable, even though it arrives as HTTP 429. */\nexport class ImageGenerationQuotaError extends ImageGenerationApiError {\n\tdeclare readonly name: \"ImageGenerationQuotaError\";\n\tdeclare readonly code: \"quota-exceeded\";\n\tconstructor(init: ImageGenerationApiErrorInit) {\n\t\tsuper(init, { name: \"ImageGenerationQuotaError\", code: \"quota-exceeded\", retryable: false });\n\t}\n}\n\n/** The request rate limit was hit. Retryable after a delay. */\nexport class ImageGenerationRateLimitError extends ImageGenerationApiError {\n\tdeclare readonly name: \"ImageGenerationRateLimitError\";\n\tdeclare readonly code: \"rate-limited\";\n\tconstructor(init: ImageGenerationApiErrorInit) {\n\t\tsuper(init, { name: \"ImageGenerationRateLimitError\", code: \"rate-limited\", retryable: true });\n\t}\n}\n\n/** The provider failed with a 5xx status. Retryable. */\nexport class ImageGenerationServerError extends ImageGenerationApiError {\n\tdeclare readonly name: \"ImageGenerationServerError\";\n\tdeclare readonly code: \"server-error\";\n\tconstructor(init: ImageGenerationApiErrorInit) {\n\t\tsuper(init, { name: \"ImageGenerationServerError\", code: \"server-error\", retryable: true });\n\t}\n}\n\n/**\n * The provider rejected the request as user-correctable (`error.type` is\n * `image_generation_user_error`). Not retryable until the prompt or the input images change.\n * `apiCode` is the stable discriminator, for example `moderation_blocked`.\n */\nexport class ImageGenerationUserError extends ImageGenerationApiError {\n\tdeclare readonly name: \"ImageGenerationUserError\" | \"ImageModerationBlockedError\";\n\tdeclare readonly code: \"user-error\" | \"moderation-blocked\";\n\tconstructor(init: ImageGenerationApiErrorInit, identity?: ApiErrorIdentity) {\n\t\tsuper(init, identity ?? { name: \"ImageGenerationUserError\", code: \"user-error\", retryable: false });\n\t}\n}\n\nexport type ImageModerationStage = \"input\" | \"output\" | \"unknown\";\n\nexport interface ImageModerationBlockedErrorInit extends ImageGenerationApiErrorInit {\n\tmoderationStage?: ImageModerationStage;\n\tcategories?: readonly string[];\n}\n\n/** Content moderation blocked the prompt, the input images or the generated image. */\nexport class ImageModerationBlockedError extends ImageGenerationUserError {\n\tdeclare readonly name: \"ImageModerationBlockedError\";\n\tdeclare readonly code: \"moderation-blocked\";\n\t/** Where the block happened, when the provider says. */\n\treadonly moderationStage?: ImageModerationStage;\n\t/** Coarse public category labels such as `harassment` or `violence`. */\n\treadonly categories: readonly string[];\n\n\tconstructor(init: ImageModerationBlockedErrorInit) {\n\t\tsuper(init, { name: \"ImageModerationBlockedError\", code: \"moderation-blocked\", retryable: false });\n\t\tthis.moderationStage = init.moderationStage;\n\t\tthis.categories = init.categories ?? [];\n\t}\n\n\tprotected override dataFields(): Record<string, ImageGenerationErrorFieldValue> {\n\t\treturn { ...super.dataFields(), moderationStage: this.moderationStage, categories: this.categories };\n\t}\n}\n\nexport interface ImageGenerationTimeoutErrorInit {\n\ttimeoutMs: number;\n\telapsedMs: number;\n\tcause?: unknown;\n}\n\n/** The request did not complete within `timeoutMs`. Retryable. */\nexport class ImageGenerationTimeoutError extends ImageGenerationError {\n\tdeclare readonly name: \"ImageGenerationTimeoutError\";\n\tdeclare readonly code: \"timeout\";\n\treadonly timeoutMs: number;\n\treadonly elapsedMs: number;\n\treadonly phase = \"request\" as const;\n\n\tconstructor(init: ImageGenerationTimeoutErrorInit) {\n\t\tsuper({\n\t\t\tname: \"ImageGenerationTimeoutError\",\n\t\t\tcode: \"timeout\",\n\t\t\tmessage: `Image generation timed out: request after ${init.elapsedMs}ms of ${init.timeoutMs}ms (timeout). Raise timeoutMs or lower the image size, count or quality.`,\n\t\t\thint: \"Raise timeoutMs or lower the image size, count or quality.\",\n\t\t\tretryable: true,\n\t\t\tcause: init.cause,\n\t\t});\n\t\tthis.timeoutMs = init.timeoutMs;\n\t\tthis.elapsedMs = init.elapsedMs;\n\t}\n\n\tprotected override dataFields(): Record<string, ImageGenerationErrorFieldValue> {\n\t\treturn { timeoutMs: this.timeoutMs, elapsedMs: this.elapsedMs, phase: this.phase };\n\t}\n}\n\n/** The `code` each concrete family class carries. The family base accepts any code. */\nconst FAMILY_CODES = {\n\tImageGenerationConfigError: \"invalid-option\",\n\tImageGenerationApiError: \"api-error\",\n\tImageGenerationQuotaError: \"quota-exceeded\",\n\tImageGenerationRateLimitError: \"rate-limited\",\n\tImageGenerationServerError: \"server-error\",\n\tImageGenerationUserError: \"user-error\",\n\tImageModerationBlockedError: \"moderation-blocked\",\n\tImageGenerationTimeoutError: \"timeout\",\n} as const;\n\ntype FamilyName = keyof typeof FAMILY_CODES | \"ImageGenerationError\";\n\nfunction hasShape(value: unknown, names: readonly FamilyName[]): boolean {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst { name, code } = value as { name?: unknown; code?: unknown };\n\tif (typeof code !== \"string\" || !(names as readonly unknown[]).includes(name)) return false;\n\treturn name === \"ImageGenerationError\" || FAMILY_CODES[name as keyof typeof FAMILY_CODES] === code;\n}\n\nfunction causeOf(error: unknown): unknown {\n\treturn typeof error === \"object\" && error !== null ? (error as { cause?: unknown }).cause : undefined;\n}\n\n/**\n * Guards check the value itself: an instance of the class, or, across processes and realms, an\n * object whose `name` is the class name and whose `code` is that class's code. Use\n * {@link findImageGenerationError} to search a `cause` chain.\n */\nfunction guard<T extends ImageGenerationError>(\n\ttype: abstract new (...args: never[]) => T,\n\tnames: readonly FamilyName[],\n): (value: unknown) => value is T {\n\treturn (value: unknown): value is T => value instanceof type || hasShape(value, names);\n}\n\nconst API_NAMES = [\"ImageGenerationApiError\", ...API_SUBCLASS_NAMES] as const;\nconst USER_NAMES = [\"ImageGenerationUserError\", \"ImageModerationBlockedError\"] as const;\nconst FAMILY_NAMES = [\n\t\"ImageGenerationError\",\n\t\"ImageGenerationConfigError\",\n\t\"ImageGenerationTimeoutError\",\n\t...API_NAMES,\n] as const;\n\nexport const isImageGenerationError = guard(ImageGenerationError, FAMILY_NAMES);\nexport const isImageGenerationConfigError = guard(ImageGenerationConfigError, [\"ImageGenerationConfigError\"]);\nexport const isImageGenerationApiError = guard(ImageGenerationApiError, API_NAMES);\nexport const isImageGenerationQuotaError = guard(ImageGenerationQuotaError, [\"ImageGenerationQuotaError\"]);\nexport const isImageGenerationRateLimitError = guard(ImageGenerationRateLimitError, [\"ImageGenerationRateLimitError\"]);\nexport const isImageGenerationServerError = guard(ImageGenerationServerError, [\"ImageGenerationServerError\"]);\nexport const isImageGenerationUserError = guard(ImageGenerationUserError, USER_NAMES);\nexport const isImageModerationBlockedError = guard(ImageModerationBlockedError, [\"ImageModerationBlockedError\"]);\nexport const isImageGenerationTimeoutError = guard(ImageGenerationTimeoutError, [\"ImageGenerationTimeoutError\"]);\n\nfunction isImageGenerationErrorInstance(value: unknown): value is ImageGenerationError {\n\treturn value instanceof ImageGenerationError;\n}\n\n/**\n * Search the error and its `cause` chain, at most eight links, for the first value `guard` accepts.\n * Without a guard, returns the nearest {@link ImageGenerationError} instance, for example\n * `findImageGenerationError(error, isImageGenerationQuotaError)`.\n */\nexport function findImageGenerationError(error: unknown): ImageGenerationError | undefined;\nexport function findImageGenerationError<T>(error: unknown, guard: (value: unknown) => value is T): T | undefined;\nexport function findImageGenerationError(\n\terror: unknown,\n\taccept: (value: unknown) => boolean = isImageGenerationErrorInstance,\n): unknown {\n\tlet current: unknown = error;\n\tfor (let depth = 0; depth < MAX_CAUSE_DEPTH; depth++) {\n\t\tif (accept(current)) return current;\n\t\tcurrent = causeOf(current);\n\t}\n\treturn undefined;\n}\n\n/** True when the nearest image-generation error in the `cause` chain says the same request may be retried. */\nexport function isRetryableImageGenerationError(error: unknown): boolean {\n\treturn findImageGenerationError(error, isImageGenerationError)?.retryable === true;\n}\n\nfunction stringField(fields: ImageGenerationErrorData[\"fields\"], key: string): string | undefined {\n\tconst value = fields[key];\n\treturn typeof value === \"string\" ? value : undefined;\n}\n\nfunction numberField(fields: ImageGenerationErrorData[\"fields\"], key: string): number | undefined {\n\tconst value = fields[key];\n\treturn typeof value === \"number\" ? value : undefined;\n}\n\nfunction listField(fields: ImageGenerationErrorData[\"fields\"], key: string): readonly string[] {\n\tconst value = fields[key];\n\treturn Array.isArray(value) ? value.filter((entry): entry is string => typeof entry === \"string\") : [];\n}\n\nfunction apiInit(data: ImageGenerationErrorData, cause: Error | undefined): ImageGenerationApiErrorInit {\n\tconst { fields } = data;\n\treturn {\n\t\tdetail: stringField(fields, \"detail\") ?? data.message,\n\t\tstatus: numberField(fields, \"status\"),\n\t\tapiCode: stringField(fields, \"apiCode\"),\n\t\tapiType: stringField(fields, \"apiType\"),\n\t\trequestId: stringField(fields, \"requestId\"),\n\t\tretryable: data.retryable,\n\t\tcause,\n\t};\n}\n\nfunction createFromData(data: ImageGenerationErrorData, cause: Error | undefined): ImageGenerationError {\n\tconst { fields } = data;\n\tswitch (data.name) {\n\t\tcase \"ImageGenerationConfigError\":\n\t\t\treturn new ImageGenerationConfigError({\n\t\t\t\tmodel: stringField(fields, \"model\") ?? \"\",\n\t\t\t\tfield: stringField(fields, \"field\") ?? \"\",\n\t\t\t\treason: (stringField(fields, \"reason\") ?? \"out-of-range\") as ImageGenerationConfigReason,\n\t\t\t\trelated: stringField(fields, \"related\"),\n\t\t\t\tdetail: stringField(fields, \"detail\") ?? data.message,\n\t\t\t\thint: data.hint ?? \"\",\n\t\t\t\tcause,\n\t\t\t});\n\t\tcase \"ImageGenerationTimeoutError\":\n\t\t\treturn new ImageGenerationTimeoutError({\n\t\t\t\ttimeoutMs: numberField(fields, \"timeoutMs\") ?? 0,\n\t\t\t\telapsedMs: numberField(fields, \"elapsedMs\") ?? 0,\n\t\t\t\tcause,\n\t\t\t});\n\t\tcase \"ImageGenerationApiError\":\n\t\t\treturn new ImageGenerationApiError(apiInit(data, cause));\n\t\tcase \"ImageGenerationQuotaError\":\n\t\t\treturn new ImageGenerationQuotaError(apiInit(data, cause));\n\t\tcase \"ImageGenerationRateLimitError\":\n\t\t\treturn new ImageGenerationRateLimitError(apiInit(data, cause));\n\t\tcase \"ImageGenerationServerError\":\n\t\t\treturn new ImageGenerationServerError(apiInit(data, cause));\n\t\tcase \"ImageGenerationUserError\":\n\t\t\treturn new ImageGenerationUserError(apiInit(data, cause));\n\t\tcase \"ImageModerationBlockedError\": {\n\t\t\tconst stage = stringField(fields, \"moderationStage\");\n\t\t\treturn new ImageModerationBlockedError({\n\t\t\t\t...apiInit(data, cause),\n\t\t\t\tmoderationStage: stage === \"input\" || stage === \"output\" || stage === \"unknown\" ? stage : undefined,\n\t\t\t\tcategories: listField(fields, \"categories\"),\n\t\t\t});\n\t\t}\n\t\tdefault:\n\t\t\treturn new ImageGenerationError({\n\t\t\t\tname: data.name,\n\t\t\t\tcode: data.code,\n\t\t\t\tmessage: data.message,\n\t\t\t\thint: data.hint,\n\t\t\t\tretryable: data.retryable,\n\t\t\t\tcause,\n\t\t\t});\n\t}\n}\n\nfunction isErrorData(value: ImageGenerationErrorData[\"cause\"]): value is ImageGenerationErrorData {\n\tconst { code, retryable, fields } = value as Partial<ImageGenerationErrorData>;\n\treturn typeof code === \"string\" && typeof retryable === \"boolean\" && typeof fields === \"object\" && fields !== null;\n}\n\nfunction causeFromData(cause: ImageGenerationErrorData[\"cause\"], depth: number): Error | undefined {\n\tif (cause === undefined || depth > MAX_CAUSE_DEPTH) return undefined;\n\tif (isErrorData(cause)) return errorFromData(cause, depth);\n\tconst nested = causeFromData(cause.cause, depth + 1);\n\tconst error = new Error(FOREIGN_MESSAGE, nested ? { cause: nested } : undefined);\n\terror.name = safeForeignName(cause.name);\n\tconst code = safeErrno(cause.code);\n\tif (code) Object.assign(error, { code });\n\treturn error;\n}\n\nfunction errorFromData(data: ImageGenerationErrorData, depth: number): ImageGenerationError {\n\tconst error = createFromData(data, causeFromData(data.cause, depth + 1));\n\terror.message = data.message;\n\treturn error;\n}\n\n/**\n * Rebuild a typed error from {@link ImageGenerationErrorData}, for example after a result crossed a\n * worker or process boundary. Family causes come back as their own classes, other causes as plain\n * errors, at most eight links deep. Unknown names become an {@link ImageGenerationError} that keeps\n * the original `name` and `code`.\n */\nexport function imageGenerationErrorFromData(data: ImageGenerationErrorData): ImageGenerationError {\n\treturn errorFromData(data, 1);\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@ export * from "./api/lazy.ts";
10
10
  export type { MistralOptions } from "./api/mistral-conversations.ts";
11
11
  export type { OpenAICodexResponsesOptions, OpenAICodexWebSocketDebugStats } from "./api/openai-codex-responses.ts";
12
12
  export type { OpenAICompletionsOptions } from "./api/openai-completions.ts";
13
- export { OPENAI_IMAGES_LIMITS, type OpenAIImagesOptions, type OpenAIImagesOutputFormat, type OpenAIImagesSvgOptions, } from "./api/openai-images-options.ts";
13
+ export { DEFAULT_SVG_AUTHOR_MODEL, OPENAI_IMAGES_LIMITS, type OpenAIImagesOptions, type OpenAIImagesOutputFormat, type OpenAIImagesSvgOptions, } from "./api/openai-images-options.ts";
14
14
  export type { OpenAIResponsesOptions } from "./api/openai-responses.ts";
15
15
  export type { PiMessagesEvent, PiMessagesOptions, PiMessagesRewriteImpact } from "./api/pi-messages.ts";
16
16
  export * from "./auth/context.ts";
@@ -18,6 +18,7 @@ export * from "./auth/credential-store.ts";
18
18
  export * from "./auth/helpers.ts";
19
19
  export { isOAuthRefreshRejectedError, isPermanentRefreshRejection, type OAuthErrorDetail, OAuthRefreshRejectedError, type OAuthRefreshRejection, parseOAuthErrorBody, } from "./auth/oauth-refresh-errors.ts";
20
20
  export * from "./auth/types.ts";
21
+ export * from "./cache-warming.ts";
21
22
  export type { OAuthAuthInfo, OAuthDeviceCodeInfo, OAuthLoginCallbacks, OAuthPrompt, OAuthSelectOption, OAuthSelectPrompt, } from "./compat/extension-oauth-types.ts";
22
23
  export * from "./decision-models.ts";
23
24
  export { containsKnownEnvCredential } from "./env-api-keys.ts";
@@ -28,6 +29,7 @@ export { normalizeProviderId } from "./provider-id.ts";
28
29
  export * from "./providers/faux.ts";
29
30
  export * from "./providers/github-copilot-capabilities.ts";
30
31
  export * from "./providers/github-copilot-errors.ts";
32
+ export * from "./providers/github-copilot-stream-attempt.ts";
31
33
  export * from "./session-resources.ts";
32
34
  export * from "./types.ts";
33
35
  export * from "./utils/diagnostics.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAO/B,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAC/G,YAAY,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AACnF,YAAY,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC/F,YAAY,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,YAAY,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAClG,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,cAAc,eAAe,CAAC;AAC9B,YAAY,EAAE,cAAc,EAA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AAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC/F,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -1,11 +1,12 @@
1
1
  export { Type } from "typebox";
2
2
  export * from "./api/lazy.js";
3
- export { OPENAI_IMAGES_LIMITS, } from "./api/openai-images-options.js";
3
+ export { DEFAULT_SVG_AUTHOR_MODEL, OPENAI_IMAGES_LIMITS, } from "./api/openai-images-options.js";
4
4
  export * from "./auth/context.js";
5
5
  export * from "./auth/credential-store.js";
6
6
  export * from "./auth/helpers.js";
7
7
  export { isOAuthRefreshRejectedError, isPermanentRefreshRejection, OAuthRefreshRejectedError, parseOAuthErrorBody, } from "./auth/oauth-refresh-errors.js";
8
8
  export * from "./auth/types.js";
9
+ export * from "./cache-warming.js";
9
10
  export * from "./decision-models.js";
10
11
  export { containsKnownEnvCredential } from "./env-api-keys.js";
11
12
  export * from "./image-generation-error.js";
@@ -15,6 +16,7 @@ export { normalizeProviderId } from "./provider-id.js";
15
16
  export * from "./providers/faux.js";
16
17
  export * from "./providers/github-copilot-capabilities.js";
17
18
  export * from "./providers/github-copilot-errors.js";
19
+ export * from "./providers/github-copilot-stream-attempt.js";
18
20
  export * from "./session-resources.js";
19
21
  export * from "./types.js";
20
22
  export * from "./utils/diagnostics.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAa/B,cAAc,eAAe,CAAC;AAI9B,OAAO,EACN,oBAAoB,GAIpB,MAAM,gCAAgC,CAAC;AAGxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,OAAO,EACN,2BAA2B,EAC3B,2BAA2B,EAE3B,yBAAyB,EAEzB,mBAAmB,GACnB,MAAM,gCAAgC,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAShC,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,cAAc,qBAAqB,CAAC;AACpC,cAAc,4CAA4C,CAAC;AAC3D,cAAc,sCAAsC,CAAC;AACrD,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC/F,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export type { Static, TSchema } from \"typebox\";\nexport { Type } from \"typebox\";\n\n// Core only, side-effect free: no generated catalogs, no provider factories,\n// no api-registry, no OAuth implementations, no compat. Provider factories\n// live under \"@bastani/pi-ai/providers/*\", API implementations under\n// \"@bastani/pi-ai/api/*\", the old global API under\n// \"@bastani/pi-ai/compat\".\nexport type { AnthropicEffort, AnthropicOptions, AnthropicThinkingDisplay } from \"./api/anthropic-messages.ts\";\nexport type { AzureOpenAIResponsesOptions } from \"./api/azure-openai-responses.ts\";\nexport type { BedrockOptions, BedrockThinkingDisplay } from \"./api/bedrock-converse-stream.ts\";\nexport type { GoogleOptions } from \"./api/google-generative-ai.ts\";\nexport type { GoogleApiThinkingLevel, ResolvedGoogleThinkingLevel } from \"./api/google-shared.ts\";\nexport type { GoogleVertexOptions } from \"./api/google-vertex.ts\";\nexport * from \"./api/lazy.ts\";\nexport type { MistralOptions } from \"./api/mistral-conversations.ts\";\nexport type { OpenAICodexResponsesOptions, OpenAICodexWebSocketDebugStats } from \"./api/openai-codex-responses.ts\";\nexport type { OpenAICompletionsOptions } from \"./api/openai-completions.ts\";\nexport {\n\tOPENAI_IMAGES_LIMITS,\n\ttype OpenAIImagesOptions,\n\ttype OpenAIImagesOutputFormat,\n\ttype OpenAIImagesSvgOptions,\n} from \"./api/openai-images-options.ts\";\nexport type { OpenAIResponsesOptions } from \"./api/openai-responses.ts\";\nexport type { PiMessagesEvent, PiMessagesOptions, PiMessagesRewriteImpact } from \"./api/pi-messages.ts\";\nexport * from \"./auth/context.ts\";\nexport * from \"./auth/credential-store.ts\";\nexport * from \"./auth/helpers.ts\";\nexport {\n\tisOAuthRefreshRejectedError,\n\tisPermanentRefreshRejection,\n\ttype OAuthErrorDetail,\n\tOAuthRefreshRejectedError,\n\ttype OAuthRefreshRejection,\n\tparseOAuthErrorBody,\n} from \"./auth/oauth-refresh-errors.ts\";\nexport * from \"./auth/types.ts\";\nexport type {\n\tOAuthAuthInfo,\n\tOAuthDeviceCodeInfo,\n\tOAuthLoginCallbacks,\n\tOAuthPrompt,\n\tOAuthSelectOption,\n\tOAuthSelectPrompt,\n} from \"./compat/extension-oauth-types.ts\";\nexport * from \"./decision-models.ts\";\nexport { containsKnownEnvCredential } from \"./env-api-keys.ts\";\nexport * from \"./image-generation-error.ts\";\nexport * from \"./models.ts\";\nexport * from \"./models-store.ts\";\nexport { normalizeProviderId } from \"./provider-id.ts\";\nexport * from \"./providers/faux.ts\";\nexport * from \"./providers/github-copilot-capabilities.ts\";\nexport * from \"./providers/github-copilot-errors.ts\";\nexport * from \"./session-resources.ts\";\nexport * from \"./types.ts\";\nexport * from \"./utils/diagnostics.ts\";\nexport * from \"./utils/event-stream.ts\";\nexport { AssistantMessageEventStream } from \"./utils/event-stream.ts\";\nexport * from \"./utils/identity.ts\";\nexport * from \"./utils/json-parse.ts\";\nexport * from \"./utils/overflow.ts\";\nexport * from \"./utils/retry.ts\";\nexport * from \"./utils/stream-deadline.ts\";\nexport * from \"./utils/streaming-json.ts\";\nexport { contentText, getSystemMessageText, renderSystemMessageUpdate } from \"./utils/text.ts\";\nexport * from \"./utils/transcript.ts\";\nexport * from \"./utils/typebox-helpers.ts\";\nexport { uuidv7 } from \"./utils/uuid.ts\";\nexport * from \"./utils/validation.ts\";\nexport { PI_AI_VERSION } from \"./utils/version.ts\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAa/B,cAAc,eAAe,CAAC;AAI9B,OAAO,EACN,wBAAwB,EACxB,oBAAoB,GAIpB,MAAM,gCAAgC,CAAC;AAGxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,OAAO,EACN,2BAA2B,EAC3B,2BAA2B,EAE3B,yBAAyB,EAEzB,mBAAmB,GACnB,MAAM,gCAAgC,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AASnC,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,cAAc,qBAAqB,CAAC;AACpC,cAAc,4CAA4C,CAAC;AAC3D,cAAc,sCAAsC,CAAC;AACrD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC/F,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export type { Static, TSchema } from \"typebox\";\nexport { Type } from \"typebox\";\n\n// Core only, side-effect free: no generated catalogs, no provider factories,\n// no api-registry, no OAuth implementations, no compat. Provider factories\n// live under \"@bastani/pi-ai/providers/*\", API implementations under\n// \"@bastani/pi-ai/api/*\", the old global API under\n// \"@bastani/pi-ai/compat\".\nexport type { AnthropicEffort, AnthropicOptions, AnthropicThinkingDisplay } from \"./api/anthropic-messages.ts\";\nexport type { AzureOpenAIResponsesOptions } from \"./api/azure-openai-responses.ts\";\nexport type { BedrockOptions, BedrockThinkingDisplay } from \"./api/bedrock-converse-stream.ts\";\nexport type { GoogleOptions } from \"./api/google-generative-ai.ts\";\nexport type { GoogleApiThinkingLevel, ResolvedGoogleThinkingLevel } from \"./api/google-shared.ts\";\nexport type { GoogleVertexOptions } from \"./api/google-vertex.ts\";\nexport * from \"./api/lazy.ts\";\nexport type { MistralOptions } from \"./api/mistral-conversations.ts\";\nexport type { OpenAICodexResponsesOptions, OpenAICodexWebSocketDebugStats } from \"./api/openai-codex-responses.ts\";\nexport type { OpenAICompletionsOptions } from \"./api/openai-completions.ts\";\nexport {\n\tDEFAULT_SVG_AUTHOR_MODEL,\n\tOPENAI_IMAGES_LIMITS,\n\ttype OpenAIImagesOptions,\n\ttype OpenAIImagesOutputFormat,\n\ttype OpenAIImagesSvgOptions,\n} from \"./api/openai-images-options.ts\";\nexport type { OpenAIResponsesOptions } from \"./api/openai-responses.ts\";\nexport type { PiMessagesEvent, PiMessagesOptions, PiMessagesRewriteImpact } from \"./api/pi-messages.ts\";\nexport * from \"./auth/context.ts\";\nexport * from \"./auth/credential-store.ts\";\nexport * from \"./auth/helpers.ts\";\nexport {\n\tisOAuthRefreshRejectedError,\n\tisPermanentRefreshRejection,\n\ttype OAuthErrorDetail,\n\tOAuthRefreshRejectedError,\n\ttype OAuthRefreshRejection,\n\tparseOAuthErrorBody,\n} from \"./auth/oauth-refresh-errors.ts\";\nexport * from \"./auth/types.ts\";\nexport * from \"./cache-warming.ts\";\nexport type {\n\tOAuthAuthInfo,\n\tOAuthDeviceCodeInfo,\n\tOAuthLoginCallbacks,\n\tOAuthPrompt,\n\tOAuthSelectOption,\n\tOAuthSelectPrompt,\n} from \"./compat/extension-oauth-types.ts\";\nexport * from \"./decision-models.ts\";\nexport { containsKnownEnvCredential } from \"./env-api-keys.ts\";\nexport * from \"./image-generation-error.ts\";\nexport * from \"./models.ts\";\nexport * from \"./models-store.ts\";\nexport { normalizeProviderId } from \"./provider-id.ts\";\nexport * from \"./providers/faux.ts\";\nexport * from \"./providers/github-copilot-capabilities.ts\";\nexport * from \"./providers/github-copilot-errors.ts\";\nexport * from \"./providers/github-copilot-stream-attempt.ts\";\nexport * from \"./session-resources.ts\";\nexport * from \"./types.ts\";\nexport * from \"./utils/diagnostics.ts\";\nexport * from \"./utils/event-stream.ts\";\nexport { AssistantMessageEventStream } from \"./utils/event-stream.ts\";\nexport * from \"./utils/identity.ts\";\nexport * from \"./utils/json-parse.ts\";\nexport * from \"./utils/overflow.ts\";\nexport * from \"./utils/retry.ts\";\nexport * from \"./utils/stream-deadline.ts\";\nexport * from \"./utils/streaming-json.ts\";\nexport { contentText, getSystemMessageText, renderSystemMessageUpdate } from \"./utils/text.ts\";\nexport * from \"./utils/transcript.ts\";\nexport * from \"./utils/typebox-helpers.ts\";\nexport { uuidv7 } from \"./utils/uuid.ts\";\nexport * from \"./utils/validation.ts\";\nexport { PI_AI_VERSION } from \"./utils/version.ts\";\n"]}
package/dist/models.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type AuthResolutionOverrides } from "./auth/resolve.ts";
2
- import type { AuthCheck, AuthContext, AuthInteraction, AuthOperationOptions, AuthResult, AuthType, Credential, CredentialStore, LoginOptions, OAuthCredential, ProviderAuth } from "./auth/types.ts";
2
+ import type { AuthCheck, AuthContext, AuthInteraction, AuthOperationOptions, AuthResult, AuthType, Credential, CredentialStore, LoginOptions, ProviderAuth } from "./auth/types.ts";
3
3
  import { type ModelsStore, type ModelsStoreEntry } from "./models-store.ts";
4
4
  import type { AnyModel, Api, ApiStreamOptions, AssistantImages, AssistantMessage, AssistantMessageEventStream, ClassifierApi, ClassifierContext, ClassifierModel, ClassifierOptions, ClassifierResult, CompactorModel, Context, DeferredCancelOptions, DeferredFetchOptions, DeferredHandle, ImageApi, ImageApiOptions, ImageModel, ImagesContext, ImagesOptions, Model, ModelCost, ModelServiceTierId, ModelThinkingLevel, ModelType, ModelTypeMap, ProviderClassifier, ProviderHeaders, ProviderImages, ProviderStreams, SimpleStreamOptions, TranscriptContext, Usage } from "./types.ts";
5
5
  import { type ClientIdentity } from "./utils/identity.ts";
@@ -33,12 +33,14 @@ export interface RefreshModelsContext {
33
33
  */
34
34
  baseUrl?: string;
35
35
  /**
36
- * Network phase with an OAuth credential only: save account data the refresh read with that login,
37
- * such as the model lists its availability filter checks. `update` receives the stored login and
38
- * returns its replacement, or undefined to leave it unchanged. Nothing is written once the store no
39
- * longer holds the token this refresh used, so a renewed login or another account is never changed.
36
+ * Network phase with a stored OAuth login or API key: save account data the refresh read with that
37
+ * credential, such as the model lists its availability filter checks. `update` receives the stored
38
+ * credential, always of the type `credential` has, and returns its replacement, or undefined to leave
39
+ * it unchanged. Nothing is written once the store no longer holds the token or key this refresh
40
+ * used, so a renewed login, a replaced key or another account is never changed. A key the store holds
41
+ * as an environment reference or command, or one that comes from the environment, is never matched.
40
42
  */
41
- updateCredential?(update: (current: OAuthCredential) => OAuthCredential | undefined): Promise<void>;
43
+ updateCredential?(update: (current: Credential) => Credential | undefined): Promise<void>;
42
44
  }
43
45
  export interface ModelsRefreshOptions {
44
46
  allowNetwork?: boolean;
@@ -111,6 +113,13 @@ export interface Provider<TApi extends Api = Api> {
111
113
  * shared abort signal for blocking work.
112
114
  */
113
115
  refreshModels?(context: RefreshModelsContext): Promise<void>;
116
+ /**
117
+ * What the network phase of `refreshModels` needs. "credential" (the default) receives the
118
+ * effective credential, so an expired OAuth token is refreshed first. "configured" is for catalogs
119
+ * served by a source other than the provider, such as pi.dev: the phase still runs only when the
120
+ * provider is configured, but OAuth is never refreshed for it and `context.credential` is undefined.
121
+ */
122
+ readonly refreshModelsAuth?: "credential" | "configured";
114
123
  /**
115
124
  * Optional provider policy for credential-specific model availability.
116
125
  * `getModels()` remains the complete synchronous chat catalog; `Models.getAvailable()`
@@ -1 +1 @@
1
- {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,KAAK,uBAAuB,EAK5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACX,SAAS,EACT,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,UAAU,EACV,QAAQ,EACR,UAAU,EACV,eAAe,EACf,YAAY,EACZ,eAAe,EACf,YAA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G;AACH,wBAAgB,cAAc,CAAC,IAAI,SAAS,GAAG,GAAG,GAAG,EAAE,KAAK,EAAE,qBAAqB,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAyJzG;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,IAAI,SAAS,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,GAAG,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,CAEzF;AAED,8GAA8G;AAC9G,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,cAAc,CAAC,EACvC,WAAW,EAAE,kBAAkB,GAC7B,SAAS,GAAG,SAAS,CAEvB;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAqB1E;AAID,wBAAgB,0BAA0B,CAAC,IAAI,SAAS,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,kBAAkB,EAAE,CASrG;AAED,wBAAgB,kBAAkB,CAAC,IAAI,SAAS,GAAG,EAClD,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAClB,KAAK,EAAE,kBAAkB,GACvB,kBAAkB,CAgBpB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,EAAE,CAAC,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAGtG"}
package/dist/models.js CHANGED
@@ -19,6 +19,12 @@ function hasKnownModelType(model) {
19
19
  function withKnownModelTypes(entry) {
20
20
  return { ...entry, models: entry.models.filter(hasKnownModelType) };
21
21
  }
22
+ /** Whether `stored` still holds the token or key `used`, the secret a refresh authenticated with. */
23
+ function holdsSameSecret(stored, used) {
24
+ if (stored.type === "oauth")
25
+ return used.type === "oauth" && stored.access === used.access;
26
+ return used.type === "api_key" && stored.key === used.key;
27
+ }
22
28
  function mergeHeaders(base, override) {
23
29
  if (!base && !override)
24
30
  return undefined;
@@ -193,7 +199,7 @@ class ModelsImpl {
193
199
  }
194
200
  async runProviderRefreshPhase(provider, credential, allowNetwork, force, generation, signal) {
195
201
  const stored = await this.modelsStore.read(provider.id, { signal });
196
- const login = allowNetwork && credential?.type === "oauth" ? credential : undefined;
202
+ const refreshed = allowNetwork ? credential : undefined;
197
203
  await provider.refreshModels({
198
204
  credential,
199
205
  stored: stored ? withKnownModelTypes(structuredClone(stored)) : undefined,
@@ -202,13 +208,15 @@ class ModelsImpl {
202
208
  force: allowNetwork ? force : undefined,
203
209
  signal,
204
210
  baseUrl: provider.baseUrl,
205
- ...(login ? { updateCredential: (update) => this.updateRefreshLogin(provider.id, login, update, signal) } : {}),
211
+ ...(refreshed
212
+ ? { updateCredential: (update) => this.updateRefreshCredential(provider.id, refreshed, update, signal) }
213
+ : {}),
206
214
  });
207
215
  }
208
216
  /** See `RefreshModelsContext.updateCredential`. */
209
- async updateRefreshLogin(providerId, login, update, signal) {
217
+ async updateRefreshCredential(providerId, refreshed, update, signal) {
210
218
  try {
211
- await this.credentials.modify(providerId, async (current) => (current?.type === "oauth" && current.access === login.access ? update(current) : undefined), { signal });
219
+ await this.credentials.modify(providerId, async (current) => (current !== undefined && holdsSameSecret(current, refreshed) ? update(current) : undefined), { signal });
212
220
  }
213
221
  catch (error) {
214
222
  signal.throwIfAborted();
@@ -241,10 +249,10 @@ class ModelsImpl {
241
249
  throw credentialError;
242
250
  if (!allowNetwork || signal.aborted)
243
251
  return;
244
- const credential = await this.resolveRefreshCredential(provider, storedCredential, signal);
245
- if (!credential)
252
+ const network = await this.resolveNetworkRefresh(provider, storedCredential, signal);
253
+ if (!network)
246
254
  return;
247
- await this.runProviderRefreshPhase(provider, credential, true, options.force, generation, signal);
255
+ await this.runProviderRefreshPhase(provider, network.credential, true, options.force, generation, signal);
248
256
  })();
249
257
  try {
250
258
  await raceWithAbortSignal(operation, signal);
@@ -293,6 +301,13 @@ class ModelsImpl {
293
301
  }
294
302
  return { aborted: callerSignal.aborted, errors: new Map(errors) };
295
303
  }
304
+ async resolveNetworkRefresh(provider, stored, signal) {
305
+ if (provider.refreshModelsAuth === "configured") {
306
+ return (await this.checkProviderAuth(provider, stored, signal)) ? {} : undefined;
307
+ }
308
+ const credential = await this.resolveRefreshCredential(provider, stored, signal);
309
+ return credential ? { credential } : undefined;
310
+ }
296
311
  async resolveRefreshCredential(provider, stored, signal) {
297
312
  if (stored?.type === "oauth") {
298
313
  const oauth = provider.auth.oauth;