aiterm-mcp 0.70.20 → 0.70.22

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.22] - 2026-11-11
11
+
12
+ - 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.
13
+ - 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.
14
+
15
+ ## [0.70.21] - 2026-11-11
16
+
17
+ - 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.
18
+
10
19
  ## [0.70.20] - 2026-11-11
11
20
 
12
21
  - `agent_auth` (claude-code) takes `login: "oauth_token"` with `token_file` (only `<HOME>/.bellteam-accounts/claude/<slot>/oauth-token`; any other path is `AGENT_AUTH_TOKEN_FILE_REJECTED` before anything starts). `start` always runs `claude setup-token` (under `configuration_root`, same `auth_ui` stages, binding and `respond`), and Aiterm writes the printed token to `token_file` as the seat user, 0600, through a temp file, fsync and rename; the pane's history and screen are then cleared. The token is never in a receipt, `auth_ui`, a log, env or argv. Failure or cancel writes nothing. `status` in this mode reports `authenticated` only for a non-empty 0600 regular file of the user and never reads `.credentials.json`. Receipts echo `login: "oauth_token"`, so a caller can refuse an older Aiterm that would run `claude auth login` instead.
@@ -3283,7 +3292,9 @@ prototype (preserved under `prototype/python/` as the porting source and referen
3283
3292
  `ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
3284
3293
  provenance.
3285
3294
 
3286
- [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.20...HEAD
3295
+ [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.22...HEAD
3296
+ [0.70.22]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.21...v0.70.22
3297
+ [0.70.21]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.20...v0.70.21
3287
3298
  [0.70.20]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.19...v0.70.20
3288
3299
  [0.70.19]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.18...v0.70.19
3289
3300
  [0.70.18]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.17...v0.70.18
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.20** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
218
+ **状態:** 開発継続中 · 現行公開版 **v0.70.22** · 動作対象は 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.20** · 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.22** · 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";
@@ -7820,8 +7820,7 @@ function prepareAgentLaunch(kind, opts = {}) {
7820
7820
  throw new AitermError("AGENT_CONFIGURATION_ROOT_REJECTED: env_varsのCLAUDE_CONFIG_DIRとconfiguration_rootは同時に指定できません。", 2);
7821
7821
  const claudeEnv = claudeRoot ? withClaudeConfigRoot(process.env, claudeRoot) : process.env;
7822
7822
  const claudeRootEntries = claudeRoot ? [["CLAUDE_CONFIG_DIR", claudeRoot.selector]] : [];
7823
- if (kind === "claude")
7824
- assertClaudeAuthenticationReady(bin, claudeEnv);
7823
+ // 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
7824
  if (kind === "cursor")
7826
7825
  assertCursorAuthenticationReady(bin);
7827
7826
  if (kind === "antigravity") {
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行を先に教えておく。包みの中へ同じ文を書いても包みの外には出ないので、印をまねる事は出来ない。
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) };
@@ -12,7 +12,7 @@ import { createRequire } from "node:module";
12
12
  import { z } from "zod";
13
13
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
14
14
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
15
- import { REMOTE_COMMAND_OPS, RemoteTerminalConnection, RemoteTerminalError, bindingStatus, confirmHostKey, loadCredential, registerBinding } from "./remote-terminal.js";
15
+ import { REMOTE_COMMAND_OPS, RemoteTerminalConnection, RemoteTerminalError, bindingStatus, confirmHostKey, loadCredential, registerBinding, runForwardKeeper } from "./remote-terminal.js";
16
16
  import { readCompletedTranscript } from "./transcript-read.js";
17
17
  import { credentialHandleSchema, terminalOsSchema } from "./remote-contract.js";
18
18
  import { inspectPath, listDirectories, makeDirectory } from "./remote-path.js";
@@ -118,6 +118,9 @@ export function main(args) {
118
118
  const [command, ...rest] = args;
119
119
  if (command === "serve")
120
120
  return serve();
121
+ // Started detached by Aiterm itself (remote-terminal.md forward keeper); not an operator command.
122
+ if (command === "forward-keeper")
123
+ return runForwardKeeper(option(rest, "--ref") ?? "");
121
124
  if (command === "status")
122
125
  return oneShot(() => bindingStatus(option(rest, "--ref") ?? ""), "aiterm.remote-binding-error.v1");
123
126
  if (command === "register")
@@ -7,12 +7,14 @@ import * as os from "node:os";
7
7
  import * as path from "node:path";
8
8
  import { createHash, randomUUID } from "node:crypto";
9
9
  import { createRequire } from "node:module";
10
+ import { fileURLToPath } from "node:url";
10
11
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
11
12
  import { ReadBuffer, serializeMessage } from "@modelcontextprotocol/sdk/shared/stdio.js";
12
13
  import { ensureStateRoot, writeJson0600 } from "./agent-shared.js";
13
14
  import { powershellForShell, remotePlatform, remoteShell, terminalCommand, terminalProgram } from "./remote.js";
14
15
  import { PRIVATE_ENV_SCHEMA } from "./private-env.js";
15
16
  import { checkRemotePath } from "./remote-path.js";
17
+ import { liveNodeExecutable } from "./live-node.js";
16
18
  const pkg = createRequire(import.meta.url)("../package.json");
17
19
  export class RemoteTerminalError extends Error {
18
20
  code;
@@ -927,7 +929,57 @@ function storedIngress(ref) {
927
929
  return undefined;
928
930
  }
929
931
  }
932
+ // Only the detached keeper process (`forward-keeper --ref R`) holds the ssh. BellTeam launches through a one-shot Aiterm,
933
+ // and a forward held there died with it right after the launch (lab 2026-11-11: ~45 s refused until a 60 s check).
934
+ let keeperProcess = false;
935
+ const startedKeepers = new Map();
936
+ const KEEPER_CLI = new URL("./remote-terminal-cli.js", import.meta.url);
937
+ function startForwardKeeper(ref) {
938
+ if (!forwardNeeded(ref)) {
939
+ releaseIdleCredential(ref);
940
+ return;
941
+ }
942
+ const owner = lockOwner(ref);
943
+ if (owner && ownerAlive(owner))
944
+ return;
945
+ const started = startedKeepers.get(ref); // one keeper per process at a time, while it takes the lock
946
+ if (started && started.exitCode === null && started.signalCode === null)
947
+ return;
948
+ const child = spawn(liveNodeExecutable(), [fileURLToPath(KEEPER_CLI), "forward-keeper", "--ref", ref], { detached: true, stdio: "ignore", env: process.env, windowsHide: true });
949
+ child.on("error", () => { /* exitCode stays null: clear it so the next check starts another */ startedKeepers.delete(ref); });
950
+ child.unref();
951
+ startedKeepers.set(ref, child);
952
+ }
953
+ /** `aiterm-remote-terminal forward-keeper --ref R`: hold R's forward while it is needed; exit when this process has nothing to hold. */
954
+ export function runForwardKeeper(ref) {
955
+ binding(ref);
956
+ keeperProcess = true;
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 */ }
965
+ keep(ref);
966
+ settleKeeper(ref);
967
+ }
968
+ let keeperHold = null;
969
+ /** The keeper process ends (its loop stops, nothing else holds it) once it has no forward, timer, probe or lock. */
970
+ function settleKeeper(ref) {
971
+ const keeper = keepers.get(ref);
972
+ if (!keeperHold || (keeper && (keeper.child || keeper.timer || keeper.starting || Number(lockOwner(ref)?.pid) === process.pid)))
973
+ return;
974
+ clearInterval(keeperHold);
975
+ keeperHold = null;
976
+ keepers.delete(ref);
977
+ }
930
978
  function keep(ref) {
979
+ if (!keeperProcess) {
980
+ startForwardKeeper(ref);
981
+ return;
982
+ }
931
983
  const keeper = keepers.get(ref) ?? { child: null, ingress: 0, refusals: 0, timer: null };
932
984
  keepers.set(ref, keeper);
933
985
  if (keeper.child) {
@@ -967,12 +1019,13 @@ function keep(ref) {
967
1019
  // The remote command depends on the terminal's shell (T4): known from the cache, or probed once by this process.
968
1020
  // The probe's ssh arguments can refuse synchronously (CREDENTIAL_NOT_LOADED before credential-load): leave like the
969
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).
970
1024
  let probe;
971
1025
  try {
972
1026
  probe = remoteShell(trustedTarget(b));
973
1027
  }
974
1028
  catch {
975
- releaseLock(ref);
976
1029
  return;
977
1030
  }
978
1031
  keeper.starting = true;
@@ -984,8 +1037,7 @@ function keep(ref) {
984
1037
  args = trustedSshArguments(ref, keeperCommand(shell), null, ["-o", "ExitOnForwardFailure=yes", "-R", seatForwardSpec(requested, b.seat_ingress_port)]);
985
1038
  }
986
1039
  catch {
987
- releaseLock(ref);
988
- return;
1040
+ return; /* as above: keep the lock, retry when the key lands */
989
1041
  }
990
1042
  const child = spawn("ssh", args, { env: sshEnvironment(), stdio: ["pipe", "pipe", "pipe"] });
991
1043
  keeper.child = child;
@@ -1022,6 +1074,7 @@ function keep(ref) {
1022
1074
  again();
1023
1075
  else
1024
1076
  keep(ref);
1077
+ settleKeeper(ref);
1025
1078
  });
1026
1079
  }, () => { keeper.starting = false; again(); });
1027
1080
  }
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.20",
3
+ "version": "0.70.22",
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": [