aiterm-mcp 0.70.31 → 0.70.33

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,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.70.33] - 2026-11-12
11
+
12
+ - `agent_launch` with `fork_from` works on a closed main seat (ADR 0140). Closing a seat used to delete its launch record, so a fork of a Bot whose seat BellTeam had idle-closed was refused with `FORK_SOURCE_UNAVAILABLE` ("no managed seat of this harness") although the conversation was saved. Closing a Claude Code or Codex seat now leaves `<seat>.fork-source.json` in Aiterm's state (0600: kind, cwd, last conversation ID, Claude root or Codex rollout). The fork reads it and never wakes the main. The file is replaced at the next close of that name and removed after 30 days. A seat closed before this version has no such file. If the saved conversation is gone, the refusal is still `FORK_SOURCE_UNAVAILABLE`.
13
+ - A local or `remote` `agent_launch` refusal now carries `_meta["aiterm/error_code"]` (for example `FORK_SOURCE_UNAVAILABLE`, `FORK_INVALID`, `READONLY_UNENFORCEABLE`), as terminal launches already did. The text is unchanged.
14
+
15
+ ## [0.70.32] - 2026-11-12
16
+
17
+ - `agent_goal` on a Claude Code seat on Windows no longer fails with `native_goal_status_input_unconfirmed` right after pasting `/goal`. On Windows, Claude draws the slash-command menu (whose first row also starts with `❯`) under the composer's bottom rule, and Aiterm took that menu row for the composer. The composer is now the lowest `❯` row framed by a rule above and below. Measured on fox with Claude Code 2.1.322.
18
+
10
19
  ## [0.70.31] - 2026-11-12
11
20
 
12
21
  - `agent_goal` on a Claude Code seat running on macOS or Windows no longer answers `goal_native_session_unavailable` every time. The goal check binds to Claude's own `sessions/<pid>.json`, and Aiterm could compute that record's process birth only on Linux. Measured on 2.1.322: macOS writes `procStart` as `LC_ALL=C TZ=UTC ps -o lstart=` with `pidDomain` `darwin`; Windows writes the process creation FILETIME with `pidDomain` `win32:<lower-case hostname>`. Aiterm now computes both. The exact birth is read once per goal operation, because every check already re-proves the same process. Windows has no terminal foreground group, so for Claude the pane's single harness process is the input owner there; the macOS and Linux terminal checks are unchanged.
