@mcpc-tech/unplugin-dev-inspector-mcp 0.0.12 → 0.0.14
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/client/dist/inspector.iife.js +1 -5
- package/dist/config-updater.cjs +710 -290
- package/dist/config-updater.js +646 -226
- package/dist/index.cjs +67 -2
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +67 -2
- package/package.json +2 -2
package/dist/config-updater.cjs
CHANGED
|
@@ -9,6 +9,7 @@ let __modelcontextprotocol_sdk_server_index_js = require("@modelcontextprotocol/
|
|
|
9
9
|
let node_module = require("node:module");
|
|
10
10
|
let node_stream = require("node:stream");
|
|
11
11
|
let stream = require("stream");
|
|
12
|
+
let node_net = require("node:net");
|
|
12
13
|
let node_crypto = require("node:crypto");
|
|
13
14
|
let node_path = require("node:path");
|
|
14
15
|
node_path = require_chunk.__toESM(node_path);
|
|
@@ -34,7 +35,6 @@ let url = require("url");
|
|
|
34
35
|
let ai = require("ai");
|
|
35
36
|
let __agentclientprotocol_sdk = require("@agentclientprotocol/sdk");
|
|
36
37
|
let node_child_process = require("node:child_process");
|
|
37
|
-
let node_fs = require("node:fs");
|
|
38
38
|
let fs_promises = require("fs/promises");
|
|
39
39
|
|
|
40
40
|
//#region ../../node_modules/.pnpm/@mcpc-tech+cmcp@0.0.15/node_modules/@mcpc-tech/cmcp/index.mjs
|
|
@@ -125,31 +125,31 @@ var ClientExecServer = class {
|
|
|
125
125
|
const registeredTools = [];
|
|
126
126
|
const conflicts = [];
|
|
127
127
|
const clientToolNames = /* @__PURE__ */ new Set();
|
|
128
|
-
for (const tool$
|
|
129
|
-
const toolName = this.getToolName(clientId, tool$
|
|
128
|
+
for (const tool$2 of tools) {
|
|
129
|
+
const toolName = this.getToolName(clientId, tool$2.name);
|
|
130
130
|
if (this.tools.has(toolName)) {
|
|
131
131
|
const existingOwner = this.toolToClient.get(toolName);
|
|
132
132
|
const isPredefined = this.predefinedTools.has(toolName);
|
|
133
133
|
if (this.useNamespacing) {
|
|
134
134
|
console.error(`[cmcp] Unexpected tool name conflict with namespacing: ${toolName}`);
|
|
135
|
-
conflicts.push(tool$
|
|
135
|
+
conflicts.push(tool$2.name);
|
|
136
136
|
continue;
|
|
137
137
|
} else if (isPredefined && existingOwner === this.clientId) {
|
|
138
|
-
console.log(`[cmcp] Client ${clientId} providing implementation for predefined tool: ${tool$
|
|
138
|
+
console.log(`[cmcp] Client ${clientId} providing implementation for predefined tool: ${tool$2.name}`);
|
|
139
139
|
this.predefinedTools.delete(toolName);
|
|
140
140
|
} else {
|
|
141
|
-
console.warn(`[cmcp] Tool ${tool$
|
|
142
|
-
conflicts.push(tool$
|
|
141
|
+
console.warn(`[cmcp] Tool ${tool$2.name} already exists, owned by client ${existingOwner}. Skipping registration for client ${clientId}`);
|
|
142
|
+
conflicts.push(tool$2.name);
|
|
143
143
|
continue;
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
this.tools.set(toolName, {
|
|
147
|
-
name: this.useNamespacing ? tool$
|
|
148
|
-
description: this.useNamespacing ? `[${clientId}] ${tool$
|
|
149
|
-
inputSchema: tool$
|
|
147
|
+
name: this.useNamespacing ? tool$2.name : toolName,
|
|
148
|
+
description: this.useNamespacing ? `[${clientId}] ${tool$2.description}` : tool$2.description,
|
|
149
|
+
inputSchema: tool$2.inputSchema
|
|
150
150
|
});
|
|
151
151
|
clientToolNames.add(toolName);
|
|
152
|
-
registeredTools.push(tool$
|
|
152
|
+
registeredTools.push(tool$2.name);
|
|
153
153
|
this.toolToClient.set(toolName, clientId);
|
|
154
154
|
}
|
|
155
155
|
this.clientTools.set(clientId, clientToolNames);
|
|
@@ -181,12 +181,12 @@ var ClientExecServer = class {
|
|
|
181
181
|
registerClientToolSchemas(tools) {
|
|
182
182
|
this.unregisterClientTools(this.clientId);
|
|
183
183
|
const clientToolNames = /* @__PURE__ */ new Set();
|
|
184
|
-
for (const tool$
|
|
185
|
-
const toolName = this.getToolName(this.clientId, tool$
|
|
184
|
+
for (const tool$2 of tools) {
|
|
185
|
+
const toolName = this.getToolName(this.clientId, tool$2.name);
|
|
186
186
|
this.tools.set(toolName, {
|
|
187
|
-
name: tool$
|
|
188
|
-
description: tool$
|
|
189
|
-
inputSchema: tool$
|
|
187
|
+
name: tool$2.name,
|
|
188
|
+
description: tool$2.description,
|
|
189
|
+
inputSchema: tool$2.inputSchema
|
|
190
190
|
});
|
|
191
191
|
this.toolToClient.set(toolName, this.clientId);
|
|
192
192
|
this.predefinedTools.add(toolName);
|
|
@@ -241,13 +241,13 @@ var ClientExecServer = class {
|
|
|
241
241
|
return toolCallHandler?.(request$1, extra);
|
|
242
242
|
}
|
|
243
243
|
const requestId = crypto.randomUUID();
|
|
244
|
-
const resultPromise = new Promise((resolve$
|
|
244
|
+
const resultPromise = new Promise((resolve$3, reject) => {
|
|
245
245
|
const timeout = setTimeout(() => {
|
|
246
246
|
this.pendingRequests.delete(requestId);
|
|
247
247
|
reject(new __modelcontextprotocol_sdk_types_js.McpError(__modelcontextprotocol_sdk_types_js.ErrorCode.InternalError, `Tool execution timeout for ${name}`));
|
|
248
248
|
}, this.requestTimeoutMs);
|
|
249
249
|
this.pendingRequests.set(requestId, {
|
|
250
|
-
resolve: resolve$
|
|
250
|
+
resolve: resolve$3,
|
|
251
251
|
reject,
|
|
252
252
|
timeout
|
|
253
253
|
});
|
|
@@ -26551,9 +26551,9 @@ var require_dispatcher_base = /* @__PURE__ */ require_chunk.__commonJSMin(((expo
|
|
|
26551
26551
|
return this[kClosed$3];
|
|
26552
26552
|
}
|
|
26553
26553
|
close(callback) {
|
|
26554
|
-
if (callback === void 0) return new Promise((resolve$
|
|
26554
|
+
if (callback === void 0) return new Promise((resolve$3, reject) => {
|
|
26555
26555
|
this.close((err, data$1) => {
|
|
26556
|
-
return err ? reject(err) : resolve$
|
|
26556
|
+
return err ? reject(err) : resolve$3(data$1);
|
|
26557
26557
|
});
|
|
26558
26558
|
});
|
|
26559
26559
|
if (typeof callback !== "function") throw new InvalidArgumentError$27("invalid callback");
|
|
@@ -26582,9 +26582,9 @@ var require_dispatcher_base = /* @__PURE__ */ require_chunk.__commonJSMin(((expo
|
|
|
26582
26582
|
callback = err;
|
|
26583
26583
|
err = null;
|
|
26584
26584
|
}
|
|
26585
|
-
if (callback === void 0) return new Promise((resolve$
|
|
26585
|
+
if (callback === void 0) return new Promise((resolve$3, reject) => {
|
|
26586
26586
|
this.destroy(err, (err$1, data$1) => {
|
|
26587
|
-
return err$1 ? reject(err$1) : resolve$
|
|
26587
|
+
return err$1 ? reject(err$1) : resolve$3(data$1);
|
|
26588
26588
|
});
|
|
26589
26589
|
});
|
|
26590
26590
|
if (typeof callback !== "function") throw new InvalidArgumentError$27("invalid callback");
|
|
@@ -29585,8 +29585,8 @@ var require_promise$2 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, m
|
|
|
29585
29585
|
let res;
|
|
29586
29586
|
let rej;
|
|
29587
29587
|
return {
|
|
29588
|
-
promise: new Promise((resolve$
|
|
29589
|
-
res = resolve$
|
|
29588
|
+
promise: new Promise((resolve$3, reject) => {
|
|
29589
|
+
res = resolve$3;
|
|
29590
29590
|
rej = reject;
|
|
29591
29591
|
}),
|
|
29592
29592
|
resolve: res,
|
|
@@ -30696,10 +30696,10 @@ var require_client_h1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, m
|
|
|
30696
30696
|
cb();
|
|
30697
30697
|
}
|
|
30698
30698
|
}
|
|
30699
|
-
const waitForDrain = () => new Promise((resolve$
|
|
30699
|
+
const waitForDrain = () => new Promise((resolve$3, reject) => {
|
|
30700
30700
|
assert$23(callback === null);
|
|
30701
30701
|
if (socket[kError$2]) reject(socket[kError$2]);
|
|
30702
|
-
else callback = resolve$
|
|
30702
|
+
else callback = resolve$3;
|
|
30703
30703
|
});
|
|
30704
30704
|
socket.on("close", onDrain).on("drain", onDrain);
|
|
30705
30705
|
const writer = new AsyncWriter({
|
|
@@ -31227,10 +31227,10 @@ var require_client_h2 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, m
|
|
|
31227
31227
|
cb();
|
|
31228
31228
|
}
|
|
31229
31229
|
}
|
|
31230
|
-
const waitForDrain = () => new Promise((resolve$
|
|
31230
|
+
const waitForDrain = () => new Promise((resolve$3, reject) => {
|
|
31231
31231
|
assert$22(callback === null);
|
|
31232
31232
|
if (socket[kError$1]) reject(socket[kError$1]);
|
|
31233
|
-
else callback = resolve$
|
|
31233
|
+
else callback = resolve$3;
|
|
31234
31234
|
});
|
|
31235
31235
|
h2stream.on("close", onDrain).on("drain", onDrain);
|
|
31236
31236
|
try {
|
|
@@ -31390,13 +31390,13 @@ var require_client = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modu
|
|
|
31390
31390
|
return this[kNeedDrain$3] < 2;
|
|
31391
31391
|
}
|
|
31392
31392
|
[kClose$7]() {
|
|
31393
|
-
return new Promise((resolve$
|
|
31394
|
-
if (this[kSize$2]) this[kClosedResolve$1] = resolve$
|
|
31395
|
-
else resolve$
|
|
31393
|
+
return new Promise((resolve$3) => {
|
|
31394
|
+
if (this[kSize$2]) this[kClosedResolve$1] = resolve$3;
|
|
31395
|
+
else resolve$3(null);
|
|
31396
31396
|
});
|
|
31397
31397
|
}
|
|
31398
31398
|
[kDestroy$5](err) {
|
|
31399
|
-
return new Promise((resolve$
|
|
31399
|
+
return new Promise((resolve$3) => {
|
|
31400
31400
|
const requests = this[kQueue$1].splice(this[kPendingIdx]);
|
|
31401
31401
|
for (let i$4 = 0; i$4 < requests.length; i$4++) {
|
|
31402
31402
|
const request$1 = requests[i$4];
|
|
@@ -31407,7 +31407,7 @@ var require_client = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modu
|
|
|
31407
31407
|
this[kClosedResolve$1]();
|
|
31408
31408
|
this[kClosedResolve$1] = null;
|
|
31409
31409
|
}
|
|
31410
|
-
resolve$
|
|
31410
|
+
resolve$3(null);
|
|
31411
31411
|
};
|
|
31412
31412
|
if (this[kHTTPContext]) {
|
|
31413
31413
|
this[kHTTPContext].destroy(err, callback);
|
|
@@ -31761,8 +31761,8 @@ var require_pool_base = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, m
|
|
|
31761
31761
|
const closeAll = new Array(this[kClients$4].length);
|
|
31762
31762
|
for (let i$4 = 0; i$4 < this[kClients$4].length; i$4++) closeAll[i$4] = this[kClients$4][i$4].close();
|
|
31763
31763
|
return Promise.all(closeAll);
|
|
31764
|
-
} else return new Promise((resolve$
|
|
31765
|
-
this[kClosedResolve] = resolve$
|
|
31764
|
+
} else return new Promise((resolve$3) => {
|
|
31765
|
+
this[kClosedResolve] = resolve$3;
|
|
31766
31766
|
});
|
|
31767
31767
|
}
|
|
31768
31768
|
[kDestroy$4](err) {
|
|
@@ -32982,7 +32982,7 @@ var require_readable = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mo
|
|
|
32982
32982
|
const limit = opts?.limit && Number.isFinite(opts.limit) ? opts.limit : 128 * 1024;
|
|
32983
32983
|
if (signal?.aborted) return Promise.reject(signal.reason ?? new AbortError$1());
|
|
32984
32984
|
if (this._readableState.closeEmitted) return Promise.resolve(null);
|
|
32985
|
-
return new Promise((resolve$
|
|
32985
|
+
return new Promise((resolve$3, reject) => {
|
|
32986
32986
|
if (this[kContentLength$1] && this[kContentLength$1] > limit || this[kBytesRead] > limit) this.destroy(new AbortError$1());
|
|
32987
32987
|
if (signal) {
|
|
32988
32988
|
const onAbort = () => {
|
|
@@ -32992,9 +32992,9 @@ var require_readable = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mo
|
|
|
32992
32992
|
this.on("close", function() {
|
|
32993
32993
|
signal.removeEventListener("abort", onAbort);
|
|
32994
32994
|
if (signal.aborted) reject(signal.reason ?? new AbortError$1());
|
|
32995
|
-
else resolve$
|
|
32995
|
+
else resolve$3(null);
|
|
32996
32996
|
});
|
|
32997
|
-
} else this.on("close", resolve$
|
|
32997
|
+
} else this.on("close", resolve$3);
|
|
32998
32998
|
this.on("error", noop$6).on("data", () => {
|
|
32999
32999
|
if (this[kBytesRead] > limit) this.destroy();
|
|
33000
33000
|
}).resume();
|
|
@@ -33055,7 +33055,7 @@ var require_readable = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mo
|
|
|
33055
33055
|
*/
|
|
33056
33056
|
function consume(stream$3, type) {
|
|
33057
33057
|
assert$19(!stream$3[kConsume]);
|
|
33058
|
-
return new Promise((resolve$
|
|
33058
|
+
return new Promise((resolve$3, reject) => {
|
|
33059
33059
|
if (isUnusable(stream$3)) {
|
|
33060
33060
|
const rState = stream$3._readableState;
|
|
33061
33061
|
if (rState.destroyed && rState.closeEmitted === false) stream$3.on("error", reject).on("close", () => {
|
|
@@ -33066,7 +33066,7 @@ var require_readable = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mo
|
|
|
33066
33066
|
stream$3[kConsume] = {
|
|
33067
33067
|
type,
|
|
33068
33068
|
stream: stream$3,
|
|
33069
|
-
resolve: resolve$
|
|
33069
|
+
resolve: resolve$3,
|
|
33070
33070
|
reject,
|
|
33071
33071
|
length: 0,
|
|
33072
33072
|
body: []
|
|
@@ -33136,13 +33136,13 @@ var require_readable = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mo
|
|
|
33136
33136
|
* @returns {void}
|
|
33137
33137
|
*/
|
|
33138
33138
|
function consumeEnd(consume$1, encoding) {
|
|
33139
|
-
const { type, body, resolve: resolve$
|
|
33139
|
+
const { type, body, resolve: resolve$3, stream: stream$3, length } = consume$1;
|
|
33140
33140
|
try {
|
|
33141
|
-
if (type === "text") resolve$
|
|
33142
|
-
else if (type === "json") resolve$
|
|
33143
|
-
else if (type === "arrayBuffer") resolve$
|
|
33144
|
-
else if (type === "blob") resolve$
|
|
33145
|
-
else if (type === "bytes") resolve$
|
|
33141
|
+
if (type === "text") resolve$3(chunksDecode(body, length, encoding));
|
|
33142
|
+
else if (type === "json") resolve$3(JSON.parse(chunksDecode(body, length, encoding)));
|
|
33143
|
+
else if (type === "arrayBuffer") resolve$3(chunksConcat(body, length).buffer);
|
|
33144
|
+
else if (type === "blob") resolve$3(new Blob(body, { type: stream$3[kContentType] }));
|
|
33145
|
+
else if (type === "bytes") resolve$3(chunksConcat(body, length));
|
|
33146
33146
|
consumeFinish(consume$1);
|
|
33147
33147
|
} catch (err) {
|
|
33148
33148
|
stream$3.destroy(err);
|
|
@@ -33310,9 +33310,9 @@ var require_api_request = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
|
|
|
33310
33310
|
}
|
|
33311
33311
|
};
|
|
33312
33312
|
function request(opts, callback) {
|
|
33313
|
-
if (callback === void 0) return new Promise((resolve$
|
|
33313
|
+
if (callback === void 0) return new Promise((resolve$3, reject) => {
|
|
33314
33314
|
request.call(this, opts, (err, data$1) => {
|
|
33315
|
-
return err ? reject(err) : resolve$
|
|
33315
|
+
return err ? reject(err) : resolve$3(data$1);
|
|
33316
33316
|
});
|
|
33317
33317
|
});
|
|
33318
33318
|
try {
|
|
@@ -33482,9 +33482,9 @@ var require_api_stream = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
|
|
|
33482
33482
|
}
|
|
33483
33483
|
};
|
|
33484
33484
|
function stream$1(opts, factory$1, callback) {
|
|
33485
|
-
if (callback === void 0) return new Promise((resolve$
|
|
33485
|
+
if (callback === void 0) return new Promise((resolve$3, reject) => {
|
|
33486
33486
|
stream$1.call(this, opts, factory$1, (err, data$1) => {
|
|
33487
|
-
return err ? reject(err) : resolve$
|
|
33487
|
+
return err ? reject(err) : resolve$3(data$1);
|
|
33488
33488
|
});
|
|
33489
33489
|
});
|
|
33490
33490
|
try {
|
|
@@ -33727,9 +33727,9 @@ var require_api_upgrade = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
|
|
|
33727
33727
|
}
|
|
33728
33728
|
};
|
|
33729
33729
|
function upgrade(opts, callback) {
|
|
33730
|
-
if (callback === void 0) return new Promise((resolve$
|
|
33730
|
+
if (callback === void 0) return new Promise((resolve$3, reject) => {
|
|
33731
33731
|
upgrade.call(this, opts, (err, data$1) => {
|
|
33732
|
-
return err ? reject(err) : resolve$
|
|
33732
|
+
return err ? reject(err) : resolve$3(data$1);
|
|
33733
33733
|
});
|
|
33734
33734
|
});
|
|
33735
33735
|
try {
|
|
@@ -33808,9 +33808,9 @@ var require_api_connect = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
|
|
|
33808
33808
|
}
|
|
33809
33809
|
};
|
|
33810
33810
|
function connect(opts, callback) {
|
|
33811
|
-
if (callback === void 0) return new Promise((resolve$
|
|
33811
|
+
if (callback === void 0) return new Promise((resolve$3, reject) => {
|
|
33812
33812
|
connect.call(this, opts, (err, data$1) => {
|
|
33813
|
-
return err ? reject(err) : resolve$
|
|
33813
|
+
return err ? reject(err) : resolve$3(data$1);
|
|
33814
33814
|
});
|
|
33815
33815
|
});
|
|
33816
33816
|
try {
|
|
@@ -34868,7 +34868,7 @@ var require_snapshot_utils = /* @__PURE__ */ require_chunk.__commonJSMin(((expor
|
|
|
34868
34868
|
//#region ../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/mock/snapshot-recorder.js
|
|
34869
34869
|
var require_snapshot_recorder = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
|
|
34870
34870
|
const { writeFile: writeFile$1, readFile: readFile$1, mkdir: mkdir$1 } = require("node:fs/promises");
|
|
34871
|
-
const { dirname: dirname$
|
|
34871
|
+
const { dirname: dirname$1, resolve: resolve$2 } = require("node:path");
|
|
34872
34872
|
const { setTimeout: setTimeout$1, clearTimeout: clearTimeout$1 } = require("node:timers");
|
|
34873
34873
|
const { InvalidArgumentError: InvalidArgumentError$6, UndiciError: UndiciError$1 } = require_errors$1();
|
|
34874
34874
|
const { hashId, isUrlExcludedFactory, normalizeHeaders: normalizeHeaders$2, createHeaderFilters } = require_snapshot_utils();
|
|
@@ -35126,7 +35126,7 @@ var require_snapshot_recorder = /* @__PURE__ */ require_chunk.__commonJSMin(((ex
|
|
|
35126
35126
|
const path$3 = filePath || this.#snapshotPath;
|
|
35127
35127
|
if (!path$3) throw new InvalidArgumentError$6("Snapshot path is required");
|
|
35128
35128
|
try {
|
|
35129
|
-
const data$1 = await readFile$1(resolve$
|
|
35129
|
+
const data$1 = await readFile$1(resolve$2(path$3), "utf8");
|
|
35130
35130
|
const parsed = JSON.parse(data$1);
|
|
35131
35131
|
if (Array.isArray(parsed)) {
|
|
35132
35132
|
this.#snapshots.clear();
|
|
@@ -35146,8 +35146,8 @@ var require_snapshot_recorder = /* @__PURE__ */ require_chunk.__commonJSMin(((ex
|
|
|
35146
35146
|
async saveSnapshots(filePath) {
|
|
35147
35147
|
const path$3 = filePath || this.#snapshotPath;
|
|
35148
35148
|
if (!path$3) throw new InvalidArgumentError$6("Snapshot path is required");
|
|
35149
|
-
const resolvedPath = resolve$
|
|
35150
|
-
await mkdir$1(dirname$
|
|
35149
|
+
const resolvedPath = resolve$2(path$3);
|
|
35150
|
+
await mkdir$1(dirname$1(resolvedPath), { recursive: true });
|
|
35151
35151
|
const data$1 = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
|
|
35152
35152
|
hash,
|
|
35153
35153
|
snapshot
|
|
@@ -40052,7 +40052,7 @@ var require_fetch = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modul
|
|
|
40052
40052
|
const url$1 = requestCurrentURL(request$1);
|
|
40053
40053
|
/** @type {import('../../..').Agent} */
|
|
40054
40054
|
const agent = fetchParams.controller.dispatcher;
|
|
40055
|
-
return new Promise((resolve$
|
|
40055
|
+
return new Promise((resolve$3, reject) => agent.dispatch({
|
|
40056
40056
|
path: url$1.pathname + url$1.search,
|
|
40057
40057
|
origin: url$1.origin,
|
|
40058
40058
|
method: request$1.method,
|
|
@@ -40113,7 +40113,7 @@ var require_fetch = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modul
|
|
|
40113
40113
|
}
|
|
40114
40114
|
}
|
|
40115
40115
|
const onError$1 = this.onError.bind(this);
|
|
40116
|
-
resolve$
|
|
40116
|
+
resolve$3({
|
|
40117
40117
|
status,
|
|
40118
40118
|
statusText,
|
|
40119
40119
|
headersList,
|
|
@@ -40144,7 +40144,7 @@ var require_fetch = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modul
|
|
|
40144
40144
|
if (status !== 101) return;
|
|
40145
40145
|
const headersList = new HeadersList();
|
|
40146
40146
|
for (let i$4 = 0; i$4 < rawHeaders.length; i$4 += 2) headersList.append(bufferToLowerCasedHeaderName(rawHeaders[i$4]), rawHeaders[i$4 + 1].toString("latin1"), true);
|
|
40147
|
-
resolve$
|
|
40147
|
+
resolve$3({
|
|
40148
40148
|
status,
|
|
40149
40149
|
statusText: STATUS_CODES[status],
|
|
40150
40150
|
headersList,
|
|
@@ -46836,7 +46836,7 @@ var require_compile = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =>
|
|
|
46836
46836
|
ref = (0, resolve_1$1.resolveUrl)(this.opts.uriResolver, baseId, ref);
|
|
46837
46837
|
const schOrFunc = root$2.refs[ref];
|
|
46838
46838
|
if (schOrFunc) return schOrFunc;
|
|
46839
|
-
let _sch = resolve$
|
|
46839
|
+
let _sch = resolve$1.call(this, root$2, ref);
|
|
46840
46840
|
if (_sch === void 0) {
|
|
46841
46841
|
const schema = (_a$2 = root$2.localRefs) === null || _a$2 === void 0 ? void 0 : _a$2[ref];
|
|
46842
46842
|
const { schemaId } = this.opts;
|
|
@@ -46862,7 +46862,7 @@ var require_compile = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =>
|
|
|
46862
46862
|
function sameSchemaEnv(s1, s2) {
|
|
46863
46863
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
46864
46864
|
}
|
|
46865
|
-
function resolve$
|
|
46865
|
+
function resolve$1(root$2, ref) {
|
|
46866
46866
|
let sch;
|
|
46867
46867
|
while (typeof (sch = this.refs[ref]) == "string") ref = sch;
|
|
46868
46868
|
return sch || this.schemas[ref] || resolveSchema.call(this, root$2, ref);
|
|
@@ -47435,7 +47435,7 @@ var require_fast_uri = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mo
|
|
|
47435
47435
|
* @param {import('./types/index').Options} [options]
|
|
47436
47436
|
* @returns {string}
|
|
47437
47437
|
*/
|
|
47438
|
-
function resolve
|
|
47438
|
+
function resolve(baseURI, relativeURI, options) {
|
|
47439
47439
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
47440
47440
|
const resolved = resolveComponent(parse$7(baseURI, schemelessOptions), parse$7(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
47441
47441
|
schemelessOptions.skipEscape = true;
|
|
@@ -47634,7 +47634,7 @@ var require_fast_uri = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mo
|
|
|
47634
47634
|
const fastUri = {
|
|
47635
47635
|
SCHEMES,
|
|
47636
47636
|
normalize,
|
|
47637
|
-
resolve
|
|
47637
|
+
resolve,
|
|
47638
47638
|
resolveComponent,
|
|
47639
47639
|
equal: equal$1,
|
|
47640
47640
|
serialize,
|
|
@@ -56265,8 +56265,8 @@ var require_promise$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =
|
|
|
56265
56265
|
exports.Deferred = void 0;
|
|
56266
56266
|
var Deferred$1 = class {
|
|
56267
56267
|
constructor() {
|
|
56268
|
-
this._promise = new Promise((resolve$
|
|
56269
|
-
this._resolve = resolve$
|
|
56268
|
+
this._promise = new Promise((resolve$3, reject) => {
|
|
56269
|
+
this._resolve = resolve$3;
|
|
56270
56270
|
this._reject = reject;
|
|
56271
56271
|
});
|
|
56272
56272
|
}
|
|
@@ -56332,10 +56332,10 @@ var require_exporter$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports)
|
|
|
56332
56332
|
* Shared functionality used by Exporters while exporting data, including suppression of Traces.
|
|
56333
56333
|
*/
|
|
56334
56334
|
function _export$1(exporter, arg) {
|
|
56335
|
-
return new Promise((resolve$
|
|
56335
|
+
return new Promise((resolve$3) => {
|
|
56336
56336
|
api_1$50.context.with((0, suppress_tracing_1$5.suppressTracing)(api_1$50.context.active()), () => {
|
|
56337
56337
|
exporter.export(arg, (result) => {
|
|
56338
|
-
resolve$
|
|
56338
|
+
resolve$3(result);
|
|
56339
56339
|
});
|
|
56340
56340
|
});
|
|
56341
56341
|
});
|
|
@@ -57596,19 +57596,19 @@ var require_BatchSpanProcessorBase = /* @__PURE__ */ require_chunk.__commonJSMin
|
|
|
57596
57596
|
* for all other cases _flush should be used
|
|
57597
57597
|
* */
|
|
57598
57598
|
_flushAll() {
|
|
57599
|
-
return new Promise((resolve$
|
|
57599
|
+
return new Promise((resolve$3, reject) => {
|
|
57600
57600
|
const promises = [];
|
|
57601
57601
|
const count = Math.ceil(this._finishedSpans.length / this._maxExportBatchSize);
|
|
57602
57602
|
for (let i$4 = 0, j = count; i$4 < j; i$4++) promises.push(this._flushOneBatch());
|
|
57603
57603
|
Promise.all(promises).then(() => {
|
|
57604
|
-
resolve$
|
|
57604
|
+
resolve$3();
|
|
57605
57605
|
}).catch(reject);
|
|
57606
57606
|
});
|
|
57607
57607
|
}
|
|
57608
57608
|
_flushOneBatch() {
|
|
57609
57609
|
this._clearTimer();
|
|
57610
57610
|
if (this._finishedSpans.length === 0) return Promise.resolve();
|
|
57611
|
-
return new Promise((resolve$
|
|
57611
|
+
return new Promise((resolve$3, reject) => {
|
|
57612
57612
|
const timer = setTimeout(() => {
|
|
57613
57613
|
reject(/* @__PURE__ */ new Error("Timeout"));
|
|
57614
57614
|
}, this._exportTimeoutMillis);
|
|
@@ -57621,7 +57621,7 @@ var require_BatchSpanProcessorBase = /* @__PURE__ */ require_chunk.__commonJSMin
|
|
|
57621
57621
|
const doExport = () => this._exporter.export(spans, (result) => {
|
|
57622
57622
|
var _a$2;
|
|
57623
57623
|
clearTimeout(timer);
|
|
57624
|
-
if (result.code === core_1$18.ExportResultCode.SUCCESS) resolve$
|
|
57624
|
+
if (result.code === core_1$18.ExportResultCode.SUCCESS) resolve$3();
|
|
57625
57625
|
else reject((_a$2 = result.error) !== null && _a$2 !== void 0 ? _a$2 : /* @__PURE__ */ new Error("BatchSpanProcessor: span export failed"));
|
|
57626
57626
|
});
|
|
57627
57627
|
let pendingResources = null;
|
|
@@ -58897,12 +58897,12 @@ var require_MultiSpanProcessor = /* @__PURE__ */ require_chunk.__commonJSMin(((e
|
|
|
58897
58897
|
forceFlush() {
|
|
58898
58898
|
const promises = [];
|
|
58899
58899
|
for (const spanProcessor of this._spanProcessors) promises.push(spanProcessor.forceFlush());
|
|
58900
|
-
return new Promise((resolve$
|
|
58900
|
+
return new Promise((resolve$3) => {
|
|
58901
58901
|
Promise.all(promises).then(() => {
|
|
58902
|
-
resolve$
|
|
58902
|
+
resolve$3();
|
|
58903
58903
|
}).catch((error$1) => {
|
|
58904
58904
|
(0, core_1$14.globalErrorHandler)(error$1 || /* @__PURE__ */ new Error("MultiSpanProcessor: forceFlush failed"));
|
|
58905
|
-
resolve$
|
|
58905
|
+
resolve$3();
|
|
58906
58906
|
});
|
|
58907
58907
|
});
|
|
58908
58908
|
}
|
|
@@ -58915,9 +58915,9 @@ var require_MultiSpanProcessor = /* @__PURE__ */ require_chunk.__commonJSMin(((e
|
|
|
58915
58915
|
shutdown() {
|
|
58916
58916
|
const promises = [];
|
|
58917
58917
|
for (const spanProcessor of this._spanProcessors) promises.push(spanProcessor.shutdown());
|
|
58918
|
-
return new Promise((resolve$
|
|
58918
|
+
return new Promise((resolve$3, reject) => {
|
|
58919
58919
|
Promise.all(promises).then(() => {
|
|
58920
|
-
resolve$
|
|
58920
|
+
resolve$3();
|
|
58921
58921
|
}, reject);
|
|
58922
58922
|
});
|
|
58923
58923
|
}
|
|
@@ -59024,30 +59024,30 @@ var require_BasicTracerProvider = /* @__PURE__ */ require_chunk.__commonJSMin(((
|
|
|
59024
59024
|
forceFlush() {
|
|
59025
59025
|
const timeout = this._config.forceFlushTimeoutMillis;
|
|
59026
59026
|
const promises = this._registeredSpanProcessors.map((spanProcessor) => {
|
|
59027
|
-
return new Promise((resolve$
|
|
59027
|
+
return new Promise((resolve$3) => {
|
|
59028
59028
|
let state;
|
|
59029
59029
|
const timeoutInterval = setTimeout(() => {
|
|
59030
|
-
resolve$
|
|
59030
|
+
resolve$3(/* @__PURE__ */ new Error(`Span processor did not completed within timeout period of ${timeout} ms`));
|
|
59031
59031
|
state = ForceFlushState.timeout;
|
|
59032
59032
|
}, timeout);
|
|
59033
59033
|
spanProcessor.forceFlush().then(() => {
|
|
59034
59034
|
clearTimeout(timeoutInterval);
|
|
59035
59035
|
if (state !== ForceFlushState.timeout) {
|
|
59036
59036
|
state = ForceFlushState.resolved;
|
|
59037
|
-
resolve$
|
|
59037
|
+
resolve$3(state);
|
|
59038
59038
|
}
|
|
59039
59039
|
}).catch((error$1) => {
|
|
59040
59040
|
clearTimeout(timeoutInterval);
|
|
59041
59041
|
state = ForceFlushState.error;
|
|
59042
|
-
resolve$
|
|
59042
|
+
resolve$3(error$1);
|
|
59043
59043
|
});
|
|
59044
59044
|
});
|
|
59045
59045
|
});
|
|
59046
|
-
return new Promise((resolve$
|
|
59046
|
+
return new Promise((resolve$3, reject) => {
|
|
59047
59047
|
Promise.all(promises).then((results) => {
|
|
59048
59048
|
const errors$1 = results.filter((result) => result !== ForceFlushState.resolved);
|
|
59049
59049
|
if (errors$1.length > 0) reject(errors$1);
|
|
59050
|
-
else resolve$
|
|
59050
|
+
else resolve$3();
|
|
59051
59051
|
}).catch((error$1) => reject([error$1]));
|
|
59052
59052
|
});
|
|
59053
59053
|
}
|
|
@@ -61184,11 +61184,11 @@ var __awaiter$3, __generator$3, BoundedQueueExportPromiseHandler;
|
|
|
61184
61184
|
var init_bounded_queue_export_promise_handler = require_chunk.__esmMin((() => {
|
|
61185
61185
|
__awaiter$3 = void 0 && (void 0).__awaiter || function(thisArg, _arguments, P, generator) {
|
|
61186
61186
|
function adopt(value) {
|
|
61187
|
-
return value instanceof P ? value : new P(function(resolve$
|
|
61188
|
-
resolve$
|
|
61187
|
+
return value instanceof P ? value : new P(function(resolve$3) {
|
|
61188
|
+
resolve$3(value);
|
|
61189
61189
|
});
|
|
61190
61190
|
}
|
|
61191
|
-
return new (P || (P = Promise))(function(resolve$
|
|
61191
|
+
return new (P || (P = Promise))(function(resolve$3, reject) {
|
|
61192
61192
|
function fulfilled(value) {
|
|
61193
61193
|
try {
|
|
61194
61194
|
step(generator.next(value));
|
|
@@ -61204,7 +61204,7 @@ var init_bounded_queue_export_promise_handler = require_chunk.__esmMin((() => {
|
|
|
61204
61204
|
}
|
|
61205
61205
|
}
|
|
61206
61206
|
function step(result) {
|
|
61207
|
-
result.done ? resolve$
|
|
61207
|
+
result.done ? resolve$3(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
61208
61208
|
}
|
|
61209
61209
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
61210
61210
|
});
|
|
@@ -63000,8 +63000,8 @@ var require_promise = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =>
|
|
|
63000
63000
|
exports.Deferred = void 0;
|
|
63001
63001
|
var Deferred = class {
|
|
63002
63002
|
constructor() {
|
|
63003
|
-
this._promise = new Promise((resolve$
|
|
63004
|
-
this._resolve = resolve$
|
|
63003
|
+
this._promise = new Promise((resolve$3, reject) => {
|
|
63004
|
+
this._resolve = resolve$3;
|
|
63005
63005
|
this._reject = reject;
|
|
63006
63006
|
});
|
|
63007
63007
|
}
|
|
@@ -63067,10 +63067,10 @@ var require_exporter = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =>
|
|
|
63067
63067
|
* Shared functionality used by Exporters while exporting data, including suppression of Traces.
|
|
63068
63068
|
*/
|
|
63069
63069
|
function _export(exporter, arg) {
|
|
63070
|
-
return new Promise((resolve$
|
|
63070
|
+
return new Promise((resolve$3) => {
|
|
63071
63071
|
api_1$17.context.with((0, suppress_tracing_1$1.suppressTracing)(api_1$17.context.active()), () => {
|
|
63072
63072
|
exporter.export(arg, (result) => {
|
|
63073
|
-
resolve$
|
|
63073
|
+
resolve$3(result);
|
|
63074
63074
|
});
|
|
63075
63075
|
});
|
|
63076
63076
|
});
|
|
@@ -63528,11 +63528,11 @@ var init_otlp_export_delegate = require_chunk.__esmMin((() => {
|
|
|
63528
63528
|
init_esm$2();
|
|
63529
63529
|
__awaiter$2 = void 0 && (void 0).__awaiter || function(thisArg, _arguments, P, generator) {
|
|
63530
63530
|
function adopt(value) {
|
|
63531
|
-
return value instanceof P ? value : new P(function(resolve$
|
|
63532
|
-
resolve$
|
|
63531
|
+
return value instanceof P ? value : new P(function(resolve$3) {
|
|
63532
|
+
resolve$3(value);
|
|
63533
63533
|
});
|
|
63534
63534
|
}
|
|
63535
|
-
return new (P || (P = Promise))(function(resolve$
|
|
63535
|
+
return new (P || (P = Promise))(function(resolve$3, reject) {
|
|
63536
63536
|
function fulfilled(value) {
|
|
63537
63537
|
try {
|
|
63538
63538
|
step(generator.next(value));
|
|
@@ -63548,7 +63548,7 @@ var init_otlp_export_delegate = require_chunk.__esmMin((() => {
|
|
|
63548
63548
|
}
|
|
63549
63549
|
}
|
|
63550
63550
|
function step(result) {
|
|
63551
|
-
result.done ? resolve$
|
|
63551
|
+
result.done ? resolve$3(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
63552
63552
|
}
|
|
63553
63553
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
63554
63554
|
});
|
|
@@ -68814,7 +68814,7 @@ var require_aspromise = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, m
|
|
|
68814
68814
|
function asPromise(fn, ctx) {
|
|
68815
68815
|
var params = new Array(arguments.length - 1), offset = 0, index$1 = 2, pending = true;
|
|
68816
68816
|
while (index$1 < arguments.length) params[offset++] = arguments[index$1++];
|
|
68817
|
-
return new Promise(function executor(resolve$
|
|
68817
|
+
return new Promise(function executor(resolve$3, reject) {
|
|
68818
68818
|
params[offset] = function callback(err) {
|
|
68819
68819
|
if (pending) {
|
|
68820
68820
|
pending = false;
|
|
@@ -68822,7 +68822,7 @@ var require_aspromise = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, m
|
|
|
68822
68822
|
else {
|
|
68823
68823
|
var params$1 = new Array(arguments.length - 1), offset$1 = 0;
|
|
68824
68824
|
while (offset$1 < params$1.length) params$1[offset$1++] = arguments[offset$1];
|
|
68825
|
-
resolve$
|
|
68825
|
+
resolve$3.apply(null, params$1);
|
|
68826
68826
|
}
|
|
68827
68827
|
}
|
|
68828
68828
|
};
|
|
@@ -82515,11 +82515,11 @@ var __awaiter$1, __generator$1, HttpExporterTransport;
|
|
|
82515
82515
|
var init_http_exporter_transport = require_chunk.__esmMin((() => {
|
|
82516
82516
|
__awaiter$1 = void 0 && (void 0).__awaiter || function(thisArg, _arguments, P, generator) {
|
|
82517
82517
|
function adopt(value) {
|
|
82518
|
-
return value instanceof P ? value : new P(function(resolve$
|
|
82519
|
-
resolve$
|
|
82518
|
+
return value instanceof P ? value : new P(function(resolve$3) {
|
|
82519
|
+
resolve$3(value);
|
|
82520
82520
|
});
|
|
82521
82521
|
}
|
|
82522
|
-
return new (P || (P = Promise))(function(resolve$
|
|
82522
|
+
return new (P || (P = Promise))(function(resolve$3, reject) {
|
|
82523
82523
|
function fulfilled(value) {
|
|
82524
82524
|
try {
|
|
82525
82525
|
step(generator.next(value));
|
|
@@ -82535,7 +82535,7 @@ var init_http_exporter_transport = require_chunk.__esmMin((() => {
|
|
|
82535
82535
|
}
|
|
82536
82536
|
}
|
|
82537
82537
|
function step(result) {
|
|
82538
|
-
result.done ? resolve$
|
|
82538
|
+
result.done ? resolve$3(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
82539
82539
|
}
|
|
82540
82540
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
82541
82541
|
});
|
|
@@ -82640,10 +82640,10 @@ var init_http_exporter_transport = require_chunk.__esmMin((() => {
|
|
|
82640
82640
|
this._agent = createHttpAgent$1(this._parameters.url, this._parameters.agentOptions);
|
|
82641
82641
|
this._send = sendWithHttp$1;
|
|
82642
82642
|
}
|
|
82643
|
-
return [2, new Promise(function(resolve$
|
|
82643
|
+
return [2, new Promise(function(resolve$3) {
|
|
82644
82644
|
var _a$3;
|
|
82645
82645
|
(_a$3 = _this._send) === null || _a$3 === void 0 || _a$3.call(_this, _this._parameters, _this._agent, data$1, function(result) {
|
|
82646
|
-
resolve$
|
|
82646
|
+
resolve$3(result);
|
|
82647
82647
|
}, timeoutMillis);
|
|
82648
82648
|
})];
|
|
82649
82649
|
});
|
|
@@ -82672,11 +82672,11 @@ var __awaiter, __generator, MAX_ATTEMPTS, INITIAL_BACKOFF, MAX_BACKOFF, BACKOFF_
|
|
|
82672
82672
|
var init_retrying_transport = require_chunk.__esmMin((() => {
|
|
82673
82673
|
__awaiter = void 0 && (void 0).__awaiter || function(thisArg, _arguments, P, generator) {
|
|
82674
82674
|
function adopt(value) {
|
|
82675
|
-
return value instanceof P ? value : new P(function(resolve$
|
|
82676
|
-
resolve$
|
|
82675
|
+
return value instanceof P ? value : new P(function(resolve$3) {
|
|
82676
|
+
resolve$3(value);
|
|
82677
82677
|
});
|
|
82678
82678
|
}
|
|
82679
|
-
return new (P || (P = Promise))(function(resolve$
|
|
82679
|
+
return new (P || (P = Promise))(function(resolve$3, reject) {
|
|
82680
82680
|
function fulfilled(value) {
|
|
82681
82681
|
try {
|
|
82682
82682
|
step(generator.next(value));
|
|
@@ -82692,7 +82692,7 @@ var init_retrying_transport = require_chunk.__esmMin((() => {
|
|
|
82692
82692
|
}
|
|
82693
82693
|
}
|
|
82694
82694
|
function step(result) {
|
|
82695
|
-
result.done ? resolve$
|
|
82695
|
+
result.done ? resolve$3(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
82696
82696
|
}
|
|
82697
82697
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
82698
82698
|
});
|
|
@@ -82792,9 +82792,9 @@ var init_retrying_transport = require_chunk.__esmMin((() => {
|
|
|
82792
82792
|
}
|
|
82793
82793
|
RetryingTransport$1.prototype.retry = function(data$1, timeoutMillis, inMillis) {
|
|
82794
82794
|
var _this = this;
|
|
82795
|
-
return new Promise(function(resolve$
|
|
82795
|
+
return new Promise(function(resolve$3, reject) {
|
|
82796
82796
|
setTimeout(function() {
|
|
82797
|
-
_this._transport.send(data$1, timeoutMillis).then(resolve$
|
|
82797
|
+
_this._transport.send(data$1, timeoutMillis).then(resolve$3, reject);
|
|
82798
82798
|
}, inMillis);
|
|
82799
82799
|
});
|
|
82800
82800
|
};
|
|
@@ -83235,7 +83235,7 @@ var import_json_schema_traverse = /* @__PURE__ */ require_chunk.__toESM(require_
|
|
|
83235
83235
|
var schemaSymbol = Symbol.for("mcpc.schema");
|
|
83236
83236
|
var vercelSchemaSymbol = Symbol.for("vercel.ai.schema");
|
|
83237
83237
|
var validatorSymbol = Symbol.for("mcpc.validator");
|
|
83238
|
-
function jsonSchema$
|
|
83238
|
+
function jsonSchema$2(schema, options = {}) {
|
|
83239
83239
|
if (isWrappedSchema(schema)) return schema;
|
|
83240
83240
|
return {
|
|
83241
83241
|
[schemaSymbol]: true,
|
|
@@ -83488,13 +83488,13 @@ async function composeMcpDepTools(mcpConfig, filterIn) {
|
|
|
83488
83488
|
acquiredKeys.push(defKey);
|
|
83489
83489
|
allClients[serverId] = client;
|
|
83490
83490
|
const { tools } = await client.listTools();
|
|
83491
|
-
tools.forEach((tool$
|
|
83492
|
-
const toolNameWithScope = `${name}.${tool$
|
|
83493
|
-
const internalToolName = tool$
|
|
83491
|
+
tools.forEach((tool$2) => {
|
|
83492
|
+
const toolNameWithScope = `${name}.${tool$2.name}`;
|
|
83493
|
+
const internalToolName = tool$2.name;
|
|
83494
83494
|
const toolId = sanitizePropertyKey(`${serverId}_${internalToolName}`);
|
|
83495
83495
|
if (filterIn && !filterIn({
|
|
83496
83496
|
action: internalToolName,
|
|
83497
|
-
tool: tool$
|
|
83497
|
+
tool: tool$2,
|
|
83498
83498
|
mcpName: name,
|
|
83499
83499
|
toolNameWithScope,
|
|
83500
83500
|
internalToolName,
|
|
@@ -83505,7 +83505,7 @@ async function composeMcpDepTools(mcpConfig, filterIn) {
|
|
|
83505
83505
|
arguments: args
|
|
83506
83506
|
}, void 0, { timeout: def$30.toolCallTimeout });
|
|
83507
83507
|
allTools[toolId] = {
|
|
83508
|
-
...tool$
|
|
83508
|
+
...tool$2,
|
|
83509
83509
|
execute,
|
|
83510
83510
|
_originalName: toolNameWithScope
|
|
83511
83511
|
};
|
|
@@ -83557,10 +83557,10 @@ var createConfigPlugin = () => ({
|
|
|
83557
83557
|
name: "built-in-config",
|
|
83558
83558
|
version: "1.0.0",
|
|
83559
83559
|
enforce: "pre",
|
|
83560
|
-
transformTool: (tool$
|
|
83560
|
+
transformTool: (tool$2, context2) => {
|
|
83561
83561
|
const config = context2.server.findToolConfig?.(context2.toolName);
|
|
83562
|
-
if (config?.description) tool$
|
|
83563
|
-
return tool$
|
|
83562
|
+
if (config?.description) tool$2.description = config.description;
|
|
83563
|
+
return tool$2;
|
|
83564
83564
|
}
|
|
83565
83565
|
});
|
|
83566
83566
|
var config_plugin_default = createConfigPlugin();
|
|
@@ -83568,16 +83568,16 @@ var createToolNameMappingPlugin = () => ({
|
|
|
83568
83568
|
name: "built-in-tool-name-mapping",
|
|
83569
83569
|
version: "1.0.0",
|
|
83570
83570
|
enforce: "pre",
|
|
83571
|
-
transformTool: (tool$
|
|
83571
|
+
transformTool: (tool$2, context2) => {
|
|
83572
83572
|
const server = context2.server;
|
|
83573
83573
|
const toolName = context2.toolName;
|
|
83574
|
-
const originalName = tool$
|
|
83574
|
+
const originalName = tool$2._originalName || toolName;
|
|
83575
83575
|
const dotNotation = originalName.replace(/_/g, ".");
|
|
83576
83576
|
const underscoreNotation = originalName.replace(/\./g, "_");
|
|
83577
83577
|
if (dotNotation !== originalName && server.toolNameMapping) server.toolNameMapping.set(dotNotation, toolName);
|
|
83578
83578
|
if (underscoreNotation !== originalName && server.toolNameMapping) server.toolNameMapping.set(underscoreNotation, toolName);
|
|
83579
83579
|
if (originalName !== toolName && server.toolNameMapping) server.toolNameMapping.set(originalName, toolName);
|
|
83580
|
-
return tool$
|
|
83580
|
+
return tool$2;
|
|
83581
83581
|
}
|
|
83582
83582
|
});
|
|
83583
83583
|
var tool_name_mapping_plugin_default = createToolNameMappingPlugin();
|
|
@@ -83926,10 +83926,10 @@ var CompiledPrompts = {
|
|
|
83926
83926
|
};
|
|
83927
83927
|
var PromptUtils = {
|
|
83928
83928
|
generateToolList: (tools) => {
|
|
83929
|
-
return tools.filter((tool$
|
|
83929
|
+
return tools.filter((tool$2) => !tool$2.hide).map((tool$2) => `<tool name="${tool$2.name}"${tool$2.description ? ` description="${tool$2.description}"` : ""}/>`).join("\n");
|
|
83930
83930
|
},
|
|
83931
83931
|
generateHiddenToolList: (tools) => {
|
|
83932
|
-
return tools.filter((tool$
|
|
83932
|
+
return tools.filter((tool$2) => tool$2.hide).map((tool$2) => `<tool name="${tool$2.name}" hide/>`).join("\n");
|
|
83933
83933
|
},
|
|
83934
83934
|
formatWorkflowSteps: (steps) => {
|
|
83935
83935
|
if (!steps.length) return "";
|
|
@@ -84504,7 +84504,7 @@ function registerAgenticTool(server, { description, name, allToolNames, depGroup
|
|
|
84504
84504
|
type: "object",
|
|
84505
84505
|
properties: {}
|
|
84506
84506
|
};
|
|
84507
|
-
server.tool(name, description, jsonSchema$
|
|
84507
|
+
server.tool(name, description, jsonSchema$2(createGoogleCompatibleJSONSchema(schema)), async (args) => {
|
|
84508
84508
|
return await agenticExecutor.execute(args, schema);
|
|
84509
84509
|
});
|
|
84510
84510
|
}
|
|
@@ -84909,7 +84909,7 @@ function registerAgenticWorkflowTool(server, { description, name, allToolNames,
|
|
|
84909
84909
|
});
|
|
84910
84910
|
const argsDef = createArgsDef.forTool();
|
|
84911
84911
|
const toolDescription = createArgsDef.forToolDescription(baseDescription, workflowState);
|
|
84912
|
-
server.tool(name, toolDescription, jsonSchema$
|
|
84912
|
+
server.tool(name, toolDescription, jsonSchema$2(createGoogleCompatibleJSONSchema(argsDef)), async (args) => {
|
|
84913
84913
|
try {
|
|
84914
84914
|
return await workflowExecutor.execute(args, workflowState);
|
|
84915
84915
|
} catch (error$1) {
|
|
@@ -85279,11 +85279,11 @@ var SamplingExecutor = class extends BaseSamplingExecutor {
|
|
|
85279
85279
|
}
|
|
85280
85280
|
buildDepGroups() {
|
|
85281
85281
|
const depGroups = {};
|
|
85282
|
-
this.toolNameToDetailList.forEach(([toolName, tool$
|
|
85283
|
-
if (tool$
|
|
85282
|
+
this.toolNameToDetailList.forEach(([toolName, tool$2]) => {
|
|
85283
|
+
if (tool$2?.inputSchema) depGroups[toolName] = {
|
|
85284
85284
|
type: "object",
|
|
85285
|
-
description: tool$
|
|
85286
|
-
...tool$
|
|
85285
|
+
description: tool$2.description || `Tool: ${toolName}`,
|
|
85286
|
+
...tool$2.inputSchema
|
|
85287
85287
|
};
|
|
85288
85288
|
else {
|
|
85289
85289
|
const toolSchema = this.server.getHiddenToolSchema(toolName);
|
|
@@ -85329,9 +85329,9 @@ var SamplingExecutor = class extends BaseSamplingExecutor {
|
|
|
85329
85329
|
}
|
|
85330
85330
|
buildSystemPrompt(userRequest, agenticSchema, context2) {
|
|
85331
85331
|
const toolList = this.allToolNames.map((name) => {
|
|
85332
|
-
const tool$
|
|
85332
|
+
const tool$2 = this.toolNameToDetailList.find(([toolName]) => toolName === name);
|
|
85333
85333
|
const toolSchema = this.server.getHiddenToolSchema(name);
|
|
85334
|
-
if (tool$
|
|
85334
|
+
if (tool$2 && tool$2[1]) return `- ${name}: ${tool$2[1].description || `Tool: ${name}`}`;
|
|
85335
85335
|
else if (toolSchema) return `- ${name}: ${toolSchema.description}`;
|
|
85336
85336
|
return `- ${name}`;
|
|
85337
85337
|
}).join("\n");
|
|
@@ -85370,7 +85370,7 @@ function registerAgenticSamplingTool(server, { description, name, allToolNames,
|
|
|
85370
85370
|
type: "object",
|
|
85371
85371
|
properties: {}
|
|
85372
85372
|
};
|
|
85373
|
-
server.tool(name, description, jsonSchema$
|
|
85373
|
+
server.tool(name, description, jsonSchema$2(createGoogleCompatibleJSONSchema(schema)), async (args) => {
|
|
85374
85374
|
return await samplingExecutor.executeSampling(args, schema);
|
|
85375
85375
|
});
|
|
85376
85376
|
}
|
|
@@ -85463,7 +85463,7 @@ function registerWorkflowSamplingTool(server, { description, name, allToolNames,
|
|
|
85463
85463
|
type: "object",
|
|
85464
85464
|
properties: {}
|
|
85465
85465
|
};
|
|
85466
|
-
server.tool(name, baseDescription, jsonSchema$
|
|
85466
|
+
server.tool(name, baseDescription, jsonSchema$2(createGoogleCompatibleJSONSchema(schema)), async (args) => {
|
|
85467
85467
|
try {
|
|
85468
85468
|
return await workflowSamplingExecutor.executeWorkflowSampling(args, schema, workflowState);
|
|
85469
85469
|
} catch (error$1) {
|
|
@@ -85718,11 +85718,11 @@ var PluginManager = class {
|
|
|
85718
85718
|
/**
|
|
85719
85719
|
* Apply transformTool hooks to a tool during composition
|
|
85720
85720
|
*/
|
|
85721
|
-
async applyTransformToolHooks(tool$
|
|
85721
|
+
async applyTransformToolHooks(tool$2, context2) {
|
|
85722
85722
|
const transformPlugins = this.plugins.filter((p2) => p2.transformTool && shouldApplyPlugin(p2, context2.mode));
|
|
85723
|
-
if (transformPlugins.length === 0) return tool$
|
|
85723
|
+
if (transformPlugins.length === 0) return tool$2;
|
|
85724
85724
|
const sortedPlugins = sortPluginsByOrder(transformPlugins);
|
|
85725
|
-
let currentTool = tool$
|
|
85725
|
+
let currentTool = tool$2;
|
|
85726
85726
|
for (const plugin of sortedPlugins) if (plugin.transformTool) try {
|
|
85727
85727
|
const result = await plugin.transformTool(currentTool, context2);
|
|
85728
85728
|
if (result) currentTool = result;
|
|
@@ -85915,11 +85915,11 @@ var ToolManager = class {
|
|
|
85915
85915
|
* Get tool schema if it's hidden (for internal access)
|
|
85916
85916
|
*/
|
|
85917
85917
|
getHiddenToolSchema(name) {
|
|
85918
|
-
const tool$
|
|
85918
|
+
const tool$2 = this.toolRegistry.get(name);
|
|
85919
85919
|
const config = this.toolConfigs.get(name);
|
|
85920
|
-
if (tool$
|
|
85921
|
-
description: tool$
|
|
85922
|
-
schema: tool$
|
|
85920
|
+
if (tool$2 && config?.visibility?.hidden && tool$2.schema) return {
|
|
85921
|
+
description: tool$2.description,
|
|
85922
|
+
schema: tool$2.schema
|
|
85923
85923
|
};
|
|
85924
85924
|
}
|
|
85925
85925
|
/**
|
|
@@ -85946,16 +85946,16 @@ var ToolManager = class {
|
|
|
85946
85946
|
*/
|
|
85947
85947
|
getRegisteredToolsAsComposed() {
|
|
85948
85948
|
const composedTools = {};
|
|
85949
|
-
for (const [name, tool$
|
|
85949
|
+
for (const [name, tool$2] of this.toolRegistry.entries()) {
|
|
85950
85950
|
if (this.toolConfigs.get(name)?.visibility?.public === true) continue;
|
|
85951
85951
|
composedTools[name] = {
|
|
85952
85952
|
name,
|
|
85953
|
-
description: tool$
|
|
85954
|
-
inputSchema: jsonSchema$
|
|
85953
|
+
description: tool$2.description,
|
|
85954
|
+
inputSchema: jsonSchema$2(tool$2.schema || {
|
|
85955
85955
|
type: "object",
|
|
85956
85956
|
properties: {}
|
|
85957
85957
|
}),
|
|
85958
|
-
execute: tool$
|
|
85958
|
+
execute: tool$2.callback
|
|
85959
85959
|
};
|
|
85960
85960
|
}
|
|
85961
85961
|
return composedTools;
|
|
@@ -86009,14 +86009,14 @@ async function processToolsWithPlugins(server, _externalTools, mode) {
|
|
|
86009
86009
|
function buildDependencyGroups(toolNameToDetailList, hiddenToolNames, publicToolNames, server) {
|
|
86010
86010
|
const depGroups = {};
|
|
86011
86011
|
const toolManager = server.toolManager;
|
|
86012
|
-
toolNameToDetailList.forEach(([toolName, tool$
|
|
86012
|
+
toolNameToDetailList.forEach(([toolName, tool$2]) => {
|
|
86013
86013
|
const resolvedName = toolManager.resolveToolName(toolName);
|
|
86014
86014
|
if (hiddenToolNames.includes(resolvedName ?? "") || publicToolNames.includes(resolvedName ?? "")) return;
|
|
86015
|
-
if (!tool$
|
|
86015
|
+
if (!tool$2) {
|
|
86016
86016
|
const allToolNames = [...toolNameToDetailList.map(([n]) => n)];
|
|
86017
86017
|
throw new Error(`Action ${toolName} not found, available action list: ${allToolNames.join(", ")}`);
|
|
86018
86018
|
}
|
|
86019
|
-
const baseSchema = tool$
|
|
86019
|
+
const baseSchema = tool$2.inputSchema.jsonSchema ?? tool$2.inputSchema ?? {
|
|
86020
86020
|
type: "object",
|
|
86021
86021
|
properties: {},
|
|
86022
86022
|
required: []
|
|
@@ -86027,7 +86027,7 @@ function buildDependencyGroups(toolNameToDetailList, hiddenToolNames, publicTool
|
|
|
86027
86027
|
const sanitizedKey = sanitizePropertyKey(toolName);
|
|
86028
86028
|
depGroups[sanitizedKey] = {
|
|
86029
86029
|
type: "object",
|
|
86030
|
-
description: tool$
|
|
86030
|
+
description: tool$2.description,
|
|
86031
86031
|
properties: updatedProperties,
|
|
86032
86032
|
required: [...baseRequired],
|
|
86033
86033
|
additionalProperties: false
|
|
@@ -86262,9 +86262,9 @@ var ComposableMCPServer = class extends __modelcontextprotocol_sdk_server_index_
|
|
|
86262
86262
|
const requestedToolNames = /* @__PURE__ */ new Set();
|
|
86263
86263
|
const availableToolNames = /* @__PURE__ */ new Set();
|
|
86264
86264
|
const allPlaceholderUsages = [];
|
|
86265
|
-
tagToResults.tool.forEach((tool$
|
|
86266
|
-
if (tool$
|
|
86267
|
-
const originalName = tool$
|
|
86265
|
+
tagToResults.tool.forEach((tool$2) => {
|
|
86266
|
+
if (tool$2.attribs.name) {
|
|
86267
|
+
const originalName = tool$2.attribs.name;
|
|
86268
86268
|
const toolName = sanitizePropertyKey(originalName);
|
|
86269
86269
|
if (toolName.endsWith(`_${ALL_TOOLS_PLACEHOLDER2}`) || toolName === ALL_TOOLS_PLACEHOLDER2) allPlaceholderUsages.push(originalName);
|
|
86270
86270
|
else requestedToolNames.add(toolName);
|
|
@@ -86283,18 +86283,18 @@ var ComposableMCPServer = class extends __modelcontextprotocol_sdk_server_index_
|
|
|
86283
86283
|
if (actionIndex !== -1) matchingStep.actions[actionIndex] = toolId;
|
|
86284
86284
|
return true;
|
|
86285
86285
|
}
|
|
86286
|
-
return tagToResults.tool.find((tool$
|
|
86287
|
-
if (tool$
|
|
86288
|
-
return tool$
|
|
86286
|
+
return tagToResults.tool.find((tool$2) => {
|
|
86287
|
+
if (tool$2.attribs.name === `${mcpName}.${ALL_TOOLS_PLACEHOLDER2}` || tool$2.attribs.name === `${mcpName}`) return true;
|
|
86288
|
+
return tool$2.attribs.name === toolNameWithScope || tool$2.attribs.name === toolId;
|
|
86289
86289
|
});
|
|
86290
86290
|
});
|
|
86291
|
-
Object.entries(tools).forEach(([toolId, tool$
|
|
86292
|
-
this.toolManager.registerTool(toolId, tool$
|
|
86291
|
+
Object.entries(tools).forEach(([toolId, tool$2]) => {
|
|
86292
|
+
this.toolManager.registerTool(toolId, tool$2.description || "", tool$2.inputSchema, tool$2.execute);
|
|
86293
86293
|
});
|
|
86294
86294
|
const registeredTools = this.toolManager.getRegisteredToolsAsComposed();
|
|
86295
86295
|
const allTools = { ...tools };
|
|
86296
|
-
Object.entries(registeredTools).forEach(([toolName, tool$
|
|
86297
|
-
if (!allTools[toolName]) allTools[toolName] = tool$
|
|
86296
|
+
Object.entries(registeredTools).forEach(([toolName, tool$2]) => {
|
|
86297
|
+
if (!allTools[toolName]) allTools[toolName] = tool$2;
|
|
86298
86298
|
availableToolNames.add(toolName);
|
|
86299
86299
|
});
|
|
86300
86300
|
if (allPlaceholderUsages.length > 0) {
|
|
@@ -86337,9 +86337,9 @@ var ComposableMCPServer = class extends __modelcontextprotocol_sdk_server_index_
|
|
|
86337
86337
|
const hiddenToolNames = this.getHiddenToolNames();
|
|
86338
86338
|
const contextToolNames = toolNameToDetailList.map(([name2]) => name2).filter((n) => !hiddenToolNames.includes(n));
|
|
86339
86339
|
publicToolNames.forEach((toolId) => {
|
|
86340
|
-
const tool$
|
|
86341
|
-
if (!tool$
|
|
86342
|
-
this.tool(toolId, tool$
|
|
86340
|
+
const tool$2 = allTools[toolId];
|
|
86341
|
+
if (!tool$2) throw new Error(`Public tool ${toolId} not found in registry, available: ${Object.keys(allTools).join(", ")}`);
|
|
86342
|
+
this.tool(toolId, tool$2.description || "", jsonSchema$2(tool$2.inputSchema), tool$2.execute, { internal: false });
|
|
86343
86343
|
});
|
|
86344
86344
|
await this.pluginManager.triggerComposeEnd({
|
|
86345
86345
|
toolName: name,
|
|
@@ -86559,14 +86559,14 @@ function callMcpMethod(mcpServer, method, params) {
|
|
|
86559
86559
|
jsonrpc: "2.0",
|
|
86560
86560
|
id: messageId
|
|
86561
86561
|
};
|
|
86562
|
-
return new Promise((resolve$
|
|
86562
|
+
return new Promise((resolve$3) => {
|
|
86563
86563
|
if (!mcpServer.transport) throw new Error("MCP server transport not initialized");
|
|
86564
86564
|
mcpServer.transport.onmessage?.(message);
|
|
86565
86565
|
const originalSend = mcpServer.transport.send;
|
|
86566
86566
|
mcpServer.transport.send = function(payload) {
|
|
86567
86567
|
const payloadObj = payload;
|
|
86568
86568
|
if (payloadObj.id === messageId) {
|
|
86569
|
-
resolve$
|
|
86569
|
+
resolve$3(payloadObj.result);
|
|
86570
86570
|
if (!mcpServer.transport) throw new Error("MCP server transport not initialized");
|
|
86571
86571
|
mcpServer.transport.send = originalSend;
|
|
86572
86572
|
}
|
|
@@ -86935,11 +86935,19 @@ function handleCors(res, method) {
|
|
|
86935
86935
|
|
|
86936
86936
|
//#endregion
|
|
86937
86937
|
//#region src/middleware/mcproute-middleware.ts
|
|
86938
|
+
let sharedConnectionManager = null;
|
|
86939
|
+
/**
|
|
86940
|
+
* Get the shared connection manager instance
|
|
86941
|
+
*/
|
|
86942
|
+
function getConnectionManager() {
|
|
86943
|
+
return sharedConnectionManager;
|
|
86944
|
+
}
|
|
86938
86945
|
/**
|
|
86939
86946
|
* Setup MCP server endpoints in Vite dev server
|
|
86940
86947
|
*/
|
|
86941
86948
|
async function setupMcpMiddleware(middlewares, serverContext) {
|
|
86942
86949
|
const connectionManager = new ConnectionManager();
|
|
86950
|
+
sharedConnectionManager = connectionManager;
|
|
86943
86951
|
middlewares.use(async (req, res, next$1) => {
|
|
86944
86952
|
const url$1 = req.url || "";
|
|
86945
86953
|
if (url$1.startsWith("/__mcp__")) {
|
|
@@ -87113,13 +87121,13 @@ async function handleSseMessage(req, res, serverContext, connectionManager) {
|
|
|
87113
87121
|
* Helper to read request body
|
|
87114
87122
|
*/
|
|
87115
87123
|
function readRequestBody(req) {
|
|
87116
|
-
return new Promise((resolve$
|
|
87124
|
+
return new Promise((resolve$3, reject) => {
|
|
87117
87125
|
let body = "";
|
|
87118
87126
|
req.on("data", (chunk) => {
|
|
87119
87127
|
body += chunk.toString();
|
|
87120
87128
|
});
|
|
87121
87129
|
req.on("end", () => {
|
|
87122
|
-
resolve$
|
|
87130
|
+
resolve$3(body);
|
|
87123
87131
|
});
|
|
87124
87132
|
req.on("error", reject);
|
|
87125
87133
|
});
|
|
@@ -87217,7 +87225,7 @@ function setupInspectorMiddleware(middlewares, config) {
|
|
|
87217
87225
|
}
|
|
87218
87226
|
|
|
87219
87227
|
//#endregion
|
|
87220
|
-
//#region ../../node_modules/.pnpm/@mcpc-tech+acp-ai-provider@0.1.
|
|
87228
|
+
//#region ../../node_modules/.pnpm/@mcpc-tech+acp-ai-provider@0.1.31/node_modules/@mcpc-tech/acp-ai-provider/index.mjs
|
|
87221
87229
|
(0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
87222
87230
|
function formatToolError(toolResult) {
|
|
87223
87231
|
if (!toolResult || toolResult.length === 0) return "Unknown tool error";
|
|
@@ -87230,7 +87238,284 @@ function formatToolError(toolResult) {
|
|
|
87230
87238
|
function extractBase64Data(data$1) {
|
|
87231
87239
|
return data$1.includes(",") ? data$1.split(",")[1] : data$1;
|
|
87232
87240
|
}
|
|
87241
|
+
function createResponse(id, result) {
|
|
87242
|
+
return {
|
|
87243
|
+
jsonrpc: "2.0",
|
|
87244
|
+
id,
|
|
87245
|
+
result
|
|
87246
|
+
};
|
|
87247
|
+
}
|
|
87248
|
+
function createErrorResponse(id, code, message, data$1) {
|
|
87249
|
+
const error$1 = {
|
|
87250
|
+
code,
|
|
87251
|
+
message
|
|
87252
|
+
};
|
|
87253
|
+
if (data$1 !== void 0) error$1.data = data$1;
|
|
87254
|
+
return {
|
|
87255
|
+
jsonrpc: "2.0",
|
|
87256
|
+
id,
|
|
87257
|
+
error: error$1
|
|
87258
|
+
};
|
|
87259
|
+
}
|
|
87260
|
+
function parseMessage(line$1) {
|
|
87261
|
+
try {
|
|
87262
|
+
const parsed = JSON.parse(line$1);
|
|
87263
|
+
if (parsed.jsonrpc !== "2.0") return null;
|
|
87264
|
+
return parsed;
|
|
87265
|
+
} catch {
|
|
87266
|
+
return null;
|
|
87267
|
+
}
|
|
87268
|
+
}
|
|
87269
|
+
function serializeMessage(message) {
|
|
87270
|
+
return JSON.stringify(message);
|
|
87271
|
+
}
|
|
87272
|
+
var JsonRpcErrorCode = {
|
|
87273
|
+
PARSE_ERROR: -32700,
|
|
87274
|
+
INVALID_REQUEST: -32600,
|
|
87275
|
+
METHOD_NOT_FOUND: -32601,
|
|
87276
|
+
INVALID_PARAMS: -32602,
|
|
87277
|
+
INTERNAL_ERROR: -32603
|
|
87278
|
+
};
|
|
87279
|
+
var ProxyMethod = {
|
|
87280
|
+
REGISTER_TOOLS: "registerTools",
|
|
87281
|
+
CALL_HANDLER: "callHandler"
|
|
87282
|
+
};
|
|
87283
|
+
var RUNTIME_CODE = `
|
|
87284
|
+
/* MCP Protocol Version 2024-11-05 */
|
|
87285
|
+
const isDeno=typeof Deno!=="undefined",MCP_VER="2024-11-05";
|
|
87286
|
+
let tools=[],host=null,pending=new Map,buf="",hbuf="",rid=0;
|
|
87287
|
+
const env=k=>isDeno?Deno.env.get(k):process.env[k];
|
|
87288
|
+
const write=async m=>{
|
|
87289
|
+
const s=JSON.stringify(m)+"\\n";
|
|
87290
|
+
if(isDeno)await Deno.stdout.write(new TextEncoder().encode(s));
|
|
87291
|
+
else process.stdout.write(s);
|
|
87292
|
+
};
|
|
87293
|
+
const send=(id,r,e)=>write({jsonrpc:"2.0",id,...(e?{error:e}:{result:r})});
|
|
87294
|
+
const hostReq=(m,p)=>new Promise((res,rej)=>{
|
|
87295
|
+
const id="r-"+ ++rid;
|
|
87296
|
+
const s=JSON.stringify({jsonrpc:"2.0",id,method:m,params:p})+"\\n";
|
|
87297
|
+
if(isDeno)host.write(new TextEncoder().encode(s));
|
|
87298
|
+
else host.write(s);
|
|
87299
|
+
const t=setTimeout(()=>{pending.delete(id);rej(new Error("timeout"))},30000);
|
|
87300
|
+
pending.set(id,{resolve:v=>{clearTimeout(t);res(v)},reject:e=>{clearTimeout(t);rej(e)}});
|
|
87301
|
+
});
|
|
87302
|
+
const init=async()=>{
|
|
87303
|
+
const p=parseInt(env("ACP_TOOL_PROXY_PORT")||"0",10);
|
|
87304
|
+
if(p){
|
|
87305
|
+
if(isDeno){
|
|
87306
|
+
host=await Deno.connect({hostname:"127.0.0.1",port:p});
|
|
87307
|
+
(async()=>{
|
|
87308
|
+
const d=new TextDecoder(),b=new Uint8Array(65536);
|
|
87309
|
+
while(true){const n=await host.read(b);if(!n)break;
|
|
87310
|
+
hbuf+=d.decode(b.subarray(0,n));let ls=hbuf.split("\\n");hbuf=ls.pop();
|
|
87311
|
+
for(let l of ls)if(l.trim())onHostMsg(l)}})();
|
|
87312
|
+
}else{
|
|
87313
|
+
host=require("net").createConnection({host:"127.0.0.1",port:p});
|
|
87314
|
+
await new Promise(r=>host.on("connect",r));
|
|
87315
|
+
host.on("data",d=>{hbuf+=d;let ls=hbuf.split("\\n");hbuf=ls.pop();
|
|
87316
|
+
for(let l of ls)if(l.trim())onHostMsg(l)});
|
|
87317
|
+
}
|
|
87318
|
+
try{tools=await hostReq("getTools")}catch(e){
|
|
87319
|
+
const m="Failed to get tools: "+e.message+"\\n";
|
|
87320
|
+
if(isDeno)Deno.stderr.write(new TextEncoder().encode(m));
|
|
87321
|
+
else process.stderr.write(m);
|
|
87322
|
+
}
|
|
87323
|
+
}
|
|
87324
|
+
};
|
|
87325
|
+
const onHostMsg=l=>{try{let r=JSON.parse(l),h=pending.get(r.id);
|
|
87326
|
+
if(h){pending.delete(r.id);r.error?h.reject(new Error(r.error.message)):h.resolve(r.result)}}catch{}};
|
|
87327
|
+
const handle=async l=>{let m;try{m=JSON.parse(l)}catch{return}if(m.jsonrpc!=="2.0")return;
|
|
87328
|
+
if(m.method==="initialize")send(m.id,{protocolVersion:MCP_VER,capabilities:{tools:{}},serverInfo:{name:"proxy",version:"1.0"}});
|
|
87329
|
+
else if(m.method==="notifications/initialized");
|
|
87330
|
+
else if(m.method==="tools/list")send(m.id,{tools:tools.map(t=>({name:t.name,description:t.description,inputSchema:t.inputSchema}))});
|
|
87331
|
+
else if(m.method==="tools/call"){let p=m.params,t=tools.find(x=>x.name===p.name);
|
|
87332
|
+
if(!t)send(m.id,null,{code:-32601,message:"Not found"});
|
|
87333
|
+
else try{let r=await hostReq("callHandler",{name:p.name,args:p.arguments||{}});send(m.id,r)}
|
|
87334
|
+
catch(e){send(m.id,{content:[{type:"text",text:"Error: "+e.message}],isError:true})}}
|
|
87335
|
+
else send(m.id,null,{code:-32601,message:"Unknown"});
|
|
87336
|
+
};
|
|
87337
|
+
init().then(async()=>{
|
|
87338
|
+
if(isDeno){
|
|
87339
|
+
const d=new TextDecoder(),b=new Uint8Array(65536);
|
|
87340
|
+
while(true){const n=await Deno.stdin.read(b);if(!n)break;
|
|
87341
|
+
buf+=d.decode(b.subarray(0,n));let ls=buf.split("\\n");buf=ls.pop();for(let l of ls)if(l.trim())handle(l)}
|
|
87342
|
+
}else{
|
|
87343
|
+
process.stdin.setEncoding("utf8");
|
|
87344
|
+
process.stdin.on("data",c=>{buf+=c;let ls=buf.split("\\n");buf=ls.pop();for(let l of ls)if(l.trim())handle(l)});
|
|
87345
|
+
}
|
|
87346
|
+
});
|
|
87347
|
+
`.trim().replace(/\n/g, "");
|
|
87348
|
+
var ToolProxyHost = class {
|
|
87349
|
+
server = null;
|
|
87350
|
+
connections = [];
|
|
87351
|
+
tools = /* @__PURE__ */ new Map();
|
|
87352
|
+
serverName;
|
|
87353
|
+
port = 0;
|
|
87354
|
+
constructor(name = "acp-tool-proxy") {
|
|
87355
|
+
this.serverName = name;
|
|
87356
|
+
}
|
|
87357
|
+
/**
|
|
87358
|
+
* Register an AI SDK tool to be exposed through the proxy
|
|
87359
|
+
*/
|
|
87360
|
+
registerTool(name, tool2) {
|
|
87361
|
+
this.tools.set(name, tool2);
|
|
87362
|
+
}
|
|
87363
|
+
/**
|
|
87364
|
+
* Register multiple tools at once
|
|
87365
|
+
*/
|
|
87366
|
+
registerTools(tools) {
|
|
87367
|
+
for (const [name, tool2] of Object.entries(tools)) this.registerTool(name, tool2);
|
|
87368
|
+
}
|
|
87369
|
+
/**
|
|
87370
|
+
* Get tool definitions for the runtime
|
|
87371
|
+
*/
|
|
87372
|
+
getToolDefinitions() {
|
|
87373
|
+
const definitions = [];
|
|
87374
|
+
for (const [name, tool2] of this.tools.entries()) definitions.push({
|
|
87375
|
+
name,
|
|
87376
|
+
description: tool2.description || `Tool: ${name}`,
|
|
87377
|
+
inputSchema: tool2.inputSchema || {
|
|
87378
|
+
type: "object",
|
|
87379
|
+
properties: {}
|
|
87380
|
+
}
|
|
87381
|
+
});
|
|
87382
|
+
return definitions;
|
|
87383
|
+
}
|
|
87384
|
+
/**
|
|
87385
|
+
* Start TCP server and return MCP server config for ACP
|
|
87386
|
+
*/
|
|
87387
|
+
async start() {
|
|
87388
|
+
if (this.server) throw new Error("Tool proxy already started");
|
|
87389
|
+
await this.startServer();
|
|
87390
|
+
return {
|
|
87391
|
+
name: this.serverName,
|
|
87392
|
+
command: "node",
|
|
87393
|
+
args: ["-e", RUNTIME_CODE],
|
|
87394
|
+
env: [{
|
|
87395
|
+
name: "ACP_TOOL_PROXY_PORT",
|
|
87396
|
+
value: String(this.port)
|
|
87397
|
+
}]
|
|
87398
|
+
};
|
|
87399
|
+
}
|
|
87400
|
+
/**
|
|
87401
|
+
* Start TCP server to receive tool execution requests
|
|
87402
|
+
*/
|
|
87403
|
+
startServer() {
|
|
87404
|
+
return new Promise((resolve$3, reject) => {
|
|
87405
|
+
this.server = (0, node_net.createServer)((socket) => {
|
|
87406
|
+
this.handleConnection(socket);
|
|
87407
|
+
});
|
|
87408
|
+
this.server.on("error", (err) => {
|
|
87409
|
+
reject(err);
|
|
87410
|
+
});
|
|
87411
|
+
this.server.listen(0, "127.0.0.1", () => {
|
|
87412
|
+
const address = this.server.address();
|
|
87413
|
+
if (typeof address === "object" && address) {
|
|
87414
|
+
this.port = address.port;
|
|
87415
|
+
resolve$3();
|
|
87416
|
+
} else reject(/* @__PURE__ */ new Error("Failed to get server address"));
|
|
87417
|
+
});
|
|
87418
|
+
});
|
|
87419
|
+
}
|
|
87420
|
+
/**
|
|
87421
|
+
* Handle incoming connection from runtime
|
|
87422
|
+
*/
|
|
87423
|
+
handleConnection(socket) {
|
|
87424
|
+
this.connections.push(socket);
|
|
87425
|
+
let buffer$2 = "";
|
|
87426
|
+
socket.on("data", (data$1) => {
|
|
87427
|
+
buffer$2 += data$1.toString();
|
|
87428
|
+
const lines = buffer$2.split("\n");
|
|
87429
|
+
buffer$2 = lines.pop() || "";
|
|
87430
|
+
for (const line$1 of lines) {
|
|
87431
|
+
if (!line$1.trim()) continue;
|
|
87432
|
+
const message = parseMessage(line$1);
|
|
87433
|
+
if (!message) continue;
|
|
87434
|
+
if ("method" in message) this.handleRequest(socket, message).catch((err) => console.error("[ToolProxy] Error handling request:", err));
|
|
87435
|
+
}
|
|
87436
|
+
});
|
|
87437
|
+
socket.on("close", () => {
|
|
87438
|
+
this.connections = this.connections.filter((c) => c !== socket);
|
|
87439
|
+
});
|
|
87440
|
+
socket.on("error", (err) => {
|
|
87441
|
+
console.error("[ToolProxy] Socket error:", err);
|
|
87442
|
+
});
|
|
87443
|
+
}
|
|
87444
|
+
/**
|
|
87445
|
+
* Handle JSON-RPC request from runtime
|
|
87446
|
+
*/
|
|
87447
|
+
async handleRequest(socket, request$1) {
|
|
87448
|
+
try {
|
|
87449
|
+
if (request$1.method === ProxyMethod.CALL_HANDLER) {
|
|
87450
|
+
const params = request$1.params;
|
|
87451
|
+
const tool2 = this.tools.get(params.name);
|
|
87452
|
+
if (!tool2) {
|
|
87453
|
+
this.sendResponse(socket, createErrorResponse(request$1.id, JsonRpcErrorCode.METHOD_NOT_FOUND, `Tool not found: ${params.name}`));
|
|
87454
|
+
return;
|
|
87455
|
+
}
|
|
87456
|
+
if (!tool2.execute) {
|
|
87457
|
+
this.sendResponse(socket, createErrorResponse(request$1.id, JsonRpcErrorCode.INTERNAL_ERROR, `Tool has no execute function: ${params.name}`));
|
|
87458
|
+
return;
|
|
87459
|
+
}
|
|
87460
|
+
const result = await tool2.execute?.(params.args, {
|
|
87461
|
+
toolCallId: params.name,
|
|
87462
|
+
messages: []
|
|
87463
|
+
});
|
|
87464
|
+
const toolResult = { content: [{
|
|
87465
|
+
type: "text",
|
|
87466
|
+
text: typeof result === "string" ? result : JSON.stringify(result)
|
|
87467
|
+
}] };
|
|
87468
|
+
this.sendResponse(socket, createResponse(request$1.id, toolResult));
|
|
87469
|
+
} else if (request$1.method === "getTools") this.sendResponse(socket, createResponse(request$1.id, this.getToolDefinitions()));
|
|
87470
|
+
else this.sendResponse(socket, createErrorResponse(request$1.id, JsonRpcErrorCode.METHOD_NOT_FOUND, `Unknown method: ${request$1.method}`));
|
|
87471
|
+
} catch (error$1) {
|
|
87472
|
+
this.sendResponse(socket, createErrorResponse(request$1.id, JsonRpcErrorCode.INTERNAL_ERROR, error$1 instanceof Error ? error$1.message : String(error$1)));
|
|
87473
|
+
}
|
|
87474
|
+
}
|
|
87475
|
+
/**
|
|
87476
|
+
* Send response to runtime
|
|
87477
|
+
*/
|
|
87478
|
+
sendResponse(socket, response) {
|
|
87479
|
+
socket.write(serializeMessage(response) + "\n");
|
|
87480
|
+
}
|
|
87481
|
+
/**
|
|
87482
|
+
* Stop the TCP server
|
|
87483
|
+
*/
|
|
87484
|
+
stop() {
|
|
87485
|
+
for (const socket of this.connections) socket.destroy();
|
|
87486
|
+
this.connections = [];
|
|
87487
|
+
if (this.server) {
|
|
87488
|
+
this.server.close();
|
|
87489
|
+
this.server = null;
|
|
87490
|
+
}
|
|
87491
|
+
this.port = 0;
|
|
87492
|
+
}
|
|
87493
|
+
};
|
|
87233
87494
|
var ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME = "acp.acp_provider_agent_dynamic_tool";
|
|
87495
|
+
var executeRegistry = /* @__PURE__ */ new Map();
|
|
87496
|
+
function acpTools(tools) {
|
|
87497
|
+
for (const [name, toolDef] of Object.entries(tools)) if (toolDef.execute) executeRegistry.set(name, toolDef.execute);
|
|
87498
|
+
return {
|
|
87499
|
+
...tools,
|
|
87500
|
+
...getACPDynamicTool()
|
|
87501
|
+
};
|
|
87502
|
+
}
|
|
87503
|
+
function getACPDynamicTool() {
|
|
87504
|
+
return { [ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME]: (0, ai.tool)({
|
|
87505
|
+
type: "provider-defined",
|
|
87506
|
+
id: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME,
|
|
87507
|
+
name: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME,
|
|
87508
|
+
args: {},
|
|
87509
|
+
inputSchema: (0, ai.jsonSchema)({})
|
|
87510
|
+
}) };
|
|
87511
|
+
}
|
|
87512
|
+
function getExecuteByName(name) {
|
|
87513
|
+
return executeRegistry.get(name);
|
|
87514
|
+
}
|
|
87515
|
+
function hasRegisteredExecute(name) {
|
|
87516
|
+
return executeRegistry.has(name);
|
|
87517
|
+
}
|
|
87518
|
+
var ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME2 = "acp.acp_provider_agent_dynamic_tool";
|
|
87234
87519
|
var providerAgentDynamicToolSchema = zod.default.object({
|
|
87235
87520
|
toolCallId: zod.default.string().describe("The unique ID of the tool call."),
|
|
87236
87521
|
toolName: zod.default.string().describe("The name of the tool being called."),
|
|
@@ -87257,11 +87542,11 @@ var ACPAISDKClient = class {
|
|
|
87257
87542
|
} };
|
|
87258
87543
|
}
|
|
87259
87544
|
writeTextFile(params) {
|
|
87260
|
-
console.log("Write file request (not implemented):", params.path);
|
|
87545
|
+
console.log("[acp-ai-provider] Write file request (not implemented):", params.path);
|
|
87261
87546
|
throw new Error("File operations not implemented in language model client");
|
|
87262
87547
|
}
|
|
87263
87548
|
readTextFile(params) {
|
|
87264
|
-
console.log("Read file request (not implemented):", params.path);
|
|
87549
|
+
console.log("[acp-ai-provider] Read file request (not implemented):", params.path);
|
|
87265
87550
|
throw new Error("File operations not implemented in language model client");
|
|
87266
87551
|
}
|
|
87267
87552
|
};
|
|
@@ -87269,6 +87554,7 @@ var ACPLanguageModel = class {
|
|
|
87269
87554
|
specificationVersion = "v2";
|
|
87270
87555
|
provider = "acp";
|
|
87271
87556
|
modelId;
|
|
87557
|
+
modeId;
|
|
87272
87558
|
supportedUrls = {};
|
|
87273
87559
|
config;
|
|
87274
87560
|
agentProcess = null;
|
|
@@ -87276,13 +87562,17 @@ var ACPLanguageModel = class {
|
|
|
87276
87562
|
sessionId = null;
|
|
87277
87563
|
sessionResponse = null;
|
|
87278
87564
|
client = null;
|
|
87565
|
+
currentModelId = null;
|
|
87566
|
+
currentModeId = null;
|
|
87279
87567
|
textBlockIndex = 0;
|
|
87280
87568
|
thinkBlockIndex = 0;
|
|
87281
87569
|
currentTextId = null;
|
|
87282
87570
|
currentThinkingId = null;
|
|
87283
87571
|
toolCallsMap = /* @__PURE__ */ new Map();
|
|
87284
|
-
|
|
87572
|
+
toolProxyHost = null;
|
|
87573
|
+
constructor(modelId, modeId, config) {
|
|
87285
87574
|
this.modelId = modelId;
|
|
87575
|
+
this.modeId = modeId;
|
|
87286
87576
|
this.config = config;
|
|
87287
87577
|
}
|
|
87288
87578
|
/**
|
|
@@ -87344,7 +87634,7 @@ var ACPLanguageModel = class {
|
|
|
87344
87634
|
if (Array.isArray(msg.content)) {
|
|
87345
87635
|
let isFirst = true;
|
|
87346
87636
|
for (const part of msg.content) if (part.type === "text") {
|
|
87347
|
-
const text$2 = isFirst ? `${prefix}${part.text}` : part.text;
|
|
87637
|
+
const text$2 = isFirst ? `${prefix}${part.text} ` : part.text;
|
|
87348
87638
|
contentBlocks.push({
|
|
87349
87639
|
type: "text",
|
|
87350
87640
|
text: text$2
|
|
@@ -87360,33 +87650,42 @@ var ACPLanguageModel = class {
|
|
|
87360
87650
|
}
|
|
87361
87651
|
} else if (typeof msg.content === "string") contentBlocks.push({
|
|
87362
87652
|
type: "text",
|
|
87363
|
-
text: `${prefix}${msg.content}`
|
|
87653
|
+
text: `${prefix}${msg.content} `
|
|
87364
87654
|
});
|
|
87365
87655
|
}
|
|
87366
87656
|
return contentBlocks;
|
|
87367
87657
|
}
|
|
87368
87658
|
/**
|
|
87369
87659
|
* Ensures the ACP agent process is running and a session is established.
|
|
87660
|
+
* @param acpTools - Tools from streamText options to proxy
|
|
87370
87661
|
*/
|
|
87371
|
-
|
|
87372
|
-
|
|
87373
|
-
|
|
87374
|
-
|
|
87375
|
-
|
|
87376
|
-
|
|
87377
|
-
|
|
87378
|
-
|
|
87379
|
-
],
|
|
87380
|
-
|
|
87381
|
-
|
|
87382
|
-
|
|
87383
|
-
|
|
87384
|
-
|
|
87385
|
-
|
|
87386
|
-
|
|
87387
|
-
|
|
87388
|
-
|
|
87389
|
-
|
|
87662
|
+
/**
|
|
87663
|
+
* Connects to the ACP agent process and initializes the protocol connection.
|
|
87664
|
+
* Does NOT start a session.
|
|
87665
|
+
*/
|
|
87666
|
+
async connectClient() {
|
|
87667
|
+
if (this.connection) return;
|
|
87668
|
+
if (!this.agentProcess) {
|
|
87669
|
+
const sessionCwd = this.config.session?.cwd || (typeof node_process.default.cwd === "function" ? node_process.default.cwd() : "/");
|
|
87670
|
+
this.agentProcess = (0, node_child_process.spawn)(this.config.command, this.config.args ?? [], {
|
|
87671
|
+
stdio: [
|
|
87672
|
+
"pipe",
|
|
87673
|
+
"pipe",
|
|
87674
|
+
"inherit"
|
|
87675
|
+
],
|
|
87676
|
+
env: {
|
|
87677
|
+
...node_process.default.env,
|
|
87678
|
+
...this.config.env
|
|
87679
|
+
},
|
|
87680
|
+
cwd: sessionCwd
|
|
87681
|
+
});
|
|
87682
|
+
if (!this.agentProcess.stdout || !this.agentProcess.stdin) throw new Error("Failed to spawn agent process with stdio");
|
|
87683
|
+
const input = node_stream.Writable.toWeb(this.agentProcess.stdin);
|
|
87684
|
+
const output = node_stream.Readable.toWeb(this.agentProcess.stdout);
|
|
87685
|
+
this.client = new ACPAISDKClient();
|
|
87686
|
+
this.connection = new __agentclientprotocol_sdk.ClientSideConnection(() => this.client, (0, __agentclientprotocol_sdk.ndJsonStream)(input, output));
|
|
87687
|
+
}
|
|
87688
|
+
if (!this.connection) throw new Error("Connection not initialized");
|
|
87390
87689
|
const initConfig = {
|
|
87391
87690
|
...this.config.initialize ?? {},
|
|
87392
87691
|
protocolVersion: this.config.initialize?.protocolVersion ?? __agentclientprotocol_sdk.PROTOCOL_VERSION,
|
|
@@ -87401,25 +87700,105 @@ var ACPLanguageModel = class {
|
|
|
87401
87700
|
const initResult = await this.connection.initialize(initConfig);
|
|
87402
87701
|
const validAuthMethods = initResult.authMethods?.find((a) => a.id === this.config.authMethodId)?.id;
|
|
87403
87702
|
if (initResult.authMethods?.length ?? false) {
|
|
87404
|
-
if (!this.config.authMethodId || !validAuthMethods) console.log("
|
|
87703
|
+
if (!this.config.authMethodId || !validAuthMethods) console.log("[acp-ai-provider] Warning: No authMethodId specified in config, skipping authentication step. If this is not desired, please set one of the authMethodId in the ACPProviderSettings.", JSON.stringify(initResult.authMethods, null, 2));
|
|
87405
87704
|
if (this.config.authMethodId && validAuthMethods) await this.connection.authenticate({ methodId: this.config.authMethodId ?? initResult.authMethods?.[0].id });
|
|
87406
|
-
} else console.log(
|
|
87705
|
+
} else console.log(`[acp-ai-provider] No authentication methods required by the ACP agent, skipping authentication step.`);
|
|
87706
|
+
}
|
|
87707
|
+
/**
|
|
87708
|
+
* Prepares the list of MCP servers, including the tool proxy if needed.
|
|
87709
|
+
*/
|
|
87710
|
+
async prepareMcpServers(acpTools2) {
|
|
87711
|
+
const mcpServers = [...this.config.session?.mcpServers ?? []];
|
|
87712
|
+
if (acpTools2 && acpTools2.length > 0) {
|
|
87713
|
+
if (!this.toolProxyHost) this.toolProxyHost = new ToolProxyHost("acp-ai-sdk-tools");
|
|
87714
|
+
for (const t$5 of acpTools2) this.toolProxyHost.registerTool(t$5.name, t$5);
|
|
87715
|
+
if (!this.toolProxyHost) {
|
|
87716
|
+
this.toolProxyHost = new ToolProxyHost("acp-ai-sdk-tools");
|
|
87717
|
+
for (const t$5 of acpTools2) this.toolProxyHost.registerTool(t$5.name, t$5);
|
|
87718
|
+
const proxyConfig = await this.toolProxyHost.start();
|
|
87719
|
+
mcpServers.push(proxyConfig);
|
|
87720
|
+
}
|
|
87721
|
+
}
|
|
87722
|
+
return mcpServers;
|
|
87723
|
+
}
|
|
87724
|
+
async prepareToolProxy(acpTools2, mcpServers) {
|
|
87725
|
+
if (this.toolProxyHost) return;
|
|
87726
|
+
this.toolProxyHost = new ToolProxyHost("acp-ai-sdk-tools");
|
|
87727
|
+
for (const t$5 of acpTools2) this.toolProxyHost.registerTool(t$5.name, t$5);
|
|
87728
|
+
const proxyConfig = await this.toolProxyHost.start();
|
|
87729
|
+
mcpServers.push(proxyConfig);
|
|
87730
|
+
}
|
|
87731
|
+
/**
|
|
87732
|
+
* Starts a new session or updates the existing one.
|
|
87733
|
+
* Assumes connectClient() has been called.
|
|
87734
|
+
*/
|
|
87735
|
+
async startSession(acpTools2) {
|
|
87736
|
+
if (!this.connection) throw new Error("Not connected");
|
|
87737
|
+
console.log(`[acp-ai-provider] startSession called with ${acpTools2?.length ?? 0} tools`);
|
|
87738
|
+
const mcpServers = [...this.config.session?.mcpServers ?? []];
|
|
87739
|
+
let toolsAdded = false;
|
|
87740
|
+
if (acpTools2 && acpTools2.length > 0 && !this.toolProxyHost) {
|
|
87741
|
+
console.log("[acp-ai-provider] Setting up tool proxy for client-side tools...");
|
|
87742
|
+
this.toolProxyHost = new ToolProxyHost("acp-ai-sdk-tools");
|
|
87743
|
+
for (const t$5 of acpTools2) this.toolProxyHost.registerTool(t$5.name, t$5);
|
|
87744
|
+
const proxyConfig = await this.toolProxyHost.start();
|
|
87745
|
+
mcpServers.push(proxyConfig);
|
|
87746
|
+
toolsAdded = true;
|
|
87747
|
+
}
|
|
87748
|
+
if (this.sessionId && toolsAdded) {
|
|
87749
|
+
console.log("[acp-ai-provider] Updating session to include new tools...");
|
|
87750
|
+
this.sessionResponse = await this.connection.newSession({
|
|
87751
|
+
...this.config.session,
|
|
87752
|
+
cwd: this.config.session?.cwd ?? node_process.default.cwd(),
|
|
87753
|
+
mcpServers
|
|
87754
|
+
});
|
|
87755
|
+
this.sessionId = this.sessionResponse.sessionId;
|
|
87756
|
+
await this.applySessionDelay();
|
|
87757
|
+
return;
|
|
87758
|
+
}
|
|
87759
|
+
if (this.sessionId) return;
|
|
87407
87760
|
if (this.config.existingSessionId) {
|
|
87408
87761
|
await this.connection.loadSession({
|
|
87409
87762
|
sessionId: this.config.existingSessionId,
|
|
87410
|
-
cwd: this.config.session?.cwd ??
|
|
87411
|
-
mcpServers
|
|
87763
|
+
cwd: this.config.session?.cwd ?? node_process.default.cwd(),
|
|
87764
|
+
mcpServers
|
|
87412
87765
|
});
|
|
87413
87766
|
this.sessionId = this.config.existingSessionId;
|
|
87414
87767
|
this.sessionResponse = { sessionId: this.config.existingSessionId };
|
|
87415
87768
|
} else {
|
|
87416
87769
|
this.sessionResponse = await this.connection.newSession({
|
|
87417
87770
|
...this.config.session,
|
|
87418
|
-
cwd: this.config.session?.cwd ??
|
|
87419
|
-
mcpServers
|
|
87771
|
+
cwd: this.config.session?.cwd ?? node_process.default.cwd(),
|
|
87772
|
+
mcpServers
|
|
87420
87773
|
});
|
|
87421
87774
|
this.sessionId = this.sessionResponse.sessionId;
|
|
87422
87775
|
}
|
|
87776
|
+
const { models, modes } = this.sessionResponse ?? {};
|
|
87777
|
+
if (models?.currentModelId) this.currentModelId = models.currentModelId;
|
|
87778
|
+
if (modes?.currentModeId) this.currentModeId = modes.currentModeId;
|
|
87779
|
+
if (this.modelId && this.modelId !== this.currentModelId) {
|
|
87780
|
+
await this.setModel(this.modelId);
|
|
87781
|
+
this.currentModelId = this.modelId;
|
|
87782
|
+
}
|
|
87783
|
+
if (this.modeId && this.modeId !== this.currentModeId) {
|
|
87784
|
+
await this.setMode(this.modeId);
|
|
87785
|
+
this.currentModeId = this.modeId;
|
|
87786
|
+
}
|
|
87787
|
+
await this.applySessionDelay();
|
|
87788
|
+
}
|
|
87789
|
+
async applySessionDelay() {
|
|
87790
|
+
if (this.config.sessionDelayMs) {
|
|
87791
|
+
console.log(`[acp-ai-provider] Waiting for ${this.config.sessionDelayMs}ms after session setup...`);
|
|
87792
|
+
await new Promise((resolve$3) => setTimeout(resolve$3, this.config.sessionDelayMs));
|
|
87793
|
+
}
|
|
87794
|
+
}
|
|
87795
|
+
/**
|
|
87796
|
+
* Ensures the ACP agent process is running and a session is established.
|
|
87797
|
+
* @param acpTools - Tools from streamText options to proxy
|
|
87798
|
+
*/
|
|
87799
|
+
async ensureConnected(acpTools2) {
|
|
87800
|
+
await this.connectClient();
|
|
87801
|
+
await this.startSession(acpTools2);
|
|
87423
87802
|
}
|
|
87424
87803
|
/**
|
|
87425
87804
|
* Clears connection state. Skips if persistSession is enabled.
|
|
@@ -87438,8 +87817,20 @@ var ACPLanguageModel = class {
|
|
|
87438
87817
|
* Initializes the session and returns session info (models, modes, meta).
|
|
87439
87818
|
* Call this before prompting to discover available options.
|
|
87440
87819
|
*/
|
|
87441
|
-
|
|
87442
|
-
|
|
87820
|
+
/**
|
|
87821
|
+
* Initializes the session and returns session info (models, modes, meta).
|
|
87822
|
+
* Call this before prompting to discover available options.
|
|
87823
|
+
*
|
|
87824
|
+
* @param acpTools - Optional list of tools to register during session initialization.
|
|
87825
|
+
*/
|
|
87826
|
+
async initSession(acpTools2) {
|
|
87827
|
+
let toolsArray = [];
|
|
87828
|
+
if (acpTools2) if (Array.isArray(acpTools2)) toolsArray = acpTools2;
|
|
87829
|
+
else toolsArray = Object.entries(acpTools2).map(([name, tool2]) => ({
|
|
87830
|
+
...tool2,
|
|
87831
|
+
name
|
|
87832
|
+
}));
|
|
87833
|
+
await this.ensureConnected(toolsArray);
|
|
87443
87834
|
return this.sessionResponse;
|
|
87444
87835
|
}
|
|
87445
87836
|
/**
|
|
@@ -87447,25 +87838,47 @@ var ACPLanguageModel = class {
|
|
|
87447
87838
|
*/
|
|
87448
87839
|
async setMode(modeId) {
|
|
87449
87840
|
if (!this.connection || !this.sessionId) throw new Error("Not connected. Call preconnect() first.");
|
|
87841
|
+
const availableModes = this.sessionResponse?.modes?.availableModes;
|
|
87842
|
+
if (availableModes) {
|
|
87843
|
+
if (!availableModes.find((m) => m.id === modeId)) {
|
|
87844
|
+
const availableList = availableModes.map((m) => m.id).join(", ");
|
|
87845
|
+
const currentInfo = this.sessionResponse?.modes?.currentModeId ? ` (Current: "${this.sessionResponse.modes.currentModeId}")` : "";
|
|
87846
|
+
throw new Error(`Mode "${modeId}" is not available${currentInfo}. Available modes: ${availableList}`);
|
|
87847
|
+
}
|
|
87848
|
+
}
|
|
87450
87849
|
await this.connection.setSessionMode({
|
|
87451
87850
|
sessionId: this.sessionId,
|
|
87452
87851
|
modeId
|
|
87453
87852
|
});
|
|
87853
|
+
this.currentModeId = modeId;
|
|
87454
87854
|
}
|
|
87455
87855
|
/**
|
|
87456
87856
|
* Sets the session model.
|
|
87457
87857
|
*/
|
|
87458
87858
|
async setModel(modelId) {
|
|
87459
87859
|
if (!this.connection || !this.sessionId) throw new Error("Not connected. Call preconnect() first.");
|
|
87860
|
+
const { models } = this.sessionResponse ?? {};
|
|
87861
|
+
if (models?.availableModels) {
|
|
87862
|
+
if (!models.availableModels.some((m) => m.modelId === modelId)) {
|
|
87863
|
+
const availableList = models.availableModels.map((m) => m.modelId).join(", ");
|
|
87864
|
+
const currentInfo = this.currentModelId ? ` (Current: "${this.currentModelId}")` : "";
|
|
87865
|
+
throw new Error(`Model "${modelId}" is not available${currentInfo}. Available models: ${availableList}`);
|
|
87866
|
+
}
|
|
87867
|
+
}
|
|
87460
87868
|
await this.connection.setSessionModel({
|
|
87461
87869
|
sessionId: this.sessionId,
|
|
87462
87870
|
modelId
|
|
87463
87871
|
});
|
|
87872
|
+
this.currentModelId = modelId;
|
|
87464
87873
|
}
|
|
87465
87874
|
/**
|
|
87466
87875
|
* Forces cleanup regardless of persistSession setting.
|
|
87467
87876
|
*/
|
|
87468
87877
|
forceCleanup() {
|
|
87878
|
+
if (this.toolProxyHost) {
|
|
87879
|
+
this.toolProxyHost.stop();
|
|
87880
|
+
this.toolProxyHost = null;
|
|
87881
|
+
}
|
|
87469
87882
|
if (this.agentProcess) {
|
|
87470
87883
|
this.agentProcess.kill();
|
|
87471
87884
|
this.agentProcess.stdin?.end();
|
|
@@ -87492,7 +87905,7 @@ var ACPLanguageModel = class {
|
|
|
87492
87905
|
break;
|
|
87493
87906
|
case "agent_thought_chunk":
|
|
87494
87907
|
if (!this.currentThinkingId) {
|
|
87495
|
-
this.currentThinkingId = `reasoning
|
|
87908
|
+
this.currentThinkingId = `reasoning - ${this.thinkBlockIndex++} `;
|
|
87496
87909
|
controller.enqueue({
|
|
87497
87910
|
type: "reasoning-start",
|
|
87498
87911
|
id: this.currentThinkingId
|
|
@@ -87515,7 +87928,7 @@ var ACPLanguageModel = class {
|
|
|
87515
87928
|
if (update$1.content.type === "text") {
|
|
87516
87929
|
const textChunk = update$1.content.text;
|
|
87517
87930
|
if (!this.currentTextId) {
|
|
87518
|
-
this.currentTextId = `text
|
|
87931
|
+
this.currentTextId = `text - ${this.textBlockIndex++} `;
|
|
87519
87932
|
controller.enqueue({
|
|
87520
87933
|
type: "text-start",
|
|
87521
87934
|
id: this.currentTextId
|
|
@@ -87547,7 +87960,7 @@ var ACPLanguageModel = class {
|
|
|
87547
87960
|
controller.enqueue({
|
|
87548
87961
|
type: "tool-call",
|
|
87549
87962
|
toolCallId,
|
|
87550
|
-
toolName:
|
|
87963
|
+
toolName: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME2,
|
|
87551
87964
|
input: JSON.stringify({
|
|
87552
87965
|
toolCallId,
|
|
87553
87966
|
toolName,
|
|
@@ -87573,7 +87986,7 @@ var ACPLanguageModel = class {
|
|
|
87573
87986
|
controller.enqueue({
|
|
87574
87987
|
type: "tool-call",
|
|
87575
87988
|
toolCallId,
|
|
87576
|
-
toolName:
|
|
87989
|
+
toolName: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME2,
|
|
87577
87990
|
input: JSON.stringify({
|
|
87578
87991
|
toolCallId,
|
|
87579
87992
|
toolName
|
|
@@ -87583,7 +87996,7 @@ var ACPLanguageModel = class {
|
|
|
87583
87996
|
controller.enqueue({
|
|
87584
87997
|
type: "tool-result",
|
|
87585
87998
|
toolCallId,
|
|
87586
|
-
toolName:
|
|
87999
|
+
toolName: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME2,
|
|
87587
88000
|
result: toolResult,
|
|
87588
88001
|
providerExecuted: true,
|
|
87589
88002
|
...isError && {
|
|
@@ -87674,7 +88087,21 @@ var ACPLanguageModel = class {
|
|
|
87674
88087
|
* Implements the streaming generation method.
|
|
87675
88088
|
*/
|
|
87676
88089
|
async doStream(options) {
|
|
87677
|
-
|
|
88090
|
+
const acpTools2 = [];
|
|
88091
|
+
if (options.tools) {
|
|
88092
|
+
for (const t$5 of options.tools) if (t$5.type === "function") {
|
|
88093
|
+
const toolInputSchema = t$5.inputSchema;
|
|
88094
|
+
if (hasRegisteredExecute(t$5.name) && toolInputSchema) {
|
|
88095
|
+
const execute = getExecuteByName(t$5.name);
|
|
88096
|
+
if (execute) acpTools2.push({
|
|
88097
|
+
...t$5,
|
|
88098
|
+
name: t$5.name,
|
|
88099
|
+
execute
|
|
88100
|
+
});
|
|
88101
|
+
}
|
|
88102
|
+
}
|
|
88103
|
+
}
|
|
88104
|
+
await this.ensureConnected(acpTools2.length > 0 ? acpTools2 : void 0);
|
|
87678
88105
|
const promptContent = this.getPromptContent(options);
|
|
87679
88106
|
const connection = this.connection;
|
|
87680
88107
|
const sessionId = this.sessionId;
|
|
@@ -87723,18 +88150,8 @@ var ACPLanguageModel = class {
|
|
|
87723
88150
|
warnings: []
|
|
87724
88151
|
};
|
|
87725
88152
|
}
|
|
87726
|
-
/**
|
|
87727
|
-
* Defines the provider agent dynamic tool used to bridge ACP's agent-side tool calls
|
|
87728
|
-
* with the AI SDK's tool execution flow.
|
|
87729
|
-
*/
|
|
87730
88153
|
get tools() {
|
|
87731
|
-
return
|
|
87732
|
-
name: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME,
|
|
87733
|
-
type: "provider-defined",
|
|
87734
|
-
inputSchema: (0, ai.jsonSchema)({}),
|
|
87735
|
-
id: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME,
|
|
87736
|
-
args: (0, ai.jsonSchema)({})
|
|
87737
|
-
}) };
|
|
88154
|
+
return getACPDynamicTool();
|
|
87738
88155
|
}
|
|
87739
88156
|
};
|
|
87740
88157
|
var ACPProvider = class {
|
|
@@ -87748,8 +88165,10 @@ var ACPProvider = class {
|
|
|
87748
88165
|
*
|
|
87749
88166
|
* @returns A LanguageModelV2 instance
|
|
87750
88167
|
*/
|
|
87751
|
-
languageModel() {
|
|
87752
|
-
if (!this.model) this.model = new ACPLanguageModel(
|
|
88168
|
+
languageModel(modelId, modeId) {
|
|
88169
|
+
if (!this.model) this.model = new ACPLanguageModel(modelId, modeId, this.config);
|
|
88170
|
+
if (modelId) this.model.modelId = modelId;
|
|
88171
|
+
if (modeId) this.model.modeId = modeId;
|
|
87753
88172
|
return this.model;
|
|
87754
88173
|
}
|
|
87755
88174
|
/**
|
|
@@ -87759,7 +88178,7 @@ var ACPProvider = class {
|
|
|
87759
88178
|
return this.languageModel();
|
|
87760
88179
|
}
|
|
87761
88180
|
/**
|
|
87762
|
-
* Provider tools
|
|
88181
|
+
* Provider tools - includes the agent dynamic tool
|
|
87763
88182
|
*/
|
|
87764
88183
|
get tools() {
|
|
87765
88184
|
return this.model?.tools;
|
|
@@ -87775,9 +88194,17 @@ var ACPProvider = class {
|
|
|
87775
88194
|
* Initializes the session and returns session info (models, modes, meta).
|
|
87776
88195
|
* Call this before prompting to discover available options.
|
|
87777
88196
|
*/
|
|
87778
|
-
initSession() {
|
|
88197
|
+
initSession(acpTools2) {
|
|
87779
88198
|
if (!this.model) this.languageModel();
|
|
87780
|
-
return this.model.initSession();
|
|
88199
|
+
return this.model.initSession(acpTools2);
|
|
88200
|
+
}
|
|
88201
|
+
/**
|
|
88202
|
+
* Initializes the connection to the agent process without starting a session.
|
|
88203
|
+
* Useful if you need to reduce the time to the first token.
|
|
88204
|
+
*/
|
|
88205
|
+
connect() {
|
|
88206
|
+
if (!this.model) this.languageModel();
|
|
88207
|
+
return this.model.connectClient();
|
|
87781
88208
|
}
|
|
87782
88209
|
/**
|
|
87783
88210
|
* Sets the session mode (e.g., "ask", "plan").
|
|
@@ -87806,55 +88233,64 @@ function createACPProvider(config) {
|
|
|
87806
88233
|
}
|
|
87807
88234
|
|
|
87808
88235
|
//#endregion
|
|
87809
|
-
//#region src/
|
|
88236
|
+
//#region src/middleware/acp-middleware.ts
|
|
87810
88237
|
/**
|
|
87811
|
-
*
|
|
87812
|
-
* This is more stable than using npx as it uses the installed package directly
|
|
87813
|
-
*
|
|
87814
|
-
* @param packageName - The npm package name (e.g., 'mcp-remote', 'typescript', 'eslint')
|
|
87815
|
-
* @param cwd - Current working directory (defaults to process.cwd())
|
|
87816
|
-
* @returns Object containing the command and args to execute the binary
|
|
87817
|
-
*
|
|
87818
|
-
* @example
|
|
87819
|
-
* ```ts
|
|
87820
|
-
* const { command, args } = resolvePackageBin('mcp-remote');
|
|
87821
|
-
* spawn(command, [...args, 'http://localhost:5173']);
|
|
87822
|
-
* ```
|
|
88238
|
+
* Call MCP method via transport and wait for response
|
|
87823
88239
|
*/
|
|
87824
|
-
function
|
|
87825
|
-
|
|
87826
|
-
|
|
87827
|
-
|
|
87828
|
-
|
|
87829
|
-
|
|
87830
|
-
|
|
87831
|
-
const fullBinPath = (0, node_path.resolve)((0, node_path.dirname)(packageJsonPath), binPath);
|
|
87832
|
-
if ((0, node_fs.existsSync)(fullBinPath)) return {
|
|
87833
|
-
command: "node",
|
|
87834
|
-
args: [fullBinPath]
|
|
87835
|
-
};
|
|
87836
|
-
}
|
|
87837
|
-
}
|
|
87838
|
-
} catch (error$1) {}
|
|
87839
|
-
console.warn(`${packageName} not found in node_modules, falling back to npx. Consider installing ${packageName} as a dependency.`);
|
|
87840
|
-
return {
|
|
87841
|
-
command: "npx",
|
|
87842
|
-
args: [packageName]
|
|
88240
|
+
function callMcpMethodViaTransport(transport, method, params) {
|
|
88241
|
+
const messageId = Date.now();
|
|
88242
|
+
const message = {
|
|
88243
|
+
method,
|
|
88244
|
+
params,
|
|
88245
|
+
jsonrpc: "2.0",
|
|
88246
|
+
id: messageId
|
|
87843
88247
|
};
|
|
88248
|
+
return new Promise((resolve$3) => {
|
|
88249
|
+
transport.onmessage?.(message);
|
|
88250
|
+
const originalSend = transport.send;
|
|
88251
|
+
transport.send = function(payload) {
|
|
88252
|
+
const payloadObj = payload;
|
|
88253
|
+
if (payloadObj.id === messageId) {
|
|
88254
|
+
resolve$3(payloadObj.result);
|
|
88255
|
+
transport.send = originalSend;
|
|
88256
|
+
}
|
|
88257
|
+
return originalSend.call(this, payload);
|
|
88258
|
+
};
|
|
88259
|
+
});
|
|
87844
88260
|
}
|
|
87845
88261
|
/**
|
|
87846
|
-
*
|
|
87847
|
-
* Convenience wrapper around resolvePackageBin for mcp-remote
|
|
87848
|
-
*
|
|
87849
|
-
* @param cwd - Current working directory (defaults to process.cwd())
|
|
87850
|
-
* @returns Object containing the command and args to execute mcp-remote
|
|
88262
|
+
* Load MCP tools from transport in AI SDK v5 format
|
|
87851
88263
|
*/
|
|
87852
|
-
function
|
|
87853
|
-
|
|
88264
|
+
async function loadMcpToolsV5(transport) {
|
|
88265
|
+
const tools = {};
|
|
88266
|
+
const { tools: toolsListFromServer } = await callMcpMethodViaTransport(transport, "tools/list");
|
|
88267
|
+
for (const toolInfo of toolsListFromServer) {
|
|
88268
|
+
const toolName = toolInfo.name;
|
|
88269
|
+
tools[toolName] = (0, ai.tool)({
|
|
88270
|
+
description: toolInfo.description,
|
|
88271
|
+
inputSchema: (0, ai.jsonSchema)(toolInfo.inputSchema),
|
|
88272
|
+
execute: async (args) => {
|
|
88273
|
+
console.log(`[dev-inspector] [acp] Executing MCP tool: ${toolName}`);
|
|
88274
|
+
return await callMcpMethodViaTransport(transport, "tools/call", {
|
|
88275
|
+
name: toolName,
|
|
88276
|
+
arguments: args
|
|
88277
|
+
});
|
|
88278
|
+
}
|
|
88279
|
+
});
|
|
88280
|
+
}
|
|
88281
|
+
console.log(`[dev-inspector] [acp] Loaded ${Object.keys(tools).length} MCP tools`);
|
|
88282
|
+
return tools;
|
|
88283
|
+
}
|
|
88284
|
+
/**
|
|
88285
|
+
* Get an active transport from the connection manager
|
|
88286
|
+
*/
|
|
88287
|
+
function getActiveTransport() {
|
|
88288
|
+
const connectionManager = getConnectionManager();
|
|
88289
|
+
if (!connectionManager) return null;
|
|
88290
|
+
const sessionIds = Object.keys(connectionManager.transports);
|
|
88291
|
+
if (sessionIds.length === 0) return null;
|
|
88292
|
+
return connectionManager.transports[sessionIds[0]];
|
|
87854
88293
|
}
|
|
87855
|
-
|
|
87856
|
-
//#endregion
|
|
87857
|
-
//#region src/middleware/acp-middleware.ts
|
|
87858
88294
|
function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
87859
88295
|
middlewares.use("/api/acp/chat", async (req, res) => {
|
|
87860
88296
|
if (handleCors(res, req.method)) return;
|
|
@@ -87867,42 +88303,26 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
87867
88303
|
const body = await readBody(req);
|
|
87868
88304
|
const { messages, agent, envVars } = JSON.parse(body);
|
|
87869
88305
|
const cwd$1 = process.cwd();
|
|
87870
|
-
const mcpRemote = resolveMcpRemote(cwd$1);
|
|
87871
88306
|
const provider = createACPProvider({
|
|
87872
88307
|
command: agent.command,
|
|
87873
88308
|
args: agent.args,
|
|
87874
88309
|
env: envVars,
|
|
87875
88310
|
session: {
|
|
87876
88311
|
cwd: cwd$1,
|
|
87877
|
-
mcpServers: [
|
|
87878
|
-
command: mcpRemote.command,
|
|
87879
|
-
args: [...mcpRemote.args, `http://${serverContext?.host || "localhost"}:${serverContext?.port || 5173}/__mcp__/sse?clientId=acp&puppetId=inspector`],
|
|
87880
|
-
env: [],
|
|
87881
|
-
name: "inspect"
|
|
87882
|
-
}]
|
|
88312
|
+
mcpServers: []
|
|
87883
88313
|
},
|
|
87884
88314
|
authMethodId: agent.authMethodId
|
|
87885
88315
|
});
|
|
87886
|
-
const
|
|
87887
|
-
|
|
87888
|
-
if (
|
|
87889
|
-
|
|
87890
|
-
console.log("[dev-inspector] [acp] Available modes:", availableModes.map((m) => m.id).join(", "));
|
|
87891
|
-
console.log("[dev-inspector] [acp] Current mode:", currentModeId);
|
|
87892
|
-
}
|
|
87893
|
-
if (sessionInfo.models) {
|
|
87894
|
-
const { availableModels, currentModelId } = sessionInfo.models;
|
|
87895
|
-
console.log("[dev-inspector] [acp] Available models:", availableModels.map((m) => m.modelId).join(", "));
|
|
87896
|
-
console.log("[dev-inspector] [acp] Current model:", currentModelId);
|
|
87897
|
-
}
|
|
88316
|
+
const transport = getActiveTransport();
|
|
88317
|
+
let mcpTools = {};
|
|
88318
|
+
if (transport) mcpTools = await loadMcpToolsV5(transport);
|
|
88319
|
+
else console.warn("[dev-inspector] [acp] No active MCP transport available, tools will not be loaded");
|
|
87898
88320
|
const mode = agent.acpMode ?? acpOptions?.acpMode;
|
|
87899
88321
|
const model = agent.acpModel ?? acpOptions?.acpModel;
|
|
87900
88322
|
const delay = agent.acpDelay ?? acpOptions?.acpDelay;
|
|
87901
|
-
if (mode !== void 0) await provider.setMode(mode);
|
|
87902
|
-
if (model !== void 0) await provider.setModel(model);
|
|
87903
88323
|
if (delay !== void 0 && delay > 0) {
|
|
87904
88324
|
console.log(`[dev-inspector] [acp] Delaying response by ${delay}ms, agent: ${agent.name}`);
|
|
87905
|
-
await new Promise((resolve$
|
|
88325
|
+
await new Promise((resolve$3) => setTimeout(resolve$3, delay));
|
|
87906
88326
|
}
|
|
87907
88327
|
const abortController = new AbortController();
|
|
87908
88328
|
req.on("close", () => {
|
|
@@ -87911,15 +88331,15 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
87911
88331
|
provider.cleanup();
|
|
87912
88332
|
});
|
|
87913
88333
|
const response = (0, ai.streamText)({
|
|
87914
|
-
model: provider.languageModel(),
|
|
88334
|
+
model: provider.languageModel(model, mode),
|
|
87915
88335
|
includeRawChunks: true,
|
|
87916
88336
|
messages: (0, ai.convertToModelMessages)(messages),
|
|
87917
88337
|
abortSignal: abortController.signal,
|
|
88338
|
+
tools: acpTools(mcpTools),
|
|
87918
88339
|
onError: (error$1) => {
|
|
87919
88340
|
console.error("Error occurred while streaming text:", JSON.stringify(error$1, null, 2));
|
|
87920
88341
|
provider.cleanup();
|
|
87921
|
-
}
|
|
87922
|
-
tools: provider.tools
|
|
88342
|
+
}
|
|
87923
88343
|
}).toUIMessageStreamResponse({
|
|
87924
88344
|
messageMetadata: ({ part }) => {
|
|
87925
88345
|
if (part.type === "raw" && part.rawValue) {
|
|
@@ -87963,13 +88383,13 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
87963
88383
|
});
|
|
87964
88384
|
}
|
|
87965
88385
|
function readBody(req) {
|
|
87966
|
-
return new Promise((resolve$
|
|
88386
|
+
return new Promise((resolve$3, reject) => {
|
|
87967
88387
|
let body = "";
|
|
87968
88388
|
req.on("data", (chunk) => {
|
|
87969
88389
|
body += chunk.toString();
|
|
87970
88390
|
});
|
|
87971
88391
|
req.on("end", () => {
|
|
87972
|
-
resolve$
|
|
88392
|
+
resolve$3(body);
|
|
87973
88393
|
});
|
|
87974
88394
|
req.on("error", (err) => {
|
|
87975
88395
|
reject(err);
|