pi-subagents 0.85.0 → 0.86.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/bundle/agents.js +3 -3
  3. package/bundle/child-tool-plan.js +2 -2
  4. package/bundle/{chunk-JWYG26RE.js → chunk-2IYBCYFU.js} +24 -23
  5. package/bundle/{chunk-KEY3UQMQ.js → chunk-374MZFF4.js} +1 -1
  6. package/bundle/{chunk-CS4O36CZ.js → chunk-3RKFH2UZ.js} +5 -5
  7. package/bundle/{chunk-7MAE3DJV.js → chunk-5H4BICQZ.js} +1 -1
  8. package/bundle/{chunk-RV5OGHLO.js → chunk-6VD7BGIC.js} +2 -2
  9. package/bundle/{chunk-KDMFBYFM.js → chunk-77ASNIEM.js} +1 -1
  10. package/bundle/{chunk-JNXT3MPI.js → chunk-7ADDXUGF.js} +5 -5
  11. package/bundle/{chunk-O7CPL6H4.js → chunk-7QA7ZA46.js} +9 -9
  12. package/bundle/{chunk-HFTBF7SG.js → chunk-7ZUFN6ME.js} +1 -1
  13. package/bundle/{chunk-RQAUNAWG.js → chunk-A637IMAO.js} +2 -2
  14. package/bundle/{chunk-LTPH2DXH.js → chunk-BGXEAYUM.js} +3 -3
  15. package/bundle/{chunk-JO67XSKD.js → chunk-BU6PFPVX.js} +4 -4
  16. package/bundle/{chunk-WOVMHDES.js → chunk-BWC2LVII.js} +39 -45
  17. package/bundle/{chunk-LGMILZNE.js → chunk-GJGTMLPE.js} +2 -2
  18. package/bundle/{chunk-PHZP3KHB.js → chunk-GRJHIXYF.js} +1 -1
  19. package/bundle/{chunk-QO75KJBT.js → chunk-LGINOOY5.js} +2 -2
  20. package/bundle/{chunk-GCSLVFCX.js → chunk-NAFLUJ26.js} +1 -1
  21. package/bundle/{chunk-3UZ5FVVJ.js → chunk-O3YH7XIY.js} +35 -31
  22. package/bundle/{chunk-PVIVCDG2.js → chunk-PYOAIN3V.js} +2 -2
  23. package/bundle/{chunk-UX4SCV5N.js → chunk-QGO6HXHG.js} +80 -35
  24. package/bundle/{chunk-DV2NCNPR.js → chunk-QM3JGE4W.js} +11 -11
  25. package/bundle/{chunk-H2NLFTC5.js → chunk-S2Q75LP3.js} +1 -1
  26. package/bundle/{chunk-KZ34KQQH.js → chunk-UR7OW5S7.js} +4 -4
  27. package/bundle/{chunk-L2ENOFVZ.js → chunk-WN2E5XHN.js} +66 -26
  28. package/bundle/{chunk-N7B2KD74.js → chunk-YK3QYNLE.js} +1 -1
  29. package/bundle/{chunk-IQIWF2VX.js → chunk-ZJJCPV3L.js} +4 -4
  30. package/bundle/{chunk-T5V5BRCL.js → chunk-ZPY5QZCS.js} +1 -1
  31. package/bundle/control-channel.js +2 -2
  32. package/bundle/index.js +1 -1
  33. package/bundle/intercom-bridge.js +2 -2
  34. package/bundle/preflight.js +8 -8
  35. package/bundle/project-panes.js +3 -3
  36. package/docs/agents.md +6 -0
  37. package/docs/configuration.md +2 -2
  38. package/docs/tool-reference.md +2 -0
  39. package/package.json +1 -1
  40. package/src/extension/tool-activation.js +10 -1
  41. package/src/extension/tool-description.d.ts +1 -1
  42. package/src/extension/tool-description.js +8 -8
  43. package/src/runs/background/run-status.js +5 -4
  44. package/src/runs/background/subagent-runner.js +6 -6
  45. package/src/runs/shared/acceptance.js +69 -26
  46. package/src/runs/shared/external-cli-contract.d.ts +49 -0
  47. package/src/runs/shared/external-cli-contract.js +18 -13
  48. package/src/runs/shared/structured-output.js +10 -3
  49. package/src/shared/types.d.ts +57 -48
  50. package/src/tui/render.js +83 -22
  51. package/src/workflows/workflow-receipt.js +36 -53
package/src/tui/render.js CHANGED
@@ -245,6 +245,33 @@ export function compactTaskText(task, label) {
245
245
  return undefined;
246
246
  return previewDisplayText(normalized, COMPACT_TASK_MAX_CHARS);
247
247
  }
