@desplega.ai/agent-swarm 2.7.9 → 2.8.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 (355) hide show
  1. package/dist/acp-adapter-t949vbbp.js +15 -0
  2. package/dist/{actions-g563mbn2.js → actions-7e9czc7s.js} +19 -19
  3. package/dist/{amp-adapter-q61w05eb.js → amp-adapter-gv6cbb7d.js} +2 -3
  4. package/dist/app-b9fbkp9v.js +20 -0
  5. package/dist/{assistant-p477rjwj.js → assistant-wjb7v4c7.js} +22 -22
  6. package/dist/{boot-args-schema-h4qj462e.js → boot-args-schema-2t37e0fe.js} +1 -1
  7. package/dist/{boot-reembed-n1ehfbsw.js → boot-reembed-a35nkyr1.js} +1 -1
  8. package/dist/{boot-reembed-qw4mc0pt.js → boot-reembed-gka3zas7.js} +1 -1
  9. package/dist/{boot-scrub-sweep-9w9jp4sm.js → boot-scrub-sweep-65sdnp6c.js} +3 -3
  10. package/dist/{boot-seeds-qdaf3sdy.js → boot-seeds-x42tzytw.js} +4 -5
  11. package/dist/{claude-adapter-348p5hx9.js → claude-adapter-v221b2fd.js} +7 -8
  12. package/dist/{claude-managed-adapter-h74d06yz.js → claude-managed-adapter-29eq09wd.js} +2 -2
  13. package/dist/{claude-managed-setup-7787fxtp.js → claude-managed-setup-9m6450zk.js} +2 -2
  14. package/dist/{claude-sdk-session-hbszbt8a.js → claude-sdk-session-0q0ptaba.js} +9066 -8818
  15. package/dist/{cli-n5yexkdg.js → cli-0b4zam62.js} +1 -0
  16. package/dist/{cli-21159vea.js → cli-0jzra9ad.js} +2 -2
  17. package/dist/{cli-eqtfgfr6.js → cli-2gxeg5gr.js} +1 -1
  18. package/dist/{cli-k70e3x9e.js → cli-2wnq8jkz.js} +9 -9
  19. package/dist/{cli-cvs2r2vq.js → cli-2zp0et3v.js} +59 -6
  20. package/dist/{cli-650zv9q9.js → cli-334z18y3.js} +4 -4
  21. package/dist/{cli-12xyjhws.js → cli-3rkdne1h.js} +2 -2
  22. package/dist/{cli-2a8py3sx.js → cli-4txa0ter.js} +5 -7
  23. package/dist/{cli-jc1g9ndz.js → cli-5j88qqa8.js} +10 -5
  24. package/dist/{cli-xfjrc279.js → cli-5mrq3ake.js} +48 -14
  25. package/dist/{cli-v3cf1ts9.js → cli-6t09sdhy.js} +3 -3
  26. package/dist/{cli-qzt90yze.js → cli-6wxjceza.js} +8 -8
  27. package/dist/{cli-9aezs55w.js → cli-7b8sbmag.js} +8 -8
  28. package/dist/{cli-3xj33nrx.js → cli-7cp6aa1q.js} +10 -3
  29. package/dist/{cli-jfx48xrj.js → cli-7p1kvkck.js} +6 -6
  30. package/dist/{cli-b932gexn.js → cli-8aes17e4.js} +2 -2
  31. package/dist/{cli-3tqcamp6.js → cli-8fknbnhw.js} +14 -13
  32. package/dist/{cli-587857ys.js → cli-8kzasymh.js} +3 -3
  33. package/dist/{cli-sgs5k6yd.js → cli-a7wvp2km.js} +1 -1
  34. package/dist/{cli-varqt4d1.js → cli-abejgen1.js} +69 -22
  35. package/dist/{cli-rwymrnaz.js → cli-bsywb58a.js} +8 -8
  36. package/dist/{cli-btc9cb4c.js → cli-c55z5chy.js} +4 -6
  37. package/dist/{cli-ms5m5r1y.js → cli-deefvewm.js} +1 -1
  38. package/dist/{cli-p17970qv.js → cli-ee0b971j.js} +3 -3
  39. package/dist/cli-f3vq58d2.js +242 -0
  40. package/dist/{cli-3xcwp3z8.js → cli-ffhtssbp.js} +2 -2
  41. package/dist/{cli-hwprv9e4.js → cli-g70vxtjh.js} +2 -2
  42. package/dist/{cli-4t0fmf3z.js → cli-gxkx0zzp.js} +1 -1
  43. package/dist/{cli-neyag5p6.js → cli-h38x262p.js} +3365 -429
  44. package/dist/{cli-2ccpqyyf.js → cli-j790gp2w.js} +105 -22
  45. package/dist/{cli-f2zenhja.js → cli-kc7v1nfv.js} +1 -1
  46. package/dist/{cli-vxh6acp7.js → cli-m23zjcy2.js} +10 -10
  47. package/dist/{cli-y8nbefpb.js → cli-m28atx8q.js} +12 -10
  48. package/dist/{cli-serm8zrx.js → cli-m4dqmnbp.js} +1 -1
  49. package/dist/{cli-ybjdc978.js → cli-mrt48bx7.js} +7 -4
  50. package/dist/{cli-y5rbvxhc.js → cli-n515ex5z.js} +14 -14
  51. package/dist/{cli-ypff1qwp.js → cli-n9ftpys4.js} +7 -7
  52. package/dist/{cli-605nn699.js → cli-p1bq50aa.js} +894 -226
  53. package/dist/{cli-qkdmz8c8.js → cli-p1w18yhx.js} +1 -1
  54. package/dist/{cli-xk879m3k.js → cli-p2gfst4m.js} +52 -43
  55. package/dist/{cli-sya22y84.js → cli-pasjcnmj.js} +12 -12
  56. package/dist/{cli-0whpms1z.js → cli-qa4wdgsy.js} +5 -5
  57. package/dist/{cli-ejkvvqbe.js → cli-qfedvmcr.js} +50 -24
  58. package/dist/{cli-tqq0hspb.js → cli-qmqk2yc2.js} +1 -1
  59. package/dist/{cli-qmd3mse0.js → cli-qsnnd04k.js} +1 -1
  60. package/dist/{cli-agyaeef4.js → cli-qwca7s44.js} +3 -3
  61. package/dist/{cli-fayav105.js → cli-rfywm85n.js} +724 -792
  62. package/dist/{cli-zgv8gxgs.js → cli-rmmpt0wm.js} +6 -6
  63. package/dist/{cli-hae9j8sv.js → cli-rzsy6nc6.js} +12 -8
  64. package/dist/{cli-btf6fw39.js → cli-s7t6p9my.js} +1 -1
  65. package/dist/{cli-cseh6f8w.js → cli-sdtt3men.js} +1 -1
  66. package/dist/{cli-9r5gtwjr.js → cli-tk7cjj8h.js} +197 -2
  67. package/dist/{cli-q26b9wre.js → cli-tph5wt3y.js} +4 -4
  68. package/dist/{cli-gce09r66.js → cli-tqegb8eq.js} +3 -3
  69. package/dist/{cli-kf3pxxdg.js → cli-v1dv1r37.js} +1 -1
  70. package/dist/{cli-09kmfkmq.js → cli-wcg8x116.js} +1 -1
  71. package/dist/{cli-mnrkgg60.js → cli-wk18cm92.js} +5 -5
  72. package/dist/{cli-p0m0p34z.js → cli-x1wa213s.js} +3 -3
  73. package/dist/{cli-jrp1dt73.js → cli-xzm9vcfg.js} +1 -1
  74. package/dist/{cli-715t1gx6.js → cli-y97qxcfx.js} +9 -9
  75. package/dist/{cli-bc779n4v.js → cli-yq3zak69.js} +1 -1
  76. package/dist/cli.js +17 -17
  77. package/dist/{codex-adapter-ysq6bzha.js → codex-adapter-30j9bpzd.js} +5 -6
  78. package/dist/{codex-hook-fac6175r.js → codex-hook-h3vk6xzr.js} +1 -1
  79. package/dist/{codex-session-runner-qakzfx93.js → codex-session-runner-8vp57v8w.js} +5 -6
  80. package/dist/{commands-rs7hkv9r.js → commands-bngnz9g7.js} +3 -3
  81. package/dist/{controller-r5x9bg6e.js → controller-hxx8wwy1.js} +2 -2
  82. package/dist/{controllers-connect-498hrxvk.js → controllers-connect-e2b4gyxc.js} +20 -20
  83. package/dist/{cursor-adapter-d46qszer.js → cursor-adapter-n5nc3mfe.js} +1 -2
  84. package/dist/{db-s13dqhr6.js → db-bgm7vkc0.js} +3 -3
  85. package/dist/{db-pm96nhdb.js → db-c6np41ca.js} +12 -2
  86. package/dist/{devin-adapter-z46ep5ph.js → devin-adapter-xedz98zv.js} +1 -1
  87. package/dist/{dispatcher-j3h81t7m.js → dispatcher-jnybck15.js} +18 -18
  88. package/dist/{dsh-adapter-rw0d5rc4.js → dsh-adapter-nrhbrjz8.js} +1 -2
  89. package/dist/{easter-egg-3d-qtgfxgze.js → easter-egg-3d-533knw22.js} +1 -1
  90. package/dist/{embedding-space-xh8p4q4x.js → embedding-space-crsm2zp0.js} +6 -6
  91. package/dist/{embeddings-wp745m91.js → embeddings-e7z3f27f.js} +1 -1
  92. package/dist/{execute-2fzb9z74.js → execute-b3mrb1mv.js} +1 -1
  93. package/dist/{external-channel-ys21h3sy.js → external-channel-m77wf5z3.js} +2 -2
  94. package/dist/{fx-adapter-vz0b9z3g.js → fx-adapter-b6w0kf56.js} +7 -8
  95. package/dist/{google-generative-ai-ytpgncx9.js → google-generative-ai-h7s3e9kk.js} +1 -1
  96. package/dist/{google-vertex-tqhze5j7.js → google-vertex-fhxaafzw.js} +1 -1
  97. package/dist/{grok-adapter-spea7zkj.js → grok-adapter-4sqtebdk.js} +7 -8
  98. package/dist/handlers-kdjcyzdj.js +32 -0
  99. package/dist/heartbeat-xgb036sx.js +43 -0
  100. package/dist/{hook-amcj4s10.js → hook-5h02c9ga.js} +6 -6
  101. package/dist/{hook-bc6n49qn.js → hook-xsk1jbha.js} +5 -5
  102. package/dist/{http-7374brv5.js → http-txe7qhvn.js} +448 -165
  103. package/dist/{index-pxn30mse.js → index-0eny15vj.js} +8 -8
  104. package/dist/{index-5a9jtqde.js → index-0rvk3vd4.js} +46 -46
  105. package/dist/{index-fvzke5kx.js → index-1qw6f2dc.js} +10 -10
  106. package/dist/{index-q5cmtbz5.js → index-4a0670yh.js} +15939 -14244
  107. package/dist/index-835xdgnm.js +33 -0
  108. package/dist/index-d469300x.js +37 -0
  109. package/dist/{index-h7f61sy9.js → index-e5pfbsys.js} +3 -3
  110. package/dist/{index-hsad2t3r.js → index-m5gx1xd6.js} +38 -38
  111. package/dist/{index-5fx3b3kw.js → index-rvccek1w.js} +9 -9
  112. package/dist/index-rzqwp11g.js +32 -0
  113. package/dist/{index-w4m9z29z.js → index-tvfafeyy.js} +1 -1
  114. package/dist/{index-c9y31ytf.js → index-vk63emp7.js} +979 -35
  115. package/dist/{index-514d9pf6.js → index-w7em4ktq.js} +8 -8
  116. package/dist/{index-p4hjwbvw.js → index-ysvbhg5m.js} +1 -1
  117. package/dist/{keepalive-wy29kbrg.js → keepalive-4zsrce78.js} +3 -3
  118. package/dist/lead-yqt47dkr.js +70 -0
  119. package/dist/{maintenance-h2ds9w6c.js → maintenance-86jvartk.js} +1 -1
  120. package/dist/{oauth-refresh-sweep-q7mtbyp3.js → oauth-refresh-sweep-j52kg9pr.js} +2 -2
  121. package/dist/{onboard-vw8r2fdw.js → onboard-c2aj5p8q.js} +3 -3
  122. package/dist/{opencode-adapter-mtb0953j.js → opencode-adapter-dsagkhtw.js} +5 -6
  123. package/dist/{otel-impl-j42czw3r.js → otel-impl-yyy203z8.js} +1 -1
  124. package/dist/{pi-mono-adapter-zk8pg9jr.js → pi-mono-adapter-546cd1cc.js} +9 -9
  125. package/dist/{pricing-refresh-x7nhv23d.js → pricing-refresh-1rgzqyzz.js} +2 -3
  126. package/dist/{rbac-roles-9044425x.js → rbac-roles-e70xfeyj.js} +4 -6
  127. package/dist/{rbac-roles-bzvee6cf.js → rbac-roles-q89qe8er.js} +3 -3
  128. package/dist/{registry-hpjfmcfz.js → registry-32b1mft6.js} +1 -1
  129. package/dist/{render-v2-t7bn4skz.js → render-v2-k6tt107q.js} +9 -4
  130. package/dist/{resume-x94gemep.js → resume-cnnrjfxa.js} +6 -6
  131. package/dist/{runtime-breq6fmv.js → runtime-1hv06jsn.js} +1 -1
  132. package/dist/{session-access-q7dmqjvt.js → session-access-xkxkjw3n.js} +4 -4
  133. package/dist/{session-source-backfill-440ysamr.js → session-source-backfill-1d5pdwww.js} +2 -2
  134. package/dist/{setup-07n4727s.js → setup-se8q7gkc.js} +1 -1
  135. package/dist/{virtual-modules-z5h6mcyf.js → virtual-modules-gazyapte.js} +3 -3
  136. package/dist/{work-objects-pnq5y534.js → work-objects-1kxnbzy5.js} +22 -22
  137. package/dist/{worker-follow-up-7z1gfkr8.js → worker-follow-up-zqm8apt4.js} +18 -18
  138. package/dist/worker-j6xxtq7p.js +70 -0
  139. package/openapi.json +334 -7
  140. package/package.json +4 -4
  141. package/src/apps/catalog.generated.json +55 -0
  142. package/src/apps/definition.ts +11 -0
  143. package/src/apps/page-validator.ts +19 -0
  144. package/src/apps/store.ts +28 -8
  145. package/src/assets/key.ts +77 -4
  146. package/src/be/db/model-profiles.ts +147 -38
  147. package/src/be/db/session-labels.ts +57 -0
  148. package/src/be/db/session-tree.ts +51 -7
  149. package/src/be/db/slack-trees.ts +146 -0
  150. package/src/be/db/tasks/read.ts +107 -8
  151. package/src/be/db/workflow-run-definitions.ts +117 -0
  152. package/src/be/db-client.ts +8 -2
  153. package/src/be/db.ts +119 -87
  154. package/src/be/event-loop-lag.ts +146 -0
  155. package/src/be/mcp-overflow-sweep.ts +2 -1
  156. package/src/be/memory/constants.ts +14 -1
  157. package/src/be/memory/key-paths.ts +8 -0
  158. package/src/be/memory/providers/sqlite-store.ts +199 -18
  159. package/src/be/memory/task-learning.ts +79 -14
  160. package/src/be/memory/types.ts +24 -1
  161. package/src/be/migrations/278_slack_render_v2_reconcile.sql +108 -0
  162. package/src/be/migrations/279_backfill_learning_expiry.sql +15 -0
  163. package/src/be/migrations/281_model_profiles_pr2.sql +28 -0
  164. package/src/be/migrations/283_workflow_run_definitions.sql +14 -0
  165. package/src/be/model-profile-check.ts +284 -0
  166. package/src/be/model-tier-resolution.ts +112 -12
  167. package/src/be/multi-runtime.ts +27 -0
  168. package/src/be/runtime-pools/routing.ts +52 -4
  169. package/src/be/scripts/typecheck.ts +1 -0
  170. package/src/be/seed-scripts/catalog/dreaming-learnings.ts +552 -0
  171. package/src/be/seed-scripts/catalog/dreaming-memtax-create.ts +389 -14
  172. package/src/be/seed-scripts/catalog/dreaming-memtax.ts +6 -3
  173. package/src/be/seed-scripts/index.ts +9 -0
  174. package/src/be/steering.ts +8 -2
  175. package/src/be/swarm-config-guard.ts +2 -0
  176. package/src/commands/context-preamble.ts +258 -0
  177. package/src/commands/onboard/agent-fs-version.ts +1 -1
  178. package/src/commands/runner.ts +32 -1
  179. package/src/extensions/catalog.generated.json +3 -3
  180. package/src/fs/provider.ts +17 -3
  181. package/src/heartbeat/heartbeat.ts +17 -5
  182. package/src/heartbeat/index.ts +1 -0
  183. package/src/http/agents.ts +56 -4
  184. package/src/http/apps.ts +3 -1
  185. package/src/http/config.ts +2 -6
  186. package/src/http/core.ts +9 -3
  187. package/src/http/index.ts +12 -9
  188. package/src/http/memory.ts +9 -4
  189. package/src/http/model-profiles.ts +58 -10
  190. package/src/http/poll.ts +36 -3
  191. package/src/http/schedules.ts +42 -3
  192. package/src/http/sessions.ts +16 -3
  193. package/src/http/tasks.ts +37 -12
  194. package/src/http/utils.ts +18 -0
  195. package/src/http/webhooks.ts +48 -0
  196. package/src/http/workflows.ts +15 -2
  197. package/src/integrations/chat-sdk/commands.ts +167 -31
  198. package/src/integrations/chat-sdk/inbound.ts +10 -8
  199. package/src/integrations/chat-sdk/message-text.ts +117 -0
  200. package/src/prompts/session-templates.ts +1 -1
  201. package/src/providers/acp-targets.ts +11 -6
  202. package/src/providers/amp-adapter.ts +1 -1
  203. package/src/providers/claude-sdk-session.ts +132 -23
  204. package/src/providers/codex-skill-resolver.ts +10 -4
  205. package/src/providers/cursor-adapter.ts +1 -1
  206. package/src/providers/devin-skill-resolver.ts +5 -5
  207. package/src/providers/dsh-adapter.ts +1 -1
  208. package/src/scheduler/schedule-task.ts +1 -0
  209. package/src/scheduler/scheduler.ts +4 -1
  210. package/src/scripts-runtime/executors/quickjs-runner.ts +2 -0
  211. package/src/scripts-runtime/executors/quickjs-structured-clone.ts +180 -0
  212. package/src/scripts-runtime/quickjs-compat.ts +0 -1
  213. package/src/scripts-runtime/sdk-allowlist.ts +1 -0
  214. package/src/scripts-runtime/swarm-sdk.ts +18 -1
  215. package/src/scripts-runtime/types/stdlib.d.ts +1 -0
  216. package/src/scripts-runtime/types/swarm-sdk.d.ts +1 -0
  217. package/src/server.ts +2 -0
  218. package/src/slack/app.ts +425 -10
  219. package/src/slack/handlers.ts +9 -2
  220. package/src/slack/inbound-dispatch.ts +18 -1
  221. package/src/slack/index.ts +7 -1
  222. package/src/slack/lifecycle-lock.ts +29 -0
  223. package/src/slack/render-v2.ts +424 -212
  224. package/src/slack/socket-fence.ts +64 -0
  225. package/src/slack/watcher.ts +42 -8
  226. package/src/slack/workspace-guard.ts +345 -0
  227. package/src/tasks/task-terminal-effects.ts +4 -0
  228. package/src/tasks/worker-follow-up.ts +102 -2
  229. package/src/tests/acp-adapter.test.ts +82 -0
  230. package/src/tests/apps-icon.test.ts +120 -0
  231. package/src/tests/apps-schema-form.test.ts +151 -0
  232. package/src/tests/chained-task-follow-up.test.ts +248 -0
  233. package/src/tests/chat-sdk-commands.test.ts +359 -2
  234. package/src/tests/chat-sdk-inbound.test.ts +20 -0
  235. package/src/tests/chat-sdk-slack.test.ts +189 -1
  236. package/src/tests/check-pr-body.test.ts +40 -0
  237. package/src/tests/claude-sdk-lifecycle.test.ts +216 -1
  238. package/src/tests/claude-sdk-process.fixture.ts +57 -0
  239. package/src/tests/codex-skill-resolver.test.ts +31 -0
  240. package/src/tests/credentials-allowlist.test.ts +470 -0
  241. package/src/tests/db-client-busy-retry.test.ts +69 -18
  242. package/src/tests/db-client.test.ts +26 -1
  243. package/src/tests/db-task-read-contract.test.ts +7 -0
  244. package/src/tests/db-task-write-contract.test.ts +6 -0
  245. package/src/tests/deferred-wake-follow-up.test.ts +47 -0
  246. package/src/tests/docs-index-footprint.test.js +3 -3
  247. package/src/tests/dreaming-learnings.test.ts +1395 -0
  248. package/src/tests/dsh-adapter.test.ts +1 -1
  249. package/src/tests/event-loop-lag.test.ts +184 -0
  250. package/src/tests/explicit-model-validation.test.ts +2 -0
  251. package/src/tests/extensions-example-comms-adherence-gate.test.ts +115 -0
  252. package/src/tests/fs-provider.test.ts +42 -0
  253. package/src/tests/github-webhook-early-ack.test.ts +144 -0
  254. package/src/tests/heartbeat.test.ts +28 -1
  255. package/src/tests/http-api-integration.test.ts +2 -0
  256. package/src/tests/http-log-scrubbing.test.ts +68 -2
  257. package/src/tests/human-free-reclassify.test.ts +5 -1
  258. package/src/tests/kv-storage.test.ts +92 -1
  259. package/src/tests/list-endpoint-slimming.test.ts +17 -0
  260. package/src/tests/memory-key-paths.test.ts +57 -0
  261. package/src/tests/memory-retrieval-purge.test.ts +19 -0
  262. package/src/tests/migration-283-workflow-run-definitions.test.ts +69 -0
  263. package/src/tests/model-profile-check.test.ts +387 -0
  264. package/src/tests/model-profiles-api.test.ts +528 -1
  265. package/src/tests/profile-claim.test.ts +415 -3
  266. package/src/tests/profile-tier-alias.test.ts +382 -0
  267. package/src/tests/quickjs-compat.test.ts +1 -1
  268. package/src/tests/runner-context-preamble.test.ts +552 -0
  269. package/src/tests/schedule-profile.test.ts +359 -0
  270. package/src/tests/script-connections.test.ts +9 -0
  271. package/src/tests/script-executor-conformance.test.ts +188 -0
  272. package/src/tests/script-per-script-executor.test.ts +1 -0
  273. package/src/tests/scripts-sdk-bridge-tool-failure.test.ts +141 -0
  274. package/src/tests/seed-scripts.test.ts +2 -2
  275. package/src/tests/sessions-tree.test.ts +133 -2
  276. package/src/tests/slack-app-icon.test.ts +4 -0
  277. package/src/tests/slack-dm-implicit-mention.test.ts +236 -0
  278. package/src/tests/slack-file-tools-attachments.test.ts +1 -0
  279. package/src/tests/slack-inbound-receipts.test.ts +22 -2
  280. package/src/tests/slack-read-boundaries.test.ts +4 -3
  281. package/src/tests/slack-render-v2-query-plans.test.ts +262 -3
  282. package/src/tests/slack-render-v2-reconcile.test.ts +201 -0
  283. package/src/tests/slack-socket-ack.test.ts +16 -1
  284. package/src/tests/slack-socket-watchdog.test.ts +748 -0
  285. package/src/tests/slack-workspace-guard.test.ts +905 -0
  286. package/src/tests/steering-core.test.ts +40 -0
  287. package/src/tests/store-progress-learning.test.ts +605 -20
  288. package/src/tests/tool-annotations.test.ts +1 -1
  289. package/src/tests/vcs-identity-inheritance.test.ts +85 -0
  290. package/src/tests/workflow-convergence.test.ts +46 -40
  291. package/src/tests/workflow-definition-pinning-recovery.test.ts +552 -0
  292. package/src/tests/workflow-definition-pinning.test.ts +645 -0
  293. package/src/tests/workflow-executors.test.ts +16 -7
  294. package/src/tests/workflow-foreach.test.ts +43 -20
  295. package/src/tests/workflow-notify-slack-ready.test.ts +161 -0
  296. package/src/tests/workflow-profile.test.ts +328 -0
  297. package/src/tools/app-upsert.ts +1 -1
  298. package/src/tools/memory-edit.ts +2 -1
  299. package/src/tools/model-profiles/check-model-profile.ts +63 -0
  300. package/src/tools/schedules/create-schedule.ts +45 -4
  301. package/src/tools/schedules/patch-schedule.ts +50 -4
  302. package/src/tools/schedules/update-schedule.ts +50 -4
  303. package/src/tools/send-task.ts +17 -2
  304. package/src/tools/store-progress.ts +15 -3
  305. package/src/tools/task-action.ts +9 -1
  306. package/src/tools/templates.ts +13 -0
  307. package/src/tools/tool-config.ts +2 -1
  308. package/src/tools/utils.ts +77 -11
  309. package/src/tools/workflows/create-workflow.ts +1 -1
  310. package/src/tools/workflows/retry-workflow-run.ts +1 -1
  311. package/src/tools/workflows/update-workflow.ts +10 -1
  312. package/src/types.ts +56 -1
  313. package/src/utils/credentials.ts +89 -12
  314. package/src/workflows/engine.ts +10 -1
  315. package/src/workflows/executors/agent-task.ts +21 -2
  316. package/src/workflows/executors/foreach.ts +4 -1
  317. package/src/workflows/executors/notify.ts +62 -6
  318. package/src/workflows/executors/sub-workflow.ts +1 -1
  319. package/src/workflows/executors/swarm-script.ts +4 -1
  320. package/src/workflows/foreach-driver.ts +8 -5
  321. package/src/workflows/limits.ts +2 -1
  322. package/src/workflows/model-validation.ts +27 -2
  323. package/src/workflows/patch-definition.ts +3 -1
  324. package/src/workflows/recovery.ts +6 -6
  325. package/src/workflows/resume.ts +9 -9
  326. package/src/workflows/retry-poller.ts +2 -2
  327. package/templates/extensions/comms-adherence-gate/README.md +25 -0
  328. package/templates/extensions/comms-adherence-gate/hooks.ts +100 -11
  329. package/templates/extensions/comms-adherence-gate/manifest.json +1 -1
  330. package/templates/skills/apps/SKILL.md +9 -0
  331. package/templates/skills/apps/content.md +9 -0
  332. package/templates/skills/code-quality/content.md +12 -0
  333. package/templates/skills/memory/content.md +8 -0
  334. package/templates/skills/scheduling/config.json +1 -1
  335. package/templates/skills/scheduling/content.md +2 -2
  336. package/templates/skills/swarm-docs/content.md +4 -0
  337. package/templates/skills/swarm-extensions/content.md +1 -1
  338. package/templates/skills/swarm-scripts/SKILL.md +1 -1
  339. package/templates/skills/swarm-scripts/content.md +1 -1
  340. package/templates/skills/work-on-task/SKILL.md +2 -0
  341. package/templates/skills/work-on-task/content.md +2 -0
  342. package/templates/workflows/dreaming/content.md +174 -7
  343. package/dist/acp-adapter-dn4gdsgr.js +0 -16
  344. package/dist/app-a66ssc4k.js +0 -17
  345. package/dist/cli-530hkwdy.js +0 -779
  346. package/dist/cli-a0657jmf.js +0 -339
  347. package/dist/cli-cyn9v8zr.js +0 -748
  348. package/dist/handlers-crckt5dq.js +0 -32
  349. package/dist/heartbeat-8phn1kdq.js +0 -41
  350. package/dist/index-4x08sjtk.js +0 -30
  351. package/dist/index-8ybffts4.js +0 -37
  352. package/dist/index-nfy4kkg5.js +0 -33
  353. package/dist/lead-zdqxsvjn.js +0 -71
  354. package/dist/worker-y62rvvq3.js +0 -71
  355. package/dist/{cli-gxy8y1dt.js → cli-8bpgbr8k.js} +3 -3
