@zvada/agent-server 0.3.25 → 0.3.27

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 (256) hide show
  1. package/CHANGELOG.md +113 -0
  2. package/README.md +4 -1
  3. package/dist/client/client.js +27 -11
  4. package/dist/client/connection.js +35 -3
  5. package/dist/core/agents/acp/acp-agent.js +91 -14
  6. package/dist/core/agents/acp/mappings.js +5 -1
  7. package/dist/core/agents/claude-code/approvals.js +3 -2
  8. package/dist/core/agents/claude-code/claude-agent.js +12 -2
  9. package/dist/core/agents/claude-code/mcp.js +9 -1
  10. package/dist/core/agents/claude-code/models.js +16 -10
  11. package/dist/core/agents/claude-code/options.js +23 -2
  12. package/dist/core/agents/claude-code/session.js +21 -1
  13. package/dist/core/agents/claude-code/tools.js +9 -4
  14. package/dist/core/agents/claude-code/turn.js +2 -0
  15. package/dist/core/agents/codex-app-server/adapter.js +2 -0
  16. package/dist/core/agents/codex-app-server/client.js +8 -5
  17. package/dist/core/agents/codex-app-server/codex-agent.js +35 -2
  18. package/dist/core/agents/codex-app-server/effort.js +13 -6
  19. package/dist/core/agents/codex-app-server/mcp.js +35 -18
  20. package/dist/core/agents/codex-app-server/models.js +10 -10
  21. package/dist/core/agents/codex-app-server/options.js +11 -2
  22. package/dist/core/agents/codex-app-server/plan-approval.js +1 -1
  23. package/dist/core/agents/codex-app-server/session.js +11 -4
  24. package/dist/core/agents/codex-app-server/thread-settings.js +30 -11
  25. package/dist/core/agents/host-tools.js +493 -0
  26. package/dist/core/agents/mcp-config.js +6 -2
  27. package/dist/core/agents/scripted/scripted-agent.js +39 -6
  28. package/dist/core/agents/scripted/steps.js +5 -1
  29. package/dist/core/agents/session-agent.js +70 -2
  30. package/dist/core/agents/thinking-levels.js +8 -5
  31. package/dist/core/index.js +1 -0
  32. package/dist/core/presets.js +16 -3
  33. package/dist/core/processes/lifeline.js +9 -5
  34. package/dist/core/provision/pins.js +7 -16
  35. package/dist/core/provision/releases.js +25 -25
  36. package/dist/core/proxy/loopback.js +22 -4
  37. package/dist/core/runtime/agent-runtime.js +15 -5
  38. package/dist/core/runtime/event-processor.js +13 -8
  39. package/dist/core/runtime/origin-line.js +42 -0
  40. package/dist/core/runtime/request-broker.js +2 -1
  41. package/dist/core/runtime/steering.js +4 -3
  42. package/dist/core/runtime/turn.js +6 -4
  43. package/dist/operator/errors.js +97 -0
  44. package/dist/operator/index.js +10 -5
  45. package/dist/operator/mcp.js +7 -12
  46. package/dist/operator/operator.js +1336 -380
  47. package/dist/operator/refs.js +59 -0
  48. package/dist/operator/render.js +171 -74
  49. package/dist/operator/session-tools.js +87 -0
  50. package/dist/operator/types.js +30 -0
  51. package/dist/operator/view.js +82 -27
  52. package/dist/protocol/config.js +33 -6
  53. package/dist/protocol/conversation.js +3 -0
  54. package/dist/protocol/history.js +2 -1
  55. package/dist/protocol/index.js +1 -0
  56. package/dist/protocol/lifecycle.js +19 -0
  57. package/dist/protocol/model-catalog.js +58 -18
  58. package/dist/protocol/models.js +6 -27
  59. package/dist/protocol/origin.js +39 -0
  60. package/dist/protocol/reduce.js +2 -0
  61. package/dist/protocol/thinking.js +22 -9
  62. package/dist/protocol/wire-api.js +2 -2
  63. package/dist/protocol/wire.js +17 -0
  64. package/dist/server/bin.js +6 -4
  65. package/dist/server/routes.js +15 -5
  66. package/dist/types/client/client.d.ts.map +1 -1
  67. package/dist/types/client/connection.d.ts +14 -2
  68. package/dist/types/client/connection.d.ts.map +1 -1
  69. package/dist/types/client/turns.d.ts +2 -2
  70. package/dist/types/client/turns.d.ts.map +1 -1
  71. package/dist/types/core/agents/acp/acp-agent.d.ts +15 -0
  72. package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -1
  73. package/dist/types/core/agents/acp/mappings.d.ts +5 -1
  74. package/dist/types/core/agents/acp/mappings.d.ts.map +1 -1
  75. package/dist/types/core/agents/acp/requests.d.ts +2 -0
  76. package/dist/types/core/agents/acp/requests.d.ts.map +1 -1
  77. package/dist/types/core/agents/base.d.ts +2 -0
  78. package/dist/types/core/agents/base.d.ts.map +1 -1
  79. package/dist/types/core/agents/claude-code/approvals.d.ts +2 -1
  80. package/dist/types/core/agents/claude-code/approvals.d.ts.map +1 -1
  81. package/dist/types/core/agents/claude-code/claude-agent.d.ts +1 -0
  82. package/dist/types/core/agents/claude-code/claude-agent.d.ts.map +1 -1
  83. package/dist/types/core/agents/claude-code/mcp.d.ts +8 -1
  84. package/dist/types/core/agents/claude-code/mcp.d.ts.map +1 -1
  85. package/dist/types/core/agents/claude-code/models.d.ts +9 -5
  86. package/dist/types/core/agents/claude-code/models.d.ts.map +1 -1
  87. package/dist/types/core/agents/claude-code/options.d.ts +10 -1
  88. package/dist/types/core/agents/claude-code/options.d.ts.map +1 -1
  89. package/dist/types/core/agents/claude-code/session.d.ts +2 -0
  90. package/dist/types/core/agents/claude-code/session.d.ts.map +1 -1
  91. package/dist/types/core/agents/claude-code/tools.d.ts.map +1 -1
  92. package/dist/types/core/agents/claude-code/turn.d.ts +3 -0
  93. package/dist/types/core/agents/claude-code/turn.d.ts.map +1 -1
  94. package/dist/types/core/agents/codex-app-server/adapter.d.ts.map +1 -1
  95. package/dist/types/core/agents/codex-app-server/client.d.ts +2 -0
  96. package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -1
  97. package/dist/types/core/agents/codex-app-server/codex-agent.d.ts +11 -0
  98. package/dist/types/core/agents/codex-app-server/codex-agent.d.ts.map +1 -1
  99. package/dist/types/core/agents/codex-app-server/effort.d.ts +7 -7
  100. package/dist/types/core/agents/codex-app-server/effort.d.ts.map +1 -1
  101. package/dist/types/core/agents/codex-app-server/mcp.d.ts +11 -3
  102. package/dist/types/core/agents/codex-app-server/mcp.d.ts.map +1 -1
  103. package/dist/types/core/agents/codex-app-server/models.d.ts +4 -1
  104. package/dist/types/core/agents/codex-app-server/models.d.ts.map +1 -1
  105. package/dist/types/core/agents/codex-app-server/options.d.ts +9 -2
  106. package/dist/types/core/agents/codex-app-server/options.d.ts.map +1 -1
  107. package/dist/types/core/agents/codex-app-server/requests.d.ts +2 -0
  108. package/dist/types/core/agents/codex-app-server/requests.d.ts.map +1 -1
  109. package/dist/types/core/agents/codex-app-server/session.d.ts +6 -3
  110. package/dist/types/core/agents/codex-app-server/session.d.ts.map +1 -1
  111. package/dist/types/core/agents/codex-app-server/thread-settings.d.ts.map +1 -1
  112. package/dist/types/core/agents/host-tools.d.ts +162 -0
  113. package/dist/types/core/agents/host-tools.d.ts.map +1 -0
  114. package/dist/types/core/agents/mcp-config.d.ts +11 -2
  115. package/dist/types/core/agents/mcp-config.d.ts.map +1 -1
  116. package/dist/types/core/agents/scripted/scripted-agent.d.ts +14 -1
  117. package/dist/types/core/agents/scripted/scripted-agent.d.ts.map +1 -1
  118. package/dist/types/core/agents/scripted/steps.d.ts.map +1 -1
  119. package/dist/types/core/agents/session-agent.d.ts +2 -7
  120. package/dist/types/core/agents/session-agent.d.ts.map +1 -1
  121. package/dist/types/core/agents/thinking-levels.d.ts +7 -3
  122. package/dist/types/core/agents/thinking-levels.d.ts.map +1 -1
  123. package/dist/types/core/index.d.ts +1 -0
  124. package/dist/types/core/index.d.ts.map +1 -1
  125. package/dist/types/core/presets.d.ts +11 -1
  126. package/dist/types/core/presets.d.ts.map +1 -1
  127. package/dist/types/core/processes/lifeline.d.ts.map +1 -1
  128. package/dist/types/core/provision/pins.d.ts +5 -4
  129. package/dist/types/core/provision/pins.d.ts.map +1 -1
  130. package/dist/types/core/proxy/loopback.d.ts.map +1 -1
  131. package/dist/types/core/runtime/agent-runtime.d.ts +4 -2
  132. package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -1
  133. package/dist/types/core/runtime/event-processor.d.ts +2 -2
  134. package/dist/types/core/runtime/event-processor.d.ts.map +1 -1
  135. package/dist/types/core/runtime/origin-line.d.ts +15 -0
  136. package/dist/types/core/runtime/origin-line.d.ts.map +1 -0
  137. package/dist/types/core/runtime/request-broker.d.ts +1 -1
  138. package/dist/types/core/runtime/request-broker.d.ts.map +1 -1
  139. package/dist/types/core/runtime/steering.d.ts +7 -4
  140. package/dist/types/core/runtime/steering.d.ts.map +1 -1
  141. package/dist/types/core/runtime/turn.d.ts.map +1 -1
  142. package/dist/types/operator/errors.d.ts +83 -0
  143. package/dist/types/operator/errors.d.ts.map +1 -0
  144. package/dist/types/operator/index.d.ts +10 -5
  145. package/dist/types/operator/index.d.ts.map +1 -1
  146. package/dist/types/operator/mcp.d.ts +1 -1
  147. package/dist/types/operator/mcp.d.ts.map +1 -1
  148. package/dist/types/operator/operator.d.ts +15 -197
  149. package/dist/types/operator/operator.d.ts.map +1 -1
  150. package/dist/types/operator/refs.d.ts +25 -0
  151. package/dist/types/operator/refs.d.ts.map +1 -0
  152. package/dist/types/operator/render.d.ts +59 -19
  153. package/dist/types/operator/render.d.ts.map +1 -1
  154. package/dist/types/operator/session-tools.d.ts +61 -0
  155. package/dist/types/operator/session-tools.d.ts.map +1 -0
  156. package/dist/types/operator/types.d.ts +441 -0
  157. package/dist/types/operator/types.d.ts.map +1 -0
  158. package/dist/types/operator/view.d.ts +19 -29
  159. package/dist/types/operator/view.d.ts.map +1 -1
  160. package/dist/types/protocol/config.d.ts +32 -24
  161. package/dist/types/protocol/config.d.ts.map +1 -1
  162. package/dist/types/protocol/conversation.d.ts +48 -39
  163. package/dist/types/protocol/conversation.d.ts.map +1 -1
  164. package/dist/types/protocol/execution.d.ts +2 -18
  165. package/dist/types/protocol/execution.d.ts.map +1 -1
  166. package/dist/types/protocol/history.d.ts +1 -1
  167. package/dist/types/protocol/history.d.ts.map +1 -1
  168. package/dist/types/protocol/index.d.ts +1 -0
  169. package/dist/types/protocol/index.d.ts.map +1 -1
  170. package/dist/types/protocol/lifecycle.d.ts +48 -74
  171. package/dist/types/protocol/lifecycle.d.ts.map +1 -1
  172. package/dist/types/protocol/model-catalog.d.ts.map +1 -1
  173. package/dist/types/protocol/models.d.ts +4 -42
  174. package/dist/types/protocol/models.d.ts.map +1 -1
  175. package/dist/types/protocol/origin.d.ts +49 -0
  176. package/dist/types/protocol/origin.d.ts.map +1 -0
  177. package/dist/types/protocol/reduce.d.ts.map +1 -1
  178. package/dist/types/protocol/thinking.d.ts +19 -19
  179. package/dist/types/protocol/thinking.d.ts.map +1 -1
  180. package/dist/types/protocol/wire-api.d.ts +59 -106
  181. package/dist/types/protocol/wire-api.d.ts.map +1 -1
  182. package/dist/types/protocol/wire.d.ts +81 -119
  183. package/dist/types/protocol/wire.d.ts.map +1 -1
  184. package/dist/types/server/routes.d.ts.map +1 -1
  185. package/docs/consuming.md +124 -132
  186. package/docs/deploy.md +6 -5
  187. package/docs/harnesses.md +79 -31
  188. package/docs/sync-history.md +2 -1
  189. package/package.json +4 -4
  190. package/src/client/client.ts +36 -9
  191. package/src/client/connection.ts +31 -1
  192. package/src/client/turns.ts +2 -1
  193. package/src/core/agents/acp/acp-agent.ts +123 -17
  194. package/src/core/agents/acp/mappings.ts +5 -1
  195. package/src/core/agents/acp/requests.ts +2 -0
  196. package/src/core/agents/base.ts +2 -0
  197. package/src/core/agents/claude-code/approvals.ts +4 -3
  198. package/src/core/agents/claude-code/claude-agent.ts +14 -2
  199. package/src/core/agents/claude-code/mcp.ts +11 -1
  200. package/src/core/agents/claude-code/models.ts +15 -10
  201. package/src/core/agents/claude-code/options.ts +33 -3
  202. package/src/core/agents/claude-code/session.ts +26 -1
  203. package/src/core/agents/claude-code/tools.ts +10 -4
  204. package/src/core/agents/claude-code/turn.ts +4 -0
  205. package/src/core/agents/codex-app-server/adapter.ts +2 -0
  206. package/src/core/agents/codex-app-server/client.ts +11 -5
  207. package/src/core/agents/codex-app-server/codex-agent.ts +45 -1
  208. package/src/core/agents/codex-app-server/effort.ts +15 -20
  209. package/src/core/agents/codex-app-server/mcp.ts +46 -23
  210. package/src/core/agents/codex-app-server/models.ts +10 -10
  211. package/src/core/agents/codex-app-server/options.ts +16 -2
  212. package/src/core/agents/codex-app-server/plan-approval.ts +1 -1
  213. package/src/core/agents/codex-app-server/requests.ts +2 -0
  214. package/src/core/agents/codex-app-server/session.ts +19 -4
  215. package/src/core/agents/codex-app-server/thread-settings.ts +31 -11
  216. package/src/core/agents/host-tools.ts +649 -0
  217. package/src/core/agents/mcp-config.ts +15 -3
  218. package/src/core/agents/scripted/scripted-agent.ts +51 -5
  219. package/src/core/agents/scripted/steps.ts +5 -1
  220. package/src/core/agents/session-agent.ts +78 -2
  221. package/src/core/agents/thinking-levels.ts +9 -6
  222. package/src/core/index.ts +9 -0
  223. package/src/core/presets.ts +28 -4
  224. package/src/core/processes/lifeline.ts +9 -5
  225. package/src/core/provision/pins.ts +7 -16
  226. package/src/core/provision/releases.ts +25 -25
  227. package/src/core/proxy/loopback.ts +25 -4
  228. package/src/core/runtime/agent-runtime.ts +31 -7
  229. package/src/core/runtime/event-processor.ts +13 -6
  230. package/src/core/runtime/origin-line.ts +43 -0
  231. package/src/core/runtime/request-broker.ts +2 -0
  232. package/src/core/runtime/steering.ts +8 -4
  233. package/src/core/runtime/turn.ts +11 -4
  234. package/src/operator/errors.ts +218 -0
  235. package/src/operator/index.ts +18 -23
  236. package/src/operator/mcp.ts +7 -16
  237. package/src/operator/operator.ts +1583 -613
  238. package/src/operator/refs.ts +75 -0
  239. package/src/operator/render.ts +208 -98
  240. package/src/operator/session-tools.ts +126 -0
  241. package/src/operator/types.ts +505 -0
  242. package/src/operator/view.ts +93 -42
  243. package/src/protocol/config.ts +36 -7
  244. package/src/protocol/conversation.ts +3 -0
  245. package/src/protocol/history.ts +2 -1
  246. package/src/protocol/index.ts +1 -0
  247. package/src/protocol/lifecycle.ts +21 -0
  248. package/src/protocol/model-catalog.ts +58 -18
  249. package/src/protocol/models.ts +6 -26
  250. package/src/protocol/origin.ts +47 -0
  251. package/src/protocol/reduce.ts +4 -0
  252. package/src/protocol/thinking.ts +27 -14
  253. package/src/protocol/wire-api.ts +2 -2
  254. package/src/protocol/wire.ts +18 -0
  255. package/src/server/bin.ts +6 -4
  256. package/src/server/routes.ts +16 -5
