@cloud411716/fancy-webnovel 4.30.20 → 4.30.21
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/package.json
CHANGED
|
@@ -10,6 +10,7 @@ import fs from 'node:fs';
|
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
|
|
12
12
|
const TEAM_FILE = 'team.json';
|
|
13
|
+
const TEAM_CALL_TIMEOUT_MS = 20 * 60 * 1000;
|
|
13
14
|
const DEFAULT_TEAM = Object.freeze({
|
|
14
15
|
version: 1,
|
|
15
16
|
enabled: false,
|
|
@@ -260,8 +261,15 @@ async function callSubagent({ subagents, parent, prompt, route, label, schema, s
|
|
|
260
261
|
} catch (err) {
|
|
261
262
|
return { ok: false, error: err && err.message ? err.message : String(err) };
|
|
262
263
|
}
|
|
264
|
+
let timer = null;
|
|
263
265
|
try {
|
|
264
|
-
const result = await
|
|
266
|
+
const result = await Promise.race([
|
|
267
|
+
activation.result,
|
|
268
|
+
new Promise((_, reject) => {
|
|
269
|
+
timer = setTimeout(() => reject(new Error(`子 agent ${label} 超时`)), TEAM_CALL_TIMEOUT_MS);
|
|
270
|
+
if (timer && typeof timer.unref === 'function') timer.unref();
|
|
271
|
+
}),
|
|
272
|
+
]);
|
|
265
273
|
if (!result || result.stopReason !== 'completed') {
|
|
266
274
|
return { ok: false, error: (result && (result.diagnostic || result.stopReason)) || '子 agent 未完成' };
|
|
267
275
|
}
|
|
@@ -270,7 +278,10 @@ async function callSubagent({ subagents, parent, prompt, route, label, schema, s
|
|
|
270
278
|
return { ok: true, value: result.structured };
|
|
271
279
|
}
|
|
272
280
|
return { ok: true, value: textFromBlocks(result.output) };
|
|
281
|
+
} catch (err) {
|
|
282
|
+
return { ok: false, error: err && err.message ? err.message : String(err) };
|
|
273
283
|
} finally {
|
|
284
|
+
if (timer) clearTimeout(timer);
|
|
274
285
|
try { await activation.dispose(); } catch { /* best effort */ }
|
|
275
286
|
}
|
|
276
287
|
}
|