@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.
Files changed (523) hide show
  1. package/AGENTS.md +35 -0
  2. package/BACKLOG.md +3 -0
  3. package/CHANGELOG.md +9 -0
  4. package/LICENSE +21 -0
  5. package/README.md +43 -0
  6. package/node_modules/@llblab/pi-actors/AGENTS.md +150 -0
  7. package/node_modules/@llblab/pi-actors/BACKLOG.md +6 -0
  8. package/node_modules/@llblab/pi-actors/CHANGELOG.md +865 -0
  9. package/node_modules/@llblab/pi-actors/README.md +231 -0
  10. package/node_modules/@llblab/pi-actors/banner.jpg +0 -0
  11. package/node_modules/@llblab/pi-actors/dist/fixtures/protocol/artifact-manifest.json +9 -0
  12. package/node_modules/@llblab/pi-actors/dist/fixtures/protocol/control-endpoint.json +6 -0
  13. package/node_modules/@llblab/pi-actors/dist/fixtures/protocol/control-record.json +9 -0
  14. package/node_modules/@llblab/pi-actors/dist/fixtures/protocol/recipe-summary.json +8 -0
  15. package/node_modules/@llblab/pi-actors/dist/fixtures/protocol/run-state.json +10 -0
  16. package/node_modules/@llblab/pi-actors/dist/fixtures/protocol/trace-event.json +9 -0
  17. package/node_modules/@llblab/pi-actors/dist/index.d.ts +7 -0
  18. package/node_modules/@llblab/pi-actors/dist/index.js +17 -0
  19. package/node_modules/@llblab/pi-actors/dist/lib/async-runs.d.ts +146 -0
  20. package/node_modules/@llblab/pi-actors/dist/lib/async-runs.js +800 -0
  21. package/node_modules/@llblab/pi-actors/dist/lib/automatic-review-runtime.d.ts +20 -0
  22. package/node_modules/@llblab/pi-actors/dist/lib/automatic-review-runtime.js +103 -0
  23. package/node_modules/@llblab/pi-actors/dist/lib/command-templates.d.ts +85 -0
  24. package/node_modules/@llblab/pi-actors/dist/lib/command-templates.js +804 -0
  25. package/node_modules/@llblab/pi-actors/dist/lib/config.d.ts +34 -0
  26. package/node_modules/@llblab/pi-actors/dist/lib/config.js +216 -0
  27. package/node_modules/@llblab/pi-actors/dist/lib/control-projection.d.ts +20 -0
  28. package/node_modules/@llblab/pi-actors/dist/lib/control-projection.js +66 -0
  29. package/node_modules/@llblab/pi-actors/dist/lib/control.d.ts +15 -0
  30. package/node_modules/@llblab/pi-actors/dist/lib/control.js +97 -0
  31. package/node_modules/@llblab/pi-actors/dist/lib/draft-consolidation-transaction.d.ts +65 -0
  32. package/node_modules/@llblab/pi-actors/dist/lib/draft-consolidation-transaction.js +610 -0
  33. package/node_modules/@llblab/pi-actors/dist/lib/draft-consolidation.d.ts +35 -0
  34. package/node_modules/@llblab/pi-actors/dist/lib/draft-consolidation.js +126 -0
  35. package/node_modules/@llblab/pi-actors/dist/lib/draft-review.d.ts +56 -0
  36. package/node_modules/@llblab/pi-actors/dist/lib/draft-review.js +254 -0
  37. package/node_modules/@llblab/pi-actors/dist/lib/draft-sleep.d.ts +65 -0
  38. package/node_modules/@llblab/pi-actors/dist/lib/draft-sleep.js +467 -0
  39. package/node_modules/@llblab/pi-actors/dist/lib/execution-output.d.ts +25 -0
  40. package/node_modules/@llblab/pi-actors/dist/lib/execution-output.js +88 -0
  41. package/node_modules/@llblab/pi-actors/dist/lib/execution-sessions.d.ts +17 -0
  42. package/node_modules/@llblab/pi-actors/dist/lib/execution-sessions.js +85 -0
  43. package/node_modules/@llblab/pi-actors/dist/lib/execution.d.ts +99 -0
  44. package/node_modules/@llblab/pi-actors/dist/lib/execution.js +725 -0
  45. package/node_modules/@llblab/pi-actors/dist/lib/extension-runtime.d.ts +21 -0
  46. package/node_modules/@llblab/pi-actors/dist/lib/extension-runtime.js +141 -0
  47. package/node_modules/@llblab/pi-actors/dist/lib/file-state.d.ts +18 -0
  48. package/node_modules/@llblab/pi-actors/dist/lib/file-state.js +310 -0
  49. package/node_modules/@llblab/pi-actors/dist/lib/identity.d.ts +9 -0
  50. package/node_modules/@llblab/pi-actors/dist/lib/identity.js +27 -0
  51. package/node_modules/@llblab/pi-actors/dist/lib/inspector-actions.d.ts +16 -0
  52. package/node_modules/@llblab/pi-actors/dist/lib/inspector-actions.js +57 -0
  53. package/node_modules/@llblab/pi-actors/dist/lib/inspector-command.d.ts +7 -0
  54. package/node_modules/@llblab/pi-actors/dist/lib/inspector-command.js +37 -0
  55. package/node_modules/@llblab/pi-actors/dist/lib/inspector-overlay.d.ts +100 -0
  56. package/node_modules/@llblab/pi-actors/dist/lib/inspector-overlay.js +824 -0
  57. package/node_modules/@llblab/pi-actors/dist/lib/inspector.d.ts +20 -0
  58. package/node_modules/@llblab/pi-actors/dist/lib/inspector.js +136 -0
  59. package/node_modules/@llblab/pi-actors/dist/lib/limits.d.ts +28 -0
  60. package/node_modules/@llblab/pi-actors/dist/lib/limits.js +28 -0
  61. package/node_modules/@llblab/pi-actors/dist/lib/model-context.d.ts +56 -0
  62. package/node_modules/@llblab/pi-actors/dist/lib/model-context.js +220 -0
  63. package/node_modules/@llblab/pi-actors/dist/lib/observability.d.ts +186 -0
  64. package/node_modules/@llblab/pi-actors/dist/lib/observability.js +951 -0
  65. package/node_modules/@llblab/pi-actors/dist/lib/paths.d.ts +27 -0
  66. package/node_modules/@llblab/pi-actors/dist/lib/paths.js +72 -0
  67. package/node_modules/@llblab/pi-actors/dist/lib/pi.d.ts +19 -0
  68. package/node_modules/@llblab/pi-actors/dist/lib/pi.js +21 -0
  69. package/node_modules/@llblab/pi-actors/dist/lib/preflight-diagnostics.d.ts +27 -0
  70. package/node_modules/@llblab/pi-actors/dist/lib/preflight-diagnostics.js +86 -0
  71. package/node_modules/@llblab/pi-actors/dist/lib/prompts.d.ts +24 -0
  72. package/node_modules/@llblab/pi-actors/dist/lib/prompts.js +49 -0
  73. package/node_modules/@llblab/pi-actors/dist/lib/recipe-control.d.ts +7 -0
  74. package/node_modules/@llblab/pi-actors/dist/lib/recipe-control.js +43 -0
  75. package/node_modules/@llblab/pi-actors/dist/lib/recipes-context.d.ts +36 -0
  76. package/node_modules/@llblab/pi-actors/dist/lib/recipes-context.js +197 -0
  77. package/node_modules/@llblab/pi-actors/dist/lib/recipes-discovery.d.ts +77 -0
  78. package/node_modules/@llblab/pi-actors/dist/lib/recipes-discovery.js +783 -0
  79. package/node_modules/@llblab/pi-actors/dist/lib/recipes-references.d.ts +113 -0
  80. package/node_modules/@llblab/pi-actors/dist/lib/recipes-references.js +1108 -0
  81. package/node_modules/@llblab/pi-actors/dist/lib/recipes-usage.d.ts +21 -0
  82. package/node_modules/@llblab/pi-actors/dist/lib/recipes-usage.js +494 -0
  83. package/node_modules/@llblab/pi-actors/dist/lib/registry.d.ts +67 -0
  84. package/node_modules/@llblab/pi-actors/dist/lib/registry.js +504 -0
  85. package/node_modules/@llblab/pi-actors/dist/lib/review-control.d.ts +14 -0
  86. package/node_modules/@llblab/pi-actors/dist/lib/review-control.js +110 -0
  87. package/node_modules/@llblab/pi-actors/dist/lib/review-diagnostics.d.ts +11 -0
  88. package/node_modules/@llblab/pi-actors/dist/lib/review-diagnostics.js +148 -0
  89. package/node_modules/@llblab/pi-actors/dist/lib/review-projection.d.ts +14 -0
  90. package/node_modules/@llblab/pi-actors/dist/lib/review-projection.js +166 -0
  91. package/node_modules/@llblab/pi-actors/dist/lib/run-evidence-policy.d.ts +95 -0
  92. package/node_modules/@llblab/pi-actors/dist/lib/run-evidence-policy.js +177 -0
  93. package/node_modules/@llblab/pi-actors/dist/lib/run-ui-runtime.d.ts +18 -0
  94. package/node_modules/@llblab/pi-actors/dist/lib/run-ui-runtime.js +125 -0
  95. package/node_modules/@llblab/pi-actors/dist/lib/runs-artifacts.d.ts +21 -0
  96. package/node_modules/@llblab/pi-actors/dist/lib/runs-artifacts.js +68 -0
  97. package/node_modules/@llblab/pi-actors/dist/lib/runs-control-delivery.d.ts +28 -0
  98. package/node_modules/@llblab/pi-actors/dist/lib/runs-control-delivery.js +150 -0
  99. package/node_modules/@llblab/pi-actors/dist/lib/runs-control.d.ts +21 -0
  100. package/node_modules/@llblab/pi-actors/dist/lib/runs-control.js +89 -0
  101. package/node_modules/@llblab/pi-actors/dist/lib/runs-controls.d.ts +39 -0
  102. package/node_modules/@llblab/pi-actors/dist/lib/runs-controls.js +283 -0
  103. package/node_modules/@llblab/pi-actors/dist/lib/runs-identity.d.ts +5 -0
  104. package/node_modules/@llblab/pi-actors/dist/lib/runs-identity.js +11 -0
  105. package/node_modules/@llblab/pi-actors/dist/lib/runs-index.d.ts +27 -0
  106. package/node_modules/@llblab/pi-actors/dist/lib/runs-index.js +142 -0
  107. package/node_modules/@llblab/pi-actors/dist/lib/runs-ownership.d.ts +7 -0
  108. package/node_modules/@llblab/pi-actors/dist/lib/runs-ownership.js +96 -0
  109. package/node_modules/@llblab/pi-actors/dist/lib/runs-parent-teardown.d.ts +51 -0
  110. package/node_modules/@llblab/pi-actors/dist/lib/runs-parent-teardown.js +172 -0
  111. package/node_modules/@llblab/pi-actors/dist/lib/runs-process.d.ts +22 -0
  112. package/node_modules/@llblab/pi-actors/dist/lib/runs-process.js +125 -0
  113. package/node_modules/@llblab/pi-actors/dist/lib/runs-retention.d.ts +18 -0
  114. package/node_modules/@llblab/pi-actors/dist/lib/runs-retention.js +108 -0
  115. package/node_modules/@llblab/pi-actors/dist/lib/runs-start.d.ts +12 -0
  116. package/node_modules/@llblab/pi-actors/dist/lib/runs-start.js +68 -0
  117. package/node_modules/@llblab/pi-actors/dist/lib/runs-status.d.ts +10 -0
  118. package/node_modules/@llblab/pi-actors/dist/lib/runs-status.js +68 -0
  119. package/node_modules/@llblab/pi-actors/dist/lib/runs-trace.d.ts +48 -0
  120. package/node_modules/@llblab/pi-actors/dist/lib/runs-trace.js +491 -0
  121. package/node_modules/@llblab/pi-actors/dist/lib/runtime-identity.d.ts +7 -0
  122. package/node_modules/@llblab/pi-actors/dist/lib/runtime-identity.js +35 -0
  123. package/node_modules/@llblab/pi-actors/dist/lib/runtime-triage.d.ts +29 -0
  124. package/node_modules/@llblab/pi-actors/dist/lib/runtime-triage.js +60 -0
  125. package/node_modules/@llblab/pi-actors/dist/lib/runtime.d.ts +69 -0
  126. package/node_modules/@llblab/pi-actors/dist/lib/runtime.js +339 -0
  127. package/node_modules/@llblab/pi-actors/dist/lib/schema.d.ts +60 -0
  128. package/node_modules/@llblab/pi-actors/dist/lib/schema.js +428 -0
  129. package/node_modules/@llblab/pi-actors/dist/lib/session-evidence.d.ts +45 -0
  130. package/node_modules/@llblab/pi-actors/dist/lib/session-evidence.js +204 -0
  131. package/node_modules/@llblab/pi-actors/dist/lib/state-readers.d.ts +21 -0
  132. package/node_modules/@llblab/pi-actors/dist/lib/state-readers.js +74 -0
  133. package/node_modules/@llblab/pi-actors/dist/lib/temp.d.ts +10 -0
  134. package/node_modules/@llblab/pi-actors/dist/lib/temp.js +90 -0
  135. package/node_modules/@llblab/pi-actors/dist/lib/tool-review-lineage-transaction.d.ts +27 -0
  136. package/node_modules/@llblab/pi-actors/dist/lib/tool-review-lineage-transaction.js +597 -0
  137. package/node_modules/@llblab/pi-actors/dist/lib/tool-review-lineage.d.ts +24 -0
  138. package/node_modules/@llblab/pi-actors/dist/lib/tool-review-lineage.js +98 -0
  139. package/node_modules/@llblab/pi-actors/dist/lib/tool-review-scheduler.d.ts +80 -0
  140. package/node_modules/@llblab/pi-actors/dist/lib/tool-review-scheduler.js +494 -0
  141. package/node_modules/@llblab/pi-actors/dist/lib/tool-review-transaction.d.ts +50 -0
  142. package/node_modules/@llblab/pi-actors/dist/lib/tool-review-transaction.js +362 -0
  143. package/node_modules/@llblab/pi-actors/dist/lib/tool-review.d.ts +56 -0
  144. package/node_modules/@llblab/pi-actors/dist/lib/tool-review.js +197 -0
  145. package/node_modules/@llblab/pi-actors/dist/lib/tools-access.d.ts +19 -0
  146. package/node_modules/@llblab/pi-actors/dist/lib/tools-access.js +44 -0
  147. package/node_modules/@llblab/pi-actors/dist/lib/tools-inspect.d.ts +15 -0
  148. package/node_modules/@llblab/pi-actors/dist/lib/tools-inspect.js +532 -0
  149. package/node_modules/@llblab/pi-actors/dist/lib/tools-local.d.ts +17 -0
  150. package/node_modules/@llblab/pi-actors/dist/lib/tools-local.js +191 -0
  151. package/node_modules/@llblab/pi-actors/dist/lib/tools-message.d.ts +9 -0
  152. package/node_modules/@llblab/pi-actors/dist/lib/tools-message.js +139 -0
  153. package/node_modules/@llblab/pi-actors/dist/lib/tools-register.d.ts +18 -0
  154. package/node_modules/@llblab/pi-actors/dist/lib/tools-register.js +41 -0
  155. package/node_modules/@llblab/pi-actors/dist/lib/tools-response.d.ts +20 -0
  156. package/node_modules/@llblab/pi-actors/dist/lib/tools-response.js +243 -0
  157. package/node_modules/@llblab/pi-actors/dist/lib/tools-spawn.d.ts +15 -0
  158. package/node_modules/@llblab/pi-actors/dist/lib/tools-spawn.js +133 -0
  159. package/node_modules/@llblab/pi-actors/dist/lib/tools.d.ts +28 -0
  160. package/node_modules/@llblab/pi-actors/dist/lib/tools.js +49 -0
  161. package/node_modules/@llblab/pi-actors/dist/lib/trace-projection.d.ts +22 -0
  162. package/node_modules/@llblab/pi-actors/dist/lib/trace-projection.js +231 -0
  163. package/node_modules/@llblab/pi-actors/dist/pi-actors/index.js +1 -0
  164. package/node_modules/@llblab/pi-actors/dist/scripts/async-runner.mjs +555 -0
  165. package/node_modules/@llblab/pi-actors/dist/scripts/build-dist.mjs +60 -0
  166. package/node_modules/@llblab/pi-actors/dist/scripts/conformance.mjs +63 -0
  167. package/node_modules/@llblab/pi-actors/dist/skills/actors/SKILL.md +126 -0
  168. package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/command-validate.json +13 -0
  169. package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/jsonl-tail.json +10 -0
  170. package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/recipe-validate.json +11 -0
  171. package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/resource-locker-snapshot.json +11 -0
  172. package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/resource-locker.json +25 -0
  173. package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/run-ops-snapshot.json +15 -0
  174. package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/run-state-files.json +13 -0
  175. package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/run-summary.json +9 -0
  176. package/node_modules/@llblab/pi-actors/dist/skills/actors/references/diagnostics.md +44 -0
  177. package/node_modules/@llblab/pi-actors/dist/skills/actors/references/persistent-tools.md +76 -0
  178. package/node_modules/@llblab/pi-actors/dist/skills/actors/references/recipes.md +51 -0
  179. package/node_modules/@llblab/pi-actors/dist/skills/actors/references/runs.md +41 -0
  180. package/node_modules/@llblab/pi-actors/dist/skills/actors/scripts/resource-locker.mjs +425 -0
  181. package/node_modules/@llblab/pi-actors/dist/skills/actors/scripts/run-utils.mjs +164 -0
  182. package/node_modules/@llblab/pi-actors/dist/skills/actors/scripts/validate-recipe.mjs +370 -0
  183. package/node_modules/@llblab/pi-actors/dist/skills/artifacts/SKILL.md +33 -0
  184. package/node_modules/@llblab/pi-actors/dist/skills/artifacts/recipes/bundle.json +77 -0
  185. package/node_modules/@llblab/pi-actors/dist/skills/artifacts/recipes/file-write.json +14 -0
  186. package/node_modules/@llblab/pi-actors/dist/skills/artifacts/recipes/manifest.json +14 -0
  187. package/node_modules/@llblab/pi-actors/dist/skills/artifacts/recipes/report.json +39 -0
  188. package/node_modules/@llblab/pi-actors/dist/skills/artifacts/recipes/write.json +53 -0
  189. package/node_modules/@llblab/pi-actors/dist/skills/artifacts/scripts/artifact-utils.mjs +63 -0
  190. package/node_modules/@llblab/pi-actors/dist/skills/music-player/SKILL.md +57 -0
  191. package/node_modules/@llblab/pi-actors/dist/skills/music-player/genapps/music-player.mjs +360 -0
  192. package/node_modules/@llblab/pi-actors/dist/skills/music-player/recipes/playback.json +29 -0
  193. package/node_modules/@llblab/pi-actors/dist/skills/music-player/scripts/playback-client.mjs +143 -0
  194. package/node_modules/@llblab/pi-actors/dist/skills/music-player/scripts/playback.mjs +1446 -0
  195. package/node_modules/@llblab/pi-actors/dist/skills/project-work/SKILL.md +37 -0
  196. package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/changelog-head.json +11 -0
  197. package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/changelog-section.json +11 -0
  198. package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/docs-maintenance.json +66 -0
  199. package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/git-log.json +11 -0
  200. package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/git-status.json +9 -0
  201. package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/markdown-index.json +14 -0
  202. package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/package-summary.json +9 -0
  203. package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/release-readiness.json +115 -0
  204. package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/release-summary.json +74 -0
  205. package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/repo-health.json +75 -0
  206. package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/run-ops.json +56 -0
  207. package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/skill-summary.json +11 -0
  208. package/node_modules/@llblab/pi-actors/dist/skills/project-work/scripts/project-utils.mjs +89 -0
  209. package/node_modules/@llblab/pi-actors/dist/skills/recipe-memory/SKILL.md +36 -0
  210. package/node_modules/@llblab/pi-actors/dist/skills/recipe-memory/recipes/draft-review.json +14 -0
  211. package/node_modules/@llblab/pi-actors/dist/skills/recipe-memory/recipes/tool-review.json +14 -0
  212. package/node_modules/@llblab/pi-actors/dist/skills/swarm/SKILL.md +84 -0
  213. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/architect.json +82 -0
  214. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/checkpoint-continuation.json +51 -0
  215. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/development-tasking.json +67 -0
  216. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/lens-review.json +63 -0
  217. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/quorum-review.json +65 -0
  218. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/research-synthesis.json +81 -0
  219. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/review-readiness.json +59 -0
  220. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-artifact.json +21 -0
  221. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-checkpoint.json +21 -0
  222. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-conflict-report.json +19 -0
  223. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-contradiction-map.json +20 -0
  224. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-critic.json +22 -0
  225. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-evidence-map.json +20 -0
  226. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-followup.json +21 -0
  227. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-judge.json +22 -0
  228. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-merge.json +24 -0
  229. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-normalize.json +20 -0
  230. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-plan.json +20 -0
  231. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-preflight.json +18 -0
  232. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-prompt.json +16 -0
  233. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-prompts.json +39 -0
  234. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-quorum.json +31 -0
  235. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-review-coordinator.json +170 -0
  236. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-review.json +26 -0
  237. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-task-card.json +22 -0
  238. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-tools.json +15 -0
  239. package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-verify.json +23 -0
  240. package/node_modules/@llblab/pi-actors/dist/skills/swarm/references/development-swarm.md +189 -0
  241. package/node_modules/@llblab/pi-actors/dist/skills/swarm/references/review-swarms.md +115 -0
  242. package/node_modules/@llblab/pi-actors/docs/README.md +20 -0
  243. package/node_modules/@llblab/pi-actors/docs/actor-inspector.md +50 -0
  244. package/node_modules/@llblab/pi-actors/docs/async-runs.md +141 -0
  245. package/node_modules/@llblab/pi-actors/docs/command-templates.md +321 -0
  246. package/node_modules/@llblab/pi-actors/docs/recipe-library.md +89 -0
  247. package/node_modules/@llblab/pi-actors/docs/releasing.md +28 -0
  248. package/node_modules/@llblab/pi-actors/docs/template-recipes.md +175 -0
  249. package/node_modules/@llblab/pi-actors/docs/tool-registry.md +90 -0
  250. package/node_modules/@llblab/pi-actors/fixtures/protocol/artifact-manifest.json +9 -0
  251. package/node_modules/@llblab/pi-actors/fixtures/protocol/control-endpoint.json +6 -0
  252. package/node_modules/@llblab/pi-actors/fixtures/protocol/control-record.json +9 -0
  253. package/node_modules/@llblab/pi-actors/fixtures/protocol/recipe-summary.json +8 -0
  254. package/node_modules/@llblab/pi-actors/fixtures/protocol/run-state.json +10 -0
  255. package/node_modules/@llblab/pi-actors/fixtures/protocol/trace-event.json +9 -0
  256. package/node_modules/@llblab/pi-actors/index.ts +30 -0
  257. package/node_modules/@llblab/pi-actors/lib/async-runs.ts +1245 -0
  258. package/node_modules/@llblab/pi-actors/lib/automatic-review-runtime.ts +148 -0
  259. package/node_modules/@llblab/pi-actors/lib/command-templates.ts +1116 -0
  260. package/node_modules/@llblab/pi-actors/lib/config.ts +261 -0
  261. package/node_modules/@llblab/pi-actors/lib/control-projection.ts +105 -0
  262. package/node_modules/@llblab/pi-actors/lib/control.ts +117 -0
  263. package/node_modules/@llblab/pi-actors/lib/draft-consolidation-transaction.ts +821 -0
  264. package/node_modules/@llblab/pi-actors/lib/draft-consolidation.ts +181 -0
  265. package/node_modules/@llblab/pi-actors/lib/draft-review.ts +325 -0
  266. package/node_modules/@llblab/pi-actors/lib/draft-sleep.ts +575 -0
  267. package/node_modules/@llblab/pi-actors/lib/execution-output.ts +123 -0
  268. package/node_modules/@llblab/pi-actors/lib/execution-sessions.ts +111 -0
  269. package/node_modules/@llblab/pi-actors/lib/execution.ts +1153 -0
  270. package/node_modules/@llblab/pi-actors/lib/extension-runtime.ts +181 -0
  271. package/node_modules/@llblab/pi-actors/lib/file-state.ts +306 -0
  272. package/node_modules/@llblab/pi-actors/lib/identity.ts +29 -0
  273. package/node_modules/@llblab/pi-actors/lib/inspector-actions.ts +79 -0
  274. package/node_modules/@llblab/pi-actors/lib/inspector-command.ts +54 -0
  275. package/node_modules/@llblab/pi-actors/lib/inspector-overlay.ts +901 -0
  276. package/node_modules/@llblab/pi-actors/lib/inspector.ts +204 -0
  277. package/node_modules/@llblab/pi-actors/lib/limits.ts +29 -0
  278. package/node_modules/@llblab/pi-actors/lib/model-context.ts +359 -0
  279. package/node_modules/@llblab/pi-actors/lib/observability.ts +1337 -0
  280. package/node_modules/@llblab/pi-actors/lib/paths.ts +111 -0
  281. package/node_modules/@llblab/pi-actors/lib/pi.ts +47 -0
  282. package/node_modules/@llblab/pi-actors/lib/preflight-diagnostics.ts +132 -0
  283. package/node_modules/@llblab/pi-actors/lib/prompts.ts +69 -0
  284. package/node_modules/@llblab/pi-actors/lib/recipe-control.ts +52 -0
  285. package/node_modules/@llblab/pi-actors/lib/recipes-context.ts +268 -0
  286. package/node_modules/@llblab/pi-actors/lib/recipes-discovery.ts +1060 -0
  287. package/node_modules/@llblab/pi-actors/lib/recipes-references.ts +1598 -0
  288. package/node_modules/@llblab/pi-actors/lib/recipes-usage.ts +638 -0
  289. package/node_modules/@llblab/pi-actors/lib/registry.ts +806 -0
  290. package/node_modules/@llblab/pi-actors/lib/review-control.ts +136 -0
  291. package/node_modules/@llblab/pi-actors/lib/review-diagnostics.ts +164 -0
  292. package/node_modules/@llblab/pi-actors/lib/review-projection.ts +196 -0
  293. package/node_modules/@llblab/pi-actors/lib/run-evidence-policy.ts +242 -0
  294. package/node_modules/@llblab/pi-actors/lib/run-ui-runtime.ts +155 -0
  295. package/node_modules/@llblab/pi-actors/lib/runs-artifacts.ts +96 -0
  296. package/node_modules/@llblab/pi-actors/lib/runs-control-delivery.ts +209 -0
  297. package/node_modules/@llblab/pi-actors/lib/runs-control.ts +148 -0
  298. package/node_modules/@llblab/pi-actors/lib/runs-controls.ts +282 -0
  299. package/node_modules/@llblab/pi-actors/lib/runs-identity.ts +14 -0
  300. package/node_modules/@llblab/pi-actors/lib/runs-index.ts +192 -0
  301. package/node_modules/@llblab/pi-actors/lib/runs-ownership.ts +136 -0
  302. package/node_modules/@llblab/pi-actors/lib/runs-parent-teardown.ts +257 -0
  303. package/node_modules/@llblab/pi-actors/lib/runs-process.ts +174 -0
  304. package/node_modules/@llblab/pi-actors/lib/runs-retention.ts +140 -0
  305. package/node_modules/@llblab/pi-actors/lib/runs-start.ts +113 -0
  306. package/node_modules/@llblab/pi-actors/lib/runs-status.ts +101 -0
  307. package/node_modules/@llblab/pi-actors/lib/runs-trace.ts +611 -0
  308. package/node_modules/@llblab/pi-actors/lib/runtime-identity.ts +39 -0
  309. package/node_modules/@llblab/pi-actors/lib/runtime-triage.ts +106 -0
  310. package/node_modules/@llblab/pi-actors/lib/runtime.ts +430 -0
  311. package/node_modules/@llblab/pi-actors/lib/schema.ts +525 -0
  312. package/node_modules/@llblab/pi-actors/lib/session-evidence.ts +302 -0
  313. package/node_modules/@llblab/pi-actors/lib/state-readers.ts +93 -0
  314. package/node_modules/@llblab/pi-actors/lib/temp.ts +99 -0
  315. package/node_modules/@llblab/pi-actors/lib/tool-review-lineage-transaction.ts +881 -0
  316. package/node_modules/@llblab/pi-actors/lib/tool-review-lineage.ts +145 -0
  317. package/node_modules/@llblab/pi-actors/lib/tool-review-scheduler.ts +635 -0
  318. package/node_modules/@llblab/pi-actors/lib/tool-review-transaction.ts +563 -0
  319. package/node_modules/@llblab/pi-actors/lib/tool-review.ts +270 -0
  320. package/node_modules/@llblab/pi-actors/lib/tools-access.ts +68 -0
  321. package/node_modules/@llblab/pi-actors/lib/tools-inspect.ts +673 -0
  322. package/node_modules/@llblab/pi-actors/lib/tools-local.ts +303 -0
  323. package/node_modules/@llblab/pi-actors/lib/tools-message.ts +176 -0
  324. package/node_modules/@llblab/pi-actors/lib/tools-register.ts +63 -0
  325. package/node_modules/@llblab/pi-actors/lib/tools-response.ts +285 -0
  326. package/node_modules/@llblab/pi-actors/lib/tools-spawn.ts +212 -0
  327. package/node_modules/@llblab/pi-actors/lib/tools.ts +88 -0
  328. package/node_modules/@llblab/pi-actors/lib/trace-projection.ts +306 -0
  329. package/node_modules/@llblab/pi-actors/package.json +76 -0
  330. package/node_modules/@llblab/pi-actors/scripts/async-runner.mjs +555 -0
  331. package/node_modules/@llblab/pi-actors/scripts/build-dist.mjs +60 -0
  332. package/node_modules/@llblab/pi-actors/scripts/conformance.mjs +63 -0
  333. package/node_modules/@llblab/pi-actors/skills/actors/SKILL.md +126 -0
  334. package/node_modules/@llblab/pi-actors/skills/actors/recipes/command-validate.json +13 -0
  335. package/node_modules/@llblab/pi-actors/skills/actors/recipes/jsonl-tail.json +10 -0
  336. package/node_modules/@llblab/pi-actors/skills/actors/recipes/recipe-validate.json +11 -0
  337. package/node_modules/@llblab/pi-actors/skills/actors/recipes/resource-locker-snapshot.json +11 -0
  338. package/node_modules/@llblab/pi-actors/skills/actors/recipes/resource-locker.json +25 -0
  339. package/node_modules/@llblab/pi-actors/skills/actors/recipes/run-ops-snapshot.json +15 -0
  340. package/node_modules/@llblab/pi-actors/skills/actors/recipes/run-state-files.json +13 -0
  341. package/node_modules/@llblab/pi-actors/skills/actors/recipes/run-summary.json +9 -0
  342. package/node_modules/@llblab/pi-actors/skills/actors/references/diagnostics.md +44 -0
  343. package/node_modules/@llblab/pi-actors/skills/actors/references/persistent-tools.md +76 -0
  344. package/node_modules/@llblab/pi-actors/skills/actors/references/recipes.md +51 -0
  345. package/node_modules/@llblab/pi-actors/skills/actors/references/runs.md +41 -0
  346. package/node_modules/@llblab/pi-actors/skills/actors/scripts/resource-locker.mjs +425 -0
  347. package/node_modules/@llblab/pi-actors/skills/actors/scripts/run-utils.mjs +164 -0
  348. package/node_modules/@llblab/pi-actors/skills/actors/scripts/validate-recipe.mjs +370 -0
  349. package/node_modules/@llblab/pi-actors/skills/artifacts/SKILL.md +33 -0
  350. package/node_modules/@llblab/pi-actors/skills/artifacts/recipes/bundle.json +77 -0
  351. package/node_modules/@llblab/pi-actors/skills/artifacts/recipes/file-write.json +14 -0
  352. package/node_modules/@llblab/pi-actors/skills/artifacts/recipes/manifest.json +14 -0
  353. package/node_modules/@llblab/pi-actors/skills/artifacts/recipes/report.json +39 -0
  354. package/node_modules/@llblab/pi-actors/skills/artifacts/recipes/write.json +53 -0
  355. package/node_modules/@llblab/pi-actors/skills/artifacts/scripts/artifact-utils.mjs +63 -0
  356. package/node_modules/@llblab/pi-actors/skills/music-player/SKILL.md +57 -0
  357. package/node_modules/@llblab/pi-actors/skills/music-player/genapps/music-player.mjs +360 -0
  358. package/node_modules/@llblab/pi-actors/skills/music-player/recipes/playback.json +29 -0
  359. package/node_modules/@llblab/pi-actors/skills/music-player/scripts/playback-client.mjs +143 -0
  360. package/node_modules/@llblab/pi-actors/skills/music-player/scripts/playback.mjs +1446 -0
  361. package/node_modules/@llblab/pi-actors/skills/project-work/SKILL.md +37 -0
  362. package/node_modules/@llblab/pi-actors/skills/project-work/recipes/changelog-head.json +11 -0
  363. package/node_modules/@llblab/pi-actors/skills/project-work/recipes/changelog-section.json +11 -0
  364. package/node_modules/@llblab/pi-actors/skills/project-work/recipes/docs-maintenance.json +66 -0
  365. package/node_modules/@llblab/pi-actors/skills/project-work/recipes/git-log.json +11 -0
  366. package/node_modules/@llblab/pi-actors/skills/project-work/recipes/git-status.json +9 -0
  367. package/node_modules/@llblab/pi-actors/skills/project-work/recipes/markdown-index.json +14 -0
  368. package/node_modules/@llblab/pi-actors/skills/project-work/recipes/package-summary.json +9 -0
  369. package/node_modules/@llblab/pi-actors/skills/project-work/recipes/release-readiness.json +115 -0
  370. package/node_modules/@llblab/pi-actors/skills/project-work/recipes/release-summary.json +74 -0
  371. package/node_modules/@llblab/pi-actors/skills/project-work/recipes/repo-health.json +75 -0
  372. package/node_modules/@llblab/pi-actors/skills/project-work/recipes/run-ops.json +56 -0
  373. package/node_modules/@llblab/pi-actors/skills/project-work/recipes/skill-summary.json +11 -0
  374. package/node_modules/@llblab/pi-actors/skills/project-work/scripts/project-utils.mjs +89 -0
  375. package/node_modules/@llblab/pi-actors/skills/recipe-memory/SKILL.md +36 -0
  376. package/node_modules/@llblab/pi-actors/skills/recipe-memory/recipes/draft-review.json +14 -0
  377. package/node_modules/@llblab/pi-actors/skills/recipe-memory/recipes/tool-review.json +14 -0
  378. package/node_modules/@llblab/pi-actors/skills/swarm/SKILL.md +84 -0
  379. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/architect.json +82 -0
  380. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/checkpoint-continuation.json +51 -0
  381. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/development-tasking.json +67 -0
  382. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/lens-review.json +63 -0
  383. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/quorum-review.json +65 -0
  384. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/research-synthesis.json +81 -0
  385. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/review-readiness.json +59 -0
  386. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-artifact.json +21 -0
  387. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-checkpoint.json +21 -0
  388. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-conflict-report.json +19 -0
  389. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-contradiction-map.json +20 -0
  390. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-critic.json +22 -0
  391. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-evidence-map.json +20 -0
  392. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-followup.json +21 -0
  393. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-judge.json +22 -0
  394. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-merge.json +24 -0
  395. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-normalize.json +20 -0
  396. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-plan.json +20 -0
  397. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-preflight.json +18 -0
  398. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-prompt.json +16 -0
  399. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-prompts.json +39 -0
  400. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-quorum.json +31 -0
  401. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-review-coordinator.json +170 -0
  402. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-review.json +26 -0
  403. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-task-card.json +22 -0
  404. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-tools.json +15 -0
  405. package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-verify.json +23 -0
  406. package/node_modules/@llblab/pi-actors/skills/swarm/references/development-swarm.md +189 -0
  407. package/node_modules/@llblab/pi-actors/skills/swarm/references/review-swarms.md +115 -0
  408. package/node_modules/@llblab/pi-codex-usage/AGENTS.md +17 -0
  409. package/node_modules/@llblab/pi-codex-usage/BACKLOG.md +8 -0
  410. package/node_modules/@llblab/pi-codex-usage/CHANGELOG.md +80 -0
  411. package/node_modules/@llblab/pi-codex-usage/LICENSE +22 -0
  412. package/node_modules/@llblab/pi-codex-usage/README.md +113 -0
  413. package/node_modules/@llblab/pi-codex-usage/banner.jpg +0 -0
  414. package/node_modules/@llblab/pi-codex-usage/index.ts +1525 -0
  415. package/node_modules/@llblab/pi-codex-usage/package.json +59 -0
  416. package/node_modules/@llblab/pi-grow-loop/AGENTS.md +56 -0
  417. package/node_modules/@llblab/pi-grow-loop/BACKLOG.md +3 -0
  418. package/node_modules/@llblab/pi-grow-loop/CHANGELOG.md +126 -0
  419. package/node_modules/@llblab/pi-grow-loop/README.md +216 -0
  420. package/node_modules/@llblab/pi-grow-loop/banner.jpg +0 -0
  421. package/node_modules/@llblab/pi-grow-loop/index.ts +219 -0
  422. package/node_modules/@llblab/pi-grow-loop/package.json +64 -0
  423. package/node_modules/@llblab/pi-grow-loop/skills/grow-loop/SKILL.md +131 -0
  424. package/node_modules/@llblab/pi-grow-loop/skills/while-true/SKILL.md +233 -0
  425. package/node_modules/@llblab/pi-telegram/AGENTS.md +157 -0
  426. package/node_modules/@llblab/pi-telegram/BACKLOG.md +15 -0
  427. package/node_modules/@llblab/pi-telegram/CHANGELOG.md +886 -0
  428. package/node_modules/@llblab/pi-telegram/README.md +330 -0
  429. package/node_modules/@llblab/pi-telegram/api/activity.ts +15 -0
  430. package/node_modules/@llblab/pi-telegram/api/commands.ts +11 -0
  431. package/node_modules/@llblab/pi-telegram/api/delivery.ts +21 -0
  432. package/node_modules/@llblab/pi-telegram/api/inbound.ts +14 -0
  433. package/node_modules/@llblab/pi-telegram/api/keyboard.ts +11 -0
  434. package/node_modules/@llblab/pi-telegram/api/outbound.ts +11 -0
  435. package/node_modules/@llblab/pi-telegram/api/sections.ts +17 -0
  436. package/node_modules/@llblab/pi-telegram/api/status.ts +12 -0
  437. package/node_modules/@llblab/pi-telegram/api/updates.ts +16 -0
  438. package/node_modules/@llblab/pi-telegram/api/voice.ts +24 -0
  439. package/node_modules/@llblab/pi-telegram/docs/README.md +25 -0
  440. package/node_modules/@llblab/pi-telegram/docs/activity.md +304 -0
  441. package/node_modules/@llblab/pi-telegram/docs/architecture.md +418 -0
  442. package/node_modules/@llblab/pi-telegram/docs/callback-namespaces.md +48 -0
  443. package/node_modules/@llblab/pi-telegram/docs/command-templates.md +365 -0
  444. package/node_modules/@llblab/pi-telegram/docs/compact-matrix-literal.md +176 -0
  445. package/node_modules/@llblab/pi-telegram/docs/delivery.md +225 -0
  446. package/node_modules/@llblab/pi-telegram/docs/generative-apps.md +310 -0
  447. package/node_modules/@llblab/pi-telegram/docs/inbound.md +136 -0
  448. package/node_modules/@llblab/pi-telegram/docs/multi-instance-bus.md +467 -0
  449. package/node_modules/@llblab/pi-telegram/docs/outbound.md +193 -0
  450. package/node_modules/@llblab/pi-telegram/docs/public-api.md +599 -0
  451. package/node_modules/@llblab/pi-telegram/docs/sections.md +452 -0
  452. package/node_modules/@llblab/pi-telegram/docs/ui-style.md +256 -0
  453. package/node_modules/@llblab/pi-telegram/docs/updates.md +171 -0
  454. package/node_modules/@llblab/pi-telegram/docs/voice.md +217 -0
  455. package/node_modules/@llblab/pi-telegram/index.ts +1336 -0
  456. package/node_modules/@llblab/pi-telegram/lib/activity-verbosity.ts +714 -0
  457. package/node_modules/@llblab/pi-telegram/lib/activity.ts +782 -0
  458. package/node_modules/@llblab/pi-telegram/lib/agent-messages.ts +121 -0
  459. package/node_modules/@llblab/pi-telegram/lib/bindings.ts +1129 -0
  460. package/node_modules/@llblab/pi-telegram/lib/bus-api.ts +379 -0
  461. package/node_modules/@llblab/pi-telegram/lib/bus-follower.ts +1941 -0
  462. package/node_modules/@llblab/pi-telegram/lib/bus-leader.ts +2119 -0
  463. package/node_modules/@llblab/pi-telegram/lib/bus-transport.ts +244 -0
  464. package/node_modules/@llblab/pi-telegram/lib/bus.ts +2645 -0
  465. package/node_modules/@llblab/pi-telegram/lib/command-templates.ts +954 -0
  466. package/node_modules/@llblab/pi-telegram/lib/commands.ts +1854 -0
  467. package/node_modules/@llblab/pi-telegram/lib/config.ts +1143 -0
  468. package/node_modules/@llblab/pi-telegram/lib/delivery.ts +891 -0
  469. package/node_modules/@llblab/pi-telegram/lib/generative-app-worker.mjs +104 -0
  470. package/node_modules/@llblab/pi-telegram/lib/generative-apps.ts +958 -0
  471. package/node_modules/@llblab/pi-telegram/lib/inbound.ts +824 -0
  472. package/node_modules/@llblab/pi-telegram/lib/journal.ts +3140 -0
  473. package/node_modules/@llblab/pi-telegram/lib/keyboard.ts +59 -0
  474. package/node_modules/@llblab/pi-telegram/lib/lifecycle.ts +623 -0
  475. package/node_modules/@llblab/pi-telegram/lib/locks.ts +1422 -0
  476. package/node_modules/@llblab/pi-telegram/lib/logs.ts +393 -0
  477. package/node_modules/@llblab/pi-telegram/lib/media.ts +921 -0
  478. package/node_modules/@llblab/pi-telegram/lib/menu-model.ts +1182 -0
  479. package/node_modules/@llblab/pi-telegram/lib/menu-queue.ts +926 -0
  480. package/node_modules/@llblab/pi-telegram/lib/menu-settings.ts +876 -0
  481. package/node_modules/@llblab/pi-telegram/lib/menu-status.ts +274 -0
  482. package/node_modules/@llblab/pi-telegram/lib/menu-thinking.ts +185 -0
  483. package/node_modules/@llblab/pi-telegram/lib/menu.ts +867 -0
  484. package/node_modules/@llblab/pi-telegram/lib/model.ts +672 -0
  485. package/node_modules/@llblab/pi-telegram/lib/outbound-attachments.ts +981 -0
  486. package/node_modules/@llblab/pi-telegram/lib/outbound-buttons.ts +331 -0
  487. package/node_modules/@llblab/pi-telegram/lib/outbound-markup.ts +515 -0
  488. package/node_modules/@llblab/pi-telegram/lib/outbound-voice.ts +285 -0
  489. package/node_modules/@llblab/pi-telegram/lib/outbound.ts +1007 -0
  490. package/node_modules/@llblab/pi-telegram/lib/ownership.ts +298 -0
  491. package/node_modules/@llblab/pi-telegram/lib/paths.ts +127 -0
  492. package/node_modules/@llblab/pi-telegram/lib/pi.ts +197 -0
  493. package/node_modules/@llblab/pi-telegram/lib/polling.ts +1588 -0
  494. package/node_modules/@llblab/pi-telegram/lib/preview.ts +846 -0
  495. package/node_modules/@llblab/pi-telegram/lib/prompt-templates.ts +158 -0
  496. package/node_modules/@llblab/pi-telegram/lib/prompts.ts +218 -0
  497. package/node_modules/@llblab/pi-telegram/lib/queue.ts +3075 -0
  498. package/node_modules/@llblab/pi-telegram/lib/recovery.ts +464 -0
  499. package/node_modules/@llblab/pi-telegram/lib/rendering.ts +1213 -0
  500. package/node_modules/@llblab/pi-telegram/lib/replies.ts +892 -0
  501. package/node_modules/@llblab/pi-telegram/lib/routing.ts +2889 -0
  502. package/node_modules/@llblab/pi-telegram/lib/runtime.ts +628 -0
  503. package/node_modules/@llblab/pi-telegram/lib/sections.ts +710 -0
  504. package/node_modules/@llblab/pi-telegram/lib/setup.ts +220 -0
  505. package/node_modules/@llblab/pi-telegram/lib/skills.ts +21 -0
  506. package/node_modules/@llblab/pi-telegram/lib/status.ts +1550 -0
  507. package/node_modules/@llblab/pi-telegram/lib/sync.ts +883 -0
  508. package/node_modules/@llblab/pi-telegram/lib/target.ts +49 -0
  509. package/node_modules/@llblab/pi-telegram/lib/telegram-api.ts +1747 -0
  510. package/node_modules/@llblab/pi-telegram/lib/text-groups.ts +487 -0
  511. package/node_modules/@llblab/pi-telegram/lib/thread-reconciler.ts +1002 -0
  512. package/node_modules/@llblab/pi-telegram/lib/threads.ts +3183 -0
  513. package/node_modules/@llblab/pi-telegram/lib/time-injection.ts +78 -0
  514. package/node_modules/@llblab/pi-telegram/lib/turns.ts +753 -0
  515. package/node_modules/@llblab/pi-telegram/lib/updates.ts +4950 -0
  516. package/node_modules/@llblab/pi-telegram/lib/voice.ts +340 -0
  517. package/node_modules/@llblab/pi-telegram/package.json +83 -0
  518. package/node_modules/@llblab/pi-telegram/screenshot.png +0 -0
  519. package/node_modules/@llblab/pi-telegram/scripts/check-downgrade.mjs +435 -0
  520. package/node_modules/@llblab/pi-telegram/skills/generated-control-surface/SKILL.md +241 -0
  521. package/node_modules/@llblab/pi-telegram/skills/generative-apps/SKILL.md +114 -0
  522. package/node_modules/@llblab/pi-telegram/skills/telegram-bridge/SKILL.md +149 -0
  523. package/package.json +67 -0
