aiterm-mcp 0.70.0 → 0.70.2
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 +12 -1
- package/README.ja.md +2 -2
- package/README.md +2 -2
- package/dist/core.js +98 -92
- package/dist/harnesses/claude.js +13 -2
- package/dist/setup.js +6 -3
- package/dist/tmux-runtime.js +68 -5
- package/docs/DESIGN.md +2 -1
- package/package.json +1 -1
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.2] - 2026-11-10
|
|
11
|
+
|
|
12
|
+
- A managed Claude or Codex launch (fresh or resumed) that fails after its terminal session was created, while Aiterm still sets it up (the process birth identity cannot be read, the session environment cannot be registered, the `.log` or offset file cannot be written, or the output pipe fails), now closes that session before returning the error. Before, the plain named session stayed, and every later launch of the same name was refused with "session '<name>' は既に存在します" until someone closed it by hand. Only the session this launch created is closed: creation marks it with a one-time token (first as the window name, then as the session option `@aiterm_create_token`), and the close is conditional on the native identity and that token, so a session of the same name that replaced it, and its files, are kept. The original error text is kept; `creation_rollback_unconfirmed` is appended only when the close fails while the session is still there. Failures after the setup (startup screens, the initial prompt, a lost transport) keep their existing behavior, and plain `pty_open` is unchanged. The session is created by the terminal's Aiterm, so a remote terminal needs this release; updating only the server side does not change it (docs/architecture/lifecycle-state-ownership.md).
|
|
13
|
+
|
|
14
|
+
## [0.70.1] - 2026-11-10
|
|
15
|
+
|
|
16
|
+
- Claude Code's "Updates to Consumer Terms and Policies" screen (2.1.318, grove) is classified as `blocked` / `vendor_onboarding_required` instead of `unrecognized_screen`, so a launch stops with the plain hint instead of waiting it out. Aiterm never answers it: the terms and the model-training choice belong to the account holder.
|
|
17
|
+
- The setup and runtime probe (`aiterm setup`, `aiterm-remote-terminal runtime-smoke`) starts its `aiterm-mcp` with the caller's whole environment, so it opens its terminal in the same `TMPDIR` socket directory as the caller's seats, and a failed probe keeps the tool's own error text. Without `TMPDIR` the probe used `/tmp/claude-tmux-sockets`, which another user of the same Mac may own.
|
|
18
|
+
- A Claude `auth status --json` preflight that does not finish in 5 seconds no longer refuses the launch (`CLAUDE_AUTH_STATUS_TIMEOUT`): the launch goes on, and a logged-out Claude stops at its login screen as `vendor_onboarding_required` (ADR 0020 addendum). A Mac seat failed this way 22 s after Claude Code updated itself to 2.1.322, under load average ~700, while `auth status` answered `loggedIn: true` in 0.75 s afterwards. `loggedIn: false`, malformed output and a failed exit still refuse before any session exists. The terminal needs this release.
|
|
10
19
|
## [0.70.0] - 2026-11-10
|
|
11
20
|
|
|
12
21
|
- `remote_terminal_command` takes `list_dirs` with an optional absolute `path` for a folder picker (BellTeam PR 887 S6; docs/architecture/remote-terminal.md R15). Without `path` it lists the SSH user's home. Result `{op, home, path, exists, directory, entries: [{name}] | null, truncated}`: subfolders only (a symlink to a folder counts), no names starting with `.`, ordered by name, at most 500 then `truncated: true`, read only. A missing folder or a file answers `exists`/`directory` false with `entries: null`, never an empty list; permission refusals (macOS privacy consent included) answer `FOLDER_NOT_PERMITTED` as for `path_status`. Needs this release on the terminal (`REMOTE_AITERM_TOO_OLD` otherwise).
|
|
@@ -3158,7 +3167,9 @@ prototype (preserved under `prototype/python/` as the porting source and referen
|
|
|
3158
3167
|
`ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
|
|
3159
3168
|
provenance.
|
|
3160
3169
|
|
|
3161
|
-
[Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.
|
|
3170
|
+
[Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.2...HEAD
|
|
3171
|
+
[0.70.2]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.1...v0.70.2
|
|
3172
|
+
[0.70.1]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.0...v0.70.1
|
|
3162
3173
|
[0.70.0]: https://github.com/kitepon/aiterm-mcp/compare/v0.69.0...v0.70.0
|
|
3163
3174
|
[0.69.0]: https://github.com/kitepon/aiterm-mcp/compare/v0.68.1...v0.69.0
|
|
3164
3175
|
[0.68.1]: https://github.com/kitepon/aiterm-mcp/compare/v0.68.0...v0.68.1
|
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.
|
|
218
|
+
**状態:** 開発継続中 · 現行公開版 **v0.70.2** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
|
|
219
219
|
|
|
220
220
|
### 更新と巻き戻し
|
|
221
221
|
|
|
@@ -760,7 +760,7 @@ 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
|
|
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は返さない。
|
|
764
764
|
|
|
765
765
|
### 別端末のagentを1回で起動する(`remote`)
|
|
766
766
|
|
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.
|
|
230
|
+
**Status:** actively maintained · current public release **v0.70.2** · 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
|
|
|
@@ -770,7 +770,7 @@ 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
|
|
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.
|
|
774
774
|
|
|
775
775
|
Set `throughline_source_session` together with a non-empty mission in `prompt` to prepend
|
|
776
776
|
Throughline's read-only handoff context. This optional route requires `throughline >= 0.9.0`,
|
package/dist/core.js
CHANGED
|
@@ -54,7 +54,7 @@ import { readLinuxProcessRegistrationIdentity, readRuntimeProcesses, readProcess
|
|
|
54
54
|
import { liveNodeExecutable } from "./live-node.js";
|
|
55
55
|
import { resolveClaudeConfigurationRoot, withClaudeConfigRoot } from "./claude-config-root.js";
|
|
56
56
|
import { AitermError, AgentResumeUnavailableError, AgentResumeError, telemetryOwnedFailure, ownTelemetryFailure } from "./errors.js";
|
|
57
|
-
import { isWin, SOCKDIR, SOCK, tmuxCommand, readOnlyTmuxList, PtyDiagnosticError, tmuxCommandWithInput, sendPsmuxPayload, loadPtyBufferChunk, pasteBufferBaseArgs, tmuxNewSession, withNativeSessionCreation, withNativeSessionTarget, hasVerifiedNativeSessionTarget, registeredSessionEnvironment, registerSessionEnvironment, attachCommand, normalizePaneCommand, atomicShellMultiline, appendMarkSentinel, paneShellForSubmission, adaptShellSubmission, settlePaneLog, paneCwdArgument, sessionEnvironmentLaunch, paneCommandArgs, } from "./tmux-runtime.js";
|
|
57
|
+
import { isWin, SOCKDIR, SOCK, tmuxCommand, readOnlyTmuxList, PtyDiagnosticError, tmuxCommandWithInput, sendPsmuxPayload, loadPtyBufferChunk, pasteBufferBaseArgs, tmuxNewSession, withNativeSessionCreation, withNativeSessionTarget, hasVerifiedNativeSessionTarget, withNativeSessionSetupRollback, hasNativeSessionSetupRollback, registeredSessionEnvironment, registerSessionEnvironment, attachCommand, normalizePaneCommand, atomicShellMultiline, appendMarkSentinel, paneShellForSubmission, adaptShellSubmission, settlePaneLog, paneCwdArgument, sessionEnvironmentLaunch, paneCommandArgs, } from "./tmux-runtime.js";
|
|
58
58
|
import { AGENT_DEFAULT_PREFACE, sleep, currentUid, runtimeStateBase, safeStatSize, readFileRange, writeJson0600, createEmpty0600, shq, LAUNCH_ID_RE, AGENT_LINEAGE_RE, AGENT_DONE_POLL_MS, AGENT_RATE_LIMIT_POLL_MS, pollGate, AGENT_EVENT_MAX_BYTES, assertSessionName, agentsDir, readAgentGeneration, selectAgentMetadataFile, publishAgentGeneration, agentMetadataPath, writeAgentMetadata, AGENT_EVENT_TAIL_BYTES, agentLabel, agentHarness, subagentInstruction, } from "./agent-shared.js";
|
|
59
59
|
import { AuthResponseError, authUi, authPromptDigest, authBindingSchema, authResponseSchema } from "./agent-auth-ui.js";
|
|
60
60
|
import { processStartIdentity } from "./runtime-error-os.js";
|
|
@@ -663,106 +663,111 @@ export function openSession(name, shell = "bash", envVars = []) {
|
|
|
663
663
|
function openSessionInternal(name, shell, envVars, preserveAgentState) {
|
|
664
664
|
assertExecutionContext(name);
|
|
665
665
|
shell = resolveWinPaneShell(shell);
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
try {
|
|
671
|
-
fs.mkdirSync(SOCKDIR, { recursive: true });
|
|
672
|
-
}
|
|
673
|
-
catch (error) {
|
|
674
|
-
ownTelemetryFailure("AITERM.PERSISTENCE_WRITE_FAILED", error);
|
|
675
|
-
}
|
|
676
|
-
// macOS標準bashの移行bannerを抑止する。環境変数の注入方法はterminal runtimeが所有する。
|
|
677
|
-
const banner = process.platform === "darwin" && path.basename(shell) === "bash"
|
|
678
|
-
? ["BASH_SILENCE_DEPRECATION_WARNING=1"]
|
|
679
|
-
: [];
|
|
680
|
-
// 並行性対策: 複数エージェントが同時に名前なし open すると autoName が同じ t{i} を返し得る(TOCTOU)。
|
|
681
|
-
// 自動採番は初回のみ読みやすい t{i}、衝突したら乱数 nonce 名でリトライする(線形リトライは高並行で
|
|
682
|
-
// 全員が同じ空き番号に殺到してスケールしない)。明示名は既存ならエラー(呼び手責任=意図的共有と区別)。
|
|
683
|
-
const explicit = !!name;
|
|
684
|
-
let nm = name || autoName();
|
|
685
|
-
assertSessionName(nm);
|
|
686
|
-
for (let attempt = 0;; attempt++) {
|
|
687
|
-
if (attempt >= 20)
|
|
688
|
-
throw new AitermError("openSession: 自動採番のリトライ上限(tmux new-session が重複以外で失敗し続けている可能性)", 2);
|
|
689
|
-
if (sessionExists(nm)) {
|
|
690
|
-
if (explicit)
|
|
691
|
-
throw new AitermError(`session '${nm}' は既に存在します(list で確認)`, 2);
|
|
666
|
+
return withNativeSessionSetupRollback(shell, () => {
|
|
667
|
+
for (const key of envVars) {
|
|
668
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key))
|
|
669
|
+
throw new AitermError("env_varsの環境変数名が不正です", 2);
|
|
692
670
|
}
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
671
|
+
try {
|
|
672
|
+
fs.mkdirSync(SOCKDIR, { recursive: true });
|
|
673
|
+
}
|
|
674
|
+
catch (error) {
|
|
675
|
+
ownTelemetryFailure("AITERM.PERSISTENCE_WRITE_FAILED", error);
|
|
676
|
+
}
|
|
677
|
+
// macOS標準bashの移行bannerを抑止する。環境変数の注入方法はterminal runtimeが所有する。
|
|
678
|
+
const banner = process.platform === "darwin" && path.basename(shell) === "bash"
|
|
679
|
+
? ["BASH_SILENCE_DEPRECATION_WARNING=1"]
|
|
680
|
+
: [];
|
|
681
|
+
// 並行性対策: 複数エージェントが同時に名前なし open すると autoName が同じ t{i} を返し得る(TOCTOU)。
|
|
682
|
+
// 自動採番は初回のみ読みやすい t{i}、衝突したら乱数 nonce 名でリトライする(線形リトライは高並行で
|
|
683
|
+
// 全員が同じ空き番号に殺到してスケールしない)。明示名は既存ならエラー(呼び手責任=意図的共有と区別)。
|
|
684
|
+
const explicit = !!name;
|
|
685
|
+
let nm = name || autoName();
|
|
686
|
+
assertSessionName(nm);
|
|
687
|
+
for (let attempt = 0;; attempt++) {
|
|
688
|
+
if (attempt >= 20)
|
|
689
|
+
throw new AitermError("openSession: 自動採番のリトライ上限(tmux new-session が重複以外で失敗し続けている可能性)", 2);
|
|
690
|
+
if (sessionExists(nm)) {
|
|
691
|
+
if (explicit)
|
|
692
|
+
throw new AitermError(`session '${nm}' は既に存在します(list で確認)`, 2);
|
|
693
|
+
}
|
|
694
|
+
else {
|
|
695
|
+
const environment = [...banner, ...envVars.filter(key => key !== "AITERM_SESSION_ID" && launchEnvValue(key) !== undefined)
|
|
696
|
+
.map(key => `${key}=${launchEnvValue(key)}`), `AITERM_SESSION_ID=${nm}`];
|
|
697
|
+
const launch = sessionEnvironmentLaunch(shell, environment);
|
|
698
|
+
const r = tmuxNewSession(true, nm, launch, environment.map(entry => entry.slice(0, entry.indexOf("="))));
|
|
699
|
+
if (r.code === 0) {
|
|
700
|
+
if (launch.register_after_start)
|
|
701
|
+
for (const entry of environment) {
|
|
702
|
+
const at = entry.indexOf("=");
|
|
703
|
+
const registered = tmux("set-environment", "-t", nm, entry.slice(0, at), entry.slice(at + 1));
|
|
704
|
+
if (registered.code !== 0) {
|
|
705
|
+
if (!hasNativeSessionSetupRollback())
|
|
706
|
+
tmux("kill-session", "-t", nm);
|
|
707
|
+
throw new AitermError("session環境変数を登録できません", 2);
|
|
708
|
+
}
|
|
706
709
|
}
|
|
707
|
-
|
|
708
|
-
|
|
710
|
+
break;
|
|
711
|
+
}
|
|
712
|
+
// 自動採番かつ「重複名」由来の失敗(他エージェントが同名を先に取った)なら次名でリトライ。
|
|
713
|
+
const dup = /duplicate|already exists/i.test(r.stderr);
|
|
714
|
+
if (explicit || !dup)
|
|
715
|
+
throw new AitermError("tmux new-session 失敗: " + r.stderr.trim(), 2);
|
|
709
716
|
}
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
if (explicit || !dup)
|
|
713
|
-
throw new AitermError("tmux new-session 失敗: " + r.stderr.trim(), 2);
|
|
717
|
+
nm = nonceName();
|
|
718
|
+
assertSessionName(nm);
|
|
714
719
|
}
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
// 新規セッションの .log は必ず truncate する。"a"(追記)だと外部 kill / killAll / クラッシュで
|
|
719
|
-
// 同名 session だけ消えて .log が残った場合、offset=0 と相まって旧出力を新規として返す(B5)。
|
|
720
|
-
// break は new-session 成功後にのみ到達=作りたての空 session ゆえ切り詰めは安全。lastcmd/mark 残骸も掃除。
|
|
721
|
-
try {
|
|
722
|
-
fs.writeFileSync(logpath(nm), "");
|
|
723
|
-
}
|
|
724
|
-
catch (error) {
|
|
725
|
-
ownTelemetryFailure("AITERM.PERSISTENCE_WRITE_FAILED", error);
|
|
726
|
-
}
|
|
727
|
-
for (const p of [lastcmdpath(nm), markpath(nm)]) {
|
|
720
|
+
// 新規セッションの .log は必ず truncate する。"a"(追記)だと外部 kill / killAll / クラッシュで
|
|
721
|
+
// 同名 session だけ消えて .log が残った場合、offset=0 と相まって旧出力を新規として返す(B5)。
|
|
722
|
+
// break は new-session 成功後にのみ到達=作りたての空 session ゆえ切り詰めは安全。lastcmd/mark 残骸も掃除。
|
|
728
723
|
try {
|
|
729
|
-
fs.
|
|
724
|
+
fs.writeFileSync(logpath(nm), "");
|
|
730
725
|
}
|
|
731
|
-
catch {
|
|
732
|
-
|
|
726
|
+
catch (error) {
|
|
727
|
+
ownTelemetryFailure("AITERM.PERSISTENCE_WRITE_FAILED", error);
|
|
733
728
|
}
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
//
|
|
747
|
-
|
|
748
|
-
|
|
729
|
+
for (const p of [lastcmdpath(nm), markpath(nm)]) {
|
|
730
|
+
try {
|
|
731
|
+
fs.unlinkSync(p);
|
|
732
|
+
}
|
|
733
|
+
catch {
|
|
734
|
+
/* noop */
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
if (!preserveAgentState)
|
|
738
|
+
cleanupAgentState(nm);
|
|
739
|
+
// pipe-pane の引数は tmux 内部の /bin/sh -c で再解釈される(argv ではない)。パスは単一引用符で包み、
|
|
740
|
+
// パス自身の ' は '\'' イディオムでエスケープする(名前は検証済みだが、Windows ユーザー名 O'Brien 等が
|
|
741
|
+
// 一時パスに ' を持ち込み redirect を壊すのを防ぐ。空白対策も兼ねる)。
|
|
742
|
+
// Windows の psmux は `cat > <path>` を in-process の直接ファイルsinkとして処理する
|
|
743
|
+
// (psmux e3e4b71 以降)。パスは Windows 形のまま渡す。
|
|
744
|
+
const pipeTarget = logpath(nm);
|
|
745
|
+
const quoted = `'${pipeTarget.replace(/'/g, "'\\''")}'`;
|
|
746
|
+
const pr = tmux("pipe-pane", "-t", nm, "-o", `cat >> ${quoted}`);
|
|
747
|
+
if (pr.code !== 0) {
|
|
748
|
+
// 配管に失敗した session は pty_read が永遠に空を返す=成功を装わない。作った session を片付けて明示エラー。
|
|
749
|
+
if (!hasNativeSessionSetupRollback()) {
|
|
750
|
+
try {
|
|
751
|
+
tmuxCleanup("kill-session", "-t", nm);
|
|
752
|
+
}
|
|
753
|
+
catch { /* cleanup failure is not a second observation */ }
|
|
754
|
+
try {
|
|
755
|
+
fs.unlinkSync(logpath(nm)); // B14: 直前に作った空 .log も残さない
|
|
756
|
+
}
|
|
757
|
+
catch {
|
|
758
|
+
/* noop */
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
ownTelemetryFailure("AITERM.PERSISTENCE_WRITE_FAILED", new AitermError("tmux pipe-pane 失敗(出力ログを配管できないため session を破棄): " + pr.stderr.trim(), 2), 2);
|
|
749
762
|
}
|
|
750
|
-
catch { /* cleanup failure is not a second observation */ }
|
|
751
763
|
try {
|
|
752
|
-
|
|
764
|
+
writeOffset(nm, 0);
|
|
753
765
|
}
|
|
754
|
-
catch {
|
|
755
|
-
|
|
766
|
+
catch (error) {
|
|
767
|
+
ownTelemetryFailure("AITERM.PERSISTENCE_WRITE_FAILED", error);
|
|
756
768
|
}
|
|
757
|
-
|
|
758
|
-
}
|
|
759
|
-
try {
|
|
760
|
-
writeOffset(nm, 0);
|
|
761
|
-
}
|
|
762
|
-
catch (error) {
|
|
763
|
-
ownTelemetryFailure("AITERM.PERSISTENCE_WRITE_FAILED", error);
|
|
764
|
-
}
|
|
765
|
-
return [nm, attachHint(nm)];
|
|
769
|
+
return [nm, attachHint(nm)];
|
|
770
|
+
});
|
|
766
771
|
}
|
|
767
772
|
export const AGENT_PREFACE_MAX_CHARS = 200;
|
|
768
773
|
// 行頭のASCII記号と空白は、入力欄が命令として読む(Claude Codeの`/`・`!`・`#`・`?`など)。`@`は文中でも候補の枠を開く。
|
|
@@ -4529,8 +4534,9 @@ async function sendAgentPromptText(name, text, kind, inputMeta) {
|
|
|
4529
4534
|
// 利用者が端末で済ませるしかない起動前の状態。reasonだけでは直し方が分からないので案内を添える。
|
|
4530
4535
|
function startupBlockedHint(reason) {
|
|
4531
4536
|
if (reason === "vendor_onboarding_required") {
|
|
4532
|
-
return "\nClaude Code
|
|
4533
|
-
"
|
|
4537
|
+
return "\nClaude Codeの初回案内(テーマ・ログイン方法の選択)か、利用規約の更新への回答が済んでいません。`claude auth status` がログイン済みでも、" +
|
|
4538
|
+
"済むまでは起動のたびにこの画面で止まります。規約への回答はアカウントの持ち主が選ぶもので、Aitermは答えません。" +
|
|
4539
|
+
"対象端末で一度 `claude` を起動し、画面の案内を最後まで進めてください。";
|
|
4534
4540
|
}
|
|
4535
4541
|
return "";
|
|
4536
4542
|
}
|
package/dist/harnesses/claude.js
CHANGED
|
@@ -344,8 +344,10 @@ export function assertClaudeAuthenticationReady(bin, env = process.env) {
|
|
|
344
344
|
"通常端末で `claude doctor` を実行し、Keychain/credential storeを直してから一度だけ `claude auth login` を実行してください。" +
|
|
345
345
|
"aiterm相関付きClaude session内で /login を繰り返さないでください。");
|
|
346
346
|
}
|
|
347
|
-
|
|
348
|
-
|
|
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は作成していません。" +
|
|
349
351
|
"`claude auth status --json` と `claude doctor` が成功することを通常端末で確認してください。");
|
|
350
352
|
}
|
|
351
353
|
/**
|
|
@@ -408,6 +410,11 @@ function claudeSecurityNotes(screen) {
|
|
|
408
410
|
return lines.slice(lastMarker + 1).some(line => /^\s*Security notes:\s*$/.test(line))
|
|
409
411
|
&& /Press (?:Enter|Return) to continue/u.test(lines.slice(lastMarker + 1).join("\n"));
|
|
410
412
|
}
|
|
413
|
+
// Claude Code 2.1.318 (grove): "Updates to Consumer Terms and Policies" with "Accept terms · Help improve our AI models: ON/OFF".
|
|
414
|
+
export function claudeConsumerTermsUpdate(screen) {
|
|
415
|
+
const tail = screen.split("\n").slice(-32).join("\n");
|
|
416
|
+
return tail.includes("Updates to Consumer Terms and Policies") && /^\s*[❯>]?\s*(?:\d+\.\s*)?Accept terms\b/mu.test(tail);
|
|
417
|
+
}
|
|
411
418
|
export function claudeTuiReady(screen) {
|
|
412
419
|
if (!screen.includes("Claude Code") && !claudeComposerBox(screen))
|
|
413
420
|
return false;
|
|
@@ -483,6 +490,10 @@ export function claudePaneObservation(screen) {
|
|
|
483
490
|
return { state: "busy", reason: "turn_running" };
|
|
484
491
|
if (claudeTuiReady(screen))
|
|
485
492
|
return { state: "idle", reason: "composer_ready" };
|
|
493
|
+
// The account holder's own choice (terms and model-training data); never answered by Aiterm. After ready, so a seat
|
|
494
|
+
// that merely talks about this screen stays idle.
|
|
495
|
+
if (claudeConsumerTermsUpdate(screen))
|
|
496
|
+
return { state: "blocked", reason: "vendor_onboarding_required" };
|
|
486
497
|
if (/new MCP servers? found in this project/i.test(tail))
|
|
487
498
|
return { state: "blocked", reason: "project_mcp_consent" };
|
|
488
499
|
if (claudeStartupAction(screen, false))
|
package/dist/setup.js
CHANGED
|
@@ -41,13 +41,16 @@ export function globalRegistration(run = runSetupCommand, options = {}) {
|
|
|
41
41
|
}
|
|
42
42
|
export async function verifySetupRuntime(registration) {
|
|
43
43
|
const client = new Client({ name: "aiterm-setup", version: "1.0.0" });
|
|
44
|
-
|
|
44
|
+
// The SDK default passes only HOME/PATH/SHELL/TERM/USER/LOGNAME; without TMPDIR the probe would use another socket directory.
|
|
45
|
+
const transport = new StdioClientTransport({ ...registration, env: process.env, stderr: "pipe" });
|
|
45
46
|
transport.stderr?.on("data", (chunk) => process.stderr.write(chunk));
|
|
46
47
|
const name = `setup-${randomUUID().slice(0, 12)}`;
|
|
47
48
|
const call = async (tool, args) => {
|
|
48
49
|
const result = await client.request({ method: "tools/call", params: { name: tool, arguments: args } }, CallToolResultSchema, { timeout: 25_000 });
|
|
49
|
-
if (result.isError)
|
|
50
|
-
|
|
50
|
+
if (result.isError) {
|
|
51
|
+
const detail = result.content.filter((item) => item.type === "text").map((item) => item.text).join(" ").slice(0, 300);
|
|
52
|
+
throw new SetupError("runtime_probe_failed", `${tool}が失敗しました${detail ? `: ${detail}` : ""}`);
|
|
53
|
+
}
|
|
51
54
|
return result;
|
|
52
55
|
};
|
|
53
56
|
await client.connect(transport);
|
package/dist/tmux-runtime.js
CHANGED
|
@@ -5,7 +5,7 @@ import { spawnSync } from "node:child_process";
|
|
|
5
5
|
import * as fs from "node:fs";
|
|
6
6
|
import * as path from "node:path";
|
|
7
7
|
import * as os from "node:os";
|
|
8
|
-
import { createHash } from "node:crypto";
|
|
8
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
10
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
11
11
|
import stringWidth from 'string-width';
|
|
@@ -15,7 +15,7 @@ import { ExecutionError } from "./execution-wire.js";
|
|
|
15
15
|
import { parseNativeSessionReceipt, nativePaneTarget, nativeSessionTarget, nativeSessionCondition } from "./native-session.js";
|
|
16
16
|
const nativeTargets = new AsyncLocalStorage();
|
|
17
17
|
const nativeReads = new Set(["list-sessions", "list-commands", "list-panes", "list-windows", "has-session", "display-message", "capture-pane", "show-environment", "show-options"]);
|
|
18
|
-
const nativePanes = new Set(["send-keys", "paste-buffer", "pipe-pane", "capture-pane", "display-message", "list-panes"]);
|
|
18
|
+
const nativePanes = new Set(["send-keys", "paste-buffer", "pipe-pane", "capture-pane", "display-message", "list-panes", "rename-window", "set-window-option"]);
|
|
19
19
|
const nativeTargetUnavailable = () => new AitermError("AGENT_RESUME_UNCONFIRMED: 復帰したnative端末の本人性を確認できません。", 2);
|
|
20
20
|
function verifyNativeTarget(frame) {
|
|
21
21
|
if (frame.checking)
|
|
@@ -48,6 +48,44 @@ export function withNativeSessionCreation(session, created, verify, body) {
|
|
|
48
48
|
throw nativeTargetUnavailable();
|
|
49
49
|
return nativeTargets.run({ session, target: null, created, verify }, body);
|
|
50
50
|
}
|
|
51
|
+
const CREATION_TOKEN_OPTION = "@aiterm_create_token";
|
|
52
|
+
export function hasNativeSessionSetupRollback() { return !!nativeTargets.getStore()?.setup; }
|
|
53
|
+
/** Only the native setup is transactional; later readiness may intentionally retain a live agent. */
|
|
54
|
+
export function withNativeSessionSetupRollback(shell, body) {
|
|
55
|
+
const frame = nativeTargets.getStore();
|
|
56
|
+
if (!frame?.created || frame.setup)
|
|
57
|
+
return body();
|
|
58
|
+
const token = randomBytes(16).toString("hex");
|
|
59
|
+
const setup = { token, window: `aiterm-create-${token}`, shell: path.basename(shell), target: null };
|
|
60
|
+
frame.setup = setup;
|
|
61
|
+
try {
|
|
62
|
+
return body();
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if (setup.target) {
|
|
66
|
+
try {
|
|
67
|
+
const closed = creationCommand(setup, ["kill-session", "-t", setup.target.session_id], true);
|
|
68
|
+
// An already absent native is a finished rollback: the created callback may have closed it.
|
|
69
|
+
if (closed.code !== 0 && creationCommand(setup, ["has-session", "-t", setup.target.session_id]).code === 0)
|
|
70
|
+
throw nativeTargetUnavailable();
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
if (error instanceof Error)
|
|
74
|
+
error.message += "\ncreation_rollback_unconfirmed: 作成した端末の片付けを確認できません。";
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
delete frame.setup;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// This scope is private to marker transfer and rollback; ordinary effects still require OS birth identity.
|
|
84
|
+
function creationCommand(setup, args, allowRefusal = false) {
|
|
85
|
+
const target = setup.target;
|
|
86
|
+
const creationCondition = `#{||:#{==:#{window_name},${setup.window}},#{==:#{${CREATION_TOKEN_OPTION}},${setup.token}}}`;
|
|
87
|
+
return nativeTargets.run({ session: target.session_id, target, verify: () => { }, creationCondition, allowRefusal }, () => runTmux(false, undefined, args));
|
|
88
|
+
}
|
|
51
89
|
function captureNativeSessionReceipt(receipt) {
|
|
52
90
|
const frame = nativeTargets.getStore();
|
|
53
91
|
if (!frame?.created || frame.target)
|
|
@@ -63,6 +101,23 @@ function captureNativeSessionReceipt(receipt) {
|
|
|
63
101
|
throw nativeTargetUnavailable();
|
|
64
102
|
frame.session = target.session_id;
|
|
65
103
|
frame.target = target;
|
|
104
|
+
if (frame.setup) {
|
|
105
|
+
const setup = frame.setup;
|
|
106
|
+
setup.target = { ...target };
|
|
107
|
+
const commands = [["set-option", "-t", target.session_id, CREATION_TOKEN_OPTION, setup.token],
|
|
108
|
+
["rename-window", "-t", target.session_id, setup.shell]];
|
|
109
|
+
if (isWin) {
|
|
110
|
+
const inherited = creationCommand(setup, ["show-options", "-t", target.session_id, "-v", "automatic-rename"]);
|
|
111
|
+
if (inherited.code !== 0 || !["on", "off"].includes(inherited.stdout.trim()))
|
|
112
|
+
throw nativeTargetUnavailable();
|
|
113
|
+
commands.push(["set-window-option", "-t", target.session_id, "automatic-rename", inherited.stdout.trim()]);
|
|
114
|
+
}
|
|
115
|
+
else
|
|
116
|
+
commands.push(["set-window-option", "-t", target.session_id, "-u", "automatic-rename"]);
|
|
117
|
+
for (const command of commands)
|
|
118
|
+
if (creationCommand(setup, command).code !== 0)
|
|
119
|
+
throw nativeTargetUnavailable();
|
|
120
|
+
}
|
|
66
121
|
frame.created({ ...frame.target });
|
|
67
122
|
verifyNativeTarget(frame);
|
|
68
123
|
}
|
|
@@ -114,7 +169,9 @@ function nativeConditionalArgs(args) {
|
|
|
114
169
|
const target = nativeTargets.getStore()?.target;
|
|
115
170
|
if (!target || nativeReads.has(args[0]) || args[0] === "delete-buffer")
|
|
116
171
|
return args;
|
|
117
|
-
const
|
|
172
|
+
const frame = nativeTargets.getStore();
|
|
173
|
+
const nativeCondition = nativeSessionCondition(target, frame.allowExitedPane);
|
|
174
|
+
const condition = frame.creationCondition ? `#{&&:${nativeCondition},${frame.creationCondition}}` : nativeCondition;
|
|
118
175
|
const quote = (value) => isWin
|
|
119
176
|
? `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`
|
|
120
177
|
: `'${value.replace(/'/g, "'\\''")}'`;
|
|
@@ -431,7 +488,7 @@ function runTmux(observe, input, args, session, deadline) {
|
|
|
431
488
|
ptyDependencyError(tmuxMissingMessage(), observe);
|
|
432
489
|
}
|
|
433
490
|
const native = nativeTargets.getStore();
|
|
434
|
-
if (native?.target && args[0] === "if-shell" && (r.stdout ?? "").trim() === NATIVE_REFUSED)
|
|
491
|
+
if (native?.target && !native.allowRefusal && args[0] === "if-shell" && (r.stdout ?? "").trim() === NATIVE_REFUSED)
|
|
435
492
|
throw nativeTargetUnavailable();
|
|
436
493
|
if (native?.target && r.status !== 0)
|
|
437
494
|
verifyNativeTarget(native);
|
|
@@ -697,13 +754,19 @@ export function tmuxNewSession(observe, name, launch, registered = []) {
|
|
|
697
754
|
}
|
|
698
755
|
const printNative = pinned ? ["-P", "-F", "#{session_id}\t#{session_name}\t#{pid}\t#{pane_id}\t#{pane_pid}"]
|
|
699
756
|
: guarded ? ["-P", "-F", "#{session_id}\t#{session_name}\t#{pid}"] : [];
|
|
757
|
+
const witness = nativeTargets.getStore()?.setup;
|
|
758
|
+
if (witness)
|
|
759
|
+
printNative.push("-n", witness.window);
|
|
700
760
|
if (isWin) {
|
|
701
761
|
const result = runTmux(observe, undefined, ["new-session", "-d", "-s", name, ...printNative, ...launch.args, "-f", TMUX_EMPTY_CONFIG, launch.shell]);
|
|
702
762
|
if (result.code === 0) {
|
|
703
763
|
if (pinned) {
|
|
704
764
|
try {
|
|
705
|
-
|
|
765
|
+
const receipt = parseNativeSessionReceipt(result.stdout);
|
|
766
|
+
if (receipt.session_id !== name)
|
|
706
767
|
throw nativeTargetUnavailable();
|
|
768
|
+
if (witness)
|
|
769
|
+
witness.target = receipt;
|
|
707
770
|
}
|
|
708
771
|
catch {
|
|
709
772
|
throw nativeTargetUnavailable();
|
package/docs/DESIGN.md
CHANGED
|
@@ -366,6 +366,7 @@ hookを外す時は`aiterm-setup --remove-cursor-parent-hooks`で専用entryだ
|
|
|
366
366
|
`trust_project:true`は対象projectの既知のworkspace、hooks、MCP初期同意を起動準備として進める意図である。
|
|
367
367
|
Claude Codeの初回テーマ選択は選択済みの項目を確定し、後続の起動準備へ進める。
|
|
368
368
|
ログイン方式の選択はユーザーのアカウント設定として扱い、composerと誤認せず`vendor_onboarding_required`で止める。
|
|
369
|
+
利用規約の更新の画面(「Updates to Consumer Terms and Policies」、`Accept terms`の選択肢)も、規約への同意と学習へのデータ利用の選択はアカウントの持ち主が決めるので、Aitermは答えず`vendor_onboarding_required`で止める(Mac 2026-11-10、`unrecognized_screen`で166秒待っていた)。
|
|
369
370
|
promptなしでも入力受付とharness生存を確認して`startup.ready`を返す。指定なしのpromptなし起動は
|
|
370
371
|
従来どおり`startup.not_checked`で返す。初手receiptは未要求・未送信・送信済み未確認・開始確認を分ける。
|
|
371
372
|
入力受付の待ちは30秒。画面が起動コマンドの表示のまま(agentがまだ何も描いていない)で切れた時だけ、
|
|
@@ -538,7 +539,7 @@ Claude authentication URL receipts recognize the official claude.com/cai/oauth/a
|
|
|
538
539
|
|
|
539
540
|
### 認証画面と専用応答
|
|
540
541
|
|
|
541
|
-
Claude起動前の公式auth status拒否はharnessが`AgentAuthenticationPreflightError`として所有し、通常MCPのfailが`aiterm.agent-launch-error.v1`へ投影する。既存数値exit code
|
|
542
|
+
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の終端とは分ける。
|
|
542
543
|
|
|
543
544
|
`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欄を必ず設定する。
|
|
544
545
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiterm-mcp",
|
|
3
|
-
"version": "0.70.
|
|
3
|
+
"version": "0.70.2",
|
|
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": [
|