@desplega.ai/agent-swarm 1.116.0 → 1.117.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 (64) hide show
  1. package/README.md +2 -2
  2. package/dist/{actions-brtj223f.js → actions-7bnvhcgs.js} +10 -8
  3. package/dist/{app-00sngzz7.js → app-976fykvr.js} +3 -3
  4. package/dist/{assistant-j2ser3vg.js → assistant-5drs03t0.js} +13 -11
  5. package/dist/{boot-reembed-v4n0jphx.js → boot-reembed-0zhftca3.js} +4 -4
  6. package/dist/{boot-reembed-fv3r1kqg.js → boot-reembed-wce58xfv.js} +3 -3
  7. package/dist/{boot-scrub-logs-72sy5z1r.js → boot-scrub-logs-vkd2vvxp.js} +2 -2
  8. package/dist/{cli-ty7qe0vp.js → cli-09j7m5v3.js} +4 -4
  9. package/dist/{cli-cjmz7pp9.js → cli-1987vgjc.js} +3 -3
  10. package/dist/{cli-n9kkkmtm.js → cli-5ekf4gcj.js} +2 -76
  11. package/dist/{cli-b4hf0g0x.js → cli-6058t3w0.js} +1 -1
  12. package/dist/{cli-et9ab56s.js → cli-9kk0xa5w.js} +1 -1
  13. package/dist/{cli-96nd7vgs.js → cli-e0xv4nd4.js} +11 -9
  14. package/dist/{cli-2rxckty2.js → cli-f5cx2j92.js} +2 -2
  15. package/dist/{cli-3ys55x7x.js → cli-fep22bhf.js} +2 -2
  16. package/dist/{cli-0pwtr9f0.js → cli-hmw1vk30.js} +1 -1
  17. package/dist/{cli-0h9yzvhe.js → cli-jkp1gndy.js} +5 -5
  18. package/dist/{cli-50czs4qy.js → cli-kfjs4fjw.js} +1 -1
  19. package/dist/{cli-vggz87j8.js → cli-m4p6c600.js} +10 -8
  20. package/dist/{cli-vb7g0zgk.js → cli-ndsyqqqk.js} +2 -2
  21. package/dist/{cli-tw7xjzk7.js → cli-q0yn57de.js} +1 -1
  22. package/dist/{cli-xj6zntcq.js → cli-r06ed00c.js} +70 -24
  23. package/dist/{cli-vnvv6hvm.js → cli-rymspw51.js} +1 -1
  24. package/dist/{cli-k4yp6w9w.js → cli-s5q026mr.js} +295 -4
  25. package/dist/{cli-x4trwrcr.js → cli-t6n84nqv.js} +8 -6
  26. package/dist/{cli-x9q6bghe.js → cli-vwhg6sbn.js} +2 -2
  27. package/dist/{cli-rmyjzd8s.js → cli-w5axeg22.js} +1 -1
  28. package/dist/{cli-qnnbe59j.js → cli-xcp5dmts.js} +1 -1
  29. package/dist/{cli-9ys4kdd4.js → cli-yarjrgd5.js} +1 -1
  30. package/dist/{cli-5g3hx9cc.js → cli-z824vphk.js} +2 -2
  31. package/dist/cli.js +9 -9
  32. package/dist/{commands-4jt6hvc9.js → commands-b3p0fjzd.js} +2 -2
  33. package/dist/{db-1p5e9zj8.js → db-6xw82vz3.js} +2 -2
  34. package/dist/{handlers-5n9gq3ek.js → handlers-kwrk085v.js} +13 -11
  35. package/dist/{hook-ny4kv3r0.js → hook-e4wdztg5.js} +1 -1
  36. package/dist/{http-bb3pva4d.js → http-x7svk8q5.js} +41 -37
  37. package/dist/{index-dpcmhqy0.js → index-35tw5g2v.js} +6 -6
  38. package/dist/{index-nzghbv06.js → index-aadhkkde.js} +10 -10
  39. package/dist/{index-mheeg078.js → index-qb6nfqmy.js} +8 -8
  40. package/dist/{index-ajkj0aaf.js → index-zj38e3q2.js} +9 -9
  41. package/dist/{keepalive-vbgjzp3y.js → keepalive-enehyqc8.js} +4 -4
  42. package/dist/{lead-98bg3kfz.js → lead-nmzd0ykq.js} +18 -18
  43. package/dist/{maintenance-1fp5fz08.js → maintenance-staxb3xt.js} +4 -4
  44. package/dist/{oauth-refresh-sweep-91s6j3dq.js → oauth-refresh-sweep-fqczcwxn.js} +3 -3
  45. package/dist/{onboard-n32hf2t4.js → onboard-shmqj6ep.js} +2 -2
  46. package/dist/{otel-impl-j42cnqry.js → otel-impl-726bmdyc.js} +1 -1
  47. package/dist/{pricing-refresh-56gkeqaw.js → pricing-refresh-rzwka8rf.js} +4 -4
  48. package/dist/{rbac-roles-xwt8319h.js → rbac-roles-chkhakmf.js} +3 -3
  49. package/dist/{rbac-roles-c1ky22v2.js → rbac-roles-j2k0h8sx.js} +2 -2
  50. package/dist/{seed-pricing-qagjzjqj.js → seed-pricing-vta6a1q3.js} +3 -3
  51. package/dist/{setup-1kk84v0w.js → setup-yv9ctywz.js} +2 -2
  52. package/dist/{worker-bmjqg3c6.js → worker-7w6571j0.js} +18 -18
  53. package/openapi.json +1 -1
  54. package/package.json +1 -1
  55. package/src/be/db.ts +89 -3
  56. package/src/server-user.ts +1 -0
  57. package/src/tasks/slack-routing.ts +147 -0
  58. package/src/tests/approval-requests.test.ts +36 -0
  59. package/src/tests/http-api-integration.test.ts +38 -0
  60. package/src/tests/pages-complete-fetch.test.ts +54 -0
  61. package/src/tests/send-task-slack-routing-guard.test.ts +355 -0
  62. package/src/tests/slack-metadata-inheritance.test.ts +279 -1
  63. package/src/tests/slack-routing-guard.test.ts +164 -0
  64. package/src/tools/send-task.ts +145 -82
