mini-opti-bridge 0.1.0 → 0.1.2

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 +15 -0
  2. package/dist/cli.js +37 -5
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -14,3 +14,18 @@ Optional named node:
14
14
  ```bash
15
15
  npx mini-opti-bridge@latest https://mini-opti.vercel.app <registrationKey> my-node local
16
16
  ```
17
+
18
+ ## Codex CLI
19
+
20
+ The bridge starts `codex app-server` locally.
21
+
22
+ - If `codex` is already in `PATH`, nothing else is needed.
23
+ - If it is installed elsewhere, set `MINI_OPTI_CODEX_BIN` to the full path of `codex`, `codex.cmd`, or `codex.exe`.
24
+ - On Windows, the bridge now launches Codex through `cmd.exe`, so standard npm-installed `codex` shims work without extra setup.
25
+
26
+ Windows example:
27
+
28
+ ```powershell
29
+ $env:MINI_OPTI_CODEX_BIN="C:\\Users\\you\\AppData\\Roaming\\npm\\codex.cmd"
30
+ npx mini-opti-bridge@latest https://mini-opti.vercel.app <registrationKey>
31
+ ```
package/dist/cli.js CHANGED
@@ -30,19 +30,51 @@ var parseBridgeBootstrap = (input) => {
30
30
  // ../connectors/src/codex/app-server-client.ts
31
31
  import { spawn } from "child_process";
32
32
  import readline from "readline";
33
+ var defaultCodexBin = (platform = process.platform) => "codex";
34
+ var resolveCodexBin = (env = process.env, platform = process.platform) => env.MINI_OPTI_CODEX_BIN?.trim() || env.CODEX_BIN?.trim() || defaultCodexBin(platform);
35
+ var resolveCodexLaunch = (env = process.env, platform = process.platform) => {
36
+ const codexBin = resolveCodexBin(env, platform);
37
+ if (platform === "win32") {
38
+ return { command: "cmd.exe", args: ["/d", "/s", "/c", codexBin, "app-server"] };
39
+ }
40
+ return { command: codexBin, args: ["app-server"] };
41
+ };
42
+ var codexStartHelp = (input) => {
43
+ if (input.code !== "ENOENT") return `Could not start \`${input.command} app-server\`.`;
44
+ const verify = input.platform === "win32" ? "Run `codex --version` in PowerShell. If that fails, point MINI_OPTI_CODEX_BIN to your codex.cmd or codex.exe." : "Run `codex --version` in your shell. If that fails, point MINI_OPTI_CODEX_BIN to the full codex path.";
45
+ return `Codex CLI was not found. ${verify}`;
46
+ };
33
47
  var CodexAppServerClient = class {
34
48
  proc = null;
35
49
  counter = 0;
36
50
  pending = /* @__PURE__ */ new Map();
37
51
  async start() {
38
52
  if (this.proc) return;
39
- this.proc = spawn("codex", ["app-server"], { stdio: ["pipe", "pipe", "inherit"] });
53
+ const launch = resolveCodexLaunch(process.env, process.platform);
54
+ this.proc = spawn(launch.command, launch.args, { stdio: ["pipe", "pipe", "inherit"] });
55
+ const proc = this.proc;
56
+ const startError = await new Promise((resolve) => {
57
+ proc.once("spawn", () => resolve(null));
58
+ proc.once(
59
+ "error",
60
+ (error) => resolve(new Error(codexStartHelp({ code: error.code, command: launch.command, platform: process.platform })))
61
+ );
62
+ });
63
+ if (startError) {
64
+ this.proc = null;
65
+ throw startError;
66
+ }
40
67
  const rl = readline.createInterface({ input: this.proc.stdout });
41
68
  rl.on("line", (line) => this.onMessage(JSON.parse(line)));
42
- await this.request("initialize", {
43
- clientInfo: { name: "mini-opti-bridge", title: "Mini Opti Bridge", version: "0.1.0" }
44
- });
45
- this.notify("initialized", {});
69
+ try {
70
+ await this.request("initialize", {
71
+ clientInfo: { name: "mini-opti-bridge", title: "Mini Opti Bridge", version: "0.1.0" }
72
+ });
73
+ this.notify("initialized", {});
74
+ } catch (error) {
75
+ this.proc = null;
76
+ throw error;
77
+ }
46
78
  }
47
79
  async listThreads() {
48
80
  const data = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mini-opti-bridge",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "One-command Codex bridge bootstrap for the Mini Opti dashboard",
5
5
  "type": "module",
6
6
  "bin": "cli.js",