@codexhost/cli 0.0.0-test.20260804.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 (3) hide show
  1. package/README.md +13 -0
  2. package/bin/codexhost.js +113 -0
  3. package/package.json +41 -0
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # @codexhost/cli
2
+
3
+ Run Pi and Claude Code as first-class external harnesses inside Codex Desktop.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g @codexhost/cli@0.0.0-test.20260804.1
9
+ ```
10
+
11
+ npm automatically installs the matching macOS or Windows platform package. Node.js 22 or newer and Codex Desktop are required.
12
+
13
+ If installation used `--omit=optional`, reinstall without that option so npm can select the native package for the current architecture.
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from "node:child_process";
3
+ import { existsSync } from "node:fs";
4
+ import { createRequire } from "node:module";
5
+ import path from "node:path";
6
+
7
+ const platformPackages = {
8
+ "darwin-arm64": "@codexhost/cli-darwin-arm64",
9
+ "darwin-x64": "@codexhost/cli-darwin-x64",
10
+ "win32-x64": "@codexhost/cli-win32-x64",
11
+ "win32-arm64": "@codexhost/cli-win32-arm64"
12
+ };
13
+ const platformKey = `${process.platform}-${process.arch}`;
14
+ const platformPackage = platformPackages[platformKey];
15
+ if (!platformPackage) fail(`unsupported platform '${platformKey}'`);
16
+
17
+ const require = createRequire(import.meta.url);
18
+ let packageRoot;
19
+ try {
20
+ packageRoot = path.dirname(require.resolve(`${platformPackage}/package.json`));
21
+ } catch {
22
+ fail(
23
+ `missing optional platform package '${platformPackage}'. Reinstall @codexhost/cli without --omit=optional.`,
24
+ );
25
+ }
26
+
27
+ const executableSuffix = process.platform === "win32" ? ".exe" : "";
28
+ const launcher = path.join(packageRoot, "bin", `codexhost${executableSuffix}`);
29
+ const shim = path.join(packageRoot, "libexec", `codexhost-shim${executableSuffix}`);
30
+ const hostRuntime = path.join(packageRoot, "app", "host-runtime.mjs");
31
+ const desktopController = path.join(packageRoot, "app", "desktop-controller.mjs");
32
+ const rendererExtension = path.join(packageRoot, "app", "renderer-extension.js");
33
+
34
+ function fail(message) {
35
+ console.error(`codexhost: ${message}`);
36
+ process.exit(1);
37
+ }
38
+
39
+ for (const [label, filePath] of [
40
+ ["launcher", launcher],
41
+ ["shim", shim],
42
+ ["host runtime", hostRuntime],
43
+ ["desktop controller", desktopController],
44
+ ["renderer extension", rendererExtension],
45
+ ]) {
46
+ if (!existsSync(filePath)) fail(`missing ${label}: ${filePath}`);
47
+ }
48
+
49
+ const userArguments = process.argv.slice(2);
50
+ let launchArguments;
51
+ if (userArguments.length === 0) {
52
+ launchArguments = ["launch", "--agent", "pi"];
53
+ } else if (userArguments[0] === "launch") {
54
+ launchArguments = userArguments;
55
+ } else if (userArguments[0] === "inspect") {
56
+ launchArguments = userArguments;
57
+ } else if (userArguments[0] === "--help" || userArguments[0] === "-h") {
58
+ console.log(
59
+ [
60
+ "usage:",
61
+ " codexhost",
62
+ " codexhost inspect",
63
+ " codexhost launch --agent <codex|pi> [launcher options]",
64
+ "",
65
+ "This npm package uses the current Node.js runtime and the packaged",
66
+ "Rust launcher/shim. Codex Desktop must already be installed.",
67
+ ].join("\n"),
68
+ );
69
+ process.exit(0);
70
+ } else {
71
+ fail(
72
+ `unknown command '${userArguments[0]}'. Run 'codexhost --help' for usage.`,
73
+ );
74
+ }
75
+
76
+ if (launchArguments[0] === "launch") {
77
+ const injected = new Set();
78
+ for (let index = 1; index < launchArguments.length; index += 1) {
79
+ const argument = launchArguments[index];
80
+ if (
81
+ argument === "--node" ||
82
+ argument === "--shim" ||
83
+ argument === "--host-runtime" ||
84
+ argument === "--desktop-controller" ||
85
+ argument === "--renderer"
86
+ ) {
87
+ injected.add(argument);
88
+ index += 1;
89
+ }
90
+ }
91
+ const extras = [];
92
+ if (!injected.has("--node")) extras.push("--node", process.execPath);
93
+ if (!injected.has("--shim")) extras.push("--shim", shim);
94
+ if (!injected.has("--host-runtime")) extras.push("--host-runtime", hostRuntime);
95
+ if (!injected.has("--desktop-controller")) {
96
+ extras.push("--desktop-controller", desktopController);
97
+ }
98
+ if (!injected.has("--renderer")) extras.push("--renderer", rendererExtension);
99
+ launchArguments = ["launch", ...extras, ...launchArguments.slice(1)];
100
+ }
101
+
102
+ const child = spawn(launcher, launchArguments, {
103
+ stdio: "inherit",
104
+ windowsHide: true,
105
+ });
106
+ child.on("error", (error) => fail(error.message));
107
+ child.on("exit", (code, signal) => {
108
+ if (signal) {
109
+ process.kill(process.pid, signal);
110
+ return;
111
+ }
112
+ process.exit(code ?? 1);
113
+ });
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@codexhost/cli",
3
+ "version": "0.0.0-test.20260804.1",
4
+ "description": "Run Pi and Claude Code as first-class external harnesses inside Codex Desktop.",
5
+ "type": "module",
6
+ "bin": {
7
+ "codexhost": "bin/codexhost.js"
8
+ },
9
+ "files": [
10
+ "bin/**",
11
+ "README.md"
12
+ ],
13
+ "engines": {
14
+ "node": ">=22"
15
+ },
16
+ "optionalDependencies": {
17
+ "@codexhost/cli-darwin-arm64": "0.0.0-test.20260804.1",
18
+ "@codexhost/cli-darwin-x64": "0.0.0-test.20260804.1",
19
+ "@codexhost/cli-win32-x64": "0.0.0-test.20260804.1",
20
+ "@codexhost/cli-win32-arm64": "0.0.0-test.20260804.1"
21
+ },
22
+ "keywords": [
23
+ "codex",
24
+ "codexhost",
25
+ "pi",
26
+ "claude-code",
27
+ "agent",
28
+ "harness"
29
+ ],
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/BytePioneer-AI/codex-host.git"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/BytePioneer-AI/codex-host/issues"
36
+ },
37
+ "homepage": "https://github.com/BytePioneer-AI/codex-host#readme",
38
+ "publishConfig": {
39
+ "access": "public"
40
+ }
41
+ }