codex-relay 1.2.0 → 1.2.1

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.
Files changed (2) hide show
  1. package/dist/src.js +33 -9
  2. package/package.json +1 -1
package/dist/src.js CHANGED
@@ -9,7 +9,7 @@ import path, { basename, dirname, extname, isAbsolute, join, relative, resolve }
9
9
  import { fileURLToPath } from "node:url";
10
10
  import { z } from "zod";
11
11
  import { fromByteArray, toByteArray } from "base64-js";
12
- import os, { homedir, hostname } from "node:os";
12
+ import os, { homedir, hostname, platform } from "node:os";
13
13
  import { serve } from "@hono/node-server";
14
14
  import { createHash, randomBytes, randomUUID } from "node:crypto";
15
15
  import pc from "picocolors";
@@ -25,6 +25,32 @@ import { randomBytes as randomBytes$1, utf8ToBytes } from "@noble/ciphers/utils.
25
25
  import { ed25519, x25519 } from "@noble/curves/ed25519.js";
26
26
  import { hkdf } from "@noble/hashes/hkdf.js";
27
27
  import { sha256 } from "@noble/hashes/sha2.js";
28
+ //#region src/codex-binary.ts
29
+ const appServerArgs = [
30
+ "app-server",
31
+ "--listen",
32
+ "stdio://"
33
+ ];
34
+ const windowsShellExtensions = new Set([".bat", ".cmd"]);
35
+ function resolveCodexAppServerSpawn(input = {}) {
36
+ const platform$1 = input.platform ?? platform();
37
+ const command = resolveCodexBinary(input.env ?? process.env);
38
+ const isWindows = platform$1 === "win32";
39
+ return {
40
+ command,
41
+ args: [...appServerArgs],
42
+ shell: isWindows && shouldUseWindowsShell(command),
43
+ windowsHide: isWindows
44
+ };
45
+ }
46
+ function resolveCodexBinary(env) {
47
+ return env.CODEX_BIN?.trim() || "codex";
48
+ }
49
+ function shouldUseWindowsShell(command) {
50
+ const extension = extname(command).toLowerCase();
51
+ return extension === "" || windowsShellExtensions.has(extension);
52
+ }
53
+ //#endregion
28
54
  //#region src/app-server.ts
29
55
  var CodexAppServerClient = class {
30
56
  child;
@@ -141,11 +167,12 @@ var CodexAppServerClient = class {
141
167
  return this.initialized;
142
168
  }
143
169
  start() {
144
- this.child = spawn(resolveCodexBinary(), [
145
- "app-server",
146
- "--listen",
147
- "stdio://"
148
- ], { env: process.env });
170
+ const spawnConfig = resolveCodexAppServerSpawn();
171
+ this.child = spawn(spawnConfig.command, spawnConfig.args, {
172
+ env: process.env,
173
+ shell: spawnConfig.shell,
174
+ windowsHide: spawnConfig.windowsHide
175
+ });
149
176
  this.readline = createInterface({
150
177
  input: this.child.stdout,
151
178
  crlfDelay: Infinity
@@ -245,9 +272,6 @@ var CodexAppServerClient = class {
245
272
  this.pending.clear();
246
273
  }
247
274
  };
248
- function resolveCodexBinary() {
249
- return process.env.CODEX_BIN ?? "codex";
250
- }
251
275
  function debugAppServer(kind, method, id, detail) {
252
276
  if (process.env.CODEX_RELAY_DEBUG_APP_SERVER !== "1") return;
253
277
  console.log(`[app-server] ${kind}${id === void 0 ? "" : ` #${id}`}${method ? ` ${method}` : ""}${detail ? ` ${detail}` : ""}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-relay",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Local Codex Relay CLI bridge for the Codex Relay mobile app.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {