aiterm-mcp 0.63.10 → 0.63.12

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.63.12] - 2026-11-07
11
+
12
+ - Remove filesystem input locks and the legacy socket/log-directory readiness predicate from managed-agent send and fresh-launch admission. Keep process-local order, current launch/native identity and stable TUI readiness checks. Independent local MCP and remote callers now serialize the same agent seat themselves; ordinary PTY/shell and standalone auth/approval file exclusion remain unchanged.
13
+ - Distinguish pre-input native absence (`AGENT_INPUT_TARGET_UNAVAILABLE`) from an actual TUI readiness refusal (`AGENT_INPUT_NOT_READY`) in error text. Public schemas/options are unchanged; these labels do not retrospectively identify older generic failures or prove vendor acceptance.
14
+
15
+ ## [0.63.11] - 2026-11-06
16
+
17
+ - Let any MCP client opt into existing host-controller routing with the initialize experimental capability `io.github.kitepon/aiterm-mcp/host-controller: {}`. The exact `bellteam` client name remains a backward-compatible alias; undeclared clients retain ordinary direct routing.
18
+ - Use the initialized controller name for interim/follow metadata opt-in, with a generic fallback and the existing `BellTeam` marker retained for compatibility. This is routing identity, not authentication; all generation/source/effect guards and resume-only wire contracts remain unchanged.
19
+
10
20
  ## [0.63.10] - 2026-11-06
11
21
 
12
22
  - Resume a killed working Codex conversation whose native metadata has not yet bound its vendor ID, using only its unique launch-marked, cwd-matching, non-fork, complete retained root rollout and same-turn settings.
