@desplega.ai/agent-swarm 2.4.2 → 2.4.4

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 (183) hide show
  1. package/dist/{acp-adapter-dv7hmx4r.js → acp-adapter-thq04adh.js} +4 -5
  2. package/dist/{actions-51nc1gny.js → actions-j6ywh6x5.js} +18 -18
  3. package/dist/{amp-adapter-abp5tdx8.js → amp-adapter-k8b5xmj8.js} +3 -3
  4. package/dist/{app-9h14qvr6.js → app-rb7vc02s.js} +3 -3
  5. package/dist/{assistant-wv1gz3mt.js → assistant-ftta1zjf.js} +20 -20
  6. package/dist/{boot-reembed-6yn53ms9.js → boot-reembed-srp6v6af.js} +1 -1
  7. package/dist/{boot-reembed-7fcka4z5.js → boot-reembed-xns7h5h9.js} +1 -1
  8. package/dist/{boot-scrub-sweep-pm1580ax.js → boot-scrub-sweep-3qqrh2mz.js} +3 -3
  9. package/dist/{boot-seeds-g5hfc1x8.js → boot-seeds-9ks8hce7.js} +4 -4
  10. package/dist/{claude-adapter-gf3kxhf0.js → claude-adapter-k5ksyres.js} +4 -4
  11. package/dist/{claude-managed-setup-h00hsgtz.js → claude-managed-setup-n5a5eqks.js} +1 -1
  12. package/dist/{claude-sdk-session-s2k1qd8y.js → claude-sdk-session-2j3j4kwn.js} +9822 -9749
  13. package/dist/{cli-pkht5hap.js → cli-1d70crsy.js} +2 -2
  14. package/dist/{cli-r99kc9yq.js → cli-1ephgwnq.js} +3 -3
  15. package/dist/{cli-7225gwj7.js → cli-1m17dc9d.js} +1 -1
  16. package/dist/{cli-bcj753sq.js → cli-2v045xyf.js} +3 -3
  17. package/dist/{cli-h38rjv87.js → cli-2y91wnbh.js} +12 -7
  18. package/dist/{cli-sv5gb0yb.js → cli-2zqpkvtt.js} +1 -1
  19. package/dist/{cli-xbzvet96.js → cli-36ckw0wx.js} +5 -4
  20. package/dist/{cli-8sxqsbbq.js → cli-37yb7307.js} +1 -1
  21. package/dist/{cli-hyfw2j1e.js → cli-3cgngyd8.js} +11 -11
  22. package/dist/{cli-a4gvwttf.js → cli-44159k28.js} +2 -2
  23. package/dist/{cli-7awf1fp8.js → cli-4dg55wsk.js} +3 -3
  24. package/dist/{cli-mhywgrrz.js → cli-4sydckyj.js} +1 -1
  25. package/dist/{cli-y2x52gs2.js → cli-51y09c6p.js} +20 -17
  26. package/dist/{cli-ahtpy9kf.js → cli-55qmbp6z.js} +10 -5
  27. package/dist/{cli-pw7v69vp.js → cli-625tb7aq.js} +1 -1
  28. package/dist/{cli-x5mq1fyq.js → cli-74c1wpm0.js} +3 -3
  29. package/dist/{cli-b1dfr1m4.js → cli-7a6p4e65.js} +1 -1
  30. package/dist/{cli-hqhzg1qq.js → cli-82d3nkc3.js} +1 -1
  31. package/dist/{cli-nmqdc2t3.js → cli-9fhkkpj5.js} +78 -12
  32. package/dist/{cli-h93c9vb3.js → cli-amyhm3gj.js} +1 -1
  33. package/dist/{cli-0qvtffe9.js → cli-b8k7epj1.js} +6 -6
  34. package/dist/{cli-1pa3rz69.js → cli-ba8ne1es.js} +6 -1
  35. package/dist/{cli-g0hgtz4p.js → cli-bnz0r3kc.js} +3 -3
  36. package/dist/{cli-0hyhdkdk.js → cli-cebvbc9t.js} +4 -1
  37. package/dist/{cli-efaqv1c7.js → cli-cynvc9fj.js} +35 -7
  38. package/dist/{cli-8zwe9mpk.js → cli-dqb4n629.js} +10 -10
  39. package/dist/{cli-7a91w22y.js → cli-e8xyjvfc.js} +1 -1
  40. package/dist/{cli-s6vr7r2d.js → cli-esxerzg7.js} +1 -1
  41. package/dist/{cli-w9g4sz81.js → cli-gf2850q7.js} +1 -1
  42. package/dist/{cli-10hhg0km.js → cli-gqvh8d8a.js} +7 -7
  43. package/dist/{cli-t30yj95q.js → cli-hj3debgw.js} +1 -1
  44. package/dist/{cli-fpmsqq59.js → cli-nc35pxb7.js} +3 -3
  45. package/dist/{cli-d3qqdy4c.js → cli-p20r8w42.js} +16 -14
  46. package/dist/{cli-shvfedvm.js → cli-pccfmtb5.js} +5 -5
  47. package/dist/{cli-02qm7src.js → cli-q6r7t299.js} +1037 -299
  48. package/dist/{cli-2wag8973.js → cli-qeaq3j6t.js} +1 -1
  49. package/dist/{cli-nn47d7e8.js → cli-qkhc5aqy.js} +15 -15
  50. package/dist/{cli-faypxz7q.js → cli-t7cyef5g.js} +4 -4
  51. package/dist/{cli-z4wd2ftv.js → cli-te6b5wvg.js} +149 -184
  52. package/dist/{cli-5rk36sjf.js → cli-v3yr2gbg.js} +119 -44
  53. package/dist/{cli-239yjk27.js → cli-vdm20wej.js} +5 -5
  54. package/dist/{cli-zfg9enh9.js → cli-vfha21c9.js} +6 -1
  55. package/dist/{cli-rdyw3mct.js → cli-vq97g1jq.js} +6 -5
  56. package/dist/{cli-n85dqg6d.js → cli-w6nadkh4.js} +4 -4
  57. package/dist/{cli-99jez72r.js → cli-w9etnnxk.js} +6 -1
  58. package/dist/{cli-saw9a6f6.js → cli-xc27fwzg.js} +2 -2
  59. package/dist/{cli-ftyypbg5.js → cli-xj0re5tm.js} +1 -1
  60. package/dist/{cli-fyzjmseb.js → cli-zrk6jxv8.js} +1 -1
  61. package/dist/{cli-y8n5k515.js → cli-zrwpctp4.js} +28 -28
  62. package/dist/cli.js +44 -19
  63. package/dist/{codex-adapter-ttygw382.js → codex-adapter-968xwfy7.js} +2 -2
  64. package/dist/{codex-hook-x7nejyrr.js → codex-hook-e2he7aca.js} +2 -2
  65. package/dist/{codex-session-runner-60b58vv3.js → codex-session-runner-ht4z99fa.js} +2 -2
  66. package/dist/{commands-edmdwa4x.js → commands-pcymaeg9.js} +3 -3
  67. package/dist/{controller-m263fg43.js → controller-fpjyk46r.js} +3 -3
  68. package/dist/{controllers-connect-5fym8sw1.js → controllers-connect-mwzx1fh6.js} +19 -19
  69. package/dist/{cursor-adapter-cz6nm6mj.js → cursor-adapter-cp4s2e2f.js} +2 -2
  70. package/dist/{db-2y0mgstc.js → db-sgd12bt9.js} +3 -3
  71. package/dist/{db-nn0hcmx5.js → db-xsjg9jqq.js} +2 -2
  72. package/dist/{dispatcher-0a9wwjcx.js → dispatcher-x0jfw2c9.js} +17 -17
  73. package/dist/{dsh-adapter-3n3net33.js → dsh-adapter-jrq7ma7h.js} +2 -2
  74. package/dist/{e2b-thdcxtjd.js → e2b-16d6ch39.js} +1 -1
  75. package/dist/{e2b-7am6tmq6.js → e2b-zn0b4w5w.js} +1 -1
  76. package/dist/{external-channel-zhvt95n3.js → external-channel-8njj4h3b.js} +2 -2
  77. package/dist/{grok-adapter-qnr1hp2y.js → grok-adapter-kkr97v2f.js} +5 -6
  78. package/dist/handlers-0pvee9nw.js +39 -0
  79. package/dist/{heartbeat-gz97r7ac.js → heartbeat-wd03zhn0.js} +20 -20
  80. package/dist/{hook-1mmdgjqs.js → hook-f0vghj42.js} +10 -5
  81. package/dist/{hook-x8rthca4.js → hook-xzj2ts2p.js} +2 -2
  82. package/dist/{http-r8f85xr9.js → http-4hwxv62p.js} +261 -123
  83. package/dist/{index-va3y63es.js → index-6srwvd5b.js} +1 -2
  84. package/dist/{index-y7rbcrc1.js → index-97q4xn03.js} +20 -11
  85. package/dist/{index-s98037v0.js → index-cbxkmfc5.js} +1 -2
  86. package/dist/{index-vzvfqzfj.js → index-gdh8jrdm.js} +17 -17
  87. package/dist/{index-aex0eba9.js → index-hg0x2cdv.js} +17 -17
  88. package/dist/index-thm0y6a8.js +41 -0
  89. package/dist/{index-smxyk04s.js → index-ww2vznkp.js} +1 -1
  90. package/dist/{keepalive-64c0f34c.js → keepalive-hrh7xnr9.js} +3 -3
  91. package/dist/{lead-b1da0f97.js → lead-ee8vazz2.js} +30 -31
  92. package/dist/{maintenance-mnxpar12.js → maintenance-e8wnwnqx.js} +1 -1
  93. package/dist/{oauth-refresh-sweep-36hs2v4h.js → oauth-refresh-sweep-zm0yj4sj.js} +2 -2
  94. package/dist/{onboard-xes8de61.js → onboard-dtwcq603.js} +3 -3
  95. package/dist/{opencode-adapter-3s7ax02e.js → opencode-adapter-x4tqzhkh.js} +3 -3
  96. package/dist/{otel-impl-fzc57kcq.js → otel-impl-w3fbhpn0.js} +1 -1
  97. package/dist/{pi-mono-adapter-ytp7gz8b.js → pi-mono-adapter-mcfkn9vf.js} +3 -3
  98. package/dist/{pricing-refresh-1nek2w7b.js → pricing-refresh-j38dehfs.js} +3 -3
  99. package/dist/{rbac-roles-ttyfaep2.js → rbac-roles-ae8yttq4.js} +3 -3
  100. package/dist/{rbac-roles-sqefb5hw.js → rbac-roles-ejxx9b35.js} +2 -2
  101. package/dist/{render-v2-vb527jwn.js → render-v2-n16n0phe.js} +3 -3
  102. package/dist/{resume-jcdzg1bn.js → resume-z0fgjc38.js} +5 -5
  103. package/dist/{session-access-zsp4wsp0.js → session-access-cv3mq6mc.js} +6 -4
  104. package/dist/{setup-1nb2zqd3.js → setup-mafhj3yt.js} +1 -1
  105. package/dist/{work-objects-61w08fwr.js → work-objects-8b86mgjp.js} +21 -21
  106. package/dist/{worker-c1e68hpa.js → worker-16s75hm5.js} +30 -31
  107. package/dist/worker-token-xf11yyds.js +136 -0
  108. package/openapi.json +295 -12
  109. package/package.json +5 -5
  110. package/src/apps/action-runner.ts +4 -0
  111. package/src/apps/catalog.generated.json +3 -0
  112. package/src/apps/page-validator.ts +8 -2
  113. package/src/be/db.ts +7 -4
  114. package/src/be/migrations/231_slack_tasks_last_updated_index.sql +5 -0
  115. package/src/be/migrations/232_agent_session_tokens.sql +41 -0
  116. package/src/be/seed-scripts/catalog/heartbeat-jev-gate.ts +10 -1
  117. package/src/be/swarm-config-guard.ts +16 -0
  118. package/src/be/users.ts +169 -12
  119. package/src/cli.tsx +24 -0
  120. package/src/commands/worker-token.ts +164 -0
  121. package/src/github/handlers.ts +6 -5
  122. package/src/hooks/hook.ts +2 -1
  123. package/src/http/apps.ts +43 -5
  124. package/src/http/codex-oauth-keep-warm.ts +27 -9
  125. package/src/http/config.ts +5 -3
  126. package/src/http/core.ts +2 -0
  127. package/src/http/session-access.ts +51 -2
  128. package/src/http/sessions.ts +249 -10
  129. package/src/http/tasks.ts +4 -32
  130. package/src/providers/acp-adapter.ts +33 -13
  131. package/src/providers/acp-swarm-events.ts +1 -1
  132. package/src/providers/amp-adapter.ts +1 -1
  133. package/src/providers/codex-adapter.ts +4 -4
  134. package/src/providers/codex-oauth/storage.ts +1 -1
  135. package/src/providers/opencode-adapter.ts +2 -2
  136. package/src/providers/pi-mono-extension.ts +2 -1
  137. package/src/rbac/legacy-policy.ts +3 -1
  138. package/src/rbac/permissions.ts +4 -0
  139. package/src/tests/acp-adapter.test.ts +10 -23
  140. package/src/tests/acp-fake-agent.ts +36 -0
  141. package/src/tests/acp-swarm-events.test.ts +1 -1
  142. package/src/tests/agent-session-tokens.test.ts +452 -0
  143. package/src/tests/apps-action-parent-task.test.ts +295 -0
  144. package/src/tests/claude-stop-hook.test.ts +47 -0
  145. package/src/tests/codex-adapter.test.ts +42 -0
  146. package/src/tests/codex-oauth-keep-warm.test.ts +85 -1
  147. package/src/tests/config-session-auth.test.ts +14 -0
  148. package/src/tests/docs-index-footprint.test.js +2 -2
  149. package/src/tests/env-flag.test.ts +15 -1
  150. package/src/tests/github-handlers-cancel-config.test.ts +29 -8
  151. package/src/tests/github-handlers-inline-comments.test.ts +9 -2
  152. package/src/tests/grok-adapter.test.ts +3 -3
  153. package/src/tests/heartbeat-jev-gate.test.ts +23 -0
  154. package/src/tests/migration-232-agent-session-tokens.test.ts +67 -0
  155. package/src/tests/rbac-engine.test.ts +1 -0
  156. package/src/tests/runtime-child-token-cleanup.test.ts +3 -3
  157. package/src/tests/script-connections.test.ts +4 -0
  158. package/src/tests/session-route-posture.test.ts +2 -0
  159. package/src/tests/skill-script-refs.test.ts +63 -0
  160. package/src/tests/slack-render-v2-query-plans.test.ts +147 -0
  161. package/src/tests/worker-token-cli.test.ts +76 -0
  162. package/src/tests/workflow-executors.test.ts +4 -2
  163. package/src/tests/workflow-system-one-extraction.test.ts +805 -0
  164. package/src/types.ts +2 -1
  165. package/src/utils/env-flag.ts +9 -0
  166. package/src/utils/request-auth-context.ts +2 -1
  167. package/src/workflows/definition.ts +7 -1
  168. package/src/workflows/engine.ts +18 -12
  169. package/src/workflows/executors/index.ts +1 -0
  170. package/src/workflows/executors/registry.ts +2 -0
  171. package/src/workflows/executors/system-one-decision.ts +56 -255
  172. package/src/workflows/executors/system-one-extract-wire.ts +57 -0
  173. package/src/workflows/executors/system-one-extraction.ts +830 -0
  174. package/src/workflows/executors/system-one-providers.ts +277 -110
  175. package/src/workflows/executors/system-one-transport.ts +264 -0
  176. package/templates/official/lead/HEARTBEAT.md +1 -1
  177. package/templates/skills/apps/SKILL.md +4 -1
  178. package/templates/skills/apps/content.md +4 -1
  179. package/templates/skills/code-quality/content.md +9 -14
  180. package/templates/skills/heartbeat-runbook/content.md +3 -3
  181. package/dist/cli-v1sjhn52.js +0 -7
  182. package/dist/handlers-dkcarkd0.js +0 -39
  183. package/dist/index-5jecgp3n.js +0 -41
