@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
|
@@ -7,6 +7,15 @@ export type OAuthCredentials = {
|
|
|
7
7
|
email?: string;
|
|
8
8
|
accountId?: string;
|
|
9
9
|
profileArn?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Organization the token is scoped to. One Anthropic account can belong to
|
|
12
|
+
* several organizations (e.g. a Team workspace and a personal Max plan); each
|
|
13
|
+
* login is bound to exactly one of them, so the organization is part of the
|
|
14
|
+
* credential's identity.
|
|
15
|
+
*/
|
|
16
|
+
organizationId?: string;
|
|
17
|
+
/** Display name of {@link organizationId}. */
|
|
18
|
+
organizationName?: string;
|
|
10
19
|
};
|
|
11
20
|
export type OAuthProvider = "kiro" | "alibaba-token-plan" | "anthropic" | "bizrouter" | "mara" | "cerebras" | "cloudflare-ai-gateway" | "cursor" | "deepseek" | "deepinfra" | "fireworks" | "firepass" | "fugu" | "github-copilot" | "google-gemini-cli" | "google-antigravity" | "gitlab-duo" | "huggingface" | "kimi-code" | "kilo" | "kagi" | "litellm" | "lm-studio" | "minimax-code" | "minimax-code-cn" | "moonshot" | "nvidia" | "nanogpt" | "ollama" | "ollama-cloud" | "openai-codex" | "openai-codex-device" | "opencode-go" | "opencode-zen" | "commandcode-goat" | "opengateway" | "openrouter" | "parallel" | "perplexity" | "qianfan" | "qwen-portal" | "sglang" | "synthetic" | "tavily" | "together" | "venice" | "vercel-ai-gateway" | "vllm" | "xai" | "glm-zcode" | "xiaomi" | "xiaomi-token-plan-sgp" | "xiaomi-token-plan-ams" | "xiaomi-token-plan-cn" | "zenmux" | "opencodex" | "zai";
|
|
12
21
|
export type OAuthProviderId = OAuthProvider | (string & {});
|
package/src/utils/oauth/types.ts
CHANGED
|
@@ -7,6 +7,15 @@ export type OAuthCredentials = {
|
|
|
7
7
|
email?: string;
|
|
8
8
|
accountId?: string;
|
|
9
9
|
profileArn?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Organization the token is scoped to. One Anthropic account can belong to
|
|
12
|
+
* several organizations (e.g. a Team workspace and a personal Max plan); each
|
|
13
|
+
* login is bound to exactly one of them, so the organization is part of the
|
|
14
|
+
* credential's identity.
|
|
15
|
+
*/
|
|
16
|
+
organizationId?: string;
|
|
17
|
+
/** Display name of {@link organizationId}. */
|
|
18
|
+
organizationName?: string;
|
|
10
19
|
};
|
|
11
20
|
|
|
12
21
|
export type OAuthProvider =
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface ParsedBind {
|
|
2
|
+
hostname: string;
|
|
3
|
+
port: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Parse a `host:port` (or bare `port`, which assumes loopback) string.
|
|
7
|
+
*
|
|
8
|
+
* Accepts:
|
|
9
|
+
* - `"4000"` → `127.0.0.1:4000`
|
|
10
|
+
* - `"0.0.0.0:4000"` → as written
|
|
11
|
+
* - `"[::1]:4000"` → as written (brackets retained, Bun handles them)
|
|
12
|
+
*
|
|
13
|
+
* Rejects:
|
|
14
|
+
* - empty input
|
|
15
|
+
* - empty hostname (`":4000"`)
|
|
16
|
+
* - non-integer / out-of-range port
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseBind(raw: string): ParsedBind;
|
|
19
|
+
/** True for loopback-only hostnames the auth servers may bind without credentials. */
|
|
20
|
+
export declare function isLoopbackHostname(hostname: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Fail closed when an unauthenticated auth server (empty bearer token set)
|
|
23
|
+
* would bind a non-loopback address: that exposes credential operations to the
|
|
24
|
+
* network with no proof of possession.
|
|
25
|
+
*/
|
|
26
|
+
export declare function assertAuthenticatedOrLoopback(bind: ParsedBind, bearerTokenCount: number, serverName: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* Tokenless loopback servers accept a request only when its Host header is the
|
|
29
|
+
* bound hostname and effective port. Default-port forms that stay allowed:
|
|
30
|
+
* a Host with no port, or an explicit :80, on an HTTP listener on port 80;
|
|
31
|
+
* an explicit :443 on a listener on port 443. Any other omitted port is
|
|
32
|
+
* rejected. A DNS-rebound same-origin GET sends the attacker's name and no
|
|
33
|
+
* Origin header.
|
|
34
|
+
*/
|
|
35
|
+
export declare function hostHeaderMatchesBind(hostHeader: string | null, bind: ParsedBind): boolean;
|
package/src/utils/proxy.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as net from "node:net";
|
|
2
2
|
import * as tls from "node:tls";
|
|
3
|
+
import { loadedProjectEnvSnapshot } from "@gajae-code/utils";
|
|
4
|
+
import { canonicalEnvKey } from "@gajae-code/utils/env-file";
|
|
3
5
|
|
|
4
6
|
export interface ProxyConnectOptions {
|
|
5
7
|
signal?: AbortSignal;
|
|
@@ -48,6 +50,33 @@ function firstEnvValue(...names: string[]): string | undefined {
|
|
|
48
50
|
return undefined;
|
|
49
51
|
}
|
|
50
52
|
|
|
53
|
+
// This module may load lazily after --worktree changes cwd. Use the shared
|
|
54
|
+
// process-startup snapshot captured by @gajae-code/utils before that transition.
|
|
55
|
+
// A dynamic declaration is refused, and a runtime value equal to the declared
|
|
56
|
+
// text is ambiguous. A distinct shell value remains a selector.
|
|
57
|
+
const projectProxyEnv = loadedProjectEnvSnapshot();
|
|
58
|
+
|
|
59
|
+
function projectSuppliedProxy(name: string, runtime: string): boolean {
|
|
60
|
+
const key = canonicalEnvKey(name);
|
|
61
|
+
const declared = projectProxyEnv.values[key];
|
|
62
|
+
if (declared === undefined && !projectProxyEnv.dynamic.has(key)) return false;
|
|
63
|
+
return projectProxyEnv.dynamic.has(key) || declared === runtime || declared === runtime.trim();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function trustedProxyEnvValue(name: string): string | undefined {
|
|
67
|
+
const runtime = process.env[name];
|
|
68
|
+
if (!runtime?.trim() || projectSuppliedProxy(name, runtime)) return undefined;
|
|
69
|
+
return runtime.trim();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function firstTrustedProxyEnv(...names: string[]): string | undefined {
|
|
73
|
+
for (const name of names) {
|
|
74
|
+
const value = trustedProxyEnvValue(name);
|
|
75
|
+
if (value) return value;
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
51
80
|
function normalizeHost(hostname: string): string {
|
|
52
81
|
return hostname
|
|
53
82
|
.trim()
|
|
@@ -254,18 +283,18 @@ export function getProxyForUrl(provider: string, url: URL): string | undefined {
|
|
|
254
283
|
const normalizedProvider = normalizeProvider(provider);
|
|
255
284
|
const protocolProxy =
|
|
256
285
|
url.protocol === "https:"
|
|
257
|
-
?
|
|
286
|
+
? firstTrustedProxyEnv("HTTPS_PROXY", "https_proxy")
|
|
258
287
|
: url.protocol === "http:"
|
|
259
|
-
?
|
|
288
|
+
? firstTrustedProxyEnv("HTTP_PROXY", "http_proxy")
|
|
260
289
|
: undefined;
|
|
261
290
|
const candidates = [
|
|
262
|
-
normalizedProvider ?
|
|
263
|
-
|
|
291
|
+
normalizedProvider ? trustedProxyEnvValue(`PI_PROXY_${normalizedProvider}`) : undefined,
|
|
292
|
+
trustedProxyEnvValue("PI_PROXY"),
|
|
264
293
|
protocolProxy,
|
|
265
|
-
|
|
294
|
+
firstTrustedProxyEnv("ALL_PROXY", "all_proxy"),
|
|
266
295
|
];
|
|
267
296
|
for (const candidate of candidates) {
|
|
268
|
-
if (candidate
|
|
297
|
+
if (candidate) return candidate;
|
|
269
298
|
}
|
|
270
299
|
return undefined;
|
|
271
300
|
}
|