brl-subagent 2.6.0 → 2.7.0
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/AGENT.md +2 -1
- package/README.md +16 -3
- package/package.json +4 -1
- package/src/dispatch-line.ts +144 -0
- package/src/history.ts +13 -1
- package/src/index.ts +542 -709
- package/src/loader.ts +178 -0
- package/src/mode-prologue.ts +169 -0
- package/src/model-availability.ts +13 -1
- package/src/params.ts +179 -62
- package/src/prelude.ts +279 -3
- package/src/presets.ts +56 -148
- package/src/project-flags.ts +58 -0
- package/src/run-registry.ts +4 -1
- package/src/schema.ts +67 -51
- package/src/session-manager.ts +790 -91
- package/src/store-permissions.ts +98 -0
- package/src/templates.ts +65 -121
- package/src/transcript.ts +5 -2
- package/src/transport-retry.ts +90 -0
- package/src/tui.ts +210 -351
- package/src/types.ts +42 -23
- package/src/validate.ts +41 -0
package/src/schema.ts
CHANGED
|
@@ -7,6 +7,50 @@
|
|
|
7
7
|
import { Type } from "typebox";
|
|
8
8
|
import { MAX_CHAIN_STEPS, MAX_PARALLEL_TASKS, MAX_GRAPH_TASKS } from "./types";
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Issue #381 (audit D7): the per-unit fields registered for `chain[]` steps,
|
|
12
|
+
* `tasks[]` items and `graph[]` nodes — defined once here, spread into the
|
|
13
|
+
* three `Type.Object` literals below.
|
|
14
|
+
*
|
|
15
|
+
* The modes differ only in their `task` wording, whether the unit carries a
|
|
16
|
+
* per-unit `priority` (chain[] does not: its steps never compete for a
|
|
17
|
+
* concurrency slot, array order IS the priority), and graph's node-only
|
|
18
|
+
* `id`/`dependsOn`. Those differences are slotted at their existing positions
|
|
19
|
+
* because the registered key ORDER is part of the contract — the schema is the
|
|
20
|
+
* LLM contract, so this extraction must not reorder a single field.
|
|
21
|
+
*/
|
|
22
|
+
const STEP_HEAD_FIELDS = {
|
|
23
|
+
label: Type.Optional(Type.String({})),
|
|
24
|
+
model: Type.Optional(Type.String({ description: "Model override for this step (provider/model-id). Defaults to the global subagent model." })),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const STEP_THINKING_LEVEL_FIELD = {
|
|
28
|
+
thinkingLevel: Type.Optional(Type.String({})),
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/** Per-unit concurrency priority — tasks[] and graph[] only (issue #114). */
|
|
32
|
+
const STEP_PRIORITY_FIELD = {
|
|
33
|
+
priority: Type.Optional(
|
|
34
|
+
Type.Union([
|
|
35
|
+
Type.Literal("critical"),
|
|
36
|
+
Type.Literal("high"),
|
|
37
|
+
Type.Literal("normal"),
|
|
38
|
+
Type.Literal("low"),
|
|
39
|
+
], { description: "Concurrency priority for this subtask (overrides the call-level default)." }),
|
|
40
|
+
),
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const STEP_TAIL_FIELDS = {
|
|
44
|
+
cwd: Type.Optional(Type.String({})),
|
|
45
|
+
timeout: Type.Optional(Type.Number({})),
|
|
46
|
+
outputFile: Type.Optional(Type.String({})),
|
|
47
|
+
tools: Type.Optional(Type.Array(Type.String({}))),
|
|
48
|
+
excludeTools: Type.Optional(Type.Array(Type.String({}))),
|
|
49
|
+
noBuiltinTools: Type.Optional(Type.Boolean({})),
|
|
50
|
+
systemPrompt: Type.Optional(Type.String({})),
|
|
51
|
+
inheritSystemPrompt: Type.Optional(Type.Boolean({})),
|
|
52
|
+
};
|
|
53
|
+
|
|
10
54
|
export const delegateTaskParamsSchema = Type.Object({
|
|
11
55
|
task: Type.Optional(Type.String({
|
|
12
56
|
description: "Detailed description of the task for the subagent to complete (required for single mode, optional for chain/tasks/graph)",
|
|
@@ -143,7 +187,7 @@ export const delegateTaskParamsSchema = Type.Object({
|
|
|
143
187
|
description:
|
|
144
188
|
"If true and a FOREGROUND subagent times out, automatically retry with the same parameters. " +
|
|
145
189
|
"Only retries once — the second timeout is treated as a final failure. " +
|
|
146
|
-
"
|
|
190
|
+
"A background run is not retried on its deadline, but it is retried once automatically on a transport-class error; any other background failure needs an explicit retryRunId.",
|
|
147
191
|
}),
|
|
148
192
|
),
|
|
149
193
|
approvalMode: Type.Optional(
|
|
@@ -162,6 +206,16 @@ export const delegateTaskParamsSchema = Type.Object({
|
|
|
162
206
|
"Warnings are surfaced either way. force never suppresses outputFile-without-write conflicts.",
|
|
163
207
|
}),
|
|
164
208
|
),
|
|
209
|
+
noJev: Type.Optional(
|
|
210
|
+
Type.String({
|
|
211
|
+
minLength: 1,
|
|
212
|
+
description:
|
|
213
|
+
"Stated bypass for the Jev dispatch-line pre-flight, which is active ONLY in a project whose package.json sets the `brl-subagent.processChecks` field (this repository). " +
|
|
214
|
+
"A NON-EMPTY reason string: the dispatch proceeds and the reason is surfaced as a warning in the result, so the bypass is never silent. " +
|
|
215
|
+
"It bypasses ONLY the line check — capability conflicts still reject (unlike force). " +
|
|
216
|
+
"Append `jev: unavailable` to the task instead when the classifier did not run.",
|
|
217
|
+
}),
|
|
218
|
+
),
|
|
165
219
|
background: Type.Optional(
|
|
166
220
|
Type.Boolean({
|
|
167
221
|
description:
|
|
@@ -170,7 +224,7 @@ export const delegateTaskParamsSchema = Type.Object({
|
|
|
170
224
|
"The conductor is woken with a completion message; use get_subagent_result for post-wake retrieval and stall checks. " +
|
|
171
225
|
"Supports a single task or the tasks array (a fan-out that starts one background agent per task; with tasks the call returns one ID per task and the conductor is woken once per agent as each finishes); combining background with chain or graph is rejected. " +
|
|
172
226
|
"Default: conditional. Omitted, a single task or tasks fan-out runs in the BACKGROUND when the effective approvalMode is 'auto' (call param, else config); it stays foreground for 'writes'/'always' (a background run has no approval dialog, so the gate must stay in front of the user) and for chain/graph, which block by definition. " +
|
|
173
|
-
"Pass background: false for a quick probe whose answer the next step needs inline. Explicit true/false
|
|
227
|
+
"Pass background: false for a quick probe whose answer the next step needs inline. Explicit true/false wins. ONE pre-flight exception exists, and only in a project that opted into its own process checks (package.json `brl-subagent.processChecks: true`; this repository): a high/xhigh-thinking dispatch with background: false AND an explicit timeout is switched to background and the explicit timeout is dropped, because a foreground run loses its whole work at a timeout while a background run keeps its session and is retried on a transport error; pass force: true to keep it foreground. Without that project opt-in the explicit shape and its timeout stand. " +
|
|
174
228
|
"A background run defaults to a 30-minute deadline when no timeout is given.",
|
|
175
229
|
}),
|
|
176
230
|
),
|
|
@@ -189,67 +243,29 @@ export const delegateTaskParamsSchema = Type.Object({
|
|
|
189
243
|
// duration); array order IS the priority.
|
|
190
244
|
chain: Type.Optional(Type.Array(Type.Object({
|
|
191
245
|
task: Type.String({ description: "Task description. Use {previous} to reference the previous step output." }),
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
cwd: Type.Optional(Type.String({})),
|
|
196
|
-
timeout: Type.Optional(Type.Number({})),
|
|
197
|
-
outputFile: Type.Optional(Type.String({})),
|
|
198
|
-
tools: Type.Optional(Type.Array(Type.String({}))),
|
|
199
|
-
excludeTools: Type.Optional(Type.Array(Type.String({}))),
|
|
200
|
-
noBuiltinTools: Type.Optional(Type.Boolean({})),
|
|
201
|
-
systemPrompt: Type.Optional(Type.String({})),
|
|
202
|
-
inheritSystemPrompt: Type.Optional(Type.Boolean({})),
|
|
246
|
+
...STEP_HEAD_FIELDS,
|
|
247
|
+
...STEP_THINKING_LEVEL_FIELD,
|
|
248
|
+
...STEP_TAIL_FIELDS,
|
|
203
249
|
}), {
|
|
204
250
|
description: "Sequential chain of tasks. Each step receives the previous step output via {previous} placeholder in the task string. Chain stops at the first failure. Max " + MAX_CHAIN_STEPS + " steps."
|
|
205
251
|
})),
|
|
206
252
|
tasks: Type.Optional(Type.Array(Type.Object({
|
|
207
253
|
task: Type.String({ description: "Task description for this parallel subtask" }),
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
Type.Union([
|
|
213
|
-
Type.Literal("critical"),
|
|
214
|
-
Type.Literal("high"),
|
|
215
|
-
Type.Literal("normal"),
|
|
216
|
-
Type.Literal("low"),
|
|
217
|
-
], { description: "Concurrency priority for this subtask (overrides the call-level default)." })
|
|
218
|
-
),
|
|
219
|
-
cwd: Type.Optional(Type.String({})),
|
|
220
|
-
timeout: Type.Optional(Type.Number({})),
|
|
221
|
-
outputFile: Type.Optional(Type.String({})),
|
|
222
|
-
tools: Type.Optional(Type.Array(Type.String({}))),
|
|
223
|
-
excludeTools: Type.Optional(Type.Array(Type.String({}))),
|
|
224
|
-
noBuiltinTools: Type.Optional(Type.Boolean({})),
|
|
225
|
-
systemPrompt: Type.Optional(Type.String({})),
|
|
226
|
-
inheritSystemPrompt: Type.Optional(Type.Boolean({})),
|
|
254
|
+
...STEP_HEAD_FIELDS,
|
|
255
|
+
...STEP_THINKING_LEVEL_FIELD,
|
|
256
|
+
...STEP_PRIORITY_FIELD,
|
|
257
|
+
...STEP_TAIL_FIELDS,
|
|
227
258
|
}), {
|
|
228
259
|
description: "Parallel tasks to execute concurrently. All tasks run regardless of individual failures. Max " + MAX_PARALLEL_TASKS + " tasks."
|
|
229
260
|
})),
|
|
230
261
|
graph: Type.Optional(Type.Array(Type.Object({
|
|
231
262
|
id: Type.String({ description: "Unique identifier for this task node" }),
|
|
232
263
|
task: Type.String({ description: "Task description. Use {<nodeId>} to reference output from another task (the referenced node's own id, which must be a word-character id - letters, digits, underscore; ids like 'step-1' or 'node.a' are not matched and the braces are left as literal text)." }),
|
|
233
|
-
|
|
234
|
-
model: Type.Optional(Type.String({ description: "Model override for this step (provider/model-id). Defaults to the global subagent model." })),
|
|
264
|
+
...STEP_HEAD_FIELDS,
|
|
235
265
|
dependsOn: Type.Optional(Type.Array(Type.String({}), { description: "IDs of tasks that must complete before this one starts" })),
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
Type.Literal("critical"),
|
|
240
|
-
Type.Literal("high"),
|
|
241
|
-
Type.Literal("normal"),
|
|
242
|
-
Type.Literal("low"),
|
|
243
|
-
], { description: "Concurrency priority for this subtask (overrides the call-level default)." })
|
|
244
|
-
),
|
|
245
|
-
cwd: Type.Optional(Type.String({})),
|
|
246
|
-
timeout: Type.Optional(Type.Number({})),
|
|
247
|
-
outputFile: Type.Optional(Type.String({})),
|
|
248
|
-
tools: Type.Optional(Type.Array(Type.String({}))),
|
|
249
|
-
excludeTools: Type.Optional(Type.Array(Type.String({}))),
|
|
250
|
-
noBuiltinTools: Type.Optional(Type.Boolean({})),
|
|
251
|
-
systemPrompt: Type.Optional(Type.String({})),
|
|
252
|
-
inheritSystemPrompt: Type.Optional(Type.Boolean({})),
|
|
266
|
+
...STEP_THINKING_LEVEL_FIELD,
|
|
267
|
+
...STEP_PRIORITY_FIELD,
|
|
268
|
+
...STEP_TAIL_FIELDS,
|
|
253
269
|
}), {
|
|
254
270
|
description: "Declare tasks with dependencies. The scheduler parallelizes independent tasks and sequences dependent ones. Max " + MAX_GRAPH_TASKS + " tasks."
|
|
255
271
|
})),
|