@epoch-agent/plugin-terminal 4.1.1 → 6.0.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/README.md CHANGED
@@ -96,8 +96,12 @@
96
96
  点名清单现在是空的,它只说**没有哪条路径看起来在沙箱里而实际不在** ——
97
97
  第 1 条和第 3 条一个字都没变。那份清单也**不认上面那个开关**(它是一张静态的
98
98
  工具名清单)—— 开关关着时唯一如实说话的地方是每条命令自己的那一行回执。
99
- 3. **Windows 上没有后端**,所以那儿一次都没包上 —— 工具输出里会逐字说
100
- `[sandbox: none] no OS-level isolation this time …`。`epoch doctor` 的沙箱一节印的是实测值。
99
+ 3. **Windows 上 2026-11-11 起有后端了,但它弱一档、而且只覆盖两条路**:受限令牌 +
100
+ 完整性标签,包住管道和后台,`pty: true` 那条递不进令牌所以不在内;读和网络不设限。
101
+ `enforcement` 恒为 `partial`,工具输出那一行会带着它(判据在
102
+ [infra 的 windows-acl/index.ts](../../infra/src/sandbox/windows-acl/index.ts) 文件头,
103
+ 对外的完整清单在 [docs/TOOLS.md](../../../docs/TOOLS.md#windows受限令牌--完整性标签2026-11-11-接上如实说是-partial))。
104
+ `epoch doctor` 的沙箱一节印的是实测值。
101
105
 
102
106
  > ⚠️ **工具输出(回给模型读的那一份)2026-11-05 起一律英文**,不跟用户界面语言走:
103
107
  > 上面那行回执、截断与落盘提示、`task_*` / `shell_*` 的状态行、沙箱与失败说明都是。
package/dist/index.js CHANGED
@@ -40,7 +40,8 @@ function sandboxPolicyFor(ctx, workspaceRoot) {
40
40
  ...ctx.extraRoots ? { extraRoots: ctx.extraRoots } : {},
41
41
  allowNetwork: true,
42
42
  enabled: ctx.sandboxTerminal !== false,
43
- ...bypass ? { bypass } : {}
43
+ ...bypass ? { bypass } : {},
44
+ ...ctx.sandboxProtectedDirs?.length ? { protectedDirs: ctx.sandboxProtectedDirs } : {}
44
45
  };
45
46
  }
46
47
  function unconfined(skipped) {
@@ -55,7 +56,11 @@ function confineShell(sh, policy, cwd) {
55
56
  if (!policy) {
56
57
  return bare(unconfined("not-requested"));
57
58
  }
58
- const result = confine(sh.file, sh.args, { ...policy, ...cwd ? { cwd } : {} });
59
+ const result = confine(sh.file, sh.args, {
60
+ ...policy,
61
+ ...cwd ? { cwd } : {},
62
+ verbatimArgs: sh.verbatim === true
63
+ });
59
64
  if (!result.confined) {
60
65
  return bare({
61
66
  mode: result.mode,
@@ -75,6 +80,7 @@ function confineShell(sh, policy, cwd) {
75
80
  return {
76
81
  file: result.command,
77
82
  args: result.args,
83
+ ...result.env ? { env: result.env } : {},
78
84
  outcome,
79
85
  classify: (exitCode, stderr) => ({
80
86
  ...outcome,
@@ -100,7 +106,11 @@ function startTask(sessionId, command, cwd, homeDir, sandbox) {
100
106
  };
101
107
  }
102
108
  const raw = shellSpawnArgs(command);
103
- const sh = confineShell({ file: raw.file, args: raw.args }, sandbox, cwd);
109
+ const sh = confineShell(
110
+ { file: raw.file, args: raw.args, verbatim: raw.options.windowsVerbatimArguments === true },
111
+ sandbox,
112
+ cwd
113
+ );
104
114
  let pid = 0;
105
115
  const job = registerJob({
106
116
  sessionId,
@@ -118,7 +128,10 @@ function startTask(sessionId, command, cwd, homeDir, sandbox) {
118
128
  file: sh.file,
119
129
  args: sh.args,
120
130
  ...cwd ? { cwd } : {},
121
- ...raw.options ? { spawnOptions: raw.options } : {},
131
+ spawnOptions: {
132
+ ...sh.outcome.skipped === null ? { ...raw.options, windowsVerbatimArguments: false } : raw.options,
133
+ ...sh.env ? { env: { ...process.env, ...sh.env } } : {}
134
+ },
122
135
  onOutput: (chunk) => job.append(chunk),
123
136
  onExit: (code) => {
124
137
  const status = code === null ? "failed" : "exited";
@@ -258,12 +271,17 @@ function collectStreams(child, onOverflow, onOutput) {
258
271
  function runCommand(command, options) {
259
272
  return new Promise((resolve3, reject) => {
260
273
  const raw = shellSpawnArgs2(command);
261
- const sh = confineShell({ file: raw.file, args: raw.args }, options.sandbox, options.cwd);
274
+ const sh = confineShell(
275
+ { file: raw.file, args: raw.args, verbatim: raw.options.windowsVerbatimArguments === true },
276
+ options.sandbox,
277
+ options.cwd
278
+ );
262
279
  const child = guardSpawn(
263
280
  () => spawn(sh.file, sh.args, {
264
281
  stdio: ["ignore", "pipe", "pipe"],
265
282
  cwd: options.cwd,
266
- ...raw.options
283
+ ...sh.outcome.skipped === null ? { ...raw.options, windowsVerbatimArguments: false } : raw.options,
284
+ ...sh.env ? { env: { ...process.env, ...sh.env } } : {}
267
285
  }),
268
286
  reject
269
287
  );
@@ -501,7 +519,8 @@ function sandboxNotice(sb) {
501
519
  }
502
520
  const boundary = MODE_BOUNDARY[sb.mode ?? ""] ?? "";
503
521
  if (sb.enforcement === "partial") {
504
- return `[sandbox: ${sb.backend} \xB7 ${sb.mode} \xB7 enforcement incomplete] ${boundary}. What is incomplete: the POSIX shell has to keep /dev/null writable, otherwise it cannot even start.`;
522
+ const incomplete = sb.backend === "windows-acl" ? "the PTY path cannot be given the restricted token, reads and network are unrestricted, and in workspace-write the write boundary rests on the Low integrity label alone" : "the POSIX shell has to keep /dev/null writable, otherwise it cannot even start";
523
+ return `[sandbox: ${sb.backend} \xB7 ${sb.mode} \xB7 enforcement incomplete] ${boundary}. What is incomplete: ${incomplete}.`;
505
524
  }
506
525
  return `[sandbox: ${sb.backend} \xB7 ${sb.mode}] ${boundary}.`;
507
526
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epoch-agent/plugin-terminal",
3
- "version": "4.1.1",
3
+ "version": "6.0.0",
4
4
  "private": false,
5
5
  "description": "epoch-agent 终端命令执行插件",
6
6
  "repository": {
@@ -22,8 +22,8 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "node-pty": "^1.1.0",
25
- "@epoch-agent/protocol": "4.1.1",
26
- "@epoch-agent/infra": "4.1.1"
25
+ "@epoch-agent/infra": "6.0.0",
26
+ "@epoch-agent/protocol": "6.0.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^26.1.2",