dsh-mcmp 2.0.2 → 2.0.3
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/lib/index.js +7 -5
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -403,7 +403,7 @@ export function apply(ctx) {
|
|
|
403
403
|
}
|
|
404
404
|
|
|
405
405
|
// 启动一个子智能体并返回 { ok, text, outcome }
|
|
406
|
-
async function runChild(provider, session, agent,
|
|
406
|
+
async function runChild(provider, session, agent, controller, label, promptText, onStarted) {
|
|
407
407
|
let child = null
|
|
408
408
|
try {
|
|
409
409
|
const parent = (agents && agents.get(session.id)) || agent
|
|
@@ -413,6 +413,7 @@ export function apply(ctx) {
|
|
|
413
413
|
parent,
|
|
414
414
|
signal: controller.signal,
|
|
415
415
|
})
|
|
416
|
+
if (onStarted) { try { onStarted(child) } catch (err) { /* ignore */ } }
|
|
416
417
|
const res = await child.result
|
|
417
418
|
const text = (Array.isArray(res.output) ? res.output.filter((b) => b && b.type === 'text').map((b) => b.text).join('') : '')
|
|
418
419
|
const outcome = res.stopReason === 'completed' ? 'completed' : res.stopReason === 'cancelled' ? 'cancelled' : 'failed'
|
|
@@ -452,12 +453,13 @@ export function apply(ctx) {
|
|
|
452
453
|
let started = false
|
|
453
454
|
let outcome = 'failed'
|
|
454
455
|
let note = ''
|
|
455
|
-
const res = await runChild(provider, session, agent,
|
|
456
|
-
|
|
456
|
+
const res = await runChild(provider, session, agent, controller, label, buildPrompt(r, f.s, f.i, s, it, args), (child) => {
|
|
457
|
+
started = true
|
|
458
|
+
appendRec(runId, session, 'tool-workflow/agent-start', { runId, seq: g + 1, label, phase: s.phase, childId: String(child.id) })
|
|
459
|
+
})
|
|
457
460
|
outcome = res.outcome
|
|
458
461
|
note = (res.text || '').trim().slice(0, 300)
|
|
459
462
|
if (res.err) note = '执行异常: ' + String((res.err && res.err.message) || res.err).slice(0, 200)
|
|
460
|
-
if (started) appendRec(runId, session, 'tool-workflow/agent-start', { runId, seq: g + 1, label, phase: s.phase, childId: '' })
|
|
461
463
|
state.done = Math.min(g + 1, state.total)
|
|
462
464
|
refreshFiles()
|
|
463
465
|
if (outcome === 'completed') {
|
|
@@ -493,7 +495,7 @@ export function apply(ctx) {
|
|
|
493
495
|
state.agentLabel = 'S8 兜底·论文定稿'
|
|
494
496
|
const fresh = makeController()
|
|
495
497
|
const reason = stopReason === 'cancelled' ? '用户中止' : stopReason === 'error' ? errorMsg : '正常流程已结束但定稿步骤未完成'
|
|
496
|
-
const fres = await runChild(provider, session, agent,
|
|
498
|
+
const fres = await runChild(provider, session, agent, fresh, '兜底·论文定稿(不论成败)', buildFinalizePrompt(args, reason))
|
|
497
499
|
if (fres.outcome === 'completed') {
|
|
498
500
|
finalDone = true
|
|
499
501
|
pushLog('兜底定稿完成: 论文定稿.md 已生成')
|