@@ -15,6 +15,7 @@ import {
15
15
  type InitializeResult,
16
16
  type ModelList,
17
17
  type ModelsListParams,
18
+ type Origin,
18
19
  type PermissionOutcome,
19
20
  type RunningTurn,
20
21
  type SessionConfirmStoppedParams,
@@ -27,8 +28,10 @@ import {
27
28
  type TurnSteerParams,
28
29
  type TurnSteerResult,
29
30
  WIRE_ERROR_CODES,
31
+ WIRE_FEATURES,
30
32
  WIRE_METHODS,
31
33
  type WireTransport,
34
+ agentOrigin,
32
35
  decodeWireEventEnvelope,
33
36
  decodeWireMessage,
34
37
  generateUUIDv7,
@@ -321,7 +324,7 @@ export class AgentServerClient {
321
324
  // Before the first `await`: a cancel sent right behind this call goes out after the start.
322
325
  const release = this.starts.begin(sessionId, turnId);
323
326
  try {
324
- await this.initialize();
327
+ carriesOrigin(await this.initialize(), params.origin);
325
328
  if (this.turns.running(sessionId))
326
329
  throw new Error(`session ${sessionId} already has an active turn`);
327
330
  const handle = this.turns.open(sessionId, turnId, true);
@@ -335,6 +338,7 @@ export class AgentServerClient {
335
338
  (ack) => {
336
339
  if (!ack.terminal) this.joinAt(handle, ack.headSeq, { turnId });
337
340
  },
341
+ (server) => carriesOrigin(server, params.origin),
338
342
  );
339
343
  release();
340
344
  const accepted = await sending;
@@ -373,7 +377,7 @@ export class AgentServerClient {
373
377
  // As in `runTurn`: a cancel sent right behind this call goes out after the start.
374
378
  const release = this.starts.begin(sessionId, turnId);
375
379
  try {
376
- await this.initialize();
380
+ carriesOrigin(await this.initialize(), params.origin);
377
381
  // `request` sends (or fails for no connection) in this call.
378
382
  const answer = this.connection.request(
379
383
  WIRE_METHODS.turnStart,
@@ -382,6 +386,7 @@ export class AgentServerClient {
382
386
  if (params.subscribe !== false && !ack.terminal)
383
387
  this.streams.joined(sessionId, ack.headSeq, { turnId });
384
388
  },
389
+ (server) => carriesOrigin(server, params.origin),
385
390
  );
386
391
  release();
387
392
  return await answer;
@@ -431,7 +436,7 @@ export class AgentServerClient {
431
436
  * steer's user message, its receipt, reaches it.
432
437
  */
433
438
  async steerTurn(params: TurnSteerParams): Promise<TurnSteerResult> {
434
- await this.initialize();
439
+ carriesOrigin(await this.initialize(), params.origin);
435
440
  const { sessionId, turnId } = params;
436
441
  // One it cannot subscribe to still takes the steer; only its receipt is lost.
437
442
  if (!this.streams.follows(sessionId))
@@ -440,10 +445,12 @@ export class AgentServerClient {
440
445
  if (ack.activeTurn?.turnId === turnId)
441
446
  this.streams.joined(sessionId, ack.headSeq, { turnId });
442
447
  }).catch(() => undefined);
443
- return this.connection.resend(WIRE_METHODS.turnSteer, {
444
- ...params,
445
- steerId: params.steerId ?? generateUUIDv7(),
446
- });
448
+ return this.connection.resend(
449
+ WIRE_METHODS.turnSteer,
450
+ { ...params, steerId: params.steerId ?? generateUUIDv7() },
451
+ undefined,
452
+ (server) => carriesOrigin(server, params.origin),
453
+ );
447
454
  }
448
455
 
449
456
  /**
@@ -895,8 +902,14 @@ export class AgentServerClient {
895
902
  get catchUp() {
896
903
  return handle.catchUp;
897
904
  },
898
- steer: (input: AgentInput, steerId?: string) =>
899
- this.steerTurn({ sessionId, turnId, input, ...(steerId !== undefined && { steerId }) }),
905
+ steer: (input: AgentInput, steerId?: string, origin?: Origin) =>
906
+ this.steerTurn({
907
+ sessionId,
908
+ turnId,
909
+ input,
910
+ ...(steerId !== undefined && { steerId }),
911
+ ...(origin && { origin }),
912
+ }),
900
913
  };
901
914
  }
902
915
 
@@ -971,3 +984,17 @@ export class AgentServerClient {
971
984
  return this.connection.request(WIRE_METHODS.sessionSubscribe, params, onAnswer);
972
985
  }
973
986
  }
987
+
988
+ // @ref LLP 0019#origin-on-the-wire-and-to-the-model — fail closed: an origin a server would strip reads as the person's
989
+ /**
990
+ * Refuse to send another sender's input to a server that does not carry
991
+ * `origin`: its schema would drop the field, and the agent would read the
992
+ * message as the person's. The person's input goes anywhere.
993
+ */
994
+ function carriesOrigin(server: InitializeResult, origin: Origin | undefined): void {
995
+ if (!agentOrigin(origin)) return;
996
+ if (server.features?.includes(WIRE_FEATURES.origin)) return;
997
+ throw new Error(
998
+ "This server does not carry a message's origin (no `origin` in its features); nothing was sent. Upgrade the server, or send the input as the person's.",
999
+ );
1000
+ }
@@ -180,6 +180,10 @@ export class Connection {
180
180
  /** The server process (or, durable, the journal) whose logs the client follows. */
181
181
  private serverIdentity: string | undefined;
182
182
  private initializing: Promise<InitializeResult> | null = null;
183
+ /** The current transport's handshake, once answered; cleared when it is asked again. */
184
+ private negotiated: InitializeResult | undefined;
185
+ /** The transport `negotiated` was answered on: a feature check holds only for it. */
186
+ private negotiatedOn: WireTransport | null = null;
183
187
  private reconnecting = false;
184
188
  /** Ends the redial backoff early: `close()` must not wait it out. */
185
189
  private stopBackoff: (() => void) | null = null;
@@ -218,6 +222,10 @@ export class Connection {
218
222
  }
219
223
  if (transport.closed) throw new ConnectionClosedError("transport opened already closed");
220
224
  this.transport = transport;
225
+ // A new transport's server is not the old one's until its own handshake says so.
226
+ this.initializing = null;
227
+ this.negotiated = undefined;
228
+ this.negotiatedOn = null;
221
229
  this.host.opened(this.reconnecting);
222
230
  transport.onLine((line) => {
223
231
  if (this.transport === transport) this.host.line(line, transport);
@@ -230,6 +238,8 @@ export class Connection {
230
238
  * client for good: it rejects with `ProtocolVersionMismatchError`.
231
239
  */
232
240
  initialize(): Promise<InitializeResult> {
241
+ if (!this.initializing) this.negotiated = undefined;
242
+ const on = this.transport;
233
243
  this.initializing ??= this.request(WIRE_METHODS.initialize, {
234
244
  protocolVersion: WIRE_PROTOCOL_VERSION,
235
245
  client: this.options.clientInfo,
@@ -245,6 +255,8 @@ export class Connection {
245
255
  if (this.serverIdentity !== undefined && this.serverIdentity !== identity)
246
256
  this.host.serverChanged();
247
257
  this.serverIdentity = identity;
258
+ this.negotiated = result;
259
+ this.negotiatedOn = on;
248
260
  return result;
249
261
  })
250
262
  .catch((error: unknown) => {
@@ -280,11 +292,23 @@ export class Connection {
280
292
  method: M,
281
293
  params: WireParams<M>,
282
294
  onAnswer?: OnAnswer<WireDecodedResult<M>>,
295
+ /** Asked with the handshake of the very transport the request goes on; throw to send nothing. */
296
+ admit?: (server: InitializeResult) => void,
283
297
  ): Promise<WireDecodedResult<M>> {
284
298
  if (this.closed)
285
299
  return Promise.reject(this.refusal ?? new ConnectionClosedError("client closed"));
286
300
  const transport = this.transport;
287
301
  if (!transport) return Promise.reject(new ConnectionClosedError("not connected"));
302
+ if (admit) {
303
+ // This transport's handshake not answered yet: wait for it, then ask again.
304
+ if (this.negotiatedOn !== transport || !this.negotiated)
305
+ return this.initialize().then(() => this.request(method, params, onAnswer, admit));
306
+ try {
307
+ admit(this.negotiated);
308
+ } catch (error) {
309
+ return Promise.reject(error);
310
+ }
311
+ }
288
312
  return this.rpc.request(transport, method, params, WIRE_API[method].decode, onAnswer);
289
313
  }
290
314
 
@@ -301,11 +325,17 @@ export class Connection {
301
325
  method: M,
302
326
  params: WireParams<M>,
303
327
  onAnswer?: OnAnswer<WireDecodedResult<M>>,
328
+ /**
329
+ * Asked with the server this attempt goes to, before each send, re-sends
330
+ * included: a redial may reach another build of the server. Throw to send
331
+ * nothing (LLP 0019: an origin that server would strip).
332
+ */
333
+ admit?: (server: InitializeResult) => void,
304
334
  ): Promise<WireDecodedResult<M>> {
305
335
  for (let resends = 0; ; resends++) {
306
336
  const identity = this.serverIdentity;
307
337
  try {
308
- return await this.request(method, params, onAnswer);
338
+ return await this.request(method, params, onAnswer, admit);
309
339
  } catch (error) {
310
340
  if (!(error instanceof ConnectionClosedError) || !this.redials || resends >= MAX_RESENDS)
311
341
  throw error;
@@ -3,6 +3,7 @@ import {
3
3
  AsyncQueue,
4
4
  type DecodedLifecycleEvent,
5
5
  type DecodedWireEventEnvelope,
6
+ type Origin,
6
7
  type TurnEndedEvent,
7
8
  type TurnSteerResult,
8
9
  type UnknownEvent,
@@ -35,7 +36,7 @@ export interface TurnHandle {
35
36
  */
36
37
  readonly catchUp: number;
37
38
  /** Add input to this turn while it runs (see `AgentServerClient.steerTurn`). */
38
- steer(input: AgentInput, steerId?: string): Promise<TurnSteerResult>;
39
+ steer(input: AgentInput, steerId?: string, origin?: Origin): Promise<TurnSteerResult>;
39
40
  }
40
41
 
41
42
  /**
@@ -7,16 +7,24 @@ import type {
7
7
  import type {
8
8
  AgentCapabilities,
9
9
  AgentInput,
10
+ McpServerConfig,
10
11
  PermissionMode,
11
12
  RunConfig,
12
13
  } from "../../../protocol/index.ts";
13
14
  import { AsyncQueue } from "../../../protocol/index.ts";
14
15
  import { type NativeProcesses, sharedNativeProcesses } from "../../processes/native-processes.ts";
15
16
  import { onAbort, untilAborted } from "../../utils/deadline.ts";
16
- import { SessionResumeError } from "../../utils/errors.ts";
17
+ import { McpUnavailableError, SessionResumeError } from "../../utils/errors.ts";
17
18
  import type { AgentExecuteOptions, RawAgentEvent } from "../base.ts";
18
19
  import { configFingerprint } from "../config-fingerprint.ts";
19
- import { nativeMcpServer } from "../mcp-config.ts";
20
+ import {
21
+ type HostLease,
22
+ type HostToolSessions,
23
+ type HostTools,
24
+ hostToolSessions,
25
+ loopbackDirect,
26
+ refuseHostName,
27
+ } from "../host-tools.ts";
20
28
  import { IDLE_TIMEOUT_MS, ProcessPool } from "../process-pool.ts";
21
29
  import { SessionAgent } from "../session-agent.ts";
22
30
  import { type AcpRawEvent, CANCELLED_PROMPT_RESULT } from "./adapter.ts";
@@ -32,25 +40,41 @@ import { type TurnScope, answerElicitation, answerPermission } from "./requests.
32
40
  /**
33
41
  * What a session's agent process was started with, as one key: a change to
34
42
  * any of it starts another, which resumes the conversation where the agent
35
- * can. MCP servers go without `required`, which is the engine's; extra
36
- * directories count, in any order, only for an agent that takes them.
43
+ * can. MCP servers count as the agent is given them (no `required`, which is
44
+ * the engine's, no `timeoutMs`, which ACP cannot carry); the host's tools by
45
+ * their name, their address and secret being the session's for its life;
46
+ * extra directories, in any order, only for an agent that takes them.
37
47
  * Hashed: the env and MCP headers carry credentials.
38
48
  */
49
+ /** What the agent is given, in an order of its own: a server's, header's or variable's place means nothing. */
50
+ function canonicalServers(servers: Record<string, McpServerConfig>) {
51
+ // A total order by code unit: `localeCompare` calls distinct names equal.
52
+ const byName = (a: { name: string }, b: { name: string }) =>
53
+ a.name < b.name ? -1 : a.name > b.name ? 1 : 0;
54
+ return toAcpMcpServers(servers)
55
+ .map((server) =>
56
+ "headers" in server
57
+ ? { ...server, headers: [...server.headers].sort(byName) }
58
+ : "env" in server
59
+ ? { ...server, env: [...server.env].sort(byName) }
60
+ : server,
61
+ )
62
+ .sort(byName);
63
+ }
64
+
39
65
  function spawnKey(
40
66
  options: AgentExecuteOptions,
41
67
  launch: AcpLaunch,
42
68
  takesDirectories: boolean,
69
+ host: string | undefined,
43
70
  ): string {
44
- const servers = options.mcpServers;
45
71
  return configFingerprint({
46
72
  launch: { command: launch.command, args: launch.args ?? [], env: launch.env ?? {} },
47
73
  cwd: options.cwd,
48
74
  env: options.env,
49
- mcpServers:
50
- servers &&
51
- Object.fromEntries(
52
- Object.entries(servers).map(([name, server]) => [name, nativeMcpServer(server)]),
53
- ),
75
+ // @ref LLP 0018#acp — only what the agent is given
76
+ mcpServers: options.mcpServers && canonicalServers(options.mcpServers),
77
+ host,
54
78
  directories: takesDirectories
55
79
  ? [...new Set(options.additionalDirectories ?? [])].sort()
56
80
  : undefined,
@@ -139,6 +163,12 @@ export interface AcpAgentOptions {
139
163
  * and recorded for its session (`createAgentRegistry` passes the runtime's).
140
164
  */
141
165
  processes?: NativeProcesses;
166
+ /**
167
+ * The host's tools for each session (LLP 0018), at the engine's loopback,
168
+ * for an agent that takes HTTP MCP servers; another goes without them,
169
+ * which its turn says. Operator-level only.
170
+ */
171
+ hostTools?: HostTools;
142
172
  }
143
173
 
144
174
  interface AcpSession {
@@ -150,6 +180,8 @@ interface AcpSession {
150
180
  takesDirectories: boolean;
151
181
  /** From `initialize`: whether another process could continue the conversation (resume or load). */
152
182
  resumable: boolean;
183
+ /** The agent takes HTTP servers, and was started without the host's: the loopback was down. */
184
+ hostFailed?: true;
153
185
  /** The agent's selectable settings, kept current by `config_option_update`. */
154
186
  configOptions: SessionConfigOption[];
155
187
  /** The agent's modes, kept current by `current_mode_update`; absent when it offers none. */
@@ -163,6 +195,8 @@ interface AcpSession {
163
195
  interface AcpPoolTurn {
164
196
  options: AgentExecuteOptions;
165
197
  launch: AcpLaunch;
198
+ /** The host's tools, which the agent reaches over HTTP when it takes such a server. */
199
+ host?: HostLease;
166
200
  }
167
201
 
168
202
  /** A JSON-RPC error's `data` usually holds the cause its message only names. */
@@ -198,16 +232,32 @@ export class AcpAgent extends SessionAgent {
198
232
  /** Its CLIs start here: the runtime's, or this OS process's own when it was made without one. */
199
233
  readonly processes: NativeProcesses;
200
234
  private readonly sessions: ProcessPool<AcpSession, AcpPoolTurn>;
235
+ private readonly host?: HostToolSessions;
201
236
 
202
237
  constructor(private readonly agentOptions: AcpAgentOptions) {
203
238
  super({ cancelConfirmMs: agentOptions.cancelConfirmMs });
204
239
  this.processes = agentOptions.processes ?? sharedNativeProcesses();
240
+ this.host = hostToolSessions(agentOptions.hostTools, this.harness, {
241
+ // @ref LLP 0018#acp — the engine's mode: the turn's, moved only by a plan the broker approved
242
+ // The agent's own `current_mode_update` never raises it.
243
+ live: (sessionId) => {
244
+ const turn = this.sessions.get(sessionId)?.turn;
245
+ return turn?.turnId
246
+ ? { turnId: turn.turnId, permissionMode: turn.mode ?? "default", signal: turn.signal }
247
+ : undefined;
248
+ },
249
+ writesNeedFullAccess: true,
250
+ });
205
251
  this.sessions = new ProcessPool<AcpSession, AcpPoolTurn>(
206
252
  {
207
253
  resumeOf: ({ options }) => options.resumeSessionId,
208
254
  conversationsOf: (session) => [session.acpSessionId],
209
- fits: (session, { options, launch }) =>
210
- session.spawnKey === spawnKey(options, launch, session.takesDirectories),
255
+ fits: (session, { options, launch, host }) =>
256
+ session.spawnKey ===
257
+ spawnKey(options, launch, session.takesDirectories, host?.source.name) &&
258
+ // @ref LLP 0018#acp — an agent started without the host's tools while the loopback was down
259
+ // One that can resume is started again, to get them; one that cannot keeps its conversation.
260
+ !(session.hostFailed && session.resumable),
211
261
  // @ref LLP 0001#d10--built-in-turns-own-their-logical-session-through-cleanup — not ended for idleness when it cannot be resumed
212
262
  // An agent that can neither resume nor load holds the only copy of
213
263
  // its conversation: neither idleness nor a host resume ends it.
@@ -232,7 +282,47 @@ export class AcpAgent extends SessionAgent {
232
282
  );
233
283
  }
234
284
 
235
- return this.sessions.acquire(options.sessionId, { options, launch }, signal);
285
+ const host = await untilAborted(
286
+ Promise.resolve(this.host?.lease(options.sessionId, options.cwd)),
287
+ signal,
288
+ );
289
+ if (host) refuseHostName(options.mcpServers, host.source.name);
290
+ return this.sessions.acquire(options.sessionId, { options, launch, host }, signal);
291
+ }
292
+
293
+ protected override hostSecret(sessionId: string): string | undefined {
294
+ return this.host?.secretOf(sessionId);
295
+ }
296
+
297
+ // @ref LLP 0018#acp — an agent that takes no HTTP server goes without the host's tools, and says so
298
+ /**
299
+ * The servers the agent is given: the turn's, and the host's when the agent
300
+ * takes HTTP servers, the loopback started only then. Without it, or with a
301
+ * loopback that cannot start, the turn says so and goes on without them.
302
+ */
303
+ private async serversFor(
304
+ options: AgentExecuteOptions,
305
+ host: HostLease | undefined,
306
+ http: boolean,
307
+ ): Promise<{ servers: AgentExecuteOptions["mcpServers"]; hostFailed?: true }> {
308
+ if (!host) return { servers: options.mcpServers };
309
+ const { name } = host.source;
310
+ let cause = "the agent takes no HTTP MCP server";
311
+ let hostFailed: true | undefined;
312
+ if (http) {
313
+ try {
314
+ return { servers: { ...options.mcpServers, [name]: await host.http() } };
315
+ } catch (error) {
316
+ if (!(error instanceof McpUnavailableError)) throw error;
317
+ cause = error.servers[name] ?? error.message;
318
+ hostFailed = true;
319
+ }
320
+ }
321
+ await options.onWarning?.({
322
+ category: "mcp_unavailable",
323
+ message: `MCP server ${name} could not connect (${cause}); the turn goes on without the host's tools`,
324
+ });
325
+ return { servers: options.mcpServers, ...(hostFailed && { hostFailed }) };
236
326
  }
237
327
 
238
328
  /**
@@ -242,7 +332,7 @@ export class AcpAgent extends SessionAgent {
242
332
  * successor never loads a conversation another agent still has.
243
333
  */
244
334
  private async spawn(
245
- { options, launch }: AcpPoolTurn,
335
+ { options, launch, host }: AcpPoolTurn,
246
336
  own: (client: AcpClient) => void,
247
337
  signal: AbortSignal,
248
338
  ): Promise<AcpSession> {
@@ -250,7 +340,14 @@ export class AcpAgent extends SessionAgent {
250
340
  const clientOptions: AcpClientOptions = {
251
341
  launch,
252
342
  cwd: options.cwd,
253
- env: options.env,
343
+ // @ref LLP 0018#acp — the bearer never travels through a proxy
344
+ // In the client's own order: the engine's environment, the launch's, the turn's.
345
+ env: this.host
346
+ ? {
347
+ ...options.env,
348
+ ...loopbackDirect({ ...process.env, ...launch.env, ...options.env }),
349
+ }
350
+ : options.env,
254
351
  clientName: this.agentOptions.clientName,
255
352
  sessionId: options.sessionId,
256
353
  processes: this.processes,
@@ -287,9 +384,14 @@ export class AcpAgent extends SessionAgent {
287
384
  : capabilities?.loadSession
288
385
  ? "session/load"
289
386
  : undefined;
387
+ const given = await this.serversFor(
388
+ options,
389
+ host,
390
+ Boolean(capabilities?.mcpCapabilities?.http),
391
+ );
290
392
  const target = {
291
393
  cwd: options.cwd,
292
- mcpServers: toAcpMcpServers(options.mcpServers),
394
+ mcpServers: toAcpMcpServers(given.servers),
293
395
  // Sent only to agents that advertise it; others keep `cwd` alone.
294
396
  ...(takesDirectories &&
295
397
  options.additionalDirectories?.length && {
@@ -332,7 +434,8 @@ export class AcpAgent extends SessionAgent {
332
434
  const session: AcpSession = {
333
435
  client,
334
436
  acpSessionId,
335
- spawnKey: spawnKey(options, launch, takesDirectories),
437
+ spawnKey: spawnKey(options, launch, takesDirectories, host?.source.name),
438
+ ...(given.hostFailed && { hostFailed: true }),
336
439
  takesDirectories,
337
440
  resumable: resumeMethod !== undefined,
338
441
  configOptions: configOptions ?? [],
@@ -458,6 +561,7 @@ export class AcpAgent extends SessionAgent {
458
561
  elicitation: options.onElicitationRequest,
459
562
  mode: options.permissionMode,
460
563
  signal: controller.signal,
564
+ turnId: options.turnId,
461
565
  };
462
566
  options.onNativeSession?.(session.acpSessionId, {
463
567
  resumed: session.acpSessionId === options.resumeSessionId,
@@ -550,6 +654,7 @@ export class AcpAgent extends SessionAgent {
550
654
  // confirm window, not after it, and its exit is what confirms it.
551
655
  // An agent an eviction or a replacement ended earlier is waited for too.
552
656
  await Promise.all([super.release(sessionId), this.sessions.release(sessionId)]);
657
+ this.host?.release(sessionId);
553
658
  }
554
659
 
555
660
  /** After a host resume, each session's next turn starts its agent again, on its conversation. */
@@ -560,5 +665,6 @@ export class AcpAgent extends SessionAgent {
560
665
  override async terminateAll(): Promise<void> {
561
666
  await super.terminateAll();
562
667
  await this.sessions.closeAll();
668
+ await this.host?.close();
563
669
  }
564
670
  }
@@ -71,7 +71,11 @@ export function toToolResultContent(
71
71
  });
72
72
  }
73
73
 
74
- /** Engine MCP config map → ACP `McpServer[]` (names come from the record keys). */
74
+ /**
75
+ * Engine MCP config map → ACP `McpServer[]` (names come from the record keys).
76
+ * ACP's fields only: a strict agent may refuse one it does not know, and ACP
77
+ * v1 has none for `required` or a tool-call limit (`timeoutMs`).
78
+ */
75
79
  export function toAcpMcpServers(
76
80
  mcpServers: Record<string, McpServerConfig> | undefined,
77
81
  ): McpServer[] {
@@ -27,6 +27,8 @@ export interface TurnScope {
27
27
  elicitation?: ElicitationRequestHandler;
28
28
  mode?: PermissionMode;
29
29
  signal: AbortSignal;
30
+ /** The engine's id of the turn, for a host tool's caller. */
31
+ turnId?: string;
30
32
  }
31
33
 
32
34
  /** The session a request is answered against: its ACP id and the turn running on it. */
@@ -58,6 +58,8 @@ export type PermissionRequestHandler = (
58
58
  * comes from them; the decision says which was picked.
59
59
  */
60
60
  options?: PermissionOption[];
61
+ /** A plan's approval says so (`permission.requested`'s `purpose`); anything else is a tool's. */
62
+ purpose?: "plan";
61
63
  /**
62
64
  * How an "always" answer works for this request. `{ rule }`: the harness
63
65
  * keeps it itself, scoped as `rule` says (Claude's own session rule,
@@ -51,7 +51,8 @@ export function startQuery<Q>(permissionMode: string | undefined, start: () => Q
51
51
  /**
52
52
  * The SDK approval callback, fixed at spawn: it asks the turn running when it
53
53
  * is called, which Claude does for a call its mode and rules do not approve
54
- * by themselves (under `bypass_permissions`, only questions and plans). The
54
+ * by themselves (under `bypass_permissions`, questions, plans and, since
55
+ * Claude Code 2.1.326, the few calls it holds back as dangerous). The
55
56
  * host `toolPolicy` sees each such call first (full native PermissionResult
56
57
  * power), questions and plans included; a call it leaves
57
58
  * (`undefined`) goes to the turn: a question to its elicitation, a plan or a
@@ -100,7 +101,7 @@ export function createCanUseTool(deps: {
100
101
  */
101
102
  const ask = async (
102
103
  title: string | undefined,
103
- opts: { options?: PermissionOption[]; always?: { rule: string } | null },
104
+ opts: { options?: PermissionOption[]; always?: { rule: string } | null; purpose?: "plan" },
104
105
  ): Promise<PermissionDecision | undefined> => {
105
106
  if (!turn.permissions) return undefined;
106
107
  // @ref LLP 0002#a-tool-call-says-what-it-acts-on — why Claude asks is `reason`, in the CLI's words
@@ -118,7 +119,7 @@ export function createCanUseTool(deps: {
118
119
  return decision;
119
120
  };
120
121
  if (toolName === "ExitPlanMode") {
121
- return planVerdict(await ask(PLAN_TITLE, { options: PLAN_OPTIONS }), input);
122
+ return planVerdict(await ask(PLAN_TITLE, { options: PLAN_OPTIONS, purpose: "plan" }), input);
122
123
  }
123
124
  // @ref LLP 0001#d4--permission-requests-are-first-class-protocol — "always" is Claude's own rule
124
125
  // "Always" is the rule Claude suggests (`Bash(npm test *)`, accept-edits
@@ -16,6 +16,7 @@ import { onAbort, untilAborted } from "../../utils/deadline.ts";
16
16
  import { SessionResumeError } from "../../utils/errors.ts";
17
17
  import { UnsupportedAttachmentError, attachedText, isTextMedia } from "../attachments.ts";
18
18
  import type { AgentExecuteOptions, ListModelsOptions } from "../base.ts";
19
+ import { type HostToolSessions, hostToolSessions, refuseHostName } from "../host-tools.ts";
19
20
  import { SessionAgent } from "../session-agent.ts";
20
21
  import { ClaudeCredentials, type ClaudeDelivery, ON_PLACEHOLDER } from "./credentials.ts";
21
22
  import type { ClaudeRawEvent } from "./events.ts";
@@ -125,12 +126,14 @@ export class ClaudeCodeAgent extends SessionAgent {
125
126
  private readonly pool: ClaudeSessionPool;
126
127
  private readonly credentials?: ClaudeCredentials;
127
128
  private readonly cancelGraceMs: number;
129
+ private readonly host?: HostToolSessions;
128
130
 
129
131
  constructor(private readonly agentOptions: ClaudeCodeAgentOptions = {}) {
130
132
  super({ cancelConfirmMs: agentOptions.cancelConfirmMs });
131
133
  this.cancelGraceMs = agentOptions.cancelGraceMs ?? CANCEL_GRACE_MS;
132
134
  this.processes = agentOptions.processes ?? sharedNativeProcesses();
133
- this.pool = claudeSessionPool({ ...agentOptions, processes: this.processes });
135
+ this.host = hostToolSessions(agentOptions.hostTools, this.harness);
136
+ this.pool = claudeSessionPool({ ...agentOptions, processes: this.processes, host: this.host });
134
137
  this.login = new ClaudeCliLogin({
135
138
  resolveCliPath: agentOptions.resolveCliPath,
136
139
  processes: this.processes,
@@ -176,6 +179,11 @@ export class ClaudeCodeAgent extends SessionAgent {
176
179
  const cliPath = resolveCliPath && (await untilAborted(resolveCliPath(), controller.signal));
177
180
  const content = toClaudeContent(input);
178
181
  controller.signal.throwIfAborted();
182
+ const source = await untilAborted(
183
+ Promise.resolve(this.host?.source(options.sessionId, options.cwd)),
184
+ controller.signal,
185
+ );
186
+ if (source) refuseHostName(options.mcpServers, source.name);
179
187
  const thinking = fitClaudeThinking(options.thinkingLevel, options.modelThinking);
180
188
  const turnOptions = this.withDelivery(
181
189
  options,
@@ -196,7 +204,8 @@ export class ClaudeCodeAgent extends SessionAgent {
196
204
  if (thinking.applied && !session.operatorThinking)
197
205
  options.onExecution?.({ thinkingLevel: thinking.applied });
198
206
  const notApplied: Array<keyof RunConfig> = [];
199
- // A model known to have no effort levels is sent no level (`fitClaudeThinking`).
207
+ // A model known to have no effort levels, or whose levels hold no fit for
208
+ // the turn's, is sent no level (`fitClaudeThinking`).
200
209
  if (options.thinkingLevel !== undefined && thinking.send === undefined)
201
210
  notApplied.push("thinkingLevel");
202
211
  // A message to resume at goes only with a resume (`buildClaudeOptions`).
@@ -221,6 +230,7 @@ export class ClaudeCodeAgent extends SessionAgent {
221
230
  if (!attemptedResume && session.currentSessionId) report(session.currentSessionId);
222
231
  const turn = session.sendMessage(content, {
223
232
  turnId: options.turnId,
233
+ signal: controller.signal,
224
234
  permissions: options.onPermissionRequest,
225
235
  elicitation: options.onElicitationRequest,
226
236
  });
@@ -369,6 +379,7 @@ export class ClaudeCodeAgent extends SessionAgent {
369
379
  await super.release(sessionId);
370
380
  await this.pool.release(sessionId);
371
381
  this.credentials?.release(sessionId);
382
+ this.host?.release(sessionId);
372
383
  }
373
384
 
374
385
  override async terminateAll(): Promise<void> {
@@ -377,5 +388,6 @@ export class ClaudeCodeAgent extends SessionAgent {
377
388
  await super.terminateAll();
378
389
  await closed;
379
390
  await this.credentials?.close();
391
+ await this.host?.close();
380
392
  }
381
393
  }
@@ -2,6 +2,7 @@ import type { McpSetServersResult, Query } from "@anthropic-ai/claude-agent-sdk"
2
2
  import type { McpServerConfig } from "../../../protocol/index.ts";
3
3
  import { configFingerprint } from "../config-fingerprint.ts";
4
4
  import {
5
+ type NativeMcpServer,
5
6
  UnavailableMcpServers,
6
7
  mcpConnectionErrors,
7
8
  nativeMcpServer,
@@ -13,6 +14,15 @@ import type { SdkMcpServers } from "./options.ts";
13
14
  /** What an MCP update asks of the live query. */
14
15
  type McpControl = Pick<Query, "setMcpServers" | "mcpServerStatus">;
15
16
 
17
+ /**
18
+ * A turn's server as Claude takes it: its tool-call limit is the SDK's
19
+ * per-server `timeout`, in milliseconds as on the wire.
20
+ */
21
+ export function claudeMcpServer(server: McpServerConfig): NativeMcpServer & { timeout?: number } {
22
+ const native = nativeMcpServer(server);
23
+ return server.timeoutMs === undefined ? native : { ...native, timeout: server.timeoutMs };
24
+ }
25
+
16
26
  function remoteMcpServer(server: McpServerConfig): boolean {
17
27
  return server.type === "http" || server.type === "sse";
18
28
  }
@@ -145,7 +155,7 @@ export class ClaudeMcpConnections {
145
155
  const retry = new Set(this.unavailable.retryNow(servers));
146
156
  const resetNames = Object.keys(servers).filter((name) => failed.has(name) || retry.has(name));
147
157
  const native = Object.fromEntries(
148
- Object.entries(servers).map(([name, server]) => [name, nativeMcpServer(server)]),
158
+ Object.entries(servers).map(([name, server]) => [name, claudeMcpServer(server)]),
149
159
  );
150
160
  const desired = { ...native, ...this.host };
151
161
  const added = new Set<string>();