@@ -3333,7 +3342,9 @@ prototype (preserved under `prototype/python/` as the porting source and referen
3333
3342
  `ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
3334
3343
  provenance.
3335
3344
 
3336
- [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.31...HEAD
3345
+ [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.33...HEAD
3346
+ [0.70.33]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.32...v0.70.33
3347
+ [0.70.32]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.31...v0.70.32
3337
3348
  [0.70.31]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.30...v0.70.31
3338
3349
  [0.70.30]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.29...v0.70.30
3339
3350
  [0.70.29]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.28...v0.70.29
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.31** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
218
+ **状態:** 開発継続中 · 現行公開版 **v0.70.33** · 動作対象は 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.31** · 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.33** · 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/core.js CHANGED
@@ -357,12 +357,56 @@ export function windowsLaunchTyped(name, launchId, full) {
357
357
  writeText0600(file, full);
358
358
  return windowsLaunchIndirection(file);
359
359
  }
360
+ const FORK_SOURCE_DAYS = 30; // Claude's own transcript retention default (cleanupPeriodDays)
361
+ function forkSourcePath(dir, name) { return path.join(dir, `${name}.fork-source.json`); }
362
+ /** ADR 0140: a closed main's last conversation, so a fork never needs the main woken. Never a resume or send authority. */
363
+ function saveForkSource(dir, name) {
364
+ const meta = tryLoadAgentMetadata(name);
365
+ if (!meta || (meta.kind !== "claude" && meta.kind !== "codex") || !meta.cwd)
366
+ return;
367
+ let rollout = null;
368
+ try {
369
+ rollout = meta.kind === "codex" ? codexRootTranscript(meta) : null;
370
+ }
371
+ catch {
372
+ rollout = null;
373
+ }
374
+ const vendor = meta.kind === "codex" ? (rollout ? codexRolloutSessionId(meta, rollout) : null) : meta.vendor_session_id;
375
+ if (!vendor || (meta.kind === "claude" && !meta.claude_home))
376
+ return;
377
+ const source = { kind: meta.kind, cwd: meta.cwd, vendor_session_id: vendor,
378
+ ...(meta.kind === "claude" ? { claude_home: meta.claude_home } : { rollout: rollout }) };
379
+ writeText0600(forkSourcePath(dir, name), JSON.stringify(source));
380
+ const stale = Date.now() - FORK_SOURCE_DAYS * 86_400_000;
381
+ for (const f of fs.readdirSync(dir))
382
+ if (f.endsWith(".fork-source.json"))
383
+ try {
384
+ if (fs.statSync(path.join(dir, f)).mtimeMs < stale)
385
+ fs.unlinkSync(path.join(dir, f));
386
+ }
387
+ catch { /* another close removed it */ }
388
+ }
389
+ function readForkSource(name) {
390
+ const dir = existingAgentsDir();
391
+ try {
392
+ const v = dir ? JSON.parse(fs.readFileSync(forkSourcePath(dir, name), "utf8")) : null;
393
+ return v && (v.kind === "claude" || v.kind === "codex") && typeof v.cwd === "string" && typeof v.vendor_session_id === "string"
394
+ && (v.kind === "claude" ? typeof v.claude_home === "string" : typeof v.rollout === "string") ? v : null;
395
+ }
396
+ catch {
397
+ return null;
398
+ }
399
+ }
360
400
  function cleanupAgentState(name) {
361
401
  assertSessionName(name);
362
402
  agentMetadataNegativeCache.delete(name);
363
403
  const dir = existingAgentsDir();
364
404
  if (!dir)
365
405
  return;
406
+ try {
407
+ saveForkSource(dir, name);
408
+ }
409
+ catch { /* best-effort like the cleanup below: a missing copy only refuses a later fork */ }
366
410
  const prefix = `${name}.`;
367
411
  try {
368
412
  for (const f of fs.readdirSync(dir)) {
@@ -8233,21 +8277,26 @@ export function resolveForkSource(kind, from, opts, probe = probeWriteBan) {
8233
8277
  throw new AitermError(`FORK_INVALID: session_name ${opts.session_name} already names a seat`, 2);
8234
8278
  assertSessionName(from.session_id);
8235
8279
  const unavailable = (why) => new AitermError(`FORK_SOURCE_UNAVAILABLE: ${from.session_id}: ${why}`, 2);
8236
- const main = tryLoadAgentMetadata(from.session_id);
8280
+ const live = tryLoadAgentMetadata(from.session_id);
8281
+ // A closed main is read from the copy its close left; it is not woken (ADR 0140).
8282
+ const main = live ?? readForkSource(from.session_id);
8237
8283
  if (!main || main.kind !== kind || !main.cwd)
8238
- throw unavailable("no managed seat of this harness");
8284
+ throw unavailable("no managed seat of this harness and no saved conversation from its close");
8239
8285
  // Codex binds its conversation lazily and may switch it (/new): read the current one without writing the main's record.
8240
8286
  let rollout = null;
8241
- try {
8242
- rollout = main.kind === "codex" ? codexRootTranscript(main) : null;
8243
- }
8244
- catch {
8245
- rollout = null;
8246
- }
8247
- const mainVendorId = main.kind === "codex" ? (rollout ? codexRolloutSessionId(main, rollout) : null) : main.vendor_session_id;
8287
+ if (live)
8288
+ try {
8289
+ rollout = live.kind === "codex" ? codexRootTranscript(live) : null;
8290
+ }
8291
+ catch {
8292
+ rollout = null;
8293
+ }
8294
+ else
8295
+ rollout = main.rollout ?? null;
8296
+ const mainVendorId = !live ? main.vendor_session_id : live.kind === "codex" ? (rollout ? codexRolloutSessionId(live, rollout) : null) : live.vendor_session_id;
8248
8297
  if (!mainVendorId || (main.kind === "claude" ? !main.claude_home
8249
- || !fs.existsSync(path.join(main.claude_home, "projects", claudeProjectSlug(main.cwd), `${mainVendorId}.jsonl`)) : !rollout))
8250
- throw unavailable("the saved conversation file does not exist yet");
8298
+ || !fs.existsSync(path.join(main.claude_home, "projects", claudeProjectSlug(main.cwd), `${mainVendorId}.jsonl`)) : !rollout || !fs.existsSync(rollout)))
8299
+ throw unavailable(live ? "the saved conversation file does not exist yet" : "the closed seat's saved conversation file no longer exists");
8251
8300
  if (opts.cwd != null && (!fs.existsSync(opts.cwd) || fs.realpathSync(opts.cwd) !== fs.realpathSync(main.cwd)))
8252
8301
  throw new AitermError("FORK_INVALID: a fork runs in its main seat's cwd; omit cwd", 2);
8253
8302
  // The main's cwd is the project folder the Owner forbade writing (ADR 0140).
@@ -107,13 +107,16 @@ import { AgentGoalNotIssuedError } from "../agent-goal.js";
107
107
  function plain(screen) { return screen.replace(/\x1b\[[0-?]*[ -/]*[@-~]/gu, ""); }
108
108
  export function claudeGoalComposer(screen) {
109
109
  const lines = plain(screen).split("\n");
110
- let at = lines.length - 1;
111
- while (at >= 0 && !/^\s*❯/u.test(lines[at]))
112
- at--;
113
110
  const rule = /^\s*─{8,}\s*$/u;
114
- if (at < 1 || !rule.test(lines[at - 1]))
115
- return null;
116
- const end = lines.findIndex((line, i) => i > at && rule.test(line));
111
+ // The composer is the lowest ❯ row between two rules; Windows draws the slash-command menu (also ❯) below the bottom rule.
112
+ let at = lines.length - 1, end = -1;
113
+ for (; at >= 1; at--) {
114
+ if (!/^\s*❯/u.test(lines[at]) || !rule.test(lines[at - 1]))
115
+ continue;
116
+ end = lines.findIndex((line, i) => i > at && rule.test(line));
117
+ if (end >= 0)
118
+ break;
119
+ }
117
120
  if (end < 0)
118
121
  return null;
119
122
  const first = /^\s*❯[ \u00a0]?(.*)$/u.exec(lines[at]);
package/dist/index.js CHANGED
@@ -1473,7 +1473,7 @@ export function createAitermServer(options = {}) {
1473
1473
  },
1474
1474
  };
1475
1475
  }
1476
- return fail(e);
1476
+ return withErrorCode(fail(e));
1477
1477
  }
1478
1478
  }
1479
1479
  function registerAgentTool(toolName, kind, desc) {
@@ -1618,10 +1618,10 @@ export function createAitermServer(options = {}) {
1618
1618
  if (!remote)
1619
1619
  return launchAgent(kindForHarness(harness), args, extra);
1620
1620
  try {
1621
- return await launchRemoteAgent(acceptRemote(remote), harness, args, extra);
1621
+ return withErrorCode(await launchRemoteAgent(acceptRemote(remote), harness, args, extra));
1622
1622
  }
1623
1623
  catch (e) {
1624
- return fail(e);
1624
+ return withErrorCode(fail(e));
1625
1625
  }
1626
1626
  });
1627
1627
  registerAgentTool("claude_agent", "claude", "【旧互換alias。新規連携は agent_launch(harness=claude-code)】Claude Codeの対話エージェントTUIを永続端末に起動する。`claude -p`ではなく、" +
package/docs/DESIGN.md CHANGED
@@ -581,7 +581,7 @@ Claude's authorization-request code=true exception is vendor-owned and requires
581
581
 
582
582
  Claude clear uses the same host provenance and original binding comparison as Codex, with no delegated token or replacement worker. The harness owns one native command submission and composer readiness; the manager owns single-attempt mutation, fresh canonical dialog plus matching clear event, and unknown outcomes. The existing turn interruption path is not called by clear. Global stop continues reporting unsupported native Claude pause separately from the one existing stop-key receipt.
583
583
 
584
- Claude objective changes reuse the native /goal setter after checking the current goal and trusted host origin. They do not emulate Codex pause/resume or numeric accounting. Representation checks bound the objective to a completely visible composer/dialog and reject reserved clear and ambiguous whitespace before submission. The shared native cell decoder preserves dim/inverse styling, letting each harness distinguish its own placeholders; Claude input interpretation and native state remain harness-owned. Claude's native ghost text (queued-input hint, startup example, post-turn prompt suggestion) is one composer row whose visible cells are all dim or inverse with at least one dim; that row is empty whatever its text. Typed text of the same words is not dim and stays a draft, so emptiness is never decided by text.
584
+ Claude objective changes reuse the native /goal setter after checking the current goal and trusted host origin. They do not emulate Codex pause/resume or numeric accounting. Representation checks bound the objective to a completely visible composer/dialog and reject reserved clear and ambiguous whitespace before submission. The shared native cell decoder preserves dim/inverse styling, letting each harness distinguish its own placeholders; Claude input interpretation and native state remain harness-owned. Claude's native ghost text (queued-input hint, startup example, post-turn prompt suggestion) is one composer row whose visible cells are all dim or inverse with at least one dim; that row is empty whatever its text. Typed text of the same words is not dim and stays a draft, so emptiness is never decided by text. The composer is the lowest ❯ row framed by a rule above and a rule below; a ❯ row outside that frame (the Windows slash-command menu drawn under the bottom rule) is never the composer.
585
585
 
586
586
 
587
587
  Native Claude goal input also verifies the official per-PID current-session registration, including native session ID, process birth ticks and PID namespace before each input boundary. A switched conversation is refused before goal input; ownership loss after input remains unknown. No conversation is switched back automatically. The registration birth format is measured per OS (Claude Code 2.1.322): Linux boot ticks and PID namespace; macOS `LC_ALL=C TZ=UTC ps -o lstart=` with domain `darwin`; Windows creation FILETIME with domain `win32:<lower-case hostname>`. Other OSes remain unavailable. The exact birth is read once per goal operation; each check re-proves the same pid, birth and argv through resolve(). Windows has no tty foreground group, so for Claude the pane's single harness process proven by resolve() is the input owner and the tty/termios check is skipped.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiterm-mcp",
3
- "version": "0.70.31",
3
+ "version": "0.70.33",
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": [