@gajae-code/ai 0.18.11 → 0.19.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 +103 -0
- package/README.md +1 -1
- package/dist/types/auth-broker/wire-schemas.d.ts +30 -0
- package/dist/types/auth-storage.d.ts +98 -13
- package/dist/types/bedrock-claude-cache-policy.d.ts +1 -1
- package/dist/types/model-cache.d.ts +6 -4
- package/dist/types/model-manager.d.ts +2 -0
- package/dist/types/model-pricing.d.ts +8 -0
- package/dist/types/model-thinking.d.ts +11 -0
- package/dist/types/openai-completions-compat.d.ts +2 -1
- package/dist/types/provider-models/google.d.ts +2 -0
- package/dist/types/providers/amazon-bedrock.d.ts +17 -2
- package/dist/types/providers/anthropic.d.ts +25 -0
- package/dist/types/providers/aws-credential-config.d.ts +5 -0
- package/dist/types/providers/google-auth.d.ts +7 -0
- package/dist/types/providers/google-gemini-headers.d.ts +11 -6
- package/dist/types/providers/kiro-api-key.d.ts +5 -0
- package/dist/types/providers/openai-chat-server-schema.d.ts +2 -1
- package/dist/types/providers/openai-completions.d.ts +1 -1
- package/dist/types/providers/openai-responses-shared.d.ts +2 -1
- package/dist/types/stream.d.ts +33 -1
- package/dist/types/types.d.ts +26 -3
- package/dist/types/usage.d.ts +3 -0
- package/dist/types/utils/discovery/antigravity.d.ts +16 -1
- package/dist/types/utils/idle-iterator.d.ts +3 -2
- package/dist/types/utils/oauth/glm-zcode.d.ts +0 -30
- package/dist/types/utils/oauth/types.d.ts +9 -0
- package/package.json +4 -4
- package/src/auth-broker/remote-store.ts +62 -11
- package/src/auth-broker/wire-schemas.ts +2 -0
- package/src/auth-gateway/server.ts +3 -2
- package/src/auth-storage.ts +908 -246
- package/src/bedrock-claude-cache-policy.d.ts +1 -1
- package/src/bedrock-claude-cache-policy.ts +2 -2
- package/src/model-cache.ts +45 -10
- package/src/model-manager.ts +18 -6
- package/src/model-pricing.d.ts +8 -0
- package/src/model-pricing.ts +87 -0
- package/src/model-thinking.d.ts +11 -0
- package/src/model-thinking.ts +97 -12
- package/src/models.json +3176 -1670
- package/src/models.ts +10 -3
- package/src/openai-completions-compat.d.ts +2 -1
- package/src/openai-completions-compat.ts +5 -0
- package/src/provider-models/google.ts +11 -1
- package/src/provider-models/openai-compat.ts +26 -0
- package/src/providers/amazon-bedrock.d.ts +17 -2
- package/src/providers/amazon-bedrock.ts +76 -16
- package/src/providers/anthropic.d.ts +25 -0
- package/src/providers/anthropic.ts +230 -18
- package/src/providers/aws-credential-config.d.ts +5 -0
- package/src/providers/aws-credential-config.ts +29 -1
- package/src/providers/google-auth.d.ts +7 -0
- package/src/providers/google-auth.ts +165 -4
- package/src/providers/google-gemini-headers.d.ts +11 -6
- package/src/providers/google-gemini-headers.ts +16 -11
- package/src/providers/google-vertex.ts +2 -4
- package/src/providers/kiro-api-key.d.ts +5 -0
- package/src/providers/kiro-api-key.ts +379 -68
- package/src/providers/ollama.ts +19 -9
- package/src/providers/openai-anthropic-shim.ts +1 -0
- package/src/providers/openai-chat-server-schema.ts +1 -1
- package/src/providers/openai-chat-server.ts +14 -2
- package/src/providers/openai-codex-responses.ts +21 -14
- package/src/providers/openai-completions.d.ts +1 -1
- package/src/providers/openai-completions.ts +65 -4
- package/src/providers/openai-responses-server.ts +10 -1
- package/src/providers/openai-responses-shared.d.ts +2 -1
- package/src/providers/openai-responses-shared.ts +42 -1
- package/src/providers/openai-responses.ts +51 -10
- package/src/providers/pi-native-server.ts +1 -1
- package/src/providers/transform-messages.ts +32 -1
- package/src/stream.d.ts +33 -1
- package/src/stream.ts +111 -17
- package/src/types.d.ts +26 -3
- package/src/types.ts +55 -2
- package/src/usage/claude.ts +4 -2
- package/src/usage.ts +3 -0
- package/src/utils/discovery/antigravity.ts +192 -7
- package/src/utils/idle-iterator.d.ts +3 -2
- package/src/utils/idle-iterator.ts +30 -10
- package/src/utils/oauth/anthropic.ts +23 -22
- package/src/utils/oauth/api-key-validation.ts +34 -11
- package/src/utils/oauth/glm-zcode.d.ts +0 -30
- package/src/utils/oauth/glm-zcode.ts +15 -4
- package/src/utils/oauth/openai-codex.ts +41 -6
- package/src/utils/oauth/types.d.ts +9 -0
- package/src/utils/oauth/types.ts +9 -0
- package/src/utils/parse-bind.d.ts +35 -0
- package/src/utils/proxy.ts +35 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,109 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.19.0] - 2026-10-22
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Added the Amazon Bedrock Claude Haiku 5.5 selectors (`anthropic.claude-haiku-5-5` and the `au.`, `eu.`, `global.`, `jp.` and `us.` inference profiles) to the bundled catalog, taken from a fresh `generate-models` run.
|
|
10
|
+
- Bedrock Haiku 5.5 resolves to adaptive thinking with the documented `low`..`max` effort range and `medium` default, sends an explicit `thinking: { type: "disabled" }` when thinking is Off (with a forced tool choice the selected effort is kept, capped at `high` while thinking is disabled), and bills prompts above 100K tokens at a long-context tier, with 1-hour cache writes (long retention) at twice the tier input rate.
|
|
11
|
+
|
|
12
|
+
- Added Claude Haiku 5.5 (`anthropic/claude-haiku-5-5`) to the bundled catalog, taken from a fresh `generate-models` run. Bedrock selectors are not part of this change.
|
|
13
|
+
- Claude Haiku 5.5 resolves to adaptive thinking with the documented `low`..`max` effort range and `medium` default on the Anthropic Messages API. Direct requests omit unsupported sampling controls, send an explicit `thinking: { type: "disabled" }` when thinking is Off, and with a forced tool choice keep the selected effort (capped at `high` while thinking is disabled), request summarized thinking output, and use the documented >100K-token pricing tier, billing 1-hour cache writes at their own rate from the response TTL split. Haiku 4.5 and older keep their existing behavior.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- First-party Anthropic requests (`api.anthropic.com` over HTTPS) now send gzip-compressed bodies with `Content-Encoding: gzip`, which shrinks large, repetitive prompts substantially. Third-party endpoints, non-standard ports, and stream bodies are sent unchanged, and a stale `Content-Length` is dropped so the transport recomputes it.
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- Antigravity model discovery now identifies with the Gemini CLI user agent so Gemini 4 Argon can be returned without relying on project metadata. Both `google-antigravity` and `google-gemini-cli` still forward project IDs from stored OAuth credentials or structured Google keys when available, and the generated-model refresh path forwards the stored project ID too. Discovery diagnostics redact endpoint credentials, and custom loggers keep their method receiver.
|
|
22
|
+
- Google discovery cache identity now includes the session-selected project and the effective user agent for both Google providers, so catalogs are not reused across projects, CLI identities, or custom Antigravity user-agent overrides. Project-specific dynamic rows are also removed or withheld when the selected project changes.
|
|
23
|
+
|
|
24
|
+
- Automatic Anthropic prompt caching now also marks the last system block, so a new session reads the shared tools + system prefix instead of re-writing it.
|
|
25
|
+
|
|
26
|
+
- Anthropic automatic prompt caching no longer adds a root cache marker when caller markers already occupy all four breakpoints, which made the request fail validation.
|
|
27
|
+
|
|
28
|
+
- `disableReasoning` is now honored on the Bedrock path, so budget-mode Bedrock models keep the caller's requested output cap when reasoning is disabled.
|
|
29
|
+
|
|
30
|
+
- GLM ZCode OAuth endpoints and the client id (`ZCODE_OAUTH_*`) now resolve from the launching shell and user-owned env files, so a project `.env` cannot redirect the authorize, broker, or login calls. A dynamic project declaration also blocks a different shell value for that name.
|
|
31
|
+
|
|
32
|
+
- A usage limit that is scoped to one model (an explicit `scope.modelId`, or a model-family tier such as Claude's `opus`/`sonnet`) no longer takes the whole credential out of rotation. The block is recorded for that model only, ranking ignores limits scoped to other models, and callers that do not know the requested model keep the previous conservative behaviour. Plan and quota tiers (`Codex`/`Copilot` plans, Gemini quota tiers) still apply to every model.
|
|
33
|
+
|
|
34
|
+
- OpenAI Codex token refresh error messages now display readable error details instead of `[object Object]` when the OpenAI token endpoint returns structured error objects with `code`, `type`, and `message` fields. Both string errors (with optional `error_description`) and object errors are now handled correctly.
|
|
35
|
+
|
|
36
|
+
- `getProxyForUrl` ignores `PI_PROXY`, `PI_PROXY_<PROVIDER>`, `HTTP_PROXY`, `HTTPS_PROXY`, and `ALL_PROXY` (and their lowercase aliases) when the project dotenv declares that value. The startup snapshot remains in force when `--worktree` changes cwd before the proxy module's first use. A different shell value is still used only when that declaration is a comparable static value. A dynamic or incomparable declaration (expansion, quoted inner whitespace, or an escape the snapshot will not compare) drops the shell value as well.
|
|
37
|
+
|
|
38
|
+
- Orphan tool results restored as a user stale-tool-result note escape `&`, `<`, and `>` in the tool text, and attribute metacharacters in the tool name and id, so a closing tag in the tool output cannot end the note early.
|
|
39
|
+
|
|
40
|
+
## [0.18.12] - 2026-10-16
|
|
41
|
+
|
|
42
|
+
### Added
|
|
43
|
+
|
|
44
|
+
- Added the `org:<organization id or name>` credential selector, matching an OAuth credential by its organization id or display name (case-insensitive).
|
|
45
|
+
|
|
46
|
+
- `AuthStorageOptions.credentialPreferences` accepts an ordered, persisted soft OAuth account preference list per provider (`ConfiguredCredentialPreference[]`: selector plus optional `maxUsedFraction` cap per entry). Selection uses the first listed account that is usable and under its cap; when every listed account is blocked or capped, the unlisted accounts are ranked by balanced/earliest-reset ranking, and capped listed accounts are used only after those. Caps read the windows each provider reports, so they also apply to providers without a ranking strategy. Runtime `--credential`/`--prefer-credential` selectors and session stickiness take precedence. A list whose entries name one stored row twice (for example an email and `account:<id>` for the same login) is ignored as a whole and reported by `AuthStorage.findDuplicateCredentialPreferences()`.
|
|
47
|
+
|
|
48
|
+
- Add Gemini 4 Argon (`gemini-4-argon`) and send `thinkingLevel` (low/medium/high) for Gemini 4 models instead of falling back to `thinkingBudget`.
|
|
49
|
+
|
|
50
|
+
- Custom `openai-responses` relays whose base URL has a loopback hostname (`127.0.0.0/8`, `localhost`, `::1`) now send `session_id`/`x-client-request-id` affinity headers without an explicit opt-in. The ChatGPT codex backend only reuses a warmed prompt prefix for requests that carry a session identity, so such a relay previously reported zero cached tokens and replayed the entire context on every turn. Remote relays stay opt-in, known non-OpenAI provider IDs stay excluded, retention `none` still suppresses the headers, and `compat.supportsResponsesSessionAffinity: false` opts a loopback relay back out.
|
|
51
|
+
|
|
52
|
+
- Added `ultrafast` as a first-class ServiceTier option, alongside existing tiers (auto, default, flex, scale, priority)
|
|
53
|
+
- Support for OpenAI's ultrafast processing tier on OpenAI chat completions and Codex responses APIs
|
|
54
|
+
- 6x ultrafast multiplier for API token pricing (per OpenAI's official pricing: $60 input, $300 output for gpt-6-astra)
|
|
55
|
+
- Ultrafast service tier now properly resolves and sends to supported models
|
|
56
|
+
|
|
57
|
+
### Changed
|
|
58
|
+
|
|
59
|
+
- Use User-Agent-aware Antigravity model-cache validation so discovery catalogs are refreshed for the active client identity.
|
|
60
|
+
|
|
61
|
+
- `ServiceTier` type now includes "ultrafast" as a valid option
|
|
62
|
+
- `shouldSendServiceTier()` now includes ultrafast in provider send logic for OpenAI
|
|
63
|
+
- OpenAI chat server schema updated to accept "ultrafast" in service_tier field
|
|
64
|
+
- Codex included-usage estimates use the official Fast 2.5x and Ultrafast 8x multipliers
|
|
65
|
+
|
|
66
|
+
### Fixed
|
|
67
|
+
|
|
68
|
+
- Kiro streams now surface explicit content-filter refusal messages with category and explanation instead of the generic "no tokens" error when a refusal is detected. Both bearer token (via `messageMetadataEvent`) and API-key (`ksk_`, via `metadataEvent`) paths are supported, with proper provider safety-stop minting. Bearer-token text streams incrementally unless a thinking block precedes it; API-key text remains quarantined until clean EOF. Tool calls are emitted only at stream end (#6150).
|
|
69
|
+
- Detail-free `stopReason: "CONTENT_FILTERED"` (without `stopDetails.refusal` object) is now treated as a refusal and suppresses unconfirmed content.
|
|
70
|
+
- API-key text remains quarantined through `COMPLETED`/`TOOL_USE` metadata and is released only at clean EOF, so a later refusal or read failure cannot leak content across HTTP chunk boundaries.
|
|
71
|
+
- A refusal takes precedence over ordinary errors or successful completion in the same batch or a later read. An active tool may finish its input after `TOOL_USE`, while `COMPLETED` fences tool fragments and later content.
|
|
72
|
+
- Error events omit duplicate partial messages so credential-shaped upstream text cannot bypass gateway redaction or leak through SSE encoders.
|
|
73
|
+
- Parser no longer resyncs into nested objects when an incomplete outer JSON frame is encountered. Incomplete frames are retained as remainder; EOF with incomplete frame throws an error.
|
|
74
|
+
- Errors before clean EOF discard quarantined text and retain only explicitly completed tool calls.
|
|
75
|
+
|
|
76
|
+
- API-key validation now accepts successful inference responses that contain reasoning output or end at the token limit before producing text, and reports empty or missing choices accurately.
|
|
77
|
+
|
|
78
|
+
- An image Anthropic rejects with `Could not process image` no longer makes every later request in the session fail. The provider replaces the rejected image with a text placeholder and keeps omitting it on later turns and fallback models. The first repair omits the images of the newest message that has any; if the request still fails, the second omits every image (#6810).
|
|
79
|
+
|
|
80
|
+
- Anthropic OAuth keeps one stored credential per organization when a single account belongs to several organizations (for example a Team workspace and a personal Max plan). Credentials now record the organization from the token response, their identity key is scoped to it, so logging in to a second organization no longer replaces or disables the first, and usage limits are reported per organization instead of being merged across them. Rows stored before this change keep working and are deduplicated once their next refresh records the organization.
|
|
81
|
+
|
|
82
|
+
- Broker usage reports are matched to a credential by the identity (account, email, or project) and Anthropic organization they carry, checked against the current broker snapshot. A report without a matching identity is taken only when the provider has a single stored OAuth credential, so a lone report is no longer assigned to every credential of a provider that holds several. A credential stored without an Anthropic organization never takes a report whose organization another stored credential is scoped to, so a legacy row whose own usage fetch fails gets no fresh usage data instead of another row's or another account's limits.
|
|
83
|
+
- An `org:` selector that matches more than one stored credential (organizations sharing a display name) is rejected with the candidate row ids instead of resolving to the first row, and an exact organization-id match is preferred over display-name matches. Pin ambiguity errors now list the candidate row ids.
|
|
84
|
+
|
|
85
|
+
- Keep cached models from a different User-Agent out of failed-refresh fallbacks, and report the effective User-Agent in discovery diagnostics.
|
|
86
|
+
|
|
87
|
+
- Replace user and tool-result images with text markers for Bedrock models without image input, including consecutive tool results, while preserving image payloads for image-capable models.
|
|
88
|
+
|
|
89
|
+
- `--prefer-credential` now selects the designated OAuth account when the provider also stores API-key rows. The preferred row was matched by its index in the full credential list against OAuth-only candidate indices, so a mixed pool could move a different OAuth account to the front.
|
|
90
|
+
|
|
91
|
+
- OpenAI Responses and Completions streams now use a model's configured idle timeout when no environment or request override is set, so long reasoning gaps on compatible proxies can be tuned per model. Longer request-level idle windows also bound SDK setup before response headers arrive, and SDK timers are kept within the platform-safe range. Kimi Code's Anthropic-compatible route also honors its model timeout, with environment and request overrides retaining precedence.
|
|
92
|
+
|
|
93
|
+
- Normalize negative and non-finite model catalog prices to zero so bundled usage estimates cannot become negative.
|
|
94
|
+
|
|
95
|
+
- Switching the model cache to a different database path now fully releases the previous database. A migration query left an unfinalized prepared statement, so closing the old connection left it open in the background; it kept the database locked and, on Windows, blocked deleting its directory.
|
|
96
|
+
|
|
97
|
+
- Omit MCP tool-result image payloads from Ollama chat requests when the model does not support image input, retaining a text omission marker.
|
|
98
|
+
|
|
99
|
+
- Closing AuthStorage and the model cache now deterministically finalizes their owned SQLite statements before releasing the database, allowing immediate removal of owned scratch directories on Windows.
|
|
100
|
+
|
|
101
|
+
- Usage pricing now follows provider-reported effective tiers when available, and gateway responses preserve that tier for downstream clients.
|
|
102
|
+
|
|
103
|
+
### Notes
|
|
104
|
+
|
|
105
|
+
- Ultrafast tier is currently available for gpt-6-astra and gpt-6.1-sol. The gpt-5.6-sol model is Fast-only and is not eligible for ultrafast.
|
|
106
|
+
- For unsupported models, ultrafast is omitted and provider-default processing is used; no unsupported tier is sent.
|
|
107
|
+
|
|
5
108
|
## [0.18.11] - 2026-10-12
|
|
6
109
|
|
|
7
110
|
## [0.18.10] - 2026-10-12
|
package/README.md
CHANGED
|
@@ -782,7 +782,7 @@ interface OpenAICompat {
|
|
|
782
782
|
supportsStore?: boolean; // Whether provider supports the `store` field (default: true)
|
|
783
783
|
supportsDeveloperRole?: boolean; // Whether provider supports `developer` role vs `system` (default: true)
|
|
784
784
|
sendSessionHeaders?: boolean; // Forward the session id as `session_id`/`x-session-id` headers for relay session-affinity & prompt-cache reuse (default: false)
|
|
785
|
-
supportsResponsesSessionAffinity?: boolean; // Opt in to session-affinity headers for custom openai-responses relays; canonical OpenAI routing
|
|
785
|
+
supportsResponsesSessionAffinity?: boolean; // Opt in to session-affinity headers for custom openai-responses relays; canonical OpenAI routing and loopback-hostname relays are automatic (default: false for remote relays)
|
|
786
786
|
supportsReasoningEffort?: boolean; // Whether provider supports `reasoning_effort` (default: true)
|
|
787
787
|
maxTokensField?: "max_completion_tokens" | "max_tokens"; // Which field name to use (default: max_completion_tokens)
|
|
788
788
|
extraBody?: Record<string, unknown>; // Extra request-body fields for custom proxy routing or provider-specific options
|
|
@@ -25,6 +25,8 @@ export declare const oauthCredentialSchema: z.ZodObject<{
|
|
|
25
25
|
projectId: z.ZodOptional<z.ZodString>;
|
|
26
26
|
email: z.ZodOptional<z.ZodString>;
|
|
27
27
|
accountId: z.ZodOptional<z.ZodString>;
|
|
28
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
29
|
+
organizationName: z.ZodOptional<z.ZodString>;
|
|
28
30
|
mcpBinding: z.ZodOptional<z.ZodObject<{
|
|
29
31
|
resourceOrigin: z.ZodString;
|
|
30
32
|
tokenEndpoint: z.ZodString;
|
|
@@ -39,6 +41,8 @@ export declare const remoteOauthCredentialSchema: z.ZodObject<{
|
|
|
39
41
|
projectId: z.ZodOptional<z.ZodString>;
|
|
40
42
|
email: z.ZodOptional<z.ZodString>;
|
|
41
43
|
accountId: z.ZodOptional<z.ZodString>;
|
|
44
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
45
|
+
organizationName: z.ZodOptional<z.ZodString>;
|
|
42
46
|
mcpBinding: z.ZodOptional<z.ZodObject<{
|
|
43
47
|
resourceOrigin: z.ZodString;
|
|
44
48
|
tokenEndpoint: z.ZodString;
|
|
@@ -59,6 +63,8 @@ export declare const writableAuthCredentialSchema: z.ZodDiscriminatedUnion<[z.Zo
|
|
|
59
63
|
projectId: z.ZodOptional<z.ZodString>;
|
|
60
64
|
email: z.ZodOptional<z.ZodString>;
|
|
61
65
|
accountId: z.ZodOptional<z.ZodString>;
|
|
66
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
67
|
+
organizationName: z.ZodOptional<z.ZodString>;
|
|
62
68
|
mcpBinding: z.ZodOptional<z.ZodObject<{
|
|
63
69
|
resourceOrigin: z.ZodString;
|
|
64
70
|
tokenEndpoint: z.ZodString;
|
|
@@ -76,6 +82,8 @@ export declare const snapshotCredentialSchema: z.ZodDiscriminatedUnion<[z.ZodObj
|
|
|
76
82
|
projectId: z.ZodOptional<z.ZodString>;
|
|
77
83
|
email: z.ZodOptional<z.ZodString>;
|
|
78
84
|
accountId: z.ZodOptional<z.ZodString>;
|
|
85
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
86
|
+
organizationName: z.ZodOptional<z.ZodString>;
|
|
79
87
|
mcpBinding: z.ZodOptional<z.ZodObject<{
|
|
80
88
|
resourceOrigin: z.ZodString;
|
|
81
89
|
tokenEndpoint: z.ZodString;
|
|
@@ -96,6 +104,8 @@ export declare const credentialSnapshotEntrySchema: z.ZodObject<{
|
|
|
96
104
|
projectId: z.ZodOptional<z.ZodString>;
|
|
97
105
|
email: z.ZodOptional<z.ZodString>;
|
|
98
106
|
accountId: z.ZodOptional<z.ZodString>;
|
|
107
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
108
|
+
organizationName: z.ZodOptional<z.ZodString>;
|
|
99
109
|
mcpBinding: z.ZodOptional<z.ZodObject<{
|
|
100
110
|
resourceOrigin: z.ZodString;
|
|
101
111
|
tokenEndpoint: z.ZodString;
|
|
@@ -119,6 +129,8 @@ export declare const snapshotEntrySchema: z.ZodObject<{
|
|
|
119
129
|
projectId: z.ZodOptional<z.ZodString>;
|
|
120
130
|
email: z.ZodOptional<z.ZodString>;
|
|
121
131
|
accountId: z.ZodOptional<z.ZodString>;
|
|
132
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
133
|
+
organizationName: z.ZodOptional<z.ZodString>;
|
|
122
134
|
mcpBinding: z.ZodOptional<z.ZodObject<{
|
|
123
135
|
resourceOrigin: z.ZodString;
|
|
124
136
|
tokenEndpoint: z.ZodString;
|
|
@@ -160,6 +172,8 @@ export declare const snapshotResponseSchema: z.ZodObject<{
|
|
|
160
172
|
projectId: z.ZodOptional<z.ZodString>;
|
|
161
173
|
email: z.ZodOptional<z.ZodString>;
|
|
162
174
|
accountId: z.ZodOptional<z.ZodString>;
|
|
175
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
176
|
+
organizationName: z.ZodOptional<z.ZodString>;
|
|
163
177
|
mcpBinding: z.ZodOptional<z.ZodObject<{
|
|
164
178
|
resourceOrigin: z.ZodString;
|
|
165
179
|
tokenEndpoint: z.ZodString;
|
|
@@ -223,6 +237,8 @@ export declare const snapshotStreamSnapshotEventSchema: z.ZodObject<{
|
|
|
223
237
|
projectId: z.ZodOptional<z.ZodString>;
|
|
224
238
|
email: z.ZodOptional<z.ZodString>;
|
|
225
239
|
accountId: z.ZodOptional<z.ZodString>;
|
|
240
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
241
|
+
organizationName: z.ZodOptional<z.ZodString>;
|
|
226
242
|
mcpBinding: z.ZodOptional<z.ZodObject<{
|
|
227
243
|
resourceOrigin: z.ZodString;
|
|
228
244
|
tokenEndpoint: z.ZodString;
|
|
@@ -261,6 +277,8 @@ export declare const snapshotStreamEntryEventSchema: z.ZodObject<{
|
|
|
261
277
|
projectId: z.ZodOptional<z.ZodString>;
|
|
262
278
|
email: z.ZodOptional<z.ZodString>;
|
|
263
279
|
accountId: z.ZodOptional<z.ZodString>;
|
|
280
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
281
|
+
organizationName: z.ZodOptional<z.ZodString>;
|
|
264
282
|
mcpBinding: z.ZodOptional<z.ZodObject<{
|
|
265
283
|
resourceOrigin: z.ZodString;
|
|
266
284
|
tokenEndpoint: z.ZodString;
|
|
@@ -312,6 +330,8 @@ export declare const snapshotStreamEventSchema: z.ZodDiscriminatedUnion<[z.ZodOb
|
|
|
312
330
|
projectId: z.ZodOptional<z.ZodString>;
|
|
313
331
|
email: z.ZodOptional<z.ZodString>;
|
|
314
332
|
accountId: z.ZodOptional<z.ZodString>;
|
|
333
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
334
|
+
organizationName: z.ZodOptional<z.ZodString>;
|
|
315
335
|
mcpBinding: z.ZodOptional<z.ZodObject<{
|
|
316
336
|
resourceOrigin: z.ZodString;
|
|
317
337
|
tokenEndpoint: z.ZodString;
|
|
@@ -348,6 +368,8 @@ export declare const snapshotStreamEventSchema: z.ZodDiscriminatedUnion<[z.ZodOb
|
|
|
348
368
|
projectId: z.ZodOptional<z.ZodString>;
|
|
349
369
|
email: z.ZodOptional<z.ZodString>;
|
|
350
370
|
accountId: z.ZodOptional<z.ZodString>;
|
|
371
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
372
|
+
organizationName: z.ZodOptional<z.ZodString>;
|
|
351
373
|
mcpBinding: z.ZodOptional<z.ZodObject<{
|
|
352
374
|
resourceOrigin: z.ZodString;
|
|
353
375
|
tokenEndpoint: z.ZodString;
|
|
@@ -453,6 +475,8 @@ export declare const credentialRefreshResponseSchema: z.ZodObject<{
|
|
|
453
475
|
projectId: z.ZodOptional<z.ZodString>;
|
|
454
476
|
email: z.ZodOptional<z.ZodString>;
|
|
455
477
|
accountId: z.ZodOptional<z.ZodString>;
|
|
478
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
479
|
+
organizationName: z.ZodOptional<z.ZodString>;
|
|
456
480
|
mcpBinding: z.ZodOptional<z.ZodObject<{
|
|
457
481
|
resourceOrigin: z.ZodString;
|
|
458
482
|
tokenEndpoint: z.ZodString;
|
|
@@ -484,6 +508,8 @@ export declare const credentialUploadRequestSchema: z.ZodObject<{
|
|
|
484
508
|
projectId: z.ZodOptional<z.ZodString>;
|
|
485
509
|
email: z.ZodOptional<z.ZodString>;
|
|
486
510
|
accountId: z.ZodOptional<z.ZodString>;
|
|
511
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
512
|
+
organizationName: z.ZodOptional<z.ZodString>;
|
|
487
513
|
mcpBinding: z.ZodOptional<z.ZodObject<{
|
|
488
514
|
resourceOrigin: z.ZodString;
|
|
489
515
|
tokenEndpoint: z.ZodString;
|
|
@@ -505,6 +531,8 @@ export declare const credentialUploadResponseSchema: z.ZodObject<{
|
|
|
505
531
|
projectId: z.ZodOptional<z.ZodString>;
|
|
506
532
|
email: z.ZodOptional<z.ZodString>;
|
|
507
533
|
accountId: z.ZodOptional<z.ZodString>;
|
|
534
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
535
|
+
organizationName: z.ZodOptional<z.ZodString>;
|
|
508
536
|
mcpBinding: z.ZodOptional<z.ZodObject<{
|
|
509
537
|
resourceOrigin: z.ZodString;
|
|
510
538
|
tokenEndpoint: z.ZodString;
|
|
@@ -541,6 +569,8 @@ export declare const credentialIfAbsentUploadResponseSchema: z.ZodObject<{
|
|
|
541
569
|
projectId: z.ZodOptional<z.ZodString>;
|
|
542
570
|
email: z.ZodOptional<z.ZodString>;
|
|
543
571
|
accountId: z.ZodOptional<z.ZodString>;
|
|
572
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
573
|
+
organizationName: z.ZodOptional<z.ZodString>;
|
|
544
574
|
mcpBinding: z.ZodOptional<z.ZodObject<{
|
|
545
575
|
resourceOrigin: z.ZodString;
|
|
546
576
|
tokenEndpoint: z.ZodString;
|
|
@@ -91,6 +91,8 @@ export interface CredentialInventoryRecord {
|
|
|
91
91
|
accountId?: string;
|
|
92
92
|
email?: string;
|
|
93
93
|
projectId?: string;
|
|
94
|
+
organizationId?: string;
|
|
95
|
+
organizationName?: string;
|
|
94
96
|
disabled: boolean;
|
|
95
97
|
disabledCause: string | null;
|
|
96
98
|
}
|
|
@@ -466,6 +468,25 @@ export interface CredentialDisabledEvent {
|
|
|
466
468
|
* thrashes accounts mid-session / cold-starts the server-side prompt cache.
|
|
467
469
|
*/
|
|
468
470
|
export type CredentialRankingMode = "balanced" | "earliest-reset";
|
|
471
|
+
/**
|
|
472
|
+
* One entry of a provider's ordered, persisted soft preference list.
|
|
473
|
+
*
|
|
474
|
+
* Entries are consulted in list order when a credential is selected. Usable
|
|
475
|
+
* entries under their cap are tried first, in list order; the remaining
|
|
476
|
+
* credentials follow in the normal ranking order. An entry whose most-used
|
|
477
|
+
* known usage window has reached `maxUsedFraction` is demoted behind every
|
|
478
|
+
* other credential, so it is used only when nothing else is available. A
|
|
479
|
+
* blocked or missing entry is skipped. Unknown usage never counts as over the
|
|
480
|
+
* cap.
|
|
481
|
+
*
|
|
482
|
+
* Runtime selectors (`--credential`, `--prefer-credential`) and session
|
|
483
|
+
* stickiness take precedence over configured preferences.
|
|
484
|
+
*/
|
|
485
|
+
export interface ConfiguredCredentialPreference {
|
|
486
|
+
selector: AuthCredentialSelector;
|
|
487
|
+
/** Used fraction in (0, 1] at which this entry stops being preferred. Absent means only blocking moves past it. */
|
|
488
|
+
maxUsedFraction?: number;
|
|
489
|
+
}
|
|
469
490
|
/**
|
|
470
491
|
* Whether credential selection may probe provider usage endpoints.
|
|
471
492
|
*
|
|
@@ -481,6 +502,8 @@ export type AuthStorageOptions = {
|
|
|
481
502
|
usageProviderResolver?: (provider: Provider) => UsageProvider | undefined;
|
|
482
503
|
rankingStrategyResolver?: (provider: Provider) => CredentialRankingStrategy | undefined;
|
|
483
504
|
credentialRankingMode?: CredentialRankingMode;
|
|
505
|
+
/** Persisted ordered soft preferences keyed by provider id. */
|
|
506
|
+
credentialPreferences?: Readonly<Record<string, readonly ConfiguredCredentialPreference[]>>;
|
|
484
507
|
usageFetch?: typeof fetch;
|
|
485
508
|
usageRequestTimeoutMs?: number;
|
|
486
509
|
usageLogger?: UsageLogger;
|
|
@@ -548,11 +571,29 @@ export type AuthApiKeyOptions = {
|
|
|
548
571
|
/** Prefer one stored OAuth credential while preserving quota-triggered fallback. */
|
|
549
572
|
preferredCredentialSelector?: AuthCredentialSelector;
|
|
550
573
|
};
|
|
551
|
-
export type AuthCredentialSelectorKind = "id" | "email" | "account" | "project";
|
|
574
|
+
export type AuthCredentialSelectorKind = "id" | "email" | "account" | "project" | "org";
|
|
552
575
|
export interface AuthCredentialSelector {
|
|
553
576
|
kind: AuthCredentialSelectorKind;
|
|
554
577
|
value: string;
|
|
555
578
|
}
|
|
579
|
+
/**
|
|
580
|
+
* Whether an OAuth credential belongs to the organization named by an `org:`
|
|
581
|
+
* selector value: the organization id, or its display name (case-insensitive).
|
|
582
|
+
*/
|
|
583
|
+
export declare function oauthCredentialMatchesOrganization(credential: Pick<OAuthCredentials, "organizationId" | "organizationName">, value: string): boolean;
|
|
584
|
+
/**
|
|
585
|
+
* The items an `org:` selector designates. An exact organization-id match wins
|
|
586
|
+
* over display-name matches, because names are not unique: two organizations
|
|
587
|
+
* can share a name, and a name can equal another organization's id. Callers
|
|
588
|
+
* must treat more than one result as ambiguous rather than picking one.
|
|
589
|
+
*/
|
|
590
|
+
export declare function selectOrganizationMatches<T>(items: readonly T[], value: string, organizationOf: (item: T) => Pick<OAuthCredentials, "organizationId" | "organizationName"> | undefined): T[];
|
|
591
|
+
/**
|
|
592
|
+
* Human-facing identity of a stored OAuth credential. The organization name is
|
|
593
|
+
* appended because one account (same email) can hold one credential per
|
|
594
|
+
* organization.
|
|
595
|
+
*/
|
|
596
|
+
export declare function formatOAuthIdentityLabel(credential: Pick<OAuthCredentials, "email" | "accountId" | "projectId" | "organizationName">): string | null;
|
|
556
597
|
/**
|
|
557
598
|
* Refreshed OAuth access plus identity metadata returned by
|
|
558
599
|
* {@link AuthStorage.getOAuthAccess}. Callers that authenticate via a bearer
|
|
@@ -577,11 +618,6 @@ export interface InvalidateCredentialMatchingOptions {
|
|
|
577
618
|
/** Read optional broker error detail without allowing hostile objects to escape classification. */
|
|
578
619
|
/** @internal Tested directly because hostile accessors must preserve the original error identity. */
|
|
579
620
|
export declare function readBrokerErrorBody(error: unknown): string | undefined;
|
|
580
|
-
/**
|
|
581
|
-
* Credential storage backed by an AuthCredentialStore.
|
|
582
|
-
* Reads from storage on reload(), manages round-robin credential selection,
|
|
583
|
-
* usage limit tracking, and OAuth token refresh.
|
|
584
|
-
*/
|
|
585
621
|
export declare class AuthStorage {
|
|
586
622
|
#private;
|
|
587
623
|
constructor(store: AuthCredentialStore, options?: AuthStorageOptions);
|
|
@@ -607,7 +643,13 @@ export declare class AuthStorage {
|
|
|
607
643
|
allocateMonotonicSequence(key: string, expiresAtSec: number): number;
|
|
608
644
|
getProviderConfigurationGeneration(provider: string, owner?: object): number;
|
|
609
645
|
getProviderOAuthRefreshGeneration(provider: string): number;
|
|
610
|
-
|
|
646
|
+
/**
|
|
647
|
+
* Return provider-specific discovery evidence. `stagedConfigApiKey` lets a read-only
|
|
648
|
+
* config candidate derive the same fingerprint before its owner-scoped override is published.
|
|
649
|
+
*/
|
|
650
|
+
getProviderEvidenceGeneration(provider: string, resolvedApiKey?: string, owner?: object, stagedConfigApiKey?: {
|
|
651
|
+
apiKey: string;
|
|
652
|
+
}): string;
|
|
611
653
|
onGenerationChanged(listener: (generation: number) => void): () => void;
|
|
612
654
|
offGenerationChanged(listener: (generation: number) => void): void;
|
|
613
655
|
/**
|
|
@@ -725,6 +767,8 @@ export declare class AuthStorage {
|
|
|
725
767
|
hasRuntimeCredentialSelector(provider: string): boolean;
|
|
726
768
|
/** Whether the effective selector for a session scope is pinned. */
|
|
727
769
|
hasEffectiveCredentialSelector(provider: string, sessionId?: string): boolean;
|
|
770
|
+
/** Whether any runtime/session scope has a credential pin, including an unavailable hard pin. */
|
|
771
|
+
hasAnyCredentialPin(provider: string): boolean;
|
|
728
772
|
/**
|
|
729
773
|
* Opaque stored row id of the credential this session is currently using.
|
|
730
774
|
*
|
|
@@ -738,6 +782,21 @@ export declare class AuthStorage {
|
|
|
738
782
|
* resolver rather than a stored row.
|
|
739
783
|
*/
|
|
740
784
|
getSessionCredentialRowId(provider: string, sessionId?: string): number | undefined;
|
|
785
|
+
/** Return the stored OAuth row pinned by a credential selector without resolving tokens. */
|
|
786
|
+
getSelectedOAuthCredentialRowId(provider: string, sessionId?: string, options?: Pick<AuthApiKeyOptions, "owner">): number | undefined;
|
|
787
|
+
/** Return the usable OAuth row selected by a soft preferred-credential selector. */
|
|
788
|
+
getPreferredOAuthCredentialRowId(provider: string): number | undefined;
|
|
789
|
+
/** Return the stored API-key row pinned by a credential selector without resolving values. */
|
|
790
|
+
getSelectedApiKeyCredentialRowId(provider: string, sessionId?: string, options?: Pick<AuthApiKeyOptions, "owner">): number | undefined;
|
|
791
|
+
/**
|
|
792
|
+
* Preview the stored API-key row request dispatch would try for this session.
|
|
793
|
+
* Requires a session id so the deterministic session order is used instead
|
|
794
|
+
* of advancing the provider's round-robin cursor. Does not resolve key values
|
|
795
|
+
* or mutate session selection.
|
|
796
|
+
*/
|
|
797
|
+
getProspectiveApiKeyCredentialRowId(provider: string, sessionId: string | undefined, options?: Pick<AuthApiKeyOptions, "owner">): number | undefined;
|
|
798
|
+
/** Cached usability of a stored API key; never resolves command-backed values. */
|
|
799
|
+
getStoredApiKeyUsability(provider: string, rowId: number): boolean | undefined;
|
|
741
800
|
/** Whether an enabled stored row is currently available outside quota backoff. */
|
|
742
801
|
isCredentialAvailable(provider: string, rowId: number): boolean;
|
|
743
802
|
/**
|
|
@@ -830,6 +889,14 @@ export declare class AuthStorage {
|
|
|
830
889
|
acquireCredentialDispatchTicket(provider: Provider, signal?: AbortSignal): Promise<CredentialDispatchTicket | undefined>;
|
|
831
890
|
/** Returns the credential type selected for a provider/session, if one has been recorded. */
|
|
832
891
|
getSessionCredentialType(provider: string, sessionId?: string): AuthCredential["type"] | undefined;
|
|
892
|
+
/**
|
|
893
|
+
* Providers whose configured preference list names one stored credential row through more than one entry, for
|
|
894
|
+
* example `email:` and `account:` selectors for the same login. Startup rejects such a list.
|
|
895
|
+
*/
|
|
896
|
+
findDuplicateCredentialPreferences(): Array<{
|
|
897
|
+
provider: string;
|
|
898
|
+
credentialId: number;
|
|
899
|
+
}>;
|
|
833
900
|
/**
|
|
834
901
|
* Get credential for a provider (first entry if multiple).
|
|
835
902
|
*/
|
|
@@ -858,11 +925,11 @@ export declare class AuthStorage {
|
|
|
858
925
|
* Mirrors getApiKey selector validation, overrides, session OAuth stickiness,
|
|
859
926
|
* cached command-key usability, OAuth retry, and environment fallback order.
|
|
860
927
|
*/
|
|
861
|
-
getEffectiveCredentialType(provider: string, sessionId?: string, options?: Pick<AuthApiKeyOptions, "owner">): AuthCredential["type"] | undefined;
|
|
862
|
-
/**
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
928
|
+
getEffectiveCredentialType(provider: string, sessionId?: string, options?: Pick<AuthApiKeyOptions, "owner" | "credentialSelector">): AuthCredential["type"] | undefined;
|
|
929
|
+
/** Check whether configured auth is usable without resolving credentials or refreshing OAuth. */
|
|
930
|
+
hasUsableAuth(provider: string, options?: Pick<AuthApiKeyOptions, "owner" | "credentialSelector"> & {
|
|
931
|
+
sessionId?: string;
|
|
932
|
+
}): boolean;
|
|
866
933
|
/**
|
|
867
934
|
* Check if OAuth credentials are configured for a provider.
|
|
868
935
|
*/
|
|
@@ -956,7 +1023,17 @@ export declare class AuthStorage {
|
|
|
956
1023
|
signal?: AbortSignal;
|
|
957
1024
|
owner?: object;
|
|
958
1025
|
rowId?: number;
|
|
1026
|
+
/** Scope the block to one model; other models keep using the credential. */
|
|
1027
|
+
modelId?: string;
|
|
959
1028
|
}): Promise<UsageLimitMarkResult>;
|
|
1029
|
+
/**
|
|
1030
|
+
* Opaque stored row IDs for credentials whose resolved key matches `apiKey`.
|
|
1031
|
+
* Unlike the session's sticky row pointer, these remain tied to the actual key
|
|
1032
|
+
* when concurrent requests share a credential session ID.
|
|
1033
|
+
* A row that cannot be resolved is skipped so an unrelated resolver failure
|
|
1034
|
+
* cannot prevent callers from using already-known credential identity.
|
|
1035
|
+
*/
|
|
1036
|
+
getCredentialRowIdsMatchingApiKey(provider: string, apiKey: string): Promise<number[]>;
|
|
960
1037
|
/**
|
|
961
1038
|
* Mark the stored credential whose key matches `apiKey` usage-limited for
|
|
962
1039
|
* `retryAfterMs` (or the default backoff). Used when the caller knows
|
|
@@ -983,7 +1060,7 @@ export declare class AuthStorage {
|
|
|
983
1060
|
* and get a best-effort token. For GitHub Copilot we preserve enterprise
|
|
984
1061
|
* routing metadata so discovery can hit the correct host.
|
|
985
1062
|
*/
|
|
986
|
-
peekApiKey(provider: string, options?:
|
|
1063
|
+
peekApiKey(provider: string, options?: AuthApiKeyOptions & {
|
|
987
1064
|
sessionId?: string;
|
|
988
1065
|
}): Promise<string | undefined>;
|
|
989
1066
|
/**
|
|
@@ -1002,6 +1079,14 @@ export declare class AuthStorage {
|
|
|
1002
1079
|
* 10. Fallback resolver (models.yml custom providers, last-resort)
|
|
1003
1080
|
*/
|
|
1004
1081
|
getApiKey(provider: string, sessionId?: string, options?: AuthApiKeyOptions): Promise<string | undefined>;
|
|
1082
|
+
/**
|
|
1083
|
+
* Resolve an API key and retain the selected stored row identity across token refreshes
|
|
1084
|
+
* and concurrent changes to the session's sticky credential pointer.
|
|
1085
|
+
*/
|
|
1086
|
+
getApiKeyWithCredentialRowId(provider: string, sessionId?: string, options?: AuthApiKeyOptions): Promise<{
|
|
1087
|
+
apiKey: string | undefined;
|
|
1088
|
+
credentialRowId: number | undefined;
|
|
1089
|
+
}>;
|
|
1005
1090
|
/**
|
|
1006
1091
|
* Resolve the OAuth credential for `provider`, refreshing through the same
|
|
1007
1092
|
* pipeline as {@link AuthStorage.getApiKey} but returning the refreshed
|
|
@@ -10,7 +10,7 @@ export type BedrockClaudeGeneration = {
|
|
|
10
10
|
* - family-first (3.x era): anthropic.claude-3-5-haiku-20241022-v1:0
|
|
11
11
|
* - kind-first (4+ era): anthropic.claude-opus-4-20250514-v1:0,
|
|
12
12
|
* anthropic.claude-haiku-4-5-20251001-v1:0
|
|
13
|
-
* Cross-region profiles (us./eu./au./jp./apac./global. prefixes) and inference-profile
|
|
13
|
+
* Cross-region profiles (us./eu./au./jp./apac./global./in. prefixes) and inference-profile
|
|
14
14
|
* ARNs keep the canonical model id as their final path segment.
|
|
15
15
|
*/
|
|
16
16
|
export declare function parseBedrockClaudeGeneration(id: string): BedrockClaudeGeneration | undefined;
|
|
@@ -14,11 +14,13 @@ interface CacheEntry<TApi extends Api = Api> {
|
|
|
14
14
|
/** IDs returned by the authoritative dynamic provider catalog, when retained. */
|
|
15
15
|
dynamicModelIds: string[] | undefined;
|
|
16
16
|
dynamicModelProvenance: string | undefined;
|
|
17
|
+
/** User-Agent used during discovery; invalidates cache if it changes. */
|
|
18
|
+
discoveryUserAgent: string | undefined;
|
|
17
19
|
}
|
|
18
20
|
/** Close the shared cache only when it owns the exact requested database path. */
|
|
19
21
|
export declare function closeModelCache(dbPath?: string): boolean;
|
|
20
|
-
export declare function readModelCache<TApi extends Api>(providerId: string, ttlMs: number, now: () => number, dbPath?: string): CacheEntry<TApi> | null;
|
|
21
|
-
export declare function writeModelCache<TApi extends Api>(providerId: string, updatedAt: number, models: Model<TApi>[], authoritative: boolean, staticFingerprint: string, dbPath?: string, dynamicModelIds?: readonly string[], dynamicModelProvenance?: string): void;
|
|
22
|
-
export declare function insertModelCacheIfAbsent<TApi extends Api>(providerId: string, updatedAt: number, models: Model<TApi>[], authoritative: boolean, staticFingerprint: string, dbPath?: string, dynamicModelIds?: readonly string[], dynamicModelProvenance?: string): boolean;
|
|
23
|
-
export declare function updateModelCacheIfUnchanged<TApi extends Api>(providerId: string, expectedUpdatedAt: number, expectedDynamicModelIds: readonly string[] | undefined, expectedDynamicModelProvenance: string | undefined, expectedModels: readonly Model<TApi>[], updatedAt: number, models: Model<TApi>[], authoritative: boolean, staticFingerprint: string, dbPath?: string, dynamicModelIds?: readonly string[], dynamicModelProvenance?: string): boolean;
|
|
22
|
+
export declare function readModelCache<TApi extends Api>(providerId: string, ttlMs: number, now: () => number, dbPath?: string, expectedDiscoveryUserAgent?: string): CacheEntry<TApi> | null;
|
|
23
|
+
export declare function writeModelCache<TApi extends Api>(providerId: string, updatedAt: number, models: Model<TApi>[], authoritative: boolean, staticFingerprint: string, dbPath?: string, dynamicModelIds?: readonly string[], dynamicModelProvenance?: string, discoveryUserAgent?: string): void;
|
|
24
|
+
export declare function insertModelCacheIfAbsent<TApi extends Api>(providerId: string, updatedAt: number, models: Model<TApi>[], authoritative: boolean, staticFingerprint: string, dbPath?: string, dynamicModelIds?: readonly string[], dynamicModelProvenance?: string, discoveryUserAgent?: string): boolean;
|
|
25
|
+
export declare function updateModelCacheIfUnchanged<TApi extends Api>(providerId: string, expectedUpdatedAt: number, expectedDynamicModelIds: readonly string[] | undefined, expectedDynamicModelProvenance: string | undefined, expectedModels: readonly Model<TApi>[], expectedDiscoveryUserAgent: string | undefined, updatedAt: number, models: Model<TApi>[], authoritative: boolean, staticFingerprint: string, dbPath?: string, dynamicModelIds?: readonly string[], dynamicModelProvenance?: string, discoveryUserAgent?: string): boolean;
|
|
24
26
|
export {};
|
|
@@ -34,6 +34,8 @@ export interface ModelManagerOptions<TApi extends Api = Api, TModelsDevPayload =
|
|
|
34
34
|
canPublishCache?: () => boolean;
|
|
35
35
|
/** Credential-and-endpoint identity required to reuse dynamic catalog IDs. */
|
|
36
36
|
cacheDynamicModelProvenance?: string;
|
|
37
|
+
/** Discovery User-Agent (e.g., for Antigravity): cache invalidates on change. */
|
|
38
|
+
discoveryUserAgent?: string;
|
|
37
39
|
}
|
|
38
40
|
/**
|
|
39
41
|
* Resolution result.
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import type { Api, Model, ModelCost } from "./types";
|
|
2
2
|
export declare function getOpenAIModelCost<TApi extends Api>(model: Model<TApi>, inputTokens: number): ModelCost | undefined;
|
|
3
|
+
export declare function getAnthropicModelCost<TApi extends Api>(model: Model<TApi>, inputTokens: number): ModelCost | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* $/million rate for 1-hour cache writes, or undefined when the model has a single
|
|
6
|
+
* cache-write rate. Cost calculation applies it to `usage.cttl.ephemeral1h` and bills
|
|
7
|
+
* the remaining cache-write tokens at `ModelCost.cacheWrite`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getAnthropicCacheWriteOneHourRate<TApi extends Api>(model: Model<TApi>, inputTokens: number): number | undefined;
|
|
10
|
+
export declare function applyAnthropicModelPricing<TApi extends Api>(model: Model<TApi>): void;
|
|
3
11
|
export declare function applyOpenAIModelPricing<TApi extends Api>(model: Model<TApi>): void;
|
|
@@ -87,12 +87,23 @@ export declare function mapEffortToAnthropicAdaptiveEffort<TApi extends Api>(mod
|
|
|
87
87
|
* - Thinking content is omitted by default (needs display: "summarized")
|
|
88
88
|
*/
|
|
89
89
|
export declare function hasOpus47ApiRestrictions(modelId: string): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Haiku 5+ enables adaptive thinking when the `thinking` field is omitted.
|
|
92
|
+
* An explicit user-facing Off choice must therefore send `type: "disabled"`.
|
|
93
|
+
*/
|
|
94
|
+
export declare function requiresAnthropicThinkingDisableWhenOff(modelId: string): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Haiku 5+ and Opus 4.7+ reject sampling parameters on the Anthropic Messages API.
|
|
97
|
+
* https://platform.claude.com/docs/en/models/haiku-5-5/migration-guide#remove-sampling-parameters
|
|
98
|
+
*/
|
|
99
|
+
export declare function hasAnthropicModelSamplingRestrictions(modelId: string): boolean;
|
|
90
100
|
/**
|
|
91
101
|
* Adaptive thinking `display` is supported starting with Anthropic Opus 4.7.
|
|
92
102
|
* Older adaptive-thinking models (Opus 4.6, Sonnet 4.6+) reject the field.
|
|
93
103
|
* Fable (5+) postdates Opus 4.7, accepts `display`, and defaults it to
|
|
94
104
|
* "omitted" — thinking tokens are billed but no content streams back — so it
|
|
95
105
|
* must opt in like Opus 4.7+ (issue #2791).
|
|
106
|
+
* Haiku 5+ also accepts `display` and defaults it to "omitted".
|
|
96
107
|
*
|
|
97
108
|
* Shares `hasOpus47ApiRestrictions` version parsing on purpose: the two
|
|
98
109
|
* predicates describe the same API generation, and a private `claude-opus-(\d+)-(\d+)`
|
|
@@ -27,13 +27,14 @@ export declare function isDirectXaiReasoningEffortModel(model: {
|
|
|
27
27
|
api?: string;
|
|
28
28
|
baseUrl?: string;
|
|
29
29
|
}, resolvedBaseUrl?: string): boolean;
|
|
30
|
-
export type ResolvedOpenAICompat = Required<Omit<OpenAICompat, "openRouterRouting" | "vercelGatewayRouting" | "extraBody" | "toolStrictMode" | "toolChoiceSupport" | "supportsResponsesSessionAffinity" | "supportsServiceTier" | "reservedToolNames">> & {
|
|
30
|
+
export type ResolvedOpenAICompat = Required<Omit<OpenAICompat, "openRouterRouting" | "vercelGatewayRouting" | "extraBody" | "toolStrictMode" | "toolChoiceSupport" | "supportsResponsesSessionAffinity" | "supportsServiceTier" | "supportsUltrafastTier" | "reservedToolNames">> & {
|
|
31
31
|
openRouterRouting?: OpenAICompat["openRouterRouting"];
|
|
32
32
|
vercelGatewayRouting?: OpenAICompat["vercelGatewayRouting"];
|
|
33
33
|
extraBody?: OpenAICompat["extraBody"];
|
|
34
34
|
toolStrictMode: ResolvedToolStrictMode;
|
|
35
35
|
supportsResponsesSessionAffinity?: OpenAICompat["supportsResponsesSessionAffinity"];
|
|
36
36
|
supportsServiceTier?: OpenAICompat["supportsServiceTier"];
|
|
37
|
+
supportsUltrafastTier?: OpenAICompat["supportsUltrafastTier"];
|
|
37
38
|
/** Optional explicit capability override; resolved via deriveToolChoiceSupport. */
|
|
38
39
|
toolChoiceSupport?: OpenAICompat["toolChoiceSupport"];
|
|
39
40
|
};
|
|
@@ -9,10 +9,12 @@ export interface GoogleVertexModelManagerConfig {
|
|
|
9
9
|
export interface GoogleAntigravityModelManagerConfig {
|
|
10
10
|
oauthToken?: string;
|
|
11
11
|
endpoint?: string;
|
|
12
|
+
project?: string;
|
|
12
13
|
}
|
|
13
14
|
export interface GoogleGeminiCliModelManagerConfig {
|
|
14
15
|
oauthToken?: string;
|
|
15
16
|
endpoint?: string;
|
|
17
|
+
project?: string;
|
|
16
18
|
}
|
|
17
19
|
export declare function googleModelManagerOptions(config?: GoogleModelManagerConfig): ModelManagerOptions<"google-generative-ai">;
|
|
18
20
|
export declare function googleVertexModelManagerOptions(_config?: GoogleVertexModelManagerConfig): ModelManagerOptions<"google-vertex">;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { parseBedrockClaudeGeneration } from "../bedrock-claude-cache-policy";
|
|
10
10
|
import type { Effort } from "../model-thinking";
|
|
11
|
-
import type { Model, StreamFunction, StreamOptions, ThinkingBudgets, Tool, ToolChoice } from "../types";
|
|
11
|
+
import type { AssistantMessage, CacheRetention, Model, StreamFunction, StreamOptions, ThinkingBudgets, Tool, ToolChoice } from "../types";
|
|
12
12
|
export type BedrockThinkingDisplay = "summarized" | "omitted";
|
|
13
13
|
export interface BedrockOptions extends StreamOptions {
|
|
14
14
|
region?: string;
|
|
@@ -51,7 +51,18 @@ interface WireToolConfig {
|
|
|
51
51
|
tools: WireToolSpec[];
|
|
52
52
|
toolChoice?: WireToolChoice;
|
|
53
53
|
}
|
|
54
|
+
interface MetadataEvent {
|
|
55
|
+
usage?: {
|
|
56
|
+
inputTokens?: number;
|
|
57
|
+
outputTokens?: number;
|
|
58
|
+
cacheReadInputTokens?: number;
|
|
59
|
+
cacheWriteInputTokens?: number;
|
|
60
|
+
totalTokens?: number;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
54
63
|
export declare const streamBedrock: StreamFunction<"bedrock-converse-stream">;
|
|
64
|
+
/** Exported for unit tests of the usage-to-cost path. */
|
|
65
|
+
export declare function handleMetadata(event: MetadataEvent, model: Model<"bedrock-converse-stream">, output: AssistantMessage, cacheRetention: CacheRetention): void;
|
|
55
66
|
/**
|
|
56
67
|
* Check if the model supports prompt caching.
|
|
57
68
|
* Supported: Claude 3.5 Haiku, Claude 3.7 Sonnet, and every later Claude
|
|
@@ -71,5 +82,9 @@ export declare function stripBedrockForcedToolChoiceForRetry<T extends {
|
|
|
71
82
|
toolConfig?: {
|
|
72
83
|
toolChoice?: unknown;
|
|
73
84
|
};
|
|
74
|
-
|
|
85
|
+
additionalModelRequestFields?: Record<string, unknown>;
|
|
86
|
+
}>(body: T, thinking?: {
|
|
87
|
+
forced: Record<string, unknown> | undefined;
|
|
88
|
+
restored: Record<string, unknown>;
|
|
89
|
+
}): T;
|
|
75
90
|
export declare function convertToolConfig(tools: Tool[] | undefined, toolChoice: BedrockOptions["toolChoice"]): WireToolConfig | undefined;
|