@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,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pi actor extension runtime coordinator.
|
|
3
|
+
* Zones: extension session lifecycle, host tool adaptation, runtime service composition
|
|
4
|
+
* Owns low-level Pi lifecycle effects and tool wrapping without owning event registration.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as AutomaticReviewRuntime from "./automatic-review-runtime.ts";
|
|
8
|
+
import * as CommandTemplates from "./command-templates.ts";
|
|
9
|
+
import * as Paths from "./paths.ts";
|
|
10
|
+
import * as Pi from "./pi.ts";
|
|
11
|
+
import * as Prompts from "./prompts.ts";
|
|
12
|
+
import * as RecipeResolution from "./recipes-context.ts";
|
|
13
|
+
import * as RecipesReferences from "./recipes-references.ts";
|
|
14
|
+
import * as RunUiRuntime from "./run-ui-runtime.ts";
|
|
15
|
+
import * as Runtime from "./runtime.ts";
|
|
16
|
+
import * as Temp from "./temp.ts";
|
|
17
|
+
import * as Tools from "./tools.ts";
|
|
18
|
+
import * as ToolsResponse from "./tools-response.ts";
|
|
19
|
+
|
|
20
|
+
export interface ActorExtensionRuntime {
|
|
21
|
+
beforeAgentStart(
|
|
22
|
+
systemPrompt: string,
|
|
23
|
+
skills: RecipesReferences.ActiveSkillRecipeSource[],
|
|
24
|
+
ctx: Pi.ExtensionContext,
|
|
25
|
+
): { systemPrompt: string };
|
|
26
|
+
discoverResources(metaUrl: string): { skillPaths: string[] } | undefined;
|
|
27
|
+
getRunOwnerId(ctx: Pi.ExtensionContext): string;
|
|
28
|
+
onAgentEnd(ctx: Pi.ExtensionContext): void;
|
|
29
|
+
onSessionShutdown(reason: string, ctx: Pi.ExtensionContext): void;
|
|
30
|
+
onSessionStart(ctx: Pi.ExtensionContext): Promise<void>;
|
|
31
|
+
registerCoreTools(): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function createActorExtensionRuntime(
|
|
35
|
+
pi: Pi.ExtensionAPI,
|
|
36
|
+
): ActorExtensionRuntime {
|
|
37
|
+
let activeRunContext: Pi.ExtensionContext | undefined;
|
|
38
|
+
const recipeResolutionContextsBySession = new Map<
|
|
39
|
+
string,
|
|
40
|
+
RecipeResolution.RecipeResolutionContext
|
|
41
|
+
>();
|
|
42
|
+
const getRunOwnerId = Pi.getSessionId;
|
|
43
|
+
const getRecipeResolutionContext = (ctx: Pi.ExtensionContext) => {
|
|
44
|
+
const sessionId = getRunOwnerId(ctx);
|
|
45
|
+
const resolutionContext = recipeResolutionContextsBySession.get(sessionId);
|
|
46
|
+
if (!resolutionContext) {
|
|
47
|
+
throw new Error(
|
|
48
|
+
`Recipe resolution context is unavailable for session ${sessionId}.`,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
return resolutionContext;
|
|
52
|
+
};
|
|
53
|
+
const automaticReview = AutomaticReviewRuntime.createAutomaticReviewRuntime({
|
|
54
|
+
getActiveContext: () => activeRunContext,
|
|
55
|
+
getRunOwnerId,
|
|
56
|
+
getThinkingLevel: () => pi.getThinkingLevel(),
|
|
57
|
+
});
|
|
58
|
+
const runUiRuntime = RunUiRuntime.createRunUiRuntime({
|
|
59
|
+
getActiveContext: () => activeRunContext,
|
|
60
|
+
getRunOwnerId,
|
|
61
|
+
onRunEvent: automaticReview.schedule,
|
|
62
|
+
pi,
|
|
63
|
+
});
|
|
64
|
+
const actorToolDefinitions = new Map<string, Tools.ActorToolDefinition>();
|
|
65
|
+
const withCurrentThinkingContext = <T extends Tools.ActorToolDefinition>(
|
|
66
|
+
definition: T,
|
|
67
|
+
): T => {
|
|
68
|
+
if (typeof definition.execute !== "function") return definition;
|
|
69
|
+
const execute = definition.execute as (...args: unknown[]) => unknown;
|
|
70
|
+
return {
|
|
71
|
+
...definition,
|
|
72
|
+
execute: async (...args: unknown[]) => {
|
|
73
|
+
const nextArgs = [...args];
|
|
74
|
+
const ctx = nextArgs[4];
|
|
75
|
+
if (ctx && typeof ctx === "object") {
|
|
76
|
+
nextArgs[4] = {
|
|
77
|
+
...(ctx as Record<string, unknown>),
|
|
78
|
+
recipeResolutionContext: getRecipeResolutionContext(
|
|
79
|
+
ctx as Pi.ExtensionContext,
|
|
80
|
+
),
|
|
81
|
+
getThinkingLevel: () => pi.getThinkingLevel(),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
return ToolsResponse.spaceToolResult(await execute(...nextArgs));
|
|
86
|
+
} catch (error) {
|
|
87
|
+
throw ToolsResponse.spaceToolError(error);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
} as T;
|
|
91
|
+
};
|
|
92
|
+
const runtime = Runtime.createAutoToolsRuntime({
|
|
93
|
+
configPath: Paths.EXTENSION_RUNTIME_PATHS.configPath,
|
|
94
|
+
exec: CommandTemplates.execCommandTemplate,
|
|
95
|
+
getActiveTools: () => pi.getActiveTools(),
|
|
96
|
+
getAllTools: () => pi.getAllTools(),
|
|
97
|
+
registerTool: (definition) => {
|
|
98
|
+
const wrapped = withCurrentThinkingContext(definition);
|
|
99
|
+
actorToolDefinitions.set(wrapped.name, wrapped);
|
|
100
|
+
pi.registerTool(wrapped);
|
|
101
|
+
},
|
|
102
|
+
reservedToolNames: Tools.RESERVED_TOOL_NAMES,
|
|
103
|
+
setActiveTools: (toolNames) => pi.setActiveTools(toolNames),
|
|
104
|
+
});
|
|
105
|
+
const recipeReload = Runtime.createRecipeToolReloadWatcher(runtime, {
|
|
106
|
+
getResolutionContext: () =>
|
|
107
|
+
activeRunContext
|
|
108
|
+
? getRecipeResolutionContext(activeRunContext)
|
|
109
|
+
: undefined,
|
|
110
|
+
});
|
|
111
|
+
return {
|
|
112
|
+
beforeAgentStart(systemPrompt, skills, ctx) {
|
|
113
|
+
const sessionId = getRunOwnerId(ctx);
|
|
114
|
+
const resolutionContext = RecipeResolution.createRecipeResolutionContext(
|
|
115
|
+
sessionId,
|
|
116
|
+
ctx.cwd,
|
|
117
|
+
RecipesReferences.createActiveSkillRecipeContext(skills),
|
|
118
|
+
);
|
|
119
|
+
recipeResolutionContextsBySession.set(sessionId, resolutionContext);
|
|
120
|
+
runtime.loadTools(ctx, resolutionContext);
|
|
121
|
+
return {
|
|
122
|
+
systemPrompt: `${systemPrompt}\n\n${Prompts.ONBOARDING_SYSTEM_PROMPT}`,
|
|
123
|
+
};
|
|
124
|
+
},
|
|
125
|
+
discoverResources(metaUrl) {
|
|
126
|
+
const skillPaths = Paths.getExistingExtensionSkillPaths(metaUrl);
|
|
127
|
+
return skillPaths.length > 0 ? { skillPaths } : undefined;
|
|
128
|
+
},
|
|
129
|
+
getRunOwnerId,
|
|
130
|
+
onAgentEnd(ctx) {
|
|
131
|
+
if (activeRunContext === ctx) automaticReview.schedule();
|
|
132
|
+
},
|
|
133
|
+
onSessionShutdown(reason, ctx) {
|
|
134
|
+
recipeResolutionContextsBySession.delete(getRunOwnerId(ctx));
|
|
135
|
+
activeRunContext = undefined;
|
|
136
|
+
automaticReview.close();
|
|
137
|
+
recipeReload.close();
|
|
138
|
+
runUiRuntime.shutdown(reason, ctx);
|
|
139
|
+
},
|
|
140
|
+
async onSessionStart(ctx) {
|
|
141
|
+
const sessionId = getRunOwnerId(ctx);
|
|
142
|
+
recipeResolutionContextsBySession.set(
|
|
143
|
+
sessionId,
|
|
144
|
+
RecipeResolution.createEmptyRecipeResolutionContext(sessionId, ctx.cwd),
|
|
145
|
+
);
|
|
146
|
+
ctx.ui.setWidget("zz-pi-actors-comms", undefined);
|
|
147
|
+
activeRunContext = ctx;
|
|
148
|
+
runUiRuntime.close();
|
|
149
|
+
automaticReview.close();
|
|
150
|
+
recipeReload.close();
|
|
151
|
+
await Temp.prepareExtensionTempDir(Paths.EXTENSION_RUNTIME_PATHS.tempDir);
|
|
152
|
+
if (activeRunContext !== ctx) return;
|
|
153
|
+
automaticReview.start(ctx);
|
|
154
|
+
runUiRuntime.start(ctx);
|
|
155
|
+
recipeReload.watch(ctx);
|
|
156
|
+
},
|
|
157
|
+
registerCoreTools() {
|
|
158
|
+
Pi.registerToolDefinitions(
|
|
159
|
+
pi,
|
|
160
|
+
Tools.createCoreActorToolDefinitions<Pi.ExtensionContext>({
|
|
161
|
+
configPath: Paths.EXTENSION_RUNTIME_PATHS.configPath,
|
|
162
|
+
getActiveTools: () => pi.getActiveTools(),
|
|
163
|
+
getRecipeResolutionContext: () =>
|
|
164
|
+
activeRunContext
|
|
165
|
+
? getRecipeResolutionContext(activeRunContext)
|
|
166
|
+
: undefined,
|
|
167
|
+
getRuntimeTool: (name) =>
|
|
168
|
+
Tools.resolveActiveRuntimeTool(
|
|
169
|
+
name,
|
|
170
|
+
runtime.getTools(),
|
|
171
|
+
(activeName) => actorToolDefinitions.get(activeName),
|
|
172
|
+
),
|
|
173
|
+
getRuntimeToolStatus: runtime.getToolStatus,
|
|
174
|
+
handleRuntimeControl: automaticReview.handleControl,
|
|
175
|
+
registryRuntime: runtime,
|
|
176
|
+
setActiveTools: (toolNames) => pi.setActiveTools(toolNames),
|
|
177
|
+
}).map(withCurrentThinkingContext),
|
|
178
|
+
);
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File state persistence helpers
|
|
3
|
+
* Zones: file persistence, atomic writes, runtime state support
|
|
4
|
+
* Owns generic durable JSON file writes shared by registry config and async run state.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { spawnSync } from "node:child_process";
|
|
8
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
9
|
+
import { existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { tmpdir } from "node:os";
|
|
11
|
+
import { basename, dirname, join, parse, resolve } from "node:path";
|
|
12
|
+
|
|
13
|
+
const FILE_MUTATION_LOCK_TIMEOUT_MS = process.platform === "win32" ? 30000 : 15000;
|
|
14
|
+
const FILE_MUTATION_LOCK_STALE_MS = 30000;
|
|
15
|
+
const FILE_MUTATION_LOCK_RECLAIM_POLL_MS = 100;
|
|
16
|
+
const FILE_MUTATION_LOCK_REMOVAL_GRACE_MS = 250;
|
|
17
|
+
const FILE_MUTATION_LOCK_MAX_WAIT_MS = 50;
|
|
18
|
+
const FILE_MUTATION_LOCK_ROOT = join(tmpdir(), "pi-actors-file-locks");
|
|
19
|
+
|
|
20
|
+
function canonicalMutationPath(path: string): string {
|
|
21
|
+
const absolute = resolve(path);
|
|
22
|
+
try {
|
|
23
|
+
if (lstatSync(absolute).isSymbolicLink()) {
|
|
24
|
+
const target = realpathSync.native(absolute);
|
|
25
|
+
return process.platform === "win32" ? target.toLowerCase() : target;
|
|
26
|
+
}
|
|
27
|
+
} catch {
|
|
28
|
+
/* Materialization may race lock-key derivation; canonicalize through the parent. */
|
|
29
|
+
}
|
|
30
|
+
const suffix: string[] = [basename(absolute)];
|
|
31
|
+
let existing = dirname(absolute);
|
|
32
|
+
while (!existsSync(existing)) {
|
|
33
|
+
const parent = dirname(existing);
|
|
34
|
+
if (parent === existing || existing === parse(existing).root) break;
|
|
35
|
+
suffix.unshift(basename(existing));
|
|
36
|
+
existing = parent;
|
|
37
|
+
}
|
|
38
|
+
const canonicalAncestor = existsSync(existing)
|
|
39
|
+
? realpathSync.native(existing)
|
|
40
|
+
: existing;
|
|
41
|
+
const canonical = resolve(canonicalAncestor, ...suffix);
|
|
42
|
+
return process.platform === "win32" ? canonical.toLowerCase() : canonical;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function mutationLockPath(path: string): string {
|
|
46
|
+
const key = createHash("sha256")
|
|
47
|
+
.update(canonicalMutationPath(path))
|
|
48
|
+
.digest("hex");
|
|
49
|
+
return join(FILE_MUTATION_LOCK_ROOT, `${key}.lock`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function isZombieProcess(pid: number): boolean {
|
|
53
|
+
if (process.platform === "linux") try {
|
|
54
|
+
const stat = readFileSync(`/proc/${pid}/stat`, "utf8");
|
|
55
|
+
return stat.slice(stat.lastIndexOf(")") + 2).startsWith("Z ");
|
|
56
|
+
} catch { return false; }
|
|
57
|
+
if (process.platform !== "darwin") return false;
|
|
58
|
+
const result = spawnSync("ps", ["-p", String(pid), "-o", "stat="], { encoding: "utf8" });
|
|
59
|
+
return result.status === 0 && result.stdout.trim().startsWith("Z");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function lockOwnerStatus(lockPath: string): "alive" | "dead" | "unknown" {
|
|
63
|
+
try {
|
|
64
|
+
const owner = JSON.parse(
|
|
65
|
+
readFileSync(join(lockPath, "owner.json"), "utf8"),
|
|
66
|
+
) as { pid?: unknown };
|
|
67
|
+
const pid = Number(owner.pid);
|
|
68
|
+
if (!Number.isInteger(pid) || pid <= 0) return "unknown";
|
|
69
|
+
try {
|
|
70
|
+
process.kill(pid, 0);
|
|
71
|
+
if (Date.now() - statSync(lockPath).mtimeMs > FILE_MUTATION_LOCK_REMOVAL_GRACE_MS &&
|
|
72
|
+
isZombieProcess(pid)) return "dead";
|
|
73
|
+
return "alive";
|
|
74
|
+
} catch (error) {
|
|
75
|
+
return (error as NodeJS.ErrnoException).code === "ESRCH"
|
|
76
|
+
? "dead"
|
|
77
|
+
: "unknown";
|
|
78
|
+
}
|
|
79
|
+
} catch {
|
|
80
|
+
return "unknown";
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface FileMutationLockOptions {
|
|
85
|
+
onBeforeLockPublish?(): void;
|
|
86
|
+
onBeforeReclaimRemove?(): void;
|
|
87
|
+
onContention?(): void;
|
|
88
|
+
onRemovalContention?(): void;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function readLockToken(lockPath: string): string | undefined {
|
|
92
|
+
try {
|
|
93
|
+
const owner = JSON.parse(
|
|
94
|
+
readFileSync(join(lockPath, "owner.json"), "utf8"),
|
|
95
|
+
) as { token?: unknown };
|
|
96
|
+
return typeof owner.token === "string" ? owner.token : undefined;
|
|
97
|
+
} catch {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function prepareLockBoundary(lockPath: string, token: string, onBeforePublish?: () => void): string {
|
|
103
|
+
const pendingPath = `${lockPath}.${process.pid}.${token}.pending`;
|
|
104
|
+
try {
|
|
105
|
+
mkdirSync(pendingPath);
|
|
106
|
+
writeFileSync(join(pendingPath, "owner.json"), `${JSON.stringify({ pid: process.pid, token, acquired_at: new Date().toISOString() })}\n`, "utf8");
|
|
107
|
+
onBeforePublish?.();
|
|
108
|
+
return pendingPath;
|
|
109
|
+
} catch (error) {
|
|
110
|
+
try { rmSync(pendingPath, { recursive: true, force: true }); } catch {}
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function removeLockBoundary(lockPath: string, token: string | undefined): boolean {
|
|
116
|
+
if (readLockToken(lockPath) !== token) return false;
|
|
117
|
+
if (process.platform === "win32") try { rmSync(lockPath, { recursive: true, force: true, maxRetries: 20, retryDelay: 5 }); return true; } catch { return false; }
|
|
118
|
+
const removingPath = `${lockPath}.${process.pid}.${randomUUID()}.removing`;
|
|
119
|
+
try { renameSync(lockPath, removingPath); } catch { return false; }
|
|
120
|
+
try { rmSync(removingPath, { recursive: true, force: true }); } catch {}
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function tryReclaimRemovalBoundary(reclaimPath: string): void {
|
|
125
|
+
if (!existsSync(reclaimPath)) return;
|
|
126
|
+
try {
|
|
127
|
+
const age = Date.now() - statSync(reclaimPath).mtimeMs;
|
|
128
|
+
if (age <= FILE_MUTATION_LOCK_REMOVAL_GRACE_MS) return;
|
|
129
|
+
const inspectedToken = readLockToken(reclaimPath);
|
|
130
|
+
const ownerStatus = lockOwnerStatus(reclaimPath);
|
|
131
|
+
if (
|
|
132
|
+
(ownerStatus === "dead" ||
|
|
133
|
+
(ownerStatus === "unknown" && age > FILE_MUTATION_LOCK_STALE_MS)) &&
|
|
134
|
+
readLockToken(reclaimPath) === inspectedToken
|
|
135
|
+
) {
|
|
136
|
+
removeLockBoundary(reclaimPath, inspectedToken);
|
|
137
|
+
}
|
|
138
|
+
} catch {
|
|
139
|
+
/* another contender changed the boundary */
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function withRemovalBoundary(
|
|
144
|
+
lockPath: string,
|
|
145
|
+
action: () => void,
|
|
146
|
+
): boolean {
|
|
147
|
+
const reclaimPath = `${lockPath}.reclaim`;
|
|
148
|
+
const token = randomUUID();
|
|
149
|
+
const pendingPath = prepareLockBoundary(reclaimPath, token);
|
|
150
|
+
try {
|
|
151
|
+
try { renameSync(pendingPath, reclaimPath); } catch {
|
|
152
|
+
tryReclaimRemovalBoundary(reclaimPath);
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
try {
|
|
156
|
+
action();
|
|
157
|
+
return true;
|
|
158
|
+
} finally {
|
|
159
|
+
removeLockBoundary(reclaimPath, token);
|
|
160
|
+
}
|
|
161
|
+
} finally {
|
|
162
|
+
try { rmSync(pendingPath, { recursive: true, force: true }); } catch {}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function tryReclaimMutationLock(
|
|
167
|
+
lockPath: string,
|
|
168
|
+
options: FileMutationLockOptions,
|
|
169
|
+
): boolean {
|
|
170
|
+
let reclaimed = false;
|
|
171
|
+
if (!withRemovalBoundary(lockPath, () => {
|
|
172
|
+
if (!existsSync(lockPath)) {
|
|
173
|
+
reclaimed = true;
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const inspectedToken = readLockToken(lockPath);
|
|
177
|
+
const age = Date.now() - statSync(lockPath).mtimeMs;
|
|
178
|
+
const ownerStatus = lockOwnerStatus(lockPath);
|
|
179
|
+
if (
|
|
180
|
+
(ownerStatus === "dead" ||
|
|
181
|
+
(ownerStatus === "unknown" && age > FILE_MUTATION_LOCK_STALE_MS)) &&
|
|
182
|
+
readLockToken(lockPath) === inspectedToken
|
|
183
|
+
) {
|
|
184
|
+
options.onBeforeReclaimRemove?.();
|
|
185
|
+
reclaimed = removeLockBoundary(lockPath, inspectedToken);
|
|
186
|
+
}
|
|
187
|
+
})) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
return reclaimed;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export function acquireFileMutationLock(
|
|
194
|
+
path: string,
|
|
195
|
+
options: FileMutationLockOptions = {},
|
|
196
|
+
): () => void {
|
|
197
|
+
mkdirSync(FILE_MUTATION_LOCK_ROOT, { recursive: true });
|
|
198
|
+
const lockPath = mutationLockPath(path);
|
|
199
|
+
const deadline = Date.now() + FILE_MUTATION_LOCK_TIMEOUT_MS;
|
|
200
|
+
const token = randomUUID();
|
|
201
|
+
const pendingPath = prepareLockBoundary(lockPath, token, options.onBeforeLockPublish);
|
|
202
|
+
let contentionReported = false;
|
|
203
|
+
let nextReclaimAt = 0;
|
|
204
|
+
let waitMs = 10;
|
|
205
|
+
try {
|
|
206
|
+
for (;;) {
|
|
207
|
+
try {
|
|
208
|
+
renameSync(pendingPath, lockPath);
|
|
209
|
+
break;
|
|
210
|
+
} catch (error) {
|
|
211
|
+
if (!contentionReported) {
|
|
212
|
+
contentionReported = true;
|
|
213
|
+
options.onContention?.();
|
|
214
|
+
}
|
|
215
|
+
const now = Date.now();
|
|
216
|
+
if (now >= nextReclaimAt) {
|
|
217
|
+
nextReclaimAt = now + FILE_MUTATION_LOCK_RECLAIM_POLL_MS;
|
|
218
|
+
if (tryReclaimMutationLock(lockPath, options)) {
|
|
219
|
+
waitMs = 10;
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (now >= deadline) {
|
|
224
|
+
throw new Error(`Timed out waiting for file mutation lock: ${canonicalMutationPath(path)}`, {
|
|
225
|
+
cause: error,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
const jitter = Math.floor(Math.random() * Math.max(1, Math.floor(waitMs / 2)));
|
|
229
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, waitMs + jitter);
|
|
230
|
+
waitMs = Math.min(FILE_MUTATION_LOCK_MAX_WAIT_MS, waitMs + 5);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
} finally {
|
|
234
|
+
try { rmSync(pendingPath, { recursive: true, force: true }); } catch {}
|
|
235
|
+
}
|
|
236
|
+
let released = false;
|
|
237
|
+
return () => {
|
|
238
|
+
if (released) return;
|
|
239
|
+
released = true;
|
|
240
|
+
const deadline = Date.now() + FILE_MUTATION_LOCK_TIMEOUT_MS;
|
|
241
|
+
let removalContentionReported = false;
|
|
242
|
+
while (
|
|
243
|
+
!withRemovalBoundary(lockPath, () => {
|
|
244
|
+
removeLockBoundary(lockPath, token);
|
|
245
|
+
})
|
|
246
|
+
) {
|
|
247
|
+
if (!removalContentionReported) {
|
|
248
|
+
removalContentionReported = true;
|
|
249
|
+
options.onRemovalContention?.();
|
|
250
|
+
}
|
|
251
|
+
if (Date.now() >= deadline) return;
|
|
252
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 10);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export function withFileMutationLock<T>(
|
|
258
|
+
path: string,
|
|
259
|
+
mutate: () => T,
|
|
260
|
+
options: FileMutationLockOptions = {},
|
|
261
|
+
): T {
|
|
262
|
+
const release = acquireFileMutationLock(path, options);
|
|
263
|
+
try {
|
|
264
|
+
return mutate();
|
|
265
|
+
} finally {
|
|
266
|
+
release();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function replaceFileWithRetry(source: string, target: string): void {
|
|
271
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
272
|
+
try {
|
|
273
|
+
renameSync(source, target);
|
|
274
|
+
return;
|
|
275
|
+
} catch (error) {
|
|
276
|
+
const code = (error as NodeJS.ErrnoException).code;
|
|
277
|
+
if ((code !== "EPERM" && code !== "EBUSY") || attempt >= 19) throw error;
|
|
278
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 50);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export function writeTextAtomic(
|
|
284
|
+
path: string,
|
|
285
|
+
content: string,
|
|
286
|
+
options: { onBeforeReplace?(): void } = {},
|
|
287
|
+
): void {
|
|
288
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
289
|
+
const tempPath = `${path}.${process.pid}.${Date.now()}.${randomUUID()}.tmp`;
|
|
290
|
+
try {
|
|
291
|
+
writeFileSync(tempPath, content, "utf8");
|
|
292
|
+
options.onBeforeReplace?.();
|
|
293
|
+
replaceFileWithRetry(tempPath, path);
|
|
294
|
+
} catch (error) {
|
|
295
|
+
try {
|
|
296
|
+
unlinkSync(tempPath);
|
|
297
|
+
} catch {
|
|
298
|
+
/* best effort */
|
|
299
|
+
}
|
|
300
|
+
throw error;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export function writeJsonAtomic(path: string, value: unknown): void {
|
|
305
|
+
writeTextAtomic(path, `${JSON.stringify(value, null, 2)}\n`);
|
|
306
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identifier normalization helpers
|
|
3
|
+
* Zones: registry identity, shared validation
|
|
4
|
+
* Owns stable tool, argument, and file-label identifier normalization
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export function normalizeIdentifier(value: string, prefix: string): string {
|
|
8
|
+
let name = value
|
|
9
|
+
.trim()
|
|
10
|
+
.toLowerCase()
|
|
11
|
+
.replace(/[^a-z0-9_]/g, "_")
|
|
12
|
+
.replace(/_+/g, "_")
|
|
13
|
+
.replace(/^_+|_+$/g, "");
|
|
14
|
+
if (!name) return "";
|
|
15
|
+
if (/^[0-9]/.test(name)) name = `${prefix}_${name}`;
|
|
16
|
+
return name.slice(0, 64).replace(/_+$/g, "");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function normalizeToolName(value: string): string {
|
|
20
|
+
return normalizeIdentifier(value, "tool");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function normalizeArgName(value: string): string {
|
|
24
|
+
return normalizeIdentifier(value, "arg");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function sanitizeFilePart(value: string): string {
|
|
28
|
+
return normalizeIdentifier(value, "tool") || "tool";
|
|
29
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Actor Inspector actions for concrete Run instances.
|
|
3
|
+
* Owns: exact-session run-action authorization, canonical kill routing, and bounded operator feedback.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
|
|
8
|
+
import { safeRunId } from "./runs-identity.ts";
|
|
9
|
+
|
|
10
|
+
const FEEDBACK_LIMIT = 180;
|
|
11
|
+
|
|
12
|
+
export interface ActorInspectorKillResult {
|
|
13
|
+
ok: boolean;
|
|
14
|
+
message: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ActorInspectorKillDeps {
|
|
18
|
+
getRunStatus: (runOrDir: string) => Record<string, unknown>;
|
|
19
|
+
killRun: (
|
|
20
|
+
runOrDir: string,
|
|
21
|
+
expected: { ownerId: string; runInstanceId: string },
|
|
22
|
+
) => Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function bounded(value: unknown): string {
|
|
26
|
+
const text = String(value ?? "").replaceAll(/\s+/g, " ").trim();
|
|
27
|
+
return text.length <= FEEDBACK_LIMIT
|
|
28
|
+
? text
|
|
29
|
+
: `${text.slice(0, FEEDBACK_LIMIT - 1)}…`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function killOwnedRunFromInspector(
|
|
33
|
+
ownerId: string,
|
|
34
|
+
run: string,
|
|
35
|
+
stateRoot: string,
|
|
36
|
+
expectedRunInstanceId: string,
|
|
37
|
+
deps: ActorInspectorKillDeps,
|
|
38
|
+
): ActorInspectorKillResult {
|
|
39
|
+
let stateDir: string;
|
|
40
|
+
try {
|
|
41
|
+
stateDir = join(stateRoot, safeRunId(run));
|
|
42
|
+
} catch (error) {
|
|
43
|
+
return {
|
|
44
|
+
ok: false,
|
|
45
|
+
message: `Kill rejected: ${bounded(error instanceof Error ? error.message : error)}`,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const status = deps.getRunStatus(stateDir);
|
|
50
|
+
if (status.ownerId !== ownerId) {
|
|
51
|
+
return { ok: false, message: "Kill rejected: run ownership changed." };
|
|
52
|
+
}
|
|
53
|
+
if (status.status !== "running") {
|
|
54
|
+
return {
|
|
55
|
+
ok: false,
|
|
56
|
+
message: `Kill unavailable: run is ${bounded(status.status || "terminal")}.`,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
if (status.run_instance_id !== expectedRunInstanceId) {
|
|
60
|
+
return { ok: false, message: "Kill rejected: run generation changed." };
|
|
61
|
+
}
|
|
62
|
+
const result = deps.killRun(stateDir, {
|
|
63
|
+
ownerId,
|
|
64
|
+
runInstanceId: expectedRunInstanceId,
|
|
65
|
+
});
|
|
66
|
+
if (result.killed === true) {
|
|
67
|
+
return { ok: true, message: `Killed run:${run}.` };
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
ok: false,
|
|
71
|
+
message: `Kill failed: ${bounded(result.reason || "control rejected")}.`,
|
|
72
|
+
};
|
|
73
|
+
} catch (error) {
|
|
74
|
+
return {
|
|
75
|
+
ok: false,
|
|
76
|
+
message: `Kill failed: ${bounded(error instanceof Error ? error.message : error)}.`,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Actor Inspector command adapter.
|
|
3
|
+
* Zones: Pi command registration, overlay construction, owned-run control ports
|
|
4
|
+
* Owns host-facing Inspector launch wiring without owning Inspector state or actions.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as AsyncRuns from "./async-runs.ts";
|
|
8
|
+
import * as InspectorActions from "./inspector-actions.ts";
|
|
9
|
+
import * as InspectorOverlay from "./inspector-overlay.ts";
|
|
10
|
+
import * as Paths from "./paths.ts";
|
|
11
|
+
import type * as Pi from "./pi.ts";
|
|
12
|
+
|
|
13
|
+
export function registerActorInspectorCommand(
|
|
14
|
+
pi: Pi.ExtensionAPI,
|
|
15
|
+
getRunOwnerId: (ctx: Pi.ExtensionContext) => string,
|
|
16
|
+
): void {
|
|
17
|
+
pi.registerCommand("actor-inspector", {
|
|
18
|
+
description: "Open the keyboard-driven Actor Inspector",
|
|
19
|
+
handler: async (_args, ctx) => {
|
|
20
|
+
ctx.ui.setWidget("zz-pi-actors-comms", undefined);
|
|
21
|
+
await ctx.ui.custom<void>(
|
|
22
|
+
(tui, theme, _keybindings, done) =>
|
|
23
|
+
new InspectorOverlay.ActorInspectorOverlay({
|
|
24
|
+
done,
|
|
25
|
+
killRun: (run, runInstanceId) =>
|
|
26
|
+
InspectorActions.killOwnedRunFromInspector(
|
|
27
|
+
getRunOwnerId(ctx),
|
|
28
|
+
run,
|
|
29
|
+
Paths.EXTENSION_RUNTIME_PATHS.runStateRoot,
|
|
30
|
+
runInstanceId,
|
|
31
|
+
{
|
|
32
|
+
getRunStatus: AsyncRuns.getRunStatus,
|
|
33
|
+
killRun: AsyncRuns.killRun,
|
|
34
|
+
},
|
|
35
|
+
),
|
|
36
|
+
ownerId: getRunOwnerId(ctx),
|
|
37
|
+
stateRoot: Paths.EXTENSION_RUNTIME_PATHS.runStateRoot,
|
|
38
|
+
theme,
|
|
39
|
+
tui,
|
|
40
|
+
}),
|
|
41
|
+
{
|
|
42
|
+
overlay: true,
|
|
43
|
+
overlayOptions: {
|
|
44
|
+
anchor: "center",
|
|
45
|
+
width: "94%",
|
|
46
|
+
minWidth: 72,
|
|
47
|
+
maxHeight: "94%",
|
|
48
|
+
margin: 1,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|