@@ -10,14 +10,14 @@ import {
10
10
  } from "./cli-ftyf58xj.js";
11
11
  import {
12
12
  startPricingRefreshLoop
13
- } from "./cli-3ys55x7x.js";
13
+ } from "./cli-fep22bhf.js";
14
14
  import {
15
15
  seedPricingFromModelsDev
16
- } from "./cli-tw7xjzk7.js";
16
+ } from "./cli-q0yn57de.js";
17
17
  import {
18
18
  ensureRbacSeedsSynced,
19
19
  getUserGrant
20
- } from "./cli-50czs4qy.js";
20
+ } from "./cli-kfjs4fjw.js";
21
21
  import {
22
22
  can,
23
23
  decideAdmission,
@@ -37,7 +37,7 @@ import {
37
37
  repointTrackerSyncBySwarmId,
38
38
  updateTrackerSync,
39
39
  updateTrackerSyncSwarmId
40
- } from "./cli-9ys4kdd4.js";
40
+ } from "./cli-yarjrgd5.js";
41
41
  import {
42
42
  ZodFirstPartyTypeKind,
43
43
  objectType
@@ -47,7 +47,7 @@ import {
47
47
  ensure,
48
48
  require_dist,
49
49
  runScheduleNow
50
- } from "./cli-x4trwrcr.js";
50
+ } from "./cli-t6n84nqv.js";
51
51
  import {
52
52
  TriggerSchemaError,
53
53
  applyDefinitionPatch,
@@ -61,7 +61,7 @@ import {
61
61
  startWorkflowExecution,
62
62
  validateDefinition,
63
63
  validateJsonSchema
64
- } from "./cli-96nd7vgs.js";
64
+ } from "./cli-e0xv4nd4.js";
65
65
  import {
66
66
  getApiKey
67
67
  } from "./cli-f14fvzag.js";
