@sayknow-cli/ai 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/dist/types/api-registry.d.ts +30 -0
  2. package/dist/types/auth-broker/client.d.ts +67 -0
  3. package/dist/types/auth-broker/index.d.ts +5 -0
  4. package/dist/types/auth-broker/refresher.d.ts +25 -0
  5. package/dist/types/auth-broker/remote-store.d.ts +99 -0
  6. package/dist/types/auth-broker/server.d.ts +32 -0
  7. package/dist/types/auth-broker/types.d.ts +110 -0
  8. package/dist/types/auth-broker/wire-schemas.d.ts +443 -0
  9. package/dist/types/auth-gateway/http.d.ts +40 -0
  10. package/dist/types/auth-gateway/index.d.ts +3 -0
  11. package/dist/types/auth-gateway/server.d.ts +36 -0
  12. package/dist/types/auth-gateway/types.d.ts +115 -0
  13. package/dist/types/auth-storage.d.ts +699 -0
  14. package/dist/types/cli.d.ts +2 -0
  15. package/dist/types/context-cap-policy.d.ts +10 -0
  16. package/dist/types/index.d.ts +53 -0
  17. package/dist/types/model-cache.d.ts +19 -0
  18. package/dist/types/model-manager.d.ts +64 -0
  19. package/dist/types/model-retirements.d.ts +6 -0
  20. package/dist/types/model-thinking.d.ts +74 -0
  21. package/dist/types/models.d.ts +21 -0
  22. package/dist/types/provider-details.d.ts +24 -0
  23. package/dist/types/provider-models/bundled-references.d.ts +4 -0
  24. package/dist/types/provider-models/descriptors.d.ts +48 -0
  25. package/dist/types/provider-models/google.d.ts +20 -0
  26. package/dist/types/provider-models/index.d.ts +5 -0
  27. package/dist/types/provider-models/ollama.d.ts +7 -0
  28. package/dist/types/provider-models/openai-compat.d.ts +256 -0
  29. package/dist/types/provider-models/special.d.ts +19 -0
  30. package/dist/types/providers/amazon-bedrock.d.ts +60 -0
  31. package/dist/types/providers/anthropic-messages-server-schema.d.ts +450 -0
  32. package/dist/types/providers/anthropic-messages-server.d.ts +17 -0
  33. package/dist/types/providers/anthropic.d.ts +209 -0
  34. package/dist/types/providers/aws-credential-config.d.ts +19 -0
  35. package/dist/types/providers/aws-credentials.d.ts +43 -0
  36. package/dist/types/providers/aws-eventstream.d.ts +38 -0
  37. package/dist/types/providers/aws-sigv4.d.ts +55 -0
  38. package/dist/types/providers/azure-openai-responses.d.ts +15 -0
  39. package/dist/types/providers/composer-discipline.d.ts +26 -0
  40. package/dist/types/providers/cursor/client-version.d.ts +10 -0
  41. package/dist/types/providers/cursor/gen/agent_pb.d.ts +13022 -0
  42. package/dist/types/providers/cursor.d.ts +45 -0
  43. package/dist/types/providers/error-message.d.ts +27 -0
  44. package/dist/types/providers/github-copilot-headers.d.ts +40 -0
  45. package/dist/types/providers/gitlab-duo.d.ts +27 -0
  46. package/dist/types/providers/google-auth.d.ts +24 -0
  47. package/dist/types/providers/google-gemini-cli.d.ts +75 -0
  48. package/dist/types/providers/google-gemini-headers.d.ts +43 -0
  49. package/dist/types/providers/google-shared.d.ts +179 -0
  50. package/dist/types/providers/google-types.d.ts +138 -0
  51. package/dist/types/providers/google-vertex.d.ts +7 -0
  52. package/dist/types/providers/google.d.ts +4 -0
  53. package/dist/types/providers/grammar.d.ts +1 -0
  54. package/dist/types/providers/kimi.d.ts +27 -0
  55. package/dist/types/providers/mock.d.ts +177 -0
  56. package/dist/types/providers/ollama.d.ts +41 -0
  57. package/dist/types/providers/openai-anthropic-shim.d.ts +31 -0
  58. package/dist/types/providers/openai-bounded-rate-limits.d.ts +3 -0
  59. package/dist/types/providers/openai-chat-server-schema.d.ts +815 -0
  60. package/dist/types/providers/openai-chat-server.d.ts +16 -0
  61. package/dist/types/providers/openai-codex/constants.d.ts +26 -0
  62. package/dist/types/providers/openai-codex/request-transformer.d.ts +50 -0
  63. package/dist/types/providers/openai-codex/response-handler.d.ts +18 -0
  64. package/dist/types/providers/openai-codex-responses.d.ts +68 -0
  65. package/dist/types/providers/openai-completions-compat.d.ts +27 -0
  66. package/dist/types/providers/openai-completions.d.ts +33 -0
  67. package/dist/types/providers/openai-request-transform.d.ts +4 -0
  68. package/dist/types/providers/openai-responses-server-schema.d.ts +392 -0
  69. package/dist/types/providers/openai-responses-server.d.ts +17 -0
  70. package/dist/types/providers/openai-responses-shared.d.ts +104 -0
  71. package/dist/types/providers/openai-responses.d.ts +32 -0
  72. package/dist/types/providers/pi-native-client.d.ts +13 -0
  73. package/dist/types/providers/pi-native-server.d.ts +60 -0
  74. package/dist/types/providers/register-builtins.d.ts +31 -0
  75. package/dist/types/providers/synthetic.d.ts +26 -0
  76. package/dist/types/providers/transform-messages.d.ts +14 -0
  77. package/dist/types/providers/vision-guard.d.ts +8 -0
  78. package/dist/types/rate-limit-utils.d.ts +19 -0
  79. package/dist/types/stream.d.ts +43 -0
  80. package/dist/types/types.d.ts +882 -0
  81. package/dist/types/usage/claude.d.ts +3 -0
  82. package/dist/types/usage/gemini.d.ts +2 -0
  83. package/dist/types/usage/github-copilot.d.ts +7 -0
  84. package/dist/types/usage/google-antigravity.d.ts +2 -0
  85. package/dist/types/usage/grok-cli.d.ts +10 -0
  86. package/dist/types/usage/kimi.d.ts +2 -0
  87. package/dist/types/usage/minimax-code.d.ts +2 -0
  88. package/dist/types/usage/openai-codex.d.ts +3 -0
  89. package/dist/types/usage/shared.d.ts +1 -0
  90. package/dist/types/usage/zai.d.ts +2 -0
  91. package/dist/types/usage.d.ts +258 -0
  92. package/dist/types/utils/abort.d.ts +19 -0
  93. package/dist/types/utils/anthropic-auth.d.ts +31 -0
  94. package/dist/types/utils/discovery/antigravity.d.ts +67 -0
  95. package/dist/types/utils/discovery/codex.d.ts +38 -0
  96. package/dist/types/utils/discovery/cursor.d.ts +23 -0
  97. package/dist/types/utils/discovery/gemini.d.ts +25 -0
  98. package/dist/types/utils/discovery/index.d.ts +4 -0
  99. package/dist/types/utils/discovery/openai-compatible.d.ts +74 -0
  100. package/dist/types/utils/event-stream.d.ts +39 -0
  101. package/dist/types/utils/fallback-transport.d.ts +66 -0
  102. package/dist/types/utils/fireworks-model-id.d.ts +10 -0
  103. package/dist/types/utils/foundry.d.ts +1 -0
  104. package/dist/types/utils/h2-fetch.d.ts +22 -0
  105. package/dist/types/utils/http-inspector.d.ts +35 -0
  106. package/dist/types/utils/idle-iterator.d.ts +67 -0
  107. package/dist/types/utils/json-parse.d.ts +18 -0
  108. package/dist/types/utils/oauth/alibaba-coding-plan.d.ts +18 -0
  109. package/dist/types/utils/oauth/anthropic.d.ts +22 -0
  110. package/dist/types/utils/oauth/api-key-login.d.ts +35 -0
  111. package/dist/types/utils/oauth/api-key-validation.d.ts +27 -0
  112. package/dist/types/utils/oauth/callback-server.d.ts +60 -0
  113. package/dist/types/utils/oauth/cerebras.d.ts +1 -0
  114. package/dist/types/utils/oauth/cloudflare-ai-gateway.d.ts +18 -0
  115. package/dist/types/utils/oauth/cursor.d.ts +15 -0
  116. package/dist/types/utils/oauth/deepinfra.d.ts +1 -0
  117. package/dist/types/utils/oauth/deepseek.d.ts +10 -0
  118. package/dist/types/utils/oauth/firepass.d.ts +1 -0
  119. package/dist/types/utils/oauth/fireworks.d.ts +1 -0
  120. package/dist/types/utils/oauth/fugu.d.ts +1 -0
  121. package/dist/types/utils/oauth/github-copilot.d.ts +38 -0
  122. package/dist/types/utils/oauth/gitlab-duo.d.ts +3 -0
  123. package/dist/types/utils/oauth/glm-zcode.d.ts +71 -0
  124. package/dist/types/utils/oauth/google-antigravity.d.ts +11 -0
  125. package/dist/types/utils/oauth/google-gemini-cli.d.ts +10 -0
  126. package/dist/types/utils/oauth/google-oauth-shared.d.ts +28 -0
  127. package/dist/types/utils/oauth/huggingface.d.ts +19 -0
  128. package/dist/types/utils/oauth/index.d.ts +39 -0
  129. package/dist/types/utils/oauth/kagi.d.ts +17 -0
  130. package/dist/types/utils/oauth/kilo.d.ts +5 -0
  131. package/dist/types/utils/oauth/kimi.d.ts +21 -0
  132. package/dist/types/utils/oauth/litellm.d.ts +18 -0
  133. package/dist/types/utils/oauth/lm-studio.d.ts +17 -0
  134. package/dist/types/utils/oauth/minimax-code.d.ts +28 -0
  135. package/dist/types/utils/oauth/moonshot.d.ts +1 -0
  136. package/dist/types/utils/oauth/nanogpt.d.ts +1 -0
  137. package/dist/types/utils/oauth/nvidia.d.ts +18 -0
  138. package/dist/types/utils/oauth/ollama-cloud.d.ts +2 -0
  139. package/dist/types/utils/oauth/ollama.d.ts +18 -0
  140. package/dist/types/utils/oauth/openai-codex.d.ts +21 -0
  141. package/dist/types/utils/oauth/opencode.d.ts +18 -0
  142. package/dist/types/utils/oauth/parallel.d.ts +17 -0
  143. package/dist/types/utils/oauth/perplexity.d.ts +9 -0
  144. package/dist/types/utils/oauth/pkce.d.ts +8 -0
  145. package/dist/types/utils/oauth/qianfan.d.ts +17 -0
  146. package/dist/types/utils/oauth/qwen-portal.d.ts +19 -0
  147. package/dist/types/utils/oauth/synthetic.d.ts +1 -0
  148. package/dist/types/utils/oauth/tavily.d.ts +17 -0
  149. package/dist/types/utils/oauth/together.d.ts +1 -0
  150. package/dist/types/utils/oauth/types.d.ts +45 -0
  151. package/dist/types/utils/oauth/venice.d.ts +18 -0
  152. package/dist/types/utils/oauth/vercel-ai-gateway.d.ts +18 -0
  153. package/dist/types/utils/oauth/vllm.d.ts +16 -0
  154. package/dist/types/utils/oauth/xai.d.ts +30 -0
  155. package/dist/types/utils/oauth/xiaomi.d.ts +25 -0
  156. package/dist/types/utils/oauth/zai.d.ts +18 -0
  157. package/dist/types/utils/oauth/zenmux.d.ts +1 -0
  158. package/dist/types/utils/overflow.d.ts +14 -0
  159. package/dist/types/utils/parse-bind.d.ts +23 -0
  160. package/dist/types/utils/provider-response.d.ts +3 -0
  161. package/dist/types/utils/retry-after.d.ts +3 -0
  162. package/dist/types/utils/retry-budget.d.ts +1 -0
  163. package/dist/types/utils/retry.d.ts +27 -0
  164. package/dist/types/utils/schema/adapt.d.ts +24 -0
  165. package/dist/types/utils/schema/compatibility.d.ts +30 -0
  166. package/dist/types/utils/schema/dereference.d.ts +11 -0
  167. package/dist/types/utils/schema/draft.d.ts +10 -0
  168. package/dist/types/utils/schema/equality.d.ts +4 -0
  169. package/dist/types/utils/schema/fields.d.ts +49 -0
  170. package/dist/types/utils/schema/index.d.ts +14 -0
  171. package/dist/types/utils/schema/json-schema-validator.d.ts +12 -0
  172. package/dist/types/utils/schema/meta-validator.d.ts +2 -0
  173. package/dist/types/utils/schema/normalize.d.ts +93 -0
  174. package/dist/types/utils/schema/root-combinator.d.ts +12 -0
  175. package/dist/types/utils/schema/spill.d.ts +8 -0
  176. package/dist/types/utils/schema/stamps.d.ts +25 -0
  177. package/dist/types/utils/schema/types.d.ts +4 -0
  178. package/dist/types/utils/schema/wire.d.ts +54 -0
  179. package/dist/types/utils/schema/zod-decontaminate.d.ts +31 -0
  180. package/dist/types/utils/sse-debug.d.ts +10 -0
  181. package/dist/types/utils/tool-call-healing.d.ts +71 -0
  182. package/dist/types/utils/tool-choice-capability.d.ts +41 -0
  183. package/dist/types/utils/tool-choice.d.ts +50 -0
  184. package/dist/types/utils/validation.d.ts +17 -0
  185. package/dist/types/utils.d.ts +89 -0
  186. package/package.json +25 -24
