ai 4.1.60 → 4.1.62
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.
- package/CHANGELOG.md +18 -0
 - package/dist/index.d.mts +153 -17
 - package/dist/index.d.ts +153 -17
 - package/dist/index.js +68 -239
 - package/dist/index.js.map +1 -1
 - package/dist/index.mjs +68 -246
 - package/dist/index.mjs.map +1 -1
 - package/package.json +10 -5
 - package/rsc/dist/index.d.ts +4 -0
 - package/rsc/dist/rsc-server.d.mts +4 -0
 - package/rsc/dist/rsc-server.mjs +2 -0
 - package/rsc/dist/rsc-server.mjs.map +1 -1
 
    
        package/dist/index.js
    CHANGED
    
    | 
         @@ -1399,6 +1399,7 @@ function convertPartToLanguageModelPart(part, downloadedAssets) { 
     | 
|
| 
       1399 
1399 
     | 
    
         
             
                  return {
         
     | 
| 
       1400 
1400 
     | 
    
         
             
                    type: "file",
         
     | 
| 
       1401 
1401 
     | 
    
         
             
                    data: normalizedData instanceof Uint8Array ? convertDataContentToBase64String(normalizedData) : normalizedData,
         
     | 
| 
      
 1402 
     | 
    
         
            +
                    filename: part.filename,
         
     | 
| 
       1402 
1403 
     | 
    
         
             
                    mimeType,
         
     | 
| 
       1403 
1404 
     | 
    
         
             
                    providerMetadata: (_d = part.providerOptions) != null ? _d : part.experimental_providerMetadata
         
     | 
| 
       1404 
1405 
     | 
    
         
             
                  };
         
     | 
| 
         @@ -1917,6 +1918,7 @@ var imagePartSchema = import_zod5.z.object({ 
     | 
|
| 
       1917 
1918 
     | 
    
         
             
            var filePartSchema = import_zod5.z.object({
         
     | 
| 
       1918 
1919 
     | 
    
         
             
              type: import_zod5.z.literal("file"),
         
     | 
| 
       1919 
1920 
     | 
    
         
             
              data: import_zod5.z.union([dataContentSchema, import_zod5.z.instanceof(URL)]),
         
     | 
| 
      
 1921 
     | 
    
         
            +
              filename: import_zod5.z.string().optional(),
         
     | 
| 
       1920 
1922 
     | 
    
         
             
              mimeType: import_zod5.z.string(),
         
     | 
| 
       1921 
1923 
     | 
    
         
             
              providerOptions: providerMetadataSchema.optional(),
         
     | 
| 
       1922 
1924 
     | 
    
         
             
              experimental_providerMetadata: providerMetadataSchema.optional()
         
     | 
| 
         @@ -6671,79 +6673,11 @@ function tool(tool2) { 
     | 
|
| 
       6671 
6673 
     | 
    
         
             
              return tool2;
         
     | 
| 
       6672 
6674 
     | 
    
         
             
            }
         
     | 
| 
       6673 
6675 
     | 
    
         | 
| 
       6674 
     | 
    
         
            -
            // core/tool/mcp/ 
     | 
| 
       6675 
     | 
    
         
            -
             
     | 
| 
       6676 
     | 
    
         
            -
             
     | 
| 
       6677 
     | 
    
         
            -
             
     | 
| 
       6678 
     | 
    
         
            -
             
     | 
| 
       6679 
     | 
    
         
            -
                throw new MCPClientError({
         
     | 
| 
       6680 
     | 
    
         
            -
                  message: "Attempted to use child_process module outside of Node.js environment"
         
     | 
| 
       6681 
     | 
    
         
            -
                });
         
     | 
| 
       6682 
     | 
    
         
            -
              }
         
     | 
| 
       6683 
     | 
    
         
            -
              let childProcess;
         
     | 
| 
       6684 
     | 
    
         
            -
              const nodePrefix = "node:";
         
     | 
| 
       6685 
     | 
    
         
            -
              try {
         
     | 
| 
       6686 
     | 
    
         
            -
                childProcess = await import(`${nodePrefix}child_process`);
         
     | 
| 
       6687 
     | 
    
         
            -
              } catch (error) {
         
     | 
| 
       6688 
     | 
    
         
            -
                try {
         
     | 
| 
       6689 
     | 
    
         
            -
                  childProcess = require(`${nodePrefix}child_process`);
         
     | 
| 
       6690 
     | 
    
         
            -
                } catch (innerError) {
         
     | 
| 
       6691 
     | 
    
         
            -
                  throw new MCPClientError({
         
     | 
| 
       6692 
     | 
    
         
            -
                    message: "Failed to load child_process module dynamically",
         
     | 
| 
       6693 
     | 
    
         
            -
                    cause: innerError
         
     | 
| 
       6694 
     | 
    
         
            -
                  });
         
     | 
| 
       6695 
     | 
    
         
            -
                }
         
     | 
| 
       6696 
     | 
    
         
            -
              }
         
     | 
| 
       6697 
     | 
    
         
            -
              const { spawn } = childProcess;
         
     | 
| 
       6698 
     | 
    
         
            -
              return spawn(config.command, (_a17 = config.args) != null ? _a17 : [], {
         
     | 
| 
       6699 
     | 
    
         
            -
                env: (_b = config.env) != null ? _b : getDefaultEnvironment(),
         
     | 
| 
       6700 
     | 
    
         
            -
                stdio: ["pipe", "pipe", (_c = config.stderr) != null ? _c : "inherit"],
         
     | 
| 
       6701 
     | 
    
         
            -
                shell: false,
         
     | 
| 
       6702 
     | 
    
         
            -
                signal,
         
     | 
| 
       6703 
     | 
    
         
            -
                windowsHide: globalThis.process.platform === "win32" && isElectron(),
         
     | 
| 
       6704 
     | 
    
         
            -
                cwd: config.cwd
         
     | 
| 
       6705 
     | 
    
         
            -
              });
         
     | 
| 
       6706 
     | 
    
         
            -
            }
         
     | 
| 
       6707 
     | 
    
         
            -
            function detectRuntime() {
         
     | 
| 
       6708 
     | 
    
         
            -
              var _a17, _b;
         
     | 
| 
       6709 
     | 
    
         
            -
              if (typeof window !== "undefined") {
         
     | 
| 
       6710 
     | 
    
         
            -
                return "browser";
         
     | 
| 
       6711 
     | 
    
         
            -
              }
         
     | 
| 
       6712 
     | 
    
         
            -
              if (((_b = (_a17 = globalThis.process) == null ? void 0 : _a17.release) == null ? void 0 : _b.name) === "node") {
         
     | 
| 
       6713 
     | 
    
         
            -
                return "node";
         
     | 
| 
       6714 
     | 
    
         
            -
              }
         
     | 
| 
       6715 
     | 
    
         
            -
              return null;
         
     | 
| 
       6716 
     | 
    
         
            -
            }
         
     | 
| 
       6717 
     | 
    
         
            -
            function getDefaultEnvironment() {
         
     | 
| 
       6718 
     | 
    
         
            -
              const DEFAULT_INHERITED_ENV_VARS = globalThis.process.platform === "win32" ? [
         
     | 
| 
       6719 
     | 
    
         
            -
                "APPDATA",
         
     | 
| 
       6720 
     | 
    
         
            -
                "HOMEDRIVE",
         
     | 
| 
       6721 
     | 
    
         
            -
                "HOMEPATH",
         
     | 
| 
       6722 
     | 
    
         
            -
                "LOCALAPPDATA",
         
     | 
| 
       6723 
     | 
    
         
            -
                "PATH",
         
     | 
| 
       6724 
     | 
    
         
            -
                "PROCESSOR_ARCHITECTURE",
         
     | 
| 
       6725 
     | 
    
         
            -
                "SYSTEMDRIVE",
         
     | 
| 
       6726 
     | 
    
         
            -
                "SYSTEMROOT",
         
     | 
| 
       6727 
     | 
    
         
            -
                "TEMP",
         
     | 
| 
       6728 
     | 
    
         
            -
                "USERNAME",
         
     | 
| 
       6729 
     | 
    
         
            -
                "USERPROFILE"
         
     | 
| 
       6730 
     | 
    
         
            -
              ] : ["HOME", "LOGNAME", "PATH", "SHELL", "TERM", "USER"];
         
     | 
| 
       6731 
     | 
    
         
            -
              const env = {};
         
     | 
| 
       6732 
     | 
    
         
            -
              for (const key of DEFAULT_INHERITED_ENV_VARS) {
         
     | 
| 
       6733 
     | 
    
         
            -
                const value = globalThis.process.env[key];
         
     | 
| 
       6734 
     | 
    
         
            -
                if (value === void 0) {
         
     | 
| 
       6735 
     | 
    
         
            -
                  continue;
         
     | 
| 
       6736 
     | 
    
         
            -
                }
         
     | 
| 
       6737 
     | 
    
         
            -
                if (value.startsWith("()")) {
         
     | 
| 
       6738 
     | 
    
         
            -
                  continue;
         
     | 
| 
       6739 
     | 
    
         
            -
                }
         
     | 
| 
       6740 
     | 
    
         
            -
                env[key] = value;
         
     | 
| 
       6741 
     | 
    
         
            -
              }
         
     | 
| 
       6742 
     | 
    
         
            -
              return env;
         
     | 
| 
       6743 
     | 
    
         
            -
            }
         
     | 
| 
       6744 
     | 
    
         
            -
            function isElectron() {
         
     | 
| 
       6745 
     | 
    
         
            -
              return "type" in globalThis.process;
         
     | 
| 
       6746 
     | 
    
         
            -
            }
         
     | 
| 
      
 6676 
     | 
    
         
            +
            // core/tool/mcp/mcp-sse-transport.ts
         
     | 
| 
      
 6677 
     | 
    
         
            +
            var import_stream = require("eventsource-parser/stream");
         
     | 
| 
      
 6678 
     | 
    
         
            +
             
     | 
| 
      
 6679 
     | 
    
         
            +
            // core/tool/mcp/json-rpc-message.ts
         
     | 
| 
      
 6680 
     | 
    
         
            +
            var import_zod9 = require("zod");
         
     | 
| 
       6747 
6681 
     | 
    
         | 
| 
       6748 
6682 
     | 
    
         
             
            // core/tool/mcp/types.ts
         
     | 
| 
       6749 
6683 
     | 
    
         
             
            var import_zod8 = require("zod");
         
     | 
| 
         @@ -6752,7 +6686,6 @@ var SUPPORTED_PROTOCOL_VERSIONS = [ 
     | 
|
| 
       6752 
6686 
     | 
    
         
             
              LATEST_PROTOCOL_VERSION,
         
     | 
| 
       6753 
6687 
     | 
    
         
             
              "2024-10-07"
         
     | 
| 
       6754 
6688 
     | 
    
         
             
            ];
         
     | 
| 
       6755 
     | 
    
         
            -
            var JSONRPC_VERSION = "2.0";
         
     | 
| 
       6756 
6689 
     | 
    
         
             
            var ClientOrServerImplementationSchema = import_zod8.z.object({
         
     | 
| 
       6757 
6690 
     | 
    
         
             
              name: import_zod8.z.string(),
         
     | 
| 
       6758 
6691 
     | 
    
         
             
              version: import_zod8.z.string()
         
     | 
| 
         @@ -6760,43 +6693,11 @@ var ClientOrServerImplementationSchema = import_zod8.z.object({ 
     | 
|
| 
       6760 
6693 
     | 
    
         
             
            var BaseParamsSchema = import_zod8.z.object({
         
     | 
| 
       6761 
6694 
     | 
    
         
             
              _meta: import_zod8.z.optional(import_zod8.z.object({}).passthrough())
         
     | 
| 
       6762 
6695 
     | 
    
         
             
            }).passthrough();
         
     | 
| 
       6763 
     | 
    
         
            -
            var RequestSchema = import_zod8.z.object({
         
     | 
| 
       6764 
     | 
    
         
            -
              method: import_zod8.z.string(),
         
     | 
| 
       6765 
     | 
    
         
            -
              params: import_zod8.z.optional(BaseParamsSchema)
         
     | 
| 
       6766 
     | 
    
         
            -
            });
         
     | 
| 
       6767 
6696 
     | 
    
         
             
            var ResultSchema = BaseParamsSchema;
         
     | 
| 
       6768 
     | 
    
         
            -
            var  
     | 
| 
      
 6697 
     | 
    
         
            +
            var RequestSchema = import_zod8.z.object({
         
     | 
| 
       6769 
6698 
     | 
    
         
             
              method: import_zod8.z.string(),
         
     | 
| 
       6770 
6699 
     | 
    
         
             
              params: import_zod8.z.optional(BaseParamsSchema)
         
     | 
| 
       6771 
6700 
     | 
    
         
             
            });
         
     | 
| 
       6772 
     | 
    
         
            -
            var RequestIdSchema = import_zod8.z.union([import_zod8.z.string(), import_zod8.z.number().int()]);
         
     | 
| 
       6773 
     | 
    
         
            -
            var JSONRPCRequestSchema = import_zod8.z.object({
         
     | 
| 
       6774 
     | 
    
         
            -
              jsonrpc: import_zod8.z.literal(JSONRPC_VERSION),
         
     | 
| 
       6775 
     | 
    
         
            -
              id: RequestIdSchema
         
     | 
| 
       6776 
     | 
    
         
            -
            }).merge(RequestSchema).strict();
         
     | 
| 
       6777 
     | 
    
         
            -
            var JSONRPCResponseSchema = import_zod8.z.object({
         
     | 
| 
       6778 
     | 
    
         
            -
              jsonrpc: import_zod8.z.literal(JSONRPC_VERSION),
         
     | 
| 
       6779 
     | 
    
         
            -
              id: RequestIdSchema,
         
     | 
| 
       6780 
     | 
    
         
            -
              result: ResultSchema
         
     | 
| 
       6781 
     | 
    
         
            -
            }).strict();
         
     | 
| 
       6782 
     | 
    
         
            -
            var JSONRPCErrorSchema = import_zod8.z.object({
         
     | 
| 
       6783 
     | 
    
         
            -
              jsonrpc: import_zod8.z.literal(JSONRPC_VERSION),
         
     | 
| 
       6784 
     | 
    
         
            -
              id: RequestIdSchema,
         
     | 
| 
       6785 
     | 
    
         
            -
              error: import_zod8.z.object({
         
     | 
| 
       6786 
     | 
    
         
            -
                code: import_zod8.z.number().int(),
         
     | 
| 
       6787 
     | 
    
         
            -
                message: import_zod8.z.string(),
         
     | 
| 
       6788 
     | 
    
         
            -
                data: import_zod8.z.optional(import_zod8.z.unknown())
         
     | 
| 
       6789 
     | 
    
         
            -
              })
         
     | 
| 
       6790 
     | 
    
         
            -
            }).strict();
         
     | 
| 
       6791 
     | 
    
         
            -
            var JSONRPCNotificationSchema = import_zod8.z.object({
         
     | 
| 
       6792 
     | 
    
         
            -
              jsonrpc: import_zod8.z.literal(JSONRPC_VERSION)
         
     | 
| 
       6793 
     | 
    
         
            -
            }).merge(NotificationSchema).strict();
         
     | 
| 
       6794 
     | 
    
         
            -
            var JSONRPCMessageSchema = import_zod8.z.union([
         
     | 
| 
       6795 
     | 
    
         
            -
              JSONRPCRequestSchema,
         
     | 
| 
       6796 
     | 
    
         
            -
              JSONRPCNotificationSchema,
         
     | 
| 
       6797 
     | 
    
         
            -
              JSONRPCResponseSchema,
         
     | 
| 
       6798 
     | 
    
         
            -
              JSONRPCErrorSchema
         
     | 
| 
       6799 
     | 
    
         
            -
            ]);
         
     | 
| 
       6800 
6701 
     | 
    
         
             
            var ServerCapabilitiesSchema = import_zod8.z.object({
         
     | 
| 
       6801 
6702 
     | 
    
         
             
              experimental: import_zod8.z.optional(import_zod8.z.object({}).passthrough()),
         
     | 
| 
       6802 
6703 
     | 
    
         
             
              logging: import_zod8.z.optional(import_zod8.z.object({}).passthrough()),
         
     | 
| 
         @@ -6877,127 +6778,43 @@ var CallToolResultSchema = ResultSchema.extend({ 
     | 
|
| 
       6877 
6778 
     | 
    
         
             
              })
         
     | 
| 
       6878 
6779 
     | 
    
         
             
            );
         
     | 
| 
       6879 
6780 
     | 
    
         | 
| 
       6880 
     | 
    
         
            -
            // core/tool/mcp/ 
     | 
| 
       6881 
     | 
    
         
            -
            var  
     | 
| 
       6882 
     | 
    
         
            -
             
     | 
| 
       6883 
     | 
    
         
            -
             
     | 
| 
       6884 
     | 
    
         
            -
             
     | 
| 
       6885 
     | 
    
         
            -
             
     | 
| 
       6886 
     | 
    
         
            -
             
     | 
| 
       6887 
     | 
    
         
            -
               
     | 
| 
       6888 
     | 
    
         
            -
             
     | 
| 
       6889 
     | 
    
         
            -
             
     | 
| 
       6890 
     | 
    
         
            -
             
     | 
| 
       6891 
     | 
    
         
            -
             
     | 
| 
       6892 
     | 
    
         
            -
             
     | 
| 
       6893 
     | 
    
         
            -
             
     | 
| 
       6894 
     | 
    
         
            -
             
     | 
| 
       6895 
     | 
    
         
            -
             
     | 
| 
       6896 
     | 
    
         
            -
             
     | 
| 
       6897 
     | 
    
         
            -
             
     | 
| 
       6898 
     | 
    
         
            -
             
     | 
| 
       6899 
     | 
    
         
            -
             
     | 
| 
       6900 
     | 
    
         
            -
             
     | 
| 
       6901 
     | 
    
         
            -
             
     | 
| 
       6902 
     | 
    
         
            -
             
     | 
| 
       6903 
     | 
    
         
            -
             
     | 
| 
       6904 
     | 
    
         
            -
             
     | 
| 
       6905 
     | 
    
         
            -
             
     | 
| 
       6906 
     | 
    
         
            -
             
     | 
| 
       6907 
     | 
    
         
            -
             
     | 
| 
       6908 
     | 
    
         
            -
             
     | 
| 
       6909 
     | 
    
         
            -
             
     | 
| 
       6910 
     | 
    
         
            -
             
     | 
| 
       6911 
     | 
    
         
            -
             
     | 
| 
       6912 
     | 
    
         
            -
             
     | 
| 
       6913 
     | 
    
         
            -
             
     | 
| 
       6914 
     | 
    
         
            -
                      var _a18;
         
     | 
| 
       6915 
     | 
    
         
            -
                      this.process = void 0;
         
     | 
| 
       6916 
     | 
    
         
            -
                      (_a18 = this.onClose) == null ? void 0 : _a18.call(this);
         
     | 
| 
       6917 
     | 
    
         
            -
                    });
         
     | 
| 
       6918 
     | 
    
         
            -
                    (_a17 = this.process.stdin) == null ? void 0 : _a17.on("error", (error) => {
         
     | 
| 
       6919 
     | 
    
         
            -
                      var _a18;
         
     | 
| 
       6920 
     | 
    
         
            -
                      (_a18 = this.onError) == null ? void 0 : _a18.call(this, error);
         
     | 
| 
       6921 
     | 
    
         
            -
                    });
         
     | 
| 
       6922 
     | 
    
         
            -
                    (_b = this.process.stdout) == null ? void 0 : _b.on("data", (chunk) => {
         
     | 
| 
       6923 
     | 
    
         
            -
                      this.readBuffer.append(chunk);
         
     | 
| 
       6924 
     | 
    
         
            -
                      this.processReadBuffer();
         
     | 
| 
       6925 
     | 
    
         
            -
                    });
         
     | 
| 
       6926 
     | 
    
         
            -
                    (_c = this.process.stdout) == null ? void 0 : _c.on("error", (error) => {
         
     | 
| 
       6927 
     | 
    
         
            -
                      var _a18;
         
     | 
| 
       6928 
     | 
    
         
            -
                      (_a18 = this.onError) == null ? void 0 : _a18.call(this, error);
         
     | 
| 
       6929 
     | 
    
         
            -
                    });
         
     | 
| 
       6930 
     | 
    
         
            -
                  } catch (error) {
         
     | 
| 
       6931 
     | 
    
         
            -
                    reject(error);
         
     | 
| 
       6932 
     | 
    
         
            -
                    (_d = this.onError) == null ? void 0 : _d.call(this, error);
         
     | 
| 
       6933 
     | 
    
         
            -
                  }
         
     | 
| 
       6934 
     | 
    
         
            -
                });
         
     | 
| 
       6935 
     | 
    
         
            -
              }
         
     | 
| 
       6936 
     | 
    
         
            -
              processReadBuffer() {
         
     | 
| 
       6937 
     | 
    
         
            -
                var _a17, _b;
         
     | 
| 
       6938 
     | 
    
         
            -
                while (true) {
         
     | 
| 
       6939 
     | 
    
         
            -
                  try {
         
     | 
| 
       6940 
     | 
    
         
            -
                    const message = this.readBuffer.readMessage();
         
     | 
| 
       6941 
     | 
    
         
            -
                    if (message === null) {
         
     | 
| 
       6942 
     | 
    
         
            -
                      break;
         
     | 
| 
       6943 
     | 
    
         
            -
                    }
         
     | 
| 
       6944 
     | 
    
         
            -
                    (_a17 = this.onMessage) == null ? void 0 : _a17.call(this, message);
         
     | 
| 
       6945 
     | 
    
         
            -
                  } catch (error) {
         
     | 
| 
       6946 
     | 
    
         
            -
                    (_b = this.onError) == null ? void 0 : _b.call(this, error);
         
     | 
| 
       6947 
     | 
    
         
            -
                  }
         
     | 
| 
       6948 
     | 
    
         
            -
                }
         
     | 
| 
       6949 
     | 
    
         
            -
              }
         
     | 
| 
       6950 
     | 
    
         
            -
              async close() {
         
     | 
| 
       6951 
     | 
    
         
            -
                this.abortController.abort();
         
     | 
| 
       6952 
     | 
    
         
            -
                this.process = void 0;
         
     | 
| 
       6953 
     | 
    
         
            -
                this.readBuffer.clear();
         
     | 
| 
       6954 
     | 
    
         
            -
              }
         
     | 
| 
       6955 
     | 
    
         
            -
              send(message) {
         
     | 
| 
       6956 
     | 
    
         
            -
                return new Promise((resolve) => {
         
     | 
| 
       6957 
     | 
    
         
            -
                  var _a17;
         
     | 
| 
       6958 
     | 
    
         
            -
                  if (!((_a17 = this.process) == null ? void 0 : _a17.stdin)) {
         
     | 
| 
       6959 
     | 
    
         
            -
                    throw new MCPClientError({
         
     | 
| 
       6960 
     | 
    
         
            -
                      message: "StdioClientTransport not connected"
         
     | 
| 
       6961 
     | 
    
         
            -
                    });
         
     | 
| 
       6962 
     | 
    
         
            -
                  }
         
     | 
| 
       6963 
     | 
    
         
            -
                  const json = serializeMessage(message);
         
     | 
| 
       6964 
     | 
    
         
            -
                  if (this.process.stdin.write(json)) {
         
     | 
| 
       6965 
     | 
    
         
            -
                    resolve();
         
     | 
| 
       6966 
     | 
    
         
            -
                  } else {
         
     | 
| 
       6967 
     | 
    
         
            -
                    this.process.stdin.once("drain", resolve);
         
     | 
| 
       6968 
     | 
    
         
            -
                  }
         
     | 
| 
       6969 
     | 
    
         
            -
                });
         
     | 
| 
       6970 
     | 
    
         
            -
              }
         
     | 
| 
       6971 
     | 
    
         
            -
            };
         
     | 
| 
       6972 
     | 
    
         
            -
            var ReadBuffer = class {
         
     | 
| 
       6973 
     | 
    
         
            -
              append(chunk) {
         
     | 
| 
       6974 
     | 
    
         
            -
                this.buffer = this.buffer ? Buffer.concat([this.buffer, chunk]) : chunk;
         
     | 
| 
       6975 
     | 
    
         
            -
              }
         
     | 
| 
       6976 
     | 
    
         
            -
              readMessage() {
         
     | 
| 
       6977 
     | 
    
         
            -
                if (!this.buffer)
         
     | 
| 
       6978 
     | 
    
         
            -
                  return null;
         
     | 
| 
       6979 
     | 
    
         
            -
                const index = this.buffer.indexOf("\n");
         
     | 
| 
       6980 
     | 
    
         
            -
                if (index === -1) {
         
     | 
| 
       6981 
     | 
    
         
            -
                  return null;
         
     | 
| 
       6982 
     | 
    
         
            -
                }
         
     | 
| 
       6983 
     | 
    
         
            -
                const line = this.buffer.toString("utf8", 0, index);
         
     | 
| 
       6984 
     | 
    
         
            -
                this.buffer = this.buffer.subarray(index + 1);
         
     | 
| 
       6985 
     | 
    
         
            -
                return deserializeMessage(line);
         
     | 
| 
       6986 
     | 
    
         
            -
              }
         
     | 
| 
       6987 
     | 
    
         
            -
              clear() {
         
     | 
| 
       6988 
     | 
    
         
            -
                this.buffer = void 0;
         
     | 
| 
       6989 
     | 
    
         
            -
              }
         
     | 
| 
       6990 
     | 
    
         
            -
            };
         
     | 
| 
       6991 
     | 
    
         
            -
            function serializeMessage(message) {
         
     | 
| 
       6992 
     | 
    
         
            -
              return JSON.stringify(message) + "\n";
         
     | 
| 
       6993 
     | 
    
         
            -
            }
         
     | 
| 
       6994 
     | 
    
         
            -
            function deserializeMessage(line) {
         
     | 
| 
       6995 
     | 
    
         
            -
              return JSONRPCMessageSchema.parse(JSON.parse(line));
         
     | 
| 
       6996 
     | 
    
         
            -
            }
         
     | 
| 
      
 6781 
     | 
    
         
            +
            // core/tool/mcp/json-rpc-message.ts
         
     | 
| 
      
 6782 
     | 
    
         
            +
            var JSONRPC_VERSION = "2.0";
         
     | 
| 
      
 6783 
     | 
    
         
            +
            var JSONRPCRequestSchema = import_zod9.z.object({
         
     | 
| 
      
 6784 
     | 
    
         
            +
              jsonrpc: import_zod9.z.literal(JSONRPC_VERSION),
         
     | 
| 
      
 6785 
     | 
    
         
            +
              id: import_zod9.z.union([import_zod9.z.string(), import_zod9.z.number().int()])
         
     | 
| 
      
 6786 
     | 
    
         
            +
            }).merge(RequestSchema).strict();
         
     | 
| 
      
 6787 
     | 
    
         
            +
            var JSONRPCResponseSchema = import_zod9.z.object({
         
     | 
| 
      
 6788 
     | 
    
         
            +
              jsonrpc: import_zod9.z.literal(JSONRPC_VERSION),
         
     | 
| 
      
 6789 
     | 
    
         
            +
              id: import_zod9.z.union([import_zod9.z.string(), import_zod9.z.number().int()]),
         
     | 
| 
      
 6790 
     | 
    
         
            +
              result: ResultSchema
         
     | 
| 
      
 6791 
     | 
    
         
            +
            }).strict();
         
     | 
| 
      
 6792 
     | 
    
         
            +
            var JSONRPCErrorSchema = import_zod9.z.object({
         
     | 
| 
      
 6793 
     | 
    
         
            +
              jsonrpc: import_zod9.z.literal(JSONRPC_VERSION),
         
     | 
| 
      
 6794 
     | 
    
         
            +
              id: import_zod9.z.union([import_zod9.z.string(), import_zod9.z.number().int()]),
         
     | 
| 
      
 6795 
     | 
    
         
            +
              error: import_zod9.z.object({
         
     | 
| 
      
 6796 
     | 
    
         
            +
                code: import_zod9.z.number().int(),
         
     | 
| 
      
 6797 
     | 
    
         
            +
                message: import_zod9.z.string(),
         
     | 
| 
      
 6798 
     | 
    
         
            +
                data: import_zod9.z.optional(import_zod9.z.unknown())
         
     | 
| 
      
 6799 
     | 
    
         
            +
              })
         
     | 
| 
      
 6800 
     | 
    
         
            +
            }).strict();
         
     | 
| 
      
 6801 
     | 
    
         
            +
            var JSONRPCNotificationSchema = import_zod9.z.object({
         
     | 
| 
      
 6802 
     | 
    
         
            +
              jsonrpc: import_zod9.z.literal(JSONRPC_VERSION)
         
     | 
| 
      
 6803 
     | 
    
         
            +
            }).merge(
         
     | 
| 
      
 6804 
     | 
    
         
            +
              import_zod9.z.object({
         
     | 
| 
      
 6805 
     | 
    
         
            +
                method: import_zod9.z.string(),
         
     | 
| 
      
 6806 
     | 
    
         
            +
                params: import_zod9.z.optional(BaseParamsSchema)
         
     | 
| 
      
 6807 
     | 
    
         
            +
              })
         
     | 
| 
      
 6808 
     | 
    
         
            +
            ).strict();
         
     | 
| 
      
 6809 
     | 
    
         
            +
            var JSONRPCMessageSchema = import_zod9.z.union([
         
     | 
| 
      
 6810 
     | 
    
         
            +
              JSONRPCRequestSchema,
         
     | 
| 
      
 6811 
     | 
    
         
            +
              JSONRPCNotificationSchema,
         
     | 
| 
      
 6812 
     | 
    
         
            +
              JSONRPCResponseSchema,
         
     | 
| 
      
 6813 
     | 
    
         
            +
              JSONRPCErrorSchema
         
     | 
| 
      
 6814 
     | 
    
         
            +
            ]);
         
     | 
| 
       6997 
6815 
     | 
    
         | 
| 
       6998 
6816 
     | 
    
         
             
            // core/tool/mcp/mcp-sse-transport.ts
         
     | 
| 
       6999 
     | 
    
         
            -
            var  
     | 
| 
       7000 
     | 
    
         
            -
            var SSEClientTransport = class {
         
     | 
| 
      
 6817 
     | 
    
         
            +
            var SseMCPTransport = class {
         
     | 
| 
       7001 
6818 
     | 
    
         
             
              constructor({ url }) {
         
     | 
| 
       7002 
6819 
     | 
    
         
             
                this.connected = false;
         
     | 
| 
       7003 
6820 
     | 
    
         
             
                this.url = new URL(url);
         
     | 
| 
         @@ -7021,7 +6838,7 @@ var SSEClientTransport = class { 
     | 
|
| 
       7021 
6838 
     | 
    
         
             
                        const error = new MCPClientError({
         
     | 
| 
       7022 
6839 
     | 
    
         
             
                          message: `MCP SSE Transport Error: ${response.status} ${response.statusText}`
         
     | 
| 
       7023 
6840 
     | 
    
         
             
                        });
         
     | 
| 
       7024 
     | 
    
         
            -
                        (_b = this. 
     | 
| 
      
 6841 
     | 
    
         
            +
                        (_b = this.onerror) == null ? void 0 : _b.call(this, error);
         
     | 
| 
       7025 
6842 
     | 
    
         
             
                        return reject(error);
         
     | 
| 
       7026 
6843 
     | 
    
         
             
                      }
         
     | 
| 
       7027 
6844 
     | 
    
         
             
                      const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new import_stream.EventSourceParserStream());
         
     | 
| 
         @@ -7055,13 +6872,13 @@ var SSEClientTransport = class { 
     | 
|
| 
       7055 
6872 
     | 
    
         
             
                                const message = JSONRPCMessageSchema.parse(
         
     | 
| 
       7056 
6873 
     | 
    
         
             
                                  JSON.parse(data)
         
     | 
| 
       7057 
6874 
     | 
    
         
             
                                );
         
     | 
| 
       7058 
     | 
    
         
            -
                                (_a18 = this. 
     | 
| 
      
 6875 
     | 
    
         
            +
                                (_a18 = this.onmessage) == null ? void 0 : _a18.call(this, message);
         
     | 
| 
       7059 
6876 
     | 
    
         
             
                              } catch (error) {
         
     | 
| 
       7060 
6877 
     | 
    
         
             
                                const e = new MCPClientError({
         
     | 
| 
       7061 
6878 
     | 
    
         
             
                                  message: "MCP SSE Transport Error: Failed to parse message",
         
     | 
| 
       7062 
6879 
     | 
    
         
             
                                  cause: error
         
     | 
| 
       7063 
6880 
     | 
    
         
             
                                });
         
     | 
| 
       7064 
     | 
    
         
            -
                                (_b2 = this. 
     | 
| 
      
 6881 
     | 
    
         
            +
                                (_b2 = this.onerror) == null ? void 0 : _b2.call(this, e);
         
     | 
| 
       7065 
6882 
     | 
    
         
             
                              }
         
     | 
| 
       7066 
6883 
     | 
    
         
             
                            }
         
     | 
| 
       7067 
6884 
     | 
    
         
             
                          }
         
     | 
| 
         @@ -7069,7 +6886,7 @@ var SSEClientTransport = class { 
     | 
|
| 
       7069 
6886 
     | 
    
         
             
                          if (error instanceof Error && error.name === "AbortError") {
         
     | 
| 
       7070 
6887 
     | 
    
         
             
                            return;
         
     | 
| 
       7071 
6888 
     | 
    
         
             
                          }
         
     | 
| 
       7072 
     | 
    
         
            -
                          (_c2 = this. 
     | 
| 
      
 6889 
     | 
    
         
            +
                          (_c2 = this.onerror) == null ? void 0 : _c2.call(this, error);
         
     | 
| 
       7073 
6890 
     | 
    
         
             
                          reject(error);
         
     | 
| 
       7074 
6891 
     | 
    
         
             
                        }
         
     | 
| 
       7075 
6892 
     | 
    
         
             
                      };
         
     | 
| 
         @@ -7081,7 +6898,7 @@ var SSEClientTransport = class { 
     | 
|
| 
       7081 
6898 
     | 
    
         
             
                      if (error instanceof Error && error.name === "AbortError") {
         
     | 
| 
       7082 
6899 
     | 
    
         
             
                        return;
         
     | 
| 
       7083 
6900 
     | 
    
         
             
                      }
         
     | 
| 
       7084 
     | 
    
         
            -
                      (_c = this. 
     | 
| 
      
 6901 
     | 
    
         
            +
                      (_c = this.onerror) == null ? void 0 : _c.call(this, error);
         
     | 
| 
       7085 
6902 
     | 
    
         
             
                      reject(error);
         
     | 
| 
       7086 
6903 
     | 
    
         
             
                    }
         
     | 
| 
       7087 
6904 
     | 
    
         
             
                  };
         
     | 
| 
         @@ -7093,7 +6910,7 @@ var SSEClientTransport = class { 
     | 
|
| 
       7093 
6910 
     | 
    
         
             
                this.connected = false;
         
     | 
| 
       7094 
6911 
     | 
    
         
             
                (_a17 = this.sseConnection) == null ? void 0 : _a17.close();
         
     | 
| 
       7095 
6912 
     | 
    
         
             
                (_b = this.abortController) == null ? void 0 : _b.abort();
         
     | 
| 
       7096 
     | 
    
         
            -
                (_c = this. 
     | 
| 
      
 6913 
     | 
    
         
            +
                (_c = this.onclose) == null ? void 0 : _c.call(this);
         
     | 
| 
       7097 
6914 
     | 
    
         
             
              }
         
     | 
| 
       7098 
6915 
     | 
    
         
             
              async send(message) {
         
     | 
| 
       7099 
6916 
     | 
    
         
             
                var _a17, _b, _c;
         
     | 
| 
         @@ -7117,11 +6934,11 @@ var SSEClientTransport = class { 
     | 
|
| 
       7117 
6934 
     | 
    
         
             
                    const error = new MCPClientError({
         
     | 
| 
       7118 
6935 
     | 
    
         
             
                      message: `MCP SSE Transport Error: POSTing to endpoint (HTTP ${response.status}): ${text2}`
         
     | 
| 
       7119 
6936 
     | 
    
         
             
                    });
         
     | 
| 
       7120 
     | 
    
         
            -
                    (_b = this. 
     | 
| 
      
 6937 
     | 
    
         
            +
                    (_b = this.onerror) == null ? void 0 : _b.call(this, error);
         
     | 
| 
       7121 
6938 
     | 
    
         
             
                    return;
         
     | 
| 
       7122 
6939 
     | 
    
         
             
                  }
         
     | 
| 
       7123 
6940 
     | 
    
         
             
                } catch (error) {
         
     | 
| 
       7124 
     | 
    
         
            -
                  (_c = this. 
     | 
| 
      
 6941 
     | 
    
         
            +
                  (_c = this.onerror) == null ? void 0 : _c.call(this, error);
         
     | 
| 
       7125 
6942 
     | 
    
         
             
                  return;
         
     | 
| 
       7126 
6943 
     | 
    
         
             
                }
         
     | 
| 
       7127 
6944 
     | 
    
         
             
              }
         
     | 
| 
         @@ -7129,7 +6946,15 @@ var SSEClientTransport = class { 
     | 
|
| 
       7129 
6946 
     | 
    
         | 
| 
       7130 
6947 
     | 
    
         
             
            // core/tool/mcp/mcp-transport.ts
         
     | 
| 
       7131 
6948 
     | 
    
         
             
            function createMcpTransport(config) {
         
     | 
| 
       7132 
     | 
    
         
            -
               
     | 
| 
      
 6949 
     | 
    
         
            +
              if (config.type !== "sse") {
         
     | 
| 
      
 6950 
     | 
    
         
            +
                throw new MCPClientError({
         
     | 
| 
      
 6951 
     | 
    
         
            +
                  message: "Unsupported or invalid transport configuration. If you are using a custom transport, make sure it implements the MCPTransport interface."
         
     | 
| 
      
 6952 
     | 
    
         
            +
                });
         
     | 
| 
      
 6953 
     | 
    
         
            +
              }
         
     | 
| 
      
 6954 
     | 
    
         
            +
              return new SseMCPTransport(config);
         
     | 
| 
      
 6955 
     | 
    
         
            +
            }
         
     | 
| 
      
 6956 
     | 
    
         
            +
            function isCustomMcpTransport(transport) {
         
     | 
| 
      
 6957 
     | 
    
         
            +
              return "start" in transport && typeof transport.start === "function" && "send" in transport && typeof transport.send === "function" && "close" in transport && typeof transport.close === "function";
         
     | 
| 
       7133 
6958 
     | 
    
         
             
            }
         
     | 
| 
       7134 
6959 
     | 
    
         | 
| 
       7135 
6960 
     | 
    
         
             
            // core/tool/mcp/mcp-client.ts
         
     | 
| 
         @@ -7150,10 +6975,14 @@ var MCPClient = class { 
     | 
|
| 
       7150 
6975 
     | 
    
         
             
                this.serverCapabilities = {};
         
     | 
| 
       7151 
6976 
     | 
    
         
             
                this.isClosed = true;
         
     | 
| 
       7152 
6977 
     | 
    
         
             
                this.onUncaughtError = onUncaughtError;
         
     | 
| 
       7153 
     | 
    
         
            -
                 
     | 
| 
       7154 
     | 
    
         
            -
             
     | 
| 
       7155 
     | 
    
         
            -
                 
     | 
| 
       7156 
     | 
    
         
            -
             
     | 
| 
      
 6978 
     | 
    
         
            +
                if (isCustomMcpTransport(transportConfig)) {
         
     | 
| 
      
 6979 
     | 
    
         
            +
                  this.transport = transportConfig;
         
     | 
| 
      
 6980 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 6981 
     | 
    
         
            +
                  this.transport = createMcpTransport(transportConfig);
         
     | 
| 
      
 6982 
     | 
    
         
            +
                }
         
     | 
| 
      
 6983 
     | 
    
         
            +
                this.transport.onclose = () => this.onClose();
         
     | 
| 
      
 6984 
     | 
    
         
            +
                this.transport.onerror = (error) => this.onError(error);
         
     | 
| 
      
 6985 
     | 
    
         
            +
                this.transport.onmessage = (message) => {
         
     | 
| 
       7157 
6986 
     | 
    
         
             
                  if ("method" in message) {
         
     | 
| 
       7158 
6987 
     | 
    
         
             
                    this.onError(
         
     | 
| 
       7159 
6988 
     | 
    
         
             
                      new MCPClientError({
         
     |