@omnicross/cli-launcher 0.1.0 → 0.1.2

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/dist/index.cjs CHANGED
@@ -1,136 +1,18 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __esm = (fn, res) => function __init() {
7
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
8
- };
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
22
2
 
23
- // src/pty-adapter.ts
24
- var pty_adapter_exports = {};
25
- __export(pty_adapter_exports, {
26
- buildPtyEnv: () => buildPtyEnv,
27
- createPtyAdapter: () => createPtyAdapter
28
- });
29
- function buildPtyEnv(overlay) {
30
- return overlay ? { ...process.env, ...overlay } : { ...process.env };
31
- }
32
- function createPtyAdapter(input) {
33
- const nodePty = require("node-pty");
34
- const shell = input.shell ?? (process.platform === "win32" ? "powershell.exe" : "/bin/bash");
35
- const pty = nodePty.spawn(shell, input.args ?? [], {
36
- name: "xterm-256color",
37
- cols: input.cols ?? 120,
38
- rows: input.rows ?? 30,
39
- cwd: input.cwd,
40
- env: buildPtyEnv(input.env)
41
- });
42
- const stdoutListeners = [];
43
- const stderrListeners = [];
44
- const dataDisposable = pty.onData((data) => {
45
- for (const cb of stdoutListeners) cb(data);
46
- });
47
- let exitResolve = null;
48
- const exitPromise = new Promise((resolve) => {
49
- exitResolve = resolve;
50
- });
51
- const exitDisposable = pty.onExit(({ exitCode, signal }) => {
52
- exitResolve?.({ code: exitCode, signal: signal != null ? String(signal) : null });
53
- });
54
- let disposed = false;
55
- return {
56
- pid: pty.pid,
57
- onStdout(cb) {
58
- stdoutListeners.push(cb);
59
- },
60
- onStderr(cb) {
61
- stderrListeners.push(cb);
62
- },
63
- stdin: {
64
- write(data) {
65
- if (!disposed) pty.write(data);
66
- },
67
- end() {
68
- if (!disposed) pty.write("");
69
- },
70
- destroy() {
71
- }
72
- },
73
- write(data) {
74
- if (!disposed) pty.write(data);
75
- },
76
- resize(cols, rows) {
77
- if (!disposed) pty.resize(cols, rows);
78
- },
79
- wait() {
80
- return exitPromise;
81
- },
82
- kill(signal) {
83
- if (disposed) return;
84
- try {
85
- pty.kill(signal);
86
- } catch {
87
- }
88
- },
89
- dispose() {
90
- if (disposed) return;
91
- disposed = true;
92
- dataDisposable.dispose();
93
- exitDisposable.dispose();
94
- try {
95
- pty.kill();
96
- } catch {
97
- }
98
- }
99
- };
100
- }
101
- var init_pty_adapter = __esm({
102
- "src/pty-adapter.ts"() {
103
- "use strict";
104
- }
105
- });
106
3
 
107
- // src/index.ts
108
- var src_exports = {};
109
- __export(src_exports, {
110
- CHAT_PROXY_BASE_PATH: () => CHAT_PROXY_BASE_PATH,
111
- CLAUDE_PROXY_API_KEY_SENTINEL: () => CLAUDE_PROXY_API_KEY_SENTINEL,
112
- CODEX_PROXY_BASE_PATH: () => CODEX_PROXY_BASE_PATH,
113
- CODEX_PROXY_PROVIDER_NAME: () => CODEX_PROXY_PROVIDER_NAME,
114
- OPENCODE_PROXY_PROVIDER_ID: () => OPENCODE_PROXY_PROVIDER_ID,
115
- OPENCODE_PROXY_TOKEN_ENV: () => OPENCODE_PROXY_TOKEN_ENV,
116
- buildChatCliLaunchConfig: () => buildChatCliLaunchConfig,
117
- buildClaudeCliLaunchConfig: () => buildClaudeCliLaunchConfig,
118
- buildCodexConfigOverrides: () => buildCodexConfigOverrides,
119
- buildCodexLaunchConfig: () => buildCodexLaunchConfig,
120
- buildGeminiCliLaunchConfig: () => buildGeminiCliLaunchConfig,
121
- getProcessSupervisor: () => getProcessSupervisor
122
- });
123
- module.exports = __toCommonJS(src_exports);
4
+
5
+ var _chunkHNYCLVZPcjs = require('./chunk-HNYCLVZP.cjs');
124
6
 
