codexui-android 0.1.92 → 0.1.93

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-cli/index.js CHANGED
@@ -225,7 +225,7 @@ import express from "express";
225
225
  import { spawn as spawn4 } from "child_process";
226
226
  import { createHash as createHash2, randomBytes } from "crypto";
227
227
  import { mkdtemp as mkdtemp3, readFile as readFile3, readdir as readdir2, rm as rm4, mkdir as mkdir4, stat as stat4 } from "fs/promises";
228
- import { createReadStream, readFileSync } from "fs";
228
+ import { createReadStream, readFileSync as readFileSync2 } from "fs";
229
229
  import { request as httpRequest2 } from "http";
230
230
  import { request as httpsRequest2 } from "https";
231
231
  import { homedir as homedir5 } from "os";
@@ -4346,11 +4346,12 @@ function handleCustomEndpointProxyRequest(req, res, options) {
4346
4346
  }
4347
4347
 
4348
4348
  // src/server/terminalManager.ts
4349
- import { chmodSync, existsSync as existsSync3 } from "fs";
4349
+ import { chmodSync, existsSync as existsSync3, lstatSync, readFileSync, realpathSync, rmSync, writeFileSync } from "fs";
4350
4350
  import { randomUUID } from "crypto";
4351
4351
  import { createRequire } from "module";
4352
4352
  import { basename as basename2, dirname, join as join5 } from "path";
4353
4353
  import { homedir as homedir4 } from "os";
4354
+ import { spawnSync as spawnSync2 } from "child_process";
4354
4355
  var TERMINAL_BUFFER_LIMIT = 16 * 1024;
4355
4356
  var DEFAULT_COLS = 80;
4356
4357
  var DEFAULT_ROWS = 24;
@@ -4584,6 +4585,8 @@ function normalizeDimension(value, fallback) {
4584
4585
  return Math.max(1, Math.min(500, Math.trunc(parsed)));
4585
4586
  }
