@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,710 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram Extension Sections registry and callback routing
|
|
3
|
+
* Zones: telegram ui, extension platform, callback routing
|
|
4
|
+
* Owns section registration, global registry binding, token mapping, main-menu/settings row injection, and section callback dispatch
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
assertTelegramCallbackData,
|
|
9
|
+
type TelegramInlineKeyboardMarkup,
|
|
10
|
+
} from "./keyboard.ts";
|
|
11
|
+
|
|
12
|
+
const SECTION_REGISTRY_KEY = "__piTelegramSectionRegistry__";
|
|
13
|
+
|
|
14
|
+
// --- Core Types ---
|
|
15
|
+
|
|
16
|
+
/** @internal */
|
|
17
|
+
export type TelegramSectionId = string;
|
|
18
|
+
|
|
19
|
+
/** @internal */
|
|
20
|
+
export type TelegramSectionToken = string;
|
|
21
|
+
|
|
22
|
+
/** @internal */
|
|
23
|
+
export type TelegramSectionCallbackResult = "handled" | "pass";
|
|
24
|
+
|
|
25
|
+
export interface TelegramSectionView {
|
|
26
|
+
text: string;
|
|
27
|
+
/**
|
|
28
|
+
* Source format for extension-provided section content.
|
|
29
|
+
* Defaults to "html" for explicit Telegram UI markup; use "markdown"
|
|
30
|
+
* when a section naturally owns Markdown content, or "plain" for text.
|
|
31
|
+
*/
|
|
32
|
+
parseMode?: "markdown" | "html" | "plain";
|
|
33
|
+
replyMarkup?: TelegramInlineKeyboardMarkup;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface TelegramSectionSettingsRegistration {
|
|
37
|
+
label: string;
|
|
38
|
+
order?: number;
|
|
39
|
+
getLabel?: () => string;
|
|
40
|
+
open: (
|
|
41
|
+
ctx: TelegramSectionContext,
|
|
42
|
+
) => TelegramSectionView | Promise<TelegramSectionView>;
|
|
43
|
+
handleCallback?: (
|
|
44
|
+
ctx: TelegramSectionCallbackContext,
|
|
45
|
+
) => TelegramSectionCallbackResult | Promise<TelegramSectionCallbackResult>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface TelegramSectionRegistration {
|
|
49
|
+
id: TelegramSectionId;
|
|
50
|
+
label: string;
|
|
51
|
+
order?: number;
|
|
52
|
+
getLabel?: () => string;
|
|
53
|
+
render: (
|
|
54
|
+
ctx: TelegramSectionContext,
|
|
55
|
+
) => TelegramSectionView | Promise<TelegramSectionView>;
|
|
56
|
+
handleCallback?: (
|
|
57
|
+
ctx: TelegramSectionCallbackContext,
|
|
58
|
+
) => TelegramSectionCallbackResult | Promise<TelegramSectionCallbackResult>;
|
|
59
|
+
settings?: TelegramSectionSettingsRegistration;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface TelegramSectionContext {
|
|
63
|
+
sectionId: string;
|
|
64
|
+
chatId: number;
|
|
65
|
+
messageId?: number;
|
|
66
|
+
answerCallback(text?: string): Promise<void>;
|
|
67
|
+
edit(view: TelegramSectionView): Promise<void>;
|
|
68
|
+
open(view: TelegramSectionView): Promise<void>;
|
|
69
|
+
enqueuePrompt(prompt: string): Promise<void>;
|
|
70
|
+
callbackData(action: string, payload?: string): string;
|
|
71
|
+
/** Delete the message that triggered this callback (dialog cleanup) */
|
|
72
|
+
deleteMessage(): Promise<void>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface TelegramSectionCallbackContext {
|
|
76
|
+
sectionId: string;
|
|
77
|
+
chatId: number;
|
|
78
|
+
messageId?: number;
|
|
79
|
+
action: string;
|
|
80
|
+
payload: string;
|
|
81
|
+
answerCallback(text?: string): Promise<void>;
|
|
82
|
+
edit(view: TelegramSectionView): Promise<void>;
|
|
83
|
+
open(view: TelegramSectionView): Promise<void>;
|
|
84
|
+
enqueuePrompt(prompt: string): Promise<void>;
|
|
85
|
+
callbackData(action: string, payload?: string): string;
|
|
86
|
+
/** Delete the message that triggered this callback (dialog cleanup) */
|
|
87
|
+
deleteMessage(): Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** @internal */
|
|
91
|
+
export interface RegisteredTelegramSection {
|
|
92
|
+
id: TelegramSectionId;
|
|
93
|
+
token: TelegramSectionToken;
|
|
94
|
+
label: string;
|
|
95
|
+
order: number;
|
|
96
|
+
registration: TelegramSectionRegistration;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** @internal */
|
|
100
|
+
export interface TelegramSectionDiagnostic {
|
|
101
|
+
id: TelegramSectionId;
|
|
102
|
+
token: TelegramSectionToken;
|
|
103
|
+
label: string;
|
|
104
|
+
status: "active" | "error";
|
|
105
|
+
lastError?: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** @internal */
|
|
109
|
+
export interface TelegramSectionRegistry {
|
|
110
|
+
register(section: TelegramSectionRegistration): () => void;
|
|
111
|
+
getSections(): RegisteredTelegramSection[];
|
|
112
|
+
getByToken(
|
|
113
|
+
token: TelegramSectionToken,
|
|
114
|
+
): RegisteredTelegramSection | undefined;
|
|
115
|
+
getDiagnostics(): TelegramSectionDiagnostic[];
|
|
116
|
+
recordError(
|
|
117
|
+
token: TelegramSectionToken,
|
|
118
|
+
message: string,
|
|
119
|
+
source?: string,
|
|
120
|
+
): void;
|
|
121
|
+
clearError(token: TelegramSectionToken, source?: string): void;
|
|
122
|
+
clear(): void;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** @internal */
|
|
126
|
+
export interface TelegramSectionMainMenuRow {
|
|
127
|
+
text: string;
|
|
128
|
+
callback_data: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** @internal */
|
|
132
|
+
export interface TelegramSectionSettingsRow {
|
|
133
|
+
label: string;
|
|
134
|
+
callback_data: string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// --- Runtime Port Builders ---
|
|
138
|
+
|
|
139
|
+
/** @internal */
|
|
140
|
+
export interface TelegramSectionTarget {
|
|
141
|
+
chatId: number;
|
|
142
|
+
threadId?: number;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** @internal */
|
|
146
|
+
export interface TelegramSectionRuntimeDeps {
|
|
147
|
+
answerCallbackQuery: (id: string, text?: string) => Promise<void>;
|
|
148
|
+
target?: TelegramSectionTarget;
|
|
149
|
+
editInteractiveMessage: (
|
|
150
|
+
chatId: number,
|
|
151
|
+
messageId: number,
|
|
152
|
+
text: string,
|
|
153
|
+
mode: "markdown" | "html" | "plain",
|
|
154
|
+
replyMarkup: TelegramInlineKeyboardMarkup,
|
|
155
|
+
) => Promise<void>;
|
|
156
|
+
sendInteractiveMessage: (
|
|
157
|
+
chatId: number,
|
|
158
|
+
text: string,
|
|
159
|
+
mode: "markdown" | "html" | "plain",
|
|
160
|
+
replyMarkup: TelegramInlineKeyboardMarkup,
|
|
161
|
+
options?: { target?: TelegramSectionTarget },
|
|
162
|
+
) => Promise<number | undefined>;
|
|
163
|
+
enqueuePrompt: (prompt: string) => Promise<void>;
|
|
164
|
+
deleteMessage: (chatId: number, messageId: number) => Promise<void>;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function buildTelegramSectionContext(
|
|
168
|
+
sectionId: string,
|
|
169
|
+
token: TelegramSectionToken,
|
|
170
|
+
chatId: number,
|
|
171
|
+
messageId: number | undefined,
|
|
172
|
+
callbackQueryId: string | undefined,
|
|
173
|
+
deps: TelegramSectionRuntimeDeps,
|
|
174
|
+
backCallback = "menu:back",
|
|
175
|
+
backLabel = "⬆️ Main menu",
|
|
176
|
+
): TelegramSectionContext {
|
|
177
|
+
return {
|
|
178
|
+
sectionId,
|
|
179
|
+
chatId,
|
|
180
|
+
messageId,
|
|
181
|
+
answerCallback: (text) =>
|
|
182
|
+
callbackQueryId
|
|
183
|
+
? deps.answerCallbackQuery(callbackQueryId, text)
|
|
184
|
+
: Promise.resolve(),
|
|
185
|
+
edit: (view) =>
|
|
186
|
+
messageId !== undefined
|
|
187
|
+
? deps.editInteractiveMessage(
|
|
188
|
+
chatId,
|
|
189
|
+
messageId,
|
|
190
|
+
view.text,
|
|
191
|
+
view.parseMode ?? "html",
|
|
192
|
+
prependBackRow(view.replyMarkup, backCallback, backLabel),
|
|
193
|
+
)
|
|
194
|
+
: Promise.resolve(),
|
|
195
|
+
open: (view) =>
|
|
196
|
+
deps
|
|
197
|
+
.sendInteractiveMessage(
|
|
198
|
+
chatId,
|
|
199
|
+
view.text,
|
|
200
|
+
view.parseMode ?? "html",
|
|
201
|
+
view.replyMarkup ?? { inline_keyboard: [] },
|
|
202
|
+
deps.target ? { target: deps.target } : undefined,
|
|
203
|
+
)
|
|
204
|
+
.then(() => {}),
|
|
205
|
+
enqueuePrompt: deps.enqueuePrompt,
|
|
206
|
+
callbackData: (action, payload) =>
|
|
207
|
+
buildTelegramSectionCallbackData(token, action, payload),
|
|
208
|
+
deleteMessage: () =>
|
|
209
|
+
messageId !== undefined
|
|
210
|
+
? deps.deleteMessage(chatId, messageId)
|
|
211
|
+
: Promise.resolve(),
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function buildTelegramSectionCallbackContext(
|
|
216
|
+
sectionId: string,
|
|
217
|
+
token: TelegramSectionToken,
|
|
218
|
+
chatId: number,
|
|
219
|
+
messageId: number | undefined,
|
|
220
|
+
action: string,
|
|
221
|
+
payload: string,
|
|
222
|
+
callbackQueryId: string,
|
|
223
|
+
deps: TelegramSectionRuntimeDeps,
|
|
224
|
+
backCallback = "menu:back",
|
|
225
|
+
backLabel = "⬆️ Back",
|
|
226
|
+
): TelegramSectionCallbackContext {
|
|
227
|
+
return {
|
|
228
|
+
sectionId,
|
|
229
|
+
chatId,
|
|
230
|
+
messageId,
|
|
231
|
+
action,
|
|
232
|
+
payload,
|
|
233
|
+
answerCallback: (text) => deps.answerCallbackQuery(callbackQueryId, text),
|
|
234
|
+
edit: (view) =>
|
|
235
|
+
messageId !== undefined
|
|
236
|
+
? deps.editInteractiveMessage(
|
|
237
|
+
chatId,
|
|
238
|
+
messageId,
|
|
239
|
+
view.text,
|
|
240
|
+
view.parseMode ?? "html",
|
|
241
|
+
prependBackRow(view.replyMarkup, backCallback, backLabel),
|
|
242
|
+
)
|
|
243
|
+
: Promise.resolve(),
|
|
244
|
+
open: (view) =>
|
|
245
|
+
deps
|
|
246
|
+
.sendInteractiveMessage(
|
|
247
|
+
chatId,
|
|
248
|
+
view.text,
|
|
249
|
+
view.parseMode ?? "html",
|
|
250
|
+
view.replyMarkup ?? { inline_keyboard: [] },
|
|
251
|
+
deps.target ? { target: deps.target } : undefined,
|
|
252
|
+
)
|
|
253
|
+
.then(() => {}),
|
|
254
|
+
enqueuePrompt: deps.enqueuePrompt,
|
|
255
|
+
callbackData: (action, payload) =>
|
|
256
|
+
buildTelegramSectionCallbackData(token, action, payload),
|
|
257
|
+
deleteMessage: () =>
|
|
258
|
+
messageId !== undefined
|
|
259
|
+
? deps.deleteMessage(chatId, messageId)
|
|
260
|
+
: Promise.resolve(),
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// --- GlobalThis Bridge ---
|
|
265
|
+
|
|
266
|
+
/** @internal */
|
|
267
|
+
export function setGlobalTelegramSectionRegistry(
|
|
268
|
+
registry: TelegramSectionRegistry,
|
|
269
|
+
): void {
|
|
270
|
+
(globalThis as Record<string, unknown>)[SECTION_REGISTRY_KEY] = registry;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** @internal */
|
|
274
|
+
export function createAndBindTelegramSectionRegistry(): TelegramSectionRegistry {
|
|
275
|
+
const registry = createTelegramExtensionSectionRegistry();
|
|
276
|
+
setGlobalTelegramSectionRegistry(registry);
|
|
277
|
+
return registry;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Register a Telegram Extension Section from any pi extension.
|
|
282
|
+
* Returns a disposer. Throws if no section registry is active.
|
|
283
|
+
*/
|
|
284
|
+
export function registerTelegramSection(
|
|
285
|
+
section: TelegramSectionRegistration,
|
|
286
|
+
): () => void {
|
|
287
|
+
const registry = (globalThis as Record<string, unknown>)[
|
|
288
|
+
SECTION_REGISTRY_KEY
|
|
289
|
+
] as TelegramSectionRegistry | undefined;
|
|
290
|
+
if (!registry) {
|
|
291
|
+
throw new Error(
|
|
292
|
+
"Telegram section registry not available. Is pi-telegram loaded and initialized?",
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
return registry.register(section);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Get current section diagnostics. Returns empty array when registry is absent.
|
|
301
|
+
* @internal
|
|
302
|
+
*/
|
|
303
|
+
export function getTelegramSectionDiagnostics(): TelegramSectionDiagnostic[] {
|
|
304
|
+
const registry = (globalThis as Record<string, unknown>)[
|
|
305
|
+
SECTION_REGISTRY_KEY
|
|
306
|
+
] as TelegramSectionRegistry | undefined;
|
|
307
|
+
return registry ? registry.getDiagnostics() : [];
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// --- Registry ---
|
|
311
|
+
|
|
312
|
+
const BACK_NAV_ROW = {
|
|
313
|
+
text: "⬆️ Back",
|
|
314
|
+
} as const;
|
|
315
|
+
|
|
316
|
+
function sectionErrorMessage(error: unknown): string {
|
|
317
|
+
return error instanceof Error ? error.message : String(error);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function buildTelegramSectionCallbackData(
|
|
321
|
+
token: TelegramSectionToken,
|
|
322
|
+
action: string,
|
|
323
|
+
payload?: string,
|
|
324
|
+
): string {
|
|
325
|
+
const data = payload
|
|
326
|
+
? `section:${token}:${action}:${payload}`
|
|
327
|
+
: `section:${token}:${action}`;
|
|
328
|
+
return assertTelegramCallbackData(data, "Telegram section callback_data");
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function prependBackRow(
|
|
332
|
+
replyMarkup: TelegramInlineKeyboardMarkup | undefined,
|
|
333
|
+
backCallback: string,
|
|
334
|
+
backLabel?: string,
|
|
335
|
+
): TelegramInlineKeyboardMarkup {
|
|
336
|
+
const backRow = {
|
|
337
|
+
text: backLabel ?? BACK_NAV_ROW.text,
|
|
338
|
+
callback_data: backCallback,
|
|
339
|
+
};
|
|
340
|
+
if (!replyMarkup || replyMarkup.inline_keyboard.length === 0) {
|
|
341
|
+
return { inline_keyboard: [[backRow]] };
|
|
342
|
+
}
|
|
343
|
+
const firstRow = replyMarkup.inline_keyboard[0];
|
|
344
|
+
const firstIsBack =
|
|
345
|
+
firstRow.length === 1 && firstRow[0].callback_data === backCallback;
|
|
346
|
+
if (firstIsBack) return replyMarkup;
|
|
347
|
+
return {
|
|
348
|
+
inline_keyboard: [[backRow], ...replyMarkup.inline_keyboard],
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/** @internal */
|
|
353
|
+
export function createTelegramExtensionSectionRegistry(): TelegramSectionRegistry {
|
|
354
|
+
const sections = new Map<TelegramSectionToken, RegisteredTelegramSection>();
|
|
355
|
+
const errors = new Map<
|
|
356
|
+
TelegramSectionToken,
|
|
357
|
+
{ message: string; source: string }
|
|
358
|
+
>();
|
|
359
|
+
let nextToken = 0;
|
|
360
|
+
|
|
361
|
+
const register = (section: TelegramSectionRegistration): (() => void) => {
|
|
362
|
+
const duplicate = [...sections.values()].find((s) => s.id === section.id);
|
|
363
|
+
if (duplicate) {
|
|
364
|
+
throw new Error(`Telegram section id already registered: ${section.id}`);
|
|
365
|
+
}
|
|
366
|
+
const token = String(nextToken++);
|
|
367
|
+
const registered: RegisteredTelegramSection = {
|
|
368
|
+
id: section.id,
|
|
369
|
+
token,
|
|
370
|
+
label: section.label,
|
|
371
|
+
order: section.order ?? 0,
|
|
372
|
+
registration: section,
|
|
373
|
+
};
|
|
374
|
+
sections.set(token, registered);
|
|
375
|
+
return () => {
|
|
376
|
+
sections.delete(token);
|
|
377
|
+
errors.delete(token);
|
|
378
|
+
};
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
const getSections = (): RegisteredTelegramSection[] => {
|
|
382
|
+
return [...sections.values()].sort((a, b) => {
|
|
383
|
+
if (a.order !== b.order) return a.order - b.order;
|
|
384
|
+
return a.id.localeCompare(b.id);
|
|
385
|
+
});
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
const getByToken = (
|
|
389
|
+
token: TelegramSectionToken,
|
|
390
|
+
): RegisteredTelegramSection | undefined => {
|
|
391
|
+
return sections.get(token);
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
const getDiagnostics = (): TelegramSectionDiagnostic[] => {
|
|
395
|
+
return getSections().map((s) => ({
|
|
396
|
+
id: s.id,
|
|
397
|
+
token: s.token,
|
|
398
|
+
label: s.label,
|
|
399
|
+
status: errors.has(s.token) ? "error" : "active",
|
|
400
|
+
lastError: errors.get(s.token)?.message,
|
|
401
|
+
}));
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
const recordError = (
|
|
405
|
+
token: TelegramSectionToken,
|
|
406
|
+
message: string,
|
|
407
|
+
source = "runtime",
|
|
408
|
+
): void => {
|
|
409
|
+
if (sections.has(token)) errors.set(token, { message, source });
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
const clearError = (token: TelegramSectionToken, source?: string): void => {
|
|
413
|
+
const current = errors.get(token);
|
|
414
|
+
if (!source || !current || current.source === source) errors.delete(token);
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
const clear = (): void => {
|
|
418
|
+
sections.clear();
|
|
419
|
+
errors.clear();
|
|
420
|
+
nextToken = 0;
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
return {
|
|
424
|
+
register,
|
|
425
|
+
getSections,
|
|
426
|
+
getByToken,
|
|
427
|
+
getDiagnostics,
|
|
428
|
+
recordError,
|
|
429
|
+
clearError,
|
|
430
|
+
clear,
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/** @internal */
|
|
435
|
+
export function getTelegramExtensionSettingsRows(
|
|
436
|
+
registry: TelegramSectionRegistry,
|
|
437
|
+
): TelegramSectionSettingsRow[] {
|
|
438
|
+
const rows: TelegramSectionSettingsRow[] = [];
|
|
439
|
+
for (const section of registry
|
|
440
|
+
.getSections()
|
|
441
|
+
.filter((s) => s.registration.settings)
|
|
442
|
+
.sort((a, b) => {
|
|
443
|
+
const orderA = a.registration.settings!.order ?? 0;
|
|
444
|
+
const orderB = b.registration.settings!.order ?? 0;
|
|
445
|
+
if (orderA !== orderB) return orderA - orderB;
|
|
446
|
+
return a.id.localeCompare(b.id);
|
|
447
|
+
})) {
|
|
448
|
+
try {
|
|
449
|
+
rows.push({
|
|
450
|
+
label:
|
|
451
|
+
section.registration.settings!.getLabel?.() ??
|
|
452
|
+
section.registration.settings!.label,
|
|
453
|
+
callback_data: `section:${section.token}:settings:open`,
|
|
454
|
+
});
|
|
455
|
+
registry.clearError(section.token, "settings_label");
|
|
456
|
+
} catch (error) {
|
|
457
|
+
registry.recordError(
|
|
458
|
+
section.token,
|
|
459
|
+
sectionErrorMessage(error),
|
|
460
|
+
"settings_label",
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return rows;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/** @internal */
|
|
468
|
+
export function getTelegramSectionMainMenuRows(
|
|
469
|
+
registry: TelegramSectionRegistry,
|
|
470
|
+
): TelegramSectionMainMenuRow[] {
|
|
471
|
+
const rows: TelegramSectionMainMenuRow[] = [];
|
|
472
|
+
for (const section of registry.getSections()) {
|
|
473
|
+
try {
|
|
474
|
+
rows.push({
|
|
475
|
+
text: section.registration.getLabel?.() ?? section.label,
|
|
476
|
+
callback_data: `section:${section.token}:open`,
|
|
477
|
+
});
|
|
478
|
+
registry.clearError(section.token, "main_label");
|
|
479
|
+
} catch (error) {
|
|
480
|
+
registry.recordError(
|
|
481
|
+
section.token,
|
|
482
|
+
sectionErrorMessage(error),
|
|
483
|
+
"main_label",
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
return rows;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/** @internal */
|
|
491
|
+
export function parseTelegramSectionCallback(
|
|
492
|
+
data: string,
|
|
493
|
+
): { token: string; action: string; payload: string } | undefined {
|
|
494
|
+
if (!data.startsWith("section:")) return undefined;
|
|
495
|
+
const rest = data.slice("section:".length);
|
|
496
|
+
const firstColon = rest.indexOf(":");
|
|
497
|
+
if (firstColon === -1) return undefined;
|
|
498
|
+
const token = rest.slice(0, firstColon);
|
|
499
|
+
const afterToken = rest.slice(firstColon + 1);
|
|
500
|
+
const secondColon = afterToken.indexOf(":");
|
|
501
|
+
if (secondColon === -1) {
|
|
502
|
+
return { token, action: afterToken, payload: "" };
|
|
503
|
+
}
|
|
504
|
+
return {
|
|
505
|
+
token,
|
|
506
|
+
action: afterToken.slice(0, secondColon),
|
|
507
|
+
payload: afterToken.slice(secondColon + 1),
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/** @internal */
|
|
512
|
+
export interface TelegramSectionCallbackHandlerDeps {
|
|
513
|
+
answerCallbackQuery: (id: string, text?: string) => Promise<void>;
|
|
514
|
+
target?: TelegramSectionTarget;
|
|
515
|
+
editInteractiveMessage: (
|
|
516
|
+
chatId: number,
|
|
517
|
+
messageId: number,
|
|
518
|
+
text: string,
|
|
519
|
+
mode: "markdown" | "html" | "plain",
|
|
520
|
+
replyMarkup: TelegramInlineKeyboardMarkup,
|
|
521
|
+
) => Promise<void>;
|
|
522
|
+
sendInteractiveMessage: (
|
|
523
|
+
chatId: number,
|
|
524
|
+
text: string,
|
|
525
|
+
mode: "markdown" | "html" | "plain",
|
|
526
|
+
replyMarkup: TelegramInlineKeyboardMarkup,
|
|
527
|
+
options?: { target?: TelegramSectionTarget },
|
|
528
|
+
) => Promise<number | undefined>;
|
|
529
|
+
enqueuePrompt: (prompt: string) => Promise<void>;
|
|
530
|
+
deleteMessage: (chatId: number, messageId: number) => Promise<void>;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
export async function handleTelegramSectionOpen(
|
|
534
|
+
registry: TelegramSectionRegistry,
|
|
535
|
+
token: TelegramSectionToken,
|
|
536
|
+
chatId: number,
|
|
537
|
+
messageId: number,
|
|
538
|
+
callbackQueryId: string,
|
|
539
|
+
deps: TelegramSectionCallbackHandlerDeps,
|
|
540
|
+
): Promise<boolean> {
|
|
541
|
+
const section = registry.getByToken(token);
|
|
542
|
+
if (!section) {
|
|
543
|
+
await deps.answerCallbackQuery(
|
|
544
|
+
callbackQueryId,
|
|
545
|
+
"This section is no longer available.",
|
|
546
|
+
);
|
|
547
|
+
return true;
|
|
548
|
+
}
|
|
549
|
+
try {
|
|
550
|
+
const sectionCtx = buildTelegramSectionContext(
|
|
551
|
+
section.id,
|
|
552
|
+
token,
|
|
553
|
+
chatId,
|
|
554
|
+
messageId,
|
|
555
|
+
callbackQueryId,
|
|
556
|
+
deps,
|
|
557
|
+
);
|
|
558
|
+
const view = await section.registration.render(sectionCtx);
|
|
559
|
+
const viewWithBack = {
|
|
560
|
+
...view,
|
|
561
|
+
replyMarkup: prependBackRow(
|
|
562
|
+
view.replyMarkup,
|
|
563
|
+
"menu:back",
|
|
564
|
+
"⬆️ Main menu",
|
|
565
|
+
),
|
|
566
|
+
};
|
|
567
|
+
await deps.editInteractiveMessage(
|
|
568
|
+
chatId,
|
|
569
|
+
messageId,
|
|
570
|
+
viewWithBack.text,
|
|
571
|
+
viewWithBack.parseMode ?? "html",
|
|
572
|
+
viewWithBack.replyMarkup,
|
|
573
|
+
);
|
|
574
|
+
await deps.answerCallbackQuery(callbackQueryId);
|
|
575
|
+
registry.clearError(token, "render");
|
|
576
|
+
return true;
|
|
577
|
+
} catch (error) {
|
|
578
|
+
const message = sectionErrorMessage(error);
|
|
579
|
+
registry.recordError(token, message, "render");
|
|
580
|
+
await deps.answerCallbackQuery(
|
|
581
|
+
callbackQueryId,
|
|
582
|
+
`Section error: ${message}`,
|
|
583
|
+
);
|
|
584
|
+
return true;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
export async function handleTelegramSectionCallback(
|
|
589
|
+
registry: TelegramSectionRegistry,
|
|
590
|
+
token: TelegramSectionToken,
|
|
591
|
+
action: string,
|
|
592
|
+
payload: string,
|
|
593
|
+
chatId: number,
|
|
594
|
+
messageId: number,
|
|
595
|
+
callbackQueryId: string,
|
|
596
|
+
deps: TelegramSectionCallbackHandlerDeps,
|
|
597
|
+
): Promise<boolean> {
|
|
598
|
+
const section = registry.getByToken(token);
|
|
599
|
+
if (!section) {
|
|
600
|
+
await deps.answerCallbackQuery(
|
|
601
|
+
callbackQueryId,
|
|
602
|
+
"This section is no longer available.",
|
|
603
|
+
);
|
|
604
|
+
return true;
|
|
605
|
+
}
|
|
606
|
+
// Try main handleCallback first, then settings handleCallback as fallback.
|
|
607
|
+
const mainHandler = section.registration.handleCallback;
|
|
608
|
+
const settingsHandler = section.registration.settings?.handleCallback;
|
|
609
|
+
const handler = mainHandler ?? settingsHandler;
|
|
610
|
+
if (!handler) {
|
|
611
|
+
await deps.answerCallbackQuery(callbackQueryId);
|
|
612
|
+
return true;
|
|
613
|
+
}
|
|
614
|
+
try {
|
|
615
|
+
const ctx = buildTelegramSectionCallbackContext(
|
|
616
|
+
section.id,
|
|
617
|
+
token,
|
|
618
|
+
chatId,
|
|
619
|
+
messageId,
|
|
620
|
+
action,
|
|
621
|
+
payload,
|
|
622
|
+
callbackQueryId,
|
|
623
|
+
deps,
|
|
624
|
+
mainHandler ? `section:${token}:open` : "settings:list",
|
|
625
|
+
);
|
|
626
|
+
let result = await handler(ctx);
|
|
627
|
+
// Fallback: if main handler passed and settings handler exists, try settings
|
|
628
|
+
// with the correct navigation context (back → settings list).
|
|
629
|
+
if (result === "pass" && mainHandler && settingsHandler) {
|
|
630
|
+
const settingsCtx = buildTelegramSectionCallbackContext(
|
|
631
|
+
section.id,
|
|
632
|
+
token,
|
|
633
|
+
chatId,
|
|
634
|
+
messageId,
|
|
635
|
+
action,
|
|
636
|
+
payload,
|
|
637
|
+
callbackQueryId,
|
|
638
|
+
deps,
|
|
639
|
+
"settings:list",
|
|
640
|
+
);
|
|
641
|
+
result = await settingsHandler(settingsCtx);
|
|
642
|
+
}
|
|
643
|
+
if (result === "pass") {
|
|
644
|
+
await deps.answerCallbackQuery(callbackQueryId);
|
|
645
|
+
}
|
|
646
|
+
registry.clearError(token, "callback");
|
|
647
|
+
return true;
|
|
648
|
+
} catch (error) {
|
|
649
|
+
const message = sectionErrorMessage(error);
|
|
650
|
+
registry.recordError(token, message, "callback");
|
|
651
|
+
await deps.answerCallbackQuery(
|
|
652
|
+
callbackQueryId,
|
|
653
|
+
`Section error: ${message}`,
|
|
654
|
+
);
|
|
655
|
+
return true;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
export async function handleTelegramSectionSettingsOpen(
|
|
660
|
+
registry: TelegramSectionRegistry,
|
|
661
|
+
token: TelegramSectionToken,
|
|
662
|
+
chatId: number,
|
|
663
|
+
messageId: number,
|
|
664
|
+
callbackQueryId: string,
|
|
665
|
+
deps: TelegramSectionCallbackHandlerDeps,
|
|
666
|
+
): Promise<boolean> {
|
|
667
|
+
const section = registry.getByToken(token);
|
|
668
|
+
if (!section || !section.registration.settings) {
|
|
669
|
+
await deps.answerCallbackQuery(
|
|
670
|
+
callbackQueryId,
|
|
671
|
+
"This section is no longer available.",
|
|
672
|
+
);
|
|
673
|
+
return true;
|
|
674
|
+
}
|
|
675
|
+
try {
|
|
676
|
+
const sectionCtx = buildTelegramSectionContext(
|
|
677
|
+
section.id,
|
|
678
|
+
token,
|
|
679
|
+
chatId,
|
|
680
|
+
messageId,
|
|
681
|
+
callbackQueryId,
|
|
682
|
+
deps,
|
|
683
|
+
"settings:list",
|
|
684
|
+
"⬆️ Back",
|
|
685
|
+
);
|
|
686
|
+
const view = await section.registration.settings.open(sectionCtx);
|
|
687
|
+
const viewWithBack = {
|
|
688
|
+
...view,
|
|
689
|
+
replyMarkup: prependBackRow(view.replyMarkup, "settings:list", "⬆️ Back"),
|
|
690
|
+
};
|
|
691
|
+
await deps.editInteractiveMessage(
|
|
692
|
+
chatId,
|
|
693
|
+
messageId,
|
|
694
|
+
viewWithBack.text,
|
|
695
|
+
viewWithBack.parseMode ?? "html",
|
|
696
|
+
viewWithBack.replyMarkup,
|
|
697
|
+
);
|
|
698
|
+
await deps.answerCallbackQuery(callbackQueryId);
|
|
699
|
+
registry.clearError(token, "settings_open");
|
|
700
|
+
return true;
|
|
701
|
+
} catch (error) {
|
|
702
|
+
const message = sectionErrorMessage(error);
|
|
703
|
+
registry.recordError(token, message, "settings_open");
|
|
704
|
+
await deps.answerCallbackQuery(
|
|
705
|
+
callbackQueryId,
|
|
706
|
+
`Section error: ${message}`,
|
|
707
|
+
);
|
|
708
|
+
return true;
|
|
709
|
+
}
|
|
710
|
+
}
|