@desplega.ai/agent-swarm 1.160.0 → 1.162.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 (398) hide show
  1. package/README.md +4 -3
  2. package/dist/{acp-adapter-2mjwcsfh.js → acp-adapter-74m73ae9.js} +163 -49
  3. package/dist/{actions-e43rxskr.js → actions-4sr14gnt.js} +42 -38
  4. package/dist/{anthropic-messages-5qx80j9k.js → anthropic-messages-8xxrzky9.js} +22 -26
  5. package/dist/{app-mc7xfagn.js → app-pt68fbwp.js} +17 -14
  6. package/dist/{artifact-3v5t9jtg.js → artifact-fey7dvj9.js} +3 -2
  7. package/dist/{assistant-sedkzv3b.js → assistant-cv3jytks.js} +43 -39
  8. package/dist/{azure-openai-responses-nfb21z9a.js → azure-openai-responses-f5cqsyj8.js} +15 -10
  9. package/dist/{boot-reembed-m3656j2n.js → boot-reembed-4ht4gqth.js} +17 -14
  10. package/dist/{boot-reembed-cqz9swn5.js → boot-reembed-nxpcvpj9.js} +16 -13
  11. package/dist/{boot-scrub-logs-xbxf5d7w.js → boot-scrub-logs-k93kyw8k.js} +13 -10
  12. package/dist/boot-seeds-1skcrs0e.js +32 -0
  13. package/dist/{claude-adapter-dc6289mc.js → claude-adapter-r5g0tzge.js} +39 -30
  14. package/dist/{claude-managed-adapter-naaw51me.js → claude-managed-adapter-yxkfxg8j.js} +6 -5
  15. package/dist/{claude-managed-setup-eacvchx0.js → claude-managed-setup-pkyrgshb.js} +27 -27
  16. package/dist/{claude-sdk-session-bqp2xvym.js → claude-sdk-session-jxyxnrwd.js} +8041 -7910
  17. package/dist/{cli-4derpgyk.js → cli-2hhfhfq5.js} +6 -1
  18. package/dist/{cli-rykfmgwg.js → cli-2x0e561b.js} +1 -1
  19. package/dist/{cli-tzx2ke1v.js → cli-2zy95vhm.js} +137 -64
  20. package/dist/{cli-0x01kwrd.js → cli-4cwxn7gp.js} +47 -186
  21. package/dist/{cli-xjcywfsf.js → cli-4dcpaefp.js} +12 -11
  22. package/dist/{cli-v7fn5gms.js → cli-4x0csdjq.js} +164 -76
  23. package/dist/{cli-12tszpk9.js → cli-5bcd7sfy.js} +91 -29
  24. package/dist/{cli-jz4w45qt.js → cli-5k6k8ta3.js} +190 -50
  25. package/dist/{cli-tpq83z89.js → cli-5xhpb3kv.js} +20 -19
  26. package/dist/{cli-r1mxd1xh.js → cli-7af8yhav.js} +6 -179
  27. package/dist/{cli-jajnsm8q.js → cli-7tre70zp.js} +18160 -31345
  28. package/dist/{cli-447dt1h3.js → cli-8ev9xqnx.js} +218 -25
  29. package/dist/cli-bsky8g7w.js +449 -0
  30. package/dist/{cli-0z2v4nhw.js → cli-cat6h73s.js} +1 -1
  31. package/dist/{cli-25fcq4b4.js → cli-cebmgwsc.js} +15 -11
  32. package/dist/{cli-shkxm1vn.js → cli-cvatsam7.js} +189 -13
  33. package/dist/{cli-2658f6at.js → cli-cvk6yzw5.js} +6 -8
  34. package/dist/cli-dbmwby6a.js +9 -0
  35. package/dist/{cli-ptr8h7kp.js → cli-eg0b3p0k.js} +5 -218
  36. package/dist/cli-f9w1semm.js +413 -0
  37. package/dist/{cli-523679eh.js → cli-g739zqzt.js} +6 -5
  38. package/dist/{cli-dv6cdjs2.js → cli-gd4favx9.js} +28 -7
  39. package/dist/{cli-c8a36vcc.js → cli-gpqpmns7.js} +2 -2
  40. package/dist/{cli-5nbmpy8w.js → cli-hb5c2x5y.js} +1 -1
  41. package/dist/{cli-741yb0xx.js → cli-hmsw1gpy.js} +55 -169
  42. package/dist/{cli-qydf22qq.js → cli-jf7wmv1r.js} +2562 -735
  43. package/dist/{cli-mfe5btp9.js → cli-jxs2ygaw.js} +317 -121
  44. package/dist/{cli-kmcpfwn2.js → cli-jyy6pm2f.js} +19 -3
  45. package/dist/cli-kdkwd3yr.js +615 -0
  46. package/dist/{cli-6cs6wzxt.js → cli-kh04eqwe.js} +2 -2
  47. package/dist/{cli-9hsgwz4w.js → cli-kp42yek0.js} +1309 -391
  48. package/dist/cli-ma3zvh39.js +10404 -0
  49. package/dist/{cli-ybgv4kw2.js → cli-mbssg1xv.js} +9 -2
  50. package/dist/{cli-jsp14b6c.js → cli-mzfth0bp.js} +38 -1
  51. package/dist/{cli-r2ap2czm.js → cli-nexqx4ve.js} +6 -0
  52. package/dist/{cli-f8gy6r2r.js → cli-nq7yqw7b.js} +19 -8
  53. package/dist/{cli-10nhj6xq.js → cli-nt8hecg9.js} +34 -33
  54. package/dist/cli-p0r8sxj5.js +303 -0
  55. package/dist/{cli-58e8yr0d.js → cli-pkd6s2wy.js} +4 -2
  56. package/dist/{cli-a8dvhzrt.js → cli-q24re23n.js} +7 -5
  57. package/dist/cli-qjjvzwzd.js +222 -0
  58. package/dist/cli-qrgt5bqf.js +189 -0
  59. package/dist/{cli-et8m9xsv.js → cli-rfjw9jw2.js} +22 -10
  60. package/dist/{cli-7e398j1h.js → cli-rj0gqwwp.js} +3 -3
  61. package/dist/{cli-btfv8y88.js → cli-rnyzn44p.js} +2 -2
  62. package/dist/{cli-d5czme6m.js → cli-s3hwpt9v.js} +4754 -4945
  63. package/dist/{cli-0jwe9034.js → cli-sptrj5f5.js} +3 -3
  64. package/dist/{cli-0q3avq3s.js → cli-sqvfa090.js} +19 -11
  65. package/dist/{cli-azhgzetg.js → cli-swfmp1fx.js} +27 -27
  66. package/dist/{cli-jyk0ynw2.js → cli-t845n9xk.js} +23 -10
  67. package/dist/{cli-zpep9q5e.js → cli-tcen9p5w.js} +20 -15
  68. package/dist/{cli-74h9hscv.js → cli-tre4bdgq.js} +1 -1
  69. package/dist/{cli-pm1rst0h.js → cli-twrh04ap.js} +30 -15
  70. package/dist/{cli-phsaj4xq.js → cli-v0pvvhfq.js} +1 -1
  71. package/dist/{cli-ydmcgve1.js → cli-vc9bp061.js} +5 -5
  72. package/dist/{cli-g2whhdrf.js → cli-vxe6qa4h.js} +1 -1
  73. package/dist/{cli-vctdqs5h.js → cli-vy3ed88x.js} +15 -2
  74. package/dist/{cli-br0qdrnp.js → cli-vyqs9ya8.js} +18 -18
  75. package/dist/{cli-cpvsaqsw.js → cli-w0bwte75.js} +8 -5
  76. package/dist/cli-wbvnn6tk.js +861 -0
  77. package/dist/{cli-r94z9p1z.js → cli-wgbezhw2.js} +3 -0
  78. package/dist/{cli-evvtk35y.js → cli-wjgs5wxe.js} +7 -7
  79. package/dist/cli-wxkkd0e0.js +33 -0
  80. package/dist/{cli-0wgxmwf6.js → cli-xk79303e.js} +20 -7
  81. package/dist/{cli-ktmyrtpn.js → cli-xqpk3rp7.js} +33 -10
  82. package/dist/{cli-ygwm91nt.js → cli-yy6dew39.js} +1 -1
  83. package/dist/cli-zp38xvtm.js +9487 -0
  84. package/dist/{cli-tfky2838.js → cli-zvhd3f64.js} +4 -4
  85. package/dist/{cli-jayjpjmb.js → cli-zxqx25nz.js} +66 -23
  86. package/dist/cli.js +40 -32
  87. package/dist/{cloudflare-workers-ai-system-one-k6fbxw9d.js → cloudflare-workers-ai-system-one-k8ddqjkq.js} +8 -6
  88. package/dist/{codex-adapter-nmxcatww.js → codex-adapter-esvmnhn7.js} +24 -23
  89. package/dist/{codex-hook-20me6byw.js → codex-hook-m73jmqgx.js} +19 -3
  90. package/dist/{codex-login-w6fz4xbz.js → codex-login-cf7mzsgg.js} +2 -2
  91. package/dist/{codex-session-runner-90aa80ev.js → codex-session-runner-ban9excr.js} +24 -23
  92. package/dist/{commands-8wcq1kn7.js → commands-75413p2n.js} +13 -10
  93. package/dist/{db-j40kc4se.js → db-7f5pecwg.js} +17 -10
  94. package/dist/{dispatcher-4zqy768d.js → dispatcher-fh9at8nz.js} +41 -37
  95. package/dist/dsh-adapter-wpze65d4.js +24 -0
  96. package/dist/{e2b-ez07znam.js → e2b-gjgdjp91.js} +12 -9
  97. package/dist/easter-egg-3d-3w5c2n4c.js +1057 -0
  98. package/dist/{execute-6e7qeyk4.js → execute-f50wg9nh.js} +203 -49
  99. package/dist/{google-generative-ai-k6n5nbpp.js → google-generative-ai-jxxpnegy.js} +2 -2
  100. package/dist/{google-vertex-44xxtcvp.js → google-vertex-x7q1angm.js} +5 -5
  101. package/dist/{handlers-kjdce1w5.js → handlers-w13787bb.js} +44 -40
  102. package/dist/{hook-r2t4bqfg.js → hook-46g1jrvx.js} +34 -20
  103. package/dist/{hook-czx13n12.js → hook-4tpts2ry.js} +25 -21
  104. package/dist/{http-3bbb19be.js → http-19pzbfrt.js} +1440 -283
  105. package/dist/{index-668me3f0.js → index-8fd4dm4h.js} +42 -38
  106. package/dist/{index-fg0dsp6c.js → index-dqmp15bq.js} +41 -37
  107. package/dist/{index-kkv84jq9.js → index-qb4q1y3e.js} +41 -37
  108. package/dist/index-s75wc4wd.js +33 -0
  109. package/dist/{index-zg7vp46x.js → index-scptvdxg.js} +64 -38
  110. package/dist/{keepalive-yra8dy57.js → keepalive-xa5ts9cd.js} +15 -12
  111. package/dist/{lead-va0pad2c.js → lead-qp4xkvjq.js} +59 -54
  112. package/dist/{maintenance-hqewtmyg.js → maintenance-rm5885hm.js} +17 -14
  113. package/dist/{mistral-conversations-pc3ntnxt.js → mistral-conversations-rw7fbt22.js} +4 -4
  114. package/dist/{node-a5e00qhp.js → node-8zkdq42h.js} +834 -833
  115. package/dist/node-f0ykebbv.js +2107 -0
  116. package/dist/node-wyamey5r.js +19 -0
  117. package/dist/{oauth-refresh-sweep-7rdt1m9n.js → oauth-refresh-sweep-1csdfebf.js} +14 -11
  118. package/dist/{onboard-j6ms6d0x.js → onboard-r6b78cs4.js} +10 -10
  119. package/dist/{openai-codex-responses-bbancrr0.js → openai-codex-responses-efvrgrq3.js} +4 -4
  120. package/dist/{openai-completions-jpaj5g2b.js → openai-completions-bbbrrz4z.js} +12 -8
  121. package/dist/{openai-responses-200k1wx4.js → openai-responses-9jjyrcm1.js} +15 -10
  122. package/dist/{opencode-adapter-89rabkw2.js → opencode-adapter-kb3g6pkf.js} +12 -9
  123. package/dist/{otel-impl-a792rjz0.js → otel-impl-0y9knpky.js} +6 -6
  124. package/dist/{pi-mono-adapter-g7qzvr3v.js → pi-mono-adapter-z6s1bme2.js} +128 -37
  125. package/dist/{pricing-refresh-wx0tp7cb.js → pricing-refresh-mth26tgp.js} +15 -12
  126. package/dist/{rbac-roles-8tzawacv.js → rbac-roles-kwntb23q.js} +17 -12
  127. package/dist/rbac-roles-vpk4ebm8.js +45 -0
  128. package/dist/{registry-v5wytg0s.js → registry-km6t1jd2.js} +1 -1
  129. package/dist/{render-v2-mm7zswb8.js → render-v2-hcm7h00y.js} +17 -14
  130. package/dist/{runtime-zyssgse0.js → runtime-vfjsfsc5.js} +5 -4
  131. package/dist/{setup-8y70ys6t.js → setup-hbyzd65h.js} +2 -2
  132. package/dist/{virtual-modules-6nmk7h3n.js → virtual-modules-9bv7ry91.js} +9 -7
  133. package/dist/{work-objects-fg6xkb0n.js → work-objects-m09sxnhe.js} +44 -40
  134. package/dist/{worker-wmwhxsph.js → worker-0h35rvk4.js} +59 -54
  135. package/dist/{x-n3e0v3xa.js → x-f1gt1pz3.js} +2 -2
  136. package/openapi.json +699 -26
  137. package/package.json +19 -11
  138. package/src/azure-devops/api.ts +121 -0
  139. package/src/azure-devops/auth.ts +78 -0
  140. package/src/azure-devops/handlers.ts +413 -0
  141. package/src/azure-devops/index.ts +27 -0
  142. package/src/azure-devops/templates.ts +108 -0
  143. package/src/azure-devops/types.ts +90 -0
  144. package/src/be/api-drain.ts +184 -0
  145. package/src/be/db/tasks/read.ts +32 -7
  146. package/src/be/db/tasks/write.ts +21 -4
  147. package/src/be/db-client.ts +11 -2
  148. package/src/be/db-retention.ts +95 -32
  149. package/src/be/db.ts +44 -19
  150. package/src/be/memory/constants.ts +16 -0
  151. package/src/be/memory/graph-expansion.ts +8 -1
  152. package/src/be/memory/index-content.ts +20 -1
  153. package/src/be/memory/key-guard.ts +93 -0
  154. package/src/be/memory/key-paths.ts +103 -0
  155. package/src/be/memory/link-resolver.ts +29 -3
  156. package/src/be/memory/providers/sqlite-store.ts +152 -45
  157. package/src/be/memory/raters/llm-summarizer.ts +10 -4
  158. package/src/be/memory/raters/llm.ts +15 -5
  159. package/src/be/memory/raters/store.ts +6 -3
  160. package/src/be/memory/raters/types.ts +11 -0
  161. package/src/be/memory/reranker.ts +38 -7
  162. package/src/be/memory/types.ts +12 -1
  163. package/src/be/migrations/190_memory_rating_model.sql +7 -0
  164. package/src/be/migrations/191_context_versions_previous_index.sql +8 -0
  165. package/src/be/migrations/192_favorites_agent_fs_path.sql +36 -0
  166. package/src/be/onboarding.ts +7 -1
  167. package/src/be/pricing-normalize.ts +4 -2
  168. package/src/be/scripts/typecheck.ts +4 -3
  169. package/src/be/seed-pricing.ts +16 -0
  170. package/src/be/seed-prompt-templates.ts +1 -0
  171. package/src/be/swarm-config-guard.ts +46 -17
  172. package/src/be/task-citations.ts +11 -5
  173. package/src/be/users.ts +3 -0
  174. package/src/cli.tsx +3 -2
  175. package/src/comb/agent-fs.ts +39 -0
  176. package/src/comb/config.ts +37 -0
  177. package/src/comb/markers.ts +37 -0
  178. package/src/comb/review-batch.ts +486 -0
  179. package/src/comb/templates.ts +88 -0
  180. package/src/commands/claude-managed-setup.ts +33 -31
  181. package/src/commands/context-preamble.ts +4 -1
  182. package/src/commands/hook.ts +2 -1
  183. package/src/commands/provider-credentials.ts +28 -15
  184. package/src/commands/runner.ts +458 -110
  185. package/src/commands/templates.ts +10 -0
  186. package/src/e2b/env.ts +2 -0
  187. package/src/extensions/catalog.generated.json +17 -0
  188. package/src/extensions/contract-types.generated.ts +1 -1
  189. package/src/fs/agent-fs-provider.ts +106 -2
  190. package/src/github/handlers.ts +10 -74
  191. package/src/github/reactions.ts +119 -138
  192. package/src/github/task-reactions.ts +34 -11
  193. package/src/heartbeat/heartbeat.ts +4 -0
  194. package/src/hooks/codex-hook.ts +25 -1
  195. package/src/hooks/hook.ts +14 -1
  196. package/src/hooks/pr-body-guard.ts +983 -0
  197. package/src/http/agents.ts +1 -1
  198. package/src/http/all-routes.ts +1 -0
  199. package/src/http/assets.ts +5 -17
  200. package/src/http/comb.ts +131 -0
  201. package/src/http/core.ts +14 -1
  202. package/src/http/extensions.ts +51 -27
  203. package/src/http/fs.ts +9 -17
  204. package/src/http/index.ts +27 -9
  205. package/src/http/mcp-user.ts +8 -13
  206. package/src/http/mcp.ts +19 -12
  207. package/src/http/memory.ts +80 -14
  208. package/src/http/onboarding.ts +21 -2
  209. package/src/http/poll.ts +30 -3
  210. package/src/http/realtime.ts +62 -0
  211. package/src/http/request-principal.ts +22 -0
  212. package/src/http/session-data.ts +6 -4
  213. package/src/http/stats.ts +1 -0
  214. package/src/http/status.ts +34 -2
  215. package/src/http/tasks.ts +17 -3
  216. package/src/http/users.ts +1 -1
  217. package/src/http/webhooks.ts +120 -2
  218. package/src/kv-reserved-namespaces.ts +10 -5
  219. package/src/providers/claude-adapter.ts +84 -16
  220. package/src/providers/claude-managed-adapter.ts +29 -2
  221. package/src/providers/codex-adapter.ts +1 -1
  222. package/src/providers/codex-skill-resolver.ts +6 -0
  223. package/src/providers/dsh-adapter.ts +204 -7
  224. package/src/providers/opencode-adapter.ts +24 -3
  225. package/src/providers/pi-mono-adapter.ts +154 -5
  226. package/src/providers/pi-mono-extension.ts +1 -1
  227. package/src/providers/pricing-sources.md +5 -1
  228. package/src/providers/reasoning-effort.ts +10 -2
  229. package/src/providers/types.ts +1 -1
  230. package/src/rbac/legacy-policy.ts +3 -0
  231. package/src/rbac/permissions.ts +14 -0
  232. package/src/realtime/auth.ts +63 -1
  233. package/src/realtime/tickets.ts +52 -0
  234. package/src/realtime/transport.ts +51 -22
  235. package/src/scripts-runtime/types/stdlib.d.ts +13 -5
  236. package/src/scripts-runtime/types/swarm-extension.d.ts +7 -3
  237. package/src/scripts-runtime/types/swarm-sdk.d.ts +13 -5
  238. package/src/tasks/context-key.ts +38 -1
  239. package/src/telemetry-context.ts +175 -0
  240. package/src/telemetry-contract/EVENTS.md +81 -0
  241. package/src/telemetry-contract/SOURCE.json +9 -0
  242. package/src/telemetry-contract/catalog.json +1335 -0
  243. package/src/telemetry-contract/index.ts +60 -0
  244. package/src/telemetry-contract/types.gen.ts +1971 -0
  245. package/src/telemetry-identity.ts +129 -0
  246. package/src/telemetry-snapshot.ts +211 -0
  247. package/src/telemetry-trigger.ts +125 -0
  248. package/src/telemetry-types.typetest.ts +40 -0
  249. package/src/telemetry.ts +271 -67
  250. package/src/tests/api-drain-e2e.test.ts +249 -0
  251. package/src/tests/api-drain-worker-e2e.test.ts +216 -0
  252. package/src/tests/api-drain.test.ts +351 -0
  253. package/src/tests/azure-devops-auth.test.ts +100 -0
  254. package/src/tests/azure-devops-handlers.test.ts +324 -0
  255. package/src/tests/azure-devops-webhook-malformed.test.ts +96 -0
  256. package/src/tests/claude-default-route.test.ts +260 -0
  257. package/src/tests/claude-managed-adapter.test.ts +47 -0
  258. package/src/tests/claude-managed-setup.test.ts +48 -0
  259. package/src/tests/claude-prompt-body-once.test.ts +117 -0
  260. package/src/tests/claude-routes-e2e.test.ts +316 -0
  261. package/src/tests/comb-config-guard.test.ts +38 -0
  262. package/src/tests/comb-links.test.ts +162 -0
  263. package/src/tests/comb-markers.test.ts +68 -0
  264. package/src/tests/comb-review-batch.test.ts +770 -0
  265. package/src/tests/comb-status.test.ts +152 -0
  266. package/src/tests/context-versions-retention.test.ts +314 -0
  267. package/src/tests/core-auth.test.ts +7 -0
  268. package/src/tests/db-retention.test.ts +14 -14
  269. package/src/tests/db-task-read-contract.test.ts +3 -0
  270. package/src/tests/db-task-write-contract.test.ts +3 -0
  271. package/src/tests/docs-index-footprint.test.js +3 -3
  272. package/src/tests/dsh-adapter.test.ts +134 -2
  273. package/src/tests/dsh-usage.test.ts +153 -0
  274. package/src/tests/extensions-catalog.test.ts +1 -0
  275. package/src/tests/extensions-example-deploy-awareness.test.ts +301 -0
  276. package/src/tests/extensions-http.test.ts +137 -10
  277. package/src/tests/extensions-mcp-tools.test.ts +28 -0
  278. package/src/tests/favorites-agent-fs-path.test.ts +226 -0
  279. package/src/tests/fetch-resolved-env.test.ts +24 -0
  280. package/src/tests/fixtures/azure-devops/pull-request-commented.json +129 -0
  281. package/src/tests/fixtures/azure-devops/pull-request-created.json +88 -0
  282. package/src/tests/fixtures/fake-claude-routes.ts +229 -0
  283. package/src/tests/github-handlers-reactions.test.ts +486 -0
  284. package/src/tests/github-reactions.test.ts +280 -0
  285. package/src/tests/harness-cli-version.test.ts +62 -0
  286. package/src/tests/http-api-integration.test.ts +21 -0
  287. package/src/tests/http-task-write-ownership.test.ts +24 -1
  288. package/src/tests/internal-ai/complete-structured.test.ts +94 -0
  289. package/src/tests/internal-ai/credentials.test.ts +22 -0
  290. package/src/tests/internal-ai/models.test.ts +36 -2
  291. package/src/tests/internal-ai/schema-parity.test.ts +25 -1
  292. package/src/tests/internal-ai/summarize-session.test.ts +23 -7
  293. package/src/tests/mcp-user-route.test.ts +133 -0
  294. package/src/tests/memory-key-paths.test.ts +1055 -0
  295. package/src/tests/memory-link-resolver.test.ts +34 -0
  296. package/src/tests/memory-rate-endpoint.test.ts +66 -0
  297. package/src/tests/memory-rater-llm-summarizer.test.ts +2 -1
  298. package/src/tests/memory-rater-llm.test.ts +73 -0
  299. package/src/tests/memory-rater-store.test.ts +31 -0
  300. package/src/tests/memory-reranker.test.ts +40 -0
  301. package/src/tests/onboarding.test.ts +108 -0
  302. package/src/tests/opencode-adapter.test.ts +57 -0
  303. package/src/tests/opencode-plugin.test.ts +4 -0
  304. package/src/tests/pi-codemode.test.ts +82 -4
  305. package/src/tests/pi-mono-adapter.test.ts +265 -2
  306. package/src/tests/pr-body-leaks.test.ts +789 -0
  307. package/src/tests/preload.ts +14 -0
  308. package/src/tests/provider-registration.test.ts +0 -2
  309. package/src/tests/providers/pi-cost.test.ts +190 -4
  310. package/src/tests/rbac-engine.test.ts +25 -1
  311. package/src/tests/realtime-room-auth.test.ts +104 -1
  312. package/src/tests/realtime-tickets.test.ts +74 -0
  313. package/src/tests/realtime-transport.test.ts +131 -4
  314. package/src/tests/runner-api-drain.test.ts +301 -0
  315. package/src/tests/runner-fallback-output.test.ts +61 -0
  316. package/src/tests/runner-fenced-json-output.test.ts +178 -0
  317. package/src/tests/runner-slot-reconcile.test.ts +199 -0
  318. package/src/tests/script-connections.test.ts +6 -0
  319. package/src/tests/send-task-requested-by.test.ts +133 -15
  320. package/src/tests/session-costs-recompute-all-providers.test.ts +23 -0
  321. package/src/tests/task-lifecycle-telemetry.test.ts +8 -3
  322. package/src/tests/task-reactions.test.ts +29 -6
  323. package/src/tests/telemetry-context.test.ts +314 -0
  324. package/src/tests/telemetry-init.test.ts +51 -19
  325. package/src/tests/telemetry-snapshot.test.ts +229 -0
  326. package/src/tests/telemetry-trigger.test.ts +200 -0
  327. package/src/tests/template-registry-helpers.ts +1 -0
  328. package/src/tests/vcs-azure-devops.test.ts +73 -0
  329. package/src/tests/webhooks-task-blocked.test.ts +23 -0
  330. package/src/tests/workflow-agent-task-retry.test.ts +363 -0
  331. package/src/tests/workflow-definition-telemetry.test.ts +4 -4
  332. package/src/tests/workflow-llm.test.ts +14 -0
  333. package/src/tools/context-diff.ts +20 -0
  334. package/src/tools/extension-install.ts +27 -16
  335. package/src/tools/memory-edit.ts +47 -3
  336. package/src/tools/memory-search.ts +13 -1
  337. package/src/tools/memory-store.ts +55 -3
  338. package/src/tools/poll-task.ts +20 -1
  339. package/src/tools/send-task.ts +9 -1
  340. package/src/tools/task-action.ts +11 -0
  341. package/src/types.ts +45 -8
  342. package/src/utils/api-drain.ts +24 -0
  343. package/src/utils/constants.ts +57 -16
  344. package/src/utils/credentials.test.ts +31 -1
  345. package/src/utils/credentials.ts +20 -9
  346. package/src/utils/dsh-usage.ts +53 -0
  347. package/src/utils/harness-cli-version.ts +6 -4
  348. package/src/utils/internal-ai/complete-structured.ts +26 -3
  349. package/src/utils/internal-ai/credentials.ts +23 -9
  350. package/src/utils/internal-ai/index.ts +8 -1
  351. package/src/utils/internal-ai/models.ts +34 -8
  352. package/src/utils/internal-ai/summarize-session.ts +22 -8
  353. package/src/utils/pr-body-leaks.ts +172 -0
  354. package/src/utils/secret-scrubber.ts +8 -0
  355. package/src/utils/task-attachment-links.ts +14 -8
  356. package/src/vcs/azure-devops.ts +80 -0
  357. package/src/vcs/index.ts +5 -1
  358. package/src/vcs/types.ts +2 -2
  359. package/src/workflows/recovery.ts +26 -1
  360. package/src/workflows/resume.ts +31 -4
  361. package/src/workflows/task-step-routing.ts +75 -2
  362. package/templates/community/open-prompt-showreel/PLAYBOOK.md +336 -0
  363. package/templates/community/open-prompt-showreel/README.md +33 -0
  364. package/templates/community/open-prompt-showreel/example/tla-races/facts.ts +145 -0
  365. package/templates/community/open-prompt-showreel/example/tla-races/facts.v3.json +140 -0
  366. package/templates/community/open-prompt-showreel/example/tla-races/music.mist-city.json +8 -0
  367. package/templates/community/open-prompt-showreel/example/tla-races/reel.html +805 -0
  368. package/templates/community/open-prompt-showreel/example/tla-races/smoke.sh +48 -0
  369. package/templates/community/open-prompt-showreel/lead-prompt.md +89 -0
  370. package/templates/community/open-prompt-showreel/setup.sh +167 -0
  371. package/templates/community/open-prompt-showreel/skills/motion-design-replication/SKILL.md +85 -0
  372. package/templates/community/open-prompt-showreel/skills/motion-design-video-analysis/SKILL.md +115 -0
  373. package/templates/community/open-prompt-showreel/skills/open-prompt-showreel/SKILL.md +147 -0
  374. package/templates/community/open-prompt-showreel/skills/video-generation/SKILL.md +195 -0
  375. package/templates/community/open-prompt-showreel/tools/fetch-music.sh +65 -0
  376. package/templates/community/open-prompt-showreel/tools/music-analyze.py +69 -0
  377. package/templates/community/open-prompt-showreel/tools/music-current.sh +34 -0
  378. package/templates/community/open-prompt-showreel/tools/music-cut.sh +36 -0
  379. package/templates/community/open-prompt-showreel/tools/music-refine.py +39 -0
  380. package/templates/community/open-prompt-showreel/tools/render.mjs +157 -0
  381. package/templates/community/open-prompt-showreel/tools/sheet.sh +44 -0
  382. package/templates/community/open-prompt-showreel/tools/web-compress.sh +17 -0
  383. package/templates/community/open-prompt-showreel/tools/x-reencode.sh +21 -0
  384. package/templates/extensions/README.md +1 -0
  385. package/templates/extensions/deploy-awareness/README.md +28 -0
  386. package/templates/extensions/deploy-awareness/hooks.ts +152 -0
  387. package/templates/extensions/deploy-awareness/manifest.json +8 -0
  388. package/templates/skills/memory/config.json +2 -2
  389. package/templates/skills/memory/content.md +59 -5
  390. package/templates/skills/swarm-extensions/config.json +1 -1
  391. package/templates/skills/swarm-extensions/content.md +28 -5
  392. package/tsconfig.json +3 -0
  393. package/dist/boot-seeds-gsetbs5y.js +0 -28
  394. package/dist/cli-j490egb5.js +0 -5632
  395. package/dist/cli-tjf4cn8z.js +0 -9119
  396. package/dist/cli-tmqt7dpj.js +0 -572
  397. package/dist/dsh-adapter-mpnzgztj.js +0 -19
  398. package/dist/index-7aj368tw.js +0 -30
