@snack-kit/porygon 0.7.0 → 0.8.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 +14 -0
- package/dist/index.cjs +30 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +30 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -630,6 +630,20 @@ npm run playground # 启动 Playground
|
|
|
630
630
|
|
|
631
631
|
## Changelog
|
|
632
632
|
|
|
633
|
+
### v0.8.0
|
|
634
|
+
|
|
635
|
+
#### 改进
|
|
636
|
+
|
|
637
|
+
- **`timeoutMs` 语义变更为空闲超时** — `timeoutMs` 不再表示进程的绝对超时时间,而是"空闲超时":进程无任何输出(stdout/stderr)超过此时间才触发终止。每次收到输出会重置计时器,更适合 LLM 调用耗时不可预测的场景
|
|
638
|
+
- **默认空闲超时调整** — 默认值从 `300_000`(5 分钟)调整为 `120_000`(2 分钟)
|
|
639
|
+
|
|
640
|
+
#### 破坏性变更
|
|
641
|
+
|
|
642
|
+
- **`timeoutMs` 语义变更** — 从绝对超时改为空闲超时(idle timeout)。如果依赖旧的绝对超时行为,需要调整使用方式。对于模型思考时间可能较长的场景,建议适当调大此值
|
|
643
|
+
- **默认超时时间缩短** — 从 5 分钟缩短至 2 分钟。如需更长超时,请在 `defaults.timeoutMs` 或请求参数中显式设置
|
|
644
|
+
|
|
645
|
+
---
|
|
646
|
+
|
|
633
647
|
### v0.7.0
|
|
634
648
|
|
|
635
649
|
#### 新特性
|
package/dist/index.cjs
CHANGED
|
@@ -58,8 +58,8 @@ var DEFAULT_CONFIG = {
|
|
|
58
58
|
defaultBackend: "claude",
|
|
59
59
|
backends: {},
|
|
60
60
|
defaults: {
|
|
61
|
-
timeoutMs:
|
|
62
|
-
//
|
|
61
|
+
timeoutMs: 12e4,
|
|
62
|
+
// 空闲超时:进程无任何输出超过此时间则终止
|
|
63
63
|
maxTurns: 50
|
|
64
64
|
},
|
|
65
65
|
proxy: void 0
|
|
@@ -317,19 +317,25 @@ var EphemeralProcess = class {
|
|
|
317
317
|
this.childProcess = child;
|
|
318
318
|
const stdoutChunks = [];
|
|
319
319
|
const stderrChunks = [];
|
|
320
|
+
let timeoutTimer;
|
|
321
|
+
const resetTimeout = () => {
|
|
322
|
+
if (options.timeoutMs !== void 0 && options.timeoutMs > 0) {
|
|
323
|
+
if (timeoutTimer) clearTimeout(timeoutTimer);
|
|
324
|
+
timeoutTimer = setTimeout(() => {
|
|
325
|
+
this.terminate();
|
|
326
|
+
reject(new Error(`Process idle timed out after ${options.timeoutMs}ms`));
|
|
327
|
+
}, options.timeoutMs);
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
resetTimeout();
|
|
320
331
|
child.stdout?.on("data", (chunk) => {
|
|
321
332
|
stdoutChunks.push(chunk);
|
|
333
|
+
resetTimeout();
|
|
322
334
|
});
|
|
323
335
|
child.stderr?.on("data", (chunk) => {
|
|
324
336
|
stderrChunks.push(chunk);
|
|
337
|
+
resetTimeout();
|
|
325
338
|
});
|
|
326
|
-
let timeoutTimer;
|
|
327
|
-
if (options.timeoutMs !== void 0 && options.timeoutMs > 0) {
|
|
328
|
-
timeoutTimer = setTimeout(() => {
|
|
329
|
-
this.terminate();
|
|
330
|
-
reject(new Error(`Process timed out after ${options.timeoutMs}ms`));
|
|
331
|
-
}, options.timeoutMs);
|
|
332
|
-
}
|
|
333
339
|
const onAbort = () => {
|
|
334
340
|
this.terminate();
|
|
335
341
|
reject(new Error("Process aborted"));
|
|
@@ -378,12 +384,16 @@ var EphemeralProcess = class {
|
|
|
378
384
|
});
|
|
379
385
|
}
|
|
380
386
|
let timeoutTimer;
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
+
const resetTimeout = () => {
|
|
388
|
+
if (options.timeoutMs !== void 0 && options.timeoutMs > 0) {
|
|
389
|
+
if (timeoutTimer) clearTimeout(timeoutTimer);
|
|
390
|
+
timeoutTimer = setTimeout(() => {
|
|
391
|
+
this.timedOut = true;
|
|
392
|
+
this.terminate();
|
|
393
|
+
}, options.timeoutMs);
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
resetTimeout();
|
|
387
397
|
const onAbort = () => {
|
|
388
398
|
this.terminate();
|
|
389
399
|
};
|
|
@@ -391,6 +401,7 @@ var EphemeralProcess = class {
|
|
|
391
401
|
const stderrChunks = [];
|
|
392
402
|
child.stderr?.on("data", (chunk) => {
|
|
393
403
|
stderrChunks.push(chunk);
|
|
404
|
+
resetTimeout();
|
|
394
405
|
});
|
|
395
406
|
let exitCode = null;
|
|
396
407
|
const exitPromise = new Promise((resolve) => {
|
|
@@ -399,6 +410,9 @@ var EphemeralProcess = class {
|
|
|
399
410
|
resolve();
|
|
400
411
|
});
|
|
401
412
|
});
|
|
413
|
+
child.stdout?.on("data", () => {
|
|
414
|
+
resetTimeout();
|
|
415
|
+
});
|
|
402
416
|
const rl = (0, import_node_readline.createInterface)({ input: child.stdout });
|
|
403
417
|
let yieldedLines = 0;
|
|
404
418
|
try {
|
|
@@ -414,7 +428,7 @@ var EphemeralProcess = class {
|
|
|
414
428
|
);
|
|
415
429
|
}
|
|
416
430
|
if (this.timedOut) {
|
|
417
|
-
throw new Error(`Process timed out after ${options.timeoutMs}ms`);
|
|
431
|
+
throw new Error(`Process idle timed out after ${options.timeoutMs}ms`);
|
|
418
432
|
}
|
|
419
433
|
} finally {
|
|
420
434
|
if (timeoutTimer) clearTimeout(timeoutTimer);
|