aiterm-mcp 0.70.2 → 0.70.3

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,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.70.3] - 2026-11-10
11
+
12
+ - A terminal seat's BellTeam MCP forward now goes to the container port named in the launch's own seat MCP URLs (`http://127.0.0.1:<D>/api/seat-mcp...`), stored in the terminal binding as `seat_ingress_port`; the forward keeper builds `-R 127.0.0.1:P:127.0.0.1:<D>` from the binding whichever Aiterm process holds it. Before, the keeper read `BELLTEAM_REMOTE_SEAT_PORT` from its own environment with default 4182, so a keeper started by a process without that variable forwarded the seats to BellTeam's admin port (401). The variable and the default are gone. Seat URLs that are not `http`, not `127.0.0.1`, or name different ports refuse the launch with `SEAT_FORWARD_UNAVAILABLE` (`not_started`) before any session. A binding written before this release has no `seat_ingress_port` and builds no forward until its next seat launch writes it, so seats launched earlier lose BellTeam MCP until relaunched. A launch with a different port clears the old forward port and the keeper replaces its ssh. Server side only (the terminal needs no update). Older Aiterm ignores the new binding field.
13
+ - Every active Aiterm process now runs the 60 s forward check, so when the process holding a terminal's forward exits, another one takes it over within a minute. Before, only processes that saw terminal seats when they initialized ran it, and a forward could stay down until another Aiterm started.
14
+
10
15
  ## [0.70.2] - 2026-11-10
11
16
 
12
17
  - A managed Claude or Codex launch (fresh or resumed) that fails after its terminal session was created, while Aiterm still sets it up (the process birth identity cannot be read, the session environment cannot be registered, the `.log` or offset file cannot be written, or the output pipe fails), now closes that session before returning the error. Before, the plain named session stayed, and every later launch of the same name was refused with "session '<name>' は既に存在します" until someone closed it by hand. Only the session this launch created is closed: creation marks it with a one-time token (first as the window name, then as the session option `@aiterm_create_token`), and the close is conditional on the native identity and that token, so a session of the same name that replaced it, and its files, are kept. The original error text is kept; `creation_rollback_unconfirmed` is appended only when the close fails while the session is still there. Failures after the setup (startup screens, the initial prompt, a lost transport) keep their existing behavior, and plain `pty_open` is unchanged. The session is created by the terminal's Aiterm, so a remote terminal needs this release; updating only the server side does not change it (docs/architecture/lifecycle-state-ownership.md).