@@ -0,0 +1,157 @@
1
+ // Renders a frame-addressable canvas reel (reel.html) to stills or to an mp4.
2
+ //
3
+ // node render.mjs --reel reel.html --w 1920 --h 1080 --facts facts.json --logo logo.png \
4
+ // --fonts SG=fonts/SpaceGrotesk.ttf,JB=fonts/JetBrainsMono.ttf --out stills/r1 --at 12,45,100
5
+ // node render.mjs --reel reel.html --w 1920 --h 1080 --facts facts.json --logo logo.png \
6
+ // --fonts SG=...,JB=... --music music.json --out out/reel-1920x1080.mp4
7
+ //
8
+ // reel.html contract: window.boot(facts, fonts, logoDataUrl) loads fonts + logo and stashes the
9
+ // facts; window.frame(f) draws frame f as a pure function of f and returns a PNG data URL.
10
+ // `--music` takes a JSON file { credit, wav? }; its fields land in facts.music and, if wav is set,
11
+ // that file is muxed in as the audio track. Without `wav` the video is silent (a warning says so).
12
+ // Exits non-zero when ffmpeg fails or the page throws; the output directory is created.
13
+ import { spawn } from "node:child_process";
14
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
15
+ import { createRequire } from "node:module";
16
+ import { dirname, resolve } from "node:path";
17
+
18
+ const args = {};
19
+ const argv = process.argv.slice(2);
20
+ for (let i = 0; i < argv.length; i++) {
21
+ if (argv[i].startsWith("--")) args[argv[i].slice(2)] = argv[i + 1];
22
+ }
23
+ for (const k of ["reel", "w", "h", "facts", "logo", "fonts", "out"]) {
24
+ if (!args[k]) throw new Error(`missing --${k}`);
25
+ }
26
+ const [w, h, fps, frames] = [+args.w, +args.h, +(args.fps ?? 30), +(args.frames ?? 720)];
27
+
28
+ // playwright is baked into the worker image under /opt/global-deps-full; fall back to a local install.
29
+ const roots = [
30
+ process.env.PLAYWRIGHT_ROOT,
31
+ "/opt/global-deps-full/node_modules/",
32
+ `${process.cwd()}/node_modules/`,
33
+ ];
34
+ let chromium;
35
+ for (const root of roots.filter(Boolean)) {
36
+ try {
37
+ ({ chromium } = createRequire(root.replace(/\/?$/, "/"))("playwright"));
38
+ break;
39
+ } catch {}
40
+ }
41
+ if (!chromium) throw new Error("playwright not found; run setup.sh or set PLAYWRIGHT_ROOT");
42
+
43
+ const music = args.music ? JSON.parse(readFileSync(args.music, "utf8")) : null;
44
+ const facts = { ...JSON.parse(readFileSync(args.facts, "utf8")), ...(music ? { music } : {}) };
45
+ const logo = `data:image/png;base64,${readFileSync(args.logo).toString("base64")}`;
46
+ const fonts = args.fonts.split(",").map((p) => {
47
+ const [name, file] = p.split("=");
48
+ return [name, readFileSync(file).toString("base64")];
49
+ });
50
+
51
+ // Spawns ffmpeg, pipes `frames` PNGs from `grab` into it, and resolves only when ffmpeg exits 0 with
52
+ // every frame written. Failure handlers are attached before the first write, and a child that dies
53
+ // also unblocks a writer that is waiting for `drain`.
54
+ const encode = async (grab) => {
55
+ mkdirSync(dirname(resolve(args.out)), { recursive: true });
56
+ const input = ["-f", "image2pipe", "-framerate", String(fps), "-i", "-"];
57
+ const audio = music?.wav ? ["-i", music.wav, "-map", "0:v", "-map", "1:a"] : [];
58
+ const video = [
59
+ ...["-c:v", "libx264", "-preset", "slow", "-crf", "16"],
60
+ ...["-pix_fmt", "yuv420p", "-profile:v", "high"],
61
+ ];
62
+ const tail = music?.wav ? ["-c:a", "aac", "-b:a", "192k", "-shortest"] : [];
63
+ const ff = spawn(
64
+ "ffmpeg",
65
+ [
66
+ "-v",
67
+ "error",
68
+ "-y",
69
+ ...input,
70
+ ...audio,
71
+ ...video,
72
+ ...tail,
73
+ "-movflags",
74
+ "+faststart",
75
+ args.out,
76
+ ],
77
+ { stdio: ["pipe", "inherit", "inherit"] },
78
+ );
79
+ let ended = null;
80
+ const gone = new Promise((done) => {
81
+ const finish = (result) => {
82
+ // A failed spawn emits "error" and then "close" (code -2); keep the first, which says why.
83
+ if (ended) return;
84
+ ended = result;
85
+ done(result);
86
+ };
87
+ ff.once("error", (error) => finish({ error }));
88
+ ff.once("close", (code, signal) => finish({ code, signal }));
89
+ });
90
+ // EPIPE after ffmpeg dies is a symptom; the exit status below is the error that gets reported.
91
+ ff.stdin.on("error", () => {});
92
+
93
+ let written = 0;
94
+ const t0 = Date.now();
95
+ try {
96
+ for (let f = 0; f < frames && !ended; f++) {
97
+ const png = await grab(f);
98
+ if (ended) break;
99
+ if (!ff.stdin.write(png)) {
100
+ await Promise.race([new Promise((r) => ff.stdin.once("drain", r)), gone]);
101
+ }
102
+ written++;
103
+ if (f % 120 === 0) console.error(`frame ${f} ${((Date.now() - t0) / 1000).toFixed(0)}s`);
104
+ }
105
+ if (!ended) ff.stdin.end();
106
+ await gone;
107
+ } finally {
108
+ if (!ended) {
109
+ ff.stdin.destroy();
110
+ ff.kill("SIGKILL");
111
+ }
112
+ }
113
+ const fail = (why) => {
114
+ rmSync(args.out, { force: true });
115
+ throw new Error(why);
116
+ };
117
+ if (ended.error) fail(`could not run ffmpeg: ${ended.error.message}`);
118
+ if (ended.code !== 0) fail(`ffmpeg exited with ${ended.signal ?? `code ${ended.code}`}`);
119
+ if (written < frames) {
120
+ fail(
121
+ `ffmpeg stopped after ${written} of ${frames} frames (is the --music wav shorter than the video?)`,
122
+ );
123
+ }
124
+ };
125
+
126
+ if (music?.wav && !existsSync(music.wav)) throw new Error(`--music wav not found: ${music.wav}`);
127
+ if (music && !music.wav && !args.at) {
128
+ console.error(`warning: ${args.music} has no "wav" field, rendering a silent video`);
129
+ }
130
+
131
+ const browser = await chromium.launch({ args: ["--disable-gpu-vsync"] });
132
+ try {
133
+ const page = await browser.newPage({ viewport: { width: w, height: h } });
134
+ page.on("console", (m) => console.error("[page]", m.text()));
135
+ page.on("pageerror", (e) => console.error("[pageerror]", e.message));
136
+ await page.goto(`file://${resolve(args.reel)}?w=${w}&h=${h}`);
137
+ console.error(
138
+ JSON.stringify(await page.evaluate(([a, b, c]) => window.boot(a, b, c), [facts, fonts, logo])),
139
+ );
140
+
141
+ const grab = async (f) =>
142
+ Buffer.from((await page.evaluate((n) => window.frame(n), f)).split(",")[1], "base64");
143
+
144
+ if (args.at) {
145
+ mkdirSync(args.out, { recursive: true });
146
+ for (const f of args.at.split(",").map(Number)) {
147
+ writeFileSync(`${args.out}/f${String(f).padStart(3, "0")}.png`, await grab(f));
148
+ }
149
+ } else {
150
+ await encode(grab);
151
+ }
152
+ } catch (e) {
153
+ console.error(`render failed: ${e.message}`);
154
+ process.exitCode = 1;
155
+ } finally {
156
+ await browser.close();
157
+ }
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env bash
2
+ # Contact sheet: render stills across the timeline and tile them with ffmpeg xstack.
3
+ #
4
+ # sheet.sh <w> <h> <name> [frames]
5
+ #
6
+ # Default is 16 frames spread over the reel, tiled 4x4. Pass a comma list to look at specific frames
7
+ # (a transition strip is 20 frames with COLS=5). The count must be a multiple of COLS.
8
+ # Needs the same env as render.mjs: REEL, FACTS, LOGO, FONTS (and optional MUSIC, FRAMES_TOTAL).
9
+ # Writes stills/<name>/fNNN.png and <name>.png in the current directory.
10
+ set -euo pipefail
11
+
12
+ W=$1 H=$2 NAME=$3
13
+ TOOLS="$(cd "$(dirname "$0")" && pwd)"
14
+ : "${REEL:?set REEL=reel.html}" "${FACTS:?set FACTS=facts.json}" "${LOGO:?set LOGO=logo.png}" "${FONTS:?set FONTS=SG=a.ttf,JB=b.ttf}"
15
+ TOTAL=${FRAMES_TOTAL:-720}
16
+
17
+ if [ -n "${4:-}" ]; then
18
+ FR=$4
19
+ else
20
+ FR=$(awk -v n="$TOTAL" 'BEGIN { for (i = 0; i < 16; i++) printf "%s%d", (i ? "," : ""), int((i + 0.5) * n / 16) }')
21
+ fi
22
+
23
+ rm -rf "stills/$NAME"
24
+ node "$TOOLS/render.mjs" --reel "$REEL" --w "$W" --h "$H" --facts "$FACTS" --logo "$LOGO" --fonts "$FONTS" \
25
+ ${MUSIC:+--music "$MUSIC"} --out "stills/$NAME" --at "$FR" 2>/dev/null
26
+
27
+ COUNT=$(awk -F, '{ print NF }' <<<"$FR")
28
+ COLS=${COLS:-4}
29
+ if [ $((COUNT % COLS)) -ne 0 ]; then
30
+ echo "frame count $COUNT does not fill a grid of $COLS columns; pass a multiple of COLS" >&2
31
+ exit 1
32
+ fi
33
+ ROWS=$((COUNT / COLS))
34
+ inputs=() filt=""
35
+ i=0
36
+ for f in ${FR//,/ }; do
37
+ inputs+=(-i "stills/$NAME/f$(printf %03d "$f").png")
38
+ filt+="[$i]scale=iw/${COLS}:-1,pad=iw+4:ih+4:2:2:gray[s$i];"
39
+ i=$((i + 1))
40
+ done
41
+ for j in $(seq 0 $((COUNT - 1))); do filt+="[s$j]"; done
42
+ filt+="xstack=inputs=$COUNT:grid=${COLS}x${ROWS}"
43
+ ffmpeg -v error -y "${inputs[@]}" -filter_complex "$filt" "$NAME.png"
44
+ echo "$NAME.png (${COUNT} frames, ${COLS}x${ROWS})"
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env bash
2
+ # Makes a small web copy of a master render (for docs pages and PR bodies) plus a poster frame.
3
+ #
4
+ # web-compress.sh <master.mp4> <out-dir> <name> [poster-second]
5
+ #
6
+ # Writes <out-dir>/<name>.mp4 (1280 px wide, h264 yuv420p, AAC 96k, faststart) and <out-dir>/<name>.jpg.
7
+ # Keep the master in agent-fs; commit only this copy. A signed agent-fs URL expires, a file in the repo does not.
8
+ set -euo pipefail
9
+
10
+ in=$1 outdir=$2 name=$3 poster=${4:-20}
11
+ mkdir -p "$outdir"
12
+ ffmpeg -v error -y -i "$in" \
13
+ -vf "scale=1280:-2:flags=lanczos,format=yuv420p" \
14
+ -c:v libx264 -preset slow -crf "${CRF:-27}" -profile:v high -pix_fmt yuv420p -color_range tv \
15
+ -c:a aac -b:a 96k -movflags +faststart "$outdir/$name.mp4"
16
+ ffmpeg -v error -y -ss "$poster" -i "$in" -frames:v 1 -vf "scale=1280:-2:flags=lanczos" -q:v 4 "$outdir/$name.jpg"
17
+ ls -l "$outdir/$name.mp4" "$outdir/$name.jpg" | awk '{ print $5, $9 }'
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env bash
2
+ # Re-encodes an mp4 to limited-range (tv) yuv420p / bt709, the shape social uploaders handle reliably.
3
+ #
4
+ # x-reencode.sh <in.mp4> <out.mp4>
5
+ #
6
+ # Why: a clip made from JPEG frames, a screen recording or a camera export is often tagged
7
+ # yuvj420p (full range, "pc"). ffmpeg reproduces that tag; whether X rejects such a file is a
8
+ # field report from our own posting runs, not something this script proves. The render pipeline
9
+ # in render.mjs already emits yuv420p/tv, so run this only on clips that came from somewhere else.
10
+ set -euo pipefail
11
+
12
+ in=$1 out=$2
13
+ fmt=$(ffmpeg -hide_banner -i "$in" 2>&1 | grep -m1 'Stream.*Video' || true)
14
+ echo "before: ${fmt#*Video: }"
15
+ ffmpeg -v error -y -i "$in" \
16
+ -vf "scale=in_range=auto:out_range=tv:out_color_matrix=bt709,format=yuv420p" \
17
+ -c:v libx264 -preset slow -crf 16 -profile:v high -pix_fmt yuv420p \
18
+ -color_range tv -colorspace bt709 -color_primaries bt709 -color_trc bt709 \
19
+ -c:a copy -movflags +faststart "$out"
20
+ fmt=$(ffmpeg -hide_banner -i "$out" 2>&1 | grep -m1 'Stream.*Video' || true)
21
+ echo "after: ${fmt#*Video: }"
@@ -12,6 +12,7 @@ Each folder holds exactly one `manifest.yaml`, `manifest.yml`, or `manifest.json
12
12
  | `github-sender-allowlist` | `pre.task.create` | Blocks GitHub webhook tasks from senders outside configured allowlists |
13
13
  | `require-ticket-ref` | `pre.task.create` | Blocks REST, MCP, and Slack tasks that do not name a ticket |
14
14
  | `notify-on-complete` | `post.task.completed`, `post.task.failed` | Posts a summary to a Slack channel |
15
+ | `deploy-awareness` | `pre.task.create` | Appends a one-line note to new tasks while a Dokploy deploy is in progress |
15
16
  | `require-verification-note` | `pre.tool.call` | Refuses completion without a `Verified:` line in the output |
16
17
  | `task-digest` | `post.task.completed`, `post.task.failed` | Ships the `task-digest-collect` script, the `task-digest-daily` schedule (09:00 UTC), the `task-digest-report` workflow, and the `task-digest-guide` skill |
17
18
 
@@ -0,0 +1,28 @@
1
+ # deploy-awareness
2
+
3
+ Appends one line to a new task's description while a Dokploy compose deploy is in progress, so the worker knows it may restart soon:
4
+
5
+ ```
6
+ Note: a prod deploy started at 14:05 UTC is in progress; your worker may restart in the next few minutes. Checkpoint with store-progress before long steps.
7
+ ```
8
+
9
+ Install config:
10
+
11
+ ```json
12
+ { "composeId": "<compose id>" }
13
+ ```
14
+
15
+ Optional keys: `label` (the environment word in the note, default `prod`), `cacheTtlMs` (how long a check result, a failure included, is reused, default 120000), `timeoutMs` (caps the Dokploy call, default 2000), `staleAfterMs` (a deployment still `running` after this long is a stuck record and is ignored, default 1800000).
16
+
17
+ The Dokploy API key and URL are not extension config. Config is writable by a lead, and a key name or a host there would let it point the API process at any env secret and any host. They come from the API process environment:
18
+
19
+ - `DOKPLOY_API_KEY`: required. A global `swarm_config` secret. The API process loads global rows into `process.env` at boot and on config reload. `ctx.swarm.config_get` cannot serve this, because the SDK scrubs every response and a secret comes back as `[REDACTED:<name>]`.
20
+ - `DOKPLOY_BASE_URL`: optional, default `https://app.dokploy.com`. It must be an `https` URL. Anything else, including an unparseable value, sends no request and logs a warning that names the variable and not its value.
21
+
22
+ The key is never written to config, state, logs, or a description.
23
+
24
+ How it decides: it calls `GET /api/deployment.allByCompose?composeId=...`, takes the deployment with the newest `createdAt`, and counts a deploy as in progress when that deployment's `status` is `running`. Dokploy statuses are `running`, `done`, `error`, and `cancelled`.
25
+
26
+ Fail open: a missing key, a non-https `DOKPLOY_BASE_URL`, a Dokploy error, a bad response, or a timeout adds no line, and the task is created as usual. The handler never throws, so an outage cannot auto-disable the extension. A task whose description already carries the note (a resume or a follow-up) is left alone.
27
+
28
+ At most one Dokploy call runs per `cacheTtlMs` window. The cache lives in `ctx.state`, so API replicas share it, and tasks created at the same moment share one in-flight check.
@@ -0,0 +1,152 @@
1
+ import { type CtxFor, modify, type SwarmExtension } from "swarm-extension";
2
+ import { z } from "zod";
3
+
4
+ // The Dokploy URL and API key are deliberately not config. Extension config is writable by a
5
+ // lead, so a key name or a host here would let it point the API process at any env secret and
6
+ // any host. Both come from the API process environment instead (see readApiKey, readBaseUrl).
7
+ export const config = z.object({
8
+ composeId: z.string().min(1),
9
+ label: z.string().min(1).default("prod"),
10
+ cacheTtlMs: z.number().int().min(0).default(120_000),
11
+ // Stays under the 5s handler limit, which also covers the secret read and the cache writes.
12
+ timeoutMs: z.number().int().min(100).max(4_000).default(2_000),
13
+ // A "running" deployment older than this is a stuck record, not a live deploy.
14
+ staleAfterMs: z.number().int().min(60_000).default(1_800_000),
15
+ });
16
+
17
+ const manifest = {
18
+ name: "deploy-awareness",
19
+ description: "Appends a one-line note to new tasks while a Dokploy compose deploy is in progress",
20
+ version: "1.0.0",
21
+ runtime: "api",
22
+ assets: { hooks: "hooks.ts" },
23
+ config,
24
+ } as const;
25
+
26
+ type Ctx = CtxFor<typeof manifest>;
27
+
28
+ type Snapshot = {
29
+ checkedAt: number;
30
+ /** ISO start of the deployment in progress, or null. */
31
+ runningSince: string | null;
32
+ failed?: true;
33
+ };
34
+
35
+ type Deployment = { status?: unknown; createdAt?: unknown; startedAt?: unknown };
36
+
37
+ const API_KEY_ENV = "DOKPLOY_API_KEY";
38
+ const BASE_URL_ENV = "DOKPLOY_BASE_URL";
39
+ const DEFAULT_BASE_URL = "https://app.dokploy.com";
40
+ const CACHE_KEY = "deploy-status";
41
+ // The tail of the note. It does not change with the label or the time, so it marks a task
42
+ // that already carries the note (a resume or a follow-up).
43
+ const ADVICE =
44
+ "your worker may restart in the next few minutes. Checkpoint with store-progress before long steps.";
45
+
46
+ // One check at a time per process, so tasks created together share a single Dokploy call.
47
+ let inflight: Promise<Snapshot> | undefined;
48
+
49
+ function errorText(error: unknown): string {
50
+ return error instanceof Error ? error.message : String(error);
51
+ }
52
+
53
+ // The API process hydrates global swarm_config rows into process.env at boot and on config
54
+ // reload. ctx.swarm.config_get cannot serve this: the SDK scrubs every response, so a secret
55
+ // comes back as "[REDACTED:<name>]".
56
+ function readApiKey(): string {
57
+ const value = process.env[API_KEY_ENV];
58
+ if (!value) throw new Error(`${API_KEY_ENV} is not set in the API process environment`);
59
+ return value;
60
+ }
61
+
62
+ // The key goes out in a request header, so the host must be reached over TLS. The value is not
63
+ // echoed: a URL can carry credentials.
64
+ function readBaseUrl(): string {
65
+ const raw = process.env[BASE_URL_ENV] || DEFAULT_BASE_URL;
66
+ let url: URL;
67
+ try {
68
+ url = new URL(raw);
69
+ } catch {
70
+ throw new Error(`${BASE_URL_ENV} is not a valid URL`);
71
+ }
72
+ if (url.protocol !== "https:") throw new Error(`${BASE_URL_ENV} must be an https URL`);
73
+ return raw.replace(/\/+$/, "");
74
+ }
75
+
76
+ /** The start of the newest deployment when it is still running, else null. */
77
+ function runningSince(deployments: Deployment[], staleAfterMs: number): string | null {
78
+ let latest: { at: number; deployment: Deployment } | undefined;
79
+ for (const deployment of deployments) {
80
+ const at = Date.parse(String(deployment.createdAt));
81
+ // The list is not chronological (compose.one is not), so compare timestamps, not positions.
82
+ if (!Number.isNaN(at) && (!latest || at > latest.at)) latest = { at, deployment };
83
+ }
84
+ if (latest?.deployment.status !== "running") return null;
85
+ const started = Date.parse(String(latest.deployment.startedAt ?? latest.deployment.createdAt));
86
+ const since = Number.isNaN(started) ? latest.at : started;
87
+ return Date.now() - since > staleAfterMs ? null : new Date(since).toISOString();
88
+ }
89
+
90
+ async function fetchRunningSince(ctx: Ctx): Promise<string | null> {
91
+ const apiKey = readApiKey();
92
+ const base = readBaseUrl();
93
+ const response = await fetch(
94
+ `${base}/api/deployment.allByCompose?composeId=${encodeURIComponent(ctx.config.composeId)}`,
95
+ {
96
+ headers: { "x-api-key": apiKey },
97
+ signal: AbortSignal.any([ctx.signal, AbortSignal.timeout(ctx.config.timeoutMs)]),
98
+ },
99
+ );
100
+ if (!response.ok) throw new Error(`Dokploy answered ${response.status}`);
101
+ const body: unknown = await response.json();
102
+ if (!Array.isArray(body)) throw new Error("Dokploy returned no deployment list");
103
+ return runningSince(body as Deployment[], ctx.config.staleAfterMs);
104
+ }
105
+
106
+ async function refresh(ctx: Ctx): Promise<Snapshot> {
107
+ let snapshot: Snapshot;
108
+ try {
109
+ snapshot = { checkedAt: Date.now(), runningSince: await fetchRunningSince(ctx) };
110
+ } catch (error) {
111
+ // Cached like a result, so an outage costs one attempt per window.
112
+ ctx.log.warn(`deploy status check failed, tasks proceed without the note: ${errorText(error)}`);
113
+ snapshot = { checkedAt: Date.now(), runningSince: null, failed: true };
114
+ }
115
+ try {
116
+ await ctx.state.set(CACHE_KEY, snapshot);
117
+ } catch (error) {
118
+ ctx.log.warn(`deploy status cache write failed: ${errorText(error)}`);
119
+ }
120
+ return snapshot;
121
+ }
122
+
123
+ /** Never throws: a throw counts toward auto-disable, and a status check must not block tasks. */
124
+ async function deployStartedAt(ctx: Ctx): Promise<string | null> {
125
+ try {
126
+ const cached = await ctx.state.get<Snapshot>(CACHE_KEY);
127
+ if (cached && Date.now() - cached.checkedAt < ctx.config.cacheTtlMs) {
128
+ return cached.runningSince;
129
+ }
130
+ inflight ??= refresh(ctx).finally(() => {
131
+ inflight = undefined;
132
+ });
133
+ return (await inflight).runningSince;
134
+ } catch (error) {
135
+ ctx.log.warn(`deploy status unavailable, tasks proceed without the note: ${errorText(error)}`);
136
+ return null;
137
+ }
138
+ }
139
+
140
+ const extension: SwarmExtension<typeof manifest> = (api) => {
141
+ api.on("pre.task.create", async (event, ctx) => {
142
+ if (event.description.includes(ADVICE)) return;
143
+ const startedAt = await deployStartedAt(ctx);
144
+ if (!startedAt) return;
145
+ const time = startedAt.slice(11, 16);
146
+ return modify({
147
+ description: `${event.description}\n\nNote: a ${ctx.config.label} deploy started at ${time} UTC is in progress; ${ADVICE}`,
148
+ });
149
+ });
150
+ };
151
+
152
+ export default extension;
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "../manifest.schema.json",
3
+ "name": "deploy-awareness",
4
+ "description": "Appends a one-line note to new tasks while a Dokploy compose deploy is in progress",
5
+ "version": "1.0.0",
6
+ "runtime": "api",
7
+ "assets": { "hooks": "hooks.ts" }
8
+ }
@@ -4,8 +4,8 @@
4
4
  "displayName": "Memory",
