@desplega.ai/agent-swarm 1.140.0 → 1.141.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 (71) hide show
  1. package/dist/{acp-adapter-npyh3hfv.js → acp-adapter-nymf4qqx.js} +1 -1
  2. package/dist/{actions-8nf107cn.js → actions-g062r5pe.js} +6 -6
  3. package/dist/{app-3s4kmb5k.js → app-y2gfznm7.js} +3 -3
  4. package/dist/{assistant-85n6cfgw.js → assistant-7b1vz5qy.js} +8 -8
  5. package/dist/{boot-reembed-9rx39tvr.js → boot-reembed-c7ezxtjj.js} +4 -4
  6. package/dist/{boot-reembed-0z7b721c.js → boot-reembed-zwt66k10.js} +3 -3
  7. package/dist/{boot-scrub-logs-zaft8n08.js → boot-scrub-logs-q2hq46vf.js} +2 -2
  8. package/dist/{claude-adapter-f51aqdh2.js → claude-adapter-jw7k5x7m.js} +3 -3
  9. package/dist/{cli-1j5yp21h.js → cli-0ejv5tq1.js} +2 -2
  10. package/dist/{cli-sz6cg9v8.js → cli-0z1cjytc.js} +8 -8
  11. package/dist/{cli-e764qkr0.js → cli-169dk2km.js} +1 -1
  12. package/dist/{cli-pynmwadf.js → cli-1smbv79b.js} +1 -1
  13. package/dist/{cli-ej7pwj1m.js → cli-2dycsvxt.js} +1 -1
  14. package/dist/{cli-cgha9zhm.js → cli-68n7t6am.js} +6 -6
  15. package/dist/{cli-b2wtvdwt.js → cli-ae7g0pp7.js} +40 -5
  16. package/dist/{cli-vn3rcr2c.js → cli-b4e7hnqh.js} +1 -1
  17. package/dist/{cli-t6gtahn6.js → cli-bbj8e2ws.js} +10 -4
  18. package/dist/{cli-x0zjngd4.js → cli-bmjg0n8y.js} +1 -1
  19. package/dist/{cli-wtpc1ejf.js → cli-e6wan0s7.js} +1 -1
  20. package/dist/{cli-gdat21q9.js → cli-fewd407e.js} +1 -1
  21. package/dist/{cli-h9fnaxmk.js → cli-fzwndvcp.js} +2 -2
  22. package/dist/{cli-b34t2mjc.js → cli-gchvp5qh.js} +2 -2
  23. package/dist/{cli-yj3mvdq6.js → cli-gwaxg2pw.js} +2 -2
  24. package/dist/{cli-bt41nfqq.js → cli-hgwjr0wx.js} +19 -19
  25. package/dist/{cli-740ttab0.js → cli-ks1x39f4.js} +5 -5
  26. package/dist/{cli-hsmjzyff.js → cli-ktajvfc1.js} +4 -4
  27. package/dist/{cli-v3cjpvw8.js → cli-sa6p8nqc.js} +3 -3
  28. package/dist/{cli-bvvnvazg.js → cli-sebnvgzq.js} +1 -1
  29. package/dist/{cli-ar3faz9d.js → cli-tbkvywy2.js} +1 -1
  30. package/dist/{cli-wq1rfmyr.js → cli-tzzvqbww.js} +1 -1
  31. package/dist/{cli-s1c38k54.js → cli-wqkg9vgk.js} +3 -3
  32. package/dist/{cli-z5vk2vk7.js → cli-wqs1rz1c.js} +3 -3
  33. package/dist/{cli-zj0w46jc.js → cli-xeckvc7v.js} +6 -6
  34. package/dist/{cli-snq43s3j.js → cli-xnsxc136.js} +1 -1
  35. package/dist/cli.js +10 -10
  36. package/dist/{commands-rnckandg.js → commands-1tw7002f.js} +2 -2
  37. package/dist/{db-szz3m7f1.js → db-xvs6h6sy.js} +2 -2
  38. package/dist/{handlers-azssw42m.js → handlers-x3tfy39f.js} +8 -8
  39. package/dist/{hook-v9gdb42y.js → hook-1d9m6edx.js} +1 -1
  40. package/dist/{hook-jkbpyap4.js → hook-7ga5tttv.js} +2 -2
  41. package/dist/{http-c7eg3n4h.js → http-vmmy7mdd.js} +38 -38
  42. package/dist/{index-03xgytp8.js → index-gcebknc7.js} +9 -9
  43. package/dist/{index-m3wpywsz.js → index-khs88v9c.js} +11 -11
  44. package/dist/{index-hp6ghhyw.js → index-v0m6fre7.js} +10 -10
  45. package/dist/{index-fm6wpp7e.js → index-zktsxh13.js} +8 -8
  46. package/dist/{keepalive-mbkpsm0v.js → keepalive-n30kyw2p.js} +4 -4
  47. package/dist/{lead-cq7gtjsg.js → lead-zha0ntzq.js} +21 -21
  48. package/dist/{maintenance-cpte8nzb.js → maintenance-y0a823n0.js} +4 -4
  49. package/dist/{oauth-refresh-sweep-mq5qv23k.js → oauth-refresh-sweep-tp81bvd0.js} +3 -3
  50. package/dist/{onboard-n939hwye.js → onboard-kqzbksgg.js} +2 -2
  51. package/dist/{otel-impl-fw3krdrh.js → otel-impl-bgseftwt.js} +1 -1
  52. package/dist/{pricing-refresh-adfxkk2d.js → pricing-refresh-1tv644rp.js} +4 -4
  53. package/dist/{rbac-roles-ja3y3hgy.js → rbac-roles-nbqjqb3h.js} +2 -2
  54. package/dist/{rbac-roles-2b3e06se.js → rbac-roles-pyh65xw7.js} +3 -3
  55. package/dist/{render-v2-qfsrtvm6.js → render-v2-bz6wnfqp.js} +3 -3
  56. package/dist/{seed-pricing-4a398z36.js → seed-pricing-4kamyke2.js} +3 -3
  57. package/dist/{setup-w512ykaf.js → setup-ks1rgmvn.js} +2 -2
  58. package/dist/{worker-87e3g35n.js → worker-tgq76zn6.js} +21 -21
  59. package/openapi.json +4 -2
  60. package/package.json +1 -1
  61. package/src/be/db.ts +74 -5
  62. package/src/http/agents.ts +7 -4
  63. package/src/tasks/worker-follow-up.ts +15 -2
  64. package/src/tests/acp-dashboard-runtime.test.ts +18 -0
  65. package/src/tests/agents-harness-provider.test.ts +81 -0
  66. package/src/tests/heartbeat-reroute-decision.test.ts +41 -0
  67. package/src/tests/pool-affinity.test.ts +140 -0
  68. package/src/tests/routing-affinity-inventory.test.ts +213 -0
  69. package/src/tests/task-tools-ctx.test.ts +17 -0
  70. package/src/tests/task-tools-ownership.test.ts +22 -0
  71. package/src/types.ts +8 -2
