@koreanhole/opencodex 3.2.27 → 3.2.28

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.
@@ -0,0 +1,14 @@
1
+ export const BUN_CA_ENV_KEYS: readonly [
2
+ "NODE_EXTRA_CA_CERTS",
3
+ "SSL_CERT_FILE",
4
+ "SSL_CERT_DIR",
5
+ "NODE_USE_SYSTEM_CA",
6
+ ];
7
+
8
+ export function seedBunCaEnv(options?: {
9
+ bun?: string;
10
+ cwd?: string;
11
+ env?: NodeJS.ProcessEnv;
12
+ spawn?: typeof import("node:child_process").spawnSync;
13
+ readdir?: (path: string) => string[];
14
+ }): Record<string, string>;
@@ -0,0 +1,73 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { readdirSync } from "node:fs";
3
+
4
+ export const BUN_CA_ENV_KEYS = [
5
+ "NODE_EXTRA_CA_CERTS",
6
+ "SSL_CERT_FILE",
7
+ "SSL_CERT_DIR",
8
+ "NODE_USE_SYSTEM_CA",
9
+ ];
10
+
11
+ function likelyEnvFile(cwd, readdir) {
12
+ try {
13
+ return readdir(cwd).some(name => /^\.env(?:\..+)?$/.test(name));
14
+ } catch {
15
+ return false;
16
+ }
17
+ }
18
+
19
+ function explicitEnvFile(env) {
20
+ return /(?:^|\s)--env-file(?:=|\s)/.test(env.BUN_OPTIONS ?? "");
21
+ }
22
+
23
+ /** Promote Bun-visible trust settings into the child process before TLS initializes. */
24
+ export function seedBunCaEnv({
25
+ bun,
26
+ cwd = process.cwd(),
27
+ env = process.env,
28
+ spawn = spawnSync,
29
+ readdir = readdirSync,
30
+ } = {}) {
31
+ if (!bun || BUN_CA_ENV_KEYS.every(key => env[key]?.trim())) return {};
32
+ if (!likelyEnvFile(cwd, readdir) && !explicitEnvFile(env)) return {};
33
+
34
+ const source = [
35
+ `const keys = ${JSON.stringify(BUN_CA_ENV_KEYS)};`,
36
+ "const values = {};",
37
+ "for (const key of keys) {",
38
+ " const value = process.env[key];",
39
+ " if (typeof value === 'string' && value.trim()) values[key] = value;",
40
+ "}",
41
+ "console.log('OCX_CA_ENV=' + JSON.stringify(values));",
42
+ ].join("\n");
43
+ const result = spawn(bun, ["-e", source], {
44
+ cwd,
45
+ env,
46
+ encoding: "utf8",
47
+ timeout: 5_000,
48
+ windowsHide: true,
49
+ stdio: ["ignore", "pipe", "pipe"],
50
+ });
51
+ if (result.error || result.status !== 0 || typeof result.stdout !== "string") return {};
52
+
53
+ let values;
54
+ for (const line of result.stdout.split(/\r?\n/)) {
55
+ if (!line.startsWith("OCX_CA_ENV=")) continue;
56
+ try {
57
+ const parsed = JSON.parse(line.slice("OCX_CA_ENV=".length));
58
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) values = parsed;
59
+ } catch {
60
+ // A malformed probe response is ignored; startup keeps the original environment.
61
+ }
62
+ }
63
+ if (!values) return {};
64
+
65
+ const seeded = {};
66
+ for (const key of BUN_CA_ENV_KEYS) {
67
+ const value = values[key];
68
+ if (env[key]?.trim() || typeof value !== "string" || !value.trim()) continue;
69
+ env[key] = value;
70
+ seeded[key] = value;
71
+ }
72
+ return seeded;
73
+ }
package/bin/ocx.mjs CHANGED
@@ -4,6 +4,7 @@ import { existsSync } from "node:fs";
4
4
  import { createRequire } from "node:module";
5
5
  import { dirname, join } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
+ import { seedBunCaEnv } from "./bun-ca-env.mjs";
7
8
 
8
9
  const require = createRequire(import.meta.url);
9
10
  const here = dirname(fileURLToPath(import.meta.url));
@@ -20,6 +21,7 @@ function bundledBun() {
20
21
  }
21
22
 
22
23
  const bun = process.env.BUN_BINARY || bundledBun() || "bun";
24
+ seedBunCaEnv({ bun });
23
25
  const child = spawn(bun, [cli, ...process.argv.slice(2)], { stdio: "inherit", env: process.env });
24
26
  child.on("error", error => {
25
27
  console.error(`ocx: unable to start Bun runtime: ${error.message}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koreanhole/opencodex",
3
- "version": "3.2.27",
3
+ "version": "3.2.28",
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",
@@ -33,6 +33,7 @@
33
33
  "test:e2e:update": "bun test tests/e2e/update.test.ts",
34
34
  "test:e2e:cline-live": "bun test ./tests/e2e/cline-live.live.ts",
35
35
  "test:e2e:gemini": "bun test ./tests/e2e/gemini-codex.live.ts -t \"full-stack:\"",
36
+ "test:e2e:native-proxy-ca": "bun test tests/e2e/native-proxy-ca.test.ts",
36
37
  "test:e2e:gemini-oauth-only": "bun test ./tests/e2e/gemini-oauth-only.test.ts",
37
38
  "test:e2e:gemini-proxy-ca": "bun test ./tests/e2e/gemini-proxy-ca.test.ts",
38
39
  "test:e2e:gemini-oauth-codeassist": "bun test ./tests/e2e/gemini-oauth-codeassist.live.ts",