5
5
  "slug": "memory",
6
6
  "title": "Memory",
7
- "description": "Remember, recall, learning, memory: how swarm memory works and how to store, search, edit, rate, and delete memories with `memory-store`, `memory-search`, `memory-get`, `memory-edit`, `memory_rate`, and `memory-delete`, plus lead promotion with `inject-learning`. Use before you store, edit, or delete a memory.",
8
- "version": "1.0.0",
7
+ "description": "Remember, recall, learning, memory: how swarm memory works and how to store, search, edit, rate, and delete memories with `memory-store`, `memory-search`, `memory-get`, `memory-edit`, `memory_rate`, and `memory-delete`, plus logical paths (`key`, `newKey`, `keyPrefix`, the `/longterm` roots and the lead-only ones) and lead promotion with `inject-learning`. Use before you store, edit, or delete a memory.",
8
+ "version": "1.1.0",
9
9
  "category": "skills",
10
10
  "placeholders": [],
11
11
  "runAllSeedersCandidate": true,
@@ -18,10 +18,10 @@ Prefer `memory-store` over memory files. It works on every harness, including th
18
18
 
19
19
  | Tool | Use |
20
20
  |---|---|
21
- | `memory-store` | create a memory: `content`, `name`, `scope`, optional `tags`, `taskId`, `intent` |
22
- | `memory-search` | find memories: `query`, `intent` (required, why you search), `scope` (`all`, `agent`, `swarm`), `limit` |
21
+ | `memory-store` | create a memory: `content`, `name`, `scope`, optional `tags`, `taskId`, `intent`, `key` (a logical path, see Logical paths) |
22
+ | `memory-search` | find memories: `query`, `scope` (`all`, `agent`, `swarm`), `limit`, optional `intent` (why you search), `source`, `keyPrefix` (only memories whose key starts with it) |
23
23
  | `memory-get` | the full content of one memory by ID |
