@oh-my-pi/pi-ai 17.0.8 → 17.1.0
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 +37 -0
- package/README.md +3 -0
- package/dist/types/auth-broker/discover.d.ts +4 -0
- package/dist/types/auth-broker/remote-store.d.ts +14 -2
- package/dist/types/auth-storage.d.ts +45 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/providers/google-shared.d.ts +11 -0
- package/dist/types/providers/openai-chat-wire.d.ts +25 -0
- package/dist/types/providers/openai-completions.d.ts +3 -0
- package/dist/types/providers/openai-responses-wire.d.ts +17 -0
- package/dist/types/providers/openai-responses.d.ts +8 -2
- package/dist/types/providers/openai-shared.d.ts +32 -11
- package/dist/types/providers/transform-messages.d.ts +7 -0
- package/dist/types/registry/alibaba-token-plan.d.ts +7 -0
- package/dist/types/registry/meta.d.ts +7 -0
- package/dist/types/registry/oauth/google-gemini-cli.d.ts +12 -0
- package/dist/types/registry/oauth/google-oauth-shared.d.ts +35 -1
- package/dist/types/registry/oauth/xai-oauth.d.ts +25 -9
- package/dist/types/registry/oauth/zai.d.ts +25 -0
- package/dist/types/registry/registry.d.ts +15 -0
- package/dist/types/registry/zai.d.ts +8 -0
- package/dist/types/types.d.ts +27 -0
- package/dist/types/usage/alibaba-token-plan.d.ts +3 -0
- package/dist/types/usage/synthetic.d.ts +2 -0
- package/dist/types/usage/xai-oauth.d.ts +12 -0
- package/dist/types/usage.d.ts +11 -0
- package/package.json +4 -4
- package/src/auth-broker/discover.ts +56 -1
- package/src/auth-broker/remote-store.ts +93 -13
- package/src/auth-storage.ts +258 -15
- package/src/index.ts +2 -0
- package/src/providers/__tests__/kimi-code-thinking.test.ts +44 -0
- package/src/providers/amazon-bedrock.ts +54 -37
- package/src/providers/azure-openai-responses.ts +6 -0
- package/src/providers/gitlab-duo.ts +4 -0
- package/src/providers/google-shared.ts +30 -0
- package/src/providers/openai-anthropic-shim.ts +2 -0
- package/src/providers/openai-chat-server.ts +30 -0
- package/src/providers/openai-chat-wire.ts +12 -0
- package/src/providers/openai-completions.ts +70 -2
- package/src/providers/openai-responses-server.ts +22 -0
- package/src/providers/openai-responses-wire.ts +8 -0
- package/src/providers/openai-responses.ts +227 -8
- package/src/providers/openai-shared.ts +121 -11
- package/src/providers/pi-native-client.ts +9 -0
- package/src/providers/pi-native-server.ts +3 -0
- package/src/providers/transform-messages.ts +64 -23
- package/src/registry/alibaba-token-plan.ts +43 -0
- package/src/registry/meta.ts +22 -0
- package/src/registry/oauth/__tests__/xai-oauth.test.ts +214 -5
- package/src/registry/oauth/callback-server.ts +19 -12
- package/src/registry/oauth/google-antigravity.ts +34 -18
- package/src/registry/oauth/google-gemini-cli.ts +56 -32
- package/src/registry/oauth/google-oauth-shared.ts +107 -21
- package/src/registry/oauth/xai-oauth.ts +146 -17
- package/src/registry/oauth/zai.ts +285 -0
- package/src/registry/registry.ts +6 -1
- package/src/registry/zai.ts +14 -0
- package/src/stream.ts +53 -1
- package/src/types.ts +28 -0
- package/src/usage/alibaba-token-plan.ts +202 -0
- package/src/usage/claude.ts +125 -1
- package/src/usage/synthetic.ts +180 -0
- package/src/usage/xai-oauth.ts +414 -0
- package/src/usage/zai.ts +9 -3
- package/src/usage.ts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,44 @@
|
|
|
4
4
|
|
|
5
5
|
### Fixed
|
|
6
6
|
|
|
7
|
+
- Fixed stateful OpenAI Responses explicit cache breakpoints being restored onto edited historical messages, ensuring full replays recompute the latest stable cache boundary.
|
|
8
|
+
|
|
9
|
+
## [17.1.0] - 2026-07-24
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Added support for caller-owned `cachedContent` on Google Generative AI and Google Vertex AI `GenerateContent` options, allowing passing of opaque cache resource names.
|
|
14
|
+
- Added Anthropic extra-usage reporting across CLI, interactive, and ACP usage endpoints, normalizing the authoritative `spend` payload into a 'Claude Extra Usage' USD row with accurate limit, remaining, and status details.
|
|
15
|
+
- Added process-scoped OAuth account pools for trusted auth-broker clients via `OMP_AUTH_BROKER_ACCOUNT_POOL_FILE` to filter snapshots, updates, refreshes, and usage reports to selected OAuth identities.
|
|
16
|
+
- Added opt-in Vercel AI Gateway automatic prompt caching for OpenAI Chat Completions, including support for cache anchors and cache lifetimes.
|
|
17
|
+
- Added opt-in explicit prompt-cache controls for OpenAI GPT-5.6+ Responses and Chat Completions, supporting stable boundary selection, stateful Responses markers, and future GPT-5.x/6.x models.
|
|
18
|
+
- Added support for forwarding `statefulResponses` through `streamSimple` to allow diagnostic callers to explicitly disable OpenAI Responses `previous_response_id` chaining.
|
|
19
|
+
- Added native QwenCloud Token Plan support, including API-key login, model discovery, and an optional interactive console-Cookie prompt for quota reporting.
|
|
20
|
+
- Added interactive Meta Model API key login and support for `MODEL_API_KEY` and `META_API_KEY` environment variables.
|
|
21
|
+
- Added model-scoped usage health tracking and same-provider reselection for native coding-plan credential pools.
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- Fixed AWS Bedrock cache checkpoints to use resolved model compatibility, falling back to the provider-default 5-minute cache for unsupported 1-hour retentions, emitting AWS-recommended explicit checkpoints for Nova models (Lite, Micro, Pro, Premier, Nova 2 Lite), and honoring configured checkpoint maxima.
|
|
26
|
+
- Fixed Pi-native and compatibility-wrapper requests dropping cache controls required by `omp bench --cache` to preserve explicit prompt-cache affinity and allow disabling OpenAI Responses chaining.
|
|
27
|
+
- Fixed outbound credential-pattern redaction running unconditionally; it is now opt-in via `configureCredentialRedaction` and disabled by default.
|
|
28
|
+
- Fixed SuperGrok (`xai-oauth`) `/usage` reporting for unified-billing accounts by falling back to the default monthly limit and usage payload when credit usage percentages are absent.
|
|
29
|
+
- Fixed sessions wedging with a `400 Invalid signature in thinking block` error when switching Anthropic-compatible providers by stripping signatures whose issuing provider differs from the target.
|
|
30
|
+
- Fixed OAuth callback servers aborting login on premature invalid callbacks, and restricted `localhost` callback listeners to the IPv4 loopback interface.
|
|
31
|
+
- Fixed Google Gemini CLI and Antigravity OAuth login hanging indefinitely during Cloud Code Assist project provisioning by introducing request timeouts, cancellation checks, and bounded polling.
|
|
32
|
+
|
|
33
|
+
## [17.0.9] - 2026-07-23
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
|
|
37
|
+
- Added Synthetic (synthetic.new) usage provider: `/usage` now reports the rolling 5-hour request limit and weekly credit quota via `GET /v2/quotas`, including per-tick regeneration rates in the window labels.
|
|
38
|
+
- Added optional `UsageWindow.resetLabel` so rolling windows can render their countdown with an accurate verb (e.g. "tick in 12m" / "regen in 51m" instead of "resets in") — both quota windows on Synthetic regenerate incrementally rather than hard-resetting.
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
|
|
7
42
|
- Fixed GitHub Copilot OpenAI-compatible requests being rejected when the session's native OpenAI service tier was set to `priority` ([#5160](https://github.com/can1357/oh-my-pi/pull/5160) by [@audreyt](https://github.com/audreyt)).
|
|
43
|
+
- Fixed OpenAI Responses token-cap truncations suppressing fully streamed function and custom tool calls whose inputs are complete.
|
|
44
|
+
- Added SuperGrok (`xai-oauth`) usage tracking for weekly credits, product limits, and positive on-demand caps.
|
|
8
45
|
|
|
9
46
|
## [17.0.8] - 2026-07-22
|
|
10
47
|
|
package/README.md
CHANGED
|
@@ -73,6 +73,8 @@ Unified LLM API with automatic model discovery, provider configuration, token an
|
|
|
73
73
|
- **Xiaomi MiMo** (requires `XIAOMI_API_KEY`)
|
|
74
74
|
- **ZenMux** (requires `ZENMUX_API_KEY`)
|
|
75
75
|
- **Qwen Portal** (supports `QWEN_OAUTH_TOKEN` or `QWEN_PORTAL_API_KEY`)
|
|
76
|
+
- **QwenCloud Token Plan** (supports `/login alibaba-token-plan`, `ALIBABA_TOKEN_PLAN_API_KEY`, or `BAILIAN_TOKEN_PLAN_API_KEY`; interactive login optionally stores a `home.qwencloud.com` Cookie request header for best-effort 5-hour and 7-day quota reporting)
|
|
77
|
+
To enable quota reporting, sign in to the Token Plan dashboard, copy the `Cookie` request-header value from a `home.qwencloud.com` request in browser developer tools, and paste it at the second login prompt. Press Enter to skip; the Cookie is sensitive and session-lived, so rerun login when it expires.
|
|
76
78
|
- **Cloudflare AI Gateway** (requires `CLOUDFLARE_AI_GATEWAY_API_KEY` and provider-specific gateway base URL)
|
|
77
79
|
- **Ollama** (local OpenAI-compatible runtime; optional `OLLAMA_API_KEY`)
|
|
78
80
|
- **Ollama Cloud** (hosted native Ollama API; requires `OLLAMA_CLOUD_API_KEY`)
|
|
@@ -953,6 +955,7 @@ In Node.js environments, you can set environment variables to avoid passing API
|
|
|
953
955
|
| Ollama | `OLLAMA_API_KEY` (optional for local deployments) |
|
|
954
956
|
| Ollama Cloud | `OLLAMA_CLOUD_API_KEY` |
|
|
955
957
|
| Qwen Portal | `QWEN_OAUTH_TOKEN` or `QWEN_PORTAL_API_KEY` |
|
|
958
|
+
| QwenCloud Token Plan | `ALIBABA_TOKEN_PLAN_API_KEY` or `BAILIAN_TOKEN_PLAN_API_KEY` |
|
|
956
959
|
| zAI | `ZAI_API_KEY` |
|
|
957
960
|
| Umans AI Coding Plan | `UMANS_AI_CODING_PLAN_API_KEY` |
|
|
958
961
|
| MiniMax Code | `MINIMAX_CODE_API_KEY` (international) or `MINIMAX_CODE_CN_API_KEY` (China) |
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AuthStorage } from "../auth-storage.js";
|
|
2
|
+
import { type AuthBrokerAccountPool } from "./remote-store.js";
|
|
2
3
|
export interface AuthBrokerClientConfig {
|
|
3
4
|
url: string;
|
|
4
5
|
token: string;
|
|
@@ -12,9 +13,12 @@ export interface DiscoverAuthStorageOptions {
|
|
|
12
13
|
configValueResolver?: (config: string) => Promise<string | undefined>;
|
|
13
14
|
cachePath?: string;
|
|
14
15
|
sourceLabel?: string;
|
|
16
|
+
/** Programmatic pool for SDK hosts. Takes precedence over the environment file. */
|
|
17
|
+
accountPool?: AuthBrokerAccountPool;
|
|
15
18
|
}
|
|
16
19
|
/** Path to the local bearer token file. Created by `omp auth-broker token`. */
|
|
17
20
|
export declare function getAuthBrokerTokenFilePath(): string;
|
|
21
|
+
export declare function loadAuthBrokerAccountPool(): Promise<AuthBrokerAccountPool | undefined>;
|
|
18
22
|
/**
|
|
19
23
|
* Resolve broker connection configuration using the same precedence as the TUI:
|
|
20
24
|
*
|
|
@@ -4,6 +4,12 @@ import type { Provider } from "../types.js";
|
|
|
4
4
|
import type { UsageReport } from "../usage.js";
|
|
5
5
|
import { type AuthBrokerClient } from "./client.js";
|
|
6
6
|
import type { SnapshotResponse } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Per-provider OAuth identities visible to this trusted broker client.
|
|
9
|
+
* Missing providers are unrestricted; an empty set excludes that provider's
|
|
10
|
+
* OAuth credentials. API keys are never filtered.
|
|
11
|
+
*/
|
|
12
|
+
export type AuthBrokerAccountPool = ReadonlyMap<string, ReadonlySet<string>>;
|
|
7
13
|
export interface RemoteAuthCredentialStoreOptions {
|
|
8
14
|
client: AuthBrokerClient;
|
|
9
15
|
/**
|
|
@@ -17,10 +23,16 @@ export interface RemoteAuthCredentialStoreOptions {
|
|
|
17
23
|
*/
|
|
18
24
|
streamSnapshots?: boolean;
|
|
19
25
|
/**
|
|
20
|
-
* Called
|
|
21
|
-
*
|
|
26
|
+
* Called with each broker-sourced raw full snapshot after the filtered
|
|
27
|
+
* public view is applied. The constructor's initial snapshot intentionally
|
|
28
|
+
* does not trigger this hook.
|
|
22
29
|
*/
|
|
23
30
|
onSnapshot?: (snapshot: SnapshotResponse, generation: number) => void;
|
|
31
|
+
/**
|
|
32
|
+
* OAuth identities visible through this store. This is a trusted-client
|
|
33
|
+
* routing policy, not broker authorization.
|
|
34
|
+
*/
|
|
35
|
+
accountPool?: AuthBrokerAccountPool;
|
|
24
36
|
}
|
|
25
37
|
export declare class RemoteAuthCredentialStore implements AuthCredentialStore {
|
|
26
38
|
#private;
|
|
@@ -457,6 +457,27 @@ export interface UsageLimitMarkResult {
|
|
|
457
457
|
switched: boolean;
|
|
458
458
|
retryAtMs?: number;
|
|
459
459
|
}
|
|
460
|
+
export type ModelUsageHealthState = "healthy" | "reserve" | "depleted" | "unknown";
|
|
461
|
+
export interface ModelUsageAccountHealth {
|
|
462
|
+
credentialId: number;
|
|
463
|
+
credentialType: AuthCredential["type"];
|
|
464
|
+
/** True when this credential is currently sticky for options.sessionId. */
|
|
465
|
+
selected?: true;
|
|
466
|
+
state: ModelUsageHealthState;
|
|
467
|
+
remainingFraction?: number;
|
|
468
|
+
resetsAt?: number;
|
|
469
|
+
}
|
|
470
|
+
export interface ModelUsageHealth {
|
|
471
|
+
state: ModelUsageHealthState;
|
|
472
|
+
accounts: ModelUsageAccountHealth[];
|
|
473
|
+
}
|
|
474
|
+
export interface ModelUsageHealthOptions {
|
|
475
|
+
modelId?: string;
|
|
476
|
+
sessionId?: string;
|
|
477
|
+
baseUrl?: string;
|
|
478
|
+
reserveFraction: number;
|
|
479
|
+
signal?: AbortSignal;
|
|
480
|
+
}
|
|
460
481
|
type AuthApiKeyOptions = {
|
|
461
482
|
baseUrl?: string;
|
|
462
483
|
modelId?: string;
|
|
@@ -825,6 +846,30 @@ export declare class AuthStorage {
|
|
|
825
846
|
* providers without a usage API) — the latter never warrants a usage row.
|
|
826
847
|
*/
|
|
827
848
|
usageProviderFor(provider: Provider): UsageProvider | undefined;
|
|
849
|
+
/**
|
|
850
|
+
* Return model ids whose live reports map to a quantitative usage scope.
|
|
851
|
+
* Provider strategies supply model/tier mapping when available; otherwise
|
|
852
|
+
* only explicitly matching model ids and account-wide shared limits count.
|
|
853
|
+
* Label-only or ambiguous tier limits are excluded rather than guessed.
|
|
854
|
+
*/
|
|
855
|
+
getUsageReportingModelIds(provider: Provider, modelIds: readonly string[], reports: readonly UsageReport[]): string[];
|
|
856
|
+
/**
|
|
857
|
+
* Inspect the credential pool that {@link getApiKey} would use for one model
|
|
858
|
+
* without advancing round-robin state or changing session stickiness.
|
|
859
|
+
*
|
|
860
|
+
* Pool aggregation is deliberately conservative: one healthy sibling makes
|
|
861
|
+
* the model healthy, while any unknown sibling prevents a depleted/reserve
|
|
862
|
+
* conclusion. Static runtime/config/env credentials return unknown because
|
|
863
|
+
* they bypass the managed account pool.
|
|
864
|
+
*/
|
|
865
|
+
getModelUsageHealth(provider: Provider, options: ModelUsageHealthOptions): Promise<ModelUsageHealth>;
|
|
866
|
+
/**
|
|
867
|
+
* Release a session's sticky credential so its next {@link getApiKey} call
|
|
868
|
+
* re-runs native pool ranking. This never blocks or penalizes the released
|
|
869
|
+
* account; usage-aware routing uses it when another sibling has more
|
|
870
|
+
* headroom, before considering a model/provider fallback.
|
|
871
|
+
*/
|
|
872
|
+
releaseSessionCredentialForReselection(provider: string, sessionId: string): boolean;
|
|
828
873
|
fetchUsageReports(options?: {
|
|
829
874
|
baseUrlResolver?: (provider: Provider) => string | undefined;
|
|
830
875
|
/** Caller's cancel signal; only rejects this caller, never the shared upstream fetch. */
|
package/dist/types/index.d.ts
CHANGED
|
@@ -39,6 +39,8 @@ export * from "./usage/ollama.js";
|
|
|
39
39
|
export * from "./usage/openai-codex.js";
|
|
40
40
|
export * from "./usage/openai-codex-reset.js";
|
|
41
41
|
export * from "./usage/opencode-go.js";
|
|
42
|
+
export * from "./usage/synthetic.js";
|
|
43
|
+
export * from "./usage/xai-oauth.js";
|
|
42
44
|
export * from "./usage/zai.js";
|
|
43
45
|
export * from "./utils/anthropic-auth.js";
|
|
44
46
|
export * from "./utils/event-stream.js";
|
|
@@ -37,6 +37,17 @@ export interface GoogleSharedStreamOptions extends StreamOptions {
|
|
|
37
37
|
hideThinkingSummary?: boolean;
|
|
38
38
|
/** Gemini/Vertex serving tier (`flex`/`priority`); other values are omitted. */
|
|
39
39
|
serviceTier?: ServiceTier;
|
|
40
|
+
/**
|
|
41
|
+
* Caller-owned Google context-cache resource name for GenerateContent.
|
|
42
|
+
* Passed through opaquely as the wire `cachedContent` field on
|
|
43
|
+
* `google-generative-ai` and `google-vertex` only. OMP does not create,
|
|
44
|
+
* refresh, validate model/project/location compatibility, or delete the
|
|
45
|
+
* resource — callers own that lifecycle.
|
|
46
|
+
*
|
|
47
|
+
* @see https://ai.google.dev/api/generate-content
|
|
48
|
+
* @see `@google/genai` `GenerateContentConfig.cachedContent`
|
|
49
|
+
*/
|
|
50
|
+
cachedContent?: string;
|
|
40
51
|
}
|
|
41
52
|
/**
|
|
42
53
|
* Determines whether a streamed Gemini `Part` should be treated as "thinking".
|
|
@@ -99,12 +99,20 @@ export interface ChatCompletionContentPartText {
|
|
|
99
99
|
text: string;
|
|
100
100
|
/** Always `text`. */
|
|
101
101
|
type: "text";
|
|
102
|
+
/** Explicit OpenAI prompt-cache breakpoint. */
|
|
103
|
+
prompt_cache_breakpoint?: {
|
|
104
|
+
mode: "explicit";
|
|
105
|
+
};
|
|
102
106
|
}
|
|
103
107
|
/** Image content part. */
|
|
104
108
|
export interface ChatCompletionContentPartImage {
|
|
105
109
|
image_url: ChatCompletionContentPartImageImageURL;
|
|
106
110
|
/** Always `image_url`. */
|
|
107
111
|
type: "image_url";
|
|
112
|
+
/** Explicit OpenAI prompt-cache breakpoint. */
|
|
113
|
+
prompt_cache_breakpoint?: {
|
|
114
|
+
mode: "explicit";
|
|
115
|
+
};
|
|
108
116
|
}
|
|
109
117
|
/** SDK `ChatCompletionContentPartImage.ImageURL`. */
|
|
110
118
|
export interface ChatCompletionContentPartImageImageURL {
|
|
@@ -118,6 +126,10 @@ export interface ChatCompletionContentPartInputAudio {
|
|
|
118
126
|
input_audio: ChatCompletionContentPartInputAudioInputAudio;
|
|
119
127
|
/** Always `input_audio`. */
|
|
120
128
|
type: "input_audio";
|
|
129
|
+
/** Explicit OpenAI prompt-cache breakpoint. */
|
|
130
|
+
prompt_cache_breakpoint?: {
|
|
131
|
+
mode: "explicit";
|
|
132
|
+
};
|
|
121
133
|
}
|
|
122
134
|
/** SDK `ChatCompletionContentPartInputAudio.InputAudio`. */
|
|
123
135
|
export interface ChatCompletionContentPartInputAudioInputAudio {
|
|
@@ -131,6 +143,10 @@ export interface ChatCompletionContentPartFile {
|
|
|
131
143
|
file: ChatCompletionContentPartFileFile;
|
|
132
144
|
/** Always `file`. */
|
|
133
145
|
type: "file";
|
|
146
|
+
/** Explicit OpenAI prompt-cache breakpoint. */
|
|
147
|
+
prompt_cache_breakpoint?: {
|
|
148
|
+
mode: "explicit";
|
|
149
|
+
};
|
|
134
150
|
}
|
|
135
151
|
/** SDK `ChatCompletionContentPart.File.File`. */
|
|
136
152
|
export interface ChatCompletionContentPartFileFile {
|
|
@@ -147,6 +163,10 @@ export interface ChatCompletionContentPartRefusal {
|
|
|
147
163
|
refusal: string;
|
|
148
164
|
/** Always `refusal`. */
|
|
149
165
|
type: "refusal";
|
|
166
|
+
/** Explicit OpenAI prompt-cache breakpoint. */
|
|
167
|
+
prompt_cache_breakpoint?: {
|
|
168
|
+
mode: "explicit";
|
|
169
|
+
};
|
|
150
170
|
}
|
|
151
171
|
/** User-message content part union. */
|
|
152
172
|
export type ChatCompletionContentPart = ChatCompletionContentPartText | ChatCompletionContentPartImage | ChatCompletionContentPartInputAudio | ChatCompletionContentPartFile;
|
|
@@ -598,6 +618,11 @@ export interface ChatCompletionCreateParamsBase {
|
|
|
598
618
|
prompt_cache_key?: string;
|
|
599
619
|
/** Retention policy for the prompt cache; `24h` enables extended caching. */
|
|
600
620
|
prompt_cache_retention?: "in_memory" | "24h" | null;
|
|
621
|
+
/** Explicit prompt-cache mode and minimum lifetime for GPT-5.6+ models. */
|
|
622
|
+
prompt_cache_options?: {
|
|
623
|
+
mode: "implicit" | "explicit";
|
|
624
|
+
ttl?: "30m";
|
|
625
|
+
};
|
|
601
626
|
/** Constrains effort on reasoning for reasoning models. */
|
|
602
627
|
reasoning_effort?: ReasoningEffort | null;
|
|
603
628
|
/** Output format: text, JSON mode, or Structured Outputs JSON schema. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ResolvedOpenAICompat } from "@oh-my-pi/pi-catalog/types";
|
|
2
2
|
import type { AssistantMessage, Context, Model, ServiceTier, StreamFunction, StreamOptions, ToolChoice } from "../types.js";
|
|
3
3
|
import type { ChatCompletionMessageParam } from "./openai-chat-wire.js";
|
|
4
|
+
import { type OpenAIPromptCacheOptions } from "./openai-shared.js";
|
|
4
5
|
export { applyOpenRouterRoutingVariant } from "./openai-shared.js";
|
|
5
6
|
/**
|
|
6
7
|
* Identify "real progress" stream chunks vs. keepalives, role-only preambles,
|
|
@@ -33,6 +34,8 @@ export interface OpenAICompletionsOptions extends StreamOptions {
|
|
|
33
34
|
* with the variant baked in).
|
|
34
35
|
*/
|
|
35
36
|
openrouterVariant?: string;
|
|
37
|
+
/** Opt-in GPT-5.6+ prompt-cache policy. Unsupported explicit mode fails locally. */
|
|
38
|
+
promptCache?: OpenAIPromptCacheOptions;
|
|
36
39
|
}
|
|
37
40
|
/**
|
|
38
41
|
* Public entry: wrap the single-attempt streamer with bounded empty-completion
|
|
@@ -2815,6 +2815,10 @@ export interface ResponseInputFile {
|
|
|
2815
2815
|
* The name of the file to be sent to the model.
|
|
2816
2816
|
*/
|
|
2817
2817
|
filename?: string;
|
|
2818
|
+
/** Explicit OpenAI prompt-cache breakpoint. */
|
|
2819
|
+
prompt_cache_breakpoint?: {
|
|
2820
|
+
mode: "explicit";
|
|
2821
|
+
};
|
|
2818
2822
|
}
|
|
2819
2823
|
/**
|
|
2820
2824
|
* A file input to the model.
|
|
@@ -2870,6 +2874,10 @@ export interface ResponseInputImage {
|
|
|
2870
2874
|
* encoded image in a data URL.
|
|
2871
2875
|
*/
|
|
2872
2876
|
image_url?: string | null;
|
|
2877
|
+
/** Explicit OpenAI prompt-cache breakpoint. */
|
|
2878
|
+
prompt_cache_breakpoint?: {
|
|
2879
|
+
mode: "explicit";
|
|
2880
|
+
};
|
|
2873
2881
|
}
|
|
2874
2882
|
/**
|
|
2875
2883
|
* An image input to the model. Learn about
|
|
@@ -3543,6 +3551,10 @@ export interface ResponseInputText {
|
|
|
3543
3551
|
* The type of the input item. Always `input_text`.
|
|
3544
3552
|
*/
|
|
3545
3553
|
type: "input_text";
|
|
3554
|
+
/** Explicit OpenAI prompt-cache breakpoint. */
|
|
3555
|
+
prompt_cache_breakpoint?: {
|
|
3556
|
+
mode: "explicit";
|
|
3557
|
+
};
|
|
3546
3558
|
}
|
|
3547
3559
|
/**
|
|
3548
3560
|
* A text input to the model.
|
|
@@ -5700,6 +5712,11 @@ export interface ResponseCreateParamsBase {
|
|
|
5700
5712
|
* `prompt_cache_retention` is not specified.
|
|
5701
5713
|
*/
|
|
5702
5714
|
prompt_cache_retention?: "in_memory" | "24h" | null;
|
|
5715
|
+
/** Explicit prompt-cache mode and minimum lifetime for GPT-5.6+ models. */
|
|
5716
|
+
prompt_cache_options?: {
|
|
5717
|
+
mode: "implicit" | "explicit";
|
|
5718
|
+
ttl?: "30m";
|
|
5719
|
+
} | null;
|
|
5703
5720
|
/**
|
|
5704
5721
|
* **gpt-5 and o-series models only**
|
|
5705
5722
|
*
|
|
@@ -2,7 +2,7 @@ import type { Context, Model, OpenAICompat, ProviderSessionState, ServiceTier, S
|
|
|
2
2
|
import { type OpenAIResponsesToolChoice } from "../utils/tool-choice.js";
|
|
3
3
|
import { type OpenAIReasoningEffortFallbackState } from "./openai-reasoning-fallback.js";
|
|
4
4
|
import type { Tool as OpenAITool, ResponseCreateParamsStreaming, ResponseInput } from "./openai-responses-wire.js";
|
|
5
|
-
import { type OpenAIStrictToolsScope, type OpenAIStrictToolsState } from "./openai-shared.js";
|
|
5
|
+
import { type OpenAIPromptCacheOptions, type OpenAIStrictToolsScope, type OpenAIStrictToolsState } from "./openai-shared.js";
|
|
6
6
|
export interface OpenAIResponsesOptions extends StreamOptions {
|
|
7
7
|
reasoning?: "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
8
8
|
reasoningSummary?: "auto" | "detailed" | "concise" | null;
|
|
@@ -56,6 +56,8 @@ export interface OpenAIResponsesOptions extends StreamOptions {
|
|
|
56
56
|
* prompt_cache_key for prompt-cache routing).
|
|
57
57
|
*/
|
|
58
58
|
extraBody?: Record<string, unknown>;
|
|
59
|
+
/** Opt-in GPT-5.6+ prompt-cache policy. Unsupported explicit mode fails locally. */
|
|
60
|
+
promptCache?: OpenAIPromptCacheOptions;
|
|
59
61
|
}
|
|
60
62
|
interface OpenAIResponsesProviderSessionState extends ProviderSessionState, OpenAIStrictToolsState, OpenAIReasoningEffortFallbackState {
|
|
61
63
|
nativeHistoryReplayWarmed: boolean;
|
|
@@ -68,6 +70,7 @@ interface OpenAIResponsesChainState {
|
|
|
68
70
|
* `previous_response_id`.
|
|
69
71
|
*/
|
|
70
72
|
lastParams?: OpenAIResponsesSamplingParams;
|
|
73
|
+
lastPromptCacheBreakpointPolicy?: "latest-stable-message" | "none";
|
|
71
74
|
lastResponseId?: string;
|
|
72
75
|
/** Output items of the last response, in replay-sanitized form (matches next-turn input). */
|
|
73
76
|
lastResponseItems?: ResponseInput;
|
|
@@ -98,6 +101,9 @@ type OpenAIResponsesSamplingParams = ResponseCreateParamsStreaming & {
|
|
|
98
101
|
enabled: false;
|
|
99
102
|
};
|
|
100
103
|
cache_control?: OpenRouterAnthropicCacheControl;
|
|
104
|
+
caching?: "auto";
|
|
105
|
+
cache_anchor_items?: number;
|
|
106
|
+
cache_ttl?: "5m" | "1h";
|
|
101
107
|
};
|
|
102
108
|
/**
|
|
103
109
|
* Public entry: wrap the single-attempt Responses streamer with bounded
|
|
@@ -106,7 +112,7 @@ type OpenAIResponsesSamplingParams = ResponseCreateParamsStreaming & {
|
|
|
106
112
|
* Anthropic providers via `withEmptyCompletionRetry`.
|
|
107
113
|
*/
|
|
108
114
|
export declare const streamOpenAIResponses: StreamFunction<"openai-responses">;
|
|
109
|
-
export declare function buildParams(model: Model<"openai-responses">, context: Context, options: OpenAIResponsesOptions | undefined, providerSessionState: OpenAIResponsesProviderSessionState | undefined, strictToolsScope?: OpenAIStrictToolsScope, disableStrictToolsOverride?: boolean): {
|
|
115
|
+
export declare function buildParams(model: Model<"openai-responses">, context: Context, options: OpenAIResponsesOptions | undefined, providerSessionState: OpenAIResponsesProviderSessionState | undefined, strictToolsScope?: OpenAIStrictToolsScope, disableStrictToolsOverride?: boolean, statefulCacheBaseline?: ResponseInput): {
|
|
110
116
|
params: OpenAIResponsesSamplingParams;
|
|
111
117
|
strictToolsApplied: boolean;
|
|
112
118
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Effort } from "@oh-my-pi/pi-catalog/effort";
|
|
2
2
|
import type { OpenAICompat, OpenAIReasoningDisableMode, OpenAIStreamMarkupHealingPattern, OpenRouterRouting, ResolvedOpenAICompat, ResolvedOpenAIResponsesCompat, ResolvedOpenAISharedCompat, VercelGatewayRouting } from "@oh-my-pi/pi-catalog/types";
|
|
3
3
|
import { type Api, type AssistantMessage, type CacheRetention, type Context, type ImageContent, type Message, type MessageAttribution, type Model, type ServiceTier, type StopReason, type StreamOptions, type TextContent, type TextSignatureV1, type ThinkingContent, type Tool, type ToolCall, type ToolResultMessage, type Usage } from "../types.js";
|
|
4
|
+
export type { OpenAIPromptCacheOptions } from "../types.js";
|
|
4
5
|
import { kStreamingLastParseLen, kStreamingPartialJson } from "../utils/block-symbols.js";
|
|
5
6
|
import type { AssistantMessageEventStream } from "../utils/event-stream.js";
|
|
6
7
|
import type { CapturedHttpErrorResponse } from "../utils/http-inspector.js";
|
|
@@ -163,10 +164,7 @@ export declare function resolveOpenAIOutputTokenParam(input: ResolveOpenAIOutput
|
|
|
163
164
|
export interface OpenAIGatewayRoutingParams {
|
|
164
165
|
provider?: OpenRouterRouting;
|
|
165
166
|
providerOptions?: {
|
|
166
|
-
gateway?:
|
|
167
|
-
only?: string[];
|
|
168
|
-
order?: string[];
|
|
169
|
-
};
|
|
167
|
+
gateway?: Pick<VercelGatewayRouting, "only" | "order" | "caching">;
|
|
170
168
|
};
|
|
171
169
|
}
|
|
172
170
|
export interface OpenAIGatewayRoutingCompat {
|
|
@@ -177,12 +175,28 @@ export interface OpenAIGatewayRoutingCompat {
|
|
|
177
175
|
}
|
|
178
176
|
/**
|
|
179
177
|
* Apply gateway routing preferences to the request body. OpenRouter routes via
|
|
180
|
-
* the top-level `provider` field; the Vercel AI Gateway routes
|
|
181
|
-
* `providerOptions.gateway`.
|
|
182
|
-
|
|
183
|
-
|
|
178
|
+
* the top-level `provider` field; the Vercel AI Gateway routes Chat
|
|
179
|
+
* Completions through `providerOptions.gateway`.
|
|
180
|
+
*/
|
|
181
|
+
export declare function applyOpenAIGatewayRouting(params: OpenAIGatewayRoutingParams, compat: OpenAIGatewayRoutingCompat, cacheEnabled?: boolean): void;
|
|
182
|
+
export interface VercelResponsesCacheParams {
|
|
183
|
+
caching?: "auto";
|
|
184
|
+
cache_anchor_items?: number;
|
|
185
|
+
cache_ttl?: "5m" | "1h";
|
|
186
|
+
providerOptions?: {
|
|
187
|
+
gateway?: Pick<VercelGatewayRouting, "only" | "order">;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
export interface VercelResponsesCacheCompat {
|
|
191
|
+
isVercelGatewayHost: boolean;
|
|
192
|
+
vercelGatewayRouting?: VercelGatewayRouting;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Apply Vercel AI Gateway's Responses-only automatic cache controls and
|
|
196
|
+
* provider routing. Cache settings are top-level Responses fields, while
|
|
197
|
+
* `only` and `order` remain under `providerOptions.gateway`.
|
|
184
198
|
*/
|
|
185
|
-
export declare function
|
|
199
|
+
export declare function applyVercelResponsesCacheControls(params: VercelResponsesCacheParams, compat: VercelResponsesCacheCompat, cacheRetention?: CacheRetention): void;
|
|
186
200
|
export interface OpenAIExtraBodyOptions {
|
|
187
201
|
/**
|
|
188
202
|
* Fireworks rejects DeepSeek-style `thinking` toggles alongside OpenAI-style
|
|
@@ -315,6 +329,14 @@ export declare function disableChatCompletionsReasoningForDialect(params: OpenAI
|
|
|
315
329
|
* routes clamp to `model.maxTokens` instead.
|
|
316
330
|
*/
|
|
317
331
|
export declare function resolveOpenAICompletionsOutputClamp(model: Model<"openai-completions">, compat: ResolvedOpenAICompat): number | undefined;
|
|
332
|
+
/**
|
|
333
|
+
* Provider-specific Responses API output clamp.
|
|
334
|
+
*
|
|
335
|
+
* Meta documents a 131,072-token output limit for Muse Spark 1.1, so native
|
|
336
|
+
* Meta requests may use the model's full advertised cap instead of the
|
|
337
|
+
* conservative 64k OpenAI-compatible default.
|
|
338
|
+
*/
|
|
339
|
+
export declare function resolveOpenAIResponsesOutputClamp(model: Pick<Model, "provider" | "maxTokens">): number | undefined;
|
|
318
340
|
/**
|
|
319
341
|
* Enable `tool_stream` for Z.AI/GLM-5.2 reasoning models when tools are present
|
|
320
342
|
* (GLM-5.2 streams tool-call arguments incrementally and needs the flag to do so).
|
|
@@ -491,7 +513,7 @@ export declare function finalizePendingResponsesToolCalls(output: AssistantMessa
|
|
|
491
513
|
* re-samples instead of ending. Callers set `output.stopReason` from the wire
|
|
492
514
|
* status first via {@link mapOpenAIResponsesStopReason}.
|
|
493
515
|
*/
|
|
494
|
-
export declare function promoteResponsesToolUseStopReason(output: AssistantMessage, endTurn: boolean | undefined): void;
|
|
516
|
+
export declare function promoteResponsesToolUseStopReason(output: AssistantMessage, endTurn: boolean | undefined, promoteIncompleteToolUse?: boolean): void;
|
|
495
517
|
/** Initial empty `AssistantMessage` that streaming providers accumulate into. */
|
|
496
518
|
export declare function createInitialResponsesAssistantMessage(api: Api, provider: string, modelId: string): AssistantMessage;
|
|
497
519
|
/** Extension fields we add on top of `ResponseCreateParamsStreaming` across the Responses-family providers. */
|
|
@@ -566,4 +588,3 @@ export declare function buildResponsesDeltaInput<TItem extends ResponseInputItem
|
|
|
566
588
|
} | undefined, previousResponseItems: readonly TItem[] | undefined, current: {
|
|
567
589
|
input?: TItem[];
|
|
568
590
|
}): TItem[] | null;
|
|
569
|
-
export {};
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { Api, AssistantMessage, Message, Model } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Toggle outbound credential-pattern redaction. When disabled (the default),
|
|
4
|
+
* {@link redactSensitiveCredentials} and {@link redactSensitiveInObject} are
|
|
5
|
+
* pass-throughs and outbound messages/system prompts leave the process
|
|
6
|
+
* unmodified.
|
|
7
|
+
*/
|
|
8
|
+
export declare function configureCredentialRedaction(enabled: boolean): void;
|
|
2
9
|
export declare function redactSensitiveCredentials(text: string): string;
|
|
3
10
|
export declare function redactSensitiveInObject(val: unknown): {
|
|
4
11
|
result: unknown;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { OAuthController, OAuthLoginCallbacks } from "./oauth/types.js";
|
|
2
|
+
export declare function loginAlibabaTokenPlan(options: OAuthController): Promise<string>;
|
|
3
|
+
export declare const alibabaTokenPlanProvider: {
|
|
4
|
+
readonly id: "alibaba-token-plan";
|
|
5
|
+
readonly name: "QwenCloud Token Plan";
|
|
6
|
+
readonly login: (cb: OAuthLoginCallbacks) => Promise<string>;
|
|
7
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { OAuthLoginCallbacks } from "./oauth/types.js";
|
|
2
|
+
export declare const loginMeta: (options: import("./oauth/index.js").OAuthController) => Promise<string>;
|
|
3
|
+
export declare const metaProvider: {
|
|
4
|
+
readonly id: "meta";
|
|
5
|
+
readonly name: "Meta Model API";
|
|
6
|
+
readonly login: (cb: OAuthLoginCallbacks) => Promise<string>;
|
|
7
|
+
};
|
|
@@ -3,8 +3,20 @@
|
|
|
3
3
|
* Standard Gemini models only (gemini-2.0-flash, gemini-2.5-*)
|
|
4
4
|
*/
|
|
5
5
|
import type { OAuthController, OAuthCredentials } from "./types.js";
|
|
6
|
+
interface LongRunningOperationResponse {
|
|
7
|
+
name?: string;
|
|
8
|
+
done?: boolean;
|
|
9
|
+
response?: {
|
|
10
|
+
cloudaicompanionProject?: {
|
|
11
|
+
id?: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare const POLL_MAX_ATTEMPTS = 24;
|
|
16
|
+
export declare function pollOperation(operationName: string, headers: Record<string, string>, signal: AbortSignal | undefined, onProgress?: (message: string) => void): Promise<LongRunningOperationResponse>;
|
|
6
17
|
export declare function loginGeminiCli(ctrl: OAuthController): Promise<OAuthCredentials>;
|
|
7
18
|
/**
|
|
8
19
|
* Refresh Google Cloud Code Assist token
|
|
9
20
|
*/
|
|
10
21
|
export declare function refreshGoogleCloudToken(refreshToken: string, projectId: string): Promise<OAuthCredentials>;
|
|
22
|
+
export {};
|
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
import { OAuthCallbackFlow } from "./callback-server.js";
|
|
2
2
|
import type { OAuthController, OAuthCredentials } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Per-request timeout for the post-callback provisioning phase (token exchange,
|
|
5
|
+
* user-info, project discovery/onboarding, LRO polling). These Cloud Code
|
|
6
|
+
* Assist calls normally settle in well under this window; a longer stall means
|
|
7
|
+
* a hung endpoint that must surface a login error instead of hanging forever.
|
|
8
|
+
* The callback server's own 300s deadline covers only the browser-callback wait
|
|
9
|
+
* ({@link OAuthCallbackFlow}) and does not gate this phase.
|
|
10
|
+
*/
|
|
11
|
+
export declare const OAUTH_REQUEST_TIMEOUT_MS = 30000;
|
|
12
|
+
/** Options for {@link oauthFetch}. */
|
|
13
|
+
export interface OAuthFetchOptions {
|
|
14
|
+
/** Provider id recorded on any {@link AIError.OAuthError} raised. */
|
|
15
|
+
provider: string;
|
|
16
|
+
/** Controller signal; when it aborts, the in-flight request is cancelled. */
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
/** Override the per-request timeout (defaults to {@link OAUTH_REQUEST_TIMEOUT_MS}). */
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Throw {@link AIError.LoginCancelledError} when the controller signal has
|
|
23
|
+
* already aborted. Gates each provisioning round-trip, which the callback-wait
|
|
24
|
+
* cancellation checks in {@link OAuthCallbackFlow} do not reach.
|
|
25
|
+
*/
|
|
26
|
+
export declare function throwIfLoginCancelled(signal: AbortSignal | undefined): void;
|
|
27
|
+
/**
|
|
28
|
+
* `fetch` for the provisioning phase: composes the controller signal with a
|
|
29
|
+
* per-request timeout so a stalled endpoint aborts instead of hanging login,
|
|
30
|
+
* and user cancellation aborts the in-flight request. Cancellation surfaces as
|
|
31
|
+
* {@link AIError.LoginCancelledError}; a timeout surfaces as an
|
|
32
|
+
* {@link AIError.OAuthError} with `kind: "timeout"`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function oauthFetch(url: string, init: RequestInit, { provider, signal, timeoutMs }: OAuthFetchOptions): Promise<Response>;
|
|
3
35
|
export interface GoogleOAuthFlowConfig {
|
|
36
|
+
/** Provider id used in progress/error reporting and per-request fetches. */
|
|
37
|
+
provider: string;
|
|
4
38
|
clientId: string;
|
|
5
39
|
clientSecret: string;
|
|
6
40
|
authUrl: string;
|
|
@@ -8,7 +42,7 @@ export interface GoogleOAuthFlowConfig {
|
|
|
8
42
|
scopes: string[];
|
|
9
43
|
callbackPort: number;
|
|
10
44
|
callbackPath: string;
|
|
11
|
-
discoverProject: (accessToken: string, onProgress?: (message: string) => void) => Promise<string>;
|
|
45
|
+
discoverProject: (accessToken: string, onProgress?: (message: string) => void, signal?: AbortSignal) => Promise<string>;
|
|
12
46
|
}
|
|
13
47
|
export declare class GoogleOAuthFlow extends OAuthCallbackFlow {
|
|
14
48
|
private readonly config;
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import type { FetchImpl } from "../../types.js";
|
|
2
2
|
import type { OAuthController, OAuthCredentials } from "./types.js";
|
|
3
|
+
export declare function validateXAIEndpoint(url: string, field: string): string;
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* The discovery response is long-lived and its token endpoint receives every
|
|
7
|
-
* future refresh token. Rejecting non-HTTPS or non-`x.ai` / `*.x.ai` hosts
|
|
8
|
-
* pins that endpoint to the xAI auth origin.
|
|
9
|
-
*
|
|
10
|
-
* @throws Error with message `Invalid xAI <field>: <url>` when the URL fails
|
|
11
|
-
* either scheme or host validation.
|
|
5
|
+
* Pin SuperGrok billing URLs to HTTPS `grok.com` / `*.grok.com`.
|
|
6
|
+
* The CLI billing proxy is intentionally not on `*.x.ai`.
|
|
12
7
|
*/
|
|
13
|
-
export declare function
|
|
8
|
+
export declare function validateXAIBillingEndpoint(url: string, field?: string): string;
|
|
9
|
+
/** Decode an xAI access-token JWT payload without verifying its signature. */
|
|
10
|
+
export declare function parseXAIAccessTokenPayload(jwt: string): Record<string, unknown> | null;
|
|
14
11
|
/**
|
|
15
12
|
* Check whether a JWT access token is at or past its `exp` claim (with an
|
|
16
13
|
* optional refresh-skew margin).
|
|
@@ -19,6 +16,25 @@ export declare function validateXAIEndpoint(url: string, field: string): string;
|
|
|
19
16
|
* not token validation.
|
|
20
17
|
*/
|
|
21
18
|
export declare function isXAIAccessTokenExpiring(jwt: string, skewSeconds?: number): boolean;
|
|
19
|
+
/** Extract the stable xAI subject UUID from an access token. */
|
|
20
|
+
export declare function extractXAIAccessTokenSubject(jwt: string): string | undefined;
|
|
21
|
+
export interface XAIOAuthIdentity {
|
|
22
|
+
accountId?: string;
|
|
23
|
+
email?: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
}
|
|
26
|
+
/** Fetch optional OIDC userinfo for a valid xAI access token. */
|
|
27
|
+
export declare function fetchXAIOAuthIdentity(accessToken: string, fetchOverride?: FetchImpl, signal?: AbortSignal): Promise<XAIOAuthIdentity | null>;
|
|
28
|
+
/** Build the SuperGrok CLI billing URL. Pass `""` to omit `format` (unified monthly payload). */
|
|
29
|
+
export declare function buildXAICliBillingUrl(format?: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Headers for SuperGrok CLI billing (`cli-chat-proxy.grok.com`).
|
|
32
|
+
* Official Grok CLI also sends `X-XAI-Token-Auth: xai-grok-cli` on this host;
|
|
33
|
+
* include it so billing stays on the same product gate as chat inference.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getXAICliBillingHeaders(options: {
|
|
36
|
+
accessToken: string;
|
|
37
|
+
}): Record<string, string>;
|
|
22
38
|
/** Log in to xAI Grok with the RFC 8628 device authorization grant. */
|
|
23
39
|
export declare function loginXAIOAuth(ctrl: OAuthController): Promise<OAuthCredentials>;
|
|
24
40
|
/**
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Z.ai / GLM OAuth flow (GLM Coding Plan · Sign in)
|
|
3
|
+
*
|
|
4
|
+
* Mirrors ZCode's desktop "Individual Plan" browser sign-in: an
|
|
5
|
+
* authorization-code flow (no PKCE) against chat.z.ai, a JSON token exchange
|
|
6
|
+
* that yields a short-lived OAuth access token, and a business-API sequence
|
|
7
|
+
* that provisions a durable `id.secret` API key. The minted key is placed in
|
|
8
|
+
* {@link OAuthCredentials.access}; `getOAuthApiKey` returns it verbatim as the
|
|
9
|
+
* request bearer for the `zai` provider, so no dialect change is needed.
|
|
10
|
+
*/
|
|
11
|
+
import { OAuthCallbackFlow } from "./callback-server.js";
|
|
12
|
+
import type { OAuthController, OAuthCredentials } from "./types.js";
|
|
13
|
+
export declare class ZaiOAuthFlow extends OAuthCallbackFlow {
|
|
14
|
+
#private;
|
|
15
|
+
constructor(ctrl: OAuthController);
|
|
16
|
+
generateAuthUrl(state: string, redirectUri: string): Promise<{
|
|
17
|
+
url: string;
|
|
18
|
+
instructions?: string;
|
|
19
|
+
}>;
|
|
20
|
+
exchangeToken(code: string, state: string, redirectUri: string): Promise<OAuthCredentials>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Login with Z.ai OAuth (GLM Coding Plan).
|
|
24
|
+
*/
|
|
25
|
+
export declare function loginZaiOAuth(ctrl: OAuthController): Promise<OAuthCredentials>;
|