@desplega.ai/agent-swarm 1.101.1 → 1.103.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 (124) hide show
  1. package/dist/{actions-3bnwa1ep.js → actions-7txktrdj.js} +6 -6
  2. package/dist/{app-5efpcda0.js → app-xm3xsdye.js} +3 -3
  3. package/dist/{assistant-rgfbyp46.js → assistant-qpv63wk6.js} +9 -9
  4. package/dist/{boot-reembed-j3gp6x92.js → boot-reembed-9cxqka3e.js} +3 -3
  5. package/dist/{boot-reembed-8428r5df.js → boot-reembed-chxhrwv8.js} +4 -4
  6. package/dist/{boot-scrub-logs-ax5e0nrw.js → boot-scrub-logs-8qtfkcz8.js} +2 -2
  7. package/dist/{claude-managed-adapter-g07dbz3b.js → claude-managed-adapter-z29hjgzz.js} +3 -3
  8. package/dist/{cli-qsy1aedt.js → cli-2307phk1.js} +435 -35
  9. package/dist/{cli-g5px3d7x.js → cli-2957pqpj.js} +24 -1
  10. package/dist/{cli-b2k39ff6.js → cli-2qynerth.js} +1 -1
  11. package/dist/{cli-42f5hj29.js → cli-4fnp2tc3.js} +1 -1
  12. package/dist/{cli-7fzbt4p5.js → cli-85pf4z38.js} +1 -1
  13. package/dist/{cli-gwp428sg.js → cli-8hyv6c2v.js} +6 -14
  14. package/dist/{cli-qr8ky518.js → cli-8w95v19d.js} +1 -1
  15. package/dist/{cli-7xdq3jg3.js → cli-92fqyjcv.js} +1 -1
  16. package/dist/{cli-dg9tkgx0.js → cli-dz3d6zjg.js} +1 -1
  17. package/dist/{cli-53w8f9q9.js → cli-fedn86nz.js} +238 -484
  18. package/dist/{cli-zwc67pz4.js → cli-fwxdt7kt.js} +3 -3
  19. package/dist/{cli-53jkzjwm.js → cli-fygaw191.js} +2 -2
  20. package/dist/{cli-rdhzpm5x.js → cli-gzepjz54.js} +10 -9
  21. package/dist/{cli-n2xem10h.js → cli-jt9d9fjw.js} +1 -1
  22. package/dist/{cli-axtg1zaa.js → cli-khe4x17a.js} +1 -1
  23. package/dist/{cli-3a5wne6a.js → cli-kk51f3tf.js} +5 -5
  24. package/dist/{cli-12mrw9t3.js → cli-krvxq8bc.js} +1 -1
  25. package/dist/{cli-ft42ja8t.js → cli-ksq38x4n.js} +2 -2
  26. package/dist/{cli-z5gm760z.js → cli-m8f6qzck.js} +1 -1
  27. package/dist/{cli-p3mgqhjg.js → cli-ns0r7mkr.js} +30 -5
  28. package/dist/{cli-0v0nmmx1.js → cli-rttgde5f.js} +18 -6
  29. package/dist/{cli-8ayape3v.js → cli-rvae030h.js} +3 -3
  30. package/dist/{cli-6w7kg2y6.js → cli-s14sb64w.js} +4 -4
  31. package/dist/{cli-yg15ef2d.js → cli-v9283nma.js} +1 -1
  32. package/dist/{cli-kdhqhhrt.js → cli-xmtsan9k.js} +1 -1
  33. package/dist/{cli-5mt46cfa.js → cli-yeemwevj.js} +155 -37
  34. package/dist/{cli-54wmx6d9.js → cli-yfwwjeft.js} +1 -1
  35. package/dist/{cli-s8jw5bmg.js → cli-yp2krx5r.js} +2 -2
  36. package/dist/cli.js +9 -9
  37. package/dist/{codex-adapter-wf119mnw.js → codex-adapter-w0xharsg.js} +3 -3
  38. package/dist/{codex-session-runner-1gknw7mh.js → codex-session-runner-kzbjcm2k.js} +3 -3
  39. package/dist/{commands-ne6wm294.js → commands-aqn63mcw.js} +2 -2
  40. package/dist/{db-4bssa9fd.js → db-azrvwsnj.js} +2 -2
  41. package/dist/{handlers-b1xzrzd8.js → handlers-hf61har3.js} +9 -9
  42. package/dist/{hook-ghkvmqhb.js → hook-306p3yz4.js} +2 -2
  43. package/dist/{http-3d87gpq5.js → http-zts4haq7.js} +106 -69
  44. package/dist/{index-zc2ryfs3.js → index-29vg51x6.js} +163 -26
  45. package/dist/{index-vfxc8p1h.js → index-3c651yfk.js} +10 -10
  46. package/dist/{index-g2dtq2m4.js → index-bfh9hgek.js} +5 -5
  47. package/dist/{index-7eqxb7sq.js → index-h2yqjyk0.js} +8 -8
  48. package/dist/{keepalive-mdrtpw97.js → keepalive-a0dg5pds.js} +4 -4
  49. package/dist/{lead-k05m28c2.js → lead-7mcxedkc.js} +21 -21
  50. package/dist/{maintenance-3qnntmp1.js → maintenance-mrzqd53t.js} +4 -4
  51. package/dist/{onboard-kch4svdx.js → onboard-4dkpv9wa.js} +2 -2
  52. package/dist/{otel-impl-7c00xnhe.js → otel-impl-jt7gpyp9.js} +1 -1
  53. package/dist/{pi-mono-adapter-hf8sw7hs.js → pi-mono-adapter-zf7dt1wg.js} +1 -1
  54. package/dist/{pricing-refresh-6038eg1z.js → pricing-refresh-xqnzh8dt.js} +4 -4
  55. package/dist/{seed-pricing-75b6h84n.js → seed-pricing-56tjm1fj.js} +3 -3
  56. package/dist/{setup-jrqcgbdc.js → setup-tbwk8j10.js} +2 -2
  57. package/dist/{worker-0p9zfby6.js → worker-e03za92t.js} +21 -21
  58. package/openapi.json +70 -1
  59. package/package.json +1 -1
  60. package/src/be/audit-user.ts +49 -0
  61. package/src/be/db.ts +114 -17
  62. package/src/be/migrations/098_repo_hooks_config.sql +3 -0
  63. package/src/be/scripts/db.ts +25 -5
  64. package/src/be/seed-skills/index.ts +7 -0
  65. package/src/be/task-lifecycle-events.ts +42 -0
  66. package/src/commands/runner.ts +174 -25
  67. package/src/github/task-reactions.ts +21 -0
  68. package/src/hooks/tool-loop-detection.test.ts +40 -0
  69. package/src/hooks/tool-loop-detection.ts +37 -1
  70. package/src/http/agents.ts +7 -0
  71. package/src/http/index.ts +16 -2
  72. package/src/http/prompt-templates.ts +1 -1
  73. package/src/http/repos.ts +5 -1
  74. package/src/http/schedules.ts +6 -2
  75. package/src/http/scripts.ts +4 -0
  76. package/src/http/session-data.ts +2 -0
  77. package/src/http/tasks.ts +2 -1
  78. package/src/http/workflows.ts +14 -1
  79. package/src/prompts/resolver.ts +1 -1
  80. package/src/scheduler/scheduler.ts +25 -2
  81. package/src/server-runtime-counters.ts +12 -0
  82. package/src/server-user.ts +1 -2
  83. package/src/server.ts +5 -0
  84. package/src/telemetry.ts +18 -1
  85. package/src/tests/audit-updated-by.test.ts +636 -0
  86. package/src/tests/audit-user.test.ts +156 -0
  87. package/src/tests/http-api-integration.test.ts +4 -0
  88. package/src/tests/model-control.test.ts +6 -6
  89. package/src/tests/swarm-repos.test.ts +25 -2
  90. package/src/tests/system-default-skills.test.ts +14 -1
  91. package/src/tests/task-lifecycle-events.test.ts +53 -0
  92. package/src/tests/task-lifecycle-telemetry.test.ts +37 -1
  93. package/src/tests/telemetry-init.test.ts +32 -0
  94. package/src/tools/prompt-templates/preview.ts +1 -1
  95. package/src/tools/repos/update-repo.ts +6 -1
  96. package/src/tools/schedules/create-schedule.ts +6 -1
  97. package/src/tools/schedules/update-schedule.ts +5 -2
  98. package/src/tools/script-common.ts +9 -5
  99. package/src/tools/send-task.ts +7 -2
  100. package/src/tools/task-action.ts +6 -2
  101. package/src/tools/workflows/create-workflow.ts +5 -0
  102. package/src/tools/workflows/patch-workflow-node.ts +10 -1
  103. package/src/tools/workflows/patch-workflow.ts +6 -0
  104. package/src/tools/workflows/update-workflow.ts +4 -0
  105. package/src/types.ts +159 -1
  106. package/src/utils/template.ts +127 -0
  107. package/src/workflows/engine.ts +7 -0
  108. package/src/workflows/executors/agent-task.ts +1 -2
  109. package/src/workflows/template.ts +12 -121
  110. package/src/workflows/triggers.ts +6 -2
  111. package/templates/community/code-health-reports/PLAYBOOK.md +355 -0
  112. package/templates/community/code-health-reports/README.md +38 -0
  113. package/templates/community/code-health-reports/lead-prompt.md +52 -0
  114. package/templates/community/code-health-reports/report.mjs +378 -0
  115. package/templates/community/code-health-reports/run.sh +143 -0
  116. package/templates/schedules/weekly-code-health-reports/config.json +13 -0
  117. package/templates/schedules/weekly-code-health-reports/content.md +60 -0
  118. package/templates/skills/TASTE-SKILL-LICENSE +21 -0
  119. package/templates/skills/pages/config.json +4 -3
  120. package/templates/skills/pages/content.md +39 -12
  121. package/templates/skills/taste-minimalist-skill/config.json +19 -0
  122. package/templates/skills/taste-minimalist-skill/content.md +83 -0
  123. package/src/model-tiers.ts +0 -140
  124. package/templates/community/.gitkeep +0 -0