248
+ const EXPANDED_TASK_MAX_LINES = 8;
249
+ /** Runs on every spinner frame, so the task is cut to what the line cap can show before any sanitizing or wrapping. */
250
+ function expandedTaskLines(task, label, width) {
251
+ const taskText = task?.trim();
252
+ if (!taskText || taskText === PROMPT_REDACTED || width <= 0)
253
+ return undefined;
254
+ const shown = truncateDisplayText(taskText, EXPANDED_TASK_MAX_LINES * width);
255
+ const labelText = label?.trim() && label.trim() !== PROMPT_REDACTED ? sanitizeDisplayText(label) : "";
256
+ const head = labelText && labelText !== sanitizeDisplayText(shown) ? `${labelText} — ` : "";
257
+ const lines = [];
258
+ for (const rawLine of `task: ${head}${shown}`.split("\n")) {
259
+ const content = sanitizeDisplayText(rawLine);
260
+ if (!content) {
261
+ if (lines.length > 0 && lines[lines.length - 1] !== "")
262
+ lines.push("");
263
+ continue;
264
+ }
265
+ const indent = rawLine.match(/^[ \t]*/)[0].replace(/\t/g, " ").slice(0, Math.floor(width / 2));
266
+ for (const part of wrapPlainText(content, width - indent.length))
267
+ lines.push(`${indent}${part}`);
268
+ if (lines.length > EXPANDED_TASK_MAX_LINES)
269
+ break;
270
+ }
271
+ if (lines.length <= EXPANDED_TASK_MAX_LINES && shown.length === taskText.length)
272
+ return lines;
273
+ return [...lines.slice(0, EXPANDED_TASK_MAX_LINES), "…"];
274
+ }
248
275
  const LANE_VALUE_MAX_CHARS = 48;
