@temporalio/strands-agents 1.24.0 → 2.0.0-rc.1

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 (52) hide show
  1. package/LICENSE +6 -6
  2. package/README.md +112 -15
  3. package/lib/empty-module.d.ts +1 -1
  4. package/lib/empty-module.js +6 -1
  5. package/lib/empty-module.js.map +1 -1
  6. package/lib/index.d.ts +2 -2
  7. package/lib/index.js +21 -11
  8. package/lib/index.js.map +1 -1
  9. package/lib/load-polyfills.js +15 -0
  10. package/lib/load-polyfills.js.map +1 -1
  11. package/lib/model-activity.d.ts +57 -2
  12. package/lib/model-activity.js +100 -6
  13. package/lib/model-activity.js.map +1 -1
  14. package/lib/plugin.d.ts +33 -12
  15. package/lib/plugin.js +127 -26
  16. package/lib/plugin.js.map +1 -1
  17. package/lib/strands-errors.d.ts +39 -0
  18. package/lib/strands-errors.js +130 -0
  19. package/lib/strands-errors.js.map +1 -0
  20. package/lib/temporal-activity-tool.d.ts +18 -10
  21. package/lib/temporal-activity-tool.js +50 -29
  22. package/lib/temporal-activity-tool.js.map +1 -1
  23. package/lib/temporal-agent.d.ts +38 -4
  24. package/lib/temporal-agent.js +68 -16
  25. package/lib/temporal-agent.js.map +1 -1
  26. package/lib/temporal-mcp-client.d.ts +113 -17
  27. package/lib/temporal-mcp-client.js +376 -102
  28. package/lib/temporal-mcp-client.js.map +1 -1
  29. package/lib/temporal-mcp-tool.d.ts +3 -1
  30. package/lib/temporal-mcp-tool.js +26 -16
  31. package/lib/temporal-mcp-tool.js.map +1 -1
  32. package/lib/temporal-model.d.ts +32 -0
  33. package/lib/temporal-model.js +108 -24
  34. package/lib/temporal-model.js.map +1 -1
  35. package/lib/workflow.js +17 -7
  36. package/lib/workflow.js.map +1 -1
  37. package/package.json +46 -22
  38. package/src/empty-module.ts +5 -0
  39. package/src/index.ts +3 -1
  40. package/src/load-polyfills.ts +20 -1
  41. package/src/model-activity.ts +153 -8
  42. package/src/plugin.ts +159 -31
  43. package/src/strands-errors.ts +147 -0
  44. package/src/temporal-activity-tool.ts +43 -32
  45. package/src/temporal-agent.ts +77 -19
  46. package/src/temporal-mcp-client.ts +407 -91
  47. package/src/temporal-mcp-tool.ts +9 -9
  48. package/src/temporal-model.ts +111 -18
  49. package/lib/failure-converter.d.ts +0 -14
  50. package/lib/failure-converter.js +0 -61
  51. package/lib/failure-converter.js.map +0 -1
  52. package/src/failure-converter.ts +0 -77
@@ -15,21 +15,32 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.MCP_CONNECTION_IDLE_MS = exports.TemporalMCPClient = void 0;
36
+ exports.McpConnections = exports.MCP_CONNECTION_IDLE_MS = exports.TemporalMCPClient = void 0;
27
37
  exports.listToolsActivityName = listToolsActivityName;
28
38
  exports.callToolActivityName = callToolActivityName;
29
39
  exports.buildListToolsActivity = buildListToolsActivity;
30
- exports._evictConnection = _evictConnection;
40
+ exports.describeValue = describeValue;
31
41
  exports.buildCallToolActivity = buildCallToolActivity;
32
42
  const sdk_1 = require("@strands-agents/sdk");
43
+ const common_1 = require("@temporalio/common");
33
44
  const workflow = __importStar(require("@temporalio/workflow"));
34
45
  const activity_1 = require("@temporalio/activity");
