@agentconnect.md/daemon 1.0.0-rc.220 → 1.0.0-rc.222

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 (30) hide show
  1. package/dist/{acp-host-CeJJZbtg.js → acp-host-DE2r7uCO.js} +191 -16
  2. package/dist/acp-host-DE2r7uCO.js.map +1 -0
  3. package/dist/{agent-list-CoYaBcDx.js → agent-list-BwgY3Xqv.js} +2 -2
  4. package/dist/{agent-list-CoYaBcDx.js.map → agent-list-BwgY3Xqv.js.map} +1 -1
  5. package/dist/bridge-DXIVgEzf.js +726 -0
  6. package/dist/bridge-DXIVgEzf.js.map +1 -0
  7. package/dist/{chat-Bcpnzw3h.js → chat--hmAp3lB.js} +4 -3
  8. package/dist/chat--hmAp3lB.js.map +1 -0
  9. package/dist/index.js +5 -5
  10. package/dist/{load-agents-nWFFmN5-.js → load-agents-hq5NXMmx.js} +34 -6
  11. package/dist/load-agents-hq5NXMmx.js.map +1 -0
  12. package/dist/{login-B99oQNXR.js → login-EVa3UJRh.js} +4 -4
  13. package/dist/{login-B99oQNXR.js.map → login-EVa3UJRh.js.map} +1 -1
  14. package/dist/{run-foreground-DLxz75b4.js → run-foreground-B05rDr1z.js} +4101 -211
  15. package/dist/run-foreground-B05rDr1z.js.map +1 -0
  16. package/dist/run-foreground-Bcg0RA3e.js +2 -0
  17. package/dist/{schemas-DujcoO0q.js → schemas-CQkO9hC5.js} +27 -2
  18. package/dist/schemas-CQkO9hC5.js.map +1 -0
  19. package/dist/{bridge-DoUrmBw9.js → stdio-CwrB9yrX.js} +41 -727
  20. package/dist/stdio-CwrB9yrX.js.map +1 -0
  21. package/package.json +1 -1
  22. package/dist/acp-host-CeJJZbtg.js.map +0 -1
  23. package/dist/bridge-DoUrmBw9.js.map +0 -1
  24. package/dist/chat-Bcpnzw3h.js.map +0 -1
  25. package/dist/ipc-2Xbxe7uu.js +0 -35
  26. package/dist/ipc-2Xbxe7uu.js.map +0 -1
  27. package/dist/load-agents-nWFFmN5-.js.map +0 -1
  28. package/dist/run-foreground-DLxz75b4.js.map +0 -1
  29. package/dist/run-foreground-PidBMaVD.js +0 -2
  30. package/dist/schemas-DujcoO0q.js.map +0 -1
@@ -1,9 +1,37 @@
1
1
  import { o as __toESM, t as __commonJSMin } from "./rolldown-runtime-CE-6LUnI.js";
2
- import { t as DAEMON_VERSION } from "./version-DGaRXjBK.js";
3
- import { _ as union, a as custom, b as datetime, c as intersection, d as number, f as object, g as string, h as record, i as boolean, l as literal, m as preprocess, n as _null, o as discriminatedUnion, p as optional, r as array, t as _enum, u as looseObject, v as unknown, x as safeParse$1 } from "./schemas-DujcoO0q.js";
4
- import { n as encodeFrame, t as decodeFrames } from "./ipc-2Xbxe7uu.js";
5
- import process$1 from "node:process";
6
- import net from "node:net";
2
+ import { S as datetime, _ as record, a as array, b as unknown, c as discriminatedUnion, d as literal, f as looseObject, g as preprocess, h as optional, m as object, n as _enum, o as boolean, p as number, r as _null, s as custom, u as intersection, v as string, w as safeParse$1, y as union } from "./schemas-CQkO9hC5.js";
3
+ //#region src/mcp/ipc.ts
4
+ /** Frame a message for the wire: compact JSON + a single trailing newline. */
5
+ function encodeFrame(msg) {
6
+ return JSON.stringify(msg) + "\n";
7
+ }
8
+ /**
9
+ * Split a buffer of newline-delimited frames into parsed objects plus the
10
+ * trailing partial line. Callers keep `rest` and prepend it to the next chunk.
11
+ *
12
+ * Per-line tolerant: a malformed (non-JSON) line is skipped, not thrown — so one
13
+ * bad frame can't crash a stream reader or discard the good frames batched
14
+ * alongside it in the same chunk. `onError` lets callers log dropped lines.
15
+ */
16
+ function decodeFrames(buf, onError) {
17
+ const parts = buf.split("\n");
18
+ const rest = parts.pop() ?? "";
19
+ const messages = [];
20
+ for (const line of parts) {
21
+ const trimmed = line.trim();
22
+ if (!trimmed) continue;
23
+ try {
24
+ messages.push(JSON.parse(trimmed));
25
+ } catch (err) {
26
+ onError?.(trimmed, err);
27
+ }
28
+ }
29
+ return {
30
+ messages,
31
+ rest
32
+ };
33
+ }
34
+ //#endregion
7
35
  //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
