pi-crew 0.9.55 → 0.9.57
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/AGENTS.md +1 -1
- package/CHANGELOG.md +58 -0
- package/README.md +53 -5
- package/dist/index.mjs +5666 -4370
- package/docs/README.md +54 -0
- package/package.json +12 -13
- package/skills/real-test-pi-crew/SKILL.md +93 -3
- package/src/agents/discover-agents.ts +68 -10
- package/src/benchmark/feedback-loop.ts +1 -1
- package/src/config/config.ts +2 -1
- package/src/config/types.ts +12 -0
- package/src/extension/action-suggestions.ts +16 -63
- package/src/extension/async-notifier.ts +3 -3
- package/src/extension/command-completions.ts +2 -2
- package/src/extension/crew-cleanup.ts +3 -3
- package/src/extension/crew-vibes/footer.ts +4 -2
- package/src/extension/cross-extension-rpc.ts +10 -5
- package/src/extension/knowledge-injection.ts +57 -10
- package/src/extension/register.ts +2 -2
- package/src/extension/registration/artifact-cleanup.ts +41 -3
- package/src/extension/registration/commands.ts +4 -4
- package/src/extension/registration/context-builder.ts +10 -10
- package/src/extension/registration/crash-recovery-cache.ts +3 -3
- package/src/extension/registration/foreground-run-controller.ts +1 -1
- package/src/extension/registration/lazy-configurers.ts +2 -2
- package/src/extension/registration/lifecycle-handlers.ts +12 -12
- package/src/extension/registration/lifecycle.ts +2 -2
- package/src/extension/registration/observability.ts +2 -2
- package/src/extension/registration/registration-types.ts +3 -3
- package/src/extension/registration/runtime-cleanup.ts +1 -1
- package/src/extension/registration/subagent-helpers.ts +2 -2
- package/src/extension/registration/subagent-manager-setup.ts +2 -2
- package/src/extension/registration/subagent-tools.ts +21 -16
- package/src/extension/registration/team-tool.ts +109 -17
- package/src/extension/registration/viewers.ts +3 -4
- package/src/extension/registration/wire-cross-extension.ts +7 -7
- package/src/extension/rpc-hmac.ts +3 -2
- package/src/extension/run-bundle-schema.ts +13 -4
- package/src/extension/run-export.ts +2 -2
- package/src/extension/run-index.ts +2 -3
- package/src/extension/run-maintenance.ts +57 -1
- package/src/extension/team-manager-command.ts +3 -1
- package/src/extension/team-tool/anchor.ts +8 -2
- package/src/extension/team-tool/api.ts +117 -39
- package/src/extension/team-tool/cancel.ts +23 -8
- package/src/extension/team-tool/chain-executor.ts +1 -1
- package/src/extension/team-tool/dispatch/automate.ts +17 -2
- package/src/extension/team-tool/dispatch/control.ts +17 -2
- package/src/extension/team-tool/dispatch/manage.ts +34 -2
- package/src/extension/team-tool/dispatch/run.ts +17 -2
- package/src/extension/team-tool/dispatch/status.ts +37 -5
- package/src/extension/team-tool/doctor.ts +2 -2
- package/src/extension/team-tool/explain.ts +1 -1
- package/src/extension/team-tool/goal-wrap.ts +5 -5
- package/src/extension/team-tool/goal.ts +30 -9
- package/src/extension/team-tool/handle-schedule.ts +37 -19
- package/src/extension/team-tool/inspect.ts +21 -5
- package/src/extension/team-tool/lifecycle-actions.ts +53 -10
- package/src/extension/team-tool/parallel-dispatch.ts +14 -5
- package/src/extension/team-tool/param-error.ts +138 -0
- package/src/extension/team-tool/respond.ts +20 -6
- package/src/extension/team-tool/run.ts +27 -17
- package/src/extension/team-tool/status.ts +17 -6
- package/src/extension/team-tool.ts +26 -19
- package/src/hooks/registry.ts +1 -1
- package/src/i18n.ts +22 -0
- package/src/observability/event-bus.ts +1 -1
- package/src/prompt/prompt-runtime.ts +2 -2
- package/src/runtime/README.md +35 -0
- package/src/runtime/agent-control.ts +1 -1
- package/src/runtime/anchor-manager.ts +0 -2
- package/src/runtime/async-runner.ts +1 -1
- package/src/runtime/attention-events.ts +3 -2
- package/src/runtime/auto-summarize.ts +0 -2
- package/src/runtime/background-runner.ts +103 -30
- package/src/runtime/{crew-broker-child.ts → broker/crew-broker-child.ts} +2 -2
- package/src/runtime/{crew-broker-client.ts → broker/crew-broker-client.ts} +4 -7
- package/src/runtime/{crew-broker.ts → broker/crew-broker.ts} +13 -21
- package/src/runtime/chain-runner.ts +50 -5
- package/src/runtime/{child-pi-constants.ts → child-pi/child-pi-constants.ts} +1 -1
- package/src/runtime/{child-pi-kill.ts → child-pi/child-pi-kill.ts} +3 -3
- package/src/runtime/{child-pi-spawn.ts → child-pi/child-pi-spawn.ts} +28 -12
- package/src/runtime/{child-pi-steering.ts → child-pi/child-pi-steering.ts} +1 -1
- package/src/runtime/{child-pi-streams.ts → child-pi/child-pi-streams.ts} +23 -4
- package/src/runtime/{child-pi-transcript.ts → child-pi/child-pi-transcript.ts} +6 -6
- package/src/runtime/{child-pi.ts → child-pi/child-pi.ts} +47 -78
- package/src/runtime/compaction/compact-stages/bounded-tail.ts +84 -0
- package/src/runtime/{compact-stages → compaction/compact-stages}/index.ts +2 -2
- package/src/runtime/{compaction-summary.ts → compaction/compaction-summary.ts} +3 -3
- package/src/runtime/{tool-output-pruner.ts → compaction/tool-output-pruner.ts} +1 -1
- package/src/runtime/crew-agent-records.ts +48 -2
- package/src/runtime/custom-tools/irc-tool.ts +2 -2
- package/src/runtime/delivery-coordinator.ts +0 -3
- package/src/runtime/diagnostic-export.ts +5 -4
- package/src/runtime/foreground-control.ts +1 -1
- package/src/runtime/foreground-watchdog.ts +1 -1
- package/src/runtime/{adaptive-plan.ts → goal-workflow/adaptive-plan.ts} +8 -8
- package/src/runtime/{dynamic-workflow-context.ts → goal-workflow/dynamic-workflow-context.ts} +16 -16
- package/src/runtime/{dynamic-workflow-runner.ts → goal-workflow/dynamic-workflow-runner.ts} +10 -10
- package/src/runtime/{goal-achievement.ts → goal-workflow/goal-achievement.ts} +3 -3
- package/src/runtime/{goal-evaluator.ts → goal-workflow/goal-evaluator.ts} +8 -8
- package/src/runtime/{goal-loop-runner.ts → goal-workflow/goal-loop-runner.ts} +27 -25
- package/src/runtime/{goal-state-store.ts → goal-workflow/goal-state-store.ts} +8 -8
- package/src/runtime/{plan-templates.ts → goal-workflow/plan-templates.ts} +1 -1
- package/src/runtime/group-join.ts +3 -3
- package/src/runtime/handoff-manager.ts +0 -2
- package/src/runtime/{heartbeat-watcher.ts → heartbeat/heartbeat-watcher.ts} +7 -7
- package/src/runtime/iteration-hooks.ts +1 -1
- package/src/runtime/{live-agent-control.ts → live-session/live-agent-control.ts} +2 -2
- package/src/runtime/{live-agent-manager.ts → live-session/live-agent-manager.ts} +4 -4
- package/src/runtime/{live-session-runtime.ts → live-session/live-session-runtime.ts} +39 -41
- package/src/runtime/manifest-cache.ts +6 -2
- package/src/runtime/{model-fallback.ts → model/model-fallback.ts} +1 -1
- package/src/runtime/{pi-args.ts → model/pi-args.ts} +20 -5
- package/src/runtime/model/provider-extensions.ts +116 -0
- package/src/runtime/{runtime-policy.ts → model/runtime-policy.ts} +2 -2
- package/src/runtime/{runtime-resolver.ts → model/runtime-resolver.ts} +3 -3
- package/src/runtime/{runtime-warmup.ts → model/runtime-warmup.ts} +8 -8
- package/src/runtime/orphan-worker-registry.ts +1 -1
- package/src/runtime/{progress-tracker.ts → output/progress-tracker.ts} +1 -1
- package/src/runtime/{result-extractor.ts → output/result-extractor.ts} +4 -4
- package/src/runtime/{sidechain-output.ts → output/sidechain-output.ts} +2 -2
- package/src/runtime/{stream-preview.ts → output/stream-preview.ts} +1 -1
- package/src/runtime/{streaming-output.ts → output/streaming-output.ts} +2 -2
- package/src/runtime/{tool-progress.ts → output/tool-progress.ts} +1 -1
- package/src/runtime/parent-guard.ts +30 -10
- package/src/runtime/pipeline-runner.ts +2 -2
- package/src/runtime/policy-engine.ts +2 -2
- package/src/runtime/{cancellation.ts → process/cancellation.ts} +1 -1
- package/src/runtime/{post-exit-stdio-guard.ts → process/post-exit-stdio-guard.ts} +1 -1
- package/src/runtime/{process-lifecycle.ts → process/process-lifecycle.ts} +3 -3
- package/src/runtime/{checkpoint.ts → recovery/checkpoint.ts} +4 -4
- package/src/runtime/{crash-recovery.ts → recovery/crash-recovery.ts} +93 -21
- package/src/runtime/{overflow-recovery.ts → recovery/overflow-recovery.ts} +1 -1
- package/src/runtime/{recovery-recipes.ts → recovery/recovery-recipes.ts} +1 -1
- package/src/runtime/{retry-executor.ts → recovery/retry-executor.ts} +2 -2
- package/src/runtime/{retry-runner.ts → recovery/retry-runner.ts} +2 -8
- package/src/runtime/run-tracker.ts +1 -1
- package/src/runtime/run-worker.ts +3 -3
- package/src/runtime/{coalesce-tasks.ts → scheduling/coalesce-tasks.ts} +3 -3
- package/src/runtime/{concurrency.ts → scheduling/concurrency.ts} +9 -3
- package/src/runtime/{parallel-research.ts → scheduling/parallel-research.ts} +4 -2
- package/src/runtime/{run-coalesced-task-group.ts → scheduling/run-coalesced-task-group.ts} +95 -36
- package/src/runtime/{semaphore.ts → scheduling/semaphore.ts} +4 -1
- package/src/runtime/{task-graph-scheduler.ts → scheduling/task-graph-scheduler.ts} +1 -1
- package/src/runtime/session-resources.ts +1 -1
- package/src/runtime/settings-store.ts +1 -1
- package/src/runtime/single-agent-compose.ts +1 -0
- package/src/runtime/stale-reconciler.ts +1 -1
- package/src/runtime/subagent-manager.ts +1 -1
- package/src/runtime/supervisor-contact.ts +28 -13
- package/src/runtime/task-output-context.ts +7 -5
- package/src/runtime/task-runner/child-executor.ts +67 -31
- package/src/runtime/task-runner/live-executor.ts +8 -8
- package/src/runtime/task-runner/post-execution.ts +12 -12
- package/src/runtime/task-runner/pre-execution.ts +6 -6
- package/src/runtime/task-runner/progress.ts +1 -1
- package/src/runtime/task-runner/run-projection.ts +1 -1
- package/src/runtime/task-runner/scaffold-executor.ts +1 -1
- package/src/runtime/task-runner/state-helpers.ts +2 -2
- package/src/runtime/task-runner.ts +4 -4
- package/src/runtime/team-runner.ts +441 -175
- package/src/runtime/{completion-guard.ts → verification/completion-guard.ts} +1 -1
- package/src/runtime/{green-contract.ts → verification/green-contract.ts} +1 -1
- package/src/runtime/{post-checks.ts → verification/post-checks.ts} +4 -4
- package/src/runtime/{verification-gates.ts → verification/verification-gates.ts} +5 -5
- package/src/runtime/{verification-integrity.ts → verification/verification-integrity.ts} +1 -1
- package/src/schema/config-schema.ts +1 -0
- package/src/schema/team-tool-schema.ts +149 -185
- package/src/state/README.md +44 -0
- package/src/state/atomic-write.ts +24 -3
- package/src/state/{locks.ts → coordination/locks.ts} +118 -38
- package/src/state/{mailbox.ts → coordination/mailbox.ts} +14 -8
- package/src/state/{schedule.ts → coordination/schedule.ts} +3 -3
- package/src/state/{task-claims.ts → coordination/task-claims.ts} +1 -1
- package/src/state/decision-ledger.ts +1 -1
- package/src/state/{event-log-rotation.ts → event-log/event-log-rotation.ts} +189 -31
- package/src/state/{event-log.ts → event-log/event-log.ts} +77 -39
- package/src/state/{jsonl-writer.ts → event-log/jsonl-writer.ts} +14 -6
- package/src/state/hook-instinct-bridge.ts +2 -2
- package/src/state/{active-run-registry.ts → stores/active-run-registry.ts} +7 -7
- package/src/state/{artifact-store.ts → stores/artifact-store.ts} +62 -4
- package/src/state/{blob-store.ts → stores/blob-store.ts} +3 -3
- package/src/state/{health-store.ts → stores/health-store.ts} +3 -3
- package/src/state/{instinct-store.ts → stores/instinct-store.ts} +3 -3
- package/src/state/{observation-store.ts → stores/observation-store.ts} +2 -2
- package/src/state/{run-cache.ts → stores/run-cache.ts} +4 -4
- package/src/state/{run-graph.ts → stores/run-graph.ts} +4 -4
- package/src/state/{run-metrics.ts → stores/run-metrics.ts} +3 -3
- package/src/state/{state-store.ts → stores/state-store.ts} +254 -21
- package/src/state/types.ts +27 -3
- package/src/ui/component.ts +55 -0
- package/src/ui/crew-select-list.ts +3 -1
- package/src/ui/dashboard-panes/agents-pane.ts +1 -1
- package/src/ui/dwf-phase-display.ts +1 -1
- package/src/ui/heartbeat-aggregator.ts +1 -1
- package/src/ui/keybinding-map.ts +179 -6
- package/src/ui/layout-primitives.ts +9 -5
- package/src/ui/live-conversation-overlay.ts +1 -1
- package/src/ui/live-run-sidebar.ts +1 -1
- package/src/ui/overlay-stack.ts +148 -0
- package/src/ui/overlays/agent-picker-overlay.ts +1 -1
- package/src/ui/overlays/mailbox-compose-overlay.ts +1 -1
- package/src/ui/overlays/mailbox-detail-overlay.ts +2 -2
- package/src/ui/powerbar-publisher.ts +1 -1
- package/src/ui/render-scheduler.ts +1 -1
- package/src/ui/run-action-dispatcher.ts +3 -3
- package/src/ui/run-dashboard.ts +5 -33
- package/src/ui/run-event-bus.ts +3 -3
- package/src/ui/run-snapshot-cache.ts +37 -18
- package/src/ui/settings-overlay.ts +13 -21
- package/src/ui/snapshot-types.ts +1 -1
- package/src/ui/status-colors.ts +0 -2
- package/src/ui/terminal-status.ts +1 -1
- package/src/ui/theme-adapter.ts +33 -13
- package/src/ui/tool-renderers/index.ts +8 -0
- package/src/ui/transcript-viewer.ts +37 -13
- package/src/ui/widget/index.ts +32 -9
- package/src/ui/widget/widget-formatters.ts +62 -4
- package/src/ui/widget/widget-model.ts +2 -2
- package/src/ui/widget/widget-renderer.ts +1 -1
- package/src/utils/conflict-detect.ts +58 -5
- package/src/utils/ndjson.ts +2 -2
- package/src/utils/redaction.ts +39 -0
- package/src/utils/socket-path.ts +1 -1
- package/src/workflows/workflow-config.ts +1 -1
- package/src/worktree/cleanup.ts +1 -1
- package/src/worktree/worktree-manager.ts +111 -47
- package/workflows/chain.workflow.md +2 -2
- package/dist/build-meta.json +0 -16807
- package/index.bundle.ts +0 -25
- package/scripts/bench-check.mjs +0 -96
- package/scripts/bench-cold-start.mjs +0 -216
- package/scripts/build-bundle.mjs +0 -92
- package/scripts/check-all-skills.ts +0 -294
- package/scripts/check-bundle-size.mjs +0 -38
- package/scripts/check-bundle-staleness.mjs +0 -97
- package/scripts/check-conflict-markers.mjs +0 -91
- package/scripts/check-lazy-imports.mjs +0 -28
- package/scripts/dev-runner.mjs +0 -106
- package/scripts/profile-startup.mjs +0 -125
- package/scripts/release-smoke.mjs +0 -74
- package/scripts/run-bench.mjs +0 -47
- package/scripts/run-real-chain.ts +0 -41
- package/scripts/test-issue-29-crash.ts +0 -111
- package/scripts/test-issue-29-e2e.ts +0 -183
- package/scripts/test-issue-29-real-runtime.ts +0 -330
- package/scripts/test-issue-29-real-tasks.ts +0 -387
- package/scripts/test-issue-29-team-tool.ts +0 -105
- package/scripts/test-runner.mjs +0 -84
- package/scripts/verify-flicker-fix.ts +0 -109
- package/scripts/verify-skill.ts +0 -550
- package/scripts/watch-bundle.mjs +0 -259
- package/scripts/watchdog-harness.ts +0 -119
- package/src/adapters/claude-adapter.ts +0 -23
- package/src/adapters/codex-adapter.ts +0 -21
- package/src/adapters/cursor-adapter.ts +0 -17
- package/src/adapters/export-util.ts +0 -143
- package/src/adapters/index.ts +0 -15
- package/src/adapters/registry.ts +0 -18
- package/src/adapters/types.ts +0 -23
- package/src/runtime/code-summary.ts +0 -292
- package/src/runtime/cross-extension-rpc.ts +0 -143
- package/src/runtime/hidden-handoff.ts +0 -407
- package/src/runtime/prose-compressor.ts +0 -162
- package/src/subagents/async-entry.ts +0 -1
- package/src/subagents/index.ts +0 -3
- package/src/subagents/live/control.ts +0 -1
- package/src/subagents/live/manager.ts +0 -1
- package/src/subagents/live/realtime.ts +0 -1
- package/src/subagents/live/session-runtime.ts +0 -1
- package/src/subagents/manager.ts +0 -1
- package/src/subagents/spawn.ts +0 -1
- package/test-integration-check.ts +0 -118
- /package/src/runtime/{broker-issuer.ts → broker/broker-issuer.ts} +0 -0
- /package/src/runtime/{crew-broker-tokens.ts → broker/crew-broker-tokens.ts} +0 -0
- /package/src/runtime/{child-pi-pool.ts → child-pi/child-pi-pool.ts} +0 -0
- /package/src/runtime/{compact-pipeline.ts → compaction/compact-pipeline.ts} +0 -0
- /package/src/runtime/{compact-stages → compaction/compact-stages}/ansi-strip-stage.ts +0 -0
- /package/src/runtime/{compact-stages → compaction/compact-stages}/blank-collapse-stage.ts +0 -0
- /package/src/runtime/{compact-stages → compaction/compact-stages}/deduplicate-stage.ts +0 -0
- /package/src/runtime/{compact-stages → compaction/compact-stages}/head-snap-stage.ts +0 -0
- /package/src/runtime/{compact-stages → compaction/compact-stages}/tail-capture-stage.ts +0 -0
- /package/src/runtime/{compact-stages → compaction/compact-stages}/truncation-stage.ts +0 -0
- /package/src/runtime/{important-line-classifier.ts → compaction/important-line-classifier.ts} +0 -0
- /package/src/runtime/{heartbeat-gradient.ts → heartbeat/heartbeat-gradient.ts} +0 -0
- /package/src/runtime/{worker-heartbeat.ts → heartbeat/worker-heartbeat.ts} +0 -0
- /package/src/runtime/{worker-startup.ts → heartbeat/worker-startup.ts} +0 -0
- /package/src/runtime/{intercom-bridge.ts → live-session/intercom-bridge.ts} +0 -0
- /package/src/runtime/{live-control-realtime.ts → live-session/live-control-realtime.ts} +0 -0
- /package/src/runtime/{live-extension-bridge.ts → live-session/live-extension-bridge.ts} +0 -0
- /package/src/runtime/{live-irc.ts → live-session/live-irc.ts} +0 -0
- /package/src/runtime/{live-session-health.ts → live-session/live-session-health.ts} +0 -0
- /package/src/runtime/{model-resolver.ts → model/model-resolver.ts} +0 -0
- /package/src/runtime/{model-scope.ts → model/model-scope.ts} +0 -0
- /package/src/runtime/{output-validator.ts → output/output-validator.ts} +0 -0
- /package/src/runtime/{pi-json-output.ts → output/pi-json-output.ts} +0 -0
- /package/src/runtime/{progress-event-coalescer.ts → output/progress-event-coalescer.ts} +0 -0
- /package/src/runtime/{cancellation-token.ts → process/cancellation-token.ts} +0 -0
- /package/src/runtime/{zombie-scanner.ts → process/zombie-scanner.ts} +0 -0
- /package/src/runtime/{crash-classification.ts → recovery/crash-classification.ts} +0 -0
- /package/src/runtime/{batch-barrier.ts → scheduling/batch-barrier.ts} +0 -0
- /package/src/runtime/{global-worker-cap.ts → scheduling/global-worker-cap.ts} +0 -0
- /package/src/runtime/{parallel-utils.ts → scheduling/parallel-utils.ts} +0 -0
- /package/src/runtime/{scheduler.ts → scheduling/scheduler.ts} +0 -0
- /package/src/runtime/{task-graph.ts → scheduling/task-graph.ts} +0 -0
- /package/src/runtime/{verification-worktree.ts → verification/verification-worktree.ts} +0 -0
- /package/src/state/{event-reconstructor.ts → event-log/event-reconstructor.ts} +0 -0
- /package/src/state/{worker-atomic-writer.ts → event-log/worker-atomic-writer.ts} +0 -0
|
@@ -4,14 +4,24 @@ import { buildAgentDashboard, readAgentOutput } from "../../runtime/agent-observ
|
|
|
4
4
|
import { buildCapabilityInventory } from "../../runtime/capability-inventory.ts";
|
|
5
5
|
import { agentOutputPath, readCrewAgentEventsCursor, readCrewAgentStatus, readCrewAgents } from "../../runtime/crew-agent-records.ts";
|
|
6
6
|
import { readForegroundControlStatus, writeForegroundInterruptRequest } from "../../runtime/foreground-control.ts";
|
|
7
|
-
import {
|
|
7
|
+
import { touchWorkerHeartbeat } from "../../runtime/heartbeat/worker-heartbeat.ts";
|
|
8
|
+
import { appendLiveAgentControlRequest } from "../../runtime/live-session/live-agent-control.ts";
|
|
9
|
+
import {
|
|
10
|
+
followUpLiveAgent,
|
|
11
|
+
getLiveAgent,
|
|
12
|
+
listActiveLiveAgents,
|
|
13
|
+
resumeLiveAgent,
|
|
14
|
+
steerLiveAgent,
|
|
15
|
+
stopLiveAgent,
|
|
16
|
+
terminateLiveAgentsForRun,
|
|
17
|
+
} from "../../runtime/live-session/live-agent-manager.ts";
|
|
18
|
+
import { liveControlRealtimeMessage, publishLiveControlRealtime } from "../../runtime/live-session/live-control-realtime.ts";
|
|
19
|
+
import { probeLiveSessionRuntime } from "../../runtime/live-session/live-session-runtime.ts";
|
|
20
|
+
import { resolveCrewRuntime } from "../../runtime/model/runtime-resolver.ts";
|
|
8
21
|
import { currentCrewRole, permissionForRole } from "../../runtime/role-permission.ts";
|
|
9
|
-
import { resolveCrewRuntime } from "../../runtime/runtime-resolver.ts";
|
|
10
|
-
import { touchWorkerHeartbeat } from "../../runtime/worker-heartbeat.ts";
|
|
11
22
|
import type { TeamToolParamsValue } from "../../schema/team-tool-schema.ts";
|
|
12
23
|
import { canTransitionTaskStatus, isTeamTaskStatus } from "../../state/contracts.ts";
|
|
13
|
-
import {
|
|
14
|
-
import { withRunLock, withRunLockSync } from "../../state/locks.ts";
|
|
24
|
+
import { withRunLock, withRunLockSync } from "../../state/coordination/locks.ts";
|
|
15
25
|
import {
|
|
16
26
|
acknowledgeMailboxMessage,
|
|
17
27
|
appendFollowUpMessage,
|
|
@@ -25,25 +35,16 @@ import {
|
|
|
25
35
|
readMailbox,
|
|
26
36
|
readMailboxMessage,
|
|
27
37
|
validateMailbox,
|
|
28
|
-
} from "../../state/mailbox.ts";
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
followUpLiveAgent,
|
|
34
|
-
getLiveAgent,
|
|
35
|
-
listActiveLiveAgents,
|
|
36
|
-
resumeLiveAgent,
|
|
37
|
-
steerLiveAgent,
|
|
38
|
-
stopLiveAgent,
|
|
39
|
-
} from "../../subagents/live/manager.ts";
|
|
40
|
-
import { liveControlRealtimeMessage, publishLiveControlRealtime } from "../../subagents/live/realtime.ts";
|
|
41
|
-
import { probeLiveSessionRuntime } from "../../subagents/live/session-runtime.ts";
|
|
38
|
+
} from "../../state/coordination/mailbox.ts";
|
|
39
|
+
import { claimTask, releaseTaskClaim, transitionClaimedTaskStatus } from "../../state/coordination/task-claims.ts";
|
|
40
|
+
import { appendEvent, readEvents, readEventsCursor } from "../../state/event-log/event-log.ts";
|
|
41
|
+
import { loadRunManifestById, saveRunManifestAsync, saveRunTasks, updateRunStatus } from "../../state/stores/state-store.ts";
|
|
42
42
|
import { logInternalError } from "../../utils/internal-error.ts";
|
|
43
43
|
import { resolveRealContainedPath } from "../../utils/safe-paths.ts";
|
|
44
44
|
import { locateRunCwd } from "../team-tool.ts";
|
|
45
45
|
import type { PiTeamsToolResult } from "../tool-result.ts";
|
|
46
46
|
import { configRecord, result, type TeamContext } from "./context.ts";
|
|
47
|
+
import { paramRequired } from "./param-error.ts";
|
|
47
48
|
import { RUN_NOT_FOUND_HINT } from "./run-not-found.ts";
|
|
48
49
|
|
|
49
50
|
export function globMatch(value: string, pattern: string): boolean {
|
|
@@ -121,7 +122,8 @@ export async function handleApi(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
121
122
|
status: "ok",
|
|
122
123
|
});
|
|
123
124
|
}
|
|
124
|
-
if (!params.runId)
|
|
125
|
+
if (!params.runId)
|
|
126
|
+
return result(paramRequired("api", "runId", "{ action: 'api', runId: 'team_...' }"), { action: "api", status: "error" }, true);
|
|
125
127
|
const runCwd = locateRunCwd(params.runId, ctx.cwd);
|
|
126
128
|
if (!runCwd) return result(`Run '${params.runId}' not found.${RUN_NOT_FOUND_HINT}`, { action: "api", status: "error" }, true);
|
|
127
129
|
const loaded = loadRunManifestById(runCwd, params.runId); // NOTE: no withRunLock - best-effort only; concurrent writes may cause inconsistency
|
|
@@ -302,7 +304,11 @@ export async function handleApi(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
302
304
|
const task = loaded.tasks.find((item) => item.id === taskId || item.stepId === taskId);
|
|
303
305
|
if (!task)
|
|
304
306
|
return result(
|
|
305
|
-
|
|
307
|
+
paramRequired(
|
|
308
|
+
"API read-task",
|
|
309
|
+
"config.taskId matching a task id or step id",
|
|
310
|
+
"{ action: 'api', runId: 'team_...', config: { operation: 'read-task', taskId: '01_01-agent' } }",
|
|
311
|
+
),
|
|
306
312
|
{
|
|
307
313
|
action: "api",
|
|
308
314
|
status: "error",
|
|
@@ -368,7 +374,11 @@ export async function handleApi(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
368
374
|
const agent = readCrewAgents(loaded.manifest).find((item) => item.id === agentId || item.taskId === agentId);
|
|
369
375
|
if (!agent)
|
|
370
376
|
return result(
|
|
371
|
-
|
|
377
|
+
paramRequired(
|
|
378
|
+
"API get-agent-result",
|
|
379
|
+
"config.agentId matching an agent id or task id",
|
|
380
|
+
"{ action: 'api', runId: 'team_...', config: { operation: 'get-agent-result', agentId: 'agent-1' } }",
|
|
381
|
+
),
|
|
372
382
|
{
|
|
373
383
|
action: "api",
|
|
374
384
|
status: "error",
|
|
@@ -391,7 +401,11 @@ export async function handleApi(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
391
401
|
const status = agent ? (readCrewAgentStatus(loaded.manifest, agent.taskId) ?? agent) : undefined;
|
|
392
402
|
if (!status)
|
|
393
403
|
return result(
|
|
394
|
-
|
|
404
|
+
paramRequired(
|
|
405
|
+
"API read-agent-status",
|
|
406
|
+
"config.agentId matching an agent id or task id",
|
|
407
|
+
"{ action: 'api', runId: 'team_...', config: { operation: 'read-agent-status', agentId: 'agent-1' } }",
|
|
408
|
+
),
|
|
395
409
|
{
|
|
396
410
|
action: "api",
|
|
397
411
|
status: "error",
|
|
@@ -412,7 +426,11 @@ export async function handleApi(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
412
426
|
const agent = agentId ? agents.find((item) => item.id === agentId || item.taskId === agentId) : agents[0];
|
|
413
427
|
if (!agent)
|
|
414
428
|
return result(
|
|
415
|
-
|
|
429
|
+
paramRequired(
|
|
430
|
+
"API read-agent-events",
|
|
431
|
+
"config.agentId matching an agent id or task id, or at least one agent in the run",
|
|
432
|
+
"{ action: 'api', runId: 'team_...', config: { operation: 'read-agent-events', agentId: 'agent-1' } }",
|
|
433
|
+
),
|
|
416
434
|
{
|
|
417
435
|
action: "api",
|
|
418
436
|
status: "error",
|
|
@@ -438,7 +456,11 @@ export async function handleApi(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
438
456
|
const agent = agentId ? agents.find((item) => item.id === agentId || item.taskId === agentId) : agents[0];
|
|
439
457
|
if (!agent)
|
|
440
458
|
return result(
|
|
441
|
-
|
|
459
|
+
paramRequired(
|
|
460
|
+
"API read-agent-transcript",
|
|
461
|
+
"config.agentId matching an agent id or task id, or at least one agent in the run",
|
|
462
|
+
"{ action: 'api', runId: 'team_...', config: { operation: 'read-agent-transcript', agentId: 'agent-1' } }",
|
|
463
|
+
),
|
|
442
464
|
{
|
|
443
465
|
action: "api",
|
|
444
466
|
status: "error",
|
|
@@ -467,7 +489,11 @@ export async function handleApi(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
467
489
|
const agent = agentId ? agents.find((item) => item.id === agentId || item.taskId === agentId) : agents[0];
|
|
468
490
|
if (!agent)
|
|
469
491
|
return result(
|
|
470
|
-
|
|
492
|
+
paramRequired(
|
|
493
|
+
"API read-agent-output",
|
|
494
|
+
"config.agentId matching an agent id or task id, or at least one agent in the run",
|
|
495
|
+
"{ action: 'api', runId: 'team_...', config: { operation: 'read-agent-output', agentId: 'agent-1' } }",
|
|
496
|
+
),
|
|
471
497
|
{
|
|
472
498
|
action: "api",
|
|
473
499
|
status: "error",
|
|
@@ -513,7 +539,11 @@ export async function handleApi(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
513
539
|
const agent = readCrewAgents(loaded.manifest).find((item) => item.id === agentId || item.taskId === agentId);
|
|
514
540
|
if (!agent)
|
|
515
541
|
return result(
|
|
516
|
-
|
|
542
|
+
paramRequired(
|
|
543
|
+
"API nudge-agent",
|
|
544
|
+
"config.agentId matching an agent id or task id",
|
|
545
|
+
"{ action: 'api', runId: 'team_...', config: { operation: 'nudge-agent', agentId: 'agent-1' } }",
|
|
546
|
+
),
|
|
517
547
|
{
|
|
518
548
|
action: "api",
|
|
519
549
|
status: "error",
|
|
@@ -580,7 +610,11 @@ export async function handleApi(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
580
610
|
const agentId = typeof cfg.agentId === "string" ? cfg.agentId : undefined;
|
|
581
611
|
if (!agentId)
|
|
582
612
|
return result(
|
|
583
|
-
|
|
613
|
+
paramRequired(
|
|
614
|
+
`API ${operation}`,
|
|
615
|
+
"config.agentId",
|
|
616
|
+
`{ action: 'api', runId: 'team_...', config: { operation: '${operation}', agentId: 'agent-1' } }`,
|
|
617
|
+
),
|
|
584
618
|
{
|
|
585
619
|
action: "api",
|
|
586
620
|
status: "error",
|
|
@@ -637,7 +671,11 @@ export async function handleApi(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
637
671
|
if (operation === "follow-up-agent") {
|
|
638
672
|
if (!prompt)
|
|
639
673
|
return result(
|
|
640
|
-
|
|
674
|
+
paramRequired(
|
|
675
|
+
"API follow-up-agent",
|
|
676
|
+
"config.prompt or config.message",
|
|
677
|
+
"{ action: 'api', runId: 'team_...', config: { operation: 'follow-up-agent', agentId: 'agent-1', prompt: '<next step>' } }",
|
|
678
|
+
),
|
|
641
679
|
{
|
|
642
680
|
action: "api",
|
|
643
681
|
status: "error",
|
|
@@ -662,7 +700,11 @@ export async function handleApi(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
662
700
|
if (operation === "resume-agent") {
|
|
663
701
|
if (!prompt)
|
|
664
702
|
return result(
|
|
665
|
-
|
|
703
|
+
paramRequired(
|
|
704
|
+
"API resume-agent",
|
|
705
|
+
"config.prompt or config.message",
|
|
706
|
+
"{ action: 'api', runId: 'team_...', config: { operation: 'resume-agent', agentId: 'agent-1', prompt: '<resume instruction>' } }",
|
|
707
|
+
),
|
|
666
708
|
{
|
|
667
709
|
action: "api",
|
|
668
710
|
status: "error",
|
|
@@ -710,7 +752,11 @@ export async function handleApi(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
710
752
|
);
|
|
711
753
|
if (operation === "resume-agent" && !prompt)
|
|
712
754
|
return result(
|
|
713
|
-
|
|
755
|
+
paramRequired(
|
|
756
|
+
"API resume-agent",
|
|
757
|
+
"config.prompt or config.message",
|
|
758
|
+
"{ action: 'api', runId: 'team_...', config: { operation: 'resume-agent', agentId: 'agent-1', prompt: '<resume instruction>' } }",
|
|
759
|
+
),
|
|
714
760
|
{
|
|
715
761
|
action: "api",
|
|
716
762
|
status: "error",
|
|
@@ -720,7 +766,11 @@ export async function handleApi(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
720
766
|
);
|
|
721
767
|
if (operation === "follow-up-agent" && !prompt)
|
|
722
768
|
return result(
|
|
723
|
-
|
|
769
|
+
paramRequired(
|
|
770
|
+
"API follow-up-agent",
|
|
771
|
+
"config.prompt or config.message",
|
|
772
|
+
"{ action: 'api', runId: 'team_...', config: { operation: 'follow-up-agent', agentId: 'agent-1', prompt: '<next step>' } }",
|
|
773
|
+
),
|
|
724
774
|
{
|
|
725
775
|
action: "api",
|
|
726
776
|
status: "error",
|
|
@@ -867,7 +917,11 @@ export async function handleApi(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
867
917
|
const taskId = typeof cfg.taskId === "string" && cfg.taskId.trim() ? cfg.taskId.trim() : undefined;
|
|
868
918
|
if (!body)
|
|
869
919
|
return result(
|
|
870
|
-
|
|
920
|
+
paramRequired(
|
|
921
|
+
"API send-message",
|
|
922
|
+
"config.body",
|
|
923
|
+
"{ action: 'api', runId: 'team_...', config: { operation: 'send-message', body: '<message>' } }",
|
|
924
|
+
),
|
|
871
925
|
{
|
|
872
926
|
action: "api",
|
|
873
927
|
status: "error",
|
|
@@ -932,7 +986,11 @@ export async function handleApi(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
932
986
|
const messageId = typeof cfg.messageId === "string" ? cfg.messageId : undefined;
|
|
933
987
|
if (!messageId)
|
|
934
988
|
return result(
|
|
935
|
-
|
|
989
|
+
paramRequired(
|
|
990
|
+
"API ack-message",
|
|
991
|
+
"config.messageId",
|
|
992
|
+
"{ action: 'api', runId: 'team_...', config: { operation: 'ack-message', messageId: 'msg-1' } }",
|
|
993
|
+
),
|
|
936
994
|
{
|
|
937
995
|
action: "api",
|
|
938
996
|
status: "error",
|
|
@@ -995,7 +1053,11 @@ export async function handleApi(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
995
1053
|
const task = loaded.tasks.find((item) => item.id === taskId || item.stepId === taskId);
|
|
996
1054
|
if (!task)
|
|
997
1055
|
return result(
|
|
998
|
-
|
|
1056
|
+
paramRequired(
|
|
1057
|
+
"API read-heartbeat",
|
|
1058
|
+
"config.taskId matching a task id or step id",
|
|
1059
|
+
"{ action: 'api', runId: 'team_...', config: { operation: 'read-heartbeat', taskId: '01_01-agent' } }",
|
|
1060
|
+
),
|
|
999
1061
|
{
|
|
1000
1062
|
action: "api",
|
|
1001
1063
|
status: "error",
|
|
@@ -1016,7 +1078,11 @@ export async function handleApi(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
1016
1078
|
const task = loaded.tasks.find((item) => item.id === taskId || item.stepId === taskId);
|
|
1017
1079
|
if (!task)
|
|
1018
1080
|
return result(
|
|
1019
|
-
|
|
1081
|
+
paramRequired(
|
|
1082
|
+
"API claim-task",
|
|
1083
|
+
"config.taskId matching a task id or step id",
|
|
1084
|
+
"{ action: 'api', runId: 'team_...', config: { operation: 'claim-task', taskId: '01_01-agent' } }",
|
|
1085
|
+
),
|
|
1020
1086
|
{
|
|
1021
1087
|
action: "api",
|
|
1022
1088
|
status: "error",
|
|
@@ -1066,7 +1132,11 @@ export async function handleApi(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
1066
1132
|
const task = loaded.tasks.find((item) => item.id === taskId || item.stepId === taskId);
|
|
1067
1133
|
if (!task || !owner || !token)
|
|
1068
1134
|
return result(
|
|
1069
|
-
|
|
1135
|
+
paramRequired(
|
|
1136
|
+
"API release-task-claim",
|
|
1137
|
+
"config.taskId, config.owner, and config.token",
|
|
1138
|
+
"{ action: 'api', runId: 'team_...', config: { operation: 'release-task-claim', taskId: '01_01-agent', owner: 'worker-1', token: 'tok-1' } }",
|
|
1139
|
+
),
|
|
1070
1140
|
{
|
|
1071
1141
|
action: "api",
|
|
1072
1142
|
status: "error",
|
|
@@ -1113,7 +1183,11 @@ export async function handleApi(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
1113
1183
|
const task = loaded.tasks.find((item) => item.id === taskId || item.stepId === taskId);
|
|
1114
1184
|
if (!task || !owner || !token || !isTeamTaskStatus(to))
|
|
1115
1185
|
return result(
|
|
1116
|
-
|
|
1186
|
+
paramRequired(
|
|
1187
|
+
"API transition-task-status",
|
|
1188
|
+
"config.taskId, config.owner, config.token, and valid config.status",
|
|
1189
|
+
"{ action: 'api', runId: 'team_...', config: { operation: 'transition-task-status', taskId: '01_01-agent', owner: 'worker-1', token: 'tok-1', status: 'done' } }",
|
|
1190
|
+
),
|
|
1117
1191
|
{
|
|
1118
1192
|
action: "api",
|
|
1119
1193
|
status: "error",
|
|
@@ -1167,7 +1241,11 @@ export async function handleApi(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
1167
1241
|
const task = loaded.tasks.find((item) => item.id === taskId || item.stepId === taskId);
|
|
1168
1242
|
if (!task)
|
|
1169
1243
|
return result(
|
|
1170
|
-
|
|
1244
|
+
paramRequired(
|
|
1245
|
+
"API write-heartbeat",
|
|
1246
|
+
"config.taskId matching a task id or step id",
|
|
1247
|
+
"{ action: 'api', runId: 'team_...', config: { operation: 'write-heartbeat', taskId: '01_01-agent' } }",
|
|
1248
|
+
),
|
|
1171
1249
|
{
|
|
1172
1250
|
action: "api",
|
|
1173
1251
|
status: "error",
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import { appendHookEvent, executeHook } from "../../hooks/registry.ts";
|
|
2
|
-
import {
|
|
3
|
-
import { killProcessPid } from "../../runtime/child-pi.ts";
|
|
2
|
+
import { killProcessPid } from "../../runtime/child-pi/child-pi.ts";
|
|
4
3
|
import { recordFromTask, saveCrewAgents } from "../../runtime/crew-agent-records.ts";
|
|
5
4
|
import { writeForegroundInterruptRequest } from "../../runtime/foreground-control.ts";
|
|
6
|
-
import { terminateLiveAgentsForRun } from "../../runtime/live-agent-manager.ts";
|
|
5
|
+
import { terminateLiveAgentsForRun } from "../../runtime/live-session/live-agent-manager.ts";
|
|
6
|
+
import {
|
|
7
|
+
buildSyntheticTerminalEvidence,
|
|
8
|
+
type CancellationReason,
|
|
9
|
+
cancellationReasonFromUnknown,
|
|
10
|
+
} from "../../runtime/process/cancellation.ts";
|
|
7
11
|
import type { TeamToolParamsValue } from "../../schema/team-tool-schema.ts";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { loadRunManifestById, saveRunTasks, updateRunStatus } from "../../state/state-store.ts";
|
|
12
|
+
import { withRunLockSync } from "../../state/coordination/locks.ts";
|
|
13
|
+
import { appendEvent } from "../../state/event-log/event-log.ts";
|
|
14
|
+
import { loadRunManifestById, saveRunTasks, updateRunStatus } from "../../state/stores/state-store.ts";
|
|
11
15
|
import { logInternalError } from "../../utils/internal-error.ts";
|
|
12
16
|
import { locateRunCwd } from "../team-tool.ts";
|
|
13
17
|
import type { PiTeamsToolResult } from "../tool-result.ts";
|
|
14
18
|
import { type CacheControlDeps, invalidateSnapshot } from "./cache-control.ts";
|
|
15
19
|
import { result, type TeamContext } from "./context.ts";
|
|
16
20
|
import { enforceDestructiveIntent, intentFromConfig } from "./intent-policy.ts";
|
|
21
|
+
import { paramRequired } from "./param-error.ts";
|
|
17
22
|
import { RUN_NOT_FOUND_HINT } from "./run-not-found.ts";
|
|
18
23
|
|
|
19
24
|
export interface AbortOwnedResult {
|
|
@@ -84,7 +89,12 @@ function cancelReasonFromParams(params: TeamToolParamsValue): CancellationReason
|
|
|
84
89
|
}
|
|
85
90
|
|
|
86
91
|
export async function handleRetry(params: TeamToolParamsValue, ctx: TeamContext, deps?: CacheControlDeps): Promise<PiTeamsToolResult> {
|
|
87
|
-
if (!params.runId)
|
|
92
|
+
if (!params.runId)
|
|
93
|
+
return result(
|
|
94
|
+
paramRequired("retry", "runId", "{ action: 'retry', runId: 'team_...' }"),
|
|
95
|
+
{ action: "retry", status: "error" },
|
|
96
|
+
true,
|
|
97
|
+
);
|
|
88
98
|
const runCwd = locateRunCwd(params.runId, ctx.cwd);
|
|
89
99
|
if (!runCwd) return result(`Run '${params.runId}' not found.${RUN_NOT_FOUND_HINT}`, { action: "retry", status: "error" }, true);
|
|
90
100
|
const loaded = loadRunManifestById(runCwd, params.runId); // NOTE: no withRunLock - best-effort only; concurrent writes may cause inconsistency
|
|
@@ -176,7 +186,12 @@ export async function handleRetry(params: TeamToolParamsValue, ctx: TeamContext,
|
|
|
176
186
|
export async function handleCancel(params: TeamToolParamsValue, ctx: TeamContext, deps?: CacheControlDeps): Promise<PiTeamsToolResult> {
|
|
177
187
|
const intentError = enforceDestructiveIntent("cancel", params, ctx.config);
|
|
178
188
|
if (intentError) return intentError;
|
|
179
|
-
if (!params.runId)
|
|
189
|
+
if (!params.runId)
|
|
190
|
+
return result(
|
|
191
|
+
paramRequired("cancel", "runId", "{ action: 'cancel', runId: 'team_...' }"),
|
|
192
|
+
{ action: "cancel", status: "error" },
|
|
193
|
+
true,
|
|
194
|
+
);
|
|
180
195
|
const runCwd = locateRunCwd(params.runId, ctx.cwd);
|
|
181
196
|
if (!runCwd) return result(`Run '${params.runId}' not found.${RUN_NOT_FOUND_HINT}`, { action: "cancel", status: "error" }, true);
|
|
182
197
|
const loaded = loadRunManifestById(runCwd, params.runId); // NOTE: no withRunLock - best-effort only; concurrent writes may cause inconsistency
|
|
@@ -31,7 +31,7 @@ import type { Decision, TaskPacket, TaskResult } from "../../runtime/handoff-man
|
|
|
31
31
|
import { readIfSmallWithTee } from "../../runtime/task-output-context.ts";
|
|
32
32
|
import type { TeamToolParamsValue } from "../../schema/team-tool-schema.ts";
|
|
33
33
|
import { atomicWriteFile } from "../../state/atomic-write.ts";
|
|
34
|
-
import { createRunPaths, loadRunManifestById } from "../../state/state-store.ts";
|
|
34
|
+
import { createRunPaths, loadRunManifestById } from "../../state/stores/state-store.ts";
|
|
35
35
|
import type { TeamRunManifest, TeamTaskState } from "../../state/types.ts";
|
|
36
36
|
import type { PiTeamsToolResult } from "../tool-result.ts";
|
|
37
37
|
import { textFromToolResult } from "../tool-result.ts";
|
|
@@ -22,8 +22,20 @@ import {
|
|
|
22
22
|
import { result, type TeamContext } from "../context.ts";
|
|
23
23
|
import { handleListScheduled, handleSchedule } from "../handle-schedule.ts";
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Actions owned by the Automate domain. Single source of truth for the switch
|
|
27
|
+
* below AND for the runtime exhaustiveness test
|
|
28
|
+
* (test/unit/dispatch-exhaustive.test.ts). The compile-time `never` sentinel in
|
|
29
|
+
* the `default` branch errors if an AutomateDomainAction is added here without
|
|
30
|
+
* a matching `case`.
|
|
31
|
+
*/
|
|
32
|
+
export const AUTOMATE_DOMAIN_ACTIONS = ["schedule", "scheduled", "anchor", "auto-summarize", "auto_boomerang", "api"] as const;
|
|
33
|
+
type AutomateDomainAction = (typeof AUTOMATE_DOMAIN_ACTIONS)[number];
|
|
34
|
+
|
|
25
35
|
export async function handleAutomateDomain(params: TeamToolParamsValue, ctx: TeamContext): Promise<PiTeamsToolResult> {
|
|
26
|
-
|
|
36
|
+
// `domainForAction` routes only Automate-domain actions here, so narrowing is sound.
|
|
37
|
+
const action = params.action as AutomateDomainAction;
|
|
38
|
+
switch (action) {
|
|
27
39
|
case "api":
|
|
28
40
|
return handleApi(params, ctx);
|
|
29
41
|
case "schedule":
|
|
@@ -70,11 +82,14 @@ export async function handleAutomateDomain(params: TeamToolParamsValue, ctx: Tea
|
|
|
70
82
|
return handleAutoSummarizeStatus(params, ctx);
|
|
71
83
|
}
|
|
72
84
|
}
|
|
73
|
-
default:
|
|
85
|
+
default: {
|
|
86
|
+
// Compile-time exhaustiveness: errors if an AutomateDomainAction lacks a case above.
|
|
87
|
+
const _exhaustive: never = action;
|
|
74
88
|
return result(
|
|
75
89
|
`Unhandled automate-domain action: ${params.action}${formatActionSuggestion(String(params.action ?? ""))}`,
|
|
76
90
|
{ action: "unknown", status: "error" },
|
|
77
91
|
true,
|
|
78
92
|
);
|
|
93
|
+
}
|
|
79
94
|
}
|
|
80
95
|
}
|
|
@@ -13,8 +13,20 @@ import { handleDoctor } from "../doctor.ts";
|
|
|
13
13
|
import { handleCleanup, handleForget, handlePrune } from "../lifecycle-actions.ts";
|
|
14
14
|
import { handleRespond } from "../respond.ts";
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Actions owned by the Control domain. Single source of truth for the switch
|
|
18
|
+
* below AND for the runtime exhaustiveness test
|
|
19
|
+
* (test/unit/dispatch-exhaustive.test.ts). The compile-time `never` sentinel in
|
|
20
|
+
* the `default` branch errors if a ControlDomainAction is added here without a
|
|
21
|
+
* matching `case`.
|
|
22
|
+
*/
|
|
23
|
+
export const CONTROL_DOMAIN_ACTIONS = ["cancel", "invalidate", "respond", "cleanup", "prune", "forget", "doctor"] as const;
|
|
24
|
+
type ControlDomainAction = (typeof CONTROL_DOMAIN_ACTIONS)[number];
|
|
25
|
+
|
|
16
26
|
export async function handleControlDomain(params: TeamToolParamsValue, ctx: TeamContext): Promise<PiTeamsToolResult> {
|
|
17
|
-
|
|
27
|
+
// `domainForAction` routes only Control-domain actions here, so narrowing is sound.
|
|
28
|
+
const action = params.action as ControlDomainAction;
|
|
29
|
+
switch (action) {
|
|
18
30
|
case "doctor":
|
|
19
31
|
return handleDoctor(ctx, params);
|
|
20
32
|
case "cleanup":
|
|
@@ -29,7 +41,9 @@ export async function handleControlDomain(params: TeamToolParamsValue, ctx: Team
|
|
|
29
41
|
return handleInvalidate(params, ctx);
|
|
30
42
|
case "respond":
|
|
31
43
|
return handleRespond(params, ctx);
|
|
32
|
-
default:
|
|
44
|
+
default: {
|
|
45
|
+
// Compile-time exhaustiveness: errors if a ControlDomainAction lacks a case above.
|
|
46
|
+
const _exhaustive: never = action;
|
|
33
47
|
return result(
|
|
34
48
|
`Unhandled control-domain action: ${params.action}`,
|
|
35
49
|
{
|
|
@@ -38,5 +52,6 @@ export async function handleControlDomain(params: TeamToolParamsValue, ctx: Team
|
|
|
38
52
|
},
|
|
39
53
|
true,
|
|
40
54
|
);
|
|
55
|
+
}
|
|
41
56
|
}
|
|
42
57
|
}
|
|
@@ -27,8 +27,37 @@ import {
|
|
|
27
27
|
handleWorkflowSave,
|
|
28
28
|
} from "../workflow-manage.ts";
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Actions owned by the Manage domain. Single source of truth for the switch
|
|
32
|
+
* below AND for the runtime exhaustiveness test
|
|
33
|
+
* (test/unit/dispatch-exhaustive.test.ts). The compile-time `never` sentinel in
|
|
34
|
+
* the `default` branch errors if a ManageDomainAction is added here without a
|
|
35
|
+
* matching `case`.
|
|
36
|
+
*/
|
|
37
|
+
export const MANAGE_DOMAIN_ACTIONS = [
|
|
38
|
+
"create",
|
|
39
|
+
"update",
|
|
40
|
+
"delete",
|
|
41
|
+
"init",
|
|
42
|
+
"config",
|
|
43
|
+
"validate",
|
|
44
|
+
"autonomy",
|
|
45
|
+
"settings",
|
|
46
|
+
"workflow-create",
|
|
47
|
+
"workflow-get",
|
|
48
|
+
"workflow-list",
|
|
49
|
+
"workflow-save",
|
|
50
|
+
"workflow-delete",
|
|
51
|
+
"import",
|
|
52
|
+
"imports",
|
|
53
|
+
"export",
|
|
54
|
+
] as const;
|
|
55
|
+
type ManageDomainAction = (typeof MANAGE_DOMAIN_ACTIONS)[number];
|
|
56
|
+
|
|
30
57
|
export async function handleManageDomain(params: TeamToolParamsValue, ctx: TeamContext): Promise<PiTeamsToolResult> {
|
|
31
|
-
|
|
58
|
+
// `domainForAction` routes only Manage-domain actions here, so narrowing is sound.
|
|
59
|
+
const action = params.action as ManageDomainAction;
|
|
60
|
+
switch (action) {
|
|
32
61
|
case "init": {
|
|
33
62
|
const cfg = configRecord(params.config);
|
|
34
63
|
const ignoreMethod =
|
|
@@ -151,11 +180,14 @@ export async function handleManageDomain(params: TeamToolParamsValue, ctx: TeamC
|
|
|
151
180
|
return handleWorkflowSave(params, ctx);
|
|
152
181
|
case "workflow-delete":
|
|
153
182
|
return handleWorkflowDelete(params, ctx);
|
|
154
|
-
default:
|
|
183
|
+
default: {
|
|
184
|
+
// Compile-time exhaustiveness: errors if a ManageDomainAction lacks a case above.
|
|
185
|
+
const _exhaustive: never = action;
|
|
155
186
|
return result(
|
|
156
187
|
`Unhandled manage-domain action: ${params.action}${formatActionSuggestion(String(params.action ?? ""))}`,
|
|
157
188
|
{ action: "unknown", status: "error" },
|
|
158
189
|
true,
|
|
159
190
|
);
|
|
191
|
+
}
|
|
160
192
|
}
|
|
161
193
|
}
|
|
@@ -20,8 +20,20 @@ import { handleOrchestrate } from "../orchestrate.ts";
|
|
|
20
20
|
import { handleParallel } from "../parallel-dispatch.ts";
|
|
21
21
|
import { handlePlan } from "../plan.ts";
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Actions owned by the Run domain. Single source of truth for the switch
|
|
25
|
+
* below AND for the runtime exhaustiveness test
|
|
26
|
+
* (test/unit/dispatch-exhaustive.test.ts). The compile-time `never` sentinel in
|
|
27
|
+
* the `default` branch errors if a RunDomainAction is added here without a
|
|
28
|
+
* matching `case`.
|
|
29
|
+
*/
|
|
30
|
+
export const RUN_DOMAIN_ACTIONS = ["run", "parallel", "plan", "orchestrate", "resume", "retry", "wait", "steer", "goal"] as const;
|
|
31
|
+
type RunDomainAction = (typeof RUN_DOMAIN_ACTIONS)[number];
|
|
32
|
+
|
|
23
33
|
export async function handleRunDomain(params: TeamToolParamsValue, ctx: TeamContext): Promise<PiTeamsToolResult> {
|
|
24
|
-
|
|
34
|
+
// `domainForAction` routes only Run-domain actions here, so narrowing is sound.
|
|
35
|
+
const action = params.action as RunDomainAction;
|
|
36
|
+
switch (action) {
|
|
25
37
|
case "run":
|
|
26
38
|
return handleRun(params, ctx);
|
|
27
39
|
case "parallel":
|
|
@@ -40,7 +52,9 @@ export async function handleRunDomain(params: TeamToolParamsValue, ctx: TeamCont
|
|
|
40
52
|
return handleSteer(params, ctx);
|
|
41
53
|
case "goal":
|
|
42
54
|
return handleGoal(params, ctx);
|
|
43
|
-
default:
|
|
55
|
+
default: {
|
|
56
|
+
// Compile-time exhaustiveness: errors if a RunDomainAction lacks a case above.
|
|
57
|
+
const _exhaustive: never = action;
|
|
44
58
|
return result(
|
|
45
59
|
`Unhandled run-domain action: ${params.action}`,
|
|
46
60
|
{
|
|
@@ -49,5 +63,6 @@ export async function handleRunDomain(params: TeamToolParamsValue, ctx: TeamCont
|
|
|
49
63
|
},
|
|
50
64
|
true,
|
|
51
65
|
);
|
|
66
|
+
}
|
|
52
67
|
}
|
|
53
68
|
}
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
import * as path from "node:path";
|
|
11
11
|
import { allAgents, discoverAgents } from "../../../agents/discover-agents.ts";
|
|
12
12
|
import { loadConfig } from "../../../config/config.ts";
|
|
13
|
-
import { FileCheckpointStore } from "../../../runtime/checkpoint.ts";
|
|
13
|
+
import { FileCheckpointStore } from "../../../runtime/recovery/checkpoint.ts";
|
|
14
14
|
import { getSkillCacheStats } from "../../../runtime/skill-instructions.ts";
|
|
15
15
|
import type { TeamToolParamsValue } from "../../../schema/team-tool-schema.ts";
|
|
16
|
-
import { computeRunCacheKey, getCachedRun, getCacheStats } from "../../../state/run-cache.ts";
|
|
17
|
-
import { listRunGraphs, loadRunGraph } from "../../../state/run-graph.ts";
|
|
16
|
+
import { computeRunCacheKey, getCachedRun, getCacheStats } from "../../../state/stores/run-cache.ts";
|
|
17
|
+
import { listRunGraphs, loadRunGraph } from "../../../state/stores/run-graph.ts";
|
|
18
18
|
import { allTeams, discoverTeams } from "../../../teams/discover-teams.ts";
|
|
19
19
|
import { searchAgents, searchTeams } from "../../../utils/bm25-search.ts";
|
|
20
20
|
import { projectCrewRoot } from "../../../utils/paths.ts";
|
|
@@ -32,8 +32,37 @@ import { handleArtifacts, handleEvents, handleSummary } from "../inspect.ts";
|
|
|
32
32
|
import { handleWorktrees } from "../lifecycle-actions.ts";
|
|
33
33
|
import { handleStatus } from "../status.ts";
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Actions owned by the Status domain. Single source of truth for the switch
|
|
37
|
+
* below AND for the runtime exhaustiveness test
|
|
38
|
+
* (test/unit/dispatch-exhaustive.test.ts). The compile-time `never` sentinel in
|
|
39
|
+
* the `default` branch errors if a StatusDomainAction is added here without a
|
|
40
|
+
* matching `case`.
|
|
41
|
+
*/
|
|
42
|
+
export const STATUS_DOMAIN_ACTIONS = [
|
|
43
|
+
"status",
|
|
44
|
+
"list",
|
|
45
|
+
"get",
|
|
46
|
+
"events",
|
|
47
|
+
"artifacts",
|
|
48
|
+
"summary",
|
|
49
|
+
"graph",
|
|
50
|
+
"search",
|
|
51
|
+
"health",
|
|
52
|
+
"worktrees",
|
|
53
|
+
"checkpoint",
|
|
54
|
+
"cache",
|
|
55
|
+
"explain",
|
|
56
|
+
"onboard",
|
|
57
|
+
"recommend",
|
|
58
|
+
"help",
|
|
59
|
+
] as const;
|
|
60
|
+
type StatusDomainAction = (typeof STATUS_DOMAIN_ACTIONS)[number];
|
|
61
|
+
|
|
35
62
|
export async function handleStatusDomain(params: TeamToolParamsValue, ctx: TeamContext): Promise<PiTeamsToolResult> {
|
|
36
|
-
|
|
63
|
+
// `domainForAction` routes only Status-domain actions here, so narrowing is sound.
|
|
64
|
+
const action = params.action as StatusDomainAction;
|
|
65
|
+
switch (action) {
|
|
37
66
|
case "list":
|
|
38
67
|
return handleList(params, ctx);
|
|
39
68
|
case "get":
|
|
@@ -177,11 +206,14 @@ export async function handleStatusDomain(params: TeamToolParamsValue, ctx: TeamC
|
|
|
177
206
|
{ action: "checkpoint", status: "ok", data: { checkpoint } },
|
|
178
207
|
);
|
|
179
208
|
}
|
|
180
|
-
default:
|
|
209
|
+
default: {
|
|
210
|
+
// Compile-time exhaustiveness: errors if a StatusDomainAction lacks a case above.
|
|
211
|
+
const _exhaustive: never = action;
|
|
181
212
|
return result(
|
|
182
213
|
`Unhandled status-domain action: ${params.action}${formatActionSuggestion(String(params.action ?? ""))}`,
|
|
183
214
|
{ action: "unknown", status: "error" },
|
|
184
215
|
true,
|
|
185
216
|
);
|
|
217
|
+
}
|
|
186
218
|
}
|
|
187
219
|
}
|
|
@@ -5,9 +5,9 @@ import { allAgents, discoverAgents } from "../../agents/discover-agents.ts";
|
|
|
5
5
|
import { loadConfig } from "../../config/config.ts";
|
|
6
6
|
import { DEFAULT_PATHS } from "../../config/defaults.ts";
|
|
7
7
|
import { type DriftReport, detectDrift, formatDriftReport } from "../../config/drift-detector.ts";
|
|
8
|
+
import { getRuntimeWarmupStatus } from "../../runtime/model/runtime-warmup.ts";
|
|
8
9
|
import { getPiSpawnCommand } from "../../runtime/pi-spawn.ts";
|
|
9
|
-
import {
|
|
10
|
-
import { formatZombieReport, scanZombieSubagents } from "../../runtime/zombie-scanner.ts";
|
|
10
|
+
import { formatZombieReport, scanZombieSubagents } from "../../runtime/process/zombie-scanner.ts";
|
|
11
11
|
import type { TeamToolParamsValue } from "../../schema/team-tool-schema.ts";
|
|
12
12
|
import { TeamToolParams } from "../../schema/team-tool-schema.ts";
|
|
13
13
|
import { atomicWriteFile } from "../../state/atomic-write.ts";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
-
import { loadRunManifestById } from "../../state/state-store.ts";
|
|
3
|
+
import { loadRunManifestById } from "../../state/stores/state-store.ts";
|
|
4
4
|
import type { TeamRunManifest, TeamTaskState } from "../../state/types.ts";
|
|
5
5
|
import { RUN_NOT_FOUND_HINT } from "./run-not-found.ts";
|
|
6
6
|
|