@bastani/pi-ai 0.9.71-alpha.1 → 0.9.72-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.
- package/CHANGELOG.md +64 -1
- package/README.md +78 -8
- package/dist/api/anthropic-messages.d.ts.map +1 -1
- package/dist/api/anthropic-messages.js +50 -10
- package/dist/api/anthropic-messages.js.map +1 -1
- package/dist/api/azure-openai-responses.d.ts.map +1 -1
- package/dist/api/azure-openai-responses.js +7 -2
- package/dist/api/azure-openai-responses.js.map +1 -1
- package/dist/api/bedrock-converse-stream.d.ts.map +1 -1
- package/dist/api/bedrock-converse-stream.js +28 -1
- package/dist/api/bedrock-converse-stream.js.map +1 -1
- package/dist/api/bedrock-converse-stream.lazy.d.ts +7 -0
- package/dist/api/bedrock-converse-stream.lazy.d.ts.map +1 -1
- package/dist/api/bedrock-converse-stream.lazy.js +18 -5
- package/dist/api/bedrock-converse-stream.lazy.js.map +1 -1
- package/dist/api/google-generative-ai.d.ts +3 -1
- package/dist/api/google-generative-ai.d.ts.map +1 -1
- package/dist/api/google-generative-ai.js +4 -2
- package/dist/api/google-generative-ai.js.map +1 -1
- package/dist/api/google-shared.d.ts +10 -2
- package/dist/api/google-shared.d.ts.map +1 -1
- package/dist/api/google-shared.js +31 -9
- package/dist/api/google-shared.js.map +1 -1
- package/dist/api/google-vertex.d.ts +3 -1
- package/dist/api/google-vertex.d.ts.map +1 -1
- package/dist/api/google-vertex.js +4 -2
- package/dist/api/google-vertex.js.map +1 -1
- package/dist/api/lazy.d.ts +2 -2
- package/dist/api/lazy.d.ts.map +1 -1
- package/dist/api/lazy.js +10 -9
- package/dist/api/lazy.js.map +1 -1
- package/dist/api/mistral-conversations.d.ts.map +1 -1
- package/dist/api/mistral-conversations.js +12 -1
- package/dist/api/mistral-conversations.js.map +1 -1
- package/dist/api/openai-codex-responses.d.ts.map +1 -1
- package/dist/api/openai-codex-responses.js +6 -1
- package/dist/api/openai-codex-responses.js.map +1 -1
- package/dist/api/openai-completions.d.ts +2 -1
- package/dist/api/openai-completions.d.ts.map +1 -1
- package/dist/api/openai-completions.js +112 -15
- package/dist/api/openai-completions.js.map +1 -1
- package/dist/api/openai-images-options.d.ts +107 -0
- package/dist/api/openai-images-options.d.ts.map +1 -0
- package/dist/api/openai-images-options.js +106 -0
- package/dist/api/openai-images-options.js.map +1 -0
- package/dist/api/openai-images.d.ts +3 -11
- package/dist/api/openai-images.d.ts.map +1 -1
- package/dist/api/openai-images.js +117 -16
- package/dist/api/openai-images.js.map +1 -1
- package/dist/api/openai-responses-shared.js +6 -2
- package/dist/api/openai-responses-shared.js.map +1 -1
- package/dist/api/openai-responses.d.ts.map +1 -1
- package/dist/api/openai-responses.js +29 -7
- package/dist/api/openai-responses.js.map +1 -1
- package/dist/auth/oauth/load.d.ts.map +1 -1
- package/dist/auth/oauth/load.js +5 -2
- package/dist/auth/oauth/load.js.map +1 -1
- package/dist/env-api-keys.d.ts.map +1 -1
- package/dist/env-api-keys.js +1 -0
- package/dist/env-api-keys.js.map +1 -1
- package/dist/image-generation-error.d.ts +203 -0
- package/dist/image-generation-error.d.ts.map +1 -0
- package/dist/image-generation-error.js +441 -0
- package/dist/image-generation-error.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/lazy-bedrock-provider.d.ts +10 -0
- package/dist/lazy-bedrock-provider.d.ts.map +1 -0
- package/dist/lazy-bedrock-provider.js +13 -0
- package/dist/lazy-bedrock-provider.js.map +1 -0
- package/dist/lazy-oauth.d.ts +10 -0
- package/dist/lazy-oauth.d.ts.map +1 -0
- package/dist/lazy-oauth.js +23 -0
- package/dist/lazy-oauth.js.map +1 -0
- package/dist/models.d.ts.map +1 -1
- package/dist/models.generated.d.ts +4 -0
- package/dist/models.generated.d.ts.map +1 -1
- package/dist/models.generated.js +4 -0
- package/dist/models.generated.js.map +1 -1
- package/dist/models.js +8 -8
- package/dist/models.js.map +1 -1
- package/dist/providers/all.d.ts.map +1 -1
- package/dist/providers/all.js +2 -0
- package/dist/providers/all.js.map +1 -1
- package/dist/providers/azure.d.ts.map +1 -1
- package/dist/providers/azure.js +2 -2
- package/dist/providers/azure.js.map +1 -1
- package/dist/providers/compat-schema.d.ts +15 -0
- package/dist/providers/compat-schema.d.ts.map +1 -1
- package/dist/providers/compat-schema.js +19 -1
- package/dist/providers/compat-schema.js.map +1 -1
- package/dist/providers/data/.manifest.json +1 -1
- package/dist/providers/data/anthropic.json +1 -1
- package/dist/providers/data/azure.json +1 -1
- package/dist/providers/data/baseten.json +1 -1
- package/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/dist/providers/data/fireworks.json +1 -1
- package/dist/providers/data/github-copilot.json +1 -1
- package/dist/providers/data/google-vertex.json +1 -1
- package/dist/providers/data/google.json +1 -1
- package/dist/providers/data/nvidia.json +1 -1
- package/dist/providers/data/openai-images.json +1 -1
- package/dist/providers/data/opencode-go.json +1 -1
- package/dist/providers/data/opencode.json +1 -1
- package/dist/providers/data/openrouter.json +1 -1
- package/dist/providers/data/qwen-token-plan-individual-cn.json +1 -0
- package/dist/providers/data/qwen-token-plan-individual.json +1 -1
- package/dist/providers/data/together.json +1 -1
- package/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/providers/github-copilot-capabilities.d.ts +67 -0
- package/dist/providers/github-copilot-capabilities.d.ts.map +1 -0
- package/dist/providers/github-copilot-capabilities.js +81 -0
- package/dist/providers/github-copilot-capabilities.js.map +1 -0
- package/dist/providers/github-copilot-errors.d.ts +243 -0
- package/dist/providers/github-copilot-errors.d.ts.map +1 -0
- package/dist/providers/github-copilot-errors.js +720 -0
- package/dist/providers/github-copilot-errors.js.map +1 -0
- package/dist/providers/github-copilot.d.ts +1 -2
- package/dist/providers/github-copilot.d.ts.map +1 -1
- package/dist/providers/github-copilot.js +29 -4
- package/dist/providers/github-copilot.js.map +1 -1
- package/dist/providers/openai-codex.js +1 -1
- package/dist/providers/openai-codex.js.map +1 -1
- package/dist/providers/qwen-token-plan-individual-cn.d.ts +3 -0
- package/dist/providers/qwen-token-plan-individual-cn.d.ts.map +1 -0
- package/dist/providers/qwen-token-plan-individual-cn.js +15 -0
- package/dist/providers/qwen-token-plan-individual-cn.js.map +1 -0
- package/dist/providers/qwen-token-plan-individual-cn.models.d.ts +5 -0
- package/dist/providers/qwen-token-plan-individual-cn.models.d.ts.map +1 -0
- package/dist/providers/qwen-token-plan-individual-cn.models.js +8 -0
- package/dist/providers/qwen-token-plan-individual-cn.models.js.map +1 -0
- package/dist/types.d.ts +29 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/error-body.d.ts +8 -0
- package/dist/utils/error-body.d.ts.map +1 -1
- package/dist/utils/error-body.js +28 -1
- package/dist/utils/error-body.js.map +1 -1
- package/dist/utils/model-operations.d.ts.map +1 -1
- package/dist/utils/model-operations.js +6 -0
- package/dist/utils/model-operations.js.map +1 -1
- package/dist/utils/overflow.d.ts +4 -0
- package/dist/utils/overflow.d.ts.map +1 -1
- package/dist/utils/overflow.js +16 -3
- package/dist/utils/overflow.js.map +1 -1
- package/dist/utils/provider-retry.d.ts +2 -0
- package/dist/utils/provider-retry.d.ts.map +1 -1
- package/dist/utils/provider-retry.js +2 -0
- package/dist/utils/provider-retry.js.map +1 -1
- package/dist/utils/retry.d.ts +3 -1
- package/dist/utils/retry.d.ts.map +1 -1
- package/dist/utils/retry.js +9 -0
- package/dist/utils/retry.js.map +1 -1
- package/dist/utils/thinking-off.d.ts +23 -0
- package/dist/utils/thinking-off.d.ts.map +1 -0
- package/dist/utils/thinking-off.js +51 -0
- package/dist/utils/thinking-off.js.map +1 -0
- package/dist/utils/version.d.ts +1 -1
- package/dist/utils/version.js +1 -1
- package/dist/utils/version.js.map +1 -1
- package/package.json +9 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-copilot-errors.js","sourceRoot":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;IAClE,IAAI,MAAM,CAAC,QAAQ,KAAK,gBAAgB,IAAI,CAAC,MAAM,CAAC,UAAU,KAAK,MAAM,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,CAAC,EAAE,CAAC;QAC/G,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CACnC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAC/F,CAAC;IACF,OAAO,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,+BAA+B,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;AAC/G,CAAC","sourcesContent":["import type { AssistantMessage, JsonObject } from \"../types.ts\";\nimport { type AssistantMessageDiagnostic, appendAssistantMessageDiagnostic } from \"../utils/diagnostics.ts\";\nimport { getProviderRetryAfterMs } from \"../utils/retry-hints.ts\";\n\n/** Stable codes of every GitHub Copilot request failure. Public API: never renamed or reused. */\nexport type GitHubCopilotErrorCode =\n\t| \"model-unavailable\"\n\t| \"rate-limited\"\n\t| \"quota-exhausted\"\n\t| \"content-filtered\"\n\t| \"prompt-too-large\"\n\t| \"invalid-request\"\n\t| \"authentication-failed\"\n\t| \"service-unavailable\"\n\t| \"stream-ended-early\"\n\t| \"empty-response\"\n\t| \"unrecognized-response\";\n\nconst MODEL_UNAVAILABLE_REASONS = [\"integration\", \"not-supported\", \"wrong-api\", \"no-endpoint\", \"not-found\"] as const;\nconst INVALID_REQUEST_REASONS = [\"reasoning-effort\", \"integration-id\", \"rejected\"] as const;\nconst UNRECOGNIZED_REASONS = [\"unknown-status\", \"unknown-error-event\", \"malformed-body\"] as const;\n\n/** Why Copilot refused to serve the model. */\nexport type GitHubCopilotModelUnavailableReason = (typeof MODEL_UNAVAILABLE_REASONS)[number];\n\n/** Which part of the request Copilot rejected. */\nexport type GitHubCopilotInvalidRequestReason = (typeof INVALID_REQUEST_REASONS)[number];\n\n/** What Atomic could not interpret. */\nexport type GitHubCopilotUnrecognizedReason = (typeof UNRECOGNIZED_REASONS)[number];\n\nexport type GitHubCopilotErrorName =\n\t| \"GitHubCopilotError\"\n\t| \"GitHubCopilotModelUnavailableError\"\n\t| \"GitHubCopilotRateLimitError\"\n\t| \"GitHubCopilotQuotaExhaustedError\"\n\t| \"GitHubCopilotContentFilterError\"\n\t| \"GitHubCopilotPromptTooLargeError\"\n\t| \"GitHubCopilotInvalidRequestError\"\n\t| \"GitHubCopilotAuthenticationError\"\n\t| \"GitHubCopilotServiceUnavailableError\"\n\t| \"GitHubCopilotStreamEndedEarlyError\"\n\t| \"GitHubCopilotEmptyResponseError\"\n\t| \"GitHubCopilotUnrecognizedResponseError\";\n\nexport type GitHubCopilotErrorFieldValue = string | number | null;\nexport type GitHubCopilotErrorFields = Readonly<Record<string, GitHubCopilotErrorFieldValue>>;\n\n/** The request a failure belongs to, and what the provider reported about it. No prompt text, tokens or bodies. */\nexport interface GitHubCopilotErrorContext {\n\treadonly modelId: string;\n\treadonly api: string;\n\t/** HTTP status, when the failure was an HTTP response. */\n\treadonly status?: number;\n\t/** The provider's own error code, such as `model_not_supported`. */\n\treadonly providerCode?: string;\n\t/** The provider's `x-request-id`, for support requests. */\n\treadonly requestId?: string;\n\t/** The provider's short error text, truncated. */\n\treadonly detail?: string;\n}\n\n/** A cause in wire form, bounded in depth. */\nexport interface SerializedGitHubCopilotErrorCause {\n\treadonly name: string;\n\treadonly message: string;\n\treadonly code?: string;\n\treadonly cause?: SerializedGitHubCopilotErrorCause;\n}\n\n/** Wire form of a GitHub Copilot error, as an assistant message's diagnostics carry it across processes. */\nexport interface SerializedGitHubCopilotError {\n\treadonly name: string;\n\treadonly code: GitHubCopilotErrorCode;\n\treadonly message: string;\n\treadonly hint: string;\n\treadonly retryable: boolean;\n\treadonly fields: GitHubCopilotErrorFields;\n\treadonly cause?: SerializedGitHubCopilotErrorCause;\n}\n\n/** `AssistantMessageDiagnostic.type` of the diagnostic that carries a serialized GitHub Copilot error. */\nexport const GITHUB_COPILOT_ERROR_DIAGNOSTIC = \"github_copilot_error\";\n\nconst MAX_CAUSE_DEPTH = 8;\nconst MAX_DETAIL_CHARS = 300;\n\n/** Every code, as a set that relayed values of any type can be checked against. */\nconst GITHUB_COPILOT_ERROR_CODES: ReadonlySet<unknown> = new Set<GitHubCopilotErrorCode>([\n\t\"model-unavailable\",\n\t\"rate-limited\",\n\t\"quota-exhausted\",\n\t\"content-filtered\",\n\t\"prompt-too-large\",\n\t\"invalid-request\",\n\t\"authentication-failed\",\n\t\"service-unavailable\",\n\t\"stream-ended-early\",\n\t\"empty-response\",\n\t\"unrecognized-response\",\n]);\n\nconst RETRYABLE_CODES: ReadonlySet<GitHubCopilotErrorCode> = new Set<GitHubCopilotErrorCode>([\n\t\"rate-limited\",\n\t\"service-unavailable\",\n\t\"stream-ended-early\",\n\t\"empty-response\",\n\t\"unrecognized-response\",\n]);\n\nconst WHAT_FAILED: Readonly<Record<GitHubCopilotErrorCode, string>> = {\n\t\"model-unavailable\": \"GitHub Copilot model unavailable\",\n\t\"rate-limited\": \"GitHub Copilot rate limit reached\",\n\t\"quota-exhausted\": \"GitHub Copilot quota exhausted\",\n\t\"content-filtered\": \"GitHub Copilot content filter blocked the request\",\n\t\"prompt-too-large\": \"GitHub Copilot prompt too large\",\n\t\"invalid-request\": \"GitHub Copilot rejected the request\",\n\t\"authentication-failed\": \"GitHub Copilot authentication failed\",\n\t\"service-unavailable\": \"GitHub Copilot service unavailable\",\n\t\"stream-ended-early\": \"GitHub Copilot response stream ended early\",\n\t\"empty-response\": \"GitHub Copilot returned an empty response\",\n\t\"unrecognized-response\": \"GitHub Copilot returned an unrecognized response\",\n};\n\nconst HINTS: Readonly<Record<GitHubCopilotErrorCode, string>> = {\n\t\"model-unavailable\": \"Pick another model, or run /login to refresh the models this account can use.\",\n\t\"rate-limited\": \"Wait for the rate limit to reset; Atomic retries the request when retries are enabled.\",\n\t\"quota-exhausted\": \"Pick another model, or wait until the Copilot plan's quota resets.\",\n\t\"content-filtered\":\n\t\t\"Rephrase the request or pick another model; retry.fallbackOnContentFilter decides whether a fallback model is tried.\",\n\t\"prompt-too-large\": \"Run /compact or start a new session to shrink the conversation.\",\n\t\"invalid-request\": \"Check the model's thinking level and any models.json overrides for this model.\",\n\t\"authentication-failed\": \"Run /login to sign in to GitHub Copilot again, or check COPILOT_GITHUB_TOKEN.\",\n\t\"service-unavailable\": \"Retry later; Atomic retries the request when retries are enabled.\",\n\t\"stream-ended-early\": \"Retry the request; Atomic retries it when retries are enabled.\",\n\t\"empty-response\": \"Retry the request; Atomic retries it when retries are enabled.\",\n\t\"unrecognized-response\": \"Retry the request, and report it if it keeps happening.\",\n};\n\n/** Hints for the reasons that need more than their code's hint. */\nconst MODEL_UNAVAILABLE_HINTS: Readonly<Partial<Record<GitHubCopilotModelUnavailableReason, string>>> = {\n\tintegration:\n\t\t\"Copilot does not offer this model to Atomic's integration. Pick another model, or run /login to refresh the model list.\",\n\t\"wrong-api\": \"Run /login to refresh the model list so Atomic calls the API Copilot serves this model on.\",\n\t\"no-endpoint\": \"Copilot has no endpoint for this model under this account's settings. Pick another model.\",\n};\n\nconst INVALID_REQUEST_HINTS: Readonly<Partial<Record<GitHubCopilotInvalidRequestReason, string>>> = {\n\t\"reasoning-effort\": \"Pick a thinking level this model lists.\",\n\t\"integration-id\": \"Remove the Copilot-Integration-Id header override from models.json.\",\n};\n\nfunction failureMessage(code: GitHubCopilotErrorCode, modelId: string, hint: string): string {\n\treturn `${WHAT_FAILED[code]}: ${modelId} (${code}). ${hint}`;\n}\n\ninterface GitHubCopilotErrorOptions {\n\treadonly hint?: string;\n\treadonly cause?: unknown;\n}\n\n/** Base of every GitHub Copilot request failure. Catch this to handle the whole family. */\nexport class GitHubCopilotError extends Error {\n\toverride readonly name: string = \"GitHubCopilotError\";\n\treadonly code: GitHubCopilotErrorCode;\n\treadonly retryable: boolean;\n\treadonly hint: string;\n\treadonly modelId: string;\n\treadonly api: string;\n\treadonly status: number | undefined;\n\treadonly providerCode: string | undefined;\n\treadonly requestId: string | undefined;\n\treadonly detail: string | undefined;\n\n\tconstructor(code: GitHubCopilotErrorCode, context: GitHubCopilotErrorContext, options?: GitHubCopilotErrorOptions) {\n\t\tconst hint = options?.hint ?? HINTS[code];\n\t\tsuper(\n\t\t\tfailureMessage(code, context.modelId, hint),\n\t\t\toptions?.cause === undefined ? undefined : { cause: options.cause },\n\t\t);\n\t\tthis.code = code;\n\t\tthis.retryable = RETRYABLE_CODES.has(code);\n\t\tthis.hint = hint;\n\t\tthis.modelId = context.modelId;\n\t\tthis.api = context.api;\n\t\tthis.status = context.status;\n\t\tthis.providerCode = context.providerCode;\n\t\tthis.requestId = context.requestId;\n\t\tthis.detail = context.detail;\n\t}\n\n\t/** JSON-safe context fields; subclasses add their own. */\n\tfields(): GitHubCopilotErrorFields {\n\t\treturn {\n\t\t\tmodelId: this.modelId,\n\t\t\tapi: this.api,\n\t\t\tstatus: this.status ?? null,\n\t\t\tproviderCode: this.providerCode ?? null,\n\t\t\trequestId: this.requestId ?? null,\n\t\t\tdetail: this.detail ?? null,\n\t\t};\n\t}\n}\n\n/** Copilot will not serve this model to this account, integration or API. Not retryable; a fallback model may work. */\nexport class GitHubCopilotModelUnavailableError extends GitHubCopilotError {\n\toverride readonly name = \"GitHubCopilotModelUnavailableError\" as const;\n\tdeclare readonly code: \"model-unavailable\";\n\treadonly reason: GitHubCopilotModelUnavailableReason;\n\n\tconstructor(\n\t\treason: GitHubCopilotModelUnavailableReason,\n\t\tcontext: GitHubCopilotErrorContext,\n\t\toptions?: { readonly cause?: unknown },\n\t) {\n\t\tsuper(\"model-unavailable\", context, { hint: MODEL_UNAVAILABLE_HINTS[reason], cause: options?.cause });\n\t\tthis.reason = reason;\n\t}\n\n\toverride fields(): GitHubCopilotErrorFields {\n\t\treturn { ...super.fields(), reason: this.reason };\n\t}\n}\n\n/** Copilot throttled the request. Retryable after `retryAfterMs` when the server sent a delay. */\nexport class GitHubCopilotRateLimitError extends GitHubCopilotError {\n\toverride readonly name = \"GitHubCopilotRateLimitError\" as const;\n\tdeclare readonly code: \"rate-limited\";\n\treadonly retryAfterMs: number | undefined;\n\n\tconstructor(context: GitHubCopilotErrorContext, retryAfterMs?: number, options?: { readonly cause?: unknown }) {\n\t\tsuper(\"rate-limited\", context, options);\n\t\tthis.retryAfterMs = retryAfterMs;\n\t}\n\n\toverride fields(): GitHubCopilotErrorFields {\n\t\treturn { ...super.fields(), retryAfterMs: this.retryAfterMs ?? null };\n\t}\n}\n\n/** The plan's quota or billing allowance for the model is used up. Not retryable until it resets. */\nexport class GitHubCopilotQuotaExhaustedError extends GitHubCopilotError {\n\toverride readonly name = \"GitHubCopilotQuotaExhaustedError\" as const;\n\tdeclare readonly code: \"quota-exhausted\";\n\n\tconstructor(context: GitHubCopilotErrorContext, options?: { readonly cause?: unknown }) {\n\t\tsuper(\"quota-exhausted\", context, options);\n\t}\n}\n\n/** A content or safety filter blocked the request or the response. The same request is refused again. */\nexport class GitHubCopilotContentFilterError extends GitHubCopilotError {\n\toverride readonly name = \"GitHubCopilotContentFilterError\" as const;\n\tdeclare readonly code: \"content-filtered\";\n\n\tconstructor(context: GitHubCopilotErrorContext, options?: { readonly cause?: unknown }) {\n\t\tsuper(\"content-filtered\", context, options);\n\t}\n}\n\n/** The prompt exceeds the model's prompt-token limit. Compact the conversation instead of retrying. */\nexport class GitHubCopilotPromptTooLargeError extends GitHubCopilotError {\n\toverride readonly name = \"GitHubCopilotPromptTooLargeError\" as const;\n\tdeclare readonly code: \"prompt-too-large\";\n\treadonly promptTokens: number | undefined;\n\treadonly limitTokens: number | undefined;\n\n\tconstructor(\n\t\tcontext: GitHubCopilotErrorContext,\n\t\ttokens?: { readonly promptTokens?: number; readonly limitTokens?: number },\n\t\toptions?: { readonly cause?: unknown },\n\t) {\n\t\tsuper(\"prompt-too-large\", context, options);\n\t\tthis.promptTokens = tokens?.promptTokens;\n\t\tthis.limitTokens = tokens?.limitTokens;\n\t}\n\n\toverride fields(): GitHubCopilotErrorFields {\n\t\treturn { ...super.fields(), promptTokens: this.promptTokens ?? null, limitTokens: this.limitTokens ?? null };\n\t}\n}\n\n/** Copilot rejected the request's shape or settings. Sending it again fails the same way. */\nexport class GitHubCopilotInvalidRequestError extends GitHubCopilotError {\n\toverride readonly name = \"GitHubCopilotInvalidRequestError\" as const;\n\tdeclare readonly code: \"invalid-request\";\n\treadonly reason: GitHubCopilotInvalidRequestReason;\n\n\tconstructor(\n\t\treason: GitHubCopilotInvalidRequestReason,\n\t\tcontext: GitHubCopilotErrorContext,\n\t\toptions?: { readonly cause?: unknown },\n\t) {\n\t\tsuper(\"invalid-request\", context, { hint: INVALID_REQUEST_HINTS[reason], cause: options?.cause });\n\t\tthis.reason = reason;\n\t}\n\n\toverride fields(): GitHubCopilotErrorFields {\n\t\treturn { ...super.fields(), reason: this.reason };\n\t}\n}\n\n/** Copilot refused the credential. Sign in again; another provider's model may still work. */\nexport class GitHubCopilotAuthenticationError extends GitHubCopilotError {\n\toverride readonly name = \"GitHubCopilotAuthenticationError\" as const;\n\tdeclare readonly code: \"authentication-failed\";\n\n\tconstructor(context: GitHubCopilotErrorContext, options?: { readonly cause?: unknown }) {\n\t\tsuper(\"authentication-failed\", context, options);\n\t}\n}\n\n/** Copilot or the model behind it is down, overloaded or timed out. Retryable. */\nexport class GitHubCopilotServiceUnavailableError extends GitHubCopilotError {\n\toverride readonly name = \"GitHubCopilotServiceUnavailableError\" as const;\n\tdeclare readonly code: \"service-unavailable\";\n\n\tconstructor(context: GitHubCopilotErrorContext, options?: { readonly cause?: unknown }) {\n\t\tsuper(\"service-unavailable\", context, options);\n\t}\n}\n\n/** The response stream stopped before its finish reason or terminal event. Retryable. */\nexport class GitHubCopilotStreamEndedEarlyError extends GitHubCopilotError {\n\toverride readonly name = \"GitHubCopilotStreamEndedEarlyError\" as const;\n\tdeclare readonly code: \"stream-ended-early\";\n\n\tconstructor(context: GitHubCopilotErrorContext, options?: { readonly cause?: unknown }) {\n\t\tsuper(\"stream-ended-early\", context, options);\n\t}\n}\n\n/** The model finished with no text and no tool call, as Copilot's Gemini models sometimes do. Retryable. */\nexport class GitHubCopilotEmptyResponseError extends GitHubCopilotError {\n\toverride readonly name = \"GitHubCopilotEmptyResponseError\" as const;\n\tdeclare readonly code: \"empty-response\";\n\n\tconstructor(context: GitHubCopilotErrorContext, options?: { readonly cause?: unknown }) {\n\t\tsuper(\"empty-response\", context, options);\n\t}\n}\n\n/** Copilot answered with a status, error event or body Atomic does not recognize. Retryable a bounded number of times. */\nexport class GitHubCopilotUnrecognizedResponseError extends GitHubCopilotError {\n\toverride readonly name = \"GitHubCopilotUnrecognizedResponseError\" as const;\n\tdeclare readonly code: \"unrecognized-response\";\n\treadonly reason: GitHubCopilotUnrecognizedReason;\n\n\tconstructor(\n\t\treason: GitHubCopilotUnrecognizedReason,\n\t\tcontext: GitHubCopilotErrorContext,\n\t\toptions?: { readonly cause?: unknown },\n\t) {\n\t\tsuper(\"unrecognized-response\", context, options);\n\t\tthis.reason = reason;\n\t}\n\n\toverride fields(): GitHubCopilotErrorFields {\n\t\treturn { ...super.fields(), reason: this.reason };\n\t}\n}\n\nconst CODE_BY_NAME: Readonly<Record<Exclude<GitHubCopilotErrorName, \"GitHubCopilotError\">, GitHubCopilotErrorCode>> = {\n\tGitHubCopilotModelUnavailableError: \"model-unavailable\",\n\tGitHubCopilotRateLimitError: \"rate-limited\",\n\tGitHubCopilotQuotaExhaustedError: \"quota-exhausted\",\n\tGitHubCopilotContentFilterError: \"content-filtered\",\n\tGitHubCopilotPromptTooLargeError: \"prompt-too-large\",\n\tGitHubCopilotInvalidRequestError: \"invalid-request\",\n\tGitHubCopilotAuthenticationError: \"authentication-failed\",\n\tGitHubCopilotServiceUnavailableError: \"service-unavailable\",\n\tGitHubCopilotStreamEndedEarlyError: \"stream-ended-early\",\n\tGitHubCopilotEmptyResponseError: \"empty-response\",\n\tGitHubCopilotUnrecognizedResponseError: \"unrecognized-response\",\n};\n\ninterface StructuralError {\n\treadonly name?: unknown;\n\treadonly code?: unknown;\n\treadonly cause?: unknown;\n\treadonly diagnostics?: unknown;\n}\n\nfunction structural(value: unknown): StructuralError | undefined {\n\treturn typeof value === \"object\" && value !== null ? (value as StructuralError) : undefined;\n}\n\n/** A family member seen from another process or realm: its name and code, maybe its message. */\ninterface StructuralFamilyMember {\n\treadonly name: string;\n\treadonly code: GitHubCopilotErrorCode;\n\treadonly message?: unknown;\n}\n\n/** A family member relayed from another process or realm: an object with a family name and that name's code. */\nfunction isRelayedFamilyMember(value: unknown): value is StructuralFamilyMember {\n\tconst candidate = structural(value);\n\tif (typeof candidate?.name !== \"string\") return false;\n\tif (candidate.name === \"GitHubCopilotError\") return GITHUB_COPILOT_ERROR_CODES.has(candidate.code);\n\treturn CODE_BY_NAME[candidate.name as keyof typeof CODE_BY_NAME] === candidate.code;\n}\n\n/** Rebuild a relayed family member as its class; one that carries only its name and code gets that code's hint. */\nfunction rebuildRelayedFamilyMember(found: StructuralFamilyMember): GitHubCopilotError | undefined {\n\tconst deserialized = deserializeGitHubCopilotError(found);\n\tif (deserialized) return deserialized;\n\tif (\"fields\" in found || \"hint\" in found || \"retryable\" in found || \"cause\" in found) return undefined;\n\tif (Reflect.ownKeys(found).some((key) => key !== \"name\" && key !== \"code\" && key !== \"message\")) return undefined;\n\tif (\"message\" in found && typeof found.message !== \"string\") return undefined;\n\treturn deserializeGitHubCopilotError({\n\t\tname: found.name,\n\t\tcode: found.code,\n\t\tmessage: found.message ?? \"\",\n\t\thint: HINTS[found.code],\n\t\tretryable: RETRYABLE_CODES.has(found.code),\n\t\tfields: {},\n\t});\n}\n\n/**\n * The typed error at one link of a cause chain: the link itself, rebuilt when it was relayed from another process, or\n * the error its `diagnostics` carry when the link is a failed assistant message, as a workflow failure's cause is.\n */\nfunction typedErrorAt(link: unknown): GitHubCopilotError | undefined {\n\tif (link instanceof GitHubCopilotError) return link;\n\tif (isRelayedFamilyMember(link)) return rebuildRelayedFamilyMember(link);\n\treturn getGitHubCopilotError(structural(link));\n}\n\n/** The first typed error `matches` accepts, walking at most MAX_CAUSE_DEPTH links of the cause chain. */\nfunction findInCauseChain(\n\terror: unknown,\n\tmatches: (typed: GitHubCopilotError) => boolean,\n): GitHubCopilotError | undefined {\n\tlet current = error;\n\tfor (let depth = 0; depth < MAX_CAUSE_DEPTH; depth++) {\n\t\tconst typed = typedErrorAt(current);\n\t\tif (typed !== undefined && matches(typed)) return typed;\n\t\tcurrent = structural(current)?.cause;\n\t}\n\treturn undefined;\n}\n\n/**\n * A guard that answers whether the error, anything in its cause chain, or a failed assistant message in that chain holds\n * an error of this class. It returns a plain boolean, not a type predicate: the value passed in is usually the wrapper\n * or the message, not the error. Use `findGitHubCopilotError()` for the instance.\n */\nfunction guard(ctor: abstract new (...args: never[]) => GitHubCopilotError): (error: unknown) => boolean {\n\treturn (error) => findInCauseChain(error, (typed) => typed instanceof ctor) !== undefined;\n}\n\n/**\n * True when the error, anything in its cause chain, or a failed assistant message in that chain holds a GitHub Copilot\n * error. A plain boolean, not a type predicate: use `findGitHubCopilotError()` for the instance.\n */\nexport function isGitHubCopilotError(error: unknown): boolean {\n\treturn findGitHubCopilotError(error) !== undefined;\n}\n\n/**\n * First GitHub Copilot error in the cause chain, as an instance of its class: a link that is one, rebuilt when it was\n * relayed from another process, or the error a failed assistant message's diagnostics carry. The chain is walked to a\n * bounded depth, through JSON round-tripped links too.\n */\nexport function findGitHubCopilotError(error: unknown): GitHubCopilotError | undefined {\n\treturn findInCauseChain(error, () => true);\n}\n\n/** True when the first GitHub Copilot error in the cause chain says the same request may be sent again. */\nexport function isRetryableGitHubCopilotError(error: unknown): boolean {\n\treturn findGitHubCopilotError(error)?.retryable === true;\n}\n\nexport const isGitHubCopilotModelUnavailableError = guard(GitHubCopilotModelUnavailableError);\nexport const isGitHubCopilotRateLimitError = guard(GitHubCopilotRateLimitError);\nexport const isGitHubCopilotQuotaExhaustedError = guard(GitHubCopilotQuotaExhaustedError);\nexport const isGitHubCopilotContentFilterError = guard(GitHubCopilotContentFilterError);\nexport const isGitHubCopilotPromptTooLargeError = guard(GitHubCopilotPromptTooLargeError);\nexport const isGitHubCopilotInvalidRequestError = guard(GitHubCopilotInvalidRequestError);\nexport const isGitHubCopilotAuthenticationError = guard(GitHubCopilotAuthenticationError);\nexport const isGitHubCopilotServiceUnavailableError = guard(GitHubCopilotServiceUnavailableError);\nexport const isGitHubCopilotStreamEndedEarlyError = guard(GitHubCopilotStreamEndedEarlyError);\nexport const isGitHubCopilotEmptyResponseError = guard(GitHubCopilotEmptyResponseError);\nexport const isGitHubCopilotUnrecognizedResponseError = guard(GitHubCopilotUnrecognizedResponseError);\n\nfunction serializeCause(cause: unknown, depth: number): SerializedGitHubCopilotErrorCause | undefined {\n\tif (depth >= MAX_CAUSE_DEPTH || cause === undefined || cause === null) return undefined;\n\tconst candidate = structural(cause);\n\tconst nested = serializeCause(candidate?.cause, depth + 1);\n\treturn {\n\t\tname: typeof candidate?.name === \"string\" ? candidate.name : typeof cause,\n\t\tmessage: truncate(cause instanceof Error ? cause.message : String(cause)),\n\t\t...(typeof candidate?.code === \"string\" ? { code: candidate.code } : {}),\n\t\t...(nested === undefined ? {} : { cause: nested }),\n\t};\n}\n\n/** Wire form for crossing a process boundary; the cause chain is kept to a bounded depth. */\nexport function serializeGitHubCopilotError(error: GitHubCopilotError): SerializedGitHubCopilotError {\n\tconst cause = serializeCause(error.cause, 0);\n\treturn {\n\t\tname: error.name,\n\t\tcode: error.code,\n\t\tmessage: error.message,\n\t\thint: error.hint,\n\t\tretryable: error.retryable,\n\t\tfields: error.fields(),\n\t\t...(cause === undefined ? {} : { cause }),\n\t};\n}\n\nfunction rehydrateCause(cause: SerializedGitHubCopilotErrorCause | undefined): Error | undefined {\n\tif (cause === undefined) return undefined;\n\tconst family = isRelayedFamilyMember(cause)\n\t\t? rebuildRelayedFamilyMember({ name: cause.name, code: cause.code, message: cause.message })\n\t\t: undefined;\n\tconst error = family ?? new Error(cause.message);\n\tObject.defineProperties(error, {\n\t\tmessage: { value: cause.message },\n\t\tcause: { value: rehydrateCause(cause.cause), writable: true, configurable: true },\n\t});\n\tObject.defineProperty(error, \"name\", { value: cause.name });\n\tif (cause.code !== undefined) Object.defineProperty(error, \"code\", { value: cause.code, enumerable: true });\n\treturn error;\n}\n\nfunction stringField(fields: GitHubCopilotErrorFields, key: string): string | undefined {\n\tconst value = fields[key];\n\treturn typeof value === \"string\" ? value : undefined;\n}\n\nfunction numberField(fields: GitHubCopilotErrorFields, key: string): number | undefined {\n\tconst value = fields[key];\n\treturn typeof value === \"number\" ? value : undefined;\n}\n\nfunction contextFromFields(fields: GitHubCopilotErrorFields): GitHubCopilotErrorContext {\n\treturn {\n\t\tmodelId: stringField(fields, \"modelId\") ?? \"\",\n\t\tapi: stringField(fields, \"api\") ?? \"\",\n\t\tstatus: numberField(fields, \"status\"),\n\t\tproviderCode: stringField(fields, \"providerCode\"),\n\t\trequestId: stringField(fields, \"requestId\"),\n\t\tdetail: stringField(fields, \"detail\"),\n\t};\n}\n\nfunction isJsonRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isSerializedCause(value: unknown, depth = 0): value is SerializedGitHubCopilotErrorCause {\n\tif (value === undefined) return true;\n\tif (depth >= MAX_CAUSE_DEPTH || !isJsonRecord(value)) return false;\n\treturn (\n\t\ttypeof value.name === \"string\" &&\n\t\ttypeof value.message === \"string\" &&\n\t\t(value.code === undefined || typeof value.code === \"string\") &&\n\t\tisSerializedCause(value.cause, depth + 1)\n\t);\n}\n\nfunction isSerializedError(value: unknown): value is SerializedGitHubCopilotError {\n\tif (!isJsonRecord(value) || !isJsonRecord(value.fields)) return false;\n\treturn (\n\t\ttypeof value.name === \"string\" &&\n\t\tGITHUB_COPILOT_ERROR_CODES.has(value.code) &&\n\t\ttypeof value.message === \"string\" &&\n\t\ttypeof value.hint === \"string\" &&\n\t\ttypeof value.retryable === \"boolean\" &&\n\t\tObject.values(value.fields).every(\n\t\t\t(field) => field === null || typeof field === \"string\" || typeof field === \"number\",\n\t\t) &&\n\t\tisSerializedCause(value.cause)\n\t);\n}\n\n/** A serialized reason: one of `allowed`, or `fallback` when the field is absent. Undefined when it is anything else. */\nfunction reasonField<T extends string>(\n\tfields: GitHubCopilotErrorFields,\n\tallowed: readonly T[],\n\tfallback: T,\n): T | undefined {\n\tconst reason = fields.reason;\n\tif (reason === undefined || reason === null) return fallback;\n\treturn allowed.find((candidate) => candidate === reason);\n}\n\n/** Whether a serialized error's name, if it is a known class, goes with its code. */\nfunction agreesWithClass(serialized: SerializedGitHubCopilotError): boolean {\n\treturn (\n\t\t!Object.hasOwn(CODE_BY_NAME, serialized.name) ||\n\t\t(CODE_BY_NAME as Record<string, string>)[serialized.name] === serialized.code\n\t);\n}\n\n/**\n * Rebuild a serialized GitHub Copilot error as its own class. An unknown name becomes the family base with the\n * original name, code, message, hint and retryability kept. Returns undefined for anything that is not a serialized\n * GitHub Copilot error: a code this version does not know, a class name that does not go with its code, or a reason\n * that class does not have.\n */\nexport function deserializeGitHubCopilotError(value: unknown): GitHubCopilotError | undefined {\n\tif (!isSerializedError(value) || !agreesWithClass(value)) return undefined;\n\tconst cause = rehydrateCause(value.cause);\n\tconst fields = value.fields;\n\tconst context = contextFromFields(fields);\n\tswitch (value.name) {\n\t\tcase \"GitHubCopilotModelUnavailableError\": {\n\t\t\tconst reason = reasonField(fields, MODEL_UNAVAILABLE_REASONS, \"not-supported\");\n\t\t\treturn reason === undefined ? undefined : new GitHubCopilotModelUnavailableError(reason, context, { cause });\n\t\t}\n\t\tcase \"GitHubCopilotRateLimitError\":\n\t\t\treturn new GitHubCopilotRateLimitError(context, numberField(fields, \"retryAfterMs\"), { cause });\n\t\tcase \"GitHubCopilotQuotaExhaustedError\":\n\t\t\treturn new GitHubCopilotQuotaExhaustedError(context, { cause });\n\t\tcase \"GitHubCopilotContentFilterError\":\n\t\t\treturn new GitHubCopilotContentFilterError(context, { cause });\n\t\tcase \"GitHubCopilotPromptTooLargeError\":\n\t\t\treturn new GitHubCopilotPromptTooLargeError(\n\t\t\t\tcontext,\n\t\t\t\t{ promptTokens: numberField(fields, \"promptTokens\"), limitTokens: numberField(fields, \"limitTokens\") },\n\t\t\t\t{ cause },\n\t\t\t);\n\t\tcase \"GitHubCopilotInvalidRequestError\": {\n\t\t\tconst reason = reasonField(fields, INVALID_REQUEST_REASONS, \"rejected\");\n\t\t\treturn reason === undefined ? undefined : new GitHubCopilotInvalidRequestError(reason, context, { cause });\n\t\t}\n\t\tcase \"GitHubCopilotAuthenticationError\":\n\t\t\treturn new GitHubCopilotAuthenticationError(context, { cause });\n\t\tcase \"GitHubCopilotServiceUnavailableError\":\n\t\t\treturn new GitHubCopilotServiceUnavailableError(context, { cause });\n\t\tcase \"GitHubCopilotStreamEndedEarlyError\":\n\t\t\treturn new GitHubCopilotStreamEndedEarlyError(context, { cause });\n\t\tcase \"GitHubCopilotEmptyResponseError\":\n\t\t\treturn new GitHubCopilotEmptyResponseError(context, { cause });\n\t\tcase \"GitHubCopilotUnrecognizedResponseError\": {\n\t\t\tconst reason = reasonField(fields, UNRECOGNIZED_REASONS, \"malformed-body\");\n\t\t\treturn reason === undefined\n\t\t\t\t? undefined\n\t\t\t\t: new GitHubCopilotUnrecognizedResponseError(reason, context, { cause });\n\t\t}\n\t\tdefault: {\n\t\t\tconst base = new GitHubCopilotError(value.code, context, { hint: value.hint, cause });\n\t\t\tObject.defineProperties(base, {\n\t\t\t\tname: { value: value.name },\n\t\t\t\tmessage: { value: value.message },\n\t\t\t\tretryable: { value: value.retryable },\n\t\t\t});\n\t\t\treturn base;\n\t\t}\n\t}\n}\n\n/** Record `error` on a failed assistant message: its diagnostics carry the typed error across processes. */\nexport function recordGitHubCopilotError(\n\toutput: AssistantMessage,\n\terror: GitHubCopilotError,\n\tproviderText?: string,\n): void {\n\toutput.errorMessage =\n\t\tproviderText === undefined || providerText === error.message\n\t\t\t? error.message\n\t\t\t: `${error.message}\\n\\n${providerText}`;\n\tif (error instanceof GitHubCopilotRateLimitError && error.retryAfterMs !== undefined) {\n\t\toutput.retryAfterMs = error.retryAfterMs;\n\t}\n\tappendAssistantMessageDiagnostic(output, {\n\t\ttype: GITHUB_COPILOT_ERROR_DIAGNOSTIC,\n\t\ttimestamp: Date.now(),\n\t\terror: { name: error.name, message: error.message, code: error.code },\n\t\tdetails: JSON.parse(JSON.stringify(serializeGitHubCopilotError(error))) as JsonObject,\n\t});\n}\n\n/**\n * The GitHub Copilot error an assistant message's diagnostics carry, rebuilt as its class: the latest valid one.\n * Accepts a message read back from JSON, whose diagnostics are validated here.\n */\nexport function getGitHubCopilotError(\n\tmessage: { readonly diagnostics?: unknown } | undefined,\n): GitHubCopilotError | undefined {\n\tconst diagnostics = message?.diagnostics;\n\tif (!Array.isArray(diagnostics)) return undefined;\n\tfor (const entry of [...diagnostics].reverse()) {\n\t\tconst diagnostic = structural(entry) as Partial<AssistantMessageDiagnostic> | undefined;\n\t\tif (diagnostic?.type !== GITHUB_COPILOT_ERROR_DIAGNOSTIC) continue;\n\t\tconst error = deserializeGitHubCopilotError(diagnostic.details);\n\t\tif (error !== undefined) return error;\n\t}\n\treturn undefined;\n}\n\nfunction truncate(text: string): string {\n\treturn text.length <= MAX_DETAIL_CHARS ? text : `${text.slice(0, MAX_DETAIL_CHARS)}…`;\n}\n\nfunction nonEmptyString(value: unknown): string | undefined {\n\treturn typeof value === \"string\" && value.trim().length > 0 ? value.trim() : undefined;\n}\n\ntype ProviderFailure = Error & {\n\tstatus?: unknown;\n\tcode?: unknown;\n\ttype?: unknown;\n\terror?: unknown;\n\trequestID?: unknown;\n\trequest_id?: unknown;\n\theaders?: unknown;\n};\n\n/**\n * The error that holds the provider's response. When the retry helper gave up on a server-requested delay above its\n * cap, it threw a wrapper that keeps only `status` and `retryAfterMs` and holds the original response error as its\n * `cause`: no code, body or headers of its own. The response is then that cause. Any other error is its own response.\n */\nfunction responseOf(error: ProviderFailure): ProviderFailure {\n\tconst origin = error.cause;\n\tconst wrapsResponse =\n\t\terror.code === undefined &&\n\t\terror.error === undefined &&\n\t\terror.headers === undefined &&\n\t\torigin instanceof Error &&\n\t\ttypeof (origin as ProviderFailure).status === \"number\";\n\treturn wrapsResponse ? (origin as ProviderFailure) : error;\n}\n\n/** The SDK's request ID, else Copilot's `x-request-id` header, which the Anthropic SDK does not read. */\nfunction requestIdOf(error: ProviderFailure): string | undefined {\n\tconst headers = error.headers;\n\tconst header = headers instanceof Headers ? headers.get(\"x-request-id\") : undefined;\n\treturn nonEmptyString(error.requestID) ?? nonEmptyString(error.request_id) ?? nonEmptyString(header);\n}\n\n/**\n * The provider's code: the SDK's `code`, then the parsed body's `error.code` or `code`. A Messages `error` event\n * arrives with no HTTP status and names its failure only by `type`, so that type is its code.\n */\nfunction providerCodeOf(error: ProviderFailure): string | undefined {\n\tconst body = structural(error.error) as { code?: unknown; error?: unknown } | undefined;\n\treturn (\n\t\tnonEmptyString(error.code) ??\n\t\tnonEmptyString((structural(body?.error) as { code?: unknown } | undefined)?.code) ??\n\t\tnonEmptyString(body?.code) ??\n\t\t(error.status === undefined && error.error !== undefined ? nonEmptyString(error.type) : undefined)\n\t);\n}\n\n/** The provider's error text: the parsed body's message, else the SDK message without its status prefix. */\nfunction providerDetailOf(error: ProviderFailure, status: number | undefined): string | undefined {\n\tconst body = structural(error.error) as { message?: unknown; error?: unknown } | undefined;\n\tconst bodyMessage =\n\t\tnonEmptyString((structural(body?.error) as { message?: unknown } | undefined)?.message) ??\n\t\tnonEmptyString(body?.message);\n\tif (bodyMessage !== undefined) return truncate(bodyMessage);\n\tif (typeof error.error === \"string\") {\n\t\tconst text = nonEmptyString(error.error);\n\t\treturn text === undefined ? undefined : truncate(text);\n\t}\n\tconst message =\n\t\tstatus !== undefined && error.message.startsWith(`${status} `)\n\t\t\t? error.message.slice(`${status} `.length)\n\t\t\t: error.message;\n\tconst text = nonEmptyString(message);\n\treturn text === undefined ? undefined : truncate(text);\n}\n\n/** Provider codes Copilot sends, observed live or documented publicly, and the failure each one means. */\nconst PROVIDER_CODE_FAILURES: Readonly<\n\tRecord<string, (context: GitHubCopilotErrorContext, error: ProviderFailure) => GitHubCopilotError>\n> = {\n\tmodel_not_available_for_integrator: (context, cause) =>\n\t\tnew GitHubCopilotModelUnavailableError(\"integration\", context, { cause }),\n\tmodel_not_supported: (context, cause) => new GitHubCopilotModelUnavailableError(\"not-supported\", context, { cause }),\n\tunsupported_api_for_model: (context, cause) =>\n\t\tnew GitHubCopilotModelUnavailableError(\"wrong-api\", context, { cause }),\n\tmodel_max_prompt_tokens_exceeded: (context, cause) => promptTooLarge(context, cause),\n\tcontext_length_exceeded: (context, cause) => promptTooLarge(context, cause),\n\tinvalid_reasoning_effort: (context, cause) =>\n\t\tnew GitHubCopilotInvalidRequestError(\"reasoning-effort\", context, { cause }),\n\tcontent_filter: (context, cause) => new GitHubCopilotContentFilterError(context, { cause }),\n\tcyber_policy: (context, cause) => new GitHubCopilotContentFilterError(context, { cause }),\n\trate_limit_exceeded: (context, cause) =>\n\t\tnew GitHubCopilotRateLimitError(context, getProviderRetryAfterMs(cause), { cause }),\n\tinsufficient_quota: (context, cause) => new GitHubCopilotQuotaExhaustedError(context, { cause }),\n\tquota_exceeded: (context, cause) => new GitHubCopilotQuotaExhaustedError(context, { cause }),\n\tserver_error: (context, cause) => new GitHubCopilotServiceUnavailableError(context, { cause }),\n\tinvalid_request_error: (context, cause) =>\n\t\tbadRequestTextFailure(undefined, context, cause) ??\n\t\tnew GitHubCopilotInvalidRequestError(\"rejected\", context, { cause }),\n\tauthentication_error: (context, cause) => new GitHubCopilotAuthenticationError(context, { cause }),\n\tpermission_error: (context, cause) => new GitHubCopilotAuthenticationError(context, { cause }),\n\tbilling_error: (context, cause) => new GitHubCopilotQuotaExhaustedError(context, { cause }),\n\tnot_found_error: (context, cause) => new GitHubCopilotModelUnavailableError(\"not-found\", context, { cause }),\n\trequest_too_large: (context, cause) => promptTooLarge(context, cause),\n\trate_limit_error: (context, cause) =>\n\t\tnew GitHubCopilotRateLimitError(context, getProviderRetryAfterMs(cause), { cause }),\n\toverloaded_error: (context, cause) => new GitHubCopilotServiceUnavailableError(context, { cause }),\n\tapi_error: (context, cause) => new GitHubCopilotServiceUnavailableError(context, { cause }),\n\ttimeout_error: (context, cause) => new GitHubCopilotServiceUnavailableError(context, { cause }),\n};\n\nconst PROMPT_TOKENS_PATTERN = /prompt token count of (\\d+) exceeds the limit of (\\d+)/i;\n\nfunction promptTooLarge(context: GitHubCopilotErrorContext, cause: ProviderFailure): GitHubCopilotPromptTooLargeError {\n\tconst match = context.detail?.match(PROMPT_TOKENS_PATTERN);\n\treturn new GitHubCopilotPromptTooLargeError(\n\t\tcontext,\n\t\tmatch ? { promptTokens: Number(match[1]), limitTokens: Number(match[2]) } : undefined,\n\t\t{ cause },\n\t);\n}\n\n/**\n * Plain-text 400 bodies Copilot sends without a JSON code, observed live. Each is matched in full at the boundary so\n * the rest of Atomic branches on the typed code instead of on this text.\n */\nfunction plainTextFailure(\n\tdetail: string | undefined,\n\tcontext: GitHubCopilotErrorContext,\n\tcause: ProviderFailure,\n): GitHubCopilotError | undefined {\n\tconst text = detail?.toLowerCase();\n\tif (text === \"no model endpoints available given user constraints\") {\n\t\treturn new GitHubCopilotModelUnavailableError(\"no-endpoint\", context, { cause });\n\t}\n\tif (text === \"bad request: unknown copilot-integration-id\") {\n\t\treturn new GitHubCopilotInvalidRequestError(\"integration-id\", context, { cause });\n\t}\n\treturn undefined;\n}\n\n/**\n * Copilot sends a used-up monthly quota as HTTP 429 with `x-ratelimit-exceeded: quota_exceeded` and the plain body\n * `quota exceeded` (seen in public reports), unlike a short rate limit.\n */\nfunction reportsExhaustedQuota(response: ProviderFailure): boolean {\n\tconst exceeded = response.headers instanceof Headers ? response.headers.get(\"x-ratelimit-exceeded\") : null;\n\treturn (\n\t\texceeded?.trim().toLowerCase() === \"quota_exceeded\" ||\n\t\tproviderDetailOf(response, 429)?.toLowerCase() === \"quota exceeded\"\n\t);\n}\n\n/**\n * A 400 whose code Atomic does not recognize: Copilot's own prompt-token overflow text means the prompt is too large,\n * whatever the code; without a code, the exact plain-text bodies Copilot sends are matched.\n */\nfunction badRequestTextFailure(\n\tproviderCode: string | undefined,\n\tcontext: GitHubCopilotErrorContext,\n\tcause: ProviderFailure,\n): GitHubCopilotError | undefined {\n\tif (context.detail?.match(PROMPT_TOKENS_PATTERN)) return promptTooLarge(context, cause);\n\treturn providerCode === undefined ? plainTextFailure(context.detail, context, cause) : undefined;\n}\n\nfunction statusFailure(\n\tstatus: number,\n\tcontext: GitHubCopilotErrorContext,\n\tcause: ProviderFailure,\n\treportsQuota: boolean,\n): GitHubCopilotError {\n\tswitch (status) {\n\t\tcase 401:\n\t\tcase 403:\n\t\t\treturn new GitHubCopilotAuthenticationError(context, { cause });\n\t\tcase 402:\n\t\t\treturn new GitHubCopilotQuotaExhaustedError(context, { cause });\n\t\tcase 404:\n\t\t\treturn new GitHubCopilotModelUnavailableError(\"not-found\", context, { cause });\n\t\tcase 408:\n\t\t\treturn new GitHubCopilotServiceUnavailableError(context, { cause });\n\t\tcase 413:\n\t\t\treturn promptTooLarge(context, cause);\n\t\tcase 429:\n\t\t\treturn reportsQuota\n\t\t\t\t? new GitHubCopilotQuotaExhaustedError(context, { cause })\n\t\t\t\t: new GitHubCopilotRateLimitError(context, getProviderRetryAfterMs(cause), { cause });\n\t}\n\tif (status >= 500 && status <= 599) return new GitHubCopilotServiceUnavailableError(context, { cause });\n\tif (status >= 400 && status <= 499) return new GitHubCopilotInvalidRequestError(\"rejected\", context, { cause });\n\treturn new GitHubCopilotUnrecognizedResponseError(\"unknown-status\", context, { cause });\n}\n\n/** Where a Copilot request was when it failed. */\nexport interface GitHubCopilotFailureContext {\n\treadonly modelId: string;\n\treadonly api: string;\n\t/** True once Copilot answered with HTTP success and the response stream started. */\n\treadonly streamStarted: boolean;\n\t/** The provider's raw finish or stop reason, when the stream reported one. */\n\treadonly finishReason?: string;\n}\n\n/**\n * The stop reasons each API reports when a content or safety filter ended the response. Responses also records a\n * plain `refusal` for a refusal delta that does not end the turn, so each API has its own set.\n */\nconst CONTENT_FILTER_STOPS: Readonly<Record<string, ReadonlySet<string | undefined>>> = {\n\t\"openai-completions\": new Set([\"content_filter\"]),\n\t\"openai-responses\": new Set([\"incomplete.content_filter\"]),\n\t\"anthropic-messages\": new Set([\"refusal\", \"sensitive\"]),\n};\n\n/**\n * Translate a failed Copilot request into its typed error, once, at the provider boundary.\n *\n * HTTP failures are classified by the provider's code first, then on a 400 by Copilot's prompt-token overflow text\n * and the exact plain-text bodies it sends without a code, then by status (a 429 that reports a used-up quota is\n * `quota-exhausted`). A failure after the stream started is a content-filter stop for its API, an in-stream error\n * event, a malformed body, or a stream that ended early. Returns undefined for a failure that never reached Copilot (a\n * connection error before any response), which keeps Atomic's generic network handling. Never call it for a\n * cancelled request: cancellation is not a failure.\n */\nexport function classifyGitHubCopilotFailure(\n\terror: unknown,\n\tfailure: GitHubCopilotFailureContext,\n): GitHubCopilotError | undefined {\n\tconst typed = findGitHubCopilotError(error);\n\tif (typed !== undefined) return typed;\n\tconst providerError: ProviderFailure =\n\t\terror instanceof Error ? (error as ProviderFailure) : new Error(String(error), { cause: error });\n\tconst response = responseOf(providerError);\n\tconst status = typeof providerError.status === \"number\" ? providerError.status : undefined;\n\tconst providerCode = providerCodeOf(response);\n\tconst context: GitHubCopilotErrorContext = {\n\t\tmodelId: failure.modelId,\n\t\tapi: failure.api,\n\t\tstatus,\n\t\tproviderCode,\n\t\trequestId: requestIdOf(response),\n\t\tdetail: providerDetailOf(response, typeof response.status === \"number\" ? response.status : undefined),\n\t};\n\tconst codeFailure = providerCode === undefined ? undefined : PROVIDER_CODE_FAILURES[providerCode.toLowerCase()];\n\tif (codeFailure !== undefined) return codeFailure(context, providerError);\n\tif (status !== undefined) {\n\t\treturn (\n\t\t\t(status === 400 ? badRequestTextFailure(providerCode, context, providerError) : undefined) ??\n\t\t\tstatusFailure(status, context, providerError, reportsExhaustedQuota(response))\n\t\t);\n\t}\n\tif (CONTENT_FILTER_STOPS[failure.api]?.has(failure.finishReason)) {\n\t\treturn new GitHubCopilotContentFilterError(context, { cause: providerError });\n\t}\n\tif (providerCode !== undefined) {\n\t\treturn new GitHubCopilotUnrecognizedResponseError(\"unknown-error-event\", context, { cause: providerError });\n\t}\n\tif (providerError instanceof SyntaxError || providerError.error !== undefined) {\n\t\treturn new GitHubCopilotUnrecognizedResponseError(\"malformed-body\", context, { cause: providerError });\n\t}\n\treturn failure.streamStarted ? new GitHubCopilotStreamEndedEarlyError(context, { cause: providerError }) : undefined;\n}\n\n/**\n * Type a failed Copilot assistant message at the provider boundary: classify `error` and record it on `output`,\n * keeping the provider's text after the typed message. A cancelled message is left alone.\n */\nexport function recordGitHubCopilotFailure(output: AssistantMessage, error: unknown, streamStarted: boolean): void {\n\tif (output.stopReason !== \"error\") return;\n\tconst typed = classifyGitHubCopilotFailure(error, {\n\t\tmodelId: output.model,\n\t\tapi: output.api,\n\t\tstreamStarted,\n\t\tfinishReason: output.rawStopReason,\n\t});\n\tif (typed !== undefined) recordGitHubCopilotError(output, typed, output.errorMessage);\n}\n\n/**\n * The typed failure for a completed Copilot turn that has no text and no tool call, as Copilot's Gemini models\n * sometimes return; undefined for any other turn. A length stop is left to the caller's length handling.\n */\nexport function githubCopilotEmptyResponse(output: AssistantMessage): GitHubCopilotEmptyResponseError | undefined {\n\tif (output.provider !== \"github-copilot\" || (output.stopReason !== \"stop\" && output.stopReason !== \"toolUse\")) {\n\t\treturn undefined;\n\t}\n\tconst answered = output.content.some(\n\t\t(block) => block.type === \"toolCall\" || (block.type === \"text\" && block.text.trim().length > 0),\n\t);\n\treturn answered ? undefined : new GitHubCopilotEmptyResponseError({ modelId: output.model, api: output.api });\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Provider, type RefreshModelsContext } from "../models.ts";
|
|
2
2
|
import type { AnyModel, Api, Model } from "../types.ts";
|
|
3
|
-
type GitHubCopilotApi
|
|
3
|
+
import type { GitHubCopilotApi } from "./github-copilot-capabilities.ts";
|
|
4
4
|
/**
|
|
5
5
|
* Turn a GitHub Copilot `GET /models` response into the chat models the catalog lacks, in the
|
|
6
6
|
* order the account lists them.
|
|
@@ -29,5 +29,4 @@ export declare function parseGitHubCopilotDiscoveredModels(raw: unknown, catalog
|
|
|
29
29
|
*/
|
|
30
30
|
export declare function discoverGitHubCopilotModels(catalog: readonly AnyModel[], context: RefreshModelsContext): Promise<Model<Api>[] | undefined>;
|
|
31
31
|
export declare function githubCopilotProvider(): Provider<GitHubCopilotApi>;
|
|
32
|
-
export {};
|
|
33
32
|
//# sourceMappingURL=github-copilot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-copilot.d.ts","sourceRoot":"","sources":["../../src/providers/github-copilot.ts"],"names":[],"mappings":"AAaA,OAAO,EAAkB,KAAK,QAAQ,EAAE,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAsB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"github-copilot.d.ts","sourceRoot":"","sources":["../../src/providers/github-copilot.ts"],"names":[],"mappings":"AAaA,OAAO,EAAkB,KAAK,QAAQ,EAAE,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAsB,MAAM,aAAa,CAAC;AAQ5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAwKzE;;;;;;;;;;;;GAYG;AACH,wBAAgB,kCAAkC,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,QAAQ,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,EAAE,CAsB3G;AAqCD;;;;;;;;;;;GAWG;AACH,wBAAsB,2BAA2B,CAChD,OAAO,EAAE,SAAS,QAAQ,EAAE,EAC5B,OAAO,EAAE,oBAAoB,GAC3B,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,SAAS,CAAC,CAkBnC;AAwBD,wBAAgB,qBAAqB,IAAI,QAAQ,CAAC,gBAAgB,CAAC,CA4ClE"}
|
|
@@ -15,6 +15,8 @@ const GITHUB_COPILOT_MODELS_TIMEOUT_MS = 15_000;
|
|
|
15
15
|
const GITHUB_COPILOT_FAST_ID_SUFFIX = "-fast";
|
|
16
16
|
const DEFAULT_CONTEXT_WINDOW = 128_000;
|
|
17
17
|
const DEFAULT_MAX_TOKENS = 8_192;
|
|
18
|
+
/** Atomic's default cap on a resized image's base64 payload, which an account's own image limit may lower. */
|
|
19
|
+
const DEFAULT_MAX_IMAGE_BASE64_BYTES = 4.5 * 1024 * 1024;
|
|
18
20
|
/** Copilot advertises entitlements as string ID arrays on the OAuth credential; ignore any other shape. */
|
|
19
21
|
function advertisedModelIds(value) {
|
|
20
22
|
if (!Array.isArray(value) || !value.every((entry) => typeof entry === "string"))
|
|
@@ -86,22 +88,42 @@ function accountModelEntries(raw) {
|
|
|
86
88
|
}
|
|
87
89
|
/**
|
|
88
90
|
* The account's list does not say which models accept a 24-hour prompt cache, and some models reject
|
|
89
|
-
* the request, so a discovered OpenAI-style model never asks for one.
|
|
90
|
-
*
|
|
91
|
+
* the request, so a discovered OpenAI-style model never asks for one. Its tool schemas are strict only
|
|
92
|
+
* when the entry lists `structured_outputs`. A Messages model the list marks as adaptive receives the
|
|
93
|
+
* selected effort instead of a thinking budget.
|
|
91
94
|
*/
|
|
92
95
|
function discoveredCompat(api, reasoning, supports) {
|
|
96
|
+
const supportsStrictMode = supports?.structured_outputs === true;
|
|
93
97
|
if (api === "openai-completions") {
|
|
94
98
|
return {
|
|
95
99
|
supportsStore: false,
|
|
96
100
|
supportsDeveloperRole: false,
|
|
97
101
|
supportsReasoningEffort: reasoning,
|
|
98
102
|
supportsLongCacheRetention: false,
|
|
103
|
+
supportsStrictMode,
|
|
99
104
|
};
|
|
100
105
|
}
|
|
101
106
|
if (api === "anthropic-messages") {
|
|
102
107
|
return supports?.adaptive_thinking === true ? { forceAdaptiveThinking: true } : undefined;
|
|
103
108
|
}
|
|
104
|
-
return { supportsLongCacheRetention: false };
|
|
109
|
+
return { supportsLongCacheRetention: false, supportsStrictMode };
|
|
110
|
+
}
|
|
111
|
+
/** Image limits from the entry's `limits.vision`: images per request, and a resize cap from the per-image byte limit. */
|
|
112
|
+
function discoveredImageLimits(limits) {
|
|
113
|
+
const vision = asRecord(limits?.vision);
|
|
114
|
+
const maxPerRequest = positiveInteger(vision?.max_prompt_images);
|
|
115
|
+
const maxImageBytes = positiveInteger(vision?.max_prompt_image_size);
|
|
116
|
+
if (maxPerRequest === undefined && maxImageBytes === undefined)
|
|
117
|
+
return undefined;
|
|
118
|
+
const base64Bytes = maxImageBytes === undefined ? undefined : Math.ceil(maxImageBytes / 3) * 4;
|
|
119
|
+
return {
|
|
120
|
+
images: {
|
|
121
|
+
...(maxPerRequest === undefined ? {} : { maxPerRequest }),
|
|
122
|
+
...(base64Bytes === undefined
|
|
123
|
+
? {}
|
|
124
|
+
: { resize: { maxBytes: Math.min(base64Bytes, DEFAULT_MAX_IMAGE_BASE64_BYTES) } }),
|
|
125
|
+
},
|
|
126
|
+
};
|
|
105
127
|
}
|
|
106
128
|
/** The display name the account's entry advertises, or its ID when the entry has no usable one. */
|
|
107
129
|
function discoveredName(entry) {
|
|
@@ -119,6 +141,8 @@ function discoveredModel(entry) {
|
|
|
119
141
|
: [];
|
|
120
142
|
const reasoning = efforts.length > 0;
|
|
121
143
|
const compat = discoveredCompat(api, reasoning, entry.supports);
|
|
144
|
+
const vision = entry.supports?.vision === true;
|
|
145
|
+
const inputLimits = vision ? discoveredImageLimits(limits) : undefined;
|
|
122
146
|
return {
|
|
123
147
|
id: entry.id,
|
|
124
148
|
name: discoveredName(entry),
|
|
@@ -127,7 +151,8 @@ function discoveredModel(entry) {
|
|
|
127
151
|
baseUrl: GITHUB_COPILOT_BASE_URL,
|
|
128
152
|
reasoning,
|
|
129
153
|
...(reasoning ? { thinkingLevelMap: thinkingLevelMap(efforts) } : {}),
|
|
130
|
-
input:
|
|
154
|
+
input: vision ? ["text", "image"] : ["text"],
|
|
155
|
+
...(inputLimits ? { inputLimits } : {}),
|
|
131
156
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
132
157
|
contextWindow: positiveInteger(limits?.max_context_window_tokens) ??
|
|
133
158
|
positiveInteger(limits?.max_prompt_tokens) ??
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-copilot.js","sourceRoot":"","sources":["../../src/providers/github-copilot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EACN,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,gCAAgC,GAChC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,OAAO,EAAE,cAAc,EAA4C,MAAM,cAAc,CAAC;AAExF,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,WAAW,E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AE,oBAAoB,EAAE;YAC5C,kBAAkB,EAAE,kBAAkB,EAAE;SACxC;QACD,WAAW,EAAE,EAAE,qBAAqB,EAAE,gBAAgB,CAAC,oBAAoB,EAAE,CAAC,EAAE;KAChF,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { anthropicMessagesApi } from \"../api/anthropic-messages.lazy.ts\";\nimport {\n\tCOPILOT_API_VERSION,\n\tCOPILOT_HEADERS,\n\tcopilotClientHeaders,\n\tpreserveCopilotIntegrationHeader,\n} from \"../api/github-copilot-headers.js\";\nimport { openAICompletionsApi } from \"../api/openai-completions.lazy.ts\";\nimport { openAIResponsesApi } from \"../api/openai-responses.lazy.ts\";\nimport { typesafeSystemOneApi } from \"../api/typesafe-system-one.lazy.js\";\nimport { envApiKeyAuth, lazyOAuth } from \"../auth/helpers.ts\";\nimport { loadGitHubCopilotOAuth } from \"../auth/oauth/load.ts\";\nimport type { OAuthCredential } from \"../auth/types.ts\";\nimport { createProvider, type Provider, type RefreshModelsContext } from \"../models.ts\";\nimport type { AnyModel, Api, Model, ProviderClassifier } from \"../types.ts\";\nimport { providerHeadersToRecord } from \"../utils/headers.js\";\nimport { isModelType } from \"../utils/model-operations.ts\";\nimport { GITHUB_COPILOT_CLASSIFIER_MODELS, GITHUB_COPILOT_MODELS } from \"./github-copilot.models.js\";\nimport {\n\tGITHUB_COPILOT_INDIVIDUAL_BASE_URL as GITHUB_COPILOT_BASE_URL,\n\tparseGitHubCopilotAccountModelLists,\n} from \"./github-copilot-account.ts\";\nimport { THINKING_LEVELS, type ThinkingLevelMap } from \"./model-schema.ts\";\n\nconst GITHUB_COPILOT_MODELS_TIMEOUT_MS = 15_000;\nconst GITHUB_COPILOT_FAST_ID_SUFFIX = \"-fast\";\nconst DEFAULT_CONTEXT_WINDOW = 128_000;\nconst DEFAULT_MAX_TOKENS = 8_192;\n\ntype GitHubCopilotApi = \"anthropic-messages\" | \"openai-completions\" | \"openai-responses\";\n\n/** Copilot advertises entitlements as string ID arrays on the OAuth credential; ignore any other shape. */\nfunction advertisedModelIds(value: unknown): ReadonlySet<string> | undefined {\n\tif (!Array.isArray(value) || !value.every((entry) => typeof entry === \"string\")) return undefined;\n\treturn new Set(value);\n}\n\n/** A login saved before Copilot model lists were stored, or whose list is malformed, must re-read it. */\nfunction lacksAccountModelList(credential: OAuthCredential): boolean {\n\treturn advertisedModelIds(credential.availableModelIds) === undefined;\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> | undefined {\n\treturn value && typeof value === \"object\" ? (value as Record<string, unknown>) : undefined;\n}\n\nfunction positiveInteger(value: unknown): number | undefined {\n\treturn typeof value === \"number\" && Number.isInteger(value) && value > 0 ? value : undefined;\n}\n\n/** Copilot prefers the Messages API, then Responses, then Chat Completions; an entry without a list uses Chat Completions. */\nfunction apiForEndpoints(endpoints: unknown): GitHubCopilotApi | undefined {\n\tif (endpoints === undefined) return \"openai-completions\";\n\tif (!Array.isArray(endpoints)) return undefined;\n\tif (endpoints.includes(\"/v1/messages\")) return \"anthropic-messages\";\n\tif (endpoints.includes(\"/responses\")) return \"openai-responses\";\n\tif (endpoints.includes(\"/chat/completions\")) return \"openai-completions\";\n\treturn undefined;\n}\n\nfunction thinkingLevelMap(efforts: readonly string[]): ThinkingLevelMap {\n\treturn Object.fromEntries([\n\t\t[\"off\", efforts.includes(\"none\") ? \"none\" : null],\n\t\t...THINKING_LEVELS.map((level) => [level, efforts.includes(level) ? level : null]),\n\t]);\n}\n\ninterface AccountModelEntry {\n\tid: string;\n\tfamily: string | undefined;\n\tpickerDisabled: boolean;\n\titem: Record<string, unknown>;\n\tcapabilities: Record<string, unknown> | undefined;\n\tsupports: Record<string, unknown> | undefined;\n}\n\nfunction accountModelEntries(raw: unknown): AccountModelEntry[] {\n\tconst data = asRecord(raw)?.data;\n\tif (!Array.isArray(data)) throw new Error(\"Invalid GitHub Copilot models response\");\n\tconst seen = new Set<string>();\n\treturn data.flatMap((rawItem): AccountModelEntry[] => {\n\t\tconst item = asRecord(rawItem);\n\t\tconst id = item?.id;\n\t\tif (!item || typeof id !== \"string\" || !id || seen.has(id)) return [];\n\t\tseen.add(id);\n\t\tconst capabilities = asRecord(item.capabilities);\n\t\tconst supports = asRecord(capabilities?.supports);\n\t\tconst type = capabilities?.type;\n\t\tif (type !== undefined && type !== \"chat\") return [];\n\t\tif (supports?.tool_calls !== true) return [];\n\t\tif (asRecord(item.policy)?.state === \"disabled\") return [];\n\t\tconst family = capabilities?.family;\n\t\treturn [\n\t\t\t{\n\t\t\t\tid,\n\t\t\t\tfamily: typeof family === \"string\" ? family : undefined,\n\t\t\t\tpickerDisabled: item.model_picker_enabled === false,\n\t\t\t\titem,\n\t\t\t\tcapabilities,\n\t\t\t\tsupports,\n\t\t\t},\n\t\t];\n\t});\n}\n\n/**\n * The account's list does not say which models accept a 24-hour prompt cache, and some models reject\n * the request, so a discovered OpenAI-style model never asks for one. A Messages model the list marks\n * as adaptive receives the selected effort instead of a thinking budget.\n */\nfunction discoveredCompat(\n\tapi: GitHubCopilotApi,\n\treasoning: boolean,\n\tsupports: Record<string, unknown> | undefined,\n): Model<Api>[\"compat\"] {\n\tif (api === \"openai-completions\") {\n\t\treturn {\n\t\t\tsupportsStore: false,\n\t\t\tsupportsDeveloperRole: false,\n\t\t\tsupportsReasoningEffort: reasoning,\n\t\t\tsupportsLongCacheRetention: false,\n\t\t};\n\t}\n\tif (api === \"anthropic-messages\") {\n\t\treturn supports?.adaptive_thinking === true ? { forceAdaptiveThinking: true } : undefined;\n\t}\n\treturn { supportsLongCacheRetention: false };\n}\n\n/** The display name the account's entry advertises, or its ID when the entry has no usable one. */\nfunction discoveredName(entry: AccountModelEntry): string {\n\tconst name = entry.item.name;\n\treturn typeof name === \"string\" && name.trim() ? name.trim() : entry.id;\n}\n\nfunction discoveredModel(entry: AccountModelEntry): Model<Api> | undefined {\n\tconst api = apiForEndpoints(entry.item.supported_endpoints);\n\tif (!api) return undefined;\n\tconst limits = asRecord(entry.capabilities?.limits);\n\tconst rawEfforts = entry.supports?.reasoning_effort;\n\tconst efforts = Array.isArray(rawEfforts)\n\t\t? rawEfforts.filter((effort): effort is string => typeof effort === \"string\")\n\t\t: [];\n\tconst reasoning = efforts.length > 0;\n\tconst compat = discoveredCompat(api, reasoning, entry.supports);\n\treturn {\n\t\tid: entry.id,\n\t\tname: discoveredName(entry),\n\t\tapi,\n\t\tprovider: \"github-copilot\",\n\t\tbaseUrl: GITHUB_COPILOT_BASE_URL,\n\t\treasoning,\n\t\t...(reasoning ? { thinkingLevelMap: thinkingLevelMap(efforts) } : {}),\n\t\tinput: entry.supports?.vision === true ? [\"text\", \"image\"] : [\"text\"],\n\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },\n\t\tcontextWindow:\n\t\t\tpositiveInteger(limits?.max_context_window_tokens) ??\n\t\t\tpositiveInteger(limits?.max_prompt_tokens) ??\n\t\t\tDEFAULT_CONTEXT_WINDOW,\n\t\tmaxTokens: positiveInteger(limits?.max_output_tokens) ?? DEFAULT_MAX_TOKENS,\n\t\theaders: { ...COPILOT_HEADERS },\n\t\t...(compat ? { compat } : {}),\n\t\tdiscovered: true,\n\t};\n}\n\n/**\n * Turn a GitHub Copilot `GET /models` response into the chat models the catalog lacks, in the\n * order the account lists them.\n *\n * Every model keeps the exact ID the account advertises, which is sent upstream unchanged, and takes\n * the entry's display name as its name, or its ID when the entry has none. An entry is skipped when it\n * is not a chat model, does not support tool calls, has a disabled policy, or is already in the\n * catalog, whose curated entry always wins. An ordinary entry is also skipped when the account hides\n * it from the model picker. A fast entry is offered\n * whenever the account lists it, as Copilot's fast entitlement does, and like every other entry is\n * described by its own row. It carries fast route metadata only when its `capabilities.family`\n * names another model in the catalog, which then becomes its base. Otherwise it is an ordinary model.\n */\nexport function parseGitHubCopilotDiscoveredModels(raw: unknown, catalog: readonly AnyModel[]): Model<Api>[] {\n\tconst known = new Set<string>();\n\tfor (const model of catalog) known.add(model.id);\n\tconst entries = accountModelEntries(raw).filter((entry) => !known.has(entry.id));\n\tconst ordinary = new Set<string>();\n\tconst models = new Map<string, Model<Api>>();\n\tfor (const entry of entries) {\n\t\tconst isFast = entry.id.endsWith(GITHUB_COPILOT_FAST_ID_SUFFIX);\n\t\tif (!isFast && entry.pickerDisabled) continue;\n\t\tconst model = discoveredModel(entry);\n\t\tif (!model) continue;\n\t\tmodels.set(entry.id, model);\n\t\tif (!isFast) ordinary.add(entry.id);\n\t}\n\treturn entries.flatMap((entry): Model<Api>[] => {\n\t\tconst model = models.get(entry.id);\n\t\tif (!model) return [];\n\t\tif (ordinary.has(entry.id)) return [model];\n\t\tconst baseId = entry.family !== entry.id ? entry.family : undefined;\n\t\tif (baseId === undefined || !(known.has(baseId) || ordinary.has(baseId))) return [model];\n\t\treturn [{ ...model, fastRoute: { baseModelId: baseId, upstreamModelId: entry.id } }];\n\t});\n}\n\nasync function accountModelListRequest(\n\tcontext: RefreshModelsContext,\n): Promise<{ token: string; baseUrl: string } | undefined> {\n\tconst credential = context.credential;\n\tif (credential?.type === \"oauth\") {\n\t\tconst auth = await (await loadGitHubCopilotOAuth()).toAuth(credential);\n\t\treturn auth.apiKey ? { token: auth.apiKey, baseUrl: auth.baseUrl ?? GITHUB_COPILOT_BASE_URL } : undefined;\n\t}\n\tif (credential?.type === \"api_key\" && credential.key) {\n\t\treturn { token: credential.key, baseUrl: context.baseUrl ?? GITHUB_COPILOT_BASE_URL };\n\t}\n\treturn undefined;\n}\n\n/** Whether a login's saved list names exactly these IDs. */\nfunction savesSameIds(saved: unknown, ids: readonly string[]): boolean {\n\tconst savedIds = advertisedModelIds(saved);\n\treturn savedIds !== undefined && savedIds.size === new Set(ids).size && ids.every((id) => savedIds.has(id));\n}\n\n/**\n * Save to an OAuth login the model lists it keeps, read from the account's list this refresh just\n * read with it. The login otherwise renews them only with its token, so a refresh with a still-valid\n * token could discover a model the login's older lists hide.\n */\nasync function saveLoginModelLists(context: RefreshModelsContext, raw: unknown, baseUrl: string): Promise<void> {\n\tif (context.credential?.type !== \"oauth\" || !context.updateCredential) return;\n\tconst { availableModelIds, fastModelIds } = parseGitHubCopilotAccountModelLists(raw, baseUrl);\n\tawait context.updateCredential((current) =>\n\t\tsavesSameIds(current.availableModelIds, availableModelIds) && savesSameIds(current.fastModelIds, fastModelIds)\n\t\t\t? undefined\n\t\t\t: { ...current, availableModelIds, fastModelIds },\n\t);\n}\n\n/**\n * Read the account's model list with the effective OAuth or API-key credential and return the chat\n * models `catalog` lacks (see {@link parseGitHubCopilotDiscoveredModels}). An OAuth login reads the\n * host its token names; an API key reads the provider's configured host, the one its requests use.\n *\n * Returns undefined when the list cannot be read: without a usable credential, or when the host\n * refuses the token (400, 401, 403 or 404). That is not an empty list, so a caller keeps the models it\n * found before. Other failures throw.\n *\n * An OAuth login's saved model lists, which decide what the login is offered, are renewed from the\n * same response through `context.updateCredential`, so what a refresh discovers is offered at once.\n */\nexport async function discoverGitHubCopilotModels(\n\tcatalog: readonly AnyModel[],\n\tcontext: RefreshModelsContext,\n): Promise<Model<Api>[] | undefined> {\n\tconst request = await accountModelListRequest(context);\n\tif (!request) return undefined;\n\tconst response = await fetch(`${request.baseUrl.replace(/\\/+$/, \"\")}/models`, {\n\t\theaders: {\n\t\t\tAccept: \"application/json\",\n\t\t\tAuthorization: `Bearer ${request.token}`,\n\t\t\t...copilotClientHeaders(request.token),\n\t\t\t\"X-GitHub-Api-Version\": COPILOT_API_VERSION,\n\t\t},\n\t\tsignal: AbortSignal.any([context.signal, AbortSignal.timeout(GITHUB_COPILOT_MODELS_TIMEOUT_MS)]),\n\t});\n\tif ([400, 401, 403, 404].includes(response.status)) return undefined;\n\tif (!response.ok) throw new Error(`GitHub Copilot model list request failed: ${response.status}`);\n\tconst raw: unknown = await response.json();\n\tconst models = parseGitHubCopilotDiscoveredModels(raw, catalog);\n\tawait saveLoginModelLists(context, raw, request.baseUrl);\n\treturn models;\n}\n\n/** Copilot's account endpoint has no version prefix, but System One requires it. */\nfunction copilotSystemOne(classifier: ProviderClassifier): ProviderClassifier {\n\treturn {\n\t\tclassify: (model, context, options) => {\n\t\t\tconst defaults = copilotClientHeaders(options?.apiKey ?? \"\");\n\t\t\tconst integration = { \"Copilot-Integration-Id\": defaults[\"Copilot-Integration-Id\"]! };\n\t\t\tconst headers = providerHeadersToRecord(defaults, model.headers, options?.headers);\n\t\t\treturn classifier.classify(\n\t\t\t\t{\n\t\t\t\t\t...model,\n\t\t\t\t\tbaseUrl: `${model.baseUrl.replace(/\\/+$/u, \"\")}/v1`,\n\t\t\t\t},\n\t\t\t\tcontext,\n\t\t\t\t{\n\t\t\t\t\t...options,\n\t\t\t\t\theaders: providerHeadersToRecord(headers, preserveCopilotIntegrationHeader(headers, integration)),\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t};\n}\n\nexport function githubCopilotProvider(): Provider<GitHubCopilotApi> {\n\treturn createProvider<GitHubCopilotApi>({\n\t\tid: \"github-copilot\",\n\t\tname: \"GitHub Copilot\",\n\t\tbaseUrl: GITHUB_COPILOT_BASE_URL,\n\t\tauth: {\n\t\t\tapiKey: envApiKeyAuth(\"GitHub Copilot token\", [\"COPILOT_GITHUB_TOKEN\"]),\n\t\t\toauth: lazyOAuth({\n\t\t\t\tname: \"GitHub Copilot\",\n\t\t\t\tisSubscription: true,\n\t\t\t\tneedsRefresh: lacksAccountModelList,\n\t\t\t\tload: loadGitHubCopilotOAuth,\n\t\t\t}),\n\t\t},\n\t\tmodels: [...Object.values(GITHUB_COPILOT_MODELS), ...Object.values(GITHUB_COPILOT_CLASSIFIER_MODELS)],\n\t\tfilterModels: (models, credential) => {\n\t\t\tconst oauth = credential?.type === \"oauth\" ? credential : undefined;\n\t\t\tconst entitledFastModelIds = advertisedModelIds(oauth?.fastModelIds);\n\t\t\tconst availableModelIds = advertisedModelIds(oauth?.availableModelIds);\n\t\t\treturn models.filter((model) => {\n\t\t\t\t// Picker entitlements list chat models, not classifiers.\n\t\t\t\tif (isModelType(model, \"classifier\")) return true;\n\t\t\t\t// The login's saved lists decide for every model, discovered ones included: discovered models are\n\t\t\t\t// cached per provider, not per login. A refresh that reads the account's list renews the lists of\n\t\t\t\t// the same login (see `discoverGitHubCopilotModels`), so they never predate what it found.\n\t\t\t\t// A fast ID the login lists is entitled whether or not it is a picker entry.\n\t\t\t\tif (entitledFastModelIds?.has(model.id) === true) return true;\n\t\t\t\t// Fast-ness comes from the explicit route metadata, never from the `-fast` suffix. A login that\n\t\t\t\t// lists its fast IDs offers only those; without such a list (an API key), the account's own\n\t\t\t\t// model list already decided which fast models exist.\n\t\t\t\tif (model.fastRoute !== undefined) return entitledFastModelIds === undefined;\n\t\t\t\t// A login without a stored model list (an older login) keeps the catalog so it is never left\n\t\t\t\t// with no models; `Models.refresh()` with network access re-reads the list once (see\n\t\t\t\t// `needsRefresh`), and the account list applies from then on.\n\t\t\t\treturn availableModelIds?.has(model.id) ?? true;\n\t\t\t});\n\t\t},\n\t\tapi: {\n\t\t\t\"anthropic-messages\": anthropicMessagesApi(),\n\t\t\t\"openai-completions\": openAICompletionsApi(),\n\t\t\t\"openai-responses\": openAIResponsesApi(),\n\t\t},\n\t\tclassifiers: { \"typesafe-system-one\": copilotSystemOne(typesafeSystemOneApi()) },\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"github-copilot.js","sourceRoot":"","sources":["../../src/providers/github-copilot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EACN,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,gCAAgC,GAChC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE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AAC,KAAK,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC;YACjD,CAAC,CAAC,CAAC;QACJ,CAAC;QACD,GAAG,EAAE;YACJ,oBAAoB,EAAE,oBAAoB,EAAE;YAC5C,oBAAoB,EAAE,oBAAoB,EAAE;YAC5C,kBAAkB,EAAE,kBAAkB,EAAE;SACxC;QACD,WAAW,EAAE,EAAE,qBAAqB,EAAE,gBAAgB,CAAC,oBAAoB,EAAE,CAAC,EAAE;KAChF,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { anthropicMessagesApi } from \"../api/anthropic-messages.lazy.ts\";\nimport {\n\tCOPILOT_API_VERSION,\n\tCOPILOT_HEADERS,\n\tcopilotClientHeaders,\n\tpreserveCopilotIntegrationHeader,\n} from \"../api/github-copilot-headers.js\";\nimport { openAICompletionsApi } from \"../api/openai-completions.lazy.ts\";\nimport { openAIResponsesApi } from \"../api/openai-responses.lazy.ts\";\nimport { typesafeSystemOneApi } from \"../api/typesafe-system-one.lazy.js\";\nimport { envApiKeyAuth, lazyOAuth } from \"../auth/helpers.ts\";\nimport { loadGitHubCopilotOAuth } from \"../auth/oauth/load.ts\";\nimport type { OAuthCredential } from \"../auth/types.ts\";\nimport { createProvider, type Provider, type RefreshModelsContext } from \"../models.ts\";\nimport type { AnyModel, Api, Model, ProviderClassifier } from \"../types.ts\";\nimport { providerHeadersToRecord } from \"../utils/headers.js\";\nimport { isModelType } from \"../utils/model-operations.ts\";\nimport { GITHUB_COPILOT_CLASSIFIER_MODELS, GITHUB_COPILOT_MODELS } from \"./github-copilot.models.js\";\nimport {\n\tGITHUB_COPILOT_INDIVIDUAL_BASE_URL as GITHUB_COPILOT_BASE_URL,\n\tparseGitHubCopilotAccountModelLists,\n} from \"./github-copilot-account.ts\";\nimport type { GitHubCopilotApi } from \"./github-copilot-capabilities.ts\";\nimport { THINKING_LEVELS, type ThinkingLevelMap } from \"./model-schema.ts\";\n\nconst GITHUB_COPILOT_MODELS_TIMEOUT_MS = 15_000;\nconst GITHUB_COPILOT_FAST_ID_SUFFIX = \"-fast\";\nconst DEFAULT_CONTEXT_WINDOW = 128_000;\nconst DEFAULT_MAX_TOKENS = 8_192;\n/** Atomic's default cap on a resized image's base64 payload, which an account's own image limit may lower. */\nconst DEFAULT_MAX_IMAGE_BASE64_BYTES = 4.5 * 1024 * 1024;\n\n/** Copilot advertises entitlements as string ID arrays on the OAuth credential; ignore any other shape. */\nfunction advertisedModelIds(value: unknown): ReadonlySet<string> | undefined {\n\tif (!Array.isArray(value) || !value.every((entry) => typeof entry === \"string\")) return undefined;\n\treturn new Set(value);\n}\n\n/** A login saved before Copilot model lists were stored, or whose list is malformed, must re-read it. */\nfunction lacksAccountModelList(credential: OAuthCredential): boolean {\n\treturn advertisedModelIds(credential.availableModelIds) === undefined;\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> | undefined {\n\treturn value && typeof value === \"object\" ? (value as Record<string, unknown>) : undefined;\n}\n\nfunction positiveInteger(value: unknown): number | undefined {\n\treturn typeof value === \"number\" && Number.isInteger(value) && value > 0 ? value : undefined;\n}\n\n/** Copilot prefers the Messages API, then Responses, then Chat Completions; an entry without a list uses Chat Completions. */\nfunction apiForEndpoints(endpoints: unknown): GitHubCopilotApi | undefined {\n\tif (endpoints === undefined) return \"openai-completions\";\n\tif (!Array.isArray(endpoints)) return undefined;\n\tif (endpoints.includes(\"/v1/messages\")) return \"anthropic-messages\";\n\tif (endpoints.includes(\"/responses\")) return \"openai-responses\";\n\tif (endpoints.includes(\"/chat/completions\")) return \"openai-completions\";\n\treturn undefined;\n}\n\nfunction thinkingLevelMap(efforts: readonly string[]): ThinkingLevelMap {\n\treturn Object.fromEntries([\n\t\t[\"off\", efforts.includes(\"none\") ? \"none\" : null],\n\t\t...THINKING_LEVELS.map((level) => [level, efforts.includes(level) ? level : null]),\n\t]);\n}\n\ninterface AccountModelEntry {\n\tid: string;\n\tfamily: string | undefined;\n\tpickerDisabled: boolean;\n\titem: Record<string, unknown>;\n\tcapabilities: Record<string, unknown> | undefined;\n\tsupports: Record<string, unknown> | undefined;\n}\n\nfunction accountModelEntries(raw: unknown): AccountModelEntry[] {\n\tconst data = asRecord(raw)?.data;\n\tif (!Array.isArray(data)) throw new Error(\"Invalid GitHub Copilot models response\");\n\tconst seen = new Set<string>();\n\treturn data.flatMap((rawItem): AccountModelEntry[] => {\n\t\tconst item = asRecord(rawItem);\n\t\tconst id = item?.id;\n\t\tif (!item || typeof id !== \"string\" || !id || seen.has(id)) return [];\n\t\tseen.add(id);\n\t\tconst capabilities = asRecord(item.capabilities);\n\t\tconst supports = asRecord(capabilities?.supports);\n\t\tconst type = capabilities?.type;\n\t\tif (type !== undefined && type !== \"chat\") return [];\n\t\tif (supports?.tool_calls !== true) return [];\n\t\tif (asRecord(item.policy)?.state === \"disabled\") return [];\n\t\tconst family = capabilities?.family;\n\t\treturn [\n\t\t\t{\n\t\t\t\tid,\n\t\t\t\tfamily: typeof family === \"string\" ? family : undefined,\n\t\t\t\tpickerDisabled: item.model_picker_enabled === false,\n\t\t\t\titem,\n\t\t\t\tcapabilities,\n\t\t\t\tsupports,\n\t\t\t},\n\t\t];\n\t});\n}\n\n/**\n * The account's list does not say which models accept a 24-hour prompt cache, and some models reject\n * the request, so a discovered OpenAI-style model never asks for one. Its tool schemas are strict only\n * when the entry lists `structured_outputs`. A Messages model the list marks as adaptive receives the\n * selected effort instead of a thinking budget.\n */\nfunction discoveredCompat(\n\tapi: GitHubCopilotApi,\n\treasoning: boolean,\n\tsupports: Record<string, unknown> | undefined,\n): Model<Api>[\"compat\"] {\n\tconst supportsStrictMode = supports?.structured_outputs === true;\n\tif (api === \"openai-completions\") {\n\t\treturn {\n\t\t\tsupportsStore: false,\n\t\t\tsupportsDeveloperRole: false,\n\t\t\tsupportsReasoningEffort: reasoning,\n\t\t\tsupportsLongCacheRetention: false,\n\t\t\tsupportsStrictMode,\n\t\t};\n\t}\n\tif (api === \"anthropic-messages\") {\n\t\treturn supports?.adaptive_thinking === true ? { forceAdaptiveThinking: true } : undefined;\n\t}\n\treturn { supportsLongCacheRetention: false, supportsStrictMode };\n}\n\n/** Image limits from the entry's `limits.vision`: images per request, and a resize cap from the per-image byte limit. */\nfunction discoveredImageLimits(limits: Record<string, unknown> | undefined): Model<Api>[\"inputLimits\"] {\n\tconst vision = asRecord(limits?.vision);\n\tconst maxPerRequest = positiveInteger(vision?.max_prompt_images);\n\tconst maxImageBytes = positiveInteger(vision?.max_prompt_image_size);\n\tif (maxPerRequest === undefined && maxImageBytes === undefined) return undefined;\n\tconst base64Bytes = maxImageBytes === undefined ? undefined : Math.ceil(maxImageBytes / 3) * 4;\n\treturn {\n\t\timages: {\n\t\t\t...(maxPerRequest === undefined ? {} : { maxPerRequest }),\n\t\t\t...(base64Bytes === undefined\n\t\t\t\t? {}\n\t\t\t\t: { resize: { maxBytes: Math.min(base64Bytes, DEFAULT_MAX_IMAGE_BASE64_BYTES) } }),\n\t\t},\n\t};\n}\n\n/** The display name the account's entry advertises, or its ID when the entry has no usable one. */\nfunction discoveredName(entry: AccountModelEntry): string {\n\tconst name = entry.item.name;\n\treturn typeof name === \"string\" && name.trim() ? name.trim() : entry.id;\n}\n\nfunction discoveredModel(entry: AccountModelEntry): Model<Api> | undefined {\n\tconst api = apiForEndpoints(entry.item.supported_endpoints);\n\tif (!api) return undefined;\n\tconst limits = asRecord(entry.capabilities?.limits);\n\tconst rawEfforts = entry.supports?.reasoning_effort;\n\tconst efforts = Array.isArray(rawEfforts)\n\t\t? rawEfforts.filter((effort): effort is string => typeof effort === \"string\")\n\t\t: [];\n\tconst reasoning = efforts.length > 0;\n\tconst compat = discoveredCompat(api, reasoning, entry.supports);\n\tconst vision = entry.supports?.vision === true;\n\tconst inputLimits = vision ? discoveredImageLimits(limits) : undefined;\n\treturn {\n\t\tid: entry.id,\n\t\tname: discoveredName(entry),\n\t\tapi,\n\t\tprovider: \"github-copilot\",\n\t\tbaseUrl: GITHUB_COPILOT_BASE_URL,\n\t\treasoning,\n\t\t...(reasoning ? { thinkingLevelMap: thinkingLevelMap(efforts) } : {}),\n\t\tinput: vision ? [\"text\", \"image\"] : [\"text\"],\n\t\t...(inputLimits ? { inputLimits } : {}),\n\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },\n\t\tcontextWindow:\n\t\t\tpositiveInteger(limits?.max_context_window_tokens) ??\n\t\t\tpositiveInteger(limits?.max_prompt_tokens) ??\n\t\t\tDEFAULT_CONTEXT_WINDOW,\n\t\tmaxTokens: positiveInteger(limits?.max_output_tokens) ?? DEFAULT_MAX_TOKENS,\n\t\theaders: { ...COPILOT_HEADERS },\n\t\t...(compat ? { compat } : {}),\n\t\tdiscovered: true,\n\t};\n}\n\n/**\n * Turn a GitHub Copilot `GET /models` response into the chat models the catalog lacks, in the\n * order the account lists them.\n *\n * Every model keeps the exact ID the account advertises, which is sent upstream unchanged, and takes\n * the entry's display name as its name, or its ID when the entry has none. An entry is skipped when it\n * is not a chat model, does not support tool calls, has a disabled policy, or is already in the\n * catalog, whose curated entry always wins. An ordinary entry is also skipped when the account hides\n * it from the model picker. A fast entry is offered\n * whenever the account lists it, as Copilot's fast entitlement does, and like every other entry is\n * described by its own row. It carries fast route metadata only when its `capabilities.family`\n * names another model in the catalog, which then becomes its base. Otherwise it is an ordinary model.\n */\nexport function parseGitHubCopilotDiscoveredModels(raw: unknown, catalog: readonly AnyModel[]): Model<Api>[] {\n\tconst known = new Set<string>();\n\tfor (const model of catalog) known.add(model.id);\n\tconst entries = accountModelEntries(raw).filter((entry) => !known.has(entry.id));\n\tconst ordinary = new Set<string>();\n\tconst models = new Map<string, Model<Api>>();\n\tfor (const entry of entries) {\n\t\tconst isFast = entry.id.endsWith(GITHUB_COPILOT_FAST_ID_SUFFIX);\n\t\tif (!isFast && entry.pickerDisabled) continue;\n\t\tconst model = discoveredModel(entry);\n\t\tif (!model) continue;\n\t\tmodels.set(entry.id, model);\n\t\tif (!isFast) ordinary.add(entry.id);\n\t}\n\treturn entries.flatMap((entry): Model<Api>[] => {\n\t\tconst model = models.get(entry.id);\n\t\tif (!model) return [];\n\t\tif (ordinary.has(entry.id)) return [model];\n\t\tconst baseId = entry.family !== entry.id ? entry.family : undefined;\n\t\tif (baseId === undefined || !(known.has(baseId) || ordinary.has(baseId))) return [model];\n\t\treturn [{ ...model, fastRoute: { baseModelId: baseId, upstreamModelId: entry.id } }];\n\t});\n}\n\nasync function accountModelListRequest(\n\tcontext: RefreshModelsContext,\n): Promise<{ token: string; baseUrl: string } | undefined> {\n\tconst credential = context.credential;\n\tif (credential?.type === \"oauth\") {\n\t\tconst auth = await (await loadGitHubCopilotOAuth()).toAuth(credential);\n\t\treturn auth.apiKey ? { token: auth.apiKey, baseUrl: auth.baseUrl ?? GITHUB_COPILOT_BASE_URL } : undefined;\n\t}\n\tif (credential?.type === \"api_key\" && credential.key) {\n\t\treturn { token: credential.key, baseUrl: context.baseUrl ?? GITHUB_COPILOT_BASE_URL };\n\t}\n\treturn undefined;\n}\n\n/** Whether a login's saved list names exactly these IDs. */\nfunction savesSameIds(saved: unknown, ids: readonly string[]): boolean {\n\tconst savedIds = advertisedModelIds(saved);\n\treturn savedIds !== undefined && savedIds.size === new Set(ids).size && ids.every((id) => savedIds.has(id));\n}\n\n/**\n * Save to an OAuth login the model lists it keeps, read from the account's list this refresh just\n * read with it. The login otherwise renews them only with its token, so a refresh with a still-valid\n * token could discover a model the login's older lists hide.\n */\nasync function saveLoginModelLists(context: RefreshModelsContext, raw: unknown, baseUrl: string): Promise<void> {\n\tif (context.credential?.type !== \"oauth\" || !context.updateCredential) return;\n\tconst { availableModelIds, fastModelIds } = parseGitHubCopilotAccountModelLists(raw, baseUrl);\n\tawait context.updateCredential((current) =>\n\t\tsavesSameIds(current.availableModelIds, availableModelIds) && savesSameIds(current.fastModelIds, fastModelIds)\n\t\t\t? undefined\n\t\t\t: { ...current, availableModelIds, fastModelIds },\n\t);\n}\n\n/**\n * Read the account's model list with the effective OAuth or API-key credential and return the chat\n * models `catalog` lacks (see {@link parseGitHubCopilotDiscoveredModels}). An OAuth login reads the\n * host its token names; an API key reads the provider's configured host, the one its requests use.\n *\n * Returns undefined when the list cannot be read: without a usable credential, or when the host\n * refuses the token (400, 401, 403 or 404). That is not an empty list, so a caller keeps the models it\n * found before. Other failures throw.\n *\n * An OAuth login's saved model lists, which decide what the login is offered, are renewed from the\n * same response through `context.updateCredential`, so what a refresh discovers is offered at once.\n */\nexport async function discoverGitHubCopilotModels(\n\tcatalog: readonly AnyModel[],\n\tcontext: RefreshModelsContext,\n): Promise<Model<Api>[] | undefined> {\n\tconst request = await accountModelListRequest(context);\n\tif (!request) return undefined;\n\tconst response = await fetch(`${request.baseUrl.replace(/\\/+$/, \"\")}/models`, {\n\t\theaders: {\n\t\t\tAccept: \"application/json\",\n\t\t\tAuthorization: `Bearer ${request.token}`,\n\t\t\t...copilotClientHeaders(request.token),\n\t\t\t\"X-GitHub-Api-Version\": COPILOT_API_VERSION,\n\t\t},\n\t\tsignal: AbortSignal.any([context.signal, AbortSignal.timeout(GITHUB_COPILOT_MODELS_TIMEOUT_MS)]),\n\t});\n\tif ([400, 401, 403, 404].includes(response.status)) return undefined;\n\tif (!response.ok) throw new Error(`GitHub Copilot model list request failed: ${response.status}`);\n\tconst raw: unknown = await response.json();\n\tconst models = parseGitHubCopilotDiscoveredModels(raw, catalog);\n\tawait saveLoginModelLists(context, raw, request.baseUrl);\n\treturn models;\n}\n\n/** Copilot's account endpoint has no version prefix, but System One requires it. */\nfunction copilotSystemOne(classifier: ProviderClassifier): ProviderClassifier {\n\treturn {\n\t\tclassify: (model, context, options) => {\n\t\t\tconst defaults = copilotClientHeaders(options?.apiKey ?? \"\");\n\t\t\tconst integration = { \"Copilot-Integration-Id\": defaults[\"Copilot-Integration-Id\"]! };\n\t\t\tconst headers = providerHeadersToRecord(defaults, model.headers, options?.headers);\n\t\t\treturn classifier.classify(\n\t\t\t\t{\n\t\t\t\t\t...model,\n\t\t\t\t\tbaseUrl: `${model.baseUrl.replace(/\\/+$/u, \"\")}/v1`,\n\t\t\t\t},\n\t\t\t\tcontext,\n\t\t\t\t{\n\t\t\t\t\t...options,\n\t\t\t\t\theaders: providerHeadersToRecord(headers, preserveCopilotIntegrationHeader(headers, integration)),\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t};\n}\n\nexport function githubCopilotProvider(): Provider<GitHubCopilotApi> {\n\treturn createProvider<GitHubCopilotApi>({\n\t\tid: \"github-copilot\",\n\t\tname: \"GitHub Copilot\",\n\t\tbaseUrl: GITHUB_COPILOT_BASE_URL,\n\t\tauth: {\n\t\t\tapiKey: envApiKeyAuth(\"GitHub Copilot token\", [\"COPILOT_GITHUB_TOKEN\"]),\n\t\t\toauth: lazyOAuth({\n\t\t\t\tname: \"GitHub Copilot\",\n\t\t\t\tisSubscription: true,\n\t\t\t\tneedsRefresh: lacksAccountModelList,\n\t\t\t\tload: loadGitHubCopilotOAuth,\n\t\t\t}),\n\t\t},\n\t\tmodels: [...Object.values(GITHUB_COPILOT_MODELS), ...Object.values(GITHUB_COPILOT_CLASSIFIER_MODELS)],\n\t\tfilterModels: (models, credential) => {\n\t\t\tconst oauth = credential?.type === \"oauth\" ? credential : undefined;\n\t\t\tconst entitledFastModelIds = advertisedModelIds(oauth?.fastModelIds);\n\t\t\tconst availableModelIds = advertisedModelIds(oauth?.availableModelIds);\n\t\t\treturn models.filter((model) => {\n\t\t\t\t// Picker entitlements list chat models, not classifiers.\n\t\t\t\tif (isModelType(model, \"classifier\")) return true;\n\t\t\t\t// The login's saved lists decide for every model, discovered ones included: discovered models are\n\t\t\t\t// cached per provider, not per login. A refresh that reads the account's list renews the lists of\n\t\t\t\t// the same login (see `discoverGitHubCopilotModels`), so they never predate what it found.\n\t\t\t\t// A fast ID the login lists is entitled whether or not it is a picker entry.\n\t\t\t\tif (entitledFastModelIds?.has(model.id) === true) return true;\n\t\t\t\t// Fast-ness comes from the explicit route metadata, never from the `-fast` suffix. A login that\n\t\t\t\t// lists its fast IDs offers only those; without such a list (an API key), the account's own\n\t\t\t\t// model list already decided which fast models exist.\n\t\t\t\tif (model.fastRoute !== undefined) return entitledFastModelIds === undefined;\n\t\t\t\t// A login without a stored model list (an older login) keeps the catalog so it is never left\n\t\t\t\t// with no models; `Models.refresh()` with network access re-reads the list once (see\n\t\t\t\t// `needsRefresh`), and the account list applies from then on.\n\t\t\t\treturn availableModelIds?.has(model.id) ?? true;\n\t\t\t});\n\t\t},\n\t\tapi: {\n\t\t\t\"anthropic-messages\": anthropicMessagesApi(),\n\t\t\t\"openai-completions\": openAICompletionsApi(),\n\t\t\t\"openai-responses\": openAIResponsesApi(),\n\t\t},\n\t\tclassifiers: { \"typesafe-system-one\": copilotSystemOne(typesafeSystemOneApi()) },\n\t});\n}\n"]}
|
|
@@ -7,7 +7,7 @@ import { openaiSubscriptionModels } from "./openai-subscription-models.js";
|
|
|
7
7
|
export function openaiCodexProvider() {
|
|
8
8
|
return createProvider({
|
|
9
9
|
id: "openai-codex",
|
|
10
|
-
name: "OpenAI Codex
|
|
10
|
+
name: "OpenAI Codex",
|
|
11
11
|
baseUrl: "https://chatgpt.com/backend-api",
|
|
12
12
|
auth: {
|
|
13
13
|
oauth: lazyOAuth({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-codex.js","sourceRoot":"","sources":["../../src/providers/openai-codex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAiB,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,MAAM,UAAU,mBAAmB;IAClC,OAAO,cAAc,CAAC;QACrB,EAAE,EAAE,cAAc;QAClB,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"openai-codex.js","sourceRoot":"","sources":["../../src/providers/openai-codex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAiB,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,MAAM,UAAU,mBAAmB;IAClC,OAAO,cAAc,CAAC;QACrB,EAAE,EAAE,cAAc;QAClB,IAAI,EAAE,cAAc;QACpB,OAAO,EAAE,iCAAiC;QAC1C,IAAI,EAAE;YACL,KAAK,EAAE,SAAS,CAAC;gBAChB,IAAI,EAAE,2BAA2B;gBACjC,kBAAkB,EAAE,IAAI;gBACxB,cAAc,EAAE,IAAI;gBACpB,IAAI,EAAE,oBAAoB;aAC1B,CAAC;SACF;QACD,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC;QAC1C,YAAY,EAAE,wBAAwB;QACtC,GAAG,EAAE,uBAAuB,EAAE;KAC9B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { openAICodexResponsesApi } from \"../api/openai-codex-responses.lazy.ts\";\nimport { lazyOAuth } from \"../auth/helpers.ts\";\nimport { loadOpenAICodexOAuth } from \"../auth/oauth/load.ts\";\nimport { createProvider, type Provider } from \"../models.ts\";\nimport { OPENAI_CODEX_MODELS } from \"./openai-codex.models.ts\";\nimport { openaiSubscriptionModels } from \"./openai-subscription-models.ts\";\n\nexport function openaiCodexProvider(): Provider<\"openai-codex-responses\"> {\n\treturn createProvider({\n\t\tid: \"openai-codex\",\n\t\tname: \"OpenAI Codex\",\n\t\tbaseUrl: \"https://chatgpt.com/backend-api\",\n\t\tauth: {\n\t\t\toauth: lazyOAuth({\n\t\t\t\tname: \"OpenAI (ChatGPT Plus/Pro)\",\n\t\t\t\tusesCallbackServer: true,\n\t\t\t\tisSubscription: true,\n\t\t\t\tload: loadOpenAICodexOAuth,\n\t\t\t}),\n\t\t},\n\t\tmodels: Object.values(OPENAI_CODEX_MODELS),\n\t\tfilterModels: openaiSubscriptionModels,\n\t\tapi: openAICodexResponsesApi(),\n\t});\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qwen-token-plan-individual-cn.d.ts","sourceRoot":"","sources":["../../src/providers/qwen-token-plan-individual-cn.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7D,wBAAgB,iCAAiC,IAAI,QAAQ,CAAC,oBAAoB,CAAC,CASlF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { openAICompletionsApi } from "../api/openai-completions.lazy.js";
|
|
2
|
+
import { envApiKeyAuth } from "../auth/helpers.js";
|
|
3
|
+
import { createProvider } from "../models.js";
|
|
4
|
+
import { QWEN_TOKEN_PLAN_INDIVIDUAL_CN_MODELS } from "./qwen-token-plan-individual-cn.models.js";
|
|
5
|
+
export function qwenTokenPlanIndividualCnProvider() {
|
|
6
|
+
return createProvider({
|
|
7
|
+
id: "qwen-token-plan-individual-cn",
|
|
8
|
+
name: "Qwen Token Plan Individual CN",
|
|
9
|
+
baseUrl: "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
|
|
10
|
+
auth: { apiKey: envApiKeyAuth("Qwen Token Plan Individual CN API key", ["QWEN_TOKEN_PLAN_CN_API_KEY"]) },
|
|
11
|
+
models: Object.values(QWEN_TOKEN_PLAN_INDIVIDUAL_CN_MODELS),
|
|
12
|
+
api: openAICompletionsApi(),
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=qwen-token-plan-individual-cn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qwen-token-plan-individual-cn.js","sourceRoot":"","sources":["../../src/providers/qwen-token-plan-individual-cn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAiB,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,oCAAoC,EAAE,MAAM,2CAA2C,CAAC;AAEjG,MAAM,UAAU,iCAAiC;IAChD,OAAO,cAAc,CAAC;QACrB,EAAE,EAAE,+BAA+B;QACnC,IAAI,EAAE,+BAA+B;QACrC,OAAO,EAAE,oEAAoE;QAC7E,IAAI,EAAE,EAAE,MAAM,EAAE,aAAa,CAAC,uCAAuC,EAAE,CAAC,4BAA4B,CAAC,CAAC,EAAE;QACxG,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,oCAAoC,CAAC;QAC3D,GAAG,EAAE,oBAAoB,EAAE;KAC3B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { openAICompletionsApi } from \"../api/openai-completions.lazy.ts\";\nimport { envApiKeyAuth } from \"../auth/helpers.ts\";\nimport { createProvider, type Provider } from \"../models.ts\";\nimport { QWEN_TOKEN_PLAN_INDIVIDUAL_CN_MODELS } from \"./qwen-token-plan-individual-cn.models.ts\";\n\nexport function qwenTokenPlanIndividualCnProvider(): Provider<\"openai-completions\"> {\n\treturn createProvider({\n\t\tid: \"qwen-token-plan-individual-cn\",\n\t\tname: \"Qwen Token Plan Individual CN\",\n\t\tbaseUrl: \"https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1\",\n\t\tauth: { apiKey: envApiKeyAuth(\"Qwen Token Plan Individual CN API key\", [\"QWEN_TOKEN_PLAN_CN_API_KEY\"]) },\n\t\tmodels: Object.values(QWEN_TOKEN_PLAN_INDIVIDUAL_CN_MODELS),\n\t\tapi: openAICompletionsApi(),\n\t});\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ChatModelCatalog, type ImageModelCatalog, type ClassifierModelCatalog } from "../model-catalog.ts";
|
|
2
|
+
export declare const QWEN_TOKEN_PLAN_INDIVIDUAL_CN_MODELS: ChatModelCatalog<typeof import("./data/qwen-token-plan-individual-cn.json", { with: { type: "json" } }), "qwen-token-plan-individual-cn">;
|
|
3
|
+
export declare const QWEN_TOKEN_PLAN_INDIVIDUAL_CN_IMAGE_MODELS: ImageModelCatalog<typeof import("./data/qwen-token-plan-individual-cn.json", { with: { type: "json" } }), "qwen-token-plan-individual-cn">;
|
|
4
|
+
export declare const QWEN_TOKEN_PLAN_INDIVIDUAL_CN_CLASSIFIER_MODELS: ClassifierModelCatalog<typeof import("./data/qwen-token-plan-individual-cn.json", { with: { type: "json" } }), "qwen-token-plan-individual-cn">;
|
|
5
|
+
//# sourceMappingURL=qwen-token-plan-individual-cn.models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qwen-token-plan-individual-cn.models.d.ts","sourceRoot":"","sources":["../../src/providers/qwen-token-plan-individual-cn.models.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoF,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAEnM,eAAO,MAAM,oCAAoC,EAAE,gBAAgB,CAAC,cAAc,2CAA2C,EAAU,UAAE,IAAI,EAAE,MAAM,IAAE,CAAG,EAAE,+BAA+B,CAC1H,CAAC;AAElE,eAAO,MAAM,0CAA0C,EAAE,iBAAiB,CAAC,cAAc,2CAA2C,EAAU,UAAE,IAAI,EAAE,MAAM,IAAE,CAAG,EAAE,+BAA+B,CAChI,CAAC;AAEnE,eAAO,MAAM,+CAA+C,EAAE,sBAAsB,CAAC,cAAc,2CAA2C,EAAU,UAAE,IAAI,EAAE,MAAM,IAAE,CAAG,EAAE,+BAA+B,CACrI,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// This file is auto-generated by scripts/generate-models.ts
|
|
2
|
+
// Do not edit manually - run 'npm run generate-models' to update
|
|
3
|
+
import values from "./data/qwen-token-plan-individual-cn.json" with { type: "json" };
|
|
4
|
+
import { flattenChatModelCatalog, flattenImageModelCatalog, flattenClassifierModelCatalog } from "../model-catalog.js";
|
|
5
|
+
export const QWEN_TOKEN_PLAN_INDIVIDUAL_CN_MODELS = flattenChatModelCatalog("qwen-token-plan-individual-cn", values);
|
|
6
|
+
export const QWEN_TOKEN_PLAN_INDIVIDUAL_CN_IMAGE_MODELS = flattenImageModelCatalog("qwen-token-plan-individual-cn", values);
|
|
7
|
+
export const QWEN_TOKEN_PLAN_INDIVIDUAL_CN_CLASSIFIER_MODELS = flattenClassifierModelCatalog("qwen-token-plan-individual-cn", values);
|
|
8
|
+
//# sourceMappingURL=qwen-token-plan-individual-cn.models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qwen-token-plan-individual-cn.models.js","sourceRoot":"","sources":["../../src/providers/qwen-token-plan-individual-cn.models.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,iEAAiE;AAEjE,OAAO,MAAM,MAAM,2CAA2C,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACrF,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,6BAA6B,EAA8E,MAAM,qBAAqB,CAAC;AAEnM,MAAM,CAAC,MAAM,oCAAoC,GAChD,uBAAuB,CAAC,+BAA+B,EAAE,MAAM,CAAC,CAAC;AAElE,MAAM,CAAC,MAAM,0CAA0C,GACtD,wBAAwB,CAAC,+BAA+B,EAAE,MAAM,CAAC,CAAC;AAEnE,MAAM,CAAC,MAAM,+CAA+C,GAC3D,6BAA6B,CAAC,+BAA+B,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// This file is auto-generated by scripts/generate-models.ts\n// Do not edit manually - run 'npm run generate-models' to update\n\nimport values from \"./data/qwen-token-plan-individual-cn.json\" with { type: \"json\" };\nimport { flattenChatModelCatalog, flattenImageModelCatalog, flattenClassifierModelCatalog, type ChatModelCatalog, type ImageModelCatalog, type ClassifierModelCatalog } from \"../model-catalog.ts\";\n\nexport const QWEN_TOKEN_PLAN_INDIVIDUAL_CN_MODELS: ChatModelCatalog<typeof import(\"./data/qwen-token-plan-individual-cn.json\", { with: { type: \"json\" } }), \"qwen-token-plan-individual-cn\"> =\n\tflattenChatModelCatalog(\"qwen-token-plan-individual-cn\", values);\n\nexport const QWEN_TOKEN_PLAN_INDIVIDUAL_CN_IMAGE_MODELS: ImageModelCatalog<typeof import(\"./data/qwen-token-plan-individual-cn.json\", { with: { type: \"json\" } }), \"qwen-token-plan-individual-cn\"> =\n\tflattenImageModelCatalog(\"qwen-token-plan-individual-cn\", values);\n\nexport const QWEN_TOKEN_PLAN_INDIVIDUAL_CN_CLASSIFIER_MODELS: ClassifierModelCatalog<typeof import(\"./data/qwen-token-plan-individual-cn.json\", { with: { type: \"json\" } }), \"qwen-token-plan-individual-cn\"> =\n\tflattenClassifierModelCatalog(\"qwen-token-plan-individual-cn\", values);\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -7,9 +7,10 @@ import type { GoogleVertexOptions } from "./api/google-vertex.ts";
|
|
|
7
7
|
import type { MistralOptions } from "./api/mistral-conversations.ts";
|
|
8
8
|
import type { OpenAICodexResponsesOptions } from "./api/openai-codex-responses.ts";
|
|
9
9
|
import type { OpenAICompletionsOptions } from "./api/openai-completions.ts";
|
|
10
|
-
import type { OpenAIImagesOptions } from "./api/openai-images.ts";
|
|
10
|
+
import type { OpenAIImagesOptions } from "./api/openai-images-options.ts";
|
|
11
11
|
import type { OpenAIResponsesOptions } from "./api/openai-responses.ts";
|
|
12
12
|
import type { PiMessagesOptions } from "./api/pi-messages.ts";
|
|
13
|
+
import type { ImageGenerationErrorData } from "./image-generation-error.ts";
|
|
13
14
|
import type { AnthropicMessagesCompat, BedrockCompat, MistralConversationsCompat, OpenAICompletionsCompat, OpenAIResponsesCompat, SystemOneCompat } from "./providers/compat-schema.ts";
|
|
14
15
|
import type { CacheRetention, ModelCost, ModelInputLimits, ModelInputModality, ModelPromptCache, ModelThinkingLevel, ThinkingLevel, ThinkingLevelMap } from "./providers/model-schema.ts";
|
|
15
16
|
import type { AssistantMessageDiagnostic } from "./utils/diagnostics.ts";
|
|
@@ -25,7 +26,7 @@ export type ImageApi = KnownImageApi | (string & {});
|
|
|
25
26
|
export type KnownClassifierApi = "typesafe-system-one" | "cloudflare-workers-ai-system-one" | "llama-cpp-classify" | "openai-decisions";
|
|
26
27
|
export type ClassifierApi = KnownClassifierApi | (string & {});
|
|
27
28
|
export type CompactorApi = "morph-compact";
|
|
28
|
-
export type KnownProvider = "amazon-bedrock" | "ant-ling" | "anthropic" | "anthropic-api" | "google" | "google-vertex" | "openai" | "openai-api" | "azure" | "azure-openai-responses" | "openai-codex" | "openai-decisions" | "openai-images" | "radius" | "typesafe" | "morph" | "nvidia" | "deepseek" | "github-copilot" | "xai" | "groq" | "cerebras" | "openrouter" | "vercel-ai-gateway" | "zai" | "zai-coding-cn" | "mistral" | "minimax" | "minimax-cn" | "moonshotai" | "moonshotai-cn" | "huggingface" | "fireworks" | "together" | "baseten" | "opencode" | "opencode-go" | "kimi-coding" | "meta" | "cloudflare-workers-ai" | "cloudflare-ai-gateway" | "qwen-token-plan" | "qwen-token-plan-cn" | "qwen-token-plan-individual" | "xiaomi" | "xiaomi-token-plan-cn" | "xiaomi-token-plan-ams" | "xiaomi-token-plan-sgp";
|
|
29
|
+
export type KnownProvider = "amazon-bedrock" | "ant-ling" | "anthropic" | "anthropic-api" | "google" | "google-vertex" | "openai" | "openai-api" | "azure" | "azure-openai-responses" | "openai-codex" | "openai-decisions" | "openai-images" | "radius" | "typesafe" | "morph" | "nvidia" | "deepseek" | "github-copilot" | "xai" | "groq" | "cerebras" | "openrouter" | "vercel-ai-gateway" | "zai" | "zai-coding-cn" | "mistral" | "minimax" | "minimax-cn" | "moonshotai" | "moonshotai-cn" | "huggingface" | "fireworks" | "together" | "baseten" | "opencode" | "opencode-go" | "kimi-coding" | "meta" | "cloudflare-workers-ai" | "cloudflare-ai-gateway" | "qwen-token-plan" | "qwen-token-plan-cn" | "qwen-token-plan-individual" | "qwen-token-plan-individual-cn" | "xiaomi" | "xiaomi-token-plan-cn" | "xiaomi-token-plan-ams" | "xiaomi-token-plan-sgp";
|
|
29
30
|
export type ProviderId = KnownProvider | string;
|
|
30
31
|
export type ToolChoice = "auto" | "none";
|
|
31
32
|
export type SamplingParams = Record<string, unknown>;
|
|
@@ -510,7 +511,17 @@ export type ToolResultMessage<TDetails = JsonValue> = IsJsonCompatible<TDetails>
|
|
|
510
511
|
durationMs?: number;
|
|
511
512
|
} : never;
|
|
512
513
|
export type Message = SystemMessage | UserMessage | AssistantMessage | ToolResultMessage;
|
|
513
|
-
|
|
514
|
+
/** Role of an input image of an image request. Images without a role are the base image and references. */
|
|
515
|
+
export type ImagesInputImageRole = "markup" | "mask";
|
|
516
|
+
/**
|
|
517
|
+
* An image of an image request. Without a `role`, the first image is the base image to edit and the
|
|
518
|
+
* rest are references. A `markup` image is a transparent annotation layer and a `mask` image an
|
|
519
|
+
* alpha-channel mask; both apply to the first image. `openai-images` honors roles.
|
|
520
|
+
*/
|
|
521
|
+
export interface ImagesInputImage extends ImageContent {
|
|
522
|
+
role?: ImagesInputImageRole;
|
|
523
|
+
}
|
|
524
|
+
export type ImagesInputContent = TextContent | ImagesInputImage;
|
|
514
525
|
export type ImagesOutputContent = TextContent | ImageContent;
|
|
515
526
|
export interface ImagesContext {
|
|
516
527
|
input: ImagesInputContent[];
|
|
@@ -525,6 +536,8 @@ export interface AssistantImages {
|
|
|
525
536
|
usage?: Usage;
|
|
526
537
|
stopReason: ImagesStopReason;
|
|
527
538
|
errorMessage?: string;
|
|
539
|
+
/** Typed form of `errorMessage` when the failure is classified. Rebuild it with `imageGenerationErrorFromData()`. */
|
|
540
|
+
error?: ImageGenerationErrorData;
|
|
528
541
|
timestamp: number;
|
|
529
542
|
}
|
|
530
543
|
export interface ClassifierChoiceQuestion {
|
|
@@ -786,9 +799,22 @@ export interface Model<TApi extends Api> extends BaseModel<TApi> {
|
|
|
786
799
|
/** Compatibility overrides for OpenAI-compatible APIs. If not set, auto-detected from baseUrl. */
|
|
787
800
|
compat?: TApi extends "openai-completions" ? OpenAICompletionsCompat : TApi extends "openai-responses" | "azure-openai-responses" | "openai-codex-responses" ? OpenAIResponsesCompat : TApi extends "anthropic-messages" ? AnthropicMessagesCompat : TApi extends "bedrock-converse-stream" ? BedrockCompat : TApi extends "mistral-conversations" ? MistralConversationsCompat : never;
|
|
788
801
|
}
|
|
802
|
+
/** Optional request features of an image model beyond plain generation and editing. */
|
|
803
|
+
export interface ImageModelCapabilities {
|
|
804
|
+
/** The `complexity` option. */
|
|
805
|
+
complexity?: boolean;
|
|
806
|
+
/** An input image with `role: "markup"`. */
|
|
807
|
+
markup?: boolean;
|
|
808
|
+
/** `outputFormat: "svg"`. */
|
|
809
|
+
svg?: boolean;
|
|
810
|
+
/** `outputFormat: "gif"` with `frameCount` and `frameDurationMs`. */
|
|
811
|
+
gif?: boolean;
|
|
812
|
+
}
|
|
789
813
|
/** Image-generation model: usable with `generateImages()` only. */
|
|
790
814
|
export interface ImageModel<TApi extends ImageApi> extends BaseModel<TApi> {
|
|
791
815
|
type: "image";
|
|
816
|
+
/** Optional request features the model supports. A feature that is absent is unsupported and fails validation. */
|
|
817
|
+
capabilities?: ImageModelCapabilities;
|
|
792
818
|
/** Output modalities. Always includes `"image"`; `"text"` means the model can also return text blocks. */
|
|
793
819
|
output: ("text" | "image")[];
|
|
794
820
|
}
|