@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,714 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge-owned Telegram activity verbosity projection
|
|
3
|
+
* Zones: telegram activity, rich rendering, operational delivery
|
|
4
|
+
* Owns persistent bounded thinking and tool disclosures; excludes activity normalization, assistant answer rendering, and transport authority policy
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { TelegramActivityEvent } from "./activity.ts";
|
|
8
|
+
import {
|
|
9
|
+
escapeHtml,
|
|
10
|
+
renderTelegramInlineMarkdownHtml,
|
|
11
|
+
} from "./rendering.ts";
|
|
12
|
+
import type {
|
|
13
|
+
TelegramEditMessageTextBody,
|
|
14
|
+
TelegramInputRichBlock,
|
|
15
|
+
TelegramInputRichMessage,
|
|
16
|
+
TelegramSendMessageBody,
|
|
17
|
+
TelegramSendRichMessageBody,
|
|
18
|
+
TelegramSentMessage,
|
|
19
|
+
} from "./telegram-api.ts";
|
|
20
|
+
import type { TelegramTarget } from "./target.ts";
|
|
21
|
+
|
|
22
|
+
export const TELEGRAM_ACTIVITY_DETAIL_MAX_CHARS = 1_200;
|
|
23
|
+
export const TELEGRAM_ACTIVITY_MESSAGE_MAX_CHARS = 3_900;
|
|
24
|
+
export const TELEGRAM_ACTIVITY_MESSAGE_MAX_TOOLS = 6;
|
|
25
|
+
export const TELEGRAM_REASONING_MESSAGE_MAX_FRAMES = 24;
|
|
26
|
+
export const TELEGRAM_REASONING_BUFFER_MAX_CHARS = 1_200;
|
|
27
|
+
export const TELEGRAM_REASONING_MIN_INTERVAL_MS = 1_200;
|
|
28
|
+
export const TELEGRAM_TOOL_UPDATE_MAX_ENTRIES = 4;
|
|
29
|
+
|
|
30
|
+
interface ToolActivity {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
args: string;
|
|
34
|
+
updates: string[];
|
|
35
|
+
droppedUpdates: number;
|
|
36
|
+
result?: string;
|
|
37
|
+
isError?: boolean;
|
|
38
|
+
complete: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface ToolMessage {
|
|
42
|
+
messageId: number;
|
|
43
|
+
tools: ToolActivity[];
|
|
44
|
+
target: TelegramTarget;
|
|
45
|
+
format: "rich" | "html";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface ReasoningMessage {
|
|
49
|
+
messageId: number;
|
|
50
|
+
target: TelegramTarget;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function targetEquals(left: TelegramTarget, right: TelegramTarget): boolean {
|
|
54
|
+
return left.chatId === right.chatId && left.threadId === right.threadId;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function redactActivityText(text: string): string {
|
|
58
|
+
return text
|
|
59
|
+
.replace(/\b\d{8,12}:[A-Za-z0-9_-]{30,}\b/g, "[REDACTED_BOT_TOKEN]")
|
|
60
|
+
.replace(
|
|
61
|
+
/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{16,}\b/gi,
|
|
62
|
+
"$1[REDACTED]",
|
|
63
|
+
)
|
|
64
|
+
.replace(
|
|
65
|
+
/(["']?(?:api[_-]?key|token|password|secret)["']?\s*[:=]\s*["']?)[^"',\s}]+/gi,
|
|
66
|
+
"$1[REDACTED]",
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function formatActivityJson(value: unknown, depth = 0): string[] {
|
|
71
|
+
const indent = " ".repeat(depth);
|
|
72
|
+
if (Array.isArray(value)) {
|
|
73
|
+
if (value.length === 0) return [`${indent}[]`];
|
|
74
|
+
if (
|
|
75
|
+
value.every(
|
|
76
|
+
(entry) =>
|
|
77
|
+
entry !== null && typeof entry === "object" && !Array.isArray(entry),
|
|
78
|
+
)
|
|
79
|
+
) {
|
|
80
|
+
const lines = [`${indent}[{`];
|
|
81
|
+
value.forEach((entry, index) => {
|
|
82
|
+
const fields = Object.entries(entry as Record<string, unknown>);
|
|
83
|
+
fields.forEach(([key, nested], fieldIndex) => {
|
|
84
|
+
const nestedLines = formatActivityJson(nested, depth + 1);
|
|
85
|
+
const nestedIndent = " ".repeat(depth + 1);
|
|
86
|
+
lines.push(
|
|
87
|
+
`${nestedIndent}${JSON.stringify(key)}: ${nestedLines[0]!.slice(nestedIndent.length)}`,
|
|
88
|
+
...nestedLines.slice(1),
|
|
89
|
+
);
|
|
90
|
+
if (fieldIndex < fields.length - 1) {
|
|
91
|
+
lines[lines.length - 1] += ",";
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
lines.push(
|
|
95
|
+
index < value.length - 1 ? `${indent}}, {` : `${indent}}]`,
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
return lines;
|
|
99
|
+
}
|
|
100
|
+
const lines = [`${indent}[`];
|
|
101
|
+
value.forEach((entry, index) => {
|
|
102
|
+
const nestedLines = formatActivityJson(entry, depth + 1);
|
|
103
|
+
if (index < value.length - 1) {
|
|
104
|
+
nestedLines[nestedLines.length - 1] += ",";
|
|
105
|
+
}
|
|
106
|
+
lines.push(...nestedLines);
|
|
107
|
+
});
|
|
108
|
+
lines.push(`${indent}]`);
|
|
109
|
+
return lines;
|
|
110
|
+
}
|
|
111
|
+
if (value !== null && typeof value === "object") {
|
|
112
|
+
const entries = Object.entries(value as Record<string, unknown>);
|
|
113
|
+
if (entries.length === 0) return [`${indent}{}`];
|
|
114
|
+
const lines = [`${indent}{`];
|
|
115
|
+
entries.forEach(([key, nested], index) => {
|
|
116
|
+
const nestedLines = formatActivityJson(nested, depth + 1);
|
|
117
|
+
const nestedIndent = " ".repeat(depth + 1);
|
|
118
|
+
lines.push(
|
|
119
|
+
`${nestedIndent}${JSON.stringify(key)}: ${nestedLines[0]!.slice(nestedIndent.length)}`,
|
|
120
|
+
...nestedLines.slice(1),
|
|
121
|
+
);
|
|
122
|
+
if (index < entries.length - 1) lines[lines.length - 1] += ",";
|
|
123
|
+
});
|
|
124
|
+
lines.push(`${indent}}`);
|
|
125
|
+
return lines;
|
|
126
|
+
}
|
|
127
|
+
return [`${indent}${JSON.stringify(value)}`];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function serializeActivityValue(value: unknown): string {
|
|
131
|
+
const seen = new WeakSet<object>();
|
|
132
|
+
let text: string;
|
|
133
|
+
try {
|
|
134
|
+
const normalized =
|
|
135
|
+
JSON.stringify(
|
|
136
|
+
value,
|
|
137
|
+
(_key, nested) => {
|
|
138
|
+
if (typeof nested === "bigint") return nested.toString();
|
|
139
|
+
if (nested && typeof nested === "object") {
|
|
140
|
+
if (seen.has(nested)) return "[Circular]";
|
|
141
|
+
seen.add(nested);
|
|
142
|
+
}
|
|
143
|
+
return nested;
|
|
144
|
+
},
|
|
145
|
+
) ?? JSON.stringify(String(value));
|
|
146
|
+
text = formatActivityJson(JSON.parse(normalized)).join("\n");
|
|
147
|
+
} catch {
|
|
148
|
+
text = JSON.stringify(String(value));
|
|
149
|
+
}
|
|
150
|
+
const redacted = redactActivityText(text);
|
|
151
|
+
if (redacted.length <= TELEGRAM_ACTIVITY_DETAIL_MAX_CHARS) return redacted;
|
|
152
|
+
const omitted = redacted.length - TELEGRAM_ACTIVITY_DETAIL_MAX_CHARS;
|
|
153
|
+
return `${redacted.slice(0, TELEGRAM_ACTIVITY_DETAIL_MAX_CHARS)}\n… [${omitted} chars truncated]`;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function neutralizeActivityAutoLinks(text: string): string {
|
|
157
|
+
return text.replace(/\b(https?:\/\/)(?=\S)/gi, "$1\u200b");
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function escapeActivityEvidenceHtml(text: string): string {
|
|
161
|
+
return escapeHtml(neutralizeActivityAutoLinks(text));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function renderThinkingActivityEvidenceHtml(text: string): string {
|
|
165
|
+
return renderTelegramInlineMarkdownHtml(neutralizeActivityAutoLinks(text), {
|
|
166
|
+
allowLinks: false,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function formatToolActivityLabel(label: string): string {
|
|
171
|
+
return label
|
|
172
|
+
.split("_")
|
|
173
|
+
.filter(Boolean)
|
|
174
|
+
.map((word) => {
|
|
175
|
+
const repeatedPrefix = word.match(/^([a-z])\1*/iu)?.[0] ?? "";
|
|
176
|
+
if (repeatedPrefix.length === 2 || repeatedPrefix.length === 3) {
|
|
177
|
+
return `${repeatedPrefix.toUpperCase()}${word.slice(repeatedPrefix.length)}`;
|
|
178
|
+
}
|
|
179
|
+
return `${word[0]!.toUpperCase()}${word.slice(1)}`;
|
|
180
|
+
})
|
|
181
|
+
.join(" ");
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function renderToolActivityHtml(tool: ToolActivity): string {
|
|
185
|
+
const evidence = [`"arguments": ${tool.args}`];
|
|
186
|
+
if (tool.droppedUpdates > 0) {
|
|
187
|
+
evidence.push(`… [${tool.droppedUpdates} earlier updates omitted]`);
|
|
188
|
+
}
|
|
189
|
+
tool.updates.forEach((update, index) => {
|
|
190
|
+
evidence.push(
|
|
191
|
+
`"update ${tool.droppedUpdates + index + 1}": ${update}`,
|
|
192
|
+
);
|
|
193
|
+
});
|
|
194
|
+
if (tool.complete && tool.result !== undefined) {
|
|
195
|
+
evidence.push(`"${tool.isError ? "error" : "result"}": ${tool.result}`);
|
|
196
|
+
}
|
|
197
|
+
const status = tool.complete
|
|
198
|
+
? tool.isError
|
|
199
|
+
? "failed"
|
|
200
|
+
: "done"
|
|
201
|
+
: "running";
|
|
202
|
+
return [
|
|
203
|
+
`<b>${escapeHtml(formatToolActivityLabel(tool.name))}:</b> <code>${status}</code>`,
|
|
204
|
+
`<blockquote expandable>${escapeActivityEvidenceHtml(evidence.join("\n\n"))}</blockquote>`,
|
|
205
|
+
].join("\n");
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function renderTelegramToolActivityHtml(
|
|
209
|
+
tools: readonly ToolActivity[],
|
|
210
|
+
): string {
|
|
211
|
+
return tools.map(renderToolActivityHtml).join("\n\n");
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function createToolActivityDetail(
|
|
215
|
+
summary: string,
|
|
216
|
+
text: string,
|
|
217
|
+
isOpen = false,
|
|
218
|
+
): TelegramInputRichBlock {
|
|
219
|
+
return {
|
|
220
|
+
type: "details",
|
|
221
|
+
summary: { type: "code", text: summary },
|
|
222
|
+
blocks: [{ type: "pre", text, language: "json" }],
|
|
223
|
+
...(isOpen ? { is_open: true as const } : {}),
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function renderToolActivityRichBlocks(
|
|
228
|
+
tool: ToolActivity,
|
|
229
|
+
): TelegramInputRichBlock[] {
|
|
230
|
+
const status = tool.complete
|
|
231
|
+
? tool.isError
|
|
232
|
+
? "failed"
|
|
233
|
+
: "done"
|
|
234
|
+
: "running";
|
|
235
|
+
const evidenceBlocks: TelegramInputRichBlock[] = [
|
|
236
|
+
createToolActivityDetail("arguments", tool.args, true),
|
|
237
|
+
];
|
|
238
|
+
tool.updates.forEach((update, index) => {
|
|
239
|
+
const number = tool.droppedUpdates + index + 1;
|
|
240
|
+
const omitted =
|
|
241
|
+
index === 0 && tool.droppedUpdates > 0
|
|
242
|
+
? ` (${tool.droppedUpdates} earlier omitted)`
|
|
243
|
+
: "";
|
|
244
|
+
evidenceBlocks.push(
|
|
245
|
+
createToolActivityDetail(`update ${number}${omitted}`, update),
|
|
246
|
+
);
|
|
247
|
+
});
|
|
248
|
+
if (tool.complete && tool.result !== undefined) {
|
|
249
|
+
evidenceBlocks.push(
|
|
250
|
+
createToolActivityDetail(tool.isError ? "error" : "result", tool.result),
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
return [
|
|
254
|
+
{
|
|
255
|
+
type: "details",
|
|
256
|
+
summary: [
|
|
257
|
+
{
|
|
258
|
+
type: "bold",
|
|
259
|
+
text: `${formatToolActivityLabel(tool.name)}:`,
|
|
260
|
+
},
|
|
261
|
+
" ",
|
|
262
|
+
{ type: "code", text: status },
|
|
263
|
+
],
|
|
264
|
+
blocks: evidenceBlocks,
|
|
265
|
+
},
|
|
266
|
+
];
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export function renderTelegramToolActivityRichMessage(
|
|
270
|
+
tools: readonly ToolActivity[],
|
|
271
|
+
): TelegramInputRichMessage {
|
|
272
|
+
return {
|
|
273
|
+
blocks: tools.flatMap(renderToolActivityRichBlocks),
|
|
274
|
+
skip_entity_detection: true,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function toolMessageSize(tools: readonly ToolActivity[]): number {
|
|
279
|
+
return renderTelegramToolActivityHtml(tools).length;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function isKnownSafeRichActivityRejection(error: unknown): boolean {
|
|
283
|
+
return error instanceof Error && /HTTP 400: Bad Request:/i.test(error.message);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export function renderTelegramThinkingActivityHtml(text: string): string {
|
|
287
|
+
return `<blockquote expandable>${renderThinkingActivityEvidenceHtml(text)}</blockquote>`;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export interface TelegramActivityVerbosityRuntime {
|
|
291
|
+
accept: (event: TelegramActivityEvent) => void;
|
|
292
|
+
reset: () => void;
|
|
293
|
+
stop: () => void;
|
|
294
|
+
waitForIdle: () => Promise<void>;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export interface TelegramActivityVerbosityBinding
|
|
298
|
+
extends TelegramActivityVerbosityRuntime {
|
|
299
|
+
bind: (runtime: TelegramActivityVerbosityRuntime) => void;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export function createTelegramActivityVerbosityBinding(): TelegramActivityVerbosityBinding {
|
|
303
|
+
let runtime: TelegramActivityVerbosityRuntime | undefined;
|
|
304
|
+
return {
|
|
305
|
+
bind(next) {
|
|
306
|
+
runtime = next;
|
|
307
|
+
},
|
|
308
|
+
accept(event) {
|
|
309
|
+
runtime?.accept(event);
|
|
310
|
+
},
|
|
311
|
+
reset() {
|
|
312
|
+
runtime?.reset();
|
|
313
|
+
},
|
|
314
|
+
stop() {
|
|
315
|
+
runtime?.stop();
|
|
316
|
+
},
|
|
317
|
+
waitForIdle() {
|
|
318
|
+
return runtime?.waitForIdle() ?? Promise.resolve();
|
|
319
|
+
},
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export function createTelegramActivityVerbosityRuntime<TAuthority>(deps: {
|
|
324
|
+
getActivityMode: () => "quiet" | "thinking" | "tools" | "verbose";
|
|
325
|
+
refreshActivityMode?: () => Promise<void>;
|
|
326
|
+
getNowMs?: () => number;
|
|
327
|
+
resolveTarget: (event: TelegramActivityEvent) => TelegramTarget | undefined;
|
|
328
|
+
captureAuthority: () => TAuthority;
|
|
329
|
+
isAuthorityActive: (authority: TAuthority) => boolean;
|
|
330
|
+
sendMessage: (body: TelegramSendMessageBody) => Promise<TelegramSentMessage>;
|
|
331
|
+
sendRichMessage: (
|
|
332
|
+
body: TelegramSendRichMessageBody,
|
|
333
|
+
) => Promise<TelegramSentMessage>;
|
|
334
|
+
editMessageText: (
|
|
335
|
+
body: TelegramEditMessageTextBody,
|
|
336
|
+
) => Promise<"edited" | "unchanged">;
|
|
337
|
+
recordFailure?: (
|
|
338
|
+
operation:
|
|
339
|
+
| "config-refresh"
|
|
340
|
+
| "reasoning-send"
|
|
341
|
+
| "reasoning-edit"
|
|
342
|
+
| "tool-send"
|
|
343
|
+
| "tool-edit",
|
|
344
|
+
event: TelegramActivityEvent,
|
|
345
|
+
error: unknown,
|
|
346
|
+
) => void;
|
|
347
|
+
}): TelegramActivityVerbosityRuntime {
|
|
348
|
+
let active = true;
|
|
349
|
+
let generation = 0;
|
|
350
|
+
let tail = Promise.resolve();
|
|
351
|
+
const getNowMs = deps.getNowMs ?? Date.now;
|
|
352
|
+
let activityId: string | undefined;
|
|
353
|
+
let authority: TAuthority | undefined;
|
|
354
|
+
let target: TelegramTarget | undefined;
|
|
355
|
+
let reasoningBuffer = "";
|
|
356
|
+
let reasoningChars = 0;
|
|
357
|
+
let reasoningMessageFrames = 0;
|
|
358
|
+
let lastReasoningMessageChars = 0;
|
|
359
|
+
let reasoningMessage: ReasoningMessage | undefined;
|
|
360
|
+
let reasoningBlocked = false;
|
|
361
|
+
let lastReasoningPublishMs = 0;
|
|
362
|
+
let toolMessage: ToolMessage | undefined;
|
|
363
|
+
const tools = new Map<string, ToolActivity>();
|
|
364
|
+
const toolOrder: string[] = [];
|
|
365
|
+
|
|
366
|
+
const clearActivity = () => {
|
|
367
|
+
activityId = undefined;
|
|
368
|
+
authority = undefined;
|
|
369
|
+
target = undefined;
|
|
370
|
+
reasoningBuffer = "";
|
|
371
|
+
reasoningChars = 0;
|
|
372
|
+
reasoningMessageFrames = 0;
|
|
373
|
+
lastReasoningMessageChars = 0;
|
|
374
|
+
reasoningMessage = undefined;
|
|
375
|
+
reasoningBlocked = false;
|
|
376
|
+
lastReasoningPublishMs = 0;
|
|
377
|
+
toolMessage = undefined;
|
|
378
|
+
tools.clear();
|
|
379
|
+
toolOrder.length = 0;
|
|
380
|
+
};
|
|
381
|
+
const hasAuthority = (): boolean =>
|
|
382
|
+
authority !== undefined && deps.isAuthorityActive(authority);
|
|
383
|
+
const ensureActivity = (event: TelegramActivityEvent): boolean => {
|
|
384
|
+
if (deps.getActivityMode() === "quiet") return false;
|
|
385
|
+
if (activityId === event.activityId) return hasAuthority();
|
|
386
|
+
clearActivity();
|
|
387
|
+
const resolvedTarget = deps.resolveTarget(event);
|
|
388
|
+
if (!resolvedTarget) return false;
|
|
389
|
+
activityId = event.activityId;
|
|
390
|
+
target = { ...resolvedTarget };
|
|
391
|
+
authority = deps.captureAuthority();
|
|
392
|
+
return hasAuthority();
|
|
393
|
+
};
|
|
394
|
+
const closeToolBatch = () => {
|
|
395
|
+
toolMessage = undefined;
|
|
396
|
+
};
|
|
397
|
+
const publishReasoning = async (
|
|
398
|
+
event: TelegramActivityEvent,
|
|
399
|
+
acceptedGeneration: number,
|
|
400
|
+
) => {
|
|
401
|
+
if (
|
|
402
|
+
generation !== acceptedGeneration ||
|
|
403
|
+
!target ||
|
|
404
|
+
!hasAuthority() ||
|
|
405
|
+
reasoningBlocked
|
|
406
|
+
) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
let retained = reasoningBuffer;
|
|
410
|
+
let body = "";
|
|
411
|
+
do {
|
|
412
|
+
const omitted = reasoningChars - retained.length;
|
|
413
|
+
const text = redactActivityText(
|
|
414
|
+
omitted > 0
|
|
415
|
+
? `… [${omitted} earlier chars omitted]\n${retained}`
|
|
416
|
+
: retained,
|
|
417
|
+
);
|
|
418
|
+
body = renderTelegramThinkingActivityHtml(text);
|
|
419
|
+
if (body.length <= TELEGRAM_ACTIVITY_MESSAGE_MAX_CHARS) break;
|
|
420
|
+
retained = retained.slice(-Math.max(1, Math.floor(retained.length * 0.75)));
|
|
421
|
+
} while (retained.length > 1);
|
|
422
|
+
const canEdit =
|
|
423
|
+
reasoningMessage && targetEquals(reasoningMessage.target, target);
|
|
424
|
+
try {
|
|
425
|
+
if (canEdit && reasoningMessage) {
|
|
426
|
+
await deps.editMessageText({
|
|
427
|
+
chat_id: target.chatId,
|
|
428
|
+
message_id: reasoningMessage.messageId,
|
|
429
|
+
text: body,
|
|
430
|
+
parse_mode: "HTML",
|
|
431
|
+
link_preview_options: { is_disabled: true },
|
|
432
|
+
});
|
|
433
|
+
} else {
|
|
434
|
+
const sent = await deps.sendMessage({
|
|
435
|
+
chat_id: target.chatId,
|
|
436
|
+
...(target.threadId === undefined
|
|
437
|
+
? {}
|
|
438
|
+
: { message_thread_id: target.threadId }),
|
|
439
|
+
text: body,
|
|
440
|
+
parse_mode: "HTML",
|
|
441
|
+
link_preview_options: { is_disabled: true },
|
|
442
|
+
});
|
|
443
|
+
reasoningMessage = {
|
|
444
|
+
messageId: sent.message_id,
|
|
445
|
+
target: { ...target },
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
if (generation !== acceptedGeneration) return;
|
|
449
|
+
reasoningMessageFrames += 1;
|
|
450
|
+
lastReasoningMessageChars = reasoningChars;
|
|
451
|
+
lastReasoningPublishMs = getNowMs();
|
|
452
|
+
} catch (error) {
|
|
453
|
+
deps.recordFailure?.(
|
|
454
|
+
canEdit ? "reasoning-edit" : "reasoning-send",
|
|
455
|
+
event,
|
|
456
|
+
error,
|
|
457
|
+
);
|
|
458
|
+
reasoningBlocked = true;
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
const publishTool = async (
|
|
462
|
+
event: TelegramActivityEvent,
|
|
463
|
+
tool: ToolActivity,
|
|
464
|
+
acceptedGeneration: number,
|
|
465
|
+
) => {
|
|
466
|
+
if (
|
|
467
|
+
generation !== acceptedGeneration ||
|
|
468
|
+
!target ||
|
|
469
|
+
!hasAuthority()
|
|
470
|
+
) {
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
const canAppend =
|
|
474
|
+
toolMessage &&
|
|
475
|
+
targetEquals(toolMessage.target, target) &&
|
|
476
|
+
toolMessage.tools.length < TELEGRAM_ACTIVITY_MESSAGE_MAX_TOOLS &&
|
|
477
|
+
toolMessageSize([...toolMessage.tools, tool]) <=
|
|
478
|
+
TELEGRAM_ACTIVITY_MESSAGE_MAX_CHARS;
|
|
479
|
+
try {
|
|
480
|
+
if (canAppend && toolMessage) {
|
|
481
|
+
const nextTools = [...toolMessage.tools, tool];
|
|
482
|
+
try {
|
|
483
|
+
await deps.editMessageText({
|
|
484
|
+
chat_id: target.chatId,
|
|
485
|
+
message_id: toolMessage.messageId,
|
|
486
|
+
...(toolMessage.format === "rich"
|
|
487
|
+
? {
|
|
488
|
+
rich_message:
|
|
489
|
+
renderTelegramToolActivityRichMessage(nextTools),
|
|
490
|
+
}
|
|
491
|
+
: {
|
|
492
|
+
text: renderTelegramToolActivityHtml(nextTools),
|
|
493
|
+
parse_mode: "HTML" as const,
|
|
494
|
+
link_preview_options: { is_disabled: true },
|
|
495
|
+
}),
|
|
496
|
+
});
|
|
497
|
+
} catch (error) {
|
|
498
|
+
if (
|
|
499
|
+
toolMessage.format !== "rich" ||
|
|
500
|
+
!isKnownSafeRichActivityRejection(error)
|
|
501
|
+
) {
|
|
502
|
+
throw error;
|
|
503
|
+
}
|
|
504
|
+
await deps.editMessageText({
|
|
505
|
+
chat_id: target.chatId,
|
|
506
|
+
message_id: toolMessage.messageId,
|
|
507
|
+
text: renderTelegramToolActivityHtml(nextTools),
|
|
508
|
+
parse_mode: "HTML",
|
|
509
|
+
link_preview_options: { is_disabled: true },
|
|
510
|
+
});
|
|
511
|
+
toolMessage.format = "html";
|
|
512
|
+
}
|
|
513
|
+
if (generation !== acceptedGeneration) return;
|
|
514
|
+
toolMessage.tools = nextTools;
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
const body = {
|
|
518
|
+
chat_id: target.chatId,
|
|
519
|
+
...(target.threadId === undefined
|
|
520
|
+
? {}
|
|
521
|
+
: { message_thread_id: target.threadId }),
|
|
522
|
+
};
|
|
523
|
+
let sent: TelegramSentMessage;
|
|
524
|
+
let format: ToolMessage["format"] = "rich";
|
|
525
|
+
try {
|
|
526
|
+
sent = await deps.sendRichMessage({
|
|
527
|
+
...body,
|
|
528
|
+
rich_message: renderTelegramToolActivityRichMessage([tool]),
|
|
529
|
+
});
|
|
530
|
+
} catch (error) {
|
|
531
|
+
if (!isKnownSafeRichActivityRejection(error)) throw error;
|
|
532
|
+
sent = await deps.sendMessage({
|
|
533
|
+
...body,
|
|
534
|
+
text: renderTelegramToolActivityHtml([tool]),
|
|
535
|
+
parse_mode: "HTML",
|
|
536
|
+
link_preview_options: { is_disabled: true },
|
|
537
|
+
});
|
|
538
|
+
format = "html";
|
|
539
|
+
}
|
|
540
|
+
if (generation !== acceptedGeneration) return;
|
|
541
|
+
toolMessage = {
|
|
542
|
+
messageId: sent.message_id,
|
|
543
|
+
tools: [tool],
|
|
544
|
+
target: { ...target },
|
|
545
|
+
format,
|
|
546
|
+
};
|
|
547
|
+
} catch (error) {
|
|
548
|
+
deps.recordFailure?.(canAppend ? "tool-edit" : "tool-send", event, error);
|
|
549
|
+
closeToolBatch();
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
const process = async (
|
|
553
|
+
event: TelegramActivityEvent,
|
|
554
|
+
acceptedGeneration: number,
|
|
555
|
+
) => {
|
|
556
|
+
if (event.type === "agent-start" && deps.refreshActivityMode) {
|
|
557
|
+
try {
|
|
558
|
+
await deps.refreshActivityMode();
|
|
559
|
+
} catch (error) {
|
|
560
|
+
deps.recordFailure?.("config-refresh", event, error);
|
|
561
|
+
clearActivity();
|
|
562
|
+
activityId = event.activityId;
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
if (!ensureActivity(event)) {
|
|
567
|
+
if (
|
|
568
|
+
activityId === event.activityId &&
|
|
569
|
+
deps.getActivityMode() === "quiet"
|
|
570
|
+
) {
|
|
571
|
+
clearActivity();
|
|
572
|
+
}
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
const mode = deps.getActivityMode();
|
|
576
|
+
const showThinking = mode === "thinking" || mode === "verbose";
|
|
577
|
+
const showTools = mode === "tools" || mode === "verbose";
|
|
578
|
+
if (
|
|
579
|
+
event.type === "assistant-text-delta" ||
|
|
580
|
+
event.type === "assistant-segment" ||
|
|
581
|
+
event.type === "reasoning-delta" ||
|
|
582
|
+
event.type === "reasoning-end"
|
|
583
|
+
) {
|
|
584
|
+
closeToolBatch();
|
|
585
|
+
}
|
|
586
|
+
if (event.type === "reasoning-delta") {
|
|
587
|
+
if (!showThinking) return;
|
|
588
|
+
reasoningChars += event.delta.length;
|
|
589
|
+
reasoningBuffer = `${reasoningBuffer}${event.delta}`.slice(
|
|
590
|
+
-TELEGRAM_REASONING_BUFFER_MAX_CHARS,
|
|
591
|
+
);
|
|
592
|
+
if (reasoningMessageFrames < TELEGRAM_REASONING_MESSAGE_MAX_FRAMES &&
|
|
593
|
+
(reasoningMessageFrames === 0 ||
|
|
594
|
+
(getNowMs() - lastReasoningPublishMs >=
|
|
595
|
+
TELEGRAM_REASONING_MIN_INTERVAL_MS &&
|
|
596
|
+
reasoningChars - lastReasoningMessageChars >= 160))
|
|
597
|
+
) {
|
|
598
|
+
await publishReasoning(event, acceptedGeneration);
|
|
599
|
+
}
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
if (event.type === "reasoning-end") {
|
|
603
|
+
if (!showThinking) return;
|
|
604
|
+
if (reasoningChars === 0 && event.text) {
|
|
605
|
+
reasoningChars = event.text.length;
|
|
606
|
+
reasoningBuffer = event.text.slice(
|
|
607
|
+
-TELEGRAM_REASONING_BUFFER_MAX_CHARS,
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
if (
|
|
611
|
+
reasoningChars > 0 &&
|
|
612
|
+
reasoningChars > lastReasoningMessageChars &&
|
|
613
|
+
!reasoningBlocked
|
|
614
|
+
) {
|
|
615
|
+
await publishReasoning(event, acceptedGeneration);
|
|
616
|
+
}
|
|
617
|
+
reasoningBuffer = "";
|
|
618
|
+
reasoningChars = 0;
|
|
619
|
+
reasoningMessageFrames = 0;
|
|
620
|
+
lastReasoningMessageChars = 0;
|
|
621
|
+
lastReasoningPublishMs = 0;
|
|
622
|
+
reasoningMessage = undefined;
|
|
623
|
+
reasoningBlocked = false;
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
if (event.type === "tool-start") {
|
|
627
|
+
if (!showTools) return;
|
|
628
|
+
tools.set(event.toolCallId, {
|
|
629
|
+
id: event.toolCallId,
|
|
630
|
+
name: event.toolName,
|
|
631
|
+
args: serializeActivityValue(event.args),
|
|
632
|
+
updates: [],
|
|
633
|
+
droppedUpdates: 0,
|
|
634
|
+
complete: false,
|
|
635
|
+
});
|
|
636
|
+
toolOrder.push(event.toolCallId);
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
if (event.type === "tool-update") {
|
|
640
|
+
if (!showTools) return;
|
|
641
|
+
const tool = tools.get(event.toolCallId);
|
|
642
|
+
if (!tool) return;
|
|
643
|
+
tool.updates.push(serializeActivityValue(event.update));
|
|
644
|
+
if (tool.updates.length > TELEGRAM_TOOL_UPDATE_MAX_ENTRIES) {
|
|
645
|
+
tool.updates.shift();
|
|
646
|
+
tool.droppedUpdates += 1;
|
|
647
|
+
}
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
if (event.type === "tool-end") {
|
|
651
|
+
if (!showTools) return;
|
|
652
|
+
const tool = tools.get(event.toolCallId) ?? {
|
|
653
|
+
id: event.toolCallId,
|
|
654
|
+
name: event.toolName,
|
|
655
|
+
args: serializeActivityValue(undefined),
|
|
656
|
+
updates: [],
|
|
657
|
+
droppedUpdates: 0,
|
|
658
|
+
complete: false,
|
|
659
|
+
};
|
|
660
|
+
if (!tools.has(event.toolCallId)) toolOrder.push(event.toolCallId);
|
|
661
|
+
tool.result = serializeActivityValue(event.result);
|
|
662
|
+
tool.isError = event.isError;
|
|
663
|
+
tool.complete = true;
|
|
664
|
+
tools.set(event.toolCallId, tool);
|
|
665
|
+
while (toolOrder.length > 0) {
|
|
666
|
+
const next = tools.get(toolOrder[0]!);
|
|
667
|
+
if (!next?.complete) break;
|
|
668
|
+
toolOrder.shift();
|
|
669
|
+
tools.delete(next.id);
|
|
670
|
+
await publishTool(event, next, acceptedGeneration);
|
|
671
|
+
if (generation !== acceptedGeneration) return;
|
|
672
|
+
}
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
if (event.type === "agent-end" || event.type === "agent-settled") {
|
|
676
|
+
if (
|
|
677
|
+
reasoningMessage &&
|
|
678
|
+
reasoningChars > lastReasoningMessageChars &&
|
|
679
|
+
!reasoningBlocked
|
|
680
|
+
) {
|
|
681
|
+
await publishReasoning(event, acceptedGeneration);
|
|
682
|
+
}
|
|
683
|
+
clearActivity();
|
|
684
|
+
}
|
|
685
|
+
};
|
|
686
|
+
return {
|
|
687
|
+
accept(event) {
|
|
688
|
+
if (!active) return;
|
|
689
|
+
const acceptedGeneration = generation;
|
|
690
|
+
tail = tail
|
|
691
|
+
.then(() => {
|
|
692
|
+
if (!active || generation !== acceptedGeneration) return;
|
|
693
|
+
return process(event, acceptedGeneration);
|
|
694
|
+
})
|
|
695
|
+
.catch((error) => {
|
|
696
|
+
deps.recordFailure?.("tool-send", event, error);
|
|
697
|
+
});
|
|
698
|
+
},
|
|
699
|
+
reset() {
|
|
700
|
+
generation += 1;
|
|
701
|
+
clearActivity();
|
|
702
|
+
tail = Promise.resolve();
|
|
703
|
+
},
|
|
704
|
+
stop() {
|
|
705
|
+
active = false;
|
|
706
|
+
generation += 1;
|
|
707
|
+
clearActivity();
|
|
708
|
+
tail = Promise.resolve();
|
|
709
|
+
},
|
|
710
|
+
waitForIdle() {
|
|
711
|
+
return tail;
|
|
712
|
+
},
|
|
713
|
+
};
|
|
714
|
+
}
|