wave-agent-sdk 0.12.7 → 0.12.8
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/builtin/skills/settings/SKILL.md +1 -0
- package/dist/managers/mcpManager.d.ts.map +1 -1
- package/dist/managers/mcpManager.js +59 -21
- package/dist/types/mcp.d.ts +1 -0
- package/dist/types/mcp.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/managers/mcpManager.ts +76 -29
- package/src/types/mcp.ts +1 -0
|
@@ -89,6 +89,7 @@ For detailed guidance on creating subagents, see [SUBAGENTS.md](${WAVE_SKILL_DIR
|
|
|
89
89
|
### 9. Other Settings
|
|
90
90
|
- `language`: Preferred language for agent communication (e.g., `"en"`, `"zh"`).
|
|
91
91
|
- `autoMemoryEnabled`: Enable or disable auto-memory (default: `true`).
|
|
92
|
+
- `autoMemoryFrequency`: Frequency of auto-memory extraction turns (default: `1`).
|
|
92
93
|
|
|
93
94
|
## How to use this skill
|
|
94
95
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcpManager.d.ts","sourceRoot":"","sources":["../../src/managers/mcpManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcpManager.d.ts","sourceRoot":"","sources":["../../src/managers/mcpManager.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAEjE,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EACV,MAAM,EACN,eAAe,EACf,SAAS,EACT,OAAO,EACP,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAQ3B,MAAM,WAAW,mBAAmB;IAClC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;CACxD;AAID,MAAM,WAAW,i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E,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC;QACT,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,SAAS,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KACtD,CAAC;YAsDY,uBAAuB;IA8D/B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAS9B;;OAEG;IACH,iBAAiB,IAAI,UAAU,EAAE;IA6BjC;;OAEG;IACH,iBAAiB,IAAI,0BAA0B,EAAE;IAIjD;;OAEG;IACG,wBAAwB,CAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC;IActB;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAcjC"}
|
|
@@ -3,6 +3,7 @@ import { join } from "path";
|
|
|
3
3
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
4
4
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
5
5
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
6
|
+
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
6
7
|
import { createMcpToolPlugin, findToolServer } from "../utils/mcpUtils.js";
|
|
7
8
|
import { logger } from "../utils/globalLogger.js";
|
|
8
9
|
export class McpManager {
|
|
@@ -165,8 +166,54 @@ export class McpManager {
|
|
|
165
166
|
try {
|
|
166
167
|
// Create transport - it will manage the process
|
|
167
168
|
let transport;
|
|
169
|
+
let client;
|
|
170
|
+
let tools = [];
|
|
171
|
+
const createClient = () => new Client({
|
|
172
|
+
name: "wave-code",
|
|
173
|
+
version: "1.0.0",
|
|
174
|
+
}, {
|
|
175
|
+
capabilities: {
|
|
176
|
+
tools: {},
|
|
177
|
+
},
|
|
178
|
+
});
|
|
168
179
|
if (server.config.url) {
|
|
169
|
-
|
|
180
|
+
const url = new URL(server.config.url);
|
|
181
|
+
const headers = server.config.headers;
|
|
182
|
+
try {
|
|
183
|
+
logger?.debug(`Attempting Streamable HTTP connection for ${name} at ${url.href}`);
|
|
184
|
+
const streamableTransport = new StreamableHTTPClientTransport(url, {
|
|
185
|
+
requestInit: { headers },
|
|
186
|
+
});
|
|
187
|
+
const streamableClient = createClient();
|
|
188
|
+
await streamableClient.connect(streamableTransport);
|
|
189
|
+
// Try to list tools to verify connection works
|
|
190
|
+
const toolsResponse = await streamableClient.listTools();
|
|
191
|
+
transport = streamableTransport;
|
|
192
|
+
client = streamableClient;
|
|
193
|
+
tools =
|
|
194
|
+
toolsResponse.tools?.map((tool) => ({
|
|
195
|
+
name: tool.name,
|
|
196
|
+
description: tool.description,
|
|
197
|
+
inputSchema: tool.inputSchema,
|
|
198
|
+
})) || [];
|
|
199
|
+
logger?.info(`Connected to MCP server ${name} using Streamable HTTP`);
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
logger?.debug(`Streamable HTTP failed for ${name}, falling back to SSE: ${error instanceof Error ? error.message : String(error)}`);
|
|
203
|
+
transport = new SSEClientTransport(url, {
|
|
204
|
+
requestInit: { headers },
|
|
205
|
+
});
|
|
206
|
+
client = createClient();
|
|
207
|
+
await client.connect(transport);
|
|
208
|
+
const toolsResponse = await client.listTools();
|
|
209
|
+
tools =
|
|
210
|
+
toolsResponse.tools?.map((tool) => ({
|
|
211
|
+
name: tool.name,
|
|
212
|
+
description: tool.description,
|
|
213
|
+
inputSchema: tool.inputSchema,
|
|
214
|
+
})) || [];
|
|
215
|
+
logger?.info(`Connected to MCP server ${name} using SSE (fallback)`);
|
|
216
|
+
}
|
|
170
217
|
}
|
|
171
218
|
else if (server.config.command) {
|
|
172
219
|
transport = new StdioClientTransport({
|
|
@@ -199,19 +246,19 @@ export class McpManager {
|
|
|
199
246
|
}
|
|
200
247
|
});
|
|
201
248
|
}
|
|
249
|
+
client = createClient();
|
|
250
|
+
await client.connect(transport);
|
|
251
|
+
const toolsResponse = await client.listTools();
|
|
252
|
+
tools =
|
|
253
|
+
toolsResponse.tools?.map((tool) => ({
|
|
254
|
+
name: tool.name,
|
|
255
|
+
description: tool.description,
|
|
256
|
+
inputSchema: tool.inputSchema,
|
|
257
|
+
})) || [];
|
|
202
258
|
}
|
|
203
259
|
else {
|
|
204
260
|
throw new Error(`MCP server ${name} configuration must include either 'command' or 'url'`);
|
|
205
261
|
}
|
|
206
|
-
// Create client
|
|
207
|
-
const client = new Client({
|
|
208
|
-
name: "wave-code",
|
|
209
|
-
version: "1.0.0",
|
|
210
|
-
}, {
|
|
211
|
-
capabilities: {
|
|
212
|
-
tools: {},
|
|
213
|
-
},
|
|
214
|
-
});
|
|
215
262
|
// Handle transport errors
|
|
216
263
|
transport.onerror = (error) => {
|
|
217
264
|
logger?.error(`MCP Server ${name} transport error:`, error);
|
|
@@ -229,20 +276,11 @@ export class McpManager {
|
|
|
229
276
|
toolCount: 0,
|
|
230
277
|
});
|
|
231
278
|
};
|
|
232
|
-
//
|
|
233
|
-
await client.connect(transport);
|
|
234
|
-
// List available tools
|
|
235
|
-
const toolsResponse = await client.listTools();
|
|
236
|
-
const tools = toolsResponse.tools?.map((tool) => ({
|
|
237
|
-
name: tool.name,
|
|
238
|
-
description: tool.description,
|
|
239
|
-
inputSchema: tool.inputSchema,
|
|
240
|
-
})) || [];
|
|
241
|
-
// Store connection (we don't have direct process access with StdioClientTransport)
|
|
279
|
+
// Store connection
|
|
242
280
|
this.connections.set(name, {
|
|
243
281
|
client,
|
|
244
282
|
transport,
|
|
245
|
-
process: null,
|
|
283
|
+
process: null,
|
|
246
284
|
});
|
|
247
285
|
// Update status
|
|
248
286
|
this.updateServerStatus(name, {
|
package/dist/types/mcp.d.ts
CHANGED
package/dist/types/mcp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/types/mcp.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/types/mcp.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CAC7C;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,EAAE,cAAc,GAAG,WAAW,GAAG,YAAY,GAAG,OAAO,CAAC;IAC9D,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
|
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ import { join } from "path";
|
|
|
3
3
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
4
4
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
5
5
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
6
|
+
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
6
7
|
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
7
8
|
import { ChatCompletionFunctionTool } from "openai/resources.js";
|
|
8
9
|
import { createMcpToolPlugin, findToolServer } from "../utils/mcpUtils.js";
|
|
@@ -227,9 +228,70 @@ export class McpManager {
|
|
|
227
228
|
try {
|
|
228
229
|
// Create transport - it will manage the process
|
|
229
230
|
let transport: Transport;
|
|
231
|
+
let client: Client;
|
|
232
|
+
let tools: McpTool[] = [];
|
|
233
|
+
|
|
234
|
+
const createClient = () =>
|
|
235
|
+
new Client(
|
|
236
|
+
{
|
|
237
|
+
name: "wave-code",
|
|
238
|
+
version: "1.0.0",
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
capabilities: {
|
|
242
|
+
tools: {},
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
);
|
|
230
246
|
|
|
231
247
|
if (server.config.url) {
|
|
232
|
-
|
|
248
|
+
const url = new URL(server.config.url);
|
|
249
|
+
const headers = server.config.headers;
|
|
250
|
+
|
|
251
|
+
try {
|
|
252
|
+
logger?.debug(
|
|
253
|
+
`Attempting Streamable HTTP connection for ${name} at ${url.href}`,
|
|
254
|
+
);
|
|
255
|
+
const streamableTransport = new StreamableHTTPClientTransport(url, {
|
|
256
|
+
requestInit: { headers },
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
const streamableClient = createClient();
|
|
260
|
+
await streamableClient.connect(streamableTransport);
|
|
261
|
+
|
|
262
|
+
// Try to list tools to verify connection works
|
|
263
|
+
const toolsResponse = await streamableClient.listTools();
|
|
264
|
+
|
|
265
|
+
transport = streamableTransport;
|
|
266
|
+
client = streamableClient;
|
|
267
|
+
tools =
|
|
268
|
+
toolsResponse.tools?.map((tool) => ({
|
|
269
|
+
name: tool.name,
|
|
270
|
+
description: tool.description,
|
|
271
|
+
inputSchema: tool.inputSchema,
|
|
272
|
+
})) || [];
|
|
273
|
+
|
|
274
|
+
logger?.info(`Connected to MCP server ${name} using Streamable HTTP`);
|
|
275
|
+
} catch (error) {
|
|
276
|
+
logger?.debug(
|
|
277
|
+
`Streamable HTTP failed for ${name}, falling back to SSE: ${error instanceof Error ? error.message : String(error)}`,
|
|
278
|
+
);
|
|
279
|
+
transport = new SSEClientTransport(url, {
|
|
280
|
+
requestInit: { headers },
|
|
281
|
+
});
|
|
282
|
+
client = createClient();
|
|
283
|
+
await client.connect(transport);
|
|
284
|
+
|
|
285
|
+
const toolsResponse = await client.listTools();
|
|
286
|
+
tools =
|
|
287
|
+
toolsResponse.tools?.map((tool) => ({
|
|
288
|
+
name: tool.name,
|
|
289
|
+
description: tool.description,
|
|
290
|
+
inputSchema: tool.inputSchema,
|
|
291
|
+
})) || [];
|
|
292
|
+
|
|
293
|
+
logger?.info(`Connected to MCP server ${name} using SSE (fallback)`);
|
|
294
|
+
}
|
|
233
295
|
} else if (server.config.command) {
|
|
234
296
|
transport = new StdioClientTransport({
|
|
235
297
|
command: server.config.command,
|
|
@@ -262,25 +324,23 @@ export class McpManager {
|
|
|
262
324
|
}
|
|
263
325
|
});
|
|
264
326
|
}
|
|
327
|
+
|
|
328
|
+
client = createClient();
|
|
329
|
+
await client.connect(transport);
|
|
330
|
+
|
|
331
|
+
const toolsResponse = await client.listTools();
|
|
332
|
+
tools =
|
|
333
|
+
toolsResponse.tools?.map((tool) => ({
|
|
334
|
+
name: tool.name,
|
|
335
|
+
description: tool.description,
|
|
336
|
+
inputSchema: tool.inputSchema,
|
|
337
|
+
})) || [];
|
|
265
338
|
} else {
|
|
266
339
|
throw new Error(
|
|
267
340
|
`MCP server ${name} configuration must include either 'command' or 'url'`,
|
|
268
341
|
);
|
|
269
342
|
}
|
|
270
343
|
|
|
271
|
-
// Create client
|
|
272
|
-
const client = new Client(
|
|
273
|
-
{
|
|
274
|
-
name: "wave-code",
|
|
275
|
-
version: "1.0.0",
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
capabilities: {
|
|
279
|
-
tools: {},
|
|
280
|
-
},
|
|
281
|
-
},
|
|
282
|
-
);
|
|
283
|
-
|
|
284
344
|
// Handle transport errors
|
|
285
345
|
transport.onerror = (error: Error) => {
|
|
286
346
|
logger?.error(`MCP Server ${name} transport error:`, error);
|
|
@@ -300,24 +360,11 @@ export class McpManager {
|
|
|
300
360
|
});
|
|
301
361
|
};
|
|
302
362
|
|
|
303
|
-
//
|
|
304
|
-
await client.connect(transport);
|
|
305
|
-
|
|
306
|
-
// List available tools
|
|
307
|
-
const toolsResponse = await client.listTools();
|
|
308
|
-
|
|
309
|
-
const tools: McpTool[] =
|
|
310
|
-
toolsResponse.tools?.map((tool) => ({
|
|
311
|
-
name: tool.name,
|
|
312
|
-
description: tool.description,
|
|
313
|
-
inputSchema: tool.inputSchema,
|
|
314
|
-
})) || [];
|
|
315
|
-
|
|
316
|
-
// Store connection (we don't have direct process access with StdioClientTransport)
|
|
363
|
+
// Store connection
|
|
317
364
|
this.connections.set(name, {
|
|
318
365
|
client,
|
|
319
366
|
transport,
|
|
320
|
-
process: null,
|
|
367
|
+
process: null,
|
|
321
368
|
});
|
|
322
369
|
|
|
323
370
|
// Update status
|