@agentrouter-top/relay-dsh-plugin-codex 0.2.2-agentrouter.8 → 0.2.2-agentrouter.9

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.
@@ -4,10 +4,10 @@ import assert from "node:assert/strict";
4
4
  import { EventEmitter } from "node:events";
5
5
  import { spawn } from "node:child_process";
6
6
  import readline from "node:readline";
7
+ import { basename, dirname, isAbsolute, join, resolve, sep } from "node:path";
7
8
  import { createHash, randomUUID, timingSafeEqual } from "node:crypto";
8
9
  import { chmod, cp, link, lstat, mkdir, readFile, realpath, stat, unlink, writeFile } from "node:fs/promises";
9
10
  import { homedir } from "node:os";
10
- import { basename, dirname, isAbsolute, join, resolve, sep } from "node:path";
11
11
  import * as llm from "@deepseek-ai/dsh-llm";
12
12
  import { LlmAdapter, LlmError, MessageId, createMessage, freezeMessage } from "@deepseek-ai/dsh-llm";
13
13
  import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
@@ -316,14 +316,35 @@ function resolveCodexLaunch({ command, env = process.env, execPath = process.exe
316
316
  throw error;
317
317
  }
318
318
  let launcher;
319
+ let nativeCommand;
319
320
  try {
320
321
  launcher = resolvePackage(BUNDLED_CODEX_ENTRY);
321
322
  resolvePackage(`${platformPackage}/package.json`);
323
+ if (platform === "win32") nativeCommand = resolvePackage(`${platformPackage}/vendor/${arch === "arm64" ? "aarch64" : "x86_64"}-pc-windows-msvc/bin/codex.exe`);
322
324
  } catch (cause) {
323
325
  const error = new Error(`The bundled Codex runtime for ${platform}/${arch} is unavailable. Reinstall @agentrouter-top/relay-dsh-plugin-codex, or set RELAY_CODEX_COMMAND to an absolute Codex executable path.`, { cause });
324
326
  error.code = "CODEX_RUNTIME_MISSING";
325
327
  throw error;
326
328
  }
329
+ if (nativeCommand) {
330
+ const nativeEnv = {
331
+ ...env,
332
+ CODEX_MANAGED_PACKAGE_ROOT: resolve(dirname(launcher), "..")
333
+ };
334
+ for (const manager of [
335
+ "NPM",
336
+ "BUN",
337
+ "PNPM",
338
+ "VITE_PLUS"
339
+ ]) delete nativeEnv[`CODEX_MANAGED_BY_${manager}`];
340
+ nativeEnv.CODEX_MANAGED_BY_NPM = "1";
341
+ return Object.freeze({
342
+ command: nativeCommand,
343
+ argsPrefix: [],
344
+ source: "bundled",
345
+ env: Object.freeze(nativeEnv)
346
+ });
347
+ }
327
348
  return Object.freeze({
328
349
  command: execPath,
329
350
  argsPrefix: [launcher],
@@ -440,6 +461,7 @@ var CodexAppServerClient = class extends EventEmitter {
440
461
  command,
441
462
  env: this.env
442
463
  });
464
+ if (launch.env) this.env = launch.env;
443
465
  this.command = launch.command;
444
466
  this.commandSource = launch.source;
445
467
  this.appServerArgs = [...args];