@desplega.ai/agent-swarm 1.102.0 → 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 (107) hide show
  1. package/dist/{actions-j9399ktm.js → actions-7txktrdj.js} +6 -6
  2. package/dist/{app-tnq1pz27.js → app-xm3xsdye.js} +3 -3
  3. package/dist/{assistant-c7y92gkw.js → assistant-qpv63wk6.js} +9 -9
  4. package/dist/{boot-reembed-k7e6fc1p.js → boot-reembed-9cxqka3e.js} +3 -3
  5. package/dist/{boot-reembed-b97r699t.js → boot-reembed-chxhrwv8.js} +4 -4
  6. package/dist/{boot-scrub-logs-14kbc61y.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-tsz1q7gk.js → cli-2307phk1.js} +375 -23
  9. package/dist/{cli-g5px3d7x.js → cli-2957pqpj.js} +24 -1
  10. package/dist/{cli-9qascwj7.js → cli-2qynerth.js} +1 -1
  11. package/dist/{cli-k1ghyj8b.js → cli-4fnp2tc3.js} +1 -1
  12. package/dist/{cli-hc4rd6sv.js → cli-85pf4z38.js} +1 -1
  13. package/dist/{cli-zk4gn40w.js → cli-8hyv6c2v.js} +6 -14
  14. package/dist/{cli-k81y1cjb.js → cli-8w95v19d.js} +1 -1
  15. package/dist/{cli-7xdq3jg3.js → cli-92fqyjcv.js} +1 -1
  16. package/dist/{cli-zctkpdmd.js → cli-dz3d6zjg.js} +1 -1
  17. package/dist/{cli-d0t4854c.js → cli-fedn86nz.js} +213 -476
  18. package/dist/{cli-g861fwjp.js → cli-fwxdt7kt.js} +3 -3
  19. package/dist/{cli-2aaa9mqr.js → cli-fygaw191.js} +2 -2
  20. package/dist/{cli-qbc6mncp.js → cli-gzepjz54.js} +2 -2
  21. package/dist/{cli-r68m8arr.js → cli-jt9d9fjw.js} +1 -1
  22. package/dist/{cli-axtg1zaa.js → cli-khe4x17a.js} +1 -1
  23. package/dist/{cli-sygq3fhn.js → cli-kk51f3tf.js} +5 -5
  24. package/dist/{cli-dgab5x2h.js → cli-krvxq8bc.js} +1 -1
  25. package/dist/{cli-xde8vhhp.js → cli-ksq38x4n.js} +2 -2
  26. package/dist/{cli-stqqf5kh.js → cli-m8f6qzck.js} +1 -1
  27. package/dist/{cli-ap4md0gc.js → cli-ns0r7mkr.js} +30 -5
  28. package/dist/{cli-t2jk33ta.js → cli-rttgde5f.js} +18 -6
  29. package/dist/{cli-mhj07xbq.js → cli-rvae030h.js} +3 -3
  30. package/dist/{cli-q6jzg6wj.js → cli-s14sb64w.js} +4 -4
  31. package/dist/{cli-zmf7refz.js → cli-v9283nma.js} +1 -1
  32. package/dist/{cli-fjx4x7nn.js → cli-xmtsan9k.js} +1 -1
  33. package/dist/{cli-vgck9mqq.js → cli-yeemwevj.js} +155 -37
  34. package/dist/{cli-5bqa41fd.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-2wyn3swb.js → commands-aqn63mcw.js} +2 -2
  40. package/dist/{db-567ntpxv.js → db-azrvwsnj.js} +2 -2
  41. package/dist/{handlers-wvwpk2kj.js → handlers-hf61har3.js} +9 -9
  42. package/dist/{hook-fatkywc0.js → hook-306p3yz4.js} +2 -2
  43. package/dist/{http-eq6wxve6.js → http-zts4haq7.js} +81 -62
  44. package/dist/{index-400x6p3j.js → index-29vg51x6.js} +6 -6
  45. package/dist/{index-9wqh5352.js → index-3c651yfk.js} +10 -10
  46. package/dist/{index-6aj8966p.js → index-bfh9hgek.js} +5 -5
  47. package/dist/{index-d1rm4ea3.js → index-h2yqjyk0.js} +8 -8
  48. package/dist/{keepalive-6x9nx92g.js → keepalive-a0dg5pds.js} +4 -4
  49. package/dist/{lead-5fgqwe13.js → lead-7mcxedkc.js} +21 -21
  50. package/dist/{maintenance-eajx5k1k.js → maintenance-mrzqd53t.js} +4 -4
  51. package/dist/{onboard-jc1w1edg.js → onboard-4dkpv9wa.js} +2 -2
  52. package/dist/{otel-impl-8k375amf.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-zed6916t.js → pricing-refresh-xqnzh8dt.js} +4 -4
  55. package/dist/{seed-pricing-5805qzkz.js → seed-pricing-56tjm1fj.js} +3 -3
  56. package/dist/{setup-wz05vxh0.js → setup-tbwk8j10.js} +2 -2
  57. package/dist/{worker-j359graf.js → worker-e03za92t.js} +21 -21
  58. package/openapi.json +70 -1
  59. package/package.json +1 -1
  60. package/src/be/db.ts +83 -13
  61. package/src/be/migrations/098_repo_hooks_config.sql +3 -0
  62. package/src/be/task-lifecycle-events.ts +42 -0
  63. package/src/commands/runner.ts +174 -25
  64. package/src/github/task-reactions.ts +21 -0
  65. package/src/hooks/tool-loop-detection.test.ts +40 -0
  66. package/src/hooks/tool-loop-detection.ts +37 -1
  67. package/src/http/agents.ts +7 -0
  68. package/src/http/index.ts +16 -2
  69. package/src/http/prompt-templates.ts +1 -1
  70. package/src/http/repos.ts +5 -1
  71. package/src/http/schedules.ts +1 -1
  72. package/src/http/session-data.ts +2 -0
  73. package/src/http/tasks.ts +2 -1
  74. package/src/http/workflows.ts +1 -0
  75. package/src/prompts/resolver.ts +1 -1
  76. package/src/scheduler/scheduler.ts +25 -2
  77. package/src/server-runtime-counters.ts +12 -0
  78. package/src/server-user.ts +1 -2
  79. package/src/server.ts +5 -0
  80. package/src/telemetry.ts +18 -1
  81. package/src/tests/http-api-integration.test.ts +4 -0
  82. package/src/tests/model-control.test.ts +6 -6
  83. package/src/tests/swarm-repos.test.ts +25 -2
  84. package/src/tests/task-lifecycle-events.test.ts +53 -0
  85. package/src/tests/task-lifecycle-telemetry.test.ts +37 -1
  86. package/src/tests/telemetry-init.test.ts +32 -0
  87. package/src/tools/prompt-templates/preview.ts +1 -1
  88. package/src/tools/repos/update-repo.ts +6 -1
  89. package/src/tools/schedules/create-schedule.ts +1 -1
  90. package/src/tools/schedules/update-schedule.ts +1 -1
  91. package/src/tools/send-task.ts +7 -2
  92. package/src/tools/task-action.ts +6 -2
  93. package/src/types.ts +155 -1
  94. package/src/utils/template.ts +127 -0
  95. package/src/workflows/engine.ts +7 -0
  96. package/src/workflows/executors/agent-task.ts +1 -2
  97. package/src/workflows/template.ts +12 -121
  98. package/src/workflows/triggers.ts +6 -2
  99. package/templates/community/code-health-reports/PLAYBOOK.md +355 -0
  100. package/templates/community/code-health-reports/README.md +38 -0
  101. package/templates/community/code-health-reports/lead-prompt.md +52 -0
  102. package/templates/community/code-health-reports/report.mjs +378 -0
  103. package/templates/community/code-health-reports/run.sh +143 -0
  104. package/templates/schedules/weekly-code-health-reports/config.json +13 -0
  105. package/templates/schedules/weekly-code-health-reports/content.md +60 -0
  106. package/src/model-tiers.ts +0 -140
  107. 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-hc4rd6sv.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",