125
7
  // src/supervisor.ts
126
- var import_node_crypto = require("crypto");
127
- var import_serializeError = require("@omnicross/core/serializeError");
8
+ var _crypto = require('crypto');
9
+ var _serializeError = require('@omnicross/core/serializeError');
128
10
 
129
11
  // src/child-adapter.ts
130
- var import_node_child_process2 = require("child_process");
12
+ var _child_process = require('child_process');
131
13
 
132
14
  // src/kill-tree.ts
133
- var import_node_child_process = require("child_process");
15
+
134
16
  var TAG = "[ProcessSupervisor]";
135
17
  var MIN_GRACE_MS = 0;
136
18
  var MAX_GRACE_MS = 6e4;
@@ -140,12 +22,12 @@ function isProcessAlive(pid) {
140
22
  try {
141
23
  process.kill(pid, 0);
142
24
  return true;
143
- } catch {
25
+ } catch (e) {
144
26
  return false;
145
27
  }
146
28
  }
147
29
  function killProcessTree(pid, opts) {
148
- const graceMs = Math.max(MIN_GRACE_MS, Math.min(MAX_GRACE_MS, opts?.graceMs ?? DEFAULT_GRACE_MS));
30
+ const graceMs = Math.max(MIN_GRACE_MS, Math.min(MAX_GRACE_MS, _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _ => _.graceMs]), () => ( DEFAULT_GRACE_MS))));
149
31
  if (!isProcessAlive(pid)) return;