24
- | `memory-edit` | change a memory in place: mode `replace` (whole content) or `exact` (one unique substring), `intent` required |
24
+ | `memory-edit` | change a memory in place: mode `replace` (whole content) or `exact` (one unique substring), `intent` required. `newKey` alone moves it to another logical path |
25
25
  | `memory-delete` | remove a memory by ID |
26
26
  | `memory_rate` | mark a memory you used in this task as useful or misleading |
27
27
  | `inject-learning` | lead only: push a learning into a worker's memory at swarm scope |
@@ -49,11 +49,65 @@ A memory must not contain a token, password, key, or connection string. Remove t
49
49
  - `agent` (default): only you recall it. Your own setup, your working notes, your mistakes.
50
50
  - `swarm`: every agent recalls it. Facts about shared repos, hosts, people, and processes. Choose `swarm` when a second agent would hit the same thing.
51
51
 
52
+ ## Logical paths (`key`)
53
+
54
+ Every memory has a `key`. By default it is an auto key (`<scope>/<source>/<id>`, or the file path for `file_index`), and the memory is **inbox material**: it keeps the lifecycle of its `source` and expires. Give it a path under `/longterm` and it becomes curated memory: findable by folder, ranked higher, and kept.
55
+
56
+ `name` is a title. `key` is the address. Use a key only for what should outlive the task: a durable fact, a decision, a person or customer. Leave working notes and task results without one; expiring is the right outcome for them.
57
+
58
+ ### The `/longterm` roots
59
+
60
+ The list is closed. A key under `/longterm` whose second segment is not in it is refused, and the error lists the roots.
61
+
62
+ | Root | Holds | Rank weight | Who may write |
63
+ |---|---|---|---|
64
+ | `/longterm/company-story` | what the company is and does | 1.4 | lead only |
65
+ | `/longterm/entities/people/<slug>`, `/longterm/entities/customers/<slug>` | one doc per person or customer | 1.3 | lead only |
66
+ | `/longterm/facts/<topic>/<slug>` | a durable fact about a repo, host, tool, or process | 1.2 | any agent |
67
+ | `/longterm/decisions/<slug>` | a decision and why | 1.1 (0.3 with the tag `superseded`) | any agent |
68
+ | `/longterm/workstreams/<slug>` | an ongoing effort | 1.0 | any agent |
69
+ | `/longterm/timeline/<period>/<slug>` | dated events | 0.8 | lead only |
70
+
71
+ Agents and repos are not entity types: agent profiles and `get-repos` own them, so `/longterm/entities/agents/...` is refused.
72
+
73
+ Key shape: lowercase letters, digits, `-`, and `.` or `_` after the first segment; segments joined by `/`; starts with `/`; no trailing `/`; at most 200 characters. A key outside `/longterm` is not root-checked but must still have this shape.
74
+
75
+ ### Write, move, find
76
+
77
+ ```
78
+ memory-store key="/longterm/facts/swarm-runtime/sqlite-busy-retry" scope="swarm"
79
+ name="SQLite BUSY_SNAPSHOT needs BEGIN IMMEDIATE" content="..."
80
+
81
+ memory-edit memoryId="<id>" newKey="/longterm/decisions/sqlite-busy-retry" intent="promote the fact to a decision"
82
+
83
+ memory-search query="busy retry" keyPrefix="/longterm/facts/swarm-runtime/"
84
+ ```
85
+
86
+ - `memory-store`: one key per owner and scope. A second memory under a key you already use fails: `memory-edit` that one. If you pass no `key` and the `name` starts with `/longterm/`, the name is the key, so you set one field. An invalid name of that form is refused, never stored under an auto key.
87
+ - `memory-edit` `newKey`: pass it alone for a pure move. Every chunk of the document moves in one step. The ID, usefulness rating, access counts, and author stay. A key that is already taken is refused. Address the memory with `memoryId`, or with `key` plus `scope`.
88
+ - `memory-search` `keyPrefix`: a literal, case-sensitive prefix, applied before the top results are cut, not after. End a folder with `/` (`/longterm/entities/`, not `/longterm/entities`) to stay inside it.
89
+
90
+ ### What a `/longterm` key changes
91
+
92
+ `source` stays provenance: there is no `longterm` source. The key is the tier. A memory under `/longterm` follows a `manual` memory's lifecycle whatever its `source`:
93
+
94
+ - It never expires. Storing under a `/longterm` key sets no expiry. Moving a memory in with `newKey` clears the expiry it had, on every chunk. Moving it back out does not restore one.
95
+ - It has no recency decay, and its source-quality multiplier is 1.5.
96
+ - Automated cleanup skips it.
97
+
98
+ A memory under any other key keeps its `source` lifecycle: `task_completion` expires after 7 days, `session_summary` after 3, `file_index` after 30, `manual` never.
99
+
100
+ Ranking multiplies similarity by recency decay, access boost, source quality, **path weight** (the table above, by longest matching root; any other key weighs 1.0), and usefulness. Path weight is one factor: a weak match under `/longterm/company-story` does not beat a strong match elsewhere on weight alone.
101
+
102
+ ### Lead-only roots
103
+
104
+ Only the lead may write or move a key under `/longterm/company-story`, `/longterm/entities`, or `/longterm/timeline`. The check is the permission `memory.write.consolidated`. It applies to a `key`, to a `newKey`, to a `/longterm/` name, and to a `sourcePath` sent to `POST /api/memory/index`, so there is no side door. A worker that tries gets an error naming the lead-only paths. A worker puts durable knowledge under `/longterm/facts` or `/longterm/decisions`, or leaves the key off, and the lead consolidates the rest.
105
+
52
106
  ## Before you store
