pi-subagents 0.69.0 → 0.70.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/CHANGELOG.md +41 -0
- package/agents/reviewer.md +3 -2
- package/docs/agents.md +6 -2
- package/docs/configuration.md +1 -1
- package/docs/extension-api.md +1 -1
- package/docs/models.md +3 -1
- package/docs/observability.md +6 -0
- package/docs/watchdog.md +2 -0
- package/docs/workflows.md +6 -2
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -0
- package/index.js +10 -0
- package/index.js.map +1 -0
- package/package.json +89 -73
- package/runner-peer-loader.mjs +4 -7
- package/runner-peer-preload.mjs +5 -7
- package/skills/pi-subagents/references/prompting-and-roles.md +2 -2
- package/src/agents/advertised-agent-prompt.d.ts +8 -0
- package/src/agents/advertised-agent-prompt.d.ts.map +1 -0
- package/src/agents/advertised-agent-prompt.js +77 -0
- package/src/agents/advertised-agent-prompt.js.map +1 -0
- package/src/agents/agent-management.d.ts +27 -0
- package/src/agents/agent-management.d.ts.map +1 -0
- package/src/agents/agent-management.js +1528 -0
- package/src/agents/agent-management.js.map +1 -0
- package/src/agents/agent-memory.d.ts +49 -0
- package/src/agents/agent-memory.d.ts.map +1 -0
- package/src/agents/agent-memory.js +349 -0
- package/src/agents/agent-memory.js.map +1 -0
- package/src/agents/agent-refinements.d.ts +100 -0
- package/src/agents/agent-refinements.d.ts.map +1 -0
- package/src/agents/agent-refinements.js +569 -0
- package/src/agents/agent-refinements.js.map +1 -0
- package/src/agents/agent-scope.d.ts +3 -0
- package/src/agents/agent-scope.d.ts.map +1 -0
- package/src/agents/agent-scope.js +6 -0
- package/src/agents/agent-scope.js.map +1 -0
- package/src/agents/agent-selection.d.ts +3 -0
- package/src/agents/agent-selection.d.ts.map +1 -0
- package/src/agents/agent-selection.js +23 -0
- package/src/agents/agent-selection.js.map +1 -0
- package/src/agents/agent-serializer.d.ts +8 -0
- package/src/agents/agent-serializer.d.ts.map +1 -0
- package/src/agents/agent-serializer.js +200 -0
- package/src/agents/agent-serializer.js.map +1 -0
- package/src/agents/agents.d.ts +313 -0
- package/src/agents/agents.d.ts.map +1 -0
- package/src/agents/agents.js +2622 -0
- package/src/agents/agents.js.map +1 -0
- package/src/agents/builtin-names.d.ts +2 -0
- package/src/agents/builtin-names.d.ts.map +1 -0
- package/src/agents/builtin-names.js +17 -0
- package/src/agents/builtin-names.js.map +1 -0
- package/src/agents/chain-serializer.d.ts +7 -0
- package/src/agents/chain-serializer.d.ts.map +1 -0
- package/src/agents/chain-serializer.js +319 -0
- package/src/agents/chain-serializer.js.map +1 -0
- package/src/agents/frontmatter.d.ts +16 -0
- package/src/agents/frontmatter.d.ts.map +1 -0
- package/src/agents/frontmatter.js +142 -0
- package/src/agents/frontmatter.js.map +1 -0
- package/src/agents/identity.d.ts +8 -0
- package/src/agents/identity.d.ts.map +1 -0
- package/src/agents/identity.js +30 -0
- package/src/agents/identity.js.map +1 -0
- package/src/agents/proactive-skills.d.ts +35 -0
- package/src/agents/proactive-skills.d.ts.map +1 -0
- package/src/agents/proactive-skills.js +154 -0
- package/src/agents/proactive-skills.js.map +1 -0
- package/src/agents/runtime-agent-events.d.ts +27 -0
- package/src/agents/runtime-agent-events.d.ts.map +1 -0
- package/src/agents/runtime-agent-events.js +53 -0
- package/src/agents/runtime-agent-events.js.map +1 -0
- package/src/agents/runtime-agent-registry.d.ts +59 -0
- package/src/agents/runtime-agent-registry.d.ts.map +1 -0
- package/src/agents/runtime-agent-registry.js +390 -0
- package/src/agents/runtime-agent-registry.js.map +1 -0
- package/src/agents/skills.d.ts +33 -0
- package/src/agents/skills.d.ts.map +1 -0
- package/src/agents/skills.js +685 -0
- package/src/agents/skills.js.map +1 -0
- package/src/api/agents.d.ts +5 -0
- package/src/api/agents.d.ts.map +1 -0
- package/src/api/agents.js +3 -0
- package/src/api/agents.js.map +1 -0
- package/src/api/background-work.d.ts +39 -0
- package/src/api/background-work.d.ts.map +1 -0
- package/src/api/background-work.js +165 -0
- package/src/api/background-work.js.map +1 -0
- package/src/api/capability-ceiling.d.ts +2 -0
- package/src/api/capability-ceiling.d.ts.map +1 -0
- package/src/api/capability-ceiling.js +2 -0
- package/src/api/capability-ceiling.js.map +1 -0
- package/src/api/child-tool-plan.d.ts +2 -0
- package/src/api/child-tool-plan.d.ts.map +1 -0
- package/src/api/child-tool-plan.js +2 -0
- package/src/api/child-tool-plan.js.map +1 -0
- package/src/api/control-channel.d.ts +2 -0
- package/src/api/control-channel.d.ts.map +1 -0
- package/src/api/control-channel.js +2 -0
- package/src/api/control-channel.js.map +1 -0
- package/src/api/delegation.d.ts +99 -0
- package/src/api/delegation.d.ts.map +1 -0
- package/src/api/delegation.js +9 -0
- package/src/api/delegation.js.map +1 -0
- package/src/api/external-job-provider.d.ts +58 -0
- package/src/api/external-job-provider.d.ts.map +1 -0
- package/src/api/external-job-provider.js +140 -0
- package/src/api/external-job-provider.js.map +1 -0
- package/src/api/external-runs.d.ts +48 -0
- package/src/api/external-runs.d.ts.map +1 -0
- package/src/api/external-runs.js +245 -0
- package/src/api/external-runs.js.map +1 -0
- package/src/api/intercom-bridge.d.ts +2 -0
- package/src/api/intercom-bridge.d.ts.map +1 -0
- package/src/api/intercom-bridge.js +2 -0
- package/src/api/intercom-bridge.js.map +1 -0
- package/src/api/preflight.d.ts +173 -0
- package/src/api/preflight.d.ts.map +1 -0
- package/src/api/preflight.js +362 -0
- package/src/api/preflight.js.map +1 -0
- package/src/api/project-panes.d.ts +8 -0
- package/src/api/project-panes.d.ts.map +1 -0
- package/src/api/project-panes.js +8 -0
- package/src/api/project-panes.js.map +1 -0
- package/src/api/required-child-extensions.d.ts +2 -0
- package/src/api/required-child-extensions.d.ts.map +1 -0
- package/src/api/required-child-extensions.js +2 -0
- package/src/api/required-child-extensions.js.map +1 -0
- package/src/api/shared-types.d.ts +2 -0
- package/src/api/shared-types.d.ts.map +1 -0
- package/src/api/shared-types.js +2 -0
- package/src/api/shared-types.js.map +1 -0
- package/src/api/workflow-resources.d.ts +3 -0
- package/src/api/workflow-resources.d.ts.map +1 -0
- package/src/api/workflow-resources.js +2 -0
- package/src/api/workflow-resources.js.map +1 -0
- package/src/extension/config.d.ts +8 -0
- package/src/extension/config.d.ts.map +1 -0
- package/src/extension/config.js +245 -0
- package/src/extension/config.js.map +1 -0
- package/src/extension/control-notices.d.ts +19 -0
- package/src/extension/control-notices.d.ts.map +1 -0
- package/src/extension/control-notices.js +34 -0
- package/src/extension/control-notices.js.map +1 -0
- package/src/extension/doctor.d.ts +33 -0
- package/src/extension/doctor.d.ts.map +1 -0
- package/src/extension/doctor.js +231 -0
- package/src/extension/doctor.js.map +1 -0
- package/src/extension/fanout-child.d.ts +7 -0
- package/src/extension/fanout-child.d.ts.map +1 -0
- package/src/extension/fanout-child.js +261 -0
- package/src/extension/fanout-child.js.map +1 -0
- package/src/extension/herdr-pi-bridge.d.ts +17 -0
- package/src/extension/herdr-pi-bridge.d.ts.map +1 -0
- package/src/extension/herdr-pi-bridge.js +243 -0
- package/src/extension/herdr-pi-bridge.js.map +1 -0
- package/src/extension/index.d.ts +20 -0
- package/src/extension/index.d.ts.map +1 -0
- package/src/extension/index.js +1108 -0
- package/src/extension/index.js.map +1 -0
- package/src/extension/public-execution.d.ts +62 -0
- package/src/extension/public-execution.d.ts.map +1 -0
- package/src/extension/public-execution.js +174 -0
- package/src/extension/public-execution.js.map +1 -0
- package/src/extension/rpc.d.ts +83 -0
- package/src/extension/rpc.d.ts.map +1 -0
- package/src/extension/rpc.js +687 -0
- package/src/extension/rpc.js.map +1 -0
- package/src/extension/schemas.d.ts +252 -0
- package/src/extension/schemas.d.ts.map +1 -0
- package/src/extension/schemas.js +396 -0
- package/src/extension/schemas.js.map +1 -0
- package/src/extension/steering-notices.d.ts +15 -0
- package/src/extension/steering-notices.d.ts.map +1 -0
- package/src/extension/steering-notices.js +23 -0
- package/src/extension/steering-notices.js.map +1 -0
- package/src/extension/subagent-guide.d.ts +4 -0
- package/src/extension/subagent-guide.d.ts.map +1 -0
- package/src/extension/subagent-guide.js +35 -0
- package/src/extension/subagent-guide.js.map +1 -0
- package/src/extension/tool-description.d.ts +20 -0
- package/src/extension/tool-description.d.ts.map +1 -0
- package/src/extension/tool-description.js +160 -0
- package/src/extension/tool-description.js.map +1 -0
- package/src/extension/tool-result.d.ts +10 -0
- package/src/extension/tool-result.d.ts.map +1 -0
- package/src/extension/tool-result.js +17 -0
- package/src/extension/tool-result.js.map +1 -0
- package/src/inspectors/actions.d.ts +23 -0
- package/src/inspectors/actions.d.ts.map +1 -0
- package/src/inspectors/actions.js +155 -0
- package/src/inspectors/actions.js.map +1 -0
- package/src/inspectors/ghostty/actions.d.ts +12 -0
- package/src/inspectors/ghostty/actions.d.ts.map +1 -0
- package/src/inspectors/ghostty/actions.js +63 -0
- package/src/inspectors/ghostty/actions.js.map +1 -0
- package/src/inspectors/ghostty/plugin.d.ts +8 -0
- package/src/inspectors/ghostty/plugin.d.ts.map +1 -0
- package/src/inspectors/ghostty/plugin.js +24 -0
- package/src/inspectors/ghostty/plugin.js.map +1 -0
- package/src/inspectors/herdr/actions.d.ts +26 -0
- package/src/inspectors/herdr/actions.d.ts.map +1 -0
- package/src/inspectors/herdr/actions.js +134 -0
- package/src/inspectors/herdr/actions.js.map +1 -0
- package/src/inspectors/herdr/client.d.ts +42 -0
- package/src/inspectors/herdr/client.d.ts.map +1 -0
- package/src/inspectors/herdr/client.js +130 -0
- package/src/inspectors/herdr/client.js.map +1 -0
- package/src/inspectors/herdr/focus.d.ts +25 -0
- package/src/inspectors/herdr/focus.d.ts.map +1 -0
- package/src/inspectors/herdr/focus.js +50 -0
- package/src/inspectors/herdr/focus.js.map +1 -0
- package/src/inspectors/herdr/plugin.d.ts +7 -0
- package/src/inspectors/herdr/plugin.d.ts.map +1 -0
- package/src/inspectors/herdr/plugin.js +15 -0
- package/src/inspectors/herdr/plugin.js.map +1 -0
- package/src/inspectors/herdr/project-panes.d.ts +137 -0
- package/src/inspectors/herdr/project-panes.d.ts.map +1 -0
- package/src/inspectors/herdr/project-panes.js +608 -0
- package/src/inspectors/herdr/project-panes.js.map +1 -0
- package/src/inspectors/inspector-runner.d.ts +24 -0
- package/src/inspectors/inspector-runner.d.ts.map +1 -0
- package/src/inspectors/inspector-runner.js +162 -0
- package/src/inspectors/inspector-runner.js.map +1 -0
- package/src/inspectors/plugins.d.ts +4 -0
- package/src/inspectors/plugins.d.ts.map +1 -0
- package/src/inspectors/plugins.js +7 -0
- package/src/inspectors/plugins.js.map +1 -0
- package/src/inspectors/session-roots-codec.d.ts +16 -0
- package/src/inspectors/session-roots-codec.d.ts.map +1 -0
- package/src/inspectors/session-roots-codec.js +33 -0
- package/src/inspectors/session-roots-codec.js.map +1 -0
- package/src/inspectors/shell-command.d.ts +2 -0
- package/src/inspectors/shell-command.d.ts.map +1 -0
- package/src/inspectors/shell-command.js +17 -0
- package/src/inspectors/shell-command.js.map +1 -0
- package/src/inspectors/types.d.ts +49 -0
- package/src/inspectors/types.d.ts.map +1 -0
- package/src/inspectors/types.js +2 -0
- package/src/inspectors/types.js.map +1 -0
- package/src/integrations/herdr-status.d.ts +46 -0
- package/src/integrations/herdr-status.d.ts.map +1 -0
- package/src/integrations/herdr-status.js +371 -0
- package/src/integrations/herdr-status.js.map +1 -0
- package/src/integrations/pi-web-session-liveness.d.ts +20 -0
- package/src/integrations/pi-web-session-liveness.d.ts.map +1 -0
- package/src/integrations/pi-web-session-liveness.js +54 -0
- package/src/integrations/pi-web-session-liveness.js.map +1 -0
- package/src/intercom/intercom-bridge.d.ts +59 -0
- package/src/intercom/intercom-bridge.d.ts.map +1 -0
- package/src/intercom/intercom-bridge.js +192 -0
- package/src/intercom/intercom-bridge.js.map +1 -0
- package/src/intercom/native-supervisor-channel.d.ts +64 -0
- package/src/intercom/native-supervisor-channel.d.ts.map +1 -0
- package/src/intercom/native-supervisor-channel.js +894 -0
- package/src/intercom/native-supervisor-channel.js.map +1 -0
- package/src/intercom/result-intercom.d.ts +36 -0
- package/src/intercom/result-intercom.d.ts.map +1 -0
- package/src/intercom/result-intercom.js +372 -0
- package/src/intercom/result-intercom.js.map +1 -0
- package/src/intercom/supervisor-ui.d.ts +40 -0
- package/src/intercom/supervisor-ui.d.ts.map +1 -0
- package/src/intercom/supervisor-ui.js +202 -0
- package/src/intercom/supervisor-ui.js.map +1 -0
- package/src/missions/actions.d.ts +55 -0
- package/src/missions/actions.d.ts.map +1 -0
- package/src/missions/actions.js +396 -0
- package/src/missions/actions.js.map +1 -0
- package/src/missions/goal-driver.d.ts +16 -0
- package/src/missions/goal-driver.d.ts.map +1 -0
- package/src/missions/goal-driver.js +157 -0
- package/src/missions/goal-driver.js.map +1 -0
- package/src/missions/lifecycle.d.ts +40 -0
- package/src/missions/lifecycle.d.ts.map +1 -0
- package/src/missions/lifecycle.js +352 -0
- package/src/missions/lifecycle.js.map +1 -0
- package/src/missions/store.d.ts +22 -0
- package/src/missions/store.d.ts.map +1 -0
- package/src/missions/store.js +573 -0
- package/src/missions/store.js.map +1 -0
- package/src/missions/types.d.ts +168 -0
- package/src/missions/types.d.ts.map +1 -0
- package/src/missions/types.js +10 -0
- package/src/missions/types.js.map +1 -0
- package/src/missions/workflow-state.d.ts +15 -0
- package/src/missions/workflow-state.d.ts.map +1 -0
- package/src/missions/workflow-state.js +274 -0
- package/src/missions/workflow-state.js.map +1 -0
- package/src/policy/authority.d.ts +10 -0
- package/src/policy/authority.d.ts.map +1 -0
- package/src/policy/authority.js +42 -0
- package/src/policy/authority.js.map +1 -0
- package/src/profiles/profiles.d.ts +135 -0
- package/src/profiles/profiles.d.ts.map +1 -0
- package/src/profiles/profiles.js +520 -0
- package/src/profiles/profiles.js.map +1 -0
- package/src/runs/background/active-async-capacity.d.ts +100 -0
- package/src/runs/background/active-async-capacity.d.ts.map +1 -0
- package/src/runs/background/active-async-capacity.js +492 -0
- package/src/runs/background/active-async-capacity.js.map +1 -0
- package/src/runs/background/active-run-index.d.ts +13 -0
- package/src/runs/background/active-run-index.d.ts.map +1 -0
- package/src/runs/background/active-run-index.js +158 -0
- package/src/runs/background/active-run-index.js.map +1 -0
- package/src/runs/background/async-execution.d.ts +274 -0
- package/src/runs/background/async-execution.d.ts.map +1 -0
- package/src/runs/background/async-execution.js +1989 -0
- package/src/runs/background/async-execution.js.map +1 -0
- package/src/runs/background/async-job-tracker.d.ts +28 -0
- package/src/runs/background/async-job-tracker.d.ts.map +1 -0
- package/src/runs/background/async-job-tracker.js +876 -0
- package/src/runs/background/async-job-tracker.js.map +1 -0
- package/src/runs/background/async-resume.d.ts +59 -0
- package/src/runs/background/async-resume.d.ts.map +1 -0
- package/src/runs/background/async-resume.js +670 -0
- package/src/runs/background/async-resume.js.map +1 -0
- package/src/runs/background/async-retention.d.ts +45 -0
- package/src/runs/background/async-retention.d.ts.map +1 -0
- package/src/runs/background/async-retention.js +884 -0
- package/src/runs/background/async-retention.js.map +1 -0
- package/src/runs/background/async-status-snapshot.d.ts +10 -0
- package/src/runs/background/async-status-snapshot.d.ts.map +1 -0
- package/src/runs/background/async-status-snapshot.js +25 -0
- package/src/runs/background/async-status-snapshot.js.map +1 -0
- package/src/runs/background/async-status.d.ts +169 -0
- package/src/runs/background/async-status.d.ts.map +1 -0
- package/src/runs/background/async-status.js +673 -0
- package/src/runs/background/async-status.js.map +1 -0
- package/src/runs/background/auto-drain.d.ts +17 -0
- package/src/runs/background/auto-drain.d.ts.map +1 -0
- package/src/runs/background/auto-drain.js +73 -0
- package/src/runs/background/auto-drain.js.map +1 -0
- package/src/runs/background/binary-bootstrap.d.ts +9 -0
- package/src/runs/background/binary-bootstrap.d.ts.map +1 -0
- package/src/runs/background/binary-bootstrap.js +41 -0
- package/src/runs/background/binary-bootstrap.js.map +1 -0
- package/src/runs/background/chain-append.d.ts +35 -0
- package/src/runs/background/chain-append.d.ts.map +1 -0
- package/src/runs/background/chain-append.js +300 -0
- package/src/runs/background/chain-append.js.map +1 -0
- package/src/runs/background/chain-root-attachment.d.ts +49 -0
- package/src/runs/background/chain-root-attachment.d.ts.map +1 -0
- package/src/runs/background/chain-root-attachment.js +184 -0
- package/src/runs/background/chain-root-attachment.js.map +1 -0
- package/src/runs/background/completion-batcher.d.ts +52 -0
- package/src/runs/background/completion-batcher.d.ts.map +1 -0
- package/src/runs/background/completion-batcher.js +120 -0
- package/src/runs/background/completion-batcher.js.map +1 -0
- package/src/runs/background/completion-dedupe.d.ts +14 -0
- package/src/runs/background/completion-dedupe.d.ts.map +1 -0
- package/src/runs/background/completion-dedupe.js +49 -0
- package/src/runs/background/completion-dedupe.js.map +1 -0
- package/src/runs/background/completion-replay.d.ts +48 -0
- package/src/runs/background/completion-replay.d.ts.map +1 -0
- package/src/runs/background/completion-replay.js +267 -0
- package/src/runs/background/completion-replay.js.map +1 -0
- package/src/runs/background/control-channel.d.ts +156 -0
- package/src/runs/background/control-channel.d.ts.map +1 -0
- package/src/runs/background/control-channel.js +521 -0
- package/src/runs/background/control-channel.js.map +1 -0
- package/src/runs/background/fleet-view.d.ts +64 -0
- package/src/runs/background/fleet-view.d.ts.map +1 -0
- package/src/runs/background/fleet-view.js +648 -0
- package/src/runs/background/fleet-view.js.map +1 -0
- package/src/runs/background/index-segment.d.ts +16 -0
- package/src/runs/background/index-segment.d.ts.map +1 -0
- package/src/runs/background/index-segment.js +59 -0
- package/src/runs/background/index-segment.js.map +1 -0
- package/src/runs/background/inspect-rpc.d.ts +60 -0
- package/src/runs/background/inspect-rpc.d.ts.map +1 -0
- package/src/runs/background/inspect-rpc.js +406 -0
- package/src/runs/background/inspect-rpc.js.map +1 -0
- package/src/runs/background/notify.d.ts +162 -0
- package/src/runs/background/notify.d.ts.map +1 -0
- package/src/runs/background/notify.js +665 -0
- package/src/runs/background/notify.js.map +1 -0
- package/src/runs/background/owned-process-tree.d.ts +11 -0
- package/src/runs/background/owned-process-tree.d.ts.map +1 -0
- package/src/runs/background/owned-process-tree.js +117 -0
- package/src/runs/background/owned-process-tree.js.map +1 -0
- package/src/runs/background/parallel-groups.d.ts +4 -0
- package/src/runs/background/parallel-groups.d.ts.map +1 -0
- package/src/runs/background/parallel-groups.js +47 -0
- package/src/runs/background/parallel-groups.js.map +1 -0
- package/src/runs/background/process-terminal.d.ts +34 -0
- package/src/runs/background/process-terminal.d.ts.map +1 -0
- package/src/runs/background/process-terminal.js +305 -0
- package/src/runs/background/process-terminal.js.map +1 -0
- package/src/runs/background/result-delivery-ownership.d.ts +11 -0
- package/src/runs/background/result-delivery-ownership.d.ts.map +1 -0
- package/src/runs/background/result-delivery-ownership.js +37 -0
- package/src/runs/background/result-delivery-ownership.js.map +1 -0
- package/src/runs/background/result-files.d.ts +33 -0
- package/src/runs/background/result-files.d.ts.map +1 -0
- package/src/runs/background/result-files.js +528 -0
- package/src/runs/background/result-files.js.map +1 -0
- package/src/runs/background/result-watcher.d.ts +87 -0
- package/src/runs/background/result-watcher.d.ts.map +1 -0
- package/src/runs/background/result-watcher.js +764 -0
- package/src/runs/background/result-watcher.js.map +1 -0
- package/src/runs/background/resume-guidance.d.ts +5 -0
- package/src/runs/background/resume-guidance.d.ts.map +1 -0
- package/src/runs/background/resume-guidance.js +57 -0
- package/src/runs/background/resume-guidance.js.map +1 -0
- package/src/runs/background/retained-children.d.ts +25 -0
- package/src/runs/background/retained-children.d.ts.map +1 -0
- package/src/runs/background/retained-children.js +128 -0
- package/src/runs/background/retained-children.js.map +1 -0
- package/src/runs/background/retained-nested-route-tracker.d.ts +13 -0
- package/src/runs/background/retained-nested-route-tracker.d.ts.map +1 -0
- package/src/runs/background/retained-nested-route-tracker.js +91 -0
- package/src/runs/background/retained-nested-route-tracker.js.map +1 -0
- package/src/runs/background/run-child-session.d.ts +123 -0
- package/src/runs/background/run-child-session.d.ts.map +1 -0
- package/src/runs/background/run-child-session.js +602 -0
- package/src/runs/background/run-child-session.js.map +1 -0
- package/src/runs/background/run-id-query.d.ts +4 -0
- package/src/runs/background/run-id-query.d.ts.map +1 -0
- package/src/runs/background/run-id-query.js +7 -0
- package/src/runs/background/run-id-query.js.map +1 -0
- package/src/runs/background/run-id-resolver.d.ts +23 -0
- package/src/runs/background/run-id-resolver.d.ts.map +1 -0
- package/src/runs/background/run-id-resolver.js +170 -0
- package/src/runs/background/run-id-resolver.js.map +1 -0
- package/src/runs/background/run-status.d.ts +26 -0
- package/src/runs/background/run-status.d.ts.map +1 -0
- package/src/runs/background/run-status.js +826 -0
- package/src/runs/background/run-status.js.map +1 -0
- package/src/runs/background/runner-aliases.d.ts +17 -0
- package/src/runs/background/runner-aliases.d.ts.map +1 -0
- package/src/runs/background/runner-aliases.js +141 -0
- package/src/runs/background/runner-aliases.js.map +1 -0
- package/src/runs/background/runner-child-launch.d.ts +24 -0
- package/src/runs/background/runner-child-launch.d.ts.map +1 -0
- package/src/runs/background/runner-child-launch.js +68 -0
- package/src/runs/background/runner-child-launch.js.map +1 -0
- package/src/runs/background/runner-child-sessions.d.ts +7 -0
- package/src/runs/background/runner-child-sessions.d.ts.map +1 -0
- package/src/runs/background/runner-child-sessions.js +35 -0
- package/src/runs/background/runner-child-sessions.js.map +1 -0
- package/src/runs/background/runner-http-dispatcher.d.ts +43 -0
- package/src/runs/background/runner-http-dispatcher.d.ts.map +1 -0
- package/src/runs/background/runner-http-dispatcher.js +114 -0
- package/src/runs/background/runner-http-dispatcher.js.map +1 -0
- package/src/runs/background/scheduled-runs.d.ts +116 -0
- package/src/runs/background/scheduled-runs.d.ts.map +1 -0
- package/src/runs/background/scheduled-runs.js +1024 -0
- package/src/runs/background/scheduled-runs.js.map +1 -0
- package/src/runs/background/stale-run-reconciler.d.ts +37 -0
- package/src/runs/background/stale-run-reconciler.d.ts.map +1 -0
- package/src/runs/background/stale-run-reconciler.js +393 -0
- package/src/runs/background/stale-run-reconciler.js.map +1 -0
- package/src/runs/background/steering.d.ts +52 -0
- package/src/runs/background/steering.d.ts.map +1 -0
- package/src/runs/background/steering.js +247 -0
- package/src/runs/background/steering.js.map +1 -0
- package/src/runs/background/subagent-runner.d.ts +201 -0
- package/src/runs/background/subagent-runner.d.ts.map +1 -0
- package/src/runs/background/subagent-runner.js +5134 -0
- package/src/runs/background/subagent-runner.js.map +1 -0
- package/src/runs/background/subagent-wait.d.ts +122 -0
- package/src/runs/background/subagent-wait.d.ts.map +1 -0
- package/src/runs/background/subagent-wait.js +735 -0
- package/src/runs/background/subagent-wait.js.map +1 -0
- package/src/runs/background/terminal-run-index.d.ts +8 -0
- package/src/runs/background/terminal-run-index.d.ts.map +1 -0
- package/src/runs/background/terminal-run-index.js +123 -0
- package/src/runs/background/terminal-run-index.js.map +1 -0
- package/src/runs/background/top-level-async.d.ts +8 -0
- package/src/runs/background/top-level-async.d.ts.map +1 -0
- package/src/runs/background/top-level-async.js +6 -0
- package/src/runs/background/top-level-async.js.map +1 -0
- package/src/runs/background/wait-completions.d.ts +29 -0
- package/src/runs/background/wait-completions.d.ts.map +1 -0
- package/src/runs/background/wait-completions.js +264 -0
- package/src/runs/background/wait-completions.js.map +1 -0
- package/src/runs/background/wait-config.d.ts +9 -0
- package/src/runs/background/wait-config.d.ts.map +1 -0
- package/src/runs/background/wait-config.js +47 -0
- package/src/runs/background/wait-config.js.map +1 -0
- package/src/runs/background/wait-subscriptions.d.ts +27 -0
- package/src/runs/background/wait-subscriptions.d.ts.map +1 -0
- package/src/runs/background/wait-subscriptions.js +337 -0
- package/src/runs/background/wait-subscriptions.js.map +1 -0
- package/src/runs/background/wait-tool.d.ts +7 -0
- package/src/runs/background/wait-tool.d.ts.map +1 -0
- package/src/runs/background/wait-tool.js +36 -0
- package/src/runs/background/wait-tool.js.map +1 -0
- package/src/runs/foreground/async-dismiss-action.d.ts +7 -0
- package/src/runs/foreground/async-dismiss-action.d.ts.map +1 -0
- package/src/runs/foreground/async-dismiss-action.js +82 -0
- package/src/runs/foreground/async-dismiss-action.js.map +1 -0
- package/src/runs/foreground/async-steering-action.d.ts +32 -0
- package/src/runs/foreground/async-steering-action.d.ts.map +1 -0
- package/src/runs/foreground/async-steering-action.js +270 -0
- package/src/runs/foreground/async-steering-action.js.map +1 -0
- package/src/runs/foreground/async-stop-action.d.ts +7 -0
- package/src/runs/foreground/async-stop-action.d.ts.map +1 -0
- package/src/runs/foreground/async-stop-action.js +171 -0
- package/src/runs/foreground/async-stop-action.js.map +1 -0
- package/src/runs/foreground/execution.d.ts +11 -0
- package/src/runs/foreground/execution.d.ts.map +1 -0
- package/src/runs/foreground/execution.js +2186 -0
- package/src/runs/foreground/execution.js.map +1 -0
- package/src/runs/foreground/foreground-control.d.ts +25 -0
- package/src/runs/foreground/foreground-control.d.ts.map +1 -0
- package/src/runs/foreground/foreground-control.js +139 -0
- package/src/runs/foreground/foreground-control.js.map +1 -0
- package/src/runs/foreground/foreground-history.d.ts +12 -0
- package/src/runs/foreground/foreground-history.d.ts.map +1 -0
- package/src/runs/foreground/foreground-history.js +165 -0
- package/src/runs/foreground/foreground-history.js.map +1 -0
- package/src/runs/foreground/prompt-audit.d.ts +33 -0
- package/src/runs/foreground/prompt-audit.d.ts.map +1 -0
- package/src/runs/foreground/prompt-audit.js +143 -0
- package/src/runs/foreground/prompt-audit.js.map +1 -0
- package/src/runs/foreground/subagent-executor.d.ts +296 -0
- package/src/runs/foreground/subagent-executor.d.ts.map +1 -0
- package/src/runs/foreground/subagent-executor.js +7047 -0
- package/src/runs/foreground/subagent-executor.js.map +1 -0
- package/src/runs/foreground/workflow-detach-reconcile.d.ts +16 -0
- package/src/runs/foreground/workflow-detach-reconcile.d.ts.map +1 -0
- package/src/runs/foreground/workflow-detach-reconcile.js +284 -0
- package/src/runs/foreground/workflow-detach-reconcile.js.map +1 -0
- package/src/runs/foreground/workflow-foreground-steering.d.ts +44 -0
- package/src/runs/foreground/workflow-foreground-steering.d.ts.map +1 -0
- package/src/runs/foreground/workflow-foreground-steering.js +149 -0
- package/src/runs/foreground/workflow-foreground-steering.js.map +1 -0
- package/src/runs/shared/abort-recovery.d.ts +27 -0
- package/src/runs/shared/abort-recovery.d.ts.map +1 -0
- package/src/runs/shared/abort-recovery.js +109 -0
- package/src/runs/shared/abort-recovery.js.map +1 -0
- package/src/runs/shared/acceptance.d.ts +145 -0
- package/src/runs/shared/acceptance.d.ts.map +1 -0
- package/src/runs/shared/acceptance.js +1650 -0
- package/src/runs/shared/acceptance.js.map +1 -0
- package/src/runs/shared/agent-contract.d.ts +6 -0
- package/src/runs/shared/agent-contract.d.ts.map +1 -0
- package/src/runs/shared/agent-contract.js +36 -0
- package/src/runs/shared/agent-contract.js.map +1 -0
- package/src/runs/shared/async-status-projection.d.ts +94 -0
- package/src/runs/shared/async-status-projection.d.ts.map +1 -0
- package/src/runs/shared/async-status-projection.js +542 -0
- package/src/runs/shared/async-status-projection.js.map +1 -0
- package/src/runs/shared/background-process-options.d.ts +5 -0
- package/src/runs/shared/background-process-options.d.ts.map +1 -0
- package/src/runs/shared/background-process-options.js +7 -0
- package/src/runs/shared/background-process-options.js.map +1 -0
- package/src/runs/shared/capability-ceiling.d.ts +58 -0
- package/src/runs/shared/capability-ceiling.d.ts.map +1 -0
- package/src/runs/shared/capability-ceiling.js +179 -0
- package/src/runs/shared/capability-ceiling.js.map +1 -0
- package/src/runs/shared/chain-outputs.d.ts +19 -0
- package/src/runs/shared/chain-outputs.d.ts.map +1 -0
- package/src/runs/shared/chain-outputs.js +105 -0
- package/src/runs/shared/chain-outputs.js.map +1 -0
- package/src/runs/shared/child-hooks.d.ts +34 -0
- package/src/runs/shared/child-hooks.d.ts.map +1 -0
- package/src/runs/shared/child-hooks.js +188 -0
- package/src/runs/shared/child-hooks.js.map +1 -0
- package/src/runs/shared/child-identity.d.ts +24 -0
- package/src/runs/shared/child-identity.d.ts.map +1 -0
- package/src/runs/shared/child-identity.js +41 -0
- package/src/runs/shared/child-identity.js.map +1 -0
- package/src/runs/shared/child-launch-plan.d.ts +71 -0
- package/src/runs/shared/child-launch-plan.d.ts.map +1 -0
- package/src/runs/shared/child-launch-plan.js +89 -0
- package/src/runs/shared/child-launch-plan.js.map +1 -0
- package/src/runs/shared/child-launch.d.ts +114 -0
- package/src/runs/shared/child-launch.d.ts.map +1 -0
- package/src/runs/shared/child-launch.js +231 -0
- package/src/runs/shared/child-launch.js.map +1 -0
- package/src/runs/shared/child-lifecycle.d.ts +14 -0
- package/src/runs/shared/child-lifecycle.d.ts.map +1 -0
- package/src/runs/shared/child-lifecycle.js +23 -0
- package/src/runs/shared/child-lifecycle.js.map +1 -0
- package/src/runs/shared/child-runtime-config.d.ts +102 -0
- package/src/runs/shared/child-runtime-config.d.ts.map +1 -0
- package/src/runs/shared/child-runtime-config.js +39 -0
- package/src/runs/shared/child-runtime-config.js.map +1 -0
- package/src/runs/shared/child-session.d.ts +155 -0
- package/src/runs/shared/child-session.d.ts.map +1 -0
- package/src/runs/shared/child-session.js +347 -0
- package/src/runs/shared/child-session.js.map +1 -0
- package/src/runs/shared/child-tool-plan.d.ts +73 -0
- package/src/runs/shared/child-tool-plan.d.ts.map +1 -0
- package/src/runs/shared/child-tool-plan.js +380 -0
- package/src/runs/shared/child-tool-plan.js.map +1 -0
- package/src/runs/shared/claude-code-adapter.d.ts +25 -0
- package/src/runs/shared/claude-code-adapter.d.ts.map +1 -0
- package/src/runs/shared/claude-code-adapter.js +120 -0
- package/src/runs/shared/claude-code-adapter.js.map +1 -0
- package/src/runs/shared/codex-exec-adapter.d.ts +26 -0
- package/src/runs/shared/codex-exec-adapter.d.ts.map +1 -0
- package/src/runs/shared/codex-exec-adapter.js +128 -0
- package/src/runs/shared/codex-exec-adapter.js.map +1 -0
- package/src/runs/shared/completion-evidence.d.ts +31 -0
- package/src/runs/shared/completion-evidence.d.ts.map +1 -0
- package/src/runs/shared/completion-evidence.js +54 -0
- package/src/runs/shared/completion-evidence.js.map +1 -0
- package/src/runs/shared/completion-guard.d.ts +35 -0
- package/src/runs/shared/completion-guard.d.ts.map +1 -0
- package/src/runs/shared/completion-guard.js +214 -0
- package/src/runs/shared/completion-guard.js.map +1 -0
- package/src/runs/shared/context-mode.d.ts +13 -0
- package/src/runs/shared/context-mode.d.ts.map +1 -0
- package/src/runs/shared/context-mode.js +39 -0
- package/src/runs/shared/context-mode.js.map +1 -0
- package/src/runs/shared/cursor-agent-adapter.d.ts +27 -0
- package/src/runs/shared/cursor-agent-adapter.d.ts.map +1 -0
- package/src/runs/shared/cursor-agent-adapter.js +100 -0
- package/src/runs/shared/cursor-agent-adapter.js.map +1 -0
- package/src/runs/shared/dynamic-fanout.d.ts +50 -0
- package/src/runs/shared/dynamic-fanout.d.ts.map +1 -0
- package/src/runs/shared/dynamic-fanout.js +274 -0
- package/src/runs/shared/dynamic-fanout.js.map +1 -0
- package/src/runs/shared/effective-system-prompt.d.ts +18 -0
- package/src/runs/shared/effective-system-prompt.d.ts.map +1 -0
- package/src/runs/shared/effective-system-prompt.js +23 -0
- package/src/runs/shared/effective-system-prompt.js.map +1 -0
- package/src/runs/shared/extension-bindings.d.ts +17 -0
- package/src/runs/shared/extension-bindings.d.ts.map +1 -0
- package/src/runs/shared/extension-bindings.js +83 -0
- package/src/runs/shared/extension-bindings.js.map +1 -0
- package/src/runs/shared/external-cli-contract.d.ts +30 -0
- package/src/runs/shared/external-cli-contract.d.ts.map +1 -0
- package/src/runs/shared/external-cli-contract.js +146 -0
- package/src/runs/shared/external-cli-contract.js.map +1 -0
- package/src/runs/shared/external-cli-preflight.d.ts +32 -0
- package/src/runs/shared/external-cli-preflight.d.ts.map +1 -0
- package/src/runs/shared/external-cli-preflight.js +116 -0
- package/src/runs/shared/external-cli-preflight.js.map +1 -0
- package/src/runs/shared/external-cli-runner.d.ts +66 -0
- package/src/runs/shared/external-cli-runner.d.ts.map +1 -0
- package/src/runs/shared/external-cli-runner.js +421 -0
- package/src/runs/shared/external-cli-runner.js.map +1 -0
- package/src/runs/shared/external-job-bridge.d.ts +18 -0
- package/src/runs/shared/external-job-bridge.d.ts.map +1 -0
- package/src/runs/shared/external-job-bridge.js +424 -0
- package/src/runs/shared/external-job-bridge.js.map +1 -0
- package/src/runs/shared/external-job-runner.d.ts +45 -0
- package/src/runs/shared/external-job-runner.d.ts.map +1 -0
- package/src/runs/shared/external-job-runner.js +353 -0
- package/src/runs/shared/external-job-runner.js.map +1 -0
- package/src/runs/shared/fast-mode-extension.d.ts +4 -0
- package/src/runs/shared/fast-mode-extension.d.ts.map +1 -0
- package/src/runs/shared/fast-mode-extension.js +9 -0
- package/src/runs/shared/fast-mode-extension.js.map +1 -0
- package/src/runs/shared/herdr-connection.d.ts +71 -0
- package/src/runs/shared/herdr-connection.d.ts.map +1 -0
- package/src/runs/shared/herdr-connection.js +258 -0
- package/src/runs/shared/herdr-connection.js.map +1 -0
- package/src/runs/shared/herdr-external-adapters.d.ts +148 -0
- package/src/runs/shared/herdr-external-adapters.d.ts.map +1 -0
- package/src/runs/shared/herdr-external-adapters.js +405 -0
- package/src/runs/shared/herdr-external-adapters.js.map +1 -0
- package/src/runs/shared/herdr-machine.d.ts +48 -0
- package/src/runs/shared/herdr-machine.d.ts.map +1 -0
- package/src/runs/shared/herdr-machine.js +247 -0
- package/src/runs/shared/herdr-machine.js.map +1 -0
- package/src/runs/shared/herdr-pi-protocol.d.ts +22 -0
- package/src/runs/shared/herdr-pi-protocol.d.ts.map +1 -0
- package/src/runs/shared/herdr-pi-protocol.js +58 -0
- package/src/runs/shared/herdr-pi-protocol.js.map +1 -0
- package/src/runs/shared/herdr-placed-run.d.ts +267 -0
- package/src/runs/shared/herdr-placed-run.d.ts.map +1 -0
- package/src/runs/shared/herdr-placed-run.js +716 -0
- package/src/runs/shared/herdr-placed-run.js.map +1 -0
- package/src/runs/shared/host-step-status.d.ts +34 -0
- package/src/runs/shared/host-step-status.d.ts.map +1 -0
- package/src/runs/shared/host-step-status.js +245 -0
- package/src/runs/shared/host-step-status.js.map +1 -0
- package/src/runs/shared/lane-metadata.d.ts +24 -0
- package/src/runs/shared/lane-metadata.d.ts.map +1 -0
- package/src/runs/shared/lane-metadata.js +127 -0
- package/src/runs/shared/lane-metadata.js.map +1 -0
- package/src/runs/shared/launch-cwd.d.ts +2 -0
- package/src/runs/shared/launch-cwd.d.ts.map +1 -0
- package/src/runs/shared/launch-cwd.js +17 -0
- package/src/runs/shared/launch-cwd.js.map +1 -0
- package/src/runs/shared/llm-intent-arbiter.d.ts +48 -0
- package/src/runs/shared/llm-intent-arbiter.d.ts.map +1 -0
- package/src/runs/shared/llm-intent-arbiter.js +235 -0
- package/src/runs/shared/llm-intent-arbiter.js.map +1 -0
- package/src/runs/shared/long-running-guard.d.ts +33 -0
- package/src/runs/shared/long-running-guard.d.ts.map +1 -0
- package/src/runs/shared/long-running-guard.js +199 -0
- package/src/runs/shared/long-running-guard.js.map +1 -0
- package/src/runs/shared/mcp-config-sources.d.ts +30 -0
- package/src/runs/shared/mcp-config-sources.d.ts.map +1 -0
- package/src/runs/shared/mcp-config-sources.js +419 -0
- package/src/runs/shared/mcp-config-sources.js.map +1 -0
- package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +59 -0
- package/src/runs/shared/mcp-direct-tool-allowlist.d.ts.map +1 -0
- package/src/runs/shared/mcp-direct-tool-allowlist.js +400 -0
- package/src/runs/shared/mcp-direct-tool-allowlist.js.map +1 -0
- package/src/runs/shared/mcp-direct-tool-grant.d.ts +41 -0
- package/src/runs/shared/mcp-direct-tool-grant.d.ts.map +1 -0
- package/src/runs/shared/mcp-direct-tool-grant.js +146 -0
- package/src/runs/shared/mcp-direct-tool-grant.js.map +1 -0
- package/src/runs/shared/model-resolution-diagnostic.d.ts +22 -0
- package/src/runs/shared/model-resolution-diagnostic.d.ts.map +1 -0
- package/src/runs/shared/model-resolution-diagnostic.js +65 -0
- package/src/runs/shared/model-resolution-diagnostic.js.map +1 -0
- package/src/runs/shared/model-resolution.d.ts +92 -0
- package/src/runs/shared/model-resolution.d.ts.map +1 -0
- package/src/runs/shared/model-resolution.js +343 -0
- package/src/runs/shared/model-resolution.js.map +1 -0
- package/src/runs/shared/model-scope.d.ts +68 -0
- package/src/runs/shared/model-scope.d.ts.map +1 -0
- package/src/runs/shared/model-scope.js +156 -0
- package/src/runs/shared/model-scope.js.map +1 -0
- package/src/runs/shared/mutation-evidence.d.ts +19 -0
- package/src/runs/shared/mutation-evidence.d.ts.map +1 -0
- package/src/runs/shared/mutation-evidence.js +199 -0
- package/src/runs/shared/mutation-evidence.js.map +1 -0
- package/src/runs/shared/nested-events.d.ts +134 -0
- package/src/runs/shared/nested-events.d.ts.map +1 -0
- package/src/runs/shared/nested-events.js +1056 -0
- package/src/runs/shared/nested-events.js.map +1 -0
- package/src/runs/shared/nested-path.d.ts +9 -0
- package/src/runs/shared/nested-path.d.ts.map +1 -0
- package/src/runs/shared/nested-path.js +35 -0
- package/src/runs/shared/nested-path.js.map +1 -0
- package/src/runs/shared/nested-render.d.ts +21 -0
- package/src/runs/shared/nested-render.d.ts.map +1 -0
- package/src/runs/shared/nested-render.js +116 -0
- package/src/runs/shared/nested-render.js.map +1 -0
- package/src/runs/shared/orca-progress-tabs.d.ts +33 -0
- package/src/runs/shared/orca-progress-tabs.d.ts.map +1 -0
- package/src/runs/shared/orca-progress-tabs.js +527 -0
- package/src/runs/shared/orca-progress-tabs.js.map +1 -0
- package/src/runs/shared/parallel-handoff.d.ts +73 -0
- package/src/runs/shared/parallel-handoff.d.ts.map +1 -0
- package/src/runs/shared/parallel-handoff.js +733 -0
- package/src/runs/shared/parallel-handoff.js.map +1 -0
- package/src/runs/shared/parallel-utils.d.ts +165 -0
- package/src/runs/shared/parallel-utils.d.ts.map +1 -0
- package/src/runs/shared/parallel-utils.js +126 -0
- package/src/runs/shared/parallel-utils.js.map +1 -0
- package/src/runs/shared/permissions.d.ts +13 -0
- package/src/runs/shared/permissions.d.ts.map +1 -0
- package/src/runs/shared/permissions.js +93 -0
- package/src/runs/shared/permissions.js.map +1 -0
- package/src/runs/shared/pi-spawn.d.ts +28 -0
- package/src/runs/shared/pi-spawn.d.ts.map +1 -0
- package/src/runs/shared/pi-spawn.js +156 -0
- package/src/runs/shared/pi-spawn.js.map +1 -0
- package/src/runs/shared/process-signal.d.ts +16 -0
- package/src/runs/shared/process-signal.d.ts.map +1 -0
- package/src/runs/shared/process-signal.js +22 -0
- package/src/runs/shared/process-signal.js.map +1 -0
- package/src/runs/shared/readonly-drain-observation.d.ts +26 -0
- package/src/runs/shared/readonly-drain-observation.d.ts.map +1 -0
- package/src/runs/shared/readonly-drain-observation.js +51 -0
- package/src/runs/shared/readonly-drain-observation.js.map +1 -0
- package/src/runs/shared/run-fanout-budget.d.ts +15 -0
- package/src/runs/shared/run-fanout-budget.d.ts.map +1 -0
- package/src/runs/shared/run-fanout-budget.js +259 -0
- package/src/runs/shared/run-fanout-budget.js.map +1 -0
- package/src/runs/shared/run-history.d.ts +20 -0
- package/src/runs/shared/run-history.d.ts.map +1 -0
- package/src/runs/shared/run-history.js +200 -0
- package/src/runs/shared/run-history.js.map +1 -0
- package/src/runs/shared/runtime-acknowledged-extensions.d.ts +8 -0
- package/src/runs/shared/runtime-acknowledged-extensions.d.ts.map +1 -0
- package/src/runs/shared/runtime-acknowledged-extensions.js +45 -0
- package/src/runs/shared/runtime-acknowledged-extensions.js.map +1 -0
- package/src/runs/shared/session-lease.d.ts +70 -0
- package/src/runs/shared/session-lease.d.ts.map +1 -0
- package/src/runs/shared/session-lease.js +251 -0
- package/src/runs/shared/session-lease.js.map +1 -0
- package/src/runs/shared/single-output.d.ts +61 -0
- package/src/runs/shared/single-output.d.ts.map +1 -0
- package/src/runs/shared/single-output.js +263 -0
- package/src/runs/shared/single-output.js.map +1 -0
- package/src/runs/shared/spawn-budget.d.ts +21 -0
- package/src/runs/shared/spawn-budget.d.ts.map +1 -0
- package/src/runs/shared/spawn-budget.js +94 -0
- package/src/runs/shared/spawn-budget.js.map +1 -0
- package/src/runs/shared/structured-output.d.ts +57 -0
- package/src/runs/shared/structured-output.d.ts.map +1 -0
- package/src/runs/shared/structured-output.js +391 -0
- package/src/runs/shared/structured-output.js.map +1 -0
- package/src/runs/shared/subagent-control.d.ts +50 -0
- package/src/runs/shared/subagent-control.d.ts.map +1 -0
- package/src/runs/shared/subagent-control.js +247 -0
- package/src/runs/shared/subagent-control.js.map +1 -0
- package/src/runs/shared/subagent-prompt-runtime.d.ts +28 -0
- package/src/runs/shared/subagent-prompt-runtime.d.ts.map +1 -0
- package/src/runs/shared/subagent-prompt-runtime.js +548 -0
- package/src/runs/shared/subagent-prompt-runtime.js.map +1 -0
- package/src/runs/shared/task-intent.d.ts +38 -0
- package/src/runs/shared/task-intent.d.ts.map +1 -0
- package/src/runs/shared/task-intent.js +213 -0
- package/src/runs/shared/task-intent.js.map +1 -0
- package/src/runs/shared/tool-availability.d.ts +17 -0
- package/src/runs/shared/tool-availability.d.ts.map +1 -0
- package/src/runs/shared/tool-availability.js +30 -0
- package/src/runs/shared/tool-availability.js.map +1 -0
- package/src/runs/shared/tool-budget.d.ts +22 -0
- package/src/runs/shared/tool-budget.d.ts.map +1 -0
- package/src/runs/shared/tool-budget.js +79 -0
- package/src/runs/shared/tool-budget.js.map +1 -0
- package/src/runs/shared/tool-timeout.d.ts +32 -0
- package/src/runs/shared/tool-timeout.d.ts.map +1 -0
- package/src/runs/shared/tool-timeout.js +74 -0
- package/src/runs/shared/tool-timeout.js.map +1 -0
- package/src/runs/shared/usage-budget.d.ts +8 -0
- package/src/runs/shared/usage-budget.d.ts.map +1 -0
- package/src/runs/shared/usage-budget.js +75 -0
- package/src/runs/shared/usage-budget.js.map +1 -0
- package/src/runs/shared/usage-reconciliation.d.ts +9 -0
- package/src/runs/shared/usage-reconciliation.d.ts.map +1 -0
- package/src/runs/shared/usage-reconciliation.js +72 -0
- package/src/runs/shared/usage-reconciliation.js.map +1 -0
- package/src/runs/shared/workflow-async-child-guidance.d.ts +4 -0
- package/src/runs/shared/workflow-async-child-guidance.d.ts.map +1 -0
- package/src/runs/shared/workflow-async-child-guidance.js +18 -0
- package/src/runs/shared/workflow-async-child-guidance.js.map +1 -0
- package/src/runs/shared/workflow-graph.d.ts +32 -0
- package/src/runs/shared/workflow-graph.d.ts.map +1 -0
- package/src/runs/shared/workflow-graph.js +222 -0
- package/src/runs/shared/workflow-graph.js.map +1 -0
- package/src/runs/shared/worktree-cleanup-plan.d.ts +78 -0
- package/src/runs/shared/worktree-cleanup-plan.d.ts.map +1 -0
- package/src/runs/shared/worktree-cleanup-plan.js +782 -0
- package/src/runs/shared/worktree-cleanup-plan.js.map +1 -0
- package/src/runs/shared/worktree-setup-command.d.ts +39 -0
- package/src/runs/shared/worktree-setup-command.d.ts.map +1 -0
- package/src/runs/shared/worktree-setup-command.js +201 -0
- package/src/runs/shared/worktree-setup-command.js.map +1 -0
- package/src/runs/shared/worktree.d.ts +179 -0
- package/src/runs/shared/worktree.d.ts.map +1 -0
- package/src/runs/shared/worktree.js +1333 -0
- package/src/runs/shared/worktree.js.map +1 -0
- package/src/shared/accessible-dir.d.ts +12 -0
- package/src/shared/accessible-dir.d.ts.map +1 -0
- package/src/shared/accessible-dir.js +37 -0
- package/src/shared/accessible-dir.js.map +1 -0
- package/src/shared/agent-stream-options.d.ts +6 -0
- package/src/shared/agent-stream-options.d.ts.map +1 -0
- package/src/shared/agent-stream-options.js +4 -0
- package/src/shared/agent-stream-options.js.map +1 -0
- package/src/shared/artifacts.d.ts +23 -0
- package/src/shared/artifacts.d.ts.map +1 -0
- package/src/shared/artifacts.js +273 -0
- package/src/shared/artifacts.js.map +1 -0
- package/src/shared/atomic-json.d.ts +19 -0
- package/src/shared/atomic-json.d.ts.map +1 -0
- package/src/shared/atomic-json.js +60 -0
- package/src/shared/atomic-json.js.map +1 -0
- package/src/shared/capacity-resilient-json.d.ts +27 -0
- package/src/shared/capacity-resilient-json.d.ts.map +1 -0
- package/src/shared/capacity-resilient-json.js +87 -0
- package/src/shared/capacity-resilient-json.js.map +1 -0
- package/src/shared/child-cache-retention.d.ts +30 -0
- package/src/shared/child-cache-retention.d.ts.map +1 -0
- package/src/shared/child-cache-retention.js +41 -0
- package/src/shared/child-cache-retention.js.map +1 -0
- package/src/shared/child-session-name.d.ts +9 -0
- package/src/shared/child-session-name.d.ts.map +1 -0
- package/src/shared/child-session-name.js +39 -0
- package/src/shared/child-session-name.js.map +1 -0
- package/src/shared/child-transcript.d.ts +38 -0
- package/src/shared/child-transcript.d.ts.map +1 -0
- package/src/shared/child-transcript.js +226 -0
- package/src/shared/child-transcript.js.map +1 -0
- package/src/shared/completion-owner.d.ts +3 -0
- package/src/shared/completion-owner.d.ts.map +1 -0
- package/src/shared/completion-owner.js +9 -0
- package/src/shared/completion-owner.js.map +1 -0
- package/src/shared/display-text.d.ts +6 -0
- package/src/shared/display-text.d.ts.map +1 -0
- package/src/shared/display-text.js +155 -0
- package/src/shared/display-text.js.map +1 -0
- package/src/shared/extension-context.d.ts +6 -0
- package/src/shared/extension-context.d.ts.map +1 -0
- package/src/shared/extension-context.js +22 -0
- package/src/shared/extension-context.js.map +1 -0
- package/src/shared/file-coalescer.d.ts +12 -0
- package/src/shared/file-coalescer.d.ts.map +1 -0
- package/src/shared/file-coalescer.js +35 -0
- package/src/shared/file-coalescer.js.map +1 -0
- package/src/shared/file-system-retry.d.ts +32 -0
- package/src/shared/file-system-retry.d.ts.map +1 -0
- package/src/shared/file-system-retry.js +85 -0
- package/src/shared/file-system-retry.js.map +1 -0
- package/src/shared/fork-context.d.ts +59 -0
- package/src/shared/fork-context.d.ts.map +1 -0
- package/src/shared/fork-context.js +171 -0
- package/src/shared/fork-context.js.map +1 -0
- package/src/shared/fork-session-cwd.d.ts +3 -0
- package/src/shared/fork-session-cwd.d.ts.map +1 -0
- package/src/shared/fork-session-cwd.js +24 -0
- package/src/shared/fork-session-cwd.js.map +1 -0
- package/src/shared/formatters.d.ts +36 -0
- package/src/shared/formatters.d.ts.map +1 -0
- package/src/shared/formatters.js +143 -0
- package/src/shared/formatters.js.map +1 -0
- package/src/shared/jsonl-writer.d.ts +21 -0
- package/src/shared/jsonl-writer.d.ts.map +1 -0
- package/src/shared/jsonl-writer.js +68 -0
- package/src/shared/jsonl-writer.js.map +1 -0
- package/src/shared/launch-contract.d.ts +64 -0
- package/src/shared/launch-contract.d.ts.map +1 -0
- package/src/shared/launch-contract.js +141 -0
- package/src/shared/launch-contract.js.map +1 -0
- package/src/shared/model-info.d.ts +44 -0
- package/src/shared/model-info.d.ts.map +1 -0
- package/src/shared/model-info.js +73 -0
- package/src/shared/model-info.js.map +1 -0
- package/src/shared/model-response-aliases.d.ts +2 -0
- package/src/shared/model-response-aliases.d.ts.map +1 -0
- package/src/shared/model-response-aliases.js +16 -0
- package/src/shared/model-response-aliases.js.map +1 -0
- package/src/shared/node-executable.d.ts +2 -0
- package/src/shared/node-executable.d.ts.map +1 -0
- package/src/shared/node-executable.js +21 -0
- package/src/shared/node-executable.js.map +1 -0
- package/src/shared/opencode-session-headers.d.ts +13 -0
- package/src/shared/opencode-session-headers.d.ts.map +1 -0
- package/src/shared/opencode-session-headers.js +27 -0
- package/src/shared/opencode-session-headers.js.map +1 -0
- package/src/shared/prompt-resources.d.ts +6 -0
- package/src/shared/prompt-resources.d.ts.map +1 -0
- package/src/shared/prompt-resources.js +11 -0
- package/src/shared/prompt-resources.js.map +1 -0
- package/src/shared/pruned-fork.d.ts +35 -0
- package/src/shared/pruned-fork.d.ts.map +1 -0
- package/src/shared/pruned-fork.js +424 -0
- package/src/shared/pruned-fork.js.map +1 -0
- package/src/shared/required-child-extensions.d.ts +20 -0
- package/src/shared/required-child-extensions.d.ts.map +1 -0
- package/src/shared/required-child-extensions.js +74 -0
- package/src/shared/required-child-extensions.js.map +1 -0
- package/src/shared/session-file-trust.d.ts +2 -0
- package/src/shared/session-file-trust.d.ts.map +1 -0
- package/src/shared/session-file-trust.js +21 -0
- package/src/shared/session-file-trust.js.map +1 -0
- package/src/shared/session-identity.d.ts +7 -0
- package/src/shared/session-identity.d.ts.map +1 -0
- package/src/shared/session-identity.js +7 -0
- package/src/shared/session-identity.js.map +1 -0
- package/src/shared/session-tokens.d.ts +3 -0
- package/src/shared/session-tokens.d.ts.map +1 -0
- package/src/shared/session-tokens.js +59 -0
- package/src/shared/session-tokens.js.map +1 -0
- package/src/shared/settings.d.ts +147 -0
- package/src/shared/settings.d.ts.map +1 -0
- package/src/shared/settings.js +248 -0
- package/src/shared/settings.js.map +1 -0
- package/src/shared/shortcuts.d.ts +2 -0
- package/src/shared/shortcuts.d.ts.map +1 -0
- package/src/shared/shortcuts.js +18 -0
- package/src/shared/shortcuts.js.map +1 -0
- package/src/shared/status-format.d.ts +10 -0
- package/src/shared/status-format.d.ts.map +1 -0
- package/src/shared/status-format.js +61 -0
- package/src/shared/status-format.js.map +1 -0
- package/src/shared/thinking-ceiling.d.ts +14 -0
- package/src/shared/thinking-ceiling.d.ts.map +1 -0
- package/src/shared/thinking-ceiling.js +38 -0
- package/src/shared/thinking-ceiling.js.map +1 -0
- package/src/shared/types.d.ts +2667 -0
- package/src/shared/types.d.ts.map +1 -0
- package/src/shared/types.js +265 -0
- package/src/shared/types.js.map +1 -0
- package/src/shared/utf8.d.ts +6 -0
- package/src/shared/utf8.d.ts.map +1 -0
- package/src/shared/utf8.js +13 -0
- package/src/shared/utf8.js.map +1 -0
- package/src/shared/utils.d.ts +71 -0
- package/src/shared/utils.d.ts.map +1 -0
- package/src/shared/utils.js +593 -0
- package/src/shared/utils.js.map +1 -0
- package/src/shared/watch-strategy.d.ts +3 -0
- package/src/shared/watch-strategy.d.ts.map +1 -0
- package/src/shared/watch-strategy.js +6 -0
- package/src/shared/watch-strategy.js.map +1 -0
- package/src/shared/workflow-child-permit.d.ts +59 -0
- package/src/shared/workflow-child-permit.d.ts.map +1 -0
- package/src/shared/workflow-child-permit.js +160 -0
- package/src/shared/workflow-child-permit.js.map +1 -0
- package/src/slash/delegation-adapters.d.ts +147 -0
- package/src/slash/delegation-adapters.d.ts.map +1 -0
- package/src/slash/delegation-adapters.js +293 -0
- package/src/slash/delegation-adapters.js.map +1 -0
- package/src/slash/delegation-json.d.ts +11 -0
- package/src/slash/delegation-json.d.ts.map +1 -0
- package/src/slash/delegation-json.js +118 -0
- package/src/slash/delegation-json.js.map +1 -0
- package/src/slash/delegation-request.d.ts +13 -0
- package/src/slash/delegation-request.d.ts.map +1 -0
- package/src/slash/delegation-request.js +175 -0
- package/src/slash/delegation-request.js.map +1 -0
- package/src/slash/prompt-template-bridge.d.ts +27 -0
- package/src/slash/prompt-template-bridge.d.ts.map +1 -0
- package/src/slash/prompt-template-bridge.js +380 -0
- package/src/slash/prompt-template-bridge.js.map +1 -0
- package/src/slash/prompt-workflows.d.ts +22 -0
- package/src/slash/prompt-workflows.d.ts.map +1 -0
- package/src/slash/prompt-workflows.js +261 -0
- package/src/slash/prompt-workflows.js.map +1 -0
- package/src/slash/selector.d.ts +48 -0
- package/src/slash/selector.d.ts.map +1 -0
- package/src/slash/selector.js +118 -0
- package/src/slash/selector.js.map +1 -0
- package/src/slash/slash-bridge.d.ts +31 -0
- package/src/slash/slash-bridge.d.ts.map +1 -0
- package/src/slash/slash-bridge.js +133 -0
- package/src/slash/slash-bridge.js.map +1 -0
- package/src/slash/slash-commands.d.ts +9 -0
- package/src/slash/slash-commands.d.ts.map +1 -0
- package/src/slash/slash-commands.js +1295 -0
- package/src/slash/slash-commands.js.map +1 -0
- package/src/slash/slash-live-state.d.ts +22 -0
- package/src/slash/slash-live-state.d.ts.map +1 -0
- package/src/slash/slash-live-state.js +264 -0
- package/src/slash/slash-live-state.js.map +1 -0
- package/src/slash/subagents-admin.d.ts +3 -0
- package/src/slash/subagents-admin.d.ts.map +1 -0
- package/src/slash/subagents-admin.js +454 -0
- package/src/slash/subagents-admin.js.map +1 -0
- package/src/tui/fleet-status.d.ts +86 -0
- package/src/tui/fleet-status.d.ts.map +1 -0
- package/src/tui/fleet-status.js +1083 -0
- package/src/tui/fleet-status.js.map +1 -0
- package/src/tui/fleet-transcript.d.ts +50 -0
- package/src/tui/fleet-transcript.d.ts.map +1 -0
- package/src/tui/fleet-transcript.js +497 -0
- package/src/tui/fleet-transcript.js.map +1 -0
- package/src/tui/fleet.d.ts +169 -0
- package/src/tui/fleet.d.ts.map +1 -0
- package/src/tui/fleet.js +1412 -0
- package/src/tui/fleet.js.map +1 -0
- package/src/tui/render-helpers.d.ts +24 -0
- package/src/tui/render-helpers.d.ts.map +1 -0
- package/src/tui/render-helpers.js +101 -0
- package/src/tui/render-helpers.js.map +1 -0
- package/src/tui/render.d.ts +61 -0
- package/src/tui/render.d.ts.map +1 -0
- package/src/tui/render.js +3607 -0
- package/src/tui/render.js.map +1 -0
- package/src/watchdog/change-signature.d.ts +8 -0
- package/src/watchdog/change-signature.d.ts.map +1 -0
- package/src/watchdog/change-signature.js +246 -0
- package/src/watchdog/change-signature.js.map +1 -0
- package/src/watchdog/child-status.d.ts +54 -0
- package/src/watchdog/child-status.d.ts.map +1 -0
- package/src/watchdog/child-status.js +188 -0
- package/src/watchdog/child-status.js.map +1 -0
- package/src/watchdog/diff-tool.d.ts +23 -0
- package/src/watchdog/diff-tool.d.ts.map +1 -0
- package/src/watchdog/diff-tool.js +84 -0
- package/src/watchdog/diff-tool.js.map +1 -0
- package/src/watchdog/emission-guard.d.ts +37 -0
- package/src/watchdog/emission-guard.d.ts.map +1 -0
- package/src/watchdog/emission-guard.js +98 -0
- package/src/watchdog/emission-guard.js.map +1 -0
- package/src/watchdog/guidance.d.ts +4 -0
- package/src/watchdog/guidance.d.ts.map +1 -0
- package/src/watchdog/guidance.js +20 -0
- package/src/watchdog/guidance.js.map +1 -0
- package/src/watchdog/lsp-diagnostics.d.ts +18 -0
- package/src/watchdog/lsp-diagnostics.d.ts.map +1 -0
- package/src/watchdog/lsp-diagnostics.js +490 -0
- package/src/watchdog/lsp-diagnostics.js.map +1 -0
- package/src/watchdog/model-selection.d.ts +25 -0
- package/src/watchdog/model-selection.d.ts.map +1 -0
- package/src/watchdog/model-selection.js +168 -0
- package/src/watchdog/model-selection.js.map +1 -0
- package/src/watchdog/permission-arbiter.d.ts +21 -0
- package/src/watchdog/permission-arbiter.d.ts.map +1 -0
- package/src/watchdog/permission-arbiter.js +136 -0
- package/src/watchdog/permission-arbiter.js.map +1 -0
- package/src/watchdog/register-child.d.ts +12 -0
- package/src/watchdog/register-child.d.ts.map +1 -0
- package/src/watchdog/register-child.js +120 -0
- package/src/watchdog/register-child.js.map +1 -0
- package/src/watchdog/register-main.d.ts +10 -0
- package/src/watchdog/register-main.d.ts.map +1 -0
- package/src/watchdog/register-main.js +419 -0
- package/src/watchdog/register-main.js.map +1 -0
- package/src/watchdog/render.d.ts +12 -0
- package/src/watchdog/render.d.ts.map +1 -0
- package/src/watchdog/render.js +52 -0
- package/src/watchdog/render.js.map +1 -0
- package/src/watchdog/review.d.ts +36 -0
- package/src/watchdog/review.d.ts.map +1 -0
- package/src/watchdog/review.js +318 -0
- package/src/watchdog/review.js.map +1 -0
- package/src/watchdog/rules.d.ts +22 -0
- package/src/watchdog/rules.d.ts.map +1 -0
- package/src/watchdog/rules.js +59 -0
- package/src/watchdog/rules.js.map +1 -0
- package/src/watchdog/runtime.d.ts +196 -0
- package/src/watchdog/runtime.d.ts.map +1 -0
- package/src/watchdog/runtime.js +862 -0
- package/src/watchdog/runtime.js.map +1 -0
- package/src/watchdog/scope.d.ts +15 -0
- package/src/watchdog/scope.d.ts.map +1 -0
- package/src/watchdog/scope.js +45 -0
- package/src/watchdog/scope.js.map +1 -0
- package/src/watchdog/settings.d.ts +30 -0
- package/src/watchdog/settings.d.ts.map +1 -0
- package/src/watchdog/settings.js +476 -0
- package/src/watchdog/settings.js.map +1 -0
- package/src/watchdog/tool-actions.d.ts +18 -0
- package/src/watchdog/tool-actions.d.ts.map +1 -0
- package/src/watchdog/tool-actions.js +151 -0
- package/src/watchdog/tool-actions.js.map +1 -0
- package/src/watchdog/turn-delta.d.ts +12 -0
- package/src/watchdog/turn-delta.d.ts.map +1 -0
- package/src/watchdog/turn-delta.js +185 -0
- package/src/watchdog/turn-delta.js.map +1 -0
- package/src/watchdog/types.d.ts +142 -0
- package/src/watchdog/types.d.ts.map +1 -0
- package/src/watchdog/types.js +28 -0
- package/src/watchdog/types.js.map +1 -0
- package/src/watchdog/warning-format.d.ts +8 -0
- package/src/watchdog/warning-format.d.ts.map +1 -0
- package/src/watchdog/warning-format.js +60 -0
- package/src/watchdog/warning-format.js.map +1 -0
- package/src/workflows/chat-progress.d.ts +38 -0
- package/src/workflows/chat-progress.d.ts.map +1 -0
- package/src/workflows/chat-progress.js +130 -0
- package/src/workflows/chat-progress.js.map +1 -0
- package/src/workflows/host-command.d.ts +31 -0
- package/src/workflows/host-command.d.ts.map +1 -0
- package/src/workflows/host-command.js +228 -0
- package/src/workflows/host-command.js.map +1 -0
- package/src/workflows/scripted-workflow.d.ts +195 -0
- package/src/workflows/scripted-workflow.d.ts.map +1 -0
- package/src/workflows/scripted-workflow.js +2636 -0
- package/src/workflows/scripted-workflow.js.map +1 -0
- package/src/workflows/workflow-checklist.d.ts +124 -0
- package/src/workflows/workflow-checklist.d.ts.map +1 -0
- package/src/workflows/workflow-checklist.js +312 -0
- package/src/workflows/workflow-checklist.js.map +1 -0
- package/src/workflows/workflow-child-summary.d.ts +20 -0
- package/src/workflows/workflow-child-summary.d.ts.map +1 -0
- package/src/workflows/workflow-child-summary.js +179 -0
- package/src/workflows/workflow-child-summary.js.map +1 -0
- package/src/workflows/workflow-preflight.d.ts +59 -0
- package/src/workflows/workflow-preflight.d.ts.map +1 -0
- package/src/workflows/workflow-preflight.js +289 -0
- package/src/workflows/workflow-preflight.js.map +1 -0
- package/src/workflows/workflow-receipt.d.ts +35 -0
- package/src/workflows/workflow-receipt.d.ts.map +1 -0
- package/src/workflows/workflow-receipt.js +449 -0
- package/src/workflows/workflow-receipt.js.map +1 -0
- package/src/workflows/workflow-resources.d.ts +43 -0
- package/src/workflows/workflow-resources.d.ts.map +1 -0
- package/src/workflows/workflow-resources.js +230 -0
- package/src/workflows/workflow-resources.js.map +1 -0
- package/src/workflows/workflow-settlement.d.ts +85 -0
- package/src/workflows/workflow-settlement.d.ts.map +1 -0
- package/src/workflows/workflow-settlement.js +204 -0
- package/src/workflows/workflow-settlement.js.map +1 -0
- package/index.ts +0 -13
- package/src/agents/advertised-agent-prompt.ts +0 -94
- package/src/agents/agent-management.ts +0 -1417
- package/src/agents/agent-memory.ts +0 -254
- package/src/agents/agent-refinements.ts +0 -624
- package/src/agents/agent-scope.ts +0 -6
- package/src/agents/agent-selection.ts +0 -25
- package/src/agents/agent-serializer.ts +0 -182
- package/src/agents/agents.ts +0 -2917
- package/src/agents/builtin-names.ts +0 -16
- package/src/agents/chain-serializer.ts +0 -285
- package/src/agents/frontmatter.ts +0 -153
- package/src/agents/identity.ts +0 -30
- package/src/agents/proactive-skills.ts +0 -194
- package/src/agents/runtime-agent-events.ts +0 -70
- package/src/agents/runtime-agent-registry.ts +0 -430
- package/src/agents/skills.ts +0 -754
- package/src/api/agents.ts +0 -12
- package/src/api/background-work.ts +0 -206
- package/src/api/capability-ceiling.ts +0 -16
- package/src/api/child-tool-plan.ts +0 -5
- package/src/api/control-channel.ts +0 -4
- package/src/api/delegation.ts +0 -116
- package/src/api/external-job-provider.ts +0 -195
- package/src/api/external-runs.ts +0 -282
- package/src/api/intercom-bridge.ts +0 -3
- package/src/api/preflight.ts +0 -539
- package/src/api/project-panes.ts +0 -32
- package/src/api/required-child-extensions.ts +0 -6
- package/src/api/shared-types.ts +0 -29
- package/src/api/workflow-resources.ts +0 -6
- package/src/extension/config.ts +0 -230
- package/src/extension/control-notices.ts +0 -58
- package/src/extension/doctor.ts +0 -270
- package/src/extension/fanout-child.ts +0 -265
- package/src/extension/herdr-pi-bridge.ts +0 -160
- package/src/extension/index.ts +0 -1205
- package/src/extension/public-execution.ts +0 -225
- package/src/extension/rpc.ts +0 -848
- package/src/extension/schemas.ts +0 -428
- package/src/extension/steering-notices.ts +0 -35
- package/src/extension/subagent-guide.ts +0 -39
- package/src/extension/tool-description.ts +0 -175
- package/src/extension/tool-result.ts +0 -19
- package/src/inspectors/actions.ts +0 -148
- package/src/inspectors/ghostty/actions.ts +0 -74
- package/src/inspectors/ghostty/plugin.ts +0 -29
- package/src/inspectors/herdr/actions.ts +0 -155
- package/src/inspectors/herdr/client.ts +0 -130
- package/src/inspectors/herdr/focus.ts +0 -55
- package/src/inspectors/herdr/plugin.ts +0 -20
- package/src/inspectors/herdr/project-panes.ts +0 -730
- package/src/inspectors/inspector-runner.ts +0 -153
- package/src/inspectors/plugins.ts +0 -8
- package/src/inspectors/session-roots-codec.ts +0 -31
- package/src/inspectors/shell-command.ts +0 -16
- package/src/inspectors/types.ts +0 -51
- package/src/integrations/herdr-status.ts +0 -400
- package/src/integrations/pi-web-session-liveness.ts +0 -73
- package/src/intercom/intercom-bridge.ts +0 -233
- package/src/intercom/native-supervisor-channel.ts +0 -917
- package/src/intercom/result-intercom.ts +0 -423
- package/src/intercom/supervisor-ui.ts +0 -244
- package/src/missions/actions.ts +0 -433
- package/src/missions/goal-driver.ts +0 -164
- package/src/missions/lifecycle.ts +0 -367
- package/src/missions/store.ts +0 -584
- package/src/missions/types.ts +0 -190
- package/src/missions/workflow-state.ts +0 -281
- package/src/policy/authority.ts +0 -50
- package/src/profiles/profiles.ts +0 -668
- package/src/runs/background/active-async-capacity.ts +0 -520
- package/src/runs/background/active-run-index.ts +0 -155
- package/src/runs/background/async-execution.ts +0 -2278
- package/src/runs/background/async-job-tracker.ts +0 -826
- package/src/runs/background/async-resume.ts +0 -647
- package/src/runs/background/async-retention.ts +0 -912
- package/src/runs/background/async-status-snapshot.ts +0 -46
- package/src/runs/background/async-status.ts +0 -771
- package/src/runs/background/auto-drain.ts +0 -92
- package/src/runs/background/binary-bootstrap.ts +0 -38
- package/src/runs/background/chain-append.ts +0 -321
- package/src/runs/background/chain-root-attachment.ts +0 -259
- package/src/runs/background/completion-batcher.ts +0 -168
- package/src/runs/background/completion-dedupe.ts +0 -58
- package/src/runs/background/completion-replay.ts +0 -287
- package/src/runs/background/control-channel.ts +0 -600
- package/src/runs/background/fleet-view.ts +0 -648
- package/src/runs/background/index-segment.ts +0 -59
- package/src/runs/background/inspect-rpc.ts +0 -443
- package/src/runs/background/notify.ts +0 -819
- package/src/runs/background/owned-process-tree.ts +0 -131
- package/src/runs/background/parallel-groups.ts +0 -45
- package/src/runs/background/process-terminal.ts +0 -310
- package/src/runs/background/result-delivery-ownership.ts +0 -45
- package/src/runs/background/result-files.ts +0 -523
- package/src/runs/background/result-watcher.ts +0 -809
- package/src/runs/background/resume-guidance.ts +0 -56
- package/src/runs/background/retained-children.ts +0 -135
- package/src/runs/background/retained-nested-route-tracker.ts +0 -96
- package/src/runs/background/run-child-session.ts +0 -690
- package/src/runs/background/run-id-query.ts +0 -7
- package/src/runs/background/run-id-resolver.ts +0 -175
- package/src/runs/background/run-status.ts +0 -786
- package/src/runs/background/runner-aliases.ts +0 -142
- package/src/runs/background/runner-child-launch.ts +0 -91
- package/src/runs/background/runner-child-sessions.ts +0 -32
- package/src/runs/background/runner-http-dispatcher.ts +0 -119
- package/src/runs/background/scheduled-runs.ts +0 -1012
- package/src/runs/background/stale-run-reconciler.ts +0 -436
- package/src/runs/background/steering.ts +0 -260
- package/src/runs/background/subagent-runner.ts +0 -5357
- package/src/runs/background/subagent-wait.ts +0 -876
- package/src/runs/background/terminal-run-index.ts +0 -138
- package/src/runs/background/top-level-async.ts +0 -14
- package/src/runs/background/wait-completions.ts +0 -261
- package/src/runs/background/wait-config.ts +0 -50
- package/src/runs/background/wait-subscriptions.ts +0 -354
- package/src/runs/background/wait-tool.ts +0 -45
- package/src/runs/foreground/async-dismiss-action.ts +0 -86
- package/src/runs/foreground/async-steering-action.ts +0 -276
- package/src/runs/foreground/async-stop-action.ts +0 -176
- package/src/runs/foreground/execution.ts +0 -2254
- package/src/runs/foreground/foreground-control.ts +0 -157
- package/src/runs/foreground/foreground-history.ts +0 -163
- package/src/runs/foreground/prompt-audit.ts +0 -178
- package/src/runs/foreground/subagent-executor.ts +0 -7526
- package/src/runs/foreground/workflow-detach-reconcile.ts +0 -304
- package/src/runs/foreground/workflow-foreground-steering.ts +0 -169
- package/src/runs/shared/abort-recovery.ts +0 -119
- package/src/runs/shared/acceptance.ts +0 -1698
- package/src/runs/shared/agent-contract.ts +0 -38
- package/src/runs/shared/async-status-projection.ts +0 -659
- package/src/runs/shared/background-process-options.ts +0 -9
- package/src/runs/shared/capability-ceiling.ts +0 -211
- package/src/runs/shared/chain-outputs.ts +0 -116
- package/src/runs/shared/child-hooks.ts +0 -189
- package/src/runs/shared/child-identity.ts +0 -62
- package/src/runs/shared/child-launch-plan.ts +0 -163
- package/src/runs/shared/child-launch.ts +0 -342
- package/src/runs/shared/child-lifecycle.ts +0 -28
- package/src/runs/shared/child-runtime-config.ts +0 -133
- package/src/runs/shared/child-session.ts +0 -448
- package/src/runs/shared/child-tool-plan.ts +0 -661
- package/src/runs/shared/claude-code-adapter.ts +0 -133
- package/src/runs/shared/codex-exec-adapter.ts +0 -129
- package/src/runs/shared/completion-evidence.ts +0 -89
- package/src/runs/shared/completion-guard.ts +0 -255
- package/src/runs/shared/context-mode.ts +0 -44
- package/src/runs/shared/cursor-agent-adapter.ts +0 -114
- package/src/runs/shared/dynamic-fanout.ts +0 -297
- package/src/runs/shared/effective-system-prompt.ts +0 -33
- package/src/runs/shared/extension-bindings.ts +0 -78
- package/src/runs/shared/external-cli-contract.ts +0 -177
- package/src/runs/shared/external-cli-preflight.ts +0 -142
- package/src/runs/shared/external-cli-runner.ts +0 -431
- package/src/runs/shared/external-job-bridge.ts +0 -460
- package/src/runs/shared/external-job-runner.ts +0 -389
- package/src/runs/shared/fast-mode-extension.ts +0 -10
- package/src/runs/shared/herdr-connection.ts +0 -134
- package/src/runs/shared/herdr-external-adapters.ts +0 -169
- package/src/runs/shared/herdr-machine.ts +0 -279
- package/src/runs/shared/herdr-pi-protocol.ts +0 -59
- package/src/runs/shared/herdr-placed-run.ts +0 -263
- package/src/runs/shared/host-step-status.ts +0 -231
- package/src/runs/shared/lane-metadata.ts +0 -126
- package/src/runs/shared/launch-cwd.ts +0 -16
- package/src/runs/shared/llm-intent-arbiter.ts +0 -321
- package/src/runs/shared/long-running-guard.ts +0 -221
- package/src/runs/shared/mcp-config-sources.ts +0 -422
- package/src/runs/shared/mcp-direct-tool-allowlist.ts +0 -484
- package/src/runs/shared/mcp-direct-tool-grant.ts +0 -194
- package/src/runs/shared/model-resolution-diagnostic.ts +0 -76
- package/src/runs/shared/model-resolution.ts +0 -441
- package/src/runs/shared/model-scope.ts +0 -205
- package/src/runs/shared/mutation-evidence.ts +0 -199
- package/src/runs/shared/nested-events.ts +0 -1079
- package/src/runs/shared/nested-path.ts +0 -38
- package/src/runs/shared/nested-render.ts +0 -127
- package/src/runs/shared/orca-progress-tabs.ts +0 -510
- package/src/runs/shared/parallel-handoff.ts +0 -741
- package/src/runs/shared/parallel-utils.ts +0 -279
- package/src/runs/shared/permissions.ts +0 -86
- package/src/runs/shared/pi-spawn.ts +0 -207
- package/src/runs/shared/process-signal.ts +0 -35
- package/src/runs/shared/readonly-drain-observation.ts +0 -42
- package/src/runs/shared/run-fanout-budget.ts +0 -267
- package/src/runs/shared/run-history.ts +0 -201
- package/src/runs/shared/runtime-acknowledged-extensions.ts +0 -44
- package/src/runs/shared/session-lease.ts +0 -293
- package/src/runs/shared/single-output.ts +0 -304
- package/src/runs/shared/spawn-budget.ts +0 -128
- package/src/runs/shared/structured-output.ts +0 -236
- package/src/runs/shared/subagent-control.ts +0 -294
- package/src/runs/shared/subagent-prompt-runtime.ts +0 -545
- package/src/runs/shared/task-intent.ts +0 -244
- package/src/runs/shared/tool-availability.ts +0 -37
- package/src/runs/shared/tool-budget.ts +0 -66
- package/src/runs/shared/tool-timeout.ts +0 -93
- package/src/runs/shared/usage-budget.ts +0 -65
- package/src/runs/shared/workflow-async-child-guidance.ts +0 -18
- package/src/runs/shared/workflow-graph.ts +0 -225
- package/src/runs/shared/worktree-cleanup-plan.ts +0 -869
- package/src/runs/shared/worktree-setup-command.ts +0 -213
- package/src/runs/shared/worktree.ts +0 -1538
- package/src/shared/accessible-dir.ts +0 -47
- package/src/shared/agent-stream-options.ts +0 -5
- package/src/shared/artifacts.ts +0 -281
- package/src/shared/atomic-json.ts +0 -83
- package/src/shared/capacity-resilient-json.ts +0 -102
- package/src/shared/child-cache-retention.ts +0 -43
- package/src/shared/child-session-name.ts +0 -46
- package/src/shared/child-transcript.ts +0 -264
- package/src/shared/completion-owner.ts +0 -14
- package/src/shared/display-text.ts +0 -150
- package/src/shared/extension-context.ts +0 -24
- package/src/shared/file-coalescer.ts +0 -49
- package/src/shared/file-system-retry.ts +0 -95
- package/src/shared/fork-context.ts +0 -236
- package/src/shared/fork-session-cwd.ts +0 -27
- package/src/shared/formatters.ts +0 -146
- package/src/shared/jsonl-writer.ts +0 -92
- package/src/shared/launch-contract.ts +0 -198
- package/src/shared/model-info.ts +0 -101
- package/src/shared/model-response-aliases.ts +0 -13
- package/src/shared/node-executable.ts +0 -21
- package/src/shared/opencode-session-headers.ts +0 -30
- package/src/shared/prompt-resources.ts +0 -11
- package/src/shared/pruned-fork.ts +0 -450
- package/src/shared/required-child-extensions.ts +0 -81
- package/src/shared/session-file-trust.ts +0 -19
- package/src/shared/session-identity.ts +0 -10
- package/src/shared/session-tokens.ts +0 -55
- package/src/shared/settings.ts +0 -412
- package/src/shared/shortcuts.ts +0 -13
- package/src/shared/status-format.ts +0 -55
- package/src/shared/thinking-ceiling.ts +0 -46
- package/src/shared/types.ts +0 -2983
- package/src/shared/utf8.ts +0 -11
- package/src/shared/utils.ts +0 -608
- package/src/shared/watch-strategy.ts +0 -12
- package/src/shared/workflow-child-permit.ts +0 -212
- package/src/slash/delegation-adapters.ts +0 -428
- package/src/slash/delegation-json.ts +0 -108
- package/src/slash/delegation-request.ts +0 -176
- package/src/slash/prompt-template-bridge.ts +0 -419
- package/src/slash/prompt-workflows.ts +0 -287
- package/src/slash/selector.ts +0 -147
- package/src/slash/slash-bridge.ts +0 -192
- package/src/slash/slash-commands.ts +0 -1325
- package/src/slash/slash-live-state.ts +0 -310
- package/src/slash/subagents-admin.ts +0 -460
- package/src/tui/fleet-status.ts +0 -1109
- package/src/tui/fleet-transcript.ts +0 -536
- package/src/tui/fleet.ts +0 -1448
- package/src/tui/render-helpers.ts +0 -111
- package/src/tui/render.ts +0 -3721
- package/src/types/pi-runtime-compat.d.ts +0 -8
- package/src/watchdog/change-signature.ts +0 -260
- package/src/watchdog/child-status.ts +0 -225
- package/src/watchdog/diff-tool.ts +0 -77
- package/src/watchdog/emission-guard.ts +0 -125
- package/src/watchdog/guidance.ts +0 -20
- package/src/watchdog/lsp-diagnostics.ts +0 -538
- package/src/watchdog/model-selection.ts +0 -187
- package/src/watchdog/permission-arbiter.ts +0 -156
- package/src/watchdog/register-child.ts +0 -128
- package/src/watchdog/register-main.ts +0 -445
- package/src/watchdog/render.ts +0 -53
- package/src/watchdog/review.ts +0 -363
- package/src/watchdog/rules.ts +0 -70
- package/src/watchdog/runtime.ts +0 -924
- package/src/watchdog/scope.ts +0 -51
- package/src/watchdog/settings.ts +0 -515
- package/src/watchdog/tool-actions.ts +0 -156
- package/src/watchdog/turn-delta.ts +0 -184
- package/src/watchdog/types.ts +0 -186
- package/src/watchdog/warning-format.ts +0 -72
- package/src/workflows/chat-progress.ts +0 -152
- package/src/workflows/host-command.ts +0 -235
- package/src/workflows/scripted-workflow.ts +0 -2575
- package/src/workflows/workflow-checklist.ts +0 -436
- package/src/workflows/workflow-child-summary.ts +0 -170
- package/src/workflows/workflow-preflight.ts +0 -297
- package/src/workflows/workflow-receipt.ts +0 -384
- package/src/workflows/workflow-resources.ts +0 -236
- package/src/workflows/workflow-settlement.ts +0 -249
|
@@ -0,0 +1,3607 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rendering functions for subagent results
|
|
3
|
+
*/
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
|
+
import { getMarkdownTheme, keyText } from "@earendil-works/pi-coding-agent";
|
|
7
|
+
import { Container, Markdown, Spacer, Text, visibleWidth } from "@earendil-works/pi-tui";
|
|
8
|
+
import { unresolvedChildWatchdogBlockers } from "../watchdog/child-status.js";
|
|
9
|
+
import { MAX_WIDGET_JOBS, WIDGET_ANIMATION_INTERVAL_MS, WIDGET_KEY, } from "../shared/types.js";
|
|
10
|
+
import { previewDisplayText, sanitizeDisplayText, truncateDisplayText } from "../shared/display-text.js";
|
|
11
|
+
import { formatShortcutLabel } from "../shared/shortcuts.js";
|
|
12
|
+
import { formatContextUsage, formatTokens, formatUsage, formatDuration, formatModelThinking, formatToolCall, formatTokenUsage, shortenPath } from "../shared/formatters.js";
|
|
13
|
+
import { getDisplayItems, getSingleResultOutput, PROMPT_REDACTED } from "../shared/utils.js";
|
|
14
|
+
import { flatToLogicalStepIndex } from "../runs/background/parallel-groups.js";
|
|
15
|
+
import { formatNestedAggregate } from "../runs/shared/nested-render.js";
|
|
16
|
+
import { aggregateStepStatus, formatActivityLabel, formatAgentRunningLabel, formatParallelOutcome } from "../shared/status-format.js";
|
|
17
|
+
import { contextModeBadge, contextModePrefix } from "../runs/shared/context-mode.js";
|
|
18
|
+
import { shouldSuppressSingleStep, stripRepeatedAgentPrefix, withDuplicateLabelDiscriminators } from "./render-helpers.js";
|
|
19
|
+
import { buildWorkflowChatProgressRows } from "../workflows/chat-progress.js";
|
|
20
|
+
import { formatWorkflowPreflight, formatWorkflowPreflightPlanSummary, formatWorkflowPreflightWarningSummary, formatWorkflowPreflightWarnings } from "../workflows/workflow-preflight.js";
|
|
21
|
+
import { encodeAsyncStatusSnapshotWidget } from "../runs/background/async-status-snapshot.js";
|
|
22
|
+
import { projectAsyncWorkflowRows } from "../runs/shared/async-status-projection.js";
|
|
23
|
+
import { hostStepReportName, hostStepVerdictLabel } from "../runs/shared/host-step-status.js";
|
|
24
|
+
import { workflowGraphStageNodes } from "../runs/shared/workflow-graph.js";
|
|
25
|
+
import { formatWorkflowChecklistBottleneck, formatWorkflowChecklistPhase, formatWorkflowChecklistSummary, projectWorkflowChecklist } from "../workflows/workflow-checklist.js";
|
|
26
|
+
function resolveMainWindowRenderLayout(config) {
|
|
27
|
+
return {
|
|
28
|
+
horizontalSpacing: config?.horizontalSpacing ?? 2,
|
|
29
|
+
...(config?.compactResultMaxLines !== undefined ? { compactResultMaxLines: config.compactResultMaxLines } : {}),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function mainWindowIndent(layout, level) {
|
|
33
|
+
return " ".repeat(Math.max(0, layout.horizontalSpacing * level));
|
|
34
|
+
}
|
|
35
|
+
function capCompactMainWindowResult(component, layout, theme, enabled) {
|
|
36
|
+
const maxLines = layout.compactResultMaxLines;
|
|
37
|
+
if (!enabled || maxLines === undefined)
|
|
38
|
+
return component;
|
|
39
|
+
const capped = new Container();
|
|
40
|
+
capped.render = (width) => {
|
|
41
|
+
const lines = component.render(width);
|
|
42
|
+
if (lines.length <= maxLines)
|
|
43
|
+
return lines;
|
|
44
|
+
const visibleRows = maxLines === 1 ? 1 : maxLines - 1;
|
|
45
|
+
const hiddenCount = lines.length - visibleRows;
|
|
46
|
+
const hint = theme.fg("accent", `… ${hiddenCount} rows hidden · ${liveDetailKeyText()} expands`);
|
|
47
|
+
if (maxLines === 1)
|
|
48
|
+
return [truncLine(`${lines[0] ?? ""} ${hint}`, width)];
|
|
49
|
+
return [...lines.slice(0, visibleRows), truncLine(hint, width)];
|
|
50
|
+
};
|
|
51
|
+
return capped;
|
|
52
|
+
}
|
|
53
|
+
function liveDetailKeyText() {
|
|
54
|
+
return keyText("app.tools.expand");
|
|
55
|
+
}
|
|
56
|
+
export function liveDetailHintText() {
|
|
57
|
+
return `Press ${liveDetailKeyText()} for live detail`;
|
|
58
|
+
}
|
|
59
|
+
function workflowDetailHintText() {
|
|
60
|
+
return `Press ${liveDetailKeyText()} for details`;
|
|
61
|
+
}
|
|
62
|
+
function foregroundSingleHintText(shortcut) {
|
|
63
|
+
if (!shortcut)
|
|
64
|
+
return liveDetailHintText();
|
|
65
|
+
const label = formatShortcutLabel(shortcut);
|
|
66
|
+
return `${liveDetailHintText()} · ${label} to run in background`;
|
|
67
|
+
}
|
|
68
|
+
function getTermWidth() {
|
|
69
|
+
return process.stdout.columns || 120;
|
|
70
|
+
}
|
|
71
|
+
const segmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
72
|
+
const ansiStylePattern = /\x1b\[[0-9;]*m/y;
|
|
73
|
+
/**
|
|
74
|
+
* Truncate a line to maxWidth, preserving ANSI styling through the ellipsis.
|
|
75
|
+
*
|
|
76
|
+
* pi-tui's truncateToWidth adds \x1b[0m before ellipsis which resets all styling,
|
|
77
|
+
* causing background color bleed in the TUI. This implementation tracks active
|
|
78
|
+
* ANSI styles and re-applies them before the ellipsis.
|
|
79
|
+
*
|
|
80
|
+
* Uses Intl.Segmenter for proper Unicode/emoji handling (not char-by-char).
|
|
81
|
+
*/
|
|
82
|
+
export function truncLine(text, maxWidth) {
|
|
83
|
+
if (maxWidth <= 0)
|
|
84
|
+
return "";
|
|
85
|
+
if (visibleWidth(text) <= maxWidth)
|
|
86
|
+
return text;
|
|
87
|
+
const targetWidth = maxWidth - 1;
|
|
88
|
+
let result = "";
|
|
89
|
+
let currentWidth = 0;
|
|
90
|
+
let activeStyles = [];
|
|
91
|
+
let i = 0;
|
|
92
|
+
while (i < text.length) {
|
|
93
|
+
ansiStylePattern.lastIndex = i;
|
|
94
|
+
const ansiMatch = ansiStylePattern.exec(text);
|
|
95
|
+
if (ansiMatch) {
|
|
96
|
+
const code = ansiMatch[0];
|
|
97
|
+
result += code;
|
|
98
|
+
if (code === "\x1b[0m" || code === "\x1b[m") {
|
|
99
|
+
activeStyles = [];
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
activeStyles.push(code);
|
|
103
|
+
}
|
|
104
|
+
i += code.length;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
let end = text.indexOf("\x1b[", i);
|
|
108
|
+
if (end === i)
|
|
109
|
+
end = text.indexOf("\x1b[", i + 2);
|
|
110
|
+
if (end === -1)
|
|
111
|
+
end = text.length;
|
|
112
|
+
const textPortion = text.slice(i, end);
|
|
113
|
+
for (const seg of segmenter.segment(textPortion)) {
|
|
114
|
+
const grapheme = seg.segment;
|
|
115
|
+
const graphemeWidth = grapheme === "\x1b" ? 0 : visibleWidth(grapheme);
|
|
116
|
+
if (currentWidth + graphemeWidth > targetWidth) {
|
|
117
|
+
return result + activeStyles.join("") + "…";
|
|
118
|
+
}
|
|
119
|
+
result += grapheme;
|
|
120
|
+
currentWidth += graphemeWidth;
|
|
121
|
+
}
|
|
122
|
+
i = end;
|
|
123
|
+
}
|
|
124
|
+
return result + activeStyles.join("") + "…";
|
|
125
|
+
}
|
|
126
|
+
function wrapPlainText(text, maxWidth) {
|
|
127
|
+
if (maxWidth <= 0)
|
|
128
|
+
return [""];
|
|
129
|
+
const lines = [];
|
|
130
|
+
for (const rawLine of text.split("\n")) {
|
|
131
|
+
if (rawLine.length === 0) {
|
|
132
|
+
lines.push("");
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
let current = "";
|
|
136
|
+
let currentWidth = 0;
|
|
137
|
+
for (const seg of segmenter.segment(rawLine)) {
|
|
138
|
+
const grapheme = seg.segment;
|
|
139
|
+
const graphemeWidth = visibleWidth(grapheme);
|
|
140
|
+
if (graphemeWidth > maxWidth)
|
|
141
|
+
continue;
|
|
142
|
+
if (currentWidth > 0 && currentWidth + graphemeWidth > maxWidth) {
|
|
143
|
+
lines.push(current);
|
|
144
|
+
current = grapheme;
|
|
145
|
+
currentWidth = graphemeWidth;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
current += grapheme;
|
|
149
|
+
currentWidth += graphemeWidth;
|
|
150
|
+
}
|
|
151
|
+
lines.push(current);
|
|
152
|
+
}
|
|
153
|
+
return lines;
|
|
154
|
+
}
|
|
155
|
+
const RUNNING_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
156
|
+
const STATIC_RUNNING_GLYPH = "●";
|
|
157
|
+
function runningSeed(...values) {
|
|
158
|
+
let seed;
|
|
159
|
+
for (const value of values) {
|
|
160
|
+
if (value === undefined || !Number.isFinite(value))
|
|
161
|
+
continue;
|
|
162
|
+
seed = (seed ?? 0) + Math.trunc(value);
|
|
163
|
+
}
|
|
164
|
+
return seed;
|
|
165
|
+
}
|
|
166
|
+
function runningGlyph(seed) {
|
|
167
|
+
if (seed === undefined)
|
|
168
|
+
return STATIC_RUNNING_GLYPH;
|
|
169
|
+
return RUNNING_FRAMES[Math.abs(seed) % RUNNING_FRAMES.length];
|
|
170
|
+
}
|
|
171
|
+
function animatedSeed(seed, frame) {
|
|
172
|
+
if (frame === undefined)
|
|
173
|
+
return seed;
|
|
174
|
+
return (seed ?? 0) + frame;
|
|
175
|
+
}
|
|
176
|
+
function progressRunningSeed(progress) {
|
|
177
|
+
if (!progress)
|
|
178
|
+
return undefined;
|
|
179
|
+
return runningSeed(progress.index, progress.toolCount, progress.tokens, progress.durationMs, progress.lastActivityAt, progress.currentToolStartedAt, progress.turnCount);
|
|
180
|
+
}
|
|
181
|
+
export function clearLegacyResultAnimationTimer(context) {
|
|
182
|
+
const timer = context.state.subagentResultAnimationTimer;
|
|
183
|
+
if (!timer)
|
|
184
|
+
return;
|
|
185
|
+
clearInterval(timer);
|
|
186
|
+
context.state.subagentResultAnimationTimer = undefined;
|
|
187
|
+
}
|
|
188
|
+
function extractOutputTarget(task) {
|
|
189
|
+
const writeToMatch = task.match(/\[Write to:\s*([^\]\n]+)\]/i);
|
|
190
|
+
if (writeToMatch?.[1]?.trim())
|
|
191
|
+
return writeToMatch[1].trim();
|
|
192
|
+
const findingsMatch = task.match(/Write your findings to(?: exactly this path)?:\s*([^\r\n]+)/i);
|
|
193
|
+
if (findingsMatch?.[1]?.trim())
|
|
194
|
+
return findingsMatch[1].trim();
|
|
195
|
+
const outputMatch = task.match(/[Oo]utput(?:\s+to)?\s*:\s*(\S+)/i);
|
|
196
|
+
if (outputMatch?.[1]?.trim())
|
|
197
|
+
return outputMatch[1].trim();
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
function hasEmptyTextOutputWithoutOutputTarget(task, output) {
|
|
201
|
+
if (output.trim())
|
|
202
|
+
return false;
|
|
203
|
+
return !extractOutputTarget(task);
|
|
204
|
+
}
|
|
205
|
+
function getToolCallLines(result, expanded) {
|
|
206
|
+
if (result.messages) {
|
|
207
|
+
return getDisplayItems(result.messages)
|
|
208
|
+
.filter((item) => item.type === "tool")
|
|
209
|
+
.map((item) => formatToolCall(item.name, item.args, expanded));
|
|
210
|
+
}
|
|
211
|
+
return result.toolCalls?.map((toolCall) => expanded ? toolCall.expandedText : toolCall.text) ?? [];
|
|
212
|
+
}
|
|
213
|
+
const ansiEscapePattern = /\x1b\[[0-9;]*m/g;
|
|
214
|
+
const noisyStatusPatterns = [
|
|
215
|
+
/^(?:i|we)\s+(?:will|need|can|should|am|are)\b/i,
|
|
216
|
+
/^i(?:'m|’m| am)\b/i,
|
|
217
|
+
/\bso i (?:will|need|can)\b/i,
|
|
218
|
+
/^(?:checking|fetching|reading|inspecting|verifying|collecting|confirming|polling)\b/i,
|
|
219
|
+
/^(?:async\s+subagent\s+)?[\w.-]+\s*·\s*(?:step|agent)\s+\d+\/\d+\s*·/i,
|
|
220
|
+
/^(?:Step|Agent)\s+\d+\/\d+:\s+[\w.-]+\s*·\s*(?:running|queued|pending|complete|completed)\b/i,
|
|
221
|
+
/^(?:async\s+subagent\s+)?[\w.-]+(?:\s+\[(?:fresh|fork|mixed)\])?\s*·\s*(?:running|queued|pending|complete|completed|done)\b/i,
|
|
222
|
+
/^Press\s+\S+\s+for\s+live\s+detail$/i,
|
|
223
|
+
/^output:\s+.+\/async-subagent-runs\//i,
|
|
224
|
+
];
|
|
225
|
+
const liveOutputWordSignalPattern = /\b(?:access denied|denied|error|exception|fail(?:ed|ure)?|fatal|panic|rejected|timeout|timed out|unable|warning)\b/i;
|
|
226
|
+
const liveOutputCodeSignalPattern = /\bE[A-Z0-9_]{2,}\b/;
|
|
227
|
+
function oneLine(text) {
|
|
228
|
+
return text.replace(ansiEscapePattern, "").replace(/\s+/g, " ").trim();
|
|
229
|
+
}
|
|
230
|
+
const COMPACT_TASK_MAX_CHARS = 96;
|
|
231
|
+
/** Display label for a child run: the derived session name (agent + task
|
|
232
|
+
* excerpt) when the launcher provided one, else the bare agent name. */
|
|
233
|
+
function childDisplayName(result, fallback = "subagent") {
|
|
234
|
+
return result?.sessionName?.trim() || result?.agent || fallback;
|
|
235
|
+
}
|
|
236
|
+
export function compactTaskText(task, label) {
|
|
237
|
+
const taskText = task?.trim();
|
|
238
|
+
const labelText = label?.trim();
|
|
239
|
+
const normalizedTask = taskText && taskText !== PROMPT_REDACTED ? oneLine(taskText) : "";
|
|
240
|
+
const normalizedLabel = labelText && labelText !== PROMPT_REDACTED ? oneLine(labelText) : "";
|
|
241
|
+
const normalized = normalizedLabel && normalizedTask && normalizedLabel !== normalizedTask
|
|
242
|
+
? `${normalizedLabel} — ${normalizedTask}`
|
|
243
|
+
: normalizedLabel || normalizedTask;
|
|
244
|
+
if (!normalized)
|
|
245
|
+
return undefined;
|
|
246
|
+
return previewDisplayText(normalized, COMPACT_TASK_MAX_CHARS);
|
|
247
|
+
}
|
|
248
|
+
const LANE_VALUE_MAX_CHARS = 48;
|
|
249
|
+
function boundedLaneValue(value, maxChars = LANE_VALUE_MAX_CHARS) {
|
|
250
|
+
if (!value?.trim() || value.trim() === PROMPT_REDACTED)
|
|
251
|
+
return undefined;
|
|
252
|
+
return previewDisplayText(oneLine(value), maxChars);
|
|
253
|
+
}
|
|
254
|
+
function workflowNodeStepStatus(status) {
|
|
255
|
+
switch (status) {
|
|
256
|
+
case "completed":
|
|
257
|
+
return "completed";
|
|
258
|
+
case "detached":
|
|
259
|
+
return "paused";
|
|
260
|
+
default:
|
|
261
|
+
return status;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function workflowNodeStatusLabel(status) {
|
|
265
|
+
switch (status) {
|
|
266
|
+
case "completed":
|
|
267
|
+
return "complete";
|
|
268
|
+
case "detached":
|
|
269
|
+
return "paused";
|
|
270
|
+
default:
|
|
271
|
+
return status;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function workflowStepPriority(step, currentNodeId) {
|
|
275
|
+
const isCurrent = step.workflowKey === currentNodeId;
|
|
276
|
+
if (step.status === "running" || (isCurrent && step.status !== "complete" && step.status !== "completed"))
|
|
277
|
+
return 0;
|
|
278
|
+
const gate = laneGate(step);
|
|
279
|
+
if (step.status === "failed"
|
|
280
|
+
|| step.status === "partial"
|
|
281
|
+
|| step.status === "paused"
|
|
282
|
+
|| step.status === "stopped"
|
|
283
|
+
|| step.status === "rejected"
|
|
284
|
+
|| step.toolBudgetBlocked === true
|
|
285
|
+
|| step.turnBudgetExceeded === true
|
|
286
|
+
|| step.activityState === "needs_attention"
|
|
287
|
+
|| step.watchdog?.phase === "stale"
|
|
288
|
+
|| unresolvedChildWatchdogBlockers(step.watchdog).length > 0
|
|
289
|
+
|| gate !== undefined)
|
|
290
|
+
return 1;
|
|
291
|
+
if (step.status === "pending")
|
|
292
|
+
return 2;
|
|
293
|
+
return 3;
|
|
294
|
+
}
|
|
295
|
+
/** Merge materialized child rows with the planned workflow stages for rendering. */
|
|
296
|
+
function workflowWidgetSteps(job, planned = job.mode === "workflow" ? workflowGraphStageNodes(job.workflowGraph) : []) {
|
|
297
|
+
const loaded = job.steps ?? [];
|
|
298
|
+
if (planned.length === 0)
|
|
299
|
+
return loaded;
|
|
300
|
+
const loadedIndexesByKey = new Map();
|
|
301
|
+
for (const [index, step] of loaded.entries()) {
|
|
302
|
+
if (!step.workflowKey)
|
|
303
|
+
continue;
|
|
304
|
+
const indexes = loadedIndexesByKey.get(step.workflowKey) ?? [];
|
|
305
|
+
indexes.push(index);
|
|
306
|
+
loadedIndexesByKey.set(step.workflowKey, indexes);
|
|
307
|
+
}
|
|
308
|
+
const consumed = new Set();
|
|
309
|
+
const entries = [];
|
|
310
|
+
for (const [order, node] of planned.entries()) {
|
|
311
|
+
const loadedIndex = loadedIndexesByKey.get(node.id)?.find((index) => !consumed.has(index));
|
|
312
|
+
if (loadedIndex !== undefined) {
|
|
313
|
+
consumed.add(loadedIndex);
|
|
314
|
+
const loadedStep = loaded[loadedIndex];
|
|
315
|
+
entries.push({
|
|
316
|
+
step: {
|
|
317
|
+
...loadedStep,
|
|
318
|
+
index: node.flatIndex ?? loadedStep.index ?? order,
|
|
319
|
+
agent: loadedStep.agent || node.agent || job.agents?.[0] || "workflow",
|
|
320
|
+
phase: loadedStep.phase ?? node.phase,
|
|
321
|
+
label: loadedStep.label ?? node.label,
|
|
322
|
+
workflowKey: loadedStep.workflowKey ?? node.id,
|
|
323
|
+
...(loadedStep.outputName === undefined && node.outputName !== undefined ? { outputName: node.outputName } : {}),
|
|
324
|
+
...(loadedStep.structured === undefined && node.structured !== undefined ? { structured: node.structured } : {}),
|
|
325
|
+
...(loadedStep.error === undefined && node.error !== undefined ? { error: node.error } : {}),
|
|
326
|
+
},
|
|
327
|
+
order,
|
|
328
|
+
});
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
entries.push({
|
|
332
|
+
step: {
|
|
333
|
+
index: node.flatIndex ?? order,
|
|
334
|
+
agent: node.agent ?? job.agents?.[0] ?? "workflow",
|
|
335
|
+
status: workflowNodeStepStatus(node.status),
|
|
336
|
+
workflowKey: node.id,
|
|
337
|
+
label: node.label,
|
|
338
|
+
...(node.phase ? { phase: node.phase } : {}),
|
|
339
|
+
...(node.outputName ? { outputName: node.outputName } : {}),
|
|
340
|
+
...(node.structured !== undefined ? { structured: node.structured } : {}),
|
|
341
|
+
...(node.error ? { error: node.error } : {}),
|
|
342
|
+
},
|
|
343
|
+
order,
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
for (const [index, step] of loaded.entries()) {
|
|
347
|
+
if (!consumed.has(index))
|
|
348
|
+
entries.push({ step, order: planned.length + index });
|
|
349
|
+
}
|
|
350
|
+
entries.sort((left, right) => workflowStepPriority(left.step, job.workflowGraph?.currentNodeId) - workflowStepPriority(right.step, job.workflowGraph?.currentNodeId) || left.order - right.order);
|
|
351
|
+
return entries.map(({ step }) => step);
|
|
352
|
+
}
|
|
353
|
+
function workflowStageProgress(job, stages = job.mode === "workflow" ? workflowGraphStageNodes(job.workflowGraph) : []) {
|
|
354
|
+
if (job.mode !== "workflow")
|
|
355
|
+
return undefined;
|
|
356
|
+
if (stages.length === 0)
|
|
357
|
+
return undefined;
|
|
358
|
+
const currentId = job.workflowGraph?.currentNodeId;
|
|
359
|
+
const currentIndex = currentId ? stages.findIndex((stage) => stage.id === currentId) : -1;
|
|
360
|
+
if (currentIndex >= 0 && stages[currentIndex]?.status !== "completed")
|
|
361
|
+
return { total: stages.length, current: currentIndex };
|
|
362
|
+
const runningIndex = stages.findIndex((stage) => stage.status === "running");
|
|
363
|
+
if (runningIndex >= 0)
|
|
364
|
+
return { total: stages.length, current: runningIndex };
|
|
365
|
+
const indexedStage = job.currentStep !== undefined && job.currentStep >= 0 ? stages[job.currentStep] : undefined;
|
|
366
|
+
if (indexedStage && indexedStage.status !== "completed")
|
|
367
|
+
return { total: stages.length, current: job.currentStep };
|
|
368
|
+
if (stages.every((stage) => stage.status === "completed"))
|
|
369
|
+
return { total: stages.length, current: stages.length - 1 };
|
|
370
|
+
return { total: stages.length };
|
|
371
|
+
}
|
|
372
|
+
function buildWorkflowWidgetProjection(job, now = Date.now()) {
|
|
373
|
+
const stages = job.mode === "workflow" ? workflowGraphStageNodes(job.workflowGraph) : [];
|
|
374
|
+
const stageProgress = workflowStageProgress(job, stages);
|
|
375
|
+
const clock = job.status === "running" ? now : job.updatedAt;
|
|
376
|
+
const loadedSteps = workflowWidgetSteps(job, stages);
|
|
377
|
+
const steps = job.mode === "workflow" ? loadedSteps.map((step) => step.status === "running" && step.startedAt !== undefined && clock !== undefined
|
|
378
|
+
? { ...step, durationMs: Math.max(0, clock - step.startedAt) } : step) : loadedSteps;
|
|
379
|
+
const projection = { stages, steps, now };
|
|
380
|
+
if (stageProgress)
|
|
381
|
+
projection.stageProgress = stageProgress;
|
|
382
|
+
if (stages.length)
|
|
383
|
+
projection.plannedKeys = new Set(stages.map((node) => node.id));
|
|
384
|
+
if (job.mode === "workflow") {
|
|
385
|
+
const checklist = projectWorkflowChecklist({
|
|
386
|
+
graph: job.workflowGraph,
|
|
387
|
+
steps: job.steps,
|
|
388
|
+
hostSteps: job.hostSteps,
|
|
389
|
+
preflight: job.preflight,
|
|
390
|
+
trace: job.workflow?.trace,
|
|
391
|
+
now: clock,
|
|
392
|
+
});
|
|
393
|
+
if (checklist.total > 0)
|
|
394
|
+
projection.checklist = checklist;
|
|
395
|
+
}
|
|
396
|
+
return projection;
|
|
397
|
+
}
|
|
398
|
+
function workflowWidgetProjectionLookup(now = Date.now(), childrenByParent = new Map()) {
|
|
399
|
+
const projections = new WeakMap();
|
|
400
|
+
return (job) => {
|
|
401
|
+
const cached = projections.get(job);
|
|
402
|
+
if (cached)
|
|
403
|
+
return cached;
|
|
404
|
+
const projection = buildWorkflowWidgetProjection(job, now);
|
|
405
|
+
const children = childrenByParent.get(job.asyncId);
|
|
406
|
+
if (children?.length) {
|
|
407
|
+
projection.children = children;
|
|
408
|
+
projection.materializedKeys = new Set(children.flatMap((child) => [child.asyncId, ...(child.workflowKey ? [child.workflowKey] : [])]));
|
|
409
|
+
for (const step of projection.steps) {
|
|
410
|
+
if (step.runId && projection.materializedKeys.has(step.runId) && step.workflowKey)
|
|
411
|
+
projection.materializedKeys.add(step.workflowKey);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
projections.set(job, projection);
|
|
415
|
+
return projection;
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
function laneStepForJob(job, steps = workflowWidgetSteps(job)) {
|
|
419
|
+
if (steps.length === 0)
|
|
420
|
+
return undefined;
|
|
421
|
+
const graphCurrent = job.workflowGraph?.currentNodeId;
|
|
422
|
+
if (graphCurrent) {
|
|
423
|
+
const current = steps.find((step) => step.workflowKey === graphCurrent);
|
|
424
|
+
if (current)
|
|
425
|
+
return current;
|
|
426
|
+
}
|
|
427
|
+
if (job.currentStep !== undefined) {
|
|
428
|
+
const current = steps[job.currentStep];
|
|
429
|
+
if (current && (current.index === undefined || current.index === job.currentStep))
|
|
430
|
+
return current;
|
|
431
|
+
// Active parallel groups retain flat indices while exposing only the group slice.
|
|
432
|
+
const indexedCurrent = steps.find((step) => step.index === job.currentStep);
|
|
433
|
+
if (indexedCurrent)
|
|
434
|
+
return indexedCurrent;
|
|
435
|
+
return steps[0];
|
|
436
|
+
}
|
|
437
|
+
return steps.find((step) => step.status === "running")
|
|
438
|
+
?? steps.find((step) => step.status === "pending")
|
|
439
|
+
?? steps.at(-1);
|
|
440
|
+
}
|
|
441
|
+
function laneTraceForJob(job) {
|
|
442
|
+
return Array.isArray(job.workflow?.trace) ? job.workflow.trace.at(-1) : undefined;
|
|
443
|
+
}
|
|
444
|
+
function laneGate(step) {
|
|
445
|
+
const review = step?.review?.status ?? step?.acceptance?.reviewResult?.status;
|
|
446
|
+
if (review === "blockers")
|
|
447
|
+
return "review blockers";
|
|
448
|
+
if (review === "review-required")
|
|
449
|
+
return "review required";
|
|
450
|
+
if (review === "reviewed")
|
|
451
|
+
return "reviewed";
|
|
452
|
+
const acceptance = step?.acceptance?.status;
|
|
453
|
+
if (acceptance === "review-required")
|
|
454
|
+
return "acceptance review";
|
|
455
|
+
if (acceptance === "checked" || acceptance === "verified" || acceptance === "accepted")
|
|
456
|
+
return "acceptance";
|
|
457
|
+
return undefined;
|
|
458
|
+
}
|
|
459
|
+
function laneNextAction(state, step, output, gate) {
|
|
460
|
+
if (unresolvedChildWatchdogBlockers(step?.watchdog).length > 0)
|
|
461
|
+
return "resolve watchdog blockers";
|
|
462
|
+
if (step?.watchdog?.phase === "stale")
|
|
463
|
+
return "inspect stale state";
|
|
464
|
+
if (step?.toolBudgetBlocked === true || step?.turnBudgetExceeded === true)
|
|
465
|
+
return "inspect blocked state";
|
|
466
|
+
if (gate === "review blockers")
|
|
467
|
+
return "resolve review blockers";
|
|
468
|
+
if (gate === "review required" || gate === "acceptance review")
|
|
469
|
+
return "review output";
|
|
470
|
+
if (step?.activityState === "needs_attention")
|
|
471
|
+
return "inspect attention";
|
|
472
|
+
if (state === "queued" || state === "pending")
|
|
473
|
+
return "await launch";
|
|
474
|
+
if (state === "failed" || state === "rejected")
|
|
475
|
+
return "inspect failure";
|
|
476
|
+
if (state === "partial")
|
|
477
|
+
return "inspect partial state";
|
|
478
|
+
if (state === "paused")
|
|
479
|
+
return "inspect paused state";
|
|
480
|
+
if (state === "stopped")
|
|
481
|
+
return "inspect stopped state";
|
|
482
|
+
if ((state === "complete" || state === "completed") && gate === "reviewed")
|
|
483
|
+
return "ready";
|
|
484
|
+
if ((state === "complete" || state === "completed") && output)
|
|
485
|
+
return "inspect output";
|
|
486
|
+
return undefined;
|
|
487
|
+
}
|
|
488
|
+
function isTerminalLaneState(state) {
|
|
489
|
+
return state !== "queued" && state !== "running";
|
|
490
|
+
}
|
|
491
|
+
/** Project already-loaded async status facts into one bounded, render-only lane row. */
|
|
492
|
+
export function projectAsyncLane(job, ...args) {
|
|
493
|
+
const selectedStep = args.length === 0 ? laneStepForJob(job) : args[0];
|
|
494
|
+
const trace = laneTraceForJob(job);
|
|
495
|
+
const workspace = job.cwd ? boundedLaneValue(shortenPath(job.cwd)) : undefined;
|
|
496
|
+
const label = compactTaskText(selectedStep?.description, selectedStep?.label)
|
|
497
|
+
?? boundedLaneValue(trace?.label)
|
|
498
|
+
?? (workspace ? undefined : boundedLaneValue(selectedStep?.workflowKey ?? job.workflowKey));
|
|
499
|
+
const role = boundedLaneValue(selectedStep?.agent ?? trace?.agent ?? job.agents?.[0] ?? widgetJobName(job), 32) ?? "subagent";
|
|
500
|
+
const phase = boundedLaneValue(selectedStep?.phase ?? trace?.phase);
|
|
501
|
+
const gate = laneGate(selectedStep);
|
|
502
|
+
const output = boundedLaneValue(selectedStep?.outputName);
|
|
503
|
+
const ref = boundedLaneValue(selectedStep?.workflowKey ?? job.workflowKey ?? job.asyncId.slice(0, 8), 24) ?? job.asyncId.slice(0, 8);
|
|
504
|
+
const chips = [
|
|
505
|
+
selectedStep?.context,
|
|
506
|
+
selectedStep?.structured ? "structured" : undefined,
|
|
507
|
+
selectedStep?.activityState === "active_long_running" ? "long-running" : undefined,
|
|
508
|
+
selectedStep?.activityState === "needs_attention" ? "attention" : undefined,
|
|
509
|
+
selectedStep?.watchdog?.phase === "stale" ? "stale" : undefined,
|
|
510
|
+
unresolvedChildWatchdogBlockers(selectedStep?.watchdog).length > 0 ? `wd:${unresolvedChildWatchdogBlockers(selectedStep?.watchdog).length}` : undefined,
|
|
511
|
+
selectedStep?.toolBudgetBlocked === true || selectedStep?.turnBudgetExceeded === true ? "blocked" : undefined,
|
|
512
|
+
].filter((chip) => Boolean(chip));
|
|
513
|
+
const state = isTerminalLaneState(job.status) ? job.status : selectedStep?.status ?? job.status;
|
|
514
|
+
const next = laneNextAction(state, selectedStep, output, gate);
|
|
515
|
+
if (!label && !phase && !gate && !output && !selectedStep?.workflowKey && !job.workflowKey && !trace?.label && !trace?.phase)
|
|
516
|
+
return undefined;
|
|
517
|
+
return { ...(label ? { label } : {}), role, ...(phase ? { phase } : {}), state, ...(gate ? { gate } : {}), ...(next ? { next } : {}), ...(output ? { output } : {}), ...(workspace ? { workspace } : {}), ref, chips };
|
|
518
|
+
}
|
|
519
|
+
function laneStateLabel(state, theme) {
|
|
520
|
+
if (state === "running")
|
|
521
|
+
return theme.fg("accent", "running");
|
|
522
|
+
if (state === "queued" || state === "pending")
|
|
523
|
+
return theme.fg("muted", state);
|
|
524
|
+
if (state === "complete" || state === "completed")
|
|
525
|
+
return theme.fg("success", "complete");
|
|
526
|
+
if (state === "failed" || state === "rejected")
|
|
527
|
+
return theme.fg("error", state === "rejected" ? "rejected" : "failed");
|
|
528
|
+
return theme.fg("warning", state);
|
|
529
|
+
}
|
|
530
|
+
function formatLaneProjection(lane, theme) {
|
|
531
|
+
const label = boundedLaneValue(lane.label, 56);
|
|
532
|
+
const identity = [label, lane.role ? `role:${lane.role}` : undefined].filter(Boolean).join(" · ");
|
|
533
|
+
return `${identity ? theme.bold(identity) : theme.bold(lane.role)} · ${laneStateLabel(lane.state, theme)}`;
|
|
534
|
+
}
|
|
535
|
+
function formatLaneChip(chip, theme) {
|
|
536
|
+
const text = `[${chip}]`;
|
|
537
|
+
if (chip === "blocked")
|
|
538
|
+
return theme.fg("error", text);
|
|
539
|
+
if (chip === "stale")
|
|
540
|
+
return theme.fg("warning", text);
|
|
541
|
+
return text;
|
|
542
|
+
}
|
|
543
|
+
function formatLaneProjectionDetails(lane, theme) {
|
|
544
|
+
const details = [
|
|
545
|
+
lane.phase ? `phase:${lane.phase}` : undefined,
|
|
546
|
+
lane.gate ? `gate:${lane.gate}` : undefined,
|
|
547
|
+
lane.next ? `next:${lane.next}` : undefined,
|
|
548
|
+
lane.output ? `out:${lane.output}` : undefined,
|
|
549
|
+
lane.workspace ? `workspace:${lane.workspace}` : lane.ref ? `ref:${lane.ref}` : undefined,
|
|
550
|
+
].filter(Boolean);
|
|
551
|
+
const chips = lane.chips.map((chip) => formatLaneChip(chip, theme));
|
|
552
|
+
return [...(details.length ? [theme.fg("dim", details.join(" · "))] : []), ...chips].join(" · ") || undefined;
|
|
553
|
+
}
|
|
554
|
+
function formatLaneProjectionLines(lane, theme, indent) {
|
|
555
|
+
const details = formatLaneProjectionDetails(lane, theme);
|
|
556
|
+
return [
|
|
557
|
+
`${indent}${formatLaneProjection(lane, theme)}`,
|
|
558
|
+
...(details ? [`${indent} ${details}`] : []),
|
|
559
|
+
];
|
|
560
|
+
}
|
|
561
|
+
function laneRenderKey(job, projection) {
|
|
562
|
+
const selectedStep = projection ? laneStepForJob(job, projection.steps) : laneStepForJob(job);
|
|
563
|
+
const lane = projectAsyncLane(job, selectedStep);
|
|
564
|
+
return lane ? [lane.label, lane.role, lane.phase, lane.state, lane.gate, lane.next, lane.output, lane.workspace, lane.ref, lane.chips] : undefined;
|
|
565
|
+
}
|
|
566
|
+
function widgetLaneDetailLines(job, theme, projection) {
|
|
567
|
+
if (job.steps?.length && (job.mode === "parallel" || job.mode === "chain"))
|
|
568
|
+
return [];
|
|
569
|
+
const selectedStep = projection ? laneStepForJob(job, projection.steps) : laneStepForJob(job);
|
|
570
|
+
const lane = projectAsyncLane(job, selectedStep);
|
|
571
|
+
return lane ? formatLaneProjectionLines(lane, theme, " ") : [];
|
|
572
|
+
}
|
|
573
|
+
function workflowPreflightLines(job) {
|
|
574
|
+
if (job.mode !== "workflow" || !job.preflight)
|
|
575
|
+
return [];
|
|
576
|
+
return [
|
|
577
|
+
...formatWorkflowPreflight(job.preflight, { indent: " " }).split("\n"),
|
|
578
|
+
...(job.workflow?.preflightWarnings ? formatWorkflowPreflightWarnings(job.workflow.preflightWarnings, { indent: " " }).split("\n") : []),
|
|
579
|
+
];
|
|
580
|
+
}
|
|
581
|
+
function workflowLabelForResult(details, resultIndex) {
|
|
582
|
+
const flatIndex = foregroundResultIndex(details, resultIndex);
|
|
583
|
+
const visit = (nodes) => {
|
|
584
|
+
for (const node of nodes) {
|
|
585
|
+
if (node.flatIndex === flatIndex && node.label.trim())
|
|
586
|
+
return node.label;
|
|
587
|
+
const nested = node.children ? visit(node.children) : undefined;
|
|
588
|
+
if (nested)
|
|
589
|
+
return nested;
|
|
590
|
+
}
|
|
591
|
+
return undefined;
|
|
592
|
+
};
|
|
593
|
+
return details.workflowGraph ? visit(details.workflowGraph.nodes) : undefined;
|
|
594
|
+
}
|
|
595
|
+
function foregroundProgressForResult(details, resultIndex) {
|
|
596
|
+
const result = details.results[resultIndex];
|
|
597
|
+
if (result?.progress)
|
|
598
|
+
return result.progress;
|
|
599
|
+
const index = result?.index ?? resultIndex;
|
|
600
|
+
const indexed = details.progress?.find((progress) => progress.index === index);
|
|
601
|
+
if (indexed)
|
|
602
|
+
return indexed;
|
|
603
|
+
return result?.agent
|
|
604
|
+
? details.progress?.find((progress) => progress.agent === result.agent && progress.status === "running")
|
|
605
|
+
: undefined;
|
|
606
|
+
}
|
|
607
|
+
function foregroundResultIndex(details, resultIndex) {
|
|
608
|
+
const result = details.results[resultIndex];
|
|
609
|
+
if (typeof result?.index === "number")
|
|
610
|
+
return result.index;
|
|
611
|
+
return foregroundProgressForResult(details, resultIndex)?.index ?? resultIndex;
|
|
612
|
+
}
|
|
613
|
+
function foregroundResultDisplayName(details, resultIndex, result, fallback) {
|
|
614
|
+
const progress = foregroundProgressForResult(details, resultIndex);
|
|
615
|
+
const agent = normalizedParallelDisplayText(result?.agent) ?? normalizedParallelDisplayText(progress?.agent);
|
|
616
|
+
const workflowLabel = normalizedParallelDisplayText(workflowLabelForResult(details, resultIndex));
|
|
617
|
+
if (workflowLabel)
|
|
618
|
+
return compactTaskText(undefined, workflowLabel) ?? workflowLabel;
|
|
619
|
+
const sessionName = normalizedParallelDisplayText(result?.sessionName) ?? normalizedParallelDisplayText(progress?.sessionName);
|
|
620
|
+
if (sessionName) {
|
|
621
|
+
const sessionTask = stripRepeatedAgentPrefix(sessionName, agent);
|
|
622
|
+
if (sessionTask && sessionTask !== PROMPT_REDACTED && sessionTask.toLowerCase() !== agent?.toLowerCase()) {
|
|
623
|
+
return compactTaskText(sessionTask) ?? sessionTask;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
return compactTaskText(result?.task) ?? compactTaskText(progress?.task) ?? agent ?? fallback;
|
|
627
|
+
}
|
|
628
|
+
function foregroundSingleDisplayName(result) {
|
|
629
|
+
return normalizedParallelDisplayText(result?.agent)
|
|
630
|
+
?? normalizedParallelDisplayText(result?.sessionName)
|
|
631
|
+
?? compactTaskText(result?.task)
|
|
632
|
+
?? "subagent";
|
|
633
|
+
}
|
|
634
|
+
function hasLiveOutputSignal(line) {
|
|
635
|
+
const clean = oneLine(line);
|
|
636
|
+
return liveOutputWordSignalPattern.test(clean) || liveOutputCodeSignalPattern.test(clean);
|
|
637
|
+
}
|
|
638
|
+
function isNoisyStatusLine(line) {
|
|
639
|
+
const clean = oneLine(line);
|
|
640
|
+
return clean.length > 0
|
|
641
|
+
&& clean.length <= 240
|
|
642
|
+
&& !hasLiveOutputSignal(clean)
|
|
643
|
+
&& noisyStatusPatterns.some((pattern) => pattern.test(clean));
|
|
644
|
+
}
|
|
645
|
+
function latestActivityText(line) {
|
|
646
|
+
return oneLine(line)
|
|
647
|
+
.replace(/^i (?:will|can|need to|am going to)\s+/i, "")
|
|
648
|
+
.replace(/^i(?:'m|’m| am)\s+/i, "");
|
|
649
|
+
}
|
|
650
|
+
function progressUpdateSummary(lines) {
|
|
651
|
+
const counts = new Map();
|
|
652
|
+
for (const line of lines)
|
|
653
|
+
counts.set(line.toLowerCase(), (counts.get(line.toLowerCase()) ?? 0) + 1);
|
|
654
|
+
const exactRepeatCount = Math.max(...counts.values());
|
|
655
|
+
const latest = latestActivityText(lines[lines.length - 1]);
|
|
656
|
+
const repeat = exactRepeatCount > 1 ? ` · repeated ${exactRepeatCount}×` : "";
|
|
657
|
+
return `↻ ${lines.length} progress updates${repeat} · latest: ${latest}`;
|
|
658
|
+
}
|
|
659
|
+
function compactRecentOutputLines(recentOutput) {
|
|
660
|
+
const lines = [];
|
|
661
|
+
const noisyLines = [];
|
|
662
|
+
const otherLines = [];
|
|
663
|
+
for (const rawLine of recentOutput ?? []) {
|
|
664
|
+
const line = oneLine(rawLine);
|
|
665
|
+
if (!line || line === "(running...)")
|
|
666
|
+
continue;
|
|
667
|
+
lines.push(line);
|
|
668
|
+
(isNoisyStatusLine(line) ? noisyLines : otherLines).push(line);
|
|
669
|
+
}
|
|
670
|
+
if (noisyLines.length >= 4 && !otherLines.some(hasLiveOutputSignal)) {
|
|
671
|
+
if (otherLines.length === 0) {
|
|
672
|
+
return [
|
|
673
|
+
progressUpdateSummary(noisyLines),
|
|
674
|
+
"pattern: repeated short status lines",
|
|
675
|
+
];
|
|
676
|
+
}
|
|
677
|
+
const visibleTail = otherLines.slice(-3);
|
|
678
|
+
const hiddenSignals = otherLines.slice(0, -3).filter(hasLiveOutputSignal);
|
|
679
|
+
return [
|
|
680
|
+
progressUpdateSummary(noisyLines),
|
|
681
|
+
...(hiddenSignals.length > 0 ? [`… ${hiddenSignals.length} older signal ${hiddenSignals.length === 1 ? "line" : "lines"}: ${hiddenSignals.at(-1)}`] : []),
|
|
682
|
+
...visibleTail,
|
|
683
|
+
].slice(0, 5);
|
|
684
|
+
}
|
|
685
|
+
if (lines.length <= 5)
|
|
686
|
+
return lines;
|
|
687
|
+
const tail = lines.slice(-5);
|
|
688
|
+
const hiddenSignals = lines.slice(0, -5).filter(hasLiveOutputSignal);
|
|
689
|
+
if (hiddenSignals.length === 0)
|
|
690
|
+
return tail;
|
|
691
|
+
return [
|
|
692
|
+
`… ${hiddenSignals.length} older signal ${hiddenSignals.length === 1 ? "line" : "lines"}: ${hiddenSignals.at(-1)}`,
|
|
693
|
+
...lines.slice(-4),
|
|
694
|
+
];
|
|
695
|
+
}
|
|
696
|
+
function compactWorkflowError(error) {
|
|
697
|
+
const outputMatch = error.match(/(?:^|\n)Output:\s*([\s\S]+)/);
|
|
698
|
+
if (!outputMatch)
|
|
699
|
+
return oneLine(error);
|
|
700
|
+
const prefix = oneLine(error.slice(0, outputMatch.index)).replace(/:$/, "") || "Failed";
|
|
701
|
+
const outputLines = outputMatch[1].split(/\r?\n/).map(oneLine).filter(Boolean);
|
|
702
|
+
const allOutputLinesAreNoisy = outputLines.length > 0 && outputLines.every(isNoisyStatusLine);
|
|
703
|
+
const latest = outputLines.at(-1);
|
|
704
|
+
return allOutputLinesAreNoisy && latest
|
|
705
|
+
? `${prefix} · latest: ${latestActivityText(latest)}`
|
|
706
|
+
: `${prefix} · ${oneLine(outputMatch[1] ?? "")}`;
|
|
707
|
+
}
|
|
708
|
+
const WORKFLOW_LIVE_ROW_LIMIT = 8;
|
|
709
|
+
function visibleWorkflowRows(rows) {
|
|
710
|
+
if (rows.length <= WORKFLOW_LIVE_ROW_LIMIT)
|
|
711
|
+
return { rows, hiddenRows: 0 };
|
|
712
|
+
const selected = new Set();
|
|
713
|
+
const add = (row) => {
|
|
714
|
+
if (selected.size >= WORKFLOW_LIVE_ROW_LIMIT || selected.has(row.key))
|
|
715
|
+
return;
|
|
716
|
+
selected.add(row.key);
|
|
717
|
+
};
|
|
718
|
+
for (const row of [...rows].reverse()) {
|
|
719
|
+
if (row.state === "failed" || row.state === "detached")
|
|
720
|
+
add(row);
|
|
721
|
+
}
|
|
722
|
+
for (const row of [...rows].reverse())
|
|
723
|
+
add(row);
|
|
724
|
+
return {
|
|
725
|
+
rows: rows.filter((row) => selected.has(row.key)),
|
|
726
|
+
hiddenRows: rows.length - selected.size,
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
function snapshotNowForProgress(progress) {
|
|
730
|
+
if (progress.currentToolStartedAt !== undefined && progress.durationMs !== undefined)
|
|
731
|
+
return progress.currentToolStartedAt + progress.durationMs;
|
|
732
|
+
return progress.lastActivityAt;
|
|
733
|
+
}
|
|
734
|
+
function renderToolArgsPreview(value, maxLength, expanded) {
|
|
735
|
+
const normalized = sanitizeDisplayText(value);
|
|
736
|
+
if (expanded || normalized.length <= maxLength)
|
|
737
|
+
return normalized;
|
|
738
|
+
return `${truncateDisplayText(normalized, maxLength)}...`;
|
|
739
|
+
}
|
|
740
|
+
function formatCurrentToolLine(progress, availableWidth, expanded, snapshotNow) {
|
|
741
|
+
if (!progress.currentTool)
|
|
742
|
+
return undefined;
|
|
743
|
+
const maxToolArgsLen = Math.max(50, availableWidth - 20);
|
|
744
|
+
const toolArgsPreview = progress.currentToolArgs
|
|
745
|
+
? renderToolArgsPreview(progress.currentToolArgs, maxToolArgsLen, expanded)
|
|
746
|
+
: "";
|
|
747
|
+
const durationSuffix = progress.currentToolStartedAt !== undefined && snapshotNow !== undefined
|
|
748
|
+
? ` | ${formatDuration(Math.max(0, snapshotNow - progress.currentToolStartedAt))}`
|
|
749
|
+
: "";
|
|
750
|
+
return toolArgsPreview
|
|
751
|
+
? `${progress.currentTool}: ${toolArgsPreview}${durationSuffix}`
|
|
752
|
+
: `${progress.currentTool}${durationSuffix}`;
|
|
753
|
+
}
|
|
754
|
+
function buildLiveStatusLine(progress, snapshotNow) {
|
|
755
|
+
if (progress.lastActivityAt !== undefined && snapshotNow !== undefined)
|
|
756
|
+
return formatActivityLabel(progress.lastActivityAt, progress.activityState, snapshotNow);
|
|
757
|
+
if (progress.activityState === "needs_attention")
|
|
758
|
+
return "needs attention";
|
|
759
|
+
if (progress.activityState === "active_long_running")
|
|
760
|
+
return "active but long-running";
|
|
761
|
+
if (progress.lastActivityAt !== undefined)
|
|
762
|
+
return "active";
|
|
763
|
+
return undefined;
|
|
764
|
+
}
|
|
765
|
+
function themeBold(theme, text) {
|
|
766
|
+
return (theme.bold?.(text)) ?? text;
|
|
767
|
+
}
|
|
768
|
+
function statJoin(theme, parts) {
|
|
769
|
+
return parts.filter(Boolean).map((part) => theme.fg("dim", part)).join(` ${theme.fg("dim", "·")} `);
|
|
770
|
+
}
|
|
771
|
+
function formatTokenStat(tokens) {
|
|
772
|
+
return `${formatTokens(tokens)} token`;
|
|
773
|
+
}
|
|
774
|
+
function formatToolUseStat(count) {
|
|
775
|
+
return `${count} tool use${count === 1 ? "" : "s"}`;
|
|
776
|
+
}
|
|
777
|
+
function formatTotalCostStat(totalCost) {
|
|
778
|
+
if (!totalCost || (totalCost.inputTokens === 0 && totalCost.outputTokens === 0 && totalCost.costUsd === 0))
|
|
779
|
+
return "";
|
|
780
|
+
const parts = [];
|
|
781
|
+
if (totalCost.inputTokens)
|
|
782
|
+
parts.push(`in:${formatTokens(totalCost.inputTokens)}`);
|
|
783
|
+
if (totalCost.outputTokens)
|
|
784
|
+
parts.push(`out:${formatTokens(totalCost.outputTokens)}`);
|
|
785
|
+
if (totalCost.costUsd)
|
|
786
|
+
parts.push(`$${totalCost.costUsd.toFixed(4)}`);
|
|
787
|
+
return parts.join(" ");
|
|
788
|
+
}
|
|
789
|
+
function formatProgressStats(theme, progress, includeDuration = true) {
|
|
790
|
+
if (!progress)
|
|
791
|
+
return "";
|
|
792
|
+
const parts = [];
|
|
793
|
+
if (progress.toolCount > 0)
|
|
794
|
+
parts.push(formatToolUseStat(progress.toolCount));
|
|
795
|
+
if (progress.tokens > 0)
|
|
796
|
+
parts.push(formatTokenStat(progress.tokens));
|
|
797
|
+
if (includeDuration && progress.durationMs > 0)
|
|
798
|
+
parts.push(formatDuration(progress.durationMs));
|
|
799
|
+
return statJoin(theme, parts);
|
|
800
|
+
}
|
|
801
|
+
function firstOutputLine(text) {
|
|
802
|
+
return text.split("\n").find((line) => line.trim())?.trim() ?? "";
|
|
803
|
+
}
|
|
804
|
+
function resultStatusLine(result, output) {
|
|
805
|
+
if (result.detached)
|
|
806
|
+
return result.detachedReason ? `Detached: ${result.detachedReason}` : "Detached";
|
|
807
|
+
if (result.stopped)
|
|
808
|
+
return "Stopped";
|
|
809
|
+
if (result.interrupted)
|
|
810
|
+
return "Paused";
|
|
811
|
+
if (result.exitCode !== 0)
|
|
812
|
+
return `Error: ${result.error ?? (firstOutputLine(output) || `exit ${result.exitCode}`)}`;
|
|
813
|
+
if (result.acceptance?.status && result.acceptance.status !== "not-required")
|
|
814
|
+
return `Done · acceptance: ${result.acceptance.status}`;
|
|
815
|
+
if (hasEmptyTextOutputWithoutOutputTarget(result.task, output))
|
|
816
|
+
return "Done (no text output)";
|
|
817
|
+
return "Done";
|
|
818
|
+
}
|
|
819
|
+
function semanticResultPresentation(input) {
|
|
820
|
+
if (input.running) {
|
|
821
|
+
const glyph = input.frame !== undefined ? runningGlyph((input.seed ?? 0) + input.frame) : runningGlyph(input.seed);
|
|
822
|
+
return { glyph, label: "running", tone: "accent" };
|
|
823
|
+
}
|
|
824
|
+
if (input.detached)
|
|
825
|
+
return { glyph: "■", label: "detached", tone: "warning" };
|
|
826
|
+
if (input.stopped)
|
|
827
|
+
return { glyph: "■", label: "stopped", tone: "warning" };
|
|
828
|
+
if (input.interrupted)
|
|
829
|
+
return { glyph: "■", label: "paused", tone: "warning" };
|
|
830
|
+
if (input.failed)
|
|
831
|
+
return { glyph: "✗", label: "failed", tone: "error" };
|
|
832
|
+
if (input.partial)
|
|
833
|
+
return { glyph: "■", label: "partial", tone: "warning" };
|
|
834
|
+
return { glyph: "✓", label: "completed", tone: input.completedWithoutOutput ? "warning" : "success" };
|
|
835
|
+
}
|
|
836
|
+
function hasTerminalResultFlag(result) {
|
|
837
|
+
return Boolean(result.detached || result.stopped || result.interrupted);
|
|
838
|
+
}
|
|
839
|
+
function hasTerminalResult(result) {
|
|
840
|
+
if (hasTerminalResultFlag(result))
|
|
841
|
+
return true;
|
|
842
|
+
const status = result.progress?.status;
|
|
843
|
+
if (status === "running" || status === "pending")
|
|
844
|
+
return false;
|
|
845
|
+
return result.exitCode !== undefined;
|
|
846
|
+
}
|
|
847
|
+
function isResultRunning(result, status = result.progress?.status) {
|
|
848
|
+
return status === "running" && !hasTerminalResultFlag(result);
|
|
849
|
+
}
|
|
850
|
+
function detailsHaveRunningResult(details) {
|
|
851
|
+
return details.progress?.some((progress) => {
|
|
852
|
+
if (progress.status !== "running")
|
|
853
|
+
return false;
|
|
854
|
+
const result = details.results.find((entry) => entry.progress?.index === progress.index) ?? details.results[progress.index];
|
|
855
|
+
return !result || !hasTerminalResultFlag(result);
|
|
856
|
+
})
|
|
857
|
+
|| details.results.some((result) => isResultRunning(result))
|
|
858
|
+
|| workflowGraphHasStatus(details, ["running"]);
|
|
859
|
+
}
|
|
860
|
+
function resultPresentation(result, output, running = isResultRunning(result), seed = progressRunningSeed(result.progress ?? result.progressSummary), frame) {
|
|
861
|
+
return semanticResultPresentation({
|
|
862
|
+
running,
|
|
863
|
+
detached: result.detached,
|
|
864
|
+
stopped: result.stopped,
|
|
865
|
+
interrupted: result.interrupted,
|
|
866
|
+
failed: result.exitCode !== 0,
|
|
867
|
+
completedWithoutOutput: hasEmptyTextOutputWithoutOutputTarget(result.task, output),
|
|
868
|
+
seed,
|
|
869
|
+
frame,
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
function resultGlyph(result, output, theme, running = isResultRunning(result), seed = progressRunningSeed(result.progress ?? result.progressSummary), frame) {
|
|
873
|
+
const presentation = resultPresentation(result, output, running, seed, frame);
|
|
874
|
+
return theme.fg(presentation.tone, presentation.glyph);
|
|
875
|
+
}
|
|
876
|
+
function styledResultPresentation(presentation, theme) {
|
|
877
|
+
return {
|
|
878
|
+
glyph: theme.fg(presentation.tone, presentation.glyph),
|
|
879
|
+
label: theme.fg(presentation.tone, presentation.label),
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
function compactCurrentActivity(progress) {
|
|
883
|
+
const snapshotNow = snapshotNowForProgress(progress);
|
|
884
|
+
return formatCurrentToolLine(progress, getTermWidth() - 4, false, snapshotNow) ?? buildLiveStatusLine(progress, snapshotNow) ?? "thinking…";
|
|
885
|
+
}
|
|
886
|
+
function textDigest(text) {
|
|
887
|
+
return createHash("sha256").update(text).digest("hex").slice(0, 16);
|
|
888
|
+
}
|
|
889
|
+
function displayTextRenderKey(text) {
|
|
890
|
+
const normalized = sanitizeDisplayText(text);
|
|
891
|
+
return [normalized.length, textDigest(normalized)];
|
|
892
|
+
}
|
|
893
|
+
function expandedStepActivityRenderKey(step) {
|
|
894
|
+
return [
|
|
895
|
+
step.recentTools?.slice(-3).map((tool) => [tool.tool, displayTextRenderKey(tool.args), tool.endMs]),
|
|
896
|
+
compactRecentOutputLines(step.recentOutput).map(displayTextRenderKey),
|
|
897
|
+
];
|
|
898
|
+
}
|
|
899
|
+
function widgetStepRenderKey(step, index, expanded = false) {
|
|
900
|
+
return [
|
|
901
|
+
step.index ?? index,
|
|
902
|
+
step.agent,
|
|
903
|
+
step.sessionName,
|
|
904
|
+
step.workflowKey,
|
|
905
|
+
step.phase,
|
|
906
|
+
step.label,
|
|
907
|
+
step.status,
|
|
908
|
+
step.activityState,
|
|
909
|
+
step.lastActivityAt,
|
|
910
|
+
step.currentTool,
|
|
911
|
+
step.currentToolArgs,
|
|
912
|
+
step.currentToolStartedAt,
|
|
913
|
+
step.currentPath,
|
|
914
|
+
step.turnCount,
|
|
915
|
+
step.toolCount,
|
|
916
|
+
step.startedAt,
|
|
917
|
+
step.endedAt,
|
|
918
|
+
step.durationMs,
|
|
919
|
+
step.tokens?.total,
|
|
920
|
+
step.model,
|
|
921
|
+
step.thinking,
|
|
922
|
+
step.context,
|
|
923
|
+
step.description,
|
|
924
|
+
step.outputName,
|
|
925
|
+
step.structured,
|
|
926
|
+
step.acceptance?.status,
|
|
927
|
+
step.acceptance?.reviewResult?.status,
|
|
928
|
+
step.review?.status,
|
|
929
|
+
step.toolBudgetBlocked,
|
|
930
|
+
step.turnBudgetExceeded,
|
|
931
|
+
step.timedOut,
|
|
932
|
+
step.stopped,
|
|
933
|
+
step.execution?.status,
|
|
934
|
+
step.execution?.error,
|
|
935
|
+
step.execution?.timedOut,
|
|
936
|
+
step.execution?.interrupted,
|
|
937
|
+
step.execution?.stopped,
|
|
938
|
+
step.execution?.detached,
|
|
939
|
+
step.watchdog?.phase,
|
|
940
|
+
unresolvedChildWatchdogBlockers(step.watchdog).length,
|
|
941
|
+
step.error,
|
|
942
|
+
expanded ? expandedStepActivityRenderKey(step) : undefined,
|
|
943
|
+
nestedRenderKey(step.children, expanded),
|
|
944
|
+
];
|
|
945
|
+
}
|
|
946
|
+
function nestedRenderKey(children, expanded = false) {
|
|
947
|
+
return (children ?? []).map((child) => [
|
|
948
|
+
child.id,
|
|
949
|
+
child.state,
|
|
950
|
+
child.agent,
|
|
951
|
+
child.sessionName,
|
|
952
|
+
child.model,
|
|
953
|
+
child.thinking,
|
|
954
|
+
child.activityState,
|
|
955
|
+
child.lastActivityAt,
|
|
956
|
+
child.currentTool,
|
|
957
|
+
child.currentToolStartedAt,
|
|
958
|
+
child.currentPath,
|
|
959
|
+
child.turnCount,
|
|
960
|
+
child.toolCount,
|
|
961
|
+
child.startedAt,
|
|
962
|
+
child.endedAt,
|
|
963
|
+
child.lastUpdate,
|
|
964
|
+
child.error,
|
|
965
|
+
child.totalTokens?.total,
|
|
966
|
+
child.steps?.map((step, index) => widgetStepRenderKey({ ...step, agent: step.agent, status: step.status }, index, expanded)),
|
|
967
|
+
nestedRenderKey(child.children, expanded),
|
|
968
|
+
]);
|
|
969
|
+
}
|
|
970
|
+
function hostStepRenderKey(row) {
|
|
971
|
+
return [
|
|
972
|
+
row.kind,
|
|
973
|
+
row.name,
|
|
974
|
+
row.state,
|
|
975
|
+
row.provider,
|
|
976
|
+
row.role,
|
|
977
|
+
row.verdict,
|
|
978
|
+
row.reasonCode,
|
|
979
|
+
row.detail,
|
|
980
|
+
row.target,
|
|
981
|
+
row.freshness,
|
|
982
|
+
row.reportPath,
|
|
983
|
+
];
|
|
984
|
+
}
|
|
985
|
+
export function widgetRenderKey(job, expanded = false) {
|
|
986
|
+
const projection = buildWorkflowWidgetProjection(job, job.updatedAt ?? 0);
|
|
987
|
+
return JSON.stringify({
|
|
988
|
+
asyncDir: job.asyncDir,
|
|
989
|
+
parentWorkflowRunId: job.parentWorkflowRunId,
|
|
990
|
+
workflowKey: job.workflowKey,
|
|
991
|
+
status: job.status,
|
|
992
|
+
description: job.mode === "workflow" ? job.description : undefined,
|
|
993
|
+
activityState: job.activityState,
|
|
994
|
+
lastActivityAt: job.lastActivityAt,
|
|
995
|
+
currentTool: job.currentTool,
|
|
996
|
+
currentToolStartedAt: job.currentToolStartedAt,
|
|
997
|
+
currentPath: job.currentPath,
|
|
998
|
+
turnCount: job.turnCount,
|
|
999
|
+
toolCount: job.toolCount,
|
|
1000
|
+
mode: job.mode,
|
|
1001
|
+
agents: job.agents,
|
|
1002
|
+
currentStep: job.currentStep,
|
|
1003
|
+
chainStepCount: job.chainStepCount,
|
|
1004
|
+
parallelGroups: job.parallelGroups,
|
|
1005
|
+
workflowHostSteps: projectAsyncWorkflowRows([], job.hostSteps).map(hostStepRenderKey),
|
|
1006
|
+
workflowGraph: job.mode === "workflow" && job.workflowGraph ? {
|
|
1007
|
+
currentNodeId: job.workflowGraph.currentNodeId,
|
|
1008
|
+
stages: projection.stages.map((node) => [node.id, node.status, node.agent, node.phase, node.label, node.flatIndex, node.outputName, node.structured, node.error]),
|
|
1009
|
+
} : undefined,
|
|
1010
|
+
preflight: expanded ? job.preflight : job.preflight?.lanes.map((lane) => [lane.key, lane.mode, lane.decision, lane.claims, lane.expectedOutput]),
|
|
1011
|
+
preflightWarnings: expanded ? job.workflow?.preflightWarnings : undefined,
|
|
1012
|
+
checklist: projection.checklist ? {
|
|
1013
|
+
total: projection.checklist.total,
|
|
1014
|
+
done: projection.checklist.done,
|
|
1015
|
+
running: projection.checklist.running,
|
|
1016
|
+
queued: projection.checklist.queued,
|
|
1017
|
+
blocked: projection.checklist.blocked,
|
|
1018
|
+
failed: projection.checklist.failed,
|
|
1019
|
+
phases: projection.checklist.phases.map((phase) => [phase.key, phase.state, phase.done, phase.total, phase.running, phase.queued, phase.blocked, phase.failed, phase.paused, phase.stopped, phase.items.map((item) => [item.key, item.label, item.agent, item.state, item.preflight?.key, item.preflight?.mode, item.preflight?.decision, item.preflight?.claims, item.preflight?.expectedOutput, item.currentTool, item.currentPath, item.durationMs, item.toolCount, item.error])]),
|
|
1020
|
+
} : undefined,
|
|
1021
|
+
steps: job.steps?.map((step, index) => widgetStepRenderKey(step, index, expanded)),
|
|
1022
|
+
nestedChildren: nestedRenderKey(job.nestedChildren, expanded),
|
|
1023
|
+
lane: laneRenderKey(job, projection),
|
|
1024
|
+
stepsTotal: job.stepsTotal,
|
|
1025
|
+
runningSteps: job.runningSteps,
|
|
1026
|
+
completedSteps: job.completedSteps,
|
|
1027
|
+
activeParallelGroup: job.activeParallelGroup,
|
|
1028
|
+
startedAt: job.startedAt,
|
|
1029
|
+
updatedAt: job.updatedAt,
|
|
1030
|
+
timedOut: job.timedOut,
|
|
1031
|
+
stopped: job.stopped,
|
|
1032
|
+
totalTokens: job.totalTokens,
|
|
1033
|
+
});
|
|
1034
|
+
}
|
|
1035
|
+
function formatWidgetAgents(agents) {
|
|
1036
|
+
const distinct = [...new Set(agents)];
|
|
1037
|
+
if (distinct.length === 1 && agents.length > 1)
|
|
1038
|
+
return `${distinct[0]} ×${agents.length}`;
|
|
1039
|
+
if (agents.length > 3)
|
|
1040
|
+
return `${agents.slice(0, 2).join(", ")} +${agents.length - 2} more`;
|
|
1041
|
+
return agents.join(", ");
|
|
1042
|
+
}
|
|
1043
|
+
function widgetJobName(job) {
|
|
1044
|
+
if (job.mode === "parallel")
|
|
1045
|
+
return "parallel";
|
|
1046
|
+
if (job.mode === "chain")
|
|
1047
|
+
return "chain";
|
|
1048
|
+
if (job.mode === "single" && job.agents?.length === 1)
|
|
1049
|
+
return job.agents[0];
|
|
1050
|
+
if (job.agents?.length)
|
|
1051
|
+
return formatWidgetAgents(job.agents);
|
|
1052
|
+
return job.mode ?? "subagent";
|
|
1053
|
+
}
|
|
1054
|
+
function isSingleChildAsyncJob(job) {
|
|
1055
|
+
return job.mode === "single"
|
|
1056
|
+
&& job.steps?.length === 1
|
|
1057
|
+
&& shouldSuppressSingleStep(job.chainStepCount, job.stepsTotal);
|
|
1058
|
+
}
|
|
1059
|
+
function isCompletedWidgetStepStatus(status) {
|
|
1060
|
+
return status === "complete" || status === "completed";
|
|
1061
|
+
}
|
|
1062
|
+
function singleChildAgentName(job, step) {
|
|
1063
|
+
return job.agents?.length === 1 ? job.agents[0] : step.agent || widgetJobName(job);
|
|
1064
|
+
}
|
|
1065
|
+
function hasSingleChildDetailEvidence(job, step) {
|
|
1066
|
+
return Boolean(step.error?.trim()
|
|
1067
|
+
|| step.execution?.error?.trim()
|
|
1068
|
+
|| step.phase?.trim()
|
|
1069
|
+
|| step.label?.trim()
|
|
1070
|
+
|| step.workflowKey?.trim()
|
|
1071
|
+
|| step.outputName?.trim()
|
|
1072
|
+
|| step.lane
|
|
1073
|
+
|| job.workflowKey?.trim()
|
|
1074
|
+
|| job.lane
|
|
1075
|
+
|| laneTraceForJob(job)?.phase?.trim()
|
|
1076
|
+
|| laneTraceForJob(job)?.label?.trim()
|
|
1077
|
+
|| step.timedOut
|
|
1078
|
+
|| step.stopped
|
|
1079
|
+
|| step.execution?.timedOut
|
|
1080
|
+
|| step.execution?.interrupted
|
|
1081
|
+
|| step.execution?.stopped
|
|
1082
|
+
|| step.execution?.detached
|
|
1083
|
+
|| job.timedOut
|
|
1084
|
+
|| job.stopped
|
|
1085
|
+
|| ["failed", "partial", "paused", "stopped", "detached"].includes(step.execution?.status ?? "")
|
|
1086
|
+
|| step.acceptance?.status === "rejected"
|
|
1087
|
+
|| step.acceptance?.reviewResult?.status === "blockers"
|
|
1088
|
+
|| step.review?.status === "blockers");
|
|
1089
|
+
}
|
|
1090
|
+
function shouldCollapseSingleChildDetails(job, step) {
|
|
1091
|
+
if (!isSingleChildAsyncJob(job) || hasSingleChildDetailEvidence(job, step))
|
|
1092
|
+
return false;
|
|
1093
|
+
if (job.status === "running")
|
|
1094
|
+
return step.status === "running";
|
|
1095
|
+
if (job.status === "complete")
|
|
1096
|
+
return isCompletedWidgetStepStatus(step.status);
|
|
1097
|
+
return false;
|
|
1098
|
+
}
|
|
1099
|
+
function singleChildTask(job, step) {
|
|
1100
|
+
const task = compactTaskText(step.description, step.label);
|
|
1101
|
+
if (task)
|
|
1102
|
+
return task;
|
|
1103
|
+
const sessionName = step.sessionName?.trim();
|
|
1104
|
+
if (!sessionName)
|
|
1105
|
+
return undefined;
|
|
1106
|
+
const agentName = singleChildAgentName(job, step);
|
|
1107
|
+
const sessionTask = stripRepeatedAgentPrefix(sessionName, agentName);
|
|
1108
|
+
return sessionTask === agentName ? undefined : compactTaskText(sessionTask);
|
|
1109
|
+
}
|
|
1110
|
+
function widgetActivity(job) {
|
|
1111
|
+
const facts = [];
|
|
1112
|
+
if (job.currentTool && job.currentToolStartedAt !== undefined && job.updatedAt !== undefined)
|
|
1113
|
+
facts.push(`${job.currentTool} ${formatDuration(Math.max(0, job.updatedAt - job.currentToolStartedAt))}`);
|
|
1114
|
+
else if (job.currentTool)
|
|
1115
|
+
facts.push(job.currentTool);
|
|
1116
|
+
if (job.currentPath)
|
|
1117
|
+
facts.push(shortenPath(job.currentPath));
|
|
1118
|
+
if (job.turnCount !== undefined)
|
|
1119
|
+
facts.push(`${job.turnCount} turns`);
|
|
1120
|
+
if (job.toolCount !== undefined)
|
|
1121
|
+
facts.push(`${job.toolCount} tools`);
|
|
1122
|
+
const activity = buildLiveStatusLine(job, job.updatedAt);
|
|
1123
|
+
if (activity && facts.length)
|
|
1124
|
+
return `${activity} · ${facts.join(" · ")}`;
|
|
1125
|
+
if (activity)
|
|
1126
|
+
return activity;
|
|
1127
|
+
if (facts.length)
|
|
1128
|
+
return facts.join(" · ");
|
|
1129
|
+
if (job.status === "running")
|
|
1130
|
+
return "thinking…";
|
|
1131
|
+
if (job.status === "queued")
|
|
1132
|
+
return "queued…";
|
|
1133
|
+
if (job.status === "paused")
|
|
1134
|
+
return "Paused";
|
|
1135
|
+
if (job.status === "stopped")
|
|
1136
|
+
return "Stopped";
|
|
1137
|
+
if (job.status === "partial")
|
|
1138
|
+
return "Partial";
|
|
1139
|
+
if (job.status === "failed")
|
|
1140
|
+
return "Failed";
|
|
1141
|
+
return "Done";
|
|
1142
|
+
}
|
|
1143
|
+
function widgetStepRunningSeed(step, fallbackIndex) {
|
|
1144
|
+
return runningSeed(fallbackIndex, step.index, step.toolCount, step.turnCount, step.tokens?.total, step.lastActivityAt, step.currentToolStartedAt, step.durationMs);
|
|
1145
|
+
}
|
|
1146
|
+
function widgetStepsRunningSeed(steps) {
|
|
1147
|
+
let seed;
|
|
1148
|
+
for (const [index, step] of (steps ?? []).entries())
|
|
1149
|
+
seed = runningSeed(seed, widgetStepRunningSeed(step, index));
|
|
1150
|
+
return seed;
|
|
1151
|
+
}
|
|
1152
|
+
function widgetJobRunningSeed(job) {
|
|
1153
|
+
return runningSeed(job.updatedAt, job.lastActivityAt, job.toolCount, job.turnCount, job.totalTokens?.total, job.currentStep, job.runningSteps, job.completedSteps, widgetStepsRunningSeed(job.steps));
|
|
1154
|
+
}
|
|
1155
|
+
function widgetJobsRunningSeed(jobs) {
|
|
1156
|
+
let seed;
|
|
1157
|
+
for (const job of jobs)
|
|
1158
|
+
seed = runningSeed(seed, widgetJobRunningSeed(job));
|
|
1159
|
+
return seed;
|
|
1160
|
+
}
|
|
1161
|
+
function widgetStatusGlyph(job, theme, frame) {
|
|
1162
|
+
if (job.status === "running")
|
|
1163
|
+
return theme.fg("accent", runningGlyph(animatedSeed(widgetJobRunningSeed(job), frame)));
|
|
1164
|
+
if (job.status === "queued")
|
|
1165
|
+
return theme.fg("muted", "◦");
|
|
1166
|
+
if (job.status === "complete")
|
|
1167
|
+
return theme.fg("success", "✓");
|
|
1168
|
+
if (job.status === "paused")
|
|
1169
|
+
return theme.fg("warning", "■");
|
|
1170
|
+
if (job.status === "stopped")
|
|
1171
|
+
return theme.fg("warning", "■");
|
|
1172
|
+
return theme.fg("error", "✗");
|
|
1173
|
+
}
|
|
1174
|
+
function widgetStepGlyph(status, theme, seed, frame) {
|
|
1175
|
+
if (status === "running")
|
|
1176
|
+
return theme.fg("accent", runningGlyph(animatedSeed(seed, frame)));
|
|
1177
|
+
if (status === "complete" || status === "completed")
|
|
1178
|
+
return theme.fg("success", "✓");
|
|
1179
|
+
if (status === "failed")
|
|
1180
|
+
return theme.fg("error", "✗");
|
|
1181
|
+
if (status === "paused")
|
|
1182
|
+
return theme.fg("warning", "■");
|
|
1183
|
+
if (status === "stopped")
|
|
1184
|
+
return theme.fg("warning", "■");
|
|
1185
|
+
return theme.fg("muted", "◦");
|
|
1186
|
+
}
|
|
1187
|
+
function widgetStepStatus(status, theme) {
|
|
1188
|
+
if (status === "running")
|
|
1189
|
+
return theme.fg("accent", "running");
|
|
1190
|
+
if (status === "complete" || status === "completed")
|
|
1191
|
+
return theme.fg("success", "complete");
|
|
1192
|
+
if (status === "failed")
|
|
1193
|
+
return theme.fg("error", "failed");
|
|
1194
|
+
if (status === "paused")
|
|
1195
|
+
return theme.fg("warning", "paused");
|
|
1196
|
+
if (status === "stopped")
|
|
1197
|
+
return theme.fg("warning", "stopped");
|
|
1198
|
+
return theme.fg("dim", status);
|
|
1199
|
+
}
|
|
1200
|
+
function workflowChecklistStateLabel(state) {
|
|
1201
|
+
if (state === "running")
|
|
1202
|
+
return "running";
|
|
1203
|
+
if (state === "complete")
|
|
1204
|
+
return "complete";
|
|
1205
|
+
return state;
|
|
1206
|
+
}
|
|
1207
|
+
function workflowChecklistGlyph(item, theme, frame) {
|
|
1208
|
+
if (item.state === "running")
|
|
1209
|
+
return theme.fg("accent", runningGlyph(animatedSeed(runningSeed(item.startedAt, item.durationMs, item.toolCount, item.currentToolStartedAt), frame)));
|
|
1210
|
+
if (item.state === "complete")
|
|
1211
|
+
return theme.fg("success", "✓");
|
|
1212
|
+
if (item.state === "blocked")
|
|
1213
|
+
return theme.fg("error", "!");
|
|
1214
|
+
if (item.state === "failed")
|
|
1215
|
+
return theme.fg("error", "✗");
|
|
1216
|
+
if (item.state === "paused" || item.state === "stopped")
|
|
1217
|
+
return theme.fg("warning", "■");
|
|
1218
|
+
return theme.fg("muted", "◦");
|
|
1219
|
+
}
|
|
1220
|
+
function workflowChecklistItemPriority(state) {
|
|
1221
|
+
if (state === "blocked")
|
|
1222
|
+
return 0;
|
|
1223
|
+
if (state === "failed")
|
|
1224
|
+
return 1;
|
|
1225
|
+
if (state === "running")
|
|
1226
|
+
return 2;
|
|
1227
|
+
if (state === "paused")
|
|
1228
|
+
return 3;
|
|
1229
|
+
if (state === "stopped")
|
|
1230
|
+
return 4;
|
|
1231
|
+
if (state === "queued")
|
|
1232
|
+
return 5;
|
|
1233
|
+
return 6;
|
|
1234
|
+
}
|
|
1235
|
+
function workflowChecklistItemLine(item, theme, indent, frame, includeError) {
|
|
1236
|
+
const identity = [item.label, item.agent && item.agent !== item.label ? item.agent : undefined].filter(Boolean).join(" · ");
|
|
1237
|
+
const context = contextModeBadge(theme, item.context);
|
|
1238
|
+
const state = item.state === "complete" ? "" : ` ${theme.fg("dim", `· ${workflowChecklistStateLabel(item.state)}`)}`;
|
|
1239
|
+
const details = [
|
|
1240
|
+
item.currentTool ? `${item.currentTool}${item.durationMs !== undefined ? ` ${formatDuration(item.durationMs)}` : ""}` : undefined,
|
|
1241
|
+
!item.currentTool && item.currentPath ? shortenPath(item.currentPath) : undefined,
|
|
1242
|
+
!item.currentTool && item.durationMs !== undefined ? formatDuration(item.durationMs) : undefined,
|
|
1243
|
+
item.toolCount !== undefined ? `${item.toolCount} tools` : undefined,
|
|
1244
|
+
item.outputName ? `out:${item.outputName}` : undefined,
|
|
1245
|
+
includeError && item.error ? `error:${oneLine(item.error)}` : undefined,
|
|
1246
|
+
].filter(Boolean).join(" · ");
|
|
1247
|
+
return `${indent}${workflowChecklistGlyph(item, theme, frame)} ${theme.bold(identity || item.key)}${context}${state}${details ? ` ${theme.fg("dim", `· ${details}`)}` : ""}`;
|
|
1248
|
+
}
|
|
1249
|
+
const COLLAPSED_WORKFLOW_PHASE_LIMIT = 4;
|
|
1250
|
+
function workflowChecklistWidgetLines(checklist, theme, indent, expanded, frame, options = {}) {
|
|
1251
|
+
if (!checklist?.total)
|
|
1252
|
+
return [];
|
|
1253
|
+
const includeSummary = options.includeSummary ?? true;
|
|
1254
|
+
const limitPhases = options.limitPhases ?? !expanded;
|
|
1255
|
+
const includeBottleneckOutput = options.includeBottleneckOutput ?? expanded;
|
|
1256
|
+
const includeItemErrors = options.includeItemErrors ?? true;
|
|
1257
|
+
const lines = includeSummary ? [`${indent}${theme.fg("dim", `Checklist ${formatWorkflowChecklistSummary(checklist)}`)}`] : [];
|
|
1258
|
+
const phases = !limitPhases || checklist.phases.length <= COLLAPSED_WORKFLOW_PHASE_LIMIT
|
|
1259
|
+
? checklist.phases
|
|
1260
|
+
: checklist.phases
|
|
1261
|
+
.map((phase, index) => ({ phase, index }))
|
|
1262
|
+
.sort((left, right) => Number(left.phase.state !== "running") - Number(right.phase.state !== "running")
|
|
1263
|
+
|| Number(left.phase.state === "complete") - Number(right.phase.state === "complete")
|
|
1264
|
+
|| left.index - right.index)
|
|
1265
|
+
.slice(0, COLLAPSED_WORKFLOW_PHASE_LIMIT)
|
|
1266
|
+
.sort((left, right) => left.index - right.index)
|
|
1267
|
+
.map(({ phase }) => phase);
|
|
1268
|
+
for (const phase of phases) {
|
|
1269
|
+
const phaseItem = phase.items.find((item) => item.state === "running") ?? phase.items[0];
|
|
1270
|
+
const glyph = workflowChecklistGlyph({
|
|
1271
|
+
state: phase.state,
|
|
1272
|
+
startedAt: phaseItem?.startedAt,
|
|
1273
|
+
durationMs: phaseItem?.durationMs,
|
|
1274
|
+
toolCount: phaseItem?.toolCount,
|
|
1275
|
+
currentToolStartedAt: phaseItem?.currentToolStartedAt,
|
|
1276
|
+
}, theme, frame);
|
|
1277
|
+
lines.push(`${indent}${glyph} ${theme.bold(formatWorkflowChecklistPhase(phase))}`);
|
|
1278
|
+
if (expanded) {
|
|
1279
|
+
for (const item of [...phase.items].sort((left, right) => workflowChecklistItemPriority(left.state) - workflowChecklistItemPriority(right.state))) {
|
|
1280
|
+
lines.push(workflowChecklistItemLine(item, theme, `${indent} `, frame, includeItemErrors || item.kind === "host"));
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
const bottleneck = formatWorkflowChecklistBottleneck(checklist.bottleneck, { includeOutput: includeBottleneckOutput, includeError: !expanded });
|
|
1285
|
+
if (bottleneck) {
|
|
1286
|
+
const tone = checklist.bottleneck?.state === "blocked" || checklist.bottleneck?.state === "failed" ? "error" : checklist.bottleneck?.state === "running" ? "accent" : "warning";
|
|
1287
|
+
lines.push(`${indent}${theme.fg(tone, `bottleneck · ${bottleneck}`)}`);
|
|
1288
|
+
}
|
|
1289
|
+
return lines;
|
|
1290
|
+
}
|
|
1291
|
+
function compactWorkflowLaneState(items) {
|
|
1292
|
+
let state;
|
|
1293
|
+
for (const item of items) {
|
|
1294
|
+
if (state === undefined || workflowChecklistItemPriority(item.state) < workflowChecklistItemPriority(state))
|
|
1295
|
+
state = item.state;
|
|
1296
|
+
}
|
|
1297
|
+
return state ?? "queued";
|
|
1298
|
+
}
|
|
1299
|
+
function compactWorkflowLaneOwner(items) {
|
|
1300
|
+
const owners = [...new Set(items.map((item) => item.agent ?? item.role).filter((value) => Boolean(value?.trim())))];
|
|
1301
|
+
if (owners.length === 0)
|
|
1302
|
+
return undefined;
|
|
1303
|
+
return boundedLaneValue(owners.length > 2 ? `${owners.slice(0, 2).join(", ")} +${owners.length - 2}` : owners.join(", "), 32);
|
|
1304
|
+
}
|
|
1305
|
+
function compactWorkflowLaneLabel(items, key) {
|
|
1306
|
+
const labels = [...new Set(items.map((item) => item.label).filter((value) => Boolean(value?.trim() && value.trim() !== key)))];
|
|
1307
|
+
if (labels.length === 0)
|
|
1308
|
+
return undefined;
|
|
1309
|
+
return boundedLaneValue(labels.length > 1 ? `${labels[0]} +${labels.length - 1}` : labels[0], 48);
|
|
1310
|
+
}
|
|
1311
|
+
function compactWorkflowLaneRow(key, items, lane = items.find((item) => item.preflight)?.preflight, fallbackState = "queued") {
|
|
1312
|
+
const state = items.length ? compactWorkflowLaneState(items) : fallbackState;
|
|
1313
|
+
const toolCounts = items.map((item) => item.toolCount).filter((value) => value !== undefined);
|
|
1314
|
+
const durations = items.map((item) => item.durationMs).filter((value) => value !== undefined);
|
|
1315
|
+
const label = compactWorkflowLaneLabel(items, key);
|
|
1316
|
+
return {
|
|
1317
|
+
key: boundedLaneValue(key, 40) ?? key,
|
|
1318
|
+
state,
|
|
1319
|
+
agent: compactWorkflowLaneOwner(items),
|
|
1320
|
+
...(lane?.mode ? { mode: lane.mode } : {}),
|
|
1321
|
+
...(lane?.decision ? { decision: boundedLaneValue(lane.decision, 56) } : {}),
|
|
1322
|
+
...(lane?.claims?.length ? { claims: boundedLaneValue(lane.claims.join(", "), 56) } : {}),
|
|
1323
|
+
...(lane?.expectedOutput ? { expectedOutput: boundedLaneValue(lane.expectedOutput, 56) } : {}),
|
|
1324
|
+
...(label ? { label } : {}),
|
|
1325
|
+
...(toolCounts.length ? { toolUses: toolCounts.reduce((sum, value) => sum + value, 0) } : {}),
|
|
1326
|
+
...(durations.length ? { durationMs: Math.max(...durations) } : {}),
|
|
1327
|
+
};
|
|
1328
|
+
}
|
|
1329
|
+
function compactWorkflowFallbackState(job) {
|
|
1330
|
+
if (job.activityState === "needs_attention" || job.timedOut || job.toolBudgetBlocked || job.turnBudgetExceeded)
|
|
1331
|
+
return "blocked";
|
|
1332
|
+
switch (job.status) {
|
|
1333
|
+
case "complete": return "complete";
|
|
1334
|
+
case "failed": return "failed";
|
|
1335
|
+
case "paused": return "paused";
|
|
1336
|
+
case "stopped": return "stopped";
|
|
1337
|
+
case "partial":
|
|
1338
|
+
case "rejected": return "blocked";
|
|
1339
|
+
default: return "queued";
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
/** Flatten the loaded checklist into one compact row per declared lane. */
|
|
1343
|
+
function compactWorkflowLaneRows(job, checklist) {
|
|
1344
|
+
const groups = new Map();
|
|
1345
|
+
for (const item of checklist?.phases.flatMap((phase) => phase.items) ?? []) {
|
|
1346
|
+
const key = item.preflight?.key ?? item.key;
|
|
1347
|
+
const group = groups.get(key);
|
|
1348
|
+
if (group)
|
|
1349
|
+
group.push(item);
|
|
1350
|
+
else
|
|
1351
|
+
groups.set(key, [item]);
|
|
1352
|
+
}
|
|
1353
|
+
const rows = [];
|
|
1354
|
+
const preflightKeys = new Set(job.preflight?.lanes.map((lane) => lane.key) ?? []);
|
|
1355
|
+
if (job.preflight?.lanes.length) {
|
|
1356
|
+
for (const lane of job.preflight.lanes) {
|
|
1357
|
+
rows.push(compactWorkflowLaneRow(lane.key, groups.get(lane.key) ?? [], lane, compactWorkflowFallbackState(job)));
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
for (const [key, items] of groups) {
|
|
1361
|
+
if (preflightKeys.has(key))
|
|
1362
|
+
continue;
|
|
1363
|
+
rows.push(compactWorkflowLaneRow(key, items));
|
|
1364
|
+
}
|
|
1365
|
+
return rows;
|
|
1366
|
+
}
|
|
1367
|
+
function compactWorkflowLaneCounts(rows) {
|
|
1368
|
+
const counts = { total: rows.length, done: 0, active: 0, queued: 0, blocked: 0, failed: 0, paused: 0, stopped: 0 };
|
|
1369
|
+
for (const row of rows) {
|
|
1370
|
+
switch (row.state) {
|
|
1371
|
+
case "complete":
|
|
1372
|
+
counts.done++;
|
|
1373
|
+
break;
|
|
1374
|
+
case "running":
|
|
1375
|
+
counts.active++;
|
|
1376
|
+
break;
|
|
1377
|
+
case "queued":
|
|
1378
|
+
counts.queued++;
|
|
1379
|
+
break;
|
|
1380
|
+
case "blocked":
|
|
1381
|
+
counts.blocked++;
|
|
1382
|
+
break;
|
|
1383
|
+
case "failed":
|
|
1384
|
+
counts.failed++;
|
|
1385
|
+
break;
|
|
1386
|
+
case "paused":
|
|
1387
|
+
counts.paused++;
|
|
1388
|
+
break;
|
|
1389
|
+
case "stopped":
|
|
1390
|
+
counts.stopped++;
|
|
1391
|
+
break;
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
return counts;
|
|
1395
|
+
}
|
|
1396
|
+
function compactWorkflowLaneLine(row, theme, indent, frame) {
|
|
1397
|
+
const owner = row.agent && row.mode ? `${row.agent}/${row.mode}` : row.agent ?? row.mode;
|
|
1398
|
+
const state = row.state === "complete" ? undefined : row.state === "running" ? "active" : row.state;
|
|
1399
|
+
const intent = [
|
|
1400
|
+
row.decision,
|
|
1401
|
+
row.claims,
|
|
1402
|
+
row.expectedOutput,
|
|
1403
|
+
!row.mode && row.label ? row.label : undefined,
|
|
1404
|
+
].filter((value) => Boolean(value));
|
|
1405
|
+
return `${indent}${workflowChecklistGlyph({ state: row.state, durationMs: row.durationMs, toolCount: row.toolUses }, theme, frame)} ${theme.bold(row.key)}${owner ? ` ${theme.fg("dim", `· ${owner}`)}` : ""}${state ? ` ${theme.fg("dim", `· ${state}`)}` : ""}${intent.length ? ` ${theme.fg("dim", `· ${intent.join(" · ")}`)}` : ""}`;
|
|
1406
|
+
}
|
|
1407
|
+
function compactWorkflowShortId(job) {
|
|
1408
|
+
return job.asyncId.slice(0, 8);
|
|
1409
|
+
}
|
|
1410
|
+
function compactWorkflowDisplayLabel(job) {
|
|
1411
|
+
return boundedLaneValue(job.description, 64) ?? compactWorkflowShortId(job);
|
|
1412
|
+
}
|
|
1413
|
+
function compactWorkflowStats(job, rows, theme, projection) {
|
|
1414
|
+
const counts = compactWorkflowLaneCounts(rows);
|
|
1415
|
+
const total = counts.total || projection.stageProgress?.total || job.stepsTotal || job.agents?.length || 0;
|
|
1416
|
+
const progress = [
|
|
1417
|
+
total > 0 ? `${counts.done}/${total} done` : undefined,
|
|
1418
|
+
counts.active ? `${counts.active} active` : undefined,
|
|
1419
|
+
counts.queued ? `${counts.queued} queued` : undefined,
|
|
1420
|
+
counts.blocked ? `${counts.blocked} blocked` : undefined,
|
|
1421
|
+
counts.failed ? `${counts.failed} failed` : undefined,
|
|
1422
|
+
counts.paused ? `${counts.paused} paused` : undefined,
|
|
1423
|
+
counts.stopped ? `${counts.stopped} stopped` : undefined,
|
|
1424
|
+
].filter((value) => Boolean(value));
|
|
1425
|
+
const rowToolUses = rows.map((row) => row.toolUses).filter((value) => value !== undefined);
|
|
1426
|
+
const toolUses = job.toolCount ?? (rowToolUses.length ? rowToolUses.reduce((sum, value) => sum + value, 0) : undefined);
|
|
1427
|
+
const rowDuration = rows.map((row) => row.durationMs).filter((value) => value !== undefined);
|
|
1428
|
+
const end = job.status === "running" ? projection.now : job.updatedAt;
|
|
1429
|
+
const durationMs = job.status !== "queued" && job.startedAt !== undefined && end !== undefined
|
|
1430
|
+
? Math.max(0, end - job.startedAt)
|
|
1431
|
+
: job.status !== "queued" && rowDuration.length ? Math.max(...rowDuration) : undefined;
|
|
1432
|
+
return statJoin(theme, [
|
|
1433
|
+
`id: ${compactWorkflowShortId(job)}`,
|
|
1434
|
+
...progress,
|
|
1435
|
+
toolUses !== undefined ? formatToolUseStat(toolUses) : undefined,
|
|
1436
|
+
durationMs !== undefined ? formatDuration(durationMs) : undefined,
|
|
1437
|
+
].filter((value) => Boolean(value)));
|
|
1438
|
+
}
|
|
1439
|
+
function compactWorkflowBottleneck(rows, job) {
|
|
1440
|
+
let row;
|
|
1441
|
+
for (const candidate of rows) {
|
|
1442
|
+
if (candidate.state !== "blocked" && candidate.state !== "failed" && candidate.state !== "paused" && candidate.state !== "stopped")
|
|
1443
|
+
continue;
|
|
1444
|
+
if (!row || workflowChecklistItemPriority(candidate.state) < workflowChecklistItemPriority(row.state))
|
|
1445
|
+
row = candidate;
|
|
1446
|
+
}
|
|
1447
|
+
if (row)
|
|
1448
|
+
return { text: `${row.key} · ${row.state}`, tone: row.state === "blocked" || row.state === "failed" ? "error" : "warning" };
|
|
1449
|
+
if (job.activityState === "needs_attention" || job.timedOut || job.toolBudgetBlocked || job.turnBudgetExceeded)
|
|
1450
|
+
return { text: `workflow · ${job.activityState === "needs_attention" ? "needs attention" : "blocked"}`, tone: job.activityState === "needs_attention" ? "warning" : "error" };
|
|
1451
|
+
if (job.status === "failed" || job.status === "partial" || job.status === "rejected")
|
|
1452
|
+
return { text: `workflow · ${job.status}`, tone: "error" };
|
|
1453
|
+
if (job.status === "paused" || job.status === "stopped")
|
|
1454
|
+
return { text: `workflow · ${job.status}`, tone: "warning" };
|
|
1455
|
+
return undefined;
|
|
1456
|
+
}
|
|
1457
|
+
function compactWorkflowHeaderLine(job, theme, width) {
|
|
1458
|
+
const label = compactWorkflowDisplayLabel(job);
|
|
1459
|
+
const full = `${theme.fg("toolTitle", themeBold(theme, `async workflow: ${label}`))} ${theme.fg("dim", "─ background")}`;
|
|
1460
|
+
if (width === undefined || visibleWidth(full) <= width)
|
|
1461
|
+
return full;
|
|
1462
|
+
return `${theme.fg("toolTitle", themeBold(theme, `async workflow ${label}`))} ${theme.fg("dim", "· background")}`;
|
|
1463
|
+
}
|
|
1464
|
+
function compactWorkflowWidgetBodyLines(job, theme, frame, projection) {
|
|
1465
|
+
const rows = compactWorkflowLaneRows(job, projection.checklist);
|
|
1466
|
+
const lines = [` ${compactWorkflowStats(job, rows, theme, projection)}`];
|
|
1467
|
+
if (projection.inlineFleetCovered)
|
|
1468
|
+
return [...lines, ` ${theme.fg("dim", "Workflow children shown in Fleet roster")}`];
|
|
1469
|
+
if (rows.length) {
|
|
1470
|
+
for (const row of rows) {
|
|
1471
|
+
if (!projection.materializedKeys?.has(row.key))
|
|
1472
|
+
lines.push(compactWorkflowLaneLine(row, theme, " ", frame));
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
else {
|
|
1476
|
+
lines.push(` ${theme.fg("dim", "◦ waiting for workflow lanes")}`);
|
|
1477
|
+
}
|
|
1478
|
+
const bottleneck = compactWorkflowBottleneck(rows, job);
|
|
1479
|
+
if (bottleneck)
|
|
1480
|
+
lines.push(` ${theme.fg(bottleneck.tone, `bottleneck · ${bottleneck.text}`)}`);
|
|
1481
|
+
if (job.status === "running" || rows.some((row) => row.state === "running"))
|
|
1482
|
+
lines.push(` ${theme.fg("accent", workflowDetailHintText())}`);
|
|
1483
|
+
return lines;
|
|
1484
|
+
}
|
|
1485
|
+
function widgetStepActivity(step, snapshotNow) {
|
|
1486
|
+
const facts = [];
|
|
1487
|
+
if (step.currentTool && step.currentToolStartedAt !== undefined && snapshotNow !== undefined)
|
|
1488
|
+
facts.push(`${step.currentTool} ${formatDuration(Math.max(0, snapshotNow - step.currentToolStartedAt))}`);
|
|
1489
|
+
else if (step.currentTool)
|
|
1490
|
+
facts.push(step.currentTool);
|
|
1491
|
+
if (step.currentPath)
|
|
1492
|
+
facts.push(shortenPath(step.currentPath));
|
|
1493
|
+
if (step.turnCount !== undefined)
|
|
1494
|
+
facts.push(`${step.turnCount} turns`);
|
|
1495
|
+
if (step.toolCount !== undefined)
|
|
1496
|
+
facts.push(`${step.toolCount} tools`);
|
|
1497
|
+
if (step.tokens?.total)
|
|
1498
|
+
facts.push(formatTokenUsage(step.tokens, "token"));
|
|
1499
|
+
const activity = buildLiveStatusLine(step, snapshotNow);
|
|
1500
|
+
if (activity && facts.length)
|
|
1501
|
+
return `${activity} · ${facts.join(" · ")}`;
|
|
1502
|
+
if (activity)
|
|
1503
|
+
return activity;
|
|
1504
|
+
return facts.join(" · ");
|
|
1505
|
+
}
|
|
1506
|
+
function widgetChainDetails(job, theme, expanded = false, width = getTermWidth(), frame) {
|
|
1507
|
+
if (!job.steps?.length)
|
|
1508
|
+
return [];
|
|
1509
|
+
const total = job.chainStepCount ?? job.steps.length;
|
|
1510
|
+
const lines = [];
|
|
1511
|
+
for (const span of buildAsyncChainStepSpans(total, job.steps.length, job.parallelGroups)) {
|
|
1512
|
+
const steps = job.steps.slice(span.start, span.start + span.count);
|
|
1513
|
+
if (span.isParallel) {
|
|
1514
|
+
lines.push(...parallelWidgetGroupDetails(job, theme, { steps, total: span.count, stepIndex: span.stepIndex, chainTotal: total }, expanded, width, frame, false));
|
|
1515
|
+
continue;
|
|
1516
|
+
}
|
|
1517
|
+
const step = steps[0];
|
|
1518
|
+
if (!step) {
|
|
1519
|
+
lines.push(` ${theme.fg("dim", `◦ Step ${span.stepIndex + 1}/${total}: pending`)}`);
|
|
1520
|
+
continue;
|
|
1521
|
+
}
|
|
1522
|
+
lines.push(...foregroundStyleWidgetStepLines(job, theme, step, "Step", span.stepIndex + 1, total, expanded, width, frame));
|
|
1523
|
+
}
|
|
1524
|
+
return lines;
|
|
1525
|
+
}
|
|
1526
|
+
function widgetParallelAgentDetails(job, theme, expanded = false, width = getTermWidth(), frame) {
|
|
1527
|
+
if (!job.steps?.length)
|
|
1528
|
+
return [];
|
|
1529
|
+
if (job.mode !== "parallel" && job.mode !== "chain")
|
|
1530
|
+
return [];
|
|
1531
|
+
if (job.mode === "chain" && !job.activeParallelGroup && job.parallelGroups?.length)
|
|
1532
|
+
return widgetChainDetails(job, theme, expanded, width, frame);
|
|
1533
|
+
const group = activeParallelWidgetGroup(job);
|
|
1534
|
+
if (group)
|
|
1535
|
+
return parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, Boolean(job.activeParallelGroup));
|
|
1536
|
+
const total = job.stepsTotal ?? job.steps.length;
|
|
1537
|
+
const lines = [];
|
|
1538
|
+
for (const [index, step] of job.steps.entries()) {
|
|
1539
|
+
const marker = index === job.steps.length - 1 ? "└" : "├";
|
|
1540
|
+
const activity = widgetStepActivity(step, job.updatedAt);
|
|
1541
|
+
const itemTitle = job.mode === "parallel" || job.activeParallelGroup ? "Agent" : "Step";
|
|
1542
|
+
const modelDisplay = modelThinkingBadge(theme, step.model, step.thinking);
|
|
1543
|
+
const label = compactTaskText(step.description, step.label);
|
|
1544
|
+
const display = step.sessionName?.trim() || (label ? `${label} (${step.agent})` : step.agent);
|
|
1545
|
+
lines.push(` ${theme.fg("dim", `${marker} ${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, index), frame)} ${itemTitle} ${index + 1}/${total}: ${display} · ${widgetStepStatus(step.status, theme)}${modelDisplay}${activity ? ` · ${activity}` : ""}`)}`);
|
|
1546
|
+
const lane = projectAsyncLane(job, step);
|
|
1547
|
+
if (lane)
|
|
1548
|
+
lines.push(...formatLaneProjectionLines(lane, theme, " "));
|
|
1549
|
+
for (const nestedLine of formatNestedWidgetLines(step.children, theme, width, expanded, job.updatedAt, expanded ? 8 : 6))
|
|
1550
|
+
lines.push(` ${nestedLine}`);
|
|
1551
|
+
}
|
|
1552
|
+
return lines;
|
|
1553
|
+
}
|
|
1554
|
+
function parseParallelGroupAgentCount(label) {
|
|
1555
|
+
if (!label || !label.startsWith("[") || !label.endsWith("]"))
|
|
1556
|
+
return undefined;
|
|
1557
|
+
const inner = label.slice(1, -1).trim();
|
|
1558
|
+
if (!inner)
|
|
1559
|
+
return 0;
|
|
1560
|
+
return inner.split("+").map((part) => part.trim()).filter(Boolean).length;
|
|
1561
|
+
}
|
|
1562
|
+
function buildChainStepSpans(details) {
|
|
1563
|
+
if (details.workflowGraph?.nodes?.length) {
|
|
1564
|
+
const spans = [];
|
|
1565
|
+
let flatCursor = 0;
|
|
1566
|
+
for (const node of details.workflowGraph.nodes) {
|
|
1567
|
+
if (node.stepIndex === undefined)
|
|
1568
|
+
continue;
|
|
1569
|
+
if (node.kind === "parallel-group" || node.kind === "dynamic-parallel-group") {
|
|
1570
|
+
const childFlatIndexes = (node.children ?? [])
|
|
1571
|
+
.map((child) => child.flatIndex)
|
|
1572
|
+
.filter((value) => typeof value === "number");
|
|
1573
|
+
const start = childFlatIndexes.length ? Math.min(...childFlatIndexes) : flatCursor;
|
|
1574
|
+
const count = node.children?.length ?? 0;
|
|
1575
|
+
spans.push({ stepIndex: node.stepIndex, start, count, isParallel: true, status: node.status, label: node.label, error: node.error });
|
|
1576
|
+
flatCursor = Math.max(flatCursor, start + count);
|
|
1577
|
+
continue;
|
|
1578
|
+
}
|
|
1579
|
+
const start = node.flatIndex ?? flatCursor;
|
|
1580
|
+
spans.push({ stepIndex: node.stepIndex, start, count: 1, isParallel: false, status: node.status, label: node.label, error: node.error });
|
|
1581
|
+
flatCursor = Math.max(flatCursor, start + 1);
|
|
1582
|
+
}
|
|
1583
|
+
if (spans.length)
|
|
1584
|
+
return spans.sort((left, right) => left.stepIndex - right.stepIndex);
|
|
1585
|
+
}
|
|
1586
|
+
if (!details.chainAgents?.length)
|
|
1587
|
+
return [];
|
|
1588
|
+
const spans = [];
|
|
1589
|
+
let start = 0;
|
|
1590
|
+
for (let stepIndex = 0; stepIndex < details.chainAgents.length; stepIndex++) {
|
|
1591
|
+
const label = details.chainAgents[stepIndex];
|
|
1592
|
+
const parsedCount = parseParallelGroupAgentCount(label);
|
|
1593
|
+
const count = parsedCount ?? 1;
|
|
1594
|
+
spans.push({ stepIndex, start, count, isParallel: parsedCount !== undefined });
|
|
1595
|
+
start += count;
|
|
1596
|
+
}
|
|
1597
|
+
return spans;
|
|
1598
|
+
}
|
|
1599
|
+
function buildAsyncChainStepSpans(total, stepCount, parallelGroups = []) {
|
|
1600
|
+
const groupsByStep = new Map();
|
|
1601
|
+
for (const group of parallelGroups) {
|
|
1602
|
+
if (!groupsByStep.has(group.stepIndex))
|
|
1603
|
+
groupsByStep.set(group.stepIndex, group);
|
|
1604
|
+
}
|
|
1605
|
+
const spans = [];
|
|
1606
|
+
let flatIndex = 0;
|
|
1607
|
+
for (let stepIndex = 0; stepIndex < total; stepIndex++) {
|
|
1608
|
+
const group = groupsByStep.get(stepIndex);
|
|
1609
|
+
if (group) {
|
|
1610
|
+
spans.push({ stepIndex, start: group.start, count: group.count, isParallel: true });
|
|
1611
|
+
flatIndex = Math.max(flatIndex, group.start + group.count);
|
|
1612
|
+
continue;
|
|
1613
|
+
}
|
|
1614
|
+
spans.push({ stepIndex, start: flatIndex, count: flatIndex < stepCount ? 1 : 0, isParallel: false });
|
|
1615
|
+
flatIndex++;
|
|
1616
|
+
}
|
|
1617
|
+
return spans;
|
|
1618
|
+
}
|
|
1619
|
+
function normalizedParallelDisplayText(value) {
|
|
1620
|
+
if (!value?.trim())
|
|
1621
|
+
return undefined;
|
|
1622
|
+
const normalized = oneLine(value);
|
|
1623
|
+
return normalized && normalized !== PROMPT_REDACTED ? normalized : undefined;
|
|
1624
|
+
}
|
|
1625
|
+
function parallelWidgetStepDisplayName(step) {
|
|
1626
|
+
const agent = normalizedParallelDisplayText(step.agent);
|
|
1627
|
+
const explicitLabel = normalizedParallelDisplayText(step.label);
|
|
1628
|
+
if (explicitLabel) {
|
|
1629
|
+
const label = compactTaskText(step.description, explicitLabel) ?? explicitLabel;
|
|
1630
|
+
return agent ? `${label} (${agent})` : label;
|
|
1631
|
+
}
|
|
1632
|
+
const sessionName = normalizedParallelDisplayText(step.sessionName);
|
|
1633
|
+
if (sessionName) {
|
|
1634
|
+
const sessionTask = stripRepeatedAgentPrefix(sessionName, agent);
|
|
1635
|
+
if (sessionTask && sessionTask !== PROMPT_REDACTED && sessionTask.toLowerCase() !== agent?.toLowerCase())
|
|
1636
|
+
return sessionTask;
|
|
1637
|
+
}
|
|
1638
|
+
return compactTaskText(step.description) ?? agent ?? "subagent";
|
|
1639
|
+
}
|
|
1640
|
+
function parallelWidgetStepPriority(step) {
|
|
1641
|
+
if (step.status === "running" || step.activityState === "needs_attention")
|
|
1642
|
+
return 0;
|
|
1643
|
+
switch (step.status) {
|
|
1644
|
+
case "failed":
|
|
1645
|
+
case "rejected":
|
|
1646
|
+
case "partial":
|
|
1647
|
+
case "stopped":
|
|
1648
|
+
case "paused":
|
|
1649
|
+
return 1;
|
|
1650
|
+
case "complete":
|
|
1651
|
+
case "completed":
|
|
1652
|
+
return 2;
|
|
1653
|
+
default:
|
|
1654
|
+
return 3;
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
function parallelWidgetStepRows(steps, total, prioritizeActive) {
|
|
1658
|
+
const indexed = steps.map((step, index) => ({ step, index, displayName: parallelWidgetStepDisplayName(step) }));
|
|
1659
|
+
if (prioritizeActive)
|
|
1660
|
+
indexed.sort((left, right) => parallelWidgetStepPriority(left.step) - parallelWidgetStepPriority(right.step) || left.index - right.index);
|
|
1661
|
+
return withDuplicateLabelDiscriminators(indexed, total).map(({ displayName, ...row }) => row);
|
|
1662
|
+
}
|
|
1663
|
+
function activeParallelWidgetGroup(job) {
|
|
1664
|
+
const steps = job.steps ?? [];
|
|
1665
|
+
if (!steps.length)
|
|
1666
|
+
return undefined;
|
|
1667
|
+
if (job.mode === "parallel")
|
|
1668
|
+
return { steps, total: job.stepsTotal ?? steps.length };
|
|
1669
|
+
if (job.mode !== "chain" || !job.activeParallelGroup)
|
|
1670
|
+
return undefined;
|
|
1671
|
+
const chainTotal = job.chainStepCount ?? job.stepsTotal ?? steps.length;
|
|
1672
|
+
const spans = buildAsyncChainStepSpans(chainTotal, steps.length, job.parallelGroups);
|
|
1673
|
+
const currentStep = job.currentStep;
|
|
1674
|
+
const activeSpan = currentStep === undefined
|
|
1675
|
+
? spans.find((span) => span.isParallel)
|
|
1676
|
+
: spans.find((span) => span.isParallel
|
|
1677
|
+
&& currentStep >= span.start
|
|
1678
|
+
&& currentStep < span.start + span.count);
|
|
1679
|
+
return {
|
|
1680
|
+
steps,
|
|
1681
|
+
total: activeSpan?.count ?? job.stepsTotal ?? steps.length,
|
|
1682
|
+
stepIndex: activeSpan?.stepIndex,
|
|
1683
|
+
chainTotal,
|
|
1684
|
+
};
|
|
1685
|
+
}
|
|
1686
|
+
function parallelWidgetGroupHeader(group, theme, frame) {
|
|
1687
|
+
const status = aggregateStepStatus(group.steps);
|
|
1688
|
+
const label = group.stepIndex !== undefined && group.chainTotal !== undefined
|
|
1689
|
+
? `Step ${group.stepIndex + 1}/${group.chainTotal}: parallel group`
|
|
1690
|
+
: "parallel group";
|
|
1691
|
+
return ` ${widgetStepGlyph(status, theme, widgetStepsRunningSeed(group.steps), frame)} ${themeBold(theme, label)} ${theme.fg("dim", "·")} ${theme.fg("dim", formatParallelOutcome(group.steps, group.total))}`;
|
|
1692
|
+
}
|
|
1693
|
+
function parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, prioritizeActive) {
|
|
1694
|
+
const lines = [parallelWidgetGroupHeader(group, theme, frame)];
|
|
1695
|
+
const rows = parallelWidgetStepRows(group.steps, group.total, prioritizeActive);
|
|
1696
|
+
for (const [rowIndex, row] of rows.entries()) {
|
|
1697
|
+
const marker = rowIndex === rows.length - 1 && rows.length >= group.total ? "└─" : "├─";
|
|
1698
|
+
lines.push(...foregroundStyleWidgetStepLines(job, theme, row.step, "Agent", row.index + 1, group.total, expanded, width, frame, {
|
|
1699
|
+
rowLabel: row.rowLabel,
|
|
1700
|
+
rowIndent: " ",
|
|
1701
|
+
detailIndent: " ",
|
|
1702
|
+
rowMarker: marker,
|
|
1703
|
+
includeCurrentPath: true,
|
|
1704
|
+
}));
|
|
1705
|
+
}
|
|
1706
|
+
for (let index = rows.length; index < group.total; index++) {
|
|
1707
|
+
const marker = index === group.total - 1 ? "└─" : "├─";
|
|
1708
|
+
lines.push(` ${marker} ${theme.fg("muted", "◦")} ${theme.fg("dim", "pending")}`);
|
|
1709
|
+
}
|
|
1710
|
+
return lines;
|
|
1711
|
+
}
|
|
1712
|
+
function isDoneResult(result) {
|
|
1713
|
+
const status = result.progress?.status;
|
|
1714
|
+
if (status === "completed")
|
|
1715
|
+
return true;
|
|
1716
|
+
if (status === "running" || status === "pending")
|
|
1717
|
+
return false;
|
|
1718
|
+
if (result.interrupted || result.detached)
|
|
1719
|
+
return false;
|
|
1720
|
+
return result.exitCode === 0;
|
|
1721
|
+
}
|
|
1722
|
+
function workflowGraphHasStatus(details, statuses) {
|
|
1723
|
+
return details.workflowGraph?.nodes.some((node) => statuses.includes(node.status)) ?? false;
|
|
1724
|
+
}
|
|
1725
|
+
function chainSpanStatus(details, span) {
|
|
1726
|
+
if (span.status)
|
|
1727
|
+
return span.status;
|
|
1728
|
+
const results = details.results.slice(span.start, span.start + span.count);
|
|
1729
|
+
if (results.some((result) => isResultRunning(result)))
|
|
1730
|
+
return "running";
|
|
1731
|
+
if (results.some((result) => !hasTerminalResultFlag(result) && (result.progress?.status === "failed" || result.exitCode !== 0) && !isResultRunning(result)))
|
|
1732
|
+
return "failed";
|
|
1733
|
+
if (results.some((result) => result.stopped))
|
|
1734
|
+
return "stopped";
|
|
1735
|
+
if (results.some((result) => result.interrupted))
|
|
1736
|
+
return "paused";
|
|
1737
|
+
if (results.some((result) => result.detached || result.progress?.status === "detached"))
|
|
1738
|
+
return "detached";
|
|
1739
|
+
if (results.length < span.count)
|
|
1740
|
+
return "pending";
|
|
1741
|
+
if (results.length > 0 && results.every(isDoneResult))
|
|
1742
|
+
return "completed";
|
|
1743
|
+
return "pending";
|
|
1744
|
+
}
|
|
1745
|
+
function withDuplicateForegroundLabels(entries, total) {
|
|
1746
|
+
return withDuplicateLabelDiscriminators(entries.map((entry) => ({ ...entry, index: entry.displayIndex, displayName: entry.agentName })), total).map(({ displayName, rowLabel, ...entry }) => ({
|
|
1747
|
+
...entry,
|
|
1748
|
+
rowLabel: rowLabel === displayName ? undefined : rowLabel.slice(0, -(displayName.length + 2)),
|
|
1749
|
+
}));
|
|
1750
|
+
}
|
|
1751
|
+
function buildChainRenderEntries(details, label) {
|
|
1752
|
+
if (details.mode !== "chain" || !label.hasParallelInChain || label.showActiveGroupOnly)
|
|
1753
|
+
return undefined;
|
|
1754
|
+
const entries = [];
|
|
1755
|
+
for (const span of buildChainStepSpans(details)) {
|
|
1756
|
+
if (span.isParallel) {
|
|
1757
|
+
entries.push({
|
|
1758
|
+
kind: "group",
|
|
1759
|
+
stepLabel: `Step ${span.stepIndex + 1}/${label.logicalStepCount}: parallel group`,
|
|
1760
|
+
groupLabel: span.label?.trim() || undefined,
|
|
1761
|
+
status: chainSpanStatus(details, span),
|
|
1762
|
+
error: span.error,
|
|
1763
|
+
});
|
|
1764
|
+
const groupEntries = [];
|
|
1765
|
+
for (let index = span.start; index < span.start + span.count; index++) {
|
|
1766
|
+
const result = details.results[index];
|
|
1767
|
+
const localIndex = foregroundResultIndex(details, index);
|
|
1768
|
+
const displayIndex = localIndex >= span.start && localIndex < span.start + span.count
|
|
1769
|
+
? localIndex - span.start
|
|
1770
|
+
: index - span.start;
|
|
1771
|
+
groupEntries.push({
|
|
1772
|
+
kind: "result",
|
|
1773
|
+
resultIndex: index,
|
|
1774
|
+
rowNumber: index - span.start + 1,
|
|
1775
|
+
agentName: foregroundResultDisplayName(details, index, result, `agent-${displayIndex + 1}`),
|
|
1776
|
+
displayIndex,
|
|
1777
|
+
isParallel: true,
|
|
1778
|
+
});
|
|
1779
|
+
}
|
|
1780
|
+
entries.push(...withDuplicateForegroundLabels(groupEntries, span.count));
|
|
1781
|
+
continue;
|
|
1782
|
+
}
|
|
1783
|
+
for (let index = span.start; index < span.start + span.count; index++) {
|
|
1784
|
+
const result = details.results[index];
|
|
1785
|
+
entries.push({
|
|
1786
|
+
kind: "result",
|
|
1787
|
+
resultIndex: index,
|
|
1788
|
+
rowNumber: span.stepIndex + 1,
|
|
1789
|
+
rowLabel: resultRowLabel(label, span.stepIndex + 1),
|
|
1790
|
+
agentName: foregroundResultDisplayName(details, index, result, details.chainAgents?.[span.stepIndex] ?? `step-${span.stepIndex + 1}`),
|
|
1791
|
+
displayIndex: foregroundResultIndex(details, index),
|
|
1792
|
+
});
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
return entries;
|
|
1796
|
+
}
|
|
1797
|
+
function buildMultiProgressLabel(details, hasRunning) {
|
|
1798
|
+
const stepSpans = buildChainStepSpans(details);
|
|
1799
|
+
const hasParallelInChain = details.mode === "chain" && stepSpans.some((span) => span.isParallel);
|
|
1800
|
+
const activeParallelGroup = details.mode === "chain"
|
|
1801
|
+
&& details.currentStepIndex !== undefined
|
|
1802
|
+
&& stepSpans.some((span) => span.stepIndex === details.currentStepIndex && span.isParallel);
|
|
1803
|
+
const itemTitle = details.mode === "parallel" || activeParallelGroup ? "Agent" : "Step";
|
|
1804
|
+
if (details.mode === "parallel") {
|
|
1805
|
+
const totalCount = details.totalSteps ?? details.results.length;
|
|
1806
|
+
const statuses = new Array(totalCount).fill("pending");
|
|
1807
|
+
for (const progress of details.progress ?? []) {
|
|
1808
|
+
if (progress.index >= 0 && progress.index < totalCount)
|
|
1809
|
+
statuses[progress.index] = progress.status;
|
|
1810
|
+
}
|
|
1811
|
+
for (let i = 0; i < details.results.length; i++) {
|
|
1812
|
+
const result = details.results[i];
|
|
1813
|
+
const progressFromArray = details.progress?.find((progress) => progress.index === i)
|
|
1814
|
+
|| details.progress?.find((progress) => progress.agent === result.agent && progress.status === "running");
|
|
1815
|
+
const index = result.progress?.index ?? progressFromArray?.index ?? i;
|
|
1816
|
+
if (index < 0 || index >= totalCount)
|
|
1817
|
+
continue;
|
|
1818
|
+
const status = result.stopped
|
|
1819
|
+
? "stopped"
|
|
1820
|
+
: result.interrupted || result.detached
|
|
1821
|
+
? "detached"
|
|
1822
|
+
: result.progress?.status
|
|
1823
|
+
?? (result.exitCode === 0 ? "completed" : "failed");
|
|
1824
|
+
statuses[index] = status;
|
|
1825
|
+
}
|
|
1826
|
+
const running = statuses.filter((status) => status === "running").length;
|
|
1827
|
+
const done = statuses.filter((status) => status === "completed").length;
|
|
1828
|
+
const headerLabel = hasRunning
|
|
1829
|
+
? `${formatAgentRunningLabel(running)} · ${done}/${totalCount} done`
|
|
1830
|
+
: `${done}/${totalCount} done`;
|
|
1831
|
+
return { headerLabel, itemTitle, totalCount, hasParallelInChain, activeParallelGroup, groupStartIndex: 0, groupEndIndex: totalCount, showActiveGroupOnly: false, logicalStepCount: totalCount };
|
|
1832
|
+
}
|
|
1833
|
+
if (activeParallelGroup) {
|
|
1834
|
+
const currentStepIndex = details.currentStepIndex;
|
|
1835
|
+
const span = stepSpans[currentStepIndex];
|
|
1836
|
+
const groupSize = span?.count ?? 1;
|
|
1837
|
+
const groupStart = span?.start ?? 0;
|
|
1838
|
+
const groupEnd = groupStart + groupSize;
|
|
1839
|
+
let running = 0;
|
|
1840
|
+
let done = 0;
|
|
1841
|
+
for (let index = groupStart; index < groupEnd; index++) {
|
|
1842
|
+
const progressEntry = details.progress?.find((progress) => progress.index === index);
|
|
1843
|
+
const resultEntry = details.results.find((result) => result.progress?.index === index) ?? details.results[index];
|
|
1844
|
+
if (progressEntry?.status === "running" && (!resultEntry || !hasTerminalResultFlag(resultEntry))) {
|
|
1845
|
+
running++;
|
|
1846
|
+
continue;
|
|
1847
|
+
}
|
|
1848
|
+
if (progressEntry?.status === "completed") {
|
|
1849
|
+
done++;
|
|
1850
|
+
continue;
|
|
1851
|
+
}
|
|
1852
|
+
if (resultEntry && isDoneResult(resultEntry))
|
|
1853
|
+
done++;
|
|
1854
|
+
}
|
|
1855
|
+
const totalSteps = details.totalSteps ?? details.chainAgents?.length ?? 1;
|
|
1856
|
+
const headerLabel = hasRunning
|
|
1857
|
+
? `step ${currentStepIndex + 1}/${totalSteps} · parallel group: ${formatAgentRunningLabel(running)} · ${done}/${groupSize} done`
|
|
1858
|
+
: `step ${currentStepIndex + 1}/${totalSteps} · parallel group: ${done}/${groupSize} done`;
|
|
1859
|
+
return { headerLabel, itemTitle, totalCount: groupSize, hasParallelInChain, activeParallelGroup, groupStartIndex: groupStart, groupEndIndex: groupEnd, showActiveGroupOnly: true, logicalStepCount: totalSteps };
|
|
1860
|
+
}
|
|
1861
|
+
if (details.mode === "chain" && details.chainAgents?.length) {
|
|
1862
|
+
const totalCount = details.totalSteps ?? details.chainAgents.length;
|
|
1863
|
+
const doneLogical = stepSpans.filter((span) => {
|
|
1864
|
+
if (span.status && span.status !== "completed")
|
|
1865
|
+
return false;
|
|
1866
|
+
if (span.count === 0)
|
|
1867
|
+
return span.status === "completed";
|
|
1868
|
+
for (let index = span.start; index < span.start + span.count; index++) {
|
|
1869
|
+
const progressEntry = details.progress?.find((progress) => progress.index === index);
|
|
1870
|
+
const resultEntry = details.results.find((result) => result.progress?.index === index) ?? details.results[index];
|
|
1871
|
+
if (progressEntry?.status === "running" || progressEntry?.status === "pending" || progressEntry?.status === "failed")
|
|
1872
|
+
return false;
|
|
1873
|
+
if (!resultEntry || !isDoneResult(resultEntry))
|
|
1874
|
+
return false;
|
|
1875
|
+
}
|
|
1876
|
+
return true;
|
|
1877
|
+
}).length;
|
|
1878
|
+
const currentStep = details.currentStepIndex !== undefined ? details.currentStepIndex + 1 : Math.min(totalCount, doneLogical + (hasRunning ? 1 : 0));
|
|
1879
|
+
const headerLabel = hasRunning ? `step ${currentStep}/${totalCount}` : `step ${doneLogical}/${totalCount}`;
|
|
1880
|
+
return { headerLabel, itemTitle, totalCount, hasParallelInChain, activeParallelGroup, groupStartIndex: 0, groupEndIndex: details.results.length, showActiveGroupOnly: false, logicalStepCount: totalCount };
|
|
1881
|
+
}
|
|
1882
|
+
const totalCount = details.totalSteps ?? details.results.length;
|
|
1883
|
+
const currentStep = details.currentStepIndex !== undefined ? details.currentStepIndex + 1 : Math.min(totalCount, details.results.filter(isDoneResult).length + (hasRunning ? 1 : 0));
|
|
1884
|
+
const done = details.results.filter(isDoneResult).length;
|
|
1885
|
+
const headerLabel = hasRunning ? `step ${currentStep}/${totalCount}` : `step ${done}/${totalCount}`;
|
|
1886
|
+
return { headerLabel, itemTitle, totalCount, hasParallelInChain, activeParallelGroup, groupStartIndex: 0, groupEndIndex: details.results.length, showActiveGroupOnly: false, logicalStepCount: totalCount };
|
|
1887
|
+
}
|
|
1888
|
+
function resultRowLabel(label, stepNumber) {
|
|
1889
|
+
if (label.itemTitle === "Agent")
|
|
1890
|
+
return undefined;
|
|
1891
|
+
if (shouldSuppressSingleStep(label.logicalStepCount))
|
|
1892
|
+
return undefined;
|
|
1893
|
+
return `Step ${stepNumber}/${label.logicalStepCount}`;
|
|
1894
|
+
}
|
|
1895
|
+
function buildForegroundResultEntries(details, label, displayStart, displayEnd, useResultsDirectly) {
|
|
1896
|
+
const fallbackLabel = label.itemTitle.toLowerCase();
|
|
1897
|
+
const entries = Array.from({ length: displayEnd - displayStart }, (_, offset) => {
|
|
1898
|
+
const index = displayStart + offset;
|
|
1899
|
+
const result = details.results[index];
|
|
1900
|
+
const stableIndex = foregroundResultIndex(details, index);
|
|
1901
|
+
const rowNumber = label.showActiveGroupOnly ? index - label.groupStartIndex + 1 : stableIndex + 1;
|
|
1902
|
+
const fallbackAgent = useResultsDirectly
|
|
1903
|
+
? (result?.agent || `${fallbackLabel}-${rowNumber}`)
|
|
1904
|
+
: (details.chainAgents[index] || result?.agent || `${fallbackLabel}-${rowNumber}`);
|
|
1905
|
+
const displayIndex = label.activeParallelGroup && stableIndex >= label.groupStartIndex && stableIndex < label.groupEndIndex
|
|
1906
|
+
? stableIndex - label.groupStartIndex
|
|
1907
|
+
: label.activeParallelGroup ? index - label.groupStartIndex : stableIndex;
|
|
1908
|
+
return {
|
|
1909
|
+
kind: "result",
|
|
1910
|
+
resultIndex: index,
|
|
1911
|
+
rowNumber,
|
|
1912
|
+
rowLabel: resultRowLabel(label, rowNumber),
|
|
1913
|
+
agentName: foregroundResultDisplayName(details, index, result, fallbackAgent),
|
|
1914
|
+
displayIndex,
|
|
1915
|
+
};
|
|
1916
|
+
});
|
|
1917
|
+
return label.itemTitle === "Agent" ? withDuplicateForegroundLabels(entries, label.totalCount) : entries;
|
|
1918
|
+
}
|
|
1919
|
+
function widgetStats(job, theme, projection = buildWorkflowWidgetProjection(job), collapsed = false) {
|
|
1920
|
+
const parts = [];
|
|
1921
|
+
const { stageProgress } = projection;
|
|
1922
|
+
const stepsTotal = stageProgress?.total ?? job.stepsTotal ?? (job.agents?.length ?? 1);
|
|
1923
|
+
const isSingleChild = isSingleChildAsyncJob(job);
|
|
1924
|
+
const checklistPrimary = collapsed && job.mode === "workflow" && projection.checklist !== undefined;
|
|
1925
|
+
if (checklistPrimary) {
|
|
1926
|
+
parts.push(formatWorkflowChecklistSummary(projection.checklist));
|
|
1927
|
+
}
|
|
1928
|
+
else if (stageProgress) {
|
|
1929
|
+
const currentStage = stageProgress.current !== undefined ? projection.stages[stageProgress.current] : undefined;
|
|
1930
|
+
const focus = currentStage
|
|
1931
|
+
? [compactTaskText(undefined, currentStage.label) ?? boundedLaneValue(currentStage.id), currentStage.agent ? boundedLaneValue(currentStage.agent) : "", workflowNodeStatusLabel(currentStage.status)].filter(Boolean)
|
|
1932
|
+
: [];
|
|
1933
|
+
parts.push(["staged lane", stageProgress.current !== undefined ? `stage ${stageProgress.current + 1}/${stageProgress.total}` : `${stageProgress.total} stages`, ...focus].join(" · "));
|
|
1934
|
+
}
|
|
1935
|
+
else if (job.activeParallelGroup) {
|
|
1936
|
+
const running = job.runningSteps ?? (job.status === "running" ? 1 : 0);
|
|
1937
|
+
const done = job.completedSteps ?? (job.status === "complete" ? stepsTotal : 0);
|
|
1938
|
+
if (job.mode === "parallel") {
|
|
1939
|
+
if (job.status === "running" && running > 0)
|
|
1940
|
+
parts.push(formatAgentRunningLabel(running));
|
|
1941
|
+
if (stepsTotal > 0)
|
|
1942
|
+
parts.push(`${done}/${stepsTotal} done`);
|
|
1943
|
+
}
|
|
1944
|
+
else {
|
|
1945
|
+
const activeGroup = job.currentStep !== undefined
|
|
1946
|
+
? job.parallelGroups?.find((group) => job.currentStep >= group.start && job.currentStep < group.start + group.count)
|
|
1947
|
+
: job.parallelGroups?.find((group) => group.start === 0);
|
|
1948
|
+
const logicalStep = activeGroup?.stepIndex ?? job.currentStep ?? 0;
|
|
1949
|
+
const total = job.chainStepCount ?? stepsTotal;
|
|
1950
|
+
const groupParts = [`${done}/${stepsTotal} done`];
|
|
1951
|
+
if (job.status === "running" && running > 0)
|
|
1952
|
+
groupParts.unshift(formatAgentRunningLabel(running));
|
|
1953
|
+
parts.push(`step ${logicalStep + 1}/${total} · parallel group: ${groupParts.join(" · ")}`);
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
else if (job.currentStep !== undefined) {
|
|
1957
|
+
if (job.mode === "chain") {
|
|
1958
|
+
const total = job.chainStepCount ?? stepsTotal;
|
|
1959
|
+
parts.push(`step ${flatToLogicalStepIndex(job.currentStep, total, job.parallelGroups ?? []) + 1}/${total}`);
|
|
1960
|
+
}
|
|
1961
|
+
else if (!isSingleChild) {
|
|
1962
|
+
parts.push(`step ${job.currentStep + 1}/${stepsTotal}`);
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
else if (stepsTotal > 1) {
|
|
1966
|
+
parts.push(`steps ${stepsTotal}`);
|
|
1967
|
+
}
|
|
1968
|
+
if (projection.checklist && !checklistPrimary)
|
|
1969
|
+
parts.push(formatWorkflowChecklistSummary(projection.checklist));
|
|
1970
|
+
if (job.toolCount !== undefined)
|
|
1971
|
+
parts.push(formatToolUseStat(job.toolCount));
|
|
1972
|
+
if (job.totalTokens?.total)
|
|
1973
|
+
parts.push(formatTokenUsage(job.totalTokens, "token"));
|
|
1974
|
+
const end = job.status === "running" && (job.mode === "workflow" || job.parentWorkflowRunId) ? projection.now : job.updatedAt;
|
|
1975
|
+
if (job.status !== "queued" && job.startedAt !== undefined && end !== undefined)
|
|
1976
|
+
parts.push(formatDuration(Math.max(0, end - job.startedAt)));
|
|
1977
|
+
return statJoin(theme, parts);
|
|
1978
|
+
}
|
|
1979
|
+
function widgetStepStats(theme, step) {
|
|
1980
|
+
return statJoin(theme, [
|
|
1981
|
+
step.turnCount !== undefined ? `${step.turnCount} turns` : "",
|
|
1982
|
+
step.toolCount !== undefined ? formatToolUseStat(step.toolCount) : "",
|
|
1983
|
+
step.tokens
|
|
1984
|
+
? step.contextLimit !== undefined
|
|
1985
|
+
? formatContextUsage(step.tokens, step.contextLimit) ?? formatTokenUsage(step.tokens, "token")
|
|
1986
|
+
: step.tokens.total ? formatTokenUsage(step.tokens, "token") : ""
|
|
1987
|
+
: "",
|
|
1988
|
+
step.durationMs !== undefined ? formatDuration(step.durationMs) : "",
|
|
1989
|
+
]);
|
|
1990
|
+
}
|
|
1991
|
+
function modelThinkingBadge(theme, model, thinking) {
|
|
1992
|
+
const label = formatModelThinking(model, thinking);
|
|
1993
|
+
return label ? theme.fg("dim", ` (${label})`) : "";
|
|
1994
|
+
}
|
|
1995
|
+
function widgetStepActivityLine(step, width, expanded, snapshotNow) {
|
|
1996
|
+
const toolLine = formatCurrentToolLine(step, width, expanded, snapshotNow);
|
|
1997
|
+
if (toolLine)
|
|
1998
|
+
return toolLine;
|
|
1999
|
+
const activity = buildLiveStatusLine(step, snapshotNow);
|
|
2000
|
+
if (activity)
|
|
2001
|
+
return activity;
|
|
2002
|
+
if (step.status === "running")
|
|
2003
|
+
return "thinking…";
|
|
2004
|
+
return "";
|
|
2005
|
+
}
|
|
2006
|
+
function widgetOutputPath(job, step) {
|
|
2007
|
+
if (typeof step.index !== "number")
|
|
2008
|
+
return undefined;
|
|
2009
|
+
return path.join(job.asyncDir, `output-${step.index}.log`);
|
|
2010
|
+
}
|
|
2011
|
+
function nestedRunName(run) {
|
|
2012
|
+
if (run.sessionName?.trim())
|
|
2013
|
+
return run.sessionName.trim();
|
|
2014
|
+
if (run.agent)
|
|
2015
|
+
return run.agent;
|
|
2016
|
+
if (run.agents?.length)
|
|
2017
|
+
return formatWidgetAgents(run.agents);
|
|
2018
|
+
return run.id;
|
|
2019
|
+
}
|
|
2020
|
+
function nestedStatusGlyph(state, theme, seed) {
|
|
2021
|
+
if (state === "running")
|
|
2022
|
+
return theme.fg("accent", runningGlyph(seed));
|
|
2023
|
+
if (state === "complete" || state === "completed")
|
|
2024
|
+
return theme.fg("success", "✓");
|
|
2025
|
+
if (state === "failed")
|
|
2026
|
+
return theme.fg("error", "✗");
|
|
2027
|
+
if (state === "partial")
|
|
2028
|
+
return theme.fg("warning", "■");
|
|
2029
|
+
if (state === "paused")
|
|
2030
|
+
return theme.fg("warning", "■");
|
|
2031
|
+
if (state === "stopped")
|
|
2032
|
+
return theme.fg("warning", "■");
|
|
2033
|
+
return theme.fg("muted", "◦");
|
|
2034
|
+
}
|
|
2035
|
+
function nestedRunSeed(run) {
|
|
2036
|
+
return runningSeed(run.lastUpdate, run.lastActivityAt, run.currentStep, run.toolCount, run.turnCount, run.totalTokens?.total, run.currentToolStartedAt);
|
|
2037
|
+
}
|
|
2038
|
+
function formatClockTime(ms) {
|
|
2039
|
+
if (ms === undefined || !Number.isFinite(ms))
|
|
2040
|
+
return undefined;
|
|
2041
|
+
const date = new Date(ms);
|
|
2042
|
+
const pad = (value) => value.toString().padStart(2, "0");
|
|
2043
|
+
return `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
|
2044
|
+
}
|
|
2045
|
+
function nestedRunEventTime(run) {
|
|
2046
|
+
return run.state === "running"
|
|
2047
|
+
? (run.lastActivityAt ?? run.currentToolStartedAt ?? run.lastUpdate ?? run.startedAt)
|
|
2048
|
+
: (run.endedAt ?? run.lastUpdate ?? run.lastActivityAt ?? run.startedAt);
|
|
2049
|
+
}
|
|
2050
|
+
function nestedStepTimestamp(step, fallback) {
|
|
2051
|
+
return formatClockTime(step.status === "running"
|
|
2052
|
+
? (step.lastActivityAt ?? step.currentToolStartedAt ?? fallback ?? step.startedAt)
|
|
2053
|
+
: (step.endedAt ?? step.lastActivityAt ?? fallback ?? step.startedAt));
|
|
2054
|
+
}
|
|
2055
|
+
function nestedTimestampPrefix(timestamp) {
|
|
2056
|
+
return timestamp ? `[${timestamp}] ` : "";
|
|
2057
|
+
}
|
|
2058
|
+
function nestedActivity(input, state, snapshotNow) {
|
|
2059
|
+
const facts = [];
|
|
2060
|
+
if (input.currentTool && input.currentToolStartedAt !== undefined && snapshotNow !== undefined)
|
|
2061
|
+
facts.push(`${input.currentTool} ${formatDuration(Math.max(0, snapshotNow - input.currentToolStartedAt))}`);
|
|
2062
|
+
else if (input.currentTool)
|
|
2063
|
+
facts.push(input.currentTool);
|
|
2064
|
+
if (input.currentPath)
|
|
2065
|
+
facts.push(shortenPath(input.currentPath));
|
|
2066
|
+
if (input.turnCount !== undefined)
|
|
2067
|
+
facts.push(`${input.turnCount} turns`);
|
|
2068
|
+
if (input.toolCount !== undefined)
|
|
2069
|
+
facts.push(`${input.toolCount} tools`);
|
|
2070
|
+
const activity = buildLiveStatusLine(input, snapshotNow);
|
|
2071
|
+
if (activity && facts.length)
|
|
2072
|
+
return `${activity} · ${facts.join(" · ")}`;
|
|
2073
|
+
if (activity)
|
|
2074
|
+
return activity;
|
|
2075
|
+
if (facts.length)
|
|
2076
|
+
return facts.join(" · ");
|
|
2077
|
+
if (state === "running")
|
|
2078
|
+
return "thinking…";
|
|
2079
|
+
if (state === "queued" || state === "pending")
|
|
2080
|
+
return "queued…";
|
|
2081
|
+
if (state === "paused")
|
|
2082
|
+
return "Paused";
|
|
2083
|
+
if (state === "stopped")
|
|
2084
|
+
return "Stopped";
|
|
2085
|
+
if (state === "partial")
|
|
2086
|
+
return "Partial";
|
|
2087
|
+
if (state === "failed")
|
|
2088
|
+
return "Failed";
|
|
2089
|
+
return "Done";
|
|
2090
|
+
}
|
|
2091
|
+
function formatNestedWidgetLines(children, theme, width, expanded, snapshotNow, lineBudget = expanded ? 12 : 1) {
|
|
2092
|
+
if (!children?.length || lineBudget <= 0)
|
|
2093
|
+
return [];
|
|
2094
|
+
if (!expanded) {
|
|
2095
|
+
const rows = [];
|
|
2096
|
+
const maxLeaves = 4;
|
|
2097
|
+
const maxLines = Math.min(6, lineBudget);
|
|
2098
|
+
let leaves = 0;
|
|
2099
|
+
let overflow = 0;
|
|
2100
|
+
const appendLeaf = (step, prefix, fallback) => {
|
|
2101
|
+
if (leaves >= maxLeaves) {
|
|
2102
|
+
overflow++;
|
|
2103
|
+
return;
|
|
2104
|
+
}
|
|
2105
|
+
leaves++;
|
|
2106
|
+
const state = "status" in step ? step.status : step.state;
|
|
2107
|
+
const modelThinking = formatModelThinking(step.model, step.thinking);
|
|
2108
|
+
const activity = nestedActivity(step, state, snapshotNow ?? fallback);
|
|
2109
|
+
const timestamp = "status" in step ? nestedStepTimestamp(step, fallback) : formatClockTime(nestedRunEventTime(step));
|
|
2110
|
+
const error = step.error ? ` · ${step.error}` : "";
|
|
2111
|
+
const name = "status" in step ? childDisplayName(step) : nestedRunName(step);
|
|
2112
|
+
rows.push({
|
|
2113
|
+
prefix,
|
|
2114
|
+
text: `${nestedTimestampPrefix(timestamp)}${nestedStatusGlyph(state, theme)} ${name} · ${state}${modelThinking ? ` · ${modelThinking}` : ""}${activity ? ` · ${activity}` : ""}${error}`,
|
|
2115
|
+
});
|
|
2116
|
+
};
|
|
2117
|
+
for (const child of children) {
|
|
2118
|
+
const steps = (child.mode === "parallel" || child.mode === "chain") ? child.steps ?? [] : [];
|
|
2119
|
+
if (steps.length > 0) {
|
|
2120
|
+
const ownerModelThinking = formatModelThinking(child.model, child.thinking);
|
|
2121
|
+
const ownerActivity = nestedActivity(child, child.state, snapshotNow ?? child.lastUpdate);
|
|
2122
|
+
const ownerError = child.error ? ` · ${child.error}` : "";
|
|
2123
|
+
rows.push({
|
|
2124
|
+
prefix: "↳ ",
|
|
2125
|
+
text: `OWNER ${nestedStatusGlyph(child.state, theme, nestedRunSeed(child))} ${nestedRunName(child)} · ${child.state}${ownerModelThinking ? ` · ${ownerModelThinking}` : ""}${ownerActivity ? ` · ${ownerActivity}` : ""}${ownerError}`,
|
|
2126
|
+
});
|
|
2127
|
+
for (const step of steps)
|
|
2128
|
+
appendLeaf(step, "↳ │ ", child.lastUpdate);
|
|
2129
|
+
}
|
|
2130
|
+
else {
|
|
2131
|
+
appendLeaf(child, "↳ ", child.lastUpdate);
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
if (overflow > 0)
|
|
2135
|
+
rows.push({ prefix: "↳ ", text: `… +${overflow} more nested leaves` });
|
|
2136
|
+
const visibleRows = rows.length <= maxLines
|
|
2137
|
+
? rows
|
|
2138
|
+
: overflow > 0
|
|
2139
|
+
? [...rows.slice(0, Math.max(0, maxLines - 1)), rows.at(-1)]
|
|
2140
|
+
: rows.slice(0, maxLines);
|
|
2141
|
+
return visibleRows.map((row, index) => {
|
|
2142
|
+
const marker = index === visibleRows.length - 1 ? "└─" : "├─";
|
|
2143
|
+
const prefix = row.prefix;
|
|
2144
|
+
const text = row.text.startsWith("OWNER ") ? row.text.slice("OWNER ".length) : row.text;
|
|
2145
|
+
return truncLine(theme.fg("dim", `${prefix}${marker} ${text}`), width);
|
|
2146
|
+
});
|
|
2147
|
+
}
|
|
2148
|
+
const lines = [];
|
|
2149
|
+
const maxDepth = 2;
|
|
2150
|
+
const append = (items, depth, prefix) => {
|
|
2151
|
+
if (!items?.length || lines.length >= lineBudget)
|
|
2152
|
+
return;
|
|
2153
|
+
if (depth > maxDepth) {
|
|
2154
|
+
const aggregate = formatNestedAggregate(items);
|
|
2155
|
+
if (aggregate && lines.length < lineBudget)
|
|
2156
|
+
lines.push(theme.fg("dim", `${prefix}↳ ${aggregate}`));
|
|
2157
|
+
return;
|
|
2158
|
+
}
|
|
2159
|
+
for (let index = 0; index < items.length; index++) {
|
|
2160
|
+
const child = items[index];
|
|
2161
|
+
if (lines.length >= lineBudget) {
|
|
2162
|
+
const aggregate = formatNestedAggregate(items.slice(index));
|
|
2163
|
+
if (aggregate)
|
|
2164
|
+
lines[lines.length - 1] = theme.fg("dim", `${prefix}↳ ${aggregate}`);
|
|
2165
|
+
return;
|
|
2166
|
+
}
|
|
2167
|
+
const activity = nestedActivity(child, child.state, snapshotNow ?? child.lastUpdate);
|
|
2168
|
+
const error = child.error ? ` · ${child.error}` : "";
|
|
2169
|
+
const modelThinking = formatModelThinking(child.model, child.thinking);
|
|
2170
|
+
lines.push(theme.fg("dim", `${prefix}↳ ${nestedTimestampPrefix(formatClockTime(nestedRunEventTime(child)))}${nestedStatusGlyph(child.state, theme, nestedRunSeed(child))} ${nestedRunName(child)} · ${child.state}${modelThinking ? ` · ${modelThinking}` : ""} · ${activity}${error}`));
|
|
2171
|
+
if (depth === maxDepth) {
|
|
2172
|
+
const aggregate = formatNestedAggregate([...(child.steps?.flatMap((step) => step.children ?? []) ?? []), ...(child.children ?? [])]);
|
|
2173
|
+
if (aggregate && lines.length < lineBudget)
|
|
2174
|
+
lines.push(theme.fg("dim", `${prefix} ↳ ${aggregate}`));
|
|
2175
|
+
continue;
|
|
2176
|
+
}
|
|
2177
|
+
for (const step of child.steps ?? []) {
|
|
2178
|
+
if (lines.length >= lineBudget)
|
|
2179
|
+
return;
|
|
2180
|
+
const modelThinking = formatModelThinking(step.model, step.thinking);
|
|
2181
|
+
lines.push(theme.fg("dim", `${prefix} ↳ ${nestedTimestampPrefix(nestedStepTimestamp(step, child.lastUpdate))}${nestedStatusGlyph(step.status, theme)} ${childDisplayName(step)} · ${step.status}${modelThinking ? ` · ${modelThinking}` : ""} · ${nestedActivity(step, step.status, snapshotNow ?? child.lastUpdate)}`));
|
|
2182
|
+
append(step.children, depth + 1, `${prefix} `);
|
|
2183
|
+
}
|
|
2184
|
+
append(child.children, depth + 1, `${prefix} `);
|
|
2185
|
+
}
|
|
2186
|
+
};
|
|
2187
|
+
append(children, 0, "");
|
|
2188
|
+
return lines.map((line) => truncLine(line, width));
|
|
2189
|
+
}
|
|
2190
|
+
function foregroundStyleWidgetStepLines(job, theme, step, itemTitle, index, total, expanded, width, frame, options) {
|
|
2191
|
+
const rowIndent = options?.rowIndent ?? " ";
|
|
2192
|
+
const detailIndent = options?.detailIndent ?? " ";
|
|
2193
|
+
const status = widgetStepStatus(step.status, theme);
|
|
2194
|
+
const stats = widgetStepStats(theme, step);
|
|
2195
|
+
const modelDisplay = modelThinkingBadge(theme, step.model, step.thinking);
|
|
2196
|
+
const collapseDetails = shouldCollapseSingleChildDetails(job, step);
|
|
2197
|
+
const displayName = collapseDetails ? singleChildAgentName(job, step) : childDisplayName(step);
|
|
2198
|
+
const stageName = itemTitle === "Stage"
|
|
2199
|
+
? compactTaskText(undefined, step.label) ?? boundedLaneValue(step.workflowKey) ?? displayName
|
|
2200
|
+
: undefined;
|
|
2201
|
+
const stageIdentity = stageName && stageName !== displayName ? `${stageName} (${displayName})` : stageName ?? displayName;
|
|
2202
|
+
const rowLabel = collapseDetails ? displayName : (options?.rowLabel ?? `${itemTitle} ${index}/${total}: ${itemTitle === "Stage" ? stageIdentity : displayName}`);
|
|
2203
|
+
const rowMarker = options?.rowMarker ? `${options.rowMarker} ` : "";
|
|
2204
|
+
const lines = [`${rowIndent}${rowMarker}${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, index - 1), frame)} ${themeBold(theme, rowLabel)}${contextModeBadge(theme, step.context)} ${theme.fg("dim", "·")} ${status}${modelDisplay}${stats ? ` ${theme.fg("dim", "·")} ${stats}` : ""}`];
|
|
2205
|
+
const lane = projectAsyncLane(job, step);
|
|
2206
|
+
if (lane)
|
|
2207
|
+
lines.push(...formatLaneProjectionLines(lane, theme, detailIndent));
|
|
2208
|
+
const task = collapseDetails ? singleChildTask(job, step) : compactTaskText(step.description, step.label);
|
|
2209
|
+
if (task)
|
|
2210
|
+
lines.push(`${detailIndent}${theme.fg("dim", `task: ${task}`)}`);
|
|
2211
|
+
const activity = widgetStepActivityLine(step, width, expanded, job.updatedAt);
|
|
2212
|
+
const currentPath = options?.includeCurrentPath && step.currentPath ? shortenPath(step.currentPath) : undefined;
|
|
2213
|
+
const activityWithPath = currentPath && activity && !activity.includes(currentPath)
|
|
2214
|
+
? `${activity} · ${currentPath}`
|
|
2215
|
+
: activity ?? currentPath;
|
|
2216
|
+
if (activityWithPath)
|
|
2217
|
+
lines.push(`${detailIndent}${theme.fg("dim", `⎿ ${activityWithPath}`)}`);
|
|
2218
|
+
for (const nestedLine of formatNestedWidgetLines(step.children, theme, width, expanded, job.updatedAt, expanded ? 12 : 6)) {
|
|
2219
|
+
lines.push(`${detailIndent}${nestedLine}`);
|
|
2220
|
+
}
|
|
2221
|
+
const error = step.error?.trim() || step.execution?.error?.trim();
|
|
2222
|
+
if (error)
|
|
2223
|
+
lines.push(`${detailIndent}${theme.fg("error", `error: ${oneLine(error)}`)}`);
|
|
2224
|
+
if (step.status === "running") {
|
|
2225
|
+
if (!expanded)
|
|
2226
|
+
lines.push(`${detailIndent}${theme.fg("accent", liveDetailHintText())}`);
|
|
2227
|
+
const output = widgetOutputPath(job, step);
|
|
2228
|
+
if (output)
|
|
2229
|
+
lines.push(`${detailIndent}${theme.fg("dim", `output: ${shortenPath(output)}`)}`);
|
|
2230
|
+
if (expanded) {
|
|
2231
|
+
const liveStatus = buildLiveStatusLine(step, job.updatedAt);
|
|
2232
|
+
if (liveStatus && liveStatus !== activity)
|
|
2233
|
+
lines.push(`${detailIndent}${theme.fg("accent", liveStatus)}`);
|
|
2234
|
+
for (const tool of step.recentTools?.slice(-3) ?? []) {
|
|
2235
|
+
const maxArgsLen = Math.max(40, width - 30);
|
|
2236
|
+
const argsPreview = renderToolArgsPreview(tool.args, maxArgsLen, expanded);
|
|
2237
|
+
lines.push(`${detailIndent} ${theme.fg("dim", `${tool.tool}${argsPreview ? `: ${argsPreview}` : ""}`)}`);
|
|
2238
|
+
}
|
|
2239
|
+
for (const line of compactRecentOutputLines(step.recentOutput)) {
|
|
2240
|
+
lines.push(`${detailIndent} ${theme.fg("dim", line)}`);
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
return lines;
|
|
2245
|
+
}
|
|
2246
|
+
function hostStepWidgetLines(job, theme, indent) {
|
|
2247
|
+
const rows = projectAsyncWorkflowRows([], job.hostSteps).filter((row) => row.kind);
|
|
2248
|
+
const visible = rows.slice(0, 8);
|
|
2249
|
+
const lines = visible.map((row) => {
|
|
2250
|
+
const state = hostStepVerdictLabel(row.state, row.verdict);
|
|
2251
|
+
const glyph = state === "running" ? theme.fg("accent", "●")
|
|
2252
|
+
: state === "pending" ? theme.fg("muted", "◦")
|
|
2253
|
+
: state === "pass" ? theme.fg("success", "✓")
|
|
2254
|
+
: state === "fail" || state === "error" ? theme.fg("error", "✗")
|
|
2255
|
+
: theme.fg("warning", "■");
|
|
2256
|
+
const details = [
|
|
2257
|
+
row.provider ? `provider:${row.provider}` : undefined,
|
|
2258
|
+
row.role ? `role:${row.role}` : undefined,
|
|
2259
|
+
row.target,
|
|
2260
|
+
row.detail,
|
|
2261
|
+
row.reasonCode ? `reason:${row.reasonCode}` : undefined,
|
|
2262
|
+
row.freshness?.stale ? "stale" : row.freshness?.observedRef ? `ref:${row.freshness.observedRef}` : undefined,
|
|
2263
|
+
row.reportPath ? `out:${hostStepReportName(row.reportPath)}` : undefined,
|
|
2264
|
+
].filter(Boolean).join(" · ");
|
|
2265
|
+
return `${indent}${glyph} ${row.kind}: ${row.name} · ${state}${details ? ` · ${details}` : ""}`;
|
|
2266
|
+
});
|
|
2267
|
+
if (rows.length > visible.length)
|
|
2268
|
+
lines.push(`${indent}${theme.fg("dim", `… +${rows.length - visible.length} host steps hidden`)}`);
|
|
2269
|
+
return lines;
|
|
2270
|
+
}
|
|
2271
|
+
function foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projection = buildWorkflowWidgetProjection(job)) {
|
|
2272
|
+
const steps = projection.steps.filter((step) => !projection.materializedKeys?.has(step.workflowKey ?? "") && !projection.materializedKeys?.has(step.runId ?? ""));
|
|
2273
|
+
const checklist = widgetChecklistWithoutMaterializedChildren(projection);
|
|
2274
|
+
if (!expanded && job.mode === "workflow") {
|
|
2275
|
+
return compactWorkflowWidgetBodyLines(job, theme, frame, projection);
|
|
2276
|
+
}
|
|
2277
|
+
if (!steps.length) {
|
|
2278
|
+
const lane = projectAsyncLane(job, laneStepForJob(job, steps));
|
|
2279
|
+
return [
|
|
2280
|
+
...(expanded ? workflowPreflightLines(job) : []),
|
|
2281
|
+
...workflowChecklistWidgetLines(checklist, theme, " ", expanded, frame),
|
|
2282
|
+
...(lane ? formatLaneProjectionLines(lane, theme, " ") : []),
|
|
2283
|
+
...hostStepWidgetLines(job, theme, " "),
|
|
2284
|
+
` ${theme.fg("dim", `⎿ ${widgetActivity(job)}`)}`,
|
|
2285
|
+
...formatNestedWidgetLines(job.nestedChildren, theme, width, expanded, job.updatedAt, expanded ? 12 : 6).map((line) => ` ${line}`),
|
|
2286
|
+
];
|
|
2287
|
+
}
|
|
2288
|
+
if (job.mode === "chain" && !job.activeParallelGroup && job.parallelGroups?.length)
|
|
2289
|
+
return widgetChainDetails(job, theme, expanded, width, frame);
|
|
2290
|
+
const lines = [
|
|
2291
|
+
...(expanded ? workflowPreflightLines(job) : []),
|
|
2292
|
+
...workflowChecklistWidgetLines(checklist, theme, " ", expanded, frame, { includeItemErrors: !expanded }),
|
|
2293
|
+
];
|
|
2294
|
+
const group = activeParallelWidgetGroup(job);
|
|
2295
|
+
if (group) {
|
|
2296
|
+
lines.push(...parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, Boolean(job.activeParallelGroup)));
|
|
2297
|
+
}
|
|
2298
|
+
else {
|
|
2299
|
+
const { stageProgress, plannedKeys } = projection;
|
|
2300
|
+
const total = job.mode === "chain"
|
|
2301
|
+
? job.chainStepCount ?? job.stepsTotal ?? steps.length
|
|
2302
|
+
: stageProgress?.total ?? job.stepsTotal ?? steps.length;
|
|
2303
|
+
const stageTotal = stageProgress?.total ?? total;
|
|
2304
|
+
const extraStepCount = plannedKeys
|
|
2305
|
+
? steps.filter((step) => step.workflowKey === undefined || !plannedKeys.has(step.workflowKey)).length
|
|
2306
|
+
: total;
|
|
2307
|
+
let extraStepIndex = 0;
|
|
2308
|
+
for (const [index, step] of steps.entries()) {
|
|
2309
|
+
const isPlannedStage = plannedKeys !== undefined && step.workflowKey !== undefined && plannedKeys.has(step.workflowKey);
|
|
2310
|
+
const itemTitle = isPlannedStage ? "Stage" : "Step";
|
|
2311
|
+
const displayIndex = isPlannedStage ? (step.index ?? index) + 1 : plannedKeys ? ++extraStepIndex : index + 1;
|
|
2312
|
+
const displayTotal = isPlannedStage ? stageTotal : extraStepCount;
|
|
2313
|
+
lines.push(...foregroundStyleWidgetStepLines(job, theme, step, itemTitle, displayIndex, displayTotal, expanded, width, frame));
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
lines.push(...hostStepWidgetLines(job, theme, " "));
|
|
2317
|
+
const attached = new Set(steps.flatMap((step) => step.children?.map((child) => child.id) ?? []));
|
|
2318
|
+
const unattached = job.nestedChildren?.filter((child) => !attached.has(child.id)) ?? [];
|
|
2319
|
+
for (const nestedLine of formatNestedWidgetLines(unattached, theme, width, expanded, job.updatedAt, expanded ? 12 : 6)) {
|
|
2320
|
+
lines.push(` ${nestedLine}`);
|
|
2321
|
+
}
|
|
2322
|
+
return lines;
|
|
2323
|
+
}
|
|
2324
|
+
function buildSingleWidgetLines(job, theme, width, expanded, frame, projection = buildWorkflowWidgetProjection(job)) {
|
|
2325
|
+
if ((!expanded || projection.inlineFleetCovered) && job.mode === "workflow")
|
|
2326
|
+
return [compactWorkflowHeaderLine(job, theme, width), ...compactWorkflowWidgetBodyLines(job, theme, frame, projection)].map((line) => truncLine(line, width));
|
|
2327
|
+
const stats = widgetStats(job, theme, projection, !expanded);
|
|
2328
|
+
const count = job.mode === "workflow"
|
|
2329
|
+
? projection.checklist?.total ?? projection.stageProgress?.total ?? job.stepsTotal ?? job.agents?.length ?? job.steps?.length
|
|
2330
|
+
: job.mode === "chain" ? job.chainStepCount : projection.stageProgress?.total ?? job.stepsTotal ?? job.agents?.length ?? job.steps?.length;
|
|
2331
|
+
const mode = widgetJobName(job);
|
|
2332
|
+
const title = isSingleChildAsyncJob(job)
|
|
2333
|
+
? "async subagent"
|
|
2334
|
+
: `async subagent ${mode}${count && count > 1 ? ` (${count})` : ""}`;
|
|
2335
|
+
const checklistPrimary = !expanded && job.mode === "workflow" && projection.checklist !== undefined;
|
|
2336
|
+
const collapseDetails = !checklistPrimary && job.steps?.length === 1 && shouldCollapseSingleChildDetails(job, job.steps[0]);
|
|
2337
|
+
const summary = `${widgetStatusGlyph(job, theme, frame)} ${themeBold(theme, mode)}${contextModeBadge(theme, job.context)}${stats ? ` ${theme.fg("dim", "·")} ${stats}` : ""}`;
|
|
2338
|
+
return [
|
|
2339
|
+
`${theme.fg("toolTitle", themeBold(theme, title))} ${theme.fg("dim", "· background")}`,
|
|
2340
|
+
...(collapseDetails ? [] : [summary]),
|
|
2341
|
+
...foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projection),
|
|
2342
|
+
].map((line) => truncLine(line, width));
|
|
2343
|
+
}
|
|
2344
|
+
function compactSingleWidgetLines(job, theme, width, frame, projection = buildWorkflowWidgetProjection(job)) {
|
|
2345
|
+
const fullLines = buildSingleWidgetLines(job, theme, width, false, frame, projection);
|
|
2346
|
+
if (fullLines.length <= 10 || !job.steps?.length || (job.mode !== "parallel" && !job.activeParallelGroup))
|
|
2347
|
+
return fullLines;
|
|
2348
|
+
const group = activeParallelWidgetGroup(job);
|
|
2349
|
+
if (!group)
|
|
2350
|
+
return fullLines;
|
|
2351
|
+
const rows = parallelWidgetStepRows(group.steps, group.total, Boolean(job.activeParallelGroup));
|
|
2352
|
+
const lines = fullLines.slice(0, 2);
|
|
2353
|
+
lines.push(parallelWidgetGroupHeader(group, theme, frame));
|
|
2354
|
+
for (const [rowIndex, row] of rows.entries()) {
|
|
2355
|
+
const step = row.step;
|
|
2356
|
+
const status = widgetStepStatus(step.status, theme);
|
|
2357
|
+
const activity = widgetStepActivityLine(step, width, false, job.updatedAt);
|
|
2358
|
+
const stepStats = widgetStepStats(theme, step);
|
|
2359
|
+
const activitySuffix = activity ? ` ${theme.fg("dim", "·")} ${theme.fg("dim", activity)}` : "";
|
|
2360
|
+
const modelDisplay = modelThinkingBadge(theme, step.model, step.thinking);
|
|
2361
|
+
const task = compactTaskText(step.description, step.label);
|
|
2362
|
+
const taskSuffix = task ? ` ${theme.fg("dim", "·")} ${theme.fg("dim", `task: ${task}`)}` : "";
|
|
2363
|
+
const marker = rowIndex === rows.length - 1 && rowIndex >= group.total - 1 ? "└─" : "├─";
|
|
2364
|
+
lines.push(` ${marker} ${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, row.index), frame)} ${themeBold(theme, row.rowLabel)}${contextModeBadge(theme, step.context)} ${theme.fg("dim", "·")} ${status}${modelDisplay}${taskSuffix}${activitySuffix}${stepStats ? ` ${theme.fg("dim", "·")} ${stepStats}` : ""}`);
|
|
2365
|
+
const lane = projectAsyncLane(job, step);
|
|
2366
|
+
if (lane)
|
|
2367
|
+
lines.push(...formatLaneProjectionLines(lane, theme, " "));
|
|
2368
|
+
for (const nestedLine of formatNestedWidgetLines(step.children, theme, width, false, job.updatedAt, 6))
|
|
2369
|
+
lines.push(` ${nestedLine}`);
|
|
2370
|
+
}
|
|
2371
|
+
lines.push(...hostStepWidgetLines(job, theme, " "));
|
|
2372
|
+
if (job.steps.some((step) => step.status === "running"))
|
|
2373
|
+
lines.push(theme.fg("accent", ` ${liveDetailHintText()}`));
|
|
2374
|
+
return lines.map((line) => truncLine(line, width));
|
|
2375
|
+
}
|
|
2376
|
+
const RESERVED_NON_WIDGET_ROWS = 19;
|
|
2377
|
+
let widgetLayoutSession;
|
|
2378
|
+
function resetWidgetLayoutSession() {
|
|
2379
|
+
widgetLayoutSession = undefined;
|
|
2380
|
+
}
|
|
2381
|
+
function estimateAvailableWidgetRows() {
|
|
2382
|
+
const rows = process.stdout.rows || 30;
|
|
2383
|
+
return Math.max(1, rows - RESERVED_NON_WIDGET_ROWS);
|
|
2384
|
+
}
|
|
2385
|
+
function currentTerminalRows() {
|
|
2386
|
+
return process.stdout.rows || 30;
|
|
2387
|
+
}
|
|
2388
|
+
function currentTerminalColumns() {
|
|
2389
|
+
return process.stdout.columns || 120;
|
|
2390
|
+
}
|
|
2391
|
+
function widgetSessionMatches(expanded) {
|
|
2392
|
+
return widgetLayoutSession?.expanded === expanded
|
|
2393
|
+
&& widgetLayoutSession.rows === currentTerminalRows()
|
|
2394
|
+
&& widgetLayoutSession.columns === currentTerminalColumns();
|
|
2395
|
+
}
|
|
2396
|
+
function widgetHeaderCounts(jobs) {
|
|
2397
|
+
return {
|
|
2398
|
+
running: jobs.filter((job) => job.status === "running"),
|
|
2399
|
+
queued: jobs.filter((job) => job.status === "queued"),
|
|
2400
|
+
complete: jobs.filter((job) => job.status === "complete"),
|
|
2401
|
+
failed: jobs.filter((job) => job.status === "failed"),
|
|
2402
|
+
paused: jobs.filter((job) => job.status === "paused"),
|
|
2403
|
+
stopped: jobs.filter((job) => job.status === "stopped"),
|
|
2404
|
+
};
|
|
2405
|
+
}
|
|
2406
|
+
function buildSingleLineWidgetLines(jobs, theme, width, frame) {
|
|
2407
|
+
const counts = widgetHeaderCounts(jobs);
|
|
2408
|
+
const hasActive = counts.running.length > 0 || counts.queued.length > 0;
|
|
2409
|
+
const glyph = counts.running.length > 0 ? runningGlyph(animatedSeed(widgetJobsRunningSeed(counts.running), frame)) : hasActive ? "●" : "○";
|
|
2410
|
+
const parts = [];
|
|
2411
|
+
if (counts.running.length > 0)
|
|
2412
|
+
parts.push(`${counts.running.length}/${jobs.length} running`);
|
|
2413
|
+
if (counts.queued.length > 0)
|
|
2414
|
+
parts.push(`${counts.queued.length} queued`);
|
|
2415
|
+
if (counts.failed.length > 0)
|
|
2416
|
+
parts.push(`${counts.failed.length} failed`);
|
|
2417
|
+
if (counts.stopped.length > 0)
|
|
2418
|
+
parts.push(`${counts.stopped.length} stopped`);
|
|
2419
|
+
if (counts.paused.length > 0)
|
|
2420
|
+
parts.push(`${counts.paused.length} paused`);
|
|
2421
|
+
for (const status of ["partial", "rejected"]) {
|
|
2422
|
+
const count = jobs.filter((job) => job.status === status).length;
|
|
2423
|
+
if (count > 0)
|
|
2424
|
+
parts.push(`${count} ${status}`);
|
|
2425
|
+
}
|
|
2426
|
+
if (!hasActive && counts.complete.length > 0)
|
|
2427
|
+
parts.push(`${counts.complete.length}/${jobs.length} done`);
|
|
2428
|
+
return [truncLine(`${theme.fg(hasActive ? "accent" : "dim", glyph)} ${theme.fg(hasActive ? "accent" : "dim", "subagents")} (${parts.join(", ") || `${jobs.length} total`})`, width)];
|
|
2429
|
+
}
|
|
2430
|
+
function orderedWidgetJobs(jobs) {
|
|
2431
|
+
return [
|
|
2432
|
+
...jobs.filter((job) => job.status === "running"),
|
|
2433
|
+
...jobs.filter((job) => job.status === "queued"),
|
|
2434
|
+
...jobs.filter((job) => job.status !== "running" && job.status !== "queued"),
|
|
2435
|
+
];
|
|
2436
|
+
}
|
|
2437
|
+
function progressiveJobKey(job) {
|
|
2438
|
+
return job.asyncId;
|
|
2439
|
+
}
|
|
2440
|
+
function isProgressiveActiveJob(job) {
|
|
2441
|
+
return job?.status === "running" || job?.status === "queued";
|
|
2442
|
+
}
|
|
2443
|
+
function selectProgressiveJobKeys(jobs, previousKeys, bodyRows) {
|
|
2444
|
+
if (bodyRows <= 0)
|
|
2445
|
+
return [];
|
|
2446
|
+
const jobsByKey = new Map(jobs.map((job) => [progressiveJobKey(job), job]));
|
|
2447
|
+
const selected = [];
|
|
2448
|
+
const append = (key) => {
|
|
2449
|
+
if (selected.includes(key) || !jobsByKey.has(key))
|
|
2450
|
+
return;
|
|
2451
|
+
selected.push(key);
|
|
2452
|
+
};
|
|
2453
|
+
for (const key of previousKeys) {
|
|
2454
|
+
if (!isProgressiveActiveJob(jobsByKey.get(key)))
|
|
2455
|
+
continue;
|
|
2456
|
+
append(key);
|
|
2457
|
+
if (selected.length >= bodyRows)
|
|
2458
|
+
return selected;
|
|
2459
|
+
}
|
|
2460
|
+
for (const job of orderedWidgetJobs(jobs)) {
|
|
2461
|
+
if (!isProgressiveActiveJob(job))
|
|
2462
|
+
continue;
|
|
2463
|
+
const key = progressiveJobKey(job);
|
|
2464
|
+
append(key);
|
|
2465
|
+
if (selected.length >= bodyRows)
|
|
2466
|
+
break;
|
|
2467
|
+
}
|
|
2468
|
+
if (selected.length >= bodyRows)
|
|
2469
|
+
return selected;
|
|
2470
|
+
for (const key of previousKeys) {
|
|
2471
|
+
if (isProgressiveActiveJob(jobsByKey.get(key)))
|
|
2472
|
+
continue;
|
|
2473
|
+
append(key);
|
|
2474
|
+
if (selected.length >= bodyRows)
|
|
2475
|
+
return selected;
|
|
2476
|
+
}
|
|
2477
|
+
for (const job of orderedWidgetJobs(jobs)) {
|
|
2478
|
+
const key = progressiveJobKey(job);
|
|
2479
|
+
append(key);
|
|
2480
|
+
if (selected.length >= bodyRows)
|
|
2481
|
+
break;
|
|
2482
|
+
}
|
|
2483
|
+
return selected;
|
|
2484
|
+
}
|
|
2485
|
+
function progressiveHeaderLine(jobs, theme, width, frame) {
|
|
2486
|
+
const counts = widgetHeaderCounts(jobs);
|
|
2487
|
+
const hasActive = counts.running.length > 0 || counts.queued.length > 0;
|
|
2488
|
+
const glyph = counts.running.length > 0 ? runningGlyph(animatedSeed(widgetJobsRunningSeed(counts.running), frame)) : hasActive ? "●" : "○";
|
|
2489
|
+
const parts = [];
|
|
2490
|
+
if (counts.running.length > 0)
|
|
2491
|
+
parts.push(formatAgentRunningLabel(counts.running.length));
|
|
2492
|
+
if (counts.queued.length > 0)
|
|
2493
|
+
parts.push(`${counts.queued.length} queued`);
|
|
2494
|
+
if (!hasActive) {
|
|
2495
|
+
if (counts.failed.length > 0)
|
|
2496
|
+
parts.push(`${counts.failed.length} failed`);
|
|
2497
|
+
if (counts.stopped.length > 0)
|
|
2498
|
+
parts.push(`${counts.stopped.length} stopped`);
|
|
2499
|
+
if (counts.paused.length > 0)
|
|
2500
|
+
parts.push(`${counts.paused.length} paused`);
|
|
2501
|
+
if (counts.complete.length > 0)
|
|
2502
|
+
parts.push(`${counts.complete.length}/${jobs.length} done`);
|
|
2503
|
+
}
|
|
2504
|
+
return truncLine(`${theme.fg(hasActive ? "accent" : "dim", glyph)} ${theme.fg(hasActive ? "accent" : "dim", "Async agents")} ${theme.fg("dim", "·")} ${theme.fg("dim", parts.join(", ") || `${jobs.length} total`)}`, width);
|
|
2505
|
+
}
|
|
2506
|
+
function progressiveJobLine(job, theme, width, frame, projection = buildWorkflowWidgetProjection(job)) {
|
|
2507
|
+
const compactWorkflow = job.mode === "workflow";
|
|
2508
|
+
const compactRows = compactWorkflow ? compactWorkflowLaneRows(job, projection.checklist) : undefined;
|
|
2509
|
+
const stats = compactWorkflow ? compactWorkflowStats(job, compactRows ?? [], theme, projection) : widgetStats(job, theme, projection, true);
|
|
2510
|
+
if (compactWorkflow) {
|
|
2511
|
+
const bottleneck = compactWorkflowBottleneck(compactRows ?? [], job);
|
|
2512
|
+
const suffix = [stats, bottleneck ? theme.fg(bottleneck.tone, `bottleneck · ${bottleneck.text}`) : undefined].filter((value) => Boolean(value)).join(` ${theme.fg("dim", "·")} `);
|
|
2513
|
+
return truncLine(` ${widgetStatusGlyph(job, theme, frame)} ${compactWorkflowHeaderLine(job, theme, Math.max(0, width - 4))}${suffix ? ` ${theme.fg("dim", "·")} ${suffix}` : ""}`, width);
|
|
2514
|
+
}
|
|
2515
|
+
const activity = widgetActivity(job);
|
|
2516
|
+
const status = job.status === "complete" ? "done" : job.status;
|
|
2517
|
+
const lane = projectAsyncLane(job, laneStepForJob(job, projection.steps));
|
|
2518
|
+
const laneSummary = lane
|
|
2519
|
+
? [lane.label ?? lane.role, lane.phase ? `phase:${lane.phase}` : undefined, lane.output ? `out:${lane.output}` : undefined, lane.workspace ? `workspace:${lane.workspace}` : `ref:${lane.ref}`].filter(Boolean).join(" · ")
|
|
2520
|
+
: "";
|
|
2521
|
+
const laneSignals = lane
|
|
2522
|
+
? [lane.next ? `next:${lane.next}` : undefined, ...lane.chips.map((chip) => formatLaneChip(chip, theme))].filter(Boolean).join(" · ")
|
|
2523
|
+
: "";
|
|
2524
|
+
const parts = [
|
|
2525
|
+
`${themeBold(theme, widgetJobName(job))}${contextModeBadge(theme, job.context)}`,
|
|
2526
|
+
theme.fg("dim", status),
|
|
2527
|
+
laneSignals ? laneSignals : "",
|
|
2528
|
+
laneSummary ? theme.fg("dim", laneSummary) : "",
|
|
2529
|
+
stats,
|
|
2530
|
+
activity && activity.toLowerCase() !== status ? theme.fg("dim", activity) : "",
|
|
2531
|
+
].filter(Boolean);
|
|
2532
|
+
return truncLine(` ${widgetStatusGlyph(job, theme, frame)} ${parts.join(` ${theme.fg("dim", "·")} `)}`, width);
|
|
2533
|
+
}
|
|
2534
|
+
function progressiveHiddenLine(hiddenJobs, theme, width) {
|
|
2535
|
+
const counts = widgetHeaderCounts(hiddenJobs);
|
|
2536
|
+
const parts = [];
|
|
2537
|
+
if (counts.running.length > 0)
|
|
2538
|
+
parts.push(`${counts.running.length} running`);
|
|
2539
|
+
if (counts.queued.length > 0)
|
|
2540
|
+
parts.push(`${counts.queued.length} queued`);
|
|
2541
|
+
const finished = counts.complete.length + counts.failed.length + counts.paused.length + counts.stopped.length;
|
|
2542
|
+
if (finished > 0)
|
|
2543
|
+
parts.push(`${finished} finished`);
|
|
2544
|
+
return truncLine(theme.fg("dim", ` +${hiddenJobs.length} more${parts.length ? ` (${parts.join(", ")})` : ""}`), width);
|
|
2545
|
+
}
|
|
2546
|
+
function buildProgressiveWidgetLines(jobs, theme, width, lockedRows, previousKeys, frame, projectionFor = workflowWidgetProjectionLookup()) {
|
|
2547
|
+
const rowCount = Math.max(1, lockedRows);
|
|
2548
|
+
if (rowCount === 1)
|
|
2549
|
+
return { lines: buildSingleLineWidgetLines(jobs, theme, width, frame), visibleJobKeys: [] };
|
|
2550
|
+
const bodyRows = rowCount - 1;
|
|
2551
|
+
let visibleJobKeys = selectProgressiveJobKeys(jobs, previousKeys, bodyRows);
|
|
2552
|
+
const jobsByKey = new Map(jobs.map((job) => [progressiveJobKey(job), job]));
|
|
2553
|
+
let visibleJobs = visibleJobKeys.map((key) => jobsByKey.get(key)).filter((job) => Boolean(job));
|
|
2554
|
+
let hiddenJobs = jobs.filter((job) => !visibleJobKeys.includes(progressiveJobKey(job)));
|
|
2555
|
+
const needsHiddenLine = hiddenJobs.length > 0;
|
|
2556
|
+
if (needsHiddenLine && visibleJobs.length >= bodyRows && bodyRows > 0) {
|
|
2557
|
+
visibleJobs = visibleJobs.slice(0, bodyRows - 1);
|
|
2558
|
+
visibleJobKeys = visibleJobs.map(progressiveJobKey);
|
|
2559
|
+
hiddenJobs = jobs.filter((job) => !visibleJobKeys.includes(progressiveJobKey(job)));
|
|
2560
|
+
}
|
|
2561
|
+
const lines = [
|
|
2562
|
+
progressiveHeaderLine(jobs, theme, width, frame),
|
|
2563
|
+
...visibleJobs.map((job) => progressiveJobLine(job, theme, width, frame, projectionFor(job))),
|
|
2564
|
+
];
|
|
2565
|
+
if (hiddenJobs.length > 0 && lines.length < rowCount)
|
|
2566
|
+
lines.push(progressiveHiddenLine(hiddenJobs, theme, width));
|
|
2567
|
+
while (lines.length < rowCount)
|
|
2568
|
+
lines.push(" ");
|
|
2569
|
+
return { lines: lines.slice(0, rowCount), visibleJobKeys };
|
|
2570
|
+
}
|
|
2571
|
+
function collapsedWidgetLineBudget(rows) {
|
|
2572
|
+
return Math.max(10, Math.min(14, Math.floor(rows * 0.35)));
|
|
2573
|
+
}
|
|
2574
|
+
function paddedWidgetLine(line, width) {
|
|
2575
|
+
if (width <= 2)
|
|
2576
|
+
return " ".repeat(Math.max(0, width));
|
|
2577
|
+
const text = ` ${truncLine(line, width - 2)} `;
|
|
2578
|
+
return `${text}${" ".repeat(Math.max(0, width - visibleWidth(text)))}`;
|
|
2579
|
+
}
|
|
2580
|
+
function fitWidgetLineBudget(lines, theme, width, expanded) {
|
|
2581
|
+
const rows = process.stdout.rows || 30;
|
|
2582
|
+
const budget = expanded
|
|
2583
|
+
? Math.max(12, Math.min(24, Math.floor(rows * 0.55)))
|
|
2584
|
+
: collapsedWidgetLineBudget(rows);
|
|
2585
|
+
if (lines.length <= budget)
|
|
2586
|
+
return lines;
|
|
2587
|
+
const visibleLines = Math.max(1, budget - 1);
|
|
2588
|
+
const hiddenCount = lines.length - visibleLines;
|
|
2589
|
+
const hint = expanded
|
|
2590
|
+
? `… ${hiddenCount} live-detail lines hidden`
|
|
2591
|
+
: `… ${hiddenCount} lines hidden · ${liveDetailKeyText()} expands`;
|
|
2592
|
+
return [...lines.slice(0, visibleLines), truncLine(theme.fg("dim", hint), width)];
|
|
2593
|
+
}
|
|
2594
|
+
function fitAdaptiveWidgetLines(jobs, buildLines, theme, width, expanded, frame, projectionFor) {
|
|
2595
|
+
if (expanded) {
|
|
2596
|
+
resetWidgetLayoutSession();
|
|
2597
|
+
return fitWidgetLineBudget(buildLines(), theme, width, true);
|
|
2598
|
+
}
|
|
2599
|
+
const hasMatchingSession = widgetSessionMatches(expanded);
|
|
2600
|
+
const rows = currentTerminalRows();
|
|
2601
|
+
const columns = currentTerminalColumns();
|
|
2602
|
+
const availableRows = estimateAvailableWidgetRows();
|
|
2603
|
+
if (hasMatchingSession && widgetLayoutSession?.tier === "single-line") {
|
|
2604
|
+
return buildSingleLineWidgetLines(jobs, theme, width, frame);
|
|
2605
|
+
}
|
|
2606
|
+
if (hasMatchingSession && widgetLayoutSession?.tier === "progressive" && widgetLayoutSession.lockedRows !== undefined) {
|
|
2607
|
+
const rendered = buildProgressiveWidgetLines(jobs, theme, width, widgetLayoutSession.lockedRows, widgetLayoutSession.visibleJobKeys, frame, projectionFor);
|
|
2608
|
+
widgetLayoutSession.visibleJobKeys = rendered.visibleJobKeys;
|
|
2609
|
+
return rendered.lines;
|
|
2610
|
+
}
|
|
2611
|
+
const lines = buildLines();
|
|
2612
|
+
if (lines.length <= availableRows) {
|
|
2613
|
+
widgetLayoutSession = { expanded, rows, columns, tier: "full", visibleJobKeys: [] };
|
|
2614
|
+
return fitWidgetLineBudget(lines, theme, width, false);
|
|
2615
|
+
}
|
|
2616
|
+
if (availableRows > 2 && jobs.length === 1 && projectionFor?.(jobs[0]).stageProgress) {
|
|
2617
|
+
widgetLayoutSession = { expanded, rows, columns, tier: "full", visibleJobKeys: [] };
|
|
2618
|
+
return fitWidgetLineBudget(lines, theme, width, false);
|
|
2619
|
+
}
|
|
2620
|
+
if (availableRows <= 2) {
|
|
2621
|
+
widgetLayoutSession = { expanded, rows, columns, tier: "single-line", visibleJobKeys: [] };
|
|
2622
|
+
return buildSingleLineWidgetLines(jobs, theme, width, frame);
|
|
2623
|
+
}
|
|
2624
|
+
const lockedRows = Math.min(availableRows, collapsedWidgetLineBudget(rows));
|
|
2625
|
+
const rendered = buildProgressiveWidgetLines(jobs, theme, width, lockedRows, [], frame, projectionFor);
|
|
2626
|
+
widgetLayoutSession = { expanded, rows, columns, tier: "progressive", lockedRows, visibleJobKeys: rendered.visibleJobKeys };
|
|
2627
|
+
return rendered.lines;
|
|
2628
|
+
}
|
|
2629
|
+
const asyncWidgetUpdates = new WeakMap();
|
|
2630
|
+
const inlineWorkflowCoverage = new WeakMap();
|
|
2631
|
+
const asyncWidgetInvalidations = new WeakMap();
|
|
2632
|
+
function inlineWorkflowDescendantShape(children) {
|
|
2633
|
+
return children?.map((child) => [child.id, child.agent, inlineWorkflowDescendantShape(child.children)]);
|
|
2634
|
+
}
|
|
2635
|
+
function inlineWorkflowRowShape(job) {
|
|
2636
|
+
return [
|
|
2637
|
+
job.asyncId,
|
|
2638
|
+
job.parentWorkflowRunId,
|
|
2639
|
+
job.workflowKey,
|
|
2640
|
+
job.mode,
|
|
2641
|
+
job.currentStep,
|
|
2642
|
+
job.activeParallelGroup,
|
|
2643
|
+
job.status,
|
|
2644
|
+
job.context,
|
|
2645
|
+
job.agents,
|
|
2646
|
+
job.steps?.map((step, index) => [
|
|
2647
|
+
step.index ?? index,
|
|
2648
|
+
step.workflowKey,
|
|
2649
|
+
step.agent,
|
|
2650
|
+
step.status,
|
|
2651
|
+
Boolean(step.runner),
|
|
2652
|
+
inlineWorkflowDescendantShape(step.children),
|
|
2653
|
+
]),
|
|
2654
|
+
inlineWorkflowDescendantShape(job.nestedChildren),
|
|
2655
|
+
job.hostSteps?.map((row) => [row.id, row.monitorKind, row.label]),
|
|
2656
|
+
Boolean(job.workflowGraph),
|
|
2657
|
+
];
|
|
2658
|
+
}
|
|
2659
|
+
/** Structural identity of the workflow rows that Fleet can cover. */
|
|
2660
|
+
export function inlineWorkflowRenderKey(job, children) {
|
|
2661
|
+
return JSON.stringify([inlineWorkflowRowShape(job), children.map(inlineWorkflowRowShape)]);
|
|
2662
|
+
}
|
|
2663
|
+
/** Presentation-only coverage from the mounted inline Fleet roster, never configuration. */
|
|
2664
|
+
export function setInlineWorkflowCoverage(ui, coverage) {
|
|
2665
|
+
const previous = inlineWorkflowCoverage.get(ui);
|
|
2666
|
+
if ((previous?.size ?? 0) === coverage.size && [...coverage].every(([id, key]) => previous?.get(id) === key))
|
|
2667
|
+
return;
|
|
2668
|
+
if (coverage.size)
|
|
2669
|
+
inlineWorkflowCoverage.set(ui, coverage);
|
|
2670
|
+
else
|
|
2671
|
+
inlineWorkflowCoverage.delete(ui);
|
|
2672
|
+
asyncWidgetInvalidations.get(ui)?.();
|
|
2673
|
+
}
|
|
2674
|
+
/** Attach only to loaded workflow parents; orphan jobs remain top-level. */
|
|
2675
|
+
function widgetJobTree(jobs, now) {
|
|
2676
|
+
const parents = new Map(jobs.filter((job) => job.mode === "workflow").map((job) => [job.asyncId, job]));
|
|
2677
|
+
const childrenByParent = new Map();
|
|
2678
|
+
const roots = [];
|
|
2679
|
+
for (const job of jobs) {
|
|
2680
|
+
const parent = job.parentWorkflowRunId ? parents.get(job.parentWorkflowRunId) : undefined;
|
|
2681
|
+
// Root-only adaptive summaries cannot advertise live work under a non-running parent.
|
|
2682
|
+
const keepLiveRoot = isProgressiveActiveJob(job) && parent?.status !== "running";
|
|
2683
|
+
if (parent && parent.asyncId !== job.asyncId && !keepLiveRoot) {
|
|
2684
|
+
const children = childrenByParent.get(parent.asyncId) ?? [];
|
|
2685
|
+
children.push(job);
|
|
2686
|
+
childrenByParent.set(parent.asyncId, children);
|
|
2687
|
+
}
|
|
2688
|
+
else
|
|
2689
|
+
roots.push(job);
|
|
2690
|
+
}
|
|
2691
|
+
return { roots, projectionFor: workflowWidgetProjectionLookup(now, childrenByParent) };
|
|
2692
|
+
}
|
|
2693
|
+
function widgetChecklistWithoutMaterializedChildren(projection) {
|
|
2694
|
+
const { checklist, materializedKeys } = projection;
|
|
2695
|
+
if (!checklist || !materializedKeys)
|
|
2696
|
+
return checklist;
|
|
2697
|
+
return { ...checklist, phases: checklist.phases.map((phase) => ({ ...phase, items: phase.items.filter((item) => !materializedKeys.has(item.key)) })) };
|
|
2698
|
+
}
|
|
2699
|
+
function materializedWidgetChildLines(job, theme, width, expanded, frame, projectionFor) {
|
|
2700
|
+
const { children, inlineFleetCovered } = projectionFor(job);
|
|
2701
|
+
if (inlineFleetCovered || !children?.length)
|
|
2702
|
+
return [];
|
|
2703
|
+
const lines = [];
|
|
2704
|
+
const shown = orderedWidgetJobs(children).slice(0, MAX_WIDGET_JOBS);
|
|
2705
|
+
for (const [index, child] of shown.entries()) {
|
|
2706
|
+
const projection = projectionFor(child);
|
|
2707
|
+
const last = index === children.length - 1;
|
|
2708
|
+
const identity = child.workflowKey ?? child.asyncId;
|
|
2709
|
+
const stats = widgetStats(child, theme, projection, !expanded);
|
|
2710
|
+
lines.push(` ${last ? "└─" : "├─"} ${theme.bold(identity)} ${widgetStatusGlyph(child, theme, frame)} ${themeBold(theme, widgetJobName(child))}${contextModeBadge(theme, child.context)}${stats ? ` ${theme.fg("dim", "·")} ${stats}` : ""}`);
|
|
2711
|
+
for (const detail of foregroundStyleWidgetDetails(child, theme, expanded, Math.max(0, width - 6), frame, projection))
|
|
2712
|
+
lines.push(` ${last ? " " : "│ "}${detail}`);
|
|
2713
|
+
for (const detail of materializedWidgetChildLines(child, theme, Math.max(0, width - 4), expanded, frame, projectionFor))
|
|
2714
|
+
lines.push(` ${detail}`);
|
|
2715
|
+
}
|
|
2716
|
+
if (shown.length < children.length)
|
|
2717
|
+
lines.push(` +${children.length - shown.length} more workflow children`);
|
|
2718
|
+
return lines;
|
|
2719
|
+
}
|
|
2720
|
+
function buildWidgetComponent(jobs, ui) {
|
|
2721
|
+
return (tui, theme) => {
|
|
2722
|
+
const container = new Container();
|
|
2723
|
+
let cachedRenderWidth;
|
|
2724
|
+
let cachedFrame;
|
|
2725
|
+
let cachedExpanded;
|
|
2726
|
+
let cachedLines;
|
|
2727
|
+
let cachedCoverage = "[]";
|
|
2728
|
+
let collapsed = false;
|
|
2729
|
+
const invalidate = () => {
|
|
2730
|
+
cachedLines = undefined;
|
|
2731
|
+
resetWidgetLayoutSession();
|
|
2732
|
+
tui.requestRender();
|
|
2733
|
+
};
|
|
2734
|
+
const invalidateCoverage = () => {
|
|
2735
|
+
cachedLines = undefined;
|
|
2736
|
+
tui.requestRender();
|
|
2737
|
+
};
|
|
2738
|
+
asyncWidgetInvalidations.set(ui, invalidateCoverage);
|
|
2739
|
+
const update = (nextJobs) => {
|
|
2740
|
+
jobs = nextJobs;
|
|
2741
|
+
cachedLines = undefined;
|
|
2742
|
+
tui.requestRender();
|
|
2743
|
+
};
|
|
2744
|
+
asyncWidgetUpdates.set(ui, update);
|
|
2745
|
+
const component = Object.assign(container, {
|
|
2746
|
+
// Only the mouse fields used here, without requiring newer Pi type exports.
|
|
2747
|
+
handleMouse(event) {
|
|
2748
|
+
if (event.type !== "click" || event.button !== "left" || event.y !== 0)
|
|
2749
|
+
return undefined;
|
|
2750
|
+
if (event.shift || event.alt || event.ctrl)
|
|
2751
|
+
return undefined;
|
|
2752
|
+
collapsed = !collapsed;
|
|
2753
|
+
invalidate();
|
|
2754
|
+
return { handled: true };
|
|
2755
|
+
},
|
|
2756
|
+
dispose() {
|
|
2757
|
+
if (asyncWidgetUpdates.get(ui) === update)
|
|
2758
|
+
asyncWidgetUpdates.delete(ui);
|
|
2759
|
+
if (asyncWidgetInvalidations.get(ui) === invalidateCoverage)
|
|
2760
|
+
asyncWidgetInvalidations.delete(ui);
|
|
2761
|
+
},
|
|
2762
|
+
});
|
|
2763
|
+
container.render = (renderWidth) => {
|
|
2764
|
+
const now = Date.now();
|
|
2765
|
+
const frame = Math.floor(now / WIDGET_ANIMATION_INTERVAL_MS);
|
|
2766
|
+
const expanded = ui.getToolsExpanded?.() ?? false;
|
|
2767
|
+
const coverage = inlineWorkflowCoverage.get(ui);
|
|
2768
|
+
const covered = new Set();
|
|
2769
|
+
if (coverage?.size) {
|
|
2770
|
+
const childrenByParent = new Map();
|
|
2771
|
+
for (const child of jobs) {
|
|
2772
|
+
if (!child.parentWorkflowRunId)
|
|
2773
|
+
continue;
|
|
2774
|
+
const children = childrenByParent.get(child.parentWorkflowRunId) ?? [];
|
|
2775
|
+
children.push(child);
|
|
2776
|
+
childrenByParent.set(child.parentWorkflowRunId, children);
|
|
2777
|
+
}
|
|
2778
|
+
for (const job of jobs) {
|
|
2779
|
+
const snapshot = coverage.get(job.asyncId);
|
|
2780
|
+
if (snapshot === undefined)
|
|
2781
|
+
continue;
|
|
2782
|
+
const children = childrenByParent.get(job.asyncId) ?? [];
|
|
2783
|
+
if (!children.some((child) => childrenByParent.has(child.asyncId))
|
|
2784
|
+
&& snapshot === inlineWorkflowRenderKey(job, children))
|
|
2785
|
+
covered.add(job.asyncId);
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
const coverageKey = JSON.stringify([...covered]);
|
|
2789
|
+
if (cachedLines && cachedRenderWidth === renderWidth && cachedFrame === frame && cachedExpanded === expanded && cachedCoverage === coverageKey)
|
|
2790
|
+
return cachedLines;
|
|
2791
|
+
if (cachedCoverage !== coverageKey)
|
|
2792
|
+
resetWidgetLayoutSession();
|
|
2793
|
+
cachedCoverage = coverageKey;
|
|
2794
|
+
const width = Math.max(0, renderWidth - 2);
|
|
2795
|
+
const { roots, projectionFor } = widgetJobTree(jobs, now);
|
|
2796
|
+
for (const job of roots)
|
|
2797
|
+
projectionFor(job).inlineFleetCovered = covered.has(job.asyncId);
|
|
2798
|
+
const buildLines = () => expanded
|
|
2799
|
+
? buildWidgetLinesWithProjection(roots, theme, width, true, frame, projectionFor)
|
|
2800
|
+
: roots.length === 1 && !projectionFor(roots[0]).children?.length
|
|
2801
|
+
? compactSingleWidgetLines(roots[0], theme, width, frame, projectionFor(roots[0]))
|
|
2802
|
+
: buildWidgetLinesWithProjection(roots, theme, width, false, frame, projectionFor);
|
|
2803
|
+
cachedRenderWidth = renderWidth;
|
|
2804
|
+
cachedFrame = frame;
|
|
2805
|
+
cachedExpanded = expanded;
|
|
2806
|
+
cachedLines = (collapsed
|
|
2807
|
+
? buildSingleLineWidgetLines(jobs, theme, width, frame)
|
|
2808
|
+
: fitAdaptiveWidgetLines(roots, buildLines, theme, width, expanded, frame, projectionFor)).map((line) => paddedWidgetLine(line, renderWidth));
|
|
2809
|
+
return cachedLines;
|
|
2810
|
+
};
|
|
2811
|
+
return component;
|
|
2812
|
+
};
|
|
2813
|
+
}
|
|
2814
|
+
function buildWidgetLinesWithProjection(jobs, theme, width = getTermWidth(), expanded = false, frame, projectionFor = workflowWidgetProjectionLookup()) {
|
|
2815
|
+
if (jobs.length === 0)
|
|
2816
|
+
return [];
|
|
2817
|
+
if (jobs.length === 1)
|
|
2818
|
+
return [
|
|
2819
|
+
...buildSingleWidgetLines(jobs[0], theme, width, expanded, frame, projectionFor(jobs[0])),
|
|
2820
|
+
...materializedWidgetChildLines(jobs[0], theme, width, expanded, frame, projectionFor).map((line) => truncLine(line, width)),
|
|
2821
|
+
];
|
|
2822
|
+
const running = jobs.filter((job) => job.status === "running");
|
|
2823
|
+
const queued = jobs.filter((job) => job.status === "queued");
|
|
2824
|
+
const finished = jobs.filter((job) => job.status !== "running" && job.status !== "queued");
|
|
2825
|
+
const lines = [];
|
|
2826
|
+
const hasActive = running.length > 0 || queued.length > 0;
|
|
2827
|
+
const headerGlyph = running.length > 0 ? runningGlyph(animatedSeed(widgetJobsRunningSeed(running), frame)) : hasActive ? "●" : "○";
|
|
2828
|
+
lines.push(truncLine(`${theme.fg(hasActive ? "accent" : "dim", headerGlyph)} ${theme.fg(hasActive ? "accent" : "dim", "Async agents")} ${theme.fg("dim", "· background")}`, width));
|
|
2829
|
+
const items = [];
|
|
2830
|
+
let hiddenRunning = 0;
|
|
2831
|
+
let hiddenFinished = 0;
|
|
2832
|
+
let queuedSummaryShown = false;
|
|
2833
|
+
let slots = MAX_WIDGET_JOBS;
|
|
2834
|
+
const appendJob = (job) => {
|
|
2835
|
+
const projection = projectionFor(job);
|
|
2836
|
+
const compactWorkflow = (!expanded || projection.inlineFleetCovered) && job.mode === "workflow";
|
|
2837
|
+
const stats = compactWorkflow ? "" : widgetStats(job, theme, projection, !expanded);
|
|
2838
|
+
const details = compactWorkflow
|
|
2839
|
+
? [
|
|
2840
|
+
...compactWorkflowWidgetBodyLines(job, theme, frame, projection),
|
|
2841
|
+
]
|
|
2842
|
+
: [
|
|
2843
|
+
` ${theme.fg("dim", `⎿ ${widgetActivity(job)}`)}`,
|
|
2844
|
+
...widgetLaneDetailLines(job, theme, projection),
|
|
2845
|
+
...workflowChecklistWidgetLines(widgetChecklistWithoutMaterializedChildren(projection), theme, " ", expanded, frame, { includeItemErrors: !expanded || !job.steps?.length }),
|
|
2846
|
+
...widgetParallelAgentDetails(job, theme, expanded, width, frame),
|
|
2847
|
+
];
|
|
2848
|
+
items.push([
|
|
2849
|
+
compactWorkflow
|
|
2850
|
+
? compactWorkflowHeaderLine(job, theme, width)
|
|
2851
|
+
: `${widgetStatusGlyph(job, theme, frame)} ${themeBold(theme, widgetJobName(job))}${contextModeBadge(theme, job.context)}${stats ? ` ${theme.fg("dim", "·")} ${stats}` : ""}`,
|
|
2852
|
+
...details,
|
|
2853
|
+
...materializedWidgetChildLines(job, theme, width, expanded, frame, projectionFor),
|
|
2854
|
+
]);
|
|
2855
|
+
};
|
|
2856
|
+
for (const job of running) {
|
|
2857
|
+
if (slots <= 0) {
|
|
2858
|
+
hiddenRunning++;
|
|
2859
|
+
continue;
|
|
2860
|
+
}
|
|
2861
|
+
appendJob(job);
|
|
2862
|
+
slots--;
|
|
2863
|
+
}
|
|
2864
|
+
if (queued.length > 0 && slots > 0) {
|
|
2865
|
+
items.push([`${theme.fg("muted", "◦")} ${theme.fg("dim", `${queued.length} queued`)}`]);
|
|
2866
|
+
queuedSummaryShown = true;
|
|
2867
|
+
slots--;
|
|
2868
|
+
}
|
|
2869
|
+
for (const job of finished) {
|
|
2870
|
+
if (slots <= 0) {
|
|
2871
|
+
hiddenFinished++;
|
|
2872
|
+
continue;
|
|
2873
|
+
}
|
|
2874
|
+
appendJob(job);
|
|
2875
|
+
slots--;
|
|
2876
|
+
}
|
|
2877
|
+
const hiddenQueued = queued.length > 0 && !queuedSummaryShown ? queued.length : 0;
|
|
2878
|
+
const hiddenTotal = hiddenRunning + hiddenFinished + hiddenQueued;
|
|
2879
|
+
if (hiddenTotal > 0) {
|
|
2880
|
+
const parts = [];
|
|
2881
|
+
if (hiddenRunning > 0)
|
|
2882
|
+
parts.push(`${hiddenRunning} running`);
|
|
2883
|
+
if (hiddenQueued > 0)
|
|
2884
|
+
parts.push(`${hiddenQueued} queued`);
|
|
2885
|
+
if (hiddenFinished > 0)
|
|
2886
|
+
parts.push(`${hiddenFinished} finished`);
|
|
2887
|
+
items.push([theme.fg("dim", `+${hiddenTotal} more (${parts.join(", ")})`)]);
|
|
2888
|
+
}
|
|
2889
|
+
for (let i = 0; i < items.length; i++) {
|
|
2890
|
+
const item = items[i];
|
|
2891
|
+
const last = i === items.length - 1;
|
|
2892
|
+
const branch = last ? "└─" : "├─";
|
|
2893
|
+
const continuation = last ? " " : "│ ";
|
|
2894
|
+
lines.push(truncLine(`${theme.fg("dim", branch)} ${item[0]}`, width));
|
|
2895
|
+
for (const detail of item.slice(1)) {
|
|
2896
|
+
lines.push(truncLine(`${theme.fg("dim", continuation)} ${detail}`, width));
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
return lines;
|
|
2900
|
+
}
|
|
2901
|
+
export function buildWidgetLines(jobs, theme, width = getTermWidth(), expanded = false, frame) {
|
|
2902
|
+
const { roots, projectionFor } = widgetJobTree(jobs, Date.now());
|
|
2903
|
+
return buildWidgetLinesWithProjection(roots, theme, width, expanded, frame, projectionFor);
|
|
2904
|
+
}
|
|
2905
|
+
/**
|
|
2906
|
+
* Render the async jobs widget
|
|
2907
|
+
*/
|
|
2908
|
+
export function renderWidget(ctx, jobs) {
|
|
2909
|
+
if (jobs.length === 0) {
|
|
2910
|
+
resetWidgetLayoutSession();
|
|
2911
|
+
asyncWidgetUpdates.delete(ctx.ui);
|
|
2912
|
+
if (ctx.hasUI)
|
|
2913
|
+
ctx.ui.setWidget(WIDGET_KEY, undefined);
|
|
2914
|
+
return;
|
|
2915
|
+
}
|
|
2916
|
+
if (!ctx.hasUI)
|
|
2917
|
+
return;
|
|
2918
|
+
if (ctx.mode === "rpc") {
|
|
2919
|
+
ctx.ui.setWidget(WIDGET_KEY, encodeAsyncStatusSnapshotWidget(jobs));
|
|
2920
|
+
return;
|
|
2921
|
+
}
|
|
2922
|
+
// Pi replaces a widget by deleting and reinserting its key. Update the mounted
|
|
2923
|
+
// component instead so progress cannot move it past other extensions' widgets.
|
|
2924
|
+
const update = asyncWidgetUpdates.get(ctx.ui);
|
|
2925
|
+
if (update)
|
|
2926
|
+
update(jobs);
|
|
2927
|
+
else
|
|
2928
|
+
ctx.ui.setWidget(WIDGET_KEY, buildWidgetComponent(jobs, ctx.ui));
|
|
2929
|
+
}
|
|
2930
|
+
function renderSingleCompact(d, r, theme, layout, frame, foregroundDetachShortcut) {
|
|
2931
|
+
const output = r.truncation?.text || getSingleResultOutput(r);
|
|
2932
|
+
const progress = r.progress || r.progressSummary;
|
|
2933
|
+
const isRunning = isResultRunning(r);
|
|
2934
|
+
const contextBadge = contextModeBadge(theme, r.context ?? d.context);
|
|
2935
|
+
const stats = statJoin(theme, [
|
|
2936
|
+
r.usage?.turns ? `⟳ ${r.usage.turns}` : "",
|
|
2937
|
+
formatProgressStats(theme, progress),
|
|
2938
|
+
]);
|
|
2939
|
+
const c = new Container();
|
|
2940
|
+
const width = getTermWidth() - 4;
|
|
2941
|
+
const detailIndent = mainWindowIndent(layout, 1);
|
|
2942
|
+
const continuationIndent = mainWindowIndent(layout, 2) + (layout.horizontalSpacing > 0 ? " " : "");
|
|
2943
|
+
const modelDisplay = modelThinkingBadge(theme, r.model ?? r.progress?.model, r.thinking ?? r.progress?.thinking);
|
|
2944
|
+
c.addChild(new Text(truncLine(`${resultGlyph(r, output, theme, isRunning, undefined, frame)} ${theme.fg("toolTitle", theme.bold(foregroundSingleDisplayName(r)))}${modelDisplay}${contextBadge}${stats ? ` ${theme.fg("dim", "·")} ${stats}` : ""}`, width), 0, 0));
|
|
2945
|
+
if (isRunning && r.progress) {
|
|
2946
|
+
const task = compactTaskText(r.task);
|
|
2947
|
+
if (task)
|
|
2948
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}task: ${task}`), width), 0, 0));
|
|
2949
|
+
const progressSnapshotNow = snapshotNowForProgress(r.progress);
|
|
2950
|
+
const activity = compactCurrentActivity(r.progress);
|
|
2951
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}⎿ ${activity}`), width), 0, 0));
|
|
2952
|
+
const liveStatus = buildLiveStatusLine(r.progress, progressSnapshotNow);
|
|
2953
|
+
if (liveStatus && liveStatus !== activity)
|
|
2954
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${continuationIndent}${liveStatus}`), width), 0, 0));
|
|
2955
|
+
for (const nestedLine of formatNestedWidgetLines(r.children, theme, width, false, progressSnapshotNow)) {
|
|
2956
|
+
c.addChild(new Text(truncLine(`${detailIndent}${nestedLine}`, width), 0, 0));
|
|
2957
|
+
}
|
|
2958
|
+
c.addChild(new Text(truncLine(theme.fg("accent", `${detailIndent}${foregroundSingleHintText(foregroundDetachShortcut)}`), width), 0, 0));
|
|
2959
|
+
if (r.artifactPaths)
|
|
2960
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}output: ${shortenPath(r.artifactPaths.outputPath)}`), width), 0, 0));
|
|
2961
|
+
return c;
|
|
2962
|
+
}
|
|
2963
|
+
for (const nestedLine of formatNestedWidgetLines(r.children, theme, width, false, r.progress?.lastActivityAt)) {
|
|
2964
|
+
c.addChild(new Text(truncLine(`${detailIndent}${nestedLine}`, width), 0, 0));
|
|
2965
|
+
}
|
|
2966
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}⎿ ${resultStatusLine(r, output)}`), width), 0, 0));
|
|
2967
|
+
const preview = firstOutputLine(output);
|
|
2968
|
+
if (preview && r.exitCode === 0 && !hasEmptyTextOutputWithoutOutputTarget(r.task, output)) {
|
|
2969
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${continuationIndent}${preview}`), width), 0, 0));
|
|
2970
|
+
}
|
|
2971
|
+
if (r.sessionFile)
|
|
2972
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}session: ${shortenPath(r.sessionFile)}`), width), 0, 0));
|
|
2973
|
+
if (r.artifactPaths)
|
|
2974
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}output: ${shortenPath(r.artifactPaths.outputPath)}`), width), 0, 0));
|
|
2975
|
+
if (r.truncation?.artifactPath)
|
|
2976
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}full output: ${shortenPath(r.truncation.artifactPath)}`), width), 0, 0));
|
|
2977
|
+
return c;
|
|
2978
|
+
}
|
|
2979
|
+
function workflowRowGlyph(row, theme, frame) {
|
|
2980
|
+
if (row.state === "planned")
|
|
2981
|
+
return theme.fg("muted", "◦");
|
|
2982
|
+
if (row.state === "running")
|
|
2983
|
+
return theme.fg("accent", runningGlyph(frame));
|
|
2984
|
+
if (row.state === "complete")
|
|
2985
|
+
return theme.fg("success", "✓");
|
|
2986
|
+
if (row.state === "detached" || row.state === "stopped")
|
|
2987
|
+
return theme.fg("warning", "■");
|
|
2988
|
+
return theme.fg("error", "✗");
|
|
2989
|
+
}
|
|
2990
|
+
function workflowRowStateLabel(row, theme) {
|
|
2991
|
+
const label = (row.state === "complete" ? "complete" : row.state).padEnd(8);
|
|
2992
|
+
if (row.state === "planned")
|
|
2993
|
+
return theme.fg("dim", label);
|
|
2994
|
+
if (row.state === "running")
|
|
2995
|
+
return theme.fg("accent", label);
|
|
2996
|
+
if (row.state === "complete")
|
|
2997
|
+
return theme.fg("success", label);
|
|
2998
|
+
if (row.state === "detached" || row.state === "stopped")
|
|
2999
|
+
return theme.fg("warning", label);
|
|
3000
|
+
return theme.fg("error", label);
|
|
3001
|
+
}
|
|
3002
|
+
function workflowOverallState(rows, hasTerminalValue, isError) {
|
|
3003
|
+
if (rows.some((row) => row.state === "failed"))
|
|
3004
|
+
return "failed";
|
|
3005
|
+
if (rows.some((row) => row.state === "detached"))
|
|
3006
|
+
return "paused";
|
|
3007
|
+
if (isError)
|
|
3008
|
+
return "failed";
|
|
3009
|
+
if ((rows.length > 0 && rows.every((row) => row.state === "complete")) || hasTerminalValue)
|
|
3010
|
+
return "complete";
|
|
3011
|
+
return "running";
|
|
3012
|
+
}
|
|
3013
|
+
function foregroundWorkflowChecklist(details) {
|
|
3014
|
+
if (details.mode !== "workflow")
|
|
3015
|
+
return undefined;
|
|
3016
|
+
const stageNodes = details.workflowGraph ? workflowGraphStageNodes(details.workflowGraph) : [];
|
|
3017
|
+
const steps = details.results.flatMap((result, resultIndex) => {
|
|
3018
|
+
const stableIndex = foregroundResultIndex(details, resultIndex);
|
|
3019
|
+
const workflowKey = result.workflowKey;
|
|
3020
|
+
if (details.workflowGraph && typeof workflowKey !== "string")
|
|
3021
|
+
return [];
|
|
3022
|
+
const node = typeof workflowKey === "string"
|
|
3023
|
+
? stageNodes.find((candidate) => candidate.id === workflowKey)
|
|
3024
|
+
: undefined;
|
|
3025
|
+
const progress = foregroundProgressForResult(details, resultIndex);
|
|
3026
|
+
const status = isResultRunning(result) || progress?.status === "running"
|
|
3027
|
+
? "running"
|
|
3028
|
+
: result.detached
|
|
3029
|
+
? "paused"
|
|
3030
|
+
: result.stopped
|
|
3031
|
+
? "stopped"
|
|
3032
|
+
: result.exitCode === 0
|
|
3033
|
+
? "complete"
|
|
3034
|
+
: "failed";
|
|
3035
|
+
return [{
|
|
3036
|
+
key: node?.id ?? (typeof workflowKey === "string" ? workflowKey : `result-${resultIndex + 1}`),
|
|
3037
|
+
label: node?.label ?? workflowLabelForResult(details, resultIndex) ?? result.task ?? result.agent,
|
|
3038
|
+
phase: node?.phase,
|
|
3039
|
+
agent: result.agent,
|
|
3040
|
+
status,
|
|
3041
|
+
context: result.context,
|
|
3042
|
+
activityState: progress?.activityState,
|
|
3043
|
+
startedAt: progress?.lastActivityAt !== undefined && progress.durationMs !== undefined ? progress.lastActivityAt - progress.durationMs : undefined,
|
|
3044
|
+
durationMs: progress?.durationMs,
|
|
3045
|
+
currentTool: progress?.currentTool,
|
|
3046
|
+
currentToolStartedAt: progress?.currentToolStartedAt,
|
|
3047
|
+
currentPath: progress?.currentPath,
|
|
3048
|
+
turnCount: progress?.turnCount,
|
|
3049
|
+
toolCount: progress?.toolCount ?? result.progressSummary?.toolCount,
|
|
3050
|
+
error: result.error,
|
|
3051
|
+
toolBudgetBlocked: result.toolBudgetBlocked,
|
|
3052
|
+
turnBudgetExceeded: result.turnBudgetExceeded,
|
|
3053
|
+
timedOut: result.timedOut,
|
|
3054
|
+
stopped: result.stopped,
|
|
3055
|
+
acceptance: result.acceptance ? { status: result.acceptance.status, reviewResult: result.acceptance.reviewResult ? { status: result.acceptance.reviewResult.status } : undefined } : undefined,
|
|
3056
|
+
review: result.review ? { status: result.review.status } : undefined,
|
|
3057
|
+
watchdog: result.watchdog,
|
|
3058
|
+
}];
|
|
3059
|
+
});
|
|
3060
|
+
const checklist = projectWorkflowChecklist({
|
|
3061
|
+
graph: details.workflowGraph,
|
|
3062
|
+
steps,
|
|
3063
|
+
hostSteps: details.workflow?.receipt?.hostSteps,
|
|
3064
|
+
preflight: details.preflight,
|
|
3065
|
+
trace: details.workflow?.trace,
|
|
3066
|
+
now: Date.now(),
|
|
3067
|
+
});
|
|
3068
|
+
return checklist.total > 0 ? checklist : undefined;
|
|
3069
|
+
}
|
|
3070
|
+
function renderWorkflowChatProgress(d, result, theme, layout, frame, expanded = false) {
|
|
3071
|
+
const workflow = d.workflow;
|
|
3072
|
+
const rows = workflow ? buildWorkflowChatProgressRows(workflow.trace, d.preflight) : d.preflight ? buildWorkflowChatProgressRows([], d.preflight) : [];
|
|
3073
|
+
const state = workflowOverallState(rows, workflow?.value !== undefined, result.isError);
|
|
3074
|
+
const glyph = state === "running" ? theme.fg("accent", runningGlyph(frame)) : state === "complete" ? theme.fg("success", "✓") : state === "paused" ? theme.fg("warning", "■") : theme.fg("error", "✗");
|
|
3075
|
+
const width = getTermWidth() - 4;
|
|
3076
|
+
const runId = d.runId ? d.runId.slice(0, 12) : "workflow";
|
|
3077
|
+
const repoLabel = d.chatProgress?.repoLabel ?? (d.chatProgress?.repoRelation === "same" ? "same repo" : "other repo");
|
|
3078
|
+
const phase = rows.find((row) => row.state === "running" && row.phase)?.phase ?? [...rows].reverse().find((row) => row.phase)?.phase;
|
|
3079
|
+
const c = new Container();
|
|
3080
|
+
const rowIndent = mainWindowIndent(layout, 1);
|
|
3081
|
+
c.addChild(new Text(truncLine(`${glyph} ${theme.fg("toolTitle", theme.bold("workflow"))} ${runId} ${theme.fg("dim", "·")} ${d.chatProgress?.repoRelation === "same" ? "same repo" : "other repo"} ${theme.fg("dim", "·")} ${state}`, width), 0, 0));
|
|
3082
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}Repo ${repoLabel}`), width), 0, 0));
|
|
3083
|
+
if (d.preflight)
|
|
3084
|
+
c.addChild(new Text(truncLine(theme.fg("dim", formatWorkflowPreflightPlanSummary(d.preflight, { indent: rowIndent })), width), 0, 0));
|
|
3085
|
+
if (phase)
|
|
3086
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}Phase ${phase}`), width), 0, 0));
|
|
3087
|
+
const checklist = projectWorkflowChecklist({ hostSteps: workflow?.receipt?.hostSteps, preflight: d.preflight, trace: workflow?.trace, now: Date.now() });
|
|
3088
|
+
for (const line of workflowChecklistWidgetLines(checklist, theme, rowIndent, false, frame, { limitPhases: !expanded, includeBottleneckOutput: expanded })) {
|
|
3089
|
+
c.addChild(new Text(truncLine(line, width), 0, 0));
|
|
3090
|
+
}
|
|
3091
|
+
if (rows.length === 0) {
|
|
3092
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}◦ waiting for workflow child launches`), width), 0, 0));
|
|
3093
|
+
return c;
|
|
3094
|
+
}
|
|
3095
|
+
const visible = visibleWorkflowRows(rows);
|
|
3096
|
+
if (visible.hiddenRows > 0)
|
|
3097
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}… ${visible.hiddenRows} older workflow rows hidden`), width), 0, 0));
|
|
3098
|
+
for (const row of visible.rows) {
|
|
3099
|
+
const status = workflowRowStateLabel(row, theme);
|
|
3100
|
+
const label = row.label && row.label !== row.key ? ` ${oneLine(row.label)}` : "";
|
|
3101
|
+
const duration = row.durationMs !== undefined ? ` ${theme.fg("dim", `· ${formatDuration(row.durationMs)}`)}` : "";
|
|
3102
|
+
const run = row.runId ? ` ${theme.fg("dim", `[${row.runId.slice(0, 8)}]`)}` : "";
|
|
3103
|
+
const error = row.error ? ` ${theme.fg(row.state === "detached" ? "warning" : "error", `· ${compactWorkflowError(row.error)}`)}` : "";
|
|
3104
|
+
const hints = expanded && row.preflight ? [
|
|
3105
|
+
row.preflight.mode ? `mode:${row.preflight.mode}` : undefined,
|
|
3106
|
+
row.preflight.decision ? `decision:${row.preflight.decision}` : undefined,
|
|
3107
|
+
row.preflight.claims?.length ? `claims:${row.preflight.claims.join(",")}` : undefined,
|
|
3108
|
+
row.preflight.expectedOutput ? `expected:${row.preflight.expectedOutput}` : undefined,
|
|
3109
|
+
row.preflight.independence ? `independence:${row.preflight.independence}` : undefined,
|
|
3110
|
+
].filter((value) => Boolean(value)).join(" · ") : "";
|
|
3111
|
+
c.addChild(new Text(truncLine(`${rowIndent}${workflowRowGlyph(row, theme, frame)} ${status} ${theme.bold(row.key)}${label}${run}${duration}${error}${hints ? ` ${theme.fg("dim", `· ${hints}`)}` : ""}`, width), 0, 0));
|
|
3112
|
+
}
|
|
3113
|
+
if (workflow?.preflightWarnings?.length) {
|
|
3114
|
+
const warningLines = expanded
|
|
3115
|
+
? formatWorkflowPreflightWarnings(workflow.preflightWarnings, { indent: rowIndent }).split("\n")
|
|
3116
|
+
: [formatWorkflowPreflightWarningSummary(workflow.preflightWarnings, { indent: rowIndent, hint: "expand for debug" })];
|
|
3117
|
+
for (const warningLine of warningLines)
|
|
3118
|
+
c.addChild(new Text(truncLine(theme.fg("warning", warningLine), width), 0, 0));
|
|
3119
|
+
}
|
|
3120
|
+
if (workflow?.emits.length)
|
|
3121
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}Emits ${workflow.emits.length}`), width), 0, 0));
|
|
3122
|
+
return c;
|
|
3123
|
+
}
|
|
3124
|
+
function renderMultiCompact(d, theme, layout, frame) {
|
|
3125
|
+
const hasRunning = detailsHaveRunningResult(d);
|
|
3126
|
+
const detached = d.results.some((r) => r.detached)
|
|
3127
|
+
|| workflowGraphHasStatus(d, ["detached"]);
|
|
3128
|
+
const stopped = d.results.some((r) => r.stopped)
|
|
3129
|
+
|| workflowGraphHasStatus(d, ["stopped"]);
|
|
3130
|
+
const failed = d.results.some((r) => !hasTerminalResultFlag(r) && r.exitCode !== 0 && !isResultRunning(r))
|
|
3131
|
+
|| workflowGraphHasStatus(d, ["failed"]);
|
|
3132
|
+
const paused = d.results.some((r) => r.interrupted)
|
|
3133
|
+
|| workflowGraphHasStatus(d, ["paused"]);
|
|
3134
|
+
const partial = workflowGraphHasStatus(d, ["partial"]);
|
|
3135
|
+
let totalSummary = d.progressSummary;
|
|
3136
|
+
if (!totalSummary) {
|
|
3137
|
+
let sawProgress = false;
|
|
3138
|
+
const summary = { toolCount: 0, tokens: 0, durationMs: 0 };
|
|
3139
|
+
for (const r of d.results) {
|
|
3140
|
+
const prog = r.progress || r.progressSummary;
|
|
3141
|
+
if (!prog)
|
|
3142
|
+
continue;
|
|
3143
|
+
sawProgress = true;
|
|
3144
|
+
summary.toolCount += prog.toolCount;
|
|
3145
|
+
summary.tokens += prog.tokens;
|
|
3146
|
+
summary.durationMs = d.mode === "chain" ? summary.durationMs + prog.durationMs : Math.max(summary.durationMs, prog.durationMs);
|
|
3147
|
+
}
|
|
3148
|
+
if (sawProgress)
|
|
3149
|
+
totalSummary = summary;
|
|
3150
|
+
}
|
|
3151
|
+
const multiLabel = buildMultiProgressLabel(d, hasRunning);
|
|
3152
|
+
const itemTitle = multiLabel.itemTitle;
|
|
3153
|
+
const workflowChecklist = foregroundWorkflowChecklist(d);
|
|
3154
|
+
const checklistPrimary = d.mode === "workflow" && workflowChecklist !== undefined;
|
|
3155
|
+
const stats = statJoin(theme, [checklistPrimary ? formatWorkflowChecklistSummary(workflowChecklist) : multiLabel.headerLabel, formatProgressStats(theme, totalSummary), formatTotalCostStat(d.totalCost)]);
|
|
3156
|
+
const aggregatePresentation = semanticResultPresentation({
|
|
3157
|
+
running: hasRunning,
|
|
3158
|
+
detached,
|
|
3159
|
+
stopped,
|
|
3160
|
+
interrupted: paused,
|
|
3161
|
+
failed,
|
|
3162
|
+
partial,
|
|
3163
|
+
seed: runningSeed(progressRunningSeed(totalSummary), d.currentStepIndex),
|
|
3164
|
+
frame,
|
|
3165
|
+
});
|
|
3166
|
+
const glyph = theme.fg(aggregatePresentation.tone, aggregatePresentation.glyph);
|
|
3167
|
+
const contextBadge = contextModeBadge(theme, d.context);
|
|
3168
|
+
const c = new Container();
|
|
3169
|
+
const width = getTermWidth() - 4;
|
|
3170
|
+
const rowIndent = mainWindowIndent(layout, 1);
|
|
3171
|
+
const detailIndent = mainWindowIndent(layout, 2);
|
|
3172
|
+
c.addChild(new Text(truncLine(`${glyph} ${theme.fg("toolTitle", theme.bold(d.mode))}${contextBadge}${stats ? ` ${theme.fg("dim", "·")} ${stats}` : ""}`, width), 0, 0));
|
|
3173
|
+
if (checklistPrimary) {
|
|
3174
|
+
for (const line of workflowChecklistWidgetLines(workflowChecklist, theme, rowIndent, false, frame, { includeSummary: false })) {
|
|
3175
|
+
c.addChild(new Text(truncLine(line, width), 0, 0));
|
|
3176
|
+
}
|
|
3177
|
+
if (hasRunning || workflowChecklist.running > 0)
|
|
3178
|
+
c.addChild(new Text(truncLine(theme.fg("accent", `${rowIndent}${liveDetailHintText()}`), width), 0, 0));
|
|
3179
|
+
return c;
|
|
3180
|
+
}
|
|
3181
|
+
for (const line of workflowChecklistWidgetLines(workflowChecklist, theme, rowIndent, false, frame)) {
|
|
3182
|
+
c.addChild(new Text(truncLine(line, width), 0, 0));
|
|
3183
|
+
}
|
|
3184
|
+
const useResultsDirectly = multiLabel.hasParallelInChain || !d.chainAgents?.length;
|
|
3185
|
+
const displayStart = multiLabel.showActiveGroupOnly ? multiLabel.groupStartIndex : 0;
|
|
3186
|
+
const displayEnd = multiLabel.showActiveGroupOnly ? multiLabel.groupEndIndex : (useResultsDirectly ? d.results.length : d.chainAgents.length);
|
|
3187
|
+
const chainEntries = buildChainRenderEntries(d, multiLabel);
|
|
3188
|
+
const renderEntries = chainEntries ?? buildForegroundResultEntries(d, multiLabel, displayStart, displayEnd, useResultsDirectly);
|
|
3189
|
+
for (const entry of renderEntries) {
|
|
3190
|
+
if (entry.kind === "group") {
|
|
3191
|
+
const glyph = widgetStepGlyph(entry.status, theme);
|
|
3192
|
+
const statusLabel = widgetStepStatus(entry.status, theme);
|
|
3193
|
+
const groupLabel = entry.groupLabel ? ` (${compactTaskText(undefined, entry.groupLabel) ?? entry.groupLabel})` : "";
|
|
3194
|
+
c.addChild(new Text(truncLine(`${rowIndent}${glyph} ${entry.stepLabel}${groupLabel} ${theme.fg("dim", "·")} ${statusLabel}`, width), 0, 0));
|
|
3195
|
+
if (entry.error)
|
|
3196
|
+
c.addChild(new Text(truncLine(theme.fg("error", `${detailIndent}⎿ Error: ${entry.error}`), width), 0, 0));
|
|
3197
|
+
continue;
|
|
3198
|
+
}
|
|
3199
|
+
const i = entry.resultIndex;
|
|
3200
|
+
const r = d.results[i];
|
|
3201
|
+
const rowNumber = entry.rowNumber;
|
|
3202
|
+
const agentName = entry.agentName;
|
|
3203
|
+
if (!r) {
|
|
3204
|
+
const pendingLabel = entry.rowLabel ?? (entry.isParallel ? "" : `${itemTitle} ${rowNumber}`);
|
|
3205
|
+
const labelPrefix = pendingLabel ? `${pendingLabel}: ` : "";
|
|
3206
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}◦ ${labelPrefix}${agentName} · pending`), width), 0, 0));
|
|
3207
|
+
continue;
|
|
3208
|
+
}
|
|
3209
|
+
const output = getSingleResultOutput(r);
|
|
3210
|
+
const progressFromArray = foregroundProgressForResult(d, i);
|
|
3211
|
+
const rProg = r.progress || progressFromArray || r.progressSummary;
|
|
3212
|
+
const rRunning = rProg && "status" in rProg && isResultRunning(r, rProg.status);
|
|
3213
|
+
const rPending = rProg && "status" in rProg && rProg.status === "pending";
|
|
3214
|
+
const stepStats = formatProgressStats(theme, rProg);
|
|
3215
|
+
const glyph = rPending ? theme.fg("dim", "◦") : resultGlyph(r, output, theme, rRunning, progressRunningSeed(rProg), frame);
|
|
3216
|
+
const pendingLabel = rPending ? ` ${theme.fg("dim", "· pending")}` : "";
|
|
3217
|
+
const stepLabel = entry.rowLabel;
|
|
3218
|
+
const rowProgressModel = rProg && "status" in rProg ? rProg : undefined;
|
|
3219
|
+
const rowModelDisplay = modelThinkingBadge(theme, r.model ?? rowProgressModel?.model, r.thinking ?? rowProgressModel?.thinking);
|
|
3220
|
+
const labelPrefix = stepLabel ? `${stepLabel}: ` : "";
|
|
3221
|
+
const line = `${glyph} ${labelPrefix}${themeBold(theme, agentName)}${contextModeBadge(theme, r.context)}${rowModelDisplay}${stepStats ? ` ${theme.fg("dim", "·")} ${stepStats}` : ""}${pendingLabel}`;
|
|
3222
|
+
c.addChild(new Text(truncLine(`${rowIndent}${line}`, width), 0, 0));
|
|
3223
|
+
if (rRunning || rPending) {
|
|
3224
|
+
const task = compactTaskText(r.task, workflowLabelForResult(d, i));
|
|
3225
|
+
if (task)
|
|
3226
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}task: ${task}`), width), 0, 0));
|
|
3227
|
+
}
|
|
3228
|
+
if (rRunning && rProg && "status" in rProg) {
|
|
3229
|
+
const liveProgress = rProg;
|
|
3230
|
+
const activity = compactCurrentActivity(liveProgress);
|
|
3231
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}⎿ ${activity}`), width), 0, 0));
|
|
3232
|
+
for (const nestedLine of formatNestedWidgetLines(r.children, theme, width, false, snapshotNowForProgress(liveProgress))) {
|
|
3233
|
+
c.addChild(new Text(truncLine(`${detailIndent}${nestedLine}`, width), 0, 0));
|
|
3234
|
+
}
|
|
3235
|
+
c.addChild(new Text(truncLine(theme.fg("accent", `${detailIndent}${liveDetailHintText()}`), width), 0, 0));
|
|
3236
|
+
}
|
|
3237
|
+
else if (!rPending && (r.exitCode !== 0 || r.interrupted || r.detached || hasEmptyTextOutputWithoutOutputTarget(r.task, output))) {
|
|
3238
|
+
c.addChild(new Text(truncLine(theme.fg(r.exitCode !== 0 ? "error" : "dim", `${detailIndent}⎿ ${resultStatusLine(r, output)}`), width), 0, 0));
|
|
3239
|
+
}
|
|
3240
|
+
if (!rRunning && !rPending) {
|
|
3241
|
+
for (const nestedLine of formatNestedWidgetLines(r.children, theme, width, false, r.progress?.lastActivityAt)) {
|
|
3242
|
+
c.addChild(new Text(truncLine(`${detailIndent}${nestedLine}`, width), 0, 0));
|
|
3243
|
+
}
|
|
3244
|
+
}
|
|
3245
|
+
const outputTarget = extractOutputTarget(r.task);
|
|
3246
|
+
if (outputTarget)
|
|
3247
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}output: ${outputTarget}`), width), 0, 0));
|
|
3248
|
+
if (r.artifactPaths)
|
|
3249
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}output: ${shortenPath(r.artifactPaths.outputPath)}`), width), 0, 0));
|
|
3250
|
+
}
|
|
3251
|
+
if (d.artifacts)
|
|
3252
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}artifacts: ${shortenPath(d.artifacts.dir)}`), width), 0, 0));
|
|
3253
|
+
return c;
|
|
3254
|
+
}
|
|
3255
|
+
export function renderSubagentSummary(result, options, theme) {
|
|
3256
|
+
const details = result.details;
|
|
3257
|
+
const results = details?.results ?? [];
|
|
3258
|
+
const hasSingleTerminalResult = results.length === 1 && hasTerminalResult(results[0]);
|
|
3259
|
+
const hasOnlyTerminalResults = results.length > 0 && results.every(hasTerminalResult);
|
|
3260
|
+
const running = !hasSingleTerminalResult && !hasOnlyTerminalResults && (options.isPartial === true
|
|
3261
|
+
|| Boolean(details?.asyncId && details.mode !== "management")
|
|
3262
|
+
|| Boolean(details && detailsHaveRunningResult(details)));
|
|
3263
|
+
const stopped = results.some((entry) => entry.stopped)
|
|
3264
|
+
|| Boolean(details && workflowGraphHasStatus(details, ["stopped"]));
|
|
3265
|
+
const paused = results.some((entry) => entry.interrupted || entry.detached)
|
|
3266
|
+
|| Boolean(details && workflowGraphHasStatus(details, ["paused", "detached"]));
|
|
3267
|
+
const failed = result.isError === true
|
|
3268
|
+
|| results.some((entry) => !hasTerminalResultFlag(entry) && entry.exitCode !== 0 && !isResultRunning(entry))
|
|
3269
|
+
|| Boolean(details && workflowGraphHasStatus(details, ["failed"]));
|
|
3270
|
+
const partial = Boolean(details && workflowGraphHasStatus(details, ["partial"]));
|
|
3271
|
+
const state = running ? "running" : failed ? "failed" : stopped ? "stopped" : paused ? "paused" : partial ? "partial" : "completed";
|
|
3272
|
+
const glyph = state === "running"
|
|
3273
|
+
? theme.fg("accent", STATIC_RUNNING_GLYPH)
|
|
3274
|
+
: state === "completed"
|
|
3275
|
+
? theme.fg("success", "✓")
|
|
3276
|
+
: state === "failed"
|
|
3277
|
+
? theme.fg("error", "✗")
|
|
3278
|
+
: theme.fg("warning", "■");
|
|
3279
|
+
const label = details?.mode === "single" && results.length === 1
|
|
3280
|
+
? foregroundSingleDisplayName(results[0])
|
|
3281
|
+
: details?.mode || "subagent";
|
|
3282
|
+
return new Text(truncLine(`${glyph} ${theme.fg("toolTitle", theme.bold(label))} ${theme.fg("dim", "·")} ${theme.fg(state === "failed" ? "error" : state === "completed" ? "success" : state === "running" ? "accent" : "warning", state)}`, getTermWidth() - 4), 0, 0);
|
|
3283
|
+
}
|
|
3284
|
+
/**
|
|
3285
|
+
* Render a subagent result
|
|
3286
|
+
*/
|
|
3287
|
+
export function renderSubagentResult(result, options, theme, frame, rendererConfig, foregroundDetachShortcut) {
|
|
3288
|
+
const layout = resolveMainWindowRenderLayout(rendererConfig);
|
|
3289
|
+
const compact = (component) => capCompactMainWindowResult(component, layout, theme, !options.expanded);
|
|
3290
|
+
const d = result.details;
|
|
3291
|
+
if (d?.mode === "workflow" && d.chatProgress?.mode === "live-card" && d.workflow?.value === undefined && (!result.isError || (d.workflow?.trace.length ?? 0) > 0)) {
|
|
3292
|
+
return compact(renderWorkflowChatProgress(d, result, theme, options.expanded ? resolveMainWindowRenderLayout() : layout, frame, options.expanded));
|
|
3293
|
+
}
|
|
3294
|
+
if (!d || !d.results.length) {
|
|
3295
|
+
const t = result.content[0];
|
|
3296
|
+
const text = t?.type === "text" ? t.text : "(no output)";
|
|
3297
|
+
const contextPrefix = contextModePrefix(theme, d?.context);
|
|
3298
|
+
const width = getTermWidth() - 4;
|
|
3299
|
+
if (!text.includes("\n"))
|
|
3300
|
+
return compact(new Text(truncLine(`${contextPrefix}${text}`, width), 0, 0));
|
|
3301
|
+
if (d && !options.expanded && !result.isError) {
|
|
3302
|
+
const lines = text.split(/\r?\n/);
|
|
3303
|
+
const firstNonEmptyLine = lines.find((line) => line.trim())?.trim() || "(no output)";
|
|
3304
|
+
const compactLine = d.mode === "workflow" && d.preflight
|
|
3305
|
+
? formatWorkflowPreflightPlanSummary(d.preflight)
|
|
3306
|
+
: firstNonEmptyLine;
|
|
3307
|
+
const c = new Container();
|
|
3308
|
+
const detailIndent = mainWindowIndent(layout, 1);
|
|
3309
|
+
c.addChild(new Text(truncLine(`${contextPrefix}${compactLine} · ${lines.length} lines`, width), 0, 0));
|
|
3310
|
+
c.addChild(new Text(truncLine(theme.fg("accent", `${detailIndent}Press ${liveDetailKeyText()} for full output`), width), 0, 0));
|
|
3311
|
+
return compact(c);
|
|
3312
|
+
}
|
|
3313
|
+
const c = new Container();
|
|
3314
|
+
const wrapped = wrapPlainText(`${contextPrefix}${text}`, width);
|
|
3315
|
+
for (const line of wrapped)
|
|
3316
|
+
c.addChild(new Text(line, 0, 0));
|
|
3317
|
+
return c;
|
|
3318
|
+
}
|
|
3319
|
+
const expanded = options.expanded;
|
|
3320
|
+
const mdTheme = getMarkdownTheme();
|
|
3321
|
+
if (d.mode === "single" && d.results.length === 1) {
|
|
3322
|
+
const r = d.results[0];
|
|
3323
|
+
const detachableShortcut = d.asyncId || d.background ? undefined : foregroundDetachShortcut;
|
|
3324
|
+
if (!r)
|
|
3325
|
+
return compact(renderMultiCompact(d, theme, layout, frame));
|
|
3326
|
+
if (!expanded)
|
|
3327
|
+
return compact(renderSingleCompact(d, r, theme, layout, frame, detachableShortcut));
|
|
3328
|
+
const isRunning = isResultRunning(r);
|
|
3329
|
+
const contextBadge = contextModeBadge(theme, r.context ?? d.context);
|
|
3330
|
+
const output = r.truncation?.text || getSingleResultOutput(r);
|
|
3331
|
+
const presentation = styledResultPresentation(resultPresentation(r, output, isRunning, undefined, frame), theme);
|
|
3332
|
+
const progressInfo = isRunning && r.progress
|
|
3333
|
+
? ` | ${r.progress.toolCount} tools, ${formatTokens(r.progress.tokens)} tok, ${formatDuration(r.progress.durationMs)}`
|
|
3334
|
+
: r.progressSummary
|
|
3335
|
+
? ` | ${r.progressSummary.toolCount} tools, ${formatTokens(r.progressSummary.tokens)} tok, ${formatDuration(r.progressSummary.durationMs)}`
|
|
3336
|
+
: "";
|
|
3337
|
+
const w = getTermWidth() - 4;
|
|
3338
|
+
const fit = (text) => expanded ? text : truncLine(text, w);
|
|
3339
|
+
const toolCallLines = getToolCallLines(r, expanded);
|
|
3340
|
+
const c = new Container();
|
|
3341
|
+
c.addChild(new Text(fit(`${presentation.glyph} ${theme.fg("toolTitle", theme.bold(foregroundSingleDisplayName(r)))}${contextBadge}${progressInfo} ${theme.fg("dim", "·")} ${presentation.label}`), 0, 0));
|
|
3342
|
+
c.addChild(new Spacer(1));
|
|
3343
|
+
const taskMaxLen = Math.max(20, w - 8);
|
|
3344
|
+
const taskPreview = expanded || r.task.length <= taskMaxLen
|
|
3345
|
+
? r.task
|
|
3346
|
+
: `${r.task.slice(0, taskMaxLen)}...`;
|
|
3347
|
+
c.addChild(new Text(fit(theme.fg("dim", `Task: ${taskPreview}`)), 0, 0));
|
|
3348
|
+
c.addChild(new Spacer(1));
|
|
3349
|
+
if (!isRunning && (r.exitCode !== 0 || r.interrupted || r.detached || r.stopped)) {
|
|
3350
|
+
c.addChild(new Text(fit(theme.fg(r.exitCode !== 0 ? "error" : "dim", ` ⎿ ${resultStatusLine(r, output)}`)), 0, 0));
|
|
3351
|
+
}
|
|
3352
|
+
if (isRunning && r.progress) {
|
|
3353
|
+
const progressSnapshotNow = snapshotNowForProgress(r.progress);
|
|
3354
|
+
for (const nestedLine of formatNestedWidgetLines(r.children, theme, w, true, progressSnapshotNow, 12)) {
|
|
3355
|
+
c.addChild(new Text(fit(` ${nestedLine}`), 0, 0));
|
|
3356
|
+
}
|
|
3357
|
+
const toolLine = formatCurrentToolLine(r.progress, w, expanded, progressSnapshotNow);
|
|
3358
|
+
if (toolLine) {
|
|
3359
|
+
c.addChild(new Text(fit(theme.fg("warning", `> ${toolLine}`)), 0, 0));
|
|
3360
|
+
}
|
|
3361
|
+
const liveStatusLine = buildLiveStatusLine(r.progress, progressSnapshotNow);
|
|
3362
|
+
if (liveStatusLine) {
|
|
3363
|
+
c.addChild(new Text(fit(theme.fg("accent", liveStatusLine)), 0, 0));
|
|
3364
|
+
}
|
|
3365
|
+
c.addChild(new Text(fit(theme.fg("accent", foregroundSingleHintText(detachableShortcut))), 0, 0));
|
|
3366
|
+
if (r.artifactPaths) {
|
|
3367
|
+
c.addChild(new Text(fit(theme.fg("dim", `Artifacts: ${shortenPath(r.artifactPaths.outputPath)}`)), 0, 0));
|
|
3368
|
+
}
|
|
3369
|
+
if (r.progress.recentTools?.length) {
|
|
3370
|
+
for (const t of r.progress.recentTools.slice(-3)) {
|
|
3371
|
+
const maxArgsLen = Math.max(40, w - 24);
|
|
3372
|
+
const argsPreview = renderToolArgsPreview(t.args, maxArgsLen, expanded);
|
|
3373
|
+
c.addChild(new Text(fit(theme.fg("dim", `${t.tool}: ${argsPreview}`)), 0, 0));
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
3376
|
+
for (const line of compactRecentOutputLines(r.progress.recentOutput)) {
|
|
3377
|
+
c.addChild(new Text(fit(theme.fg("dim", ` ${line}`)), 0, 0));
|
|
3378
|
+
}
|
|
3379
|
+
if (toolLine || liveStatusLine || r.progress.recentTools?.length || r.progress.recentOutput?.length || r.artifactPaths) {
|
|
3380
|
+
c.addChild(new Spacer(1));
|
|
3381
|
+
}
|
|
3382
|
+
}
|
|
3383
|
+
else {
|
|
3384
|
+
for (const nestedLine of formatNestedWidgetLines(r.children, theme, w, true, r.progress?.lastActivityAt, 8)) {
|
|
3385
|
+
c.addChild(new Text(fit(` ${nestedLine}`), 0, 0));
|
|
3386
|
+
}
|
|
3387
|
+
}
|
|
3388
|
+
if (expanded) {
|
|
3389
|
+
for (const line of toolCallLines) {
|
|
3390
|
+
c.addChild(new Text(fit(theme.fg("muted", line)), 0, 0));
|
|
3391
|
+
}
|
|
3392
|
+
if (toolCallLines.length)
|
|
3393
|
+
c.addChild(new Spacer(1));
|
|
3394
|
+
}
|
|
3395
|
+
if (output)
|
|
3396
|
+
c.addChild(new Markdown(output, 0, 0, mdTheme));
|
|
3397
|
+
c.addChild(new Spacer(1));
|
|
3398
|
+
if (r.skills?.length) {
|
|
3399
|
+
c.addChild(new Text(fit(theme.fg("dim", `Skills: ${r.skills.join(", ")}`)), 0, 0));
|
|
3400
|
+
}
|
|
3401
|
+
if (r.skillsWarning) {
|
|
3402
|
+
c.addChild(new Text(fit(theme.fg("warning", `Warning: ${r.skillsWarning}`)), 0, 0));
|
|
3403
|
+
}
|
|
3404
|
+
c.addChild(new Text(fit(theme.fg("dim", formatUsage(r.usage, r.model))), 0, 0));
|
|
3405
|
+
if (r.sessionFile) {
|
|
3406
|
+
c.addChild(new Text(fit(theme.fg("dim", `Session: ${shortenPath(r.sessionFile)}`)), 0, 0));
|
|
3407
|
+
}
|
|
3408
|
+
if (!isRunning && r.artifactPaths) {
|
|
3409
|
+
c.addChild(new Spacer(1));
|
|
3410
|
+
c.addChild(new Text(fit(theme.fg("dim", `Artifacts: ${shortenPath(r.artifactPaths.outputPath)}`)), 0, 0));
|
|
3411
|
+
}
|
|
3412
|
+
return c;
|
|
3413
|
+
}
|
|
3414
|
+
if (!expanded)
|
|
3415
|
+
return compact(renderMultiCompact(d, theme, layout, frame));
|
|
3416
|
+
const hasRunning = detailsHaveRunningResult(d);
|
|
3417
|
+
const detached = d.results.some((r) => r.detached)
|
|
3418
|
+
|| workflowGraphHasStatus(d, ["detached"]);
|
|
3419
|
+
const stopped = d.results.some((r) => r.stopped)
|
|
3420
|
+
|| workflowGraphHasStatus(d, ["stopped"]);
|
|
3421
|
+
const failed = d.results.some((r) => !hasTerminalResultFlag(r) && r.exitCode !== 0 && !isResultRunning(r))
|
|
3422
|
+
|| workflowGraphHasStatus(d, ["failed"]);
|
|
3423
|
+
const paused = d.results.some((r) => r.interrupted)
|
|
3424
|
+
|| workflowGraphHasStatus(d, ["paused"]);
|
|
3425
|
+
const partial = workflowGraphHasStatus(d, ["partial"]);
|
|
3426
|
+
const completedWithoutOutput = d.results.some((r) => !hasTerminalResultFlag(r)
|
|
3427
|
+
&& r.exitCode === 0
|
|
3428
|
+
&& !isResultRunning(r)
|
|
3429
|
+
&& hasEmptyTextOutputWithoutOutputTarget(r.task, getSingleResultOutput(r)));
|
|
3430
|
+
const presentation = styledResultPresentation(semanticResultPresentation({
|
|
3431
|
+
running: hasRunning,
|
|
3432
|
+
detached,
|
|
3433
|
+
stopped,
|
|
3434
|
+
interrupted: paused,
|
|
3435
|
+
failed,
|
|
3436
|
+
partial,
|
|
3437
|
+
completedWithoutOutput,
|
|
3438
|
+
frame,
|
|
3439
|
+
}), theme);
|
|
3440
|
+
const totalSummary = d.progressSummary ||
|
|
3441
|
+
d.results.reduce((acc, r) => {
|
|
3442
|
+
const prog = r.progress || r.progressSummary;
|
|
3443
|
+
if (prog) {
|
|
3444
|
+
acc.toolCount += prog.toolCount;
|
|
3445
|
+
acc.tokens += prog.tokens;
|
|
3446
|
+
acc.durationMs =
|
|
3447
|
+
d.mode === "chain"
|
|
3448
|
+
? acc.durationMs + prog.durationMs
|
|
3449
|
+
: Math.max(acc.durationMs, prog.durationMs);
|
|
3450
|
+
}
|
|
3451
|
+
return acc;
|
|
3452
|
+
}, { toolCount: 0, tokens: 0, durationMs: 0 });
|
|
3453
|
+
const summaryParts = [
|
|
3454
|
+
totalSummary.toolCount || totalSummary.tokens
|
|
3455
|
+
? `${totalSummary.toolCount} tools, ${formatTokens(totalSummary.tokens)} tok, ${formatDuration(totalSummary.durationMs)}`
|
|
3456
|
+
: "",
|
|
3457
|
+
formatTotalCostStat(d.totalCost),
|
|
3458
|
+
].filter(Boolean);
|
|
3459
|
+
const summaryStr = summaryParts.length ? ` | ${summaryParts.join(", ")}` : "";
|
|
3460
|
+
const modeLabel = d.mode;
|
|
3461
|
+
const contextBadge = contextModeBadge(theme, d.context);
|
|
3462
|
+
const multiLabel = buildMultiProgressLabel(d, hasRunning);
|
|
3463
|
+
const itemTitle = multiLabel.itemTitle;
|
|
3464
|
+
const chainVis = d.chainAgents?.length && !multiLabel.hasParallelInChain
|
|
3465
|
+
? d.chainAgents
|
|
3466
|
+
.map((agent, i) => {
|
|
3467
|
+
const result = d.results[i];
|
|
3468
|
+
const displayName = foregroundResultDisplayName(d, i, result, agent);
|
|
3469
|
+
const isCurrent = i === (d.currentStepIndex ?? d.results.length);
|
|
3470
|
+
const stepPresentation = result
|
|
3471
|
+
? styledResultPresentation(resultPresentation(result, getSingleResultOutput(result), isCurrent && hasRunning && !hasTerminalResultFlag(result)), theme)
|
|
3472
|
+
: undefined;
|
|
3473
|
+
const stepStatus = stepPresentation
|
|
3474
|
+
? `${stepPresentation.glyph} ${stepPresentation.label}`
|
|
3475
|
+
: theme.fg("dim", "◦ pending");
|
|
3476
|
+
return `${stepStatus} ${displayName}${contextModeBadge(theme, result?.context)}`;
|
|
3477
|
+
})
|
|
3478
|
+
.join(theme.fg("dim", " → "))
|
|
3479
|
+
: null;
|
|
3480
|
+
const w = getTermWidth() - 4;
|
|
3481
|
+
const fit = (text) => expanded ? text : truncLine(text, w);
|
|
3482
|
+
const c = new Container();
|
|
3483
|
+
c.addChild(new Text(fit(`${presentation.glyph} ${theme.fg("toolTitle", theme.bold(modeLabel))}${contextBadge} · ${multiLabel.headerLabel}${summaryStr} ${theme.fg("dim", "·")} ${presentation.label}`), 0, 0));
|
|
3484
|
+
if (chainVis) {
|
|
3485
|
+
c.addChild(new Text(fit(` ${chainVis}`), 0, 0));
|
|
3486
|
+
}
|
|
3487
|
+
const workflowChecklist = foregroundWorkflowChecklist(d);
|
|
3488
|
+
for (const line of workflowChecklistWidgetLines(workflowChecklist, theme, " ", true, frame, { includeItemErrors: false })) {
|
|
3489
|
+
c.addChild(new Text(fit(line), 0, 0));
|
|
3490
|
+
}
|
|
3491
|
+
const useResultsDirectly = multiLabel.hasParallelInChain || !d.chainAgents?.length;
|
|
3492
|
+
const displayStart = multiLabel.showActiveGroupOnly ? multiLabel.groupStartIndex : 0;
|
|
3493
|
+
const displayEnd = multiLabel.showActiveGroupOnly ? multiLabel.groupEndIndex : (useResultsDirectly ? d.results.length : d.chainAgents.length);
|
|
3494
|
+
const chainEntries = buildChainRenderEntries(d, multiLabel);
|
|
3495
|
+
const renderEntries = chainEntries ?? buildForegroundResultEntries(d, multiLabel, displayStart, displayEnd, useResultsDirectly);
|
|
3496
|
+
c.addChild(new Spacer(1));
|
|
3497
|
+
for (const entry of renderEntries) {
|
|
3498
|
+
if (entry.kind === "group") {
|
|
3499
|
+
const statusLabel = widgetStepStatus(entry.status, theme);
|
|
3500
|
+
const groupLabel = entry.groupLabel ? ` (${compactTaskText(undefined, entry.groupLabel) ?? entry.groupLabel})` : "";
|
|
3501
|
+
c.addChild(new Text(fit(` ${statusLabel} ${entry.stepLabel}${groupLabel}`), 0, 0));
|
|
3502
|
+
c.addChild(new Text(theme.fg(entry.status === "failed" ? "error" : "dim", ` status: ${entry.status}`), 0, 0));
|
|
3503
|
+
if (entry.error)
|
|
3504
|
+
c.addChild(new Text(theme.fg("error", ` error: ${entry.error}`), 0, 0));
|
|
3505
|
+
c.addChild(new Spacer(1));
|
|
3506
|
+
continue;
|
|
3507
|
+
}
|
|
3508
|
+
const i = entry.resultIndex;
|
|
3509
|
+
const r = d.results[i];
|
|
3510
|
+
const rowNumber = entry.rowNumber;
|
|
3511
|
+
const agentName = entry.agentName;
|
|
3512
|
+
if (!r) {
|
|
3513
|
+
const pendingLabel = entry.rowLabel ?? (entry.isParallel ? "" : `${itemTitle} ${rowNumber}`);
|
|
3514
|
+
const labelPrefix = pendingLabel ? `${pendingLabel}: ` : "";
|
|
3515
|
+
c.addChild(new Text(fit(theme.fg("dim", ` ${labelPrefix}${agentName}`)), 0, 0));
|
|
3516
|
+
c.addChild(new Text(theme.fg("dim", ` status: pending`), 0, 0));
|
|
3517
|
+
c.addChild(new Spacer(1));
|
|
3518
|
+
continue;
|
|
3519
|
+
}
|
|
3520
|
+
const progressFromArray = foregroundProgressForResult(d, i);
|
|
3521
|
+
const rProg = r.progress || progressFromArray || r.progressSummary;
|
|
3522
|
+
const rRunning = isResultRunning(r, rProg?.status);
|
|
3523
|
+
const resultOutput = getSingleResultOutput(r);
|
|
3524
|
+
const rowPresentation = styledResultPresentation(resultPresentation(r, resultOutput, rRunning, progressRunningSeed(rProg), frame), theme);
|
|
3525
|
+
const stats = rProg ? ` | ${rProg.toolCount} tools, ${formatDuration(rProg.durationMs)}` : "";
|
|
3526
|
+
const modelDisplay = modelThinkingBadge(theme, r.model ?? rProg?.model, r.thinking ?? rProg?.thinking);
|
|
3527
|
+
const stepLabel = entry.rowLabel;
|
|
3528
|
+
const contextBadge = contextModeBadge(theme, r.context);
|
|
3529
|
+
const labelPrefix = stepLabel ? `${stepLabel}: ` : "";
|
|
3530
|
+
const stepHeader = rRunning
|
|
3531
|
+
? `${rowPresentation.glyph} ${labelPrefix}${theme.bold(theme.fg("warning", agentName))}${contextBadge}${modelDisplay}${stats} ${theme.fg("dim", "·")} ${rowPresentation.label}`
|
|
3532
|
+
: `${rowPresentation.glyph} ${labelPrefix}${theme.bold(agentName)}${contextBadge}${modelDisplay}${stats} ${theme.fg("dim", "·")} ${rowPresentation.label}`;
|
|
3533
|
+
const toolCallLines = getToolCallLines(r, expanded);
|
|
3534
|
+
c.addChild(new Text(fit(stepHeader), 0, 0));
|
|
3535
|
+
const taskMaxLen = Math.max(20, w - 12);
|
|
3536
|
+
const taskPreview = expanded || r.task.length <= taskMaxLen
|
|
3537
|
+
? r.task
|
|
3538
|
+
: `${r.task.slice(0, taskMaxLen)}...`;
|
|
3539
|
+
c.addChild(new Text(fit(theme.fg("dim", ` task: ${taskPreview}`)), 0, 0));
|
|
3540
|
+
const outputTarget = extractOutputTarget(r.task);
|
|
3541
|
+
if (outputTarget) {
|
|
3542
|
+
c.addChild(new Text(fit(theme.fg("dim", ` output: ${outputTarget}`)), 0, 0));
|
|
3543
|
+
}
|
|
3544
|
+
if (!rRunning && (r.exitCode !== 0 || r.interrupted || r.detached || r.stopped)) {
|
|
3545
|
+
c.addChild(new Text(fit(theme.fg(r.exitCode !== 0 ? "error" : "dim", ` ⎿ ${resultStatusLine(r, resultOutput)}`)), 0, 0));
|
|
3546
|
+
}
|
|
3547
|
+
if (r.skills?.length) {
|
|
3548
|
+
c.addChild(new Text(fit(theme.fg("dim", ` skills: ${r.skills.join(", ")}`)), 0, 0));
|
|
3549
|
+
}
|
|
3550
|
+
if (r.skillsWarning) {
|
|
3551
|
+
c.addChild(new Text(fit(theme.fg("warning", ` Warning: ${r.skillsWarning}`)), 0, 0));
|
|
3552
|
+
}
|
|
3553
|
+
if (rRunning && rProg) {
|
|
3554
|
+
if (rProg.skills?.length) {
|
|
3555
|
+
c.addChild(new Text(fit(theme.fg("accent", ` skills: ${rProg.skills.join(", ")}`)), 0, 0));
|
|
3556
|
+
}
|
|
3557
|
+
const progressSnapshotNow = snapshotNowForProgress(rProg);
|
|
3558
|
+
const toolLine = formatCurrentToolLine(rProg, w, expanded, progressSnapshotNow);
|
|
3559
|
+
if (toolLine) {
|
|
3560
|
+
c.addChild(new Text(fit(theme.fg("warning", ` > ${toolLine}`)), 0, 0));
|
|
3561
|
+
}
|
|
3562
|
+
const liveStatusLine = buildLiveStatusLine(rProg, progressSnapshotNow);
|
|
3563
|
+
if (liveStatusLine) {
|
|
3564
|
+
c.addChild(new Text(fit(theme.fg("accent", ` ${liveStatusLine}`)), 0, 0));
|
|
3565
|
+
}
|
|
3566
|
+
for (const nestedLine of formatNestedWidgetLines(r.children, theme, w, true, progressSnapshotNow, 8)) {
|
|
3567
|
+
c.addChild(new Text(fit(` ${nestedLine}`), 0, 0));
|
|
3568
|
+
}
|
|
3569
|
+
c.addChild(new Text(fit(theme.fg("accent", ` ${liveDetailHintText()}`)), 0, 0));
|
|
3570
|
+
if (r.artifactPaths) {
|
|
3571
|
+
c.addChild(new Text(fit(theme.fg("dim", ` artifacts: ${shortenPath(r.artifactPaths.outputPath)}`)), 0, 0));
|
|
3572
|
+
}
|
|
3573
|
+
if (rProg.recentTools?.length) {
|
|
3574
|
+
for (const t of rProg.recentTools.slice(-3)) {
|
|
3575
|
+
const maxArgsLen = Math.max(40, w - 30);
|
|
3576
|
+
const argsPreview = renderToolArgsPreview(t.args, maxArgsLen, expanded);
|
|
3577
|
+
c.addChild(new Text(fit(theme.fg("dim", ` ${t.tool}: ${argsPreview}`)), 0, 0));
|
|
3578
|
+
}
|
|
3579
|
+
}
|
|
3580
|
+
for (const line of compactRecentOutputLines(rProg.recentOutput)) {
|
|
3581
|
+
c.addChild(new Text(fit(theme.fg("dim", ` ${line}`)), 0, 0));
|
|
3582
|
+
}
|
|
3583
|
+
}
|
|
3584
|
+
if (!rRunning) {
|
|
3585
|
+
for (const nestedLine of formatNestedWidgetLines(r.children, theme, w, true, r.progress?.lastActivityAt, 8)) {
|
|
3586
|
+
c.addChild(new Text(fit(` ${nestedLine}`), 0, 0));
|
|
3587
|
+
}
|
|
3588
|
+
}
|
|
3589
|
+
if (!rRunning && r.artifactPaths) {
|
|
3590
|
+
c.addChild(new Text(fit(theme.fg("dim", ` artifacts: ${shortenPath(r.artifactPaths.outputPath)}`)), 0, 0));
|
|
3591
|
+
}
|
|
3592
|
+
if (expanded && !rRunning) {
|
|
3593
|
+
for (const line of toolCallLines) {
|
|
3594
|
+
c.addChild(new Text(fit(theme.fg("muted", ` ${line}`)), 0, 0));
|
|
3595
|
+
}
|
|
3596
|
+
if (toolCallLines.length)
|
|
3597
|
+
c.addChild(new Spacer(1));
|
|
3598
|
+
}
|
|
3599
|
+
c.addChild(new Spacer(1));
|
|
3600
|
+
}
|
|
3601
|
+
if (d.artifacts) {
|
|
3602
|
+
c.addChild(new Spacer(1));
|
|
3603
|
+
c.addChild(new Text(fit(theme.fg("dim", `Artifacts dir: ${shortenPath(d.artifacts.dir)}`)), 0, 0));
|
|
3604
|
+
}
|
|
3605
|
+
return c;
|
|
3606
|
+
}
|
|
3607
|
+
//# sourceMappingURL=render.js.map
|