@@ -0,0 +1,39 @@
1
+ import type { OAuthCredentials, OAuthProvider, OAuthProviderId, OAuthProviderInfo, OAuthProviderInterface } from "./types";
2
+ /**
3
+ * Register a custom OAuth provider.
4
+ */
5
+ export declare function registerOAuthProvider(provider: OAuthProviderInterface): void;
6
+ /**
7
+ * Get a custom OAuth provider by ID.
8
+ */
9
+ export declare function getOAuthProvider(id: OAuthProviderId): OAuthProviderInterface | undefined;
10
+ /**
11
+ * Remove all custom OAuth providers registered by a source.
12
+ */
13
+ export declare function unregisterOAuthProviders(sourceId: string): void;
14
+ /**
15
+ * Refresh token for any OAuth provider.
16
+ * Saves the new credentials and returns the new access token.
17
+ */
18
+ export declare function refreshOAuthToken(provider: OAuthProvider, credentials: OAuthCredentials): Promise<OAuthCredentials>;
19
+ /**
20
+ * Build API-key bytes for a provider from an already-fresh OAuth credential.
21
+ *
22
+ * Refresh is owned by AuthStorage. This helper deliberately refuses expired
23
+ * credentials so it cannot POST broker redaction sentinels to upstream token
24
+ * endpoints as a side channel.
25
+ *
26
+ * For providers that need credential metadata at request time, returns
27
+ * JSON-encoded credentials plus expiry metadata for diagnostics/edge guards.
28
+ * @returns API key string, or null if no credentials
29
+ * @throws Error if the credential is expired and must be refreshed upstream
30
+ */
31
+ export declare function getOAuthApiKey(provider: OAuthProvider, credentials: Record<string, OAuthCredentials>): Promise<{
32
+ newCredentials: OAuthCredentials;
33
+ apiKey: string;
34
+ } | null>;
35
+ export declare function resolveOAuthStorageProvider(provider: OAuthProviderId): OAuthProviderId;
36
+ /**
37
+ * Get list of OAuth providers.
38
+ */
39
+ export declare function getOAuthProviders(): OAuthProviderInfo[];
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Kagi login flow.
3
+ *
4
+ * Kagi web search uses an API key from the account settings page.
5
+ * This is an API key flow:
6
+ * 1. Open browser to Kagi API settings
7
+ * 2. User copies API key
8
+ * 3. User pastes key into CLI
9
+ */
10
+ import type { OAuthController } from "./types";
11
+ /**
12
+ * Login to Kagi.
13
+ *
14
+ * Opens browser to API settings and prompts user to paste their API key.
15
+ * Returns the API key directly (not OAuthCredentials - this isn't OAuth).
16
+ */
17
+ export declare function loginKagi(options: OAuthController): Promise<string>;
@@ -0,0 +1,5 @@
1
+ import type { OAuthController, OAuthCredentials } from "./types";
2
+ /**
3
+ * Login with Kilo Gateway OAuth (device code flow).
4
+ */
5
+ export declare function loginKilo(callbacks: OAuthController): Promise<OAuthCredentials>;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Kimi Code OAuth flow (device authorization grant)
3
+ */
4
+ import type { OAuthController, OAuthCredentials } from "./types";
5
+ export declare let getKimiCommonHeaders: () => Readonly<{
6
+ "User-Agent": `KimiCLI/${string}`;
7
+ "X-Msh-Platform": "kimi_cli";
8
+ "X-Msh-Version": string;
9
+ "X-Msh-Device-Name": string;
10
+ "X-Msh-Device-Model": string;
11
+ "X-Msh-Os-Version": string;
12
+ "X-Msh-Device-Id": string;
13
+ }>;
14
+ /**
15
+ * Login with Kimi Code OAuth (device code flow).
16
+ */
17
+ export declare function loginKimi(options: OAuthController): Promise<OAuthCredentials>;
18
+ /**
19
+ * Refresh Kimi OAuth token.
20
+ */
21
+ export declare function refreshKimiToken(refreshToken: string): Promise<OAuthCredentials>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * LiteLLM login flow.
3
+ *
4
+ * LiteLLM is an OpenAI-compatible proxy that routes requests to many upstream providers.
5
+ *
6
+ * This is not OAuth - it's a simple API key flow:
7
+ * 1. Open browser to LiteLLM docs/dashboard
8
+ * 2. User copies their LiteLLM API key
9
+ * 3. User pastes the API key into the CLI
10
+ */
11
+ import type { OAuthController } from "./types";
12
+ /**
13
+ * Login to LiteLLM.
14
+ *
15
+ * Opens browser to LiteLLM setup docs, prompts user to paste their API key.
16
+ * Returns the API key directly (not OAuthCredentials - this isn't OAuth).
17
+ */
18
+ export declare function loginLiteLLM(options: OAuthController): Promise<string>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * LM Studio login flow.
3
+ *
4
+ * LM Studio provides an OpenAI-compatible API at a local base URL.
5
+ * It usually runs unauthenticated but can be configured to require a bearer token.
6
+ *
7
+ * This flow stores an API-key-style credential used by `/login` and auth storage.
8
+ */
9
+ import type { OAuthController } from "./types";
10
+ export declare const DEFAULT_LOCAL_TOKEN = "lm-studio-local";
11
+ /**
12
+ * Login to LM Studio.
13
+ *
14
+ * Opens LM Studio API docs, prompts for an optional token,
15
+ * and returns a stored key value.
16
+ */
17
+ export declare function loginLmStudio(options: OAuthController): Promise<string>;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * MiniMax Coding Plan login flow.
3
+ *
4
+ * MiniMax Coding Plan is a subscription service that provides access to
5
+ * MiniMax models (M2, M2.1) through an OpenAI-compatible API.
6
+ *
7
+ * This is not OAuth - it's a simple API key flow:
8
+ * 1. Open browser to https://platform.minimax.io/subscribe/coding-plan
9
+ * 2. User subscribes and copies their API key
10
+ * 3. User pastes the API key back into the CLI
11
+ *
12
+ * International: https://api.minimax.io/v1
13
+ * China: https://api.minimaxi.com/v1
14
+ */
15
+ import type { OAuthController } from "./types";
16
+ /**
17
+ * Login to MiniMax Coding Plan (international).
18
+ *
19
+ * Opens browser to subscription page, prompts user to paste their API key.
20
+ * Returns the API key directly (not OAuthCredentials - this isn't OAuth).
21
+ */
22
+ export declare function loginMiniMaxCode(options: OAuthController): Promise<string>;
23
+ /**
24
+ * Login to MiniMax Coding Plan (China).
25
+ *
26
+ * Same flow as international but uses China endpoint.
27
+ */
28
+ export declare function loginMiniMaxCodeCn(options: OAuthController): Promise<string>;
@@ -0,0 +1 @@
1
+ export declare const loginMoonshot: (options: import("./types").OAuthController) => Promise<string>;
@@ -0,0 +1 @@
1
+ export declare const loginNanoGPT: (options: import("./types").OAuthController) => Promise<string>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * NVIDIA login flow.
3
+ *
4
+ * NVIDIA provides OpenAI-compatible models via https://integrate.api.nvidia.com/v1.
5
+ *
6
+ * This is not OAuth - it's a simple API key flow:
7
+ * 1. Open browser to NVIDIA NGC catalog
8
+ * 2. User copies their API key
9
+ * 3. User pastes the API key into the CLI
10
+ */
11
+ import type { OAuthController } from "./types";
12
+ /**
13
+ * Login to NVIDIA.
14
+ *
15
+ * Opens browser to NVIDIA dashboard, prompts user to paste their API key.
16
+ * Returns the API key directly (not OAuthCredentials - this isn't OAuth).
17
+ */
18
+ export declare function loginNvidia(options: OAuthController): Promise<string>;
@@ -0,0 +1,2 @@
1
+ import type { OAuthController } from "./types";
2
+ export declare function loginOllamaCloud(options: OAuthController): Promise<string>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Ollama login flow.
3
+ *
4
+ * Ollama is typically used locally without authentication, but some hosted
5
+ * deployments require a bearer token/API key.
6
+ *
7
+ * This flow is API-key based (not OAuth):
8
+ * 1. Optionally open Ollama docs
9
+ * 2. Prompt user for API key/token (optional)
10
+ * 3. Persist key only when provided
11
+ */
12
+ import type { OAuthController } from "./types";
13
+ /**
14
+ * Login to Ollama.
15
+ *
16
+ * Returns a trimmed API key/token string. Empty string means local no-auth mode.
17
+ */
18
+ export declare function loginOllama(options: OAuthController): Promise<string>;
@@ -0,0 +1,21 @@
1
+ import type { OAuthController, OAuthCredentials } from "./types";
2
+ export declare function decodeJwt<T = Record<string, unknown>>(token: string): T | null;
3
+ /**
4
+ * Login with OpenAI code provider OAuth
5
+ */
6
+ export type OpenAICodexLoginOptions = OAuthController & {
7
+ /** Optional originator value for OpenAI code provider OAuth. Default: "opencode". */
8
+ originator?: string;
9
+ };
10
+ export declare function loginOpenAICodex(options: OpenAICodexLoginOptions): Promise<OAuthCredentials>;
11
+ /**
12
+ * Login with OpenAI code provider using the device-code (headless) flow.
13
+ *
14
+ * Avoids a local callback server entirely — useful when port 1455 is unavailable
15
+ * or when the browser callback flow fails with 403 (e.g. network/proxy issues).
16
+ */
17
+ export declare function loginOpenAICodexDevice(ctrl: OAuthController): Promise<OAuthCredentials>;
18
+ /**
19
+ * Refresh OpenAI code provider OAuth token
20
+ */
21
+ export declare function refreshOpenAICodexToken(refreshToken: string): Promise<OAuthCredentials>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * OpenCode Zen login flow.
3
+ *
4
+ * OpenCode Zen is a subscription service that provides access to various AI models
5
+ * (GPT-5.x, Anthropic model 4.x, Gemini 3, etc.) through a unified API at opencode.ai/zen.
6
+ * This is not OAuth - it's a simple API key flow:
7
+ * 1. Open browser to https://opencode.ai/auth
8
+ * 2. User logs in and copies their API key
9
+ * 3. User pastes the API key back into the CLI
10
+ */
11
+ import type { OAuthController } from "./types";
12
+ /**
13
+ * Login to OpenCode Zen.
14
+ *
15
+ * Opens browser to auth page, prompts user to paste their API key.
16
+ * Returns the API key directly (not OAuthCredentials - this isn't OAuth).
17
+ */
18
+ export declare function loginOpenCode(options: OAuthController): Promise<string>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Parallel login flow.
3
+ *
4
+ * Parallel uses an API key from the account settings page.
5
+ * This is an API key flow:
6
+ * 1. Open browser to Parallel API key settings
7
+ * 2. User copies API key
8
+ * 3. User pastes key into the CLI/TUI
9
+ */
10
+ import type { OAuthController } from "./types";
11
+ /**
12
+ * Login to Parallel.
13
+ *
14
+ * Opens browser to the API keys page, prompts the user to paste their API key,
15
+ * and returns the API key directly.
16
+ */
17
+ export declare function loginParallel(options: OAuthController): Promise<string>;
@@ -0,0 +1,9 @@
1
+ import type { OAuthController, OAuthCredentials } from "./types";
2
+ /**
3
+ * Login to Perplexity.
4
+ *
5
+ * Tries auto-extraction from the desktop app, then runs HTTP email OTP login.
6
+ *
7
+ * No browser/manual token paste fallback is used.
8
+ */
9
+ export declare function loginPerplexity(ctrl: OAuthController): Promise<OAuthCredentials>;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Generate PKCE code verifier and challenge.
3
+ * Uses Web Crypto API for cross-platform compatibility.
4
+ */
5
+ export declare function generatePKCE(): Promise<{
6
+ verifier: string;
7
+ challenge: string;
8
+ }>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Qianfan login flow.
3
+ *
4
+ * Qianfan provides an OpenAI-compatible API endpoint.
5
+ * Login is API-key based:
6
+ * 1. Open browser to Qianfan API key console
7
+ * 2. User copies API key
8
+ * 3. User pastes key into CLI prompt
9
+ */
10
+ import type { OAuthController } from "./types";
11
+ /**
12
+ * Login to Qianfan.
13
+ *
14
+ * Opens browser to API key page, prompts user to paste their API key.
15
+ * Returns the API key directly (not OAuthCredentials - this isn't OAuth).
16
+ */
17
+ export declare function loginQianfan(options: OAuthController): Promise<string>;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Qwen Portal login flow.
3
+ *
4
+ * Qwen Portal exposes an OpenAI-compatible endpoint at https://portal.qwen.ai/v1
5
+ * and accepts OAuth bearer tokens or API keys.
6
+ *
7
+ * This is a token/API-key flow:
8
+ * 1. Open Qwen Portal
9
+ * 2. Copy either your OAuth token or API key
10
+ * 3. Paste it into the CLI
11
+ */
12
+ import type { OAuthController } from "./types";
13
+ /**
14
+ * Login to Qwen Portal.
15
+ *
16
+ * Prompts for either `QWEN_OAUTH_TOKEN` or `QWEN_PORTAL_API_KEY` value.
17
+ * Returns the value directly (stored as api_key credential in auth storage).
18
+ */
19
+ export declare function loginQwenPortal(options: OAuthController): Promise<string>;
@@ -0,0 +1 @@
1
+ export declare const loginSynthetic: (options: import("./types").OAuthController) => Promise<string>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Tavily login flow.
3
+ *
4
+ * Tavily web search uses an API key from the account settings page.
5
+ * This is an API key flow:
6
+ * 1. Open browser to Tavily settings
7
+ * 2. User copies API key
8
+ * 3. User pastes key into CLI
9
+ */
10
+ import type { OAuthController } from "./types";
11
+ /**
12
+ * Login to Tavily.
13
+ *
14
+ * Opens browser to API keys page and prompts user to paste their API key.
15
+ * Returns the API key directly (not OAuthCredentials - this isn't OAuth).
16
+ */
17
+ export declare function loginTavily(options: OAuthController): Promise<string>;
@@ -0,0 +1 @@
1
+ export declare const loginTogether: (options: import("./types").OAuthController) => Promise<string>;
@@ -0,0 +1,45 @@
1
+ export type OAuthCredentials = {
2
+ refresh: string;
3
+ access: string;
4
+ expires: number;
5
+ enterpriseUrl?: string;
6
+ projectId?: string;
7
+ email?: string;
8
+ accountId?: string;
9
+ };
10
+ export type OAuthProvider = "alibaba-coding-plan" | "anthropic" | "cerebras" | "cloudflare-ai-gateway" | "cursor" | "deepseek" | "deepinfra" | "fireworks" | "firepass" | "fugu" | "github-copilot" | "google-gemini-cli" | "google-antigravity" | "gitlab-duo" | "huggingface" | "kimi-code" | "kilo" | "kagi" | "litellm" | "lm-studio" | "minimax-code" | "minimax-code-cn" | "moonshot" | "nvidia" | "nanogpt" | "ollama" | "ollama-cloud" | "openai-codex" | "openai-codex-device" | "opencode-go" | "opencode-zen" | "parallel" | "perplexity" | "qianfan" | "qwen-portal" | "synthetic" | "tavily" | "together" | "venice" | "vercel-ai-gateway" | "vllm" | "xai" | "glm-zcode" | "xiaomi" | "xiaomi-token-plan-sgp" | "xiaomi-token-plan-ams" | "xiaomi-token-plan-cn" | "zenmux" | "zai";
11
+ export type OAuthProviderId = OAuthProvider | (string & {});
12
+ export type OAuthPrompt = {
13
+ message: string;
14
+ placeholder?: string;
15
+ allowEmpty?: boolean;
16
+ };
17
+ export type OAuthAuthInfo = {
18
+ url: string;
19
+ instructions?: string;
20
+ };
21
+ export interface OAuthProviderInfo {
22
+ id: OAuthProviderId;
23
+ name: string;
24
+ available: boolean;
25
+ }
26
+ export interface OAuthController {
27
+ onAuth?(info: OAuthAuthInfo): void;
28
+ onProgress?(message: string): void;
29
+ onManualCodeInput?(): Promise<string>;
30
+ onPrompt?(prompt: OAuthPrompt): Promise<string>;
31
+ signal?: AbortSignal;
32
+ fetch?: typeof globalThis.fetch;
33
+ }
34
+ export interface OAuthLoginCallbacks extends OAuthController {
35
+ onAuth: (info: OAuthAuthInfo) => void;
36
+ onPrompt: (prompt: OAuthPrompt) => Promise<string>;
37
+ }
38
+ export interface OAuthProviderInterface {
39
+ readonly id: OAuthProviderId;
40
+ readonly name: string;
41
+ readonly sourceId?: string;
42
+ login(callbacks: OAuthLoginCallbacks): Promise<OAuthCredentials | string>;
43
+ refreshToken?(credentials: OAuthCredentials): Promise<OAuthCredentials>;
44
+ getApiKey?(credentials: OAuthCredentials): string;
45
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Venice login flow.
3
+ *
4
+ * Venice provides OpenAI-compatible models via https://api.venice.ai/api/v1.
5
+ *
6
+ * This is not OAuth - it's a simple API key flow:
7
+ * 1. Open browser to Venice API key settings
8
+ * 2. User copies their API key
9
+ * 3. User pastes the API key into the CLI
10
+ */
11
+ import type { OAuthController } from "./types";
12
+ /**
13
+ * Login to Venice.
14
+ *
15
+ * Opens browser to API keys page, prompts user to paste their API key.
16
+ * Returns the API key directly (not OAuthCredentials - this isn't OAuth).
17
+ */
18
+ export declare function loginVenice(options: OAuthController): Promise<string>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Vercel AI Gateway login flow.
3
+ *
4
+ * Vercel AI Gateway proxies upstream model providers through a unified endpoint.
5
+ *
6
+ * This is not OAuth - it's a simple API key flow:
7
+ * 1. Open Vercel AI Gateway docs
8
+ * 2. User copies their API key
9
+ * 3. User pastes the API key into the CLI
10
+ */
11
+ import type { OAuthController } from "./types";
12
+ /**
13
+ * Login to Vercel AI Gateway.
14
+ *
15
+ * Opens browser to Vercel AI Gateway docs and prompts for an API key.
16
+ * Returns the API key directly (not OAuthCredentials - this isn't OAuth).
17
+ */
18
+ export declare function loginVercelAiGateway(options: OAuthController): Promise<string>;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * vLLM login flow.
3
+ *
4
+ * vLLM is commonly self-hosted with an OpenAI-compatible API at a local base URL.
5
+ * Some deployments require a bearer token, others allow unauthenticated access.
6
+ *
7
+ * This flow stores an API-key-style credential used by `/login` and auth storage.
8
+ */
9
+ import type { OAuthController } from "./types";
10
+ /**
11
+ * Login to vLLM.
12
+ *
13
+ * Opens vLLM OpenAI-compatible auth docs, prompts for an optional token,
14
+ * and returns a stored key value.
15
+ */
16
+ export declare function loginVllm(options: OAuthController): Promise<string>;
@@ -0,0 +1,30 @@
1
+ /** xAI OAuth flow (Grok account login). */
2
+ import { OAuthCallbackFlow } from "./callback-server";
3
+ import type { OAuthController, OAuthCredentials } from "./types";
4
+ export declare const XAI_OAUTH_DISCOVERY_URL = "https://auth.x.ai/.well-known/openid-configuration";
5
+ export declare const XAI_OAUTH_CLIENT_ID = "b1a00492-073a-47ea-816f-4c329264a828";
6
+ export declare const XAI_OAUTH_SCOPE = "openid profile email offline_access grok-cli:access api:access";
7
+ interface XaiDiscovery {
8
+ authorizationEndpoint: string;
9
+ tokenEndpoint: string;
10
+ }
11
+ export interface XaiOAuthFlowOptions {
12
+ extraAuthorizeParams?: Readonly<Record<string, string>>;
13
+ }
14
+ export interface XaiOAuthRefreshOptions {
15
+ signal?: AbortSignal;
16
+ extraTokenParams?: Readonly<Record<string, string>>;
17
+ }
18
+ export declare function discoverXaiOAuthEndpoints(signal?: AbortSignal): Promise<XaiDiscovery>;
19
+ export declare class XaiOAuthFlow extends OAuthCallbackFlow {
20
+ #private;
21
+ constructor(ctrl: OAuthController, options?: XaiOAuthFlowOptions);
22
+ generateAuthUrl(state: string, redirectUri: string): Promise<{
23
+ url: string;
24
+ instructions?: string;
25
+ }>;
26
+ exchangeToken(code: string, _state: string, redirectUri: string): Promise<OAuthCredentials>;
27
+ }
28
+ export declare function loginXai(ctrl: OAuthController, options?: XaiOAuthFlowOptions): Promise<OAuthCredentials>;
29
+ export declare function refreshXaiToken(refreshToken: string, options?: AbortSignal | XaiOAuthRefreshOptions): Promise<OAuthCredentials>;
30
+ export {};
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Xiaomi MiMo login flow.
3
+ *
4
+ * Xiaomi MiMo provides OpenAI-compatible models via
5
+ * https://api.xiaomimimo.com/v1.
6
+ *
7
+ * Standard Xiaomi login opens the pay-as-you-go API key console. Token Plan
8
+ * login opens plan management so users copy the regional `tp-...` key.
9
+ */
10
+ import type { OAuthController } from "./types";
11
+ /** Region codes accepted by the Xiaomi Token Plan login flow. */
12
+ export type XiaomiTokenPlanRegion = "sgp" | "ams" | "cn";
13
+ /**
14
+ * Login to Xiaomi MiMo.
15
+ *
16
+ * Opens browser to API keys page, prompts user to paste their API key.
17
+ * Returns the API key directly (not OAuthCredentials - this isn't OAuth).
18
+ */
19
+ export declare function loginXiaomi(options: OAuthController): Promise<string>;
20
+ /**
21
+ * Login to a regional Xiaomi Token Plan endpoint.
22
+ *
23
+ * Prompts for a token-plan API key and validates it against the selected region.
24
+ */
25
+ export declare function loginXiaomiTokenPlan(options: OAuthController, region: XiaomiTokenPlanRegion): Promise<string>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Z.AI login flow.
3
+ *
4
+ * Z.AI is a platform that provides access to GLM models through an OpenAI-compatible API.
5
+ * API docs: https://docs.z.ai/guides/overview/quick-start
6
+ *
7
+ * This is not OAuth - it's a simple API key flow:
8
+ * 1. User gets their API key from https://z.ai/settings/api-keys
9
+ * 2. User pastes the API key into the CLI
10
+ */
11
+ import type { OAuthController } from "./types";
12
+ /**
13
+ * Login to Z.AI.
14
+ *
15
+ * Opens browser to API keys page, prompts user to paste their API key.
16
+ * Returns the API key directly (not OAuthCredentials - this isn't OAuth).
17
+ */
18
+ export declare function loginZai(options: OAuthController): Promise<string>;
@@ -0,0 +1 @@
1
+ export declare const loginZenMux: (options: import("./types").OAuthController) => Promise<string>;
@@ -0,0 +1,14 @@
1
+ import type { AssistantMessage } from "../types";
2
+ import type { TransportFailureFacts } from "./fallback-transport";
3
+ export declare function classifyContextOverflow(message: AssistantMessage, transportFailure?: TransportFailureFacts, contextWindow?: number): boolean;
4
+ /**
5
+ * Check if an assistant message represents a context overflow error.
6
+ *
7
+ * Callers with normalized transport facts should use {@link classifyContextOverflow}
8
+ * so typed provider codes take precedence over error prose.
9
+ */
10
+ export declare function isContextOverflow(message: AssistantMessage, contextWindow?: number): boolean;
11
+ /**
12
+ * Get the overflow patterns for testing purposes.
13
+ */
14
+ export declare function getOverflowPatterns(): RegExp[];
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Shared `host:port` parser used by the auth-broker and auth-gateway boot
3
+ * paths. Centralized so the two servers can't drift on what they accept (the
4
+ * gateway used to silently allow empty hostnames; this fixes it).
5
+ */
6
+ export interface ParsedBind {
7
+ hostname: string;
8
+ port: number;
9
+ }
10
+ /**
11
+ * Parse a `host:port` (or bare `port`, which assumes loopback) string.
12
+ *
13
+ * Accepts:
14
+ * - `"4000"` → `127.0.0.1:4000`
15
+ * - `"0.0.0.0:4000"` → as written
16
+ * - `"[::1]:4000"` → as written (brackets retained, Bun handles them)
17
+ *
18
+ * Rejects:
19
+ * - empty input
20
+ * - empty hostname (`":4000"`)
21
+ * - non-integer / out-of-range port
22
+ */
23
+ export declare function parseBind(raw: string): ParsedBind;
@@ -0,0 +1,3 @@
1
+ import type { Api, Model, ProviderResponseMetadata, StreamOptions } from "../types";
2
+ export declare function normalizeProviderResponse(response: Response, requestId?: string | null, metadata?: Record<string, unknown>): ProviderResponseMetadata;
3
+ export declare function notifyProviderResponse(options: Pick<StreamOptions, "onResponse"> | undefined, response: Response, model?: Model<Api>, requestId?: string | null, metadata?: Record<string, unknown>): Promise<void>;
@@ -0,0 +1,3 @@
1
+ export type HeadersLike = Headers | Record<string, string | undefined> | undefined | null;
2
+ export declare function formatErrorMessageWithRetryAfter(error: unknown, headers?: HeadersLike): string;
3
+ export declare function getRetryAfterMsFromHeaders(headers: HeadersLike): number | undefined;
@@ -0,0 +1 @@
1
+ export declare function resolveRetryBudget(value: number | undefined, fallback: number): number;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * GitHub Copilot intermittently rejects preview models (gpt-5.3-OpenAI code backend,
3
+ * gpt-5.4, gpt-5.4-mini, ...) with HTTP 400 `model_not_supported`, even
4
+ * though the model is listed as enabled on the user's account via `/models`.
5
+ *
6
+ * Root cause: Copilot's request-routing backend is rolled out per OAuth
7
+ * client. Our OAuth client id is shared with opencode; VS Code uses its own
8
+ * client and sees full availability, so the same account may succeed in VS
9
+ * Code and flap between 200/400 here. See opencode#13313 and copilot-cli#2597.
10
+ *
11
+ * Retrying the identical request 2-3 times almost always lands on a backend
12
+ * that has the model, so we wrap the initial request with a short retry loop.
13
+ */
14
+ export declare function isCopilotTransientModelError(error: unknown): boolean;
15
+ /**
16
+ * Wrap an initial Copilot request so transient `model_not_supported` 400s are
17
+ * retried a small number of times. No-op for non-Copilot providers.
18
+ *
19
+ * The callback **MUST** create a fresh in-flight request each invocation — a
20
+ * once-consumed AsyncIterable cannot be re-iterated.
21
+ */
22
+ export declare function callWithCopilotModelRetry<T>(fn: () => Promise<T>, options: {
23
+ provider: string;
24
+ signal?: AbortSignal;
25
+ retryBaseDelayMs?: number;
26
+ fallbackManaged?: boolean;
27
+ }): Promise<T>;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Set when callers want to globally bypass OpenAI strict-mode enforcement
3
+ * (e.g. for debugging a provider that misreports strict support, or when
4
+ * comparing strict vs non-strict outputs).
5
+ *
6
+ * Honored by every provider that emits `strict: true` on its function tools —
7
+ * see `openai-completions`, `openai-responses`, `OpenAI code provider-responses`, and
8
+ * the strict candidate selection in `anthropic`.
9
+ */
10
+ export declare const NO_STRICT: boolean;
11
+ /**
12
+ * Consolidated helper for OpenAI-style strict schema enforcement.
13
+ *
14
+ * Each provider computes its own `strict` boolean (logic differs), then calls
15
+ * this to handle the tryEnforceStrictSchema dance uniformly:
16
+ * - Draft-07-shaped inputs are upgraded to draft 2020-12 first.
17
+ * - If `strict` is false, passes the upgraded schema through unchanged.
18
+ * - If `strict` is true, attempts to enforce strict mode; falls back to
19
+ * non-strict if the schema isn't representable.
20
+ */
21
+ export declare function adaptSchemaForStrict(schema: Record<string, unknown>, strict: boolean): {
22
+ schema: Record<string, unknown>;
23
+ strict: boolean;
24
+ };