53
107
 
54
108
  1. Run `memory-dedup-check` with the text, or `memory-search` with one or two queries and `intent: "dedup before store"`.
55
109
  2. A near-duplicate exists: `memory-edit` it. Mode `replace` for a rewrite, mode `exact` for a one-line correction. Say why in `intent`.
56
- 3. Nothing close exists: `memory-store`.
110
+ 3. Nothing close exists: `memory-store`. For a keyed memory, `memory-search` with `keyPrefix` set to the folder you will write into shows what is already there.
57
111
 
58
112
  ## Triage
59
113
 
@@ -63,4 +117,4 @@ A memory must not contain a token, password, key, or connection string. Remove t
63
117
 
64
118
  ## Lead: promote a learning
65
119
 
66
- When a worker's output or failure holds a lesson other workers need, call `inject-learning` with the worker's `agentId`, the `learning`, and a `category`: `mistake-pattern`, `best-practice`, `codebase-knowledge`, or `preference`. It lands at swarm scope and every agent recalls it.
120
+ When a worker's output or failure holds a lesson other workers need, call `inject-learning` with the worker's `agentId`, the `learning`, and a `category`: `mistake-pattern`, `best-practice`, `codebase-knowledge`, or `preference`. It lands at swarm scope and every agent recalls it. It is stored as `manual`, so it never expires, but it takes no key: it has no path weight and `keyPrefix` does not find it. To file a learning by path, `memory-store` it with a `/longterm` key, or `memory-edit` it with `newKey`.
@@ -4,7 +4,7 @@
4
4
  "displayName": "Swarm Extensions",