@@ -0,0 +1,926 @@
1
+ /**
2
+ * Telegram queue menu UI helpers
3
+ * Zones: telegram ui, queue controls, menu composition
4
+ * Owns queue-menu rendering, queue item callbacks, and queue-menu runtime adapters while core queue mechanics stay in queue
5
+ */
6
+
7
+ import type { TelegramInlineKeyboardMarkup } from "./keyboard.ts";
8
+ import type { TelegramModelMenuState } from "./menu.ts";
9
+ import type { MenuModel } from "./model.ts";
10
+ import * as Queue from "./queue.ts";
11
+
12
+ // --- Queue Menu ---
13
+
14
+ const QUEUE_ITEM_PROMPT_HTML_LIMIT = 3600;
15
+ const QUEUE_ITEM_PROMPT_TRUNCATION_SUFFIX = "\n… [truncated]";
16
+ const EMPTY_QUEUE_REFRESH_TITLES = [
17
+ "<b>⌛ Queue is still empty.</b>",
18
+ "<b>🫙 Still nothing in queue.</b>",
19
+ "<b>🍃 Queue remains empty.</b>",
20
+ "<b>🕳 Nothing queued yet.</b>",
21
+ "<b>🦗 Queue crickets continue.</b>",
22
+ "<b>🌙 Queue is peacefully idle.</b>",
23
+ "<b>🧘 Nothing waiting. Very zen.</b>",
24
+ "<b>🪐 Queue orbit is clear.</b>",
25
+ "<b>🧺 Basket is empty.</b>",
26
+ "<b>🔭 No prompts on the horizon.</b>",
27
+ "<b>🫧 Queue bubbles: none.</b>",
28
+ "<b>🛸 No queued signals detected.</b>",
29
+ ] as const;
30
+ type TelegramQueueMenuReplyMarkup = TelegramInlineKeyboardMarkup;
31
+ interface TelegramQueueMenuItem {
32
+ chatId: number;
33
+ replyToMessageId: number;
34
+ queuePosition: number;
35
+ isPriority: boolean;
36
+ priorityEmoji?: string;
37
+ reactionSuppressionEmoji?: string;
38
+ hasAttachments: boolean;
39
+ statusSummary: string;
40
+ promptText: string;
41
+ }
42
+
43
+ function getTelegramQueueItemPromptText<Context>(
44
+ item: Queue.TelegramQueueItem<Context>,
45
+ ): string {
46
+ if (item.kind !== "prompt") return item.statusSummary;
47
+ return (
48
+ item.content
49
+ .filter((block) => block.type === "text")
50
+ .map((block) => block.text)
51
+ .join("\n")
52
+ .trim() || item.statusSummary
53
+ );
54
+ }
55
+
56
+ function toTelegramQueueMenuItems<Context>(
57
+ items: readonly Queue.TelegramQueueItem<Context>[],
58
+ ): TelegramQueueMenuItem[] {
59
+ return items.map((item, index) => {
60
+ return {
61
+ chatId: item.chatId,
62
+ replyToMessageId: item.replyToMessageId,
63
+ queuePosition: index + 1,
64
+ isPriority: item.queueLane === "priority",
65
+ priorityEmoji: item.kind === "prompt" ? item.priorityEmoji : undefined,
66
+ reactionSuppressionEmoji:
67
+ item.kind === "prompt" ? item.reactionSuppressionEmoji : undefined,
68
+ hasAttachments:
69
+ item.kind === "prompt" && item.queuedAttachments.length > 0,
70
+ statusSummary: item.statusSummary,
71
+ promptText: getTelegramQueueItemPromptText(item),
72
+ };
73
+ });
74
+ }
75
+
76
+ function buildTelegramQueueMenuReplyMarkup(
77
+ items: readonly TelegramQueueMenuItem[],
78
+ emptyRefreshIndex = 0,
79
+ ): TelegramQueueMenuReplyMarkup {
80
+ const backRow = [{ text: "⬆️ Main menu", callback_data: "menu:back" }];
81
+ const nextEmptyRefreshIndex =
82
+ (emptyRefreshIndex + 1) % EMPTY_QUEUE_REFRESH_TITLES.length;
83
+ const refreshData =
84
+ items.length === 0
85
+ ? `queue:refresh:${nextEmptyRefreshIndex}`
86
+ : "queue:refresh";
87
+ const refreshRow = [{ text: "🌀 Refresh", callback_data: refreshData }];
88
+ if (items.length === 0) return { inline_keyboard: [backRow, refreshRow] };
89
+ const rows = items.map((item, index) => {
90
+ const prefix = item.reactionSuppressionEmoji
91
+ ? `${item.reactionSuppressionEmoji} `
92
+ : item.isPriority
93
+ ? `${item.priorityEmoji ?? "⚡"} `
94
+ : item.hasAttachments
95
+ ? "📎 "
96
+ : "";
97
+ const label = `${index + 1}. ${prefix}${item.statusSummary}`;
98
+ return [
99
+ {
100
+ text: label,
101
+ callback_data: `queue:pick:${item.chatId}:${item.replyToMessageId}`,
102
+ },
103
+ ];
104
+ });
105
+ return { inline_keyboard: [backRow, refreshRow, ...rows] };
106
+ }
107
+
108
+ function findTelegramQueueItem<Context>(
109
+ items: readonly Queue.TelegramQueueItem<Context>[],
110
+ chatId: number,
111
+ replyToMessageId: number,
112
+ ): Queue.TelegramQueueItem<Context> | undefined {
113
+ return items.find((item) => {
114
+ return item.chatId === chatId && item.replyToMessageId === replyToMessageId;
115
+ });
116
+ }
117
+
118
+ function findTelegramQueueMenuItem(
119
+ items: readonly TelegramQueueMenuItem[],
120
+ chatId: number,
121
+ replyToMessageId: number,
122
+ ): TelegramQueueMenuItem | undefined {
123
+ return items.find((item) => {
124
+ return item.chatId === chatId && item.replyToMessageId === replyToMessageId;
125
+ });
126
+ }
127
+
128
+ function escapeTelegramQueueMenuHtmlChar(char: string): string {
129
+ if (char === "&") return "&amp;";
130
+ if (char === "<") return "&lt;";
131
+ if (char === ">") return "&gt;";
132
+ return char;
133
+ }
134
+
135
+ function escapeTelegramQueueMenuHtml(text: string): string {
136
+ return Array.from(text).map(escapeTelegramQueueMenuHtmlChar).join("");
137
+ }
138
+
139
+ function escapeTelegramQueueMenuHtmlPreview(text: string): string {
140
+ const suffix = escapeTelegramQueueMenuHtml(
141
+ QUEUE_ITEM_PROMPT_TRUNCATION_SUFFIX,
142
+ );
143
+ let escaped = "";
144
+ let truncated = false;
145
+ for (const char of text) {
146
+ const next = escapeTelegramQueueMenuHtmlChar(char);
147
+ if (
148
+ escaped.length + next.length + suffix.length >
149
+ QUEUE_ITEM_PROMPT_HTML_LIMIT
150
+ ) {
151
+ truncated = true;
152
+ break;
153
+ }
154
+ escaped += next;
155
+ }
156
+ return truncated ? escaped + suffix : escaped;
157
+ }
158
+
159
+ function getTelegramQueueMenuItemText(item: TelegramQueueMenuItem): string {
160
+ const badge = item.reactionSuppressionEmoji
161
+ ? ` ${item.reactionSuppressionEmoji}`
162
+ : item.isPriority
163
+ ? ` ${item.priorityEmoji ?? "⚡"}`
164
+ : "";
165
+ const heading = `<b>${item.queuePosition}.</b>${badge}`;
166
+ const preview = `<pre>${escapeTelegramQueueMenuHtmlPreview(item.promptText)}</pre>`;
167
+ return `${heading}\n${preview}`;
168
+ }
169
+
170
+ function buildTelegramQueueItemSubmenuReplyMarkup(
171
+ chatId: number,
172
+ replyToMessageId: number,
173
+ isPriority: boolean,
174
+ isSkipped: boolean,
175
+ ): TelegramQueueMenuReplyMarkup {
176
+ return {
177
+ inline_keyboard: [
178
+ [{ text: "⬆️ Back", callback_data: "queue:list" }],
179
+ [
180
+ {
181
+ text: isPriority ? "🟡 Priority" : "⚫️ Priority",
182
+ callback_data: `queue:prio-set:${chatId}:${replyToMessageId}:priority`,
183
+ },
184
+ {
185
+ text: isPriority ? "⚫️ Normal" : "🟣 Normal",
186
+ callback_data: `queue:prio-set:${chatId}:${replyToMessageId}:normal`,
187
+ },
188
+ ],
189
+ [
190
+ {
191
+ text: isSkipped ? "⚫️ Keep" : "🟢 Keep",
192
+ callback_data: `queue:skip-set:${chatId}:${replyToMessageId}:keep`,
193
+ },
194
+ {
195
+ text: isSkipped ? "🔴 Skip" : "⚫️ Skip",
196
+ callback_data: `queue:skip-set:${chatId}:${replyToMessageId}:skip`,
197
+ },
198
+ ],
199
+ ],
200
+ };
201
+ }
202
+
203
+ interface TelegramQueueMenuCallbackDeps<Context = unknown> {
204
+ getQueuedItems: () => TelegramQueueMenuItem[];
205
+ findItem: (
206
+ chatId: number,
207
+ replyToMessageId: number,
208
+ ) => TelegramQueueMenuItem | undefined;
209
+ togglePriority: (chatId: number, replyToMessageId: number) => boolean;
210
+ setPriority: (
211
+ chatId: number,
212
+ replyToMessageId: number,
213
+ enabled: boolean,
214
+ ) => boolean;
215
+ setSkipped: (
216
+ chatId: number,
217
+ replyToMessageId: number,
218
+ skipped: boolean,
219
+ ) => boolean;
220
+ updateQueueMessage: (
221
+ chatId: number,
222
+ messageId: number,
223
+ text: string,
224
+ replyMarkup: TelegramQueueMenuReplyMarkup,
225
+ ) => Promise<number | undefined>;
226
+ answerCallbackQuery: (
227
+ callbackQueryId: string,
228
+ text?: string,
229
+ ) => Promise<void>;
230
+ updateStatus: (ctx: Context) => void;
231
+ }
232
+
233
+ async function handleTelegramQueueMenuCallback<Context>(
234
+ callbackQueryId: string,
235
+ data: string,
236
+ replyChatId: number,
237
+ replyMessageId: number,
238
+ ctx: Context,
239
+ deps: TelegramQueueMenuCallbackDeps<Context>,
240
+ ): Promise<boolean> {
241
+ if (!data.startsWith("queue:")) return false;
242
+ if (data === "queue:noop") {
243
+ await deps.answerCallbackQuery(callbackQueryId);
244
+ return true;
245
+ }
246
+ if (data === "queue:list") {
247
+ await updateTelegramQueueMenuList(
248
+ callbackQueryId,
249
+ replyChatId,
250
+ replyMessageId,
251
+ deps,
252
+ );
253
+ return true;
254
+ }
255
+ const refreshMatch = data.match(/^queue:refresh(?::(\d+))?$/);
256
+ if (refreshMatch) {
257
+ await updateTelegramQueueMenuList(
258
+ callbackQueryId,
259
+ replyChatId,
260
+ replyMessageId,
261
+ deps,
262
+ undefined,
263
+ refreshMatch[1] === undefined ? 0 : Number(refreshMatch[1]),
264
+ );
265
+ return true;
266
+ }
267
+ const pickMatch = data.match(/^queue:pick:(\d+):(\d+)$/);
268
+ if (pickMatch) {
269
+ await handleTelegramQueueMenuPick(
270
+ callbackQueryId,
271
+ replyChatId,
272
+ replyMessageId,
273
+ Number(pickMatch[1]),
274
+ Number(pickMatch[2]),
275
+ deps,
276
+ );
277
+ return true;
278
+ }
279
+ const prioSetMatch = data.match(
280
+ /^queue:prio-set:(\d+):(\d+):(priority|normal)$/,
281
+ );
282
+ if (prioSetMatch) {
283
+ await handleTelegramQueueMenuPrioritySet(
284
+ callbackQueryId,
285
+ replyChatId,
286
+ replyMessageId,
287
+ Number(prioSetMatch[1]),
288
+ Number(prioSetMatch[2]),
289
+ prioSetMatch[3] === "priority",
290
+ ctx,
291
+ deps,
292
+ );
293
+ return true;
294
+ }
295
+ const prioMatch = data.match(/^queue:prio:(\d+):(\d+)$/);
296
+ if (prioMatch) {
297
+ await handleTelegramQueueMenuPriority(
298
+ callbackQueryId,
299
+ replyChatId,
300
+ replyMessageId,
301
+ Number(prioMatch[1]),
302
+ Number(prioMatch[2]),
303
+ ctx,
304
+ deps,
305
+ );
306
+ return true;
307
+ }
308
+ const skipSetMatch = data.match(
309
+ /^queue:skip-set:(\d+):(\d+):(skip|keep)$/,
310
+ );
311
+ if (skipSetMatch) {
312
+ await handleTelegramQueueMenuSkipSet(
313
+ callbackQueryId,
314
+ replyChatId,
315
+ replyMessageId,
316
+ Number(skipSetMatch[1]),
317
+ Number(skipSetMatch[2]),
318
+ skipSetMatch[3] === "skip",
319
+ ctx,
320
+ deps,
321
+ );
322
+ return true;
323
+ }
324
+ return false;
325
+ }
326
+
327
+ function getTelegramQueueMenuListText(
328
+ items: readonly TelegramQueueMenuItem[],
329
+ emptyRefreshIndex?: number,
330
+ ): string {
331
+ if (items.length > 0) return "<b>⏳ Queue:</b>";
332
+ if (emptyRefreshIndex === undefined) return "<b>⌛ Queue is empty.</b>";
333
+ return EMPTY_QUEUE_REFRESH_TITLES[
334
+ emptyRefreshIndex % EMPTY_QUEUE_REFRESH_TITLES.length
335
+ ];
336
+ }
337
+
338
+ async function updateTelegramQueueMenuList<Context>(
339
+ callbackQueryId: string,
340
+ replyChatId: number,
341
+ replyMessageId: number,
342
+ deps: TelegramQueueMenuCallbackDeps<Context>,
343
+ notice?: string,
344
+ emptyRefreshIndex?: number,
345
+ ): Promise<void> {
346
+ const items = deps.getQueuedItems();
347
+ await deps.updateQueueMessage(
348
+ replyChatId,
349
+ replyMessageId,
350
+ getTelegramQueueMenuListText(items, emptyRefreshIndex),
351
+ buildTelegramQueueMenuReplyMarkup(items, emptyRefreshIndex),
352
+ );
353
+ await deps.answerCallbackQuery(callbackQueryId, notice);
354
+ }
355
+
356
+ async function refreshStaleTelegramQueueMenuItem<Context>(
357
+ callbackQueryId: string,
358
+ replyChatId: number,
359
+ replyMessageId: number,
360
+ deps: TelegramQueueMenuCallbackDeps<Context>,
361
+ ): Promise<void> {
362
+ await updateTelegramQueueMenuList(
363
+ callbackQueryId,
364
+ replyChatId,
365
+ replyMessageId,
366
+ deps,
367
+ "Item no longer in queue.",
368
+ );
369
+ }
370
+
371
+ async function handleTelegramQueueMenuPick<Context>(
372
+ callbackQueryId: string,
373
+ replyChatId: number,
374
+ replyMessageId: number,
375
+ chatId: number,
376
+ msgId: number,
377
+ deps: TelegramQueueMenuCallbackDeps<Context>,
378
+ ): Promise<void> {
379
+ const item = deps.findItem(chatId, msgId);
380
+ if (!item) {
381
+ return refreshStaleTelegramQueueMenuItem(
382
+ callbackQueryId,
383
+ replyChatId,
384
+ replyMessageId,
385
+ deps,
386
+ );
387
+ }
388
+ await deps.updateQueueMessage(
389
+ replyChatId,
390
+ replyMessageId,
391
+ getTelegramQueueMenuItemText(item),
392
+ buildTelegramQueueItemSubmenuReplyMarkup(
393
+ chatId,
394
+ msgId,
395
+ item.isPriority,
396
+ item.reactionSuppressionEmoji !== undefined,
397
+ ),
398
+ );
399
+ await deps.answerCallbackQuery(callbackQueryId);
400
+ }
401
+
402
+ async function handleTelegramQueueMenuPriority<Context>(
403
+ callbackQueryId: string,
404
+ replyChatId: number,
405
+ replyMessageId: number,
406
+ chatId: number,
407
+ msgId: number,
408
+ ctx: Context,
409
+ deps: TelegramQueueMenuCallbackDeps<Context>,
410
+ ): Promise<void> {
411
+ const item = deps.findItem(chatId, msgId);
412
+ if (!item) {
413
+ return refreshStaleTelegramQueueMenuItem(
414
+ callbackQueryId,
415
+ replyChatId,
416
+ replyMessageId,
417
+ deps,
418
+ );
419
+ }
420
+ await updateTelegramQueueMenuPriority(
421
+ callbackQueryId,
422
+ replyChatId,
423
+ replyMessageId,
424
+ chatId,
425
+ msgId,
426
+ !item.isPriority,
427
+ ctx,
428
+ deps,
429
+ );
430
+ }
431
+
432
+ async function handleTelegramQueueMenuPrioritySet<Context>(
433
+ callbackQueryId: string,
434
+ replyChatId: number,
435
+ replyMessageId: number,
436
+ chatId: number,
437
+ msgId: number,
438
+ enabled: boolean,
439
+ ctx: Context,
440
+ deps: TelegramQueueMenuCallbackDeps<Context>,
441
+ ): Promise<void> {
442
+ const item = deps.findItem(chatId, msgId);
443
+ if (!item) {
444
+ return refreshStaleTelegramQueueMenuItem(
445
+ callbackQueryId,
446
+ replyChatId,
447
+ replyMessageId,
448
+ deps,
449
+ );
450
+ }
451
+ await updateTelegramQueueMenuPriority(
452
+ callbackQueryId,
453
+ replyChatId,
454
+ replyMessageId,
455
+ chatId,
456
+ msgId,
457
+ enabled,
458
+ ctx,
459
+ deps,
460
+ );
461
+ }
462
+
463
+ async function updateTelegramQueueMenuPriority<Context>(
464
+ callbackQueryId: string,
465
+ replyChatId: number,
466
+ replyMessageId: number,
467
+ chatId: number,
468
+ msgId: number,
469
+ enabled: boolean,
470
+ ctx: Context,
471
+ deps: TelegramQueueMenuCallbackDeps<Context>,
472
+ ): Promise<void> {
473
+ deps.setPriority(chatId, msgId, enabled);
474
+ deps.updateStatus(ctx);
475
+ const updated = deps.findItem(chatId, msgId);
476
+ if (!updated) {
477
+ return refreshStaleTelegramQueueMenuItem(
478
+ callbackQueryId,
479
+ replyChatId,
480
+ replyMessageId,
481
+ deps,
482
+ );
483
+ }
484
+ await deps.updateQueueMessage(
485
+ replyChatId,
486
+ replyMessageId,
487
+ getTelegramQueueMenuItemText(updated),
488
+ buildTelegramQueueItemSubmenuReplyMarkup(
489
+ chatId,
490
+ msgId,
491
+ updated.isPriority,
492
+ updated.reactionSuppressionEmoji !== undefined,
493
+ ),
494
+ );
495
+ await deps.answerCallbackQuery(
496
+ callbackQueryId,
497
+ updated.isPriority ? "Prioritized." : "Normal priority.",
498
+ );
499
+ }
500
+
501
+ async function handleTelegramQueueMenuSkipSet<Context>(
502
+ callbackQueryId: string,
503
+ replyChatId: number,
504
+ replyMessageId: number,
505
+ chatId: number,
506
+ msgId: number,
507
+ skipped: boolean,
508
+ ctx: Context,
509
+ deps: TelegramQueueMenuCallbackDeps<Context>,
510
+ ): Promise<void> {
511
+ const item = deps.findItem(chatId, msgId);
512
+ if (!item) {
513
+ return refreshStaleTelegramQueueMenuItem(
514
+ callbackQueryId,
515
+ replyChatId,
516
+ replyMessageId,
517
+ deps,
518
+ );
519
+ }
520
+ deps.setSkipped(chatId, msgId, skipped);
521
+ deps.updateStatus(ctx);
522
+ const updated = deps.findItem(chatId, msgId);
523
+ if (!updated) {
524
+ return refreshStaleTelegramQueueMenuItem(
525
+ callbackQueryId,
526
+ replyChatId,
527
+ replyMessageId,
528
+ deps,
529
+ );
530
+ }
531
+ await deps.updateQueueMessage(
532
+ replyChatId,
533
+ replyMessageId,
534
+ getTelegramQueueMenuItemText(updated),
535
+ buildTelegramQueueItemSubmenuReplyMarkup(
536
+ chatId,
537
+ msgId,
538
+ updated.isPriority,
539
+ updated.reactionSuppressionEmoji !== undefined,
540
+ ),
541
+ );
542
+ await deps.answerCallbackQuery(callbackQueryId);
543
+ }
544
+
545
+ interface TelegramQueueMenuCallbackQuery {
546
+ id: string;
547
+ data?: string;
548
+ message?: { chat?: { id?: number }; message_id?: number };
549
+ }
550
+ interface TelegramQueueMenuRuntime<Context> {
551
+ openQueueMenu: (
552
+ chatId: number,
553
+ replyToMessageId: number,
554
+ ctx: Context,
555
+ ) => Promise<void>;
556
+ handleCallbackQuery: (
557
+ query: TelegramQueueMenuCallbackQuery,
558
+ ctx: Context,
559
+ ) => Promise<boolean>;
560
+ }
561
+ export function createTelegramQueueMenuRuntime<
562
+ Context,
563
+ TModel extends MenuModel = MenuModel,
564
+ >(deps: {
565
+ telegramQueueStore: Queue.TelegramQueueStateStore<Context>;
566
+ queueMutationRuntime: Queue.TelegramQueueMutationController<Context>;
567
+ sendInteractiveMessage: (
568
+ chatId: number,
569
+ text: string,
570
+ mode: "html",
571
+ replyMarkup: TelegramQueueMenuReplyMarkup,
572
+ ) => Promise<number | undefined>;
573
+ editInteractiveMessage: (
574
+ chatId: number,
575
+ messageId: number,
576
+ text: string,
577
+ mode: "html",
578
+ replyMarkup: TelegramQueueMenuReplyMarkup,
579
+ ) => Promise<void>;
580
+ answerCallbackQuery: (
581
+ callbackQueryId: string,
582
+ text?: string,
583
+ ) => Promise<void>;
584
+ getModelMenuState: (
585
+ chatId: number,
586
+ ctx: Context,
587
+ ) => Promise<TelegramModelMenuState<TModel>>;
588
+ getStoredModelMenuState: (
589
+ messageId: number | undefined,
590
+ chatId?: number,
591
+ ) => TelegramModelMenuState<TModel> | undefined;
592
+ storeModelMenuState: (state: TelegramModelMenuState<TModel>) => void;
593
+ updateStatusMessage: (
594
+ state: TelegramModelMenuState<TModel>,
595
+ ctx: Context,
596
+ ) => Promise<void>;
597
+ updateStatus: (ctx: Context) => void;
598
+ }): TelegramQueueMenuRuntime<Context> {
599
+ const sendQueueMenuMessage = createQueueMenuSendMessageAdapter(
600
+ deps.sendInteractiveMessage,
601
+ );
602
+ const editQueueMenuMessage = createQueueMenuEditMessageAdapter(
603
+ deps.editInteractiveMessage,
604
+ );
605
+ return {
606
+ openQueueMenu: createOpenQueueMenu<Context, TModel>({
607
+ getQueuedItems: deps.telegramQueueStore.getQueuedItems,
608
+ getModelMenuState: deps.getModelMenuState,
609
+ storeModelMenuState: deps.storeModelMenuState,
610
+ sendInteractiveMessage: sendQueueMenuMessage,
611
+ }),
612
+ handleCallbackQuery: createQueueMenuCallbackHandler<Context, TModel>({
613
+ telegramQueueStore: deps.telegramQueueStore,
614
+ queueMutationRuntime: deps.queueMutationRuntime,
615
+ editInteractiveMessage: editQueueMenuMessage,
616
+ getStoredModelMenuState: deps.getStoredModelMenuState,
617
+ updateStatusMessage: deps.updateStatusMessage,
618
+ answerCallbackQuery: deps.answerCallbackQuery,
619
+ updateStatus: deps.updateStatus,
620
+ }),
621
+ };
622
+ }
623
+
624
+ function createOpenQueueMenu<
625
+ Context,
626
+ TModel extends MenuModel = MenuModel,
627
+ >(deps: {
628
+ getQueuedItems: () => Queue.TelegramQueueItem<Context>[];
629
+ getModelMenuState: (
630
+ chatId: number,
631
+ ctx: Context,
632
+ ) => Promise<TelegramModelMenuState<TModel>>;
633
+ storeModelMenuState: (state: TelegramModelMenuState<TModel>) => void;
634
+ sendInteractiveMessage: (
635
+ chatId: number,
636
+ replyToMessageId: number,
637
+ text: string,
638
+ replyMarkup: TelegramQueueMenuReplyMarkup,
639
+ ) => Promise<number | undefined>;
640
+ }) {
641
+ return async (
642
+ chatId: number,
643
+ replyToMessageId: number,
644
+ ctx: Context,
645
+ ): Promise<void> => {
646
+ const state = await deps.getModelMenuState(chatId, ctx);
647
+ const menuItems = toTelegramQueueMenuItems(deps.getQueuedItems());
648
+ const text = getTelegramQueueMenuListText(menuItems);
649
+ const messageId = await deps.sendInteractiveMessage(
650
+ chatId,
651
+ replyToMessageId,
652
+ text,
653
+ buildTelegramQueueMenuReplyMarkup(menuItems),
654
+ );
655
+ if (messageId === undefined) return;
656
+ state.messageId = messageId;
657
+ state.mode = "queue";
658
+ deps.storeModelMenuState(state);
659
+ };
660
+ }
661
+
662
+ function createQueueMenuCallbackHandler<
663
+ Context,
664
+ TModel extends MenuModel = MenuModel,
665
+ >(deps: {
666
+ telegramQueueStore: Queue.TelegramQueueStateStore<Context>;
667
+ queueMutationRuntime: Queue.TelegramQueueMutationController<Context>;
668
+ editInteractiveMessage: (
669
+ chatId: number,
670
+ messageId: number,
671
+ text: string,
672
+ replyMarkup: TelegramQueueMenuReplyMarkup,
673
+ ) => Promise<number | undefined>;
674
+ getStoredModelMenuState: (
675
+ messageId: number | undefined,
676
+ chatId?: number,
677
+ ) => TelegramModelMenuState<TModel> | undefined;
678
+ updateStatusMessage: (
679
+ state: TelegramModelMenuState<TModel>,
680
+ ctx: Context,
681
+ ) => Promise<void>;
682
+ answerCallbackQuery: (
683
+ callbackQueryId: string,
684
+ text?: string,
685
+ ) => Promise<void>;
686
+ updateStatus: (ctx: Context) => void;
687
+ }) {
688
+ return async (
689
+ query: TelegramQueueMenuCallbackQuery,
690
+ ctx: Context,
691
+ ): Promise<boolean> => {
692
+ const data = query.data;
693
+ const chatId = query.message?.chat?.id;
694
+ const messageId = query.message?.message_id;
695
+ if (!data || typeof chatId !== "number" || typeof messageId !== "number")
696
+ return false;
697
+ if (data === "menu:queue" || data === "status:queue") {
698
+ const state = deps.getStoredModelMenuState(messageId, chatId);
699
+ if (!state) {
700
+ await deps.answerCallbackQuery(
701
+ query.id,
702
+ "Interactive message expired.",
703
+ );
704
+ return true;
705
+ }
706
+ const menuItems = toTelegramQueueMenuItems(
707
+ deps.telegramQueueStore.getQueuedItems(),
708
+ );
709
+ await deps.editInteractiveMessage(
710
+ chatId,
711
+ messageId,
712
+ getTelegramQueueMenuListText(menuItems),
713
+ buildTelegramQueueMenuReplyMarkup(menuItems),
714
+ );
715
+ state.mode = "queue";
716
+ await deps.answerCallbackQuery(query.id);
717
+ return true;
718
+ }
719
+ if (!data.startsWith("queue:")) return false;
720
+ const getQueueSnapshot = () => {
721
+ return deps.telegramQueueStore.getQueuedItems();
722
+ };
723
+ const toMenuItems = () => {
724
+ return toTelegramQueueMenuItems(getQueueSnapshot());
725
+ };
726
+ const findItem = (cId: number, rId: number) => {
727
+ return findTelegramQueueMenuItem(toMenuItems(), cId, rId);
728
+ };
729
+ return handleTelegramQueueMenuCallback(
730
+ query.id,
731
+ data,
732
+ chatId,
733
+ messageId,
734
+ ctx,
735
+ {
736
+ getQueuedItems: toMenuItems,
737
+ findItem,
738
+ togglePriority: (cId, rId) => {
739
+ return toggleQueuedTelegramPromptPriority(cId, rId, ctx, {
740
+ getQueueSnapshot,
741
+ queueMutationRuntime: deps.queueMutationRuntime,
742
+ });
743
+ },
744
+ setPriority: (cId, rId, enabled) => {
745
+ return setQueuedTelegramPromptPriority(cId, rId, enabled, ctx, {
746
+ getQueueSnapshot,
747
+ queueMutationRuntime: deps.queueMutationRuntime,
748
+ });
749
+ },
750
+ setSkipped: (cId, rId, skipped) => {
751
+ return setQueuedTelegramPromptSkipped(cId, rId, skipped, ctx, {
752
+ getQueueSnapshot,
753
+ queueMutationRuntime: deps.queueMutationRuntime,
754
+ });
755
+ },
756
+ updateQueueMessage: deps.editInteractiveMessage,
757
+ answerCallbackQuery: deps.answerCallbackQuery,
758
+ updateStatus: deps.updateStatus,
759
+ },
760
+ );
761
+ };
762
+ }
763
+
764
+ function getQueueMenuReactionDisposition<Context>(
765
+ item: Queue.TelegramQueueItem<Context>,
766
+ priority: boolean,
767
+ skipped: boolean,
768
+ ): Queue.TelegramQueueReactionDisposition {
769
+ if (priority && skipped) {
770
+ return {
771
+ kind: "priority-suppressed",
772
+ priorityEmoji:
773
+ item.kind === "prompt" ? item.priorityEmoji ?? "⚡" : "⚡",
774
+ suppressionEmoji:
775
+ item.kind === "prompt"
776
+ ? item.reactionSuppressionEmoji ?? "👎"
777
+ : "👎",
778
+ };
779
+ }
780
+ if (priority) {
781
+ return {
782
+ kind: "priority",
783
+ emoji: item.kind === "prompt" ? item.priorityEmoji ?? "⚡" : "⚡",
784
+ };
785
+ }
786
+ if (skipped) {
787
+ return {
788
+ kind: "suppressed",
789
+ emoji:
790
+ item.kind === "prompt"
791
+ ? item.reactionSuppressionEmoji ?? "👎"
792
+ : "👎",
793
+ };
794
+ }
795
+ return { kind: "default" };
796
+ }
797
+
798
+ function toggleQueuedTelegramPromptPriority<Context>(
799
+ chatId: number,
800
+ replyToMessageId: number,
801
+ ctx: Context,
802
+ deps: {
803
+ getQueueSnapshot: () => Queue.TelegramQueueItem<Context>[];
804
+ queueMutationRuntime: Queue.TelegramQueueMutationController<Context>;
805
+ },
806
+ ): boolean {
807
+ const item = findTelegramQueueItem(
808
+ deps.getQueueSnapshot(),
809
+ chatId,
810
+ replyToMessageId,
811
+ );
812
+ if (!item) return false;
813
+ deps.queueMutationRuntime.applyReactionByMessageId(
814
+ replyToMessageId,
815
+ getQueueMenuReactionDisposition(
816
+ item,
817
+ item.queueLane !== "priority",
818
+ item.kind === "prompt" &&
819
+ item.reactionSuppressionEmoji !== undefined,
820
+ ),
821
+ ctx,
822
+ );
823
+ return true;
824
+ }
825
+
826
+ function setQueuedTelegramPromptPriority<Context>(
827
+ chatId: number,
828
+ replyToMessageId: number,
829
+ enabled: boolean,
830
+ ctx: Context,
831
+ deps: {
832
+ getQueueSnapshot: () => Queue.TelegramQueueItem<Context>[];
833
+ queueMutationRuntime: Queue.TelegramQueueMutationController<Context>;
834
+ },
835
+ ): boolean {
836
+ const item = findTelegramQueueItem(
837
+ deps.getQueueSnapshot(),
838
+ chatId,
839
+ replyToMessageId,
840
+ );
841
+ if (!item) return false;
842
+ deps.queueMutationRuntime.applyReactionByMessageId(
843
+ replyToMessageId,
844
+ getQueueMenuReactionDisposition(
845
+ item,
846
+ enabled,
847
+ item.kind === "prompt" &&
848
+ item.reactionSuppressionEmoji !== undefined,
849
+ ),
850
+ ctx,
851
+ );
852
+ return true;
853
+ }
854
+
855
+ function setQueuedTelegramPromptSkipped<Context>(
856
+ chatId: number,
857
+ replyToMessageId: number,
858
+ skipped: boolean,
859
+ ctx: Context,
860
+ deps: {
861
+ getQueueSnapshot: () => Queue.TelegramQueueItem<Context>[];
862
+ queueMutationRuntime: Queue.TelegramQueueMutationController<Context>;
863
+ },
864
+ ): boolean {
865
+ const item = findTelegramQueueItem(
866
+ deps.getQueueSnapshot(),
867
+ chatId,
868
+ replyToMessageId,
869
+ );
870
+ if (!item || item.kind !== "prompt") return false;
871
+ deps.queueMutationRuntime.applyReactionByMessageId(
872
+ replyToMessageId,
873
+ getQueueMenuReactionDisposition(
874
+ item,
875
+ item.queueLane === "priority",
876
+ skipped,
877
+ ),
878
+ ctx,
879
+ );
880
+ return true;
881
+ }
882
+
883
+ function createQueueMenuSendMessageAdapter(
884
+ sendInteractiveMessage: (
885
+ chatId: number,
886
+ text: string,
887
+ mode: "html",
888
+ replyMarkup: TelegramQueueMenuReplyMarkup,
889
+ ) => Promise<number | undefined>,
890
+ ) {
891
+ return (
892
+ chatId: number,
893
+ _replyToMessageId: number,
894
+ text: string,
895
+ replyMarkup: TelegramQueueMenuReplyMarkup,
896
+ ): Promise<number | undefined> => {
897
+ return sendInteractiveMessage(chatId, text, "html", replyMarkup);
898
+ };
899
+ }
900
+
901
+ function createQueueMenuEditMessageAdapter(
902
+ editInteractiveMessage: (
903
+ chatId: number,
904
+ messageId: number,
905
+ text: string,
906
+ mode: "html",
907
+ replyMarkup: TelegramQueueMenuReplyMarkup,
908
+ ) => Promise<void>,
909
+ ) {
910
+ return (
911
+ chatId: number,
912
+ messageId: number,
913
+ text: string,
914
+ replyMarkup: TelegramQueueMenuReplyMarkup,
915
+ ): Promise<number | undefined> => {
916
+ return editInteractiveMessage(
917
+ chatId,
918
+ messageId,
919
+ text,
920
+ "html",
921
+ replyMarkup,
922
+ ).then(() => {
923
+ return undefined as number | undefined;
924
+ });
925
+ };
926
+ }