35
46
  const STUB_TRANSPORT = {
@@ -48,8 +59,9 @@ const STUB_TRANSPORT = {
48
59
  *
49
60
  * The transport factory and tool discovery live worker-side via
50
61
  * `StrandsPlugin({ mcpClients: { server: () => new McpClient(...) } })`.
51
- * This handle only carries the server name (which selects the registered
52
- * factory) and the per-call activity options.
62
+ * This handle carries the server name (which selects the registered
63
+ * factory), the tool `prefix` and `toolFilters`, and the per-call activity
64
+ * options.
53
65
  *
54
66
  * Extends {@link McpClient} so it can be passed directly in an
55
67
  * {@link AgentConfig.tools | Agent.tools} array (Strands' `flattenTools`
@@ -61,13 +73,23 @@ const STUB_TRANSPORT = {
61
73
  class TemporalMCPClient extends sdk_1.McpClient {
62
74
  server;
63
75
  activityOptions;
76
+ prefix;
77
+ toolFilters;
64
78
  /** Whether the agent lists this server's tools once or re-lists each turn. */
65
79
  cacheTools;
80
+ // The names this client's tools hold in each agent's registry: the names of the tools Strands
81
+ // added there, then the names of each refresh. While the server lists a name, the name is this
82
+ // client's, whatever tool workflow code puts under it.
83
+ held = new WeakMap();
84
+ // The tools this client listed, to find its names in a registry it has no record for.
85
+ listed = new WeakSet();
66
86
  constructor(options) {
67
87
  super({ transport: STUB_TRANSPORT });
68
88
  this.server = options.server;
69
89
  this.activityOptions = options.activityOptions ?? {};
70
90
  this.cacheTools = options.cacheTools ?? false;
91
+ this.prefix = options.prefix;
92
+ this.toolFilters = options.toolFilters;
71
93
  }
72
94
  async connect() {
73
95
  // No-op; all I/O happens inside the per-server callTool activity.
@@ -89,29 +111,189 @@ class TemporalMCPClient extends sdk_1.McpClient {
89
111
  ...this.activityOptions,
90
112
  });
91
113
  const infos = await activities[listToolsActivityName(this.server)]({ server: this.server });
92
- return infos.map((info) => new TemporalMCPTool(this.server, info, this.activityOptions));
114
+ const tools = infos
115
+ .map((info) => new TemporalMCPTool(this.server, info, this.activityOptions, this.prefix))
116
+ .filter((tool) => included(tool, this.toolFilters));
117
+ for (const tool of tools)
118
+ this.listed.add(tool);
119
+ return tools;
93
120
  }
94
121
  /**
95
122
  * Re-list this server's tools and reconcile them into the agent's tool
96
- * registry, dropping tools that no longer exist and adding new ones.
97
- * {@link TemporalAgent} calls this on each agent turn when `cacheTools` is
98
- * `false` so a mid-workflow MCP-server restart is reflected in the next call.
123
+ * registry, dropping tools that no longer exist and adding new ones, so a
124
+ * mid-workflow MCP-server restart is reflected in the next call.
125
+ * {@link TemporalAgent} instead re-lists each of its `cacheTools: false`
126
+ * clients in its own hook after each tool round, and checks and applies
127
+ * their listings together, so a name can move between its servers.
128
+ *
129
+ * A listed name that another tool of the agent has, that differs from one
130
+ * only by `-` or `_`, that the listing has twice, or that Strands rejects
131
+ * throws Strands' `ToolValidationError` and leaves the registry as it was.
99
132
  */
100
133
  async refreshTools(registry) {
134
+ const tools = (await this.listTools());
135
+ TemporalMCPClient.apply(registry, [{ client: this, tools }]);
136
+ }
137
+ /**
138
+ * One `AfterToolsEvent` hook per client in `clients`, the `cacheTools: false` clients of one agent
139
+ * in `tools` order, to register in that order. Strands runs them last to first. Each lists its
140
+ * server as {@link refreshTools} does, so the `listTools` activities keep the order and timing
141
+ * they had with one `refreshTools()` hook per client, unless a re-listing is refused: then every
142
+ * server has listed before the refusal. The last client's hook starts the tool round, and the
143
+ * first client's checks the round's listings together and applies them. So a name can move from
144
+ * one server to another between tool rounds, and a name that two of the new listings share is
145
+ * refused.
146
+ *
147
+ * @internal
148
+ */
149
+ static refreshHooks(clients) {
150
+ const round = [];
151
+ return clients.map((client, i) => (event) => client.listInRound(event.agent.toolRegistry, round, i === clients.length - 1, i === 0));
152
+ }
153
+ // List this server into `round`, which `start` empties first, and apply the round at its `end`.
154
+ async listInRound(registry, round, start, end) {
155
+ if (start)
156
+ round.length = 0;
157
+ const tools = (await this.listTools());
158
+ round.unshift({ client: this, tools });
159
+ if (end)
160
+ TemporalMCPClient.apply(registry, round);
161
+ }
162
+ /**
163
+ * Make each of `clients` hold the name of each tool it listed that Strands adds to `registry`,
164
+ * the agent's registry, when Strands adds it. Strands adds a listing tool by tool and stops at a
165
+ * refused one, and a listing of an initialization that failed can add its tools after the agent
166
+ * initialized again, so only the tools that are added count, whenever they are.
167
+ *
168
+ * @internal
169
+ */
170
+ static holdAdded(clients, registry) {
171
+ const add = registry.add.bind(registry);
172
+ registry.add = (tool) => {
173
+ try {
174
+ add(tool);
175
+ }
176
+ finally {
177
+ const present = new Set(registry.list());
178
+ for (const added of [tool].flat()) {
179
+ const client = clients.find((c) => c.listed.has(added));
180
+ if (client === undefined || !present.has(added))
181
+ continue;
182
+ const names = client.held.get(registry) ?? new Set();
183
+ client.held.set(registry, names.add(added.name));
184
+ }
185
+ }
186
+ };
187
+ }
188
+ // The names this client's tools hold in `registry`.
189
+ heldIn(registry) {
190
+ return this.held.get(registry) ?? new Set(registry.list().flatMap((t) => (this.listed.has(t) ? [t.name] : [])));
191
+ }
192
+ // Check `listings` against each other, the agent's other tools and Strands' name rules, then apply
193
+ // them: drop the names each client held and no longer lists, and add or replace the listed tools.
194
+ // A refusal throws Strands' `ToolValidationError` and changes nothing.
195
+ static apply(registry, listings) {
101
196
  // Imported lazily to avoid a circular module cycle with TemporalMCPTool.
102
197
  // eslint-disable-next-line @typescript-eslint/no-require-imports
103
198
  const { TemporalMCPTool } = require('./temporal-mcp-tool');
104
- const fresh = await this.listTools();
105
- const freshNames = new Set(fresh.map((t) => t.name));
199
+ const held = new Map(listings.map(({ client }) => [client, client.heldIn(registry)]));
200
+ const freed = new Set([...held.values()].flatMap((names) => [...names]));
201
+ const taken = new Map();
106
202
  for (const tool of registry.list()) {
107
- if (tool instanceof TemporalMCPTool && tool.server === this.server && !freshNames.has(tool.name)) {
108
- registry.remove(tool.name);
203
+ if (!freed.has(tool.name))
204
+ taken.set(normalized(tool.name), tool);
205
+ }
206
+ const seen = new Map();
207
+ for (const { client, tools } of listings) {
208
+ const own = new Map();
209
+ for (const tool of tools) {
210
+ const { name } = tool;
211
+ const rejected = rejection(name);
212
+ if (rejected !== undefined) {
213
+ throw new sdk_1.ToolValidationError(`${rejected}. MCP server ${listedAs(tool)} lists '${name}'. Drop it with the toolFilters of the ` +
214
+ `server's TemporalMCPClient.`);
215
+ }
216
+ const first = own.get(normalized(name));
217
+ if (first !== undefined) {
218
+ const both = first.name === name ? 'it twice' : 'both names';
219
+ throw duplicateToolName(name, first.name, `MCP server '${client.server}' lists ${both}.`);
220
+ }
221
+ own.set(normalized(name), tool);
222
+ const earlier = seen.get(normalized(name));
223
+ if (earlier !== undefined)
224
+ throw duplicateToolName(name, earlier.name, clash(earlier, tool));
225
+ const other = taken.get(normalized(name));
226
+ if (other !== undefined) {
227
+ const source = other instanceof TemporalMCPTool && !client.listed.has(other)
228
+ ? clash(other, tool)
229
+ : `MCP server ${listedAs(tool)} lists it, and another tool of the agent has it. Set a prefix (or a ` +
230
+ `different one) on the server's TemporalMCPClient, or drop '${tool.serverToolName}' with its toolFilters.`;
231
+ throw duplicateToolName(name, other.name, source);
232
+ }
233
+ }
234
+ for (const [key, tool] of own)
235
+ seen.set(key, tool);
236
+ }
237
+ for (const { client, tools } of listings) {
238
+ const names = new Set(tools.map((t) => t.name));
239
+ for (const name of held.get(client)) {
240
+ if (!names.has(name))
241
+ registry.remove(name);
109
242
  }
110
243
  }
111
- registry.addOrReplace(fresh);
244
+ for (const { client, tools } of listings) {
245
+ registry.addOrReplace(tools);
246
+ client.held.set(registry, new Set(tools.map((t) => t.name)));
247
+ }
112
248
  }
113
249
  }
114
250
  exports.TemporalMCPClient = TemporalMCPClient;
251
+ // Strands' McpClient filter rule: whether `filters` let the agent have `tool`.
252
+ function included(tool, filters) {
253
+ if (!filters)
254
+ return true;
255
+ if (filters.allowed !== undefined && !filters.allowed.some((m) => matches(tool, m)))
256
+ return false;
257
+ return !(filters.rejected !== undefined && filters.rejected.some((m) => matches(tool, m)));
258
+ }
259
+ function matches(tool, matcher) {
260
+ if (typeof matcher === 'function')
261
+ return matcher(tool);
262
+ if (typeof matcher === 'string')
263
+ return matcher === tool.serverToolName;
264
+ // The sticky flag anchors the match at the start of the name, as Strands does.
265
+ const anchored = new RegExp(matcher.source, matcher.flags.includes('y') ? matcher.flags : `${matcher.flags}y`);
266
+ return anchored.test(tool.serverToolName);
267
+ }
268
+ // Strands' words when its ToolRegistry rejects a tool name, or undefined when it accepts it.
269
+ function rejection(name) {
270
+ if (name.length < 1 || name.length > 64)
271
+ return 'Tool name must be between 1 and 64 characters';
272
+ if (!/^[a-zA-Z0-9_-]+$/.test(name))
273
+ return 'Tool name must contain only alphanumeric characters, hyphens, and underscores';
274
+ return undefined;
275
+ }
276
+ // Strands' ToolRegistry refuses a name that differs from a registered one only by '-' or '_'.
277
+ function normalized(name) {
278
+ return name.replaceAll('-', '_');
279
+ }
280
+ // The server that lists `tool`, with the server's own name for it when a prefix renames it.
281
+ function listedAs(tool) {
282
+ return tool.serverToolName === tool.name ? `'${tool.server}'` : `'${tool.server}' (as '${tool.serverToolName}')`;
283
+ }
284
+ // Where two clashing MCP tools of two clients come from: `held` is the agent's, and `tool` the new one.
285
+ function clash(held, tool) {
286
+ return held.server === tool.server
287
+ ? `The agent has two TemporalMCPClient handles for MCP server '${tool.server}'. Give one a different ` +
288
+ `prefix, narrow one's toolFilters, or pass only one.`
289
+ : `MCP servers ${listedAs(held)} and ${listedAs(tool)} both list it. Set a prefix (or a different one) on ` +
290
+ `one server's TemporalMCPClient, or drop the tool from one with its toolFilters.`;
291
+ }
292
+ // Strands' words when its ToolRegistry refuses a name, then where the two tools come from.
293
+ function duplicateToolName(name, other, source) {
294
+ const refused = other === name ? `Tool with name '${name}' already registered.` : `Tool name '${name}' already exists as '${other}'.`;
295
+ return new sdk_1.ToolValidationError(`${refused} ${source}`);
296
+ }
115
297
  function listToolsActivityName(server) {
116
298
  return `${server}-listTools`;
117
299
  }
@@ -120,16 +302,17 @@ function callToolActivityName(server) {
120
302
  }
121
303
  /**
122
304
  * Builds the per-server `{server}-listTools` activity. Enumerates the server's
123
- * tools live over the shared worker-process connection on every call, so the
124
- * agent sees the server's current tools even if it is redeployed mid-workflow.
125
- * Runs whenever a workflow calls {@link TemporalMCPClient.listTools}.
305
+ * tools live over the plugin's connection on every call, so the agent sees the
306
+ * server's current tools even if it is redeployed mid-workflow. Runs whenever a
307
+ * workflow calls {@link TemporalMCPClient.listTools}.
126
308
  */
127
- function buildListToolsActivity(server, factory, idleMs = exports.MCP_CONNECTION_IDLE_MS) {
309
+ function buildListToolsActivity(server, factory, connections) {
128
310
  const name = listToolsActivityName(server);
129
311
  const fn = async (_input) => {
130
- const record = acquireConnection(server, factory);
312
+ const record = connections.acquire(server, factory);
131
313
  try {
132
314
  const client = await record.client;
315
+ refuseFactoryPrefix(server, client);
133
316
  const tools = await client.listTools();
134
317
  return tools.map((t) => ({
135
318
  name: t.name,
@@ -138,42 +321,48 @@ function buildListToolsActivity(server, factory, idleMs = exports.MCP_CONNECTION
138
321
  }));
139
322
  }
140
323
  catch (err) {
141
- // The session may be broken (e.g. the server was redeployed); drop it so
142
- // the next call reconnects to the current deployment.
143
- await _evictConnection(server);
324
+ // The session may be broken (e.g. the server was redeployed); stop handing
325
+ // it out so the next call reconnects to the current deployment. It is
326
+ // closed once the calls still using it have finished.
327
+ connections.retire(server, record);
144
328
  throw err;
145
329
  }
146
330
  finally {
147
- // No more in-flight call on this connection; let idle eviction resume
148
- // (no-op if the connection was just evicted above).
149
- releaseConnection(server, record, idleMs);
331
+ // Closes the connection if it was retired and this was the last in-flight
332
+ // call; otherwise lets idle eviction resume.
333
+ connections.release(server, record);
150
334
  }
151
335
  };
152
336
  Object.defineProperty(fn, 'name', { value: name });
153
337
  return fn;
154
338
  }
339
+ // A prefix on the factory's McpClient renames the tools the agent sees, and the callTool activity
340
+ // then asks the server for those names. Refuse it, retryably, so a run waits for a fixed worker.
341
+ function refuseFactoryPrefix(server, client) {
342
+ // Strands' McpClient keeps the option in a private field.
343
+ const prefix = client._prefix;
344
+ if (prefix) {
345
+ throw new Error(`The McpClient that the StrandsPlugin mcpClients factory returns for MCP server '${server}' sets ` +
346
+ `prefix '${prefix}'. Set it on the workflow-side TemporalMCPClient instead: ` +
347
+ `new TemporalMCPClient({ server: '${server}', prefix: '${prefix}' }).`);
348
+ }
349
+ }
155
350
  /**
156
351
  * Default for how long an *idle* MCP connection is kept open before it's
157
352
  * disconnected. The window only starts once no {@link callToolActivityName |
158
353
  * callTool} or {@link listToolsActivityName | listTools} activity is using the
159
354
  * connection, so a call that runs longer than this is never cut off. Override
160
- * per worker via `StrandsPlugin({ mcpConnectionIdleTimeout })`.
355
+ * per plugin via `StrandsPlugin({ mcpConnectionIdleTimeout })`.
161
356
  */
162
357
  exports.MCP_CONNECTION_IDLE_MS = 5 * 60 * 1000;
163
- // Worker-process cache, keyed by server name. Activities run in the worker's
164
- // Node process, so this module state is shared across every activity invocation on the worker.
165
- const CONNECTIONS = new Map();
166
- async function _evictConnection(server) {
167
- const record = CONNECTIONS.get(server);
168
- if (record === undefined)
169
- return;
170
- // Delete before awaiting: a call arriving during `disconnect` must open a
171
- // fresh connection rather than join the one being torn down.
172
- CONNECTIONS.delete(server);
358
+ function clearIdleTimer(record) {
173
359
  if (record.idleTimer !== undefined) {
174
360
  clearTimeout(record.idleTimer);
175
361
  record.idleTimer = undefined;
176
362
  }
363
+ }
364
+ /** Disconnect a record that is no longer handed out. Best-effort. */
365
+ async function closeRecord(record) {
177
366
  try {
178
367
  const client = await record.client;
179
368
  await client.disconnect();
@@ -182,73 +371,157 @@ async function _evictConnection(server) {
182
371
  // Best-effort; the session may already be broken.
183
372
  }
184
373
  }
374
+ // Names a value for an error message: `undefined`, `null`, `number`, or an object's class, such as `Client`.
375
+ function describeValue(value) {
376
+ if (value === null)
377
+ return 'null';
378
+ if (typeof value !== 'object' && typeof value !== 'function')
379
+ return typeof value;
380
+ return value.constructor?.name || typeof value;
381
+ }
185
382
  /**
186
- * Return the cached connection for `server`, opening one lazily if needed, and
187
- * mark a call in flight so idle eviction can't disconnect underneath it.
188
- * Concurrent first-callers dedupe onto a single connect handshake by awaiting
189
- * the same record. Every caller must {@link releaseConnection} once its call
190
- * completes.
383
+ * The worker-process MCP connections of one {@link StrandsPlugin}, keyed by
384
+ * server name. Workers that share a plugin instance share its connections;
385
+ * another plugin instance opens its own through its own factories, even for
386
+ * the same server name. The plugin's `runContext` counts the Workers using
387
+ * them, and the last one to stop closes them. A connection that a call still
388
+ * uses is closed when that call finishes.
191
389
  */
192
- function acquireConnection(server, factory) {
193
- let record = CONNECTIONS.get(server);
194
- if (record === undefined) {
195
- const entry = {
196
- inflight: 0,
197
- client: (async () => {
198
- const client = factory();
199
- await client.connect();
200
- return client;
201
- })(),
202
- };
203
- // If the connect handshake fails, drop the rejected promise so the next
204
- // call retries instead of caching the failure forever.
205
- entry.client.catch(() => {
206
- if (CONNECTIONS.get(server) === entry)
207
- CONNECTIONS.delete(server);
208
- });
209
- CONNECTIONS.set(server, entry);
210
- record = entry;
390
+ class McpConnections {
391
+ idleMs;
392
+ records = new Map();
393
+ workers = 0;
394
+ /**
395
+ * @param idleMs how long an idle connection stays open; defaults to
396
+ * {@link MCP_CONNECTION_IDLE_MS}.
397
+ */
398
+ constructor(idleMs = exports.MCP_CONNECTION_IDLE_MS) {
399
+ this.idleMs = idleMs;
211
400
  }
212
- record.inflight += 1;
213
- if (record.idleTimer !== undefined) {
214
- clearTimeout(record.idleTimer);
215
- record.idleTimer = undefined;
401
+ /** Runs one Worker; once no Worker uses these connections, closes them. */
402
+ async use(next) {
403
+ this.workers += 1;
404
+ try {
405
+ await next();
406
+ }
407
+ finally {
408
+ this.workers -= 1;
409
+ if (this.workers === 0) {
410
+ await Promise.all([...this.records.keys()].map((server) => this.evict(server)));
411
+ }
412
+ }
413
+ }
414
+ /**
415
+ * Stop handing out `server`'s connection, and disconnect it now or when the
416
+ * last call still using it finishes.
417
+ */
418
+ async evict(server) {
419
+ const record = this.records.get(server);
420
+ if (record === undefined)
421
+ return;
422
+ // Delete before awaiting: a call arriving during `disconnect` must open a
423
+ // fresh connection rather than join the one being torn down.
424
+ this.records.delete(server);
425
+ clearIdleTimer(record);
426
+ if (record.inflight > 0) {
427
+ record.retired = true;
428
+ return;
429
+ }
430
+ await closeRecord(record);
431
+ }
432
+ /**
433
+ * Return the cached connection for `server`, opening one lazily if needed,
434
+ * and mark a call in flight so idle eviction can't disconnect underneath it.
435
+ * Concurrent first-callers dedupe onto a single connect handshake by awaiting
436
+ * the same record. Every caller must {@link release} once its call completes.
437
+ */
438
+ acquire(server, factory) {
439
+ let record = this.records.get(server);
440
+ if (record === undefined) {
441
+ const entry = {
442
+ inflight: 0,
443
+ retired: false,
444
+ client: (async () => {
445
+ const client = factory();
446
+ if (client == null ||
447
+ typeof client.connect !== 'function' ||
448
+ typeof client.disconnect !== 'function' ||
449
+ typeof client.listTools !== 'function' ||
450
+ typeof client.callTool !== 'function') {
451
+ throw common_1.ApplicationFailure.nonRetryable(`MCP client factory '${server}' returned ${describeValue(client)}, not a client with ` +
452
+ 'connect(), disconnect(), listTools() and callTool() methods.', 'MCPClientFactoryTypeError');
453
+ }
454
+ await client.connect();
455
+ return client;
456
+ })(),
457
+ };
458
+ // If the connect handshake fails, drop the rejected promise so the next
459
+ // call retries instead of caching the failure forever.
460
+ entry.client.catch(() => {
461
+ if (this.records.get(server) === entry)
462
+ this.records.delete(server);
463
+ });
464
+ this.records.set(server, entry);
465
+ record = entry;
466
+ }
467
+ record.inflight += 1;
468
+ clearIdleTimer(record);
469
+ return record;
470
+ }
471
+ /**
472
+ * Flag `record` as suspect after a failed call. It is unpublished at once so
473
+ * new calls open a fresh connection, but not disconnected until the calls
474
+ * still using it have released it (see {@link release}).
475
+ */
476
+ retire(server, record) {
477
+ // Already evicted or replaced; whoever did that is closing it.
478
+ if (this.records.get(server) !== record)
479
+ return;
480
+ record.retired = true;
481
+ this.records.delete(server);
482
+ clearIdleTimer(record);
483
+ }
484
+ /**
485
+ * Mark a call done. Once no calls remain in flight, disconnect a retired
486
+ * connection or arm idle eviction for a healthy one.
487
+ */
488
+ release(server, record) {
489
+ record.inflight -= 1;
490
+ if (record.retired) {
491
+ if (record.inflight === 0)
492
+ void closeRecord(record);
493
+ return;
494
+ }
495
+ // Only the record still cached under this server arms a timer; a record
496
+ // already evicted must not schedule one, or it could later evict a
497
+ // different, healthy connection for the same server.
498
+ if (record.inflight > 0 || this.records.get(server) !== record)
499
+ return;
500
+ const timer = setTimeout(() => {
501
+ // `acquire` clears this timer synchronously, so a pending timer implies
502
+ // the connection is still idle; re-checked to keep that invariant local.
503
+ if (record.inflight === 0)
504
+ void this.evict(server);
505
+ }, this.idleMs);
506
+ // Don't let an idle MCP connection keep the worker process alive.
507
+ timer.unref?.();
508
+ record.idleTimer = timer;
216
509
  }
217
- return record;
218
- }
219
- /** Mark a call done; arm idle eviction once no calls remain in flight. */
220
- function releaseConnection(server, record, idleMs) {
221
- record.inflight -= 1;
222
- // Only the record still cached under this server arms a timer; a record
223
- // already evicted must not schedule one, or it could later evict a
224
- // different, healthy connection for the same server.
225
- if (record.inflight > 0 || CONNECTIONS.get(server) !== record)
226
- return;
227
- const timer = setTimeout(() => {
228
- // `acquireConnection` clears this timer synchronously, so a pending timer
229
- // implies the connection is still idle; re-checked to keep that invariant
230
- // local.
231
- if (record.inflight === 0)
232
- void _evictConnection(server);
233
- }, idleMs);
234
- // Don't let an idle MCP connection keep the worker process alive.
235
- timer.unref?.();
236
- record.idleTimer = timer;
237
510
  }
511
+ exports.McpConnections = McpConnections;
238
512
  /**
239
- * Builds the per-server `{server}-callTool` activity. Reuses a worker-process
240
- * MCP session opened lazily through the user-supplied factory — successive
241
- * calls share one connection rather than reconnecting per call. Idle
242
- * connections are disconnected after `idleMs` (defaults to
243
- * {@link MCP_CONNECTION_IDLE_MS}).
513
+ * Builds the per-server `{server}-callTool` activity. Reuses the plugin's MCP
514
+ * session, opened lazily through the user-supplied factory — successive calls
515
+ * share one connection rather than reconnecting per call. Idle connections are
516
+ * disconnected after the plugin's idle timeout.
244
517
  */
245
- function buildCallToolActivity(server, factory, idleMs = exports.MCP_CONNECTION_IDLE_MS) {
518
+ function buildCallToolActivity(server, factory, connections) {
246
519
  const name = callToolActivityName(server);
247
520
  const fn = async (input) => {
248
521
  activity_1.Context.current().log.debug(`Calling MCP tool ${input.toolName} on server ${server}`, {
249
522
  activityId: (0, activity_1.activityInfo)().activityId,
250
523
  });
251
- const record = acquireConnection(server, factory);
524
+ const record = connections.acquire(server, factory);
252
525
  // Dispatch by name without re-listing tools on the connection: the agent
253
526
  // already has the schema from `listTools`, and `McpClient.callTool` only
254
527
  // reads `tool.name` to build the request. A minimal `{ name }` matches the
@@ -259,14 +532,15 @@ function buildCallToolActivity(server, factory, idleMs = exports.MCP_CONNECTION_
259
532
  return await client.callTool(tool, input.args);
260
533
  }
261
534
  catch (err) {
262
- // The session may be broken; drop it so the next call reconnects.
263
- await _evictConnection(server);
535
+ // The session may be broken; stop handing it out so the next call
536
+ // reconnects. It is closed once the calls still using it have finished.
537
+ connections.retire(server, record);
264
538
  throw err;
265
539
  }
266
540
  finally {
267
- // No more in-flight call on this connection; let idle eviction resume
268
- // (no-op if the connection was just evicted above).
269
- releaseConnection(server, record, idleMs);
541
+ // Closes the connection if it was retired and this was the last in-flight
542
+ // call; otherwise lets idle eviction resume.
543
+ connections.release(server, record);
270
544
  }
271
545
  };
272
546
  Object.defineProperty(fn, 'name', { value: name });
@@ -1 +1 @@
1
- {"version":3,"file":"temporal-mcp-client.js","sourceRoot":"","sources":["../src/temporal-mcp-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA8IA,sDAEC;AAED,oDAEC;AAQD,wDA6BC;AAyBD,4CAgBC;AA6DD,sDA+BC;AA9TD,6CAAgD;AAGhD,+DAAiD;AAEjD,mD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