@desplega.ai/agent-swarm 2.7.5 → 2.7.6

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 (206) hide show
  1. package/dist/{acp-adapter-g3ads55s.js → acp-adapter-bp91d37f.js} +4 -4
  2. package/dist/{actions-zwfykqqk.js → actions-yj0eeaqh.js} +18 -17
  3. package/dist/{amp-adapter-z3s0ssdt.js → amp-adapter-4pg9h34q.js} +1 -1
  4. package/dist/{app-vmp4fgep.js → app-909e97cr.js} +3 -3
  5. package/dist/{assistant-vwde653f.js → assistant-qdyb5fyy.js} +24 -22
  6. package/dist/{boot-reembed-375t7tbk.js → boot-reembed-fk0s9z18.js} +1 -1
  7. package/dist/{boot-reembed-gq9rcpnj.js → boot-reembed-gs1rzrnh.js} +1 -1
  8. package/dist/{boot-scrub-sweep-nd938kyf.js → boot-scrub-sweep-4qfd4kfx.js} +2 -2
  9. package/dist/{boot-seeds-aykx51v3.js → boot-seeds-yr00k13d.js} +4 -4
  10. package/dist/{boxd-k1j26g3h.js → boxd-vdmfssd9.js} +4 -4
  11. package/dist/{claude-adapter-8j4hm099.js → claude-adapter-qta1f1xn.js} +3 -3
  12. package/dist/{claude-managed-setup-0wyynpn1.js → claude-managed-setup-sc6j4dm0.js} +1 -1
  13. package/dist/{claude-sdk-session-q6wj5hmy.js → claude-sdk-session-zgrz6yvc.js} +9169 -9070
  14. package/dist/{cli-gjr2y2xk.js → cli-0agcv1v5.js} +4 -1
  15. package/dist/{cli-vqypxzh4.js → cli-0at8w34w.js} +7 -7
  16. package/dist/{cli-7a42nfy0.js → cli-0qatpy8q.js} +3 -3
  17. package/dist/{cli-p599f1qm.js → cli-0yv5z2pg.js} +1 -1
  18. package/dist/{cli-0gey5fzy.js → cli-386tyxxg.js} +2 -2
  19. package/dist/{cli-5pag6rmn.js → cli-3ypk9vk1.js} +1 -1
  20. package/dist/{cli-qxnf8z2z.js → cli-436532ck.js} +2 -2
  21. package/dist/{cli-z8eh3ex8.js → cli-4necwtsv.js} +4 -4
  22. package/dist/{cli-zh3fp8v2.js → cli-54t00gt8.js} +1 -1
  23. package/dist/{cli-hf6zt5m6.js → cli-69szn7w7.js} +17 -1
  24. package/dist/{cli-nn4d8dne.js → cli-89knwags.js} +2 -2
  25. package/dist/{cli-spknvxbq.js → cli-8bc1w0tw.js} +10 -10
  26. package/dist/{cli-rqkxrmgw.js → cli-8snvgs5r.js} +38 -13
  27. package/dist/{cli-rhw40jgb.js → cli-bjb3z51z.js} +2 -2
  28. package/dist/{cli-xtjhfmpc.js → cli-c60vetmm.js} +1 -1
  29. package/dist/{cli-0731hvbw.js → cli-decfb6v8.js} +2 -2
  30. package/dist/{cli-bhjt02p8.js → cli-drr5v6av.js} +1 -1
  31. package/dist/{cli-fqzx7gwa.js → cli-dxae2yg7.js} +2 -2
  32. package/dist/{cli-tqgg40ek.js → cli-e3r2neck.js} +8 -7
  33. package/dist/{cli-zppwg9p9.js → cli-ekwks2vs.js} +1 -1
  34. package/dist/{cli-nzxr556s.js → cli-es6va8jk.js} +26 -26
  35. package/dist/{cli-a47xy8eq.js → cli-faxe6thg.js} +1 -1
  36. package/dist/cli-gdhpcbhf.js +55 -0
  37. package/dist/{cli-82jg7fp9.js → cli-he5nxaa8.js} +1 -1
  38. package/dist/{cli-8veytvbh.js → cli-he9wchme.js} +1 -1
  39. package/dist/{cli-pywf3eh5.js → cli-hgaazk69.js} +1 -1
  40. package/dist/{cli-0bxqnvq9.js → cli-hr2e2fft.js} +28 -6
  41. package/dist/{cli-1ayk1eas.js → cli-k2gzwsj2.js} +135 -26
  42. package/dist/{cli-xbkdm710.js → cli-kqdg1bsb.js} +3 -3
  43. package/dist/cli-m2z8jagn.js +12078 -0
  44. package/dist/{cli-g61qxmge.js → cli-m48g6p95.js} +3 -3
  45. package/dist/{cli-7wspm5gm.js → cli-nhrvpaj7.js} +20 -4
  46. package/dist/{cli-afrrppsw.js → cli-nwj0ee2w.js} +2 -2
  47. package/dist/{cli-3h4nhjn8.js → cli-p5gp8pcx.js} +9 -7
  48. package/dist/{cli-rm6hqj3z.js → cli-pd7vagab.js} +33 -139
  49. package/dist/{cli-mjzynrse.js → cli-q0k1w5zd.js} +1 -1
  50. package/dist/{cli-8hs41zy2.js → cli-rmmmrjkd.js} +1 -1
  51. package/dist/{cli-kg8hchyg.js → cli-sa02jsqt.js} +1 -1
  52. package/dist/{cli-1338796d.js → cli-shpbx5ee.js} +142 -98
  53. package/dist/{cli-82ae98pz.js → cli-svj5090z.js} +2 -2
  54. package/dist/{cli-bnz7a7qf.js → cli-vvpx3gsx.js} +1 -1
  55. package/dist/{cli-mmwm7zbf.js → cli-w6dt9ged.js} +1 -1
  56. package/dist/{cli-wvaawacd.js → cli-waqbxg08.js} +5230 -66
  57. package/dist/{cli-j3jvnpe8.js → cli-wp9sp1qb.js} +1 -1
  58. package/dist/{cli-nmbmy64z.js → cli-xbbndvjy.js} +3 -3
  59. package/dist/{cli-vbyfwh92.js → cli-xds5f77d.js} +2 -2
  60. package/dist/{cli-7wcyk2s5.js → cli-xnqgpshy.js} +1 -1
  61. package/dist/{cli-rpm2sgv0.js → cli-xnrwazav.js} +19 -2
  62. package/dist/{cli-gf5hbmdr.js → cli-yjdgea32.js} +3 -3
  63. package/dist/{cli-mry0qzym.js → cli-yn4kxs06.js} +123 -10
  64. package/dist/{cli-hn9hxmz9.js → cli-yx4kfngt.js} +1 -1
  65. package/dist/{cli-y24sc29k.js → cli-yy3rhsdw.js} +30 -8
  66. package/dist/{cli-6s7vdcta.js → cli-zbbwez0r.js} +4 -4
  67. package/dist/{cli-z6jkx23q.js → cli-zm72anhg.js} +9 -9
  68. package/dist/cli.js +22 -21
  69. package/dist/{codex-adapter-q6k3gnyg.js → codex-adapter-ayd1fb6h.js} +2 -2
  70. package/dist/{codex-session-runner-3mwmk3d9.js → codex-session-runner-jesa32xc.js} +2 -2
  71. package/dist/{commands-evrenjn9.js → commands-hanewgf2.js} +9 -3
  72. package/dist/{controller-xjp8vswh.js → controller-dt1n3c1q.js} +8 -3
  73. package/dist/{controllers-connect-pp5jnxvc.js → controllers-connect-xx8x64n5.js} +20 -19
  74. package/dist/{cursor-adapter-yf47w4t0.js → cursor-adapter-9s4dwwdw.js} +1 -1
  75. package/dist/{db-zxpw6aht.js → db-3vttcbv4.js} +3 -3
  76. package/dist/{db-rgfsh91f.js → db-9dv0g1ab.js} +11 -3
  77. package/dist/{devtools-82fzqra8.js → devtools-qxfgbsqz.js} +1 -1
  78. package/dist/{dispatcher-smasgws7.js → dispatcher-tx9hd1sv.js} +17 -16
  79. package/dist/{docker-rrjhaqt9.js → docker-c1a3gqmf.js} +89 -22
  80. package/dist/{dsh-adapter-ftyy8dnp.js → dsh-adapter-007y4ejs.js} +1 -1
  81. package/dist/{e2b-qcaj675y.js → e2b-a19d28rz.js} +2 -2
  82. package/dist/{e2b-w1p0bnpm.js → e2b-we6hs6q5.js} +4 -4
  83. package/dist/{easter-egg-3d-yyts7p16.js → easter-egg-3d-rgbrqb8s.js} +1 -1
  84. package/dist/{embedding-space-1z0mbg95.js → embedding-space-ny1e2940.js} +6 -6
  85. package/dist/{embeddings-ygeg7tm7.js → embeddings-2t386t13.js} +1 -1
  86. package/dist/{execute-14qhqp4d.js → execute-pksh0ceh.js} +1 -1
  87. package/dist/{external-channel-ttgrs3sx.js → external-channel-phgmhmd7.js} +2 -2
  88. package/dist/{fx-adapter-gt6pncj2.js → fx-adapter-fy8rr921.js} +5 -5
  89. package/dist/{google-generative-ai-yvmdxyxa.js → google-generative-ai-8y3m3k4b.js} +1 -1
  90. package/dist/{google-vertex-jrtdh9gs.js → google-vertex-w3v98n7b.js} +1 -1
  91. package/dist/{grok-adapter-sm4m5k4g.js → grok-adapter-q0abvpaj.js} +5 -5
  92. package/dist/handlers-by3sfxyx.js +32 -0
  93. package/dist/{heartbeat-qahz4p62.js → heartbeat-kadyek8p.js} +20 -19
  94. package/dist/{hook-kj3d398m.js → hook-5zs3msf6.js} +2 -2
  95. package/dist/{hook-4fd5wq5w.js → hook-9k551xnj.js} +2 -2
  96. package/dist/{http-1ted0j1k.js → http-mhz9vw1f.js} +213 -80
  97. package/dist/index-4f2pvxae.js +37 -0
  98. package/dist/index-98gz7tmp.js +30 -0
  99. package/dist/{index-5rk6rfzr.js → index-fvzke5kx.js} +1 -1
  100. package/dist/index-k08z2cak.js +33 -0
  101. package/dist/{index-yqhz88yy.js → index-pxn30mse.js} +8 -8
  102. package/dist/{index-6rq3r5zb.js → index-q361cg2f.js} +1 -1
  103. package/dist/{index-7v51awbn.js → index-rvr00sg7.js} +20 -13
  104. package/dist/{index-q4b917zs.js → index-vdygbq10.js} +1 -1
  105. package/dist/{keepalive-6cf311t5.js → keepalive-w56f32cg.js} +3 -3
  106. package/dist/{lead-fjy418cw.js → lead-enq35nqp.js} +31 -30
  107. package/dist/{maintenance-a4bm1bmt.js → maintenance-7mdgxcea.js} +1 -1
  108. package/dist/{oauth-refresh-sweep-3h0dfw1k.js → oauth-refresh-sweep-29txy9vk.js} +2 -2
  109. package/dist/{onboard-myn5hraa.js → onboard-kpsrkarj.js} +4 -4
  110. package/dist/{opencode-adapter-p2nkb5am.js → opencode-adapter-j25vm3rr.js} +3 -3
  111. package/dist/{otel-impl-a1a0ef6b.js → otel-impl-6kkct7a8.js} +1 -1
  112. package/dist/{pi-mono-adapter-rzmpb72a.js → pi-mono-adapter-exhkzhn2.js} +4 -4
  113. package/dist/{pricing-refresh-83drrnxj.js → pricing-refresh-n2x7jh6k.js} +3 -3
  114. package/dist/{rbac-roles-s8y6ecb5.js → rbac-roles-81ypx6es.js} +1 -1
  115. package/dist/{rbac-roles-0fb6e7pj.js → rbac-roles-b5htkjby.js} +2 -2
  116. package/dist/{render-v2-twmbgrz4.js → render-v2-qn6jmpk4.js} +3 -3
  117. package/dist/{resume-zfqc36xj.js → resume-wd30wx23.js} +6 -6
  118. package/dist/{runtime-qwggdpqr.js → runtime-4hsg7h60.js} +1 -1
  119. package/dist/{session-access-sc9pn9da.js → session-access-5qvfevhk.js} +4 -4
  120. package/dist/{session-source-backfill-qh07xr8g.js → session-source-backfill-n1czavbr.js} +2 -2
  121. package/dist/{setup-4fr0m7a1.js → setup-dnb56qy5.js} +3 -3
  122. package/dist/{virtual-modules-fh4ha15b.js → virtual-modules-76xxv9fs.js} +2 -2
  123. package/dist/{work-objects-0wr8zxct.js → work-objects-4n21tfkm.js} +20 -19
  124. package/dist/{worker-follow-up-ktyyazyp.js → worker-follow-up-77hvzxww.js} +17 -16
  125. package/dist/{worker-0c5tyzqe.js → worker-gg1576j3.js} +31 -30
  126. package/openapi.json +93 -1
  127. package/package.json +8 -7
  128. package/src/be/db/script-runs.ts +23 -0
  129. package/src/be/db/tasks/read.ts +122 -3
  130. package/src/be/db-client.ts +8 -5
  131. package/src/be/db.ts +15 -4
  132. package/src/be/memory/providers/sqlite-store.ts +49 -12
  133. package/src/be/migrations/260_runtime_pool_cache.sql +20 -0
  134. package/src/be/migrations/262_session_visibility_indexes.sql +18 -0
  135. package/src/be/migrations/263_task_list_filter_index.sql +11 -0
  136. package/src/be/migrations/264_slack_thread_cover_index.sql +9 -0
  137. package/src/be/migrations/266_script_runs_source_task.sql +11 -0
  138. package/src/be/runtime-pools/cache-cleanup.ts +109 -0
  139. package/src/be/runtime-pools/db.ts +65 -6
  140. package/src/be/runtime-pools/remote-controller.ts +5 -0
  141. package/src/be/runtime-pools/supervisor.ts +33 -2
  142. package/src/be/scripts/typecheck.ts +22 -0
  143. package/src/be/seed-scripts/catalog/task-failure-audit.ts +5 -1
  144. package/src/commands/controller.ts +4 -0
  145. package/src/commands/entrypoint-api-readiness.ts +74 -0
  146. package/src/http/index.ts +1 -1
  147. package/src/http/list-total-cache.ts +14 -7
  148. package/src/http/memory.ts +38 -9
  149. package/src/http/script-runs.ts +174 -5
  150. package/src/http/status.ts +10 -2
  151. package/src/http/tasks.ts +4 -2
  152. package/src/providers/amp-adapter.ts +1 -1
  153. package/src/providers/fx-adapter.ts +1 -1
  154. package/src/runtime-providers/controller-protocol.ts +14 -1
  155. package/src/runtime-providers/controller.ts +5 -0
  156. package/src/runtime-providers/docker.ts +108 -23
  157. package/src/runtime-providers/types.ts +16 -0
  158. package/src/script-workflows/workflow-ctx.ts +8 -0
  159. package/src/scripts-runtime/types/stdlib.d.ts +22 -0
  160. package/src/scripts-runtime/types/swarm-sdk.d.ts +22 -0
  161. package/src/server-user.ts +1 -0
  162. package/src/slack/commands.ts +5 -1
  163. package/src/slack/handlers.ts +37 -2
  164. package/src/slack/left-threads.ts +27 -4
  165. package/src/tasks/follow-up-redelegation-guard.ts +155 -0
  166. package/src/tests/claude-artifacts-read-script.test.ts +209 -0
  167. package/src/tests/db-client.test.ts +21 -0
  168. package/src/tests/db-task-read-contract.test.ts +8 -2
  169. package/src/tests/db-task-write-contract.test.ts +5 -1
  170. package/src/tests/entrypoint-api-readiness.test.ts +416 -210
  171. package/src/tests/explicit-model-validation.test.ts +14 -8
  172. package/src/tests/follow-up-redelivery-guard.test.ts +432 -202
  173. package/src/tests/list-total-cache.test.ts +27 -2
  174. package/src/tests/memory-fts-populate.test.ts +11 -9
  175. package/src/tests/memory-retrieval-purge.test.ts +80 -0
  176. package/src/tests/migration-260-runtime-pool-cache.test.ts +118 -0
  177. package/src/tests/query-audit-plans.test.ts +27 -0
  178. package/src/tests/runtime-cache-cleanup.test.ts +367 -0
  179. package/src/tests/runtime-e2b-pools.test.ts +41 -0
  180. package/src/tests/runtime-pools-db.test.ts +98 -0
  181. package/src/tests/runtime-pools-http.test.ts +29 -0
  182. package/src/tests/runtime-providers-docker.test.ts +253 -0
  183. package/src/tests/runtime-remote-controller.test.ts +66 -2
  184. package/src/tests/runtime-supervisor.test.ts +66 -2
  185. package/src/tests/script-connections.test.ts +11 -0
  186. package/src/tests/script-runs-http.test.ts +684 -2
  187. package/src/tests/seed-scripts.test.ts +26 -0
  188. package/src/tests/slack-leave-thread.test.ts +145 -5
  189. package/src/tests/slack-render-v2-query-plans.test.ts +24 -2
  190. package/src/tests/status.test.ts +11 -0
  191. package/src/tests/tasks-readable-row.test.ts +155 -0
  192. package/src/tools/send-task.ts +35 -47
  193. package/src/tools/slack-leave-thread.ts +1 -1
  194. package/src/tools/task-dedup.ts +45 -21
  195. package/src/types.ts +38 -0
  196. package/templates/skills/composio-google-docs/content.md +10 -0
  197. package/templates/skills/script-workflows/content.md +19 -1
  198. package/templates/skills/swarm-docs/content.md +1 -0
  199. package/templates/skills/swarm-scripts/SKILL.md +2 -0
  200. package/templates/skills/swarm-scripts/content.md +2 -0
  201. package/dist/cli-dznrgaep.js +0 -30
  202. package/dist/cli-w3hcrxht.js +0 -6985
  203. package/dist/handlers-vwmba1m2.js +0 -31
  204. package/dist/index-5r71rf98.js +0 -32
  205. package/dist/index-anmwxs87.js +0 -29
  206. package/dist/index-spp0ra5c.js +0 -36
