@desplega.ai/agent-swarm 2.9.0 → 2.10.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 (453) hide show
  1. package/dist/acp-adapter-bht22g3k.js +16 -0
  2. package/dist/{acp-targets-swxq55dr.js → acp-targets-arrwv4f0.js} +7 -7
  3. package/dist/{actions-pb678g3e.js → actions-y0d2n1c2.js} +102 -21
  4. package/dist/{agent-fs-provision-dmhnc38q.js → agent-fs-provision-tpj7sktd.js} +4 -4
  5. package/dist/{amp-adapter-3pa66q27.js → amp-adapter-vmmnmw8d.js} +2 -2
  6. package/dist/{anthropic-messages-x2cp5fvf.js → anthropic-messages-zdca3gv1.js} +22 -22
  7. package/dist/{app-17d12ev4.js → app-wb7w45dq.js} +6 -3
  8. package/dist/{approval-notifications-h7vd9pmg.js → approval-notifications-7mqr6vbd.js} +8 -5
  9. package/dist/{assistant-t7k39ree.js → assistant-gf60454p.js} +23 -21
  10. package/dist/{boot-args-schema-0gqmkfbe.js → boot-args-schema-qxmd59sr.js} +1 -1
  11. package/dist/{boot-reembed-f064w382.js → boot-reembed-5tmeskj2.js} +1 -1
  12. package/dist/{boot-reembed-n6anc01d.js → boot-reembed-wb44vc3s.js} +1 -1
  13. package/dist/boot-scrub-sweep-25bxhnw4.js +9 -0
  14. package/dist/{boot-seeds-f99fjs5q.js → boot-seeds-nj9za0vk.js} +4 -4
  15. package/dist/{claude-adapter-gvznwxgc.js → claude-adapter-d3krpdyb.js} +7 -7
  16. package/dist/{claude-managed-adapter-pbrbvc64.js → claude-managed-adapter-t8nfgcgz.js} +2 -2
  17. package/dist/{claude-managed-setup-kdxttvc3.js → claude-managed-setup-7y4pwd81.js} +3 -3
  18. package/dist/{claude-sdk-session-0t2teq6n.js → claude-sdk-session-d138zy0e.js} +7 -7
  19. package/dist/{cli-6dp0jkfj.js → cli-01k6wpr9.js} +4 -4
  20. package/dist/{cli-c07v0qfa.js → cli-124ntmf0.js} +83 -74
  21. package/dist/{cli-1tvdx9t5.js → cli-2rnd5j3t.js} +1 -1
  22. package/dist/{cli-4ghh072d.js → cli-2spnz7ye.js} +36 -36
  23. package/dist/{cli-dd37e0cm.js → cli-2v2zdm0a.js} +1 -1
  24. package/dist/{cli-aa8s22gn.js → cli-3aaeb78m.js} +195 -186
  25. package/dist/{cli-8x8y70av.js → cli-3caf7pmg.js} +2 -2
  26. package/dist/{cli-jd3kxppb.js → cli-3et6fmfe.js} +1 -1
  27. package/dist/{cli-kaa4bd7x.js → cli-3f8zbtqa.js} +9 -8
  28. package/dist/{cli-57pvhnyt.js → cli-43evxwj4.js} +1 -1
  29. package/dist/cli-43ms35q9.js +270 -0
  30. package/dist/cli-47hz21se.js +25584 -0
  31. package/dist/{cli-n515ex5z.js → cli-4ymxrwg5.js} +16 -16
  32. package/dist/{cli-2tnbc3gw.js → cli-539h29es.js} +2379 -66
  33. package/dist/{cli-rts1qvb4.js → cli-5qhfv9rw.js} +2 -2
  34. package/dist/{cli-faf46gdq.js → cli-6037prsx.js} +10 -10
  35. package/dist/{cli-bk9v1xrv.js → cli-6cwr32fe.js} +25 -25
  36. package/dist/{cli-812paz57.js → cli-6ehs4mta.js} +18 -2
  37. package/dist/{cli-95930z69.js → cli-6ym4jhzp.js} +2 -2
  38. package/dist/{cli-zg3z63x3.js → cli-7mv4h3sn.js} +1 -1
  39. package/dist/{cli-9a2rtd77.js → cli-7r162fxe.js} +24 -15
  40. package/dist/{cli-eg437b5p.js → cli-7sf9sb0w.js} +2 -1
  41. package/dist/{cli-vw5x18yj.js → cli-8st34zhr.js} +20 -10
  42. package/dist/{cli-fgphc007.js → cli-91pkxres.js} +1 -1
  43. package/dist/{cli-2kg31ted.js → cli-9fjr27ez.js} +11 -11
  44. package/dist/{cli-wr1h0k28.js → cli-9w8712tq.js} +617 -278
  45. package/dist/cli-aw83sr40.js +98 -0
  46. package/dist/{cli-ssvdrk4y.js → cli-b6px1k1q.js} +1 -1
  47. package/dist/{cli-w7dxb2fj.js → cli-cc93xzes.js} +6 -6
  48. package/dist/{cli-js8zrfyg.js → cli-fcfbct2j.js} +5 -5
  49. package/dist/{cli-3zxdz9r7.js → cli-fq2rr3jb.js} +6 -6
  50. package/dist/{boot-scrub-sweep-ejd5dnrz.js → cli-had1p04a.js} +8 -9
  51. package/dist/{cli-7cgf614g.js → cli-j6te8keb.js} +5 -5
  52. package/dist/{cli-25nstr34.js → cli-jrbq4djp.js} +1 -1
  53. package/dist/{cli-pz1c00aa.js → cli-k3q2va86.js} +2 -2
  54. package/dist/{cli-nhq5js1b.js → cli-k5yewqgd.js} +3 -3
  55. package/dist/cli-kbtzfrxj.js +404 -0
  56. package/dist/{cli-dx439zpg.js → cli-kpgcm7xy.js} +13 -1
  57. package/dist/{cli-mc1fx4xd.js → cli-m9cvf7vs.js} +10 -10
  58. package/dist/{cli-kmvcm34h.js → cli-md50mj0r.js} +2 -2
  59. package/dist/{cli-q8cfh1t9.js → cli-mk7c5ac4.js} +1 -1
  60. package/dist/cli-mys27d03.js +321 -0
  61. package/dist/{cli-spzkdgtg.js → cli-n3qe7tyr.js} +172 -168
  62. package/dist/{cli-7akn6ze9.js → cli-nh7x3133.js} +7 -28
  63. package/dist/{cli-fnh4b12r.js → cli-nstkanmx.js} +6 -6
  64. package/dist/{cli-g3zzby8t.js → cli-nv4xsvmk.js} +5 -5
  65. package/dist/{cli-sn4pc4qx.js → cli-p0c3vtch.js} +2 -2
  66. package/dist/{cli-5ntc4we6.js → cli-p0n7b5rz.js} +859 -2058
  67. package/dist/{cli-pn1v1pb0.js → cli-psffsanb.js} +3 -2
  68. package/dist/{cli-svc803vq.js → cli-q5srsxq2.js} +15 -15
  69. package/dist/{cli-nmcpzbty.js → cli-qrta34nb.js} +4 -4
  70. package/dist/{cli-k09cxm6m.js → cli-qx4f057j.js} +2 -2
  71. package/dist/{cli-eepnpee7.js → cli-s1khw52h.js} +12 -12
  72. package/dist/{cli-h474mvp5.js → cli-s1zqk1aj.js} +21 -11
  73. package/dist/{cli-8axx8vnw.js → cli-sb4426be.js} +10 -10
  74. package/dist/{cli-kqh27v2y.js → cli-th1dkc2v.js} +1 -1
  75. package/dist/{cli-cw7mc1je.js → cli-tr27kwyg.js} +3 -3
  76. package/dist/{cli-5kcmxwxv.js → cli-tvgqesec.js} +7 -5
  77. package/dist/{cli-a9hfzg2r.js → cli-ty3gha1p.js} +6 -6
  78. package/dist/{cli-fjggej24.js → cli-v46zsvqk.js} +1 -1
  79. package/dist/{cli-5gygrr67.js → cli-v8z0yga9.js} +4 -4
  80. package/dist/{cli-k7pt28ad.js → cli-vfqvrd82.js} +5 -5
  81. package/dist/{cli-vvgaz8t6.js → cli-vq2eg24x.js} +2 -2
  82. package/dist/{cli-pwsax0vp.js → cli-vsw91x06.js} +23 -22
  83. package/dist/{cli-7fx9jyfs.js → cli-w1q68d8x.js} +67 -11
  84. package/dist/{cli-c5cspahx.js → cli-wafmk3fn.js} +45 -20
  85. package/dist/{cli-ymct0ycy.js → cli-wwp1bd3n.js} +5495 -5095
  86. package/dist/{cli-me4maa4j.js → cli-y4ccxtz5.js} +45 -9
  87. package/dist/{cli-m1fbz2wj.js → cli-y8p78ekx.js} +178 -19
  88. package/dist/{cli-nr46j5pw.js → cli-z0m452jr.js} +1 -1
  89. package/dist/{cli-gddgcnav.js → cli-zeh2mhkg.js} +1 -1
  90. package/dist/{cli-e9973bf0.js → cli-zk7v5s89.js} +2 -2
  91. package/dist/cli.js +24 -23
  92. package/dist/{cloudflare-workers-ai-system-one-9y1zx3pt.js → cloudflare-workers-ai-system-one-4aysy6rh.js} +2 -2
  93. package/dist/{codex-adapter-44yq2fkn.js → codex-adapter-exfdbj73.js} +6 -6
  94. package/dist/{codex-hook-h1zb7cfk.js → codex-hook-59atdwd8.js} +1 -1
  95. package/dist/{codex-login-cdyrr5y1.js → codex-login-a239g1ah.js} +1 -1
  96. package/dist/{codex-session-runner-zbh26gbw.js → codex-session-runner-xhznc4g3.js} +6 -6
  97. package/dist/{commands-54f02v5b.js → commands-d8g349v4.js} +3 -3
  98. package/dist/{controller-9gpwcdek.js → controller-mwgdmb8y.js} +6 -3
  99. package/dist/{controllers-connect-61re6k1n.js → controllers-connect-5v7qx04j.js} +22 -20
  100. package/dist/core-sxy4epp2.js +38 -0
  101. package/dist/{cursor-adapter-7e4g81vd.js → cursor-adapter-p2q5h35d.js} +1 -1
  102. package/dist/{db-wnh0qjy1.js → db-qpganbeb.js} +3 -3
  103. package/dist/{db-dg2gc7fd.js → db-wcw0b2j8.js} +8 -2
  104. package/dist/{dispatcher-jrm24r43.js → dispatcher-8d8s49yz.js} +20 -18
  105. package/dist/{docker-9aq30pp2.js → docker-09tkkg0n.js} +42 -3
  106. package/dist/{dsh-adapter-1yqk267c.js → dsh-adapter-me0twn13.js} +1 -1
  107. package/dist/{easter-egg-3d-r4h9cs9m.js → easter-egg-3d-wv7w5ty6.js} +1 -1
  108. package/dist/{embedding-space-bafjr5f7.js → embedding-space-e48xchqa.js} +6 -6
  109. package/dist/{embeddings-7xmgqe0e.js → embeddings-tgq2afbq.js} +1 -1
  110. package/dist/{execute-d6jg5ns0.js → execute-8rhwrk7f.js} +1 -1
  111. package/dist/{external-channel-frq1xvq2.js → external-channel-8bt3j2pm.js} +2 -2
  112. package/dist/fx-adapter-adtdb3jb.js +19 -0
  113. package/dist/{google-generative-ai-hh7strj3.js → google-generative-ai-bh0djqjp.js} +5 -5
  114. package/dist/{google-vertex-fy5bw2pm.js → google-vertex-prjbw8dj.js} +9 -9
  115. package/dist/grok-adapter-accnn9km.js +19 -0
  116. package/dist/handlers-1x77561e.js +35 -0
  117. package/dist/{heartbeat-6bpa611t.js → heartbeat-x0056ra5.js} +23 -21
  118. package/dist/{hook-hvm5nf46.js → hook-a7vmn2st.js} +5 -5
  119. package/dist/{hook-w12k146y.js → hook-mrd2ayxv.js} +6 -6
  120. package/dist/{http-43tthdvs.js → http-ym9c5svp.js} +1335 -363
  121. package/dist/{index-fn054vsf.js → index-01ns1pkw.js} +1 -1
  122. package/dist/{index-1f0vypbg.js → index-0h6qd4p1.js} +34 -24
  123. package/dist/index-48qzcqzj.js +35 -0
  124. package/dist/{index-4b1q8kan.js → index-4k7m5dgj.js} +629 -354
  125. package/dist/index-620y7jzq.js +15 -0
  126. package/dist/{index-cret47a5.js → index-8p0j4h4j.js} +506 -43
  127. package/dist/{index-m5gx1xd6.js → index-9myfj74s.js} +40 -40
  128. package/dist/{index-bs7gw5fd.js → index-b5wgnm78.js} +44 -44
  129. package/dist/{index-ftywhyr0.js → index-ny60jcat.js} +394 -66
  130. package/dist/{index-tx9mc2ap.js → index-p46tvwtx.js} +24 -22
  131. package/dist/{index-585gyczt.js → index-pe3d8jfy.js} +3 -3
  132. package/dist/index-rkvaambe.js +36 -0
  133. package/dist/{index-mhq4sh5w.js → index-x6azjwm8.js} +1 -1
  134. package/dist/index-xj1mq27m.js +40 -0
  135. package/dist/k8s-m56sw868.js +217 -0
  136. package/dist/{keepalive-rk0j0jvh.js → keepalive-7yxg8z4c.js} +3 -3
  137. package/dist/lead-enzn86bz.js +74 -0
  138. package/dist/{maintenance-g6z6kaxw.js → maintenance-6tefxmk1.js} +1 -1
  139. package/dist/{node-jftbyawr.js → node-2wfcey7d.js} +1 -1
  140. package/dist/{oauth-refresh-sweep-2k3g2q4w.js → oauth-refresh-sweep-70cavc3a.js} +2 -2
  141. package/dist/{onboard-6fdbvh3v.js → onboard-fja65z08.js} +5 -5
  142. package/dist/{openai-decisions-q3hh60wr.js → openai-decisions-ytp6w6xh.js} +1 -1
  143. package/dist/{opencode-adapter-fdbsvts7.js → opencode-adapter-hakkm7yh.js} +6 -6
  144. package/dist/{otel-impl-rvwtc09q.js → otel-impl-7zhnt6gj.js} +1 -1
  145. package/dist/{pending-sqkrb836.js → pending-h01yzpx4.js} +21 -19
  146. package/dist/{pi-mono-adapter-asqayqcg.js → pi-mono-adapter-f52hz743.js} +40 -13
  147. package/dist/{pricing-refresh-f5tkgmw2.js → pricing-refresh-fzxvk2zf.js} +2 -2
  148. package/dist/{rbac-roles-06s555fa.js → rbac-roles-9v6vhgbs.js} +3 -3
  149. package/dist/{rbac-roles-szxsg8t1.js → rbac-roles-hfgh8sba.js} +2 -2
  150. package/dist/{render-v2-103p266q.js → render-v2-1rgspxzf.js} +6 -3
  151. package/dist/{resume-v7kjewt9.js → resume-tqy61x24.js} +10 -7
  152. package/dist/{runtime-f1gmk0b7.js → runtime-exkxyx5f.js} +1 -1
  153. package/dist/{session-access-6shev8ts.js → session-access-3act7vt4.js} +4 -4
  154. package/dist/{session-source-backfill-bd7spzjd.js → session-source-backfill-82qe7fqq.js} +3 -3
  155. package/dist/{setup-kmxmztdb.js → setup-ry1vfdef.js} +1 -1
  156. package/dist/thread-buffer-3x93yexa.js +38 -0
  157. package/dist/{typesafe-system-one-f2en2knd.js → typesafe-system-one-vcfj2ak8.js} +2 -2
  158. package/dist/user-merge-jobs-bx6bf7db.js +22 -0
  159. package/dist/{virtual-modules-57eje5wy.js → virtual-modules-s0rjzcqq.js} +3 -3
  160. package/dist/{work-objects-zr47ygmf.js → work-objects-z2e5tv03.js} +29 -23
  161. package/dist/{worker-follow-up-grrr3fda.js → worker-follow-up-y3xeg89w.js} +20 -18
  162. package/dist/worker-zfcv2wbf.js +74 -0
  163. package/openapi.json +2763 -147
  164. package/package.json +9 -8
  165. package/src/apps/catalog.generated.json +43 -3
  166. package/src/apps/page-validator.ts +27 -0
  167. package/src/be/boot-seeds.ts +7 -1
  168. package/src/be/db/model-groups.ts +238 -0
  169. package/src/be/db/model-profiles.ts +28 -7
  170. package/src/be/db/session-costs.ts +225 -0
  171. package/src/be/db/session-log-reasoning.ts +36 -0
  172. package/src/be/db/tasks/read.ts +8 -3
  173. package/src/be/db/tasks/write.ts +34 -1
  174. package/src/be/db/user-references.ts +75 -0
  175. package/src/be/db/users/references.ts +185 -0
  176. package/src/be/db-client.ts +70 -19
  177. package/src/be/db.ts +232 -361
  178. package/src/be/key-window-usage.ts +386 -0
  179. package/src/be/memory/demotion-evidence.ts +34 -0
  180. package/src/be/memory/reranker.ts +34 -12
  181. package/src/be/memory/review-recall-filter.ts +83 -0
  182. package/src/be/memory/search-candidates.ts +19 -6
  183. package/src/be/memory/types.ts +11 -0
  184. package/src/be/migrations/303_task_ui_specs.sql +28 -0
  185. package/src/be/migrations/306_provider_account_telemetry.sql +1 -0
  186. package/src/be/migrations/307_session_cost_credential_attribution.sql +23 -0
  187. package/src/be/migrations/310_session_logs_reasoning.sql +12 -0
  188. package/src/be/migrations/312_task_ui_action_runs_repeatable.sql +6 -0
  189. package/src/be/migrations/314_model_groups.sql +85 -0
  190. package/src/be/migrations/318_superseded_workflow_cut_backfill.sql +22 -0
  191. package/src/be/migrations/319_user_fk_indexes.sql +153 -0
  192. package/src/be/migrations/320_session_costs_kind.sql +4 -0
  193. package/src/be/migrations/321_user_merge_jobs.sql +52 -0
  194. package/src/be/pricing-normalize.ts +2 -0
  195. package/src/be/rbac-roles.ts +6 -4
  196. package/src/be/runtime-pools/db.ts +23 -5
  197. package/src/be/runtime-pools/supervisor.ts +15 -1
  198. package/src/be/scripts/db.ts +11 -0
  199. package/src/be/scripts/typecheck.ts +2 -0
  200. package/src/be/seed-model-groups.ts +86 -0
  201. package/src/be/seed-model-profiles.ts +20 -13
  202. package/src/be/seed-scripts/catalog/boot-triage.inline.ts +1 -0
  203. package/src/be/seed-scripts/catalog/boot-triage.ts +1 -0
  204. package/src/be/seed-scripts/catalog/dreaming-gather.ts +165 -1
  205. package/src/be/seed-scripts/catalog/wait-for-task.ts +5 -1
  206. package/src/be/seed-skills/index.ts +3 -0
  207. package/src/be/swarm-config-guard.ts +58 -1
  208. package/src/be/task-ui-spec.ts +259 -0
  209. package/src/be/user-merge-jobs.ts +564 -0
  210. package/src/be/users.ts +41 -23
  211. package/src/commands/controller.ts +3 -0
  212. package/src/commands/credential-outcome-report.ts +13 -3
  213. package/src/commands/onboard/agent-fs-version.ts +1 -1
  214. package/src/commands/onboard/compose-generator.ts +1 -1
  215. package/src/commands/onboard/env-generator.ts +1 -1
  216. package/src/commands/provider-credentials.ts +1 -1
  217. package/src/commands/rate-limit-outcome.ts +6 -0
  218. package/src/commands/runner.ts +34 -53
  219. package/src/extensions/catalog.generated.json +3 -3
  220. package/src/extensions/contract-types.generated.ts +1 -1
  221. package/src/extensions/contract.ts +15 -0
  222. package/src/extensions/dispatcher.ts +14 -4
  223. package/src/github/handlers.ts +57 -0
  224. package/src/github/types.ts +4 -0
  225. package/src/http/all-routes.ts +2 -0
  226. package/src/http/api-keys.ts +258 -30
  227. package/src/http/approval-requests.ts +5 -1
  228. package/src/http/auth.ts +3 -1
  229. package/src/http/config.ts +34 -1
  230. package/src/http/index.ts +13 -0
  231. package/src/http/memory.ts +19 -6
  232. package/src/http/model-groups.ts +277 -0
  233. package/src/http/model-profiles.ts +30 -13
  234. package/src/http/session-data.ts +74 -23
  235. package/src/http/sessions.ts +6 -2
  236. package/src/http/tasks.ts +140 -5
  237. package/src/http/tool-hooks.ts +140 -0
  238. package/src/http/users.ts +142 -19
  239. package/src/http/workflows.ts +19 -1
  240. package/src/integrations/chat-sdk/inbound.ts +8 -2
  241. package/src/integrations/chat-sdk/limits.ts +8 -3
  242. package/src/integrations/chat-sdk/relay.ts +87 -0
  243. package/src/jira/outbound.ts +5 -3
  244. package/src/linear/outbound.ts +5 -1
  245. package/src/prompts/base-prompt.ts +8 -0
  246. package/src/prompts/session-templates.ts +19 -2
  247. package/src/providers/acp-targets.ts +2 -2
  248. package/src/providers/amp-adapter.ts +1 -1
  249. package/src/providers/claude-adapter.ts +27 -4
  250. package/src/providers/claude-flag-settings.ts +39 -1
  251. package/src/providers/codex-adapter.ts +85 -3
  252. package/src/providers/codex-app-server.ts +9 -5
  253. package/src/providers/codex-oauth/auth-json.ts +1 -0
  254. package/src/providers/pi-mono-adapter.ts +35 -2
  255. package/src/providers/pricing-sources.md +41 -0
  256. package/src/providers/types.ts +11 -0
  257. package/src/rbac/legacy-policy.ts +1 -0
  258. package/src/rbac/permissions.ts +5 -0
  259. package/src/runtime-providers/docker.ts +65 -1
  260. package/src/runtime-providers/index.ts +7 -5
  261. package/src/runtime-providers/k8s.ts +250 -0
  262. package/src/scheduler/deferred-task-waits.ts +18 -5
  263. package/src/scripts-runtime/types/stdlib.d.ts +2 -0
  264. package/src/scripts-runtime/types/swarm-extension.d.ts +24 -9
  265. package/src/scripts-runtime/types/swarm-sdk.d.ts +2 -0
  266. package/src/slack/actions.ts +79 -0
  267. package/src/slack/app.ts +22 -15
  268. package/src/slack/blocks.ts +23 -2
  269. package/src/slack/inbound-files.ts +2 -0
  270. package/src/slack/render-v2.ts +154 -23
  271. package/src/slack/responses.ts +3 -2
  272. package/src/slack/work-objects.ts +4 -1
  273. package/src/tasks/errors.ts +5 -0
  274. package/src/tests/acp-adapter.test.ts +30 -6
  275. package/src/tests/api-key-tracking.test.ts +0 -72
  276. package/src/tests/api-keys-status-model-limits.test.ts +93 -1
  277. package/src/tests/api-keys-validation.test.ts +42 -0
  278. package/src/tests/approval-card-resolution.test.ts +7 -1
  279. package/src/tests/approval-requests-notifications.test.ts +11 -1
  280. package/src/tests/apps-catalog-page-frame.test.ts +49 -0
  281. package/src/tests/apps-session-thread.test.ts +79 -0
  282. package/src/tests/base-prompt.test.ts +111 -5
  283. package/src/tests/chat-sdk-relay.test.ts +170 -2
  284. package/src/tests/check-pr-body.test.ts +43 -0
  285. package/src/tests/claude-adapter-binary.test.ts +67 -6
  286. package/src/tests/claude-flag-settings.test.ts +29 -0
  287. package/src/tests/claude-sdk-lifecycle.test.ts +5 -0
  288. package/src/tests/codex-adapter.test.ts +340 -2
  289. package/src/tests/codex-app-server.test.ts +16 -0
  290. package/src/tests/codex-oauth.test.ts +3 -1
  291. package/src/tests/codex-rate-limits.test.ts +384 -0
  292. package/src/tests/credential-check.test.ts +14 -6
  293. package/src/tests/credential-outcome-report.test.ts +20 -0
  294. package/src/tests/db-client.test.ts +146 -0
  295. package/src/tests/db-task-read-contract.test.ts +3 -0
  296. package/src/tests/db-task-write-contract.test.ts +4 -0
  297. package/src/tests/deferred-task-wake.test.ts +63 -1
  298. package/src/tests/deploy-guard.test.ts +7 -7
  299. package/src/tests/deploy-select.test.ts +83 -0
  300. package/src/tests/docker-isolation-config-guard.test.ts +29 -0
  301. package/src/tests/docs-index-footprint.test.js +11 -3
  302. package/src/tests/dreaming-gather-corrections.test.ts +467 -0
  303. package/src/tests/e2e-visuals-comment.test.ts +82 -0
  304. package/src/tests/e2e-visuals-verify-pr.test.ts +138 -0
  305. package/src/tests/event-loop-lag.test.ts +9 -7
  306. package/src/tests/extensions-example-sql-admin-only.test.ts +7 -4
  307. package/src/tests/fixtures/extensions/native-tool-recorder/hooks.ts +26 -0
  308. package/src/tests/fixtures/extensions/native-tool-recorder/manifest.json +10 -0
  309. package/src/tests/fixtures/onboard/content.compose.yml.txt +1 -1
  310. package/src/tests/fixtures/onboard/content.env.txt +1 -1
  311. package/src/tests/fixtures/onboard/dev.compose.yml.txt +1 -1
  312. package/src/tests/fixtures/onboard/dev.env.txt +1 -1
  313. package/src/tests/fixtures/onboard/full-all.compose.yml.txt +1 -1
  314. package/src/tests/fixtures/onboard/full-all.env.txt +1 -1
  315. package/src/tests/fixtures/onboard/full.compose.yml.txt +1 -1
  316. package/src/tests/fixtures/onboard/full.env.txt +1 -1
  317. package/src/tests/fixtures/onboard/research.compose.yml.txt +1 -1
  318. package/src/tests/fixtures/onboard/research.env.txt +1 -1
  319. package/src/tests/fixtures/onboard/solo.compose.yml.txt +1 -1
  320. package/src/tests/fixtures/onboard/solo.env.txt +1 -1
  321. package/src/tests/fixtures/ui-spec-slack/deploys.json +121 -0
  322. package/src/tests/fixtures/ui-spec-slack/incident.json +183 -0
  323. package/src/tests/fixtures/ui-spec-slack/three-charts-stale.json +196 -0
  324. package/src/tests/fixtures/ui-spec-slack/video-rejected-by-slack.json +183 -0
  325. package/src/tests/fixtures/ui-spec-slack/video.json +446 -0
  326. package/src/tests/github-event-filter.test.ts +8 -0
  327. package/src/tests/github-handlers-inline-comments.test.ts +2 -0
  328. package/src/tests/github-handlers-reactions.test.ts +4 -0
  329. package/src/tests/github-handlers.test.ts +3 -0
  330. package/src/tests/github-sender-trust.test.ts +223 -0
  331. package/src/tests/gitleaks-download-retry.test.ts +85 -0
  332. package/src/tests/http-users.test.ts +142 -41
  333. package/src/tests/human-thread-routing.test.ts +187 -0
  334. package/src/tests/jira-outbound-sync.test.ts +33 -1
  335. package/src/tests/k8s-pool-smoke.test.ts +190 -0
  336. package/src/tests/key-window-usage.test.ts +846 -0
  337. package/src/tests/linear-outbound-sync.test.ts +30 -1
  338. package/src/tests/memory-rater-store.test.ts +35 -1
  339. package/src/tests/memory-reranker.test.ts +39 -4
  340. package/src/tests/memory-review-recall-filter.test.ts +205 -0
  341. package/src/tests/migration-318-superseded-workflow-cut-backfill.test.ts +74 -0
  342. package/src/tests/model-groups-api.test.ts +415 -0
  343. package/src/tests/model-profiles-api.test.ts +1 -0
  344. package/src/tests/operator-granted-credentials.test.ts +7 -2
  345. package/src/tests/operator-granted-role-wire.test.ts +2 -1
  346. package/src/tests/pi-mono-adapter.test.ts +79 -0
  347. package/src/tests/preload-env.test.ts +2 -0
  348. package/src/tests/preload.ts +3 -1
  349. package/src/tests/prompt-template-session.test.ts +4 -3
  350. package/src/tests/provider-quota-persistence.test.ts +362 -0
  351. package/src/tests/rate-limit-event.test.ts +22 -0
  352. package/src/tests/rbac-engine.test.ts +1 -0
  353. package/src/tests/reasoning-events.test.ts +164 -0
  354. package/src/tests/routing-affinity-inventory.test.ts +22 -0
  355. package/src/tests/runtime-k8s-pools.test.ts +142 -0
  356. package/src/tests/runtime-pools-db.test.ts +42 -2
  357. package/src/tests/runtime-pools-http.test.ts +47 -2
  358. package/src/tests/runtime-provider-registration.test.ts +5 -14
  359. package/src/tests/runtime-providers-docker.test.ts +91 -0
  360. package/src/tests/runtime-providers-k8s.test.ts +303 -0
  361. package/src/tests/script-connections.test.ts +18 -1
  362. package/src/tests/secret-canary-sweep.test.ts +41 -5
  363. package/src/tests/seed-scripts.test.ts +23 -0
  364. package/src/tests/session-cost-attribution.test.ts +748 -0
  365. package/src/tests/session-costs.test.ts +14 -15
  366. package/src/tests/session-logs.test.ts +83 -0
  367. package/src/tests/sessions-detail-batch.test.ts +7 -0
  368. package/src/tests/short-id.test.ts +23 -0
  369. package/src/tests/slack-blocks.test.ts +69 -0
  370. package/src/tests/slack-render-v2.test.ts +411 -0
  371. package/src/tests/slack-start-reload-race.test.ts +67 -0
  372. package/src/tests/spec-base-url.test.ts +13 -1
  373. package/src/tests/subscription-plans.test.ts +20 -1
  374. package/src/tests/system-one-decide-session-cost.test.ts +196 -0
  375. package/src/tests/task-ui-action-route.test.ts +249 -0
  376. package/src/tests/task-ui-actions.test.ts +195 -0
  377. package/src/tests/task-ui-script-actions.test.ts +517 -0
  378. package/src/tests/task-ui-spec-fallback.test.ts +65 -0
  379. package/src/tests/task-ui-spec.test.ts +368 -0
  380. package/src/tests/tool-hooks-http.test.ts +187 -0
  381. package/src/tests/ui-spec-script-actions-config.test.ts +196 -0
  382. package/src/tests/user-delete-perf.test.ts +321 -0
  383. package/src/tests/user-merge-jobs.test.ts +680 -0
  384. package/src/tests/vcs-provider.test.ts +25 -5
  385. package/src/tests/vendored-openapi.test.ts +13 -1
  386. package/src/tests/workflow-agent-task-retry.test.ts +96 -1
  387. package/src/tests/workflow-foreach-supersede-retry.test.ts +10 -0
  388. package/src/tests/workflow-http-v2.test.ts +27 -0
  389. package/src/tests/workflow-replay.test.ts +10 -1
  390. package/src/tests/workflow-triggers-v2.test.ts +128 -0
  391. package/src/tests/workflow-wait-event.test.ts +109 -1
  392. package/src/tools/defer-task.ts +1 -1
  393. package/src/tools/memory-search.ts +14 -3
  394. package/src/tools/store-progress.ts +69 -3
  395. package/src/tools/swarm-config/delete-config.ts +12 -1
  396. package/src/tools/swarm-config/set-config.ts +8 -0
  397. package/src/tools/system-one-decide.ts +113 -3
  398. package/src/tools/utils.ts +4 -1
  399. package/src/tools/workflows/create-workflow.ts +2 -0
  400. package/src/tools/workflows/update-workflow.ts +3 -1
  401. package/src/types.ts +93 -4
  402. package/src/ui-spec/actions.ts +112 -0
  403. package/src/ui-spec/fallback.ts +19 -0
  404. package/src/ui-spec/schema.ts +38 -0
  405. package/src/ui-spec/script-actions.ts +340 -0
  406. package/src/ui-spec/script-allowlist.ts +48 -0
  407. package/src/ui-spec/slack.ts +17 -0
  408. package/src/ui-spec/validate.ts +169 -0
  409. package/src/utils/codex-rate-limits.ts +159 -0
  410. package/src/utils/credentials.ts +2 -0
  411. package/src/utils/error-tracker.ts +19 -0
  412. package/src/utils/provider-account-telemetry.ts +331 -0
  413. package/src/utils/reasoning-events.ts +107 -0
  414. package/src/utils/short-id.ts +20 -14
  415. package/src/utils/subscription-plans.ts +11 -59
  416. package/src/utils/task-ui-spec.ts +79 -0
  417. package/src/vcs/index.ts +12 -2
  418. package/src/workflows/executors/system-one-decision.ts +2 -2
  419. package/src/workflows/resume.ts +3 -2
  420. package/src/workflows/task-step-routing.ts +38 -13
  421. package/src/workflows/triggers.ts +35 -3
  422. package/templates/extensions/manifest.schema.json +13 -0
  423. package/templates/extensions/sql-admin-only/README.md +2 -1
  424. package/templates/extensions/sql-admin-only/hooks.ts +7 -3
  425. package/templates/extensions/sql-admin-only/manifest.json +1 -1
  426. package/templates/skills/apps/SKILL.md +32 -5
  427. package/templates/skills/apps/content.md +32 -5
  428. package/templates/skills/swarm-docs/content.md +2 -0
  429. package/templates/skills/ui-spec/config.json +14 -0
  430. package/templates/skills/ui-spec/content.md +133 -0
  431. package/templates/workflows/dreaming/content.md +1 -1
  432. package/dist/acp-adapter-jqn86aam.js +0 -16
  433. package/dist/cli-7831nhaw.js +0 -93
  434. package/dist/cli-srtkr1h2.js +0 -12078
  435. package/dist/fx-adapter-0zrkfbkd.js +0 -19
  436. package/dist/grok-adapter-3db1c538.js +0 -19
  437. package/dist/handlers-k22n8mnn.js +0 -33
  438. package/dist/index-8xcyd3mc.js +0 -33
  439. package/dist/index-9sy2bh6n.js +0 -38
  440. package/dist/index-b24j7t2m.js +0 -12797
  441. package/dist/index-wjd56k1v.js +0 -34
  442. package/dist/lead-atxf3q6e.js +0 -72
  443. package/dist/thread-buffer-4yz236d0.js +0 -36
  444. package/dist/worker-p4hbtcy3.js +0 -72
  445. package/dist/{azure-openai-responses-590s1eea.js → azure-openai-responses-b3y7fz36.js} +8 -8
  446. package/dist/{cli-j49yqpvh.js → cli-7evph51z.js} +3 -3
  447. package/dist/{cli-g0vv9dg4.js → cli-8y43jx2r.js} +8 -8
  448. package/dist/{cli-m0cy2vyf.js → cli-k6nejceb.js} +4 -4
  449. package/dist/{mistral-conversations-0c30em7t.js → mistral-conversations-tm2vd4gc.js} +8 -8
  450. package/dist/{openai-codex-responses-bkcd8pjj.js → openai-codex-responses-sxjv60xx.js} +4 -4
  451. package/dist/{openai-completions-f3n69rep.js → openai-completions-0c7qnhsx.js} +20 -20
  452. package/dist/{openai-responses-gbh0wfqe.js → openai-responses-a7h29chp.js} +15 -15
  453. package/dist/{pi-messages-zebyt7gb.js → pi-messages-2j0fpqwq.js} +5 -5