@@ -3053,7 +3063,9 @@ prototype (preserved under `prototype/python/` as the porting source and referen
3053
3063
  `ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
3054
3064
  provenance.
3055
3065
 
3056
- [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.63.10...HEAD
3066
+ [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.63.12...HEAD
3067
+ [0.63.12]: https://github.com/kitepon/aiterm-mcp/compare/v0.63.11...v0.63.12
3068
+ [0.63.11]: https://github.com/kitepon/aiterm-mcp/compare/v0.63.10...v0.63.11
3057
3069
  [0.63.10]: https://github.com/kitepon/aiterm-mcp/compare/v0.63.9...v0.63.10
3058
3070
  [0.63.9]: https://github.com/kitepon/aiterm-mcp/compare/v0.63.8...v0.63.9
3059
3071
  [0.63.8]: https://github.com/kitepon/aiterm-mcp/compare/v0.63.7...v0.63.8
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.63.10** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
218
+ **状態:** 開発継続中 · 現行公開版 **v0.63.12** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
219
219
 
220
220
  ### 更新と巻き戻し
221
221
 
@@ -786,7 +786,7 @@ agent_launch({ "harness": "codex-cli", "remote": { "host": "rabbit" }, "cwd": "/
786
786
 
787
787
  `pty_send` はコマンドやpromptの意味を判定せず、指定された本文を端末へ送る。既定ではESC・ブラケットペースト終端などをサニタイズし、`pty_read`も制御文字を無害化して返す(`raw: true`はそのまま扱う)。コマンドの許可・拒否はshell、接続先、起動したharnessが所有する。
788
788
 
789
- 1回の `pty_send` が受理する本文はUTF-8で最大64KiB。同一sessionへの送信はaiterm processをまたいで直列化し、chunk同士の混線を防ぐ。全OSで長いPTY入力の欠落を避けるためplatformのmultiplexerへUTF-8境界を壊さない256-byte単位でpasteし、chunk間に10msのdrain間隔を置く。POSIX shellまたはPowerShellが前面にいる時のsanitize済み複数行は、改行を含まない単一入力へ符号化する。POSIXは`eval`、PowerShellはUTF-8のBase64を復元したscriptblockのdot-sourceを使い、変数と作業場所を現在のshellに保つ。shellがscript全体を所有してから先頭行を実行するため、途中で起動したpager/REPLが後続行を対話キーとして奪わない。単一行、`raw:true`、非shell前面は従来どおり直接PTYへpasteする。agent dispatchは本文全体を`ESC[200~/201~`で1回だけ包み、包んだ全体を同じchunkで流す。agent TUIには1回の貼り付けに見えるので画像pathが貼り付けの間で切れず、chunk投入中のキー解釈による語中文字化け・submit取り落としも抑える。途中chunkが失敗した場合は部分送信済みであることを明示し、自動でEnterを押さない。送信processの異常終了でlockが残った場合は送信前にfail-closedする。`pty_list`で対象sessionを確認し、`pty_close`で閉じてから同じsession IDを作り直す。公開の一括停止toolは存在しない。 POSIXの明示native execution構成では、unknown sendになった対象1席も`pty_close`で閉じて再作成できる。元requestはunknownのまま保持し、再送しない。発行中の操作、管理close自体のunknown、native identityが不明な席は引き続き拒否する。
789
+ 1回の `pty_send` が受理する本文はUTF-8で最大64KiB。Managed-agent callers serialize operations for the same seat across independent local MCP and remote clients. Aiterm keeps process-local ordering/native ownership; agent input has no filesystem send-lock or legacy directory readiness prerequisite. Ordinary PTY/shell and standalone auth/approval retain existing file exclusion.全OSで長いPTY入力の欠落を避けるためplatformのmultiplexerへUTF-8境界を壊さない256-byte単位でpasteし、chunk間に10msのdrain間隔を置く。POSIX shellまたはPowerShellが前面にいる時のsanitize済み複数行は、改行を含まない単一入力へ符号化する。POSIXは`eval`、PowerShellはUTF-8のBase64を復元したscriptblockのdot-sourceを使い、変数と作業場所を現在のshellに保つ。shellがscript全体を所有してから先頭行を実行するため、途中で起動したpager/REPLが後続行を対話キーとして奪わない。単一行、`raw:true`、非shell前面は従来どおり直接PTYへpasteする。agent dispatchは本文全体を`ESC[200~/201~`で1回だけ包み、包んだ全体を同じchunkで流す。agent TUIには1回の貼り付けに見えるので画像pathが貼り付けの間で切れず、chunk投入中のキー解釈による語中文字化け・submit取り落としも抑える。途中chunkが失敗した場合は部分送信済みであることを明示し、自動でEnterを押さない。For ordinary PTY/shell input, a lock left by a terminated sender still fails closed.`pty_list`で対象sessionを確認し、`pty_close`で閉じてから同じsession IDを作り直す。公開の一括停止toolは存在しない。 POSIXの明示native execution構成では、unknown sendになった対象1席も`pty_close`で閉じて再作成できる。元requestはunknownのまま保持し、再送しない。発行中の操作、管理close自体のunknown、native identityが不明な席は引き続き拒否する。
790
790
 
791
791
  BellTeamのmodel・effort・fast変更も、既存session世代に結合したnative管理要求で受け付ける。途中で世代・受付枠・停止状態が変われば、それ以降の打鍵を止める。途中まで変更した結果は作用不明のまま保持し、自動でやり直さない。
792
792
 
@@ -889,3 +889,8 @@ Grok 1.0.70のLinux読取は公式active_sessions.jsonのPID・開始tick・cwd
889
889
  対象はLinux/Codex。明示した永続保存先 `AITERM_STATE_BASE`、同じUIDと絶対パス、元のCodex会話記録の保持が必要。呼出側は保存前に元runtimeの全書込processを停止し、再起動を防ぐ。復元は新runtimeの起動時排他を取得してから、通常の初期化やnative起動より前に行う。保存成功は全process停止の証明にはならない。
890
890
 
891
891
  初回更新で既に失われた旧tmpfsの状態と、未配送の回答は復元しない。通常の初期化後に復元入力を再使用しない。復元した保存先を旧版へそのまま戻さず、互換性のある別の保存先と会話の控えを使うか、利用者が明示して状態を初期化する。詳細は[保存・復元の契約と図](https://github.com/kitepon/aiterm-mcp/blob/v0.63.3/docs/architecture/resume-checkpoint.md)と[更新・巻き戻し条件](CHANGELOG.md)を参照する。
892
+
893
+
894
+ ### Host-controller clients
895
+
896
+ Any MCP client can opt into the existing host-orchestration routing by declaring `capabilities.experimental["io.github.kitepon/aiterm-mcp/host-controller"] = {}` during initialize. This is routing identity, not authentication; source, generation, native identity and effect guards still apply. Clients without that declaration stay on the ordinary direct path. The exact client name `bellteam` remains a backward-compatible alias. A declared controller requests interim/follow metadata with `_meta["aiterm/caller"]` equal to its initialized client name (blank/missing name: `MCP client`); the old `BellTeam` marker is also preserved for compatibility. See [function map and data flow](https://github.com/kitepon/aiterm-mcp/blob/main/docs/architecture/host-controller.md). BellTeam's own caller can adopt the capability later; that migration is separate from this release.
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.63.10** · 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.63.12** · 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
 
@@ -844,7 +844,7 @@ Ordinary delivery and parent-return hooks do not acquire or wait for the shared
844
844
 
845
845
  `pty_send` does not interpret command or prompt meaning; it delivers the requested text to the terminal. By default it sanitizes ESC and bracketed-paste terminators, while `pty_read` neutralizes control characters in returned output (`raw: true` keeps them unchanged). The shell, remote endpoint, or launched harness owns command authorization.
846
846
 
847
- Each `pty_send` accepts at most 64 KiB of UTF-8 text. Sends to the same session are serialized across aiterm processes so chunks cannot interleave. Every OS pastes through its multiplexer in UTF-8-safe 256-byte chunks with a 10 ms drain interval; macOS, Linux, and WSL2 have all demonstrated silent middle/trailing loss when a long input is pushed without that boundary. Sanitized multiline text sent while a POSIX shell or PowerShell is in the foreground is encoded as one newline-free input (`eval` for POSIX shells; a dot-sourced, UTF-8 Base64-decoded scriptblock for PowerShell): the shell receives the complete script before it runs the first line, so a pager or REPL started mid-script cannot consume later lines as interactive keystrokes. Single-line input, `raw:true`, and non-shell frontends remain direct PTY pastes. Agent dispatches additionally wrap the whole text once in `ESC[200~/201~` and stream the wrapped text in the same chunks, so the agent TUI sees one paste (an image path is never split across pastes), hardening prompt injection against mid-word key-interpretation corruption and dropped submits. If a later chunk fails, aiterm reports the partial-send state and does not press Enter automatically. A lock left by a terminated sender fails closed before sending; use `pty_list` to confirm the affected session, close it with `pty_close`, then recreate the same session ID. There is no public kill-all tool.
847
+ Each `pty_send` accepts at most 64 KiB of UTF-8 text. Managed-agent callers must serialize operations for the same seat across independent local MCP and remote clients. Aiterm retains process-local ordering/native ownership, but agent input no longer acquires filesystem send locks or treats the legacy socket/log directory as readiness. Ordinary PTY/shell and standalone auth/approval still use their existing file exclusion. Every OS pastes through its multiplexer in UTF-8-safe 256-byte chunks with a 10 ms drain interval; macOS, Linux, and WSL2 have all demonstrated silent middle/trailing loss when a long input is pushed without that boundary. Sanitized multiline text sent while a POSIX shell or PowerShell is in the foreground is encoded as one newline-free input (`eval` for POSIX shells; a dot-sourced, UTF-8 Base64-decoded scriptblock for PowerShell): the shell receives the complete script before it runs the first line, so a pager or REPL started mid-script cannot consume later lines as interactive keystrokes. Single-line input, `raw:true`, and non-shell frontends remain direct PTY pastes. Agent dispatches additionally wrap the whole text once in `ESC[200~/201~` and stream the wrapped text in the same chunks, so the agent TUI sees one paste (an image path is never split across pastes), hardening prompt injection against mid-word key-interpretation corruption and dropped submits. If a later chunk fails, aiterm reports the partial-send state and does not press Enter automatically. For ordinary PTY/shell input, a lock left by a terminated sender fails closed before sending; use `pty_list` to confirm the affected session, close it with `pty_close`, then recreate the same session ID. There is no public kill-all tool.
848
848
 
849
849
  ## A human can watch
850
850
 
@@ -956,3 +956,8 @@ The Linux Grok 1.0.70 inspector binds the native current-session registry to the
956
956
  ### Offline resume checkpoint
957
957
 
958
958
  `aiterm-resume-state checkpoint --session ID --launch LAUNCH` emits a private bundle on stdout and a safe receipt on stderr. `aiterm-resume-state restore --session ID --launch LAUNCH --sha256 SHA` reads that bundle on stdin and emits its receipt on stdout. This Linux/Codex scope requires the explicit persistent `AITERM_STATE_BASE`, the same UID/absolute paths and retained vendor rollout identity. The caller must stop all source writers and prevent restart before checkpoint; restore runs under startup admission before bootstrap or native startup. It does not recover already-lost legacy tmpfs state or migrate pending deliveries. The bundle is limited to 16 MiB including LF; the safe receipt is at most 512 bytes. Success exits 0; refusal exits 2 with `aiterm: RESUME_STATE_UNCONFIRMED` plus LF (33 bytes). See the [contract and diagram](https://github.com/kitepon/aiterm-mcp/blob/v0.63.3/docs/architecture/resume-checkpoint.md).
959
+
960
+
961
+ ### Host-controller clients
962
+
963
+ Any MCP client can opt into the existing host-orchestration routing by declaring `capabilities.experimental["io.github.kitepon/aiterm-mcp/host-controller"] = {}` during initialize. This is routing identity, not authentication; source, generation, native identity and effect guards still apply. Clients without that declaration stay on the ordinary direct path. The exact client name `bellteam` remains a backward-compatible alias. A declared controller requests interim/follow metadata with `_meta["aiterm/caller"]` equal to its initialized client name (blank/missing name: `MCP client`); the old `BellTeam` marker is also preserved for compatibility. See [function map and data flow](https://github.com/kitepon/aiterm-mcp/blob/main/docs/architecture/host-controller.md). BellTeam's own caller can adopt the capability later; that migration is separate from this release.
@@ -1,3 +1,4 @@
1
+ import { isHostControllerClient } from "./host-controller.js";
1
2
  // Goal state belongs to the CLI. This module holds no goal store or loop.
2
3
  import { z } from "zod";
3
4
  import { executionLaunchSchema } from "./execution-contract.js";
@@ -19,10 +20,10 @@ export const agentGoalInputSchema = agentGoalInputObject.superRefine((value, con
19
20
  export const GOAL_HOST_META_KEY = "aiterm/goal";
20
21
  const hostOrigin = z.object({ origin: z.literal("user") }).strict();
21
22
  /** Host provenance on the existing local MCP channel, not authentication.
22
- * BellTeam must authenticate the Owner and reject seat ingress before stamping
23
+ * The controller must authenticate the user and reject seat ingress before stamping
23
24
  * this metadata. A model client's metadata never upgrades its origin. */
24
- export function goalOriginFromHost(clientName, meta) {
25
- if (clientName !== "bellteam" || !meta || typeof meta !== "object")
25
+ export function goalOriginFromHost(clientName, meta, capabilities) {
26
+ if (!isHostControllerClient(clientName, capabilities) || !meta || typeof meta !== "object")
26
27
  return "automatic";
27
28
  return hostOrigin.safeParse(meta[GOAL_HOST_META_KEY]).success ? "user" : "automatic";
28
29
  }
package/dist/core.js CHANGED
@@ -101,7 +101,6 @@ const SESSION_SEND_LOCK_POLL_MS = 25;
101
101
  // 同じagent sessionへの送信が重なった時に、前の1通を待つ上限(ADR 0088)。
102
102
  // 起動から最初の描画を待つ上限と、貼り付けの上限の和。前の1通が正常に進んでいる間は待ち切れる長さにする。
103
103
  const AGENT_SEND_LOCK_WAIT_MS = AGENT_TUI_FIRST_DRAW_TIMEOUT_MS + SESSION_SEND_LOCK_WAIT_MS;
104
- const AGENT_SEND_LOCK_POLL_MS = 50;
105
104
  const PASTE_MARKERS_RE = /\x1b\[20[01]~/g;
106
105
  // よく使う制御キーの別名(tmux のキー名へ)
107
106
  const KEYMAP = {
@@ -829,7 +828,7 @@ export function send(name, text, o = {}) {
829
828
  `正しく展開されません。until で完了パターンを指定してください。`, 2);
830
829
  }
831
830
  }
832
- const releaseSendLock = acquireSessionSendFileLock(name);
831
+ const releaseSendLock = isAgentSession(name) ? () => { } : acquireSessionSendFileLock(name);
833
832
  try {
834
833
  // managed Claudeの通常送信は、lastcmd/mark/PTYのどれにも触れる前に拒否する。
835
834
  // 拒否した呼び出しが古いmarkを消したり偽のmarkを残すと、後続readが存在しない
@@ -3101,7 +3100,7 @@ function acquireSessionSendFileLock(name) {
3101
3100
  // ── 同じagent sessionへの送信を1本ずつ通す(ADR 0088) ────
3102
3101
  // 振り分け(差し込みか新しいturnか)から送り終えるまでの間に、入力受付待ちなどの待ちが挟まる。
3103
3102
  // その間に次の1通が同じ状態を読むと、Claudeはturnの印の取り合いで後の1通が断られ、他のharnessは同じ入力欄へ2回貼る。
3104
- // 同じprocessの中は着いた順の待ち行列、別のprocessの間はfileで排他し、後の1通は前の1通が終わってから振り分け直す。
3103
+ // Process-local order/ownership remains; independent MCP/remote clients serialize the same managed seat themselves.
3105
3104
  const agentSendQueues = new Map();
3106
3105
  const agentSendHeld = new Set();
3107
3106
  const agentSendOwner = new AsyncLocalStorage();
@@ -3213,48 +3212,6 @@ function agentSendBusyError(name, pid, waitMs, untouched = AGENT_SEND_UNSENT) {
3213
3212
  return new AitermError(`AGENT_SEND_BUSY: agent session '${name}' は${pid != null ? `別プロセス(pid ${pid})` : "先に受け付けた送信"}の処理中です。` +
3214
3213
  `${waitMs}ms待っても順番が来ませんでした。${untouched}`, 2);
3215
3214
  }
3216
- async function acquireAgentSendFileLock(name, deadline, waitMs, untouched = AGENT_SEND_UNSENT) {
3217
- const p = agentSendLockPath(name);
3218
- let checkedOwner = null;
3219
- let checkedOwnerReplaced = false;
3220
- for (;;) {
3221
- let token;
3222
- try {
3223
- token = tryCreateOwnedLock(p);
3224
- }
3225
- catch (e) {
3226
- // socketの置き場が無ければ、守る相手のsessionにも届かない。lockを取らずに進め、送信側の今まで通りの断りを返す。
3227
- if (e.code === "ENOENT")
3228
- return () => { };
3229
- throw e;
3230
- }
3231
- if (token !== null)
3232
- return () => releaseOwnedLock(p, token);
3233
- const probe = probeAgentSendLock(name);
3234
- let dead = !probe.live;
3235
- let replacedToken = null;
3236
- // 生きて見える持ち主は、初めて見た時に1回、本人かを確かめる。結果は覚え、待つ間にOSへ照会し直さない。
3237
- if (!dead && probe.pid != null) {
3238
- const owner = `${probe.pid}@${probe.at}`;
3239
- if (owner !== checkedOwner) {
3240
- checkedOwner = owner;
3241
- checkedOwnerReplaced = agentSendLockOwnerReplaced(probe);
3242
- }
3243
- if (checkedOwnerReplaced) {
3244
- dead = true;
3245
- replacedToken = probe.token ?? null;
3246
- }
3247
- }
3248
- if (dead && reapDeadAgentSendLock(name, replacedToken) === "stuck") {
3249
- throw new AitermError(`agent session '${name}' に、終了した送信のlockを片付ける途中で残った印があります。` +
3250
- `自動回収は並行送信の混線を招くため行いません。文字列は送信していません。` +
3251
- `pty_listで対象を確認し、pty_closeでsessionを閉じてから同じIDで再作成してください`, 2);
3252
- }
3253
- if (performance.now() >= deadline)
3254
- throw agentSendBusyError(name, dead ? null : probe.pid, waitMs, untouched);
3255
- await sleep(AGENT_SEND_LOCK_POLL_MS);
3256
- }
3257
- }
3258
3215
  function withAgentNativeOperation(name, mutates, body) {
3259
3216
  assertSessionName(name);
3260
3217
  if (!isAgentSession(name))
@@ -3273,9 +3230,6 @@ function withAgentNativeOperation(name, mutates, body) {
3273
3230
  };
3274
3231
  if (!mutates || owns)
3275
3232
  return execute();
3276
- const token = tryCreateOwnedLock(agentSendLockPath(name));
3277
- if (!token)
3278
- throw unavailable();
3279
3233
  const mine = Symbol(name);
3280
3234
  agentSendHeld.add(name);
3281
3235
  activeAgentSendOwner.set(name, mine);
@@ -3285,13 +3239,11 @@ function withAgentNativeOperation(name, mutates, body) {
3285
3239
  finally {
3286
3240
  activeAgentSendOwner.delete(name);
3287
3241
  agentSendHeld.delete(name);
3288
- releaseOwnedLock(agentSendLockPath(name), token);
3289
3242
  }
3290
3243
  }
3291
3244
  async function withAgentSendLock(name, run, untouched = AGENT_SEND_UNSENT, pinResume = true) {
3292
3245
  const launchId = tryLoadAgentMetadata(name)?.launch_id;
3293
3246
  const waitMs = agentSendLockWaitMs;
3294
- const deadline = performance.now() + waitMs;
3295
3247
  const previous = agentSendQueues.get(name) ?? Promise.resolve();
3296
3248
  let leave;
3297
3249
  const mine = new Promise((resolve) => {
@@ -3315,7 +3267,6 @@ async function withAgentSendLock(name, run, untouched = AGENT_SEND_UNSENT, pinRe
3315
3267
  clearTimeout(timer);
3316
3268
  if (!myTurn)
3317
3269
  throw agentSendBusyError(name, null, waitMs, untouched);
3318
- const release = await acquireAgentSendFileLock(name, deadline, waitMs, untouched);
3319
3270
  const mine = Symbol(name);
3320
3271
  agentSendHeld.add(name);
3321
3272
  activeAgentSendOwner.set(name, mine);
@@ -3328,8 +3279,6 @@ async function withAgentSendLock(name, run, untouched = AGENT_SEND_UNSENT, pinRe
3328
3279
  return await agentSendOwner.run(mine, async () => {
3329
3280
  const meta = pinResume ? tryLoadAgentMetadata(name) : null;
3330
3281
  if (meta && !readAgentLifecycle(meta)) {
3331
- if (!fs.existsSync(SOCKDIR) && !meta.resumed_from)
3332
- throw new AitermError(`agent session '${name}' の ${agentLabel(meta.kind)} TUI が入力受付状態になりません。文字列は送信していません。`, 2);
3333
3282
  const uncertain = () => new AgentResumeError("AGENT_RESUME_UNCONFIRMED", "復帰対象のnativeを確認できません。本文は送信していません。", name, meta.launch_id);
3334
3283
  let failed;
3335
3284
  try {
@@ -3365,7 +3314,6 @@ async function withAgentSendLock(name, run, untouched = AGENT_SEND_UNSENT, pinRe
3365
3314
  finally {
3366
3315
  activeAgentSendOwner.delete(name);
3367
3316
  agentSendHeld.delete(name);
3368
- release();
3369
3317
  }
3370
3318
  }
3371
3319
  finally {
@@ -6860,7 +6808,7 @@ async function dispatchAgentTurnInLock(name, text, o, pendingSend) {
6860
6808
  }
6861
6809
  // 待たずに断るのは、応答が要る既知の画面(承認・確認のmodal)の時。どの画面で断ったかを残す。
6862
6810
  const state = agentPaneObservation(meta.kind, ready.lastScreen);
6863
- throw new AitermError(`agent session '${name}' の ${agentLabel(meta.kind)} TUI が入力受付状態になりません。文字列は送信していません。` +
6811
+ throw new AitermError(`AGENT_INPUT_NOT_READY: agent session '${name}' の ${agentLabel(meta.kind)} TUI が入力受付状態になりません。文字列は送信していません。` +
6864
6812
  "少し後で pty_read(screen:true) を確認し、TUI が起動済みなら再度 pty_send してください。" +
6865
6813
  `\nstate=${state.state} reason=${state.reason}`, 2);
6866
6814
  }
@@ -7062,7 +7010,7 @@ function assertAgentSendHarness(name, meta, inputStarted = false, waiting = fals
7062
7010
  const starting = current.reason === "harness_start_unconfirmed";
7063
7011
  if (!current.exists || current.harness_alive === false || (starting && !waiting)) {
7064
7012
  throw new AitermError((inputStarted ? `agent session '${name}' の ${agentLabel(meta.kind)} への入力完了を確認できません。本文を再送しないでください。`
7065
- : `agent session '${name}' の ${agentLabel(meta.kind)} TUI が入力受付状態になりません。文字列は送信していません。`) +
7013
+ : `AGENT_INPUT_TARGET_UNAVAILABLE: agent session '${name}' の ${agentLabel(meta.kind)} TUI が入力受付状態になりません。文字列は送信していません。`) +
7066
7014
  `\nstate=${current.state} reason=${current.reason}`, 2);
7067
7015
  }
7068
7016
  return !starting;
@@ -7691,10 +7639,7 @@ function prepareAgentLaunch(kind, opts = {}) {
7691
7639
  throw new AitermError("AGENT_RESUME_UNCONFIRMED: 作成したnative本人性を取得できません。", 2);
7692
7640
  initialNative = { ...receipt, server_started_identity: server, pane_started_identity: pane };
7693
7641
  try {
7694
- const token = tryCreateOwnedLock(agentSendLockPath(receipt.session_id));
7695
- if (!token)
7696
- throw agentSendBusyError(receipt.session_id, null, 0);
7697
- initialAdmission = { name: receipt.session_id, token };
7642
+ initialAdmission = { name: receipt.session_id };
7698
7643
  agentSendHeld.add(receipt.session_id);
7699
7644
  // The old launch may have entered hibernation after the public precheck.
7700
7645
  assertNoDormantSession(receipt.session_id);
@@ -7717,9 +7662,8 @@ function prepareAgentLaunch(kind, opts = {}) {
7717
7662
  }
7718
7663
  finally {
7719
7664
  if (initialAdmission) {
7720
- const { name, token } = initialAdmission;
7665
+ const { name } = initialAdmission;
7721
7666
  agentSendHeld.delete(name);
7722
- releaseOwnedLock(agentSendLockPath(name), token);
7723
7667
  }
7724
7668
  }
7725
7669
  };
@@ -1,3 +1,4 @@
1
+ import { isHostControllerClient } from "./host-controller.js";
1
2
  // Request-local adapter for the serving stdio dispatcher. No live I/O, core
2
3
  // imports or public mount at import. Uncovered ordinary/native/remote targets
3
4
  // fail before the handler; they must acquire their own generation adapter.
@@ -124,9 +125,9 @@ export function createExecutionDispatcher(bindings) {
124
125
  if (service !== bindings.service)
125
126
  throw new ExecutionError("EXECUTION_UNSUPPORTED");
126
127
  bindings.assertParticipant?.();
127
- return { sourceContext: extra => executionHostSourceFromMeta(extra._meta, bindings.initializedClientName()),
128
+ return { sourceContext: extra => executionHostSourceFromMeta(extra._meta, bindings.initializedClientName(), bindings.initializedClientCapabilities?.()),
128
129
  closeManagementRequest: (extra, session) => {
129
- if (!registeredControls || !native || bindings.initializedClientName() !== "bellteam")
130
+ if (!registeredControls || !native || !isHostControllerClient(bindings.initializedClientName(), bindings.initializedClientCapabilities?.()))
130
131
  throw new ExecutionError("EXECUTION_UNSUPPORTED");
131
132
  return executionRequestSchema.options[4].parse({ kind: "mcp", process_pid: native.pid,
132
133
  process_started_identity: native.started_identity, request_id: extra.requestId,
@@ -148,7 +149,7 @@ export function createExecutionDispatcher(bindings) {
148
149
  throw new ExecutionError("EXECUTION_UNSUPPORTED");
149
150
  // Only the same server's registered typed handlers run here. They
150
151
  // already own metadata admission/stop; no synthetic send edge/frame.
151
- executionHostSourceFromMeta(fixedExtra._meta, bindings.initializedClientName());
152
+ executionHostSourceFromMeta(fixedExtra._meta, bindings.initializedClientName(), bindings.initializedClientCapabilities?.());
152
153
  return await body(args, fixedExtra);
153
154
  }
154
155
  if (name === "agent_auth" && (args.action !== "status" || args.session_id !== undefined) && !observeAuth)
@@ -162,7 +163,9 @@ export function createExecutionDispatcher(bindings) {
162
163
  if (!route)
163
164
  return await body(args, fixedExtra);
164
165
  const client = bindings.initializedClientName();
165
- const host = executionHostSourceFromMeta(fixedExtra._meta, client);
166
+ const capabilities = bindings.initializedClientCapabilities?.();
167
+ const controller = isHostControllerClient(client, capabilities);
168
+ const host = executionHostSourceFromMeta(fixedExtra._meta, client, capabilities);
166
169
  const source = host !== undefined ? host.source : directSource;
167
170
  // Partial/mismatched stdio identity is not an independent operator.
168
171
  if (host === undefined && sourceFieldsPresent && !source)
@@ -171,22 +174,22 @@ export function createExecutionDispatcher(bindings) {
171
174
  const supplied = executionRefFromMeta(fixedExtra._meta);
172
175
  // A host's explicit session close is a management RPC with its own
173
176
  // existing process/request identity, not a delivery or resend.
174
- const hostClose = client === "bellteam" && route.tool === "pty_close" && !supplied;
175
- const hostLaunch = client === "bellteam" && route.tool === "agent_launch" && !supplied
177
+ const hostClose = controller && route.tool === "pty_close" && !supplied;
178
+ const hostLaunch = controller && route.tool === "agent_launch" && !supplied
176
179
  && args.prompt == null && args.throughline_source_session === undefined;
177
- const hostConfigure = client === "bellteam" && route.tool === "agent_configure" && !supplied;
180
+ const hostConfigure = controller && route.tool === "agent_configure" && !supplied;
178
181
  const authOperation = name === "agent_auth";
179
182
  const authInput = (route.tool === "pty_send" || route.tool === "pty_key") && !supplied
180
- && client === "bellteam" ? authGeneration(route.target) : null;
181
- const hostAuth = client === "bellteam" && !supplied && authOperation;
182
- const hostGoal = client === "bellteam" && route.tool === "agent_goal" && !supplied;
183
+ && controller ? authGeneration(route.target) : null;
184
+ const hostAuth = controller && !supplied && authOperation;
185
+ const hostGoal = controller && route.tool === "agent_goal" && !supplied;
183
186
  const hostManagement = hostClose || hostLaunch || hostConfigure || hostGoal || hostAuth || !!authInput;
184
187
  if (args.remote !== undefined && args.remote !== null)
185
188
  throw new ExecutionError("EXECUTION_UNSUPPORTED");
186
189
  let reference = supplied;
187
190
  let directRequest = null;
188
191
  let frozenParent = null;
189
- if (!reference && (client !== "bellteam" || hostManagement) && native) {
192
+ if (!reference && (!controller || hostManagement) && native) {
190
193
  directRequest = executionRequestSchema.options[4].parse({ kind: "mcp", process_pid: native.pid,
191
194
  process_started_identity: native.started_identity, request_id: fixedExtra.requestId,
192
195
  tool: route.tool, target_session_id: route.target });
@@ -207,7 +210,7 @@ export function createExecutionDispatcher(bindings) {
207
210
  // External host refs are created by the real Bridge ingress. Direct
208
211
  // model requests cannot borrow another call's reservation or choose
209
212
  // a native control label to suppress an invocation edge.
210
- if (client !== "bellteam" || reference.request.kind === "mcp"
213
+ if (!controller || reference.request.kind === "mcp"
211
214
  || (route.tool !== "agent_launch" && route.tool !== "pty_send"))
212
215
  throw new ExecutionError("EXECUTION_UNSUPPORTED");
213
216
  const record = await bindings.service.execute({ action: "status", request: reference.request });
@@ -227,7 +230,7 @@ export function createExecutionDispatcher(bindings) {
227
230
  }
228
231
  else {
229
232
  // BellTeam must retain its existing delivery/room/call reference.
230
- if ((client === "bellteam" && !hostManagement) || !directRequest)
233
+ if ((controller && !hostManagement) || !directRequest)
231
234
  throw new ExecutionError("EXECUTION_UNSUPPORTED");
232
235
  const current = await observe(route.target);
233
236
  if (authOperation && route.tool !== "agent_auth.start") {
@@ -32,7 +32,7 @@ export function createNativeDeliveryServer(dependencies = {}) {
32
32
  sendKey: dependencies.sendKey ?? core.interruptSessionNow,
33
33
  };
34
34
  const result = args.pause_goals
35
- ? await interruptKnownSessionsAndGoals(args, { ...stop, pauseGoal: dependencies.pauseGoal ?? core.pauseAgentGoalForStop }, dependencies.goalOrigin ? dependencies.goalOrigin(extra) : goalOriginFromHost(server.server.getClientVersion()?.name, extra._meta))
35
+ ? await interruptKnownSessionsAndGoals(args, { ...stop, pauseGoal: dependencies.pauseGoal ?? core.pauseAgentGoalForStop }, dependencies.goalOrigin ? dependencies.goalOrigin(extra) : goalOriginFromHost(server.server.getClientVersion()?.name, extra._meta, server.server.getClientCapabilities()))
36
36
  : interruptKnownSessions(args, stop);
37
37
  return { content: [{ type: "text", text: JSON.stringify(result) }], structuredContent: result };
38
38
  });
@@ -70,7 +70,8 @@ export function createExecutionParticipant(input) {
70
70
  const server = createAitermServer({ execution: server => {
71
71
  assertScope();
72
72
  dispatcher = createExecutionDispatcher({ service: producer.service, nativeIdentity: actor, sourceEnvironment,
73
- initializedClientName: () => server.server.getClientVersion()?.name, observeSessionGeneration, assertParticipant: assertScope, captureNativeParent,
73
+ initializedClientName: () => server.server.getClientVersion()?.name,
74
+ initializedClientCapabilities: () => server.server.getClientCapabilities(), observeSessionGeneration, assertParticipant: assertScope, captureNativeParent,
74
75
  ...(producer.startup.selectAuthSessionName ? { selectAuthSessionName: producer.startup.selectAuthSessionName } : {}),
75
76
  ...(producer.startup.observeAuthSessionGeneration ? { observeAuthSessionGeneration: producer.startup.observeAuthSessionGeneration } : {}) });
76
77
  return { dispatcher, parentExecution: producer.execution, parentDependencies, parentStateRoot: producer.scope.state_root };
@@ -1,3 +1,4 @@
1
+ import { isHostControllerClient } from "./host-controller.js";
1
2
  // Versioned Bridge/MCP contract. No dependency on core, PTY or the tool server.
2
3
  import { z } from "zod";
3
4
  import { executionLaunchSchema, executionPointSchema, executionRequestSchema, executionReservationSchema, executionRelationSchema, executionPhaseSchema, cascadeStopRequestSchema, cascadeStopResultSchema, executionNativeBindingSchema } from "./execution-contract.js";
@@ -10,12 +11,12 @@ export const executionTransportSourceSchema = z.object({
10
11
  schema: z.literal("aiterm.execution-source.v1"), source: executionPointSchema.nullable(),
11
12
  }).strict();
12
13
  /** Local host correlation, not client authentication. The product mount calls
13
- * this with the initialized client name, never a tool argument. Direct CLI
14
+ * this with initialized client identity/capabilities, never a tool argument. Direct CLI
14
15
  * callers use their fixed stdio environment; they cannot override it here.
15
16
  */
16
- export function executionHostSourceFromMeta(meta, clientName) {
17
+ export function executionHostSourceFromMeta(meta, clientName, capabilities) {
17
18
  const value = meta && typeof meta === "object" ? meta[EXECUTION_SOURCE_META_KEY] : undefined;
18
- if (clientName !== "bellteam") {
19
+ if (!isHostControllerClient(clientName, capabilities)) {
19
20
  if (value !== undefined)
20
21
  throw new ExecutionError("EXECUTION_UNSUPPORTED");
21
22
  return undefined;
@@ -0,0 +1,18 @@
1
+ /** Initialize-time routing declaration, never authentication or native-effect proof. */
2
+ export const HOST_CONTROLLER_CAPABILITY = "io.github.kitepon/aiterm-mcp/host-controller";
3
+ export const LEGACY_HOST_CONTROLLER_NAME = "bellteam";
4
+ export const LEGACY_INTERIM_CALLER = "BellTeam";
5
+ export function isHostControllerClient(name, capabilities) {
6
+ if (name === LEGACY_HOST_CONTROLLER_NAME)
7
+ return true;
8
+ if (!capabilities || typeof capabilities !== "object")
9
+ return false;
10
+ const experimental = capabilities.experimental;
11
+ if (!experimental || typeof experimental !== "object")
12
+ return false;
13
+ const role = experimental[HOST_CONTROLLER_CAPABILITY];
14
+ return role !== null && typeof role === "object" && !Array.isArray(role);
15
+ }
16
+ export function hostControllerLabel(name) {
17
+ return name?.trim() ? name : "MCP client";
18
+ }
package/dist/index.js CHANGED
@@ -475,9 +475,9 @@ export function createAitermServer(options = {}) {
475
475
  delivery = await deliveryForRequest(extra);
476
476
  // BellTeamのため(ADR 0122): 差し込みになった時、その文を取った番の終わりを待つ手がかりを返す。印の無い呼び手には何も足さない。
477
477
  const receipt = await core.sendAgentMessage(session_id, core.attachImages(text, image), { raw, before_send: delivery?.before_send, preface,
478
- follow: interimCallerFromMeta(extra._meta) });
478
+ follow: interimCallerFromMeta(extra._meta, server.server.getClientVersion()?.name, server.server.getClientCapabilities()) });
479
479
  if (receipt.schema === "aiterm.agent-steer.v1") {
480
- const follow = interimCallerFromMeta(extra._meta) ? receipt.follow ?? null : null;
480
+ const follow = interimCallerFromMeta(extra._meta, server.server.getClientVersion()?.name, server.server.getClientCapabilities()) ? receipt.follow ?? null : null;
481
481
  return {
482
482
  content: [
483
483
  {
@@ -748,10 +748,10 @@ export function createAitermServer(options = {}) {
748
748
  return fail(e);
749
749
  }
750
750
  });
751
- // BellTeamのため(ADR 0122): 要求の_metaに aiterm/caller="BellTeam" がある時だけ、結果の_metaへ席の今の番を載せる。
751
+ // Declared controller caller markers opt into current-turn metadata (ADR 0122).
752
752
  // 説明と引数には出さない(steer-follow.ts の冒頭)。それ以外の呼び手には何も足さない。
753
753
  function seatTurnsMeta(sessions, requestMeta) {
754
- if (!interimCallerFromMeta(requestMeta))
754
+ if (!interimCallerFromMeta(requestMeta, server.server.getClientVersion()?.name, server.server.getClientCapabilities()))
755
755
  return {};
756
756
  try {
757
757
  return { _meta: { [SEAT_TURNS_RESULT_META_KEY]: core.readSeatTurns(sessions.filter(session => session.harness !== null).map(session => session.session_id)) } };
@@ -795,10 +795,10 @@ export function createAitermServer(options = {}) {
795
795
  return fail(e);
796
796
  }
797
797
  });
798
- // BellTeamのため: 要求の_metaに aiterm/caller="BellTeam" がある時だけ、結果の_metaへ合間の言葉を載せる。
798
+ // Declared controller caller markers opt into interim words.
799
799
  // 説明と引数には出さない(interim-words.ts の冒頭)。それ以外の呼び手には何も足さない。
800
800
  function interimWordsMeta(sessionId, requestMeta) {
801
- const request = interimRequestFromMeta(requestMeta);
801
+ const request = interimRequestFromMeta(requestMeta, server.server.getClientVersion()?.name, server.server.getClientCapabilities());
802
802
  if (!request)
803
803
  return {};
804
804
  try {
@@ -989,7 +989,7 @@ export function createAitermServer(options = {}) {
989
989
  outputSchema: agentGoalOutputSchema,
990
990
  }, async (args, extra) => {
991
991
  try {
992
- const origin = goalOrigin ? goalOrigin(extra) : goalOriginFromHost(server.server.getClientVersion()?.name, extra._meta);
992
+ const origin = goalOrigin ? goalOrigin(extra) : goalOriginFromHost(server.server.getClientVersion()?.name, extra._meta, server.server.getClientCapabilities());
993
993
  if (origin !== "user" && origin !== "automatic")
994
994
  throw new Error("Invalid trusted goal provenance");
995
995
  const result = agentGoalWireResultSchema.parse(await core.agentGoal(agentGoalInputSchema.parse(args), origin));
@@ -1,9 +1,6 @@
1
- // 合間の言葉: agent sessionがturnの途中で書き、そのあと道具を使った言葉。
2
- // BellTeamのためにある。BellTeamは実行中のBotが何をしているかを会話画面へ出すため、
3
- // pty_observeのMCP要求の_metaに caller="BellTeam" を入れて呼び、結果の_metaでこれを受け取る。
4
- // 利用者向けのツール説明と引数には出さない(BellTeam以外のAIに指定させないため)。要らないものと見て消さないこと。
5
- //
6
- // 最後の回答と思考は含めない。APIエラーやsession limitの知らせは、記録に書かれていれば含める。
1
+ import { isHostControllerClient, hostControllerLabel, LEGACY_INTERIM_CALLER } from "./host-controller.js";
2
+ // Controller-requested interim words; final answers and thinking are excluded.
3
+ // See docs/architecture/host-controller.md for the initialize role and caller marker.
7
4
  // ハーネスごとの見分け方(2026-09-28 記録で確認):
8
5
  // Claude Code: text block で message.stop_reason="tool_use"。isApiErrorMessage の行は知らせ。
9
6
  // Codex: assistant message の phase="commentary"。task_complete の error はturnを終えた知らせ。
@@ -17,9 +14,8 @@ import { claudeSessionTranscriptPath } from "./harnesses/claude.js";
17
14
  import { codexBoundTranscript, codexRootTranscript, codexResumeCursor, codexResumeTurnId, codexTurnError, codexTurnErrorLine } from "./harnesses/codex.js";
18
15
  import { grokSessionDirectory } from "./harnesses/grok.js";
19
16
  import { cursorTranscript } from "./harnesses/cursor.js";
20
- /** BellTeamが要求の_metaへ入れる呼び手の印。値が "BellTeam" の時だけ合間の言葉を返す。 */
17
+ /** Controller caller label in request metadata; see host-controller.md. */
21
18
  export const INTERIM_CALLER_META_KEY = "aiterm/caller";
22
- export const INTERIM_CALLER = "BellTeam";
23
19
  /** 前回受け取った最後のseq。これより後の言葉だけを返す。 */
24
20
  export const INTERIM_AFTER_META_KEY = "aiterm/interim_after";
25
21
  /** 結果の_metaで返すキー。 */
@@ -46,17 +42,20 @@ export function agentInterimBoundaryPath(name, launchId) {
46
42
  throw new AitermError(`launch_id が不正です: ${launchId}`, 2);
47
43
  return path.join(agentsDir(), `${name}.${launchId}.interim.json`);
48
44
  }
49
- /** 要求の_metaがBellTeamの印を持つか。 */
50
- export function interimCallerFromMeta(meta) {
51
- return !!meta && typeof meta === "object" && meta[INTERIM_CALLER_META_KEY] === INTERIM_CALLER;
45
+ /** Controller name marker, with the historical marker retained for compatibility. */
46
+ export function interimCallerFromMeta(meta, clientName, capabilities) {
47
+ if (!meta || typeof meta !== "object")
48
+ return false;
49
+ const caller = meta[INTERIM_CALLER_META_KEY];
50
+ return caller === LEGACY_INTERIM_CALLER || (isHostControllerClient(clientName, capabilities) && caller === hostControllerLabel(clientName));
52
51
  }
53
52
  /**
54
- * 要求の_metaがBellTeamの印を持つ時だけ、前回のseqを返す。それ以外はnull(何も足さない)。
53
+ * 要求の_metaがcontrollerの印を持つ時だけ、前回のseqを返す。それ以外はnull(何も足さない)。
55
54
  * 読み始める位置(aiterm/interim_from)が付いていれば、fromに入れる。付いているのに読めない時はfromがnullでfrom_invalidがtrue
56
55
  * (最後のdispatchの言葉を黙って返すと、呼び手は別の番の言葉を出してしまう)。
57
56
  */
58
- export function interimRequestFromMeta(meta) {
59
- if (!interimCallerFromMeta(meta))
57
+ export function interimRequestFromMeta(meta, clientName, capabilities) {
58
+ if (!interimCallerFromMeta(meta, clientName, capabilities))
60
59
  return null;
61
60
  const record = meta;
62
61
  const raw = record[INTERIM_AFTER_META_KEY];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiterm-mcp",
3
- "version": "0.63.10",
3
+ "version": "0.63.12",
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": [