@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,951 @@
1
+ /**
2
+ * Async run observability helpers
3
+ * Zones: async runtime, ambient UI, diagnostics
4
+ * Owns ambient summaries, terminal events, and Trace-attention delivery for detached Runs
5
+ */
6
+ import { closeSync, existsSync, fstatSync, openSync, readdirSync, readFileSync, readSync, watch, } from "node:fs";
7
+ import { basename, dirname, isAbsolute, join, relative, } from "node:path";
8
+ import * as AsyncRuns from "./async-runs.js";
9
+ import * as Paths from "./paths.js";
10
+ import * as RunsTrace from "./runs-trace.js";
11
+ import { readJsonlFileResilient } from "./state-readers.js";
12
+ export function createRunUiObservationState() {
13
+ return {
14
+ attentionEventIds: new Map(),
15
+ legacyEventLines: new Map(),
16
+ frame: 0,
17
+ observed: new Map(),
18
+ };
19
+ }
20
+ export function primeRunAttentionState(state, ownerId, stateRoot) {
21
+ detectRunAttentionEvents(state.legacyEventLines, summarizeRuns(stateRoot, ownerId), state.attentionEventIds, true);
22
+ }
23
+ export function readRunUiSnapshot(state, ownerId, options = {}) {
24
+ const summary = summarizeRuns(options.stateRoot, ownerId);
25
+ const status = renderRunStatus(summary, state.frame++);
26
+ return {
27
+ attentionEvents: options.includeAttention === false
28
+ ? []
29
+ : detectRunAttentionEvents(state.legacyEventLines, summary, state.attentionEventIds),
30
+ status,
31
+ summary,
32
+ transitions: detectRunTransitions(state.observed, summary),
33
+ };
34
+ }
35
+ export function pruneRunUiObservationState(state, snapshot) {
36
+ pruneRunObservationState(state.observed, state.legacyEventLines, snapshot.summary, snapshot.transitions.map((transition) => transition.stateDir ?? transition.run), state.attentionEventIds);
37
+ }
38
+ export function deliverRunTransitionNotifications(transitions, sink, inFlight = new Set()) {
39
+ for (const transition of transitions) {
40
+ if (!shouldNotifyRunTransition(transition))
41
+ continue;
42
+ const key = transition.stateDir ?? transition.run;
43
+ if (inFlight.has(key))
44
+ continue;
45
+ inFlight.add(key);
46
+ try {
47
+ const text = formatRunTransitionMessage(transition);
48
+ sink.notify(text, getRunTransitionNotificationType(transition));
49
+ if (!shouldSendRunTransitionFollowUp(transition))
50
+ continue;
51
+ sink.sendFollowUp({
52
+ customType: "pi-actors-run",
53
+ content: text,
54
+ display: false,
55
+ details: transition,
56
+ });
57
+ if (transition.stateDir) {
58
+ AsyncRuns.markRunTerminalNotificationHandled(transition.stateDir, transition.to);
59
+ }
60
+ }
61
+ catch (error) {
62
+ if (transition.stateDir) {
63
+ AsyncRuns.recordRunTerminalDeliveryFailure(transition.stateDir, transition.to, error);
64
+ }
65
+ const message = error instanceof Error ? error.message : String(error);
66
+ sink.notify(`Actor terminal delivery failed for run:${transition.run}: ${message.replaceAll(/\s+/g, " ").slice(0, 240)}`, "error");
67
+ }
68
+ finally {
69
+ inFlight.delete(key);
70
+ }
71
+ }
72
+ }
73
+ export function reconcileRunTerminalNotifications(input) {
74
+ const snapshot = readRunUiSnapshot(input.state, input.ownerId, {
75
+ includeAttention: input.includeAttention,
76
+ stateRoot: input.stateRoot,
77
+ });
78
+ if (input.includeAttention)
79
+ deliverRunAttentionNotifications(snapshot.attentionEvents, input.sink);
80
+ deliverRunTransitionNotifications(snapshot.transitions, input.sink, input.inFlight);
81
+ pruneRunUiObservationState(input.state, snapshot);
82
+ return snapshot;
83
+ }
84
+ export function deliverRunAttentionNotifications(events, sink) {
85
+ for (const event of events) {
86
+ if (!shouldNotifyRunAttentionEvent(event))
87
+ continue;
88
+ const text = formatRunAttentionMessage(event);
89
+ sink.notify(text, getRunAttentionNotificationType(event));
90
+ if (!shouldSendRunAttentionFollowUp(event))
91
+ continue;
92
+ sink.sendFollowUp({
93
+ customType: "pi-actors-run-trace",
94
+ content: text,
95
+ display: false,
96
+ details: event,
97
+ });
98
+ }
99
+ }
100
+ const RUN_WATCHER_DIAGNOSTIC_LIMIT = 32;
101
+ export function createRunStateWatcher(input) {
102
+ const stateRoot = input.stateRoot ?? Paths.getRunStateRoot();
103
+ const pathExists = input.exists ?? existsSync;
104
+ const listDirectories = input.listDirectories ??
105
+ ((path) => readdirSync(path, { withFileTypes: true })
106
+ .filter((entry) => entry.isDirectory())
107
+ .map((entry) => join(path, entry.name)));
108
+ const watchPath = input.watchPath ?? ((path, onChange) => watch(path, onChange));
109
+ let diagnosticId = 0;
110
+ let rootDegraded = false;
111
+ let stateRootWatcher;
112
+ const degradedRunDirs = new Set();
113
+ const diagnostics = [];
114
+ const lastDiagnosticSignatures = new Map();
115
+ const runDirWatchers = new Map();
116
+ const record = (code, scope, path, error) => {
117
+ const detail = error instanceof Error ? `: ${error.message}` : "";
118
+ const signature = `${code}${detail}`;
119
+ const signatureKey = `${scope}:${path}`;
120
+ if (lastDiagnosticSignatures.get(signatureKey) === signature)
121
+ return;
122
+ lastDiagnosticSignatures.set(signatureKey, signature);
123
+ const recovery = code === "rearmed"
124
+ ? "; terminal watch acceleration restored"
125
+ : "; terminal reconciliation remains active and watcher rearm will retry";
126
+ diagnostics.push({
127
+ code,
128
+ id: ++diagnosticId,
129
+ message: `Run-state ${scope} watcher ${code.replace("_", " ")} for ${path}${detail}${recovery}`,
130
+ path,
131
+ scope,
132
+ ts: new Date().toISOString(),
133
+ });
134
+ if (diagnostics.length > RUN_WATCHER_DIAGNOSTIC_LIMIT)
135
+ diagnostics.shift();
136
+ };
137
+ const removeRunWatcher = (stateDir, watcher, options = {}) => {
138
+ if (runDirWatchers.get(stateDir) !== watcher)
139
+ return;
140
+ watcher.close();
141
+ runDirWatchers.delete(stateDir);
142
+ if (options.degraded === false) {
143
+ degradedRunDirs.delete(stateDir);
144
+ lastDiagnosticSignatures.delete(`run:${stateDir}`);
145
+ return;
146
+ }
147
+ degradedRunDirs.add(stateDir);
148
+ if (options.error)
149
+ record("error", "run", stateDir, options.error);
150
+ record("removed", "run", stateDir);
151
+ };
152
+ const close = () => {
153
+ stateRootWatcher?.close();
154
+ stateRootWatcher = undefined;
155
+ for (const watcher of runDirWatchers.values())
156
+ watcher.close();
157
+ runDirWatchers.clear();
158
+ };
159
+ const watchRunDir = (stateDir) => {
160
+ if (runDirWatchers.has(stateDir) || !pathExists(stateDir))
161
+ return;
162
+ try {
163
+ const watcher = watchPath(stateDir, input.onChange);
164
+ watcher.on("error", (error) => removeRunWatcher(stateDir, watcher, { error }));
165
+ runDirWatchers.set(stateDir, watcher);
166
+ if (degradedRunDirs.delete(stateDir))
167
+ record("rearmed", "run", stateDir);
168
+ }
169
+ catch (error) {
170
+ degradedRunDirs.add(stateDir);
171
+ record("attach_failed", "run", stateDir, error);
172
+ }
173
+ };
174
+ function refresh() {
175
+ if (!pathExists(stateRoot))
176
+ return;
177
+ if (!stateRootWatcher) {
178
+ try {
179
+ const watcher = watchPath(stateRoot, input.onChange);
180
+ stateRootWatcher = watcher;
181
+ watcher.on("error", (error) => {
182
+ if (stateRootWatcher !== watcher)
183
+ return;
184
+ watcher.close();
185
+ stateRootWatcher = undefined;
186
+ rootDegraded = true;
187
+ record("error", "root", stateRoot, error);
188
+ record("removed", "root", stateRoot);
189
+ });
190
+ if (rootDegraded) {
191
+ rootDegraded = false;
192
+ record("rearmed", "root", stateRoot);
193
+ }
194
+ }
195
+ catch (error) {
196
+ rootDegraded = true;
197
+ record("attach_failed", "root", stateRoot, error);
198
+ }
199
+ }
200
+ let stateDirs;
201
+ try {
202
+ stateDirs = listDirectories(stateRoot);
203
+ }
204
+ catch (error) {
205
+ record("attach_failed", "root", stateRoot, error);
206
+ return;
207
+ }
208
+ const present = new Set(stateDirs);
209
+ for (const [stateDir, watcher] of runDirWatchers) {
210
+ if (present.has(stateDir) && pathExists(stateDir))
211
+ continue;
212
+ removeRunWatcher(stateDir, watcher, { degraded: false });
213
+ }
214
+ for (const stateDir of stateDirs)
215
+ watchRunDir(stateDir);
216
+ }
217
+ return {
218
+ close,
219
+ getDiagnostics: () => [...diagnostics],
220
+ refresh,
221
+ };
222
+ }
223
+ export function createRunTerminalReconciliationLoop(input) {
224
+ const intervalMs = input.intervalMs ?? 10_000;
225
+ let interval;
226
+ const reconcileNow = () => {
227
+ try {
228
+ input.refreshWatcher();
229
+ input.reconcile();
230
+ }
231
+ catch (error) {
232
+ input.onError?.(error);
233
+ }
234
+ };
235
+ const close = () => {
236
+ if (interval)
237
+ clearInterval(interval);
238
+ interval = undefined;
239
+ };
240
+ const start = () => {
241
+ close();
242
+ interval = setInterval(reconcileNow, intervalMs);
243
+ interval.unref?.();
244
+ };
245
+ return { close, reconcileNow, start };
246
+ }
247
+ const TERMINAL = new Set([
248
+ "done",
249
+ "failed",
250
+ "exited",
251
+ "cancelled",
252
+ "killed",
253
+ ]);
254
+ const PROC_DESCENDANT_SCAN_TTL_MS = 1000;
255
+ const RUN_STATE_DISCOVERY_MAX_DEPTH = 8;
256
+ const procDescendantScanCache = new Map();
257
+ function toNumber(value) {
258
+ const number = Number(value);
259
+ return Number.isFinite(number) ? number : undefined;
260
+ }
261
+ function getProgress(status) {
262
+ const progress = status.progress;
263
+ return progress && typeof progress === "object"
264
+ ? progress
265
+ : {};
266
+ }
267
+ function getUpdatedAt(status) {
268
+ const progress = getProgress(status);
269
+ return typeof progress.updatedAt === "string"
270
+ ? progress.updatedAt
271
+ : typeof status.createdAt === "string"
272
+ ? status.createdAt
273
+ : undefined;
274
+ }
275
+ function scanRunStateDirs(stateRoot, depth = 0, seen = new Set()) {
276
+ if (!existsSync(stateRoot) || seen.has(stateRoot))
277
+ return [];
278
+ seen.add(stateRoot);
279
+ let entries;
280
+ try {
281
+ entries = readdirSync(stateRoot, { withFileTypes: true });
282
+ }
283
+ catch {
284
+ return [];
285
+ }
286
+ const result = [];
287
+ for (const entry of entries) {
288
+ if (!entry.isDirectory())
289
+ continue;
290
+ const child = join(stateRoot, entry.name);
291
+ if (existsSync(join(child, "run.json")))
292
+ result.push(child);
293
+ if (depth + 1 < RUN_STATE_DISCOVERY_MAX_DEPTH)
294
+ result.push(...scanRunStateDirs(child, depth + 1, seen));
295
+ }
296
+ return result;
297
+ }
298
+ const TERMINAL_RESULT_BYTES = 8 * 1024;
299
+ const TERMINAL_RESULT_CHARS = 4_000;
300
+ function readBoundedStart(path) {
301
+ if (!existsSync(path))
302
+ return "";
303
+ const fd = openSync(path, "r");
304
+ try {
305
+ const size = Math.min(fstatSync(fd).size, TERMINAL_RESULT_BYTES);
306
+ const buffer = Buffer.alloc(size);
307
+ const bytes = readSync(fd, buffer, 0, size, 0);
308
+ const text = buffer.subarray(0, bytes).toString("utf8").trim();
309
+ return text.length > TERMINAL_RESULT_CHARS
310
+ ? `${text.slice(0, TERMINAL_RESULT_CHARS - 1)}…`
311
+ : text;
312
+ }
313
+ finally {
314
+ closeSync(fd);
315
+ }
316
+ }
317
+ function semanticBodyFromStdout(stateDir) {
318
+ const text = readBoundedStart(join(stateDir, "stdout.log"));
319
+ if (!text)
320
+ return undefined;
321
+ const withoutMarker = text.replace(/^ACTOR_REVIEW_RESULT\s*(?:\r?\n)?/, "").trim();
322
+ return withoutMarker || undefined;
323
+ }
324
+ function terminalSemanticResult(status, stateDir, observedStatus) {
325
+ const correlation = status.launch_correlation &&
326
+ typeof status.launch_correlation === "object" &&
327
+ !Array.isArray(status.launch_correlation)
328
+ ? status.launch_correlation
329
+ : {};
330
+ const correlationId = typeof correlation.correlation_id === "string"
331
+ ? correlation.correlation_id
332
+ : typeof correlation.tool_call_id === "string"
333
+ ? correlation.tool_call_id
334
+ : undefined;
335
+ const reviewCompleted = false;
336
+ const result = status.result &&
337
+ typeof status.result === "object" &&
338
+ !Array.isArray(status.result)
339
+ ? status.result
340
+ : {};
341
+ const type = reviewCompleted
342
+ ? "review.completed"
343
+ : observedStatus === "done" ? "run.done" : "run.failed";
344
+ const stdoutBody = observedStatus === "done"
345
+ ? semanticBodyFromStdout(stateDir) : undefined;
346
+ return {
347
+ ...(stdoutBody
348
+ ? { body: stdoutBody }
349
+ : typeof result.error === "string" ? { body: result.error } : {}),
350
+ ...(correlationId ? { correlationId } : {}),
351
+ metadata: {
352
+ ...(status.transport_context &&
353
+ typeof status.transport_context === "object" &&
354
+ !Array.isArray(status.transport_context)
355
+ ? {
356
+ transport_context: status.transport_context,
357
+ } : {}),
358
+ run: String(status.run ?? ""), status: observedStatus,
359
+ },
360
+ summary: reviewCompleted ? "Review completed." :
361
+ observedStatus === "done" ? "Run completed." : `Run ${observedStatus}.`,
362
+ synthesized: true,
363
+ type,
364
+ };
365
+ }
366
+ function observeRun(stateDir) {
367
+ try {
368
+ const status = AsyncRuns.getRunStatus(stateDir);
369
+ const progress = getProgress(status);
370
+ const run = typeof status.run === "string" ? status.run : undefined;
371
+ if (!run)
372
+ return undefined;
373
+ const observedStatus = status.status;
374
+ return {
375
+ activeSubagents: toNumber(progress.activeSubagents),
376
+ completed: toNumber(progress.completed),
377
+ ...(status.launch_correlation &&
378
+ typeof status.launch_correlation === "object" &&
379
+ !Array.isArray(status.launch_correlation)
380
+ ? { launchCorrelation: status.launch_correlation }
381
+ : {}),
382
+ failures: Array.isArray(progress.failures)
383
+ ? progress.failures.length
384
+ : undefined,
385
+ ...(typeof status.ownerId === "string"
386
+ ? { ownerId: status.ownerId }
387
+ : {}),
388
+ ...(status.artifacts &&
389
+ typeof status.artifacts === "object" &&
390
+ !Array.isArray(status.artifacts)
391
+ ? { artifacts: status.artifacts }
392
+ : {}),
393
+ ...(status.launch_source === "spawn" || status.launch_source === "tool"
394
+ ? { launchSource: status.launch_source }
395
+ : {}),
396
+ ...(status.model_policy &&
397
+ typeof status.model_policy === "object" &&
398
+ !Array.isArray(status.model_policy)
399
+ ? { modelPolicy: status.model_policy }
400
+ : {}),
401
+ ...(status.notification_policy === "silent"
402
+ ? { notificationPolicy: "silent" }
403
+ : {}),
404
+ ...(typeof status.recipe_file === "string"
405
+ ? { recipeFile: status.recipe_file }
406
+ : {}),
407
+ ...(status.terminal_handled ? { terminalHandled: true } : {}),
408
+ ...(typeof status.retire_when === "string"
409
+ ? { retireWhen: status.retire_when }
410
+ : {}),
411
+ ...(TERMINAL.has(observedStatus)
412
+ ? { semanticResult: terminalSemanticResult(status, stateDir, observedStatus) }
413
+ : {}),
414
+ run,
415
+ stateDir,
416
+ status: observedStatus,
417
+ ...(typeof status.tool === "string" ? { tool: status.tool } : {}),
418
+ updatedAt: getUpdatedAt(status),
419
+ };
420
+ }
421
+ catch {
422
+ return undefined;
423
+ }
424
+ }
425
+ export function summarizeRuns(stateRoot = Paths.getRunStateRoot(), ownerId) {
426
+ if (!existsSync(stateRoot)) {
427
+ return {
428
+ cancelled: 0,
429
+ done: 0,
430
+ exited: 0,
431
+ failed: 0,
432
+ killed: 0,
433
+ running: 0,
434
+ runningSubagents: 0,
435
+ runs: [],
436
+ total: 0,
437
+ };
438
+ }
439
+ const runs = (AsyncRuns.readRunStateIndex(stateRoot)?.map((entry) => entry.state_dir) ??
440
+ scanRunStateDirs(stateRoot))
441
+ .map((stateDir) => observeRun(stateDir))
442
+ .filter((run) => Boolean(run))
443
+ .filter((run) => ownerId === undefined || run.ownerId === ownerId)
444
+ .sort((a, b) => (b.updatedAt ?? "").localeCompare(a.updatedAt ?? ""));
445
+ const processSubagentsByRun = countRunningSubagentsByRun(stateRoot, ownerId);
446
+ const runsWithDescendants = runs.map((run) => {
447
+ const descendantSubagents = processSubagentsByRun.get(run.run) ?? 0;
448
+ return descendantSubagents > 0 ? { ...run, descendantSubagents } : run;
449
+ });
450
+ const runningRuns = runsWithDescendants.filter((run) => run.status === "running");
451
+ const running = runningRuns.length;
452
+ const done = runsWithDescendants.filter((run) => run.status === "done").length;
453
+ const exited = runsWithDescendants.filter((run) => run.status === "exited").length;
454
+ const failed = runsWithDescendants.filter((run) => run.status === "failed").length;
455
+ const cancelled = runsWithDescendants.filter((run) => run.status === "cancelled").length;
456
+ const killed = runsWithDescendants.filter((run) => run.status === "killed").length;
457
+ const progressSubagents = runningRuns.reduce((sum, run) => sum + Math.max(1, Math.floor(run.activeSubagents ?? 0)), 0);
458
+ const processSubagents = [...processSubagentsByRun.values()].reduce((sum, count) => sum + count, 0);
459
+ const runningSubagents = Math.max(progressSubagents, running + processSubagents);
460
+ return {
461
+ cancelled,
462
+ done,
463
+ exited,
464
+ failed,
465
+ killed,
466
+ running,
467
+ runningSubagents,
468
+ runs: runsWithDescendants,
469
+ total: runsWithDescendants.length,
470
+ };
471
+ }
472
+ function readProcFile(path) {
473
+ try {
474
+ return readFileSync(path, "utf8");
475
+ }
476
+ catch {
477
+ return undefined;
478
+ }
479
+ }
480
+ function getProcPpid(pid) {
481
+ const stat = readProcFile(`/proc/${pid}/stat`);
482
+ if (!stat)
483
+ return undefined;
484
+ const close = stat.lastIndexOf(")");
485
+ if (close === -1)
486
+ return undefined;
487
+ return stat.slice(close + 2).split(" ")[1];
488
+ }
489
+ function getProcCommand(pid) {
490
+ return (readProcFile(`/proc/${pid}/cmdline`) ?? "").replaceAll("\0", " ");
491
+ }
492
+ function getRunningRunPidMap(stateRoot, ownerId) {
493
+ const pids = new Map();
494
+ for (const run of summarizeRunsWithoutSubagents(stateRoot, ownerId).runs) {
495
+ if (run.status !== "running")
496
+ continue;
497
+ const status = AsyncRuns.getRunStatus(run.stateDir ?? join(stateRoot, run.run));
498
+ const pid = Number(status.pid || 0);
499
+ if (pid > 0)
500
+ pids.set(String(pid), run.run);
501
+ }
502
+ return pids;
503
+ }
504
+ function summarizeRunsWithoutSubagents(stateRoot, ownerId) {
505
+ if (!existsSync(stateRoot))
506
+ return {
507
+ cancelled: 0,
508
+ done: 0,
509
+ exited: 0,
510
+ failed: 0,
511
+ killed: 0,
512
+ running: 0,
513
+ runs: [],
514
+ total: 0,
515
+ };
516
+ const runs = (AsyncRuns.readRunStateIndex(stateRoot)?.map((entry) => entry.state_dir) ??
517
+ scanRunStateDirs(stateRoot))
518
+ .map((stateDir) => observeRun(stateDir))
519
+ .filter((run) => Boolean(run))
520
+ .filter((run) => ownerId === undefined || run.ownerId === ownerId)
521
+ .sort((a, b) => (b.updatedAt ?? "").localeCompare(a.updatedAt ?? ""));
522
+ const running = runs.filter((run) => run.status === "running").length;
523
+ const done = runs.filter((run) => run.status === "done").length;
524
+ const exited = runs.filter((run) => run.status === "exited").length;
525
+ const failed = runs.filter((run) => run.status === "failed").length;
526
+ const cancelled = runs.filter((run) => run.status === "cancelled").length;
527
+ const killed = runs.filter((run) => run.status === "killed").length;
528
+ return {
529
+ cancelled,
530
+ done,
531
+ exited,
532
+ failed,
533
+ killed,
534
+ running,
535
+ runs,
536
+ total: runs.length,
537
+ };
538
+ }
539
+ export function countRunningSubagentsByRun(stateRoot = Paths.getRunStateRoot(), ownerId) {
540
+ const runPidMap = getRunningRunPidMap(stateRoot, ownerId);
541
+ if (runPidMap.size === 0 || !existsSync("/proc"))
542
+ return new Map();
543
+ const signature = [...runPidMap.keys()].sort().join(",");
544
+ const cacheKey = `${stateRoot}\0${ownerId ?? ""}`;
545
+ const cached = procDescendantScanCache.get(cacheKey);
546
+ const now = Date.now();
547
+ if (cached && cached.signature === signature && cached.expiresAt > now) {
548
+ return new Map(cached.counts);
549
+ }
550
+ const parentByPid = new Map();
551
+ const commandByPid = new Map();
552
+ let procEntries;
553
+ try {
554
+ procEntries = readdirSync("/proc", { withFileTypes: true });
555
+ }
556
+ catch {
557
+ return new Map();
558
+ }
559
+ for (const entry of procEntries) {
560
+ if (!entry.isDirectory() || !/^\d+$/.test(entry.name))
561
+ continue;
562
+ const ppid = getProcPpid(entry.name);
563
+ if (!ppid)
564
+ continue;
565
+ parentByPid.set(entry.name, ppid);
566
+ commandByPid.set(entry.name, getProcCommand(entry.name));
567
+ }
568
+ const runForDescendant = (pid) => {
569
+ let current = parentByPid.get(pid);
570
+ const seen = new Set();
571
+ while (current && !seen.has(current)) {
572
+ const run = runPidMap.get(current);
573
+ if (run)
574
+ return run;
575
+ seen.add(current);
576
+ current = parentByPid.get(current);
577
+ }
578
+ return undefined;
579
+ };
580
+ const counts = new Map();
581
+ for (const [pid, command] of commandByPid.entries()) {
582
+ if (!command.includes("pi -p") && !command.includes("pi\0-p"))
583
+ continue;
584
+ const run = runForDescendant(pid);
585
+ if (run)
586
+ counts.set(run, (counts.get(run) ?? 0) + 1);
587
+ }
588
+ procDescendantScanCache.set(cacheKey, {
589
+ counts,
590
+ expiresAt: now + PROC_DESCENDANT_SCAN_TTL_MS,
591
+ signature,
592
+ });
593
+ return new Map(counts);
594
+ }
595
+ export function countRunningSubagents(stateRoot = Paths.getRunStateRoot(), ownerId) {
596
+ return [...countRunningSubagentsByRun(stateRoot, ownerId).values()].reduce((sum, count) => sum + count, 0);
597
+ }
598
+ export function renderSubagentStatus(count, frame = 0) {
599
+ if (count <= 0)
600
+ return undefined;
601
+ if (count === 1)
602
+ return frame % 2 === 0 ? "▶" : "▷";
603
+ const active = frame % count;
604
+ return Array.from({ length: count }, (_value, index) => index === active ? "▶" : "▷").join(" ");
605
+ }
606
+ export function renderRunStatus(summary, frame = 0) {
607
+ return renderSubagentStatus(summary.runningSubagents, frame);
608
+ }
609
+ function isNestedStateDir(parent, child) {
610
+ const path = relative(parent, child);
611
+ return Boolean(path) && !path.startsWith("..") && !isAbsolute(path);
612
+ }
613
+ export function findRunRetirementCandidates(summary) {
614
+ return summary.runs
615
+ .map((run) => {
616
+ const activeSubagents = Math.max(0, Math.floor(run.activeSubagents ?? 0));
617
+ const descendantSubagents = Math.max(0, Math.floor(run.descendantSubagents ?? 0));
618
+ const childRuns = run.stateDir
619
+ ? summary.runs.filter((child) => child.stateDir !== undefined &&
620
+ child.stateDir !== run.stateDir &&
621
+ isNestedStateDir(run.stateDir, child.stateDir))
622
+ : [];
623
+ const runningChildRuns = childRuns.filter((child) => child.status === "running").length;
624
+ return {
625
+ activeSubagents,
626
+ childRuns: childRuns.length,
627
+ descendantSubagents,
628
+ ready: run.status === "running" &&
629
+ run.retireWhen === "children_terminal" &&
630
+ run.stateDir !== undefined &&
631
+ !run.terminalHandled &&
632
+ activeSubagents + descendantSubagents + runningChildRuns <= 0,
633
+ run,
634
+ terminalChildRuns: childRuns.filter((child) => TERMINAL.has(child.status)).length,
635
+ };
636
+ })
637
+ .filter((item) => item.ready)
638
+ .map((item) => ({
639
+ activeSubagents: item.activeSubagents,
640
+ childRuns: item.childRuns,
641
+ descendantSubagents: item.descendantSubagents,
642
+ run: item.run.run,
643
+ stateDir: item.run.stateDir,
644
+ terminalChildRuns: item.terminalChildRuns,
645
+ }));
646
+ }
647
+ export async function executeRunRetirements(summary, options) {
648
+ const results = [];
649
+ for (const candidate of findRunRetirementCandidates(summary)) {
650
+ if (options.attempted?.has(candidate.stateDir)) {
651
+ results.push({
652
+ action: "skip",
653
+ run: candidate.run,
654
+ stateDir: candidate.stateDir,
655
+ });
656
+ continue;
657
+ }
658
+ options.attempted?.add(candidate.stateDir);
659
+ try {
660
+ await options.sendStop(candidate);
661
+ options.notify?.(`Retiring actor ${candidate.run} after child runs reached terminal state`, "info");
662
+ results.push({
663
+ action: "stop",
664
+ run: candidate.run,
665
+ stateDir: candidate.stateDir,
666
+ });
667
+ continue;
668
+ }
669
+ catch (error) {
670
+ try {
671
+ const cancelResult = options.cancelRun(candidate);
672
+ const cancelled = Boolean(cancelResult.cancelled);
673
+ options.notify?.(cancelled
674
+ ? `Retiring actor ${candidate.run} by cancellation after graceful stop failed`
675
+ : `Actor retirement skipped for ${candidate.run}: ${error instanceof Error ? error.message : String(error)}`, cancelled ? "warning" : "error");
676
+ results.push({
677
+ action: cancelled ? "cancel" : "skip",
678
+ ...(cancelled
679
+ ? {}
680
+ : {
681
+ error: error instanceof Error ? error.message : String(error),
682
+ }),
683
+ run: candidate.run,
684
+ stateDir: candidate.stateDir,
685
+ });
686
+ }
687
+ catch (cancelError) {
688
+ const message = cancelError instanceof Error
689
+ ? cancelError.message
690
+ : String(cancelError);
691
+ options.notify?.(`Actor retirement failed for ${candidate.run}: ${message}`, "error");
692
+ results.push({
693
+ action: "failed",
694
+ error: message,
695
+ run: candidate.run,
696
+ stateDir: candidate.stateDir,
697
+ });
698
+ }
699
+ }
700
+ }
701
+ return results;
702
+ }
703
+ function runObservationKey(run) {
704
+ return run.stateDir ?? run.run;
705
+ }
706
+ export function detectRunTransitions(previous, summary) {
707
+ const transitions = [];
708
+ for (const run of summary.runs) {
709
+ const key = runObservationKey(run);
710
+ const old = previous.get(key);
711
+ if (run.notificationPolicy !== "silent" &&
712
+ !run.terminalHandled &&
713
+ TERMINAL.has(run.status)) {
714
+ transitions.push({
715
+ from: old ?? "running",
716
+ run: run.run,
717
+ ...(run.stateDir ? { stateDir: run.stateDir } : {}),
718
+ ...(run.artifacts ? { artifacts: run.artifacts } : {}),
719
+ ...(run.launchCorrelation ? { launchCorrelation: run.launchCorrelation } : {}),
720
+ ...(run.launchSource ? { launchSource: run.launchSource } : {}),
721
+ ...(run.modelPolicy ? { modelPolicy: run.modelPolicy } : {}),
722
+ ...(run.recipeFile ? { recipeFile: run.recipeFile } : {}),
723
+ ...(run.semanticResult ? { semanticResult: run.semanticResult } : {}),
724
+ ...(run.terminalHandled ? { terminalHandled: true } : {}),
725
+ to: run.status,
726
+ ...(run.tool ? { tool: run.tool } : {}),
727
+ });
728
+ }
729
+ previous.set(key, run.status);
730
+ }
731
+ return transitions;
732
+ }
733
+ function normalizeTraceAttention(value) {
734
+ return value === "notify" || value === "followup" ? value : "log";
735
+ }
736
+ function normalizeTraceLevel(value) {
737
+ return value === "warning" || value === "error" ? value : "info";
738
+ }
739
+ function parseAttentionRecord(raw, run, index) {
740
+ if (!run.stateDir)
741
+ return undefined;
742
+ const event = typeof raw.kind === "string" && raw.kind.trim()
743
+ ? raw.kind.trim()
744
+ : typeof raw.event === "string" && raw.event.trim()
745
+ ? raw.event.trim()
746
+ : "run.event";
747
+ const summary = typeof raw.summary === "string" && raw.summary.trim()
748
+ ? raw.summary.trim()
749
+ : event;
750
+ const ts = typeof raw.ts === "string" && raw.ts.trim()
751
+ ? raw.ts.trim()
752
+ : new Date(0).toISOString();
753
+ const id = typeof raw.id === "string" && raw.id.trim()
754
+ ? raw.id.trim()
755
+ : `${run.run}:${index}`;
756
+ return {
757
+ ...(raw.body !== undefined ? { body: raw.body } : {}),
758
+ ...(raw.data !== undefined ? { data: raw.data } : {}),
759
+ attention: raw.attention === "notify" || raw.attention === "followup"
760
+ ? raw.attention
761
+ : normalizeTraceAttention(raw.delivery),
762
+ id,
763
+ kind: event,
764
+ level: normalizeTraceLevel(raw.level),
765
+ ...(raw.metadata &&
766
+ typeof raw.metadata === "object" &&
767
+ !Array.isArray(raw.metadata)
768
+ ? { metadata: raw.metadata }
769
+ : {}),
770
+ run: run.run,
771
+ stateDir: run.stateDir,
772
+ summary,
773
+ ts,
774
+ };
775
+ }
776
+ function readTraceAttentionRecords(run) {
777
+ if (!run.stateDir)
778
+ return { canonical: true, records: [] };
779
+ if (existsSync(join(run.stateDir, "trace.jsonl")))
780
+ return {
781
+ canonical: true,
782
+ records: RunsTrace.readRunTraceJournal(run.stateDir).events.map(({ event }) => event),
783
+ };
784
+ return { canonical: false, records: readJsonlFileResilient(join(run.stateDir, "outbox.jsonl")).records };
785
+ }
786
+ export function pruneRunObservationState(previousStatuses, previousLineCounts, summary, terminalRuns = [], seenEventIds = new Map()) {
787
+ const activeRuns = new Set(summary.runs.map((run) => runObservationKey(run)));
788
+ const terminalRunSet = new Set(terminalRuns);
789
+ const activeLineKeys = new Set(summary.runs.map((run) => run.stateDir ?? run.run));
790
+ for (const run of terminalRunSet)
791
+ previousStatuses.delete(run);
792
+ for (const run of previousStatuses.keys())
793
+ if (!activeRuns.has(run))
794
+ previousStatuses.delete(run);
795
+ for (const key of previousLineCounts.keys())
796
+ if (!activeLineKeys.has(key))
797
+ previousLineCounts.delete(key);
798
+ for (const key of seenEventIds.keys())
799
+ if (!activeLineKeys.has(key))
800
+ seenEventIds.delete(key);
801
+ }
802
+ export function detectRunAttentionEvents(legacyLineCounts, summary, seenEventIds = new Map(), prime = false) {
803
+ const events = [];
804
+ for (const run of summary.runs) {
805
+ const key = run.stateDir ?? run.run;
806
+ const read = readTraceAttentionRecords(run);
807
+ const retained = new Set();
808
+ const seen = seenEventIds.get(key) ?? new Set();
809
+ const start = read.canonical ? 0
810
+ : Math.min(legacyLineCounts.get(key) ?? 0, read.records.length);
811
+ for (const [index, record] of read.records.entries()) {
812
+ const event = parseAttentionRecord(record, run, index);
813
+ if (!event || !shouldNotifyRunAttentionEvent(event) ||
814
+ event.kind === "runtime.trace_compacted")
815
+ continue;
816
+ retained.add(event.id);
817
+ if (prime || run.notificationPolicy === "silent")
818
+ seen.add(event.id);
819
+ else if (index >= start && !seen.has(event.id)) {
820
+ events.push(event);
821
+ seen.add(event.id);
822
+ }
823
+ }
824
+ seenEventIds.set(key, new Set([...retained].filter((id) => seen.has(id))));
825
+ if (read.canonical)
826
+ legacyLineCounts.delete(key);
827
+ else
828
+ legacyLineCounts.set(key, read.records.length);
829
+ }
830
+ return events;
831
+ }
832
+ export function getRunAttentionNotificationType(event) {
833
+ return event.level;
834
+ }
835
+ export function shouldNotifyRunAttentionEvent(event) {
836
+ return event.attention === "notify" || event.attention === "followup";
837
+ }
838
+ export function shouldSendRunAttentionFollowUp(event) {
839
+ return event.attention === "followup";
840
+ }
841
+ function commonDirectory(paths) {
842
+ if (paths.length === 0)
843
+ return undefined;
844
+ const split = (path) => dirname(path).split("/").filter(Boolean);
845
+ const first = split(paths[0]);
846
+ let length = first.length;
847
+ for (const path of paths.slice(1)) {
848
+ const parts = split(path);
849
+ length = Math.min(length, parts.length);
850
+ for (let index = 0; index < length; index += 1) {
851
+ if (first[index] !== parts[index]) {
852
+ length = index;
853
+ break;
854
+ }
855
+ }
856
+ }
857
+ if (length === 0)
858
+ return paths[0].startsWith("/") ? "/" : undefined;
859
+ return `${paths[0].startsWith("/") ? "/" : ""}${first.slice(0, length).join("/")}`;
860
+ }
861
+ function relativeName(base, path) {
862
+ if (!base)
863
+ return basename(path) || path;
864
+ const name = relative(base, path);
865
+ return name && !name.startsWith("..") ? name : basename(path) || path;
866
+ }
867
+ function formatPathGroup(label, paths) {
868
+ const unique = [...new Set(paths.filter(Boolean))].slice(0, 8);
869
+ if (unique.length === 0)
870
+ return "";
871
+ const base = commonDirectory(unique);
872
+ const names = unique
873
+ .map((path) => `\`${relativeName(base, path)}\``)
874
+ .join(", ");
875
+ return `\n${label}:\n- Base: ${base ? `\`${base}\`` : "current run"}\n- Files: ${names}`;
876
+ }
877
+ function formatRunFileList(files) {
878
+ if (!Array.isArray(files))
879
+ return "";
880
+ return formatPathGroup("Run files", files.filter((file) => typeof file === "string"));
881
+ }
882
+ function formatNamedArtifacts(artifacts) {
883
+ if (!artifacts || typeof artifacts !== "object" || Array.isArray(artifacts))
884
+ return "";
885
+ return formatPathGroup("Artifacts", Object.values(artifacts).filter((path) => typeof path === "string"));
886
+ }
887
+ function getAttentionDataField(event, key) {
888
+ return event.data &&
889
+ typeof event.data === "object" &&
890
+ !Array.isArray(event.data)
891
+ ? event.data[key]
892
+ : undefined;
893
+ }
894
+ function formatBodyPreview(body) {
895
+ if (body === undefined)
896
+ return "";
897
+ const rendered = typeof body === "string" ? body : JSON.stringify(body);
898
+ const compact = rendered.replaceAll(/\s+/g, " ").trim();
899
+ if (!compact)
900
+ return "";
901
+ return `\nBody: ${compact.length > 500 ? `${compact.slice(0, 500)}…` : compact}`;
902
+ }
903
+ export function formatRunAttentionMessage(event) {
904
+ if (event.kind === "command.done")
905
+ return `Run ${event.run}: ${event.summary}`;
906
+ return `Run ${event.run}: ${event.summary}${formatBodyPreview(event.body)}${formatNamedArtifacts(getAttentionDataField(event, "artifacts"))}${formatRunFileList(getAttentionDataField(event, "run_files"))}`;
907
+ }
908
+ export function getRunTransitionNotificationType(transition) {
909
+ if (transition.to === "done" || transition.to === "cancelled")
910
+ return "info";
911
+ if (transition.to === "killed" || transition.to === "exited")
912
+ return "warning";
913
+ return "error";
914
+ }
915
+ export function shouldNotifyRunTransition(transition) {
916
+ if (transition.terminalHandled)
917
+ return false;
918
+ return (transition.to === "done" ||
919
+ transition.to === "failed" ||
920
+ transition.to === "killed" ||
921
+ transition.to === "exited");
922
+ }
923
+ export function shouldSendRunTransitionFollowUp(transition) {
924
+ return shouldNotifyRunTransition(transition);
925
+ }
926
+ const TERMINAL_FOLLOW_UP_ARTIFACT_LIMIT = 4;
927
+ const TERMINAL_FOLLOW_UP_IDENTIFIER_CHARS = 120;
928
+ const TERMINAL_FOLLOW_UP_PATH_CHARS = 320;
929
+ function compactTerminalText(value, limit) {
930
+ const compact = value.replaceAll(/\s+/g, " ").trim();
931
+ return compact.length > limit ? `${compact.slice(0, limit - 1)}…` : compact;
932
+ }
933
+ function formatTerminalPath(path) {
934
+ return `\`${compactTerminalText(path, TERMINAL_FOLLOW_UP_PATH_CHARS)}\``;
935
+ }
936
+ function formatTerminalResultLocations(transition) {
937
+ const artifactPaths = [...new Set(Object.values(transition.artifacts ?? {}).filter((path) => typeof path === "string" && path.length > 0))];
938
+ if (artifactPaths.length === 0)
939
+ return transition.stateDir ? `\nBase: ${formatTerminalPath(transition.stateDir)}` : "";
940
+ const base = commonDirectory(artifactPaths);
941
+ const artifactPreview = artifactPaths
942
+ .slice(0, TERMINAL_FOLLOW_UP_ARTIFACT_LIMIT)
943
+ .map((path) => formatTerminalPath(base ? relativeName(base, path) : path));
944
+ const omitted = artifactPaths.length - artifactPreview.length;
945
+ const artifacts = `${artifactPreview.join(", ")}${omitted > 0 ? ` (+${omitted} more)` : ""}`;
946
+ return `${base ? `\nBase: ${formatTerminalPath(base)}` : ""}\nArtifacts: ${artifacts}`;
947
+ }
948
+ export function formatRunTransitionMessage(transition) {
949
+ const run = compactTerminalText(transition.run, TERMINAL_FOLLOW_UP_IDENTIFIER_CHARS);
950
+ return `Run: \`${run}\`\nStatus: \`${transition.to}\`${formatTerminalResultLocations(transition)}`;
951
+ }