@@ -6,11 +6,11 @@
6
6
  * route, no effort and no fallbacks.
7
7
  *
8
8
  * Idempotent: an existing name is never overwritten, so an operator's edit to a
9
- * seed survives every boot. Harnesses with no portable tier mapping (acp) get
9
+ * seed survives every boot. A name a model group already took is skipped. Harnesses with no portable tier mapping (acp) get
10
10
  * no seeds.
11
11
  */
12
12
  import { DEFAULT_MODEL_TIER_MAP, MODEL_TIERS, ProviderNameSchema } from "../types";
13
- import { createModelProfile } from "./db/model-profiles";
13
+ import { createModelProfile, isModelNameTakenError } from "./db/model-profiles";
14
14
  import { getDbClient } from "./db/runtime";
15
15
  import { tierConfigKey } from "./model-tier-keys";
16
16
 
@@ -24,17 +24,24 @@ export async function seedModelProfiles(): Promise<number> {
24
24
  "SELECT value FROM swarm_config WHERE scope = 'global' AND scopeId IS NULL AND key = ? AND isSecret = 0",
25
25
  [tierConfigKey(harness, tier)],
26
26
  );
27
- const created = await createModelProfile({
28
- name: `${harness}-${tier}`,
29
- harness,
30
- model: configured?.value.trim() || fallback,
31
- effort: null,
32
- // Tier values are free-form today (a `latest:` alias, a gateway id); keep that.
33
- allowCustomModel: true,
34
- description: `The ${tier} tier on ${harness}, seeded from the tier map.`,
35
- seededFrom: `tier:${tier}`,
36
- });
37
- if (created) inserted++;
27
+ const name = `${harness}-${tier}`;
28
+ try {
29
+ const created = await createModelProfile({
30
+ name,
31
+ harness,
32
+ model: configured?.value.trim() || fallback,
33
+ effort: null,
34
+ // Tier values are free-form today (a `latest:` alias, a gateway id); keep that.
35
+ allowCustomModel: true,
36
+ description: `The ${tier} tier on ${harness}, seeded from the tier map.`,
37
+ seededFrom: `tier:${tier}`,
38
+ });
39
+ if (created) inserted++;
40
+ } catch (error) {
41
+ // A model group already has the name (one name space): skip this seed only.
42
+ if (!isModelNameTakenError(error)) throw error;
43
+ console.warn(`[startup] Model profile "${name}" not seeded: a model group has this name`);
44
+ }
38
45
  }
