aiterm-mcp 0.70.21 → 0.70.23

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,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.70.23] - 2026-11-11
11
+
12
+ - A Claude seat that is signed out now reports failure category `authentication`. The real signed-out API error record of Claude Code 2.1.310/2.1.319 carries `error: "authentication_failed"` and no `apiErrorStatus`; that record, a 401, or (for a record with neither) the CLI's login line is now `authentication`, and the parent-delivery record accepts the value.
13
+ - Resuming a hibernated Claude seat through `agent_launch` with `env_vars` no longer conflicts on its login or config directory. `CLAUDE_CODE_OAUTH_TOKEN` is the seat's login, not a setting: it is left out of the env-name comparison, the launch's value (private env line, then process env) goes into the resumed seat, and a login that is not named or has no value is unset. `CLAUDE_CONFIG_DIR`, which Aiterm adds to every Claude recipe, is left out of the comparison too; before, every `env_vars` resume conflicted on it. On Linux and macOS the resume line reads the values from the same 0600 launch-env file a fresh launch uses instead of typing them into the pane, and the login stays out of the multiplexer environment and `pty_list`.
14
+
15
+ ## [0.70.22] - 2026-11-11
16
+
17
+ - A Claude launch no longer refuses on an authentication pre-check. `claude auth status` read the computer's own login, while a seat may run on a credential passed only in its private environment (for example `CLAUDE_CODE_OAUTH_TOKEN`); with the computer's own login expired, seats that would run were refused as `AGENT_AUTH_REQUIRED`. A logged-out Claude now stops at its own login screen (`vendor_onboarding_required`, initial prompt not sent). Terminals on older versions still answer the old codes, and callers keep reading them.
18
+ - A terminal's seat forward no longer waits up to 60 seconds when the key arrives just after a launch asked for it. The keeper started before the key gave up and exited, and a key that landed while it was still running started no new one; it now waits for the key and starts the forward when it lands.
19
+
10
20
  ## [0.70.21] - 2026-11-11
11
21
 
12
22
  - A terminal's seat MCP forward no longer goes down a few seconds after a launch. The `ssh -R` keeper ran inside the MCP process that handled the launch; BellTeam launches through a one-shot Aiterm, so the forward died when that process ended and stayed refused until another process's 60-second check (about 45 s in a lab run). A seat whose Claude was still connecting its MCP servers then, or that started in that window, lost its tools for good. The forward is now held by a detached keeper process (`aiterm-remote-terminal forward-keeper --ref R`) that lives while the forward is needed; MCP processes only start it when no live keeper holds the lock.
