aiterm-mcp 0.28.2 → 0.28.3
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/dist/agent-shared.js +2 -25
- package/dist/claude-stop-hook.js +1 -21
- package/dist/grok-stop-hook.js +1 -24
- package/dist/state-root.js +30 -0
- package/package.json +1 -1
package/dist/agent-shared.js
CHANGED
|
@@ -1,35 +1,12 @@
|
|
|
1
1
|
// harness中立の共有プリミティブ。core と harnesses/ の両方が依存する最下層で、
|
|
2
2
|
// tmux-runtime / errors 以外の内部moduleへ依存しない(依存方向: core → harnesses → agent-shared)。
|
|
3
3
|
import * as fs from "node:fs";
|
|
4
|
-
import * as os from "node:os";
|
|
5
4
|
import * as path from "node:path";
|
|
6
5
|
import { randomBytes } from "node:crypto";
|
|
7
6
|
import { AitermError } from "./errors.js";
|
|
8
7
|
export const sleep = (ms) => new Promise((res) => setTimeout(res, ms));
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// agent metadata の存在確認経由で素の pty_send まで巻き込んで全 send を殺していた。
|
|
12
|
-
// Windows の fs.Stats.uid は常に 0 なので、ここも 0 を返せば owner 比較
|
|
13
|
-
// (st.uid !== currentUid()) は自然に通過する。Windows は POSIX owner 検証を
|
|
14
|
-
// 持たない(NTFS ACL は別体系)という既知の制約の明示的受容であり、POSIX 側は
|
|
15
|
-
// getuid をそのまま返すため挙動不変。
|
|
16
|
-
if (typeof process.getuid !== "function")
|
|
17
|
-
return 0;
|
|
18
|
-
return process.getuid();
|
|
19
|
-
}
|
|
20
|
-
export function runtimeStateBase() {
|
|
21
|
-
const xdg = process.env.XDG_RUNTIME_DIR;
|
|
22
|
-
if (xdg) {
|
|
23
|
-
try {
|
|
24
|
-
if (fs.statSync(xdg).isDirectory())
|
|
25
|
-
return xdg;
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
/* XDG_RUNTIME_DIR が壊れている CI/非 login 環境では os.tmpdir() に戻す */
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return os.tmpdir();
|
|
32
|
-
}
|
|
8
|
+
import { currentUid, runtimeStateBase } from "./state-root.js";
|
|
9
|
+
export { currentUid, runtimeStateBase };
|
|
33
10
|
export function safeStatSize(p) {
|
|
34
11
|
try {
|
|
35
12
|
return fs.statSync(p).size;
|
package/dist/claude-stop-hook.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
|
-
import * as os from "node:os";
|
|
4
3
|
import * as path from "node:path";
|
|
4
|
+
import { currentUid as uid, runtimeStateBase } from "./state-root.js";
|
|
5
5
|
import { createHash, randomBytes } from "node:crypto";
|
|
6
6
|
const LAUNCH_ID_RE = /^[0-9a-f]{32}$/;
|
|
7
7
|
const SESSION_RE = /^[A-Za-z0-9_-]{1,64}$/;
|
|
@@ -21,26 +21,6 @@ function hasAitermEnv() {
|
|
|
21
21
|
process.env.AITERM_AGENT_SESSION_ID ||
|
|
22
22
|
process.env.AITERM_AGENT_LAUNCH_ID);
|
|
23
23
|
}
|
|
24
|
-
function uid() {
|
|
25
|
-
// state root のパス構成要素 `aiterm-mcp-<uid>` にだけ使う。Windows(native) は
|
|
26
|
-
// process.getuid を持たないため core の currentUid() と同じ受容で 0 を返す。
|
|
27
|
-
if (typeof process.getuid !== "function")
|
|
28
|
-
return 0;
|
|
29
|
-
return process.getuid();
|
|
30
|
-
}
|
|
31
|
-
function runtimeStateBase() {
|
|
32
|
-
const xdg = process.env.XDG_RUNTIME_DIR;
|
|
33
|
-
if (xdg) {
|
|
34
|
-
try {
|
|
35
|
-
if (fs.statSync(xdg).isDirectory())
|
|
36
|
-
return xdg;
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
/* 壊れたXDG_RUNTIME_DIRはTMPDIRへ戻す */
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return os.tmpdir();
|
|
43
|
-
}
|
|
44
24
|
function agentsDir() {
|
|
45
25
|
// state root は OS が与える per-user runtime dir(XDG_RUNTIME_DIR / os.tmpdir())の下にある。
|
|
46
26
|
// 以前はここで symlink・owner・mode を検査していたが、共有 /tmp に敵対的な同居主体がいる
|
package/dist/grok-stop-hook.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
|
-
import * as os from "node:os";
|
|
4
3
|
import * as path from "node:path";
|
|
4
|
+
import { currentUid as uid, runtimeStateBase } from "./state-root.js";
|
|
5
5
|
const LAUNCH_ID_RE = /^[0-9a-f]{32}$/;
|
|
6
6
|
const SESSION_RE = /^[A-Za-z0-9_-]{1,64}$/;
|
|
7
7
|
const MAX_STDIN_BYTES = 1024 * 1024;
|
|
@@ -18,29 +18,6 @@ function hasAitermEnv() {
|
|
|
18
18
|
process.env.AITERM_AGENT_SESSION_ID ||
|
|
19
19
|
process.env.AITERM_AGENT_LAUNCH_ID);
|
|
20
20
|
}
|
|
21
|
-
function uid() {
|
|
22
|
-
// Windows(native) は process.getuid を持たない。core の currentUid()・claude-stop-hook と
|
|
23
|
-
// 同じ受容として 0 を返す(Windows の fs.Stats.uid は常に 0 のため owner 比較は自然に
|
|
24
|
-
// 通過する。NTFS ACL は別体系)。POSIX は getuid のまま=挙動不変。
|
|
25
|
-
// 以前はここで fail していたため、Windows では Grok/Composer の完了 event が
|
|
26
|
-
// 一度も書かれず aiterm-wait が timeout まで返らなかった。
|
|
27
|
-
if (typeof process.getuid !== "function")
|
|
28
|
-
return 0;
|
|
29
|
-
return process.getuid();
|
|
30
|
-
}
|
|
31
|
-
function runtimeStateBase() {
|
|
32
|
-
const xdg = process.env.XDG_RUNTIME_DIR;
|
|
33
|
-
if (xdg) {
|
|
34
|
-
try {
|
|
35
|
-
if (fs.statSync(xdg).isDirectory())
|
|
36
|
-
return xdg;
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
/* XDG_RUNTIME_DIR が壊れている CI/非 login 環境では os.tmpdir() に戻す */
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return os.tmpdir();
|
|
43
|
-
}
|
|
44
21
|
function agentsDir() {
|
|
45
22
|
const root = path.join(runtimeStateBase(), `aiterm-mcp-${uid()}`);
|
|
46
23
|
const agents = path.join(root, "agents");
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// state root(`aiterm-mcp-<uid>`)の位置決めの唯一の置き場。node builtin 以外へ依存しない最下層で、
|
|
2
|
+
// 単体実行される stop hook 2本と agent-shared がここだけを共有する(campaign 32 の maintenance queue
|
|
3
|
+
// に積んだ uid()/runtimeStateBase() の三重実装を解消。stop hook の「内部 module へ依存しない」設計は、
|
|
4
|
+
// 本 module が builtin 依存だけであることで保たれる)。
|
|
5
|
+
import * as fs from "node:fs";
|
|
6
|
+
import * as os from "node:os";
|
|
7
|
+
export function currentUid() {
|
|
8
|
+
// Windows(native)は process.getuid を持たない。以前はここで throw していたが、
|
|
9
|
+
// agent metadata の存在確認経由で素の pty_send まで巻き込んで全 send を殺していた。
|
|
10
|
+
// Windows の fs.Stats.uid は常に 0 なので、ここも 0 を返せば owner 比較
|
|
11
|
+
// (st.uid !== currentUid()) は自然に通過する。Windows は POSIX owner 検証を
|
|
12
|
+
// 持たない(NTFS ACL は別体系)という既知の制約の明示的受容であり、POSIX 側は
|
|
13
|
+
// getuid をそのまま返すため挙動不変。
|
|
14
|
+
if (typeof process.getuid !== "function")
|
|
15
|
+
return 0;
|
|
16
|
+
return process.getuid();
|
|
17
|
+
}
|
|
18
|
+
export function runtimeStateBase() {
|
|
19
|
+
const xdg = process.env.XDG_RUNTIME_DIR;
|
|
20
|
+
if (xdg) {
|
|
21
|
+
try {
|
|
22
|
+
if (fs.statSync(xdg).isDirectory())
|
|
23
|
+
return xdg;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
/* XDG_RUNTIME_DIR が壊れている CI/非 login 環境では os.tmpdir() に戻す */
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return os.tmpdir();
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiterm-mcp",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.3",
|
|
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, and Cursor Agent CLI, plus durable PTYs for SSH, containers, and REPLs.",
|
|
6
6
|
"keywords": [
|