@@ -34,11 +34,53 @@ const HIGH_SIMILARITY_THRESHOLD = 0.8;
34
34
  /** Lower threshold used when the tasks also target the same agent */
35
35
  const SAME_AGENT_SIMILARITY_THRESHOLD = 0.6;
36
36
 
37
+ /**
38
+ * Rows one duplicate check scans. The JS similarity match needs more than the
39
+ * query's default 50 (an older duplicate can sit behind newer unrelated tasks),
40
+ * but the scan must stay bounded: send-task runs it twice per call, once inside
41
+ * the write transaction.
42
+ */
43
+ export const DEDUP_SCAN_LIMIT = 500;
44
+
37
45
  export interface DedupMatch {
38
46
  task: AgentTask;
39
47
  reason: string;
40
48
  }
41
49
 
50
+ /**
51
+ * The description-similarity rules shared by the duplicate check and the
52
+ * follow-up re-delegation guard: a very similar description matches any
53
+ * target, a moderately similar one matches only the same target agent.
54
+ */
55
+ export function matchSimilarTask(
56
+ existing: AgentTask,
57
+ opts: { taskDescription: string; targetAgentId?: string },
58
+ ): DedupMatch | null {
59
+ const similarity = jaccardSimilarity(existing.task, opts.taskDescription);
60
+
61
+ // Very similar task description: likely duplicate regardless of target
62
+ if (similarity > HIGH_SIMILARITY_THRESHOLD) {
63
+ return {
64
+ task: existing,
65
+ reason: `similar task description (${(similarity * 100).toFixed(0)}% match)`,
66
+ };
67
+ }
68
+
69
+ // Same target agent + moderately similar task: lower threshold
70
+ if (
71
+ opts.targetAgentId &&
72
+ existing.agentId === opts.targetAgentId &&
73
+ similarity > SAME_AGENT_SIMILARITY_THRESHOLD
74
+ ) {
75
+ return {
76
+ task: existing,
77
+ reason: `similar task to same agent (${(similarity * 100).toFixed(0)}% match)`,
78
+ };
79
+ }
80
+
81
+ return null;
82
+ }
83
+
42
84
  /**
43
85
  * Check for duplicate tasks created recently.
44
86
  * Returns the first matching duplicate, or null if none found.
@@ -54,6 +96,7 @@ export async function findDuplicateTask(opts: {
54
96
  const recentTasks = await findRecentSimilarTasks({
55
97
  creatorAgentId: opts.creatorAgentId,
56
98
  windowMinutes: opts.windowMinutes ?? 10,
99
+ limit: DEDUP_SCAN_LIMIT,
57
100
  });
58
101
 
59
102
  for (const existing of recentTasks) {
@@ -70,27 +113,8 @@ export async function findDuplicateTask(opts: {
70
113
  };
71
114
  }
72
115
 
73
- const similarity = jaccardSimilarity(existing.task, opts.taskDescription);
74
-
75
- // 2. Very similar task description — likely duplicate regardless of target
76
- if (similarity > HIGH_SIMILARITY_THRESHOLD) {
77
- return {
78
- task: existing,
79
- reason: `similar task description (${(similarity * 100).toFixed(0)}% match)`,
80
- };
81
- }
82
-
83
- // 3. Same target agent + moderately similar task — lower threshold
84
- if (
85
- opts.targetAgentId &&
86
- existing.agentId === opts.targetAgentId &&
87
- similarity > SAME_AGENT_SIMILARITY_THRESHOLD
88
- ) {
89
- return {
90
- task: existing,
91
- reason: `similar task to same agent (${(similarity * 100).toFixed(0)}% match)`,
92
- };
93
- }
116
+ const match = matchSimilarTask(existing, opts);
117
+ if (match) return match;
94
118
  }
95
119
 
96
120
  return null;
package/src/types.ts CHANGED
@@ -2212,6 +2212,39 @@ export const RuntimeControllerSchema = RuntimeControllerCreateSchema.omit({ secr
2212
2212
  .openapi("RuntimeController");
2213
2213
  export type RuntimeController = z.infer<typeof RuntimeControllerSchema>;
2214
2214
 
2215
+ export const RuntimePoolCacheSchema = z
2216
+ .object({
2217
+ mountPath: z
2218
+ .string()
2219
+ .min(2)
2220
+ .refine((path) => {
2221
+ const parts = path.split("/").filter(Boolean);
2222
+ const normalized = `/${parts.join("/")}`;
2223
+ const protectedPaths = [
2224
+ "/workspace/personal",
2225
+ "/workspace/shared",
2226
+ ...["/home/worker", "/root"].flatMap((home) =>
2227
+ [".ssh", ".codex", ".claude", ".claude.json", ".pi", ".config", ".local"].map(
2228
+ (directory) => `${home}/${directory}`,
2229
+ ),
2230
+ ),
2231
+ ];
2232
+ return (
2233
+ path.startsWith("/") &&
2234
+ parts.length > 0 &&
2235
+ !path.includes("\0") &&
2236
+ !parts.some((part) => part === "." || part === "..") &&
2237
+ !protectedPaths.some(
2238
+ (protectedPath) =>
2239
+ protectedPath === normalized ||
2240
+ protectedPath.startsWith(`${normalized}/`) ||
2241
+ normalized.startsWith(`${protectedPath}/`),
2242
+ )
2243
+ );
2244
+ }, "Cache mountPath must be absolute, without . or .., and must not cover worker homes, workspaces or credential directories"),
2245
+ })
2246
+ .strict();
2247
+
2215
2248
  export const RuntimePoolCreateSchema = z
2216
2249
  .object({
2217
2250
  name: z.string().min(1).max(200),
@@ -2226,6 +2259,7 @@ export const RuntimePoolCreateSchema = z
2226
2259
  delivery: DeliveryModeSchema.nullable().default(null),
2227
2260
  env: z.record(z.string(), z.string()).default({}),
2228
2261
  resources: RuntimeResourcesSchema.nullable().default(null),
2262
+ cache: RuntimePoolCacheSchema.nullable().default(null),
2229
2263
  ttlSec: z.number().int().positive().nullable().default(null),
2230
2264
  enabled: z.boolean().default(true),
2231
2265
  })
@@ -2239,6 +2273,7 @@ export const RuntimePoolUpdateSchema = RuntimePoolCreateSchema.partial().extend(
2239
2273
  delivery: DeliveryModeSchema.nullable().optional(),
2240
2274
  env: z.record(z.string(), z.string()).optional(),
2241
2275
  resources: RuntimeResourcesSchema.nullable().optional(),
2276
+ cache: RuntimePoolCacheSchema.nullable().optional(),
2242
2277
  ttlSec: z.number().int().positive().nullable().optional(),
2243
2278
  enabled: z.boolean().optional(),
2244
2279
  });
@@ -3114,6 +3149,8 @@ export const ScriptRunSchema = z
3114
3149
  lastHeartbeatAt: z.string().optional(),
3115
3150
  idempotencyKey: z.string().optional(),
3116
3151
  requestedByUserId: z.string().optional(),
3152
+ /** Task whose session launched the run; the follow-up re-delegation guard reads it. */
3153
+ sourceTaskId: z.string().optional(),
3117
3154
  })
