@desplega.ai/agent-swarm 1.130.0 → 1.131.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 (122) hide show
  1. package/README.md +1 -1
  2. package/dist/{actions-73ee723n.js → actions-w53mbns9.js} +7 -7
  3. package/dist/{anthropic-messages-3xgme8my.js → anthropic-messages-rjmd2e7n.js} +5 -5
  4. package/dist/{app-hz5c2xay.js → app-m9gwqsqv.js} +4 -4
  5. package/dist/{assistant-08mr16yp.js → assistant-bp65m6f3.js} +9 -9
  6. package/dist/{azure-openai-responses-xa4sh9f6.js → azure-openai-responses-c0yjmbfd.js} +8 -5
  7. package/dist/{boot-reembed-5bgan3cd.js → boot-reembed-62p0at2k.js} +4 -4
  8. package/dist/{boot-reembed-z7ykyeq8.js → boot-reembed-xmfp6wdh.js} +5 -5
  9. package/dist/{boot-scrub-logs-b2rjk8mv.js → boot-scrub-logs-rr8q2dms.js} +3 -3
  10. package/dist/{claude-adapter-qr0k17km.js → claude-adapter-2y47mrkd.js} +6 -6
  11. package/dist/{cli-s21zzx4b.js → cli-0rcyq6d9.js} +447 -183
  12. package/dist/{cli-brebbsen.js → cli-2q72qz2s.js} +9 -6
  13. package/dist/{cli-e5p3es48.js → cli-3kf51j15.js} +1 -1
  14. package/dist/{cli-vgexpfsr.js → cli-57khth04.js} +6 -3
  15. package/dist/{cli-h3e66g5b.js → cli-5kx36evn.js} +1 -1
  16. package/dist/{cli-n9yxcnvk.js → cli-5n6e5yfn.js} +29 -7
  17. package/dist/{cli-tp519bjz.js → cli-5v4rw6yd.js} +2 -2
  18. package/dist/{cli-dakxgk70.js → cli-5ze9rv97.js} +4 -4
  19. package/dist/{cli-ch7t5v7n.js → cli-6map995v.js} +9 -4
  20. package/dist/{cli-mgerp0vs.js → cli-70xqj0z3.js} +2 -2
  21. package/dist/{cli-7v5dhmc8.js → cli-72q8m8gk.js} +6 -6
  22. package/dist/{cli-yj7z99vp.js → cli-78xwvkhj.js} +2 -2
  23. package/dist/{cli-t5tsq67k.js → cli-9dr5qzc0.js} +39 -4
  24. package/dist/{cli-73bvdyxr.js → cli-a40rnf71.js} +6 -6
  25. package/dist/{cli-s18zzkfp.js → cli-a4jzdpa3.js} +44 -7
  26. package/dist/{cli-w10fkrf1.js → cli-akdvwc9v.js} +354 -115
  27. package/dist/{cli-hntzdchd.js → cli-bqw0mt1n.js} +1 -1
  28. package/dist/{cli-mhr8tq3v.js → cli-cdeg08wx.js} +1 -1
  29. package/dist/{cli-qcsjdppx.js → cli-cvgjwnh1.js} +7 -7
  30. package/dist/{cli-z9q7pb38.js → cli-d2tfkcga.js} +4 -4
  31. package/dist/{cli-r62me33w.js → cli-d3x3x1c9.js} +2 -2
  32. package/dist/{cli-6nh2qxvh.js → cli-darcwax3.js} +1 -1
  33. package/dist/{cli-326083vb.js → cli-e7ckcg4v.js} +12 -12
  34. package/dist/{cli-fs153s3x.js → cli-efxfnq6q.js} +3 -3
  35. package/dist/{cli-xg2eezyv.js → cli-f1am9szv.js} +1 -1
  36. package/dist/{cli-2pa5w9b6.js → cli-fywms69x.js} +1 -1
  37. package/dist/{cli-1mj7yz1r.js → cli-g6b8x1h8.js} +1 -1
  38. package/dist/{cli-epsvdckx.js → cli-gm9cbhbq.js} +20 -10
  39. package/dist/{cli-tfw3c0y1.js → cli-nm5gtp1x.js} +2 -2
  40. package/dist/{cli-q8zwffx0.js → cli-pm6xbh84.js} +128 -35
  41. package/dist/{cli-m8fs5ttq.js → cli-psh3c4va.js} +1 -1
  42. package/dist/{cli-1px8pn1s.js → cli-qv61hp37.js} +2 -2
  43. package/dist/{cli-mf009e0j.js → cli-rzbpmxdr.js} +1 -1
  44. package/dist/{cli-vr2f46zj.js → cli-t1xze5qh.js} +1 -1
  45. package/dist/{cli-qbb2ten8.js → cli-t55yw3a1.js} +2 -2
  46. package/dist/{cli-haanc4qd.js → cli-t76vw5db.js} +22 -22
  47. package/dist/{cli-4n4mdv21.js → cli-xpxde7rm.js} +7 -3
  48. package/dist/{cli-xdrmxvd4.js → cli-yw8vghx2.js} +46 -10
  49. package/dist/cli.js +22 -22
  50. package/dist/{codex-adapter-6pc50x9q.js → codex-adapter-d24q75wk.js} +4 -4
  51. package/dist/{codex-hook-amndawyb.js → codex-hook-hq54t9ft.js} +2 -2
  52. package/dist/{codex-session-runner-tpg8hyj7.js → codex-session-runner-g50vcsex.js} +4 -4
  53. package/dist/{commands-yfpwt11g.js → commands-c3nrc5hg.js} +3 -3
  54. package/dist/{db-jn499nmp.js → db-nt7fg3tw.js} +3 -3
  55. package/dist/{google-generative-ai-txgg2q58.js → google-generative-ai-hysrd8qx.js} +7 -5
  56. package/dist/{google-vertex-t663s1c3.js → google-vertex-p5arrga0.js} +7 -5
  57. package/dist/{handlers-eev4nng0.js → handlers-fkr6swat.js} +9 -9
  58. package/dist/{hook-sn7pj75w.js → hook-77wpvnjc.js} +4 -4
  59. package/dist/{hook-9fkwkf3m.js → hook-g019yehy.js} +5 -5
  60. package/dist/{http-xdbbtmhx.js → http-jewj0syk.js} +202 -79
  61. package/dist/{index-c0qedjh6.js → index-6gm5he8h.js} +9 -9
  62. package/dist/{index-5fdsemf0.js → index-7n2xpbd4.js} +155 -37
  63. package/dist/{index-9vnkprkh.js → index-hfvggd0z.js} +10 -10
  64. package/dist/{index-fnack5vh.js → index-hp1kdbjj.js} +11 -11
  65. package/dist/{keepalive-fc7a2hw9.js → keepalive-j0fjvqfd.js} +5 -5
  66. package/dist/{lead-1fva34y9.js → lead-1n8x30xe.js} +28 -28
  67. package/dist/{maintenance-0rdb12vf.js → maintenance-gvev11sa.js} +5 -5
  68. package/dist/{mistral-conversations-4swenhmf.js → mistral-conversations-81fwav0j.js} +2 -2
  69. package/dist/{oauth-refresh-sweep-f9rptqbt.js → oauth-refresh-sweep-s9ecsvh0.js} +4 -4
  70. package/dist/{onboard-9zn0fx2m.js → onboard-pvm5b38w.js} +2 -2
  71. package/dist/{openai-codex-responses-xetseqvt.js → openai-codex-responses-5g27pd6f.js} +43 -23
  72. package/dist/{openai-completions-5r2g5axa.js → openai-completions-3vkmfz2a.js} +55 -11
  73. package/dist/{openai-responses-ce67hd23.js → openai-responses-dg4t7j7a.js} +8 -5
  74. package/dist/{openrouter-images-pzfp22jb.js → openrouter-images-g3gm8931.js} +1 -1
  75. package/dist/{otel-impl-thnttmbn.js → otel-impl-p6jvgd9c.js} +1 -1
  76. package/dist/{pi-mono-adapter-bpfrn6d7.js → pi-mono-adapter-t091s27g.js} +17114 -7514
  77. package/dist/{pricing-refresh-n0ve0kh6.js → pricing-refresh-k49rcyed.js} +5 -5
  78. package/dist/{rbac-roles-bbwb4wrm.js → rbac-roles-30pspvy7.js} +5 -5
  79. package/dist/{rbac-roles-w45bhahg.js → rbac-roles-cr80g96t.js} +4 -4
  80. package/dist/{render-v2-d675cp9r.js → render-v2-xm457ng1.js} +4 -4
  81. package/dist/{seed-pricing-47q77nw4.js → seed-pricing-yhpv35fr.js} +4 -4
  82. package/dist/{setup-3vnv2m43.js → setup-nytnmwwr.js} +2 -2
  83. package/dist/{worker-7shsr8hk.js → worker-msytr2cw.js} +28 -28
  84. package/openapi.json +342 -10
  85. package/package.json +6 -6
  86. package/src/apps/store.ts +13 -4
  87. package/src/assets/key.ts +8 -1
  88. package/src/be/asset-key-audit.ts +3 -1
  89. package/src/be/db-queries/mcp-oauth.ts +26 -0
  90. package/src/be/db.ts +42 -1
  91. package/src/be/migrations/129_asset_keys_apps_scripts.sql +161 -0
  92. package/src/be/scripts/db.ts +5 -2
  93. package/src/be/seed-skills/index.ts +7 -0
  94. package/src/http/assets.ts +120 -29
  95. package/src/http/mcp-oauth.ts +69 -1
  96. package/src/http/users.ts +45 -0
  97. package/src/oauth/ensure-mcp-token.ts +7 -1
  98. package/src/oauth/mcp-wrapper.ts +247 -24
  99. package/src/providers/pi-mono-adapter.ts +1 -1
  100. package/src/tests/asset-key-api.test.ts +48 -2
  101. package/src/tests/asset-key-invariants.test.ts +92 -0
  102. package/src/tests/asset-key-migration.test.ts +174 -8
  103. package/src/tests/asset-key-normalization.test.ts +2 -0
  104. package/src/tests/mcp-oauth-dcr-reuse.test.ts +95 -0
  105. package/src/tests/mcp-oauth-ensure-token.test.ts +23 -0
  106. package/src/tests/mcp-oauth-manual-client.test.ts +135 -2
  107. package/src/tests/mcp-oauth-wrapper.test.ts +380 -0
  108. package/src/tests/rbac-admission-e2e.test.ts +68 -0
  109. package/src/tests/script-connections.test.ts +3 -0
  110. package/src/tests/whoami-route.test.ts +127 -0
  111. package/src/tests/workflow-engine-v2.test.ts +80 -7
  112. package/src/tests/workflow-swarm-script.test.ts +104 -0
  113. package/src/tools/workflows/create-workflow.ts +4 -1
  114. package/src/types.ts +18 -5
  115. package/src/utils/template.ts +8 -1
  116. package/src/workflows/engine.ts +27 -4
  117. package/src/workflows/executors/swarm-script.ts +28 -0
  118. package/src/workflows/retry-poller.ts +19 -2
  119. package/templates/skills/asset-namespaces/content.md +2 -2
  120. package/templates/skills/scheduled-task-resilience/SKILL.md +102 -0
  121. package/templates/skills/scheduled-task-resilience/config.json +14 -0
  122. package/templates/skills/scheduled-task-resilience/content.md +97 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  init_env_flag,
