@herbertgao/pi-extensions 2026.11.13 → 2026.11.14
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/CHANGELOG.md +10 -0
- package/README.md +4 -4
- package/node_modules/@herbertgao/pi-inline-skill-commands/README.md +6 -2
- package/node_modules/@herbertgao/pi-inline-skill-commands/package.json +1 -1
- package/node_modules/@herbertgao/pi-inline-skill-commands/src/index.ts +41 -15
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +10 -0
- package/node_modules/@herbertgao/pi-subagents/README.md +37 -7
- package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +113 -34
- package/node_modules/@herbertgao/pi-subagents/package.json +9 -4
- package/node_modules/@herbertgao/pi-subagents/skills/workflow-authoring/SKILL.md +147 -0
- package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +48 -32
- package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +16 -8
- package/node_modules/@herbertgao/pi-subagents/src/custom-agents.ts +16 -6
- package/node_modules/@herbertgao/pi-subagents/src/index.ts +99 -7
- package/node_modules/@herbertgao/pi-subagents/src/mention.ts +5 -7
- package/node_modules/@herbertgao/pi-subagents/src/settings.ts +26 -0
- package/node_modules/@herbertgao/pi-subagents/src/structured-output.ts +13 -5
- package/node_modules/@herbertgao/pi-subagents/src/ui/fleet-list.ts +55 -8
- package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-card-redraw.ts +86 -0
- package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-card.ts +5 -5
- package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-dialog.ts +478 -115
- package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-menu.ts +77 -6
- package/node_modules/@herbertgao/pi-subagents/src/workflow/agent-detail.ts +148 -0
- package/node_modules/@herbertgao/pi-subagents/src/workflow/host.ts +88 -14
- package/node_modules/@herbertgao/pi-subagents/src/workflow/journal.ts +8 -0
- package/node_modules/@herbertgao/pi-subagents/src/workflow/json-schema.ts +507 -57
- package/node_modules/@herbertgao/pi-subagents/src/workflow/progress.ts +41 -11
- package/node_modules/@herbertgao/pi-subagents/src/workflow/runtime.ts +106 -34
- package/node_modules/@herbertgao/pi-subagents/src/workflow/task.ts +43 -5
- package/node_modules/@herbertgao/pi-subagents/src/workflow/tool-description.ts +93 -153
- package/node_modules/@herbertgao/pi-subagents/src/workflow/worker-source.ts +283 -71
- package/node_modules/@pi-plugins/fast-mode/dist/index.mjs +288 -177
- package/node_modules/@pi-plugins/fast-mode/dist/index.mjs.map +1 -1
- package/node_modules/@pi-plugins/fast-mode/package.json +7 -7
- package/node_modules/pi-lens/CHANGELOG-USER.md +6 -6
- package/node_modules/pi-lens/CHANGELOG.md +132 -0
- package/node_modules/pi-lens/README.md +2 -0
- package/node_modules/pi-lens/config/dependency-cruiser-eager-allowlist.json +1 -0
- package/node_modules/pi-lens/dist/{chunk-LGH2HHZG.js → chunk-25CAONWT.js} +36 -25
- package/node_modules/pi-lens/dist/{chunk-ZQSSO7LO.js → chunk-2DWNYVUN.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-YCR6ZYTE.js → chunk-2RQREVGO.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-VWEBZ2JV.js → chunk-2XALJI2K.js} +40 -40
- package/node_modules/pi-lens/dist/{chunk-PQXUZYTQ.js → chunk-2YQ5LI7R.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-VSQT6IHZ.js → chunk-35UJUF27.js} +18 -4
- package/node_modules/pi-lens/dist/{chunk-OLWGYBYT.js → chunk-3IWMNN2S.js} +17 -17
- package/node_modules/pi-lens/dist/chunk-3UTDLQWO.js +88 -0
- package/node_modules/pi-lens/dist/chunk-3Z7Z3B7V.js +27 -0
- package/node_modules/pi-lens/dist/{chunk-UNP6Y4JV.js → chunk-4E4OCW3L.js} +16 -16
- package/node_modules/pi-lens/dist/{chunk-37IDWT6O.js → chunk-4GLSO2EM.js} +13 -11
- package/node_modules/pi-lens/dist/{chunk-QV3JPCMK.js → chunk-5HVDD7IA.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-ZRQMENT4.js → chunk-62PIU4TO.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-3TSMQZG6.js → chunk-6MDWNZ7E.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-WLD6BGON.js → chunk-6MWX2J5H.js} +4 -0
- package/node_modules/pi-lens/dist/{chunk-SCU62JLX.js → chunk-6MZLS6CK.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-B42AIWPJ.js → chunk-7BWPQZHE.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-I3NZVAMN.js → chunk-7JMEPY6P.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-7DPXUPRF.js → chunk-7ORBRDFY.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-6E5QLMWI.js → chunk-7WAQ3K26.js} +23 -23
- package/node_modules/pi-lens/dist/{chunk-2H5GHZKC.js → chunk-AB26NAHA.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-BBSDJTOV.js → chunk-AFSG6YUB.js} +13 -13
- package/node_modules/pi-lens/dist/{chunk-XDNWR7SG.js → chunk-ALTHJUZO.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-UN72ZAJ5.js → chunk-AOEVZXR6.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-HRLF35WL.js → chunk-ARTCVE6I.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-LQQNFCQJ.js → chunk-B2QO7GHY.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-I2FYOZNW.js → chunk-BJGWP4UX.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-G53LBDNU.js → chunk-BKJ6WZKP.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-P5MSLVUW.js → chunk-BQ72NQQM.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-K7O6AHSJ.js → chunk-BWGNVM33.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-ADYQRETD.js → chunk-BYIEU4E4.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-7ZVTFLCC.js → chunk-CDAJQBKJ.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-BKWFDWYM.js → chunk-D3UQWOCB.js} +16 -16
- package/node_modules/pi-lens/dist/{chunk-3PAS2ERX.js → chunk-DHFJS2I4.js} +8 -8
- package/node_modules/pi-lens/dist/{chunk-KNSOA43J.js → chunk-DKXIUGNA.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-LOEJFTF2.js → chunk-DLGJYQML.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-VGRGW4UL.js → chunk-DNJJVKJZ.js} +31 -31
- package/node_modules/pi-lens/dist/{chunk-5HBQL7DH.js → chunk-EBXCYEII.js} +3 -3
- package/node_modules/pi-lens/dist/chunk-EH6EHFW2.js +73 -0
- package/node_modules/pi-lens/dist/{chunk-W26QZ3OM.js → chunk-EKQDQPX6.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-TWEOJE3D.js → chunk-EXHSWN3P.js} +844 -377
- package/node_modules/pi-lens/dist/{chunk-4IZZEN63.js → chunk-F7BFIENK.js} +33 -33
- package/node_modules/pi-lens/dist/{chunk-ZI7YHV6I.js → chunk-FD4LJQ6Y.js} +5 -5
- package/node_modules/pi-lens/dist/{chunk-RIH3UBK4.js → chunk-GFCPPCNR.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-5JB4WENL.js → chunk-GIK6VUCY.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-PPQHMSPH.js → chunk-GNK2IHVG.js} +15 -15
- package/node_modules/pi-lens/dist/{chunk-CXQYK4YT.js → chunk-H6DNTQ4V.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-NGNBJIUO.js → chunk-HERQPNY6.js} +8 -8
- package/node_modules/pi-lens/dist/{chunk-INBK3HIT.js → chunk-HFIFEH46.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-J2ZB5MDS.js → chunk-HKRESBMC.js} +20 -20
- package/node_modules/pi-lens/dist/{chunk-AZG5UJYY.js → chunk-HMXWZUQW.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-XSC3BCN3.js → chunk-HOWHAKXO.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-7CLWC2UH.js → chunk-HUWW77QY.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-KZ732ZVW.js → chunk-IO6P3NBP.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-7WKVCZI4.js → chunk-J7VNGHLN.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-QE7BJQ6K.js → chunk-JGCBMCCS.js} +8 -8
- package/node_modules/pi-lens/dist/{chunk-PFJLYRO3.js → chunk-KIQSNH3F.js} +34 -34
- package/node_modules/pi-lens/dist/{chunk-JGUDT5KD.js → chunk-KSQJBGRO.js} +5 -5
- package/node_modules/pi-lens/dist/{chunk-RJ3APNIP.js → chunk-KXKM2DFP.js} +4 -4
- package/node_modules/pi-lens/dist/chunk-L3Q72QGQ.js +25 -0
- package/node_modules/pi-lens/dist/{chunk-6GLMMGCX.js → chunk-LDPY22FS.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-3PO4YYOX.js → chunk-M3QGXGY4.js} +3793 -3814
- package/node_modules/pi-lens/dist/{chunk-NNEQOC3U.js → chunk-MET776XM.js} +9 -7
- package/node_modules/pi-lens/dist/{chunk-X33QECRJ.js → chunk-MKQFSW2Q.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-7U36VQL6.js → chunk-MKW7ZUTT.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-PQF6YGYB.js → chunk-N2U644ZW.js} +4 -18
- package/node_modules/pi-lens/dist/{chunk-DI4AZZNY.js → chunk-NAACKIKT.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-O6LCSHHI.js → chunk-NHHS5T52.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-DCA2MXVQ.js → chunk-NIZKGBOU.js} +51 -27
- package/node_modules/pi-lens/dist/{chunk-PKWEBMCA.js → chunk-NNDZ7DOP.js} +194 -111
- package/node_modules/pi-lens/dist/{chunk-Q7J3JYJ2.js → chunk-NZ7NSKIW.js} +13 -13
- package/node_modules/pi-lens/dist/{chunk-S6MCMD27.js → chunk-OG3UCAHV.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-3QXFUP6T.js → chunk-OHTHVILU.js} +12 -12
- package/node_modules/pi-lens/dist/{chunk-NHA5K226.js → chunk-P7EV5ISR.js} +17 -2
- package/node_modules/pi-lens/dist/{chunk-L6BDRYUK.js → chunk-PVV27TOX.js} +5 -5
- package/node_modules/pi-lens/dist/{chunk-HIRBC72R.js → chunk-Q32RJDYC.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-QE5DJ7MX.js → chunk-Q4UQNTLB.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-SDYLT45T.js → chunk-QQGZY2BR.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-QMWKSYWB.js → chunk-S247BOH2.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-ARTYCUGF.js → chunk-S7KUDW73.js} +121 -18
- package/node_modules/pi-lens/dist/{chunk-6CFSDLHE.js → chunk-SJ2SR432.js} +17 -17
- package/node_modules/pi-lens/dist/{chunk-CQY2HEH7.js → chunk-SL4G67AP.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-LVLPA32Q.js → chunk-T2D2WWP6.js} +48 -11
- package/node_modules/pi-lens/dist/{chunk-HIJ4CHFF.js → chunk-T7KHGEJ5.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-74AMPWNC.js → chunk-TABDCX35.js} +2 -2
- package/node_modules/pi-lens/dist/chunk-TFSBHRL2.js +25 -0
- package/node_modules/pi-lens/dist/{chunk-KNJH6WJQ.js → chunk-TQKWR5AZ.js} +7 -7
- package/node_modules/pi-lens/dist/chunk-TWAQFMLW.js +110 -0
- package/node_modules/pi-lens/dist/{chunk-TKOFTLGB.js → chunk-UARVPNAU.js} +33 -33
- package/node_modules/pi-lens/dist/chunk-UWBD3JMH.js +56 -0
- package/node_modules/pi-lens/dist/{chunk-K4Z7MK6T.js → chunk-VEF3GFOL.js} +15 -15
- package/node_modules/pi-lens/dist/{chunk-4DAHGU3V.js → chunk-W2JPGW7Q.js} +27 -25
- package/node_modules/pi-lens/dist/{chunk-CZJGAOKL.js → chunk-W2YHHNY3.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-R4L7KZ7R.js → chunk-WA6U2URH.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-OZQQ3AIR.js → chunk-WAK2AXQQ.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-DFKOA74L.js → chunk-WH6O4IFD.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-27JQHK7Y.js → chunk-WJ7GY5WJ.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-KXGTLAUW.js → chunk-WWZLT6AM.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-O2MHF7QM.js → chunk-XRLZ75YY.js} +38 -38
- package/node_modules/pi-lens/dist/chunk-XWWFESYZ.js +27 -0
- package/node_modules/pi-lens/dist/chunk-XZSXSM4K.js +27 -0
- package/node_modules/pi-lens/dist/{chunk-C5PLBTNR.js → chunk-Y2LIOCA7.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-AXAR5ZW2.js → chunk-YIEHUKX2.js} +84 -169
- package/node_modules/pi-lens/dist/{chunk-B2OXE4AH.js → chunk-YOMLAKU6.js} +182 -180
- package/node_modules/pi-lens/dist/{chunk-MOAVEPC4.js → chunk-YV7XVYSJ.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-ZULZS2I6.js → chunk-ZVQUYCBU.js} +996 -365
- package/node_modules/pi-lens/dist/index.js +4911 -2376
- package/node_modules/pi-lens/dist/mcp/analyze-cli.js +8 -8
- package/node_modules/pi-lens/dist/mcp/cli.js +40 -40
- package/node_modules/pi-lens/dist/mcp/server.js +321 -234
- package/node_modules/pi-lens/dist/mcp/worker.js +58 -58
- package/node_modules/pi-lens/dist/probes/installer.js +21 -21
- package/node_modules/pi-lens/docs/ci-bot-pr-checks.md +18 -9
- package/node_modules/pi-lens/docs/ci.md +7 -0
- package/node_modules/pi-lens/docs/defect-shapes.md +43 -28
- package/node_modules/pi-lens/docs/globalconfig.md +1 -0
- package/node_modules/pi-lens/docs/invariants/dispatch-runners.md +15 -0
- package/node_modules/pi-lens/docs/lsp-capability-matrix.md +3 -3
- package/node_modules/pi-lens/docs/lsp-idle-eviction.md +3 -2
- package/node_modules/pi-lens/docs/module-report-read-symbol.md +6 -2
- package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +3 -2
- package/node_modules/pi-lens/docs/pi-lens-orchestration.md +2 -1
- package/node_modules/pi-lens/docs/pi-lens-subagent.md +2 -1
- package/node_modules/pi-lens/docs/servercapabilities.md +1 -1
- package/node_modules/pi-lens/docs/settings.md +1 -0
- package/node_modules/pi-lens/docs/usage.md +1 -0
- package/node_modules/pi-lens/package.json +1 -1
- package/package.json +7 -5
- package/node_modules/pi-lens/dist/chunk-2H7NFZ4Q.js +0 -25
- package/node_modules/pi-lens/dist/chunk-5YJXF2IS.js +0 -56
- package/node_modules/pi-lens/dist/chunk-GCSDF5IE.js +0 -27
- package/node_modules/pi-lens/dist/chunk-H5API74E.js +0 -67
- package/node_modules/pi-lens/dist/chunk-HBX55MWO.js +0 -27
- package/node_modules/pi-lens/dist/chunk-JOIKBUQN.js +0 -88
- package/node_modules/pi-lens/dist/chunk-M2YMBT5G.js +0 -73
- package/node_modules/pi-lens/dist/chunk-MJRGPEQ5.js +0 -25
- package/node_modules/pi-lens/dist/chunk-TFKN5EIR.js +0 -27
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* progress.ts — the workflow progress model,
|
|
2
|
+
* progress.ts — the workflow progress model, aiming for compatibility with Claude Code's.
|
|
3
3
|
*
|
|
4
|
-
* Progress is an **
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* Progress is an **event log**, not a tree. Agent entries are keyed by `index`
|
|
5
|
+
* and last-write-wins, so a running agent is updated by emitting a fresh entry
|
|
6
|
+
* with the same index rather than mutating anything. The task's copy keeps only
|
|
7
|
+
* each agent's latest entry, in place (`updateWorkflowProgressBatch`). Every
|
|
8
|
+
* view — the inline card, the workflows dialog, the fleet widget — derives its
|
|
9
|
+
* shape by collapsing that log. Keeping the log authoritative is what lets a batched
|
|
9
10
|
* update carry several agents' changes in one message from the worker.
|
|
10
11
|
*
|
|
11
12
|
* Two vocabularies, deliberately distinct:
|
|
@@ -347,7 +348,14 @@ export function buildPhaseGroups(
|
|
|
347
348
|
progress: readonly WorkflowEntry[],
|
|
348
349
|
declared?: readonly WorkflowPhaseMeta[],
|
|
349
350
|
): PhaseGroup[] {
|
|
350
|
-
|
|
351
|
+
return phaseGroupsOf(collapse(progress), declared)
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/** {@link buildPhaseGroups} over a log the caller has already collapsed. */
|
|
355
|
+
export function phaseGroupsOf(
|
|
356
|
+
{ agents, phaseTitles }: CollapsedProgress,
|
|
357
|
+
declared?: readonly WorkflowPhaseMeta[],
|
|
358
|
+
): PhaseGroup[] {
|
|
351
359
|
const observed = groupByPhase(agents, phaseTitles) ?? []
|
|
352
360
|
const merged = mergePhases(declared, observed)
|
|
353
361
|
if (merged.length === 0 && agents.length > 0) {
|
|
@@ -379,8 +387,8 @@ export function stats(
|
|
|
379
387
|
let started = 0
|
|
380
388
|
let anyLive = false
|
|
381
389
|
|
|
382
|
-
// The log
|
|
383
|
-
// only each agent's latest one describes it.
|
|
390
|
+
// The log can hold several entries per agent (one per transition, in the
|
|
391
|
+
// runtime's copy); only each agent's latest one describes it.
|
|
384
392
|
for (const entry of collapse(progress).agents) {
|
|
385
393
|
seen++
|
|
386
394
|
if (entry.state === "done") {
|
|
@@ -566,7 +574,7 @@ const GERUND_CANDIDATE = /^[A-Za-z]{3,12}$/
|
|
|
566
574
|
/**
|
|
567
575
|
* Render a phase title as an activity: `Scan` → `Scanning`.
|
|
568
576
|
*
|
|
569
|
-
* Only applied
|
|
577
|
+
* Only applied to the active-phase label, which reads as "what is happening now".
|
|
570
578
|
* Anything that is not a plain short word is left untouched.
|
|
571
579
|
*/
|
|
572
580
|
export function gerund(word: string): string {
|
|
@@ -604,7 +612,7 @@ const truncate = (text: string, width: number) =>
|
|
|
604
612
|
text.length <= width ? text : `${text.slice(0, Math.max(1, width - 1))}…`
|
|
605
613
|
|
|
606
614
|
/**
|
|
607
|
-
* The
|
|
615
|
+
* The "what is this run doing" label, shown on a run's FleetView row.
|
|
608
616
|
*
|
|
609
617
|
* One active phase shows its position; two concurrent phases are joined, since
|
|
610
618
|
* a barrier-free pipeline routinely has work in more than one at a time.
|
|
@@ -621,3 +629,25 @@ export function footerPhaseLabel(input: {
|
|
|
621
629
|
}
|
|
622
630
|
return titles.map((t) => truncate(t, FOOTER_TITLE_WIDTH)).join(" & ")
|
|
623
631
|
}
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* {@link footerPhaseLabel} for the phases that still have work outstanding:
|
|
635
|
+
* `Reviewing (2/3)`. Empty when the run has no phases — the single "Agents"
|
|
636
|
+
* group a phase-less run collapses into is not one.
|
|
637
|
+
*/
|
|
638
|
+
export function activePhaseLabel(
|
|
639
|
+
collapsed: CollapsedProgress,
|
|
640
|
+
declared?: readonly WorkflowPhaseMeta[],
|
|
641
|
+
): string {
|
|
642
|
+
if (!collapsed.agents.some((agent) => agent.phaseIndex != null)) return ""
|
|
643
|
+
const groups = phaseGroupsOf(collapsed, declared)
|
|
644
|
+
const active = groups.flatMap((group, i) =>
|
|
645
|
+
group.status === "running" ? [i] : [],
|
|
646
|
+
)
|
|
647
|
+
if (active.length === 0) return ""
|
|
648
|
+
return footerPhaseLabel({
|
|
649
|
+
titles: active.map((i) => groups[i].title),
|
|
650
|
+
positionStart: active[0] + 1,
|
|
651
|
+
totalPhases: groups.length,
|
|
652
|
+
})
|
|
653
|
+
}
|
|
@@ -71,6 +71,10 @@ export interface WorkflowSpawnRequest {
|
|
|
71
71
|
*/
|
|
72
72
|
effort?: string
|
|
73
73
|
isolation?: "worktree"
|
|
74
|
+
/** Tools denied to this child, on top of its agent type's own deny list. */
|
|
75
|
+
disallowedTools?: string[]
|
|
76
|
+
/** Absolute counters for this spawn/resume invocation, not per-event deltas. */
|
|
77
|
+
onProgress?(info: Pick<WorkflowSpawnResult, "tokens" | "toolCalls">): void
|
|
74
78
|
/**
|
|
75
79
|
* Called by the host once the child's EFFECTIVE configuration is known —
|
|
76
80
|
* which is when its session exists, not when the spawn resolves.
|
|
@@ -132,11 +136,12 @@ export interface WorkflowSpawnResult {
|
|
|
132
136
|
error?: string
|
|
133
137
|
/** The user dismissed it rather than it failing; renders as skipped. */
|
|
134
138
|
skipped?: boolean
|
|
139
|
+
/** Display total for this spawn/resume invocation, excluding earlier turns. */
|
|
135
140
|
tokens?: number
|
|
136
141
|
/**
|
|
137
142
|
* Output tokens only, for the script's `budget.spent()`.
|
|
138
143
|
*
|
|
139
|
-
* Separate from {@link tokens}, which
|
|
144
|
+
* Separate from {@link tokens}, which includes input. Claude Code's
|
|
140
145
|
* budget counts output, and a fan-out's re-sent input would swamp it.
|
|
141
146
|
*/
|
|
142
147
|
outputTokens?: number
|
|
@@ -209,6 +214,7 @@ export interface WorkflowHost {
|
|
|
209
214
|
* the row above it shows the one that ran.
|
|
210
215
|
*/
|
|
211
216
|
onResolved?: WorkflowSpawnRequest["onResolved"],
|
|
217
|
+
onProgress?: WorkflowSpawnRequest["onProgress"],
|
|
212
218
|
): Promise<WorkflowSpawnResult>
|
|
213
219
|
/**
|
|
214
220
|
* Run a `gate` command and report whether it passed.
|
|
@@ -325,14 +331,28 @@ export interface WorkflowRunResult {
|
|
|
325
331
|
/** The script's return value, JSON-checked at the boundary. */
|
|
326
332
|
value?: unknown
|
|
327
333
|
error?: string
|
|
328
|
-
/**
|
|
334
|
+
/**
|
|
335
|
+
* Every transition, in emission order: one entry each time an agent is
|
|
336
|
+
* queued, started, resolved or settled. Live counter reports go to
|
|
337
|
+
* `onProgress` only; the settled entry carries the final counters.
|
|
338
|
+
*/
|
|
329
339
|
progress: WorkflowEntry[]
|
|
330
340
|
/** Agents scheduled, including those that failed. */
|
|
331
341
|
agentCount: number
|
|
332
342
|
/** How many of those came back from the journal instead of being spawned. */
|
|
333
343
|
replayedCount: number
|
|
344
|
+
/**
|
|
345
|
+
* One line per failure, in settle order: `[label] failed: reason` for an
|
|
346
|
+
* agent, `parallel[i] failed: …` / `pipeline[i] failed: …` for a slot that
|
|
347
|
+
* dropped to null. Skips are not failures. Reported in the completion
|
|
348
|
+
* notification's `<failures>`, as Claude Code's is.
|
|
349
|
+
*/
|
|
350
|
+
failures: string[]
|
|
334
351
|
}
|
|
335
352
|
|
|
353
|
+
/** Cap on a failure reason, the same in the journal and in `agentError()`. */
|
|
354
|
+
const FAILURE_REASON_CAP = 500
|
|
355
|
+
|
|
336
356
|
/* ------------------------------------------------------------------------- *
|
|
337
357
|
* JSON boundary — host side
|
|
338
358
|
* ------------------------------------------------------------------------- */
|
|
@@ -455,11 +475,14 @@ interface AgentCallPayload {
|
|
|
455
475
|
effort?: string
|
|
456
476
|
/** Raw JSON Schema from `agent({ schema })`, compiled before anything spawns. */
|
|
457
477
|
schema?: unknown
|
|
478
|
+
/** Deduped and sorted worker-side; absent when the script passed none or `[]`. */
|
|
479
|
+
disallowedTools?: string[]
|
|
458
480
|
}
|
|
459
481
|
|
|
460
482
|
type WorkerMessage =
|
|
461
483
|
| { type: "call"; callId: number; method: string; payload: AgentCallPayload }
|
|
462
484
|
| { type: "progress"; entries: WorkflowEntry[] }
|
|
485
|
+
| { type: "failure"; message: string }
|
|
463
486
|
| { type: "complete"; resultJson?: string }
|
|
464
487
|
| { type: "error"; message: string; stack?: string }
|
|
465
488
|
|
|
@@ -630,6 +653,7 @@ export async function runWorkflow(
|
|
|
630
653
|
* realm, which §2.4 rules out, and reading stack traces, which is brittle.
|
|
631
654
|
*/
|
|
632
655
|
const openLaunches = new Map<number, string>()
|
|
656
|
+
const failures: string[] = []
|
|
633
657
|
let agentCount = 0
|
|
634
658
|
let aborted = false
|
|
635
659
|
let settled = false
|
|
@@ -780,6 +804,10 @@ export async function runWorkflow(
|
|
|
780
804
|
error?: string,
|
|
781
805
|
fatal?: boolean,
|
|
782
806
|
) => {
|
|
807
|
+
// An agent call's label rides along so the worker can keep
|
|
808
|
+
// `agentError(label)` current: set by a null with a reason, cleared by
|
|
809
|
+
// anything else.
|
|
810
|
+
const agentLabel = openLaunches.get(callId)
|
|
783
811
|
// Cleared before the settled check: a launch answered by a run that is
|
|
784
812
|
// already finishing is not an unawaited launch either.
|
|
785
813
|
openLaunches.delete(callId)
|
|
@@ -793,6 +821,7 @@ export async function runWorkflow(
|
|
|
793
821
|
value,
|
|
794
822
|
error,
|
|
795
823
|
fatal,
|
|
824
|
+
agentLabel,
|
|
796
825
|
spent: spentOutputTokens,
|
|
797
826
|
})
|
|
798
827
|
}
|
|
@@ -800,7 +829,7 @@ export async function runWorkflow(
|
|
|
800
829
|
const finish = (
|
|
801
830
|
result: Omit<
|
|
802
831
|
WorkflowRunResult,
|
|
803
|
-
"meta" | "progress" | "agentCount" | "replayedCount"
|
|
832
|
+
"meta" | "progress" | "agentCount" | "replayedCount" | "failures"
|
|
804
833
|
>,
|
|
805
834
|
) => {
|
|
806
835
|
if (settled) return
|
|
@@ -817,7 +846,14 @@ export async function runWorkflow(
|
|
|
817
846
|
// Resolve only once the thread is actually down, so a caller that awaits
|
|
818
847
|
// runWorkflow() is guaranteed not to be leaking one.
|
|
819
848
|
const settle = () =>
|
|
820
|
-
resolve({
|
|
849
|
+
resolve({
|
|
850
|
+
...result,
|
|
851
|
+
meta,
|
|
852
|
+
progress,
|
|
853
|
+
agentCount,
|
|
854
|
+
replayedCount,
|
|
855
|
+
failures,
|
|
856
|
+
})
|
|
821
857
|
void worker.terminate().then(settle, settle)
|
|
822
858
|
}
|
|
823
859
|
|
|
@@ -1005,7 +1041,6 @@ export async function runWorkflow(
|
|
|
1005
1041
|
resultPreview: preview(replayedText),
|
|
1006
1042
|
},
|
|
1007
1043
|
])
|
|
1008
|
-
openLaunches.delete(callId)
|
|
1009
1044
|
// Re-recorded so this run's journal is complete on its own terms: a
|
|
1010
1045
|
// resume of a resume must not have to walk back through a chain of
|
|
1011
1046
|
// earlier files to find the prefix.
|
|
@@ -1025,20 +1060,15 @@ export async function runWorkflow(
|
|
|
1025
1060
|
|
|
1026
1061
|
/** A skip the user asked for, before the child ever started. */
|
|
1027
1062
|
const settleSkipped = (extra: Partial<WorkflowAgentEntry>) => {
|
|
1028
|
-
|
|
1063
|
+
const error = "Skipped by user."
|
|
1064
|
+
recordJournal?.({ index, key, ok: false, error, ...resumeMark })
|
|
1029
1065
|
emit([
|
|
1030
|
-
{
|
|
1031
|
-
...base,
|
|
1032
|
-
queuedAt,
|
|
1033
|
-
...extra,
|
|
1034
|
-
state: "error",
|
|
1035
|
-
skipped: true,
|
|
1036
|
-
error: "Skipped by user.",
|
|
1037
|
-
},
|
|
1066
|
+
{ ...base, queuedAt, ...extra, state: "error", skipped: true, error },
|
|
1038
1067
|
])
|
|
1039
1068
|
// `null`, exactly as a terminal failure gives — a skipped agent is one
|
|
1040
|
-
// the script's `.filter(Boolean)` was already written to survive.
|
|
1041
|
-
|
|
1069
|
+
// the script's `.filter(Boolean)` was already written to survive. Not a
|
|
1070
|
+
// `failures` line: the user chose it.
|
|
1071
|
+
respond(callId, true, null, error)
|
|
1042
1072
|
}
|
|
1043
1073
|
|
|
1044
1074
|
// Registered for exactly as long as the call is unanswered, which is the
|
|
@@ -1091,6 +1121,37 @@ export async function runWorkflow(
|
|
|
1091
1121
|
|
|
1092
1122
|
const startedAt = Date.now()
|
|
1093
1123
|
emit([{ ...base, queuedAt, startedAt, ...attemptMark }])
|
|
1124
|
+
// One row covers every attempt. Reconcile snapshots against the previous
|
|
1125
|
+
// attempts, not the last live snapshot, so completion cannot count twice.
|
|
1126
|
+
const previousTokens = base.tokens ?? 0
|
|
1127
|
+
const previousToolCalls = base.toolCalls ?? 0
|
|
1128
|
+
const updateCounters: NonNullable<
|
|
1129
|
+
WorkflowSpawnRequest["onProgress"]
|
|
1130
|
+
> = (info) => {
|
|
1131
|
+
if (info.tokens !== undefined)
|
|
1132
|
+
base.tokens = previousTokens + info.tokens
|
|
1133
|
+
if (info.toolCalls !== undefined)
|
|
1134
|
+
base.toolCalls = previousToolCalls + info.toolCalls
|
|
1135
|
+
}
|
|
1136
|
+
let acceptingProgress = true
|
|
1137
|
+
const onProgress: WorkflowSpawnRequest["onProgress"] = (info) => {
|
|
1138
|
+
// agentId is reused by retries and resumes; an inflight id alone would
|
|
1139
|
+
// let an older callback overwrite the current attempt or revive a row.
|
|
1140
|
+
if (!acceptingProgress || settled) return
|
|
1141
|
+
updateCounters(info)
|
|
1142
|
+
// To the listener only, not `emit`: a report arrives on every
|
|
1143
|
+
// finished tool and message, and logging each would grow `progress`
|
|
1144
|
+
// by one entry. The settled entry carries the final counters.
|
|
1145
|
+
options.onProgress?.([
|
|
1146
|
+
{
|
|
1147
|
+
...base,
|
|
1148
|
+
queuedAt,
|
|
1149
|
+
startedAt,
|
|
1150
|
+
...attemptMark,
|
|
1151
|
+
lastProgressAt: Date.now(),
|
|
1152
|
+
},
|
|
1153
|
+
])
|
|
1154
|
+
}
|
|
1094
1155
|
|
|
1095
1156
|
// Mutates `base` rather than emitting a standalone patch: every later
|
|
1096
1157
|
// emit spreads it, so the settle path carries the effective values
|
|
@@ -1105,6 +1166,7 @@ export async function runWorkflow(
|
|
|
1105
1166
|
requestedThinking?: string
|
|
1106
1167
|
requestedModel?: string
|
|
1107
1168
|
}) => {
|
|
1169
|
+
if (!acceptingProgress || settled) return
|
|
1108
1170
|
if (info.recordId !== undefined) base.recordId = info.recordId
|
|
1109
1171
|
if (info.modelName !== undefined) base.model = info.modelName
|
|
1110
1172
|
if (info.modelId !== undefined) base.modelId = info.modelId
|
|
@@ -1113,12 +1175,6 @@ export async function runWorkflow(
|
|
|
1113
1175
|
base.requestedThinking = info.requestedThinking
|
|
1114
1176
|
if (info.requestedModel !== undefined)
|
|
1115
1177
|
base.requestedModel = info.requestedModel
|
|
1116
|
-
// `base.state` is still "start", so emitting after the row reached a
|
|
1117
|
-
// terminal state would revert it to running under last-write-wins.
|
|
1118
|
-
// Not reachable from this repo's host, which reports during startup
|
|
1119
|
-
// — but this is the host boundary, and every other promise it makes
|
|
1120
|
-
// is checked rather than trusted.
|
|
1121
|
-
if (!inflight.has(agentId)) return
|
|
1122
1178
|
emit([
|
|
1123
1179
|
{
|
|
1124
1180
|
...base,
|
|
@@ -1136,7 +1192,12 @@ export async function runWorkflow(
|
|
|
1136
1192
|
try {
|
|
1137
1193
|
result =
|
|
1138
1194
|
resumed !== undefined && resumeAgent !== undefined
|
|
1139
|
-
? await resumeAgent(
|
|
1195
|
+
? await resumeAgent(
|
|
1196
|
+
resumed.agentId,
|
|
1197
|
+
payload.prompt,
|
|
1198
|
+
onResolved,
|
|
1199
|
+
onProgress,
|
|
1200
|
+
)
|
|
1140
1201
|
: await host.spawnAgent({
|
|
1141
1202
|
agentId,
|
|
1142
1203
|
index,
|
|
@@ -1147,6 +1208,9 @@ export async function runWorkflow(
|
|
|
1147
1208
|
...(payload.effort !== undefined
|
|
1148
1209
|
? { effort: payload.effort }
|
|
1149
1210
|
: {}),
|
|
1211
|
+
...(payload.disallowedTools !== undefined
|
|
1212
|
+
? { disallowedTools: payload.disallowedTools }
|
|
1213
|
+
: {}),
|
|
1150
1214
|
...(compiledSchema !== undefined
|
|
1151
1215
|
? { schema: compiledSchema }
|
|
1152
1216
|
: {}),
|
|
@@ -1163,7 +1227,9 @@ export async function runWorkflow(
|
|
|
1163
1227
|
? { gate: payload.gate }
|
|
1164
1228
|
: {}),
|
|
1165
1229
|
onResolved,
|
|
1230
|
+
onProgress,
|
|
1166
1231
|
})
|
|
1232
|
+
updateCounters(result)
|
|
1167
1233
|
if (result.ok) {
|
|
1168
1234
|
// Recorded before the gate runs: the child itself finished, so it is
|
|
1169
1235
|
// resumable even when its gate rejects the work — "here is what the
|
|
@@ -1199,6 +1265,7 @@ export async function runWorkflow(
|
|
|
1199
1265
|
error: error instanceof Error ? error.message : String(error),
|
|
1200
1266
|
}
|
|
1201
1267
|
} finally {
|
|
1268
|
+
acceptingProgress = false
|
|
1202
1269
|
inflight.delete(agentId)
|
|
1203
1270
|
live.started = false
|
|
1204
1271
|
semaphore.release()
|
|
@@ -1206,6 +1273,10 @@ export async function runWorkflow(
|
|
|
1206
1273
|
|
|
1207
1274
|
if (settled) return
|
|
1208
1275
|
|
|
1276
|
+
// Budget stays output-only and settlement-based, including stopped
|
|
1277
|
+
// attempts: a retry cannot refund tokens the previous child spent.
|
|
1278
|
+
spentOutputTokens += result.outputTokens ?? 0
|
|
1279
|
+
|
|
1209
1280
|
// The stop that produced this result was ours, so run the same call
|
|
1210
1281
|
// again rather than reporting it. The script is still awaiting this
|
|
1211
1282
|
// `agent()`, which is the only reason a retry can mean anything.
|
|
@@ -1218,11 +1289,6 @@ export async function runWorkflow(
|
|
|
1218
1289
|
continue
|
|
1219
1290
|
}
|
|
1220
1291
|
|
|
1221
|
-
// Counted before the response is sent, so the very call that spent
|
|
1222
|
-
// them already sees them in `budget.spent()`. Failed and skipped
|
|
1223
|
-
// agents count too — they burned the tokens either way.
|
|
1224
|
-
spentOutputTokens += result.outputTokens ?? 0
|
|
1225
|
-
|
|
1226
1292
|
const finishedAt = Date.now()
|
|
1227
1293
|
const common = {
|
|
1228
1294
|
...base,
|
|
@@ -1231,10 +1297,6 @@ export async function runWorkflow(
|
|
|
1231
1297
|
...attemptMark,
|
|
1232
1298
|
lastProgressAt: finishedAt,
|
|
1233
1299
|
durationMs: finishedAt - startedAt,
|
|
1234
|
-
...(result.tokens !== undefined ? { tokens: result.tokens } : {}),
|
|
1235
|
-
...(result.toolCalls !== undefined
|
|
1236
|
-
? { toolCalls: result.toolCalls }
|
|
1237
|
-
: {}),
|
|
1238
1300
|
}
|
|
1239
1301
|
|
|
1240
1302
|
if (result.ok) {
|
|
@@ -1247,7 +1309,14 @@ export async function runWorkflow(
|
|
|
1247
1309
|
// Recorded as a failure rather than left out: a gap would be read as an
|
|
1248
1310
|
// unchanged prefix on the next resume, silently skipping the retry this
|
|
1249
1311
|
// whole mechanism exists to make cheap.
|
|
1250
|
-
|
|
1312
|
+
// The reason is capped: provider and gate text can be large, and the
|
|
1313
|
+
// same string goes to disk, to the script and to the notification.
|
|
1314
|
+
const error = (result.error ?? "Agent failed.").slice(
|
|
1315
|
+
0,
|
|
1316
|
+
FAILURE_REASON_CAP,
|
|
1317
|
+
)
|
|
1318
|
+
recordJournal?.({ index, key, ok: false, error, ...resumeMark })
|
|
1319
|
+
if (!result.skipped) failures.push(`[${label}] failed: ${error}`)
|
|
1251
1320
|
// A dead agent is a null in the script, not a thrown error: Claude Code
|
|
1252
1321
|
// scripts .filter(Boolean) rather than try/catch around every call.
|
|
1253
1322
|
emit([
|
|
@@ -1262,7 +1331,7 @@ export async function runWorkflow(
|
|
|
1262
1331
|
...(result.skipped ? { skipped: true } : {}),
|
|
1263
1332
|
},
|
|
1264
1333
|
])
|
|
1265
|
-
respond(callId, true, null)
|
|
1334
|
+
respond(callId, true, null, error)
|
|
1266
1335
|
return
|
|
1267
1336
|
}
|
|
1268
1337
|
} finally {
|
|
@@ -1333,6 +1402,9 @@ export async function runWorkflow(
|
|
|
1333
1402
|
case "progress":
|
|
1334
1403
|
emit(message.entries)
|
|
1335
1404
|
break
|
|
1405
|
+
case "failure":
|
|
1406
|
+
failures.push(message.message)
|
|
1407
|
+
break
|
|
1336
1408
|
case "call":
|
|
1337
1409
|
if (message.method === "workflow") {
|
|
1338
1410
|
void handleLoadWorkflow(
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
* Claude Code's `local_workflow` task so the fields line up with what the
|
|
9
9
|
* renderers already expect.
|
|
10
10
|
*
|
|
11
|
-
* The progress log
|
|
11
|
+
* The progress log holds each agent's latest entry, replaced in place, plus
|
|
12
|
+
* logs and phases in order, and collapses by index (see `progress.ts`),
|
|
12
13
|
* so every derived counter here is recomputed from the log rather than
|
|
13
14
|
* incremented as entries arrive — a re-emitted agent entry replaces its
|
|
14
15
|
* predecessor, and adding its tokens on top would double-count them.
|
|
@@ -19,6 +20,7 @@ import { escapeXml } from "../xml.js"
|
|
|
19
20
|
import type { WorkflowJournalEntry } from "./journal.js"
|
|
20
21
|
import type { WorkflowMeta } from "./meta.js"
|
|
21
22
|
import {
|
|
23
|
+
activePhaseLabel,
|
|
22
24
|
collapse,
|
|
23
25
|
elapsedMs,
|
|
24
26
|
stats,
|
|
@@ -66,8 +68,13 @@ export interface WorkflowTask {
|
|
|
66
68
|
/** How many agents came back from {@link replay} instead of being spawned. */
|
|
67
69
|
replayedCount: number
|
|
68
70
|
|
|
69
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* The event log, in first-emission order, holding each agent's latest entry
|
|
73
|
+
* only — see {@link updateWorkflowProgressBatch}. Logs and phases append.
|
|
74
|
+
*/
|
|
70
75
|
workflowProgress: WorkflowEntry[]
|
|
76
|
+
/** Agent index → its entry's position in {@link workflowProgress}. */
|
|
77
|
+
agentSlots: Map<number, number>
|
|
71
78
|
/** Bumped once per applied batch, so a renderer can tell nothing changed. */
|
|
72
79
|
progressVersion: number
|
|
73
80
|
agentCount: number
|
|
@@ -75,10 +82,12 @@ export interface WorkflowTask {
|
|
|
75
82
|
* Agents that have settled successfully, recomputed with the other counters.
|
|
76
83
|
*
|
|
77
84
|
* Cached rather than derived on read because the fleet list asks five times a
|
|
78
|
-
* second: deriving it there would walk the whole
|
|
85
|
+
* second: deriving it there would walk the whole progress log on every
|
|
79
86
|
* tick, which for a thousand-agent run is real work in the render loop.
|
|
80
87
|
*/
|
|
81
88
|
doneCount: number
|
|
89
|
+
/** `Reviewing (2/3)` — the phases with work outstanding, or "". Cached like {@link doneCount}. */
|
|
90
|
+
phaseLabel: string
|
|
82
91
|
totalTokens: number
|
|
83
92
|
totalToolCalls: number
|
|
84
93
|
logs: string[]
|
|
@@ -92,6 +101,8 @@ export interface WorkflowTask {
|
|
|
92
101
|
/** The script's return value, once the run produced one. */
|
|
93
102
|
value?: unknown
|
|
94
103
|
error?: string
|
|
104
|
+
/** The run's failure lines, for the notification's `<failures>`. */
|
|
105
|
+
failures?: string[]
|
|
95
106
|
}
|
|
96
107
|
|
|
97
108
|
export function createWorkflowTask(init: {
|
|
@@ -121,9 +132,11 @@ export function createWorkflowTask(init: {
|
|
|
121
132
|
resumedFrom: init.resumedFrom,
|
|
122
133
|
replayedCount: 0,
|
|
123
134
|
workflowProgress: [],
|
|
135
|
+
agentSlots: new Map(),
|
|
124
136
|
progressVersion: 0,
|
|
125
137
|
agentCount: 0,
|
|
126
138
|
doneCount: 0,
|
|
139
|
+
phaseLabel: "",
|
|
127
140
|
totalTokens: 0,
|
|
128
141
|
totalToolCalls: 0,
|
|
129
142
|
logs: [],
|
|
@@ -146,11 +159,30 @@ export function updateWorkflowProgressBatch(
|
|
|
146
159
|
entries: readonly WorkflowEntry[],
|
|
147
160
|
): void {
|
|
148
161
|
if (entries.length === 0) return
|
|
149
|
-
|
|
162
|
+
for (const entry of entries) {
|
|
163
|
+
// An agent's newer entry replaces its older one in place. Every reader goes
|
|
164
|
+
// through `collapse`, which keeps only the latest entry per index, so this
|
|
165
|
+
// loses nothing — and a running child's live counters, re-emitted on every
|
|
166
|
+
// tool and message, would otherwise grow the log (and the session entry it
|
|
167
|
+
// is persisted into) by one entry each.
|
|
168
|
+
const slot =
|
|
169
|
+
entry.type === "workflow_agent"
|
|
170
|
+
? task.agentSlots.get(entry.index)
|
|
171
|
+
: undefined
|
|
172
|
+
if (slot !== undefined) {
|
|
173
|
+
task.workflowProgress[slot] = entry
|
|
174
|
+
continue
|
|
175
|
+
}
|
|
176
|
+
if (entry.type === "workflow_agent")
|
|
177
|
+
task.agentSlots.set(entry.index, task.workflowProgress.length)
|
|
178
|
+
task.workflowProgress.push(entry)
|
|
179
|
+
}
|
|
150
180
|
task.progressVersion++
|
|
151
181
|
|
|
152
|
-
const
|
|
182
|
+
const collapsed = collapse(task.workflowProgress)
|
|
183
|
+
const { agents, logs } = collapsed
|
|
153
184
|
task.logs = logs
|
|
185
|
+
task.phaseLabel = activePhaseLabel(collapsed, task.meta?.phases)
|
|
154
186
|
// `agentCount` is what the runtime has scheduled, which can lead what the log
|
|
155
187
|
// has seen — never let a recompute walk it backwards.
|
|
156
188
|
task.agentCount = Math.max(task.agentCount, agents.length)
|
|
@@ -222,6 +254,7 @@ export function completeWorkflowTask(
|
|
|
222
254
|
task.replayedCount = result.replayedCount
|
|
223
255
|
task.value = result.value
|
|
224
256
|
task.error = result.error
|
|
257
|
+
task.failures = result.failures
|
|
225
258
|
task.endTime = Date.now()
|
|
226
259
|
}
|
|
227
260
|
|
|
@@ -325,6 +358,11 @@ export function formatWorkflowNotification(
|
|
|
325
358
|
: ""
|
|
326
359
|
}</summary>`,
|
|
327
360
|
`<result>${escapeXml(result.length > 4000 ? `${result.slice(0, 4000)}\n...(truncated)` : result)}</result>`,
|
|
361
|
+
// Compatible with Claude Code's: every failure line, capped, and absent
|
|
362
|
+
// when nothing failed.
|
|
363
|
+
task.failures?.length
|
|
364
|
+
? `<failures>${escapeXml(task.failures.join("\n").slice(0, 40_000))}</failures>`
|
|
365
|
+
: null,
|
|
328
366
|
`<usage><total_tokens>${task.totalTokens}</total_tokens><tool_uses>${task.totalToolCalls}</tool_uses><duration_ms>${elapsedMs(task, now)}</duration_ms></usage>`,
|
|
329
367
|
`</task-notification>`,
|
|
330
368
|
]
|