{"version":3,"sources":["../../src/tools/smithery.ts"],"names":["SmitheryToolOutput","JSONToolOutput","SmitheryTool","Tool","name","description","emitter","client","tool","options","Emitter","root","child","namespace","creator","inputSchema","_run","input","_options","run","result","callTool","arguments","undefined","signal","fromClient","tools","paginate","size","Infinity","handler","cursor","nextCursor","listTools","data","map"],"mappings":";;;;;;;;AAwCO,MAAMA,2BAA2BC,uBAAAA,CAAAA;EAxCxC;;;AAwC6D;AAEtD,MAAMC,qBAAqBC,aAAAA,CAAAA;EA1ClC;;;AA2CkBC,EAAAA,IAAAA;AACAC,EAAAA,WAAAA;AACAC,EAAAA,OAAAA;AAEAC,EAAAA,MAAAA;AACCC,EAAAA,IAAAA;AAEjB,EAAA,WAAA,CAAmB,EAAED,MAAAA,EAAQC,IAAM,EAAA,GAAGC,SAA8B,EAAA;AAClE,IAAA,KAAA,CAAMA,OAAAA,CAAAA;AACN,IAAA,IAAA,CAAKF,MAASA,GAAAA,MAAAA;AACd,IAAA,IAAA,CAAKC,IAAOA,GAAAA,IAAAA;AACZ,IAAA,IAAA,CAAKJ,OAAOI,IAAKJ,CAAAA,IAAAA;AACjB,IAAKC,IAAAA,CAAAA,WAAAA,GACHG,KAAKH,WACL,IAAA,sEAAA;AACF,IAAKC,IAAAA,CAAAA,OAAAA,GAAUI,mBAAQC,CAAAA,IAAAA,CAAKC,KAAM,CAAA;MAChCC,SAAW,EAAA;AAAC,QAAA,MAAA;AAAQ,QAAA,UAAA;QAAY,IAAKT,CAAAA;;MACrCU,OAAS,EAAA;KACX,CAAA;AACF;EAEOC,WAA4B,GAAA;AAEjC,IAAA,OAAO,KAAKP,IAAKO,CAAAA,WAAAA;AACnB;EAEA,MAAgBC,IAAAA,CACdC,KACAC,EAAAA,QAAAA,EACAC,GAC6B,EAAA;AAE7B,IAAA,MAAMC,MAAS,GAAA,MAAM,IAAKb,CAAAA,MAAAA,CAAOc,QAC/B,CAAA;AAAEjB,MAAAA,IAAAA,EAAM,IAAKA,CAAAA,IAAAA;MAAMkB,SAAWL,EAAAA;AAAM,KAAA,EACpCM,MACA,EAAA;AAAEC,MAAAA,MAAAA,EAAQL,GAAIK,CAAAA;KAAO,CAAA;AAEvB,IAAO,OAAA,IAAIxB,mBAAmBoB,MAAAA,CAAAA;AAChC;;;;;;AAOA,EAAA,aAAoBK,WAAWlB,MAAsC,EAAA;AAInE,IAAMmB,MAAAA,KAAAA,GAAQ,MAAMC,qBAAS,CAAA;MAC3BC,IAAMC,EAAAA,QAAAA;MACNC,OAAS,kBAAA,MAAA,CAAA,OAAO,EAAEC,MAAAA,EAA6B,KAAA;AAC7C,QAAA,MAAM,EAAEL,KAAAA,EAAAA,MAAAA,EAAOM,YAAe,GAAA,MAAMzB,OAAO0B,SAAU,CAAA;AAAEF,UAAAA;SAAO,CAAA;AAC9D,QAAO,OAAA;UAAEG,IAAMR,EAAAA,MAAAA;AAAOM,UAAAA;AAAW,SAAA;OAF1B,EAAA,SAAA;KAIX,CAAA;AACA,IAAA,OAAON,KAAMS,CAAAA,GAAAA,CAAI,CAAC3B,IAAAA,KAAc,IAAIN,YAAa,CAAA;AAAEK,MAAAA,MAAAA;AAAQC,MAAAA;AAAK,KAAA,CAAA,CAAA;AAClE;AACF","file":"smithery.cjs","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Import only non-MCP utilities statically.\nimport {\n  BaseToolRunOptions,\n  ToolEmitter,\n  ToolInput,\n  JSONToolOutput,\n  Tool,\n} from \"@/tools/base.js\";\nimport { Emitter } from \"@/emitter/emitter.js\";\nimport { GetRunContext } from \"@/context.js\";\nimport { SchemaObject } from \"ajv\";\nimport { paginate } from \"@/internals/helpers/paginate.js\";\n\n/**\n * NOTE:\n * We no longer statically import any Model Context Protocol modules.\n * Instead, the MCP client and tool types are passed in dynamically.\n */\n\nexport interface SmitheryToolInput {\n  client: any; // dynamically imported MCP client\n  tool: any; // dynamically imported tool definition from MCP\n}\n\nexport class SmitheryToolOutput extends JSONToolOutput<any> {}\n\nexport class SmitheryTool extends Tool<SmitheryToolOutput> {\n  public readonly name: string;\n  public readonly description: string;\n  public readonly emitter: ToolEmitter<ToolInput<this>, SmitheryToolOutput>;\n\n  public readonly client: any;\n  private readonly tool: any;\n\n  public constructor({ client, tool, ...options }: SmitheryToolInput) {\n    super(options);\n    this.client = client;\n    this.tool = tool;\n    this.name = tool.name;\n    this.description =\n      tool.description ??\n      \"No available description, use the tool based on its name and schema.\";\n    this.emitter = Emitter.root.child({\n      namespace: [\"tool\", \"smithery\", this.name],\n      creator: this,\n    });\n  }\n\n  public inputSchema(): SchemaObject {\n    // Use the tool's defined input schema.\n    return this.tool.inputSchema as SchemaObject;\n  }\n\n  protected async _run(\n    input: ToolInput<this>,\n    _options: BaseToolRunOptions,\n    run: GetRunContext<typeof this>\n  ): Promise<SmitheryToolOutput> {\n    // Call the tool via the MCP client.\n    const result = await this.client.callTool(\n      { name: this.name, arguments: input },\n      undefined,\n      { signal: run.signal }\n    );\n    return new SmitheryToolOutput(result);\n  }\n\n  /**\n   * Load all available tools from the provided MCP client.\n   *\n   * Uses the paginate helper to retrieve all pages of tools.\n   */\n  public static async fromClient(client: any): Promise<SmitheryTool[]> {\n    // Optionally, if you want to load the paginate helper dynamically,\n    // you can do the following:\n    // const { paginate } = await import('@/internals/helpers/paginate.js');\n    const tools = await paginate({\n      size: Infinity,\n      handler: async ({ cursor }: { cursor?: string }) => {\n        const { tools, nextCursor } = await client.listTools({ cursor });\n        return { data: tools, nextCursor } as const;\n      },\n    });\n    return tools.map((tool: any) => new SmitheryTool({ client, tool }));\n  }\n}\n"]}