@@ -1397,6 +1060,9 @@ var init_types = __esm(() => {
1397
1060
  allowMerge: boolean().optional().default(false),
1398
1061
  review: array(string())
1399
1062
  });
1063
+ RepoHooksSchema = object({
1064
+ enabled: boolean().default(false)
1065
+ });
1400
1066
  SwarmRepoSchema = object({
1401
1067
  id: string().uuid(),
1402
1068
  url: string().min(1),
@@ -1404,6 +1070,7 @@ var init_types = __esm(() => {
1404
1070
  clonePath: string().min(1),
1405
1071
  defaultBranch: string().default("main"),
1406
1072
  autoClone: boolean().default(true),
1073
+ hooks: RepoHooksSchema.optional().default({ enabled: false }),
1407
1074
  guidelines: RepoGuidelinesSchema.nullable().optional(),
1408
1075
  createdAt: string(),
1409
1076
  lastUpdatedAt: string()
@@ -3488,6 +3155,25 @@ var init_swarm_config_guard = __esm(() => {
3488
3155
  };
3489
3156
  });
3490
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
+
3491
3177
  // src/prompts/defaults.ts
3492
3178
  function generateDefaultClaudeMd(agent) {
3493
3179
  const descSection = agent.description ? `${agent.description}
@@ -4100,6 +3786,18 @@ function emitTaskLifecycleTelemetryAfterCommit(event, props, verify) {
4100
3786
  telemetry.taskEvent(event, props);
4101
3787
  });
4102
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
+ }
4103
3801
  function isSqliteVecAvailable() {
4104
3802
  return sqliteVecAvailable;
4105
3803
  }
@@ -4702,7 +4400,7 @@ function startTask(taskId) {
4702
4400
  }
4703
4401
  const result = row ? rowToAgentTask(row) : null;
4704
4402
  if (result && oldTask.status !== "in_progress") {
4705
- addEyesReactionOnTaskStart(result).catch(() => {});
4403
+ emitTaskStarted(result);
4706
4404
  }
4707
4405
  return result;
4708
4406
  }
@@ -5118,6 +4816,8 @@ function completeTask(id, output) {
5118
4816
  if (row && oldTask) {
5119
4817
  emitTaskLifecycleTelemetryAfterCommit("completed", {
5120
4818
  taskId: id,
4819
+ source: oldTask.source,
4820
+ ...taskContextForTelemetry(oldTask),
5121
4821
  agentId: row.agentId ?? undefined,
5122
4822
  durationMs: row.createdAt ? Date.now() - new Date(row.createdAt).getTime() : undefined
5123
4823
  }, (task) => task?.status === "completed");
@@ -5157,6 +4857,8 @@ function failTask(id, reason) {
5157
4857
  if (row && oldTask) {
5158
4858
  emitTaskLifecycleTelemetryAfterCommit("failed", {
5159
4859
  taskId: id,
4860
+ source: oldTask.source,
4861
+ ...taskContextForTelemetry(oldTask),
5160
4862
  agentId: row.agentId ?? undefined,
5161
4863
  durationMs: row.createdAt ? Date.now() - new Date(row.createdAt).getTime() : undefined
5162
4864
  }, (task) => task?.status === "failed");
@@ -5250,6 +4952,14 @@ function supersedeTask(id, args) {
5250
4952
  WHERE id = ? AND status NOT IN ('completed', 'failed', 'cancelled', 'superseded')
5251
4953
  RETURNING *`).get(finishedAt, id);
5252
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");
5253
4963
  try {
5254
4964
  createLogEntry({
5255
4965
  eventType: "task_superseded",
@@ -5674,7 +5384,7 @@ function createTaskExtended(task, options) {
5674
5384
  emitTaskLifecycleTelemetryAfterCommit("created", {
5675
5385
  taskId: row.id,
5676
5386
  source: row.source,
5677
- tags: options?.tags ?? [],
5387
+ ...taskContextForTelemetry(rowToAgentTask(row)),
5678
5388
  hasParent: !!row.parentTaskId,
5679
5389
  priority: row.priority
5680
5390
  }, (task2) => task2 !== null);
@@ -5710,7 +5420,7 @@ function claimTask(taskId, agentId) {
5710
5420
  }
5711
5421
  const result = row ? rowToAgentTask(row) : null;
5712
5422
  if (result) {
5713
- addEyesReactionOnTaskStart(result).catch(() => {});
5423
+ emitTaskStarted(result);
5714
5424
  }
5715
5425
  return result;
5716
5426
  }
@@ -7044,6 +6754,7 @@ function rowToSwarmRepo(row) {
7044
6754
  clonePath: row.clonePath,
7045
6755
  defaultBranch: row.defaultBranch,
7046
6756
  autoClone: row.autoClone === 1,
6757
+ hooks: row.hooks ? JSON.parse(row.hooks) : { enabled: false },
7047
6758
  guidelines: row.guidelines ? JSON.parse(row.guidelines) : null,
7048
6759
  createdAt: row.createdAt,
7049
6760
  lastUpdatedAt: row.lastUpdatedAt
@@ -7079,10 +6790,11 @@ function getSwarmRepoByUrl(url) {
7079
6790
  function createSwarmRepo(data) {
7080
6791
  const id = crypto.randomUUID();
7081
6792
  const now = new Date().toISOString();
7082
- 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 });
7083
6795
  const guidelinesJson = data.guidelines ? JSON.stringify(data.guidelines) : null;
7084
- const row = getDb().prepare(`INSERT INTO swarm_repos (id, url, name, clonePath, defaultBranch, autoClone, guidelines, createdAt, lastUpdatedAt)
7085
- 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);
7086
6798
  if (!row)
7087
6799
  throw new Error("Failed to create repo");
7088
6800
  return rowToSwarmRepo(row);
@@ -7101,6 +6813,10 @@ function updateSwarmRepo(id, updates) {
7101
6813
  setClauses.push("autoClone = ?");
7102
6814
  params.push(updates.autoClone ? 1 : 0);
7103
6815
  }
6816
+ if (updates.hooks !== undefined) {
6817
+ setClauses.push("hooks = ?");
6818
+ params.push(updates.hooks ? JSON.stringify(updates.hooks) : null);
6819
+ }
7104
6820
  if (updates.guidelines !== undefined) {
7105
6821
  setClauses.push("guidelines = ?");
7106
6822
  params.push(updates.guidelines ? JSON.stringify(updates.guidelines) : null);
@@ -7422,6 +7138,22 @@ function getWorkflowRun(id) {
7422
7138
  const row = getDb().prepare("SELECT * FROM workflow_runs WHERE id = ?").get(id);
7423
7139
  return row ? rowToWorkflowRun(row) : null;
7424
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
+ }
7425
7157
  function updateWorkflowRun(id, data) {
7426
7158
  const updates = [];
7427
7159
  const params = [];
@@ -7447,7 +7179,13 @@ function updateWorkflowRun(id, data) {
7447
7179
  params.push(new Date().toISOString());
7448
7180
  params.push(id);
7449
7181
  const row = getDb().prepare(`UPDATE workflow_runs SET ${updates.join(", ")} WHERE id = ? RETURNING *`).get(...params);
7450
- 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;
7451
7189
  }
7452
7190
  function listWorkflowRuns(workflowId) {
7453
7191
  return getDb().prepare("SELECT * FROM workflow_runs WHERE workflowId = ? ORDER BY startedAt DESC").all(workflowId).map(rowToWorkflowRun);
@@ -9899,8 +9637,6 @@ var db = null, sqliteVecAvailable = false, VERSIONABLE_FIELDS, agentQueries, MAX
9899
9637
  var init_db = __esm(() => {
9900
9638
  init_provider_metadata();
9901
9639
  init_package();
9902
- init_task_reactions();
9903
- init_model_tiers();
9904
9640
  init_resolver();
9905
9641
  init_telemetry();
9906
9642
  init_types();
@@ -9912,6 +9648,7 @@ var init_db = __esm(() => {
9912
9648
  init_runner();
9913
9649
  init_seed_prompt_templates();
9914
9650
  init_swarm_config_guard();
9651
+ init_task_lifecycle_events();
9915
9652
  init_defaults();
9916
9653
  VERSIONABLE_FIELDS = [
9917
9654
  "soulMd",
@@ -10004,4 +9741,4 @@ var init_db = __esm(() => {
10004
9741
  };
10005
9742
  });
10006
9743
 
10007
- 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 };