@desplega.ai/agent-swarm 2.7.7 → 2.7.8

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 (251) hide show
  1. package/dist/{acp-adapter-7b4vk3h5.js → acp-adapter-vg5hqkvj.js} +6 -6
  2. package/dist/{actions-3tt153af.js → actions-4m1ct4nh.js} +18 -18
  3. package/dist/{amp-adapter-njpts0yr.js → amp-adapter-txqh7eqj.js} +2 -2
  4. package/dist/{app-nky4378f.js → app-e00m45gn.js} +3 -3
  5. package/dist/{assistant-jnb669pa.js → assistant-gd08kr9e.js} +20 -20
  6. package/dist/boot-args-schema-tjrkpbvm.js +89 -0
  7. package/dist/{boot-reembed-9mgvaztt.js → boot-reembed-21hbck22.js} +1 -1
  8. package/dist/{boot-reembed-qs2djdej.js → boot-reembed-mdxd3wgp.js} +1 -1
  9. package/dist/{boot-scrub-sweep-yjpdj7s1.js → boot-scrub-sweep-qy0zr9t2.js} +3 -3
  10. package/dist/{boot-seeds-5cm6ambd.js → boot-seeds-n46eaxdv.js} +4 -4
  11. package/dist/{claude-adapter-fn287zmm.js → claude-adapter-j37w2eds.js} +6 -6
  12. package/dist/{claude-managed-adapter-dvs2xw5n.js → claude-managed-adapter-8jvcma9a.js} +3 -3
  13. package/dist/{claude-managed-setup-wtdz2mj2.js → claude-managed-setup-rzkjmgc1.js} +3 -3
  14. package/dist/{claude-sdk-session-x91kqyhm.js → claude-sdk-session-4k7w73t0.js} +7 -7
  15. package/dist/{cli-rtt8g4v9.js → cli-0ykgn1h5.js} +1 -1
  16. package/dist/{cli-5b456bpf.js → cli-1cxrbkk6.js} +2 -2
  17. package/dist/{cli-5jnhv72d.js → cli-269q28a1.js} +4 -2
  18. package/dist/{cli-k1nje3v3.js → cli-32m9eda8.js} +49 -37
  19. package/dist/{cli-35rsp8ye.js → cli-3e4snnzf.js} +1 -1
  20. package/dist/{cli-5zx699j9.js → cli-4t50yq3j.js} +2 -2
  21. package/dist/{cli-n6bv12jn.js → cli-5j0m12ns.js} +10 -3
  22. package/dist/{cli-dhar9qay.js → cli-5ja3b75e.js} +2 -2
  23. package/dist/{cli-g08zdaec.js → cli-66ww7fer.js} +1 -1
  24. package/dist/{cli-nmzhp1b5.js → cli-7axf41jq.js} +25 -14
  25. package/dist/{cli-gz6q4eve.js → cli-84rj785g.js} +5 -5
  26. package/dist/{cli-fyt2g4wd.js → cli-85gzce7b.js} +5 -5
  27. package/dist/{cli-3fg0bdcv.js → cli-8h0ayw8c.js} +1 -1
  28. package/dist/{cli-qghe0h66.js → cli-8rpcng8j.js} +2 -2
  29. package/dist/{cli-ws19768n.js → cli-8sdejs1f.js} +115 -51
  30. package/dist/{cli-8305gbq0.js → cli-9m8hdawy.js} +3 -3
  31. package/dist/{cli-excnnjg2.js → cli-ae0dnfee.js} +1 -1
  32. package/dist/{cli-e0kmphd6.js → cli-bb0mmdk8.js} +2 -2
  33. package/dist/{cli-1c6tzt8g.js → cli-bbw9wj9m.js} +8 -8
  34. package/dist/{cli-pjctyea3.js → cli-bshb7jas.js} +2 -2
  35. package/dist/{cli-08bmz9z9.js → cli-btfsp3mv.js} +3 -3
  36. package/dist/{cli-4zsenjhy.js → cli-c0kqky8y.js} +16 -3
  37. package/dist/{cli-tgrv9cjx.js → cli-dq8x79v8.js} +1 -1
  38. package/dist/{cli-ftyxyspd.js → cli-eqtfgfr6.js} +1 -1
  39. package/dist/{cli-ddaanqkd.js → cli-eyg1pa00.js} +3 -3
  40. package/dist/{cli-8sckt74b.js → cli-fyhr5h4s.js} +34 -12
  41. package/dist/{cli-q3tkegby.js → cli-fzachfnf.js} +1 -1
  42. package/dist/{cli-ayayvfg4.js → cli-ga786dzg.js} +13 -10
  43. package/dist/{cli-yyj3j5m4.js → cli-gazw7kpa.js} +2 -2
  44. package/dist/{cli-e46hg0xw.js → cli-gvx71kqv.js} +2 -2
  45. package/dist/{cli-pc6n7fre.js → cli-jdv6ypxs.js} +1 -1
  46. package/dist/{cli-cm5yqn35.js → cli-kf3pxxdg.js} +1 -0
  47. package/dist/{cli-6g0hb4cp.js → cli-kyr67fgx.js} +7 -7
  48. package/dist/{cli-95jzxcp3.js → cli-m0hmeqma.js} +2 -2
  49. package/dist/{cli-6pfd54vx.js → cli-msg9m2ny.js} +3 -1
  50. package/dist/{cli-afkqkrtw.js → cli-nbsf8yvn.js} +15 -3
  51. package/dist/{cli-tfyyvzx6.js → cli-njwac61j.js} +5 -0
  52. package/dist/{cli-vz22fyqv.js → cli-nn3ysbqk.js} +1 -1
  53. package/dist/{cli-m0da8j35.js → cli-p3vsj0d3.js} +5 -5
  54. package/dist/{cli-72v799xn.js → cli-ppjxh6ah.js} +3 -3
  55. package/dist/{cli-k899ehvh.js → cli-q4ebh7h7.js} +4 -4
  56. package/dist/{cli-75gkpjvw.js → cli-qd57hhhh.js} +2 -2
  57. package/dist/{cli-qh4d4tvk.js → cli-rjknb2ae.js} +4 -4
  58. package/dist/{cli-caj33vcq.js → cli-s4ss5g59.js} +1 -1
  59. package/dist/{cli-cb2a8pna.js → cli-sq4n7af4.js} +1 -1
  60. package/dist/{cli-vfym7wmz.js → cli-ssnjfg5p.js} +5 -5
  61. package/dist/{cli-je518txm.js → cli-t60ajbbp.js} +8 -8
  62. package/dist/{cli-adeegh7d.js → cli-tpksw2nr.js} +21 -17
  63. package/dist/{cli-wk5yrfwd.js → cli-w4xnbm46.js} +150 -58
  64. package/dist/{cli-k8196sh2.js → cli-wemma3jd.js} +8 -7
  65. package/dist/{cli-cppkf404.js → cli-xq9r2wtt.js} +45 -21
  66. package/dist/{cli-bfv7vdg6.js → cli-xr8908my.js} +11 -11
  67. package/dist/{cli-73jzwksr.js → cli-ycscb2ar.js} +4 -1
  68. package/dist/{cli-p82cnnjq.js → cli-yqefz277.js} +1 -1
  69. package/dist/{cli-jtjtabxe.js → cli-z1srzaf6.js} +11 -3
  70. package/dist/{cli-pq73h5mz.js → cli-z75yxkjh.js} +3 -3
  71. package/dist/{cli-e5bzrn01.js → cli-zkky4t5g.js} +1 -1
  72. package/dist/cli.js +17 -15
  73. package/dist/{codex-adapter-cf2yxe9m.js → codex-adapter-88z6psm4.js} +5 -5
  74. package/dist/{codex-hook-a0c6g6t6.js → codex-hook-fac6175r.js} +1 -1
  75. package/dist/{codex-login-y0pmff1c.js → codex-login-74wa4hmq.js} +1 -1
  76. package/dist/{codex-session-runner-6vfzdgbd.js → codex-session-runner-zwbcwzvx.js} +5 -5
  77. package/dist/{commands-t3mfy7vn.js → commands-7amxs716.js} +3 -3
  78. package/dist/{controller-q7xrbaz0.js → controller-5rkkc37m.js} +2 -2
  79. package/dist/{controllers-connect-c6nm70kg.js → controllers-connect-m7d4vxxb.js} +19 -19
  80. package/dist/{cursor-adapter-ftd81ga8.js → cursor-adapter-x1q18693.js} +1 -1
  81. package/dist/{db-vemtpmcc.js → db-athc68zt.js} +4 -2
  82. package/dist/{db-dk572x25.js → db-h2fsfve3.js} +3 -3
  83. package/dist/{dispatcher-kh7ecxh9.js → dispatcher-b1yz2bnn.js} +17 -17
  84. package/dist/{dsh-adapter-v8628r89.js → dsh-adapter-e33bkxq9.js} +1 -1
  85. package/dist/{easter-egg-3d-nenw4x63.js → easter-egg-3d-pv5qnzc8.js} +1 -1
  86. package/dist/{embedding-space-0jepb239.js → embedding-space-b4txbwrk.js} +6 -6
  87. package/dist/{embeddings-xxt49yxg.js → embeddings-m6zn6tad.js} +1 -1
  88. package/dist/{execute-1mhw6e4x.js → execute-68nwny8m.js} +1 -1
  89. package/dist/{external-channel-55v12e60.js → external-channel-gkckmhzh.js} +2 -2
  90. package/dist/{fx-adapter-bs8wqrk5.js → fx-adapter-m5jbgd5q.js} +7 -7
  91. package/dist/{grok-adapter-gpjqmkcq.js → grok-adapter-csvv7sac.js} +7 -7
  92. package/dist/handlers-8x5gfbzx.js +32 -0
  93. package/dist/{heartbeat-k42svnr0.js → heartbeat-6c2y3267.js} +20 -20
  94. package/dist/{hook-6nphweh0.js → hook-q5fv0jy2.js} +6 -6
  95. package/dist/{hook-114m7hap.js → hook-w0q2wcrv.js} +5 -5
  96. package/dist/{http-r8cc4wz7.js → http-bxat8dg3.js} +260 -120
  97. package/dist/{index-nh3wyqdt.js → index-bxrexmfy.js} +13 -13
  98. package/dist/{index-e3s8wmxy.js → index-cqhqpgrv.js} +1 -1
  99. package/dist/{index-fpk4bcd9.js → index-fm0czesf.js} +1 -1
  100. package/dist/index-hpfte8jd.js +33 -0
  101. package/dist/index-ncf7yb5s.js +30 -0
  102. package/dist/index-vte6dyeh.js +37 -0
  103. package/dist/{keepalive-x060nt9p.js → keepalive-qnt21cv0.js} +3 -3
  104. package/dist/lead-4bvftzm6.js +71 -0
  105. package/dist/{maintenance-2xxfexhf.js → maintenance-btdr68y4.js} +1 -1
  106. package/dist/{oauth-refresh-sweep-fckc4ar5.js → oauth-refresh-sweep-vczabeh4.js} +2 -2
  107. package/dist/{onboard-zc48j237.js → onboard-k33ezyq8.js} +2 -2
  108. package/dist/{opencode-adapter-r690h1cr.js → opencode-adapter-3dst2ka7.js} +5 -5
  109. package/dist/{otel-impl-r5xbh81q.js → otel-impl-13am7a65.js} +1 -1
  110. package/dist/{pi-mono-adapter-c7v8sdec.js → pi-mono-adapter-c53de1gd.js} +15 -9
  111. package/dist/{pricing-refresh-3pmre11v.js → pricing-refresh-9fcbnq3f.js} +3 -3
  112. package/dist/{rbac-roles-910mmkgz.js → rbac-roles-66j5h4y5.js} +5 -3
  113. package/dist/{rbac-roles-3vbshwsb.js → rbac-roles-gw0p9h3j.js} +2 -2
  114. package/dist/{render-v2-pxykkbab.js → render-v2-fg8bmdn4.js} +3 -3
  115. package/dist/{resume-adda0bwy.js → resume-1c8kr3nh.js} +6 -6
  116. package/dist/{runtime-fnbm7stk.js → runtime-tzf9j7tc.js} +1 -1
  117. package/dist/{session-access-2fvamrdc.js → session-access-d0atq10j.js} +7 -5
  118. package/dist/{session-source-backfill-08xvv0sm.js → session-source-backfill-0vscqmsa.js} +2 -2
  119. package/dist/{setup-1aqmvmh1.js → setup-tvfa7rwe.js} +1 -1
  120. package/dist/{virtual-modules-d2pjk9j1.js → virtual-modules-efxcp740.js} +2 -2
  121. package/dist/{work-objects-9s0yrm5j.js → work-objects-ks71xqeb.js} +20 -20
  122. package/dist/worker-e7v2bvm9.js +71 -0
  123. package/dist/{worker-follow-up-3q78fqmr.js → worker-follow-up-bfx0h9hg.js} +17 -17
  124. package/openapi.json +104 -24
  125. package/package.json +3 -1
  126. package/src/be/db/model-profiles.ts +1 -1
  127. package/src/be/db/session-tree.ts +9 -5
  128. package/src/be/db/session-visibility.ts +25 -9
  129. package/src/be/db/tasks/read.ts +11 -6
  130. package/src/be/db/tasks/write.ts +77 -7
  131. package/src/be/db-queries/tracker.ts +4 -2
  132. package/src/be/db.ts +49 -17
  133. package/src/be/migrations/271_subscription_usage_model.sql +30 -0
  134. package/src/be/model-validation.ts +19 -1
  135. package/src/be/rbac-roles.ts +21 -0
  136. package/src/be/runtime-pools/routing.ts +1 -1
  137. package/src/be/scripts/boot-args-schema.ts +95 -0
  138. package/src/be/scripts/extract-schema.ts +15 -10
  139. package/src/be/seed-scripts/catalog/boot-triage.inline.ts +1 -1
  140. package/src/be/seed-scripts/catalog/boot-triage.ts +1 -1
  141. package/src/be/seed-scripts/catalog/get-child-outputs.ts +1 -1
  142. package/src/be/seed-scripts/catalog/wait-for-task.ts +1 -1
  143. package/src/be/swarm-config-guard.ts +7 -0
  144. package/src/be/users.ts +6 -4
  145. package/src/commands/claude-managed-setup.ts +1 -1
  146. package/src/commands/runner.ts +26 -9
  147. package/src/extensions/contract-types.generated.ts +1 -1
  148. package/src/http/agents.ts +7 -1
  149. package/src/http/approval-requests.ts +30 -6
  150. package/src/http/codex-oauth-device.ts +2 -2
  151. package/src/http/index.ts +8 -0
  152. package/src/http/mcp-oauth.ts +6 -0
  153. package/src/http/mcp-servers.ts +8 -0
  154. package/src/http/models-catalog.ts +1 -1
  155. package/src/http/pages-public.ts +38 -1
  156. package/src/http/poll.ts +3 -4
  157. package/src/http/prompt-templates.ts +1 -1
  158. package/src/http/schedules.ts +4 -0
  159. package/src/http/script-runs.ts +6 -1
  160. package/src/http/session-access.ts +61 -6
  161. package/src/http/sessions.ts +23 -7
  162. package/src/http/tasks.ts +53 -9
  163. package/src/http/users.ts +30 -1
  164. package/src/http/utils.ts +2 -1
  165. package/src/http/workflows.ts +11 -7
  166. package/src/prompts/session-templates.ts +1 -0
  167. package/src/providers/acp-targets.ts +1 -1
  168. package/src/providers/amp-adapter.ts +1 -1
  169. package/src/providers/codex-adapter.ts +9 -2
  170. package/src/providers/codex-oauth/device.ts +49 -15
  171. package/src/providers/codex-oauth/flow.ts +2 -1
  172. package/src/providers/pi-mono-adapter.ts +8 -0
  173. package/src/providers/pricing-sources.md +16 -1
  174. package/src/providers/swarm-events-shared.ts +15 -2
  175. package/src/rbac/legacy-policy.ts +1 -0
  176. package/src/rbac/permissions.ts +5 -0
  177. package/src/scheduler/deferred-task-waits.ts +9 -4
  178. package/src/scripts-runtime/extract-args-schema.ts +3 -1
  179. package/src/scripts-runtime/swarm-sdk.ts +1 -1
  180. package/src/scripts-runtime/types/swarm-extension.d.ts +29 -28
  181. package/src/server-user.ts +1 -1
  182. package/src/slack/ack.ts +48 -12
  183. package/src/slack/blocks.ts +1 -0
  184. package/src/slack/reaction-shortcode.ts +8 -2
  185. package/src/slack/render-v2.ts +30 -3
  186. package/src/slack/task-output.ts +4 -1
  187. package/src/slack/thread-buffer.ts +2 -2
  188. package/src/tasks/task-skip.ts +28 -0
  189. package/src/tasks/terminal-result-guard.ts +3 -2
  190. package/src/telemetry.ts +28 -1
  191. package/src/tests/agentmail-inbox-mapping.test.ts +73 -0
  192. package/src/tests/approval-requests.test.ts +58 -0
  193. package/src/tests/claude-managed-setup.test.ts +36 -0
  194. package/src/tests/codex-adapter.test.ts +2 -2
  195. package/src/tests/codex-oauth-device.test.ts +60 -0
  196. package/src/tests/codex-swarm-events.test.ts +43 -1
  197. package/src/tests/context-window.test.ts +14 -0
  198. package/src/tests/db-queries-tracker.test.ts +2 -1
  199. package/src/tests/db-task-read-contract.test.ts +1 -0
  200. package/src/tests/db-task-write-contract.test.ts +2 -0
  201. package/src/tests/deferred-task-wake.test.ts +7 -2
  202. package/src/tests/e2e-coverage-contract.test.ts +235 -0
  203. package/src/tests/empty-output-schema.test.ts +160 -0
  204. package/src/tests/env-flag.test.ts +1 -0
  205. package/src/tests/explicit-model-validation.test.ts +14 -0
  206. package/src/tests/http-api-integration.test.ts +2 -2
  207. package/src/tests/http-users.test.ts +63 -0
  208. package/src/tests/mcp-input-caps.test.ts +4 -3
  209. package/src/tests/merge-gate-detect-changes.test.ts +22 -0
  210. package/src/tests/pages-authed-mode.test.ts +13 -2
  211. package/src/tests/pi-mono-adapter.test.ts +39 -4
  212. package/src/tests/rbac-engine.test.ts +1 -0
  213. package/src/tests/runner-context-usage.test.ts +119 -0
  214. package/src/tests/script-connections.test.ts +2 -0
  215. package/src/tests/script-executor-quickjs.test.ts +2 -0
  216. package/src/tests/script-runs-http.test.ts +57 -0
  217. package/src/tests/scripts-boot-args-schema.test.ts +181 -0
  218. package/src/tests/scripts-runtime.test.ts +24 -0
  219. package/src/tests/sdk-store-progress-skipped.test.ts +155 -0
  220. package/src/tests/session-costs-model-key-normalize.test.ts +59 -0
  221. package/src/tests/session-sharing.test.ts +212 -2
  222. package/src/tests/slack-reaction-config.test.ts +1 -0
  223. package/src/tests/slack-render-v2.test.ts +73 -0
  224. package/src/tests/slack-skip-reaction.test.ts +203 -0
  225. package/src/tests/store-progress-skipped.test.ts +159 -0
  226. package/src/tests/subscription-usage-migration.test.ts +57 -0
  227. package/src/tests/swarm-config-reserved-keys.test.ts +3 -0
  228. package/src/tests/telemetry-endpoint-override.test.ts +27 -0
  229. package/src/tests/trigger-claiming.test.ts +2 -0
  230. package/src/tests/workflow-system-one-extraction.test.ts +29 -0
  231. package/src/tools/create-channel.ts +1 -1
  232. package/src/tools/defer-task.ts +1 -1
  233. package/src/tools/register-agentmail-inbox.ts +5 -0
  234. package/src/tools/repos/update-repo.ts +1 -1
  235. package/src/tools/request-human-input.ts +1 -1
  236. package/src/tools/send-task.ts +1 -1
  237. package/src/tools/store-progress.ts +39 -8
  238. package/src/tools/tracker/tracker-unlink.ts +2 -1
  239. package/src/tools/workflows/retry-workflow-run.ts +3 -0
  240. package/src/types.ts +11 -2
  241. package/src/utils/context-window.ts +6 -1
  242. package/src/utils/output-schema.ts +23 -0
  243. package/src/workflows/executors/system-one-providers.ts +25 -6
  244. package/src/workflows/recovery.ts +8 -4
  245. package/src/workflows/resume.ts +19 -0
  246. package/dist/handlers-zxmp1ta4.js +0 -32
  247. package/dist/index-a8phxqnk.js +0 -37
  248. package/dist/index-k6h00t4c.js +0 -30
  249. package/dist/index-xrz7te8h.js +0 -33
  250. package/dist/lead-956sd2yc.js +0 -71
  251. package/dist/worker-y15hy08h.js +0 -71
