@oh-my-pi/pi-ai 17.0.9 → 17.1.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 +47 -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-gateway/types.d.ts +5 -1
- package/dist/types/auth-storage.d.ts +60 -1
- 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-codex/request-transformer.d.ts +8 -2
- package/dist/types/providers/openai-codex-responses.d.ts +22 -1
- package/dist/types/providers/openai-completions.d.ts +3 -0
- package/dist/types/providers/openai-responses-server-schema.d.ts +346 -8
- 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 +39 -14
- 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 +1 -1
- 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 +109 -0
- package/dist/types/usage/alibaba-token-plan.d.ts +3 -0
- package/dist/types/usage/xai-oauth.d.ts +6 -3
- package/dist/types/usage.d.ts +2 -0
- package/dist/types/utils/tool-choice.d.ts +2 -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-gateway/server.ts +6 -1
- package/src/auth-gateway/types.ts +4 -2
- package/src/auth-storage.ts +262 -15
- 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 +40 -16
- package/src/providers/gitlab-duo.ts +4 -0
- package/src/providers/google-shared.ts +30 -0
- package/src/providers/ollama.ts +2 -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-codex/request-transformer.ts +54 -25
- package/src/providers/openai-codex-responses.ts +229 -35
- package/src/providers/openai-completions.ts +70 -2
- package/src/providers/openai-responses-server-schema.ts +125 -10
- package/src/providers/openai-responses-server.ts +290 -117
- package/src/providers/openai-responses-wire.ts +8 -0
- package/src/providers/openai-responses.ts +242 -8
- package/src/providers/openai-shared.ts +297 -59
- 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 +1 -0
- 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 +2 -2
- 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 +93 -1
- package/src/usage/alibaba-token-plan.ts +202 -0
- package/src/usage/claude.ts +125 -1
- package/src/usage/xai-oauth.ts +222 -64
- package/src/usage/zai.ts +9 -3
- package/src/usage.ts +2 -0
- package/src/utils/tool-choice.ts +2 -0
- package/src/utils.ts +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,53 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [17.1.1] - 2026-07-24
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Added `setCodexAttestationProvider` API for injecting `x-oai-attestation` headers in ChatGPT-OAuth Codex requests
|
|
10
|
+
- Added OAuth account session pinning and active status tracking in storage
|
|
11
|
+
- Added OpenAI Responses native computer-use transport, including batched actions and exact `computer_call`/`computer_call_output` replay with pending/acknowledged safety checks and `image_url`/`file_id` output references. Models without native support receive the same action surface as a regular function tool; provider-specific tool-choice forcing is used where supported.
|
|
12
|
+
- Added `PI_CODEX_RESPONSES_LITE` to override the catalog-selected Codex Responses transport for diagnostics (`1`/`true` forces Lite; `0`/`false` forces the standard body).
|
|
13
|
+
- Added caller-owned `cachedContent` on `google-generative-ai` and `google-vertex` GenerateContent options: pass an opaque cache resource name through the shared builder (blank values rejected); no create/refresh/delete lifecycle and no guessed model/project/location validation; existing `cachedContentTokenCount` → `Usage.cacheRead` normalization is unchanged.
|
|
14
|
+
- Added Anthropic extra-usage reporting across `omp usage`, interactive `/usage`, and ACP `/usage`: the OAuth usage endpoint's authoritative `spend` payload (or legacy `extra_usage` fallback when absent) is normalized into a `Claude Extra Usage` USD row; capped accounts show limit/remaining/fractions and status, while uncapped spend exposes only its absolute used amount—rendered as `$… used` in CLI/TUI and `123.45 usd used` in ACP—without a fabricated cap, percentage, or status. ([#5575](https://github.com/can1357/oh-my-pi/issues/5575))
|
|
15
|
+
- Added process-scoped OAuth account pools for trusted auth-broker clients via `OMP_AUTH_BROKER_ACCOUNT_POOL_FILE`, consistently filtering snapshots, streaming updates, refreshes, and usage reports to selected OAuth identities while leaving API-key credentials and the shared encrypted snapshot cache unrestricted.
|
|
16
|
+
- Added opt-in Vercel AI Gateway automatic prompt caching for OpenAI Chat Completions while preserving `only` and `order` routing preferences.
|
|
17
|
+
- Added Vercel AI Gateway Responses cache anchors and cache lifetimes, emitted only with automatic caching.
|
|
18
|
+
- Added opt-in OpenAI GPT-5.6 explicit prompt-cache controls for Responses and Chat Completions. Existing requests remain implicit; the policy marks at most one existing stable-history block and is rejected locally on unsupported explicit routes.
|
|
19
|
+
- Forwarded `statefulResponses` through `streamSimple`, so diagnostic callers can explicitly disable OpenAI Responses `previous_response_id` chaining.
|
|
20
|
+
- Added native QwenCloud Token Plan API-key login, model discovery, and an optional interactive console-Cookie prompt for 5-hour and 7-day quota reporting ([#6151](https://github.com/can1357/oh-my-pi/issues/6151)).
|
|
21
|
+
- Added model-scoped usage health and same-provider reselection for native coding-plan credential pools, preserving OAuth/login-pool precedence, scoped broker blocks, sibling rotation state, and conservative unknown-account handling while excluding ordinary configured API keys ([#5018](https://github.com/can1357/oh-my-pi/issues/5018)).
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- Fixed stateful OpenAI Responses explicit cache breakpoints being restored onto edited historical messages, ensuring full replays recompute the latest stable cache boundary.
|
|
26
|
+
- Fixed ChatGPT Codex standard and Lite transports rejecting or hiding native computer-use payloads by unrolling the tool definition, forced choice, `computer_call`, and `computer_call_output` into ordinary function-tool forms.
|
|
27
|
+
|
|
28
|
+
## [17.1.0] - 2026-07-24
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
|
|
32
|
+
- Added support for caller-owned `cachedContent` on Google Generative AI and Google Vertex AI `GenerateContent` options, allowing passing of opaque cache resource names.
|
|
33
|
+
- 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.
|
|
34
|
+
- 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.
|
|
35
|
+
- Added opt-in Vercel AI Gateway automatic prompt caching for OpenAI Chat Completions, including support for cache anchors and cache lifetimes.
|
|
36
|
+
- 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.
|
|
37
|
+
- Added support for forwarding `statefulResponses` through `streamSimple` to allow diagnostic callers to explicitly disable OpenAI Responses `previous_response_id` chaining.
|
|
38
|
+
- Added native QwenCloud Token Plan support, including API-key login, model discovery, and an optional interactive console-Cookie prompt for quota reporting.
|
|
39
|
+
- Added interactive Meta Model API key login and support for `MODEL_API_KEY` and `META_API_KEY` environment variables.
|
|
40
|
+
- Added model-scoped usage health tracking and same-provider reselection for native coding-plan credential pools.
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
|
|
44
|
+
- 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.
|
|
45
|
+
- 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.
|
|
46
|
+
- Fixed outbound credential-pattern redaction running unconditionally; it is now opt-in via `configureCredentialRedaction` and disabled by default.
|
|
47
|
+
- 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.
|
|
48
|
+
- 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.
|
|
49
|
+
- Fixed OAuth callback servers aborting login on premature invalid callbacks, and restricted `localhost` callback listeners to the IPv4 loopback interface.
|
|
50
|
+
- 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.
|
|
51
|
+
|
|
5
52
|
## [17.0.9] - 2026-07-23
|
|
6
53
|
|
|
7
54
|
### Added
|
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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Effort } from "@oh-my-pi/pi-catalog/effort";
|
|
2
|
-
import type { AssistantMessage, AssistantMessageEventStream, CacheRetention, Context, ServiceTier, TokenTaskBudget } from "../types.js";
|
|
2
|
+
import type { AssistantMessage, AssistantMessageEventStream, CacheRetention, Context, OpenAIResponseInclude, ServiceTier, TokenTaskBudget } from "../types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Wire types for the omp auth-gateway.
|
|
5
5
|
*
|
|
@@ -14,6 +14,8 @@ import type { AssistantMessage, AssistantMessageEventStream, CacheRetention, Con
|
|
|
14
14
|
export declare const DEFAULT_AUTH_GATEWAY_BIND = "127.0.0.1:4000";
|
|
15
15
|
export type AuthGatewayToolChoice = "auto" | "none" | "required" | {
|
|
16
16
|
name: string;
|
|
17
|
+
} | {
|
|
18
|
+
type: "computer";
|
|
17
19
|
};
|
|
18
20
|
export interface AuthGatewayParsedRequestOptions {
|
|
19
21
|
maxOutputTokens?: number;
|
|
@@ -39,6 +41,8 @@ export interface AuthGatewayParsedRequestOptions {
|
|
|
39
41
|
toolChoice?: AuthGatewayToolChoice;
|
|
40
42
|
/** OpenAI `parallel_tool_calls`. */
|
|
41
43
|
parallelToolCalls?: boolean;
|
|
44
|
+
/** OpenAI Responses fields requested in the response payload. */
|
|
45
|
+
include?: OpenAIResponseInclude[];
|
|
42
46
|
/** Effort-level reasoning request (OpenAI Responses / Chat `reasoning_effort`). */
|
|
43
47
|
reasoning?: Effort;
|
|
44
48
|
/** Force-disable reasoning (Anthropic `thinking: { type: "disabled" }`). */
|
|
@@ -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;
|
|
@@ -552,6 +573,8 @@ export interface OAuthAccountSummary {
|
|
|
552
573
|
/** Organization/workspace the credential is scoped to (Anthropic/ChatGPT multi-subscription). */
|
|
553
574
|
orgId?: string;
|
|
554
575
|
orgName?: string;
|
|
576
|
+
/** True when this account is the session-sticky OAuth credential requested by `listOAuthAccounts`. */
|
|
577
|
+
active: boolean;
|
|
555
578
|
}
|
|
556
579
|
export interface InvalidateCredentialMatchingOptions {
|
|
557
580
|
signal?: AbortSignal;
|
|
@@ -825,6 +848,30 @@ export declare class AuthStorage {
|
|
|
825
848
|
* providers without a usage API) — the latter never warrants a usage row.
|
|
826
849
|
*/
|
|
827
850
|
usageProviderFor(provider: Provider): UsageProvider | undefined;
|
|
851
|
+
/**
|
|
852
|
+
* Return model ids whose live reports map to a quantitative usage scope.
|
|
853
|
+
* Provider strategies supply model/tier mapping when available; otherwise
|
|
854
|
+
* only explicitly matching model ids and account-wide shared limits count.
|
|
855
|
+
* Label-only or ambiguous tier limits are excluded rather than guessed.
|
|
856
|
+
*/
|
|
857
|
+
getUsageReportingModelIds(provider: Provider, modelIds: readonly string[], reports: readonly UsageReport[]): string[];
|
|
858
|
+
/**
|
|
859
|
+
* Inspect the credential pool that {@link getApiKey} would use for one model
|
|
860
|
+
* without advancing round-robin state or changing session stickiness.
|
|
861
|
+
*
|
|
862
|
+
* Pool aggregation is deliberately conservative: one healthy sibling makes
|
|
863
|
+
* the model healthy, while any unknown sibling prevents a depleted/reserve
|
|
864
|
+
* conclusion. Static runtime/config/env credentials return unknown because
|
|
865
|
+
* they bypass the managed account pool.
|
|
866
|
+
*/
|
|
867
|
+
getModelUsageHealth(provider: Provider, options: ModelUsageHealthOptions): Promise<ModelUsageHealth>;
|
|
868
|
+
/**
|
|
869
|
+
* Release a session's sticky credential so its next {@link getApiKey} call
|
|
870
|
+
* re-runs native pool ranking. This never blocks or penalizes the released
|
|
871
|
+
* account; usage-aware routing uses it when another sibling has more
|
|
872
|
+
* headroom, before considering a model/provider fallback.
|
|
873
|
+
*/
|
|
874
|
+
releaseSessionCredentialForReselection(provider: string, sessionId: string): boolean;
|
|
828
875
|
fetchUsageReports(options?: {
|
|
829
876
|
baseUrlResolver?: (provider: Provider) => string | undefined;
|
|
830
877
|
/** Caller's cancel signal; only rejects this caller, never the shared upstream fetch. */
|
|
@@ -912,8 +959,20 @@ export declare class AuthStorage {
|
|
|
912
959
|
* order, WITHOUT refreshing any token. The array position (0-based) is the
|
|
913
960
|
* selector accepted by {@link AuthStorage.getOAuthAccessAt}; a "pick the Nth
|
|
914
961
|
* account" UI should render `position + 1`.
|
|
962
|
+
*
|
|
963
|
+
* When `sessionId` is supplied, the session-sticky OAuth credential is marked
|
|
964
|
+
* `active`. No account is active before that session has resolved or pinned a
|
|
965
|
+
* credential.
|
|
966
|
+
*/
|
|
967
|
+
listOAuthAccounts(provider: string, sessionId?: string): OAuthAccountSummary[];
|
|
968
|
+
/**
|
|
969
|
+
* Pin one stored OAuth account as this session's preferred credential.
|
|
970
|
+
*
|
|
971
|
+
* The durable credential id keeps the pin stable across credential refreshes,
|
|
972
|
+
* storage reordering, and process restarts. Normal auth retry and usage-limit
|
|
973
|
+
* handling may still route around an unavailable account.
|
|
915
974
|
*/
|
|
916
|
-
|
|
975
|
+
pinSessionOAuthAccount(provider: string, sessionId: string, credentialId: number): boolean;
|
|
917
976
|
/**
|
|
918
977
|
* Resolve every stored OAuth credential for `provider` independently.
|
|
919
978
|
*
|
|
@@ -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. */
|
|
@@ -35,6 +35,10 @@ export interface InputItem {
|
|
|
35
35
|
name?: string;
|
|
36
36
|
output?: unknown;
|
|
37
37
|
arguments?: unknown;
|
|
38
|
+
action?: unknown;
|
|
39
|
+
actions?: unknown;
|
|
40
|
+
pending_safety_checks?: unknown;
|
|
41
|
+
acknowledged_safety_checks?: unknown;
|
|
38
42
|
/** `additional_tools` developer item payload (Responses Lite). */
|
|
39
43
|
tools?: unknown;
|
|
40
44
|
}
|
|
@@ -65,8 +69,10 @@ export interface RequestBody {
|
|
|
65
69
|
}
|
|
66
70
|
/**
|
|
67
71
|
* Resolve whether a Codex request uses the Responses Lite transport: an
|
|
68
|
-
* explicit option wins,
|
|
69
|
-
* `
|
|
72
|
+
* explicit option wins, then the `PI_CODEX_RESPONSES_LITE` env override
|
|
73
|
+
* (`1`/`true` forces Lite, `0`/`false` forces the full Responses body),
|
|
74
|
+
* otherwise the model's catalog flag (codex-rs `model_info.use_responses_lite`)
|
|
75
|
+
* decides.
|
|
70
76
|
*/
|
|
71
77
|
export declare function resolveCodexResponsesLite(model: Model<"openai-codex-responses">, requested: boolean | undefined): boolean;
|
|
72
78
|
/**
|
|
@@ -7,7 +7,6 @@ export interface OpenAICodexResponsesOptions extends StreamOptions {
|
|
|
7
7
|
/** `reasoning.context` replay scope; defaults to `all_turns` when unset. The `all_turns` value is gated to gpt-5.4+ Codex models — older ids reject it, so it is suppressed and `context` omitted. */
|
|
8
8
|
reasoningContext?: CodexReasoningContext;
|
|
9
9
|
textVerbosity?: "low" | "medium" | "high";
|
|
10
|
-
include?: string[];
|
|
11
10
|
codexMode?: boolean;
|
|
12
11
|
toolChoice?: ToolChoice;
|
|
13
12
|
preferWebsockets?: boolean;
|
|
@@ -64,6 +63,28 @@ export declare function createOpenAICodexCompactionRequestContext(options: {
|
|
|
64
63
|
context: CodexCompactionContext | undefined;
|
|
65
64
|
implementation: "responses" | "responses_compaction_v2" | "responses_compact";
|
|
66
65
|
}): CodexCompactionRequestContext | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Host integration boundary for just-in-time `x-oai-attestation` header
|
|
68
|
+
* values (codex-rs `AttestationProvider`). Resolves to the full header value
|
|
69
|
+
* — an `{"v":1,"s":0,"t":"v1.…"}` envelope — or `undefined` when no
|
|
70
|
+
* attestation should be sent.
|
|
71
|
+
*/
|
|
72
|
+
export type CodexAttestationProvider = () => Promise<string | undefined>;
|
|
73
|
+
/**
|
|
74
|
+
* Install the process-wide attestation hook consulted for upstream Codex
|
|
75
|
+
* requests (codex-rs stores its provider on `ModelClient` construction). The
|
|
76
|
+
* hook is only consulted for ChatGPT-OAuth credentials and runs just-in-time
|
|
77
|
+
* per request; WebSocket handshakes resolve once per connection because the
|
|
78
|
+
* header is connection-scoped there.
|
|
79
|
+
*/
|
|
80
|
+
export declare function setCodexAttestationProvider(provider: CodexAttestationProvider | undefined): void;
|
|
81
|
+
/**
|
|
82
|
+
* Resolve the `x-oai-attestation` header value for one upstream request.
|
|
83
|
+
* Gated on ChatGPT-OAuth credentials (a Codex JWT carries `chatgpt_account_id`;
|
|
84
|
+
* codex-rs gates on `auth.is_chatgpt_auth()`). A throwing hook degrades to no
|
|
85
|
+
* header rather than failing the request.
|
|
86
|
+
*/
|
|
87
|
+
export declare function getCodexAttestationHeader(accountId: string | undefined): Promise<string | undefined>;
|
|
67
88
|
type CodexTransport = "sse" | "websocket";
|
|
68
89
|
/** Shape of the Codex request sent on the latest provider turn. */
|
|
69
90
|
export interface OpenAICodexTurnRequestDiagnostics {
|
|
@@ -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
|