aiterm-mcp 0.70.16 → 0.70.18

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/CHANGELOG.md CHANGED
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.70.18] - 2026-11-11
11
+
12
+ - A seat relaunched on a terminal right after its last seat closed (for example `restart_session`) no longer gets a seat MCP port with no forward behind it (`ECONNREFUSED` at Claude start, and Claude Code never retries a failed MCP). The forward keeper stopped once no seat was bound, but the binding kept its port, and the next launch received that port at once. A launch in another Aiterm process was also invisible to the keeper. Now the keeper's remote command prints a mark once the forward's listener is up; a launch receives the port only when a live keeper reported that mark for it. A launch in any process keeps the forward needed until its seat is bound, and a stopped keeper hands over its lock at once, so the relaunch's process starts a new forward without the 15 s restart delay.
13
+
14
+ ## [0.70.17] - 2026-11-11
15
+
16
+ - On a POSIX terminal where npm linked only `aiterm-mcp` onto the login PATH, Aiterm's other programs on the terminal (`aiterm-remote-terminal` for `path_status` / `make_dir` / `list_dirs` and transcript reads) now run from the same package, as `aiterm-wait` already did. Before, the folder picker failed there with `/bin/sh: aiterm-remote-terminal: not found`.
17
+ - An Aiterm program missing on the terminal (exit 127) now ends as `REMOTE_AITERM_UNAVAILABLE` with an action (install Aiterm with its programs on the login PATH, or provision the terminal), instead of `COMMAND_FAILED`.
18
+
19
+ - After a restart of the controlling host (for example a container restart, which starts a new pid namespace), a terminal's seat MCP forward is started again. The forward lock kept only the old keeper's pid. The new host reused that number at once, here for a thread of a long-lived process, and `kill(pid, 0)` succeeds on a Linux thread id too, so the lock read as held and no process started the forward. Every seat on that terminal lost its BellTeam MCP tools. The lock now also records the boot time and, on Linux, the process start time; a pid that differs in either, or a thread id in an older lock, is not the owner. macOS and Windows have no thread ids in the pid space; a lock from an earlier boot is now also ignored there.
20
+ - A terminal launch no longer receives the stored seat forward port when no keeper is running. Before, the port kept from the previous host was returned at once and the seat started with an MCP URL that reached nothing. Now the launch waits for the new keeper's ssh, or ends with `SEAT_FORWARD_UNAVAILABLE`.
21
+
10
22
  ## [0.70.16] - 2026-11-11
11
23
 
12
24
  - `pty_list` no longer starts an idle-clock checker process for every hibernated, closed or dead seat on every call. A seat without a live session retires its clock at once, so each list re-spawned a checker for it (about 30 per call on a BellTeam host with 50 saved seats and 18 live). The sweep now covers only seats with a live terminal session, and confirms all clock owners with one process read instead of one per seat. On that host this load kept the serving process busy 95 % of the time, with stretches up to 7 s, so a terminal relay's answer often arrived after the 4 s budget and the terminal's seats came back `unread`.