@@ -18,7 +18,7 @@ import {
18
18
  import {
19
19
  applyOpenRouterBaseUrlOverride2,
20
20
  buildOpenAICompatibleProviderBlock2
21
- } from "./cli-xbzvet96.js";
21
+ } from "./cli-36ckw0wx.js";
22
22
  import {
23
23
  fetchInstalledMcpServers
24
24
  } from "./cli-bst1vp7e.js";
@@ -43,7 +43,7 @@ import {
43
43
  import {
44
44
  init_package,
45
45
  package_default
46
- } from "./cli-shvfedvm.js";
46
+ } from "./cli-pccfmtb5.js";
47
47
  import {
48
48
  scrubSecrets,
49
49
  init_secret_scrubber
@@ -56,7 +56,7 @@ import {
56
56
  init_src2
57
57
  } from "./cli-nwyw3zhg.js";
58
58
 
59
- // node_modules/@agentclientprotocol/sdk/dist/schema/index.js
59
+ // node_modules/@agentclientprotocol/sdk/dist/v1/unstable/schema/index.js
60
60
  var AGENT_METHODS = {
61
61
  initialize: "initialize",
62
62
  authenticate: "authenticate",
@@ -96,7 +96,7 @@ var PROTOCOL_METHODS = {
96
96
  };
97
97
  var PROTOCOL_VERSION = 1;
98
98
 
99
- // node_modules/@agentclientprotocol/sdk/dist/schema-deserialize.js
99
+ // node_modules/@agentclientprotocol/sdk/dist/core/schema-deserialize.js
100
100
  var skippedItem = Symbol("skippedItem");
101
101
  function defaultOnError(schema, fallback) {
102
102
  return schema.catch(fallback);
@@ -174,7 +174,7 @@ function vecSkipError(itemSchema) {
174
174
  return array2(itemSchema.catch(skippedItem)).transform((items) => items.filter((item) => item !== skippedItem));
175
175
  }
176
176
 
177
- // node_modules/@agentclientprotocol/sdk/dist/schema/zod.gen.js
177
+ // node_modules/@agentclientprotocol/sdk/dist/v1/unstable/schema/zod.gen.js
178
178
  var zRequestId = union2([number2(), string2()]).nullable();
179
179
  var zSessionId = string2();
180
180
  var zWriteTextFileRequest = object2({
@@ -2156,7 +2156,7 @@ var zCancelRequestNotification = object2({
2156
2156
  })
2157
2157
  });
2158
2158
 
2159
- // node_modules/@agentclientprotocol/sdk/dist/jsonrpc.js
2159
+ // node_modules/@agentclientprotocol/sdk/dist/core/jsonrpc.js
2160
2160
  var CANCEL_REQUEST_METHOD = "$/cancel_request";
2161
2161
  function isRequestMessage(value) {
2162
2162
  return isJsonRpcEnvelope(value) && "id" in value && typeof value["method"] === "string" && isJsonRpcId(value["id"]);
@@ -2372,6 +2372,7 @@ class Connection {
2372
2372
  nextRequestId = 0;
2373
2373
  staticHandlers = [];
2374
2374
  dynamicHandlers = new Set;
2375
+ fallbackHandlers = [];
2375
2376
  stream;
2376
2377
  writeQueue = Promise.resolve();
2377
2378
  abortController = new AbortController;
@@ -2555,6 +2556,7 @@ class Connection {
2555
2556
  initialize(stream, handlers, options) {
2556
2557
  this.stream = stream;
2557
2558
  this.staticHandlers = handlers;
2559
+ this.fallbackHandlers = [...options?.fallbackHandlers ?? []];
2558
2560
  this.allowBatches = options?.allowBatches ?? true;
2559
2561
  this.closedPromise = new Promise((resolve) => {
2560
2562
  this.abortController.signal.addEventListener("abort", () => resolve());
@@ -2689,7 +2691,8 @@ class Connection {
2689
2691
  try {
2690
2692
  for (const handler of [
2691
2693
  ...this.staticHandlers,
2692
- ...this.dynamicHandlers.values()
2694
+ ...this.dynamicHandlers.values(),
2695
+ ...this.fallbackHandlers
2693
2696
  ]) {
2694
2697
  if (this.abortController.signal.aborted) {
2695
2698
  return;
@@ -2816,6 +2819,7 @@ class Connection {
2816
2819
 
2817
2820
  class ConnectionBuilder {
2818
2821
  handlers = [];
2822
+ fallbackHandlers = [];
2819
2823
  connectionName;
2820
2824
  name(name) {
2821
2825
  this.connectionName = name;
@@ -2825,6 +2829,10 @@ class ConnectionBuilder {
2825
2829
  this.handlers.push(handler);
2826
2830
  return this;
2827
2831
  }
2832
+ withFallbackHandler(handler) {
2833
+ this.fallbackHandlers.push(handler);
2834
+ return this;
2835
+ }
2828
2836
  onReceiveMessage(handler) {
2829
2837
  return this.withHandler({
2830
2838
  handleMessage: async (message, cx) => await handler(message, cx) ?? Handled.no(message),
@@ -2856,7 +2864,13 @@ class ConnectionBuilder {
2856
2864
  });
2857
2865
  }
2858
2866
  connect(stream, options) {
2859
- return new Connection(stream, this.handlers, options);
2867
+ return new Connection(stream, this.handlers, {
2868
+ ...options,
2869
+ fallbackHandlers: [
2870
+ ...options?.fallbackHandlers ?? [],
2871
+ ...this.fallbackHandlers
2872
+ ]
2873
+ });
2860
2874
  }
2861
2875
  connectWith(stream, op, options) {
2862
2876
  return this.connect(stream, options).runUntil(op);
@@ -2929,7 +2943,7 @@ function protocolErrorResponse(error) {
2929
2943
  };
2930
2944
  }
2931
2945
 
2932
- // node_modules/@agentclientprotocol/sdk/dist/stream-limits.js
2946
+ // node_modules/@agentclientprotocol/sdk/dist/core/stream-limits.js
2933
2947
  var DEFAULT_MAX_MESSAGE_BYTES = 32 * 1024 * 1024;
2934
2948
 
2935
2949
  class MessageTooLargeError extends Error {
@@ -2990,7 +3004,7 @@ class MessageBuffer {
2990
3004
  }
2991
3005
  }
2992
3006
 
2993
- // node_modules/@agentclientprotocol/sdk/dist/line-buffer.js
3007
+ // node_modules/@agentclientprotocol/sdk/dist/core/line-buffer.js
2994
3008
  var newline = 10;
2995
3009
 
2996
3010
  class LineBuffer {
@@ -3044,7 +3058,7 @@ function stripCarriageReturn(line) {
3044
3058
  return line[line.byteLength - 1] === 13 ? line.subarray(0, -1) : line;
3045
3059
  }
3046
3060
 
3047
- // node_modules/@agentclientprotocol/sdk/dist/stream.js
3061
+ // node_modules/@agentclientprotocol/sdk/dist/core/stream.js
3048
3062
  function ndJsonStream(output, input, options = {}) {
3049
3063
  const maxMessageBytes = resolveMaxMessageBytes(options.maxMessageBytes);
3050
3064
  const textEncoder = new TextEncoder;
@@ -3147,7 +3161,7 @@ function ndJsonStream(output, input, options = {}) {
3147
3161
  return { readable, writable };
3148
3162
  }
3149
3163
 
3150
- // node_modules/@agentclientprotocol/sdk/dist/schema/guards.gen.js
3164
+ // node_modules/@agentclientprotocol/sdk/dist/v1/unstable/schema/guards.gen.js
3151
3165
  var zGuardCreateElicitationRequestForm = zElicitationFormMode.and(object2({ mode: literal2("form") })).and(object2({ message: string2() }));
3152
3166
  var zGuardCreateElicitationRequestUrl = zElicitationUrlMode.and(object2({ mode: literal2("url") })).and(object2({ message: string2() }));
3153
3167
  var zGuardCreateElicitationRequestCustom = union2([zElicitationSessionScope, zElicitationRequestScope]).and(object2({ message: string2() }));
@@ -3185,7 +3199,57 @@ var zGuardCreateElicitationResponseDecline = object2({
3185
3199
  var zGuardCreateElicitationResponseCancel = object2({
3186
3200
  action: literal2("cancel")
3187
3201
  });
3188
- // node_modules/@agentclientprotocol/sdk/dist/acp.js
3202
+ // node_modules/@agentclientprotocol/sdk/dist/core/app-handlers.js
3203
+ function parseParams(parser, params) {
3204
+ if (!parser) {
3205
+ return params;
3206
+ }
3207
+ if (typeof parser === "function") {
3208
+ return parser(params);
3209
+ }
3210
+ return parser.parse(params);
3211
+ }
3212
+ function registerAppRequest(builder, spec, context, handler, serializeResponse, lifecycle) {
3213
+ const handle = async (params, responder, cx, method) => {
3214
+ try {
3215
+ const response = await handler(context(params, cx, responder.signal, responder.id, method));
3216
+ const sentResponse = serializeResponse ? serializeResponse(response) : response;
3217
+ await responder.respond(sentResponse);
3218
+ lifecycle?.afterResponse(params, sentResponse, cx);
3219
+ } catch (error) {
3220
+ lifecycle?.onError(cx, error);
3221
+ throw error;
3222
+ }
3223
+ };
3224
+ if (spec.method === "*") {
3225
+ builder.withFallbackHandler({
3226
+ handleMessage: async (message, cx) => {
3227
+ if (message.kind !== "request")
3228
+ return Handled.no(message);
3229
+ await handle(message.params, message.responder, cx, message.method);
3230
+ return Handled.yes();
3231
+ }
3232
+ });
3233
+ } else {
3234
+ builder.onReceiveRequest(spec.method, (params) => parseParams(spec.params, params), (params, responder, cx) => handle(params, responder, cx, spec.method));
3235
+ }
3236
+ }
3237
+ function registerAppNotification(builder, spec, context, handler) {
3238
+ if (spec.method === "*") {
3239
+ builder.withFallbackHandler({
3240
+ handleMessage: async (message, cx) => {
3241
+ if (message.kind !== "notification")
3242
+ return Handled.no(message);
3243
+ await handler(context(message.params, cx, cx.signal, message.method));
3244
+ return Handled.yes();
3245
+ }
3246
+ });
3247
+ } else {
3248
+ builder.onReceiveNotification(spec.method, (params) => parseParams(spec.params, params), (params, cx) => handler(context(params, cx, cx.signal, spec.method)));
3249
+ }
3250
+ }
3251
+
3252
+ // node_modules/@agentclientprotocol/sdk/dist/v1/acp.js
3189
3253
  function ndJsonStream2(output, input, options) {
3190
3254
  return ndJsonStream(output, input, options);
3191
3255
  }
@@ -3291,6 +3355,10 @@ class AgentContext extends AcpContext {
3291
3355
  static create(cx, requestId) {
3292
3356
  return new AgentContext(cx, requestId);
3293
3357
  }
3358
+ async createTerminal(params, options) {
3359
+ const response = await this.request(CLIENT_METHODS.terminal_create, params, options);
3360
+ return TerminalHandle.create(response.terminalId, params.sessionId, this.connectionContext);
3361
+ }
3294
3362
  request(method, params, options) {
3295
3363
  const spec = clientRequestSpecsByMethod[method];
3296
3364
  return this.sendRequest(method, params, spec?.mapResponse, options);
@@ -3589,15 +3657,6 @@ class ActiveSession {
3589
3657
  return [prompt];
3590
3658
  }
3591
3659
  }
3592
- function parseParams(parser, params) {
3593
- if (!parser) {
3594
- return params;
3595
- }
3596
- if (typeof parser === "function") {
3597
- return parser(params);
3598
- }
3599
- return parser.parse(params);
3600
- }
3601
3660
  function requestSpec(method, params, mapResponse) {
3602
3661
  return {
3603
3662
  method,
@@ -3608,15 +3667,6 @@ function requestSpec(method, params, mapResponse) {
3608
3667
  function notificationSpec(method, params) {
3609
3668
  return { method, params };
3610
3669
  }
3611
- function registerAppRequest(builder, spec, context, handler) {
3612
- builder.onReceiveRequest(spec.method, (params) => parseParams(spec.params, params), async (params, responder, cx) => {
3613
- const response = await handler(context(params, cx, responder.signal, responder.id));
3614
- await responder.respond(spec.mapResponse ? spec.mapResponse(response) : response);
3615
- });
3616
- }
3617
- function registerAppNotification(builder, spec, context, handler) {
3618
- builder.onReceiveNotification(spec.method, (params) => parseParams(spec.params, params), (params, cx) => handler(context(params, cx, cx.signal)));
3619
- }
3620
3670
  function specsByMethod(specs) {
3621
3671
  const byMethod = {};
3622
3672
  for (const spec of Object.values(specs)) {
@@ -3664,16 +3714,18 @@ var agentRequestSpecsByMethod = specsByMethod(agentRequestSpecs);
3664
3714
  var agentNotificationSpecsByMethod = specsByMethod(agentNotificationSpecs);
3665
3715
  var clientRequestSpecsByMethod = specsByMethod(clientRequestSpecs);
3666
3716
  var clientNotificationSpecsByMethod = specsByMethod(clientNotificationSpecs);
3667
- function clientRequestContext(params, agent, signal, requestId) {
3717
+ function clientRequestContext(params, agent, signal, requestId, method) {
3668
3718
  return {
3719
+ method,
3669
3720
  params,
3670
3721
  requestId,
3671
3722
  signal,
3672
3723
  agent
3673
3724
  };
3674
3725
  }
3675
- function clientNotificationContext(params, agent, signal) {
3726
+ function clientNotificationContext(params, agent, signal, method) {
3676
3727
  return {
3728
+ method,
3677
3729
  params,
3678
3730
  signal,
3679
3731
  agent
@@ -3746,6 +3798,7 @@ function client(options) {
3746
3798
  class ClientApp {
3747
3799
  builder = Connection.builder();
3748
3800
  connectHandlers = [];
3801
+ fallbackKinds = new Set;
3749
3802
  constructor(options = {}) {
3750
3803
  if (options.name) {
3751
3804
  this.builder.name(options.name);
@@ -3773,6 +3826,14 @@ class ClientApp {
3773
3826
  return this;
3774
3827
  }
3775
3828
  onRequest(method, handlerOrParams, handler) {
3829
+ if (method === "*") {
3830
+ if (handler)
3831
+ throw new Error("Wildcard handlers receive raw params; omit the parser.");
3832
+ if (this.fallbackKinds.has("request"))
3833
+ throw new Error("A request fallback is already registered.");
3834
+ this.fallbackKinds.add("request");
3835
+ return this.request({ method }, handlerOrParams);
3836
+ }
3776
3837
  if (handler) {
3777
3838
  return this.request({ method, params: handlerOrParams }, handler);
3778
3839
  }
@@ -3783,6 +3844,14 @@ class ClientApp {
3783
3844
  return this.request(spec, handlerOrParams);
3784
3845
  }
3785
3846
  onNotification(method, handlerOrParams, handler) {
3847
+ if (method === "*") {
3848
+ if (handler)
3849
+ throw new Error("Wildcard handlers receive raw params; omit the parser.");
3850
+ if (this.fallbackKinds.has("notification"))
3851
+ throw new Error("A notification fallback is already registered.");
3852
+ this.fallbackKinds.add("notification");
3853
+ return this.notification({ method }, handlerOrParams);
3854
+ }
3786
3855
  if (handler) {
3787
3856
  return this.notification({ method, params: handlerOrParams }, handler);
3788
3857
  }
@@ -3793,11 +3862,11 @@ class ClientApp {
3793
3862
  return this.notification(spec, handlerOrParams);
3794
3863
  }
3795
3864
  request(spec, handler) {
3796
- registerAppRequest(this.builder, spec, (params, cx, signal, requestId) => clientRequestContext(params, ClientContext.create(cx, requestId), signal, requestId), handler);
3865
+ registerAppRequest(this.builder, spec, (params, cx, signal, requestId, method) => clientRequestContext(params, ClientContext.create(cx, requestId), signal, requestId, method), handler, spec.mapResponse);
3797
3866
  return this;
3798
3867
  }
3799
3868
  notification(spec, handler) {
3800
- registerAppNotification(this.builder, spec, (params, cx, signal) => clientNotificationContext(params, ClientContext.create(cx), signal), handler);
3869
+ registerAppNotification(this.builder, spec, (params, cx, signal, method) => clientNotificationContext(params, ClientContext.create(cx), signal, method), handler);
3801
3870
  return this;
3802
3871
  }
3803
3872
  connectConnection(target) {
@@ -3830,153 +3899,47 @@ class ClientApp {
3830
3899
  };
3831
3900
  }
3832
3901
  }
3833
- var legacyAgentRequestMethods = new Set([
3834
- AGENT_METHODS.initialize,
3835
- AGENT_METHODS.authenticate,
3836
- AGENT_METHODS.providers_list,
3837
- AGENT_METHODS.providers_set,
3838
- AGENT_METHODS.providers_disable,
3839
- AGENT_METHODS.session_new,
3840
- AGENT_METHODS.session_load,
3841
- AGENT_METHODS.session_set_mode,
3842
- AGENT_METHODS.session_set_config_option,
3843
- AGENT_METHODS.session_prompt,
3844
- AGENT_METHODS.session_list,
3845
- AGENT_METHODS.session_delete,
3846
- AGENT_METHODS.session_fork,
3847
- AGENT_METHODS.session_resume,
3848
- AGENT_METHODS.session_close,
3849
- AGENT_METHODS.logout
3850
- ]);
3851
- var legacyAgentNotificationMethods = new Set([
3852
- AGENT_METHODS.session_cancel
3853
- ]);
3854
- var legacyClientRequestMethods = new Set([
3855
- CLIENT_METHODS.session_request_permission,
3856
- CLIENT_METHODS.fs_write_text_file,
3857
- CLIENT_METHODS.fs_read_text_file,
3858
- CLIENT_METHODS.terminal_create,
3859
- CLIENT_METHODS.terminal_output,
3860
- CLIENT_METHODS.terminal_release,
3861
- CLIENT_METHODS.terminal_wait_for_exit,
3862
- CLIENT_METHODS.terminal_kill,
3863
- CLIENT_METHODS.elicitation_create
3864
- ]);
3865
- var legacyClientNotificationMethods = new Set([
3866
- CLIENT_METHODS.session_update,
3867
- CLIENT_METHODS.elicitation_complete
3868
- ]);
3869
- function legacyClientApp(implementation) {
3870
- const app = client().onRequest(CLIENT_METHODS.session_request_permission, (ctx) => implementation.requestPermission(ctx.params)).onNotification(CLIENT_METHODS.session_update, (ctx) => implementation.sessionUpdate(ctx.params)).onRequest(CLIENT_METHODS.fs_write_text_file, async (ctx) => await implementation.writeTextFile?.(ctx.params) ?? {}).onRequest(CLIENT_METHODS.fs_read_text_file, async (ctx) => await implementation.readTextFile?.(ctx.params)).onRequest(CLIENT_METHODS.terminal_create, async (ctx) => await implementation.createTerminal?.(ctx.params)).onRequest(CLIENT_METHODS.terminal_output, async (ctx) => await implementation.terminalOutput?.(ctx.params)).onRequest(CLIENT_METHODS.terminal_release, async (ctx) => await implementation.releaseTerminal?.(ctx.params) ?? {}).onRequest(CLIENT_METHODS.terminal_wait_for_exit, async (ctx) => await implementation.waitForTerminalExit?.(ctx.params)).onRequest(CLIENT_METHODS.terminal_kill, async (ctx) => await implementation.killTerminal?.(ctx.params) ?? {});
3871
- if (implementation.createElicitation) {
3872
- app.onRequest(CLIENT_METHODS.elicitation_create, (ctx) => implementation.createElicitation(ctx.params));
3873
- }
3874
- if (implementation.completeElicitation) {
3875
- app.onNotification(CLIENT_METHODS.elicitation_complete, (ctx) => implementation.completeElicitation(ctx.params));
3876
- }
3877
- if (implementation.extMethod) {
3878
- app[appBuilder]().withHandler({
3879
- handleMessage: async (message) => {
3880
- if (message.kind !== "request" || legacyClientRequestMethods.has(message.method)) {
3881
- return Handled.no(message);
3882
- }
3883
- await message.responder.respond(await implementation.extMethod(message.method, message.params));
3884
- return Handled.yes();
3885
- },
3886
- describe: () => "legacy-client-extension-request"
3887
- });
3888
- }
3889
- if (implementation.extNotification) {
3890
- app[appBuilder]().withHandler({
3891
- handleMessage: async (message) => {
3892
- if (message.kind !== "notification" || legacyClientNotificationMethods.has(message.method)) {
3893
- return Handled.no(message);
3894
- }
3895
- await implementation.extNotification(message.method, message.params);
3896
- return Handled.yes();
3897
- },
3898
- describe: () => "legacy-client-extension-notification"
3899
- });
3900
- }
3901
- return app;
3902
- }
3903
- class ClientSideConnection {
3902
+
3903
+ class TerminalHandle {
3904
+ id;
3905
+ sessionId;
3904
3906
  connection;
3905
- constructor(toClient, stream) {
3906
- this.connection = legacyClientApp(toClient(this))[appBuilder]().connect(stream, stableConnectionOptions);
3907
- }
3908
- initialize(params) {
3909
- return this.connection.sendRequest(AGENT_METHODS.initialize, params);
3910
- }
3911
- newSession(params) {
3912
- return this.connection.sendRequest(AGENT_METHODS.session_new, params);
3913
- }
3914
- loadSession(params) {
3915
- return this.connection.sendRequest(AGENT_METHODS.session_load, params, emptyObjectResponse);
3916
- }
3917
- unstable_forkSession(params) {
3918
- return this.connection.sendRequest(AGENT_METHODS.session_fork, params);
3919
- }
3920
- listSessions(params) {
3921
- return this.connection.sendRequest(AGENT_METHODS.session_list, params);
3922
- }
3923
- deleteSession(params) {
3924
- return this.connection.sendRequest(AGENT_METHODS.session_delete, params, emptyObjectResponse);
3925
- }
3926
- resumeSession(params) {
3927
- return this.connection.sendRequest(AGENT_METHODS.session_resume, params);
3928
- }
3929
- closeSession(params) {
3930
- return this.connection.sendRequest(AGENT_METHODS.session_close, params, emptyObjectResponse);
3931
- }
3932
- setSessionMode(params) {
3933
- return this.connection.sendRequest(AGENT_METHODS.session_set_mode, params, emptyObjectResponse);
3934
- }
3935
- setSessionConfigOption(params) {
3936
- return this.connection.sendRequest(AGENT_METHODS.session_set_config_option, params);
3937
- }
3938
- authenticate(params) {
3939
- return this.connection.sendRequest(AGENT_METHODS.authenticate, params, emptyObjectResponse);
3940
- }
3941
- unstable_listProviders(params) {
3942
- return this.connection.sendRequest(AGENT_METHODS.providers_list, params);
3943
- }
3944
- unstable_setProvider(params) {
3945
- return this.connection.sendRequest(AGENT_METHODS.providers_set, params, emptyObjectResponse);
3946
- }
3947
- unstable_disableProvider(params) {
3948
- return this.connection.sendRequest(AGENT_METHODS.providers_disable, params, emptyObjectResponse);
3949
- }
3950
- logout(params) {
3951
- return this.connection.sendRequest(AGENT_METHODS.logout, params, emptyObjectResponse);
3952
- }
3953
- prompt(params) {
3954
- return this.connection.sendRequest(AGENT_METHODS.session_prompt, params);
3955
- }
3956
- cancel(params) {
3957
- return this.connection.sendNotification(AGENT_METHODS.session_cancel, params);
3907
+ constructor(id, sessionId, conn) {
3908
+ this.id = id;
3909
+ this.sessionId = sessionId;
3910
+ this.connection = conn;
3958
3911
  }
3959
- request(method, params, options) {
3960
- const spec = agentRequestSpecsByMethod[method];
3961
- return this.connection.sendRequest(method, params, spec?.mapResponse, options);
3912
+ static create(id, sessionId, conn) {
3913
+ return new TerminalHandle(id, sessionId, conn);
3962
3914
  }
3963
- notify(method, params) {
3964
- return this.connection.sendNotification(method, params);
3915
+ currentOutput() {
3916
+ return this.connection.sendRequest(CLIENT_METHODS.terminal_output, {
3917
+ sessionId: this.sessionId,
3918
+ terminalId: this.id
3919
+ });
3965
3920
  }
3966
- extMethod(method, params) {
3967
- return this.request(method, params);
3921
+ waitForExit() {
3922
+ return this.connection.sendRequest(CLIENT_METHODS.terminal_wait_for_exit, {
3923
+ sessionId: this.sessionId,
3924
+ terminalId: this.id
3925
+ });
3968
3926
  }
3969
- extNotification(method, params) {
3970
- return this.notify(method, params);
3927
+ kill() {
3928
+ return this.connection.sendRequest(CLIENT_METHODS.terminal_kill, {
3929
+ sessionId: this.sessionId,
3930
+ terminalId: this.id
3931
+ }, emptyObjectResponse);
3971
3932
  }
3972
- get signal() {
3973
- return this.connection.signal;
3933
+ release() {
3934
+ return this.connection.sendRequest(CLIENT_METHODS.terminal_release, {
3935
+ sessionId: this.sessionId,
3936
+ terminalId: this.id
3937
+ }, emptyObjectResponse);
3974
3938
  }
3975
- get closed() {
3976
- return this.connection.closed;
3939
+ async[Symbol.asyncDispose]() {
3940
+ await this.release();
3977
3941
  }
3978
3942
  }
3979
-
3980
3943
  // src/providers/acp-adapter.ts
3981
3944
  init_package();
3982
3945
 
@@ -4784,7 +4747,7 @@ class SwarmAcpClient {
4784
4747
  }
4785
4748
 
4786
4749
  class ACPSession {
4787
- connection;
4750
+ agent;
4788
4751
  client;
4789
4752
  process;
4790
4753
  config;
@@ -4800,8 +4763,8 @@ class ACPSession {
4800
4763
  completionPromise;
4801
4764
  completionResolve;
4802
4765
  ephemeralTokenId = null;
4803
- constructor(connection, client, process2, config, sessionId, providerName, target, providerMeta, ephemeralTokenId) {
4804
- this.connection = connection;
4766
+ constructor(agent, client, process2, config, sessionId, providerName, target, providerMeta, ephemeralTokenId) {
4767
+ this.agent = agent;
4805
4768
  this.client = client;
4806
4769
  this.process = process2;
4807
4770
  this.config = config;
@@ -4830,7 +4793,7 @@ class ACPSession {
4830
4793
  return;
4831
4794
  this.aborted = true;
4832
4795
  try {
4833
- await this.connection.cancel({ sessionId: this.sessionId });
4796
+ await this.agent.notify(methods.agent.session.cancel, { sessionId: this.sessionId });
4834
4797
  await Promise.race([this.completionPromise, Bun.sleep(ACP_CANCEL_SETTLE_MS)]);
4835
4798
  } catch (err) {
4836
4799
  this.emit({
@@ -4874,7 +4837,7 @@ class ACPSession {
4874
4837
  async runPrompt() {
4875
4838
  let result;
4876
4839
  try {
4877
- const response = await this.connection.prompt({
4840
+ const response = await this.agent.request(methods.agent.session.prompt, {
4878
4841
  sessionId: this.sessionId,
4879
4842
  prompt: [{ type: "text", text: this.config.prompt }]
4880
4843
  });
@@ -5007,17 +4970,17 @@ class ACPAdapter2 {
5007
4970
  }
5008
4971
  let session = null;
5009
4972
  const preSessionEvents = [];
5010
- const client = new SwarmAcpClient((event) => {
4973
+ const client2 = new SwarmAcpClient((event) => {
5011
4974
  if (session)
5012
4975
  session.emitFromAcp(event);
5013
4976
  else
5014
4977
  preSessionEvents.push(event);
5015
4978
  }, target);
5016
4979
  const stream = ndJsonStream2(fileSinkWritableStream(proc.stdin), proc.stdout);
5017
- const connection = new ClientSideConnection(() => client, stream);
4980
+ const agent = client().onRequest(methods.client.session.requestPermission, ({ params }) => client2.requestPermission(params)).onNotification(methods.client.session.update, ({ params }) => client2.sessionUpdate(params)).connect(stream).agent;
5018
4981
  let ephemeralToken = null;
5019
4982
  try {
5020
- await connection.initialize({
4983
+ await agent.request(methods.agent.initialize, {
5021
4984
  protocolVersion: PROTOCOL_VERSION,
5022
4985
  clientInfo: { name: "agent-swarm", version: package_default.version },
5023
4986
  clientCapabilities: { session: { configOptions: { boolean: {} } } }
@@ -5025,7 +4988,7 @@ class ACPAdapter2 {
5025
4988
  ephemeralToken = await mintAcpSessionToken(config.apiUrl, config.apiKey, config.agentId, config.taskId);
5026
4989
  const installedServers = await fetchInstalledMcpServers(config.apiUrl, config.apiKey, config.agentId, "claude");
5027
4990
  const sessionMeta = target.sessionMeta?.(config);
5028
- const newSession = await connection.newSession({
4991
+ const newSession = await agent.request(methods.agent.session.new, {
5029
4992
  ...sessionMeta ? { _meta: sessionMeta } : {},
5030
4993
  cwd: config.cwd,
5031
4994
  mcpServers: [
@@ -5042,8 +5005,10 @@ class ACPAdapter2 {
5042
5005
  ...toAcpMcpServers(installedServers)
5043
5006
  ]
5044
5007
  });
5045
- const configOptions = await applyConfiguredOptions(connection, newSession.sessionId, newSession.configOptions ?? [], target.configuredOptions(config));
5046
- session = new ACPSession(connection, client, proc, config, newSession.sessionId, this.name, target, {
5008
+ const configOptions = await applyConfiguredOptions({
5009
+ setSessionConfigOption: (params) => agent.request(methods.agent.session.setConfigOption, params)
5010
+ }, newSession.sessionId, newSession.configOptions ?? [], target.configuredOptions(config));
5011
+ session = new ACPSession(agent, client2, proc, config, newSession.sessionId, this.name, target, {
5047
5012
  target: target.target,
5048
5013
  configOptions: sanitizeAcpConfigOptions(configOptions)
5049
5014
  }, ephemeralToken.tokenId);