@lesscap/baton-cli 0.7.8 → 0.7.9

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/baton.mjs CHANGED
@@ -9809,10 +9809,23 @@ var import_websocket_server = __toESM(require_websocket_server(), 1);
9809
9809
 
9810
9810
  // src/worker/pty.ts
9811
9811
  import { existsSync as existsSync8, readdirSync as readdirSync2 } from "node:fs";
9812
+ import { createRequire as createModuleRequire } from "node:module";
9812
9813
  import { homedir as homedir3 } from "node:os";
9813
9814
  import { join as join12 } from "node:path";
9814
9815
  var MAX_TERMINALS = 10;
9815
- var ptyArgs = (agentSessionId, hasJsonl) => hasJsonl ? ["--resume", agentSessionId] : ["--session-id", agentSessionId];
9816
+ var claudePtyCommand = (agentSessionId, hasJsonl, env = process.env) => ({
9817
+ file: env.BATON_CLAUDE_BIN?.trim() || "claude",
9818
+ args: hasJsonl ? ["--resume", agentSessionId] : ["--session-id", agentSessionId]
9819
+ });
9820
+ var moduleRequire = createModuleRequire(import.meta.url);
9821
+ var codexPtyCommand = (agentSessionId, env = process.env) => {
9822
+ const args = ["resume", "--include-non-interactive", agentSessionId];
9823
+ const override = env.BATON_CODEX_BIN?.trim();
9824
+ return override ? { file: override, args } : {
9825
+ file: process.execPath,
9826
+ args: [moduleRequire.resolve("@openai/codex/bin/codex.js"), ...args]
9827
+ };
9828
+ };
9816
9829
  var hasSessionJsonl = (agentSessionId) => {
9817
9830
  const root = join12(homedir3(), ".claude", "projects");
9818
9831
  if (!existsSync8(root)) return false;
@@ -9839,8 +9852,8 @@ var createTerminalManager = (deps) => {
9839
9852
  log(`terminal #${sessionId}: worktree preparation failed: ${String(error)}`);
9840
9853
  return;
9841
9854
  }
9842
- const claudeBin = process.env.BATON_CLAUDE_BIN ?? "claude";
9843
- const term = spawn4(claudeBin, ptyArgs(agentSessionId, hasSessionJsonl(agentSessionId)), {
9855
+ const command = cfg.agentKind === "codex" ? codexPtyCommand(agentSessionId) : claudePtyCommand(agentSessionId, hasSessionJsonl(agentSessionId));
9856
+ const term = spawn4(command.file, command.args, {
9844
9857
  name: "xterm-color",
9845
9858
  cols: 80,
9846
9859
  rows: 24,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lesscap/baton-cli",
3
- "version": "0.7.8",
3
+ "version": "0.7.9",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -27,7 +27,8 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@anthropic-ai/claude-agent-sdk": "^0.3.220",
30
- "@openai/codex-sdk": "^0.146.0",
30
+ "@openai/codex": "0.146.0",
31
+ "@openai/codex-sdk": "0.146.0",
31
32
  "mime": "^4.1.0",
32
33
  "node-pty": "^1.1.0",
33
34
  "ws": "^8.21.0"
@@ -5,14 +5,31 @@
5
5
  // python3 + a C++ toolchain). Non-fatal: a host that can't build it just loses
6
6
  // interactive terminals, while the headless relay keeps working.
7
7
  import { execSync } from 'node:child_process'
8
+ import { chmodSync, existsSync } from 'node:fs'
8
9
  import { createRequire } from 'node:module'
10
+ import { dirname, join } from 'node:path'
9
11
 
10
12
  const require = createRequire(import.meta.url)
11
13
 
14
+ const ensureSpawnHelperExecutable = () => {
15
+ if (process.platform === 'win32') return
16
+ const helper = join(
17
+ dirname(require.resolve('node-pty')),
18
+ '..',
19
+ 'prebuilds',
20
+ `${process.platform}-${process.arch}`,
21
+ 'spawn-helper',
22
+ )
23
+ if (existsSync(helper)) chmodSync(helper, 0o755)
24
+ }
25
+
12
26
  const works = () => {
13
27
  try {
28
+ ensureSpawnHelperExecutable()
14
29
  const pty = require('node-pty')
15
- pty.spawn(process.platform === 'win32' ? 'cmd.exe' : '/bin/sh', [], { cols: 80, rows: 24 }).kill()
30
+ pty
31
+ .spawn(process.platform === 'win32' ? 'cmd.exe' : '/bin/sh', [], { cols: 80, rows: 24 })
32
+ .kill()
16
33
  return true
17
34
  } catch {
18
35
  return false