@gajae-code/ai 0.18.12 → 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 +35 -0
- package/dist/types/auth-storage.d.ts +18 -5
- package/dist/types/model-pricing.d.ts +8 -0
- package/dist/types/model-thinking.d.ts +11 -0
- 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 +15 -0
- package/dist/types/providers/google-gemini-headers.d.ts +1 -1
- package/dist/types/utils/discovery/antigravity.d.ts +5 -1
- package/dist/types/utils/oauth/glm-zcode.d.ts +0 -30
- package/package.json +3 -3
- package/src/auth-storage.ts +261 -52
- 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 +60 -5
- package/src/models.json +245 -0
- package/src/models.ts +10 -3
- package/src/provider-models/google.ts +4 -0
- package/src/providers/amazon-bedrock.d.ts +17 -2
- package/src/providers/amazon-bedrock.ts +56 -5
- package/src/providers/anthropic.d.ts +15 -0
- package/src/providers/anthropic.ts +91 -14
- package/src/providers/google-gemini-headers.d.ts +1 -1
- package/src/providers/google-gemini-headers.ts +6 -6
- package/src/providers/transform-messages.ts +32 -1
- package/src/stream.ts +4 -4
- package/src/utils/discovery/antigravity.ts +69 -26
- 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/proxy.ts +35 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,41 @@
|
|
|
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
|
+
|
|
5
40
|
## [0.18.12] - 2026-10-16
|
|
6
41
|
|
|
7
42
|
### Added
|
|
@@ -618,11 +618,6 @@ export interface InvalidateCredentialMatchingOptions {
|
|
|
618
618
|
/** Read optional broker error detail without allowing hostile objects to escape classification. */
|
|
619
619
|
/** @internal Tested directly because hostile accessors must preserve the original error identity. */
|
|
620
620
|
export declare function readBrokerErrorBody(error: unknown): string | undefined;
|
|
621
|
-
/**
|
|
622
|
-
* Credential storage backed by an AuthCredentialStore.
|
|
623
|
-
* Reads from storage on reload(), manages round-robin credential selection,
|
|
624
|
-
* usage limit tracking, and OAuth token refresh.
|
|
625
|
-
*/
|
|
626
621
|
export declare class AuthStorage {
|
|
627
622
|
#private;
|
|
628
623
|
constructor(store: AuthCredentialStore, options?: AuthStorageOptions);
|
|
@@ -1028,7 +1023,17 @@ export declare class AuthStorage {
|
|
|
1028
1023
|
signal?: AbortSignal;
|
|
1029
1024
|
owner?: object;
|
|
1030
1025
|
rowId?: number;
|
|
1026
|
+
/** Scope the block to one model; other models keep using the credential. */
|
|
1027
|
+
modelId?: string;
|
|
1031
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[]>;
|
|
1032
1037
|
/**
|
|
1033
1038
|
* Mark the stored credential whose key matches `apiKey` usage-limited for
|
|
1034
1039
|
* `retryAfterMs` (or the default backoff). Used when the caller knows
|
|
@@ -1074,6 +1079,14 @@ export declare class AuthStorage {
|
|
|
1074
1079
|
* 10. Fallback resolver (models.yml custom providers, last-resort)
|
|
1075
1080
|
*/
|
|
1076
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
|
+
}>;
|
|
1077
1090
|
/**
|
|
1078
1091
|
* Resolve the OAuth credential for `provider`, refreshing through the same
|
|
1079
1092
|
* pipeline as {@link AuthStorage.getApiKey} but returning the refreshed
|
|
@@ -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+)`
|
|
@@ -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;
|
|
@@ -117,6 +117,14 @@ export interface CpaToolAliasRestoreFailure {
|
|
|
117
117
|
*/
|
|
118
118
|
export declare function parseCpaToolAliasRestoreFailure(error: unknown): CpaToolAliasRestoreFailure | undefined;
|
|
119
119
|
export declare function isCpaToolAliasRestoreFailure(error: unknown): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* How many breakpoints we are still willing to generate after a gateway has
|
|
122
|
+
* rejected a previous attempt. `explicit` mode normally emits two (a reusable
|
|
123
|
+
* prefix anchor on the last assistant turn plus a refresh point on the current
|
|
124
|
+
* user turn), so stepping down to one still caches the prefix, and only the
|
|
125
|
+
* final step gives caching up entirely.
|
|
126
|
+
*/
|
|
127
|
+
type GeneratedCacheBudget = 2 | 1 | 0;
|
|
120
128
|
export declare const claudeCodeEntrypoint = "sdk-cli";
|
|
121
129
|
export declare const claudeToolPrefix: string;
|
|
122
130
|
export declare const claudeCodeSystemInstruction = "You are a Claude agent, built on Anthropic's Claude Agent SDK.";
|
|
@@ -228,6 +236,8 @@ export type AnthropicClientOptionsResult = {
|
|
|
228
236
|
fetchOptions?: AnthropicSdkClientOptions["fetchOptions"];
|
|
229
237
|
};
|
|
230
238
|
export declare function resolveGlmZcodeAnthropicBaseUrl(): string;
|
|
239
|
+
/** Compresses request bodies with gzip for first-party Anthropic endpoints only. */
|
|
240
|
+
export declare function wrapAnthropicFetchForGzip(baseFetch: FetchImpl): FetchImpl;
|
|
231
241
|
export declare function isProviderRetryableError(error: unknown, provider?: string): boolean;
|
|
232
242
|
export type AnthropicUsageLike = {
|
|
233
243
|
cache_creation?: {
|
|
@@ -261,6 +271,11 @@ type SystemBlockOptions = {
|
|
|
261
271
|
export declare function buildAnthropicSystemBlocks(systemPrompt: readonly string[] | undefined, options?: SystemBlockOptions): AnthropicSystemBlock[] | undefined;
|
|
262
272
|
export declare function normalizeExtraBetas(betas?: string[] | string): string[];
|
|
263
273
|
export declare function buildAnthropicClientOptions(args: AnthropicClientOptionsArgs): AnthropicClientOptionsResult;
|
|
274
|
+
type AnthropicCacheParams = MessageCreateParamsStreaming & {
|
|
275
|
+
cache_control?: AnthropicCacheControl;
|
|
276
|
+
};
|
|
277
|
+
type AnthropicCacheMode = "automatic" | "explicit" | "none";
|
|
278
|
+
export declare function applyPromptCaching(params: AnthropicCacheParams, cacheMode: AnthropicCacheMode, cacheControl?: AnthropicCacheControl, budget?: GeneratedCacheBudget): void;
|
|
264
279
|
export declare function normalizeCacheControlTtlOrdering(params: MessageCreateParamsStreaming): void;
|
|
265
280
|
export declare function convertAnthropicMessages(messages: Message[], model: Model<"anthropic-messages">, isOAuthToken: boolean, options?: {
|
|
266
281
|
repairLatestAssistantThinking?: boolean;
|
|
@@ -42,7 +42,7 @@ export declare const ANTIGRAVITY_SYSTEM_INSTRUCTION = "You are Antigravity, a po
|
|
|
42
42
|
*
|
|
43
43
|
* Overridable via PI_AI_ANTIGRAVITY_USER_AGENT environment variable.
|
|
44
44
|
*/
|
|
45
|
-
export declare
|
|
45
|
+
export declare function getAntigravityUserAgent(): string;
|
|
46
46
|
export declare const getAntigravityRequestHeaders: () => {
|
|
47
47
|
"User-Agent": string;
|
|
48
48
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { logger } from "@gajae-code/utils";
|
|
1
2
|
import type { Model } from "../../types";
|
|
2
3
|
/**
|
|
3
4
|
* Returns the default Antigravity discovery User-Agent.
|
|
@@ -54,7 +55,7 @@ export interface FetchAntigravityDiscoveryModelsOptions {
|
|
|
54
55
|
token: string;
|
|
55
56
|
/** Optional endpoint override. Defaults to Antigravity fallback endpoints. */
|
|
56
57
|
endpoint?: string;
|
|
57
|
-
/**
|
|
58
|
+
/** Optional Google Cloud project ID for tier-gated model discovery. */
|
|
58
59
|
project?: string;
|
|
59
60
|
/** Optional user agent override. */
|
|
60
61
|
userAgent?: string;
|
|
@@ -68,6 +69,8 @@ export interface FetchAntigravityDiscoveryModelsOptions {
|
|
|
68
69
|
* Default: `google-antigravity`.
|
|
69
70
|
*/
|
|
70
71
|
targetProvider?: "google-antigravity" | "google-gemini-cli";
|
|
72
|
+
/** Optional logger for debug diagnostics. */
|
|
73
|
+
logger?: Pick<typeof logger, "debug">;
|
|
71
74
|
}
|
|
72
75
|
/**
|
|
73
76
|
* Fetches discoverable Antigravity models and normalizes them into canonical model entries.
|
|
@@ -76,3 +79,4 @@ export interface FetchAntigravityDiscoveryModelsOptions {
|
|
|
76
79
|
* Returns `[]` only when the endpoint responds successfully with no usable models.
|
|
77
80
|
*/
|
|
78
81
|
export declare function fetchAntigravityDiscoveryModels(options: FetchAntigravityDiscoveryModelsOptions): Promise<Model<"google-gemini-cli">[] | null>;
|
|
82
|
+
export declare function getAntigravityDiscoveryUserAgent(): string;
|
|
@@ -1,33 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GLM ZCode OAuth flow (UNOFFICIAL, opt-in).
|
|
3
|
-
*
|
|
4
|
-
* Replicates how the ZCode desktop app turns a Z.AI login into usable GLM model
|
|
5
|
-
* access. This is NOT an official Z.AI OAuth client: it reuses ZCode's authorize
|
|
6
|
-
* page, broker, and a custom-protocol redirect. It may break at any time and may
|
|
7
|
-
* violate ZCode/Z.AI Terms of Service. Endpoints/client id are overridable via
|
|
8
|
-
* `ZCODE_OAUTH_*` environment variables.
|
|
9
|
-
*
|
|
10
|
-
* Verified end-to-end against the ZCode host bundle (`resolveZaiApiKey` /
|
|
11
|
-
* `resolveBizApiKey`) and live traffic:
|
|
12
|
-
* 1. Authorize: GET {authorize}?redirect_uri=zcode://oauth/callback&response_type=code&client_id=...&state=...
|
|
13
|
-
* (custom-protocol redirect → a CLI cannot catch it, so the user pastes the code/redirect URL)
|
|
14
|
-
* 2. Broker: POST {broker} { provider:"zai", code, redirect_uri, state }
|
|
15
|
-
* → { data: { token: <ZCode JWT>, zai: { access_token: <upstream Z.AI token> } } }
|
|
16
|
-
* 3. Business: POST {z/login} { token: <upstream Z.AI token> } → { data: { access_token: <business token> } }
|
|
17
|
-
* 4. Provision: with the business token, GET getCustomerInfo → default org/project,
|
|
18
|
-
* GET/POST .../api_keys (find/create a key named "zcode-api-key"),
|
|
19
|
-
* GET .../api_keys/copy/{id} → secretKey ⇒ a real Z.AI API key "{id}.{secret}".
|
|
20
|
-
*
|
|
21
|
-
* Credential mapping:
|
|
22
|
-
* - `access` = the provisioned **Z.AI API key** ("{id}.{secret}"). Model requests go to
|
|
23
|
-
* `https://api.z.ai/api/anthropic/v1/messages` with `Authorization: Bearer <key>`
|
|
24
|
-
* (exactly like a dashboard key) — NO zcode.z.ai gateway, NO captcha.
|
|
25
|
-
* - `refresh` = the upstream Z.AI OAuth access token (used to re-provision the key).
|
|
26
|
-
* The API key is long-lived, so `expires` is set far in the future.
|
|
27
|
-
*
|
|
28
|
-
* This provider must NEVER force `isOAuth=true`: the key is a plain Z.AI API key, and
|
|
29
|
-
* api.z.ai is not api.anthropic.com, so the Anthropic path already emits a plain bearer.
|
|
30
|
-
*/
|
|
31
1
|
import { OAuthCallbackFlow } from "./callback-server";
|
|
32
2
|
import type { OAuthController, OAuthCredentials } from "./types";
|
|
33
3
|
export declare const GLM_ZCODE_REFRESH_SKEW_MS: number;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@gajae-code/ai",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.19.0",
|
|
5
5
|
"description": "Unified LLM API with automatic model discovery and provider configuration",
|
|
6
6
|
"homepage": "https://gajae-code.com",
|
|
7
7
|
"author": "Yeachan-Heo and Gajae Code Contributors",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"@agentclientprotocol/sdk": "1.3.0",
|
|
42
42
|
"@anthropic-ai/sdk": "^0.94.0",
|
|
43
43
|
"@bufbuild/protobuf": "^2.12.0",
|
|
44
|
-
"@gajae-code/natives": "0.
|
|
45
|
-
"@gajae-code/utils": "0.
|
|
44
|
+
"@gajae-code/natives": "0.19.0",
|
|
45
|
+
"@gajae-code/utils": "0.19.0",
|
|
46
46
|
"openai": "^6.36.0",
|
|
47
47
|
"partial-json": "^0.1.7",
|
|
48
48
|
"zod": "4.4.3"
|