4586
4587
  function loadTerminalSpawn() {
4588
+ repairNativePtyBuild("node-pty-prebuilt-multiarch");
4589
+ repairNativePtyBuild("node-pty");
4587
4590
  if (resolveNodePtyPrebuiltPath()) {
4588
4591
  try {
4589
4592
  const terminal2 = require2("node-pty-prebuilt-multiarch");
@@ -4594,6 +4597,39 @@ function loadTerminalSpawn() {
4594
4597
  const terminal = require2("node-pty");
4595
4598
  return terminal.spawn;
4596
4599
  }
4600
+ function repairNativePtyBuild(packageName) {
4601
+ try {
4602
+ const packageJson = require2.resolve(`${packageName}/package.json`);
4603
+ const packageRoot = dirname(packageJson);
4604
+ const buildDir = join5(packageRoot, "build");
4605
+ const makefile = join5(buildDir, "Makefile");
4606
+ const binary = join5(buildDir, "Release", "pty.node");
4607
+ if (!existsSync3(makefile) || !isBrokenSymlink(binary)) return;
4608
+ const source = readFileSync(makefile, "utf8");
4609
+ const patched = source.replace(
4610
+ /^cmd_copy = ln -f "\$<" "\$@" 2>\/dev\/null \|\| \(rm -rf "\$@" && cp -af "\$<" "\$@"\)$/m,
4611
+ 'cmd_copy = rm -rf "$@" && cp -af "$<" "$@"'
4612
+ );
4613
+ if (patched !== source) {
4614
+ writeFileSync(makefile, patched);
4615
+ }
4616
+ rmSync(binary, { force: true });
4617
+ spawnSync2("make", ["BUILDTYPE=Release", "-C", buildDir], { stdio: "ignore" });
4618
+ } catch {
4619
+ }
4620
+ }
4621
+ function isBrokenSymlink(path) {
4622
+ try {
4623
+ if (!lstatSync(path).isSymbolicLink()) return false;
4624
+ try {
4625
+ return !existsSync3(realpathSync(path));
4626
+ } catch {
4627
+ return true;
4628
+ }
4629
+ } catch {
4630
+ return false;
4631
+ }
4632
+ }
4597
4633
  function resolveNodePtyPrebuiltPath() {
4598
4634
  try {
4599
4635
  const packageJson = require2.resolve("node-pty-prebuilt-multiarch/package.json");
@@ -4634,7 +4670,7 @@ function shellQuote(value) {
4634
4670
  }
4635
4671
 
4636
4672
  // src/utils/commandInvocation.ts
4637
- import { spawnSync as spawnSync2 } from "child_process";
4673
+ import { spawnSync as spawnSync3 } from "child_process";
4638
4674
  import { basename as basename3, extname } from "path";
4639
4675
  var WINDOWS_CMD_NAMES = /* @__PURE__ */ new Set(["codex", "npm", "npx"]);
4640
4676
  function quoteCmdExeArg(value) {
@@ -4669,7 +4705,7 @@ function getSpawnInvocation(command, args = []) {
4669
4705
  }
4670
4706
  function spawnSyncCommand(command, args = [], options = {}) {
4671
4707
  const invocation = getSpawnInvocation(command, args);
4672
- return spawnSync2(invocation.command, invocation.args, options);
4708
+ return spawnSync3(invocation.command, invocation.args, options);
4673
4709
  }
4674
4710
 
4675
4711
  // src/server/codexAppServerBridge.ts
@@ -4685,7 +4721,7 @@ var DEFAULT_API_PERF_BODY_MB_THRESHOLD = 1;
4685
4721
  var MB_DIVISOR = 1024 * 1024;
4686
4722
  function readEnvValueFromFile(filePath, key) {
4687
4723
  try {
4688
- const content = readFileSync(filePath, "utf8");
4724
+ const content = readFileSync2(filePath, "utf8");
4689
4725
  const escapedKey = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4690
4726
  const match = content.match(new RegExp(`^\\s*${escapedKey}\\s*=\\s*(.+)\\s*$`, "m"));
4691
4727
  if (!match) return null;
@@ -6616,7 +6652,7 @@ var AppServerProcess = class {
6616
6652
  const serverPort = parseInt(process.env.CODEXUI_SERVER_PORT ?? "", 10) || void 0;
6617
6653
  const statePath = join6(getCodexHomeDir3(), FREE_MODE_STATE_FILE);
6618
6654
  try {
6619
- const raw = readFileSync(statePath, "utf8");
6655
+ const raw = readFileSync2(statePath, "utf8");
6620
6656
  const state = JSON.parse(raw);
6621
6657
  args.push(...getFreeModeConfigArgs(state, serverPort));
6622
6658
  extraEnv = getFreeModeEnvVars(state);
@@ -7238,7 +7274,7 @@ function createCodexBridgeMiddleware() {
7238
7274
  let bearerToken = "";
7239
7275
  let wireApi = "chat";
7240
7276
  try {
7241
- const state = JSON.parse(readFileSync(statePath, "utf8"));
7277
+ const state = JSON.parse(readFileSync2(statePath, "utf8"));
7242
7278
  bearerToken = state.apiKey ?? "";
7243
7279
  wireApi = state.wireApi === "responses" ? "responses" : "chat";
7244
7280
  } catch {
@@ -7251,7 +7287,7 @@ function createCodexBridgeMiddleware() {
7251
7287
  let bearerToken = "";
7252
7288
  let wireApi = "responses";
7253
7289
  try {
7254
- const state = JSON.parse(readFileSync(statePath, "utf8"));
7290
+ const state = JSON.parse(readFileSync2(statePath, "utf8"));
7255
7291
  bearerToken = state.apiKey ?? "";
7256
7292
  wireApi = state.wireApi === "chat" ? "chat" : "responses";
7257
7293
  } catch {
@@ -7265,7 +7301,7 @@ function createCodexBridgeMiddleware() {
7265
7301
  let wireApi = "responses";
7266
7302
  let baseUrl = "";
7267
7303
  try {
7268
- const state = JSON.parse(readFileSync(statePath, "utf8"));
7304
+ const state = JSON.parse(readFileSync2(statePath, "utf8"));
7269
7305
  bearerToken = state.apiKey ?? "";
7270
7306
  wireApi = state.wireApi === "chat" ? "chat" : "responses";
7271
7307
  baseUrl = state.customBaseUrl ?? "";
@@ -7277,7 +7313,7 @@ function createCodexBridgeMiddleware() {
7277
7313
  if (url.pathname.startsWith("/codex-api/free-mode")) {
7278
7314
  let readFreeModeState2 = function() {
7279
7315
  try {
7280
- return JSON.parse(readFileSync(statePath, "utf8"));
7316
+ return JSON.parse(readFileSync2(statePath, "utf8"));
7281
7317
  } catch {
7282
7318
  return { enabled: false, apiKey: null, model: FREE_MODE_DEFAULT_MODEL };
7283
7319
  }
@@ -7766,7 +7802,7 @@ function createCodexBridgeMiddleware() {
7766
7802
  }
7767
7803
  if (req.method === "GET" && url.pathname === "/codex-api/provider-models") {
7768
7804
  try {
7769
- const fmState = JSON.parse(readFileSync(join6(getCodexHomeDir3(), FREE_MODE_STATE_FILE), "utf8"));
7805
+ const fmState = JSON.parse(readFileSync2(join6(getCodexHomeDir3(), FREE_MODE_STATE_FILE), "utf8"));
7770
7806
  if (fmState.enabled) {
7771
7807
  if (fmState.provider === "opencode-zen") {
7772
7808
  try {