@epoch-agent/plugin-terminal 0.13.0 → 0.15.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/dist/index.d.ts +6 -3
- package/dist/index.js +17 -10
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ interface SandboxOutcome {
|
|
|
66
66
|
*
|
|
67
67
|
* 从 `index.ts` 拆出来的:那边只留工具定义(参数 schema、危险命令拦截、
|
|
68
68
|
* workdir 校验、结果映射),这边只管「怎么起、怎么收」。拆的直接原因是
|
|
69
|
-
* 方案 16 把 `index.ts` 顶到了 630 行,越过
|
|
69
|
+
* 方案 16 把 `index.ts` 顶到了 630 行,越过 AGENTS.md 铁律 3 的 500 行线。
|
|
70
70
|
*
|
|
71
71
|
* 这个文件的主题只有一个:**别留下孤儿进程**。
|
|
72
72
|
*
|
|
@@ -316,8 +316,11 @@ declare function rekeyTasks(from: string, to: string): void;
|
|
|
316
316
|
*
|
|
317
317
|
* 宿主要的第三个口子 —— 前两个({@link listTasks} / {@link taskOutput})答的是
|
|
318
318
|
* 「现在是什么样」,这一个答的是「什么时候该再问一遍」。少了它,`epoch web`
|
|
319
|
-
*
|
|
320
|
-
*
|
|
319
|
+
* 检视面板「输出」那一格只在回合状态跃迁时才重取,于是一个会话空闲着的时候,
|
|
320
|
+
* 一条自己跑完(或者崩了)的构建会**无限期**停在「运行中」上。
|
|
321
|
+
*
|
|
322
|
+
* (2026-09-10 立这一条时说的是侧栏那行「N 在跑 / M」—— 那一行 2026-09-18 撤了,
|
|
323
|
+
* 宾语换成了「输出」那一格,而这个口子存在的理由一个字没变。)
|
|
321
324
|
*
|
|
322
325
|
* ## ⚠️ 这一个**不过 {@link isCommandJob} 那道闸**
|
|
323
326
|
*
|
package/dist/index.js
CHANGED
|
@@ -118,6 +118,7 @@ function startTask(sessionId, command, cwd, homeDir, sandbox) {
|
|
|
118
118
|
job.finish(status, code ?? void 0);
|
|
119
119
|
}
|
|
120
120
|
});
|
|
121
|
+
if (!started) return { task: toInfo(job.info()), sandbox: sh.outcome };
|
|
121
122
|
pid = started.pid;
|
|
122
123
|
job.setPid(pid);
|
|
123
124
|
return { task: toInfo(job.info()), sandbox: sh.outcome };
|
|
@@ -190,6 +191,7 @@ function describeTask(info) {
|
|
|
190
191
|
import { spawn } from "child_process";
|
|
191
192
|
import {
|
|
192
193
|
createStreamDecoder,
|
|
194
|
+
guardSpawn,
|
|
193
195
|
killProcessTree,
|
|
194
196
|
processFallbackTable,
|
|
195
197
|
shellSpawnArgs as shellSpawnArgs2
|
|
@@ -246,15 +248,20 @@ function runCommand(command, options) {
|
|
|
246
248
|
return new Promise((resolve3, reject) => {
|
|
247
249
|
const raw = shellSpawnArgs2(command);
|
|
248
250
|
const sh = confineShell({ file: raw.file, args: raw.args }, options.sandbox, options.cwd);
|
|
249
|
-
const child =
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
251
|
+
const child = guardSpawn(
|
|
252
|
+
() => spawn(sh.file, sh.args, {
|
|
253
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
254
|
+
cwd: options.cwd,
|
|
255
|
+
...raw.options
|
|
256
|
+
}),
|
|
257
|
+
reject
|
|
258
|
+
);
|
|
259
|
+
if (!child) return;
|
|
260
|
+
const proc = child;
|
|
254
261
|
let killedBy = null;
|
|
255
262
|
let settled = false;
|
|
256
263
|
let forceTimer;
|
|
257
|
-
const drain = collectStreams(
|
|
264
|
+
const drain = collectStreams(proc, () => kill("overflow"), options.onOutput);
|
|
258
265
|
const timer = setTimeout(() => kill("timeout"), options.timeout);
|
|
259
266
|
const abortCheck = setInterval(() => {
|
|
260
267
|
if (options.signal?.aborted) kill("abort");
|
|
@@ -269,7 +276,7 @@ function runCommand(command, options) {
|
|
|
269
276
|
settled = true;
|
|
270
277
|
clearTimers();
|
|
271
278
|
const { stdout, stderr } = drain();
|
|
272
|
-
const exitCode =
|
|
279
|
+
const exitCode = proc.exitCode ?? -1;
|
|
273
280
|
resolve3({
|
|
274
281
|
stdout,
|
|
275
282
|
stderr,
|
|
@@ -282,12 +289,12 @@ function runCommand(command, options) {
|
|
|
282
289
|
function kill(why) {
|
|
283
290
|
if (killedBy) return;
|
|
284
291
|
killedBy = why;
|
|
285
|
-
killChildTree(
|
|
292
|
+
killChildTree(proc);
|
|
286
293
|
forceTimer = setTimeout(finish, FORCE_SETTLE_MS);
|
|
287
294
|
}
|
|
288
295
|
if (options.signal?.aborted) kill("abort");
|
|
289
|
-
|
|
290
|
-
|
|
296
|
+
proc.on("close", finish);
|
|
297
|
+
proc.on("error", (err) => {
|
|
291
298
|
if (settled) return;
|
|
292
299
|
settled = true;
|
|
293
300
|
clearTimers();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epoch-agent/plugin-terminal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.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.15.0",
|
|
26
|
+
"@epoch-agent/protocol": "0.15.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^26.1.2",
|