@@ -20,7 +20,7 @@ import {
20
20
  import {
21
21
  init_package,
22
22
  package_default
23
- } from "./cli-ej7pwj1m.js";
23
+ } from "./cli-2dycsvxt.js";
24
24
  import {
25
25
  init_secret_scrubber,
26
26
  scrubSecrets
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  resolveSlackUserId
3
- } from "./cli-h9fnaxmk.js";
4
- import"./cli-wtpc1ejf.js";
3
+ } from "./cli-fzwndvcp.js";
4
+ import"./cli-e6wan0s7.js";
5
5
  import {
6
6
  createTaskWithSiblingAwareness
7
- } from "./cli-gdat21q9.js";
7
+ } from "./cli-fewd407e.js";
8
8
  import {
9
9
  buildCancelledBlocks,
10
10
  ensureSlackThreadTree,
@@ -12,7 +12,7 @@ import {
12
12
  getAgentEmoji,
13
13
  getTaskLink,
14
14
  isSlackRenderV2Enabled
15
- } from "./cli-cgha9zhm.js";
15
+ } from "./cli-68n7t6am.js";
16
16
  import"./cli-qf9kpsve.js";
17
17
  import"./cli-g2p9bd1z.js";
18
18
  import {
@@ -23,7 +23,7 @@ import {
23
23
  init_context_key,
24
24
  init_db,
25
25
  slackContextKey
26
- } from "./cli-b2wtvdwt.js";
26
+ } from "./cli-ae7g0pp7.js";
27
27
  import"./cli-d2epf5ae.js";
28
28
  import"./cli-87zrjxdb.js";
29
29
  import"./cli-a1rrkrb4.js";
@@ -31,7 +31,7 @@ import"./cli-xbyjkasx.js";
31
31
  import"./cli-nanaxrz6.js";
32
32
  import"./cli-s35981d0.js";
33
33
  import"./cli-pqv5gvyf.js";
34
- import"./cli-ej7pwj1m.js";
34
+ import"./cli-2dycsvxt.js";
35
35
  import"./cli-mkq1rk7b.js";
36
36
  import"./cli-qntkxysp.js";
37
37
  import"./cli-497b685t.js";
@@ -3,10 +3,10 @@ import {
3
3
  initSlackApp,
4
4
  startSlackApp,
5
5
  stopSlackApp
6
- } from "./cli-cgha9zhm.js";
6
+ } from "./cli-68n7t6am.js";
7
7
  import"./cli-qf9kpsve.js";