@@ -3261,7 +3273,9 @@ prototype (preserved under `prototype/python/` as the porting source and referen
3261
3273
  `ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
3262
3274
  provenance.
3263
3275
 
3264
- [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.16...HEAD
3276
+ [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.18...HEAD
3277
+ [0.70.18]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.17...v0.70.18
3278
+ [0.70.17]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.16...v0.70.17
3265
3279
  [0.70.16]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.15...v0.70.16
3266
3280
  [0.70.15]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.14...v0.70.15
3267
3281
  [0.70.14]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.13...v0.70.14
package/README.ja.md CHANGED
@@ -215,7 +215,7 @@ runtime-error store は canonical dotagents config の `collection.enabled: true
215
215
  場合だけ収集し、既定OFF、network送信は行いません。tag起点CIのnpm provenance(OIDC Trusted
216
216
  Publishing)で公開し、GitHub Release が Official MCP Registry を再登録します。
217
217
 
218
- **状態:** 開発継続中 · 現行公開版 **v0.70.16** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
218
+ **状態:** 開発継続中 · 現行公開版 **v0.70.18** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
219
219
 
220
220
  ### 更新と巻き戻し
221
221
 
package/README.md CHANGED
@@ -227,7 +227,7 @@ collection is off by default and performs no network I/O. It ships via
227
227
  tag-triggered CI with npm provenance (OIDC Trusted Publishing); the GitHub
228
228
  Release re-registers the Official MCP Registry entry.
229
229
 
230
- **Status:** actively maintained · current public release **v0.70.16** · runs on Linux · WSL2 · macOS · native Windows (tmux on POSIX, the tmux-CLI-compatible [psmux](https://github.com/psmux/psmux) on native Windows — no WSL required) · MIT · see the [CHANGELOG](CHANGELOG.md).
230
+ **Status:** actively maintained · current public release **v0.70.18** · runs on Linux · WSL2 · macOS · native Windows (tmux on POSIX, the tmux-CLI-compatible [psmux](https://github.com/psmux/psmux) on native Windows — no WSL required) · MIT · see the [CHANGELOG](CHANGELOG.md).
231
231
 
232
232
  ### Update and rollback
233
233
 
@@ -10,7 +10,7 @@ import { createRequire } from "node:module";
10
10
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
11
11
  import { ReadBuffer, serializeMessage } from "@modelcontextprotocol/sdk/shared/stdio.js";
12
12
  import { ensureStateRoot, writeJson0600 } from "./agent-shared.js";
13
- import { WAIT_RESOLVE, powershellForShell, remotePlatform, remoteShell, terminalCommand, terminalProgram } from "./remote.js";
13
+ import { powershellForShell, remotePlatform, remoteShell, terminalCommand, terminalProgram } from "./remote.js";
14
14
  import { PRIVATE_ENV_SCHEMA } from "./private-env.js";
15
15
  import { checkRemotePath } from "./remote-path.js";
16
16
  const pkg = createRequire(import.meta.url)("../package.json");
@@ -167,6 +167,16 @@ export function confirmHostKey(ref, fingerprint) {
167
167
  return bindingStatus(ref);
168
168
  }
169
169
  // ---- connection ----
170
+ const AITERM_MISSING_ACTION = "install Aiterm on the terminal with its programs on the login PATH (npm install -g aiterm-mcp), or provision the terminal";
171
+ /** 255 = ssh failed; 127 = an Aiterm program is missing on the terminal (terminalProgram exits so on every shell). */
172
+ function failedRun(result) {
173
+ if (result.code === 127)
174
+ return new RemoteTerminalError("REMOTE_AITERM_UNAVAILABLE", "an Aiterm program is missing on the terminal (Aiterm is incomplete there)", AITERM_MISSING_ACTION);
175
+ if (result.code !== 255)
176
+ return null;
177
+ const f = classifySshFailure(result.stderr);
178
+ return new RemoteTerminalError(f.code, f.message, f.action);
179
+ }
170
180
  export function classifySshFailure(stderr) {
171
181
  if (/REMOTE HOST IDENTIFICATION HAS CHANGED|Host key for .* has changed/i.test(stderr))
172
182
  return { code: "HOST_KEY_MISMATCH", message: "the terminal presented a different host key", action: "confirm the new host key" };
@@ -176,7 +186,7 @@ export function classifySshFailure(stderr) {
176
186
  return { code: "AUTH_FAILED", message: "the terminal refused the key" };
177
187
  // POSIX, our own Windows guard (any language), and the English cmd / PowerShell wording when it names an Aiterm program.
178
188
  if (/aiterm-[\w-]+: (command )?not found|aiterm-[\w-]+: No such file|aiterm-[\w-]+['"]? is not recognized as (an internal or external command|(the|a) name of a cmdlet)/i.test(stderr))
179
- return { code: "REMOTE_AITERM_UNAVAILABLE", message: "Aiterm is not installed on the terminal" };
189
+ return { code: "REMOTE_AITERM_UNAVAILABLE", message: "Aiterm is not installed on the terminal", action: AITERM_MISSING_ACTION };
180
190
  if (/Connection refused/i.test(stderr))
181
191
  return { code: "CONNECTION_REFUSED", message: "the terminal refused the SSH connection" };
182
192
  if (/timed out|No route to host|Network is unreachable|Could not resolve|Connection closed|Connection reset/i.test(stderr))
@@ -314,8 +324,10 @@ const cliAuthScript = (c) => ({
314
324
  windows: `$p = (Get-Command ${c.bin} -ErrorAction SilentlyContinue).Source; if (-not $p) { $p = ${c.winPath}; if (-not (Test-Path -LiteralPath $p)) { exit 127 } }; & $p ${c.auth.join(" ")}`,
315
325
  });
316
326
  /** The remote command the forward keeper holds: it ends exactly when ssh's stdin closes. */
327
+ export const FORWARD_READY_MARK = "AITERM_FORWARD_READY";
317
328
  export function keeperCommand(shell) {
318
- return shell === "posix" ? "cat >/dev/null" : powershellForShell(shell, "[Console]::In.ReadToEnd() | Out-Null");
329
+ return shell === "posix" ? `echo ${FORWARD_READY_MARK}; exec cat >/dev/null`
330
+ : powershellForShell(shell, `[Console]::Out.WriteLine('${FORWARD_READY_MARK}'); [Console]::In.ReadToEnd() | Out-Null`);
319
331
  }
320
332
  const WAIT_FLAGS = new Set(["--session", "--operation", "--timeout", "--cursor", "--steer", "--launch", "--input"]);
321
333
  const WAIT_VALUE = /^[A-Za-z0-9_.:-]{1,128}$/;
@@ -505,17 +517,17 @@ export class RemoteTerminalConnection extends EventEmitter {
505
517
  return parsed;
506
518
  if (parsed?.code)
507
519
  throw new RemoteTerminalError(parsed.code, parsed.message ?? "transcript read failed");
508
- if (result.code === 255) {
509
- const f = classifySshFailure(result.stderr);
510
- throw new RemoteTerminalError(f.code, f.message, f.action);
520
+ {
521
+ const f = failedRun(result);
522
+ if (f)
523
+ throw f;
511
524
  }
512
525
  throw new RemoteTerminalError("COMMAND_FAILED", "the transcript reader failed on the terminal");
513
526
  }
514
527
  /** Run the terminal's aiterm-wait with the flags of a receipt's wait_process; its one-line JSON comes back unchanged. */
515
528
  async wait(waitProcess, signal) {
516
529
  const flags = waitArguments(waitProcess?.args);
517
- // Same resolution as remoteWaitCommand: npm may link only aiterm-mcp.
518
- const result = await this.exec({ posix: `${WAIT_RESOLVE}; exec "$w" ${flags.join(" ")}`, windows: terminalProgram(["aiterm-wait", ...flags]).windows }, 90_000_000, signal);
530
+ const result = await this.exec(terminalProgram(["aiterm-wait", ...flags]), 90_000_000, signal);
519
531
  if (signal?.aborted)
520
532
  throw new RemoteTerminalError("WAIT_CANCELLED", "the wait was cancelled");
521
533
  const line = result.stdout.trim().split("\n").pop() ?? "";
@@ -523,11 +535,7 @@ export class RemoteTerminalConnection extends EventEmitter {
523
535
  return JSON.parse(line);
524
536
  }
525
537
  catch {
526
- if (result.code === 255) {
527
- const f = classifySshFailure(result.stderr);
528
- throw new RemoteTerminalError(f.code, f.message, f.action);
529
- }
530
- throw new RemoteTerminalError("COMMAND_FAILED", "aiterm-wait returned no receipt");
538
+ throw failedRun(result) ?? new RemoteTerminalError("COMMAND_FAILED", "aiterm-wait returned no receipt");
531
539
  }
532
540
  }
533
541
  async command(op, targetPath, harness) {
@@ -596,9 +604,10 @@ export class RemoteTerminalConnection extends EventEmitter {
596
604
  throw new RemoteTerminalError("REMOTE_AITERM_TOO_OLD", `the terminal runs Aiterm ${this.remoteVersion}; ${minimum} or later is required (provision the terminal)`);
597
605
  const sub = op === "path_status" ? "path-status" : "make-dir";
598
606
  const result = await this.exec(terminalProgram(["aiterm-remote-terminal", sub, "--path-base64", Buffer.from(targetPath, "utf8").toString("base64")]), 60_000);
599
- if (result.code === 255) {
600
- const f = classifySshFailure(result.stderr);
601
- throw new RemoteTerminalError(f.code, f.message, f.action);
607
+ {
608
+ const f = failedRun(result);
609
+ if (f)
610
+ throw f;
602
611
  }
603
612
  let parsed = null;
604
613
  try {
@@ -620,9 +629,10 @@ export class RemoteTerminalConnection extends EventEmitter {
620
629
  throw new RemoteTerminalError("REMOTE_AITERM_TOO_OLD", `the terminal runs Aiterm ${this.remoteVersion}; ${minimum} or later is required (update or provision the terminal)`);
621
630
  const flag = targetPath === undefined ? [] : ["--path-base64", Buffer.from(targetPath, "utf8").toString("base64")];
622
631
  const result = await this.exec(terminalProgram(["aiterm-remote-terminal", "list-dirs", ...flag]), 60_000);
623
- if (result.code === 255) {
624
- const f = classifySshFailure(result.stderr);
625
- throw new RemoteTerminalError(f.code, f.message, f.action);
632
+ {
633
+ const f = failedRun(result);
634
+ if (f)
635
+ throw f;
626
636
  }
627
637
  let parsed = null;
628
638
  try {
@@ -807,46 +817,107 @@ function writeBinding(ref, change) {
807
817
  writeJson0600(storePath(), { schema: "aiterm.remote-bindings.v1", bindings });
808
818
  }
809
819
  function lockFile(ref) { return path.join(ensureStateRoot(), `terminal-forward-${ref}.lock`); }
820
+ function lockOwner(ref) {
821
+ try {
822
+ return JSON.parse(fs.readFileSync(lockFile(ref), "utf8"));
823
+ }
824
+ catch {
825
+ return null; /* absent or unreadable: no owner */
826
+ }
827
+ }
828
+ const bootTime = () => Math.round(Date.now() / 1000 - os.uptime());
829
+ /** Linux: the start time (field 22 of /proc/<pid>/stat, counted after the comm's last ") "); null elsewhere. */
830
+ function procStart(pid) {
831
+ try {
832
+ return fs.readFileSync(`/proc/${pid}/stat`, "utf8").split(") ").pop().split(" ")[19] ?? null;
833
+ }
834
+ catch {
835
+ return null;
836
+ }
837
+ }
838
+ /** T3: the recorded owner is this same process still running, not a later process or a thread given the same number. */
839
+ function ownerAlive(owner) {
840
+ const pid = Number(owner.pid);
841
+ if (!(pid > 0))
842
+ return false;
843
+ try {
844
+ process.kill(pid, 0);
845
+ }
846
+ catch {
847
+ return false;
848
+ }
849
+ if (typeof owner.boot === "number" && Math.abs(owner.boot - bootTime()) > 60)
850
+ return false; // from an earlier boot
851
+ if (process.platform !== "linux")
852
+ return true; // shortcut: a pid reused within one boot looks alive until that process exits
853
+ // A container restart reuses pids at once, and kill(pid, 0) also succeeds on a thread id (0.70.16 stayed down).
854
+ if (typeof owner.start === "string")
855
+ return procStart(pid) === owner.start;
856
+ try {
857
+ return /^Tgid:\s*(\d+)$/m.exec(fs.readFileSync(`/proc/${pid}/status`, "utf8"))?.[1] === String(pid);
858
+ }
859
+ catch {
860
+ return true;
861
+ }
862
+ }
863
+ const lockIdentity = () => ({ pid: process.pid, boot: bootTime(), start: procStart(process.pid) });
864
+ /** T3: only the owner rewrites its lock (rename, so no reader sees half a file): `ready` = the P its running ssh -R holds. */
865
+ function markReady(ref, ready) {
866
+ if (Number(lockOwner(ref)?.pid) !== process.pid)
867
+ return;
868
+ const file = lockFile(ref), staged = `${file}.${process.pid}`;
869
+ try {
870
+ fs.writeFileSync(staged, JSON.stringify(ready ? { ...lockIdentity(), ready } : lockIdentity()), { mode: 0o600 });
871
+ fs.renameSync(staged, file);
872
+ }
873
+ catch {
874
+ fs.rmSync(staged, { force: true });
875
+ }
876
+ }
810
877
  /** T3: true when this process holds the keeper lock for ref (taking it from a dead owner). */
811
878
  function holdLock(ref) {
812
879
  const file = lockFile(ref);
813
880
  for (let attempt = 0; attempt < 2; attempt++) {
814
881
  try {
815
- fs.writeFileSync(file, JSON.stringify({ pid: process.pid }), { flag: "wx", mode: 0o600 });
882
+ fs.writeFileSync(file, JSON.stringify(lockIdentity()), { flag: "wx", mode: 0o600 });
816
883
  return true;
817
884
  }
818
885
  catch (error) {
819
886
  if (error.code !== "EEXIST")
820
887
  return false;
821
- let pid = 0;
822
- try {
823
- pid = Number(JSON.parse(fs.readFileSync(file, "utf8")).pid);
824
- }
825
- catch { /* unreadable: treat as dead */ }
826
- if (pid === process.pid)
888
+ const owner = lockOwner(ref);
889
+ if (Number(owner?.pid) === process.pid)
827
890
  return true;
828
- // shortcut: a reused pid looks alive; the next owner check after that process exits takes over.
829
- try {
830
- if (pid > 0) {
831
- process.kill(pid, 0);
832
- return false;
833
- }
834
- }
835
- catch { /* owner gone */ }
891
+ if (owner && ownerAlive(owner))
892
+ return false;
836
893
  fs.rmSync(file, { force: true });
837
894
  }
838
895
  }
839
896
  return false;
840
897
  }
841
898
  function releaseLock(ref) {
842
- try {
843
- if (Number(JSON.parse(fs.readFileSync(lockFile(ref), "utf8")).pid) === process.pid)
844
- fs.rmSync(lockFile(ref), { force: true });
845
- }
846
- catch { /* none */ }
899
+ if (Number(lockOwner(ref)?.pid) === process.pid)
900
+ fs.rmSync(lockFile(ref), { force: true });
901
+ }
902
+ /** P is usable only when a live owner's running ssh -R has reported it ready (its remote command started after the listener). */
903
+ function forwardReady(ref, port) {
904
+ const owner = lockOwner(ref);
905
+ // shortcut: a keeper of Aiterm 0.70.16 or older (lock without boot) never reports ready; trust it while alive, until it exits.
906
+ if (owner && owner.boot === undefined)
907
+ return ownerAlive(owner);
908
+ if (!owner || owner.ready !== port)
909
+ return false;
910
+ return Number(owner.pid) === process.pid ? Boolean(keepers.get(ref)?.child) : ownerAlive(owner);
847
911
  }
912
+ // T3: a launch in any process keeps the forward needed (the seat is bound only after it), so the owner never stops it meanwhile.
913
+ const launchFile = (ref) => path.join(ensureStateRoot(), `terminal-forward-${ref}.launch`);
848
914
  function forwardNeeded(ref) {
849
- return (keepers.get(ref)?.launchUntil ?? 0) > Date.now() || Object.values(readSeats()).includes(ref);
915
+ let until = 0;
916
+ try {
917
+ until = Number(fs.readFileSync(launchFile(ref), "utf8"));
918
+ }
919
+ catch { /* no launch */ }
920
+ return until > Date.now() || Object.values(readSeats()).includes(ref);
850
921
  }
851
922
  function storedIngress(ref) {
852
923
  try {
@@ -857,7 +928,7 @@ function storedIngress(ref) {
857
928
  }
858
929
  }
859
930
  function keep(ref) {
860
- const keeper = keepers.get(ref) ?? { child: null, ingress: 0, refusals: 0, timer: null, launchUntil: 0 };
931
+ const keeper = keepers.get(ref) ?? { child: null, ingress: 0, refusals: 0, timer: null };
861
932
  keepers.set(ref, keeper);
862
933
  if (keeper.child) {
863
934
  if (!forwardNeeded(ref) || storedIngress(ref) !== keeper.ingress)
@@ -916,9 +987,18 @@ function keep(ref) {
916
987
  releaseLock(ref);
917
988
  return;
918
989
  }
919
- const child = spawn("ssh", args, { env: sshEnvironment(), stdio: ["pipe", "ignore", "pipe"] });
990
+ const child = spawn("ssh", args, { env: sshEnvironment(), stdio: ["pipe", "pipe", "pipe"] });
920
991
  keeper.child = child;
921
- let stderr = "";
992
+ let stderr = "", stdout = "", ready = false;
993
+ // Ready = the remote command printed its mark (sshd binds the -R listener before it runs the session) and P is known.
994
+ const report = () => {
995
+ const forward = parseSeatForward(stderr), port = typeof forward === "number" ? forward : requested;
996
+ if (!ready && port && stdout.includes(FORWARD_READY_MARK)) {
997
+ ready = true;
998
+ markReady(ref, port);
999
+ }
1000
+ };
1001
+ child.stdout.on("data", (chunk) => { stdout = (stdout + chunk.toString("utf8")).slice(-200); report(); });
922
1002
  child.stderr.on("data", (chunk) => {
923
1003
  stderr = (stderr + chunk.toString("utf8")).slice(-4000);
924
1004
  const forward = parseSeatForward(stderr);
@@ -926,16 +1006,22 @@ function keep(ref) {
926
1006
  writeBinding(ref, { seat_forward_port: forward });
927
1007
  keeper.refusals = 0;
928
1008
  }
1009
+ report();
929
1010
  });
930
1011
  child.on("error", () => { });
931
1012
  child.on("close", () => {
932
1013
  keeper.child = null;
1014
+ markReady(ref, null);
933
1015
  if (parseSeatForward(stderr) === "refused" && requested !== 0 && ++keeper.refusals >= FORWARD_REFUSALS_BEFORE_NEW_PORT) {
934
1016
  // The old P stays taken on the terminal: let sshd pick a new one (seats launched with the old P need a relaunch).
935
1017
  writeBinding(ref, { seat_forward_port: undefined });
936
1018
  keeper.refusals = 0;
937
1019
  }
938
- again();
1020
+ // Stopped because no seat needs it: hand the lock over at once, so a launch in another process starts its own.
1021
+ if (forwardNeeded(ref))
1022
+ again();
1023
+ else
1024
+ keep(ref);
939
1025
  });
940
1026
  }, () => { keeper.starting = false; again(); });
941
1027
  }
@@ -965,15 +1051,15 @@ export async function ensureSeatForward(ref, ingress, timeoutMs = 30_000) {
965
1051
  // A new D makes the old P (forwarding to the old D) useless: clear it so the wait below sees only a forward to D.
966
1052
  if (binding(ref).seat_ingress_port !== ingress)
967
1053
  writeBinding(ref, { seat_ingress_port: ingress, seat_forward_port: undefined });
968
- const keeper = keepers.get(ref) ?? { child: null, ingress: 0, refusals: 0, timer: null, launchUntil: 0 };
969
- keeper.launchUntil = Date.now() + LAUNCH_GRACE_MS;
970
- keepers.set(ref, keeper);
1054
+ fs.writeFileSync(launchFile(ref), String(Date.now() + LAUNCH_GRACE_MS), { mode: 0o600 });
971
1055
  maintainSeatForwards();
972
1056
  const deadline = Date.now() + timeoutMs;
973
1057
  for (;;) {
1058
+ // A stored P without a ready forward (after a restart, or a keeper just stopped) reaches nothing: wait for one.
974
1059
  const port = binding(ref).seat_forward_port;
975
- if (port)
1060
+ if (port && forwardReady(ref, port))
976
1061
  return port;
1062
+ keep(ref); // takes over at once when the owner stopped and released the lock
977
1063
  if (Date.now() > deadline)
978
1064
  throw new RemoteTerminalError("SEAT_FORWARD_UNAVAILABLE", "the seat's MCP route back to this computer is not ready; launch again later");
979
1065
  await new Promise(resolve => setTimeout(resolve, 250));
package/dist/remote.js CHANGED
@@ -193,8 +193,11 @@ export const powershellInvoke = (argv) => `& ${argv.map(powershellQuote).join("
193
193
  /** 固定のプログラム呼び出し。windowsのaiterm-*は、無い時に言語によらず読める`command not found`を出す。 */
194
194
  export function terminalProgram(argv) {
195
195
  const [program] = argv;
196
+ const file = program.startsWith("aiterm-") ? pkg.bin[program]?.replace(/^dist\//, "") : undefined;
196
197
  return {
197
- posix: `exec ${argv.join(" ")}`,
198
+ // npm may link only aiterm-mcp onto PATH: then the program runs from the same package; else the shell's exit 127.
199
+ posix: file ? `p=$(command -v ${program}) || p="$(dirname "$(readlink -f "$(command -v aiterm-mcp)")")/${file}"; [ -x "$p" ] || p=${program}; exec "$p" ${argv.slice(1).join(" ")}`.trimEnd()
200
+ : `exec ${argv.join(" ")}`,
198
201
  windows: `${program.startsWith("aiterm-") ? `if (-not (Get-Command ${powershellQuote(program)} -ErrorAction SilentlyContinue)) { [Console]::Error.WriteLine(${powershellQuote(`${program}: command not found`)}); exit 127 }; ` : ""}${powershellInvoke(argv)}`,
199
202
  };
200
203
  }
@@ -264,8 +267,6 @@ export async function callRemoteTool(target, name, args, timeoutMs = 600_000, pr
264
267
  await client.close().catch(() => { });
265
268
  }
266
269
  }
267
- // npmのbinをPATHへ通さず aiterm-mcp だけリンクしている端末がある。見つからなければ同じpackageのCLIを使う。
268
- export const WAIT_RESOLVE = 'w=$(command -v aiterm-wait) || w="$(dirname "$(readlink -f "$(command -v aiterm-mcp)")")/aiterm-wait-cli.js"';
269
270
  const SESSION_RE = /^[A-Za-z0-9_-]{1,64}$/;
270
271
  const OPERATION_RE = /^sha256:[0-9a-f]{64}$/;
271
272
  export function remoteWaitCommand(shell, session, cursor, operationId, timeout, inputId, trusted = false) {
@@ -283,10 +284,10 @@ export function remoteWaitCommand(shell, session, cursor, operationId, timeout,
283
284
  if (inputId !== undefined)
284
285
  parts.push("--input", inputId);
285
286
  if (trusted)
286
- return terminalCommand(shell, { posix: `${WAIT_RESOLVE}; exec "$w" ${parts.join(" ")}`, windows: terminalProgram(["aiterm-wait", ...parts]).windows });
287
+ return terminalCommand(shell, terminalProgram(["aiterm-wait", ...parts]));
287
288
  if (shell !== "posix")
288
289
  return `aiterm-wait ${parts.join(" ")}`;
289
- return posixCommand(`${WAIT_RESOLVE}; exec "$w" ${parts.join(" ")}`);
290
+ return posixCommand(terminalProgram(["aiterm-wait", ...parts]).posix);
290
291
  }
291
292
  /** 親が別processで起動する完了待ち。ssh越しのaiterm-waitで、exit codeは現地のaiterm-waitをそのまま返す。 */
292
293
  export async function remoteWaitProcess(target, session, cursor, inputId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiterm-mcp",
3
- "version": "0.70.16",
3
+ "version": "0.70.18",
4
4
  "mcpName": "io.github.kitepon/aiterm-mcp",
5
5
  "description": "Persistent terminal MCP with one harness-based launcher for Claude Code, Codex CLI, Grok CLI, Cursor Agent CLI, and Antigravity CLI, plus durable PTYs for SSH, containers, and REPLs.",
6
6
  "keywords": [