@selesai/code 0.5.28 → 0.5.29
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/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +9 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/credential-print.d.ts +23 -0
- package/dist/cli/credential-print.d.ts.map +1 -0
- package/dist/cli/credential-print.js +117 -0
- package/dist/cli/credential-print.js.map +1 -0
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +1 -1
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +3 -0
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +12 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +20 -14
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +11 -3
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +11 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +14 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +10 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +1 -1
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/llama/provider.d.ts.map +1 -1
- package/dist/core/llama/provider.js +8 -3
- package/dist/core/llama/provider.js.map +1 -1
- package/dist/core/model-config.d.ts +30 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +6 -0
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +2 -2
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -0
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +20 -3
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +2 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +5 -4
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +13 -6
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +24 -11
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts +15 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +66 -9
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +1 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +34 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +3 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/extensions/pi-intercom/CHANGELOG.md +249 -0
- package/dist/extensions/pi-intercom/README.md +102 -39
- package/dist/extensions/pi-intercom/broker/broker.ts +1233 -36
- package/dist/extensions/pi-intercom/broker/client.test.ts +83 -0
- package/dist/extensions/pi-intercom/broker/client.ts +315 -12
- package/dist/extensions/pi-intercom/broker/extension-state.ts +186 -0
- package/dist/extensions/pi-intercom/broker/extension.test.ts +387 -0
- package/dist/extensions/pi-intercom/broker/framing.test.ts +114 -0
- package/dist/extensions/pi-intercom/broker/framing.ts +82 -24
- package/dist/extensions/pi-intercom/broker/paths.test.ts +153 -0
- package/dist/extensions/pi-intercom/broker/paths.ts +117 -8
- package/dist/extensions/pi-intercom/broker/runtime-claim.test.ts +34 -0
- package/dist/extensions/pi-intercom/broker/runtime-claim.ts +21 -0
- package/dist/extensions/pi-intercom/broker/spawn.test.ts +160 -23
- package/dist/extensions/pi-intercom/broker/spawn.ts +113 -27
- package/dist/extensions/pi-intercom/config.test.ts +93 -0
- package/dist/extensions/pi-intercom/config.ts +55 -6
- package/dist/extensions/pi-intercom/cwd.test.ts +40 -0
- package/dist/extensions/pi-intercom/cwd.ts +31 -0
- package/dist/extensions/pi-intercom/extension-api.ts +44 -0
- package/dist/extensions/pi-intercom/format-context.test.ts +31 -0
- package/dist/extensions/pi-intercom/format-context.ts +32 -0
- package/dist/extensions/pi-intercom/index.ts +742 -145
- package/dist/extensions/pi-intercom/intercom.integration.test.ts +2646 -0
- package/dist/extensions/pi-intercom/package.json +15 -5
- package/dist/extensions/pi-intercom/reply-tracker.test.ts +134 -0
- package/dist/extensions/pi-intercom/reply-tracker.ts +31 -13
- package/dist/extensions/pi-intercom/skills/pi-intercom/SKILL.md +13 -11
- package/dist/extensions/pi-intercom/test/inline-message.test.ts +184 -0
- package/dist/extensions/pi-intercom/test/overlay-width.test.ts +66 -0
- package/dist/extensions/pi-intercom/types.ts +94 -4
- package/dist/extensions/pi-intercom/ui/compose.ts +8 -4
- package/dist/extensions/pi-intercom/ui/inline-message.ts +61 -25
- package/dist/extensions/pi-intercom/ui/session-list.ts +7 -3
- package/dist/extensions/pi-subagents/CHANGELOG.md +85 -0
- package/dist/extensions/pi-subagents/LICENSE +21 -0
- package/dist/extensions/pi-subagents/README.md +146 -52
- package/dist/extensions/pi-subagents/agents/architect.md +1 -0
- package/dist/extensions/pi-subagents/agents/builder.md +1 -0
- package/dist/extensions/pi-subagents/package-lock.json +2 -2
- package/dist/extensions/pi-subagents/package.json +3 -3
- package/dist/extensions/pi-subagents/prompts/review-loop.md +1 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +21 -989
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/constraints-and-recipes.md +256 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md +430 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/management-authoring-rpc.md +144 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/prompting-and-roles.md +282 -0
- package/dist/extensions/pi-subagents/src/agents/agent-management.ts +71 -30
- package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +4 -0
- package/dist/extensions/pi-subagents/src/agents/agents.ts +118 -9
- package/dist/extensions/pi-subagents/src/agents/skills.ts +14 -12
- package/dist/extensions/pi-subagents/src/api/delegation.ts +3 -0
- package/dist/extensions/pi-subagents/src/api/preflight.ts +16 -12
- package/dist/extensions/pi-subagents/src/extension/chain-validation.ts +17 -1
- package/dist/extensions/pi-subagents/src/extension/index.ts +17 -7
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +248 -6
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +31 -6
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +8 -7
- package/dist/extensions/pi-subagents/src/intercom/intercom-bridge.ts +9 -4
- package/dist/extensions/pi-subagents/src/intercom/result-intercom.ts +33 -4
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +63 -16
- package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +24 -13
- package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +7 -5
- package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +18 -2
- package/dist/extensions/pi-subagents/src/runs/background/chain-append.ts +48 -5
- package/dist/extensions/pi-subagents/src/runs/background/control-channel.ts +68 -1
- package/dist/extensions/pi-subagents/src/runs/background/notify.ts +29 -4
- package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +29 -6
- package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +29 -3
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +372 -28
- package/dist/extensions/pi-subagents/src/runs/foreground/async-stop-action.ts +65 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/chain-clarify.ts +3 -3
- package/dist/extensions/pi-subagents/src/runs/foreground/chain-execution.ts +143 -43
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +527 -247
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-control.ts +42 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +426 -123
- package/dist/extensions/pi-subagents/src/runs/shared/acceptance.ts +15 -7
- package/dist/extensions/pi-subagents/src/runs/shared/capability-ceiling.ts +51 -19
- package/dist/extensions/pi-subagents/src/runs/shared/chain-outputs.ts +3 -1
- package/dist/extensions/pi-subagents/src/runs/shared/dynamic-fanout.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +44 -11
- package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +8 -0
- package/dist/extensions/pi-subagents/src/runs/shared/nested-events.ts +97 -20
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +43 -12
- package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +52 -4
- package/dist/extensions/pi-subagents/src/runs/shared/process-signal.ts +19 -0
- package/dist/extensions/pi-subagents/src/runs/shared/run-history.ts +45 -9
- package/dist/extensions/pi-subagents/src/runs/shared/runtime-acknowledged-extensions.ts +71 -0
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +31 -1
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-startup-retry.ts +101 -0
- package/dist/extensions/pi-subagents/src/runs/shared/task-intent.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/usage-budget.ts +65 -0
- package/dist/extensions/pi-subagents/src/runs/shared/workflow-graph.ts +26 -1
- package/dist/extensions/pi-subagents/src/shared/settings.ts +17 -1
- package/dist/extensions/pi-subagents/src/shared/types.ts +155 -10
- package/dist/extensions/pi-subagents/src/shared/utils.ts +73 -4
- package/dist/extensions/pi-subagents/src/slash/delegation-adapters.ts +5 -0
- package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +46 -4
- package/dist/extensions/pi-subagents/src/slash/slash-live-state.ts +5 -3
- package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +87 -24
- package/dist/extensions/pi-subagents/src/tui/fleet.ts +182 -9
- package/dist/extensions/pi-subagents/src/tui/render.ts +27 -28
- package/dist/extensions/pi-subagents/src/watchdog/register-main.ts +14 -7
- package/dist/extensions/pi-subagents/src/watchdog/review.ts +5 -4
- package/dist/extensions/pi-subagents/src/watchdog/runtime.ts +170 -17
- package/dist/extensions/pi-subagents/src/watchdog/scope.ts +62 -0
- package/dist/extensions/pi-subagents/src/watchdog/settings.ts +41 -1
- package/dist/extensions/pi-subagents/src/watchdog/types.ts +10 -0
- package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +348 -7
- package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +84 -0
- package/dist/extensions/pi-subagents/test/integration/async-status.test.ts +4 -2
- package/dist/extensions/pi-subagents/test/integration/chain-clarify.test.ts +51 -2
- package/dist/extensions/pi-subagents/test/integration/chain-execution.test.ts +26 -1
- package/dist/extensions/pi-subagents/test/integration/detect-error.test.ts +48 -0
- package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +3 -3
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +213 -13
- package/dist/extensions/pi-subagents/test/integration/parallel-execution.test.ts +34 -0
- package/dist/extensions/pi-subagents/test/integration/render-fork-badge.test.ts +44 -0
- package/dist/extensions/pi-subagents/test/integration/result-watcher.test.ts +118 -12
- package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +850 -7
- package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +112 -23
- package/dist/extensions/pi-subagents/test/support/mock-pi-script.mjs +17 -5
- package/dist/extensions/pi-subagents/test/support/mock-pi.ts +2 -0
- package/dist/extensions/pi-subagents/test/support/register-loader.mjs +3 -3
- package/dist/extensions/pi-subagents/test/unit/acceptance.test.ts +3 -1
- package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +128 -0
- package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +47 -2
- package/dist/extensions/pi-subagents/test/unit/async-recovery-descriptor.test.ts +60 -0
- package/dist/extensions/pi-subagents/test/unit/async-resume.test.ts +8 -0
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling-agent-allowlist.test.ts +102 -0
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/chain-append.test.ts +6 -0
- package/dist/extensions/pi-subagents/test/unit/chain-validation.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +48 -48
- package/dist/extensions/pi-subagents/test/unit/config-dir-runtime.test.ts +23 -0
- package/dist/extensions/pi-subagents/test/unit/control-channel.test.ts +27 -0
- package/dist/extensions/pi-subagents/test/unit/delegation-api.test.ts +4 -2
- package/dist/extensions/pi-subagents/test/unit/dynamic-fanout.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +176 -8
- package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +164 -5
- package/dist/extensions/pi-subagents/test/unit/foreground-control.test.ts +41 -1
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +11 -11
- package/dist/extensions/pi-subagents/test/unit/intercom-bridge.test.ts +18 -2
- package/dist/extensions/pi-subagents/test/unit/nested-control.test.ts +20 -1
- package/dist/extensions/pi-subagents/test/unit/nested-events.test.ts +30 -2
- package/dist/extensions/pi-subagents/test/unit/notify.test.ts +10 -2
- package/dist/extensions/pi-subagents/test/unit/parallel-utils.test.ts +22 -0
- package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +103 -0
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +18 -0
- package/dist/extensions/pi-subagents/test/unit/preflight.test.ts +46 -0
- package/dist/extensions/pi-subagents/test/unit/render-helpers.test.ts +13 -1
- package/dist/extensions/pi-subagents/test/unit/result-intercom.test.ts +29 -4
- package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +223 -4
- package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +30 -0
- package/dist/extensions/pi-subagents/test/unit/runtime-acknowledged-extensions.test.ts +52 -0
- package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +34 -2
- package/dist/extensions/pi-subagents/test/unit/skills-fallback.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/steering-action.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/streamed-progress-bounds.test.ts +78 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +41 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-startup-retry.test.ts +77 -0
- package/dist/extensions/pi-subagents/test/unit/task-intent.test.ts +3 -0
- package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/total-cost.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-runtime.test.ts +210 -1
- package/dist/extensions/pi-subagents/test/unit/watchdog-scope.test.ts +33 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-settings.test.ts +32 -0
- package/dist/extensions/pi-subagents/test/unit/writer-budget-guidance.test.ts +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +43 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts +3 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +10 -2
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +1 -2
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +16 -46
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +4 -1
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +22 -13
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts +12 -0
- package/dist/modes/interactive/external-editor.d.ts.map +1 -0
- package/dist/modes/interactive/external-editor.js +37 -0
- package/dist/modes/interactive/external-editor.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +72 -64
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +14 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +19 -8
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +1 -1
- package/dist/utils/version-check.js.map +1 -1
- package/docs/compaction.md +1 -1
- package/docs/custom-provider.md +14 -5
- package/docs/environment-variables.md +86 -0
- package/docs/extensions.md +15 -5
- package/docs/index.md +1 -0
- package/docs/models.md +9 -2
- package/docs/providers.md +21 -2
- package/docs/rpc.md +23 -6
- package/docs/session-format.md +2 -0
- package/docs/settings.md +1 -1
- package/docs/usage.md +0 -13
- package/examples/extensions/custom-compaction.ts +5 -2
- package/examples/extensions/custom-provider-anthropic/index.ts +9 -3
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/handoff.ts +11 -3
- package/examples/extensions/message-renderer.ts +3 -3
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/summarize.ts +5 -2
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/sdk/12-full-control.ts +3 -1
- package/package.json +15 -6
- package/dist/extensions/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
|
@@ -304,6 +304,21 @@ function stopFallbackText(targets: StopSelectorTarget[]): string {
|
|
|
304
304
|
return lines.join("\n");
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
+
function selectForegroundDetachControl(state: SubagentState, requested: string) {
|
|
308
|
+
const controls = [...state.foregroundControls.values()];
|
|
309
|
+
if (requested) {
|
|
310
|
+
const matches = controls.filter((control) => control.runId === requested || control.runId.startsWith(requested));
|
|
311
|
+
if (matches.length > 1) throw new Error(`Ambiguous foreground run id prefix '${requested}' matched: ${matches.map((control) => control.runId).join(", ")}. Provide a longer id.`);
|
|
312
|
+
return matches[0];
|
|
313
|
+
}
|
|
314
|
+
const singleControls = controls.filter((control) => control.mode === "single");
|
|
315
|
+
if (state.lastForegroundControlId) {
|
|
316
|
+
const latest = state.foregroundControls.get(state.lastForegroundControlId);
|
|
317
|
+
if (latest?.mode === "single") return latest;
|
|
318
|
+
}
|
|
319
|
+
return singleControls.sort((left, right) => right.updatedAt - left.updatedAt)[0];
|
|
320
|
+
}
|
|
321
|
+
|
|
307
322
|
class SubagentsStopSelector implements Component {
|
|
308
323
|
readonly width = 84;
|
|
309
324
|
private selected = 0;
|
|
@@ -336,12 +351,12 @@ class SubagentsStopSelector implements Component {
|
|
|
336
351
|
}
|
|
337
352
|
return;
|
|
338
353
|
}
|
|
339
|
-
if (matchesKey(data, "up")) {
|
|
354
|
+
if (matchesKey(data, "up") || matchesKey(data, "k")) {
|
|
340
355
|
this.selected = Math.max(0, this.selected - 1);
|
|
341
356
|
this.tui.requestRender();
|
|
342
357
|
return;
|
|
343
358
|
}
|
|
344
|
-
if (matchesKey(data, "down")) {
|
|
359
|
+
if (matchesKey(data, "down") || matchesKey(data, "j")) {
|
|
345
360
|
this.selected = Math.min(this.targets.length - 1, this.selected + 1);
|
|
346
361
|
this.tui.requestRender();
|
|
347
362
|
return;
|
|
@@ -375,7 +390,7 @@ class SubagentsStopSelector implements Component {
|
|
|
375
390
|
if (target.kind === "async") lines.push(this.theme.fg("dim", "Stop ends this run; use interrupt for a resumable pause."));
|
|
376
391
|
lines.push(this.theme.fg("dim", "Enter/Y confirms · N returns · Esc cancels"));
|
|
377
392
|
} else {
|
|
378
|
-
lines.push(this.theme.fg("dim", "
|
|
393
|
+
lines.push(this.theme.fg("dim", "↑↓/jk select · Enter confirm · Esc cancel"));
|
|
379
394
|
}
|
|
380
395
|
return lines;
|
|
381
396
|
}
|
|
@@ -1283,7 +1298,7 @@ export function registerSlashCommands(
|
|
|
1283
1298
|
});
|
|
1284
1299
|
|
|
1285
1300
|
pi.registerCommand("subagents-fleet", {
|
|
1286
|
-
description: "Open the live
|
|
1301
|
+
description: "Open the live subagent fleet inspector",
|
|
1287
1302
|
handler: async (_args, ctx) => showFleet(ctx),
|
|
1288
1303
|
});
|
|
1289
1304
|
|
|
@@ -1292,6 +1307,33 @@ export function registerSlashCommands(
|
|
|
1292
1307
|
handler: async (ctx) => showFleet(ctx),
|
|
1293
1308
|
});
|
|
1294
1309
|
|
|
1310
|
+
pi.registerCommand("subagents-detach", {
|
|
1311
|
+
description: "Detach the active foreground single-subagent run without terminating it",
|
|
1312
|
+
handler: async (args, ctx) => {
|
|
1313
|
+
const id = args.trim();
|
|
1314
|
+
let control: ReturnType<typeof selectForegroundDetachControl>;
|
|
1315
|
+
try {
|
|
1316
|
+
control = selectForegroundDetachControl(state, id);
|
|
1317
|
+
} catch (error) {
|
|
1318
|
+
ctx.ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
1319
|
+
return;
|
|
1320
|
+
}
|
|
1321
|
+
if (!control) {
|
|
1322
|
+
ctx.ui.notify(id ? `No active foreground run found for '${id}'.` : "No active foreground single-subagent run to detach.", "info");
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1325
|
+
if (control.mode !== "single") {
|
|
1326
|
+
ctx.ui.notify("/subagents-detach currently supports single-subagent runs only.", "error");
|
|
1327
|
+
return;
|
|
1328
|
+
}
|
|
1329
|
+
if (!control.detach?.()) {
|
|
1330
|
+
ctx.ui.notify(`Foreground run ${control.runId} is not currently detachable.`, "info");
|
|
1331
|
+
return;
|
|
1332
|
+
}
|
|
1333
|
+
sendSlashText(pi, `Detached foreground run ${control.runId} without terminating its child. Use subagent({ action: "status", id: ${JSON.stringify(control.runId)} }) or subagent_wait({ id: ${JSON.stringify(control.runId)} }) to recover the eventual result. This does not daemonize the process or guarantee survival across Pi reload/restart.`);
|
|
1334
|
+
},
|
|
1335
|
+
});
|
|
1336
|
+
|
|
1295
1337
|
pi.registerCommand("subagents-stop", {
|
|
1296
1338
|
description: "Stop a current-session async subagent run",
|
|
1297
1339
|
handler: async (args, ctx) => {
|
|
@@ -51,16 +51,17 @@ function createPlaceholderResult(
|
|
|
51
51
|
agent: string,
|
|
52
52
|
task: string,
|
|
53
53
|
status: "pending" | "running",
|
|
54
|
-
index
|
|
54
|
+
index: number,
|
|
55
55
|
): SingleResult {
|
|
56
56
|
return {
|
|
57
57
|
agent,
|
|
58
58
|
task,
|
|
59
|
+
index,
|
|
59
60
|
exitCode: 0,
|
|
60
61
|
messages: EMPTY_MESSAGES,
|
|
61
62
|
usage: cloneUsage(),
|
|
62
63
|
progress: {
|
|
63
|
-
|
|
64
|
+
index,
|
|
64
65
|
agent,
|
|
65
66
|
status,
|
|
66
67
|
task,
|
|
@@ -162,8 +163,9 @@ function buildSingleInitialResult(params: SubagentParamsLike): AgentToolResult<D
|
|
|
162
163
|
details: {
|
|
163
164
|
mode: "single",
|
|
164
165
|
...(params.context ? { context: params.context } : {}),
|
|
165
|
-
results: [createPlaceholderResult(agent, task, "running")],
|
|
166
|
+
results: [createPlaceholderResult(agent, task, "running", 0)],
|
|
166
167
|
progress: [{
|
|
168
|
+
index: 0,
|
|
167
169
|
agent,
|
|
168
170
|
status: "running",
|
|
169
171
|
task,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ExtensionContext } from "@selesai/code";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { type EditorComponent, isKeyRelease, Key, matchesKey, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
3
|
+
import { formatModelThinking } from "../shared/formatters.ts";
|
|
4
|
+
import type { AsyncJobStep, FleetViewPlacement, SubagentState } from "../shared/types.ts";
|
|
4
5
|
|
|
5
6
|
export const FLEET_STATUS_WIDGET_KEY = "subagent-fleet-status";
|
|
6
7
|
|
|
@@ -14,6 +15,7 @@ type FleetStatusTui = {
|
|
|
14
15
|
type FleetStatusEntry = {
|
|
15
16
|
key: string;
|
|
16
17
|
agent: string;
|
|
18
|
+
modelThinking?: string;
|
|
17
19
|
description?: string;
|
|
18
20
|
startedAt: number;
|
|
19
21
|
tokens: number;
|
|
@@ -22,6 +24,11 @@ type FleetStatusEntry = {
|
|
|
22
24
|
export interface FleetStatusOptions {
|
|
23
25
|
refreshMs?: number;
|
|
24
26
|
maxAgentRows?: number;
|
|
27
|
+
placement?: FleetViewPlacement;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function resolveFleetViewPlacement(value: unknown): FleetViewPlacement {
|
|
31
|
+
return value === "aboveEditor" ? "aboveEditor" : "belowEditor";
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
export function formatFleetElapsed(ms: number): string {
|
|
@@ -48,14 +55,23 @@ function isActiveState(value: string): boolean {
|
|
|
48
55
|
return value === "running" || value === "queued" || value === "pending";
|
|
49
56
|
}
|
|
50
57
|
|
|
58
|
+
function isStaleExtensionContextError(error: unknown): boolean {
|
|
59
|
+
// Pi currently exposes stale contexts as plain Errors without a stable code or subtype.
|
|
60
|
+
return error instanceof Error
|
|
61
|
+
&& (error.message.includes("This extension ctx is stale")
|
|
62
|
+
|| error.message.includes("Extension context no longer active"));
|
|
63
|
+
}
|
|
64
|
+
|
|
51
65
|
export function collectFleetStatusEntries(state: SubagentState): FleetStatusEntry[] {
|
|
52
66
|
const entries: FleetStatusEntry[] = [];
|
|
53
67
|
for (const control of state.foregroundControls.values()) {
|
|
54
68
|
if (control.activeChildren) {
|
|
55
69
|
for (const child of [...control.activeChildren.values()].sort((left, right) => left.index - right.index)) {
|
|
70
|
+
const modelThinking = formatModelThinking(child.model, child.thinking) || undefined;
|
|
56
71
|
entries.push({
|
|
57
72
|
key: `foreground-active:${control.runId}:${child.index}`,
|
|
58
73
|
agent: child.agent,
|
|
74
|
+
...(modelThinking ? { modelThinking } : {}),
|
|
59
75
|
description: child.description,
|
|
60
76
|
startedAt: child.startedAt,
|
|
61
77
|
tokens: child.tokens ?? 0,
|
|
@@ -63,9 +79,11 @@ export function collectFleetStatusEntries(state: SubagentState): FleetStatusEntr
|
|
|
63
79
|
}
|
|
64
80
|
continue;
|
|
65
81
|
}
|
|
82
|
+
const modelThinking = formatModelThinking(control.model, control.thinking) || undefined;
|
|
66
83
|
entries.push({
|
|
67
84
|
key: `foreground-active:${control.runId}:${control.currentIndex ?? 0}`,
|
|
68
85
|
agent: control.currentAgent ?? control.mode,
|
|
86
|
+
...(modelThinking ? { modelThinking } : {}),
|
|
69
87
|
description: control.description,
|
|
70
88
|
startedAt: control.startedAt,
|
|
71
89
|
tokens: control.tokens ?? 0,
|
|
@@ -96,10 +114,12 @@ export function collectFleetStatusEntries(state: SubagentState): FleetStatusEntr
|
|
|
96
114
|
if (!isActiveState(step.status)) continue;
|
|
97
115
|
const index = step.index ?? offset;
|
|
98
116
|
if (step.status === "pending" && job.mode === "chain" && !job.activeParallelGroup && index !== (job.currentStep ?? 0)) continue;
|
|
117
|
+
const modelThinking = formatModelThinking(step.model, step.thinking) || undefined;
|
|
99
118
|
entries.push({
|
|
100
119
|
key: `async:${job.asyncId}:${index}`,
|
|
101
120
|
agent: step.label ? `${step.label} (${step.agent})` : step.agent,
|
|
102
|
-
|
|
121
|
+
...(modelThinking ? { modelThinking } : {}),
|
|
122
|
+
description: step.description ?? job.description,
|
|
103
123
|
startedAt: step.startedAt ?? startedAt,
|
|
104
124
|
tokens: step.tokens?.total ?? (steps.length === 1 ? job.totalTokens?.total ?? 0 : 0),
|
|
105
125
|
});
|
|
@@ -111,6 +131,7 @@ export function collectFleetStatusEntries(state: SubagentState): FleetStatusEntr
|
|
|
111
131
|
|
|
112
132
|
export class SubagentFleetStatus {
|
|
113
133
|
private ctx: ExtensionContext | undefined;
|
|
134
|
+
private ui: ExtensionContext["ui"] | undefined;
|
|
114
135
|
private tui: FleetStatusTui | undefined;
|
|
115
136
|
private inputUnsubscribe: (() => void) | undefined;
|
|
116
137
|
private timer: ReturnType<typeof setInterval> | undefined;
|
|
@@ -124,6 +145,7 @@ export class SubagentFleetStatus {
|
|
|
124
145
|
private readonly openInspector: (itemKey: string) => Promise<void> | void;
|
|
125
146
|
private readonly refreshMs: number;
|
|
126
147
|
private readonly maxAgentRows: number;
|
|
148
|
+
private readonly placement: FleetViewPlacement;
|
|
127
149
|
|
|
128
150
|
constructor(
|
|
129
151
|
state: SubagentState,
|
|
@@ -134,19 +156,22 @@ export class SubagentFleetStatus {
|
|
|
134
156
|
this.openInspector = openInspector;
|
|
135
157
|
this.refreshMs = options.refreshMs ?? REFRESH_MS;
|
|
136
158
|
this.maxAgentRows = options.maxAgentRows ?? MAX_AGENT_ROWS;
|
|
159
|
+
this.placement = options.placement ?? "belowEditor";
|
|
137
160
|
}
|
|
138
161
|
|
|
139
162
|
setContext(ctx: ExtensionContext): void {
|
|
140
163
|
if (!ctx.hasUI) return;
|
|
141
|
-
|
|
164
|
+
const ui = ctx.ui;
|
|
165
|
+
if (this.ui === ui) {
|
|
142
166
|
this.ctx = ctx;
|
|
143
167
|
this.refresh();
|
|
144
168
|
return;
|
|
145
169
|
}
|
|
146
170
|
this.clearUiRegistration();
|
|
147
171
|
this.ctx = ctx;
|
|
148
|
-
|
|
149
|
-
|
|
172
|
+
this.ui = ui;
|
|
173
|
+
if (typeof ui.onTerminalInput === "function") {
|
|
174
|
+
this.inputUnsubscribe = ui.onTerminalInput((data) => this.handleKey(data));
|
|
150
175
|
}
|
|
151
176
|
this.timer = setInterval(() => this.refresh(), this.refreshMs);
|
|
152
177
|
this.timer.unref?.();
|
|
@@ -156,6 +181,7 @@ export class SubagentFleetStatus {
|
|
|
156
181
|
dispose(): void {
|
|
157
182
|
this.clearUiRegistration();
|
|
158
183
|
this.ctx = undefined;
|
|
184
|
+
this.ui = undefined;
|
|
159
185
|
this.entries = [];
|
|
160
186
|
this.active = false;
|
|
161
187
|
this.selectedKey = "main";
|
|
@@ -164,8 +190,8 @@ export class SubagentFleetStatus {
|
|
|
164
190
|
}
|
|
165
191
|
|
|
166
192
|
refresh(): void {
|
|
167
|
-
const ctx = this.
|
|
168
|
-
if (!ctx
|
|
193
|
+
const ctx = this.getActiveUiContext();
|
|
194
|
+
if (!ctx) return;
|
|
169
195
|
this.entries = collectFleetStatusEntries(this.state);
|
|
170
196
|
this.clampSelection();
|
|
171
197
|
if (this.inspectorOpen || this.state.fleetInspectorOpen) {
|
|
@@ -204,7 +230,7 @@ export class SubagentFleetStatus {
|
|
|
204
230
|
this.tui = undefined;
|
|
205
231
|
},
|
|
206
232
|
};
|
|
207
|
-
}, { placement:
|
|
233
|
+
}, { placement: this.placement });
|
|
208
234
|
this.widgetRegistered = true;
|
|
209
235
|
this.lastRenderKey = renderKey;
|
|
210
236
|
return;
|
|
@@ -215,8 +241,8 @@ export class SubagentFleetStatus {
|
|
|
215
241
|
}
|
|
216
242
|
|
|
217
243
|
handleKey(data: string): { consume?: boolean; data?: string } | undefined {
|
|
218
|
-
const ctx = this.
|
|
219
|
-
if (!ctx
|
|
244
|
+
const ctx = this.getActiveUiContext();
|
|
245
|
+
if (!ctx || this.entries.length === 0 || isKeyRelease(data)) return undefined;
|
|
220
246
|
if (this.inspectorOpen) return undefined;
|
|
221
247
|
if (!this.editorHasFocus()) {
|
|
222
248
|
if (this.active) this.deactivate();
|
|
@@ -234,12 +260,12 @@ export class SubagentFleetStatus {
|
|
|
234
260
|
|
|
235
261
|
const roster = this.rosterKeys();
|
|
236
262
|
const selectedIndex = Math.max(0, roster.indexOf(this.selectedKey));
|
|
237
|
-
if (matchesKey(data, "down")) {
|
|
263
|
+
if (matchesKey(data, "down") || matchesKey(data, "j")) {
|
|
238
264
|
this.selectedKey = roster[Math.min(roster.length - 1, selectedIndex + 1)] ?? "main";
|
|
239
265
|
this.refresh();
|
|
240
266
|
return { consume: true };
|
|
241
267
|
}
|
|
242
|
-
if (matchesKey(data, "up")) {
|
|
268
|
+
if (matchesKey(data, "up") || matchesKey(data, "k")) {
|
|
243
269
|
if (selectedIndex === 0) {
|
|
244
270
|
this.deactivate();
|
|
245
271
|
return { consume: true };
|
|
@@ -279,7 +305,7 @@ export class SubagentFleetStatus {
|
|
|
279
305
|
const roster = this.rosterKeys();
|
|
280
306
|
const selectedIndex = Math.max(0, roster.indexOf(this.selectedKey));
|
|
281
307
|
const hint = this.active
|
|
282
|
-
? "
|
|
308
|
+
? "↑↓/jk select · enter inspect · esc back"
|
|
283
309
|
: "esc to interrupt · ← for agents · ↓ to manage";
|
|
284
310
|
const lines = [truncateToWidth(` ${theme.fg("dim", hint)}`, width), ""];
|
|
285
311
|
lines.push(truncateToWidth(` ${this.bullet(0, selectedIndex, theme)} main`, width));
|
|
@@ -298,7 +324,8 @@ export class SubagentFleetStatus {
|
|
|
298
324
|
|
|
299
325
|
private renderEntry(rosterIndex: number, selectedIndex: number, entry: FleetStatusEntry, width: number, theme: Theme): string {
|
|
300
326
|
const description = entry.description?.replace(/\s+/g, " ").trim();
|
|
301
|
-
const
|
|
327
|
+
const agent = entry.modelThinking ? `${entry.agent} (${entry.modelThinking})` : entry.agent;
|
|
328
|
+
const left = ` ${this.bullet(rosterIndex, selectedIndex, theme)} ${theme.fg("muted", agent)}${description ? ` ${description}` : ""}`;
|
|
302
329
|
const elapsed = Date.now() - entry.startedAt;
|
|
303
330
|
const right = theme.fg("dim", `${formatFleetElapsed(elapsed)} · ${formatFleetTokens(entry.tokens)}`);
|
|
304
331
|
return rightAlign(left, right, width);
|
|
@@ -323,9 +350,16 @@ export class SubagentFleetStatus {
|
|
|
323
350
|
}
|
|
324
351
|
|
|
325
352
|
private editorHasFocus(): boolean {
|
|
326
|
-
// pi-tui exposes focus mutation but no focus getter
|
|
353
|
+
// pi-tui exposes focus mutation but no focus getter, so inspect the focused
|
|
354
|
+
// component structurally. instanceof is unreliable across jiti module boundaries.
|
|
327
355
|
const focused = (this.tui as unknown as { focusedComponent?: unknown } | undefined)?.focusedComponent;
|
|
328
|
-
|
|
356
|
+
if (!focused || typeof focused !== "object") return false;
|
|
357
|
+
const candidate = focused as Partial<EditorComponent>;
|
|
358
|
+
return typeof candidate.render === "function"
|
|
359
|
+
&& typeof candidate.invalidate === "function"
|
|
360
|
+
&& typeof candidate.handleInput === "function"
|
|
361
|
+
&& typeof candidate.getText === "function"
|
|
362
|
+
&& typeof candidate.setText === "function";
|
|
329
363
|
}
|
|
330
364
|
|
|
331
365
|
private getRenderKey(): string {
|
|
@@ -337,6 +371,7 @@ export class SubagentFleetStatus {
|
|
|
337
371
|
entries: this.entries.map((entry) => [
|
|
338
372
|
entry.key,
|
|
339
373
|
entry.agent,
|
|
374
|
+
entry.modelThinking,
|
|
340
375
|
entry.description,
|
|
341
376
|
Math.round((now - entry.startedAt) / 1000),
|
|
342
377
|
entry.tokens,
|
|
@@ -344,19 +379,47 @@ export class SubagentFleetStatus {
|
|
|
344
379
|
});
|
|
345
380
|
}
|
|
346
381
|
|
|
382
|
+
private getActiveUiContext(): ExtensionContext | undefined {
|
|
383
|
+
const ctx = this.ctx;
|
|
384
|
+
if (!ctx) return undefined;
|
|
385
|
+
try {
|
|
386
|
+
return ctx.hasUI ? ctx : undefined;
|
|
387
|
+
} catch (error) {
|
|
388
|
+
if (!isStaleExtensionContextError(error)) throw error;
|
|
389
|
+
this.clearUiRegistration();
|
|
390
|
+
return undefined;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
347
394
|
private clearUiRegistration(): void {
|
|
348
395
|
if (this.timer) clearInterval(this.timer);
|
|
349
396
|
this.timer = undefined;
|
|
350
|
-
|
|
397
|
+
|
|
398
|
+
const inputUnsubscribe = this.inputUnsubscribe;
|
|
399
|
+
const ui = this.ui;
|
|
400
|
+
const widgetRegistered = this.widgetRegistered;
|
|
351
401
|
this.inputUnsubscribe = undefined;
|
|
352
|
-
|
|
402
|
+
this.ctx = undefined;
|
|
403
|
+
this.ui = undefined;
|
|
404
|
+
this.widgetRegistered = false;
|
|
405
|
+
this.tui = undefined;
|
|
406
|
+
|
|
407
|
+
const cleanupErrors: unknown[] = [];
|
|
408
|
+
try {
|
|
409
|
+
inputUnsubscribe?.();
|
|
410
|
+
} catch (error) {
|
|
411
|
+
if (!isStaleExtensionContextError(error)) cleanupErrors.push(error);
|
|
412
|
+
}
|
|
413
|
+
if (ui && widgetRegistered) {
|
|
353
414
|
try {
|
|
354
|
-
|
|
355
|
-
} catch {
|
|
356
|
-
|
|
415
|
+
ui.setWidget(FLEET_STATUS_WIDGET_KEY, undefined);
|
|
416
|
+
} catch (error) {
|
|
417
|
+
if (!isStaleExtensionContextError(error)) cleanupErrors.push(error);
|
|
357
418
|
}
|
|
358
419
|
}
|
|
359
|
-
|
|
360
|
-
|
|
420
|
+
if (cleanupErrors.length === 1) throw cleanupErrors[0];
|
|
421
|
+
if (cleanupErrors.length > 1) {
|
|
422
|
+
throw new AggregateError(cleanupErrors, "Failed to clean up FleetView UI registration");
|
|
423
|
+
}
|
|
361
424
|
}
|
|
362
425
|
}
|