aiterm-mcp 0.70.69 → 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 +12 -1
- package/README.ja.md +1 -1
- package/README.md +4 -1
- package/dist/configuration-lock.js +72 -0
- package/dist/configure-request.js +4 -3
- package/dist/core.js +27 -3
- package/dist/harnesses/claude-configure.js +13 -1
- package/dist/harnesses/claude.js +10 -7
- package/dist/index.js +22 -1
- package/dist/user-config.js +14 -3
- 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.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
|
+
|
|
14
|
+
## [0.70.70] - 2026-11-15
|
|
15
|
+
|
|
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).
|
|
17
|
+
- The restore of the user's default after a typed `/model opusplan` (or fast) no longer replaces a symlinked `settings.json` with a copy: BellTeam's account roots link `settings.json` to a shared file, the restore wrote a copy beside the link and the real file kept `"model"`. The lock beside the settings file is taken on the real file, and a dangling lock link no longer makes the wait spin forever (a busy loop that froze the Aiterm process) (model-configuration.md).
|
|
18
|
+
|
|
10
19
|
## [0.70.69] - 2026-11-15
|
|
11
20
|
|
|
12
21
|
- The EnterPlanMode spec hook (0.70.67) no longer relies on the call's own transcript rows (Kiro's Z41 lab: a seat that wrote a 300-character spec in the same message was turned back at its first call, 3 of 3 runs). In the interactive Claude Code 2.1.325 the rows of the message that holds the call are often not in the transcript while the hook runs, however long the hook waits (measured up to 2.6 s; they appear after the hook returns), so the hook now counts the assistant text since the last real user prompt up to the call: an earlier message of the same prompt with 80+ characters lets the first call through. When the call's own message is not readable and nothing earlier was written, the first call of a prompt is turned back once (the instruction now says that a seat that has just written its spec only needs to call EnterPlanMode again), the second call always enters. The wait for the call's row is 600 ms instead of 1500 ms (harness-contracts.md "EnterPlanModeの前に仕様を書かせる").
|
|
@@ -3526,7 +3535,9 @@ prototype (preserved under `prototype/python/` as the porting source and referen
|
|
|
3526
3535
|
`ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
|
|
3527
3536
|
provenance.
|
|
3528
3537
|
|
|
3529
|
-
[Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.
|
|
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
|
|
3540
|
+
[0.70.70]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.69...v0.70.70
|
|
3530
3541
|
[0.70.69]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.68...v0.70.69
|
|
3531
3542
|
[0.70.68]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.67...v0.70.68
|
|
3532
3543
|
[0.70.67]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.66...v0.70.67
|
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.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.
|
|
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
|
-
|
|
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 });
|
|
@@ -6723,6 +6724,22 @@ function claudeSeatCatalogEnv(name, meta) {
|
|
|
6723
6724
|
env[key] = value;
|
|
6724
6725
|
return env;
|
|
6725
6726
|
}
|
|
6727
|
+
const IN_TURN_PANE_ROWS = 50;
|
|
6728
|
+
/**
|
|
6729
|
+
* The lines of a running turn (spinner, a tool's block) plus the model picker are taller than the default 24-row pane: the picker's
|
|
6730
|
+
* foot ("Esc to cancel") is cut and the picker cannot be read (Z43 lab, reproduced on 2.1.325). The pane is made taller for the
|
|
6731
|
+
* switch; returns the undo (the original size), or null when nothing was changed.
|
|
6732
|
+
*/
|
|
6733
|
+
async function tallenPaneForPicker(name) {
|
|
6734
|
+
const size = tmux("display-message", "-p", "-t", `=${name}:`, "#{window_width} #{window_height}");
|
|
6735
|
+
const [width, height] = size.stdout.trim().split(/\s+/u).map(Number);
|
|
6736
|
+
if (size.code !== 0 || !(width > 0) || !(height > 0) || height >= IN_TURN_PANE_ROWS)
|
|
6737
|
+
return null;
|
|
6738
|
+
if (tmux("resize-window", "-t", name, "-x", String(width), "-y", String(IN_TURN_PANE_ROWS)).code !== 0)
|
|
6739
|
+
return null;
|
|
6740
|
+
await sleep(400); // Claude Code redraws to the new height
|
|
6741
|
+
return () => { tmux("resize-window", "-t", name, "-x", String(width), "-y", String(height)); };
|
|
6742
|
+
}
|
|
6726
6743
|
/** Whether a Claude goal is running on the seat (inside the send lock). Unreadable counts as no goal: the picker path is harmless either way. */
|
|
6727
6744
|
async function claudeGoalActive(name, meta) {
|
|
6728
6745
|
try {
|
|
@@ -6851,8 +6868,15 @@ async function configureAgentInLock(name, model, effort, fast, beforeChange) {
|
|
|
6851
6868
|
}
|
|
6852
6869
|
if (model?.toLowerCase() === "opusplan")
|
|
6853
6870
|
await switchClaudeOpusPlan(name, meta, beforeChange);
|
|
6854
|
-
if (model || level)
|
|
6855
|
-
|
|
6871
|
+
if (model || level) {
|
|
6872
|
+
const restoreSize = inTurn ? await tallenPaneForPicker(name) : null;
|
|
6873
|
+
try {
|
|
6874
|
+
await configureClaudeForSessionOnly(name, meta, model, level, beforeChange, { ...agentModelUi(name), ready: () => waitAgentTuiReady(name, meta, AGENT_TUI_READY_TIMEOUT_MS) }, claudeSeatEnv() ?? process.env, inTurn);
|
|
6875
|
+
}
|
|
6876
|
+
finally {
|
|
6877
|
+
restoreSize?.();
|
|
6878
|
+
}
|
|
6879
|
+
}
|
|
6856
6880
|
if (effort && !level) {
|
|
6857
6881
|
beforeChange();
|
|
6858
6882
|
await sendAgentPromptText(name, `/effort ${effort}`);
|
|
@@ -59,6 +59,17 @@ inTurn = false) {
|
|
|
59
59
|
if (!now) {
|
|
60
60
|
// 読めない形の画面が開いたままだと、席が次の文を受け取れない。入力待ちでも動作中でもない時だけ、Escを1度打って閉じる。
|
|
61
61
|
let state = claudePaneObservation(screen());
|
|
62
|
+
// In a running turn the picker may be open but not readable; Esc closes it only while its heading is on screen
|
|
63
|
+
// (anywhere else an Esc stops the turn), and a picker left open would take the next typed message as keys (Z43).
|
|
64
|
+
const headingShown = () => /^\s*(?:Select model|Choose a model)\s*$/mu.test(screen());
|
|
65
|
+
let closedPicker = false;
|
|
66
|
+
if (inTurn) {
|
|
67
|
+
for (let i = 0; i < 3 && headingShown(); i++) {
|
|
68
|
+
ui.key("Escape");
|
|
69
|
+
await sleep(300);
|
|
70
|
+
}
|
|
71
|
+
closedPicker = !headingShown();
|
|
72
|
+
}
|
|
62
73
|
if (!inTurn && state.state === "unknown") {
|
|
63
74
|
ui.key("Escape");
|
|
64
75
|
await sleep(500);
|
|
@@ -67,7 +78,8 @@ inTurn = false) {
|
|
|
67
78
|
const error = new AitermError(`CLAUDE_MODEL_PICKER_NOT_SHOWN vendor=claude session=${name} state=${state.state}/${state.reason}\n` +
|
|
68
79
|
"Claude Codeの /model の選ぶ画面を読めません(Claude Codeの版で画面の形が変わった見込み)。modelとreasoning_effortは変えていません。", 2);
|
|
69
80
|
// 読めない画面が何を受けたかは分からないので、選ばれていないとは記録しない。
|
|
70
|
-
|
|
81
|
+
// In a running turn only the opening key and the closing Esc were sent, so nothing was selected once the picker is gone.
|
|
82
|
+
error.configureRefusal = { code: "CLAUDE_MODEL_PICKER_NOT_SHOWN", relaunch: false, selection_excluded: closedPicker };
|
|
71
83
|
throw error;
|
|
72
84
|
}
|
|
73
85
|
if (!now.session_only) {
|
package/dist/harnesses/claude.js
CHANGED
|
@@ -637,11 +637,13 @@ export function claudeModelSwitchConfirm(screen) {
|
|
|
637
637
|
}
|
|
638
638
|
function switchResultAt(lines, start) {
|
|
639
639
|
const parts = [lines[start].replace(/^\s*⎿\s+/u, "").trim()];
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
640
|
+
// Only a ⎿ row can continue on the lines below; the plain notification of an in-turn switch is one line.
|
|
641
|
+
if (/^\s*⎿/u.test(lines[start]))
|
|
642
|
+
for (const line of lines.slice(start + 1)) {
|
|
643
|
+
if (!/^\s{3,}\S/u.test(line) || /^\s*⎿/u.test(line))
|
|
644
|
+
break;
|
|
645
|
+
parts.push(line.trim());
|
|
646
|
+
}
|
|
645
647
|
const line = parts.join(" ");
|
|
646
648
|
if (/\bblocked by a PreModelSwitch hook\b/u.test(line))
|
|
647
649
|
return { scope: "blocked", line };
|
|
@@ -663,11 +665,12 @@ export function claudeModelSwitchResult(screen) {
|
|
|
663
665
|
}
|
|
664
666
|
/**
|
|
665
667
|
* Every switch result line on the screen, oldest first. A switch made with Alt+P in a running turn prints its result with no
|
|
666
|
-
* `❯ /model` line above it (2.1.325), so the caller compares against the lines present before the picker was opened.
|
|
668
|
+
* `❯ /model` line above it and without the ⎿ mark (2.1.325), so the caller compares against the lines present before the picker was opened.
|
|
667
669
|
*/
|
|
668
670
|
export function claudeModelSwitchResults(screen) {
|
|
669
671
|
const lines = screen.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "").split(/\r?\n/u);
|
|
670
|
-
|
|
672
|
+
// A switch made with Alt+P in a running turn shows its result as a plain, indented notification line: no ⎿ (2.1.325 lab).
|
|
673
|
+
return lines.flatMap((text, i) => /^\s*(?:⎿\s+\S|(?:Model set to|Set model to|Kept model as)\b)/u.test(text) ? [switchResultAt(lines, i)] : []).filter(row => row !== null);
|
|
671
674
|
}
|
|
672
675
|
// Claude Code 2.1.282 は選択肢へ「1.」などの番号を付ける。番号の有無のどちらも受ける。
|
|
673
676
|
export function claudeLoginMethodMenu(screen) {
|
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/dist/user-config.js
CHANGED
|
@@ -16,7 +16,7 @@ const LOCK_POLL_MS = 120;
|
|
|
16
16
|
* 設定fileの置き場が無い・書けない時は、harnessも書けないので鍵なしで通す。
|
|
17
17
|
*/
|
|
18
18
|
export async function withUserConfigLock(configPath, action) {
|
|
19
|
-
const lock = `${configPath}.aiterm-lock`;
|
|
19
|
+
const lock = `${realPathOrSelf(configPath)}.aiterm-lock`;
|
|
20
20
|
if (!fs.existsSync(path.dirname(configPath)))
|
|
21
21
|
return action();
|
|
22
22
|
const deadline = Date.now() + LOCK_WAIT_MS;
|
|
@@ -32,9 +32,10 @@ export async function withUserConfigLock(configPath, action) {
|
|
|
32
32
|
}
|
|
33
33
|
let age = 0;
|
|
34
34
|
try {
|
|
35
|
-
age = Date.now() - fs.
|
|
35
|
+
age = Date.now() - fs.lstatSync(lock).mtimeMs;
|
|
36
36
|
}
|
|
37
37
|
catch {
|
|
38
|
+
await sleep(LOCK_POLL_MS);
|
|
38
39
|
continue;
|
|
39
40
|
}
|
|
40
41
|
if (age > LOCK_STALE_MS) {
|
|
@@ -72,7 +73,17 @@ export function readFileOrNull(file) {
|
|
|
72
73
|
return null;
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
|
-
|
|
76
|
+
/** A root's settings.json can be a symlink to a shared file (BellTeam 2nd-account roots): lock and write the real file, never replace the link. */
|
|
77
|
+
function realPathOrSelf(file) {
|
|
78
|
+
try {
|
|
79
|
+
return fs.realpathSync(file);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return file;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function writeInPlace(link, body) {
|
|
86
|
+
const file = realPathOrSelf(link);
|
|
76
87
|
let mode = 0o600;
|
|
77
88
|
try {
|
|
78
89
|
mode = fs.statSync(file).mode & 0o777;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiterm-mcp",
|
|
3
|
-
"version": "0.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": [
|