@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/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
|
}
|