@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,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Journaled active-tool portfolio mutation.
|
|
3
|
+
* Zones: approved-plan CAS, source quarantine, target commit, crash recovery
|
|
4
|
+
* Owns deterministic filesystem mutation; reviewer policy and runtime activation remain separate domains.
|
|
5
|
+
*/
|
|
6
|
+
import type { ToolReviewDecision } from "./tool-review.ts";
|
|
7
|
+
export interface ToolReviewApprovedSource {
|
|
8
|
+
action: ToolReviewDecision["action"];
|
|
9
|
+
name: string;
|
|
10
|
+
path: string;
|
|
11
|
+
sha256: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ToolReviewApprovedTarget {
|
|
14
|
+
expectedSha256: string | null;
|
|
15
|
+
lineage: "demote" | "evolve" | "merge" | "replace" | "split";
|
|
16
|
+
name: string;
|
|
17
|
+
path: string;
|
|
18
|
+
recipe: Record<string, unknown>;
|
|
19
|
+
sources: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface ToolReviewApprovedPlan {
|
|
22
|
+
createdAt: string;
|
|
23
|
+
decisions: ToolReviewDecision[];
|
|
24
|
+
reviewId: string;
|
|
25
|
+
sources: ToolReviewApprovedSource[];
|
|
26
|
+
targets: ToolReviewApprovedTarget[];
|
|
27
|
+
}
|
|
28
|
+
export type ToolReviewTransactionPhase = "committed" | "prepared" | "rollback_required" | "rolled_back" | "sources_quarantined" | "targets_written";
|
|
29
|
+
export interface ToolReviewTransactionResult {
|
|
30
|
+
evidencePath?: string;
|
|
31
|
+
journalPath: string;
|
|
32
|
+
phase: ToolReviewTransactionPhase;
|
|
33
|
+
quarantineDir: string;
|
|
34
|
+
}
|
|
35
|
+
export type ToolReviewTransactionCheckpoint = "evidence_written" | "prepared" | "source_quarantined" | "sources_quarantined" | "target_written" | "targets_written";
|
|
36
|
+
export interface ToolReviewTransactionOptions {
|
|
37
|
+
checkpoint?(checkpoint: ToolReviewTransactionCheckpoint): void;
|
|
38
|
+
now?(): Date;
|
|
39
|
+
recipeRoot: string;
|
|
40
|
+
}
|
|
41
|
+
interface PathContainmentApi {
|
|
42
|
+
isAbsolute(path: string): boolean;
|
|
43
|
+
relative(from: string, to: string): string;
|
|
44
|
+
resolve(...paths: string[]): string;
|
|
45
|
+
sep: string;
|
|
46
|
+
}
|
|
47
|
+
export declare function isPathContained(path: string, root: string, pathApi?: PathContainmentApi): boolean;
|
|
48
|
+
export declare function applyToolReviewPlan(approvedPath: string, options: ToolReviewTransactionOptions): ToolReviewTransactionResult;
|
|
49
|
+
export declare function recoverToolReviewTransaction(approvedPath: string, options: ToolReviewTransactionOptions): ToolReviewTransactionResult;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Journaled active-tool portfolio mutation.
|
|
3
|
+
* Zones: approved-plan CAS, source quarantine, target commit, crash recovery
|
|
4
|
+
* Owns deterministic filesystem mutation; reviewer policy and runtime activation remain separate domains.
|
|
5
|
+
*/
|
|
6
|
+
import { createHash } from "node:crypto";
|
|
7
|
+
import { existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, } from "node:fs";
|
|
8
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep, } from "node:path";
|
|
9
|
+
import { withFileMutationLock, writeJsonAtomic } from "./file-state.js";
|
|
10
|
+
import * as RecipesReferences from "./recipes-references.js";
|
|
11
|
+
function sha256Bytes(value) {
|
|
12
|
+
return createHash("sha256").update(value).digest("hex");
|
|
13
|
+
}
|
|
14
|
+
function sha256File(path) {
|
|
15
|
+
return sha256Bytes(readFileSync(path));
|
|
16
|
+
}
|
|
17
|
+
function canonicalJson(value) {
|
|
18
|
+
if (Array.isArray(value))
|
|
19
|
+
return `[${value.map(canonicalJson).join(",")}]`;
|
|
20
|
+
if (!value || typeof value !== "object")
|
|
21
|
+
return JSON.stringify(value);
|
|
22
|
+
const record = value;
|
|
23
|
+
return `{${Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key])}`).join(",")}}`;
|
|
24
|
+
}
|
|
25
|
+
export function isPathContained(path, root, pathApi = { isAbsolute, relative, resolve, sep }) {
|
|
26
|
+
const relation = pathApi.relative(pathApi.resolve(root), pathApi.resolve(path));
|
|
27
|
+
return Boolean(relation &&
|
|
28
|
+
relation !== ".." &&
|
|
29
|
+
!relation.startsWith(`..${pathApi.sep}`) &&
|
|
30
|
+
!pathApi.isAbsolute(relation));
|
|
31
|
+
}
|
|
32
|
+
function assertNoSymlinkComponents(path, root) {
|
|
33
|
+
const absoluteRoot = resolve(root);
|
|
34
|
+
if (!existsSync(absoluteRoot) || lstatSync(absoluteRoot).isSymbolicLink()) {
|
|
35
|
+
throw new Error(`Invalid tool review transaction root: ${absoluteRoot}`);
|
|
36
|
+
}
|
|
37
|
+
if (!isPathContained(path, absoluteRoot)) {
|
|
38
|
+
throw new Error(`Tool review path escapes transaction root: ${path}`);
|
|
39
|
+
}
|
|
40
|
+
let current = absoluteRoot;
|
|
41
|
+
for (const segment of relative(absoluteRoot, resolve(path)).split(/[\\/]/u)) {
|
|
42
|
+
current = join(current, segment);
|
|
43
|
+
if (!existsSync(current))
|
|
44
|
+
break;
|
|
45
|
+
if (lstatSync(current).isSymbolicLink()) {
|
|
46
|
+
throw new Error(`Symlink is not allowed in tool review transaction: ${current}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function captureRootIdentity(path) {
|
|
51
|
+
const absolute = resolve(path);
|
|
52
|
+
const lexical = lstatSync(absolute);
|
|
53
|
+
if (!lexical.isDirectory() || lexical.isSymbolicLink()) {
|
|
54
|
+
throw new Error(`Invalid tool review transaction root: ${absolute}`);
|
|
55
|
+
}
|
|
56
|
+
const canonical = realpathSync.native(absolute);
|
|
57
|
+
const stat = statSync(canonical, { bigint: true });
|
|
58
|
+
return {
|
|
59
|
+
dev: String(stat.dev),
|
|
60
|
+
ino: String(stat.ino),
|
|
61
|
+
path: absolute,
|
|
62
|
+
realpath: canonical,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function captureRootIdentities(cycleDir, quarantineDir, recipeRoot) {
|
|
66
|
+
return {
|
|
67
|
+
cycleDir: captureRootIdentity(cycleDir),
|
|
68
|
+
quarantineDir: captureRootIdentity(quarantineDir),
|
|
69
|
+
recipeRoot: captureRootIdentity(recipeRoot),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function verifyRootIdentities(roots, cycleDir, quarantineDir, recipeRoot) {
|
|
73
|
+
const current = captureRootIdentities(cycleDir, quarantineDir, recipeRoot);
|
|
74
|
+
for (const key of ["cycleDir", "quarantineDir", "recipeRoot"]) {
|
|
75
|
+
const expected = roots?.[key];
|
|
76
|
+
if (!expected ||
|
|
77
|
+
expected.path !== current[key].path ||
|
|
78
|
+
expected.realpath !== current[key].realpath ||
|
|
79
|
+
expected.dev !== current[key].dev ||
|
|
80
|
+
expected.ino !== current[key].ino) {
|
|
81
|
+
throw new Error(`Tool review transaction root changed: ${key}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function deriveOperations(plan, quarantineDir) {
|
|
86
|
+
const sources = changedSources(plan).map((source, index) => ({
|
|
87
|
+
original: resolve(source.path),
|
|
88
|
+
quarantine: join(quarantineDir, `${index}-${basename(source.path)}`),
|
|
89
|
+
sha256: source.sha256,
|
|
90
|
+
}));
|
|
91
|
+
const targets = plan.targets.map((target) => ({
|
|
92
|
+
path: resolve(target.path),
|
|
93
|
+
sha256: sha256Bytes(`${JSON.stringify(target.recipe, null, 2)}\n`),
|
|
94
|
+
}));
|
|
95
|
+
return { sources, targets };
|
|
96
|
+
}
|
|
97
|
+
function assertPlan(plan, recipeRoot) {
|
|
98
|
+
if (!/^[a-f0-9-]{36}$/u.test(plan.reviewId) ||
|
|
99
|
+
plan.sources.length !== 36 ||
|
|
100
|
+
plan.decisions.length !== 36) {
|
|
101
|
+
throw new Error("Invalid approved tool review plan identity.");
|
|
102
|
+
}
|
|
103
|
+
const sourcePaths = new Set();
|
|
104
|
+
for (const source of plan.sources) {
|
|
105
|
+
if (!isPathContained(source.path, recipeRoot) || sourcePaths.has(resolve(source.path))) {
|
|
106
|
+
throw new Error(`Invalid or duplicate tool review source: ${source.path}`);
|
|
107
|
+
}
|
|
108
|
+
sourcePaths.add(resolve(source.path));
|
|
109
|
+
}
|
|
110
|
+
const targetPaths = new Set();
|
|
111
|
+
for (const target of plan.targets) {
|
|
112
|
+
if (!isPathContained(target.path, recipeRoot) || targetPaths.has(resolve(target.path))) {
|
|
113
|
+
throw new Error(`Invalid or duplicate tool review target: ${target.path}`);
|
|
114
|
+
}
|
|
115
|
+
targetPaths.add(resolve(target.path));
|
|
116
|
+
if (!target.recipe || typeof target.recipe !== "object" || !("template" in target.recipe)) {
|
|
117
|
+
throw new Error(`Incomplete tool review target recipe: ${target.path}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function readPlan(path) {
|
|
122
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
123
|
+
}
|
|
124
|
+
function readJournal(path, plan, cycleDir, quarantineDir, recipeRoot) {
|
|
125
|
+
const journal = JSON.parse(readFileSync(path, "utf8"));
|
|
126
|
+
const phases = [
|
|
127
|
+
"committed",
|
|
128
|
+
"prepared",
|
|
129
|
+
"rollback_required",
|
|
130
|
+
"rolled_back",
|
|
131
|
+
"sources_quarantined",
|
|
132
|
+
"targets_written",
|
|
133
|
+
];
|
|
134
|
+
const operations = deriveOperations(plan, quarantineDir);
|
|
135
|
+
if (journal.reviewId !== plan.reviewId ||
|
|
136
|
+
journal.approvedSha256 !== sha256Bytes(canonicalJson(plan)) ||
|
|
137
|
+
!phases.includes(journal.phase) ||
|
|
138
|
+
journal.operationsSha256 !== sha256Bytes(canonicalJson(journal.operations)) ||
|
|
139
|
+
canonicalJson(journal.operations) !== canonicalJson(operations) ||
|
|
140
|
+
journal.quarantined.length > operations.sources.length ||
|
|
141
|
+
journal.writtenTargets.length > operations.targets.length ||
|
|
142
|
+
canonicalJson(journal.quarantined) !==
|
|
143
|
+
canonicalJson(operations.sources.slice(0, journal.quarantined.length)) ||
|
|
144
|
+
canonicalJson(journal.writtenTargets) !==
|
|
145
|
+
canonicalJson(operations.targets.slice(0, journal.writtenTargets.length))) {
|
|
146
|
+
throw new Error("Invalid or mismatched tool review transaction journal.");
|
|
147
|
+
}
|
|
148
|
+
verifyRootIdentities(journal.roots, cycleDir, quarantineDir, recipeRoot);
|
|
149
|
+
for (const source of operations.sources) {
|
|
150
|
+
assertNoSymlinkComponents(source.original, recipeRoot);
|
|
151
|
+
assertNoSymlinkComponents(source.quarantine, cycleDir);
|
|
152
|
+
}
|
|
153
|
+
for (const target of operations.targets) {
|
|
154
|
+
assertNoSymlinkComponents(target.path, recipeRoot);
|
|
155
|
+
}
|
|
156
|
+
return journal;
|
|
157
|
+
}
|
|
158
|
+
function writeJournal(path, journal) {
|
|
159
|
+
writeJsonAtomic(path, journal);
|
|
160
|
+
}
|
|
161
|
+
function changedSources(plan) {
|
|
162
|
+
return plan.sources.filter((source) => source.action !== "keep");
|
|
163
|
+
}
|
|
164
|
+
function assertCas(plan) {
|
|
165
|
+
for (const source of plan.sources) {
|
|
166
|
+
if (!existsSync(source.path) || sha256File(source.path) !== source.sha256) {
|
|
167
|
+
throw new Error(`Tool review source CAS failed: ${source.path}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
for (const target of plan.targets) {
|
|
171
|
+
if (target.expectedSha256 === null) {
|
|
172
|
+
if (existsSync(target.path))
|
|
173
|
+
throw new Error(`Tool review target appeared: ${target.path}`);
|
|
174
|
+
}
|
|
175
|
+
else if (!existsSync(target.path) || sha256File(target.path) !== target.expectedSha256) {
|
|
176
|
+
throw new Error(`Tool review target CAS failed: ${target.path}`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function rollback(journalPath, journal, now) {
|
|
181
|
+
for (const target of [...journal.writtenTargets].reverse()) {
|
|
182
|
+
if (!existsSync(target.path))
|
|
183
|
+
continue;
|
|
184
|
+
if (sha256File(target.path) !== target.sha256) {
|
|
185
|
+
const failed = { ...journal, phase: "rollback_required", updatedAt: now.toISOString() };
|
|
186
|
+
writeJournal(journalPath, failed);
|
|
187
|
+
return failed;
|
|
188
|
+
}
|
|
189
|
+
rmSync(target.path);
|
|
190
|
+
}
|
|
191
|
+
for (const source of [...journal.quarantined].reverse()) {
|
|
192
|
+
const originalExists = existsSync(source.original);
|
|
193
|
+
const quarantineExists = existsSync(source.quarantine);
|
|
194
|
+
if (originalExists &&
|
|
195
|
+
!quarantineExists &&
|
|
196
|
+
sha256File(source.original) === source.sha256)
|
|
197
|
+
continue;
|
|
198
|
+
if (originalExists ||
|
|
199
|
+
!quarantineExists ||
|
|
200
|
+
sha256File(source.quarantine) !== source.sha256) {
|
|
201
|
+
const failed = { ...journal, phase: "rollback_required", updatedAt: now.toISOString() };
|
|
202
|
+
writeJournal(journalPath, failed);
|
|
203
|
+
return failed;
|
|
204
|
+
}
|
|
205
|
+
mkdirSync(dirname(source.original), { recursive: true });
|
|
206
|
+
renameSync(source.quarantine, source.original);
|
|
207
|
+
}
|
|
208
|
+
const rolledBack = {
|
|
209
|
+
...journal,
|
|
210
|
+
phase: "rolled_back",
|
|
211
|
+
updatedAt: now.toISOString(),
|
|
212
|
+
writtenTargets: [],
|
|
213
|
+
};
|
|
214
|
+
writeJournal(journalPath, rolledBack);
|
|
215
|
+
return rolledBack;
|
|
216
|
+
}
|
|
217
|
+
function commitEvidence(cycleDir, journalPath, journal, plan, now, checkpoint) {
|
|
218
|
+
verifyRootIdentities(journal.roots, cycleDir, join(cycleDir, "quarantine"), journal.roots.recipeRoot.path);
|
|
219
|
+
if (journal.writtenTargets.length !== journal.operations.targets.length) {
|
|
220
|
+
throw new Error("Committed tool review targets are incomplete.");
|
|
221
|
+
}
|
|
222
|
+
for (const target of journal.writtenTargets) {
|
|
223
|
+
if (!existsSync(target.path) || sha256File(target.path) !== target.sha256) {
|
|
224
|
+
throw new Error(`Committed tool review target changed: ${target.path}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (journal.quarantined.length !== journal.operations.sources.length) {
|
|
228
|
+
throw new Error("Committed tool review quarantine is incomplete.");
|
|
229
|
+
}
|
|
230
|
+
for (const source of journal.quarantined) {
|
|
231
|
+
const replacement = journal.operations.targets.find((target) => resolve(target.path) === resolve(source.original));
|
|
232
|
+
if (existsSync(source.original) &&
|
|
233
|
+
(!replacement || sha256File(source.original) !== replacement.sha256)) {
|
|
234
|
+
throw new Error(`Committed tool review source changed: ${source.original}`);
|
|
235
|
+
}
|
|
236
|
+
if (!existsSync(source.quarantine) ||
|
|
237
|
+
sha256File(source.quarantine) !== source.sha256) {
|
|
238
|
+
throw new Error(`Committed tool review quarantine changed: ${source.quarantine}`);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
const evidencePath = join(cycleDir, "evidence.json");
|
|
242
|
+
writeJsonAtomic(evidencePath, {
|
|
243
|
+
actions: Object.fromEntries([...new Set(plan.sources.map((source) => source.action))].map((action) => [
|
|
244
|
+
action,
|
|
245
|
+
plan.sources.filter((source) => source.action === action).length,
|
|
246
|
+
])),
|
|
247
|
+
reviewId: plan.reviewId,
|
|
248
|
+
sources: plan.sources.length,
|
|
249
|
+
targets: plan.targets.length,
|
|
250
|
+
ts: now.toISOString(),
|
|
251
|
+
});
|
|
252
|
+
checkpoint?.("evidence_written");
|
|
253
|
+
const committed = { ...journal, phase: "committed", updatedAt: now.toISOString() };
|
|
254
|
+
writeJournal(journalPath, committed);
|
|
255
|
+
return {
|
|
256
|
+
evidencePath,
|
|
257
|
+
journalPath,
|
|
258
|
+
phase: "committed",
|
|
259
|
+
quarantineDir: join(cycleDir, "quarantine"),
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
export function applyToolReviewPlan(approvedPath, options) {
|
|
263
|
+
const plan = readPlan(approvedPath);
|
|
264
|
+
assertPlan(plan, options.recipeRoot);
|
|
265
|
+
const cycleDir = dirname(approvedPath);
|
|
266
|
+
const journalPath = join(cycleDir, "journal.json");
|
|
267
|
+
const quarantineDir = join(cycleDir, "quarantine");
|
|
268
|
+
const now = options.now ?? (() => new Date());
|
|
269
|
+
return withFileMutationLock(options.recipeRoot, () => {
|
|
270
|
+
if (existsSync(journalPath)) {
|
|
271
|
+
throw new Error(`Tool review transaction already exists: ${plan.reviewId}`);
|
|
272
|
+
}
|
|
273
|
+
mkdirSync(quarantineDir, { recursive: true });
|
|
274
|
+
const operations = deriveOperations(plan, quarantineDir);
|
|
275
|
+
const roots = captureRootIdentities(cycleDir, quarantineDir, options.recipeRoot);
|
|
276
|
+
for (const source of operations.sources) {
|
|
277
|
+
assertNoSymlinkComponents(source.original, options.recipeRoot);
|
|
278
|
+
assertNoSymlinkComponents(source.quarantine, cycleDir);
|
|
279
|
+
}
|
|
280
|
+
for (const target of operations.targets) {
|
|
281
|
+
assertNoSymlinkComponents(target.path, options.recipeRoot);
|
|
282
|
+
}
|
|
283
|
+
assertCas(plan);
|
|
284
|
+
let journal = {
|
|
285
|
+
approvedSha256: sha256Bytes(canonicalJson(plan)),
|
|
286
|
+
operations,
|
|
287
|
+
operationsSha256: sha256Bytes(canonicalJson(operations)),
|
|
288
|
+
phase: "prepared",
|
|
289
|
+
quarantined: [],
|
|
290
|
+
reviewId: plan.reviewId,
|
|
291
|
+
roots,
|
|
292
|
+
updatedAt: now().toISOString(),
|
|
293
|
+
writtenTargets: [],
|
|
294
|
+
};
|
|
295
|
+
writeJournal(journalPath, journal);
|
|
296
|
+
options.checkpoint?.("prepared");
|
|
297
|
+
try {
|
|
298
|
+
for (const source of operations.sources) {
|
|
299
|
+
journal = {
|
|
300
|
+
...journal,
|
|
301
|
+
quarantined: [...journal.quarantined, source],
|
|
302
|
+
updatedAt: now().toISOString(),
|
|
303
|
+
};
|
|
304
|
+
writeJournal(journalPath, journal);
|
|
305
|
+
renameSync(source.original, source.quarantine);
|
|
306
|
+
options.checkpoint?.("source_quarantined");
|
|
307
|
+
}
|
|
308
|
+
journal = { ...journal, phase: "sources_quarantined", updatedAt: now().toISOString() };
|
|
309
|
+
writeJournal(journalPath, journal);
|
|
310
|
+
options.checkpoint?.("sources_quarantined");
|
|
311
|
+
for (const [index, target] of plan.targets.entries()) {
|
|
312
|
+
const operation = operations.targets[index];
|
|
313
|
+
mkdirSync(dirname(operation.path), { recursive: true });
|
|
314
|
+
journal = {
|
|
315
|
+
...journal,
|
|
316
|
+
writtenTargets: [...journal.writtenTargets, operation],
|
|
317
|
+
updatedAt: now().toISOString(),
|
|
318
|
+
};
|
|
319
|
+
writeJournal(journalPath, journal);
|
|
320
|
+
writeJsonAtomic(operation.path, target.recipe);
|
|
321
|
+
if (sha256File(operation.path) !== operation.sha256 ||
|
|
322
|
+
!RecipesReferences.readResolvedRecipeConfig(operation.path)) {
|
|
323
|
+
throw new Error(`Written tool review target is invalid: ${operation.path}`);
|
|
324
|
+
}
|
|
325
|
+
options.checkpoint?.("target_written");
|
|
326
|
+
}
|
|
327
|
+
journal = { ...journal, phase: "targets_written", updatedAt: now().toISOString() };
|
|
328
|
+
writeJournal(journalPath, journal);
|
|
329
|
+
options.checkpoint?.("targets_written");
|
|
330
|
+
return commitEvidence(cycleDir, journalPath, journal, plan, now(), options.checkpoint);
|
|
331
|
+
}
|
|
332
|
+
catch (error) {
|
|
333
|
+
const result = rollback(journalPath, journal, now());
|
|
334
|
+
if (result.phase === "rollback_required") {
|
|
335
|
+
throw new Error(`Tool review rollback requires operator attention: ${plan.reviewId}`);
|
|
336
|
+
}
|
|
337
|
+
throw error;
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
export function recoverToolReviewTransaction(approvedPath, options) {
|
|
342
|
+
const plan = readPlan(approvedPath);
|
|
343
|
+
assertPlan(plan, options.recipeRoot);
|
|
344
|
+
const cycleDir = dirname(approvedPath);
|
|
345
|
+
const journalPath = join(cycleDir, "journal.json");
|
|
346
|
+
const quarantineDir = join(cycleDir, "quarantine");
|
|
347
|
+
const now = options.now ?? (() => new Date());
|
|
348
|
+
return withFileMutationLock(options.recipeRoot, () => {
|
|
349
|
+
const journal = readJournal(journalPath, plan, cycleDir, quarantineDir, options.recipeRoot);
|
|
350
|
+
if (journal.phase === "committed") {
|
|
351
|
+
return commitEvidence(cycleDir, journalPath, journal, plan, now());
|
|
352
|
+
}
|
|
353
|
+
if (journal.phase === "targets_written") {
|
|
354
|
+
return commitEvidence(cycleDir, journalPath, journal, plan, now());
|
|
355
|
+
}
|
|
356
|
+
if (journal.phase === "rollback_required") {
|
|
357
|
+
return { journalPath, phase: journal.phase, quarantineDir };
|
|
358
|
+
}
|
|
359
|
+
const recovered = rollback(journalPath, journal, now());
|
|
360
|
+
return { journalPath, phase: recovered.phase, quarantineDir };
|
|
361
|
+
});
|
|
362
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automatic active-tool portfolio review contract.
|
|
3
|
+
* Zones: thirty-six-tool reviewer input, evolution decisions, mechanical contract gates
|
|
4
|
+
* Owns strict read-only keep/evolve/replace/demote/merge/split review semantics.
|
|
5
|
+
*/
|
|
6
|
+
export declare const TOOL_REVIEW_THRESHOLD = 36;
|
|
7
|
+
export interface ToolReviewAssessment {
|
|
8
|
+
adaptability: number;
|
|
9
|
+
futureUsefulness: number;
|
|
10
|
+
lifetimeCalls: number;
|
|
11
|
+
redundancy: number;
|
|
12
|
+
revisionCalls: number;
|
|
13
|
+
safety: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ToolReviewTool {
|
|
16
|
+
name: string;
|
|
17
|
+
path: string;
|
|
18
|
+
recipe: Record<string, unknown>;
|
|
19
|
+
riskLabels: string[];
|
|
20
|
+
sha256: string;
|
|
21
|
+
usage?: Record<string, unknown>;
|
|
22
|
+
valid: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface ToolReviewInput {
|
|
25
|
+
createdAt: string;
|
|
26
|
+
reviewId: string;
|
|
27
|
+
tools: ToolReviewTool[];
|
|
28
|
+
}
|
|
29
|
+
export interface ToolReviewOutputRecipe {
|
|
30
|
+
name: string;
|
|
31
|
+
recipe: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
export type ToolReviewAction = "demote" | "evolve" | "keep" | "merge" | "replace" | "split";
|
|
34
|
+
export interface ToolReviewDecision {
|
|
35
|
+
action: ToolReviewAction;
|
|
36
|
+
assessment: ToolReviewAssessment;
|
|
37
|
+
rationale: string;
|
|
38
|
+
recipe?: Record<string, unknown>;
|
|
39
|
+
sha256: string;
|
|
40
|
+
source: string;
|
|
41
|
+
target?: string;
|
|
42
|
+
outputs?: ToolReviewOutputRecipe[];
|
|
43
|
+
}
|
|
44
|
+
export interface ToolReviewResult {
|
|
45
|
+
createdAt: string;
|
|
46
|
+
decisions: ToolReviewDecision[];
|
|
47
|
+
reviewId: string;
|
|
48
|
+
}
|
|
49
|
+
export interface ToolReviewValidation {
|
|
50
|
+
errors: string[];
|
|
51
|
+
ok: boolean;
|
|
52
|
+
}
|
|
53
|
+
export declare function validateToolReviewInput(input: ToolReviewInput): ToolReviewValidation;
|
|
54
|
+
export declare function validateToolReviewResult(input: ToolReviewInput, result: ToolReviewResult): ToolReviewValidation;
|
|
55
|
+
export declare function parseToolReviewResult(stdout: string): ToolReviewResult;
|
|
56
|
+
export declare function createToolReviewPrompt(inputPath: string): string;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automatic active-tool portfolio review contract.
|
|
3
|
+
* Zones: thirty-six-tool reviewer input, evolution decisions, mechanical contract gates
|
|
4
|
+
* Owns strict read-only keep/evolve/replace/demote/merge/split review semantics.
|
|
5
|
+
*/
|
|
6
|
+
export const TOOL_REVIEW_THRESHOLD = 36;
|
|
7
|
+
const UUID_PATTERN = /^[a-f0-9-]{36}$/u;
|
|
8
|
+
const TOOL_NAME_PATTERN = /^[a-z][a-z0-9_]*$/u;
|
|
9
|
+
function isRecord(value) {
|
|
10
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
11
|
+
}
|
|
12
|
+
function canonicalJson(value) {
|
|
13
|
+
if (Array.isArray(value))
|
|
14
|
+
return `[${value.map(canonicalJson).join(",")}]`;
|
|
15
|
+
if (!isRecord(value))
|
|
16
|
+
return JSON.stringify(value);
|
|
17
|
+
return `{${Object.keys(value)
|
|
18
|
+
.sort()
|
|
19
|
+
.map((key) => `${JSON.stringify(key)}:${canonicalJson(value[key])}`)
|
|
20
|
+
.join(",")}}`;
|
|
21
|
+
}
|
|
22
|
+
function finiteScore(value) {
|
|
23
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1;
|
|
24
|
+
}
|
|
25
|
+
function calls(value) {
|
|
26
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0
|
|
27
|
+
? value
|
|
28
|
+
: 0;
|
|
29
|
+
}
|
|
30
|
+
function validateAssessment(assessment, tool, errors) {
|
|
31
|
+
if (!isRecord(assessment) ||
|
|
32
|
+
!finiteScore(assessment.adaptability) ||
|
|
33
|
+
!finiteScore(assessment.futureUsefulness) ||
|
|
34
|
+
!finiteScore(assessment.redundancy) ||
|
|
35
|
+
typeof assessment.safety !== "string" ||
|
|
36
|
+
!assessment.safety.trim() ||
|
|
37
|
+
!Number.isInteger(assessment.lifetimeCalls) ||
|
|
38
|
+
Number(assessment.lifetimeCalls) < 0 ||
|
|
39
|
+
!Number.isInteger(assessment.revisionCalls) ||
|
|
40
|
+
Number(assessment.revisionCalls) < 0) {
|
|
41
|
+
errors.push(`invalid tool assessment: ${tool.name}`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (assessment.lifetimeCalls !== calls(tool.usage?.lifetime_calls ?? tool.usage?.calls)) {
|
|
45
|
+
errors.push(`tool lifetime calls differ from lineage: ${tool.name}`);
|
|
46
|
+
}
|
|
47
|
+
if (assessment.revisionCalls !== calls(tool.usage?.revision_calls)) {
|
|
48
|
+
errors.push(`tool revision calls differ from lineage: ${tool.name}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export function validateToolReviewInput(input) {
|
|
52
|
+
const errors = [];
|
|
53
|
+
if (!UUID_PATTERN.test(input.reviewId))
|
|
54
|
+
errors.push("tool reviewId must be a UUID");
|
|
55
|
+
if (!input.createdAt || Number.isNaN(Date.parse(input.createdAt))) {
|
|
56
|
+
errors.push("tool review createdAt must be an ISO timestamp");
|
|
57
|
+
}
|
|
58
|
+
if (!Array.isArray(input.tools) || input.tools.length !== TOOL_REVIEW_THRESHOLD) {
|
|
59
|
+
errors.push(`tool review input must contain exactly ${TOOL_REVIEW_THRESHOLD} tools`);
|
|
60
|
+
}
|
|
61
|
+
const names = new Set();
|
|
62
|
+
for (const tool of input.tools ?? []) {
|
|
63
|
+
if (!tool ||
|
|
64
|
+
!TOOL_NAME_PATTERN.test(tool.name) ||
|
|
65
|
+
typeof tool.path !== "string" ||
|
|
66
|
+
typeof tool.sha256 !== "string" ||
|
|
67
|
+
typeof tool.valid !== "boolean" ||
|
|
68
|
+
!isRecord(tool.recipe) ||
|
|
69
|
+
!Array.isArray(tool.riskLabels) ||
|
|
70
|
+
names.has(tool.name)) {
|
|
71
|
+
errors.push(`invalid or duplicate reviewed tool: ${String(tool?.name)}`);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
names.add(tool.name);
|
|
75
|
+
}
|
|
76
|
+
return { errors, ok: errors.length === 0 };
|
|
77
|
+
}
|
|
78
|
+
export function validateToolReviewResult(input, result) {
|
|
79
|
+
const errors = [...validateToolReviewInput(input).errors];
|
|
80
|
+
if (result.reviewId !== input.reviewId)
|
|
81
|
+
errors.push("tool review identity mismatch");
|
|
82
|
+
if (!result.createdAt || Number.isNaN(Date.parse(result.createdAt))) {
|
|
83
|
+
errors.push("tool review result createdAt must be an ISO timestamp");
|
|
84
|
+
}
|
|
85
|
+
if (!Array.isArray(result.decisions)) {
|
|
86
|
+
errors.push("tool review decisions must be an array");
|
|
87
|
+
return { errors, ok: false };
|
|
88
|
+
}
|
|
89
|
+
const inventory = new Map(input.tools.map((tool) => [tool.name, tool]));
|
|
90
|
+
const activeNames = new Set(inventory.keys());
|
|
91
|
+
const seen = new Set();
|
|
92
|
+
const outputNames = new Set();
|
|
93
|
+
const mergeGroups = new Map();
|
|
94
|
+
for (const decision of result.decisions) {
|
|
95
|
+
const tool = inventory.get(decision.source);
|
|
96
|
+
if (!tool) {
|
|
97
|
+
errors.push(`unknown reviewed tool: ${decision.source}`);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (seen.has(decision.source)) {
|
|
101
|
+
errors.push(`duplicate tool decision: ${decision.source}`);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
seen.add(decision.source);
|
|
105
|
+
if (decision.sha256 !== tool.sha256)
|
|
106
|
+
errors.push(`reviewed tool changed: ${tool.name}`);
|
|
107
|
+
if (!decision.rationale?.trim())
|
|
108
|
+
errors.push(`missing tool rationale: ${tool.name}`);
|
|
109
|
+
validateAssessment(decision.assessment, tool, errors);
|
|
110
|
+
if (decision.action === "keep" || decision.action === "demote") {
|
|
111
|
+
if (decision.target || decision.recipe || decision.outputs) {
|
|
112
|
+
errors.push(`${decision.action} declares evolution fields: ${tool.name}`);
|
|
113
|
+
}
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (decision.action === "replace" || decision.action === "split") {
|
|
117
|
+
errors.push(`${decision.action} requires explicit operator-authored recipe mutation: ${tool.name}`);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (decision.action === "evolve") {
|
|
121
|
+
if (!decision.target || !TOOL_NAME_PATTERN.test(decision.target)) {
|
|
122
|
+
errors.push(`evolve requires snake_case target: ${tool.name}`);
|
|
123
|
+
}
|
|
124
|
+
if (decision.recipe !== undefined || decision.outputs !== undefined) {
|
|
125
|
+
errors.push(`evolve must not supply executable recipe content: ${tool.name}`);
|
|
126
|
+
}
|
|
127
|
+
if (decision.target &&
|
|
128
|
+
activeNames.has(decision.target) &&
|
|
129
|
+
decision.target !== tool.name) {
|
|
130
|
+
errors.push(`evolve target collides with active tool: ${decision.target}`);
|
|
131
|
+
}
|
|
132
|
+
if (decision.target && outputNames.has(decision.target)) {
|
|
133
|
+
errors.push(`duplicate evolved target: ${decision.target}`);
|
|
134
|
+
}
|
|
135
|
+
else if (decision.target)
|
|
136
|
+
outputNames.add(decision.target);
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (decision.action === "merge") {
|
|
140
|
+
if (!decision.target || !TOOL_NAME_PATTERN.test(decision.target)) {
|
|
141
|
+
errors.push(`merge requires snake_case target: ${tool.name}`);
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (decision.recipe !== undefined || decision.outputs !== undefined) {
|
|
145
|
+
errors.push(`merge must not supply executable recipe content: ${tool.name}`);
|
|
146
|
+
}
|
|
147
|
+
const group = mergeGroups.get(decision.target) ?? [];
|
|
148
|
+
group.push({ decision, recipe: canonicalJson(tool.recipe) });
|
|
149
|
+
mergeGroups.set(decision.target, group);
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
errors.push(`invalid tool review action: ${tool.name}`);
|
|
153
|
+
}
|
|
154
|
+
for (const tool of input.tools) {
|
|
155
|
+
if (!seen.has(tool.name))
|
|
156
|
+
errors.push(`missing tool decision: ${tool.name}`);
|
|
157
|
+
}
|
|
158
|
+
for (const [target, group] of mergeGroups) {
|
|
159
|
+
if (group.length < 2)
|
|
160
|
+
errors.push(`merge target requires at least two sources: ${target}`);
|
|
161
|
+
if (activeNames.has(target) &&
|
|
162
|
+
!group.some((entry) => entry.decision.source === target)) {
|
|
163
|
+
errors.push(`merge target collides with unrelated active tool: ${target}`);
|
|
164
|
+
}
|
|
165
|
+
if (new Set(group.map((entry) => entry.recipe)).size !== 1) {
|
|
166
|
+
errors.push(`merge target recipes differ: ${target}`);
|
|
167
|
+
}
|
|
168
|
+
if (outputNames.has(target))
|
|
169
|
+
errors.push(`duplicate evolved target: ${target}`);
|
|
170
|
+
outputNames.add(target);
|
|
171
|
+
}
|
|
172
|
+
return { errors, ok: errors.length === 0 };
|
|
173
|
+
}
|
|
174
|
+
export function parseToolReviewResult(stdout) {
|
|
175
|
+
const marker = "TOOL_REVIEW_RESULT";
|
|
176
|
+
const markerIndex = stdout.lastIndexOf(marker);
|
|
177
|
+
if (markerIndex < 0)
|
|
178
|
+
throw new Error("Tool reviewer output marker is missing.");
|
|
179
|
+
const payload = stdout.slice(markerIndex + marker.length).trim();
|
|
180
|
+
if (!payload.startsWith("{") || !payload.endsWith("}")) {
|
|
181
|
+
throw new Error("Tool reviewer output must end with one JSON object.");
|
|
182
|
+
}
|
|
183
|
+
const value = JSON.parse(payload);
|
|
184
|
+
if (!isRecord(value))
|
|
185
|
+
throw new Error("Tool reviewer result must be an object.");
|
|
186
|
+
return value;
|
|
187
|
+
}
|
|
188
|
+
export function createToolReviewPrompt(inputPath) {
|
|
189
|
+
return [
|
|
190
|
+
`Review the attached immutable active-tool portfolio from ${inputPath}.`,
|
|
191
|
+
"Evaluate all 36 tools independently from lifetime/revision usage, adaptability, redundancy, safety, contract quality, and likely future usefulness.",
|
|
192
|
+
"Choose exactly one action per source: keep, evolve, demote, or merge. There is no quota for any action.",
|
|
193
|
+
"evolve may only rename one unchanged captured recipe; demote moves the unchanged recipe to draft memory; merge may only deduplicate at least two canonically identical captured recipes. Never return recipe or outputs fields. replace and split require explicit operator-authored mutation and are unavailable to automatic review.",
|
|
194
|
+
"Do not mutate, register, move, or delete recipes. You are a read-only selector; the deterministic executor derives exact recipe bytes from captured sources and owns every portfolio mutation.",
|
|
195
|
+
"End stdout with TOOL_REVIEW_RESULT on its own line followed by exactly one JSON object with reviewId, createdAt, and decisions.",
|
|
196
|
+
].join("\n");
|
|
197
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public tool access and ownership checks
|
|
3
|
+
* Zones: session ownership, run visibility guards, tool authorization errors
|
|
4
|
+
* Owns consistent session-mismatch diagnostics for public tool execution paths
|
|
5
|
+
*/
|
|
6
|
+
export interface SessionContext {
|
|
7
|
+
sessionManager?: {
|
|
8
|
+
getSessionId?: () => string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare function getContextSessionId(ctx: unknown): string | undefined;
|
|
12
|
+
export declare function requireContextSessionId(ctx: unknown, actor: string): string;
|
|
13
|
+
export declare function sessionMismatchError(input: {
|
|
14
|
+
currentSession?: string;
|
|
15
|
+
expectedSession?: string;
|
|
16
|
+
run?: string;
|
|
17
|
+
target?: string;
|
|
18
|
+
}): Error;
|
|
19
|
+
export declare function assertRunAccessibleToContext(runId: string, ctx: unknown): Record<string, unknown>;
|