8
8
  import"./cli-g2p9bd1z.js";
9
- import"./cli-b2wtvdwt.js";
9
+ import"./cli-ae7g0pp7.js";
10
10
  import"./cli-d2epf5ae.js";
11
11
  import"./cli-87zrjxdb.js";
12
12
  import"./cli-a1rrkrb4.js";
@@ -14,7 +14,7 @@ import"./cli-xbyjkasx.js";
14
14
  import"./cli-nanaxrz6.js";
15
15
  import"./cli-s35981d0.js";
16
16
  import"./cli-pqv5gvyf.js";
17
- import"./cli-ej7pwj1m.js";
17
+ import"./cli-2dycsvxt.js";
18
18
  import"./cli-mkq1rk7b.js";
19
19
  import"./cli-qntkxysp.js";
20
20
  import"./cli-497b685t.js";
@@ -2,24 +2,24 @@ import {
2
2
  bufferThreadMessage,
3
3
  getBufferMessageCount,
4
4
  wasEventSeen
5
- } from "./cli-740ttab0.js";
5
+ } from "./cli-ks1x39f4.js";
6
6
  import {
7
7
  hasOtherUserMention
8
- } from "./cli-x0zjngd4.js";
8
+ } from "./cli-bmjg0n8y.js";
9
9
  import {
10
10
  resolveSlackUserId,
11
11
  rewriteSlackMentions
12
- } from "./cli-h9fnaxmk.js";
13
- import"./cli-wtpc1ejf.js";
12
+ } from "./cli-fzwndvcp.js";
13
+ import"./cli-e6wan0s7.js";
14
14
  import {
15
15
  createTaskWithSiblingAwareness
16
- } from "./cli-gdat21q9.js";
16
+ } from "./cli-fewd407e.js";
17
17
  import {
18
18
  ackSlackMessage,
19
19
  ensureSlackThreadTree,
20
20
  isSlackRenderV2Enabled,
21
21
  require_dist
22
- } from "./cli-cgha9zhm.js";
22
+ } from "./cli-68n7t6am.js";
23
23
  import"./cli-qf9kpsve.js";
24
24
  import"./cli-g2p9bd1z.js";
25
25
  import {
@@ -29,7 +29,7 @@ import {
29
29
  init_context_key,
30
30
  init_db,
31
31
  slackContextKey
32
- } from "./cli-b2wtvdwt.js";
32
+ } from "./cli-ae7g0pp7.js";
33
33
  import"./cli-d2epf5ae.js";
34
34
  import {
35
35
  init_resolver,
@@ -43,7 +43,7 @@ import {
43
43
  } from "./cli-nanaxrz6.js";
44
44
  import"./cli-s35981d0.js";
45
45
  import"./cli-pqv5gvyf.js";
46
- import"./cli-ej7pwj1m.js";
46
+ import"./cli-2dycsvxt.js";
47
47
  import"./cli-mkq1rk7b.js";
48
48
  import"./cli-qntkxysp.js";
49
49
  import"./cli-497b685t.js";
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  embedScript,
3
3
  embeddingProvider
4
- } from "./cli-1j5yp21h.js";
5
- import"./cli-e764qkr0.js";
4
+ } from "./cli-0ejv5tq1.js";
5
+ import"./cli-169dk2km.js";
6
6
  import"./cli-dr5tcz68.js";
7
7
  import"./cli-vsap7a8d.js";
8
8
  import {
9
9
  getDbClient,
10
10
  init_db
11
- } from "./cli-b2wtvdwt.js";
11
+ } from "./cli-ae7g0pp7.js";
12
12
  import"./cli-d2epf5ae.js";
13
13
  import"./cli-87zrjxdb.js";
14
14
  import"./cli-a1rrkrb4.js";
@@ -16,7 +16,7 @@ import"./cli-xbyjkasx.js";
16
16
  import"./cli-nanaxrz6.js";
17
17
  import"./cli-s35981d0.js";
18
18
  import"./cli-pqv5gvyf.js";
19
- import"./cli-ej7pwj1m.js";
19
+ import"./cli-2dycsvxt.js";
20
20
  import"./cli-mkq1rk7b.js";
21
21
  import"./cli-pq2ee5ja.js";
22
22
 
@@ -3,13 +3,13 @@ import {
3
3
  getEmbeddingProvider,
4
4
  getMemoryStore,
5
5
  init_constants
6
- } from "./cli-e764qkr0.js";
6
+ } from "./cli-169dk2km.js";
7
7
  import"./cli-dr5tcz68.js";
8
8
  import"./cli-vsap7a8d.js";