5
5
  "slug": "swarm-extensions",
6
6
  "title": "Swarm Extensions",
7
- "description": "Write, install, and manage swarm extensions: TypeScript hook bundles that block, modify, or observe task creation, follow-ups, Slack routing, heartbeat remediation, and tool calls. Covers catalog-only install of predefined extensions (templates/extensions, YAML or JSON manifests) and the scripts, schedules, workflows and skills they ship, the hook contract, where to fetch swarm-extension.d.ts, the extension-catalog, extension-install and extension-list tools, config schemas, and the operator enable step.",
7
+ "description": "Write, install, and manage swarm extensions: TypeScript hook bundles that block, modify, or observe task creation, follow-ups, Slack routing, heartbeat remediation, and tool calls. Covers installing predefined catalog extensions (templates/extensions, YAML or JSON manifests) by name and, when EXTENSION_ALLOW_INLINE_INSTALL is on, installing an inline manifest plus files as a lead, plus the scripts, schedules, workflows and skills extensions ship, the hook contract, where to fetch swarm-extension.d.ts, the extension-catalog, extension-install and extension-list tools, config schemas, and the operator enable step.",
8
8
  "version": "1.0.0",
9
9
  "category": "skills",
10
10
  "placeholders": [],
@@ -4,15 +4,18 @@ An extension is a trusted TypeScript hook bundle that runs inside the swarm API
4
4
 
