@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,628 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram bridge runtime-state helpers
|
|
3
|
+
* Zones: pi agent runtime state, telegram session, shared coordination
|
|
4
|
+
* Owns small session-local runtime primitives that are shared by orchestration but are not specific to queueing, rendering, polling, or Telegram transport
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const TELEGRAM_TYPING_ACTION_INTERVAL_MS = 2500;
|
|
8
|
+
const TELEGRAM_TYPING_IDLE_DRAIN_MAX_MS = 250;
|
|
9
|
+
|
|
10
|
+
export interface TelegramRuntimeQueueCounters {
|
|
11
|
+
nextQueuedTelegramItemOrder: number;
|
|
12
|
+
nextQueuedTelegramControlOrder: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface TelegramRuntimeLifecycleFlags {
|
|
16
|
+
activeTelegramToolExecutions: number;
|
|
17
|
+
telegramTurnDispatchPending: boolean;
|
|
18
|
+
compactionInProgress: boolean;
|
|
19
|
+
foldQueuedPromptsIntoHistory: boolean;
|
|
20
|
+
setupInProgress: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface TelegramBridgeRuntimeState
|
|
24
|
+
extends TelegramRuntimeQueueCounters, TelegramRuntimeLifecycleFlags {
|
|
25
|
+
abortHandler?: () => void;
|
|
26
|
+
typingInterval?: ReturnType<typeof setInterval>;
|
|
27
|
+
typingInFlight?: Promise<void>;
|
|
28
|
+
typingLoopDeps?: TelegramTypingLoopDeps;
|
|
29
|
+
typingLoopKey?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface TelegramRuntimeQueuePort {
|
|
33
|
+
syncCounters: (counters: Partial<TelegramRuntimeQueueCounters>) => void;
|
|
34
|
+
allocateItemOrder: () => number;
|
|
35
|
+
allocateControlOrder: () => number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface TelegramRuntimeLifecyclePort {
|
|
39
|
+
syncFlags: (flags: Partial<TelegramRuntimeLifecycleFlags>) => void;
|
|
40
|
+
getActiveToolExecutions: () => number;
|
|
41
|
+
setActiveToolExecutions: (count: number) => void;
|
|
42
|
+
resetActiveToolExecutions: () => void;
|
|
43
|
+
hasDispatchPending: () => boolean;
|
|
44
|
+
setDispatchPending: (pending: boolean) => void;
|
|
45
|
+
clearDispatchPending: () => void;
|
|
46
|
+
isCompactionInProgress: () => boolean;
|
|
47
|
+
setCompactionInProgress: (inProgress: boolean) => void;
|
|
48
|
+
shouldFoldQueuedPromptsIntoHistory: () => boolean;
|
|
49
|
+
setFoldQueuedPromptsIntoHistory: (fold: boolean) => void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface TelegramRuntimeSetupPort {
|
|
53
|
+
isInProgress: () => boolean;
|
|
54
|
+
start: () => boolean;
|
|
55
|
+
finish: () => void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface TelegramRuntimeAbortPort {
|
|
59
|
+
hasHandler: () => boolean;
|
|
60
|
+
setHandler: (abortHandler: () => void) => void;
|
|
61
|
+
clearHandler: () => void;
|
|
62
|
+
getHandler: () => (() => void) | undefined;
|
|
63
|
+
abortTurn: () => boolean;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface TelegramRuntimeTypingPort {
|
|
67
|
+
start: (deps: TelegramTypingLoopDeps) => boolean;
|
|
68
|
+
stop: () => boolean;
|
|
69
|
+
waitForIdle: () => Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface TelegramBridgeRuntime {
|
|
73
|
+
state: TelegramBridgeRuntimeState;
|
|
74
|
+
queue: TelegramRuntimeQueuePort;
|
|
75
|
+
lifecycle: TelegramRuntimeLifecyclePort;
|
|
76
|
+
setup: TelegramRuntimeSetupPort;
|
|
77
|
+
abort: TelegramRuntimeAbortPort;
|
|
78
|
+
typing: TelegramRuntimeTypingPort;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function createTelegramBridgeRuntimeState(): TelegramBridgeRuntimeState {
|
|
82
|
+
return {
|
|
83
|
+
nextQueuedTelegramItemOrder: 0,
|
|
84
|
+
nextQueuedTelegramControlOrder: 0,
|
|
85
|
+
activeTelegramToolExecutions: 0,
|
|
86
|
+
telegramTurnDispatchPending: false,
|
|
87
|
+
compactionInProgress: false,
|
|
88
|
+
foldQueuedPromptsIntoHistory: false,
|
|
89
|
+
setupInProgress: false,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function createTelegramBridgeRuntime(
|
|
94
|
+
state = createTelegramBridgeRuntimeState(),
|
|
95
|
+
): TelegramBridgeRuntime {
|
|
96
|
+
return {
|
|
97
|
+
state,
|
|
98
|
+
queue: {
|
|
99
|
+
syncCounters: (counters) =>
|
|
100
|
+
syncTelegramQueueRuntimeCounters(state, counters),
|
|
101
|
+
allocateItemOrder: () => allocateTelegramQueueItemOrder(state),
|
|
102
|
+
allocateControlOrder: () => allocateTelegramQueueControlOrder(state),
|
|
103
|
+
},
|
|
104
|
+
lifecycle: {
|
|
105
|
+
syncFlags: (flags) => syncTelegramLifecycleRuntimeFlags(state, flags),
|
|
106
|
+
getActiveToolExecutions: () => getActiveTelegramToolExecutions(state),
|
|
107
|
+
setActiveToolExecutions: (count) =>
|
|
108
|
+
setActiveTelegramToolExecutions(state, count),
|
|
109
|
+
resetActiveToolExecutions: () => resetActiveTelegramToolExecutions(state),
|
|
110
|
+
hasDispatchPending: () => hasTelegramDispatchPending(state),
|
|
111
|
+
setDispatchPending: (pending) =>
|
|
112
|
+
setTelegramDispatchPending(state, pending),
|
|
113
|
+
clearDispatchPending: () => clearTelegramDispatchPending(state),
|
|
114
|
+
isCompactionInProgress: () => isTelegramCompactionInProgress(state),
|
|
115
|
+
setCompactionInProgress: (inProgress) =>
|
|
116
|
+
setTelegramCompactionInProgress(state, inProgress),
|
|
117
|
+
shouldFoldQueuedPromptsIntoHistory: () =>
|
|
118
|
+
shouldFoldQueuedPromptsIntoHistory(state),
|
|
119
|
+
setFoldQueuedPromptsIntoHistory: (fold) =>
|
|
120
|
+
setFoldQueuedPromptsIntoHistory(state, fold),
|
|
121
|
+
},
|
|
122
|
+
setup: {
|
|
123
|
+
isInProgress: () => isTelegramSetupInProgress(state),
|
|
124
|
+
start: () => startTelegramSetup(state),
|
|
125
|
+
finish: () => finishTelegramSetup(state),
|
|
126
|
+
},
|
|
127
|
+
abort: {
|
|
128
|
+
hasHandler: () => hasTelegramAbortHandler(state),
|
|
129
|
+
setHandler: (abortHandler) =>
|
|
130
|
+
setTelegramAbortHandler(state, abortHandler),
|
|
131
|
+
clearHandler: () => clearTelegramAbortHandler(state),
|
|
132
|
+
getHandler: () => getTelegramAbortHandler(state),
|
|
133
|
+
abortTurn: () => abortTelegramTurn(state),
|
|
134
|
+
},
|
|
135
|
+
typing: {
|
|
136
|
+
start: (deps) => startTelegramTypingLoop(state, deps),
|
|
137
|
+
stop: () => stopTelegramTypingLoop(state),
|
|
138
|
+
waitForIdle: () => waitForTelegramTypingLoopIdle(state),
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function syncTelegramQueueRuntimeCounters(
|
|
144
|
+
state: TelegramBridgeRuntimeState,
|
|
145
|
+
counters: Partial<TelegramRuntimeQueueCounters>,
|
|
146
|
+
): void {
|
|
147
|
+
if (counters.nextQueuedTelegramItemOrder !== undefined) {
|
|
148
|
+
state.nextQueuedTelegramItemOrder = counters.nextQueuedTelegramItemOrder;
|
|
149
|
+
}
|
|
150
|
+
if (counters.nextQueuedTelegramControlOrder !== undefined) {
|
|
151
|
+
state.nextQueuedTelegramControlOrder =
|
|
152
|
+
counters.nextQueuedTelegramControlOrder;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function allocateTelegramQueueItemOrder(
|
|
157
|
+
state: TelegramBridgeRuntimeState,
|
|
158
|
+
): number {
|
|
159
|
+
return state.nextQueuedTelegramItemOrder++;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export function allocateTelegramQueueControlOrder(
|
|
163
|
+
state: TelegramBridgeRuntimeState,
|
|
164
|
+
): number {
|
|
165
|
+
return state.nextQueuedTelegramControlOrder++;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export function syncTelegramLifecycleRuntimeFlags(
|
|
169
|
+
state: TelegramBridgeRuntimeState,
|
|
170
|
+
flags: Partial<TelegramRuntimeLifecycleFlags>,
|
|
171
|
+
): void {
|
|
172
|
+
if (flags.activeTelegramToolExecutions !== undefined) {
|
|
173
|
+
state.activeTelegramToolExecutions = flags.activeTelegramToolExecutions;
|
|
174
|
+
}
|
|
175
|
+
if (flags.telegramTurnDispatchPending !== undefined) {
|
|
176
|
+
state.telegramTurnDispatchPending = flags.telegramTurnDispatchPending;
|
|
177
|
+
}
|
|
178
|
+
if (flags.compactionInProgress !== undefined) {
|
|
179
|
+
state.compactionInProgress = flags.compactionInProgress;
|
|
180
|
+
}
|
|
181
|
+
if (flags.foldQueuedPromptsIntoHistory !== undefined) {
|
|
182
|
+
state.foldQueuedPromptsIntoHistory = flags.foldQueuedPromptsIntoHistory;
|
|
183
|
+
}
|
|
184
|
+
if (flags.setupInProgress !== undefined) {
|
|
185
|
+
state.setupInProgress = flags.setupInProgress;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export function getActiveTelegramToolExecutions(
|
|
190
|
+
state: TelegramBridgeRuntimeState,
|
|
191
|
+
): number {
|
|
192
|
+
return state.activeTelegramToolExecutions;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export function setActiveTelegramToolExecutions(
|
|
196
|
+
state: TelegramBridgeRuntimeState,
|
|
197
|
+
count: number,
|
|
198
|
+
): void {
|
|
199
|
+
state.activeTelegramToolExecutions = count;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export function resetActiveTelegramToolExecutions(
|
|
203
|
+
state: TelegramBridgeRuntimeState,
|
|
204
|
+
): void {
|
|
205
|
+
state.activeTelegramToolExecutions = 0;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function hasTelegramDispatchPending(
|
|
209
|
+
state: TelegramBridgeRuntimeState,
|
|
210
|
+
): boolean {
|
|
211
|
+
return state.telegramTurnDispatchPending;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function setTelegramDispatchPending(
|
|
215
|
+
state: TelegramBridgeRuntimeState,
|
|
216
|
+
pending: boolean,
|
|
217
|
+
): void {
|
|
218
|
+
state.telegramTurnDispatchPending = pending;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export function clearTelegramDispatchPending(
|
|
222
|
+
state: TelegramBridgeRuntimeState,
|
|
223
|
+
): void {
|
|
224
|
+
state.telegramTurnDispatchPending = false;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export function isTelegramCompactionInProgress(
|
|
228
|
+
state: TelegramBridgeRuntimeState,
|
|
229
|
+
): boolean {
|
|
230
|
+
return state.compactionInProgress;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export function setTelegramCompactionInProgress(
|
|
234
|
+
state: TelegramBridgeRuntimeState,
|
|
235
|
+
inProgress: boolean,
|
|
236
|
+
): void {
|
|
237
|
+
state.compactionInProgress = inProgress;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export function shouldFoldQueuedPromptsIntoHistory(
|
|
241
|
+
state: TelegramBridgeRuntimeState,
|
|
242
|
+
): boolean {
|
|
243
|
+
return state.foldQueuedPromptsIntoHistory;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export function setFoldQueuedPromptsIntoHistory(
|
|
247
|
+
state: TelegramBridgeRuntimeState,
|
|
248
|
+
fold: boolean,
|
|
249
|
+
): void {
|
|
250
|
+
state.foldQueuedPromptsIntoHistory = fold;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export function isTelegramSetupInProgress(
|
|
254
|
+
state: TelegramBridgeRuntimeState,
|
|
255
|
+
): boolean {
|
|
256
|
+
return state.setupInProgress;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export function startTelegramSetup(state: TelegramBridgeRuntimeState): boolean {
|
|
260
|
+
if (state.setupInProgress) return false;
|
|
261
|
+
state.setupInProgress = true;
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export function finishTelegramSetup(state: TelegramBridgeRuntimeState): void {
|
|
266
|
+
state.setupInProgress = false;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export function hasTelegramAbortHandler(
|
|
270
|
+
state: TelegramBridgeRuntimeState,
|
|
271
|
+
): boolean {
|
|
272
|
+
return !!state.abortHandler;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export function setTelegramAbortHandler(
|
|
276
|
+
state: TelegramBridgeRuntimeState,
|
|
277
|
+
abortHandler: () => void,
|
|
278
|
+
): void {
|
|
279
|
+
state.abortHandler = abortHandler;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export function clearTelegramAbortHandler(
|
|
283
|
+
state: TelegramBridgeRuntimeState,
|
|
284
|
+
): void {
|
|
285
|
+
state.abortHandler = undefined;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export function getTelegramAbortHandler(
|
|
289
|
+
state: TelegramBridgeRuntimeState,
|
|
290
|
+
): (() => void) | undefined {
|
|
291
|
+
return state.abortHandler;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export function abortTelegramTurn(state: TelegramBridgeRuntimeState): boolean {
|
|
295
|
+
if (!state.abortHandler) return false;
|
|
296
|
+
state.abortHandler();
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export interface TelegramTypingLoopTarget {
|
|
301
|
+
chatId: number;
|
|
302
|
+
threadId?: number;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function getTelegramTypingLoopThreadParams(
|
|
306
|
+
target: TelegramTypingLoopTarget | undefined,
|
|
307
|
+
): { message_thread_id?: number } | undefined {
|
|
308
|
+
const threadId = target?.threadId;
|
|
309
|
+
return Number.isInteger(threadId)
|
|
310
|
+
? { message_thread_id: threadId }
|
|
311
|
+
: undefined;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export interface TelegramTypingLoopDeps {
|
|
315
|
+
chatId: number | undefined;
|
|
316
|
+
target?: TelegramTypingLoopTarget;
|
|
317
|
+
intervalMs: number;
|
|
318
|
+
sendTypingAction: (
|
|
319
|
+
chatId: number,
|
|
320
|
+
options?: { message_thread_id?: number },
|
|
321
|
+
) => Promise<unknown>;
|
|
322
|
+
sendAggregateTypingAction?: (chatId: number) => Promise<unknown>;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export interface TelegramRuntimeEventRecorderPort {
|
|
326
|
+
recordRuntimeEvent?: (
|
|
327
|
+
category: string,
|
|
328
|
+
error: unknown,
|
|
329
|
+
details?: Record<string, unknown>,
|
|
330
|
+
) => void;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function updateTelegramRuntimeStatusSafely<TContext>(
|
|
334
|
+
updateStatus: (ctx: TContext, error?: string) => void,
|
|
335
|
+
ctx: TContext,
|
|
336
|
+
options: {
|
|
337
|
+
error?: string;
|
|
338
|
+
category: string;
|
|
339
|
+
phase: string;
|
|
340
|
+
recordRuntimeEvent?: TelegramRuntimeEventRecorderPort["recordRuntimeEvent"];
|
|
341
|
+
},
|
|
342
|
+
): void {
|
|
343
|
+
try {
|
|
344
|
+
updateStatus(ctx, options.error);
|
|
345
|
+
} catch (statusError) {
|
|
346
|
+
try {
|
|
347
|
+
options.recordRuntimeEvent?.(options.category, statusError, {
|
|
348
|
+
phase: options.phase,
|
|
349
|
+
});
|
|
350
|
+
} catch {
|
|
351
|
+
// Status diagnostics cannot escape an asynchronous runtime owner.
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export interface TelegramTypingLoopStarterDeps<
|
|
357
|
+
TContext,
|
|
358
|
+
> extends TelegramRuntimeEventRecorderPort {
|
|
359
|
+
typing: TelegramRuntimeTypingPort;
|
|
360
|
+
getDefaultChatId: () => number | undefined;
|
|
361
|
+
sendTypingAction: (
|
|
362
|
+
chatId: number,
|
|
363
|
+
options?: { message_thread_id?: number },
|
|
364
|
+
) => Promise<unknown>;
|
|
365
|
+
sendAggregateTypingAction?: (chatId: number) => Promise<unknown>;
|
|
366
|
+
updateStatus: (ctx: TContext, error?: string) => void;
|
|
367
|
+
isContextActive?: (ctx: TContext) => boolean;
|
|
368
|
+
intervalMs?: number;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
export function createTelegramTypingLoopStarter<TContext>(
|
|
372
|
+
deps: TelegramTypingLoopStarterDeps<TContext>,
|
|
373
|
+
): (
|
|
374
|
+
ctx: TContext,
|
|
375
|
+
chatId?: number,
|
|
376
|
+
options?: { target?: TelegramTypingLoopTarget },
|
|
377
|
+
) => void {
|
|
378
|
+
return (ctx, chatId, options) => {
|
|
379
|
+
deps.typing.start({
|
|
380
|
+
chatId: chatId ?? deps.getDefaultChatId(),
|
|
381
|
+
target: options?.target,
|
|
382
|
+
intervalMs: deps.intervalMs ?? TELEGRAM_TYPING_ACTION_INTERVAL_MS,
|
|
383
|
+
sendTypingAction: async (targetChatId, actionOptions) => {
|
|
384
|
+
try {
|
|
385
|
+
await deps.sendTypingAction(targetChatId, actionOptions);
|
|
386
|
+
} catch (error) {
|
|
387
|
+
if (deps.isContextActive?.(ctx) === false) return;
|
|
388
|
+
const message =
|
|
389
|
+
error instanceof Error ? error.message : String(error);
|
|
390
|
+
updateTelegramRuntimeStatusSafely(deps.updateStatus, ctx, {
|
|
391
|
+
error: message,
|
|
392
|
+
category: "typing",
|
|
393
|
+
phase: "status-update",
|
|
394
|
+
recordRuntimeEvent: deps.recordRuntimeEvent,
|
|
395
|
+
});
|
|
396
|
+
try {
|
|
397
|
+
deps.recordRuntimeEvent?.("typing", error, {
|
|
398
|
+
chatId: targetChatId,
|
|
399
|
+
});
|
|
400
|
+
} catch {
|
|
401
|
+
// Typing diagnostics cannot escape the in-flight action owner.
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
sendAggregateTypingAction: deps.sendAggregateTypingAction
|
|
406
|
+
? async (targetChatId) => {
|
|
407
|
+
try {
|
|
408
|
+
await deps.sendAggregateTypingAction?.(targetChatId);
|
|
409
|
+
} catch (error) {
|
|
410
|
+
if (deps.isContextActive?.(ctx) === false) return;
|
|
411
|
+
const message =
|
|
412
|
+
error instanceof Error ? error.message : String(error);
|
|
413
|
+
updateTelegramRuntimeStatusSafely(deps.updateStatus, ctx, {
|
|
414
|
+
error: message,
|
|
415
|
+
category: "typing",
|
|
416
|
+
phase: "status-update",
|
|
417
|
+
recordRuntimeEvent: deps.recordRuntimeEvent,
|
|
418
|
+
});
|
|
419
|
+
try {
|
|
420
|
+
deps.recordRuntimeEvent?.("typing", error, {
|
|
421
|
+
chatId: targetChatId,
|
|
422
|
+
aggregate: true,
|
|
423
|
+
});
|
|
424
|
+
} catch {
|
|
425
|
+
// Typing diagnostics cannot escape the in-flight action owner.
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
: undefined,
|
|
430
|
+
});
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function getTelegramTypingLoopKey(deps: TelegramTypingLoopDeps): string {
|
|
435
|
+
const threadId = deps.target?.threadId;
|
|
436
|
+
return `${deps.chatId ?? 0}:${Number.isInteger(threadId) ? threadId : "all"}`;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
export function startTelegramTypingLoop(
|
|
440
|
+
state: TelegramBridgeRuntimeState,
|
|
441
|
+
deps: TelegramTypingLoopDeps,
|
|
442
|
+
): boolean {
|
|
443
|
+
if (deps.chatId === undefined || deps.chatId === 0) return false;
|
|
444
|
+
const previousKey = state.typingLoopKey;
|
|
445
|
+
const nextKey = getTelegramTypingLoopKey(deps);
|
|
446
|
+
state.typingLoopDeps = deps;
|
|
447
|
+
state.typingLoopKey = nextKey;
|
|
448
|
+
const sendTyping = (): void => {
|
|
449
|
+
const activeDeps = state.typingLoopDeps;
|
|
450
|
+
if (
|
|
451
|
+
!activeDeps ||
|
|
452
|
+
activeDeps.chatId === undefined ||
|
|
453
|
+
activeDeps.chatId === 0 ||
|
|
454
|
+
state.typingInFlight
|
|
455
|
+
)
|
|
456
|
+
return;
|
|
457
|
+
const targetChatId = activeDeps.chatId;
|
|
458
|
+
const threadParams = getTelegramTypingLoopThreadParams(activeDeps.target);
|
|
459
|
+
const typing = Promise.resolve()
|
|
460
|
+
.then(async () => {
|
|
461
|
+
await activeDeps.sendTypingAction(targetChatId, threadParams);
|
|
462
|
+
if (threadParams?.message_thread_id !== undefined) {
|
|
463
|
+
await activeDeps.sendAggregateTypingAction?.(targetChatId);
|
|
464
|
+
}
|
|
465
|
+
})
|
|
466
|
+
.then(() => undefined)
|
|
467
|
+
.catch(() => undefined);
|
|
468
|
+
state.typingInFlight = typing;
|
|
469
|
+
void typing.finally(() => {
|
|
470
|
+
if (state.typingInFlight === typing) state.typingInFlight = undefined;
|
|
471
|
+
});
|
|
472
|
+
};
|
|
473
|
+
if (state.typingInterval) {
|
|
474
|
+
if (previousKey === nextKey) return false;
|
|
475
|
+
sendTyping();
|
|
476
|
+
return true;
|
|
477
|
+
}
|
|
478
|
+
sendTyping();
|
|
479
|
+
state.typingInterval = setInterval(sendTyping, deps.intervalMs);
|
|
480
|
+
state.typingInterval.unref?.();
|
|
481
|
+
return true;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
export function stopTelegramTypingLoop(
|
|
485
|
+
state: TelegramBridgeRuntimeState,
|
|
486
|
+
): boolean {
|
|
487
|
+
if (!state.typingInterval) return false;
|
|
488
|
+
clearInterval(state.typingInterval);
|
|
489
|
+
state.typingInterval = undefined;
|
|
490
|
+
state.typingLoopDeps = undefined;
|
|
491
|
+
state.typingLoopKey = undefined;
|
|
492
|
+
return true;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
export async function waitForTelegramTypingLoopIdle(
|
|
496
|
+
state: TelegramBridgeRuntimeState,
|
|
497
|
+
timeoutMs = TELEGRAM_TYPING_IDLE_DRAIN_MAX_MS,
|
|
498
|
+
): Promise<void> {
|
|
499
|
+
const inFlight = state.typingInFlight;
|
|
500
|
+
if (!inFlight) return;
|
|
501
|
+
if (timeoutMs <= 0) {
|
|
502
|
+
await Promise.race([inFlight, Promise.resolve()]);
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
await Promise.race([
|
|
506
|
+
inFlight,
|
|
507
|
+
new Promise<void>((resolve) => {
|
|
508
|
+
setTimeout(resolve, timeoutMs);
|
|
509
|
+
}),
|
|
510
|
+
]);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
export function createTelegramContextAbortHandlerSetter<
|
|
514
|
+
TContext extends { abort: () => void },
|
|
515
|
+
>(
|
|
516
|
+
abort: Pick<TelegramRuntimeAbortPort, "setHandler">,
|
|
517
|
+
): (ctx: TContext) => void {
|
|
518
|
+
return (ctx) => {
|
|
519
|
+
abort.setHandler(() => ctx.abort());
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
export interface TelegramAgentEndResetDeps {
|
|
524
|
+
abort: Pick<TelegramRuntimeAbortPort, "clearHandler">;
|
|
525
|
+
typing: Pick<TelegramRuntimeTypingPort, "stop">;
|
|
526
|
+
clearActiveTurn: () => void;
|
|
527
|
+
resetToolExecutions: () => void;
|
|
528
|
+
clearPendingModelSwitch: () => void;
|
|
529
|
+
clearDispatchPending: () => void;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
export function createTelegramAgentEndResetter(
|
|
533
|
+
deps: TelegramAgentEndResetDeps,
|
|
534
|
+
): () => void {
|
|
535
|
+
return () => {
|
|
536
|
+
deps.abort.clearHandler();
|
|
537
|
+
deps.typing.stop();
|
|
538
|
+
deps.clearActiveTurn();
|
|
539
|
+
deps.resetToolExecutions();
|
|
540
|
+
deps.clearPendingModelSwitch();
|
|
541
|
+
deps.clearDispatchPending();
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
export interface TelegramPromptDispatchLifecycleDeps<
|
|
546
|
+
TContext,
|
|
547
|
+
> extends TelegramRuntimeEventRecorderPort {
|
|
548
|
+
lifecycle: Pick<
|
|
549
|
+
TelegramRuntimeLifecyclePort,
|
|
550
|
+
"setDispatchPending" | "clearDispatchPending"
|
|
551
|
+
>;
|
|
552
|
+
typing: Pick<TelegramRuntimeTypingPort, "stop">;
|
|
553
|
+
startTypingLoop: (
|
|
554
|
+
ctx: TContext,
|
|
555
|
+
chatId?: number,
|
|
556
|
+
options?: { target?: TelegramTypingLoopTarget },
|
|
557
|
+
) => void;
|
|
558
|
+
updateStatus: (ctx: TContext, error?: string) => void;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
export interface TelegramPromptDispatchRuntimeDeps<
|
|
562
|
+
TContext,
|
|
563
|
+
> extends TelegramRuntimeEventRecorderPort {
|
|
564
|
+
lifecycle: TelegramPromptDispatchLifecycleDeps<TContext>["lifecycle"];
|
|
565
|
+
typing: TelegramRuntimeTypingPort;
|
|
566
|
+
getDefaultChatId: () => number | undefined;
|
|
567
|
+
sendTypingAction: (
|
|
568
|
+
chatId: number,
|
|
569
|
+
options?: { message_thread_id?: number },
|
|
570
|
+
) => Promise<unknown>;
|
|
571
|
+
sendAggregateTypingAction?: (chatId: number) => Promise<unknown>;
|
|
572
|
+
updateStatus: (ctx: TContext, error?: string) => void;
|
|
573
|
+
isContextActive?: (ctx: TContext) => boolean;
|
|
574
|
+
intervalMs?: number;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
export interface TelegramPromptDispatchRuntime<TContext> {
|
|
578
|
+
startTypingLoop: (
|
|
579
|
+
ctx: TContext,
|
|
580
|
+
chatId?: number,
|
|
581
|
+
options?: { target?: TelegramTypingLoopTarget },
|
|
582
|
+
) => void;
|
|
583
|
+
onPromptDispatchStart: (ctx: TContext, chatId?: number) => void;
|
|
584
|
+
onPromptDispatchFailure: (ctx: TContext, message: string) => void;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
export function createTelegramPromptDispatchRuntime<TContext>(
|
|
588
|
+
deps: TelegramPromptDispatchRuntimeDeps<TContext>,
|
|
589
|
+
): TelegramPromptDispatchRuntime<TContext> {
|
|
590
|
+
const startTypingLoop = createTelegramTypingLoopStarter(deps);
|
|
591
|
+
return {
|
|
592
|
+
startTypingLoop,
|
|
593
|
+
...createTelegramPromptDispatchLifecycle({
|
|
594
|
+
lifecycle: deps.lifecycle,
|
|
595
|
+
typing: deps.typing,
|
|
596
|
+
startTypingLoop,
|
|
597
|
+
updateStatus: deps.updateStatus,
|
|
598
|
+
recordRuntimeEvent: deps.recordRuntimeEvent,
|
|
599
|
+
}),
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
export function createTelegramPromptDispatchLifecycle<TContext>(
|
|
604
|
+
deps: TelegramPromptDispatchLifecycleDeps<TContext>,
|
|
605
|
+
) {
|
|
606
|
+
return {
|
|
607
|
+
onPromptDispatchStart: (ctx: TContext, chatId?: number): void => {
|
|
608
|
+
deps.lifecycle.setDispatchPending(true);
|
|
609
|
+
deps.startTypingLoop(ctx, chatId);
|
|
610
|
+
updateTelegramRuntimeStatusSafely(deps.updateStatus, ctx, {
|
|
611
|
+
category: "dispatch",
|
|
612
|
+
phase: "status-update",
|
|
613
|
+
recordRuntimeEvent: deps.recordRuntimeEvent,
|
|
614
|
+
});
|
|
615
|
+
},
|
|
616
|
+
onPromptDispatchFailure: (ctx: TContext, message: string): void => {
|
|
617
|
+
deps.lifecycle.clearDispatchPending();
|
|
618
|
+
deps.typing.stop();
|
|
619
|
+
deps.recordRuntimeEvent?.("dispatch", new Error(message));
|
|
620
|
+
updateTelegramRuntimeStatusSafely(deps.updateStatus, ctx, {
|
|
621
|
+
error: `dispatch failed: ${message}`,
|
|
622
|
+
category: "dispatch",
|
|
623
|
+
phase: "status-update",
|
|
624
|
+
recordRuntimeEvent: deps.recordRuntimeEvent,
|
|
625
|
+
});
|
|
626
|
+
},
|
|
627
|
+
};
|
|
628
|
+
}
|