@koreanhole/opencodex 3.2.20 → 3.2.21
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/README.md
CHANGED
|
@@ -43,6 +43,35 @@ applies, including logins stored in the vendor keychain or under a custom
|
|
|
43
43
|
`GEMINI_CLI_HOME`. Linux keyring access and the vendor encrypted credential file
|
|
44
44
|
are preserved for isolated OAuth turns.
|
|
45
45
|
|
|
46
|
+
### Vertex AI (enterprise)
|
|
47
|
+
|
|
48
|
+
Select Vertex AI in the vendor settings and authenticate with Application
|
|
49
|
+
Default Credentials:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"security": {
|
|
54
|
+
"auth": {
|
|
55
|
+
"selectedType": "vertex-ai"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
gcloud auth application-default login
|
|
63
|
+
export GOOGLE_CLOUD_PROJECT="your-project"
|
|
64
|
+
export GOOGLE_CLOUD_LOCATION="us-central1"
|
|
65
|
+
# Optional: use a service-account ADC file instead of the gcloud login.
|
|
66
|
+
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/adc.json"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
opencodex mirrors the vendor `vertex-ai` selection into its isolated Gemini
|
|
70
|
+
settings, forwards those three variables unchanged, and adds neither
|
|
71
|
+
`GOOGLE_GENAI_USE_GCA` nor encrypted-storage forcing. Gemini CLI's
|
|
72
|
+
`oauth_creds.json` is not used in this mode; an existing cached OAuth login
|
|
73
|
+
does not override the Vertex selection.
|
|
74
|
+
|
|
46
75
|
Cline 2.2.0 is the minimum supported release. Newer options are used only when
|
|
47
76
|
the installed binary advertises them.
|
|
48
77
|
|
package/package.json
CHANGED
|
@@ -250,7 +250,20 @@ export async function runGeminiTurn(
|
|
|
250
250
|
...(deps.reapTimeoutMs !== undefined ? { reapTimeoutMs: deps.reapTimeoutMs } : {}),
|
|
251
251
|
...(deps.killWindowsProcessTree ? { killWindowsProcessTree: deps.killWindowsProcessTree } : {}),
|
|
252
252
|
};
|
|
253
|
-
|
|
253
|
+
let childEnv: Record<string, string>;
|
|
254
|
+
try {
|
|
255
|
+
childEnv = buildGeminiHeadlessEnv(sourceEnv, deps.platform ?? process.platform);
|
|
256
|
+
} catch (error) {
|
|
257
|
+
emit({
|
|
258
|
+
type: "error",
|
|
259
|
+
message: error instanceof Error ? error.message : String(error),
|
|
260
|
+
status: 400,
|
|
261
|
+
errorType: "invalid_request_error",
|
|
262
|
+
code: "gemini_vertex_adc_missing",
|
|
263
|
+
retryable: false,
|
|
264
|
+
});
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
254
267
|
let mode;
|
|
255
268
|
try {
|
|
256
269
|
mode = await (deps.probeHeadless ?? probeGeminiHeadlessSupport)(binary, childEnv, headlessDeps);
|
|
@@ -67,7 +67,7 @@ const FORWARDED_ENV_KEYS = [
|
|
|
67
67
|
|
|
68
68
|
const AUTH_FILE_NAMES = ["oauth_creds.json", "google_accounts.json", ".env"] as const;
|
|
69
69
|
const OAUTH_AUTH_FILE_NAMES = ["oauth_creds.json", "google_accounts.json", "gemini-credentials.json"] as const;
|
|
70
|
-
type GeminiHeadlessAuth = "oauth" | "environment";
|
|
70
|
+
type GeminiHeadlessAuth = "oauth" | "environment" | "vertex";
|
|
71
71
|
|
|
72
72
|
export interface GeminiHeadlessDeps extends CliAgentTurnDeps {
|
|
73
73
|
env?: NodeJS.ProcessEnv;
|
|
@@ -124,9 +124,29 @@ function geminiSelectedAuth(sourceEnv: NodeJS.ProcessEnv): GeminiHeadlessAuth |
|
|
|
124
124
|
const selectedType = nonEmpty(asRecord(security?.auth)?.selectedType);
|
|
125
125
|
if (selectedType === "oauth-personal") return "oauth";
|
|
126
126
|
if (selectedType === "gemini-api-key") return "environment";
|
|
127
|
+
if (selectedType === "vertex-ai") {
|
|
128
|
+
if (!hasVertexAdc(sourceEnv)) {
|
|
129
|
+
throw new Error(
|
|
130
|
+
"Gemini CLI is configured for Vertex AI, but no Application Default Credentials were found. "
|
|
131
|
+
+ "Set GOOGLE_APPLICATION_CREDENTIALS or run `gcloud auth application-default login`. "
|
|
132
|
+
+ "Vertex also requires GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION.",
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
return "vertex";
|
|
136
|
+
}
|
|
127
137
|
return undefined;
|
|
128
138
|
}
|
|
129
139
|
|
|
140
|
+
function hasVertexAdc(sourceEnv: NodeJS.ProcessEnv): boolean {
|
|
141
|
+
if (nonEmpty(sourceEnv.GOOGLE_APPLICATION_CREDENTIALS)) return true;
|
|
142
|
+
const home = nonEmpty(sourceEnv.HOME) ?? nonEmpty(sourceEnv.USERPROFILE) ?? homedir();
|
|
143
|
+
const appData = nonEmpty(sourceEnv.APPDATA);
|
|
144
|
+
return [
|
|
145
|
+
join(home, ".config", "gcloud", "application_default_credentials.json"),
|
|
146
|
+
...(appData ? [join(appData, "gcloud", "application_default_credentials.json")] : []),
|
|
147
|
+
].some(path => existsSync(path));
|
|
148
|
+
}
|
|
149
|
+
|
|
130
150
|
function geminiHeadlessAuth(sourceEnv: NodeJS.ProcessEnv): GeminiHeadlessAuth {
|
|
131
151
|
if (enabled(sourceEnv.GOOGLE_GENAI_USE_GCA)) return "oauth";
|
|
132
152
|
if (
|
|
@@ -328,9 +348,8 @@ function geminiSystemSettings(
|
|
|
328
348
|
auth: GeminiHeadlessAuth = "oauth",
|
|
329
349
|
): string {
|
|
330
350
|
const settings = JSON.parse(GEMINI_SYSTEM_SETTINGS) as Record<string, unknown>;
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
351
|
+
const selectedType = auth === "oauth" ? "oauth-personal" : auth === "vertex" ? "vertex-ai" : undefined;
|
|
352
|
+
if (selectedType) settings.security = { auth: { selectedType } };
|
|
334
353
|
settings.tools = { core: mcpServers ? ["mcp_opencodex_*"] : [] };
|
|
335
354
|
settings.mcp = mcpServers
|
|
336
355
|
? { allowed: [GEMINI_MCP_SERVER_NAME], excluded: [] }
|