249
276
  function boundedLaneValue(value, maxChars = LANE_VALUE_MAX_CHARS) {
250
277
  if (!value?.trim() || value.trim() === PROMPT_REDACTED)
@@ -1543,7 +1570,7 @@ function widgetStepActivity(step, snapshotNow) {
1543
1570
  return activity;
1544
1571
  return facts.join(" · ");
1545
1572
  }
1546
- function widgetChainDetails(job, theme, expanded = false, width = getTermWidth(), frame) {
1573
+ function widgetChainDetails(job, theme, expanded = false, width = getTermWidth(), frame, fullTask = false) {
1547
1574
  if (!job.steps?.length)
1548
1575
  return [];
1549
1576
  const total = job.chainStepCount ?? job.steps.length;
@@ -1551,7 +1578,7 @@ function widgetChainDetails(job, theme, expanded = false, width = getTermWidth()
1551
1578
  for (const span of buildAsyncChainStepSpans(total, job.steps.length, job.parallelGroups)) {
1552
1579
  const steps = job.steps.slice(span.start, span.start + span.count);
1553
1580
  if (span.isParallel) {
1554
- lines.push(...parallelWidgetGroupDetails(job, theme, { steps, total: span.count, stepIndex: span.stepIndex, chainTotal: total }, expanded, width, frame, false));
1581
+ lines.push(...parallelWidgetGroupDetails(job, theme, { steps, total: span.count, stepIndex: span.stepIndex, chainTotal: total }, expanded, width, frame, false, fullTask));
1555
1582
  continue;
1556
1583
  }
1557
1584
  const step = steps[0];
@@ -1559,20 +1586,26 @@ function widgetChainDetails(job, theme, expanded = false, width = getTermWidth()
1559
1586
  lines.push(` ${theme.fg("dim", `◦ Step ${span.stepIndex + 1}/${total}: pending`)}`);
1560
1587
  continue;
1561
1588
  }
1562
- lines.push(...foregroundStyleWidgetStepLines(job, theme, step, "Step", span.stepIndex + 1, total, expanded, width, frame));
1589
+ lines.push(...foregroundStyleWidgetStepLines(job, theme, step, "Step", span.stepIndex + 1, total, expanded, width, frame, { fullTask }));
1563
1590
  }
1564
1591
  return lines;
1565
1592
  }
1566
- function widgetParallelAgentDetails(job, theme, expanded = false, width = getTermWidth(), frame) {
1593
+ function widgetParallelAgentDetails(job, theme, expanded = false, width = getTermWidth(), frame, fullTask = false) {
1567
1594
  if (!job.steps?.length)
1568
1595
  return [];
1596
+ // Multi-job cards prefix every line with a 4-column tree continuation after this returns.
1597
+ const taskLines = (step, indent) => expanded && fullTask && step.status === "running"
1598
+ ? (expandedTaskLines(step.description, step.label, width - indent.length - 4) ?? []).map((line) => `${indent}${theme.fg("dim", line)}`)
1599
+ : [];
1600
+ if (job.mode === "single")
1601
+ return job.steps.flatMap((step) => taskLines(step, " "));
1569
1602
  if (job.mode !== "parallel" && job.mode !== "chain")
1570
1603
  return [];
1571
1604
  if (job.mode === "chain" && !job.activeParallelGroup && job.parallelGroups?.length)
1572
- return widgetChainDetails(job, theme, expanded, width, frame);
1605
+ return widgetChainDetails(job, theme, expanded, width, frame, fullTask);
1573
1606
  const group = activeParallelWidgetGroup(job);
1574
1607
  if (group)
1575
- return parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, Boolean(job.activeParallelGroup));
1608
+ return parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, Boolean(job.activeParallelGroup), fullTask);
1576
1609
  const total = job.stepsTotal ?? job.steps.length;
1577
1610
  const lines = [];
1578
1611
  for (const [index, step] of job.steps.entries()) {
@@ -1584,6 +1617,7 @@ function widgetParallelAgentDetails(job, theme, expanded = false, width = getTer
1584
1617
  const display = step.sessionName?.trim() || (label ? `${label} (${step.agent})` : step.agent);
1585
1618
  const thinking = childThinkingLevel(step);
1586
1619
  lines.push(` ${theme.fg("dim", `${marker} ${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, index), frame, thinking)} ${itemTitle} ${index + 1}/${total}: ${display} · ${widgetStepStatus(step.status, theme, thinking)}${modelDisplay}${activity ? ` · ${activity}` : ""}`)}`);
1620
+ lines.push(...taskLines(step, " "));
1587
1621
  const lane = projectAsyncLane(job, step);
1588
1622
  if (lane)
1589
1623
  lines.push(...formatLaneProjectionLines(lane, theme, " "));
@@ -1731,7 +1765,7 @@ function parallelWidgetGroupHeader(group, theme, frame) {
1731
1765
  : "parallel group";
1732
1766
  return ` ${widgetStepGlyph(status, theme, widgetStepsRunningSeed(group.steps), frame)} ${themeBold(theme, label)} ${theme.fg("dim", "·")} ${theme.fg("dim", formatParallelOutcome(group.steps, group.total))}`;
1733
1767
  }
1734
- function parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, prioritizeActive) {
1768
+ function parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, prioritizeActive, fullTask = false) {
1735
1769
  const lines = [parallelWidgetGroupHeader(group, theme, frame)];
1736
1770
  const rows = parallelWidgetStepRows(group.steps, group.total, prioritizeActive);
1737
1771
  for (const [rowIndex, row] of rows.entries()) {
@@ -1742,6 +1776,7 @@ function parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, p
1742
1776
  detailIndent: " ",
1743
1777
  rowMarker: marker,
1744
1778
  includeCurrentPath: true,
1779
+ fullTask,
1745
1780
  }));
1746
1781
  }
