aiterm-mcp 0.70.64 → 0.70.66

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,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.70.66] - 2026-11-15
11
+
12
+ - A Claude seat on plan mode no longer waits for a person at the ExitPlanMode dialog "Ready to code?" (a141, Kiro's request). Every Claude seat's own settings now carry a `PermissionRequest` hook for `ExitPlanMode` only. The hook answers as option 1 ("Yes, and switch to BYPASS PERMISSIONS"): it allows the call with the call's own input and sets the session mode to `bypassPermissions`, which the seat already ran in. Claude Code 2.1.325 ignores an allow without the input for this tool, so the input is part of the answer. Any other tool, any other dialog (AskUserQuestion included), an unreadable input and a process outside an Aiterm seat get no decision and keep their screen. A seat already running keeps its old settings until it is resumed or relaunched; an Aiterm below 0.70.66 behaves as before (harness-contracts.md "ExitPlanModeの承認").
13
+
14
+ ## [0.70.65] - 2026-11-15
15
+
16
+ - A seat no longer stays unreachable after an idle stop that took effect but whose Aiterm process ended before it wrote `hibernated`. Anchor's seat bot-632c5d04 stayed in `stopping` from 05:11Z on 2026-11-15, so every send, `pty_close {hibernate:true}` and `pty_close` refused it, also across a body restart. Now the next send, dispatch, idle check, hibernate or close checks the stuck record. When the recorded pane process (pid and start identity) is gone and the native session is confirmed absent, Aiterm records it `hibernated`, as the interrupted stop would have, and the operation continues: a send resumes the same conversation, a close closes. A `stopping` record whose pane is still alive is left alone (lifecycle-state-ownership.md).
17
+
10
18
  ## [0.70.64] - 2026-11-15
11
19
 
12
20
  - `agent_configure model: "opusplan"` no longer hangs on a seat whose conversation is cached for its current model (Z27 lab). Claude Code asks "Switch model? … ❯ 1. Yes, switch" after `/model opusplan`; Aiterm now reads that question (with or without a model name) and answers Yes once, as the picker path does. If no result line comes within 20 seconds, Aiterm closes what is open with Escape (at most 3 times) and refuses with `CLAUDE_MODEL_SWITCH_UNCONFIRMED` (with `configureRefusal`), without waiting for the composer. The root's `settings.json` still goes back to its exact prior bytes.
@@ -3506,7 +3514,9 @@ prototype (preserved under `prototype/python/` as the porting source and referen
3506
3514
  `ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
3507
3515
  provenance.
3508
3516
 
3509
- [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.64...HEAD
3517
+ [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.66...HEAD
3518
+ [0.70.66]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.65...v0.70.66
3519
+ [0.70.65]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.64...v0.70.65
3510
3520
  [0.70.64]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.63...v0.70.64
3511
3521
  [0.70.63]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.62...v0.70.63
3512
3522
  [0.70.62]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.61...v0.70.62
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.64** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
218
+ **状態:** 開発継続中 · 現行公開版 **v0.70.66** · 動作対象は 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.64** · 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.66** · 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
 
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env node
2
+ // Claude PermissionRequest hook for ExitPlanMode only (harness-contracts.md "ExitPlanModeの承認").
3
+ // The dialog "Ready to code?" would hold the seat's turn until a person picks 1: this answers it as option 1, the seat's own
4
+ // bypass mode. Anything that does not match exactly prints nothing and exits 0, so Claude Code keeps asking as before.
5
+ const MAX_STDIN_BYTES = 8 * 1024 * 1024;
6
+ const AITERM_ENV = ["AITERM_AGENT_KIND", "AITERM_SESSION_ID", "AITERM_AGENT_SESSION_ID", "AITERM_AGENT_LAUNCH_ID"];
7
+ async function readStdin() {
8
+ const chunks = [];
9
+ let total = 0;
10
+ for await (const chunk of process.stdin) {
11
+ const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));
12
+ total += bytes.length;
13
+ if (total > MAX_STDIN_BYTES)
14
+ return "";
15
+ chunks.push(bytes);
16
+ }
17
+ return Buffer.concat(chunks).toString("utf8");
18
+ }
19
+ export function planApproval(payload, env = process.env) {
20
+ const input = payload;
21
+ // Claude Code 2.1.325 ignores a bare "allow" for ExitPlanMode (a tool that needs the user's own answer): the decision
22
+ // must carry updatedInput, the call's own input unchanged (verified on a real seat, a141).
23
+ if (!input || typeof input !== "object" || input.hook_event_name !== "PermissionRequest" || input.tool_name !== "ExitPlanMode"
24
+ || typeof input.tool_input?.plan !== "string" || !AITERM_ENV.some(name => env[name]))
25
+ return null;
26
+ return { hookSpecificOutput: { hookEventName: "PermissionRequest", decision: { behavior: "allow", updatedInput: input.tool_input,
27
+ updatedPermissions: [{ type: "setMode", mode: "bypassPermissions", destination: "session" }] } } };
28
+ }
29
+ async function main() {
30
+ let payload = null;
31
+ try {
32
+ payload = JSON.parse(await readStdin());
33
+ }
34
+ catch { /* not JSON: no decision */ }
35
+ const decision = planApproval(payload);
36
+ if (decision)
37
+ process.stdout.write(JSON.stringify(decision) + "\n");
38
+ }
39
+ // Run only as the hook entry; importing it (tests) has no effect.
40
+ if (process.argv[1] && /claude-plan-approve-hook\.js$/.test(process.argv[1]))
41
+ await main();
package/dist/core.js CHANGED
@@ -2251,6 +2251,9 @@ const HIBERNATE_BUSY_REASONS = new Set(["turn_running", "turn_end_unconfirmed",
2251
2251
  export async function hibernateAgentSession(name) {
2252
2252
  assertSessionName(name);
2253
2253
  const meta = loadAgentMetadata(name);
2254
+ // An interrupted stop that already took effect: the seat is hibernated, nothing is left to stop.
2255
+ if (settleInterruptedStop(meta))
2256
+ return { schema: "aiterm.pty-close-result.v1", session_id: name, outcome: "hibernated" };
2254
2257
  const result = await checkAgentIdle({ session_id: name, launch_id: meta.launch_id }, undefined, true);
2255
2258
  if (result.outcome === "hibernated")
2256
2259
  return { schema: "aiterm.pty-close-result.v1", session_id: name, outcome: "hibernated" };
@@ -2706,7 +2709,7 @@ function closeSessionInternal(name, observeDependency = true, o = {}) {
2706
2709
  agentLaunchLines.delete(name);
2707
2710
  return `closed ${name}`;
2708
2711
  };
2709
- const meta = tryLoadAgentMetadata(name), lifecycle = meta && readAgentLifecycle(meta);
2712
+ const meta = tryLoadAgentMetadata(name), lifecycle = meta && (settleInterruptedStop(meta) ?? readAgentLifecycle(meta));
2710
2713
  const native = meta && !lifecycle && readAgentResumeNative(meta) ? observeExecutionNativeSessions() : null;
2711
2714
  const absent = native?.state === "known" && !native.sessions.some(row => row.session_id === name);
2712
2715
  if (meta && (lifecycle || absent)) {
@@ -3672,7 +3675,10 @@ async function withAgentSendLock(name, run, untouched = AGENT_SEND_UNSENT, pinRe
3672
3675
  if (current?.launch_id !== launchId && !resumed)
3673
3676
  throw new ExecutionError("EXECUTION_STALE_GENERATION");
3674
3677
  return await agentSendOwner.run(mine, async () => {
3675
- const meta = pinResume ? tryLoadAgentMetadata(name) : null;
3678
+ const held = tryLoadAgentMetadata(name);
3679
+ if (held)
3680
+ settleInterruptedStop(held);
3681
+ const meta = pinResume ? held : null;
3676
3682
  if (meta && !readAgentLifecycle(meta)) {
3677
3683
  const uncertain = () => new AgentResumeError("AGENT_RESUME_UNCONFIRMED", "復帰対象のnativeを確認できません。本文は送信していません。", name, meta.launch_id);
3678
3684
  let failed;
@@ -7350,6 +7356,30 @@ function commitWorkingAgentResume(previous, lifecycle) {
7350
7356
  throw new AgentResumeUnavailableError(name);
7351
7357
  withExecutionPreparation(name, () => writeAgentLifecycle(previous, lifecycle));
7352
7358
  }
7359
+ /**
7360
+ * An idle stop whose effect finished but whose process ended before it wrote hibernated leaves "stopping" behind, and
7361
+ * every send, close and hibernate refused on it (bot-632c5d04, 2026-11-15). When the recorded pane process is gone and
7362
+ * the native is confirmed absent, the stop did take effect: record it as finish() would. A live pane is left alone (a
7363
+ * stop may still be running in another process). Returns the hibernated record when it settled one.
7364
+ */
7365
+ function settleInterruptedStop(meta) {
7366
+ const lifecycle = readAgentLifecycle(meta);
7367
+ if (lifecycle?.state !== "stopping" || lifecycle.socket !== SOCK || readAgentResumeAttempt(meta))
7368
+ return null;
7369
+ const native = observeExecutionNativeSessions();
7370
+ if (native.state !== "known" || native.sessions.some(row => row.session_id === meta.aiterm_session))
7371
+ return null;
7372
+ const pane = lifecycle.pane;
7373
+ if (readRuntimeProcesses().some(row => row.pid === pane.pid && row.started_identity === pane.started_identity))
7374
+ return null;
7375
+ const settled = { ...lifecycle, state: "hibernated", at: new Date().toISOString() };
7376
+ withExecutionPreparation(meta.aiterm_session, () => {
7377
+ if (!isDeepStrictEqual(readAgentLifecycle(meta), lifecycle))
7378
+ throw new AgentResumeUnavailableError(meta.aiterm_session);
7379
+ writeAgentLifecycle(meta, settled);
7380
+ });
7381
+ return settled;
7382
+ }
7353
7383
  /** A current generation with no lifecycle/attempt state whose native is confirmed absent. */
7354
7384
  function vanishedAgentNative(meta) {
7355
7385
  if (agentDormantState(meta) !== null)
@@ -76,6 +76,9 @@ export function agentClaudeDispatchReceiptPath(name, launchId, operationId) {
76
76
  const validated = validateOperationId(operationId);
77
77
  return path.join(agentsDir(), `${name}.${launchId}.${validated.slice("sha256:".length)}.claude-dispatch`);
78
78
  }
79
+ function claudePlanApproveScriptPath() {
80
+ return path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "claude-plan-approve-hook.js");
81
+ }
79
82
  function claudeHookScriptPath() {
80
83
  // この module は dist/harnesses/ に置かれるが、stop hook 実体は dist/ 直下に build される。
81
84
  return path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "claude-stop-hook.js");
@@ -98,6 +101,10 @@ export function createClaudeCorrelationSettings(name, launchId, model, effort) {
98
101
  if (!fs.existsSync(hookScript)) {
99
102
  throw new AitermError(`Claude Stop hook wrapper が見つかりません。npm run build を実行してください: ${hookScript}`, 2);
100
103
  }
104
+ const planScript = claudePlanApproveScriptPath();
105
+ if (!fs.existsSync(planScript)) {
106
+ throw new AitermError(`Claude plan approve hook が見つかりません。npm run build を実行してください: ${planScript}`, 2);
107
+ }
101
108
  const settings = agentManagedClaudeSettingsPath(name, launchId);
102
109
  writeJson0600(settings, {
103
110
  ...(model ? { model } : {}),
@@ -117,6 +124,10 @@ export function createClaudeCorrelationSettings(name, launchId, model, effort) {
117
124
  ],
118
125
  },
119
126
  ],
127
+ // The ExitPlanMode dialog ("Ready to code?") holds a seat's turn for a person; answer it as option 1 (harness-contracts.md).
128
+ PermissionRequest: [
129
+ { matcher: "ExitPlanMode", hooks: [{ type: "command", command: nodeHookCommand(planScript), timeout: 10 }] },
130
+ ],
120
131
  },
121
132
  });
122
133
  return settings;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiterm-mcp",
3
- "version": "0.70.64",
3
+ "version": "0.70.66",
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": [