@cloud411716/fancy-webnovel 4.30.23 → 4.30.25
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
|
@@ -2130,13 +2130,7 @@ async function handleTeamCommand(ctx, session, tokens) {
|
|
|
2130
2130
|
return notify(session, 'error', '❌ 读取模型列表失败:' + (err && err.message ? err.message : String(err)));
|
|
2131
2131
|
}
|
|
2132
2132
|
const ids = models.map((item) => String(item && item.id || ''));
|
|
2133
|
-
|
|
2134
|
-
return notify(session, 'error', [
|
|
2135
|
-
`❌ ${provider} 没有模型 "${model}"。可用:`,
|
|
2136
|
-
...ids.slice(0, 30).map((id) => '- ' + id),
|
|
2137
|
-
ids.length > 30 ? `… 共 ${ids.length} 个` : '',
|
|
2138
|
-
].filter(Boolean).join('\n'));
|
|
2139
|
-
}
|
|
2133
|
+
const catalogMiss = ids.length && !ids.includes(model);
|
|
2140
2134
|
const field = key === 'a' ? 'generatorA' : key === 'b' ? 'generatorB' : 'judge';
|
|
2141
2135
|
const clash = ['generatorA', 'generatorB', 'judge']
|
|
2142
2136
|
.filter((name) => name !== field)
|
|
@@ -2146,7 +2140,8 @@ async function handleTeamCommand(ctx, session, tokens) {
|
|
|
2146
2140
|
}
|
|
2147
2141
|
config[field] = { provider, model };
|
|
2148
2142
|
writeTeamConfig(root, config);
|
|
2149
|
-
return notify(session, 'success', `✅ ${field} 已设为 ${provider}/${model}。`
|
|
2143
|
+
return notify(session, 'success', `✅ ${field} 已设为 ${provider}/${model}。`
|
|
2144
|
+
+ (catalogMiss ? '\n⚠️ 该模型不在当前 provider 目录里,生成时以实际 API 为准。' : ''));
|
|
2150
2145
|
}
|
|
2151
2146
|
if (key === 'rounds') {
|
|
2152
2147
|
const n = Number.parseInt(value[0], 10);
|
|
@@ -120,9 +120,11 @@ export async function validateTeamModels(ctx, config) {
|
|
|
120
120
|
return `${label} 的 provider "${route.provider}" 不可用:${err && err.message ? err.message : String(err)}`;
|
|
121
121
|
}
|
|
122
122
|
const ids = (Array.isArray(models) ? models : []).map((item) => String(item && item.id || ''));
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
// Provider catalogs can lag behind accepted model aliases (for example a
|
|
124
|
+
// deprecated `-free` id that the API redirects to its stable id). Do not
|
|
125
|
+
// block generation here; an actually invalid route fails at the call with
|
|
126
|
+
// the provider's own error, which the team meta now records.
|
|
127
|
+
if (ids.length && !ids.includes(route.model)) continue;
|
|
126
128
|
}
|
|
127
129
|
return '';
|
|
128
130
|
}
|
|
@@ -153,6 +155,26 @@ function service(ctx, name) {
|
|
|
153
155
|
}
|
|
154
156
|
}
|
|
155
157
|
|
|
158
|
+
/** Read the child's terminal error from its durable session when available. */
|
|
159
|
+
async function subagentFailureDetail(ctx, childId) {
|
|
160
|
+
if (!childId) return '';
|
|
161
|
+
const query = service(ctx, 'sessionQuery');
|
|
162
|
+
if (!query || typeof query.readSession !== 'function') return '';
|
|
163
|
+
try {
|
|
164
|
+
const snapshot = await query.readSession(childId);
|
|
165
|
+
const events = Array.isArray(snapshot && snapshot.events) ? snapshot.events : [];
|
|
166
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
167
|
+
const event = events[index];
|
|
168
|
+
if (!event || event.type !== 'turn/end') continue;
|
|
169
|
+
const reason = event.data && event.data.reason;
|
|
170
|
+
if (!reason || reason.kind !== 'error') continue;
|
|
171
|
+
const message = reason.error && reason.error.message;
|
|
172
|
+
if (message) return String(message);
|
|
173
|
+
}
|
|
174
|
+
} catch { /* diagnostics only */ }
|
|
175
|
+
return '';
|
|
176
|
+
}
|
|
177
|
+
|
|
156
178
|
function retargetPrompt(prompt, from, to) {
|
|
157
179
|
return String(prompt || '').split(`目标文件(**绝对路径**):\`${from}\``).join(`目标文件(**绝对路径**):\`${to}\``);
|
|
158
180
|
}
|
|
@@ -281,7 +303,7 @@ function textFromBlocks(blocks) {
|
|
|
281
303
|
.join('');
|
|
282
304
|
}
|
|
283
305
|
|
|
284
|
-
async function callSubagent({ subagents, parent, prompt, route, label, schema, signal }) {
|
|
306
|
+
async function callSubagent({ ctx, subagents, parent, prompt, route, label, schema, signal }) {
|
|
285
307
|
let activation;
|
|
286
308
|
try {
|
|
287
309
|
activation = await subagents.startActivation({
|
|
@@ -307,7 +329,11 @@ async function callSubagent({ subagents, parent, prompt, route, label, schema, s
|
|
|
307
329
|
}),
|
|
308
330
|
]);
|
|
309
331
|
if (!result || result.stopReason !== 'completed') {
|
|
310
|
-
|
|
332
|
+
const detail = (result && result.diagnostic)
|
|
333
|
+
|| await subagentFailureDetail(ctx, activation.childId)
|
|
334
|
+
|| (result && result.stopReason)
|
|
335
|
+
|| '子 agent 未完成';
|
|
336
|
+
return { ok: false, error: detail, childId: activation.childId };
|
|
311
337
|
}
|
|
312
338
|
if (schema) {
|
|
313
339
|
if (result.structured === undefined) return { ok: false, error: '子 agent 没有返回结构化结果' };
|
|
@@ -319,6 +345,7 @@ async function callSubagent({ subagents, parent, prompt, route, label, schema, s
|
|
|
319
345
|
ok: false,
|
|
320
346
|
error: err && err.message ? err.message : String(err),
|
|
321
347
|
stack: err && err.stack ? String(err.stack) : '',
|
|
348
|
+
childId: activation && activation.childId,
|
|
322
349
|
};
|
|
323
350
|
} finally {
|
|
324
351
|
if (timer) clearTimeout(timer);
|
|
@@ -432,7 +459,7 @@ export async function runTeamBatch({
|
|
|
432
459
|
const call = async (promptText, route, label, schema) => {
|
|
433
460
|
if (calls >= maxCalls) return { ok: false, error: 'team workflow reached maxTotalCalls' };
|
|
434
461
|
calls += 1;
|
|
435
|
-
return callSubagent({ subagents, parent, prompt: promptText, route, label, schema, signal: parentSignal });
|
|
462
|
+
return callSubagent({ ctx, subagents, parent, prompt: promptText, route, label, schema, signal: parentSignal });
|
|
436
463
|
};
|
|
437
464
|
|
|
438
465
|
const [genA, genB] = await Promise.all([
|