3
3
  isEnvFlagEnabled
4
- } from "./cli-4n4mdv21.js";
4
+ } from "./cli-xpxde7rm.js";
5
5
  import {
6
6
  init_zod
7
7
  } from "./cli-zsspvvm2.js";
@@ -3,7 +3,7 @@ import {
3
3
  getAgentById,
4
4
  getInProgressTasksByContextKey,
5
5
  init_db
6
- } from "./cli-s18zzkfp.js";
6
+ } from "./cli-a4jzdpa3.js";
7
7
 
8
8
  // src/tasks/sibling-awareness.ts
9
9
  init_db();
@@ -37,11 +37,11 @@ import {
37
37
  setSlackMessageTracking,
38
38
  slackContextKey,
39
39
  updateSlackMessageRecord
40
- } from "./cli-s18zzkfp.js";
40
+ } from "./cli-a4jzdpa3.js";
41
41
  import {
42
42
  init_env_flag,
43
43
  isEnvFlagEnabled
44
- } from "./cli-4n4mdv21.js";
44
+ } from "./cli-xpxde7rm.js";
45
45
  import {
46
46
  getAppUrl,
47
47
  init_constants
@@ -55420,13 +55420,13 @@ async function initSlackApp() {
55420
55420
  socketMode: true,
55421
55421
  logLevel: import_bolt.LogLevel.DEBUG
55422
55422
  });