3118
3155
  .openapi("ScriptRun");
3119
3156
  export type ScriptRun = z.infer<typeof ScriptRunSchema>;
@@ -3122,6 +3159,7 @@ export const ScriptRunListItemSchema = ScriptRunSchema.omit({
3122
3159
  source: true,
3123
3160
  args: true,
3124
3161
  output: true,
3162
+ sourceTaskId: true,
3125
3163
  });
3126
3164
  export type ScriptRunListItem = z.infer<typeof ScriptRunListItemSchema>;
3127
3165
 
@@ -80,6 +80,16 @@ Google Drive export, then preserve or reconstruct the structure explicitly.
80
80
  There is no `GET_DOCUMENT_MARKDOWN` tool; markdown exists on create/update, not
81
81
  on read.
82
82
 
83
+ ## Comments
84
+
85
+ Doc comments are a Drive feature, not a Docs one: there is no `GOOGLEDOCS_*`
86
+ comment slug. List them with `GOOGLEDRIVE_LIST_COMMENTS` (replies:
87
+ `GOOGLEDRIVE_LIST_REPLIES`) from the `googledrive` toolkit, so resolve the
88
+ user's `googledrive` connected account instead of their `googledocs` one.
89
+ Listing only works when the Drive read scopes are authorized on that account.
90
+ `GOOGLEDRIVE_CREATE_COMMENT` and the update/delete tools are write actions,
91
+ only on explicit request.
92
+
83
93
  ## Gotchas