5
5
  Do not use an extension for work that one task, one script, or one schedule can do.
6
6
 
7
- ## Install only from the catalog
7
+ ## Two ways to install
8
8
 
9
- Extensions install only from the predefined catalog in the repo (`templates/extensions/<name>/`). Inline bundles are rejected with `inline_install_disabled`. To ship a new extension, open a PR that adds a template directory (see Bundle shape below); it becomes installable once that build is deployed.
9
+ - **Catalog** (always on): a predefined extension in the repo (`templates/extensions/<name>/`), installed by name. Any authenticated agent can do it. To ship a catalog extension, open a PR that adds a template directory (see Bundle shape below); it becomes installable once that build is deployed.
10
+ - **Inline** (opt-in): a `manifest` plus a `files` map in the install request, with no PR and no deploy. It is off unless an operator sets `EXTENSION_ALLOW_INLINE_INSTALL=true` (dashboard Settings > Configuration > Security & access, or the API environment). With the flag off the install fails with `inline_install_disabled`. With it on, only a lead, operator, or dashboard user may send an inline bundle; a worker gets 403 and stays catalog-only. An inline bundle runs as code in the API process once enabled, so write it as carefully as a catalog one.
11
+
12
+ Both paths run the same validation and both land disabled.
10
13
 
11
14
  ## Tools
