aiterm-mcp 0.70.2 → 0.70.4

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,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.70.4] - 2026-11-10
11
+
12
+ - `agent_configure` on Claude Code reads both `/model` picker layouts. Claude Code 2.1.322 shows, per session, either versioned rows (`Opus 5.5`) or alias rows with the model the alias resolves to in the second column (`Opus ✔ Opus 5.5 · …`). Rows now match by their first column or, outside the `Default` row and only when unique, by that resolved model, so `opus`, `sonnet`, `haiku` and `claude-opus-5-5` work on alias pickers. Before, every model change on an alias picker was refused with `CLAUDE_MODEL_NOT_IN_PICKER`. An alias still matches the native catalog's model, not the picker's alias row: where the session's `Fable` row resolves to Fable 5.1 and the catalog names Fable 5.2, `fable` and `claude-fable-5-2` are refused rather than selecting the older model. The refusal now lists alias rows with their resolved model, e.g. `Fable (Fable 5.1)`. A missing Claude CLI during this lookup now reports `CLAUDE_MODEL_CATALOG_UNAVAILABLE` instead of `CLAUDE_MODEL_NOT_IN_PICKER`.
13
+ - A Claude picker refusal carries `_meta["aiterm/configure_error"]` = `{code, relaunch}` on tracked and untracked calls. `relaunch: true` (`CLAUDE_MODEL_NOT_IN_PICKER` for a model in the native catalog, `CLAUDE_MODEL_NOT_SELECTABLE`, `CLAUDE_MODEL_SESSION_ONLY_UNAVAILABLE`) means this live session cannot take the model but a launch or resume with it can.
14
+ - A tracked request refused by the Claude picker before its selecting key (`s`, or the switch confirmation's Enter), with the picker and confirmation read closed after Esc, is stored with `native_effect: "selection_excluded"` and reconciles to `later_effect: "excluded"`. Before, the `/model` command alone left it `unconfirmed`. A refusal whose picker stays open, or any refusal after `s`, stays `unconfirmed`. Older Aiterm cannot parse the new value and reads such a receipt as `unavailable`/`unconfirmed`. The change is where the Claude seat runs: the BellTeam body for container seats, the terminal for terminal seats.
15
+
16
+ ## [0.70.3] - 2026-11-10
17
+
18
+ - 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.
19
+ - 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.
20
+
10
21
  ## [0.70.2] - 2026-11-10
11
22
 
12
23
  - 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 +3178,9 @@ prototype (preserved under `prototype/python/` as the porting source and referen
3167
3178
  `ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
3168
3179
  provenance.
3169
3180
 
3170
- [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.2...HEAD
3181
+ [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.4...HEAD
3182
+ [0.70.4]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.3...v0.70.4
3183
+ [0.70.3]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.2...v0.70.3
3171
3184
  [0.70.2]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.1...v0.70.2
3172
3185
  [0.70.1]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.0...v0.70.1
3173
3186
  [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.4** · 動作対象は 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.4** · 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
 
@@ -23,7 +23,7 @@ const resultSchema = z.object({ schema: z.literal("aiterm.agent-configure-result
23
23
  harness: z.enum(["claude-code", "codex-cli", "grok-cli", "cursor-cli", "antigravity-cli"]),
24
24
  model: z.string().nullable(), reasoning_effort: z.string().nullable(), fast: z.boolean().nullable() }).strict();
25
25
  const recordSchema = z.object({ schema: z.literal("aiterm.configuration-request.v1"), binding: configurationBindingSchema,
26
- requested: settingsSchema, terminal_at: z.iso.datetime().nullable(), native_effect: z.enum(["not_issued", "possible"]),
26
+ requested: settingsSchema, terminal_at: z.iso.datetime().nullable(), native_effect: z.enum(["not_issued", "possible", "selection_excluded"]),
27
27
  outcome: z.enum(["applied", "not_applied", "outcome_unknown"]), result: resultSchema.nullable(),
28
28
  }).strict().refine(value => configurationRequestDigest(value.requested) === value.binding.digest
29
29
  && (value.result === null || value.result.session_id === value.binding.session_id)
@@ -78,7 +78,7 @@ function receipt(binding, record, missing = "unavailable") {
78
78
  return { schema: "aiterm.agent-configure-request-result.v1", binding,
79
79
  request_state: record ? record.terminal_at === null ? "pending_or_unknown" : "terminal" : missing,
80
80
  outcome: record?.outcome ?? "outcome_unknown",
81
- later_effect: record?.terminal_at !== null && record?.native_effect === "not_issued" ? "excluded" : "unconfirmed",
81
+ later_effect: record && record.terminal_at !== null && record.native_effect !== "possible" ? "excluded" : "unconfirmed",
82
82
  terminal_at: record?.terminal_at ?? null, result: record?.result ?? null,
83
83
  current: { availability: "unsupported" }, observed_at: new Date().toISOString() };
84
84
  }
@@ -135,6 +135,9 @@ export async function applyConfigurationRequest(input, settings, apply) {
135
135
  failure = error instanceof Error ? error : new Error("configuration failed");
136
136
  const detail = failure.configurationFailure;
137
137
  record.outcome = detail?.outcome === "not_applied" ? "not_applied" : "outcome_unknown";
138
+ // UI input was issued, but the adapter read the picker closed before any selecting key (configure-reconcile.md).
139
+ if (record.outcome === "not_applied" && record.native_effect === "possible" && failure.configureRefusal?.selection_excluded)
140
+ record.native_effect = "selection_excluded";
138
141
  }
139
142
  record.terminal_at = new Date().toISOString();
140
143
  try {
package/dist/errors.js CHANGED
@@ -4,6 +4,8 @@ export class AitermError extends Error {
4
4
  code;
5
5
  sendFailure;
6
6
  configurationFailure;
7
+ /** Claudeの選ぶ画面での拒否。selection_excludedは、sを打つ前に断り、閉じた画面を読んだ時だけtrue。 */
8
+ configureRefusal;
7
9
  constructor(message, code = 1) {
8
10
  super(message);
9
11
  this.code = code;
@@ -1,7 +1,7 @@
1
1
  import { AitermError } from "../errors.js";
2
2
  import { sleep } from "../agent-shared.js";
3
3
  import { resolveAgentBin } from "../agent-resolver.js";
4
- import { claudeModelPicker, claudeModelPickerRow, claudeModelSwitchConfirm, claudeModelSwitchResult, claudePaneObservation, claudeModelChoices } from "./claude.js";
4
+ import { claudeModelPicker, claudeModelPickerRow, claudePickerRowByName, claudeModelDisplayName, claudeModelSwitchConfirm, claudeModelSwitchResult, claudePaneObservation, claudeModelChoices } from "./claude.js";
5
5
  const CLAUDE_MODEL_PICKER_TIMEOUT_MS = 8_000;
6
6
  const CLAUDE_MODEL_PICKER_KEY_TIMEOUT_MS = 1_500;
7
7
  const CLAUDE_MODEL_SWITCH_TIMEOUT_MS = 15_000;
@@ -20,16 +20,19 @@ export async function configureClaudeForSessionOnly(name, meta, model, effort, b
20
20
  return null;
21
21
  };
22
22
  // Escは、選ぶ画面か確かめの画面が出ている間だけ打つ(入力欄へ戻った後のEscは、ほかの操作を取り消してしまう)。
23
- const refuse = async (code, reason) => {
24
- for (let i = 0; i < 3; i++) {
25
- const now = screen();
26
- if (!claudeModelPicker(now) && !claudeModelSwitchConfirm(now))
27
- break;
23
+ // 設定を決めるのはsと確かめのEnterだけ。sの前に断り、閉じた画面を読めた時だけ、設定は選ばれていないと記録できる。
24
+ const refuse = async (code, reason, relaunch = false) => {
25
+ const closed = () => { const now = screen(); return !claudeModelPicker(now) && !claudeModelSwitchConfirm(now); };
26
+ let shut = closed();
27
+ for (let i = 0; i < 3 && !shut; i++) {
28
28
  ui.key("Escape");
29
29
  await sleep(300);
30
+ shut = closed();
30
31
  }
31
- throw new AitermError(`${code} vendor=claude session=${name}\n${reason}。` +
32
+ const error = new AitermError(`${code} vendor=claude session=${name}\n${reason}。` +
32
33
  (selectionIssued ? "設定が変わった可能性があります。再送しないでください。" : "modelとreasoning_effortは変えていません。"), 2);
34
+ error.configureRefusal = { code, relaunch, selection_excluded: !selectionIssued && shut };
35
+ throw error;
33
36
  };
34
37
  const picker = () => claudeModelPicker(screen());
35
38
  const cursorOf = (p) => p?.rows.find((row) => row.cursor) ?? null;
@@ -54,12 +57,15 @@ export async function configureClaudeForSessionOnly(name, meta, model, effort, b
54
57
  await sleep(500);
55
58
  state = claudePaneObservation(screen());
56
59
  }
57
- throw new AitermError(`CLAUDE_MODEL_PICKER_NOT_SHOWN vendor=claude session=${name} state=${state.state}/${state.reason}\n` +
60
+ const error = new AitermError(`CLAUDE_MODEL_PICKER_NOT_SHOWN vendor=claude session=${name} state=${state.state}/${state.reason}\n` +
58
61
  "Claude Codeの /model の選ぶ画面を読めません(Claude Codeの版で画面の形が変わった見込み)。modelとreasoning_effortは変えていません。", 2);
62
+ // 読めない画面が何を受けたかは分からないので、選ばれていないとは記録しない。
63
+ error.configureRefusal = { code: "CLAUDE_MODEL_PICKER_NOT_SHOWN", relaunch: false, selection_excluded: false };
64
+ throw error;
59
65
  }
60
66
  if (!now.session_only) {
61
67
  return refuse("CLAUDE_MODEL_SESSION_ONLY_UNAVAILABLE", "このClaude Codeの /model の選ぶ画面に、この会話だけで使う選び方(s to use this session only)がありません。" +
62
- "端末の既定を書き換える選び方は使いません");
68
+ "端末の既定を書き換える選び方は使いません", true);
63
69
  }
64
70
  let targetIndex = null;
65
71
  if (model) {
@@ -83,11 +89,13 @@ export async function configureClaudeForSessionOnly(name, meta, model, effort, b
83
89
  break;
84
90
  seen.add(at);
85
91
  }
86
- let target = claudeModelPickerRow([...known.values()], model);
92
+ const rows = [...known.values()].sort((a, b) => a.index - b.index);
93
+ let target = claudeModelPickerRow(rows, model);
94
+ let offered = false; // native catalogにある(起こし直せば使える見込み)
87
95
  if (!target || /^[a-z]+$/iu.test(model)) {
88
96
  const bin = meta.agent_executable ?? resolveAgentBin("claude");
89
97
  if (!bin)
90
- return refuse("CLAUDE_MODEL_NOT_IN_PICKER", "Claude CodeのCLIが見つかりません");
98
+ return refuse("CLAUDE_MODEL_CATALOG_UNAVAILABLE", "Claude CodeのCLIが見つかりません");
91
99
  let catalog;
92
100
  try {
93
101
  catalog = await claudeModelChoices(bin, meta.cwd ?? process.cwd());
@@ -96,14 +104,16 @@ export async function configureClaudeForSessionOnly(name, meta, model, effort, b
96
104
  return refuse("CLAUDE_MODEL_CATALOG_UNAVAILABLE", error instanceof Error ? error.message : String(error));
97
105
  }
98
106
  const native = catalog.models.find(item => item.id.toLowerCase() === model.toLowerCase());
99
- // The native alias can resolve to an older model; picker order is not alias authority.
107
+ // The native alias can resolve to an older model; picker order and the picker's alias rows are not alias authority.
100
108
  const label = native?.display_name ?? native?.id ?? model;
101
- const matching = [...known.values()].filter(row => row.label.toLowerCase() === label.toLowerCase());
102
- target = matching.length === 1 ? matching[0] : null;
109
+ const shown = claudeModelDisplayName(model);
110
+ offered = !!native || catalog.models.some(item => item.display_name?.toLowerCase() === shown);
111
+ target = claudePickerRowByName(rows, label);
103
112
  }
104
113
  if (!target) {
105
- const names = [...known.values()].sort((a, b) => a.index - b.index).map((row) => row.label).join(", ");
106
- return refuse("CLAUDE_MODEL_NOT_IN_PICKER", `Claude Codeの /model の選ぶ画面に ${model} がありません(選べる機種: ${names})`);
114
+ const names = rows.map((row) => row.resolved && row.resolved !== row.label && !/^default\b/iu.test(row.label)
115
+ ? `${row.label} (${row.resolved})` : row.label).join(", ");
116
+ return refuse("CLAUDE_MODEL_NOT_IN_PICKER", `Claude Codeの /model の選ぶ画面に ${model} がありません(選べる機種: ${names})`, offered);
107
117
  }
108
118
  for (let i = 0; i < 80 && at !== target.index; i++) {
109
119
  const before = at;
@@ -117,7 +127,7 @@ export async function configureClaudeForSessionOnly(name, meta, model, effort, b
117
127
  return refuse("CLAUDE_MODEL_PICKER_UNREADABLE", `選ぶ画面で ${target.label} の行へ動けません`);
118
128
  // 起きた後にClaude Codeが更新された席では、「Update Claude Code to use this model」の行が出る。その行にはEnterもsも無い。
119
129
  if (!now.session_only) {
120
- return refuse("CLAUDE_MODEL_NOT_SELECTABLE", `${target.label} は、この席のClaude Codeでは選べません(選ぶ画面のその行に、選ぶためのキーが出ていません。席のClaude Codeが古い見込み)`);
130
+ return refuse("CLAUDE_MODEL_NOT_SELECTABLE", `${target.label} は、この席のClaude Codeでは選べません(選ぶ画面のその行に、選ぶためのキーが出ていません。席のClaude Codeが古い見込み)`, true);
121
131
  }
122
132
  targetIndex = target.index;
123
133
  }
@@ -570,12 +570,13 @@ export function claudeModelPicker(screen) {
570
570
  for (const line of body.slice(0, foot)) {
571
571
  const row = /^\s*([❯↓↑]\s+)?(\d+)\.\s+(.*?)\s*$/u.exec(line);
572
572
  if (row) {
573
- const name = row[3].split(/\s{2,}/u)[0];
573
+ const [name, second = ""] = row[3].split(/\s{2,}/u);
574
574
  rows.push({
575
575
  index: Number(row[2]),
576
576
  label: name.replace(/\s*✔$/u, ""),
577
577
  cursor: row[1]?.includes("❯") === true,
578
578
  current: /✔$/u.test(name),
579
+ resolved: /^([A-Z][\w.-]*(?: [A-Z][\w.-]*)* \d+(?:\.\d+)?)(?:\s+·\s.*)?$/u.exec(second)?.[1] ?? null,
579
580
  });
580
581
  continue;
581
582
  }
@@ -594,13 +595,26 @@ export function claudeModelPicker(screen) {
594
595
  export function claudeModelPickerRow(rows, model) {
595
596
  const want = model.trim().toLowerCase();
596
597
  const sorted = [...rows].sort((a, b) => a.index - b.index);
597
- const id = /^claude-([a-z]+)-(\d+)(?:-(\d{1,2}))?(?:-\d{8})?$/u.exec(want);
598
- const name = id ? `${id[1]} ${id[2]}${id[3] ? `.${id[3]}` : ""}` : want;
599
- return sorted.find((row) => row.label.toLowerCase() === name)
598
+ return claudePickerRowByName(sorted, claudeModelDisplayName(want))
600
599
  ?? (want === "default" ? sorted.find((row) => /^default\b/iu.test(row.label)) : undefined)
601
600
  ?? (/^[a-z]+$/u.test(want) ? sorted.find((row) => row.label.toLowerCase().startsWith(`${want} `) && /^\S+ \d/u.test(row.label)) : undefined)
602
601
  ?? null;
603
602
  }
603
+ /** `claude-fable-5-2` → `fable 5.2`。IDの形でなければ小文字にしただけの物。 */
604
+ export function claudeModelDisplayName(model) {
605
+ const want = model.trim().toLowerCase();
606
+ const id = /^claude-([a-z]+)-(\d+)(?:-(\d{1,2}))?(?:-\d{8})?$/u.exec(want);
607
+ return id ? `${id[1]} ${id[2]}${id[3] ? `.${id[3]}` : ""}` : want;
608
+ }
609
+ /** 名前が1列目と同じ行。無ければ、2列目の機種名が同じ行(Default行を除き、1行だけの時)。 */
610
+ export function claudePickerRowByName(rows, name) {
611
+ const want = name.trim().toLowerCase();
612
+ const byLabel = rows.find((row) => row.label.toLowerCase() === want);
613
+ if (byLabel)
614
+ return byLabel;
615
+ const byResolved = rows.filter((row) => !/^default\b/iu.test(row.label) && row.resolved?.toLowerCase() === want);
616
+ return byResolved.length === 1 ? byResolved[0] : null;
617
+ }
604
618
  // 会話が今のmodelでcacheされている時だけ、sの後に出る確かめ(2.1.293・2.1.296)。
605
619
  // Switch model?
606
620
  // Your next response will be slower and use more tokens
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";
@@ -225,6 +225,11 @@ export function createAitermServer(options = {}) {
225
225
  child_turn_id: z.string().nullable(), queued_submission_id: z.string().nullable(), error_code: z.string().nullable(),
226
226
  child_failure: failureObservationSchema.optional(), child_error_kind: z.string().nullable().optional(), child_vendor_session_id: z.string().nullable().optional(),
227
227
  });
228
+ /** configure-reconcile.md: the Claude picker's refusal code, and whether a launch with the model could apply it. */
229
+ function configureErrorMeta(e) {
230
+ const refusal = e instanceof AitermError ? e.configureRefusal : undefined;
231
+ return refusal ? { _meta: { "aiterm/configure_error": { code: refusal.code, relaunch: refusal.relaunch } } } : {};
232
+ }
228
233
  function ok(s) {
229
234
  return { content: [{ type: "text", text: s }] };
230
235
  }
@@ -245,7 +250,7 @@ export function createAitermServer(options = {}) {
245
250
  if (configurationFailure)
246
251
  return {
247
252
  content: [{ type: "text", text: "aiterm: " + msg }], isError: true,
248
- structuredContent: { ...configurationFailure },
253
+ structuredContent: { ...configurationFailure }, ...configureErrorMeta(e),
249
254
  };
250
255
  if (e instanceof AgentAuthenticationPreflightError)
251
256
  return {
@@ -1102,7 +1107,7 @@ export function createAitermServer(options = {}) {
1102
1107
  if (request) {
1103
1108
  const tracked = await applyConfigurationRequest({ ...request, session_id }, { model, reasoning_effort, fast }, () => core.configureAgent(session_id, { model, reasoning_effort, fast }, request.launch_id));
1104
1109
  return { content: [{ type: "text", text: tracked.error?.message ?? JSON.stringify(tracked.receipt) }],
1105
- structuredContent: { ...tracked.receipt }, ...(tracked.error ? { isError: true } : {}) };
1110
+ structuredContent: { ...tracked.receipt }, ...(tracked.error ? { isError: true, ...configureErrorMeta(tracked.error) } : {}) };
1106
1111
  }
1107
1112
  const result = await core.configureAgent(session_id, { model, reasoning_effort, fast });
1108
1113
  return {
@@ -1262,8 +1267,9 @@ export function createAitermServer(options = {}) {
1262
1267
  const extracted = extractMcpHeaders(mcpConfig);
1263
1268
  Object.assign(privateEnv, extracted.env);
1264
1269
  mcpConfig = extracted.config;
1265
- if (hasSeatMcpUrl(mcpConfig))
1266
- mcpConfig = rewriteSeatMcpConfig(mcpConfig, await ensureSeatForward(target.trusted_ref));
1270
+ const ingress = seatIngressPort(mcpConfig);
1271
+ if (ingress)
1272
+ mcpConfig = rewriteSeatMcpConfig(mcpConfig, await ensureSeatForward(target.trusted_ref, ingress));
1267
1273
  }
1268
1274
  const envVars = [...new Set([...(args.env_vars ?? []), ...Object.keys(privateEnv)])];
1269
1275
  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();
@@ -44,11 +44,13 @@ Model, effort and fast are forbidden in reconcile. The reader does not create a
44
44
  | `outcome` | Historical `applied`, `not_applied`, or `outcome_unknown`; not a current settings snapshot |
45
45
  | `terminal_at` | Saved handler/finally completion time, otherwise null |
46
46
  | `result` | Original successful configure result, otherwise null; its model/effort retain their existing requested-value semantics |
47
- | `later_effect` | `excluded` only for saved terminal requests with no native mutation issued; otherwise `unconfirmed` |
47
+ | `later_effect` | `excluded` for saved terminal requests with no native mutation issued, or refused by the Claude model picker before its selection key with the picker read closed afterwards; otherwise `unconfirmed` |
48
48
  | `current` | `{ "availability": "unsupported" }`; no UI preview is performed |
49
49
  | `observed_at` | Time this receipt was read |
50
50
 
51
- Any native mutation, including menu preparation, keeps `later_effect=unconfirmed` even if the handler succeeds or the visible model matches. A native send acknowledgment does not prove input consumption. Pending records remain uncertain after process exit or restart. Missing/corrupt records are not proof of non-admission: an original packet could still arrive. Receipt loss, elapsed time, a completed goal/turn or a new current launch must not authorize replay or uncertainty removal. The local terminal guard prevents new Aiterm continuations; it cannot retract already issued native input. Removing product state also removes duplicate protection and must never be presented as reconciliation.
51
+ Any other native mutation, including menu preparation, keeps `later_effect=unconfirmed` even if the handler succeeds or the visible model matches. The one exception is a Claude `/model` picker refusal (`not_applied`): only `s` and the switch confirmation's Enter select a setting, Aiterm sends neither before refusing, and it reads the picker and confirmation closed after its Esc. The receipt then stores `native_effect: "selection_excluded"`; older Aiterm cannot parse that value and reads the receipt as `unavailable`. A refusal whose picker stays open keeps `possible`.
52
+
53
+ A Claude picker refusal also carries `_meta["aiterm/configure_error"]` = `{"code": "<CODE>", "relaunch": <bool>}` on both tracked and untracked calls. `relaunch: true` means the model is in the native catalog but this live session cannot take it (`CLAUDE_MODEL_NOT_IN_PICKER`, `CLAUDE_MODEL_NOT_SELECTABLE`, `CLAUDE_MODEL_SESSION_ONLY_UNAVAILABLE`): a launch or resume with that model can apply it. A session's alias picker may resolve an alias to an older model than the catalog (Fable → Fable 5.1 while the catalog names Fable 5.2); Aiterm matches the catalog's model, so such a request is refused with `relaunch: true` instead of selecting the older row. A native send acknowledgment does not prove input consumption. Pending records remain uncertain after process exit or restart. Missing/corrupt records are not proof of non-admission: an original packet could still arrive. Receipt loss, elapsed time, a completed goal/turn or a new current launch must not authorize replay or uncertainty removal. The local terminal guard prevents new Aiterm continuations; it cannot retract already issued native input. Removing product state also removes duplicate protection and must never be presented as reconciliation.
52
54
 
53
55
  For a consumer to consider its own fence, the local uncertainty/version and original binding must still match, and native `request_state=terminal` plus `later_effect=excluded` must both be present. Keep the outcome and desired/current differences separate. This product receipt does not itself delete consumer flags or authorize a message, restart, stop or reconfiguration. `later_effect=unconfirmed` is not a request to retry.
54
56
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiterm-mcp",
3
- "version": "0.70.2",
3
+ "version": "0.70.4",
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": [