@@ -81,7 +81,7 @@ import {
81
81
  setScriptConnectionEnabled,
82
82
  upsertCredentialBinding,
83
83
  upsertScriptConnection
84
- } from "./cli-x9q6bghe.js";
84
+ } from "./cli-vwhg6sbn.js";
85
85
  import {
86
86
  CANDIDATE_SET_MULTIPLIER,
87
87
  computeScore,
@@ -93,7 +93,7 @@ import {
93
93
  isGraphExpansionEnabled,
94
94
  rerank,
95
95
  rowToCandidate
96
- } from "./cli-vnvv6hvm.js";
96
+ } from "./cli-rymspw51.js";
97
97
  import {
98
98
  buildAuthorizationUrl,
99
99
  ensureToken,
@@ -101,17 +101,17 @@ import {
101
101
  getOAuthApp,
102
102
  getOAuthTokens,
103
103
  upsertOAuthApp
104
- } from "./cli-0pwtr9f0.js";
104
+ } from "./cli-hmw1vk30.js";
105
105
  import {
106
106
  createAdditiveBuffer,
107
107
  extractSlackMessageText,
108
108
  parseSlackTs
109
- } from "./cli-et9ab56s.js";
109
+ } from "./cli-9kk0xa5w.js";
110
110
  import {
111
111
  getSlackApp,
112
112
  startSlackApp,
113
113
  stopSlackApp
114
- } from "./cli-0h9yzvhe.js";
114
+ } from "./cli-jkp1gndy.js";
115
115
  import {
116
116
  findOrCreateUserByEmail,
117
117
  findUserByExternalId,
@@ -127,18 +127,13 @@ import {
127
127
  resolveIdentityByEmail,
128
128
  resolveUserByToken,
129
129
  unlinkIdentity
130
- } from "./cli-rmyjzd8s.js";
130
+ } from "./cli-w5axeg22.js";
131
131
  import {
132
132
  markdownToSlack
133
133
  } from "./cli-ma04faw5.js";
