codeam-cli 2.4.29 → 2.4.30

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/dist/index.js +64 -51
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1482,7 +1482,7 @@ var import_qrcode_terminal = __toESM(require("qrcode-terminal"));
1482
1482
  // package.json
1483
1483
  var package_default = {
1484
1484
  name: "codeam-cli",
1485
- version: "2.4.29",
1485
+ version: "2.4.30",
1486
1486
  description: "Remote control Claude Code (and other AI coding agents) from your mobile phone. Pair your device, send prompts, stream responses in real-time, and approve commands \u2014 from anywhere.",
1487
1487
  main: "dist/index.js",
1488
1488
  bin: {
@@ -1557,7 +1557,7 @@ var package_default = {
1557
1557
  zod: "^4.3.6"
1558
1558
  },
1559
1559
  optionalDependencies: {
1560
- "node-pty": "^1.0.0"
1560
+ "node-pty": "^1.1.0"
1561
1561
  },
1562
1562
  devDependencies: {
1563
1563
  "@codeagent/shared": "*",
@@ -2291,31 +2291,19 @@ var WindowsConPtyStrategy = class _WindowsConPtyStrategy {
2291
2291
  return new _WindowsConPtyStrategy(opts, lib);
2292
2292
  }
2293
2293
  spawn(cmd, cwd, args2 = []) {
2294
- try {
2295
- this.pty = this.lib.spawn(cmd, args2, {
2296
- name: "xterm-256color",
2297
- cols: 220,
2298
- rows: 50,
2299
- cwd,
2300
- env: {
2301
- ...process.env,
2302
- TERM: "xterm-256color",
2303
- FORCE_COLOR: "1"
2304
- },
2305
- useConpty: true,
2306
- conptyInheritCursor: false
2307
- });
2308
- } catch (err) {
2309
- const msg = err instanceof Error ? err.message : String(err);
2310
- console.error(
2311
- `
2312
- \u2717 Failed to launch Claude Code via ConPTY: ${msg}
2313
- Make sure claude is installed: npm install -g @anthropic-ai/claude-code
2314
- `
2315
- );
2316
- this.opts.onExit(1);
2317
- return;
2318
- }
2294
+ this.pty = this.lib.spawn(cmd, args2, {
2295
+ name: "xterm-256color",
2296
+ cols: 220,
2297
+ rows: 50,
2298
+ cwd,
2299
+ env: {
2300
+ ...process.env,
2301
+ TERM: "xterm-256color",
2302
+ FORCE_COLOR: "1"
2303
+ },
2304
+ useConpty: true,
2305
+ conptyInheritCursor: false
2306
+ });
2319
2307
  this.dataSub = this.pty.onData((data) => {
2320
2308
  process.stdout.write(data);
2321
2309
  this.opts.onData(data);
@@ -4362,27 +4350,18 @@ async function ensureClaudeInstalled() {
4362
4350
  var ClaudeService = class {
4363
4351
  constructor(opts) {
4364
4352
  this.opts = opts;
4365
- const strategyOpts = {
4353
+ this.strategyOpts = {
4366
4354
  onData: opts.onData ?? (() => {
4367
4355
  }),
4368
4356
  onExit: opts.onExit
4369
4357
  };
4370
- if (process.platform === "win32") {
4371
- const conpty = WindowsConPtyStrategy.tryCreate(strategyOpts);
4372
- if (conpty) {
4373
- this.strategy = conpty;
4374
- } else {
4375
- console.error(
4376
- '\n \u26A0 Windows: node-pty unavailable, falling back to pipe mode.\n Claude Code may exit immediately with "no stdin data" / "--print" errors.\n Install build tools or run codeam-cli inside WSL for the best experience.\n'
4377
- );
4378
- this.strategy = new WindowsPtyStrategy(strategyOpts);
4379
- }
4380
- } else {
4381
- this.strategy = new UnixPtyStrategy(strategyOpts);
4382
- }
4383
4358
  }
4384
4359
  opts;
4385
- strategy;
4360
+ // Strategy is selected lazily inside spawn() so we can fall back from
4361
+ // ConPTY → legacy pipe at runtime if the native binding fails to load.
4362
+ // Methods called before spawn() (e.g. early kill/SIGINT) no-op safely.
4363
+ strategy = null;
4364
+ strategyOpts;
4386
4365
  async spawn() {
4387
4366
  if (!findInPath("claude") && !findInPath("claude-code")) {
4388
4367
  const installed = await ensureClaudeInstalled();
@@ -4399,7 +4378,36 @@ var ClaudeService = class {
4399
4378
  }
4400
4379
  }
4401
4380
  const claudeCmd = findInPath("claude") ? "claude" : "claude-code";
4402
- this.strategy.spawn(claudeCmd, this.opts.cwd);
4381
+ if (process.platform === "win32") {
4382
+ const conpty = WindowsConPtyStrategy.tryCreate(this.strategyOpts);
4383
+ if (conpty) {
4384
+ try {
4385
+ conpty.spawn(claudeCmd, this.opts.cwd);
4386
+ this.strategy = conpty;
4387
+ return;
4388
+ } catch (err) {
4389
+ const msg = err instanceof Error ? err.message : String(err);
4390
+ try {
4391
+ conpty.dispose();
4392
+ } catch {
4393
+ }
4394
+ console.error(`
4395
+ \u26A0 ConPTY launch failed (${msg.split("\n")[0]})`);
4396
+ console.error(" Falling back to pipe mode (limited interactivity)\u2026\n");
4397
+ }
4398
+ } else {
4399
+ console.error(
4400
+ '\n \u26A0 Windows: node-pty unavailable, falling back to pipe mode.\n Claude may exit with "no stdin data" / "--print" errors.\n Reinstall the CLI to fetch the prebuilt ConPTY binary, or run inside WSL.\n'
4401
+ );
4402
+ }
4403
+ const pipe = new WindowsPtyStrategy(this.strategyOpts);
4404
+ pipe.spawn(claudeCmd, this.opts.cwd);
4405
+ this.strategy = pipe;
4406
+ return;
4407
+ }
4408
+ const unix = new UnixPtyStrategy(this.strategyOpts);
4409
+ unix.spawn(claudeCmd, this.opts.cwd);
4410
+ this.strategy = unix;
4403
4411
  }
4404
4412
  /**
4405
4413
  * Send a command to Claude's stdin (remote control from mobile).
@@ -4415,8 +4423,10 @@ var ClaudeService = class {
4415
4423
  * a fresh event-loop tick, after React has flushed the text into input state.
4416
4424
  */
4417
4425
  sendCommand(text) {
4418
- this.strategy.write(text);
4419
- setTimeout(() => this.strategy.write("\r"), 50);
4426
+ if (!this.strategy) return;
4427
+ const s = this.strategy;
4428
+ s.write(text);
4429
+ setTimeout(() => s.write("\r"), 50);
4420
4430
  }
4421
4431
  /**
4422
4432
  * Navigate a React Ink selector to the given 0-based target index and confirm.
@@ -4437,40 +4447,43 @@ var ClaudeService = class {
4437
4447
  * ENTER_MS after the last arrow.
4438
4448
  */
4439
4449
  selectOption(targetIndex, fromIndex = 0) {
4450
+ if (!this.strategy) return;
4451
+ const s = this.strategy;
4440
4452
  const delta = targetIndex - fromIndex;
4441
4453
  const steps = Math.abs(delta);
4442
4454
  const arrow = delta >= 0 ? "\x1B[B" : "\x1B[A";
4443
4455
  const ARROW_MS = 80;
4444
4456
  const ENTER_MS = 200;
4445
4457
  if (steps === 0) {
4446
- this.strategy.write("\r");
4458
+ s.write("\r");
4447
4459
  return;
4448
4460
  }
4449
4461
  for (let i = 0; i < steps; i++) {
4450
4462
  setTimeout(() => {
4451
- this.strategy.write(arrow);
4463
+ s.write(arrow);
4452
4464
  }, i * ARROW_MS);
4453
4465
  }
4454
4466
  setTimeout(() => {
4455
- this.strategy.write("\r");
4467
+ s.write("\r");
4456
4468
  }, steps * ARROW_MS + ENTER_MS);
4457
4469
  }
4458
4470
  /** Send Escape key to Claude (cancels interactive prompts). */
4459
4471
  sendEscape() {
4460
- this.strategy.write("\x1B");
4472
+ this.strategy?.write("\x1B");
4461
4473
  }
4462
4474
  /** Send Ctrl+C to Claude. */
4463
4475
  interrupt() {
4464
- this.strategy.write("");
4476
+ this.strategy?.write("");
4465
4477
  }
4466
4478
  kill() {
4467
- this.strategy.kill();
4479
+ this.strategy?.kill();
4468
4480
  }
4469
4481
  /**
4470
4482
  * Kill the current Claude process and relaunch it resuming the given session.
4471
4483
  * Pass auto=true to add --dangerously-skip-permissions (no confirmation prompts).
4472
4484
  */
4473
4485
  restart(sessionId, auto = false) {
4486
+ if (!this.strategy) return;
4474
4487
  const claudeCmd = findInPath("claude") ? "claude" : "claude-code";
4475
4488
  this.strategy.kill();
4476
4489
  const args2 = ["--resume", sessionId];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeam-cli",
3
- "version": "2.4.29",
3
+ "version": "2.4.30",
4
4
  "description": "Remote control Claude Code (and other AI coding agents) from your mobile phone. Pair your device, send prompts, stream responses in real-time, and approve commands — from anywhere.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -75,7 +75,7 @@
75
75
  "zod": "^4.3.6"
76
76
  },
77
77
  "optionalDependencies": {
78
- "node-pty": "^1.0.0"
78
+ "node-pty": "^1.1.0"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@codeagent/shared": "*",