@@ -1,8 +1,45 @@
1
+ import type { App } from "@slack/bolt";
1
2
  import { z } from "zod";
3
+ import { isSlackConfigured } from "../../slack/config";
2
4
  import type { ExecutorMeta } from "../../types";
3
5
  import { scrubSecrets } from "../../utils/secret-scrubber";
4
6
  import { BaseExecutor, type ExecutorResult } from "./base";
5
7
 
8
+ // ─── Slack readiness wait ───────────────────────────────────
9
+
10
+ /**
11
+ * How long a Slack notify waits for a configured but not yet initialized
12
+ * client. Kept under the default 30s node watchdog (`DEFAULT_NODE_TIMEOUT_MS`)
13
+ * so the step fails with this executor's error rather than a bare timeout.
14
+ */
15
+ const slackReadyWait = { timeoutMs: 25_000, pollMs: 250 };
16
+
17
+ /** Test seam: shrink the readiness wait. */
18
+ export function _setNotifySlackReadyWaitForTests(opts: {
19
+ timeoutMs?: number;
20
+ pollMs?: number;
21
+ }): void {
22
+ if (opts.timeoutMs !== undefined) slackReadyWait.timeoutMs = opts.timeoutMs;
23
+ if (opts.pollMs !== undefined) slackReadyWait.pollMs = opts.pollMs;
24
+ }
25
+
26
+ /** Poll for the Slack client until it exists, the wait runs out, or `signal` aborts. */
27
+ async function waitForSlackApp(
28
+ getApp: () => App | null,
29
+ signal: AbortSignal | undefined,
30
+ ): Promise<App | null> {
31
+ const deadline = Date.now() + slackReadyWait.timeoutMs;
32
+ while (Date.now() < deadline && !signal?.aborted) {
33
+ await Bun.sleep(Math.min(slackReadyWait.pollMs, Math.max(0, deadline - Date.now())));
34
+ // The deadline may have fired during the sleep. Posting now would land
35
+ // after the engine marked the step failed, and a retry would post again.
36
+ if (signal?.aborted) return null;
37
+ const app = getApp();
38
+ if (app) return app;
39
+ }
40
+ return null;
41
+ }
42
+
6
43
  // ─── Schemas ────────────────────────────────────────────────
