aiterm-mcp 0.70.6 → 0.70.8
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 +30 -1
- package/README.ja.md +1 -1
- package/README.md +1 -1
- package/dist/agent-metadata-reader.js +4 -1
- package/dist/agent-resolver.js +10 -0
- package/dist/core.js +31 -9
- package/dist/errors.js +6 -0
- package/dist/harnesses/codex.js +144 -3
- package/dist/index.js +51 -29
- package/dist/process-runtime.js +1 -1
- package/dist/process-tree-stop.js +8 -2
- package/dist/remote-authorize.js +51 -6
- package/dist/remote-contract.js +9 -4
- package/dist/remote-path.js +29 -5
- package/dist/remote-provision.js +108 -10
- package/dist/remote-terminal-cli.js +8 -5
- package/dist/remote-terminal.js +93 -54
- package/dist/remote.js +85 -8
- package/dist/terminal-launch-error.js +13 -9
- package/dist/transcript-read-cli.js +5 -10
- package/dist/write-ban.js +32 -42
- package/docs/RELEASE.md +1 -1
- package/native/write-ban/linux-arm64/aiterm-write-ban +0 -0
- package/native/write-ban/linux-x64/aiterm-write-ban +0 -0
- package/native/write-ban/win32-x64/aiterm-write-ban.exe +0 -0
- package/package.json +3 -1
package/dist/write-ban.js
CHANGED
|
@@ -3,66 +3,56 @@
|
|
|
3
3
|
import { spawnSync } from "node:child_process";
|
|
4
4
|
import * as fs from "node:fs";
|
|
5
5
|
import * as path from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
6
7
|
import { AitermError } from "./errors.js";
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
for
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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")}'))`;
|
|
8
|
+
import { resolveWindowsPowerShell7 } from "./windows-powershell.js";
|
|
9
|
+
// Linux: Landlock via the bundled static helper (native/write-ban/aiterm-write-ban.c), so nothing has to be
|
|
10
|
+
// installed on the machine. Unprivileged (works in standard Docker, where bwrap cannot create a namespace).
|
|
11
|
+
// Fails closed: exit 126 before the CLI starts.
|
|
12
|
+
function landlockHelper() {
|
|
13
|
+
if (process.arch !== "x64" && process.arch !== "arm64")
|
|
14
|
+
throw unenforceable(`no write-ban helper for CPU ${process.arch}`);
|
|
15
|
+
return fileURLToPath(new URL(`../native/write-ban/linux-${process.arch}/aiterm-write-ban`, import.meta.url));
|
|
16
|
+
}
|
|
17
|
+
// Windows: the bundled helper (native/write-ban/aiterm-write-ban-win.c) runs the CLI under a restricted token whose
|
|
18
|
+
// marker SID is denied writes by an inert inheritable ACE on the folder (ADR 0140).
|
|
19
|
+
function windowsHelper() {
|
|
20
|
+
if (process.arch !== "x64")
|
|
21
|
+
throw unenforceable(`no write-ban helper for CPU ${process.arch}`);
|
|
22
|
+
return fileURLToPath(new URL("../native/write-ban/win32-x64/aiterm-write-ban.exe", import.meta.url));
|
|
23
|
+
}
|
|
24
|
+
const unenforceable = (why) => new AitermError(`READONLY_UNENFORCEABLE: the project write-ban cannot be applied here: ${why}`, 2);
|
|
41
25
|
function seatbeltProfile(folder) {
|
|
42
26
|
return `(version 1)(allow default)(deny file-write* (subpath "${folder.replace(/[\\"]/g, "\\$&")}"))`;
|
|
43
27
|
}
|
|
44
28
|
/** argv placed before the CLI's own argv. The CLI is exec'd, so its PID and process name stay the seat's. */
|
|
45
29
|
export function writeBanPrefix(ban) {
|
|
46
|
-
return ban.method === "landlock"
|
|
47
|
-
|
|
48
|
-
|
|
30
|
+
return ban.method === "landlock" ? [landlockHelper(), ban.path, "--"]
|
|
31
|
+
: ban.method === "restricted-token" ? [windowsHelper(), ban.path, "--"]
|
|
32
|
+
: ["/usr/bin/sandbox-exec", "-p", seatbeltProfile(ban.path)];
|
|
33
|
+
}
|
|
34
|
+
/** Windows: the helper starts the CLI with CreateProcess, which runs only real executables; npm shims go through pwsh. */
|
|
35
|
+
export function windowsWriteBanArgv(ban, argv) {
|
|
36
|
+
const [bin, ...rest] = argv;
|
|
37
|
+
const ps1 = /\.ps1$/i.test(bin) ? bin : /\.(?:cmd|bat)$/i.test(bin) ? bin.replace(/\.(?:cmd|bat)$/i, ".ps1") : null;
|
|
38
|
+
const cli = ps1 && fs.existsSync(ps1)
|
|
39
|
+
? [resolveWindowsPowerShell7(), "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", ps1, ...rest]
|
|
40
|
+
: /\.(?:cmd|bat)$/i.test(bin) ? [process.env.ComSpec ?? "cmd.exe", "/d", "/c", ...argv] : argv;
|
|
41
|
+
return [...writeBanPrefix(ban), ...cli];
|
|
49
42
|
}
|
|
50
43
|
/**
|
|
51
44
|
* Prove on this machine that the ban can be applied before any seat starts. Without proof the fork is refused:
|
|
52
45
|
* starting it would let it write the project (the one thing the Owner forbade).
|
|
53
46
|
*/
|
|
54
47
|
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
48
|
if (!path.isAbsolute(folder) || !fs.existsSync(folder))
|
|
59
49
|
throw unenforceable(`folder ${folder} does not exist`);
|
|
60
50
|
const real = fs.realpathSync(folder);
|
|
61
51
|
if (real === path.parse(real).root)
|
|
62
52
|
throw unenforceable("the folder is the filesystem root");
|
|
63
|
-
const ban = { path: real, method: platform === "darwin" ? "seatbelt" : "landlock" };
|
|
53
|
+
const ban = { path: real, method: platform === "darwin" ? "seatbelt" : platform === "win32" ? "restricted-token" : "landlock" };
|
|
64
54
|
const [bin, ...args] = writeBanPrefix(ban);
|
|
65
|
-
const probe = ban.method === "
|
|
55
|
+
const probe = ban.method === "seatbelt" ? [...args, "/usr/bin/true"] : ["--probe", real];
|
|
66
56
|
const r = spawnSync(bin, probe, { encoding: "utf8", timeout: 10_000 });
|
|
67
57
|
if (r.status !== 0)
|
|
68
58
|
throw unenforceable((r.stderr || r.error?.message || `exit ${r.status}`).trim().split("\n").pop() ?? "probe failed");
|
package/docs/RELEASE.md
CHANGED
|
@@ -35,7 +35,7 @@ Steerの未公開release sourceは` scripts/fixtures/steer-release-source.json `
|
|
|
35
35
|
|
|
36
36
|
## Release手順
|
|
37
37
|
|
|
38
|
-
1. 変更に直結するfocused test
|
|
38
|
+
1. 変更に直結するfocused testを手元で通す。`native/write-ban/aiterm-write-ban.c`を変えた時は`pip install ziglang==0.15.2`の上で`node scripts/build-write-ban.mjs`で組み直し、`--check`で同じbytesになることを確かめてから組んだ物をcommitする。full regressionは手元で回さず、CIに任せる。
|
|
39
39
|
個別試験も`node scripts/run-seat-tests.mjs --test ...`で起動する。稼働中の席の保存場所を試験へ継承しない。
|
|
40
40
|
2. `CHANGELOG.md`の`## [Unreleased]`へ内容を書き、mainへcommitしてpushする。
|
|
41
41
|
3環境の全テストを先に通しておく時は、枝をpushして手動実行(`gh workflow run ci.yml --ref <枝> -f environment=all -f comparison_base=<前の公開commit>`)を
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiterm-mcp",
|
|
3
|
-
"version": "0.70.
|
|
3
|
+
"version": "0.70.8",
|
|
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": [
|
|
@@ -55,6 +55,8 @@
|
|
|
55
55
|
"files": [
|
|
56
56
|
"dist/*.js",
|
|
57
57
|
"dist/harnesses/*.js",
|
|
58
|
+
"native/write-ban/linux-*/aiterm-write-ban",
|
|
59
|
+
"native/write-ban/win32-x64/aiterm-write-ban.exe",
|
|
58
60
|
"runtime-overlap.json",
|
|
59
61
|
"state-compat.json",
|
|
60
62
|
"README.md",
|