nomadexapp 0.2.0 → 0.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/bin/nomadex.mjs +68 -4
  2. package/package.json +1 -1
package/bin/nomadex.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { createServer } from "node:http";
4
- import { statSync, readFileSync, existsSync } from "node:fs";
4
+ import { statSync, readFileSync, existsSync, realpathSync } from "node:fs";
5
5
  import { readFile } from "node:fs/promises";
6
6
  import net from "node:net";
7
7
  import os from "node:os";
@@ -443,6 +443,15 @@ const isTermuxEnvironment = () => {
443
443
  );
444
444
  };
445
445
 
446
+ const isTransientNpxCodexPath = (candidate) => {
447
+ const normalized = candidate.replaceAll("\\", "/");
448
+ return (
449
+ normalized.includes("/.npm/_npx/") ||
450
+ normalized.includes("/node_modules/.bin/codex") ||
451
+ normalized.includes("/node_modules/@openai/codex/")
452
+ );
453
+ };
454
+
446
455
  const resolveLocalNodePackageLaunch = (packageName, binName) => {
447
456
  try {
448
457
  const packageJsonPath = require.resolve(`${packageName}/package.json`);
@@ -467,14 +476,24 @@ const resolveLocalNodePackageLaunch = (packageName, binName) => {
467
476
  }
468
477
  };
469
478
 
470
- const resolveExecutableOnPath = (commandNames) => {
479
+ const resolveExecutableOnPath = (commandNames, options = {}) => {
480
+ const { exclude } = options;
471
481
  const pathDirs = (process.env.PATH ?? "").split(path.delimiter).filter(Boolean);
472
482
 
473
483
  for (const dir of pathDirs) {
474
484
  for (const commandName of commandNames) {
475
485
  const candidate = path.join(dir, commandName);
476
486
  try {
477
- if (statSync(candidate).isFile()) {
487
+ if (!statSync(candidate).isFile()) {
488
+ continue;
489
+ }
490
+
491
+ const resolved = realpathSync(candidate);
492
+ if (exclude?.(candidate, resolved)) {
493
+ continue;
494
+ }
495
+
496
+ if (resolved) {
478
497
  return candidate;
479
498
  }
480
499
  } catch {
@@ -504,6 +523,49 @@ const resolvePathCodexLaunch = () => {
504
523
  };
505
524
  };
506
525
 
526
+ const resolveTermuxCodexLaunch = () => {
527
+ const prefix = process.env.PREFIX?.trim() || "/data/data/com.termux/files/usr";
528
+ const directCandidates = [
529
+ path.join(prefix, "bin", "codex"),
530
+ "/data/data/com.termux/files/usr/bin/codex",
531
+ ];
532
+
533
+ for (const candidate of directCandidates) {
534
+ try {
535
+ if (statSync(candidate).isFile()) {
536
+ return {
537
+ command: candidate,
538
+ args: [],
539
+ shell: false,
540
+ source: "Termux codex",
541
+ };
542
+ }
543
+ } catch {
544
+ continue;
545
+ }
546
+ }
547
+
548
+ const commandNames =
549
+ process.platform === "win32"
550
+ ? ["codex.cmd", "codex.exe", "codex.bat", "codex"]
551
+ : ["codex"];
552
+ const command = resolveExecutableOnPath(commandNames, {
553
+ exclude: (candidate, resolved) =>
554
+ isTransientNpxCodexPath(candidate) || isTransientNpxCodexPath(resolved),
555
+ });
556
+
557
+ if (!command) {
558
+ return null;
559
+ }
560
+
561
+ return {
562
+ command,
563
+ args: [],
564
+ shell: false,
565
+ source: "Termux codex",
566
+ };
567
+ };
568
+
507
569
  const getCodexLaunch = () => {
508
570
  const explicitCommand = options.codexCommand.trim();
509
571
  if (explicitCommand) {
@@ -516,7 +578,9 @@ const getCodexLaunch = () => {
516
578
  }
517
579
 
518
580
  const dependencyLaunch = resolveLocalNodePackageLaunch("@openai/codex", "codex");
519
- const pathLaunch = resolvePathCodexLaunch();
581
+ const pathLaunch = isTermuxEnvironment()
582
+ ? resolveTermuxCodexLaunch()
583
+ : resolvePathCodexLaunch();
520
584
 
521
585
  if (isTermuxEnvironment()) {
522
586
  return pathLaunch ?? dependencyLaunch ?? {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nomadexapp",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Remote browser workspace for local coding agents",
5
5
  "license": "MIT",
6
6
  "type": "module",