aiterm-mcp 0.70.70 → 0.70.71

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,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.70.71] - 2026-11-17
11
+
12
+ - A launcher can lock a seat's model and effort so that the AI inside cannot change them (a313, the Owner's "AI settings lock"). `agent_configure({ session_id, configuration_lock: "lock" | "unlock", configuration_lock_key })` stores only the SHA-256 of the key beside the seat's launch record (`<session>.<launch_id>.configuration-lock.json`, removed when the seat is closed). While locked, calls without the matching key are refused with `AGENT_CONFIGURATION_LOCKED` before anything is typed: `agent_configure` with `model`/`reasoning_effort`, `pty_send` text starting with `/model`, `/models`, `/effort` or `/reasoning` (also with `force`), and `pty_key` Alt+P. `agent_configure` with the key (BellTeam applying the Owner's change), `fast`, ordinary text, a person typing in the terminal and Aiterm's own typing during a configure are not affected. An unlocked seat can be locked by any caller; the launcher is expected to lock a seat right after starting it (model-configuration.md "席の設定の固定").
13
+
10
14
  ## [0.70.70] - 2026-11-15
11
15
 
12
16
  - The in-turn model/effort change of a Claude seat (0.70.68) now works on a real running turn (Kiro's Z43 lab, b8 failed with `CLAUDE_MODEL_PICKER_NOT_SHOWN`). Cause, reproduced with Aiterm's own code on a seat running one long Bash call: the running turn's spinner and tool block plus the model picker are taller than the default 24-row pane, so the picker's foot ("Esc to cancel") was cut and unreadable. The in-turn path now makes the pane 50 rows tall for the switch and restores its size afterwards; reads the result of an in-turn switch, which Claude Code prints as a plain indented line (`Model set to sonnet (claude-sonnet-5-5) for this session only`, no `⎿`); and, when the picker is open but unreadable, closes it with Esc only while its heading is on screen (a picker left open would take the owner's next message as keys, which is the likely cause of the Z43 seat that stopped and of `"model": "opus"` appearing in `~/.claude/settings.json` through Enter). Verified on a real 2.1.325 seat: the same turn's next request ran on the new model (transcript).
@@ -3531,7 +3535,8 @@ prototype (preserved under `prototype/python/` as the porting source and referen
3531
3535
  `ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
3532
3536
  provenance.
3533
3537
 
3534
- [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.70...HEAD
3538
+ [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.71...HEAD
3539
+ [0.70.71]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.70...v0.70.71
3535
3540
  [0.70.70]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.69...v0.70.70
3536
3541
  [0.70.69]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.68...v0.70.69
3537
3542
  [0.70.68]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.67...v0.70.68
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.70** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
218
+ **状態:** 開発継続中 · 現行公開版 **v0.70.71** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
219
219
 
220
220
  ### 更新と巻き戻し
221
221
 
package/README.md CHANGED
@@ -227,7 +227,7 @@ collection is off by default and performs no network I/O. It ships via
227
227
  tag-triggered CI with npm provenance (OIDC Trusted Publishing); the GitHub
228
228
  Release re-registers the Official MCP Registry entry.
229
229
 
230
- **Status:** actively maintained · current public release **v0.70.70** · 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.71** · 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
 
@@ -695,6 +695,8 @@ enables collection on that host.
695
695
 
696
696
  `agent_configure({ session_id, model?, reasoning_effort?, fast? })` changes a running Claude, Codex, Grok, or Cursor TUI through the harness's standard controls, preserving the PTY and conversation context.
697
697
 
698
+ A launcher can lock a seat's model/effort: `agent_configure({ session_id, configuration_lock: "lock" | "unlock", configuration_lock_key })` (key: 16-128 printable ASCII characters; Aiterm stores only its SHA-256, per launch). While locked, calls that do not carry the key are refused with `AGENT_CONFIGURATION_LOCKED` and nothing is typed: `agent_configure` with `model`/`reasoning_effort`, `pty_send` text that starts with `/model`, `/models`, `/effort` or `/reasoning`, and `pty_key` Alt+P. `agent_configure` with the matching `configuration_lock_key` still applies, and `fast`, ordinary text and a person typing in the terminal are not affected. Unlock with the key, or close the seat. Keep the key in the launcher; never give it to the seat's AI.
699
+
698
700
  New consumers can opt into an original `request` binding (UUID, expected launch, settings digest) and use `action: "reconcile"` to read the saved outcome without input or replay. Negotiate the exact tool schema before the first call. Handler completion does not prove that previously issued native input cannot act later; current settings inspection remains unsupported. Tracked apply is POSIX-only and uses a local target connection. Existing incidents without the original binding cannot be recovered this way. See the [request/reconcile contract](docs/configure-reconcile.md).
699
701
 
700
702
  For an active Codex v1 goal, `agent_configure` temporarily pauses the goal, waits for the current native turn to end (up to 30 minutes), applies settings through the same send queue, and resumes that goal. Steering remains available during the wait. A changed goal is preserved; a failed or uncertain restoration is reported with the configuration outcome. Other harnesses retain the normal readiness limit: stop or complete a continuously running goal before configuring them.
@@ -710,6 +712,7 @@ Configuration failures keep `isError: true` and the original error text, with `s
710
712
  **ファスト(`fast`)。** 各harnessの、費用や利用量を多く払って応答を速くする切り替え(Claude Codeの`/fast`、Codexの速度の段、GrokとCursorのfast版のmodel)を、席ごとに切り替える(ADR 0114)。
711
713
 
712
714
  - 席は必ず通常の速度で起きる。`agent_launch`の`fast`を省いた時とfalseは同じで、利用者の設定にファストが残っていても通常で始まる。`fast: true`は通常で起こしてから、その席を切り替える。
715
+ - 席のmodel/effortの固定(0.70.71): launcherは`agent_configure({ session_id, configuration_lock: "lock"|"unlock", configuration_lock_key })`で固定・解除する。固定中は、鍵の無い`agent_configure`のmodel/effort、`/model`・`/models`・`/effort`・`/reasoning`で始まる`pty_send`、`pty_key`のAlt+Pを`AGENT_CONFIGURATION_LOCKED`で断る。鍵を付けた`agent_configure`、`fast`、通常の本文、人が端末へ打つ文字は通る。
713
716
  - `agent_configure({ session_id, fast })`は、動いている席を起こし直さずに切り替える。`fast`だけでも渡せる。省略は、その席の今の状態を変えない。
714
717
  - 切り替えは席だけに留める。harnessの切り替えの命令は利用者の既定(`~/.claude/settings.json`の`fastMode`、`~/.codex/config.toml`の`service_tier`、`~/.grok/config.toml`の`[models]`)も書き換えるので、Aitermが切り替えの直前の値へ戻す。Grokは起動の`--model`でも既定を書くので、起動の前後でも戻す。
715
718
  - 返りの`fast`は、切り替えた後の実際の状態。`agent_models`のmodelごとの`fast`が、そのmodelで切り替えられるかを示す(GrokとCursorのfast版は別のmodelとして並ばず、元のmodelの`fast: true`になる)。最上位の`fast_unavailable`は、アカウントの都合でどのmodelでも使えない時の訳。
@@ -0,0 +1,72 @@
1
+ // 席のmodel/effortの固定。持ち主(launcher)だけが知る鍵のSHA-256を席ごとに保存し、鍵を示さない呼びを断る。
2
+ // 保護するもの: 指揮官氏が決めた席の設定を、席の中のAIがAitermのtoolで書き替えること。鍵はlauncherの手元にだけあり、AIには渡らない。
3
+ // 抜け道(self-exit): launcherの`unlock`、または席を閉じる事(pty_closeの片付けがこのfileを消す)。人が端末へ打つ文字はAitermを通らない。
4
+ import crypto from "node:crypto";
5
+ import fs from "node:fs";
6
+ import path from "node:path";
7
+ import { agentsDir, writeJson0600 } from "./agent-shared.js";
8
+ import { tryLoadAgentMetadata } from "./agent-metadata-reader.js";
9
+ import { AitermError } from "./errors.js";
10
+ export const CONFIGURATION_LOCKED = "AGENT_CONFIGURATION_LOCKED";
11
+ const KEY_RE = /^[\x21-\x7e]{16,128}$/;
12
+ const hash = (key) => crypto.createHash("sha256").update(key).digest();
13
+ /** 席の今の起動世代に結び付く。再起動・閉じた席の固定は引き継がない。 */
14
+ function lockPath(name) {
15
+ const meta = tryLoadAgentMetadata(name);
16
+ return meta ? path.join(agentsDir(), `${name}.${meta.launch_id}.configuration-lock.json`) : null;
17
+ }
18
+ function readLock(file) {
19
+ try {
20
+ const v = JSON.parse(fs.readFileSync(file, "utf8"));
21
+ return v?.schema === "aiterm.configuration-lock.v1" && typeof v.key_sha256 === "string" ? Buffer.from(v.key_sha256, "hex") : null;
22
+ }
23
+ catch (e) {
24
+ // 書込みはtemp→renameの原子置換なので、読めない記録は「固定していない」と読む。
25
+ if (e.code === "ENOENT" || e instanceof SyntaxError)
26
+ return null;
27
+ throw e;
28
+ }
29
+ }
30
+ const refusal = (reason) => {
31
+ const error = new AitermError(`${CONFIGURATION_LOCKED}: ${reason} 設定は変えていません。`, 2);
32
+ error.configureRefusal = { code: CONFIGURATION_LOCKED, relaunch: false, selection_excluded: false };
33
+ return error;
34
+ };
35
+ /** 固定中なら、鍵が合う時だけ通す。固定していない席・agentでない席は常に通す。 */
36
+ export function assertConfigurationKey(name, key) {
37
+ const file = lockPath(name), stored = file ? readLock(file) : null;
38
+ if (!stored)
39
+ return;
40
+ const given = key === undefined ? null : hash(key);
41
+ if (!given || !crypto.timingSafeEqual(stored, given))
42
+ throw refusal("この席のmodel/effortは固定されています。持ち主の鍵なしには変えられません。");
43
+ }
44
+ /** launcherの固定・解除。固定中の鍵違いは断る。同じ鍵の固定と、固定していない席の解除は何もしない。 */
45
+ export function applyConfigurationLock(name, action, key) {
46
+ if (key === undefined || !KEY_RE.test(key))
47
+ throw new AitermError("CONFIGURATION_LOCK_KEY_INVALID: configuration_lock_keyは記号を含む印字可能なASCII 16〜128文字で指定してください。", 2);
48
+ const file = lockPath(name);
49
+ if (!file)
50
+ throw new AitermError(`session '${name}' は agent session ではありません。`, 2);
51
+ assertConfigurationKey(name, key);
52
+ if (action === "unlock") {
53
+ fs.rmSync(file, { force: true });
54
+ return "unlocked";
55
+ }
56
+ writeJson0600(file, { schema: "aiterm.configuration-lock.v1", key_sha256: hash(key).toString("hex") });
57
+ return "locked";
58
+ }
59
+ // 席のCLIの入力欄の先頭に置くとmodel/effortを替える命令。fastは対象外。
60
+ const MODEL_COMMAND = /^\s*\/(?:model|models|effort|reasoning)(?![\w-])/i;
61
+ // Claude Codeでmodelの選ぶ画面を開くキー(Alt+P)。
62
+ const MODEL_PICKER_KEY = /^(?:m|a|alt|meta)p$/;
63
+ /** pty_send/pty_keyの入口で、固定中の席へmodel/effortを替える入力を断る。launcherはagent_configureを使う。 */
64
+ export function assertNoModelInput(name, input) {
65
+ const model = (input.text !== undefined && MODEL_COMMAND.test(input.text))
66
+ || (input.key !== undefined && MODEL_PICKER_KEY.test(input.key.toLowerCase().replace(/[-+\s]/g, "")));
67
+ if (!model)
68
+ return;
69
+ const file = lockPath(name);
70
+ if (file && readLock(file))
71
+ throw refusal("この席のmodel/effortは固定されています。席への入力では変えられません。");
72
+ }
@@ -38,13 +38,14 @@ export const configurationReceiptSchema = z.object({ schema: z.literal("aiterm.a
38
38
  const failureSchema = z.object({ schema: z.literal("aiterm.agent-configure-error.v1"), session_id: z.string(),
39
39
  outcome: z.enum(["not_applied", "outcome_unknown"]), effect: z.enum(["not_started", "possible"]) }).strict()
40
40
  .refine(value => value.outcome === "not_applied" ? value.effect === "not_started" : value.effect === "possible");
41
- export const configurationToolOutputSchema = z.object({ ...resultSchema.partial().shape, ...configurationReceiptSchema.partial().shape,
41
+ const lockSchema = z.object({ schema: z.literal("aiterm.agent-configure-lock.v1"), session_id: z.string(), configuration_lock: z.enum(["locked", "unlocked"]) }).strict();
42
+ export const configurationToolOutputSchema = z.object({ ...resultSchema.partial().shape, ...configurationReceiptSchema.partial().shape, ...lockSchema.partial().shape,
42
43
  ...z.object(failureSchema.shape).partial().shape,
43
- schema: z.enum(["aiterm.agent-configure-result.v1", "aiterm.agent-configure-error.v1", "aiterm.agent-configure-request-result.v1"]),
44
+ schema: z.enum(["aiterm.agent-configure-result.v1", "aiterm.agent-configure-error.v1", "aiterm.agent-configure-request-result.v1", "aiterm.agent-configure-lock.v1"]),
44
45
  outcome: configurationReceiptSchema.shape.outcome.optional(),
45
46
  }).strict().superRefine((value, context) => {
46
47
  const schema = value.schema === "aiterm.agent-configure-result.v1" ? resultSchema
47
- : value.schema === "aiterm.agent-configure-error.v1" ? failureSchema : configurationReceiptSchema;
48
+ : value.schema === "aiterm.agent-configure-error.v1" ? failureSchema : value.schema === "aiterm.agent-configure-lock.v1" ? lockSchema : configurationReceiptSchema;
48
49
  if (!schema.safeParse(value).success)
49
50
  context.addIssue({ code: "custom", message: "Invalid configuration result variant" });
50
51
  });
package/dist/core.js CHANGED
@@ -508,7 +508,8 @@ function cleanupAgentState(name) {
508
508
  f.endsWith(".claude-dispatch") ||
509
509
  f.endsWith(".interim.json") ||
510
510
  f.endsWith(".steers.jsonl") ||
511
- f.endsWith(".auth.json"))
511
+ f.endsWith(".auth.json") ||
512
+ f.endsWith(".configuration-lock.json"))
512
513
  fs.unlinkSync(p);
513
514
  else if (f.endsWith(".seat-span.d") || f.endsWith(".codex-home") || f.endsWith(".grok-home") || f.endsWith(".cursor-plugin") || f.endsWith(".antigravity-caller") || f.endsWith(".home") || f.endsWith(".resume-restore.d")) {
514
515
  fs.rmSync(p, { recursive: true, force: true });
package/dist/index.js CHANGED
@@ -6,6 +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 { assertConfigurationKey, applyConfigurationLock, assertNoModelInput } from "./configuration-lock.js";
9
10
  import { AitermError, AgentResumeUnavailableError, AgentResumeError, AgentResumeSecretsError, launchInputRefusal } from "./errors.js";
10
11
  /**
11
12
  * aiterm-mcp — AI が握るローカル永続端末を stdio MCP サーバとして公開する(Node/TS 版)。
@@ -547,6 +548,7 @@ export function createAitermServer(options = {}) {
547
548
  if (require_agent && force) {
548
549
  throw new Error("require_agent:true は force:true と併用できません。文字列は送信していません。");
549
550
  }
551
+ assertNoModelInput(session_id, { text: (preface ?? "") + text });
550
552
  const agentSession = !force && core.isAgentSession(session_id);
551
553
  if (require_agent && !agentSession) {
552
554
  throw new Error(`AGENT_SESSION_REQUIRED: session '${session_id}' のagent登録がありません。文字列は送信していません。`);
@@ -790,6 +792,7 @@ export function createAitermServer(options = {}) {
790
792
  // pty_key peer that still returns the existing text-only success.
791
793
  }, async ({ session_id, key }) => {
792
794
  try {
795
+ assertNoModelInput(session_id, { key });
793
796
  const result = core.sendKeyResult(session_id, key);
794
797
  return { ...ok(`sent key ${result.key} to ${result.session_id}`), structuredContent: { ...result } };
795
798
  }
@@ -1221,10 +1224,28 @@ export function createAitermServer(options = {}) {
1221
1224
  model: z.string().min(1).nullish().describe("変更後のmodel。省略時はmodelを変更しない"),
1222
1225
  reasoning_effort: z.string().min(1).nullish().describe("変更後のreasoning effort。省略時はeffortを変更しない"),
1223
1226
  fast: z.boolean().nullish().describe("変更後のfast。省略時は、その席の今の状態を変えない"),
1227
+ configuration_lock: z.enum(["lock", "unlock"]).optional().describe("launcher用。席のmodel/effortを固定・解除する。configuration_lock_keyが要り、model・reasoning_effort・fast・request・actionとは併用できない。固定中は、AIのtool呼びとして来るmodel/effortの変更とpty_sendの/model・/effort、pty_keyのAlt+Pを断る(fastは対象外)"),
1228
+ configuration_lock_key: z.string().optional().describe("固定の鍵(記号を含む印字可能なASCII 16〜128文字)。Aitermはそのsha256だけを保存する。固定中の席のmodel/effortを変える呼びにはこの鍵が要る。鍵はlauncherだけが持ち、席のAIへ渡さない"),
1224
1229
  },
1225
1230
  outputSchema: configurationToolOutputSchema,
1226
- }, async ({ action, request, session_id, model, reasoning_effort, fast }) => {
1231
+ }, async ({ action, request, session_id, model, reasoning_effort, fast, configuration_lock, configuration_lock_key }) => {
1227
1232
  try {
1233
+ if (configuration_lock) {
1234
+ if (action || request || model != null || reasoning_effort != null || fast != null)
1235
+ throw new AitermError("CONFIGURATION_LOCK_INVALID: configuration_lockは他の設定・actionと併用できません。", 2);
1236
+ const lock = applyConfigurationLock(session_id, configuration_lock, configuration_lock_key);
1237
+ return { content: [{ type: "text", text: JSON.stringify({ session_id, configuration_lock: lock }) }],
1238
+ structuredContent: { schema: "aiterm.agent-configure-lock.v1", session_id, configuration_lock: lock } };
1239
+ }
1240
+ if (model != null || reasoning_effort != null) {
1241
+ try {
1242
+ assertConfigurationKey(session_id, configuration_lock_key);
1243
+ }
1244
+ catch (e) {
1245
+ e.configurationFailure = { schema: "aiterm.agent-configure-error.v1", session_id, outcome: "not_applied", effect: "not_started" };
1246
+ throw e;
1247
+ }
1248
+ }
1228
1249
  if (action === "reconcile") {
1229
1250
  if (!request || model != null || reasoning_effort != null || fast != null)
1230
1251
  throw new Error("CONFIGURATION_RECONCILE_INVALID: request required; settings forbidden");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiterm-mcp",
3
- "version": "0.70.70",
3
+ "version": "0.70.71",
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": [