@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,1060 @@
1
+ /**
2
+ * File-discovered recipe registry helpers
3
+ * Zones: recipe discovery, tool exposure, registry diagnostics
4
+ * Owns filename identity discovery across prioritized recipe roots
5
+ */
6
+
7
+ import { execFileSync } from "node:child_process";
8
+ import { createHash } from "node:crypto";
9
+ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
10
+ import { join } from "node:path";
11
+
12
+ import * as CommandTemplates from "./command-templates.ts";
13
+ import type { RegisteredTool } from "./config.ts";
14
+ import * as ModelContext from "./model-context.ts";
15
+ import type { RecipeResolutionContext } from "./recipes-context.ts";
16
+ import type { TemplateRecipeConfig } from "./recipes-references.ts";
17
+ import * as RecipesReferences from "./recipes-references.ts";
18
+ import * as RecipesUsage from "./recipes-usage.ts";
19
+ import * as Schema from "./schema.ts";
20
+
21
+ export interface DiscoveredRecipe {
22
+ id: string;
23
+ path: string;
24
+ root: string;
25
+ priority: number;
26
+ config?: TemplateRecipeConfig;
27
+ active: boolean;
28
+ shadowed: boolean;
29
+ invalid: boolean;
30
+ disabled: boolean;
31
+ tool: boolean;
32
+ mutableUsage: boolean;
33
+ resolutionContext?: RecipeResolutionContext;
34
+ diagnostics: string[];
35
+ riskLabels: CommandTemplates.CommandTemplateRiskLabel[];
36
+ shadows: string[];
37
+ }
38
+
39
+ export interface RecipeIntegrityManifestEntry {
40
+ id: string;
41
+ path: string;
42
+ root: string;
43
+ sha256: string;
44
+ size: number;
45
+ tool: boolean;
46
+ active: boolean;
47
+ invalid: boolean;
48
+ disabled: boolean;
49
+ shadowed: boolean;
50
+ }
51
+
52
+ export interface RecipesDiscoveryResult {
53
+ active: Map<string, DiscoveredRecipe>;
54
+ entries: DiscoveredRecipe[];
55
+ diagnostics: string[];
56
+ }
57
+
58
+ export interface RecipesDiscoverySource {
59
+ root?: string;
60
+ file?: string;
61
+ defaultTool?: boolean;
62
+ mutableUsage?: boolean;
63
+ resolutionContext?: RecipeResolutionContext;
64
+ }
65
+
66
+ export interface UserRecipeAdmission {
67
+ args?: string[];
68
+ argTypes?: RegisteredTool["argTypes"];
69
+ artifacts?: Record<string, string>;
70
+ async?: boolean;
71
+ control?: string[];
72
+ defaults?: Record<string, unknown>;
73
+ diagnostics: string[];
74
+ effectiveRecipe?: TemplateRecipeConfig;
75
+ identity: string;
76
+ sourcePath: string;
77
+ tool?: RegisteredTool;
78
+ validated: boolean;
79
+ }
80
+
81
+ function assertToolSafeRepeatConfig(
82
+ config: unknown,
83
+ argTypes: Record<string, { kind: string }>,
84
+ defaults: Record<string, unknown>,
85
+ ): void {
86
+ if (typeof config === "string" || config === undefined || config === null)
87
+ return;
88
+ if (Array.isArray(config)) {
89
+ for (const step of config)
90
+ assertToolSafeRepeatConfig(step, argTypes, defaults);
91
+ return;
92
+ }
93
+ if (typeof config !== "object") return;
94
+ const node = config as {
95
+ repeat?: unknown;
96
+ template?: unknown;
97
+ recover?: unknown;
98
+ };
99
+ if (typeof node.repeat === "string") {
100
+ const trimmed = node.repeat.trim();
101
+ if (!/^\d+$/.test(trimmed)) {
102
+ const match = trimmed.match(/^\{?([A-Za-z_][A-Za-z0-9_-]*)\.length\}?$/);
103
+ if (
104
+ !match ||
105
+ (argTypes[match[1]]?.kind !== "array" &&
106
+ !Array.isArray(defaults[match[1]]))
107
+ )
108
+ throw new Error(
109
+ "Command template repeat must be a positive integer or {array.length} with an array argument/default.",
110
+ );
111
+ }
112
+ }
113
+ assertToolSafeRepeatConfig(node.template, argTypes, defaults);
114
+ assertToolSafeRepeatConfig(node.recover, argTypes, defaults);
115
+ }
116
+
117
+ function listRecipeFiles(root: string): string[] {
118
+ if (!existsSync(root)) return [];
119
+ return readdirSync(root, { withFileTypes: true })
120
+ .filter(
121
+ (entry) =>
122
+ entry.isFile() &&
123
+ (entry.name.endsWith(".json") || entry.name.endsWith(".md")),
124
+ )
125
+ .map((entry) => join(root, entry.name))
126
+ .sort(
127
+ (a, b) =>
128
+ a
129
+ .replace(/\.md$/, ".json")
130
+ .localeCompare(b.replace(/\.md$/, ".json")) ||
131
+ (a.endsWith(".json") ? -1 : 1),
132
+ );
133
+ }
134
+
135
+ function getRecipeCommandTemplateConfig(
136
+ config: TemplateRecipeConfig,
137
+ ): CommandTemplates.CommandTemplateConfig {
138
+ return (typeof config.template === "object" && config.template !== null
139
+ ? config.template
140
+ : config) as CommandTemplates.CommandTemplateConfig;
141
+ }
142
+
143
+ function getRecipeDiagnosticTemplateConfig(
144
+ config: TemplateRecipeConfig,
145
+ ): CommandTemplates.CommandTemplateObjectConfig {
146
+ const templateConfig = getRecipeCommandTemplateConfig(config);
147
+ return typeof templateConfig === "object" && !Array.isArray(templateConfig)
148
+ ? {
149
+ ...templateConfig,
150
+ defaults: {
151
+ ...(templateConfig.defaults ?? {}),
152
+ ...(config.defaults ?? {}),
153
+ ...(config.values ?? {}),
154
+ },
155
+ }
156
+ : {
157
+ defaults: { ...(config.defaults ?? {}), ...(config.values ?? {}) },
158
+ template: templateConfig,
159
+ };
160
+ }
161
+
162
+ function getRecipeConfigDiagnostics(
163
+ file: string,
164
+ config: TemplateRecipeConfig | undefined,
165
+ ): string[] {
166
+ if (!config) {
167
+ const reason = RecipesReferences.diagnoseRawRecipeConfigFailure(file);
168
+ return [`Invalid recipe: ${file}${reason ? `: ${reason}` : ""}`];
169
+ }
170
+ return CommandTemplates.getCommandTemplateWarnings(
171
+ getRecipeDiagnosticTemplateConfig(config),
172
+ ).map((warning) => `Recipe ${file}: ${warning}`);
173
+ }
174
+
175
+ function getRecipeRiskLabels(
176
+ config: TemplateRecipeConfig | undefined,
177
+ ): CommandTemplates.CommandTemplateRiskLabel[] {
178
+ if (!config) return [];
179
+ const labels = new Set(
180
+ CommandTemplates.getCommandTemplateRiskLabels(
181
+ getRecipeDiagnosticTemplateConfig(config),
182
+ ),
183
+ );
184
+ if (config.async === true) labels.add("risk.long_running");
185
+ return [
186
+ "risk.shell",
187
+ "risk.eval",
188
+ "risk.destructive_fs",
189
+ "risk.broad_fs_write",
190
+ "risk.external_side_effect",
191
+ "risk.secret_touching",
192
+ "risk.network",
193
+ "risk.long_running",
194
+ "risk.platform_specific",
195
+ ].filter((label): label is CommandTemplates.CommandTemplateRiskLabel =>
196
+ labels.has(label as CommandTemplates.CommandTemplateRiskLabel),
197
+ );
198
+ }
199
+
200
+ function readDiscoveredRecipe(
201
+ root: string,
202
+ file: string,
203
+ priority: number,
204
+ defaultTool = false,
205
+ mutableUsage = false,
206
+ resolutionContext?: RecipeResolutionContext,
207
+ ): DiscoveredRecipe {
208
+ const id = RecipesReferences.getRecipeIdFromPath(file);
209
+ try {
210
+ const config = RecipesReferences.readResolvedRecipeConfig(file, [], {
211
+ skillContext: resolutionContext?.activeSkills,
212
+ });
213
+ const invalid = !config;
214
+ const disabled = config?.disabled === true;
215
+ return {
216
+ id,
217
+ path: file,
218
+ root,
219
+ priority,
220
+ config,
221
+ active: false,
222
+ shadowed: false,
223
+ invalid,
224
+ disabled,
225
+ tool: defaultTool && !disabled && !invalid,
226
+ mutableUsage,
227
+ resolutionContext,
228
+ diagnostics: getRecipeConfigDiagnostics(file, config),
229
+ riskLabels: getRecipeRiskLabels(config),
230
+ shadows: [],
231
+ };
232
+ } catch (error) {
233
+ return {
234
+ id,
235
+ path: file,
236
+ root,
237
+ priority,
238
+ active: false,
239
+ shadowed: false,
240
+ invalid: true,
241
+ disabled: false,
242
+ tool: false,
243
+ mutableUsage,
244
+ resolutionContext,
245
+ diagnostics: [
246
+ `Recipe ${id} rejected: ${error instanceof Error ? error.message : String(error)}`,
247
+ ],
248
+ riskLabels: [],
249
+ shadows: [],
250
+ };
251
+ }
252
+ }
253
+
254
+ function filesForSource(source: RecipesDiscoverySource): Array<{
255
+ root: string;
256
+ file: string;
257
+ defaultTool: boolean;
258
+ mutableUsage: boolean;
259
+ resolutionContext?: RecipeResolutionContext;
260
+ }> {
261
+ const defaultTool = source.defaultTool === true;
262
+ const mutableUsage = source.mutableUsage === true;
263
+ if (source.file)
264
+ return [
265
+ {
266
+ root: source.root ?? source.file,
267
+ file: source.file,
268
+ defaultTool,
269
+ mutableUsage,
270
+ resolutionContext: source.resolutionContext,
271
+ },
272
+ ];
273
+ return source.root
274
+ ? listRecipeFiles(source.root).map((file) => ({
275
+ root: source.root!,
276
+ file,
277
+ defaultTool,
278
+ mutableUsage,
279
+ resolutionContext: source.resolutionContext,
280
+ }))
281
+ : [];
282
+ }
283
+
284
+ const WINDOWS_BROAD_WRITE_PRINCIPALS = [
285
+ "Everyone",
286
+ "BUILTIN\\Users",
287
+ "Authenticated Users",
288
+ "S-1-1-0",
289
+ "S-1-5-11",
290
+ "S-1-5-32-545",
291
+ ];
292
+
293
+ const WINDOWS_WRITE_ACL_PATTERN = /\((?:[^)]*,)?(?:F|M|W|WD|AD|DC|GA|GW)(?:,[^)]*)?\)/i;
294
+
295
+ export function hasBroadWindowsWriteAcl(icaclsOutput: string): boolean {
296
+ return icaclsOutput
297
+ .split(/\r?\n/)
298
+ .some((line) =>
299
+ WINDOWS_BROAD_WRITE_PRINCIPALS.some((principal) =>
300
+ line.includes(principal),
301
+ ) && WINDOWS_WRITE_ACL_PATTERN.test(line),
302
+ );
303
+ }
304
+
305
+ function getWindowsRecipeRootDiagnostics(root: string): string[] {
306
+ try {
307
+ const output = execFileSync("icacls", [root], {
308
+ encoding: "utf8",
309
+ windowsHide: true,
310
+ timeout: 5000,
311
+ });
312
+ if (!hasBroadWindowsWriteAcl(output)) return [];
313
+ return [
314
+ `Recipe root grants write access to broad Windows principals; review ACLs: ${root}`,
315
+ ];
316
+ } catch (error) {
317
+ return [
318
+ `Failed to inspect Windows ACL for recipe root ${root}: ${error instanceof Error ? error.message : String(error)}`,
319
+ ];
320
+ }
321
+ }
322
+
323
+ function getPosixRecipeRootDiagnostics(root: string): string[] {
324
+ const diagnostics: string[] = [];
325
+ const stat = statSync(root);
326
+ if ((stat.mode & 0o002) !== 0) {
327
+ diagnostics.push(
328
+ `Recipe root is world-writable; review permissions: ${root}`,
329
+ );
330
+ }
331
+ if ((stat.mode & 0o020) !== 0) {
332
+ diagnostics.push(
333
+ `Recipe root is group-writable; review ownership and permissions: ${root}`,
334
+ );
335
+ }
336
+ return diagnostics;
337
+ }
338
+
339
+ function getRecipeRootDiagnostics(sources: RecipesDiscoverySource[]): string[] {
340
+ const diagnostics: string[] = [];
341
+ const roots = new Set(
342
+ sources
343
+ .map((source) => source.root)
344
+ .filter((root): root is string => typeof root === "string"),
345
+ );
346
+ for (const root of roots) {
347
+ try {
348
+ if (!existsSync(root)) continue;
349
+ diagnostics.push(
350
+ ...(process.platform === "win32"
351
+ ? getWindowsRecipeRootDiagnostics(root)
352
+ : getPosixRecipeRootDiagnostics(root)),
353
+ );
354
+ } catch (error) {
355
+ diagnostics.push(
356
+ `Failed to inspect recipe root ${root}: ${error instanceof Error ? error.message : String(error)}`,
357
+ );
358
+ }
359
+ }
360
+ return diagnostics;
361
+ }
362
+
363
+ export function discoverRecipeSources(
364
+ sources: RecipesDiscoverySource[],
365
+ ): RecipesDiscoveryResult {
366
+ const entries = sources.flatMap((source, priority) =>
367
+ filesForSource(source).map(
368
+ ({ root, file, defaultTool, mutableUsage, resolutionContext }) =>
369
+ readDiscoveredRecipe(
370
+ root,
371
+ file,
372
+ priority,
373
+ defaultTool,
374
+ mutableUsage,
375
+ resolutionContext,
376
+ ),
377
+ ),
378
+ );
379
+ const byId = new Map<string, DiscoveredRecipe[]>();
380
+ for (const entry of entries) {
381
+ const bucket = byId.get(entry.id) ?? [];
382
+ bucket.push(entry);
383
+ byId.set(entry.id, bucket);
384
+ }
385
+
386
+ const active = new Map<string, DiscoveredRecipe>();
387
+ const diagnostics: string[] = getRecipeRootDiagnostics(sources);
388
+ for (const [id, bucket] of byId) {
389
+ bucket.sort(
390
+ (a, b) =>
391
+ a.priority - b.priority ||
392
+ a.path
393
+ .replace(/\.md$/, ".json")
394
+ .localeCompare(b.path.replace(/\.md$/, ".json")) ||
395
+ (a.path.endsWith(".json") ? -1 : 1),
396
+ );
397
+ const winner = bucket[0];
398
+ winner.active = true;
399
+ winner.shadows = bucket.slice(1).map((entry) => entry.path);
400
+ active.set(id, winner);
401
+ for (const shadow of bucket.slice(1)) {
402
+ shadow.shadowed = true;
403
+ if (winner.path.endsWith(".json") && shadow.path.endsWith(".md"))
404
+ shadow.diagnostics.push(
405
+ `Markdown recipe ${shadow.path} is shadowed by JSON recipe ${winner.path}`,
406
+ );
407
+ }
408
+ if (winner.invalid)
409
+ diagnostics.push(
410
+ `Recipe ${id} is invalid and blocks lower-priority recipes`,
411
+ );
412
+ if (winner.disabled)
413
+ diagnostics.push(
414
+ `Recipe ${id} is disabled and blocks lower-priority recipes`,
415
+ );
416
+ if (winner.shadows.length > 0)
417
+ diagnostics.push(
418
+ `Recipe ${id} shadows ${winner.shadows.length} lower-priority recipe(s)`,
419
+ );
420
+ diagnostics.push(...winner.diagnostics);
421
+ }
422
+
423
+ return { active, entries, diagnostics };
424
+ }
425
+
426
+ export function discoverRecipes(roots: string[]): RecipesDiscoveryResult {
427
+ return discoverRecipeSources(roots.map((root) => ({ root })));
428
+ }
429
+
430
+ function recipeUsage(
431
+ entry: DiscoveredRecipe,
432
+ ): Record<string, unknown> | undefined {
433
+ const stored = entry.mutableUsage
434
+ ? RecipesUsage.readRecipeUsage(entry.path)
435
+ : undefined;
436
+ if (stored) return stored;
437
+ const usage = (entry.config as { usage?: unknown } | undefined)?.usage;
438
+ return usage && typeof usage === "object" && !Array.isArray(usage)
439
+ ? (usage as Record<string, unknown>)
440
+ : undefined;
441
+ }
442
+
443
+ function cleanupRecommendation(
444
+ entry: DiscoveredRecipe,
445
+ ): Record<string, unknown> | undefined {
446
+ if (entry.invalid) {
447
+ return {
448
+ id: entry.id,
449
+ path: entry.path,
450
+ reason: "invalid recipe blocks lower-priority entries with the same id",
451
+ actions: ["fix", "delete", "archive"],
452
+ };
453
+ }
454
+ if (entry.shadowed) {
455
+ return {
456
+ id: entry.id,
457
+ path: entry.path,
458
+ reason: "shadowed by a higher-priority recipe",
459
+ actions: ["merge", "delete", "archive"],
460
+ };
461
+ }
462
+ if (entry.disabled) {
463
+ return {
464
+ id: entry.id,
465
+ path: entry.path,
466
+ reason: "disabled recipe is retained but not exposed as a tool",
467
+ actions: ["keep disabled", "delete", "archive"],
468
+ };
469
+ }
470
+ const usage = recipeUsage(entry);
471
+ const calls = Number(usage?.calls ?? 0);
472
+ if (entry.mutableUsage && entry.tool && calls === 0) {
473
+ return {
474
+ id: entry.id,
475
+ path: entry.path,
476
+ reason: "active user tool has no recorded launches",
477
+ actions: ["keep as tool", "move out of tool root", "delete", "archive"],
478
+ };
479
+ }
480
+ if (entry.mutableUsage && !entry.tool) {
481
+ return {
482
+ id: entry.id,
483
+ path: entry.path,
484
+ reason: "user recipe is a component, not an active tool",
485
+ actions: [
486
+ "keep component",
487
+ "move into tool root",
488
+ "merge",
489
+ "delete",
490
+ "archive",
491
+ ],
492
+ };
493
+ }
494
+ if (entry.shadows.length > 0) {
495
+ return {
496
+ id: entry.id,
497
+ path: entry.path,
498
+ reason: `overrides ${entry.shadows.length} lower-priority recipe(s)`,
499
+ actions: ["keep override", "merge", "delete", "archive"],
500
+ };
501
+ }
502
+ return undefined;
503
+ }
504
+
505
+ export function createRecipeIntegrityManifest(
506
+ result: RecipesDiscoveryResult,
507
+ ): RecipeIntegrityManifestEntry[] {
508
+ return result.entries
509
+ .map((entry) => {
510
+ const bytes = readFileSync(entry.path);
511
+ return {
512
+ active: entry.active,
513
+ disabled: entry.disabled,
514
+ id: entry.id,
515
+ invalid: entry.invalid,
516
+ path: entry.path,
517
+ root: entry.root,
518
+ sha256: createHash("sha256").update(bytes).digest("hex"),
519
+ shadowed: entry.shadowed,
520
+ size: bytes.byteLength,
521
+ tool: entry.tool,
522
+ };
523
+ })
524
+ .sort((a, b) => a.id.localeCompare(b.id) || a.path.localeCompare(b.path));
525
+ }
526
+
527
+ function diagnosticSeverity(message: string): "info" | "warning" | "error" {
528
+ if (
529
+ /invalid|failed to load|not found|cyclic|exceeds|must define|repeat must/i.test(
530
+ message,
531
+ )
532
+ ) {
533
+ return "error";
534
+ }
535
+ if (
536
+ /world-writable|group-writable|invokes bash|eval|destructive|broad filesystem|unsafe/i.test(
537
+ message,
538
+ )
539
+ ) {
540
+ return "warning";
541
+ }
542
+ return "info";
543
+ }
544
+
545
+ function diagnosticSuggestedAction(message: string): string {
546
+ if (/world-writable|group-writable/i.test(message))
547
+ return "tighten recipe root permissions";
548
+ if (/invokes bash/i.test(message))
549
+ return "audit the trusted shell boundary and keep only if intentional";
550
+ if (/must define template/i.test(message))
551
+ return "add a template field or remove the recipe";
552
+ if (/JSON|Expected|parse/i.test(message))
553
+ return "fix recipe syntax or archive the file";
554
+ if (/Markdown recipe/i.test(message))
555
+ return "fix frontmatter and add a fenced template or recipe block";
556
+ if (/cyclic/i.test(message)) return "break the import cycle";
557
+ if (/exceeds.*size/i.test(message))
558
+ return "split large prompt or data into separate files";
559
+ if (/recipe\.mailbox was removed/i.test(message))
560
+ return "replace mailbox.accepts with control actions and route outputs to Trace events";
561
+ if (/repeat must/i.test(message))
562
+ return "use a positive repeat count or an array-typed repeat source";
563
+ if (/shadows/i.test(message))
564
+ return "confirm the active override or rename one recipe";
565
+ if (/disabled/i.test(message))
566
+ return "keep disabled intentionally or delete/archive the file";
567
+ return "inspect the recipe and fix or archive it if unexpected";
568
+ }
569
+
570
+ function diagnosticDetails(
571
+ result: RecipesDiscoveryResult,
572
+ ): Array<Record<string, unknown>> {
573
+ const details: Array<Record<string, unknown>> = [];
574
+ const seen = new Set<string>();
575
+ const push = (message: string, entry?: DiscoveredRecipe): void => {
576
+ const key = `${entry?.path ?? "root"}\n${message}`;
577
+ if (seen.has(key)) return;
578
+ seen.add(key);
579
+ details.push({
580
+ ...(entry ? { id: entry.id, path: entry.path } : {}),
581
+ ...(entry?.riskLabels.length ? { risk_labels: entry.riskLabels } : {}),
582
+ action: diagnosticSuggestedAction(message),
583
+ message,
584
+ severity: diagnosticSeverity(message),
585
+ });
586
+ };
587
+ for (const message of result.diagnostics) push(message);
588
+ for (const entry of result.entries) {
589
+ for (const message of entry.diagnostics) push(message, entry);
590
+ }
591
+ return details.sort((a, b) => {
592
+ const rank = { error: 0, warning: 1, info: 2 } as const;
593
+ return (
594
+ rank[a.severity as keyof typeof rank] -
595
+ rank[b.severity as keyof typeof rank] ||
596
+ String(a.message).localeCompare(String(b.message))
597
+ );
598
+ });
599
+ }
600
+
601
+ function remediationForEntry(
602
+ entry: DiscoveredRecipe,
603
+ activePath: string | undefined,
604
+ ): Record<string, unknown> | undefined {
605
+ const riskyDiagnostics = entry.diagnostics.filter(
606
+ (message) => diagnosticSeverity(message) === "warning",
607
+ );
608
+ const blockedFallback = entry.shadows[0];
609
+ if (entry.invalid) {
610
+ return {
611
+ id: entry.id,
612
+ kind: blockedFallback ? "blocking_invalid" : "invalid",
613
+ severity: "error",
614
+ path: entry.path,
615
+ ...(blockedFallback ? { blocked_fallback: blockedFallback } : {}),
616
+ reason: blockedFallback
617
+ ? "invalid higher-priority recipe blocks a lower-priority fallback"
618
+ : "recipe is invalid and cannot be exposed as a tool",
619
+ action:
620
+ "fix recipe syntax/config, or disable/delete/archive it to restore fallback",
621
+ };
622
+ }
623
+ if (entry.disabled && entry.active) {
624
+ return {
625
+ id: entry.id,
626
+ kind: blockedFallback ? "blocking_disabled" : "disabled",
627
+ severity: "warning",
628
+ path: entry.path,
629
+ ...(blockedFallback ? { blocked_fallback: blockedFallback } : {}),
630
+ reason: blockedFallback
631
+ ? "disabled higher-priority recipe intentionally blocks a lower-priority fallback"
632
+ : "recipe is disabled and not exposed as a tool",
633
+ action:
634
+ "keep disabled intentionally, re-enable, or delete/archive the file",
635
+ };
636
+ }
637
+ if (riskyDiagnostics.length > 0) {
638
+ return {
639
+ id: entry.id,
640
+ kind: "risky_shell_boundary",
641
+ severity: "warning",
642
+ path: entry.path,
643
+ ...(entry.riskLabels.length ? { risk_labels: entry.riskLabels } : {}),
644
+ reason: riskyDiagnostics[0],
645
+ action:
646
+ "audit trusted command boundary; keep only if the recipe is local and intentional",
647
+ };
648
+ }
649
+ if (entry.shadowed) {
650
+ return {
651
+ id: entry.id,
652
+ kind: "shadowed",
653
+ severity: "info",
654
+ path: entry.path,
655
+ ...(activePath ? { active_path: activePath } : {}),
656
+ reason: activePath
657
+ ? `shadowed by ${activePath}`
658
+ : "shadowed by a higher-priority recipe",
659
+ action: "keep as fallback/component, merge, rename, delete, or archive",
660
+ };
661
+ }
662
+ return undefined;
663
+ }
664
+
665
+ function remediationRank(item: Record<string, unknown>): number {
666
+ const kind = String(item.kind ?? "");
667
+ if (kind === "blocking_invalid") return 0;
668
+ if (kind === "invalid") return 1;
669
+ if (kind === "blocking_disabled") return 2;
670
+ if (kind === "risky_shell_boundary") return 3;
671
+ if (kind === "disabled") return 4;
672
+ if (kind === "shadowed") return 5;
673
+ return 6;
674
+ }
675
+
676
+ function discoveryRemediations(
677
+ result: RecipesDiscoveryResult,
678
+ ): Array<Record<string, unknown>> {
679
+ return result.entries
680
+ .map((entry) =>
681
+ remediationForEntry(entry, result.active.get(entry.id)?.path),
682
+ )
683
+ .filter((entry): entry is Record<string, unknown> => Boolean(entry))
684
+ .sort(
685
+ (a, b) =>
686
+ remediationRank(a) - remediationRank(b) ||
687
+ String(a.id).localeCompare(String(b.id)) ||
688
+ String(a.path).localeCompare(String(b.path)),
689
+ );
690
+ }
691
+
692
+ function summarizeRiskLabels(
693
+ entries: DiscoveredRecipe[],
694
+ ): Array<Record<string, unknown>> {
695
+ const counts = new Map<string, { count: number; ids: Set<string> }>();
696
+ for (const entry of entries) {
697
+ for (const label of entry.riskLabels) {
698
+ const current = counts.get(label) ?? { count: 0, ids: new Set<string>() };
699
+ current.count += 1;
700
+ current.ids.add(entry.id);
701
+ counts.set(label, current);
702
+ }
703
+ }
704
+ return [...counts.entries()]
705
+ .map(([label, value]) => ({
706
+ label,
707
+ count: value.count,
708
+ recipes: [...value.ids].sort(),
709
+ }))
710
+ .sort(
711
+ (a, b) =>
712
+ Number(b.count) - Number(a.count) ||
713
+ String(a.label).localeCompare(String(b.label)),
714
+ );
715
+ }
716
+
717
+ function recommendationForEntry(
718
+ entry: DiscoveredRecipe,
719
+ activePath: string | undefined,
720
+ ): Record<string, unknown> | undefined {
721
+ const recommendation = cleanupRecommendation(entry);
722
+ if (!recommendation) return undefined;
723
+ if (entry.shadowed && activePath) {
724
+ return {
725
+ ...recommendation,
726
+ reason: `shadowed by ${activePath}`,
727
+ };
728
+ }
729
+ return recommendation;
730
+ }
731
+
732
+ export function getShadowedLaunchDiagnostic(
733
+ result: RecipesDiscoveryResult,
734
+ id: string,
735
+ ): Record<string, unknown> | undefined {
736
+ const active = result.active.get(id.trim());
737
+ if (!active || active.shadows.length === 0) return undefined;
738
+ if (!active.invalid && !active.disabled) return undefined;
739
+ return {
740
+ active_path: active.path,
741
+ blocked_fallback: active.shadows[0],
742
+ hint: "inspect_recipes_doctor",
743
+ reason: active.invalid ? "shadowed_invalid" : "shadowed_disabled",
744
+ };
745
+ }
746
+
747
+ function templatePreview(value: unknown): string | undefined {
748
+ const rendered =
749
+ typeof value === "string"
750
+ ? value
751
+ : value === undefined
752
+ ? undefined
753
+ : JSON.stringify(value);
754
+ return rendered && rendered.length > 120
755
+ ? `${rendered.slice(0, 117)}...`
756
+ : rendered;
757
+ }
758
+
759
+ export function listDraftRecipes(root: string): Array<Record<string, unknown>> {
760
+ return listRecipeFiles(root).map((path) => {
761
+ for (let attempt = 0; attempt < 3; attempt += 1) {
762
+ const id = RecipesReferences.getRecipeIdFromPath(path);
763
+ const bytes = readFileSync(path);
764
+ const fingerprint = createHash("sha256").update(bytes).digest("hex");
765
+ const stat = statSync(path);
766
+ const config = RecipesReferences.readRawRecipeConfig(path);
767
+ const resolved = RecipesReferences.readResolvedRecipeConfig(path);
768
+ const diagnostics = getRecipeConfigDiagnostics(path, resolved);
769
+ const after = readFileSync(path);
770
+ if (createHash("sha256").update(after).digest("hex") !== fingerprint) {
771
+ continue;
772
+ }
773
+ const sourceRun = String(config?.description ?? "").match(
774
+ /spawn run ([^\s]+)/,
775
+ )?.[1];
776
+ const preview = templatePreview(config?.template);
777
+ const riskLabels = getRecipeRiskLabels(resolved);
778
+ return {
779
+ id,
780
+ path,
781
+ sha256: fingerprint,
782
+ size: bytes.byteLength,
783
+ created_at: stat.birthtime.toISOString(),
784
+ modified_at: stat.mtime.toISOString(),
785
+ valid: Boolean(resolved),
786
+ diagnostics,
787
+ ...(riskLabels.length ? { risk_labels: riskLabels } : {}),
788
+ ...(config?.description ? { description: config.description } : {}),
789
+ ...(sourceRun ? { source_run: sourceRun } : {}),
790
+ ...(config?.async !== undefined ? { async: config.async } : {}),
791
+ ...(preview ? { template_preview: preview } : {}),
792
+ };
793
+ }
794
+ throw new Error(`Draft changed repeatedly during inventory: ${path}`);
795
+ });
796
+ }
797
+
798
+ export function summarizeDiscovery(
799
+ result: RecipesDiscoveryResult,
800
+ ): Record<string, unknown> {
801
+ const recommendations = result.entries
802
+ .map((entry) =>
803
+ recommendationForEntry(entry, result.active.get(entry.id)?.path),
804
+ )
805
+ .filter((entry): entry is Record<string, unknown> => Boolean(entry))
806
+ .sort(
807
+ (a, b) =>
808
+ String(a.id).localeCompare(String(b.id)) ||
809
+ String(a.path).localeCompare(String(b.path)),
810
+ );
811
+ const remediations = discoveryRemediations(result);
812
+ return {
813
+ active: [...result.active.values()]
814
+ .map((entry) => ({
815
+ id: entry.id,
816
+ path: entry.path,
817
+ description: entry.config?.description,
818
+ tool: entry.tool,
819
+ disabled: entry.disabled,
820
+ invalid: entry.invalid,
821
+ shadows: entry.shadows,
822
+ ...(entry.riskLabels.length ? { risk_labels: entry.riskLabels } : {}),
823
+ ...(entry.config &&
824
+ ModelContext.describeRecipeCurrentPolicy({
825
+ args: entry.config.args,
826
+ defaults: entry.config.defaults,
827
+ template: entry.config.template,
828
+ })
829
+ ? {
830
+ current_policy: ModelContext.describeRecipeCurrentPolicy({
831
+ args: entry.config.args,
832
+ defaults: entry.config.defaults,
833
+ template: entry.config.template,
834
+ }),
835
+ }
836
+ : {}),
837
+ ...(entry.config?.imports ? { imports: entry.config.imports } : {}),
838
+ ...(recipeUsage(entry)
839
+ ? { usage: recipeUsage(entry) }
840
+ : {}),
841
+ }))
842
+ .sort((a, b) => a.id.localeCompare(b.id)),
843
+ shadowed: result.entries
844
+ .filter((entry) => entry.shadowed)
845
+ .map((entry) => ({
846
+ id: entry.id,
847
+ path: entry.path,
848
+ shadowedBy: result.active.get(entry.id)?.path,
849
+ }))
850
+ .sort((a, b) => a.id.localeCompare(b.id) || a.path.localeCompare(b.path)),
851
+ invalid: result.entries
852
+ .filter((entry) => entry.invalid)
853
+ .map((entry) => ({
854
+ id: entry.id,
855
+ path: entry.path,
856
+ diagnostics: entry.diagnostics,
857
+ }))
858
+ .sort((a, b) => a.id.localeCompare(b.id)),
859
+ disabled: result.entries
860
+ .filter((entry) => entry.disabled)
861
+ .map((entry) => ({ id: entry.id, path: entry.path }))
862
+ .sort((a, b) => a.id.localeCompare(b.id)),
863
+ risk_summary: summarizeRiskLabels(result.entries),
864
+ recommendations,
865
+ remediations,
866
+ top_action: remediations[0],
867
+ diagnostics: result.diagnostics,
868
+ diagnostic_details: diagnosticDetails(result),
869
+ integrity_manifest: createRecipeIntegrityManifest(result),
870
+ };
871
+ }
872
+
873
+ function projectRegisteredTool(
874
+ identity: string,
875
+ path: string,
876
+ cfg: TemplateRecipeConfig,
877
+ mutableUsage: boolean,
878
+ ): RegisteredTool {
879
+ const description = cfg.description ?? `Execute template recipe: ${identity}`;
880
+ const argTemplate = cfg.template;
881
+ const argTemplateConfig =
882
+ typeof argTemplate === "object" && !Array.isArray(argTemplate)
883
+ ? {
884
+ ...argTemplate,
885
+ ...(cfg.args !== undefined ? { args: cfg.args } : {}),
886
+ defaults: {
887
+ ...(argTemplate.defaults ?? {}),
888
+ ...(cfg.defaults ?? {}),
889
+ },
890
+ }
891
+ : { args: cfg.args, defaults: cfg.defaults ?? {}, template: argTemplate };
892
+ const explicitArgTypes = Object.fromEntries(
893
+ (cfg.args ?? []).map((arg) => {
894
+ const parsed = Schema.parseToolArgToken(String(arg));
895
+ return [parsed.arg, parsed.type];
896
+ }),
897
+ );
898
+ assertToolSafeRepeatConfig(
899
+ argTemplateConfig,
900
+ explicitArgTypes,
901
+ { ...(cfg.defaults ?? {}), ...(cfg.values ?? {}) },
902
+ );
903
+ const inferredArgTypes = Schema.getTemplateArgTypes(argTemplateConfig);
904
+ Schema.assertCompatibleToolArgTypes(explicitArgTypes, inferredArgTypes);
905
+ const effectiveArgTypes = { ...inferredArgTypes, ...explicitArgTypes };
906
+ const args = Schema.getToolArgNames(argTemplateConfig).filter(
907
+ (arg) => !RecipesReferences.isRuntimeOwnedRecipeInput(arg),
908
+ );
909
+ const callerArgSet = new Set(args);
910
+ const argTypes = Object.fromEntries(
911
+ Object.entries(effectiveArgTypes).filter(([arg]) => callerArgSet.has(arg)),
912
+ );
913
+ const defaults = Object.fromEntries(
914
+ Object.entries(cfg.defaults ?? {}).filter(([arg]) => callerArgSet.has(arg)),
915
+ );
916
+ const storedArgs = cfg.args?.filter((arg) =>
917
+ callerArgSet.has(Schema.parseToolArgToken(String(arg)).arg),
918
+ );
919
+ return {
920
+ name: identity,
921
+ description,
922
+ template: path,
923
+ recipe: cfg,
924
+ args,
925
+ defaults: Object.fromEntries(
926
+ Object.entries(defaults).map(([key, value]) => [key, String(value)]),
927
+ ),
928
+ ...(Object.keys(argTypes).length > 0 ? { argTypes } : {}),
929
+ ...(mutableUsage ? { sourcePath: path } : {}),
930
+ ...(storedArgs ? { storedArgs } : {}),
931
+ ...(Object.keys(defaults).length > 0
932
+ ? {
933
+ storedDefaults: Object.fromEntries(
934
+ Object.entries(defaults).map(([key, value]) => [
935
+ key,
936
+ String(value),
937
+ ]),
938
+ ),
939
+ }
940
+ : {}),
941
+ };
942
+ }
943
+
944
+ export function summarizeRegisteredToolArgs(tool: RegisteredTool): {
945
+ optional: string[];
946
+ required: string[];
947
+ } {
948
+ const publicArgs = tool.args.filter(
949
+ (arg) => !RecipesReferences.isRuntimeOwnedRecipeInput(arg),
950
+ );
951
+ const inlineDefaults = Schema.getExplicitToolArgDefaults(tool.recipe?.args);
952
+ const required = publicArgs.filter(
953
+ (arg) =>
954
+ !Object.hasOwn(tool.defaults, arg) &&
955
+ !Object.hasOwn(inlineDefaults, arg),
956
+ );
957
+ const requiredSet = new Set(required);
958
+ const optional = publicArgs.filter((arg) => !requiredSet.has(arg));
959
+ if (tool.recipe?.async === true) {
960
+ if (tool.recipe.singleton !== true) optional.push("run_id");
961
+ optional.push("transport_context");
962
+ }
963
+ return { optional, required };
964
+ }
965
+
966
+ function boundedAdmissionDiagnostic(error: unknown): string {
967
+ const message = error instanceof Error ? error.message : String(error);
968
+ return message.length <= 4096 ? message : `${message.slice(0, 4095)}…`;
969
+ }
970
+
971
+ export function admitUserRecipe(
972
+ sourcePath: string,
973
+ resolutionContext: RecipeResolutionContext,
974
+ authoredRecipe?: Record<string, unknown>,
975
+ mutableUsage = true,
976
+ ): UserRecipeAdmission {
977
+ const identity = RecipesReferences.getRecipeIdFromPath(sourcePath);
978
+ try {
979
+ const effectiveRecipe = RecipesReferences.readResolvedRecipeConfig(
980
+ sourcePath,
981
+ [],
982
+ {
983
+ ...(authoredRecipe
984
+ ? { authoredEntry: { path: sourcePath, recipe: authoredRecipe } }
985
+ : {}),
986
+ skillContext: resolutionContext.activeSkills,
987
+ },
988
+ );
989
+ if (!effectiveRecipe) {
990
+ return {
991
+ diagnostics: [
992
+ authoredRecipe
993
+ ? "Recipe must define a valid template."
994
+ : RecipesReferences.diagnoseRawRecipeConfigFailure(sourcePath) ??
995
+ "Recipe must define a valid template.",
996
+ ],
997
+ identity,
998
+ sourcePath,
999
+ validated: false,
1000
+ };
1001
+ }
1002
+ if (effectiveRecipe.disabled === true) {
1003
+ return {
1004
+ diagnostics: ["Recipe is disabled."],
1005
+ effectiveRecipe,
1006
+ identity,
1007
+ sourcePath,
1008
+ validated: false,
1009
+ };
1010
+ }
1011
+ const tool = projectRegisteredTool(
1012
+ identity,
1013
+ sourcePath,
1014
+ effectiveRecipe,
1015
+ mutableUsage,
1016
+ );
1017
+ return {
1018
+ args: tool.args,
1019
+ argTypes: tool.argTypes,
1020
+ artifacts: effectiveRecipe.artifacts,
1021
+ async: effectiveRecipe.async === true,
1022
+ control: effectiveRecipe.control,
1023
+ defaults: effectiveRecipe.defaults,
1024
+ diagnostics: [],
1025
+ effectiveRecipe,
1026
+ identity,
1027
+ sourcePath,
1028
+ tool,
1029
+ validated: true,
1030
+ };
1031
+ } catch (error) {
1032
+ return {
1033
+ diagnostics: [boundedAdmissionDiagnostic(error)],
1034
+ identity,
1035
+ sourcePath,
1036
+ validated: false,
1037
+ };
1038
+ }
1039
+ }
1040
+
1041
+ export function toRegisteredTool(
1042
+ entry: DiscoveredRecipe,
1043
+ ): RegisteredTool | undefined {
1044
+ if (!entry.tool || entry.invalid || entry.disabled || !entry.config)
1045
+ return undefined;
1046
+ if (entry.resolutionContext) {
1047
+ return admitUserRecipe(
1048
+ entry.path,
1049
+ entry.resolutionContext,
1050
+ undefined,
1051
+ entry.mutableUsage,
1052
+ ).tool;
1053
+ }
1054
+ return projectRegisteredTool(
1055
+ entry.id,
1056
+ entry.path,
1057
+ entry.config,
1058
+ entry.mutableUsage,
1059
+ );
1060
+ }