ai 0.0.0-156c9f7b-20250115085202 → 0.0.0-677c097b-20250505090413
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 +774 -2
- package/README.md +22 -9
- package/dist/index.d.mts +3081 -1016
- package/dist/index.d.ts +3081 -1016
- package/dist/index.js +3120 -975
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3060 -931
- package/dist/index.mjs.map +1 -1
- package/mcp-stdio/dist/index.d.mts +169 -0
- package/mcp-stdio/dist/index.d.ts +169 -0
- package/mcp-stdio/dist/index.js +352 -0
- package/mcp-stdio/dist/index.js.map +1 -0
- package/mcp-stdio/dist/index.mjs +337 -0
- package/mcp-stdio/dist/index.mjs.map +1 -0
- package/package.json +15 -11
- package/react/dist/index.d.mts +13 -1
- package/react/dist/index.d.ts +13 -1
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs.map +1 -1
- package/rsc/dist/index.d.ts +108 -18
- package/rsc/dist/rsc-server.d.mts +108 -18
- package/rsc/dist/rsc-server.mjs +603 -274
- package/rsc/dist/rsc-server.mjs.map +1 -1
- package/rsc/dist/rsc-shared.mjs +1 -3
- package/rsc/dist/rsc-shared.mjs.map +1 -1
- package/test/dist/index.d.mts +2 -4
- package/test/dist/index.d.ts +2 -4
- package/test/dist/index.js +4 -14
- package/test/dist/index.js.map +1 -1
- package/test/dist/index.mjs +7 -14
- package/test/dist/index.mjs.map +1 -1
@@ -0,0 +1,169 @@
|
|
1
|
+
import { IOType } from 'node:child_process';
|
2
|
+
import { Stream } from 'node:stream';
|
3
|
+
import { z } from 'zod';
|
4
|
+
|
5
|
+
declare const JSONRPCMessageSchema: z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
|
6
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
7
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
8
|
+
}, {
|
9
|
+
method: z.ZodString;
|
10
|
+
params: z.ZodOptional<z.ZodObject<{
|
11
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
12
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
13
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
14
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
15
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
16
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
17
|
+
}>, "strict", z.ZodTypeAny, {
|
18
|
+
method: string;
|
19
|
+
jsonrpc: "2.0";
|
20
|
+
id: string | number;
|
21
|
+
params?: z.objectOutputType<{
|
22
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
23
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
24
|
+
}, {
|
25
|
+
method: string;
|
26
|
+
jsonrpc: "2.0";
|
27
|
+
id: string | number;
|
28
|
+
params?: z.objectInputType<{
|
29
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
30
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
31
|
+
}>, z.ZodObject<z.objectUtil.extendShape<{
|
32
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
33
|
+
}, {
|
34
|
+
method: z.ZodString;
|
35
|
+
params: z.ZodOptional<z.ZodObject<{
|
36
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
37
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
38
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
39
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
40
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
41
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
42
|
+
}>, "strict", z.ZodTypeAny, {
|
43
|
+
method: string;
|
44
|
+
jsonrpc: "2.0";
|
45
|
+
params?: z.objectOutputType<{
|
46
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
47
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
48
|
+
}, {
|
49
|
+
method: string;
|
50
|
+
jsonrpc: "2.0";
|
51
|
+
params?: z.objectInputType<{
|
52
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
53
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
54
|
+
}>, z.ZodObject<{
|
55
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
56
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
57
|
+
result: z.ZodObject<{
|
58
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
59
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
60
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
61
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
62
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
63
|
+
}, z.ZodTypeAny, "passthrough">>;
|
64
|
+
}, "strict", z.ZodTypeAny, {
|
65
|
+
result: {
|
66
|
+
_meta?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
67
|
+
} & {
|
68
|
+
[k: string]: unknown;
|
69
|
+
};
|
70
|
+
jsonrpc: "2.0";
|
71
|
+
id: string | number;
|
72
|
+
}, {
|
73
|
+
result: {
|
74
|
+
_meta?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
75
|
+
} & {
|
76
|
+
[k: string]: unknown;
|
77
|
+
};
|
78
|
+
jsonrpc: "2.0";
|
79
|
+
id: string | number;
|
80
|
+
}>, z.ZodObject<{
|
81
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
82
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
83
|
+
error: z.ZodObject<{
|
84
|
+
code: z.ZodNumber;
|
85
|
+
message: z.ZodString;
|
86
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
87
|
+
}, "strip", z.ZodTypeAny, {
|
88
|
+
code: number;
|
89
|
+
message: string;
|
90
|
+
data?: unknown;
|
91
|
+
}, {
|
92
|
+
code: number;
|
93
|
+
message: string;
|
94
|
+
data?: unknown;
|
95
|
+
}>;
|
96
|
+
}, "strict", z.ZodTypeAny, {
|
97
|
+
error: {
|
98
|
+
code: number;
|
99
|
+
message: string;
|
100
|
+
data?: unknown;
|
101
|
+
};
|
102
|
+
jsonrpc: "2.0";
|
103
|
+
id: string | number;
|
104
|
+
}, {
|
105
|
+
error: {
|
106
|
+
code: number;
|
107
|
+
message: string;
|
108
|
+
data?: unknown;
|
109
|
+
};
|
110
|
+
jsonrpc: "2.0";
|
111
|
+
id: string | number;
|
112
|
+
}>]>;
|
113
|
+
type JSONRPCMessage = z.infer<typeof JSONRPCMessageSchema>;
|
114
|
+
|
115
|
+
/**
|
116
|
+
* Transport interface for MCP (Model Context Protocol) communication.
|
117
|
+
* Maps to the `Transport` interface in the MCP spec.
|
118
|
+
*/
|
119
|
+
interface MCPTransport {
|
120
|
+
/**
|
121
|
+
* Initialize and start the transport
|
122
|
+
*/
|
123
|
+
start(): Promise<void>;
|
124
|
+
/**
|
125
|
+
* Send a JSON-RPC message through the transport
|
126
|
+
* @param message The JSON-RPC message to send
|
127
|
+
*/
|
128
|
+
send(message: JSONRPCMessage): Promise<void>;
|
129
|
+
/**
|
130
|
+
* Clean up and close the transport
|
131
|
+
*/
|
132
|
+
close(): Promise<void>;
|
133
|
+
/**
|
134
|
+
* Event handler for transport closure
|
135
|
+
*/
|
136
|
+
onclose?: () => void;
|
137
|
+
/**
|
138
|
+
* Event handler for transport errors
|
139
|
+
*/
|
140
|
+
onerror?: (error: Error) => void;
|
141
|
+
/**
|
142
|
+
* Event handler for received messages
|
143
|
+
*/
|
144
|
+
onmessage?: (message: JSONRPCMessage) => void;
|
145
|
+
}
|
146
|
+
|
147
|
+
interface StdioConfig {
|
148
|
+
command: string;
|
149
|
+
args?: string[];
|
150
|
+
env?: Record<string, string>;
|
151
|
+
stderr?: IOType | Stream | number;
|
152
|
+
cwd?: string;
|
153
|
+
}
|
154
|
+
declare class StdioMCPTransport implements MCPTransport {
|
155
|
+
private process?;
|
156
|
+
private abortController;
|
157
|
+
private readBuffer;
|
158
|
+
private serverParams;
|
159
|
+
onclose?: () => void;
|
160
|
+
onerror?: (error: unknown) => void;
|
161
|
+
onmessage?: (message: JSONRPCMessage) => void;
|
162
|
+
constructor(server: StdioConfig);
|
163
|
+
start(): Promise<void>;
|
164
|
+
private processReadBuffer;
|
165
|
+
close(): Promise<void>;
|
166
|
+
send(message: JSONRPCMessage): Promise<void>;
|
167
|
+
}
|
168
|
+
|
169
|
+
export { StdioMCPTransport as Experimental_StdioMCPTransport, StdioConfig };
|
@@ -0,0 +1,169 @@
|
|
1
|
+
import { IOType } from 'node:child_process';
|
2
|
+
import { Stream } from 'node:stream';
|
3
|
+
import { z } from 'zod';
|
4
|
+
|
5
|
+
declare const JSONRPCMessageSchema: z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
|
6
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
7
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
8
|
+
}, {
|
9
|
+
method: z.ZodString;
|
10
|
+
params: z.ZodOptional<z.ZodObject<{
|
11
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
12
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
13
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
14
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
15
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
16
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
17
|
+
}>, "strict", z.ZodTypeAny, {
|
18
|
+
method: string;
|
19
|
+
jsonrpc: "2.0";
|
20
|
+
id: string | number;
|
21
|
+
params?: z.objectOutputType<{
|
22
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
23
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
24
|
+
}, {
|
25
|
+
method: string;
|
26
|
+
jsonrpc: "2.0";
|
27
|
+
id: string | number;
|
28
|
+
params?: z.objectInputType<{
|
29
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
30
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
31
|
+
}>, z.ZodObject<z.objectUtil.extendShape<{
|
32
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
33
|
+
}, {
|
34
|
+
method: z.ZodString;
|
35
|
+
params: z.ZodOptional<z.ZodObject<{
|
36
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
37
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
38
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
39
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
40
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
41
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
42
|
+
}>, "strict", z.ZodTypeAny, {
|
43
|
+
method: string;
|
44
|
+
jsonrpc: "2.0";
|
45
|
+
params?: z.objectOutputType<{
|
46
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
47
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
48
|
+
}, {
|
49
|
+
method: string;
|
50
|
+
jsonrpc: "2.0";
|
51
|
+
params?: z.objectInputType<{
|
52
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
53
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
54
|
+
}>, z.ZodObject<{
|
55
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
56
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
57
|
+
result: z.ZodObject<{
|
58
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
59
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
60
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
61
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
62
|
+
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
63
|
+
}, z.ZodTypeAny, "passthrough">>;
|
64
|
+
}, "strict", z.ZodTypeAny, {
|
65
|
+
result: {
|
66
|
+
_meta?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
67
|
+
} & {
|
68
|
+
[k: string]: unknown;
|
69
|
+
};
|
70
|
+
jsonrpc: "2.0";
|
71
|
+
id: string | number;
|
72
|
+
}, {
|
73
|
+
result: {
|
74
|
+
_meta?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
75
|
+
} & {
|
76
|
+
[k: string]: unknown;
|
77
|
+
};
|
78
|
+
jsonrpc: "2.0";
|
79
|
+
id: string | number;
|
80
|
+
}>, z.ZodObject<{
|
81
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
82
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
83
|
+
error: z.ZodObject<{
|
84
|
+
code: z.ZodNumber;
|
85
|
+
message: z.ZodString;
|
86
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
87
|
+
}, "strip", z.ZodTypeAny, {
|
88
|
+
code: number;
|
89
|
+
message: string;
|
90
|
+
data?: unknown;
|
91
|
+
}, {
|
92
|
+
code: number;
|
93
|
+
message: string;
|
94
|
+
data?: unknown;
|
95
|
+
}>;
|
96
|
+
}, "strict", z.ZodTypeAny, {
|
97
|
+
error: {
|
98
|
+
code: number;
|
99
|
+
message: string;
|
100
|
+
data?: unknown;
|
101
|
+
};
|
102
|
+
jsonrpc: "2.0";
|
103
|
+
id: string | number;
|
104
|
+
}, {
|
105
|
+
error: {
|
106
|
+
code: number;
|
107
|
+
message: string;
|
108
|
+
data?: unknown;
|
109
|
+
};
|
110
|
+
jsonrpc: "2.0";
|
111
|
+
id: string | number;
|
112
|
+
}>]>;
|
113
|
+
type JSONRPCMessage = z.infer<typeof JSONRPCMessageSchema>;
|
114
|
+
|
115
|
+
/**
|
116
|
+
* Transport interface for MCP (Model Context Protocol) communication.
|
117
|
+
* Maps to the `Transport` interface in the MCP spec.
|
118
|
+
*/
|
119
|
+
interface MCPTransport {
|
120
|
+
/**
|
121
|
+
* Initialize and start the transport
|
122
|
+
*/
|
123
|
+
start(): Promise<void>;
|
124
|
+
/**
|
125
|
+
* Send a JSON-RPC message through the transport
|
126
|
+
* @param message The JSON-RPC message to send
|
127
|
+
*/
|
128
|
+
send(message: JSONRPCMessage): Promise<void>;
|
129
|
+
/**
|
130
|
+
* Clean up and close the transport
|
131
|
+
*/
|
132
|
+
close(): Promise<void>;
|
133
|
+
/**
|
134
|
+
* Event handler for transport closure
|
135
|
+
*/
|
136
|
+
onclose?: () => void;
|
137
|
+
/**
|
138
|
+
* Event handler for transport errors
|
139
|
+
*/
|
140
|
+
onerror?: (error: Error) => void;
|
141
|
+
/**
|
142
|
+
* Event handler for received messages
|
143
|
+
*/
|
144
|
+
onmessage?: (message: JSONRPCMessage) => void;
|
145
|
+
}
|
146
|
+
|
147
|
+
interface StdioConfig {
|
148
|
+
command: string;
|
149
|
+
args?: string[];
|
150
|
+
env?: Record<string, string>;
|
151
|
+
stderr?: IOType | Stream | number;
|
152
|
+
cwd?: string;
|
153
|
+
}
|
154
|
+
declare class StdioMCPTransport implements MCPTransport {
|
155
|
+
private process?;
|
156
|
+
private abortController;
|
157
|
+
private readBuffer;
|
158
|
+
private serverParams;
|
159
|
+
onclose?: () => void;
|
160
|
+
onerror?: (error: unknown) => void;
|
161
|
+
onmessage?: (message: JSONRPCMessage) => void;
|
162
|
+
constructor(server: StdioConfig);
|
163
|
+
start(): Promise<void>;
|
164
|
+
private processReadBuffer;
|
165
|
+
close(): Promise<void>;
|
166
|
+
send(message: JSONRPCMessage): Promise<void>;
|
167
|
+
}
|
168
|
+
|
169
|
+
export { StdioMCPTransport as Experimental_StdioMCPTransport, StdioConfig };
|
@@ -0,0 +1,352 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name2 in all)
|
8
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
|
20
|
+
// mcp-stdio/index.ts
|
21
|
+
var mcp_stdio_exports = {};
|
22
|
+
__export(mcp_stdio_exports, {
|
23
|
+
Experimental_StdioMCPTransport: () => StdioMCPTransport
|
24
|
+
});
|
25
|
+
module.exports = __toCommonJS(mcp_stdio_exports);
|
26
|
+
|
27
|
+
// core/tool/mcp/json-rpc-message.ts
|
28
|
+
var import_zod2 = require("zod");
|
29
|
+
|
30
|
+
// core/tool/mcp/types.ts
|
31
|
+
var import_zod = require("zod");
|
32
|
+
var ClientOrServerImplementationSchema = import_zod.z.object({
|
33
|
+
name: import_zod.z.string(),
|
34
|
+
version: import_zod.z.string()
|
35
|
+
}).passthrough();
|
36
|
+
var BaseParamsSchema = import_zod.z.object({
|
37
|
+
_meta: import_zod.z.optional(import_zod.z.object({}).passthrough())
|
38
|
+
}).passthrough();
|
39
|
+
var ResultSchema = BaseParamsSchema;
|
40
|
+
var RequestSchema = import_zod.z.object({
|
41
|
+
method: import_zod.z.string(),
|
42
|
+
params: import_zod.z.optional(BaseParamsSchema)
|
43
|
+
});
|
44
|
+
var ServerCapabilitiesSchema = import_zod.z.object({
|
45
|
+
experimental: import_zod.z.optional(import_zod.z.object({}).passthrough()),
|
46
|
+
logging: import_zod.z.optional(import_zod.z.object({}).passthrough()),
|
47
|
+
prompts: import_zod.z.optional(
|
48
|
+
import_zod.z.object({
|
49
|
+
listChanged: import_zod.z.optional(import_zod.z.boolean())
|
50
|
+
}).passthrough()
|
51
|
+
),
|
52
|
+
resources: import_zod.z.optional(
|
53
|
+
import_zod.z.object({
|
54
|
+
subscribe: import_zod.z.optional(import_zod.z.boolean()),
|
55
|
+
listChanged: import_zod.z.optional(import_zod.z.boolean())
|
56
|
+
}).passthrough()
|
57
|
+
),
|
58
|
+
tools: import_zod.z.optional(
|
59
|
+
import_zod.z.object({
|
60
|
+
listChanged: import_zod.z.optional(import_zod.z.boolean())
|
61
|
+
}).passthrough()
|
62
|
+
)
|
63
|
+
}).passthrough();
|
64
|
+
var InitializeResultSchema = ResultSchema.extend({
|
65
|
+
protocolVersion: import_zod.z.string(),
|
66
|
+
capabilities: ServerCapabilitiesSchema,
|
67
|
+
serverInfo: ClientOrServerImplementationSchema,
|
68
|
+
instructions: import_zod.z.optional(import_zod.z.string())
|
69
|
+
});
|
70
|
+
var PaginatedResultSchema = ResultSchema.extend({
|
71
|
+
nextCursor: import_zod.z.optional(import_zod.z.string())
|
72
|
+
});
|
73
|
+
var ToolSchema = import_zod.z.object({
|
74
|
+
name: import_zod.z.string(),
|
75
|
+
description: import_zod.z.optional(import_zod.z.string()),
|
76
|
+
inputSchema: import_zod.z.object({
|
77
|
+
type: import_zod.z.literal("object"),
|
78
|
+
properties: import_zod.z.optional(import_zod.z.object({}).passthrough())
|
79
|
+
}).passthrough()
|
80
|
+
}).passthrough();
|
81
|
+
var ListToolsResultSchema = PaginatedResultSchema.extend({
|
82
|
+
tools: import_zod.z.array(ToolSchema)
|
83
|
+
});
|
84
|
+
var TextContentSchema = import_zod.z.object({
|
85
|
+
type: import_zod.z.literal("text"),
|
86
|
+
text: import_zod.z.string()
|
87
|
+
}).passthrough();
|
88
|
+
var ImageContentSchema = import_zod.z.object({
|
89
|
+
type: import_zod.z.literal("image"),
|
90
|
+
data: import_zod.z.string().base64(),
|
91
|
+
mimeType: import_zod.z.string()
|
92
|
+
}).passthrough();
|
93
|
+
var ResourceContentsSchema = import_zod.z.object({
|
94
|
+
/**
|
95
|
+
* The URI of this resource.
|
96
|
+
*/
|
97
|
+
uri: import_zod.z.string(),
|
98
|
+
/**
|
99
|
+
* The MIME type of this resource, if known.
|
100
|
+
*/
|
101
|
+
mimeType: import_zod.z.optional(import_zod.z.string())
|
102
|
+
}).passthrough();
|
103
|
+
var TextResourceContentsSchema = ResourceContentsSchema.extend({
|
104
|
+
text: import_zod.z.string()
|
105
|
+
});
|
106
|
+
var BlobResourceContentsSchema = ResourceContentsSchema.extend({
|
107
|
+
blob: import_zod.z.string().base64()
|
108
|
+
});
|
109
|
+
var EmbeddedResourceSchema = import_zod.z.object({
|
110
|
+
type: import_zod.z.literal("resource"),
|
111
|
+
resource: import_zod.z.union([TextResourceContentsSchema, BlobResourceContentsSchema])
|
112
|
+
}).passthrough();
|
113
|
+
var CallToolResultSchema = ResultSchema.extend({
|
114
|
+
content: import_zod.z.array(
|
115
|
+
import_zod.z.union([TextContentSchema, ImageContentSchema, EmbeddedResourceSchema])
|
116
|
+
),
|
117
|
+
isError: import_zod.z.boolean().default(false).optional()
|
118
|
+
}).or(
|
119
|
+
ResultSchema.extend({
|
120
|
+
toolResult: import_zod.z.unknown()
|
121
|
+
})
|
122
|
+
);
|
123
|
+
|
124
|
+
// core/tool/mcp/json-rpc-message.ts
|
125
|
+
var JSONRPC_VERSION = "2.0";
|
126
|
+
var JSONRPCRequestSchema = import_zod2.z.object({
|
127
|
+
jsonrpc: import_zod2.z.literal(JSONRPC_VERSION),
|
128
|
+
id: import_zod2.z.union([import_zod2.z.string(), import_zod2.z.number().int()])
|
129
|
+
}).merge(RequestSchema).strict();
|
130
|
+
var JSONRPCResponseSchema = import_zod2.z.object({
|
131
|
+
jsonrpc: import_zod2.z.literal(JSONRPC_VERSION),
|
132
|
+
id: import_zod2.z.union([import_zod2.z.string(), import_zod2.z.number().int()]),
|
133
|
+
result: ResultSchema
|
134
|
+
}).strict();
|
135
|
+
var JSONRPCErrorSchema = import_zod2.z.object({
|
136
|
+
jsonrpc: import_zod2.z.literal(JSONRPC_VERSION),
|
137
|
+
id: import_zod2.z.union([import_zod2.z.string(), import_zod2.z.number().int()]),
|
138
|
+
error: import_zod2.z.object({
|
139
|
+
code: import_zod2.z.number().int(),
|
140
|
+
message: import_zod2.z.string(),
|
141
|
+
data: import_zod2.z.optional(import_zod2.z.unknown())
|
142
|
+
})
|
143
|
+
}).strict();
|
144
|
+
var JSONRPCNotificationSchema = import_zod2.z.object({
|
145
|
+
jsonrpc: import_zod2.z.literal(JSONRPC_VERSION)
|
146
|
+
}).merge(
|
147
|
+
import_zod2.z.object({
|
148
|
+
method: import_zod2.z.string(),
|
149
|
+
params: import_zod2.z.optional(BaseParamsSchema)
|
150
|
+
})
|
151
|
+
).strict();
|
152
|
+
var JSONRPCMessageSchema = import_zod2.z.union([
|
153
|
+
JSONRPCRequestSchema,
|
154
|
+
JSONRPCNotificationSchema,
|
155
|
+
JSONRPCResponseSchema,
|
156
|
+
JSONRPCErrorSchema
|
157
|
+
]);
|
158
|
+
|
159
|
+
// errors/index.ts
|
160
|
+
var import_provider2 = require("@ai-sdk/provider");
|
161
|
+
|
162
|
+
// errors/mcp-client-error.ts
|
163
|
+
var import_provider = require("@ai-sdk/provider");
|
164
|
+
var name = "AI_MCPClientError";
|
165
|
+
var marker = `vercel.ai.error.${name}`;
|
166
|
+
var symbol = Symbol.for(marker);
|
167
|
+
var _a;
|
168
|
+
var MCPClientError = class extends import_provider.AISDKError {
|
169
|
+
constructor({
|
170
|
+
name: name2 = "MCPClientError",
|
171
|
+
message,
|
172
|
+
cause
|
173
|
+
}) {
|
174
|
+
super({ name: name2, message, cause });
|
175
|
+
this[_a] = true;
|
176
|
+
}
|
177
|
+
static isInstance(error) {
|
178
|
+
return import_provider.AISDKError.hasMarker(error, marker);
|
179
|
+
}
|
180
|
+
};
|
181
|
+
_a = symbol;
|
182
|
+
|
183
|
+
// mcp-stdio/create-child-process.ts
|
184
|
+
var import_node_child_process = require("child_process");
|
185
|
+
|
186
|
+
// mcp-stdio/get-environment.ts
|
187
|
+
function getEnvironment(customEnv) {
|
188
|
+
const DEFAULT_INHERITED_ENV_VARS = globalThis.process.platform === "win32" ? [
|
189
|
+
"APPDATA",
|
190
|
+
"HOMEDRIVE",
|
191
|
+
"HOMEPATH",
|
192
|
+
"LOCALAPPDATA",
|
193
|
+
"PATH",
|
194
|
+
"PROCESSOR_ARCHITECTURE",
|
195
|
+
"SYSTEMDRIVE",
|
196
|
+
"SYSTEMROOT",
|
197
|
+
"TEMP",
|
198
|
+
"USERNAME",
|
199
|
+
"USERPROFILE"
|
200
|
+
] : ["HOME", "LOGNAME", "PATH", "SHELL", "TERM", "USER"];
|
201
|
+
const env = customEnv ? { ...customEnv } : {};
|
202
|
+
for (const key of DEFAULT_INHERITED_ENV_VARS) {
|
203
|
+
const value = globalThis.process.env[key];
|
204
|
+
if (value === void 0) {
|
205
|
+
continue;
|
206
|
+
}
|
207
|
+
if (value.startsWith("()")) {
|
208
|
+
continue;
|
209
|
+
}
|
210
|
+
env[key] = value;
|
211
|
+
}
|
212
|
+
return env;
|
213
|
+
}
|
214
|
+
|
215
|
+
// mcp-stdio/create-child-process.ts
|
216
|
+
function createChildProcess(config, signal) {
|
217
|
+
var _a2, _b;
|
218
|
+
return (0, import_node_child_process.spawn)(config.command, (_a2 = config.args) != null ? _a2 : [], {
|
219
|
+
env: getEnvironment(config.env),
|
220
|
+
stdio: ["pipe", "pipe", (_b = config.stderr) != null ? _b : "inherit"],
|
221
|
+
shell: false,
|
222
|
+
signal,
|
223
|
+
windowsHide: globalThis.process.platform === "win32" && isElectron(),
|
224
|
+
cwd: config.cwd
|
225
|
+
});
|
226
|
+
}
|
227
|
+
function isElectron() {
|
228
|
+
return "type" in globalThis.process;
|
229
|
+
}
|
230
|
+
|
231
|
+
// mcp-stdio/mcp-stdio-transport.ts
|
232
|
+
var StdioMCPTransport = class {
|
233
|
+
constructor(server) {
|
234
|
+
this.abortController = new AbortController();
|
235
|
+
this.readBuffer = new ReadBuffer();
|
236
|
+
this.serverParams = server;
|
237
|
+
}
|
238
|
+
async start() {
|
239
|
+
if (this.process) {
|
240
|
+
throw new MCPClientError({
|
241
|
+
message: "StdioMCPTransport already started."
|
242
|
+
});
|
243
|
+
}
|
244
|
+
return new Promise((resolve, reject) => {
|
245
|
+
var _a2, _b, _c, _d;
|
246
|
+
try {
|
247
|
+
const process = createChildProcess(
|
248
|
+
this.serverParams,
|
249
|
+
this.abortController.signal
|
250
|
+
);
|
251
|
+
this.process = process;
|
252
|
+
this.process.on("error", (error) => {
|
253
|
+
var _a3, _b2;
|
254
|
+
if (error.name === "AbortError") {
|
255
|
+
(_a3 = this.onclose) == null ? void 0 : _a3.call(this);
|
256
|
+
return;
|
257
|
+
}
|
258
|
+
reject(error);
|
259
|
+
(_b2 = this.onerror) == null ? void 0 : _b2.call(this, error);
|
260
|
+
});
|
261
|
+
this.process.on("spawn", () => {
|
262
|
+
resolve();
|
263
|
+
});
|
264
|
+
this.process.on("close", (_code) => {
|
265
|
+
var _a3;
|
266
|
+
this.process = void 0;
|
267
|
+
(_a3 = this.onclose) == null ? void 0 : _a3.call(this);
|
268
|
+
});
|
269
|
+
(_a2 = this.process.stdin) == null ? void 0 : _a2.on("error", (error) => {
|
270
|
+
var _a3;
|
271
|
+
(_a3 = this.onerror) == null ? void 0 : _a3.call(this, error);
|
272
|
+
});
|
273
|
+
(_b = this.process.stdout) == null ? void 0 : _b.on("data", (chunk) => {
|
274
|
+
this.readBuffer.append(chunk);
|
275
|
+
this.processReadBuffer();
|
276
|
+
});
|
277
|
+
(_c = this.process.stdout) == null ? void 0 : _c.on("error", (error) => {
|
278
|
+
var _a3;
|
279
|
+
(_a3 = this.onerror) == null ? void 0 : _a3.call(this, error);
|
280
|
+
});
|
281
|
+
} catch (error) {
|
282
|
+
reject(error);
|
283
|
+
(_d = this.onerror) == null ? void 0 : _d.call(this, error);
|
284
|
+
}
|
285
|
+
});
|
286
|
+
}
|
287
|
+
processReadBuffer() {
|
288
|
+
var _a2, _b;
|
289
|
+
while (true) {
|
290
|
+
try {
|
291
|
+
const message = this.readBuffer.readMessage();
|
292
|
+
if (message === null) {
|
293
|
+
break;
|
294
|
+
}
|
295
|
+
(_a2 = this.onmessage) == null ? void 0 : _a2.call(this, message);
|
296
|
+
} catch (error) {
|
297
|
+
(_b = this.onerror) == null ? void 0 : _b.call(this, error);
|
298
|
+
}
|
299
|
+
}
|
300
|
+
}
|
301
|
+
async close() {
|
302
|
+
this.abortController.abort();
|
303
|
+
this.process = void 0;
|
304
|
+
this.readBuffer.clear();
|
305
|
+
}
|
306
|
+
send(message) {
|
307
|
+
return new Promise((resolve) => {
|
308
|
+
var _a2;
|
309
|
+
if (!((_a2 = this.process) == null ? void 0 : _a2.stdin)) {
|
310
|
+
throw new MCPClientError({
|
311
|
+
message: "StdioClientTransport not connected"
|
312
|
+
});
|
313
|
+
}
|
314
|
+
const json = serializeMessage(message);
|
315
|
+
if (this.process.stdin.write(json)) {
|
316
|
+
resolve();
|
317
|
+
} else {
|
318
|
+
this.process.stdin.once("drain", resolve);
|
319
|
+
}
|
320
|
+
});
|
321
|
+
}
|
322
|
+
};
|
323
|
+
var ReadBuffer = class {
|
324
|
+
append(chunk) {
|
325
|
+
this.buffer = this.buffer ? Buffer.concat([this.buffer, chunk]) : chunk;
|
326
|
+
}
|
327
|
+
readMessage() {
|
328
|
+
if (!this.buffer)
|
329
|
+
return null;
|
330
|
+
const index = this.buffer.indexOf("\n");
|
331
|
+
if (index === -1) {
|
332
|
+
return null;
|
333
|
+
}
|
334
|
+
const line = this.buffer.toString("utf8", 0, index);
|
335
|
+
this.buffer = this.buffer.subarray(index + 1);
|
336
|
+
return deserializeMessage(line);
|
337
|
+
}
|
338
|
+
clear() {
|
339
|
+
this.buffer = void 0;
|
340
|
+
}
|
341
|
+
};
|
342
|
+
function serializeMessage(message) {
|
343
|
+
return JSON.stringify(message) + "\n";
|
344
|
+
}
|
345
|
+
function deserializeMessage(line) {
|
346
|
+
return JSONRPCMessageSchema.parse(JSON.parse(line));
|
347
|
+
}
|
348
|
+
// Annotate the CommonJS export names for ESM import in node:
|
349
|
+
0 && (module.exports = {
|
350
|
+
Experimental_StdioMCPTransport
|
351
|
+
});
|
352
|
+
//# sourceMappingURL=index.js.map
|