@quantish/agent 0.1.31 → 0.1.33
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/dist/index.js +18 -52
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -251,27 +251,17 @@ var MCPClient = class {
|
|
|
251
251
|
if (this.toolsCache) {
|
|
252
252
|
return this.toolsCache;
|
|
253
253
|
}
|
|
254
|
+
const headers = {
|
|
255
|
+
"Content-Type": "application/json",
|
|
256
|
+
"x-api-key": this.apiKey
|
|
257
|
+
};
|
|
254
258
|
if (this.source === "discovery") {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
headers: {
|
|
258
|
-
"Content-Type": "application/json",
|
|
259
|
-
"X-API-Key": this.apiKey
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
if (!response2.ok) {
|
|
263
|
-
throw new Error(`MCP server error: ${response2.status} ${response2.statusText}`);
|
|
264
|
-
}
|
|
265
|
-
const data2 = await response2.json();
|
|
266
|
-
this.toolsCache = data2.tools || [];
|
|
267
|
-
return this.toolsCache;
|
|
259
|
+
headers["Accept"] = "application/json, text/event-stream";
|
|
260
|
+
headers["X-API-Key"] = this.apiKey;
|
|
268
261
|
}
|
|
269
262
|
const response = await fetch(this.baseUrl, {
|
|
270
263
|
method: "POST",
|
|
271
|
-
headers
|
|
272
|
-
"Content-Type": "application/json",
|
|
273
|
-
"x-api-key": this.apiKey
|
|
274
|
-
},
|
|
264
|
+
headers,
|
|
275
265
|
body: JSON.stringify({
|
|
276
266
|
jsonrpc: "2.0",
|
|
277
267
|
method: "tools/list",
|
|
@@ -292,45 +282,20 @@ var MCPClient = class {
|
|
|
292
282
|
}
|
|
293
283
|
/**
|
|
294
284
|
* Call a tool on the MCP server
|
|
295
|
-
*
|
|
285
|
+
* All MCPs use JSON-RPC format
|
|
296
286
|
*/
|
|
297
287
|
async callTool(name, args) {
|
|
288
|
+
const headers = {
|
|
289
|
+
"Content-Type": "application/json",
|
|
290
|
+
"x-api-key": this.apiKey
|
|
291
|
+
};
|
|
298
292
|
if (this.source === "discovery") {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
headers: {
|
|
302
|
-
"Content-Type": "application/json",
|
|
303
|
-
"X-API-Key": this.apiKey
|
|
304
|
-
},
|
|
305
|
-
body: JSON.stringify({
|
|
306
|
-
name,
|
|
307
|
-
arguments: args
|
|
308
|
-
})
|
|
309
|
-
});
|
|
310
|
-
if (!response2.ok) {
|
|
311
|
-
return {
|
|
312
|
-
success: false,
|
|
313
|
-
error: `MCP server error: ${response2.status} ${response2.statusText}`
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
const data2 = await response2.json();
|
|
317
|
-
if (data2.error) {
|
|
318
|
-
return {
|
|
319
|
-
success: false,
|
|
320
|
-
error: typeof data2.error === "string" ? data2.error : JSON.stringify(data2.error)
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
return {
|
|
324
|
-
success: true,
|
|
325
|
-
data: data2.data ?? data2.result ?? data2
|
|
326
|
-
};
|
|
293
|
+
headers["Accept"] = "application/json, text/event-stream";
|
|
294
|
+
headers["X-API-Key"] = this.apiKey;
|
|
327
295
|
}
|
|
328
296
|
const response = await fetch(this.baseUrl, {
|
|
329
297
|
method: "POST",
|
|
330
|
-
headers
|
|
331
|
-
"Content-Type": "application/json",
|
|
332
|
-
"x-api-key": this.apiKey
|
|
333
|
-
},
|
|
298
|
+
headers,
|
|
334
299
|
body: JSON.stringify({
|
|
335
300
|
jsonrpc: "2.0",
|
|
336
301
|
method: "tools/call",
|
|
@@ -3723,7 +3688,8 @@ var Agent = class {
|
|
|
3723
3688
|
}
|
|
3724
3689
|
const allTools = await this.getAllTools();
|
|
3725
3690
|
const systemPrompt = this.config.systemPrompt ?? DEFAULT_SYSTEM_PROMPT;
|
|
3726
|
-
const
|
|
3691
|
+
const defaultModel = this.config.provider === "openrouter" ? "z-ai/glm-4.7" : DEFAULT_MODEL;
|
|
3692
|
+
const model = this.config.model ?? defaultModel;
|
|
3727
3693
|
const maxTokens = this.config.maxTokens ?? 8192;
|
|
3728
3694
|
this.llmProvider = createLLMProvider({
|
|
3729
3695
|
provider: this.config.provider || "anthropic",
|
|
@@ -5456,7 +5422,7 @@ Stopped ${count} background process${count > 1 ? "es" : ""}.`);
|
|
|
5456
5422
|
}
|
|
5457
5423
|
|
|
5458
5424
|
// src/index.ts
|
|
5459
|
-
var VERSION = "0.1.
|
|
5425
|
+
var VERSION = "0.1.33";
|
|
5460
5426
|
function cleanup() {
|
|
5461
5427
|
if (processManager.hasRunning()) {
|
|
5462
5428
|
const count = processManager.runningCount();
|