@aragon-agent/cli 0.6.57 → 0.6.58
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 +71 -0
- package/README.md +159 -3
- package/dist/agent/controller.d.ts +112 -1
- package/dist/agent/controller.js +350 -7
- package/dist/agent/project-guidance-prompt.js +97 -97
- package/dist/agent/redteam-prompt.d.ts +29 -11
- package/dist/agent/redteam-prompt.js +118 -103
- package/dist/agent/redteam-wiring.d.ts +117 -2
- package/dist/agent/redteam-wiring.js +204 -1
- package/dist/agent/team-notices.d.ts +68 -0
- package/dist/agent/team-notices.js +82 -0
- package/dist/app/App.js +208 -5
- package/dist/app/use-redteam-mode.d.ts +1 -1
- package/dist/app/use-redteam-mode.js +14 -1
- package/dist/cli.js +13 -0
- package/dist/commands/catalog.js +6 -2
- package/dist/commands/redteam-command.d.ts +14 -8
- package/dist/commands/redteam-command.js +243 -12
- package/dist/commands/team-command.js +93 -2
- package/dist/config/app-paths.d.ts +19 -0
- package/dist/config/app-paths.js +23 -0
- package/dist/config/load.d.ts +8 -0
- package/dist/gene/catalog-sync.js +37 -16
- package/dist/gene/curator/budget.js +1 -1
- package/dist/gene/curator/curator.d.ts +6 -0
- package/dist/gene/curator/curator.js +8 -0
- package/dist/gene/curator/task-runner.js +4 -1
- package/dist/gene/curator/tools-verify.js +17 -5
- package/dist/gene/curator/validate/evidence-tokens.js +97 -18
- package/dist/gene/curator/validate/knowledge.d.ts +5 -0
- package/dist/gene/curator/validate/knowledge.js +57 -13
- package/dist/gene/curator/validate/types.d.ts +6 -1
- package/dist/gene/learn/learn-prompt.d.ts +10 -1
- package/dist/gene/learn/learn-prompt.js +11 -2
- package/dist/governance/engine/lifecycle.js +1 -1
- package/dist/governance/store/run-lock.d.ts +9 -2
- package/dist/governance/store/run-lock.js +91 -7
- package/dist/host/controller-factory.d.ts +13 -0
- package/dist/host/controller-factory.js +7 -0
- package/dist/host/index.d.ts +1 -0
- package/dist/host/index.js +1 -0
- package/dist/host/interaction.d.ts +19 -0
- package/dist/host/interaction.js +75 -0
- package/dist/host/team-control.d.ts +83 -0
- package/dist/host/team-control.js +55 -0
- package/dist/logging/install.d.ts +32 -1
- package/dist/logging/install.js +21 -0
- package/dist/proc/output-streams.d.ts +11 -0
- package/dist/proc/output-streams.js +11 -0
- package/dist/redteam/prompt-resolve.d.ts +61 -0
- package/dist/redteam/prompt-resolve.js +303 -0
- package/dist/redteam/prompt-store.d.ts +96 -0
- package/dist/redteam/prompt-store.js +156 -0
- package/dist/redteam/prompt-template.d.ts +22 -0
- package/dist/redteam/prompt-template.js +72 -0
- package/dist/team/bus.d.ts +18 -0
- package/dist/team/bus.js +70 -18
- package/dist/team/console-tools.d.ts +54 -0
- package/dist/team/console-tools.js +333 -0
- package/dist/team/console-view.d.ts +88 -0
- package/dist/team/console-view.js +173 -0
- package/dist/team/forced-mode.d.ts +61 -1
- package/dist/team/forced-mode.js +75 -0
- package/dist/team/normalize.d.ts +31 -0
- package/dist/team/normalize.js +49 -5
- package/dist/team/notices.d.ts +95 -0
- package/dist/team/notices.js +121 -0
- package/dist/team/pause-gate.d.ts +79 -0
- package/dist/team/pause-gate.js +127 -0
- package/dist/team/prompt.d.ts +25 -9
- package/dist/team/prompt.js +29 -29
- package/dist/team/report.js +33 -0
- package/dist/team/runtime.d.ts +270 -5
- package/dist/team/runtime.js +732 -64
- package/dist/team/settled.d.ts +5 -2
- package/dist/team/settled.js +12 -2
- package/dist/team/subagent.d.ts +7 -0
- package/dist/team/subagent.js +12 -1
- package/dist/team/task-tool.d.ts +39 -1
- package/dist/team/task-tool.js +75 -18
- package/dist/tools/bash-tool.d.ts +11 -8
- package/dist/tools/bash-tool.js +37 -9
- package/dist/tools/index.d.ts +2 -2
- package/dist/tools/index.js +30 -0
- package/package.json +3 -3
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The cooperative pause gate for subagents (team-detached-dispatch section 5.2.4).
|
|
3
|
+
*
|
|
4
|
+
* ASCII ONLY: `src/team/**` is inside `glyphs.test.ts`'s static scan.
|
|
5
|
+
*
|
|
6
|
+
* "PAUSED" IS COOPERATIVE AND THE WORDING SAYS SO. There is no way to freeze a
|
|
7
|
+
* child mid-request: the only places a child can be held are (a) between two tool
|
|
8
|
+
* calls and (b) at the top of its own loop, before the next `prompt()`. This file
|
|
9
|
+
* owns (a), `TeamRuntime.runOne` owns (b). Anything that promises more - "frozen
|
|
10
|
+
* instantly" - is a promise the mechanism cannot keep, so `team_pause`'s result
|
|
11
|
+
* text is written to match this reality instead.
|
|
12
|
+
*
|
|
13
|
+
* WHY A SEPARATE FILE. `team/subagent.ts` is already 1 032 lines and
|
|
14
|
+
* `team/runtime.ts` 1 631 (both recorded in `.claude-index/config.md`); the gate
|
|
15
|
+
* is a self-contained little scheduler (a resolve queue per label), so it lives
|
|
16
|
+
* here and those two only wire it.
|
|
17
|
+
*
|
|
18
|
+
* THE GATE WRAPS *OUTSIDE* `withMailboxTail` (spec REV-12). The order matters
|
|
19
|
+
* twice over: a held child must not be handed a mailbox tail (that would be a
|
|
20
|
+
* delivery to an agent that is not running), and the existing wrapper stack
|
|
21
|
+
* (`withToolPolicy` / `withPlanModeGate` / `withMailboxTail`) keeps the order it
|
|
22
|
+
* was designed with.
|
|
23
|
+
*/
|
|
24
|
+
import type { AgentTool } from '@aragon-agent/core';
|
|
25
|
+
import type { TeamControlBy } from '@aragon-agent/tui/model/team/types';
|
|
26
|
+
/**
|
|
27
|
+
* One gate per dispatch: the pause state for every label plus the accounting the
|
|
28
|
+
* report and the child's own timeout budget need.
|
|
29
|
+
*/
|
|
30
|
+
export declare class PauseGate {
|
|
31
|
+
private readonly held;
|
|
32
|
+
/** Milliseconds spent held, closed out at each resume. */
|
|
33
|
+
private readonly total;
|
|
34
|
+
/** How many times each label was held. */
|
|
35
|
+
private readonly holds;
|
|
36
|
+
private readonly now;
|
|
37
|
+
constructor(now?: () => number);
|
|
38
|
+
/**
|
|
39
|
+
* Hold `label`. Idempotent: a second pause of an already held child only
|
|
40
|
+
* restates WHO holds it, so a supervisor's hold can be taken over by the lead
|
|
41
|
+
* without restarting the accounting.
|
|
42
|
+
*/
|
|
43
|
+
pause(label: string, by: TeamControlBy): boolean;
|
|
44
|
+
/** Release `label`, waking everything that waited on it. `false` when it was not held. */
|
|
45
|
+
resume(label: string): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Release everything. Used by abort and by dispose: a held child that nobody
|
|
48
|
+
* releases would leave a promise (and therefore a worker slot) dangling, and
|
|
49
|
+
* `finally` in the runtime could never run.
|
|
50
|
+
*/
|
|
51
|
+
releaseAll(): void;
|
|
52
|
+
isPaused(label: string): boolean;
|
|
53
|
+
/** Who holds it, for the status line and the run's `controlBy` fact. */
|
|
54
|
+
holderOf(label: string): TeamControlBy | undefined;
|
|
55
|
+
/** When the current hold started (epoch ms), or `undefined` when not held. */
|
|
56
|
+
pausedSince(label: string): number | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Total milliseconds `label` has spent held, INCLUDING the hold that is open
|
|
59
|
+
* right now. This is the number settlement credits back to the child's own
|
|
60
|
+
* `subagentTimeoutMs` - and the one it must never add to the dispatch ceiling.
|
|
61
|
+
*/
|
|
62
|
+
pausedMs(label: string): number;
|
|
63
|
+
/** How many times `label` was held. */
|
|
64
|
+
pauseCount(label: string): number;
|
|
65
|
+
/**
|
|
66
|
+
* Resolve when `label` may run. Resolves IMMEDIATELY when it is not held, which
|
|
67
|
+
* keeps an unpaused dispatch free of an extra await on the hot path.
|
|
68
|
+
*/
|
|
69
|
+
waitIfPaused(label: string): Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Wrap one tool so a held child cannot execute it.
|
|
73
|
+
*
|
|
74
|
+
* CHECKS THEN DELEGATES: arguments, results and errors are untouched, and on
|
|
75
|
+
* release the original `execute` runs exactly once with the arguments it was
|
|
76
|
+
* called with - so the model's tool-call id, and therefore the conversation,
|
|
77
|
+
* is unchanged.
|
|
78
|
+
*/
|
|
79
|
+
export declare function withPauseGate(tool: AgentTool, gate: PauseGate, label: string): AgentTool;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The cooperative pause gate for subagents (team-detached-dispatch section 5.2.4).
|
|
3
|
+
*
|
|
4
|
+
* ASCII ONLY: `src/team/**` is inside `glyphs.test.ts`'s static scan.
|
|
5
|
+
*
|
|
6
|
+
* "PAUSED" IS COOPERATIVE AND THE WORDING SAYS SO. There is no way to freeze a
|
|
7
|
+
* child mid-request: the only places a child can be held are (a) between two tool
|
|
8
|
+
* calls and (b) at the top of its own loop, before the next `prompt()`. This file
|
|
9
|
+
* owns (a), `TeamRuntime.runOne` owns (b). Anything that promises more - "frozen
|
|
10
|
+
* instantly" - is a promise the mechanism cannot keep, so `team_pause`'s result
|
|
11
|
+
* text is written to match this reality instead.
|
|
12
|
+
*
|
|
13
|
+
* WHY A SEPARATE FILE. `team/subagent.ts` is already 1 032 lines and
|
|
14
|
+
* `team/runtime.ts` 1 631 (both recorded in `.claude-index/config.md`); the gate
|
|
15
|
+
* is a self-contained little scheduler (a resolve queue per label), so it lives
|
|
16
|
+
* here and those two only wire it.
|
|
17
|
+
*
|
|
18
|
+
* THE GATE WRAPS *OUTSIDE* `withMailboxTail` (spec REV-12). The order matters
|
|
19
|
+
* twice over: a held child must not be handed a mailbox tail (that would be a
|
|
20
|
+
* delivery to an agent that is not running), and the existing wrapper stack
|
|
21
|
+
* (`withToolPolicy` / `withPlanModeGate` / `withMailboxTail`) keeps the order it
|
|
22
|
+
* was designed with.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* One gate per dispatch: the pause state for every label plus the accounting the
|
|
26
|
+
* report and the child's own timeout budget need.
|
|
27
|
+
*/
|
|
28
|
+
export class PauseGate {
|
|
29
|
+
held = new Map();
|
|
30
|
+
/** Milliseconds spent held, closed out at each resume. */
|
|
31
|
+
total = new Map();
|
|
32
|
+
/** How many times each label was held. */
|
|
33
|
+
holds = new Map();
|
|
34
|
+
now;
|
|
35
|
+
constructor(now = () => Date.now()) {
|
|
36
|
+
this.now = now;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Hold `label`. Idempotent: a second pause of an already held child only
|
|
40
|
+
* restates WHO holds it, so a supervisor's hold can be taken over by the lead
|
|
41
|
+
* without restarting the accounting.
|
|
42
|
+
*/
|
|
43
|
+
pause(label, by) {
|
|
44
|
+
const existing = this.held.get(label);
|
|
45
|
+
if (existing !== undefined) {
|
|
46
|
+
existing.by = by;
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
this.held.set(label, { by, since: this.now(), waiters: [] });
|
|
50
|
+
this.holds.set(label, (this.holds.get(label) ?? 0) + 1);
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
/** Release `label`, waking everything that waited on it. `false` when it was not held. */
|
|
54
|
+
resume(label) {
|
|
55
|
+
const held = this.held.get(label);
|
|
56
|
+
if (held === undefined)
|
|
57
|
+
return false;
|
|
58
|
+
this.total.set(label, this.pausedMs(label));
|
|
59
|
+
this.held.delete(label);
|
|
60
|
+
for (const wake of held.waiters.splice(0, held.waiters.length))
|
|
61
|
+
wake();
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Release everything. Used by abort and by dispose: a held child that nobody
|
|
66
|
+
* releases would leave a promise (and therefore a worker slot) dangling, and
|
|
67
|
+
* `finally` in the runtime could never run.
|
|
68
|
+
*/
|
|
69
|
+
releaseAll() {
|
|
70
|
+
for (const label of [...this.held.keys()])
|
|
71
|
+
this.resume(label);
|
|
72
|
+
}
|
|
73
|
+
isPaused(label) {
|
|
74
|
+
return this.held.has(label);
|
|
75
|
+
}
|
|
76
|
+
/** Who holds it, for the status line and the run's `controlBy` fact. */
|
|
77
|
+
holderOf(label) {
|
|
78
|
+
return this.held.get(label)?.by;
|
|
79
|
+
}
|
|
80
|
+
/** When the current hold started (epoch ms), or `undefined` when not held. */
|
|
81
|
+
pausedSince(label) {
|
|
82
|
+
return this.held.get(label)?.since;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Total milliseconds `label` has spent held, INCLUDING the hold that is open
|
|
86
|
+
* right now. This is the number settlement credits back to the child's own
|
|
87
|
+
* `subagentTimeoutMs` - and the one it must never add to the dispatch ceiling.
|
|
88
|
+
*/
|
|
89
|
+
pausedMs(label) {
|
|
90
|
+
const closed = this.total.get(label) ?? 0;
|
|
91
|
+
const held = this.held.get(label);
|
|
92
|
+
return held === undefined ? closed : closed + (this.now() - held.since);
|
|
93
|
+
}
|
|
94
|
+
/** How many times `label` was held. */
|
|
95
|
+
pauseCount(label) {
|
|
96
|
+
return this.holds.get(label) ?? 0;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Resolve when `label` may run. Resolves IMMEDIATELY when it is not held, which
|
|
100
|
+
* keeps an unpaused dispatch free of an extra await on the hot path.
|
|
101
|
+
*/
|
|
102
|
+
waitIfPaused(label) {
|
|
103
|
+
const held = this.held.get(label);
|
|
104
|
+
if (held === undefined)
|
|
105
|
+
return Promise.resolve();
|
|
106
|
+
return new Promise((resolve) => {
|
|
107
|
+
held.waiters.push(resolve);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Wrap one tool so a held child cannot execute it.
|
|
113
|
+
*
|
|
114
|
+
* CHECKS THEN DELEGATES: arguments, results and errors are untouched, and on
|
|
115
|
+
* release the original `execute` runs exactly once with the arguments it was
|
|
116
|
+
* called with - so the model's tool-call id, and therefore the conversation,
|
|
117
|
+
* is unchanged.
|
|
118
|
+
*/
|
|
119
|
+
export function withPauseGate(tool, gate, label) {
|
|
120
|
+
return {
|
|
121
|
+
...tool,
|
|
122
|
+
async execute(id, params, ctx) {
|
|
123
|
+
await gate.waitIfPaused(label);
|
|
124
|
+
return tool.execute(id, params, ctx);
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
package/dist/team/prompt.d.ts
CHANGED
|
@@ -18,19 +18,35 @@ export { TEAM_BLOCK_VERSION };
|
|
|
18
18
|
export interface TeamBlockParams {
|
|
19
19
|
maxSubagents: number;
|
|
20
20
|
maxConcurrent: number;
|
|
21
|
+
/**
|
|
22
|
+
* Whether a dispatch outlives the `task` call (`team.detachDispatch`).
|
|
23
|
+
*
|
|
24
|
+
* THE ONLY CONDITIONAL IN THIS BLOCK, AND IT IS THE ONE THAT CARRIES I-DD8: with
|
|
25
|
+
* the key false the only paragraph that differs is the one describing a free lead,
|
|
26
|
+
* which would be a lie in a session where `task` still blocks. The rest of the
|
|
27
|
+
* block is the compressed text below - byte-identical between the two modes, and
|
|
28
|
+
* NOT byte-identical to v3: the compression the 1 200-character budget forced
|
|
29
|
+
* applies to both (spec 'implementation findings', IF-14).
|
|
30
|
+
* `task`'s own description is NOT conditional (it cannot be: the tool array is
|
|
31
|
+
* frozen at construction), which is why the detach contract lives here.
|
|
32
|
+
*/
|
|
33
|
+
detachDispatch?: boolean;
|
|
21
34
|
}
|
|
22
35
|
/**
|
|
23
|
-
* The lead's `<team_mode>` block.
|
|
24
|
-
*
|
|
25
|
-
*
|
|
36
|
+
* The lead's `<team_mode>` block.
|
|
37
|
+
*
|
|
38
|
+
* UNDER 1200 CHARACTERS, AND NOW ASSERTED BY A TEST (`team-prompt.test.ts`), which
|
|
39
|
+
* is a change of kind rather than of number: v3 measured 1 204 and the budget had
|
|
40
|
+
* never been enforced, so every later addition was free money. The detach
|
|
41
|
+
* paragraph costs ~600 characters, so the prose below was compressed by more than
|
|
42
|
+
* that rather than by "roughly enough": what went is everything that repeated
|
|
43
|
+
* `task`'s own description (the whole "do not delegate when" list, the second
|
|
44
|
+
* "cannot ask the user anything", the duplicate "one combined report" sentence)
|
|
45
|
+
* and the second copy of a maximum that is already in the first line.
|
|
26
46
|
*
|
|
27
47
|
* "Two to four is usually enough" is where the requirement's "shu liang zi shi
|
|
28
|
-
* ying" (adaptive count) actually lives
|
|
29
|
-
* elsewhere
|
|
30
|
-
* the model's, and this paragraph is the only thing that informs it. It names a
|
|
31
|
-
* USUAL size rather than the maximum on purpose: the default fan-out moved to 8
|
|
32
|
-
* (subagent-fanout D-1), and a block that told the model "eight is normal"
|
|
33
|
-
* would turn every two-part job into an eight-agent bill.
|
|
48
|
+
* ying" (adaptive count) actually lives: the ceiling is mechanical and enforced
|
|
49
|
+
* elsewhere, this paragraph is the only thing that informs the CHOICE.
|
|
34
50
|
*/
|
|
35
51
|
export declare function buildTeamBlock(params: TeamBlockParams): string;
|
|
36
52
|
export interface SubagentBlockParams {
|
package/dist/team/prompt.js
CHANGED
|
@@ -16,46 +16,46 @@
|
|
|
16
16
|
import { TEAM_BLOCK_VERSION, TEAM_LIMITS } from '@aragon-agent/tui/model/team/limits';
|
|
17
17
|
export { TEAM_BLOCK_VERSION };
|
|
18
18
|
/**
|
|
19
|
-
* The lead's `<team_mode>` block.
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* The lead's `<team_mode>` block.
|
|
20
|
+
*
|
|
21
|
+
* UNDER 1200 CHARACTERS, AND NOW ASSERTED BY A TEST (`team-prompt.test.ts`), which
|
|
22
|
+
* is a change of kind rather than of number: v3 measured 1 204 and the budget had
|
|
23
|
+
* never been enforced, so every later addition was free money. The detach
|
|
24
|
+
* paragraph costs ~600 characters, so the prose below was compressed by more than
|
|
25
|
+
* that rather than by "roughly enough": what went is everything that repeated
|
|
26
|
+
* `task`'s own description (the whole "do not delegate when" list, the second
|
|
27
|
+
* "cannot ask the user anything", the duplicate "one combined report" sentence)
|
|
28
|
+
* and the second copy of a maximum that is already in the first line.
|
|
22
29
|
*
|
|
23
30
|
* "Two to four is usually enough" is where the requirement's "shu liang zi shi
|
|
24
|
-
* ying" (adaptive count) actually lives
|
|
25
|
-
* elsewhere
|
|
26
|
-
* the model's, and this paragraph is the only thing that informs it. It names a
|
|
27
|
-
* USUAL size rather than the maximum on purpose: the default fan-out moved to 8
|
|
28
|
-
* (subagent-fanout D-1), and a block that told the model "eight is normal"
|
|
29
|
-
* would turn every two-part job into an eight-agent bill.
|
|
31
|
+
* ying" (adaptive count) actually lives: the ceiling is mechanical and enforced
|
|
32
|
+
* elsewhere, this paragraph is the only thing that informs the CHOICE.
|
|
30
33
|
*/
|
|
31
34
|
export function buildTeamBlock(params) {
|
|
32
35
|
const max = Math.max(1, Math.floor(params.maxSubagents));
|
|
33
36
|
const concurrent = Math.max(1, Math.min(Math.floor(params.maxConcurrent), max));
|
|
34
|
-
|
|
37
|
+
const lines = [
|
|
35
38
|
'<team_mode>',
|
|
36
39
|
`You can delegate to parallel subagents with the task tool (up to ${max} per`,
|
|
37
40
|
`call, ${concurrent} running at once).`,
|
|
38
41
|
'',
|
|
39
|
-
'Delegate when
|
|
40
|
-
'
|
|
41
|
-
'
|
|
42
|
-
'',
|
|
43
|
-
'Do not delegate when: one part needs another part\'s result (do those in order',
|
|
44
|
-
'yourself); two parts would edit the same file; the whole job is a few edits.',
|
|
45
|
-
'One well-scoped subagent is better than four vague ones. Two to four is',
|
|
46
|
-
'usually enough; go wider only when the parts are genuinely independent - a',
|
|
47
|
-
'narrow fan-out is cheaper and easier to read.',
|
|
42
|
+
'Delegate when the work splits into 2+ parts that need no other\'s output, when',
|
|
43
|
+
'several areas must be read at once, or when a long build can run beside other',
|
|
44
|
+
'work. Two to four is usually enough; a narrow fan-out is cheaper to read.',
|
|
48
45
|
'',
|
|
49
|
-
'Each subagent starts with no memory of this conversation
|
|
50
|
-
'
|
|
51
|
-
'
|
|
52
|
-
'
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
'
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
46
|
+
'Each subagent starts with no memory of this conversation: its prompt must carry',
|
|
47
|
+
'the goal, the files it owns, and what to report back. Give each a disjoint set',
|
|
48
|
+
'of files to write. Each runs on the model configured for subagents (usually',
|
|
49
|
+
'yours), and none may delegate further.',
|
|
50
|
+
];
|
|
51
|
+
if (params.detachDispatch === true) {
|
|
52
|
+
lines.push('', 'While a dispatch runs you are FREE, not waiting: a new user message is your', 'own turn - answer it, do not route it to the team. team_status shows the', 'roster and partial results; team_message corrects a child; team_pause /', 'team_resume hold one; team_stop ends one; team_spawn adds one; team_collect', 'only when you cannot answer without results. If the user changes the goal', 'mid-flight, propagate it with team_message (and pause what no longer matters)', 'before you answer. The report arrives when the team finishes; summarise it', 'then, in your own words.');
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
lines.push('', 'You get one combined report when they all finish. Read it before deciding', 'what to do next, and tell the user what the team found in your own words.');
|
|
56
|
+
}
|
|
57
|
+
lines.push('</team_mode>');
|
|
58
|
+
return lines.join('\n');
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
61
|
* The child's `<subagent_role>` block.
|
package/dist/team/report.js
CHANGED
|
@@ -253,6 +253,36 @@ function buildLeadMail(outcome) {
|
|
|
253
253
|
}
|
|
254
254
|
return lines;
|
|
255
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* The Control section (team-detached-dispatch section 6.3 / I-DD5).
|
|
258
|
+
*
|
|
259
|
+
* WHY IT IS PART OF THE REPORT AND NOT A SEPARATE LOG. Once a dispatch can be
|
|
260
|
+
* paused, steered and stopped by the lead or the user, the report's reader needs
|
|
261
|
+
* to know that before reading a "failed after 8 minutes" row - otherwise "it was
|
|
262
|
+
* stopped on purpose" and "it broke" look identical in the one artefact people
|
|
263
|
+
* actually read afterwards. Every row names its AUTHOR.
|
|
264
|
+
*
|
|
265
|
+
* HELD TIME is summarised per child, because a paused child's elapsed time and its
|
|
266
|
+
* working time are different numbers and only the second one explains anything.
|
|
267
|
+
*/
|
|
268
|
+
function buildControl(outcome) {
|
|
269
|
+
const controlled = (outcome.interventions ?? []).filter((item) => item.trigger === 'lead' || item.trigger === 'user');
|
|
270
|
+
const held = outcome.runs.filter((run) => (run.pausedMs ?? 0) > 0);
|
|
271
|
+
if (controlled.length === 0 && held.length === 0)
|
|
272
|
+
return [];
|
|
273
|
+
const lines = ['### Control'];
|
|
274
|
+
for (const item of controlled) {
|
|
275
|
+
const at = Math.max(0, Math.round((item.at - outcome.startedAt) / 1000));
|
|
276
|
+
lines.push(`[${item.trigger} ${at}s] ${item.label}: ${item.reason}`);
|
|
277
|
+
}
|
|
278
|
+
for (const run of held) {
|
|
279
|
+
const seconds = Math.round((run.pausedMs ?? 0) / 1000);
|
|
280
|
+
const holds = run.pauseCount ?? 1;
|
|
281
|
+
lines.push(`${run.label} was held for ${seconds}s in ${holds} hold${holds === 1 ? '' : 's'}` +
|
|
282
|
+
`${run.controlBy !== undefined ? ` (last by ${run.controlBy})` : ''}.`);
|
|
283
|
+
}
|
|
284
|
+
return lines;
|
|
285
|
+
}
|
|
256
286
|
/**
|
|
257
287
|
* Assemble the report.
|
|
258
288
|
*
|
|
@@ -267,6 +297,7 @@ export function buildDispatchReport(outcome, options = {}) {
|
|
|
267
297
|
const sections = outcome.runs.map(buildSection);
|
|
268
298
|
const mail = buildLeadMail(outcome);
|
|
269
299
|
const overseer = buildOverseer(outcome, options);
|
|
300
|
+
const control = buildControl(outcome);
|
|
270
301
|
const summaries = sections.map((s) => truncateBytes(s.summary, TEAM_LIMITS.summaryMaxBytes));
|
|
271
302
|
const trimmed = summaries.map((s, i) => s.length < sections[i].summary.length);
|
|
272
303
|
const render = (bodies) => {
|
|
@@ -281,6 +312,8 @@ export function buildDispatchReport(outcome, options = {}) {
|
|
|
281
312
|
});
|
|
282
313
|
if (overseer.length > 0)
|
|
283
314
|
blocks.push(overseer.join('\n'));
|
|
315
|
+
if (control.length > 0)
|
|
316
|
+
blocks.push(control.join('\n'));
|
|
284
317
|
if (mail.length > 0)
|
|
285
318
|
blocks.push(mail.join('\n'));
|
|
286
319
|
return blocks.join('\n\n');
|