@epoch-agent/plugin-terminal 0.20.1 → 0.22.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 +7 -1
- package/dist/index.d.ts +9 -2
- package/dist/index.js +9 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -90,7 +90,7 @@ PTY 那条是最后接的,而且方案里**允许的结论是「不上沙箱
|
|
|
90
90
|
```
|
|
91
91
|
terminal({ command: 'pnpm dev', background: true }) → 立即返回 t1
|
|
92
92
|
task_output({ id: 't1', since }) → 增量取输出
|
|
93
|
-
task_wait({ id: 't1', timeoutMs }) →
|
|
93
|
+
task_wait({ id: 't1', timeoutMs }) → 等它结束(**超时不杀它**;用户按停止当场返回)
|
|
94
94
|
task_stop({ id: 't1' }) → 停掉(杀整棵树)
|
|
95
95
|
task_list() → 看全部
|
|
96
96
|
```
|
|
@@ -115,6 +115,12 @@ task_list() → 看全部
|
|
|
115
115
|
一个例外:`task_wait` 遇到持久会话会**立刻**返回一句「它没有『结束』这个状态」,
|
|
116
116
|
而不是干等到超时 —— 那是方案 §五「不做 `shell_wait`」的理由说给模型听一遍。
|
|
117
117
|
|
|
118
|
+
另一个例外:用户按停止时它**当场**返回(2026-09-29)。判据和「超时不杀它」逐字
|
|
119
|
+
同款 —— 只是**我们不等了**,那条作业照旧在跑。在这一笔之前它是唯一一个愿意干等
|
|
120
|
+
5 分钟却不看 `ctx.signal` 的工具(`terminal` 前台命令 100ms 轮询、`delegate_task`
|
|
121
|
+
走 `linkAbort`、MCP / LSP 各接各的),于是用户按终止之后界面一直挂在「正在终止…」
|
|
122
|
+
上,直到那个 `timeoutMs` 走满 —— 看起来就是卡死。
|
|
123
|
+
|
|
118
124
|
**给宿主的两个口子(`listTasks` / `taskOutput`,runtime 转给 server / TUI)
|
|
119
125
|
仍然只报后台命令那一类。** 判据在 `src/background.ts` 的文件头:它们的落点是
|
|
120
126
|
`BackgroundTaskInfo` 那个线上形状,而把持久会话塞进去意味着 `command` 那一格
|
package/dist/index.d.ts
CHANGED
|
@@ -291,12 +291,19 @@ interface TaskWaitResult {
|
|
|
291
291
|
info: BackgroundTaskInfo;
|
|
292
292
|
/** 等超时了(任务还在跑)。**没杀它** */
|
|
293
293
|
timedOut: boolean;
|
|
294
|
+
/**
|
|
295
|
+
* 等待被中止信号打断了(用户按了停止)。**同样没杀它** ——
|
|
296
|
+
* 判据整段在 infra 的 `JobWaitResult.aborted` 上。
|
|
297
|
+
*/
|
|
298
|
+
aborted: boolean;
|
|
294
299
|
}
|
|
295
300
|
/**
|
|
296
301
|
* 等一个任务结束。超时**不杀它** —— 「我等不及了」和「我要停掉它」是两件事。
|
|
297
|
-
* 实现在 `infra/jobs.ts` 的 `waitJob()
|
|
302
|
+
* 实现在 `infra/jobs.ts` 的 `waitJob()`,中止那一档同样由它负责。
|
|
298
303
|
*/
|
|
299
|
-
declare function waitTask(sessionId: string, id: string, timeoutMs: number
|
|
304
|
+
declare function waitTask(sessionId: string, id: string, timeoutMs: number, signal?: {
|
|
305
|
+
readonly aborted: boolean;
|
|
306
|
+
}): Promise<TaskWaitResult | undefined>;
|
|
300
307
|
/**
|
|
301
308
|
* `/resume` 换了会话 id,这一格跟着搬(方案 25 PR-4)。
|
|
302
309
|
*
|
package/dist/index.js
CHANGED
|
@@ -146,11 +146,11 @@ function stopTask(sessionId, id) {
|
|
|
146
146
|
if (!commandJob(sessionId, id)) return Promise.resolve(false);
|
|
147
147
|
return stopJob(sessionId, id);
|
|
148
148
|
}
|
|
149
|
-
async function waitTask(sessionId, id, timeoutMs) {
|
|
149
|
+
async function waitTask(sessionId, id, timeoutMs, signal) {
|
|
150
150
|
if (!commandJob(sessionId, id)) return void 0;
|
|
151
|
-
const result = await waitJob(sessionId, id, timeoutMs);
|
|
151
|
+
const result = await waitJob(sessionId, id, timeoutMs, signal);
|
|
152
152
|
if (!result) return void 0;
|
|
153
|
-
return { info: toInfo(result.info), timedOut: result.timedOut };
|
|
153
|
+
return { info: toInfo(result.info), timedOut: result.timedOut, aborted: result.aborted };
|
|
154
154
|
}
|
|
155
155
|
function rekeyTasks(from, to) {
|
|
156
156
|
rekeyJobs(from, to, ["command"]);
|
|
@@ -1060,6 +1060,10 @@ function waitTimedOutNotice(seconds) {
|
|
|
1060
1060
|
return `
|
|
1061
1061
|
\u7B49\u4E86 ${seconds}s \u8FD8\u6CA1\u7ED3\u675F\uFF0C**\u6CA1\u6709\u505C\u5B83**\u3002\u53EF\u4EE5\u63A5\u7740\u5E72\u522B\u7684\uFF0C\u6216\u518D\u7B49\u4E00\u6B21\u3002`;
|
|
1062
1062
|
}
|
|
1063
|
+
function waitAbortedNotice(id) {
|
|
1064
|
+
return `
|
|
1065
|
+
\u7528\u6237\u4E2D\u6B62\u4E86\u8FD9\u6B21\u7B49\u5F85\uFF0C**\u6CA1\u6709\u505C\u5B83**\u3002${id} \u8FD8\u5728\u8DD1\uFF1A\u8981\u770B\u5B83\u73B0\u5728\u7684\u72B6\u6001\u7528 task_list\uFF0C\u8981\u7EE7\u7EED\u7B49\u518D\u8C03\u4E00\u6B21 task_wait\uFF0C\u8981\u771F\u7684\u6536\u6389\u5B83\u7528 task_stop\u3002`;
|
|
1066
|
+
}
|
|
1063
1067
|
var WAIT_DONE = "\n\u7528 task_output \u53D6\u8F93\u51FA\u3002";
|
|
1064
1068
|
function neverEndsNotice(id) {
|
|
1065
1069
|
return `
|
|
@@ -1170,9 +1174,9 @@ var taskWait = {
|
|
|
1170
1174
|
Number.isFinite(requested) && requested > 0 ? requested : DEFAULT_WAIT_MS2,
|
|
1171
1175
|
MAX_WAIT_MS2
|
|
1172
1176
|
);
|
|
1173
|
-
const result = await waitJob2(ctx.sessionId, id, timeout);
|
|
1177
|
+
const result = await waitJob2(ctx.sessionId, id, timeout, ctx.signal);
|
|
1174
1178
|
if (!result) return notFound2(id);
|
|
1175
|
-
const tail = result.neverEnds ? neverEndsNotice(id) : result.timedOut ? waitTimedOutNotice(Math.round(timeout / 1e3)) : WAIT_DONE;
|
|
1179
|
+
const tail = result.aborted ? waitAbortedNotice(id) : result.neverEnds ? neverEndsNotice(id) : result.timedOut ? waitTimedOutNotice(Math.round(timeout / 1e3)) : WAIT_DONE;
|
|
1176
1180
|
return ok2(describeJob(result.info) + tail);
|
|
1177
1181
|
}
|
|
1178
1182
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epoch-agent/plugin-terminal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.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.22.0",
|
|
26
|
+
"@epoch-agent/protocol": "0.22.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^26.1.2",
|