aiterm-mcp 0.70.5 → 0.70.7

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.
@@ -927,6 +927,14 @@ export function markShellCommand(foreground, screen, platform = process.platform
927
927
  }
928
928
  return foreground;
929
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
+ }
930
938
  /** The runtime owns platform foreground queries and shell-dialect reconciliation. */
931
939
  export function paneShellForSubmission(name) {
932
940
  const r = tmuxCommand(true, "display-message", "-p", "-t", name, "#{pane_current_command}");
@@ -935,12 +943,20 @@ export function paneShellForSubmission(name) {
935
943
  return foreground;
936
944
  const screen = tmuxCommand(true, "capture-pane", "-p", "-J", "-t", name, "-S", "-4");
937
945
  const text = screen.code === 0 ? screen.stdout : "";
938
- const selected = markShellCommand(foreground, text);
939
- if (!isWin || selected !== foreground || selected === "bash" || !/(?:^|\n)\$\s*$/u.test(text.trimEnd()))
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);
940
957
  return selected;
941
- const width = tmuxCommand(true, "display-message", "-p", "-t", name, "#{pane_width}");
942
- const columns = width.code === 0 && /^\d+\s*$/u.test(width.stdout) ? Number(width.stdout.trim()) : undefined;
943
- return markShellCommand(foreground, text, "win32", columns);
958
+ }
959
+ return windowsPromptShells.get(name) ?? selected;
944
960
  }
945
961
  /** Common send code supplies intent; the runtime decides whether/how to encode it. */
946
962
  export function adaptShellSubmission(name, text, options = {}) {
@@ -0,0 +1,45 @@
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 { fileURLToPath } from "node:url";
7
+ import { AitermError } from "./errors.js";
8
+ // Linux: Landlock via the bundled static helper (native/write-ban/aiterm-write-ban.c), so nothing has to be
9
+ // installed on the machine. Unprivileged (works in standard Docker, where bwrap cannot create a namespace).
10
+ // Fails closed: exit 126 before the CLI starts.
11
+ function landlockHelper() {
12
+ if (process.arch !== "x64" && process.arch !== "arm64")
13
+ throw unenforceable(`no write-ban helper for CPU ${process.arch}`);
14
+ return fileURLToPath(new URL(`../native/write-ban/linux-${process.arch}/aiterm-write-ban`, import.meta.url));
15
+ }
16
+ const unenforceable = (why) => new AitermError(`READONLY_UNENFORCEABLE: the project write-ban cannot be applied here: ${why}`, 2);
17
+ function seatbeltProfile(folder) {
18
+ return `(version 1)(allow default)(deny file-write* (subpath "${folder.replace(/[\\"]/g, "\\$&")}"))`;
19
+ }
20
+ /** argv placed before the CLI's own argv. The CLI is exec'd, so its PID and process name stay the seat's. */
21
+ export function writeBanPrefix(ban) {
22
+ return ban.method === "landlock"
23
+ ? [landlockHelper(), ban.path, "--"]
24
+ : ["/usr/bin/sandbox-exec", "-p", seatbeltProfile(ban.path)];
25
+ }
26
+ /**
27
+ * Prove on this machine that the ban can be applied before any seat starts. Without proof the fork is refused:
28
+ * starting it would let it write the project (the one thing the Owner forbade).
29
+ */
30
+ export function probeWriteBan(folder, platform = process.platform) {
31
+ if (platform === "win32")
32
+ throw unenforceable("Windows has no same-user folder write-ban yet");
33
+ if (!path.isAbsolute(folder) || !fs.existsSync(folder))
34
+ throw unenforceable(`folder ${folder} does not exist`);
35
+ const real = fs.realpathSync(folder);
36
+ if (real === path.parse(real).root)
37
+ throw unenforceable("the folder is the filesystem root");
38
+ const ban = { path: real, method: platform === "darwin" ? "seatbelt" : "landlock" };
39
+ const [bin, ...args] = writeBanPrefix(ban);
40
+ const probe = ban.method === "landlock" ? ["--probe", real] : [...args, "/usr/bin/true"];
41
+ const r = spawnSync(bin, probe, { encoding: "utf8", timeout: 10_000 });
42
+ if (r.status !== 0)
43
+ throw unenforceable((r.stderr || r.error?.message || `exit ${r.status}`).trim().split("\n").pop() ?? "probe failed");
44
+ return ban;
45
+ }
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)。単語だけのshell名は`/bin/sh -c 'exec <shell>'`で置き換え、paneの前面を要求したshellにする(dashは単独の-c命令をforkし、前面が`sh`に見える)。POSIXのPowerShellは行編集の開始前に打たれた文を壊すので、`pty_open`は最初のpromptで行頭からcursorが動くまで最大10秒待つ。WindowsのPowerShell/psmux経路は従来どおり。
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
 
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を手元で通す。full regressionは手元で回さず、CIに任せる。
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>`)を
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiterm-mcp",
3
- "version": "0.70.5",
3
+ "version": "0.70.7",
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,7 @@
55
55
  "files": [
56
56
  "dist/*.js",
57
57
  "dist/harnesses/*.js",
58
+ "native/write-ban/linux-*/aiterm-write-ban",
58
59
  "runtime-overlap.json",
59
60
  "state-compat.json",
60
61
  "README.md",