55423
- const { registerMessageHandler } = await import("./handlers-eev4nng0.js");
55424
- const { registerCommandHandler } = await import("./commands-yfpwt11g.js");
55425
- const { registerActionHandlers } = await import("./actions-73ee723n.js");
55423
+ const { registerMessageHandler } = await import("./handlers-fkr6swat.js");
55424
+ const { registerCommandHandler } = await import("./commands-c3nrc5hg.js");
55425
+ const { registerActionHandlers } = await import("./actions-w53mbns9.js");
55426
55426
  registerMessageHandler(app);
55427
55427
  registerCommandHandler(app);
55428
55428
  registerActionHandlers(app);
55429
- const { createAssistant } = await import("./assistant-08mr16yp.js");
55429
+ const { createAssistant } = await import("./assistant-bp65m6f3.js");
55430
55430
  app.assistant(createAssistant());
55431
55431
  return app;
55432
55432
  }
@@ -55435,7 +55435,7 @@ async function startSlackApp() {
55435
55435
  await initSlackApp();
55436
55436
  }
55437
55437
  if (app) {
55438
- const { isSlackRenderV2Enabled: isSlackRenderV2Enabled2 } = await import("./render-v2-d675cp9r.js");
55438
+ const { isSlackRenderV2Enabled: isSlackRenderV2Enabled2 } = await import("./render-v2-xm457ng1.js");
55439
55439
  if (isSlackRenderV2Enabled2())
55440
55440
  ensureSlackRenderV2Activation();
55441
55441
  await app.start();
@@ -7,11 +7,11 @@ import {
7
7
  getPinCandidateAgent,
8
8
  getResumeGeneration,
9
9
  repointTrackerSyncBySwarmId
10
- } from "./cli-tfw3c0y1.js";
10
+ } from "./cli-nm5gtp1x.js";
11
11
  import {
12
12
  getExecutorRegistry,
13
13
  recoverIncompleteRuns
14
- } from "./cli-xdrmxvd4.js";
14
+ } from "./cli-yw8vghx2.js";
15
15
  import {
16
16
  MAX_EMPTY_POLLS,
17
17
  assignUnassignedTaskPending,
@@ -51,13 +51,13 @@ import {
51
51
  releaseStaleReviewingTasks,
52
52
  supersedeTask,
53
53
  updateAgentStatus
54
- } from "./cli-s18zzkfp.js";
54
+ } from "./cli-a4jzdpa3.js";
55
55
  import {
56
56
  init_registry,
57
57
  init_resolver,
58
58
  registerTemplate,
59
59
  resolveTemplate
60
- } from "./cli-4n4mdv21.js";
60
+ } from "./cli-xpxde7rm.js";
61
61
  import {
62
62
  init_secret_scrubber,
63
63
  scrubSecrets
@@ -3,11 +3,11 @@ import {
3
3
  getAgentWorkingOnThread,
4
4
  getAllAgents,
5
5
  init_db
6
- } from "./cli-s18zzkfp.js";
6
+ } from "./cli-a4jzdpa3.js";
7
7
  import {
8
8
  init_env_flag,
9
9
  isEnvFlagEnabled
10
- } from "./cli-4n4mdv21.js";
10
+ } from "./cli-xpxde7rm.js";
11
11
 
12
12
  // src/slack/router.ts
13
13
  init_db();
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  lazyApi
3
- } from "./cli-w10fkrf1.js";
3
+ } from "./cli-akdvwc9v.js";
4
4
 
5
5
  // node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.lazy.js
6
6
  var __rewriteRelativeImportExtension = function(path, preserveJsx) {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  renderSteeringDelivery
3
- } from "./cli-xg2eezyv.js";
3
+ } from "./cli-f1am9szv.js";
4
4
  import {
5
5
  checkCodexCredentials
6
- } from "./cli-h3e66g5b.js";
6
+ } from "./cli-5kx36evn.js";
7
7
  import {
8
8
  checkClaudeManagedCredentials
9
9
  } from "./cli-qmdnhpej.js";
@@ -15,7 +15,7 @@ import {
15
15
  } from "./cli-n6h8qt8n.js";
16
16
  import {
17
17
  checkClaudeCredentials
18
- } from "./cli-e5p3es48.js";
18
+ } from "./cli-3kf51j15.js";
19
19
  import {
20
20
  MAX_RATE_LIMIT_RESET_MS,
21
21
  isCodexCreditsExhaustedMessage,
@@ -35,7 +35,7 @@ import {
35
35
  withSpan,
36
36
  withSpanContext,
37
37
  writeSkillsToFilesystem
38
- } from "./cli-haanc4qd.js";
38
+ } from "./cli-t76vw5db.js";
39
39
  import {
40
40
  authJsonToCredentialSelection,
41
41
  credentialsToAuthJson,
@@ -44,10 +44,10 @@ import {
44
44
  import {
45
45
  ensure,
46
46
  initialize
47
- } from "./cli-dakxgk70.js";
47
+ } from "./cli-5ze9rv97.js";
48
48
  import {
49
49
  validateJsonSchema
50
- } from "./cli-xdrmxvd4.js";
50
+ } from "./cli-yw8vghx2.js";
51
51
  import {
52
52
  getOpenRouterBaseUrl
53
53
  } from "./cli-3dpj7atn.js";
