@koreanhole/opencodex 3.2.19 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koreanhole/opencodex",
3
- "version": "3.2.19",
3
+ "version": "3.2.21",
4
4
  "description": "Full opencodex runtime with Cline 2.2.0+ JSON and Gemini CLI headless provider adapters",
5
5
  "type": "module",
6
6
  "main": "./bin/package-main.mjs",
@@ -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
- const childEnv = buildGeminiHeadlessEnv(sourceEnv, deps.platform ?? process.platform);
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 (
@@ -196,10 +216,6 @@ export function buildGeminiHeadlessEnv(
196
216
  if (env.GEMINI_FORCE_ENCRYPTED_FILE_STORAGE === undefined) {
197
217
  env.GEMINI_FORCE_ENCRYPTED_FILE_STORAGE = "true";
198
218
  }
199
- const oauthPath = join(geminiVendorHome(sourceEnv), ".gemini", "oauth_creds.json");
200
- if (!env.GOOGLE_APPLICATION_CREDENTIALS && existsSync(oauthPath)) {
201
- env.GOOGLE_APPLICATION_CREDENTIALS = resolve(oauthPath);
202
- }
203
219
  }
204
220
  Object.assign(env, {
205
221
  GEMINI_CLI_TRUST_WORKSPACE: "true",
@@ -332,9 +348,8 @@ function geminiSystemSettings(
332
348
  auth: GeminiHeadlessAuth = "oauth",
333
349
  ): string {
334
350
  const settings = JSON.parse(GEMINI_SYSTEM_SETTINGS) as Record<string, unknown>;
335
- if (auth === "oauth") {
336
- settings.security = { auth: { selectedType: "oauth-personal" } };
337
- }
351
+ const selectedType = auth === "oauth" ? "oauth-personal" : auth === "vertex" ? "vertex-ai" : undefined;
352
+ if (selectedType) settings.security = { auth: { selectedType } };
338
353
  settings.tools = { core: mcpServers ? ["mcp_opencodex_*"] : [] };
339
354
  settings.mcp = mcpServers
340
355
  ? { allowed: [GEMINI_MCP_SERVER_NAME], excluded: [] }