@@ -3287,7 +3297,9 @@ prototype (preserved under `prototype/python/` as the porting source and referen
3287
3297
  `ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
3288
3298
  provenance.
3289
3299
 
3290
- [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.21...HEAD
3300
+ [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.23...HEAD
3301
+ [0.70.23]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.22...v0.70.23
3302
+ [0.70.22]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.21...v0.70.22
3291
3303
  [0.70.21]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.20...v0.70.21
3292
3304
  [0.70.20]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.19...v0.70.20
3293
3305
  [0.70.19]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.18...v0.70.19
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.21** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
218
+ **状態:** 開発継続中 · 現行公開版 **v0.70.23** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
219
219
 
220
220
  ### 更新と巻き戻し
221
221
 
@@ -760,9 +760,9 @@ Cursor親(`clientInfo.name`が`cursor-vscode`)も同じ完了観測と本文
760
760
  Claudeをリンク経由の`cwd`から起動した場合も、実体パスに対応する会話記録を参照する。
761
761
 
762
762
 
763
- Claudeの認証事前確認による起動拒否は従来のエラー文を保ち、`structuredContent`へ`schema:"aiterm.agent-launch-error.v1"`、`harness:"claude-code"`、`phase:"authentication_preflight"`、`effect:"not_issued"`、`session_created:false`を返す。`code`は`CLAUDE_AUTH_NOT_AUTHENTICATED`(公式statusが未認証)、`CLAUDE_AUTH_STATUS_UNCONFIRMED`(確認不能)を区別する。確認が5秒で終わらない時は拒否せず起動へ進み、未ログインならlogin画面で`vendor_onboarding_required`として止まる。`CLAUDE_AUTH_STATUS_TIMEOUT`は0.70.1より前の端末だけが返す。資格情報の故障原因やログイン期限切れは断定せず、公式status本文・stderrは返さない。
763
+ Claudeの起動では、起動前の認証確認をしない(0.70.22)。`claude auth status`はその計算機自身のloginを読むが、席は私的envで渡された資格(例: `CLAUDE_CODE_OAUTH_TOKEN`)で動く事があり、動く席まで断っていた。起動へ進み、未ログインならlogin画面で`vendor_onboarding_required`として止まり初回promptを送らない。資格が拒まれた時は最初のturnがClaude自身の誤りで終わる。0.70.1〜0.70.21の端末は従来どおり`structuredContent`(`schema:"aiterm.agent-launch-error.v1"`、`phase:"authentication_preflight"`、`code`は`CLAUDE_AUTH_NOT_AUTHENTICATED`か`CLAUDE_AUTH_STATUS_UNCONFIRMED`。`CLAUDE_AUTH_STATUS_TIMEOUT`は0.70.1より前だけ)で断る。
764
764
 
765
- ログインしていないと確かめられたCLIは、起動前確認のあるClaude Code・Cursor・Antigravityで同じ形で起動を断る。`_meta["aiterm/launch_error"]`が`code:"AGENT_AUTH_REQUIRED"`・`phase:"input"`・`effect:"not_started"`・`session_created:false`・`harness`を持つ(本文は`AGENT_LAUNCH_NOT_STARTED: AGENT_AUTH_REQUIRED: ...`。Claudeは従来の本文と`structuredContent`も残す)。CodexとGrokには起動前確認が無く、各CLIのログイン画面で止まる。状態を読めなかった場合はこのcodeにしない。
765
+ ログインしていないと確かめられたCLIは、起動前確認のあるCursor・Antigravity(0.70.22より前の端末ではClaude Codeも)で同じ形で起動を断る。`_meta["aiterm/launch_error"]`が`code:"AGENT_AUTH_REQUIRED"`・`phase:"input"`・`effect:"not_started"`・`session_created:false`・`harness`を持つ(本文は`AGENT_LAUNCH_NOT_STARTED: AGENT_AUTH_REQUIRED: ...`。古い端末のClaudeは従来の本文と`structuredContent`も残す)。Claude Code・Codex・Grokには起動前確認が無く、各CLIのログイン画面で止まる。状態を読めなかった場合はこのcodeにしない。
766
766
 
767
767
  ### 別端末のagentを1回で起動する(`remote`)
768
768
 
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.21** · 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.23** · 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
 
@@ -368,7 +368,7 @@ PTY launch command and retained in aiterm's per-session `.lastcmd`; the launched
368
368
  processes with access to the same OS user may read them. Use this for non-secret seat identity and
369
369
  workflow variables, not as a secret transport.
370
370
 
371
- The selected harness CLI must be installed and authenticated. Aiterm resolves `CLAUDE_BIN` / `CODEX_BIN` / `GROK_BIN` / `CURSOR_AGENT_BIN`, then the documented default binary, then `PATH`. Cursor resolution deliberately uses `cursor-agent`, never the ambiguous `agent` name. Claude and Cursor authentication are checked before a PTY exists, so a failed preflight leaves no session. All harnesses use their normal harness-owned credential and configuration stores in place.
371
+ The selected harness CLI must be installed and authenticated. Aiterm resolves `CLAUDE_BIN` / `CODEX_BIN` / `GROK_BIN` / `CURSOR_AGENT_BIN`, then the documented default binary, then `PATH`. Cursor resolution deliberately uses `cursor-agent`, never the ambiguous `agent` name. Cursor authentication is checked before a PTY exists, so a failed preflight leaves no session. Claude is not checked before launch (0.70.22): a logged-out Claude stops at its own login screen. All harnesses use their normal harness-owned credential and configuration stores in place.
372
372
  For Grok, Aiterm does not lock, inspect, or modify the credential. A non-empty inherited
373
373
  `GROK_AUTH_PATH` must be absolute and exist; Aiterm passes it unchanged to Grok. Grok owns its
374
374
  contents, permissions, and link handling. Absence of the default auth file is accepted only when
@@ -770,9 +770,9 @@ The result (`aiterm.agent-models.v1`) is `{ harness, source, harness_version, de
770
770
 
771
771
  The selected harness CLI must be installed and authenticated. Use each product owner's official installer and updater; Aiterm does not distribute alternate CLI tarballs. For Cursor Agent CLI, use `curl https://cursor.com/install -fsS | bash` on macOS/Linux/WSL or `irm 'https://cursor.com/install?win32=true' | iex` on native Windows, authenticate once with `agent login`, and update with `agent update`; Aiterm invokes the unambiguous `cursor-agent` binary. Missing binaries, invalid model/effort values, unavailable Grok catalog models, and nonexistent `cwd` fail before a session exists.
772
772
 
773
- Claude authentication preflight refusals retain the existing error text and add `structuredContent` with schema `aiterm.agent-launch-error.v1`, `harness:"claude-code"`, `phase:"authentication_preflight"`, `effect:"not_issued"`, and `session_created:false`. `code` distinguishes `CLAUDE_AUTH_NOT_AUTHENTICATED` and `CLAUDE_AUTH_STATUS_UNCONFIRMED`. A status check that does not finish in 5 seconds no longer refuses: the launch goes on, and a logged-out Claude stops at its login screen as `vendor_onboarding_required`. `CLAUDE_AUTH_STATUS_TIMEOUT` comes only from terminals older than 0.70.1. These describe the official status check, not the cause of a credential failure or a confirmed login expiry. Native status bodies and stderr are omitted.
773
+ A Claude launch runs no authentication pre-check (0.70.22): `claude auth status` read the computer's own login, while a seat may run on a credential passed in its private environment (for example `CLAUDE_CODE_OAUTH_TOKEN`), so the check refused seats that would run. The launch goes on; a logged-out Claude stops at its login screen as `vendor_onboarding_required` with the initial prompt not sent, and a rejected credential ends the first turn with Claude's own error. Terminals on 0.70.1 to 0.70.21 still refuse with the old `structuredContent` (schema `aiterm.agent-launch-error.v1`, `phase:"authentication_preflight"`, `code` `CLAUDE_AUTH_NOT_AUTHENTICATED` or `CLAUDE_AUTH_STATUS_UNCONFIRMED`; `CLAUDE_AUTH_STATUS_TIMEOUT` only before 0.70.1).
774
774
 
775
- A CLI that is positively not logged in refuses the launch the same way for Claude Code, Cursor and Antigravity (the harnesses with a launch preflight): `_meta["aiterm/launch_error"]` carries `code:"AGENT_AUTH_REQUIRED"`, `phase:"input"`, `effect:"not_started"`, `session_created:false` and the `harness`; the text is `AGENT_LAUNCH_NOT_STARTED: AGENT_AUTH_REQUIRED: ...` (Claude keeps its older text and structured answer beside it). Codex and Grok have no launch preflight and stop at their own login screen. A status check that cannot be read is not this code.
775
+ A CLI that is positively not logged in refuses the launch the same way for Cursor and Antigravity (the harnesses with a launch preflight; Claude Code on terminals older than 0.70.22): `_meta["aiterm/launch_error"]` carries `code:"AGENT_AUTH_REQUIRED"`, `phase:"input"`, `effect:"not_started"`, `session_created:false` and the `harness`; the text is `AGENT_LAUNCH_NOT_STARTED: AGENT_AUTH_REQUIRED: ...` (an older terminal's Claude keeps its older text and structured answer beside it). Claude Code, Codex and Grok have no launch preflight and stop at their own login screen. A status check that cannot be read is not this code.
776
776
 
777
777
  Set `throughline_source_session` together with a non-empty mission in `prompt` to prepend
778
778
  Throughline's read-only handoff context. This optional route requires `throughline >= 0.9.0`,
package/dist/core.js CHANGED
@@ -67,7 +67,7 @@ import { readFileOrNull, restoreJsonSetting, withUserConfigLock, restoreUserDefa
67
67
  import { isDeepStrictEqual } from "node:util";
68
68
  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";
69
69
  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";
70
- import { claudeAuthPlan, claudeAuthStatus, claudeAuthPane, claudeOauthTokenFile, claudeSetupTokenPlan, claudeOauthToken, claudeOauthTokenPresent, writeClaudeOauthToken, OPERATION_ID_RE, CLAUDE_RESULT_MAX_BYTES, CLAUDE_EFFORTS, agentClaudeOperationPath, agentClaudeApprovalReceiptPath, agentClaudeDispatchReceiptPath, validateOperationId, readClaudeResultText, assertClaudeAuthenticationReady, claudeModelChoices, claudeConfigDir, claudeProjectSlug, claudeFastIndicatorShown, claudeFastResult, buildClaudeAgentCmd, claudeAgentArgv, claudeResumeArgv, claudeLaunchNote, claudePaneObservation, CLAUDE_INTERRUPT_KEY, claudeUsageLimit, claudeLiveSelectMenu, claudeStartupAction, createClaudeAgentMetadata, writeClaudeCallerFiles, claudeSessionTranscriptPath, claudeApiErrorFromLine, claudeApiErrorAfter, claudeApiErrorEndingTurn, claudeFailureCategory, } from "./harnesses/claude.js";
70
+ 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, claudeApiErrorEndingTurn, claudeFailureCategory, } from "./harnesses/claude.js";
71
71
  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";
72
72
  import { interimFromNow, interimFromToken, readInterimWords, recordInterimBoundary } from "./interim-words.js";
73
73
  import { codexSeatAwaitingRollout, codexSeatTurn, grokSteerAcceptance, observeSteerDone, readSteerEntry, recordSteer } from "./steer-follow.js";
@@ -2213,7 +2213,7 @@ export function listSessionsResult(envKeys = [], runTmux = tmux) {
2213
2213
  const recipe = readAgentResumeRecipe(meta);
2214
2214
  if (recipe?.kind === meta.kind && recipe.vendor_session_id === meta.vendor_session_id)
2215
2215
  for (const key of envKeys)
2216
- environment[key] = recipe.environment[key] ?? null;
2216
+ environment[key] = key === CLAUDE_LOGIN_ENV ? null : recipe.environment[key] ?? null;
2217
2217
  if (state === "hibernated") {
2218
2218
  try {
2219
2219
  confirmedAgentResumeRecipe(meta, readAgentLifecycle(meta));
@@ -6864,7 +6864,9 @@ function adoptVanishedAgentNative(meta) {
6864
6864
  "文字列は送信していません。agent_launchで起動し直してください。", 2);
6865
6865
  }
6866
6866
  }
6867
- async function resumeAgentInLock(name, readyTimeout, claudeRoot) {
6867
+ // Claude's login, not a recipe setting (lifecycle-state-ownership 4b): a resume through agent_launch may replace it.
6868
+ const CLAUDE_LOGIN_ENV = "CLAUDE_CODE_OAUTH_TOKEN";
6869
+ async function resumeAgentInLock(name, readyTimeout, claudeRoot, claudeLogin) {
6868
6870
  const previous = loadAgentMetadata(name);
6869
6871
  readyTimeout ??= previous.kind === "codex" ? AGENT_TUI_FIRST_DRAW_TIMEOUT_MS : AGENT_TUI_READY_TIMEOUT_MS;
6870
6872
  let lifecycle = readAgentLifecycle(previous);
@@ -6915,8 +6917,11 @@ async function resumeAgentInLock(name, readyTimeout, claudeRoot) {
6915
6917
  assertExecutionResumeSupported();
6916
6918
  const confirmed = confirmedAgentResumeRecipe(previous, lifecycle);
6917
6919
  // Same vendor session under another Claude root; the caller proved the transcript is there.
6918
- const recipe = claudeRoot && confirmed.kind === "claude" ? { ...confirmed, configuration_root: claudeRoot.root,
6920
+ const rooted = claudeRoot && confirmed.kind === "claude" ? { ...confirmed, configuration_root: claudeRoot.root,
6919
6921
  environment: { ...confirmed.environment, CLAUDE_CONFIG_DIR: claudeRoot.selector } } : confirmed;
6922
+ // null = unset in the seat: it resumes on the root's own login.
6923
+ const recipe = claudeLogin && rooted.kind === "claude"
6924
+ ? { ...rooted, environment: { ...rooted.environment, [CLAUDE_LOGIN_ENV]: claudeLogin.value } } : rooted;
6920
6925
  if (sessionExists(name))
6921
6926
  throw uncertain();
6922
6927
  const controlEnv = { ...process.env };
@@ -7010,6 +7015,9 @@ async function resumeAgentInLock(name, readyTimeout, claudeRoot) {
7010
7015
  const environment = [...Object.entries(recipe.environment),
7011
7016
  ...(next.kind === "codex" ? [["CODEX_HOME", recipe.configuration_root]] : []), ...agentEnvEntries(next, name)];
7012
7017
  for (const [key, value] of environment) {
7018
+ // The Claude login never goes on a multiplexer argv or into pty_list; the launch reads it from the 0600 file.
7019
+ if (value !== null && key === CLAUDE_LOGIN_ENV)
7020
+ continue;
7013
7021
  const stored = value === null ? tmux("set-environment", isWin ? "-u" : "-r", "-t", name, key) : tmux("set-environment", "-t", name, key, value);
7014
7022
  if (stored.code !== 0)
7015
7023
  throw uncertain();
@@ -7023,8 +7031,9 @@ async function resumeAgentInLock(name, readyTimeout, claudeRoot) {
7023
7031
  const forkBan = next.fork_of?.write_ban;
7024
7032
  const winArgv = () => (cli => forkBan ? windowsWriteBanArgv(forkBan, cli) : cli)(windowsAgentArgv(cliArgv, () => resolveWinPaneShell("bash")));
7025
7033
  const full = isWin ? windowsLaunchTyped(name, next.launch_id, windowsAgentLaunchLine(recipe.cwd, environment, winArgv(), { file: agentMetadataPath(name, next.launch_id) + ".launch-exited", launch_id: next.launch_id }))
7026
- : `cd ${shq(recipe.cwd)} && /usr/bin/env ${environment.filter(([, value]) => value === null).map(([key]) => `-u ${shq(key)}`).join(" ")} `
7027
- + `${environment.filter(([, value]) => value !== null).map(([key, value]) => shq(`${key}=${value}`)).join(" ")} ${argv.map(shq).join(" ")}`;
7034
+ // Values only by the 0600 launch-env file, as in a fresh launch: typed into the pane they stayed on its screen and log.
7035
+ : `cd ${shq(recipe.cwd)} && ${launchEnvSource(name, environment.filter((entry) => entry[1] !== null))}`
7036
+ + `/usr/bin/env ${environment.filter(([, value]) => value === null).map(([key]) => `-u ${shq(key)}`).join(" ")} ${argv.map(shq).join(" ")}`;
7028
7037
  agentLaunchLines.set(name, atomicShellMultiline(full, shell));
7029
7038
  send(name, full, { enter: true, mark: false, force: true, rtk: false, raw: true, launchShell: shell, preserveAgentOperation: true });
7030
7039
  phase = "generation_publish";
@@ -7661,6 +7670,11 @@ function agentEnvPrefix(meta, sid, envVars = []) {
7661
7670
  }
7662
7671
  /** Inherited values are written to a 0600 file the launch line sources and deletes, so the typed
7663
7672
  * line and the pane log carry only its path (remote-terminal.md R7). Identity names stay inline. */
7673
+ /** The env names a resume compares. Claude: the login is not a setting (lifecycle-state-ownership 4b), and every Claude
7674
+ * recipe carries CLAUDE_CONFIG_DIR, which Aiterm adds from the root (configuration_root decides it), not the caller. */
7675
+ function resumeEnvNames(kind, names) {
7676
+ return [...new Set(names)].filter(name => kind !== "claude" || (name !== CLAUDE_LOGIN_ENV && name !== "CLAUDE_CONFIG_DIR")).sort();
7677
+ }
7664
7678
  function launchEnvSource(sid, entries) {
7665
7679
  if (entries.length === 0)
7666
7680
  return "";
@@ -7820,8 +7834,7 @@ function prepareAgentLaunch(kind, opts = {}) {
7820
7834
  throw new AitermError("AGENT_CONFIGURATION_ROOT_REJECTED: env_varsのCLAUDE_CONFIG_DIRとconfiguration_rootは同時に指定できません。", 2);
7821
7835
  const claudeEnv = claudeRoot ? withClaudeConfigRoot(process.env, claudeRoot) : process.env;
7822
7836
  const claudeRootEntries = claudeRoot ? [["CLAUDE_CONFIG_DIR", claudeRoot.selector]] : [];
7823
- if (kind === "claude")
7824
- assertClaudeAuthenticationReady(bin, claudeEnv);
7837
+ // No Claude pre-check (ADR 0020, 2026-11-11): it read this computer's login, not the seat's private-env credential; a logged-out Claude stops at its login screen.
7825
7838
  if (kind === "cursor")
7826
7839
  assertCursorAuthenticationReady(bin);
7827
7840
  if (kind === "antigravity") {
@@ -8228,7 +8241,7 @@ export async function openAgentWithInitialPrompt(kind, opts = {}) {
8228
8241
  || (opts.fast != null && opts.fast !== recipe.fast)
8229
8242
  || (opts.cwd != null && path.resolve(opts.cwd) !== recipe.cwd)
8230
8243
  || (opts.write_scope !== undefined && opts.write_scope !== previous.write_scope)
8231
- || (opts.env_vars !== undefined && !isDeepStrictEqual([...new Set(opts.env_vars)].sort(), Object.keys(recipe.environment).sort())))
8244
+ || (opts.env_vars !== undefined && !isDeepStrictEqual(resumeEnvNames(kind, opts.env_vars), resumeEnvNames(kind, Object.keys(recipe.environment)))))
8232
8245
  throw opts.require_existing_resume ? new AgentResumeUnavailableError(name) : new AitermError("AGENT_RESUME_CONFLICT: 同名の休止席は保存したharness・設定・project・明示envで再開します。変更は再開後に行ってください。", 2);
8233
8246
  // The only setting a resume may change: the Claude root, when it holds this conversation's transcript.
8234
8247
  const rootChange = claudeRoot && (claudeRoot.root !== recipe.configuration_root
@@ -8240,7 +8253,9 @@ export async function openAgentWithInitialPrompt(kind, opts = {}) {
8240
8253
  cwd: opts.cwd ?? null, agentDone: true }));
8241
8254
  if (preparedLifecycle)
8242
8255
  commitWorkingAgentResume(previous, preparedLifecycle);
8243
- const resumed = await resumeAgentInLock(name, opts.ready_timeout ?? undefined, rootChange);
8256
+ const claudeLogin = kind === "claude" && opts.env_vars !== undefined
8257
+ ? { value: opts.env_vars.includes(CLAUDE_LOGIN_ENV) ? launchEnvValue(CLAUDE_LOGIN_ENV) ?? null : null } : undefined;
8258
+ const resumed = await resumeAgentInLock(name, opts.ready_timeout ?? undefined, rootChange, claudeLogin);
8244
8259
  return withAgentResumeTarget(resumed, async () => {
8245
8260
  const hint = `${agentLabel(kind)} を保存した同じ会話へ再開した。\n${attachHint(name)}`;
8246
8261
  const fastState = { fast: resumed.fast === true, fast_error: null };
package/dist/errors.js CHANGED
@@ -27,16 +27,6 @@ export function launchAuthRequired(harness, reason) {
27
27
  error.launchNotStarted = { harness, phase: "input", code: "AGENT_AUTH_REQUIRED" };
28
28
  return error;
29
29
  }
30
- /** A harness authentication check refused launch before any session creation.
31
- * Keep the native CLI's status body and credential diagnostics out of the wire. */
32
- export class AgentAuthenticationPreflightError extends AitermError {
33
- reasonCode;
34
- constructor(reasonCode, message) {
35
- super(message, 2);
36
- this.reasonCode = reasonCode;
37
- this.name = "AgentAuthenticationPreflightError";
38
- }
39
- }
40
30
  /** Admission refusal before the requested resume starts. */
41
31
  export class AgentResumeUnavailableError extends AitermError {
42
32
  resumeUnavailable;
@@ -7,7 +7,7 @@ import * as os from "node:os";
7
7
  import * as path from "node:path";
8
8
  import { createHash, randomBytes, randomUUID } from "node:crypto";
9
9
  import { fileURLToPath } from "node:url";
10
- import { AitermError, AgentAuthenticationPreflightError } from "../errors.js";
10
+ import { AitermError } from "../errors.js";
11
11
  import { modeBitsWorldAccessible } from "../tmux-runtime.js";
12
12
  import { runAgentProtocolCommand, spawnAgentControlCommand } from "../agent-resolver.js";
13
13
  import { claudeCatalogRoot } from "../claude-catalog-root.js";
@@ -167,7 +167,6 @@ export function readClaudeResultText(meta, done, operationId, transcriptUnavaila
167
167
  }
168
168
  return result.text;
169
169
  }
170
- const CLAUDE_AUTH_STATUS_TIMEOUT_MS = 5_000;
171
170
  const CLAUDE_MODELS_TIMEOUT_MS = 30_000;
172
171
  const CLAUDE_MODELS_MAX_BYTES = 4 * 1024 * 1024;
173
172
  // ultracodeはClaude Codeのsession設定で、`--effort ultracode` で有効になる(2.1.285実測:警告なしで受け付け、
@@ -314,42 +313,6 @@ export function claudeCatalogFromInitialize(stdout, requestId, summary = "") {
314
313
  fast_unavailable: claudeFastUnavailable(response.response.response?.fast_mode_disabled_reason),
315
314
  });
316
315
  }
317
- export function assertClaudeAuthenticationReady(bin, env = process.env) {
318
- const result = spawnAgentControlCommand(bin, ["auth", "status", "--json"], process.cwd(), {
319
- env,
320
- encoding: "utf8",
321
- timeout: CLAUDE_AUTH_STATUS_TIMEOUT_MS,
322
- maxBuffer: 64 * 1024,
323
- });
324
- let status = null;
325
- try {
326
- status = JSON.parse((result.stdout ?? "").trim());
327
- }
328
- catch {
329
- status = null;
330
- }
331
- if (result.error == null &&
332
- result.status === 0 &&
333
- status !== null &&
334
- typeof status === "object" &&
335
- !Array.isArray(status) &&
336
- status.loggedIn === true) {
337
- return;
338
- }
339
- if (status !== null &&
340
- typeof status === "object" &&
341
- !Array.isArray(status) &&
342
- status.loggedIn === false) {
343
- throw new AgentAuthenticationPreflightError("CLAUDE_AUTH_NOT_AUTHENTICATED", "Claude Codeの認証を利用できません。sessionは作成していません。" +
344
- "通常端末で `claude doctor` を実行し、Keychain/credential storeを直してから一度だけ `claude auth login` を実行してください。" +
345
- "aiterm相関付きClaude session内で /login を繰り返さないでください。");
346
- }
347
- // A slow check is not a refusal (ADR 0020, 2026-11-10): launch on; a logged-out Claude stops at its login screen.
348
- if (result.error && result.error.code === "ETIMEDOUT")
349
- return;
350
- throw new AgentAuthenticationPreflightError("CLAUDE_AUTH_STATUS_UNCONFIRMED", "Claude Codeの認証状態を起動前に確認できません。sessionは作成していません。" +
351
- "`claude auth status --json` と `claude doctor` が成功することを通常端末で確認してください。");
352
- }
353
316
  /**
354
317
  * 起動時に席へ渡す、Aitermの届け方の説明(ADR 0116)。Claude Codeは貼り付けを包み、包みの中の指示を利用者の言葉と分けて読む。
355
318
  * Aitermが包みの外へ添える1行を先に教えておく。包みの中へ同じ文を書いても包みの外には出ないので、印をまねる事は出来ない。
@@ -774,6 +737,10 @@ export function claudeApiErrorFromLine(line) {
774
737
  export function claudeFailureCategory(error) {
775
738
  if (error.status === 429 || error.kind === "rate_limit" || /^You've (?:reached your [^.\r\n]{1,80} limit\.|hit your (?:[a-z0-9-]+ ){0,3}limit\b)/i.test(error.text))
776
739
  return "rate_limited";
740
+ // The real record (2.1.310, 2.1.319): error "authentication_failed", no apiErrorStatus, "Login expired · Please run /login".
741
+ if (error.kind === "authentication_failed" || error.status === 401
742
+ || (error.kind === null && error.status === null && /Please run \/login|OAuth token (?:has been )?revoked|Invalid API key/i.test(error.text)))
743
+ return "authentication";
777
744
  if (error.status === 529)
778
745
  return "capacity";
779
746
  return error.status !== null && error.status >= 500 ? "transient" : "other";
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { terminalCwdFits } from "./remote-path.js";
6
6
  import { launchEnvValue } from "./private-env.js";
7
7
  import { AuthResponseError, authUiSchema, authBindingSchema, authResponseSchema } from "./agent-auth-ui.js";
8
8
  import { configurationRequestSchema, configurationToolOutputSchema, applyConfigurationRequest, reconcileConfigurationRequest } from "./configure-request.js";
9
- import { AitermError, AgentAuthenticationPreflightError, AgentResumeUnavailableError, AgentResumeError, launchInputRefusal } from "./errors.js";
9
+ import { AitermError, AgentResumeUnavailableError, AgentResumeError, launchInputRefusal } from "./errors.js";
10
10
  /**
11
11
  * aiterm-mcp — AI が握るローカル永続端末を stdio MCP サーバとして公開する(Node/TS 版)。
12
12
  *
@@ -255,13 +255,6 @@ export function createAitermServer(options = {}) {
255
255
  content: [{ type: "text", text: "aiterm: " + msg }], isError: true,
256
256
  structuredContent: { ...configurationFailure }, ...configureErrorMeta(e),
257
257
  };
258
- if (e instanceof AgentAuthenticationPreflightError)
259
- return {
260
- content: [{ type: "text", text: "aiterm: " + msg }], isError: true,
261
- structuredContent: { schema: "aiterm.agent-launch-error.v1", harness: "claude-code", code: e.reasonCode,
262
- phase: "authentication_preflight", effect: "not_issued", session_created: false, message: msg },
263
- ...(e.reasonCode === "CLAUDE_AUTH_NOT_AUTHENTICATED" ? { _meta: launchNotStartedMeta("claude-code", "input", "AGENT_AUTH_REQUIRED") } : {}),
264
- };
265
258
  if (e instanceof AitermError && e.launchNotStarted)
266
259
  return { content: [{ type: "text", text: "aiterm: " + msg }], isError: true,
267
260
  _meta: launchNotStartedMeta(e.launchNotStarted.harness, e.launchNotStarted.phase, e.launchNotStarted.code) };
@@ -10,7 +10,7 @@ import { executionRequestSchema } from "./execution-contract.js";
10
10
  import { parentSourceSchema } from "./execution-parent-source.js";
11
11
  import { executionActorSchema } from "./execution-inventory.js";
12
12
  export const failureObservationSchema = z.object({
13
- category: z.enum(["capacity", "rate_limited", "transient", "other"]),
13
+ category: z.enum(["capacity", "rate_limited", "transient", "authentication", "other"]),
14
14
  execution: z.enum(["not_started", "started", "unknown"]),
15
15
  boundary: z.object({ event_cursor: z.number().int().nonnegative(), operation_id: z.string().nullable(), turn_id: z.string().nullable(),
16
16
  input_id: z.string().regex(/^[a-f0-9]{32}$/).optional() }).strict().nullable(),
@@ -955,6 +955,13 @@ export function runForwardKeeper(ref) {
955
955
  binding(ref);
956
956
  keeperProcess = true;
957
957
  keeperHold = setInterval(() => { keep(ref); settleKeeper(ref); }, 5_000);
958
+ try { // a key that lands while this keeper waits for it: retry at once, not at the next 5 s turn
959
+ const watch = fs.watch(credentialDir(), (_event, name) => { if (!name || String(name).endsWith(".json"))
960
+ keep(ref); });
961
+ watch.on("error", () => watch.close());
962
+ watch.unref();
963
+ }
964
+ catch { /* the 5 s turn still covers it */ }
958
965
  keep(ref);
959
966
  settleKeeper(ref);
960
967
  }
@@ -1012,12 +1019,13 @@ function keep(ref) {
1012
1019
  // The remote command depends on the terminal's shell (T4): known from the cache, or probed once by this process.
1013
1020
  // The probe's ssh arguments can refuse synchronously (CREDENTIAL_NOT_LOADED before credential-load): leave like the
1014
1021
  // argument refusal below, never with `starting` set, or no later keep() would ever start the forward (0.70.9).
1022
+ // Keep the lock and stay (0.70.22): this keeper retries when the key lands. Exiting here left a credential-load
1023
+ // that landed while it was still running with no keeper until the 60 s check (other processes saw it alive).
1015
1024
  let probe;
1016
1025
  try {
1017
1026
  probe = remoteShell(trustedTarget(b));
1018
1027
  }
1019
1028
  catch {
1020
- releaseLock(ref);
1021
1029
  return;
1022
1030
  }
1023
1031
  keeper.starting = true;
@@ -1029,8 +1037,7 @@ function keep(ref) {
1029
1037
  args = trustedSshArguments(ref, keeperCommand(shell), null, ["-o", "ExitOnForwardFailure=yes", "-R", seatForwardSpec(requested, b.seat_ingress_port)]);
1030
1038
  }
1031
1039
  catch {
1032
- releaseLock(ref);
1033
- return;
1040
+ return; /* as above: keep the lock, retry when the key lands */
1034
1041
  }
1035
1042
  const child = spawn("ssh", args, { env: sshEnvironment(), stdio: ["pipe", "pipe", "pipe"] });
1036
1043
  keeper.child = child;
package/docs/DESIGN.md CHANGED
@@ -541,7 +541,7 @@ Claude authentication URL receipts recognize the official claude.com/cai/oauth/a
541
541
 
542
542
  ### 認証画面と専用応答
543
543
 
544
- Claude起動前の公式auth status拒否はharnessが`AgentAuthenticationPreflightError`として所有し、通常MCPのfailが`aiterm.agent-launch-error.v1`へ投影する。既存数値exit codeと文言を維持し、未認証・確認不能の機械code(timeoutは拒否せず起動へ進み、未認証なら起動後のlogin画面判定が止める。`CLAUDE_AUTH_STATUS_TIMEOUT`は旧版の端末だけが返す。ADR 0020追補)、authentication_preflight/not_issued/session_created:falseだけを追加する。CLI status本文・stderr・資格・推定したexpiry原因は持ち出さず、この拒否は認証PTYの入力や起動後turnの終端とは分ける。
544
+ (0.70.22で廃止: Claudeの起動前auth statusは席の私的envの資格を見ずに動く席を断っていたため、起動前確認をやめ、未ログインは起動後のlogin画面判定が止める。以下は0.70.21までの端末の答えとして呼び手側の写像だけ残る。)Claude起動前の公式auth status拒否はharnessが`AgentAuthenticationPreflightError`として所有し、通常MCPのfailが`aiterm.agent-launch-error.v1`へ投影する。既存数値exit codeと文言を維持し、未認証・確認不能の機械code(timeoutは拒否せず起動へ進み、未認証なら起動後のlogin画面判定が止める。`CLAUDE_AUTH_STATUS_TIMEOUT`は旧版の端末だけが返す。ADR 0020追補)、authentication_preflight/not_issued/session_created:falseだけを追加する。CLI status本文・stderr・資格・推定したexpiry原因は持ち出さず、この拒否は認証PTYの入力や起動後turnの終端とは分ける。
545
545
 
546
546
  `agent-auth-ui.ts`が既v1 receiptに追加する`auth_ui`とrespondの型を所有する。Native harnessが公式URL・device code・空code欄・現在のラベル付き選択肢を識別し、Rootはキー列を作らない。不明な入力段階はunavailable。coreが既auth metadataのdev/ino/作成・更新時刻、native session/pane/server/PID開始識別を照合する。legacyのlaunch UUID欠測はnullのまま扱い、無関係なflowをadoptしない。新startは既launch_id欄を必ず設定する。
547
547
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiterm-mcp",
3
- "version": "0.70.21",
3
+ "version": "0.70.23",
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": [