84
94
 
85
95
  - Search returns Drive metadata, not document content — do a second
@@ -43,7 +43,25 @@ export default async function main(args, ctx) {
43
43
  }
44
44
  ```
45
45
 
46
- `ctx.step.agentTask` blocks until the dispatched task reaches a terminal status (default `waitForCompletion: true`, default `timeoutMs` 2h) and journals its real output — a sequential `plan → implement → review` chain will not fan out. Pass `waitForCompletion: false` for the legacy fire-and-poll-yourself shape, or `failOnTaskFailure: false` to receive `{taskId, status: "failed", error}` instead of a throw when the task fails/is cancelled.
46
+ `ctx.step.agentTask` blocks until the dispatched task reaches a terminal status (default `waitForCompletion: true`, default `timeoutMs` 2h) and journals its real output — a sequential `plan → implement → review` chain will not fan out. Pass `failOnTaskFailure: false` to receive `{taskId, status: "failed", error}` instead of a throw when the task fails/is cancelled.
47
+
48
+ A run launched from a `follow-up` task in a Slack thread passes the same re-delegation guard as `send-task`, decided once for the whole run at its first new step: a step that repeats completed thread work, or a run past the thread's dispatch cap (a run counts once), throws with the rule's message, and every later new step of that run throws too. Pass `allowRedelegation: true` on a step only for a deliberate re-run. Do not wrap a single dispatch in a durable run; use `send-task`.
49
+
50
+ `waitForCompletion: false` does not return right after dispatch. The first call still waits up to ~30s while the server polls the task, then returns one of three shapes:
51
+
52
+ - The task finished in that window: its output string or `null`, as on success.
53
+ - The task failed or was cancelled in that window: a throw, or `{taskId, status: "failed", error}` with `failOnTaskFailure: false`.
54
+ - The task is still running: `{taskId, status}`.
55
+
56
+ On success, `ctx.step.agentTask` resolves to the worker's output string (JSON text under `outputSchema`, so parse it yourself; `null` when the task stored none), not a task record. On a string, `step.taskId` and `step.status` are undefined, so a guard such as `step.status !== "completed"` or `step?.taskId ?? "unknown"` silently misfires. On `null`, `step.taskId` throws a TypeError. Only `failOnTaskFailure: false` with a failed or cancelled task returns `{taskId, status: "failed", error}`, and only `waitForCompletion: false` on a task still running returns `{taskId, status}`. To get a step's task id, query by its context key (the label is the step label you passed):
57
+
58
+ ```sql
59
+ SELECT id, status, output FROM agent_tasks
60
+ WHERE contextKey = 'script-run:<runId>:<label>' AND taskType = 'script-run-step'
61
+ ORDER BY createdAt DESC, rowid DESC LIMIT 1
62
+ ```
63
+
64
+ Inside the run, `<runId>` is `ctx.run.id`.
47
65
 
48
66
  ## Label Rules
49
67
 
@@ -91,6 +91,7 @@ Fetch the page as markdown: `curl -fsSL https://docs.agent-swarm.dev/llms.mdx/do
91
91
  - [One-off Script Workflow Runs](https://docs.agent-swarm.dev/docs/guides/script-workflow-runs). Reference.
92
92
  - [Dreaming](https://docs.agent-swarm.dev/docs/guides/dreaming). When: Someone asks what the nightly dreaming run changed, how to configure or turn it off, or how to undo one of its changes.
93
93
  - [Claude Bridge](https://docs.agent-swarm.dev/docs/guides/claude-bridge-experimental). Reference.
94
+ - [Reading claude.ai Artifacts headless](https://docs.agent-swarm.dev/docs/guides/claude-artifacts-read). When: Someone wants an agent to read a claude.ai Artifact link, such as a design and its canvas.json, from a headless session.
94
95
  - [Worker Credential Recovery](https://docs.agent-swarm.dev/docs/guides/worker-credential-recovery). Reference.
95
96
  - [Model Gateways](https://docs.agent-swarm.dev/docs/guides/provider-auth/model-gateways). Reference.
96
97
  - [Codex OAuth](https://docs.agent-swarm.dev/docs/guides/provider-auth/codex-oauth). Reference.
@@ -23,6 +23,8 @@ Named script only when the logic will run two or more times, by you, another age
23
23
 
24
24
  Reference point: a workflow triage that took about 26 tool calls returns as one result of about 4k tokens in about 13 seconds.
25
25
 
26
+ Pick the run mode before you author. A short inline `script-run` is for small lookups only. A job that scans a whole population or may run past the inline cap of about 30 s starts as a durable `launch-script-run` from the start. A single `ctx.step.swarmScript` step has the same cap, so collect in bounded steps: each step takes a cursor, collects one slice in well under 30 s, and returns its rows plus the next cursor. Label each step with its slice (`collect-${page}`) so the journal checkpoints it, then compute from the collected slices in a final step. Restarting a long inline run throws away the work it already did.
27
+
26
28
  ## Loading the tools
27
29
 
28
30
  The script tools are deferred. Load them with your harness tool search before the first call: `script-search`, `script-run`, `script-upsert`, `script-query-types`, `script-delete`, and for durable runs `launch-script-run`, `get-script-run`, `list-script-runs`.
@@ -18,6 +18,8 @@ Named script only when the logic will run two or more times, by you, another age
18
18
 
19
19
  Reference point: a workflow triage that took about 26 tool calls returns as one result of about 4k tokens in about 13 seconds.
20
20
 
21
+ Pick the run mode before you author. A short inline `script-run` is for small lookups only. A job that scans a whole population or may run past the inline cap of about 30 s starts as a durable `launch-script-run` from the start. A single `ctx.step.swarmScript` step has the same cap, so collect in bounded steps: each step takes a cursor, collects one slice in well under 30 s, and returns its rows plus the next cursor. Label each step with its slice (`collect-${page}`) so the journal checkpoints it, then compute from the collected slices in a final step. Restarting a long inline run throws away the work it already did.
22
+
21
23
  ## Loading the tools
22
24
 
23
25
  The script tools are deferred. Load them with your harness tool search before the first call: `script-search`, `script-run`, `script-upsert`, `script-query-types`, `script-delete`, and for durable runs `launch-script-run`, `get-script-run`, `list-script-runs`.
@@ -1,30 +0,0 @@
1
- import {
2
- require_permessage_deflate,
3
- require_receiver,
4
- require_sender,
5
- require_extension,
6
- require_websocket,
7
- require_stream,
8
- require_subprotocol,
9
- require_websocket_server
10
- } from "./cli-hf6zt5m6.js";
11
- import {
12
- __toESM,
13
- __esm
14
- } from "./cli-242037k3.js";
15
-
16
- // node_modules/ws/wrapper.mjs
17
- var import_stream, import_extension, import_permessage_deflate, import_receiver, import_sender, import_subprotocol, import_websocket, import_websocket_server, wrapper_default;
18
- var init_wrapper2 = __esm(() => {
19
- import_stream = __toESM(require_stream(), 1);
20
- import_extension = __toESM(require_extension(), 1);
21
- import_permessage_deflate = __toESM(require_permessage_deflate(), 1);
22
- import_receiver = __toESM(require_receiver(), 1);
23
- import_sender = __toESM(require_sender(), 1);
24
- import_subprotocol = __toESM(require_subprotocol(), 1);
25
- import_websocket = __toESM(require_websocket(), 1);
26
- import_websocket_server = __toESM(require_websocket_server(), 1);
27
- wrapper_default = import_websocket.default;
28
- });
29
-
30
- export { import_websocket, import_websocket_server, wrapper_default, init_wrapper2 };