pi-subagents 0.79.2 → 0.81.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 +56 -0
- package/README.md +1 -1
- package/bundle/agents.js +18 -0
- package/bundle/background-work.js +16 -0
- package/bundle/capability-ceiling.js +22 -0
- package/bundle/child-tool-plan.js +11 -0
- package/bundle/chunk-26C3WLYQ.js +8388 -0
- package/bundle/chunk-2XYWN7QJ.js +128 -0
- package/bundle/chunk-2ZSNH26H.js +4164 -0
- package/bundle/chunk-3DC5KBVP.js +235 -0
- package/bundle/chunk-3IF2PGW7.js +380 -0
- package/bundle/chunk-4QFZZV3O.js +57 -0
- package/bundle/chunk-563BHAZ5.js +1365 -0
- package/bundle/chunk-5LFLVSTM.js +260 -0
- package/bundle/chunk-62OCY2S4.js +14 -0
- package/bundle/chunk-74RT5YQE.js +326 -0
- package/bundle/chunk-7F6RKT6W.js +132 -0
- package/bundle/chunk-7J4ZXMY7.js +18 -0
- package/bundle/chunk-ARRKBB2B.js +179 -0
- package/bundle/chunk-BJN5LUQY.js +458 -0
- package/bundle/chunk-BPS2AGBZ.js +5421 -0
- package/bundle/chunk-CEKS3TFO.js +1337 -0
- package/bundle/chunk-CTPAE36Y.js +94 -0
- package/bundle/chunk-D4EHT5SJ.js +14 -0
- package/bundle/chunk-EYNJ6VL6.js +526 -0
- package/bundle/chunk-G5DKFLLI.js +1185 -0
- package/bundle/chunk-KSWQVGDW.js +1027 -0
- package/bundle/chunk-L5ZHE4L4.js +946 -0
- package/bundle/chunk-LSRUTHT7.js +57 -0
- package/bundle/chunk-N2BN7BF5.js +159 -0
- package/bundle/chunk-NF7IEKBH.js +490 -0
- package/bundle/chunk-NIXWDZZV.js +9 -0
- package/bundle/chunk-NNLASTQE.js +4082 -0
- package/bundle/chunk-TUWLXTAM.js +935 -0
- package/bundle/chunk-UKG4V45O.js +228 -0
- package/bundle/chunk-V2JWDB5U.js +753 -0
- package/bundle/chunk-V3BIUPLU.js +9163 -0
- package/bundle/chunk-V6MR5TOQ.js +270 -0
- package/bundle/chunk-VJHOELQP.js +8245 -0
- package/bundle/chunk-WSBNENFS.js +732 -0
- package/bundle/chunk-XMFLCKMQ.js +16664 -0
- package/bundle/chunk-YFCK7H2S.js +129 -0
- package/bundle/chunk-YYREO77V.js +137 -0
- package/bundle/chunk-Z7KVHQHL.js +173 -0
- package/bundle/chunk-ZBC44JJ3.js +8606 -0
- package/bundle/chunk-ZP3HODFH.js +175 -0
- package/bundle/control-channel.js +11 -0
- package/bundle/delegation.js +14 -0
- package/bundle/external-job-provider.js +20 -0
- package/bundle/external-runs.js +21 -0
- package/bundle/index.js +30 -0
- package/bundle/inspectors.js +8 -0
- package/bundle/intercom-bridge.js +11 -0
- package/bundle/preflight.js +425 -0
- package/bundle/project-panes.js +28 -0
- package/bundle/required-child-extensions.js +6 -0
- package/bundle/shared-types.js +8 -0
- package/bundle/workflow-resources.js +7 -0
- package/docs/agents.md +1 -1
- package/docs/configuration.md +15 -5
- package/docs/extension-api.md +29 -2
- package/docs/observability.md +6 -2
- package/docs/standalone-background.md +3 -3
- package/docs/workflows.md +1 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/package.json +19 -19
- package/src/agents/advertised-agent-prompt.d.ts +0 -1
- package/src/agents/advertised-agent-prompt.js +0 -1
- package/src/agents/agent-management.d.ts +0 -1
- package/src/agents/agent-management.js +0 -1
- package/src/agents/agent-memory.d.ts +0 -1
- package/src/agents/agent-memory.js +0 -1
- package/src/agents/agent-refinements.d.ts +0 -1
- package/src/agents/agent-refinements.js +0 -1
- package/src/agents/agent-scope.d.ts +0 -1
- package/src/agents/agent-scope.js +0 -1
- package/src/agents/agent-selection.d.ts +0 -1
- package/src/agents/agent-selection.js +0 -1
- package/src/agents/agent-serializer.d.ts +0 -1
- package/src/agents/agent-serializer.js +0 -1
- package/src/agents/agents.d.ts +0 -1
- package/src/agents/agents.js +0 -1
- package/src/agents/builtin-names.d.ts +0 -1
- package/src/agents/builtin-names.js +0 -1
- package/src/agents/chain-serializer.d.ts +0 -1
- package/src/agents/chain-serializer.js +0 -1
- package/src/agents/frontmatter.d.ts +2 -1
- package/src/agents/frontmatter.js +9 -3
- package/src/agents/global-npm-root.d.ts +0 -1
- package/src/agents/global-npm-root.js +0 -1
- package/src/agents/identity.d.ts +0 -1
- package/src/agents/identity.js +0 -1
- package/src/agents/proactive-skills.d.ts +0 -1
- package/src/agents/proactive-skills.js +0 -1
- package/src/agents/runtime-agent-events.d.ts +0 -1
- package/src/agents/runtime-agent-events.js +0 -1
- package/src/agents/runtime-agent-registry.d.ts +0 -1
- package/src/agents/runtime-agent-registry.js +0 -1
- package/src/agents/skills.d.ts +0 -1
- package/src/agents/skills.js +0 -1
- package/src/api/agents.d.ts +0 -1
- package/src/api/agents.js +0 -1
- package/src/api/background-work.d.ts +0 -1
- package/src/api/background-work.js +0 -1
- package/src/api/capability-ceiling.d.ts +0 -1
- package/src/api/capability-ceiling.js +0 -1
- package/src/api/child-tool-plan.d.ts +0 -1
- package/src/api/child-tool-plan.js +0 -1
- package/src/api/control-channel.d.ts +0 -1
- package/src/api/control-channel.js +0 -1
- package/src/api/delegation.d.ts +20 -1
- package/src/api/delegation.js +0 -1
- package/src/api/external-job-provider.d.ts +0 -1
- package/src/api/external-job-provider.js +0 -1
- package/src/api/external-runs.d.ts +0 -1
- package/src/api/external-runs.js +0 -1
- package/src/api/inspectors.d.ts +0 -1
- package/src/api/inspectors.js +0 -1
- package/src/api/intercom-bridge.d.ts +0 -1
- package/src/api/intercom-bridge.js +0 -1
- package/src/api/preflight.d.ts +0 -1
- package/src/api/preflight.js +0 -1
- package/src/api/project-panes.d.ts +0 -1
- package/src/api/project-panes.js +0 -1
- package/src/api/required-child-extensions.d.ts +0 -1
- package/src/api/required-child-extensions.js +0 -1
- package/src/api/shared-types.d.ts +0 -1
- package/src/api/shared-types.js +0 -1
- package/src/api/workflow-resources.d.ts +0 -1
- package/src/api/workflow-resources.js +0 -1
- package/src/extension/active-runs-prompt.d.ts +0 -1
- package/src/extension/active-runs-prompt.js +0 -1
- package/src/extension/config.d.ts +0 -1
- package/src/extension/config.js +3 -1
- package/src/extension/control-notices.d.ts +0 -1
- package/src/extension/control-notices.js +0 -1
- package/src/extension/declaration-pinning.d.ts +0 -1
- package/src/extension/declaration-pinning.js +0 -1
- package/src/extension/doctor.d.ts +0 -1
- package/src/extension/doctor.js +0 -1
- package/src/extension/fanout-child.d.ts +0 -1
- package/src/extension/fanout-child.js +0 -1
- package/src/extension/herdr-pi-bridge.d.ts +0 -1
- package/src/extension/herdr-pi-bridge.js +0 -1
- package/src/extension/index.d.ts +0 -1
- package/src/extension/index.js +40 -18
- package/src/extension/public-execution.d.ts +0 -1
- package/src/extension/public-execution.js +0 -1
- package/src/extension/reply-workflow-script.d.ts +0 -1
- package/src/extension/reply-workflow-script.js +0 -1
- package/src/extension/rpc.d.ts +0 -1
- package/src/extension/rpc.js +0 -1
- package/src/extension/schemas.d.ts +0 -1
- package/src/extension/schemas.js +3 -4
- package/src/extension/steering-notices.d.ts +0 -1
- package/src/extension/steering-notices.js +0 -1
- package/src/extension/subagent-guide.d.ts +0 -1
- package/src/extension/subagent-guide.js +0 -1
- package/src/extension/subagent-options.d.ts +0 -1
- package/src/extension/subagent-options.js +0 -1
- package/src/extension/tool-activation.d.ts +0 -1
- package/src/extension/tool-activation.js +0 -9
- package/src/extension/tool-description.d.ts +0 -1
- package/src/extension/tool-description.js +2 -3
- package/src/extension/tool-result.d.ts +0 -1
- package/src/extension/tool-result.js +0 -1
- package/src/extension/upgrade-notice.d.ts +0 -1
- package/src/extension/upgrade-notice.js +0 -1
- package/src/inspectors/actions.d.ts +0 -1
- package/src/inspectors/actions.js +0 -1
- package/src/inspectors/ghostty/actions.d.ts +0 -1
- package/src/inspectors/ghostty/actions.js +0 -1
- package/src/inspectors/ghostty/plugin.d.ts +0 -1
- package/src/inspectors/ghostty/plugin.js +0 -1
- package/src/inspectors/herdr/actions.d.ts +0 -1
- package/src/inspectors/herdr/actions.js +0 -1
- package/src/inspectors/herdr/client.d.ts +0 -1
- package/src/inspectors/herdr/client.js +0 -1
- package/src/inspectors/herdr/focus.d.ts +0 -1
- package/src/inspectors/herdr/focus.js +0 -1
- package/src/inspectors/herdr/plugin.d.ts +0 -1
- package/src/inspectors/herdr/plugin.js +0 -1
- package/src/inspectors/herdr/project-panes.d.ts +0 -1
- package/src/inspectors/herdr/project-panes.js +0 -1
- package/src/inspectors/inspector-runner.d.ts +0 -1
- package/src/inspectors/inspector-runner.js +0 -1
- package/src/inspectors/plugins.d.ts +0 -1
- package/src/inspectors/plugins.js +0 -1
- package/src/inspectors/session-roots-codec.d.ts +0 -1
- package/src/inspectors/session-roots-codec.js +0 -1
- package/src/inspectors/shell-command.d.ts +0 -1
- package/src/inspectors/shell-command.js +0 -1
- package/src/inspectors/tmux/actions.d.ts +0 -1
- package/src/inspectors/tmux/actions.js +0 -1
- package/src/inspectors/tmux/client.d.ts +0 -1
- package/src/inspectors/tmux/client.js +0 -1
- package/src/inspectors/tmux/plugin.d.ts +0 -1
- package/src/inspectors/tmux/plugin.js +0 -1
- package/src/inspectors/types.d.ts +0 -1
- package/src/inspectors/types.js +0 -1
- package/src/integrations/herdr-status.d.ts +0 -1
- package/src/integrations/herdr-status.js +0 -1
- package/src/integrations/pi-web-session-liveness.d.ts +0 -1
- package/src/integrations/pi-web-session-liveness.js +0 -1
- package/src/integrations/program-status.d.ts +0 -1
- package/src/integrations/program-status.js +0 -1
- package/src/intercom/intercom-bridge.d.ts +0 -1
- package/src/intercom/intercom-bridge.js +0 -1
- package/src/intercom/native-supervisor-channel.d.ts +0 -1
- package/src/intercom/native-supervisor-channel.js +1 -2
- package/src/intercom/result-intercom.d.ts +0 -1
- package/src/intercom/result-intercom.js +0 -1
- package/src/intercom/supervisor-ui.d.ts +0 -1
- package/src/intercom/supervisor-ui.js +0 -1
- package/src/missions/actions.d.ts +0 -1
- package/src/missions/actions.js +0 -1
- package/src/missions/goal-driver.d.ts +0 -1
- package/src/missions/goal-driver.js +0 -1
- package/src/missions/lifecycle.d.ts +0 -1
- package/src/missions/lifecycle.js +0 -1
- package/src/missions/store.d.ts +0 -1
- package/src/missions/store.js +0 -1
- package/src/missions/types.d.ts +0 -1
- package/src/missions/types.js +0 -1
- package/src/missions/workflow-state.d.ts +0 -1
- package/src/missions/workflow-state.js +0 -1
- package/src/policy/authority.d.ts +0 -1
- package/src/policy/authority.js +0 -1
- package/src/profiles/profiles.d.ts +0 -1
- package/src/profiles/profiles.js +0 -1
- package/src/runs/background/active-async-capacity.d.ts +0 -1
- package/src/runs/background/active-async-capacity.js +0 -1
- package/src/runs/background/active-run-index.d.ts +0 -1
- package/src/runs/background/active-run-index.js +0 -1
- package/src/runs/background/async-execution.d.ts +0 -1
- package/src/runs/background/async-execution.js +0 -1
- package/src/runs/background/async-job-tracker.d.ts +0 -1
- package/src/runs/background/async-job-tracker.js +0 -1
- package/src/runs/background/async-resume.d.ts +0 -1
- package/src/runs/background/async-resume.js +0 -1
- package/src/runs/background/async-retention.d.ts +0 -1
- package/src/runs/background/async-retention.js +0 -1
- package/src/runs/background/async-status-snapshot.d.ts +0 -1
- package/src/runs/background/async-status-snapshot.js +0 -1
- package/src/runs/background/async-status.d.ts +0 -1
- package/src/runs/background/async-status.js +0 -1
- package/src/runs/background/auto-drain.d.ts +0 -1
- package/src/runs/background/auto-drain.js +0 -1
- package/src/runs/background/await-async-run.d.ts +0 -1
- package/src/runs/background/await-async-run.js +0 -1
- package/src/runs/background/binary-bootstrap.d.ts +0 -1
- package/src/runs/background/binary-bootstrap.js +0 -1
- package/src/runs/background/calendar-schedule.d.ts +0 -1
- package/src/runs/background/calendar-schedule.js +0 -1
- package/src/runs/background/chain-append.d.ts +0 -1
- package/src/runs/background/chain-append.js +0 -1
- package/src/runs/background/chain-root-attachment.d.ts +0 -1
- package/src/runs/background/chain-root-attachment.js +0 -1
- package/src/runs/background/completion-batcher.d.ts +0 -1
- package/src/runs/background/completion-batcher.js +0 -1
- package/src/runs/background/completion-dedupe.d.ts +0 -1
- package/src/runs/background/completion-dedupe.js +0 -1
- package/src/runs/background/completion-replay.d.ts +0 -1
- package/src/runs/background/completion-replay.js +0 -1
- package/src/runs/background/control-channel.d.ts +0 -1
- package/src/runs/background/control-channel.js +0 -1
- package/src/runs/background/fleet-view.d.ts +0 -1
- package/src/runs/background/fleet-view.js +0 -1
- package/src/runs/background/index-segment.d.ts +0 -1
- package/src/runs/background/index-segment.js +0 -1
- package/src/runs/background/inspect-rpc.d.ts +0 -1
- package/src/runs/background/inspect-rpc.js +0 -1
- package/src/runs/background/notify.d.ts +1 -2
- package/src/runs/background/notify.js +3 -4
- package/src/runs/background/owned-process-tree.d.ts +0 -1
- package/src/runs/background/owned-process-tree.js +0 -1
- package/src/runs/background/parallel-groups.d.ts +0 -1
- package/src/runs/background/parallel-groups.js +0 -1
- package/src/runs/background/pid-namespace.d.ts +0 -1
- package/src/runs/background/pid-namespace.js +0 -1
- package/src/runs/background/process-terminal-candidate.d.ts +0 -1
- package/src/runs/background/process-terminal-candidate.js +0 -1
- package/src/runs/background/process-terminal.d.ts +0 -1
- package/src/runs/background/process-terminal.js +0 -1
- package/src/runs/background/result-delivery-ownership.d.ts +0 -1
- package/src/runs/background/result-delivery-ownership.js +0 -1
- package/src/runs/background/result-files.d.ts +0 -1
- package/src/runs/background/result-files.js +0 -1
- package/src/runs/background/result-watcher.d.ts +0 -1
- package/src/runs/background/result-watcher.js +0 -1
- package/src/runs/background/resume-guidance.d.ts +0 -1
- package/src/runs/background/resume-guidance.js +0 -1
- package/src/runs/background/retained-children.d.ts +0 -1
- package/src/runs/background/retained-children.js +0 -1
- package/src/runs/background/retained-nested-route-tracker.d.ts +0 -1
- package/src/runs/background/retained-nested-route-tracker.js +0 -1
- package/src/runs/background/run-child-session.d.ts +0 -1
- package/src/runs/background/run-child-session.js +18 -1
- package/src/runs/background/run-id-query.d.ts +0 -1
- package/src/runs/background/run-id-query.js +0 -1
- package/src/runs/background/run-id-resolver.d.ts +0 -1
- package/src/runs/background/run-id-resolver.js +0 -1
- package/src/runs/background/run-status.d.ts +0 -1
- package/src/runs/background/run-status.js +0 -1
- package/src/runs/background/runner-aliases.d.ts +0 -1
- package/src/runs/background/runner-aliases.js +0 -1
- package/src/runs/background/runner-child-launch.d.ts +0 -1
- package/src/runs/background/runner-child-launch.js +0 -1
- package/src/runs/background/runner-child-sessions.d.ts +0 -1
- package/src/runs/background/runner-child-sessions.js +0 -1
- package/src/runs/background/runner-http-dispatcher.d.ts +0 -1
- package/src/runs/background/runner-http-dispatcher.js +0 -1
- package/src/runs/background/runner-startup-failure.d.ts +0 -1
- package/src/runs/background/runner-startup-failure.js +0 -1
- package/src/runs/background/scheduled-runs.d.ts +0 -1
- package/src/runs/background/scheduled-runs.js +0 -1
- package/src/runs/background/stale-run-reconciler.d.ts +0 -1
- package/src/runs/background/stale-run-reconciler.js +2 -1
- package/src/runs/background/steering.d.ts +0 -1
- package/src/runs/background/steering.js +0 -1
- package/src/runs/background/subagent-runner-bootstrap.d.ts +0 -1
- package/src/runs/background/subagent-runner-bootstrap.js +0 -1
- package/src/runs/background/subagent-runner.d.ts +0 -1
- package/src/runs/background/subagent-runner.js +0 -1
- package/src/runs/background/subagent-wait.d.ts +0 -1
- package/src/runs/background/subagent-wait.js +0 -1
- package/src/runs/background/terminal-run-index.d.ts +0 -1
- package/src/runs/background/terminal-run-index.js +0 -1
- package/src/runs/background/top-level-async.d.ts +0 -1
- package/src/runs/background/top-level-async.js +0 -1
- package/src/runs/background/wait-completions.d.ts +0 -1
- package/src/runs/background/wait-completions.js +0 -1
- package/src/runs/background/wait-config.d.ts +0 -1
- package/src/runs/background/wait-config.js +0 -1
- package/src/runs/background/wait-subscriptions.d.ts +0 -1
- package/src/runs/background/wait-subscriptions.js +4 -2
- package/src/runs/background/wait-tool.d.ts +0 -1
- package/src/runs/background/wait-tool.js +0 -1
- package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
- package/src/runs/background/workflow-terminal-proof.js +0 -1
- package/src/runs/foreground/async-dismiss-action.d.ts +0 -1
- package/src/runs/foreground/async-dismiss-action.js +0 -1
- package/src/runs/foreground/async-steering-action.d.ts +0 -1
- package/src/runs/foreground/async-steering-action.js +0 -1
- package/src/runs/foreground/async-stop-action.d.ts +0 -1
- package/src/runs/foreground/async-stop-action.js +0 -1
- package/src/runs/foreground/command-action.d.ts +0 -1
- package/src/runs/foreground/command-action.js +0 -1
- package/src/runs/foreground/execution.d.ts +0 -1
- package/src/runs/foreground/execution.js +39 -3
- package/src/runs/foreground/foreground-control.d.ts +0 -1
- package/src/runs/foreground/foreground-control.js +0 -1
- package/src/runs/foreground/foreground-history.d.ts +0 -1
- package/src/runs/foreground/foreground-history.js +0 -1
- package/src/runs/foreground/prompt-audit.d.ts +0 -1
- package/src/runs/foreground/prompt-audit.js +0 -1
- package/src/runs/foreground/subagent-executor.d.ts +0 -1
- package/src/runs/foreground/subagent-executor.js +6 -4
- package/src/runs/foreground/workflow-detach-reconcile.d.ts +0 -1
- package/src/runs/foreground/workflow-detach-reconcile.js +0 -1
- package/src/runs/foreground/workflow-foreground-steering.d.ts +0 -1
- package/src/runs/foreground/workflow-foreground-steering.js +0 -1
- package/src/runs/shared/abort-recovery.d.ts +0 -1
- package/src/runs/shared/abort-recovery.js +0 -1
- package/src/runs/shared/acceptance.d.ts +0 -1
- package/src/runs/shared/acceptance.js +0 -1
- package/src/runs/shared/agent-contract.d.ts +0 -1
- package/src/runs/shared/agent-contract.js +0 -1
- package/src/runs/shared/async-status-projection.d.ts +0 -1
- package/src/runs/shared/async-status-projection.js +0 -1
- package/src/runs/shared/background-process-options.d.ts +0 -1
- package/src/runs/shared/background-process-options.js +0 -1
- package/src/runs/shared/capability-ceiling.d.ts +0 -1
- package/src/runs/shared/capability-ceiling.js +0 -1
- package/src/runs/shared/chain-outputs.d.ts +0 -1
- package/src/runs/shared/chain-outputs.js +0 -1
- package/src/runs/shared/child-commands.d.ts +0 -1
- package/src/runs/shared/child-commands.js +2 -2
- package/src/runs/shared/child-hooks.d.ts +0 -1
- package/src/runs/shared/child-hooks.js +0 -1
- package/src/runs/shared/child-identity.d.ts +0 -1
- package/src/runs/shared/child-identity.js +0 -1
- package/src/runs/shared/child-launch-plan.d.ts +0 -1
- package/src/runs/shared/child-launch-plan.js +0 -1
- package/src/runs/shared/child-launch.d.ts +0 -1
- package/src/runs/shared/child-launch.js +0 -1
- package/src/runs/shared/child-lifecycle.d.ts +0 -1
- package/src/runs/shared/child-lifecycle.js +0 -1
- package/src/runs/shared/child-runtime-config.d.ts +0 -1
- package/src/runs/shared/child-runtime-config.js +0 -1
- package/src/runs/shared/child-session.d.ts +0 -1
- package/src/runs/shared/child-session.js +2 -3
- package/src/runs/shared/child-tool-plan.d.ts +0 -1
- package/src/runs/shared/child-tool-plan.js +0 -1
- package/src/runs/shared/claude-code-adapter.d.ts +0 -1
- package/src/runs/shared/claude-code-adapter.js +0 -1
- package/src/runs/shared/codex-exec-adapter.d.ts +0 -1
- package/src/runs/shared/codex-exec-adapter.js +0 -1
- package/src/runs/shared/context-mode.d.ts +0 -1
- package/src/runs/shared/context-mode.js +0 -1
- package/src/runs/shared/cursor-agent-adapter.d.ts +0 -1
- package/src/runs/shared/cursor-agent-adapter.js +0 -1
- package/src/runs/shared/dynamic-fanout.d.ts +0 -1
- package/src/runs/shared/dynamic-fanout.js +0 -1
- package/src/runs/shared/effective-system-prompt.d.ts +0 -1
- package/src/runs/shared/effective-system-prompt.js +0 -1
- package/src/runs/shared/extension-bindings.d.ts +0 -1
- package/src/runs/shared/extension-bindings.js +0 -1
- package/src/runs/shared/external-cli-contract.d.ts +0 -1
- package/src/runs/shared/external-cli-contract.js +0 -1
- package/src/runs/shared/external-cli-preflight.d.ts +0 -1
- package/src/runs/shared/external-cli-preflight.js +0 -1
- package/src/runs/shared/external-cli-runner.d.ts +0 -1
- package/src/runs/shared/external-cli-runner.js +0 -1
- package/src/runs/shared/external-job-bridge.d.ts +0 -1
- package/src/runs/shared/external-job-bridge.js +0 -1
- package/src/runs/shared/external-job-runner.d.ts +0 -1
- package/src/runs/shared/external-job-runner.js +0 -1
- package/src/runs/shared/fast-mode-extension.d.ts +0 -1
- package/src/runs/shared/fast-mode-extension.js +0 -1
- package/src/runs/shared/git-environment.d.ts +0 -1
- package/src/runs/shared/git-environment.js +0 -1
- package/src/runs/shared/herdr-connection.d.ts +0 -1
- package/src/runs/shared/herdr-connection.js +0 -1
- package/src/runs/shared/herdr-external-adapters.d.ts +0 -1
- package/src/runs/shared/herdr-external-adapters.js +0 -1
- package/src/runs/shared/herdr-machine.d.ts +0 -1
- package/src/runs/shared/herdr-machine.js +0 -1
- package/src/runs/shared/herdr-pi-protocol.d.ts +0 -1
- package/src/runs/shared/herdr-pi-protocol.js +0 -1
- package/src/runs/shared/herdr-placed-run.d.ts +0 -1
- package/src/runs/shared/herdr-placed-run.js +0 -1
- package/src/runs/shared/host-step-status.d.ts +0 -1
- package/src/runs/shared/host-step-status.js +0 -1
- package/src/runs/shared/lane-metadata.d.ts +0 -1
- package/src/runs/shared/lane-metadata.js +0 -1
- package/src/runs/shared/launch-cwd.d.ts +0 -1
- package/src/runs/shared/launch-cwd.js +0 -1
- package/src/runs/shared/long-running-guard.d.ts +0 -1
- package/src/runs/shared/long-running-guard.js +0 -1
- package/src/runs/shared/mcp-config-sources.d.ts +0 -1
- package/src/runs/shared/mcp-config-sources.js +0 -1
- package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +0 -1
- package/src/runs/shared/mcp-direct-tool-allowlist.js +0 -1
- package/src/runs/shared/mcp-direct-tool-grant.d.ts +0 -1
- package/src/runs/shared/mcp-direct-tool-grant.js +0 -1
- package/src/runs/shared/model-resolution-diagnostic.d.ts +0 -1
- package/src/runs/shared/model-resolution-diagnostic.js +0 -1
- package/src/runs/shared/model-resolution.d.ts +0 -1
- package/src/runs/shared/model-resolution.js +0 -1
- package/src/runs/shared/model-scope.d.ts +0 -1
- package/src/runs/shared/model-scope.js +0 -1
- package/src/runs/shared/mutation-evidence.d.ts +0 -1
- package/src/runs/shared/mutation-evidence.js +0 -1
- package/src/runs/shared/nested-events.d.ts +0 -1
- package/src/runs/shared/nested-events.js +0 -1
- package/src/runs/shared/nested-path.d.ts +0 -1
- package/src/runs/shared/nested-path.js +0 -1
- package/src/runs/shared/nested-render.d.ts +0 -1
- package/src/runs/shared/nested-render.js +0 -1
- package/src/runs/shared/orca-progress-tabs.d.ts +0 -1
- package/src/runs/shared/orca-progress-tabs.js +0 -1
- package/src/runs/shared/parallel-handoff.d.ts +0 -1
- package/src/runs/shared/parallel-handoff.js +0 -1
- package/src/runs/shared/parallel-utils.d.ts +0 -1
- package/src/runs/shared/parallel-utils.js +0 -1
- package/src/runs/shared/partial-output.d.ts +0 -1
- package/src/runs/shared/partial-output.js +0 -1
- package/src/runs/shared/permissions.d.ts +0 -1
- package/src/runs/shared/permissions.js +0 -1
- package/src/runs/shared/pi-spawn.d.ts +0 -1
- package/src/runs/shared/pi-spawn.js +0 -1
- package/src/runs/shared/process-signal.d.ts +0 -1
- package/src/runs/shared/process-signal.js +0 -1
- package/src/runs/shared/readonly-drain-observation.d.ts +0 -1
- package/src/runs/shared/readonly-drain-observation.js +0 -1
- package/src/runs/shared/run-fanout-budget.d.ts +0 -1
- package/src/runs/shared/run-fanout-budget.js +0 -1
- package/src/runs/shared/run-ownership.d.ts +0 -1
- package/src/runs/shared/run-ownership.js +0 -1
- package/src/runs/shared/runner-launcher.d.ts +0 -1
- package/src/runs/shared/runner-launcher.js +0 -1
- package/src/runs/shared/runtime-acknowledged-extensions.d.ts +0 -1
- package/src/runs/shared/runtime-acknowledged-extensions.js +0 -1
- package/src/runs/shared/session-lease.d.ts +0 -1
- package/src/runs/shared/session-lease.js +0 -1
- package/src/runs/shared/single-output.d.ts +0 -1
- package/src/runs/shared/single-output.js +0 -1
- package/src/runs/shared/spawn-budget.d.ts +0 -1
- package/src/runs/shared/spawn-budget.js +0 -1
- package/src/runs/shared/structured-output.d.ts +1 -1
- package/src/runs/shared/structured-output.js +1 -1
- package/src/runs/shared/subagent-control.d.ts +0 -1
- package/src/runs/shared/subagent-control.js +0 -1
- package/src/runs/shared/subagent-prompt-runtime.d.ts +0 -1
- package/src/runs/shared/subagent-prompt-runtime.js +2 -2
- package/src/runs/shared/tool-availability.d.ts +0 -1
- package/src/runs/shared/tool-availability.js +0 -1
- package/src/runs/shared/tool-budget.d.ts +0 -1
- package/src/runs/shared/tool-budget.js +0 -1
- package/src/runs/shared/tool-timeout.d.ts +0 -1
- package/src/runs/shared/tool-timeout.js +0 -1
- package/src/runs/shared/usage-budget.d.ts +0 -1
- package/src/runs/shared/usage-budget.js +0 -1
- package/src/runs/shared/usage-reconciliation.d.ts +0 -1
- package/src/runs/shared/usage-reconciliation.js +0 -1
- package/src/runs/shared/workflow-async-child-guidance.d.ts +0 -1
- package/src/runs/shared/workflow-async-child-guidance.js +0 -1
- package/src/runs/shared/workflow-graph.d.ts +0 -1
- package/src/runs/shared/workflow-graph.js +0 -1
- package/src/runs/shared/worktree-cleanup-apply.d.ts +0 -1
- package/src/runs/shared/worktree-cleanup-apply.js +0 -1
- package/src/runs/shared/worktree-cleanup-plan.d.ts +0 -1
- package/src/runs/shared/worktree-cleanup-plan.js +0 -1
- package/src/runs/shared/worktree-lock.d.ts +0 -1
- package/src/runs/shared/worktree-lock.js +0 -1
- package/src/runs/shared/worktree-setup-command.d.ts +0 -1
- package/src/runs/shared/worktree-setup-command.js +0 -1
- package/src/runs/shared/worktree.d.ts +0 -1
- package/src/runs/shared/worktree.js +0 -1
- package/src/shared/accessible-dir.d.ts +0 -1
- package/src/shared/accessible-dir.js +4 -2
- package/src/shared/agent-stream-options.d.ts +0 -1
- package/src/shared/agent-stream-options.js +0 -1
- package/src/shared/artifacts.d.ts +0 -1
- package/src/shared/artifacts.js +0 -1
- package/src/shared/atomic-json.d.ts +0 -1
- package/src/shared/atomic-json.js +0 -1
- package/src/shared/capacity-resilient-json.d.ts +0 -1
- package/src/shared/capacity-resilient-json.js +0 -1
- package/src/shared/child-cache-retention.d.ts +0 -1
- package/src/shared/child-cache-retention.js +0 -1
- package/src/shared/child-session-name.d.ts +0 -1
- package/src/shared/child-session-name.js +0 -1
- package/src/shared/child-transcript.d.ts +0 -1
- package/src/shared/child-transcript.js +0 -1
- package/src/shared/completion-owner.d.ts +0 -1
- package/src/shared/completion-owner.js +0 -1
- package/src/shared/disabled-features.d.ts +0 -1
- package/src/shared/disabled-features.js +0 -1
- package/src/shared/display-text.d.ts +0 -1
- package/src/shared/display-text.js +0 -1
- package/src/shared/edit-distance.d.ts +0 -1
- package/src/shared/edit-distance.js +0 -1
- package/src/shared/extension-context.d.ts +0 -1
- package/src/shared/extension-context.js +0 -1
- package/src/shared/file-coalescer.d.ts +0 -1
- package/src/shared/file-coalescer.js +0 -1
- package/src/shared/file-lease.d.ts +0 -1
- package/src/shared/file-lease.js +0 -1
- package/src/shared/file-system-retry.d.ts +0 -1
- package/src/shared/file-system-retry.js +0 -1
- package/src/shared/fork-context.d.ts +0 -1
- package/src/shared/fork-context.js +0 -1
- package/src/shared/fork-session-cwd.d.ts +0 -1
- package/src/shared/fork-session-cwd.js +0 -1
- package/src/shared/formatters.d.ts +0 -1
- package/src/shared/formatters.js +0 -1
- package/src/shared/jsonl-writer.d.ts +0 -1
- package/src/shared/jsonl-writer.js +0 -1
- package/src/shared/launch-contract.d.ts +0 -1
- package/src/shared/launch-contract.js +0 -1
- package/src/shared/model-info.d.ts +0 -1
- package/src/shared/model-info.js +0 -1
- package/src/shared/model-response-aliases.d.ts +0 -1
- package/src/shared/model-response-aliases.js +0 -1
- package/src/shared/node-executable.d.ts +0 -1
- package/src/shared/node-executable.js +0 -1
- package/src/shared/opencode-session-headers.d.ts +0 -1
- package/src/shared/opencode-session-headers.js +0 -1
- package/src/shared/package-version.d.ts +0 -1
- package/src/shared/package-version.js +0 -1
- package/src/shared/parent-wake.d.ts +9 -7
- package/src/shared/parent-wake.js +12 -15
- package/src/shared/prompt-resources.d.ts +0 -1
- package/src/shared/prompt-resources.js +0 -1
- package/src/shared/provider-diagnostics.d.ts +9 -0
- package/src/shared/provider-diagnostics.js +75 -0
- package/src/shared/pruned-fork.d.ts +0 -1
- package/src/shared/pruned-fork.js +0 -1
- package/src/shared/required-child-extensions.d.ts +0 -1
- package/src/shared/required-child-extensions.js +0 -1
- package/src/shared/runtime-module-path.d.ts +0 -1
- package/src/shared/runtime-module-path.js +0 -1
- package/src/shared/session-file-trust.d.ts +0 -1
- package/src/shared/session-file-trust.js +0 -1
- package/src/shared/session-identity.d.ts +0 -1
- package/src/shared/session-identity.js +0 -1
- package/src/shared/session-succession.d.ts +0 -1
- package/src/shared/session-succession.js +0 -1
- package/src/shared/session-tokens.d.ts +0 -1
- package/src/shared/session-tokens.js +0 -1
- package/src/shared/settings-file-lease.d.ts +0 -1
- package/src/shared/settings-file-lease.js +0 -1
- package/src/shared/settings.d.ts +0 -1
- package/src/shared/settings.js +0 -1
- package/src/shared/shortcuts.d.ts +0 -1
- package/src/shared/shortcuts.js +0 -1
- package/src/shared/status-format.d.ts +0 -1
- package/src/shared/status-format.js +0 -1
- package/src/shared/thinking-ceiling.d.ts +0 -1
- package/src/shared/thinking-ceiling.js +0 -1
- package/src/shared/types.d.ts +5 -1
- package/src/shared/types.js +0 -1
- package/src/shared/utf8.d.ts +0 -1
- package/src/shared/utf8.js +0 -1
- package/src/shared/utils.d.ts +0 -1
- package/src/shared/utils.js +0 -1
- package/src/shared/watch-strategy.d.ts +0 -1
- package/src/shared/watch-strategy.js +0 -1
- package/src/shared/workflow-child-permit.d.ts +0 -1
- package/src/shared/workflow-child-permit.js +0 -1
- package/src/slash/delegation-adapters.d.ts +3 -2
- package/src/slash/delegation-adapters.js +7 -1
- package/src/slash/delegation-json.d.ts +0 -1
- package/src/slash/delegation-json.js +0 -1
- package/src/slash/delegation-request.d.ts +0 -1
- package/src/slash/delegation-request.js +0 -1
- package/src/slash/prompt-template-bridge.d.ts +0 -1
- package/src/slash/prompt-template-bridge.js +3 -2
- package/src/slash/prompt-workflows.d.ts +0 -1
- package/src/slash/prompt-workflows.js +0 -1
- package/src/slash/selector.d.ts +0 -1
- package/src/slash/selector.js +0 -1
- package/src/slash/slash-bridge.d.ts +0 -1
- package/src/slash/slash-bridge.js +0 -1
- package/src/slash/slash-commands.d.ts +0 -1
- package/src/slash/slash-commands.js +1 -2
- package/src/slash/slash-live-state.d.ts +0 -1
- package/src/slash/slash-live-state.js +0 -1
- package/src/slash/subagent-cost.d.ts +0 -1
- package/src/slash/subagent-cost.js +0 -1
- package/src/slash/subagents-admin.d.ts +1 -1
- package/src/slash/subagents-admin.js +1 -2
- package/src/tui/fleet-layout.d.ts +20 -0
- package/src/tui/fleet-layout.js +17 -0
- package/src/tui/fleet-status.d.ts +0 -1
- package/src/tui/fleet-status.js +0 -1
- package/src/tui/fleet-transcript.d.ts +0 -1
- package/src/tui/fleet-transcript.js +0 -1
- package/src/tui/fleet-viewport.d.ts +12 -0
- package/src/tui/fleet-viewport.js +35 -0
- package/src/tui/fleet.d.ts +5 -7
- package/src/tui/fleet.js +69 -52
- package/src/tui/render-helpers.d.ts +0 -1
- package/src/tui/render-helpers.js +0 -1
- package/src/tui/render.d.ts +0 -1
- package/src/tui/render.js +48 -18
- package/src/tui/running-tone.d.ts +0 -1
- package/src/tui/running-tone.js +0 -1
- package/src/tui/subagent-messages.d.ts +0 -1
- package/src/tui/subagent-messages.js +0 -1
- package/src/watchdog/change-signature.d.ts +0 -1
- package/src/watchdog/change-signature.js +0 -1
- package/src/watchdog/child-status.d.ts +0 -1
- package/src/watchdog/child-status.js +0 -1
- package/src/watchdog/diff-tool.d.ts +0 -1
- package/src/watchdog/diff-tool.js +9 -4
- package/src/watchdog/emission-guard.d.ts +0 -1
- package/src/watchdog/emission-guard.js +0 -1
- package/src/watchdog/guidance.d.ts +0 -1
- package/src/watchdog/guidance.js +0 -1
- package/src/watchdog/lsp-diagnostics.d.ts +0 -1
- package/src/watchdog/lsp-diagnostics.js +0 -1
- package/src/watchdog/model-selection.d.ts +0 -1
- package/src/watchdog/model-selection.js +0 -1
- package/src/watchdog/permission-arbiter.d.ts +0 -1
- package/src/watchdog/permission-arbiter.js +0 -1
- package/src/watchdog/register-child.d.ts +0 -1
- package/src/watchdog/register-child.js +0 -1
- package/src/watchdog/register-main.d.ts +2 -1
- package/src/watchdog/register-main.js +8 -8
- package/src/watchdog/render.d.ts +0 -1
- package/src/watchdog/render.js +0 -1
- package/src/watchdog/review.d.ts +0 -1
- package/src/watchdog/review.js +0 -1
- package/src/watchdog/rules.d.ts +0 -1
- package/src/watchdog/rules.js +0 -1
- package/src/watchdog/runtime.d.ts +0 -1
- package/src/watchdog/runtime.js +0 -1
- package/src/watchdog/scope.d.ts +0 -1
- package/src/watchdog/scope.js +0 -1
- package/src/watchdog/settings.d.ts +0 -1
- package/src/watchdog/settings.js +0 -1
- package/src/watchdog/tool-actions.d.ts +0 -1
- package/src/watchdog/tool-actions.js +0 -1
- package/src/watchdog/turn-delta.d.ts +0 -1
- package/src/watchdog/turn-delta.js +0 -1
- package/src/watchdog/types.d.ts +0 -1
- package/src/watchdog/types.js +0 -1
- package/src/watchdog/warning-format.d.ts +0 -1
- package/src/watchdog/warning-format.js +0 -1
- package/src/workflows/chat-progress.d.ts +0 -1
- package/src/workflows/chat-progress.js +0 -1
- package/src/workflows/host-command.d.ts +0 -1
- package/src/workflows/host-command.js +0 -1
- package/src/workflows/scripted-workflow.d.ts +0 -1
- package/src/workflows/scripted-workflow.js +0 -1
- package/src/workflows/structured-workflow-scripts.d.ts +1 -1
- package/src/workflows/structured-workflow-scripts.js +22 -9
- package/src/workflows/workflow-checklist.d.ts +0 -1
- package/src/workflows/workflow-checklist.js +0 -1
- package/src/workflows/workflow-child-summary.d.ts +0 -1
- package/src/workflows/workflow-child-summary.js +0 -1
- package/src/workflows/workflow-preflight.d.ts +0 -1
- package/src/workflows/workflow-preflight.js +0 -1
- package/src/workflows/workflow-receipt.d.ts +0 -1
- package/src/workflows/workflow-receipt.js +0 -1
- package/src/workflows/workflow-resources.d.ts +0 -1
- package/src/workflows/workflow-resources.js +2 -3
- package/src/workflows/workflow-reuse.d.ts +0 -1
- package/src/workflows/workflow-reuse.js +0 -1
- package/src/workflows/workflow-revival.d.ts +0 -1
- package/src/workflows/workflow-revival.js +0 -1
- package/src/workflows/workflow-settlement.d.ts +0 -1
- package/src/workflows/workflow-settlement.js +0 -1
- package/index.d.ts.map +0 -1
- package/index.js.map +0 -1
- package/src/agents/advertised-agent-prompt.d.ts.map +0 -1
- package/src/agents/advertised-agent-prompt.js.map +0 -1
- package/src/agents/agent-management.d.ts.map +0 -1
- package/src/agents/agent-management.js.map +0 -1
- package/src/agents/agent-memory.d.ts.map +0 -1
- package/src/agents/agent-memory.js.map +0 -1
- package/src/agents/agent-refinements.d.ts.map +0 -1
- package/src/agents/agent-refinements.js.map +0 -1
- package/src/agents/agent-scope.d.ts.map +0 -1
- package/src/agents/agent-scope.js.map +0 -1
- package/src/agents/agent-selection.d.ts.map +0 -1
- package/src/agents/agent-selection.js.map +0 -1
- package/src/agents/agent-serializer.d.ts.map +0 -1
- package/src/agents/agent-serializer.js.map +0 -1
- package/src/agents/agents.d.ts.map +0 -1
- package/src/agents/agents.js.map +0 -1
- package/src/agents/builtin-names.d.ts.map +0 -1
- package/src/agents/builtin-names.js.map +0 -1
- package/src/agents/chain-serializer.d.ts.map +0 -1
- package/src/agents/chain-serializer.js.map +0 -1
- package/src/agents/frontmatter.d.ts.map +0 -1
- package/src/agents/frontmatter.js.map +0 -1
- package/src/agents/global-npm-root.d.ts.map +0 -1
- package/src/agents/global-npm-root.js.map +0 -1
- package/src/agents/identity.d.ts.map +0 -1
- package/src/agents/identity.js.map +0 -1
- package/src/agents/proactive-skills.d.ts.map +0 -1
- package/src/agents/proactive-skills.js.map +0 -1
- package/src/agents/runtime-agent-events.d.ts.map +0 -1
- package/src/agents/runtime-agent-events.js.map +0 -1
- package/src/agents/runtime-agent-registry.d.ts.map +0 -1
- package/src/agents/runtime-agent-registry.js.map +0 -1
- package/src/agents/skills.d.ts.map +0 -1
- package/src/agents/skills.js.map +0 -1
- package/src/api/agents.d.ts.map +0 -1
- package/src/api/agents.js.map +0 -1
- package/src/api/background-work.d.ts.map +0 -1
- package/src/api/background-work.js.map +0 -1
- package/src/api/capability-ceiling.d.ts.map +0 -1
- package/src/api/capability-ceiling.js.map +0 -1
- package/src/api/child-tool-plan.d.ts.map +0 -1
- package/src/api/child-tool-plan.js.map +0 -1
- package/src/api/control-channel.d.ts.map +0 -1
- package/src/api/control-channel.js.map +0 -1
- package/src/api/delegation.d.ts.map +0 -1
- package/src/api/delegation.js.map +0 -1
- package/src/api/external-job-provider.d.ts.map +0 -1
- package/src/api/external-job-provider.js.map +0 -1
- package/src/api/external-runs.d.ts.map +0 -1
- package/src/api/external-runs.js.map +0 -1
- package/src/api/inspectors.d.ts.map +0 -1
- package/src/api/inspectors.js.map +0 -1
- package/src/api/intercom-bridge.d.ts.map +0 -1
- package/src/api/intercom-bridge.js.map +0 -1
- package/src/api/preflight.d.ts.map +0 -1
- package/src/api/preflight.js.map +0 -1
- package/src/api/project-panes.d.ts.map +0 -1
- package/src/api/project-panes.js.map +0 -1
- package/src/api/required-child-extensions.d.ts.map +0 -1
- package/src/api/required-child-extensions.js.map +0 -1
- package/src/api/shared-types.d.ts.map +0 -1
- package/src/api/shared-types.js.map +0 -1
- package/src/api/workflow-resources.d.ts.map +0 -1
- package/src/api/workflow-resources.js.map +0 -1
- package/src/extension/active-runs-prompt.d.ts.map +0 -1
- package/src/extension/active-runs-prompt.js.map +0 -1
- package/src/extension/config.d.ts.map +0 -1
- package/src/extension/config.js.map +0 -1
- package/src/extension/control-notices.d.ts.map +0 -1
- package/src/extension/control-notices.js.map +0 -1
- package/src/extension/declaration-pinning.d.ts.map +0 -1
- package/src/extension/declaration-pinning.js.map +0 -1
- package/src/extension/doctor.d.ts.map +0 -1
- package/src/extension/doctor.js.map +0 -1
- package/src/extension/fanout-child.d.ts.map +0 -1
- package/src/extension/fanout-child.js.map +0 -1
- package/src/extension/herdr-pi-bridge.d.ts.map +0 -1
- package/src/extension/herdr-pi-bridge.js.map +0 -1
- package/src/extension/index.d.ts.map +0 -1
- package/src/extension/index.js.map +0 -1
- package/src/extension/public-execution.d.ts.map +0 -1
- package/src/extension/public-execution.js.map +0 -1
- package/src/extension/reply-workflow-script.d.ts.map +0 -1
- package/src/extension/reply-workflow-script.js.map +0 -1
- package/src/extension/rpc.d.ts.map +0 -1
- package/src/extension/rpc.js.map +0 -1
- package/src/extension/schemas.d.ts.map +0 -1
- package/src/extension/schemas.js.map +0 -1
- package/src/extension/steering-notices.d.ts.map +0 -1
- package/src/extension/steering-notices.js.map +0 -1
- package/src/extension/subagent-guide.d.ts.map +0 -1
- package/src/extension/subagent-guide.js.map +0 -1
- package/src/extension/subagent-options.d.ts.map +0 -1
- package/src/extension/subagent-options.js.map +0 -1
- package/src/extension/tool-activation.d.ts.map +0 -1
- package/src/extension/tool-activation.js.map +0 -1
- package/src/extension/tool-description.d.ts.map +0 -1
- package/src/extension/tool-description.js.map +0 -1
- package/src/extension/tool-result.d.ts.map +0 -1
- package/src/extension/tool-result.js.map +0 -1
- package/src/extension/upgrade-notice.d.ts.map +0 -1
- package/src/extension/upgrade-notice.js.map +0 -1
- package/src/inspectors/actions.d.ts.map +0 -1
- package/src/inspectors/actions.js.map +0 -1
- package/src/inspectors/ghostty/actions.d.ts.map +0 -1
- package/src/inspectors/ghostty/actions.js.map +0 -1
- package/src/inspectors/ghostty/plugin.d.ts.map +0 -1
- package/src/inspectors/ghostty/plugin.js.map +0 -1
- package/src/inspectors/herdr/actions.d.ts.map +0 -1
- package/src/inspectors/herdr/actions.js.map +0 -1
- package/src/inspectors/herdr/client.d.ts.map +0 -1
- package/src/inspectors/herdr/client.js.map +0 -1
- package/src/inspectors/herdr/focus.d.ts.map +0 -1
- package/src/inspectors/herdr/focus.js.map +0 -1
- package/src/inspectors/herdr/plugin.d.ts.map +0 -1
- package/src/inspectors/herdr/plugin.js.map +0 -1
- package/src/inspectors/herdr/project-panes.d.ts.map +0 -1
- package/src/inspectors/herdr/project-panes.js.map +0 -1
- package/src/inspectors/inspector-runner.d.ts.map +0 -1
- package/src/inspectors/inspector-runner.js.map +0 -1
- package/src/inspectors/plugins.d.ts.map +0 -1
- package/src/inspectors/plugins.js.map +0 -1
- package/src/inspectors/session-roots-codec.d.ts.map +0 -1
- package/src/inspectors/session-roots-codec.js.map +0 -1
- package/src/inspectors/shell-command.d.ts.map +0 -1
- package/src/inspectors/shell-command.js.map +0 -1
- package/src/inspectors/tmux/actions.d.ts.map +0 -1
- package/src/inspectors/tmux/actions.js.map +0 -1
- package/src/inspectors/tmux/client.d.ts.map +0 -1
- package/src/inspectors/tmux/client.js.map +0 -1
- package/src/inspectors/tmux/plugin.d.ts.map +0 -1
- package/src/inspectors/tmux/plugin.js.map +0 -1
- package/src/inspectors/types.d.ts.map +0 -1
- package/src/inspectors/types.js.map +0 -1
- package/src/integrations/herdr-status.d.ts.map +0 -1
- package/src/integrations/herdr-status.js.map +0 -1
- package/src/integrations/pi-web-session-liveness.d.ts.map +0 -1
- package/src/integrations/pi-web-session-liveness.js.map +0 -1
- package/src/integrations/program-status.d.ts.map +0 -1
- package/src/integrations/program-status.js.map +0 -1
- package/src/intercom/intercom-bridge.d.ts.map +0 -1
- package/src/intercom/intercom-bridge.js.map +0 -1
- package/src/intercom/native-supervisor-channel.d.ts.map +0 -1
- package/src/intercom/native-supervisor-channel.js.map +0 -1
- package/src/intercom/result-intercom.d.ts.map +0 -1
- package/src/intercom/result-intercom.js.map +0 -1
- package/src/intercom/supervisor-ui.d.ts.map +0 -1
- package/src/intercom/supervisor-ui.js.map +0 -1
- package/src/missions/actions.d.ts.map +0 -1
- package/src/missions/actions.js.map +0 -1
- package/src/missions/goal-driver.d.ts.map +0 -1
- package/src/missions/goal-driver.js.map +0 -1
- package/src/missions/lifecycle.d.ts.map +0 -1
- package/src/missions/lifecycle.js.map +0 -1
- package/src/missions/store.d.ts.map +0 -1
- package/src/missions/store.js.map +0 -1
- package/src/missions/types.d.ts.map +0 -1
- package/src/missions/types.js.map +0 -1
- package/src/missions/workflow-state.d.ts.map +0 -1
- package/src/missions/workflow-state.js.map +0 -1
- package/src/policy/authority.d.ts.map +0 -1
- package/src/policy/authority.js.map +0 -1
- package/src/profiles/profiles.d.ts.map +0 -1
- package/src/profiles/profiles.js.map +0 -1
- package/src/runs/background/active-async-capacity.d.ts.map +0 -1
- package/src/runs/background/active-async-capacity.js.map +0 -1
- package/src/runs/background/active-run-index.d.ts.map +0 -1
- package/src/runs/background/active-run-index.js.map +0 -1
- package/src/runs/background/async-execution.d.ts.map +0 -1
- package/src/runs/background/async-execution.js.map +0 -1
- package/src/runs/background/async-job-tracker.d.ts.map +0 -1
- package/src/runs/background/async-job-tracker.js.map +0 -1
- package/src/runs/background/async-resume.d.ts.map +0 -1
- package/src/runs/background/async-resume.js.map +0 -1
- package/src/runs/background/async-retention.d.ts.map +0 -1
- package/src/runs/background/async-retention.js.map +0 -1
- package/src/runs/background/async-status-snapshot.d.ts.map +0 -1
- package/src/runs/background/async-status-snapshot.js.map +0 -1
- package/src/runs/background/async-status.d.ts.map +0 -1
- package/src/runs/background/async-status.js.map +0 -1
- package/src/runs/background/auto-drain.d.ts.map +0 -1
- package/src/runs/background/auto-drain.js.map +0 -1
- package/src/runs/background/await-async-run.d.ts.map +0 -1
- package/src/runs/background/await-async-run.js.map +0 -1
- package/src/runs/background/binary-bootstrap.d.ts.map +0 -1
- package/src/runs/background/binary-bootstrap.js.map +0 -1
- package/src/runs/background/calendar-schedule.d.ts.map +0 -1
- package/src/runs/background/calendar-schedule.js.map +0 -1
- package/src/runs/background/chain-append.d.ts.map +0 -1
- package/src/runs/background/chain-append.js.map +0 -1
- package/src/runs/background/chain-root-attachment.d.ts.map +0 -1
- package/src/runs/background/chain-root-attachment.js.map +0 -1
- package/src/runs/background/completion-batcher.d.ts.map +0 -1
- package/src/runs/background/completion-batcher.js.map +0 -1
- package/src/runs/background/completion-dedupe.d.ts.map +0 -1
- package/src/runs/background/completion-dedupe.js.map +0 -1
- package/src/runs/background/completion-replay.d.ts.map +0 -1
- package/src/runs/background/completion-replay.js.map +0 -1
- package/src/runs/background/control-channel.d.ts.map +0 -1
- package/src/runs/background/control-channel.js.map +0 -1
- package/src/runs/background/fleet-view.d.ts.map +0 -1
- package/src/runs/background/fleet-view.js.map +0 -1
- package/src/runs/background/index-segment.d.ts.map +0 -1
- package/src/runs/background/index-segment.js.map +0 -1
- package/src/runs/background/inspect-rpc.d.ts.map +0 -1
- package/src/runs/background/inspect-rpc.js.map +0 -1
- package/src/runs/background/notify.d.ts.map +0 -1
- package/src/runs/background/notify.js.map +0 -1
- package/src/runs/background/owned-process-tree.d.ts.map +0 -1
- package/src/runs/background/owned-process-tree.js.map +0 -1
- package/src/runs/background/parallel-groups.d.ts.map +0 -1
- package/src/runs/background/parallel-groups.js.map +0 -1
- package/src/runs/background/pid-namespace.d.ts.map +0 -1
- package/src/runs/background/pid-namespace.js.map +0 -1
- package/src/runs/background/process-terminal-candidate.d.ts.map +0 -1
- package/src/runs/background/process-terminal-candidate.js.map +0 -1
- package/src/runs/background/process-terminal.d.ts.map +0 -1
- package/src/runs/background/process-terminal.js.map +0 -1
- package/src/runs/background/result-delivery-ownership.d.ts.map +0 -1
- package/src/runs/background/result-delivery-ownership.js.map +0 -1
- package/src/runs/background/result-files.d.ts.map +0 -1
- package/src/runs/background/result-files.js.map +0 -1
- package/src/runs/background/result-watcher.d.ts.map +0 -1
- package/src/runs/background/result-watcher.js.map +0 -1
- package/src/runs/background/resume-guidance.d.ts.map +0 -1
- package/src/runs/background/resume-guidance.js.map +0 -1
- package/src/runs/background/retained-children.d.ts.map +0 -1
- package/src/runs/background/retained-children.js.map +0 -1
- package/src/runs/background/retained-nested-route-tracker.d.ts.map +0 -1
- package/src/runs/background/retained-nested-route-tracker.js.map +0 -1
- package/src/runs/background/run-child-session.d.ts.map +0 -1
- package/src/runs/background/run-child-session.js.map +0 -1
- package/src/runs/background/run-id-query.d.ts.map +0 -1
- package/src/runs/background/run-id-query.js.map +0 -1
- package/src/runs/background/run-id-resolver.d.ts.map +0 -1
- package/src/runs/background/run-id-resolver.js.map +0 -1
- package/src/runs/background/run-status.d.ts.map +0 -1
- package/src/runs/background/run-status.js.map +0 -1
- package/src/runs/background/runner-aliases.d.ts.map +0 -1
- package/src/runs/background/runner-aliases.js.map +0 -1
- package/src/runs/background/runner-child-launch.d.ts.map +0 -1
- package/src/runs/background/runner-child-launch.js.map +0 -1
- package/src/runs/background/runner-child-sessions.d.ts.map +0 -1
- package/src/runs/background/runner-child-sessions.js.map +0 -1
- package/src/runs/background/runner-http-dispatcher.d.ts.map +0 -1
- package/src/runs/background/runner-http-dispatcher.js.map +0 -1
- package/src/runs/background/runner-startup-failure.d.ts.map +0 -1
- package/src/runs/background/runner-startup-failure.js.map +0 -1
- package/src/runs/background/scheduled-runs.d.ts.map +0 -1
- package/src/runs/background/scheduled-runs.js.map +0 -1
- package/src/runs/background/stale-run-reconciler.d.ts.map +0 -1
- package/src/runs/background/stale-run-reconciler.js.map +0 -1
- package/src/runs/background/steering.d.ts.map +0 -1
- package/src/runs/background/steering.js.map +0 -1
- package/src/runs/background/subagent-runner-bootstrap.d.ts.map +0 -1
- package/src/runs/background/subagent-runner-bootstrap.js.map +0 -1
- package/src/runs/background/subagent-runner.d.ts.map +0 -1
- package/src/runs/background/subagent-runner.js.map +0 -1
- package/src/runs/background/subagent-wait.d.ts.map +0 -1
- package/src/runs/background/subagent-wait.js.map +0 -1
- package/src/runs/background/terminal-run-index.d.ts.map +0 -1
- package/src/runs/background/terminal-run-index.js.map +0 -1
- package/src/runs/background/top-level-async.d.ts.map +0 -1
- package/src/runs/background/top-level-async.js.map +0 -1
- package/src/runs/background/wait-completions.d.ts.map +0 -1
- package/src/runs/background/wait-completions.js.map +0 -1
- package/src/runs/background/wait-config.d.ts.map +0 -1
- package/src/runs/background/wait-config.js.map +0 -1
- package/src/runs/background/wait-subscriptions.d.ts.map +0 -1
- package/src/runs/background/wait-subscriptions.js.map +0 -1
- package/src/runs/background/wait-tool.d.ts.map +0 -1
- package/src/runs/background/wait-tool.js.map +0 -1
- package/src/runs/background/workflow-terminal-proof.d.ts.map +0 -1
- package/src/runs/background/workflow-terminal-proof.js.map +0 -1
- package/src/runs/foreground/async-dismiss-action.d.ts.map +0 -1
- package/src/runs/foreground/async-dismiss-action.js.map +0 -1
- package/src/runs/foreground/async-steering-action.d.ts.map +0 -1
- package/src/runs/foreground/async-steering-action.js.map +0 -1
- package/src/runs/foreground/async-stop-action.d.ts.map +0 -1
- package/src/runs/foreground/async-stop-action.js.map +0 -1
- package/src/runs/foreground/command-action.d.ts.map +0 -1
- package/src/runs/foreground/command-action.js.map +0 -1
- package/src/runs/foreground/execution.d.ts.map +0 -1
- package/src/runs/foreground/execution.js.map +0 -1
- package/src/runs/foreground/foreground-control.d.ts.map +0 -1
- package/src/runs/foreground/foreground-control.js.map +0 -1
- package/src/runs/foreground/foreground-history.d.ts.map +0 -1
- package/src/runs/foreground/foreground-history.js.map +0 -1
- package/src/runs/foreground/prompt-audit.d.ts.map +0 -1
- package/src/runs/foreground/prompt-audit.js.map +0 -1
- package/src/runs/foreground/subagent-executor.d.ts.map +0 -1
- package/src/runs/foreground/subagent-executor.js.map +0 -1
- package/src/runs/foreground/workflow-detach-reconcile.d.ts.map +0 -1
- package/src/runs/foreground/workflow-detach-reconcile.js.map +0 -1
- package/src/runs/foreground/workflow-foreground-steering.d.ts.map +0 -1
- package/src/runs/foreground/workflow-foreground-steering.js.map +0 -1
- package/src/runs/shared/abort-recovery.d.ts.map +0 -1
- package/src/runs/shared/abort-recovery.js.map +0 -1
- package/src/runs/shared/acceptance.d.ts.map +0 -1
- package/src/runs/shared/acceptance.js.map +0 -1
- package/src/runs/shared/agent-contract.d.ts.map +0 -1
- package/src/runs/shared/agent-contract.js.map +0 -1
- package/src/runs/shared/async-status-projection.d.ts.map +0 -1
- package/src/runs/shared/async-status-projection.js.map +0 -1
- package/src/runs/shared/background-process-options.d.ts.map +0 -1
- package/src/runs/shared/background-process-options.js.map +0 -1
- package/src/runs/shared/capability-ceiling.d.ts.map +0 -1
- package/src/runs/shared/capability-ceiling.js.map +0 -1
- package/src/runs/shared/chain-outputs.d.ts.map +0 -1
- package/src/runs/shared/chain-outputs.js.map +0 -1
- package/src/runs/shared/child-commands.d.ts.map +0 -1
- package/src/runs/shared/child-commands.js.map +0 -1
- package/src/runs/shared/child-hooks.d.ts.map +0 -1
- package/src/runs/shared/child-hooks.js.map +0 -1
- package/src/runs/shared/child-identity.d.ts.map +0 -1
- package/src/runs/shared/child-identity.js.map +0 -1
- package/src/runs/shared/child-launch-plan.d.ts.map +0 -1
- package/src/runs/shared/child-launch-plan.js.map +0 -1
- package/src/runs/shared/child-launch.d.ts.map +0 -1
- package/src/runs/shared/child-launch.js.map +0 -1
- package/src/runs/shared/child-lifecycle.d.ts.map +0 -1
- package/src/runs/shared/child-lifecycle.js.map +0 -1
- package/src/runs/shared/child-runtime-config.d.ts.map +0 -1
- package/src/runs/shared/child-runtime-config.js.map +0 -1
- package/src/runs/shared/child-session.d.ts.map +0 -1
- package/src/runs/shared/child-session.js.map +0 -1
- package/src/runs/shared/child-tool-plan.d.ts.map +0 -1
- package/src/runs/shared/child-tool-plan.js.map +0 -1
- package/src/runs/shared/claude-code-adapter.d.ts.map +0 -1
- package/src/runs/shared/claude-code-adapter.js.map +0 -1
- package/src/runs/shared/codex-exec-adapter.d.ts.map +0 -1
- package/src/runs/shared/codex-exec-adapter.js.map +0 -1
- package/src/runs/shared/context-mode.d.ts.map +0 -1
- package/src/runs/shared/context-mode.js.map +0 -1
- package/src/runs/shared/cursor-agent-adapter.d.ts.map +0 -1
- package/src/runs/shared/cursor-agent-adapter.js.map +0 -1
- package/src/runs/shared/dynamic-fanout.d.ts.map +0 -1
- package/src/runs/shared/dynamic-fanout.js.map +0 -1
- package/src/runs/shared/effective-system-prompt.d.ts.map +0 -1
- package/src/runs/shared/effective-system-prompt.js.map +0 -1
- package/src/runs/shared/extension-bindings.d.ts.map +0 -1
- package/src/runs/shared/extension-bindings.js.map +0 -1
- package/src/runs/shared/external-cli-contract.d.ts.map +0 -1
- package/src/runs/shared/external-cli-contract.js.map +0 -1
- package/src/runs/shared/external-cli-preflight.d.ts.map +0 -1
- package/src/runs/shared/external-cli-preflight.js.map +0 -1
- package/src/runs/shared/external-cli-runner.d.ts.map +0 -1
- package/src/runs/shared/external-cli-runner.js.map +0 -1
- package/src/runs/shared/external-job-bridge.d.ts.map +0 -1
- package/src/runs/shared/external-job-bridge.js.map +0 -1
- package/src/runs/shared/external-job-runner.d.ts.map +0 -1
- package/src/runs/shared/external-job-runner.js.map +0 -1
- package/src/runs/shared/fast-mode-extension.d.ts.map +0 -1
- package/src/runs/shared/fast-mode-extension.js.map +0 -1
- package/src/runs/shared/git-environment.d.ts.map +0 -1
- package/src/runs/shared/git-environment.js.map +0 -1
- package/src/runs/shared/herdr-connection.d.ts.map +0 -1
- package/src/runs/shared/herdr-connection.js.map +0 -1
- package/src/runs/shared/herdr-external-adapters.d.ts.map +0 -1
- package/src/runs/shared/herdr-external-adapters.js.map +0 -1
- package/src/runs/shared/herdr-machine.d.ts.map +0 -1
- package/src/runs/shared/herdr-machine.js.map +0 -1
- package/src/runs/shared/herdr-pi-protocol.d.ts.map +0 -1
- package/src/runs/shared/herdr-pi-protocol.js.map +0 -1
- package/src/runs/shared/herdr-placed-run.d.ts.map +0 -1
- package/src/runs/shared/herdr-placed-run.js.map +0 -1
- package/src/runs/shared/host-step-status.d.ts.map +0 -1
- package/src/runs/shared/host-step-status.js.map +0 -1
- package/src/runs/shared/lane-metadata.d.ts.map +0 -1
- package/src/runs/shared/lane-metadata.js.map +0 -1
- package/src/runs/shared/launch-cwd.d.ts.map +0 -1
- package/src/runs/shared/launch-cwd.js.map +0 -1
- package/src/runs/shared/long-running-guard.d.ts.map +0 -1
- package/src/runs/shared/long-running-guard.js.map +0 -1
- package/src/runs/shared/mcp-config-sources.d.ts.map +0 -1
- package/src/runs/shared/mcp-config-sources.js.map +0 -1
- package/src/runs/shared/mcp-direct-tool-allowlist.d.ts.map +0 -1
- package/src/runs/shared/mcp-direct-tool-allowlist.js.map +0 -1
- package/src/runs/shared/mcp-direct-tool-grant.d.ts.map +0 -1
- package/src/runs/shared/mcp-direct-tool-grant.js.map +0 -1
- package/src/runs/shared/model-resolution-diagnostic.d.ts.map +0 -1
- package/src/runs/shared/model-resolution-diagnostic.js.map +0 -1
- package/src/runs/shared/model-resolution.d.ts.map +0 -1
- package/src/runs/shared/model-resolution.js.map +0 -1
- package/src/runs/shared/model-scope.d.ts.map +0 -1
- package/src/runs/shared/model-scope.js.map +0 -1
- package/src/runs/shared/mutation-evidence.d.ts.map +0 -1
- package/src/runs/shared/mutation-evidence.js.map +0 -1
- package/src/runs/shared/nested-events.d.ts.map +0 -1
- package/src/runs/shared/nested-events.js.map +0 -1
- package/src/runs/shared/nested-path.d.ts.map +0 -1
- package/src/runs/shared/nested-path.js.map +0 -1
- package/src/runs/shared/nested-render.d.ts.map +0 -1
- package/src/runs/shared/nested-render.js.map +0 -1
- package/src/runs/shared/orca-progress-tabs.d.ts.map +0 -1
- package/src/runs/shared/orca-progress-tabs.js.map +0 -1
- package/src/runs/shared/parallel-handoff.d.ts.map +0 -1
- package/src/runs/shared/parallel-handoff.js.map +0 -1
- package/src/runs/shared/parallel-utils.d.ts.map +0 -1
- package/src/runs/shared/parallel-utils.js.map +0 -1
- package/src/runs/shared/partial-output.d.ts.map +0 -1
- package/src/runs/shared/partial-output.js.map +0 -1
- package/src/runs/shared/permissions.d.ts.map +0 -1
- package/src/runs/shared/permissions.js.map +0 -1
- package/src/runs/shared/pi-spawn.d.ts.map +0 -1
- package/src/runs/shared/pi-spawn.js.map +0 -1
- package/src/runs/shared/process-signal.d.ts.map +0 -1
- package/src/runs/shared/process-signal.js.map +0 -1
- package/src/runs/shared/readonly-drain-observation.d.ts.map +0 -1
- package/src/runs/shared/readonly-drain-observation.js.map +0 -1
- package/src/runs/shared/run-fanout-budget.d.ts.map +0 -1
- package/src/runs/shared/run-fanout-budget.js.map +0 -1
- package/src/runs/shared/run-ownership.d.ts.map +0 -1
- package/src/runs/shared/run-ownership.js.map +0 -1
- package/src/runs/shared/runner-launcher.d.ts.map +0 -1
- package/src/runs/shared/runner-launcher.js.map +0 -1
- package/src/runs/shared/runtime-acknowledged-extensions.d.ts.map +0 -1
- package/src/runs/shared/runtime-acknowledged-extensions.js.map +0 -1
- package/src/runs/shared/session-lease.d.ts.map +0 -1
- package/src/runs/shared/session-lease.js.map +0 -1
- package/src/runs/shared/single-output.d.ts.map +0 -1
- package/src/runs/shared/single-output.js.map +0 -1
- package/src/runs/shared/spawn-budget.d.ts.map +0 -1
- package/src/runs/shared/spawn-budget.js.map +0 -1
- package/src/runs/shared/structured-output.d.ts.map +0 -1
- package/src/runs/shared/structured-output.js.map +0 -1
- package/src/runs/shared/subagent-control.d.ts.map +0 -1
- package/src/runs/shared/subagent-control.js.map +0 -1
- package/src/runs/shared/subagent-prompt-runtime.d.ts.map +0 -1
- package/src/runs/shared/subagent-prompt-runtime.js.map +0 -1
- package/src/runs/shared/tool-availability.d.ts.map +0 -1
- package/src/runs/shared/tool-availability.js.map +0 -1
- package/src/runs/shared/tool-budget.d.ts.map +0 -1
- package/src/runs/shared/tool-budget.js.map +0 -1
- package/src/runs/shared/tool-timeout.d.ts.map +0 -1
- package/src/runs/shared/tool-timeout.js.map +0 -1
- package/src/runs/shared/usage-budget.d.ts.map +0 -1
- package/src/runs/shared/usage-budget.js.map +0 -1
- package/src/runs/shared/usage-reconciliation.d.ts.map +0 -1
- package/src/runs/shared/usage-reconciliation.js.map +0 -1
- package/src/runs/shared/workflow-async-child-guidance.d.ts.map +0 -1
- package/src/runs/shared/workflow-async-child-guidance.js.map +0 -1
- package/src/runs/shared/workflow-graph.d.ts.map +0 -1
- package/src/runs/shared/workflow-graph.js.map +0 -1
- package/src/runs/shared/worktree-cleanup-apply.d.ts.map +0 -1
- package/src/runs/shared/worktree-cleanup-apply.js.map +0 -1
- package/src/runs/shared/worktree-cleanup-plan.d.ts.map +0 -1
- package/src/runs/shared/worktree-cleanup-plan.js.map +0 -1
- package/src/runs/shared/worktree-lock.d.ts.map +0 -1
- package/src/runs/shared/worktree-lock.js.map +0 -1
- package/src/runs/shared/worktree-setup-command.d.ts.map +0 -1
- package/src/runs/shared/worktree-setup-command.js.map +0 -1
- package/src/runs/shared/worktree.d.ts.map +0 -1
- package/src/runs/shared/worktree.js.map +0 -1
- package/src/shared/accessible-dir.d.ts.map +0 -1
- package/src/shared/accessible-dir.js.map +0 -1
- package/src/shared/agent-stream-options.d.ts.map +0 -1
- package/src/shared/agent-stream-options.js.map +0 -1
- package/src/shared/artifacts.d.ts.map +0 -1
- package/src/shared/artifacts.js.map +0 -1
- package/src/shared/atomic-json.d.ts.map +0 -1
- package/src/shared/atomic-json.js.map +0 -1
- package/src/shared/capacity-resilient-json.d.ts.map +0 -1
- package/src/shared/capacity-resilient-json.js.map +0 -1
- package/src/shared/child-cache-retention.d.ts.map +0 -1
- package/src/shared/child-cache-retention.js.map +0 -1
- package/src/shared/child-session-name.d.ts.map +0 -1
- package/src/shared/child-session-name.js.map +0 -1
- package/src/shared/child-transcript.d.ts.map +0 -1
- package/src/shared/child-transcript.js.map +0 -1
- package/src/shared/completion-owner.d.ts.map +0 -1
- package/src/shared/completion-owner.js.map +0 -1
- package/src/shared/disabled-features.d.ts.map +0 -1
- package/src/shared/disabled-features.js.map +0 -1
- package/src/shared/display-text.d.ts.map +0 -1
- package/src/shared/display-text.js.map +0 -1
- package/src/shared/edit-distance.d.ts.map +0 -1
- package/src/shared/edit-distance.js.map +0 -1
- package/src/shared/extension-context.d.ts.map +0 -1
- package/src/shared/extension-context.js.map +0 -1
- package/src/shared/file-coalescer.d.ts.map +0 -1
- package/src/shared/file-coalescer.js.map +0 -1
- package/src/shared/file-lease.d.ts.map +0 -1
- package/src/shared/file-lease.js.map +0 -1
- package/src/shared/file-system-retry.d.ts.map +0 -1
- package/src/shared/file-system-retry.js.map +0 -1
- package/src/shared/fork-context.d.ts.map +0 -1
- package/src/shared/fork-context.js.map +0 -1
- package/src/shared/fork-session-cwd.d.ts.map +0 -1
- package/src/shared/fork-session-cwd.js.map +0 -1
- package/src/shared/formatters.d.ts.map +0 -1
- package/src/shared/formatters.js.map +0 -1
- package/src/shared/jsonl-writer.d.ts.map +0 -1
- package/src/shared/jsonl-writer.js.map +0 -1
- package/src/shared/launch-contract.d.ts.map +0 -1
- package/src/shared/launch-contract.js.map +0 -1
- package/src/shared/model-info.d.ts.map +0 -1
- package/src/shared/model-info.js.map +0 -1
- package/src/shared/model-response-aliases.d.ts.map +0 -1
- package/src/shared/model-response-aliases.js.map +0 -1
- package/src/shared/node-executable.d.ts.map +0 -1
- package/src/shared/node-executable.js.map +0 -1
- package/src/shared/opencode-session-headers.d.ts.map +0 -1
- package/src/shared/opencode-session-headers.js.map +0 -1
- package/src/shared/package-version.d.ts.map +0 -1
- package/src/shared/package-version.js.map +0 -1
- package/src/shared/parent-wake.d.ts.map +0 -1
- package/src/shared/parent-wake.js.map +0 -1
- package/src/shared/prompt-resources.d.ts.map +0 -1
- package/src/shared/prompt-resources.js.map +0 -1
- package/src/shared/pruned-fork.d.ts.map +0 -1
- package/src/shared/pruned-fork.js.map +0 -1
- package/src/shared/required-child-extensions.d.ts.map +0 -1
- package/src/shared/required-child-extensions.js.map +0 -1
- package/src/shared/runtime-module-path.d.ts.map +0 -1
- package/src/shared/runtime-module-path.js.map +0 -1
- package/src/shared/session-file-trust.d.ts.map +0 -1
- package/src/shared/session-file-trust.js.map +0 -1
- package/src/shared/session-identity.d.ts.map +0 -1
- package/src/shared/session-identity.js.map +0 -1
- package/src/shared/session-succession.d.ts.map +0 -1
- package/src/shared/session-succession.js.map +0 -1
- package/src/shared/session-tokens.d.ts.map +0 -1
- package/src/shared/session-tokens.js.map +0 -1
- package/src/shared/settings-file-lease.d.ts.map +0 -1
- package/src/shared/settings-file-lease.js.map +0 -1
- package/src/shared/settings.d.ts.map +0 -1
- package/src/shared/settings.js.map +0 -1
- package/src/shared/shortcuts.d.ts.map +0 -1
- package/src/shared/shortcuts.js.map +0 -1
- package/src/shared/status-format.d.ts.map +0 -1
- package/src/shared/status-format.js.map +0 -1
- package/src/shared/thinking-ceiling.d.ts.map +0 -1
- package/src/shared/thinking-ceiling.js.map +0 -1
- package/src/shared/types.d.ts.map +0 -1
- package/src/shared/types.js.map +0 -1
- package/src/shared/utf8.d.ts.map +0 -1
- package/src/shared/utf8.js.map +0 -1
- package/src/shared/utils.d.ts.map +0 -1
- package/src/shared/utils.js.map +0 -1
- package/src/shared/watch-strategy.d.ts.map +0 -1
- package/src/shared/watch-strategy.js.map +0 -1
- package/src/shared/workflow-child-permit.d.ts.map +0 -1
- package/src/shared/workflow-child-permit.js.map +0 -1
- package/src/slash/delegation-adapters.d.ts.map +0 -1
- package/src/slash/delegation-adapters.js.map +0 -1
- package/src/slash/delegation-json.d.ts.map +0 -1
- package/src/slash/delegation-json.js.map +0 -1
- package/src/slash/delegation-request.d.ts.map +0 -1
- package/src/slash/delegation-request.js.map +0 -1
- package/src/slash/prompt-template-bridge.d.ts.map +0 -1
- package/src/slash/prompt-template-bridge.js.map +0 -1
- package/src/slash/prompt-workflows.d.ts.map +0 -1
- package/src/slash/prompt-workflows.js.map +0 -1
- package/src/slash/selector.d.ts.map +0 -1
- package/src/slash/selector.js.map +0 -1
- package/src/slash/slash-bridge.d.ts.map +0 -1
- package/src/slash/slash-bridge.js.map +0 -1
- package/src/slash/slash-commands.d.ts.map +0 -1
- package/src/slash/slash-commands.js.map +0 -1
- package/src/slash/slash-live-state.d.ts.map +0 -1
- package/src/slash/slash-live-state.js.map +0 -1
- package/src/slash/subagent-cost.d.ts.map +0 -1
- package/src/slash/subagent-cost.js.map +0 -1
- package/src/slash/subagents-admin.d.ts.map +0 -1
- package/src/slash/subagents-admin.js.map +0 -1
- package/src/tui/fleet-status.d.ts.map +0 -1
- package/src/tui/fleet-status.js.map +0 -1
- package/src/tui/fleet-transcript.d.ts.map +0 -1
- package/src/tui/fleet-transcript.js.map +0 -1
- package/src/tui/fleet.d.ts.map +0 -1
- package/src/tui/fleet.js.map +0 -1
- package/src/tui/render-helpers.d.ts.map +0 -1
- package/src/tui/render-helpers.js.map +0 -1
- package/src/tui/render.d.ts.map +0 -1
- package/src/tui/render.js.map +0 -1
- package/src/tui/running-tone.d.ts.map +0 -1
- package/src/tui/running-tone.js.map +0 -1
- package/src/tui/subagent-messages.d.ts.map +0 -1
- package/src/tui/subagent-messages.js.map +0 -1
- package/src/watchdog/change-signature.d.ts.map +0 -1
- package/src/watchdog/change-signature.js.map +0 -1
- package/src/watchdog/child-status.d.ts.map +0 -1
- package/src/watchdog/child-status.js.map +0 -1
- package/src/watchdog/diff-tool.d.ts.map +0 -1
- package/src/watchdog/diff-tool.js.map +0 -1
- package/src/watchdog/emission-guard.d.ts.map +0 -1
- package/src/watchdog/emission-guard.js.map +0 -1
- package/src/watchdog/guidance.d.ts.map +0 -1
- package/src/watchdog/guidance.js.map +0 -1
- package/src/watchdog/lsp-diagnostics.d.ts.map +0 -1
- package/src/watchdog/lsp-diagnostics.js.map +0 -1
- package/src/watchdog/model-selection.d.ts.map +0 -1
- package/src/watchdog/model-selection.js.map +0 -1
- package/src/watchdog/permission-arbiter.d.ts.map +0 -1
- package/src/watchdog/permission-arbiter.js.map +0 -1
- package/src/watchdog/register-child.d.ts.map +0 -1
- package/src/watchdog/register-child.js.map +0 -1
- package/src/watchdog/register-main.d.ts.map +0 -1
- package/src/watchdog/register-main.js.map +0 -1
- package/src/watchdog/render.d.ts.map +0 -1
- package/src/watchdog/render.js.map +0 -1
- package/src/watchdog/review.d.ts.map +0 -1
- package/src/watchdog/review.js.map +0 -1
- package/src/watchdog/rules.d.ts.map +0 -1
- package/src/watchdog/rules.js.map +0 -1
- package/src/watchdog/runtime.d.ts.map +0 -1
- package/src/watchdog/runtime.js.map +0 -1
- package/src/watchdog/scope.d.ts.map +0 -1
- package/src/watchdog/scope.js.map +0 -1
- package/src/watchdog/settings.d.ts.map +0 -1
- package/src/watchdog/settings.js.map +0 -1
- package/src/watchdog/tool-actions.d.ts.map +0 -1
- package/src/watchdog/tool-actions.js.map +0 -1
- package/src/watchdog/turn-delta.d.ts.map +0 -1
- package/src/watchdog/turn-delta.js.map +0 -1
- package/src/watchdog/types.d.ts.map +0 -1
- package/src/watchdog/types.js.map +0 -1
- package/src/watchdog/warning-format.d.ts.map +0 -1
- package/src/watchdog/warning-format.js.map +0 -1
- package/src/workflows/chat-progress.d.ts.map +0 -1
- package/src/workflows/chat-progress.js.map +0 -1
- package/src/workflows/host-command.d.ts.map +0 -1
- package/src/workflows/host-command.js.map +0 -1
- package/src/workflows/scripted-workflow.d.ts.map +0 -1
- package/src/workflows/scripted-workflow.js.map +0 -1
- package/src/workflows/structured-workflow-scripts.d.ts.map +0 -1
- package/src/workflows/structured-workflow-scripts.js.map +0 -1
- package/src/workflows/workflow-checklist.d.ts.map +0 -1
- package/src/workflows/workflow-checklist.js.map +0 -1
- package/src/workflows/workflow-child-summary.d.ts.map +0 -1
- package/src/workflows/workflow-child-summary.js.map +0 -1
- package/src/workflows/workflow-preflight.d.ts.map +0 -1
- package/src/workflows/workflow-preflight.js.map +0 -1
- package/src/workflows/workflow-receipt.d.ts.map +0 -1
- package/src/workflows/workflow-receipt.js.map +0 -1
- package/src/workflows/workflow-resources.d.ts.map +0 -1
- package/src/workflows/workflow-resources.js.map +0 -1
- package/src/workflows/workflow-reuse.d.ts.map +0 -1
- package/src/workflows/workflow-reuse.js.map +0 -1
- package/src/workflows/workflow-revival.d.ts.map +0 -1
- package/src/workflows/workflow-revival.js.map +0 -1
- package/src/workflows/workflow-settlement.d.ts.map +0 -1
- package/src/workflows/workflow-settlement.js.map +0 -1
|
@@ -0,0 +1,4164 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildWorkflowChatProgressRows
|
|
3
|
+
} from "./chunk-KSWQVGDW.js";
|
|
4
|
+
import {
|
|
5
|
+
aggregateStepStatus,
|
|
6
|
+
contextModeBadge,
|
|
7
|
+
contextModeLabel,
|
|
8
|
+
contextModePrefix,
|
|
9
|
+
formatActivityLabel,
|
|
10
|
+
formatAgentRunningLabel,
|
|
11
|
+
formatNestedAggregate,
|
|
12
|
+
formatParallelOutcome,
|
|
13
|
+
formatWorkflowChecklistBottleneck,
|
|
14
|
+
formatWorkflowChecklistPhase,
|
|
15
|
+
formatWorkflowChecklistSummary,
|
|
16
|
+
formatWorkflowPreflight,
|
|
17
|
+
formatWorkflowPreflightPlanSummary,
|
|
18
|
+
formatWorkflowPreflightWarningSummary,
|
|
19
|
+
formatWorkflowPreflightWarnings,
|
|
20
|
+
isStaleExtensionContextError,
|
|
21
|
+
isUnboundExtensionRuntimeError,
|
|
22
|
+
ownerSessionIds,
|
|
23
|
+
projectAsyncStatusSnapshot,
|
|
24
|
+
projectAsyncWorkflowRows,
|
|
25
|
+
projectWorkflowChecklist,
|
|
26
|
+
withCachedUiContext,
|
|
27
|
+
workflowGraphStageNodes
|
|
28
|
+
} from "./chunk-NNLASTQE.js";
|
|
29
|
+
import {
|
|
30
|
+
flatToLogicalStepIndex,
|
|
31
|
+
formatWorkflowJsonPreview,
|
|
32
|
+
hostStepReportName,
|
|
33
|
+
hostStepVerdictLabel
|
|
34
|
+
} from "./chunk-VJHOELQP.js";
|
|
35
|
+
import {
|
|
36
|
+
snapshotExternalRuns
|
|
37
|
+
} from "./chunk-UKG4V45O.js";
|
|
38
|
+
import {
|
|
39
|
+
PROMPT_REDACTED,
|
|
40
|
+
childThinkingLevel,
|
|
41
|
+
formatContextUsage,
|
|
42
|
+
formatDuration,
|
|
43
|
+
formatModelThinking,
|
|
44
|
+
formatTokenUsage,
|
|
45
|
+
formatTokens,
|
|
46
|
+
formatToolCall,
|
|
47
|
+
formatUsage,
|
|
48
|
+
getDisplayItems,
|
|
49
|
+
getSingleResultOutput,
|
|
50
|
+
shortenPath,
|
|
51
|
+
unresolvedChildWatchdogBlockers
|
|
52
|
+
} from "./chunk-ZBC44JJ3.js";
|
|
53
|
+
import {
|
|
54
|
+
MAX_WIDGET_JOBS,
|
|
55
|
+
WIDGET_ANIMATION_INTERVAL_MS,
|
|
56
|
+
WIDGET_KEY
|
|
57
|
+
} from "./chunk-5LFLVSTM.js";
|
|
58
|
+
import {
|
|
59
|
+
previewDisplayText,
|
|
60
|
+
sanitizeDisplayText,
|
|
61
|
+
truncateDisplayText
|
|
62
|
+
} from "./chunk-YFCK7H2S.js";
|
|
63
|
+
|
|
64
|
+
// src/tui/running-tone.ts
|
|
65
|
+
var mainThinkingLevelSource = () => void 0;
|
|
66
|
+
function setMainThinkingLevelSource(source) {
|
|
67
|
+
mainThinkingLevelSource = source;
|
|
68
|
+
}
|
|
69
|
+
function readMainThinkingLevel(read) {
|
|
70
|
+
try {
|
|
71
|
+
return read();
|
|
72
|
+
} catch (error) {
|
|
73
|
+
if (isStaleExtensionContextError(error) || isUnboundExtensionRuntimeError(error)) return void 0;
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function runningTone(theme, childLevel) {
|
|
78
|
+
const level = childLevel ?? mainThinkingLevelSource();
|
|
79
|
+
return level ? theme.getThinkingBorderColor(level) : (text) => theme.fg("accent", text);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// src/tui/render.ts
|
|
83
|
+
import * as path from "node:path";
|
|
84
|
+
import { createHash } from "node:crypto";
|
|
85
|
+
import { getMarkdownTheme, keyText } from "@earendil-works/pi-coding-agent";
|
|
86
|
+
import { Container, Markdown, Spacer, Text, visibleWidth as visibleWidth2 } from "@earendil-works/pi-tui";
|
|
87
|
+
|
|
88
|
+
// src/shared/shortcuts.ts
|
|
89
|
+
function formatShortcutLabel(shortcut) {
|
|
90
|
+
return shortcut.split("+").map((part) => {
|
|
91
|
+
const normalized = part.trim().toLowerCase();
|
|
92
|
+
if (normalized === "ctrl") return "Ctrl";
|
|
93
|
+
if (normalized === "alt") return "Alt";
|
|
94
|
+
if (normalized === "shift") return "Shift";
|
|
95
|
+
if (normalized === "super") return "Super";
|
|
96
|
+
return normalized.length === 1 ? normalized.toUpperCase() : part.trim();
|
|
97
|
+
}).join("+");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// src/tui/render-helpers.ts
|
|
101
|
+
import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
102
|
+
function stripRepeatedAgentPrefix(label, jobName) {
|
|
103
|
+
const value = label.trim();
|
|
104
|
+
const prefix = jobName?.trim();
|
|
105
|
+
if (!prefix || !value.startsWith(prefix)) return value;
|
|
106
|
+
const suffix = value.slice(prefix.length);
|
|
107
|
+
if (!suffix || !/^(?::|·|\s)/u.test(suffix)) return value;
|
|
108
|
+
return suffix.replace(/^\s*(?::|·)?\s*/u, "").trim();
|
|
109
|
+
}
|
|
110
|
+
function shouldSuppressSingleStep(chainStepCount, stepsTotal) {
|
|
111
|
+
return (chainStepCount ?? stepsTotal) === 1;
|
|
112
|
+
}
|
|
113
|
+
function withDuplicateLabelDiscriminators(rows, total) {
|
|
114
|
+
const counts = /* @__PURE__ */ new Map();
|
|
115
|
+
for (const row of rows) counts.set(row.displayName, (counts.get(row.displayName) ?? 0) + 1);
|
|
116
|
+
return rows.map((row) => ({
|
|
117
|
+
...row,
|
|
118
|
+
rowLabel: (counts.get(row.displayName) ?? 0) > 1 ? `Agent ${row.index + 1}/${total}: ${row.displayName}` : row.displayName
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/runs/background/async-status-snapshot.ts
|
|
123
|
+
var ASYNC_STATUS_SNAPSHOT_WIDGET_PREFIX = "PI_SUBAGENT_ASYNC_JSON:";
|
|
124
|
+
function asyncStatusSnapshotJobsForState(state, sessionId) {
|
|
125
|
+
if (!state || !sessionId || state.currentSessionId !== sessionId) return [];
|
|
126
|
+
const owners = ownerSessionIds(sessionId);
|
|
127
|
+
const jobs = /* @__PURE__ */ new Map();
|
|
128
|
+
for (const job of state.asyncJobs.values()) {
|
|
129
|
+
if (owners.has(job.sessionId)) jobs.set(job.asyncId, job);
|
|
130
|
+
}
|
|
131
|
+
for (const job of state.fleetJobs?.values() ?? []) {
|
|
132
|
+
if (owners.has(job.sessionId) && !jobs.has(job.asyncId)) jobs.set(job.asyncId, job);
|
|
133
|
+
}
|
|
134
|
+
return [...jobs.values()];
|
|
135
|
+
}
|
|
136
|
+
function buildAsyncStatusSnapshotForState(state, sessionId, options = {}) {
|
|
137
|
+
return projectAsyncStatusSnapshot(asyncStatusSnapshotJobsForState(state, sessionId), options);
|
|
138
|
+
}
|
|
139
|
+
function encodeAsyncStatusSnapshotWidget(jobs, options = {}) {
|
|
140
|
+
return [`${ASYNC_STATUS_SNAPSHOT_WIDGET_PREFIX}${JSON.stringify(projectAsyncStatusSnapshot(jobs, options))}`];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// src/tui/render.ts
|
|
144
|
+
function resolveMainWindowRenderLayout(config) {
|
|
145
|
+
return {
|
|
146
|
+
horizontalSpacing: config?.horizontalSpacing ?? 2,
|
|
147
|
+
...config?.compactResultMaxLines !== void 0 ? { compactResultMaxLines: config.compactResultMaxLines } : {}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function mainWindowIndent(layout, level) {
|
|
151
|
+
return " ".repeat(Math.max(0, layout.horizontalSpacing * level));
|
|
152
|
+
}
|
|
153
|
+
function capCompactMainWindowResult(component, layout, theme, enabled) {
|
|
154
|
+
const maxLines = layout.compactResultMaxLines;
|
|
155
|
+
if (!enabled || maxLines === void 0) return component;
|
|
156
|
+
const capped = new Container();
|
|
157
|
+
capped.render = (width) => {
|
|
158
|
+
const lines = component.render(width);
|
|
159
|
+
if (lines.length <= maxLines) return lines;
|
|
160
|
+
const visibleRows = maxLines === 1 ? 1 : maxLines - 1;
|
|
161
|
+
const hiddenCount = lines.length - visibleRows;
|
|
162
|
+
const hint = theme.fg("accent", `\u2026 ${hiddenCount} rows hidden \xB7 ${expandKeyHint("to expand")}`);
|
|
163
|
+
if (maxLines === 1) return [truncLine(`${lines[0] ?? ""} ${hint}`, width)];
|
|
164
|
+
return [...lines.slice(0, visibleRows), truncLine(hint, width)];
|
|
165
|
+
};
|
|
166
|
+
return capped;
|
|
167
|
+
}
|
|
168
|
+
function expandKeyHint(action) {
|
|
169
|
+
return `Press ${keyText("app.tools.expand") || "the expand key"} ${action}`;
|
|
170
|
+
}
|
|
171
|
+
function liveDetailHintText() {
|
|
172
|
+
return expandKeyHint("for live detail");
|
|
173
|
+
}
|
|
174
|
+
function workflowDetailHintText() {
|
|
175
|
+
return expandKeyHint("for details");
|
|
176
|
+
}
|
|
177
|
+
function foregroundSingleHintText(shortcut) {
|
|
178
|
+
if (!shortcut) return liveDetailHintText();
|
|
179
|
+
const label = formatShortcutLabel(shortcut);
|
|
180
|
+
return `${liveDetailHintText()} \xB7 ${label} to run in background`;
|
|
181
|
+
}
|
|
182
|
+
function getTermWidth() {
|
|
183
|
+
return process.stdout.columns || 120;
|
|
184
|
+
}
|
|
185
|
+
var segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
186
|
+
var ansiStylePattern = /\x1b\[[0-9;]*m/y;
|
|
187
|
+
function truncLine(text, maxWidth) {
|
|
188
|
+
if (maxWidth <= 0) return "";
|
|
189
|
+
if (visibleWidth2(text) <= maxWidth) return text;
|
|
190
|
+
const targetWidth = maxWidth - 1;
|
|
191
|
+
let result = "";
|
|
192
|
+
let currentWidth = 0;
|
|
193
|
+
let activeStyles = [];
|
|
194
|
+
let i = 0;
|
|
195
|
+
while (i < text.length) {
|
|
196
|
+
ansiStylePattern.lastIndex = i;
|
|
197
|
+
const ansiMatch = ansiStylePattern.exec(text);
|
|
198
|
+
if (ansiMatch) {
|
|
199
|
+
const code = ansiMatch[0];
|
|
200
|
+
result += code;
|
|
201
|
+
if (code === "\x1B[0m" || code === "\x1B[m") {
|
|
202
|
+
activeStyles = [];
|
|
203
|
+
} else {
|
|
204
|
+
activeStyles.push(code);
|
|
205
|
+
}
|
|
206
|
+
i += code.length;
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
let end = text.indexOf("\x1B[", i);
|
|
210
|
+
if (end === i) end = text.indexOf("\x1B[", i + 2);
|
|
211
|
+
if (end === -1) end = text.length;
|
|
212
|
+
const textPortion = text.slice(i, end);
|
|
213
|
+
for (const seg of segmenter.segment(textPortion)) {
|
|
214
|
+
const grapheme = seg.segment;
|
|
215
|
+
const graphemeWidth = grapheme === "\x1B" ? 0 : visibleWidth2(grapheme);
|
|
216
|
+
if (currentWidth + graphemeWidth > targetWidth) {
|
|
217
|
+
return result + activeStyles.join("") + "\u2026";
|
|
218
|
+
}
|
|
219
|
+
result += grapheme;
|
|
220
|
+
currentWidth += graphemeWidth;
|
|
221
|
+
}
|
|
222
|
+
i = end;
|
|
223
|
+
}
|
|
224
|
+
return result + activeStyles.join("") + "\u2026";
|
|
225
|
+
}
|
|
226
|
+
function wrapPlainText(text, maxWidth) {
|
|
227
|
+
if (maxWidth <= 0) return [""];
|
|
228
|
+
const lines = [];
|
|
229
|
+
for (const rawLine of text.split("\n")) {
|
|
230
|
+
if (rawLine.length === 0) {
|
|
231
|
+
lines.push("");
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
let current = "";
|
|
235
|
+
let currentWidth = 0;
|
|
236
|
+
for (const seg of segmenter.segment(rawLine)) {
|
|
237
|
+
const grapheme = seg.segment;
|
|
238
|
+
const graphemeWidth = visibleWidth2(grapheme);
|
|
239
|
+
if (graphemeWidth > maxWidth) continue;
|
|
240
|
+
if (currentWidth > 0 && currentWidth + graphemeWidth > maxWidth) {
|
|
241
|
+
lines.push(current);
|
|
242
|
+
current = grapheme;
|
|
243
|
+
currentWidth = graphemeWidth;
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
current += grapheme;
|
|
247
|
+
currentWidth += graphemeWidth;
|
|
248
|
+
}
|
|
249
|
+
lines.push(current);
|
|
250
|
+
}
|
|
251
|
+
return lines;
|
|
252
|
+
}
|
|
253
|
+
var RUNNING_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
254
|
+
var STATIC_RUNNING_GLYPH = "\u25CF";
|
|
255
|
+
function runningSeed(...values) {
|
|
256
|
+
let seed;
|
|
257
|
+
for (const value of values) {
|
|
258
|
+
if (value === void 0 || !Number.isFinite(value)) continue;
|
|
259
|
+
seed = (seed ?? 0) + Math.trunc(value);
|
|
260
|
+
}
|
|
261
|
+
return seed;
|
|
262
|
+
}
|
|
263
|
+
function runningGlyph(seed) {
|
|
264
|
+
if (seed === void 0) return STATIC_RUNNING_GLYPH;
|
|
265
|
+
return RUNNING_FRAMES[Math.abs(seed) % RUNNING_FRAMES.length];
|
|
266
|
+
}
|
|
267
|
+
function animatedSeed(seed, frame) {
|
|
268
|
+
if (frame === void 0) return seed;
|
|
269
|
+
return (seed ?? 0) + frame;
|
|
270
|
+
}
|
|
271
|
+
function progressRunningSeed(progress) {
|
|
272
|
+
if (!progress) return void 0;
|
|
273
|
+
return runningSeed(
|
|
274
|
+
progress.index,
|
|
275
|
+
progress.toolCount,
|
|
276
|
+
progress.tokens,
|
|
277
|
+
progress.durationMs,
|
|
278
|
+
progress.lastActivityAt,
|
|
279
|
+
progress.currentToolStartedAt,
|
|
280
|
+
progress.turnCount
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
function clearLegacyResultAnimationTimer(context) {
|
|
284
|
+
const timer = context.state.subagentResultAnimationTimer;
|
|
285
|
+
if (!timer) return;
|
|
286
|
+
clearInterval(timer);
|
|
287
|
+
context.state.subagentResultAnimationTimer = void 0;
|
|
288
|
+
}
|
|
289
|
+
function extractOutputTarget(task) {
|
|
290
|
+
const writeToMatch = task.match(/\[Write to:\s*([^\]\n]+)\]/i);
|
|
291
|
+
if (writeToMatch?.[1]?.trim()) return writeToMatch[1].trim();
|
|
292
|
+
const findingsMatch = task.match(/Write your findings to(?: exactly this path)?:\s*([^\r\n]+)/i);
|
|
293
|
+
if (findingsMatch?.[1]?.trim()) return findingsMatch[1].trim();
|
|
294
|
+
const outputMatch = task.match(/[Oo]utput(?:\s+to)?\s*:\s*(\S+)/i);
|
|
295
|
+
if (outputMatch?.[1]?.trim()) return outputMatch[1].trim();
|
|
296
|
+
return void 0;
|
|
297
|
+
}
|
|
298
|
+
function hasEmptyTextOutputWithoutOutputTarget(task, output) {
|
|
299
|
+
if (output.trim()) return false;
|
|
300
|
+
return !extractOutputTarget(task);
|
|
301
|
+
}
|
|
302
|
+
function getToolCallLines(result, expanded) {
|
|
303
|
+
if (result.messages) {
|
|
304
|
+
return getDisplayItems(result.messages).filter((item) => item.type === "tool").map((item) => formatToolCall(item.name, item.args, expanded));
|
|
305
|
+
}
|
|
306
|
+
return result.toolCalls?.map((toolCall) => expanded ? toolCall.expandedText : toolCall.text) ?? [];
|
|
307
|
+
}
|
|
308
|
+
var ansiEscapePattern = /\x1b\[[0-9;]*m/g;
|
|
309
|
+
var noisyStatusPatterns = [
|
|
310
|
+
/^(?:i|we)\s+(?:will|need|can|should|am|are)\b/i,
|
|
311
|
+
/^i(?:'m|’m| am)\b/i,
|
|
312
|
+
/\bso i (?:will|need|can)\b/i,
|
|
313
|
+
/^(?:checking|fetching|reading|inspecting|verifying|collecting|confirming|polling)\b/i,
|
|
314
|
+
/^(?:async\s+subagent\s+)?[\w.-]+\s*·\s*(?:step|agent)\s+\d+\/\d+\s*·/i,
|
|
315
|
+
/^(?:Step|Agent)\s+\d+\/\d+:\s+[\w.-]+\s*·\s*(?:running|queued|pending|complete|completed)\b/i,
|
|
316
|
+
/^(?:async\s+subagent\s+)?[\w.-]+(?:\s+\[(?:fresh|fork|mixed)\])?\s*·\s*(?:running|queued|pending|complete|completed|done)\b/i,
|
|
317
|
+
/^Press\s+\S+\s+for\s+live\s+detail$/i,
|
|
318
|
+
/^output:\s+.+\/async-subagent-runs\//i
|
|
319
|
+
];
|
|
320
|
+
var liveOutputWordSignalPattern = /\b(?:access denied|denied|error|exception|fail(?:ed|ure)?|fatal|panic|rejected|timeout|timed out|unable|warning)\b/i;
|
|
321
|
+
var liveOutputCodeSignalPattern = /\bE[A-Z0-9_]{2,}\b/;
|
|
322
|
+
function oneLine(text) {
|
|
323
|
+
return text.replace(ansiEscapePattern, "").replace(/\s+/g, " ").trim();
|
|
324
|
+
}
|
|
325
|
+
var COMPACT_TASK_MAX_CHARS = 96;
|
|
326
|
+
function childDisplayName(result, fallback = "subagent") {
|
|
327
|
+
return result?.sessionName?.trim() || result?.agent || fallback;
|
|
328
|
+
}
|
|
329
|
+
function compactTaskText(task, label) {
|
|
330
|
+
const taskText = task?.trim();
|
|
331
|
+
const labelText = label?.trim();
|
|
332
|
+
const normalizedTask = taskText && taskText !== PROMPT_REDACTED ? oneLine(taskText) : "";
|
|
333
|
+
const normalizedLabel = labelText && labelText !== PROMPT_REDACTED ? oneLine(labelText) : "";
|
|
334
|
+
const normalized = normalizedLabel && normalizedTask && normalizedLabel !== normalizedTask ? `${normalizedLabel} \u2014 ${normalizedTask}` : normalizedLabel || normalizedTask;
|
|
335
|
+
if (!normalized) return void 0;
|
|
336
|
+
return previewDisplayText(normalized, COMPACT_TASK_MAX_CHARS);
|
|
337
|
+
}
|
|
338
|
+
var LANE_VALUE_MAX_CHARS = 48;
|
|
339
|
+
function boundedLaneValue(value, maxChars = LANE_VALUE_MAX_CHARS) {
|
|
340
|
+
if (!value?.trim() || value.trim() === PROMPT_REDACTED) return void 0;
|
|
341
|
+
return previewDisplayText(oneLine(value), maxChars);
|
|
342
|
+
}
|
|
343
|
+
function workflowNodeStepStatus(status) {
|
|
344
|
+
switch (status) {
|
|
345
|
+
case "completed":
|
|
346
|
+
return "completed";
|
|
347
|
+
case "detached":
|
|
348
|
+
return "paused";
|
|
349
|
+
default:
|
|
350
|
+
return status;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
function workflowNodeStatusLabel(status) {
|
|
354
|
+
switch (status) {
|
|
355
|
+
case "completed":
|
|
356
|
+
return "complete";
|
|
357
|
+
case "detached":
|
|
358
|
+
return "paused";
|
|
359
|
+
default:
|
|
360
|
+
return status;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
function workflowStepPriority(step, currentNodeId) {
|
|
364
|
+
const isCurrent = step.workflowKey === currentNodeId;
|
|
365
|
+
if (step.status === "running" || isCurrent && step.status !== "complete" && step.status !== "completed") return 0;
|
|
366
|
+
const gate = laneGate(step);
|
|
367
|
+
if (step.status === "failed" || step.status === "partial" || step.status === "paused" || step.status === "stopped" || step.status === "rejected" || step.toolBudgetBlocked === true || step.turnBudgetExceeded === true || step.activityState === "needs_attention" || step.watchdog?.phase === "stale" || unresolvedChildWatchdogBlockers(step.watchdog).length > 0 || gate !== void 0) return 1;
|
|
368
|
+
if (step.status === "pending") return 2;
|
|
369
|
+
return 3;
|
|
370
|
+
}
|
|
371
|
+
function workflowWidgetSteps(job, planned = job.mode === "workflow" ? workflowGraphStageNodes(job.workflowGraph) : []) {
|
|
372
|
+
const loaded = job.steps ?? [];
|
|
373
|
+
if (planned.length === 0) return loaded;
|
|
374
|
+
const loadedIndexesByKey = /* @__PURE__ */ new Map();
|
|
375
|
+
for (const [index, step] of loaded.entries()) {
|
|
376
|
+
if (!step.workflowKey) continue;
|
|
377
|
+
const indexes = loadedIndexesByKey.get(step.workflowKey) ?? [];
|
|
378
|
+
indexes.push(index);
|
|
379
|
+
loadedIndexesByKey.set(step.workflowKey, indexes);
|
|
380
|
+
}
|
|
381
|
+
const consumed = /* @__PURE__ */ new Set();
|
|
382
|
+
const entries = [];
|
|
383
|
+
for (const [order, node] of planned.entries()) {
|
|
384
|
+
const loadedIndex = loadedIndexesByKey.get(node.id)?.find((index) => !consumed.has(index));
|
|
385
|
+
if (loadedIndex !== void 0) {
|
|
386
|
+
consumed.add(loadedIndex);
|
|
387
|
+
const loadedStep = loaded[loadedIndex];
|
|
388
|
+
entries.push({
|
|
389
|
+
step: {
|
|
390
|
+
...loadedStep,
|
|
391
|
+
index: node.flatIndex ?? loadedStep.index ?? order,
|
|
392
|
+
agent: loadedStep.agent || node.agent || job.agents?.[0] || "workflow",
|
|
393
|
+
phase: loadedStep.phase ?? node.phase,
|
|
394
|
+
label: loadedStep.label ?? node.label,
|
|
395
|
+
workflowKey: loadedStep.workflowKey ?? node.id,
|
|
396
|
+
...loadedStep.outputName === void 0 && node.outputName !== void 0 ? { outputName: node.outputName } : {},
|
|
397
|
+
...loadedStep.structured === void 0 && node.structured !== void 0 ? { structured: node.structured } : {},
|
|
398
|
+
...loadedStep.error === void 0 && node.error !== void 0 ? { error: node.error } : {}
|
|
399
|
+
},
|
|
400
|
+
order
|
|
401
|
+
});
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
entries.push({
|
|
405
|
+
step: {
|
|
406
|
+
index: node.flatIndex ?? order,
|
|
407
|
+
agent: node.agent ?? job.agents?.[0] ?? "workflow",
|
|
408
|
+
status: workflowNodeStepStatus(node.status),
|
|
409
|
+
workflowKey: node.id,
|
|
410
|
+
label: node.label,
|
|
411
|
+
...node.phase ? { phase: node.phase } : {},
|
|
412
|
+
...node.outputName ? { outputName: node.outputName } : {},
|
|
413
|
+
...node.structured !== void 0 ? { structured: node.structured } : {},
|
|
414
|
+
...node.error ? { error: node.error } : {}
|
|
415
|
+
},
|
|
416
|
+
order
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
for (const [index, step] of loaded.entries()) {
|
|
420
|
+
if (!consumed.has(index)) entries.push({ step, order: planned.length + index });
|
|
421
|
+
}
|
|
422
|
+
entries.sort((left, right) => workflowStepPriority(left.step, job.workflowGraph?.currentNodeId) - workflowStepPriority(right.step, job.workflowGraph?.currentNodeId) || left.order - right.order);
|
|
423
|
+
return entries.map(({ step }) => step);
|
|
424
|
+
}
|
|
425
|
+
function workflowStageProgress(job, stages = job.mode === "workflow" ? workflowGraphStageNodes(job.workflowGraph) : []) {
|
|
426
|
+
if (job.mode !== "workflow") return void 0;
|
|
427
|
+
if (stages.length === 0) return void 0;
|
|
428
|
+
const currentId = job.workflowGraph?.currentNodeId;
|
|
429
|
+
const currentIndex = currentId ? stages.findIndex((stage) => stage.id === currentId) : -1;
|
|
430
|
+
if (currentIndex >= 0 && stages[currentIndex]?.status !== "completed") return { total: stages.length, current: currentIndex };
|
|
431
|
+
const runningIndex = stages.findIndex((stage) => stage.status === "running");
|
|
432
|
+
if (runningIndex >= 0) return { total: stages.length, current: runningIndex };
|
|
433
|
+
const indexedStage = job.currentStep !== void 0 && job.currentStep >= 0 ? stages[job.currentStep] : void 0;
|
|
434
|
+
if (indexedStage && indexedStage.status !== "completed") return { total: stages.length, current: job.currentStep };
|
|
435
|
+
if (stages.every((stage) => stage.status === "completed")) return { total: stages.length, current: stages.length - 1 };
|
|
436
|
+
return { total: stages.length };
|
|
437
|
+
}
|
|
438
|
+
function buildWorkflowWidgetProjection(job, now = Date.now()) {
|
|
439
|
+
const stages = job.mode === "workflow" ? workflowGraphStageNodes(job.workflowGraph) : [];
|
|
440
|
+
const stageProgress = workflowStageProgress(job, stages);
|
|
441
|
+
const clock = job.status === "running" ? now : job.updatedAt;
|
|
442
|
+
const loadedSteps = workflowWidgetSteps(job, stages);
|
|
443
|
+
const steps = job.mode === "workflow" ? loadedSteps.map((step) => step.status === "running" && step.startedAt !== void 0 && clock !== void 0 ? { ...step, durationMs: Math.max(0, clock - step.startedAt) } : step) : loadedSteps;
|
|
444
|
+
const projection = { stages, steps, now };
|
|
445
|
+
if (stageProgress) projection.stageProgress = stageProgress;
|
|
446
|
+
if (stages.length) projection.plannedKeys = new Set(stages.map((node) => node.id));
|
|
447
|
+
if (job.mode === "workflow") {
|
|
448
|
+
const checklist = projectWorkflowChecklist({
|
|
449
|
+
graph: job.workflowGraph,
|
|
450
|
+
steps: job.steps,
|
|
451
|
+
hostSteps: job.hostSteps,
|
|
452
|
+
preflight: job.preflight,
|
|
453
|
+
trace: job.workflow?.trace,
|
|
454
|
+
now: clock
|
|
455
|
+
});
|
|
456
|
+
if (checklist.total > 0) projection.checklist = checklist;
|
|
457
|
+
}
|
|
458
|
+
return projection;
|
|
459
|
+
}
|
|
460
|
+
function workflowWidgetProjectionLookup(now = Date.now(), childrenByParent = /* @__PURE__ */ new Map()) {
|
|
461
|
+
const projections = /* @__PURE__ */ new WeakMap();
|
|
462
|
+
return (job) => {
|
|
463
|
+
const cached = projections.get(job);
|
|
464
|
+
if (cached) return cached;
|
|
465
|
+
const projection = buildWorkflowWidgetProjection(job, now);
|
|
466
|
+
const children = childrenByParent.get(job.asyncId);
|
|
467
|
+
if (children?.length) {
|
|
468
|
+
projection.children = children;
|
|
469
|
+
projection.materializedKeys = new Set(children.flatMap((child) => [child.asyncId, ...child.workflowKey ? [child.workflowKey] : []]));
|
|
470
|
+
for (const step of projection.steps) {
|
|
471
|
+
if (step.runId && projection.materializedKeys.has(step.runId) && step.workflowKey) projection.materializedKeys.add(step.workflowKey);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
projections.set(job, projection);
|
|
475
|
+
return projection;
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
function laneStepForJob(job, steps = workflowWidgetSteps(job)) {
|
|
479
|
+
if (steps.length === 0) return void 0;
|
|
480
|
+
const graphCurrent = job.workflowGraph?.currentNodeId;
|
|
481
|
+
if (graphCurrent) {
|
|
482
|
+
const current = steps.find((step) => step.workflowKey === graphCurrent);
|
|
483
|
+
if (current) return current;
|
|
484
|
+
}
|
|
485
|
+
if (job.currentStep !== void 0) {
|
|
486
|
+
const current = steps[job.currentStep];
|
|
487
|
+
if (current && (current.index === void 0 || current.index === job.currentStep)) return current;
|
|
488
|
+
const indexedCurrent = steps.find((step) => step.index === job.currentStep);
|
|
489
|
+
if (indexedCurrent) return indexedCurrent;
|
|
490
|
+
return steps[0];
|
|
491
|
+
}
|
|
492
|
+
return steps.find((step) => step.status === "running") ?? steps.find((step) => step.status === "pending") ?? steps.at(-1);
|
|
493
|
+
}
|
|
494
|
+
function laneTraceForJob(job) {
|
|
495
|
+
return Array.isArray(job.workflow?.trace) ? job.workflow.trace.at(-1) : void 0;
|
|
496
|
+
}
|
|
497
|
+
function laneGate(step) {
|
|
498
|
+
const review = step?.review?.status ?? step?.acceptance?.reviewResult?.status;
|
|
499
|
+
if (review === "blockers") return "review blockers";
|
|
500
|
+
if (review === "review-required") return "review required";
|
|
501
|
+
if (review === "reviewed") return "reviewed";
|
|
502
|
+
const acceptance = step?.acceptance?.status;
|
|
503
|
+
if (acceptance === "review-required") return "acceptance review";
|
|
504
|
+
if (acceptance === "checked" || acceptance === "verified" || acceptance === "accepted") return "acceptance";
|
|
505
|
+
return void 0;
|
|
506
|
+
}
|
|
507
|
+
function laneNextAction(state, step, output, gate) {
|
|
508
|
+
if (unresolvedChildWatchdogBlockers(step?.watchdog).length > 0) return "resolve watchdog blockers";
|
|
509
|
+
if (step?.watchdog?.phase === "stale") return "inspect stale state";
|
|
510
|
+
if (step?.toolBudgetBlocked === true || step?.turnBudgetExceeded === true) return "inspect blocked state";
|
|
511
|
+
if (gate === "review blockers") return "resolve review blockers";
|
|
512
|
+
if (gate === "review required" || gate === "acceptance review") return "review output";
|
|
513
|
+
if (step?.activityState === "needs_attention") return "inspect attention";
|
|
514
|
+
if (state === "queued" || state === "pending") return "await launch";
|
|
515
|
+
if (state === "failed" || state === "rejected") return "inspect failure";
|
|
516
|
+
if (state === "partial") return "inspect partial state";
|
|
517
|
+
if (state === "paused") return "inspect paused state";
|
|
518
|
+
if (state === "stopped") return "inspect stopped state";
|
|
519
|
+
if ((state === "complete" || state === "completed") && gate === "reviewed") return "ready";
|
|
520
|
+
if ((state === "complete" || state === "completed") && output) return "inspect output";
|
|
521
|
+
return void 0;
|
|
522
|
+
}
|
|
523
|
+
function isTerminalLaneState(state) {
|
|
524
|
+
return state !== "queued" && state !== "running";
|
|
525
|
+
}
|
|
526
|
+
function projectAsyncLane(job, ...args) {
|
|
527
|
+
const selectedStep = args.length === 0 ? laneStepForJob(job) : args[0];
|
|
528
|
+
const trace = laneTraceForJob(job);
|
|
529
|
+
const workspace = job.cwd ? boundedLaneValue(shortenPath(job.cwd)) : void 0;
|
|
530
|
+
const label = compactTaskText(selectedStep?.description, selectedStep?.label) ?? boundedLaneValue(trace?.label) ?? (workspace ? void 0 : boundedLaneValue(selectedStep?.workflowKey ?? job.workflowKey));
|
|
531
|
+
const role = boundedLaneValue(selectedStep?.agent ?? trace?.agent ?? job.agents?.[0] ?? widgetJobName(job), 32) ?? "subagent";
|
|
532
|
+
const phase = boundedLaneValue(selectedStep?.phase ?? trace?.phase);
|
|
533
|
+
const gate = laneGate(selectedStep);
|
|
534
|
+
const output = boundedLaneValue(selectedStep?.outputName);
|
|
535
|
+
const ref = boundedLaneValue(selectedStep?.workflowKey ?? job.workflowKey ?? job.asyncId.slice(0, 8), 24) ?? job.asyncId.slice(0, 8);
|
|
536
|
+
const chips = [
|
|
537
|
+
selectedStep?.context,
|
|
538
|
+
selectedStep?.structured ? "structured" : void 0,
|
|
539
|
+
selectedStep?.activityState === "active_long_running" ? "long-running" : void 0,
|
|
540
|
+
selectedStep?.activityState === "needs_attention" ? "attention" : void 0,
|
|
541
|
+
selectedStep?.watchdog?.phase === "stale" ? "stale" : void 0,
|
|
542
|
+
unresolvedChildWatchdogBlockers(selectedStep?.watchdog).length > 0 ? `wd:${unresolvedChildWatchdogBlockers(selectedStep?.watchdog).length}` : void 0,
|
|
543
|
+
selectedStep?.toolBudgetBlocked === true || selectedStep?.turnBudgetExceeded === true ? "blocked" : void 0
|
|
544
|
+
].filter((chip) => Boolean(chip));
|
|
545
|
+
const state = isTerminalLaneState(job.status) ? job.status : selectedStep?.status ?? job.status;
|
|
546
|
+
const next = laneNextAction(state, selectedStep, output, gate);
|
|
547
|
+
if (!label && !phase && !gate && !output && !selectedStep?.workflowKey && !job.workflowKey && !trace?.label && !trace?.phase) return void 0;
|
|
548
|
+
return { ...label ? { label } : {}, role, ...phase ? { phase } : {}, state, ...gate ? { gate } : {}, ...next ? { next } : {}, ...output ? { output } : {}, ...workspace ? { workspace } : {}, ref, chips };
|
|
549
|
+
}
|
|
550
|
+
function laneStateLabel(state, theme) {
|
|
551
|
+
if (state === "running") return theme.fg("accent", "running");
|
|
552
|
+
if (state === "queued" || state === "pending") return theme.fg("muted", state);
|
|
553
|
+
if (state === "complete" || state === "completed") return theme.fg("success", "complete");
|
|
554
|
+
if (state === "failed" || state === "rejected") return theme.fg("error", state === "rejected" ? "rejected" : "failed");
|
|
555
|
+
return theme.fg("warning", state);
|
|
556
|
+
}
|
|
557
|
+
function formatLaneProjection(lane, theme) {
|
|
558
|
+
const label = boundedLaneValue(lane.label, 56);
|
|
559
|
+
const identity = [label, lane.role ? `role:${lane.role}` : void 0].filter(Boolean).join(" \xB7 ");
|
|
560
|
+
return `${identity ? theme.bold(identity) : theme.bold(lane.role)} \xB7 ${laneStateLabel(lane.state, theme)}`;
|
|
561
|
+
}
|
|
562
|
+
function formatLaneChip(chip, theme) {
|
|
563
|
+
const text = `[${chip}]`;
|
|
564
|
+
if (chip === "blocked") return theme.fg("error", text);
|
|
565
|
+
if (chip === "stale") return theme.fg("warning", text);
|
|
566
|
+
return text;
|
|
567
|
+
}
|
|
568
|
+
function formatLaneProjectionDetails(lane, theme) {
|
|
569
|
+
const details = [
|
|
570
|
+
lane.phase ? `phase:${lane.phase}` : void 0,
|
|
571
|
+
lane.gate ? `gate:${lane.gate}` : void 0,
|
|
572
|
+
lane.next ? `next:${lane.next}` : void 0,
|
|
573
|
+
lane.output ? `out:${lane.output}` : void 0,
|
|
574
|
+
lane.workspace ? `workspace:${lane.workspace}` : lane.ref ? `ref:${lane.ref}` : void 0
|
|
575
|
+
].filter(Boolean);
|
|
576
|
+
const chips = lane.chips.map((chip) => formatLaneChip(chip, theme));
|
|
577
|
+
return [...details.length ? [theme.fg("dim", details.join(" \xB7 "))] : [], ...chips].join(" \xB7 ") || void 0;
|
|
578
|
+
}
|
|
579
|
+
function formatLaneProjectionLines(lane, theme, indent) {
|
|
580
|
+
const details = formatLaneProjectionDetails(lane, theme);
|
|
581
|
+
return [
|
|
582
|
+
`${indent}${formatLaneProjection(lane, theme)}`,
|
|
583
|
+
...details ? [`${indent} ${details}`] : []
|
|
584
|
+
];
|
|
585
|
+
}
|
|
586
|
+
function laneRenderKey(job, projection) {
|
|
587
|
+
const selectedStep = projection ? laneStepForJob(job, projection.steps) : laneStepForJob(job);
|
|
588
|
+
const lane = projectAsyncLane(job, selectedStep);
|
|
589
|
+
return lane ? [lane.label, lane.role, lane.phase, lane.state, lane.gate, lane.next, lane.output, lane.workspace, lane.ref, lane.chips] : void 0;
|
|
590
|
+
}
|
|
591
|
+
function widgetLaneDetailLines(job, theme, projection) {
|
|
592
|
+
if (job.steps?.length && (job.mode === "parallel" || job.mode === "chain")) return [];
|
|
593
|
+
const selectedStep = projection ? laneStepForJob(job, projection.steps) : laneStepForJob(job);
|
|
594
|
+
const lane = projectAsyncLane(job, selectedStep);
|
|
595
|
+
return lane ? formatLaneProjectionLines(lane, theme, " ") : [];
|
|
596
|
+
}
|
|
597
|
+
function workflowPreflightLines(job) {
|
|
598
|
+
if (job.mode !== "workflow" || !job.preflight) return [];
|
|
599
|
+
return [
|
|
600
|
+
...formatWorkflowPreflight(job.preflight, { indent: " " }).split("\n"),
|
|
601
|
+
...job.workflow?.preflightWarnings ? formatWorkflowPreflightWarnings(job.workflow.preflightWarnings, { indent: " " }).split("\n") : []
|
|
602
|
+
];
|
|
603
|
+
}
|
|
604
|
+
function workflowLabelForResult(details, resultIndex) {
|
|
605
|
+
const flatIndex = foregroundResultIndex(details, resultIndex);
|
|
606
|
+
const visit = (nodes) => {
|
|
607
|
+
for (const node of nodes) {
|
|
608
|
+
if (node.flatIndex === flatIndex && node.label.trim()) return node.label;
|
|
609
|
+
const nested = node.children ? visit(node.children) : void 0;
|
|
610
|
+
if (nested) return nested;
|
|
611
|
+
}
|
|
612
|
+
return void 0;
|
|
613
|
+
};
|
|
614
|
+
return details.workflowGraph ? visit(details.workflowGraph.nodes) : void 0;
|
|
615
|
+
}
|
|
616
|
+
function foregroundProgressForResult(details, resultIndex) {
|
|
617
|
+
const result = details.results[resultIndex];
|
|
618
|
+
if (result?.progress) return result.progress;
|
|
619
|
+
const index = result?.index ?? resultIndex;
|
|
620
|
+
const indexed = details.progress?.find((progress) => progress.index === index);
|
|
621
|
+
if (indexed) return indexed;
|
|
622
|
+
return result?.agent ? details.progress?.find((progress) => progress.agent === result.agent && progress.status === "running") : void 0;
|
|
623
|
+
}
|
|
624
|
+
function foregroundResultIndex(details, resultIndex) {
|
|
625
|
+
const result = details.results[resultIndex];
|
|
626
|
+
if (typeof result?.index === "number") return result.index;
|
|
627
|
+
return foregroundProgressForResult(details, resultIndex)?.index ?? resultIndex;
|
|
628
|
+
}
|
|
629
|
+
function foregroundResultDisplayName(details, resultIndex, result, fallback) {
|
|
630
|
+
const progress = foregroundProgressForResult(details, resultIndex);
|
|
631
|
+
const agent = normalizedParallelDisplayText(result?.agent) ?? normalizedParallelDisplayText(progress?.agent);
|
|
632
|
+
const workflowLabel = normalizedParallelDisplayText(workflowLabelForResult(details, resultIndex));
|
|
633
|
+
if (workflowLabel) return compactTaskText(void 0, workflowLabel) ?? workflowLabel;
|
|
634
|
+
const sessionName = normalizedParallelDisplayText(result?.sessionName) ?? normalizedParallelDisplayText(progress?.sessionName);
|
|
635
|
+
if (sessionName) {
|
|
636
|
+
const sessionTask = stripRepeatedAgentPrefix(sessionName, agent);
|
|
637
|
+
if (sessionTask && sessionTask !== PROMPT_REDACTED && sessionTask.toLowerCase() !== agent?.toLowerCase()) {
|
|
638
|
+
return compactTaskText(sessionTask) ?? sessionTask;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
return compactTaskText(result?.task) ?? compactTaskText(progress?.task) ?? agent ?? fallback;
|
|
642
|
+
}
|
|
643
|
+
function foregroundSingleDisplayName(result) {
|
|
644
|
+
return normalizedParallelDisplayText(result?.agent) ?? normalizedParallelDisplayText(result?.sessionName) ?? compactTaskText(result?.task) ?? "subagent";
|
|
645
|
+
}
|
|
646
|
+
function hasLiveOutputSignal(line) {
|
|
647
|
+
const clean = oneLine(line);
|
|
648
|
+
return liveOutputWordSignalPattern.test(clean) || liveOutputCodeSignalPattern.test(clean);
|
|
649
|
+
}
|
|
650
|
+
function isNoisyStatusLine(line) {
|
|
651
|
+
const clean = oneLine(line);
|
|
652
|
+
return clean.length > 0 && clean.length <= 240 && !hasLiveOutputSignal(clean) && noisyStatusPatterns.some((pattern) => pattern.test(clean));
|
|
653
|
+
}
|
|
654
|
+
function latestActivityText(line) {
|
|
655
|
+
return oneLine(line).replace(/^i (?:will|can|need to|am going to)\s+/i, "").replace(/^i(?:'m|’m| am)\s+/i, "");
|
|
656
|
+
}
|
|
657
|
+
function progressUpdateSummary(lines) {
|
|
658
|
+
const counts = /* @__PURE__ */ new Map();
|
|
659
|
+
for (const line of lines) counts.set(line.toLowerCase(), (counts.get(line.toLowerCase()) ?? 0) + 1);
|
|
660
|
+
const exactRepeatCount = Math.max(...counts.values());
|
|
661
|
+
const latest = latestActivityText(lines[lines.length - 1]);
|
|
662
|
+
const repeat = exactRepeatCount > 1 ? ` \xB7 repeated ${exactRepeatCount}\xD7` : "";
|
|
663
|
+
return `\u21BB ${lines.length} progress updates${repeat} \xB7 latest: ${latest}`;
|
|
664
|
+
}
|
|
665
|
+
function compactRecentOutputLines(recentOutput) {
|
|
666
|
+
const lines = [];
|
|
667
|
+
const noisyLines = [];
|
|
668
|
+
const otherLines = [];
|
|
669
|
+
for (const rawLine of recentOutput ?? []) {
|
|
670
|
+
const line = oneLine(rawLine);
|
|
671
|
+
if (!line || line === "(running...)") continue;
|
|
672
|
+
lines.push(line);
|
|
673
|
+
(isNoisyStatusLine(line) ? noisyLines : otherLines).push(line);
|
|
674
|
+
}
|
|
675
|
+
if (noisyLines.length >= 4 && !otherLines.some(hasLiveOutputSignal)) {
|
|
676
|
+
if (otherLines.length === 0) {
|
|
677
|
+
return [
|
|
678
|
+
progressUpdateSummary(noisyLines),
|
|
679
|
+
"pattern: repeated short status lines"
|
|
680
|
+
];
|
|
681
|
+
}
|
|
682
|
+
const visibleTail = otherLines.slice(-3);
|
|
683
|
+
const hiddenSignals2 = otherLines.slice(0, -3).filter(hasLiveOutputSignal);
|
|
684
|
+
return [
|
|
685
|
+
progressUpdateSummary(noisyLines),
|
|
686
|
+
...hiddenSignals2.length > 0 ? [`\u2026 ${hiddenSignals2.length} older signal ${hiddenSignals2.length === 1 ? "line" : "lines"}: ${hiddenSignals2.at(-1)}`] : [],
|
|
687
|
+
...visibleTail
|
|
688
|
+
].slice(0, 5);
|
|
689
|
+
}
|
|
690
|
+
if (lines.length <= 5) return lines;
|
|
691
|
+
const tail = lines.slice(-5);
|
|
692
|
+
const hiddenSignals = lines.slice(0, -5).filter(hasLiveOutputSignal);
|
|
693
|
+
if (hiddenSignals.length === 0) return tail;
|
|
694
|
+
return [
|
|
695
|
+
`\u2026 ${hiddenSignals.length} older signal ${hiddenSignals.length === 1 ? "line" : "lines"}: ${hiddenSignals.at(-1)}`,
|
|
696
|
+
...lines.slice(-4)
|
|
697
|
+
];
|
|
698
|
+
}
|
|
699
|
+
function compactWorkflowError(error) {
|
|
700
|
+
const outputMatch = error.match(/(?:^|\n)Output:\s*([\s\S]+)/);
|
|
701
|
+
if (!outputMatch) return oneLine(error);
|
|
702
|
+
const prefix = oneLine(error.slice(0, outputMatch.index)).replace(/:$/, "") || "Failed";
|
|
703
|
+
const outputLines = outputMatch[1].split(/\r?\n/).map(oneLine).filter(Boolean);
|
|
704
|
+
const allOutputLinesAreNoisy = outputLines.length > 0 && outputLines.every(isNoisyStatusLine);
|
|
705
|
+
const latest = outputLines.at(-1);
|
|
706
|
+
return allOutputLinesAreNoisy && latest ? `${prefix} \xB7 latest: ${latestActivityText(latest)}` : `${prefix} \xB7 ${oneLine(outputMatch[1] ?? "")}`;
|
|
707
|
+
}
|
|
708
|
+
var WORKFLOW_LIVE_ROW_LIMIT = 8;
|
|
709
|
+
function visibleWorkflowRows(rows) {
|
|
710
|
+
if (rows.length <= WORKFLOW_LIVE_ROW_LIMIT) return { rows, hiddenRows: 0 };
|
|
711
|
+
const selected = /* @__PURE__ */ new Set();
|
|
712
|
+
const add = (row) => {
|
|
713
|
+
if (selected.size >= WORKFLOW_LIVE_ROW_LIMIT || selected.has(row.key)) return;
|
|
714
|
+
selected.add(row.key);
|
|
715
|
+
};
|
|
716
|
+
for (const row of [...rows].reverse()) {
|
|
717
|
+
if (row.state === "failed" || row.state === "detached") add(row);
|
|
718
|
+
}
|
|
719
|
+
for (const row of [...rows].reverse()) add(row);
|
|
720
|
+
return {
|
|
721
|
+
rows: rows.filter((row) => selected.has(row.key)),
|
|
722
|
+
hiddenRows: rows.length - selected.size
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
function snapshotNowForProgress(progress) {
|
|
726
|
+
if (progress.currentToolStartedAt !== void 0 && progress.durationMs !== void 0) return progress.currentToolStartedAt + progress.durationMs;
|
|
727
|
+
return progress.lastActivityAt;
|
|
728
|
+
}
|
|
729
|
+
function renderToolArgsPreview(value, maxLength, expanded) {
|
|
730
|
+
const normalized = sanitizeDisplayText(value);
|
|
731
|
+
if (expanded || normalized.length <= maxLength) return normalized;
|
|
732
|
+
return `${truncateDisplayText(normalized, maxLength)}...`;
|
|
733
|
+
}
|
|
734
|
+
function formatCurrentToolLine(progress, availableWidth, expanded, snapshotNow) {
|
|
735
|
+
if (!progress.currentTool) return void 0;
|
|
736
|
+
const maxToolArgsLen = Math.max(50, availableWidth - 20);
|
|
737
|
+
const toolArgsPreview = progress.currentToolArgs ? renderToolArgsPreview(progress.currentToolArgs, maxToolArgsLen, expanded) : "";
|
|
738
|
+
const durationSuffix = progress.currentToolStartedAt !== void 0 && snapshotNow !== void 0 ? ` | ${formatDuration(Math.max(0, snapshotNow - progress.currentToolStartedAt))}` : "";
|
|
739
|
+
return toolArgsPreview ? `${progress.currentTool}: ${toolArgsPreview}${durationSuffix}` : `${progress.currentTool}${durationSuffix}`;
|
|
740
|
+
}
|
|
741
|
+
function buildLiveStatusLine(progress, snapshotNow) {
|
|
742
|
+
if (progress.lastActivityAt !== void 0 && snapshotNow !== void 0) return formatActivityLabel(progress.lastActivityAt, progress.activityState, snapshotNow);
|
|
743
|
+
if (progress.activityState === "needs_attention") return "needs attention";
|
|
744
|
+
if (progress.activityState === "active_long_running") return "active but long-running";
|
|
745
|
+
if (progress.lastActivityAt !== void 0) return "active";
|
|
746
|
+
return void 0;
|
|
747
|
+
}
|
|
748
|
+
function themeBold(theme, text) {
|
|
749
|
+
return theme.bold?.(text) ?? text;
|
|
750
|
+
}
|
|
751
|
+
function statJoin(theme, parts) {
|
|
752
|
+
return parts.filter(Boolean).map((part) => theme.fg("dim", part)).join(` ${theme.fg("dim", "\xB7")} `);
|
|
753
|
+
}
|
|
754
|
+
function formatTokenStat(tokens) {
|
|
755
|
+
return `${formatTokens(tokens)} token`;
|
|
756
|
+
}
|
|
757
|
+
function formatToolUseStat(count) {
|
|
758
|
+
return `${count} tool use${count === 1 ? "" : "s"}`;
|
|
759
|
+
}
|
|
760
|
+
function formatTotalCostStat(totalCost) {
|
|
761
|
+
if (!totalCost || totalCost.inputTokens === 0 && totalCost.outputTokens === 0 && totalCost.costUsd === 0) return "";
|
|
762
|
+
const parts = [];
|
|
763
|
+
if (totalCost.inputTokens) parts.push(`in:${formatTokens(totalCost.inputTokens)}`);
|
|
764
|
+
if (totalCost.outputTokens) parts.push(`out:${formatTokens(totalCost.outputTokens)}`);
|
|
765
|
+
if (totalCost.costUsd) parts.push(`$${totalCost.costUsd.toFixed(4)}`);
|
|
766
|
+
return parts.join(" ");
|
|
767
|
+
}
|
|
768
|
+
function formatProgressStats(theme, progress, includeDuration = true) {
|
|
769
|
+
if (!progress) return "";
|
|
770
|
+
const parts = [];
|
|
771
|
+
if (progress.toolCount > 0) parts.push(formatToolUseStat(progress.toolCount));
|
|
772
|
+
if (progress.tokens > 0) parts.push(formatTokenStat(progress.tokens));
|
|
773
|
+
if (includeDuration && progress.durationMs > 0) parts.push(formatDuration(progress.durationMs));
|
|
774
|
+
return statJoin(theme, parts);
|
|
775
|
+
}
|
|
776
|
+
function firstOutputLine(text) {
|
|
777
|
+
return text.split("\n").find((line) => line.trim())?.trim() ?? "";
|
|
778
|
+
}
|
|
779
|
+
function resultStatusLine(result, output) {
|
|
780
|
+
if (result.detached) return result.detachedReason ? `Detached: ${result.detachedReason}` : "Detached";
|
|
781
|
+
if (result.stopped) return "Stopped";
|
|
782
|
+
if (result.interrupted) return "Paused";
|
|
783
|
+
if (result.exitCode !== 0) return `Error: ${result.error ?? (firstOutputLine(output) || `exit ${result.exitCode}`)}`;
|
|
784
|
+
if (result.acceptance?.status && result.acceptance.status !== "not-required") return `Done \xB7 acceptance: ${result.acceptance.status}`;
|
|
785
|
+
if (hasEmptyTextOutputWithoutOutputTarget(result.task, output)) return "Done (no text output)";
|
|
786
|
+
return "Done";
|
|
787
|
+
}
|
|
788
|
+
function semanticResultPresentation(input) {
|
|
789
|
+
if (input.running) {
|
|
790
|
+
const glyph = input.frame !== void 0 ? runningGlyph((input.seed ?? 0) + input.frame) : runningGlyph(input.seed);
|
|
791
|
+
return { glyph, label: "running", tone: "accent", ...input.thinking ? { thinking: input.thinking } : {} };
|
|
792
|
+
}
|
|
793
|
+
if (input.detached) return { glyph: "\u25A0", label: "detached", tone: "warning" };
|
|
794
|
+
if (input.stopped) return { glyph: "\u25A0", label: "stopped", tone: "warning" };
|
|
795
|
+
if (input.interrupted) return { glyph: "\u25A0", label: "paused", tone: "warning" };
|
|
796
|
+
if (input.failed) return { glyph: "\u2717", label: "failed", tone: "error" };
|
|
797
|
+
if (input.partial) return { glyph: "\u25A0", label: "partial", tone: "warning" };
|
|
798
|
+
return { glyph: "\u2713", label: "completed", tone: input.completedWithoutOutput ? "warning" : "success" };
|
|
799
|
+
}
|
|
800
|
+
function hasTerminalResultFlag(result) {
|
|
801
|
+
return Boolean(result.detached || result.stopped || result.interrupted);
|
|
802
|
+
}
|
|
803
|
+
function hasTerminalResult(result) {
|
|
804
|
+
if (hasTerminalResultFlag(result)) return true;
|
|
805
|
+
const status = result.progress?.status;
|
|
806
|
+
if (status === "running" || status === "pending") return false;
|
|
807
|
+
return result.exitCode !== void 0;
|
|
808
|
+
}
|
|
809
|
+
function isResultRunning(result, status = result.progress?.status) {
|
|
810
|
+
return status === "running" && !hasTerminalResultFlag(result);
|
|
811
|
+
}
|
|
812
|
+
function detailsHaveRunningResult(details) {
|
|
813
|
+
return details.progress?.some((progress) => {
|
|
814
|
+
if (progress.status !== "running") return false;
|
|
815
|
+
const result = details.results.find((entry) => entry.progress?.index === progress.index) ?? details.results[progress.index];
|
|
816
|
+
return !result || !hasTerminalResultFlag(result);
|
|
817
|
+
}) || details.results.some((result) => isResultRunning(result)) || workflowGraphHasStatus(details, ["running"]);
|
|
818
|
+
}
|
|
819
|
+
function resultPresentation(result, output, running = isResultRunning(result), seed = progressRunningSeed(result.progress ?? result.progressSummary), frame) {
|
|
820
|
+
return semanticResultPresentation({
|
|
821
|
+
running,
|
|
822
|
+
detached: result.detached,
|
|
823
|
+
stopped: result.stopped,
|
|
824
|
+
interrupted: result.interrupted,
|
|
825
|
+
failed: result.exitCode !== 0,
|
|
826
|
+
completedWithoutOutput: hasEmptyTextOutputWithoutOutputTarget(result.task, output),
|
|
827
|
+
seed,
|
|
828
|
+
frame,
|
|
829
|
+
thinking: childThinkingLevel(result, result.progress)
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
function presentationTone(presentation, theme) {
|
|
833
|
+
return presentation.label === "running" ? runningTone(theme, presentation.thinking) : (text) => theme.fg(presentation.tone, text);
|
|
834
|
+
}
|
|
835
|
+
function resultGlyph(result, output, theme, running = isResultRunning(result), seed = progressRunningSeed(result.progress ?? result.progressSummary), frame) {
|
|
836
|
+
const presentation = resultPresentation(result, output, running, seed, frame);
|
|
837
|
+
return presentationTone(presentation, theme)(presentation.glyph);
|
|
838
|
+
}
|
|
839
|
+
function styledResultPresentation(presentation, theme) {
|
|
840
|
+
const tone = presentationTone(presentation, theme);
|
|
841
|
+
return {
|
|
842
|
+
glyph: tone(presentation.glyph),
|
|
843
|
+
label: tone(presentation.label)
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
function compactCurrentActivity(progress) {
|
|
847
|
+
const snapshotNow = snapshotNowForProgress(progress);
|
|
848
|
+
return formatCurrentToolLine(progress, getTermWidth() - 4, false, snapshotNow) ?? buildLiveStatusLine(progress, snapshotNow) ?? "thinking\u2026";
|
|
849
|
+
}
|
|
850
|
+
function textDigest(text) {
|
|
851
|
+
return createHash("sha256").update(text).digest("hex").slice(0, 16);
|
|
852
|
+
}
|
|
853
|
+
function displayTextRenderKey(text) {
|
|
854
|
+
const normalized = sanitizeDisplayText(text);
|
|
855
|
+
return [normalized.length, textDigest(normalized)];
|
|
856
|
+
}
|
|
857
|
+
function expandedStepActivityRenderKey(step) {
|
|
858
|
+
return [
|
|
859
|
+
step.recentTools?.slice(-3).map((tool) => [tool.tool, displayTextRenderKey(tool.args), tool.endMs]),
|
|
860
|
+
compactRecentOutputLines(step.recentOutput).map(displayTextRenderKey)
|
|
861
|
+
];
|
|
862
|
+
}
|
|
863
|
+
function widgetStepRenderKey(step, index, expanded = false) {
|
|
864
|
+
return [
|
|
865
|
+
step.index ?? index,
|
|
866
|
+
step.agent,
|
|
867
|
+
step.sessionName,
|
|
868
|
+
step.workflowKey,
|
|
869
|
+
step.phase,
|
|
870
|
+
step.label,
|
|
871
|
+
step.status,
|
|
872
|
+
step.activityState,
|
|
873
|
+
step.lastActivityAt,
|
|
874
|
+
step.currentTool,
|
|
875
|
+
step.currentToolArgs,
|
|
876
|
+
step.currentToolStartedAt,
|
|
877
|
+
step.currentPath,
|
|
878
|
+
step.turnCount,
|
|
879
|
+
step.toolCount,
|
|
880
|
+
step.startedAt,
|
|
881
|
+
step.endedAt,
|
|
882
|
+
step.durationMs,
|
|
883
|
+
step.tokens?.total,
|
|
884
|
+
step.model,
|
|
885
|
+
step.thinking,
|
|
886
|
+
step.context,
|
|
887
|
+
step.description,
|
|
888
|
+
step.outputName,
|
|
889
|
+
step.structured,
|
|
890
|
+
step.acceptance?.status,
|
|
891
|
+
step.acceptance?.reviewResult?.status,
|
|
892
|
+
step.review?.status,
|
|
893
|
+
step.toolBudgetBlocked,
|
|
894
|
+
step.turnBudgetExceeded,
|
|
895
|
+
step.timedOut,
|
|
896
|
+
step.stopped,
|
|
897
|
+
step.execution?.status,
|
|
898
|
+
step.execution?.error,
|
|
899
|
+
step.execution?.timedOut,
|
|
900
|
+
step.execution?.interrupted,
|
|
901
|
+
step.execution?.stopped,
|
|
902
|
+
step.execution?.detached,
|
|
903
|
+
step.watchdog?.phase,
|
|
904
|
+
unresolvedChildWatchdogBlockers(step.watchdog).length,
|
|
905
|
+
step.error,
|
|
906
|
+
expanded ? expandedStepActivityRenderKey(step) : void 0,
|
|
907
|
+
nestedRenderKey(step.children, expanded)
|
|
908
|
+
];
|
|
909
|
+
}
|
|
910
|
+
function nestedRenderKey(children, expanded = false) {
|
|
911
|
+
return (children ?? []).map((child) => [
|
|
912
|
+
child.id,
|
|
913
|
+
child.state,
|
|
914
|
+
child.agent,
|
|
915
|
+
child.sessionName,
|
|
916
|
+
child.model,
|
|
917
|
+
child.thinking,
|
|
918
|
+
child.activityState,
|
|
919
|
+
child.lastActivityAt,
|
|
920
|
+
child.currentTool,
|
|
921
|
+
child.currentToolStartedAt,
|
|
922
|
+
child.currentPath,
|
|
923
|
+
child.turnCount,
|
|
924
|
+
child.toolCount,
|
|
925
|
+
child.startedAt,
|
|
926
|
+
child.endedAt,
|
|
927
|
+
child.lastUpdate,
|
|
928
|
+
child.error,
|
|
929
|
+
child.totalTokens?.total,
|
|
930
|
+
child.steps?.map((step, index) => widgetStepRenderKey({ ...step, agent: step.agent, status: step.status }, index, expanded)),
|
|
931
|
+
nestedRenderKey(child.children, expanded)
|
|
932
|
+
]);
|
|
933
|
+
}
|
|
934
|
+
function hostStepRenderKey(row) {
|
|
935
|
+
return [
|
|
936
|
+
row.kind,
|
|
937
|
+
row.name,
|
|
938
|
+
row.state,
|
|
939
|
+
row.provider,
|
|
940
|
+
row.role,
|
|
941
|
+
row.verdict,
|
|
942
|
+
row.reasonCode,
|
|
943
|
+
row.detail,
|
|
944
|
+
row.target,
|
|
945
|
+
row.freshness,
|
|
946
|
+
row.reportPath
|
|
947
|
+
];
|
|
948
|
+
}
|
|
949
|
+
function widgetRenderKey(job, expanded = false) {
|
|
950
|
+
const projection = buildWorkflowWidgetProjection(job, job.updatedAt ?? 0);
|
|
951
|
+
return JSON.stringify({
|
|
952
|
+
asyncDir: job.asyncDir,
|
|
953
|
+
parentWorkflowRunId: job.parentWorkflowRunId,
|
|
954
|
+
workflowKey: job.workflowKey,
|
|
955
|
+
status: job.status,
|
|
956
|
+
description: job.mode === "workflow" ? job.description : void 0,
|
|
957
|
+
activityState: job.activityState,
|
|
958
|
+
lastActivityAt: job.lastActivityAt,
|
|
959
|
+
currentTool: job.currentTool,
|
|
960
|
+
currentToolStartedAt: job.currentToolStartedAt,
|
|
961
|
+
currentPath: job.currentPath,
|
|
962
|
+
turnCount: job.turnCount,
|
|
963
|
+
toolCount: job.toolCount,
|
|
964
|
+
mode: job.mode,
|
|
965
|
+
agents: job.agents,
|
|
966
|
+
currentStep: job.currentStep,
|
|
967
|
+
chainStepCount: job.chainStepCount,
|
|
968
|
+
parallelGroups: job.parallelGroups,
|
|
969
|
+
workflowHostSteps: projectAsyncWorkflowRows([], job.hostSteps).map(hostStepRenderKey),
|
|
970
|
+
workflowGraph: job.mode === "workflow" && job.workflowGraph ? {
|
|
971
|
+
currentNodeId: job.workflowGraph.currentNodeId,
|
|
972
|
+
stages: projection.stages.map((node) => [node.id, node.status, node.agent, node.phase, node.label, node.flatIndex, node.outputName, node.structured, node.error])
|
|
973
|
+
} : void 0,
|
|
974
|
+
preflight: expanded ? job.preflight : job.preflight?.lanes.map((lane) => [lane.key, lane.mode, lane.decision, lane.claims, lane.expectedOutput]),
|
|
975
|
+
preflightWarnings: expanded ? job.workflow?.preflightWarnings : void 0,
|
|
976
|
+
checklist: projection.checklist ? {
|
|
977
|
+
total: projection.checklist.total,
|
|
978
|
+
done: projection.checklist.done,
|
|
979
|
+
running: projection.checklist.running,
|
|
980
|
+
queued: projection.checklist.queued,
|
|
981
|
+
blocked: projection.checklist.blocked,
|
|
982
|
+
failed: projection.checklist.failed,
|
|
983
|
+
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])])
|
|
984
|
+
} : void 0,
|
|
985
|
+
steps: job.steps?.map((step, index) => widgetStepRenderKey(step, index, expanded)),
|
|
986
|
+
nestedChildren: nestedRenderKey(job.nestedChildren, expanded),
|
|
987
|
+
lane: laneRenderKey(job, projection),
|
|
988
|
+
stepsTotal: job.stepsTotal,
|
|
989
|
+
runningSteps: job.runningSteps,
|
|
990
|
+
completedSteps: job.completedSteps,
|
|
991
|
+
activeParallelGroup: job.activeParallelGroup,
|
|
992
|
+
startedAt: job.startedAt,
|
|
993
|
+
updatedAt: job.updatedAt,
|
|
994
|
+
timedOut: job.timedOut,
|
|
995
|
+
stopped: job.stopped,
|
|
996
|
+
totalTokens: job.totalTokens
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
function formatWidgetAgents(agents) {
|
|
1000
|
+
const distinct = [...new Set(agents)];
|
|
1001
|
+
if (distinct.length === 1 && agents.length > 1) return `${distinct[0]} \xD7${agents.length}`;
|
|
1002
|
+
if (agents.length > 3) return `${agents.slice(0, 2).join(", ")} +${agents.length - 2} more`;
|
|
1003
|
+
return agents.join(", ");
|
|
1004
|
+
}
|
|
1005
|
+
function widgetJobName(job) {
|
|
1006
|
+
if (job.mode === "parallel") return "parallel";
|
|
1007
|
+
if (job.mode === "chain") return "chain";
|
|
1008
|
+
if (job.mode === "single" && job.agents?.length === 1) return job.agents[0];
|
|
1009
|
+
if (job.agents?.length) return formatWidgetAgents(job.agents);
|
|
1010
|
+
return job.mode ?? "subagent";
|
|
1011
|
+
}
|
|
1012
|
+
function isSingleChildAsyncJob(job) {
|
|
1013
|
+
return job.mode === "single" && job.steps?.length === 1 && shouldSuppressSingleStep(job.chainStepCount, job.stepsTotal);
|
|
1014
|
+
}
|
|
1015
|
+
function isCompletedWidgetStepStatus(status) {
|
|
1016
|
+
return status === "complete" || status === "completed";
|
|
1017
|
+
}
|
|
1018
|
+
function singleChildAgentName(job, step) {
|
|
1019
|
+
return job.agents?.length === 1 ? job.agents[0] : step.agent || widgetJobName(job);
|
|
1020
|
+
}
|
|
1021
|
+
function hasSingleChildDetailEvidence(job, step) {
|
|
1022
|
+
return Boolean(
|
|
1023
|
+
step.error?.trim() || step.execution?.error?.trim() || step.phase?.trim() || step.label?.trim() || step.workflowKey?.trim() || step.outputName?.trim() || step.lane || job.workflowKey?.trim() || job.lane || laneTraceForJob(job)?.phase?.trim() || laneTraceForJob(job)?.label?.trim() || step.timedOut || step.stopped || step.execution?.timedOut || step.execution?.interrupted || step.execution?.stopped || step.execution?.detached || job.timedOut || job.stopped || ["failed", "partial", "paused", "stopped", "detached"].includes(step.execution?.status ?? "") || step.acceptance?.status === "rejected" || step.acceptance?.reviewResult?.status === "blockers" || step.review?.status === "blockers"
|
|
1024
|
+
);
|
|
1025
|
+
}
|
|
1026
|
+
function shouldCollapseSingleChildDetails(job, step) {
|
|
1027
|
+
if (!isSingleChildAsyncJob(job) || hasSingleChildDetailEvidence(job, step)) return false;
|
|
1028
|
+
if (job.status === "running") return step.status === "running";
|
|
1029
|
+
if (job.status === "complete") return isCompletedWidgetStepStatus(step.status);
|
|
1030
|
+
return false;
|
|
1031
|
+
}
|
|
1032
|
+
function singleChildTask(job, step) {
|
|
1033
|
+
const task = compactTaskText(step.description, step.label);
|
|
1034
|
+
if (task) return task;
|
|
1035
|
+
const sessionName = step.sessionName?.trim();
|
|
1036
|
+
if (!sessionName) return void 0;
|
|
1037
|
+
const agentName = singleChildAgentName(job, step);
|
|
1038
|
+
const sessionTask = stripRepeatedAgentPrefix(sessionName, agentName);
|
|
1039
|
+
return sessionTask === agentName ? void 0 : compactTaskText(sessionTask);
|
|
1040
|
+
}
|
|
1041
|
+
function widgetActivity(job) {
|
|
1042
|
+
const facts = [];
|
|
1043
|
+
if (job.currentTool && job.currentToolStartedAt !== void 0 && job.updatedAt !== void 0) facts.push(`${job.currentTool} ${formatDuration(Math.max(0, job.updatedAt - job.currentToolStartedAt))}`);
|
|
1044
|
+
else if (job.currentTool) facts.push(job.currentTool);
|
|
1045
|
+
if (job.currentPath) facts.push(shortenPath(job.currentPath));
|
|
1046
|
+
if (job.turnCount !== void 0) facts.push(`${job.turnCount} turns`);
|
|
1047
|
+
if (job.toolCount !== void 0) facts.push(`${job.toolCount} tools`);
|
|
1048
|
+
const activity = buildLiveStatusLine(job, job.updatedAt);
|
|
1049
|
+
if (activity && facts.length) return `${activity} \xB7 ${facts.join(" \xB7 ")}`;
|
|
1050
|
+
if (activity) return activity;
|
|
1051
|
+
if (facts.length) return facts.join(" \xB7 ");
|
|
1052
|
+
if (job.status === "running") return "thinking\u2026";
|
|
1053
|
+
if (job.status === "queued") return "queued\u2026";
|
|
1054
|
+
if (job.status === "paused") return "Paused";
|
|
1055
|
+
if (job.status === "stopped") return "Stopped";
|
|
1056
|
+
if (job.status === "partial") return "Partial";
|
|
1057
|
+
if (job.status === "failed") return "Failed";
|
|
1058
|
+
return "Done";
|
|
1059
|
+
}
|
|
1060
|
+
function widgetStepRunningSeed(step, fallbackIndex) {
|
|
1061
|
+
return runningSeed(
|
|
1062
|
+
fallbackIndex,
|
|
1063
|
+
step.index,
|
|
1064
|
+
step.toolCount,
|
|
1065
|
+
step.turnCount,
|
|
1066
|
+
step.tokens?.total,
|
|
1067
|
+
step.lastActivityAt,
|
|
1068
|
+
step.currentToolStartedAt,
|
|
1069
|
+
step.durationMs
|
|
1070
|
+
);
|
|
1071
|
+
}
|
|
1072
|
+
function widgetStepsRunningSeed(steps) {
|
|
1073
|
+
let seed;
|
|
1074
|
+
for (const [index, step] of (steps ?? []).entries()) seed = runningSeed(seed, widgetStepRunningSeed(step, index));
|
|
1075
|
+
return seed;
|
|
1076
|
+
}
|
|
1077
|
+
function widgetJobRunningSeed(job) {
|
|
1078
|
+
return runningSeed(
|
|
1079
|
+
job.updatedAt,
|
|
1080
|
+
job.lastActivityAt,
|
|
1081
|
+
job.toolCount,
|
|
1082
|
+
job.turnCount,
|
|
1083
|
+
job.totalTokens?.total,
|
|
1084
|
+
job.currentStep,
|
|
1085
|
+
job.runningSteps,
|
|
1086
|
+
job.completedSteps,
|
|
1087
|
+
widgetStepsRunningSeed(job.steps)
|
|
1088
|
+
);
|
|
1089
|
+
}
|
|
1090
|
+
function widgetJobsRunningSeed(jobs) {
|
|
1091
|
+
let seed;
|
|
1092
|
+
for (const job of jobs) seed = runningSeed(seed, widgetJobRunningSeed(job));
|
|
1093
|
+
return seed;
|
|
1094
|
+
}
|
|
1095
|
+
function activeHeaderTone(theme, hasActive) {
|
|
1096
|
+
return hasActive ? runningTone(theme) : (text) => theme.fg("dim", text);
|
|
1097
|
+
}
|
|
1098
|
+
function widgetStatusGlyph(job, theme, frame) {
|
|
1099
|
+
if (job.status === "running") return runningTone(theme, job.mode === "single" ? childThinkingLevel(job.steps?.[0]) : void 0)(runningGlyph(animatedSeed(widgetJobRunningSeed(job), frame)));
|
|
1100
|
+
if (job.status === "queued") return theme.fg("muted", "\u25E6");
|
|
1101
|
+
if (job.status === "complete") return theme.fg("success", "\u2713");
|
|
1102
|
+
if (job.status === "paused") return theme.fg("warning", "\u25A0");
|
|
1103
|
+
if (job.status === "stopped") return theme.fg("warning", "\u25A0");
|
|
1104
|
+
return theme.fg("error", "\u2717");
|
|
1105
|
+
}
|
|
1106
|
+
function widgetStepGlyph(status, theme, seed, frame, thinking) {
|
|
1107
|
+
if (status === "running") return runningTone(theme, thinking)(runningGlyph(animatedSeed(seed, frame)));
|
|
1108
|
+
if (status === "complete" || status === "completed") return theme.fg("success", "\u2713");
|
|
1109
|
+
if (status === "failed") return theme.fg("error", "\u2717");
|
|
1110
|
+
if (status === "paused") return theme.fg("warning", "\u25A0");
|
|
1111
|
+
if (status === "stopped") return theme.fg("warning", "\u25A0");
|
|
1112
|
+
return theme.fg("muted", "\u25E6");
|
|
1113
|
+
}
|
|
1114
|
+
function widgetStepStatus(status, theme, thinking) {
|
|
1115
|
+
if (status === "running") return runningTone(theme, thinking)("running");
|
|
1116
|
+
if (status === "complete" || status === "completed") return theme.fg("success", "complete");
|
|
1117
|
+
if (status === "failed") return theme.fg("error", "failed");
|
|
1118
|
+
if (status === "paused") return theme.fg("warning", "paused");
|
|
1119
|
+
if (status === "stopped") return theme.fg("warning", "stopped");
|
|
1120
|
+
return theme.fg("dim", status);
|
|
1121
|
+
}
|
|
1122
|
+
function workflowChecklistStateLabel(state) {
|
|
1123
|
+
if (state === "running") return "running";
|
|
1124
|
+
if (state === "complete") return "complete";
|
|
1125
|
+
return state;
|
|
1126
|
+
}
|
|
1127
|
+
function workflowChecklistGlyph(item, theme, frame) {
|
|
1128
|
+
if (item.state === "running") return runningTone(theme, item.thinking)(runningGlyph(animatedSeed(runningSeed(item.startedAt, item.durationMs, item.toolCount, item.currentToolStartedAt), frame)));
|
|
1129
|
+
if (item.state === "complete") return theme.fg("success", "\u2713");
|
|
1130
|
+
if (item.state === "blocked") return theme.fg("error", "!");
|
|
1131
|
+
if (item.state === "failed") return theme.fg("error", "\u2717");
|
|
1132
|
+
if (item.state === "paused" || item.state === "stopped") return theme.fg("warning", "\u25A0");
|
|
1133
|
+
return theme.fg("muted", "\u25E6");
|
|
1134
|
+
}
|
|
1135
|
+
function workflowChecklistItemPriority(state) {
|
|
1136
|
+
if (state === "blocked") return 0;
|
|
1137
|
+
if (state === "failed") return 1;
|
|
1138
|
+
if (state === "running") return 2;
|
|
1139
|
+
if (state === "paused") return 3;
|
|
1140
|
+
if (state === "stopped") return 4;
|
|
1141
|
+
if (state === "queued") return 5;
|
|
1142
|
+
return 6;
|
|
1143
|
+
}
|
|
1144
|
+
function workflowChecklistItemLine(item, theme, indent, frame, includeError) {
|
|
1145
|
+
const identity = [item.label, item.agent && item.agent !== item.label ? item.agent : void 0].filter(Boolean).join(" \xB7 ");
|
|
1146
|
+
const context = contextModeBadge(theme, item.context);
|
|
1147
|
+
const state = item.state === "complete" ? "" : ` ${theme.fg("dim", `\xB7 ${workflowChecklistStateLabel(item.state)}`)}`;
|
|
1148
|
+
const details = [
|
|
1149
|
+
item.currentTool ? `${item.currentTool}${item.durationMs !== void 0 ? ` ${formatDuration(item.durationMs)}` : ""}` : void 0,
|
|
1150
|
+
!item.currentTool && item.currentPath ? shortenPath(item.currentPath) : void 0,
|
|
1151
|
+
!item.currentTool && item.durationMs !== void 0 ? formatDuration(item.durationMs) : void 0,
|
|
1152
|
+
item.toolCount !== void 0 ? `${item.toolCount} tools` : void 0,
|
|
1153
|
+
item.outputName ? `out:${item.outputName}` : void 0,
|
|
1154
|
+
includeError && item.error ? `error:${oneLine(item.error)}` : void 0
|
|
1155
|
+
].filter(Boolean).join(" \xB7 ");
|
|
1156
|
+
return `${indent}${workflowChecklistGlyph(item, theme, frame)} ${theme.bold(identity || item.key)}${context}${state}${details ? ` ${theme.fg("dim", `\xB7 ${details}`)}` : ""}`;
|
|
1157
|
+
}
|
|
1158
|
+
var COLLAPSED_WORKFLOW_PHASE_LIMIT = 4;
|
|
1159
|
+
function workflowChecklistWidgetLines(checklist, theme, indent, expanded, frame, options = {}) {
|
|
1160
|
+
if (!checklist?.total) return [];
|
|
1161
|
+
const includeSummary = options.includeSummary ?? true;
|
|
1162
|
+
const limitPhases = options.limitPhases ?? !expanded;
|
|
1163
|
+
const includeBottleneckOutput = options.includeBottleneckOutput ?? expanded;
|
|
1164
|
+
const includeItemErrors = options.includeItemErrors ?? true;
|
|
1165
|
+
const lines = includeSummary ? [`${indent}${theme.fg("dim", `Checklist ${formatWorkflowChecklistSummary(checklist)}`)}`] : [];
|
|
1166
|
+
const phases = !limitPhases || checklist.phases.length <= COLLAPSED_WORKFLOW_PHASE_LIMIT ? checklist.phases : checklist.phases.map((phase, index) => ({ phase, index })).sort((left, right) => Number(left.phase.state !== "running") - Number(right.phase.state !== "running") || Number(left.phase.state === "complete") - Number(right.phase.state === "complete") || left.index - right.index).slice(0, COLLAPSED_WORKFLOW_PHASE_LIMIT).sort((left, right) => left.index - right.index).map(({ phase }) => phase);
|
|
1167
|
+
for (const phase of phases) {
|
|
1168
|
+
const phaseItem = phase.items.find((item) => item.state === "running") ?? phase.items[0];
|
|
1169
|
+
const glyph = workflowChecklistGlyph({
|
|
1170
|
+
state: phase.state,
|
|
1171
|
+
startedAt: phaseItem?.startedAt,
|
|
1172
|
+
durationMs: phaseItem?.durationMs,
|
|
1173
|
+
toolCount: phaseItem?.toolCount,
|
|
1174
|
+
currentToolStartedAt: phaseItem?.currentToolStartedAt
|
|
1175
|
+
}, theme, frame);
|
|
1176
|
+
lines.push(`${indent}${glyph} ${theme.bold(formatWorkflowChecklistPhase(phase))}`);
|
|
1177
|
+
if (expanded) {
|
|
1178
|
+
for (const item of [...phase.items].sort((left, right) => workflowChecklistItemPriority(left.state) - workflowChecklistItemPriority(right.state))) {
|
|
1179
|
+
lines.push(workflowChecklistItemLine(item, theme, `${indent} `, frame, includeItemErrors || item.kind === "host"));
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
const bottleneck = formatWorkflowChecklistBottleneck(checklist.bottleneck, { includeOutput: includeBottleneckOutput, includeError: !expanded });
|
|
1184
|
+
if (bottleneck) {
|
|
1185
|
+
const tone = checklist.bottleneck?.state === "blocked" || checklist.bottleneck?.state === "failed" ? "error" : checklist.bottleneck?.state === "running" ? "accent" : "warning";
|
|
1186
|
+
lines.push(`${indent}${theme.fg(tone, `bottleneck \xB7 ${bottleneck}`)}`);
|
|
1187
|
+
}
|
|
1188
|
+
return lines;
|
|
1189
|
+
}
|
|
1190
|
+
function compactWorkflowLaneState(items) {
|
|
1191
|
+
let state;
|
|
1192
|
+
for (const item of items) {
|
|
1193
|
+
if (state === void 0 || workflowChecklistItemPriority(item.state) < workflowChecklistItemPriority(state)) state = item.state;
|
|
1194
|
+
}
|
|
1195
|
+
return state ?? "queued";
|
|
1196
|
+
}
|
|
1197
|
+
function compactWorkflowLaneOwner(items) {
|
|
1198
|
+
const owners = [...new Set(items.map((item) => item.agent ?? item.role).filter((value) => Boolean(value?.trim())))];
|
|
1199
|
+
if (owners.length === 0) return void 0;
|
|
1200
|
+
return boundedLaneValue(owners.length > 2 ? `${owners.slice(0, 2).join(", ")} +${owners.length - 2}` : owners.join(", "), 32);
|
|
1201
|
+
}
|
|
1202
|
+
function compactWorkflowLaneLabel(items, key) {
|
|
1203
|
+
const labels = [...new Set(items.map((item) => item.label).filter((value) => Boolean(value?.trim() && value.trim() !== key)))];
|
|
1204
|
+
if (labels.length === 0) return void 0;
|
|
1205
|
+
return boundedLaneValue(labels.length > 1 ? `${labels[0]} +${labels.length - 1}` : labels[0], 48);
|
|
1206
|
+
}
|
|
1207
|
+
function compactWorkflowLaneRow(key, items, lane = items.find((item) => item.preflight)?.preflight, fallbackState = "queued") {
|
|
1208
|
+
const state = items.length ? compactWorkflowLaneState(items) : fallbackState;
|
|
1209
|
+
const toolCounts = items.map((item) => item.toolCount).filter((value) => value !== void 0);
|
|
1210
|
+
const durations = items.map((item) => item.durationMs).filter((value) => value !== void 0);
|
|
1211
|
+
const label = compactWorkflowLaneLabel(items, key);
|
|
1212
|
+
return {
|
|
1213
|
+
key: boundedLaneValue(key, 40) ?? key,
|
|
1214
|
+
state,
|
|
1215
|
+
agent: compactWorkflowLaneOwner(items),
|
|
1216
|
+
...items.length === 1 && items[0]?.thinking ? { thinking: items[0].thinking } : {},
|
|
1217
|
+
...lane?.mode ? { mode: lane.mode } : {},
|
|
1218
|
+
...lane?.decision ? { decision: boundedLaneValue(lane.decision, 56) } : {},
|
|
1219
|
+
...lane?.claims?.length ? { claims: boundedLaneValue(lane.claims.join(", "), 56) } : {},
|
|
1220
|
+
...lane?.expectedOutput ? { expectedOutput: boundedLaneValue(lane.expectedOutput, 56) } : {},
|
|
1221
|
+
...label ? { label } : {},
|
|
1222
|
+
...toolCounts.length ? { toolUses: toolCounts.reduce((sum, value) => sum + value, 0) } : {},
|
|
1223
|
+
...durations.length ? { durationMs: Math.max(...durations) } : {}
|
|
1224
|
+
};
|
|
1225
|
+
}
|
|
1226
|
+
function compactWorkflowFallbackState(job) {
|
|
1227
|
+
if (job.activityState === "needs_attention" || job.timedOut || job.toolBudgetBlocked || job.turnBudgetExceeded) return "blocked";
|
|
1228
|
+
switch (job.status) {
|
|
1229
|
+
case "complete":
|
|
1230
|
+
return "complete";
|
|
1231
|
+
case "failed":
|
|
1232
|
+
return "failed";
|
|
1233
|
+
case "paused":
|
|
1234
|
+
return "paused";
|
|
1235
|
+
case "stopped":
|
|
1236
|
+
return "stopped";
|
|
1237
|
+
case "partial":
|
|
1238
|
+
case "rejected":
|
|
1239
|
+
return "blocked";
|
|
1240
|
+
default:
|
|
1241
|
+
return "queued";
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
function compactWorkflowLaneRows(job, checklist) {
|
|
1245
|
+
const groups = /* @__PURE__ */ new Map();
|
|
1246
|
+
for (const item of checklist?.phases.flatMap((phase) => phase.items) ?? []) {
|
|
1247
|
+
const key = item.preflight?.key ?? item.key;
|
|
1248
|
+
const group = groups.get(key);
|
|
1249
|
+
if (group) group.push(item);
|
|
1250
|
+
else groups.set(key, [item]);
|
|
1251
|
+
}
|
|
1252
|
+
const rows = [];
|
|
1253
|
+
const preflightKeys = new Set(job.preflight?.lanes.map((lane) => lane.key) ?? []);
|
|
1254
|
+
if (job.preflight?.lanes.length) {
|
|
1255
|
+
for (const lane of job.preflight.lanes) {
|
|
1256
|
+
rows.push(compactWorkflowLaneRow(lane.key, groups.get(lane.key) ?? [], lane, compactWorkflowFallbackState(job)));
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
for (const [key, items] of groups) {
|
|
1260
|
+
if (preflightKeys.has(key)) continue;
|
|
1261
|
+
rows.push(compactWorkflowLaneRow(key, items));
|
|
1262
|
+
}
|
|
1263
|
+
return rows;
|
|
1264
|
+
}
|
|
1265
|
+
function compactWorkflowLaneCounts(rows) {
|
|
1266
|
+
const counts = { total: rows.length, done: 0, active: 0, queued: 0, blocked: 0, failed: 0, paused: 0, stopped: 0 };
|
|
1267
|
+
for (const row of rows) {
|
|
1268
|
+
switch (row.state) {
|
|
1269
|
+
case "complete":
|
|
1270
|
+
counts.done++;
|
|
1271
|
+
break;
|
|
1272
|
+
case "running":
|
|
1273
|
+
counts.active++;
|
|
1274
|
+
break;
|
|
1275
|
+
case "queued":
|
|
1276
|
+
counts.queued++;
|
|
1277
|
+
break;
|
|
1278
|
+
case "blocked":
|
|
1279
|
+
counts.blocked++;
|
|
1280
|
+
break;
|
|
1281
|
+
case "failed":
|
|
1282
|
+
counts.failed++;
|
|
1283
|
+
break;
|
|
1284
|
+
case "paused":
|
|
1285
|
+
counts.paused++;
|
|
1286
|
+
break;
|
|
1287
|
+
case "stopped":
|
|
1288
|
+
counts.stopped++;
|
|
1289
|
+
break;
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
return counts;
|
|
1293
|
+
}
|
|
1294
|
+
function compactWorkflowLaneLine(row, theme, indent, frame) {
|
|
1295
|
+
const owner = row.agent && row.mode ? `${row.agent}/${row.mode}` : row.agent ?? row.mode;
|
|
1296
|
+
const state = row.state === "complete" ? void 0 : row.state === "running" ? "active" : row.state;
|
|
1297
|
+
const intent = [
|
|
1298
|
+
row.decision,
|
|
1299
|
+
row.claims,
|
|
1300
|
+
row.expectedOutput,
|
|
1301
|
+
!row.mode && row.label ? row.label : void 0
|
|
1302
|
+
].filter((value) => Boolean(value));
|
|
1303
|
+
return `${indent}${workflowChecklistGlyph({ state: row.state, durationMs: row.durationMs, toolCount: row.toolUses, thinking: row.thinking }, theme, frame)} ${theme.bold(row.key)}${owner ? ` ${theme.fg("dim", `\xB7 ${owner}`)}` : ""}${state ? ` ${theme.fg("dim", `\xB7 ${state}`)}` : ""}${intent.length ? ` ${theme.fg("dim", `\xB7 ${intent.join(" \xB7 ")}`)}` : ""}`;
|
|
1304
|
+
}
|
|
1305
|
+
function compactWorkflowShortId(job) {
|
|
1306
|
+
return job.asyncId.slice(0, 8);
|
|
1307
|
+
}
|
|
1308
|
+
function compactWorkflowDisplayLabel(job) {
|
|
1309
|
+
return boundedLaneValue(job.description, 64) ?? compactWorkflowShortId(job);
|
|
1310
|
+
}
|
|
1311
|
+
function compactWorkflowStats(job, rows, theme, projection) {
|
|
1312
|
+
const counts = compactWorkflowLaneCounts(rows);
|
|
1313
|
+
const total = counts.total || projection.stageProgress?.total || job.stepsTotal || job.agents?.length || 0;
|
|
1314
|
+
const progress = [
|
|
1315
|
+
total > 0 ? `${counts.done}/${total} done` : void 0,
|
|
1316
|
+
counts.active ? `${counts.active} active` : void 0,
|
|
1317
|
+
counts.queued ? `${counts.queued} queued` : void 0,
|
|
1318
|
+
counts.blocked ? `${counts.blocked} blocked` : void 0,
|
|
1319
|
+
counts.failed ? `${counts.failed} failed` : void 0,
|
|
1320
|
+
counts.paused ? `${counts.paused} paused` : void 0,
|
|
1321
|
+
counts.stopped ? `${counts.stopped} stopped` : void 0
|
|
1322
|
+
].filter((value) => Boolean(value));
|
|
1323
|
+
const rowToolUses = rows.map((row) => row.toolUses).filter((value) => value !== void 0);
|
|
1324
|
+
const toolUses = job.toolCount ?? (rowToolUses.length ? rowToolUses.reduce((sum, value) => sum + value, 0) : void 0);
|
|
1325
|
+
const rowDuration = rows.map((row) => row.durationMs).filter((value) => value !== void 0);
|
|
1326
|
+
const end = job.status === "running" ? projection.now : job.updatedAt;
|
|
1327
|
+
const durationMs = job.status !== "queued" && job.startedAt !== void 0 && end !== void 0 ? Math.max(0, end - job.startedAt) : job.status !== "queued" && rowDuration.length ? Math.max(...rowDuration) : void 0;
|
|
1328
|
+
return statJoin(theme, [
|
|
1329
|
+
`id: ${compactWorkflowShortId(job)}`,
|
|
1330
|
+
...progress,
|
|
1331
|
+
toolUses !== void 0 ? formatToolUseStat(toolUses) : void 0,
|
|
1332
|
+
durationMs !== void 0 ? formatDuration(durationMs) : void 0
|
|
1333
|
+
].filter((value) => Boolean(value)));
|
|
1334
|
+
}
|
|
1335
|
+
function compactWorkflowBottleneck(rows, job) {
|
|
1336
|
+
let row;
|
|
1337
|
+
for (const candidate of rows) {
|
|
1338
|
+
if (candidate.state !== "blocked" && candidate.state !== "failed" && candidate.state !== "paused" && candidate.state !== "stopped") continue;
|
|
1339
|
+
if (!row || workflowChecklistItemPriority(candidate.state) < workflowChecklistItemPriority(row.state)) row = candidate;
|
|
1340
|
+
}
|
|
1341
|
+
if (row) return { text: `${row.key} \xB7 ${row.state}`, tone: row.state === "blocked" || row.state === "failed" ? "error" : "warning" };
|
|
1342
|
+
if (job.activityState === "needs_attention" || job.timedOut || job.toolBudgetBlocked || job.turnBudgetExceeded) return { text: `workflow \xB7 ${job.activityState === "needs_attention" ? "needs attention" : "blocked"}`, tone: job.activityState === "needs_attention" ? "warning" : "error" };
|
|
1343
|
+
if (job.status === "failed" || job.status === "partial" || job.status === "rejected") return { text: `workflow \xB7 ${job.status}`, tone: "error" };
|
|
1344
|
+
if (job.status === "paused" || job.status === "stopped") return { text: `workflow \xB7 ${job.status}`, tone: "warning" };
|
|
1345
|
+
return void 0;
|
|
1346
|
+
}
|
|
1347
|
+
function compactWorkflowHeaderLine(job, theme, width) {
|
|
1348
|
+
const label = compactWorkflowDisplayLabel(job);
|
|
1349
|
+
const full = `${theme.fg("toolTitle", themeBold(theme, `async workflow: ${label}`))} ${theme.fg("dim", "\u2500 background")}`;
|
|
1350
|
+
if (width === void 0 || visibleWidth2(full) <= width) return full;
|
|
1351
|
+
return `${theme.fg("toolTitle", themeBold(theme, `async workflow ${label}`))} ${theme.fg("dim", "\xB7 background")}`;
|
|
1352
|
+
}
|
|
1353
|
+
function compactWorkflowWidgetBodyLines(job, theme, frame, projection) {
|
|
1354
|
+
const rows = compactWorkflowLaneRows(job, projection.checklist);
|
|
1355
|
+
const lines = [` ${compactWorkflowStats(job, rows, theme, projection)}`];
|
|
1356
|
+
if (projection.inlineFleetCovered) return [...lines, ` ${theme.fg("dim", "Workflow children shown in Fleet roster")}`];
|
|
1357
|
+
if (rows.length) {
|
|
1358
|
+
for (const row of rows) {
|
|
1359
|
+
if (!projection.materializedKeys?.has(row.key)) lines.push(compactWorkflowLaneLine(row, theme, " ", frame));
|
|
1360
|
+
}
|
|
1361
|
+
} else {
|
|
1362
|
+
lines.push(` ${theme.fg("dim", "\u25E6 waiting for workflow lanes")}`);
|
|
1363
|
+
}
|
|
1364
|
+
const bottleneck = compactWorkflowBottleneck(rows, job);
|
|
1365
|
+
if (bottleneck) lines.push(` ${theme.fg(bottleneck.tone, `bottleneck \xB7 ${bottleneck.text}`)}`);
|
|
1366
|
+
if (job.status === "running" || rows.some((row) => row.state === "running")) lines.push(` ${theme.fg("accent", workflowDetailHintText())}`);
|
|
1367
|
+
return lines;
|
|
1368
|
+
}
|
|
1369
|
+
function widgetStepActivity(step, snapshotNow) {
|
|
1370
|
+
const facts = [];
|
|
1371
|
+
if (step.currentTool && step.currentToolStartedAt !== void 0 && snapshotNow !== void 0) facts.push(`${step.currentTool} ${formatDuration(Math.max(0, snapshotNow - step.currentToolStartedAt))}`);
|
|
1372
|
+
else if (step.currentTool) facts.push(step.currentTool);
|
|
1373
|
+
if (step.currentPath) facts.push(shortenPath(step.currentPath));
|
|
1374
|
+
if (step.turnCount !== void 0) facts.push(`${step.turnCount} turns`);
|
|
1375
|
+
if (step.toolCount !== void 0) facts.push(`${step.toolCount} tools`);
|
|
1376
|
+
if (step.tokens?.total) facts.push(formatTokenUsage(step.tokens, "token"));
|
|
1377
|
+
const activity = buildLiveStatusLine(step, snapshotNow);
|
|
1378
|
+
if (activity && facts.length) return `${activity} \xB7 ${facts.join(" \xB7 ")}`;
|
|
1379
|
+
if (activity) return activity;
|
|
1380
|
+
return facts.join(" \xB7 ");
|
|
1381
|
+
}
|
|
1382
|
+
function widgetChainDetails(job, theme, expanded = false, width = getTermWidth(), frame) {
|
|
1383
|
+
if (!job.steps?.length) return [];
|
|
1384
|
+
const total = job.chainStepCount ?? job.steps.length;
|
|
1385
|
+
const lines = [];
|
|
1386
|
+
for (const span of buildAsyncChainStepSpans(total, job.steps.length, job.parallelGroups)) {
|
|
1387
|
+
const steps = job.steps.slice(span.start, span.start + span.count);
|
|
1388
|
+
if (span.isParallel) {
|
|
1389
|
+
lines.push(...parallelWidgetGroupDetails(job, theme, { steps, total: span.count, stepIndex: span.stepIndex, chainTotal: total }, expanded, width, frame, false));
|
|
1390
|
+
continue;
|
|
1391
|
+
}
|
|
1392
|
+
const step = steps[0];
|
|
1393
|
+
if (!step) {
|
|
1394
|
+
lines.push(` ${theme.fg("dim", `\u25E6 Step ${span.stepIndex + 1}/${total}: pending`)}`);
|
|
1395
|
+
continue;
|
|
1396
|
+
}
|
|
1397
|
+
lines.push(...foregroundStyleWidgetStepLines(job, theme, step, "Step", span.stepIndex + 1, total, expanded, width, frame));
|
|
1398
|
+
}
|
|
1399
|
+
return lines;
|
|
1400
|
+
}
|
|
1401
|
+
function widgetParallelAgentDetails(job, theme, expanded = false, width = getTermWidth(), frame) {
|
|
1402
|
+
if (!job.steps?.length) return [];
|
|
1403
|
+
if (job.mode !== "parallel" && job.mode !== "chain") return [];
|
|
1404
|
+
if (job.mode === "chain" && !job.activeParallelGroup && job.parallelGroups?.length) return widgetChainDetails(job, theme, expanded, width, frame);
|
|
1405
|
+
const group = activeParallelWidgetGroup(job);
|
|
1406
|
+
if (group) return parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, Boolean(job.activeParallelGroup));
|
|
1407
|
+
const total = job.stepsTotal ?? job.steps.length;
|
|
1408
|
+
const lines = [];
|
|
1409
|
+
for (const [index, step] of job.steps.entries()) {
|
|
1410
|
+
const marker = index === job.steps.length - 1 ? "\u2514" : "\u251C";
|
|
1411
|
+
const activity = widgetStepActivity(step, job.updatedAt);
|
|
1412
|
+
const itemTitle = job.mode === "parallel" || job.activeParallelGroup ? "Agent" : "Step";
|
|
1413
|
+
const modelDisplay = modelThinkingBadge(theme, step.model, step.thinking);
|
|
1414
|
+
const label = compactTaskText(step.description, step.label);
|
|
1415
|
+
const display = step.sessionName?.trim() || (label ? `${label} (${step.agent})` : step.agent);
|
|
1416
|
+
const thinking = childThinkingLevel(step);
|
|
1417
|
+
lines.push(` ${theme.fg("dim", `${marker} ${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, index), frame, thinking)} ${itemTitle} ${index + 1}/${total}: ${display} \xB7 ${widgetStepStatus(step.status, theme, thinking)}${modelDisplay}${activity ? ` \xB7 ${activity}` : ""}`)}`);
|
|
1418
|
+
const lane = projectAsyncLane(job, step);
|
|
1419
|
+
if (lane) lines.push(...formatLaneProjectionLines(lane, theme, " "));
|
|
1420
|
+
for (const nestedLine of formatNestedWidgetLines(step.children, theme, width, expanded, job.updatedAt, expanded ? 8 : 6)) lines.push(` ${nestedLine}`);
|
|
1421
|
+
}
|
|
1422
|
+
return lines;
|
|
1423
|
+
}
|
|
1424
|
+
function parseParallelGroupAgentCount(label) {
|
|
1425
|
+
if (!label || !label.startsWith("[") || !label.endsWith("]")) return void 0;
|
|
1426
|
+
const inner = label.slice(1, -1).trim();
|
|
1427
|
+
if (!inner) return 0;
|
|
1428
|
+
return inner.split("+").map((part) => part.trim()).filter(Boolean).length;
|
|
1429
|
+
}
|
|
1430
|
+
function buildChainStepSpans(details) {
|
|
1431
|
+
if (details.workflowGraph?.nodes?.length) {
|
|
1432
|
+
const spans2 = [];
|
|
1433
|
+
let flatCursor = 0;
|
|
1434
|
+
for (const node of details.workflowGraph.nodes) {
|
|
1435
|
+
if (node.stepIndex === void 0) continue;
|
|
1436
|
+
if (node.kind === "parallel-group" || node.kind === "dynamic-parallel-group") {
|
|
1437
|
+
const childFlatIndexes = (node.children ?? []).map((child) => child.flatIndex).filter((value) => typeof value === "number");
|
|
1438
|
+
const start3 = childFlatIndexes.length ? Math.min(...childFlatIndexes) : flatCursor;
|
|
1439
|
+
const count = node.children?.length ?? 0;
|
|
1440
|
+
spans2.push({ stepIndex: node.stepIndex, start: start3, count, isParallel: true, status: node.status, label: node.label, error: node.error });
|
|
1441
|
+
flatCursor = Math.max(flatCursor, start3 + count);
|
|
1442
|
+
continue;
|
|
1443
|
+
}
|
|
1444
|
+
const start2 = node.flatIndex ?? flatCursor;
|
|
1445
|
+
spans2.push({ stepIndex: node.stepIndex, start: start2, count: 1, isParallel: false, status: node.status, label: node.label, error: node.error });
|
|
1446
|
+
flatCursor = Math.max(flatCursor, start2 + 1);
|
|
1447
|
+
}
|
|
1448
|
+
if (spans2.length) return spans2.sort((left, right) => left.stepIndex - right.stepIndex);
|
|
1449
|
+
}
|
|
1450
|
+
if (!details.chainAgents?.length) return [];
|
|
1451
|
+
const spans = [];
|
|
1452
|
+
let start = 0;
|
|
1453
|
+
for (let stepIndex = 0; stepIndex < details.chainAgents.length; stepIndex++) {
|
|
1454
|
+
const label = details.chainAgents[stepIndex];
|
|
1455
|
+
const parsedCount = parseParallelGroupAgentCount(label);
|
|
1456
|
+
const count = parsedCount ?? 1;
|
|
1457
|
+
spans.push({ stepIndex, start, count, isParallel: parsedCount !== void 0 });
|
|
1458
|
+
start += count;
|
|
1459
|
+
}
|
|
1460
|
+
return spans;
|
|
1461
|
+
}
|
|
1462
|
+
function buildAsyncChainStepSpans(total, stepCount, parallelGroups = []) {
|
|
1463
|
+
const groupsByStep = /* @__PURE__ */ new Map();
|
|
1464
|
+
for (const group of parallelGroups) {
|
|
1465
|
+
if (!groupsByStep.has(group.stepIndex)) groupsByStep.set(group.stepIndex, group);
|
|
1466
|
+
}
|
|
1467
|
+
const spans = [];
|
|
1468
|
+
let flatIndex = 0;
|
|
1469
|
+
for (let stepIndex = 0; stepIndex < total; stepIndex++) {
|
|
1470
|
+
const group = groupsByStep.get(stepIndex);
|
|
1471
|
+
if (group) {
|
|
1472
|
+
spans.push({ stepIndex, start: group.start, count: group.count, isParallel: true });
|
|
1473
|
+
flatIndex = Math.max(flatIndex, group.start + group.count);
|
|
1474
|
+
continue;
|
|
1475
|
+
}
|
|
1476
|
+
spans.push({ stepIndex, start: flatIndex, count: flatIndex < stepCount ? 1 : 0, isParallel: false });
|
|
1477
|
+
flatIndex++;
|
|
1478
|
+
}
|
|
1479
|
+
return spans;
|
|
1480
|
+
}
|
|
1481
|
+
function normalizedParallelDisplayText(value) {
|
|
1482
|
+
if (!value?.trim()) return void 0;
|
|
1483
|
+
const normalized = oneLine(value);
|
|
1484
|
+
return normalized && normalized !== PROMPT_REDACTED ? normalized : void 0;
|
|
1485
|
+
}
|
|
1486
|
+
function parallelWidgetStepDisplayName(step) {
|
|
1487
|
+
const agent = normalizedParallelDisplayText(step.agent);
|
|
1488
|
+
const explicitLabel = normalizedParallelDisplayText(step.label);
|
|
1489
|
+
if (explicitLabel) {
|
|
1490
|
+
const label = compactTaskText(step.description, explicitLabel) ?? explicitLabel;
|
|
1491
|
+
return agent ? `${label} (${agent})` : label;
|
|
1492
|
+
}
|
|
1493
|
+
const sessionName = normalizedParallelDisplayText(step.sessionName);
|
|
1494
|
+
if (sessionName) {
|
|
1495
|
+
const sessionTask = stripRepeatedAgentPrefix(sessionName, agent);
|
|
1496
|
+
if (sessionTask && sessionTask !== PROMPT_REDACTED && sessionTask.toLowerCase() !== agent?.toLowerCase()) return sessionTask;
|
|
1497
|
+
}
|
|
1498
|
+
return compactTaskText(step.description) ?? agent ?? "subagent";
|
|
1499
|
+
}
|
|
1500
|
+
function parallelWidgetStepPriority(step) {
|
|
1501
|
+
if (step.status === "running" || step.activityState === "needs_attention") return 0;
|
|
1502
|
+
switch (step.status) {
|
|
1503
|
+
case "failed":
|
|
1504
|
+
case "rejected":
|
|
1505
|
+
case "partial":
|
|
1506
|
+
case "stopped":
|
|
1507
|
+
case "paused":
|
|
1508
|
+
return 1;
|
|
1509
|
+
case "complete":
|
|
1510
|
+
case "completed":
|
|
1511
|
+
return 2;
|
|
1512
|
+
default:
|
|
1513
|
+
return 3;
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
function parallelWidgetStepRows(steps, total, prioritizeActive) {
|
|
1517
|
+
const indexed = steps.map((step, index) => ({ step, index, displayName: parallelWidgetStepDisplayName(step) }));
|
|
1518
|
+
if (prioritizeActive) indexed.sort((left, right) => parallelWidgetStepPriority(left.step) - parallelWidgetStepPriority(right.step) || left.index - right.index);
|
|
1519
|
+
return withDuplicateLabelDiscriminators(indexed, total).map(({ displayName, ...row }) => row);
|
|
1520
|
+
}
|
|
1521
|
+
function activeParallelWidgetGroup(job) {
|
|
1522
|
+
const steps = job.steps ?? [];
|
|
1523
|
+
if (!steps.length) return void 0;
|
|
1524
|
+
if (job.mode === "parallel") return { steps, total: job.stepsTotal ?? steps.length };
|
|
1525
|
+
if (job.mode !== "chain" || !job.activeParallelGroup) return void 0;
|
|
1526
|
+
const chainTotal = job.chainStepCount ?? job.stepsTotal ?? steps.length;
|
|
1527
|
+
const spans = buildAsyncChainStepSpans(chainTotal, steps.length, job.parallelGroups);
|
|
1528
|
+
const currentStep = job.currentStep;
|
|
1529
|
+
const activeSpan = currentStep === void 0 ? spans.find((span) => span.isParallel) : spans.find((span) => span.isParallel && currentStep >= span.start && currentStep < span.start + span.count);
|
|
1530
|
+
return {
|
|
1531
|
+
steps,
|
|
1532
|
+
total: activeSpan?.count ?? job.stepsTotal ?? steps.length,
|
|
1533
|
+
stepIndex: activeSpan?.stepIndex,
|
|
1534
|
+
chainTotal
|
|
1535
|
+
};
|
|
1536
|
+
}
|
|
1537
|
+
function parallelWidgetGroupHeader(group, theme, frame) {
|
|
1538
|
+
const status = aggregateStepStatus(group.steps);
|
|
1539
|
+
const label = group.stepIndex !== void 0 && group.chainTotal !== void 0 ? `Step ${group.stepIndex + 1}/${group.chainTotal}: parallel group` : "parallel group";
|
|
1540
|
+
return ` ${widgetStepGlyph(status, theme, widgetStepsRunningSeed(group.steps), frame)} ${themeBold(theme, label)} ${theme.fg("dim", "\xB7")} ${theme.fg("dim", formatParallelOutcome(group.steps, group.total))}`;
|
|
1541
|
+
}
|
|
1542
|
+
function parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, prioritizeActive) {
|
|
1543
|
+
const lines = [parallelWidgetGroupHeader(group, theme, frame)];
|
|
1544
|
+
const rows = parallelWidgetStepRows(group.steps, group.total, prioritizeActive);
|
|
1545
|
+
for (const [rowIndex, row] of rows.entries()) {
|
|
1546
|
+
const marker = rowIndex === rows.length - 1 && rows.length >= group.total ? "\u2514\u2500" : "\u251C\u2500";
|
|
1547
|
+
lines.push(...foregroundStyleWidgetStepLines(job, theme, row.step, "Agent", row.index + 1, group.total, expanded, width, frame, {
|
|
1548
|
+
rowLabel: row.rowLabel,
|
|
1549
|
+
rowIndent: " ",
|
|
1550
|
+
detailIndent: " ",
|
|
1551
|
+
rowMarker: marker,
|
|
1552
|
+
includeCurrentPath: true
|
|
1553
|
+
}));
|
|
1554
|
+
}
|
|
1555
|
+
for (let index = rows.length; index < group.total; index++) {
|
|
1556
|
+
const marker = index === group.total - 1 ? "\u2514\u2500" : "\u251C\u2500";
|
|
1557
|
+
lines.push(` ${marker} ${theme.fg("muted", "\u25E6")} ${theme.fg("dim", "pending")}`);
|
|
1558
|
+
}
|
|
1559
|
+
return lines;
|
|
1560
|
+
}
|
|
1561
|
+
function isDoneResult(result) {
|
|
1562
|
+
const status = result.progress?.status;
|
|
1563
|
+
if (status === "completed") return true;
|
|
1564
|
+
if (status === "running" || status === "pending") return false;
|
|
1565
|
+
if (result.interrupted || result.detached) return false;
|
|
1566
|
+
return result.exitCode === 0;
|
|
1567
|
+
}
|
|
1568
|
+
function workflowGraphHasStatus(details, statuses) {
|
|
1569
|
+
return details.workflowGraph?.nodes.some((node) => statuses.includes(node.status)) ?? false;
|
|
1570
|
+
}
|
|
1571
|
+
function chainSpanStatus(details, span) {
|
|
1572
|
+
if (span.status) return span.status;
|
|
1573
|
+
const results = details.results.slice(span.start, span.start + span.count);
|
|
1574
|
+
if (results.some((result) => isResultRunning(result))) return "running";
|
|
1575
|
+
if (results.some((result) => !hasTerminalResultFlag(result) && (result.progress?.status === "failed" || result.exitCode !== 0) && !isResultRunning(result))) return "failed";
|
|
1576
|
+
if (results.some((result) => result.stopped)) return "stopped";
|
|
1577
|
+
if (results.some((result) => result.interrupted)) return "paused";
|
|
1578
|
+
if (results.some((result) => result.detached || result.progress?.status === "detached")) return "detached";
|
|
1579
|
+
if (results.length < span.count) return "pending";
|
|
1580
|
+
if (results.length > 0 && results.every(isDoneResult)) return "completed";
|
|
1581
|
+
return "pending";
|
|
1582
|
+
}
|
|
1583
|
+
function withDuplicateForegroundLabels(entries, total) {
|
|
1584
|
+
return withDuplicateLabelDiscriminators(
|
|
1585
|
+
entries.map((entry) => ({ ...entry, index: entry.displayIndex, displayName: entry.agentName })),
|
|
1586
|
+
total
|
|
1587
|
+
).map(({ displayName, rowLabel, ...entry }) => ({
|
|
1588
|
+
...entry,
|
|
1589
|
+
rowLabel: rowLabel === displayName ? void 0 : rowLabel.slice(0, -(displayName.length + 2))
|
|
1590
|
+
}));
|
|
1591
|
+
}
|
|
1592
|
+
function buildChainRenderEntries(details, label) {
|
|
1593
|
+
if (details.mode !== "chain" || !label.hasParallelInChain || label.showActiveGroupOnly) return void 0;
|
|
1594
|
+
const entries = [];
|
|
1595
|
+
for (const span of buildChainStepSpans(details)) {
|
|
1596
|
+
if (span.isParallel) {
|
|
1597
|
+
entries.push({
|
|
1598
|
+
kind: "group",
|
|
1599
|
+
stepLabel: `Step ${span.stepIndex + 1}/${label.logicalStepCount}: parallel group`,
|
|
1600
|
+
groupLabel: span.label?.trim() || void 0,
|
|
1601
|
+
status: chainSpanStatus(details, span),
|
|
1602
|
+
error: span.error
|
|
1603
|
+
});
|
|
1604
|
+
const groupEntries = [];
|
|
1605
|
+
for (let index = span.start; index < span.start + span.count; index++) {
|
|
1606
|
+
const result = details.results[index];
|
|
1607
|
+
const localIndex = foregroundResultIndex(details, index);
|
|
1608
|
+
const displayIndex = localIndex >= span.start && localIndex < span.start + span.count ? localIndex - span.start : index - span.start;
|
|
1609
|
+
groupEntries.push({
|
|
1610
|
+
kind: "result",
|
|
1611
|
+
resultIndex: index,
|
|
1612
|
+
rowNumber: index - span.start + 1,
|
|
1613
|
+
agentName: foregroundResultDisplayName(details, index, result, `agent-${displayIndex + 1}`),
|
|
1614
|
+
displayIndex,
|
|
1615
|
+
isParallel: true
|
|
1616
|
+
});
|
|
1617
|
+
}
|
|
1618
|
+
entries.push(...withDuplicateForegroundLabels(groupEntries, span.count));
|
|
1619
|
+
continue;
|
|
1620
|
+
}
|
|
1621
|
+
for (let index = span.start; index < span.start + span.count; index++) {
|
|
1622
|
+
const result = details.results[index];
|
|
1623
|
+
entries.push({
|
|
1624
|
+
kind: "result",
|
|
1625
|
+
resultIndex: index,
|
|
1626
|
+
rowNumber: span.stepIndex + 1,
|
|
1627
|
+
rowLabel: resultRowLabel(label, span.stepIndex + 1),
|
|
1628
|
+
agentName: foregroundResultDisplayName(details, index, result, details.chainAgents?.[span.stepIndex] ?? `step-${span.stepIndex + 1}`),
|
|
1629
|
+
displayIndex: foregroundResultIndex(details, index)
|
|
1630
|
+
});
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
return entries;
|
|
1634
|
+
}
|
|
1635
|
+
function buildMultiProgressLabel(details, hasRunning) {
|
|
1636
|
+
const stepSpans = buildChainStepSpans(details);
|
|
1637
|
+
const hasParallelInChain = details.mode === "chain" && stepSpans.some((span) => span.isParallel);
|
|
1638
|
+
const activeParallelGroup = details.mode === "chain" && details.currentStepIndex !== void 0 && stepSpans.some((span) => span.stepIndex === details.currentStepIndex && span.isParallel);
|
|
1639
|
+
const itemTitle = details.mode === "parallel" || activeParallelGroup ? "Agent" : "Step";
|
|
1640
|
+
if (details.mode === "parallel") {
|
|
1641
|
+
const totalCount2 = details.totalSteps ?? details.results.length;
|
|
1642
|
+
const statuses = new Array(totalCount2).fill("pending");
|
|
1643
|
+
for (const progress of details.progress ?? []) {
|
|
1644
|
+
if (progress.index >= 0 && progress.index < totalCount2) statuses[progress.index] = progress.status;
|
|
1645
|
+
}
|
|
1646
|
+
for (let i = 0; i < details.results.length; i++) {
|
|
1647
|
+
const result = details.results[i];
|
|
1648
|
+
const progressFromArray = details.progress?.find((progress) => progress.index === i) || details.progress?.find((progress) => progress.agent === result.agent && progress.status === "running");
|
|
1649
|
+
const index = result.progress?.index ?? progressFromArray?.index ?? i;
|
|
1650
|
+
if (index < 0 || index >= totalCount2) continue;
|
|
1651
|
+
const status = result.stopped ? "stopped" : result.interrupted || result.detached ? "detached" : result.progress?.status ?? (result.exitCode === 0 ? "completed" : "failed");
|
|
1652
|
+
statuses[index] = status;
|
|
1653
|
+
}
|
|
1654
|
+
const running = statuses.filter((status) => status === "running").length;
|
|
1655
|
+
const done2 = statuses.filter((status) => status === "completed").length;
|
|
1656
|
+
const headerLabel2 = hasRunning ? `${formatAgentRunningLabel(running)} \xB7 ${done2}/${totalCount2} done` : `${done2}/${totalCount2} done`;
|
|
1657
|
+
return { headerLabel: headerLabel2, itemTitle, totalCount: totalCount2, hasParallelInChain, activeParallelGroup, groupStartIndex: 0, groupEndIndex: totalCount2, showActiveGroupOnly: false, logicalStepCount: totalCount2 };
|
|
1658
|
+
}
|
|
1659
|
+
if (activeParallelGroup) {
|
|
1660
|
+
const currentStepIndex = details.currentStepIndex;
|
|
1661
|
+
const span = stepSpans[currentStepIndex];
|
|
1662
|
+
const groupSize = span?.count ?? 1;
|
|
1663
|
+
const groupStart = span?.start ?? 0;
|
|
1664
|
+
const groupEnd = groupStart + groupSize;
|
|
1665
|
+
let running = 0;
|
|
1666
|
+
let done2 = 0;
|
|
1667
|
+
for (let index = groupStart; index < groupEnd; index++) {
|
|
1668
|
+
const progressEntry = details.progress?.find((progress) => progress.index === index);
|
|
1669
|
+
const resultEntry = details.results.find((result) => result.progress?.index === index) ?? details.results[index];
|
|
1670
|
+
if (progressEntry?.status === "running" && (!resultEntry || !hasTerminalResultFlag(resultEntry))) {
|
|
1671
|
+
running++;
|
|
1672
|
+
continue;
|
|
1673
|
+
}
|
|
1674
|
+
if (progressEntry?.status === "completed") {
|
|
1675
|
+
done2++;
|
|
1676
|
+
continue;
|
|
1677
|
+
}
|
|
1678
|
+
if (resultEntry && isDoneResult(resultEntry)) done2++;
|
|
1679
|
+
}
|
|
1680
|
+
const totalSteps = details.totalSteps ?? details.chainAgents?.length ?? 1;
|
|
1681
|
+
const headerLabel2 = hasRunning ? `step ${currentStepIndex + 1}/${totalSteps} \xB7 parallel group: ${formatAgentRunningLabel(running)} \xB7 ${done2}/${groupSize} done` : `step ${currentStepIndex + 1}/${totalSteps} \xB7 parallel group: ${done2}/${groupSize} done`;
|
|
1682
|
+
return { headerLabel: headerLabel2, itemTitle, totalCount: groupSize, hasParallelInChain, activeParallelGroup, groupStartIndex: groupStart, groupEndIndex: groupEnd, showActiveGroupOnly: true, logicalStepCount: totalSteps };
|
|
1683
|
+
}
|
|
1684
|
+
if (details.mode === "chain" && details.chainAgents?.length) {
|
|
1685
|
+
const totalCount2 = details.totalSteps ?? details.chainAgents.length;
|
|
1686
|
+
const doneLogical = stepSpans.filter((span) => {
|
|
1687
|
+
if (span.status && span.status !== "completed") return false;
|
|
1688
|
+
if (span.count === 0) return span.status === "completed";
|
|
1689
|
+
for (let index = span.start; index < span.start + span.count; index++) {
|
|
1690
|
+
const progressEntry = details.progress?.find((progress) => progress.index === index);
|
|
1691
|
+
const resultEntry = details.results.find((result) => result.progress?.index === index) ?? details.results[index];
|
|
1692
|
+
if (progressEntry?.status === "running" || progressEntry?.status === "pending" || progressEntry?.status === "failed") return false;
|
|
1693
|
+
if (!resultEntry || !isDoneResult(resultEntry)) return false;
|
|
1694
|
+
}
|
|
1695
|
+
return true;
|
|
1696
|
+
}).length;
|
|
1697
|
+
const currentStep2 = details.currentStepIndex !== void 0 ? details.currentStepIndex + 1 : Math.min(totalCount2, doneLogical + (hasRunning ? 1 : 0));
|
|
1698
|
+
const headerLabel2 = hasRunning ? `step ${currentStep2}/${totalCount2}` : `step ${doneLogical}/${totalCount2}`;
|
|
1699
|
+
return { headerLabel: headerLabel2, itemTitle, totalCount: totalCount2, hasParallelInChain, activeParallelGroup, groupStartIndex: 0, groupEndIndex: details.results.length, showActiveGroupOnly: false, logicalStepCount: totalCount2 };
|
|
1700
|
+
}
|
|
1701
|
+
const totalCount = details.totalSteps ?? details.results.length;
|
|
1702
|
+
const currentStep = details.currentStepIndex !== void 0 ? details.currentStepIndex + 1 : Math.min(totalCount, details.results.filter(isDoneResult).length + (hasRunning ? 1 : 0));
|
|
1703
|
+
const done = details.results.filter(isDoneResult).length;
|
|
1704
|
+
const headerLabel = hasRunning ? `step ${currentStep}/${totalCount}` : `step ${done}/${totalCount}`;
|
|
1705
|
+
return { headerLabel, itemTitle, totalCount, hasParallelInChain, activeParallelGroup, groupStartIndex: 0, groupEndIndex: details.results.length, showActiveGroupOnly: false, logicalStepCount: totalCount };
|
|
1706
|
+
}
|
|
1707
|
+
function resultRowLabel(label, stepNumber) {
|
|
1708
|
+
if (label.itemTitle === "Agent") return void 0;
|
|
1709
|
+
if (shouldSuppressSingleStep(label.logicalStepCount)) return void 0;
|
|
1710
|
+
return `Step ${stepNumber}/${label.logicalStepCount}`;
|
|
1711
|
+
}
|
|
1712
|
+
function buildForegroundResultEntries(details, label, displayStart, displayEnd, useResultsDirectly) {
|
|
1713
|
+
const fallbackLabel = label.itemTitle.toLowerCase();
|
|
1714
|
+
const entries = Array.from({ length: displayEnd - displayStart }, (_, offset) => {
|
|
1715
|
+
const index = displayStart + offset;
|
|
1716
|
+
const result = details.results[index];
|
|
1717
|
+
const stableIndex = foregroundResultIndex(details, index);
|
|
1718
|
+
const rowNumber = label.showActiveGroupOnly ? index - label.groupStartIndex + 1 : stableIndex + 1;
|
|
1719
|
+
const fallbackAgent = useResultsDirectly ? result?.agent || `${fallbackLabel}-${rowNumber}` : details.chainAgents[index] || result?.agent || `${fallbackLabel}-${rowNumber}`;
|
|
1720
|
+
const displayIndex = label.activeParallelGroup && stableIndex >= label.groupStartIndex && stableIndex < label.groupEndIndex ? stableIndex - label.groupStartIndex : label.activeParallelGroup ? index - label.groupStartIndex : stableIndex;
|
|
1721
|
+
return {
|
|
1722
|
+
kind: "result",
|
|
1723
|
+
resultIndex: index,
|
|
1724
|
+
rowNumber,
|
|
1725
|
+
rowLabel: resultRowLabel(label, rowNumber),
|
|
1726
|
+
agentName: foregroundResultDisplayName(details, index, result, fallbackAgent),
|
|
1727
|
+
displayIndex
|
|
1728
|
+
};
|
|
1729
|
+
});
|
|
1730
|
+
return label.itemTitle === "Agent" ? withDuplicateForegroundLabels(entries, label.totalCount) : entries;
|
|
1731
|
+
}
|
|
1732
|
+
function widgetStats(job, theme, projection = buildWorkflowWidgetProjection(job), collapsed = false) {
|
|
1733
|
+
const parts = [];
|
|
1734
|
+
const { stageProgress } = projection;
|
|
1735
|
+
const stepsTotal = stageProgress?.total ?? job.stepsTotal ?? (job.agents?.length ?? 1);
|
|
1736
|
+
const isSingleChild = isSingleChildAsyncJob(job);
|
|
1737
|
+
const checklistPrimary = collapsed && job.mode === "workflow" && projection.checklist !== void 0;
|
|
1738
|
+
if (checklistPrimary) {
|
|
1739
|
+
parts.push(formatWorkflowChecklistSummary(projection.checklist));
|
|
1740
|
+
} else if (stageProgress) {
|
|
1741
|
+
const currentStage = stageProgress.current !== void 0 ? projection.stages[stageProgress.current] : void 0;
|
|
1742
|
+
const focus = currentStage ? [compactTaskText(void 0, currentStage.label) ?? boundedLaneValue(currentStage.id), currentStage.agent ? boundedLaneValue(currentStage.agent) : "", workflowNodeStatusLabel(currentStage.status)].filter(Boolean) : [];
|
|
1743
|
+
parts.push(["staged lane", stageProgress.current !== void 0 ? `stage ${stageProgress.current + 1}/${stageProgress.total}` : `${stageProgress.total} stages`, ...focus].join(" \xB7 "));
|
|
1744
|
+
} else if (job.activeParallelGroup) {
|
|
1745
|
+
const running = job.runningSteps ?? (job.status === "running" ? 1 : 0);
|
|
1746
|
+
const done = job.completedSteps ?? (job.status === "complete" ? stepsTotal : 0);
|
|
1747
|
+
if (job.mode === "parallel") {
|
|
1748
|
+
if (job.status === "running" && running > 0) parts.push(formatAgentRunningLabel(running));
|
|
1749
|
+
if (stepsTotal > 0) parts.push(`${done}/${stepsTotal} done`);
|
|
1750
|
+
} else {
|
|
1751
|
+
const activeGroup = job.currentStep !== void 0 ? job.parallelGroups?.find((group) => job.currentStep >= group.start && job.currentStep < group.start + group.count) : job.parallelGroups?.find((group) => group.start === 0);
|
|
1752
|
+
const logicalStep = activeGroup?.stepIndex ?? job.currentStep ?? 0;
|
|
1753
|
+
const total = job.chainStepCount ?? stepsTotal;
|
|
1754
|
+
const groupParts = [`${done}/${stepsTotal} done`];
|
|
1755
|
+
if (job.status === "running" && running > 0) groupParts.unshift(formatAgentRunningLabel(running));
|
|
1756
|
+
parts.push(`step ${logicalStep + 1}/${total} \xB7 parallel group: ${groupParts.join(" \xB7 ")}`);
|
|
1757
|
+
}
|
|
1758
|
+
} else if (job.currentStep !== void 0) {
|
|
1759
|
+
if (job.mode === "chain") {
|
|
1760
|
+
const total = job.chainStepCount ?? stepsTotal;
|
|
1761
|
+
parts.push(`step ${flatToLogicalStepIndex(job.currentStep, total, job.parallelGroups ?? []) + 1}/${total}`);
|
|
1762
|
+
} else if (!isSingleChild) {
|
|
1763
|
+
parts.push(`step ${job.currentStep + 1}/${stepsTotal}`);
|
|
1764
|
+
}
|
|
1765
|
+
} else if (stepsTotal > 1) {
|
|
1766
|
+
parts.push(`steps ${stepsTotal}`);
|
|
1767
|
+
}
|
|
1768
|
+
if (projection.checklist && !checklistPrimary) parts.push(formatWorkflowChecklistSummary(projection.checklist));
|
|
1769
|
+
if (job.toolCount !== void 0) parts.push(formatToolUseStat(job.toolCount));
|
|
1770
|
+
if (job.totalTokens?.total) parts.push(formatTokenUsage(job.totalTokens, "token"));
|
|
1771
|
+
const end = job.status === "running" && (job.mode === "workflow" || job.parentWorkflowRunId) ? projection.now : job.updatedAt;
|
|
1772
|
+
if (job.status !== "queued" && job.startedAt !== void 0 && end !== void 0) parts.push(formatDuration(Math.max(0, end - job.startedAt)));
|
|
1773
|
+
return statJoin(theme, parts);
|
|
1774
|
+
}
|
|
1775
|
+
function widgetStepStats(theme, step, snapshotNow = Date.now()) {
|
|
1776
|
+
const externalElapsed = step.runner?.type === "external-cli" && step.externalProcess ? step.externalProcess.durationMs ?? Math.max(0, (step.externalProcess.endedAt ?? snapshotNow) - step.externalProcess.startedAt) : void 0;
|
|
1777
|
+
return statJoin(theme, [
|
|
1778
|
+
step.runner?.type === "external-cli" ? "external-cli" : "",
|
|
1779
|
+
step.turnCount !== void 0 ? `${step.turnCount} turns` : "",
|
|
1780
|
+
step.toolCount !== void 0 ? formatToolUseStat(step.toolCount) : "",
|
|
1781
|
+
step.tokens ? step.contextLimit !== void 0 ? formatContextUsage(step.tokens, step.contextLimit) ?? formatTokenUsage(step.tokens, "token") : step.tokens.total ? formatTokenUsage(step.tokens, "token") : "" : "",
|
|
1782
|
+
externalElapsed !== void 0 ? formatDuration(externalElapsed) : step.durationMs !== void 0 ? formatDuration(step.durationMs) : ""
|
|
1783
|
+
]);
|
|
1784
|
+
}
|
|
1785
|
+
function modelThinkingBadge(theme, model, thinking) {
|
|
1786
|
+
const label = formatModelThinking(model, thinking);
|
|
1787
|
+
return label ? theme.fg("dim", ` (${label})`) : "";
|
|
1788
|
+
}
|
|
1789
|
+
function widgetStepActivityLine(step, width, expanded, snapshotNow) {
|
|
1790
|
+
const toolLine = formatCurrentToolLine(step, width, expanded, snapshotNow);
|
|
1791
|
+
if (toolLine) return toolLine;
|
|
1792
|
+
const activity = buildLiveStatusLine(step, snapshotNow);
|
|
1793
|
+
if (activity) return activity;
|
|
1794
|
+
if (step.status === "running") return "thinking\u2026";
|
|
1795
|
+
return "";
|
|
1796
|
+
}
|
|
1797
|
+
function widgetOutputPath(job, step) {
|
|
1798
|
+
if (typeof step.index !== "number") return void 0;
|
|
1799
|
+
return path.join(job.asyncDir, `output-${step.index}.log`);
|
|
1800
|
+
}
|
|
1801
|
+
function nestedRunName(run) {
|
|
1802
|
+
if (run.sessionName?.trim()) return run.sessionName.trim();
|
|
1803
|
+
if (run.agent) return run.agent;
|
|
1804
|
+
if (run.agents?.length) return formatWidgetAgents(run.agents);
|
|
1805
|
+
return run.id;
|
|
1806
|
+
}
|
|
1807
|
+
function nestedStatusGlyph(state, theme, seed, thinking) {
|
|
1808
|
+
if (state === "running") return runningTone(theme, thinking)(runningGlyph(seed));
|
|
1809
|
+
if (state === "complete" || state === "completed") return theme.fg("success", "\u2713");
|
|
1810
|
+
if (state === "failed") return theme.fg("error", "\u2717");
|
|
1811
|
+
if (state === "partial") return theme.fg("warning", "\u25A0");
|
|
1812
|
+
if (state === "paused") return theme.fg("warning", "\u25A0");
|
|
1813
|
+
if (state === "stopped") return theme.fg("warning", "\u25A0");
|
|
1814
|
+
return theme.fg("muted", "\u25E6");
|
|
1815
|
+
}
|
|
1816
|
+
function nestedRunSeed(run) {
|
|
1817
|
+
return runningSeed(run.lastUpdate, run.lastActivityAt, run.currentStep, run.toolCount, run.turnCount, run.totalTokens?.total, run.currentToolStartedAt);
|
|
1818
|
+
}
|
|
1819
|
+
function formatClockTime(ms) {
|
|
1820
|
+
if (ms === void 0 || !Number.isFinite(ms)) return void 0;
|
|
1821
|
+
const date = new Date(ms);
|
|
1822
|
+
const pad = (value) => value.toString().padStart(2, "0");
|
|
1823
|
+
return `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
|
1824
|
+
}
|
|
1825
|
+
function nestedRunEventTime(run) {
|
|
1826
|
+
return run.state === "running" ? run.lastActivityAt ?? run.currentToolStartedAt ?? run.lastUpdate ?? run.startedAt : run.endedAt ?? run.lastUpdate ?? run.lastActivityAt ?? run.startedAt;
|
|
1827
|
+
}
|
|
1828
|
+
function nestedStepTimestamp(step, fallback) {
|
|
1829
|
+
return formatClockTime(step.status === "running" ? step.lastActivityAt ?? step.currentToolStartedAt ?? fallback ?? step.startedAt : step.endedAt ?? step.lastActivityAt ?? fallback ?? step.startedAt);
|
|
1830
|
+
}
|
|
1831
|
+
function nestedTimestampPrefix(timestamp) {
|
|
1832
|
+
return timestamp ? `[${timestamp}] ` : "";
|
|
1833
|
+
}
|
|
1834
|
+
function nestedActivity(input, state, snapshotNow) {
|
|
1835
|
+
const facts = [];
|
|
1836
|
+
if (input.currentTool && input.currentToolStartedAt !== void 0 && snapshotNow !== void 0) facts.push(`${input.currentTool} ${formatDuration(Math.max(0, snapshotNow - input.currentToolStartedAt))}`);
|
|
1837
|
+
else if (input.currentTool) facts.push(input.currentTool);
|
|
1838
|
+
if (input.currentPath) facts.push(shortenPath(input.currentPath));
|
|
1839
|
+
if (input.turnCount !== void 0) facts.push(`${input.turnCount} turns`);
|
|
1840
|
+
if (input.toolCount !== void 0) facts.push(`${input.toolCount} tools`);
|
|
1841
|
+
const activity = buildLiveStatusLine(input, snapshotNow);
|
|
1842
|
+
if (activity && facts.length) return `${activity} \xB7 ${facts.join(" \xB7 ")}`;
|
|
1843
|
+
if (activity) return activity;
|
|
1844
|
+
if (facts.length) return facts.join(" \xB7 ");
|
|
1845
|
+
if (state === "running") return "thinking\u2026";
|
|
1846
|
+
if (state === "queued" || state === "pending") return "queued\u2026";
|
|
1847
|
+
if (state === "paused") return "Paused";
|
|
1848
|
+
if (state === "stopped") return "Stopped";
|
|
1849
|
+
if (state === "partial") return "Partial";
|
|
1850
|
+
if (state === "failed") return "Failed";
|
|
1851
|
+
return "Done";
|
|
1852
|
+
}
|
|
1853
|
+
function formatNestedWidgetLines(children, theme, width, expanded, snapshotNow, lineBudget = expanded ? 12 : 1) {
|
|
1854
|
+
if (!children?.length || lineBudget <= 0) return [];
|
|
1855
|
+
if (!expanded) {
|
|
1856
|
+
const rows = [];
|
|
1857
|
+
const maxLeaves = 4;
|
|
1858
|
+
const maxLines = Math.min(6, lineBudget);
|
|
1859
|
+
let leaves = 0;
|
|
1860
|
+
let overflow = 0;
|
|
1861
|
+
const appendLeaf = (step, prefix, fallback) => {
|
|
1862
|
+
if (leaves >= maxLeaves) {
|
|
1863
|
+
overflow++;
|
|
1864
|
+
return;
|
|
1865
|
+
}
|
|
1866
|
+
leaves++;
|
|
1867
|
+
const state = "status" in step ? step.status : step.state;
|
|
1868
|
+
const modelThinking = formatModelThinking(step.model, step.thinking);
|
|
1869
|
+
const activity = nestedActivity(step, state, snapshotNow ?? fallback);
|
|
1870
|
+
const timestamp = "status" in step ? nestedStepTimestamp(step, fallback) : formatClockTime(nestedRunEventTime(step));
|
|
1871
|
+
const error = step.error ? ` \xB7 ${step.error}` : "";
|
|
1872
|
+
const name = "status" in step ? childDisplayName(step) : nestedRunName(step);
|
|
1873
|
+
rows.push({
|
|
1874
|
+
prefix,
|
|
1875
|
+
text: `${nestedTimestampPrefix(timestamp)}${nestedStatusGlyph(state, theme, void 0, childThinkingLevel(step))} ${name} \xB7 ${state}${modelThinking ? ` \xB7 ${modelThinking}` : ""}${activity ? ` \xB7 ${activity}` : ""}${error}`
|
|
1876
|
+
});
|
|
1877
|
+
};
|
|
1878
|
+
for (const child of children) {
|
|
1879
|
+
const steps = child.mode === "parallel" || child.mode === "chain" ? child.steps ?? [] : [];
|
|
1880
|
+
if (steps.length > 0) {
|
|
1881
|
+
const ownerModelThinking = formatModelThinking(child.model, child.thinking);
|
|
1882
|
+
const ownerActivity = nestedActivity(child, child.state, snapshotNow ?? child.lastUpdate);
|
|
1883
|
+
const ownerError = child.error ? ` \xB7 ${child.error}` : "";
|
|
1884
|
+
rows.push({
|
|
1885
|
+
prefix: "\u21B3 ",
|
|
1886
|
+
text: `OWNER ${nestedStatusGlyph(child.state, theme, nestedRunSeed(child), childThinkingLevel(child))} ${nestedRunName(child)} \xB7 ${child.state}${ownerModelThinking ? ` \xB7 ${ownerModelThinking}` : ""}${ownerActivity ? ` \xB7 ${ownerActivity}` : ""}${ownerError}`
|
|
1887
|
+
});
|
|
1888
|
+
for (const step of steps) appendLeaf(step, "\u21B3 \u2502 ", child.lastUpdate);
|
|
1889
|
+
} else {
|
|
1890
|
+
appendLeaf(child, "\u21B3 ", child.lastUpdate);
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
if (overflow > 0) rows.push({ prefix: "\u21B3 ", text: `\u2026 +${overflow} more nested leaves` });
|
|
1894
|
+
const visibleRows = rows.length <= maxLines ? rows : overflow > 0 ? [...rows.slice(0, Math.max(0, maxLines - 1)), rows.at(-1)] : rows.slice(0, maxLines);
|
|
1895
|
+
return visibleRows.map((row, index) => {
|
|
1896
|
+
const marker = index === visibleRows.length - 1 ? "\u2514\u2500" : "\u251C\u2500";
|
|
1897
|
+
const prefix = row.prefix;
|
|
1898
|
+
const text = row.text.startsWith("OWNER ") ? row.text.slice("OWNER ".length) : row.text;
|
|
1899
|
+
return truncLine(theme.fg("dim", `${prefix}${marker} ${text}`), width);
|
|
1900
|
+
});
|
|
1901
|
+
}
|
|
1902
|
+
const lines = [];
|
|
1903
|
+
const maxDepth = 2;
|
|
1904
|
+
const append = (items, depth, prefix) => {
|
|
1905
|
+
if (!items?.length || lines.length >= lineBudget) return;
|
|
1906
|
+
if (depth > maxDepth) {
|
|
1907
|
+
const aggregate = formatNestedAggregate(items);
|
|
1908
|
+
if (aggregate && lines.length < lineBudget) lines.push(theme.fg("dim", `${prefix}\u21B3 ${aggregate}`));
|
|
1909
|
+
return;
|
|
1910
|
+
}
|
|
1911
|
+
for (let index = 0; index < items.length; index++) {
|
|
1912
|
+
const child = items[index];
|
|
1913
|
+
if (lines.length >= lineBudget) {
|
|
1914
|
+
const aggregate = formatNestedAggregate(items.slice(index));
|
|
1915
|
+
if (aggregate) lines[lines.length - 1] = theme.fg("dim", `${prefix}\u21B3 ${aggregate}`);
|
|
1916
|
+
return;
|
|
1917
|
+
}
|
|
1918
|
+
const activity = nestedActivity(child, child.state, snapshotNow ?? child.lastUpdate);
|
|
1919
|
+
const error = child.error ? ` \xB7 ${child.error}` : "";
|
|
1920
|
+
const modelThinking = formatModelThinking(child.model, child.thinking);
|
|
1921
|
+
lines.push(theme.fg("dim", `${prefix}\u21B3 ${nestedTimestampPrefix(formatClockTime(nestedRunEventTime(child)))}${nestedStatusGlyph(child.state, theme, nestedRunSeed(child), childThinkingLevel(child))} ${nestedRunName(child)} \xB7 ${child.state}${modelThinking ? ` \xB7 ${modelThinking}` : ""} \xB7 ${activity}${error}`));
|
|
1922
|
+
if (depth === maxDepth) {
|
|
1923
|
+
const aggregate = formatNestedAggregate([...child.steps?.flatMap((step) => step.children ?? []) ?? [], ...child.children ?? []]);
|
|
1924
|
+
if (aggregate && lines.length < lineBudget) lines.push(theme.fg("dim", `${prefix} \u21B3 ${aggregate}`));
|
|
1925
|
+
continue;
|
|
1926
|
+
}
|
|
1927
|
+
for (const step of child.steps ?? []) {
|
|
1928
|
+
if (lines.length >= lineBudget) return;
|
|
1929
|
+
const modelThinking2 = formatModelThinking(step.model, step.thinking);
|
|
1930
|
+
lines.push(theme.fg("dim", `${prefix} \u21B3 ${nestedTimestampPrefix(nestedStepTimestamp(step, child.lastUpdate))}${nestedStatusGlyph(step.status, theme, void 0, childThinkingLevel(step))} ${childDisplayName(step)} \xB7 ${step.status}${modelThinking2 ? ` \xB7 ${modelThinking2}` : ""} \xB7 ${nestedActivity(step, step.status, snapshotNow ?? child.lastUpdate)}`));
|
|
1931
|
+
append(step.children, depth + 1, `${prefix} `);
|
|
1932
|
+
}
|
|
1933
|
+
append(child.children, depth + 1, `${prefix} `);
|
|
1934
|
+
}
|
|
1935
|
+
};
|
|
1936
|
+
append(children, 0, "");
|
|
1937
|
+
return lines.map((line) => truncLine(line, width));
|
|
1938
|
+
}
|
|
1939
|
+
function foregroundStyleWidgetStepLines(job, theme, step, itemTitle, index, total, expanded, width, frame, options) {
|
|
1940
|
+
const rowIndent = options?.rowIndent ?? " ";
|
|
1941
|
+
const detailIndent = options?.detailIndent ?? " ";
|
|
1942
|
+
const thinking = childThinkingLevel(step);
|
|
1943
|
+
const status = widgetStepStatus(step.status, theme, thinking);
|
|
1944
|
+
const stats = widgetStepStats(theme, step, job.updatedAt);
|
|
1945
|
+
const modelDisplay = modelThinkingBadge(theme, step.model, step.thinking);
|
|
1946
|
+
const collapseDetails = shouldCollapseSingleChildDetails(job, step);
|
|
1947
|
+
const displayName = collapseDetails ? singleChildAgentName(job, step) : childDisplayName(step);
|
|
1948
|
+
const stageName = itemTitle === "Stage" ? compactTaskText(void 0, step.label) ?? boundedLaneValue(step.workflowKey) ?? displayName : void 0;
|
|
1949
|
+
const stageIdentity = stageName && stageName !== displayName ? `${stageName} (${displayName})` : stageName ?? displayName;
|
|
1950
|
+
const rowLabel = collapseDetails ? displayName : options?.rowLabel ?? `${itemTitle} ${index}/${total}: ${itemTitle === "Stage" ? stageIdentity : displayName}`;
|
|
1951
|
+
const rowMarker = options?.rowMarker ? `${options.rowMarker} ` : "";
|
|
1952
|
+
const lines = [`${rowIndent}${rowMarker}${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, index - 1), frame, thinking)} ${themeBold(theme, rowLabel)}${contextModeBadge(theme, step.context)} ${theme.fg("dim", "\xB7")} ${status}${modelDisplay}${stats ? ` ${theme.fg("dim", "\xB7")} ${stats}` : ""}`];
|
|
1953
|
+
const lane = projectAsyncLane(job, step);
|
|
1954
|
+
if (lane) lines.push(...formatLaneProjectionLines(lane, theme, detailIndent));
|
|
1955
|
+
const task = collapseDetails ? singleChildTask(job, step) : compactTaskText(step.description, step.label);
|
|
1956
|
+
if (task) lines.push(`${detailIndent}${theme.fg("dim", `task: ${task}`)}`);
|
|
1957
|
+
const activity = widgetStepActivityLine(step, width, expanded, job.updatedAt);
|
|
1958
|
+
const currentPath = options?.includeCurrentPath && step.currentPath ? shortenPath(step.currentPath) : void 0;
|
|
1959
|
+
const activityWithPath = currentPath && activity && !activity.includes(currentPath) ? `${activity} \xB7 ${currentPath}` : activity ?? currentPath;
|
|
1960
|
+
if (activityWithPath) lines.push(`${detailIndent}${theme.fg("dim", `\u23BF ${activityWithPath}`)}`);
|
|
1961
|
+
for (const nestedLine of formatNestedWidgetLines(step.children, theme, width, expanded, job.updatedAt, expanded ? 12 : 6)) {
|
|
1962
|
+
lines.push(`${detailIndent}${nestedLine}`);
|
|
1963
|
+
}
|
|
1964
|
+
const error = step.error?.trim() || step.execution?.error?.trim();
|
|
1965
|
+
if (error) lines.push(`${detailIndent}${theme.fg("error", `error: ${oneLine(error)}`)}`);
|
|
1966
|
+
if (step.status === "running") {
|
|
1967
|
+
if (!expanded) lines.push(`${detailIndent}${theme.fg("accent", liveDetailHintText())}`);
|
|
1968
|
+
const output = widgetOutputPath(job, step);
|
|
1969
|
+
if (output) lines.push(`${detailIndent}${theme.fg("dim", `output: ${shortenPath(output)}`)}`);
|
|
1970
|
+
if (expanded) {
|
|
1971
|
+
const liveStatus = buildLiveStatusLine(step, job.updatedAt);
|
|
1972
|
+
if (liveStatus && liveStatus !== activity) lines.push(`${detailIndent}${theme.fg("accent", liveStatus)}`);
|
|
1973
|
+
for (const tool of step.recentTools?.slice(-3) ?? []) {
|
|
1974
|
+
const maxArgsLen = Math.max(40, width - 30);
|
|
1975
|
+
const argsPreview = renderToolArgsPreview(tool.args, maxArgsLen, expanded);
|
|
1976
|
+
lines.push(`${detailIndent} ${theme.fg("dim", `${tool.tool}${argsPreview ? `: ${argsPreview}` : ""}`)}`);
|
|
1977
|
+
}
|
|
1978
|
+
for (const line of compactRecentOutputLines(step.recentOutput)) {
|
|
1979
|
+
lines.push(`${detailIndent} ${theme.fg("dim", line)}`);
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
return lines;
|
|
1984
|
+
}
|
|
1985
|
+
function hostStepWidgetLines(job, theme, indent) {
|
|
1986
|
+
const rows = projectAsyncWorkflowRows([], job.hostSteps).filter((row) => row.kind);
|
|
1987
|
+
const visible = rows.slice(0, 8);
|
|
1988
|
+
const lines = visible.map((row) => {
|
|
1989
|
+
const state = hostStepVerdictLabel(row.state, row.verdict);
|
|
1990
|
+
const glyph = state === "running" ? theme.fg("accent", "\u25CF") : state === "pending" ? theme.fg("muted", "\u25E6") : state === "pass" ? theme.fg("success", "\u2713") : state === "fail" || state === "error" ? theme.fg("error", "\u2717") : theme.fg("warning", "\u25A0");
|
|
1991
|
+
const details = [
|
|
1992
|
+
row.provider ? `provider:${row.provider}` : void 0,
|
|
1993
|
+
row.role ? `role:${row.role}` : void 0,
|
|
1994
|
+
row.target,
|
|
1995
|
+
row.detail,
|
|
1996
|
+
row.reasonCode ? `reason:${row.reasonCode}` : void 0,
|
|
1997
|
+
row.freshness?.stale ? "stale" : row.freshness?.observedRef ? `ref:${row.freshness.observedRef}` : void 0,
|
|
1998
|
+
row.reportPath ? `out:${hostStepReportName(row.reportPath)}` : void 0
|
|
1999
|
+
].filter(Boolean).join(" \xB7 ");
|
|
2000
|
+
return `${indent}${glyph} ${row.kind}: ${row.name} \xB7 ${state}${details ? ` \xB7 ${details}` : ""}`;
|
|
2001
|
+
});
|
|
2002
|
+
if (rows.length > visible.length) lines.push(`${indent}${theme.fg("dim", `\u2026 +${rows.length - visible.length} host steps hidden`)}`);
|
|
2003
|
+
return lines;
|
|
2004
|
+
}
|
|
2005
|
+
function foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projection = buildWorkflowWidgetProjection(job)) {
|
|
2006
|
+
const steps = projection.steps.filter((step) => !projection.materializedKeys?.has(step.workflowKey ?? "") && !projection.materializedKeys?.has(step.runId ?? ""));
|
|
2007
|
+
const checklist = widgetChecklistWithoutMaterializedChildren(projection);
|
|
2008
|
+
if (!expanded && job.mode === "workflow") {
|
|
2009
|
+
return compactWorkflowWidgetBodyLines(job, theme, frame, projection);
|
|
2010
|
+
}
|
|
2011
|
+
if (!steps.length) {
|
|
2012
|
+
const lane = projectAsyncLane(job, laneStepForJob(job, steps));
|
|
2013
|
+
return [
|
|
2014
|
+
...expanded ? workflowPreflightLines(job) : [],
|
|
2015
|
+
...workflowChecklistWidgetLines(checklist, theme, " ", expanded, frame),
|
|
2016
|
+
...lane ? formatLaneProjectionLines(lane, theme, " ") : [],
|
|
2017
|
+
...hostStepWidgetLines(job, theme, " "),
|
|
2018
|
+
` ${theme.fg("dim", `\u23BF ${widgetActivity(job)}`)}`,
|
|
2019
|
+
...formatNestedWidgetLines(job.nestedChildren, theme, width, expanded, job.updatedAt, expanded ? 12 : 6).map((line) => ` ${line}`)
|
|
2020
|
+
];
|
|
2021
|
+
}
|
|
2022
|
+
if (job.mode === "chain" && !job.activeParallelGroup && job.parallelGroups?.length) return widgetChainDetails(job, theme, expanded, width, frame);
|
|
2023
|
+
const lines = [
|
|
2024
|
+
...expanded ? workflowPreflightLines(job) : [],
|
|
2025
|
+
...workflowChecklistWidgetLines(checklist, theme, " ", expanded, frame, { includeItemErrors: !expanded })
|
|
2026
|
+
];
|
|
2027
|
+
const group = activeParallelWidgetGroup(job);
|
|
2028
|
+
if (group) {
|
|
2029
|
+
lines.push(...parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, Boolean(job.activeParallelGroup)));
|
|
2030
|
+
} else {
|
|
2031
|
+
const { stageProgress, plannedKeys } = projection;
|
|
2032
|
+
const total = job.mode === "chain" ? job.chainStepCount ?? job.stepsTotal ?? steps.length : stageProgress?.total ?? job.stepsTotal ?? steps.length;
|
|
2033
|
+
const stageTotal = stageProgress?.total ?? total;
|
|
2034
|
+
const extraStepCount = plannedKeys ? steps.filter((step) => step.workflowKey === void 0 || !plannedKeys.has(step.workflowKey)).length : total;
|
|
2035
|
+
let extraStepIndex = 0;
|
|
2036
|
+
for (const [index, step] of steps.entries()) {
|
|
2037
|
+
const isPlannedStage = plannedKeys !== void 0 && step.workflowKey !== void 0 && plannedKeys.has(step.workflowKey);
|
|
2038
|
+
const itemTitle = isPlannedStage ? "Stage" : "Step";
|
|
2039
|
+
const displayIndex = isPlannedStage ? (step.index ?? index) + 1 : plannedKeys ? ++extraStepIndex : index + 1;
|
|
2040
|
+
const displayTotal = isPlannedStage ? stageTotal : extraStepCount;
|
|
2041
|
+
lines.push(...foregroundStyleWidgetStepLines(job, theme, step, itemTitle, displayIndex, displayTotal, expanded, width, frame));
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
lines.push(...hostStepWidgetLines(job, theme, " "));
|
|
2045
|
+
const attached = new Set(steps.flatMap((step) => step.children?.map((child) => child.id) ?? []));
|
|
2046
|
+
const unattached = job.nestedChildren?.filter((child) => !attached.has(child.id)) ?? [];
|
|
2047
|
+
for (const nestedLine of formatNestedWidgetLines(unattached, theme, width, expanded, job.updatedAt, expanded ? 12 : 6)) {
|
|
2048
|
+
lines.push(` ${nestedLine}`);
|
|
2049
|
+
}
|
|
2050
|
+
return lines;
|
|
2051
|
+
}
|
|
2052
|
+
function buildSingleWidgetLines(job, theme, width, expanded, frame, projection = buildWorkflowWidgetProjection(job)) {
|
|
2053
|
+
if ((!expanded || projection.inlineFleetCovered) && job.mode === "workflow") return [compactWorkflowHeaderLine(job, theme, width), ...compactWorkflowWidgetBodyLines(job, theme, frame, projection)].map((line) => truncLine(line, width));
|
|
2054
|
+
const stats = widgetStats(job, theme, projection, !expanded);
|
|
2055
|
+
const count = job.mode === "workflow" ? projection.checklist?.total ?? projection.stageProgress?.total ?? job.stepsTotal ?? job.agents?.length ?? job.steps?.length : job.mode === "chain" ? job.chainStepCount : projection.stageProgress?.total ?? job.stepsTotal ?? job.agents?.length ?? job.steps?.length;
|
|
2056
|
+
const mode = widgetJobName(job);
|
|
2057
|
+
const title = isSingleChildAsyncJob(job) ? "async subagent" : `async subagent ${mode}${count && count > 1 ? ` (${count})` : ""}`;
|
|
2058
|
+
const checklistPrimary = !expanded && job.mode === "workflow" && projection.checklist !== void 0;
|
|
2059
|
+
const collapseDetails = !checklistPrimary && job.steps?.length === 1 && shouldCollapseSingleChildDetails(job, job.steps[0]);
|
|
2060
|
+
const summary = `${widgetStatusGlyph(job, theme, frame)} ${themeBold(theme, mode)}${contextModeBadge(theme, job.context)}${stats ? ` ${theme.fg("dim", "\xB7")} ${stats}` : ""}`;
|
|
2061
|
+
return [
|
|
2062
|
+
`${theme.fg("toolTitle", themeBold(theme, title))} ${theme.fg("dim", "\xB7 background")}`,
|
|
2063
|
+
...collapseDetails ? [] : [summary],
|
|
2064
|
+
...foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projection)
|
|
2065
|
+
].map((line) => truncLine(line, width));
|
|
2066
|
+
}
|
|
2067
|
+
function compactSingleWidgetLines(job, theme, width, frame, projection = buildWorkflowWidgetProjection(job)) {
|
|
2068
|
+
const fullLines = buildSingleWidgetLines(job, theme, width, false, frame, projection);
|
|
2069
|
+
if (fullLines.length <= 10 || !job.steps?.length || job.mode !== "parallel" && !job.activeParallelGroup) return fullLines;
|
|
2070
|
+
const group = activeParallelWidgetGroup(job);
|
|
2071
|
+
if (!group) return fullLines;
|
|
2072
|
+
const rows = parallelWidgetStepRows(group.steps, group.total, Boolean(job.activeParallelGroup));
|
|
2073
|
+
const lines = fullLines.slice(0, 2);
|
|
2074
|
+
lines.push(parallelWidgetGroupHeader(group, theme, frame));
|
|
2075
|
+
for (const [rowIndex, row] of rows.entries()) {
|
|
2076
|
+
const step = row.step;
|
|
2077
|
+
const thinking = childThinkingLevel(step);
|
|
2078
|
+
const status = widgetStepStatus(step.status, theme, thinking);
|
|
2079
|
+
const activity = widgetStepActivityLine(step, width, false, job.updatedAt);
|
|
2080
|
+
const stepStats = widgetStepStats(theme, step, job.updatedAt);
|
|
2081
|
+
const activitySuffix = activity ? ` ${theme.fg("dim", "\xB7")} ${theme.fg("dim", activity)}` : "";
|
|
2082
|
+
const modelDisplay = modelThinkingBadge(theme, step.model, step.thinking);
|
|
2083
|
+
const task = compactTaskText(step.description, step.label);
|
|
2084
|
+
const taskSuffix = task ? ` ${theme.fg("dim", "\xB7")} ${theme.fg("dim", `task: ${task}`)}` : "";
|
|
2085
|
+
const marker = rowIndex === rows.length - 1 && rowIndex >= group.total - 1 ? "\u2514\u2500" : "\u251C\u2500";
|
|
2086
|
+
lines.push(` ${marker} ${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, row.index), frame, thinking)} ${themeBold(theme, row.rowLabel)}${contextModeBadge(theme, step.context)} ${theme.fg("dim", "\xB7")} ${status}${modelDisplay}${taskSuffix}${activitySuffix}${stepStats ? ` ${theme.fg("dim", "\xB7")} ${stepStats}` : ""}`);
|
|
2087
|
+
const lane = projectAsyncLane(job, step);
|
|
2088
|
+
if (lane) lines.push(...formatLaneProjectionLines(lane, theme, " "));
|
|
2089
|
+
for (const nestedLine of formatNestedWidgetLines(step.children, theme, width, false, job.updatedAt, 6)) lines.push(` ${nestedLine}`);
|
|
2090
|
+
}
|
|
2091
|
+
lines.push(...hostStepWidgetLines(job, theme, " "));
|
|
2092
|
+
if (job.steps.some((step) => step.status === "running")) lines.push(theme.fg("accent", ` ${liveDetailHintText()}`));
|
|
2093
|
+
return lines.map((line) => truncLine(line, width));
|
|
2094
|
+
}
|
|
2095
|
+
var RESERVED_NON_WIDGET_ROWS = 19;
|
|
2096
|
+
var widgetLayoutSession;
|
|
2097
|
+
function resetWidgetLayoutSession() {
|
|
2098
|
+
widgetLayoutSession = void 0;
|
|
2099
|
+
}
|
|
2100
|
+
function estimateAvailableWidgetRows() {
|
|
2101
|
+
const rows = process.stdout.rows || 30;
|
|
2102
|
+
return Math.max(1, rows - RESERVED_NON_WIDGET_ROWS);
|
|
2103
|
+
}
|
|
2104
|
+
function currentTerminalRows() {
|
|
2105
|
+
return process.stdout.rows || 30;
|
|
2106
|
+
}
|
|
2107
|
+
function currentTerminalColumns() {
|
|
2108
|
+
return process.stdout.columns || 120;
|
|
2109
|
+
}
|
|
2110
|
+
function widgetSessionMatches(expanded) {
|
|
2111
|
+
return widgetLayoutSession?.expanded === expanded && widgetLayoutSession.rows === currentTerminalRows() && widgetLayoutSession.columns === currentTerminalColumns();
|
|
2112
|
+
}
|
|
2113
|
+
function widgetHeaderCounts(jobs) {
|
|
2114
|
+
return {
|
|
2115
|
+
running: jobs.filter((job) => job.status === "running"),
|
|
2116
|
+
queued: jobs.filter((job) => job.status === "queued"),
|
|
2117
|
+
complete: jobs.filter((job) => job.status === "complete"),
|
|
2118
|
+
failed: jobs.filter((job) => job.status === "failed"),
|
|
2119
|
+
paused: jobs.filter((job) => job.status === "paused"),
|
|
2120
|
+
stopped: jobs.filter((job) => job.status === "stopped")
|
|
2121
|
+
};
|
|
2122
|
+
}
|
|
2123
|
+
var roundStateByUi = /* @__PURE__ */ new WeakMap();
|
|
2124
|
+
function trackSubagentsRound(ui, jobs, now) {
|
|
2125
|
+
const running = jobs.filter((job) => job.status === "running");
|
|
2126
|
+
if (running.length > 0) {
|
|
2127
|
+
if (!roundStateByUi.has(ui)) roundStateByUi.set(ui, { startedAt: Math.min(now, ...running.map((job) => job.startedAt ?? now)) });
|
|
2128
|
+
return;
|
|
2129
|
+
}
|
|
2130
|
+
roundStateByUi.delete(ui);
|
|
2131
|
+
}
|
|
2132
|
+
function roundElapsedSuffix(ui, now) {
|
|
2133
|
+
const state = roundStateByUi.get(ui);
|
|
2134
|
+
return state ? ` ${formatRoundElapsed(now - state.startedAt)}` : "";
|
|
2135
|
+
}
|
|
2136
|
+
function formatRoundElapsed(ms) {
|
|
2137
|
+
const total = Math.max(0, Math.floor(ms / 1e3));
|
|
2138
|
+
const hours = Math.floor(total / 3600);
|
|
2139
|
+
const minutes = Math.floor(total % 3600 / 60);
|
|
2140
|
+
const seconds = total % 60;
|
|
2141
|
+
if (hours > 0) return `${hours}h${minutes}m${seconds}s`;
|
|
2142
|
+
if (minutes > 0) return `${minutes}m${seconds}s`;
|
|
2143
|
+
return `${seconds}s`;
|
|
2144
|
+
}
|
|
2145
|
+
function buildSingleLineWidgetLines(jobs, theme, width, frame, elapsedSuffix = "") {
|
|
2146
|
+
const counts = widgetHeaderCounts(jobs);
|
|
2147
|
+
const hasActive = counts.running.length > 0 || counts.queued.length > 0;
|
|
2148
|
+
const glyph = counts.running.length > 0 ? runningGlyph(animatedSeed(widgetJobsRunningSeed(counts.running), frame)) : hasActive ? "\u25CF" : "\u25CB";
|
|
2149
|
+
const parts = [];
|
|
2150
|
+
if (counts.running.length > 0) parts.push(`${counts.running.length}/${jobs.length} running${elapsedSuffix}`);
|
|
2151
|
+
if (counts.queued.length > 0) parts.push(`${counts.queued.length} queued`);
|
|
2152
|
+
if (counts.failed.length > 0) parts.push(`${counts.failed.length} failed`);
|
|
2153
|
+
if (counts.stopped.length > 0) parts.push(`${counts.stopped.length} stopped`);
|
|
2154
|
+
if (counts.paused.length > 0) parts.push(`${counts.paused.length} paused`);
|
|
2155
|
+
for (const status of ["partial", "rejected"]) {
|
|
2156
|
+
const count = jobs.filter((job) => job.status === status).length;
|
|
2157
|
+
if (count > 0) parts.push(`${count} ${status}`);
|
|
2158
|
+
}
|
|
2159
|
+
if (!hasActive && counts.complete.length > 0) parts.push(`${counts.complete.length}/${jobs.length} done`);
|
|
2160
|
+
const tone = activeHeaderTone(theme, hasActive);
|
|
2161
|
+
return [truncLine(`${tone(glyph)} ${tone("subagents")} (${parts.join(", ") || `${jobs.length} total`})`, width)];
|
|
2162
|
+
}
|
|
2163
|
+
function orderedWidgetJobs(jobs) {
|
|
2164
|
+
return [
|
|
2165
|
+
...jobs.filter((job) => job.status === "running"),
|
|
2166
|
+
...jobs.filter((job) => job.status === "queued"),
|
|
2167
|
+
...jobs.filter((job) => job.status !== "running" && job.status !== "queued")
|
|
2168
|
+
];
|
|
2169
|
+
}
|
|
2170
|
+
function progressiveJobKey(job) {
|
|
2171
|
+
return job.asyncId;
|
|
2172
|
+
}
|
|
2173
|
+
function isProgressiveActiveJob(job) {
|
|
2174
|
+
return job?.status === "running" || job?.status === "queued";
|
|
2175
|
+
}
|
|
2176
|
+
function selectProgressiveJobKeys(jobs, previousKeys, bodyRows) {
|
|
2177
|
+
if (bodyRows <= 0) return [];
|
|
2178
|
+
const jobsByKey = new Map(jobs.map((job) => [progressiveJobKey(job), job]));
|
|
2179
|
+
const selected = [];
|
|
2180
|
+
const append = (key) => {
|
|
2181
|
+
if (selected.includes(key) || !jobsByKey.has(key)) return;
|
|
2182
|
+
selected.push(key);
|
|
2183
|
+
};
|
|
2184
|
+
for (const key of previousKeys) {
|
|
2185
|
+
if (!isProgressiveActiveJob(jobsByKey.get(key))) continue;
|
|
2186
|
+
append(key);
|
|
2187
|
+
if (selected.length >= bodyRows) return selected;
|
|
2188
|
+
}
|
|
2189
|
+
for (const job of orderedWidgetJobs(jobs)) {
|
|
2190
|
+
if (!isProgressiveActiveJob(job)) continue;
|
|
2191
|
+
const key = progressiveJobKey(job);
|
|
2192
|
+
append(key);
|
|
2193
|
+
if (selected.length >= bodyRows) break;
|
|
2194
|
+
}
|
|
2195
|
+
if (selected.length >= bodyRows) return selected;
|
|
2196
|
+
for (const key of previousKeys) {
|
|
2197
|
+
if (isProgressiveActiveJob(jobsByKey.get(key))) continue;
|
|
2198
|
+
append(key);
|
|
2199
|
+
if (selected.length >= bodyRows) return selected;
|
|
2200
|
+
}
|
|
2201
|
+
for (const job of orderedWidgetJobs(jobs)) {
|
|
2202
|
+
const key = progressiveJobKey(job);
|
|
2203
|
+
append(key);
|
|
2204
|
+
if (selected.length >= bodyRows) break;
|
|
2205
|
+
}
|
|
2206
|
+
return selected;
|
|
2207
|
+
}
|
|
2208
|
+
function runningLeafAgentCount(job, projectionFor) {
|
|
2209
|
+
if (job.mode === "workflow") return (projectionFor(job).children ?? []).reduce((total, child) => total + runningLeafAgentCount(child, projectionFor), 0);
|
|
2210
|
+
if (job.status !== "running") return 0;
|
|
2211
|
+
const sequential = job.mode === "chain" && !job.activeParallelGroup;
|
|
2212
|
+
const current = job.currentStep ?? 0;
|
|
2213
|
+
const steps = job.steps?.length ? job.steps : job.agents?.map((_, index) => ({ index, status: sequential && index !== current ? "pending" : "running" }));
|
|
2214
|
+
if (!steps?.length) return 1;
|
|
2215
|
+
return steps.filter((step, offset) => ["running", "queued", "pending"].includes(step.status) && !(step.status === "pending" && sequential && (step.index ?? offset) !== current)).length;
|
|
2216
|
+
}
|
|
2217
|
+
function progressiveHeaderLine(jobs, theme, width, frame, projectionFor) {
|
|
2218
|
+
const counts = widgetHeaderCounts(jobs);
|
|
2219
|
+
const hasActive = counts.running.length > 0 || counts.queued.length > 0;
|
|
2220
|
+
const glyph = counts.running.length > 0 ? runningGlyph(animatedSeed(widgetJobsRunningSeed(counts.running), frame)) : hasActive ? "\u25CF" : "\u25CB";
|
|
2221
|
+
const parts = [];
|
|
2222
|
+
const runningAgents = jobs.reduce((total, job) => total + runningLeafAgentCount(job, projectionFor), 0);
|
|
2223
|
+
if (runningAgents > 0) parts.push(formatAgentRunningLabel(runningAgents));
|
|
2224
|
+
if (counts.queued.length > 0) parts.push(`${counts.queued.length} queued`);
|
|
2225
|
+
if (!hasActive) {
|
|
2226
|
+
if (counts.failed.length > 0) parts.push(`${counts.failed.length} failed`);
|
|
2227
|
+
if (counts.stopped.length > 0) parts.push(`${counts.stopped.length} stopped`);
|
|
2228
|
+
if (counts.paused.length > 0) parts.push(`${counts.paused.length} paused`);
|
|
2229
|
+
if (counts.complete.length > 0) parts.push(`${counts.complete.length}/${jobs.length} done`);
|
|
2230
|
+
}
|
|
2231
|
+
const tone = activeHeaderTone(theme, hasActive);
|
|
2232
|
+
return truncLine(`${tone(glyph)} ${tone("Async agents")} ${theme.fg("dim", "\xB7")} ${theme.fg("dim", parts.join(", ") || `${jobs.length} total`)}`, width);
|
|
2233
|
+
}
|
|
2234
|
+
function progressiveJobLine(job, theme, width, frame, projection = buildWorkflowWidgetProjection(job), compactRows = job.mode === "workflow" ? compactWorkflowLaneRows(job, projection.checklist) : void 0) {
|
|
2235
|
+
const compactWorkflow = job.mode === "workflow";
|
|
2236
|
+
const stats = compactWorkflow ? compactWorkflowStats(job, compactRows ?? [], theme, projection) : widgetStats(job, theme, projection, true);
|
|
2237
|
+
if (compactWorkflow) {
|
|
2238
|
+
const bottleneck = compactWorkflowBottleneck(compactRows ?? [], job);
|
|
2239
|
+
const suffix = [stats, bottleneck ? theme.fg(bottleneck.tone, `bottleneck \xB7 ${bottleneck.text}`) : void 0].filter((value) => Boolean(value)).join(` ${theme.fg("dim", "\xB7")} `);
|
|
2240
|
+
return truncLine(` ${widgetStatusGlyph(job, theme, frame)} ${compactWorkflowHeaderLine(job, theme, Math.max(0, width - 4))}${suffix ? ` ${theme.fg("dim", "\xB7")} ${suffix}` : ""}`, width);
|
|
2241
|
+
}
|
|
2242
|
+
const activity = widgetActivity(job);
|
|
2243
|
+
const status = job.status === "complete" ? "done" : job.status;
|
|
2244
|
+
const lane = projectAsyncLane(job, laneStepForJob(job, projection.steps));
|
|
2245
|
+
const laneSummary = lane ? [lane.label ?? lane.role, lane.phase ? `phase:${lane.phase}` : void 0, lane.output ? `out:${lane.output}` : void 0, lane.workspace ? `workspace:${lane.workspace}` : `ref:${lane.ref}`].filter(Boolean).join(" \xB7 ") : "";
|
|
2246
|
+
const laneSignals = lane ? [lane.next ? `next:${lane.next}` : void 0, ...lane.chips.map((chip) => formatLaneChip(chip, theme))].filter(Boolean).join(" \xB7 ") : "";
|
|
2247
|
+
const parts = [
|
|
2248
|
+
`${themeBold(theme, widgetJobName(job))}${contextModeBadge(theme, job.context)}`,
|
|
2249
|
+
theme.fg("dim", status),
|
|
2250
|
+
laneSignals ? laneSignals : "",
|
|
2251
|
+
laneSummary ? theme.fg("dim", laneSummary) : "",
|
|
2252
|
+
stats,
|
|
2253
|
+
activity && activity.toLowerCase() !== status ? theme.fg("dim", activity) : ""
|
|
2254
|
+
].filter(Boolean);
|
|
2255
|
+
return truncLine(` ${widgetStatusGlyph(job, theme, frame)} ${parts.join(` ${theme.fg("dim", "\xB7")} `)}`, width);
|
|
2256
|
+
}
|
|
2257
|
+
function progressiveHiddenLine(hiddenJobs, theme, width) {
|
|
2258
|
+
const counts = widgetHeaderCounts(hiddenJobs);
|
|
2259
|
+
const parts = [];
|
|
2260
|
+
if (counts.running.length > 0) parts.push(`${counts.running.length} running`);
|
|
2261
|
+
if (counts.queued.length > 0) parts.push(`${counts.queued.length} queued`);
|
|
2262
|
+
const finished = counts.complete.length + counts.failed.length + counts.paused.length + counts.stopped.length;
|
|
2263
|
+
if (finished > 0) parts.push(`${finished} finished`);
|
|
2264
|
+
return truncLine(theme.fg("dim", ` +${hiddenJobs.length} more${parts.length ? ` (${parts.join(", ")})` : ""}`), width);
|
|
2265
|
+
}
|
|
2266
|
+
function buildProgressiveWidgetLines(jobs, theme, width, lockedRows, previousKeys, frame, projectionFor = workflowWidgetProjectionLookup(), elapsedSuffix = "") {
|
|
2267
|
+
const rowCount = Math.max(1, lockedRows);
|
|
2268
|
+
if (rowCount === 1) return { lines: buildSingleLineWidgetLines(jobs, theme, width, frame, elapsedSuffix), visibleJobKeys: [], contentRows: 1 };
|
|
2269
|
+
const bodyRows = rowCount - 1;
|
|
2270
|
+
let visibleJobKeys = selectProgressiveJobKeys(jobs, previousKeys, bodyRows);
|
|
2271
|
+
const jobsByKey = new Map(jobs.map((job) => [progressiveJobKey(job), job]));
|
|
2272
|
+
let visibleJobs = visibleJobKeys.map((key) => jobsByKey.get(key)).filter((job) => Boolean(job));
|
|
2273
|
+
let hiddenJobs = jobs.filter((job) => !visibleJobKeys.includes(progressiveJobKey(job)));
|
|
2274
|
+
const needsHiddenLine = hiddenJobs.length > 0;
|
|
2275
|
+
if (needsHiddenLine && visibleJobs.length >= bodyRows && bodyRows > 0) {
|
|
2276
|
+
visibleJobs = visibleJobs.slice(0, bodyRows - 1);
|
|
2277
|
+
visibleJobKeys = visibleJobs.map(progressiveJobKey);
|
|
2278
|
+
hiddenJobs = jobs.filter((job) => !visibleJobKeys.includes(progressiveJobKey(job)));
|
|
2279
|
+
}
|
|
2280
|
+
let spareRows = rowCount - 1 - visibleJobs.length - (hiddenJobs.length > 0 ? 1 : 0);
|
|
2281
|
+
const lines = [progressiveHeaderLine(jobs, theme, width, frame, projectionFor)];
|
|
2282
|
+
for (const job of visibleJobs) {
|
|
2283
|
+
const projection = projectionFor(job);
|
|
2284
|
+
const laneRows = job.mode === "workflow" ? compactWorkflowLaneRows(job, projection.checklist) : void 0;
|
|
2285
|
+
lines.push(progressiveJobLine(job, theme, width, frame, projection, laneRows));
|
|
2286
|
+
if (!laneRows || projection.inlineFleetCovered) continue;
|
|
2287
|
+
const shownLanes = laneRows.slice(0, Math.max(0, spareRows));
|
|
2288
|
+
for (const row of shownLanes) lines.push(truncLine(compactWorkflowLaneLine(row, theme, " ", frame), width));
|
|
2289
|
+
spareRows -= shownLanes.length;
|
|
2290
|
+
}
|
|
2291
|
+
if (hiddenJobs.length > 0 && lines.length < rowCount) lines.push(progressiveHiddenLine(hiddenJobs, theme, width));
|
|
2292
|
+
const contentRows = Math.min(lines.length, rowCount);
|
|
2293
|
+
while (lines.length < rowCount) lines.push(" ");
|
|
2294
|
+
return { lines: lines.slice(0, rowCount), visibleJobKeys, contentRows };
|
|
2295
|
+
}
|
|
2296
|
+
function collapsedWidgetLineBudget(rows) {
|
|
2297
|
+
return Math.max(10, Math.min(14, Math.floor(rows * 0.35)));
|
|
2298
|
+
}
|
|
2299
|
+
function paddedWidgetLine(line, width) {
|
|
2300
|
+
if (width <= 2) return " ".repeat(Math.max(0, width));
|
|
2301
|
+
const text = ` ${truncLine(line, width - 2)} `;
|
|
2302
|
+
return `${text}${" ".repeat(Math.max(0, width - visibleWidth2(text)))}`;
|
|
2303
|
+
}
|
|
2304
|
+
function fitWidgetLineBudget(lines, theme, width, expanded) {
|
|
2305
|
+
const rows = process.stdout.rows || 30;
|
|
2306
|
+
const budget = expanded ? Math.max(12, Math.min(24, Math.floor(rows * 0.55))) : collapsedWidgetLineBudget(rows);
|
|
2307
|
+
if (lines.length <= budget) return lines;
|
|
2308
|
+
const visibleLines = Math.max(1, budget - 1);
|
|
2309
|
+
const hiddenCount = lines.length - visibleLines;
|
|
2310
|
+
const hint = expanded ? `\u2026 ${hiddenCount} live-detail lines hidden` : `\u2026 ${hiddenCount} lines hidden \xB7 ${expandKeyHint("to expand")}`;
|
|
2311
|
+
return [...lines.slice(0, visibleLines), truncLine(theme.fg("dim", hint), width)];
|
|
2312
|
+
}
|
|
2313
|
+
function fitAdaptiveWidgetLines(jobs, buildLines, theme, width, expanded, frame, projectionFor, layout = "adaptive", elapsedSuffix = "") {
|
|
2314
|
+
if (expanded) {
|
|
2315
|
+
resetWidgetLayoutSession();
|
|
2316
|
+
return fitWidgetLineBudget(buildLines(), theme, width, true);
|
|
2317
|
+
}
|
|
2318
|
+
const hasMatchingSession = widgetSessionMatches(expanded);
|
|
2319
|
+
const rows = currentTerminalRows();
|
|
2320
|
+
const columns = currentTerminalColumns();
|
|
2321
|
+
const availableRows = estimateAvailableWidgetRows();
|
|
2322
|
+
if (hasMatchingSession && widgetLayoutSession?.tier === "single-line") {
|
|
2323
|
+
return buildSingleLineWidgetLines(jobs, theme, width, frame, elapsedSuffix);
|
|
2324
|
+
}
|
|
2325
|
+
if (hasMatchingSession && widgetLayoutSession?.tier === "progressive" && widgetLayoutSession.lockedRows !== void 0) {
|
|
2326
|
+
const session = widgetLayoutSession;
|
|
2327
|
+
const lockedRows2 = widgetLayoutSession.lockedRows;
|
|
2328
|
+
let rendered2 = buildProgressiveWidgetLines(jobs, theme, width, lockedRows2, session.visibleJobKeys, frame, projectionFor, elapsedSuffix);
|
|
2329
|
+
const capRows = Math.min(availableRows, collapsedWidgetLineBudget(rows));
|
|
2330
|
+
if (rendered2.visibleJobKeys.length < jobs.length && lockedRows2 < capRows) {
|
|
2331
|
+
rendered2 = buildProgressiveWidgetLines(jobs, theme, width, capRows, session.visibleJobKeys, frame, projectionFor, elapsedSuffix);
|
|
2332
|
+
session.lockedRows = Math.max(lockedRows2, rendered2.contentRows);
|
|
2333
|
+
} else if (jobs.length < (session.rootJobCount ?? 0)) {
|
|
2334
|
+
session.lockedRows = rendered2.contentRows;
|
|
2335
|
+
}
|
|
2336
|
+
session.rootJobCount = jobs.length;
|
|
2337
|
+
session.visibleJobKeys = rendered2.visibleJobKeys;
|
|
2338
|
+
return rendered2.lines.slice(0, session.lockedRows);
|
|
2339
|
+
}
|
|
2340
|
+
if (layout === "adaptive") {
|
|
2341
|
+
const lines = buildLines();
|
|
2342
|
+
if (lines.length <= availableRows) {
|
|
2343
|
+
widgetLayoutSession = { expanded, rows, columns, tier: "full", visibleJobKeys: [] };
|
|
2344
|
+
return fitWidgetLineBudget(lines, theme, width, false);
|
|
2345
|
+
}
|
|
2346
|
+
if (availableRows > 2 && jobs.length === 1 && projectionFor?.(jobs[0]).stageProgress) {
|
|
2347
|
+
widgetLayoutSession = { expanded, rows, columns, tier: "full", visibleJobKeys: [] };
|
|
2348
|
+
return fitWidgetLineBudget(lines, theme, width, false);
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2351
|
+
if (availableRows <= 2) {
|
|
2352
|
+
widgetLayoutSession = { expanded, rows, columns, tier: "single-line", visibleJobKeys: [] };
|
|
2353
|
+
return buildSingleLineWidgetLines(jobs, theme, width, frame, elapsedSuffix);
|
|
2354
|
+
}
|
|
2355
|
+
const rendered = buildProgressiveWidgetLines(jobs, theme, width, Math.min(availableRows, collapsedWidgetLineBudget(rows)), [], frame, projectionFor, elapsedSuffix);
|
|
2356
|
+
const lockedRows = rendered.contentRows;
|
|
2357
|
+
widgetLayoutSession = { expanded, rows, columns, tier: "progressive", lockedRows, rootJobCount: jobs.length, visibleJobKeys: rendered.visibleJobKeys };
|
|
2358
|
+
return rendered.lines.slice(0, lockedRows);
|
|
2359
|
+
}
|
|
2360
|
+
var asyncWidgetUpdates = /* @__PURE__ */ new WeakMap();
|
|
2361
|
+
var inlineWorkflowCoverage = /* @__PURE__ */ new WeakMap();
|
|
2362
|
+
var asyncWidgetInvalidations = /* @__PURE__ */ new WeakMap();
|
|
2363
|
+
function inlineWorkflowDescendantShape(children) {
|
|
2364
|
+
return children?.map((child) => [child.id, child.agent, inlineWorkflowDescendantShape(child.children)]);
|
|
2365
|
+
}
|
|
2366
|
+
function inlineWorkflowRowShape(job) {
|
|
2367
|
+
return [
|
|
2368
|
+
job.asyncId,
|
|
2369
|
+
job.parentWorkflowRunId,
|
|
2370
|
+
job.workflowKey,
|
|
2371
|
+
job.mode,
|
|
2372
|
+
job.currentStep,
|
|
2373
|
+
job.activeParallelGroup,
|
|
2374
|
+
job.status,
|
|
2375
|
+
job.context,
|
|
2376
|
+
job.agents,
|
|
2377
|
+
job.steps?.map((step, index) => [
|
|
2378
|
+
step.index ?? index,
|
|
2379
|
+
step.workflowKey,
|
|
2380
|
+
step.agent,
|
|
2381
|
+
step.status,
|
|
2382
|
+
Boolean(step.runner),
|
|
2383
|
+
inlineWorkflowDescendantShape(step.children)
|
|
2384
|
+
]),
|
|
2385
|
+
inlineWorkflowDescendantShape(job.nestedChildren),
|
|
2386
|
+
job.hostSteps?.map((row) => [row.id, row.monitorKind, row.label]),
|
|
2387
|
+
Boolean(job.workflowGraph)
|
|
2388
|
+
];
|
|
2389
|
+
}
|
|
2390
|
+
function inlineWorkflowRenderKey(job, children) {
|
|
2391
|
+
return JSON.stringify([inlineWorkflowRowShape(job), children.map(inlineWorkflowRowShape)]);
|
|
2392
|
+
}
|
|
2393
|
+
function setInlineWorkflowCoverage(ui, coverage) {
|
|
2394
|
+
const previous = inlineWorkflowCoverage.get(ui);
|
|
2395
|
+
if ((previous?.size ?? 0) === coverage.size && [...coverage].every(([id, key]) => previous?.get(id) === key)) return;
|
|
2396
|
+
if (coverage.size) inlineWorkflowCoverage.set(ui, coverage);
|
|
2397
|
+
else inlineWorkflowCoverage.delete(ui);
|
|
2398
|
+
asyncWidgetInvalidations.get(ui)?.();
|
|
2399
|
+
}
|
|
2400
|
+
function widgetJobTree(jobs, now) {
|
|
2401
|
+
const parents = new Map(jobs.filter((job) => job.mode === "workflow").map((job) => [job.asyncId, job]));
|
|
2402
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
2403
|
+
const roots = [];
|
|
2404
|
+
for (const job of jobs) {
|
|
2405
|
+
const parent = job.parentWorkflowRunId ? parents.get(job.parentWorkflowRunId) : void 0;
|
|
2406
|
+
const keepLiveRoot = isProgressiveActiveJob(job) && parent?.status !== "running";
|
|
2407
|
+
if (parent && parent.asyncId !== job.asyncId && !keepLiveRoot) {
|
|
2408
|
+
const children = childrenByParent.get(parent.asyncId) ?? [];
|
|
2409
|
+
children.push(job);
|
|
2410
|
+
childrenByParent.set(parent.asyncId, children);
|
|
2411
|
+
} else roots.push(job);
|
|
2412
|
+
}
|
|
2413
|
+
return { roots, projectionFor: workflowWidgetProjectionLookup(now, childrenByParent) };
|
|
2414
|
+
}
|
|
2415
|
+
function widgetChecklistWithoutMaterializedChildren(projection) {
|
|
2416
|
+
const { checklist, materializedKeys } = projection;
|
|
2417
|
+
if (!checklist || !materializedKeys) return checklist;
|
|
2418
|
+
return { ...checklist, phases: checklist.phases.map((phase) => ({ ...phase, items: phase.items.filter((item) => !materializedKeys.has(item.key)) })) };
|
|
2419
|
+
}
|
|
2420
|
+
function materializedWidgetChildLines(job, theme, width, expanded, frame, projectionFor) {
|
|
2421
|
+
const { children, inlineFleetCovered } = projectionFor(job);
|
|
2422
|
+
if (inlineFleetCovered || !children?.length) return [];
|
|
2423
|
+
const lines = [];
|
|
2424
|
+
const shown = orderedWidgetJobs(children).slice(0, MAX_WIDGET_JOBS);
|
|
2425
|
+
for (const [index, child] of shown.entries()) {
|
|
2426
|
+
const projection = projectionFor(child);
|
|
2427
|
+
const last = index === children.length - 1;
|
|
2428
|
+
const identity = child.workflowKey ?? child.asyncId;
|
|
2429
|
+
const stats = widgetStats(child, theme, projection, !expanded);
|
|
2430
|
+
lines.push(` ${last ? "\u2514\u2500" : "\u251C\u2500"} ${theme.bold(identity)} ${widgetStatusGlyph(child, theme, frame)} ${themeBold(theme, widgetJobName(child))}${contextModeBadge(theme, child.context)}${stats ? ` ${theme.fg("dim", "\xB7")} ${stats}` : ""}`);
|
|
2431
|
+
for (const detail of foregroundStyleWidgetDetails(child, theme, expanded, Math.max(0, width - 6), frame, projection)) lines.push(` ${last ? " " : "\u2502 "}${detail}`);
|
|
2432
|
+
for (const detail of materializedWidgetChildLines(child, theme, Math.max(0, width - 4), expanded, frame, projectionFor)) lines.push(` ${detail}`);
|
|
2433
|
+
}
|
|
2434
|
+
if (shown.length < children.length) lines.push(` +${children.length - shown.length} more workflow children`);
|
|
2435
|
+
return lines;
|
|
2436
|
+
}
|
|
2437
|
+
function buildWidgetComponent(jobs, ui, initiallyCollapsed = false, layout) {
|
|
2438
|
+
return (tui, theme) => {
|
|
2439
|
+
const container = new Container();
|
|
2440
|
+
let cachedRenderWidth;
|
|
2441
|
+
let cachedFrame;
|
|
2442
|
+
let cachedExpanded;
|
|
2443
|
+
let cachedLines;
|
|
2444
|
+
let cachedCoverage = "[]";
|
|
2445
|
+
let collapsed = initiallyCollapsed;
|
|
2446
|
+
const invalidate = () => {
|
|
2447
|
+
cachedLines = void 0;
|
|
2448
|
+
resetWidgetLayoutSession();
|
|
2449
|
+
tui.requestRender();
|
|
2450
|
+
};
|
|
2451
|
+
const invalidateCoverage = () => {
|
|
2452
|
+
cachedLines = void 0;
|
|
2453
|
+
tui.requestRender();
|
|
2454
|
+
};
|
|
2455
|
+
asyncWidgetInvalidations.set(ui, invalidateCoverage);
|
|
2456
|
+
const update = (nextJobs) => {
|
|
2457
|
+
jobs = nextJobs;
|
|
2458
|
+
cachedLines = void 0;
|
|
2459
|
+
tui.requestRender();
|
|
2460
|
+
};
|
|
2461
|
+
asyncWidgetUpdates.set(ui, update);
|
|
2462
|
+
const component = Object.assign(container, {
|
|
2463
|
+
// Only the mouse fields used here, without requiring newer Pi type exports.
|
|
2464
|
+
handleMouse(event) {
|
|
2465
|
+
if (event.type !== "click" || event.button !== "left" || event.y !== 0) return void 0;
|
|
2466
|
+
if (event.shift || event.alt || event.ctrl) return void 0;
|
|
2467
|
+
collapsed = !collapsed;
|
|
2468
|
+
invalidate();
|
|
2469
|
+
return { handled: true };
|
|
2470
|
+
},
|
|
2471
|
+
dispose() {
|
|
2472
|
+
if (asyncWidgetUpdates.get(ui) === update) asyncWidgetUpdates.delete(ui);
|
|
2473
|
+
if (asyncWidgetInvalidations.get(ui) === invalidateCoverage) asyncWidgetInvalidations.delete(ui);
|
|
2474
|
+
}
|
|
2475
|
+
});
|
|
2476
|
+
container.render = (renderWidth) => {
|
|
2477
|
+
const now = Date.now();
|
|
2478
|
+
const frame = Math.floor(now / WIDGET_ANIMATION_INTERVAL_MS);
|
|
2479
|
+
trackSubagentsRound(ui, jobs, now);
|
|
2480
|
+
const expanded = ui.getToolsExpanded?.() ?? false;
|
|
2481
|
+
const coverage = inlineWorkflowCoverage.get(ui);
|
|
2482
|
+
const covered = /* @__PURE__ */ new Set();
|
|
2483
|
+
if (coverage?.size) {
|
|
2484
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
2485
|
+
for (const child of jobs) {
|
|
2486
|
+
if (!child.parentWorkflowRunId) continue;
|
|
2487
|
+
const children = childrenByParent.get(child.parentWorkflowRunId) ?? [];
|
|
2488
|
+
children.push(child);
|
|
2489
|
+
childrenByParent.set(child.parentWorkflowRunId, children);
|
|
2490
|
+
}
|
|
2491
|
+
for (const job of jobs) {
|
|
2492
|
+
const snapshot = coverage.get(job.asyncId);
|
|
2493
|
+
if (snapshot === void 0) continue;
|
|
2494
|
+
const children = childrenByParent.get(job.asyncId) ?? [];
|
|
2495
|
+
if (!children.some((child) => childrenByParent.has(child.asyncId)) && snapshot === inlineWorkflowRenderKey(job, children)) covered.add(job.asyncId);
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
const coverageKey = JSON.stringify([...covered]);
|
|
2499
|
+
if (cachedLines && cachedRenderWidth === renderWidth && cachedFrame === frame && cachedExpanded === expanded && cachedCoverage === coverageKey) return cachedLines;
|
|
2500
|
+
if (cachedCoverage !== coverageKey) resetWidgetLayoutSession();
|
|
2501
|
+
cachedCoverage = coverageKey;
|
|
2502
|
+
const width = Math.max(0, renderWidth - 2);
|
|
2503
|
+
const { roots, projectionFor } = widgetJobTree(jobs, now);
|
|
2504
|
+
for (const job of roots) projectionFor(job).inlineFleetCovered = covered.has(job.asyncId);
|
|
2505
|
+
const buildLines = () => expanded ? buildWidgetLinesWithProjection(roots, theme, width, true, frame, projectionFor) : roots.length === 1 && !projectionFor(roots[0]).children?.length ? compactSingleWidgetLines(roots[0], theme, width, frame, projectionFor(roots[0])) : buildWidgetLinesWithProjection(roots, theme, width, false, frame, projectionFor);
|
|
2506
|
+
cachedRenderWidth = renderWidth;
|
|
2507
|
+
cachedFrame = frame;
|
|
2508
|
+
cachedExpanded = expanded;
|
|
2509
|
+
const elapsedSuffix = roundElapsedSuffix(ui, now);
|
|
2510
|
+
cachedLines = (collapsed ? buildSingleLineWidgetLines(jobs, theme, width, frame, elapsedSuffix) : fitAdaptiveWidgetLines(roots, buildLines, theme, width, expanded, frame, projectionFor, layout, elapsedSuffix)).map((line) => paddedWidgetLine(line, renderWidth));
|
|
2511
|
+
return cachedLines;
|
|
2512
|
+
};
|
|
2513
|
+
return component;
|
|
2514
|
+
};
|
|
2515
|
+
}
|
|
2516
|
+
function buildWidgetLinesWithProjection(jobs, theme, width = getTermWidth(), expanded = false, frame, projectionFor = workflowWidgetProjectionLookup()) {
|
|
2517
|
+
if (jobs.length === 0) return [];
|
|
2518
|
+
if (jobs.length === 1) return [
|
|
2519
|
+
...buildSingleWidgetLines(jobs[0], theme, width, expanded, frame, projectionFor(jobs[0])),
|
|
2520
|
+
...materializedWidgetChildLines(jobs[0], theme, width, expanded, frame, projectionFor).map((line) => truncLine(line, width))
|
|
2521
|
+
];
|
|
2522
|
+
const running = jobs.filter((job) => job.status === "running");
|
|
2523
|
+
const queued = jobs.filter((job) => job.status === "queued");
|
|
2524
|
+
const finished = jobs.filter((job) => job.status !== "running" && job.status !== "queued");
|
|
2525
|
+
const lines = [];
|
|
2526
|
+
const hasActive = running.length > 0 || queued.length > 0;
|
|
2527
|
+
const headerGlyph = running.length > 0 ? runningGlyph(animatedSeed(widgetJobsRunningSeed(running), frame)) : hasActive ? "\u25CF" : "\u25CB";
|
|
2528
|
+
const tone = activeHeaderTone(theme, hasActive);
|
|
2529
|
+
lines.push(truncLine(`${tone(headerGlyph)} ${tone("Async agents")} ${theme.fg("dim", "\xB7 background")}`, width));
|
|
2530
|
+
const items = [];
|
|
2531
|
+
let hiddenRunning = 0;
|
|
2532
|
+
let hiddenFinished = 0;
|
|
2533
|
+
let queuedSummaryShown = false;
|
|
2534
|
+
let slots = MAX_WIDGET_JOBS;
|
|
2535
|
+
const appendJob = (job) => {
|
|
2536
|
+
const projection = projectionFor(job);
|
|
2537
|
+
const compactWorkflow = (!expanded || projection.inlineFleetCovered) && job.mode === "workflow";
|
|
2538
|
+
const stats = compactWorkflow ? "" : widgetStats(job, theme, projection, !expanded);
|
|
2539
|
+
const details = compactWorkflow ? [
|
|
2540
|
+
...compactWorkflowWidgetBodyLines(job, theme, frame, projection)
|
|
2541
|
+
] : [
|
|
2542
|
+
` ${theme.fg("dim", `\u23BF ${widgetActivity(job)}`)}`,
|
|
2543
|
+
...widgetLaneDetailLines(job, theme, projection),
|
|
2544
|
+
...workflowChecklistWidgetLines(widgetChecklistWithoutMaterializedChildren(projection), theme, " ", expanded, frame, { includeItemErrors: !expanded || !job.steps?.length }),
|
|
2545
|
+
...widgetParallelAgentDetails(job, theme, expanded, width, frame)
|
|
2546
|
+
];
|
|
2547
|
+
items.push([
|
|
2548
|
+
compactWorkflow ? compactWorkflowHeaderLine(job, theme, width) : `${widgetStatusGlyph(job, theme, frame)} ${themeBold(theme, widgetJobName(job))}${contextModeBadge(theme, job.context)}${stats ? ` ${theme.fg("dim", "\xB7")} ${stats}` : ""}`,
|
|
2549
|
+
...details,
|
|
2550
|
+
...materializedWidgetChildLines(job, theme, width, expanded, frame, projectionFor)
|
|
2551
|
+
]);
|
|
2552
|
+
};
|
|
2553
|
+
for (const job of running) {
|
|
2554
|
+
if (slots <= 0) {
|
|
2555
|
+
hiddenRunning++;
|
|
2556
|
+
continue;
|
|
2557
|
+
}
|
|
2558
|
+
appendJob(job);
|
|
2559
|
+
slots--;
|
|
2560
|
+
}
|
|
2561
|
+
if (queued.length > 0 && slots > 0) {
|
|
2562
|
+
items.push([`${theme.fg("muted", "\u25E6")} ${theme.fg("dim", `${queued.length} queued`)}`]);
|
|
2563
|
+
queuedSummaryShown = true;
|
|
2564
|
+
slots--;
|
|
2565
|
+
}
|
|
2566
|
+
for (const job of finished) {
|
|
2567
|
+
if (slots <= 0) {
|
|
2568
|
+
hiddenFinished++;
|
|
2569
|
+
continue;
|
|
2570
|
+
}
|
|
2571
|
+
appendJob(job);
|
|
2572
|
+
slots--;
|
|
2573
|
+
}
|
|
2574
|
+
const hiddenQueued = queued.length > 0 && !queuedSummaryShown ? queued.length : 0;
|
|
2575
|
+
const hiddenTotal = hiddenRunning + hiddenFinished + hiddenQueued;
|
|
2576
|
+
if (hiddenTotal > 0) {
|
|
2577
|
+
const parts = [];
|
|
2578
|
+
if (hiddenRunning > 0) parts.push(`${hiddenRunning} running`);
|
|
2579
|
+
if (hiddenQueued > 0) parts.push(`${hiddenQueued} queued`);
|
|
2580
|
+
if (hiddenFinished > 0) parts.push(`${hiddenFinished} finished`);
|
|
2581
|
+
items.push([theme.fg("dim", `+${hiddenTotal} more (${parts.join(", ")})`)]);
|
|
2582
|
+
}
|
|
2583
|
+
for (let i = 0; i < items.length; i++) {
|
|
2584
|
+
const item = items[i];
|
|
2585
|
+
const last = i === items.length - 1;
|
|
2586
|
+
const branch = last ? "\u2514\u2500" : "\u251C\u2500";
|
|
2587
|
+
const continuation = last ? " " : "\u2502 ";
|
|
2588
|
+
lines.push(truncLine(`${theme.fg("dim", branch)} ${item[0]}`, width));
|
|
2589
|
+
for (const detail of item.slice(1)) {
|
|
2590
|
+
lines.push(truncLine(`${theme.fg("dim", continuation)} ${detail}`, width));
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
return lines;
|
|
2594
|
+
}
|
|
2595
|
+
function renderWidget(ctx, jobs, initiallyCollapsed = false, layout = "adaptive") {
|
|
2596
|
+
trackSubagentsRound(ctx.ui, jobs, Date.now());
|
|
2597
|
+
if (jobs.length === 0) {
|
|
2598
|
+
resetWidgetLayoutSession();
|
|
2599
|
+
asyncWidgetUpdates.delete(ctx.ui);
|
|
2600
|
+
if (ctx.hasUI) ctx.ui.setWidget(WIDGET_KEY, void 0);
|
|
2601
|
+
return;
|
|
2602
|
+
}
|
|
2603
|
+
if (!ctx.hasUI) return;
|
|
2604
|
+
if (ctx.mode === "rpc") {
|
|
2605
|
+
ctx.ui.setWidget(WIDGET_KEY, encodeAsyncStatusSnapshotWidget(jobs));
|
|
2606
|
+
return;
|
|
2607
|
+
}
|
|
2608
|
+
const update = asyncWidgetUpdates.get(ctx.ui);
|
|
2609
|
+
if (update) update(jobs);
|
|
2610
|
+
else ctx.ui.setWidget(WIDGET_KEY, buildWidgetComponent(jobs, ctx.ui, initiallyCollapsed, layout));
|
|
2611
|
+
}
|
|
2612
|
+
function renderSingleCompact(d, r, theme, layout, frame, foregroundDetachShortcut) {
|
|
2613
|
+
const output = r.truncation?.text || getSingleResultOutput(r);
|
|
2614
|
+
const progress = r.progress || r.progressSummary;
|
|
2615
|
+
const isRunning = isResultRunning(r);
|
|
2616
|
+
const contextBadge = contextModeBadge(theme, r.context ?? d.context);
|
|
2617
|
+
const stats = statJoin(theme, [
|
|
2618
|
+
r.usage?.turns ? `\u27F3 ${r.usage.turns}` : "",
|
|
2619
|
+
formatProgressStats(theme, progress)
|
|
2620
|
+
]);
|
|
2621
|
+
const c = new Container();
|
|
2622
|
+
const width = getTermWidth() - 4;
|
|
2623
|
+
const detailIndent = mainWindowIndent(layout, 1);
|
|
2624
|
+
const continuationIndent = mainWindowIndent(layout, 2) + (layout.horizontalSpacing > 0 ? " " : "");
|
|
2625
|
+
const modelDisplay = modelThinkingBadge(theme, r.progress?.model ?? r.model, r.thinking ?? r.progress?.thinking);
|
|
2626
|
+
c.addChild(new Text(truncLine(`${resultGlyph(r, output, theme, isRunning, void 0, frame)} ${theme.fg("toolTitle", theme.bold(foregroundSingleDisplayName(r)))}${modelDisplay}${contextBadge}${stats ? ` ${theme.fg("dim", "\xB7")} ${stats}` : ""}`, width), 0, 0));
|
|
2627
|
+
if (isRunning && r.progress) {
|
|
2628
|
+
const task = compactTaskText(r.task);
|
|
2629
|
+
if (task) c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}task: ${task}`), width), 0, 0));
|
|
2630
|
+
const progressSnapshotNow = snapshotNowForProgress(r.progress);
|
|
2631
|
+
const activity = compactCurrentActivity(r.progress);
|
|
2632
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}\u23BF ${activity}`), width), 0, 0));
|
|
2633
|
+
const liveStatus = buildLiveStatusLine(r.progress, progressSnapshotNow);
|
|
2634
|
+
if (liveStatus && liveStatus !== activity) c.addChild(new Text(truncLine(theme.fg("dim", `${continuationIndent}${liveStatus}`), width), 0, 0));
|
|
2635
|
+
for (const nestedLine of formatNestedWidgetLines(r.children, theme, width, false, progressSnapshotNow)) {
|
|
2636
|
+
c.addChild(new Text(truncLine(`${detailIndent}${nestedLine}`, width), 0, 0));
|
|
2637
|
+
}
|
|
2638
|
+
c.addChild(new Text(truncLine(theme.fg("accent", `${detailIndent}${foregroundSingleHintText(foregroundDetachShortcut)}`), width), 0, 0));
|
|
2639
|
+
if (r.artifactPaths) c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}output: ${shortenPath(r.artifactPaths.outputPath)}`), width), 0, 0));
|
|
2640
|
+
return c;
|
|
2641
|
+
}
|
|
2642
|
+
for (const nestedLine of formatNestedWidgetLines(r.children, theme, width, false, r.progress?.lastActivityAt)) {
|
|
2643
|
+
c.addChild(new Text(truncLine(`${detailIndent}${nestedLine}`, width), 0, 0));
|
|
2644
|
+
}
|
|
2645
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}\u23BF ${resultStatusLine(r, output)}`), width), 0, 0));
|
|
2646
|
+
const preview = firstOutputLine(output);
|
|
2647
|
+
if (preview && r.exitCode === 0 && !hasEmptyTextOutputWithoutOutputTarget(r.task, output)) {
|
|
2648
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${continuationIndent}${preview}`), width), 0, 0));
|
|
2649
|
+
}
|
|
2650
|
+
if (r.sessionFile) c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}session: ${shortenPath(r.sessionFile)}`), width), 0, 0));
|
|
2651
|
+
if (r.artifactPaths) c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}output: ${shortenPath(r.artifactPaths.outputPath)}`), width), 0, 0));
|
|
2652
|
+
if (r.truncation?.artifactPath) c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}full output: ${shortenPath(r.truncation.artifactPath)}`), width), 0, 0));
|
|
2653
|
+
return c;
|
|
2654
|
+
}
|
|
2655
|
+
function workflowRowGlyph(row, theme, frame, thinking) {
|
|
2656
|
+
if (row.state === "planned") return theme.fg("muted", "\u25E6");
|
|
2657
|
+
if (row.state === "running") return runningTone(theme, thinking)(runningGlyph(frame));
|
|
2658
|
+
if (row.state === "complete") return theme.fg("success", "\u2713");
|
|
2659
|
+
if (row.state === "detached" || row.state === "stopped") return theme.fg("warning", "\u25A0");
|
|
2660
|
+
return theme.fg("error", "\u2717");
|
|
2661
|
+
}
|
|
2662
|
+
function workflowRowStateLabel(row, theme, thinking) {
|
|
2663
|
+
const label = (row.state === "complete" ? "complete" : row.state).padEnd(8);
|
|
2664
|
+
if (row.state === "planned") return theme.fg("dim", label);
|
|
2665
|
+
if (row.state === "running") return runningTone(theme, thinking)(label);
|
|
2666
|
+
if (row.state === "complete") return theme.fg("success", label);
|
|
2667
|
+
if (row.state === "detached" || row.state === "stopped") return theme.fg("warning", label);
|
|
2668
|
+
return theme.fg("error", label);
|
|
2669
|
+
}
|
|
2670
|
+
function workflowOverallState(rows, hasTerminalValue, isError) {
|
|
2671
|
+
if (rows.some((row) => row.state === "failed")) return "failed";
|
|
2672
|
+
if (rows.some((row) => row.state === "detached")) return "paused";
|
|
2673
|
+
if (isError) return "failed";
|
|
2674
|
+
if (rows.length > 0 && rows.every((row) => row.state === "complete") || hasTerminalValue) return "complete";
|
|
2675
|
+
return "running";
|
|
2676
|
+
}
|
|
2677
|
+
function foregroundWorkflowChecklist(details) {
|
|
2678
|
+
if (details.mode !== "workflow") return void 0;
|
|
2679
|
+
const stageNodes = details.workflowGraph ? workflowGraphStageNodes(details.workflowGraph) : [];
|
|
2680
|
+
const steps = details.results.flatMap((result, resultIndex) => {
|
|
2681
|
+
const stableIndex = foregroundResultIndex(details, resultIndex);
|
|
2682
|
+
const workflowKey = result.workflowKey;
|
|
2683
|
+
if (details.workflowGraph && typeof workflowKey !== "string") return [];
|
|
2684
|
+
const node = typeof workflowKey === "string" ? stageNodes.find((candidate) => candidate.id === workflowKey) : void 0;
|
|
2685
|
+
const progress = foregroundProgressForResult(details, resultIndex);
|
|
2686
|
+
const status = isResultRunning(result) || progress?.status === "running" ? "running" : result.detached ? "paused" : result.stopped ? "stopped" : result.exitCode === 0 ? "complete" : "failed";
|
|
2687
|
+
return [{
|
|
2688
|
+
key: node?.id ?? (typeof workflowKey === "string" ? workflowKey : `result-${resultIndex + 1}`),
|
|
2689
|
+
label: node?.label ?? workflowLabelForResult(details, resultIndex) ?? result.task ?? result.agent,
|
|
2690
|
+
phase: node?.phase,
|
|
2691
|
+
agent: result.agent,
|
|
2692
|
+
thinking: result.thinking ?? progress?.thinking,
|
|
2693
|
+
status,
|
|
2694
|
+
context: result.context,
|
|
2695
|
+
activityState: progress?.activityState,
|
|
2696
|
+
startedAt: progress?.lastActivityAt !== void 0 && progress.durationMs !== void 0 ? progress.lastActivityAt - progress.durationMs : void 0,
|
|
2697
|
+
durationMs: progress?.durationMs,
|
|
2698
|
+
currentTool: progress?.currentTool,
|
|
2699
|
+
currentToolStartedAt: progress?.currentToolStartedAt,
|
|
2700
|
+
currentPath: progress?.currentPath,
|
|
2701
|
+
turnCount: progress?.turnCount,
|
|
2702
|
+
toolCount: progress?.toolCount ?? result.progressSummary?.toolCount,
|
|
2703
|
+
error: result.error,
|
|
2704
|
+
toolBudgetBlocked: result.toolBudgetBlocked,
|
|
2705
|
+
turnBudgetExceeded: result.turnBudgetExceeded,
|
|
2706
|
+
timedOut: result.timedOut,
|
|
2707
|
+
stopped: result.stopped,
|
|
2708
|
+
acceptance: result.acceptance ? { status: result.acceptance.status, reviewResult: result.acceptance.reviewResult ? { status: result.acceptance.reviewResult.status } : void 0 } : void 0,
|
|
2709
|
+
review: result.review ? { status: result.review.status } : void 0,
|
|
2710
|
+
watchdog: result.watchdog
|
|
2711
|
+
}];
|
|
2712
|
+
});
|
|
2713
|
+
const checklist = projectWorkflowChecklist({
|
|
2714
|
+
graph: details.workflowGraph,
|
|
2715
|
+
steps,
|
|
2716
|
+
hostSteps: details.workflow?.receipt?.hostSteps,
|
|
2717
|
+
preflight: details.preflight,
|
|
2718
|
+
trace: details.workflow?.trace,
|
|
2719
|
+
now: Date.now()
|
|
2720
|
+
});
|
|
2721
|
+
return checklist.total > 0 ? checklist : void 0;
|
|
2722
|
+
}
|
|
2723
|
+
function renderWorkflowChatProgress(d, result, theme, layout, frame, expanded = false) {
|
|
2724
|
+
const workflow = d.workflow;
|
|
2725
|
+
const rows = workflow ? buildWorkflowChatProgressRows(workflow.trace, d.preflight) : d.preflight ? buildWorkflowChatProgressRows([], d.preflight) : [];
|
|
2726
|
+
const state = workflowOverallState(rows, workflow?.value !== void 0, result.isError);
|
|
2727
|
+
const glyph = state === "running" ? runningTone(theme)(runningGlyph(frame)) : state === "complete" ? theme.fg("success", "\u2713") : state === "paused" ? theme.fg("warning", "\u25A0") : theme.fg("error", "\u2717");
|
|
2728
|
+
const width = getTermWidth() - 4;
|
|
2729
|
+
const runId = d.runId ? d.runId.slice(0, 12) : "workflow";
|
|
2730
|
+
const repoLabel = d.chatProgress?.repoLabel ?? (d.chatProgress?.repoRelation === "same" ? "same repo" : "other repo");
|
|
2731
|
+
const phase = rows.find((row) => row.state === "running" && row.phase)?.phase ?? [...rows].reverse().find((row) => row.phase)?.phase;
|
|
2732
|
+
const c = new Container();
|
|
2733
|
+
const rowIndent = mainWindowIndent(layout, 1);
|
|
2734
|
+
c.addChild(new Text(truncLine(`${glyph} ${theme.fg("toolTitle", theme.bold("workflow"))} ${runId} ${theme.fg("dim", "\xB7")} ${d.chatProgress?.repoRelation === "same" ? "same repo" : "other repo"} ${theme.fg("dim", "\xB7")} ${state}`, width), 0, 0));
|
|
2735
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}Repo ${repoLabel}`), width), 0, 0));
|
|
2736
|
+
if (d.preflight) c.addChild(new Text(truncLine(theme.fg("dim", formatWorkflowPreflightPlanSummary(d.preflight, { indent: rowIndent })), width), 0, 0));
|
|
2737
|
+
if (phase) c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}Phase ${phase}`), width), 0, 0));
|
|
2738
|
+
const checklist = projectWorkflowChecklist({ hostSteps: workflow?.receipt?.hostSteps, preflight: d.preflight, trace: workflow?.trace, now: Date.now() });
|
|
2739
|
+
for (const line of workflowChecklistWidgetLines(checklist, theme, rowIndent, false, frame, { limitPhases: !expanded, includeBottleneckOutput: expanded })) {
|
|
2740
|
+
c.addChild(new Text(truncLine(line, width), 0, 0));
|
|
2741
|
+
}
|
|
2742
|
+
if (rows.length === 0) {
|
|
2743
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}\u25E6 waiting for workflow child launches`), width), 0, 0));
|
|
2744
|
+
return c;
|
|
2745
|
+
}
|
|
2746
|
+
const visible = visibleWorkflowRows(rows);
|
|
2747
|
+
if (visible.hiddenRows > 0) c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}\u2026 ${visible.hiddenRows} older workflow rows hidden`), width), 0, 0));
|
|
2748
|
+
const childLevels = new Map((d.workflowChildren?.children ?? []).map((child) => [child.childId, childThinkingLevel(child)]));
|
|
2749
|
+
for (const row of visible.rows) {
|
|
2750
|
+
const thinking = childLevels.get(row.key);
|
|
2751
|
+
const status = workflowRowStateLabel(row, theme, thinking);
|
|
2752
|
+
const label = row.label && row.label !== row.key ? ` ${oneLine(row.label)}` : "";
|
|
2753
|
+
const duration = row.durationMs !== void 0 ? ` ${theme.fg("dim", `\xB7 ${formatDuration(row.durationMs)}`)}` : "";
|
|
2754
|
+
const run = row.runId ? ` ${theme.fg("dim", `[${row.runId.slice(0, 8)}]`)}` : "";
|
|
2755
|
+
const error = row.error ? ` ${theme.fg(row.state === "detached" ? "warning" : "error", `\xB7 ${compactWorkflowError(row.error)}`)}` : "";
|
|
2756
|
+
const hints = expanded && row.preflight ? [
|
|
2757
|
+
row.preflight.mode ? `mode:${row.preflight.mode}` : void 0,
|
|
2758
|
+
row.preflight.decision ? `decision:${row.preflight.decision}` : void 0,
|
|
2759
|
+
row.preflight.claims?.length ? `claims:${row.preflight.claims.join(",")}` : void 0,
|
|
2760
|
+
row.preflight.expectedOutput ? `expected:${row.preflight.expectedOutput}` : void 0,
|
|
2761
|
+
row.preflight.independence ? `independence:${row.preflight.independence}` : void 0
|
|
2762
|
+
].filter((value) => Boolean(value)).join(" \xB7 ") : "";
|
|
2763
|
+
c.addChild(new Text(truncLine(`${rowIndent}${workflowRowGlyph(row, theme, frame, thinking)} ${status} ${theme.bold(row.key)}${label}${run}${duration}${error}${hints ? ` ${theme.fg("dim", `\xB7 ${hints}`)}` : ""}`, width), 0, 0));
|
|
2764
|
+
}
|
|
2765
|
+
if (workflow?.preflightWarnings?.length) {
|
|
2766
|
+
const warningLines = expanded ? formatWorkflowPreflightWarnings(workflow.preflightWarnings, { indent: rowIndent }).split("\n") : [formatWorkflowPreflightWarningSummary(workflow.preflightWarnings, { indent: rowIndent, hint: "expand for debug" })];
|
|
2767
|
+
for (const warningLine of warningLines) c.addChild(new Text(truncLine(theme.fg("warning", warningLine), width), 0, 0));
|
|
2768
|
+
}
|
|
2769
|
+
if (workflow?.emits.length) c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}Emits ${workflow.emits.length}`), width), 0, 0));
|
|
2770
|
+
return c;
|
|
2771
|
+
}
|
|
2772
|
+
function renderMultiCompact(d, theme, layout, frame) {
|
|
2773
|
+
const hasRunning = detailsHaveRunningResult(d);
|
|
2774
|
+
const detached = d.results.some((r) => r.detached) || workflowGraphHasStatus(d, ["detached"]);
|
|
2775
|
+
const stopped = d.results.some((r) => r.stopped) || workflowGraphHasStatus(d, ["stopped"]);
|
|
2776
|
+
const failed = d.results.some((r) => !hasTerminalResultFlag(r) && r.exitCode !== 0 && !isResultRunning(r)) || workflowGraphHasStatus(d, ["failed"]);
|
|
2777
|
+
const paused = d.results.some((r) => r.interrupted) || workflowGraphHasStatus(d, ["paused"]);
|
|
2778
|
+
const partial = workflowGraphHasStatus(d, ["partial"]);
|
|
2779
|
+
let totalSummary = d.progressSummary;
|
|
2780
|
+
if (!totalSummary) {
|
|
2781
|
+
let sawProgress = false;
|
|
2782
|
+
const summary = { toolCount: 0, tokens: 0, durationMs: 0 };
|
|
2783
|
+
for (const r of d.results) {
|
|
2784
|
+
const prog = r.progress || r.progressSummary;
|
|
2785
|
+
if (!prog) continue;
|
|
2786
|
+
sawProgress = true;
|
|
2787
|
+
summary.toolCount += prog.toolCount;
|
|
2788
|
+
summary.tokens += prog.tokens;
|
|
2789
|
+
summary.durationMs = d.mode === "chain" ? summary.durationMs + prog.durationMs : Math.max(summary.durationMs, prog.durationMs);
|
|
2790
|
+
}
|
|
2791
|
+
if (sawProgress) totalSummary = summary;
|
|
2792
|
+
}
|
|
2793
|
+
const multiLabel = buildMultiProgressLabel(d, hasRunning);
|
|
2794
|
+
const itemTitle = multiLabel.itemTitle;
|
|
2795
|
+
const workflowChecklist = foregroundWorkflowChecklist(d);
|
|
2796
|
+
const checklistPrimary = d.mode === "workflow" && workflowChecklist !== void 0;
|
|
2797
|
+
const stats = statJoin(theme, [checklistPrimary ? formatWorkflowChecklistSummary(workflowChecklist) : multiLabel.headerLabel, formatProgressStats(theme, totalSummary), formatTotalCostStat(d.totalCost)]);
|
|
2798
|
+
const aggregatePresentation = semanticResultPresentation({
|
|
2799
|
+
running: hasRunning,
|
|
2800
|
+
detached,
|
|
2801
|
+
stopped,
|
|
2802
|
+
interrupted: paused,
|
|
2803
|
+
failed,
|
|
2804
|
+
partial,
|
|
2805
|
+
seed: runningSeed(progressRunningSeed(totalSummary), d.currentStepIndex),
|
|
2806
|
+
frame
|
|
2807
|
+
});
|
|
2808
|
+
const glyph = presentationTone(aggregatePresentation, theme)(aggregatePresentation.glyph);
|
|
2809
|
+
const contextBadge = contextModeBadge(theme, d.context);
|
|
2810
|
+
const c = new Container();
|
|
2811
|
+
const width = getTermWidth() - 4;
|
|
2812
|
+
const rowIndent = mainWindowIndent(layout, 1);
|
|
2813
|
+
const detailIndent = mainWindowIndent(layout, 2);
|
|
2814
|
+
c.addChild(new Text(truncLine(`${glyph} ${theme.fg("toolTitle", theme.bold(d.mode))}${contextBadge}${stats ? ` ${theme.fg("dim", "\xB7")} ${stats}` : ""}`, width), 0, 0));
|
|
2815
|
+
if (checklistPrimary) {
|
|
2816
|
+
for (const line of workflowChecklistWidgetLines(workflowChecklist, theme, rowIndent, false, frame, { includeSummary: false })) {
|
|
2817
|
+
c.addChild(new Text(truncLine(line, width), 0, 0));
|
|
2818
|
+
}
|
|
2819
|
+
if (hasRunning || workflowChecklist.running > 0) c.addChild(new Text(truncLine(theme.fg("accent", `${rowIndent}${liveDetailHintText()}`), width), 0, 0));
|
|
2820
|
+
return c;
|
|
2821
|
+
}
|
|
2822
|
+
for (const line of workflowChecklistWidgetLines(workflowChecklist, theme, rowIndent, false, frame)) {
|
|
2823
|
+
c.addChild(new Text(truncLine(line, width), 0, 0));
|
|
2824
|
+
}
|
|
2825
|
+
const useResultsDirectly = multiLabel.hasParallelInChain || !d.chainAgents?.length;
|
|
2826
|
+
const displayStart = multiLabel.showActiveGroupOnly ? multiLabel.groupStartIndex : 0;
|
|
2827
|
+
const displayEnd = multiLabel.showActiveGroupOnly ? multiLabel.groupEndIndex : useResultsDirectly ? d.results.length : d.chainAgents.length;
|
|
2828
|
+
const chainEntries = buildChainRenderEntries(d, multiLabel);
|
|
2829
|
+
const renderEntries = chainEntries ?? buildForegroundResultEntries(d, multiLabel, displayStart, displayEnd, useResultsDirectly);
|
|
2830
|
+
for (const entry of renderEntries) {
|
|
2831
|
+
if (entry.kind === "group") {
|
|
2832
|
+
const glyph3 = widgetStepGlyph(entry.status, theme);
|
|
2833
|
+
const statusLabel = widgetStepStatus(entry.status, theme);
|
|
2834
|
+
const groupLabel = entry.groupLabel ? ` (${compactTaskText(void 0, entry.groupLabel) ?? entry.groupLabel})` : "";
|
|
2835
|
+
c.addChild(new Text(truncLine(`${rowIndent}${glyph3} ${entry.stepLabel}${groupLabel} ${theme.fg("dim", "\xB7")} ${statusLabel}`, width), 0, 0));
|
|
2836
|
+
if (entry.error) c.addChild(new Text(truncLine(theme.fg("error", `${detailIndent}\u23BF Error: ${entry.error}`), width), 0, 0));
|
|
2837
|
+
continue;
|
|
2838
|
+
}
|
|
2839
|
+
const i = entry.resultIndex;
|
|
2840
|
+
const r = d.results[i];
|
|
2841
|
+
const rowNumber = entry.rowNumber;
|
|
2842
|
+
const agentName = entry.agentName;
|
|
2843
|
+
if (!r) {
|
|
2844
|
+
const pendingLabel2 = entry.rowLabel ?? (entry.isParallel ? "" : `${itemTitle} ${rowNumber}`);
|
|
2845
|
+
const labelPrefix2 = pendingLabel2 ? `${pendingLabel2}: ` : "";
|
|
2846
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}\u25E6 ${labelPrefix2}${agentName} \xB7 pending`), width), 0, 0));
|
|
2847
|
+
continue;
|
|
2848
|
+
}
|
|
2849
|
+
const output = getSingleResultOutput(r);
|
|
2850
|
+
const progressFromArray = foregroundProgressForResult(d, i);
|
|
2851
|
+
const rProg = r.progress || progressFromArray || r.progressSummary;
|
|
2852
|
+
const rRunning = rProg && "status" in rProg && isResultRunning(r, rProg.status);
|
|
2853
|
+
const rPending = rProg && "status" in rProg && rProg.status === "pending";
|
|
2854
|
+
const stepStats = formatProgressStats(theme, rProg);
|
|
2855
|
+
const glyph2 = rPending ? theme.fg("dim", "\u25E6") : resultGlyph(r, output, theme, rRunning, progressRunningSeed(rProg), frame);
|
|
2856
|
+
const pendingLabel = rPending ? ` ${theme.fg("dim", "\xB7 pending")}` : "";
|
|
2857
|
+
const stepLabel = entry.rowLabel;
|
|
2858
|
+
const rowProgressModel = rProg && "status" in rProg ? rProg : void 0;
|
|
2859
|
+
const rowModelDisplay = modelThinkingBadge(theme, rowProgressModel?.model ?? r.model, r.thinking ?? rowProgressModel?.thinking);
|
|
2860
|
+
const labelPrefix = stepLabel ? `${stepLabel}: ` : "";
|
|
2861
|
+
const line = `${glyph2} ${labelPrefix}${themeBold(theme, agentName)}${contextModeBadge(theme, r.context)}${rowModelDisplay}${stepStats ? ` ${theme.fg("dim", "\xB7")} ${stepStats}` : ""}${pendingLabel}`;
|
|
2862
|
+
c.addChild(new Text(truncLine(`${rowIndent}${line}`, width), 0, 0));
|
|
2863
|
+
if (rRunning || rPending) {
|
|
2864
|
+
const task = compactTaskText(r.task, workflowLabelForResult(d, i));
|
|
2865
|
+
if (task) c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}task: ${task}`), width), 0, 0));
|
|
2866
|
+
}
|
|
2867
|
+
if (rRunning && rProg && "status" in rProg) {
|
|
2868
|
+
const liveProgress = rProg;
|
|
2869
|
+
const activity = compactCurrentActivity(liveProgress);
|
|
2870
|
+
c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}\u23BF ${activity}`), width), 0, 0));
|
|
2871
|
+
for (const nestedLine of formatNestedWidgetLines(r.children, theme, width, false, snapshotNowForProgress(liveProgress))) {
|
|
2872
|
+
c.addChild(new Text(truncLine(`${detailIndent}${nestedLine}`, width), 0, 0));
|
|
2873
|
+
}
|
|
2874
|
+
c.addChild(new Text(truncLine(theme.fg("accent", `${detailIndent}${liveDetailHintText()}`), width), 0, 0));
|
|
2875
|
+
} else if (!rPending && (r.exitCode !== 0 || r.interrupted || r.detached || hasEmptyTextOutputWithoutOutputTarget(r.task, output))) {
|
|
2876
|
+
c.addChild(new Text(truncLine(theme.fg(r.exitCode !== 0 ? "error" : "dim", `${detailIndent}\u23BF ${resultStatusLine(r, output)}`), width), 0, 0));
|
|
2877
|
+
}
|
|
2878
|
+
if (!rRunning && !rPending) {
|
|
2879
|
+
for (const nestedLine of formatNestedWidgetLines(r.children, theme, width, false, r.progress?.lastActivityAt)) {
|
|
2880
|
+
c.addChild(new Text(truncLine(`${detailIndent}${nestedLine}`, width), 0, 0));
|
|
2881
|
+
}
|
|
2882
|
+
}
|
|
2883
|
+
const outputTarget = extractOutputTarget(r.task);
|
|
2884
|
+
if (outputTarget) c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}output: ${outputTarget}`), width), 0, 0));
|
|
2885
|
+
if (r.artifactPaths) c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}output: ${shortenPath(r.artifactPaths.outputPath)}`), width), 0, 0));
|
|
2886
|
+
}
|
|
2887
|
+
if (d.artifacts) c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}artifacts: ${shortenPath(d.artifacts.dir)}`), width), 0, 0));
|
|
2888
|
+
return c;
|
|
2889
|
+
}
|
|
2890
|
+
function renderSubagentSummary(result, options, theme) {
|
|
2891
|
+
const details = result.details;
|
|
2892
|
+
const results = details?.results ?? [];
|
|
2893
|
+
const hasSingleTerminalResult = results.length === 1 && hasTerminalResult(results[0]);
|
|
2894
|
+
const hasOnlyTerminalResults = results.length > 0 && results.every(hasTerminalResult);
|
|
2895
|
+
const running = !hasSingleTerminalResult && !hasOnlyTerminalResults && (options.isPartial === true || Boolean(details?.asyncId && details.mode !== "management") || Boolean(details && detailsHaveRunningResult(details)));
|
|
2896
|
+
const stopped = results.some((entry) => entry.stopped) || Boolean(details && workflowGraphHasStatus(details, ["stopped"]));
|
|
2897
|
+
const paused = results.some((entry) => entry.interrupted || entry.detached) || Boolean(details && workflowGraphHasStatus(details, ["paused", "detached"]));
|
|
2898
|
+
const failed = result.isError === true || results.some((entry) => !hasTerminalResultFlag(entry) && entry.exitCode !== 0 && !isResultRunning(entry)) || Boolean(details && workflowGraphHasStatus(details, ["failed"]));
|
|
2899
|
+
const partial = Boolean(details && workflowGraphHasStatus(details, ["partial"]));
|
|
2900
|
+
const state = running ? "running" : failed ? "failed" : stopped ? "stopped" : paused ? "paused" : partial ? "partial" : "completed";
|
|
2901
|
+
const glyph = state === "running" ? runningTone(theme, details?.mode === "single" && results.length === 1 ? childThinkingLevel(results[0], results[0]?.progress) : void 0)(STATIC_RUNNING_GLYPH) : state === "completed" ? theme.fg("success", "\u2713") : state === "failed" ? theme.fg("error", "\u2717") : theme.fg("warning", "\u25A0");
|
|
2902
|
+
const label = details?.mode === "single" && results.length === 1 ? foregroundSingleDisplayName(results[0]) : details?.mode || "subagent";
|
|
2903
|
+
return new Text(
|
|
2904
|
+
truncLine(`${glyph} ${theme.fg("toolTitle", theme.bold(label))} ${theme.fg("dim", "\xB7")} ${theme.fg(state === "failed" ? "error" : state === "completed" ? "success" : state === "running" ? "accent" : "warning", state)}`, getTermWidth() - 4),
|
|
2905
|
+
0,
|
|
2906
|
+
0
|
|
2907
|
+
);
|
|
2908
|
+
}
|
|
2909
|
+
function renderSubagentResult(result, options, theme, frame, rendererConfig, foregroundDetachShortcut) {
|
|
2910
|
+
const layout = resolveMainWindowRenderLayout(rendererConfig);
|
|
2911
|
+
const compact = (component) => capCompactMainWindowResult(component, layout, theme, !options.expanded);
|
|
2912
|
+
const d = result.details;
|
|
2913
|
+
if (d?.mode === "workflow" && d.chatProgress?.mode === "live-card" && d.workflow?.value === void 0 && (!result.isError || (d.workflow?.trace.length ?? 0) > 0)) {
|
|
2914
|
+
return compact(renderWorkflowChatProgress(d, result, theme, options.expanded ? resolveMainWindowRenderLayout() : layout, frame, options.expanded));
|
|
2915
|
+
}
|
|
2916
|
+
if (!d || !d.results.length) {
|
|
2917
|
+
const t = result.content[0];
|
|
2918
|
+
const text = t?.type === "text" ? t.text : "(no output)";
|
|
2919
|
+
const contextPrefix = contextModePrefix(theme, d?.context);
|
|
2920
|
+
const width = getTermWidth() - 4;
|
|
2921
|
+
if (!text.includes("\n")) return compact(new Text(truncLine(`${contextPrefix}${text}`, width), 0, 0));
|
|
2922
|
+
if (d && !options.expanded && !result.isError) {
|
|
2923
|
+
const lines = text.split(/\r?\n/);
|
|
2924
|
+
const firstNonEmptyLine = lines.find((line) => line.trim())?.trim() || "(no output)";
|
|
2925
|
+
const compactLine = d.mode === "workflow" && d.preflight ? formatWorkflowPreflightPlanSummary(d.preflight) : firstNonEmptyLine;
|
|
2926
|
+
const c3 = new Container();
|
|
2927
|
+
const detailIndent = mainWindowIndent(layout, 1);
|
|
2928
|
+
c3.addChild(new Text(truncLine(`${contextPrefix}${compactLine} \xB7 ${lines.length} lines`, width), 0, 0));
|
|
2929
|
+
c3.addChild(new Text(truncLine(theme.fg("accent", `${detailIndent}${expandKeyHint("for full output")}`), width), 0, 0));
|
|
2930
|
+
return compact(c3);
|
|
2931
|
+
}
|
|
2932
|
+
const c2 = new Container();
|
|
2933
|
+
const wrapped = wrapPlainText(`${contextPrefix}${text}`, width);
|
|
2934
|
+
for (const line of wrapped) c2.addChild(new Text(line, 0, 0));
|
|
2935
|
+
return c2;
|
|
2936
|
+
}
|
|
2937
|
+
const expanded = options.expanded;
|
|
2938
|
+
const mdTheme = getMarkdownTheme();
|
|
2939
|
+
if (d.mode === "single" && d.results.length === 1) {
|
|
2940
|
+
const r = d.results[0];
|
|
2941
|
+
const detachableShortcut = d.asyncId || d.background ? void 0 : foregroundDetachShortcut;
|
|
2942
|
+
if (!r) return compact(renderMultiCompact(d, theme, layout, frame));
|
|
2943
|
+
if (!expanded) return compact(renderSingleCompact(d, r, theme, layout, frame, detachableShortcut));
|
|
2944
|
+
const isRunning = isResultRunning(r);
|
|
2945
|
+
const contextBadge2 = contextModeBadge(theme, r.context ?? d.context);
|
|
2946
|
+
const output = r.truncation?.text || getSingleResultOutput(r);
|
|
2947
|
+
const presentation2 = styledResultPresentation(resultPresentation(r, output, isRunning, void 0, frame), theme);
|
|
2948
|
+
const progressInfo = isRunning && r.progress ? ` | ${r.progress.toolCount} tools, ${formatTokens(r.progress.tokens)} tok, ${formatDuration(r.progress.durationMs)}` : r.progressSummary ? ` | ${r.progressSummary.toolCount} tools, ${formatTokens(r.progressSummary.tokens)} tok, ${formatDuration(r.progressSummary.durationMs)}` : "";
|
|
2949
|
+
const w2 = getTermWidth() - 4;
|
|
2950
|
+
const fit2 = (text) => expanded ? text : truncLine(text, w2);
|
|
2951
|
+
const toolCallLines = getToolCallLines(r, expanded);
|
|
2952
|
+
const c2 = new Container();
|
|
2953
|
+
c2.addChild(new Text(fit2(`${presentation2.glyph} ${theme.fg("toolTitle", theme.bold(foregroundSingleDisplayName(r)))}${contextBadge2}${progressInfo} ${theme.fg("dim", "\xB7")} ${presentation2.label}`), 0, 0));
|
|
2954
|
+
c2.addChild(new Spacer(1));
|
|
2955
|
+
const taskMaxLen = Math.max(20, w2 - 8);
|
|
2956
|
+
const taskPreview = expanded || r.task.length <= taskMaxLen ? r.task : `${r.task.slice(0, taskMaxLen)}...`;
|
|
2957
|
+
c2.addChild(
|
|
2958
|
+
new Text(fit2(theme.fg("dim", `Task: ${taskPreview}`)), 0, 0)
|
|
2959
|
+
);
|
|
2960
|
+
c2.addChild(new Spacer(1));
|
|
2961
|
+
if (!isRunning && (r.exitCode !== 0 || r.interrupted || r.detached || r.stopped)) {
|
|
2962
|
+
c2.addChild(new Text(fit2(theme.fg(r.exitCode !== 0 ? "error" : "dim", ` \u23BF ${resultStatusLine(r, output)}`)), 0, 0));
|
|
2963
|
+
}
|
|
2964
|
+
if (isRunning && r.progress) {
|
|
2965
|
+
const progressSnapshotNow = snapshotNowForProgress(r.progress);
|
|
2966
|
+
for (const nestedLine of formatNestedWidgetLines(r.children, theme, w2, true, progressSnapshotNow, 12)) {
|
|
2967
|
+
c2.addChild(new Text(fit2(` ${nestedLine}`), 0, 0));
|
|
2968
|
+
}
|
|
2969
|
+
const toolLine = formatCurrentToolLine(r.progress, w2, expanded, progressSnapshotNow);
|
|
2970
|
+
if (toolLine) {
|
|
2971
|
+
c2.addChild(new Text(fit2(theme.fg("warning", `> ${toolLine}`)), 0, 0));
|
|
2972
|
+
}
|
|
2973
|
+
const liveStatusLine = buildLiveStatusLine(r.progress, progressSnapshotNow);
|
|
2974
|
+
if (liveStatusLine) {
|
|
2975
|
+
c2.addChild(new Text(fit2(theme.fg("accent", liveStatusLine)), 0, 0));
|
|
2976
|
+
}
|
|
2977
|
+
c2.addChild(new Text(fit2(theme.fg("accent", foregroundSingleHintText(detachableShortcut))), 0, 0));
|
|
2978
|
+
if (r.artifactPaths) {
|
|
2979
|
+
c2.addChild(new Text(fit2(theme.fg("dim", `Artifacts: ${shortenPath(r.artifactPaths.outputPath)}`)), 0, 0));
|
|
2980
|
+
}
|
|
2981
|
+
if (r.progress.recentTools?.length) {
|
|
2982
|
+
for (const t of r.progress.recentTools.slice(-3)) {
|
|
2983
|
+
const maxArgsLen = Math.max(40, w2 - 24);
|
|
2984
|
+
const argsPreview = renderToolArgsPreview(t.args, maxArgsLen, expanded);
|
|
2985
|
+
c2.addChild(new Text(fit2(theme.fg("dim", `${t.tool}: ${argsPreview}`)), 0, 0));
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2988
|
+
for (const line of compactRecentOutputLines(r.progress.recentOutput)) {
|
|
2989
|
+
c2.addChild(new Text(fit2(theme.fg("dim", ` ${line}`)), 0, 0));
|
|
2990
|
+
}
|
|
2991
|
+
if (toolLine || liveStatusLine || r.progress.recentTools?.length || r.progress.recentOutput?.length || r.artifactPaths) {
|
|
2992
|
+
c2.addChild(new Spacer(1));
|
|
2993
|
+
}
|
|
2994
|
+
} else {
|
|
2995
|
+
for (const nestedLine of formatNestedWidgetLines(r.children, theme, w2, true, r.progress?.lastActivityAt, 8)) {
|
|
2996
|
+
c2.addChild(new Text(fit2(` ${nestedLine}`), 0, 0));
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
if (expanded) {
|
|
3000
|
+
for (const line of toolCallLines) {
|
|
3001
|
+
c2.addChild(new Text(fit2(theme.fg("muted", line)), 0, 0));
|
|
3002
|
+
}
|
|
3003
|
+
if (toolCallLines.length) c2.addChild(new Spacer(1));
|
|
3004
|
+
}
|
|
3005
|
+
if (output) c2.addChild(new Markdown(output, 0, 0, mdTheme));
|
|
3006
|
+
c2.addChild(new Spacer(1));
|
|
3007
|
+
if (r.skills?.length) {
|
|
3008
|
+
c2.addChild(new Text(fit2(theme.fg("dim", `Skills: ${r.skills.join(", ")}`)), 0, 0));
|
|
3009
|
+
}
|
|
3010
|
+
if (r.skillsWarning) {
|
|
3011
|
+
c2.addChild(new Text(fit2(theme.fg("warning", `Warning: ${r.skillsWarning}`)), 0, 0));
|
|
3012
|
+
}
|
|
3013
|
+
c2.addChild(new Text(fit2(theme.fg("dim", formatUsage(r.usage, r.progress?.model ?? r.model))), 0, 0));
|
|
3014
|
+
if (r.sessionFile) {
|
|
3015
|
+
c2.addChild(new Text(fit2(theme.fg("dim", `Session: ${shortenPath(r.sessionFile)}`)), 0, 0));
|
|
3016
|
+
}
|
|
3017
|
+
if (!isRunning && r.artifactPaths) {
|
|
3018
|
+
c2.addChild(new Spacer(1));
|
|
3019
|
+
c2.addChild(new Text(fit2(theme.fg("dim", `Artifacts: ${shortenPath(r.artifactPaths.outputPath)}`)), 0, 0));
|
|
3020
|
+
}
|
|
3021
|
+
return c2;
|
|
3022
|
+
}
|
|
3023
|
+
if (!expanded) return compact(renderMultiCompact(d, theme, layout, frame));
|
|
3024
|
+
const hasRunning = detailsHaveRunningResult(d);
|
|
3025
|
+
const detached = d.results.some((r) => r.detached) || workflowGraphHasStatus(d, ["detached"]);
|
|
3026
|
+
const stopped = d.results.some((r) => r.stopped) || workflowGraphHasStatus(d, ["stopped"]);
|
|
3027
|
+
const failed = d.results.some((r) => !hasTerminalResultFlag(r) && r.exitCode !== 0 && !isResultRunning(r)) || workflowGraphHasStatus(d, ["failed"]);
|
|
3028
|
+
const paused = d.results.some((r) => r.interrupted) || workflowGraphHasStatus(d, ["paused"]);
|
|
3029
|
+
const partial = workflowGraphHasStatus(d, ["partial"]);
|
|
3030
|
+
const completedWithoutOutput = d.results.some(
|
|
3031
|
+
(r) => !hasTerminalResultFlag(r) && r.exitCode === 0 && !isResultRunning(r) && hasEmptyTextOutputWithoutOutputTarget(r.task, getSingleResultOutput(r))
|
|
3032
|
+
);
|
|
3033
|
+
const presentation = styledResultPresentation(semanticResultPresentation({
|
|
3034
|
+
running: hasRunning,
|
|
3035
|
+
detached,
|
|
3036
|
+
stopped,
|
|
3037
|
+
interrupted: paused,
|
|
3038
|
+
failed,
|
|
3039
|
+
partial,
|
|
3040
|
+
completedWithoutOutput,
|
|
3041
|
+
frame
|
|
3042
|
+
}), theme);
|
|
3043
|
+
const totalSummary = d.progressSummary || d.results.reduce(
|
|
3044
|
+
(acc, r) => {
|
|
3045
|
+
const prog = r.progress || r.progressSummary;
|
|
3046
|
+
if (prog) {
|
|
3047
|
+
acc.toolCount += prog.toolCount;
|
|
3048
|
+
acc.tokens += prog.tokens;
|
|
3049
|
+
acc.durationMs = d.mode === "chain" ? acc.durationMs + prog.durationMs : Math.max(acc.durationMs, prog.durationMs);
|
|
3050
|
+
}
|
|
3051
|
+
return acc;
|
|
3052
|
+
},
|
|
3053
|
+
{ toolCount: 0, tokens: 0, durationMs: 0 }
|
|
3054
|
+
);
|
|
3055
|
+
const summaryParts = [
|
|
3056
|
+
totalSummary.toolCount || totalSummary.tokens ? `${totalSummary.toolCount} tools, ${formatTokens(totalSummary.tokens)} tok, ${formatDuration(totalSummary.durationMs)}` : "",
|
|
3057
|
+
formatTotalCostStat(d.totalCost)
|
|
3058
|
+
].filter(Boolean);
|
|
3059
|
+
const summaryStr = summaryParts.length ? ` | ${summaryParts.join(", ")}` : "";
|
|
3060
|
+
const modeLabel = d.mode;
|
|
3061
|
+
const contextBadge = contextModeBadge(theme, d.context);
|
|
3062
|
+
const multiLabel = buildMultiProgressLabel(d, hasRunning);
|
|
3063
|
+
const itemTitle = multiLabel.itemTitle;
|
|
3064
|
+
const chainVis = d.chainAgents?.length && !multiLabel.hasParallelInChain ? d.chainAgents.map((agent, i) => {
|
|
3065
|
+
const result2 = d.results[i];
|
|
3066
|
+
const displayName = foregroundResultDisplayName(d, i, result2, agent);
|
|
3067
|
+
const isCurrent = i === (d.currentStepIndex ?? d.results.length);
|
|
3068
|
+
const stepPresentation = result2 ? styledResultPresentation(resultPresentation(result2, getSingleResultOutput(result2), isCurrent && hasRunning && !hasTerminalResultFlag(result2)), theme) : void 0;
|
|
3069
|
+
const stepStatus = stepPresentation ? `${stepPresentation.glyph} ${stepPresentation.label}` : theme.fg("dim", "\u25E6 pending");
|
|
3070
|
+
return `${stepStatus} ${displayName}${contextModeBadge(theme, result2?.context)}`;
|
|
3071
|
+
}).join(theme.fg("dim", " \u2192 ")) : null;
|
|
3072
|
+
const w = getTermWidth() - 4;
|
|
3073
|
+
const fit = (text) => expanded ? text : truncLine(text, w);
|
|
3074
|
+
const c = new Container();
|
|
3075
|
+
c.addChild(
|
|
3076
|
+
new Text(
|
|
3077
|
+
fit(`${presentation.glyph} ${theme.fg("toolTitle", theme.bold(modeLabel))}${contextBadge} \xB7 ${multiLabel.headerLabel}${summaryStr} ${theme.fg("dim", "\xB7")} ${presentation.label}`),
|
|
3078
|
+
0,
|
|
3079
|
+
0
|
|
3080
|
+
)
|
|
3081
|
+
);
|
|
3082
|
+
if (chainVis) {
|
|
3083
|
+
c.addChild(new Text(fit(` ${chainVis}`), 0, 0));
|
|
3084
|
+
}
|
|
3085
|
+
const workflowChecklist = foregroundWorkflowChecklist(d);
|
|
3086
|
+
for (const line of workflowChecklistWidgetLines(workflowChecklist, theme, " ", true, frame, { includeItemErrors: false })) {
|
|
3087
|
+
c.addChild(new Text(fit(line), 0, 0));
|
|
3088
|
+
}
|
|
3089
|
+
const useResultsDirectly = multiLabel.hasParallelInChain || !d.chainAgents?.length;
|
|
3090
|
+
const displayStart = multiLabel.showActiveGroupOnly ? multiLabel.groupStartIndex : 0;
|
|
3091
|
+
const displayEnd = multiLabel.showActiveGroupOnly ? multiLabel.groupEndIndex : useResultsDirectly ? d.results.length : d.chainAgents.length;
|
|
3092
|
+
const chainEntries = buildChainRenderEntries(d, multiLabel);
|
|
3093
|
+
const renderEntries = chainEntries ?? buildForegroundResultEntries(d, multiLabel, displayStart, displayEnd, useResultsDirectly);
|
|
3094
|
+
c.addChild(new Spacer(1));
|
|
3095
|
+
for (const entry of renderEntries) {
|
|
3096
|
+
if (entry.kind === "group") {
|
|
3097
|
+
const statusLabel = widgetStepStatus(entry.status, theme);
|
|
3098
|
+
const groupLabel = entry.groupLabel ? ` (${compactTaskText(void 0, entry.groupLabel) ?? entry.groupLabel})` : "";
|
|
3099
|
+
c.addChild(new Text(fit(` ${statusLabel} ${entry.stepLabel}${groupLabel}`), 0, 0));
|
|
3100
|
+
c.addChild(new Text(theme.fg(entry.status === "failed" ? "error" : "dim", ` status: ${entry.status}`), 0, 0));
|
|
3101
|
+
if (entry.error) c.addChild(new Text(theme.fg("error", ` error: ${entry.error}`), 0, 0));
|
|
3102
|
+
c.addChild(new Spacer(1));
|
|
3103
|
+
continue;
|
|
3104
|
+
}
|
|
3105
|
+
const i = entry.resultIndex;
|
|
3106
|
+
const r = d.results[i];
|
|
3107
|
+
const rowNumber = entry.rowNumber;
|
|
3108
|
+
const agentName = entry.agentName;
|
|
3109
|
+
if (!r) {
|
|
3110
|
+
const pendingLabel = entry.rowLabel ?? (entry.isParallel ? "" : `${itemTitle} ${rowNumber}`);
|
|
3111
|
+
const labelPrefix2 = pendingLabel ? `${pendingLabel}: ` : "";
|
|
3112
|
+
c.addChild(new Text(fit(theme.fg("dim", ` ${labelPrefix2}${agentName}`)), 0, 0));
|
|
3113
|
+
c.addChild(new Text(theme.fg("dim", ` status: pending`), 0, 0));
|
|
3114
|
+
c.addChild(new Spacer(1));
|
|
3115
|
+
continue;
|
|
3116
|
+
}
|
|
3117
|
+
const progressFromArray = foregroundProgressForResult(d, i);
|
|
3118
|
+
const rProg = r.progress || progressFromArray || r.progressSummary;
|
|
3119
|
+
const rRunning = isResultRunning(r, rProg?.status);
|
|
3120
|
+
const resultOutput = getSingleResultOutput(r);
|
|
3121
|
+
const rowPresentation = styledResultPresentation(resultPresentation(r, resultOutput, rRunning, progressRunningSeed(rProg), frame), theme);
|
|
3122
|
+
const stats = rProg ? ` | ${rProg.toolCount} tools, ${formatDuration(rProg.durationMs)}` : "";
|
|
3123
|
+
const modelDisplay = modelThinkingBadge(theme, rProg?.model ?? r.model, r.thinking ?? rProg?.thinking);
|
|
3124
|
+
const stepLabel = entry.rowLabel;
|
|
3125
|
+
const contextBadge2 = contextModeBadge(theme, r.context);
|
|
3126
|
+
const labelPrefix = stepLabel ? `${stepLabel}: ` : "";
|
|
3127
|
+
const stepHeader = rRunning ? `${rowPresentation.glyph} ${labelPrefix}${theme.bold(theme.fg("warning", agentName))}${contextBadge2}${modelDisplay}${stats} ${theme.fg("dim", "\xB7")} ${rowPresentation.label}` : `${rowPresentation.glyph} ${labelPrefix}${theme.bold(agentName)}${contextBadge2}${modelDisplay}${stats} ${theme.fg("dim", "\xB7")} ${rowPresentation.label}`;
|
|
3128
|
+
const toolCallLines = getToolCallLines(r, expanded);
|
|
3129
|
+
c.addChild(new Text(fit(stepHeader), 0, 0));
|
|
3130
|
+
const taskMaxLen = Math.max(20, w - 12);
|
|
3131
|
+
const taskPreview = expanded || r.task.length <= taskMaxLen ? r.task : `${r.task.slice(0, taskMaxLen)}...`;
|
|
3132
|
+
c.addChild(new Text(fit(theme.fg("dim", ` task: ${taskPreview}`)), 0, 0));
|
|
3133
|
+
const outputTarget = extractOutputTarget(r.task);
|
|
3134
|
+
if (outputTarget) {
|
|
3135
|
+
c.addChild(new Text(fit(theme.fg("dim", ` output: ${outputTarget}`)), 0, 0));
|
|
3136
|
+
}
|
|
3137
|
+
if (!rRunning && (r.exitCode !== 0 || r.interrupted || r.detached || r.stopped)) {
|
|
3138
|
+
c.addChild(new Text(fit(theme.fg(r.exitCode !== 0 ? "error" : "dim", ` \u23BF ${resultStatusLine(r, resultOutput)}`)), 0, 0));
|
|
3139
|
+
}
|
|
3140
|
+
if (r.skills?.length) {
|
|
3141
|
+
c.addChild(new Text(fit(theme.fg("dim", ` skills: ${r.skills.join(", ")}`)), 0, 0));
|
|
3142
|
+
}
|
|
3143
|
+
if (r.skillsWarning) {
|
|
3144
|
+
c.addChild(new Text(fit(theme.fg("warning", ` Warning: ${r.skillsWarning}`)), 0, 0));
|
|
3145
|
+
}
|
|
3146
|
+
if (rRunning && rProg) {
|
|
3147
|
+
if (rProg.skills?.length) {
|
|
3148
|
+
c.addChild(new Text(fit(theme.fg("accent", ` skills: ${rProg.skills.join(", ")}`)), 0, 0));
|
|
3149
|
+
}
|
|
3150
|
+
const progressSnapshotNow = snapshotNowForProgress(rProg);
|
|
3151
|
+
const toolLine = formatCurrentToolLine(rProg, w, expanded, progressSnapshotNow);
|
|
3152
|
+
if (toolLine) {
|
|
3153
|
+
c.addChild(new Text(fit(theme.fg("warning", ` > ${toolLine}`)), 0, 0));
|
|
3154
|
+
}
|
|
3155
|
+
const liveStatusLine = buildLiveStatusLine(rProg, progressSnapshotNow);
|
|
3156
|
+
if (liveStatusLine) {
|
|
3157
|
+
c.addChild(new Text(fit(theme.fg("accent", ` ${liveStatusLine}`)), 0, 0));
|
|
3158
|
+
}
|
|
3159
|
+
for (const nestedLine of formatNestedWidgetLines(r.children, theme, w, true, progressSnapshotNow, 8)) {
|
|
3160
|
+
c.addChild(new Text(fit(` ${nestedLine}`), 0, 0));
|
|
3161
|
+
}
|
|
3162
|
+
c.addChild(new Text(fit(theme.fg("accent", ` ${liveDetailHintText()}`)), 0, 0));
|
|
3163
|
+
if (r.artifactPaths) {
|
|
3164
|
+
c.addChild(new Text(fit(theme.fg("dim", ` artifacts: ${shortenPath(r.artifactPaths.outputPath)}`)), 0, 0));
|
|
3165
|
+
}
|
|
3166
|
+
if (rProg.recentTools?.length) {
|
|
3167
|
+
for (const t of rProg.recentTools.slice(-3)) {
|
|
3168
|
+
const maxArgsLen = Math.max(40, w - 30);
|
|
3169
|
+
const argsPreview = renderToolArgsPreview(t.args, maxArgsLen, expanded);
|
|
3170
|
+
c.addChild(new Text(fit(theme.fg("dim", ` ${t.tool}: ${argsPreview}`)), 0, 0));
|
|
3171
|
+
}
|
|
3172
|
+
}
|
|
3173
|
+
for (const line of compactRecentOutputLines(rProg.recentOutput)) {
|
|
3174
|
+
c.addChild(new Text(fit(theme.fg("dim", ` ${line}`)), 0, 0));
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3177
|
+
if (!rRunning) {
|
|
3178
|
+
for (const nestedLine of formatNestedWidgetLines(r.children, theme, w, true, r.progress?.lastActivityAt, 8)) {
|
|
3179
|
+
c.addChild(new Text(fit(` ${nestedLine}`), 0, 0));
|
|
3180
|
+
}
|
|
3181
|
+
}
|
|
3182
|
+
if (!rRunning && r.artifactPaths) {
|
|
3183
|
+
c.addChild(new Text(fit(theme.fg("dim", ` artifacts: ${shortenPath(r.artifactPaths.outputPath)}`)), 0, 0));
|
|
3184
|
+
}
|
|
3185
|
+
if (expanded && !rRunning) {
|
|
3186
|
+
for (const line of toolCallLines) {
|
|
3187
|
+
c.addChild(new Text(fit(theme.fg("muted", ` ${line}`)), 0, 0));
|
|
3188
|
+
}
|
|
3189
|
+
if (toolCallLines.length) c.addChild(new Spacer(1));
|
|
3190
|
+
}
|
|
3191
|
+
c.addChild(new Spacer(1));
|
|
3192
|
+
}
|
|
3193
|
+
if (d.artifacts) {
|
|
3194
|
+
c.addChild(new Spacer(1));
|
|
3195
|
+
c.addChild(new Text(fit(theme.fg("dim", `Artifacts dir: ${shortenPath(d.artifacts.dir)}`)), 0, 0));
|
|
3196
|
+
}
|
|
3197
|
+
return c;
|
|
3198
|
+
}
|
|
3199
|
+
|
|
3200
|
+
// src/tui/fleet-status.ts
|
|
3201
|
+
import { isKeyRelease, Key, matchesKey, truncateToWidth as truncateToWidth2, visibleWidth as visibleWidth3 } from "@earendil-works/pi-tui";
|
|
3202
|
+
var FLEET_STATUS_WIDGET_KEY = "subagent-fleet-status";
|
|
3203
|
+
var MAX_AGENT_ROWS = 6;
|
|
3204
|
+
var REFRESH_MS = 500;
|
|
3205
|
+
var FLEET_AGENT_IDENTITY_COLORS = [
|
|
3206
|
+
"mdLink",
|
|
3207
|
+
"mdHeading",
|
|
3208
|
+
"syntaxFunction",
|
|
3209
|
+
"syntaxKeyword",
|
|
3210
|
+
"syntaxNumber",
|
|
3211
|
+
"syntaxType",
|
|
3212
|
+
"syntaxVariable",
|
|
3213
|
+
"customMessageLabel",
|
|
3214
|
+
"toolTitle",
|
|
3215
|
+
"thinkingMedium",
|
|
3216
|
+
"thinkingHigh",
|
|
3217
|
+
"mdQuote",
|
|
3218
|
+
"bashMode",
|
|
3219
|
+
"userMessageText",
|
|
3220
|
+
"mdCode",
|
|
3221
|
+
"syntaxOperator"
|
|
3222
|
+
];
|
|
3223
|
+
function fleetAgentIdentityColor(identity) {
|
|
3224
|
+
let hash = 2166136261;
|
|
3225
|
+
for (let i = 0; i < identity.length; i++) {
|
|
3226
|
+
hash ^= identity.charCodeAt(i);
|
|
3227
|
+
hash = Math.imul(hash, 16777619);
|
|
3228
|
+
}
|
|
3229
|
+
return FLEET_AGENT_IDENTITY_COLORS[(hash >>> 0) % FLEET_AGENT_IDENTITY_COLORS.length];
|
|
3230
|
+
}
|
|
3231
|
+
function resolveFleetViewPlacement(value) {
|
|
3232
|
+
return value === "aboveEditor" ? "aboveEditor" : "belowEditor";
|
|
3233
|
+
}
|
|
3234
|
+
function formatFleetElapsed(ms) {
|
|
3235
|
+
return `${Math.max(0, Math.round(ms / 1e3))}s`;
|
|
3236
|
+
}
|
|
3237
|
+
function detailElapsed(row) {
|
|
3238
|
+
const duration = row.state === "running" && row.startedAt !== void 0 ? Date.now() - row.startedAt : row.durationMs ?? (row.startedAt !== void 0 && row.endedAt !== void 0 ? row.endedAt - row.startedAt : void 0);
|
|
3239
|
+
return duration !== void 0 ? formatFleetElapsed(duration) : void 0;
|
|
3240
|
+
}
|
|
3241
|
+
function formatFleetTokens(count, window, windowCount = 1) {
|
|
3242
|
+
const compact = (value) => value >= 1e6 ? `${(value / 1e6).toFixed(1)}M` : value >= 1e3 ? `${(value / 1e3).toFixed(1)}k` : `${Math.max(0, Math.round(value))}`;
|
|
3243
|
+
return window !== void 0 ? `\u2193 ${compact(window)} ${windowCount > 1 ? "\u03A3 windows" : "window"} \xB7 ${compact(count)} spent` : `\u2193 ${compact(count)} tokens`;
|
|
3244
|
+
}
|
|
3245
|
+
function rightAlign(left, right, width) {
|
|
3246
|
+
const rightWidth = visibleWidth3(right);
|
|
3247
|
+
const maxLeftWidth = Math.max(0, width - rightWidth - 1);
|
|
3248
|
+
const leftClamped = truncateToWidth2(left, maxLeftWidth);
|
|
3249
|
+
const gap = Math.max(1, width - visibleWidth3(leftClamped) - rightWidth);
|
|
3250
|
+
return truncateToWidth2(`${leftClamped}${" ".repeat(gap)}${right}`, width);
|
|
3251
|
+
}
|
|
3252
|
+
function isActiveState(value) {
|
|
3253
|
+
return value === "running" || value === "queued" || value === "pending";
|
|
3254
|
+
}
|
|
3255
|
+
function nestedRunLabel(run) {
|
|
3256
|
+
if (run.agent) return run.agent;
|
|
3257
|
+
if (run.agents?.length) return run.agents.length === 1 ? run.agents[0] : `${run.agents.slice(0, 2).join(", ")}${run.agents.length > 2 ? ` +${run.agents.length - 2}` : ""}`;
|
|
3258
|
+
return run.id;
|
|
3259
|
+
}
|
|
3260
|
+
function nestedActivity2(node) {
|
|
3261
|
+
if (node.currentTool) return `tool ${node.currentTool}`;
|
|
3262
|
+
if (node.currentPath) return node.currentPath.split(/[\\/]/).at(-1);
|
|
3263
|
+
if (node.activityState === "needs_attention") return "needs attention";
|
|
3264
|
+
if (node.activityState === "active_long_running") return "long-running";
|
|
3265
|
+
return void 0;
|
|
3266
|
+
}
|
|
3267
|
+
function visibleWorkflowRows2(rows, visibleLimit) {
|
|
3268
|
+
if (!rows?.length) return [];
|
|
3269
|
+
if (rows.length <= visibleLimit) return rows;
|
|
3270
|
+
const selected = /* @__PURE__ */ new Set();
|
|
3271
|
+
for (const [index, row] of rows.entries()) {
|
|
3272
|
+
if (!isWorkflowRowTerminal(row)) selected.add(index);
|
|
3273
|
+
if (selected.size >= visibleLimit) break;
|
|
3274
|
+
}
|
|
3275
|
+
for (let index = rows.length - 1; index >= 0 && selected.size < visibleLimit; index--) selected.add(index);
|
|
3276
|
+
const visible = [...selected].sort((left, right) => left - right).map((index) => rows[index]);
|
|
3277
|
+
return [{ name: `\u2026 +${rows.length - visible.length} hidden workflow steps`, state: "complete", overflow: rows.length - visible.length }, ...visible];
|
|
3278
|
+
}
|
|
3279
|
+
function visibleWorkflowPhases(checklist, visibleLimit) {
|
|
3280
|
+
const phases = checklist?.phases ?? [];
|
|
3281
|
+
if (phases.length <= visibleLimit) return phases;
|
|
3282
|
+
const selected = /* @__PURE__ */ new Set();
|
|
3283
|
+
for (const [index, phase] of phases.entries()) {
|
|
3284
|
+
if (phase.state !== "complete") selected.add(index);
|
|
3285
|
+
if (selected.size >= visibleLimit) break;
|
|
3286
|
+
}
|
|
3287
|
+
for (let index = phases.length - 1; index >= 0 && selected.size < visibleLimit; index--) selected.add(index);
|
|
3288
|
+
return [...selected].sort((left, right) => left - right).map((index) => phases[index]);
|
|
3289
|
+
}
|
|
3290
|
+
function isWorkflowRowTerminal(row) {
|
|
3291
|
+
if (row.kind) return row.state === "done" || row.state === "cancelled" || row.state === "error";
|
|
3292
|
+
return row.state === "complete" || row.state === "completed";
|
|
3293
|
+
}
|
|
3294
|
+
function nestedStatusGlyph2(state, theme, thinking) {
|
|
3295
|
+
if (state === "running") return runningTone(theme, thinking)("\u25CF");
|
|
3296
|
+
if (state === "queued" || state === "pending" || state === "planned") return theme.fg("muted", "\u25E6");
|
|
3297
|
+
if (state === "complete" || state === "completed") return theme.fg("success", "\u2713");
|
|
3298
|
+
if (state === "failed" || state === "rejected") return theme.fg("error", "\u2717");
|
|
3299
|
+
return theme.fg("warning", "\u25A0");
|
|
3300
|
+
}
|
|
3301
|
+
function nestedStepDisplayCount(steps, start = 0) {
|
|
3302
|
+
let count = 0;
|
|
3303
|
+
for (let index = start; index < (steps?.length ?? 0); index++) {
|
|
3304
|
+
count += 1 + nestedDisplayCount(steps[index].children);
|
|
3305
|
+
}
|
|
3306
|
+
return count;
|
|
3307
|
+
}
|
|
3308
|
+
function nestedDisplayCount(children, start = 0) {
|
|
3309
|
+
let count = 0;
|
|
3310
|
+
for (let index = start; index < (children?.length ?? 0); index++) {
|
|
3311
|
+
const child = children[index];
|
|
3312
|
+
const steps = child.mode === "parallel" || child.mode === "chain" ? child.steps ?? [] : [];
|
|
3313
|
+
count += steps.length > 0 ? nestedStepDisplayCount(steps) : 1;
|
|
3314
|
+
count += nestedDisplayCount(child.children);
|
|
3315
|
+
}
|
|
3316
|
+
return count;
|
|
3317
|
+
}
|
|
3318
|
+
function nestedFleetRows(children, visibleLimit) {
|
|
3319
|
+
const rows = [];
|
|
3320
|
+
let omitted = 0;
|
|
3321
|
+
const appendRuns = (runs, depth) => {
|
|
3322
|
+
for (let runIndex = 0; runIndex < (runs?.length ?? 0); runIndex++) {
|
|
3323
|
+
const child = runs[runIndex];
|
|
3324
|
+
const steps = child.mode === "parallel" || child.mode === "chain" ? child.steps ?? [] : [];
|
|
3325
|
+
if (steps.length > 0) {
|
|
3326
|
+
for (let stepIndex = 0; stepIndex < steps.length; stepIndex++) {
|
|
3327
|
+
if (rows.length >= visibleLimit) {
|
|
3328
|
+
omitted += nestedStepDisplayCount(steps, stepIndex);
|
|
3329
|
+
omitted += nestedDisplayCount(child.children);
|
|
3330
|
+
omitted += nestedDisplayCount(runs, runIndex + 1);
|
|
3331
|
+
return false;
|
|
3332
|
+
}
|
|
3333
|
+
const step = steps[stepIndex];
|
|
3334
|
+
const modelThinking = formatModelThinking(step.model, step.thinking) || void 0;
|
|
3335
|
+
const thinking = childThinkingLevel(step);
|
|
3336
|
+
const activity = nestedActivity2(step);
|
|
3337
|
+
rows.push({
|
|
3338
|
+
name: step.agent,
|
|
3339
|
+
agentIdentity: step.agent,
|
|
3340
|
+
state: step.status,
|
|
3341
|
+
depth,
|
|
3342
|
+
...modelThinking ? { modelThinking } : {},
|
|
3343
|
+
...thinking ? { thinking } : {},
|
|
3344
|
+
...activity ? { activity } : {},
|
|
3345
|
+
...step.startedAt !== void 0 ? { startedAt: step.startedAt } : {},
|
|
3346
|
+
...step.endedAt !== void 0 ? { endedAt: step.endedAt } : {}
|
|
3347
|
+
});
|
|
3348
|
+
if (!appendRuns(step.children, depth + 1)) {
|
|
3349
|
+
omitted += nestedStepDisplayCount(steps, stepIndex + 1);
|
|
3350
|
+
omitted += nestedDisplayCount(child.children);
|
|
3351
|
+
omitted += nestedDisplayCount(runs, runIndex + 1);
|
|
3352
|
+
return false;
|
|
3353
|
+
}
|
|
3354
|
+
}
|
|
3355
|
+
} else {
|
|
3356
|
+
if (rows.length >= visibleLimit) {
|
|
3357
|
+
omitted += nestedDisplayCount(runs, runIndex);
|
|
3358
|
+
return false;
|
|
3359
|
+
}
|
|
3360
|
+
const modelThinking = formatModelThinking(child.model, child.thinking) || void 0;
|
|
3361
|
+
const thinking = childThinkingLevel(child);
|
|
3362
|
+
const activity = nestedActivity2(child);
|
|
3363
|
+
rows.push({
|
|
3364
|
+
name: nestedRunLabel(child),
|
|
3365
|
+
agentIdentity: child.agent ?? child.agents?.join("\0") ?? child.id,
|
|
3366
|
+
state: child.state,
|
|
3367
|
+
depth,
|
|
3368
|
+
...modelThinking ? { modelThinking } : {},
|
|
3369
|
+
...thinking ? { thinking } : {},
|
|
3370
|
+
...activity ? { activity } : {},
|
|
3371
|
+
...child.startedAt !== void 0 ? { startedAt: child.startedAt } : {},
|
|
3372
|
+
...child.endedAt !== void 0 ? { endedAt: child.endedAt } : {}
|
|
3373
|
+
});
|
|
3374
|
+
}
|
|
3375
|
+
if (!appendRuns(child.children, depth + 1)) {
|
|
3376
|
+
omitted += nestedDisplayCount(runs, runIndex + 1);
|
|
3377
|
+
return false;
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
return true;
|
|
3381
|
+
};
|
|
3382
|
+
appendRuns(children, 0);
|
|
3383
|
+
if (omitted > 0) rows.push({ name: `\u2026 +${omitted} more nested leaves`, state: "complete", depth: 0, overflow: omitted });
|
|
3384
|
+
return rows;
|
|
3385
|
+
}
|
|
3386
|
+
function fleetTreeRows(entries) {
|
|
3387
|
+
const rows = [];
|
|
3388
|
+
const entryKeys = new Set(entries.map((entry) => entry.key));
|
|
3389
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
3390
|
+
for (const entry of entries) {
|
|
3391
|
+
if (!entry.parentKey || !entryKeys.has(entry.parentKey)) continue;
|
|
3392
|
+
const children = childrenByParent.get(entry.parentKey) ?? [];
|
|
3393
|
+
children.push(entry);
|
|
3394
|
+
childrenByParent.set(entry.parentKey, children);
|
|
3395
|
+
}
|
|
3396
|
+
for (const entry of entries) {
|
|
3397
|
+
if (entry.parentKey && entryKeys.has(entry.parentKey)) continue;
|
|
3398
|
+
rows.push({ kind: "owner", entry });
|
|
3399
|
+
const attached = childrenByParent.get(entry.key) ?? [];
|
|
3400
|
+
const workflowPhases = visibleWorkflowPhases(entry.workflowChecklist, attached.length > 0 ? 2 : 4);
|
|
3401
|
+
const workflowRows = visibleWorkflowRows2(entry.workflowRows, attached.length > 0 ? 2 : 4);
|
|
3402
|
+
for (const [index, child] of attached.entries()) {
|
|
3403
|
+
const nested2 = nestedFleetRows(child.nestedChildren, 3);
|
|
3404
|
+
const laterRows = index < attached.length - 1 || workflowPhases.length > 0 || workflowRows.length > 0 || Boolean(entry.nestedChildren?.length);
|
|
3405
|
+
rows.push({ kind: "child", entry: child, last: !laterRows && nested2.length === 0 });
|
|
3406
|
+
for (const [nestedIndex, row] of nested2.entries()) rows.push({
|
|
3407
|
+
kind: "nested",
|
|
3408
|
+
ownerKey: child.key,
|
|
3409
|
+
row: { ...row, depth: row.depth + 1 },
|
|
3410
|
+
last: nestedIndex === nested2.length - 1 && !laterRows
|
|
3411
|
+
});
|
|
3412
|
+
}
|
|
3413
|
+
for (const [index, phase] of workflowPhases.entries()) rows.push({
|
|
3414
|
+
kind: "workflow-phase",
|
|
3415
|
+
ownerKey: entry.key,
|
|
3416
|
+
phase,
|
|
3417
|
+
last: index === workflowPhases.length - 1 && workflowRows.length === 0 && !entry.nestedChildren?.length
|
|
3418
|
+
});
|
|
3419
|
+
for (const [index, row] of workflowRows.entries()) rows.push({ kind: "workflow", ownerKey: entry.key, row, last: index === workflowRows.length - 1 && !entry.nestedChildren?.length });
|
|
3420
|
+
const nested = nestedFleetRows(entry.nestedChildren, attached.length > 0 ? 3 : 4);
|
|
3421
|
+
for (const [index, row] of nested.entries()) rows.push({ kind: "nested", ownerKey: entry.key, row, last: index === nested.length - 1 });
|
|
3422
|
+
}
|
|
3423
|
+
return rows;
|
|
3424
|
+
}
|
|
3425
|
+
function foregroundDescription(control, description) {
|
|
3426
|
+
if (!control.parentWorkflowRunId) return description;
|
|
3427
|
+
const workflow = `workflow child: ${control.parentWorkflowRunId}${control.workflowKey ? ` (${control.workflowKey})` : ""}`;
|
|
3428
|
+
return description ? `${workflow} \xB7 ${description}` : workflow;
|
|
3429
|
+
}
|
|
3430
|
+
function workflowIdentityCandidates(step) {
|
|
3431
|
+
return [...new Set([step.workflowKey, step.runId].filter((value) => typeof value === "string" && value.length > 0))];
|
|
3432
|
+
}
|
|
3433
|
+
function asyncJobIdentityCandidates(job) {
|
|
3434
|
+
return [...new Set([job.workflowKey, job.asyncId].filter((value) => typeof value === "string" && value.length > 0))];
|
|
3435
|
+
}
|
|
3436
|
+
function linkedWorkflowParentKey(parentWorkflowRunId, activeWorkflowKeys) {
|
|
3437
|
+
if (!parentWorkflowRunId) return void 0;
|
|
3438
|
+
const parentKey = `async:${parentWorkflowRunId}`;
|
|
3439
|
+
return activeWorkflowKeys.has(parentKey) ? parentKey : void 0;
|
|
3440
|
+
}
|
|
3441
|
+
function workflowStepsWithoutMaterializedChildren(steps, materializedChildIds) {
|
|
3442
|
+
if (!steps?.length || !materializedChildIds?.size) return steps;
|
|
3443
|
+
return steps.filter((step) => !workflowIdentityCandidates(step).some((identity) => materializedChildIds.has(identity)));
|
|
3444
|
+
}
|
|
3445
|
+
function activeLeafAgentCount(entries) {
|
|
3446
|
+
return entries.filter((entry) => !entry.workflowWrapper && !entry.surface).length;
|
|
3447
|
+
}
|
|
3448
|
+
function projectPaneNeedsAttention(pane) {
|
|
3449
|
+
return ["attention", "blocked", "paused", "failed", "error"].some((status) => pane.agentStatus.includes(status)) || pane.summary?.includes("\u26A0") === true;
|
|
3450
|
+
}
|
|
3451
|
+
function projectName(projectRoot) {
|
|
3452
|
+
return projectRoot.split(/[\\/]/).filter(Boolean).at(-1) ?? projectRoot;
|
|
3453
|
+
}
|
|
3454
|
+
function projectPaneEntries(state) {
|
|
3455
|
+
return [...state.herdrProjectPanes?.values() ?? []].filter((pane) => pane.state === "open").sort((left, right) => left.openedAt.localeCompare(right.openedAt) || left.projectRoot.localeCompare(right.projectRoot)).map((pane) => ({
|
|
3456
|
+
key: `project-pane:${pane.projectRoot}`,
|
|
3457
|
+
surface: "project-pane",
|
|
3458
|
+
agent: `${projectName(pane.projectRoot)} \xB7 ${pane.paneId}`,
|
|
3459
|
+
description: pane.summary,
|
|
3460
|
+
startedAt: Date.parse(pane.openedAt) || pane.refreshedAt,
|
|
3461
|
+
tokens: 0,
|
|
3462
|
+
state: pane.agentStatus || "unknown",
|
|
3463
|
+
projectPane: pane
|
|
3464
|
+
}));
|
|
3465
|
+
}
|
|
3466
|
+
var reportedFleetWarnings = /* @__PURE__ */ new Set();
|
|
3467
|
+
function reportFleetWarning(state, message) {
|
|
3468
|
+
if (reportedFleetWarnings.has(message)) return;
|
|
3469
|
+
reportedFleetWarnings.add(message);
|
|
3470
|
+
const text = `[pi-subagents] ${message}`;
|
|
3471
|
+
const cached = state.lastUiContext;
|
|
3472
|
+
const notified = withCachedUiContext(cached, () => {
|
|
3473
|
+
if (state.lastUiContext === cached) state.lastUiContext = null;
|
|
3474
|
+
}, (ctx) => {
|
|
3475
|
+
ctx.ui.notify(text, "warning");
|
|
3476
|
+
return true;
|
|
3477
|
+
});
|
|
3478
|
+
if (!notified) console.warn(text);
|
|
3479
|
+
}
|
|
3480
|
+
function collectFleetStatusEntries(state) {
|
|
3481
|
+
const now = Date.now();
|
|
3482
|
+
const entries = [];
|
|
3483
|
+
const activeWorkflowKeys = new Set([...state.asyncJobs.values()].filter((job) => job.mode === "workflow" && isActiveState(job.status)).map((job) => `async:${job.asyncId}`));
|
|
3484
|
+
const materializedChildrenByWorkflow = /* @__PURE__ */ new Map();
|
|
3485
|
+
for (const job of state.asyncJobs.values()) {
|
|
3486
|
+
if (!isActiveState(job.status) || !job.parentWorkflowRunId) continue;
|
|
3487
|
+
const parentKey = linkedWorkflowParentKey(job.parentWorkflowRunId, activeWorkflowKeys);
|
|
3488
|
+
if (!parentKey) continue;
|
|
3489
|
+
const childIds = materializedChildrenByWorkflow.get(parentKey) ?? /* @__PURE__ */ new Set();
|
|
3490
|
+
for (const identity of asyncJobIdentityCandidates(job)) childIds.add(identity);
|
|
3491
|
+
materializedChildrenByWorkflow.set(parentKey, childIds);
|
|
3492
|
+
}
|
|
3493
|
+
for (const control of state.foregroundControls.values()) {
|
|
3494
|
+
const linkedParentKey = linkedWorkflowParentKey(control.parentWorkflowRunId, activeWorkflowKeys);
|
|
3495
|
+
if (control.activeChildren) {
|
|
3496
|
+
const nestedChildren = control.nestedChildren ?? [];
|
|
3497
|
+
const nestedChildrenByParentStep = /* @__PURE__ */ new Map();
|
|
3498
|
+
for (const nested of nestedChildren) {
|
|
3499
|
+
if (nested.parentStepIndex === void 0) continue;
|
|
3500
|
+
const children = nestedChildrenByParentStep.get(nested.parentStepIndex) ?? [];
|
|
3501
|
+
children.push(nested);
|
|
3502
|
+
nestedChildrenByParentStep.set(nested.parentStepIndex, children);
|
|
3503
|
+
}
|
|
3504
|
+
for (const child of [...control.activeChildren.values()].sort((left, right) => left.index - right.index)) {
|
|
3505
|
+
const modelThinking2 = formatModelThinking(child.model, child.thinking) || void 0;
|
|
3506
|
+
const childNestedChildren = nestedChildrenByParentStep.get(child.index) ?? (control.activeChildren.size === 1 && nestedChildren.length ? nestedChildren : void 0);
|
|
3507
|
+
entries.push({
|
|
3508
|
+
key: `foreground-active:${control.runId}:${child.index}`,
|
|
3509
|
+
...linkedParentKey ? { parentKey: linkedParentKey } : {},
|
|
3510
|
+
agent: child.agent,
|
|
3511
|
+
...modelThinking2 ? { modelThinking: modelThinking2 } : {},
|
|
3512
|
+
description: foregroundDescription(control, child.description),
|
|
3513
|
+
startedAt: child.startedAt,
|
|
3514
|
+
tokens: child.tokens ?? 0,
|
|
3515
|
+
...child.window !== void 0 ? { window: child.window } : {},
|
|
3516
|
+
state: "running",
|
|
3517
|
+
...childNestedChildren?.length ? { nestedChildren: childNestedChildren } : {}
|
|
3518
|
+
});
|
|
3519
|
+
}
|
|
3520
|
+
continue;
|
|
3521
|
+
}
|
|
3522
|
+
const modelThinking = formatModelThinking(control.model, control.thinking) || void 0;
|
|
3523
|
+
entries.push({
|
|
3524
|
+
key: `foreground-active:${control.runId}:${control.currentIndex ?? 0}`,
|
|
3525
|
+
...linkedParentKey ? { parentKey: linkedParentKey } : {},
|
|
3526
|
+
agent: control.currentAgent ?? control.mode,
|
|
3527
|
+
...modelThinking ? { modelThinking } : {},
|
|
3528
|
+
description: foregroundDescription(control, control.description),
|
|
3529
|
+
startedAt: control.startedAt,
|
|
3530
|
+
tokens: control.tokens ?? 0,
|
|
3531
|
+
...control.window !== void 0 ? { window: control.window } : {},
|
|
3532
|
+
state: "running",
|
|
3533
|
+
...control.nestedChildren?.length ? { nestedChildren: control.nestedChildren } : {}
|
|
3534
|
+
});
|
|
3535
|
+
}
|
|
3536
|
+
for (const job of state.asyncJobs.values()) {
|
|
3537
|
+
if (!isActiveState(job.status)) continue;
|
|
3538
|
+
const startedAt = job.startedAt ?? job.updatedAt ?? now;
|
|
3539
|
+
const linkedParentKey = linkedWorkflowParentKey(job.parentWorkflowRunId, activeWorkflowKeys);
|
|
3540
|
+
if (job.mode === "workflow") {
|
|
3541
|
+
const latestEmit = job.workflow?.emits?.length ? formatWorkflowJsonPreview(job.workflow.emits.at(-1), 120) : void 0;
|
|
3542
|
+
const workflowSteps = workflowStepsWithoutMaterializedChildren(job.steps, materializedChildrenByWorkflow.get(`async:${job.asyncId}`));
|
|
3543
|
+
const workflowRows = projectAsyncWorkflowRows(workflowSteps, job.workflowGraph ?? job.hostSteps, job.preflight);
|
|
3544
|
+
const workflowChecklist = projectWorkflowChecklist({
|
|
3545
|
+
graph: job.workflowGraph,
|
|
3546
|
+
steps: job.steps,
|
|
3547
|
+
hostSteps: job.hostSteps,
|
|
3548
|
+
preflight: job.preflight,
|
|
3549
|
+
trace: job.workflow?.trace,
|
|
3550
|
+
now
|
|
3551
|
+
});
|
|
3552
|
+
entries.push({
|
|
3553
|
+
key: `async:${job.asyncId}`,
|
|
3554
|
+
...linkedParentKey ? { parentKey: linkedParentKey } : {},
|
|
3555
|
+
workflowWrapper: true,
|
|
3556
|
+
agent: "workflow",
|
|
3557
|
+
description: latestEmit !== void 0 ? `latest emit: ${latestEmit}` : job.description,
|
|
3558
|
+
startedAt,
|
|
3559
|
+
tokens: job.totalTokens?.total ?? 0,
|
|
3560
|
+
...job.totalTokens?.window !== void 0 ? { window: job.totalTokens.window } : {},
|
|
3561
|
+
state: job.status,
|
|
3562
|
+
...workflowRows.length ? { workflowRows } : {},
|
|
3563
|
+
...workflowChecklist.total ? { workflowChecklist } : {},
|
|
3564
|
+
...job.nestedChildren?.length ? { nestedChildren: job.nestedChildren } : {}
|
|
3565
|
+
});
|
|
3566
|
+
continue;
|
|
3567
|
+
}
|
|
3568
|
+
const steps = job.steps?.length ? job.steps : job.agents?.map((agent, index) => {
|
|
3569
|
+
const pending = job.status === "queued" || job.mode === "chain" && !job.activeParallelGroup && index !== (job.currentStep ?? 0);
|
|
3570
|
+
return { agent, index, status: pending ? "pending" : "running" };
|
|
3571
|
+
});
|
|
3572
|
+
if (!steps?.length) {
|
|
3573
|
+
entries.push({
|
|
3574
|
+
key: `async:${job.asyncId}`,
|
|
3575
|
+
...linkedParentKey ? { parentKey: linkedParentKey } : {},
|
|
3576
|
+
agent: job.mode ?? "subagent",
|
|
3577
|
+
description: job.description,
|
|
3578
|
+
startedAt,
|
|
3579
|
+
tokens: job.totalTokens?.total ?? 0,
|
|
3580
|
+
...job.totalTokens?.window !== void 0 ? { window: job.totalTokens.window } : {},
|
|
3581
|
+
state: job.status,
|
|
3582
|
+
...job.nestedChildren?.length ? { nestedChildren: job.nestedChildren } : {}
|
|
3583
|
+
});
|
|
3584
|
+
continue;
|
|
3585
|
+
}
|
|
3586
|
+
for (const [offset, step] of steps.entries()) {
|
|
3587
|
+
if (!isActiveState(step.status)) continue;
|
|
3588
|
+
const index = step.index ?? offset;
|
|
3589
|
+
if (step.status === "pending" && job.mode === "chain" && !job.activeParallelGroup && index !== (job.currentStep ?? 0)) continue;
|
|
3590
|
+
const modelThinking = formatModelThinking(step.model, step.thinking) || void 0;
|
|
3591
|
+
entries.push({
|
|
3592
|
+
key: `async:${job.asyncId}:${index}`,
|
|
3593
|
+
...linkedParentKey ? { parentKey: linkedParentKey } : {},
|
|
3594
|
+
agent: step.agent,
|
|
3595
|
+
...step.label ? { displayLabel: `${step.label} (${step.agent})` } : {},
|
|
3596
|
+
...modelThinking ? { modelThinking } : {},
|
|
3597
|
+
description: step.description ?? job.description,
|
|
3598
|
+
startedAt: step.startedAt ?? startedAt,
|
|
3599
|
+
tokens: step.tokens?.total ?? (steps.length === 1 ? job.totalTokens?.total ?? 0 : 0),
|
|
3600
|
+
...(step.tokens?.window ?? (steps.length === 1 ? job.totalTokens?.window : void 0)) !== void 0 ? { window: step.tokens?.window ?? job.totalTokens?.window } : {},
|
|
3601
|
+
state: step.status,
|
|
3602
|
+
...(step.children?.length ?? 0) > 0 ? { nestedChildren: step.children } : job.nestedChildren?.filter((nested) => nested.parentStepIndex === index).length ? { nestedChildren: job.nestedChildren.filter((nested) => nested.parentStepIndex === index) } : {}
|
|
3603
|
+
});
|
|
3604
|
+
}
|
|
3605
|
+
}
|
|
3606
|
+
if (state.currentSessionId) {
|
|
3607
|
+
try {
|
|
3608
|
+
for (const run of snapshotExternalRuns(state.currentSessionId, { ignoreMalformed: true, onMalformedRecord: (message) => reportFleetWarning(state, `Removed ${message}`) })) {
|
|
3609
|
+
if (!isActiveState(run.state)) continue;
|
|
3610
|
+
entries.push({
|
|
3611
|
+
key: `external:${run.id}`,
|
|
3612
|
+
agent: `external \xB7 ${run.label}`,
|
|
3613
|
+
description: run.currentAction ?? `source: ${run.source}`,
|
|
3614
|
+
startedAt: run.startedAt,
|
|
3615
|
+
tokens: 0,
|
|
3616
|
+
state: run.state,
|
|
3617
|
+
external: true
|
|
3618
|
+
});
|
|
3619
|
+
}
|
|
3620
|
+
} catch (cause) {
|
|
3621
|
+
reportFleetWarning(state, `Failed to inspect external jobs: ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
3622
|
+
}
|
|
3623
|
+
}
|
|
3624
|
+
entries.push(...projectPaneEntries(state));
|
|
3625
|
+
return entries.sort((left, right) => left.startedAt - right.startedAt || left.key.localeCompare(right.key));
|
|
3626
|
+
}
|
|
3627
|
+
var SubagentFleetStatus = class {
|
|
3628
|
+
ctx;
|
|
3629
|
+
ui;
|
|
3630
|
+
tui;
|
|
3631
|
+
inputUnsubscribe;
|
|
3632
|
+
timer;
|
|
3633
|
+
widgetRegistered = false;
|
|
3634
|
+
active = false;
|
|
3635
|
+
selectedKey = "main";
|
|
3636
|
+
inspectorOpen = false;
|
|
3637
|
+
lastRenderKey = "";
|
|
3638
|
+
lastPaint;
|
|
3639
|
+
prepaint;
|
|
3640
|
+
entries = [];
|
|
3641
|
+
workflowSnapshots = /* @__PURE__ */ new Map();
|
|
3642
|
+
onWorkflowCoverageChange;
|
|
3643
|
+
state;
|
|
3644
|
+
openInspector;
|
|
3645
|
+
refreshMs;
|
|
3646
|
+
maxAgentRows;
|
|
3647
|
+
placement;
|
|
3648
|
+
constructor(state, openInspector, options = {}) {
|
|
3649
|
+
this.state = state;
|
|
3650
|
+
this.openInspector = openInspector;
|
|
3651
|
+
this.refreshMs = options.refreshMs ?? REFRESH_MS;
|
|
3652
|
+
this.maxAgentRows = options.maxAgentRows ?? MAX_AGENT_ROWS;
|
|
3653
|
+
this.placement = options.placement ?? "belowEditor";
|
|
3654
|
+
this.onWorkflowCoverageChange = options.onWorkflowCoverageChange;
|
|
3655
|
+
}
|
|
3656
|
+
setContext(ctx) {
|
|
3657
|
+
if (!ctx.hasUI) {
|
|
3658
|
+
this.clearUiRegistration();
|
|
3659
|
+
return;
|
|
3660
|
+
}
|
|
3661
|
+
const ui = ctx.ui;
|
|
3662
|
+
if (this.ui === ui) {
|
|
3663
|
+
this.ctx = ctx;
|
|
3664
|
+
this.refresh();
|
|
3665
|
+
return;
|
|
3666
|
+
}
|
|
3667
|
+
this.clearUiRegistration();
|
|
3668
|
+
this.ctx = ctx;
|
|
3669
|
+
this.ui = ui;
|
|
3670
|
+
if (typeof ui.onTerminalInput === "function") {
|
|
3671
|
+
this.inputUnsubscribe = ui.onTerminalInput((data) => this.handleKey(data));
|
|
3672
|
+
}
|
|
3673
|
+
this.timer = setInterval(() => this.refresh(), this.refreshMs);
|
|
3674
|
+
this.timer.unref?.();
|
|
3675
|
+
this.refresh();
|
|
3676
|
+
}
|
|
3677
|
+
dispose() {
|
|
3678
|
+
this.clearUiRegistration();
|
|
3679
|
+
this.ctx = void 0;
|
|
3680
|
+
this.ui = void 0;
|
|
3681
|
+
this.entries = [];
|
|
3682
|
+
this.active = false;
|
|
3683
|
+
this.selectedKey = "main";
|
|
3684
|
+
this.inspectorOpen = false;
|
|
3685
|
+
this.lastRenderKey = "";
|
|
3686
|
+
}
|
|
3687
|
+
refresh() {
|
|
3688
|
+
this.prepaint = void 0;
|
|
3689
|
+
const ctx = this.getActiveUiContext();
|
|
3690
|
+
if (!ctx) return;
|
|
3691
|
+
if (this.state.widgetsSuspended) {
|
|
3692
|
+
this.clearWidget();
|
|
3693
|
+
return;
|
|
3694
|
+
}
|
|
3695
|
+
this.entries = collectFleetStatusEntries(this.state);
|
|
3696
|
+
this.workflowSnapshots.clear();
|
|
3697
|
+
if (this.active && !this.inspectorOpen && !this.state.fleetInspectorOpen && this.onWorkflowCoverageChange) {
|
|
3698
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
3699
|
+
for (const child of this.state.asyncJobs.values()) {
|
|
3700
|
+
if (!child.parentWorkflowRunId) continue;
|
|
3701
|
+
const children = childrenByParent.get(child.parentWorkflowRunId) ?? [];
|
|
3702
|
+
children.push(child);
|
|
3703
|
+
childrenByParent.set(child.parentWorkflowRunId, children);
|
|
3704
|
+
}
|
|
3705
|
+
const attachedByParent = /* @__PURE__ */ new Map();
|
|
3706
|
+
for (const entry of this.entries) {
|
|
3707
|
+
if (!entry.parentKey) continue;
|
|
3708
|
+
const attached = attachedByParent.get(entry.parentKey) ?? [];
|
|
3709
|
+
attached.push(entry);
|
|
3710
|
+
attachedByParent.set(entry.parentKey, attached);
|
|
3711
|
+
}
|
|
3712
|
+
for (const job of this.state.asyncJobs.values()) {
|
|
3713
|
+
if (job.mode !== "workflow" || !isActiveState(job.status) || job.parentWorkflowRunId || job.nestedChildren?.length || job.steps?.some((step) => step.children?.length)) continue;
|
|
3714
|
+
const key = `async:${job.asyncId}`;
|
|
3715
|
+
const children = childrenByParent.get(job.asyncId) ?? [];
|
|
3716
|
+
const attached = attachedByParent.get(key) ?? [];
|
|
3717
|
+
if (children.length && job.status !== "running") continue;
|
|
3718
|
+
if (attached.length >= this.maxAgentRows) continue;
|
|
3719
|
+
const rowKeys = /* @__PURE__ */ new Set();
|
|
3720
|
+
let unsupported = false;
|
|
3721
|
+
for (const child of children) {
|
|
3722
|
+
if (!isActiveState(child.status) || child.mode !== "single" && child.mode !== "parallel" && child.mode !== "chain" || child.hostSteps?.length || child.workflowGraph || childrenByParent.has(child.asyncId) || child.nestedChildren?.length || child.steps?.some((step) => step.children?.length || step.runner || !isActiveState(step.status))) {
|
|
3723
|
+
unsupported = true;
|
|
3724
|
+
break;
|
|
3725
|
+
}
|
|
3726
|
+
const count = child.steps?.length || child.agents?.length || 0;
|
|
3727
|
+
if (!count || (child.stepsTotal ?? 0) > count || (child.chainStepCount ?? 0) > count) {
|
|
3728
|
+
unsupported = true;
|
|
3729
|
+
break;
|
|
3730
|
+
}
|
|
3731
|
+
for (let index = 0; index < count; index++) rowKeys.add(`async:${child.asyncId}:${child.steps?.[index]?.index ?? index}`);
|
|
3732
|
+
}
|
|
3733
|
+
if (unsupported || attached.length !== rowKeys.size || attached.some((entry) => !rowKeys.has(entry.key))) continue;
|
|
3734
|
+
this.workflowSnapshots.set(key, { snapshot: inlineWorkflowRenderKey(job, children), childRows: rowKeys });
|
|
3735
|
+
}
|
|
3736
|
+
}
|
|
3737
|
+
this.clampSelection();
|
|
3738
|
+
if (this.inspectorOpen || this.state.fleetInspectorOpen) {
|
|
3739
|
+
this.lastRenderKey = "";
|
|
3740
|
+
this.clearWidget();
|
|
3741
|
+
return;
|
|
3742
|
+
}
|
|
3743
|
+
if (!this.hasInlineSurface()) {
|
|
3744
|
+
this.active = false;
|
|
3745
|
+
this.selectedKey = "main";
|
|
3746
|
+
this.lastRenderKey = "";
|
|
3747
|
+
this.clearWidget();
|
|
3748
|
+
return;
|
|
3749
|
+
}
|
|
3750
|
+
const renderKey = this.getRenderKey();
|
|
3751
|
+
if (!this.active) this.clearWorkflowCoverage();
|
|
3752
|
+
else if (renderKey !== this.lastRenderKey && this.lastPaint) {
|
|
3753
|
+
const { width, theme } = this.lastPaint;
|
|
3754
|
+
this.prepaint = { key: renderKey, width, theme, lines: this.render(width, theme) };
|
|
3755
|
+
}
|
|
3756
|
+
if (!this.widgetRegistered) {
|
|
3757
|
+
ctx.ui.setWidget(FLEET_STATUS_WIDGET_KEY, (tui, theme) => {
|
|
3758
|
+
this.tui = tui;
|
|
3759
|
+
return {
|
|
3760
|
+
render: (width) => {
|
|
3761
|
+
this.lastPaint = { width, theme };
|
|
3762
|
+
const prepaint = this.prepaint;
|
|
3763
|
+
this.prepaint = void 0;
|
|
3764
|
+
if (prepaint && prepaint.key === this.lastRenderKey && prepaint.key === this.getRenderKey() && prepaint.width === width && prepaint.theme === theme && !this.state.widgetsSuspended && !this.inspectorOpen && !this.state.fleetInspectorOpen) return prepaint.lines;
|
|
3765
|
+
return this.render(width, theme);
|
|
3766
|
+
},
|
|
3767
|
+
invalidate: () => {
|
|
3768
|
+
this.lastRenderKey = "";
|
|
3769
|
+
this.prepaint = void 0;
|
|
3770
|
+
},
|
|
3771
|
+
dispose: () => {
|
|
3772
|
+
if (this.tui !== tui) return;
|
|
3773
|
+
this.prepaint = void 0;
|
|
3774
|
+
this.lastPaint = void 0;
|
|
3775
|
+
this.clearWorkflowCoverage();
|
|
3776
|
+
this.widgetRegistered = false;
|
|
3777
|
+
this.tui = void 0;
|
|
3778
|
+
}
|
|
3779
|
+
};
|
|
3780
|
+
}, { placement: this.placement });
|
|
3781
|
+
this.widgetRegistered = true;
|
|
3782
|
+
this.lastRenderKey = renderKey;
|
|
3783
|
+
return;
|
|
3784
|
+
}
|
|
3785
|
+
if (renderKey === this.lastRenderKey) {
|
|
3786
|
+
if (this.entries.some((entry) => entry.state === "running")) this.tui?.requestRender();
|
|
3787
|
+
return;
|
|
3788
|
+
}
|
|
3789
|
+
this.lastRenderKey = renderKey;
|
|
3790
|
+
this.tui?.requestRender();
|
|
3791
|
+
}
|
|
3792
|
+
handleKey(data) {
|
|
3793
|
+
if (this.state.widgetsSuspended) return void 0;
|
|
3794
|
+
const ctx = this.getActiveUiContext();
|
|
3795
|
+
if (!ctx || this.entries.length === 0 || isKeyRelease(data)) return void 0;
|
|
3796
|
+
if (this.inspectorOpen) return void 0;
|
|
3797
|
+
if (!this.editorHasFocus()) {
|
|
3798
|
+
if (this.active) this.deactivate();
|
|
3799
|
+
return void 0;
|
|
3800
|
+
}
|
|
3801
|
+
if (!this.active) {
|
|
3802
|
+
const activates = matchesKey(data, "down") || matchesKey(data, "left");
|
|
3803
|
+
if (!activates || ctx.ui.getEditorText() !== "") return void 0;
|
|
3804
|
+
this.active = true;
|
|
3805
|
+
this.selectedKey = "main";
|
|
3806
|
+
this.refresh();
|
|
3807
|
+
return { consume: true };
|
|
3808
|
+
}
|
|
3809
|
+
const roster = this.rosterKeys();
|
|
3810
|
+
const selectedIndex = Math.max(0, roster.indexOf(this.selectedKey));
|
|
3811
|
+
if (matchesKey(data, "down") || matchesKey(data, "j")) {
|
|
3812
|
+
this.selectedKey = roster[Math.min(roster.length - 1, selectedIndex + 1)] ?? "main";
|
|
3813
|
+
this.refresh();
|
|
3814
|
+
return { consume: true };
|
|
3815
|
+
}
|
|
3816
|
+
if (matchesKey(data, "up") || matchesKey(data, "k")) {
|
|
3817
|
+
if (selectedIndex === 0) {
|
|
3818
|
+
this.deactivate();
|
|
3819
|
+
return { consume: true };
|
|
3820
|
+
}
|
|
3821
|
+
this.selectedKey = roster[selectedIndex - 1] ?? "main";
|
|
3822
|
+
this.refresh();
|
|
3823
|
+
return { consume: true };
|
|
3824
|
+
}
|
|
3825
|
+
if (matchesKey(data, "escape")) {
|
|
3826
|
+
this.deactivate();
|
|
3827
|
+
return { consume: true };
|
|
3828
|
+
}
|
|
3829
|
+
if (matchesKey(data, Key.enter)) {
|
|
3830
|
+
if (this.selectedKey === "main") {
|
|
3831
|
+
this.deactivate();
|
|
3832
|
+
return { consume: true };
|
|
3833
|
+
}
|
|
3834
|
+
this.inspectorOpen = true;
|
|
3835
|
+
this.refresh();
|
|
3836
|
+
const selectedKey = this.selectedKey;
|
|
3837
|
+
void Promise.resolve().then(() => this.openInspector(selectedKey)).catch((error) => ctx.ui.notify(error instanceof Error ? error.message : String(error), "error")).finally(() => {
|
|
3838
|
+
this.inspectorOpen = false;
|
|
3839
|
+
this.refresh();
|
|
3840
|
+
});
|
|
3841
|
+
return { consume: true };
|
|
3842
|
+
}
|
|
3843
|
+
this.deactivate();
|
|
3844
|
+
return void 0;
|
|
3845
|
+
}
|
|
3846
|
+
render(width, theme) {
|
|
3847
|
+
if (!this.hasInlineSurface() || this.state.widgetsSuspended || this.inspectorOpen || this.state.fleetInspectorOpen) {
|
|
3848
|
+
this.clearWorkflowCoverage();
|
|
3849
|
+
return [];
|
|
3850
|
+
}
|
|
3851
|
+
if (!this.active) {
|
|
3852
|
+
this.clearWorkflowCoverage();
|
|
3853
|
+
const workEntries2 = this.entries.filter((entry) => !entry.surface);
|
|
3854
|
+
const projectEntries = this.entries.filter((entry) => entry.surface === "project-pane");
|
|
3855
|
+
const hasWorkflow = workEntries2.some((entry) => entry.workflowWrapper);
|
|
3856
|
+
const nativeEntries = workEntries2.filter((entry) => !entry.external && !entry.workflowWrapper && !entry.parentKey);
|
|
3857
|
+
const tokens = nativeEntries.reduce((total, entry) => total + entry.tokens, 0);
|
|
3858
|
+
const window = nativeEntries.length > 0 && nativeEntries.every((entry) => entry.window !== void 0) ? nativeEntries.reduce((total, entry) => total + entry.window, 0) : void 0;
|
|
3859
|
+
const capacity = this.state.activeAsyncCapacity;
|
|
3860
|
+
const hasNativeRows = nativeEntries.length > 0 || hasWorkflow;
|
|
3861
|
+
const showNativeSummary = hasNativeRows || Boolean(capacity?.used);
|
|
3862
|
+
const asyncRuns = capacity && showNativeSummary && (capacity.used > 0 || capacity.limit > 0) ? `Async runs ${capacity.used}/${capacity.limit || "\u221E"}` : "";
|
|
3863
|
+
const activeEntries = activeLeafAgentCount(workEntries2);
|
|
3864
|
+
const noun = workEntries2.some((entry) => entry.external) ? "job" : "agent";
|
|
3865
|
+
const agents = activeEntries > 0 ? `${activeEntries} active ${noun}${activeEntries === 1 ? "" : "s"}` : "";
|
|
3866
|
+
const paneAttention = projectEntries.filter((entry) => entry.projectPane && projectPaneNeedsAttention(entry.projectPane)).length;
|
|
3867
|
+
const panes = projectEntries.length > 0 ? `${projectEntries.length} pane${projectEntries.length === 1 ? "" : "s"}${paneAttention ? ` (${paneAttention} \u26A0)` : ""}` : "";
|
|
3868
|
+
const label = [agents, asyncRuns, panes].filter(Boolean).join(" \xB7 ");
|
|
3869
|
+
const nativeUsage = formatFleetTokens(tokens, window, nativeEntries.length);
|
|
3870
|
+
const usage = hasWorkflow ? nativeEntries.length > 0 ? `standalone: ${nativeUsage} \xB7 workflow usage on child rows` : "usage on child rows" : nativeUsage;
|
|
3871
|
+
const detail = [showNativeSummary ? usage : void 0, "\u2193/\u2190 to inspect"].filter(Boolean).join(" \xB7 ");
|
|
3872
|
+
return [truncateToWidth2(` ${theme.fg("muted", label)}${label && detail ? " \xB7 " : ""}${theme.fg("dim", detail)}`, width)];
|
|
3873
|
+
}
|
|
3874
|
+
const roster = this.rosterKeys();
|
|
3875
|
+
const selectedIndex = Math.max(0, roster.indexOf(this.selectedKey));
|
|
3876
|
+
const rosterIndexByKey = /* @__PURE__ */ new Map();
|
|
3877
|
+
for (const [index, entry] of this.entries.entries()) {
|
|
3878
|
+
if (!rosterIndexByKey.has(entry.key)) rosterIndexByKey.set(entry.key, index + 1);
|
|
3879
|
+
}
|
|
3880
|
+
const lines = [truncateToWidth2(` ${theme.fg("dim", "\u2191\u2193/jk select \xB7 enter inspect \xB7 esc back")}`, width), ""];
|
|
3881
|
+
lines.push(truncateToWidth2(` ${this.bullet(0, selectedIndex, theme)} main`, width));
|
|
3882
|
+
const workEntries = this.entries.filter((entry) => !entry.surface);
|
|
3883
|
+
const tree = fleetTreeRows(workEntries);
|
|
3884
|
+
const selectedTreeIndex = Math.max(0, tree.findIndex((row) => (row.kind === "owner" || row.kind === "child") && row.entry.key === this.selectedKey));
|
|
3885
|
+
const visibleCount = Math.min(this.maxAgentRows, tree.length);
|
|
3886
|
+
const start = selectedTreeIndex < visibleCount ? 0 : selectedTreeIndex - visibleCount + 1;
|
|
3887
|
+
const hiddenBelow = tree.length - (start + visibleCount);
|
|
3888
|
+
if (start > 0) lines.push(rightAlign("", theme.fg("dim", `\u2191 ${start} more`), width));
|
|
3889
|
+
for (let index = start; index < start + visibleCount; index++) {
|
|
3890
|
+
const row = tree[index];
|
|
3891
|
+
if (row.kind === "owner" || row.kind === "child") {
|
|
3892
|
+
const rosterIndex = rosterIndexByKey.get(row.entry.key) ?? 0;
|
|
3893
|
+
lines.push(this.renderEntry(rosterIndex, selectedIndex, row.entry, width, theme, row.kind === "child" ? row.last ? "\u2514\u2500" : "\u251C\u2500" : void 0));
|
|
3894
|
+
} else if (row.kind === "workflow") {
|
|
3895
|
+
lines.push(this.renderWorkflowRow(row.row, row.last, width, theme));
|
|
3896
|
+
} else if (row.kind === "workflow-phase") {
|
|
3897
|
+
lines.push(this.renderWorkflowPhaseRow(row.phase, row.last, width, theme));
|
|
3898
|
+
} else {
|
|
3899
|
+
lines.push(this.renderNestedRow(row.row, row.last, width, theme));
|
|
3900
|
+
}
|
|
3901
|
+
}
|
|
3902
|
+
if (hiddenBelow > 0) lines.push(rightAlign("", theme.fg("dim", `\u2193 ${hiddenBelow} more`), width));
|
|
3903
|
+
if (this.ui && this.widgetRegistered && this.onWorkflowCoverageChange) {
|
|
3904
|
+
const coverage = /* @__PURE__ */ new Map();
|
|
3905
|
+
for (const [key, { snapshot, childRows }] of this.workflowSnapshots) {
|
|
3906
|
+
const ownerIndex = tree.findIndex((row) => row.kind === "owner" && row.entry.key === key);
|
|
3907
|
+
const owner = tree[ownerIndex];
|
|
3908
|
+
if (owner?.kind !== "owner" || ownerIndex < start) continue;
|
|
3909
|
+
const count = childRows.size + (owner.entry.workflowRows?.length ?? 0) + (owner.entry.workflowChecklist?.phases.length ?? 0);
|
|
3910
|
+
if (!count || ownerIndex + count >= start + visibleCount) continue;
|
|
3911
|
+
const descendants = tree.slice(ownerIndex + 1, ownerIndex + count + 1);
|
|
3912
|
+
if (!descendants.every((row) => row.kind === "workflow" && row.ownerKey === key && !row.row.overflow && visibleWidth3(this.renderWorkflowRow(row.row, row.last, Infinity, theme)) <= width || row.kind === "workflow-phase" && row.ownerKey === key && visibleWidth3(this.renderWorkflowPhaseRow(row.phase, row.last, Infinity, theme)) <= width || row.kind === "child" && childRows.has(row.entry.key) && visibleWidth3(this.renderEntry(rosterIndexByKey.get(row.entry.key) ?? 0, selectedIndex, row.entry, 0, theme, row.last ? "\u2514\u2500" : "\u251C\u2500", true)) <= width)) continue;
|
|
3913
|
+
if (childRows.size && visibleWidth3(this.renderEntry(rosterIndexByKey.get(key) ?? 0, selectedIndex, owner.entry, 0, theme, void 0, true)) > width) continue;
|
|
3914
|
+
coverage.set(key.slice("async:".length), snapshot);
|
|
3915
|
+
}
|
|
3916
|
+
this.onWorkflowCoverageChange(this.ui, coverage);
|
|
3917
|
+
}
|
|
3918
|
+
this.renderProjectPaneSection(lines, selectedIndex, width, theme, rosterIndexByKey);
|
|
3919
|
+
return lines;
|
|
3920
|
+
}
|
|
3921
|
+
renderProjectPaneSection(lines, selectedIndex, width, theme, rosterIndexByKey) {
|
|
3922
|
+
const entries = this.entries.filter((entry) => entry.surface === "project-pane");
|
|
3923
|
+
if (!entries.length) return;
|
|
3924
|
+
lines.push("", truncateToWidth2(` ${theme.fg("dim", "project panes")}`, width));
|
|
3925
|
+
for (const entry of entries) {
|
|
3926
|
+
const rosterIndex = rosterIndexByKey.get(entry.key) ?? 0;
|
|
3927
|
+
lines.push(this.renderEntry(rosterIndex, selectedIndex, entry, width, theme));
|
|
3928
|
+
}
|
|
3929
|
+
}
|
|
3930
|
+
renderEntry(rosterIndex, selectedIndex, entry, width, theme, branch, unclipped = false) {
|
|
3931
|
+
const label = entry.displayLabel ?? entry.agent;
|
|
3932
|
+
const agent = entry.modelThinking ? `${label} (${entry.modelThinking})` : label;
|
|
3933
|
+
const prefix = branch ? ` ${branch}` : " ";
|
|
3934
|
+
const checklist = entry.workflowWrapper && entry.workflowChecklist ? ` \xB7 checklist ${formatWorkflowChecklistSummary(entry.workflowChecklist)}${entry.workflowChecklist.bottleneck ? ` \xB7 bottleneck ${formatWorkflowChecklistBottleneck(entry.workflowChecklist.bottleneck)}` : ""}` : "";
|
|
3935
|
+
const left = `${prefix} ${this.bullet(rosterIndex, selectedIndex, theme)} ${theme.fg(fleetAgentIdentityColor(entry.agent), agent)} \xB7 ${entry.state}${checklist}`;
|
|
3936
|
+
const elapsed = Date.now() - entry.startedAt;
|
|
3937
|
+
const rightText = entry.projectPane ? `${entry.projectPane.summary ?? "\u2014"} \xB7 ${formatFleetElapsed(Date.now() - entry.projectPane.refreshedAt)} ago` : entry.external ? formatFleetElapsed(elapsed) : `${formatFleetElapsed(elapsed)} \xB7 ${entry.workflowWrapper ? "usage on child rows" : formatFleetTokens(entry.tokens, entry.window)}`;
|
|
3938
|
+
const right = theme.fg("dim", rightText);
|
|
3939
|
+
if (unclipped) return `${left} ${right}`;
|
|
3940
|
+
return rightAlign(left, right, width);
|
|
3941
|
+
}
|
|
3942
|
+
renderNestedRow(row, last, width, theme) {
|
|
3943
|
+
const marker = last ? "\u2514\u2500" : "\u251C\u2500";
|
|
3944
|
+
const indent = " ".repeat(row.depth + 1);
|
|
3945
|
+
if (row.overflow !== void 0) return truncateToWidth2(`${indent}${marker} ${theme.fg("dim", `+${row.overflow} nested leaves`)}`, width);
|
|
3946
|
+
const modelThinking = row.modelThinking ? ` (${row.modelThinking})` : "";
|
|
3947
|
+
const activity = row.activity ? ` \xB7 ${row.activity}` : "";
|
|
3948
|
+
const left = `${indent}${marker} ${nestedStatusGlyph2(row.state, theme, row.thinking)} ${theme.fg(fleetAgentIdentityColor(row.agentIdentity ?? row.name), `${row.name}${modelThinking}`)} \xB7 ${row.state}${activity}`;
|
|
3949
|
+
const elapsed = detailElapsed(row);
|
|
3950
|
+
return truncateToWidth2(`${left}${elapsed !== void 0 ? theme.fg("dim", ` \xB7 ${elapsed}`) : ""}`, width);
|
|
3951
|
+
}
|
|
3952
|
+
workflowRowGlyph(row, theme) {
|
|
3953
|
+
if (!row.kind) return nestedStatusGlyph2(row.state, theme, row.thinking);
|
|
3954
|
+
const state = row.state;
|
|
3955
|
+
if (state === "pending") return theme.fg("muted", "\u25E6");
|
|
3956
|
+
if (state === "running") return theme.fg("accent", "\u25CF");
|
|
3957
|
+
if (state === "done") return row.verdict === "pass" ? theme.fg("success", "\u2713") : row.verdict === "fail" ? theme.fg("error", "\u2717") : theme.fg("warning", "\u25A0");
|
|
3958
|
+
if (state === "error") return theme.fg("error", "\u2717");
|
|
3959
|
+
return theme.fg("warning", "\u25A0");
|
|
3960
|
+
}
|
|
3961
|
+
workflowRowStateLabel(row, theme) {
|
|
3962
|
+
const state = row.kind ? hostStepVerdictLabel(row.state, row.verdict) : row.state;
|
|
3963
|
+
if (state === "running") return row.kind ? theme.fg("accent", state) : runningTone(theme, row.thinking)(state);
|
|
3964
|
+
if (state === "pending" || state === "queued") return theme.fg("muted", state);
|
|
3965
|
+
if (state === "pass" || state === "complete" || state === "completed") return theme.fg("success", state === "pass" ? "pass" : "complete");
|
|
3966
|
+
if (state === "fail" || state === "failed" || state === "error") return theme.fg("error", state === "fail" ? "fail" : state);
|
|
3967
|
+
return theme.fg("warning", state);
|
|
3968
|
+
}
|
|
3969
|
+
renderWorkflowPhaseRow(phase, last, width, theme) {
|
|
3970
|
+
const marker = last ? "\u2514\u2500" : "\u251C\u2500";
|
|
3971
|
+
const glyph = phase.state === "complete" ? theme.fg("success", "\u2713") : phase.state === "running" ? runningTone(theme)("\u25CF") : phase.state === "blocked" || phase.state === "failed" ? theme.fg("error", phase.state === "blocked" ? "!" : "\u2717") : phase.state === "queued" ? theme.fg("muted", "\u25E6") : theme.fg("warning", "\u25A0");
|
|
3972
|
+
return truncateToWidth2(` ${marker} ${glyph} ${theme.fg("muted", formatWorkflowChecklistPhase(phase))}`, width);
|
|
3973
|
+
}
|
|
3974
|
+
renderWorkflowRow(row, last, width, theme) {
|
|
3975
|
+
const marker = last ? "\u2514\u2500" : "\u251C\u2500";
|
|
3976
|
+
const indent = " ";
|
|
3977
|
+
if (row.overflow !== void 0) return truncateToWidth2(`${indent}${marker} ${theme.fg("dim", `+${row.overflow} hidden workflow steps`)}`, width);
|
|
3978
|
+
const context = contextModeLabel(row.context);
|
|
3979
|
+
const modelThinking = row.modelThinking ? ` (${row.modelThinking})` : "";
|
|
3980
|
+
const activity = row.activity ? ` \xB7 ${row.activity}` : "";
|
|
3981
|
+
const kind = row.kind ? `${row.kind}: ` : "";
|
|
3982
|
+
const hints = row.preflight ? [
|
|
3983
|
+
row.preflight.mode ? `mode:${row.preflight.mode}` : void 0,
|
|
3984
|
+
row.preflight.decision ? `decision:${row.preflight.decision}` : void 0,
|
|
3985
|
+
row.preflight.claims?.length ? `claims:${row.preflight.claims.join(",")}` : void 0,
|
|
3986
|
+
row.preflight.expectedOutput ? `expected:${row.preflight.expectedOutput}` : void 0,
|
|
3987
|
+
row.preflight.independence ? `independence:${row.preflight.independence}` : void 0
|
|
3988
|
+
].filter((value) => Boolean(value)).join(" \xB7 ") : "";
|
|
3989
|
+
const left = `${indent}${marker} ${this.workflowRowGlyph(row, theme)} ${theme.fg("muted", `${kind}${row.name}${context ? ` ${context}` : ""}${modelThinking}`)} \xB7 ${this.workflowRowStateLabel(row, theme)}${activity}${hints ? ` \xB7 ${hints}` : ""}`;
|
|
3990
|
+
const details = [
|
|
3991
|
+
detailElapsed(row),
|
|
3992
|
+
row.tokens !== void 0 ? formatFleetTokens(row.tokens, row.window) : void 0,
|
|
3993
|
+
row.provider ? `provider:${row.provider}` : void 0,
|
|
3994
|
+
row.role ? `role:${row.role}` : void 0,
|
|
3995
|
+
row.target,
|
|
3996
|
+
row.detail,
|
|
3997
|
+
row.reasonCode ? `reason:${row.reasonCode}` : void 0,
|
|
3998
|
+
row.freshness?.stale ? "stale" : row.freshness?.observedRef ? `ref:${row.freshness.observedRef}` : void 0,
|
|
3999
|
+
row.reportPath ? `out:${hostStepReportName(row.reportPath)}` : void 0
|
|
4000
|
+
].filter(Boolean).join(" \xB7 ");
|
|
4001
|
+
return truncateToWidth2(`${left}${details ? theme.fg("dim", ` \xB7 ${details}`) : ""}`, width);
|
|
4002
|
+
}
|
|
4003
|
+
bullet(rosterIndex, selectedIndex, theme) {
|
|
4004
|
+
return rosterIndex === selectedIndex ? theme.fg("accent", ">") : " ";
|
|
4005
|
+
}
|
|
4006
|
+
rosterKeys() {
|
|
4007
|
+
return ["main", ...this.entries.map((entry) => entry.key)];
|
|
4008
|
+
}
|
|
4009
|
+
clampSelection() {
|
|
4010
|
+
if (!this.rosterKeys().includes(this.selectedKey)) this.selectedKey = "main";
|
|
4011
|
+
}
|
|
4012
|
+
deactivate() {
|
|
4013
|
+
this.active = false;
|
|
4014
|
+
this.selectedKey = "main";
|
|
4015
|
+
this.refresh();
|
|
4016
|
+
}
|
|
4017
|
+
editorHasFocus() {
|
|
4018
|
+
const focused = this.tui?.focusedComponent;
|
|
4019
|
+
if (!focused || typeof focused !== "object") return false;
|
|
4020
|
+
const candidate = focused;
|
|
4021
|
+
return typeof candidate.render === "function" && typeof candidate.invalidate === "function" && typeof candidate.handleInput === "function" && typeof candidate.getText === "function" && typeof candidate.setText === "function";
|
|
4022
|
+
}
|
|
4023
|
+
getRenderKey() {
|
|
4024
|
+
const now = Date.now();
|
|
4025
|
+
return JSON.stringify({
|
|
4026
|
+
active: this.active,
|
|
4027
|
+
selected: this.selectedKey,
|
|
4028
|
+
inspectorOpen: this.inspectorOpen,
|
|
4029
|
+
entries: this.entries.map((entry) => this.active ? [
|
|
4030
|
+
entry.key,
|
|
4031
|
+
entry.surface,
|
|
4032
|
+
entry.parentKey,
|
|
4033
|
+
entry.agent,
|
|
4034
|
+
entry.displayLabel,
|
|
4035
|
+
entry.state,
|
|
4036
|
+
entry.modelThinking,
|
|
4037
|
+
entry.description,
|
|
4038
|
+
entry.external,
|
|
4039
|
+
Math.round((now - entry.startedAt) / 1e3),
|
|
4040
|
+
entry.tokens,
|
|
4041
|
+
entry.workflowChecklist ? [
|
|
4042
|
+
entry.workflowChecklist.total,
|
|
4043
|
+
entry.workflowChecklist.done,
|
|
4044
|
+
entry.workflowChecklist.running,
|
|
4045
|
+
entry.workflowChecklist.queued,
|
|
4046
|
+
entry.workflowChecklist.blocked,
|
|
4047
|
+
entry.workflowChecklist.failed,
|
|
4048
|
+
entry.workflowChecklist.phases.map((phase) => [phase.key, phase.state, phase.done, phase.total, phase.running, phase.queued, phase.blocked, phase.failed, phase.items.map((item) => [item.key, item.state, item.currentTool, item.currentPath, item.durationMs, item.toolCount, item.error])])
|
|
4049
|
+
] : void 0,
|
|
4050
|
+
visibleWorkflowRows2(entry.workflowRows, entry.parentKey ? 2 : 4).map((row) => [
|
|
4051
|
+
row.kind,
|
|
4052
|
+
row.name,
|
|
4053
|
+
row.state,
|
|
4054
|
+
row.context,
|
|
4055
|
+
row.modelThinking,
|
|
4056
|
+
row.activity,
|
|
4057
|
+
row.startedAt,
|
|
4058
|
+
row.endedAt,
|
|
4059
|
+
row.durationMs,
|
|
4060
|
+
row.tokens,
|
|
4061
|
+
row.provider,
|
|
4062
|
+
row.role,
|
|
4063
|
+
row.verdict,
|
|
4064
|
+
row.reasonCode,
|
|
4065
|
+
row.detail,
|
|
4066
|
+
row.target,
|
|
4067
|
+
row.freshness,
|
|
4068
|
+
row.reportPath,
|
|
4069
|
+
row.overflow
|
|
4070
|
+
]),
|
|
4071
|
+
nestedFleetRows(entry.nestedChildren, entry.parentKey ? 3 : 4).map((row) => [
|
|
4072
|
+
row.name,
|
|
4073
|
+
row.agentIdentity,
|
|
4074
|
+
row.state,
|
|
4075
|
+
row.modelThinking,
|
|
4076
|
+
row.activity,
|
|
4077
|
+
row.startedAt,
|
|
4078
|
+
row.endedAt,
|
|
4079
|
+
row.depth,
|
|
4080
|
+
row.overflow
|
|
4081
|
+
])
|
|
4082
|
+
] : [entry.key, entry.state, entry.external, entry.surface, entry.tokens, entry.projectPane?.refreshedAt, entry.projectPane?.summary])
|
|
4083
|
+
});
|
|
4084
|
+
}
|
|
4085
|
+
hasInlineSurface() {
|
|
4086
|
+
return this.entries.length > 0 || Boolean(this.state.activeAsyncCapacity?.used);
|
|
4087
|
+
}
|
|
4088
|
+
getActiveUiContext() {
|
|
4089
|
+
const ctx = this.ctx;
|
|
4090
|
+
if (!ctx) return void 0;
|
|
4091
|
+
try {
|
|
4092
|
+
return ctx.hasUI ? ctx : void 0;
|
|
4093
|
+
} catch (error) {
|
|
4094
|
+
if (!isStaleExtensionContextError(error)) throw error;
|
|
4095
|
+
this.clearUiRegistration();
|
|
4096
|
+
return void 0;
|
|
4097
|
+
}
|
|
4098
|
+
}
|
|
4099
|
+
clearWidget() {
|
|
4100
|
+
this.prepaint = void 0;
|
|
4101
|
+
this.clearWorkflowCoverage();
|
|
4102
|
+
if (!this.widgetRegistered) return;
|
|
4103
|
+
try {
|
|
4104
|
+
this.ui?.setWidget(FLEET_STATUS_WIDGET_KEY, void 0);
|
|
4105
|
+
} catch (error) {
|
|
4106
|
+
if (!isStaleExtensionContextError(error)) throw error;
|
|
4107
|
+
this.clearUiRegistration();
|
|
4108
|
+
return;
|
|
4109
|
+
}
|
|
4110
|
+
this.widgetRegistered = false;
|
|
4111
|
+
this.tui = void 0;
|
|
4112
|
+
}
|
|
4113
|
+
clearUiRegistration() {
|
|
4114
|
+
this.prepaint = void 0;
|
|
4115
|
+
this.clearWorkflowCoverage();
|
|
4116
|
+
if (this.timer) clearInterval(this.timer);
|
|
4117
|
+
this.timer = void 0;
|
|
4118
|
+
const inputUnsubscribe = this.inputUnsubscribe;
|
|
4119
|
+
const ui = this.ui;
|
|
4120
|
+
const widgetRegistered = this.widgetRegistered;
|
|
4121
|
+
this.inputUnsubscribe = void 0;
|
|
4122
|
+
this.ctx = void 0;
|
|
4123
|
+
this.ui = void 0;
|
|
4124
|
+
this.widgetRegistered = false;
|
|
4125
|
+
this.tui = void 0;
|
|
4126
|
+
const cleanupErrors = [];
|
|
4127
|
+
try {
|
|
4128
|
+
inputUnsubscribe?.();
|
|
4129
|
+
} catch (error) {
|
|
4130
|
+
if (!isStaleExtensionContextError(error)) cleanupErrors.push(error);
|
|
4131
|
+
}
|
|
4132
|
+
if (ui && widgetRegistered) {
|
|
4133
|
+
try {
|
|
4134
|
+
ui.setWidget(FLEET_STATUS_WIDGET_KEY, void 0);
|
|
4135
|
+
} catch (error) {
|
|
4136
|
+
if (!isStaleExtensionContextError(error)) cleanupErrors.push(error);
|
|
4137
|
+
}
|
|
4138
|
+
}
|
|
4139
|
+
if (cleanupErrors.length === 1) throw cleanupErrors[0];
|
|
4140
|
+
if (cleanupErrors.length > 1) {
|
|
4141
|
+
throw new AggregateError(cleanupErrors, "Failed to clean up FleetView UI registration");
|
|
4142
|
+
}
|
|
4143
|
+
}
|
|
4144
|
+
clearWorkflowCoverage() {
|
|
4145
|
+
if (this.ui) this.onWorkflowCoverageChange?.(this.ui, /* @__PURE__ */ new Map());
|
|
4146
|
+
}
|
|
4147
|
+
};
|
|
4148
|
+
|
|
4149
|
+
export {
|
|
4150
|
+
setMainThinkingLevelSource,
|
|
4151
|
+
readMainThinkingLevel,
|
|
4152
|
+
runningTone,
|
|
4153
|
+
buildAsyncStatusSnapshotForState,
|
|
4154
|
+
clearLegacyResultAnimationTimer,
|
|
4155
|
+
widgetRenderKey,
|
|
4156
|
+
setInlineWorkflowCoverage,
|
|
4157
|
+
renderWidget,
|
|
4158
|
+
renderSubagentSummary,
|
|
4159
|
+
renderSubagentResult,
|
|
4160
|
+
FLEET_STATUS_WIDGET_KEY,
|
|
4161
|
+
resolveFleetViewPlacement,
|
|
4162
|
+
reportFleetWarning,
|
|
4163
|
+
SubagentFleetStatus
|
|
4164
|
+
};
|