@opencode/ai 0.0.0-dev-20791 → 0.0.0-dev-20794

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.
@@ -1,4 +1,6 @@
1
+ import type { AnyAuthClient } from "google-auth-library";
1
2
  import { Auth } from "../route/auth.js";
3
+ export declare const loadADCClient: (project?: string) => Promise<AnyAuthClient>;
2
4
  export type OAuthOptions = {
3
5
  readonly accessToken?: string;
4
6
  readonly auth?: never;
@@ -3,6 +3,32 @@ import { Auth, MissingCredentialError } from "../route/auth.js";
3
3
  import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
4
4
  const SCOPE = "https://www.googleapis.com/auth/cloud-platform";
5
5
  const id = ProviderID.make("google-vertex");
6
+ export const loadADCClient = async (project) => {
7
+ const { GoogleAuth } = await import("google-auth-library");
8
+ // google-auth-library 10.5.0 ignores CLOUDSDK_CONFIG during ADC file discovery.
9
+ // Fix this in shipped AI code: a repository-level Bun dependency patch would not
10
+ // reach npm or Bun consumers of the published @opencode/ai package.
11
+ // Override only the well-known-file lookup: keyFilename bypasses ADC's quota-project
12
+ // preparation. Keep explicit credentials and metadata fallback in Google's ADC chain.
13
+ class CloudSDKAuth extends GoogleAuth {
14
+ async _tryGetApplicationCredentialsFromWellKnownFile(options) {
15
+ const config = process.env.CLOUDSDK_CONFIG;
16
+ if (!config)
17
+ return super._tryGetApplicationCredentialsFromWellKnownFile(options);
18
+ // Keep local filesystem helpers lazy for explicitly authenticated Worker callers;
19
+ // this ADC-file lookup itself requires a Node-compatible filesystem.
20
+ const { existsSync } = await import("node:fs");
21
+ const { homedir } = await import("node:os");
22
+ const { join } = await import("node:path");
23
+ const directory = config === "~" ? homedir() : config.startsWith("~/") ? join(homedir(), config.slice(2)) : config;
24
+ const file = join(directory, "application_default_credentials.json");
25
+ if (!existsSync(file))
26
+ return null;
27
+ return this._getApplicationCredentialsFromFilePath(file, options);
28
+ }
29
+ }
30
+ return new CloudSDKAuth({ projectId: project, scopes: [SCOPE] }).getClient();
31
+ };
6
32
  export const project = (value) => value ??
7
33
  process.env.GOOGLE_VERTEX_PROJECT ??
8
34
  process.env.GOOGLE_CLOUD_PROJECT ??
@@ -50,7 +76,7 @@ const adc = (project) => {
50
76
  const loadClient = () => {
51
77
  if (client)
52
78
  return client;
53
- client = import("google-auth-library").then(({ GoogleAuth }) => new GoogleAuth({ projectId: project, scopes: [SCOPE] }).getClient());
79
+ client = loadADCClient(project);
54
80
  return client;
55
81
  };
56
82
  return Auth.effect(Effect.tryPromise({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "0.0.0-dev-20791",
3
+ "version": "0.0.0-dev-20794",
4
4
  "name": "@opencode/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  "devDependencies": {
35
35
  "@clack/prompts": "1.0.0-alpha.1",
36
36
  "@effect/platform-node": "4.0.0-rc.118",
37
- "@opencode/http-recorder": "0.0.0-dev-20791",
37
+ "@opencode/http-recorder": "0.0.0-dev-20794",
38
38
  "@tsconfig/bun": "1.0.9",
39
39
  "@types/bun": "1.4.0",
40
40
  "@typescript/native-preview": "7.0.0-dev.20251207.1",
@@ -44,7 +44,7 @@
44
44
  "@aws-sdk/credential-providers": "3.1057.0",
45
45
  "@smithy/eventstream-codec": "4.2.14",
46
46
  "@smithy/util-utf8": "4.2.2",
47
- "@opencode/schema": "0.0.0-dev-20791",
47
+ "@opencode/schema": "0.0.0-dev-20794",
48
48
  "aws4fetch": "1.0.20",
49
49
  "effect": "4.0.0-rc.118",
50
50
  "google-auth-library": "10.5.0"