@@ -78,7 +78,7 @@ import {
78
78
  init_types,
79
79
  resolveTaskModelSelection,
80
80
  telemetry
81
- } from "./cli-s18zzkfp.js";
81
+ } from "./cli-a4jzdpa3.js";
82
82
  import {
83
83
  configureHttpResolver,
84
84
  init_resolver,
@@ -88,7 +88,7 @@ import {
88
88
  interpolate,
89
89
  isSteeringEnabled,
90
90
  resolveTemplateAsync
91
- } from "./cli-4n4mdv21.js";
91
+ } from "./cli-xpxde7rm.js";
92
92
  import {
93
93
  getMcpBaseUrl,
94
94
  init_constants
@@ -495,15 +495,15 @@ async function materializeCodexAuthJson(_slot, creds, deps = {}) {
495
495
  async function createProviderAdapter(provider) {
496
496
  switch (provider) {
497
497
  case "claude": {
498
- const { ClaudeAdapter } = await import("./claude-adapter-qr0k17km.js");
498
+ const { ClaudeAdapter } = await import("./claude-adapter-2y47mrkd.js");
499
499
  return new ClaudeAdapter;
500
500
  }
501
501
  case "pi": {
502
- const { PiMonoAdapter } = await import("./pi-mono-adapter-bpfrn6d7.js");
502
+ const { PiMonoAdapter } = await import("./pi-mono-adapter-t091s27g.js");
503
503
  return new PiMonoAdapter;
504
504
  }
505
505
  case "codex": {
506
- const { CodexAdapter } = await import("./codex-adapter-6pc50x9q.js");
506
+ const { CodexAdapter } = await import("./codex-adapter-d24q75wk.js");
507
507
  return new CodexAdapter;
508
508
  }
509
509
  case "claude-managed": {
@@ -1201,7 +1201,7 @@ async function checkProviderCredentials(provider, env, opts) {
1201
1201
  case "opencode":
1202
1202
  return checkOpencodeCredentials(env, opts);
1203
1203
  case "pi": {
1204
- const { checkPiMonoCredentials } = await import("./pi-mono-adapter-bpfrn6d7.js");
1204
+ const { checkPiMonoCredentials } = await import("./pi-mono-adapter-t091s27g.js");
1205
1205
  return checkPiMonoCredentials(env, opts);
1206
1206
  }
1207
1207
  default:
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  SYSTEM_COLUMN_KINDS,
3
3
  listAppRecords
4
- } from "./cli-brebbsen.js";
4
+ } from "./cli-2q72qz2s.js";
5
5
  import {
6
6
  getScriptApiTypes,
7
7
  getScriptMcpTypes,
8
8
  require_typescript
9
- } from "./cli-q8zwffx0.js";
9
+ } from "./cli-pm6xbh84.js";
10
10
  import {
11
11
  deleteSwarmConfigByKey,
12
12
  getAgentById,
@@ -15,7 +15,7 @@ import {
15
15
  getSwarmConfigs,
16
16
  init_db,
17
17
  upsertSwarmConfig
18
- } from "./cli-s18zzkfp.js";
18
+ } from "./cli-a4jzdpa3.js";
19
19
  import {
20
20
  init_secret_scrubber,
21
21
  scrubSecrets
@@ -2,7 +2,7 @@ import {
2
2
  init_resolver,
3
3
  init_session_templates,
4
4
  resolveTemplateAsync
5
- } from "./cli-4n4mdv21.js";
5
+ } from "./cli-xpxde7rm.js";
6
6
 
7
7
  // src/prompts/steering-delivery.ts
8
8
  init_session_templates();
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  init_package,
3
3
  package_default
4
- } from "./cli-7v5dhmc8.js";
4
+ } from "./cli-72q8m8gk.js";
5
5
 
6
6
  // src/commands/shared/client-config.ts
7
7
  init_package();
@@ -7,7 +7,7 @@ import {
7
7
  init_date_utils,
8
8
  init_db,
9
9
  normalizeDateRequired
10
- } from "./cli-s18zzkfp.js";
10
+ } from "./cli-a4jzdpa3.js";
11
11
  import {
12
12
  init_secret_scrubber,
13
13
  registerVolatileSecret,
@@ -10,13 +10,13 @@ import {
10
10
  resolveGrammarConstrainedSampling,
11
11
  resolveJsonSchemaStrictSampling,
12
12
  transformMessages
13
- } from "./cli-vgexpfsr.js";
13
+ } from "./cli-57khth04.js";
14
14
  import {
15
15
  sanitizeSurrogates
16
16
  } from "./cli-y2apkfe2.js";
17
17
  import {
18
18
  calculateCost
19
- } from "./cli-w10fkrf1.js";
19
+ } from "./cli-akdvwc9v.js";
20
20
 
21
21
  // node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js
22
22
  function encodeTextSignatureV1(id, phase) {
@@ -418,8 +418,12 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
418
418
  options.applyServiceTierPricing(output.usage, serviceTier);
419
419
  }
420
420
  const status = response?.status;
421
- output.rawStopReason = status;
422
- output.stopReason = mapStopReason(status);
421
+ const incompleteDetails = response?.incomplete_details;
422
+ const incompleteReason = typeof incompleteDetails?.reason === "string" ? incompleteDetails.reason : undefined;
423
+ output.rawStopReason = incompleteReason ? `${status}.${incompleteReason}` : status;
424
+ const mappedStop = mapStopReason(status, incompleteReason);
425
+ output.stopReason = mappedStop.stopReason;
426
+ output.errorMessage = mappedStop.errorMessage;
423
427
  if (output.content.some((b) => b.type === "toolCall") && output.stopReason === "stop") {
424
428
  output.stopReason = "toolUse";
425
429
  }
@@ -586,20 +590,26 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
586
590
  throw new Error("OpenAI Responses stream ended before a terminal response event");
587
591
  }
588
592
  }
