@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,806 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry mutation use-cases
|
|
3
|
+
* Zones: registry mutations, persistence, runtime activation
|
|
4
|
+
* Owns register/update/delete validation, persistence, runtime side effects, and result payloads
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { existsSync, mkdirSync, readFileSync, unlinkSync } from "node:fs";
|
|
8
|
+
import { dirname, join, relative, resolve } from "node:path";
|
|
9
|
+
|
|
10
|
+
import * as CommandTemplates from "./command-templates.ts";
|
|
11
|
+
import * as Config from "./config.ts";
|
|
12
|
+
import * as ExecutionOutput from "./execution-output.ts";
|
|
13
|
+
import {
|
|
14
|
+
withFileMutationLock,
|
|
15
|
+
writeJsonAtomic,
|
|
16
|
+
writeTextAtomic,
|
|
17
|
+
} from "./file-state.ts";
|
|
18
|
+
import * as Identity from "./identity.ts";
|
|
19
|
+
import * as Paths from "./paths.ts";
|
|
20
|
+
import * as RecipesContext from "./recipes-context.ts";
|
|
21
|
+
import * as RecipesDiscovery from "./recipes-discovery.ts";
|
|
22
|
+
import * as RecipesReferences from "./recipes-references.ts";
|
|
23
|
+
import * as Schema from "./schema.ts";
|
|
24
|
+
|
|
25
|
+
export interface RegisterToolInput {
|
|
26
|
+
name?: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
async?: boolean;
|
|
29
|
+
template?: CommandTemplates.CommandTemplateValue | null;
|
|
30
|
+
from?: string;
|
|
31
|
+
defaults?: Record<string, unknown>;
|
|
32
|
+
draft?: string;
|
|
33
|
+
args?: string;
|
|
34
|
+
update?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface RegisterToolResultDetails {
|
|
38
|
+
active_tool?: boolean;
|
|
39
|
+
activation?: "current_session" | "unverified";
|
|
40
|
+
activation_boundary?: string;
|
|
41
|
+
args?: string[];
|
|
42
|
+
async?: boolean;
|
|
43
|
+
callable_now?: boolean;
|
|
44
|
+
defaults?: Record<string, string>;
|
|
45
|
+
host_registered?: boolean;
|
|
46
|
+
next_actions?: string[];
|
|
47
|
+
optional_args?: string[];
|
|
48
|
+
persisted?: boolean;
|
|
49
|
+
promoted?: boolean;
|
|
50
|
+
registry_active?: boolean;
|
|
51
|
+
required_args?: string[];
|
|
52
|
+
resolved?: boolean;
|
|
53
|
+
source?: string;
|
|
54
|
+
templateWarnings?: string[];
|
|
55
|
+
tool: string;
|
|
56
|
+
validated?: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface RegisterToolResult {
|
|
60
|
+
content: Array<{ type: "text"; text: string }>;
|
|
61
|
+
details: RegisterToolResultDetails;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface RuntimeActivation {
|
|
65
|
+
active_tool: boolean;
|
|
66
|
+
activation: "current_session" | "unverified";
|
|
67
|
+
callable_now: boolean;
|
|
68
|
+
host_registered: boolean;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface RegisterToolRuntimeDeps<TContext> {
|
|
72
|
+
configPath: string;
|
|
73
|
+
recipeRoot?: string;
|
|
74
|
+
getToolNameBlocker: (name: string) => string | undefined;
|
|
75
|
+
getTools: () => Map<string, Config.RegisteredTool>;
|
|
76
|
+
getRecipeResolutionContext?: () => RecipesContext.RecipeResolutionContext | undefined;
|
|
77
|
+
getActiveTools: () => string[];
|
|
78
|
+
notify: (
|
|
79
|
+
ctx: TContext,
|
|
80
|
+
message: string,
|
|
81
|
+
type: "info" | "warning" | "error",
|
|
82
|
+
) => void;
|
|
83
|
+
registerRuntimeTool: (cfg: Config.RegisteredTool) => RuntimeActivation | void;
|
|
84
|
+
reservedToolNames: Set<string>;
|
|
85
|
+
setActiveTools: (toolNames: string[]) => void;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function textContent(text: string) {
|
|
89
|
+
return { type: "text" as const, text };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function listTools<TContext>(
|
|
93
|
+
deps: RegisterToolRuntimeDeps<TContext>,
|
|
94
|
+
): RegisterToolResult {
|
|
95
|
+
const names = [...deps.getTools().keys()].sort();
|
|
96
|
+
return {
|
|
97
|
+
content: [
|
|
98
|
+
textContent(
|
|
99
|
+
ExecutionOutput.formatToolText(
|
|
100
|
+
names.length > 0
|
|
101
|
+
? `Registered tools:\n${names.map((name) => `- ${name}`).join("\n")}`
|
|
102
|
+
: "No registered tools.",
|
|
103
|
+
),
|
|
104
|
+
),
|
|
105
|
+
],
|
|
106
|
+
details: { tool: "register_tool" },
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function getRecipeRoot<TContext>(
|
|
111
|
+
deps: RegisterToolRuntimeDeps<TContext>,
|
|
112
|
+
): string {
|
|
113
|
+
return deps.recipeRoot ?? Paths.getRecipeRoot(dirname(deps.configPath));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function getToolRecipePath<TContext>(
|
|
117
|
+
deps: RegisterToolRuntimeDeps<TContext>,
|
|
118
|
+
name: string,
|
|
119
|
+
): string {
|
|
120
|
+
return join(getRecipeRoot(deps), `${name}.json`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function activationBoundary(
|
|
124
|
+
activation: RuntimeActivation | undefined,
|
|
125
|
+
): string {
|
|
126
|
+
if (activation?.callable_now) return "current_session";
|
|
127
|
+
if (!activation) return "session_activation_unverified";
|
|
128
|
+
if (!activation.host_registered) return "host_registration";
|
|
129
|
+
if (!activation.active_tool) return "active_tool_set";
|
|
130
|
+
return "callability_verification";
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function recipeDoctorAction(source: string): string {
|
|
134
|
+
return /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(source)
|
|
135
|
+
? `inspect target=recipes view=doctor identity=${source}`
|
|
136
|
+
: "inspect target=recipes view=doctor";
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function registrationNextActions(
|
|
140
|
+
tool: string,
|
|
141
|
+
source: string,
|
|
142
|
+
callableNow: boolean,
|
|
143
|
+
): string[] {
|
|
144
|
+
if (callableNow) {
|
|
145
|
+
return [
|
|
146
|
+
`call tool ${tool}`,
|
|
147
|
+
`inspect target=tool:${tool} view=status`,
|
|
148
|
+
];
|
|
149
|
+
}
|
|
150
|
+
return [
|
|
151
|
+
`inspect target=tool:${tool} view=status`,
|
|
152
|
+
...(source === "template" || source === "draft"
|
|
153
|
+
? []
|
|
154
|
+
: [recipeDoctorAction(source)]),
|
|
155
|
+
];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function activeSkillSummary(
|
|
159
|
+
resolutionContext: RecipesContext.RecipeResolutionContext,
|
|
160
|
+
): string {
|
|
161
|
+
const names = Object.keys(
|
|
162
|
+
RecipesReferences.getActiveSkillRecipeNamespaces(
|
|
163
|
+
resolutionContext.activeSkills,
|
|
164
|
+
),
|
|
165
|
+
)
|
|
166
|
+
.sort()
|
|
167
|
+
.slice(0, 20);
|
|
168
|
+
return names.length > 0 ? names.join(", ") : "<none>";
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function assertDraftPath<TContext>(
|
|
172
|
+
deps: RegisterToolRuntimeDeps<TContext>,
|
|
173
|
+
draft: string,
|
|
174
|
+
): string {
|
|
175
|
+
const draftRoot = resolve(getRecipeRoot(deps), "drafts");
|
|
176
|
+
const path = resolve(draft);
|
|
177
|
+
const relation = relative(draftRoot, path);
|
|
178
|
+
if (
|
|
179
|
+
relation === "" ||
|
|
180
|
+
relation.startsWith("..") ||
|
|
181
|
+
resolve(relation) === relation
|
|
182
|
+
) {
|
|
183
|
+
throw new Error(
|
|
184
|
+
ExecutionOutput.formatToolText(
|
|
185
|
+
`Draft must be under ${draftRoot}. Use inspect target=recipes view=summary to list drafts.`,
|
|
186
|
+
),
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
if (!existsSync(path)) {
|
|
190
|
+
throw new Error(ExecutionOutput.formatToolText(`Draft not found: ${path}`));
|
|
191
|
+
}
|
|
192
|
+
return path;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function promoteDraftRecipe<TContext>(
|
|
196
|
+
name: string,
|
|
197
|
+
input: RegisterToolInput,
|
|
198
|
+
ctx: TContext,
|
|
199
|
+
deps: RegisterToolRuntimeDeps<TContext>,
|
|
200
|
+
): RegisterToolResult {
|
|
201
|
+
const draftPath = assertDraftPath(deps, String(input.draft ?? ""));
|
|
202
|
+
const targetPath = getToolRecipePath(deps, name);
|
|
203
|
+
const tools = deps.getTools();
|
|
204
|
+
const existing = tools.get(name);
|
|
205
|
+
const blocker = deps.getToolNameBlocker(name);
|
|
206
|
+
if (blocker) throw new Error(ExecutionOutput.formatToolText(blocker));
|
|
207
|
+
if ((existing || existsSync(targetPath)) && !input.update) {
|
|
208
|
+
throw new Error(
|
|
209
|
+
ExecutionOutput.formatToolText(
|
|
210
|
+
`Tool "${name}" already registered. Use update=true to overwrite.`,
|
|
211
|
+
),
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
const raw = RecipesReferences.readRawRecipeConfig(draftPath);
|
|
215
|
+
if (!raw) {
|
|
216
|
+
const reason = RecipesReferences.diagnoseRawRecipeConfigFailure(draftPath);
|
|
217
|
+
throw new Error(
|
|
218
|
+
ExecutionOutput.formatToolText(
|
|
219
|
+
`Draft recipe is invalid${reason ? `: ${reason}` : "."}`,
|
|
220
|
+
),
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
const authoredRecipe = buildAuthoredRecipe(
|
|
224
|
+
{
|
|
225
|
+
...input,
|
|
226
|
+
description:
|
|
227
|
+
input.description ??
|
|
228
|
+
(typeof raw.description === "string" ? raw.description : undefined),
|
|
229
|
+
},
|
|
230
|
+
existing,
|
|
231
|
+
raw,
|
|
232
|
+
);
|
|
233
|
+
const resolutionContext = getRegistrationResolutionContext(ctx, deps);
|
|
234
|
+
const candidate = RecipesDiscovery.admitUserRecipe(
|
|
235
|
+
targetPath,
|
|
236
|
+
resolutionContext,
|
|
237
|
+
authoredRecipe,
|
|
238
|
+
);
|
|
239
|
+
if (!candidate.validated || !candidate.tool) {
|
|
240
|
+
throw new Error(
|
|
241
|
+
ExecutionOutput.formatToolText(
|
|
242
|
+
`Draft recipe is invalid: ${candidate.diagnostics.join("; ")}`,
|
|
243
|
+
),
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
mkdirSync(dirname(targetPath), { recursive: true });
|
|
247
|
+
writeJsonAtomic(targetPath, authoredRecipe);
|
|
248
|
+
const promoted = RecipesDiscovery.admitUserRecipe(
|
|
249
|
+
targetPath,
|
|
250
|
+
resolutionContext,
|
|
251
|
+
).tool!;
|
|
252
|
+
tools.set(name, promoted);
|
|
253
|
+
const activation = deps.registerRuntimeTool(promoted) ?? undefined;
|
|
254
|
+
const argSummary = RecipesDiscovery.summarizeRegisteredToolArgs(promoted);
|
|
255
|
+
const callableNow = activation?.callable_now ?? false;
|
|
256
|
+
const nextActions = registrationNextActions(name, "draft", callableNow);
|
|
257
|
+
deps.notify(ctx, `Promoted draft recipe: ${name}`, "info");
|
|
258
|
+
return {
|
|
259
|
+
content: [
|
|
260
|
+
textContent(
|
|
261
|
+
ExecutionOutput.formatToolText(
|
|
262
|
+
`${existing ? "Updated" : "Registered"} tool "${name}" from draft; callable_now=${callableNow}; next=${nextActions[0]}.`,
|
|
263
|
+
),
|
|
264
|
+
),
|
|
265
|
+
],
|
|
266
|
+
details: {
|
|
267
|
+
active_tool: activation?.active_tool ?? false,
|
|
268
|
+
activation: activation?.activation ?? "unverified",
|
|
269
|
+
activation_boundary: activationBoundary(activation),
|
|
270
|
+
args: promoted.args,
|
|
271
|
+
callable_now: callableNow,
|
|
272
|
+
defaults: promoted.defaults,
|
|
273
|
+
host_registered: activation?.host_registered ?? false,
|
|
274
|
+
next_actions: nextActions,
|
|
275
|
+
optional_args: argSummary.optional,
|
|
276
|
+
persisted: true,
|
|
277
|
+
promoted: true,
|
|
278
|
+
registry_active: tools.get(name) === promoted,
|
|
279
|
+
required_args: argSummary.required,
|
|
280
|
+
resolved: true,
|
|
281
|
+
source: "draft",
|
|
282
|
+
tool: name,
|
|
283
|
+
validated: true,
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function persistToolRecipe<TContext>(
|
|
289
|
+
deps: RegisterToolRuntimeDeps<TContext>,
|
|
290
|
+
name: string,
|
|
291
|
+
recipe: Record<string, unknown>,
|
|
292
|
+
): string {
|
|
293
|
+
const path = getToolRecipePath(deps, name);
|
|
294
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
295
|
+
writeJsonAtomic(path, recipe);
|
|
296
|
+
return path;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function deleteTool<TContext>(
|
|
300
|
+
name: string,
|
|
301
|
+
ctx: TContext,
|
|
302
|
+
deps: RegisterToolRuntimeDeps<TContext>,
|
|
303
|
+
): RegisterToolResult {
|
|
304
|
+
const tools = deps.getTools();
|
|
305
|
+
if (!tools.has(name)) {
|
|
306
|
+
return {
|
|
307
|
+
content: [
|
|
308
|
+
textContent(
|
|
309
|
+
ExecutionOutput.formatToolText(`Tool "${name}" not found.`),
|
|
310
|
+
),
|
|
311
|
+
],
|
|
312
|
+
details: { tool: name },
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
const recipePath = getToolRecipePath(deps, name);
|
|
316
|
+
if (existsSync(recipePath)) unlinkSync(recipePath);
|
|
317
|
+
tools.delete(name);
|
|
318
|
+
deps.setActiveTools(
|
|
319
|
+
deps.getActiveTools().filter((toolName) => toolName !== name),
|
|
320
|
+
);
|
|
321
|
+
deps.notify(ctx, `Deleted tool: ${name}`, "info");
|
|
322
|
+
return {
|
|
323
|
+
content: [
|
|
324
|
+
textContent(
|
|
325
|
+
ExecutionOutput.formatToolText(
|
|
326
|
+
`Deleted tool "${name}". Reload to remove it from the complete registry.`,
|
|
327
|
+
),
|
|
328
|
+
),
|
|
329
|
+
],
|
|
330
|
+
details: { tool: name },
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function readAuthoritativeStoredTool<TContext>(
|
|
335
|
+
deps: RegisterToolRuntimeDeps<TContext>,
|
|
336
|
+
name: string,
|
|
337
|
+
): {
|
|
338
|
+
bytes?: string;
|
|
339
|
+
exists: boolean;
|
|
340
|
+
recipe?: Record<string, unknown>;
|
|
341
|
+
tool?: Config.RegisteredTool;
|
|
342
|
+
} {
|
|
343
|
+
const path = getToolRecipePath(deps, name);
|
|
344
|
+
if (!existsSync(path)) return { exists: false };
|
|
345
|
+
try {
|
|
346
|
+
const bytes = readFileSync(path, "utf8");
|
|
347
|
+
const recipe = JSON.parse(bytes);
|
|
348
|
+
const normalized = Config.normalizeStoredTool(
|
|
349
|
+
name,
|
|
350
|
+
recipe,
|
|
351
|
+
deps.reservedToolNames,
|
|
352
|
+
);
|
|
353
|
+
if (!normalized.cfg) return { bytes, exists: true, recipe };
|
|
354
|
+
return {
|
|
355
|
+
bytes,
|
|
356
|
+
exists: true,
|
|
357
|
+
recipe,
|
|
358
|
+
tool: { ...normalized.cfg, sourcePath: path },
|
|
359
|
+
};
|
|
360
|
+
} catch {
|
|
361
|
+
return { exists: true };
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function looksLikeRecipeReference(value: string): boolean {
|
|
366
|
+
const trimmed = value.trim();
|
|
367
|
+
return (
|
|
368
|
+
trimmed.endsWith(".json") ||
|
|
369
|
+
trimmed.endsWith(".md") ||
|
|
370
|
+
/^[^/:\\]+\/[^/:\\]+$/.test(trimmed)
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function assertTemplateIsNotNestedRecipe(value: unknown): void {
|
|
375
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
376
|
+
const record = value as Record<string, unknown>;
|
|
377
|
+
if (
|
|
378
|
+
typeof record.template === "string" &&
|
|
379
|
+
looksLikeRecipeReference(record.template) &&
|
|
380
|
+
(Object.keys(record).length === 1 ||
|
|
381
|
+
["artifacts", "async", "control", "description", "imports", "values"].some(
|
|
382
|
+
(key) => Object.hasOwn(record, key),
|
|
383
|
+
))
|
|
384
|
+
) {
|
|
385
|
+
throw new Error(
|
|
386
|
+
ExecutionOutput.formatToolText(
|
|
387
|
+
"Nested Recipe-shaped templates are not a register_tool source mode. Next: retry with from=<skill>/<recipe> and defaults={...}.",
|
|
388
|
+
),
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function getInputTemplate(
|
|
394
|
+
value: CommandTemplates.CommandTemplateValue | null | undefined,
|
|
395
|
+
): CommandTemplates.CommandTemplateValue | null | undefined {
|
|
396
|
+
assertTemplateIsNotNestedRecipe(value);
|
|
397
|
+
if (typeof value === "string") return value.trim();
|
|
398
|
+
if (value === null || value === undefined) return value;
|
|
399
|
+
if (Array.isArray(value)) {
|
|
400
|
+
const steps = CommandTemplates.expandCommandTemplateConfigs({
|
|
401
|
+
template: value,
|
|
402
|
+
});
|
|
403
|
+
if (steps.length === 0)
|
|
404
|
+
throw new Error(
|
|
405
|
+
ExecutionOutput.formatToolText("Tool template sequence is empty."),
|
|
406
|
+
);
|
|
407
|
+
return value;
|
|
408
|
+
}
|
|
409
|
+
if (value && typeof value === "object") {
|
|
410
|
+
CommandTemplates.expandCommandTemplateConfigs(
|
|
411
|
+
value as CommandTemplates.CommandTemplateConfig,
|
|
412
|
+
);
|
|
413
|
+
return value as CommandTemplates.CommandTemplateConfig;
|
|
414
|
+
}
|
|
415
|
+
throw new Error(
|
|
416
|
+
ExecutionOutput.formatToolText(
|
|
417
|
+
"Tool template must be a string, object, or sequence.",
|
|
418
|
+
),
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function getRegistrationResolutionContext<TContext>(
|
|
423
|
+
ctx: TContext,
|
|
424
|
+
deps: RegisterToolRuntimeDeps<TContext>,
|
|
425
|
+
): RecipesContext.RecipeResolutionContext {
|
|
426
|
+
const runtimeContext = deps.getRecipeResolutionContext?.();
|
|
427
|
+
if (runtimeContext) return runtimeContext;
|
|
428
|
+
if (ctx && typeof ctx === "object" && "recipeResolutionContext" in ctx) {
|
|
429
|
+
const resolutionContext = (ctx as {
|
|
430
|
+
recipeResolutionContext?: RecipesContext.RecipeResolutionContext;
|
|
431
|
+
}).recipeResolutionContext;
|
|
432
|
+
if (resolutionContext) return resolutionContext;
|
|
433
|
+
}
|
|
434
|
+
return RecipesContext.createEmptyRecipeResolutionContext(
|
|
435
|
+
"offline-register-tool",
|
|
436
|
+
getRecipeRoot(deps),
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function normalizeDefaults(value: unknown): Record<string, unknown> | undefined {
|
|
441
|
+
if (value === undefined) return undefined;
|
|
442
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
443
|
+
throw new Error(
|
|
444
|
+
ExecutionOutput.formatToolText("Tool defaults must be an object."),
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
return { ...(value as Record<string, unknown>) };
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function normalizeFromReference(
|
|
451
|
+
value: string,
|
|
452
|
+
resolutionContext: RecipesContext.RecipeResolutionContext,
|
|
453
|
+
): string {
|
|
454
|
+
const trimmed = value.trim();
|
|
455
|
+
if (!trimmed) {
|
|
456
|
+
throw new Error(
|
|
457
|
+
ExecutionOutput.formatToolText(
|
|
458
|
+
"Tool from must be a non-empty Recipe reference. Next: retry register_tool with from=<skill>/<recipe> or an explicit .json/.md path.",
|
|
459
|
+
),
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
if (trimmed.startsWith("std:")) {
|
|
463
|
+
throw new Error(
|
|
464
|
+
ExecutionOutput.formatToolText(
|
|
465
|
+
"std: Recipe references were removed; use <skill>/<recipe> or an explicit .json/.md file path.",
|
|
466
|
+
),
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
if (trimmed.startsWith("skill:")) {
|
|
470
|
+
throw new Error(
|
|
471
|
+
ExecutionOutput.formatToolText(
|
|
472
|
+
`skill: Recipe references were removed; use ${trimmed.slice("skill:".length)} without a prefix.`,
|
|
473
|
+
),
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
if (trimmed.endsWith(".json") || trimmed.endsWith(".md")) {
|
|
477
|
+
return resolve(resolutionContext.cwd, trimmed);
|
|
478
|
+
}
|
|
479
|
+
if (!looksLikeRecipeReference(trimmed)) {
|
|
480
|
+
throw new Error(
|
|
481
|
+
ExecutionOutput.formatToolText(
|
|
482
|
+
"Tool from must use <skill>/<recipe> or an explicit .json/.md file path.",
|
|
483
|
+
),
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
return trimmed;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function buildAuthoredRecipe(
|
|
490
|
+
input: RegisterToolInput,
|
|
491
|
+
existing: Config.RegisteredTool | undefined,
|
|
492
|
+
existingRecipe: Record<string, unknown> | undefined,
|
|
493
|
+
): Record<string, unknown> {
|
|
494
|
+
const explicitArgs =
|
|
495
|
+
input.args === undefined
|
|
496
|
+
? undefined
|
|
497
|
+
: Schema.parseToolArgDeclarations(input.args);
|
|
498
|
+
if (explicitArgs?.error)
|
|
499
|
+
throw new Error(ExecutionOutput.formatToolText(explicitArgs.error));
|
|
500
|
+
const from = typeof input.from === "string" ? input.from.trim() : "";
|
|
501
|
+
const description = (input.description ?? existing?.description ?? "").trim();
|
|
502
|
+
if (!description && !from) {
|
|
503
|
+
throw new Error(
|
|
504
|
+
ExecutionOutput.formatToolText(
|
|
505
|
+
"Tool description is required for command-template registration.",
|
|
506
|
+
),
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
const inputDefaults = normalizeDefaults(input.defaults);
|
|
510
|
+
if (from) {
|
|
511
|
+
const runtimeOwnedDefault = Object.keys(inputDefaults ?? {}).find((key) =>
|
|
512
|
+
RecipesReferences.isRuntimeOwnedRecipeInput(key),
|
|
513
|
+
);
|
|
514
|
+
if (runtimeOwnedDefault) {
|
|
515
|
+
throw new Error(
|
|
516
|
+
ExecutionOutput.formatToolText(
|
|
517
|
+
`Tool defaults cannot set runtime-owned input: ${runtimeOwnedDefault}. Next: remove that default and retry register_tool; the runtime supplies it.`,
|
|
518
|
+
),
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
const authored: Record<string, unknown> = {
|
|
522
|
+
...(description ? { description } : {}),
|
|
523
|
+
template: from,
|
|
524
|
+
};
|
|
525
|
+
const retainedDefaults =
|
|
526
|
+
inputDefaults ??
|
|
527
|
+
(existingRecipe?.defaults && typeof existingRecipe.defaults === "object"
|
|
528
|
+
? (existingRecipe.defaults as Record<string, unknown>)
|
|
529
|
+
: undefined);
|
|
530
|
+
if (retainedDefaults && Object.keys(retainedDefaults).length > 0)
|
|
531
|
+
authored.defaults = retainedDefaults;
|
|
532
|
+
return authored;
|
|
533
|
+
}
|
|
534
|
+
const template = getInputTemplate(input.template);
|
|
535
|
+
if (template === null) {
|
|
536
|
+
throw new Error(
|
|
537
|
+
ExecutionOutput.formatToolText("Tool template cannot be null here."),
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
const finalTemplate =
|
|
541
|
+
template === undefined || template === ""
|
|
542
|
+
? existingRecipe?.template ?? existing?.template
|
|
543
|
+
: template;
|
|
544
|
+
if (!finalTemplate) {
|
|
545
|
+
throw new Error(
|
|
546
|
+
ExecutionOutput.formatToolText("Tool template is required."),
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
const authored: Record<string, unknown> = {
|
|
550
|
+
...(existingRecipe ?? {}),
|
|
551
|
+
description,
|
|
552
|
+
template: finalTemplate,
|
|
553
|
+
};
|
|
554
|
+
if (typeof input.async === "boolean") authored.async = input.async;
|
|
555
|
+
if (explicitArgs) {
|
|
556
|
+
authored.args = explicitArgs.declarations;
|
|
557
|
+
const defaults = { ...explicitArgs.defaults, ...(inputDefaults ?? {}) };
|
|
558
|
+
if (Object.keys(defaults).length > 0) authored.defaults = defaults;
|
|
559
|
+
else delete authored.defaults;
|
|
560
|
+
} else if (inputDefaults !== undefined) {
|
|
561
|
+
if (Object.keys(inputDefaults).length > 0) authored.defaults = inputDefaults;
|
|
562
|
+
else delete authored.defaults;
|
|
563
|
+
}
|
|
564
|
+
return authored;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
function assertRegisterToolInputModes(input: RegisterToolInput): void {
|
|
568
|
+
const record = input as RegisterToolInput & Record<string, unknown>;
|
|
569
|
+
if (Object.hasOwn(record, "values")) {
|
|
570
|
+
throw new Error(
|
|
571
|
+
ExecutionOutput.formatToolText(
|
|
572
|
+
"register_tool values was removed. Next: retry register_tool with defaults for caller inputs, or use from=<skill>/<recipe> for maintained composition.",
|
|
573
|
+
),
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
const fromProvided = Object.hasOwn(record, "from");
|
|
577
|
+
if (
|
|
578
|
+
fromProvided &&
|
|
579
|
+
(typeof input.from !== "string" || input.from.trim().length === 0)
|
|
580
|
+
) {
|
|
581
|
+
throw new Error(
|
|
582
|
+
ExecutionOutput.formatToolText(
|
|
583
|
+
"Tool from must be a non-empty Recipe reference. Next: retry register_tool with from=<skill>/<recipe> or an explicit .json/.md path.",
|
|
584
|
+
),
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
const draftProvided =
|
|
588
|
+
typeof input.draft === "string" && input.draft.trim().length > 0;
|
|
589
|
+
const templateProvided = Object.hasOwn(record, "template");
|
|
590
|
+
const modeCount =
|
|
591
|
+
Number(fromProvided) + Number(draftProvided) + Number(templateProvided);
|
|
592
|
+
if (modeCount > 1) {
|
|
593
|
+
throw new Error(
|
|
594
|
+
ExecutionOutput.formatToolText(
|
|
595
|
+
"Use exactly one register_tool source mode: from, template, or draft. Next: remove the extra source fields and retry register_tool.",
|
|
596
|
+
),
|
|
597
|
+
);
|
|
598
|
+
}
|
|
599
|
+
if (
|
|
600
|
+
fromProvided &&
|
|
601
|
+
(Object.hasOwn(record, "args") || Object.hasOwn(record, "async"))
|
|
602
|
+
) {
|
|
603
|
+
throw new Error(
|
|
604
|
+
ExecutionOutput.formatToolText(
|
|
605
|
+
"register_tool from inherits args and async behavior. Next: retry register_tool with from and optional defaults only; omit args and async.",
|
|
606
|
+
),
|
|
607
|
+
);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
function executeRegisterToolUnlocked<TContext>(
|
|
612
|
+
params: unknown,
|
|
613
|
+
ctx: TContext,
|
|
614
|
+
deps: RegisterToolRuntimeDeps<TContext>,
|
|
615
|
+
): RegisterToolResult {
|
|
616
|
+
const rawInput =
|
|
617
|
+
params && typeof params === "object"
|
|
618
|
+
? (params as RegisterToolInput)
|
|
619
|
+
: ({} as RegisterToolInput);
|
|
620
|
+
assertRegisterToolInputModes(rawInput);
|
|
621
|
+
let input = rawInput;
|
|
622
|
+
if (!input.name) return listTools(deps);
|
|
623
|
+
const name = Identity.normalizeToolName(input.name);
|
|
624
|
+
if (!name)
|
|
625
|
+
throw new Error(ExecutionOutput.formatToolText("Invalid tool name."));
|
|
626
|
+
if (deps.reservedToolNames.has(name)) {
|
|
627
|
+
throw new Error(
|
|
628
|
+
ExecutionOutput.formatToolText(`Reserved tool name: ${name}`),
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
if (typeof input.draft === "string" && input.draft.trim()) {
|
|
632
|
+
return promoteDraftRecipe(name, input, ctx, deps);
|
|
633
|
+
}
|
|
634
|
+
const resolutionContext = getRegistrationResolutionContext(ctx, deps);
|
|
635
|
+
const requestedSource =
|
|
636
|
+
typeof rawInput.from === "string" ? rawInput.from.trim() : undefined;
|
|
637
|
+
if (typeof input.from === "string") {
|
|
638
|
+
try {
|
|
639
|
+
input = {
|
|
640
|
+
...input,
|
|
641
|
+
from: normalizeFromReference(input.from, resolutionContext),
|
|
642
|
+
};
|
|
643
|
+
} catch (error) {
|
|
644
|
+
const reason = error instanceof Error ? error.message.trim() : String(error);
|
|
645
|
+
const diagnosticSource = requestedSource?.startsWith("skill:")
|
|
646
|
+
? requestedSource.slice("skill:".length)
|
|
647
|
+
: requestedSource ?? "";
|
|
648
|
+
throw new Error(
|
|
649
|
+
ExecutionOutput.formatToolText(
|
|
650
|
+
`Recipe source "${requestedSource}" is invalid: ${reason}. Active Skills: ${activeSkillSummary(resolutionContext)}. Next: ${recipeDoctorAction(diagnosticSource)}`,
|
|
651
|
+
),
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
const templateProvided = Object.hasOwn(input, "template");
|
|
656
|
+
const template = getInputTemplate(input.template);
|
|
657
|
+
if (templateProvided && (template === null || template === ""))
|
|
658
|
+
return deleteTool(name, ctx, deps);
|
|
659
|
+
const tools = deps.getTools();
|
|
660
|
+
const authoritative = readAuthoritativeStoredTool(deps, name);
|
|
661
|
+
const existing = authoritative.tool ?? tools.get(name);
|
|
662
|
+
const blocker = deps.getToolNameBlocker(name);
|
|
663
|
+
if (blocker) throw new Error(ExecutionOutput.formatToolText(blocker));
|
|
664
|
+
if ((authoritative.exists || existing) && !input.update) {
|
|
665
|
+
throw new Error(
|
|
666
|
+
ExecutionOutput.formatToolText(
|
|
667
|
+
`Tool "${name}" already registered. Use update=true to overwrite.`,
|
|
668
|
+
),
|
|
669
|
+
);
|
|
670
|
+
}
|
|
671
|
+
if (template === undefined && !input.from && !existing) {
|
|
672
|
+
throw new Error(
|
|
673
|
+
ExecutionOutput.formatToolText(
|
|
674
|
+
"New registration requires exactly one source mode: from, template, or draft. Next: retry register_tool with one source field.",
|
|
675
|
+
),
|
|
676
|
+
);
|
|
677
|
+
}
|
|
678
|
+
const recipePath = getToolRecipePath(deps, name);
|
|
679
|
+
const authoredRecipe = buildAuthoredRecipe(
|
|
680
|
+
input,
|
|
681
|
+
existing,
|
|
682
|
+
authoritative.recipe,
|
|
683
|
+
);
|
|
684
|
+
const candidate = RecipesDiscovery.admitUserRecipe(
|
|
685
|
+
recipePath,
|
|
686
|
+
resolutionContext,
|
|
687
|
+
authoredRecipe,
|
|
688
|
+
);
|
|
689
|
+
if (!candidate.validated || !candidate.tool) {
|
|
690
|
+
const sourceDiagnostic = requestedSource
|
|
691
|
+
? `Recipe source "${requestedSource}" validation failed: ${candidate.diagnostics.join("; ")}. Active Skills: ${activeSkillSummary(resolutionContext)}. Next: ${recipeDoctorAction(requestedSource)}`
|
|
692
|
+
: `Tool recipe validation failed: ${candidate.diagnostics.join("; ")}`;
|
|
693
|
+
throw new Error(ExecutionOutput.formatToolText(sourceDiagnostic));
|
|
694
|
+
}
|
|
695
|
+
const activeBefore = deps.getActiveTools();
|
|
696
|
+
let persisted = false;
|
|
697
|
+
let activation: RuntimeActivation | undefined;
|
|
698
|
+
let cfg: Config.RegisteredTool;
|
|
699
|
+
let transactionStage = "persist";
|
|
700
|
+
try {
|
|
701
|
+
persistToolRecipe(deps, name, authoredRecipe);
|
|
702
|
+
persisted = true;
|
|
703
|
+
transactionStage = "persisted_admission";
|
|
704
|
+
const admitted = RecipesDiscovery.admitUserRecipe(
|
|
705
|
+
recipePath,
|
|
706
|
+
resolutionContext,
|
|
707
|
+
);
|
|
708
|
+
if (!admitted.validated || !admitted.tool) {
|
|
709
|
+
throw new Error(
|
|
710
|
+
`Persisted tool recipe admission failed: ${admitted.diagnostics.join("; ")}`,
|
|
711
|
+
);
|
|
712
|
+
}
|
|
713
|
+
cfg = admitted.tool;
|
|
714
|
+
tools.set(name, cfg);
|
|
715
|
+
transactionStage = "runtime_activation";
|
|
716
|
+
activation = deps.registerRuntimeTool(cfg) ?? undefined;
|
|
717
|
+
if (
|
|
718
|
+
activation &&
|
|
719
|
+
(!activation.host_registered ||
|
|
720
|
+
!activation.active_tool ||
|
|
721
|
+
!activation.callable_now)
|
|
722
|
+
) {
|
|
723
|
+
throw new Error(
|
|
724
|
+
`Tool "${name}" activation failed at ${activationBoundary(activation)}; host_registered=${activation.host_registered}, active_tool=${activation.active_tool}, callable_now=${activation.callable_now}. Registration was rolled back. Next: inspect target=runtime view=status; do not use spawn as proof of tool invocation.`,
|
|
725
|
+
);
|
|
726
|
+
}
|
|
727
|
+
} catch (error) {
|
|
728
|
+
if (persisted) {
|
|
729
|
+
if (authoritative.bytes !== undefined)
|
|
730
|
+
writeTextAtomic(recipePath, authoritative.bytes);
|
|
731
|
+
else if (existsSync(recipePath)) unlinkSync(recipePath);
|
|
732
|
+
}
|
|
733
|
+
if (existing) {
|
|
734
|
+
tools.set(name, existing);
|
|
735
|
+
deps.registerRuntimeTool(existing);
|
|
736
|
+
} else {
|
|
737
|
+
tools.delete(name);
|
|
738
|
+
}
|
|
739
|
+
deps.setActiveTools(activeBefore);
|
|
740
|
+
throw new Error(
|
|
741
|
+
ExecutionOutput.formatToolText(
|
|
742
|
+
`Tool registration transaction failed at ${transactionStage} (${resolutionContext.generation}; active Skills: ${activeSkillSummary(resolutionContext)}): ${error instanceof Error ? error.message : String(error)}`,
|
|
743
|
+
),
|
|
744
|
+
);
|
|
745
|
+
}
|
|
746
|
+
deps.notify(ctx, `Tool activated: ${name}`, "info");
|
|
747
|
+
const templateWarnings = CommandTemplates.getCommandTemplateWarnings(
|
|
748
|
+
typeof cfg.recipe?.template === "object" && !Array.isArray(cfg.recipe.template)
|
|
749
|
+
? cfg.recipe.template
|
|
750
|
+
: { template: cfg.recipe?.template ?? cfg.template! },
|
|
751
|
+
);
|
|
752
|
+
const warningText =
|
|
753
|
+
templateWarnings.length > 0
|
|
754
|
+
? `\nWarnings:\n${templateWarnings.map((warning) => `- ${warning}`).join("\n")}`
|
|
755
|
+
: "";
|
|
756
|
+
const callableNow = activation?.callable_now ?? false;
|
|
757
|
+
const source = requestedSource ?? "template";
|
|
758
|
+
const argSummary = RecipesDiscovery.summarizeRegisteredToolArgs(cfg);
|
|
759
|
+
const nextActions = registrationNextActions(name, source, callableNow);
|
|
760
|
+
const outcomeText = callableNow
|
|
761
|
+
? `${existing ? "Updated" : "Registered"} tool "${name}" from ${source}; callable_now=true`
|
|
762
|
+
: `Persisted tool "${name}" from ${source}; callable_now=false; activation_boundary=${activationBoundary(activation)}`;
|
|
763
|
+
return {
|
|
764
|
+
content: [
|
|
765
|
+
textContent(
|
|
766
|
+
ExecutionOutput.formatToolText(
|
|
767
|
+
`${outcomeText}; required=${Schema.formatToolArgs(argSummary.required)}; optional=${Schema.formatToolArgs(argSummary.optional)}; next=${nextActions[0]}.${warningText}`,
|
|
768
|
+
),
|
|
769
|
+
),
|
|
770
|
+
],
|
|
771
|
+
details: {
|
|
772
|
+
active_tool: activation?.active_tool ?? false,
|
|
773
|
+
activation: activation?.activation ?? "unverified",
|
|
774
|
+
activation_boundary: activationBoundary(activation),
|
|
775
|
+
args: cfg.args,
|
|
776
|
+
callable_now: callableNow,
|
|
777
|
+
defaults: cfg.defaults,
|
|
778
|
+
host_registered: activation?.host_registered ?? false,
|
|
779
|
+
next_actions: nextActions,
|
|
780
|
+
optional_args: argSummary.optional,
|
|
781
|
+
persisted: true,
|
|
782
|
+
registry_active: tools.get(name) === cfg,
|
|
783
|
+
required_args: argSummary.required,
|
|
784
|
+
resolved: true,
|
|
785
|
+
source,
|
|
786
|
+
...(cfg.recipe?.async !== undefined ? { async: cfg.recipe.async } : {}),
|
|
787
|
+
...(templateWarnings.length > 0 ? { templateWarnings } : {}),
|
|
788
|
+
tool: name,
|
|
789
|
+
validated: true,
|
|
790
|
+
},
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
export async function executeRegisterTool<TContext>(
|
|
795
|
+
params: unknown,
|
|
796
|
+
ctx: TContext,
|
|
797
|
+
deps: RegisterToolRuntimeDeps<TContext>,
|
|
798
|
+
): Promise<RegisterToolResult> {
|
|
799
|
+
const input = params as RegisterToolInput;
|
|
800
|
+
if (!input.name) return executeRegisterToolUnlocked(params, ctx, deps);
|
|
801
|
+
const name = Identity.normalizeToolName(input.name);
|
|
802
|
+
if (!name) return executeRegisterToolUnlocked(params, ctx, deps);
|
|
803
|
+
return withFileMutationLock(getToolRecipePath(deps, name), () =>
|
|
804
|
+
executeRegisterToolUnlocked(params, ctx, deps),
|
|
805
|
+
);
|
|
806
|
+
}
|