aiterm-mcp 0.62.5 → 0.63.0
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 +23 -1
- package/README.ja.md +8 -2
- package/README.md +8 -2
- package/dist/agent-activity.js +69 -0
- package/dist/agent-goal.js +3 -1
- package/dist/agent-idle-cli.js +36 -0
- package/dist/agent-idle-clock.js +100 -0
- package/dist/agent-idle.js +92 -0
- package/dist/agent-lifecycle.js +182 -0
- package/dist/agent-resolver.js +1 -1
- package/dist/agent-shared.js +61 -0
- package/dist/aiterm-wait-cli.js +11 -4
- package/dist/claude-stop-hook.js +12 -1
- package/dist/configure-goal.js +63 -0
- package/dist/core.js +1261 -304
- package/dist/errors.js +1 -0
- package/dist/execution-effect.js +8 -0
- package/dist/harnesses/claude.js +20 -5
- package/dist/harnesses/codex.js +170 -10
- package/dist/harnesses/grok.js +21 -0
- package/dist/harnesses/idle-settings.js +109 -0
- package/dist/index.js +14 -7
- package/dist/interim-words.js +18 -3
- package/dist/native-session.js +22 -0
- package/dist/process-runtime.js +83 -9
- package/dist/process-start.js +26 -7
- package/dist/process-tree-stop.js +91 -0
- package/dist/psmux-send-worker.js +7 -1
- package/dist/steer-follow.js +88 -3
- package/dist/tmux-runtime.js +157 -8
- package/docs/DESIGN.md +13 -1
- package/package.json +3 -2
package/dist/tmux-runtime.js
CHANGED
|
@@ -7,10 +7,120 @@ import * as path from "node:path";
|
|
|
7
7
|
import * as os from "node:os";
|
|
8
8
|
import { createHash } from "node:crypto";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
10
11
|
import stringWidth from 'string-width';
|
|
11
12
|
import { AitermError, ptyDependencyError } from "./errors.js";
|
|
12
13
|
import { guardTmuxExecution, beforeExecutionEffect, hasExecutionCreationScope, prepareExecutionCreation, captureExecutionCreatedNative } from "./execution-effect.js";
|
|
13
14
|
import { ExecutionError } from "./execution-wire.js";
|
|
15
|
+
import { parseNativeSessionReceipt, nativePaneTarget, nativeSessionTarget, nativeSessionCondition } from "./native-session.js";
|
|
16
|
+
const nativeTargets = new AsyncLocalStorage();
|
|
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"]);
|
|
19
|
+
const nativeTargetUnavailable = () => new AitermError("AGENT_RESUME_UNCONFIRMED: 復帰したnative端末の本人性を確認できません。", 2);
|
|
20
|
+
function verifyNativeTarget(frame) {
|
|
21
|
+
if (frame.checking)
|
|
22
|
+
return;
|
|
23
|
+
frame.checking = true;
|
|
24
|
+
try {
|
|
25
|
+
frame.verify();
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
frame.checking = false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** Target routing only: guardTmuxExecution still owns every effect authorization. */
|
|
32
|
+
export function withNativeSessionTarget(target, verify, body, allowExitedPane = false) {
|
|
33
|
+
const enclosing = nativeTargets.getStore();
|
|
34
|
+
if (enclosing && JSON.stringify(enclosing.target) !== JSON.stringify(target))
|
|
35
|
+
throw nativeTargetUnavailable();
|
|
36
|
+
const frame = { session: target.session_id, target, verify, allowExitedPane };
|
|
37
|
+
return nativeTargets.run(frame, () => { verifyNativeTarget(frame); return body(); });
|
|
38
|
+
}
|
|
39
|
+
export function hasVerifiedNativeSessionTarget(name) {
|
|
40
|
+
const frame = nativeTargets.getStore();
|
|
41
|
+
if (!frame?.target || frame.session !== name)
|
|
42
|
+
return false;
|
|
43
|
+
verifyNativeTarget(frame);
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
export function withNativeSessionCreation(session, created, verify, body) {
|
|
47
|
+
if (nativeTargets.getStore())
|
|
48
|
+
throw nativeTargetUnavailable();
|
|
49
|
+
return nativeTargets.run({ session, target: null, created, verify }, body);
|
|
50
|
+
}
|
|
51
|
+
function captureNativeSessionReceipt(receipt) {
|
|
52
|
+
const frame = nativeTargets.getStore();
|
|
53
|
+
if (!frame?.created || frame.target)
|
|
54
|
+
throw nativeTargetUnavailable();
|
|
55
|
+
let target;
|
|
56
|
+
try {
|
|
57
|
+
target = parseNativeSessionReceipt(receipt);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
throw nativeTargetUnavailable();
|
|
61
|
+
}
|
|
62
|
+
if (frame.session !== null && target.session_id !== frame.session)
|
|
63
|
+
throw nativeTargetUnavailable();
|
|
64
|
+
frame.session = target.session_id;
|
|
65
|
+
frame.target = target;
|
|
66
|
+
frame.created({ ...frame.target });
|
|
67
|
+
verifyNativeTarget(frame);
|
|
68
|
+
}
|
|
69
|
+
function nativeSessionArgs(input) {
|
|
70
|
+
const frame = nativeTargets.getStore();
|
|
71
|
+
if (!frame)
|
|
72
|
+
return input;
|
|
73
|
+
const args = [...input];
|
|
74
|
+
let effect = false, targetedRead = false;
|
|
75
|
+
for (let start = 0; start < args.length;) {
|
|
76
|
+
let end = args.indexOf(";", start);
|
|
77
|
+
if (end < 0)
|
|
78
|
+
end = args.length;
|
|
79
|
+
const command = args[start];
|
|
80
|
+
if (!nativeReads.has(command) && command !== "delete-buffer")
|
|
81
|
+
effect = true;
|
|
82
|
+
if (command === "new-session") {
|
|
83
|
+
const named = args.findIndex((value, index) => index > start && index < end && value === "-s");
|
|
84
|
+
if (frame.target || !frame.created || named < 0 || frame.session !== null && args[named + 1] !== frame.session)
|
|
85
|
+
throw nativeTargetUnavailable();
|
|
86
|
+
}
|
|
87
|
+
const at = args.findIndex((value, index) => index > start && index < end && value === "-t");
|
|
88
|
+
if (at >= 0) {
|
|
89
|
+
if (frame.session === null && !frame.target && nativeReads.has(command)) {
|
|
90
|
+
start = end + 1;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
targetedRead ||= nativeReads.has(command);
|
|
94
|
+
const raw = args[at + 1], named = /^=?([A-Za-z0-9_-]{1,64})(?::(?:\d+(?:\.\d+)?)?)?$/.exec(raw);
|
|
95
|
+
const own = named?.[1] === frame.session || raw === frame.target?.native_id || raw === frame.target?.pane_id
|
|
96
|
+
|| frame.target !== null && raw === nativePaneTarget(frame.target);
|
|
97
|
+
if (!own || (!frame.target && !nativeReads.has(command)))
|
|
98
|
+
throw nativeTargetUnavailable();
|
|
99
|
+
args[at + 1] = frame.target ? (nativePanes.has(command) ? nativePaneTarget(frame.target) : nativeSessionTarget(frame.target)) : `=${frame.session}`;
|
|
100
|
+
}
|
|
101
|
+
start = end + 1;
|
|
102
|
+
}
|
|
103
|
+
if (effect || (targetedRead && frame.target)) {
|
|
104
|
+
if (frame.target)
|
|
105
|
+
verifyNativeTarget(frame);
|
|
106
|
+
else if (!args.includes("new-session") && !(args.length === 3 && args[0] === "set-option" && args[1] === "-gu" && args[2] === "update-environment"))
|
|
107
|
+
throw nativeTargetUnavailable();
|
|
108
|
+
}
|
|
109
|
+
return args;
|
|
110
|
+
}
|
|
111
|
+
const NATIVE_REFUSED = "__AITERM_NATIVE_GENERATION_REFUSED__";
|
|
112
|
+
/** Check on the receiving server too: a new server may recycle session and pane IDs. */
|
|
113
|
+
function nativeConditionalArgs(args) {
|
|
114
|
+
const target = nativeTargets.getStore()?.target;
|
|
115
|
+
if (!target || nativeReads.has(args[0]) || args[0] === "delete-buffer")
|
|
116
|
+
return args;
|
|
117
|
+
const condition = nativeSessionCondition(target, nativeTargets.getStore()?.allowExitedPane);
|
|
118
|
+
const quote = (value) => isWin
|
|
119
|
+
? `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`
|
|
120
|
+
: `'${value.replace(/'/g, "'\\''")}'`;
|
|
121
|
+
const command = args.map(quote).join(" ");
|
|
122
|
+
return ["if-shell", "-F", "-t", nativePaneTarget(target), condition, command, `display-message -p ${NATIVE_REFUSED}`];
|
|
123
|
+
}
|
|
14
124
|
// Windows ネイティブには tmux が無いため、tmux CLI 互換の native psmux を叩く
|
|
15
125
|
// (POSIX = Linux/WSL2/macOS は従来どおり tmux を直接叩く。WSL 橋は e3f5fc8 で全廃)。
|
|
16
126
|
export const isWin = process.platform === "win32";
|
|
@@ -243,7 +353,9 @@ export function tmuxCommandWithInput(observe, input, ...args) {
|
|
|
243
353
|
// session は、新しい session を作る呼び出しの時だけ渡す client の環境(POSIX のみ)。server を起こし得るのは
|
|
244
354
|
// この呼び出しだけなので、空 config の指定と macOS の gui domain での起動もここに限る。
|
|
245
355
|
function runTmux(observe, input, args, session) {
|
|
246
|
-
|
|
356
|
+
// Authorize the logical/native session before routing it to its pinned pane.
|
|
357
|
+
args = nativeSessionArgs(guardTmuxExecution(args));
|
|
358
|
+
args = nativeConditionalArgs(args);
|
|
247
359
|
// maxBuffer は既定 1MiB。capture-pane(大きなスクロールバック)や多セッションの list-sessions で
|
|
248
360
|
// 頭打ちになり stdout が切れる/空になる。Python の subprocess.run は無制限だったので 64MiB へ広げる。
|
|
249
361
|
// Windows は tmux CLI 互換の native psmux を -L namespace 隔離で叩く(WSL 非依存)。
|
|
@@ -272,6 +384,11 @@ function runTmux(observe, input, args, session) {
|
|
|
272
384
|
tmuxBin = null; // 次回 resolveTmux で再解決を許す
|
|
273
385
|
ptyDependencyError(tmuxMissingMessage(), observe);
|
|
274
386
|
}
|
|
387
|
+
const native = nativeTargets.getStore();
|
|
388
|
+
if (native?.target && args[0] === "if-shell" && (r.stdout ?? "").trim() === NATIVE_REFUSED)
|
|
389
|
+
throw nativeTargetUnavailable();
|
|
390
|
+
if (native?.target && r.status !== 0)
|
|
391
|
+
verifyNativeTarget(native);
|
|
275
392
|
return { code: r.status ?? 1, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
|
|
276
393
|
}
|
|
277
394
|
// macOS の login keychain は GUI(Aqua)の security session からしか読めない。SSH 等から立てた
|
|
@@ -394,9 +511,16 @@ export function sendPsmuxPayload(observe, sessionName, text, bracketedPaste) {
|
|
|
394
511
|
return { code: 1, stdout: "", stderr: "psmux direct send is Windows-only" };
|
|
395
512
|
ensureWinPsmux(observe);
|
|
396
513
|
beforeExecutionEffect(sessionName);
|
|
514
|
+
const frame = nativeTargets.getStore();
|
|
515
|
+
if (frame && (!frame.target || frame.session !== sessionName))
|
|
516
|
+
throw nativeTargetUnavailable();
|
|
517
|
+
if (frame)
|
|
518
|
+
verifyNativeTarget(frame);
|
|
519
|
+
const target = frame?.target;
|
|
520
|
+
const proof = target ? [target.native_id, target.session_id, target.server_pid, target.pane_id, target.pane_pid].join("\t") : null;
|
|
397
521
|
const worker = fileURLToPath(new URL("./psmux-send-worker.js", import.meta.url));
|
|
398
522
|
const body = bracketedPaste ? `\x1b[200~${text}\x1b[201~` : text;
|
|
399
|
-
const result = spawnSync(process.execPath, [worker, `${WIN_NS}__${sessionName}
|
|
523
|
+
const result = spawnSync(process.execPath, [worker, `${WIN_NS}__${sessionName}`, ...(proof === null ? [] : [proof])], {
|
|
400
524
|
encoding: "utf8",
|
|
401
525
|
maxBuffer: 1024 * 1024,
|
|
402
526
|
input: Buffer.from(body, "utf8"),
|
|
@@ -457,8 +581,9 @@ export function sessionEnvironmentLaunch(shell, environment, version) {
|
|
|
457
581
|
environment = [...environment, `PATH=${callerPath}`];
|
|
458
582
|
}
|
|
459
583
|
const modern = isWin || tmuxHasSessionEnvironmentFlags(version);
|
|
584
|
+
// tmux's argv parser treats even an environment value's trailing semicolon as a command separator.
|
|
460
585
|
if (modern)
|
|
461
|
-
return { shell, args: environment.flatMap(entry => ["-e", entry]), register_after_start: false };
|
|
586
|
+
return { shell, args: environment.flatMap(entry => ["-e", isWin ? entry : entry.replace(/;$/, "\\;")]), register_after_start: false };
|
|
462
587
|
// tmux <3.2はnew-session -eを持たない。子への継承とsession台帳への登録を製品内で完結する。
|
|
463
588
|
const quote = (value) => `'${value.replace(/'/g, "'\\''")}'`;
|
|
464
589
|
return { shell: `exec /usr/bin/env ${environment.map(quote).join(" ")} ${quote(shell)}`, args: [], register_after_start: true };
|
|
@@ -498,6 +623,11 @@ export function registeredSessionEnvironment(name) {
|
|
|
498
623
|
const r = runTmux(false, undefined, ["show-options", "-t", `=${name}:`, "-v", REGISTERED_ENV_OPTION]);
|
|
499
624
|
return r.code === 0 && r.stdout.trim() ? r.stdout.trim().split(" ") : null;
|
|
500
625
|
}
|
|
626
|
+
export function registerSessionEnvironment(observe, name, keys) {
|
|
627
|
+
if (keys.some(key => !ENV_NAME.test(key)))
|
|
628
|
+
throw new AitermError("env_varsの環境変数名が不正です", 2);
|
|
629
|
+
return runTmux(observe, undefined, ["set-option", "-t", `=${name}:`, REGISTERED_ENV_OPTION, [...new Set(keys)].join(" ")]);
|
|
630
|
+
}
|
|
501
631
|
// tmux は、server を起こした client の環境を共通環境として全 session へ配る。何もしないと、最初に端末を
|
|
502
632
|
// 開いた呼び出し元の値が、後から別の呼び出し元が開く端末へ入る。新しい端末の環境を「開いた process の環境」に
|
|
503
633
|
// するため、new-session の間だけ update-environment を差し替えて client の環境を session へ写し、共通環境に
|
|
@@ -505,6 +635,7 @@ export function registeredSessionEnvironment(name) {
|
|
|
505
635
|
// 変えない。同じ server を使う旧版の process が、開く端末の環境をそこから受け取っている。
|
|
506
636
|
export function tmuxNewSession(observe, name, launch, registered = []) {
|
|
507
637
|
const guarded = hasExecutionCreationScope();
|
|
638
|
+
const pinned = nativeTargets.getStore()?.created !== undefined;
|
|
508
639
|
// Windows per-session server creation needs a separate native-owner proof.
|
|
509
640
|
// The legacy public launcher is unchanged.
|
|
510
641
|
let cold = false;
|
|
@@ -513,11 +644,27 @@ export function tmuxNewSession(observe, name, launch, registered = []) {
|
|
|
513
644
|
throw new ExecutionError("EXECUTION_UNSUPPORTED");
|
|
514
645
|
cold = prepareExecutionCreation();
|
|
515
646
|
}
|
|
516
|
-
const printNative =
|
|
647
|
+
const printNative = pinned ? ["-P", "-F", "#{session_id}\t#{session_name}\t#{pid}\t#{pane_id}\t#{pane_pid}"]
|
|
648
|
+
: guarded ? ["-P", "-F", "#{session_id}\t#{session_name}\t#{pid}"] : [];
|
|
517
649
|
if (isWin) {
|
|
518
650
|
const result = runTmux(observe, undefined, ["new-session", "-d", "-s", name, ...printNative, ...launch.args, "-f", TMUX_EMPTY_CONFIG, launch.shell]);
|
|
651
|
+
if (result.code === 0) {
|
|
652
|
+
if (pinned) {
|
|
653
|
+
try {
|
|
654
|
+
if (parseNativeSessionReceipt(result.stdout).session_id !== name)
|
|
655
|
+
throw nativeTargetUnavailable();
|
|
656
|
+
}
|
|
657
|
+
catch {
|
|
658
|
+
throw nativeTargetUnavailable();
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
// Existing psmux 3.3.8 registry protection must run before identity reads can trigger registry reaping.
|
|
662
|
+
openPsmuxServerToDesktop(name);
|
|
663
|
+
}
|
|
519
664
|
if (guarded && (result.code === 0 || result.stdout))
|
|
520
665
|
captureExecutionCreatedNative(result.stdout);
|
|
666
|
+
if (pinned && (result.code === 0 || result.stdout))
|
|
667
|
+
captureNativeSessionReceipt(result.stdout);
|
|
521
668
|
return result;
|
|
522
669
|
}
|
|
523
670
|
const env = sessionCallerEnvironment();
|
|
@@ -540,20 +687,22 @@ export function tmuxNewSession(observe, name, launch, registered = []) {
|
|
|
540
687
|
const r = runTmux(observe, undefined, [
|
|
541
688
|
"set-option", "-g", "update-environment", updateEnvironmentPatterns(Object.keys(env), [...others], wildcard).join(" "), ";",
|
|
542
689
|
"new-session", "-d", "-s", name, ...printNative, ...launch.args, ...command, ";",
|
|
543
|
-
...(guarded ? [] : ["set-option", "-t", `=${name}:`, REGISTERED_ENV_OPTION, registered.join(" "), ";"]),
|
|
690
|
+
...(guarded || pinned ? [] : ["set-option", "-t", `=${name}:`, REGISTERED_ENV_OPTION, registered.join(" "), ";"]),
|
|
544
691
|
"set-option", "-gu", "update-environment",
|
|
545
692
|
], env);
|
|
546
693
|
// Bind only the ID printed by this exact create command. Target-specific
|
|
547
694
|
// setup runs later through that native ID, never a fresh same-name lookup.
|
|
548
695
|
if (guarded && (r.code === 0 || r.stdout))
|
|
549
696
|
captureExecutionCreatedNative(r.stdout);
|
|
697
|
+
if (pinned && (r.code === 0 || r.stdout))
|
|
698
|
+
captureNativeSessionReceipt(r.stdout);
|
|
550
699
|
if (r.code !== 0) {
|
|
551
700
|
// 途中の命令が失敗すると、後続の命令は実行されない。差し替えた設定を戻す。
|
|
552
701
|
runTmux(false, undefined, ["set-option", "-gu", "update-environment"]);
|
|
553
702
|
return r;
|
|
554
703
|
}
|
|
555
|
-
if (guarded) {
|
|
556
|
-
const registeredResult =
|
|
704
|
+
if (guarded || pinned) {
|
|
705
|
+
const registeredResult = registerSessionEnvironment(observe, name, registered);
|
|
557
706
|
if (registeredResult.code !== 0)
|
|
558
707
|
return registeredResult;
|
|
559
708
|
}
|
|
@@ -565,7 +714,7 @@ export function tmuxNewSession(observe, name, launch, registered = []) {
|
|
|
565
714
|
if (uncovered?.length === 0)
|
|
566
715
|
return r;
|
|
567
716
|
runTmux(false, undefined, ["kill-session", "-t", `=${name}`]);
|
|
568
|
-
if (guarded || !uncovered || attempt >= 2) {
|
|
717
|
+
if (guarded || pinned || !uncovered || attempt >= 2) {
|
|
569
718
|
return { code: 1, stdout: "", stderr: "共通環境の変数をsessionから外せなかったため、sessionを破棄しました" };
|
|
570
719
|
}
|
|
571
720
|
for (const key of uncovered)
|
package/docs/DESIGN.md
CHANGED
|
@@ -183,6 +183,12 @@ Codex model-only configuration reads the native current effort before navigating
|
|
|
183
183
|
|
|
184
184
|
4harness共通の`agent_configure`は、変更を発行し得る境界に達したかを要求内で保持する。失敗は`aiterm.agent-configure-error.v1`の`not_applied/not_started`又は`outcome_unknown/possible`で返し、後者には部分適用を含む。これは要求単位の保守的な分類で、以前の実設定や他要求の状態は証明しない。成功型は維持し、Codexの完了は指定ID・effortに一致する新規native通知を確認する。別modelの通知や残画面では成功にしない。
|
|
185
185
|
|
|
186
|
+
Codex v1のactive goalは設定替えの間だけ一時停止する。`configure-goal.ts`がpause→nativeの番終了待ち→既存の設定替え→resumeを持つ。coreは同じlaunch/threadへの束縛と番終了記録を供給し、待機中は送信lockを持たない。pause/resumeは既存のCLI goal adapterで一度だけ発行し、mutation直前のnative readbackが比較元から変われば発行しない。設定替え失敗でも自分のpauseの復元を試み、別goalや変更されたgoalは再開しない。公開schemaは維持し、設定とgoalの不確定な結果はエラー本文で併記する(ADR 0137)。
|
|
187
|
+
|
|
188
|
+
無活動判定用の時刻は、起動世代ごとのactivity.jsonlに追記する。agent-activity.tsがlast_input_atとlast_turn_end_atを返し、metadata全体を書き戻す処理とは独立する。親からの初手・dispatch・steerのPTY書込み境界と、Claude Stop/既存のnative完了観測だけが記録する。同じ番の完了を繰り返し読んでも起点を更新せず、途中出力・画面描画・設定命令では更新しない。履歴欠測と破損は未知として扱い、時刻記録失敗で既に得た完了結果を失わせない。Claude/Codexの3OS実会話復帰・公開論理席とconsumer受入に基づき、通常起動では自動休止を有効にする(ADR 0138)。node:testのfixtureはcontrollerを明示駆動し、無人timerを作らない。
|
|
189
|
+
|
|
190
|
+
休止判定の部品はagent-idle.ts、木の停止はprocess-tree-stop.tsに置く。前者はruntimeが供給する既存の席admissionで世代/入力/保護条件を再確認し、未確定を成功にしない。後者は本人性を照合したpane木へTERM→5秒→KILLと退出確認を行い、POSIXの別sessionを除外する。OSごとのsignalはprocess-runtime.tsが所有する。本体adapterは既存送信queue/file lockで期待launchと元のnative ID/pane本人性を固定する。最新native完了の保存とprivate resume recipeの一致を確認し、durable stoppingの後も最初のsignal前は保護条件全体を再確認する。効果前だけ準備を取消し、効果後の不明はstoppingに残す。木の退出後に元native IDを閉じ、同世代だけをhibernatedへ進める。時計はper-launchのdetached shell/sleep(WindowsはPowerShell 7)で待ち、起床時だけNodeで同じC判定を行う。owner/tokenを同じ送信排他で記録し、busy等は60秒後の後続確認を持つ。list/launch/Stop/waiterから起動口を通し、元のnative作成proofが無い旧席には時計を登録しない。新規起動templateと設定替えの更新は接続し、既定値欠測や途中設定失敗は休止を許可しない。各世代のmetadataは保持し、active-launch.jsonの原子的切替で現在のlaunchを選ぶ。Codexの停止前には一意な起動marker付きroot/完了境界を検証し、file本人性・prefix hash・旧cursor/turn IDのproofをlifecycleへ束縛する。resumed_fromを持つ読取りは旧metadata/lifecycle/recipe/proofを照合し、保存cursor以前と最後の旧turnの遅れた記録を除外する。通常waiter・番境界・差し込み・合間の言葉と次回停止が同じ相関を使い、復帰後の/newは新markerだけで認める。物理再開候補は同じ送信排他で旧stateを残し、新世代の公式resume→ready/fast確認→本文投入を進める。private resume-attemptの失敗は追加CLIと本文を止め、Claudeの設定rootもper-launchで保持する。通常POSIXのmanaged Claude/Codex初回起動も、実create receiptをその場で取得し、送信/休止と同じfile lockを取ってから旧記録を掃除する。同名置換・休止競合ではCLIを入れず古い記録を残し、自動採番も論理席名を避ける。実create receipt由来のnative IDとserver/paneの開始本人性をprivateに保存し、同じ送信排他でCLI/ready/fast/本文と後続操作を固定する。tmux受信側のnative format条件も同じqueueで確かめ、server再起動によるID再利用を拒否する。既存effect guardを迂回せず、正規resume transitionの無いmounted graphは停止・再開対象外にする。Windowsはqualified paneと固定server認証・native本人性を用いる。既存psmux registry保護を開始本人性取得の前へ置き、server/paneの開始時刻は保存精度を保って一括取得する。Windows closeは元server終了の確認後に記録を片付ける。受信側命令の引用はpsmuxのparserに合わせる。Windowsのnative clockはconsoleを継がないProcessStartInfoとnull標準handleで起こし、一時receiptのPID/開始時刻を保存して起動helperを終了する。同名agent_launchも保存設定を照合して同会話へ戻し、既存の初手/tupleを使う。公開list/observe/seat_turns/closeは論理席を扱い、内部の物理観測と分離する。native読取り/キー/承認は休止・復帰途中・失敗を拒否し、復帰先の実receiptへ固定する。中断は確定休止ならidleで返し、途中や不整合を拒否する。キーと承認応答は送信file lockを共有し、停止ボタンの即時性と既存のキー制限は維持する。登録env名も再現し、復帰中から公開一覧の本人性を保つ。native手動設定とClaude/Codex各3OSの実会話復帰、公開論理席とconsumerを受入済み。元作成証拠を持たない旧席・未受入harnessは対象へ登録しない(ADR 0138)。
|
|
191
|
+
|
|
186
192
|
agent turnは常に非ブロックdispatchであり、receiptの`event_cursor`がturn境界になる。
|
|
187
193
|
Codex親にはAitermのMCP processが完了を観測し、選択設定に応じて公式Steerまたはqueueへ本文を自動配送する。
|
|
188
194
|
Claude Code親は公式の非同期hookで本文を受け取り、待機中も新しいturnへ進める。
|
|
@@ -205,9 +211,11 @@ Claude Codeはtool処理中に画面の実行中表示が消え、Stop hookの
|
|
|
205
211
|
待つ上限は、起動から最初の描画を待つ上限と貼り付けの上限の和で、越えたら`AGENT_SEND_BUSY`で未送信を返す。判断の記録はADR 0088(`docs/adr/0088-one-agent-send-per-session.md`)。
|
|
206
212
|
CodexとClaude Codeは次のtool境界で同じturnへ取り込む。Cursorは「follow-ups」枠へ入った文を「enter steer」で現在turnへ移し、`turn_ended`は最後に1回書く。
|
|
207
213
|
待ち行列の表示は5秒待ち、子のturnが続いている間だけ30秒まで延ばす(表示が遅い端末がある。turnが終わっていれば、文は新しいturnとして始まっている)。
|
|
208
|
-
Grokは待ち行列へ入れた後に「send now
|
|
214
|
+
Grokは待ち行列へ入れた後に「send now」を押す。押す直前に元launchとqueueの現在表示を再確認する。旧turnは`cancelled`(`cancellation_context.trigger=send_now`)で閉じ、
|
|
209
215
|
新turnが作業を継ぐので、完了判定はこの継ぎ目を完了と数えない。Grokが待ち行列へ入れない時とCursorの入力欄に本文が残る時は`steered`を返さない。
|
|
210
216
|
Cursorのsubmitはadapterがextended keyboard protocolのEnterへ変換し、呼び出し側は通常のdispatchだけを使う。
|
|
217
|
+
Grokのbusy判定後にturnが終わる競合では、送信前のhistory byte位置と本文全体のdigestを保存し、新しい実user行の`prompt_index`と送信後eventの`turn_started.turn_number`を照合する。新turnでの受理が確定した時だけ、その開始位置を使ったdispatch receiptと親配送登録へ移す。本文やEnterを再送しない。Grokの差し込みwaiterも同じ照合を使い、古い完了や短い本文prefixを受理証拠にしない。欠測・曖昧・旧控え・控え消失は未確定とし、旧turn待ちへのfallbackをしない。生成する観測processの`--launch`は元世代へ固定する。
|
|
218
|
+
queueの未確認/残留は`aiterm.agent-send-error.v1`(文字列code、outcome_unknown/effect possible、元session/launch)を既isError/prefixへ追加する。Grokの保存済み送信前位置だけを観測に渡し、Cursorの未知な受理へ旧turnのwaiterを渡さない。
|
|
211
219
|
起動直後のClaude sessionへの初回dispatchは、他harnessと同じくTUIの入力受付を確認してから貼付とEnterを送る。
|
|
212
220
|
Codex・Grok・Cursorの席は、新しいturnを送るたびに入力受付を確かめる。起動の途中の入力欄を採らないよう、500msおきに11回続けて
|
|
213
221
|
入力待ちを読む(ADR 0014)。席のharnessが自分の記録で「この起動でturnを1つ終えていて、次のturnを始めていない」と示している時は、
|
|
@@ -570,3 +578,7 @@ Native Claude goal input also verifies the official per-PID current-session regi
|
|
|
570
578
|
Grok 1.0.70 inspection verifies active_sessions.json against the original TUI PID, Linux birth ticks, cwd and vendor session. A fresh local /goal status update on that same session establishes null only with an absent state file, or an existing goal whose ID and exact objective remain stable across the query. The native persisted snapshot remains in goal.native; goal.current_status carries the separately parsed current status, phase, safe integer token count and original elapsed display. Resuming can leave persisted phase different from the live worker. Neither an old reply nor the snapshot supplies current values. A busy TUI queues the local slash command. The adapter does not send it on busy minimal views. An already fullscreen root view with a known Goal header and empty boxed composer instead permits native Goal-detail inspection. Core validates pane coordinates and the harness-provided current viewport predicate immediately before the bounded SGR pointer press/release, under the existing generation, PID-birth, current-session, TTY foreground/raw and native-admission checks. The harness uses string-width 7.2.0 display cells, requires the exact untruncated objective and stable native goal ID across the observation, then closes only its recognized modal with a current-row-checked key and confirms the empty composer. It neither switches modes nor stops a turn. The UI has rounded budget text and a phase label rather than an exact native phase/counter: the goal-detail current_status variant preserves those display strings while phase and tokens_used are null. Unknown views, existing drafts, moved hit targets and unavailable native ownership never trigger another input or a query through another leader. No leader, worker or conversation is created or resumed by product inspection.
|
|
571
579
|
|
|
572
580
|
Grok clear uses the existing host-origin contract and only a fresh UserPaused/Idle status and empty composer on the same original worker. The native manager advertises clear only with a freshly observed existing goal and confirmed input readiness. The harness verifies the same goal ID/objective before paste and immediately before Enter, and accepts only the current anchored completion menu for the exact command when minimal mode hides its model footer. Core repeats current viewport and native ownership checks under input admission. A single /goal clear requires a fresh same-session host-turn reply of Goal cleared. plus absent native state; the manager then reads a separate fresh no-goal status. A known pre-Enter refusal remains not_issued; uncertain input or missing/replaced readback removes the goal and capabilities and reports outcome_unknown. It never retries, restores a goal, interrupts a turn or routes to another worker. Other Grok mutations remain unsupported.
|
|
581
|
+
|
|
582
|
+
休止の直前には、保存templateではなく元nativeのmodel/effort/fast表示を、同じ送信admissionとcreate receiptで確認する。harnesses/idle-settings.tsが保存しないnative表示の確認/取消しを所有し、coreは既存の入力とready確認を供給する。確認後の画面やattach履歴が最初のsignal前に変われば停止しない。未対応表示や現在設定の欠測はskipし、native表示用の命令を活動時刻へ数えない。詳細と現時点の受入限界はADR0138。
|
|
583
|
+
|
|
584
|
+
Claude resume preserves the original CLAUDE_CONFIG_DIR selector (including unset) separately from its resolved path; incomplete old selectors remain unavailable. Security notes block startup even when an older shell marker remains above them.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiterm-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.63.0",
|
|
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": [
|
|
@@ -46,7 +46,8 @@
|
|
|
46
46
|
"aiterm-wait": "dist/aiterm-wait-cli.js",
|
|
47
47
|
"aiterm-delivery-wake": "dist/delivery-wake-cli.js",
|
|
48
48
|
"aiterm-parent-delivery": "dist/parent-delivery-cli.js",
|
|
49
|
-
"aiterm-update": "dist/update-cli.js"
|
|
49
|
+
"aiterm-update": "dist/update-cli.js",
|
|
50
|
+
"aiterm-idle-check": "dist/agent-idle-cli.js"
|
|
50
51
|
},
|
|
51
52
|
"files": [
|
|
52
53
|
"dist/*.js",
|