589
- function mapStopReason(status) {
593
+ function mapStopReason(status, incompleteReason) {
590
594
  if (!status)
591
- return "stop";
595
+ return { stopReason: "stop" };
592
596
  switch (status) {
593
597
  case "completed":
594
- return "stop";
598
+ return { stopReason: "stop" };
595
599
  case "incomplete":
596
- return "length";
600
+ if (incompleteReason === "max_output_tokens") {
601
+ return { stopReason: "length" };
602
+ }
603
+ return {
604
+ stopReason: "error",
605
+ errorMessage: incompleteReason ? `Response incomplete: ${incompleteReason}` : "Response incomplete without a provider reason"
606
+ };
597
607
  case "failed":
598
608
  case "cancelled":
599
- return "error";
609
+ return { stopReason: "error" };
600
610
  case "in_progress":
601
611
  case "queued":
602
- return "stop";
612
+ return { stopReason: "stop" };
603
613
  default: {
604
614
  const _exhaustive = status;
605
615
  throw new Error(`Unhandled stop reason: ${_exhaustive}`);
@@ -16,13 +16,13 @@ import {
16
16
  init_db,
17
17
  init_templates1 as init_templates,
18
18
  normalizeDateRequired
19
- } from "./cli-s18zzkfp.js";
19
+ } from "./cli-a4jzdpa3.js";
20
20
  import {
21
21
  init_env_flag,
22
22
  init_resolver,
23
23
  isEnvFlagEnabled,
24
24
  resolveTemplate
25
- } from "./cli-4n4mdv21.js";
25
+ } from "./cli-xpxde7rm.js";
26
26
 
27
27
  // src/be/db-queries/tracker.ts
28
28
  init_date_utils();
@@ -6,7 +6,7 @@ import {
6
6
  } from "./cli-f14fvzag.js";
7
7
  import {
8
8
  embedScript
9
- } from "./cli-1px8pn1s.js";
9
+ } from "./cli-qv61hp37.js";
10
10
  import {
11
11
  calculatePKCECodeChallenge,
12
12
  ensureAuthorizationTokenOrThrow,
@@ -18,12 +18,13 @@ import {
18
18
  oauthAppRowToProviderConfig,
19
19
  updateAuthorizationTokens,
20
20
  upsertAuthorization
21
- } from "./cli-1mj7yz1r.js";
21
+ } from "./cli-g6b8x1h8.js";
22
22
  import {
23
23
  CredentialBroker,
24
24
  DEFAULT_CREDENTIAL_BINDINGS,
25
25
  computeContentHash,
26
26
  decryptSecret,
27
+ defaultAssetKey,
27
28
  encryptSecret,
28
29
  getDb,
29
30
  getEncryptionKey,
@@ -33,14 +34,15 @@ import {
33
34
  init_crypto,
34
35
  init_date_utils,
35
36
  init_db,
37
+ init_key,
36
38
  normalizeDateRequired,
37
39
  placeholderForConfigKey,
38
40
  upsertSwarmConfig
39
- } from "./cli-s18zzkfp.js";
41
+ } from "./cli-a4jzdpa3.js";
40
42
  import {
41
43
  init_env_flag,
42
44
  isEnvFlagEnabled
43
- } from "./cli-4n4mdv21.js";
45
+ } from "./cli-xpxde7rm.js";
44
46
  import {
45
47
  init_zod
46
48
  } from "./cli-zsspvvm2.js";
@@ -168933,6 +168935,75 @@ async function discoverAuthorizationServerMetadata(issuer) {
168933
168935
  }
168934
168936
  throw lastError ?? new Error(`Authorization server metadata not found at ${issuer}`);
168935
168937
  }
