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,10 +4,10 @@ import { sanitizeTaskText } from "../../runtime/task-packet.ts";
|
|
|
4
4
|
// Heavy runtime — lazy-loaded to avoid 1.4s import cost at extension registration.
|
|
5
5
|
import type { executeTeamRun as ExecuteTeamRunFn } from "../../runtime/team-runner.ts";
|
|
6
6
|
import type { TeamToolParamsValue } from "../../schema/team-tool-schema.ts";
|
|
7
|
-
import { registerActiveRun, unregisterActiveRun } from "../../state/active-run-registry.ts";
|
|
8
|
-
import { writeArtifact } from "../../state/artifact-store.ts";
|
|
9
7
|
import { atomicWriteJson } from "../../state/atomic-write.ts";
|
|
10
|
-
import {
|
|
8
|
+
import { registerActiveRun, unregisterActiveRun } from "../../state/stores/active-run-registry.ts";
|
|
9
|
+
import { writeArtifact } from "../../state/stores/artifact-store.ts";
|
|
10
|
+
import { createRunManifest, loadRunManifestById, updateRunStatus } from "../../state/stores/state-store.ts";
|
|
11
11
|
import { allTeams, discoverTeams } from "../../teams/discover-teams.ts";
|
|
12
12
|
import { allWorkflows, discoverWorkflows } from "../../workflows/discover-workflows.ts";
|
|
13
13
|
import { assertCleanLeaderAsync, findGitRootAsync } from "../../worktree/worktree-manager.ts";
|
|
@@ -18,6 +18,7 @@ const _typeCheck: typeof ExecuteTeamRunFn = null as never as typeof ExecuteTeamR
|
|
|
18
18
|
import { errorMessage } from "../../utils/guards.ts";
|
|
19
19
|
import { logInternalError } from "../../utils/internal-error.ts";
|
|
20
20
|
import { resolveRealContainedPath } from "../../utils/safe-paths.ts";
|
|
21
|
+
import { paramRequired } from "./param-error.ts";
|
|
21
22
|
|
|
22
23
|
let _cachedExecuteTeamRun: typeof ExecuteTeamRunFn | undefined;
|
|
23
24
|
async function executeTeamRun(...args: Parameters<typeof ExecuteTeamRunFn>): Promise<Awaited<ReturnType<typeof ExecuteTeamRunFn>>> {
|
|
@@ -29,11 +30,11 @@ async function executeTeamRun(...args: Parameters<typeof ExecuteTeamRunFn>): Pro
|
|
|
29
30
|
return _cachedExecuteTeamRun(...args);
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import
|
|
33
|
+
import { spawnBackgroundTeamRun } from "../../runtime/async-runner.ts";
|
|
34
|
+
import { resolveCrewRuntime, runtimeResolutionState } from "../../runtime/model/runtime-resolver.ts";
|
|
35
|
+
import { appendEventAsync, readEvents } from "../../state/event-log/event-log.ts";
|
|
36
|
+
import type { RunMetrics } from "../../state/stores/run-metrics.ts";
|
|
35
37
|
import type { RuntimeResolutionState, TeamRunManifest, TeamTaskState } from "../../state/types.ts";
|
|
36
|
-
import { spawnBackgroundTeamRun } from "../../subagents/async-entry.ts";
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* Module-scoped latch for the crew-init dynamic import.
|
|
@@ -72,10 +73,11 @@ function loadCrewInit(): Promise<typeof import("../../state/crew-init.ts")> {
|
|
|
72
73
|
|
|
73
74
|
import * as fs from "node:fs";
|
|
74
75
|
import * as path from "node:path";
|
|
76
|
+
import { t } from "../../i18n.ts";
|
|
75
77
|
import { hasAsyncStartMarker } from "../../runtime/async-marker.ts";
|
|
76
78
|
import { checkProcessLiveness, isActiveRunStatus } from "../../runtime/process-status.ts";
|
|
77
79
|
import { waitForRun } from "../../runtime/run-tracker.ts";
|
|
78
|
-
import { collectRunMetrics } from "../../state/run-metrics.ts";
|
|
80
|
+
import { collectRunMetrics } from "../../state/stores/run-metrics.ts";
|
|
79
81
|
import type { PiTeamsToolResult } from "../tool-result.ts";
|
|
80
82
|
import { effectiveRunConfig } from "./config-patch.ts";
|
|
81
83
|
import { buildParentContext, result, type TeamContext } from "./context.ts";
|
|
@@ -256,7 +258,7 @@ function formatRunResult(manifest: TeamRunManifest, options: FormatRunResultOpti
|
|
|
256
258
|
? "Experimental live-session worker execution was enabled."
|
|
257
259
|
: "Safe scaffold mode: child Pi workers were not launched because runtime.mode=scaffold or executeWorkers=false was configured.";
|
|
258
260
|
const text = [
|
|
259
|
-
|
|
261
|
+
t("team.run.created", { runId: manifest.runId }),
|
|
260
262
|
`Team: ${team}`,
|
|
261
263
|
`Workflow: ${workflow}`,
|
|
262
264
|
`Status: ${manifest.status}`,
|
|
@@ -285,7 +287,10 @@ function formatRunResult(manifest: TeamRunManifest, options: FormatRunResultOpti
|
|
|
285
287
|
}
|
|
286
288
|
|
|
287
289
|
// mode === "waited" — detailed per-task summary.
|
|
288
|
-
const lines: string[] = [
|
|
290
|
+
const lines: string[] = [
|
|
291
|
+
t("team.run.completed", { status: manifest.status, runId: manifest.runId, team }),
|
|
292
|
+
`Goal: ${goal.slice(0, 100)}`,
|
|
293
|
+
];
|
|
289
294
|
if (metrics) {
|
|
290
295
|
lines.push("");
|
|
291
296
|
lines.push(
|
|
@@ -346,10 +351,10 @@ function formatRunResult(manifest: TeamRunManifest, options: FormatRunResultOpti
|
|
|
346
351
|
|
|
347
352
|
if (failedCount === 0) {
|
|
348
353
|
lines.push("");
|
|
349
|
-
lines.push("
|
|
354
|
+
lines.push(t("team.run.allCompleted"));
|
|
350
355
|
} else {
|
|
351
356
|
lines.push("");
|
|
352
|
-
lines.push(
|
|
357
|
+
lines.push(t("team.run.tasksFailed", { count: failedCount, ids: failedIds.join(", ") }));
|
|
353
358
|
}
|
|
354
359
|
} else {
|
|
355
360
|
lines.push(
|
|
@@ -385,7 +390,12 @@ export async function handleRun(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
385
390
|
return handleChainRun(params, ctx, handleRun);
|
|
386
391
|
}
|
|
387
392
|
const goal = params.goal ?? params.task;
|
|
388
|
-
if (!goal)
|
|
393
|
+
if (!goal)
|
|
394
|
+
return result(
|
|
395
|
+
paramRequired("run", "goal or task", "{ action: 'run', goal: '<what to achieve>' }"),
|
|
396
|
+
{ action: "run", status: "error" },
|
|
397
|
+
true,
|
|
398
|
+
);
|
|
389
399
|
const intentPrefix = goal.length > 60 ? `${goal.slice(0, 57)}...` : goal;
|
|
390
400
|
|
|
391
401
|
// P0: Ensure .crew directory structure exists before creating any manifests.
|
|
@@ -494,7 +504,7 @@ export async function handleRun(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
494
504
|
if (analysisParam.error) return result(analysisParam.error, { action: "run", status: "error" }, true);
|
|
495
505
|
|
|
496
506
|
// LAZY: dodge the jiti ESM/CJS interop TDZ race on the static `import { expandParallelResearchWorkflow }` above (issue #28, RFC 17). At call time the module body has fully evaluated, so the dynamic import returns a live binding. Multi-line form breaks scripts/check-lazy-imports.mjs (which does `lines[lineNum - 2]`), so keep destructuring + await import on one line.
|
|
497
|
-
const { expandParallelResearchWorkflow: expandParallelResearch } = await import("../../runtime/parallel-research.ts");
|
|
507
|
+
const { expandParallelResearchWorkflow: expandParallelResearch } = await import("../../runtime/scheduling/parallel-research.ts");
|
|
498
508
|
const workflow = directAgent ? baseWorkflow : expandParallelResearch(baseWorkflow, resolvedCtx.cwd);
|
|
499
509
|
const isDynamicWorkflow =
|
|
500
510
|
!directAgent && (workflow as import("../../workflows/workflow-config.ts").WorkflowConfig).runtime === "dynamic";
|
|
@@ -623,8 +633,8 @@ export async function handleRun(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
623
633
|
console.warn(
|
|
624
634
|
`[pi-crew SECURITY] Dynamic workflow '${workflow.name}' executes as trusted Node.js code with full process/require/import access; run only reviewed .dwf.ts files.`,
|
|
625
635
|
);
|
|
626
|
-
// LAZY: defer dynamic import of ../../runtime/dynamic-workflow-runner.ts to its call site.
|
|
627
|
-
const { runDynamicWorkflow } = await import("../../runtime/dynamic-workflow-runner.ts");
|
|
636
|
+
// LAZY: defer dynamic import of ../../runtime/goal-workflow/dynamic-workflow-runner.ts to its call site.
|
|
637
|
+
const { runDynamicWorkflow } = await import("../../runtime/goal-workflow/dynamic-workflow-runner.ts");
|
|
628
638
|
// Re-synthesize a dynamic-team (§0c C9) for role resolution.
|
|
629
639
|
const dwfTeam: import("../../teams/team-config.ts").TeamConfig = {
|
|
630
640
|
name: `dwf-${manifest.runId.slice(-12)}`,
|
|
@@ -643,7 +653,7 @@ export async function handleRun(params: TeamToolParamsValue, ctx: TeamContext):
|
|
|
643
653
|
// CORE-8: unified deadline — resolve params > config > 1h default.
|
|
644
654
|
const dwfDeadline = resolveRunDeadline(ctx, params);
|
|
645
655
|
try {
|
|
646
|
-
let dwfResult: import("../../runtime/dynamic-workflow-runner.ts").RunDynamicWorkflowResult | undefined;
|
|
656
|
+
let dwfResult: import("../../runtime/goal-workflow/dynamic-workflow-runner.ts").RunDynamicWorkflowResult | undefined;
|
|
647
657
|
try {
|
|
648
658
|
dwfResult = await runDynamicWorkflow({
|
|
649
659
|
manifest: dwfManifest,
|
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
import { loadConfig } from "../../config/config.ts";
|
|
2
2
|
import { applyAttentionState, formatActivityAge, resolveCrewControlConfig } from "../../runtime/agent-control.ts";
|
|
3
3
|
import { extractCommandTrace } from "../../runtime/command-trace.ts";
|
|
4
|
-
import { verifyTaskCompletion } from "../../runtime/completion-guard.ts";
|
|
5
4
|
import { readCrewAgents } from "../../runtime/crew-agent-records.ts";
|
|
6
5
|
import { evaluateRunEffectiveness } from "../../runtime/effectiveness.ts";
|
|
7
6
|
import { computePhaseProgress } from "../../runtime/phase-progress.ts";
|
|
8
7
|
import { checkProcessLiveness, isActiveRunStatus } from "../../runtime/process-status.ts";
|
|
9
8
|
import { formatTaskGraphLines, waitingReason } from "../../runtime/task-display.ts";
|
|
9
|
+
import { verifyTaskCompletion } from "../../runtime/verification/completion-guard.ts";
|
|
10
10
|
import type { TeamToolParamsValue } from "../../schema/team-tool-schema.ts";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { loadRunManifestById, saveRunTasks, updateRunStatus } from "../../state/state-store.ts";
|
|
11
|
+
import { readDeliveryState, readMailbox } from "../../state/coordination/mailbox.ts";
|
|
12
|
+
import { appendEvent, readEvents } from "../../state/event-log/event-log.ts";
|
|
13
|
+
import { loadRunManifestById, saveRunTasks, updateRunStatus } from "../../state/stores/state-store.ts";
|
|
14
14
|
import { aggregateUsage, formatCost, formatUsage } from "../../state/usage.ts";
|
|
15
15
|
import { formatDuration } from "../../ui/format-helpers.ts";
|
|
16
16
|
import { locateRunCwd } from "../team-tool.ts";
|
|
17
17
|
import type { PiTeamsToolResult } from "../tool-result.ts";
|
|
18
18
|
import { result, type TeamContext } from "./context.ts";
|
|
19
|
+
import { paramRequired } from "./param-error.ts";
|
|
19
20
|
import { RUN_NOT_FOUND_HINT } from "./run-not-found.ts";
|
|
20
21
|
|
|
21
22
|
export function handleStatus(params: TeamToolParamsValue, ctx: TeamContext): PiTeamsToolResult {
|
|
22
|
-
if (!params.runId)
|
|
23
|
+
if (!params.runId)
|
|
24
|
+
return result(
|
|
25
|
+
paramRequired("status", "runId", "{ action: 'status', runId: 'team_...' }"),
|
|
26
|
+
{ action: "status", status: "error" },
|
|
27
|
+
true,
|
|
28
|
+
);
|
|
23
29
|
const runCwd = locateRunCwd(params.runId, ctx.cwd);
|
|
24
30
|
if (!runCwd) return result(`Run '${params.runId}' not found.${RUN_NOT_FOUND_HINT}`, { action: "status", status: "error" }, true);
|
|
25
31
|
const loaded = loadRunManifestById(runCwd, params.runId); // NOTE: no withRunLock - best-effort only; concurrent writes may cause inconsistency
|
|
@@ -60,6 +66,11 @@ export function handleStatus(params: TeamToolParamsValue, ctx: TeamContext): PiT
|
|
|
60
66
|
const phaseProgress = computePhaseProgress(tasks);
|
|
61
67
|
const allEvents = readEvents(manifest.eventsPath);
|
|
62
68
|
const events = allEvents.slice(-8);
|
|
69
|
+
// P1-8: pre-build the ack-timeout requestId set once (was O(events × messages)
|
|
70
|
+
// via allEvents.some() inside the mailbox loop).
|
|
71
|
+
const ackTimeoutRequestIds = new Set(
|
|
72
|
+
allEvents.filter((event) => event.type === "agent.group_join.ack_timeout").map((event) => String(event.data?.requestId ?? "")),
|
|
73
|
+
);
|
|
63
74
|
const attentionByTask = new Map(
|
|
64
75
|
allEvents.filter((event) => event.type === "task.attention" && event.taskId).map((event) => [event.taskId!, event]),
|
|
65
76
|
);
|
|
@@ -80,7 +91,7 @@ export function handleStatus(params: TeamToolParamsValue, ctx: TeamContext): PiT
|
|
|
80
91
|
const ageMs = Date.now() - new Date(message.createdAt).getTime();
|
|
81
92
|
const requestId = String(message.data?.requestId ?? "unknown");
|
|
82
93
|
const timedOut = ack === "pending" && ackTimeoutMs !== undefined && Number.isFinite(ageMs) && ageMs > ackTimeoutMs;
|
|
83
|
-
if (timedOut && !
|
|
94
|
+
if (timedOut && !ackTimeoutRequestIds.has(requestId)) {
|
|
84
95
|
appendEvent(manifest.eventsPath, {
|
|
85
96
|
type: "agent.group_join.ack_timeout",
|
|
86
97
|
runId: manifest.runId,
|
|
@@ -7,12 +7,12 @@ import { loadConfig } from "../config/config.ts";
|
|
|
7
7
|
// executeTeamRun is only called when a team run actually executes.
|
|
8
8
|
import type { executeTeamRun as _executeTeamRunFn } from "../runtime/team-runner.ts";
|
|
9
9
|
import type { TeamToolParamsValue } from "../schema/team-tool-schema.ts";
|
|
10
|
-
import { writeArtifact } from "../state/artifact-store.ts";
|
|
11
10
|
import { TEAM_TERMINAL_TASK_STATUSES } from "../state/contracts.ts";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
11
|
+
import { withRunLock } from "../state/coordination/locks.ts";
|
|
12
|
+
import { replayPendingMailboxMessages } from "../state/coordination/mailbox.ts";
|
|
13
|
+
import { appendEvent, appendEventFireAndForget } from "../state/event-log/event-log.ts";
|
|
14
|
+
import { writeArtifact } from "../state/stores/artifact-store.ts";
|
|
15
|
+
import { loadRunManifestById, saveRunManifestAsync, saveRunTasks, updateRunStatus } from "../state/stores/state-store.ts";
|
|
16
16
|
import type { ArtifactDescriptor, TeamRunManifest, TeamTaskState } from "../state/types.ts";
|
|
17
17
|
import { allTeams, discoverTeams } from "../teams/discover-teams.ts";
|
|
18
18
|
import { resolveRealContainedPath } from "../utils/safe-paths.ts";
|
|
@@ -32,8 +32,8 @@ async function executeTeamRun(...args: Parameters<ExecuteTeamRunFn>): Promise<Aw
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
import { directTeamAndWorkflowFromRun } from "../runtime/direct-run.ts";
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
35
|
+
import { resolveCrewRuntime, runtimeResolutionState } from "../runtime/model/runtime-resolver.ts";
|
|
36
|
+
import { parsePiJsonOutput } from "../runtime/output/pi-json-output.ts";
|
|
37
37
|
import { effectiveRunConfig } from "./team-tool/config-patch.ts";
|
|
38
38
|
import { buildParentContext, formatScoped, result, type TeamContext } from "./team-tool/context.ts";
|
|
39
39
|
// Lazy-loaded: run.ts pulls in spawnBackgroundTeamRun, resolveCrewRuntime, etc.
|
|
@@ -51,6 +51,7 @@ async function handleRun(...args: Parameters<HandleRunFn>): Promise<Awaited<Retu
|
|
|
51
51
|
return _cachedHandleRun(...args);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
import { t } from "../i18n.ts";
|
|
54
55
|
import { waitForRun } from "../runtime/run-tracker.ts";
|
|
55
56
|
import { normalizeSkillOverride } from "../runtime/skill-instructions.ts";
|
|
56
57
|
import { formatActionSuggestion } from "./action-suggestions.ts";
|
|
@@ -638,10 +639,9 @@ export async function handleTeamTool(params: TeamToolParamsValue, ctx: TeamConte
|
|
|
638
639
|
return handleManageDomain(params, ctx);
|
|
639
640
|
case "automate":
|
|
640
641
|
return handleAutomateDomain(params, ctx);
|
|
641
|
-
case undefined:
|
|
642
642
|
default:
|
|
643
643
|
return result(
|
|
644
|
-
|
|
644
|
+
t("team.unknownAction", { action: String(action) }) + formatActionSuggestion(String(action)),
|
|
645
645
|
{ action: "unknown", status: "error" },
|
|
646
646
|
true,
|
|
647
647
|
);
|
|
@@ -649,11 +649,15 @@ export async function handleTeamTool(params: TeamToolParamsValue, ctx: TeamConte
|
|
|
649
649
|
}
|
|
650
650
|
|
|
651
651
|
/**
|
|
652
|
-
*
|
|
653
|
-
*
|
|
654
|
-
*
|
|
652
|
+
* Module-scoped RPC registry for access to pi-crew's team orchestrator.
|
|
653
|
+
*
|
|
654
|
+
* EXT-9: Previously this used a `globalThis[Symbol.for("pi-crew:registry")]`
|
|
655
|
+
* singleton — fragile (cross-realm, no lifecycle, peer extensions could
|
|
656
|
+
* read/overwrite it). It is now a module-level variable: exactly one instance
|
|
657
|
+
* per extension load (one per pi session), invisible to peer extensions.
|
|
658
|
+
* Cross-extension consumers should use the `pi.events` RPC channel
|
|
659
|
+
* (`registerPiCrewRpc`) instead of poking globalThis.
|
|
655
660
|
*/
|
|
656
|
-
const CREW_REGISTRY_KEY = Symbol.for("pi-crew:registry");
|
|
657
661
|
interface CrewRegistry {
|
|
658
662
|
version: 2;
|
|
659
663
|
getRecord: (runId: string) => TeamRunManifest | undefined;
|
|
@@ -674,13 +678,16 @@ interface CrewRegistry {
|
|
|
674
678
|
// discovery results with highest priority. The CrewRegistry interface exposes
|
|
675
679
|
// registerAgent/unregisterAgent/listDynamicAgents for cross-extension access.
|
|
676
680
|
|
|
681
|
+
// Module-scoped singleton instance — one per extension load (EXT-9).
|
|
682
|
+
let crewRegistryInstance: CrewRegistry | undefined;
|
|
683
|
+
|
|
677
684
|
export function registerCrewGlobalRegistry(registry: CrewRegistry): void {
|
|
678
|
-
|
|
685
|
+
crewRegistryInstance = registry;
|
|
679
686
|
}
|
|
680
687
|
|
|
681
|
-
/** @internal */
|
|
682
|
-
function getCrewGlobalRegistry(): CrewRegistry | undefined {
|
|
683
|
-
return
|
|
688
|
+
/** @internal — exported for lifecycle tests. */
|
|
689
|
+
export function getCrewGlobalRegistry(): CrewRegistry | undefined {
|
|
690
|
+
return crewRegistryInstance;
|
|
684
691
|
}
|
|
685
692
|
|
|
686
693
|
/** Manifest cache shape needed to construct the global registry's read-side. */
|
|
@@ -744,7 +751,7 @@ export function installCrewGlobalRegistry(deps?: { manifestCache: ManifestCacheF
|
|
|
744
751
|
registerCrewGlobalRegistry(registry);
|
|
745
752
|
}
|
|
746
753
|
|
|
747
|
-
/** Remove the
|
|
754
|
+
/** Remove the CrewRegistry singleton. Call during session cleanup. */
|
|
748
755
|
export function uninstallCrewGlobalRegistry(): void {
|
|
749
|
-
|
|
756
|
+
crewRegistryInstance = undefined;
|
|
750
757
|
}
|
package/src/hooks/registry.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { appendEvent } from "../state/event-log.ts";
|
|
1
|
+
import { appendEvent } from "../state/event-log/event-log.ts";
|
|
2
2
|
import type { TeamRunManifest } from "../state/types.ts";
|
|
3
3
|
import { runEventBus } from "../ui/run-event-bus.ts";
|
|
4
4
|
import type { HookContext, HookDefinition, HookExecutionReport, HookName, HookResult } from "./types.ts";
|
package/src/i18n.ts
CHANGED
|
@@ -24,6 +24,13 @@ const fallback = {
|
|
|
24
24
|
"steer.noted": "Steering request noted for {id}.",
|
|
25
25
|
"steer.unavailable": "Current default pi-crew backend is child-process, so mid-turn session.steer is not available yet.",
|
|
26
26
|
"steer.cancelHint": "Use team cancel runId={runId} if the agent must be interrupted.",
|
|
27
|
+
// PR-F12 (EXT-12): team tool user-facing strings routed through t() for
|
|
28
|
+
// consistency with the subagent tools (Agent / get_subagent_result).
|
|
29
|
+
"team.run.created": "Created pi-crew run {runId}.",
|
|
30
|
+
"team.run.completed": "pi-crew run {status}: {runId} ({team})",
|
|
31
|
+
"team.run.allCompleted": "All tasks completed successfully.",
|
|
32
|
+
"team.run.tasksFailed": "{count} task(s) failed: {ids}. Consider retrying.",
|
|
33
|
+
"team.unknownAction": "Unknown action: {action}",
|
|
27
34
|
} as const;
|
|
28
35
|
|
|
29
36
|
type Key = keyof typeof fallback;
|
|
@@ -50,6 +57,11 @@ const translations: Record<string, Partial<Record<Key, string>>> = {
|
|
|
50
57
|
"steer.unavailable":
|
|
51
58
|
"El backend predeterminado actual de pi-crew es child-process, así que session.steer a mitad de turno aún no está disponible.",
|
|
52
59
|
"steer.cancelHint": "Usa team cancel runId={runId} si hay que interrumpir el agente.",
|
|
60
|
+
"team.run.created": "Ejecución de pi-crew creada {runId}.",
|
|
61
|
+
"team.run.completed": "Ejecución de pi-crew {status}: {runId} ({team})",
|
|
62
|
+
"team.run.allCompleted": "Todas las tareas se completaron con éxito.",
|
|
63
|
+
"team.run.tasksFailed": "{count} tarea(s) fallaron: {ids}. Considera reintentar.",
|
|
64
|
+
"team.unknownAction": "Acción desconocida: {action}",
|
|
53
65
|
},
|
|
54
66
|
fr: {
|
|
55
67
|
"agent.requiresPrompt": "Agent nécessite un prompt.",
|
|
@@ -71,6 +83,11 @@ const translations: Record<string, Partial<Record<Key, string>>> = {
|
|
|
71
83
|
"steer.unavailable":
|
|
72
84
|
"Le backend pi-crew par défaut actuel est child-process, donc session.steer en milieu de tour n'est pas encore disponible.",
|
|
73
85
|
"steer.cancelHint": "Utilisez team cancel runId={runId} si l'agent doit être interrompu.",
|
|
86
|
+
"team.run.created": "Exécution pi-crew créée {runId}.",
|
|
87
|
+
"team.run.completed": "Exécution pi-crew {status} : {runId} ({team})",
|
|
88
|
+
"team.run.allCompleted": "Toutes les tâches ont été effectuées avec succès.",
|
|
89
|
+
"team.run.tasksFailed": "{count} tâche(s) ont échoué : {ids}. Envisagez de réessayer.",
|
|
90
|
+
"team.unknownAction": "Action inconnue : {action}",
|
|
74
91
|
},
|
|
75
92
|
"pt-BR": {
|
|
76
93
|
"agent.requiresPrompt": "Agent requer prompt.",
|
|
@@ -92,6 +109,11 @@ const translations: Record<string, Partial<Record<Key, string>>> = {
|
|
|
92
109
|
"steer.unavailable":
|
|
93
110
|
"O backend padrão atual do pi-crew é child-process, então session.steer no meio do turno ainda não está disponível.",
|
|
94
111
|
"steer.cancelHint": "Use team cancel runId={runId} se o agente precisar ser interrompido.",
|
|
112
|
+
"team.run.created": "Execução do pi-crew criada {runId}.",
|
|
113
|
+
"team.run.completed": "Execução do pi-crew {status}: {runId} ({team})",
|
|
114
|
+
"team.run.allCompleted": "Todas as tarefas foram concluídas com sucesso.",
|
|
115
|
+
"team.run.tasksFailed": "{count} tarefa(s) falharam: {ids}. Considere tentar novamente.",
|
|
116
|
+
"team.unknownAction": "Ação desconhecida: {action}",
|
|
95
117
|
},
|
|
96
118
|
};
|
|
97
119
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentProgress } from "../runtime/progress-tracker.ts";
|
|
1
|
+
import type { AgentProgress } from "../runtime/output/progress-tracker.ts";
|
|
2
2
|
import { logInternalError } from "../utils/internal-error.ts";
|
|
3
3
|
|
|
4
4
|
export type CrewEventType = "agent:progress" | "agent:complete" | "agent:error" | "run:start" | "run:complete";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
4
|
-
import { startChildBrokerClient } from "../runtime/crew-broker-child.ts";
|
|
4
|
+
import { startChildBrokerClient } from "../runtime/broker/crew-broker-child.ts";
|
|
5
5
|
import { logInternalError } from "../utils/internal-error.ts";
|
|
6
6
|
import { resolveRealContainedPath } from "../utils/safe-paths.ts";
|
|
7
7
|
|
|
@@ -362,7 +362,7 @@ export default function registerPiTeamsPromptRuntime(pi: ExtensionAPI): void {
|
|
|
362
362
|
// already .unref()'d so it never blocks event-loop exit; errors are
|
|
363
363
|
// swallowed because teardown failures during shutdown are harmless.
|
|
364
364
|
pi.on("session_shutdown", () => {
|
|
365
|
-
void brokerHandle.close().catch(() =>
|
|
365
|
+
void brokerHandle.close().catch(() => undefined);
|
|
366
366
|
});
|
|
367
367
|
|
|
368
368
|
// ── Prompt rewriting (existing) ────────────────────────────────────────
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# src/runtime/ — runtime cluster map
|
|
2
|
+
|
|
3
|
+
This directory holds the team-run execution machinery. After the v0.9.x reorg, the largest
|
|
4
|
+
clusters are extracted into subdirectories; the remaining files stay at the root.
|
|
5
|
+
|
|
6
|
+
## Extracted subdirectories (navigable clusters)
|
|
7
|
+
|
|
8
|
+
| Subdir | Phase | Cluster | Key files |
|
|
9
|
+
|--------|-------|---------|-----------|
|
|
10
|
+
| [`child-pi/`](./child-pi/) | B-1 | child Pi worker spawn/lifecycle/steering/transcript | `child-pi.ts`, `child-pi-spawn.ts`, `child-pi-kill.ts`, `child-pi-constants.ts`, `child-pi-steering.ts`, `child-pi-streams.ts`, `child-pi-transcript.ts`, `child-pi-pool.ts` |
|
|
11
|
+
| [`broker/`](./broker/) | B-2 | crew broker server/client/auth (child-pi ↔ parent IPC) | `crew-broker.ts`, `crew-broker-client.ts`, `crew-broker-child.ts`, `crew-broker-tokens.ts`, `broker-issuer.ts` |
|
|
12
|
+
| [`task-runner/`](./task-runner/) | (pre-existing) | per-task execution (pre-execution, child-executor) | `child-executor.ts`, `pre-execution.ts`, ... |
|
|
13
|
+
| [`live-session/`](./live-session/) | 3 | live agent control/manager, session runtime, IRC, health, extension bridge | `live-session-runtime.ts`, `live-agent-manager.ts`, `live-agent-control.ts`, `live-control-realtime.ts`, `live-irc.ts`, `live-session-health.ts`, `live-extension-bridge.ts`, `intercom-bridge.ts` |
|
|
14
|
+
| [`recovery/`](./recovery/) | 4 | crash recovery, retry, checkpoint | `crash-recovery.ts`, `crash-classification.ts`, `recovery-recipes.ts`, `overflow-recovery.ts`, `retry-executor.ts`, `retry-runner.ts`, `checkpoint.ts` |
|
|
15
|
+
| [`scheduling/`](./scheduling/) | 5 | scheduler, concurrency, task-graph, batch-barrier, parallel utils | `scheduler.ts`, `semaphore.ts`, `concurrency.ts`, `task-graph.ts`, `task-graph-scheduler.ts`, `batch-barrier.ts`, `coalesce-tasks.ts`, `run-coalesced-task-group.ts`, `global-worker-cap.ts`, `parallel-research.ts`, `parallel-utils.ts` |
|
|
16
|
+
| [`verification/`](./verification/) | 6a | verification gates, green-contract, post-checks, completion-guard | `verification-gates.ts`, `verification-integrity.ts`, `verification-worktree.ts`, `green-contract.ts`, `post-checks.ts`, `completion-guard.ts` |
|
|
17
|
+
| [`model/`](./model/) | 6b | model fallback/resolver/scope, pi-args, runtime policy/resolver/warmup | `model-fallback.ts`, `model-resolver.ts`, `model-scope.ts`, `pi-args.ts`, `runtime-policy.ts`, `runtime-resolver.ts`, `runtime-warmup.ts` |
|
|
18
|
+
| [`output/`](./output/) | 6c | streaming output, progress tracking, sidechain, result extraction | `streaming-output.ts`, `stream-preview.ts`, `output-validator.ts`, `pi-json-output.ts`, `tool-progress.ts`, `progress-event-coalescer.ts`, `progress-tracker.ts`, `result-extractor.ts`, `sidechain-output.ts` |
|
|
19
|
+
| [`heartbeat/`](./heartbeat/) | 6d | heartbeat gradient/watcher, worker heartbeat/startup | `heartbeat-gradient.ts`, `heartbeat-watcher.ts`, `worker-heartbeat.ts`, `worker-startup.ts` |
|
|
20
|
+
| [`process/`](./process/) | 6e | cancellation, process lifecycle, zombie scanner, stdio guard | `cancellation-token.ts`, `cancellation.ts`, `process-lifecycle.ts`, `zombie-scanner.ts`, `post-exit-stdio-guard.ts` |
|
|
21
|
+
| [`goal-workflow/`](./goal-workflow/) | 6f | goal achievement/evaluation/loop, dynamic-workflow, adaptive plan | `goal-achievement.ts`, `goal-evaluator.ts`, `goal-loop-runner.ts`, `goal-state-store.ts`, `dynamic-workflow-context.ts`, `dynamic-workflow-runner.ts`, `adaptive-plan.ts`, `plan-templates.ts` |
|
|
22
|
+
| [`compaction/`](./compaction/) | 6g | compaction pipeline, tool-output-pruner, important-line-classifier, compact-stages | `compact-pipeline.ts`, `compaction-summary.ts`, `tool-output-pruner.ts`, `important-line-classifier.ts`, [`compact-stages/`](./compaction/compact-stages/) |
|
|
23
|
+
| [`custom-tools/`](./custom-tools/) | (pre-existing) | custom tool definitions | `irc-tool.ts`, `submit-result-tool.ts`, ... |
|
|
24
|
+
| [`errors/`](./errors/) | (pre-existing) | error types | ... |
|
|
25
|
+
|
|
26
|
+
## Remaining flat files at root (~77)
|
|
27
|
+
|
|
28
|
+
- **team-runner** — `team-runner.ts` (the orchestrator) + `run-worker.ts`, `run-tracker.ts`
|
|
29
|
+
- **chain/pipeline runners** — `chain-parser.ts`, `chain-runner.ts`, `pipeline-runner.ts`, `direct-run.ts`
|
|
30
|
+
- **foreground/background runners** — `foreground-control.ts`, `foreground-watchdog.ts`, `async-runner.ts`, `background-runner.ts`
|
|
31
|
+
- **crew agent** — `crew-agent-records.ts`, `crew-agent-runtime.ts`, `crew-hooks.ts`, `single-agent-compose.ts`
|
|
32
|
+
- **observability** — `effectiveness.ts`, `agent-observability.ts`, `command-trace.ts`, `metric-parser.ts`
|
|
33
|
+
- **misc** — `stale-reconciler.ts`, `parent-guard.ts`, `manifest-cache.ts`, `event-stream-bridge.ts`, `policy-engine.ts`, `role-permission.ts`, `workspace-lock.ts`, `workspace-tree.ts`, `session-*.ts`, ...
|
|
34
|
+
|
|
35
|
+
See `docs/COVERAGE-ASSESSMENT-2026-08-01.md` § "Source reorganization" for the reorg history + remaining-cluster plan.
|
|
@@ -32,7 +32,7 @@ export function resolveCrewControlConfig(config: PiTeamsConfig | undefined): Cre
|
|
|
32
32
|
})
|
|
33
33
|
| undefined;
|
|
34
34
|
return {
|
|
35
|
-
enabled: raw?.control?.enabled
|
|
35
|
+
enabled: raw?.control?.enabled !== false,
|
|
36
36
|
needsAttentionAfterMs: positiveInt(raw?.control?.needsAttentionAfterMs) ?? DEFAULT_NEEDS_ATTENTION_MS,
|
|
37
37
|
consecutiveFailureThreshold: positiveInt(raw?.control?.consecutiveFailureThreshold) ?? DEFAULT_CONSECUTIVE_FAILURE_THRESHOLD,
|
|
38
38
|
longRunningMinutes: positiveInt(raw?.control?.longRunningMinutes) ?? DEFAULT_LONG_RUNNING_MINUTES,
|
|
@@ -16,8 +16,6 @@ const MAX_HANDOFFS_PER_ANCHOR = 100;
|
|
|
16
16
|
* - accumulateHandoff() adds handoffs to the anchor
|
|
17
17
|
* - clearAnchor() finalizes and returns accumulated summaries
|
|
18
18
|
* - getAnchorHandoff() retrieves accumulated summary without clearing
|
|
19
|
-
*
|
|
20
|
-
* @see docs/pi-boomerang-integration-plan.md
|
|
21
19
|
*/
|
|
22
20
|
|
|
23
21
|
import type { HandoffSummary } from "./handoff-manager.ts";
|
|
@@ -3,7 +3,7 @@ import * as fs from "node:fs";
|
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import * as path from "node:path";
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
|
-
import { appendEventAsync } from "../state/event-log.ts";
|
|
6
|
+
import { appendEventAsync } from "../state/event-log/event-log.ts";
|
|
7
7
|
import type { TeamRunManifest } from "../state/types.ts";
|
|
8
8
|
import { WINDOWS_ESSENTIAL_ENV_VARS } from "../utils/env-allowlist.ts";
|
|
9
9
|
import { sanitizeEnvSecrets } from "../utils/env-filter.ts";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { appendEvent,
|
|
1
|
+
import { appendEvent, type TeamEvent } from "../state/event-log/event-log.ts";
|
|
2
2
|
import type { CrewAttentionEventData, TeamRunManifest } from "../state/types.ts";
|
|
3
|
+
import { readJsonlTail } from "../utils/incremental-reader.ts";
|
|
3
4
|
|
|
4
5
|
export interface AppendTaskAttentionInput {
|
|
5
6
|
manifest: TeamRunManifest;
|
|
@@ -9,7 +10,7 @@ export interface AppendTaskAttentionInput {
|
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export function appendTaskAttentionEvent(input: AppendTaskAttentionInput): boolean {
|
|
12
|
-
const recent =
|
|
13
|
+
const recent = readJsonlTail<TeamEvent>(input.manifest.eventsPath, 256 * 1024).items.slice(-200);
|
|
13
14
|
const dedupKey = `${input.taskId ?? ""}:${input.data.reason}:${input.data.activityState}`;
|
|
14
15
|
const duplicate = recent.some(
|
|
15
16
|
(event) =>
|
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
* - toggle() enables/disables auto-summarization
|
|
6
6
|
* - shouldAutoSummarize() checks if task should auto-summarize
|
|
7
7
|
* - Token and tool thresholds control when summarization triggers
|
|
8
|
-
*
|
|
9
|
-
* @see docs/pi-boomerang-integration-plan.md
|
|
10
8
|
*/
|
|
11
9
|
|
|
12
10
|
import type { TaskPacket, TaskResult } from "./handoff-manager.ts";
|