@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,575 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automatic draft-sleep scheduling.
|
|
3
|
+
* Zones: twelve-draft trigger, immutable batch capture, silent post-turn launch
|
|
4
|
+
* Owns non-blocking review admission and persisted launch evidence, not reviewer decisions or mutation.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
8
|
+
import { existsSync, readFileSync, rmSync } from "node:fs";
|
|
9
|
+
import { basename, dirname, join } from "node:path";
|
|
10
|
+
|
|
11
|
+
import type { DraftConsolidationPlan } from "./draft-consolidation.ts";
|
|
12
|
+
import * as DraftConsolidationTransaction from "./draft-consolidation-transaction.ts";
|
|
13
|
+
import type {
|
|
14
|
+
DraftReviewActiveTool,
|
|
15
|
+
DraftReviewDraft,
|
|
16
|
+
DraftReviewInput,
|
|
17
|
+
} from "./draft-review.ts";
|
|
18
|
+
import {
|
|
19
|
+
parseDraftReviewResult,
|
|
20
|
+
validateDraftReviewInput,
|
|
21
|
+
validateDraftReviewResult,
|
|
22
|
+
} from "./draft-review.ts";
|
|
23
|
+
import { withFileMutationLock, writeJsonAtomic } from "./file-state.ts";
|
|
24
|
+
import * as Paths from "./paths.ts";
|
|
25
|
+
import * as RecipesDiscovery from "./recipes-discovery.ts";
|
|
26
|
+
import * as RecipesReferences from "./recipes-references.ts";
|
|
27
|
+
import * as RecipesUsage from "./recipes-usage.ts";
|
|
28
|
+
import * as ReviewProjection from "./review-projection.ts";
|
|
29
|
+
|
|
30
|
+
export const DRAFT_SLEEP_THRESHOLD = 12;
|
|
31
|
+
const DEFAULT_DELAY_MS = 25;
|
|
32
|
+
|
|
33
|
+
export interface DraftSleepBatch {
|
|
34
|
+
batchId: string;
|
|
35
|
+
inputPath: string;
|
|
36
|
+
reviewerInputPath: string;
|
|
37
|
+
sourcePaths: string[];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface DraftSleepState {
|
|
41
|
+
attempts: number;
|
|
42
|
+
batchId: string;
|
|
43
|
+
inputPath: string;
|
|
44
|
+
evidencePath?: string;
|
|
45
|
+
failedStage?: string;
|
|
46
|
+
lastError?: string;
|
|
47
|
+
nextAction?: string;
|
|
48
|
+
phase: "captured" | "completed" | "failed" | "launched" | "processing_failed";
|
|
49
|
+
processingAttempts?: number;
|
|
50
|
+
reviewerInputPath: string;
|
|
51
|
+
runId?: string;
|
|
52
|
+
sourcePaths: string[];
|
|
53
|
+
updatedAt: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface DraftSleepProcessResult {
|
|
57
|
+
cleanup?(): void;
|
|
58
|
+
error?: string;
|
|
59
|
+
evidencePath?: string;
|
|
60
|
+
outcome: "completed" | "pending" | "processing_failed" | "review_failed";
|
|
61
|
+
stage?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface DraftSleepSchedulerDeps {
|
|
65
|
+
activeTools?(): DraftReviewActiveTool[];
|
|
66
|
+
batchRoot?(batchId: string): string;
|
|
67
|
+
createBatchId?(): string;
|
|
68
|
+
delayMs?: number;
|
|
69
|
+
draftRoot?: string;
|
|
70
|
+
hasActiveActors(): boolean;
|
|
71
|
+
launch(batch: DraftSleepBatch): { run: string };
|
|
72
|
+
now?(): Date;
|
|
73
|
+
process?(state: DraftSleepState): DraftSleepProcessResult;
|
|
74
|
+
recipeRoot?: string;
|
|
75
|
+
statePath?: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface DraftSleepScheduler {
|
|
79
|
+
close(): void;
|
|
80
|
+
schedule(): void;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function sha256(path: string): string {
|
|
84
|
+
return createHash("sha256").update(readFileSync(path)).digest("hex");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function readState(path: string): DraftSleepState | undefined {
|
|
88
|
+
try {
|
|
89
|
+
const value = JSON.parse(readFileSync(path, "utf8")) as DraftSleepState;
|
|
90
|
+
return value && typeof value === "object" ? value : undefined;
|
|
91
|
+
} catch {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function defaultActiveTools(recipeRoot: string): DraftReviewActiveTool[] {
|
|
97
|
+
const discovered = RecipesDiscovery.discoverRecipeSources([
|
|
98
|
+
{ root: recipeRoot, defaultTool: true, mutableUsage: true },
|
|
99
|
+
]);
|
|
100
|
+
return [...discovered.active.values()]
|
|
101
|
+
.filter((entry) => existsSync(entry.path))
|
|
102
|
+
.map((entry) => ({
|
|
103
|
+
name: entry.id,
|
|
104
|
+
path: entry.path,
|
|
105
|
+
sha256: sha256(entry.path),
|
|
106
|
+
}))
|
|
107
|
+
.sort((left, right) => left.name.localeCompare(right.name));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function draftFromRecord(
|
|
111
|
+
record: Record<string, unknown>,
|
|
112
|
+
recipeRoot: string,
|
|
113
|
+
now: Date,
|
|
114
|
+
): DraftReviewDraft | undefined {
|
|
115
|
+
if (
|
|
116
|
+
typeof record.path !== "string" ||
|
|
117
|
+
typeof record.sha256 !== "string" ||
|
|
118
|
+
typeof record.valid !== "boolean"
|
|
119
|
+
) {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
RecipesUsage.ensureRecipeLineage(record.path, now, recipeRoot);
|
|
123
|
+
const riskLabels = Array.isArray(record.risk_labels)
|
|
124
|
+
? record.risk_labels.filter((label): label is string => typeof label === "string")
|
|
125
|
+
: [];
|
|
126
|
+
const secretTouching = riskLabels.includes("risk.secret_touching");
|
|
127
|
+
const recipe = secretTouching || !record.valid
|
|
128
|
+
? undefined
|
|
129
|
+
: RecipesReferences.readRawRecipeConfig(record.path);
|
|
130
|
+
const usage = RecipesUsage.readRecipeUsage(record.path, recipeRoot);
|
|
131
|
+
if (
|
|
132
|
+
typeof usage?.demoted_fingerprint === "string" &&
|
|
133
|
+
usage.demoted_fingerprint === usage.fingerprint
|
|
134
|
+
) {
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
...(record.diagnostics !== undefined
|
|
139
|
+
? { diagnostics: record.diagnostics }
|
|
140
|
+
: {}),
|
|
141
|
+
path: record.path,
|
|
142
|
+
...(recipe ? { recipe } : {}),
|
|
143
|
+
riskLabels,
|
|
144
|
+
sha256: record.sha256,
|
|
145
|
+
...(usage ? { usage } : {}),
|
|
146
|
+
valid: record.valid && !secretTouching,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
type DraftSleepCaptureOptions = Pick<
|
|
151
|
+
DraftSleepSchedulerDeps,
|
|
152
|
+
| "activeTools"
|
|
153
|
+
| "batchRoot"
|
|
154
|
+
| "createBatchId"
|
|
155
|
+
| "draftRoot"
|
|
156
|
+
| "now"
|
|
157
|
+
| "recipeRoot"
|
|
158
|
+
| "statePath"
|
|
159
|
+
>;
|
|
160
|
+
|
|
161
|
+
function captureDraftSleepBatchLocked(
|
|
162
|
+
options: DraftSleepCaptureOptions,
|
|
163
|
+
draftRoot: string,
|
|
164
|
+
recipeRoot: string,
|
|
165
|
+
statePath: string,
|
|
166
|
+
): DraftSleepBatch | undefined {
|
|
167
|
+
const state = readState(statePath);
|
|
168
|
+
if (
|
|
169
|
+
state?.phase === "captured" ||
|
|
170
|
+
state?.phase === "launched" ||
|
|
171
|
+
state?.phase === "processing_failed"
|
|
172
|
+
) return undefined;
|
|
173
|
+
return withFileMutationLock(draftRoot, () => {
|
|
174
|
+
const records = RecipesDiscovery.listDraftRecipes(draftRoot);
|
|
175
|
+
const capturedAt = (options.now ?? (() => new Date()))();
|
|
176
|
+
const candidates = records.flatMap((record) => {
|
|
177
|
+
const draft = draftFromRecord(record, recipeRoot, capturedAt);
|
|
178
|
+
return draft ? [draft] : [];
|
|
179
|
+
});
|
|
180
|
+
if (candidates.length < DRAFT_SLEEP_THRESHOLD) return undefined;
|
|
181
|
+
const batchId = (options.createBatchId ?? randomUUID)();
|
|
182
|
+
const batchDir = (options.batchRoot ?? Paths.getDraftSleepBatchDir)(batchId);
|
|
183
|
+
const inputPath = join(batchDir, "input.json");
|
|
184
|
+
const drafts = candidates.slice(0, DRAFT_SLEEP_THRESHOLD);
|
|
185
|
+
const input: DraftReviewInput = {
|
|
186
|
+
activeTools: options.activeTools?.() ?? defaultActiveTools(recipeRoot),
|
|
187
|
+
batchId,
|
|
188
|
+
createdAt: capturedAt.toISOString(),
|
|
189
|
+
drafts,
|
|
190
|
+
};
|
|
191
|
+
const validation = validateDraftReviewInput(input);
|
|
192
|
+
if (!validation.ok) {
|
|
193
|
+
throw new Error(`Draft sleep input rejected: ${validation.errors.join("; ")}`);
|
|
194
|
+
}
|
|
195
|
+
writeJsonAtomic(inputPath, input);
|
|
196
|
+
const reviewerInputPath = join(batchDir, "review-input.json");
|
|
197
|
+
writeJsonAtomic(reviewerInputPath, ReviewProjection.projectDraftReviewInput(input));
|
|
198
|
+
const sourcePaths = drafts.map((draft) => draft.path);
|
|
199
|
+
writeJsonAtomic(statePath, {
|
|
200
|
+
attempts: 0,
|
|
201
|
+
batchId,
|
|
202
|
+
inputPath,
|
|
203
|
+
phase: "captured",
|
|
204
|
+
reviewerInputPath,
|
|
205
|
+
sourcePaths,
|
|
206
|
+
updatedAt: input.createdAt,
|
|
207
|
+
} satisfies DraftSleepState);
|
|
208
|
+
return { batchId, inputPath, reviewerInputPath, sourcePaths };
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export function captureDraftSleepBatch(
|
|
213
|
+
options: DraftSleepCaptureOptions = {},
|
|
214
|
+
): DraftSleepBatch | undefined {
|
|
215
|
+
const draftRoot = options.draftRoot ?? Paths.getRecipeDraftRoot();
|
|
216
|
+
const recipeRoot = options.recipeRoot ?? Paths.getRecipeRoot();
|
|
217
|
+
const statePath = options.statePath ?? Paths.getDraftSleepStatePath();
|
|
218
|
+
return withFileMutationLock(statePath, () =>
|
|
219
|
+
captureDraftSleepBatchLocked(options, draftRoot, recipeRoot, statePath),
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface ProcessDraftSleepReviewDeps {
|
|
224
|
+
getRunStatus(runId: string): Record<string, unknown>;
|
|
225
|
+
now?(): Date;
|
|
226
|
+
recipeRoot?: string;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function completeDraftSleepTransaction(
|
|
230
|
+
transaction: DraftConsolidationTransaction.DraftConsolidationTransactionResult,
|
|
231
|
+
state: DraftSleepState,
|
|
232
|
+
deps: ProcessDraftSleepReviewDeps,
|
|
233
|
+
cycleDir: string,
|
|
234
|
+
recipeRoot: string,
|
|
235
|
+
): DraftSleepProcessResult {
|
|
236
|
+
try {
|
|
237
|
+
if (transaction.phase !== "committed") {
|
|
238
|
+
return {
|
|
239
|
+
error: `draft transaction remained ${transaction.phase}`,
|
|
240
|
+
outcome: "processing_failed",
|
|
241
|
+
stage: "transaction",
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
const committedDecisions = transaction.plan.drafts;
|
|
245
|
+
for (const decision of committedDecisions) {
|
|
246
|
+
if (decision.action === "promote") {
|
|
247
|
+
const targetPath = join(recipeRoot, `${decision.target}.json`);
|
|
248
|
+
if (!RecipesUsage.moveRecipeUsage(decision.draft, targetPath, recipeRoot)) {
|
|
249
|
+
throw new Error(`Could not transfer promoted recipe lineage: ${decision.draft}`);
|
|
250
|
+
}
|
|
251
|
+
} else if (!RecipesUsage.retireRecipeUsage(decision.draft, recipeRoot)) {
|
|
252
|
+
throw new Error(`Could not retire discarded recipe lineage: ${decision.draft}`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
const evidencePath = join(cycleDir, "sleep-evidence.json");
|
|
256
|
+
writeJsonAtomic(evidencePath, {
|
|
257
|
+
batchId: state.batchId,
|
|
258
|
+
decisions: committedDecisions,
|
|
259
|
+
garbageCollection: {
|
|
260
|
+
reviewedSources: committedDecisions.length,
|
|
261
|
+
status: "pending",
|
|
262
|
+
},
|
|
263
|
+
transactionEvidencePath: transaction.evidencePath,
|
|
264
|
+
ts: (deps.now ?? (() => new Date()))().toISOString(),
|
|
265
|
+
});
|
|
266
|
+
return {
|
|
267
|
+
cleanup: () => {
|
|
268
|
+
rmSync(join(cycleDir, "quarantine"), { recursive: true, force: true });
|
|
269
|
+
rmSync(join(cycleDir, "backups"), { recursive: true, force: true });
|
|
270
|
+
writeJsonAtomic(evidencePath, {
|
|
271
|
+
batchId: state.batchId,
|
|
272
|
+
decisions: committedDecisions,
|
|
273
|
+
garbageCollection: {
|
|
274
|
+
reviewedSources: committedDecisions.length,
|
|
275
|
+
status: "completed",
|
|
276
|
+
},
|
|
277
|
+
transactionEvidencePath: transaction.evidencePath,
|
|
278
|
+
ts: (deps.now ?? (() => new Date()))().toISOString(),
|
|
279
|
+
});
|
|
280
|
+
},
|
|
281
|
+
evidencePath,
|
|
282
|
+
outcome: "completed",
|
|
283
|
+
};
|
|
284
|
+
} catch (error) {
|
|
285
|
+
return {
|
|
286
|
+
error: error instanceof Error ? error.message : String(error),
|
|
287
|
+
outcome: "processing_failed",
|
|
288
|
+
stage: "transaction_or_lineage",
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export function processDraftSleepReview(
|
|
294
|
+
state: DraftSleepState,
|
|
295
|
+
deps: ProcessDraftSleepReviewDeps,
|
|
296
|
+
): DraftSleepProcessResult {
|
|
297
|
+
const recipeRoot = deps.recipeRoot ?? Paths.getRecipeRoot();
|
|
298
|
+
const cycleDir = dirname(state.inputPath);
|
|
299
|
+
if (existsSync(join(cycleDir, "journal.json"))) {
|
|
300
|
+
const firstSource = state.sourcePaths[0];
|
|
301
|
+
if (!firstSource) {
|
|
302
|
+
return {
|
|
303
|
+
error: "captured draft source is unavailable for transaction recovery",
|
|
304
|
+
outcome: "processing_failed",
|
|
305
|
+
stage: "transaction",
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
try {
|
|
309
|
+
const transaction = DraftConsolidationTransaction.recoverDraftConsolidationCycle({
|
|
310
|
+
cycleDir,
|
|
311
|
+
draftRoot: dirname(firstSource),
|
|
312
|
+
recipeRoot,
|
|
313
|
+
});
|
|
314
|
+
return completeDraftSleepTransaction(transaction, state, deps, cycleDir, recipeRoot);
|
|
315
|
+
} catch (error) {
|
|
316
|
+
return {
|
|
317
|
+
error: error instanceof Error ? error.message : String(error),
|
|
318
|
+
outcome: "processing_failed",
|
|
319
|
+
stage: "transaction_or_lineage",
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (!state.runId) {
|
|
324
|
+
return { error: "review run id is unavailable", outcome: "review_failed", stage: "review_state" };
|
|
325
|
+
}
|
|
326
|
+
let status: Record<string, unknown>;
|
|
327
|
+
try {
|
|
328
|
+
status = deps.getRunStatus(state.runId);
|
|
329
|
+
} catch (error) {
|
|
330
|
+
return {
|
|
331
|
+
error: error instanceof Error ? error.message : String(error),
|
|
332
|
+
outcome: "review_failed",
|
|
333
|
+
stage: "review_state",
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
if (status.status === "running") return { outcome: "pending" };
|
|
337
|
+
if (status.status !== "done" || typeof status.state_dir !== "string") {
|
|
338
|
+
return {
|
|
339
|
+
error: `review run ended with status ${String(status.status ?? "unknown")}`,
|
|
340
|
+
outcome: "review_failed",
|
|
341
|
+
stage: "review_run",
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
let input: DraftReviewInput;
|
|
345
|
+
let result: ReturnType<typeof parseDraftReviewResult>;
|
|
346
|
+
try {
|
|
347
|
+
input = JSON.parse(readFileSync(state.inputPath, "utf8")) as DraftReviewInput;
|
|
348
|
+
result = parseDraftReviewResult(
|
|
349
|
+
readFileSync(join(status.state_dir, "stdout.log"), "utf8"),
|
|
350
|
+
);
|
|
351
|
+
result = ReviewProjection.restoreDraftReviewResult(input, result);
|
|
352
|
+
} catch (error) {
|
|
353
|
+
return {
|
|
354
|
+
error: error instanceof Error ? error.message : String(error),
|
|
355
|
+
outcome: "review_failed",
|
|
356
|
+
stage: "result_parse",
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
const validation = validateDraftReviewResult(input, result);
|
|
360
|
+
if (!validation.ok) {
|
|
361
|
+
return {
|
|
362
|
+
error: validation.errors.join("; "),
|
|
363
|
+
outcome: "review_failed",
|
|
364
|
+
stage: "result_validation",
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
const draftRoot = dirname(input.drafts[0]!.path);
|
|
368
|
+
const capturedDrafts = new Map(input.drafts.map((draft) => [draft.path, draft]));
|
|
369
|
+
const plan: DraftConsolidationPlan = {
|
|
370
|
+
createdAt: result.createdAt,
|
|
371
|
+
cycleId: state.batchId,
|
|
372
|
+
drafts: result.decisions.map((decision) => {
|
|
373
|
+
const source = capturedDrafts.get(decision.draft);
|
|
374
|
+
if (decision.action === "promote" && !source?.recipe) {
|
|
375
|
+
throw new Error(`Promoted draft source recipe is unavailable: ${decision.draft}`);
|
|
376
|
+
}
|
|
377
|
+
return {
|
|
378
|
+
action: decision.action,
|
|
379
|
+
draft: decision.draft,
|
|
380
|
+
rationale: decision.rationale,
|
|
381
|
+
...(decision.action === "promote" ? { recipe: source!.recipe } : {}),
|
|
382
|
+
sha256: decision.sha256,
|
|
383
|
+
...(decision.target ? { target: decision.target } : {}),
|
|
384
|
+
...(decision.action === "promote" ? { targetSha256: null } : {}),
|
|
385
|
+
};
|
|
386
|
+
}),
|
|
387
|
+
};
|
|
388
|
+
const inventory = input.drafts.map((draft) => ({
|
|
389
|
+
id: basename(draft.path).replace(/\.(?:json|md)$/u, ""),
|
|
390
|
+
path: draft.path,
|
|
391
|
+
sha256: draft.sha256,
|
|
392
|
+
valid: draft.valid,
|
|
393
|
+
...(draft.diagnostics !== undefined ? { diagnostics: draft.diagnostics } : {}),
|
|
394
|
+
...(draft.riskLabels.length > 0 ? { riskLabels: draft.riskLabels } : {}),
|
|
395
|
+
}));
|
|
396
|
+
try {
|
|
397
|
+
const transaction = DraftConsolidationTransaction.applyDraftConsolidationPlan(plan, {
|
|
398
|
+
cycleDir,
|
|
399
|
+
draftRoot,
|
|
400
|
+
inventory,
|
|
401
|
+
recipeRoot,
|
|
402
|
+
sourceScope: "batch",
|
|
403
|
+
});
|
|
404
|
+
return completeDraftSleepTransaction(transaction, state, deps, cycleDir, recipeRoot);
|
|
405
|
+
} catch (error) {
|
|
406
|
+
return {
|
|
407
|
+
error: error instanceof Error ? error.message : String(error),
|
|
408
|
+
outcome: "processing_failed",
|
|
409
|
+
stage: "transaction_or_lineage",
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function cleanupCompletedState(state: DraftSleepState): void {
|
|
415
|
+
const cycleDir = dirname(state.inputPath);
|
|
416
|
+
rmSync(join(cycleDir, "quarantine"), { recursive: true, force: true });
|
|
417
|
+
rmSync(join(cycleDir, "backups"), { recursive: true, force: true });
|
|
418
|
+
if (!state.evidencePath || !existsSync(state.evidencePath)) return;
|
|
419
|
+
try {
|
|
420
|
+
const evidence = JSON.parse(readFileSync(state.evidencePath, "utf8")) as Record<string, unknown>;
|
|
421
|
+
const garbageCollection = evidence.garbageCollection as
|
|
422
|
+
| Record<string, unknown>
|
|
423
|
+
| undefined;
|
|
424
|
+
if (garbageCollection?.status === "completed") return;
|
|
425
|
+
writeJsonAtomic(state.evidencePath, {
|
|
426
|
+
...evidence,
|
|
427
|
+
garbageCollection: {
|
|
428
|
+
...garbageCollection,
|
|
429
|
+
status: "completed",
|
|
430
|
+
},
|
|
431
|
+
});
|
|
432
|
+
} catch {
|
|
433
|
+
/* bounded diagnostic evidence remains available for later inspection */
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
export function createDraftSleepScheduler(
|
|
438
|
+
deps: DraftSleepSchedulerDeps,
|
|
439
|
+
): DraftSleepScheduler {
|
|
440
|
+
const statePath = deps.statePath ?? Paths.getDraftSleepStatePath();
|
|
441
|
+
const draftRoot = deps.draftRoot ?? Paths.getRecipeDraftRoot();
|
|
442
|
+
const recipeRoot = deps.recipeRoot ?? Paths.getRecipeRoot();
|
|
443
|
+
const now = deps.now ?? (() => new Date());
|
|
444
|
+
let timer: NodeJS.Timeout | undefined;
|
|
445
|
+
let closed = false;
|
|
446
|
+
const close = (): void => {
|
|
447
|
+
closed = true;
|
|
448
|
+
if (timer) clearTimeout(timer);
|
|
449
|
+
timer = undefined;
|
|
450
|
+
};
|
|
451
|
+
const schedule = (): void => {
|
|
452
|
+
if (closed || timer) return;
|
|
453
|
+
timer = setTimeout(() => {
|
|
454
|
+
timer = undefined;
|
|
455
|
+
if (closed || deps.hasActiveActors()) return;
|
|
456
|
+
try {
|
|
457
|
+
withFileMutationLock(statePath, () => {
|
|
458
|
+
const existing = readState(statePath);
|
|
459
|
+
if (existing?.phase === "completed") {
|
|
460
|
+
cleanupCompletedState(existing);
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
if (
|
|
464
|
+
existing?.phase === "launched" ||
|
|
465
|
+
existing?.phase === "processing_failed"
|
|
466
|
+
) {
|
|
467
|
+
if (!deps.process || (existing.processingAttempts ?? 0) >= 3) return;
|
|
468
|
+
let processed: DraftSleepProcessResult;
|
|
469
|
+
try {
|
|
470
|
+
processed = deps.process(existing);
|
|
471
|
+
} catch (error) {
|
|
472
|
+
processed = {
|
|
473
|
+
error: error instanceof Error ? error.message : String(error),
|
|
474
|
+
outcome: "processing_failed",
|
|
475
|
+
stage: "result_processing",
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
if (processed.outcome === "pending") return;
|
|
479
|
+
if (processed.outcome === "completed") {
|
|
480
|
+
const completed = {
|
|
481
|
+
...existing,
|
|
482
|
+
...(processed.evidencePath
|
|
483
|
+
? { evidencePath: processed.evidencePath }
|
|
484
|
+
: {}),
|
|
485
|
+
failedStage: undefined,
|
|
486
|
+
lastError: undefined,
|
|
487
|
+
nextAction: undefined,
|
|
488
|
+
phase: "completed" as const,
|
|
489
|
+
updatedAt: now().toISOString(),
|
|
490
|
+
};
|
|
491
|
+
writeJsonAtomic(statePath, completed);
|
|
492
|
+
processed.cleanup?.();
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
if (processed.outcome === "processing_failed") {
|
|
496
|
+
writeJsonAtomic(statePath, {
|
|
497
|
+
...existing,
|
|
498
|
+
failedStage: processed.stage ?? "result_processing",
|
|
499
|
+
lastError: processed.error ?? "automatic draft review processing failed",
|
|
500
|
+
nextAction: "message target=runtime action=review.retry input={\"scope\":\"draft\"}",
|
|
501
|
+
phase: "processing_failed",
|
|
502
|
+
processingAttempts: (existing.processingAttempts ?? 0) + 1,
|
|
503
|
+
updatedAt: now().toISOString(),
|
|
504
|
+
});
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
writeJsonAtomic(statePath, {
|
|
508
|
+
...existing,
|
|
509
|
+
failedStage: processed.stage ?? "review_result",
|
|
510
|
+
lastError: processed.error ?? "automatic draft reviewer failed",
|
|
511
|
+
nextAction: "message target=runtime action=review.retry input={\"scope\":\"draft\"}",
|
|
512
|
+
phase: "failed",
|
|
513
|
+
runId: undefined,
|
|
514
|
+
updatedAt: now().toISOString(),
|
|
515
|
+
});
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
let batch: DraftSleepBatch | undefined;
|
|
519
|
+
try {
|
|
520
|
+
batch = existing?.phase === "captured" || existing?.phase === "failed"
|
|
521
|
+
? {
|
|
522
|
+
batchId: existing.batchId,
|
|
523
|
+
inputPath: existing.inputPath,
|
|
524
|
+
reviewerInputPath: existing.reviewerInputPath,
|
|
525
|
+
sourcePaths: existing.sourcePaths,
|
|
526
|
+
}
|
|
527
|
+
: captureDraftSleepBatchLocked(
|
|
528
|
+
deps,
|
|
529
|
+
draftRoot,
|
|
530
|
+
recipeRoot,
|
|
531
|
+
statePath,
|
|
532
|
+
);
|
|
533
|
+
if (!batch) return;
|
|
534
|
+
const attempts = (existing?.batchId === batch.batchId ? existing.attempts : 0) + 1;
|
|
535
|
+
if (attempts > 3) return;
|
|
536
|
+
const launched = deps.launch(batch);
|
|
537
|
+
writeJsonAtomic(statePath, {
|
|
538
|
+
attempts,
|
|
539
|
+
batchId: batch.batchId,
|
|
540
|
+
inputPath: batch.inputPath,
|
|
541
|
+
phase: "launched",
|
|
542
|
+
reviewerInputPath: batch.reviewerInputPath,
|
|
543
|
+
runId: launched.run,
|
|
544
|
+
sourcePaths: batch.sourcePaths,
|
|
545
|
+
updatedAt: now().toISOString(),
|
|
546
|
+
} satisfies DraftSleepState);
|
|
547
|
+
} catch (error) {
|
|
548
|
+
if (!batch) return;
|
|
549
|
+
const prior = readState(statePath);
|
|
550
|
+
writeJsonAtomic(statePath, {
|
|
551
|
+
attempts: (prior?.batchId === batch.batchId ? prior.attempts : 0) + 1,
|
|
552
|
+
failedStage: "review_launch",
|
|
553
|
+
lastError: error instanceof Error ? error.message : String(error),
|
|
554
|
+
nextAction: "message target=runtime action=review.retry input={\"scope\":\"draft\"}",
|
|
555
|
+
batchId: batch.batchId,
|
|
556
|
+
inputPath: batch.inputPath,
|
|
557
|
+
phase: "failed",
|
|
558
|
+
reviewerInputPath: batch.reviewerInputPath,
|
|
559
|
+
sourcePaths: batch.sourcePaths,
|
|
560
|
+
updatedAt: now().toISOString(),
|
|
561
|
+
} satisfies DraftSleepState);
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
} catch {
|
|
565
|
+
/* another session owns the durable admission transition */
|
|
566
|
+
}
|
|
567
|
+
}, deps.delayMs ?? DEFAULT_DELAY_MS);
|
|
568
|
+
timer.unref?.();
|
|
569
|
+
};
|
|
570
|
+
return { close, schedule };
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
export function draftSleepRunId(batchId: string): string {
|
|
574
|
+
return `draft-sleep-${basename(batchId)}`;
|
|
575
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registered tool execution output.
|
|
3
|
+
* Zones: command execution results, bounded output formatting, temp artifacts
|
|
4
|
+
* Owns stdout/stderr failure formatting, tail truncation, and full-output temp-file persistence.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
|
|
10
|
+
import { sanitizeFilePart } from "./identity.ts";
|
|
11
|
+
import * as Limits from "./limits.ts";
|
|
12
|
+
import * as Paths from "./paths.ts";
|
|
13
|
+
|
|
14
|
+
export interface FormattedOutput {
|
|
15
|
+
text: string;
|
|
16
|
+
truncated: boolean;
|
|
17
|
+
fullOutputPath?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function writeFullOutput(
|
|
21
|
+
toolName: string,
|
|
22
|
+
stream: string,
|
|
23
|
+
content: string,
|
|
24
|
+
): string | undefined {
|
|
25
|
+
try {
|
|
26
|
+
const outputRoot = join(Paths.getExtensionTmpDir(), "outputs");
|
|
27
|
+
mkdirSync(outputRoot, { recursive: true });
|
|
28
|
+
const dir = mkdtempSync(join(outputRoot, "tool-output-"));
|
|
29
|
+
const filePath = join(
|
|
30
|
+
dir,
|
|
31
|
+
`${sanitizeFilePart(toolName)}-${sanitizeFilePart(stream)}.txt`,
|
|
32
|
+
);
|
|
33
|
+
writeFileSync(filePath, content, "utf8");
|
|
34
|
+
return filePath;
|
|
35
|
+
} catch {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function formatSize(bytes: number): string {
|
|
41
|
+
if (bytes < 1024) return `${bytes}B`;
|
|
42
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)}KB`;
|
|
43
|
+
return `${(bytes / 1024 / 1024).toFixed(1)}MB`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function byteLength(value: string): number {
|
|
47
|
+
return Buffer.byteLength(value, "utf8");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function trimToTailBytes(value: string, maxBytes: number): string {
|
|
51
|
+
const buffer = Buffer.from(value, "utf8");
|
|
52
|
+
if (buffer.length <= maxBytes) return value;
|
|
53
|
+
return buffer
|
|
54
|
+
.subarray(buffer.length - maxBytes)
|
|
55
|
+
.toString("utf8")
|
|
56
|
+
.replace(/^\uFFFD+/, "");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function truncateTailContent(content: string): {
|
|
60
|
+
content: string;
|
|
61
|
+
outputBytes: number;
|
|
62
|
+
outputLines: number;
|
|
63
|
+
totalBytes: number;
|
|
64
|
+
totalLines: number;
|
|
65
|
+
truncated: boolean;
|
|
66
|
+
} {
|
|
67
|
+
const totalBytes = byteLength(content);
|
|
68
|
+
const lines = content.split("\n");
|
|
69
|
+
const totalLines = lines.length;
|
|
70
|
+
let output =
|
|
71
|
+
totalLines > Limits.TOOL_OUTPUT_MAX_LINES
|
|
72
|
+
? lines.slice(-Limits.TOOL_OUTPUT_MAX_LINES).join("\n")
|
|
73
|
+
: content;
|
|
74
|
+
output = trimToTailBytes(output, Limits.TOOL_OUTPUT_MAX_BYTES);
|
|
75
|
+
const outputBytes = byteLength(output);
|
|
76
|
+
const outputLines = output ? output.split("\n").length : 0;
|
|
77
|
+
return {
|
|
78
|
+
content: output,
|
|
79
|
+
outputBytes,
|
|
80
|
+
outputLines,
|
|
81
|
+
totalBytes,
|
|
82
|
+
totalLines,
|
|
83
|
+
truncated: outputBytes < totalBytes || outputLines < totalLines,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function formatToolText(text: string): string {
|
|
88
|
+
return `\n${text.replace(/^\n+/, "")}`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function formatOutput(
|
|
92
|
+
toolName: string,
|
|
93
|
+
stream: string,
|
|
94
|
+
content: string,
|
|
95
|
+
): FormattedOutput {
|
|
96
|
+
const body = content.trimEnd() || "(no output)";
|
|
97
|
+
const truncation = truncateTailContent(body);
|
|
98
|
+
if (!truncation.truncated) {
|
|
99
|
+
return { text: formatToolText(truncation.content), truncated: false };
|
|
100
|
+
}
|
|
101
|
+
const fullOutputPath = writeFullOutput(toolName, stream, body);
|
|
102
|
+
const notice = fullOutputPath
|
|
103
|
+
? `[Output truncated: ${truncation.outputLines} of ${truncation.totalLines} lines (${formatSize(truncation.outputBytes)} of ${formatSize(truncation.totalBytes)}). Full output saved to: ${fullOutputPath}]`
|
|
104
|
+
: `[Output truncated: ${truncation.outputLines} of ${truncation.totalLines} lines (${formatSize(truncation.outputBytes)} of ${formatSize(truncation.totalBytes)}). Full output could not be saved.]`;
|
|
105
|
+
return {
|
|
106
|
+
text: formatToolText(`${truncation.content}\n\n${notice}`),
|
|
107
|
+
truncated: true,
|
|
108
|
+
fullOutputPath,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function formatFailureOutput(
|
|
113
|
+
toolName: string,
|
|
114
|
+
code: number,
|
|
115
|
+
killed: boolean,
|
|
116
|
+
stdout: string,
|
|
117
|
+
stderr: string,
|
|
118
|
+
): FormattedOutput {
|
|
119
|
+
const parts = [`Exit code ${code}${killed ? " (killed)" : ""}`];
|
|
120
|
+
if (stderr.trim()) parts.push(`stderr:\n${stderr.trimEnd()}`);
|
|
121
|
+
if (stdout.trim()) parts.push(`stdout:\n${stdout.trimEnd()}`);
|
|
122
|
+
return formatOutput(toolName, "error", parts.join("\n\n"));
|
|
123
|
+
}
|