150
32
  if (IS_WIN) {
151
33
  killTreeWindows(pid, graceMs);
@@ -155,7 +37,7 @@ function killProcessTree(pid, opts) {
155
37
  }
156
38
  function killTreeWindows(pid, graceMs) {
157
39
  try {
158
- (0, import_node_child_process.spawn)("taskkill", ["/T", "/PID", String(pid)], {
40
+ _child_process.spawn.call(void 0, "taskkill", ["/T", "/PID", String(pid)], {
159
41
  detached: true,
160
42
  windowsHide: true,
161
43
  stdio: "ignore"
@@ -166,7 +48,7 @@ function killTreeWindows(pid, graceMs) {
166
48
  const timer = setTimeout(() => {
167
49
  if (!isProcessAlive(pid)) return;
168
50
  try {
169
- (0, import_node_child_process.spawn)("taskkill", ["/F", "/T", "/PID", String(pid)], {
51
+ _child_process.spawn.call(void 0, "taskkill", ["/F", "/T", "/PID", String(pid)], {
170
52
  detached: true,
171
53
  windowsHide: true,
172
54
  stdio: "ignore"
@@ -214,12 +96,12 @@ function createChildAdapter(input) {
214
96
  windowsVerbatimArguments: input.windowsVerbatimArguments,
215
97
  detached: !IS_WIN2
216
98
  };
217
- const child = (0, import_node_child_process2.spawn)(command, args, opts);
218
- const stdinMode = input.stdinMode ?? (input.input ? "pipe-closed" : "pipe-open");
99
+ const child = _child_process.spawn.call(void 0, command, args, opts);
100
+ const stdinMode = _nullishCoalesce(input.stdinMode, () => ( (input.input ? "pipe-closed" : "pipe-open")));
219
101
  if (input.input && child.stdin) {
220
102
  child.stdin.write(input.input, () => {
221
103
  if (stdinMode === "pipe-closed") {
222
- child.stdin?.end();
104
+ _optionalChain([child, 'access', _2 => _2.stdin, 'optionalAccess', _3 => _3.end, 'call', _4 => _4()]);
223
105
  }
224
106
  });
225
107
  } else if (stdinMode === "pipe-closed" && child.stdin) {
@@ -229,12 +111,12 @@ function createChildAdapter(input) {
229
111
  return {
230
112
  pid: child.pid,
231
113
  onStdout(cb) {
232
- child.stdout?.setEncoding("utf8");
233
- child.stdout?.on("data", cb);
114
+ _optionalChain([child, 'access', _5 => _5.stdout, 'optionalAccess', _6 => _6.setEncoding, 'call', _7 => _7("utf8")]);
115
+ _optionalChain([child, 'access', _8 => _8.stdout, 'optionalAccess', _9 => _9.on, 'call', _10 => _10("data", cb)]);
234
116
  },
235
117
  onStderr(cb) {
236
- child.stderr?.setEncoding("utf8");
237
- child.stderr?.on("data", cb);
118
+ _optionalChain([child, 'access', _11 => _11.stderr, 'optionalAccess', _12 => _12.setEncoding, 'call', _13 => _13("utf8")]);
119
+ _optionalChain([child, 'access', _14 => _14.stderr, 'optionalAccess', _15 => _15.on, 'call', _16 => _16("data", cb)]);
238
120
  },
239
121
  wait() {
240
122
  return new Promise((resolve) => {
@@ -243,7 +125,7 @@ function createChildAdapter(input) {
243
125
  resolve({ code: -1, signal: null });
244
126
  });
245
127
  child.on("close", (code, signal) => {
246
- resolve({ code, signal: signal ?? null });
128
+ resolve({ code, signal: _nullishCoalesce(signal, () => ( null)) });
247
129
  });
248
130
  });
249
131
  },
@@ -253,7 +135,7 @@ function createChildAdapter(input) {
253
135
  killProcessTree(child.pid);
254
136
  } else {
255
137
  try {
256
- child.kill(signal ?? "SIGTERM");
138
+ child.kill(_nullishCoalesce(signal, () => ( "SIGTERM")));
257
139
  } catch (err) {
258
140
  console.warn(TAG2, `child.kill failed for pid=${child.pid}:`, err);
259
141
  }
@@ -263,8 +145,8 @@ function createChildAdapter(input) {
263
145
  dispose() {
264
146
  if (disposed) return;
265
147
  disposed = true;
266
- child.stdout?.removeAllListeners();
267
- child.stderr?.removeAllListeners();
148
+ _optionalChain([child, 'access', _17 => _17.stdout, 'optionalAccess', _18 => _18.removeAllListeners, 'call', _19 => _19()]);
149
+ _optionalChain([child, 'access', _20 => _20.stderr, 'optionalAccess', _21 => _21.removeAllListeners, 'call', _22 => _22()]);
268
150
  child.removeAllListeners();
269
151
  }
270
152
  };
@@ -350,9 +232,9 @@ function createProcessSupervisor() {
350
232
  const registry = createRunRegistry();
351
233
  const active = /* @__PURE__ */ new Map();
352
234
  function spawn(input) {
353
- const runId = input.runId ?? (0, import_node_crypto.randomUUID)();
235
+ const runId = _nullishCoalesce(input.runId, () => ( _crypto.randomUUID.call(void 0, )));
354
236
  const now = Date.now();
355
- const captureOutput = input.captureOutput ?? true;
237
+ const captureOutput = _nullishCoalesce(input.captureOutput, () => ( true));
356
238
  if (input.replaceExistingScope && input.scopeKey) {
357
239
  cancelScope(input.scopeKey, "manual-cancel");
358
240
  }
@@ -377,8 +259,8 @@ function createProcessSupervisor() {
377
259
  let adapter;
378
260
  try {
379
261
  if (input.mode === "pty") {
380
- const { createPtyAdapter: createPtyAdapter2 } = (init_pty_adapter(), __toCommonJS(pty_adapter_exports));
381
- adapter = createPtyAdapter2(input);
262
+ const { createPtyAdapter } = (_chunkHNYCLVZPcjs.init_pty_adapter.call(void 0, ), _chunkHNYCLVZPcjs.__toCommonJS.call(void 0, _chunkHNYCLVZPcjs.pty_adapter_exports));
263
+ adapter = createPtyAdapter(input);
382
264
  } else {
383
265
  adapter = createChildAdapter(input);
384
266
  }
@@ -390,7 +272,7 @@ function createProcessSupervisor() {
390
272
  exitSignal: null,
391
273
  durationMs: 0,
392
274
  stdout: "",
393
- stderr: (0, import_serializeError.serializeError)(err),
275
+ stderr: _serializeError.serializeError.call(void 0, err),
394
276
  timedOut: false,
395
277
  noOutputTimedOut: false
396
278
  };
@@ -405,7 +287,7 @@ function createProcessSupervisor() {
405
287
  registry.updateState(runId, "running", { pid: adapter.pid });
406
288
  function cancelRun(reason) {
407
289
  if (settled) return;
408
- forcedReason = reason ?? "manual-cancel";
290
+ forcedReason = _nullishCoalesce(reason, () => ( "manual-cancel"));
409
291
  registry.updateState(runId, "exiting", { terminationReason: forcedReason });
410
292
  adapter.kill("SIGKILL");
411
293
  }
@@ -445,32 +327,32 @@ function createProcessSupervisor() {
445
327
  if (captureOutput) stdout += chunk;
446
328
  registry.touchOutput(runId);
447
329
  resetNoOutputTimer();
448
- input.onStdout?.(chunk);
330
+ _optionalChain([input, 'access', _23 => _23.onStdout, 'optionalCall', _24 => _24(chunk)]);
449
331
  });
450
332
  adapter.onStderr((chunk) => {
451
333
  if (captureOutput) stderr += chunk;
452
334
  registry.touchOutput(runId);
453
335
  resetNoOutputTimer();
454
- input.onStderr?.(chunk);
336
+ _optionalChain([input, 'access', _25 => _25.onStderr, 'optionalCall', _26 => _26(chunk)]);
455
337
  });
456
338
  let stdinHandle;
457
339
  if (adapter.stdin) {
458
340
  stdinHandle = {
459
341
  write(data) {
460
- adapter.stdin?.write(data);
342
+ _optionalChain([adapter, 'access', _27 => _27.stdin, 'optionalAccess', _28 => _28.write, 'call', _29 => _29(data)]);
461
343
  },
462
344
  end() {
463
- adapter.stdin?.end();
345
+ _optionalChain([adapter, 'access', _30 => _30.stdin, 'optionalAccess', _31 => _31.end, 'call', _32 => _32()]);
464
346
  },
465
347
  destroy() {
466
- adapter.stdin?.destroy();
348
+ _optionalChain([adapter, 'access', _33 => _33.stdin, 'optionalAccess', _34 => _34.destroy, 'call', _35 => _35()]);
467
349
  }
468
350
  };
469
351
  }
470
352
  const waitPromise = adapter.wait().then(({ code, signal }) => {
471
353
  settled = true;
472
354
  clearTimers();
473
- const reason = forcedReason ?? (code === -1 ? "spawn-error" : signal ? "signal" : "exit");
355
+ const reason = _nullishCoalesce(forcedReason, () => ( (code === -1 ? "spawn-error" : signal ? "signal" : "exit")));
474
356
  registry.finalize(runId, reason, code, signal);
475
357
  active.delete(runId);
476
358
  adapter.dispose();
@@ -527,8 +409,8 @@ function createProcessSupervisor() {
527
409
  }
528
410
 
529
411
  // src/proxy-env/claude-proxy-env.ts
530
- var import_completion = require("@omnicross/core/completion");
531
- var import_provider_proxy = require("@omnicross/core/provider-proxy");
412
+ var _completion = require('@omnicross/core/completion');
413
+ var _providerproxy = require('@omnicross/core/provider-proxy');
532
414
  var CLAUDE_PROXY_API_KEY_SENTINEL = "omnicross-proxy";
533
415
  async function buildClaudeCliLaunchConfig(inputs) {
534
416
  const provider = await inputs.llmConfig.getProvider(inputs.providerId);
@@ -537,21 +419,21 @@ async function buildClaudeCliLaunchConfig(inputs) {
537
419
  `claude proxy: provider not found: ${inputs.providerId}. Add a provider row to the daemon config (omnicross providers add \u2026).`
538
420
  );
539
421
  }
540
- const { apiKey } = (0, import_completion.resolveProviderEndpoint)(provider);
422
+ const { apiKey } = _completion.resolveProviderEndpoint.call(void 0, provider);
541
423
  if (!resolveApiKey(apiKey)) {
542
424
  throw new Error(
543
425
  `claude proxy: provider "${inputs.providerId}" has no valid API key. Set apiKey (or a $ENV_VAR reference) on the provider row.`
544
426
  );
545
427
  }
546
428
  const route = {
547
- sessionId: inputs.sessionId ?? null,
429
+ sessionId: _nullishCoalesce(inputs.sessionId, () => ( null)),
548
430
  targetProviderFormat: provider.apiFormat === "anthropic" ? "anthropic" : "transform",
549
431
  model: inputs.model,
550
432
  ingressFormat: "anthropic-messages",
551
433
  authMode: "byo",
552
434
  providerId: inputs.providerId
553
435
  };
554
- const proxy = (0, import_provider_proxy.getProviderProxy)();
436
+ const proxy = _providerproxy.getProviderProxy.call(void 0, );
555
437
  const token = proxy.addRoute(route);
556
438
  const baseUrl = proxy.getBaseUrl();
557
439
  console.info("[buildClaudeCliLaunchConfig] claude route ready", {
@@ -572,7 +454,7 @@ async function buildClaudeCliLaunchConfig(inputs) {
572
454
  onSessionEnd: () => {
573
455
  try {
574
456
  proxy.removeRoute(token);
575
- } catch {
457
+ } catch (e2) {
576
458
  }
577
459
  }
578
460
  };
@@ -586,11 +468,11 @@ function resolveApiKey(apiKey) {
586
468
  }
587
469
 
588
470
  // src/proxy-env/cli-proxy-env.ts
589
- var import_node_fs = require("fs");
590
- var import_node_os = require("os");
591
- var import_node_path = require("path");
592
- var import_completion2 = require("@omnicross/core/completion");
593
- var import_provider_proxy2 = require("@omnicross/core/provider-proxy");
471
+ var _fs = require('fs');
472
+ var _os = require('os');
473
+ var _path = require('path');
474
+
475
+
594
476
  var CHAT_PROXY_BASE_PATH = "/v1";
595
477
  var OPENCODE_PROXY_PROVIDER_ID = "omnicross";
596
478
  var OPENCODE_PROXY_TOKEN_ENV = "OMNICROSS_OPENCODE_TOKEN";
@@ -601,21 +483,21 @@ async function buildChatCliLaunchConfig(inputs) {
601
483
  `${inputs.backendId} proxy: provider not found: ${inputs.providerId}. Add an OpenAI-compatible provider in Settings \u2192 LLM Providers.`
602
484
  );
603
485
  }
604
- const { apiKey } = (0, import_completion2.resolveProviderEndpoint)(provider);
486
+ const { apiKey } = _completion.resolveProviderEndpoint.call(void 0, provider);
605
487
  if (!resolveApiKey2(apiKey)) {
606
488
  throw new Error(
607
489
  `${inputs.backendId} proxy: provider "${inputs.providerId}" has no valid API key. Add an API key in Settings \u2192 LLM Providers.`
608
490
  );
609
491
  }
610
492
  const route = {
611
- sessionId: inputs.sessionId ?? null,
493
+ sessionId: _nullishCoalesce(inputs.sessionId, () => ( null)),
612
494
  targetProviderFormat: "transform",
613
495
  model: inputs.model,
614
496
  ingressFormat: "openai-chat",
615
497
  authMode: "byo",
616
498
  providerId: inputs.providerId
617
499
  };
618
- const proxy = (0, import_provider_proxy2.getProviderProxy)();
500
+ const proxy = _providerproxy.getProviderProxy.call(void 0, );
619
501
  const token = proxy.addRoute(route);
620
502
  const baseUrl = proxy.getBaseUrl();
621
503
  const chatBase = `${baseUrl}${CHAT_PROXY_BASE_PATH}`;
@@ -641,7 +523,7 @@ async function buildChatCliLaunchConfig(inputs) {
641
523
  for (const c of cleanups) {
642
524
  try {
643
525
  c();
644
- } catch {
526
+ } catch (e3) {
645
527
  }
646
528
  }
647
529
  }
@@ -688,10 +570,10 @@ function buildOpencodeEnv(ctx) {
688
570
  }
689
571
  }
690
572
  };
691
- const dir = (0, import_node_fs.mkdtempSync)((0, import_node_path.join)((0, import_node_os.tmpdir)(), "omnicross-opencode-"));
692
- const configPath = (0, import_node_path.join)(dir, "opencode.json");
693
- (0, import_node_fs.writeFileSync)(configPath, JSON.stringify(config, null, 2), "utf-8");
694
- ctx.cleanups.push(() => (0, import_node_fs.rmSync)(dir, { recursive: true, force: true }));
573
+ const dir = _fs.mkdtempSync.call(void 0, _path.join.call(void 0, _os.tmpdir.call(void 0, ), "omnicross-opencode-"));
574
+ const configPath = _path.join.call(void 0, dir, "opencode.json");
575
+ _fs.writeFileSync.call(void 0, configPath, JSON.stringify(config, null, 2), "utf-8");
576
+ ctx.cleanups.push(() => _fs.rmSync.call(void 0, dir, { recursive: true, force: true }));
695
577
  return {
696
578
  OPENCODE_CONFIG: configPath,
697
579
  [OPENCODE_PROXY_TOKEN_ENV]: ctx.token
@@ -704,21 +586,21 @@ async function buildGeminiCliLaunchConfig(inputs) {
704
586
  `gemini-cli proxy: provider not found: ${inputs.providerId}. Add a Gemini-compatible provider in Settings \u2192 LLM Providers.`
705
587
  );
706
588
  }
707
- const { apiKey } = (0, import_completion2.resolveProviderEndpoint)(provider);
589
+ const { apiKey } = _completion.resolveProviderEndpoint.call(void 0, provider);
708
590
  if (!resolveApiKey2(apiKey)) {
709
591
  throw new Error(
710
592
  `gemini-cli proxy: provider "${inputs.providerId}" has no valid API key. Add an API key in Settings \u2192 LLM Providers.`
711
593
  );
712
594
  }
713
595
  const route = {
714
- sessionId: inputs.sessionId ?? null,
596
+ sessionId: _nullishCoalesce(inputs.sessionId, () => ( null)),
715
597
  targetProviderFormat: "transform",
716
598
  model: inputs.model,
717
599
  ingressFormat: "gemini-generatecontent",
718
600
  authMode: "byo",
719
601
  providerId: inputs.providerId
720
602
  };
721
- const proxy = (0, import_provider_proxy2.getProviderProxy)();
603
+ const proxy = _providerproxy.getProviderProxy.call(void 0, );
722
604
  const token = proxy.addRoute(route);
723
605
  const baseUrl = proxy.getBaseUrl();
724
606
  console.log("[buildGeminiCliLaunchConfig] gemini-CLI route ready (forced API-key)", {
@@ -740,7 +622,7 @@ async function buildGeminiCliLaunchConfig(inputs) {
740
622
  onSessionEnd: () => {
741
623
  try {
742
624
  proxy.removeRoute(token);
743
- } catch {
625
+ } catch (e4) {
744
626
  }
745
627
  }
746
628
  };
@@ -754,8 +636,8 @@ function resolveApiKey2(apiKey) {
754
636
  }
755
637
 
756
638
  // src/proxy-env/codex-proxy-env.ts
757
- var import_completion3 = require("@omnicross/core/completion");
758
- var import_provider_proxy3 = require("@omnicross/core/provider-proxy");
639
+
640
+
759
641
  var CODEX_PROXY_PROVIDER_NAME = "omnicross";
760
642
  var CODEX_PROXY_BASE_PATH = "/openai";
761
643
  function buildCodexConfigOverrides(baseUrl) {
@@ -782,7 +664,7 @@ function buildCodexConfigOverrides(baseUrl) {
782
664
  ];
783
665
  }
784
666
  async function buildCodexLaunchConfig(inputs) {
785
- const authMode = inputs.authMode ?? "byo";
667
+ const authMode = _nullishCoalesce(inputs.authMode, () => ( "byo"));
786
668
  if (authMode === "byo") {
787
669
  const provider = await inputs.llmConfig.getProvider(inputs.providerId);
788
670
  if (!provider) {
@@ -790,7 +672,7 @@ async function buildCodexLaunchConfig(inputs) {
790
672
  `Codex proxy: provider not found: ${inputs.providerId}. Add an OpenAI-compatible provider in Settings \u2192 LLM Providers.`
791
673
  );
792
674
  }
793
- const { apiKey } = (0, import_completion3.resolveProviderEndpoint)(provider);
675
+ const { apiKey } = _completion.resolveProviderEndpoint.call(void 0, provider);
794
676
  const resolved = resolveApiKey3(apiKey);
795
677
  if (!resolved) {
796
678
  throw new Error(
@@ -801,15 +683,15 @@ async function buildCodexLaunchConfig(inputs) {
801
683
  throw new Error("Codex proxy: subscription mode requires a codex subscription profile.");
802
684
  }
803
685
  const route = {
804
- sessionId: inputs.sessionId ?? null,
686
+ sessionId: _nullishCoalesce(inputs.sessionId, () => ( null)),
805
687
  targetProviderFormat: "openai-responses",
806
688
  model: inputs.model,
807
689
  ingressFormat: "openai-responses",
808
690
  authMode,
809
691
  providerId: inputs.providerId,
810
- subscriptionProfile: inputs.subscriptionProfile ?? null
692
+ subscriptionProfile: _nullishCoalesce(inputs.subscriptionProfile, () => ( null))
811
693
  };
812
- const proxy = (0, import_provider_proxy3.getProviderProxy)();
694
+ const proxy = _providerproxy.getProviderProxy.call(void 0, );
813
695
  const token = proxy.addRoute(route);
814
696
  const baseUrl = proxy.getBaseUrl();
815
697
  console.log("[buildCodexLaunchConfig] Codex route ready", {
@@ -848,18 +730,17 @@ function getProcessSupervisor() {
848
730
  if (!instance) instance = createProcessSupervisor();
849
731
  return instance;
850
732
  }
851
- // Annotate the CommonJS export names for ESM import in node:
852
- 0 && (module.exports = {
853
- CHAT_PROXY_BASE_PATH,
854
- CLAUDE_PROXY_API_KEY_SENTINEL,
855
- CODEX_PROXY_BASE_PATH,
856
- CODEX_PROXY_PROVIDER_NAME,
857
- OPENCODE_PROXY_PROVIDER_ID,
858
- OPENCODE_PROXY_TOKEN_ENV,
859
- buildChatCliLaunchConfig,
860
- buildClaudeCliLaunchConfig,
861
- buildCodexConfigOverrides,
862
- buildCodexLaunchConfig,
863
- buildGeminiCliLaunchConfig,
864
- getProcessSupervisor
865
- });
733
+
734
+
735
+
736
+
737
+
738
+
739
+
740
+
741
+
742
+
743
+
744
+
745
+
746
+ exports.CHAT_PROXY_BASE_PATH = CHAT_PROXY_BASE_PATH; exports.CLAUDE_PROXY_API_KEY_SENTINEL = CLAUDE_PROXY_API_KEY_SENTINEL; exports.CODEX_PROXY_BASE_PATH = CODEX_PROXY_BASE_PATH; exports.CODEX_PROXY_PROVIDER_NAME = CODEX_PROXY_PROVIDER_NAME; exports.OPENCODE_PROXY_PROVIDER_ID = OPENCODE_PROXY_PROVIDER_ID; exports.OPENCODE_PROXY_TOKEN_ENV = OPENCODE_PROXY_TOKEN_ENV; exports.buildChatCliLaunchConfig = buildChatCliLaunchConfig; exports.buildClaudeCliLaunchConfig = buildClaudeCliLaunchConfig; exports.buildCodexConfigOverrides = buildCodexConfigOverrides; exports.buildCodexLaunchConfig = buildCodexLaunchConfig; exports.buildGeminiCliLaunchConfig = buildGeminiCliLaunchConfig; exports.getProcessSupervisor = getProcessSupervisor;