8
36
  function isZ4Schema(s) {
9
37
  return !!s._zod;
@@ -528,6 +556,7 @@ const InitializedNotificationSchema = NotificationSchema.extend({
528
556
  method: literal("notifications/initialized"),
529
557
  params: NotificationsParamsSchema.optional()
530
558
  });
559
+ const isInitializedNotification = (value) => InitializedNotificationSchema.safeParse(value).success;
531
560
  /**
532
561
  * A ping, issued by either the server or the client, to check that the other party is still alive. The receiver must promptly respond, or else may be disconnected.
533
562
  */
@@ -1256,7 +1285,11 @@ const ToolListChangedNotificationSchema = NotificationSchema.extend({
1256
1285
  method: literal("notifications/tools/list_changed"),
1257
1286
  params: NotificationsParamsSchema.optional()
1258
1287
  });
1259
- object({
1288
+ /**
1289
+ * Base schema for list changed subscription options (without callback).
1290
+ * Used internally for Zod validation of autoRefresh and debounceMs.
1291
+ */
1292
+ const ListChangedOptionsBaseSchema = object({
1260
1293
  /**
1261
1294
  * If true, the list will be refreshed automatically when a list changed notification is received.
1262
1295
  * The callback will be called with the updated list.
@@ -9102,226 +9135,6 @@ var AjvJsonSchemaValidator = class {
9102
9135
  }
9103
9136
  };
9104
9137
  //#endregion
9105
- //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
9106
- /**
9107
- * Experimental server task features for MCP SDK.
9108
- * WARNING: These APIs are experimental and may change without notice.
9109
- *
9110
- * @experimental
9111
- */
9112
- /**
9113
- * Experimental task features for low-level MCP servers.
9114
- *
9115
- * Access via `server.experimental.tasks`:
9116
- * ```typescript
9117
- * const stream = server.experimental.tasks.requestStream(request, schema, options);
9118
- * ```
9119
- *
9120
- * For high-level server usage with task-based tools, use `McpServer.experimental.tasks` instead.
9121
- *
9122
- * @experimental
9123
- */
9124
- var ExperimentalServerTasks = class {
9125
- constructor(_server) {
9126
- this._server = _server;
9127
- }
9128
- /**
9129
- * Sends a request and returns an AsyncGenerator that yields response messages.
9130
- * The generator is guaranteed to end with either a 'result' or 'error' message.
9131
- *
9132
- * This method provides streaming access to request processing, allowing you to
9133
- * observe intermediate task status updates for task-augmented requests.
9134
- *
9135
- * @param request - The request to send
9136
- * @param resultSchema - Zod schema for validating the result
9137
- * @param options - Optional request options (timeout, signal, task creation params, etc.)
9138
- * @returns AsyncGenerator that yields ResponseMessage objects
9139
- *
9140
- * @experimental
9141
- */
9142
- requestStream(request, resultSchema, options) {
9143
- return this._server.requestStream(request, resultSchema, options);
9144
- }
9145
- /**
9146
- * Sends a sampling request and returns an AsyncGenerator that yields response messages.
9147
- * The generator is guaranteed to end with either a 'result' or 'error' message.
9148
- *
9149
- * For task-augmented requests, yields 'taskCreated' and 'taskStatus' messages
9150
- * before the final result.
9151
- *
9152
- * @example
9153
- * ```typescript
9154
- * const stream = server.experimental.tasks.createMessageStream({
9155
- * messages: [{ role: 'user', content: { type: 'text', text: 'Hello' } }],
9156
- * maxTokens: 100
9157
- * }, {
9158
- * onprogress: (progress) => {
9159
- * // Handle streaming tokens via progress notifications
9160
- * console.log('Progress:', progress.message);
9161
- * }
9162
- * });
9163
- *
9164
- * for await (const message of stream) {
9165
- * switch (message.type) {
9166
- * case 'taskCreated':
9167
- * console.log('Task created:', message.task.taskId);
9168
- * break;
9169
- * case 'taskStatus':
9170
- * console.log('Task status:', message.task.status);
9171
- * break;
9172
- * case 'result':
9173
- * console.log('Final result:', message.result);
9174
- * break;
9175
- * case 'error':
9176
- * console.error('Error:', message.error);
9177
- * break;
9178
- * }
9179
- * }
9180
- * ```
9181
- *
9182
- * @param params - The sampling request parameters
9183
- * @param options - Optional request options (timeout, signal, task creation params, onprogress, etc.)
9184
- * @returns AsyncGenerator that yields ResponseMessage objects
9185
- *
9186
- * @experimental
9187
- */
9188
- createMessageStream(params, options) {
9189
- const clientCapabilities = this._server.getClientCapabilities();
9190
- if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) throw new Error("Client does not support sampling tools capability.");
9191
- if (params.messages.length > 0) {
9192
- const lastMessage = params.messages[params.messages.length - 1];
9193
- const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
9194
- const hasToolResults = lastContent.some((c) => c.type === "tool_result");
9195
- const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : void 0;
9196
- const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
9197
- const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
9198
- if (hasToolResults) {
9199
- if (lastContent.some((c) => c.type !== "tool_result")) throw new Error("The last message must contain only tool_result content if any is present");
9200
- if (!hasPreviousToolUse) throw new Error("tool_result blocks are not matching any tool_use from the previous message");
9201
- }
9202
- if (hasPreviousToolUse) {
9203
- const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
9204
- const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
9205
- if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
9206
- }
9207
- }
9208
- return this.requestStream({
9209
- method: "sampling/createMessage",
9210
- params
9211
- }, CreateMessageResultSchema, options);
9212
- }
9213
- /**
9214
- * Sends an elicitation request and returns an AsyncGenerator that yields response messages.
9215
- * The generator is guaranteed to end with either a 'result' or 'error' message.
9216
- *
9217
- * For task-augmented requests (especially URL-based elicitation), yields 'taskCreated'
9218
- * and 'taskStatus' messages before the final result.
9219
- *
9220
- * @example
9221
- * ```typescript
9222
- * const stream = server.experimental.tasks.elicitInputStream({
9223
- * mode: 'url',
9224
- * message: 'Please authenticate',
9225
- * elicitationId: 'auth-123',
9226
- * url: 'https://example.com/auth'
9227
- * }, {
9228
- * task: { ttl: 300000 } // Task-augmented for long-running auth flow
9229
- * });
9230
- *
9231
- * for await (const message of stream) {
9232
- * switch (message.type) {
9233
- * case 'taskCreated':
9234
- * console.log('Task created:', message.task.taskId);
9235
- * break;
9236
- * case 'taskStatus':
9237
- * console.log('Task status:', message.task.status);
9238
- * break;
9239
- * case 'result':
9240
- * console.log('User action:', message.result.action);
9241
- * break;
9242
- * case 'error':
9243
- * console.error('Error:', message.error);
9244
- * break;
9245
- * }
9246
- * }
9247
- * ```
9248
- *
9249
- * @param params - The elicitation request parameters
9250
- * @param options - Optional request options (timeout, signal, task creation params, etc.)
9251
- * @returns AsyncGenerator that yields ResponseMessage objects
9252
- *
9253
- * @experimental
9254
- */
9255
- elicitInputStream(params, options) {
9256
- const clientCapabilities = this._server.getClientCapabilities();
9257
- const mode = params.mode ?? "form";
9258
- switch (mode) {
9259
- case "url":
9260
- if (!clientCapabilities?.elicitation?.url) throw new Error("Client does not support url elicitation.");
9261
- break;
9262
- case "form":
9263
- if (!clientCapabilities?.elicitation?.form) throw new Error("Client does not support form elicitation.");
9264
- break;
9265
- }
9266
- const normalizedParams = mode === "form" && params.mode === void 0 ? {
9267
- ...params,
9268
- mode: "form"
9269
- } : params;
9270
- return this.requestStream({
9271
- method: "elicitation/create",
9272
- params: normalizedParams
9273
- }, ElicitResultSchema, options);
9274
- }
9275
- /**
9276
- * Gets the current status of a task.
9277
- *
9278
- * @param taskId - The task identifier
9279
- * @param options - Optional request options
9280
- * @returns The task status
9281
- *
9282
- * @experimental
9283
- */
9284
- async getTask(taskId, options) {
9285
- return this._server.getTask({ taskId }, options);
9286
- }
9287
- /**
9288
- * Retrieves the result of a completed task.
9289
- *
9290
- * @param taskId - The task identifier
9291
- * @param resultSchema - Zod schema for validating the result
9292
- * @param options - Optional request options
9293
- * @returns The task result
9294
- *
9295
- * @experimental
9296
- */
9297
- async getTaskResult(taskId, resultSchema, options) {
9298
- return this._server.getTaskResult({ taskId }, resultSchema, options);
9299
- }
9300
- /**
9301
- * Lists tasks with optional pagination.
9302
- *
9303
- * @param cursor - Optional pagination cursor
9304
- * @param options - Optional request options
9305
- * @returns List of tasks with optional next cursor
9306
- *
9307
- * @experimental
9308
- */
9309
- async listTasks(cursor, options) {
9310
- return this._server.listTasks(cursor ? { cursor } : void 0, options);
9311
- }
9312
- /**
9313
- * Cancels a running task.
9314
- *
9315
- * @param taskId - The task identifier
9316
- * @param options - Optional request options
9317
- *
9318
- * @experimental
9319
- */
9320
- async cancelTask(taskId, options) {
9321
- return this._server.cancelTask({ taskId }, options);
9322
- }
9323
- };
9324
- //#endregion
9325
9138
  //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
9326
9139
  /**
9327
9140
  * Experimental task capability assertion helpers.
@@ -9373,347 +9186,6 @@ function assertClientRequestTaskCapability(requests, method, entityName) {
9373
9186
  }
9374
9187
  }
9375
9188
  //#endregion
9376
- //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
9377
- /**
9378
- * An MCP server on top of a pluggable transport.
9379
- *
9380
- * This server will automatically respond to the initialization flow as initiated from the client.
9381
- *
9382
- * To use with custom types, extend the base Request/Notification/Result types and pass them as type parameters:
9383
- *
9384
- * ```typescript
9385
- * // Custom schemas
9386
- * const CustomRequestSchema = RequestSchema.extend({...})
9387
- * const CustomNotificationSchema = NotificationSchema.extend({...})
9388
- * const CustomResultSchema = ResultSchema.extend({...})
9389
- *
9390
- * // Type aliases
9391
- * type CustomRequest = z.infer<typeof CustomRequestSchema>
9392
- * type CustomNotification = z.infer<typeof CustomNotificationSchema>
9393
- * type CustomResult = z.infer<typeof CustomResultSchema>
9394
- *
9395
- * // Create typed server
9396
- * const server = new Server<CustomRequest, CustomNotification, CustomResult>({
9397
- * name: "CustomServer",
9398
- * version: "1.0.0"
9399
- * })
9400
- * ```
9401
- * @deprecated Use `McpServer` instead for the high-level API. Only use `Server` for advanced use cases.
9402
- */
9403
- var Server = class extends Protocol {
9404
- /**
9405
- * Initializes this server with the given name and version information.
9406
- */
9407
- constructor(_serverInfo, options) {
9408
- super(options);
9409
- this._serverInfo = _serverInfo;
9410
- this._loggingLevels = /* @__PURE__ */ new Map();
9411
- this.LOG_LEVEL_SEVERITY = new Map(LoggingLevelSchema.options.map((level, index) => [level, index]));
9412
- this.isMessageIgnored = (level, sessionId) => {
9413
- const currentLevel = this._loggingLevels.get(sessionId);
9414
- return currentLevel ? this.LOG_LEVEL_SEVERITY.get(level) < this.LOG_LEVEL_SEVERITY.get(currentLevel) : false;
9415
- };
9416
- this._capabilities = options?.capabilities ?? {};
9417
- this._instructions = options?.instructions;
9418
- this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new AjvJsonSchemaValidator();
9419
- this.setRequestHandler(InitializeRequestSchema, (request) => this._oninitialize(request));
9420
- this.setNotificationHandler(InitializedNotificationSchema, () => this.oninitialized?.());
9421
- if (this._capabilities.logging) this.setRequestHandler(SetLevelRequestSchema, async (request, extra) => {
9422
- const transportSessionId = extra.sessionId || extra.requestInfo?.headers["mcp-session-id"] || void 0;
9423
- const { level } = request.params;
9424
- const parseResult = LoggingLevelSchema.safeParse(level);
9425
- if (parseResult.success) this._loggingLevels.set(transportSessionId, parseResult.data);
9426
- return {};
9427
- });
9428
- }
9429
- /**
9430
- * Access experimental features.
9431
- *
9432
- * WARNING: These APIs are experimental and may change without notice.
9433
- *
9434
- * @experimental
9435
- */
9436
- get experimental() {
9437
- if (!this._experimental) this._experimental = { tasks: new ExperimentalServerTasks(this) };
9438
- return this._experimental;
9439
- }
9440
- /**
9441
- * Registers new capabilities. This can only be called before connecting to a transport.
9442
- *
9443
- * The new capabilities will be merged with any existing capabilities previously given (e.g., at initialization).
9444
- */
9445
- registerCapabilities(capabilities) {
9446
- if (this.transport) throw new Error("Cannot register capabilities after connecting to transport");
9447
- this._capabilities = mergeCapabilities(this._capabilities, capabilities);
9448
- }
9449
- /**
9450
- * Override request handler registration to enforce server-side validation for tools/call.
9451
- */
9452
- setRequestHandler(requestSchema, handler) {
9453
- const methodSchema = getObjectShape(requestSchema)?.method;
9454
- if (!methodSchema) throw new Error("Schema is missing a method literal");
9455
- let methodValue;
9456
- if (isZ4Schema(methodSchema)) {
9457
- const v4Schema = methodSchema;
9458
- methodValue = (v4Schema._zod?.def)?.value ?? v4Schema.value;
9459
- } else {
9460
- const v3Schema = methodSchema;
9461
- methodValue = v3Schema._def?.value ?? v3Schema.value;
9462
- }
9463
- if (typeof methodValue !== "string") throw new Error("Schema method literal must be a string");
9464
- if (methodValue === "tools/call") {
9465
- const wrappedHandler = async (request, extra) => {
9466
- const validatedRequest = safeParse(CallToolRequestSchema, request);
9467
- if (!validatedRequest.success) {
9468
- const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
9469
- throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call request: ${errorMessage}`);
9470
- }
9471
- const { params } = validatedRequest.data;
9472
- const result = await Promise.resolve(handler(request, extra));
9473
- if (params.task) {
9474
- const taskValidationResult = safeParse(CreateTaskResultSchema, result);
9475
- if (!taskValidationResult.success) {
9476
- const errorMessage = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
9477
- throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
9478
- }
9479
- return taskValidationResult.data;
9480
- }
9481
- const validationResult = safeParse(CallToolResultSchema, result);
9482
- if (!validationResult.success) {
9483
- const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
9484
- throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call result: ${errorMessage}`);
9485
- }
9486
- return validationResult.data;
9487
- };
9488
- return super.setRequestHandler(requestSchema, wrappedHandler);
9489
- }
9490
- return super.setRequestHandler(requestSchema, handler);
9491
- }
9492
- assertCapabilityForMethod(method) {
9493
- switch (method) {
9494
- case "sampling/createMessage":
9495
- if (!this._clientCapabilities?.sampling) throw new Error(`Client does not support sampling (required for ${method})`);
9496
- break;
9497
- case "elicitation/create":
9498
- if (!this._clientCapabilities?.elicitation) throw new Error(`Client does not support elicitation (required for ${method})`);
9499
- break;
9500
- case "roots/list":
9501
- if (!this._clientCapabilities?.roots) throw new Error(`Client does not support listing roots (required for ${method})`);
9502
- break;
9503
- case "ping": break;
9504
- }
9505
- }
9506
- assertNotificationCapability(method) {
9507
- switch (method) {
9508
- case "notifications/message":
9509
- if (!this._capabilities.logging) throw new Error(`Server does not support logging (required for ${method})`);
9510
- break;
9511
- case "notifications/resources/updated":
9512
- case "notifications/resources/list_changed":
9513
- if (!this._capabilities.resources) throw new Error(`Server does not support notifying about resources (required for ${method})`);
9514
- break;
9515
- case "notifications/tools/list_changed":
9516
- if (!this._capabilities.tools) throw new Error(`Server does not support notifying of tool list changes (required for ${method})`);
9517
- break;
9518
- case "notifications/prompts/list_changed":
9519
- if (!this._capabilities.prompts) throw new Error(`Server does not support notifying of prompt list changes (required for ${method})`);
9520
- break;
9521
- case "notifications/elicitation/complete":
9522
- if (!this._clientCapabilities?.elicitation?.url) throw new Error(`Client does not support URL elicitation (required for ${method})`);
9523
- break;
9524
- case "notifications/cancelled": break;
9525
- case "notifications/progress": break;
9526
- }
9527
- }
9528
- assertRequestHandlerCapability(method) {
9529
- if (!this._capabilities) return;
9530
- switch (method) {
9531
- case "completion/complete":
9532
- if (!this._capabilities.completions) throw new Error(`Server does not support completions (required for ${method})`);
9533
- break;
9534
- case "logging/setLevel":
9535
- if (!this._capabilities.logging) throw new Error(`Server does not support logging (required for ${method})`);
9536
- break;
9537
- case "prompts/get":
9538
- case "prompts/list":
9539
- if (!this._capabilities.prompts) throw new Error(`Server does not support prompts (required for ${method})`);
9540
- break;
9541
- case "resources/list":
9542
- case "resources/templates/list":
9543
- case "resources/read":
9544
- if (!this._capabilities.resources) throw new Error(`Server does not support resources (required for ${method})`);
9545
- break;
9546
- case "tools/call":
9547
- case "tools/list":
9548
- if (!this._capabilities.tools) throw new Error(`Server does not support tools (required for ${method})`);
9549
- break;
9550
- case "tasks/get":
9551
- case "tasks/list":
9552
- case "tasks/result":
9553
- case "tasks/cancel":
9554
- if (!this._capabilities.tasks) throw new Error(`Server does not support tasks capability (required for ${method})`);
9555
- break;
9556
- case "ping":
9557
- case "initialize": break;
9558
- }
9559
- }
9560
- assertTaskCapability(method) {
9561
- assertClientRequestTaskCapability(this._clientCapabilities?.tasks?.requests, method, "Client");
9562
- }
9563
- assertTaskHandlerCapability(method) {
9564
- if (!this._capabilities) return;
9565
- assertToolsCallTaskCapability(this._capabilities.tasks?.requests, method, "Server");
9566
- }
9567
- async _oninitialize(request) {
9568
- const requestedVersion = request.params.protocolVersion;
9569
- this._clientCapabilities = request.params.capabilities;
9570
- this._clientVersion = request.params.clientInfo;
9571
- return {
9572
- protocolVersion: SUPPORTED_PROTOCOL_VERSIONS.includes(requestedVersion) ? requestedVersion : LATEST_PROTOCOL_VERSION,
9573
- capabilities: this.getCapabilities(),
9574
- serverInfo: this._serverInfo,
9575
- ...this._instructions && { instructions: this._instructions }
9576
- };
9577
- }
9578
- /**
9579
- * After initialization has completed, this will be populated with the client's reported capabilities.
9580
- */
9581
- getClientCapabilities() {
9582
- return this._clientCapabilities;
9583
- }
9584
- /**
9585
- * After initialization has completed, this will be populated with information about the client's name and version.
9586
- */
9587
- getClientVersion() {
9588
- return this._clientVersion;
9589
- }
9590
- getCapabilities() {
9591
- return this._capabilities;
9592
- }
9593
- async ping() {
9594
- return this.request({ method: "ping" }, EmptyResultSchema);
9595
- }
9596
- async createMessage(params, options) {
9597
- if (params.tools || params.toolChoice) {
9598
- if (!this._clientCapabilities?.sampling?.tools) throw new Error("Client does not support sampling tools capability.");
9599
- }
9600
- if (params.messages.length > 0) {
9601
- const lastMessage = params.messages[params.messages.length - 1];
9602
- const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
9603
- const hasToolResults = lastContent.some((c) => c.type === "tool_result");
9604
- const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : void 0;
9605
- const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
9606
- const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
9607
- if (hasToolResults) {
9608
- if (lastContent.some((c) => c.type !== "tool_result")) throw new Error("The last message must contain only tool_result content if any is present");
9609
- if (!hasPreviousToolUse) throw new Error("tool_result blocks are not matching any tool_use from the previous message");
9610
- }
9611
- if (hasPreviousToolUse) {
9612
- const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
9613
- const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
9614
- if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
9615
- }
9616
- }
9617
- if (params.tools) return this.request({
9618
- method: "sampling/createMessage",
9619
- params
9620
- }, CreateMessageResultWithToolsSchema, options);
9621
- return this.request({
9622
- method: "sampling/createMessage",
9623
- params
9624
- }, CreateMessageResultSchema, options);
9625
- }
9626
- /**
9627
- * Creates an elicitation request for the given parameters.
9628
- * For backwards compatibility, `mode` may be omitted for form requests and will default to `'form'`.
9629
- * @param params The parameters for the elicitation request.
9630
- * @param options Optional request options.
9631
- * @returns The result of the elicitation request.
9632
- */
9633
- async elicitInput(params, options) {
9634
- switch (params.mode ?? "form") {
9635
- case "url": {
9636
- if (!this._clientCapabilities?.elicitation?.url) throw new Error("Client does not support url elicitation.");
9637
- const urlParams = params;
9638
- return this.request({
9639
- method: "elicitation/create",
9640
- params: urlParams
9641
- }, ElicitResultSchema, options);
9642
- }
9643
- case "form": {
9644
- if (!this._clientCapabilities?.elicitation?.form) throw new Error("Client does not support form elicitation.");
9645
- const formParams = params.mode === "form" ? params : {
9646
- ...params,
9647
- mode: "form"
9648
- };
9649
- const result = await this.request({
9650
- method: "elicitation/create",
9651
- params: formParams
9652
- }, ElicitResultSchema, options);
9653
- if (result.action === "accept" && result.content && formParams.requestedSchema) try {
9654
- const validationResult = this._jsonSchemaValidator.getValidator(formParams.requestedSchema)(result.content);
9655
- if (!validationResult.valid) throw new McpError(ErrorCode.InvalidParams, `Elicitation response content does not match requested schema: ${validationResult.errorMessage}`);
9656
- } catch (error) {
9657
- if (error instanceof McpError) throw error;
9658
- throw new McpError(ErrorCode.InternalError, `Error validating elicitation response: ${error instanceof Error ? error.message : String(error)}`);
9659
- }
9660
- return result;
9661
- }
9662
- }
9663
- }
9664
- /**
9665
- * Creates a reusable callback that, when invoked, will send a `notifications/elicitation/complete`
9666
- * notification for the specified elicitation ID.
9667
- *
9668
- * @param elicitationId The ID of the elicitation to mark as complete.
9669
- * @param options Optional notification options. Useful when the completion notification should be related to a prior request.
9670
- * @returns A function that emits the completion notification when awaited.
9671
- */
9672
- createElicitationCompletionNotifier(elicitationId, options) {
9673
- if (!this._clientCapabilities?.elicitation?.url) throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");
9674
- return () => this.notification({
9675
- method: "notifications/elicitation/complete",
9676
- params: { elicitationId }
9677
- }, options);
9678
- }
9679
- async listRoots(params, options) {
9680
- return this.request({
9681
- method: "roots/list",
9682
- params
9683
- }, ListRootsResultSchema, options);
9684
- }
9685
- /**
9686
- * Sends a logging message to the client, if connected.
9687
- * Note: You only need to send the parameters object, not the entire JSON RPC message
9688
- * @see LoggingMessageNotification
9689
- * @param params
9690
- * @param sessionId optional for stateless and backward compatibility
9691
- */
9692
- async sendLoggingMessage(params, sessionId) {
9693
- if (this._capabilities.logging) {
9694
- if (!this.isMessageIgnored(params.level, sessionId)) return this.notification({
9695
- method: "notifications/message",
9696
- params
9697
- });
9698
- }
9699
- }
9700
- async sendResourceUpdated(params) {
9701
- return this.notification({
9702
- method: "notifications/resources/updated",
9703
- params
9704
- });
9705
- }
9706
- async sendResourceListChanged() {
9707
- return this.notification({ method: "notifications/resources/list_changed" });
9708
- }
9709
- async sendToolListChanged() {
9710
- return this.notification({ method: "notifications/tools/list_changed" });
9711
- }
9712
- async sendPromptListChanged() {
9713
- return this.notification({ method: "notifications/prompts/list_changed" });
9714
- }
9715
- };
9716
- //#endregion
9717
9189
  //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
9718
9190
  /**
9719
9191
  * Buffers a continuous stdio stream into discrete JSON-RPC messages.
@@ -9741,164 +9213,6 @@ function serializeMessage(message) {
9741
9213
  return JSON.stringify(message) + "\n";
9742
9214
  }
9743
9215
  //#endregion
9744
- //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
9745
- /**
9746
- * Server transport for stdio: this communicates with an MCP client by reading from the current process' stdin and writing to stdout.
9747
- *
9748
- * This transport is only available in Node.js environments.
9749
- */
9750
- var StdioServerTransport = class {
9751
- constructor(_stdin = process$1.stdin, _stdout = process$1.stdout) {
9752
- this._stdin = _stdin;
9753
- this._stdout = _stdout;
9754
- this._readBuffer = new ReadBuffer();
9755
- this._started = false;
9756
- this._ondata = (chunk) => {
9757
- this._readBuffer.append(chunk);
9758
- this.processReadBuffer();
9759
- };
9760
- this._onerror = (error) => {
9761
- this.onerror?.(error);
9762
- };
9763
- }
9764
- /**
9765
- * Starts listening for messages on stdin.
9766
- */
9767
- async start() {
9768
- if (this._started) throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");
9769
- this._started = true;
9770
- this._stdin.on("data", this._ondata);
9771
- this._stdin.on("error", this._onerror);
9772
- }
9773
- processReadBuffer() {
9774
- while (true) try {
9775
- const message = this._readBuffer.readMessage();
9776
- if (message === null) break;
9777
- this.onmessage?.(message);
9778
- } catch (error) {
9779
- this.onerror?.(error);
9780
- }
9781
- }
9782
- async close() {
9783
- this._stdin.off("data", this._ondata);
9784
- this._stdin.off("error", this._onerror);
9785
- if (this._stdin.listenerCount("data") === 0) this._stdin.pause();
9786
- this._readBuffer.clear();
9787
- this.onclose?.();
9788
- }
9789
- send(message) {
9790
- return new Promise((resolve) => {
9791
- const json = serializeMessage(message);
9792
- if (this._stdout.write(json)) resolve();
9793
- else this._stdout.once("drain", resolve);
9794
- });
9795
- }
9796
- };
9797
- //#endregion
9798
- //#region src/mcp/bridge.ts
9799
- /**
9800
- * IPC client half of the bridge: a persistent UDS connection to the daemon's
9801
- * control server. Requests are correlated by an incrementing id; an `ok:false`
9802
- * response rejects with the daemon's error message.
9803
- */
9804
- var IpcClient = class {
9805
- token;
9806
- socket;
9807
- nextId = 1;
9808
- pending = /* @__PURE__ */ new Map();
9809
- buf = "";
9810
- ready;
9811
- constructor(endpoint, token) {
9812
- this.token = token;
9813
- this.socket = net.connect(endpoint);
9814
- this.socket.setEncoding("utf8");
9815
- this.ready = new Promise((resolve, reject) => {
9816
- this.socket.once("connect", resolve);
9817
- this.socket.once("error", reject);
9818
- });
9819
- this.socket.on("data", (chunk) => {
9820
- this.buf += chunk;
9821
- const { messages, rest } = decodeFrames(this.buf);
9822
- this.buf = rest;
9823
- for (const res of messages) {
9824
- const p = this.pending.get(res.id);
9825
- if (!p) continue;
9826
- this.pending.delete(res.id);
9827
- if (res.ok) p.resolve(res.result);
9828
- else p.reject(new Error(res.error ?? "tool call failed"));
9829
- }
9830
- });
9831
- this.socket.on("close", () => {
9832
- for (const p of this.pending.values()) p.reject(/* @__PURE__ */ new Error("daemon connection closed"));
9833
- this.pending.clear();
9834
- });
9835
- }
9836
- async request(call) {
9837
- await this.ready;
9838
- const id = this.nextId++;
9839
- return new Promise((resolve, reject) => {
9840
- this.pending.set(id, {
9841
- resolve,
9842
- reject
9843
- });
9844
- this.socket.write(encodeFrame({
9845
- id,
9846
- token: this.token,
9847
- ...call
9848
- }));
9849
- });
9850
- }
9851
- };
9852
- /**
9853
- * Entry point for `agentconnect mcp-bridge`: a stdio MCP server that relays
9854
- * `tools/list` and `tools/call` to the running daemon over its control socket.
9855
- * The agent harness spawns this per session; the daemon does the real work.
9856
- */
9857
- async function runBridge() {
9858
- const endpoint = process.env.AC_MCP_ENDPOINT;
9859
- const token = process.env.AC_MCP_TOKEN;
9860
- if (!endpoint || !token) {
9861
- process.stderr.write("mcp-bridge: AC_MCP_ENDPOINT and AC_MCP_TOKEN must be set\n");
9862
- process.exit(2);
9863
- }
9864
- const ipc = new IpcClient(endpoint, token);
9865
- let tools;
9866
- try {
9867
- tools = (await ipc.request({ op: "listTools" })).tools;
9868
- } catch (err) {
9869
- process.stderr.write(`mcp-bridge: could not reach daemon: ${err.message}\n`);
9870
- process.exit(1);
9871
- }
9872
- const server = new Server({
9873
- name: "agentconnect",
9874
- version: DAEMON_VERSION
9875
- }, { capabilities: { tools: {} } });
9876
- server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools }));
9877
- server.setRequestHandler(CallToolRequestSchema, async (req) => {
9878
- try {
9879
- const result = await ipc.request({
9880
- op: "callTool",
9881
- name: req.params.name,
9882
- args: req.params.arguments ?? {}
9883
- });
9884
- if (result && typeof result === "object" && Array.isArray(result.mcpContent)) return { content: result.mcpContent };
9885
- return { content: [{
9886
- type: "text",
9887
- text: typeof result === "string" ? result : JSON.stringify(result, null, 2)
9888
- }] };
9889
- } catch (err) {
9890
- return {
9891
- content: [{
9892
- type: "text",
9893
- text: err.message
9894
- }],
9895
- isError: true
9896
- };
9897
- }
9898
- });
9899
- await server.connect(new StdioServerTransport());
9900
- }
9901
- //#endregion
9902
- export { runBridge };
9216
+ export { ListToolsRequestSchema as A, isInitializedNotification as B, JSONRPCMessageSchema as C, ListResourceTemplatesResultSchema as D, ListPromptsResultSchema as E, ReadResourceResultSchema as F, safeParse as G, isJSONRPCResultResponse as H, ResourceListChangedNotificationSchema as I, decodeFrames as K, SUPPORTED_PROTOCOL_VERSIONS as L, LoggingLevelSchema as M, McpError as N, ListResourcesResultSchema as O, PromptListChangedNotificationSchema as P, SetLevelRequestSchema as R, InitializedNotificationSchema as S, ListChangedOptionsBaseSchema as T, getObjectShape as U, isJSONRPCRequest as V, isZ4Schema as W, EmptyResultSchema as _, AjvJsonSchemaValidator as a, InitializeRequestSchema as b, CallToolRequestSchema as c, CreateMessageRequestSchema as d, CreateMessageResultSchema as f, ElicitResultSchema as g, ElicitRequestSchema as h, assertToolsCallTaskCapability as i, ListToolsResultSchema as j, ListRootsResultSchema as k, CallToolResultSchema as l, CreateTaskResultSchema as m, serializeMessage as n, Protocol as o, CreateMessageResultWithToolsSchema as p, encodeFrame as q, assertClientRequestTaskCapability as r, mergeCapabilities as s, ReadBuffer as t, CompleteResultSchema as u, ErrorCode as v, LATEST_PROTOCOL_VERSION as w, InitializeResultSchema as x, GetPromptResultSchema as y, ToolListChangedNotificationSchema as z };
9903
9217
 
9904
- //# sourceMappingURL=bridge-DoUrmBw9.js.map
9218
+ //# sourceMappingURL=stdio-CwrB9yrX.js.map