@@ -0,0 +1,159 @@
1
+ import { afterAll, beforeAll, describe, expect, test } from "bun:test";
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import type { ZodType } from "zod";
4
+ import {
5
+ checkDependencies,
6
+ closeDb,
7
+ createAgent,
8
+ createTaskExtended,
9
+ getAgentById,
10
+ getDbClient,
11
+ getTaskById,
12
+ initDb,
13
+ startTask,
14
+ } from "../be/db";
15
+ import { registerStoreProgressTool } from "../tools/store-progress";
16
+ import type { SwarmToolResult } from "../tools/utils";
17
+ import { isTerminalTaskStatus } from "../types";
18
+
19
+ // `skipped` ends a task the agent decided is not its to handle. It is
20
+ // terminal, frees the agent, satisfies dependsOn, and creates no lead
21
+ // follow-up, unlike `completed` / `failed`.
22
+ const workerId = "aaaa0000-0000-4000-8000-00000000b501";
23
+ const leadId = "cccc0000-0000-4000-8000-00000000b503";
24
+
25
+ const server = new McpServer({ name: "store-progress-skipped", version: "1.0.0" });
26
+ registerStoreProgressTool(server);
27
+ const tool = (
28
+ server as unknown as {
29
+ _registeredTools: Record<
30
+ string,
31
+ {
32
+ inputSchema: ZodType;
33
+ handler: (args: unknown, meta: unknown) => Promise<SwarmToolResult>;
34
+ }
35
+ >;
36
+ }
37
+ )._registeredTools["store-progress"]!;
38
+
39
+ async function call(args: unknown) {
40
+ return tool.handler(tool.inputSchema.parse(args), {
41
+ sessionId: "store-progress-skipped-session",
42
+ requestInfo: { headers: { "x-agent-id": workerId } },
43
+ });
44
+ }
45
+
46
+ async function startedTask(text: string, options: { dependsOn?: string[] } = {}) {
47
+ const row = await createTaskExtended(text, {
48
+ agentId: workerId,
49
+ source: "slack",
50
+ slackChannelId: "C_SKIP_TEST",
51
+ slackThreadTs: "1700000000.000100",
52
+ ...options,
53
+ });
54
+ await startTask(row.id);
55
+ return row;
56
+ }
57
+
58
+ async function followUpsOf(taskId: string): Promise<number> {
59
+ const row = await getDbClient().get<{ n: number }>(
60
+ "SELECT COUNT(*) AS n FROM agent_tasks WHERE parentTaskId = ? AND taskType = 'follow-up'",
61
+ [taskId],
62
+ );
63
+ return row?.n ?? 0;
64
+ }
65
+
66
+ const originalEmbeddingKey = process.env.EMBEDDING_API_KEY;
67
+ const originalOpenAiKey = process.env.OPENAI_API_KEY;
68
+ beforeAll(async () => {
69
+ process.env.EMBEDDING_API_KEY = "";
70
+ process.env.OPENAI_API_KEY = "";
71
+ initDb(":memory:");
72
+ await createAgent({ id: workerId, name: "Skip worker", isLead: false, status: "idle" });
73
+ await createAgent({ id: leadId, name: "Lead", role: "lead", isLead: true, status: "idle" });
74
+ });
75
+ afterAll(() => {
76
+ closeDb();
77
+ if (originalEmbeddingKey === undefined) delete process.env.EMBEDDING_API_KEY;
78
+ else process.env.EMBEDDING_API_KEY = originalEmbeddingKey;
79
+ if (originalOpenAiKey === undefined) delete process.env.OPENAI_API_KEY;
80
+ else process.env.OPENAI_API_KEY = originalOpenAiKey;
81
+ });
82
+
83
+ describe("store-progress status skipped", () => {
84
+ test("skipped is a terminal status", () => {
85
+ expect(isTerminalTaskStatus("skipped")).toBe(true);
86
+ });
87
+
88
+ test("refuses a skip without a reason and leaves the task running", async () => {
89
+ const task = await startedTask("thread follow-up, no reason");
90
+ const result = await call({ taskId: task.id, status: "skipped" });
91
+ expect(result.structuredContent?.success).toBe(false);
92
+ expect(result.structuredContent?.message).toContain("one-line reason");
93
+ expect((await getTaskById(task.id))?.status).toBe("in_progress");
94
+ // End it so the agent's capacity check in the next test starts clean.
95
+ await call({ taskId: task.id, status: "skipped", failureReason: "Not mine." });
96
+ });
97
+
98
+ test("ends the task as skipped with the reason, frees the agent, and creates no follow-up", async () => {
99
+ // Positive control: the same kind of task, completed, does get a lead follow-up.
100
+ const control = await startedTask("thread follow-up, answered");
101
+ const completed = await call({ taskId: control.id, status: "completed", output: "answered" });
102
+ expect(completed.structuredContent?.success).toBe(true);
103
+ expect(await followUpsOf(control.id)).toBe(1);
104
+
105
+ const task = await startedTask("thread follow-up for someone else");
106
+ const result = await call({
107
+ taskId: task.id,
108
+ status: "skipped",
109
+ failureReason: "Addressed to someone else,\n not to me.",
110
+ });
111
+ expect(result.structuredContent?.success).toBe(true);
112
+
113
+ const after = await getTaskById(task.id);
114
+ expect(after?.status).toBe("skipped");
115
+ expect(after?.failureReason).toBe("Addressed to someone else, not to me.");
116
+ expect(after?.output).toBeUndefined();
117
+ expect(after?.finishedAt).toBeTruthy();
118
+ expect(await followUpsOf(task.id)).toBe(0);
119
+ expect((await getAgentById(workerId))?.status).toBe("idle");
120
+ });
121
+
122
+ test("takes the reason from output when failureReason is absent", async () => {
123
+ const task = await startedTask("thread chatter");
124
+ const result = await call({ taskId: task.id, status: "skipped", output: "People chatting." });
125
+ expect(result.structuredContent?.success).toBe(true);
126
+ const after = await getTaskById(task.id);
127
+ expect(after?.status).toBe("skipped");
128
+ expect(after?.failureReason).toBe("People chatting.");
129
+ expect(after?.output).toBeUndefined();
130
+ });
131
+
132
+ test("a repeated skip is a no-op and a later completion cannot revive the task", async () => {
133
+ const task = await startedTask("skip twice");
134
+ await call({ taskId: task.id, status: "skipped", failureReason: "Not mine." });
135
+ const again = await call({ taskId: task.id, status: "skipped", failureReason: "Not mine." });
136
+ expect(again.structuredContent?.success).toBe(true);
137
+ expect((again.structuredContent as { wasNoOp?: boolean } | undefined)?.wasNoOp).toBe(true);
138
+
139
+ await call({ taskId: task.id, status: "completed", output: "late answer" });
140
+ const after = await getTaskById(task.id);
141
+ expect(after?.status).toBe("skipped");
142
+ expect(after?.output).toBeUndefined();
143
+ expect(await followUpsOf(task.id)).toBe(0);
144
+ });
145
+
146
+ test("a skipped dependency satisfies dependsOn", async () => {
147
+ const dependency = await startedTask("upstream that turns out not to be mine");
148
+ const dependent = await createTaskExtended("downstream", {
149
+ agentId: workerId,
150
+ source: "mcp",
151
+ dependsOn: [dependency.id],
152
+ });
153
+ expect((await checkDependencies(dependent.id)).ready).toBe(false);
154
+ await call({ taskId: dependency.id, status: "skipped", failureReason: "Not mine." });
155
+ expect((await checkDependencies(dependent.id)).ready).toBe(true);
156
+ // Not cascade-failed, unlike a failed or cancelled dependency.
157
+ expect((await getTaskById(dependent.id))?.status).not.toBe("failed");
158
+ });
159
+ });
@@ -0,0 +1,57 @@
1
+ import { Database } from "bun:sqlite";
2
+ import { expect, test } from "bun:test";
3
+
4
+ test("subscription usage migration merges historical keys and preserves routes and spend", async () => {
5
+ const db = new Database(":memory:");
6
+ try {
7
+ db.run("CREATE TABLE session_costs (model TEXT, totalCostUsd REAL, modelBreakdown TEXT)");
8
+ db.run("CREATE TABLE agent_tasks (model TEXT)");
9
+ db.run("INSERT INTO agent_tasks VALUES ('openai-codex/gpt-5.6-luna')");
10
+ const breakdown = [
11
+ { model: "openai-codex/gpt-5.6-luna", inputTokens: 123, totalCostUsd: 2 },
12
+ { model: "openrouter/openai/gpt-5.6-luna", inputTokens: 456, totalCostUsd: 3 },
13
+ ];
14
+ db.run("INSERT INTO session_costs VALUES (?, 5, ?)", [
15
+ " OpenAI-Codex/GPT-5.6-luna ",
16
+ JSON.stringify(breakdown),
17
+ ]);
18
+ db.run("INSERT INTO session_costs VALUES ('gpt-5.6-luna', 7, NULL)");
19
+ db.run("INSERT INTO session_costs VALUES ('openrouter/openai/gpt-5.6-luna', 11, NULL)");
20
+ db.run("INSERT INTO session_costs VALUES ('openai-codex/', 0, NULL)");
21
+ db.run("INSERT INTO session_costs VALUES ('openai-codex/vendor/model', 0, NULL)");
22
+ const sql = await Bun.file(
23
+ new URL("../be/migrations/271_subscription_usage_model.sql", import.meta.url),
24
+ ).text();
25
+ db.exec(sql);
26
+ expect(
27
+ db
28
+ .query(
29
+ "SELECT model, SUM(totalCostUsd) AS cost FROM session_costs GROUP BY model ORDER BY model",
30
+ )
31
+ .all(),
32
+ ).toEqual([
33
+ { model: "gpt-5.6-luna", cost: 12 },
34
+ { model: "openai-codex/", cost: 0 },
35
+ { model: "openai-codex/vendor/model", cost: 0 },
36
+ { model: "openrouter/openai/gpt-5.6-luna", cost: 11 },
37
+ ]);
38
+ expect(db.query("SELECT model FROM agent_tasks").get()).toEqual({
39
+ model: "openai-codex/gpt-5.6-luna",
40
+ });
41
+ const row = db
42
+ .query<{ modelBreakdown: string }, []>(
43
+ "SELECT modelBreakdown FROM session_costs WHERE modelBreakdown IS NOT NULL",
44
+ )
45
+ .get();
46
+ expect(JSON.parse(row!.modelBreakdown)).toEqual([
47
+ { ...breakdown[0], model: "gpt-5.6-luna" },
48
+ breakdown[1],
49
+ ]);
50
+ // Applying it again leaves both identities and monetary totals intact.
51
+ const before = db.query("SELECT * FROM session_costs").all();
52
+ db.exec(sql);
53
+ expect(db.query("SELECT * FROM session_costs").all()).toEqual(before);
54
+ } finally {
55
+ db.close();
56
+ }
57
+ });
@@ -155,6 +155,9 @@ describe("swarm-config reserved keys guard", () => {
155
155
  "EXTENSION_ALLOW_LEAD_ACTIVATION",
156
156
  "extension_allow_lead_activation",
157
157
  "CHAT_SDK_API_URL_OVERRIDES",
158
+ "CODEX_OAUTH_DEVICE_BASE_URL",
159
+ "DESPLEGA_TELEMETRY_ENDPOINT",
160
+ "CLOUDFLARE_API_BASE_URL",
158
161
  ]) {
159
162
  test(`rejects deployment-only ${key} through DB, HTTP, and MCP`, async () => {
160
163
  const config = { scope: "global" as const, key, value: "true" };
@@ -0,0 +1,27 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { resolveTelemetryEndpoint } from "../telemetry";
3
+
4
+ const DEFAULT = "https://proxy.desplega.sh/v1/events";
5
+
6
+ describe("DESPLEGA_TELEMETRY_ENDPOINT override", () => {
7
+ test("unset or blank keeps the default sink", () => {
8
+ expect(resolveTelemetryEndpoint(undefined)).toBe(DEFAULT);
9
+ expect(resolveTelemetryEndpoint(" ")).toBe(DEFAULT);
10
+ });
11
+
12
+ test("https origins and loopback http are accepted", () => {
13
+ expect(resolveTelemetryEndpoint("https://sink.example.com/v1/events")).toBe(
14
+ "https://sink.example.com/v1/events",
15
+ );
16
+ expect(resolveTelemetryEndpoint("http://127.0.0.1:4321/telemetry/v1/events")).toBe(
17
+ "http://127.0.0.1:4321/telemetry/v1/events",
18
+ );
19
+ expect(resolveTelemetryEndpoint("http://localhost:4321/x")).toBe("http://localhost:4321/x");
20
+ });
21
+
22
+ test("plain http to a remote host and non-URLs fall back to the default", () => {
23
+ expect(resolveTelemetryEndpoint("http://collector.example.com/v1/events")).toBe(DEFAULT);
24
+ expect(resolveTelemetryEndpoint("ftp://127.0.0.1/x")).toBe(DEFAULT);
25
+ expect(resolveTelemetryEndpoint("not a url")).toBe(DEFAULT);
26
+ });
27
+ });
@@ -468,6 +468,8 @@ describe("Trigger Claiming - Mentions", () => {
468
468
  // Should claim both channels
469
469
  expect(claimed.length).toBe(2);
470
470
  expect(claimed.map((c) => c.channelId).sort()).toEqual([channel1.id, channel2.id].sort());
471
+ // Each claimed channel reports the mentions it took (the poll trigger sums them).
472
+ expect(claimed.map((c) => c.mentionsCount)).toEqual([1, 1]);
471
473
  });
472
474
 
473
475
  test("concurrent claims do not return duplicate mentions", async () => {
@@ -310,6 +310,34 @@ function envelope(result: unknown = clairicResult()) {
310
310
  // ─── Request and answers ────────────────────────────────────
311
311
 
312
312
  describe("system-one-extraction on Cloudflare Clairic", () => {
313
+ test("a test process can send the Cloudflare request to a loopback mock", async () => {
314
+ const { executor, calls } = makeExecutor([jsonResponse(envelope())], {
315
+ env: { NODE_ENV: "test", CLOUDFLARE_API_BASE_URL: "http://localhost" },
316
+ });
317
+ expect((await run(executor, config())).status).toBe("success");
318
+ expect(calls[0]?.url).toBe(
319
+ `http://localhost/client/v4/accounts/${CF_ACCOUNT}/ai/run/@cf/cloudflare/clairic`,
320
+ );
321
+ });
322
+
323
+ for (const env of [
324
+ { NODE_ENV: "production", CLOUDFLARE_API_BASE_URL: "http://localhost" },
325
+ { NODE_ENV: "test", CLOUDFLARE_API_BASE_URL: "https://example.com" },
326
+ { NODE_ENV: "test", CLOUDFLARE_API_BASE_URL: "http://example.com" },
327
+ { NODE_ENV: "test", CLOUDFLARE_API_BASE_URL: "http://localhost.example.com" },
328
+ { NODE_ENV: "test", CLOUDFLARE_API_BASE_URL: "http://user:pass@localhost" },
329
+ { NODE_ENV: "test", CLOUDFLARE_API_BASE_URL: "http://localhost/proxy" },
330
+ { NODE_ENV: "test", CLOUDFLARE_API_BASE_URL: "http://localhost?target=remote" },
331
+ { NODE_ENV: "test", CLOUDFLARE_API_BASE_URL: "http://localhost#fragment" },
332
+ { NODE_ENV: "test", CLOUDFLARE_API_BASE_URL: "invalid-url" },
333
+ ]) {
334
+ test(`ignores the Cloudflare override ${JSON.stringify(env)}`, async () => {
335
+ const { executor, calls } = makeExecutor([jsonResponse(envelope())], { env });
336
+ expect((await run(executor, config())).status).toBe("success");
337
+ expect(calls[0]?.url).toBe(`${CF_BASE}/clairic`);
338
+ });
339
+ }
340
+
313
341
  test("sends the Clairic request to the account-scoped route and returns typed answers", async () => {
314
342
  const { executor, calls } = makeExecutor([jsonResponse(envelope())]);
315
343
  const result = await run(executor, config({ referenceDate: "2026-10-09" }));
@@ -538,6 +566,7 @@ describe("system-one-extraction config", () => {
538
566
  test("only Clairic models and extraction hosts are accepted", () => {
539
567
  expect(parse({ model: "clef" }).success).toBe(false);
540
568
  expect(parse({ provider: "typesafe" }).success).toBe(false);
569
+ expect(parse({ provider: "laya" }).success).toBe(false);
541
570
  expect(SYSTEM_ONE_EXTRACT_PROVIDER_IDS).toEqual(["cloudflare"]);
542
571
  // The decision hosts are unchanged.
543
572
  expect(SYSTEM_ONE_PROVIDER_IDS).toEqual([
@@ -46,7 +46,7 @@ export const registerCreateChannelTool = (server: McpServer) => {
46
46
  }
47
47
 
48
48
  try {
49
- const channel = createChannel(name, {
49
+ const channel = await createChannel(name, {
50
50
  description,
51
51
  type: type ?? "public",
52
52
  createdBy: requestInfo.agentId,
@@ -191,7 +191,7 @@ export const registerDeferTaskTool = (server: McpServer) => {
191
191
  })
192
192
  .optional()
193
193
  .describe(
194
- "Wake early on a task event. Provide taskId or nonempty, unique taskIds. mode defaults to all (every member must match); any wakes on the first match. settled covers completed, failed, or cancelled. Deferred and superseded members follow their continuations; a superseded member without a resume child holds to the ceiling. Any already-terminal member rejects the request; one delayMs/runAt ceiling is still required for the whole set. The member whose settlement wakes you creates no separate lead follow-up for your agent unless its followUpConfig sets onCompleted/onFailed; an all-mode member that settles while others are pending still does.",
194
+ "Wake early on a task event. Provide taskId or nonempty, unique taskIds. mode defaults to all (every member must match); any wakes on the first match. settled covers completed, failed, cancelled, or skipped. Deferred and superseded members follow their continuations; a superseded member without a resume child holds to the ceiling. Any already-terminal member rejects the request; one delayMs/runAt ceiling is still required for the whole set. The member whose settlement wakes you creates no separate lead follow-up for your agent unless its followUpConfig sets onCompleted/onFailed; an all-mode member that settles while others are pending still does.",
195
195
  ),
196
196
  summary: z
197
197
  .string()
@@ -80,6 +80,11 @@ export const registerRegisterAgentmailInboxTool = (server: McpServer) => {
80
80
  requestInfo.agentId,
81
81
  inboxEmail,
82
82
  );
83
+ if (!mapping) {
84
+ return toolErr(`Inbox ${inboxId} is owned by another agent`, {
85
+ data: { yourAgentId: requestInfo.agentId },
86
+ });
87
+ }
83
88
  const text = `Registered inbox ${inboxId} → agent ${agent.name} (${requestInfo.agentId})`;
84
89
  return toolOk(text, {
85
90
  data: { yourAgentId: requestInfo.agentId, mappings: [mapping] },
@@ -46,7 +46,7 @@ export const registerUpdateRepoTool = (server: McpServer) => {
46
46
  hooks: RepoHooksSchema.nullable()
47
47
  .optional()
48
48
  .describe(
49
- "Repository hook install config. Set { enabled: true } to opt into best-effort worker hook installation, or null to disable.",
49
+ "Repository hook install config. Best-effort worker hook installation is enabled by default for new repos. Disable it with { enabled: false } (or null), or turn it back on with { enabled: true }.",
50
50
  ),
51
51
  guidelines: RepoGuidelinesInputSchema.nullable()
52
52
  .optional()
@@ -20,7 +20,7 @@ const QuestionSchema = z.object({
20
20
  .describe(
21
21
  "The question text displayed to the user (required except for config, which defaults to the key)",
22
22
  ),
23
- required: z.boolean().optional().describe("Whether this question is required (default: true)"),
23
+ required: z.boolean().default(true).describe("Whether this question is required (default: true)"),
24
24
  description: z
25
25
  .string()
26
26
  .optional()
@@ -204,7 +204,7 @@ export const sendTaskInputSchema = z
204
204
  .record(z.string(), z.unknown())
205
205
  .optional()
206
206
  .describe(
207
- "Optional JSON Schema the assignee's final output must satisfy. store-progress rejects a completion that does not match. Supported keywords: type, required, properties, enum, const, items.",
207
+ "Optional JSON Schema the assignee's final output must satisfy. store-progress rejects a completion that does not match. Supported keywords: type, required, properties, enum, const, items. When omitted, the child inherits the schema of its parent task (your current task by default). An empty object {} means no schema: the child stores none and inherits none.",
208
208
  ),
209
209
  })
210
210
  .superRefine((data, ctx) => {
@@ -10,6 +10,7 @@ import {
10
10
  getResolvedConfig,
11
11
  getTaskById,
12
12
  insertTaskAttachment,
13
+ skipTask,
13
14
  updateAgentStatusFromCapacity,
14
15
  updateTaskProgress,
15
16
  } from "@/be/db";
@@ -27,6 +28,7 @@ import {
27
28
  } from "@/be/task-citations";
28
29
  import { AgentFsProvider } from "@/fs/agent-fs-provider";
29
30
  import { can } from "@/rbac";
31
+ import { finalizeSkippedTaskReaction, skipReasonFrom } from "@/tasks/task-skip";
30
32
  import { runTaskTerminalEffects } from "@/tasks/task-terminal-effects";
31
33
  import {
32
34
  getTaskOutputValidationError,
@@ -149,7 +151,7 @@ export const registerStoreProgressTool = (server: McpServer) => {
149
151
  {
150
152
  title: "Store task progress",
151
153
  description:
152
- "Stores the progress of a specific task. Can also mark task as completed or failed, which will set the agent back to idle.",
154
+ "Stores the progress of a specific task. Can also mark task as completed, failed, or skipped, which will set the agent back to idle. Use skipped only when the work is not yours to handle, such as a Slack thread message addressed to someone else; never skip an explicit @mention of you or work assigned to you.",
153
155
  annotations: { idempotentHint: true },
154
156
 
155
157
  inputSchema: z.object({
@@ -161,10 +163,10 @@ export const registerStoreProgressTool = (server: McpServer) => {
161
163
  ),
162
164
  progress: z.string().optional().describe("The progress update to store."),
163
165
  status: z
164
- .enum(["completed", "failed", "in_progress", "pending"])
166
+ .enum(["completed", "failed", "skipped", "in_progress", "pending"])
165
167
  .optional()
166
168
  .describe(
167
- "Set to 'completed' or 'failed' to finish the task. 'in_progress' and 'pending' store progress only and do not change task status.",
169
+ "Set to 'completed' or 'failed' to finish the task. Set 'skipped' to end a task that is not yours to handle (a Slack thread message addressed to someone else, or one you have nothing to add to); it posts nothing to the thread, creates no follow-up, and needs a one-line reason in failureReason. Never skip an explicit @mention of you or work assigned to you. 'in_progress' and 'pending' store progress only and do not change task status.",
168
170
  ),
169
171
  output: z
170
172
  .string()
@@ -175,7 +177,9 @@ export const registerStoreProgressTool = (server: McpServer) => {
175
177
  failureReason: z
176
178
  .string()
177
179
  .optional()
178
- .describe("The reason for failure (used when failing)."),
180
+ .describe(
181
+ "The reason for failure (used when failing), or the one-line reason for a skip (required with status 'skipped').",
182
+ ),
179
183
  attachments: z
180
184
  .array(AttachmentInputSchema)
181
185
  .max(20)
@@ -255,9 +259,19 @@ export const registerStoreProgressTool = (server: McpServer) => {
255
259
  }
256
260
  }
257
261
  const status =
258
- requestedStatus === "completed" || requestedStatus === "failed"
262
+ requestedStatus === "completed" ||
263
+ requestedStatus === "failed" ||
264
+ requestedStatus === "skipped"
259
265
  ? requestedStatus
260
266
  : undefined;
267
+ const skipReason = status === "skipped" ? skipReasonFrom(failureReason, output) : undefined;
268
+ if (status === "skipped") {
269
+ if (!skipReason) {
270
+ return toolErr(
271
+ 'Status "skipped" needs a one-line reason in failureReason. The task was not changed.',
272
+ );
273
+ }
274
+ }
261
275
 
262
276
  // Stock Claude occasionally puts the next tool parameter inside output.
263
277
  // Strip the leaked tail before validation/persistence; recovered pointers
@@ -510,8 +524,7 @@ export const registerStoreProgressTool = (server: McpServer) => {
510
524
  // fields untouched.
511
525
  const terminalResultGuard = await guardTerminalTaskResultWrite(existingTask, {
512
526
  status,
513
- output,
514
- failureReason,
527
+ ...(status === "skipped" ? { failureReason: skipReason } : { output, failureReason }),
515
528
  force,
516
529
  });
517
530
  if (terminalResultGuard.handled) {
@@ -646,6 +659,14 @@ export const registerStoreProgressTool = (server: McpServer) => {
646
659
  await updateAgentStatusFromCapacity(existingTask.agentId);
647
660
  }
648
661
  }
662
+ } else if (status === "skipped") {
663
+ const result = await skipTask(taskId, skipReason!);
664
+ if (result) {
665
+ updatedTask = result;
666
+ if (existingTask.agentId) {
667
+ await updateAgentStatusFromCapacity(existingTask.agentId);
668
+ }
669
+ }
649
670
  } else {
650
671
  // Progress update - ensure status reflects current load
651
672
  if (existingTask.agentId) {
@@ -681,7 +702,7 @@ export const registerStoreProgressTool = (server: McpServer) => {
681
702
  // src/tasks/task-terminal-effects.ts. Skipped on no-op (idempotent
682
703
  // re-call on a terminal task) and on forced text-only overwrites, so a
683
704
  // replay never duplicates memories or follow-up tasks.
684
- if (shouldRunTerminalSideEffects && status) {
705
+ if (shouldRunTerminalSideEffects && (status === "completed" || status === "failed")) {
685
706
  await runTaskTerminalEffects({
686
707
  task: result.task!,
687
708
  status,
@@ -692,6 +713,16 @@ export const registerStoreProgressTool = (server: McpServer) => {
692
713
  });
693
714
  }
694
715
 
716
+ // runTaskTerminalEffects above is completed/failed only: a skip posts
717
+ // nothing and only swaps the trigger message's reaction.
718
+ const skipWasFresh =
719
+ status === "skipped" &&
720
+ result.success &&
721
+ result.task?.status === "skipped" &&
722
+ !("wasNoOp" in result && result.wasNoOp) &&
723
+ !("wasForcedOverwrite" in result && result.wasForcedOverwrite);
724
+ if (skipWasFresh && result.task) finalizeSkippedTaskReaction(result.task, "store-progress");
725
+
695
726
  const learningResult = await learningWrite;
696
727
  const { success } = result;
697
728
  const message = learningResult
@@ -18,7 +18,8 @@ export const registerTrackerUnlinkTool = (server: McpServer) => {
18
18
  },
19
19
  async (args, _requestInfo, _meta) => {
20
20
  try {
21
- await deleteTrackerSync(args.syncId);
21
+ const removed = await deleteTrackerSync(args.syncId);
22
+ if (!removed) return toolErr(`No tracker mapping ${args.syncId}`);
22
23
  return toolOk(`Removed tracker sync mapping ${args.syncId}.`);
23
24
  } catch (error) {
24
25
  const message = error instanceof Error ? error.message : "Unknown error";
@@ -1,5 +1,6 @@
1
1
  import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import { z } from "zod";
3
+ import { getWorkflowRunSummary } from "@/be/db/workflow-runs";
3
4
  import { createToolRegistrar, swarmToolOutputSchema, toolErr, toolOk } from "@/tools/utils";
4
5
  import { getExecutorRegistry, retryFailedRun } from "@/workflows";
5
6
 
@@ -18,6 +19,8 @@ export const registerRetryWorkflowRunTool = (server: McpServer) => {
18
19
  },
19
20
  async ({ runId }) => {
20
21
  try {
22
+ if (!(await getWorkflowRunSummary(runId)))
23
+ return toolErr(`Workflow run not found: ${runId}`);
21
24
  await retryFailedRun(runId, getExecutorRegistry());
22
25
  return toolOk(`Retrying workflow run ${runId}.`);
23
26
  } catch (err) {
package/src/types.ts CHANGED
@@ -319,6 +319,7 @@ export const AgentTaskStatusSchema = z.enum([
319
319
  "failed",
320
320
  "cancelled", // Task was cancelled by lead or creator
321
321
  "superseded", // Original terminated, replaced by a follow-up "resume" task
322
+ "skipped", // Agent declined: the work was not its to handle (e.g. a Slack thread message addressed to someone else)
322
323
  ]);
323
324
 
324
325
  /**
@@ -337,7 +338,13 @@ export const AgentTaskStatusSchema = z.enum([
337
338
  * - `status = CASE WHEN status IN ('completed'` — setProgress guard
338
339
  * and update every site.
339
340
  */
340
- export const TERMINAL_TASK_STATUSES = ["completed", "failed", "cancelled", "superseded"] as const;
341
+ export const TERMINAL_TASK_STATUSES = [
342
+ "completed",
343
+ "failed",
344
+ "cancelled",
345
+ "superseded",
346
+ "skipped",
347
+ ] as const;
341
348
  export type TerminalTaskStatus = (typeof TERMINAL_TASK_STATUSES)[number];
342
349
 
343
350
  export function isTerminalTaskStatus(status: string): status is TerminalTaskStatus {
@@ -2075,7 +2082,9 @@ export const SwarmRepoSchema = z
2075
2082
  clonePath: z.string().min(1),
2076
2083
  defaultBranch: z.string().default("main"),
2077
2084
  autoClone: z.boolean().default(true),
2078
- hooks: RepoHooksSchema.optional().default({ enabled: false }),
2085
+ hooks: RepoHooksSchema.describe(
2086
+ "Worker hook installation. Enabled by default: a repo created without `hooks` stores { enabled: true }. Disable with { enabled: false }. A repo with no stored hooks config reads as disabled.",
2087
+ ),
2079
2088
  guidelines: RepoGuidelinesSchema.nullable().optional(),
2080
2089
  createdAt: z.string(),
2081
2090
  lastUpdatedAt: z.string(),
@@ -64,9 +64,14 @@ function catalogContext(provider: string, model: string): number | undefined {
64
64
  * (`src/utils/runtime-model-catalog.ts`: live `model_catalog` + overlay,
65
65
  * vendored models.dev snapshot offline). Accepts Anthropic ids (dated or
66
66
  * not), Claude CLI shortnames, OpenAI/Codex ids and `provider/model` ids.
67
+ * A positive finite `reportedWindow` from the running harness takes precedence.
67
68
  * Unknown models get a conservative 200k so percent math stays finite.
68
69
  */
69
- export function getContextWindowSize(model: string): number {
70
+ export function getContextWindowSize(model: string, reportedWindow?: number | null): number {
71
+ // Harness limits can be smaller than the model's API/catalog maximum.
72
+ if (reportedWindow != null && Number.isFinite(reportedWindow) && reportedWindow > 0) {
73
+ return reportedWindow;
74
+ }
70
75
  return getKnownContextWindowSize(model) ?? DEFAULT_CONTEXT_WINDOW;
71
76
  }
72
77
 
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Task `outputSchema` presence rules, shared by the API server and workers.
3
+ *
4
+ * An explicit empty schema (`{}`) means "no output schema". Callers pass it on
5
+ * purpose to stop a child task from inheriting the parent's schema. It must
6
+ * never reach a harness as a contract: a worker told to return JSON matching
7
+ * `{}` completes with the literal output "{}" and drops its real result.
8
+ */
9
+
10
+ /** True when `schema` is a non-empty JSON Schema object the task must satisfy. */
11
+ export function isEffectiveOutputSchema(schema: unknown): schema is Record<string, unknown> {
12
+ return (
13
+ !!schema &&
14
+ typeof schema === "object" &&
15
+ !Array.isArray(schema) &&
16
+ Object.keys(schema).length > 0
17
+ );
18
+ }
19
+
20
+ /** Returns the schema when it is effective, otherwise `undefined`. */
21
+ export function normalizeOutputSchema(schema: unknown): Record<string, unknown> | undefined {
22
+ return isEffectiveOutputSchema(schema) ? schema : undefined;
23
+ }
@@ -51,7 +51,7 @@ export interface SystemOneBuiltEndpoint {
51
51
  /** What the value is, for messages: "the account id of a Cloudflare account". */
52
52
  readonly describe: string;
53
53
  /** Request URL, or null when the value is not usable. `model` is already allowlisted. */
54
- readonly build: (value: string, model: string) => string | null;
54
+ readonly build: (value: string, model: string, env: NodeJS.ProcessEnv) => string | null;
55
55
  }
56
56
 
57
57
  export type SystemOneEndpoint = string | SystemOneConfiguredEndpoint | SystemOneBuiltEndpoint;
@@ -155,11 +155,30 @@ async function readFirstGlobalConfig(
155
155
  const CLOUDFLARE_ENDPOINT: SystemOneBuiltEndpoint = {
156
156
  configKey: CLOUDFLARE_ACCOUNT_KEY,
157
157
  describe: "the 32-character id of a Cloudflare account",
158
- build: (accountId, model) => {
158
+ build: (accountId, model, env) => {
159
159
  const id = accountId.trim();
160
- return CLOUDFLARE_ACCOUNT_RE.test(id)
161
- ? `https://api.cloudflare.com/client/v4/accounts/${id}/ai/run/@cf/cloudflare/${model}`
162
- : null;
160
+ if (!CLOUDFLARE_ACCOUNT_RE.test(id)) return null;
161
+ const path = `/client/v4/accounts/${id}/ai/run/@cf/cloudflare/${model}`;
162
+ // Test traffic can reach a local mock. Config rows cannot set this reserved key.
163
+ if (env.NODE_ENV === "test" && env.CLOUDFLARE_API_BASE_URL) {
164
+ try {
165
+ const url = new URL(env.CLOUDFLARE_API_BASE_URL);
166
+ if (
167
+ url.protocol === "http:" &&
168
+ LOOPBACK_HOSTS.has(url.hostname) &&
169
+ url.pathname === "/" &&
170
+ !url.username &&
171
+ !url.password &&
172
+ !url.search &&
173
+ !url.hash
174
+ ) {
175
+ return `${url.origin}${path}`;
176
+ }
177
+ } catch {
178
+ // Ignore an invalid override and use the production endpoint.
179
+ }
180
+ }
181
+ return `https://api.cloudflare.com${path}`;
163
182
  },
164
183
  };
165
184
 
@@ -576,7 +595,7 @@ export async function resolveSystemOneTarget(
576
595
  errors.push(systemOneUrlMissingMessage(id, capability));
577
596
  } else {
578
597
  const resolved = isBuiltEndpoint(service.endpoint)
579
- ? service.endpoint.build(base, overrides.model ?? service.defaultModel ?? "")
598
+ ? service.endpoint.build(base, overrides.model ?? service.defaultModel ?? "", ctx.env)
580
599
  : systemOneEndpointFromBase(base, service.endpoint.path);
581
600
  if (resolved) endpoint = resolved;
582
601
  else errors.push(systemOneUrlInvalidMessage(id, capability));