nuwax-codex 0.16.1-beta.6

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/nuwax-codex.js +95 -0
  2. package/package.json +45 -0
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env node
2
+ // Launcher for the nuwax-codex npm package.
3
+ // Resolves the platform-specific optional dependency that ships the native
4
+ // `nuwax-codex` binary (and the bundled `bwrap` on Linux) and spawns it with
5
+ // the forwarded argv. Both the npm command and the native binary are named
6
+ // "nuwax-codex".
7
+
8
+ import { spawnSync } from "node:child_process";
9
+ import { existsSync } from "node:fs";
10
+ import { fileURLToPath } from "node:url";
11
+ import { familySync } from "detect-libc";
12
+
13
+ // Map Node.js platform/arch to the platform-specific npm package name.
14
+ function getPlatformPackage() {
15
+ const platform = process.platform;
16
+ const arch = process.arch;
17
+
18
+ const platformMap = {
19
+ darwin: {
20
+ arm64: "nuwax-codex-darwin-arm64",
21
+ x64: "nuwax-codex-darwin-x64",
22
+ },
23
+ linux: {
24
+ // arm64 Linux is not shipped (GitHub arm64 runners are too flaky to build
25
+ // it reliably); only x64 Linux is supported for now.
26
+ x64: familySync() === "musl"
27
+ ? "nuwax-codex-linux-x64-musl"
28
+ : "nuwax-codex-linux-x64",
29
+ },
30
+ win32: {
31
+ arm64: "nuwax-codex-win32-arm64",
32
+ x64: "nuwax-codex-win32-x64",
33
+ },
34
+ };
35
+
36
+ const packages = platformMap[platform];
37
+ if (!packages) {
38
+ console.error(`Unsupported platform: ${platform}`);
39
+ process.exit(1);
40
+ }
41
+
42
+ const packageName = packages[arch];
43
+ if (!packageName) {
44
+ console.error(`Unsupported architecture: ${arch} on ${platform}`);
45
+ process.exit(1);
46
+ }
47
+
48
+ return packageName;
49
+ }
50
+
51
+ // Locate the native `nuwax-codex` binary inside the resolved platform package.
52
+ function getBinaryPath() {
53
+ const packageName = getPlatformPackage();
54
+ const binaryName =
55
+ process.platform === "win32" ? "nuwax-codex.exe" : "nuwax-codex";
56
+
57
+ try {
58
+ const binaryPath = fileURLToPath(
59
+ import.meta.resolve(`${packageName}/bin/${binaryName}`),
60
+ );
61
+
62
+ if (existsSync(binaryPath)) {
63
+ return binaryPath;
64
+ }
65
+ } catch (e) {
66
+ console.error(`Error resolving package: ${e}`);
67
+ // Package not found — fall through to the helpful error below.
68
+ }
69
+
70
+ console.error(
71
+ `Failed to locate ${packageName} binary. This usually means the optional dependency was not installed.`,
72
+ );
73
+ console.error(`Platform: ${process.platform}, Architecture: ${process.arch}`);
74
+ process.exit(1);
75
+ }
76
+
77
+ // Execute the binary, forwarding stdin/stdout/stderr and the exit code.
78
+ function run() {
79
+ const binaryPath = getBinaryPath();
80
+ const result = spawnSync(binaryPath, process.argv.slice(2), {
81
+ stdio: "inherit",
82
+ windowsHide: true,
83
+ });
84
+
85
+ if (result.error) {
86
+ console.error(`Failed to execute ${binaryPath}:`, result.error);
87
+ process.exit(1);
88
+ }
89
+
90
+ // result.status is null when the child was killed by a signal; treat that as
91
+ // a failure (exit 1) rather than success.
92
+ process.exit(result.status ?? 1);
93
+ }
94
+
95
+ run();
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "nuwax-codex",
3
+ "version": "0.16.1-beta.6",
4
+ "type": "module",
5
+ "description": "Fork of OpenAI Codex CLI with domestic (Chinese) LLM support via genai",
6
+ "license": "Apache-2.0",
7
+ "author": "soddygo <soddygo@qq.com>",
8
+ "homepage": "https://github.com/nuwax-ai/codex",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/nuwax-ai/codex.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/nuwax-ai/codex/issues"
15
+ },
16
+ "keywords": [
17
+ "codex",
18
+ "agent",
19
+ "coding",
20
+ "ai",
21
+ "assistant",
22
+ "llm",
23
+ "genai"
24
+ ],
25
+ "bin": {
26
+ "nuwax-codex": "bin/nuwax-codex.js"
27
+ },
28
+ "files": [
29
+ "bin"
30
+ ],
31
+ "engines": {
32
+ "node": ">=20"
33
+ },
34
+ "dependencies": {
35
+ "detect-libc": "^2.0.0"
36
+ },
37
+ "optionalDependencies": {
38
+ "nuwax-codex-darwin-arm64": "0.16.1-beta.6",
39
+ "nuwax-codex-darwin-x64": "0.16.1-beta.6",
40
+ "nuwax-codex-linux-x64": "0.16.1-beta.6",
41
+ "nuwax-codex-linux-x64-musl": "0.16.1-beta.6",
42
+ "nuwax-codex-win32-arm64": "0.16.1-beta.6",
43
+ "nuwax-codex-win32-x64": "0.16.1-beta.6"
44
+ }
45
+ }