brl-subagent 2.5.2 → 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/src/types.ts CHANGED
@@ -288,6 +288,46 @@ export interface ProcessOwner {
288
288
  start: string;
289
289
  }
290
290
 
291
+ /**
292
+ * Issue #381 (audit D5): the retry-override snapshot taken from the caller's
293
+ * raw delegate_task params at dispatch (see `snapshotOriginalParams` in
294
+ * params.ts). Declared once so the snapshotter and the run record cannot
295
+ * drift apart; `errorCategory` is deliberately NOT a snapshot field — the
296
+ * failure paths stamp it onto `originalParams` after the fact.
297
+ */
298
+ export interface SnapshotParams {
299
+ systemPrompt?: string;
300
+ inheritSystemPrompt?: boolean;
301
+ model?: string;
302
+ thinkingLevel?: string;
303
+ /** Issue #114: per-unit priority survives retries. */
304
+ priority?: string;
305
+ outputFile?: string;
306
+ timeout?: number;
307
+ cwd?: string;
308
+ tools?: string[];
309
+ excludeTools?: string[];
310
+ noBuiltinTools?: boolean;
311
+ preset?: string;
312
+ /**
313
+ * Issue #227: the execution-shape fields survive retries, so a retried
314
+ * background run stays background and a retried branch-mode run keeps its
315
+ * work branch, its approvalMode gating and its force override.
316
+ */
317
+ background?: boolean;
318
+ gitMode?: string;
319
+ approvalMode?: string;
320
+ force?: boolean;
321
+ /**
322
+ * Issue #401: the original, un-prefixed task — recorded ONLY by the transport
323
+ * auto-retry spawn site, whose child record's `task` also carries the resume
324
+ * preamble. `snapshotOriginalParams` never writes it (the run record's `task`
325
+ * is the normal carrier); it exists so a further retry resolves from the
326
+ * original text instead of stacking preambles.
327
+ */
328
+ task?: string;
329
+ }
330
+
291
331
  export interface SubagentRun {
292
332
  id: string;
293
333
  task: string;
@@ -351,29 +391,8 @@ export interface SubagentRun {
351
391
  errorMessage?: string;
352
392
  outputSummary?: string;
353
393
  fullOutput?: string;
354
- originalParams?: {
355
- systemPrompt?: string;
356
- inheritSystemPrompt?: boolean;
357
- model?: string;
358
- thinkingLevel?: string;
359
- // Issue #114: per-unit priority survives retries — the snapshot carries
360
- // it through so a retried run keeps its priority.
361
- priority?: string;
362
- outputFile?: string;
363
- timeout?: number;
364
- cwd?: string;
365
- tools?: string[];
366
- excludeTools?: string[];
367
- noBuiltinTools?: boolean;
368
- preset?: string;
369
- // Issue #227: the execution-shape fields survive retries, so a retried
370
- // background run stays background and a retried branch-mode run keeps its
371
- // work branch, its approvalMode gating and its force override. Additive:
372
- // records written before this change simply lack the keys.
373
- background?: boolean;
374
- gitMode?: string;
375
- approvalMode?: string;
376
- force?: boolean;
394
+ originalParams?: SnapshotParams & {
395
+ /** Issue #179 (D1/D2): classification stamped by the failure paths. */
377
396
  errorCategory?: ErrorCategory;
378
397
  };
379
398
  }
@@ -577,6 +596,16 @@ export type DelegateTaskDetails =
577
596
  */
578
597
  export type DelegateTaskParams = Static<typeof delegateTaskParamsSchema>;
579
598
 
599
+ /**
600
+ * The multi-unit breakdown shown in the footer while a graph/chain dispatch is
601
+ * in flight (issue #133). `SessionState.modeContext` carries it for the
602
+ * duration of the dispatch; the footer formatter (src/tui-format.ts) renders
603
+ * it, so the shape lives here rather than in `state.ts`.
604
+ */
605
+ export type ModeContext =
606
+ | { kind: "graph"; wave: number; totalWaves: number; node: number; totalNodes: number }
607
+ | { kind: "chain"; step: number; totalSteps: number };
608
+
580
609
  // ---------------------------------------------------------------------------
581
610
  // Resolved params (after preset merging + validation)
582
611
  // ---------------------------------------------------------------------------
@@ -983,11 +1012,11 @@ export function coherentFailureReason(
983
1012
  }
984
1013
 
985
1014
  export function formatModel(m: { provider: string; id: string } | undefined): string {
986
- return m ? `${m.provider}/${m.id}` : "Not set (will use main agent\u2019s model)";
1015
+ return m ? `${m.provider}/${m.id}` : "Not set";
987
1016
  }
988
1017
 
989
1018
  export function formatMaxParallel(n: number): string {
990
- return n === 0 ? "unlimited" : String(n);
1019
+ return n === 0 ? "Unlimited" : String(n);
991
1020
  }
992
1021
 
993
1022
  /**
package/src/validate.ts CHANGED
@@ -9,6 +9,8 @@
9
9
 
10
10
  import type { ThinkingLevel, SubagentToolOptions } from './types';
11
11
  import { THINKING_LEVELS } from './types';
12
+ import { DISPATCH_LINE_FORM, JEV_UNAVAILABLE, parseDispatchLine } from './dispatch-line';
13
+ import { isProcessChecksEnabled } from './project-flags';
12
14
 
13
15
  // ── Types ────────────────────────────────────────────────────────────
14
16
 
@@ -27,6 +29,21 @@ export interface ValidateConfig {
27
29
  * can never succeed, so force does not apply to it.
28
30
  */
29
31
  force?: boolean;
32
+ /**
33
+ * The project this dispatch runs in (the resolved dispatch cwd). The
34
+ * project-local process checks key on it: no cwd means no project to
35
+ * consult, so unit callers that never resolve one perform no check
36
+ * (issues #412, #415).
37
+ */
38
+ cwd?: string;
39
+ /**
40
+ * delegate_task's `noJev` param — the STATED bypass for the Jev-line check
41
+ * (issue #412, ADR 0018). Non-empty by schema. It downgrades the rejection
42
+ * to a warning that carries the reason, so the bypass is visible in the
43
+ * result, never silent. It bypasses ONLY the line check: every capability
44
+ * conflict still rejects (unlike `force`, which is capability-only).
45
+ */
46
+ noJev?: string;
30
47
  }
31
48
 
32
49
  export interface ValidateResult {
@@ -304,6 +321,30 @@ export function validatePreTask(config: ValidateConfig): ValidateResult {
304
321
  return { valid: true, warnings: [], errors: [] };
305
322
  }
306
323
 
324
+ // Issue #412 (absorbs #407): the Jev dispatch line, checked BEFORE anything
325
+ // spawns. Opt-in per project via the umbrella `processChecks` flag (#415,
326
+ // ADR 0019): this is our process, not a product requirement, so a user's
327
+ // dispatch is never rejected for a missing line. The flag read is fail-open
328
+ // (`src/project-flags.ts`). `noJev` — a stated reason — downgrades the
329
+ // rejection to a WARNING that names the reason, so the bypass is surfaced
330
+ // rather than silent (ADR 0007's pattern).
331
+ if (isProcessChecksEnabled(config.cwd)) {
332
+ const verdict = parseDispatchLine(taskText);
333
+ if (!verdict.ok) {
334
+ if (config.noJev !== undefined && config.noJev.trim() !== '') {
335
+ warnings.push(
336
+ `noJev override: the Jev dispatch line was skipped — ${config.noJev} (${verdict.reason})`,
337
+ );
338
+ } else {
339
+ errors.push(
340
+ `missing Jev dispatch line: ${verdict.reason}. ` +
341
+ `Classify with the Jev classifier, format the answer with \`jev-check --line '<json>'\` (it prints the line verbatim), and append it to the task as: ${DISPATCH_LINE_FORM}. ` +
342
+ `When the classifier did not run, append \`${JEV_UNAVAILABLE}\` instead, or pass noJev: "<reason>".`,
343
+ );
344
+ }
345
+ }
346
+ }
347
+
307
348
  // Check tool requirements. A missing capability is warning-class by
308
349
  // default (conductor can judge); the high-confidence capability-critical
309
350
  // cases (blockingPatterns) are promoted to ERRORS unless `force` is set.