@oh-my-pi/pi-ai 17.1.0 → 17.1.2
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 +35 -0
- package/dist/types/auth-broker/client.d.ts +12 -1
- package/dist/types/auth-broker/remote-store.d.ts +10 -1
- package/dist/types/auth-broker/types.d.ts +21 -1
- package/dist/types/auth-broker/wire-schemas.d.ts +55 -0
- package/dist/types/auth-gateway/types.d.ts +5 -1
- package/dist/types/auth-storage.d.ts +50 -2
- package/dist/types/providers/anthropic-wire.d.ts +29 -2
- package/dist/types/providers/anthropic.d.ts +1 -1
- 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-responses-server-schema.d.ts +346 -8
- package/dist/types/providers/openai-shared.d.ts +8 -4
- package/dist/types/types.d.ts +102 -1
- package/dist/types/usage.d.ts +50 -0
- package/dist/types/utils/tool-choice.d.ts +2 -0
- package/package.json +4 -4
- package/src/auth-broker/client.ts +39 -0
- package/src/auth-broker/remote-store.ts +76 -3
- package/src/auth-broker/server.ts +40 -0
- package/src/auth-broker/types.ts +25 -1
- package/src/auth-broker/wire-schemas.ts +71 -0
- package/src/auth-gateway/server.ts +6 -1
- package/src/auth-gateway/types.ts +4 -2
- package/src/auth-storage.ts +230 -1
- package/src/providers/anthropic-messages-server.ts +47 -3
- package/src/providers/anthropic-wire.ts +41 -0
- package/src/providers/anthropic.ts +81 -33
- package/src/providers/azure-openai-responses.ts +34 -16
- package/src/providers/ollama.ts +2 -0
- package/src/providers/openai-codex/request-transformer.ts +54 -25
- package/src/providers/openai-codex-responses.ts +229 -35
- package/src/providers/openai-responses-server-schema.ts +125 -10
- package/src/providers/openai-responses-server.ts +268 -117
- package/src/providers/openai-responses.ts +15 -0
- package/src/providers/openai-shared.ts +217 -51
- package/src/providers/transform-messages.ts +8 -0
- package/src/types.ts +88 -1
- package/src/usage/zai.ts +3 -3
- package/src/usage.ts +55 -0
- package/src/utils/leaked-thinking-stream.ts +38 -1
- package/src/utils/tool-choice.ts +2 -0
- package/src/utils.ts +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,9 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [17.1.2] - 2026-07-24
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Added `GET /v1/usage/history` to the auth broker (recorded usage-limit snapshots with `sinceMs`/`provider` filters) and `AuthBrokerClient.fetchUsageHistory` — in broker deployments the broker host performs every upstream usage fetch, so its durable history is the only complete utilization record
|
|
10
|
+
- Added per-client burn tracking to the auth broker: clients batch observed request usage per (provider, model) and flush it to `POST /v1/usage/observed` every 10 seconds (install id as client key, hostname as display name); the broker persists 5-minute buckets in `client_usage`/`clients` and serves aggregates from `GET /v1/usage/clients`. Brokers without the endpoint disable reporting for the process lifetime
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Renamed the Z.AI feature quota row to `ZAI Zread Quota` (tier/id slug `zread`), replacing the 74-char `ZAI Web Search / Reader / Zread Quota (web-search-reader-zread)` title that wrapped `omp usage` rows
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Fixed every Claude (`anthropic-messages`) model on the `opencode-zen` provider failing with `401 Missing API key`: the gateway requires `x-api-key`, so `opencode-zen` now uses X-Api-Key auth like `opencode-go`/`umans` instead of bearer-only, and no longer sends the `context_management` field its Anthropic proxy rejects on thinking requests ([#6510](https://github.com/can1357/oh-my-pi/issues/6510)).
|
|
19
|
+
- Fixed Anthropic native server-tool blocks being dropped from persisted assistant turns, preserving signed web-search continuations in their original response order ([#6495](https://github.com/can1357/oh-my-pi/issues/6495))
|
|
20
|
+
|
|
21
|
+
## [17.1.1] - 2026-07-24
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- Added `setCodexAttestationProvider` API for injecting `x-oai-attestation` headers in ChatGPT-OAuth Codex requests
|
|
26
|
+
- Added OAuth account session pinning and active status tracking in storage
|
|
27
|
+
- 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.
|
|
28
|
+
- 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).
|
|
29
|
+
- 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.
|
|
30
|
+
- 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))
|
|
31
|
+
- 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.
|
|
32
|
+
- Added opt-in Vercel AI Gateway automatic prompt caching for OpenAI Chat Completions while preserving `only` and `order` routing preferences.
|
|
33
|
+
- Added Vercel AI Gateway Responses cache anchors and cache lifetimes, emitted only with automatic caching.
|
|
34
|
+
- 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.
|
|
35
|
+
- Forwarded `statefulResponses` through `streamSimple`, so diagnostic callers can explicitly disable OpenAI Responses `previous_response_id` chaining.
|
|
36
|
+
- 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)).
|
|
37
|
+
- 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)).
|
|
38
|
+
|
|
5
39
|
### Fixed
|
|
6
40
|
|
|
7
41
|
- Fixed stateful OpenAI Responses explicit cache breakpoints being restored onto edited historical messages, ensuring full replays recompute the latest stable cache boundary.
|
|
42
|
+
- 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.
|
|
8
43
|
|
|
9
44
|
## [17.1.0] - 2026-07-24
|
|
10
45
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AuthCredential } from "../auth-storage.js";
|
|
2
|
-
import type { CredentialBlockRequest, CredentialBlockResponse, CredentialBlocksDeleteResponse, CredentialDisableResponse, CredentialRefreshResponse, CredentialUploadResponse, HealthzResponse, SnapshotResponse, SnapshotStreamEvent, UsageResponse, UsageStaleResponse } from "./types.js";
|
|
2
|
+
import type { ClientUsageReportRequest, ClientUsageReportResponse, ClientUsageSummaryResponse, CredentialBlockRequest, CredentialBlockResponse, CredentialBlocksDeleteResponse, CredentialDisableResponse, CredentialRefreshResponse, CredentialUploadResponse, HealthzResponse, SnapshotResponse, SnapshotStreamEvent, UsageHistoryResponse, UsageResponse, UsageStaleResponse } from "./types.js";
|
|
3
3
|
export interface AuthBrokerClientOptions {
|
|
4
4
|
/** Base URL (e.g. `https://broker.tailnet:8765`). Trailing slashes are trimmed. */
|
|
5
5
|
url: string;
|
|
@@ -60,6 +60,17 @@ export declare class AuthBrokerClient {
|
|
|
60
60
|
signal?: AbortSignal;
|
|
61
61
|
}): AsyncGenerator<SnapshotStreamEvent>;
|
|
62
62
|
fetchUsage(signal?: AbortSignal): Promise<UsageResponse>;
|
|
63
|
+
/** Recorded usage-limit snapshots from the broker host, oldest first. */
|
|
64
|
+
fetchUsageHistory(query?: {
|
|
65
|
+
sinceMs?: number;
|
|
66
|
+
provider?: string;
|
|
67
|
+
}, signal?: AbortSignal): Promise<UsageHistoryResponse>;
|
|
68
|
+
/** Report this client's batched observed request usage for per-install burn tracking. */
|
|
69
|
+
reportClientUsage(report: ClientUsageReportRequest, signal?: AbortSignal): Promise<ClientUsageReportResponse>;
|
|
70
|
+
/** Per-client token burn aggregates recorded by the broker host. */
|
|
71
|
+
fetchClientUsageSummary(query?: {
|
|
72
|
+
sinceMs?: number;
|
|
73
|
+
}, signal?: AbortSignal): Promise<ClientUsageSummaryResponse>;
|
|
63
74
|
notifyUsageStale(signal?: AbortSignal): Promise<UsageStaleResponse>;
|
|
64
75
|
refreshCredential(id: number, signal?: AbortSignal): Promise<CredentialRefreshResponse>;
|
|
65
76
|
disableCredential(id: number, cause: string, signal?: AbortSignal): Promise<CredentialDisableResponse>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type AuthCredential, type AuthCredentialStore, type OAuthCredential, type StoredAuthCredential, type StoredCredentialBlock } from "../auth-storage.js";
|
|
2
2
|
import type { OAuthCredentials } from "../registry/oauth/types.js";
|
|
3
3
|
import type { Provider } from "../types.js";
|
|
4
|
-
import type { UsageReport } from "../usage.js";
|
|
4
|
+
import type { ObservedUsageEntry, UsageReport } from "../usage.js";
|
|
5
5
|
import { type AuthBrokerClient } from "./client.js";
|
|
6
6
|
import type { SnapshotResponse } from "./types.js";
|
|
7
7
|
/**
|
|
@@ -33,6 +33,8 @@ export interface RemoteAuthCredentialStoreOptions {
|
|
|
33
33
|
* routing policy, not broker authorization.
|
|
34
34
|
*/
|
|
35
35
|
accountPool?: AuthBrokerAccountPool;
|
|
36
|
+
/** Flush cadence for batched observed-usage reports. Default 10s. */
|
|
37
|
+
observedUsageFlushMs?: number;
|
|
36
38
|
}
|
|
37
39
|
export declare class RemoteAuthCredentialStore implements AuthCredentialStore {
|
|
38
40
|
#private;
|
|
@@ -120,5 +122,12 @@ export declare class RemoteAuthCredentialStore implements AuthCredentialStore {
|
|
|
120
122
|
*/
|
|
121
123
|
getUsageReport(provider: Provider, credential: OAuthCredential, signal?: AbortSignal): Promise<UsageReport | null>;
|
|
122
124
|
ingestUsageReport(provider: Provider, credential: OAuthCredential, report: UsageReport): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Fold locally observed request usage into the pending report and schedule
|
|
127
|
+
* a flush. One `POST /v1/usage/observed` at most per flush interval; on
|
|
128
|
+
* failure the batch is retained and retried with the next flush. A 404
|
|
129
|
+
* (pre-endpoint broker) disables reporting for the life of this store.
|
|
130
|
+
*/
|
|
131
|
+
recordObservedUsage(entries: ObservedUsageEntry[]): void;
|
|
123
132
|
close(): void;
|
|
124
133
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* credential expires or a 401 surfaces on a supposedly-fresh credential.
|
|
7
7
|
*/
|
|
8
8
|
import type { AuthCredential, AuthCredentialSnapshot, AuthCredentialSnapshotEntry, StoredCredentialBlock } from "../auth-storage.js";
|
|
9
|
-
import type { UsageReport } from "../usage.js";
|
|
9
|
+
import type { ClientUsageClientSummary, ClientUsageReport, UsageHistoryEntry, UsageReport } from "../usage.js";
|
|
10
10
|
/** GET /v1/healthz response body. */
|
|
11
11
|
export interface HealthzResponse {
|
|
12
12
|
ok: boolean;
|
|
@@ -34,6 +34,26 @@ export interface UsageResponse {
|
|
|
34
34
|
generatedAt: number;
|
|
35
35
|
reports: UsageReport[];
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* GET /v1/usage/history response body. Entries come from the broker host's
|
|
39
|
+
* durable `usage_history` — the broker performs every upstream usage fetch in
|
|
40
|
+
* broker deployments, so this is the only complete utilization record.
|
|
41
|
+
*/
|
|
42
|
+
export interface UsageHistoryResponse {
|
|
43
|
+
generatedAt: number;
|
|
44
|
+
entries: UsageHistoryEntry[];
|
|
45
|
+
}
|
|
46
|
+
/** POST /v1/usage/observed request body — one client's batched observed usage. */
|
|
47
|
+
export type ClientUsageReportRequest = ClientUsageReport;
|
|
48
|
+
/** POST /v1/usage/observed response body. */
|
|
49
|
+
export interface ClientUsageReportResponse {
|
|
50
|
+
ok: boolean;
|
|
51
|
+
}
|
|
52
|
+
/** GET /v1/usage/clients response body — per-client token burn aggregates. */
|
|
53
|
+
export interface ClientUsageSummaryResponse {
|
|
54
|
+
generatedAt: number;
|
|
55
|
+
clients: ClientUsageClientSummary[];
|
|
56
|
+
}
|
|
37
57
|
/** POST /v1/credential/:id/refresh response body. */
|
|
38
58
|
export interface CredentialRefreshResponse {
|
|
39
59
|
entry: AuthCredentialSnapshotEntry;
|
|
@@ -418,6 +418,61 @@ export declare const usageResponseSchema: import("arktype/internal/variants/obje
|
|
|
418
418
|
raw?: unknown;
|
|
419
419
|
}[];
|
|
420
420
|
}, {}>;
|
|
421
|
+
/** Broker `/v1/usage/history` response — recorded usage-limit snapshots, oldest first. */
|
|
422
|
+
export declare const usageHistoryResponseSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
423
|
+
generatedAt: number;
|
|
424
|
+
entries: {
|
|
425
|
+
recordedAt: number;
|
|
426
|
+
provider: string;
|
|
427
|
+
accountKey: string;
|
|
428
|
+
email?: string | undefined;
|
|
429
|
+
accountId?: string | undefined;
|
|
430
|
+
limitId: string;
|
|
431
|
+
label: string;
|
|
432
|
+
windowLabel?: string | undefined;
|
|
433
|
+
usedFraction?: number | undefined;
|
|
434
|
+
status?: "exhausted" | "ok" | "unknown" | "warning" | undefined;
|
|
435
|
+
resetsAt?: number | undefined;
|
|
436
|
+
}[];
|
|
437
|
+
}, {}>;
|
|
438
|
+
/** Broker `POST /v1/usage/observed` request — one client's batched observed usage. */
|
|
439
|
+
export declare const clientUsageReportRequestSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
440
|
+
installId: string;
|
|
441
|
+
hostname?: string | undefined;
|
|
442
|
+
entries: {
|
|
443
|
+
at: number;
|
|
444
|
+
provider: string;
|
|
445
|
+
model: string;
|
|
446
|
+
requests: number;
|
|
447
|
+
inputTokens: number;
|
|
448
|
+
outputTokens: number;
|
|
449
|
+
cacheReadTokens: number;
|
|
450
|
+
cacheWriteTokens: number;
|
|
451
|
+
costUsd: number;
|
|
452
|
+
}[];
|
|
453
|
+
}, {}>;
|
|
454
|
+
export declare const clientUsageReportResponseSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
455
|
+
ok: boolean;
|
|
456
|
+
}, {}>;
|
|
457
|
+
/** Broker `GET /v1/usage/clients` response — per-client token burn aggregates. */
|
|
458
|
+
export declare const clientUsageSummaryResponseSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
459
|
+
generatedAt: number;
|
|
460
|
+
clients: {
|
|
461
|
+
installId: string;
|
|
462
|
+
hostname?: string | undefined;
|
|
463
|
+
firstSeen: number;
|
|
464
|
+
lastSeen: number;
|
|
465
|
+
providers: {
|
|
466
|
+
provider: string;
|
|
467
|
+
requests: number;
|
|
468
|
+
inputTokens: number;
|
|
469
|
+
outputTokens: number;
|
|
470
|
+
cacheReadTokens: number;
|
|
471
|
+
cacheWriteTokens: number;
|
|
472
|
+
costUsd: number;
|
|
473
|
+
}[];
|
|
474
|
+
}[];
|
|
475
|
+
}, {}>;
|
|
421
476
|
export declare const credentialRefreshResponseSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
422
477
|
entry: {
|
|
423
478
|
id: number;
|
|
@@ -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" }`). */
|
|
@@ -11,7 +11,7 @@ import { Database } from "bun:sqlite";
|
|
|
11
11
|
import type { ApiKeyResolver } from "./auth-retry.js";
|
|
12
12
|
import type { OAuthAuthInfo, OAuthController, OAuthCredentials, OAuthProviderId } from "./registry/oauth/types.js";
|
|
13
13
|
import type { Provider } from "./types.js";
|
|
14
|
-
import type { CredentialRankingStrategy, UsageCostHistoryEntry, UsageCostHistoryQuery, UsageHistoryEntry, UsageHistoryQuery, UsageLogger, UsageProvider, UsageReport } from "./usage.js";
|
|
14
|
+
import type { ClientUsageReport, ClientUsageSummary, CredentialRankingStrategy, ObservedUsageEntry, UsageCostHistoryEntry, UsageCostHistoryQuery, UsageHistoryEntry, UsageHistoryQuery, UsageLogger, UsageProvider, UsageReport } from "./usage.js";
|
|
15
15
|
import { type CodexResetConsumeCode, type CodexResetCredit } from "./usage/openai-codex-reset.js";
|
|
16
16
|
export type ApiKeyCredential = {
|
|
17
17
|
type: "api_key";
|
|
@@ -281,6 +281,16 @@ export interface AuthCredentialStore {
|
|
|
281
281
|
listUsageCosts?(query?: UsageCostHistoryQuery): UsageCostHistoryEntry[];
|
|
282
282
|
/** Read recorded usage-limit snapshots, oldest first. */
|
|
283
283
|
listUsageHistory?(query?: UsageHistoryQuery): UsageHistoryEntry[];
|
|
284
|
+
/**
|
|
285
|
+
* Client hook: forward locally observed request usage. Remote broker stores
|
|
286
|
+
* batch these to the broker so it can attribute token burn per install;
|
|
287
|
+
* local stores omit it and observation is skipped.
|
|
288
|
+
*/
|
|
289
|
+
recordObservedUsage?(entries: ObservedUsageEntry[]): void;
|
|
290
|
+
/** Broker host: persist one client's observed-usage report. */
|
|
291
|
+
recordClientUsage?(report: ClientUsageReport): void;
|
|
292
|
+
/** Broker host: aggregate recorded per-client usage since a timestamp. */
|
|
293
|
+
getClientUsageSummary?(sinceMs: number): ClientUsageSummary;
|
|
284
294
|
/**
|
|
285
295
|
* Optional store-supplied OAuth refresh. When present, `AuthStorage` uses
|
|
286
296
|
* it before the per-provider local refresh path. `RemoteAuthCredentialStore`
|
|
@@ -573,6 +583,8 @@ export interface OAuthAccountSummary {
|
|
|
573
583
|
/** Organization/workspace the credential is scoped to (Anthropic/ChatGPT multi-subscription). */
|
|
574
584
|
orgId?: string;
|
|
575
585
|
orgName?: string;
|
|
586
|
+
/** True when this account is the session-sticky OAuth credential requested by `listOAuthAccounts`. */
|
|
587
|
+
active: boolean;
|
|
576
588
|
}
|
|
577
589
|
export interface InvalidateCredentialMatchingOptions {
|
|
578
590
|
signal?: AbortSignal;
|
|
@@ -834,6 +846,28 @@ export declare class AuthStorage {
|
|
|
834
846
|
recordedAt?: number;
|
|
835
847
|
baseUrl?: string;
|
|
836
848
|
}): boolean;
|
|
849
|
+
/**
|
|
850
|
+
* Forward one completed request's usage to the store's observer hook.
|
|
851
|
+
* Broker-backed stores batch these into per-install reports so the broker
|
|
852
|
+
* can track actual token burn per client; local stores have no hook and
|
|
853
|
+
* the call is a no-op.
|
|
854
|
+
*/
|
|
855
|
+
recordObservedUsage(entry: {
|
|
856
|
+
provider: Provider;
|
|
857
|
+
model: string;
|
|
858
|
+
usage: {
|
|
859
|
+
input: number;
|
|
860
|
+
output: number;
|
|
861
|
+
cacheRead: number;
|
|
862
|
+
cacheWrite: number;
|
|
863
|
+
};
|
|
864
|
+
costUsd?: number;
|
|
865
|
+
at?: number;
|
|
866
|
+
}): void;
|
|
867
|
+
/** Broker host: persist one client's observed-usage report (per-install token burn). */
|
|
868
|
+
recordClientUsage(report: ClientUsageReport): boolean;
|
|
869
|
+
/** Broker host: aggregate recorded per-client usage since `sinceMs`. */
|
|
870
|
+
getClientUsageSummary(sinceMs: number): ClientUsageSummary;
|
|
837
871
|
ingestUsageHeaders(provider: Provider, headers: Record<string, string>, options?: {
|
|
838
872
|
sessionId?: string;
|
|
839
873
|
baseUrl?: string;
|
|
@@ -957,8 +991,20 @@ export declare class AuthStorage {
|
|
|
957
991
|
* order, WITHOUT refreshing any token. The array position (0-based) is the
|
|
958
992
|
* selector accepted by {@link AuthStorage.getOAuthAccessAt}; a "pick the Nth
|
|
959
993
|
* account" UI should render `position + 1`.
|
|
994
|
+
*
|
|
995
|
+
* When `sessionId` is supplied, the session-sticky OAuth credential is marked
|
|
996
|
+
* `active`. No account is active before that session has resolved or pinned a
|
|
997
|
+
* credential.
|
|
998
|
+
*/
|
|
999
|
+
listOAuthAccounts(provider: string, sessionId?: string): OAuthAccountSummary[];
|
|
1000
|
+
/**
|
|
1001
|
+
* Pin one stored OAuth account as this session's preferred credential.
|
|
1002
|
+
*
|
|
1003
|
+
* The durable credential id keeps the pin stable across credential refreshes,
|
|
1004
|
+
* storage reordering, and process restarts. Normal auth retry and usage-limit
|
|
1005
|
+
* handling may still route around an unavailable account.
|
|
960
1006
|
*/
|
|
961
|
-
|
|
1007
|
+
pinSessionOAuthAccount(provider: string, sessionId: string, credentialId: number): boolean;
|
|
962
1008
|
/**
|
|
963
1009
|
* Resolve every stored OAuth credential for `provider` independently.
|
|
964
1010
|
*
|
|
@@ -1186,6 +1232,8 @@ export declare class SqliteAuthCredentialStore implements AuthCredentialStore {
|
|
|
1186
1232
|
listUsageHistory(query?: UsageHistoryQuery): UsageHistoryEntry[];
|
|
1187
1233
|
recordUsageCosts(entries: UsageCostHistoryEntry[]): void;
|
|
1188
1234
|
listUsageCosts(query?: UsageCostHistoryQuery): UsageCostHistoryEntry[];
|
|
1235
|
+
recordClientUsage(report: ClientUsageReport): void;
|
|
1236
|
+
getClientUsageSummary(sinceMs: number): ClientUsageSummary;
|
|
1189
1237
|
/**
|
|
1190
1238
|
* Save OAuth credentials for a provider.
|
|
1191
1239
|
* Preserves unrelated identities and replaces only the matching credential.
|
|
@@ -57,6 +57,33 @@ export type ToolResultBlockParam = {
|
|
|
57
57
|
is_error?: boolean;
|
|
58
58
|
cache_control?: CacheControlEphemeral | null;
|
|
59
59
|
};
|
|
60
|
+
/** Anthropic-executed server tool call replayed inside an assistant turn. */
|
|
61
|
+
export type ServerToolUseBlockParam = {
|
|
62
|
+
type: "server_tool_use";
|
|
63
|
+
id: string;
|
|
64
|
+
name: string;
|
|
65
|
+
input?: Record<string, unknown> | null;
|
|
66
|
+
[key: string]: unknown;
|
|
67
|
+
};
|
|
68
|
+
/** Web-search server-tool call whose matching result is replayable by omp. */
|
|
69
|
+
export type WebSearchServerToolUseBlockParam = ServerToolUseBlockParam & {
|
|
70
|
+
name: "web_search";
|
|
71
|
+
};
|
|
72
|
+
/** Native web-search result replayed inside an assistant turn. */
|
|
73
|
+
export type WebSearchToolResultBlockParam = {
|
|
74
|
+
type: "web_search_tool_result";
|
|
75
|
+
tool_use_id: string;
|
|
76
|
+
content: unknown;
|
|
77
|
+
[key: string]: unknown;
|
|
78
|
+
};
|
|
79
|
+
/** True for the complete native web-search history variants omp can replay. */
|
|
80
|
+
export declare function isAnthropicWebSearchHistoryBlock(block: {
|
|
81
|
+
type: string;
|
|
82
|
+
name?: unknown;
|
|
83
|
+
id?: unknown;
|
|
84
|
+
tool_use_id?: unknown;
|
|
85
|
+
content?: unknown;
|
|
86
|
+
}): block is WebSearchServerToolUseBlockParam | WebSearchToolResultBlockParam;
|
|
60
87
|
export type ThinkingBlockParam = {
|
|
61
88
|
type: "thinking";
|
|
62
89
|
thinking: string;
|
|
@@ -81,7 +108,7 @@ export type FallbackBlockParam = {
|
|
|
81
108
|
model: string;
|
|
82
109
|
};
|
|
83
110
|
};
|
|
84
|
-
export type ContentBlockParam = TextBlockParam | ImageBlockParam | ToolUseBlockParam | ToolResultBlockParam | ThinkingBlockParam | RedactedThinkingBlockParam | FallbackBlockParam;
|
|
111
|
+
export type ContentBlockParam = TextBlockParam | ImageBlockParam | ToolUseBlockParam | ToolResultBlockParam | ServerToolUseBlockParam | WebSearchToolResultBlockParam | ThinkingBlockParam | RedactedThinkingBlockParam | FallbackBlockParam;
|
|
85
112
|
/**
|
|
86
113
|
* A single conversation turn.
|
|
87
114
|
*
|
|
@@ -257,7 +284,7 @@ export type ResponseContentBlock = {
|
|
|
257
284
|
id: string;
|
|
258
285
|
name: string;
|
|
259
286
|
input?: Record<string, unknown> | null;
|
|
260
|
-
} | {
|
|
287
|
+
} | ServerToolUseBlockParam | WebSearchToolResultBlockParam | {
|
|
261
288
|
type: "fallback";
|
|
262
289
|
from: {
|
|
263
290
|
model: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FetchImpl, Message, Model, ProviderSessionState, ServiceTier, SimpleStreamOptions, StreamFunction, StreamOptions, Usage } from "../types.js";
|
|
2
2
|
import { type AnthropicFetchOptions, type AnthropicMessagesClientLike } from "./anthropic-client.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type FallbackParam, type MessageParam, type TextBlockParam } from "./anthropic-wire.js";
|
|
4
4
|
export type AnthropicHeaderOptions = {
|
|
5
5
|
apiKey: string;
|
|
6
6
|
baseUrl?: string;
|
|
@@ -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 {
|