aiterm-mcp 0.70.4 → 0.70.6
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 +19 -1
- package/README.ja.md +1 -1
- package/README.md +1 -1
- package/dist/agent-metadata-reader.js +15 -0
- package/dist/core.js +123 -10
- package/dist/errors.js +4 -0
- package/dist/harnesses/claude.js +7 -1
- package/dist/harnesses/codex.js +22 -6
- package/dist/index.js +64 -31
- package/dist/managed-seat-turn.js +13 -6
- package/dist/remote-terminal.js +12 -0
- package/dist/remote.js +6 -2
- package/dist/terminal-launch-error.js +15 -0
- package/dist/tmux-runtime.js +83 -42
- package/dist/write-ban.js +70 -0
- package/docs/DESIGN.md +2 -1
- package/docs/RELEASE.md +3 -1
- package/package.json +1 -1
package/dist/tmux-runtime.js
CHANGED
|
@@ -16,7 +16,9 @@ import { parseNativeSessionReceipt, nativePaneTarget, nativeSessionTarget, nativ
|
|
|
16
16
|
const nativeTargets = new AsyncLocalStorage();
|
|
17
17
|
const nativeReads = new Set(["list-sessions", "list-commands", "list-panes", "list-windows", "has-session", "display-message", "capture-pane", "show-environment", "show-options"]);
|
|
18
18
|
const nativePanes = new Set(["send-keys", "paste-buffer", "pipe-pane", "capture-pane", "display-message", "list-panes", "rename-window", "set-window-option"]);
|
|
19
|
-
|
|
19
|
+
// Every site names itself: the same refusal text from fifteen places could not be traced (macbook 2026-11-10).
|
|
20
|
+
const nativeTargetUnavailable = (reason) => new AitermError(`AGENT_RESUME_UNCONFIRMED: native端末の本人性を確認できません。native_reason=${reason}`, 2);
|
|
21
|
+
const tmuxFailure = (r) => `rc=${r.code} ${r.stderr.trim().split("\n")[0].slice(0, 160)}`.trim();
|
|
20
22
|
function verifyNativeTarget(frame) {
|
|
21
23
|
if (frame.checking)
|
|
22
24
|
return;
|
|
@@ -32,7 +34,7 @@ function verifyNativeTarget(frame) {
|
|
|
32
34
|
export function withNativeSessionTarget(target, verify, body, allowExitedPane = false) {
|
|
33
35
|
const enclosing = nativeTargets.getStore();
|
|
34
36
|
if (enclosing && JSON.stringify(enclosing.target) !== JSON.stringify(target))
|
|
35
|
-
throw nativeTargetUnavailable();
|
|
37
|
+
throw nativeTargetUnavailable("enclosing_target_differs");
|
|
36
38
|
const frame = { session: target.session_id, target, verify, allowExitedPane };
|
|
37
39
|
return nativeTargets.run(frame, () => { verifyNativeTarget(frame); return body(); });
|
|
38
40
|
}
|
|
@@ -45,7 +47,7 @@ export function hasVerifiedNativeSessionTarget(name) {
|
|
|
45
47
|
}
|
|
46
48
|
export function withNativeSessionCreation(session, created, verify, body) {
|
|
47
49
|
if (nativeTargets.getStore())
|
|
48
|
-
throw nativeTargetUnavailable();
|
|
50
|
+
throw nativeTargetUnavailable("nested_creation");
|
|
49
51
|
return nativeTargets.run({ session, target: null, created, verify }, body);
|
|
50
52
|
}
|
|
51
53
|
const CREATION_TOKEN_OPTION = "@aiterm_create_token";
|
|
@@ -62,43 +64,61 @@ export function withNativeSessionSetupRollback(shell, body) {
|
|
|
62
64
|
return body();
|
|
63
65
|
}
|
|
64
66
|
catch (error) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
67
|
+
const created = setup.target, name = created?.session_id ?? frame.session;
|
|
68
|
+
let rows = null;
|
|
69
|
+
try {
|
|
70
|
+
if (created)
|
|
71
|
+
creationCommand(setup, ["kill-session", "-t", created.session_id], true);
|
|
72
|
+
rows = nativeSessionRows();
|
|
73
|
+
}
|
|
74
|
+
catch { /* an unavailable listing proves nothing */ }
|
|
75
|
+
// Only a complete listing proves absence; an already absent native (the created callback may have closed it) is a finished rollback.
|
|
76
|
+
if (rows && name !== null && !rows.some(row => row[1] === name)) {
|
|
77
|
+
if (error instanceof AitermError)
|
|
78
|
+
error.nativeSessionAbsent = name;
|
|
76
79
|
}
|
|
80
|
+
else if (created && (!rows || rows.some(row => row[0] === created.native_id)) && error instanceof Error)
|
|
81
|
+
error.message += "\ncreation_rollback_unconfirmed: 作成した端末の片付けを確認できません。";
|
|
77
82
|
throw error;
|
|
78
83
|
}
|
|
79
84
|
finally {
|
|
80
85
|
delete frame.setup;
|
|
81
86
|
}
|
|
82
87
|
}
|
|
88
|
+
/** [native id, name] of every session, or null when the listing is unavailable. Reads absence as core.listNativeSessionsResult does. */
|
|
89
|
+
function nativeSessionRows() {
|
|
90
|
+
// Outside the creation frame: its verify would throw on the non-zero exit that proves the server is gone.
|
|
91
|
+
const list = () => nativeTargets.exit(() => runTmux(false, undefined, ["list-sessions", "-F", "#{session_id}\t#{session_name}"]));
|
|
92
|
+
let listed = list();
|
|
93
|
+
// A server that just lost its last session answers this for a moment before "no server running" (macOS, 2026-10-23).
|
|
94
|
+
for (const deadline = performance.now() + 500; listed.code !== 0 && /server exited unexpectedly/i.test(listed.stderr) && performance.now() < deadline;) {
|
|
95
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 20);
|
|
96
|
+
listed = list();
|
|
97
|
+
}
|
|
98
|
+
if (listed.code === 0)
|
|
99
|
+
return listed.stdout.split(/\r?\n/).filter(Boolean).map(row => row.split(/[\t ]/));
|
|
100
|
+
return /no server running|No such file or directory/i.test(listed.stderr) ? [] : null;
|
|
101
|
+
}
|
|
83
102
|
// This scope is private to marker transfer and rollback; ordinary effects still require OS birth identity.
|
|
84
103
|
function creationCommand(setup, args, allowRefusal = false) {
|
|
85
104
|
const target = setup.target;
|
|
86
105
|
const creationCondition = `#{||:#{==:#{window_name},${setup.window}},#{==:#{${CREATION_TOKEN_OPTION}},${setup.token}}}`;
|
|
87
106
|
return nativeTargets.run({ session: target.session_id, target, verify: () => { }, creationCondition, allowRefusal }, () => runTmux(false, undefined, args));
|
|
88
107
|
}
|
|
89
|
-
|
|
108
|
+
const receiptUnparsed = (r) => `receipt_unparsed(stdout_bytes=${Buffer.byteLength(r.stdout)}; ${tmuxFailure(r)})`;
|
|
109
|
+
function captureNativeSessionReceipt(created) {
|
|
90
110
|
const frame = nativeTargets.getStore();
|
|
91
111
|
if (!frame?.created || frame.target)
|
|
92
|
-
throw nativeTargetUnavailable();
|
|
112
|
+
throw nativeTargetUnavailable("receipt_not_expected");
|
|
93
113
|
let target;
|
|
94
114
|
try {
|
|
95
|
-
target = parseNativeSessionReceipt(
|
|
115
|
+
target = parseNativeSessionReceipt(created.stdout);
|
|
96
116
|
}
|
|
97
117
|
catch {
|
|
98
|
-
throw nativeTargetUnavailable();
|
|
118
|
+
throw nativeTargetUnavailable(receiptUnparsed(created));
|
|
99
119
|
}
|
|
100
120
|
if (frame.session !== null && target.session_id !== frame.session)
|
|
101
|
-
throw nativeTargetUnavailable();
|
|
121
|
+
throw nativeTargetUnavailable("receipt_name_differs");
|
|
102
122
|
frame.session = target.session_id;
|
|
103
123
|
frame.target = target;
|
|
104
124
|
if (frame.setup) {
|
|
@@ -109,14 +129,16 @@ function captureNativeSessionReceipt(receipt) {
|
|
|
109
129
|
if (isWin) {
|
|
110
130
|
const inherited = creationCommand(setup, ["show-options", "-t", target.session_id, "-v", "automatic-rename"]);
|
|
111
131
|
if (inherited.code !== 0 || !["on", "off"].includes(inherited.stdout.trim()))
|
|
112
|
-
throw nativeTargetUnavailable();
|
|
132
|
+
throw nativeTargetUnavailable(`automatic_rename_unread(${tmuxFailure(inherited)})`);
|
|
113
133
|
commands.push(["set-window-option", "-t", target.session_id, "automatic-rename", inherited.stdout.trim()]);
|
|
114
134
|
}
|
|
115
135
|
else
|
|
116
136
|
commands.push(["set-window-option", "-t", target.session_id, "-u", "automatic-rename"]);
|
|
117
|
-
for (const command of commands)
|
|
118
|
-
|
|
119
|
-
|
|
137
|
+
for (const command of commands) {
|
|
138
|
+
const result = creationCommand(setup, command);
|
|
139
|
+
if (result.code !== 0)
|
|
140
|
+
throw nativeTargetUnavailable(`creation_command_failed(${command[0]}; ${tmuxFailure(result)})`);
|
|
141
|
+
}
|
|
120
142
|
}
|
|
121
143
|
frame.created({ ...frame.target });
|
|
122
144
|
verifyNativeTarget(frame);
|
|
@@ -137,7 +159,7 @@ function nativeSessionArgs(input) {
|
|
|
137
159
|
if (command === "new-session") {
|
|
138
160
|
const named = args.findIndex((value, index) => index > start && index < end && value === "-s");
|
|
139
161
|
if (frame.target || !frame.created || named < 0 || frame.session !== null && args[named + 1] !== frame.session)
|
|
140
|
-
throw nativeTargetUnavailable();
|
|
162
|
+
throw nativeTargetUnavailable("new_session_not_admitted");
|
|
141
163
|
}
|
|
142
164
|
const at = args.findIndex((value, index) => index > start && index < end && value === "-t");
|
|
143
165
|
if (at >= 0) {
|
|
@@ -150,7 +172,7 @@ function nativeSessionArgs(input) {
|
|
|
150
172
|
const own = named?.[1] === frame.session || raw === frame.target?.native_id || raw === frame.target?.pane_id
|
|
151
173
|
|| frame.target !== null && raw === nativePaneTarget(frame.target);
|
|
152
174
|
if (!own || (!frame.target && !nativeReads.has(command)))
|
|
153
|
-
throw nativeTargetUnavailable();
|
|
175
|
+
throw nativeTargetUnavailable(`target_not_owned(${command})`);
|
|
154
176
|
args[at + 1] = frame.target ? (nativePanes.has(command) ? nativePaneTarget(frame.target) : nativeSessionTarget(frame.target)) : `=${frame.session}`;
|
|
155
177
|
}
|
|
156
178
|
start = end + 1;
|
|
@@ -159,7 +181,7 @@ function nativeSessionArgs(input) {
|
|
|
159
181
|
if (frame.target)
|
|
160
182
|
verifyNativeTarget(frame);
|
|
161
183
|
else if (!args.includes("new-session") && !(args.length === 3 && args[0] === "set-option" && args[1] === "-gu" && args[2] === "update-environment"))
|
|
162
|
-
throw nativeTargetUnavailable();
|
|
184
|
+
throw nativeTargetUnavailable(`effect_before_creation(${args[0]})`);
|
|
163
185
|
}
|
|
164
186
|
return args;
|
|
165
187
|
}
|
|
@@ -489,7 +511,7 @@ function runTmux(observe, input, args, session, deadline) {
|
|
|
489
511
|
}
|
|
490
512
|
const native = nativeTargets.getStore();
|
|
491
513
|
if (native?.target && !native.allowRefusal && args[0] === "if-shell" && (r.stdout ?? "").trim() === NATIVE_REFUSED)
|
|
492
|
-
throw nativeTargetUnavailable();
|
|
514
|
+
throw nativeTargetUnavailable("native_condition_refused");
|
|
493
515
|
if (native?.target && r.status !== 0)
|
|
494
516
|
verifyNativeTarget(native);
|
|
495
517
|
return { code: r.status ?? 1, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
|
|
@@ -620,7 +642,7 @@ export function sendPsmuxPayload(observe, sessionName, text, bracketedPaste) {
|
|
|
620
642
|
beforeExecutionEffect(sessionName);
|
|
621
643
|
const frame = nativeTargets.getStore();
|
|
622
644
|
if (frame && (!frame.target || frame.session !== sessionName))
|
|
623
|
-
throw nativeTargetUnavailable();
|
|
645
|
+
throw nativeTargetUnavailable("send_target_differs");
|
|
624
646
|
if (frame)
|
|
625
647
|
verifyNativeTarget(frame);
|
|
626
648
|
const target = frame?.target;
|
|
@@ -668,7 +690,9 @@ export function pasteBufferBaseArgs() {
|
|
|
668
690
|
export const TMUX_EMPTY_CONFIG = isWin ? "NUL" : "/dev/null";
|
|
669
691
|
// A single POSIX command goes through the account's possibly non-login default-shell.
|
|
670
692
|
export function paneCommandArgs(shell) {
|
|
671
|
-
|
|
693
|
+
// A plain command name is exec'd so the pane's foreground is the requested shell: dash forks a lone -c command,
|
|
694
|
+
// and pane_current_command would then read "sh" (macOS /bin/sh already execs it).
|
|
695
|
+
return isWin ? [shell] : ["/bin/sh", "-c", /^[A-Za-z0-9_./+-]+$/u.test(shell) ? `exec ${shell}` : shell];
|
|
672
696
|
}
|
|
673
697
|
// tmux 3.2 で new-session -e と、update-environment のワイルドカードが入った。
|
|
674
698
|
function tmuxHasSessionEnvironmentFlags(version) {
|
|
@@ -761,16 +785,17 @@ export function tmuxNewSession(observe, name, launch, registered = []) {
|
|
|
761
785
|
const result = runTmux(observe, undefined, ["new-session", "-d", "-s", name, ...printNative, ...launch.args, "-f", TMUX_EMPTY_CONFIG, launch.shell]);
|
|
762
786
|
if (result.code === 0) {
|
|
763
787
|
if (pinned) {
|
|
788
|
+
let receipt;
|
|
764
789
|
try {
|
|
765
|
-
|
|
766
|
-
if (receipt.session_id !== name)
|
|
767
|
-
throw nativeTargetUnavailable();
|
|
768
|
-
if (witness)
|
|
769
|
-
witness.target = receipt;
|
|
790
|
+
receipt = parseNativeSessionReceipt(result.stdout);
|
|
770
791
|
}
|
|
771
792
|
catch {
|
|
772
|
-
throw nativeTargetUnavailable();
|
|
793
|
+
throw nativeTargetUnavailable(receiptUnparsed(result));
|
|
773
794
|
}
|
|
795
|
+
if (receipt.session_id !== name)
|
|
796
|
+
throw nativeTargetUnavailable("receipt_name_differs");
|
|
797
|
+
if (witness)
|
|
798
|
+
witness.target = receipt;
|
|
774
799
|
}
|
|
775
800
|
// Existing psmux 3.3.8 registry protection must run before identity reads can trigger registry reaping.
|
|
776
801
|
openPsmuxServerToDesktop(name);
|
|
@@ -778,7 +803,7 @@ export function tmuxNewSession(observe, name, launch, registered = []) {
|
|
|
778
803
|
if (guarded && (result.code === 0 || result.stdout))
|
|
779
804
|
captureExecutionCreatedNative(result.stdout);
|
|
780
805
|
if (pinned && (result.code === 0 || result.stdout))
|
|
781
|
-
captureNativeSessionReceipt(result
|
|
806
|
+
captureNativeSessionReceipt(result);
|
|
782
807
|
return result;
|
|
783
808
|
}
|
|
784
809
|
const env = sessionCallerEnvironment();
|
|
@@ -809,7 +834,7 @@ export function tmuxNewSession(observe, name, launch, registered = []) {
|
|
|
809
834
|
if (guarded && (r.code === 0 || r.stdout))
|
|
810
835
|
captureExecutionCreatedNative(r.stdout);
|
|
811
836
|
if (pinned && (r.code === 0 || r.stdout))
|
|
812
|
-
captureNativeSessionReceipt(r
|
|
837
|
+
captureNativeSessionReceipt(r);
|
|
813
838
|
if (r.code !== 0) {
|
|
814
839
|
// 途中の命令が失敗すると、後続の命令は実行されない。差し替えた設定を戻す。
|
|
815
840
|
runTmux(false, undefined, ["set-option", "-gu", "update-environment"]);
|
|
@@ -902,6 +927,14 @@ export function markShellCommand(foreground, screen, platform = process.platform
|
|
|
902
927
|
}
|
|
903
928
|
return foreground;
|
|
904
929
|
}
|
|
930
|
+
// Windows: the shell that last showed its prompt in each pane (seeded with the shell the pane was opened with).
|
|
931
|
+
// psmux's foreground name can be stale (pwsh for a Git Bash pane), so input typed while a command runs, or before the
|
|
932
|
+
// first prompt, would get the wrong dialect; the shell that reads it is the one whose prompt was last seen.
|
|
933
|
+
const windowsPromptShells = new Map();
|
|
934
|
+
export function rememberPaneShell(name, shell) {
|
|
935
|
+
if (isWin)
|
|
936
|
+
windowsPromptShells.set(name, normalizePaneCommand(shell));
|
|
937
|
+
}
|
|
905
938
|
/** The runtime owns platform foreground queries and shell-dialect reconciliation. */
|
|
906
939
|
export function paneShellForSubmission(name) {
|
|
907
940
|
const r = tmuxCommand(true, "display-message", "-p", "-t", name, "#{pane_current_command}");
|
|
@@ -910,12 +943,20 @@ export function paneShellForSubmission(name) {
|
|
|
910
943
|
return foreground;
|
|
911
944
|
const screen = tmuxCommand(true, "capture-pane", "-p", "-J", "-t", name, "-S", "-4");
|
|
912
945
|
const text = screen.code === 0 ? screen.stdout : "";
|
|
913
|
-
|
|
914
|
-
if (
|
|
946
|
+
let selected = markShellCommand(foreground, text);
|
|
947
|
+
if (isWin && selected === foreground && selected !== "bash" && /(?:^|\n)\$\s*$/u.test(text.trimEnd())) {
|
|
948
|
+
const width = tmuxCommand(true, "display-message", "-p", "-t", name, "#{pane_width}");
|
|
949
|
+
const columns = width.code === 0 && /^\d+\s*$/u.test(width.stdout) ? Number(width.stdout.trim()) : undefined;
|
|
950
|
+
selected = markShellCommand(foreground, text, "win32", columns);
|
|
951
|
+
}
|
|
952
|
+
if (!isWin)
|
|
953
|
+
return selected;
|
|
954
|
+
const current = text.replace(/\x1b\[[0-9;?]*[a-zA-Z]/g, "").trimEnd();
|
|
955
|
+
if (/(?:^|\n)PS [^\r\n]*>$/u.test(current) || /(?:^|\n)\$$/u.test(current)) {
|
|
956
|
+
windowsPromptShells.set(name, selected);
|
|
915
957
|
return selected;
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
return markShellCommand(foreground, text, "win32", columns);
|
|
958
|
+
}
|
|
959
|
+
return windowsPromptShells.get(name) ?? selected;
|
|
919
960
|
}
|
|
920
961
|
/** Common send code supplies intent; the runtime decides whether/how to encode it. */
|
|
921
962
|
export function adaptShellSubmission(name, text, options = {}) {
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Fork write-ban (ADR 0140): every write inside one folder is refused below the tools, for the whole CLI process tree.
|
|
2
|
+
// Everything else (reads, commands, network, MCP, writes elsewhere) is untouched.
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import * as fs from "node:fs";
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
import { AitermError } from "./errors.js";
|
|
7
|
+
// Linux: Landlock, unprivileged (works in standard Docker, where bwrap cannot create a namespace).
|
|
8
|
+
// Handles only write-type rights and grants them on every sibling along / -> the folder, so only the folder
|
|
9
|
+
// (and new entries directly in its ancestors) is unwritable. Fails closed: exit 126 before the CLI starts.
|
|
10
|
+
const LANDLOCK_PY = `import ctypes,os,sys,struct
|
|
11
|
+
a=sys.argv[1:];probe=a[0]=='--probe'
|
|
12
|
+
if probe:a=a[1:]
|
|
13
|
+
P=os.path.realpath(a[0]);L=ctypes.CDLL(None,use_errno=True)
|
|
14
|
+
def c(r,w):
|
|
15
|
+
if r<0:
|
|
16
|
+
sys.stderr.write('aiterm write-ban: %s: %s\\n'%(w,os.strerror(ctypes.get_errno())));sys.exit(126)
|
|
17
|
+
return r
|
|
18
|
+
abi=c(L.syscall(444,None,0,1),'landlock unavailable')
|
|
19
|
+
D=0
|
|
20
|
+
for b in (1,4,5,6,7,8,9,10,11,12,13,14):D|=1<<b
|
|
21
|
+
if abi<2:D&=~(1<<13)
|
|
22
|
+
if abi<3:D&=~(1<<14)
|
|
23
|
+
F=D&((1<<1)|(1<<14));A=struct.pack('QQQ',D,0,0)
|
|
24
|
+
fd=c(L.syscall(444,ctypes.c_char_p(A),ctypes.c_size_t(len(A)),0),'create_ruleset')
|
|
25
|
+
def g(p):
|
|
26
|
+
try:q=os.open(p,os.O_PATH|os.O_CLOEXEC)
|
|
27
|
+
except OSError:return
|
|
28
|
+
try:c(L.syscall(445,fd,1,ctypes.c_char_p(struct.pack('=Qi',D if os.path.isdir(p) else F,q)),0),'add_rule '+p)
|
|
29
|
+
finally:os.close(q)
|
|
30
|
+
cur='/'
|
|
31
|
+
for part in P.strip('/').split('/'):
|
|
32
|
+
for e in os.listdir(cur):
|
|
33
|
+
if e!=part:g(os.path.join(cur,e))
|
|
34
|
+
cur=os.path.join(cur,part)
|
|
35
|
+
c(L.prctl(38,1,0,0,0),'no_new_privs')
|
|
36
|
+
c(L.syscall(446,fd,0),'restrict_self')
|
|
37
|
+
if probe:print('landlock',abi);sys.exit(0)
|
|
38
|
+
cmd=a[a.index('--')+1:];os.execvp(cmd[0],cmd)
|
|
39
|
+
`;
|
|
40
|
+
const LANDLOCK_LAUNCHER = `import base64;exec(base64.b64decode('${Buffer.from(LANDLOCK_PY).toString("base64")}'))`;
|
|
41
|
+
function seatbeltProfile(folder) {
|
|
42
|
+
return `(version 1)(allow default)(deny file-write* (subpath "${folder.replace(/[\\"]/g, "\\$&")}"))`;
|
|
43
|
+
}
|
|
44
|
+
/** argv placed before the CLI's own argv. The CLI is exec'd, so its PID and process name stay the seat's. */
|
|
45
|
+
export function writeBanPrefix(ban) {
|
|
46
|
+
return ban.method === "landlock"
|
|
47
|
+
? ["python3", "-c", LANDLOCK_LAUNCHER, ban.path, "--"]
|
|
48
|
+
: ["/usr/bin/sandbox-exec", "-p", seatbeltProfile(ban.path)];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Prove on this machine that the ban can be applied before any seat starts. Without proof the fork is refused:
|
|
52
|
+
* starting it would let it write the project (the one thing the Owner forbade).
|
|
53
|
+
*/
|
|
54
|
+
export function probeWriteBan(folder, platform = process.platform) {
|
|
55
|
+
const unenforceable = (why) => new AitermError(`READONLY_UNENFORCEABLE: the project write-ban cannot be applied here: ${why}`, 2);
|
|
56
|
+
if (platform === "win32")
|
|
57
|
+
throw unenforceable("Windows has no same-user folder write-ban yet");
|
|
58
|
+
if (!path.isAbsolute(folder) || !fs.existsSync(folder))
|
|
59
|
+
throw unenforceable(`folder ${folder} does not exist`);
|
|
60
|
+
const real = fs.realpathSync(folder);
|
|
61
|
+
if (real === path.parse(real).root)
|
|
62
|
+
throw unenforceable("the folder is the filesystem root");
|
|
63
|
+
const ban = { path: real, method: platform === "darwin" ? "seatbelt" : "landlock" };
|
|
64
|
+
const [bin, ...args] = writeBanPrefix(ban);
|
|
65
|
+
const probe = ban.method === "landlock" ? [args[0], args[1], "--probe", real] : [...args, "/usr/bin/true"];
|
|
66
|
+
const r = spawnSync(bin, probe, { encoding: "utf8", timeout: 10_000 });
|
|
67
|
+
if (r.status !== 0)
|
|
68
|
+
throw unenforceable((r.stderr || r.error?.message || `exit ${r.status}`).trim().split("\n").pop() ?? "probe failed");
|
|
69
|
+
return ban;
|
|
70
|
+
}
|
package/docs/DESIGN.md
CHANGED
|
@@ -169,7 +169,7 @@ Claude Codeの入力待ちは、起動時の見出しが取得範囲から流れ
|
|
|
169
169
|
|
|
170
170
|
## Agent model
|
|
171
171
|
|
|
172
|
-
POSIXのpane作成は要求したshellを直接実行するargvを渡し、サービス用アカウントのログイン不可shellへ仲介させない(ADR 0136
|
|
172
|
+
POSIXのpane作成は要求したshellを直接実行するargvを渡し、サービス用アカウントのログイン不可shellへ仲介させない(ADR 0136)。単語だけのshell名は`/bin/sh -c 'exec <shell>'`で置き換え、paneの前面を要求したshellにする(dashは単独の-c命令をforkし、前面が`sh`に見える)。POSIXのPowerShellは行編集の開始前に打たれた文を壊すので、`pty_open`は最初のpromptで行頭からcursorが動くまで最大10秒待つ。WindowsのPowerShell/psmux経路は従来どおり。WindowsではpsmuxのFG名が古いまま(Git Bashのpaneでpwsh)返ることがあるため、送信の方言は見えているpromptで決め、promptが見えない時(命令の実行中や最初のpromptの前)は、そのpaneで最後にpromptを見たshell(最初はpaneを開いたshell)を使う(ADR 0136追補)。
|
|
173
173
|
|
|
174
174
|
AntigravityのTUI+公式hook、発話位置とexecutionNumによる完了相関は[ADR 0135](https://github.com/kitepon/aiterm-mcp/blob/main/docs/adr/0135-antigravity-native-harness.md)を正とする。
|
|
175
175
|
|
|
@@ -386,6 +386,7 @@ PowerShellは`$PSHOME`を展開し、POSIX系はどちらも展開しない。PO
|
|
|
386
386
|
`env`のPATHだけを受け取り、処理は`/bin/sh`で行う。profileの出力やfish等の文法差をMCPのstdoutへ持ち込まない。
|
|
387
387
|
WindowsはユーザーのPATHで`aiterm-mcp`と`aiterm-wait`をそのまま呼ぶ。起動、hook、transcript、multiplexerは現地のAitermが所有し、
|
|
388
388
|
呼び出し側は結果を返すだけにする。現地にポートは開けない。
|
|
389
|
+
MCP要求の`_meta`は現地へ不透明なまま渡し、現地resultの`_meta`も変更せず返す。親配送などのローカル投影を加える時も、現地metadataを保持する。
|
|
389
390
|
|
|
390
391
|
接続先はtool引数で毎回受け取り、Aitermは一覧も既定値も持たない(オーナー裁定 2026-09-26。管理まで持つと重くなるため)。
|
|
391
392
|
配送記録には、パスフレーズ本文を除いた接続情報だけを残す。平文のパスフレーズはMCP processのメモリにだけ置き、
|
package/docs/RELEASE.md
CHANGED
|
@@ -5,14 +5,16 @@ Aitermのreleaseはこのrepositoryが所有する。`.github/workflows/product-
|
|
|
5
5
|
|
|
6
6
|
## CIの範囲
|
|
7
7
|
|
|
8
|
-
- push/pull request: 共通実装・CI自身・未分類の変更は`macos-
|
|
8
|
+
- push/pull request: 共通実装・CI自身・未分類の変更は`macos-hosted`、`linux-workstation`、`windows-native`を選ぶ。
|
|
9
9
|
Windows固有ファイル(`src/windows-powershell.ts`、`src/psmux-send-worker.ts`、`test/windows-*.test.mjs`)だけの変更は
|
|
10
10
|
LinuxとWindowsを選ぶ。共通変更が混ざっても対象OSを落とさない。試験は依存graphから選び、依存を確定できない変更だけ全テストへ広げる。
|
|
11
11
|
- 版番号だけの変更はJSONの実差分で識別し、Linuxでbuildと配布metadata・pack・文書確認を行う。依存や実行設定の変更は省略しない。
|
|
12
12
|
文書だけなら文書検査、実装と文書の混在なら関連試験と文書検査を行う。
|
|
13
13
|
- 手動実行の`test_files`へ既存試験fileのJSON配列を渡すと、指定OSでその試験だけを実行する。空欄は従来の全試験。
|
|
14
14
|
選択実行のjob名は`selected`で、同headの全試験成功の再利用対象にしない。
|
|
15
|
+
- `macos-hosted`は公開repositoryで利用できるGitHub-hosted `macos-latest` runnerを使う。AitermのCI/buildはOwnerのMacでは実行しない。`linux-workstation`と`windows-native`はfactory runnerを使う。
|
|
15
16
|
- 週1回の定期実行(月曜 03:00 JST)と`test_files`未指定の手動実行は、指定された環境で全テストを回す。定期実行の対象は3環境である。
|
|
17
|
+
- macOS terminal runtimeのrelease buildもGitHub-hosted `macos-latest` runnerで行う。
|
|
16
18
|
- pushは、同じcommitの全テスト(手動実行か定期実行)がもう通っている環境を流さない。枝で手動実行を通してからmainへ早送りすると、
|
|
17
19
|
mainのpushは変更分類と関門だけで終わる。通っている環境が一部の時は、残りの環境だけを流す。GitHubへ聞けない時は、選んだ環境を全部流す。
|
|
18
20
|
同じcommitのpush・pull requestの成功は、試験を絞っている事があるので数えない(ADR 0115)。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiterm-mcp",
|
|
3
|
-
"version": "0.70.
|
|
3
|
+
"version": "0.70.6",
|
|
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": [
|