@@ -3167,7 +3172,8 @@ prototype (preserved under `prototype/python/` as the porting source and referen
3167
3172
  `ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
3168
3173
  provenance.
3169
3174
 
3170
- [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.2...HEAD
3175
+ [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.3...HEAD
3176
+ [0.70.3]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.2...v0.70.3
3171
3177
  [0.70.2]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.1...v0.70.2
3172
3178
  [0.70.1]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.0...v0.70.1
3173
3179
  [0.70.0]: https://github.com/kitepon/aiterm-mcp/compare/v0.69.0...v0.70.0
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.2** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
218
+ **状態:** 開発継続中 · 現行公開版 **v0.70.3** · 動作対象は 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.2** · 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.3** · 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
 
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { remoteInputDescription, remoteInputSchema, terminalArgumentDescription, terminalArgumentSchema } from "./remote-contract.js";
3
- import { boundTerminalTarget, bindTerminalSession, ensureSeatForward, extractMcpHeaders, hasSeatMcpUrl, maintainSeatForwards, REMOTE_MINIMUM_VERSION, rewriteSeatMcpConfig, terminalRemoteTarget, unbindTerminalSession, versionAtLeast } from "./remote-terminal.js";
3
+ import { boundTerminalTarget, bindTerminalSession, ensureSeatForward, extractMcpHeaders, maintainSeatForwards, REMOTE_MINIMUM_VERSION, seatIngressPort, rewriteSeatMcpConfig, terminalRemoteTarget, unbindTerminalSession, versionAtLeast } from "./remote-terminal.js";
4
4
  import { launchEnvValue } from "./private-env.js";
5
5
  import { AuthResponseError, authUiSchema, authBindingSchema, authResponseSchema } from "./agent-auth-ui.js";
6
6
  import { configurationRequestSchema, configurationToolOutputSchema, applyConfigurationRequest, reconcileConfigurationRequest } from "./configure-request.js";
@@ -1262,8 +1262,9 @@ export function createAitermServer(options = {}) {
1262
1262
  const extracted = extractMcpHeaders(mcpConfig);
1263
1263
  Object.assign(privateEnv, extracted.env);
1264
1264
  mcpConfig = extracted.config;
1265
- if (hasSeatMcpUrl(mcpConfig))
1266
- mcpConfig = rewriteSeatMcpConfig(mcpConfig, await ensureSeatForward(target.trusted_ref));
1265
+ const ingress = seatIngressPort(mcpConfig);
1266
+ if (ingress)
1267
+ mcpConfig = rewriteSeatMcpConfig(mcpConfig, await ensureSeatForward(target.trusted_ref, ingress));
1267
1268
  }
1268
1269
  const envVars = [...new Set([...(args.env_vars ?? []), ...Object.keys(privateEnv)])];
1269
1270
  const result = await launchRemoteAgent(target, harness, { ...args, ...(envVars.length ? { env_vars: envVars } : {}), ...(mcpConfig ? { mcp_config: mcpConfig } : {}) }, extra, privateEnv);
@@ -56,4 +56,4 @@ export const terminalArgumentDescription = "Run this seat on another computer (a
56
56
  "CREDENTIAL_REQUIRED / CREDENTIAL_NOT_LOADED = this terminal's key comes from a credential handle that the registry must load first; never paste a key anywhere. " +
57
57
  "AUTH_FAILED = the terminal refused the key. UNREACHABLE = the terminal is offline; try later. CONNECTION_REFUSED = the terminal refused the SSH connection (SSH may be off there); try later. " +
58
58
  "REMOTE_AITERM_TOO_OLD = update Aiterm on the terminal. CWD_UNAVAILABLE = the folder does not exist there; do not pick another folder. " +
59
- "SEAT_FORWARD_UNAVAILABLE = the seat's MCP route back to this computer is not ready; launch again later. TERMINAL_HARNESS_UNSUPPORTED = use harness claude-code.";
59
+ "SEAT_FORWARD_UNAVAILABLE = the seat's MCP route back to this computer is not ready (launch again later), or the seat MCP URLs are not http://127.0.0.1:<one port>/api/seat-mcp. TERMINAL_HARNESS_UNSUPPORTED = use harness claude-code.";
@@ -182,12 +182,9 @@ export function classifySshFailure(stderr) {
182
182
  return { code: "UNREACHABLE", message: "the terminal cannot be reached" };
183
183
  return { code: "CONNECTION_FAILED", message: "the SSH connection failed" };
184
184
  }
185
- /** -R spec for the seats' BellTeam MCP (remote-terminal.md R12). P=0 lets the terminal's sshd pick the port. */
186
- export function seatForwardSpec(terminalPort, env = process.env) {
187
- const port = Number(env.BELLTEAM_REMOTE_SEAT_PORT ?? 4182);
188
- if (!Number.isInteger(port) || port < 1 || port > 65535)
189
- throw new RemoteTerminalError("SEAT_FORWARD_UNAVAILABLE", "BELLTEAM_REMOTE_SEAT_PORT is not a port");
190
- return `127.0.0.1:${terminalPort}:127.0.0.1:${port}`;
185
+ /** -R spec for the seats' BellTeam MCP (remote-terminal.md R12). P=0 lets the terminal's sshd pick the port; D comes from the binding. */
186
+ export function seatForwardSpec(terminalPort, ingressPort) {
187
+ return `127.0.0.1:${terminalPort}:127.0.0.1:${ingressPort}`;
191
188
  }
192
189
  /** ssh stderr -> the allocated terminal port, "refused", or null while unknown. */
193
190
  export function parseSeatForward(stderr) {
@@ -631,15 +628,28 @@ export function boundTerminalTarget(session) {
631
628
  return ref ? trustedTarget(binding(ref)) : null;
632
629
  }
633
630
  const SEAT_PATH = /^\/api\/seat-mcp(\/|$)/;
634
- export function hasSeatMcpUrl(config) {
635
- return Object.values((config.mcpServers ?? {})).some(server => {
631
+ /** The one container port D of the seat URLs (R12), or null without seat URLs. */
632
+ export function seatIngressPort(config) {
633
+ const ports = new Set();
634
+ for (const server of Object.values((config.mcpServers ?? {}))) {
635
+ let url;
636
636
  try {
637
- return typeof server?.url === "string" && SEAT_PATH.test(new URL(server.url).pathname);
637
+ if (typeof server?.url !== "string")
638
+ continue;
639
+ url = new URL(server.url);
638
640
  }
639
641
  catch {
640
- return false;
642
+ continue;
641
643
  }
642
- });
644
+ if (!SEAT_PATH.test(url.pathname))
645
+ continue;
646
+ if (url.protocol !== "http:" || url.hostname !== "127.0.0.1")
647
+ throw new RemoteTerminalError("SEAT_FORWARD_UNAVAILABLE", "seat MCP URLs must be http://127.0.0.1:<port>/api/seat-mcp");
648
+ ports.add(Number(url.port || 80));
649
+ }
650
+ if (ports.size > 1)
651
+ throw new RemoteTerminalError("SEAT_FORWARD_UNAVAILABLE", "seat MCP URLs name different ports");
652
+ return ports.size ? [...ports][0] : null;
643
653
  }
644
654
  /** Header values leave the config file: each becomes ${AITERM_MCP_HEADER_n}, its value goes to the private env line. */
645
655
  export function extractMcpHeaders(config) {
@@ -716,11 +726,19 @@ function releaseLock(ref) {
716
726
  function forwardNeeded(ref) {
717
727
  return (keepers.get(ref)?.launchUntil ?? 0) > Date.now() || Object.values(readSeats()).includes(ref);
718
728
  }
729
+ function storedIngress(ref) {
730
+ try {
731
+ return binding(ref).seat_ingress_port;
732
+ }
733
+ catch {
734
+ return undefined;
735
+ }
736
+ }
719
737
  function keep(ref) {
720
- const keeper = keepers.get(ref) ?? { child: null, refusals: 0, timer: null, launchUntil: 0 };
738
+ const keeper = keepers.get(ref) ?? { child: null, ingress: 0, refusals: 0, timer: null, launchUntil: 0 };
721
739
  keepers.set(ref, keeper);
722
740
  if (keeper.child) {
723
- if (!forwardNeeded(ref))
741
+ if (!forwardNeeded(ref) || storedIngress(ref) !== keeper.ingress)
724
742
  keeper.child.kill();
725
743
  return;
726
744
  }
@@ -742,11 +760,17 @@ function keep(ref) {
742
760
  releaseLock(ref);
743
761
  return;
744
762
  }
763
+ // No D in the binding (written before 0.70.3): no forward until a launch writes D; never a default port.
764
+ if (!b.seat_ingress_port) {
765
+ releaseLock(ref);
766
+ return;
767
+ }
745
768
  const requested = b.seat_forward_port ?? 0;
769
+ keeper.ingress = b.seat_ingress_port;
746
770
  let args;
747
771
  try {
748
772
  // The remote command ends when our stdin closes, so the forward dies with this process even on SIGKILL.
749
- args = trustedSshArguments(ref, "cat >/dev/null", null, ["-o", "ExitOnForwardFailure=yes", "-R", seatForwardSpec(requested)]);
773
+ args = trustedSshArguments(ref, "cat >/dev/null", null, ["-o", "ExitOnForwardFailure=yes", "-R", seatForwardSpec(requested, b.seat_ingress_port)]);
750
774
  }
751
775
  catch {
752
776
  releaseLock(ref);
@@ -775,19 +799,22 @@ function keep(ref) {
775
799
  keeper.timer.unref();
776
800
  });
777
801
  }
778
- /** Every 60 s: keep (or take over) the forwards this process's state root needs. */
802
+ /** Every 60 s in every active process: keep (or take over from an exited holder) the forwards this state root needs. */
779
803
  export function maintainSeatForwards() {
780
804
  const refs = new Set([...Object.values(readSeats()), ...keepers.keys(), ...loadedCredentialRefs()]);
781
805
  for (const ref of refs)
782
806
  keep(ref);
783
- if (refs.size && !maintainTimer) {
807
+ if (!maintainTimer) {
784
808
  maintainTimer = setInterval(maintainSeatForwards, 60_000);
785
809
  maintainTimer.unref();
786
810
  }
787
811
  }
788
- /** The terminal-local port for seat URLs; starts the keeper if no process holds it yet. */
789
- export async function ensureSeatForward(ref, timeoutMs = 30_000) {
790
- const keeper = keepers.get(ref) ?? { child: null, refusals: 0, timer: null, launchUntil: 0 };
812
+ /** The terminal-local port for seat URLs reaching container port `ingress`; starts the keeper if no process holds it yet. */
813
+ export async function ensureSeatForward(ref, ingress, timeoutMs = 30_000) {
814
+ // 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.
815
+ if (binding(ref).seat_ingress_port !== ingress)
816
+ writeBinding(ref, { seat_ingress_port: ingress, seat_forward_port: undefined });
817
+ const keeper = keepers.get(ref) ?? { child: null, ingress: 0, refusals: 0, timer: null, launchUntil: 0 };
791
818
  keeper.launchUntil = Date.now() + LAUNCH_GRACE_MS;
792
819
  keepers.set(ref, keeper);
793
820
  maintainSeatForwards();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiterm-mcp",
3
- "version": "0.70.2",
3
+ "version": "0.70.3",
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": [