@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,954 @@
1
+ /**
2
+ * Command-template execution standard.
3
+ * Zones: shell-free command parsing, placeholder expansion, local process execution, composition semantics
4
+ * Owns portable command-template parsing, expansion, risk checks, retries, timeouts, and direct execution.
5
+ */
6
+
7
+ import { spawn } from "node:child_process";
8
+ import { homedir } from "node:os";
9
+ import { isAbsolute, resolve } from "node:path";
10
+
11
+ export type CommandTemplateFailureScope = "continue" | "branch" | "root";
12
+
13
+ export interface CommandTemplateActorRecipeContext {
14
+ alias?: string;
15
+ file?: string;
16
+ name?: string;
17
+ path?: string;
18
+ role?: string;
19
+ }
20
+
21
+ export interface CommandTemplateObjectConfig {
22
+ actorRecipeContext?: CommandTemplateActorRecipeContext;
23
+ label?: string;
24
+ parallel?: boolean;
25
+ when?: boolean | string;
26
+ template?: CommandTemplateValue;
27
+ args?: string[];
28
+ defaults?: Record<string, unknown>;
29
+ timeout?: number | string;
30
+ delay?: number | string;
31
+ output?: string;
32
+ retry?: number | string;
33
+ failure?: CommandTemplateFailureScope;
34
+ recover?: CommandTemplateValue;
35
+ repeat?: number | string;
36
+ }
37
+
38
+ export type CommandTemplateValue =
39
+ string | CommandTemplateConfig[] | CommandTemplateObjectConfig;
40
+
41
+ export type CommandTemplateConfig = string | CommandTemplateObjectConfig;
42
+
43
+ export interface CommandTemplateLeafConfig extends CommandTemplateObjectConfig {
44
+ template: string;
45
+ }
46
+
47
+ export interface CommandTemplateInvocation {
48
+ command: string;
49
+ args: string[];
50
+ }
51
+
52
+ export interface CommandTemplateExecOptions {
53
+ cwd?: string;
54
+ timeout?: number;
55
+ signal?: AbortSignal;
56
+ stdin?: string;
57
+ killGrace?: number;
58
+ retry?: number;
59
+ }
60
+
61
+ export interface CommandTemplateExecResult {
62
+ stdout: string;
63
+ stderr: string;
64
+ code: number;
65
+ killed: boolean;
66
+ }
67
+
68
+ export type CommandTemplateRiskLabel =
69
+ | "risk.shell"
70
+ | "risk.eval"
71
+ | "risk.broad_fs_write"
72
+ | "risk.destructive_fs"
73
+ | "risk.network"
74
+ | "risk.external_side_effect"
75
+ | "risk.long_running"
76
+ | "risk.platform_specific"
77
+ | "risk.secret_touching";
78
+
79
+ const COMMAND_TEMPLATE_RISK_LABEL_ORDER: CommandTemplateRiskLabel[] = [
80
+ "risk.shell",
81
+ "risk.eval",
82
+ "risk.destructive_fs",
83
+ "risk.broad_fs_write",
84
+ "risk.external_side_effect",
85
+ "risk.secret_touching",
86
+ "risk.network",
87
+ "risk.long_running",
88
+ "risk.platform_specific",
89
+ ];
90
+
91
+ function normalizeCommandTemplateArgs(value: string[] | undefined): string[] {
92
+ if (!Array.isArray(value)) return [];
93
+ return value.map(String).map((item) => item.trim());
94
+ }
95
+
96
+ export function normalizeCommandTemplateConfig(
97
+ config: CommandTemplateConfig,
98
+ ): CommandTemplateObjectConfig {
99
+ return typeof config === "string" ? { template: config } : config;
100
+ }
101
+
102
+ function normalizeRecoverConfig(
103
+ config: CommandTemplateValue | undefined,
104
+ ): CommandTemplateConfig | undefined {
105
+ if (config === undefined) return undefined;
106
+ return Array.isArray(config) ? { template: config } : config;
107
+ }
108
+
109
+ function normalizeCommandTemplateDefaults(
110
+ defaults: Record<string, unknown> | undefined,
111
+ ): Record<string, unknown> | undefined {
112
+ if (!defaults) return undefined;
113
+ const normalized: Record<string, unknown> = {};
114
+ for (const [key, value] of Object.entries(defaults)) {
115
+ normalized[key] = Array.isArray(value)
116
+ ? value
117
+ : value === undefined || value === null
118
+ ? ""
119
+ : String(value);
120
+ }
121
+ return normalized;
122
+ }
123
+
124
+ export function resolveInheritedDefaultReferences(
125
+ ownDefaults: Record<string, unknown> | undefined,
126
+ inheritedDefaults: Record<string, unknown> | undefined,
127
+ runtimeValues: Record<string, unknown> = {},
128
+ ): Record<string, unknown> | undefined {
129
+ if (!ownDefaults || !inheritedDefaults) return ownDefaults;
130
+ const resolved = { ...ownDefaults };
131
+ for (const [key, value] of Object.entries(ownDefaults)) {
132
+ if (typeof value !== "string") continue;
133
+ const exact = /^\{([A-Za-z_][A-Za-z0-9_-]*)\}$/.exec(value);
134
+ if (
135
+ !exact ||
136
+ Object.hasOwn(runtimeValues, exact[1]) ||
137
+ !Object.hasOwn(inheritedDefaults, exact[1])
138
+ )
139
+ continue;
140
+ resolved[key] = inheritedDefaults[exact[1]];
141
+ }
142
+ return resolved;
143
+ }
144
+
145
+ export function resolveCommandTemplateRepeat(
146
+ value: number | string | undefined,
147
+ values: Record<string, unknown> = {},
148
+ ): number | undefined {
149
+ if (value === undefined) return undefined;
150
+ if (typeof value === "number") {
151
+ if (!Number.isInteger(value) || value < 1)
152
+ throw new Error("Command template repeat must be a positive integer.");
153
+ return value;
154
+ }
155
+ const trimmed = value.trim();
156
+ if (/^\d+$/.test(trimmed)) return Number(trimmed);
157
+ const lengthMatch = trimmed.match(
158
+ /^\{?([A-Za-z_][A-Za-z0-9_-]*)\.length\}?$/,
159
+ );
160
+ if (lengthMatch) {
161
+ const source = values[lengthMatch[1]];
162
+ if (Array.isArray(source)) return source.length;
163
+ if (source === undefined) return undefined;
164
+ }
165
+ throw new Error(
166
+ "Command template repeat must be a positive integer or {array.length}.",
167
+ );
168
+ }
169
+
170
+ function getExecutableName(command: string | undefined): string {
171
+ if (!command) return "";
172
+ return command.split(/[\\/]/).pop()?.toLowerCase() ?? "";
173
+ }
174
+
175
+ function matchesFlag(arg: string, flag: string): boolean {
176
+ if (arg === flag) return true;
177
+ if (/^-[A-Za-z]$/.test(flag) && /^-[A-Za-z]+$/.test(arg))
178
+ return arg.slice(1).includes(flag.slice(1));
179
+ return false;
180
+ }
181
+
182
+ function hasAnyFlag(args: string[], flags: string[]): boolean {
183
+ return args.some((arg) => flags.some((flag) => matchesFlag(arg, flag)));
184
+ }
185
+
186
+ function hasRiskyPathArg(args: string[]): boolean {
187
+ return args.some(
188
+ (arg) =>
189
+ arg === "/" ||
190
+ arg === "~" ||
191
+ arg === "./" ||
192
+ arg === "../" ||
193
+ arg.includes("{") ||
194
+ arg.startsWith("~/") ||
195
+ arg.startsWith("/"),
196
+ );
197
+ }
198
+
199
+ function sortRiskLabels(
200
+ labels: Iterable<CommandTemplateRiskLabel>,
201
+ ): CommandTemplateRiskLabel[] {
202
+ const unique = new Set(labels);
203
+ return COMMAND_TEMPLATE_RISK_LABEL_ORDER.filter((label) => unique.has(label));
204
+ }
205
+
206
+ function hasAnyArg(args: string[], values: string[]): boolean {
207
+ return args.some((arg) => values.includes(arg.toLowerCase()));
208
+ }
209
+
210
+ function hasSecretTouchingText(parts: string[]): boolean {
211
+ return parts.some((part) =>
212
+ /(^|[{}._\-\s/])(?:secret|token|password|passwd|credential|api[_-]?key|private[_-]?key|\.env|ssh[_-]?key)(?:[{}._\-\s/]|$)/i.test(
213
+ part,
214
+ ),
215
+ );
216
+ }
217
+
218
+ function getLeafCommandTemplateRiskLabels(
219
+ config: CommandTemplateLeafConfig,
220
+ ): CommandTemplateRiskLabel[] {
221
+ const parts = splitCommandTemplate(config.template);
222
+ const command = getExecutableName(parts[0]);
223
+ const args = parts.slice(1);
224
+ const labels = new Set<CommandTemplateRiskLabel>();
225
+ if (["bash", "sh", "zsh", "fish"].includes(command)) {
226
+ labels.add("risk.shell");
227
+ if (hasAnyFlag(args, ["-c"])) labels.add("risk.eval");
228
+ }
229
+ if (
230
+ ["node", "deno", "bun"].includes(command) &&
231
+ hasAnyFlag(args, ["-e", "--eval"])
232
+ ) {
233
+ labels.add("risk.eval");
234
+ }
235
+ if (
236
+ ["python", "python3", "perl", "ruby"].includes(command) &&
237
+ hasAnyFlag(args, ["-c", "-e"])
238
+ ) {
239
+ labels.add("risk.eval");
240
+ }
241
+ if (
242
+ command === "rm" &&
243
+ (args.some((arg) => /^-[^-]*r/.test(arg) || /^-[^-]*f/.test(arg)) ||
244
+ hasRiskyPathArg(args))
245
+ ) {
246
+ labels.add("risk.destructive_fs");
247
+ }
248
+ if (["mv", "cp", "rsync"].includes(command) && hasRiskyPathArg(args)) {
249
+ labels.add("risk.broad_fs_write");
250
+ }
251
+ if (
252
+ [
253
+ "curl",
254
+ "wget",
255
+ "ssh",
256
+ "scp",
257
+ "sftp",
258
+ "rsync",
259
+ "nc",
260
+ "ncat",
261
+ "telnet",
262
+ "ftp",
263
+ ].includes(command) ||
264
+ (command === "git" &&
265
+ hasAnyArg(args, ["clone", "fetch", "pull", "push", "ls-remote"])) ||
266
+ ["npm", "pnpm", "yarn", "pip", "cargo"].includes(command)
267
+ ) {
268
+ labels.add("risk.network");
269
+ }
270
+ if (
271
+ ["gh", "glab", "hub", "kubectl", "terraform"].includes(command) ||
272
+ (command === "git" && hasAnyArg(args, ["push"])) ||
273
+ (["npm", "pnpm", "yarn"].includes(command) &&
274
+ hasAnyArg(args, ["publish", "login", "logout", "deprecate"]))
275
+ ) {
276
+ labels.add("risk.external_side_effect");
277
+ }
278
+ if (
279
+ command === "sleep" ||
280
+ command === "watch" ||
281
+ (command === "tail" && hasAnyFlag(args, ["-f"])) ||
282
+ hasAnyArg(args, ["--watch", "--serve", "serve"])
283
+ ) {
284
+ labels.add("risk.long_running");
285
+ }
286
+ if (
287
+ [
288
+ "systemctl",
289
+ "launchctl",
290
+ "osascript",
291
+ "open",
292
+ "xdg-open",
293
+ "powershell",
294
+ "pwsh",
295
+ "cmd.exe",
296
+ "apt",
297
+ "apt-get",
298
+ "dnf",
299
+ "yum",
300
+ "brew",
301
+ "pacman",
302
+ "apk",
303
+ "xclip",
304
+ "wl-copy",
305
+ ].includes(command)
306
+ ) {
307
+ labels.add("risk.platform_specific");
308
+ }
309
+ if (
310
+ ["pass", "gpg", "ssh-add"].includes(command) ||
311
+ hasSecretTouchingText(parts)
312
+ ) {
313
+ labels.add("risk.secret_touching");
314
+ }
315
+ return sortRiskLabels(labels);
316
+ }
317
+
318
+ function getLeafCommandTemplateWarnings(
319
+ config: CommandTemplateLeafConfig,
320
+ ): string[] {
321
+ const parts = splitCommandTemplate(config.template);
322
+ const command = getExecutableName(parts[0]);
323
+ const args = parts.slice(1);
324
+ const warnings: string[] = [];
325
+ if (["bash", "sh", "zsh", "fish"].includes(command)) {
326
+ const shellContent = hasAnyFlag(args, ["-c"])
327
+ ? "shell command strings"
328
+ : "shell scripts";
329
+ warnings.push(
330
+ `${config.label ?? command}: invokes ${command}; ${shellContent} are trusted executable content and are not sandboxed by command-template argv splitting. Mitigation: keep scripts local, reviewed, and parameterized with explicit placeholders.`,
331
+ );
332
+ }
333
+ if (
334
+ ["node", "deno", "bun"].includes(command) &&
335
+ hasAnyFlag(args, ["-e", "--eval"])
336
+ ) {
337
+ warnings.push(
338
+ `${config.label ?? command}: invokes ${command} eval mode; code strings are trusted executable content and are not sandboxed. Mitigation: prefer a checked-in script file or keep eval input fixed and reviewed.`,
339
+ );
340
+ }
341
+ if (
342
+ ["python", "python3", "perl", "ruby"].includes(command) &&
343
+ hasAnyFlag(args, ["-c", "-e"])
344
+ ) {
345
+ warnings.push(
346
+ `${config.label ?? command}: invokes ${command} code-eval mode; code strings are trusted executable content and are not sandboxed. Mitigation: prefer a checked-in script file or keep eval input fixed and reviewed.`,
347
+ );
348
+ }
349
+ if (
350
+ command === "rm" &&
351
+ (args.some((arg) => /^-[^-]*r/.test(arg) || /^-[^-]*f/.test(arg)) ||
352
+ hasRiskyPathArg(args))
353
+ ) {
354
+ warnings.push(
355
+ `${config.label ?? command}: removes filesystem paths; verify placeholders and paths before running trusted destructive commands. Mitigation: constrain path placeholders and consider dry-run or explicit confirmation.`,
356
+ );
357
+ }
358
+ if (["mv", "cp", "rsync"].includes(command) && hasRiskyPathArg(args)) {
359
+ warnings.push(
360
+ `${config.label ?? command}: mutates broad filesystem paths; verify placeholders and paths before running trusted commands. Mitigation: constrain path placeholders and prefer narrow source/destination paths.`,
361
+ );
362
+ }
363
+ return warnings;
364
+ }
365
+
366
+ function pad(value: number, width: number): string {
367
+ return String(value).padStart(width, "0");
368
+ }
369
+
370
+ export function getCommandTemplateRepeatDefaults(
371
+ index: number,
372
+ repeat: number,
373
+ ): Record<string, string> {
374
+ const prev = (index - 1 + repeat) % repeat;
375
+ const next = (index + 1) % repeat;
376
+ const values: Record<string, string> = {
377
+ index: String(index),
378
+ next: String(next),
379
+ prev: String(prev),
380
+ repeat: String(repeat),
381
+ };
382
+ for (const name of ["index", "prev", "next", "repeat"]) {
383
+ const numeric = Number(values[name]);
384
+ for (let underscores = 1; underscores <= 6; underscores += 1) {
385
+ values[`${"_".repeat(underscores)}${name}`] = pad(
386
+ numeric,
387
+ underscores + 1,
388
+ );
389
+ }
390
+ }
391
+ return values;
392
+ }
393
+
394
+ function expandRepeatConfig(
395
+ config: CommandTemplateObjectConfig,
396
+ context: Pick<CommandTemplateObjectConfig, "args" | "defaults">,
397
+ ): CommandTemplateObjectConfig[] | undefined {
398
+ const repeat = resolveCommandTemplateRepeat(
399
+ config.repeat,
400
+ context.defaults ?? {},
401
+ );
402
+ if (repeat === undefined) return undefined;
403
+ return Array.from({ length: repeat }, (_unused, index0) => {
404
+ const { repeat: _repeat, ...rest } = config;
405
+ return {
406
+ ...rest,
407
+ defaults: {
408
+ ...(context.defaults ?? {}),
409
+ ...(rest.defaults ?? {}),
410
+ ...getCommandTemplateRepeatDefaults(index0, repeat),
411
+ },
412
+ };
413
+ });
414
+ }
415
+
416
+ export function expandCommandTemplateConfigs(
417
+ config: CommandTemplateConfig,
418
+ inherited: Pick<CommandTemplateObjectConfig, "args" | "defaults"> = {},
419
+ ): CommandTemplateLeafConfig[] {
420
+ const normalizedConfig = normalizeCommandTemplateConfig(config);
421
+ const inheritedDefaults = normalizeCommandTemplateDefaults(
422
+ inherited.defaults,
423
+ );
424
+ const ownDefaults = resolveInheritedDefaultReferences(
425
+ normalizeCommandTemplateDefaults(normalizedConfig.defaults),
426
+ inheritedDefaults,
427
+ );
428
+ const context = {
429
+ ...(inherited.args !== undefined ? { args: inherited.args } : {}),
430
+ ...(inheritedDefaults ? { defaults: inheritedDefaults } : {}),
431
+ ...(normalizedConfig.args !== undefined
432
+ ? { args: normalizedConfig.args }
433
+ : {}),
434
+ ...(ownDefaults
435
+ ? { defaults: { ...(inheritedDefaults ?? {}), ...ownDefaults } }
436
+ : {}),
437
+ };
438
+ const repeated = expandRepeatConfig(normalizedConfig, context);
439
+ if (repeated) {
440
+ return repeated.flatMap((step) =>
441
+ expandCommandTemplateConfigs(step, context),
442
+ );
443
+ }
444
+ const recoverConfig = normalizeRecoverConfig(normalizedConfig.recover);
445
+ const recoverSteps = recoverConfig
446
+ ? expandCommandTemplateConfigs(recoverConfig, context)
447
+ : [];
448
+ if (Array.isArray(normalizedConfig.template)) {
449
+ return [
450
+ ...normalizedConfig.template.flatMap((step) =>
451
+ expandCommandTemplateConfigs(step, context),
452
+ ),
453
+ ...recoverSteps,
454
+ ];
455
+ }
456
+ if (typeof normalizedConfig.template !== "string") return recoverSteps;
457
+ return [
458
+ {
459
+ ...normalizedConfig,
460
+ ...context,
461
+ template: normalizedConfig.template,
462
+ retry: normalizedConfig.retry,
463
+ },
464
+ ...recoverSteps,
465
+ ];
466
+ }
467
+
468
+ export function getCommandTemplateWarnings(
469
+ config: CommandTemplateConfig,
470
+ ): string[] {
471
+ return [
472
+ ...new Set(
473
+ expandCommandTemplateConfigs(config).flatMap((leaf) =>
474
+ getLeafCommandTemplateWarnings(leaf),
475
+ ),
476
+ ),
477
+ ];
478
+ }
479
+
480
+ export function getCommandTemplateRiskLabels(
481
+ config: CommandTemplateConfig,
482
+ ): CommandTemplateRiskLabel[] {
483
+ return sortRiskLabels(
484
+ expandCommandTemplateConfigs(config).flatMap((leaf) =>
485
+ getLeafCommandTemplateRiskLabels(leaf),
486
+ ),
487
+ );
488
+ }
489
+
490
+ function parseCommandTemplateArgToken(value: string): {
491
+ name: string;
492
+ defaultValue?: string;
493
+ } {
494
+ const separatorIndex = value.indexOf("=");
495
+ const rawName =
496
+ separatorIndex === -1 ? value : value.slice(0, separatorIndex);
497
+ const colonIndex = rawName.indexOf(":");
498
+ return {
499
+ name: (colonIndex === -1 ? rawName : rawName.slice(0, colonIndex)).trim(),
500
+ ...(separatorIndex === -1
501
+ ? {}
502
+ : { defaultValue: value.slice(separatorIndex + 1).trim() }),
503
+ };
504
+ }
505
+
506
+ function parseCommandTemplatePlaceholderContent(
507
+ content: string,
508
+ ): { name: string; inlineDefault?: string } | undefined {
509
+ const match = content.match(
510
+ /^([A-Za-z_][A-Za-z0-9_-]*)(?::(?:string|path|int|number|bool|array|enum\([^)]*\)))?(?:=([^}]*))?$/,
511
+ );
512
+ if (!match) return undefined;
513
+ return {
514
+ name: match[1],
515
+ ...(match[2] !== undefined ? { inlineDefault: match[2] } : {}),
516
+ };
517
+ }
518
+
519
+ export function getCommandTemplateDefaults(
520
+ config: CommandTemplateConfig | undefined,
521
+ ): Record<string, string> {
522
+ const normalizedConfig = config
523
+ ? normalizeCommandTemplateConfig(config)
524
+ : undefined;
525
+ const defaults: Record<string, string> = {};
526
+ for (const item of normalizeCommandTemplateArgs(normalizedConfig?.args)) {
527
+ if (!item) continue;
528
+ const parsed = parseCommandTemplateArgToken(item);
529
+ if (!parsed.name || parsed.defaultValue === undefined) continue;
530
+ defaults[parsed.name] = parsed.defaultValue;
531
+ }
532
+ for (const [key, value] of Object.entries(normalizedConfig?.defaults ?? {})) {
533
+ defaults[key] = value === undefined || value === null ? "" : String(value);
534
+ }
535
+ return defaults;
536
+ }
537
+
538
+ export function splitCommandTemplate(input: string): string[] {
539
+ const words: string[] = [];
540
+ let current = "";
541
+ let quote: "'" | '"' | undefined;
542
+ let escaped = false;
543
+ let active = false;
544
+ for (const char of input) {
545
+ if (escaped) {
546
+ current += char;
547
+ escaped = false;
548
+ active = true;
549
+ continue;
550
+ }
551
+ if (char === "\\" && quote !== "'") {
552
+ escaped = true;
553
+ active = true;
554
+ continue;
555
+ }
556
+ if (quote) {
557
+ if (char === quote) quote = undefined;
558
+ else current += char;
559
+ active = true;
560
+ continue;
561
+ }
562
+ if (char === "'" || char === '"') {
563
+ quote = char;
564
+ active = true;
565
+ continue;
566
+ }
567
+ if (/\s/.test(char)) {
568
+ if (active) words.push(current);
569
+ if (active) current = "";
570
+ active = false;
571
+ continue;
572
+ }
573
+ current += char;
574
+ active = true;
575
+ }
576
+ if (escaped) current += "\\";
577
+ if (active || current) words.push(current);
578
+ return words;
579
+ }
580
+
581
+ export function expandCommandTemplateExecutable(
582
+ command: string,
583
+ cwd: string,
584
+ ): string {
585
+ if (command === "~") return homedir();
586
+ if (command.startsWith("~/")) return resolve(homedir(), command.slice(2));
587
+ if (command.includes("/") && !isAbsolute(command))
588
+ return resolve(cwd, command);
589
+ return command;
590
+ }
591
+
592
+ function evaluateCommandTemplateExpression(
593
+ expression: string,
594
+ values: Record<string, unknown>,
595
+ ): number {
596
+ let index = 0;
597
+ const source = expression.replace(/\s+/g, "");
598
+ const peek = (): string | undefined => source[index];
599
+ const consume = (char: string): boolean => {
600
+ if (peek() !== char) return false;
601
+ index += 1;
602
+ return true;
603
+ };
604
+ const parsePrimary = (): number => {
605
+ if (consume("(")) {
606
+ const value = parseExpression();
607
+ if (!consume(")"))
608
+ throw new Error(`Invalid command template expression: ${expression}`);
609
+ return value;
610
+ }
611
+ const numberMatch = source.slice(index).match(/^\d+/);
612
+ if (numberMatch) {
613
+ index += numberMatch[0].length;
614
+ return Number(numberMatch[0]);
615
+ }
616
+ const nameMatch = source.slice(index).match(/^[A-Za-z_][A-Za-z0-9_-]*/);
617
+ if (nameMatch) {
618
+ index += nameMatch[0].length;
619
+ const value = values[nameMatch[0]];
620
+ if (value === undefined || !/^-?\d+$/.test(String(value)))
621
+ throw new Error(
622
+ `Invalid command template expression variable: ${nameMatch[0]}`,
623
+ );
624
+ return Number(value);
625
+ }
626
+ throw new Error(`Invalid command template expression: ${expression}`);
627
+ };
628
+ const parseTerm = (): number => {
629
+ let value = parsePrimary();
630
+ while (true) {
631
+ if (consume("*")) value *= parsePrimary();
632
+ else if (consume("/")) value = Math.trunc(value / parsePrimary());
633
+ else if (consume("%")) value %= parsePrimary();
634
+ else return value;
635
+ }
636
+ };
637
+ const parseExpression = (): number => {
638
+ let value = parseTerm();
639
+ while (true) {
640
+ if (consume("+")) value += parseTerm();
641
+ else if (consume("-")) value -= parseTerm();
642
+ else return value;
643
+ }
644
+ };
645
+ const value = parseExpression();
646
+ if (index !== source.length)
647
+ throw new Error(`Invalid command template expression: ${expression}`);
648
+ return value;
649
+ }
650
+
651
+ function substituteCommandTemplateExpression(
652
+ content: string,
653
+ values: Record<string, unknown>,
654
+ ): string | undefined {
655
+ const padded = content.match(/^(_{1,6})\((.+)\)$/);
656
+ if (padded) {
657
+ return pad(
658
+ evaluateCommandTemplateExpression(padded[2], values),
659
+ padded[1].length + 1,
660
+ );
661
+ }
662
+ if (!/[()+\-*\/%]/.test(content)) return undefined;
663
+ return String(evaluateCommandTemplateExpression(content, values));
664
+ }
665
+
666
+ function shouldResolveEmbeddedCommandTemplateToken(
667
+ token: string,
668
+ values: Record<string, unknown>,
669
+ ): boolean {
670
+ const matches = [...token.matchAll(/\{([^{}]+)\}/g)];
671
+ if (matches.length === 0) return false;
672
+ return matches.every((match) => {
673
+ const content = match[1];
674
+ if (resolveCommandTemplateNullish(content, values) !== undefined)
675
+ return true;
676
+ if (resolveCommandTemplateTernary(content, values) !== undefined)
677
+ return true;
678
+ const indexed = content.match(
679
+ /^([A-Za-z_][A-Za-z0-9_-]*)\[([A-Za-z_][A-Za-z0-9_-]*|\d+)\]$/,
680
+ );
681
+ if (indexed) return Object.hasOwn(values, indexed[1]);
682
+ const simple = parseCommandTemplatePlaceholderContent(content);
683
+ if (simple)
684
+ return (
685
+ Object.hasOwn(values, simple.name) || simple.inlineDefault !== undefined
686
+ );
687
+ try {
688
+ return substituteCommandTemplateExpression(content, values) !== undefined;
689
+ } catch {
690
+ return false;
691
+ }
692
+ });
693
+ }
694
+
695
+ function isFalsyCommandTemplateValue(value: unknown): boolean {
696
+ if (value === undefined || value === null || value === false) return true;
697
+ const normalized = String(value).trim().toLowerCase();
698
+ return (
699
+ normalized === "" ||
700
+ normalized === "0" ||
701
+ normalized === "false" ||
702
+ normalized === "no"
703
+ );
704
+ }
705
+
706
+ function resolveCommandTemplateCondition(
707
+ condition: string,
708
+ values: Record<string, unknown>,
709
+ ): unknown {
710
+ const trimmed = condition.trim();
711
+ const negated = trimmed.startsWith("!");
712
+ const name = negated ? trimmed.slice(1).trim() : trimmed;
713
+ const value = /^[A-Za-z_][A-Za-z0-9_-]*$/.test(name)
714
+ ? values[name]
715
+ : undefined;
716
+ return negated ? isFalsyCommandTemplateValue(value) : value;
717
+ }
718
+
719
+ export function shouldRunCommandTemplateNode(
720
+ value: boolean | string | undefined,
721
+ values: Record<string, unknown>,
722
+ ): boolean {
723
+ if (value === undefined) return true;
724
+ if (typeof value === "boolean") return value;
725
+ const trimmed = value.trim();
726
+ if (!trimmed) return false;
727
+ const exact = /^\{([^{}]+)\}$/.exec(trimmed);
728
+ const resolved = exact
729
+ ? resolveCommandTemplateValue(exact[1], values, "command template when")
730
+ : resolveCommandTemplateCondition(trimmed, values);
731
+ return !isFalsyCommandTemplateValue(resolved);
732
+ }
733
+
734
+ function resolveCommandTemplateNullish(
735
+ content: string,
736
+ values: Record<string, unknown>,
737
+ ): string | undefined {
738
+ const coalescing = content.match(/^([A-Za-z_][A-Za-z0-9_-]*)\?\?(.*)$/);
739
+ if (!coalescing) return undefined;
740
+ const value = values[coalescing[1]];
741
+ return isFalsyCommandTemplateValue(value) ? coalescing[2] : String(value);
742
+ }
743
+
744
+ function resolveCommandTemplateTernary(
745
+ content: string,
746
+ values: Record<string, unknown>,
747
+ ): string | undefined {
748
+ const ternary = content.match(/^([^?:]+)\?([^:]*):(.*)$/);
749
+ if (!ternary) return undefined;
750
+ const condition = resolveCommandTemplateCondition(ternary[1], values);
751
+ return isFalsyCommandTemplateValue(condition) ? ternary[3] : ternary[2];
752
+ }
753
+
754
+ function resolveCommandTemplateValue(
755
+ content: string,
756
+ values: Record<string, unknown>,
757
+ missingLabel: string,
758
+ depth = 0,
759
+ ): string | undefined {
760
+ if (depth > 5)
761
+ throw new Error(`Command template value recursion exceeded: ${content}`);
762
+ const nullish = resolveCommandTemplateNullish(content, values);
763
+ if (nullish !== undefined) return nullish;
764
+ const ternary = resolveCommandTemplateTernary(content, values);
765
+ if (ternary !== undefined) return ternary;
766
+ const indexed = content.match(
767
+ /^([A-Za-z_][A-Za-z0-9_-]*)\[([A-Za-z_][A-Za-z0-9_-]*|\d+)\]$/,
768
+ );
769
+ if (indexed) {
770
+ const source = values[indexed[1]];
771
+ const indexValue = /^\d+$/.test(indexed[2])
772
+ ? indexed[2]
773
+ : values[indexed[2]];
774
+ const index = Number(indexValue);
775
+ if (
776
+ !Array.isArray(source) ||
777
+ !Number.isInteger(index) ||
778
+ index < 0 ||
779
+ index >= source.length
780
+ ) {
781
+ throw new Error(`Missing ${missingLabel} value: ${content}`);
782
+ }
783
+ return String(source[index] ?? "");
784
+ }
785
+ const simple = parseCommandTemplatePlaceholderContent(content);
786
+ if (simple) {
787
+ if (Object.hasOwn(values, simple.name)) {
788
+ const raw = values[simple.name] ?? "";
789
+ if (
790
+ typeof raw === "string" &&
791
+ shouldResolveEmbeddedCommandTemplateToken(raw, values)
792
+ ) {
793
+ return substituteCommandTemplateToken(
794
+ raw,
795
+ values,
796
+ missingLabel,
797
+ depth + 1,
798
+ );
799
+ }
800
+ return Array.isArray(raw) ? JSON.stringify(raw) : String(raw);
801
+ }
802
+ if (simple.inlineDefault !== undefined) return simple.inlineDefault;
803
+ }
804
+ const expression = substituteCommandTemplateExpression(content, values);
805
+ if (expression !== undefined) return expression;
806
+ return undefined;
807
+ }
808
+
809
+ export function substituteCommandTemplateToken(
810
+ token: string,
811
+ values: Record<string, unknown>,
812
+ missingLabel = "command template",
813
+ depth = 0,
814
+ ): string {
815
+ return token.replace(/\{([^{}]+)\}/g, (_match, content: string) => {
816
+ const resolved = resolveCommandTemplateValue(
817
+ content,
818
+ values,
819
+ missingLabel,
820
+ depth,
821
+ );
822
+ if (resolved !== undefined) return resolved;
823
+ throw new Error(`Missing ${missingLabel} value: ${content}`);
824
+ });
825
+ }
826
+
827
+ export async function execCommandTemplate(
828
+ command: string,
829
+ args: string[],
830
+ options: CommandTemplateExecOptions = {},
831
+ ): Promise<CommandTemplateExecResult> {
832
+ const maxAttempts = options.retry ?? 1;
833
+ let lastResult: CommandTemplateExecResult = {
834
+ stdout: "",
835
+ stderr: "",
836
+ code: 1,
837
+ killed: false,
838
+ };
839
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
840
+ const result = await execCommandTemplateOnce(command, args, options);
841
+ if (result.code === 0) return result;
842
+ lastResult = result;
843
+ }
844
+ return lastResult;
845
+ }
846
+
847
+ function execCommandTemplateOnce(
848
+ command: string,
849
+ args: string[],
850
+ options: CommandTemplateExecOptions = {},
851
+ ): Promise<CommandTemplateExecResult> {
852
+ return new Promise((resolve) => {
853
+ const proc = spawn(command, args, {
854
+ cwd: options.cwd,
855
+ shell: false,
856
+ stdio: [options.stdin === undefined ? "ignore" : "pipe", "pipe", "pipe"],
857
+ });
858
+ let stdout = "";
859
+ let stderr = "";
860
+ let killed = false;
861
+ let settled = false;
862
+ let timeoutId: NodeJS.Timeout | undefined;
863
+ let killTimeoutId: NodeJS.Timeout | undefined;
864
+ const killProcess = (): void => {
865
+ if (killed) return;
866
+ killed = true;
867
+ proc.kill("SIGTERM");
868
+ killTimeoutId = setTimeout(() => {
869
+ if (!settled) proc.kill("SIGKILL");
870
+ }, options.killGrace ?? 5000);
871
+ };
872
+ const settle = (code: number): void => {
873
+ if (settled) return;
874
+ settled = true;
875
+ if (timeoutId) clearTimeout(timeoutId);
876
+ if (killTimeoutId) clearTimeout(killTimeoutId);
877
+ if (options.signal)
878
+ options.signal.removeEventListener("abort", killProcess);
879
+ resolve({ stdout, stderr, code, killed });
880
+ };
881
+ if (options.signal) {
882
+ if (options.signal.aborted) killProcess();
883
+ else
884
+ options.signal.addEventListener("abort", killProcess, { once: true });
885
+ }
886
+ if (options.timeout !== undefined && options.timeout > 0)
887
+ timeoutId = setTimeout(killProcess, options.timeout);
888
+ proc.stdout?.on("data", (data) => {
889
+ stdout += data.toString();
890
+ });
891
+ proc.stderr?.on("data", (data) => {
892
+ stderr += data.toString();
893
+ });
894
+ proc.stdin?.on("error", () => {});
895
+ if (options.stdin !== undefined) proc.stdin?.end(options.stdin);
896
+ proc.on("error", (error) => {
897
+ stderr += error instanceof Error ? error.message : String(error);
898
+ settle(1);
899
+ });
900
+ proc.on("close", (code) => {
901
+ settle(code ?? (killed ? 1 : 0));
902
+ });
903
+ });
904
+ }
905
+
906
+ export function buildCommandTemplateInvocation(
907
+ config: CommandTemplateConfig,
908
+ values: Record<string, unknown>,
909
+ cwd: string,
910
+ options: { emptyMessage?: string; missingLabel?: string } = {},
911
+ ): CommandTemplateInvocation {
912
+ const normalizedConfig = normalizeCommandTemplateConfig(config);
913
+ if (Array.isArray(normalizedConfig.template)) {
914
+ throw new Error(
915
+ options.emptyMessage ??
916
+ "Command template sequence cannot be executed as one command",
917
+ );
918
+ }
919
+ if (!normalizedConfig.template)
920
+ throw new Error(options.emptyMessage ?? "Command template is required");
921
+ if (typeof normalizedConfig.template !== "string") {
922
+ throw new Error(
923
+ options.emptyMessage ??
924
+ "Command template object cannot be executed as one command",
925
+ );
926
+ }
927
+ const parts = splitCommandTemplate(normalizedConfig.template);
928
+ const commandPart = parts[0];
929
+ if (!commandPart)
930
+ throw new Error(options.emptyMessage ?? "Command template is empty");
931
+ const resolvedValues = {
932
+ ...getCommandTemplateDefaults(normalizedConfig),
933
+ ...values,
934
+ };
935
+ const command = expandCommandTemplateExecutable(
936
+ substituteCommandTemplateToken(
937
+ commandPart,
938
+ resolvedValues,
939
+ options.missingLabel,
940
+ ),
941
+ cwd,
942
+ );
943
+ const args = parts
944
+ .slice(1)
945
+ .map((part) =>
946
+ substituteCommandTemplateToken(
947
+ part,
948
+ resolvedValues,
949
+ options.missingLabel,
950
+ ),
951
+ )
952
+ .filter((part) => part !== "");
953
+ return { command, args };
954
+ }