@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,725 @@
|
|
|
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
|
+
import { readFile } from "node:fs/promises";
|
|
7
|
+
import * as CommandTemplates from "./command-templates.js";
|
|
8
|
+
import { formatFailureOutput, formatOutput, formatToolText, } from "./execution-output.js";
|
|
9
|
+
import * as Schema from "./schema.js";
|
|
10
|
+
const DEFAULT_MAX_PARALLEL_BRANCHES = 64;
|
|
11
|
+
function textContent(text) {
|
|
12
|
+
return { type: "text", text };
|
|
13
|
+
}
|
|
14
|
+
function createTemplateConfig(cfg) {
|
|
15
|
+
if (!cfg.template)
|
|
16
|
+
throw new Error(`Tool "${cfg.name}" has no command template.`);
|
|
17
|
+
if (typeof cfg.template === "object" && !Array.isArray(cfg.template)) {
|
|
18
|
+
return {
|
|
19
|
+
...cfg.template,
|
|
20
|
+
args: cfg.template.args ?? cfg.args,
|
|
21
|
+
defaults: mergeDefaults(cfg.defaults, cfg.template.defaults),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return { args: cfg.args, defaults: cfg.defaults, template: cfg.template };
|
|
25
|
+
}
|
|
26
|
+
function quoteCommandDetailPart(value) {
|
|
27
|
+
if (value === "")
|
|
28
|
+
return "''";
|
|
29
|
+
if (/^[A-Za-z0-9_/:=.,@%+\-]+$/.test(value))
|
|
30
|
+
return value;
|
|
31
|
+
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
32
|
+
}
|
|
33
|
+
function formatInvocationDetail(invocation) {
|
|
34
|
+
return [invocation.command, ...invocation.args]
|
|
35
|
+
.map(quoteCommandDetailPart)
|
|
36
|
+
.join(" ");
|
|
37
|
+
}
|
|
38
|
+
function formatCommandDetail(commands) {
|
|
39
|
+
return commands.length === 1 ? commands[0] : commands.join(" && ");
|
|
40
|
+
}
|
|
41
|
+
function getExecutionFailureReason(branches, softQuorum, stderr) {
|
|
42
|
+
if (/parallel branch quorum not met/.test(stderr)) {
|
|
43
|
+
return "parallel_quorum_not_met";
|
|
44
|
+
}
|
|
45
|
+
if (branches.length > 0 && softQuorum?.usable === false) {
|
|
46
|
+
return "all_branches_unusable";
|
|
47
|
+
}
|
|
48
|
+
return "command_failed";
|
|
49
|
+
}
|
|
50
|
+
function mergeDefaults(inherited, own) {
|
|
51
|
+
if (!inherited && !own)
|
|
52
|
+
return undefined;
|
|
53
|
+
return { ...(inherited ?? {}), ...(own ?? {}) };
|
|
54
|
+
}
|
|
55
|
+
function getNodeLabel(config, index) {
|
|
56
|
+
const normalized = CommandTemplates.normalizeCommandTemplateConfig(config);
|
|
57
|
+
if (normalized.label)
|
|
58
|
+
return normalized.label;
|
|
59
|
+
return index === undefined ? "command" : `branch ${index + 1}`;
|
|
60
|
+
}
|
|
61
|
+
function getBranchStatus(result) {
|
|
62
|
+
if (result.code === 0)
|
|
63
|
+
return "done";
|
|
64
|
+
return result.killed ? "timeout" : "failed";
|
|
65
|
+
}
|
|
66
|
+
const REVIEW_RESULT_MARKER = "ACTOR_REVIEW_RESULT";
|
|
67
|
+
export async function applyOutputAcceptancePolicy(result, output) {
|
|
68
|
+
if (result.code !== 0 || output !== "review_evidence")
|
|
69
|
+
return result;
|
|
70
|
+
let semanticStdout = result.pipelineStdout ?? result.stdout;
|
|
71
|
+
if (result.pipelineStdout === undefined && result.stdoutTruncated) {
|
|
72
|
+
if (!result.stdoutFile)
|
|
73
|
+
semanticStdout = "";
|
|
74
|
+
else {
|
|
75
|
+
try {
|
|
76
|
+
semanticStdout = await readFile(result.stdoutFile, "utf8");
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
semanticStdout = "";
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const firstNonWhitespaceLine = semanticStdout
|
|
84
|
+
.split(/\r?\n/)
|
|
85
|
+
.find((line) => line.trim().length > 0);
|
|
86
|
+
if (firstNonWhitespaceLine?.trim() === REVIEW_RESULT_MARKER)
|
|
87
|
+
return result;
|
|
88
|
+
return {
|
|
89
|
+
...result,
|
|
90
|
+
code: 65,
|
|
91
|
+
stderr: [
|
|
92
|
+
result.stderr,
|
|
93
|
+
`review evidence rejected: missing ${REVIEW_RESULT_MARKER} marker`,
|
|
94
|
+
].filter(Boolean).join("\n"),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
async function resolvePipelineStdout(result) {
|
|
98
|
+
let stdout = result.pipelineStdout ?? result.stdout;
|
|
99
|
+
if (result.pipelineStdout === undefined && result.stdoutTruncated) {
|
|
100
|
+
if (!result.stdoutFile)
|
|
101
|
+
return undefined;
|
|
102
|
+
try {
|
|
103
|
+
stdout = await readFile(result.stdoutFile, "utf8");
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return result.evidenceRef
|
|
110
|
+
? `${stdout}\nACTOR_EVIDENCE_REF: ${result.evidenceRef}`
|
|
111
|
+
: stdout;
|
|
112
|
+
}
|
|
113
|
+
function rejectIncompletePipelineOutput(result) {
|
|
114
|
+
return {
|
|
115
|
+
...result,
|
|
116
|
+
code: 74,
|
|
117
|
+
stderr: [
|
|
118
|
+
result.stderr,
|
|
119
|
+
`incomplete pipeline stdin: complete stdout unavailable${result.stdoutFile ? `; capture path unreadable: ${result.stdoutFile}` : ""}`,
|
|
120
|
+
].filter(Boolean).join("\n"),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function getBranchFailureReason(result) {
|
|
124
|
+
if (result.code === 0) {
|
|
125
|
+
return result.stdout.trim() ? undefined : "empty_output";
|
|
126
|
+
}
|
|
127
|
+
if (result.killed)
|
|
128
|
+
return "timeout_or_killed";
|
|
129
|
+
return result.stderr.trim() ? "nonzero_exit" : "nonzero_exit_empty_stderr";
|
|
130
|
+
}
|
|
131
|
+
function createBranchReport(label, command, result) {
|
|
132
|
+
const failureReason = getBranchFailureReason(result);
|
|
133
|
+
return {
|
|
134
|
+
code: result.code,
|
|
135
|
+
command,
|
|
136
|
+
...(failureReason ? { failureReason } : {}),
|
|
137
|
+
killed: result.killed,
|
|
138
|
+
label,
|
|
139
|
+
status: getBranchStatus(result),
|
|
140
|
+
...(result.stderr ? { stderr: result.stderr.slice(-1000) } : {}),
|
|
141
|
+
stderrBytes: result.stderrBytes ?? Buffer.byteLength(result.stderr),
|
|
142
|
+
stderrCapturedBytes: Buffer.byteLength(result.stderr),
|
|
143
|
+
...(result.stderrFile ? { stderrFile: result.stderrFile } : {}),
|
|
144
|
+
...(result.stderrTruncated ? { stderrTruncated: true } : {}),
|
|
145
|
+
...(result.stdout ? { stdout: result.stdout.slice(-1000) } : {}),
|
|
146
|
+
stdoutBytes: result.stdoutBytes ?? Buffer.byteLength(result.stdout),
|
|
147
|
+
stdoutCapturedBytes: Buffer.byteLength(result.stdout),
|
|
148
|
+
...(result.stdoutFile ? { stdoutFile: result.stdoutFile } : {}),
|
|
149
|
+
...(result.stdoutTruncated ? { stdoutTruncated: true } : {}),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function isUsableBranch(branch) {
|
|
153
|
+
return (branch.status === "done" &&
|
|
154
|
+
branch.stdoutBytes > 0 &&
|
|
155
|
+
branch.stdoutTruncated !== true);
|
|
156
|
+
}
|
|
157
|
+
function createSoftQuorum(branches) {
|
|
158
|
+
if (branches.length === 0)
|
|
159
|
+
return undefined;
|
|
160
|
+
const done = branches.filter((branch) => branch.status === "done").length;
|
|
161
|
+
const failed = branches.length - done;
|
|
162
|
+
return {
|
|
163
|
+
coverage: done / branches.length,
|
|
164
|
+
degraded: failed > 0,
|
|
165
|
+
done,
|
|
166
|
+
expected: branches.length,
|
|
167
|
+
failed,
|
|
168
|
+
usable: branches.some(isUsableBranch),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function countUsableBranches(branches) {
|
|
172
|
+
return branches.filter(isUsableBranch).length;
|
|
173
|
+
}
|
|
174
|
+
function getMaxParallelBranches() {
|
|
175
|
+
const raw = Number(process.env.PI_ACTORS_MAX_PARALLEL_BRANCHES ?? "");
|
|
176
|
+
return Number.isInteger(raw) && raw > 0 ? raw : DEFAULT_MAX_PARALLEL_BRANCHES;
|
|
177
|
+
}
|
|
178
|
+
function assertParallelBranchLimit(count) {
|
|
179
|
+
const max = getMaxParallelBranches();
|
|
180
|
+
if (count <= max)
|
|
181
|
+
return;
|
|
182
|
+
throw new Error(`Command template parallel fanout ${count} exceeds limit ${max}; set PI_ACTORS_MAX_PARALLEL_BRANCHES to override intentionally.`);
|
|
183
|
+
}
|
|
184
|
+
function normalizeFailureScope(value) {
|
|
185
|
+
if (value === undefined)
|
|
186
|
+
return "continue";
|
|
187
|
+
if (value === "continue" || value === "branch" || value === "root")
|
|
188
|
+
return value;
|
|
189
|
+
throw new Error("Command template failure must be one of: continue, branch, root.");
|
|
190
|
+
}
|
|
191
|
+
function getFailureScope(config) {
|
|
192
|
+
const normalized = CommandTemplates.normalizeCommandTemplateConfig(config);
|
|
193
|
+
return normalizeFailureScope(normalized.failure);
|
|
194
|
+
}
|
|
195
|
+
function maxFailureScope(...scopes) {
|
|
196
|
+
const rank = { branch: 1, continue: 0, root: 2 };
|
|
197
|
+
return scopes.reduce((current, scope) => rank[scope ?? "continue"] > rank[current] ? scope : current, "continue");
|
|
198
|
+
}
|
|
199
|
+
function normalizeRetry(value, values) {
|
|
200
|
+
const resolved = resolveNumericControlField(value, values, "retry");
|
|
201
|
+
if (resolved === undefined)
|
|
202
|
+
return 1;
|
|
203
|
+
if (!Number.isInteger(resolved) || resolved < 1)
|
|
204
|
+
throw new Error("Command template retry must be a positive integer.");
|
|
205
|
+
return resolved;
|
|
206
|
+
}
|
|
207
|
+
function normalizeConcurrency(value, values, branchCount) {
|
|
208
|
+
const resolved = resolveNumericControlField(value, values, "concurrency");
|
|
209
|
+
if (resolved === undefined)
|
|
210
|
+
return branchCount;
|
|
211
|
+
if (!Number.isInteger(resolved) || resolved < 1)
|
|
212
|
+
throw new Error("Command template concurrency must be a positive integer.");
|
|
213
|
+
return Math.min(resolved, branchCount);
|
|
214
|
+
}
|
|
215
|
+
function normalizeMinSuccessful(value, values, branchCount) {
|
|
216
|
+
const resolved = resolveNumericControlField(value, values, "min_successful");
|
|
217
|
+
if (resolved === undefined)
|
|
218
|
+
return undefined;
|
|
219
|
+
if (!Number.isInteger(resolved) || resolved < 0)
|
|
220
|
+
throw new Error("Command template min_successful must be a non-negative integer.");
|
|
221
|
+
if (resolved > branchCount)
|
|
222
|
+
throw new Error(`Command template min_successful ${resolved} exceeds branch count ${branchCount}.`);
|
|
223
|
+
return resolved;
|
|
224
|
+
}
|
|
225
|
+
function getRecoverConfig(config) {
|
|
226
|
+
const recovered = Array.isArray(config) ? { template: config } : config;
|
|
227
|
+
const normalized = CommandTemplates.normalizeCommandTemplateConfig(recovered);
|
|
228
|
+
if (normalized.failure !== undefined)
|
|
229
|
+
return recovered;
|
|
230
|
+
return { ...normalized, failure: "root" };
|
|
231
|
+
}
|
|
232
|
+
function addResultFailure(failures, execution) {
|
|
233
|
+
if (execution.result.code === 0)
|
|
234
|
+
return;
|
|
235
|
+
const failure = {
|
|
236
|
+
code: execution.result.code,
|
|
237
|
+
command: execution.commands.at(-1) ?? "<template>",
|
|
238
|
+
killed: execution.result.killed,
|
|
239
|
+
};
|
|
240
|
+
const last = failures.at(-1);
|
|
241
|
+
if (last?.code === failure.code &&
|
|
242
|
+
last.command === failure.command &&
|
|
243
|
+
last.killed === failure.killed)
|
|
244
|
+
return;
|
|
245
|
+
failures.push(failure);
|
|
246
|
+
}
|
|
247
|
+
function mergeExecution(target, source) {
|
|
248
|
+
target.branches.push(...source.branches);
|
|
249
|
+
target.commands.push(...source.commands);
|
|
250
|
+
target.failures.push(...source.failures);
|
|
251
|
+
}
|
|
252
|
+
function sleep(ms, signal) {
|
|
253
|
+
return new Promise((resolve) => {
|
|
254
|
+
let timeoutId;
|
|
255
|
+
const settle = () => {
|
|
256
|
+
if (timeoutId)
|
|
257
|
+
clearTimeout(timeoutId);
|
|
258
|
+
if (signal)
|
|
259
|
+
signal.removeEventListener("abort", settle);
|
|
260
|
+
resolve();
|
|
261
|
+
};
|
|
262
|
+
if (signal?.aborted)
|
|
263
|
+
return settle();
|
|
264
|
+
timeoutId = setTimeout(settle, ms);
|
|
265
|
+
if (signal)
|
|
266
|
+
signal.addEventListener("abort", settle, { once: true });
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
function resolveNumericControlField(value, values, label) {
|
|
270
|
+
if (value === undefined)
|
|
271
|
+
return undefined;
|
|
272
|
+
const resolved = typeof value === "string"
|
|
273
|
+
? CommandTemplates.substituteCommandTemplateToken(value, values, label)
|
|
274
|
+
: value;
|
|
275
|
+
if (resolved === "")
|
|
276
|
+
return undefined;
|
|
277
|
+
const numeric = Number(resolved);
|
|
278
|
+
if (!Number.isFinite(numeric) || numeric < 0)
|
|
279
|
+
throw new Error(`Command template ${label} must be a non-negative number.`);
|
|
280
|
+
return numeric;
|
|
281
|
+
}
|
|
282
|
+
async function applyDelay(delay, values, signal) {
|
|
283
|
+
const resolved = resolveNumericControlField(delay, values, "delay");
|
|
284
|
+
if (resolved === undefined || resolved <= 0)
|
|
285
|
+
return;
|
|
286
|
+
await sleep(resolved, signal);
|
|
287
|
+
}
|
|
288
|
+
function getParallelStatus(branches, minSuccessful) {
|
|
289
|
+
const usable = countUsableBranches(branches);
|
|
290
|
+
if (minSuccessful !== undefined && usable < minSuccessful) {
|
|
291
|
+
return "insufficient_data";
|
|
292
|
+
}
|
|
293
|
+
return branches.every(isUsableBranch) ? "complete" : "degraded";
|
|
294
|
+
}
|
|
295
|
+
function formatParallelStatusHeader(branches, minSuccessful) {
|
|
296
|
+
if (minSuccessful === undefined)
|
|
297
|
+
return undefined;
|
|
298
|
+
return `--- parallel_status: ${getParallelStatus(branches, minSuccessful)} usable: ${countUsableBranches(branches)} expected: ${branches.length} minimum: ${minSuccessful} ---`;
|
|
299
|
+
}
|
|
300
|
+
function stdoutWithEvidenceReference(result) {
|
|
301
|
+
return result.evidenceRef
|
|
302
|
+
? `${result.stdout}\nACTOR_EVIDENCE_REF: ${result.evidenceRef}`
|
|
303
|
+
: result.stdout;
|
|
304
|
+
}
|
|
305
|
+
function joinParallelStdout(branches, results, minSuccessful) {
|
|
306
|
+
const body = results
|
|
307
|
+
.map((result, index) => {
|
|
308
|
+
const branch = branches[index];
|
|
309
|
+
const evidence = result.evidenceRef
|
|
310
|
+
? ` evidence_ref: ${result.evidenceRef}`
|
|
311
|
+
: "";
|
|
312
|
+
const header = `--- branch: ${branch.label} status: ${branch.status}${evidence} ---`;
|
|
313
|
+
if (branch.status === "done")
|
|
314
|
+
return `${header}\n${stdoutWithEvidenceReference(result)}`;
|
|
315
|
+
const stdout = result.stdout ? `\nrejected_stdout: ${result.stdout}` : "";
|
|
316
|
+
const stderr = branch.stderr ? `\nstderr: ${branch.stderr}` : "";
|
|
317
|
+
return `${header}\nexit: ${branch.code}${stdout}${stderr}`;
|
|
318
|
+
})
|
|
319
|
+
.join("\n");
|
|
320
|
+
return [formatParallelStatusHeader(branches, minSuccessful), body]
|
|
321
|
+
.filter(Boolean)
|
|
322
|
+
.join("\n");
|
|
323
|
+
}
|
|
324
|
+
async function mapConcurrent(items, concurrency, fn) {
|
|
325
|
+
const results = new Array(items.length);
|
|
326
|
+
let nextIndex = 0;
|
|
327
|
+
async function worker() {
|
|
328
|
+
for (;;) {
|
|
329
|
+
const index = nextIndex;
|
|
330
|
+
nextIndex += 1;
|
|
331
|
+
if (index >= items.length)
|
|
332
|
+
return;
|
|
333
|
+
results[index] = await fn(items[index], index);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
await Promise.all(Array.from({ length: Math.min(concurrency, items.length) }, () => worker()));
|
|
337
|
+
return results;
|
|
338
|
+
}
|
|
339
|
+
async function executeRetriableTemplateConfig(normalized, inherited, params, exec, cwd, signal, stdin, isRoot, actorRecipeContext) {
|
|
340
|
+
const maxAttempts = normalizeRetry(normalized.retry, {
|
|
341
|
+
...(inherited.defaults ?? {}),
|
|
342
|
+
...params,
|
|
343
|
+
});
|
|
344
|
+
const attemptConfig = {
|
|
345
|
+
...normalized,
|
|
346
|
+
delay: undefined,
|
|
347
|
+
recover: undefined,
|
|
348
|
+
retry: undefined,
|
|
349
|
+
};
|
|
350
|
+
const aggregate = {
|
|
351
|
+
branches: [],
|
|
352
|
+
commands: [],
|
|
353
|
+
failures: [],
|
|
354
|
+
result: { code: 1, killed: false, stderr: "", stdout: "" },
|
|
355
|
+
};
|
|
356
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
357
|
+
const executed = await executeTemplateConfig(attemptConfig, inherited, params, exec, cwd, signal, stdin, isRoot, actorRecipeContext);
|
|
358
|
+
mergeExecution(aggregate, executed);
|
|
359
|
+
aggregate.result = executed.result;
|
|
360
|
+
aggregate.criticalFailure = executed.criticalFailure;
|
|
361
|
+
aggregate.failureScope = executed.failureScope;
|
|
362
|
+
if (executed.result.code === 0)
|
|
363
|
+
return aggregate;
|
|
364
|
+
addResultFailure(aggregate.failures, executed);
|
|
365
|
+
if (attempt === maxAttempts)
|
|
366
|
+
return aggregate;
|
|
367
|
+
if (normalized.recover === undefined)
|
|
368
|
+
continue;
|
|
369
|
+
const recovered = await executeTemplateConfig(getRecoverConfig(normalized.recover), inherited, params, exec, cwd, signal, executed.result.stdout, false, actorRecipeContext);
|
|
370
|
+
mergeExecution(aggregate, recovered);
|
|
371
|
+
if (recovered.result.code === 0)
|
|
372
|
+
continue;
|
|
373
|
+
addResultFailure(aggregate.failures, recovered);
|
|
374
|
+
aggregate.result = recovered.result;
|
|
375
|
+
aggregate.criticalFailure = recovered.criticalFailure;
|
|
376
|
+
aggregate.failureScope = maxFailureScope(recovered.failureScope, getFailureScope(normalized));
|
|
377
|
+
return aggregate;
|
|
378
|
+
}
|
|
379
|
+
return aggregate;
|
|
380
|
+
}
|
|
381
|
+
async function executeTemplateConfig(config, inherited, params, exec, cwd, signal, stdin, isRoot, inheritedActorRecipeContext) {
|
|
382
|
+
const normalized = CommandTemplates.normalizeCommandTemplateConfig(config);
|
|
383
|
+
const normalizedDefaults = CommandTemplates.resolveInheritedDefaultReferences(normalized.defaults, inherited.defaults, params);
|
|
384
|
+
const context = {
|
|
385
|
+
...(inherited.args !== undefined ? { args: inherited.args } : {}),
|
|
386
|
+
...(inherited.defaults !== undefined
|
|
387
|
+
? { defaults: inherited.defaults }
|
|
388
|
+
: {}),
|
|
389
|
+
...(normalized.args !== undefined ? { args: normalized.args } : {}),
|
|
390
|
+
...(mergeDefaults(inherited.defaults, normalizedDefaults)
|
|
391
|
+
? { defaults: mergeDefaults(inherited.defaults, normalizedDefaults) }
|
|
392
|
+
: {}),
|
|
393
|
+
};
|
|
394
|
+
const actorRecipeContext = normalized.actorRecipeContext ?? inheritedActorRecipeContext;
|
|
395
|
+
const controlValues = { ...(context.defaults ?? {}), ...params };
|
|
396
|
+
await applyDelay(normalized.delay, controlValues, signal);
|
|
397
|
+
if (!CommandTemplates.shouldRunCommandTemplateNode(normalized.when, controlValues)) {
|
|
398
|
+
return {
|
|
399
|
+
branches: [],
|
|
400
|
+
commands: [],
|
|
401
|
+
failures: [],
|
|
402
|
+
result: { code: 0, killed: false, stderr: "", stdout: stdin ?? "" },
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
getFailureScope(normalized);
|
|
406
|
+
if (normalized.repeat !== undefined) {
|
|
407
|
+
const repeat = CommandTemplates.resolveCommandTemplateRepeat(normalized.repeat, { ...(context.defaults ?? {}), ...params });
|
|
408
|
+
if (repeat === undefined)
|
|
409
|
+
throw new Error("Command template repeat could not be resolved.");
|
|
410
|
+
if (normalized.parallel === true)
|
|
411
|
+
assertParallelBranchLimit(repeat);
|
|
412
|
+
const repeatedSteps = Array.from({ length: repeat }, (_unused, index0) => {
|
|
413
|
+
const { repeat: _repeat, ...rest } = normalized;
|
|
414
|
+
return {
|
|
415
|
+
...rest,
|
|
416
|
+
defaults: {
|
|
417
|
+
...(context.defaults ?? {}),
|
|
418
|
+
...(rest.defaults ?? {}),
|
|
419
|
+
...CommandTemplates.getCommandTemplateRepeatDefaults(index0, repeat),
|
|
420
|
+
},
|
|
421
|
+
};
|
|
422
|
+
});
|
|
423
|
+
return executeTemplateConfig({
|
|
424
|
+
parallel: normalized.parallel === true,
|
|
425
|
+
...(normalized.concurrency !== undefined
|
|
426
|
+
? { concurrency: normalized.concurrency }
|
|
427
|
+
: {}),
|
|
428
|
+
...(normalized.min_successful !== undefined
|
|
429
|
+
? { min_successful: normalized.min_successful }
|
|
430
|
+
: {}),
|
|
431
|
+
...(normalized.failure !== undefined ? { failure: normalized.failure } : {}),
|
|
432
|
+
template: repeatedSteps,
|
|
433
|
+
}, context, params, exec, cwd, signal, stdin, isRoot, actorRecipeContext);
|
|
434
|
+
}
|
|
435
|
+
if (normalized.retry !== undefined &&
|
|
436
|
+
(Array.isArray(normalized.template) || normalized.recover !== undefined)) {
|
|
437
|
+
return executeRetriableTemplateConfig(normalized, context, params, exec, cwd, signal, stdin, isRoot, actorRecipeContext);
|
|
438
|
+
}
|
|
439
|
+
if (normalized.template &&
|
|
440
|
+
typeof normalized.template === "object" &&
|
|
441
|
+
!Array.isArray(normalized.template)) {
|
|
442
|
+
return executeTemplateConfig(normalized.template, context, params, exec, cwd, signal, stdin, false, actorRecipeContext);
|
|
443
|
+
}
|
|
444
|
+
if (!Array.isArray(normalized.template)) {
|
|
445
|
+
const leaf = { ...normalized, ...context };
|
|
446
|
+
const invocation = CommandTemplates.buildCommandTemplateInvocation(leaf, params, cwd, { emptyMessage: "Tool template produced an empty command." });
|
|
447
|
+
const evidenceContext = {
|
|
448
|
+
...(normalized.accept_output
|
|
449
|
+
? { acceptOutput: normalized.accept_output }
|
|
450
|
+
: {}),
|
|
451
|
+
...(normalized.label ? { label: normalized.label } : {}),
|
|
452
|
+
...(typeof controlValues.index === "string"
|
|
453
|
+
? { repeatIndex: controlValues.index }
|
|
454
|
+
: {}),
|
|
455
|
+
};
|
|
456
|
+
const rawResult = await exec(invocation.command, invocation.args, {
|
|
457
|
+
...(actorRecipeContext ? { actorRecipeContext } : {}),
|
|
458
|
+
...(Object.keys(evidenceContext).length > 0 ? { evidenceContext } : {}),
|
|
459
|
+
cwd,
|
|
460
|
+
signal,
|
|
461
|
+
stdin,
|
|
462
|
+
...(resolveNumericControlField(normalized.timeout, controlValues, "timeout") !== undefined
|
|
463
|
+
? {
|
|
464
|
+
timeout: resolveNumericControlField(normalized.timeout, controlValues, "timeout"),
|
|
465
|
+
}
|
|
466
|
+
: {}),
|
|
467
|
+
...(normalized.retry !== undefined
|
|
468
|
+
? { retry: normalizeRetry(normalized.retry, controlValues) }
|
|
469
|
+
: {}),
|
|
470
|
+
});
|
|
471
|
+
const result = await applyOutputAcceptancePolicy(rawResult, normalized.accept_output);
|
|
472
|
+
return {
|
|
473
|
+
branches: [],
|
|
474
|
+
commands: [formatInvocationDetail(invocation)],
|
|
475
|
+
failures: [],
|
|
476
|
+
result,
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
const steps = normalized.template;
|
|
480
|
+
if (steps.length === 0)
|
|
481
|
+
throw new Error(formatToolText("Tool template produced no command steps."));
|
|
482
|
+
if (normalized.parallel === true) {
|
|
483
|
+
assertParallelBranchLimit(steps.length);
|
|
484
|
+
const concurrency = normalizeConcurrency(normalized.concurrency, controlValues, steps.length);
|
|
485
|
+
const minSuccessful = normalizeMinSuccessful(normalized.min_successful, controlValues, steps.length);
|
|
486
|
+
const branchResults = await mapConcurrent(steps, concurrency, (step) => executeTemplateConfig(step, context, params, exec, cwd, signal, stdin, false, actorRecipeContext));
|
|
487
|
+
const branchPipelineStdouts = await Promise.all(branchResults.map((item) => resolvePipelineStdout(item.result)));
|
|
488
|
+
for (const [index, item] of branchResults.entries()) {
|
|
489
|
+
if (item.result.stdoutTruncated && branchPipelineStdouts[index] === undefined) {
|
|
490
|
+
item.result = rejectIncompletePipelineOutput(item.result);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
const commands = branchResults.flatMap((item) => item.commands);
|
|
494
|
+
const failures = branchResults.flatMap((item) => item.failures);
|
|
495
|
+
const branches = branchResults.map((item, index) => createBranchReport(getNodeLabel(steps[index], index), item.commands.at(-1) ?? "<template>", item.result));
|
|
496
|
+
const usableBranches = countUsableBranches(branches);
|
|
497
|
+
const quorumUnmet = minSuccessful !== undefined && usableBranches < minSuccessful;
|
|
498
|
+
const quorumFailureMessage = quorumUnmet
|
|
499
|
+
? `parallel branch quorum not met: usable ${usableBranches}/${branches.length}, minimum ${minSuccessful}`
|
|
500
|
+
: "";
|
|
501
|
+
const nodeFailure = getFailureScope(normalized);
|
|
502
|
+
const rootFailure = branchResults.find((item, index) => {
|
|
503
|
+
if (item.result.code === 0)
|
|
504
|
+
return false;
|
|
505
|
+
const branchFailure = maxFailureScope(item.failureScope, item.criticalFailure ? "root" : undefined, getFailureScope(steps[index]), nodeFailure);
|
|
506
|
+
return branchFailure === "root";
|
|
507
|
+
});
|
|
508
|
+
if (rootFailure) {
|
|
509
|
+
return {
|
|
510
|
+
branches: [
|
|
511
|
+
...branchResults.flatMap((item) => item.branches),
|
|
512
|
+
...branches,
|
|
513
|
+
],
|
|
514
|
+
commands,
|
|
515
|
+
criticalFailure: true,
|
|
516
|
+
failureScope: "root",
|
|
517
|
+
failures,
|
|
518
|
+
result: rootFailure.result,
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
const firstFailedBranch = branchResults.find((item) => item.result.code !== 0);
|
|
522
|
+
const allBranchesUnusable = branches.every((branch) => !isUsableBranch(branch));
|
|
523
|
+
const successful = branchResults.map((item) => {
|
|
524
|
+
if (item.result.code === 0)
|
|
525
|
+
return item.result;
|
|
526
|
+
addResultFailure(failures, item);
|
|
527
|
+
return { ...item.result, code: 0 };
|
|
528
|
+
});
|
|
529
|
+
const completeSuccessful = successful.map((item, index) => ({
|
|
530
|
+
...item,
|
|
531
|
+
stdout: branchPipelineStdouts[index] ?? item.stdout,
|
|
532
|
+
evidenceRef: undefined,
|
|
533
|
+
}));
|
|
534
|
+
const result = {
|
|
535
|
+
code: 0,
|
|
536
|
+
killed: successful.some((item) => item.killed),
|
|
537
|
+
stderr: successful
|
|
538
|
+
.map((item) => item.stderr)
|
|
539
|
+
.filter(Boolean)
|
|
540
|
+
.join("\n"),
|
|
541
|
+
stdout: joinParallelStdout(branches, successful, minSuccessful),
|
|
542
|
+
pipelineStdout: joinParallelStdout(branches, completeSuccessful, minSuccessful),
|
|
543
|
+
stdoutBytes: successful.reduce((total, item) => total + (item.stdoutBytes ?? Buffer.byteLength(item.stdout)), 0),
|
|
544
|
+
...(successful.some((item) => item.stdoutTruncated)
|
|
545
|
+
? { stdoutTruncated: true }
|
|
546
|
+
: {}),
|
|
547
|
+
};
|
|
548
|
+
if (quorumUnmet && nodeFailure === "root") {
|
|
549
|
+
return {
|
|
550
|
+
commands,
|
|
551
|
+
branches: [
|
|
552
|
+
...branchResults.flatMap((item) => item.branches),
|
|
553
|
+
...branches,
|
|
554
|
+
],
|
|
555
|
+
criticalFailure: true,
|
|
556
|
+
failureScope: "root",
|
|
557
|
+
failures,
|
|
558
|
+
result: {
|
|
559
|
+
...result,
|
|
560
|
+
code: firstFailedBranch?.result.code || 1,
|
|
561
|
+
stderr: [result.stderr, quorumFailureMessage]
|
|
562
|
+
.filter(Boolean)
|
|
563
|
+
.join("\n"),
|
|
564
|
+
},
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
const branchFailureTriggered = minSuccessful === undefined
|
|
568
|
+
? firstFailedBranch || allBranchesUnusable
|
|
569
|
+
: quorumUnmet;
|
|
570
|
+
if (branchFailureTriggered && nodeFailure === "branch") {
|
|
571
|
+
return {
|
|
572
|
+
commands,
|
|
573
|
+
branches: [
|
|
574
|
+
...branchResults.flatMap((item) => item.branches),
|
|
575
|
+
...branches,
|
|
576
|
+
],
|
|
577
|
+
failureScope: "branch",
|
|
578
|
+
failures,
|
|
579
|
+
result: {
|
|
580
|
+
...result,
|
|
581
|
+
code: firstFailedBranch?.result.code || 1,
|
|
582
|
+
stderr: [
|
|
583
|
+
result.stderr,
|
|
584
|
+
allBranchesUnusable
|
|
585
|
+
? "all parallel branches failed or produced empty output"
|
|
586
|
+
: "",
|
|
587
|
+
quorumFailureMessage,
|
|
588
|
+
]
|
|
589
|
+
.filter(Boolean)
|
|
590
|
+
.join("\n"),
|
|
591
|
+
},
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
return {
|
|
595
|
+
commands,
|
|
596
|
+
branches: [
|
|
597
|
+
...branchResults.flatMap((item) => item.branches),
|
|
598
|
+
...branches,
|
|
599
|
+
],
|
|
600
|
+
failures,
|
|
601
|
+
result,
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
const branches = [];
|
|
605
|
+
const commands = [];
|
|
606
|
+
const failures = [];
|
|
607
|
+
let nextStdin = stdin;
|
|
608
|
+
let result;
|
|
609
|
+
for (const [stepIndex, step] of steps.entries()) {
|
|
610
|
+
const executed = await executeTemplateConfig(step, context, params, exec, cwd, signal, nextStdin, false, actorRecipeContext);
|
|
611
|
+
branches.push(...executed.branches);
|
|
612
|
+
commands.push(...executed.commands);
|
|
613
|
+
failures.push(...executed.failures);
|
|
614
|
+
const pipelineStdout = await resolvePipelineStdout(executed.result);
|
|
615
|
+
const incompletePipelineInput = stepIndex < steps.length - 1 && pipelineStdout === undefined;
|
|
616
|
+
result = incompletePipelineInput
|
|
617
|
+
? rejectIncompletePipelineOutput(executed.result)
|
|
618
|
+
: executed.result;
|
|
619
|
+
executed.result = result;
|
|
620
|
+
if (incompletePipelineInput) {
|
|
621
|
+
addResultFailure(failures, executed);
|
|
622
|
+
return {
|
|
623
|
+
branches,
|
|
624
|
+
commands,
|
|
625
|
+
criticalFailure: true,
|
|
626
|
+
failureScope: "root",
|
|
627
|
+
failures,
|
|
628
|
+
result,
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
if (result.code !== 0) {
|
|
632
|
+
const failureScope = maxFailureScope(executed.failureScope, executed.criticalFailure ? "root" : undefined, getFailureScope(step), getFailureScope(normalized), isRoot && steps.length === 1 ? "root" : undefined);
|
|
633
|
+
if (failureScope === "root") {
|
|
634
|
+
return {
|
|
635
|
+
branches,
|
|
636
|
+
commands,
|
|
637
|
+
criticalFailure: true,
|
|
638
|
+
failureScope: "root",
|
|
639
|
+
failures,
|
|
640
|
+
result,
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
if (failureScope === "branch") {
|
|
644
|
+
addResultFailure(failures, executed);
|
|
645
|
+
return {
|
|
646
|
+
branches,
|
|
647
|
+
commands,
|
|
648
|
+
failureScope: "branch",
|
|
649
|
+
failures,
|
|
650
|
+
result,
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
addResultFailure(failures, executed);
|
|
654
|
+
result = { ...result, code: 0, stdout: "" };
|
|
655
|
+
nextStdin = "";
|
|
656
|
+
continue;
|
|
657
|
+
}
|
|
658
|
+
nextStdin = pipelineStdout;
|
|
659
|
+
}
|
|
660
|
+
return { branches, commands, failures, result: result };
|
|
661
|
+
}
|
|
662
|
+
async function executeTemplateSteps(cfg, params, exec, cwd, signal) {
|
|
663
|
+
return executeTemplateConfig(createTemplateConfig(cfg), {}, params, exec, cwd, signal, undefined, true, undefined);
|
|
664
|
+
}
|
|
665
|
+
function getCaptureDetails(result) {
|
|
666
|
+
return {
|
|
667
|
+
stdoutBytes: result.stdoutBytes ?? Buffer.byteLength(result.stdout),
|
|
668
|
+
stdoutCapturedBytes: Buffer.byteLength(result.stdout),
|
|
669
|
+
stderrBytes: result.stderrBytes ?? Buffer.byteLength(result.stderr),
|
|
670
|
+
stderrCapturedBytes: Buffer.byteLength(result.stderr),
|
|
671
|
+
...(result.stdoutFile ? { stdoutFile: result.stdoutFile } : {}),
|
|
672
|
+
...(result.stderrFile ? { stderrFile: result.stderrFile } : {}),
|
|
673
|
+
...(result.stdoutTruncated ? { stdoutTruncated: true } : {}),
|
|
674
|
+
...(result.stderrTruncated ? { stderrTruncated: true } : {}),
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
export async function executeRegisteredTool(cfg, params, exec, cwd, signal) {
|
|
678
|
+
const executed = await executeTemplateSteps(cfg, Schema.normalizeRuntimeValues(params, cfg.argTypes), exec, cwd, signal);
|
|
679
|
+
const command = formatCommandDetail(executed.commands);
|
|
680
|
+
const result = executed.result;
|
|
681
|
+
const softQuorum = createSoftQuorum(executed.branches);
|
|
682
|
+
if (result.code !== 0) {
|
|
683
|
+
const formatted = formatFailureOutput(cfg.name, result.code, result.killed, result.stdout, result.stderr);
|
|
684
|
+
throw Object.assign(new Error(formatted.text), {
|
|
685
|
+
details: {
|
|
686
|
+
branches: executed.branches,
|
|
687
|
+
code: result.code,
|
|
688
|
+
command,
|
|
689
|
+
fullOutputPath: result.stdoutFile ?? formatted.fullOutputPath,
|
|
690
|
+
killed: result.killed,
|
|
691
|
+
...getCaptureDetails(result),
|
|
692
|
+
...(executed.failures.length > 0
|
|
693
|
+
? { nonCriticalFailures: executed.failures }
|
|
694
|
+
: {}),
|
|
695
|
+
...(softQuorum ? { softQuorum } : {}),
|
|
696
|
+
failureReason: getExecutionFailureReason(executed.branches, softQuorum, result.stderr),
|
|
697
|
+
template: cfg.template,
|
|
698
|
+
tool: cfg.name,
|
|
699
|
+
truncated: formatted.truncated,
|
|
700
|
+
},
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
const formatted = formatOutput(cfg.name, "stdout", result.stdout);
|
|
704
|
+
const templateWarnings = CommandTemplates.getCommandTemplateWarnings(createTemplateConfig(cfg));
|
|
705
|
+
return {
|
|
706
|
+
content: [textContent(formatted.text)],
|
|
707
|
+
details: {
|
|
708
|
+
code: result.code,
|
|
709
|
+
command,
|
|
710
|
+
fullOutputPath: result.stdoutFile ?? formatted.fullOutputPath,
|
|
711
|
+
killed: result.killed,
|
|
712
|
+
launch_kind: "tool",
|
|
713
|
+
...getCaptureDetails(result),
|
|
714
|
+
...(executed.branches.length > 0 ? { branches: executed.branches } : {}),
|
|
715
|
+
...(executed.failures.length > 0
|
|
716
|
+
? { nonCriticalFailures: executed.failures }
|
|
717
|
+
: {}),
|
|
718
|
+
...(softQuorum ? { softQuorum } : {}),
|
|
719
|
+
template: cfg.template,
|
|
720
|
+
...(templateWarnings.length > 0 ? { templateWarnings } : {}),
|
|
721
|
+
tool: cfg.name,
|
|
722
|
+
truncated: formatted.truncated,
|
|
723
|
+
},
|
|
724
|
+
};
|
|
725
|
+
}
|