39
46
  }
40
47
  return inserted;
@@ -189,6 +189,7 @@ export default async function bootTriage(args: any, ctx: any) {
189
189
  FROM agent_tasks p
190
190
  LEFT JOIN agents a ON a.id = p.agentId
191
191
  WHERE p.status = 'superseded'
192
+ AND p.failureReason IS NOT 'superseded_workflow_task'
192
193
  AND datetime(p.lastUpdatedAt) >= datetime(?, ?)
193
194
  AND NOT EXISTS (
194
195
  SELECT 1
@@ -189,6 +189,7 @@ export default async function bootTriage(args: any, ctx: any) {
189
189
  FROM agent_tasks p
190
190
  LEFT JOIN agents a ON a.id = p.agentId
191
191
  WHERE p.status = 'superseded'
192
+ AND p.failureReason IS NOT 'superseded_workflow_task'
192
193
  AND datetime(p.lastUpdatedAt) >= datetime(?, ?)
193
194
  AND NOT EXISTS (
194
195
  SELECT 1
@@ -10,8 +10,11 @@ const CAPS = {
10
10
  identityOpsTotal: 6,
11
11
  identityOpsPerAgent: 1,
12
12
  memoryStore: 5,
13
- memoryEdit: 5,
13
+ // 5 for the lanes that existed before + memoryCorrections, since a confirmed correction is an edit.
14
+ memoryEdit: 15,
14
15
  memoryDelete: 10,
16
+ // Memories per night in swarm.memory.corrections (explicit-self rating notes). About 3 new notes a day.
17
+ memoryCorrections: 10,
15
18
  skillCreate: 2,
16
19
  skillUpdate: 6,
17
20
  scriptSpecs: 2,
@@ -473,6 +476,156 @@ export default async function (args: unknown, ctx: ScriptContext) {
473
476
  // memories had long titles. A newline in a name is the real defect.
474
477
  [win],
475
478
  );
479
+ // Correction queue: explicit-self ratings whose note says a manual memory is wrong or stale. One item per memory,
480
+ // oldest unhandled note first. Handled = the memory has a version newer than the rating (edited), or a non-dry
481
+ // synthesis already ruled on the rating: a rejected[] item from "swarm.memory.corrections" naming "rating:<id>"
482
+ // with a non-cap reason, or a propose action whose evidence cites "rating:<id>". Cap overflow and edits apply
483
+ // refused leave no marker, so they come back the next night.
484
+ // A rating on a later chunk counts for its document: it maps to chunk 0 by the same match dreaming-apply uses
485
+ // (name, agent, chunk count, write minute). A single-chunk body is sent whole, since synthesis may replace it;
486
+ // one longer than CORR_SINGLE_MAX is held out of the queue (counted in `oversize`) instead of being truncated.
487
+ // A body the egress scrubber rewrote is held out too (counted in `scrubbed`): synthesis could copy its
488
+ // "[REDACTED:<key>]" marker into a replace, and apply's scrubberGuard credits markers in the op content, so the
489
+ // original text would be lost. SQL length() is a number, so the scrubber leaves it alone; a changed code-point
490
+ // count catches a rewrite even when no marker text survives.
491
+ const CORR_SINGLE_MAX = 8000;
492
+ const scrubbedRead = (text: string, rawLen: unknown) =>
493
+ text.includes("[REDACTED") || [...text].length !== Number(rawLen ?? 0);
494
+ const corrWf = await q(
495
+ "correctionsWorkflow",
496
+ `SELECT COALESCE((SELECT workflowId FROM workflow_runs WHERE id = ?),
497
+ (SELECT id FROM workflows WHERE name = 'dreaming' ORDER BY createdAt ASC LIMIT 1)) wf`,
498
+ [a.runId ?? ""],
499
+ );
500
+ // The scrubber rewrites a body after the query returns, so a held-out memory is only known here. Page by
501
+ // excluding every memory already read: a run of scrubbed or held memories at the head of the queue can no
502
+ // longer fill the window and starve the clean corrections behind it night after night.
503
+ const corrPage = (seen: string[]) => q(
504
+ "memCorrections",
505
+ `WITH syn AS MATERIALIZED (
506
+ SELECT json_extract(s.output, '$.taskOutput') o FROM workflow_run_steps s JOIN workflow_runs r ON r.id = s.runId
507
+ WHERE r.workflowId = ? AND s.nodeId = 'synthesize' AND s.runId <> ? AND json_valid(s.output)
508
+ AND COALESCE(CASE WHEN json_valid(r.triggerData) THEN json_type(r.triggerData, '$.dryRun') = 'true'
509
+ OR json_extract(r.triggerData, '$.dryRun') = 'true' END, 0) = 0),
510
+ handled AS MATERIALIZED (
511
+ SELECT json_extract(j.value, '$.item') ref FROM syn, json_each(syn.o, '$.rejected') j
512
+ WHERE j.type = 'object' AND json_extract(j.value, '$.from') = 'swarm.memory.corrections'
513
+ AND COALESCE(json_extract(j.value, '$.reason'), '') NOT GLOB 'cap*'
514
+ UNION
515
+ SELECT e.value FROM syn, json_each(syn.o, '$.actions') x, json_each(x.value, '$.evidence') e
516
+ WHERE x.type = 'object' AND json_extract(x.value, '$.tier') = 'propose' AND e.type = 'text' AND e.value GLOB 'rating:*'),
517
+ rated AS MATERIALIZED (
518
+ SELECT r.id ratingId, r.memoryId ratedId, r.taskId, r.signal, r.reasoning, r.createdAt ratedAt,
519
+ CASE WHEN COALESCE(c.chunkIndex, 0) = 0 THEN c.id ELSE (
520
+ SELECT h.id FROM agent_memory h WHERE h.name = c.name AND h.agentId IS c.agentId AND h.source = 'manual'
521
+ AND COALESCE(h.chunkIndex, 0) = 0 AND COALESCE(h.totalChunks, 1) = COALESCE(c.totalChunks, 1)
522
+ AND substr(h.createdAt, 1, 16) = substr(c.createdAt, 1, 16) ORDER BY h.createdAt, h.id LIMIT 1) END docId
523
+ FROM memory_rating r JOIN agent_memory c ON c.id = r.memoryId
524
+ WHERE r.source = 'explicit-self' AND r.signal < 0 AND length(trim(COALESCE(r.reasoning, ''))) > 0
525
+ AND c.source = 'manual'),
526
+ q AS MATERIALIZED (
527
+ SELECT r.ratingId, r.docId memoryId, r.ratedId, r.taskId, r.signal, r.reasoning, r.ratedAt,
528
+ m.name, m.agentId, m.scope, m.version, m.alpha, m.beta, m.createdAt memCreatedAt, m.content, length(m.content) rawLen,
529
+ COALESCE(m.totalChunks, 1) totalChunks,
530
+ (COALESCE(m.totalChunks, 1) = 1 AND length(m.content) > ?) big,
531
+ ROW_NUMBER() OVER (PARTITION BY r.docId ORDER BY r.ratedAt DESC) rn,
532
+ MIN(r.ratedAt) OVER (PARTITION BY r.docId) firstAt
533
+ FROM rated r JOIN agent_memory m ON m.id = r.docId
534
+ WHERE julianday(r.ratedAt) > julianday(COALESCE(
535
+ (SELECT MAX(v.createdAt) FROM agent_memory_version v WHERE v.memory_id = m.id), m.createdAt))
536
+ AND ('rating:' || r.ratingId) NOT IN (SELECT ref FROM handled WHERE ref IS NOT NULL))
537
+ -- The counts row survives an empty pick (memoryId NULL), so oversize-only backlogs still report.
538
+ SELECT f.*, s.backlog, s.oversize
539
+ FROM (SELECT COUNT(DISTINCT memoryId) backlog, COUNT(DISTINCT CASE WHEN big THEN memoryId END) oversize FROM q) s
540
+ LEFT JOIN (SELECT * FROM q WHERE rn <= 3 AND memoryId IN (
541
+ SELECT memoryId FROM q WHERE rn = 1 AND NOT big
542
+ AND memoryId NOT IN (SELECT value FROM json_each(?)) ORDER BY firstAt ASC, memoryId LIMIT ?)) f ON 1
543
+ ORDER BY f.firstAt ASC, f.memoryId, f.rn`,
544
+ [String(corrWf?.[0]?.wf ?? ""), a.runId ?? "", CORR_SINGLE_MAX, JSON.stringify(seen), CAPS.memoryCorrections * 2],
545
+ );
546
+ // Each page adds only unseen memories, so the loop ends when the queue is exhausted. The page guard is a
547
+ // runaway stop: 50 pages x 20 memories is ten times the backlog seen in prod.
548
+ const CORR_MAX_PAGES = 50;
549
+ // ok false = a page query failed, so the items read so far are not the whole queue.
550
+ let corrOk = !!corrWf;
551
+ let corrCounts: any = null;
552
+ const corrSeen: string[] = [];
553
+ // Multi-chunk bodies may be cut for the prompt: apply refuses edits to them, so they only become proposals.
554
+ const CORR_BODY_MAX = 3000;
555
+ const corrItems: any[] = [];
556
+ const corrHeld = new Set<string>();
557
+ const corrScrubbed = new Set<string>();
558
+ for (let page = 0; corrOk && page < CORR_MAX_PAGES && corrItems.length < CAPS.memoryCorrections; page++) {
559
+ const rows = await corrPage(corrSeen);
560
+ if (rows === null) {
561
+ corrOk = false;
562
+ break;
563
+ }
564
+ corrCounts ??= rows[0] ?? null;
565
+ const fresh = [...new Set(rows.map((r: any) => r.memoryId).filter((id: unknown) => id != null))] as string[];
566
+ if (!fresh.length) break;
567
+ corrSeen.push(...fresh);
568
+ for (const r of rows) {
569
+ if (r.memoryId == null || corrHeld.has(r.memoryId) || corrScrubbed.has(r.memoryId)) continue;
570
+ let item = corrItems.find((x) => x.memoryId === r.memoryId);
571
+ if (!item) {
572
+ if (corrItems.length >= CAPS.memoryCorrections) continue;
573
+ let body = String(r.content ?? "");
574
+ const totalChunks = Number(r.totalChunks);
575
+ // SQLite length() counts code points and JS counts UTF-16 units: re-check, never send a cut single-chunk body.
576
+ if (totalChunks <= 1 && body.length > CORR_SINGLE_MAX) {
577
+ corrHeld.add(r.memoryId);
578
+ continue;
579
+ }
580
+ let joined = totalChunks <= 1;
581
+ if (totalChunks > 1) {
582
+ // Same document match as dreaming-apply (name, agent, chunk count), pinned to chunk 0's write minute.
583
+ const parts = await q(
584
+ "memCorrectionChunks",
585
+ `SELECT content, length(content) rawLen FROM agent_memory WHERE name = ? AND agentId IS ? AND source = 'manual'
586
+ AND COALESCE(totalChunks, 1) = ? AND substr(createdAt, 1, 16) = substr(?, 1, 16) ORDER BY chunkIndex ASC`,
587
+ [r.name, r.agentId ?? null, totalChunks, r.memCreatedAt],
588
+ );
589
+ if (parts?.length) body = joinChunks(parts.map((x: any) => String(x.content ?? "")));
590
+ joined = parts?.length === totalChunks;
591
+ if (parts?.some((x: any) => scrubbedRead(String(x.content ?? ""), x.rawLen))) {
592
+ corrScrubbed.add(r.memoryId);
593
+ continue;
594
+ }
595
+ }
596
+ if (scrubbedRead(String(r.content ?? ""), r.rawLen)) {
597
+ corrScrubbed.add(r.memoryId);
598
+ continue;
599
+ }
600
+ const cut = totalChunks > 1 && body.length > CORR_BODY_MAX;
601
+ item = {
602
+ memoryId: r.memoryId,
603
+ name: r.name,
604
+ agentId: r.agentId ?? null,
605
+ scope: r.scope,
606
+ version: Number(r.version ?? 1),
607
+ alpha: Number(r.alpha),
608
+ beta: Number(r.beta),
609
+ totalChunks,
610
+ multiChunk: totalChunks > 1,
611
+ content: cut ? body.slice(0, CORR_BODY_MAX) : body,
612
+ // true = the body shown is not the whole memory (cut for the prompt, or a chunk read came back short).
613
+ contentTruncated: cut || !joined,
614
+ notes: [],
615
+ };
616
+ corrItems.push(item);
617
+ }
618
+ item.notes.push({
619
+ ratingId: r.ratingId,
620
+ // The chunk row the agent rated; differs from memoryId when the rating was on a later chunk.
621
+ ratedMemoryId: r.ratedId,
622
+ taskId: r.taskId ?? null,
623
+ signal: Number(r.signal),
624
+ ratedAt: r.ratedAt,
625
+ note: String(r.reasoning ?? "").slice(0, 1000),
626
+ });
627
+ }
628
+ }
476
629
  const created = await q(
477
630
  "memCreatedInWindow",
478
631
  `SELECT source, COUNT(*) n FROM agent_memory WHERE julianday(createdAt) > julianday('now', ?) GROUP BY source`,
@@ -487,6 +640,17 @@ export default async function (args: unknown, ctx: ScriptContext) {
487
640
  })),
488
641
  unhelpful: unhelpful ?? [],
489
642
  badKeys: badKeys ?? [],
643
+ // ok false = a queue page failed, so the list may be short or empty; it is not "nothing to correct".
644
+ corrections: {
645
+ ok: corrOk,
646
+ cap: CAPS.memoryCorrections,
647
+ backlog: Number(corrCounts?.backlog ?? 0),
648
+ // Single-chunk memories over CORR_SINGLE_MAX chars: held out, never sent cut (synthesis could replace them).
649
+ oversize: Number(corrCounts?.oversize ?? 0) + corrHeld.size,
650
+ // Memories whose body came back scrubbed: held out, never sent (a replace would persist the marker).
651
+ scrubbed: corrScrubbed.size,
652
+ items: corrItems,
653
+ },
490
654
  createdInWindow: {
491
655
  manual: cnt("manual"),
492
656
  taskCompletion: cnt("task_completion"),
@@ -23,7 +23,11 @@ export default async function waitForTask(args: any, ctx: any) {
23
23
  const t: any = await ctx.swarm.task_get({ taskId });
24
24
  const d = t?.data ?? t ?? {};
25
25
  last = { status: d.status ?? null, output: d.output ?? null };
26
- if (["completed", "failed", "cancelled", "skipped"].includes(String(last.status))) {
26
+ // A workflow step whose supersede cut got a retry moves from failed to
27
+ // superseded with no resume to follow; it is as settled as the failure was.
28
+ const cutWithRetry =
29
+ last.status === "superseded" && d.failureReason === "superseded_workflow_task";
30
+ if (cutWithRetry || ["completed", "failed", "cancelled", "skipped"].includes(String(last.status))) {
27
31
  return { done: true, ...last };
28
32
  }
29
33
  await new Promise((r) => setTimeout(r, 2000));
@@ -250,6 +250,8 @@ import tddPlanningConfig from "../../../templates/skills/tdd-planning/config.jso
250
250
  import tddPlanningContent from "../../../templates/skills/tdd-planning/content.md" with {
251
251
  type: "text",
252
252
  };
253
+ import uiSpecConfig from "../../../templates/skills/ui-spec/config.json" with { type: "text" };
254
+ import uiSpecContent from "../../../templates/skills/ui-spec/content.md" with { type: "text" };
253
255
  import vImplementingConfig from "../../../templates/skills/v-implementing/config.json" with {
254
256
  type: "text",
255
257
  };
@@ -390,6 +392,7 @@ const BUILT_IN_SKILL_SOURCES = [
390
392
  { config: tackleGhCommentsConfig, body: tackleGhCommentsContent },
391
393
  { config: tasteMinimalistSkillConfig, body: tasteMinimalistSkillContent },
392
394
  { config: tddPlanningConfig, body: tddPlanningContent },
395
+ { config: uiSpecConfig, body: uiSpecContent },
393
396
  { config: vImplementingConfig, body: vImplementingContent },
394
397
  { config: vPlanningConfig, body: vPlanningContent },
395
398
  { config: verifyingConfig, body: verifyingContent },
@@ -3,6 +3,10 @@ import { parseTelemetryRanking, TELEMETRY_RANKING_KEY } from "../ranking/telemet
3
3
  import { validateQuickJSPoolSize } from "../scripts-runtime/executors/quickjs-pool-config";
4
4
  import { normalizeSlackReactionShortcode } from "../slack/reaction-shortcode";
5
5
  import { ProviderNameSchema } from "../types";
6
+ import {
7
+ UI_SPEC_SCRIPT_ACTIONS_KEY,
8
+ validateScriptActionAllowlist,
9
+ } from "../ui-spec/script-allowlist";
6
10
  import { API_DRAIN_MAX_MS_LIMIT } from "../utils/api-drain";
7
11
  import {
8
12
  COMPANY_ACQUISITION_SOURCES,
@@ -115,6 +119,35 @@ export function internalConfigKeyError(key: string): Error {
115
119
  return new Error(`Key '${key}' is managed by ${owner}`);
116
120
  }
117
121
 
122
+ /**
123
+ * Keys only an admin user (a user token or dashboard session) may write or
124
+ * delete: never an agent, the Lead included, a guest, or the shared operator
125
+ * key, which every worker holds. The deployment env can still seed them.
126
+ * `UI_SPEC_SCRIPT_ACTIONS` decides which scripts a card button may run.
127
+ *
128
+ * shortcut: this stops direct writes, not a determined holder of the
129
+ * operator key. That key is root: it can create an admin user and mint a
130
+ * token for it (`POST /api/users`, `/mcp-tokens`). Such a holder gains
131
+ * nothing from a pin, because a script action runs as the card's own agent,
132
+ * which the key can already act as. Upgrade to an anchor the key cannot mint
133
+ * (deployment-env only, or an out-of-band human approval) if workers stop
134
+ * holding the operator key.
135
+ */
136
+ const HUMAN_ONLY_CONFIG_KEYS = new Set([UI_SPEC_SCRIPT_ACTIONS_KEY]);
137
+
138
+ export function isHumanOnlyConfigKey(key: string): boolean {
139
+ return HUMAN_ONLY_CONFIG_KEYS.has(key.toUpperCase());
140
+ }
141
+
142
+ export function humanOnlyConfigKeyError(key: string): string {
143
+ return `Key '${key}' can only be changed by an admin user (a user token or dashboard session). Agents and the shared API key cannot change it.`;
144
+ }
145
+
146
+ /** A page session acts for its viewer but runs the page author's code. */
147
+ export function humanOnlyConfigKeyPageError(key: string): string {
148
+ return `Key '${key}' cannot be changed from a page session. Change it from the dashboard or with a user token.`;
149
+ }
150
+
118
151
  export function isReservedConfigKey(key: string): boolean {
119
152
  return RESERVED_KEYS.has(key.toUpperCase());
120
153
  }
@@ -347,6 +380,27 @@ export function validateTaskAutoTitleModel(value: unknown): string | null {
347
380
  : "Invalid TASK_AUTO_TITLE_MODEL (provider must be openrouter, anthropic, openai, or openai-codex)";
348
381
  }
349
382
 
383
+ /**
384
+ * Docker runtime isolation keys. Empty clears the key. The Docker adapter
385
+ * applies the same rules (`src/runtime-providers/docker.ts`), so a value
386
+ * this guard accepts never fails `checkConfig`.
387
+ */
388
+ export function validateDockerRuntime(value: unknown): string | null {
389
+ if (typeof value !== "string") return "Invalid DOCKER_RUNTIME (must be a string)";
390
+ const name = value.trim();
391
+ return !name || /^[A-Za-z0-9._-]+$/.test(name)
392
+ ? null
393
+ : "Invalid DOCKER_RUNTIME (use an OCI runtime name: letters, digits, '.', '-', '_')";
394
+ }
395
+
396
+ export function validateDockerPidsLimit(value: unknown): string | null {
397
+ if (typeof value !== "string") return "Invalid DOCKER_PIDS_LIMIT (must be a string)";
398
+ const limit = value.trim();
399
+ return !limit || (/^[1-9]\d*$/.test(limit) && Number.isSafeInteger(Number(limit)))
400
+ ? null
401
+ : "Invalid DOCKER_PIDS_LIMIT (must be a positive integer, or empty)";
402
+ }
403
+
350
404
  export const validateControllerTokenTtlDays = boundedIntegerValidators(
351
405
  ["RUNTIME_CONTROLLER_TOKEN_TTL_DAYS"],
352
406
  1,
@@ -360,7 +414,10 @@ export const validateControllerGraceSec = boundedIntegerValidators(
360
414
  ).RUNTIME_CONTROLLER_GRACE_SEC!;
361
415
 
362
416
  const VALIDATED_KEYS: Record<string, ConfigValidator> = {
363
- ...booleanValidators(["RUNTIME_POOLS_ENABLED"]),
417
+ [UI_SPEC_SCRIPT_ACTIONS_KEY]: validateScriptActionAllowlist,
418
+ ...booleanValidators(["RUNTIME_POOLS_ENABLED", "DOCKER_HARDENED"]),
419
+ DOCKER_RUNTIME: validateDockerRuntime,
420
+ DOCKER_PIDS_LIMIT: validateDockerPidsLimit,
364
421
  ...enumValidator("RUNTIME_DEFAULT_DELIVERY", ["poll", "push"]),
365
422
  RUNTIME_TOKEN_TTL_HOURS: validateRuntimeTokenTtlHours,
366
423
  RUNTIME_CONTROLLER_TOKEN_TTL_DAYS: validateControllerTokenTtlDays,
@@ -0,0 +1,259 @@
1
+ import * as z from "zod";
2
+ import { scrubSecrets } from "../utils/secret-scrubber";
3
+ import type { TaskUiSpec } from "../utils/task-ui-spec";
4
+ import { getDbClient } from "./db";
5
+ import { scrubJsonValue } from "./scrub-json";
6
+
7
+ /** The stored task UI spec, as task and session payloads return it. */
8
+ export const TaskUiSpecSchema = z.object({
9
+ spec: z.object({
10
+ root: z.string(),
11
+ elements: z.record(z.string(), z.unknown()),
12
+ state: z.record(z.string(), z.unknown()).optional(),
13
+ }),
14
+ actions: z
15
+ .record(
16
+ z.string(),
17
+ z.discriminatedUnion("kind", [
18
+ z.object({ kind: z.literal("follow_up"), prompt: z.string() }),
19
+ z.object({
20
+ kind: z.literal("script"),
21
+ script: z.string(),
22
+ args: z.record(z.string(), z.unknown()).optional(),
23
+ }),
24
+ ]),
25
+ )
26
+ .optional(),
27
+ fallbackText: z.string(),
28
+ });
29
+
30
+ export type TaskUiActionSurface = "slack" | "web";
31
+
32
+ type TaskUiSpecRow = {
33
+ taskId: string;
34
+ spec: string;
35
+ actions: string | null;
36
+ fallbackText: string;
37
+ };
38
+
39
+ function rowToTaskUiSpec(row: TaskUiSpecRow): TaskUiSpec {
40
+ const value: TaskUiSpec = { spec: JSON.parse(row.spec), fallbackText: row.fallbackText };
41
+ if (row.actions !== null) value.actions = JSON.parse(row.actions);
42
+ return value;
43
+ }
44
+
45
+ export async function getTaskUiSpec(taskId: string): Promise<TaskUiSpec | null> {
46
+ const row = await getDbClient().get<TaskUiSpecRow>(
47
+ `SELECT task_id AS taskId, spec, actions, fallback_text AS fallbackText
48
+ FROM task_ui_specs WHERE task_id = ?`,
49
+ [taskId],
50
+ );
51
+ return row ? rowToTaskUiSpec(row) : null;
52
+ }
53
+
54
+ /** Bound-parameter chunk for `IN (...)`, well under SQLite's variable limit. */
55
+ const TASK_ID_CHUNK = 500;
56
+
57
+ /**
58
+ * Batched {@link getTaskUiSpec}: one query per 500 task ids. Every requested
59
+ * id is a key; a task with no spec maps to `null`.
60
+ */
61
+ export async function getTaskUiSpecsForTasks(
62
+ taskIds: string[],
63
+ ): Promise<Map<string, TaskUiSpec | null>> {
64
+ const ids = [...new Set(taskIds)];
65
+ const byTask = new Map<string, TaskUiSpec | null>(ids.map((id) => [id, null]));
66
+ for (let i = 0; i < ids.length; i += TASK_ID_CHUNK) {
67
+ const chunk = ids.slice(i, i + TASK_ID_CHUNK);
68
+ const rows = await getDbClient().query<TaskUiSpecRow>(
69
+ `SELECT task_id AS taskId, spec, actions, fallback_text AS fallbackText
70
+ FROM task_ui_specs WHERE task_id IN (${chunk.map(() => "?").join(",")})`,
71
+ chunk,
72
+ );
73
+ for (const row of rows) byTask.set(row.taskId, rowToTaskUiSpec(row));
74
+ }
75
+ return byTask;
76
+ }
77
+
78
+ /**
79
+ * One spec per task: a second upsert replaces the first. Secrets are
80
+ * redacted before the write, so Slack, Linear and Jira, which read the
81
+ * stored row, never see them.
82
+ */
83
+ export async function upsertTaskUiSpec(
84
+ taskId: string,
85
+ value: TaskUiSpec,
86
+ userId?: string,
87
+ ): Promise<void> {
88
+ await getDbClient().run(
89
+ `INSERT INTO task_ui_specs (task_id, spec, actions, fallback_text, created_by, updated_by)
90
+ VALUES (?, ?, ?, ?, ?, ?)
91
+ ON CONFLICT(task_id) DO UPDATE SET
92
+ spec=excluded.spec, actions=excluded.actions, fallback_text=excluded.fallback_text,
93
+ updated_by=excluded.updated_by, updated_at=strftime('%Y-%m-%dT%H:%M:%fZ', 'now')`,
94
+ [
95
+ taskId,
96
+ scrubJsonValue(value.spec),
97
+ value.actions === undefined ? null : scrubJsonValue(value.actions),
98
+ scrubSecrets(value.fallbackText),
99
+ userId ?? null,
100
+ userId ?? null,
101
+ ],
102
+ );
103
+ }
104
+
105
+ /**
106
+ * Reserves the one run of an action before its side effect. Returns
107
+ * `"exists"` when the action already ran (or is running) for this task.
108
+ */
109
+ export async function reserveTaskUiActionRun({
110
+ taskId,
111
+ actionId,
112
+ surface,
113
+ slackUserId,
114
+ userId,
115
+ }: {
116
+ taskId: string;
117
+ actionId: string;
118
+ surface: TaskUiActionSurface;
119
+ slackUserId?: string | null;
120
+ userId?: string | null;
121
+ }): Promise<"reserved" | "exists"> {
122
+ const { changes } = await getDbClient().run(
123
+ `INSERT INTO task_ui_action_runs
124
+ (task_id, action_id, surface, slack_user_id, created_by, updated_by)
125
+ VALUES (?, ?, ?, ?, ?, ?)
126
+ ON CONFLICT(task_id, action_id) DO NOTHING`,
127
+ [taskId, actionId, surface, slackUserId ?? null, userId ?? null, userId ?? null],
128
+ );
129
+ return changes === 1 ? "reserved" : "exists";
130
+ }
131
+
132
+ /**
133
+ * Drops a reservation whose follow-up task never started, so the button can
134
+ * run again. A finished run (with a result task) stays.
135
+ */
136
+ export async function releaseTaskUiActionRun(taskId: string, actionId: string): Promise<void> {
137
+ await getDbClient().run(
138
+ `DELETE FROM task_ui_action_runs
139
+ WHERE task_id = ? AND action_id = ? AND result_task_id IS NULL`,
140
+ [taskId, actionId],
141
+ );
142
+ }
143
+
144
+ export async function setTaskUiActionResult(
145
+ taskId: string,
146
+ actionId: string,
147
+ resultTaskId: string,
148
+ ): Promise<void> {
149
+ await getDbClient().run(
150
+ `UPDATE task_ui_action_runs SET result_task_id = ?,
151
+ updated_at = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
152
+ WHERE task_id = ? AND action_id = ?`,
153
+ [resultTaskId, taskId, actionId],
154
+ );
155
+ }
156
+
157
+ export type TaskUiScriptActionLock =
158
+ | { status: "acquired" }
159
+ | { status: "running" | "rate_limited"; retryAfterSec: number };
160
+
161
+ /**
162
+ * Takes the lease of a repeatable `script` action in one statement, so it
163
+ * holds across API processes that share the DB file. Refuses while another
164
+ * run holds an unexpired lease, or inside the cooldown after the last run.
165
+ * A follow-up row (with a result task) is never taken over.
166
+ */
167
+ export async function acquireTaskUiScriptActionRun({
168
+ taskId,
169
+ actionId,
170
+ surface,
171
+ slackUserId,
172
+ userId,
173
+ leaseMs,
174
+ cooldownMs,
175
+ nowMs = Date.now(),
176
+ }: {
177
+ taskId: string;
178
+ actionId: string;
179
+ surface: TaskUiActionSurface;
180
+ slackUserId?: string | null;
181
+ userId?: string | null;
182
+ leaseMs: number;
183
+ cooldownMs: number;
184
+ nowMs?: number;
185
+ }): Promise<TaskUiScriptActionLock> {
186
+ // ISO strings in the strftime('%Y-%m-%dT%H:%M:%fZ') shape compare as text.
187
+ const now = new Date(nowMs).toISOString();
188
+ const lockedUntil = new Date(nowMs + leaseMs).toISOString();
189
+ const cooldownCutoff = new Date(nowMs - cooldownMs).toISOString();
190
+ const { changes } = await getDbClient().run(
191
+ `INSERT INTO task_ui_action_runs
192
+ (task_id, action_id, surface, slack_user_id, created_by, updated_by, locked_until)
193
+ VALUES (?, ?, ?, ?, ?, ?, ?)
194
+ ON CONFLICT(task_id, action_id) DO UPDATE SET
195
+ locked_until = excluded.locked_until, surface = excluded.surface,
196
+ slack_user_id = excluded.slack_user_id, updated_by = excluded.updated_by, updated_at = ?
197
+ WHERE task_ui_action_runs.result_task_id IS NULL
198
+ AND (task_ui_action_runs.locked_until IS NULL OR task_ui_action_runs.locked_until < ?)
199
+ AND (task_ui_action_runs.last_run_at IS NULL OR task_ui_action_runs.last_run_at < ?)`,
200
+ [
201
+ taskId,
202
+ actionId,
203
+ surface,
204
+ slackUserId ?? null,
205
+ userId ?? null,
206
+ userId ?? null,
207
+ lockedUntil,
208
+ now,
209
+ now,
210
+ cooldownCutoff,
211
+ ],
212
+ );
213
+ if (changes === 1) return { status: "acquired" };
214
+
215
+ const row = await getDbClient().get<{ lockedUntil: string | null; lastRunAt: string | null }>(
216
+ `SELECT locked_until AS lockedUntil, last_run_at AS lastRunAt
217
+ FROM task_ui_action_runs WHERE task_id = ? AND action_id = ?`,
218
+ [taskId, actionId],
219
+ );
220
+ const secondsUntil = (ms: number) => Math.max(1, Math.ceil((ms - nowMs) / 1000));
221
+ if (row?.lockedUntil && row.lockedUntil >= now) {
222
+ return { status: "running", retryAfterSec: secondsUntil(Date.parse(row.lockedUntil)) };
223
+ }
224
+ if (row?.lastRunAt && row.lastRunAt >= cooldownCutoff) {
225
+ return {
226
+ status: "rate_limited",
227
+ retryAfterSec: secondsUntil(Date.parse(row.lastRunAt) + cooldownMs),
228
+ };
229
+ }
230
+ return { status: "running", retryAfterSec: 1 };
231
+ }
232
+
233
+ /** Ends a script run: frees the lease and records when it ran and how. */
234
+ export async function finishTaskUiScriptActionRun(
235
+ taskId: string,
236
+ actionId: string,
237
+ error: string | null,
238
+ ): Promise<void> {
239
+ const now = new Date().toISOString();
240
+ await getDbClient().run(
241
+ `UPDATE task_ui_action_runs SET locked_until = NULL, last_run_at = ?,
242
+ run_count = run_count + 1, last_error = ?, updated_at = ?
243
+ WHERE task_id = ? AND action_id = ?`,
244
+ [now, error === null ? null : scrubSecrets(error), now, taskId, actionId],
245
+ );
246
+ }
247
+
248
+ /**
249
+ * The completion uiSpec check refuses at most once per task. The refusal is
250
+ * an `agent_log` row, so it also shows in the task's activity timeline.
251
+ */
252
+ export async function hasTaskUiSpecCheckRefusal(taskId: string): Promise<boolean> {
253
+ return Boolean(
254
+ await getDbClient().get<{ id: string }>(
255
+ "SELECT id FROM agent_log WHERE taskId = ? AND eventType = 'task_ui_spec_check_refused' LIMIT 1",
256
+ [taskId],
257
+ ),
258
+ );
259
+ }