@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,635 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automatic active-tool portfolio review admission.
|
|
3
|
+
* Zones: revision eligibility, immutable thirty-six-tool capture, persisted review state
|
|
4
|
+
* Owns exact portfolio admission; reviewer execution and recipe mutation remain separate domains.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
8
|
+
import { existsSync, readFileSync, rmSync, statSync } from "node:fs";
|
|
9
|
+
import { dirname, join } from "node:path";
|
|
10
|
+
|
|
11
|
+
import { withFileMutationLock, writeJsonAtomic } from "./file-state.ts";
|
|
12
|
+
import * as Paths from "./paths.ts";
|
|
13
|
+
import * as RecipesDiscovery from "./recipes-discovery.ts";
|
|
14
|
+
import * as RecipesReferences from "./recipes-references.ts";
|
|
15
|
+
import * as RecipesUsage from "./recipes-usage.ts";
|
|
16
|
+
import * as ReviewProjection from "./review-projection.ts";
|
|
17
|
+
import * as ToolReviewLineage from "./tool-review-lineage.ts";
|
|
18
|
+
import * as ToolReviewLineageTransaction from "./tool-review-lineage-transaction.ts";
|
|
19
|
+
import * as ToolReviewTransaction from "./tool-review-transaction.ts";
|
|
20
|
+
import { findUnsafeRecipeReason } from "./draft-review.ts";
|
|
21
|
+
import {
|
|
22
|
+
parseToolReviewResult,
|
|
23
|
+
TOOL_REVIEW_THRESHOLD,
|
|
24
|
+
validateToolReviewInput,
|
|
25
|
+
validateToolReviewResult,
|
|
26
|
+
type ToolReviewDecision,
|
|
27
|
+
type ToolReviewInput,
|
|
28
|
+
type ToolReviewTool,
|
|
29
|
+
} from "./tool-review.ts";
|
|
30
|
+
|
|
31
|
+
export const TOOL_REVIEW_RESULT_MAX_BYTES = 16 * 1024 * 1024;
|
|
32
|
+
|
|
33
|
+
export interface ToolReviewBatch {
|
|
34
|
+
inputPath: string;
|
|
35
|
+
reviewerInputPath: string;
|
|
36
|
+
reviewId: string;
|
|
37
|
+
toolNames: string[];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface ToolReviewAdmissionState {
|
|
41
|
+
approvedPath?: string;
|
|
42
|
+
attempts: number;
|
|
43
|
+
failedStage?: string;
|
|
44
|
+
lastError?: string;
|
|
45
|
+
lineageJournalPath?: string;
|
|
46
|
+
inputPath: string;
|
|
47
|
+
nextAction?: string;
|
|
48
|
+
phase: "approved" | "captured" | "completed" | "failed" | "launched" | "lineage_pending" | "processing_failed";
|
|
49
|
+
processingAttempts?: number;
|
|
50
|
+
reviewerInputPath: string;
|
|
51
|
+
reviewId: string;
|
|
52
|
+
runId?: string;
|
|
53
|
+
toolNames: string[];
|
|
54
|
+
transactionEvidencePath?: string;
|
|
55
|
+
updatedAt: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface ToolReviewSchedulerDeps extends CaptureToolReviewOptions {
|
|
59
|
+
delayMs?: number;
|
|
60
|
+
hasActiveActors(): boolean;
|
|
61
|
+
launch(batch: ToolReviewBatch): { run: string };
|
|
62
|
+
process?(state: ToolReviewAdmissionState): ToolReviewProcessResult;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface ToolReviewProcessResult {
|
|
66
|
+
approvedPath?: string;
|
|
67
|
+
error?: string;
|
|
68
|
+
outcome: "approved" | "pending" | "processing_failed" | "review_failed";
|
|
69
|
+
stage?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface ToolReviewScheduler {
|
|
73
|
+
close(): void;
|
|
74
|
+
schedule(): void;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface CaptureToolReviewOptions {
|
|
78
|
+
batchRoot?(reviewId: string): string;
|
|
79
|
+
createReviewId?(): string;
|
|
80
|
+
now?(): Date;
|
|
81
|
+
recipeRoot?: string;
|
|
82
|
+
statePath?: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function sha256(path: string): string {
|
|
86
|
+
return createHash("sha256").update(readFileSync(path)).digest("hex");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function readAdmissionState(path: string): ToolReviewAdmissionState | undefined {
|
|
90
|
+
try {
|
|
91
|
+
const value = JSON.parse(readFileSync(path, "utf8")) as ToolReviewAdmissionState;
|
|
92
|
+
return value && typeof value === "object" ? value : undefined;
|
|
93
|
+
} catch {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function usageOrder(tool: ToolReviewTool): string {
|
|
99
|
+
const firstSeen = tool.usage?.first_seen;
|
|
100
|
+
return typeof firstSeen === "string" ? firstSeen : "";
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function listEligibleToolReviewRecipes(
|
|
104
|
+
recipeRoot = Paths.getRecipeRoot(),
|
|
105
|
+
now = new Date(),
|
|
106
|
+
): ToolReviewTool[] {
|
|
107
|
+
const discovered = RecipesDiscovery.discoverRecipeSources([
|
|
108
|
+
{ root: recipeRoot, defaultTool: true, mutableUsage: true },
|
|
109
|
+
]);
|
|
110
|
+
return [...discovered.active.values()]
|
|
111
|
+
.filter((entry) => entry.active && entry.tool && !entry.invalid && !entry.disabled)
|
|
112
|
+
.flatMap((entry) => {
|
|
113
|
+
if (!RecipesUsage.ensureRecipeLineage(entry.path, now, recipeRoot)) return [];
|
|
114
|
+
if (RecipesUsage.isCurrentRecipeRevisionReviewed(entry.path, recipeRoot)) return [];
|
|
115
|
+
const recipe = RecipesReferences.readRawRecipeConfig(entry.path);
|
|
116
|
+
if (
|
|
117
|
+
!recipe ||
|
|
118
|
+
entry.riskLabels.includes("risk.secret_touching") ||
|
|
119
|
+
findUnsafeRecipeReason(recipe)
|
|
120
|
+
) return [];
|
|
121
|
+
return [{
|
|
122
|
+
name: entry.id,
|
|
123
|
+
path: entry.path,
|
|
124
|
+
recipe,
|
|
125
|
+
riskLabels: [...entry.riskLabels],
|
|
126
|
+
sha256: sha256(entry.path),
|
|
127
|
+
usage: RecipesUsage.readRecipeUsage(entry.path, recipeRoot),
|
|
128
|
+
valid: true,
|
|
129
|
+
} satisfies ToolReviewTool];
|
|
130
|
+
})
|
|
131
|
+
.sort((left, right) =>
|
|
132
|
+
usageOrder(left).localeCompare(usageOrder(right)) ||
|
|
133
|
+
left.name.localeCompare(right.name),
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function captureToolReviewBatchLocked(
|
|
138
|
+
options: CaptureToolReviewOptions,
|
|
139
|
+
recipeRoot: string,
|
|
140
|
+
statePath: string,
|
|
141
|
+
now: () => Date,
|
|
142
|
+
): ToolReviewBatch | undefined {
|
|
143
|
+
const state = readAdmissionState(statePath);
|
|
144
|
+
if (
|
|
145
|
+
state?.phase === "captured" ||
|
|
146
|
+
state?.phase === "launched" ||
|
|
147
|
+
state?.phase === "processing_failed"
|
|
148
|
+
) return undefined;
|
|
149
|
+
const eligible = listEligibleToolReviewRecipes(recipeRoot, now());
|
|
150
|
+
if (eligible.length < TOOL_REVIEW_THRESHOLD) return undefined;
|
|
151
|
+
const reviewId = (options.createReviewId ?? randomUUID)();
|
|
152
|
+
const inputPath = join(
|
|
153
|
+
(options.batchRoot ?? Paths.getToolReviewBatchDir)(reviewId),
|
|
154
|
+
"input.json",
|
|
155
|
+
);
|
|
156
|
+
const tools = eligible.slice(0, TOOL_REVIEW_THRESHOLD);
|
|
157
|
+
const input: ToolReviewInput = {
|
|
158
|
+
createdAt: now().toISOString(),
|
|
159
|
+
reviewId,
|
|
160
|
+
tools,
|
|
161
|
+
};
|
|
162
|
+
const validation = validateToolReviewInput(input);
|
|
163
|
+
if (!validation.ok) {
|
|
164
|
+
throw new Error(`Tool review input rejected: ${validation.errors.join("; ")}`);
|
|
165
|
+
}
|
|
166
|
+
writeJsonAtomic(inputPath, input);
|
|
167
|
+
const reviewerInputPath = join(dirname(inputPath), "review-input.json");
|
|
168
|
+
writeJsonAtomic(reviewerInputPath, ReviewProjection.projectToolReviewInput(input));
|
|
169
|
+
const toolNames = tools.map((tool) => tool.name);
|
|
170
|
+
writeJsonAtomic(statePath, {
|
|
171
|
+
attempts: 0,
|
|
172
|
+
inputPath,
|
|
173
|
+
phase: "captured",
|
|
174
|
+
reviewerInputPath,
|
|
175
|
+
reviewId,
|
|
176
|
+
toolNames,
|
|
177
|
+
updatedAt: input.createdAt,
|
|
178
|
+
} satisfies ToolReviewAdmissionState);
|
|
179
|
+
return { inputPath, reviewerInputPath, reviewId, toolNames };
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function captureToolReviewBatch(
|
|
183
|
+
options: CaptureToolReviewOptions = {},
|
|
184
|
+
): ToolReviewBatch | undefined {
|
|
185
|
+
const recipeRoot = options.recipeRoot ?? Paths.getRecipeRoot();
|
|
186
|
+
const statePath = options.statePath ?? Paths.getToolReviewStatePath();
|
|
187
|
+
const now = options.now ?? (() => new Date());
|
|
188
|
+
return withFileMutationLock(statePath, () =>
|
|
189
|
+
captureToolReviewBatchLocked(options, recipeRoot, statePath, now),
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function approvedTargets(
|
|
194
|
+
input: ToolReviewInput,
|
|
195
|
+
decisions: ToolReviewDecision[],
|
|
196
|
+
recipeRoot: string,
|
|
197
|
+
): ToolReviewTransaction.ToolReviewApprovedTarget[] {
|
|
198
|
+
const targets = new Map<string, ToolReviewTransaction.ToolReviewApprovedTarget>();
|
|
199
|
+
const tools = new Map(input.tools.map((tool) => [tool.name, tool]));
|
|
200
|
+
const add = (
|
|
201
|
+
name: string,
|
|
202
|
+
path: string,
|
|
203
|
+
recipe: Record<string, unknown>,
|
|
204
|
+
lineage: ToolReviewTransaction.ToolReviewApprovedTarget["lineage"],
|
|
205
|
+
source: string,
|
|
206
|
+
): void => {
|
|
207
|
+
const existing = targets.get(path);
|
|
208
|
+
if (existing) {
|
|
209
|
+
if (lineage !== "merge" || existing.lineage !== "merge") {
|
|
210
|
+
throw new Error(`Duplicate tool review target: ${path}`);
|
|
211
|
+
}
|
|
212
|
+
existing.sources.push(source);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const sourceAtPath = input.tools.find((tool) => tool.path === path);
|
|
216
|
+
if (existsSync(path) && !sourceAtPath) {
|
|
217
|
+
throw new Error(`Tool review target appeared after capture: ${path}`);
|
|
218
|
+
}
|
|
219
|
+
targets.set(path, {
|
|
220
|
+
expectedSha256: sourceAtPath?.sha256 ?? null,
|
|
221
|
+
lineage,
|
|
222
|
+
name,
|
|
223
|
+
path,
|
|
224
|
+
recipe,
|
|
225
|
+
sources: [source],
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
for (const decision of decisions) {
|
|
229
|
+
const source = tools.get(decision.source)!;
|
|
230
|
+
if (decision.action === "keep") continue;
|
|
231
|
+
if (decision.action === "demote") {
|
|
232
|
+
add(
|
|
233
|
+
decision.source,
|
|
234
|
+
join(recipeRoot, "drafts", `${decision.source}.json`),
|
|
235
|
+
source.recipe,
|
|
236
|
+
"demote",
|
|
237
|
+
decision.source,
|
|
238
|
+
);
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (decision.action === "evolve") {
|
|
242
|
+
const source = tools.get(decision.source)!;
|
|
243
|
+
add(
|
|
244
|
+
decision.target!,
|
|
245
|
+
join(recipeRoot, `${decision.target}.json`),
|
|
246
|
+
source.recipe,
|
|
247
|
+
"evolve",
|
|
248
|
+
decision.source,
|
|
249
|
+
);
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
if (decision.action === "merge") {
|
|
253
|
+
const source = tools.get(decision.source)!;
|
|
254
|
+
add(
|
|
255
|
+
decision.target!,
|
|
256
|
+
join(recipeRoot, `${decision.target}.json`),
|
|
257
|
+
source.recipe,
|
|
258
|
+
"merge",
|
|
259
|
+
decision.source,
|
|
260
|
+
);
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
throw new Error(
|
|
264
|
+
`${decision.action} requires explicit operator-authored recipe mutation.`,
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
return [...targets.values()].sort((left, right) => left.path.localeCompare(right.path));
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface ProcessToolReviewDeps {
|
|
271
|
+
draftRoot?: string;
|
|
272
|
+
getRunStatus(runId: string): Record<string, unknown>;
|
|
273
|
+
now?(): Date;
|
|
274
|
+
recipeRoot?: string;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export function processToolReviewResult(
|
|
278
|
+
state: ToolReviewAdmissionState,
|
|
279
|
+
deps: ProcessToolReviewDeps,
|
|
280
|
+
): ToolReviewProcessResult {
|
|
281
|
+
if (!state.runId) {
|
|
282
|
+
return { error: "review run id is unavailable", outcome: "review_failed", stage: "review_state" };
|
|
283
|
+
}
|
|
284
|
+
let status: Record<string, unknown>;
|
|
285
|
+
try {
|
|
286
|
+
status = deps.getRunStatus(state.runId);
|
|
287
|
+
} catch (error) {
|
|
288
|
+
return {
|
|
289
|
+
error: error instanceof Error ? error.message : String(error),
|
|
290
|
+
outcome: "review_failed",
|
|
291
|
+
stage: "review_state",
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
if (status.status === "running") return { outcome: "pending" };
|
|
295
|
+
if (status.status !== "done" || typeof status.state_dir !== "string") {
|
|
296
|
+
return {
|
|
297
|
+
error: `review run ended with status ${String(status.status ?? "unknown")}`,
|
|
298
|
+
outcome: "review_failed",
|
|
299
|
+
stage: "review_run",
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
let input: ToolReviewInput;
|
|
303
|
+
let result: ReturnType<typeof parseToolReviewResult>;
|
|
304
|
+
try {
|
|
305
|
+
input = JSON.parse(readFileSync(state.inputPath, "utf8")) as ToolReviewInput;
|
|
306
|
+
const stdoutPath = join(status.state_dir, "stdout.log");
|
|
307
|
+
if (statSync(stdoutPath).size > TOOL_REVIEW_RESULT_MAX_BYTES) {
|
|
308
|
+
throw new Error("Tool reviewer output exceeds the approval limit.");
|
|
309
|
+
}
|
|
310
|
+
result = ReviewProjection.restoreToolReviewResult(
|
|
311
|
+
input,
|
|
312
|
+
parseToolReviewResult(readFileSync(stdoutPath, "utf8")),
|
|
313
|
+
);
|
|
314
|
+
} catch (error) {
|
|
315
|
+
return {
|
|
316
|
+
error: error instanceof Error ? error.message : String(error),
|
|
317
|
+
outcome: "review_failed",
|
|
318
|
+
stage: "result_parse",
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
const validation = validateToolReviewResult(input, result);
|
|
322
|
+
if (!validation.ok) {
|
|
323
|
+
return {
|
|
324
|
+
error: validation.errors.join("; "),
|
|
325
|
+
outcome: "review_failed",
|
|
326
|
+
stage: "result_validation",
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
try {
|
|
330
|
+
for (const tool of input.tools) {
|
|
331
|
+
if (!existsSync(tool.path) || sha256(tool.path) !== tool.sha256) {
|
|
332
|
+
throw new Error(`Reviewed tool changed after capture: ${tool.name}`);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
const recipeRoot = deps.recipeRoot ?? Paths.getRecipeRoot();
|
|
336
|
+
const plan: ToolReviewTransaction.ToolReviewApprovedPlan = {
|
|
337
|
+
createdAt: (deps.now ?? (() => new Date()))().toISOString(),
|
|
338
|
+
decisions: result.decisions,
|
|
339
|
+
reviewId: state.reviewId,
|
|
340
|
+
sources: result.decisions.map((decision) => {
|
|
341
|
+
const tool = input.tools.find((candidate) => candidate.name === decision.source)!;
|
|
342
|
+
return {
|
|
343
|
+
action: decision.action,
|
|
344
|
+
name: tool.name,
|
|
345
|
+
path: tool.path,
|
|
346
|
+
sha256: tool.sha256,
|
|
347
|
+
};
|
|
348
|
+
}),
|
|
349
|
+
targets: approvedTargets(input, result.decisions, recipeRoot),
|
|
350
|
+
};
|
|
351
|
+
ToolReviewLineage.projectToolReviewLineage(plan);
|
|
352
|
+
if (Buffer.byteLength(JSON.stringify(plan)) > TOOL_REVIEW_RESULT_MAX_BYTES) {
|
|
353
|
+
throw new Error("Tool review approved plan exceeds the persistence limit.");
|
|
354
|
+
}
|
|
355
|
+
const approvedPath = join(dirname(state.inputPath), "approved.json");
|
|
356
|
+
writeJsonAtomic(approvedPath, plan);
|
|
357
|
+
return { approvedPath, outcome: "approved" };
|
|
358
|
+
} catch (error) {
|
|
359
|
+
return {
|
|
360
|
+
error: error instanceof Error ? error.message : String(error),
|
|
361
|
+
outcome: "processing_failed",
|
|
362
|
+
stage: "approval",
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export interface ToolReviewBoundaryResult {
|
|
368
|
+
outcome: "completed" | "lineage_pending" | "none" | "processing_failed";
|
|
369
|
+
state?: ToolReviewAdmissionState;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export function applyApprovedToolReviewAtSessionBoundary(
|
|
373
|
+
options: {
|
|
374
|
+
lifecycleHooks?: {
|
|
375
|
+
onCompleted?(): void;
|
|
376
|
+
onLineagePending?(): void;
|
|
377
|
+
onStateLocked?(): void;
|
|
378
|
+
};
|
|
379
|
+
now?(): Date;
|
|
380
|
+
recipeRoot?: string;
|
|
381
|
+
statePath?: string;
|
|
382
|
+
} = {},
|
|
383
|
+
): ToolReviewBoundaryResult {
|
|
384
|
+
const statePath = options.statePath ?? Paths.getToolReviewStatePath();
|
|
385
|
+
const recipeRoot = options.recipeRoot ?? Paths.getRecipeRoot();
|
|
386
|
+
return withFileMutationLock(statePath, () => {
|
|
387
|
+
options.lifecycleHooks?.onStateLocked?.();
|
|
388
|
+
const state = readAdmissionState(statePath);
|
|
389
|
+
if (!state) return { outcome: "none" };
|
|
390
|
+
if (state.phase === "completed") {
|
|
391
|
+
if (state.approvedPath) {
|
|
392
|
+
rmSync(join(dirname(state.approvedPath), "quarantine"), {
|
|
393
|
+
recursive: true,
|
|
394
|
+
force: true,
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
return { outcome: "completed", state };
|
|
398
|
+
}
|
|
399
|
+
if (state.phase !== "approved" && state.phase !== "lineage_pending") {
|
|
400
|
+
return { outcome: "none" };
|
|
401
|
+
}
|
|
402
|
+
if (!state.approvedPath) {
|
|
403
|
+
const failed = {
|
|
404
|
+
...state,
|
|
405
|
+
failedStage: "approval_state",
|
|
406
|
+
lastError: "approved review path is unavailable",
|
|
407
|
+
nextAction: "message target=runtime action=review.retry input={\"scope\":\"tool\"}",
|
|
408
|
+
phase: "processing_failed" as const,
|
|
409
|
+
updatedAt: (options.now ?? (() => new Date()))().toISOString(),
|
|
410
|
+
};
|
|
411
|
+
writeJsonAtomic(statePath, failed);
|
|
412
|
+
return { outcome: "processing_failed", state: failed };
|
|
413
|
+
}
|
|
414
|
+
try {
|
|
415
|
+
const journalPath = join(dirname(state.approvedPath), "journal.json");
|
|
416
|
+
const transaction = existsSync(journalPath)
|
|
417
|
+
? ToolReviewTransaction.recoverToolReviewTransaction(state.approvedPath, {
|
|
418
|
+
now: options.now,
|
|
419
|
+
recipeRoot,
|
|
420
|
+
})
|
|
421
|
+
: ToolReviewTransaction.applyToolReviewPlan(state.approvedPath, {
|
|
422
|
+
now: options.now,
|
|
423
|
+
recipeRoot,
|
|
424
|
+
});
|
|
425
|
+
if (transaction.phase !== "committed") {
|
|
426
|
+
const failed = {
|
|
427
|
+
...state,
|
|
428
|
+
failedStage: "transaction",
|
|
429
|
+
lastError: `tool review transaction remained ${transaction.phase}`,
|
|
430
|
+
nextAction: "message target=runtime action=review.retry input={\"scope\":\"tool\"}",
|
|
431
|
+
phase: "processing_failed" as const,
|
|
432
|
+
updatedAt: (options.now ?? (() => new Date()))().toISOString(),
|
|
433
|
+
};
|
|
434
|
+
writeJsonAtomic(statePath, failed);
|
|
435
|
+
return { outcome: "processing_failed", state: failed };
|
|
436
|
+
}
|
|
437
|
+
const pending = {
|
|
438
|
+
...state,
|
|
439
|
+
...(transaction.evidencePath
|
|
440
|
+
? { transactionEvidencePath: transaction.evidencePath }
|
|
441
|
+
: {}),
|
|
442
|
+
phase: "lineage_pending" as const,
|
|
443
|
+
updatedAt: (options.now ?? (() => new Date()))().toISOString(),
|
|
444
|
+
};
|
|
445
|
+
writeJsonAtomic(statePath, pending);
|
|
446
|
+
options.lifecycleHooks?.onLineagePending?.();
|
|
447
|
+
let lineage: ToolReviewLineageTransaction.ToolReviewLineageTransactionResult;
|
|
448
|
+
try {
|
|
449
|
+
lineage = ToolReviewLineageTransaction.finalizeToolReviewLineage(
|
|
450
|
+
state.approvedPath,
|
|
451
|
+
{
|
|
452
|
+
now: options.now,
|
|
453
|
+
recipeRoot,
|
|
454
|
+
},
|
|
455
|
+
);
|
|
456
|
+
} catch (error) {
|
|
457
|
+
const failedPending = {
|
|
458
|
+
...pending,
|
|
459
|
+
failedStage: "lineage",
|
|
460
|
+
lastError: error instanceof Error ? error.message : String(error),
|
|
461
|
+
nextAction: "message target=runtime action=review.retry input={\"scope\":\"tool\"}",
|
|
462
|
+
};
|
|
463
|
+
writeJsonAtomic(statePath, failedPending);
|
|
464
|
+
return { outcome: "lineage_pending", state: failedPending };
|
|
465
|
+
}
|
|
466
|
+
const completed = {
|
|
467
|
+
...pending,
|
|
468
|
+
lineageJournalPath: lineage.journalPath,
|
|
469
|
+
phase: "completed" as const,
|
|
470
|
+
updatedAt: (options.now ?? (() => new Date()))().toISOString(),
|
|
471
|
+
};
|
|
472
|
+
writeJsonAtomic(statePath, completed);
|
|
473
|
+
options.lifecycleHooks?.onCompleted?.();
|
|
474
|
+
rmSync(transaction.quarantineDir, { recursive: true, force: true });
|
|
475
|
+
return { outcome: "completed", state: completed };
|
|
476
|
+
} catch (error) {
|
|
477
|
+
const failed = {
|
|
478
|
+
...state,
|
|
479
|
+
failedStage: "transaction",
|
|
480
|
+
lastError: error instanceof Error ? error.message : String(error),
|
|
481
|
+
nextAction: "message target=runtime action=review.retry input={\"scope\":\"tool\"}",
|
|
482
|
+
phase: "processing_failed" as const,
|
|
483
|
+
updatedAt: (options.now ?? (() => new Date()))().toISOString(),
|
|
484
|
+
};
|
|
485
|
+
writeJsonAtomic(statePath, failed);
|
|
486
|
+
return { outcome: "processing_failed", state: failed };
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
export function createToolReviewScheduler(
|
|
492
|
+
deps: ToolReviewSchedulerDeps,
|
|
493
|
+
): ToolReviewScheduler {
|
|
494
|
+
const statePath = deps.statePath ?? Paths.getToolReviewStatePath();
|
|
495
|
+
const recipeRoot = deps.recipeRoot ?? Paths.getRecipeRoot();
|
|
496
|
+
const now = deps.now ?? (() => new Date());
|
|
497
|
+
let timer: NodeJS.Timeout | undefined;
|
|
498
|
+
let closed = false;
|
|
499
|
+
const close = (): void => {
|
|
500
|
+
closed = true;
|
|
501
|
+
if (timer) clearTimeout(timer);
|
|
502
|
+
timer = undefined;
|
|
503
|
+
};
|
|
504
|
+
const schedule = (): void => {
|
|
505
|
+
if (closed || timer) return;
|
|
506
|
+
timer = setTimeout(() => {
|
|
507
|
+
timer = undefined;
|
|
508
|
+
if (closed || deps.hasActiveActors()) return;
|
|
509
|
+
try {
|
|
510
|
+
withFileMutationLock(statePath, () => {
|
|
511
|
+
const existing = readAdmissionState(statePath);
|
|
512
|
+
if (
|
|
513
|
+
existing?.phase === "launched" ||
|
|
514
|
+
existing?.phase === "processing_failed"
|
|
515
|
+
) {
|
|
516
|
+
if (!deps.process || (existing.processingAttempts ?? 0) >= 3) return;
|
|
517
|
+
let processed: ToolReviewProcessResult;
|
|
518
|
+
try {
|
|
519
|
+
processed = deps.process(existing);
|
|
520
|
+
} catch (error) {
|
|
521
|
+
processed = {
|
|
522
|
+
error: error instanceof Error ? error.message : String(error),
|
|
523
|
+
outcome: "processing_failed",
|
|
524
|
+
stage: "result_processing",
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
if (processed.outcome === "pending") return;
|
|
528
|
+
if (processed.outcome === "approved") {
|
|
529
|
+
writeJsonAtomic(statePath, {
|
|
530
|
+
...existing,
|
|
531
|
+
...(processed.approvedPath ? { approvedPath: processed.approvedPath } : {}),
|
|
532
|
+
failedStage: undefined,
|
|
533
|
+
lastError: undefined,
|
|
534
|
+
nextAction: undefined,
|
|
535
|
+
phase: "approved",
|
|
536
|
+
updatedAt: now().toISOString(),
|
|
537
|
+
} satisfies ToolReviewAdmissionState);
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
writeJsonAtomic(statePath, {
|
|
541
|
+
...existing,
|
|
542
|
+
failedStage: processed.stage ?? "review_result",
|
|
543
|
+
lastError: processed.error ?? "automatic tool reviewer failed",
|
|
544
|
+
nextAction: "message target=runtime action=review.retry input={\"scope\":\"tool\"}",
|
|
545
|
+
phase: processed.outcome === "processing_failed"
|
|
546
|
+
? "processing_failed"
|
|
547
|
+
: "failed",
|
|
548
|
+
...(processed.outcome === "processing_failed"
|
|
549
|
+
? { processingAttempts: (existing.processingAttempts ?? 0) + 1 }
|
|
550
|
+
: { runId: undefined }),
|
|
551
|
+
updatedAt: now().toISOString(),
|
|
552
|
+
} satisfies ToolReviewAdmissionState);
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
if (
|
|
556
|
+
existing?.phase === "captured" ||
|
|
557
|
+
existing?.phase === "failed"
|
|
558
|
+
) {
|
|
559
|
+
if (existing.attempts >= 3) return;
|
|
560
|
+
try {
|
|
561
|
+
const launched = deps.launch({
|
|
562
|
+
inputPath: existing.inputPath,
|
|
563
|
+
reviewerInputPath: existing.reviewerInputPath,
|
|
564
|
+
reviewId: existing.reviewId,
|
|
565
|
+
toolNames: existing.toolNames,
|
|
566
|
+
});
|
|
567
|
+
writeJsonAtomic(statePath, {
|
|
568
|
+
...existing,
|
|
569
|
+
attempts: existing.attempts + 1,
|
|
570
|
+
phase: "launched",
|
|
571
|
+
runId: launched.run,
|
|
572
|
+
updatedAt: now().toISOString(),
|
|
573
|
+
} satisfies ToolReviewAdmissionState);
|
|
574
|
+
} catch (error) {
|
|
575
|
+
writeJsonAtomic(statePath, {
|
|
576
|
+
...existing,
|
|
577
|
+
attempts: existing.attempts + 1,
|
|
578
|
+
failedStage: "review_launch",
|
|
579
|
+
lastError: error instanceof Error ? error.message : String(error),
|
|
580
|
+
nextAction: "message target=runtime action=review.retry input={\"scope\":\"tool\"}",
|
|
581
|
+
phase: "failed",
|
|
582
|
+
updatedAt: now().toISOString(),
|
|
583
|
+
} satisfies ToolReviewAdmissionState);
|
|
584
|
+
}
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
if (existing && existing.phase !== "completed") return;
|
|
588
|
+
let batch: ToolReviewBatch | undefined;
|
|
589
|
+
try {
|
|
590
|
+
batch = captureToolReviewBatchLocked(
|
|
591
|
+
deps,
|
|
592
|
+
recipeRoot,
|
|
593
|
+
statePath,
|
|
594
|
+
now,
|
|
595
|
+
);
|
|
596
|
+
if (!batch) return;
|
|
597
|
+
const launched = deps.launch(batch);
|
|
598
|
+
writeJsonAtomic(statePath, {
|
|
599
|
+
attempts: 1,
|
|
600
|
+
inputPath: batch.inputPath,
|
|
601
|
+
phase: "launched",
|
|
602
|
+
reviewerInputPath: batch.reviewerInputPath,
|
|
603
|
+
reviewId: batch.reviewId,
|
|
604
|
+
runId: launched.run,
|
|
605
|
+
toolNames: batch.toolNames,
|
|
606
|
+
updatedAt: now().toISOString(),
|
|
607
|
+
} satisfies ToolReviewAdmissionState);
|
|
608
|
+
} catch (error) {
|
|
609
|
+
if (!batch) return;
|
|
610
|
+
writeJsonAtomic(statePath, {
|
|
611
|
+
attempts: 1,
|
|
612
|
+
failedStage: "review_launch",
|
|
613
|
+
inputPath: batch.inputPath,
|
|
614
|
+
lastError: error instanceof Error ? error.message : String(error),
|
|
615
|
+
nextAction: "message target=runtime action=review.retry input={\"scope\":\"tool\"}",
|
|
616
|
+
phase: "failed",
|
|
617
|
+
reviewerInputPath: batch.reviewerInputPath,
|
|
618
|
+
reviewId: batch.reviewId,
|
|
619
|
+
toolNames: batch.toolNames,
|
|
620
|
+
updatedAt: now().toISOString(),
|
|
621
|
+
} satisfies ToolReviewAdmissionState);
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
} catch {
|
|
625
|
+
/* another session owns the durable admission transition */
|
|
626
|
+
}
|
|
627
|
+
}, deps.delayMs ?? 50);
|
|
628
|
+
timer.unref?.();
|
|
629
|
+
};
|
|
630
|
+
return { close, schedule };
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
export function toolReviewRunId(reviewId: string): string {
|
|
634
|
+
return `tool-review-${reviewId}`;
|
|
635
|
+
}
|