import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';

// src/core/client/http-client-transport.ts
var HTTPClientTransport = class extends StreamableHTTPClientTransport {
  constructor(url, opts) {
    super(url, opts);
  }
  send(message, options) {
    const mockAction = getMockActionFor(message);
    if (mockAction?.type === "emit") {
      this.onmessage?.(mockAction.message);
      return Promise.resolve();
    }
    if (mockAction?.type === "suppress") {
      return Promise.resolve();
    }
    return super.send(message, options);
  }
};
function getMockActionFor(message) {
  const m = message;
  if (!m || typeof m !== "object" || !("method" in m)) return null;
  switch (m.method) {
    case "initialize": {
      const protocolVersion = m?.params?.protocolVersion;
      if (!protocolVersion) return null;
      return {
        type: "emit",
        message: {
          result: {
            protocolVersion,
            capabilities: { tools: {} },
            serverInfo: { name: "deco-chat-server", version: "1.0.0" }
          },
          jsonrpc: m.jsonrpc ?? "2.0",
          // @ts-expect-error - id is not typed
          id: m.id
        }
      };
    }
    case "notifications/roots/list_changed":
    case "notifications/initialized":
    case "notifications/cancelled":
    case "notifications/progress": {
      return { type: "suppress" };
    }
    default:
      return null;
  }
}

export { HTTPClientTransport };
//# sourceMappingURL=client.js.map
//# sourceMappingURL=client.js.map