12
15
 
13
16
  `extension-catalog`, `extension-install` and `extension-list`. They are deferred. Load them with your harness tool search before the first call.
14
17
 
15
- `extension-catalog` lists the predefined extensions, the assets each declares, and whether it is installed. `extension-install` takes `{ template: "<name>" }` (plus optional `priority` and `config`), validates the bundle (manifest, imports, typecheck against the hook contract, script typecheck) and stores it. Any authenticated agent, including a worker, can install. Your agent is recorded as its owner in `createdByAgentId`; `extension-list` exposes that field. Always send your `X-Agent-ID` when using REST so ownership is attributed to you.
18
+ `extension-catalog` lists the predefined extensions, the assets each declares, and whether it is installed. `extension-install` takes `{ template: "<name>" }` or, for an inline bundle, `{ manifest, files }` (plus optional `priority` and `config`). `template` and `manifest`/`files` are mutually exclusive. It validates the bundle (manifest, imports, typecheck against the hook contract, script typecheck) and stores it. Any authenticated agent, including a worker, can install a catalog template. Your agent is recorded as its owner in `createdByAgentId`; `extension-list` exposes that field. Always send your `X-Agent-ID` when using REST so ownership is attributed to you.
16
19
 
17
20
  Install also creates the `ext:<name>` agent and every asset the extension declares. Scripts are live and callable right away (scripts have no enabled state). Schedules, workflows, and skills are created disabled. A disabled workflow ignores its triggers and refuses manual triggers.
18
21
 
@@ -22,7 +25,7 @@ Workers may install subsequent versions only for their own extensions, and PATCH
22
25
 
23
26
  A new install is disabled and inert. A lead, operator, or dashboard user must enable it with `extension-enable` or `POST /api/extensions/{id}/enable`. Enabling turns its schedules, workflows, and skills on; disabling turns them off and remembers which ones you had turned off. Workers cannot enable, disable, or activate versions. Report the extension name and the required activation step.
24
27
 
25
- Installing a catalog template whose content changed stages a new version without activating it. Workers may stage updates while an extension is enabled, but cannot PATCH or change its live config/priority. Ask a lead or operator to make those changes. `EXTENSION_ALLOW_LEAD_ACTIVATION=false` restricts activation to operators/dashboard users.
28
+ Installing a template or inline bundle whose content changed stages a new version without activating it. An operator or dashboard user reinstalling an enabled extension activates the new version immediately; a lead never does. Workers may stage updates while an extension is enabled, but cannot PATCH or change its live config/priority. Ask a lead or operator to make those changes. `EXTENSION_ALLOW_LEAD_ACTIVATION=false` restricts activation to operators/dashboard users.
26
29
 
27
30
  Uninstall (`extension-delete`, disabled extensions only) deletes the assets you never edited and detaches the ones you did, so your edits survive.
28
31
 
@@ -82,6 +85,25 @@ A workflow file holds `name`, optional `description`, `definition`, and optional
82
85
 
83
86
  A JSON manifest carries `"$schema": "../manifest.schema.json"` instead. After changing a template, run `bun run build:extension-catalog` and commit `src/extensions/catalog.generated.json`.
84
87
 
88
+ ### Inline bundle
89
+
90
+ An inline install sends the same manifest as a JSON object, plus every file it references in `files`, keyed by bundle path:
91
+
92
+ ```json
93
+ {
94
+ "manifest": {
95
+ "name": "require-ticket-ref",
96
+ "description": "Blocks REST and MCP tasks that do not name a ticket",
97
+ "version": "1.0.0",
98
+ "runtime": "api",
99
+ "assets": { "hooks": "hooks.ts" }
100
+ },
101
+ "files": { "hooks.ts": "import { block, type SwarmExtension } from \"swarm-extension\";\n..." }
102
+ }
103
+ ```
104
+
105
+ `files` must hold `assets.hooks`, each script `file`, each workflow `file`, and for each skill `dir` its `SKILL.md` plus any `files/**`. A file the manifest does not reference is rejected. Naming rules (`<name>-` prefixes, schedule scripts declared in `assets.scripts`) are the same as for a template. To change an inline extension, send the full bundle again under the same name; it adds a new version.
106
+
85
107
  Rules for `hooks.ts`:
86
108
 
87
109
  - Import only from `swarm-extension`, `zod`, and `stdlib`. Relative imports, other packages, and dynamic imports are rejected.
@@ -145,5 +167,6 @@ export default extension;
145
167
  - Modifying fields the event does not allow. Read the `*Modify` type for that event.
146
168
  - Expecting the extension to run after install. Its hooks, schedules, workflows, and skills are off until a lead or operator enables it.
147
169
  - Expecting agents to see an extension skill after enable. Install it on each agent with `skill-install`.
148
- - Sending an inline `manifest`/`files` bundle. Install takes a catalog `template` name only.
170
+ - Sending an inline `manifest`/`files` bundle as a worker, or without `EXTENSION_ALLOW_INLINE_INSTALL` on. Workers use a catalog `template`; with the flag off ask an operator to turn it on, or ship a catalog template.
171
+ - Sending both `template` and `manifest`/`files`. Pick one.
149
172
  - Blocking tasks from every origin. Check `event.origin` so schedules, workflows, and follow-ups keep working unless you mean to block them.
package/tsconfig.json CHANGED
@@ -47,6 +47,9 @@
47
47
  "docs-site",
48
48
  "assets/video-source",
49
49
  "mockups",
50
+ // Claude Code mod: built against the `claude-code` types the engine lays
51
+ // beside it; checked with `claude plugin validate` and `bun run test:claude-mod`.
52
+ "claude-mod",
50
53
  // Bundled skill assets shipped verbatim to agents. Their imports describe
51
54
  // what an agent writes in /workspace, not this repo's layout, so they are
52
55
  // deliberately not typechecked here.