@llblab/pi-kit 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +35 -0
- package/BACKLOG.md +3 -0
- package/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/README.md +43 -0
- package/node_modules/@llblab/pi-actors/AGENTS.md +150 -0
- package/node_modules/@llblab/pi-actors/BACKLOG.md +6 -0
- package/node_modules/@llblab/pi-actors/CHANGELOG.md +865 -0
- package/node_modules/@llblab/pi-actors/README.md +231 -0
- package/node_modules/@llblab/pi-actors/banner.jpg +0 -0
- package/node_modules/@llblab/pi-actors/dist/fixtures/protocol/artifact-manifest.json +9 -0
- package/node_modules/@llblab/pi-actors/dist/fixtures/protocol/control-endpoint.json +6 -0
- package/node_modules/@llblab/pi-actors/dist/fixtures/protocol/control-record.json +9 -0
- package/node_modules/@llblab/pi-actors/dist/fixtures/protocol/recipe-summary.json +8 -0
- package/node_modules/@llblab/pi-actors/dist/fixtures/protocol/run-state.json +10 -0
- package/node_modules/@llblab/pi-actors/dist/fixtures/protocol/trace-event.json +9 -0
- package/node_modules/@llblab/pi-actors/dist/index.d.ts +7 -0
- package/node_modules/@llblab/pi-actors/dist/index.js +17 -0
- package/node_modules/@llblab/pi-actors/dist/lib/async-runs.d.ts +146 -0
- package/node_modules/@llblab/pi-actors/dist/lib/async-runs.js +800 -0
- package/node_modules/@llblab/pi-actors/dist/lib/automatic-review-runtime.d.ts +20 -0
- package/node_modules/@llblab/pi-actors/dist/lib/automatic-review-runtime.js +103 -0
- package/node_modules/@llblab/pi-actors/dist/lib/command-templates.d.ts +85 -0
- package/node_modules/@llblab/pi-actors/dist/lib/command-templates.js +804 -0
- package/node_modules/@llblab/pi-actors/dist/lib/config.d.ts +34 -0
- package/node_modules/@llblab/pi-actors/dist/lib/config.js +216 -0
- package/node_modules/@llblab/pi-actors/dist/lib/control-projection.d.ts +20 -0
- package/node_modules/@llblab/pi-actors/dist/lib/control-projection.js +66 -0
- package/node_modules/@llblab/pi-actors/dist/lib/control.d.ts +15 -0
- package/node_modules/@llblab/pi-actors/dist/lib/control.js +97 -0
- package/node_modules/@llblab/pi-actors/dist/lib/draft-consolidation-transaction.d.ts +65 -0
- package/node_modules/@llblab/pi-actors/dist/lib/draft-consolidation-transaction.js +610 -0
- package/node_modules/@llblab/pi-actors/dist/lib/draft-consolidation.d.ts +35 -0
- package/node_modules/@llblab/pi-actors/dist/lib/draft-consolidation.js +126 -0
- package/node_modules/@llblab/pi-actors/dist/lib/draft-review.d.ts +56 -0
- package/node_modules/@llblab/pi-actors/dist/lib/draft-review.js +254 -0
- package/node_modules/@llblab/pi-actors/dist/lib/draft-sleep.d.ts +65 -0
- package/node_modules/@llblab/pi-actors/dist/lib/draft-sleep.js +467 -0
- package/node_modules/@llblab/pi-actors/dist/lib/execution-output.d.ts +25 -0
- package/node_modules/@llblab/pi-actors/dist/lib/execution-output.js +88 -0
- package/node_modules/@llblab/pi-actors/dist/lib/execution-sessions.d.ts +17 -0
- package/node_modules/@llblab/pi-actors/dist/lib/execution-sessions.js +85 -0
- package/node_modules/@llblab/pi-actors/dist/lib/execution.d.ts +99 -0
- package/node_modules/@llblab/pi-actors/dist/lib/execution.js +725 -0
- package/node_modules/@llblab/pi-actors/dist/lib/extension-runtime.d.ts +21 -0
- package/node_modules/@llblab/pi-actors/dist/lib/extension-runtime.js +141 -0
- package/node_modules/@llblab/pi-actors/dist/lib/file-state.d.ts +18 -0
- package/node_modules/@llblab/pi-actors/dist/lib/file-state.js +310 -0
- package/node_modules/@llblab/pi-actors/dist/lib/identity.d.ts +9 -0
- package/node_modules/@llblab/pi-actors/dist/lib/identity.js +27 -0
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-actions.d.ts +16 -0
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-actions.js +57 -0
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-command.d.ts +7 -0
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-command.js +37 -0
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-overlay.d.ts +100 -0
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-overlay.js +824 -0
- package/node_modules/@llblab/pi-actors/dist/lib/inspector.d.ts +20 -0
- package/node_modules/@llblab/pi-actors/dist/lib/inspector.js +136 -0
- package/node_modules/@llblab/pi-actors/dist/lib/limits.d.ts +28 -0
- package/node_modules/@llblab/pi-actors/dist/lib/limits.js +28 -0
- package/node_modules/@llblab/pi-actors/dist/lib/model-context.d.ts +56 -0
- package/node_modules/@llblab/pi-actors/dist/lib/model-context.js +220 -0
- package/node_modules/@llblab/pi-actors/dist/lib/observability.d.ts +186 -0
- package/node_modules/@llblab/pi-actors/dist/lib/observability.js +951 -0
- package/node_modules/@llblab/pi-actors/dist/lib/paths.d.ts +27 -0
- package/node_modules/@llblab/pi-actors/dist/lib/paths.js +72 -0
- package/node_modules/@llblab/pi-actors/dist/lib/pi.d.ts +19 -0
- package/node_modules/@llblab/pi-actors/dist/lib/pi.js +21 -0
- package/node_modules/@llblab/pi-actors/dist/lib/preflight-diagnostics.d.ts +27 -0
- package/node_modules/@llblab/pi-actors/dist/lib/preflight-diagnostics.js +86 -0
- package/node_modules/@llblab/pi-actors/dist/lib/prompts.d.ts +24 -0
- package/node_modules/@llblab/pi-actors/dist/lib/prompts.js +49 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipe-control.d.ts +7 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipe-control.js +43 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipes-context.d.ts +36 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipes-context.js +197 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipes-discovery.d.ts +77 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipes-discovery.js +783 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipes-references.d.ts +113 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipes-references.js +1108 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipes-usage.d.ts +21 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipes-usage.js +494 -0
- package/node_modules/@llblab/pi-actors/dist/lib/registry.d.ts +67 -0
- package/node_modules/@llblab/pi-actors/dist/lib/registry.js +504 -0
- package/node_modules/@llblab/pi-actors/dist/lib/review-control.d.ts +14 -0
- package/node_modules/@llblab/pi-actors/dist/lib/review-control.js +110 -0
- package/node_modules/@llblab/pi-actors/dist/lib/review-diagnostics.d.ts +11 -0
- package/node_modules/@llblab/pi-actors/dist/lib/review-diagnostics.js +148 -0
- package/node_modules/@llblab/pi-actors/dist/lib/review-projection.d.ts +14 -0
- package/node_modules/@llblab/pi-actors/dist/lib/review-projection.js +166 -0
- package/node_modules/@llblab/pi-actors/dist/lib/run-evidence-policy.d.ts +95 -0
- package/node_modules/@llblab/pi-actors/dist/lib/run-evidence-policy.js +177 -0
- package/node_modules/@llblab/pi-actors/dist/lib/run-ui-runtime.d.ts +18 -0
- package/node_modules/@llblab/pi-actors/dist/lib/run-ui-runtime.js +125 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-artifacts.d.ts +21 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-artifacts.js +68 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-control-delivery.d.ts +28 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-control-delivery.js +150 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-control.d.ts +21 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-control.js +89 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-controls.d.ts +39 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-controls.js +283 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-identity.d.ts +5 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-identity.js +11 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-index.d.ts +27 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-index.js +142 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-ownership.d.ts +7 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-ownership.js +96 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-parent-teardown.d.ts +51 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-parent-teardown.js +172 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-process.d.ts +22 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-process.js +125 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-retention.d.ts +18 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-retention.js +108 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-start.d.ts +12 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-start.js +68 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-status.d.ts +10 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-status.js +68 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-trace.d.ts +48 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-trace.js +491 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runtime-identity.d.ts +7 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runtime-identity.js +35 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runtime-triage.d.ts +29 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runtime-triage.js +60 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runtime.d.ts +69 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runtime.js +339 -0
- package/node_modules/@llblab/pi-actors/dist/lib/schema.d.ts +60 -0
- package/node_modules/@llblab/pi-actors/dist/lib/schema.js +428 -0
- package/node_modules/@llblab/pi-actors/dist/lib/session-evidence.d.ts +45 -0
- package/node_modules/@llblab/pi-actors/dist/lib/session-evidence.js +204 -0
- package/node_modules/@llblab/pi-actors/dist/lib/state-readers.d.ts +21 -0
- package/node_modules/@llblab/pi-actors/dist/lib/state-readers.js +74 -0
- package/node_modules/@llblab/pi-actors/dist/lib/temp.d.ts +10 -0
- package/node_modules/@llblab/pi-actors/dist/lib/temp.js +90 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tool-review-lineage-transaction.d.ts +27 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tool-review-lineage-transaction.js +597 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tool-review-lineage.d.ts +24 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tool-review-lineage.js +98 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tool-review-scheduler.d.ts +80 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tool-review-scheduler.js +494 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tool-review-transaction.d.ts +50 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tool-review-transaction.js +362 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tool-review.d.ts +56 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tool-review.js +197 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-access.d.ts +19 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-access.js +44 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-inspect.d.ts +15 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-inspect.js +532 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-local.d.ts +17 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-local.js +191 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-message.d.ts +9 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-message.js +139 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-register.d.ts +18 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-register.js +41 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-response.d.ts +20 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-response.js +243 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-spawn.d.ts +15 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-spawn.js +133 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools.d.ts +28 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools.js +49 -0
- package/node_modules/@llblab/pi-actors/dist/lib/trace-projection.d.ts +22 -0
- package/node_modules/@llblab/pi-actors/dist/lib/trace-projection.js +231 -0
- package/node_modules/@llblab/pi-actors/dist/pi-actors/index.js +1 -0
- package/node_modules/@llblab/pi-actors/dist/scripts/async-runner.mjs +555 -0
- package/node_modules/@llblab/pi-actors/dist/scripts/build-dist.mjs +60 -0
- package/node_modules/@llblab/pi-actors/dist/scripts/conformance.mjs +63 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/SKILL.md +126 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/command-validate.json +13 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/jsonl-tail.json +10 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/recipe-validate.json +11 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/resource-locker-snapshot.json +11 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/resource-locker.json +25 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/run-ops-snapshot.json +15 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/run-state-files.json +13 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/run-summary.json +9 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/references/diagnostics.md +44 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/references/persistent-tools.md +76 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/references/recipes.md +51 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/references/runs.md +41 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/scripts/resource-locker.mjs +425 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/scripts/run-utils.mjs +164 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/scripts/validate-recipe.mjs +370 -0
- package/node_modules/@llblab/pi-actors/dist/skills/artifacts/SKILL.md +33 -0
- package/node_modules/@llblab/pi-actors/dist/skills/artifacts/recipes/bundle.json +77 -0
- package/node_modules/@llblab/pi-actors/dist/skills/artifacts/recipes/file-write.json +14 -0
- package/node_modules/@llblab/pi-actors/dist/skills/artifacts/recipes/manifest.json +14 -0
- package/node_modules/@llblab/pi-actors/dist/skills/artifacts/recipes/report.json +39 -0
- package/node_modules/@llblab/pi-actors/dist/skills/artifacts/recipes/write.json +53 -0
- package/node_modules/@llblab/pi-actors/dist/skills/artifacts/scripts/artifact-utils.mjs +63 -0
- package/node_modules/@llblab/pi-actors/dist/skills/music-player/SKILL.md +57 -0
- package/node_modules/@llblab/pi-actors/dist/skills/music-player/genapps/music-player.mjs +360 -0
- package/node_modules/@llblab/pi-actors/dist/skills/music-player/recipes/playback.json +29 -0
- package/node_modules/@llblab/pi-actors/dist/skills/music-player/scripts/playback-client.mjs +143 -0
- package/node_modules/@llblab/pi-actors/dist/skills/music-player/scripts/playback.mjs +1446 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/SKILL.md +37 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/changelog-head.json +11 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/changelog-section.json +11 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/docs-maintenance.json +66 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/git-log.json +11 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/git-status.json +9 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/markdown-index.json +14 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/package-summary.json +9 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/release-readiness.json +115 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/release-summary.json +74 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/repo-health.json +75 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/run-ops.json +56 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/skill-summary.json +11 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/scripts/project-utils.mjs +89 -0
- package/node_modules/@llblab/pi-actors/dist/skills/recipe-memory/SKILL.md +36 -0
- package/node_modules/@llblab/pi-actors/dist/skills/recipe-memory/recipes/draft-review.json +14 -0
- package/node_modules/@llblab/pi-actors/dist/skills/recipe-memory/recipes/tool-review.json +14 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/SKILL.md +84 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/architect.json +82 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/checkpoint-continuation.json +51 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/development-tasking.json +67 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/lens-review.json +63 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/quorum-review.json +65 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/research-synthesis.json +81 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/review-readiness.json +59 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-artifact.json +21 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-checkpoint.json +21 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-conflict-report.json +19 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-contradiction-map.json +20 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-critic.json +22 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-evidence-map.json +20 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-followup.json +21 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-judge.json +22 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-merge.json +24 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-normalize.json +20 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-plan.json +20 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-preflight.json +18 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-prompt.json +16 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-prompts.json +39 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-quorum.json +31 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-review-coordinator.json +170 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-review.json +26 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-task-card.json +22 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-tools.json +15 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-verify.json +23 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/references/development-swarm.md +189 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/references/review-swarms.md +115 -0
- package/node_modules/@llblab/pi-actors/docs/README.md +20 -0
- package/node_modules/@llblab/pi-actors/docs/actor-inspector.md +50 -0
- package/node_modules/@llblab/pi-actors/docs/async-runs.md +141 -0
- package/node_modules/@llblab/pi-actors/docs/command-templates.md +321 -0
- package/node_modules/@llblab/pi-actors/docs/recipe-library.md +89 -0
- package/node_modules/@llblab/pi-actors/docs/releasing.md +28 -0
- package/node_modules/@llblab/pi-actors/docs/template-recipes.md +175 -0
- package/node_modules/@llblab/pi-actors/docs/tool-registry.md +90 -0
- package/node_modules/@llblab/pi-actors/fixtures/protocol/artifact-manifest.json +9 -0
- package/node_modules/@llblab/pi-actors/fixtures/protocol/control-endpoint.json +6 -0
- package/node_modules/@llblab/pi-actors/fixtures/protocol/control-record.json +9 -0
- package/node_modules/@llblab/pi-actors/fixtures/protocol/recipe-summary.json +8 -0
- package/node_modules/@llblab/pi-actors/fixtures/protocol/run-state.json +10 -0
- package/node_modules/@llblab/pi-actors/fixtures/protocol/trace-event.json +9 -0
- package/node_modules/@llblab/pi-actors/index.ts +30 -0
- package/node_modules/@llblab/pi-actors/lib/async-runs.ts +1245 -0
- package/node_modules/@llblab/pi-actors/lib/automatic-review-runtime.ts +148 -0
- package/node_modules/@llblab/pi-actors/lib/command-templates.ts +1116 -0
- package/node_modules/@llblab/pi-actors/lib/config.ts +261 -0
- package/node_modules/@llblab/pi-actors/lib/control-projection.ts +105 -0
- package/node_modules/@llblab/pi-actors/lib/control.ts +117 -0
- package/node_modules/@llblab/pi-actors/lib/draft-consolidation-transaction.ts +821 -0
- package/node_modules/@llblab/pi-actors/lib/draft-consolidation.ts +181 -0
- package/node_modules/@llblab/pi-actors/lib/draft-review.ts +325 -0
- package/node_modules/@llblab/pi-actors/lib/draft-sleep.ts +575 -0
- package/node_modules/@llblab/pi-actors/lib/execution-output.ts +123 -0
- package/node_modules/@llblab/pi-actors/lib/execution-sessions.ts +111 -0
- package/node_modules/@llblab/pi-actors/lib/execution.ts +1153 -0
- package/node_modules/@llblab/pi-actors/lib/extension-runtime.ts +181 -0
- package/node_modules/@llblab/pi-actors/lib/file-state.ts +306 -0
- package/node_modules/@llblab/pi-actors/lib/identity.ts +29 -0
- package/node_modules/@llblab/pi-actors/lib/inspector-actions.ts +79 -0
- package/node_modules/@llblab/pi-actors/lib/inspector-command.ts +54 -0
- package/node_modules/@llblab/pi-actors/lib/inspector-overlay.ts +901 -0
- package/node_modules/@llblab/pi-actors/lib/inspector.ts +204 -0
- package/node_modules/@llblab/pi-actors/lib/limits.ts +29 -0
- package/node_modules/@llblab/pi-actors/lib/model-context.ts +359 -0
- package/node_modules/@llblab/pi-actors/lib/observability.ts +1337 -0
- package/node_modules/@llblab/pi-actors/lib/paths.ts +111 -0
- package/node_modules/@llblab/pi-actors/lib/pi.ts +47 -0
- package/node_modules/@llblab/pi-actors/lib/preflight-diagnostics.ts +132 -0
- package/node_modules/@llblab/pi-actors/lib/prompts.ts +69 -0
- package/node_modules/@llblab/pi-actors/lib/recipe-control.ts +52 -0
- package/node_modules/@llblab/pi-actors/lib/recipes-context.ts +268 -0
- package/node_modules/@llblab/pi-actors/lib/recipes-discovery.ts +1060 -0
- package/node_modules/@llblab/pi-actors/lib/recipes-references.ts +1598 -0
- package/node_modules/@llblab/pi-actors/lib/recipes-usage.ts +638 -0
- package/node_modules/@llblab/pi-actors/lib/registry.ts +806 -0
- package/node_modules/@llblab/pi-actors/lib/review-control.ts +136 -0
- package/node_modules/@llblab/pi-actors/lib/review-diagnostics.ts +164 -0
- package/node_modules/@llblab/pi-actors/lib/review-projection.ts +196 -0
- package/node_modules/@llblab/pi-actors/lib/run-evidence-policy.ts +242 -0
- package/node_modules/@llblab/pi-actors/lib/run-ui-runtime.ts +155 -0
- package/node_modules/@llblab/pi-actors/lib/runs-artifacts.ts +96 -0
- package/node_modules/@llblab/pi-actors/lib/runs-control-delivery.ts +209 -0
- package/node_modules/@llblab/pi-actors/lib/runs-control.ts +148 -0
- package/node_modules/@llblab/pi-actors/lib/runs-controls.ts +282 -0
- package/node_modules/@llblab/pi-actors/lib/runs-identity.ts +14 -0
- package/node_modules/@llblab/pi-actors/lib/runs-index.ts +192 -0
- package/node_modules/@llblab/pi-actors/lib/runs-ownership.ts +136 -0
- package/node_modules/@llblab/pi-actors/lib/runs-parent-teardown.ts +257 -0
- package/node_modules/@llblab/pi-actors/lib/runs-process.ts +174 -0
- package/node_modules/@llblab/pi-actors/lib/runs-retention.ts +140 -0
- package/node_modules/@llblab/pi-actors/lib/runs-start.ts +113 -0
- package/node_modules/@llblab/pi-actors/lib/runs-status.ts +101 -0
- package/node_modules/@llblab/pi-actors/lib/runs-trace.ts +611 -0
- package/node_modules/@llblab/pi-actors/lib/runtime-identity.ts +39 -0
- package/node_modules/@llblab/pi-actors/lib/runtime-triage.ts +106 -0
- package/node_modules/@llblab/pi-actors/lib/runtime.ts +430 -0
- package/node_modules/@llblab/pi-actors/lib/schema.ts +525 -0
- package/node_modules/@llblab/pi-actors/lib/session-evidence.ts +302 -0
- package/node_modules/@llblab/pi-actors/lib/state-readers.ts +93 -0
- package/node_modules/@llblab/pi-actors/lib/temp.ts +99 -0
- package/node_modules/@llblab/pi-actors/lib/tool-review-lineage-transaction.ts +881 -0
- package/node_modules/@llblab/pi-actors/lib/tool-review-lineage.ts +145 -0
- package/node_modules/@llblab/pi-actors/lib/tool-review-scheduler.ts +635 -0
- package/node_modules/@llblab/pi-actors/lib/tool-review-transaction.ts +563 -0
- package/node_modules/@llblab/pi-actors/lib/tool-review.ts +270 -0
- package/node_modules/@llblab/pi-actors/lib/tools-access.ts +68 -0
- package/node_modules/@llblab/pi-actors/lib/tools-inspect.ts +673 -0
- package/node_modules/@llblab/pi-actors/lib/tools-local.ts +303 -0
- package/node_modules/@llblab/pi-actors/lib/tools-message.ts +176 -0
- package/node_modules/@llblab/pi-actors/lib/tools-register.ts +63 -0
- package/node_modules/@llblab/pi-actors/lib/tools-response.ts +285 -0
- package/node_modules/@llblab/pi-actors/lib/tools-spawn.ts +212 -0
- package/node_modules/@llblab/pi-actors/lib/tools.ts +88 -0
- package/node_modules/@llblab/pi-actors/lib/trace-projection.ts +306 -0
- package/node_modules/@llblab/pi-actors/package.json +76 -0
- package/node_modules/@llblab/pi-actors/scripts/async-runner.mjs +555 -0
- package/node_modules/@llblab/pi-actors/scripts/build-dist.mjs +60 -0
- package/node_modules/@llblab/pi-actors/scripts/conformance.mjs +63 -0
- package/node_modules/@llblab/pi-actors/skills/actors/SKILL.md +126 -0
- package/node_modules/@llblab/pi-actors/skills/actors/recipes/command-validate.json +13 -0
- package/node_modules/@llblab/pi-actors/skills/actors/recipes/jsonl-tail.json +10 -0
- package/node_modules/@llblab/pi-actors/skills/actors/recipes/recipe-validate.json +11 -0
- package/node_modules/@llblab/pi-actors/skills/actors/recipes/resource-locker-snapshot.json +11 -0
- package/node_modules/@llblab/pi-actors/skills/actors/recipes/resource-locker.json +25 -0
- package/node_modules/@llblab/pi-actors/skills/actors/recipes/run-ops-snapshot.json +15 -0
- package/node_modules/@llblab/pi-actors/skills/actors/recipes/run-state-files.json +13 -0
- package/node_modules/@llblab/pi-actors/skills/actors/recipes/run-summary.json +9 -0
- package/node_modules/@llblab/pi-actors/skills/actors/references/diagnostics.md +44 -0
- package/node_modules/@llblab/pi-actors/skills/actors/references/persistent-tools.md +76 -0
- package/node_modules/@llblab/pi-actors/skills/actors/references/recipes.md +51 -0
- package/node_modules/@llblab/pi-actors/skills/actors/references/runs.md +41 -0
- package/node_modules/@llblab/pi-actors/skills/actors/scripts/resource-locker.mjs +425 -0
- package/node_modules/@llblab/pi-actors/skills/actors/scripts/run-utils.mjs +164 -0
- package/node_modules/@llblab/pi-actors/skills/actors/scripts/validate-recipe.mjs +370 -0
- package/node_modules/@llblab/pi-actors/skills/artifacts/SKILL.md +33 -0
- package/node_modules/@llblab/pi-actors/skills/artifacts/recipes/bundle.json +77 -0
- package/node_modules/@llblab/pi-actors/skills/artifacts/recipes/file-write.json +14 -0
- package/node_modules/@llblab/pi-actors/skills/artifacts/recipes/manifest.json +14 -0
- package/node_modules/@llblab/pi-actors/skills/artifacts/recipes/report.json +39 -0
- package/node_modules/@llblab/pi-actors/skills/artifacts/recipes/write.json +53 -0
- package/node_modules/@llblab/pi-actors/skills/artifacts/scripts/artifact-utils.mjs +63 -0
- package/node_modules/@llblab/pi-actors/skills/music-player/SKILL.md +57 -0
- package/node_modules/@llblab/pi-actors/skills/music-player/genapps/music-player.mjs +360 -0
- package/node_modules/@llblab/pi-actors/skills/music-player/recipes/playback.json +29 -0
- package/node_modules/@llblab/pi-actors/skills/music-player/scripts/playback-client.mjs +143 -0
- package/node_modules/@llblab/pi-actors/skills/music-player/scripts/playback.mjs +1446 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/SKILL.md +37 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/changelog-head.json +11 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/changelog-section.json +11 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/docs-maintenance.json +66 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/git-log.json +11 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/git-status.json +9 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/markdown-index.json +14 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/package-summary.json +9 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/release-readiness.json +115 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/release-summary.json +74 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/repo-health.json +75 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/run-ops.json +56 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/skill-summary.json +11 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/scripts/project-utils.mjs +89 -0
- package/node_modules/@llblab/pi-actors/skills/recipe-memory/SKILL.md +36 -0
- package/node_modules/@llblab/pi-actors/skills/recipe-memory/recipes/draft-review.json +14 -0
- package/node_modules/@llblab/pi-actors/skills/recipe-memory/recipes/tool-review.json +14 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/SKILL.md +84 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/architect.json +82 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/checkpoint-continuation.json +51 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/development-tasking.json +67 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/lens-review.json +63 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/quorum-review.json +65 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/research-synthesis.json +81 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/review-readiness.json +59 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-artifact.json +21 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-checkpoint.json +21 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-conflict-report.json +19 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-contradiction-map.json +20 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-critic.json +22 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-evidence-map.json +20 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-followup.json +21 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-judge.json +22 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-merge.json +24 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-normalize.json +20 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-plan.json +20 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-preflight.json +18 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-prompt.json +16 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-prompts.json +39 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-quorum.json +31 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-review-coordinator.json +170 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-review.json +26 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-task-card.json +22 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-tools.json +15 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-verify.json +23 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/references/development-swarm.md +189 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/references/review-swarms.md +115 -0
- package/node_modules/@llblab/pi-codex-usage/AGENTS.md +17 -0
- package/node_modules/@llblab/pi-codex-usage/BACKLOG.md +8 -0
- package/node_modules/@llblab/pi-codex-usage/CHANGELOG.md +80 -0
- package/node_modules/@llblab/pi-codex-usage/LICENSE +22 -0
- package/node_modules/@llblab/pi-codex-usage/README.md +113 -0
- package/node_modules/@llblab/pi-codex-usage/banner.jpg +0 -0
- package/node_modules/@llblab/pi-codex-usage/index.ts +1525 -0
- package/node_modules/@llblab/pi-codex-usage/package.json +59 -0
- package/node_modules/@llblab/pi-grow-loop/AGENTS.md +56 -0
- package/node_modules/@llblab/pi-grow-loop/BACKLOG.md +3 -0
- package/node_modules/@llblab/pi-grow-loop/CHANGELOG.md +126 -0
- package/node_modules/@llblab/pi-grow-loop/README.md +216 -0
- package/node_modules/@llblab/pi-grow-loop/banner.jpg +0 -0
- package/node_modules/@llblab/pi-grow-loop/index.ts +219 -0
- package/node_modules/@llblab/pi-grow-loop/package.json +64 -0
- package/node_modules/@llblab/pi-grow-loop/skills/grow-loop/SKILL.md +131 -0
- package/node_modules/@llblab/pi-grow-loop/skills/while-true/SKILL.md +233 -0
- package/node_modules/@llblab/pi-telegram/AGENTS.md +157 -0
- package/node_modules/@llblab/pi-telegram/BACKLOG.md +15 -0
- package/node_modules/@llblab/pi-telegram/CHANGELOG.md +886 -0
- package/node_modules/@llblab/pi-telegram/README.md +330 -0
- package/node_modules/@llblab/pi-telegram/api/activity.ts +15 -0
- package/node_modules/@llblab/pi-telegram/api/commands.ts +11 -0
- package/node_modules/@llblab/pi-telegram/api/delivery.ts +21 -0
- package/node_modules/@llblab/pi-telegram/api/inbound.ts +14 -0
- package/node_modules/@llblab/pi-telegram/api/keyboard.ts +11 -0
- package/node_modules/@llblab/pi-telegram/api/outbound.ts +11 -0
- package/node_modules/@llblab/pi-telegram/api/sections.ts +17 -0
- package/node_modules/@llblab/pi-telegram/api/status.ts +12 -0
- package/node_modules/@llblab/pi-telegram/api/updates.ts +16 -0
- package/node_modules/@llblab/pi-telegram/api/voice.ts +24 -0
- package/node_modules/@llblab/pi-telegram/docs/README.md +25 -0
- package/node_modules/@llblab/pi-telegram/docs/activity.md +304 -0
- package/node_modules/@llblab/pi-telegram/docs/architecture.md +418 -0
- package/node_modules/@llblab/pi-telegram/docs/callback-namespaces.md +48 -0
- package/node_modules/@llblab/pi-telegram/docs/command-templates.md +365 -0
- package/node_modules/@llblab/pi-telegram/docs/compact-matrix-literal.md +176 -0
- package/node_modules/@llblab/pi-telegram/docs/delivery.md +225 -0
- package/node_modules/@llblab/pi-telegram/docs/generative-apps.md +310 -0
- package/node_modules/@llblab/pi-telegram/docs/inbound.md +136 -0
- package/node_modules/@llblab/pi-telegram/docs/multi-instance-bus.md +467 -0
- package/node_modules/@llblab/pi-telegram/docs/outbound.md +193 -0
- package/node_modules/@llblab/pi-telegram/docs/public-api.md +599 -0
- package/node_modules/@llblab/pi-telegram/docs/sections.md +452 -0
- package/node_modules/@llblab/pi-telegram/docs/ui-style.md +256 -0
- package/node_modules/@llblab/pi-telegram/docs/updates.md +171 -0
- package/node_modules/@llblab/pi-telegram/docs/voice.md +217 -0
- package/node_modules/@llblab/pi-telegram/index.ts +1336 -0
- package/node_modules/@llblab/pi-telegram/lib/activity-verbosity.ts +714 -0
- package/node_modules/@llblab/pi-telegram/lib/activity.ts +782 -0
- package/node_modules/@llblab/pi-telegram/lib/agent-messages.ts +121 -0
- package/node_modules/@llblab/pi-telegram/lib/bindings.ts +1129 -0
- package/node_modules/@llblab/pi-telegram/lib/bus-api.ts +379 -0
- package/node_modules/@llblab/pi-telegram/lib/bus-follower.ts +1941 -0
- package/node_modules/@llblab/pi-telegram/lib/bus-leader.ts +2119 -0
- package/node_modules/@llblab/pi-telegram/lib/bus-transport.ts +244 -0
- package/node_modules/@llblab/pi-telegram/lib/bus.ts +2645 -0
- package/node_modules/@llblab/pi-telegram/lib/command-templates.ts +954 -0
- package/node_modules/@llblab/pi-telegram/lib/commands.ts +1854 -0
- package/node_modules/@llblab/pi-telegram/lib/config.ts +1143 -0
- package/node_modules/@llblab/pi-telegram/lib/delivery.ts +891 -0
- package/node_modules/@llblab/pi-telegram/lib/generative-app-worker.mjs +104 -0
- package/node_modules/@llblab/pi-telegram/lib/generative-apps.ts +958 -0
- package/node_modules/@llblab/pi-telegram/lib/inbound.ts +824 -0
- package/node_modules/@llblab/pi-telegram/lib/journal.ts +3140 -0
- package/node_modules/@llblab/pi-telegram/lib/keyboard.ts +59 -0
- package/node_modules/@llblab/pi-telegram/lib/lifecycle.ts +623 -0
- package/node_modules/@llblab/pi-telegram/lib/locks.ts +1422 -0
- package/node_modules/@llblab/pi-telegram/lib/logs.ts +393 -0
- package/node_modules/@llblab/pi-telegram/lib/media.ts +921 -0
- package/node_modules/@llblab/pi-telegram/lib/menu-model.ts +1182 -0
- package/node_modules/@llblab/pi-telegram/lib/menu-queue.ts +926 -0
- package/node_modules/@llblab/pi-telegram/lib/menu-settings.ts +876 -0
- package/node_modules/@llblab/pi-telegram/lib/menu-status.ts +274 -0
- package/node_modules/@llblab/pi-telegram/lib/menu-thinking.ts +185 -0
- package/node_modules/@llblab/pi-telegram/lib/menu.ts +867 -0
- package/node_modules/@llblab/pi-telegram/lib/model.ts +672 -0
- package/node_modules/@llblab/pi-telegram/lib/outbound-attachments.ts +981 -0
- package/node_modules/@llblab/pi-telegram/lib/outbound-buttons.ts +331 -0
- package/node_modules/@llblab/pi-telegram/lib/outbound-markup.ts +515 -0
- package/node_modules/@llblab/pi-telegram/lib/outbound-voice.ts +285 -0
- package/node_modules/@llblab/pi-telegram/lib/outbound.ts +1007 -0
- package/node_modules/@llblab/pi-telegram/lib/ownership.ts +298 -0
- package/node_modules/@llblab/pi-telegram/lib/paths.ts +127 -0
- package/node_modules/@llblab/pi-telegram/lib/pi.ts +197 -0
- package/node_modules/@llblab/pi-telegram/lib/polling.ts +1588 -0
- package/node_modules/@llblab/pi-telegram/lib/preview.ts +846 -0
- package/node_modules/@llblab/pi-telegram/lib/prompt-templates.ts +158 -0
- package/node_modules/@llblab/pi-telegram/lib/prompts.ts +218 -0
- package/node_modules/@llblab/pi-telegram/lib/queue.ts +3075 -0
- package/node_modules/@llblab/pi-telegram/lib/recovery.ts +464 -0
- package/node_modules/@llblab/pi-telegram/lib/rendering.ts +1213 -0
- package/node_modules/@llblab/pi-telegram/lib/replies.ts +892 -0
- package/node_modules/@llblab/pi-telegram/lib/routing.ts +2889 -0
- package/node_modules/@llblab/pi-telegram/lib/runtime.ts +628 -0
- package/node_modules/@llblab/pi-telegram/lib/sections.ts +710 -0
- package/node_modules/@llblab/pi-telegram/lib/setup.ts +220 -0
- package/node_modules/@llblab/pi-telegram/lib/skills.ts +21 -0
- package/node_modules/@llblab/pi-telegram/lib/status.ts +1550 -0
- package/node_modules/@llblab/pi-telegram/lib/sync.ts +883 -0
- package/node_modules/@llblab/pi-telegram/lib/target.ts +49 -0
- package/node_modules/@llblab/pi-telegram/lib/telegram-api.ts +1747 -0
- package/node_modules/@llblab/pi-telegram/lib/text-groups.ts +487 -0
- package/node_modules/@llblab/pi-telegram/lib/thread-reconciler.ts +1002 -0
- package/node_modules/@llblab/pi-telegram/lib/threads.ts +3183 -0
- package/node_modules/@llblab/pi-telegram/lib/time-injection.ts +78 -0
- package/node_modules/@llblab/pi-telegram/lib/turns.ts +753 -0
- package/node_modules/@llblab/pi-telegram/lib/updates.ts +4950 -0
- package/node_modules/@llblab/pi-telegram/lib/voice.ts +340 -0
- package/node_modules/@llblab/pi-telegram/package.json +83 -0
- package/node_modules/@llblab/pi-telegram/screenshot.png +0 -0
- package/node_modules/@llblab/pi-telegram/scripts/check-downgrade.mjs +435 -0
- package/node_modules/@llblab/pi-telegram/skills/generated-control-surface/SKILL.md +241 -0
- package/node_modules/@llblab/pi-telegram/skills/generative-apps/SKILL.md +114 -0
- package/node_modules/@llblab/pi-telegram/skills/telegram-bridge/SKILL.md +149 -0
- package/package.json +67 -0
|
@@ -0,0 +1,1153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registered tool execution runtime
|
|
3
|
+
* Zones: tool execution, command templates, output formatting
|
|
4
|
+
* Owns command-template invocation execution and pi tool-result payload formatting
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { readFile } from "node:fs/promises";
|
|
8
|
+
|
|
9
|
+
import * as CommandTemplates from "./command-templates.ts";
|
|
10
|
+
import type { RegisteredTool } from "./config.ts";
|
|
11
|
+
import {
|
|
12
|
+
formatFailureOutput,
|
|
13
|
+
formatOutput,
|
|
14
|
+
formatToolText,
|
|
15
|
+
} from "./execution-output.ts";
|
|
16
|
+
import * as Schema from "./schema.ts";
|
|
17
|
+
|
|
18
|
+
export interface ToolExecOptions {
|
|
19
|
+
actorRecipeContext?: CommandTemplates.CommandTemplateActorRecipeContext;
|
|
20
|
+
evidenceContext?: {
|
|
21
|
+
acceptOutput?: "review_evidence";
|
|
22
|
+
label?: string;
|
|
23
|
+
repeatIndex?: string;
|
|
24
|
+
};
|
|
25
|
+
cwd?: string;
|
|
26
|
+
signal?: AbortSignal;
|
|
27
|
+
stdin?: string;
|
|
28
|
+
timeout?: number;
|
|
29
|
+
retry?: number;
|
|
30
|
+
captureDir?: string;
|
|
31
|
+
captureLimitBytes?: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface ToolExecResult {
|
|
35
|
+
stdout: string;
|
|
36
|
+
stderr: string;
|
|
37
|
+
code: number;
|
|
38
|
+
killed: boolean;
|
|
39
|
+
stdoutBytes?: number;
|
|
40
|
+
stderrBytes?: number;
|
|
41
|
+
stdoutFile?: string;
|
|
42
|
+
stderrFile?: string;
|
|
43
|
+
evidenceRef?: string;
|
|
44
|
+
stdoutTruncated?: boolean;
|
|
45
|
+
stderrTruncated?: boolean;
|
|
46
|
+
/** Complete internal stdout for downstream pipeline stdin; never returned to model-facing output. */
|
|
47
|
+
pipelineStdout?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface BranchReport {
|
|
51
|
+
code: number;
|
|
52
|
+
command: string;
|
|
53
|
+
failureReason?: string;
|
|
54
|
+
killed: boolean;
|
|
55
|
+
label: string;
|
|
56
|
+
status: "done" | "failed" | "timeout";
|
|
57
|
+
stderr?: string;
|
|
58
|
+
stderrBytes: number;
|
|
59
|
+
stderrCapturedBytes: number;
|
|
60
|
+
stderrFile?: string;
|
|
61
|
+
stderrTruncated?: boolean;
|
|
62
|
+
stdout?: string;
|
|
63
|
+
stdoutBytes: number;
|
|
64
|
+
stdoutCapturedBytes: number;
|
|
65
|
+
stdoutFile?: string;
|
|
66
|
+
stdoutTruncated?: boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface SoftQuorumReport {
|
|
70
|
+
coverage: number;
|
|
71
|
+
degraded: boolean;
|
|
72
|
+
done: number;
|
|
73
|
+
expected: number;
|
|
74
|
+
failed: number;
|
|
75
|
+
usable: boolean;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface RegisteredToolExecutionResult {
|
|
79
|
+
content: Array<{ type: "text"; text: string }>;
|
|
80
|
+
details: {
|
|
81
|
+
branches?: BranchReport[];
|
|
82
|
+
code: number;
|
|
83
|
+
command: string;
|
|
84
|
+
fullOutputPath?: string;
|
|
85
|
+
killed: boolean;
|
|
86
|
+
launch_kind: "tool";
|
|
87
|
+
stderrBytes?: number;
|
|
88
|
+
stderrCapturedBytes?: number;
|
|
89
|
+
stderrFile?: string;
|
|
90
|
+
stderrTruncated?: boolean;
|
|
91
|
+
stdoutBytes?: number;
|
|
92
|
+
stdoutCapturedBytes?: number;
|
|
93
|
+
stdoutFile?: string;
|
|
94
|
+
stdoutTruncated?: boolean;
|
|
95
|
+
nonCriticalFailures?: Array<{
|
|
96
|
+
code: number;
|
|
97
|
+
command: string;
|
|
98
|
+
killed: boolean;
|
|
99
|
+
}>;
|
|
100
|
+
softQuorum?: SoftQuorumReport;
|
|
101
|
+
failureReason?: string;
|
|
102
|
+
template: CommandTemplates.CommandTemplateValue;
|
|
103
|
+
templateWarnings?: string[];
|
|
104
|
+
tool: string;
|
|
105
|
+
truncated: boolean;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export type RegisteredToolExec = (
|
|
110
|
+
command: string,
|
|
111
|
+
args: string[],
|
|
112
|
+
options?: ToolExecOptions,
|
|
113
|
+
) => Promise<ToolExecResult>;
|
|
114
|
+
|
|
115
|
+
const DEFAULT_MAX_PARALLEL_BRANCHES = 64;
|
|
116
|
+
|
|
117
|
+
type TemplateExecution = {
|
|
118
|
+
branches: BranchReport[];
|
|
119
|
+
commands: string[];
|
|
120
|
+
criticalFailure?: boolean;
|
|
121
|
+
failureScope?: CommandTemplates.CommandTemplateFailureScope;
|
|
122
|
+
failures: Array<{ code: number; command: string; killed: boolean }>;
|
|
123
|
+
result: ToolExecResult;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
function textContent(text: string) {
|
|
127
|
+
return { type: "text" as const, text };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function createTemplateConfig(
|
|
131
|
+
cfg: RegisteredTool,
|
|
132
|
+
): CommandTemplates.CommandTemplateObjectConfig {
|
|
133
|
+
if (!cfg.template)
|
|
134
|
+
throw new Error(`Tool "${cfg.name}" has no command template.`);
|
|
135
|
+
if (typeof cfg.template === "object" && !Array.isArray(cfg.template)) {
|
|
136
|
+
return {
|
|
137
|
+
...cfg.template,
|
|
138
|
+
args: cfg.template.args ?? cfg.args,
|
|
139
|
+
defaults: mergeDefaults(cfg.defaults, cfg.template.defaults),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return { args: cfg.args, defaults: cfg.defaults, template: cfg.template };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function quoteCommandDetailPart(value: string): string {
|
|
146
|
+
if (value === "") return "''";
|
|
147
|
+
if (/^[A-Za-z0-9_/:=.,@%+\-]+$/.test(value)) return value;
|
|
148
|
+
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function formatInvocationDetail(
|
|
152
|
+
invocation: CommandTemplates.CommandTemplateInvocation,
|
|
153
|
+
): string {
|
|
154
|
+
return [invocation.command, ...invocation.args]
|
|
155
|
+
.map(quoteCommandDetailPart)
|
|
156
|
+
.join(" ");
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function formatCommandDetail(commands: string[]): string {
|
|
160
|
+
return commands.length === 1 ? commands[0] : commands.join(" && ");
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function getExecutionFailureReason(
|
|
164
|
+
branches: BranchReport[],
|
|
165
|
+
softQuorum: SoftQuorumReport | undefined,
|
|
166
|
+
stderr: string,
|
|
167
|
+
): string {
|
|
168
|
+
if (/parallel branch quorum not met/.test(stderr)) {
|
|
169
|
+
return "parallel_quorum_not_met";
|
|
170
|
+
}
|
|
171
|
+
if (branches.length > 0 && softQuorum?.usable === false) {
|
|
172
|
+
return "all_branches_unusable";
|
|
173
|
+
}
|
|
174
|
+
return "command_failed";
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function mergeDefaults(
|
|
178
|
+
inherited: Record<string, unknown> | undefined,
|
|
179
|
+
own: Record<string, unknown> | undefined,
|
|
180
|
+
): Record<string, unknown> | undefined {
|
|
181
|
+
if (!inherited && !own) return undefined;
|
|
182
|
+
return { ...(inherited ?? {}), ...(own ?? {}) };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function getNodeLabel(
|
|
186
|
+
config: CommandTemplates.CommandTemplateConfig,
|
|
187
|
+
index?: number,
|
|
188
|
+
): string {
|
|
189
|
+
const normalized = CommandTemplates.normalizeCommandTemplateConfig(config);
|
|
190
|
+
if (normalized.label) return normalized.label;
|
|
191
|
+
return index === undefined ? "command" : `branch ${index + 1}`;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function getBranchStatus(result: ToolExecResult): BranchReport["status"] {
|
|
195
|
+
if (result.code === 0) return "done";
|
|
196
|
+
return result.killed ? "timeout" : "failed";
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const REVIEW_RESULT_MARKER = "ACTOR_REVIEW_RESULT";
|
|
200
|
+
|
|
201
|
+
export async function applyOutputAcceptancePolicy(
|
|
202
|
+
result: ToolExecResult,
|
|
203
|
+
output: string | undefined,
|
|
204
|
+
): Promise<ToolExecResult> {
|
|
205
|
+
if (result.code !== 0 || output !== "review_evidence") return result;
|
|
206
|
+
let semanticStdout = result.pipelineStdout ?? result.stdout;
|
|
207
|
+
if (result.pipelineStdout === undefined && result.stdoutTruncated) {
|
|
208
|
+
if (!result.stdoutFile) semanticStdout = "";
|
|
209
|
+
else {
|
|
210
|
+
try {
|
|
211
|
+
semanticStdout = await readFile(result.stdoutFile, "utf8");
|
|
212
|
+
} catch {
|
|
213
|
+
semanticStdout = "";
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const firstNonWhitespaceLine = semanticStdout
|
|
218
|
+
.split(/\r?\n/)
|
|
219
|
+
.find((line) => line.trim().length > 0);
|
|
220
|
+
if (firstNonWhitespaceLine?.trim() === REVIEW_RESULT_MARKER) return result;
|
|
221
|
+
return {
|
|
222
|
+
...result,
|
|
223
|
+
code: 65,
|
|
224
|
+
stderr: [
|
|
225
|
+
result.stderr,
|
|
226
|
+
`review evidence rejected: missing ${REVIEW_RESULT_MARKER} marker`,
|
|
227
|
+
].filter(Boolean).join("\n"),
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
async function resolvePipelineStdout(
|
|
232
|
+
result: ToolExecResult,
|
|
233
|
+
): Promise<string | undefined> {
|
|
234
|
+
let stdout = result.pipelineStdout ?? result.stdout;
|
|
235
|
+
if (result.pipelineStdout === undefined && result.stdoutTruncated) {
|
|
236
|
+
if (!result.stdoutFile) return undefined;
|
|
237
|
+
try {
|
|
238
|
+
stdout = await readFile(result.stdoutFile, "utf8");
|
|
239
|
+
} catch {
|
|
240
|
+
return undefined;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return result.evidenceRef
|
|
244
|
+
? `${stdout}\nACTOR_EVIDENCE_REF: ${result.evidenceRef}`
|
|
245
|
+
: stdout;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function rejectIncompletePipelineOutput(result: ToolExecResult): ToolExecResult {
|
|
249
|
+
return {
|
|
250
|
+
...result,
|
|
251
|
+
code: 74,
|
|
252
|
+
stderr: [
|
|
253
|
+
result.stderr,
|
|
254
|
+
`incomplete pipeline stdin: complete stdout unavailable${result.stdoutFile ? `; capture path unreadable: ${result.stdoutFile}` : ""}`,
|
|
255
|
+
].filter(Boolean).join("\n"),
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function getBranchFailureReason(
|
|
260
|
+
result: ToolExecResult,
|
|
261
|
+
): string | undefined {
|
|
262
|
+
if (result.code === 0) {
|
|
263
|
+
return result.stdout.trim() ? undefined : "empty_output";
|
|
264
|
+
}
|
|
265
|
+
if (result.killed) return "timeout_or_killed";
|
|
266
|
+
return result.stderr.trim() ? "nonzero_exit" : "nonzero_exit_empty_stderr";
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function createBranchReport(
|
|
270
|
+
label: string,
|
|
271
|
+
command: string,
|
|
272
|
+
result: ToolExecResult,
|
|
273
|
+
): BranchReport {
|
|
274
|
+
const failureReason = getBranchFailureReason(result);
|
|
275
|
+
return {
|
|
276
|
+
code: result.code,
|
|
277
|
+
command,
|
|
278
|
+
...(failureReason ? { failureReason } : {}),
|
|
279
|
+
killed: result.killed,
|
|
280
|
+
label,
|
|
281
|
+
status: getBranchStatus(result),
|
|
282
|
+
...(result.stderr ? { stderr: result.stderr.slice(-1000) } : {}),
|
|
283
|
+
stderrBytes: result.stderrBytes ?? Buffer.byteLength(result.stderr),
|
|
284
|
+
stderrCapturedBytes: Buffer.byteLength(result.stderr),
|
|
285
|
+
...(result.stderrFile ? { stderrFile: result.stderrFile } : {}),
|
|
286
|
+
...(result.stderrTruncated ? { stderrTruncated: true } : {}),
|
|
287
|
+
...(result.stdout ? { stdout: result.stdout.slice(-1000) } : {}),
|
|
288
|
+
stdoutBytes: result.stdoutBytes ?? Buffer.byteLength(result.stdout),
|
|
289
|
+
stdoutCapturedBytes: Buffer.byteLength(result.stdout),
|
|
290
|
+
...(result.stdoutFile ? { stdoutFile: result.stdoutFile } : {}),
|
|
291
|
+
...(result.stdoutTruncated ? { stdoutTruncated: true } : {}),
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function isUsableBranch(branch: BranchReport): boolean {
|
|
296
|
+
return (
|
|
297
|
+
branch.status === "done" &&
|
|
298
|
+
branch.stdoutBytes > 0 &&
|
|
299
|
+
branch.stdoutTruncated !== true
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function createSoftQuorum(
|
|
304
|
+
branches: BranchReport[],
|
|
305
|
+
): SoftQuorumReport | undefined {
|
|
306
|
+
if (branches.length === 0) return undefined;
|
|
307
|
+
const done = branches.filter((branch) => branch.status === "done").length;
|
|
308
|
+
const failed = branches.length - done;
|
|
309
|
+
return {
|
|
310
|
+
coverage: done / branches.length,
|
|
311
|
+
degraded: failed > 0,
|
|
312
|
+
done,
|
|
313
|
+
expected: branches.length,
|
|
314
|
+
failed,
|
|
315
|
+
usable: branches.some(isUsableBranch),
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function countUsableBranches(branches: BranchReport[]): number {
|
|
320
|
+
return branches.filter(isUsableBranch).length;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function getMaxParallelBranches(): number {
|
|
324
|
+
const raw = Number(process.env.PI_ACTORS_MAX_PARALLEL_BRANCHES ?? "");
|
|
325
|
+
return Number.isInteger(raw) && raw > 0 ? raw : DEFAULT_MAX_PARALLEL_BRANCHES;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function assertParallelBranchLimit(count: number): void {
|
|
329
|
+
const max = getMaxParallelBranches();
|
|
330
|
+
if (count <= max) return;
|
|
331
|
+
throw new Error(
|
|
332
|
+
`Command template parallel fanout ${count} exceeds limit ${max}; set PI_ACTORS_MAX_PARALLEL_BRANCHES to override intentionally.`,
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function normalizeFailureScope(
|
|
337
|
+
value: CommandTemplates.CommandTemplateFailureScope | undefined,
|
|
338
|
+
): CommandTemplates.CommandTemplateFailureScope {
|
|
339
|
+
if (value === undefined) return "continue";
|
|
340
|
+
if (value === "continue" || value === "branch" || value === "root")
|
|
341
|
+
return value;
|
|
342
|
+
throw new Error(
|
|
343
|
+
"Command template failure must be one of: continue, branch, root.",
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function getFailureScope(
|
|
348
|
+
config: CommandTemplates.CommandTemplateConfig,
|
|
349
|
+
): CommandTemplates.CommandTemplateFailureScope {
|
|
350
|
+
const normalized = CommandTemplates.normalizeCommandTemplateConfig(config);
|
|
351
|
+
return normalizeFailureScope(normalized.failure);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function maxFailureScope(
|
|
355
|
+
...scopes: Array<CommandTemplates.CommandTemplateFailureScope | undefined>
|
|
356
|
+
): CommandTemplates.CommandTemplateFailureScope {
|
|
357
|
+
const rank = { branch: 1, continue: 0, root: 2 } as const;
|
|
358
|
+
return scopes.reduce<CommandTemplates.CommandTemplateFailureScope>(
|
|
359
|
+
(current, scope) =>
|
|
360
|
+
rank[scope ?? "continue"] > rank[current] ? scope! : current,
|
|
361
|
+
"continue",
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function normalizeRetry(
|
|
366
|
+
value: number | string | undefined,
|
|
367
|
+
values: Record<string, unknown>,
|
|
368
|
+
): number {
|
|
369
|
+
const resolved = resolveNumericControlField(value, values, "retry");
|
|
370
|
+
if (resolved === undefined) return 1;
|
|
371
|
+
if (!Number.isInteger(resolved) || resolved < 1)
|
|
372
|
+
throw new Error("Command template retry must be a positive integer.");
|
|
373
|
+
return resolved;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function normalizeConcurrency(
|
|
377
|
+
value: number | string | undefined,
|
|
378
|
+
values: Record<string, unknown>,
|
|
379
|
+
branchCount: number,
|
|
380
|
+
): number {
|
|
381
|
+
const resolved = resolveNumericControlField(value, values, "concurrency");
|
|
382
|
+
if (resolved === undefined) return branchCount;
|
|
383
|
+
if (!Number.isInteger(resolved) || resolved < 1)
|
|
384
|
+
throw new Error("Command template concurrency must be a positive integer.");
|
|
385
|
+
return Math.min(resolved, branchCount);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function normalizeMinSuccessful(
|
|
389
|
+
value: number | string | undefined,
|
|
390
|
+
values: Record<string, unknown>,
|
|
391
|
+
branchCount: number,
|
|
392
|
+
): number | undefined {
|
|
393
|
+
const resolved = resolveNumericControlField(value, values, "min_successful");
|
|
394
|
+
if (resolved === undefined) return undefined;
|
|
395
|
+
if (!Number.isInteger(resolved) || resolved < 0)
|
|
396
|
+
throw new Error("Command template min_successful must be a non-negative integer.");
|
|
397
|
+
if (resolved > branchCount)
|
|
398
|
+
throw new Error(
|
|
399
|
+
`Command template min_successful ${resolved} exceeds branch count ${branchCount}.`,
|
|
400
|
+
);
|
|
401
|
+
return resolved;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
function getRecoverConfig(
|
|
405
|
+
config: CommandTemplates.CommandTemplateValue,
|
|
406
|
+
): CommandTemplates.CommandTemplateConfig {
|
|
407
|
+
const recovered = Array.isArray(config) ? { template: config } : config;
|
|
408
|
+
const normalized = CommandTemplates.normalizeCommandTemplateConfig(recovered);
|
|
409
|
+
if (normalized.failure !== undefined) return recovered;
|
|
410
|
+
return { ...normalized, failure: "root" };
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
function addResultFailure(
|
|
414
|
+
failures: Array<{ code: number; command: string; killed: boolean }>,
|
|
415
|
+
execution: TemplateExecution,
|
|
416
|
+
): void {
|
|
417
|
+
if (execution.result.code === 0) return;
|
|
418
|
+
const failure = {
|
|
419
|
+
code: execution.result.code,
|
|
420
|
+
command: execution.commands.at(-1) ?? "<template>",
|
|
421
|
+
killed: execution.result.killed,
|
|
422
|
+
};
|
|
423
|
+
const last = failures.at(-1);
|
|
424
|
+
if (
|
|
425
|
+
last?.code === failure.code &&
|
|
426
|
+
last.command === failure.command &&
|
|
427
|
+
last.killed === failure.killed
|
|
428
|
+
)
|
|
429
|
+
return;
|
|
430
|
+
failures.push(failure);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function mergeExecution(
|
|
434
|
+
target: TemplateExecution,
|
|
435
|
+
source: TemplateExecution,
|
|
436
|
+
): void {
|
|
437
|
+
target.branches.push(...source.branches);
|
|
438
|
+
target.commands.push(...source.commands);
|
|
439
|
+
target.failures.push(...source.failures);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function sleep(ms: number, signal: AbortSignal | undefined): Promise<void> {
|
|
443
|
+
return new Promise((resolve) => {
|
|
444
|
+
let timeoutId: NodeJS.Timeout | undefined;
|
|
445
|
+
const settle = (): void => {
|
|
446
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
447
|
+
if (signal) signal.removeEventListener("abort", settle);
|
|
448
|
+
resolve();
|
|
449
|
+
};
|
|
450
|
+
if (signal?.aborted) return settle();
|
|
451
|
+
timeoutId = setTimeout(settle, ms);
|
|
452
|
+
if (signal) signal.addEventListener("abort", settle, { once: true });
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
function resolveNumericControlField(
|
|
457
|
+
value: number | string | undefined,
|
|
458
|
+
values: Record<string, unknown>,
|
|
459
|
+
label: string,
|
|
460
|
+
): number | undefined {
|
|
461
|
+
if (value === undefined) return undefined;
|
|
462
|
+
const resolved =
|
|
463
|
+
typeof value === "string"
|
|
464
|
+
? CommandTemplates.substituteCommandTemplateToken(value, values, label)
|
|
465
|
+
: value;
|
|
466
|
+
if (resolved === "") return undefined;
|
|
467
|
+
const numeric = Number(resolved);
|
|
468
|
+
if (!Number.isFinite(numeric) || numeric < 0)
|
|
469
|
+
throw new Error(`Command template ${label} must be a non-negative number.`);
|
|
470
|
+
return numeric;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
async function applyDelay(
|
|
474
|
+
delay: number | string | undefined,
|
|
475
|
+
values: Record<string, unknown>,
|
|
476
|
+
signal: AbortSignal | undefined,
|
|
477
|
+
): Promise<void> {
|
|
478
|
+
const resolved = resolveNumericControlField(delay, values, "delay");
|
|
479
|
+
if (resolved === undefined || resolved <= 0) return;
|
|
480
|
+
await sleep(resolved, signal);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function getParallelStatus(
|
|
484
|
+
branches: BranchReport[],
|
|
485
|
+
minSuccessful: number | undefined,
|
|
486
|
+
): "complete" | "degraded" | "insufficient_data" {
|
|
487
|
+
const usable = countUsableBranches(branches);
|
|
488
|
+
if (minSuccessful !== undefined && usable < minSuccessful) {
|
|
489
|
+
return "insufficient_data";
|
|
490
|
+
}
|
|
491
|
+
return branches.every(isUsableBranch) ? "complete" : "degraded";
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function formatParallelStatusHeader(
|
|
495
|
+
branches: BranchReport[],
|
|
496
|
+
minSuccessful: number | undefined,
|
|
497
|
+
): string | undefined {
|
|
498
|
+
if (minSuccessful === undefined) return undefined;
|
|
499
|
+
return `--- parallel_status: ${getParallelStatus(
|
|
500
|
+
branches,
|
|
501
|
+
minSuccessful,
|
|
502
|
+
)} usable: ${countUsableBranches(branches)} expected: ${branches.length} minimum: ${minSuccessful} ---`;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
function stdoutWithEvidenceReference(result: ToolExecResult): string {
|
|
506
|
+
return result.evidenceRef
|
|
507
|
+
? `${result.stdout}\nACTOR_EVIDENCE_REF: ${result.evidenceRef}`
|
|
508
|
+
: result.stdout;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
function joinParallelStdout(
|
|
512
|
+
branches: BranchReport[],
|
|
513
|
+
results: ToolExecResult[],
|
|
514
|
+
minSuccessful?: number,
|
|
515
|
+
): string {
|
|
516
|
+
const body = results
|
|
517
|
+
.map((result, index) => {
|
|
518
|
+
const branch = branches[index];
|
|
519
|
+
const evidence = result.evidenceRef
|
|
520
|
+
? ` evidence_ref: ${result.evidenceRef}`
|
|
521
|
+
: "";
|
|
522
|
+
const header = `--- branch: ${branch.label} status: ${branch.status}${evidence} ---`;
|
|
523
|
+
if (branch.status === "done")
|
|
524
|
+
return `${header}\n${stdoutWithEvidenceReference(result)}`;
|
|
525
|
+
const stdout = result.stdout ? `\nrejected_stdout: ${result.stdout}` : "";
|
|
526
|
+
const stderr = branch.stderr ? `\nstderr: ${branch.stderr}` : "";
|
|
527
|
+
return `${header}\nexit: ${branch.code}${stdout}${stderr}`;
|
|
528
|
+
})
|
|
529
|
+
.join("\n");
|
|
530
|
+
return [formatParallelStatusHeader(branches, minSuccessful), body]
|
|
531
|
+
.filter(Boolean)
|
|
532
|
+
.join("\n");
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
async function mapConcurrent<T, TResult>(
|
|
536
|
+
items: readonly T[],
|
|
537
|
+
concurrency: number,
|
|
538
|
+
fn: (item: T, index: number) => Promise<TResult>,
|
|
539
|
+
): Promise<TResult[]> {
|
|
540
|
+
const results = new Array<TResult>(items.length);
|
|
541
|
+
let nextIndex = 0;
|
|
542
|
+
async function worker(): Promise<void> {
|
|
543
|
+
for (;;) {
|
|
544
|
+
const index = nextIndex;
|
|
545
|
+
nextIndex += 1;
|
|
546
|
+
if (index >= items.length) return;
|
|
547
|
+
results[index] = await fn(items[index]!, index);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
await Promise.all(
|
|
551
|
+
Array.from({ length: Math.min(concurrency, items.length) }, () => worker()),
|
|
552
|
+
);
|
|
553
|
+
return results;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
async function executeRetriableTemplateConfig(
|
|
557
|
+
normalized: CommandTemplates.CommandTemplateObjectConfig,
|
|
558
|
+
inherited: Pick<
|
|
559
|
+
CommandTemplates.CommandTemplateObjectConfig,
|
|
560
|
+
"args" | "defaults"
|
|
561
|
+
>,
|
|
562
|
+
params: Record<string, unknown>,
|
|
563
|
+
exec: RegisteredToolExec,
|
|
564
|
+
cwd: string,
|
|
565
|
+
signal: AbortSignal | undefined,
|
|
566
|
+
stdin: string | undefined,
|
|
567
|
+
isRoot: boolean,
|
|
568
|
+
actorRecipeContext: CommandTemplates.CommandTemplateActorRecipeContext | undefined,
|
|
569
|
+
): Promise<TemplateExecution> {
|
|
570
|
+
const maxAttempts = normalizeRetry(normalized.retry, {
|
|
571
|
+
...(inherited.defaults ?? {}),
|
|
572
|
+
...params,
|
|
573
|
+
});
|
|
574
|
+
const attemptConfig = {
|
|
575
|
+
...normalized,
|
|
576
|
+
delay: undefined,
|
|
577
|
+
recover: undefined,
|
|
578
|
+
retry: undefined,
|
|
579
|
+
};
|
|
580
|
+
const aggregate: TemplateExecution = {
|
|
581
|
+
branches: [],
|
|
582
|
+
commands: [],
|
|
583
|
+
failures: [],
|
|
584
|
+
result: { code: 1, killed: false, stderr: "", stdout: "" },
|
|
585
|
+
};
|
|
586
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
587
|
+
const executed = await executeTemplateConfig(
|
|
588
|
+
attemptConfig,
|
|
589
|
+
inherited,
|
|
590
|
+
params,
|
|
591
|
+
exec,
|
|
592
|
+
cwd,
|
|
593
|
+
signal,
|
|
594
|
+
stdin,
|
|
595
|
+
isRoot,
|
|
596
|
+
actorRecipeContext,
|
|
597
|
+
);
|
|
598
|
+
mergeExecution(aggregate, executed);
|
|
599
|
+
aggregate.result = executed.result;
|
|
600
|
+
aggregate.criticalFailure = executed.criticalFailure;
|
|
601
|
+
aggregate.failureScope = executed.failureScope;
|
|
602
|
+
if (executed.result.code === 0) return aggregate;
|
|
603
|
+
addResultFailure(aggregate.failures, executed);
|
|
604
|
+
if (attempt === maxAttempts) return aggregate;
|
|
605
|
+
if (normalized.recover === undefined) continue;
|
|
606
|
+
const recovered = await executeTemplateConfig(
|
|
607
|
+
getRecoverConfig(normalized.recover),
|
|
608
|
+
inherited,
|
|
609
|
+
params,
|
|
610
|
+
exec,
|
|
611
|
+
cwd,
|
|
612
|
+
signal,
|
|
613
|
+
executed.result.stdout,
|
|
614
|
+
false,
|
|
615
|
+
actorRecipeContext,
|
|
616
|
+
);
|
|
617
|
+
mergeExecution(aggregate, recovered);
|
|
618
|
+
if (recovered.result.code === 0) continue;
|
|
619
|
+
addResultFailure(aggregate.failures, recovered);
|
|
620
|
+
aggregate.result = recovered.result;
|
|
621
|
+
aggregate.criticalFailure = recovered.criticalFailure;
|
|
622
|
+
aggregate.failureScope = maxFailureScope(
|
|
623
|
+
recovered.failureScope,
|
|
624
|
+
getFailureScope(normalized),
|
|
625
|
+
);
|
|
626
|
+
return aggregate;
|
|
627
|
+
}
|
|
628
|
+
return aggregate;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
async function executeTemplateConfig(
|
|
632
|
+
config: CommandTemplates.CommandTemplateConfig,
|
|
633
|
+
inherited: Pick<
|
|
634
|
+
CommandTemplates.CommandTemplateObjectConfig,
|
|
635
|
+
"args" | "defaults"
|
|
636
|
+
>,
|
|
637
|
+
params: Record<string, unknown>,
|
|
638
|
+
exec: RegisteredToolExec,
|
|
639
|
+
cwd: string,
|
|
640
|
+
signal: AbortSignal | undefined,
|
|
641
|
+
stdin: string | undefined,
|
|
642
|
+
isRoot: boolean,
|
|
643
|
+
inheritedActorRecipeContext: CommandTemplates.CommandTemplateActorRecipeContext | undefined,
|
|
644
|
+
): Promise<TemplateExecution> {
|
|
645
|
+
const normalized = CommandTemplates.normalizeCommandTemplateConfig(config);
|
|
646
|
+
const normalizedDefaults = CommandTemplates.resolveInheritedDefaultReferences(
|
|
647
|
+
normalized.defaults,
|
|
648
|
+
inherited.defaults,
|
|
649
|
+
params,
|
|
650
|
+
);
|
|
651
|
+
const context = {
|
|
652
|
+
...(inherited.args !== undefined ? { args: inherited.args } : {}),
|
|
653
|
+
...(inherited.defaults !== undefined
|
|
654
|
+
? { defaults: inherited.defaults }
|
|
655
|
+
: {}),
|
|
656
|
+
...(normalized.args !== undefined ? { args: normalized.args } : {}),
|
|
657
|
+
...(mergeDefaults(inherited.defaults, normalizedDefaults)
|
|
658
|
+
? { defaults: mergeDefaults(inherited.defaults, normalizedDefaults) }
|
|
659
|
+
: {}),
|
|
660
|
+
};
|
|
661
|
+
const actorRecipeContext = normalized.actorRecipeContext ?? inheritedActorRecipeContext;
|
|
662
|
+
const controlValues = { ...(context.defaults ?? {}), ...params };
|
|
663
|
+
await applyDelay(normalized.delay, controlValues, signal);
|
|
664
|
+
if (
|
|
665
|
+
!CommandTemplates.shouldRunCommandTemplateNode(
|
|
666
|
+
normalized.when,
|
|
667
|
+
controlValues,
|
|
668
|
+
)
|
|
669
|
+
) {
|
|
670
|
+
return {
|
|
671
|
+
branches: [],
|
|
672
|
+
commands: [],
|
|
673
|
+
failures: [],
|
|
674
|
+
result: { code: 0, killed: false, stderr: "", stdout: stdin ?? "" },
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
getFailureScope(normalized);
|
|
678
|
+
if (normalized.repeat !== undefined) {
|
|
679
|
+
const repeat = CommandTemplates.resolveCommandTemplateRepeat(
|
|
680
|
+
normalized.repeat,
|
|
681
|
+
{ ...(context.defaults ?? {}), ...params },
|
|
682
|
+
);
|
|
683
|
+
if (repeat === undefined)
|
|
684
|
+
throw new Error("Command template repeat could not be resolved.");
|
|
685
|
+
if (normalized.parallel === true) assertParallelBranchLimit(repeat);
|
|
686
|
+
const repeatedSteps = Array.from({ length: repeat }, (_unused, index0) => {
|
|
687
|
+
const { repeat: _repeat, ...rest } = normalized;
|
|
688
|
+
return {
|
|
689
|
+
...rest,
|
|
690
|
+
defaults: {
|
|
691
|
+
...(context.defaults ?? {}),
|
|
692
|
+
...(rest.defaults ?? {}),
|
|
693
|
+
...CommandTemplates.getCommandTemplateRepeatDefaults(index0, repeat),
|
|
694
|
+
},
|
|
695
|
+
};
|
|
696
|
+
});
|
|
697
|
+
return executeTemplateConfig(
|
|
698
|
+
{
|
|
699
|
+
parallel: normalized.parallel === true,
|
|
700
|
+
...(normalized.concurrency !== undefined
|
|
701
|
+
? { concurrency: normalized.concurrency }
|
|
702
|
+
: {}),
|
|
703
|
+
...(normalized.min_successful !== undefined
|
|
704
|
+
? { min_successful: normalized.min_successful }
|
|
705
|
+
: {}),
|
|
706
|
+
...(normalized.failure !== undefined ? { failure: normalized.failure } : {}),
|
|
707
|
+
template: repeatedSteps,
|
|
708
|
+
},
|
|
709
|
+
context,
|
|
710
|
+
params,
|
|
711
|
+
exec,
|
|
712
|
+
cwd,
|
|
713
|
+
signal,
|
|
714
|
+
stdin,
|
|
715
|
+
isRoot,
|
|
716
|
+
actorRecipeContext,
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
if (
|
|
720
|
+
normalized.retry !== undefined &&
|
|
721
|
+
(Array.isArray(normalized.template) || normalized.recover !== undefined)
|
|
722
|
+
) {
|
|
723
|
+
return executeRetriableTemplateConfig(
|
|
724
|
+
normalized,
|
|
725
|
+
context,
|
|
726
|
+
params,
|
|
727
|
+
exec,
|
|
728
|
+
cwd,
|
|
729
|
+
signal,
|
|
730
|
+
stdin,
|
|
731
|
+
isRoot,
|
|
732
|
+
actorRecipeContext,
|
|
733
|
+
);
|
|
734
|
+
}
|
|
735
|
+
if (
|
|
736
|
+
normalized.template &&
|
|
737
|
+
typeof normalized.template === "object" &&
|
|
738
|
+
!Array.isArray(normalized.template)
|
|
739
|
+
) {
|
|
740
|
+
return executeTemplateConfig(
|
|
741
|
+
normalized.template,
|
|
742
|
+
context,
|
|
743
|
+
params,
|
|
744
|
+
exec,
|
|
745
|
+
cwd,
|
|
746
|
+
signal,
|
|
747
|
+
stdin,
|
|
748
|
+
false,
|
|
749
|
+
actorRecipeContext,
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
if (!Array.isArray(normalized.template)) {
|
|
753
|
+
const leaf = { ...normalized, ...context };
|
|
754
|
+
const invocation = CommandTemplates.buildCommandTemplateInvocation(
|
|
755
|
+
leaf,
|
|
756
|
+
params as Record<string, string>,
|
|
757
|
+
cwd,
|
|
758
|
+
{ emptyMessage: "Tool template produced an empty command." },
|
|
759
|
+
);
|
|
760
|
+
const evidenceContext = {
|
|
761
|
+
...(normalized.accept_output
|
|
762
|
+
? { acceptOutput: normalized.accept_output }
|
|
763
|
+
: {}),
|
|
764
|
+
...(normalized.label ? { label: normalized.label } : {}),
|
|
765
|
+
...(typeof controlValues.index === "string"
|
|
766
|
+
? { repeatIndex: controlValues.index }
|
|
767
|
+
: {}),
|
|
768
|
+
};
|
|
769
|
+
const rawResult = await exec(invocation.command, invocation.args, {
|
|
770
|
+
...(actorRecipeContext ? { actorRecipeContext } : {}),
|
|
771
|
+
...(Object.keys(evidenceContext).length > 0 ? { evidenceContext } : {}),
|
|
772
|
+
cwd,
|
|
773
|
+
signal,
|
|
774
|
+
stdin,
|
|
775
|
+
...(resolveNumericControlField(
|
|
776
|
+
normalized.timeout,
|
|
777
|
+
controlValues,
|
|
778
|
+
"timeout",
|
|
779
|
+
) !== undefined
|
|
780
|
+
? {
|
|
781
|
+
timeout: resolveNumericControlField(
|
|
782
|
+
normalized.timeout,
|
|
783
|
+
controlValues,
|
|
784
|
+
"timeout",
|
|
785
|
+
),
|
|
786
|
+
}
|
|
787
|
+
: {}),
|
|
788
|
+
...(normalized.retry !== undefined
|
|
789
|
+
? { retry: normalizeRetry(normalized.retry, controlValues) }
|
|
790
|
+
: {}),
|
|
791
|
+
});
|
|
792
|
+
const result = await applyOutputAcceptancePolicy(
|
|
793
|
+
rawResult,
|
|
794
|
+
normalized.accept_output,
|
|
795
|
+
);
|
|
796
|
+
return {
|
|
797
|
+
branches: [],
|
|
798
|
+
commands: [formatInvocationDetail(invocation)],
|
|
799
|
+
failures: [],
|
|
800
|
+
result,
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
const steps = normalized.template;
|
|
804
|
+
if (steps.length === 0)
|
|
805
|
+
throw new Error(formatToolText("Tool template produced no command steps."));
|
|
806
|
+
if (normalized.parallel === true) {
|
|
807
|
+
assertParallelBranchLimit(steps.length);
|
|
808
|
+
const concurrency = normalizeConcurrency(
|
|
809
|
+
normalized.concurrency,
|
|
810
|
+
controlValues,
|
|
811
|
+
steps.length,
|
|
812
|
+
);
|
|
813
|
+
const minSuccessful = normalizeMinSuccessful(
|
|
814
|
+
normalized.min_successful,
|
|
815
|
+
controlValues,
|
|
816
|
+
steps.length,
|
|
817
|
+
);
|
|
818
|
+
const branchResults = await mapConcurrent(steps, concurrency, (step) =>
|
|
819
|
+
executeTemplateConfig(
|
|
820
|
+
step,
|
|
821
|
+
context,
|
|
822
|
+
params,
|
|
823
|
+
exec,
|
|
824
|
+
cwd,
|
|
825
|
+
signal,
|
|
826
|
+
stdin,
|
|
827
|
+
false,
|
|
828
|
+
actorRecipeContext,
|
|
829
|
+
),
|
|
830
|
+
);
|
|
831
|
+
const branchPipelineStdouts = await Promise.all(
|
|
832
|
+
branchResults.map((item) => resolvePipelineStdout(item.result)),
|
|
833
|
+
);
|
|
834
|
+
for (const [index, item] of branchResults.entries()) {
|
|
835
|
+
if (item.result.stdoutTruncated && branchPipelineStdouts[index] === undefined) {
|
|
836
|
+
item.result = rejectIncompletePipelineOutput(item.result);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
const commands = branchResults.flatMap((item) => item.commands);
|
|
840
|
+
const failures = branchResults.flatMap((item) => item.failures);
|
|
841
|
+
const branches = branchResults.map((item, index) =>
|
|
842
|
+
createBranchReport(
|
|
843
|
+
getNodeLabel(steps[index], index),
|
|
844
|
+
item.commands.at(-1) ?? "<template>",
|
|
845
|
+
item.result,
|
|
846
|
+
),
|
|
847
|
+
);
|
|
848
|
+
const usableBranches = countUsableBranches(branches);
|
|
849
|
+
const quorumUnmet =
|
|
850
|
+
minSuccessful !== undefined && usableBranches < minSuccessful;
|
|
851
|
+
const quorumFailureMessage = quorumUnmet
|
|
852
|
+
? `parallel branch quorum not met: usable ${usableBranches}/${branches.length}, minimum ${minSuccessful}`
|
|
853
|
+
: "";
|
|
854
|
+
const nodeFailure = getFailureScope(normalized);
|
|
855
|
+
const rootFailure = branchResults.find((item, index) => {
|
|
856
|
+
if (item.result.code === 0) return false;
|
|
857
|
+
const branchFailure = maxFailureScope(
|
|
858
|
+
item.failureScope,
|
|
859
|
+
item.criticalFailure ? "root" : undefined,
|
|
860
|
+
getFailureScope(steps[index]),
|
|
861
|
+
nodeFailure,
|
|
862
|
+
);
|
|
863
|
+
return branchFailure === "root";
|
|
864
|
+
});
|
|
865
|
+
if (rootFailure) {
|
|
866
|
+
return {
|
|
867
|
+
branches: [
|
|
868
|
+
...branchResults.flatMap((item) => item.branches),
|
|
869
|
+
...branches,
|
|
870
|
+
],
|
|
871
|
+
commands,
|
|
872
|
+
criticalFailure: true,
|
|
873
|
+
failureScope: "root",
|
|
874
|
+
failures,
|
|
875
|
+
result: rootFailure.result,
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
const firstFailedBranch = branchResults.find(
|
|
879
|
+
(item) => item.result.code !== 0,
|
|
880
|
+
);
|
|
881
|
+
const allBranchesUnusable = branches.every(
|
|
882
|
+
(branch) => !isUsableBranch(branch),
|
|
883
|
+
);
|
|
884
|
+
const successful = branchResults.map((item) => {
|
|
885
|
+
if (item.result.code === 0) return item.result;
|
|
886
|
+
addResultFailure(failures, item);
|
|
887
|
+
return { ...item.result, code: 0 };
|
|
888
|
+
});
|
|
889
|
+
const completeSuccessful = successful.map((item, index) => ({
|
|
890
|
+
...item,
|
|
891
|
+
stdout: branchPipelineStdouts[index] ?? item.stdout,
|
|
892
|
+
evidenceRef: undefined,
|
|
893
|
+
}));
|
|
894
|
+
const result: ToolExecResult = {
|
|
895
|
+
code: 0,
|
|
896
|
+
killed: successful.some((item) => item.killed),
|
|
897
|
+
stderr: successful
|
|
898
|
+
.map((item) => item.stderr)
|
|
899
|
+
.filter(Boolean)
|
|
900
|
+
.join("\n"),
|
|
901
|
+
stdout: joinParallelStdout(branches, successful, minSuccessful),
|
|
902
|
+
pipelineStdout: joinParallelStdout(
|
|
903
|
+
branches,
|
|
904
|
+
completeSuccessful,
|
|
905
|
+
minSuccessful,
|
|
906
|
+
),
|
|
907
|
+
stdoutBytes: successful.reduce(
|
|
908
|
+
(total, item) => total + (item.stdoutBytes ?? Buffer.byteLength(item.stdout)),
|
|
909
|
+
0,
|
|
910
|
+
),
|
|
911
|
+
...(successful.some((item) => item.stdoutTruncated)
|
|
912
|
+
? { stdoutTruncated: true }
|
|
913
|
+
: {}),
|
|
914
|
+
};
|
|
915
|
+
if (quorumUnmet && nodeFailure === "root") {
|
|
916
|
+
return {
|
|
917
|
+
commands,
|
|
918
|
+
branches: [
|
|
919
|
+
...branchResults.flatMap((item) => item.branches),
|
|
920
|
+
...branches,
|
|
921
|
+
],
|
|
922
|
+
criticalFailure: true,
|
|
923
|
+
failureScope: "root",
|
|
924
|
+
failures,
|
|
925
|
+
result: {
|
|
926
|
+
...result,
|
|
927
|
+
code: firstFailedBranch?.result.code || 1,
|
|
928
|
+
stderr: [result.stderr, quorumFailureMessage]
|
|
929
|
+
.filter(Boolean)
|
|
930
|
+
.join("\n"),
|
|
931
|
+
},
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
const branchFailureTriggered = minSuccessful === undefined
|
|
935
|
+
? firstFailedBranch || allBranchesUnusable
|
|
936
|
+
: quorumUnmet;
|
|
937
|
+
if (branchFailureTriggered && nodeFailure === "branch") {
|
|
938
|
+
return {
|
|
939
|
+
commands,
|
|
940
|
+
branches: [
|
|
941
|
+
...branchResults.flatMap((item) => item.branches),
|
|
942
|
+
...branches,
|
|
943
|
+
],
|
|
944
|
+
failureScope: "branch",
|
|
945
|
+
failures,
|
|
946
|
+
result: {
|
|
947
|
+
...result,
|
|
948
|
+
code: firstFailedBranch?.result.code || 1,
|
|
949
|
+
stderr: [
|
|
950
|
+
result.stderr,
|
|
951
|
+
allBranchesUnusable
|
|
952
|
+
? "all parallel branches failed or produced empty output"
|
|
953
|
+
: "",
|
|
954
|
+
quorumFailureMessage,
|
|
955
|
+
]
|
|
956
|
+
.filter(Boolean)
|
|
957
|
+
.join("\n"),
|
|
958
|
+
},
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
return {
|
|
962
|
+
commands,
|
|
963
|
+
branches: [
|
|
964
|
+
...branchResults.flatMap((item) => item.branches),
|
|
965
|
+
...branches,
|
|
966
|
+
],
|
|
967
|
+
failures,
|
|
968
|
+
result,
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
const branches: BranchReport[] = [];
|
|
972
|
+
const commands: string[] = [];
|
|
973
|
+
const failures: Array<{ code: number; command: string; killed: boolean }> =
|
|
974
|
+
[];
|
|
975
|
+
let nextStdin = stdin;
|
|
976
|
+
let result: ToolExecResult | undefined;
|
|
977
|
+
for (const [stepIndex, step] of steps.entries()) {
|
|
978
|
+
const executed = await executeTemplateConfig(
|
|
979
|
+
step,
|
|
980
|
+
context,
|
|
981
|
+
params,
|
|
982
|
+
exec,
|
|
983
|
+
cwd,
|
|
984
|
+
signal,
|
|
985
|
+
nextStdin,
|
|
986
|
+
false,
|
|
987
|
+
actorRecipeContext,
|
|
988
|
+
);
|
|
989
|
+
branches.push(...executed.branches);
|
|
990
|
+
commands.push(...executed.commands);
|
|
991
|
+
failures.push(...executed.failures);
|
|
992
|
+
const pipelineStdout = await resolvePipelineStdout(executed.result);
|
|
993
|
+
const incompletePipelineInput =
|
|
994
|
+
stepIndex < steps.length - 1 && pipelineStdout === undefined;
|
|
995
|
+
result = incompletePipelineInput
|
|
996
|
+
? rejectIncompletePipelineOutput(executed.result)
|
|
997
|
+
: executed.result;
|
|
998
|
+
executed.result = result;
|
|
999
|
+
if (incompletePipelineInput) {
|
|
1000
|
+
addResultFailure(failures, executed);
|
|
1001
|
+
return {
|
|
1002
|
+
branches,
|
|
1003
|
+
commands,
|
|
1004
|
+
criticalFailure: true,
|
|
1005
|
+
failureScope: "root",
|
|
1006
|
+
failures,
|
|
1007
|
+
result,
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
if (result.code !== 0) {
|
|
1011
|
+
const failureScope = maxFailureScope(
|
|
1012
|
+
executed.failureScope,
|
|
1013
|
+
executed.criticalFailure ? "root" : undefined,
|
|
1014
|
+
getFailureScope(step),
|
|
1015
|
+
getFailureScope(normalized),
|
|
1016
|
+
isRoot && steps.length === 1 ? "root" : undefined,
|
|
1017
|
+
);
|
|
1018
|
+
if (failureScope === "root") {
|
|
1019
|
+
return {
|
|
1020
|
+
branches,
|
|
1021
|
+
commands,
|
|
1022
|
+
criticalFailure: true,
|
|
1023
|
+
failureScope: "root",
|
|
1024
|
+
failures,
|
|
1025
|
+
result,
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
if (failureScope === "branch") {
|
|
1029
|
+
addResultFailure(failures, executed);
|
|
1030
|
+
return {
|
|
1031
|
+
branches,
|
|
1032
|
+
commands,
|
|
1033
|
+
failureScope: "branch",
|
|
1034
|
+
failures,
|
|
1035
|
+
result,
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
1038
|
+
addResultFailure(failures, executed);
|
|
1039
|
+
result = { ...result, code: 0, stdout: "" };
|
|
1040
|
+
nextStdin = "";
|
|
1041
|
+
continue;
|
|
1042
|
+
}
|
|
1043
|
+
nextStdin = pipelineStdout;
|
|
1044
|
+
}
|
|
1045
|
+
return { branches, commands, failures, result: result! };
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
async function executeTemplateSteps(
|
|
1049
|
+
cfg: RegisteredTool,
|
|
1050
|
+
params: Record<string, unknown>,
|
|
1051
|
+
exec: RegisteredToolExec,
|
|
1052
|
+
cwd: string,
|
|
1053
|
+
signal?: AbortSignal,
|
|
1054
|
+
): Promise<TemplateExecution> {
|
|
1055
|
+
return executeTemplateConfig(
|
|
1056
|
+
createTemplateConfig(cfg),
|
|
1057
|
+
{},
|
|
1058
|
+
params,
|
|
1059
|
+
exec,
|
|
1060
|
+
cwd,
|
|
1061
|
+
signal,
|
|
1062
|
+
undefined,
|
|
1063
|
+
true,
|
|
1064
|
+
undefined,
|
|
1065
|
+
);
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
function getCaptureDetails(result: ToolExecResult): Record<string, unknown> {
|
|
1069
|
+
return {
|
|
1070
|
+
stdoutBytes: result.stdoutBytes ?? Buffer.byteLength(result.stdout),
|
|
1071
|
+
stdoutCapturedBytes: Buffer.byteLength(result.stdout),
|
|
1072
|
+
stderrBytes: result.stderrBytes ?? Buffer.byteLength(result.stderr),
|
|
1073
|
+
stderrCapturedBytes: Buffer.byteLength(result.stderr),
|
|
1074
|
+
...(result.stdoutFile ? { stdoutFile: result.stdoutFile } : {}),
|
|
1075
|
+
...(result.stderrFile ? { stderrFile: result.stderrFile } : {}),
|
|
1076
|
+
...(result.stdoutTruncated ? { stdoutTruncated: true } : {}),
|
|
1077
|
+
...(result.stderrTruncated ? { stderrTruncated: true } : {}),
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
export async function executeRegisteredTool(
|
|
1082
|
+
cfg: RegisteredTool,
|
|
1083
|
+
params: Record<string, unknown>,
|
|
1084
|
+
exec: RegisteredToolExec,
|
|
1085
|
+
cwd: string,
|
|
1086
|
+
signal?: AbortSignal,
|
|
1087
|
+
): Promise<RegisteredToolExecutionResult> {
|
|
1088
|
+
const executed = await executeTemplateSteps(
|
|
1089
|
+
cfg,
|
|
1090
|
+
Schema.normalizeRuntimeValues(params, cfg.argTypes),
|
|
1091
|
+
exec,
|
|
1092
|
+
cwd,
|
|
1093
|
+
signal,
|
|
1094
|
+
);
|
|
1095
|
+
const command = formatCommandDetail(executed.commands);
|
|
1096
|
+
const result = executed.result;
|
|
1097
|
+
const softQuorum = createSoftQuorum(executed.branches);
|
|
1098
|
+
if (result.code !== 0) {
|
|
1099
|
+
const formatted = formatFailureOutput(
|
|
1100
|
+
cfg.name,
|
|
1101
|
+
result.code,
|
|
1102
|
+
result.killed,
|
|
1103
|
+
result.stdout,
|
|
1104
|
+
result.stderr,
|
|
1105
|
+
);
|
|
1106
|
+
throw Object.assign(new Error(formatted.text), {
|
|
1107
|
+
details: {
|
|
1108
|
+
branches: executed.branches,
|
|
1109
|
+
code: result.code,
|
|
1110
|
+
command,
|
|
1111
|
+
fullOutputPath: result.stdoutFile ?? formatted.fullOutputPath,
|
|
1112
|
+
killed: result.killed,
|
|
1113
|
+
...getCaptureDetails(result),
|
|
1114
|
+
...(executed.failures.length > 0
|
|
1115
|
+
? { nonCriticalFailures: executed.failures }
|
|
1116
|
+
: {}),
|
|
1117
|
+
...(softQuorum ? { softQuorum } : {}),
|
|
1118
|
+
failureReason: getExecutionFailureReason(
|
|
1119
|
+
executed.branches,
|
|
1120
|
+
softQuorum,
|
|
1121
|
+
result.stderr,
|
|
1122
|
+
),
|
|
1123
|
+
template: cfg.template!,
|
|
1124
|
+
tool: cfg.name,
|
|
1125
|
+
truncated: formatted.truncated,
|
|
1126
|
+
},
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1129
|
+
const formatted = formatOutput(cfg.name, "stdout", result.stdout);
|
|
1130
|
+
const templateWarnings = CommandTemplates.getCommandTemplateWarnings(
|
|
1131
|
+
createTemplateConfig(cfg),
|
|
1132
|
+
);
|
|
1133
|
+
return {
|
|
1134
|
+
content: [textContent(formatted.text)],
|
|
1135
|
+
details: {
|
|
1136
|
+
code: result.code,
|
|
1137
|
+
command,
|
|
1138
|
+
fullOutputPath: result.stdoutFile ?? formatted.fullOutputPath,
|
|
1139
|
+
killed: result.killed,
|
|
1140
|
+
launch_kind: "tool",
|
|
1141
|
+
...getCaptureDetails(result),
|
|
1142
|
+
...(executed.branches.length > 0 ? { branches: executed.branches } : {}),
|
|
1143
|
+
...(executed.failures.length > 0
|
|
1144
|
+
? { nonCriticalFailures: executed.failures }
|
|
1145
|
+
: {}),
|
|
1146
|
+
...(softQuorum ? { softQuorum } : {}),
|
|
1147
|
+
template: cfg.template!,
|
|
1148
|
+
...(templateWarnings.length > 0 ? { templateWarnings } : {}),
|
|
1149
|
+
tool: cfg.name,
|
|
1150
|
+
truncated: formatted.truncated,
|
|
1151
|
+
},
|
|
1152
|
+
};
|
|
1153
|
+
}
|