@@ -11,7 +11,6 @@ import {
11
11
  array,
12
12
  boolean,
13
13
  discriminatedUnion,
14
- exports_external,
15
14
  exports_iso,
16
15
  lazy,
17
16
  literal,
@@ -26,7 +25,7 @@ import {
26
25
  import {
27
26
  init_package,
28
27
  package_default
29
- } from "./cli-7fzbt4p5.js";
28
+ } from "./cli-85pf4z38.js";
30
29
  import {
31
30
  init_secret_scrubber,
32
31
  scrubSecrets
@@ -46,467 +45,7 @@ function parseProviderMeta(rawProvider, rawMeta) {
46
45
  }
47
46
  var init_provider_metadata = () => {};
48
47
 
49
- // src/github/app.ts
50
- function isGitHubEnabled() {
51
- const githubDisable = process.env.GITHUB_DISABLE;
52
- if (githubDisable === "true" || githubDisable === "1") {
53
- return false;
54
- }
55
- return !!process.env.GITHUB_WEBHOOK_SECRET;
56
- }
57
- function resetGitHub() {
58
- initialized = false;
59
- webhookSecret = null;
60
- appId = null;
61
- privateKey = null;
62
- tokenCache.clear();
63
- }
64
- function initGitHub() {
65
- if (initialized) {
66
- console.log("[GitHub] Already initialized, skipping");
67
- return isGitHubEnabled();
68
- }
69
- initialized = true;
70
- const githubDisable = process.env.GITHUB_DISABLE;
71
- if (githubDisable === "true" || githubDisable === "1") {
72
- console.log("[GitHub] Disabled via GITHUB_DISABLE");
73
- return false;
74
- }
75
- webhookSecret = process.env.GITHUB_WEBHOOK_SECRET ?? null;
76
- if (!webhookSecret) {
77
- console.log("[GitHub] Missing GITHUB_WEBHOOK_SECRET, GitHub integration disabled");
78
- return false;
79
- }
80
- appId = process.env.GITHUB_APP_ID ?? null;
81
- const rawPrivateKey = process.env.GITHUB_APP_PRIVATE_KEY ?? null;
82
- if (appId && rawPrivateKey) {
83
- if (rawPrivateKey.startsWith("-----BEGIN")) {
84
- privateKey = rawPrivateKey.replace(/\\n/g, `
85
- `);
86
- } else {
87
- privateKey = Buffer.from(rawPrivateKey, "base64").toString("utf-8");
88
- }
89
- console.log("[GitHub] App credentials loaded for bot reactions");
90
- } else {
91
- console.log("[GitHub] No App credentials, bot reactions disabled");
92
- }
93
- console.log("[GitHub] Webhook handler initialized");
94
- return true;
95
- }
96
- function isReactionsEnabled() {
97
- return !!(appId && privateKey);
98
- }
99
- async function verifyWebhookSignature(payload, signature) {
100
- if (!webhookSecret || !signature) {
101
- console.log(`[GitHub] Signature verification failed: webhookSecret=${!!webhookSecret}, signature=${!!signature}`);
102
- return false;
103
- }
104
- if (!signature.startsWith("sha256=")) {
105
- return false;
106
- }
107
- const expectedSig = signature.slice(7);
108
- const encoder = new TextEncoder;
109
- const key = await crypto.subtle.importKey("raw", encoder.encode(webhookSecret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
110
- const signatureBuffer = await crypto.subtle.sign("HMAC", key, encoder.encode(payload));
111
- const computedSig = Array.from(new Uint8Array(signatureBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
112
- if (computedSig.length !== expectedSig.length) {
113
- console.log(`[GitHub] Signature length mismatch: computed=${computedSig.length}, expected=${expectedSig.length}`);
114
- return false;
115
- }
116
- let result = 0;
117
- for (let i = 0;i < computedSig.length; i++) {
118
- result |= computedSig.charCodeAt(i) ^ expectedSig.charCodeAt(i);
119
- }
120
- const isValid = result === 0;
121
- if (!isValid) {
122
- console.log(`[GitHub] Signature mismatch:`);
123
- console.log(` Expected: ${expectedSig}`);
124
- console.log(` Computed: ${computedSig}`);
125
- }
126
- return isValid;
127
- }
128
- async function generateAppJWT() {
129
- if (!appId || !privateKey) {
130
- return null;
131
- }
132
- const now = Math.floor(Date.now() / 1000);
133
- const payload = {
134
- iat: now - 60,
135
- exp: now + 600,
136
- iss: appId
137
- };
138
- const base64url = (data) => {
139
- const base64 = Buffer.isBuffer(data) ? data.toString("base64") : Buffer.from(data).toString("base64");
140
- return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
141
- };
142
- const header = { alg: "RS256", typ: "JWT" };
143
- const headerB64 = base64url(JSON.stringify(header));
144
- const payloadB64 = base64url(JSON.stringify(payload));
145
- const signingInput = `${headerB64}.${payloadB64}`;
146
- try {
147
- const crypto2 = await import("node:crypto");
148
- const sign = crypto2.createSign("RSA-SHA256");
149
- sign.update(signingInput);
150
- const signature = sign.sign(privateKey);
151
- const signatureB64 = base64url(signature);
152
- return `${signingInput}.${signatureB64}`;
153
- } catch (error) {
154
- console.error("[GitHub] Failed to generate JWT:", error);
155
- return null;
156
- }
157
- }
158
- async function getInstallationToken(installationId) {
159
- const cached = tokenCache.get(installationId);
160
- if (cached && cached.expiresAt > Date.now() + 60000) {
161
- return cached.token;
162
- }
163
- const jwt = await generateAppJWT();
164
- if (!jwt) {
165
- console.log("[GitHub] No JWT available, cannot get installation token");
166
- return null;
167
- }
168
- try {
169
- const response = await fetch(`https://api.github.com/app/installations/${installationId}/access_tokens`, {
170
- method: "POST",
171
- headers: {
172
- Accept: "application/vnd.github+json",
173
- Authorization: `Bearer ${jwt}`,
174
- "X-GitHub-Api-Version": "2022-11-28"
175
- }
176
- });
177
- if (!response.ok) {
178
- const errorText = await response.text();
179
- console.error(`[GitHub] Failed to get installation token: ${response.status} ${errorText}`);
180
- return null;
181
- }
182
- const data = await response.json();
183
- const expiresAt = new Date(data.expires_at).getTime();
184
- tokenCache.set(installationId, { token: data.token, expiresAt });
185
- console.log(`[GitHub] Got installation token for ${installationId}, expires at ${data.expires_at}`);
186
- return data.token;
187
- } catch (error) {
188
- console.error("[GitHub] Error getting installation token:", error);
189
- return null;
190
- }
191
- }
192
- var initialized = false, webhookSecret = null, appId = null, privateKey = null, tokenCache;
193
- var init_app = __esm(() => {
194
- tokenCache = new Map;
195
- });
196
-
197
- // src/github/reactions.ts
198
- async function addReaction(repo, commentId, reaction, installationId) {
199
- if (!isReactionsEnabled()) {
200
- console.log("[GitHub] Reactions not enabled, skipping");
201
- return false;
202
- }
203
- const token = await getInstallationToken(installationId);
204
- if (!token) {
205
- console.log("[GitHub] No installation token, skipping reaction");
206
- return false;
207
- }
208
- try {
209
- const response = await fetch(`https://api.github.com/repos/${repo}/issues/comments/${commentId}/reactions`, {
210
- method: "POST",
211
- headers: {
212
- Accept: "application/vnd.github+json",
213
- Authorization: `Bearer ${token}`,
214
- "X-GitHub-Api-Version": "2022-11-28",
215
- "Content-Type": "application/json"
216
- },
217
- body: JSON.stringify({ content: reaction })
218
- });
219
- if (!response.ok) {
220
- const errorText = await response.text();
221
- console.error(`[GitHub] Failed to add reaction: ${response.status} ${errorText}`);
222
- return false;
223
- }
224
- console.log(`[GitHub] Added ${reaction} reaction to comment ${commentId}`);
225
- return true;
226
- } catch (error) {
227
- console.error("[GitHub] Error adding reaction:", error);
228
- return false;
229
- }
230
- }
231
- async function addIssueReaction(repo, issueNumber, reaction, installationId) {
232
- if (!isReactionsEnabled()) {
233
- console.log("[GitHub] Reactions not enabled, skipping");
234
- return false;
235
- }
236
- const token = await getInstallationToken(installationId);
237
- if (!token) {
238
- console.log("[GitHub] No installation token, skipping reaction");
239
- return false;
240
- }
241
- try {
242
- const response = await fetch(`https://api.github.com/repos/${repo}/issues/${issueNumber}/reactions`, {
243
- method: "POST",
244
- headers: {
245
- Accept: "application/vnd.github+json",
246
- Authorization: `Bearer ${token}`,
247
- "X-GitHub-Api-Version": "2022-11-28",
248
- "Content-Type": "application/json"
249
- },
250
- body: JSON.stringify({ content: reaction })
251
- });
252
- if (!response.ok) {
253
- const errorText = await response.text();
254
- console.error(`[GitHub] Failed to add issue reaction: ${response.status} ${errorText}`);
255
- return false;
256
- }
257
- console.log(`[GitHub] Added ${reaction} reaction to issue/PR #${issueNumber}`);
258
- return true;
259
- } catch (error) {
260
- console.error("[GitHub] Error adding issue reaction:", error);
261
- return false;
262
- }
263
- }
264
- async function addPullReviewCommentReaction(repo, commentId, reaction, installationId) {
265
- if (!isReactionsEnabled()) {
266
- console.log("[GitHub] Reactions not enabled, skipping");
267
- return false;
268
- }
269
- const token = await getInstallationToken(installationId);
270
- if (!token) {
271
- console.log("[GitHub] No installation token, skipping reaction");
272
- return false;
273
- }
274
- try {
275
- const response = await fetch(`https://api.github.com/repos/${repo}/pulls/comments/${commentId}/reactions`, {
276
- method: "POST",
277
- headers: {
278
- Accept: "application/vnd.github+json",
279
- Authorization: `Bearer ${token}`,
280
- "X-GitHub-Api-Version": "2022-11-28",
281
- "Content-Type": "application/json"
282
- },
283
- body: JSON.stringify({ content: reaction })
284
- });
285
- if (!response.ok) {
286
- const errorText = await response.text();
287
- console.error(`[GitHub] Failed to add PR review comment reaction: ${response.status} ${errorText}`);
288
- return false;
289
- }
290
- console.log(`[GitHub] Added ${reaction} reaction to PR review comment ${commentId}`);
291
- return true;
292
- } catch (error) {
293
- console.error("[GitHub] Error adding PR review comment reaction:", error);
294
- return false;
295
- }
296
- }
297
- async function addGraphQLReaction(nodeId, reaction, installationId) {
298
- if (!isReactionsEnabled()) {
299
- console.log("[GitHub] Reactions not enabled, skipping");
300
- return false;
301
- }
302
- const token = await getInstallationToken(installationId);
303
- if (!token) {
304
- console.log("[GitHub] No installation token, skipping GraphQL reaction");
305
- return false;
306
- }
307
- try {
308
- const response = await fetch("https://api.github.com/graphql", {
309
- method: "POST",
310
- headers: {
311
- Authorization: `Bearer ${token}`,
312
- "Content-Type": "application/json"
313
- },
314
- body: JSON.stringify({
315
- query: `mutation AddReaction($input: AddReactionInput!) {
316
- addReaction(input: $input) {
317
- reaction { content }
318
- }
319
- }`,
320
- variables: {
321
- input: { subjectId: nodeId, content: reaction }
322
- }
323
- })
324
- });
325
- if (!response.ok) {
326
- const errorText = await response.text();
327
- console.error(`[GitHub] GraphQL reaction failed: ${response.status} ${errorText}`);
328
- return false;
329
- }
330
- const data = await response.json();
331
- if (data.errors?.length) {
332
- console.error(`[GitHub] GraphQL reaction errors: ${JSON.stringify(data.errors)}`);
333
- return false;
334
- }
335
- console.log(`[GitHub] Added ${reaction} GraphQL reaction to node ${nodeId}`);
336
- return true;
337
- } catch (error) {
338
- console.error("[GitHub] Error adding GraphQL reaction:", error);
339
- return false;
340
- }
341
- }
342
- var init_reactions = __esm(() => {
343
- init_app();
344
- });
345
-
346
- // src/github/task-reactions.ts
347
- async function addEyesReactionOnTaskStart(task) {
348
- if (task.source !== "github" || task.vcsProvider !== "github")
349
- return;
350
- if (!task.vcsInstallationId)
351
- return;
352
- const installationId = task.vcsInstallationId;
353
- const repo = task.vcsRepo;
354
- if (!repo)
355
- return;
356
- try {
357
- switch (task.vcsEventType) {
358
- case "issue_comment": {
359
- if (task.vcsCommentId) {
360
- await addReaction(repo, task.vcsCommentId, "eyes", installationId);
361
- }
362
- break;
363
- }
364
- case "pull_request_review_comment": {
365
- if (task.vcsCommentId) {
366
- await addPullReviewCommentReaction(repo, task.vcsCommentId, "eyes", installationId);
367
- }
368
- break;
369
- }
370
- case "pull_request_review": {
371
- if (task.vcsNodeId) {
372
- await addGraphQLReaction(task.vcsNodeId, "EYES", installationId);
373
- }
374
- break;
375
- }
376
- case "pull_request":
377
- case "issues": {
378
- if (task.vcsNumber) {
379
- await addIssueReaction(repo, task.vcsNumber, "eyes", installationId);
380
- }
381
- break;
382
- }
383
- }
384
- } catch (error) {
385
- console.error("[GitHub] Failed to add eyes reaction on task start:", error);
386
- }
387
- }
388
- var init_task_reactions = __esm(() => {
389
- init_reactions();
390
- });
391
-
392
- // src/model-tiers.ts
393
- function parseModelTier(value) {
394
- if (!value)
395
- return;
396
- const normalized = value.trim().toLowerCase();
397
- return ModelTierSchema.safeParse(normalized).success ? normalized : LEGACY_MODEL_TO_TIER[normalized];
398
- }
399
- function splitLegacyModelAlias(input) {
400
- const explicitTier = parseModelTier(input.modelTier);
401
- const model = input.model?.trim();
402
- if (!model)
403
- return { modelTier: explicitTier };
404
- const legacyTier = parseModelTier(model);
405
- if (legacyTier && !explicitTier) {
406
- return { modelTier: legacyTier };
407
- }
408
- return {
409
- model,
410
- modelTier: explicitTier
411
- };
412
- }
413
- function parseTierMapJson(value) {
414
- if (!value)
415
- return {};
416
- try {
417
- const parsed = JSON.parse(value);
418
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
419
- return {};
420
- const result = {};
421
- for (const tier of MODEL_TIERS) {
422
- const model = parsed[tier];
423
- if (typeof model === "string" && model.trim())
424
- result[tier] = model.trim();
425
- }
426
- return result;
427
- } catch {
428
- return {};
429
- }
430
- }
431
- function resolveModelTier(opts) {
432
- const tier = parseModelTier(opts.tier);
433
- if (!tier)
434
- return;
435
- const env = opts.env ?? {};
436
- const jsonOverrides = parseTierMapJson(env.MODEL_TIER_MAP);
437
- const envKey = `MODEL_TIER_${tier.toUpperCase()}`;
438
- const directOverride = env[envKey]?.trim();
439
- if (directOverride)
440
- return directOverride;
441
- if (jsonOverrides[tier])
442
- return jsonOverrides[tier];
443
- return DEFAULT_MODEL_TIER_MAP[opts.harnessProvider]?.[tier];
444
- }
445
- function resolveTaskModelSelection(opts) {
446
- const model = opts.model?.trim();
447
- if (model)
448
- return { model, source: "model" };
449
- const tierModel = resolveModelTier({
450
- tier: opts.modelTier,
451
- harnessProvider: opts.harnessProvider,
452
- env: opts.env
453
- });
454
- if (tierModel)
455
- return { model: tierModel, source: "modelTier" };
456
- return { source: "none" };
457
- }
458
- var ModelTierSchema, MODEL_TIERS, LEGACY_MODEL_TO_TIER, DEFAULT_MODEL_TIER_MAP;
459
- var init_model_tiers = __esm(() => {
460
- init_zod();
461
- ModelTierSchema = exports_external.enum(["smol", "regular", "smart", "ultra"]);
462
- MODEL_TIERS = ModelTierSchema.options;
463
- LEGACY_MODEL_TO_TIER = {
464
- haiku: "smol",
465
- sonnet: "regular",
466
- opus: "smart",
467
- fable: "ultra"
468
- };
469
- DEFAULT_MODEL_TIER_MAP = {
470
- claude: {
471
- smol: "haiku",
472
- regular: "sonnet",
473
- smart: "opus",
474
- ultra: "fable"
475
- },
476
- "claude-managed": {
477
- smol: "claude-haiku-4-5",
478
- regular: "claude-sonnet-4-6",
479
- smart: "claude-opus-4-8",
480
- ultra: "claude-fable-5"
481
- },
482
- codex: {
483
- smol: "gpt-5.4-mini",
484
- regular: "gpt-5.4",
485
- smart: "gpt-5.5",
486
- ultra: "gpt-5.5"
487
- },
488
- pi: {
489
- smol: "openrouter/deepseek/deepseek-v4-flash",
490
- regular: "openrouter/deepseek/deepseek-v4-flash",
491
- smart: "openrouter/deepseek/deepseek-v4-pro",
492
- ultra: "openrouter/anthropic/claude-opus-4.8"
493
- },
494
- opencode: {
495
- smol: "openrouter/deepseek/deepseek-v4-flash",
496
- regular: "openrouter/deepseek/deepseek-v4-flash",
497
- smart: "openrouter/deepseek/deepseek-v4-pro",
498
- ultra: "openrouter/anthropic/claude-opus-4.8"
499
- },
500
- devin: {
501
- smol: "devin",
502
- regular: "devin",
503
- smart: "devin",
504
- ultra: "devin"
505
- }
506
- };
507
- });
508
-
509
- // src/workflows/template.ts
48
+ // src/utils/template.ts
510
49
  function interpolate(template, ctx) {
511
50
  const unresolved = [];
512
51
  const result = template.replace(/\{\{([^}]+)\}\}/g, (_match, path) => {
@@ -807,7 +346,8 @@ function track(options) {
807
346
  properties: {
808
347
  ...options.properties ?? {},
809
348
  is_cloud: cachedIsCloud,
810
- is_e2b: cachedIsE2b
349
+ is_e2b: cachedIsE2b,
350
+ swarmVersion: package_default.version
811
351
  },
812
352
  metadata: {
813
353
  transport: "https",
@@ -828,6 +368,7 @@ function track(options) {
828
368
  }
829
369
  var TELEMETRY_ENDPOINT = "https://proxy.desplega.sh/v1/events", PRODUCT = "agent-swarm", TIMEOUT_MS = 5000, installationId = null, source = "unknown", cachedIsCloud = false, cachedIsE2b = false, CLOUD_HOST_EXACT, CLOUD_HOST_SUFFIXES, telemetry;
830
370
  var init_telemetry = __esm(() => {
371
+ init_package();
831
372
  CLOUD_HOST_EXACT = new Set([
832
373
  "agent-swarm-mcp.desplega.sh",
833
374
  "agent-swarm.dev",
@@ -843,18 +384,140 @@ var init_telemetry = __esm(() => {
843
384
  },
844
385
  session(event, props) {
845
386
  track({ event: `session.${event}`, properties: props });
387
+ },
388
+ schedule(event, props) {
389
+ track({ event: `schedule.${event}`, properties: props });
390
+ },
391
+ workflow(event, props) {
392
+ track({ event: `workflow.${event}`, properties: props });
393
+ },
394
+ agent(event, props) {
395
+ track({ event: `agent.${event}`, properties: props });
396
+ },
397
+ compaction(event, props) {
398
+ track({ event: `compaction.${event}`, properties: props });
846
399
  }
847
400
  };
848
401
  });
849
402
 
850
403
  // src/types.ts
404
+ function parseModelTier(value) {
405
+ if (!value)
406
+ return;
407
+ const normalized = value.trim().toLowerCase();
408
+ return ModelTierSchema.safeParse(normalized).success ? normalized : LEGACY_MODEL_TO_TIER[normalized];
409
+ }
410
+ function splitLegacyModelAlias(input) {
411
+ const explicitTier = parseModelTier(input.modelTier);
412
+ const model = input.model?.trim();
413
+ if (!model)
414
+ return { modelTier: explicitTier };
415
+ const legacyTier = parseModelTier(model);
416
+ if (legacyTier && !explicitTier) {
417
+ return { modelTier: legacyTier };
418
+ }
419
+ return {
420
+ model,
421
+ modelTier: explicitTier
422
+ };
423
+ }
424
+ function parseTierMapJson(value) {
425
+ if (!value)
426
+ return {};
427
+ try {
428
+ const parsed = JSON.parse(value);
429
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
430
+ return {};
431
+ const result = {};
432
+ for (const tier of MODEL_TIERS) {
433
+ const model = parsed[tier];
434
+ if (typeof model === "string" && model.trim())
435
+ result[tier] = model.trim();
436
+ }
437
+ return result;
438
+ } catch {
439
+ return {};
440
+ }
441
+ }
442
+ function resolveModelTier(opts) {
443
+ const tier = parseModelTier(opts.tier);
444
+ if (!tier)
445
+ return;
446
+ const env = opts.env ?? {};
447
+ const jsonOverrides = parseTierMapJson(env.MODEL_TIER_MAP);
448
+ const envKey = `MODEL_TIER_${tier.toUpperCase()}`;
449
+ const directOverride = env[envKey]?.trim();
450
+ if (directOverride)
451
+ return directOverride;
452
+ if (jsonOverrides[tier])
453
+ return jsonOverrides[tier];
454
+ return DEFAULT_MODEL_TIER_MAP[opts.harnessProvider]?.[tier];
455
+ }
456
+ function resolveTaskModelSelection(opts) {
457
+ const model = opts.model?.trim();
458
+ if (model)
459
+ return { model, source: "model" };
460
+ const tierModel = resolveModelTier({
461
+ tier: opts.modelTier,
462
+ harnessProvider: opts.harnessProvider,
463
+ env: opts.env
464
+ });
465
+ if (tierModel)
466
+ return { model: tierModel, source: "modelTier" };
467
+ return { source: "none" };
468
+ }
851
469
  function isTerminalTaskStatus(status) {
852
470
  return TERMINAL_TASK_STATUSES.includes(status);
853
471
  }
854
- var AgentTaskStatusSchema, TERMINAL_TASK_STATUSES, InboxMessageStatusSchema, InboxMessageSchema, AgentTaskSourceSchema, ProviderNameSchema, FollowUpConfigSchema, AgentTaskSchema, TaskAttachmentKindSchema, attachmentCommonFields, AttachmentInputSchema, TaskAttachmentSchema, UserSchema, IdentityEventTypeSchema, InboxItemTypeSchema, InboxItemStatusSchema, InboxItemStateSchema, TaskTemplateKindSchema, TaskTemplateSchema, AgentStatusSchema, AgentSchema, AgentCredStatusLiveTestSchema, AgentLatestModelSchema, AgentBedrockStatusSchema, AgentCredStatusSchema, AgentWithTasksSchema, ChangeSourceSchema, VersionableFieldSchema, ContextVersionSchema, ChannelTypeSchema, ChannelSchema, ChannelMessageSchema, ServiceStatusSchema, ServiceSchema, AgentLogEventTypeSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostSourceSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, ActiveSessionSchema, RetryPolicySchema, ExecutorMetaSchema, ValidationResultSchema, StepValidationConfigSchema, SwarmScriptNodeConfigSchema, WorkflowNodeSchema, WorkflowEdgeSchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, WorkflowTemplateSchema, WorkflowSnapshotSchema, WorkflowSchema, WorkflowVersionSchema, PageContentTypeSchema, PageAuthModeSchema, PageSnapshotSchema, PageSchema, PageVersionSchema, MetricParamSchema, MetricVariableTypeSchema, MetricFormatSchema, MetricVisualizationSchema, MetricQuerySchema, MetricVariableSchema, MetricVizConfigSchema, MetricWidgetSchema, MetricDefinitionSchema, MetricSnapshotSchema, MetricSchema, MetricVersionSchema, WorkflowRunStatusSchema, WorkflowRunSchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, ScriptRunKindSchema, ScriptRunSchema, ScriptRunListItemSchema, ScriptRunJournalEntrySchema, WorkflowRunStepStatusSchema, WorkflowRunStepSchema, WaitModeSchema, WaitStateStatusSchema, WaitStateRowSchema, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ScriptRecordSchema, ScriptVersionRecordSchema, SkillTypeSchema, SkillScopeSchema, SkillSchema, AgentSkillSchema, SkillWithInstallInfoSchema, SkillFileSchema, McpServerTransportSchema, McpServerScopeSchema, McpAuthMethodSchema, McpServerSchema, AgentMcpServerSchema, McpServerWithInstallInfoSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, ContextSnapshotSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, BudgetRefusedTriggerSchema, KvValueTypeSchema, KV_NAME_REGEX, KvNamespaceSchema, KvKeySchema, KvEntrySchema;
472
+ var ModelTierSchema, MODEL_TIERS, LEGACY_MODEL_TO_TIER, DEFAULT_MODEL_TIER_MAP, AgentTaskStatusSchema, TERMINAL_TASK_STATUSES, InboxMessageStatusSchema, InboxMessageSchema, AgentTaskSourceSchema, ProviderNameSchema, FollowUpConfigSchema, AgentTaskSchema, TaskAttachmentKindSchema, attachmentCommonFields, AttachmentInputSchema, TaskAttachmentSchema, UserSchema, IdentityEventTypeSchema, InboxItemTypeSchema, InboxItemStatusSchema, InboxItemStateSchema, TaskTemplateKindSchema, TaskTemplateSchema, AgentStatusSchema, AgentSchema, AgentCredStatusLiveTestSchema, AgentLatestModelSchema, AgentBedrockStatusSchema, AgentCredStatusSchema, AgentWithTasksSchema, ChangeSourceSchema, VersionableFieldSchema, ContextVersionSchema, ChannelTypeSchema, ChannelSchema, ChannelMessageSchema, ServiceStatusSchema, ServiceSchema, AgentLogEventTypeSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostSourceSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, ActiveSessionSchema, RetryPolicySchema, ExecutorMetaSchema, ValidationResultSchema, StepValidationConfigSchema, SwarmScriptNodeConfigSchema, WorkflowNodeSchema, WorkflowEdgeSchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, WorkflowTemplateSchema, WorkflowSnapshotSchema, WorkflowSchema, WorkflowVersionSchema, PageContentTypeSchema, PageAuthModeSchema, PageSnapshotSchema, PageSchema, PageVersionSchema, MetricParamSchema, MetricVariableTypeSchema, MetricFormatSchema, MetricVisualizationSchema, MetricQuerySchema, MetricVariableSchema, MetricVizConfigSchema, MetricWidgetSchema, MetricDefinitionSchema, MetricSnapshotSchema, MetricSchema, MetricVersionSchema, WorkflowRunStatusSchema, WorkflowRunSchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, ScriptRunKindSchema, ScriptRunSchema, ScriptRunListItemSchema, ScriptRunJournalEntrySchema, WorkflowRunStepStatusSchema, WorkflowRunStepSchema, WaitModeSchema, WaitStateStatusSchema, WaitStateRowSchema, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ScriptRecordSchema, ScriptVersionRecordSchema, SkillTypeSchema, SkillScopeSchema, SkillSchema, AgentSkillSchema, SkillWithInstallInfoSchema, SkillFileSchema, McpServerTransportSchema, McpServerScopeSchema, McpAuthMethodSchema, McpServerSchema, AgentMcpServerSchema, McpServerWithInstallInfoSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, ContextSnapshotSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, BudgetRefusedTriggerSchema, KvValueTypeSchema, KV_NAME_REGEX, KvNamespaceSchema, KvKeySchema, KvEntrySchema;
855
473
  var init_types = __esm(() => {
856
474
  init_zod();
857
- init_model_tiers();
475
+ ModelTierSchema = _enum(["smol", "regular", "smart", "ultra"]);
476
+ MODEL_TIERS = ModelTierSchema.options;
477
+ LEGACY_MODEL_TO_TIER = {
478
+ haiku: "smol",
479
+ sonnet: "regular",
480
+ opus: "smart",
481
+ fable: "ultra"
482
+ };
483
+ DEFAULT_MODEL_TIER_MAP = {
484
+ claude: {
485
+ smol: "haiku",
486
+ regular: "sonnet",
487
+ smart: "opus",
488
+ ultra: "fable"
489
+ },
490
+ "claude-managed": {
491
+ smol: "claude-haiku-4-5",
492
+ regular: "claude-sonnet-4-6",
493
+ smart: "claude-opus-4-8",
494
+ ultra: "claude-fable-5"
495
+ },
496
+ codex: {
497
+ smol: "gpt-5.4-mini",
498
+ regular: "gpt-5.4",
499
+ smart: "gpt-5.5",
500
+ ultra: "gpt-5.5"
501
+ },
502
+ pi: {
503
+ smol: "openrouter/deepseek/deepseek-v4-flash",
504
+ regular: "openrouter/deepseek/deepseek-v4-flash",
505
+ smart: "openrouter/deepseek/deepseek-v4-pro",
506
+ ultra: "openrouter/anthropic/claude-opus-4.8"
507
+ },
508
+ opencode: {
509
+ smol: "openrouter/deepseek/deepseek-v4-flash",
510
+ regular: "openrouter/deepseek/deepseek-v4-flash",
511
+ smart: "openrouter/deepseek/deepseek-v4-pro",
512
+ ultra: "openrouter/anthropic/claude-opus-4.8"
513
+ },
514
+ devin: {
515
+ smol: "devin",
516
+ regular: "devin",
517
+ smart: "devin",
518
+ ultra: "devin"
519
+ }
520
+ };
858
521
  AgentTaskStatusSchema = _enum([
859
522
  "backlog",
860
523
  "unassigned",
@@ -1367,7 +1030,9 @@ var init_types = __esm(() => {
1367
1030
  modelTier: ModelTierSchema.optional(),
1368
1031
  scheduleType: _enum(["recurring", "one_time"]).default("recurring"),
1369
1032
  createdAt: exports_iso.datetime(),
1370
- lastUpdatedAt: exports_iso.datetime()
1033
+ lastUpdatedAt: exports_iso.datetime(),
1034
+ createdBy: string().optional(),
1035
+ updatedBy: string().optional()
1371
1036
  }).refine((data) => {
1372
1037
  if (data.scheduleType === "one_time")
1373
1038
  return true;
@@ -1395,6 +1060,9 @@ var init_types = __esm(() => {
1395
1060
  allowMerge: boolean().optional().default(false),
1396
1061
  review: array(string())
1397
1062
  });
1063
+ RepoHooksSchema = object({
1064
+ enabled: boolean().default(false)
1065
+ });
1398
1066
  SwarmRepoSchema = object({
1399
1067
  id: string().uuid(),
1400
1068
  url: string().min(1),
@@ -1402,6 +1070,7 @@ var init_types = __esm(() => {
1402
1070
  clonePath: string().min(1),
1403
1071
  defaultBranch: string().default("main"),
1404
1072
  autoClone: boolean().default(true),
1073
+ hooks: RepoHooksSchema.optional().default({ enabled: false }),
1405
1074
  guidelines: RepoGuidelinesSchema.nullable().optional(),
1406
1075
  createdAt: string(),
1407
1076
  lastUpdatedAt: string()
@@ -1572,7 +1241,9 @@ var init_types = __esm(() => {
1572
1241
  vcsRepo: string().min(1).optional(),
1573
1242
  createdByAgentId: string().uuid().optional(),
1574
1243
  createdAt: string(),
1575
- lastUpdatedAt: string()
1244
+ lastUpdatedAt: string(),
1245
+ createdBy: string().optional(),
1246
+ updatedBy: string().optional()
1576
1247
  });
1577
1248
  WorkflowVersionSchema = object({
1578
1249
  id: string().uuid(),
@@ -3484,6 +3155,25 @@ var init_swarm_config_guard = __esm(() => {
3484
3155
  };
3485
3156
  });
3486
3157
 
3158
+ // src/be/task-lifecycle-events.ts
3159
+ function onTaskStarted(handler) {
3160
+ taskStartedHandlers.push(handler);
3161
+ }
3162
+ function emitTaskStarted(task) {
3163
+ for (const handler of taskStartedHandlers) {
3164
+ try {
3165
+ const result = handler(task);
3166
+ if (result && typeof result.catch === "function") {
3167
+ result.catch(() => {});
3168
+ }
3169
+ } catch {}
3170
+ }
3171
+ }
3172
+ var taskStartedHandlers;
3173
+ var init_task_lifecycle_events = __esm(() => {
3174
+ taskStartedHandlers = [];
3175
+ });
3176
+
3487
3177
  // src/prompts/defaults.ts
3488
3178
  function generateDefaultClaudeMd(agent) {
3489
3179
  const descSection = agent.description ? `${agent.description}
@@ -4096,6 +3786,18 @@ function emitTaskLifecycleTelemetryAfterCommit(event, props, verify) {
4096
3786
  telemetry.taskEvent(event, props);
4097
3787
  });
4098
3788
  }
3789
+ function taskContextForTelemetry(task) {
3790
+ const harnessVersion = task.harnessVariantMeta?.version;
3791
+ const context = {};
3792
+ if (task.provider)
3793
+ context.provider = task.provider;
3794
+ if (task.harnessVariant)
3795
+ context.harnessVariant = task.harnessVariant;
3796
+ if (typeof harnessVersion === "string" || typeof harnessVersion === "number") {
3797
+ context.harnessVersion = String(harnessVersion);
3798
+ }
3799
+ return context;
3800
+ }
4099
3801
  function isSqliteVecAvailable() {
4100
3802
  return sqliteVecAvailable;
4101
3803
  }
@@ -4698,7 +4400,7 @@ function startTask(taskId) {
4698
4400
  }
4699
4401
  const result = row ? rowToAgentTask(row) : null;
4700
4402
  if (result && oldTask.status !== "in_progress") {
4701
- addEyesReactionOnTaskStart(result).catch(() => {});
4403
+ emitTaskStarted(result);
4702
4404
  }
4703
4405
  return result;
4704
4406
  }
@@ -5114,6 +4816,8 @@ function completeTask(id, output) {
5114
4816
  if (row && oldTask) {
5115
4817
  emitTaskLifecycleTelemetryAfterCommit("completed", {
5116
4818
  taskId: id,
4819
+ source: oldTask.source,
4820
+ ...taskContextForTelemetry(oldTask),
5117
4821
  agentId: row.agentId ?? undefined,
5118
4822
  durationMs: row.createdAt ? Date.now() - new Date(row.createdAt).getTime() : undefined
5119
4823
  }, (task) => task?.status === "completed");
@@ -5153,6 +4857,8 @@ function failTask(id, reason) {
5153
4857
  if (row && oldTask) {
5154
4858
  emitTaskLifecycleTelemetryAfterCommit("failed", {
5155
4859
  taskId: id,
4860
+ source: oldTask.source,
4861
+ ...taskContextForTelemetry(oldTask),
5156
4862
  agentId: row.agentId ?? undefined,
5157
4863
  durationMs: row.createdAt ? Date.now() - new Date(row.createdAt).getTime() : undefined
5158
4864
  }, (task) => task?.status === "failed");
@@ -5246,6 +4952,14 @@ function supersedeTask(id, args) {
5246
4952
  WHERE id = ? AND status NOT IN ('completed', 'failed', 'cancelled', 'superseded')
5247
4953
  RETURNING *`).get(finishedAt, id);
5248
4954
  if (row && oldTask) {
4955
+ emitTaskLifecycleTelemetryAfterCommit("superseded", {
4956
+ taskId: id,
4957
+ source: oldTask.source,
4958
+ ...taskContextForTelemetry(oldTask),
4959
+ agentId: row.agentId ?? undefined,
4960
+ reason: args.reason,
4961
+ durationMs: oldTask.createdAt ? Date.now() - new Date(oldTask.createdAt).getTime() : undefined
4962
+ }, (task) => task?.status === "superseded");
5249
4963
  try {
5250
4964
  createLogEntry({
5251
4965
  eventType: "task_superseded",
@@ -5670,7 +5384,7 @@ function createTaskExtended(task, options) {
5670
5384
  emitTaskLifecycleTelemetryAfterCommit("created", {
5671
5385
  taskId: row.id,
5672
5386
  source: row.source,
5673
- tags: options?.tags ?? [],
5387
+ ...taskContextForTelemetry(rowToAgentTask(row)),
5674
5388
  hasParent: !!row.parentTaskId,
5675
5389
  priority: row.priority
5676
5390
  }, (task2) => task2 !== null);
@@ -5706,7 +5420,7 @@ function claimTask(taskId, agentId) {
5706
5420
  }
5707
5421
  const result = row ? rowToAgentTask(row) : null;
5708
5422
  if (result) {
5709
- addEyesReactionOnTaskStart(result).catch(() => {});
5423
+ emitTaskStarted(result);
5710
5424
  }
5711
5425
  return result;
5712
5426
  }
@@ -6662,7 +6376,9 @@ function rowToScheduledTask(row) {
6662
6376
  modelTier: parseModelTier(row.modelTier) ?? undefined,
6663
6377
  scheduleType: row.scheduleType,
6664
6378
  createdAt: normalizeDateRequired(row.createdAt),
6665
- lastUpdatedAt: normalizeDateRequired(row.lastUpdatedAt)
6379
+ lastUpdatedAt: normalizeDateRequired(row.lastUpdatedAt),
6380
+ createdBy: row.created_by ?? undefined,
6381
+ updatedBy: row.updated_by ?? undefined
6666
6382
  };
6667
6383
  }
6668
6384
  function rowToScheduledTaskSummary(row) {
@@ -6708,8 +6424,9 @@ function createScheduledTask(data) {
6708
6424
  const row = getDb().prepare(`INSERT INTO scheduled_tasks (
6709
6425
  id, name, description, cronExpression, intervalMs, taskTemplate,
6710
6426
  taskType, tags, priority, targetAgentId, enabled, nextRunAt,
6711
- createdByAgentId, timezone, model, modelTier, scheduleType, createdAt, lastUpdatedAt
6712
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *`).get(id, data.name, data.description ?? null, data.cronExpression ?? null, data.intervalMs ?? null, data.taskTemplate, data.taskType ?? null, JSON.stringify(data.tags ?? []), data.priority ?? 50, data.targetAgentId ?? null, data.enabled !== false ? 1 : 0, data.nextRunAt ?? null, data.createdByAgentId ?? null, data.timezone ?? "UTC", data.model ?? null, data.modelTier ?? null, data.scheduleType ?? "recurring", now, now);
6427
+ createdByAgentId, timezone, model, modelTier, scheduleType, createdAt, lastUpdatedAt,
6428
+ created_by, updated_by
6429
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *`).get(id, data.name, data.description ?? null, data.cronExpression ?? null, data.intervalMs ?? null, data.taskTemplate, data.taskType ?? null, JSON.stringify(data.tags ?? []), data.priority ?? 50, data.targetAgentId ?? null, data.enabled !== false ? 1 : 0, data.nextRunAt ?? null, data.createdByAgentId ?? null, data.timezone ?? "UTC", data.model ?? null, data.modelTier ?? null, data.scheduleType ?? "recurring", now, now, data.createdBy ?? null, data.createdBy ?? null);
6713
6430
  if (!row)
6714
6431
  throw new Error("Failed to create scheduled task");
6715
6432
  return rowToScheduledTask(row);
@@ -6793,6 +6510,10 @@ function updateScheduledTask(id, data) {
6793
6510
  updates.push("scheduleType = ?");
6794
6511
  params.push(data.scheduleType);
6795
6512
  }
6513
+ if (data.updatedBy !== undefined) {
6514
+ updates.push("updated_by = ?");
6515
+ params.push(data.updatedBy);
6516
+ }
6796
6517
  if (updates.length === 0) {
6797
6518
  return getScheduledTaskById(id);
6798
6519
  }
@@ -7033,6 +6754,7 @@ function rowToSwarmRepo(row) {
7033
6754
  clonePath: row.clonePath,
7034
6755
  defaultBranch: row.defaultBranch,
7035
6756
  autoClone: row.autoClone === 1,
6757
+ hooks: row.hooks ? JSON.parse(row.hooks) : { enabled: false },
7036
6758
  guidelines: row.guidelines ? JSON.parse(row.guidelines) : null,
7037
6759
  createdAt: row.createdAt,
7038
6760
  lastUpdatedAt: row.lastUpdatedAt
@@ -7068,10 +6790,11 @@ function getSwarmRepoByUrl(url) {
7068
6790
  function createSwarmRepo(data) {
7069
6791
  const id = crypto.randomUUID();
7070
6792
  const now = new Date().toISOString();
7071
- const clonePath = data.clonePath || `/workspace/repos/${data.name}`;
6793
+ const clonePath = data.clonePath || `/workspace/personal/repos/${data.name}`;
6794
+ const hooksJson = JSON.stringify(data.hooks ?? { enabled: true });
7072
6795
  const guidelinesJson = data.guidelines ? JSON.stringify(data.guidelines) : null;
7073
- const row = getDb().prepare(`INSERT INTO swarm_repos (id, url, name, clonePath, defaultBranch, autoClone, guidelines, createdAt, lastUpdatedAt)
7074
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *`).get(id, data.url, data.name, clonePath, data.defaultBranch ?? "main", data.autoClone !== false ? 1 : 0, guidelinesJson, now, now);
6796
+ const row = getDb().prepare(`INSERT INTO swarm_repos (id, url, name, clonePath, defaultBranch, autoClone, hooks, guidelines, createdAt, lastUpdatedAt)
6797
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *`).get(id, data.url, data.name, clonePath, data.defaultBranch ?? "main", data.autoClone !== false ? 1 : 0, hooksJson, guidelinesJson, now, now);
7075
6798
  if (!row)
7076
6799
  throw new Error("Failed to create repo");
7077
6800
  return rowToSwarmRepo(row);
@@ -7090,6 +6813,10 @@ function updateSwarmRepo(id, updates) {
7090
6813
  setClauses.push("autoClone = ?");
7091
6814
  params.push(updates.autoClone ? 1 : 0);
7092
6815
  }
6816
+ if (updates.hooks !== undefined) {
6817
+ setClauses.push("hooks = ?");
6818
+ params.push(updates.hooks ? JSON.stringify(updates.hooks) : null);
6819
+ }
7093
6820
  if (updates.guidelines !== undefined) {
7094
6821
  setClauses.push("guidelines = ?");
7095
6822
  params.push(updates.guidelines ? JSON.stringify(updates.guidelines) : null);
@@ -7268,13 +6995,15 @@ function rowToWorkflow(row) {
7268
6995
  vcsRepo: row.vcs_repo ?? undefined,
7269
6996
  createdByAgentId: row.createdByAgentId ?? undefined,
7270
6997
  createdAt: normalizeDateRequired(row.createdAt),
7271
- lastUpdatedAt: normalizeDateRequired(row.lastUpdatedAt)
6998
+ lastUpdatedAt: normalizeDateRequired(row.lastUpdatedAt),
6999
+ createdBy: row.created_by ?? undefined,
7000
+ updatedBy: row.updated_by ?? undefined
7272
7001
  };
7273
7002
  }
7274
7003
  function createWorkflow(data) {
7275
7004
  const id = crypto.randomUUID();
7276
- const row = getDb().prepare(`INSERT INTO workflows (id, name, description, definition, triggers, cooldown, input, triggerSchema, dir, vcs_repo, createdByAgentId)
7277
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *`).get(id, data.name, data.description ?? null, JSON.stringify(data.definition), JSON.stringify(data.triggers ?? []), data.cooldown ? JSON.stringify(data.cooldown) : null, data.input ? JSON.stringify(data.input) : null, data.triggerSchema ? JSON.stringify(data.triggerSchema) : null, data.dir ?? null, data.vcsRepo ?? null, data.createdByAgentId ?? null);
7005
+ const row = getDb().prepare(`INSERT INTO workflows (id, name, description, definition, triggers, cooldown, input, triggerSchema, dir, vcs_repo, createdByAgentId, created_by, updated_by)
7006
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *`).get(id, data.name, data.description ?? null, JSON.stringify(data.definition), JSON.stringify(data.triggers ?? []), data.cooldown ? JSON.stringify(data.cooldown) : null, data.input ? JSON.stringify(data.input) : null, data.triggerSchema ? JSON.stringify(data.triggerSchema) : null, data.dir ?? null, data.vcsRepo ?? null, data.createdByAgentId ?? null, data.createdBy ?? null, data.createdBy ?? null);
7278
7007
  if (!row)
7279
7008
  throw new Error("Failed to create workflow");
7280
7009
  return rowToWorkflow(row);
@@ -7358,6 +7087,10 @@ function updateWorkflow(id, data) {
7358
7087
  updates.push("vcs_repo = ?");
7359
7088
  params.push(data.vcsRepo ?? null);
7360
7089
  }
7090
+ if (data.updatedBy !== undefined) {
7091
+ updates.push("updated_by = ?");
7092
+ params.push(data.updatedBy);
7093
+ }
7361
7094
  if (updates.length === 0)
7362
7095
  return getWorkflow(id);
7363
7096
  updates.push("lastUpdatedAt = ?");
@@ -7405,6 +7138,22 @@ function getWorkflowRun(id) {
7405
7138
  const row = getDb().prepare("SELECT * FROM workflow_runs WHERE id = ?").get(id);
7406
7139
  return row ? rowToWorkflowRun(row) : null;
7407
7140
  }
7141
+ function emitWorkflowTerminalTelemetry(run) {
7142
+ if (run.status !== "completed" && run.status !== "failed")
7143
+ return;
7144
+ queueMicrotask(() => {
7145
+ const latest = getWorkflowRun(run.id);
7146
+ if (!latest || latest.status !== run.status)
7147
+ return;
7148
+ const steps = getWorkflowRunStepsByRunId(run.id);
7149
+ telemetry.workflow(run.status, {
7150
+ workflowId: run.workflowId,
7151
+ durationMs: run.startedAt ? Date.now() - new Date(run.startedAt).getTime() : undefined,
7152
+ stepsCompleted: steps.filter((step) => step.status === "completed").length,
7153
+ stepsFailed: steps.filter((step) => step.status === "failed").length
7154
+ });
7155
+ });
7156
+ }
7408
7157
  function updateWorkflowRun(id, data) {
7409
7158
  const updates = [];
7410
7159
  const params = [];
@@ -7430,7 +7179,13 @@ function updateWorkflowRun(id, data) {
7430
7179
  params.push(new Date().toISOString());
7431
7180
  params.push(id);
7432
7181
  const row = getDb().prepare(`UPDATE workflow_runs SET ${updates.join(", ")} WHERE id = ? RETURNING *`).get(...params);
7433
- return row ? rowToWorkflowRun(row) : null;
7182
+ if (!row)
7183
+ return null;
7184
+ const run = rowToWorkflowRun(row);
7185
+ if (data.status === "completed" || data.status === "failed") {
7186
+ emitWorkflowTerminalTelemetry(run);
7187
+ }
7188
+ return run;
7434
7189
  }
7435
7190
  function listWorkflowRuns(workflowId) {
7436
7191
  return getDb().prepare("SELECT * FROM workflow_runs WHERE workflowId = ? ORDER BY startedAt DESC").all(workflowId).map(rowToWorkflowRun);
@@ -9882,8 +9637,6 @@ var db = null, sqliteVecAvailable = false, VERSIONABLE_FIELDS, agentQueries, MAX
9882
9637
  var init_db = __esm(() => {
9883
9638
  init_provider_metadata();
9884
9639
  init_package();
9885
- init_task_reactions();
9886
- init_model_tiers();
9887
9640
  init_resolver();
9888
9641
  init_telemetry();
9889
9642
  init_types();
@@ -9895,6 +9648,7 @@ var init_db = __esm(() => {
9895
9648
  init_runner();
9896
9649
  init_seed_prompt_templates();
9897
9650
  init_swarm_config_guard();
9651
+ init_task_lifecycle_events();
9898
9652
  init_defaults();
9899
9653
  VERSIONABLE_FIELDS = [
9900
9654
  "soulMd",
@@ -9987,4 +9741,4 @@ var init_db = __esm(() => {
9987
9741
  };
9988
9742
  });
9989
9743
 
9990
- export { isGitHubEnabled, resetGitHub, initGitHub, verifyWebhookSignature, getInstallationToken, init_app, addReaction, addIssueReaction, init_reactions, ModelTierSchema, splitLegacyModelAlias, resolveTaskModelSelection, init_model_tiers, interpolate, deepInterpolate, init_template, registerTemplate, getTemplateDefinition, getAllTemplateDefinitions, init_registry, configureHttpResolver, resolveTemplate, resolveTemplateAsync, init_resolver, initTelemetry, telemetry, init_telemetry, AgentTaskStatusSchema, isTerminalTaskStatus, AgentTaskSourceSchema, ProviderNameSchema, FollowUpConfigSchema, AgentTaskSchema, AttachmentInputSchema, TaskAttachmentSchema, InboxItemTypeSchema, InboxItemStatusSchema, TaskTemplateKindSchema, AgentSchema, AgentLatestModelSchema, AgentCredStatusSchema, ChannelTypeSchema, ChannelSchema, ChannelMessageSchema, ServiceStatusSchema, ServiceSchema, ResumeReasonSchema, AgentLogSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, PageContentTypeSchema, PageAuthModeSchema, MetricDefinitionSchema, MetricVersionSchema, WorkflowRunStatusSchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, KvValueTypeSchema, KvNamespaceSchema, KvKeySchema, KvEntrySchema, init_types, setRequestAuth, getRequestAuth, init_request_auth_context, encryptSecret, decryptSecret, getEncryptionKey, init_crypto, normalizeDateRequired, init_date_utils, init_session_templates, init_templates, init_templates2 as init_templates1, isReservedConfigKey, reservedKeyError, validateConfigValue, init_swarm_config_guard, generateDefaultClaudeMd, generateDefaultSoulMd, generateDefaultIdentityMd, generateDefaultToolsMd, init_defaults, isSqliteVecAvailable, initDb, getDb, closeDb, computeContentHash, createContextVersion, getLatestContextVersion, getContextVersion, getContextVersionHistory, agentQueries, updateAgentCredentialState, createAgent, getAgentById, getAllAgents, getLeadAgent, updateAgentStatus, updateAgentMaxTasks, updateAgentProvider, setAgentHarnessProvider, updateAgentCredStatus, listAgentsWithCredStatusByProvider, getAgentHarnessProviders, updateAgentActivity, MAX_EMPTY_POLLS, incrementEmptyPollCount, resetEmptyPollCount, shouldBlockPolling, deleteAgent, getActiveTaskCount, hasCapacity, getRemainingCapacity, updateAgentStatusFromCapacity, taskQueries, createTask, getPendingTaskForAgent, assignUnassignedTaskPending, startTask, getTaskById, markTaskSlackReplySent, setSlackMessageTracking, getChildTasks, hasNonTerminalResumeChild, hasNonTerminalRerouteDecisionChild, updateTaskClaudeSessionId, updateTaskVcs, getTasksByAgentId, getAgentCurrentTask, getTasksByStatus, findTaskByVcs, findTaskByGitHub, getAllTasks, getTasksCount, getTaskStats, getCompletedSlackTasks, getRecentlyFinishedWorkerTasks, markTasksNotified, resetTasksNotified, getInProgressSlackTasks, getInProgressTasksByContextKey, getLatestTaskByContextKey, getAgentWorkingOnThread, getLatestActiveTaskInThread, getMostRecentTaskInThread, findCompletedTaskInThread, findRecentCancelledTaskInThread, completeTask, failTask, cancelTask, supersedeTask, backfillSupersedeTaskResumeTaskId, pauseTask, resumeTask, getPausedTasksForAgent, getOrphanedInProgressTasksForAgent, resetOrphanedInProgressTasksForAgent, getRecentlyCancelledTasksForAgent, deleteTask, updateTaskProgress, insertTaskAttachment, getTaskAttachments, getAgentWithTasks, getAllAgentsWithTasks, logQueries, createLogEntry, getLogsByAgentId, getLogsByTaskId, getLogsByTaskIdChronological, getLogsByEventType, getAllLogs, findRecentSimilarTasks, createTaskExtended, claimTask, releaseTask, acceptTask, rejectTask, moveTaskToBacklog, moveTaskFromBacklog, releaseStaleReviewingTasks, getOfferedTasksForAgent, claimOfferedTask, getUnassignedTasksCount, getUnassignedTaskIds, checkDependencies, getDependentTasks, cascadeFailDependents, updateAgentProfile, updateAgentName, createChannel, getMessageById, getChannelById, getChannelByName, getAllChannels, deleteChannel, postMessage, getChannelMessages, updateReadState, getLastReadAt, getUnreadMessages, getMentionsForAgent, getInboxSummary, claimMentions, releaseMentionProcessing, releaseStaleMentionProcessing, createService, getServiceById, getServiceByAgentAndName, getServicesByAgentId, getAllServices, updateServiceStatus, deleteService, upsertService, deleteServicesByAgentId, sessionLogQueries, createSessionLogs, getSessionLogsByTaskId, getSessionLogsBySession, createSessionCost, getSessionCostsByTaskId, getSessionCostsByAgentId, getAllSessionCosts, getSessionCostsFiltered, getSessionCostSummary, getDashboardCostSummary, createInboxMessage, getInboxMessageById, getUnreadInboxMessages, claimInboxMessages, markInboxMessageRead, markInboxMessageResponded, markInboxMessageDelegated, releaseStaleProcessingInbox, getConcurrentContext, getScheduledTasks, getScheduledTaskById, getScheduledTaskByName, createScheduledTask, updateScheduledTask, deleteScheduledTask, getDueScheduledTasks, autoEncryptLegacyPlaintextSecrets, maskSecrets, getSwarmConfigs, getInjectableGlobalConfigs, getSwarmConfigById, getSwarmConfigLookupById, upsertSwarmConfig, deleteSwarmConfig, getResolvedConfig, getSwarmRepos, getSwarmRepoById, getSwarmRepoByName, getSwarmRepoByUrl, createSwarmRepo, updateSwarmRepo, deleteSwarmRepo, getAgentMailInboxMapping, getAgentMailInboxMappingsByAgent, getAllAgentMailInboxMappings, createAgentMailInboxMapping, deleteAgentMailInboxMapping, findTaskByAgentMailThread, insertActiveSession, deleteActiveSession, deleteActiveSessionById, getActiveSessions, heartbeatActiveSession, cleanupStaleSessions, cleanupAgentSessions, updateActiveSessionProviderSessionId, getActiveSessionForTask, reassociateSessionLogs, getStalledInProgressTasks, getStalePinnedResumes, failPendingResumeIfUnclaimed, getIdleWorkersWithCapacity, getUnassignedPoolTasks, getRecentFailedTasks, getRecentCompletedCount, getRecentFailedCount, createWorkflow, getWorkflow, listWorkflows, updateWorkflow, deleteWorkflow, getWorkflowsByScheduleId, createWorkflowRun, getWorkflowRun, updateWorkflowRun, listWorkflowRuns, createWorkflowRunStep, getWorkflowRunStep, updateWorkflowRunStep, getWorkflowRunStepsByRunId, getStuckWorkflowRuns, getLastSuccessfulRun, getLastRunStart, getRetryableSteps, getCompletedStepNodeIds, getTaskByWorkflowRunStepId, getStepByIdempotencyKey, getStepCountForNode, getLatestStepForNode, createWorkflowVersion, getWorkflowVersions, getWorkflowVersion, createPage, getPage, getPageBySlug, listPagesByAgent, listAllPages, countAllPages, countPagesByAgent, updatePage, deletePage, incrementPageViewCount, createPageVersion, getPageVersions, getPageVersion, createMetric, getMetric, getMetricBySlug, listMetricsByAgent, listAllMetrics, countAllMetrics, countMetricsByAgent, updateMetric, deleteMetric, createMetricVersion, getMetricVersions, getMetricVersion, getPromptTemplates, getPromptTemplateById, upsertPromptTemplate, deletePromptTemplate, resetPromptTemplateToDefault, getPromptTemplateHistory, resolvePromptTemplate, checkoutPromptTemplate, getAllChannelActivityCursors, getChannelActivityCursor, upsertChannelActivityCursor, createApprovalRequest, getApprovalRequestById, resolveApprovalRequest, updateApprovalRequestNotifications, listApprovalRequests, getStuckApprovalRuns, getApprovalRequestByStepId, getExpiredPendingApprovals, createWaitState, getWaitStateById, getWaitStateByStepId, getDueWaitStates, getPendingEventWaitNames, getPendingWaitsByEvent, resolveWaitState, getStuckWaitRuns, SKILL_FILE_LIMITS, normalizeSkillFilePath, createSkill, updateSkill, listSkillFileManifest, getSkillFiles, getSkillFile, upsertSkillFile, upsertSkillFiles, deleteSkillFile, deleteSkill, getSkillById, getSkillByName, listSkills, searchSkills, installSkill, getSystemDefaultSkills, installSystemDefaultSkillsForAgent, uninstallSkill, getAgentSkills, toggleAgentSkill, createMcpServer, updateMcpServer, deleteMcpServer, getMcpServerById, getMcpServerByName, listMcpServers, installMcpServer, uninstallMcpServer, getAgentMcpServers, createContextSnapshot, getContextSnapshotsByTaskId, getContextSnapshotsBySessionId, getContextSummaryByTaskId, getAvailableKeyIndices, recordKeyUsage, markKeyRateLimited, recordKeyRateLimitWindows, setApiKeyName, clearKeyRateLimit, getKeyStatuses, getKeyCostSummary, getUserById, getAllUsers, createUser, updateUser, deleteUser, listInboxState, upsertInboxState, listTaskTemplates, getRootTaskChain, listRecentSessions, countSessions, getBudget, getBudgets, upsertBudget, deleteBudget, getAllPricingRows, getPricingRows, getActivePricingRow, insertPricingRow, deletePricingRow, getDailySpendForAgent, getDailySpendGlobal, getDailySpendForUser, recordBudgetRefusalNotification, getBudgetRefusalNotification, getRecentBudgetRefusalNotifications, hasBudgetRefusalNotificationToday, setBudgetRefusalFollowUpTaskId, getLiveAgentCounts, getInstanceActivity, getSwarmMetrics, hasFirstCompletedTask, getKv, upsertKv, deleteKv, KvTypeCollisionError, incrKv, listKv, countKv, createScriptRun, recordInlineScriptRun, getScriptRun, getScriptRunByIdempotencyKey, listScriptRuns, countScriptRuns, countActiveScriptRuns, updateScriptRun, getRunningScriptRuns, getScriptRunJournalStep, upsertScriptRunJournalStep, listScriptRunJournalSteps, countScriptRunJournalSteps, countScriptRunJournalAgentTaskSteps, exports_db, init_db };
9744
+ export { interpolate, deepInterpolate, init_template, registerTemplate, getTemplateDefinition, getAllTemplateDefinitions, init_registry, configureHttpResolver, resolveTemplate, resolveTemplateAsync, init_resolver, initTelemetry, telemetry, init_telemetry, ModelTierSchema, splitLegacyModelAlias, resolveTaskModelSelection, AgentTaskStatusSchema, isTerminalTaskStatus, AgentTaskSourceSchema, ProviderNameSchema, FollowUpConfigSchema, AgentTaskSchema, AttachmentInputSchema, TaskAttachmentSchema, InboxItemTypeSchema, InboxItemStatusSchema, TaskTemplateKindSchema, AgentSchema, AgentLatestModelSchema, AgentCredStatusSchema, ChannelTypeSchema, ChannelSchema, ChannelMessageSchema, ServiceStatusSchema, ServiceSchema, ResumeReasonSchema, AgentLogSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, PageContentTypeSchema, PageAuthModeSchema, MetricDefinitionSchema, MetricVersionSchema, WorkflowRunStatusSchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, KvValueTypeSchema, KvNamespaceSchema, KvKeySchema, KvEntrySchema, init_types, setRequestAuth, getRequestAuth, init_request_auth_context, encryptSecret, decryptSecret, getEncryptionKey, init_crypto, normalizeDateRequired, init_date_utils, init_session_templates, init_templates, init_templates2 as init_templates1, isReservedConfigKey, reservedKeyError, validateConfigValue, init_swarm_config_guard, onTaskStarted, init_task_lifecycle_events, generateDefaultClaudeMd, generateDefaultSoulMd, generateDefaultIdentityMd, generateDefaultToolsMd, init_defaults, isSqliteVecAvailable, initDb, getDb, closeDb, computeContentHash, createContextVersion, getLatestContextVersion, getContextVersion, getContextVersionHistory, agentQueries, updateAgentCredentialState, createAgent, getAgentById, getAllAgents, getLeadAgent, updateAgentStatus, updateAgentMaxTasks, updateAgentProvider, setAgentHarnessProvider, updateAgentCredStatus, listAgentsWithCredStatusByProvider, getAgentHarnessProviders, updateAgentActivity, MAX_EMPTY_POLLS, incrementEmptyPollCount, resetEmptyPollCount, shouldBlockPolling, deleteAgent, getActiveTaskCount, hasCapacity, getRemainingCapacity, updateAgentStatusFromCapacity, taskQueries, createTask, getPendingTaskForAgent, assignUnassignedTaskPending, startTask, getTaskById, markTaskSlackReplySent, setSlackMessageTracking, getChildTasks, hasNonTerminalResumeChild, hasNonTerminalRerouteDecisionChild, updateTaskClaudeSessionId, updateTaskVcs, getTasksByAgentId, getAgentCurrentTask, getTasksByStatus, findTaskByVcs, findTaskByGitHub, getAllTasks, getTasksCount, getTaskStats, getCompletedSlackTasks, getRecentlyFinishedWorkerTasks, markTasksNotified, resetTasksNotified, getInProgressSlackTasks, getInProgressTasksByContextKey, getLatestTaskByContextKey, getAgentWorkingOnThread, getLatestActiveTaskInThread, getMostRecentTaskInThread, findCompletedTaskInThread, findRecentCancelledTaskInThread, completeTask, failTask, cancelTask, supersedeTask, backfillSupersedeTaskResumeTaskId, pauseTask, resumeTask, getPausedTasksForAgent, getOrphanedInProgressTasksForAgent, resetOrphanedInProgressTasksForAgent, getRecentlyCancelledTasksForAgent, deleteTask, updateTaskProgress, insertTaskAttachment, getTaskAttachments, getAgentWithTasks, getAllAgentsWithTasks, logQueries, createLogEntry, getLogsByAgentId, getLogsByTaskId, getLogsByTaskIdChronological, getLogsByEventType, getAllLogs, findRecentSimilarTasks, createTaskExtended, claimTask, releaseTask, acceptTask, rejectTask, moveTaskToBacklog, moveTaskFromBacklog, releaseStaleReviewingTasks, getOfferedTasksForAgent, claimOfferedTask, getUnassignedTasksCount, getUnassignedTaskIds, checkDependencies, getDependentTasks, cascadeFailDependents, updateAgentProfile, updateAgentName, createChannel, getMessageById, getChannelById, getChannelByName, getAllChannels, deleteChannel, postMessage, getChannelMessages, updateReadState, getLastReadAt, getUnreadMessages, getMentionsForAgent, getInboxSummary, claimMentions, releaseMentionProcessing, releaseStaleMentionProcessing, createService, getServiceById, getServiceByAgentAndName, getServicesByAgentId, getAllServices, updateServiceStatus, deleteService, upsertService, deleteServicesByAgentId, sessionLogQueries, createSessionLogs, getSessionLogsByTaskId, getSessionLogsBySession, createSessionCost, getSessionCostsByTaskId, getSessionCostsByAgentId, getAllSessionCosts, getSessionCostsFiltered, getSessionCostSummary, getDashboardCostSummary, createInboxMessage, getInboxMessageById, getUnreadInboxMessages, claimInboxMessages, markInboxMessageRead, markInboxMessageResponded, markInboxMessageDelegated, releaseStaleProcessingInbox, getConcurrentContext, getScheduledTasks, getScheduledTaskById, getScheduledTaskByName, createScheduledTask, updateScheduledTask, deleteScheduledTask, getDueScheduledTasks, autoEncryptLegacyPlaintextSecrets, maskSecrets, getSwarmConfigs, getInjectableGlobalConfigs, getSwarmConfigById, getSwarmConfigLookupById, upsertSwarmConfig, deleteSwarmConfig, getResolvedConfig, getSwarmRepos, getSwarmRepoById, getSwarmRepoByName, getSwarmRepoByUrl, createSwarmRepo, updateSwarmRepo, deleteSwarmRepo, getAgentMailInboxMapping, getAgentMailInboxMappingsByAgent, getAllAgentMailInboxMappings, createAgentMailInboxMapping, deleteAgentMailInboxMapping, findTaskByAgentMailThread, insertActiveSession, deleteActiveSession, deleteActiveSessionById, getActiveSessions, heartbeatActiveSession, cleanupStaleSessions, cleanupAgentSessions, updateActiveSessionProviderSessionId, getActiveSessionForTask, reassociateSessionLogs, getStalledInProgressTasks, getStalePinnedResumes, failPendingResumeIfUnclaimed, getIdleWorkersWithCapacity, getUnassignedPoolTasks, getRecentFailedTasks, getRecentCompletedCount, getRecentFailedCount, createWorkflow, getWorkflow, listWorkflows, updateWorkflow, deleteWorkflow, getWorkflowsByScheduleId, createWorkflowRun, getWorkflowRun, updateWorkflowRun, listWorkflowRuns, createWorkflowRunStep, getWorkflowRunStep, updateWorkflowRunStep, getWorkflowRunStepsByRunId, getStuckWorkflowRuns, getLastSuccessfulRun, getLastRunStart, getRetryableSteps, getCompletedStepNodeIds, getTaskByWorkflowRunStepId, getStepByIdempotencyKey, getStepCountForNode, getLatestStepForNode, createWorkflowVersion, getWorkflowVersions, getWorkflowVersion, createPage, getPage, getPageBySlug, listPagesByAgent, listAllPages, countAllPages, countPagesByAgent, updatePage, deletePage, incrementPageViewCount, createPageVersion, getPageVersions, getPageVersion, createMetric, getMetric, getMetricBySlug, listMetricsByAgent, listAllMetrics, countAllMetrics, countMetricsByAgent, updateMetric, deleteMetric, createMetricVersion, getMetricVersions, getMetricVersion, getPromptTemplates, getPromptTemplateById, upsertPromptTemplate, deletePromptTemplate, resetPromptTemplateToDefault, getPromptTemplateHistory, resolvePromptTemplate, checkoutPromptTemplate, getAllChannelActivityCursors, getChannelActivityCursor, upsertChannelActivityCursor, createApprovalRequest, getApprovalRequestById, resolveApprovalRequest, updateApprovalRequestNotifications, listApprovalRequests, getStuckApprovalRuns, getApprovalRequestByStepId, getExpiredPendingApprovals, createWaitState, getWaitStateById, getWaitStateByStepId, getDueWaitStates, getPendingEventWaitNames, getPendingWaitsByEvent, resolveWaitState, getStuckWaitRuns, SKILL_FILE_LIMITS, normalizeSkillFilePath, createSkill, updateSkill, listSkillFileManifest, getSkillFiles, getSkillFile, upsertSkillFile, upsertSkillFiles, deleteSkillFile, deleteSkill, getSkillById, getSkillByName, listSkills, searchSkills, installSkill, getSystemDefaultSkills, installSystemDefaultSkillsForAgent, uninstallSkill, getAgentSkills, toggleAgentSkill, createMcpServer, updateMcpServer, deleteMcpServer, getMcpServerById, getMcpServerByName, listMcpServers, installMcpServer, uninstallMcpServer, getAgentMcpServers, createContextSnapshot, getContextSnapshotsByTaskId, getContextSnapshotsBySessionId, getContextSummaryByTaskId, getAvailableKeyIndices, recordKeyUsage, markKeyRateLimited, recordKeyRateLimitWindows, setApiKeyName, clearKeyRateLimit, getKeyStatuses, getKeyCostSummary, getUserById, getAllUsers, createUser, updateUser, deleteUser, listInboxState, upsertInboxState, listTaskTemplates, getRootTaskChain, listRecentSessions, countSessions, getBudget, getBudgets, upsertBudget, deleteBudget, getAllPricingRows, getPricingRows, getActivePricingRow, insertPricingRow, deletePricingRow, getDailySpendForAgent, getDailySpendGlobal, getDailySpendForUser, recordBudgetRefusalNotification, getBudgetRefusalNotification, getRecentBudgetRefusalNotifications, hasBudgetRefusalNotificationToday, setBudgetRefusalFollowUpTaskId, getLiveAgentCounts, getInstanceActivity, getSwarmMetrics, hasFirstCompletedTask, getKv, upsertKv, deleteKv, KvTypeCollisionError, incrKv, listKv, countKv, createScriptRun, recordInlineScriptRun, getScriptRun, getScriptRunByIdempotencyKey, listScriptRuns, countScriptRuns, countActiveScriptRuns, updateScriptRun, getRunningScriptRuns, getScriptRunJournalStep, upsertScriptRunJournalStep, listScriptRunJournalSteps, countScriptRunJournalSteps, countScriptRunJournalAgentTaskSteps, exports_db, init_db };