168938
+ var KNOWN_TOKEN_ENDPOINT_AUTH_METHODS = [
168939
+ "client_secret_basic",
168940
+ "client_secret_post",
168941
+ "none"
168942
+ ];
168943
+ var DEFAULT_TOKEN_ENDPOINT_AUTH_METHOD = "client_secret_basic";
168944
+ function normalizeTokenEndpointAuthMethod(value) {
168945
+ return KNOWN_TOKEN_ENDPOINT_AUTH_METHODS.includes(value ?? "") ? value : DEFAULT_TOKEN_ENDPOINT_AUTH_METHOD;
168946
+ }
168947
+
168948
+ class UnsupportedTokenEndpointAuthMethodError extends Error {
168949
+ constructor(value, source) {
168950
+ super(`Authorization server ${source} token_endpoint_auth_method "${value}", which agent-swarm cannot perform. ` + `Supported methods: ${KNOWN_TOKEN_ENDPOINT_AUTH_METHODS.join(", ")}. ` + `Register a client manually via POST /api/mcp-oauth/:id/manual-client with a supported method.`);
168951
+ this.name = "UnsupportedTokenEndpointAuthMethodError";
168952
+ }
168953
+ }
168954
+ function resolveAdvertisedTokenEndpointAuthMethod(value, source) {
168955
+ if (value == null || value === "")
168956
+ return DEFAULT_TOKEN_ENDPOINT_AUTH_METHOD;
168957
+ if (!KNOWN_TOKEN_ENDPOINT_AUTH_METHODS.includes(value)) {
168958
+ throw new UnsupportedTokenEndpointAuthMethodError(value, source);
168959
+ }
168960
+ return value;
168961
+ }
168962
+ function authMethodForStoredClient(value) {
168963
+ if (value == null || value === "")
168964
+ return "client_secret_post";
168965
+ return normalizeTokenEndpointAuthMethod(value);
168966
+ }
168967
+ function selectDcrTokenEndpointAuthMethod(supportedMethods) {
168968
+ if (!supportedMethods || supportedMethods.length === 0) {
168969
+ return DEFAULT_TOKEN_ENDPOINT_AUTH_METHOD;
168970
+ }
168971
+ for (const method of KNOWN_TOKEN_ENDPOINT_AUTH_METHODS) {
168972
+ if (supportedMethods.includes(method))
168973
+ return method;
168974
+ }
168975
+ throw new UnsupportedTokenEndpointAuthMethodError(supportedMethods.join(", "), "advertises only");
168976
+ }
168977
+ function formUrlEncodeComponent(value) {
168978
+ return new URLSearchParams({ v: value }).toString().slice(2);
168979
+ }
168980
+ function redactSentCredentials(text, sent) {
168981
+ let out = scrubSecrets(text);
168982
+ for (const value of sent) {
168983
+ if (!value)
168984
+ continue;
168985
+ for (const shape of new Set([value, formUrlEncodeComponent(value)])) {
168986
+ out = out.split(shape).join("[REDACTED]");
168987
+ }
168988
+ }
168989
+ return out;
168990
+ }
168991
+ function applyClientAuthentication(method, clientId, clientSecret, body, headers) {
168992
+ if (method === "client_secret_basic" && clientSecret) {
168993
+ const encodedSecret = formUrlEncodeComponent(clientSecret);
168994
+ const credentials = `${formUrlEncodeComponent(clientId)}:${encodedSecret}`;
168995
+ const encoded = Buffer.from(credentials).toString("base64");
168996
+ registerVolatileSecret(encoded, "mcp_oauth_basic_credential");
168997
+ headers.Authorization = `Basic ${encoded}`;
168998
+ return [clientSecret, encodedSecret, encoded, credentials];
168999
+ }
169000
+ body.set("client_id", clientId);
169001
+ if (method === "client_secret_post" && clientSecret) {
169002
+ body.set("client_secret", clientSecret);
169003
+ return [clientSecret, formUrlEncodeComponent(clientSecret)];
169004
+ }
169005
+ return [];
169006
+ }
168936
169007
  async function registerClient(registrationEndpoint, req) {
168937
169008
  const res = await safeFetch(registrationEndpoint, {
168938
169009
  method: "POST",
@@ -168985,27 +169056,33 @@ async function buildAuthorizeUrl(input) {
168985
169056
  return { url: url.toString(), state, codeVerifier, codeChallenge };
168986
169057
  }
168987
169058
  async function exchangeCodeForTokens(input) {
169059
+ if (input.clientSecret)
169060
+ registerVolatileSecret(input.clientSecret, "mcp_oauth_client_secret");
169061
+ const method = normalizeTokenEndpointAuthMethod(input.tokenEndpointAuthMethod);
168988
169062
  const body = new URLSearchParams({
168989
169063
  grant_type: "authorization_code",
168990
169064
  code: input.code,
168991
169065
  redirect_uri: input.redirectUri,
168992
- client_id: input.clientId,
168993
169066
  code_verifier: input.codeVerifier,
168994
169067
  resource: input.resource
168995
169068
  });
168996
- if (input.clientSecret)
168997
- body.set("client_secret", input.clientSecret);
169069
+ const headers = {
169070
+ "Content-Type": "application/x-www-form-urlencoded",
169071
+ Accept: "application/json"
169072
+ };
169073
+ const sentCredentials = applyClientAuthentication(method, input.clientId, input.clientSecret, body, headers);
168998
169074
  const res = await safeFetch(input.tokenUrl, {
168999
169075
  method: "POST",
169000
- headers: {
169001
- "Content-Type": "application/x-www-form-urlencoded",
169002
- Accept: "application/json"
169003
- },
169076
+ headers,
169004
169077
  body: body.toString()
169005
169078
  });
169006
169079
  if (!res.ok) {
169007
169080
  const text = await res.text().catch(() => "");
169008
- throw new Error(`Token exchange failed (${res.status}): ${text}`);
169081
+ throw new Error(`Token exchange failed (${res.status}): ${redactSentCredentials(text, [
169082
+ ...sentCredentials,
169083
+ input.code,
169084
+ input.codeVerifier
169085
+ ])}`);
169009
169086
  }
169010
169087
  return await res.json();
169011
169088
  }
@@ -169013,50 +169090,57 @@ async function refreshMcpToken(input) {
169013
169090
  if (input.clientSecret)
169014
169091
  registerVolatileSecret(input.clientSecret, "mcp_oauth_client_secret");
169015
169092
  registerVolatileSecret(input.refreshToken, "mcp_oauth_refresh_token");
169093
+ const method = normalizeTokenEndpointAuthMethod(input.tokenEndpointAuthMethod);
169016
169094
  const body = new URLSearchParams({
169017
169095
  grant_type: "refresh_token",
169018
169096
  refresh_token: input.refreshToken,
169019
- client_id: input.clientId,
169020
169097
  resource: input.resource
169021
169098
  });
169022
- if (input.clientSecret)
169023
- body.set("client_secret", input.clientSecret);
169024
169099
  if (input.scopes && input.scopes.length > 0)
169025
169100
  body.set("scope", input.scopes.join(" "));
169101
+ const headers = {
169102
+ "Content-Type": "application/x-www-form-urlencoded",
169103
+ Accept: "application/json"
169104
+ };
169105
+ const sentCredentials = applyClientAuthentication(method, input.clientId, input.clientSecret, body, headers);
169026
169106
  const res = await safeFetch(input.tokenUrl, {
169027
169107
  method: "POST",
169028
- headers: {
169029
- "Content-Type": "application/x-www-form-urlencoded",
169030
- Accept: "application/json"
169031
- },
169108
+ headers,
169032
169109
  body: body.toString()
169033
169110
  });
169034
169111
  if (!res.ok) {
169035
169112
  const text = await res.text().catch(() => "");
169036
- throw new Error(`Token refresh failed (${res.status}): ${scrubSecrets(text)}`);
169113
+ throw new Error(`Token refresh failed (${res.status}): ${redactSentCredentials(text, [
169114
+ ...sentCredentials,
169115
+ input.refreshToken
169116
+ ])}`);
169037
169117
  }
169038
169118
  return await res.json();
169039
169119
  }
169040
169120
  async function revokeMcpToken(input) {
169041
- const body = new URLSearchParams({
169042
- token: input.token,
169043
- client_id: input.clientId
169044
- });
169121
+ if (input.clientSecret)
169122
+ registerVolatileSecret(input.clientSecret, "mcp_oauth_client_secret");
169123
+ registerVolatileSecret(input.token, "mcp_oauth_revoked_token");
169124
+ const method = normalizeTokenEndpointAuthMethod(input.tokenEndpointAuthMethod);
169125
+ const body = new URLSearchParams({ token: input.token });
169045
169126
  if (input.tokenTypeHint)
169046
169127
  body.set("token_type_hint", input.tokenTypeHint);
169047
- if (input.clientSecret)
169048
- body.set("client_secret", input.clientSecret);
169128
+ const headers = {
169129
+ "Content-Type": "application/x-www-form-urlencoded",
169130
+ Accept: "application/json"
169131
+ };
169132
+ const sentCredentials = applyClientAuthentication(method, input.clientId, input.clientSecret, body, headers);
169049
169133
  const res = await safeFetch(input.revocationUrl, {
169050
169134
  method: "POST",
169051
- headers: {
169052
- "Content-Type": "application/x-www-form-urlencoded",
169053
- Accept: "application/json"
169054
- },
169135
+ headers,
169055
169136
  body: body.toString()
169056
169137
  });
169057
169138
  if (!res.ok && res.status !== 200 && res.status !== 204) {
169058
169139
  const text = await res.text().catch(() => "");
169059
- throw new Error(`Token revocation failed (${res.status}): ${text}`);
169140
+ throw new Error(`Token revocation failed (${res.status}): ${redactSentCredentials(text, [
169141
+ ...sentCredentials,
169142
+ input.token
169143
+ ])}`);
169060
169144
  }
169061
169145
  }
169062
169146
  function computeExpiresAt(expiresInSeconds) {
@@ -169136,6 +169220,7 @@ function decryptTokenRow(row) {
169136
169220
  revocationUrl: row.revocationUrl,
169137
169221
  dcrClientId: row.clientId || null,
169138
169222
  dcrClientSecret: row.clientSecret == null ? null : clientKey ? decryptSecret(row.clientSecret, clientKey) : row.clientSecret,
169223
+ tokenEndpointAuthMethod: typeof metadata.tokenEndpointAuthMethod === "string" ? metadata.tokenEndpointAuthMethod : null,
169139
169224
  clientSource,
169140
169225
  status: statusFromUnified(row.status),
169141
169226
  lastErrorMessage: row.lastErrorMessage,
@@ -169157,6 +169242,7 @@ function upsertMcpApp(input) {
169157
169242
  authorizationServerIssuer: input.authorizationServerIssuer,
169158
169243
  registrationEndpoint: input.registrationEndpoint ?? null,
169159
169244
  clientSource: input.clientSource,
169245
+ ...input.tokenEndpointAuthMethod !== undefined ? { tokenEndpointAuthMethod: input.tokenEndpointAuthMethod } : {},
169160
169246
  registeredScopes: input.registeredScopes !== undefined ? input.registeredScopes : existingMetadata.registeredScopes ?? null,
169161
169247
  invalidated: false
169162
169248
  });
@@ -169216,6 +169302,7 @@ function readMcpOAuthApp(appId) {
169216
169302
  authorizationServerIssuer: typeof metadata.authorizationServerIssuer === "string" ? metadata.authorizationServerIssuer : "",
169217
169303
  registrationEndpoint: typeof metadata.registrationEndpoint === "string" ? metadata.registrationEndpoint : null,
169218
169304
  registeredScopes: Array.isArray(metadata.registeredScopes) ? metadata.registeredScopes : null,
169305
+ tokenEndpointAuthMethod: typeof metadata.tokenEndpointAuthMethod === "string" ? metadata.tokenEndpointAuthMethod : null,
169219
169306
  clientSource
169220
169307
  };
169221
169308
  }
@@ -169277,6 +169364,7 @@ function upsertMcpOAuthToken(input) {
169277
169364
  registeredScopes: input.registeredScopes,
169278
169365
  dcrClientId: input.dcrClientId,
169279
169366
  dcrClientSecret: input.dcrClientSecret,
169367
+ tokenEndpointAuthMethod: input.tokenEndpointAuthMethod,
169280
169368
  clientSource: input.clientSource
169281
169369
  });
169282
169370
  upsertAuthorization({
@@ -169359,6 +169447,7 @@ function insertMcpOAuthPending(input) {
169359
169447
  registeredScopes: input.registeredScopes,
169360
169448
  dcrClientId: input.dcrClientId,
169361
169449
  dcrClientSecret: input.dcrClientSecret,
169450
+ tokenEndpointAuthMethod: input.tokenEndpointAuthMethod,
169362
169451
  clientSource,
169363
169452
  redirectUri: input.redirectUri
169364
169453
  });
@@ -169373,6 +169462,7 @@ function insertMcpOAuthPending(input) {
169373
169462
  registeredScopes: input.registeredScopes ?? null,
169374
169463
  dcrClientId: input.dcrClientId ?? null,
169375
169464
  dcrClientSecret: input.dcrClientSecret == null ? null : encryptSecret(input.dcrClientSecret, getEncryptionKey()),
169465
+ tokenEndpointAuthMethod: input.tokenEndpointAuthMethod ?? null,
169376
169466
  clientSource
169377
169467
  });
169378
169468
  getDb().query(`INSERT INTO oauth_pending (
@@ -169420,6 +169510,7 @@ function consumeMcpOAuthPending(state) {
169420
169510
  registeredScopes: Array.isArray(context.registeredScopes) ? context.registeredScopes : null,
169421
169511
  dcrClientId: typeof context.dcrClientId === "string" ? context.dcrClientId : null,
169422
169512
  dcrClientSecret: encryptedClientSecret ? decryptSecret(encryptedClientSecret, getEncryptionKey()) : null,
169513
+ tokenEndpointAuthMethod: typeof context.tokenEndpointAuthMethod === "string" ? context.tokenEndpointAuthMethod : null,
169423
169514
  redirectUri: row.redirectUri,
169424
169515
  finalRedirect: row.finalRedirect,
169425
169516
  createdAt: normalizeDateRequired(row.createdAt)
@@ -169465,6 +169556,7 @@ async function ensureMcpToken(mcpServerId, opts = {}) {
169465
169556
  tokenUrl: token.tokenUrl,
169466
169557
  clientId: token.dcrClientId ?? "",
169467
169558
  clientSecret: token.dcrClientSecret ?? undefined,
169559
+ tokenEndpointAuthMethod: authMethodForStoredClient(token.tokenEndpointAuthMethod),
169468
169560
  refreshToken: token.refreshToken,
169469
169561
  resource: token.resourceUrl,
169470
169562
  scopes: token.scope ? token.scope.split(" ").filter(Boolean) : undefined
@@ -170915,6 +171007,7 @@ ${members.join(`
170915
171007
  }
170916
171008
 
170917
171009
  // src/be/scripts/db.ts
171010
+ init_key();
170918
171011
  init_secret_scrubber();
170919
171012
 
170920
171013
  // src/utils/short-id.ts
@@ -170988,12 +171081,12 @@ function insertScript(args) {
170988
171081
  const typeChecked = args.typeChecked ? 1 : 0;
170989
171082
  const txn = getDb().transaction(() => {
170990
171083
  const row = getDb().prepare(`INSERT INTO scripts (
170991
- id, name, scope, scopeId, source, description, intent, signatureJson,
171084
+ id, "key", name, scope, scopeId, source, description, intent, signatureJson,
170992
171085
  argsJsonSchema, contentHash, isScratch, typeChecked, fsMode, createdByAgentId, createdAt, updatedAt,
170993
171086
  created_by, updated_by
170994
171087
  )
170995
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
170996
- RETURNING *`).get(id, args.name, args.scope, scopeId, args.source, args.description, args.intent, args.signatureJson, args.argsJsonSchema ?? null, contentHash, isScratch, typeChecked, fsMode, args.agentId ?? null, now, now, args.createdBy ?? null, args.createdBy ?? null);
171088
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
171089
+ RETURNING *`).get(id, defaultAssetKey("script", id), args.name, args.scope, scopeId, args.source, args.description, args.intent, args.signatureJson, args.argsJsonSchema ?? null, contentHash, isScratch, typeChecked, fsMode, args.agentId ?? null, now, now, args.createdBy ?? null, args.createdBy ?? null);
170997
171090
  if (!row)
170998
171091
  throw new Error("Failed to insert script");
170999
171092
  insertScriptVersion({
@@ -171729,4 +171822,4 @@ async function buildScriptCredentialBindings(input) {
171729
171822
  return (await buildScriptCredentialBindingsWithFailures(input)).egressSecrets;
171730
171823
  }
171731
171824
 
171732
- export { MIN_SCRIPT_WALL_CLOCK_MS, SCRIPT_LONG_TIMEOUT_HINT_MS, MAX_SCRIPT_WALL_CLOCK_MS, DEFAULT_SCRIPT_RESOURCES, isInvalidClientError, assertUrlSafe, publicEndpointSsrfOptions, discoverProtectedResourceMetadata, discoverAuthorizationServerMetadata, registerClient, buildAuthorizeUrl, exchangeCodeForTokens, refreshMcpToken, revokeMcpToken, computeExpiresAt, getMcpOAuthToken, findReusableMcpOAuthClient, invalidateMcpOAuthClient, upsertMcpOAuthToken, applyMcpOAuthRefresh, markMcpOAuthTokenStatus, deleteMcpOAuthToken, insertMcpOAuthPending, consumeMcpOAuthPending, gcMcpOAuthPending, setMcpServerAuthMethod, ensureMcpToken, callMcpServerTool, listVendoredOpenapiEntries, ConnectionAuthInputSchema, connectionAuthSummary, listRelationalCredentialBindings, upsertCredentialBinding, disableCredentialBinding, listScriptConnections, getScriptConnectionById, connectionAuthInputFromFlat, upsertScriptConnection, refreshScriptConnection, setScriptConnectionEnabled, getScriptApiConnectionDescriptors, getScriptMcpConnectionDescriptors, getScriptApiTypes, getScriptMcpTypes, upsertScriptByName, getScript, getScriptById, getScriptVersion, listScripts, listScriptVersions, deleteScript, createScriptApi, listScriptApisForScript, getScriptApiById, getScriptApiSecret, updateScriptApi, rotateScriptApiSecret, deleteScriptApi, recordScriptApiUsage, buildSandboxedCommand, sandboxSpawnEnv, createCappedStreamState, snapshotCapped, readStreamCapped, require_typescript, validateScriptImports, runScript, oauthAppToProviderConfig, getOAuthProviderConfig, getOAuthBindingTokenStatus, buildScriptCredentialBindingsWithFailures, buildScriptCredentialBindings };
171825
+ export { MIN_SCRIPT_WALL_CLOCK_MS, SCRIPT_LONG_TIMEOUT_HINT_MS, MAX_SCRIPT_WALL_CLOCK_MS, DEFAULT_SCRIPT_RESOURCES, isInvalidClientError, assertUrlSafe, publicEndpointSsrfOptions, discoverProtectedResourceMetadata, discoverAuthorizationServerMetadata, normalizeTokenEndpointAuthMethod, resolveAdvertisedTokenEndpointAuthMethod, authMethodForStoredClient, selectDcrTokenEndpointAuthMethod, registerClient, buildAuthorizeUrl, exchangeCodeForTokens, refreshMcpToken, revokeMcpToken, computeExpiresAt, getMcpOAuthToken, findReusableMcpOAuthClient, invalidateMcpOAuthClient, upsertMcpOAuthToken, applyMcpOAuthRefresh, markMcpOAuthTokenStatus, deleteMcpOAuthToken, insertMcpOAuthPending, consumeMcpOAuthPending, gcMcpOAuthPending, setMcpServerAuthMethod, ensureMcpToken, callMcpServerTool, listVendoredOpenapiEntries, ConnectionAuthInputSchema, connectionAuthSummary, listRelationalCredentialBindings, upsertCredentialBinding, disableCredentialBinding, listScriptConnections, getScriptConnectionById, connectionAuthInputFromFlat, upsertScriptConnection, refreshScriptConnection, setScriptConnectionEnabled, getScriptApiConnectionDescriptors, getScriptMcpConnectionDescriptors, getScriptApiTypes, getScriptMcpTypes, upsertScriptByName, getScript, getScriptById, getScriptVersion, listScripts, listScriptVersions, deleteScript, createScriptApi, listScriptApisForScript, getScriptApiById, getScriptApiSecret, updateScriptApi, rotateScriptApiSecret, deleteScriptApi, recordScriptApiUsage, buildSandboxedCommand, sandboxSpawnEnv, createCappedStreamState, snapshotCapped, readStreamCapped, require_typescript, validateScriptImports, runScript, oauthAppToProviderConfig, getOAuthProviderConfig, getOAuthBindingTokenStatus, buildScriptCredentialBindingsWithFailures, buildScriptCredentialBindings };