7
44
 
8
45
  export const NotifyConfigSchema = z.object({
@@ -31,7 +68,7 @@ export class NotifyExecutor extends BaseExecutor<
31
68
  protected async execute(
32
69
  config: z.infer<typeof NotifyConfigSchema>,
33
70
  context: Readonly<Record<string, unknown>>,
34
- _meta: ExecutorMeta,
71
+ meta: ExecutorMeta,
35
72
  ): Promise<ExecutorResult<z.infer<typeof NotifyOutputSchema>>> {
36
73
  // Scrub once: the message reaches Slack, the swarm channel, a log line and
37
74
  // the step output.
@@ -62,12 +99,31 @@ export class NotifyExecutor extends BaseExecutor<
62
99
  }
63
100
  case "slack": {
64
101
  const { getSlackApp } = await import("../../slack/app");
65
- const app = getSlackApp();
102
+ let app = getSlackApp();
66
103
  if (!app) {
67
- return {
68
- status: "success",
69
- output: { sent: false, message },
70
- };
104
+ // No Slack on this install: nothing to post to, so not a failure.
105
+ if (!isSlackConfigured()) {
106
+ return {
107
+ status: "success",
108
+ output: { sent: false, message },
109
+ };
110
+ }
111
+ // Slack is configured but its client is not up: the server is still
112
+ // booting, shutting down, or reloading integrations. Reporting
113
+ // success here would drop the message and hide it.
114
+ app = await waitForSlackApp(getSlackApp, meta.signal);
115
+ if (meta.signal?.aborted) {
116
+ return {
117
+ status: "failed",
118
+ error: "Step deadline reached while waiting for the Slack client; message not sent",
119
+ };
120
+ }
121
+ if (!app) {
122
+ return {
123
+ status: "failed",
124
+ error: `Slack is configured but its client was not ready within ${slackReadyWait.timeoutMs}ms; message not sent`,
125
+ };
126
+ }
71
127
  }
72
128
  try {
73
129
  const result = await app.client.chat.postMessage({
@@ -125,7 +125,7 @@ export class SubWorkflowExecutor extends BaseExecutor<
125
125
  // The child acts as the parent's principal, never as an `agentId` in
126
126
  // `config.inputs`: the parent's author writes those, so a creator-less
127
127
  // child would otherwise run as any agent the author names.
128
- const parent = await db.getWorkflow(meta.workflowId);
128
+ const parent = await db.getRunWorkflow({ id: meta.runId, workflowId: meta.workflowId });
129
129
  const triggeredByAgentId =
130
130
  parent?.createdByAgentId ?? (await getWorkflowRunTriggeredByAgentId(meta.runId)) ?? undefined;
131
131
 
@@ -89,7 +89,10 @@ export class SwarmScriptExecutor extends BaseExecutor<
89
89
  };
90
90
  }
91
91
 
92
- const workflow = await this.deps.db.getWorkflow(meta.workflowId);
92
+ const workflow = await this.deps.db.getRunWorkflow({
93
+ id: meta.runId,
94
+ workflowId: meta.workflowId,
95
+ });
93
96
  // Never `trigger.agentId`: trigger data is caller-supplied, so reading the
94
97
  // principal from it let any agent run a creator-less workflow's scripts as
95
98
  // the lead. The run row carries the server-stamped starting agent.
@@ -3,8 +3,8 @@ import {
3
3
  detachTaskFromWorkflowRunStep,
4
4
  getDbClient,
5
5
  getLatestStepForNode,
6
+ getRunWorkflow,
6
7
  getTaskByWorkflowRunStepId,
7
- getWorkflow,
8
8
  getWorkflowRun,
9
9
  getWorkflowRunStep,
10
10
  getWorkflowRunStepsByRunId,
@@ -128,7 +128,7 @@ export async function driveForeach(
128
128
  ): Promise<ForeachDriveResult> {
129
129
  const run = await getWorkflowRun(runId);
130
130
  if (!run || (run.status !== "running" && run.status !== "waiting")) return NOT_JOINED;
131
- const workflow = await getRenderedWorkflow(run.workflowId);
131
+ const workflow = await getRenderedWorkflow(run);
132
132
  if (!workflow) return NOT_JOINED;
133
133
  const def = workflow.definition;
134
134
  const parentNode = def.nodes.find((node) => node.id === parentNodeId);
@@ -277,7 +277,7 @@ export async function runForeachDrive(
277
277
  return drive;
278
278
  }
279
279
  const run = await getWorkflowRun(runId);
280
- const workflow = run ? await getRenderedWorkflow(run.workflowId) : null;
280
+ const workflow = run ? await getRenderedWorkflow(run) : null;
281
281
  if (!run || !workflow) return drive;
282
282
  const ctx = (run.context ?? {}) as Record<string, unknown>;
283
283
  if (drive.successors.length > 0) {
@@ -313,8 +313,11 @@ export async function drainForeachDrives(): Promise<void> {
313
313
  * post-join walk reload the definition, so without this a `{{PARAM}}` token in
314
314
  * the body config or in `over` would reach the per-item pass unresolved.
315
315
  */
316
- async function getRenderedWorkflow(workflowId: string): Promise<Workflow | null> {
317
- const workflow = await getWorkflow(workflowId);
316
+ async function getRenderedWorkflow(run: {
317
+ id: string;
318
+ workflowId: string;
319
+ }): Promise<Workflow | null> {
320
+ const workflow = await getRunWorkflow(run);
318
321
  return workflow ? renderAutomationTokens(workflow, workflow.params ?? {}) : null;
319
322
  }
320
323
 
@@ -4,5 +4,6 @@ const DEFAULT_MAX_STEPS_PER_RUN = 500;
4
4
  // workflow modules before `loadGlobalConfigsIntoEnv()` hydrates `swarm_config`
5
5
  // into `process.env`. A function also lets config reloads take effect live.
6
6
  export function getMaxWorkflowStepsPerRun(): number {
7
- return Number(process.env.WORKFLOW_MAX_STEPS_PER_RUN) || DEFAULT_MAX_STEPS_PER_RUN;
7
+ const value = Number(process.env.WORKFLOW_MAX_STEPS_PER_RUN);
8
+ return Number.isInteger(value) && value > 0 ? value : DEFAULT_MAX_STEPS_PER_RUN;
8
9
  }
@@ -5,6 +5,7 @@
5
5
  * from the create/update/patch handlers. The agent-task executor keeps its own
6
6
  * check as the run-time guard (it also covers pool nodes and interpolated values).
7
7
  */
8
+ import { taskProfileError } from "../be/db/model-profiles";
8
9
  import { explicitModelErrorForAgent } from "../be/model-validation";
9
10
  import { splitLegacyModelAlias, type WorkflowDefinition } from "../types";
10
11
 
@@ -20,8 +21,21 @@ function isStatic(value: unknown): value is string {
20
21
  return typeof value === "string" && value.trim() !== "" && !value.includes("{{");
21
22
  }
22
23
 
23
- /** Errors for agent-task nodes (and foreach bodies) that pin a model their `agentId` cannot run. */
24
- export async function workflowModelErrors(def: WorkflowDefinition): Promise<string[]> {
24
+ function asString(value: unknown): string | undefined {
25
+ return typeof value === "string" ? value : undefined;
26
+ }
27
+
28
+ /**
29
+ * Errors for agent-task nodes (and foreach bodies) that pin a model or a
30
+ * profile their `agentId` cannot run. A static `profile` must exist, must not
31
+ * sit beside `model`/`modelTier`, and must pass the profile check when
32
+ * `agentId` is static too.
33
+ */
34
+ export async function workflowModelErrors(
35
+ def: WorkflowDefinition,
36
+ /** The workflow-level `vcsRepo` a node without its own inherits. */
37
+ { vcsRepo }: { vcsRepo?: string | null } = {},
38
+ ): Promise<string[]> {
25
39
  const errors: string[] = [];
26
40
  for (const node of def.nodes) {
27
41
  const targets: Array<{ config: NodeConfig; path: string }> = [];
@@ -31,6 +45,17 @@ export async function workflowModelErrors(def: WorkflowDefinition): Promise<stri
31
45
  if (body) targets.push({ config: body, path: "config.body.config" });
32
46
  }
33
47
  for (const { config, path } of targets) {
48
+ if (isStatic(config.profile)) {
49
+ const error = await taskProfileError({
50
+ profile: config.profile,
51
+ model: asString(config.model),
52
+ modelTier: asString(config.modelTier),
53
+ agentId: isStatic(config.agentId) ? config.agentId : undefined,
54
+ // A node's own repo wins over the workflow's, as in the executor.
55
+ vcsRepo: config.vcsRepo === undefined ? vcsRepo : asString(config.vcsRepo),
56
+ });
57
+ if (error) errors.push(`Node "${node.id}" ${path}.profile: ${error}`);
58
+ }
34
59
  if (!isStatic(config.model) || !isStatic(config.agentId)) continue;
35
60
  const modelTier = typeof config.modelTier === "string" ? config.modelTier : undefined;
36
61
  const error = await explicitModelErrorForAgent({
@@ -53,7 +53,9 @@ export async function patchWorkflowDefinition(options: {
53
53
  if (!validation.valid) {
54
54
  return { ok: false, reason: "invalid", errors: validation.errors };
55
55
  }
56
- const modelErrors = await workflowModelErrors(patchResult.definition);
56
+ const modelErrors = await workflowModelErrors(patchResult.definition, {
57
+ vcsRepo: updates?.vcsRepo === undefined ? existing.vcsRepo : updates.vcsRepo,
58
+ });
57
59
  if (modelErrors.length > 0) {
58
60
  return { ok: false, reason: "invalid", errors: modelErrors };
59
61
  }
@@ -2,10 +2,10 @@ import {
2
2
  getApprovalRequestById,
3
3
  getCompletedStepNodeIds,
4
4
  getDbClient,
5
+ getRunWorkflow,
5
6
  getStuckApprovalRuns,
6
7
  getStuckWaitRuns,
7
8
  getStuckWorkflowRuns,
8
- getWorkflow,
9
9
  getWorkflowRun,
10
10
  getWorkflowRunStep,
11
11
  getWorkflowRunStepsByRunId,
@@ -114,7 +114,7 @@ async function recoverRunningRuns(registry: ExecutorRegistry): Promise<number> {
114
114
  continue;
115
115
  }
116
116
 
117
- const workflow = await getWorkflow(run.workflowId);
117
+ const workflow = await getRunWorkflow(run);
118
118
  if (!workflow) continue;
119
119
 
120
120
  const completedNodeIds = new Set(await getCompletedStepNodeIds(runId));
@@ -189,7 +189,7 @@ async function recoverOrphanedSubWorkflowSteps(registry: ExecutorRegistry): Prom
189
189
  if (isWorkflowRunActive(row.runId) || isStepExecuting(row.stepId)) continue;
190
190
  const run = await getWorkflowRun(row.runId);
191
191
  if (!run || (run.status !== "running" && run.status !== "waiting")) continue;
192
- const workflow = await getWorkflow(run.workflowId);
192
+ const workflow = await getRunWorkflow(run);
193
193
  const node = workflow?.definition.nodes.find((n) => n.id === row.nodeId);
194
194
  if (!workflow || !node) continue;
195
195
  // DB reads above yield; a resume may have acquired the run meanwhile.
@@ -267,7 +267,7 @@ async function recoverWaitingRuns(registry: ExecutorRegistry): Promise<number> {
267
267
  for (const stuck of stuckRuns) {
268
268
  try {
269
269
  const run = await getWorkflowRun(stuck.runId);
270
- const workflow = await getWorkflow(stuck.workflowId);
270
+ const workflow = await getRunWorkflow({ id: stuck.runId, workflowId: stuck.workflowId });
271
271
  if (!run || run.status !== "waiting" || !workflow) continue;
272
272
 
273
273
  const taskCompleted = stuck.taskStatus === "completed";
@@ -378,7 +378,7 @@ async function recoverApprovalWaitingRuns(registry: ExecutorRegistry): Promise<n
378
378
  for (const stuck of stuckRuns) {
379
379
  try {
380
380
  const run = await getWorkflowRun(stuck.runId);
381
- const workflow = await getWorkflow(stuck.workflowId);
381
+ const workflow = await getRunWorkflow({ id: stuck.runId, workflowId: stuck.workflowId });
382
382
  if (!run || !workflow) continue;
383
383
 
384
384
  const ctx = (run.context ?? {}) as Record<string, unknown>;
@@ -533,7 +533,7 @@ async function recoverForeachFanouts(registry: ExecutorRegistry): Promise<number
533
533
  try {
534
534
  // The drive re-checks the run, the parent step and each child's latest
535
535
  // row, so a stale snapshot row claims nothing.
536
- const workflow = await getWorkflow(fanout.workflowId);
536
+ const workflow = await getRunWorkflow({ id: fanout.runId, workflowId: fanout.workflowId });
537
537
  const parent = workflow?.definition.nodes.find((node) => node.id === fanout.parentNodeId);
538
538
  if (parent?.type !== "foreach") continue;
539
539
  const drive = await runForeachDrive(fanout.runId, fanout.parentNodeId, registry);
@@ -7,9 +7,9 @@ import {
7
7
  getDbClient,
8
8
  getPendingEventWaitNames,
9
9
  getPendingWaitsByEvent,
10
+ getRunWorkflow,
10
11
  getTaskByWorkflowRunStepId,
11
12
  getWaitStateById,
12
- getWorkflow,
13
13
  getWorkflowRun,
14
14
  getWorkflowRunStep,
15
15
  getWorkflowRunStepsByRunId,
@@ -261,7 +261,7 @@ async function resumeFromTaskCompletionUnguarded(
261
261
  if (!step || step.status !== "waiting") return;
262
262
  if (await isStaleTaskEvent(step.id, event)) return;
263
263
 
264
- const workflow = await getWorkflow(run.workflowId);
264
+ const workflow = await getRunWorkflow(run);
265
265
  if (!workflow) return;
266
266
 
267
267
  // Checkpoint: atomic step completion + context update
@@ -379,7 +379,7 @@ async function handleTaskFailureUnguarded(
379
379
  if (!step || step.status !== "waiting") return;
380
380
  if (await isStaleTaskEvent(step.id, event)) return;
381
381
 
382
- const workflow = await getWorkflow(run.workflowId);
382
+ const workflow = await getRunWorkflow(run);
383
383
  if (!workflow) return;
384
384
 
385
385
  if (options.retryable) {
@@ -460,7 +460,7 @@ async function recordLateForeachOutcome(
460
460
  const step = await getWorkflowRunStep(stepId);
461
461
  if (!step || step.status !== "waiting") return;
462
462
  if (await isStaleTaskEvent(step.id, event)) return;
463
- const workflow = await getWorkflow(run.workflowId);
463
+ const workflow = await getRunWorkflow(run);
464
464
  if (!workflow || !resolveForeachParent(workflow.definition, step.nodeId)) return;
465
465
  await settleForeachChild(
466
466
  workflow.definition,
@@ -513,7 +513,7 @@ export async function retryFailedRun(runId: string, registry: ExecutorRegistry):
513
513
  const run = await getWorkflowRun(runId);
514
514
  if (!run || run.status !== "failed") throw new Error("Run is not in failed state");
515
515
 
516
- const workflow = await getWorkflow(run.workflowId);
516
+ const workflow = await getRunWorkflow(run);
517
517
  if (!workflow) throw new Error("Workflow not found");
518
518
 
519
519
  // Find the failed step. Only the latest row per node id counts: a foreach
@@ -906,7 +906,7 @@ async function resumeFromApprovalResolutionUnguarded(
906
906
  const step = await getWorkflowRunStep(event.workflowRunStepId!);
907
907
  if (!step || step.status !== "waiting") return;
908
908
 
909
- const workflow = await getWorkflow(run.workflowId);
909
+ const workflow = await getRunWorkflow(run);
910
910
  if (!workflow) return;
911
911
 
912
912
  if (event.status === "cancelled") {
@@ -1039,7 +1039,7 @@ async function resumeClaimedWait(
1039
1039
  const step = await getWorkflowRunStep(waitRow.workflowRunStepId);
1040
1040
  if (!step || step.status !== "waiting") return;
1041
1041
 
1042
- const workflow = await getWorkflow(run.workflowId);
1042
+ const workflow = await getRunWorkflow(run);
1043
1043
  if (!workflow) return;
1044
1044
 
1045
1045
  // 3. Pick the output port.
@@ -1054,7 +1054,7 @@ async function resumeClaimedWait(
1054
1054
  payload: cappedPayload === undefined ? undefined : cappedPayload,
1055
1055
  };
1056
1056
 
1057
- // The `waiting` checks above ran before getWorkflow's await. The wait-state
1057
+ // The `waiting` checks above ran before getRunWorkflow's await. The wait-state
1058
1058
  // claim only arbitrates two resumeWaitState callers, not a user cancel
1059
1059
  // landing in that window (cancelWorkflowRun never touches wait_states), so
1060
1060
  // the authoritative claim is the in-transaction re-read of the step.
@@ -1112,7 +1112,7 @@ export async function resumeFromChildRun(
1112
1112
  await failClosedOnUnreadableReplay(step.runId, step.id, async () => {
1113
1113
  const run = await getWorkflowRun(step.runId);
1114
1114
  if (!run || (run.status !== "waiting" && run.status !== "running")) return;
1115
- const workflow = await getWorkflow(run.workflowId);
1115
+ const workflow = await getRunWorkflow(run);
1116
1116
  if (!workflow) return;
1117
1117
 
1118
1118
  const ctx = (run.context ?? {}) as Record<string, unknown>;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getDbClient,
3
3
  getRetryableSteps,
4
- getWorkflow,
4
+ getRunWorkflow,
5
5
  getWorkflowRun,
6
6
  getWorkflowRunStepsByRunId,
7
7
  updateWorkflowRun,
@@ -44,7 +44,7 @@ export function startRetryPoller(registry: ExecutorRegistry, intervalMs = 5000):
44
44
  const run = await getWorkflowRun(step.runId);
45
45
  if (!run) continue;
46
46
 
47
- const workflow = await getWorkflow(run.workflowId);
47
+ const workflow = await getRunWorkflow(run);
48
48
  if (!workflow) continue;
49
49
 
50
50
  // A foreach child goes back to its fan-out's queue: the driver
@@ -75,6 +75,30 @@ Every error lets the completion through: a missing key, an HTTP error, a network
75
75
 
76
76
  Call `store-progress` with a non-completed status and `progress` starting with `comms-gate-selftest`. The gate judges a known-bad and a known-good message against a terse preference, and a dense and a plain message on `plain`, then writes `selftest:last`: every score, both thresholds, the provider, `controlsOk` (verbosity: bad below `threshold`, good at or above it) and `plainControlsOk` (the same against `plainThreshold`). Real traffic is untouched.
77
77
 
78
+ ### Fixtures
79
+
80
+ Fixed text that your own templates tell an agent to post (a daily report's all-clear line, a standard reply) should pass the gate. List it under `fixtures` and the self-test judges each entry with the same state and questions as real traffic, then records `fixtures` (per entry: `name`, `scores`, `failed`, `pass`) and `fixturesOk` in `selftest:last`. A failing fixture means the template line or the gate needs a fix before a quiet day forces an ad-hoc rewrite.
81
+
82
+ ```json
83
+ {
84
+ "fixtures": [
85
+ { "name": "daily-report-all-clear", "text": "📊 11-03: all clear, nothing for you. 56 of 73 workflows are turned on." },
86
+ {
87
+ "name": "short-reply",
88
+ "text": "Went with option B: it keeps the migration reversible. PR #123.",
89
+ "prefs": { "verbosity": "very terse, ~400 chars max" },
90
+ "request": "which option did you pick?"
91
+ }
92
+ ]
93
+ }
94
+ ```
95
+
96
+ Fill placeholders with realistic sample values. `prefs` adds the preference dimensions it names; without it only `plain` is judged. At most 8 entries run; an invalid entry is skipped, never fatal to the rest of the config.
97
+
98
+ `fixturesOk` is `true` only when at least one entry ran and every entry passed. It is `null` when no valid entry ran: `fixtures` unset, an explicit `fixtures: []`, or every entry invalid. `null` means nothing was checked, so never read it as a pass. A skipped entry is missing from `fixtures` in `selftest:last`, so compare that list with your config.
99
+
100
+ Unit tests mock Jev, so they cannot show that a line passes. Only the self-test, which calls the live judge, can.
101
+
78
102
  ## Config
79
103
 
80
104
  | Key | Default | Notes |
@@ -89,6 +113,7 @@ Call `store-progress` with a non-completed status and `progress` starting with `
89
113
  | `model` | `jev-latest` | Jev model on TypeSafe |
90
114
  | `openrouterModel` | `typesafe/jev-1.13` | Jev model on OpenRouter |
91
115
  | `apiKey` | unset | Explicit TypeSafe key. Prefer the `TYPESAFE_API_KEY` secret below |
116
+ | `fixtures` | unset | Fixed template text the self-test expects to pass. See [Fixtures](#fixtures) |
92
117
 
93
118
  ## Required secrets
94
119
 
@@ -54,6 +54,12 @@ export const config = z.object({
54
54
  openrouterModel: z.string().default("typesafe/jev-1.13"),
55
55
  /** Explicit TypeSafe key; otherwise TYPESAFE_API_KEY from the API process env. */
56
56
  apiKey: z.string().optional(),
57
+ /**
58
+ * Fixed text the operator's own templates mandate, judged by the self-test and
59
+ * expected to pass. Kept loose here and parsed per entry by `fixturesOf`, so one
60
+ * bad entry cannot fail the whole config and drop `mode` back to its default.
61
+ */
62
+ fixtures: z.unknown().optional(),
57
63
  });
58
64
 
59
65
  type Cfg = z.infer<typeof config>;
@@ -254,6 +260,27 @@ export const resolveTransport = (cfg: Cfg): JevTransport => {
254
260
  );
255
261
  };
256
262
 
263
+ /**
264
+ * The judge input for one message. The live gate and the self-test fixtures build it
265
+ * here, so a fixture is judged exactly like real traffic.
266
+ */
267
+ export const gateState = (s: {
268
+ requester: string;
269
+ prefs: Prefs;
270
+ ask: string;
271
+ threadOpening: string;
272
+ text: string;
273
+ }): Record<string, unknown> => ({
274
+ role: "You audit an AI agent's message to the human who requested the work.",
275
+ requester: s.requester,
276
+ requester_preferences: s.prefs,
277
+ latest_request: s.ask,
278
+ thread_opening: s.threadOpening,
279
+ judging_rules: JUDGING_RULES,
280
+ plain_language_rules: PLAIN_RULES,
281
+ agent_message: s.text,
282
+ });
283
+
257
284
  /** One Jev call; returns the `noul` score per question. Throws on any failure. */
258
285
  export const askJev = async (
259
286
  state: Record<string, unknown>,
@@ -310,6 +337,72 @@ const SELFTEST_PLAIN_GOOD =
310
337
  const below = (bad: unknown, good: unknown, threshold: number): boolean =>
311
338
  typeof bad === "number" && typeof good === "number" && bad < threshold && good >= threshold;
312
339
 
340
+ /** Fixtures judged per self-test run: one Jev call each, inside the 5 s handler budget. */
341
+ export const MAX_FIXTURES = 8;
342
+ const fixture = z.object({
343
+ name: z.string().min(1).max(80),
344
+ /** The fixed text as it will be posted, placeholders filled with sample values. */
345
+ text: z.string().min(1).max(4000),
346
+ /** Audience preferences; omit to judge `plain` only. */
347
+ prefs: z
348
+ .object({
349
+ verbosity: z.string().optional(),
350
+ tone: z.string().optional(),
351
+ language: z.string().optional(),
352
+ })
353
+ .optional(),
354
+ /** The request the text answers, as `latest_request`. */
355
+ request: z.string().max(900).optional(),
356
+ });
357
+ export type Fixture = z.infer<typeof fixture>;
358
+
359
+ /** Valid fixture entries, in order, capped at MAX_FIXTURES; invalid entries are skipped. */
360
+ export const fixturesOf = (raw: unknown): Fixture[] =>
361
+ (Array.isArray(raw) ? raw : [])
362
+ .map((f) => fixture.safeParse(f))
363
+ .filter((r) => r.success)
364
+ .map((r) => r.data)
365
+ .slice(0, MAX_FIXTURES);
366
+
367
+ /**
368
+ * Judge each fixture with the live gate's questions and state. A fixture is fixed
369
+ * text the operator expects to pass, so any dimension below its threshold fails it.
370
+ */
371
+ const judgeFixtures = async (
372
+ fixtures: Fixture[],
373
+ transport: JevTransport,
374
+ cfg: Cfg,
375
+ signal?: AbortSignal,
376
+ ) =>
377
+ Promise.all(
378
+ fixtures.map(async (f) => {
379
+ const prefs: Prefs = f.prefs ?? {};
380
+ const questions = { ...buildQuestions(prefs), plain: PLAIN_QUESTION };
381
+ try {
382
+ const { scores } = await askJev(
383
+ gateState({
384
+ requester: "the requester",
385
+ prefs,
386
+ ask: f.request ?? "",
387
+ threadOpening: "",
388
+ text: f.text,
389
+ }),
390
+ questions,
391
+ transport,
392
+ cfg,
393
+ signal,
394
+ );
395
+ const failed = Object.keys(questions).filter((dim) => {
396
+ const s = scores[dim];
397
+ return typeof s !== "number" || s < (dim === "plain" ? cfg.plainThreshold : cfg.threshold);
398
+ });
399
+ return { name: f.name, scores, failed, pass: failed.length === 0 };
400
+ } catch (err) {
401
+ return { name: f.name, error: String(err).slice(0, 200), pass: false };
402
+ }
403
+ }),
404
+ );
405
+
313
406
  /**
314
407
  * Run the judge on known-bad (positive control, must score below threshold) and
315
408
  * known-good (negative control, must score at or above it) messages and record
@@ -330,11 +423,13 @@ const selfTest = async (swarm: Swarm, cfg: Cfg, signal?: AbortSignal): Promise<v
330
423
  cfg,
331
424
  signal,
332
425
  ).then((r) => r.scores[dim] ?? null);
333
- const [bad, good, plainBad, plainGood] = await Promise.all([
426
+ const fixtures = fixturesOf(cfg.fixtures);
427
+ const [bad, good, plainBad, plainGood, fixtureResults] = await Promise.all([
334
428
  judge(SELFTEST_BAD, "verbosity"),
335
429
  judge(SELFTEST_GOOD, "verbosity"),
336
430
  judge(SELFTEST_PLAIN_BAD, "plain"),
337
431
  judge(SELFTEST_PLAIN_GOOD, "plain"),
432
+ judgeFixtures(fixtures, transport, cfg, signal),
338
433
  ]);
339
434
  await swarm.kv_set({
340
435
  namespace: NS,
@@ -350,6 +445,9 @@ const selfTest = async (swarm: Swarm, cfg: Cfg, signal?: AbortSignal): Promise<v
350
445
  plainPositiveControlBadScore: plainBad,
351
446
  plainNegativeControlGoodScore: plainGood,
352
447
  plainControlsOk: below(plainBad, plainGood, cfg.plainThreshold),
448
+ fixtures: fixtureResults,
449
+ // null when none are configured: zero fixtures is not a pass.
450
+ fixturesOk: fixtureResults.length === 0 ? null : fixtureResults.every((f) => f.pass),
353
451
  latencyMs: Date.now() - started,
354
452
  },
355
453
  });
@@ -561,16 +659,7 @@ const extension: SwarmExtension = (api) => {
561
659
 
562
660
  const transport = resolveTransport(cfg);
563
661
  const { scores, latencyMs } = await askJev(
564
- {
565
- role: "You audit an AI agent's message to the human who requested the work.",
566
- requester: audienceName,
567
- requester_preferences: prefs,
568
- latest_request: ask,
569
- thread_opening: threadOpening,
570
- judging_rules: JUDGING_RULES,
571
- plain_language_rules: PLAIN_RULES,
572
- agent_message: text,
573
- },
662
+ gateState({ requester: audienceName, prefs, ask, threadOpening, text }),
574
663
  questions,
575
664
  transport,
576
665
  cfg,
@@ -2,7 +2,7 @@
2
2
  "$schema": "../manifest.schema.json",
3
3
  "name": "comms-adherence-gate",
4
4
  "description": "Judges every Slack-facing store-progress completion and agent Slack post against the comms preferences of the requester, or of the person it @-mentions, their latest request and a plain-language rubric with Jev (TypeSafe or OpenRouter), and in enforce blocks a failing call once per task",
5
- "version": "1.7.0",
5
+ "version": "1.8.0",
6
6
  "runtime": "api",
7
7
  "assets": { "hooks": "hooks.ts" }
8
8
  }
@@ -137,6 +137,8 @@ An optional top-level `"theme"` sets the preset the dashboard applies to the app
137
137
 
138
138
  Viewers can override the preset per app from the app's settings drawer; the override rides the reserved `$theme` key of the user-config values (accepted on every app, even without a declared `userConfig` schema, and never visible at `/user/...`). A present override always beats the definition's `theme` — even an unrecognized one, which degrades to the dashboard theme — so treat `theme` as the app's default styling, not a guarantee.
139
139
 
140
+ An optional top-level `"icon"` sets the app's icon on the dashboard Apps page, in the same shape as agent avatars: `{ "type": "lucide", "icon": "<kebab-case lucide name>", "color": "#RRGGBB" }` (`color` optional). The server validates shape only; the dashboard looks the name up in its curated icon catalog and shows a generic grid icon for an unknown name, so omitting `icon` is always safe.
141
+
140
142
  Distinguish the two rollback 400s. A lossy-migration 400 is fixable: copy the required `migration` entries from the message and retry. A target-snapshot validation 400 explicitly says that directives cannot repair that historical definition; use `app-history` and choose a different version.
141
143
 
142
144
  When a schema patch reports stale page/query bindings, repair them in that same patch. Page elements are atomic: replace the complete `pages.<page>.elements.<id>` declaration, removing any reference to a hidden or deleted column, instead of sending only the changed nested prop. This is also the repair move for older apps whose stored page already references an undeclared column; full-definition validation otherwise blocks every patch.
@@ -521,6 +523,7 @@ Tones: Badge, Metric and Progress `tone` take `neutral`, `success`, `active`, `e
521
523
  | `Calendar` | `startField`, `titleField` | `data`, `loading`, `endField`, `idField`, `onSelect`; read-only month grid; see below. |
522
524
  | `ContributionGraph` | none | `data`, `loading`, `dateField` (default `date`), `countField`, `days` (7-730, default 365); read-only activity heatmap. |
523
525
  | `Tree` | `id`, `nodes` | `label`, `maxHeight` (default `480px`), `fill`; collapsible outline of a doc-shaped value that writes the clicked node key to `/ui/<id>/value`; see below. |
526
+ | `SchemaForm` | `id`, `schema` | `value`, `baseDoc`, `nodeKey`, `onChange`, `fill`; form generated from a JSON schema's `properties`, mirrored to `/ui/<id>/value`; see below. |
524
527
 
525
528
  Table details:
526
529
 
@@ -571,6 +574,12 @@ Tree details:
571
574
  - Each row shows `key — type`. Clicking a row writes its key to `/ui/<id>/value`, and the row bound to that path renders selected; read the selection with `{ "$state": "/ui/<id>/value" }`. The Tree never writes `null`: when the selected key leaves the doc (a refetch, an edit) the stored key stays and no row renders selected. Selection and collapse are keyed by node key, so a key reachable through two parents selects and collapses in both places.
572
575
  - Rows scroll inside `maxHeight` (default `480px`). Set `fill: true` inside a `fill` Stack or Split pane to grow to that height instead and scroll within it (ignores `maxHeight`).
573
576
 
577
+ SchemaForm details:
578
+
579
+ - `schema` is a JSON schema object held in state (usually `{ "$state": ... }`). Each entry of `properties` becomes one control: `type: "boolean"` a switch, `enum` of strings a select, `type: "number"` or `"integer"` a number input, anything else a text input. `description` is the tooltip. Fields seed from `value[key]`, else the property `default`. At most 100 fields and 200 enum options render. `id` must match `[A-Za-z0-9_-]+`. Rebinding `schema` resets the form.
580
+ - Typing updates `/ui/<id>/value` with the draft object; switches and selects commit at once and text and number inputs commit on blur. Each commit runs `onChange` with `$form` = the draft.
581
+ - Nested document editing: bind `baseDoc` to a doc-shaped value (`{ root, elements }`) and `nodeKey` to an element key, such as a Tree's `{ "$state": "/ui/<tree>/value" }`. The form then edits `baseDoc.elements[nodeKey].props`, and `/ui/<id>/value` holds the whole doc with the edit merged in, so one `app.mutate` with `values: { <jsonColumn>: { "$state": "/ui/<id>/value" } }` persists it. Props the schema does not list are kept. Edits the query has not returned yet stay applied, so two quick edits on different nodes both survive. A `nodeKey` that is not a key of `elements` falls back to plain mode, and a `baseDoc` over 5,000 elements is not editable. Typing writes `/ui/<id>/value` on every keystroke, before the commit on blur, so another component's `app.mutate` that reads that path can persist half-typed text; persist from the SchemaForm's own `onChange`.
582
+
574
583
  Form details:
575
584
 
576
585
  - `fields[]`: `{ name, label?, kind?, options?: string[], placeholder?, required? }`; `kind` is `string`, `text`, `number`, `boolean`, `date`, or `enum`, and enum fields need `options`.