9
9
  import {
10
10
  getDbClient,
11
11
  init_db
12
- } from "./cli-b2wtvdwt.js";
12
+ } from "./cli-ae7g0pp7.js";
13
13
  import"./cli-d2epf5ae.js";
14
14
  import"./cli-87zrjxdb.js";
15
15
  import"./cli-a1rrkrb4.js";
@@ -17,7 +17,7 @@ import"./cli-xbyjkasx.js";
17
17
  import"./cli-nanaxrz6.js";
18
18
  import"./cli-s35981d0.js";
19
19
  import"./cli-pqv5gvyf.js";
20
- import"./cli-ej7pwj1m.js";
20
+ import"./cli-2dycsvxt.js";
21
21
  import"./cli-mkq1rk7b.js";
22
22
  import"./cli-pq2ee5ja.js";
23
23
 
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getDbClient,
3
3
  init_db
4
- } from "./cli-b2wtvdwt.js";
4
+ } from "./cli-ae7g0pp7.js";
5
5
  import"./cli-d2epf5ae.js";
6
6
  import"./cli-87zrjxdb.js";
7
7
  import"./cli-a1rrkrb4.js";
@@ -9,7 +9,7 @@ import"./cli-xbyjkasx.js";
9
9
  import"./cli-nanaxrz6.js";
10
10
  import"./cli-s35981d0.js";
11
11
  import"./cli-pqv5gvyf.js";
12
- import"./cli-ej7pwj1m.js";
12
+ import"./cli-2dycsvxt.js";
13
13
  import {
14
14
  init_secret_scrubber,
15
15
  scrubSecrets
@@ -12,8 +12,8 @@ import {
12
12
  resolveClaudeBinary,
13
13
  resolveClaudeBinaryArgv,
14
14
  resolveClaudeBridgeEnabled
15
- } from "./cli-pynmwadf.js";
16
- import"./cli-bvvnvazg.js";
15
+ } from "./cli-1smbv79b.js";
16
+ import"./cli-sebnvgzq.js";
17
17
  import"./cli-a3pkfpqs.js";
18
18
  import"./cli-z0f80e8e.js";
19
19
  import"./cli-hp1n6zq3.js";
@@ -37,7 +37,7 @@ import"./cli-xbyjkasx.js";
37
37
  import"./cli-nanaxrz6.js";
38
38
  import"./cli-s35981d0.js";
39
39
  import"./cli-pqv5gvyf.js";
40
- import"./cli-ej7pwj1m.js";
40
+ import"./cli-2dycsvxt.js";
41
41
  import"./cli-mkq1rk7b.js";
42
42
  import"./cli-c4eeb5q2.js";
43
43
  import"./cli-00w4hbam.js";