134
134
  import {
135
- agentContextKey,
136
- agentmailContextKey,
137
- buildJiraContextKey,
138
- createTaskWithSiblingAwareness,
139
- githubContextKey,
140
- linearContextKey
141
- } from "./cli-n9kkkmtm.js";
135
+ createTaskWithSiblingAwareness
136
+ } from "./cli-5ekf4gcj.js";
142
137
  import {
143
138
  getAppUrl,
144
139
  getMcpBaseUrl,
@@ -190,8 +185,12 @@ import {
190
185
  WorkflowNodePatchSchema,
191
186
  WorkflowRunStatusSchema,
192
187
  acceptTask,
188
+ agentContextKey,
189
+ agentmailContextKey,
190
+ buildJiraContextKey,
193
191
  cancelTask,
194
192
  checkDependencies,
193
+ checkSlackRoutingCoherence,
195
194
  claimTask,
196
195
  completeTask,
197
196
  countKv,
@@ -299,15 +298,18 @@ import {
299
298
  getWorkflow,
300
299
  getWorkflowRun,
301
300
  getWorkflowRunStepsByRunId,
301
+ githubContextKey,
302
302
  hasCapacity,
303
303
  incrKv,
304
304
  incrementEmptyPollCount,
305
305
  initDb,
306
+ init_context_key,
306
307
  init_db,
307
308
  init_defaults,
308
309
  init_registry,
309
310
  init_request_auth_context,
310
311
  init_resolver,
312
+ init_slack_routing,
311
313
  init_swarm_config_guard,
312
314
  init_task_lifecycle_events,
313
315
  init_template,
@@ -319,6 +321,7 @@ import {
319
321
  isAgentEligibleForTask,
320
322
  isReservedConfigKey,
321
323
  isTerminalTaskStatus,
324
+ linearContextKey,
322
325
  listKv,
323
326
  listMcpServers,
324
327
  listSkills,
@@ -369,7 +372,7 @@ import {
369
372
  upsertService,
370
373
  upsertSwarmConfig,
371
374
  validateConfigValue
372
- } from "./cli-k4yp6w9w.js";
375
+ } from "./cli-s5q026mr.js";
373
376
  import {
374
377
  init_zod
375
378
  } from "./cli-bw80ck94.js";
@@ -377,6 +380,7 @@ import {
377
380
  $ZodObject,
378
381
  $ZodType,
379
382
  $constructor,
383
+ ZodIssueCode,
380
384
  ZodOptional,
381
385
  _enum,
382
386
  _null,
@@ -413,7 +417,7 @@ import {
413
417
  import {
414
418
  init_package,
415
419
  package_default
416
- } from "./cli-qnnbe59j.js";
420
+ } from "./cli-xcp5dmts.js";
417
421
  import {
418
422
  init_secret_scrubber,
419
423
  refreshSecretScrubberCache,
@@ -19701,7 +19705,7 @@ async function initOtel(serviceRole = process.env.AGENT_ROLE || "api") {
19701
19705
  return;
19702
19706
  initialized2 = true;
19703
19707
  try {
19704
- const impl = await import("./otel-impl-j42cnqry.js");
19708
+ const impl = await import("./otel-impl-726bmdyc.js");
19705
19709
  await impl.boot(serviceRole);
19706
19710
  realWithSpan = impl.withSpan;
19707
19711
  realStartSpan = impl.startSpan;
@@ -22194,6 +22198,7 @@ function kvWriteAuthError(namespace, info) {
22194
22198
 
22195
22199
  // src/tools/kv/resolve-namespace.ts
22196
22200
  init_db();
22201
+ init_context_key();
22197
22202
  function resolveNamespace(explicit, info) {
22198
22203
  if (explicit && explicit.length > 0) {
22199
22204
  return { namespace: explicit, source: "explicit" };
@@ -28606,6 +28611,7 @@ var registerScriptUpsertTool = (server) => {
28606
28611
  // src/tools/send-task.ts
28607
28612
  init_zod();
28608
28613
  init_db();
28614
+ init_slack_routing();
28609
28615
 
28610
28616
  // src/tools/task-dedup.ts
28611
28617
  init_db();
@@ -28677,8 +28683,19 @@ var sendTaskInputSchema = object({
28677
28683
  slackChannelId: string().optional().describe("Slack channel ID to post progress updates to. Use this to propagate Slack context when delegating from a Slack thread."),
28678
28684
  slackThreadTs: string().optional().describe("Slack thread timestamp. Required with slackChannelId for thread-level updates."),
28679
28685
  slackUserId: string().optional().describe("Slack user ID of the original requester."),
28686
+ overrideSlackContext: boolean().default(false).describe("Explicitly route this task's Slack updates to a different channel/thread than its parent/contextKey. Requires slackChannelId AND slackThreadTs. Use only for deliberate cross-channel dispatch (e.g. escalation to another human's DM); logged for audit. Without this flag, a slackChannelId/slackThreadTs that disagrees with the parent task or inherited contextKey is rejected — omit the three Slack fields to inherit them from the parent as a unit instead."),
28680
28687
  requestedByUserId: string().uuid().optional().describe("ID of the human user who originally requested this task chain. When omitted, inherited from the caller's current task so the attribution flows through multi-hop delegation automatically."),
28681
28688
  followUpConfig: FollowUpConfigSchema.optional().describe("Control the lead follow-up created when this task finishes. When to use `followUpConfig`: set `disabled: true` when you'll wait for this task to complete inline and no follow-up is needed; set `onCompleted` / `onFailed` with specific instructions when you need to follow up effectively on a particular outcome of a long-running flow; for normal one-shot tasks, leave it unset because defaults are fine. It is most valuable for long-running / complex flows.")
28689
+ }).superRefine((data, ctx) => {
28690
+ const hasChannel = !!data.slackChannelId;
28691
+ const hasThread = !!data.slackThreadTs;
28692
+ if (hasChannel !== hasThread) {
28693
+ ctx.addIssue({
28694
+ code: ZodIssueCode.custom,
28695
+ message: "slackChannelId and slackThreadTs must both be set, or both omitted.",
28696
+ path: [hasChannel ? "slackThreadTs" : "slackChannelId"]
28697
+ });
28698
+ }
28682
28699
  });
28683
28700
  var sendTaskOutputSchema = object({
28684
28701
  yourAgentId: string().uuid().optional(),
@@ -28722,6 +28739,7 @@ async function sendTaskHandler(ctx, {
28722
28739
  slackChannelId,
28723
28740
  slackThreadTs,
28724
28741
  slackUserId,
28742
+ overrideSlackContext,
28725
28743
  requestedByUserId: inputRequestedByUserId,
28726
28744
  followUpConfig
28727
28745
  }) {
@@ -28763,6 +28781,27 @@ async function sendTaskHandler(ctx, {
28763
28781
  const normalizedModel = splitLegacyModelAlias({ model, modelTier });
28764
28782
  const effectiveParentTaskId = parentTaskId ?? sourceTaskId;
28765
28783
  const effectiveParentTask = effectiveParentTaskId ? getTaskById(effectiveParentTaskId) : null;
28784
+ if (!overrideSlackContext) {
28785
+ const inheritedContextKey = effectiveParentTask?.contextKey;
28786
+ const routingCheck = checkSlackRoutingCoherence({
28787
+ explicit: { channelId: slackChannelId, threadTs: slackThreadTs, userId: slackUserId },
28788
+ parent: effectiveParentTask,
28789
+ inheritedContextKey
28790
+ });
28791
+ if (routingCheck.verdict !== "ok") {
28792
+ const msg = routingCheck.verdict === "partial-unit" ? `Slack routing rejected: ${routingCheck.detail}` : `Slack routing mismatch: you passed ${routingCheck.field}="${routingCheck.got}" but the ${routingCheck.expectedSource} task says "${routingCheck.expected}". Omit the three Slack fields to inherit them from the parent as a unit (preferred), or pass overrideSlackContext: true if the cross-channel routing is deliberate.`;
28793
+ return {
28794
+ content: [{ type: "text", text: msg }],
28795
+ structuredContent: {
28796
+ yourAgentId: creatorAgentId,
28797
+ success: false,
28798
+ message: msg
28799
+ }
28800
+ };
28801
+ }
28802
+ } else if (slackChannelId || slackThreadTs) {
28803
+ console.log(`[send-task] slack-context override: creatorAgentId=${creatorAgentId ?? "n/a"} slackChannelId=${slackChannelId ?? "n/a"} slackThreadTs=${slackThreadTs ?? "n/a"} parentTaskId=${effectiveParentTaskId ?? "n/a"}`);
28804
+ }
28766
28805
  let effectiveAgentId = agentId;
28767
28806
  if (effectiveParentTaskId && !agentId) {
28768
28807
  if (effectiveParentTask?.agentId) {
@@ -28842,6 +28881,7 @@ async function sendTaskHandler(ctx, {
28842
28881
  slackChannelId,
28843
28882
  slackThreadTs,
28844
28883
  slackUserId,
28884
+ overrideSlackContext,
28845
28885
  followUpConfig,
28846
28886
  routingAffinity: requiredCapabilities?.length ? { capabilities: requiredCapabilities } : undefined
28847
28887
  });
@@ -28895,6 +28935,7 @@ async function sendTaskHandler(ctx, {
28895
28935
  slackChannelId,
28896
28936
  slackThreadTs,
28897
28937
  slackUserId,
28938
+ overrideSlackContext,
28898
28939
  followUpConfig
28899
28940
  });
28900
28941
  transferTrackerSyncToResumeChild({
@@ -28926,6 +28967,7 @@ async function sendTaskHandler(ctx, {
28926
28967
  slackChannelId,
28927
28968
  slackThreadTs,
28928
28969
  slackUserId,
28970
+ overrideSlackContext,
28929
28971
  followUpConfig
28930
28972
  });
28931
28973
  transferTrackerSyncToResumeChild({
@@ -32281,6 +32323,7 @@ function createIngressBuffer(opts) {
32281
32323
  }
32282
32324
 
32283
32325
  // src/agentmail/handlers.ts
32326
+ init_context_key();
32284
32327
  init_event_bus();
32285
32328
 
32286
32329
  // src/agentmail/templates.ts
@@ -32830,6 +32873,7 @@ function stopAuditGc() {
32830
32873
  // src/github/handlers.ts
32831
32874
  init_db();
32832
32875
  init_resolver();
32876
+ init_context_key();
32833
32877
 
32834
32878
  // src/github/mentions.ts
32835
32879
  var GITHUB_BOT_NAME = process.env.GITHUB_BOT_NAME || "agent-swarm-bot";
@@ -34462,6 +34506,7 @@ Original issue: {{issue_key}} — {{issue_summary}}`,
34462
34506
  // src/jira/sync.ts
34463
34507
  init_db();
34464
34508
  init_resolver();
34509
+ init_context_key();
34465
34510
  init_types();
34466
34511
  var JIRA_WEBHOOK_ACTOR = { kind: "system", id: "webhook:jira" };
34467
34512
  function resolveJiraActor(accountId, email, name, sampleEventType, sampleContext) {
@@ -34838,7 +34883,7 @@ async function notifySlack(text) {
34838
34883
  return;
34839
34884
  }
34840
34885
  try {
34841
- const { getSlackApp: getSlackApp2 } = await import("./app-00sngzz7.js");
34886
+ const { getSlackApp: getSlackApp2 } = await import("./app-976fykvr.js");
34842
34887
  const app = getSlackApp2();
34843
34888
  if (!app) {
34844
34889
  console.warn("[Jira webhook keepalive] Slack not available, cannot send notification");
@@ -34907,7 +34952,7 @@ async function deleteJiraWebhook(webhookId) {
34907
34952
  console.log(`[Jira webhook keepalive] Deleted webhook id=${webhookId}`);
34908
34953
  }
34909
34954
  async function overwriteWebhookIds(next) {
34910
- const { getDb: getDb2 } = await import("./db-1p5e9zj8.js");
34955
+ const { getDb: getDb2 } = await import("./db-6xw82vz3.js");
34911
34956
  const db = getDb2();
34912
34957
  const txn = db.transaction(() => {
34913
34958
  const row = db.query("SELECT metadata FROM oauth_apps WHERE provider = 'jira'").get();
@@ -106641,6 +106686,7 @@ function resetLinearClient() {
106641
106686
  // src/linear/sync.ts
106642
106687
  init_db();
106643
106688
  init_resolver();
106689
+ init_context_key();
106644
106690
  init_types();
106645
106691
 
106646
106692
  // src/linear/gate.ts
@@ -6,7 +6,7 @@ import {
6
6
  getDb,
7
7
  init_db,
8
8
  isSqliteVecAvailable
9
- } from "./cli-k4yp6w9w.js";
9
+ } from "./cli-s5q026mr.js";
10
10
  import {
11
11
  __esm,
12
12
  __export,