aiterm-mcp 0.70.63 → 0.70.65

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.65] - 2026-11-15
11
+
12
+ - 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).
13
+
14
+ ## [0.70.64] - 2026-11-15
15
+
16
+ - `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.
17
+
10
18
  ## [0.70.63] - 2026-11-15
11
19
 
12
20
  - Claude seats can use `opusplan` (Opus Plan Mode), a141. `agent_models` for claude-code now lists it on both login paths: the catalog asks `initialize` with `--model opusplan`, and Claude Code 2.1.325 adds that row only while the session runs it. `agent_configure` with `model: "opusplan"` first sends `/model opusplan`, because the picker has no such row until the seat runs it. Claude Code saves that as the user's default; the root's `settings.json` `model` goes back to its value before, the same way as for fast. The picker step then selects the row for this session only, with the requested effort. Launches already passed `--model opusplan` unchanged.
@@ -3502,7 +3510,9 @@ prototype (preserved under `prototype/python/` as the porting source and referen
3502
3510
  `ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
3503
3511
  provenance.
3504
3512
 
3505
- [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.63...HEAD
3513
+ [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.65...HEAD
3514
+ [0.70.65]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.64...v0.70.65
3515
+ [0.70.64]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.63...v0.70.64
3506
3516
  [0.70.63]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.62...v0.70.63
3507
3517
  [0.70.62]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.61...v0.70.62
3508
3518
  [0.70.61]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.60...v0.70.61
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.63** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
218
+ **状態:** 開発継続中 · 現行公開版 **v0.70.65** · 動作対象は 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.63** · 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.65** · 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
@@ -70,7 +70,7 @@ import { readFileOrNull, restoreJsonSetting, withUserConfigLock, restoreUserDefa
70
70
  import { isDeepStrictEqual } from "node:util";
71
71
  import { grokAuthPlan, grokAuthStatus, grokAuthPane, GROK_MODEL_DEFAULTS, realGrokHome, resolveAndValidateGrokAuth, assertGrokModelAvailable, grokModelChoices, grokModelFromFooter, grokFooterModelName, grokModelDefaultsFromBody, restoreGrokModelDefaults, grokEventsTranscript, grokSessionDirectory, latestGrokCompletion, grokTurnSettled, observeGrokDone, buildGrokAgentCmd, grokAgentArgv, writeGrokCallerFiles, checkGrokCallerInput, grokLaunchNote, grokEnvTokens, grokEnvEntries, grokTuiReady, grokPaneObservation, GROK_INTERRUPT_KEY, grokRateLimitDialog, grokPromptAwaitingAccept, grokUnacceptedPromptRestored, grokStartupAction, grokFooterHasConfiguration, grokTranscriptText, createGrokAgentMetadata, } from "./harnesses/grok.js";
72
72
  import { codexAuthPlan, codexAuthStatus, codexAuthPane, realCodexHome, readCodexConfigPins, bindCodexTranscriptSession, latestCodexCompletion, codexTurnSettled, codexCompletedTurnId, codexWorkingResumeConfiguration, captureCodexRecoveryProof, captureCodexResumeProof, readCodexResumeProof, codexResumeProofDigest, codexRootTranscript, codexRolloutSessionId, codexRunningTurn, codexInterruptionRecord, observeCodexDone, buildCodexAgentCmd, codexAgentArgv, codexResumeArgv, writeCodexCallerFiles, refuseCodexCallerInput, codexLaunchNote, codexPaneObservation, CODEX_INTERRUPT_KEY, codexHelperProcess, codexRateLimitModelSwitchDialog, codexApprovalDialog, codexStartupAction, codexModelChoice, codexEffortChoice, codexMoreReasoningChoice, codexTranscriptText, createCodexAgentMetadata, codexModelChoices, codexFastCommandOffered, codexFooterShowsFast, codexServiceTierNotices, restoreCodexDefaults, restoreCodexDefaultInFile, } from "./harnesses/codex.js";
73
- import { claudeAuthPlan, claudeAuthStatus, claudeAuthPane, claudeOauthTokenFile, claudeSetupTokenPlan, claudeOauthToken, claudeOauthTokenPresent, writeClaudeOauthToken, OPERATION_ID_RE, CLAUDE_RESULT_MAX_BYTES, CLAUDE_EFFORTS, agentClaudeOperationPath, agentClaudeApprovalReceiptPath, agentClaudeDispatchReceiptPath, validateOperationId, readClaudeResultText, claudeModelChoices, claudeConfigDir, claudeProjectSlug, claudeFastIndicatorShown, claudeFastResult, buildClaudeAgentCmd, claudeAgentArgv, claudeResumeArgv, claudeLaunchNote, claudePaneObservation, CLAUDE_INTERRUPT_KEY, claudeUsageLimit, claudeLiveSelectMenu, claudeStartupAction, createClaudeAgentMetadata, writeClaudeCallerFiles, claudeSessionTranscriptPath, claudeApiErrorFromLine, claudeApiErrorAfter, claudeLimitEnd, claudeInterruptedAfter, claudeLimitResetAt, claudeApiErrorEndingTurn, claudeFailureCategory, claudeOwnMcpNames, claudeModelSwitchResult, } from "./harnesses/claude.js";
73
+ import { claudeAuthPlan, claudeAuthStatus, claudeAuthPane, claudeOauthTokenFile, claudeSetupTokenPlan, claudeOauthToken, claudeOauthTokenPresent, writeClaudeOauthToken, OPERATION_ID_RE, CLAUDE_RESULT_MAX_BYTES, CLAUDE_EFFORTS, agentClaudeOperationPath, agentClaudeApprovalReceiptPath, agentClaudeDispatchReceiptPath, validateOperationId, readClaudeResultText, claudeModelChoices, claudeConfigDir, claudeProjectSlug, claudeFastIndicatorShown, claudeFastResult, buildClaudeAgentCmd, claudeAgentArgv, claudeResumeArgv, claudeLaunchNote, claudePaneObservation, CLAUDE_INTERRUPT_KEY, claudeUsageLimit, claudeLiveSelectMenu, claudeModelPicker, claudeStartupAction, createClaudeAgentMetadata, writeClaudeCallerFiles, claudeSessionTranscriptPath, claudeApiErrorFromLine, claudeApiErrorAfter, claudeLimitEnd, claudeInterruptedAfter, claudeLimitResetAt, claudeApiErrorEndingTurn, claudeFailureCategory, claudeOwnMcpNames, claudeModelSwitchResult, claudeModelSwitchConfirm, } from "./harnesses/claude.js";
74
74
  import { cursorAuthPlan, cursorAuthStatus, cursorAuthPane, bindCursorTranscriptSession, cursorTurnBoundary, latestCursorCompletion, cursorTranscript, cursorTranscriptSessionId, observeCursorDone, cursorTranscriptText, assertCursorAuthenticationReady, assertCursorModelAvailable, cursorModelChoices, cursorModelIsFastVariant, cursorFastParameter, cursorHeaderShowsFast, cursorPickerView, cursorEffortSelected, cursorParameterRows, cursorUserConfigPath, CURSOR_DEFAULT_MODEL_KEYS, realCursorHome, buildCursorAgentCmd, cursorAgentArgv, cursorPromptWithLineage, cursorLineagePreface, writeCursorCallerFiles, checkCursorCallerInput, createCursorAgentMetadata, cursorLaunchNote, cursorEffortNavigation, cursorTuiReady, cursorPaneObservation, CURSOR_INTERRUPT_KEY, cursorPromptHooksRunning, cursorUsageLimit, CURSOR_SUBMIT_SEQUENCE, validateCursorModelEffort, } from "./harnesses/cursor.js";
75
75
  import { interimFromNow, interimFromToken, readInterimWords, recordInterimBoundary } from "./interim-words.js";
76
76
  import { codexSeatAwaitingRollout, codexSeatTurn, grokSteerAcceptance, observeSteerDone, readSteerEntry, recordSteer } from "./steer-follow.js";
@@ -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;
@@ -5954,19 +5960,42 @@ async function switchAgentFast(name, meta, target, verified = false) {
5954
5960
  async function switchClaudeOpusPlan(name, meta, beforeChange) {
5955
5961
  const settings = path.join(meta.claude_home ?? claudeConfigDir(), "settings.json");
5956
5962
  beforeChange();
5963
+ const ui = agentModelUi(name);
5957
5964
  const seen = await keepingUserDefaults(settings, (before) => { restoreJsonSetting(settings, before, "model"); }, async () => {
5958
5965
  await sendAgentPromptText(name, "/model opusplan");
5959
5966
  const deadline = performance.now() + CLAUDE_FAST_RESULT_TIMEOUT_MS;
5960
- let result = null;
5967
+ let answered = false;
5961
5968
  do {
5962
5969
  await sleep(150);
5963
- result = claudeModelSwitchResult(captureScreen(name, AGENT_TUI_READY_LINES));
5964
- } while (!result && performance.now() < deadline);
5965
- return result;
5970
+ const screen = ui.screen();
5971
+ const confirm = claudeModelSwitchConfirm(screen);
5972
+ // A seat with a cached conversation asks "Switch model?" first: answer Yes once, as the picker path does.
5973
+ if (confirm === "yes_selected" && !answered) {
5974
+ answered = true;
5975
+ ui.key("Enter");
5976
+ }
5977
+ if (confirm)
5978
+ continue;
5979
+ const result = claudeModelSwitchResult(screen);
5980
+ if (result)
5981
+ return result;
5982
+ } while (performance.now() < deadline);
5983
+ return null;
5966
5984
  });
5985
+ if (!seen) {
5986
+ // Close what is still open (the switch question, or a screen Aiterm cannot read) so the seat takes the next input.
5987
+ for (let i = 0; i < 3; i++) {
5988
+ const screen = ui.screen();
5989
+ if (!claudeModelSwitchConfirm(screen) && !claudeModelPicker(screen) && claudePaneObservation(screen).state !== "unknown")
5990
+ break;
5991
+ ui.key("Escape");
5992
+ await sleep(300);
5993
+ }
5994
+ const error = new AitermError(`CLAUDE_MODEL_SWITCH_UNCONFIRMED vendor=claude session=${name}\nClaude Codeへ /model opusplan を送りましたが、結果の行を確かめられません。modelは変わった可能性があります。再送しないでください。`, 2);
5995
+ error.configureRefusal = { code: "CLAUDE_MODEL_SWITCH_UNCONFIRMED", relaunch: false, selection_excluded: false };
5996
+ throw error;
5997
+ }
5967
5998
  const ready = await waitAgentTuiReady(name, meta, AGENT_TUI_READY_TIMEOUT_MS);
5968
- if (!seen)
5969
- throw new AitermError(`CLAUDE_MODEL_SWITCH_UNCONFIRMED vendor=claude session=${name}\nClaude Codeへ /model opusplan を送りましたが、結果の行を確かめられません。modelは変わった可能性があります。再送しないでください。`, 2);
5970
5999
  if (seen.scope !== "saved_as_default" && seen.scope !== "session_only")
5971
6000
  throw new AitermError(`CLAUDE_MODEL_SWITCH_REFUSED vendor=claude session=${name}\nClaude Codeがmodelを切り替えませんでした(${seen.line})。`, 2);
5972
6001
  if (!ready.ready)
@@ -7327,6 +7356,30 @@ function commitWorkingAgentResume(previous, lifecycle) {
7327
7356
  throw new AgentResumeUnavailableError(name);
7328
7357
  withExecutionPreparation(name, () => writeAgentLifecycle(previous, lifecycle));
7329
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
+ }
7330
7383
  /** A current generation with no lifecycle/attempt state whose native is confirmed absent. */
7331
7384
  function vanishedAgentNative(meta) {
7332
7385
  if (agentDormantState(meta) !== null)
@@ -602,15 +602,16 @@ export function claudePickerRowByName(rows, name) {
602
602
  // Your next response will be slower and use more tokens
603
603
  // ❯ 1. Yes, switch to Opus 5.5
604
604
  // 2. No, go back
605
+ // `/model opusplan` (2.1.325) asks the same with "❯ 1. Yes, switch" and no model name (Z27 lab).
605
606
  export function claudeModelSwitchConfirm(screen) {
606
607
  const lines = screen.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "").split(/\r?\n/u);
607
608
  const head = lastLineIndex(lines, /^\s*Switch model\?\s*$/u);
608
609
  if (head < 0)
609
610
  return null;
610
611
  const body = lines.slice(head + 1);
611
- if (!body.some((line) => /^\s*(?:❯\s*)?1\.\s*Yes, switch to\b/u.test(line)))
612
+ if (!body.some((line) => /^\s*(?:❯\s*)?1\.\s*Yes, switch\b/u.test(line)))
612
613
  return null;
613
- return body.some((line) => /^\s*❯\s*1\.\s*Yes, switch to\b/u.test(line)) ? "yes_selected" : "other_selected";
614
+ return body.some((line) => /^\s*❯\s*1\.\s*Yes, switch\b/u.test(line)) ? "yes_selected" : "other_selected";
614
615
  }
615
616
  export function claudeModelSwitchResult(screen) {
616
617
  const lines = screen.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "").split(/\r?\n/u);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiterm-mcp",
3
- "version": "0.70.63",
3
+ "version": "0.70.65",
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": [