1747
1782
  for (let index = rows.length; index < group.total; index++) {
@@ -2232,7 +2267,9 @@ function formatNestedWidgetLines(children, theme, width, expanded, snapshotNow,
2232
2267
  append(children, 0, "");
2233
2268
  return lines.map((line) => truncLine(line, width));
2234
2269
  }
2235
- function foregroundStyleWidgetStepLines(job, theme, step, itemTitle, index, total, expanded, width, frame, options) {
2270
+ function foregroundStyleWidgetStepLines(job, theme, step, itemTitle, index, total, expanded, width, frame,
2271
+ /** `fullTask`: the widget has exactly one running child, so an expanded row may spend lines on its whole task. */
2272
+ options) {
2236
2273
  const rowIndent = options?.rowIndent ?? " ";
2237
2274
  const detailIndent = options?.detailIndent ?? " ";
2238
2275
  const thinking = childThinkingLevel(step);
@@ -2251,7 +2288,11 @@ function foregroundStyleWidgetStepLines(job, theme, step, itemTitle, index, tota
2251
2288
  const lane = projectAsyncLane(job, step);
2252
2289
  if (lane)
2253
2290
  lines.push(...formatLaneProjectionLines(lane, theme, detailIndent));
2254
- const task = collapseDetails ? stepTaskSummary(step, displayName) : compactTaskText(step.description, step.label);
2291
+ // Multi-job cards prefix every line with a 4-column tree continuation after this returns.
2292
+ const fullTask = expanded && options?.fullTask && step.status === "running" ? expandedTaskLines(step.description, step.label, width - detailIndent.length - 4) : undefined;
2293
+ const task = fullTask ? undefined : collapseDetails ? stepTaskSummary(step, displayName) : compactTaskText(step.description, step.label);
2294
+ for (const line of fullTask ?? [])
2295
+ lines.push(`${detailIndent}${theme.fg("dim", line)}`);
2255
2296
  if (task)
2256
2297
  lines.push(`${detailIndent}${theme.fg("dim", `task: ${task}`)}`);
2257
2298
  const activity = widgetStepActivityLine(step, width, expanded, job.updatedAt);
@@ -2314,7 +2355,7 @@ function hostStepWidgetLines(job, theme, indent) {
2314
2355
  lines.push(`${indent}${theme.fg("dim", `… +${rows.length - visible.length} host steps hidden`)}`);
2315
2356
  return lines;
2316
2357
  }
2317
- function foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projection = buildWorkflowWidgetProjection(job)) {
2358
+ function foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projection = buildWorkflowWidgetProjection(job), fullTask = false) {
2318
2359
  const steps = projection.steps.filter((step) => !projection.materializedKeys?.has(step.workflowKey ?? "") && !projection.materializedKeys?.has(step.runId ?? ""));
2319
2360
  const checklist = widgetChecklistWithoutMaterializedChildren(projection);
2320
2361
  if (!expanded && job.mode === "workflow") {
@@ -2332,14 +2373,14 @@ function foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projec
2332
2373
  ];
2333
2374
  }
2334
2375
  if (job.mode === "chain" && !job.activeParallelGroup && job.parallelGroups?.length)
2335
- return widgetChainDetails(job, theme, expanded, width, frame);
2376
+ return widgetChainDetails(job, theme, expanded, width, frame, fullTask);
2336
2377
  const lines = [
2337
2378
  ...(expanded ? workflowPreflightLines(job) : []),
2338
2379
  ...workflowChecklistWidgetLines(checklist, theme, " ", expanded, frame, { includeItemErrors: !expanded, liveWidget: true }),
2339
2380
  ];
2340
2381
  const group = activeParallelWidgetGroup(job);
2341
2382
  if (group) {
2342
- lines.push(...parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, Boolean(job.activeParallelGroup)));
2383
+ lines.push(...parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, Boolean(job.activeParallelGroup), fullTask));
2343
2384
  }
2344
2385
  else {
2345
2386
  const { stageProgress, plannedKeys } = projection;
@@ -2356,7 +2397,7 @@ function foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projec
2356
2397
  const itemTitle = isPlannedStage ? "Stage" : "Step";
2357
2398
  const displayIndex = isPlannedStage ? (step.index ?? index) + 1 : plannedKeys ? ++extraStepIndex : index + 1;
2358
2399
  const displayTotal = isPlannedStage ? stageTotal : extraStepCount;
2359
- lines.push(...foregroundStyleWidgetStepLines(job, theme, step, itemTitle, displayIndex, displayTotal, expanded, width, frame));
2400
+ lines.push(...foregroundStyleWidgetStepLines(job, theme, step, itemTitle, displayIndex, displayTotal, expanded, width, frame, { fullTask }));
2360
2401
  }
2361
2402
  }
2362
2403
  lines.push(...hostStepWidgetLines(job, theme, " "));
@@ -2368,7 +2409,7 @@ function foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projec
2368
2409
  return lines;
2369
2410
  }
2370
2411
  /** `reservedLines` are lines the caller renders after these, such as materialized workflow children. */
2371
- function buildSingleWidgetLines(job, theme, width, expanded, frame, projection = buildWorkflowWidgetProjection(job), reservedLines = 0) {
2412
+ function buildSingleWidgetLines(job, theme, width, expanded, frame, projection = buildWorkflowWidgetProjection(job), reservedLines = 0, fullTask = false) {
2372
2413
  if ((!expanded || projection.inlineFleetCovered) && job.mode === "workflow")
2373
2414
  return [compactWorkflowHeaderLine(job, theme, width), ...compactWorkflowWidgetBodyLines(job, theme, frame, projection, widgetLineBudget(expanded) - 1 - reservedLines)].map((line) => truncLine(line, width));
2374
2415
  const stats = widgetStats(job, theme, projection, !expanded);
@@ -2385,7 +2426,7 @@ function buildSingleWidgetLines(job, theme, width, expanded, frame, projection =
2385
2426
  return [
2386
2427
  `${theme.fg("toolTitle", themeBold(theme, title))} ${theme.fg("dim", "· background")}`,
2387
2428
  ...(collapseDetails ? [] : [summary]),
2388
- ...foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projection),
2429
+ ...foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projection, fullTask),
2389
2430
  ].map((line) => truncLine(line, width));
2390
2431
  }
