@selesai/code 0.8.11 → 0.9.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 +21 -0
- package/dist/core/agent-session.js +41 -29
- package/dist/core/resource-loader.d.ts +1 -1
- package/dist/core/resource-loader.js +2 -2
- package/dist/defaults/models.json +30 -7
- package/dist/defaults/settings.json +10 -8
- package/dist/extensions/model-prompt-injector/config.json +6 -0
- package/dist/extensions/package.json +2 -1
- package/dist/extensions/pi-subagents/README.md +4 -4
- package/dist/extensions/pi-subagents/docs/configuration.md +3 -54
- package/dist/extensions/pi-subagents/docs/extension-api.md +4 -15
- package/dist/extensions/pi-subagents/docs/missions.md +2 -39
- package/dist/extensions/pi-subagents/docs/observability.md +2 -42
- package/dist/extensions/pi-subagents/docs/tool-reference.md +1 -2
- package/dist/extensions/pi-subagents/docs/watchdog.md +0 -57
- package/dist/extensions/pi-subagents/docs/workflows.md +2 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md +4 -49
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/management-authoring-rpc.md +1 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/prompting-and-roles.md +1 -2
- package/dist/extensions/pi-subagents/src/extension/config.ts +3 -15
- package/dist/extensions/pi-subagents/src/extension/index.ts +1 -53
- package/dist/extensions/pi-subagents/src/extension/public-execution.ts +4 -10
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +1 -2
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +1 -12
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +1 -2
- package/dist/extensions/pi-subagents/src/policy/authority.ts +0 -2
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +33 -102
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +0 -2
- package/dist/extensions/pi-subagents/src/shared/types.ts +1 -1
- package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +4 -58
- package/dist/extensions/pi-subagents/src/watchdog/register-main.ts +2 -8
- package/dist/extensions/pi-subagents/src/watchdog/tool-actions.ts +1 -2
- package/dist/extensions/pi-subagents/src/workflows/workflow-auto-relaunch.ts +16 -3
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +0 -95
- package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +0 -15
- package/dist/extensions/pi-subagents/test/integration/result-watcher.test.ts +0 -59
- package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +0 -59
- package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +0 -47
- package/dist/extensions/pi-subagents/test/unit/authority-policy.test.ts +0 -1
- package/dist/extensions/pi-subagents/test/unit/compaction-resume.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +5 -5
- package/dist/extensions/pi-subagents/test/unit/public-execution.test.ts +0 -8
- package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/subagent-action-recovery.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +4 -4
- package/dist/extensions/pi-subagents/test/unit/workflow-auto-relaunch.test.ts +21 -1
- package/dist/modes/interactive/components/model-selector.d.ts +10 -1
- package/dist/modes/interactive/components/model-selector.js +10 -6
- package/dist/modes/interactive/components/settings-selector.d.ts +2 -0
- package/dist/modes/interactive/components/settings-selector.js +3 -0
- package/dist/modes/interactive/interactive-mode.js +7 -0
- package/dist/skills/pi-subagents/references/constraints-and-recipes.md +1 -1
- package/dist/skills/pi-subagents/references/execution-controls.md +2 -32
- package/dist/skills/pi-subagents/references/management-authoring-rpc.md +1 -1
- package/dist/skills/pi-subagents/references/prompting-and-roles.md +3 -3
- package/docs/custom-provider.md +1 -0
- package/package.json +3 -3
- package/dist/extensions/pi-subagents/src/runs/background/scheduled-runs.ts +0 -803
- package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +0 -691
- package/dist/extensions/pi-subagents/src/tui/fleet.ts +0 -1314
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/cli.d.ts +0 -3
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/register-bedrock.d.ts +0 -2
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/restore-sandbox-env.d.ts +0 -17
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/args.d.ts +0 -57
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/config-selector.d.ts +0 -16
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/file-processor.d.ts +0 -15
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/initial-message.d.ts +0 -18
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/list-models.d.ts +0 -9
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/project-trust.d.ts +0 -10
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/session-picker.d.ts +0 -10
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/startup-ui.d.ts +0 -20
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli.d.ts +0 -3
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/config.d.ts +0 -96
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session-runtime.d.ts +0 -119
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session-services.d.ts +0 -85
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session.d.ts +0 -620
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/auth-guidance.d.ts +0 -5
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/auth-storage.d.ts +0 -56
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/bash-executor.d.ts +0 -32
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/cache-stats.d.ts +0 -49
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/branch-summarization.d.ts +0 -93
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/compaction.d.ts +0 -128
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/index.d.ts +0 -7
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/utils.d.ts +0 -38
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/defaults.d.ts +0 -3
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/diagnostics.d.ts +0 -15
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/event-bus.d.ts +0 -9
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/exec.d.ts +0 -29
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/experimental.d.ts +0 -2
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/ansi-to-html.d.ts +0 -22
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/index.d.ts +0 -37
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/tool-renderer.d.ts +0 -34
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/index.d.ts +0 -12
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/loader.d.ts +0 -23
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/runner.d.ts +0 -171
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/types.d.ts +0 -1263
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/wrapper.d.ts +0 -20
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/footer-data-provider.d.ts +0 -54
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/http-dispatcher.d.ts +0 -22
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/index.d.ts +0 -13
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/keybindings.d.ts +0 -358
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/messages.d.ts +0 -77
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-config.d.ts +0 -512
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-registry.d.ts +0 -43
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-resolver.d.ts +0 -121
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-runtime.d.ts +0 -82
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/models-store.d.ts +0 -17
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/output-guard.d.ts +0 -7
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/package-manager.d.ts +0 -210
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/project-trust.d.ts +0 -15
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/prompt-templates.d.ts +0 -54
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/provider-attribution.d.ts +0 -4
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/provider-composer.d.ts +0 -55
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/radius.d.ts +0 -2
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/remote-catalog-provider.d.ts +0 -5
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/resolve-config-value.d.ts +0 -30
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/resource-loader.d.ts +0 -206
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/runtime-credentials.d.ts +0 -15
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/sdk.d.ts +0 -106
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/session-cwd.d.ts +0 -19
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/session-manager.d.ts +0 -356
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/settings-manager.d.ts +0 -297
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/skills.d.ts +0 -60
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/slash-commands.d.ts +0 -15
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/source-info.d.ts +0 -18
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/system-prompt.d.ts +0 -28
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/telemetry.d.ts +0 -3
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/timings.d.ts +0 -10
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/bash.d.ts +0 -68
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/edit-diff.d.ts +0 -106
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/edit.d.ts +0 -51
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/file-mutation-queue.d.ts +0 -6
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/find.d.ts +0 -35
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/grep.d.ts +0 -37
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/index.d.ts +0 -40
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/ls.d.ts +0 -37
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/output-accumulator.d.ts +0 -52
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/path-utils.d.ts +0 -10
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/read.d.ts +0 -35
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/render-utils.d.ts +0 -24
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/tool-definition-wrapper.d.ts +0 -14
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/truncate.d.ts +0 -70
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/write.d.ts +0 -26
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/trust-manager.d.ts +0 -36
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/usage-totals.d.ts +0 -19
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/index.d.ts +0 -3
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/client.d.ts +0 -61
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/huggingface.d.ts +0 -23
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/index.d.ts +0 -3
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/provider.d.ts +0 -10
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/ui.d.ts +0 -42
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/index.d.ts +0 -35
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/main.d.ts +0 -12
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/migrations.d.ts +0 -33
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/index.d.ts +0 -9
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/armin.d.ts +0 -34
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/assistant-message.d.ts +0 -22
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/bash-execution.d.ts +0 -34
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/bordered-loader.d.ts +0 -16
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/branch-summary-message.d.ts +0 -16
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/compaction-summary-message.d.ts +0 -16
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/config-selector.d.ts +0 -102
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/countdown-timer.d.ts +0 -14
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-editor.d.ts +0 -21
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-entry.d.ts +0 -19
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-message.d.ts +0 -20
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/daxnuts.d.ts +0 -23
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/diff.d.ts +0 -12
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/dynamic-border.d.ts +0 -15
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/earendil-announcement.d.ts +0 -5
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-editor.d.ts +0 -22
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-input.d.ts +0 -23
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-selector.d.ts +0 -26
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/first-time-setup.d.ts +0 -25
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/footer.d.ts +0 -32
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/index.d.ts +0 -34
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/keybinding-hints.d.ts +0 -13
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/login-dialog.d.ts +0 -52
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/model-selector.d.ts +0 -54
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/oauth-selector.d.ts +0 -33
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/scoped-models-selector.d.ts +0 -42
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/session-selector-search.d.ts +0 -23
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/session-selector.d.ts +0 -95
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/settings-selector.d.ts +0 -77
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/show-images-selector.d.ts +0 -10
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/skill-invocation-message.d.ts +0 -17
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/status-indicator.d.ts +0 -28
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/theme-selector.d.ts +0 -11
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/thinking-selector.d.ts +0 -11
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/tool-execution.d.ts +0 -63
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/tree-selector.d.ts +0 -94
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/trust-selector.d.ts +0 -23
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/user-message-selector.d.ts +0 -30
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/user-message.d.ts +0 -14
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/visual-truncate.d.ts +0 -24
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/interactive-mode.d.ts +0 -394
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/model-search.d.ts +0 -12
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/theme/theme-controller.d.ts +0 -29
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/theme/theme.d.ts +0 -120
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/print-mode.d.ts +0 -28
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/jsonl.d.ts +0 -17
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-client.d.ts +0 -246
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-mode.d.ts +0 -20
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-types.d.ts +0 -457
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/package-manager-cli.d.ts +0 -8
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/rpc-entry.d.ts +0 -3
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/ansi.d.ts +0 -2
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/changelog.d.ts +0 -22
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/child-process.d.ts +0 -18
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard-image.d.ts +0 -11
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard-native.d.ts +0 -11
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard.d.ts +0 -4
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/deprecation.d.ts +0 -4
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/exif-orientation.d.ts +0 -5
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/frontmatter.d.ts +0 -8
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/fs-watch.d.ts +0 -5
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/git.d.ts +0 -26
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/html.d.ts +0 -7
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-convert.d.ts +0 -10
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-process.d.ts +0 -18
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize-core.d.ts +0 -30
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize-worker.d.ts +0 -2
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize.d.ts +0 -16
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/json.d.ts +0 -3
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/mime.d.ts +0 -3
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/open-browser.d.ts +0 -9
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/paths.d.ts +0 -31
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/photon.d.ts +0 -21
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/pi-user-agent.d.ts +0 -2
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/shell.d.ts +0 -31
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/sleep.d.ts +0 -5
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/syntax-highlight.d.ts +0 -12
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/tools-manager.d.ts +0 -3
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/version-check.d.ts +0 -15
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/windows-self-update.d.ts +0 -3
- package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +0 -1004
- package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +0 -1511
- package/dist/extensions/pi-subagents/test/unit/scheduled-runs.test.ts +0 -634
- package/dist/extensions/pi-subagents/test/unit/scheduled-store-root.test.ts +0 -67
|
@@ -1,691 +0,0 @@
|
|
|
1
|
-
import type { ExtensionContext } from "@selesai/code";
|
|
2
|
-
import { type EditorComponent, isKeyRelease, Key, matchesKey, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
3
|
-
import { snapshotExternalRuns } from "../api/external-runs.ts";
|
|
4
|
-
import { formatModelThinking } from "../shared/formatters.ts";
|
|
5
|
-
import type { AsyncJobStep, FleetViewPlacement, NestedRunSummary, NestedStepSummary, SubagentState } from "../shared/types.ts";
|
|
6
|
-
import { formatWorkflowJsonPreview } from "../workflows/scripted-workflow.ts";
|
|
7
|
-
|
|
8
|
-
export const FLEET_STATUS_WIDGET_KEY = "subagent-fleet-status";
|
|
9
|
-
|
|
10
|
-
// Six rows fit the accepted collapsed hierarchy: one owner, four visible descendants, and overflow.
|
|
11
|
-
const MAX_AGENT_ROWS = 6;
|
|
12
|
-
const REFRESH_MS = 500;
|
|
13
|
-
|
|
14
|
-
type Theme = ExtensionContext["ui"]["theme"];
|
|
15
|
-
type FleetStatusTui = {
|
|
16
|
-
requestRender(): void;
|
|
17
|
-
};
|
|
18
|
-
type FleetStatusEntry = {
|
|
19
|
-
key: string;
|
|
20
|
-
parentKey?: string;
|
|
21
|
-
workflowWrapper?: boolean;
|
|
22
|
-
agent: string;
|
|
23
|
-
modelThinking?: string;
|
|
24
|
-
description?: string;
|
|
25
|
-
startedAt: number;
|
|
26
|
-
tokens: number;
|
|
27
|
-
state: string;
|
|
28
|
-
external?: true;
|
|
29
|
-
nestedChildren?: NestedRunSummary[];
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
type FleetNestedRow = {
|
|
33
|
-
name: string;
|
|
34
|
-
state: NestedRunSummary["state"] | NestedStepSummary["status"];
|
|
35
|
-
modelThinking?: string;
|
|
36
|
-
activity?: string;
|
|
37
|
-
startedAt?: number;
|
|
38
|
-
depth: number;
|
|
39
|
-
overflow?: number;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
type FleetTreeRow =
|
|
43
|
-
| { kind: "owner"; entry: FleetStatusEntry }
|
|
44
|
-
| { kind: "child"; entry: FleetStatusEntry; last: boolean }
|
|
45
|
-
| { kind: "nested"; ownerKey: string; row: FleetNestedRow; last: boolean };
|
|
46
|
-
|
|
47
|
-
export interface FleetStatusOptions {
|
|
48
|
-
refreshMs?: number;
|
|
49
|
-
maxAgentRows?: number;
|
|
50
|
-
placement?: FleetViewPlacement;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function resolveFleetViewPlacement(value: unknown): FleetViewPlacement {
|
|
54
|
-
return value === "aboveEditor" ? "aboveEditor" : "belowEditor";
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function formatFleetElapsed(ms: number): string {
|
|
58
|
-
return `${Math.max(0, Math.round(ms / 1000))}s`;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function formatFleetTokens(count: number): string {
|
|
62
|
-
let compact: string;
|
|
63
|
-
if (count >= 1_000_000) compact = `${(count / 1_000_000).toFixed(1)}M`;
|
|
64
|
-
else if (count >= 1_000) compact = `${(count / 1_000).toFixed(1)}k`;
|
|
65
|
-
else compact = `${Math.max(0, Math.round(count))}`;
|
|
66
|
-
return `↓ ${compact} tokens`;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function rightAlign(left: string, right: string, width: number): string {
|
|
70
|
-
const rightWidth = visibleWidth(right);
|
|
71
|
-
const maxLeftWidth = Math.max(0, width - rightWidth - 1);
|
|
72
|
-
const leftClamped = truncateToWidth(left, maxLeftWidth);
|
|
73
|
-
const gap = Math.max(1, width - visibleWidth(leftClamped) - rightWidth);
|
|
74
|
-
return truncateToWidth(`${leftClamped}${" ".repeat(gap)}${right}`, width);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function isActiveState(value: string): boolean {
|
|
78
|
-
return value === "running" || value === "queued" || value === "pending";
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function nestedRunLabel(run: NestedRunSummary): string {
|
|
82
|
-
if (run.agent) return run.agent;
|
|
83
|
-
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}` : ""}`;
|
|
84
|
-
return run.id;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function nestedActivity(node: NestedRunSummary | NestedStepSummary): string | undefined {
|
|
88
|
-
if (node.currentTool) return `tool ${node.currentTool}`;
|
|
89
|
-
if (node.currentPath) return node.currentPath.split(/[\\/]/).at(-1);
|
|
90
|
-
if (node.activityState === "needs_attention") return "needs attention";
|
|
91
|
-
if (node.activityState === "active_long_running") return "long-running";
|
|
92
|
-
return undefined;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function nestedStatusGlyph(state: FleetNestedRow["state"], theme: Theme): string {
|
|
96
|
-
if (state === "running") return theme.fg("accent", "●");
|
|
97
|
-
if (state === "queued" || state === "pending") return theme.fg("muted", "◦");
|
|
98
|
-
if (state === "complete" || state === "completed") return theme.fg("success", "✓");
|
|
99
|
-
if (state === "failed" || state === "rejected") return theme.fg("error", "✗");
|
|
100
|
-
return theme.fg("warning", "■");
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function nestedStepDisplayCount(steps: NestedStepSummary[] | undefined, start = 0): number {
|
|
104
|
-
let count = 0;
|
|
105
|
-
for (let index = start; index < (steps?.length ?? 0); index++) {
|
|
106
|
-
count += 1 + nestedDisplayCount(steps![index]!.children);
|
|
107
|
-
}
|
|
108
|
-
return count;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function nestedDisplayCount(children: NestedRunSummary[] | undefined, start = 0): number {
|
|
112
|
-
let count = 0;
|
|
113
|
-
for (let index = start; index < (children?.length ?? 0); index++) {
|
|
114
|
-
const child = children![index]!;
|
|
115
|
-
const steps = (child.mode === "parallel" || child.mode === "chain") ? child.steps ?? [] : [];
|
|
116
|
-
count += steps.length > 0 ? nestedStepDisplayCount(steps) : 1;
|
|
117
|
-
count += nestedDisplayCount(child.children);
|
|
118
|
-
}
|
|
119
|
-
return count;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function nestedFleetRows(children: NestedRunSummary[] | undefined, visibleLimit: number): FleetNestedRow[] {
|
|
123
|
-
const rows: FleetNestedRow[] = [];
|
|
124
|
-
let omitted = 0;
|
|
125
|
-
const appendRuns = (runs: NestedRunSummary[] | undefined, depth: number): boolean => {
|
|
126
|
-
for (let runIndex = 0; runIndex < (runs?.length ?? 0); runIndex++) {
|
|
127
|
-
const child = runs![runIndex]!;
|
|
128
|
-
const steps = (child.mode === "parallel" || child.mode === "chain") ? child.steps ?? [] : [];
|
|
129
|
-
if (steps.length > 0) {
|
|
130
|
-
for (let stepIndex = 0; stepIndex < steps.length; stepIndex++) {
|
|
131
|
-
if (rows.length >= visibleLimit) {
|
|
132
|
-
omitted += nestedStepDisplayCount(steps, stepIndex);
|
|
133
|
-
omitted += nestedDisplayCount(child.children);
|
|
134
|
-
omitted += nestedDisplayCount(runs, runIndex + 1);
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
const step = steps[stepIndex]!;
|
|
138
|
-
const modelThinking = formatModelThinking(step.model, step.thinking) || undefined;
|
|
139
|
-
const activity = nestedActivity(step);
|
|
140
|
-
rows.push({
|
|
141
|
-
name: step.agent,
|
|
142
|
-
state: step.status,
|
|
143
|
-
depth,
|
|
144
|
-
...(modelThinking ? { modelThinking } : {}),
|
|
145
|
-
...(activity ? { activity } : {}),
|
|
146
|
-
...(step.startedAt !== undefined ? { startedAt: step.startedAt } : {}),
|
|
147
|
-
});
|
|
148
|
-
if (!appendRuns(step.children, depth + 1)) {
|
|
149
|
-
omitted += nestedStepDisplayCount(steps, stepIndex + 1);
|
|
150
|
-
omitted += nestedDisplayCount(child.children);
|
|
151
|
-
omitted += nestedDisplayCount(runs, runIndex + 1);
|
|
152
|
-
return false;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
} else {
|
|
156
|
-
if (rows.length >= visibleLimit) {
|
|
157
|
-
omitted += nestedDisplayCount(runs, runIndex);
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
const modelThinking = formatModelThinking(child.model, child.thinking) || undefined;
|
|
161
|
-
const activity = nestedActivity(child);
|
|
162
|
-
rows.push({
|
|
163
|
-
name: nestedRunLabel(child),
|
|
164
|
-
state: child.state,
|
|
165
|
-
depth,
|
|
166
|
-
...(modelThinking ? { modelThinking } : {}),
|
|
167
|
-
...(activity ? { activity } : {}),
|
|
168
|
-
...(child.startedAt !== undefined ? { startedAt: child.startedAt } : {}),
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
if (!appendRuns(child.children, depth + 1)) {
|
|
172
|
-
omitted += nestedDisplayCount(runs, runIndex + 1);
|
|
173
|
-
return false;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return true;
|
|
177
|
-
};
|
|
178
|
-
appendRuns(children, 0);
|
|
179
|
-
if (omitted > 0) rows.push({ name: `… +${omitted} more nested leaves`, state: "complete", depth: 0, overflow: omitted });
|
|
180
|
-
return rows;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function fleetTreeRows(entries: FleetStatusEntry[]): FleetTreeRow[] {
|
|
184
|
-
const rows: FleetTreeRow[] = [];
|
|
185
|
-
const entryKeys = new Set(entries.map((entry) => entry.key));
|
|
186
|
-
const childrenByParent = new Map<string, FleetStatusEntry[]>();
|
|
187
|
-
for (const entry of entries) {
|
|
188
|
-
if (!entry.parentKey || !entryKeys.has(entry.parentKey)) continue;
|
|
189
|
-
const children = childrenByParent.get(entry.parentKey) ?? [];
|
|
190
|
-
children.push(entry);
|
|
191
|
-
childrenByParent.set(entry.parentKey, children);
|
|
192
|
-
}
|
|
193
|
-
for (const entry of entries) {
|
|
194
|
-
if (entry.parentKey && entryKeys.has(entry.parentKey)) continue;
|
|
195
|
-
rows.push({ kind: "owner", entry });
|
|
196
|
-
const attached = childrenByParent.get(entry.key) ?? [];
|
|
197
|
-
for (const [index, child] of attached.entries()) {
|
|
198
|
-
const nested = nestedFleetRows(child.nestedChildren, 3);
|
|
199
|
-
const laterRows = index < attached.length - 1 || Boolean(entry.nestedChildren?.length);
|
|
200
|
-
rows.push({ kind: "child", entry: child, last: !laterRows && nested.length === 0 });
|
|
201
|
-
for (const [nestedIndex, row] of nested.entries()) rows.push({
|
|
202
|
-
kind: "nested",
|
|
203
|
-
ownerKey: child.key,
|
|
204
|
-
row: { ...row, depth: row.depth + 1 },
|
|
205
|
-
last: nestedIndex === nested.length - 1 && !laterRows,
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
const nested = nestedFleetRows(entry.nestedChildren, attached.length > 0 ? 3 : 4);
|
|
209
|
-
for (const [index, row] of nested.entries()) rows.push({ kind: "nested", ownerKey: entry.key, row, last: index === nested.length - 1 });
|
|
210
|
-
}
|
|
211
|
-
return rows;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
function isStaleExtensionContextError(error: unknown): boolean {
|
|
215
|
-
// Pi currently exposes stale contexts as plain Errors without a stable code or subtype.
|
|
216
|
-
return error instanceof Error
|
|
217
|
-
&& (error.message.includes("This extension ctx is stale")
|
|
218
|
-
|| error.message.includes("Extension context no longer active"));
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
function foregroundDescription(control: { parentWorkflowRunId?: string; workflowKey?: string }, description: string | undefined): string | undefined {
|
|
222
|
-
if (!control.parentWorkflowRunId) return description;
|
|
223
|
-
const workflow = `workflow child: ${control.parentWorkflowRunId}${control.workflowKey ? ` (${control.workflowKey})` : ""}`;
|
|
224
|
-
return description ? `${workflow} · ${description}` : workflow;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
function activeLeafAgentCount(entries: FleetStatusEntry[]): number {
|
|
228
|
-
return entries.filter((entry) => !entry.workflowWrapper).length;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
export function collectFleetStatusEntries(state: SubagentState): FleetStatusEntry[] {
|
|
232
|
-
const entries: FleetStatusEntry[] = [];
|
|
233
|
-
const activeWorkflowKeys = new Set([...state.asyncJobs.values()]
|
|
234
|
-
.filter((job) => job.mode === "workflow" && isActiveState(job.status))
|
|
235
|
-
.map((job) => `async:${job.asyncId}`));
|
|
236
|
-
for (const control of state.foregroundControls.values()) {
|
|
237
|
-
const parentKey = control.parentWorkflowRunId ? `async:${control.parentWorkflowRunId}` : undefined;
|
|
238
|
-
const linkedParentKey = parentKey && activeWorkflowKeys.has(parentKey) ? parentKey : undefined;
|
|
239
|
-
if (control.activeChildren) {
|
|
240
|
-
for (const child of [...control.activeChildren.values()].sort((left, right) => left.index - right.index)) {
|
|
241
|
-
const modelThinking = formatModelThinking(child.model, child.thinking) || undefined;
|
|
242
|
-
entries.push({
|
|
243
|
-
key: `foreground-active:${control.runId}:${child.index}`,
|
|
244
|
-
...(linkedParentKey ? { parentKey: linkedParentKey } : {}),
|
|
245
|
-
agent: child.agent,
|
|
246
|
-
...(modelThinking ? { modelThinking } : {}),
|
|
247
|
-
description: foregroundDescription(control, child.description),
|
|
248
|
-
startedAt: child.startedAt,
|
|
249
|
-
tokens: child.tokens ?? 0,
|
|
250
|
-
state: "running",
|
|
251
|
-
...((control.nestedChildren?.filter((nested) => nested.parentStepIndex === child.index).length ?? 0) > 0
|
|
252
|
-
? { nestedChildren: control.nestedChildren!.filter((nested) => nested.parentStepIndex === child.index) }
|
|
253
|
-
: control.activeChildren.size === 1 && control.nestedChildren?.length ? { nestedChildren: control.nestedChildren } : {}),
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
continue;
|
|
257
|
-
}
|
|
258
|
-
const modelThinking = formatModelThinking(control.model, control.thinking) || undefined;
|
|
259
|
-
entries.push({
|
|
260
|
-
key: `foreground-active:${control.runId}:${control.currentIndex ?? 0}`,
|
|
261
|
-
...(linkedParentKey ? { parentKey: linkedParentKey } : {}),
|
|
262
|
-
agent: control.currentAgent ?? control.mode,
|
|
263
|
-
...(modelThinking ? { modelThinking } : {}),
|
|
264
|
-
description: foregroundDescription(control, control.description),
|
|
265
|
-
startedAt: control.startedAt,
|
|
266
|
-
tokens: control.tokens ?? 0,
|
|
267
|
-
state: "running",
|
|
268
|
-
...(control.nestedChildren?.length ? { nestedChildren: control.nestedChildren } : {}),
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
for (const job of state.asyncJobs.values()) {
|
|
273
|
-
if (!isActiveState(job.status)) continue;
|
|
274
|
-
const startedAt = job.startedAt ?? job.updatedAt ?? Date.now();
|
|
275
|
-
if (job.mode === "workflow") {
|
|
276
|
-
const latestEmit = job.workflow?.emits?.length ? formatWorkflowJsonPreview(job.workflow.emits.at(-1), 120) : undefined;
|
|
277
|
-
entries.push({
|
|
278
|
-
key: `async:${job.asyncId}`,
|
|
279
|
-
workflowWrapper: true,
|
|
280
|
-
agent: "workflow",
|
|
281
|
-
description: latestEmit !== undefined ? `latest emit: ${latestEmit}` : job.description,
|
|
282
|
-
startedAt,
|
|
283
|
-
tokens: job.totalTokens?.total ?? 0,
|
|
284
|
-
state: job.status,
|
|
285
|
-
...(job.nestedChildren?.length ? { nestedChildren: job.nestedChildren } : {}),
|
|
286
|
-
});
|
|
287
|
-
continue;
|
|
288
|
-
}
|
|
289
|
-
const steps: AsyncJobStep[] | undefined = job.steps?.length
|
|
290
|
-
? job.steps
|
|
291
|
-
: job.agents?.map((agent, index) => {
|
|
292
|
-
const pending = job.status === "queued"
|
|
293
|
-
|| (job.mode === "chain" && !job.activeParallelGroup && index !== (job.currentStep ?? 0));
|
|
294
|
-
return { agent, index, status: pending ? "pending" : "running" };
|
|
295
|
-
});
|
|
296
|
-
if (!steps?.length) {
|
|
297
|
-
entries.push({
|
|
298
|
-
key: `async:${job.asyncId}`,
|
|
299
|
-
agent: job.mode ?? "subagent",
|
|
300
|
-
description: job.description,
|
|
301
|
-
startedAt,
|
|
302
|
-
tokens: job.totalTokens?.total ?? 0,
|
|
303
|
-
state: job.status,
|
|
304
|
-
...(job.nestedChildren?.length ? { nestedChildren: job.nestedChildren } : {}),
|
|
305
|
-
});
|
|
306
|
-
continue;
|
|
307
|
-
}
|
|
308
|
-
for (const [offset, step] of steps.entries()) {
|
|
309
|
-
if (!isActiveState(step.status)) continue;
|
|
310
|
-
const index = step.index ?? offset;
|
|
311
|
-
if (step.status === "pending" && job.mode === "chain" && !job.activeParallelGroup && index !== (job.currentStep ?? 0)) continue;
|
|
312
|
-
const modelThinking = formatModelThinking(step.model, step.thinking) || undefined;
|
|
313
|
-
entries.push({
|
|
314
|
-
key: `async:${job.asyncId}:${index}`,
|
|
315
|
-
agent: step.label ? `${step.label} (${step.agent})` : step.agent,
|
|
316
|
-
...(modelThinking ? { modelThinking } : {}),
|
|
317
|
-
description: step.description ?? job.description,
|
|
318
|
-
startedAt: step.startedAt ?? startedAt,
|
|
319
|
-
tokens: step.tokens?.total ?? (steps.length === 1 ? job.totalTokens?.total ?? 0 : 0),
|
|
320
|
-
state: step.status,
|
|
321
|
-
...((step.children?.length ?? 0) > 0
|
|
322
|
-
? { nestedChildren: step.children }
|
|
323
|
-
: job.nestedChildren?.filter((nested) => nested.parentStepIndex === index).length
|
|
324
|
-
? { nestedChildren: job.nestedChildren.filter((nested) => nested.parentStepIndex === index) }
|
|
325
|
-
: {}),
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
if (state.currentSessionId) {
|
|
331
|
-
try {
|
|
332
|
-
for (const run of snapshotExternalRuns(state.currentSessionId, { ignoreMalformed: true, onMalformedRecord: (message) => console.warn(`[pi-subagents] Removed ${message}`) })) {
|
|
333
|
-
if (!isActiveState(run.state)) continue;
|
|
334
|
-
entries.push({
|
|
335
|
-
key: `external:${run.id}`,
|
|
336
|
-
agent: `external · ${run.label}`,
|
|
337
|
-
description: run.currentAction ?? `source: ${run.source}`,
|
|
338
|
-
startedAt: run.startedAt,
|
|
339
|
-
tokens: 0,
|
|
340
|
-
state: run.state,
|
|
341
|
-
external: true,
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
} catch (cause) {
|
|
345
|
-
console.warn(`[pi-subagents] Failed to inspect external jobs: ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
return entries.sort((left, right) => left.startedAt - right.startedAt || left.key.localeCompare(right.key));
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
export class SubagentFleetStatus {
|
|
353
|
-
private ctx: ExtensionContext | undefined;
|
|
354
|
-
private ui: ExtensionContext["ui"] | undefined;
|
|
355
|
-
private tui: FleetStatusTui | undefined;
|
|
356
|
-
private inputUnsubscribe: (() => void) | undefined;
|
|
357
|
-
private timer: ReturnType<typeof setInterval> | undefined;
|
|
358
|
-
private widgetRegistered = false;
|
|
359
|
-
private active = false;
|
|
360
|
-
private selectedKey = "main";
|
|
361
|
-
private inspectorOpen = false;
|
|
362
|
-
private lastRenderKey = "";
|
|
363
|
-
private entries: FleetStatusEntry[] = [];
|
|
364
|
-
private readonly state: SubagentState;
|
|
365
|
-
private readonly openInspector: (itemKey: string) => Promise<void> | void;
|
|
366
|
-
private readonly refreshMs: number;
|
|
367
|
-
private readonly maxAgentRows: number;
|
|
368
|
-
private readonly placement: FleetViewPlacement;
|
|
369
|
-
|
|
370
|
-
constructor(
|
|
371
|
-
state: SubagentState,
|
|
372
|
-
openInspector: (itemKey: string) => Promise<void> | void,
|
|
373
|
-
options: FleetStatusOptions = {},
|
|
374
|
-
) {
|
|
375
|
-
this.state = state;
|
|
376
|
-
this.openInspector = openInspector;
|
|
377
|
-
this.refreshMs = options.refreshMs ?? REFRESH_MS;
|
|
378
|
-
this.maxAgentRows = options.maxAgentRows ?? MAX_AGENT_ROWS;
|
|
379
|
-
this.placement = options.placement ?? "belowEditor";
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
setContext(ctx: ExtensionContext): void {
|
|
383
|
-
if (!ctx.hasUI) return;
|
|
384
|
-
const ui = ctx.ui;
|
|
385
|
-
if (this.ui === ui) {
|
|
386
|
-
this.ctx = ctx;
|
|
387
|
-
this.refresh();
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
this.clearUiRegistration();
|
|
391
|
-
this.ctx = ctx;
|
|
392
|
-
this.ui = ui;
|
|
393
|
-
if (typeof ui.onTerminalInput === "function") {
|
|
394
|
-
this.inputUnsubscribe = ui.onTerminalInput((data) => this.handleKey(data));
|
|
395
|
-
}
|
|
396
|
-
this.timer = setInterval(() => this.refresh(), this.refreshMs);
|
|
397
|
-
this.timer.unref?.();
|
|
398
|
-
this.refresh();
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
dispose(): void {
|
|
402
|
-
this.clearUiRegistration();
|
|
403
|
-
this.ctx = undefined;
|
|
404
|
-
this.ui = undefined;
|
|
405
|
-
this.entries = [];
|
|
406
|
-
this.active = false;
|
|
407
|
-
this.selectedKey = "main";
|
|
408
|
-
this.inspectorOpen = false;
|
|
409
|
-
this.lastRenderKey = "";
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
refresh(): void {
|
|
413
|
-
const ctx = this.getActiveUiContext();
|
|
414
|
-
if (!ctx) return;
|
|
415
|
-
if (this.state.widgetsSuspended) {
|
|
416
|
-
this.clearWidget();
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
this.entries = collectFleetStatusEntries(this.state);
|
|
420
|
-
this.clampSelection();
|
|
421
|
-
if (this.inspectorOpen || this.state.fleetInspectorOpen) {
|
|
422
|
-
this.lastRenderKey = "";
|
|
423
|
-
this.clearWidget();
|
|
424
|
-
return;
|
|
425
|
-
}
|
|
426
|
-
if (this.entries.length === 0 && !(this.state.activeAsyncCapacity?.used)) {
|
|
427
|
-
this.active = false;
|
|
428
|
-
this.selectedKey = "main";
|
|
429
|
-
this.lastRenderKey = "";
|
|
430
|
-
this.clearWidget();
|
|
431
|
-
return;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
const renderKey = this.getRenderKey();
|
|
435
|
-
if (!this.widgetRegistered) {
|
|
436
|
-
ctx.ui.setWidget(FLEET_STATUS_WIDGET_KEY, (tui, theme) => {
|
|
437
|
-
this.tui = tui;
|
|
438
|
-
return {
|
|
439
|
-
render: (width: number) => this.render(width, theme),
|
|
440
|
-
invalidate: () => {
|
|
441
|
-
this.lastRenderKey = "";
|
|
442
|
-
},
|
|
443
|
-
dispose: () => {
|
|
444
|
-
if (this.tui !== tui) return;
|
|
445
|
-
this.widgetRegistered = false;
|
|
446
|
-
this.tui = undefined;
|
|
447
|
-
},
|
|
448
|
-
};
|
|
449
|
-
}, { placement: this.placement });
|
|
450
|
-
this.widgetRegistered = true;
|
|
451
|
-
this.lastRenderKey = renderKey;
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
if (renderKey === this.lastRenderKey) return;
|
|
455
|
-
this.lastRenderKey = renderKey;
|
|
456
|
-
this.tui?.requestRender();
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
handleKey(data: string): { consume?: boolean; data?: string } | undefined {
|
|
460
|
-
if (this.state.widgetsSuspended) return undefined;
|
|
461
|
-
const ctx = this.getActiveUiContext();
|
|
462
|
-
if (!ctx || this.entries.length === 0 || isKeyRelease(data)) return undefined;
|
|
463
|
-
if (this.inspectorOpen) return undefined;
|
|
464
|
-
if (!this.editorHasFocus()) {
|
|
465
|
-
if (this.active) this.deactivate();
|
|
466
|
-
return undefined;
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
if (!this.active) {
|
|
470
|
-
const activates = matchesKey(data, "down") || matchesKey(data, "left");
|
|
471
|
-
if (!activates || ctx.ui.getEditorText() !== "") return undefined;
|
|
472
|
-
this.active = true;
|
|
473
|
-
this.selectedKey = "main";
|
|
474
|
-
this.refresh();
|
|
475
|
-
return { consume: true };
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
const roster = this.rosterKeys();
|
|
479
|
-
const selectedIndex = Math.max(0, roster.indexOf(this.selectedKey));
|
|
480
|
-
if (matchesKey(data, "down") || matchesKey(data, "j")) {
|
|
481
|
-
this.selectedKey = roster[Math.min(roster.length - 1, selectedIndex + 1)] ?? "main";
|
|
482
|
-
this.refresh();
|
|
483
|
-
return { consume: true };
|
|
484
|
-
}
|
|
485
|
-
if (matchesKey(data, "up") || matchesKey(data, "k")) {
|
|
486
|
-
if (selectedIndex === 0) {
|
|
487
|
-
this.deactivate();
|
|
488
|
-
return { consume: true };
|
|
489
|
-
}
|
|
490
|
-
this.selectedKey = roster[selectedIndex - 1] ?? "main";
|
|
491
|
-
this.refresh();
|
|
492
|
-
return { consume: true };
|
|
493
|
-
}
|
|
494
|
-
if (matchesKey(data, "escape")) {
|
|
495
|
-
this.deactivate();
|
|
496
|
-
return { consume: true };
|
|
497
|
-
}
|
|
498
|
-
if (matchesKey(data, Key.enter)) {
|
|
499
|
-
if (this.selectedKey === "main") {
|
|
500
|
-
this.deactivate();
|
|
501
|
-
return { consume: true };
|
|
502
|
-
}
|
|
503
|
-
this.inspectorOpen = true;
|
|
504
|
-
this.refresh();
|
|
505
|
-
const selectedKey = this.selectedKey;
|
|
506
|
-
void Promise.resolve()
|
|
507
|
-
.then(() => this.openInspector(selectedKey))
|
|
508
|
-
.catch((error) => ctx.ui.notify(error instanceof Error ? error.message : String(error), "error"))
|
|
509
|
-
.finally(() => {
|
|
510
|
-
this.inspectorOpen = false;
|
|
511
|
-
this.refresh();
|
|
512
|
-
});
|
|
513
|
-
return { consume: true };
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
this.deactivate();
|
|
517
|
-
return undefined;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
render(width: number, theme: Theme): string[] {
|
|
521
|
-
if (this.entries.length === 0 && !(this.state.activeAsyncCapacity?.used)) return [];
|
|
522
|
-
if (!this.active) {
|
|
523
|
-
const tokens = this.entries.reduce((total, entry) => total + entry.tokens, 0);
|
|
524
|
-
const capacity = this.state.activeAsyncCapacity;
|
|
525
|
-
const hasNativeRows = this.entries.some((entry) => !entry.external);
|
|
526
|
-
const showNativeSummary = hasNativeRows || Boolean(capacity?.used);
|
|
527
|
-
const asyncRuns = capacity && showNativeSummary ? `Async runs ${capacity.used}/${capacity.limit || "∞"}` : "";
|
|
528
|
-
const activeEntries = activeLeafAgentCount(this.entries);
|
|
529
|
-
const noun = this.entries.some((entry) => entry.external) ? "job" : "agent";
|
|
530
|
-
const agents = activeEntries > 0 ? `${activeEntries} active ${noun}${activeEntries === 1 ? "" : "s"}` : "";
|
|
531
|
-
const label = [agents, asyncRuns].filter(Boolean).join(" · ");
|
|
532
|
-
const detail = [showNativeSummary ? formatFleetTokens(tokens) : undefined, "↓/← to inspect"].filter(Boolean).join(" · ");
|
|
533
|
-
return [truncateToWidth(` ${theme.fg("muted", label)} · ${theme.fg("dim", detail)}`, width)];
|
|
534
|
-
}
|
|
535
|
-
const roster = this.rosterKeys();
|
|
536
|
-
const selectedIndex = Math.max(0, roster.indexOf(this.selectedKey));
|
|
537
|
-
const lines = [truncateToWidth(` ${theme.fg("dim", "↑↓/jk select · enter inspect · esc back")}`, width), ""];
|
|
538
|
-
lines.push(truncateToWidth(` ${this.bullet(0, selectedIndex, theme)} main`, width));
|
|
539
|
-
|
|
540
|
-
const tree = fleetTreeRows(this.entries);
|
|
541
|
-
const selectedTreeIndex = Math.max(0, tree.findIndex((row) => (row.kind === "owner" || row.kind === "child") && row.entry.key === this.selectedKey));
|
|
542
|
-
const visibleCount = Math.min(this.maxAgentRows, tree.length);
|
|
543
|
-
const start = selectedTreeIndex < visibleCount ? 0 : selectedTreeIndex - visibleCount + 1;
|
|
544
|
-
const hiddenBelow = tree.length - (start + visibleCount);
|
|
545
|
-
if (start > 0) lines.push(rightAlign("", theme.fg("dim", `↑ ${start} more`), width));
|
|
546
|
-
for (let index = start; index < start + visibleCount; index++) {
|
|
547
|
-
const row = tree[index]!;
|
|
548
|
-
if (row.kind === "owner" || row.kind === "child") {
|
|
549
|
-
const ownerIndex = this.entries.findIndex((entry) => entry.key === row.entry.key);
|
|
550
|
-
lines.push(this.renderEntry(ownerIndex + 1, selectedIndex, row.entry, width, theme, row.kind === "child" ? (row.last ? "└─" : "├─") : undefined));
|
|
551
|
-
} else {
|
|
552
|
-
lines.push(this.renderNestedRow(row.row, row.last, width, theme));
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
if (hiddenBelow > 0) lines.push(rightAlign("", theme.fg("dim", `↓ ${hiddenBelow} more`), width));
|
|
556
|
-
return lines;
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
private renderEntry(rosterIndex: number, selectedIndex: number, entry: FleetStatusEntry, width: number, theme: Theme, branch?: string): string {
|
|
560
|
-
const agent = entry.modelThinking ? `${entry.agent} (${entry.modelThinking})` : entry.agent;
|
|
561
|
-
const prefix = branch ? ` ${branch}` : " ";
|
|
562
|
-
const left = `${prefix} ${this.bullet(rosterIndex, selectedIndex, theme)} ${theme.fg("muted", agent)} · ${entry.state}`;
|
|
563
|
-
const elapsed = Date.now() - entry.startedAt;
|
|
564
|
-
const right = theme.fg("dim", entry.external ? formatFleetElapsed(elapsed) : `${formatFleetElapsed(elapsed)} · ${formatFleetTokens(entry.tokens)}`);
|
|
565
|
-
return rightAlign(left, right, width);
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
private renderNestedRow(row: FleetNestedRow, last: boolean, width: number, theme: Theme): string {
|
|
569
|
-
const marker = last ? "└─" : "├─";
|
|
570
|
-
const indent = " ".repeat(row.depth + 1);
|
|
571
|
-
if (row.overflow !== undefined) return truncateToWidth(`${indent}${marker} ${theme.fg("dim", `+${row.overflow} nested leaves`)}`, width);
|
|
572
|
-
const modelThinking = row.modelThinking ? ` (${row.modelThinking})` : "";
|
|
573
|
-
const activity = row.activity ? ` · ${row.activity}` : "";
|
|
574
|
-
const left = `${indent}${marker} ${nestedStatusGlyph(row.state, theme)} ${theme.fg("muted", `${row.name}${modelThinking}`)} · ${row.state}${activity}`;
|
|
575
|
-
const elapsed = row.startedAt !== undefined ? ` · ${formatFleetElapsed(Date.now() - row.startedAt)}` : "";
|
|
576
|
-
return truncateToWidth(`${left}${theme.fg("dim", elapsed)}`, width);
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
private bullet(rosterIndex: number, selectedIndex: number, theme: Theme): string {
|
|
580
|
-
return rosterIndex === selectedIndex ? theme.fg("accent", ">") : " ";
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
private rosterKeys(): string[] {
|
|
584
|
-
return ["main", ...this.entries.map((entry) => entry.key)];
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
private clampSelection(): void {
|
|
588
|
-
if (!this.rosterKeys().includes(this.selectedKey)) this.selectedKey = "main";
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
private deactivate(): void {
|
|
592
|
-
this.active = false;
|
|
593
|
-
this.selectedKey = "main";
|
|
594
|
-
this.refresh();
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
private editorHasFocus(): boolean {
|
|
598
|
-
// pi-tui exposes focus mutation but no focus getter, so inspect the focused
|
|
599
|
-
// component structurally. instanceof is unreliable across jiti module boundaries.
|
|
600
|
-
const focused = (this.tui as unknown as { focusedComponent?: unknown } | undefined)?.focusedComponent;
|
|
601
|
-
if (!focused || typeof focused !== "object") return false;
|
|
602
|
-
const candidate = focused as Partial<EditorComponent>;
|
|
603
|
-
return typeof candidate.render === "function"
|
|
604
|
-
&& typeof candidate.invalidate === "function"
|
|
605
|
-
&& typeof candidate.handleInput === "function"
|
|
606
|
-
&& typeof candidate.getText === "function"
|
|
607
|
-
&& typeof candidate.setText === "function";
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
private getRenderKey(): string {
|
|
611
|
-
const now = Date.now();
|
|
612
|
-
return JSON.stringify({
|
|
613
|
-
active: this.active,
|
|
614
|
-
selected: this.selectedKey,
|
|
615
|
-
inspectorOpen: this.inspectorOpen,
|
|
616
|
-
entries: this.entries.map((entry) => this.active
|
|
617
|
-
? [
|
|
618
|
-
entry.key,
|
|
619
|
-
entry.parentKey,
|
|
620
|
-
entry.agent,
|
|
621
|
-
entry.state,
|
|
622
|
-
entry.modelThinking,
|
|
623
|
-
entry.description,
|
|
624
|
-
entry.external,
|
|
625
|
-
Math.round((now - entry.startedAt) / 1000),
|
|
626
|
-
entry.tokens,
|
|
627
|
-
nestedFleetRows(entry.nestedChildren, entry.parentKey ? 3 : 4).map((row) => [
|
|
628
|
-
row.name,
|
|
629
|
-
row.state,
|
|
630
|
-
row.modelThinking,
|
|
631
|
-
row.activity,
|
|
632
|
-
row.startedAt,
|
|
633
|
-
row.depth,
|
|
634
|
-
row.overflow,
|
|
635
|
-
]),
|
|
636
|
-
]
|
|
637
|
-
: [entry.key, entry.state, entry.external, entry.tokens]),
|
|
638
|
-
});
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
private getActiveUiContext(): ExtensionContext | undefined {
|
|
642
|
-
const ctx = this.ctx;
|
|
643
|
-
if (!ctx) return undefined;
|
|
644
|
-
try {
|
|
645
|
-
return ctx.hasUI ? ctx : undefined;
|
|
646
|
-
} catch (error) {
|
|
647
|
-
if (!isStaleExtensionContextError(error)) throw error;
|
|
648
|
-
this.clearUiRegistration();
|
|
649
|
-
return undefined;
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
private clearWidget(): void {
|
|
654
|
-
if (!this.widgetRegistered) return;
|
|
655
|
-
this.ui?.setWidget(FLEET_STATUS_WIDGET_KEY, undefined);
|
|
656
|
-
this.widgetRegistered = false;
|
|
657
|
-
this.tui = undefined;
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
private clearUiRegistration(): void {
|
|
661
|
-
if (this.timer) clearInterval(this.timer);
|
|
662
|
-
this.timer = undefined;
|
|
663
|
-
|
|
664
|
-
const inputUnsubscribe = this.inputUnsubscribe;
|
|
665
|
-
const ui = this.ui;
|
|
666
|
-
const widgetRegistered = this.widgetRegistered;
|
|
667
|
-
this.inputUnsubscribe = undefined;
|
|
668
|
-
this.ctx = undefined;
|
|
669
|
-
this.ui = undefined;
|
|
670
|
-
this.widgetRegistered = false;
|
|
671
|
-
this.tui = undefined;
|
|
672
|
-
|
|
673
|
-
const cleanupErrors: unknown[] = [];
|
|
674
|
-
try {
|
|
675
|
-
inputUnsubscribe?.();
|
|
676
|
-
} catch (error) {
|
|
677
|
-
if (!isStaleExtensionContextError(error)) cleanupErrors.push(error);
|
|
678
|
-
}
|
|
679
|
-
if (ui && widgetRegistered) {
|
|
680
|
-
try {
|
|
681
|
-
ui.setWidget(FLEET_STATUS_WIDGET_KEY, undefined);
|
|
682
|
-
} catch (error) {
|
|
683
|
-
if (!isStaleExtensionContextError(error)) cleanupErrors.push(error);
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
if (cleanupErrors.length === 1) throw cleanupErrors[0];
|
|
687
|
-
if (cleanupErrors.length > 1) {
|
|
688
|
-
throw new AggregateError(cleanupErrors, "Failed to clean up FleetView UI registration");
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
}
|