@epoch-agent/plugin-terminal 0.22.0 → 0.23.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 +19 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -38,11 +38,17 @@
|
|
|
38
38
|
|
|
39
39
|
边界按**权限档位**推导,用户不多学一个概念:
|
|
40
40
|
|
|
41
|
-
| 权限档位
|
|
42
|
-
|
|
|
43
|
-
| `plan`
|
|
44
|
-
| `
|
|
45
|
-
| `bypass`
|
|
41
|
+
| 权限档位 | 沙箱模式 | 能写到哪 |
|
|
42
|
+
| ------------------------- | -------------------- | --------------------------------------- |
|
|
43
|
+
| `plan` | `read-only` | 哪都不行(`/dev/null` 除外) |
|
|
44
|
+
| `default` / `acceptEdits` | `workspace-write` | 工作区 + 额外根 + 临时目录 + 工具链缓存 |
|
|
45
|
+
| `auto` / `bypass` | `danger-full-access` | 不设限 —— **但危险命令表照旧拦** |
|
|
46
|
+
|
|
47
|
+
⚠️ **`auto` 那一格 2026-10-08 从 `workspace-write` 改成 `danger-full-access`。**
|
|
48
|
+
不是「越松越好」:那一档的**文件工具早就不看工作区了**(工作区外的读写它都放行),
|
|
49
|
+
留着沙箱只会让同一档里 `file_write('~/x')` 落得下去、而 `echo > ~/x` 被 OS 挡下
|
|
50
|
+
—— 而菜单上那一档写的是「工作区外也一样」。改完之后它和 `bypass` 在**这一轴上**
|
|
51
|
+
相同,差别收窄成审批那一格(`bypass` 连「判不了」的都不问,`auto` 照问)。
|
|
46
52
|
|
|
47
53
|
**外加一个开关**:`sandbox.terminal: false`(2026-08-21,方案 46 §11.3 第一条,见
|
|
48
54
|
[CONFIGURATION.md](../../../docs/CONFIGURATION.md#关掉-terminal-的-os-沙箱))。
|
|
@@ -63,6 +69,7 @@
|
|
|
63
69
|
1. **只管写入。** 读取和网络都**不设限** —— 给终端上读白名单会让 `git push`
|
|
64
70
|
(要读 `~/.ssh`)和 `pnpm install`(要读 `~/.npmrc`)当场废掉。
|
|
65
71
|
沙箱里的命令还能 `ps` 看见主机上别的进程。
|
|
72
|
+
⚠️ **`auto` / `bypass` 两档连写入都不挡**(上面那张表),这两档下第 1 条不适用。
|
|
66
73
|
2. **「三条路径都包上了」不等于「terminal 安全了」。** 安全中心那份「不在沙箱里」的
|
|
67
74
|
点名清单现在是空的,它只说**没有哪条路径看起来在沙箱里而实际不在** ——
|
|
68
75
|
第 1 条和第 3 条一个字都没变。那份清单也**不认上面那个开关**(它是一张静态的
|
|
@@ -253,7 +260,13 @@ per-call 覆盖等于让「哪个 shell 在跑」有第二个说了算的地方
|
|
|
253
260
|
「在工作区内」(`workdir` 的判定)用的是 infra 的
|
|
254
261
|
[`isInWorkspace()`](../../infra/src/workspace.ts) —— 全仓唯一一份,权限层和 plugin-file
|
|
255
262
|
共用(本插件里原来有一份逐字相同的私有实现)。`ctx.extraRoots`(`epoch --add-dir`)
|
|
256
|
-
|
|
263
|
+
里的目录同样算工作区内,`ctx.grantedPaths`(**权限层这一次放行的**路径,2026-10-08)
|
|
264
|
+
也一并当根用 —— 后者是「你刚在审批框里点了允许」那一档,判据在 protocol 的
|
|
265
|
+
`ToolContext.grantedPaths` 上。
|
|
266
|
+
|
|
267
|
+
> ⚠️ **`grantedPaths` 只进这道判定,不进沙箱**:沙箱那份可写根仍只认
|
|
268
|
+
> `extraRoots`(`sandbox.ts` 的 `sandboxPolicyFor`)。批准读一个目录不该顺手
|
|
269
|
+
> 把沙箱的写也放开。
|
|
257
270
|
|
|
258
271
|
## 三条执行路径
|
|
259
272
|
|
package/dist/index.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ interface SandboxOutcome {
|
|
|
42
42
|
*
|
|
43
43
|
* 四档是四句不同的话,不能合成一个「没有沙箱」:
|
|
44
44
|
* `config-disabled` 是**用户把 `sandbox.terminal` 关了**(方案 46 §11.3 第一条),
|
|
45
|
-
* `mode-disabled`
|
|
45
|
+
* `mode-disabled` 是**用户选了不上沙箱的那两档**(`auto` / `bypass`),
|
|
46
46
|
* `no-backend` 是**平台限制**(Windows / 没装 bwrap),
|
|
47
47
|
* `not-requested` 是**调用方没传 policy**(今天只有用例会这样)。
|
|
48
48
|
*
|
package/dist/index.js
CHANGED
|
@@ -476,7 +476,7 @@ function sandboxNotice(sb) {
|
|
|
476
476
|
return "[\u6C99\u7BB1: \u5173] \u914D\u7F6E\u91CC sandbox.terminal \u662F false\uFF0C\u672C\u6B21\u6CA1\u6709 OS \u7EA7\u9694\u79BB\uFF0C\u547D\u4EE4\u80FD\u8BFB\u5199\u6574\u4E2A\u6587\u4EF6\u7CFB\u7EDF\u3002\u8FD9\u4E00\u6863\u548C\u6743\u9650\u6863\u4F4D\u65E0\u5173\uFF08\u5BA1\u6279\u7167\u65E7\uFF09\uFF0C\u5371\u9669\u547D\u4EE4\u8868\u4ECD\u7136\u5728\u5C97\u3002";
|
|
477
477
|
}
|
|
478
478
|
if (sb.skipped === "mode-disabled") {
|
|
479
|
-
return "[\u6C99\u7BB1: \u5173] \u5F53\u524D\u6743\u9650\u6863\u4F4D\
|
|
479
|
+
return "[\u6C99\u7BB1: \u5173] \u5F53\u524D\u6743\u9650\u6863\u4F4D\uFF08`auto` / `bypass` \u4E24\u6863\u90FD\u4E0D\u4E0A\u6C99\u7BB1\uFF09\uFF0C\u672C\u6B21\u6CA1\u6709 OS \u7EA7\u9694\u79BB\u3002\u5371\u9669\u547D\u4EE4\u8868\u4ECD\u7136\u5728\u5C97\u3002";
|
|
480
480
|
}
|
|
481
481
|
if (sb.skipped === "no-backend") {
|
|
482
482
|
return `[\u6C99\u7BB1: \u65E0] \u672C\u6B21\u6CA1\u6709 OS \u7EA7\u9694\u79BB\u2014\u2014\u8FD9\u4E2A\u5E73\u53F0\uFF08${sb.backend === "none" ? process.platform : sb.backend}\uFF09\u4E0A\u63A2\u6D4B\u4E0D\u5230\u53EF\u7528\u540E\u7AEF\uFF0C\u547D\u4EE4\u80FD\u8BFB\u5199\u6574\u4E2A\u6587\u4EF6\u7CFB\u7EDF\u3002`;
|
|
@@ -877,7 +877,8 @@ var shellOpen = {
|
|
|
877
877
|
execute: (args, ctx) => {
|
|
878
878
|
const workdir = args["workdir"] ? String(args["workdir"]) : void 0;
|
|
879
879
|
const baseDir = ctx.workDir || process.cwd();
|
|
880
|
-
|
|
880
|
+
const roots = [...ctx.extraRoots ?? [], ...ctx.grantedPaths ?? []];
|
|
881
|
+
if (workdir && !isInWorkspace(workdir, baseDir, roots)) {
|
|
881
882
|
return Promise.resolve(
|
|
882
883
|
fail(
|
|
883
884
|
2006,
|
|
@@ -1298,7 +1299,8 @@ var terminalTool = {
|
|
|
1298
1299
|
const baseDir = ctx.workDir || process.cwd();
|
|
1299
1300
|
let cwd = baseDir;
|
|
1300
1301
|
if (workdir) {
|
|
1301
|
-
|
|
1302
|
+
const roots = [...ctx.extraRoots ?? [], ...ctx.grantedPaths ?? []];
|
|
1303
|
+
if (!isInWorkspace2(workdir, baseDir, roots)) {
|
|
1302
1304
|
return {
|
|
1303
1305
|
success: false,
|
|
1304
1306
|
output: "",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epoch-agent/plugin-terminal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.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/infra": "0.
|
|
26
|
-
"@epoch-agent/protocol": "0.
|
|
25
|
+
"@epoch-agent/infra": "0.23.0",
|
|
26
|
+
"@epoch-agent/protocol": "0.23.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^26.1.2",
|