@@ -4,11 +4,11 @@ import {
4
4
  getEmbeddingProvider,
5
5
  init_embedding,
6
6
  serializeEmbedding
7
- } from "./cli-e764qkr0.js";
7
+ } from "./cli-169dk2km.js";
8
8
  import {
9
9
  getDbClient,
10
10
  init_db
11
- } from "./cli-b2wtvdwt.js";
11
+ } from "./cli-ae7g0pp7.js";
12
12
  import {
13
13
  init_secret_scrubber,
14
14
  scrubSecrets
@@ -24,10 +24,10 @@ import {
24
24
  withSpan,
25
25
  withSpanContext,
26
26
  writeSkillsToFilesystem
27
- } from "./cli-bt41nfqq.js";
27
+ } from "./cli-hgwjr0wx.js";
28
28
  import {
29
29
  checkClaudeCredentials
30
- } from "./cli-pynmwadf.js";
30
+ } from "./cli-1smbv79b.js";
31
31
  import {
32
32
  MAX_RATE_LIMIT_RESET_MS,
33
33
  isCodexCreditsExhaustedMessage,
@@ -41,10 +41,10 @@ import {
41
41
  import {
42
42
  ensure,
43
43
  initialize
44
- } from "./cli-hsmjzyff.js";
44
+ } from "./cli-ktajvfc1.js";
45
45
  import {
46
46
  validateJsonSchema
47
- } from "./cli-zj0w46jc.js";
47
+ } from "./cli-xeckvc7v.js";
48
48
  import {
49
49
  authJsonToCredentialSelection,
50
50
  credentialsToAuthJson,
@@ -67,7 +67,7 @@ import {
67
67
  } from "./cli-dr5tcz68.js";
68
68
  import {
69
69
  taskAttachmentDisplayUrl
70
- } from "./cli-cgha9zhm.js";
70
+ } from "./cli-68n7t6am.js";
71
71
  import {
72
72
  ProviderNameSchema,
73
73
  initTelemetry,
@@ -75,7 +75,7 @@ import {
75
75
  init_types,
76
76
  resolveTaskModelSelection,
77
77
  telemetry
78
- } from "./cli-b2wtvdwt.js";
78
+ } from "./cli-ae7g0pp7.js";
79
79
  import {
80
80
  generateDefaultClaudeMd,
81
81
  generateDefaultIdentityMd,
@@ -143,7 +143,7 @@ async function materializeCodexAuthJson(_slot, creds, deps = {}) {
143
143
  async function createProviderAdapter(provider) {
144
144
  switch (provider) {
145
145
  case "claude": {
146
- const { ClaudeAdapter } = await import("./claude-adapter-f51aqdh2.js");
146
+ const { ClaudeAdapter } = await import("./claude-adapter-jw7k5x7m.js");
147
147
  return new ClaudeAdapter;
148
148
  }
149
149
  case "pi": {
@@ -167,7 +167,7 @@ async function createProviderAdapter(provider) {
167
167
  return new OpencodeAdapter;
168
168
  }
169
169
  case "acp": {
170
- const { ACPAdapter } = await import("./acp-adapter-npyh3hfv.js");
170
+ const { ACPAdapter } = await import("./acp-adapter-nymf4qqx.js");
171
171
  return new ACPAdapter;
172
172
  }
173
173
  default:
@@ -11,7 +11,7 @@ import {
11
11
  getDbClient,
12
12
  init_db,
13
13
  isSqliteVecAvailable
14
- } from "./cli-b2wtvdwt.js";
14
+ } from "./cli-ae7g0pp7.js";
15
15
  import {
16
16
  __esm,
17
17
  __export,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runStopHookSessionSummarySubprocess
3
- } from "./cli-bvvnvazg.js";
3
+ } from "./cli-sebnvgzq.js";
4
4
  import {
5
5
  SessionErrorTracker,
6
6
  buildOtelTraceparentEnv,
@@ -7,7 +7,7 @@ var package_default;
7
7
  var init_package = __esm(() => {
8
8
  package_default = {
9
9
  name: "@desplega.ai/agent-swarm",
10
- version: "1.140.0",
10
+ version: "1.141.0",
11
11
  description: "agent-swarm.dev — an open-source operating system for AI work: a lead agent breaks goals into tasks, routes them to specialized workers such as Claude Code or Codex, runs each worker in an isolated container, and preserves shared memory, tools, schedules, and review gates so delegated work compounds across sessions.",
12
12
  keywords: [
13
13
  "agent-swarm.dev",
@@ -35,7 +35,7 @@ import {
35
35
  setSlackMessageTracking,
36
36
  slackContextKey,
37
37
  updateSlackMessageRecord
38
- } from "./cli-b2wtvdwt.js";
38
+ } from "./cli-ae7g0pp7.js";
39
39
  import {
40
40
  buildAgentFsLiveUrl,
41
41
  getAppUrl,
@@ -55206,13 +55206,13 @@ async function initSlackApp() {
55206
55206
  logLevel: import_bolt.LogLevel.DEBUG,
55207
55207
  ...slackApiUrl ? { clientOptions: { slackApiUrl } } : {}
55208
55208
  });
55209
- const { registerMessageHandler } = await import("./handlers-azssw42m.js");
55210
- const { registerCommandHandler } = await import("./commands-rnckandg.js");
55211
- const { registerActionHandlers } = await import("./actions-8nf107cn.js");
55209
+ const { registerMessageHandler } = await import("./handlers-x3tfy39f.js");
55210
+ const { registerCommandHandler } = await import("./commands-1tw7002f.js");
55211
+ const { registerActionHandlers } = await import("./actions-g062r5pe.js");
55212
55212
  registerMessageHandler(app);
55213
55213
  registerCommandHandler(app);
55214
55214
  registerActionHandlers(app);
55215
- const { createAssistant } = await import("./assistant-85n6cfgw.js");
55215
+ const { createAssistant } = await import("./assistant-7b1vz5qy.js");
55216
55216
  app.assistant(createAssistant());
55217
55217
  return app;
55218
55218
  }
@@ -55221,7 +55221,7 @@ async function startSlackApp() {
55221
55221
  await initSlackApp();
55222
55222
  }
55223
55223
  if (app) {
55224
- const { isSlackRenderV2Enabled: isSlackRenderV2Enabled2 } = await import("./render-v2-qfsrtvm6.js");
55224
+ const { isSlackRenderV2Enabled: isSlackRenderV2Enabled2 } = await import("./render-v2-bz6wnfqp.js");
55225
55225
  if (isSlackRenderV2Enabled2())
55226
55226
  await ensureSlackRenderV2Activation();
55227
55227
  await app.start();
@@ -46,7 +46,7 @@ import {
46
46
  import {
47
47
  init_package,
48
48
  package_default
49
- } from "./cli-ej7pwj1m.js";
49
+ } from "./cli-2dycsvxt.js";
50
50
  import {
51
51
  init_secret_scrubber,
52
52
  registerVolatileSecret,
@@ -2523,6 +2523,7 @@ var init_types = __esm(() => {
2523
2523
  sourceTaskId: exports_zod.string().optional(),
2524
2524
  outputSchema: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
2525
2525
  inheritParentOutputSchema: exports_zod.boolean().optional(),
2526
+ inheritParentRoutingAffinity: exports_zod.boolean().optional(),
2526
2527
  followUpConfig: FollowUpConfigSchema.optional(),
2527
2528
  requestedByUserId: exports_zod.string().optional(),
2528
2529
  contextKey: exports_zod.string().optional(),
@@ -2817,6 +2818,7 @@ var init_types = __esm(() => {
2817
2818
  "task_rejected",
2818
2819
  "task_claimed",
2819
2820
  "task_claim_rejected_affinity",
2821
+ "task_dispatch_rejected_affinity",
2820
2822
  "task_authorization_rejected",
2821
2823
  "task_recovery_authorization",
2822
2824
  "task_released",
@@ -6664,6 +6666,28 @@ async function createTask(agentId, task, options) {
6664
6666
  } catch {}
6665
6667
  return rowToAgentTask(row);
6666
6668
  }
6669
+ async function logAffinityDispatchSkip(agent, task) {
6670
+ const now = Date.now();
6671
+ const lastLoggedAt = lastAffinityDispatchSkipLoggedAt.get(task.id);
6672
+ if (lastLoggedAt !== undefined && now - lastLoggedAt < AFFINITY_DISPATCH_SKIP_LOG_COOLDOWN_MS) {
6673
+ return;
6674
+ }
6675
+ lastAffinityDispatchSkipLoggedAt.set(task.id, now);
6676
+ try {
6677
+ await createLogEntry({
6678
+ eventType: "task_dispatch_rejected_affinity",
6679
+ agentId: agent.id,
6680
+ taskId: task.id,
6681
+ metadata: {
6682
+ agentRole: agent.role ?? null,
6683
+ requiredRole: task.routingAffinity?.role ?? null,
6684
+ leadOnly: task.routingAffinity?.leadOnly === true,
6685
+ agentIsLead: agent.isLead ?? false,
6686
+ routingAffinityInvalid: task.routingAffinityInvalid === true
6687
+ }
6688
+ });
6689
+ } catch {}
6690
+ }
6667
6691
  async function getPendingTaskForAgent(agentId) {
6668
6692
  const rows = await getDbClient().query("SELECT * FROM agent_tasks WHERE agentId = ? AND status = 'pending' ORDER BY priority DESC, createdAt ASC", [agentId]);
6669
6693
  const agent = await getAgentById(agentId);
@@ -6671,8 +6695,14 @@ async function getPendingTaskForAgent(agentId) {
6671
6695
  return null;
6672
6696
  for (const row of rows) {
6673
6697
  const task = rowToAgentTask(row);
6674
- if (!isAgentEligibleForTask(agent, task))
6698
+ if (task.routingAffinityInvalid) {
6699
+ await logAffinityDispatchSkip(agent, task);
6675
6700
  continue;
6701
+ }
6702
+ if (task.routingAffinity?.leadOnly && !isAgentEligibleForTask(agent, task)) {
6703
+ await logAffinityDispatchSkip(agent, task);
6704
+ continue;
6705
+ }
6676
6706
  const { ready } = await checkDependencies(task.id);
6677
6707
  if (ready)
6678
6708
  return task;
@@ -8655,6 +8685,9 @@ async function createTaskExtended(task, options) {
8655
8685
  throw new Error("createTaskExtended: 'task' must be a non-empty string");
8656
8686
  }
8657
8687
  options = CreateTaskOptionsSchema.parse(options ?? {});
8688
+ if (options.inheritParentRoutingAffinity === false && options.routingAffinity?.leadOnly !== true) {
8689
+ throw new Error("Disabling parent routing-affinity inheritance requires an explicit Lead-only control-plane affinity.");
8690
+ }
8658
8691
  let requestedByUserIdInherited = false;
8659
8692
  let routingAffinityIsInheritedProvenance = false;
8660
8693
  const id = crypto.randomUUID();
@@ -8734,10 +8767,10 @@ async function createTaskExtended(task, options) {
8734
8767
  if (parent.followUpConfig && !options.followUpConfig) {
8735
8768
  options.followUpConfig = parent.followUpConfig;
8736
8769
  }
8737
- if (parent.routingAffinityInvalid) {
8770
+ if (parent.routingAffinityInvalid && options.inheritParentRoutingAffinity !== false) {
8738
8771
  throw new Error(`Cannot continue task ${parent.id}: routing affinity is invalid.`);
8739
8772
  }
8740
- if (parent.routingAffinity) {
8773
+ if (parent.routingAffinity && options.inheritParentRoutingAffinity !== false) {
8741
8774
  if (!options.routingAffinity) {
8742
8775
  options.routingAffinity = parent.routingAffinity;
8743
8776
  routingAffinityIsInheritedProvenance = !parent.routingAffinity.leadOnly && (!!parent.routingAffinity.sourceAgentId || !!parent.routingAffinity.role);
@@ -14581,7 +14614,7 @@ async function countScriptRunJournalAgentTaskSteps(runId) {
14581
14614
  const row = await getDbClient().get("SELECT COUNT(*) AS count FROM script_run_journal WHERE runId = ? AND stepType = 'agent-task'", [runId]);
14582
14615
  return row?.count ?? 0;
14583
14616
  }
14584
- var db = null, sqliteVecAvailable = false, cachedSqliteVecExtensionPath = null, dbClientInstance = null, VERSIONABLE_FIELDS, BUDGETED_IDENTITY_FIELDS, MAX_EMPTY_POLLS = 2, PENDING_SLACK_MESSAGE_TS_PREFIX = "pending:", findTaskByGitHub, LINEAR_TRACKER_CONTEXT_KEY_PREFIX = "task:trackers:linear:", GENERATED_PULL_REQUEST_PROVIDER_ID = "github", GENERATED_PULL_REQUEST_INTENT = "task-deliverable", GENERATED_PULL_REQUEST_DESCRIPTION = "Pull request shipped by this task", GENERATED_PULL_REQUEST_SOURCE = "task-pull-request-recorder", ELIGIBILITY_SCAN_BATCH_SIZE, ELIGIBILITY_SCAN_CAP, UNATTRIBUTED_USER_ID = "unattributed", HUMAN_FREE_TASKS_CTE = `human_free_tasks(id) AS (
14617
+ var db = null, sqliteVecAvailable = false, cachedSqliteVecExtensionPath = null, dbClientInstance = null, VERSIONABLE_FIELDS, BUDGETED_IDENTITY_FIELDS, MAX_EMPTY_POLLS = 2, AFFINITY_DISPATCH_SKIP_LOG_COOLDOWN_MS, lastAffinityDispatchSkipLoggedAt, PENDING_SLACK_MESSAGE_TS_PREFIX = "pending:", findTaskByGitHub, LINEAR_TRACKER_CONTEXT_KEY_PREFIX = "task:trackers:linear:", GENERATED_PULL_REQUEST_PROVIDER_ID = "github", GENERATED_PULL_REQUEST_INTENT = "task-deliverable", GENERATED_PULL_REQUEST_DESCRIPTION = "Pull request shipped by this task", GENERATED_PULL_REQUEST_SOURCE = "task-pull-request-recorder", ELIGIBILITY_SCAN_BATCH_SIZE, ELIGIBILITY_SCAN_CAP, UNATTRIBUTED_USER_ID = "unattributed", HUMAN_FREE_TASKS_CTE = `human_free_tasks(id) AS (
14585
14618
  SELECT task.id
14586
14619
  FROM agent_tasks task
14587
14620
  LEFT JOIN agent_tasks parent ON parent.id = task.parentTaskId
@@ -14669,6 +14702,8 @@ var init_db = __esm(() => {
14669
14702
  "claudeMd",
14670
14703
  "toolsMd"
14671
14704
  ];
14705
+ AFFINITY_DISPATCH_SKIP_LOG_COOLDOWN_MS = 5 * 60 * 1000;
14706
+ lastAffinityDispatchSkipLoggedAt = new Map;
14672
14707
  findTaskByGitHub = findTaskByVcs;
14673
14708
  ELIGIBILITY_SCAN_BATCH_SIZE = Number(process.env.ELIGIBILITY_SCAN_BATCH_SIZE) || 25;
14674
14709
  ELIGIBILITY_SCAN_CAP = Number(process.env.ELIGIBILITY_SCAN_CAP) || 500;
@@ -5,7 +5,7 @@ import {
5
5
  getDb,
6
6
  getDbClient,
7
7
  init_db
8
- } from "./cli-b2wtvdwt.js";
8
+ } from "./cli-ae7g0pp7.js";
9
9
 
10
10
  // src/be/rbac-roles.ts
11
11
  init_db();
@@ -3,7 +3,7 @@ import {
3
3
  } from "./cli-qh4sqfws.js";
4
4
  import {
5
5
  taskAttachmentDisplayUrl
6
- } from "./cli-cgha9zhm.js";
6
+ } from "./cli-68n7t6am.js";
7
7
  import {
8
8
  buildRoutingAffinityFromAgent,
9
9
  createLogEntry,
@@ -25,7 +25,7 @@ import {
25
25
  updateAgentMaxTasks,
26
26
  updateAgentStatus,
27
27
  upsertSwarmConfig
28
- } from "./cli-b2wtvdwt.js";
28
+ } from "./cli-ae7g0pp7.js";
29
29
  import {
30
30
  init_resolver,
31
31
  resolveTemplate
@@ -612,10 +612,15 @@ async function createRerouteDecisionTask(args) {
612
612
  tags: ["reroute-decision"],
613
613
  priority: Math.min(100, (original.priority ?? 50) + 10),
614
614
  parentTaskId: original.id,
615
- inheritParentOutputSchema: false
615
+ inheritParentOutputSchema: false,
616
+ inheritParentRoutingAffinity: false,
617
+ routingAffinity: leadControlPlaneRoutingAffinity()
616
618
  });
617
619
  return { kind: "created", task: created };
618
620
  }
621
+ function leadControlPlaneRoutingAffinity() {
622
+ return { leadOnly: true, capabilities: [] };
623
+ }
619
624
  async function createPoolStarvationDecisionTask(args) {
620
625
  const { original } = args;
621
626
  const leadAgent = await getLeadAgent();
@@ -644,7 +649,8 @@ async function createPoolStarvationDecisionTask(args) {
644
649
  priority: Math.min(100, (original.priority ?? 50) + 10),
645
650
  parentTaskId: original.id,
646
651
  inheritParentOutputSchema: false,
647
- routingAffinity: { leadOnly: true, capabilities: [] }
652
+ inheritParentRoutingAffinity: false,
653
+ routingAffinity: leadControlPlaneRoutingAffinity()
648
654
  });
649
655
  return { kind: "created", task: created };
650
656
  }
@@ -3,7 +3,7 @@ import {
3
3
  getAgentWorkingOnThread,
4
4
  getAllAgents,
5
5
  init_db
6
- } from "./cli-b2wtvdwt.js";
6
+ } from "./cli-ae7g0pp7.js";
7
7
  import {
8
8
  init_env_flag,
9
9
  isEnvFlagEnabled
@@ -4,7 +4,7 @@ import {
4
4
  incrKv,
5
5
  init_db,
6
6
  upsertKv
7
- } from "./cli-b2wtvdwt.js";
7
+ } from "./cli-ae7g0pp7.js";
8
8
 
9
9
  // src/be/users.ts
10
10
  init_db();
@@ -3,7 +3,7 @@ import {
3
3
  getAgentById,
4
4
  getInProgressTasksByContextKey,
5
5
  init_db
6
- } from "./cli-b2wtvdwt.js";
6
+ } from "./cli-ae7g0pp7.js";
7
7
 
8
8
  // src/tasks/sibling-awareness.ts
9
9
  init_db();
@@ -4,12 +4,12 @@ import {
4
4
  linkIdentity,
5
5
  recordUnmappedIdentity,
6
6
  resolveIdentity
7
- } from "./cli-wtpc1ejf.js";
7
+ } from "./cli-e6wan0s7.js";
8
8
  import {
9
9
  getKv,
10
10
  init_db,
11
11
  upsertKv
12
- } from "./cli-b2wtvdwt.js";
12
+ } from "./cli-ae7g0pp7.js";
13
13
 
14
14
  // src/slack/enrich.ts
15
15
  init_db();
@@ -7,14 +7,14 @@ import {
7
7
  restoreScratchScriptLastUsedIfUnchanged,
8
8
  runScript,
9
9
  touchScratchScriptLastUsed
10
- } from "./cli-v3cjpvw8.js";
10
+ } from "./cli-sa6p8nqc.js";
11
11
  import {
12
12
  defaultAssetKey,
13
13
  getDbClient,
14
14
  getLeadAgent,
15
15
  init_db,
16
16
  init_key
17
- } from "./cli-b2wtvdwt.js";
17
+ } from "./cli-ae7g0pp7.js";
18
18
  import {
19
19
  init_zod
20
20
  } from "./cli-s35981d0.js";
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  buildModelsDevSeedRows,
3
3
  loadModelsDevCache
4
- } from "./cli-snq43s3j.js";
4
+ } from "./cli-xnsxc136.js";
5
5
  import {
6
6
  createLogEntry,
7
7
  getActivePricingRow,
8
8
  getDbClient,
9
9
  init_db,
10
10
  insertPricingRow
11
- } from "./cli-b2wtvdwt.js";
11
+ } from "./cli-ae7g0pp7.js";
12
12
  import {
13
13
  init_secret_scrubber,
14
14
  scrubSecrets