2391
2432
  function compactSingleWidgetLines(job, theme, width, frame, projection = buildWorkflowWidgetProjection(job)) {
@@ -2817,7 +2858,7 @@ function widgetChecklistWithoutMaterializedChildren(projection) {
2817
2858
  return checklist;
2818
2859
  return { ...checklist, phases: checklist.phases.map((phase) => ({ ...phase, items: phase.items.filter((item) => !materializedKeys.has(item.key)) })) };
2819
2860
  }
2820
- function materializedWidgetChildLines(job, theme, width, expanded, frame, projectionFor) {
2861
+ function materializedWidgetChildLines(job, theme, width, expanded, frame, projectionFor, fullTask = false) {
2821
2862
  const { children, inlineFleetCovered } = projectionFor(job);
2822
2863
  if (inlineFleetCovered || !children?.length)
2823
2864
  return [];
@@ -2829,9 +2870,9 @@ function materializedWidgetChildLines(job, theme, width, expanded, frame, projec
2829
2870
  const identity = child.workflowKey ?? child.asyncId;
2830
2871
  const stats = widgetStats(child, theme, projection, !expanded);
2831
2872
  lines.push(` ${last ? "└─" : "├─"} ${theme.bold(identity)} ${widgetStatusGlyph(child, theme, frame)} ${themeBold(theme, widgetJobName(child))}${contextModeBadge(theme, child.context)}${stats ? ` ${theme.fg("dim", "·")} ${stats}` : ""}`);
2832
- for (const detail of foregroundStyleWidgetDetails(child, theme, expanded, Math.max(0, width - 6), frame, projection))
2873
+ for (const detail of foregroundStyleWidgetDetails(child, theme, expanded, Math.max(0, width - 6), frame, projection, fullTask))
2833
2874
  lines.push(` ${last ? " " : "│ "}${detail}`);
2834
- for (const detail of materializedWidgetChildLines(child, theme, Math.max(0, width - 4), expanded, frame, projectionFor))
2875
+ for (const detail of materializedWidgetChildLines(child, theme, Math.max(0, width - 4), expanded, frame, projectionFor, fullTask))
2835
2876
  lines.push(` ${detail}`);
2836
2877
  }
2837
2878
  if (shown.length < children.length)
@@ -2934,12 +2975,32 @@ function buildWidgetComponent(jobs, ui, initiallyCollapsed = false, layout) {
2934
2975
  return component;
2935
2976
  };
2936
2977
  }
2978
+ /** Running children the widget shows, counted the way it renders them: a workflow step that has
2979
+ * its own child job is that job's row, so it counts once. */
2980
+ function runningWidgetChildCount(jobs, projectionFor) {
2981
+ let running = 0;
2982
+ for (const job of jobs) {
2983
+ const { steps, materializedKeys, children } = projectionFor(job);
2984
+ if (!steps.length && job.status === "running")
2985
+ running++;
2986
+ for (const step of steps) {
2987
+ if (step.status === "running" && !materializedKeys?.has(step.workflowKey ?? "") && !materializedKeys?.has(step.runId ?? ""))
2988
+ running++;
2989
+ }
2990
+ if (children?.length)
2991
+ running += runningWidgetChildCount(children, projectionFor);
2992
+ }
2993
+ return running;
2994
+ }
2937
2995
  function buildWidgetLinesWithProjection(jobs, theme, width = getTermWidth(), expanded = false, frame, projectionFor = workflowWidgetProjectionLookup()) {
2938
2996
  if (jobs.length === 0)
2939
2997
  return [];
2998
+ // Expanded rows show a whole task only while exactly one child runs in the whole widget; with
2999
+ // more, the extra lines would push other running children past the widget's line budget.
3000
+ const fullTask = expanded && runningWidgetChildCount(jobs, projectionFor) === 1;
2940
3001
  if (jobs.length === 1) {
2941
- const childLines = materializedWidgetChildLines(jobs[0], theme, width, expanded, frame, projectionFor).map((line) => truncLine(line, width));
2942
- return [...buildSingleWidgetLines(jobs[0], theme, width, expanded, frame, projectionFor(jobs[0]), childLines.length), ...childLines];
3002
+ const childLines = materializedWidgetChildLines(jobs[0], theme, width, expanded, frame, projectionFor, fullTask).map((line) => truncLine(line, width));
3003
+ return [...buildSingleWidgetLines(jobs[0], theme, width, expanded, frame, projectionFor(jobs[0]), childLines.length, fullTask), ...childLines];
2943
3004
  }
2944
3005
  const running = jobs.filter((job) => job.status === "running");
2945
3006
  const queued = jobs.filter((job) => job.status === "queued");
@@ -2965,14 +3026,14 @@ function buildWidgetLinesWithProjection(jobs, theme, width = getTermWidth(), exp
2965
3026
  ` ${theme.fg("dim", `⎿ ${widgetActivity(job)}`)}`,
2966
3027
  ...widgetLaneDetailLines(job, theme, projection),
2967
3028
  ...workflowChecklistWidgetLines(widgetChecklistWithoutMaterializedChildren(projection), theme, " ", expanded, frame, { includeItemErrors: !expanded || !job.steps?.length, liveWidget: true }),
2968
- ...widgetParallelAgentDetails(job, theme, expanded, width, frame),
3029
+ ...widgetParallelAgentDetails(job, theme, expanded, width, frame, fullTask),
2969
3030
  ];
2970
3031
  const item = [
2971
3032
  compactWorkflow
2972
3033
  ? compactWorkflowHeaderLine(job, theme, width)
2973
3034
  : `${widgetStatusGlyph(job, theme, frame)} ${themeBold(theme, widgetJobName(job))}${contextModeBadge(theme, job.context)}${stats ? ` ${theme.fg("dim", "·")} ${stats}` : ""}`,
2974
3035
  ...details,
2975
- ...materializedWidgetChildLines(job, theme, width, expanded, frame, projectionFor),
3036
+ ...materializedWidgetChildLines(job, theme, width, expanded, frame, projectionFor, fullTask),
2976
3037
  ];
2977
3038
  items.push(item);
2978
3039
  if (compactWorkflow)
@@ -5,6 +5,7 @@ import { parseWorkflowChildSummary } from "./workflow-child-summary.js";
5
5
  import { HOST_STEP_MAX_COUNT, assertUniqueHostStepIds, parseHostStepNode } from "../runs/shared/host-step-status.js";
6
6
  import { assertWorkflowLaneKey, normalizeWorkflowLaneMetadata } from "../runs/shared/lane-metadata.js";
7
7
  import { projectWorkflowKeyRevival } from "./workflow-revival.js";
8
+ import { EXTERNAL_CLI_ADAPTER_SAFETY, isCodeOwnedExternalCliAdapterId } from "../runs/shared/external-cli-contract.js";
8
9
  export const WORKFLOW_RECEIPT_VERSION = 1;
9
10
  export const WORKFLOW_RECEIPT_FILE = "workflow-receipt.json";
10
11
  const MAX_WORKFLOW_RECEIPT_BYTES = 2 * 1024 * 1024;
@@ -127,6 +128,30 @@ function parseExternalCliMachine(value, label) {
127
128
  if (unknownRemoteGit.length > 0 || (remoteGit.head !== undefined && (typeof remoteGit.head !== "string" || !remoteGit.head.trim())) || (remoteGit.branch !== undefined && (typeof remoteGit.branch !== "string" || !remoteGit.branch.trim())) || (remoteGit.dirty !== undefined && typeof remoteGit.dirty !== "boolean"))
128
129
  throw new Error(`${label}.machine.remoteGit is invalid.`);
129
130
  }
131
+ function parseCodeOwnedSafety(value, adapter, label) {
132
+ if (!value || typeof value !== "object" || Array.isArray(value))
133
+ throw new Error(`${label}.safety is missing.`);
134
+ const safety = value;
135
+ const profile = EXTERNAL_CLI_ADAPTER_SAFETY[adapter];
136
+ const unknownSafety = Object.keys(safety).filter((field) => !Object.hasOwn(profile, field));
137
+ if (unknownSafety.length > 0)
138
+ throw new Error(`${label}.safety has unsupported fields: ${unknownSafety.join(", ")}.`);
139
+ if (Object.entries(profile).some(([field, expected]) => safety[field] !== expected))
140
+ throw new Error(`${label}.safety is invalid.`);
141
+ }
142
+ function parseExternalCliSafetySource(value, label) {
143
+ if (value === undefined)
144
+ return false;
145
+ if (!value || typeof value !== "object" || Array.isArray(value))
146
+ throw new Error(`${label}.safetySource must be an object.`);
147
+ const source = value;
148
+ const unknownSource = Object.keys(source).filter((field) => !["measured", "command"].includes(field));
149
+ if (unknownSource.length > 0)
150
+ throw new Error(`${label}.safetySource has unsupported fields: ${unknownSource.join(", ")}.`);
151
+ if (source.measured !== false || (source.command !== undefined && (typeof source.command !== "string" || !source.command.trim())))
152
+ throw new Error(`${label}.safetySource is invalid.`);
153
+ return true;
154
+ }
130
155
  function parseExternalCliReceiptMetadata(value, key, source) {
131
156
  if (value === undefined)
132
157
  return undefined;
@@ -134,7 +159,7 @@ function parseExternalCliReceiptMetadata(value, key, source) {
134
159
  if (!value || typeof value !== "object" || Array.isArray(value))
135
160
  throw new Error(`${label} must be an object.`);
136
161
  const metadata = value;
137
- const unknownMetadata = Object.keys(metadata).filter((field) => !["adapter", "capabilities", "machine", "safety", "outputArtifacts", "handoff", "supervisor", "nonResumableReason"].includes(field));
162
+ const unknownMetadata = Object.keys(metadata).filter((field) => !["adapter", "capabilities", "machine", "safety", "safetySource", "outputArtifacts", "handoff", "supervisor", "nonResumableReason"].includes(field));
138
163
  if (unknownMetadata.length > 0)
139
164
  throw new Error(`${label} has unsupported fields: ${unknownMetadata.join(", ")}.`);
140
165
  const adapter = metadata.adapter;
@@ -160,65 +185,21 @@ function parseExternalCliReceiptMetadata(value, key, source) {
160
185
  if (metadata.machine !== undefined)
161
186
  parseExternalCliMachine(metadata.machine, label);
162
187
  const safety = metadata.safety;
163
- if (adapterRecord.id === "codex-exec") {
164
- if (!safety || typeof safety !== "object" || Array.isArray(safety))
165
- throw new Error(`${label}.safety is missing.`);
166
- const safetyRecord = safety;
167
- const unknownSafety = Object.keys(safetyRecord).filter((field) => !["sandbox", "approvalPolicy", "ephemeral"].includes(field));
168
- if (unknownSafety.length > 0)
169
- throw new Error(`${label}.safety has unsupported fields: ${unknownSafety.join(", ")}.`);
170
- if (safetyRecord.sandbox !== "read-only" || safetyRecord.approvalPolicy !== "never" || safetyRecord.ephemeral !== true)
171
- throw new Error(`${label}.safety is invalid.`);
172
- }
173
- else if (adapterRecord.id === "codex-exec-writer") {
174
- if (!safety || typeof safety !== "object" || Array.isArray(safety))
175
- throw new Error(`${label}.safety is missing.`);
188
+ const hasSafetySource = parseExternalCliSafetySource(metadata.safetySource, label);
189
+ if (adapterRecord.id === "claude-code" && !hasSafetySource && safety && typeof safety === "object" && !Array.isArray(safety) && safety.authentication === undefined) {
176
190
  const safetyRecord = safety;
177
- const unknownSafety = Object.keys(safetyRecord).filter((field) => !["access", "sandbox", "approvalPolicy", "ephemeral"].includes(field));
191
+ const unknownSafety = Object.keys(safetyRecord).filter((field) => !["permissionMode", "tools", "mcp", "settingSources", "sessionPersistence"].includes(field));
178
192
  if (unknownSafety.length > 0)
179
193
  throw new Error(`${label}.safety has unsupported fields: ${unknownSafety.join(", ")}.`);
180
- if (safetyRecord.access !== "workspace-write" || safetyRecord.sandbox !== "workspace-write" || safetyRecord.approvalPolicy !== "never" || safetyRecord.ephemeral !== true)
194
+ if (safetyRecord.permissionMode !== "plan" || safetyRecord.tools !== "none" || safetyRecord.mcp !== "empty-strict" || safetyRecord.settingSources !== "none" || safetyRecord.sessionPersistence !== false)
181
195
  throw new Error(`${label}.safety is invalid.`);
182
196
  }
183
- else if (adapterRecord.id === "claude-code") {
184
- if (!safety || typeof safety !== "object" || Array.isArray(safety))
185
- throw new Error(`${label}.safety is missing.`);
186
- const safetyRecord = safety;
187
- const legacy = safetyRecord.authentication === undefined;
188
- const unknownSafety = Object.keys(safetyRecord).filter((field) => !(legacy
189
- ? ["permissionMode", "tools", "mcp", "settingSources", "sessionPersistence"]
190
- : ["access", "authentication", "permissionMode", "tools", "mcp", "settingSources", "userSettingsTrust", "sessionPersistence"]).includes(field));
191
- if (unknownSafety.length > 0)
192
- throw new Error(`${label}.safety has unsupported fields: ${unknownSafety.join(", ")}.`);
193
- if (legacy) {
194
- if (safetyRecord.permissionMode !== "plan" || safetyRecord.tools !== "none" || safetyRecord.mcp !== "empty-strict" || safetyRecord.settingSources !== "none" || safetyRecord.sessionPersistence !== false)
195
- throw new Error(`${label}.safety is invalid.`);
196
- }
197
- else if (safetyRecord.access !== "read-only" || safetyRecord.authentication !== "existing-cli-required" || safetyRecord.permissionMode !== "plan" || safetyRecord.tools !== "none" || safetyRecord.mcp !== "empty-strict" || safetyRecord.settingSources !== "user" || safetyRecord.userSettingsTrust !== "required" || safetyRecord.sessionPersistence !== false)
198
- throw new Error(`${label}.safety is invalid.`);
199
- }
200
- else if (adapterRecord.id === "claude-code-writer") {
201
- if (!safety || typeof safety !== "object" || Array.isArray(safety))
202
- throw new Error(`${label}.safety is missing.`);
203
- const safetyRecord = safety;
204
- const unknownSafety = Object.keys(safetyRecord).filter((field) => !["access", "authentication", "permissionMode", "tools", "mcp", "settingSources", "userSettingsTrust", "sessionPersistence"].includes(field));
205
- if (unknownSafety.length > 0)
206
- throw new Error(`${label}.safety has unsupported fields: ${unknownSafety.join(", ")}.`);
207
- if (safetyRecord.access !== "workspace-write" || safetyRecord.authentication !== "existing-cli-required" || safetyRecord.permissionMode !== "acceptEdits" || safetyRecord.tools !== "Read,Write,Edit,Glob,Grep" || safetyRecord.mcp !== "empty-strict" || safetyRecord.settingSources !== "user" || safetyRecord.userSettingsTrust !== "required" || safetyRecord.sessionPersistence !== false)
208
- throw new Error(`${label}.safety is invalid.`);
209
- }
210
- else if (adapterRecord.id === "cursor-agent" || adapterRecord.id === "cursor-agent-writer") {
211
- if (!safety || typeof safety !== "object" || Array.isArray(safety))
212
- throw new Error(`${label}.safety is missing.`);
213
- const safetyRecord = safety;
214
- const unknownSafety = Object.keys(safetyRecord).filter((field) => !["access", "authentication", "mode", "sandbox", "workspaceTrust", "sessionReuse"].includes(field));
215
- if (unknownSafety.length > 0)
216
- throw new Error(`${label}.safety has unsupported fields: ${unknownSafety.join(", ")}.`);
217
- const writer = adapterRecord.id === "cursor-agent-writer";
218
- if (safetyRecord.access !== (writer ? "workspace-write" : "read-only") || safetyRecord.authentication !== "cursor-api-key-or-existing-login" || safetyRecord.mode !== (writer ? "print" : "ask") || safetyRecord.sandbox !== "enabled" || safetyRecord.workspaceTrust !== "existing-required" || safetyRecord.sessionReuse !== false)
219
- throw new Error(`${label}.safety is invalid.`);
197
+ else if (isCodeOwnedExternalCliAdapterId(adapterRecord.id)) {
198
+ parseCodeOwnedSafety(safety, adapterRecord.id, label);
220
199
  }
221
200
  else if (adapterRecord.id === "grok-build") {
201
+ if (hasSafetySource)
202
+ throw new Error(`${label}.safetySource is invalid for the legacy grok-build adapter.`);
222
203
  if (!safety || typeof safety !== "object" || Array.isArray(safety))
223
204
  throw new Error(`${label}.safety is missing.`);
224
205
  const safetyRecord = safety;
@@ -228,6 +209,8 @@ function parseExternalCliReceiptMetadata(value, key, source) {
228
209
  if (safetyRecord.access !== "read-only" || safetyRecord.authentication !== "xai-api-key-required" || safetyRecord.permissionMode !== "plan" || safetyRecord.tools !== "read_file,grep,list_dir" || safetyRecord.deniedTools !== "run_terminal_cmd,search_replace,Agent,Bash,Edit,Write,MCPTool" || safetyRecord.sandbox !== "read-only" || safetyRecord.webSearch !== false || safetyRecord.subagents !== false || safetyRecord.config !== "temporary-home" || safetyRecord.updates !== "disabled" || safetyRecord.sessionPersistence !== false)
229
210
  throw new Error(`${label}.safety is invalid.`);
230
211
  }
212
+ else if (hasSafetySource)
213
+ throw new Error(`${label}.safetySource is invalid for the generic adapter.`);
231
214
  else if (safety !== undefined)
232
215
  throw new Error(`${label}.safety is invalid for the generic adapter.`);
233
216
  const handoff = metadata.handoff;