codexapp 0.1.11 → 0.1.13
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.html
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Codex Web Local</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-BbLBa1Hd.js"></script>
|
|
8
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BiAYhIR0.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body class="bg-slate-950">
|
|
11
11
|
<div id="app"></div>
|
package/dist-cli/index.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
// src/cli/index.ts
|
|
4
4
|
import { createServer as createServer2 } from "http";
|
|
5
5
|
import { existsSync } from "fs";
|
|
6
|
-
import { accessSync, constants } from "fs";
|
|
7
6
|
import { readFile as readFile2 } from "fs/promises";
|
|
8
7
|
import { homedir as homedir2 } from "os";
|
|
9
8
|
import { join as join3 } from "path";
|
|
@@ -1463,42 +1462,6 @@ function runWithStatus(command, args) {
|
|
|
1463
1462
|
function getUserNpmPrefix() {
|
|
1464
1463
|
return join3(homedir2(), ".npm-global");
|
|
1465
1464
|
}
|
|
1466
|
-
function installGlobalNpmPackageWithFallback(pkg, label) {
|
|
1467
|
-
const npmPrefix = spawnSync("npm", ["config", "get", "prefix"], {
|
|
1468
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
1469
|
-
encoding: "utf8"
|
|
1470
|
-
}).stdout?.trim();
|
|
1471
|
-
const globalPrefixWritable = Boolean(npmPrefix && (() => {
|
|
1472
|
-
try {
|
|
1473
|
-
accessSync(npmPrefix, constants.W_OK);
|
|
1474
|
-
return true;
|
|
1475
|
-
} catch {
|
|
1476
|
-
return false;
|
|
1477
|
-
}
|
|
1478
|
-
})());
|
|
1479
|
-
if (!globalPrefixWritable && !isTermuxRuntime()) {
|
|
1480
|
-
const userPrefix2 = getUserNpmPrefix();
|
|
1481
|
-
console.log(`
|
|
1482
|
-
Global npm prefix is not writable. Installing with --prefix ${userPrefix2}...
|
|
1483
|
-
`);
|
|
1484
|
-
runOrFail("npm", ["install", "-g", "--prefix", userPrefix2, pkg], `${label} (user prefix)`);
|
|
1485
|
-
process.env.PATH = `${join3(userPrefix2, "bin")}:${process.env.PATH ?? ""}`;
|
|
1486
|
-
return;
|
|
1487
|
-
}
|
|
1488
|
-
const status = runWithStatus("npm", ["install", "-g", pkg]);
|
|
1489
|
-
if (status === 0) {
|
|
1490
|
-
return;
|
|
1491
|
-
}
|
|
1492
|
-
if (isTermuxRuntime()) {
|
|
1493
|
-
throw new Error(`${label} failed with exit code ${String(status)}`);
|
|
1494
|
-
}
|
|
1495
|
-
const userPrefix = getUserNpmPrefix();
|
|
1496
|
-
console.log(`
|
|
1497
|
-
Global npm install requires elevated permissions. Retrying with --prefix ${userPrefix}...
|
|
1498
|
-
`);
|
|
1499
|
-
runOrFail("npm", ["install", "-g", "--prefix", userPrefix, pkg], `${label} (user prefix)`);
|
|
1500
|
-
process.env.PATH = `${join3(userPrefix, "bin")}:${process.env.PATH ?? ""}`;
|
|
1501
|
-
}
|
|
1502
1465
|
function resolveCodexCommand() {
|
|
1503
1466
|
if (canRun("codex", ["--version"])) {
|
|
1504
1467
|
return "codex";
|
|
@@ -1524,17 +1487,32 @@ function hasCodexAuth() {
|
|
|
1524
1487
|
function ensureCodexInstalled() {
|
|
1525
1488
|
let codexCommand = resolveCodexCommand();
|
|
1526
1489
|
if (!codexCommand) {
|
|
1490
|
+
const installWithFallback = (pkg, label) => {
|
|
1491
|
+
const status = runWithStatus("npm", ["install", "-g", pkg]);
|
|
1492
|
+
if (status === 0) {
|
|
1493
|
+
return;
|
|
1494
|
+
}
|
|
1495
|
+
if (isTermuxRuntime()) {
|
|
1496
|
+
throw new Error(`${label} failed with exit code ${String(status)}`);
|
|
1497
|
+
}
|
|
1498
|
+
const userPrefix = getUserNpmPrefix();
|
|
1499
|
+
console.log(`
|
|
1500
|
+
Global npm install requires elevated permissions. Retrying with --prefix ${userPrefix}...
|
|
1501
|
+
`);
|
|
1502
|
+
runOrFail("npm", ["install", "-g", "--prefix", userPrefix, pkg], `${label} (user prefix)`);
|
|
1503
|
+
process.env.PATH = `${join3(userPrefix, "bin")}:${process.env.PATH ?? ""}`;
|
|
1504
|
+
};
|
|
1527
1505
|
if (isTermuxRuntime()) {
|
|
1528
1506
|
console.log("\nCodex CLI not found. Installing Termux-compatible Codex CLI from npm...\n");
|
|
1529
|
-
|
|
1507
|
+
installWithFallback("@mmmbuto/codex-cli-termux", "Codex CLI install");
|
|
1530
1508
|
codexCommand = resolveCodexCommand();
|
|
1531
1509
|
if (!codexCommand) {
|
|
1532
1510
|
console.log("\nTermux npm package did not expose `codex`. Installing official CLI fallback...\n");
|
|
1533
|
-
|
|
1511
|
+
installWithFallback("@openai/codex", "Codex CLI fallback install");
|
|
1534
1512
|
}
|
|
1535
1513
|
} else {
|
|
1536
1514
|
console.log("\nCodex CLI not found. Installing official Codex CLI from npm...\n");
|
|
1537
|
-
|
|
1515
|
+
installWithFallback("@openai/codex", "Codex CLI install");
|
|
1538
1516
|
}
|
|
1539
1517
|
codexCommand = resolveCodexCommand();
|
|
1540
1518
|
if (!codexCommand && !isTermuxRuntime()) {
|
|
@@ -1550,37 +1528,6 @@ function ensureCodexInstalled() {
|
|
|
1550
1528
|
}
|
|
1551
1529
|
return codexCommand;
|
|
1552
1530
|
}
|
|
1553
|
-
function resolveCloudflaredCommand() {
|
|
1554
|
-
if (canRun("cloudflared", ["--version"])) {
|
|
1555
|
-
return "cloudflared";
|
|
1556
|
-
}
|
|
1557
|
-
const userCandidate = join3(getUserNpmPrefix(), "bin", "cloudflared");
|
|
1558
|
-
if (existsSync(userCandidate) && canRun(userCandidate, ["--version"])) {
|
|
1559
|
-
return userCandidate;
|
|
1560
|
-
}
|
|
1561
|
-
const prefix = process.env.PREFIX?.trim();
|
|
1562
|
-
if (!prefix) {
|
|
1563
|
-
return null;
|
|
1564
|
-
}
|
|
1565
|
-
const candidate = join3(prefix, "bin", "cloudflared");
|
|
1566
|
-
if (existsSync(candidate) && canRun(candidate, ["--version"])) {
|
|
1567
|
-
return candidate;
|
|
1568
|
-
}
|
|
1569
|
-
return null;
|
|
1570
|
-
}
|
|
1571
|
-
function ensureCloudflaredInstalled() {
|
|
1572
|
-
let cloudflaredCommand = resolveCloudflaredCommand();
|
|
1573
|
-
if (!cloudflaredCommand) {
|
|
1574
|
-
console.log("\ncloudflared not found. Installing from npm...\n");
|
|
1575
|
-
installGlobalNpmPackageWithFallback("cloudflared", "cloudflared install");
|
|
1576
|
-
cloudflaredCommand = resolveCloudflaredCommand();
|
|
1577
|
-
if (!cloudflaredCommand) {
|
|
1578
|
-
throw new Error("cloudflared install completed but binary is still not available in PATH");
|
|
1579
|
-
}
|
|
1580
|
-
console.log("\ncloudflared installed.\n");
|
|
1581
|
-
}
|
|
1582
|
-
return cloudflaredCommand;
|
|
1583
|
-
}
|
|
1584
1531
|
function resolvePassword(input) {
|
|
1585
1532
|
if (input === false) {
|
|
1586
1533
|
return void 0;
|
|
@@ -1614,9 +1561,9 @@ function parseCloudflaredUrl(chunk) {
|
|
|
1614
1561
|
}
|
|
1615
1562
|
return urlMatch[urlMatch.length - 1] ?? null;
|
|
1616
1563
|
}
|
|
1617
|
-
async function startCloudflaredTunnel(
|
|
1564
|
+
async function startCloudflaredTunnel(localPort) {
|
|
1618
1565
|
return new Promise((resolve2, reject) => {
|
|
1619
|
-
const child = spawn2(
|
|
1566
|
+
const child = spawn2("cloudflared", ["tunnel", "--url", `http://localhost:${String(localPort)}`], {
|
|
1620
1567
|
stdio: ["ignore", "pipe", "pipe"]
|
|
1621
1568
|
});
|
|
1622
1569
|
const timeout = setTimeout(() => {
|
|
@@ -1688,19 +1635,14 @@ async function startServer(options) {
|
|
|
1688
1635
|
let tunnelChild = null;
|
|
1689
1636
|
let tunnelUrl = null;
|
|
1690
1637
|
if (options.tunnel) {
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
tunnelUrl = tunnel.url;
|
|
1699
|
-
} catch (error) {
|
|
1700
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1701
|
-
console.warn(`
|
|
1638
|
+
try {
|
|
1639
|
+
const tunnel = await startCloudflaredTunnel(port);
|
|
1640
|
+
tunnelChild = tunnel.process;
|
|
1641
|
+
tunnelUrl = tunnel.url;
|
|
1642
|
+
} catch (error) {
|
|
1643
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1644
|
+
console.warn(`
|
|
1702
1645
|
[cloudflared] Tunnel not started: ${message}`);
|
|
1703
|
-
}
|
|
1704
1646
|
}
|
|
1705
1647
|
}
|
|
1706
1648
|
const lines = [
|