@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.js
CHANGED
|
@@ -7,8 +7,9 @@ import z$1, { z } from "zod";
|
|
|
7
7
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
8
8
|
import { Readable, Writable } from "node:stream";
|
|
9
9
|
import { Readable as Readable$1 } from "stream";
|
|
10
|
+
import { createServer } from "node:net";
|
|
10
11
|
import { createHash } from "node:crypto";
|
|
11
|
-
import path
|
|
12
|
+
import path from "node:path";
|
|
12
13
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
13
14
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
14
15
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
@@ -20,12 +21,11 @@ import fs, { existsSync } from "fs";
|
|
|
20
21
|
import * as http from "http";
|
|
21
22
|
import * as https from "https";
|
|
22
23
|
import * as zlib from "zlib";
|
|
23
|
-
import path$1, { dirname
|
|
24
|
+
import path$1, { dirname, join } from "path";
|
|
24
25
|
import { fileURLToPath } from "url";
|
|
25
26
|
import { convertToModelMessages, jsonSchema, streamText, tool } from "ai";
|
|
26
27
|
import { ClientSideConnection, PROTOCOL_VERSION, ndJsonStream, planEntrySchema } from "@agentclientprotocol/sdk";
|
|
27
28
|
import { spawn } from "node:child_process";
|
|
28
|
-
import { existsSync as existsSync$1, readFileSync } from "node:fs";
|
|
29
29
|
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
30
30
|
|
|
31
31
|
//#region rolldown:runtime
|
|
@@ -276,13 +276,13 @@ var ClientExecServer = class {
|
|
|
276
276
|
return toolCallHandler?.(request$1, extra);
|
|
277
277
|
}
|
|
278
278
|
const requestId = crypto.randomUUID();
|
|
279
|
-
const resultPromise = new Promise((resolve$
|
|
279
|
+
const resultPromise = new Promise((resolve$3, reject) => {
|
|
280
280
|
const timeout = setTimeout(() => {
|
|
281
281
|
this.pendingRequests.delete(requestId);
|
|
282
282
|
reject(new McpError(ErrorCode.InternalError, `Tool execution timeout for ${name}`));
|
|
283
283
|
}, this.requestTimeoutMs);
|
|
284
284
|
this.pendingRequests.set(requestId, {
|
|
285
|
-
resolve: resolve$
|
|
285
|
+
resolve: resolve$3,
|
|
286
286
|
reject,
|
|
287
287
|
timeout
|
|
288
288
|
});
|
|
@@ -26586,9 +26586,9 @@ var require_dispatcher_base = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
26586
26586
|
return this[kClosed$3];
|
|
26587
26587
|
}
|
|
26588
26588
|
close(callback) {
|
|
26589
|
-
if (callback === void 0) return new Promise((resolve$
|
|
26589
|
+
if (callback === void 0) return new Promise((resolve$3, reject) => {
|
|
26590
26590
|
this.close((err, data$1) => {
|
|
26591
|
-
return err ? reject(err) : resolve$
|
|
26591
|
+
return err ? reject(err) : resolve$3(data$1);
|
|
26592
26592
|
});
|
|
26593
26593
|
});
|
|
26594
26594
|
if (typeof callback !== "function") throw new InvalidArgumentError$27("invalid callback");
|
|
@@ -26617,9 +26617,9 @@ var require_dispatcher_base = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
26617
26617
|
callback = err;
|
|
26618
26618
|
err = null;
|
|
26619
26619
|
}
|
|
26620
|
-
if (callback === void 0) return new Promise((resolve$
|
|
26620
|
+
if (callback === void 0) return new Promise((resolve$3, reject) => {
|
|
26621
26621
|
this.destroy(err, (err$1, data$1) => {
|
|
26622
|
-
return err$1 ? reject(err$1) : resolve$
|
|
26622
|
+
return err$1 ? reject(err$1) : resolve$3(data$1);
|
|
26623
26623
|
});
|
|
26624
26624
|
});
|
|
26625
26625
|
if (typeof callback !== "function") throw new InvalidArgumentError$27("invalid callback");
|
|
@@ -29620,8 +29620,8 @@ var require_promise$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
29620
29620
|
let res;
|
|
29621
29621
|
let rej;
|
|
29622
29622
|
return {
|
|
29623
|
-
promise: new Promise((resolve$
|
|
29624
|
-
res = resolve$
|
|
29623
|
+
promise: new Promise((resolve$3, reject) => {
|
|
29624
|
+
res = resolve$3;
|
|
29625
29625
|
rej = reject;
|
|
29626
29626
|
}),
|
|
29627
29627
|
resolve: res,
|
|
@@ -30731,10 +30731,10 @@ var require_client_h1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
30731
30731
|
cb();
|
|
30732
30732
|
}
|
|
30733
30733
|
}
|
|
30734
|
-
const waitForDrain = () => new Promise((resolve$
|
|
30734
|
+
const waitForDrain = () => new Promise((resolve$3, reject) => {
|
|
30735
30735
|
assert$23(callback === null);
|
|
30736
30736
|
if (socket[kError$2]) reject(socket[kError$2]);
|
|
30737
|
-
else callback = resolve$
|
|
30737
|
+
else callback = resolve$3;
|
|
30738
30738
|
});
|
|
30739
30739
|
socket.on("close", onDrain).on("drain", onDrain);
|
|
30740
30740
|
const writer = new AsyncWriter({
|
|
@@ -31262,10 +31262,10 @@ var require_client_h2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
31262
31262
|
cb();
|
|
31263
31263
|
}
|
|
31264
31264
|
}
|
|
31265
|
-
const waitForDrain = () => new Promise((resolve$
|
|
31265
|
+
const waitForDrain = () => new Promise((resolve$3, reject) => {
|
|
31266
31266
|
assert$22(callback === null);
|
|
31267
31267
|
if (socket[kError$1]) reject(socket[kError$1]);
|
|
31268
|
-
else callback = resolve$
|
|
31268
|
+
else callback = resolve$3;
|
|
31269
31269
|
});
|
|
31270
31270
|
h2stream.on("close", onDrain).on("drain", onDrain);
|
|
31271
31271
|
try {
|
|
@@ -31425,13 +31425,13 @@ var require_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
31425
31425
|
return this[kNeedDrain$3] < 2;
|
|
31426
31426
|
}
|
|
31427
31427
|
[kClose$7]() {
|
|
31428
|
-
return new Promise((resolve$
|
|
31429
|
-
if (this[kSize$2]) this[kClosedResolve$1] = resolve$
|
|
31430
|
-
else resolve$
|
|
31428
|
+
return new Promise((resolve$3) => {
|
|
31429
|
+
if (this[kSize$2]) this[kClosedResolve$1] = resolve$3;
|
|
31430
|
+
else resolve$3(null);
|
|
31431
31431
|
});
|
|
31432
31432
|
}
|
|
31433
31433
|
[kDestroy$5](err) {
|
|
31434
|
-
return new Promise((resolve$
|
|
31434
|
+
return new Promise((resolve$3) => {
|
|
31435
31435
|
const requests = this[kQueue$1].splice(this[kPendingIdx]);
|
|
31436
31436
|
for (let i$4 = 0; i$4 < requests.length; i$4++) {
|
|
31437
31437
|
const request$1 = requests[i$4];
|
|
@@ -31442,7 +31442,7 @@ var require_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
31442
31442
|
this[kClosedResolve$1]();
|
|
31443
31443
|
this[kClosedResolve$1] = null;
|
|
31444
31444
|
}
|
|
31445
|
-
resolve$
|
|
31445
|
+
resolve$3(null);
|
|
31446
31446
|
};
|
|
31447
31447
|
if (this[kHTTPContext]) {
|
|
31448
31448
|
this[kHTTPContext].destroy(err, callback);
|
|
@@ -31796,8 +31796,8 @@ var require_pool_base = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
31796
31796
|
const closeAll = new Array(this[kClients$4].length);
|
|
31797
31797
|
for (let i$4 = 0; i$4 < this[kClients$4].length; i$4++) closeAll[i$4] = this[kClients$4][i$4].close();
|
|
31798
31798
|
return Promise.all(closeAll);
|
|
31799
|
-
} else return new Promise((resolve$
|
|
31800
|
-
this[kClosedResolve] = resolve$
|
|
31799
|
+
} else return new Promise((resolve$3) => {
|
|
31800
|
+
this[kClosedResolve] = resolve$3;
|
|
31801
31801
|
});
|
|
31802
31802
|
}
|
|
31803
31803
|
[kDestroy$4](err) {
|
|
@@ -33017,7 +33017,7 @@ var require_readable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
33017
33017
|
const limit = opts?.limit && Number.isFinite(opts.limit) ? opts.limit : 128 * 1024;
|
|
33018
33018
|
if (signal?.aborted) return Promise.reject(signal.reason ?? new AbortError$1());
|
|
33019
33019
|
if (this._readableState.closeEmitted) return Promise.resolve(null);
|
|
33020
|
-
return new Promise((resolve$
|
|
33020
|
+
return new Promise((resolve$3, reject) => {
|
|
33021
33021
|
if (this[kContentLength$1] && this[kContentLength$1] > limit || this[kBytesRead] > limit) this.destroy(new AbortError$1());
|
|
33022
33022
|
if (signal) {
|
|
33023
33023
|
const onAbort = () => {
|
|
@@ -33027,9 +33027,9 @@ var require_readable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
33027
33027
|
this.on("close", function() {
|
|
33028
33028
|
signal.removeEventListener("abort", onAbort);
|
|
33029
33029
|
if (signal.aborted) reject(signal.reason ?? new AbortError$1());
|
|
33030
|
-
else resolve$
|
|
33030
|
+
else resolve$3(null);
|
|
33031
33031
|
});
|
|
33032
|
-
} else this.on("close", resolve$
|
|
33032
|
+
} else this.on("close", resolve$3);
|
|
33033
33033
|
this.on("error", noop$6).on("data", () => {
|
|
33034
33034
|
if (this[kBytesRead] > limit) this.destroy();
|
|
33035
33035
|
}).resume();
|
|
@@ -33090,7 +33090,7 @@ var require_readable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
33090
33090
|
*/
|
|
33091
33091
|
function consume(stream$2, type) {
|
|
33092
33092
|
assert$19(!stream$2[kConsume]);
|
|
33093
|
-
return new Promise((resolve$
|
|
33093
|
+
return new Promise((resolve$3, reject) => {
|
|
33094
33094
|
if (isUnusable(stream$2)) {
|
|
33095
33095
|
const rState = stream$2._readableState;
|
|
33096
33096
|
if (rState.destroyed && rState.closeEmitted === false) stream$2.on("error", reject).on("close", () => {
|
|
@@ -33101,7 +33101,7 @@ var require_readable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
33101
33101
|
stream$2[kConsume] = {
|
|
33102
33102
|
type,
|
|
33103
33103
|
stream: stream$2,
|
|
33104
|
-
resolve: resolve$
|
|
33104
|
+
resolve: resolve$3,
|
|
33105
33105
|
reject,
|
|
33106
33106
|
length: 0,
|
|
33107
33107
|
body: []
|
|
@@ -33171,13 +33171,13 @@ var require_readable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
33171
33171
|
* @returns {void}
|
|
33172
33172
|
*/
|
|
33173
33173
|
function consumeEnd(consume$1, encoding) {
|
|
33174
|
-
const { type, body, resolve: resolve$
|
|
33174
|
+
const { type, body, resolve: resolve$3, stream: stream$2, length } = consume$1;
|
|
33175
33175
|
try {
|
|
33176
|
-
if (type === "text") resolve$
|
|
33177
|
-
else if (type === "json") resolve$
|
|
33178
|
-
else if (type === "arrayBuffer") resolve$
|
|
33179
|
-
else if (type === "blob") resolve$
|
|
33180
|
-
else if (type === "bytes") resolve$
|
|
33176
|
+
if (type === "text") resolve$3(chunksDecode(body, length, encoding));
|
|
33177
|
+
else if (type === "json") resolve$3(JSON.parse(chunksDecode(body, length, encoding)));
|
|
33178
|
+
else if (type === "arrayBuffer") resolve$3(chunksConcat(body, length).buffer);
|
|
33179
|
+
else if (type === "blob") resolve$3(new Blob(body, { type: stream$2[kContentType] }));
|
|
33180
|
+
else if (type === "bytes") resolve$3(chunksConcat(body, length));
|
|
33181
33181
|
consumeFinish(consume$1);
|
|
33182
33182
|
} catch (err) {
|
|
33183
33183
|
stream$2.destroy(err);
|
|
@@ -33345,9 +33345,9 @@ var require_api_request = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
33345
33345
|
}
|
|
33346
33346
|
};
|
|
33347
33347
|
function request(opts, callback) {
|
|
33348
|
-
if (callback === void 0) return new Promise((resolve$
|
|
33348
|
+
if (callback === void 0) return new Promise((resolve$3, reject) => {
|
|
33349
33349
|
request.call(this, opts, (err, data$1) => {
|
|
33350
|
-
return err ? reject(err) : resolve$
|
|
33350
|
+
return err ? reject(err) : resolve$3(data$1);
|
|
33351
33351
|
});
|
|
33352
33352
|
});
|
|
33353
33353
|
try {
|
|
@@ -33517,9 +33517,9 @@ var require_api_stream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
33517
33517
|
}
|
|
33518
33518
|
};
|
|
33519
33519
|
function stream(opts, factory$1, callback) {
|
|
33520
|
-
if (callback === void 0) return new Promise((resolve$
|
|
33520
|
+
if (callback === void 0) return new Promise((resolve$3, reject) => {
|
|
33521
33521
|
stream.call(this, opts, factory$1, (err, data$1) => {
|
|
33522
|
-
return err ? reject(err) : resolve$
|
|
33522
|
+
return err ? reject(err) : resolve$3(data$1);
|
|
33523
33523
|
});
|
|
33524
33524
|
});
|
|
33525
33525
|
try {
|
|
@@ -33762,9 +33762,9 @@ var require_api_upgrade = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
33762
33762
|
}
|
|
33763
33763
|
};
|
|
33764
33764
|
function upgrade(opts, callback) {
|
|
33765
|
-
if (callback === void 0) return new Promise((resolve$
|
|
33765
|
+
if (callback === void 0) return new Promise((resolve$3, reject) => {
|
|
33766
33766
|
upgrade.call(this, opts, (err, data$1) => {
|
|
33767
|
-
return err ? reject(err) : resolve$
|
|
33767
|
+
return err ? reject(err) : resolve$3(data$1);
|
|
33768
33768
|
});
|
|
33769
33769
|
});
|
|
33770
33770
|
try {
|
|
@@ -33843,9 +33843,9 @@ var require_api_connect = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
33843
33843
|
}
|
|
33844
33844
|
};
|
|
33845
33845
|
function connect(opts, callback) {
|
|
33846
|
-
if (callback === void 0) return new Promise((resolve$
|
|
33846
|
+
if (callback === void 0) return new Promise((resolve$3, reject) => {
|
|
33847
33847
|
connect.call(this, opts, (err, data$1) => {
|
|
33848
|
-
return err ? reject(err) : resolve$
|
|
33848
|
+
return err ? reject(err) : resolve$3(data$1);
|
|
33849
33849
|
});
|
|
33850
33850
|
});
|
|
33851
33851
|
try {
|
|
@@ -34903,7 +34903,7 @@ var require_snapshot_utils = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
34903
34903
|
//#region ../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/mock/snapshot-recorder.js
|
|
34904
34904
|
var require_snapshot_recorder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
34905
34905
|
const { writeFile: writeFile$1, readFile: readFile$1, mkdir: mkdir$1 } = __require("node:fs/promises");
|
|
34906
|
-
const { dirname: dirname$
|
|
34906
|
+
const { dirname: dirname$1, resolve: resolve$2 } = __require("node:path");
|
|
34907
34907
|
const { setTimeout: setTimeout$1, clearTimeout: clearTimeout$1 } = __require("node:timers");
|
|
34908
34908
|
const { InvalidArgumentError: InvalidArgumentError$6, UndiciError: UndiciError$1 } = require_errors$1();
|
|
34909
34909
|
const { hashId, isUrlExcludedFactory, normalizeHeaders: normalizeHeaders$2, createHeaderFilters } = require_snapshot_utils();
|
|
@@ -35161,7 +35161,7 @@ var require_snapshot_recorder = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
35161
35161
|
const path$2 = filePath || this.#snapshotPath;
|
|
35162
35162
|
if (!path$2) throw new InvalidArgumentError$6("Snapshot path is required");
|
|
35163
35163
|
try {
|
|
35164
|
-
const data$1 = await readFile$1(resolve$
|
|
35164
|
+
const data$1 = await readFile$1(resolve$2(path$2), "utf8");
|
|
35165
35165
|
const parsed = JSON.parse(data$1);
|
|
35166
35166
|
if (Array.isArray(parsed)) {
|
|
35167
35167
|
this.#snapshots.clear();
|
|
@@ -35181,8 +35181,8 @@ var require_snapshot_recorder = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
35181
35181
|
async saveSnapshots(filePath) {
|
|
35182
35182
|
const path$2 = filePath || this.#snapshotPath;
|
|
35183
35183
|
if (!path$2) throw new InvalidArgumentError$6("Snapshot path is required");
|
|
35184
|
-
const resolvedPath = resolve$
|
|
35185
|
-
await mkdir$1(dirname$
|
|
35184
|
+
const resolvedPath = resolve$2(path$2);
|
|
35185
|
+
await mkdir$1(dirname$1(resolvedPath), { recursive: true });
|
|
35186
35186
|
const data$1 = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
|
|
35187
35187
|
hash,
|
|
35188
35188
|
snapshot
|
|
@@ -40087,7 +40087,7 @@ var require_fetch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
40087
40087
|
const url = requestCurrentURL(request$1);
|
|
40088
40088
|
/** @type {import('../../..').Agent} */
|
|
40089
40089
|
const agent = fetchParams.controller.dispatcher;
|
|
40090
|
-
return new Promise((resolve$
|
|
40090
|
+
return new Promise((resolve$3, reject) => agent.dispatch({
|
|
40091
40091
|
path: url.pathname + url.search,
|
|
40092
40092
|
origin: url.origin,
|
|
40093
40093
|
method: request$1.method,
|
|
@@ -40148,7 +40148,7 @@ var require_fetch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
40148
40148
|
}
|
|
40149
40149
|
}
|
|
40150
40150
|
const onError$1 = this.onError.bind(this);
|
|
40151
|
-
resolve$
|
|
40151
|
+
resolve$3({
|
|
40152
40152
|
status,
|
|
40153
40153
|
statusText,
|
|
40154
40154
|
headersList,
|
|
@@ -40179,7 +40179,7 @@ var require_fetch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
40179
40179
|
if (status !== 101) return;
|
|
40180
40180
|
const headersList = new HeadersList();
|
|
40181
40181
|
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);
|
|
40182
|
-
resolve$
|
|
40182
|
+
resolve$3({
|
|
40183
40183
|
status,
|
|
40184
40184
|
statusText: STATUS_CODES[status],
|
|
40185
40185
|
headersList,
|
|
@@ -46871,7 +46871,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
46871
46871
|
ref = (0, resolve_1$1.resolveUrl)(this.opts.uriResolver, baseId, ref);
|
|
46872
46872
|
const schOrFunc = root$2.refs[ref];
|
|
46873
46873
|
if (schOrFunc) return schOrFunc;
|
|
46874
|
-
let _sch = resolve$
|
|
46874
|
+
let _sch = resolve$1.call(this, root$2, ref);
|
|
46875
46875
|
if (_sch === void 0) {
|
|
46876
46876
|
const schema = (_a$2 = root$2.localRefs) === null || _a$2 === void 0 ? void 0 : _a$2[ref];
|
|
46877
46877
|
const { schemaId } = this.opts;
|
|
@@ -46897,7 +46897,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
46897
46897
|
function sameSchemaEnv(s1, s2) {
|
|
46898
46898
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
46899
46899
|
}
|
|
46900
|
-
function resolve$
|
|
46900
|
+
function resolve$1(root$2, ref) {
|
|
46901
46901
|
let sch;
|
|
46902
46902
|
while (typeof (sch = this.refs[ref]) == "string") ref = sch;
|
|
46903
46903
|
return sch || this.schemas[ref] || resolveSchema.call(this, root$2, ref);
|
|
@@ -47470,7 +47470,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
47470
47470
|
* @param {import('./types/index').Options} [options]
|
|
47471
47471
|
* @returns {string}
|
|
47472
47472
|
*/
|
|
47473
|
-
function resolve
|
|
47473
|
+
function resolve(baseURI, relativeURI, options) {
|
|
47474
47474
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
47475
47475
|
const resolved = resolveComponent(parse$7(baseURI, schemelessOptions), parse$7(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
47476
47476
|
schemelessOptions.skipEscape = true;
|
|
@@ -47669,7 +47669,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
47669
47669
|
const fastUri = {
|
|
47670
47670
|
SCHEMES,
|
|
47671
47671
|
normalize,
|
|
47672
|
-
resolve
|
|
47672
|
+
resolve,
|
|
47673
47673
|
resolveComponent,
|
|
47674
47674
|
equal: equal$1,
|
|
47675
47675
|
serialize,
|
|
@@ -56300,8 +56300,8 @@ var require_promise$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
56300
56300
|
exports.Deferred = void 0;
|
|
56301
56301
|
var Deferred$1 = class {
|
|
56302
56302
|
constructor() {
|
|
56303
|
-
this._promise = new Promise((resolve$
|
|
56304
|
-
this._resolve = resolve$
|
|
56303
|
+
this._promise = new Promise((resolve$3, reject) => {
|
|
56304
|
+
this._resolve = resolve$3;
|
|
56305
56305
|
this._reject = reject;
|
|
56306
56306
|
});
|
|
56307
56307
|
}
|
|
@@ -56367,10 +56367,10 @@ var require_exporter$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
56367
56367
|
* Shared functionality used by Exporters while exporting data, including suppression of Traces.
|
|
56368
56368
|
*/
|
|
56369
56369
|
function _export$1(exporter, arg) {
|
|
56370
|
-
return new Promise((resolve$
|
|
56370
|
+
return new Promise((resolve$3) => {
|
|
56371
56371
|
api_1$50.context.with((0, suppress_tracing_1$5.suppressTracing)(api_1$50.context.active()), () => {
|
|
56372
56372
|
exporter.export(arg, (result) => {
|
|
56373
|
-
resolve$
|
|
56373
|
+
resolve$3(result);
|
|
56374
56374
|
});
|
|
56375
56375
|
});
|
|
56376
56376
|
});
|
|
@@ -57631,19 +57631,19 @@ var require_BatchSpanProcessorBase = /* @__PURE__ */ __commonJSMin(((exports) =>
|
|
|
57631
57631
|
* for all other cases _flush should be used
|
|
57632
57632
|
* */
|
|
57633
57633
|
_flushAll() {
|
|
57634
|
-
return new Promise((resolve$
|
|
57634
|
+
return new Promise((resolve$3, reject) => {
|
|
57635
57635
|
const promises = [];
|
|
57636
57636
|
const count = Math.ceil(this._finishedSpans.length / this._maxExportBatchSize);
|
|
57637
57637
|
for (let i$4 = 0, j = count; i$4 < j; i$4++) promises.push(this._flushOneBatch());
|
|
57638
57638
|
Promise.all(promises).then(() => {
|
|
57639
|
-
resolve$
|
|
57639
|
+
resolve$3();
|
|
57640
57640
|
}).catch(reject);
|
|
57641
57641
|
});
|
|
57642
57642
|
}
|
|
57643
57643
|
_flushOneBatch() {
|
|
57644
57644
|
this._clearTimer();
|
|
57645
57645
|
if (this._finishedSpans.length === 0) return Promise.resolve();
|
|
57646
|
-
return new Promise((resolve$
|
|
57646
|
+
return new Promise((resolve$3, reject) => {
|
|
57647
57647
|
const timer = setTimeout(() => {
|
|
57648
57648
|
reject(/* @__PURE__ */ new Error("Timeout"));
|
|
57649
57649
|
}, this._exportTimeoutMillis);
|
|
@@ -57656,7 +57656,7 @@ var require_BatchSpanProcessorBase = /* @__PURE__ */ __commonJSMin(((exports) =>
|
|
|
57656
57656
|
const doExport = () => this._exporter.export(spans, (result) => {
|
|
57657
57657
|
var _a$2;
|
|
57658
57658
|
clearTimeout(timer);
|
|
57659
|
-
if (result.code === core_1$18.ExportResultCode.SUCCESS) resolve$
|
|
57659
|
+
if (result.code === core_1$18.ExportResultCode.SUCCESS) resolve$3();
|
|
57660
57660
|
else reject((_a$2 = result.error) !== null && _a$2 !== void 0 ? _a$2 : /* @__PURE__ */ new Error("BatchSpanProcessor: span export failed"));
|
|
57661
57661
|
});
|
|
57662
57662
|
let pendingResources = null;
|
|
@@ -58932,12 +58932,12 @@ var require_MultiSpanProcessor = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
58932
58932
|
forceFlush() {
|
|
58933
58933
|
const promises = [];
|
|
58934
58934
|
for (const spanProcessor of this._spanProcessors) promises.push(spanProcessor.forceFlush());
|
|
58935
|
-
return new Promise((resolve$
|
|
58935
|
+
return new Promise((resolve$3) => {
|
|
58936
58936
|
Promise.all(promises).then(() => {
|
|
58937
|
-
resolve$
|
|
58937
|
+
resolve$3();
|
|
58938
58938
|
}).catch((error$1) => {
|
|
58939
58939
|
(0, core_1$14.globalErrorHandler)(error$1 || /* @__PURE__ */ new Error("MultiSpanProcessor: forceFlush failed"));
|
|
58940
|
-
resolve$
|
|
58940
|
+
resolve$3();
|
|
58941
58941
|
});
|
|
58942
58942
|
});
|
|
58943
58943
|
}
|
|
@@ -58950,9 +58950,9 @@ var require_MultiSpanProcessor = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
58950
58950
|
shutdown() {
|
|
58951
58951
|
const promises = [];
|
|
58952
58952
|
for (const spanProcessor of this._spanProcessors) promises.push(spanProcessor.shutdown());
|
|
58953
|
-
return new Promise((resolve$
|
|
58953
|
+
return new Promise((resolve$3, reject) => {
|
|
58954
58954
|
Promise.all(promises).then(() => {
|
|
58955
|
-
resolve$
|
|
58955
|
+
resolve$3();
|
|
58956
58956
|
}, reject);
|
|
58957
58957
|
});
|
|
58958
58958
|
}
|
|
@@ -59059,30 +59059,30 @@ var require_BasicTracerProvider = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
59059
59059
|
forceFlush() {
|
|
59060
59060
|
const timeout = this._config.forceFlushTimeoutMillis;
|
|
59061
59061
|
const promises = this._registeredSpanProcessors.map((spanProcessor) => {
|
|
59062
|
-
return new Promise((resolve$
|
|
59062
|
+
return new Promise((resolve$3) => {
|
|
59063
59063
|
let state;
|
|
59064
59064
|
const timeoutInterval = setTimeout(() => {
|
|
59065
|
-
resolve$
|
|
59065
|
+
resolve$3(/* @__PURE__ */ new Error(`Span processor did not completed within timeout period of ${timeout} ms`));
|
|
59066
59066
|
state = ForceFlushState.timeout;
|
|
59067
59067
|
}, timeout);
|
|
59068
59068
|
spanProcessor.forceFlush().then(() => {
|
|
59069
59069
|
clearTimeout(timeoutInterval);
|
|
59070
59070
|
if (state !== ForceFlushState.timeout) {
|
|
59071
59071
|
state = ForceFlushState.resolved;
|
|
59072
|
-
resolve$
|
|
59072
|
+
resolve$3(state);
|
|
59073
59073
|
}
|
|
59074
59074
|
}).catch((error$1) => {
|
|
59075
59075
|
clearTimeout(timeoutInterval);
|
|
59076
59076
|
state = ForceFlushState.error;
|
|
59077
|
-
resolve$
|
|
59077
|
+
resolve$3(error$1);
|
|
59078
59078
|
});
|
|
59079
59079
|
});
|
|
59080
59080
|
});
|
|
59081
|
-
return new Promise((resolve$
|
|
59081
|
+
return new Promise((resolve$3, reject) => {
|
|
59082
59082
|
Promise.all(promises).then((results) => {
|
|
59083
59083
|
const errors$1 = results.filter((result) => result !== ForceFlushState.resolved);
|
|
59084
59084
|
if (errors$1.length > 0) reject(errors$1);
|
|
59085
|
-
else resolve$
|
|
59085
|
+
else resolve$3();
|
|
59086
59086
|
}).catch((error$1) => reject([error$1]));
|
|
59087
59087
|
});
|
|
59088
59088
|
}
|
|
@@ -61219,11 +61219,11 @@ var __awaiter$3, __generator$3, BoundedQueueExportPromiseHandler;
|
|
|
61219
61219
|
var init_bounded_queue_export_promise_handler = __esmMin((() => {
|
|
61220
61220
|
__awaiter$3 = void 0 && (void 0).__awaiter || function(thisArg, _arguments, P, generator) {
|
|
61221
61221
|
function adopt(value) {
|
|
61222
|
-
return value instanceof P ? value : new P(function(resolve$
|
|
61223
|
-
resolve$
|
|
61222
|
+
return value instanceof P ? value : new P(function(resolve$3) {
|
|
61223
|
+
resolve$3(value);
|
|
61224
61224
|
});
|
|
61225
61225
|
}
|
|
61226
|
-
return new (P || (P = Promise))(function(resolve$
|
|
61226
|
+
return new (P || (P = Promise))(function(resolve$3, reject) {
|
|
61227
61227
|
function fulfilled(value) {
|
|
61228
61228
|
try {
|
|
61229
61229
|
step(generator.next(value));
|
|
@@ -61239,7 +61239,7 @@ var init_bounded_queue_export_promise_handler = __esmMin((() => {
|
|
|
61239
61239
|
}
|
|
61240
61240
|
}
|
|
61241
61241
|
function step(result) {
|
|
61242
|
-
result.done ? resolve$
|
|
61242
|
+
result.done ? resolve$3(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
61243
61243
|
}
|
|
61244
61244
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
61245
61245
|
});
|
|
@@ -63035,8 +63035,8 @@ var require_promise = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
63035
63035
|
exports.Deferred = void 0;
|
|
63036
63036
|
var Deferred = class {
|
|
63037
63037
|
constructor() {
|
|
63038
|
-
this._promise = new Promise((resolve$
|
|
63039
|
-
this._resolve = resolve$
|
|
63038
|
+
this._promise = new Promise((resolve$3, reject) => {
|
|
63039
|
+
this._resolve = resolve$3;
|
|
63040
63040
|
this._reject = reject;
|
|
63041
63041
|
});
|
|
63042
63042
|
}
|
|
@@ -63102,10 +63102,10 @@ var require_exporter = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
63102
63102
|
* Shared functionality used by Exporters while exporting data, including suppression of Traces.
|
|
63103
63103
|
*/
|
|
63104
63104
|
function _export(exporter, arg) {
|
|
63105
|
-
return new Promise((resolve$
|
|
63105
|
+
return new Promise((resolve$3) => {
|
|
63106
63106
|
api_1$17.context.with((0, suppress_tracing_1$1.suppressTracing)(api_1$17.context.active()), () => {
|
|
63107
63107
|
exporter.export(arg, (result) => {
|
|
63108
|
-
resolve$
|
|
63108
|
+
resolve$3(result);
|
|
63109
63109
|
});
|
|
63110
63110
|
});
|
|
63111
63111
|
});
|
|
@@ -63563,11 +63563,11 @@ var init_otlp_export_delegate = __esmMin((() => {
|
|
|
63563
63563
|
init_esm$2();
|
|
63564
63564
|
__awaiter$2 = void 0 && (void 0).__awaiter || function(thisArg, _arguments, P, generator) {
|
|
63565
63565
|
function adopt(value) {
|
|
63566
|
-
return value instanceof P ? value : new P(function(resolve$
|
|
63567
|
-
resolve$
|
|
63566
|
+
return value instanceof P ? value : new P(function(resolve$3) {
|
|
63567
|
+
resolve$3(value);
|
|
63568
63568
|
});
|
|
63569
63569
|
}
|
|
63570
|
-
return new (P || (P = Promise))(function(resolve$
|
|
63570
|
+
return new (P || (P = Promise))(function(resolve$3, reject) {
|
|
63571
63571
|
function fulfilled(value) {
|
|
63572
63572
|
try {
|
|
63573
63573
|
step(generator.next(value));
|
|
@@ -63583,7 +63583,7 @@ var init_otlp_export_delegate = __esmMin((() => {
|
|
|
63583
63583
|
}
|
|
63584
63584
|
}
|
|
63585
63585
|
function step(result) {
|
|
63586
|
-
result.done ? resolve$
|
|
63586
|
+
result.done ? resolve$3(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
63587
63587
|
}
|
|
63588
63588
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
63589
63589
|
});
|
|
@@ -68849,7 +68849,7 @@ var require_aspromise = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
68849
68849
|
function asPromise(fn, ctx) {
|
|
68850
68850
|
var params = new Array(arguments.length - 1), offset = 0, index$1 = 2, pending = true;
|
|
68851
68851
|
while (index$1 < arguments.length) params[offset++] = arguments[index$1++];
|
|
68852
|
-
return new Promise(function executor(resolve$
|
|
68852
|
+
return new Promise(function executor(resolve$3, reject) {
|
|
68853
68853
|
params[offset] = function callback(err) {
|
|
68854
68854
|
if (pending) {
|
|
68855
68855
|
pending = false;
|
|
@@ -68857,7 +68857,7 @@ var require_aspromise = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
68857
68857
|
else {
|
|
68858
68858
|
var params$1 = new Array(arguments.length - 1), offset$1 = 0;
|
|
68859
68859
|
while (offset$1 < params$1.length) params$1[offset$1++] = arguments[offset$1];
|
|
68860
|
-
resolve$
|
|
68860
|
+
resolve$3.apply(null, params$1);
|
|
68861
68861
|
}
|
|
68862
68862
|
}
|
|
68863
68863
|
};
|
|
@@ -82550,11 +82550,11 @@ var __awaiter$1, __generator$1, HttpExporterTransport;
|
|
|
82550
82550
|
var init_http_exporter_transport = __esmMin((() => {
|
|
82551
82551
|
__awaiter$1 = void 0 && (void 0).__awaiter || function(thisArg, _arguments, P, generator) {
|
|
82552
82552
|
function adopt(value) {
|
|
82553
|
-
return value instanceof P ? value : new P(function(resolve$
|
|
82554
|
-
resolve$
|
|
82553
|
+
return value instanceof P ? value : new P(function(resolve$3) {
|
|
82554
|
+
resolve$3(value);
|
|
82555
82555
|
});
|
|
82556
82556
|
}
|
|
82557
|
-
return new (P || (P = Promise))(function(resolve$
|
|
82557
|
+
return new (P || (P = Promise))(function(resolve$3, reject) {
|
|
82558
82558
|
function fulfilled(value) {
|
|
82559
82559
|
try {
|
|
82560
82560
|
step(generator.next(value));
|
|
@@ -82570,7 +82570,7 @@ var init_http_exporter_transport = __esmMin((() => {
|
|
|
82570
82570
|
}
|
|
82571
82571
|
}
|
|
82572
82572
|
function step(result) {
|
|
82573
|
-
result.done ? resolve$
|
|
82573
|
+
result.done ? resolve$3(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
82574
82574
|
}
|
|
82575
82575
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
82576
82576
|
});
|
|
@@ -82675,10 +82675,10 @@ var init_http_exporter_transport = __esmMin((() => {
|
|
|
82675
82675
|
this._agent = createHttpAgent$1(this._parameters.url, this._parameters.agentOptions);
|
|
82676
82676
|
this._send = sendWithHttp$1;
|
|
82677
82677
|
}
|
|
82678
|
-
return [2, new Promise(function(resolve$
|
|
82678
|
+
return [2, new Promise(function(resolve$3) {
|
|
82679
82679
|
var _a$3;
|
|
82680
82680
|
(_a$3 = _this._send) === null || _a$3 === void 0 || _a$3.call(_this, _this._parameters, _this._agent, data$1, function(result) {
|
|
82681
|
-
resolve$
|
|
82681
|
+
resolve$3(result);
|
|
82682
82682
|
}, timeoutMillis);
|
|
82683
82683
|
})];
|
|
82684
82684
|
});
|
|
@@ -82707,11 +82707,11 @@ var __awaiter, __generator, MAX_ATTEMPTS, INITIAL_BACKOFF, MAX_BACKOFF, BACKOFF_
|
|
|
82707
82707
|
var init_retrying_transport = __esmMin((() => {
|
|
82708
82708
|
__awaiter = void 0 && (void 0).__awaiter || function(thisArg, _arguments, P, generator) {
|
|
82709
82709
|
function adopt(value) {
|
|
82710
|
-
return value instanceof P ? value : new P(function(resolve$
|
|
82711
|
-
resolve$
|
|
82710
|
+
return value instanceof P ? value : new P(function(resolve$3) {
|
|
82711
|
+
resolve$3(value);
|
|
82712
82712
|
});
|
|
82713
82713
|
}
|
|
82714
|
-
return new (P || (P = Promise))(function(resolve$
|
|
82714
|
+
return new (P || (P = Promise))(function(resolve$3, reject) {
|
|
82715
82715
|
function fulfilled(value) {
|
|
82716
82716
|
try {
|
|
82717
82717
|
step(generator.next(value));
|
|
@@ -82727,7 +82727,7 @@ var init_retrying_transport = __esmMin((() => {
|
|
|
82727
82727
|
}
|
|
82728
82728
|
}
|
|
82729
82729
|
function step(result) {
|
|
82730
|
-
result.done ? resolve$
|
|
82730
|
+
result.done ? resolve$3(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
82731
82731
|
}
|
|
82732
82732
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
82733
82733
|
});
|
|
@@ -82827,9 +82827,9 @@ var init_retrying_transport = __esmMin((() => {
|
|
|
82827
82827
|
}
|
|
82828
82828
|
RetryingTransport$1.prototype.retry = function(data$1, timeoutMillis, inMillis) {
|
|
82829
82829
|
var _this = this;
|
|
82830
|
-
return new Promise(function(resolve$
|
|
82830
|
+
return new Promise(function(resolve$3, reject) {
|
|
82831
82831
|
setTimeout(function() {
|
|
82832
|
-
_this._transport.send(data$1, timeoutMillis).then(resolve$
|
|
82832
|
+
_this._transport.send(data$1, timeoutMillis).then(resolve$3, reject);
|
|
82833
82833
|
}, inMillis);
|
|
82834
82834
|
});
|
|
82835
82835
|
};
|
|
@@ -86594,14 +86594,14 @@ function callMcpMethod(mcpServer, method, params) {
|
|
|
86594
86594
|
jsonrpc: "2.0",
|
|
86595
86595
|
id: messageId
|
|
86596
86596
|
};
|
|
86597
|
-
return new Promise((resolve$
|
|
86597
|
+
return new Promise((resolve$3) => {
|
|
86598
86598
|
if (!mcpServer.transport) throw new Error("MCP server transport not initialized");
|
|
86599
86599
|
mcpServer.transport.onmessage?.(message);
|
|
86600
86600
|
const originalSend = mcpServer.transport.send;
|
|
86601
86601
|
mcpServer.transport.send = function(payload) {
|
|
86602
86602
|
const payloadObj = payload;
|
|
86603
86603
|
if (payloadObj.id === messageId) {
|
|
86604
|
-
resolve$
|
|
86604
|
+
resolve$3(payloadObj.result);
|
|
86605
86605
|
if (!mcpServer.transport) throw new Error("MCP server transport not initialized");
|
|
86606
86606
|
mcpServer.transport.send = originalSend;
|
|
86607
86607
|
}
|
|
@@ -86970,11 +86970,19 @@ function handleCors(res, method) {
|
|
|
86970
86970
|
|
|
86971
86971
|
//#endregion
|
|
86972
86972
|
//#region src/middleware/mcproute-middleware.ts
|
|
86973
|
+
let sharedConnectionManager = null;
|
|
86974
|
+
/**
|
|
86975
|
+
* Get the shared connection manager instance
|
|
86976
|
+
*/
|
|
86977
|
+
function getConnectionManager() {
|
|
86978
|
+
return sharedConnectionManager;
|
|
86979
|
+
}
|
|
86973
86980
|
/**
|
|
86974
86981
|
* Setup MCP server endpoints in Vite dev server
|
|
86975
86982
|
*/
|
|
86976
86983
|
async function setupMcpMiddleware(middlewares, serverContext) {
|
|
86977
86984
|
const connectionManager = new ConnectionManager();
|
|
86985
|
+
sharedConnectionManager = connectionManager;
|
|
86978
86986
|
middlewares.use(async (req, res, next$1) => {
|
|
86979
86987
|
const url = req.url || "";
|
|
86980
86988
|
if (url.startsWith("/__mcp__")) {
|
|
@@ -87148,13 +87156,13 @@ async function handleSseMessage(req, res, serverContext, connectionManager) {
|
|
|
87148
87156
|
* Helper to read request body
|
|
87149
87157
|
*/
|
|
87150
87158
|
function readRequestBody(req) {
|
|
87151
|
-
return new Promise((resolve$
|
|
87159
|
+
return new Promise((resolve$3, reject) => {
|
|
87152
87160
|
let body = "";
|
|
87153
87161
|
req.on("data", (chunk) => {
|
|
87154
87162
|
body += chunk.toString();
|
|
87155
87163
|
});
|
|
87156
87164
|
req.on("end", () => {
|
|
87157
|
-
resolve$
|
|
87165
|
+
resolve$3(body);
|
|
87158
87166
|
});
|
|
87159
87167
|
req.on("error", reject);
|
|
87160
87168
|
});
|
|
@@ -87168,7 +87176,7 @@ function isInitializeRequest(body) {
|
|
|
87168
87176
|
|
|
87169
87177
|
//#endregion
|
|
87170
87178
|
//#region src/middleware/inspector-middleware.ts
|
|
87171
|
-
const __dirname = dirname
|
|
87179
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
87172
87180
|
/**
|
|
87173
87181
|
* Get the inspector client script content
|
|
87174
87182
|
* Tries multiple paths to locate the bundled inspector script
|
|
@@ -87252,7 +87260,7 @@ function setupInspectorMiddleware(middlewares, config) {
|
|
|
87252
87260
|
}
|
|
87253
87261
|
|
|
87254
87262
|
//#endregion
|
|
87255
|
-
//#region ../../node_modules/.pnpm/@mcpc-tech+acp-ai-provider@0.1.
|
|
87263
|
+
//#region ../../node_modules/.pnpm/@mcpc-tech+acp-ai-provider@0.1.31/node_modules/@mcpc-tech/acp-ai-provider/index.mjs
|
|
87256
87264
|
createRequire(import.meta.url);
|
|
87257
87265
|
function formatToolError(toolResult) {
|
|
87258
87266
|
if (!toolResult || toolResult.length === 0) return "Unknown tool error";
|
|
@@ -87265,7 +87273,284 @@ function formatToolError(toolResult) {
|
|
|
87265
87273
|
function extractBase64Data(data$1) {
|
|
87266
87274
|
return data$1.includes(",") ? data$1.split(",")[1] : data$1;
|
|
87267
87275
|
}
|
|
87276
|
+
function createResponse(id, result) {
|
|
87277
|
+
return {
|
|
87278
|
+
jsonrpc: "2.0",
|
|
87279
|
+
id,
|
|
87280
|
+
result
|
|
87281
|
+
};
|
|
87282
|
+
}
|
|
87283
|
+
function createErrorResponse(id, code, message, data$1) {
|
|
87284
|
+
const error$1 = {
|
|
87285
|
+
code,
|
|
87286
|
+
message
|
|
87287
|
+
};
|
|
87288
|
+
if (data$1 !== void 0) error$1.data = data$1;
|
|
87289
|
+
return {
|
|
87290
|
+
jsonrpc: "2.0",
|
|
87291
|
+
id,
|
|
87292
|
+
error: error$1
|
|
87293
|
+
};
|
|
87294
|
+
}
|
|
87295
|
+
function parseMessage(line$1) {
|
|
87296
|
+
try {
|
|
87297
|
+
const parsed = JSON.parse(line$1);
|
|
87298
|
+
if (parsed.jsonrpc !== "2.0") return null;
|
|
87299
|
+
return parsed;
|
|
87300
|
+
} catch {
|
|
87301
|
+
return null;
|
|
87302
|
+
}
|
|
87303
|
+
}
|
|
87304
|
+
function serializeMessage(message) {
|
|
87305
|
+
return JSON.stringify(message);
|
|
87306
|
+
}
|
|
87307
|
+
var JsonRpcErrorCode = {
|
|
87308
|
+
PARSE_ERROR: -32700,
|
|
87309
|
+
INVALID_REQUEST: -32600,
|
|
87310
|
+
METHOD_NOT_FOUND: -32601,
|
|
87311
|
+
INVALID_PARAMS: -32602,
|
|
87312
|
+
INTERNAL_ERROR: -32603
|
|
87313
|
+
};
|
|
87314
|
+
var ProxyMethod = {
|
|
87315
|
+
REGISTER_TOOLS: "registerTools",
|
|
87316
|
+
CALL_HANDLER: "callHandler"
|
|
87317
|
+
};
|
|
87318
|
+
var RUNTIME_CODE = `
|
|
87319
|
+
/* MCP Protocol Version 2024-11-05 */
|
|
87320
|
+
const isDeno=typeof Deno!=="undefined",MCP_VER="2024-11-05";
|
|
87321
|
+
let tools=[],host=null,pending=new Map,buf="",hbuf="",rid=0;
|
|
87322
|
+
const env=k=>isDeno?Deno.env.get(k):process.env[k];
|
|
87323
|
+
const write=async m=>{
|
|
87324
|
+
const s=JSON.stringify(m)+"\\n";
|
|
87325
|
+
if(isDeno)await Deno.stdout.write(new TextEncoder().encode(s));
|
|
87326
|
+
else process.stdout.write(s);
|
|
87327
|
+
};
|
|
87328
|
+
const send=(id,r,e)=>write({jsonrpc:"2.0",id,...(e?{error:e}:{result:r})});
|
|
87329
|
+
const hostReq=(m,p)=>new Promise((res,rej)=>{
|
|
87330
|
+
const id="r-"+ ++rid;
|
|
87331
|
+
const s=JSON.stringify({jsonrpc:"2.0",id,method:m,params:p})+"\\n";
|
|
87332
|
+
if(isDeno)host.write(new TextEncoder().encode(s));
|
|
87333
|
+
else host.write(s);
|
|
87334
|
+
const t=setTimeout(()=>{pending.delete(id);rej(new Error("timeout"))},30000);
|
|
87335
|
+
pending.set(id,{resolve:v=>{clearTimeout(t);res(v)},reject:e=>{clearTimeout(t);rej(e)}});
|
|
87336
|
+
});
|
|
87337
|
+
const init=async()=>{
|
|
87338
|
+
const p=parseInt(env("ACP_TOOL_PROXY_PORT")||"0",10);
|
|
87339
|
+
if(p){
|
|
87340
|
+
if(isDeno){
|
|
87341
|
+
host=await Deno.connect({hostname:"127.0.0.1",port:p});
|
|
87342
|
+
(async()=>{
|
|
87343
|
+
const d=new TextDecoder(),b=new Uint8Array(65536);
|
|
87344
|
+
while(true){const n=await host.read(b);if(!n)break;
|
|
87345
|
+
hbuf+=d.decode(b.subarray(0,n));let ls=hbuf.split("\\n");hbuf=ls.pop();
|
|
87346
|
+
for(let l of ls)if(l.trim())onHostMsg(l)}})();
|
|
87347
|
+
}else{
|
|
87348
|
+
host=require("net").createConnection({host:"127.0.0.1",port:p});
|
|
87349
|
+
await new Promise(r=>host.on("connect",r));
|
|
87350
|
+
host.on("data",d=>{hbuf+=d;let ls=hbuf.split("\\n");hbuf=ls.pop();
|
|
87351
|
+
for(let l of ls)if(l.trim())onHostMsg(l)});
|
|
87352
|
+
}
|
|
87353
|
+
try{tools=await hostReq("getTools")}catch(e){
|
|
87354
|
+
const m="Failed to get tools: "+e.message+"\\n";
|
|
87355
|
+
if(isDeno)Deno.stderr.write(new TextEncoder().encode(m));
|
|
87356
|
+
else process.stderr.write(m);
|
|
87357
|
+
}
|
|
87358
|
+
}
|
|
87359
|
+
};
|
|
87360
|
+
const onHostMsg=l=>{try{let r=JSON.parse(l),h=pending.get(r.id);
|
|
87361
|
+
if(h){pending.delete(r.id);r.error?h.reject(new Error(r.error.message)):h.resolve(r.result)}}catch{}};
|
|
87362
|
+
const handle=async l=>{let m;try{m=JSON.parse(l)}catch{return}if(m.jsonrpc!=="2.0")return;
|
|
87363
|
+
if(m.method==="initialize")send(m.id,{protocolVersion:MCP_VER,capabilities:{tools:{}},serverInfo:{name:"proxy",version:"1.0"}});
|
|
87364
|
+
else if(m.method==="notifications/initialized");
|
|
87365
|
+
else if(m.method==="tools/list")send(m.id,{tools:tools.map(t=>({name:t.name,description:t.description,inputSchema:t.inputSchema}))});
|
|
87366
|
+
else if(m.method==="tools/call"){let p=m.params,t=tools.find(x=>x.name===p.name);
|
|
87367
|
+
if(!t)send(m.id,null,{code:-32601,message:"Not found"});
|
|
87368
|
+
else try{let r=await hostReq("callHandler",{name:p.name,args:p.arguments||{}});send(m.id,r)}
|
|
87369
|
+
catch(e){send(m.id,{content:[{type:"text",text:"Error: "+e.message}],isError:true})}}
|
|
87370
|
+
else send(m.id,null,{code:-32601,message:"Unknown"});
|
|
87371
|
+
};
|
|
87372
|
+
init().then(async()=>{
|
|
87373
|
+
if(isDeno){
|
|
87374
|
+
const d=new TextDecoder(),b=new Uint8Array(65536);
|
|
87375
|
+
while(true){const n=await Deno.stdin.read(b);if(!n)break;
|
|
87376
|
+
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)}
|
|
87377
|
+
}else{
|
|
87378
|
+
process.stdin.setEncoding("utf8");
|
|
87379
|
+
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)});
|
|
87380
|
+
}
|
|
87381
|
+
});
|
|
87382
|
+
`.trim().replace(/\n/g, "");
|
|
87383
|
+
var ToolProxyHost = class {
|
|
87384
|
+
server = null;
|
|
87385
|
+
connections = [];
|
|
87386
|
+
tools = /* @__PURE__ */ new Map();
|
|
87387
|
+
serverName;
|
|
87388
|
+
port = 0;
|
|
87389
|
+
constructor(name = "acp-tool-proxy") {
|
|
87390
|
+
this.serverName = name;
|
|
87391
|
+
}
|
|
87392
|
+
/**
|
|
87393
|
+
* Register an AI SDK tool to be exposed through the proxy
|
|
87394
|
+
*/
|
|
87395
|
+
registerTool(name, tool2) {
|
|
87396
|
+
this.tools.set(name, tool2);
|
|
87397
|
+
}
|
|
87398
|
+
/**
|
|
87399
|
+
* Register multiple tools at once
|
|
87400
|
+
*/
|
|
87401
|
+
registerTools(tools) {
|
|
87402
|
+
for (const [name, tool2] of Object.entries(tools)) this.registerTool(name, tool2);
|
|
87403
|
+
}
|
|
87404
|
+
/**
|
|
87405
|
+
* Get tool definitions for the runtime
|
|
87406
|
+
*/
|
|
87407
|
+
getToolDefinitions() {
|
|
87408
|
+
const definitions = [];
|
|
87409
|
+
for (const [name, tool2] of this.tools.entries()) definitions.push({
|
|
87410
|
+
name,
|
|
87411
|
+
description: tool2.description || `Tool: ${name}`,
|
|
87412
|
+
inputSchema: tool2.inputSchema || {
|
|
87413
|
+
type: "object",
|
|
87414
|
+
properties: {}
|
|
87415
|
+
}
|
|
87416
|
+
});
|
|
87417
|
+
return definitions;
|
|
87418
|
+
}
|
|
87419
|
+
/**
|
|
87420
|
+
* Start TCP server and return MCP server config for ACP
|
|
87421
|
+
*/
|
|
87422
|
+
async start() {
|
|
87423
|
+
if (this.server) throw new Error("Tool proxy already started");
|
|
87424
|
+
await this.startServer();
|
|
87425
|
+
return {
|
|
87426
|
+
name: this.serverName,
|
|
87427
|
+
command: "node",
|
|
87428
|
+
args: ["-e", RUNTIME_CODE],
|
|
87429
|
+
env: [{
|
|
87430
|
+
name: "ACP_TOOL_PROXY_PORT",
|
|
87431
|
+
value: String(this.port)
|
|
87432
|
+
}]
|
|
87433
|
+
};
|
|
87434
|
+
}
|
|
87435
|
+
/**
|
|
87436
|
+
* Start TCP server to receive tool execution requests
|
|
87437
|
+
*/
|
|
87438
|
+
startServer() {
|
|
87439
|
+
return new Promise((resolve$3, reject) => {
|
|
87440
|
+
this.server = createServer((socket) => {
|
|
87441
|
+
this.handleConnection(socket);
|
|
87442
|
+
});
|
|
87443
|
+
this.server.on("error", (err) => {
|
|
87444
|
+
reject(err);
|
|
87445
|
+
});
|
|
87446
|
+
this.server.listen(0, "127.0.0.1", () => {
|
|
87447
|
+
const address = this.server.address();
|
|
87448
|
+
if (typeof address === "object" && address) {
|
|
87449
|
+
this.port = address.port;
|
|
87450
|
+
resolve$3();
|
|
87451
|
+
} else reject(/* @__PURE__ */ new Error("Failed to get server address"));
|
|
87452
|
+
});
|
|
87453
|
+
});
|
|
87454
|
+
}
|
|
87455
|
+
/**
|
|
87456
|
+
* Handle incoming connection from runtime
|
|
87457
|
+
*/
|
|
87458
|
+
handleConnection(socket) {
|
|
87459
|
+
this.connections.push(socket);
|
|
87460
|
+
let buffer$2 = "";
|
|
87461
|
+
socket.on("data", (data$1) => {
|
|
87462
|
+
buffer$2 += data$1.toString();
|
|
87463
|
+
const lines = buffer$2.split("\n");
|
|
87464
|
+
buffer$2 = lines.pop() || "";
|
|
87465
|
+
for (const line$1 of lines) {
|
|
87466
|
+
if (!line$1.trim()) continue;
|
|
87467
|
+
const message = parseMessage(line$1);
|
|
87468
|
+
if (!message) continue;
|
|
87469
|
+
if ("method" in message) this.handleRequest(socket, message).catch((err) => console.error("[ToolProxy] Error handling request:", err));
|
|
87470
|
+
}
|
|
87471
|
+
});
|
|
87472
|
+
socket.on("close", () => {
|
|
87473
|
+
this.connections = this.connections.filter((c) => c !== socket);
|
|
87474
|
+
});
|
|
87475
|
+
socket.on("error", (err) => {
|
|
87476
|
+
console.error("[ToolProxy] Socket error:", err);
|
|
87477
|
+
});
|
|
87478
|
+
}
|
|
87479
|
+
/**
|
|
87480
|
+
* Handle JSON-RPC request from runtime
|
|
87481
|
+
*/
|
|
87482
|
+
async handleRequest(socket, request$1) {
|
|
87483
|
+
try {
|
|
87484
|
+
if (request$1.method === ProxyMethod.CALL_HANDLER) {
|
|
87485
|
+
const params = request$1.params;
|
|
87486
|
+
const tool2 = this.tools.get(params.name);
|
|
87487
|
+
if (!tool2) {
|
|
87488
|
+
this.sendResponse(socket, createErrorResponse(request$1.id, JsonRpcErrorCode.METHOD_NOT_FOUND, `Tool not found: ${params.name}`));
|
|
87489
|
+
return;
|
|
87490
|
+
}
|
|
87491
|
+
if (!tool2.execute) {
|
|
87492
|
+
this.sendResponse(socket, createErrorResponse(request$1.id, JsonRpcErrorCode.INTERNAL_ERROR, `Tool has no execute function: ${params.name}`));
|
|
87493
|
+
return;
|
|
87494
|
+
}
|
|
87495
|
+
const result = await tool2.execute?.(params.args, {
|
|
87496
|
+
toolCallId: params.name,
|
|
87497
|
+
messages: []
|
|
87498
|
+
});
|
|
87499
|
+
const toolResult = { content: [{
|
|
87500
|
+
type: "text",
|
|
87501
|
+
text: typeof result === "string" ? result : JSON.stringify(result)
|
|
87502
|
+
}] };
|
|
87503
|
+
this.sendResponse(socket, createResponse(request$1.id, toolResult));
|
|
87504
|
+
} else if (request$1.method === "getTools") this.sendResponse(socket, createResponse(request$1.id, this.getToolDefinitions()));
|
|
87505
|
+
else this.sendResponse(socket, createErrorResponse(request$1.id, JsonRpcErrorCode.METHOD_NOT_FOUND, `Unknown method: ${request$1.method}`));
|
|
87506
|
+
} catch (error$1) {
|
|
87507
|
+
this.sendResponse(socket, createErrorResponse(request$1.id, JsonRpcErrorCode.INTERNAL_ERROR, error$1 instanceof Error ? error$1.message : String(error$1)));
|
|
87508
|
+
}
|
|
87509
|
+
}
|
|
87510
|
+
/**
|
|
87511
|
+
* Send response to runtime
|
|
87512
|
+
*/
|
|
87513
|
+
sendResponse(socket, response) {
|
|
87514
|
+
socket.write(serializeMessage(response) + "\n");
|
|
87515
|
+
}
|
|
87516
|
+
/**
|
|
87517
|
+
* Stop the TCP server
|
|
87518
|
+
*/
|
|
87519
|
+
stop() {
|
|
87520
|
+
for (const socket of this.connections) socket.destroy();
|
|
87521
|
+
this.connections = [];
|
|
87522
|
+
if (this.server) {
|
|
87523
|
+
this.server.close();
|
|
87524
|
+
this.server = null;
|
|
87525
|
+
}
|
|
87526
|
+
this.port = 0;
|
|
87527
|
+
}
|
|
87528
|
+
};
|
|
87268
87529
|
var ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME = "acp.acp_provider_agent_dynamic_tool";
|
|
87530
|
+
var executeRegistry = /* @__PURE__ */ new Map();
|
|
87531
|
+
function acpTools(tools) {
|
|
87532
|
+
for (const [name, toolDef] of Object.entries(tools)) if (toolDef.execute) executeRegistry.set(name, toolDef.execute);
|
|
87533
|
+
return {
|
|
87534
|
+
...tools,
|
|
87535
|
+
...getACPDynamicTool()
|
|
87536
|
+
};
|
|
87537
|
+
}
|
|
87538
|
+
function getACPDynamicTool() {
|
|
87539
|
+
return { [ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME]: tool({
|
|
87540
|
+
type: "provider-defined",
|
|
87541
|
+
id: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME,
|
|
87542
|
+
name: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME,
|
|
87543
|
+
args: {},
|
|
87544
|
+
inputSchema: jsonSchema({})
|
|
87545
|
+
}) };
|
|
87546
|
+
}
|
|
87547
|
+
function getExecuteByName(name) {
|
|
87548
|
+
return executeRegistry.get(name);
|
|
87549
|
+
}
|
|
87550
|
+
function hasRegisteredExecute(name) {
|
|
87551
|
+
return executeRegistry.has(name);
|
|
87552
|
+
}
|
|
87553
|
+
var ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME2 = "acp.acp_provider_agent_dynamic_tool";
|
|
87269
87554
|
var providerAgentDynamicToolSchema = z$1.object({
|
|
87270
87555
|
toolCallId: z$1.string().describe("The unique ID of the tool call."),
|
|
87271
87556
|
toolName: z$1.string().describe("The name of the tool being called."),
|
|
@@ -87292,11 +87577,11 @@ var ACPAISDKClient = class {
|
|
|
87292
87577
|
} };
|
|
87293
87578
|
}
|
|
87294
87579
|
writeTextFile(params) {
|
|
87295
|
-
console.log("Write file request (not implemented):", params.path);
|
|
87580
|
+
console.log("[acp-ai-provider] Write file request (not implemented):", params.path);
|
|
87296
87581
|
throw new Error("File operations not implemented in language model client");
|
|
87297
87582
|
}
|
|
87298
87583
|
readTextFile(params) {
|
|
87299
|
-
console.log("Read file request (not implemented):", params.path);
|
|
87584
|
+
console.log("[acp-ai-provider] Read file request (not implemented):", params.path);
|
|
87300
87585
|
throw new Error("File operations not implemented in language model client");
|
|
87301
87586
|
}
|
|
87302
87587
|
};
|
|
@@ -87304,6 +87589,7 @@ var ACPLanguageModel = class {
|
|
|
87304
87589
|
specificationVersion = "v2";
|
|
87305
87590
|
provider = "acp";
|
|
87306
87591
|
modelId;
|
|
87592
|
+
modeId;
|
|
87307
87593
|
supportedUrls = {};
|
|
87308
87594
|
config;
|
|
87309
87595
|
agentProcess = null;
|
|
@@ -87311,13 +87597,17 @@ var ACPLanguageModel = class {
|
|
|
87311
87597
|
sessionId = null;
|
|
87312
87598
|
sessionResponse = null;
|
|
87313
87599
|
client = null;
|
|
87600
|
+
currentModelId = null;
|
|
87601
|
+
currentModeId = null;
|
|
87314
87602
|
textBlockIndex = 0;
|
|
87315
87603
|
thinkBlockIndex = 0;
|
|
87316
87604
|
currentTextId = null;
|
|
87317
87605
|
currentThinkingId = null;
|
|
87318
87606
|
toolCallsMap = /* @__PURE__ */ new Map();
|
|
87319
|
-
|
|
87607
|
+
toolProxyHost = null;
|
|
87608
|
+
constructor(modelId, modeId, config) {
|
|
87320
87609
|
this.modelId = modelId;
|
|
87610
|
+
this.modeId = modeId;
|
|
87321
87611
|
this.config = config;
|
|
87322
87612
|
}
|
|
87323
87613
|
/**
|
|
@@ -87379,7 +87669,7 @@ var ACPLanguageModel = class {
|
|
|
87379
87669
|
if (Array.isArray(msg.content)) {
|
|
87380
87670
|
let isFirst = true;
|
|
87381
87671
|
for (const part of msg.content) if (part.type === "text") {
|
|
87382
|
-
const text$2 = isFirst ? `${prefix}${part.text}` : part.text;
|
|
87672
|
+
const text$2 = isFirst ? `${prefix}${part.text} ` : part.text;
|
|
87383
87673
|
contentBlocks.push({
|
|
87384
87674
|
type: "text",
|
|
87385
87675
|
text: text$2
|
|
@@ -87395,33 +87685,42 @@ var ACPLanguageModel = class {
|
|
|
87395
87685
|
}
|
|
87396
87686
|
} else if (typeof msg.content === "string") contentBlocks.push({
|
|
87397
87687
|
type: "text",
|
|
87398
|
-
text: `${prefix}${msg.content}`
|
|
87688
|
+
text: `${prefix}${msg.content} `
|
|
87399
87689
|
});
|
|
87400
87690
|
}
|
|
87401
87691
|
return contentBlocks;
|
|
87402
87692
|
}
|
|
87403
87693
|
/**
|
|
87404
87694
|
* Ensures the ACP agent process is running and a session is established.
|
|
87695
|
+
* @param acpTools - Tools from streamText options to proxy
|
|
87405
87696
|
*/
|
|
87406
|
-
|
|
87407
|
-
|
|
87408
|
-
|
|
87409
|
-
|
|
87410
|
-
|
|
87411
|
-
|
|
87412
|
-
|
|
87413
|
-
|
|
87414
|
-
],
|
|
87415
|
-
|
|
87416
|
-
|
|
87417
|
-
|
|
87418
|
-
|
|
87419
|
-
|
|
87420
|
-
|
|
87421
|
-
|
|
87422
|
-
|
|
87423
|
-
|
|
87424
|
-
|
|
87697
|
+
/**
|
|
87698
|
+
* Connects to the ACP agent process and initializes the protocol connection.
|
|
87699
|
+
* Does NOT start a session.
|
|
87700
|
+
*/
|
|
87701
|
+
async connectClient() {
|
|
87702
|
+
if (this.connection) return;
|
|
87703
|
+
if (!this.agentProcess) {
|
|
87704
|
+
const sessionCwd = this.config.session?.cwd || (typeof process$1.cwd === "function" ? process$1.cwd() : "/");
|
|
87705
|
+
this.agentProcess = spawn(this.config.command, this.config.args ?? [], {
|
|
87706
|
+
stdio: [
|
|
87707
|
+
"pipe",
|
|
87708
|
+
"pipe",
|
|
87709
|
+
"inherit"
|
|
87710
|
+
],
|
|
87711
|
+
env: {
|
|
87712
|
+
...process$1.env,
|
|
87713
|
+
...this.config.env
|
|
87714
|
+
},
|
|
87715
|
+
cwd: sessionCwd
|
|
87716
|
+
});
|
|
87717
|
+
if (!this.agentProcess.stdout || !this.agentProcess.stdin) throw new Error("Failed to spawn agent process with stdio");
|
|
87718
|
+
const input = Writable.toWeb(this.agentProcess.stdin);
|
|
87719
|
+
const output = Readable.toWeb(this.agentProcess.stdout);
|
|
87720
|
+
this.client = new ACPAISDKClient();
|
|
87721
|
+
this.connection = new ClientSideConnection(() => this.client, ndJsonStream(input, output));
|
|
87722
|
+
}
|
|
87723
|
+
if (!this.connection) throw new Error("Connection not initialized");
|
|
87425
87724
|
const initConfig = {
|
|
87426
87725
|
...this.config.initialize ?? {},
|
|
87427
87726
|
protocolVersion: this.config.initialize?.protocolVersion ?? PROTOCOL_VERSION,
|
|
@@ -87436,25 +87735,105 @@ var ACPLanguageModel = class {
|
|
|
87436
87735
|
const initResult = await this.connection.initialize(initConfig);
|
|
87437
87736
|
const validAuthMethods = initResult.authMethods?.find((a) => a.id === this.config.authMethodId)?.id;
|
|
87438
87737
|
if (initResult.authMethods?.length ?? false) {
|
|
87439
|
-
if (!this.config.authMethodId || !validAuthMethods) console.log("
|
|
87738
|
+
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));
|
|
87440
87739
|
if (this.config.authMethodId && validAuthMethods) await this.connection.authenticate({ methodId: this.config.authMethodId ?? initResult.authMethods?.[0].id });
|
|
87441
|
-
} else console.log(
|
|
87740
|
+
} else console.log(`[acp-ai-provider] No authentication methods required by the ACP agent, skipping authentication step.`);
|
|
87741
|
+
}
|
|
87742
|
+
/**
|
|
87743
|
+
* Prepares the list of MCP servers, including the tool proxy if needed.
|
|
87744
|
+
*/
|
|
87745
|
+
async prepareMcpServers(acpTools2) {
|
|
87746
|
+
const mcpServers = [...this.config.session?.mcpServers ?? []];
|
|
87747
|
+
if (acpTools2 && acpTools2.length > 0) {
|
|
87748
|
+
if (!this.toolProxyHost) this.toolProxyHost = new ToolProxyHost("acp-ai-sdk-tools");
|
|
87749
|
+
for (const t$5 of acpTools2) this.toolProxyHost.registerTool(t$5.name, t$5);
|
|
87750
|
+
if (!this.toolProxyHost) {
|
|
87751
|
+
this.toolProxyHost = new ToolProxyHost("acp-ai-sdk-tools");
|
|
87752
|
+
for (const t$5 of acpTools2) this.toolProxyHost.registerTool(t$5.name, t$5);
|
|
87753
|
+
const proxyConfig = await this.toolProxyHost.start();
|
|
87754
|
+
mcpServers.push(proxyConfig);
|
|
87755
|
+
}
|
|
87756
|
+
}
|
|
87757
|
+
return mcpServers;
|
|
87758
|
+
}
|
|
87759
|
+
async prepareToolProxy(acpTools2, mcpServers) {
|
|
87760
|
+
if (this.toolProxyHost) return;
|
|
87761
|
+
this.toolProxyHost = new ToolProxyHost("acp-ai-sdk-tools");
|
|
87762
|
+
for (const t$5 of acpTools2) this.toolProxyHost.registerTool(t$5.name, t$5);
|
|
87763
|
+
const proxyConfig = await this.toolProxyHost.start();
|
|
87764
|
+
mcpServers.push(proxyConfig);
|
|
87765
|
+
}
|
|
87766
|
+
/**
|
|
87767
|
+
* Starts a new session or updates the existing one.
|
|
87768
|
+
* Assumes connectClient() has been called.
|
|
87769
|
+
*/
|
|
87770
|
+
async startSession(acpTools2) {
|
|
87771
|
+
if (!this.connection) throw new Error("Not connected");
|
|
87772
|
+
console.log(`[acp-ai-provider] startSession called with ${acpTools2?.length ?? 0} tools`);
|
|
87773
|
+
const mcpServers = [...this.config.session?.mcpServers ?? []];
|
|
87774
|
+
let toolsAdded = false;
|
|
87775
|
+
if (acpTools2 && acpTools2.length > 0 && !this.toolProxyHost) {
|
|
87776
|
+
console.log("[acp-ai-provider] Setting up tool proxy for client-side tools...");
|
|
87777
|
+
this.toolProxyHost = new ToolProxyHost("acp-ai-sdk-tools");
|
|
87778
|
+
for (const t$5 of acpTools2) this.toolProxyHost.registerTool(t$5.name, t$5);
|
|
87779
|
+
const proxyConfig = await this.toolProxyHost.start();
|
|
87780
|
+
mcpServers.push(proxyConfig);
|
|
87781
|
+
toolsAdded = true;
|
|
87782
|
+
}
|
|
87783
|
+
if (this.sessionId && toolsAdded) {
|
|
87784
|
+
console.log("[acp-ai-provider] Updating session to include new tools...");
|
|
87785
|
+
this.sessionResponse = await this.connection.newSession({
|
|
87786
|
+
...this.config.session,
|
|
87787
|
+
cwd: this.config.session?.cwd ?? process$1.cwd(),
|
|
87788
|
+
mcpServers
|
|
87789
|
+
});
|
|
87790
|
+
this.sessionId = this.sessionResponse.sessionId;
|
|
87791
|
+
await this.applySessionDelay();
|
|
87792
|
+
return;
|
|
87793
|
+
}
|
|
87794
|
+
if (this.sessionId) return;
|
|
87442
87795
|
if (this.config.existingSessionId) {
|
|
87443
87796
|
await this.connection.loadSession({
|
|
87444
87797
|
sessionId: this.config.existingSessionId,
|
|
87445
|
-
cwd: this.config.session?.cwd ??
|
|
87446
|
-
mcpServers
|
|
87798
|
+
cwd: this.config.session?.cwd ?? process$1.cwd(),
|
|
87799
|
+
mcpServers
|
|
87447
87800
|
});
|
|
87448
87801
|
this.sessionId = this.config.existingSessionId;
|
|
87449
87802
|
this.sessionResponse = { sessionId: this.config.existingSessionId };
|
|
87450
87803
|
} else {
|
|
87451
87804
|
this.sessionResponse = await this.connection.newSession({
|
|
87452
87805
|
...this.config.session,
|
|
87453
|
-
cwd: this.config.session?.cwd ??
|
|
87454
|
-
mcpServers
|
|
87806
|
+
cwd: this.config.session?.cwd ?? process$1.cwd(),
|
|
87807
|
+
mcpServers
|
|
87455
87808
|
});
|
|
87456
87809
|
this.sessionId = this.sessionResponse.sessionId;
|
|
87457
87810
|
}
|
|
87811
|
+
const { models, modes } = this.sessionResponse ?? {};
|
|
87812
|
+
if (models?.currentModelId) this.currentModelId = models.currentModelId;
|
|
87813
|
+
if (modes?.currentModeId) this.currentModeId = modes.currentModeId;
|
|
87814
|
+
if (this.modelId && this.modelId !== this.currentModelId) {
|
|
87815
|
+
await this.setModel(this.modelId);
|
|
87816
|
+
this.currentModelId = this.modelId;
|
|
87817
|
+
}
|
|
87818
|
+
if (this.modeId && this.modeId !== this.currentModeId) {
|
|
87819
|
+
await this.setMode(this.modeId);
|
|
87820
|
+
this.currentModeId = this.modeId;
|
|
87821
|
+
}
|
|
87822
|
+
await this.applySessionDelay();
|
|
87823
|
+
}
|
|
87824
|
+
async applySessionDelay() {
|
|
87825
|
+
if (this.config.sessionDelayMs) {
|
|
87826
|
+
console.log(`[acp-ai-provider] Waiting for ${this.config.sessionDelayMs}ms after session setup...`);
|
|
87827
|
+
await new Promise((resolve$3) => setTimeout(resolve$3, this.config.sessionDelayMs));
|
|
87828
|
+
}
|
|
87829
|
+
}
|
|
87830
|
+
/**
|
|
87831
|
+
* Ensures the ACP agent process is running and a session is established.
|
|
87832
|
+
* @param acpTools - Tools from streamText options to proxy
|
|
87833
|
+
*/
|
|
87834
|
+
async ensureConnected(acpTools2) {
|
|
87835
|
+
await this.connectClient();
|
|
87836
|
+
await this.startSession(acpTools2);
|
|
87458
87837
|
}
|
|
87459
87838
|
/**
|
|
87460
87839
|
* Clears connection state. Skips if persistSession is enabled.
|
|
@@ -87473,8 +87852,20 @@ var ACPLanguageModel = class {
|
|
|
87473
87852
|
* Initializes the session and returns session info (models, modes, meta).
|
|
87474
87853
|
* Call this before prompting to discover available options.
|
|
87475
87854
|
*/
|
|
87476
|
-
|
|
87477
|
-
|
|
87855
|
+
/**
|
|
87856
|
+
* Initializes the session and returns session info (models, modes, meta).
|
|
87857
|
+
* Call this before prompting to discover available options.
|
|
87858
|
+
*
|
|
87859
|
+
* @param acpTools - Optional list of tools to register during session initialization.
|
|
87860
|
+
*/
|
|
87861
|
+
async initSession(acpTools2) {
|
|
87862
|
+
let toolsArray = [];
|
|
87863
|
+
if (acpTools2) if (Array.isArray(acpTools2)) toolsArray = acpTools2;
|
|
87864
|
+
else toolsArray = Object.entries(acpTools2).map(([name, tool2]) => ({
|
|
87865
|
+
...tool2,
|
|
87866
|
+
name
|
|
87867
|
+
}));
|
|
87868
|
+
await this.ensureConnected(toolsArray);
|
|
87478
87869
|
return this.sessionResponse;
|
|
87479
87870
|
}
|
|
87480
87871
|
/**
|
|
@@ -87482,25 +87873,47 @@ var ACPLanguageModel = class {
|
|
|
87482
87873
|
*/
|
|
87483
87874
|
async setMode(modeId) {
|
|
87484
87875
|
if (!this.connection || !this.sessionId) throw new Error("Not connected. Call preconnect() first.");
|
|
87876
|
+
const availableModes = this.sessionResponse?.modes?.availableModes;
|
|
87877
|
+
if (availableModes) {
|
|
87878
|
+
if (!availableModes.find((m) => m.id === modeId)) {
|
|
87879
|
+
const availableList = availableModes.map((m) => m.id).join(", ");
|
|
87880
|
+
const currentInfo = this.sessionResponse?.modes?.currentModeId ? ` (Current: "${this.sessionResponse.modes.currentModeId}")` : "";
|
|
87881
|
+
throw new Error(`Mode "${modeId}" is not available${currentInfo}. Available modes: ${availableList}`);
|
|
87882
|
+
}
|
|
87883
|
+
}
|
|
87485
87884
|
await this.connection.setSessionMode({
|
|
87486
87885
|
sessionId: this.sessionId,
|
|
87487
87886
|
modeId
|
|
87488
87887
|
});
|
|
87888
|
+
this.currentModeId = modeId;
|
|
87489
87889
|
}
|
|
87490
87890
|
/**
|
|
87491
87891
|
* Sets the session model.
|
|
87492
87892
|
*/
|
|
87493
87893
|
async setModel(modelId) {
|
|
87494
87894
|
if (!this.connection || !this.sessionId) throw new Error("Not connected. Call preconnect() first.");
|
|
87895
|
+
const { models } = this.sessionResponse ?? {};
|
|
87896
|
+
if (models?.availableModels) {
|
|
87897
|
+
if (!models.availableModels.some((m) => m.modelId === modelId)) {
|
|
87898
|
+
const availableList = models.availableModels.map((m) => m.modelId).join(", ");
|
|
87899
|
+
const currentInfo = this.currentModelId ? ` (Current: "${this.currentModelId}")` : "";
|
|
87900
|
+
throw new Error(`Model "${modelId}" is not available${currentInfo}. Available models: ${availableList}`);
|
|
87901
|
+
}
|
|
87902
|
+
}
|
|
87495
87903
|
await this.connection.setSessionModel({
|
|
87496
87904
|
sessionId: this.sessionId,
|
|
87497
87905
|
modelId
|
|
87498
87906
|
});
|
|
87907
|
+
this.currentModelId = modelId;
|
|
87499
87908
|
}
|
|
87500
87909
|
/**
|
|
87501
87910
|
* Forces cleanup regardless of persistSession setting.
|
|
87502
87911
|
*/
|
|
87503
87912
|
forceCleanup() {
|
|
87913
|
+
if (this.toolProxyHost) {
|
|
87914
|
+
this.toolProxyHost.stop();
|
|
87915
|
+
this.toolProxyHost = null;
|
|
87916
|
+
}
|
|
87504
87917
|
if (this.agentProcess) {
|
|
87505
87918
|
this.agentProcess.kill();
|
|
87506
87919
|
this.agentProcess.stdin?.end();
|
|
@@ -87527,7 +87940,7 @@ var ACPLanguageModel = class {
|
|
|
87527
87940
|
break;
|
|
87528
87941
|
case "agent_thought_chunk":
|
|
87529
87942
|
if (!this.currentThinkingId) {
|
|
87530
|
-
this.currentThinkingId = `reasoning
|
|
87943
|
+
this.currentThinkingId = `reasoning - ${this.thinkBlockIndex++} `;
|
|
87531
87944
|
controller.enqueue({
|
|
87532
87945
|
type: "reasoning-start",
|
|
87533
87946
|
id: this.currentThinkingId
|
|
@@ -87550,7 +87963,7 @@ var ACPLanguageModel = class {
|
|
|
87550
87963
|
if (update$1.content.type === "text") {
|
|
87551
87964
|
const textChunk = update$1.content.text;
|
|
87552
87965
|
if (!this.currentTextId) {
|
|
87553
|
-
this.currentTextId = `text
|
|
87966
|
+
this.currentTextId = `text - ${this.textBlockIndex++} `;
|
|
87554
87967
|
controller.enqueue({
|
|
87555
87968
|
type: "text-start",
|
|
87556
87969
|
id: this.currentTextId
|
|
@@ -87582,7 +87995,7 @@ var ACPLanguageModel = class {
|
|
|
87582
87995
|
controller.enqueue({
|
|
87583
87996
|
type: "tool-call",
|
|
87584
87997
|
toolCallId,
|
|
87585
|
-
toolName:
|
|
87998
|
+
toolName: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME2,
|
|
87586
87999
|
input: JSON.stringify({
|
|
87587
88000
|
toolCallId,
|
|
87588
88001
|
toolName,
|
|
@@ -87608,7 +88021,7 @@ var ACPLanguageModel = class {
|
|
|
87608
88021
|
controller.enqueue({
|
|
87609
88022
|
type: "tool-call",
|
|
87610
88023
|
toolCallId,
|
|
87611
|
-
toolName:
|
|
88024
|
+
toolName: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME2,
|
|
87612
88025
|
input: JSON.stringify({
|
|
87613
88026
|
toolCallId,
|
|
87614
88027
|
toolName
|
|
@@ -87618,7 +88031,7 @@ var ACPLanguageModel = class {
|
|
|
87618
88031
|
controller.enqueue({
|
|
87619
88032
|
type: "tool-result",
|
|
87620
88033
|
toolCallId,
|
|
87621
|
-
toolName:
|
|
88034
|
+
toolName: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME2,
|
|
87622
88035
|
result: toolResult,
|
|
87623
88036
|
providerExecuted: true,
|
|
87624
88037
|
...isError && {
|
|
@@ -87709,7 +88122,21 @@ var ACPLanguageModel = class {
|
|
|
87709
88122
|
* Implements the streaming generation method.
|
|
87710
88123
|
*/
|
|
87711
88124
|
async doStream(options) {
|
|
87712
|
-
|
|
88125
|
+
const acpTools2 = [];
|
|
88126
|
+
if (options.tools) {
|
|
88127
|
+
for (const t$5 of options.tools) if (t$5.type === "function") {
|
|
88128
|
+
const toolInputSchema = t$5.inputSchema;
|
|
88129
|
+
if (hasRegisteredExecute(t$5.name) && toolInputSchema) {
|
|
88130
|
+
const execute = getExecuteByName(t$5.name);
|
|
88131
|
+
if (execute) acpTools2.push({
|
|
88132
|
+
...t$5,
|
|
88133
|
+
name: t$5.name,
|
|
88134
|
+
execute
|
|
88135
|
+
});
|
|
88136
|
+
}
|
|
88137
|
+
}
|
|
88138
|
+
}
|
|
88139
|
+
await this.ensureConnected(acpTools2.length > 0 ? acpTools2 : void 0);
|
|
87713
88140
|
const promptContent = this.getPromptContent(options);
|
|
87714
88141
|
const connection = this.connection;
|
|
87715
88142
|
const sessionId = this.sessionId;
|
|
@@ -87758,18 +88185,8 @@ var ACPLanguageModel = class {
|
|
|
87758
88185
|
warnings: []
|
|
87759
88186
|
};
|
|
87760
88187
|
}
|
|
87761
|
-
/**
|
|
87762
|
-
* Defines the provider agent dynamic tool used to bridge ACP's agent-side tool calls
|
|
87763
|
-
* with the AI SDK's tool execution flow.
|
|
87764
|
-
*/
|
|
87765
88188
|
get tools() {
|
|
87766
|
-
return
|
|
87767
|
-
name: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME,
|
|
87768
|
-
type: "provider-defined",
|
|
87769
|
-
inputSchema: jsonSchema({}),
|
|
87770
|
-
id: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME,
|
|
87771
|
-
args: jsonSchema({})
|
|
87772
|
-
}) };
|
|
88189
|
+
return getACPDynamicTool();
|
|
87773
88190
|
}
|
|
87774
88191
|
};
|
|
87775
88192
|
var ACPProvider = class {
|
|
@@ -87783,8 +88200,10 @@ var ACPProvider = class {
|
|
|
87783
88200
|
*
|
|
87784
88201
|
* @returns A LanguageModelV2 instance
|
|
87785
88202
|
*/
|
|
87786
|
-
languageModel() {
|
|
87787
|
-
if (!this.model) this.model = new ACPLanguageModel(
|
|
88203
|
+
languageModel(modelId, modeId) {
|
|
88204
|
+
if (!this.model) this.model = new ACPLanguageModel(modelId, modeId, this.config);
|
|
88205
|
+
if (modelId) this.model.modelId = modelId;
|
|
88206
|
+
if (modeId) this.model.modeId = modeId;
|
|
87788
88207
|
return this.model;
|
|
87789
88208
|
}
|
|
87790
88209
|
/**
|
|
@@ -87794,7 +88213,7 @@ var ACPProvider = class {
|
|
|
87794
88213
|
return this.languageModel();
|
|
87795
88214
|
}
|
|
87796
88215
|
/**
|
|
87797
|
-
* Provider tools
|
|
88216
|
+
* Provider tools - includes the agent dynamic tool
|
|
87798
88217
|
*/
|
|
87799
88218
|
get tools() {
|
|
87800
88219
|
return this.model?.tools;
|
|
@@ -87810,9 +88229,17 @@ var ACPProvider = class {
|
|
|
87810
88229
|
* Initializes the session and returns session info (models, modes, meta).
|
|
87811
88230
|
* Call this before prompting to discover available options.
|
|
87812
88231
|
*/
|
|
87813
|
-
initSession() {
|
|
88232
|
+
initSession(acpTools2) {
|
|
88233
|
+
if (!this.model) this.languageModel();
|
|
88234
|
+
return this.model.initSession(acpTools2);
|
|
88235
|
+
}
|
|
88236
|
+
/**
|
|
88237
|
+
* Initializes the connection to the agent process without starting a session.
|
|
88238
|
+
* Useful if you need to reduce the time to the first token.
|
|
88239
|
+
*/
|
|
88240
|
+
connect() {
|
|
87814
88241
|
if (!this.model) this.languageModel();
|
|
87815
|
-
return this.model.
|
|
88242
|
+
return this.model.connectClient();
|
|
87816
88243
|
}
|
|
87817
88244
|
/**
|
|
87818
88245
|
* Sets the session mode (e.g., "ask", "plan").
|
|
@@ -87841,55 +88268,64 @@ function createACPProvider(config) {
|
|
|
87841
88268
|
}
|
|
87842
88269
|
|
|
87843
88270
|
//#endregion
|
|
87844
|
-
//#region src/
|
|
88271
|
+
//#region src/middleware/acp-middleware.ts
|
|
87845
88272
|
/**
|
|
87846
|
-
*
|
|
87847
|
-
* This is more stable than using npx as it uses the installed package directly
|
|
87848
|
-
*
|
|
87849
|
-
* @param packageName - The npm package name (e.g., 'mcp-remote', 'typescript', 'eslint')
|
|
87850
|
-
* @param cwd - Current working directory (defaults to process.cwd())
|
|
87851
|
-
* @returns Object containing the command and args to execute the binary
|
|
87852
|
-
*
|
|
87853
|
-
* @example
|
|
87854
|
-
* ```ts
|
|
87855
|
-
* const { command, args } = resolvePackageBin('mcp-remote');
|
|
87856
|
-
* spawn(command, [...args, 'http://localhost:5173']);
|
|
87857
|
-
* ```
|
|
88273
|
+
* Call MCP method via transport and wait for response
|
|
87858
88274
|
*/
|
|
87859
|
-
function
|
|
87860
|
-
|
|
87861
|
-
|
|
87862
|
-
|
|
87863
|
-
|
|
87864
|
-
|
|
87865
|
-
|
|
87866
|
-
const fullBinPath = resolve(dirname(packageJsonPath), binPath);
|
|
87867
|
-
if (existsSync$1(fullBinPath)) return {
|
|
87868
|
-
command: "node",
|
|
87869
|
-
args: [fullBinPath]
|
|
87870
|
-
};
|
|
87871
|
-
}
|
|
87872
|
-
}
|
|
87873
|
-
} catch (error$1) {}
|
|
87874
|
-
console.warn(`${packageName} not found in node_modules, falling back to npx. Consider installing ${packageName} as a dependency.`);
|
|
87875
|
-
return {
|
|
87876
|
-
command: "npx",
|
|
87877
|
-
args: [packageName]
|
|
88275
|
+
function callMcpMethodViaTransport(transport, method, params) {
|
|
88276
|
+
const messageId = Date.now();
|
|
88277
|
+
const message = {
|
|
88278
|
+
method,
|
|
88279
|
+
params,
|
|
88280
|
+
jsonrpc: "2.0",
|
|
88281
|
+
id: messageId
|
|
87878
88282
|
};
|
|
88283
|
+
return new Promise((resolve$3) => {
|
|
88284
|
+
transport.onmessage?.(message);
|
|
88285
|
+
const originalSend = transport.send;
|
|
88286
|
+
transport.send = function(payload) {
|
|
88287
|
+
const payloadObj = payload;
|
|
88288
|
+
if (payloadObj.id === messageId) {
|
|
88289
|
+
resolve$3(payloadObj.result);
|
|
88290
|
+
transport.send = originalSend;
|
|
88291
|
+
}
|
|
88292
|
+
return originalSend.call(this, payload);
|
|
88293
|
+
};
|
|
88294
|
+
});
|
|
88295
|
+
}
|
|
88296
|
+
/**
|
|
88297
|
+
* Load MCP tools from transport in AI SDK v5 format
|
|
88298
|
+
*/
|
|
88299
|
+
async function loadMcpToolsV5(transport) {
|
|
88300
|
+
const tools = {};
|
|
88301
|
+
const { tools: toolsListFromServer } = await callMcpMethodViaTransport(transport, "tools/list");
|
|
88302
|
+
for (const toolInfo of toolsListFromServer) {
|
|
88303
|
+
const toolName = toolInfo.name;
|
|
88304
|
+
tools[toolName] = tool({
|
|
88305
|
+
description: toolInfo.description,
|
|
88306
|
+
inputSchema: jsonSchema(toolInfo.inputSchema),
|
|
88307
|
+
execute: async (args) => {
|
|
88308
|
+
console.log(`[dev-inspector] [acp] Executing MCP tool: ${toolName}`);
|
|
88309
|
+
return await callMcpMethodViaTransport(transport, "tools/call", {
|
|
88310
|
+
name: toolName,
|
|
88311
|
+
arguments: args
|
|
88312
|
+
});
|
|
88313
|
+
}
|
|
88314
|
+
});
|
|
88315
|
+
}
|
|
88316
|
+
console.log(`[dev-inspector] [acp] Loaded ${Object.keys(tools).length} MCP tools`);
|
|
88317
|
+
return tools;
|
|
87879
88318
|
}
|
|
87880
88319
|
/**
|
|
87881
|
-
*
|
|
87882
|
-
* Convenience wrapper around resolvePackageBin for mcp-remote
|
|
87883
|
-
*
|
|
87884
|
-
* @param cwd - Current working directory (defaults to process.cwd())
|
|
87885
|
-
* @returns Object containing the command and args to execute mcp-remote
|
|
88320
|
+
* Get an active transport from the connection manager
|
|
87886
88321
|
*/
|
|
87887
|
-
function
|
|
87888
|
-
|
|
88322
|
+
function getActiveTransport() {
|
|
88323
|
+
const connectionManager = getConnectionManager();
|
|
88324
|
+
if (!connectionManager) return null;
|
|
88325
|
+
const sessionIds = Object.keys(connectionManager.transports);
|
|
88326
|
+
if (sessionIds.length === 0) return null;
|
|
88327
|
+
return connectionManager.transports[sessionIds[0]];
|
|
87889
88328
|
}
|
|
87890
|
-
|
|
87891
|
-
//#endregion
|
|
87892
|
-
//#region src/middleware/acp-middleware.ts
|
|
87893
88329
|
function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
87894
88330
|
middlewares.use("/api/acp/chat", async (req, res) => {
|
|
87895
88331
|
if (handleCors(res, req.method)) return;
|
|
@@ -87902,42 +88338,26 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
87902
88338
|
const body = await readBody(req);
|
|
87903
88339
|
const { messages, agent, envVars } = JSON.parse(body);
|
|
87904
88340
|
const cwd$1 = process.cwd();
|
|
87905
|
-
const mcpRemote = resolveMcpRemote(cwd$1);
|
|
87906
88341
|
const provider = createACPProvider({
|
|
87907
88342
|
command: agent.command,
|
|
87908
88343
|
args: agent.args,
|
|
87909
88344
|
env: envVars,
|
|
87910
88345
|
session: {
|
|
87911
88346
|
cwd: cwd$1,
|
|
87912
|
-
mcpServers: [
|
|
87913
|
-
command: mcpRemote.command,
|
|
87914
|
-
args: [...mcpRemote.args, `http://${serverContext?.host || "localhost"}:${serverContext?.port || 5173}/__mcp__/sse?clientId=acp&puppetId=inspector`],
|
|
87915
|
-
env: [],
|
|
87916
|
-
name: "inspect"
|
|
87917
|
-
}]
|
|
88347
|
+
mcpServers: []
|
|
87918
88348
|
},
|
|
87919
88349
|
authMethodId: agent.authMethodId
|
|
87920
88350
|
});
|
|
87921
|
-
const
|
|
87922
|
-
|
|
87923
|
-
if (
|
|
87924
|
-
|
|
87925
|
-
console.log("[dev-inspector] [acp] Available modes:", availableModes.map((m) => m.id).join(", "));
|
|
87926
|
-
console.log("[dev-inspector] [acp] Current mode:", currentModeId);
|
|
87927
|
-
}
|
|
87928
|
-
if (sessionInfo.models) {
|
|
87929
|
-
const { availableModels, currentModelId } = sessionInfo.models;
|
|
87930
|
-
console.log("[dev-inspector] [acp] Available models:", availableModels.map((m) => m.modelId).join(", "));
|
|
87931
|
-
console.log("[dev-inspector] [acp] Current model:", currentModelId);
|
|
87932
|
-
}
|
|
88351
|
+
const transport = getActiveTransport();
|
|
88352
|
+
let mcpTools = {};
|
|
88353
|
+
if (transport) mcpTools = await loadMcpToolsV5(transport);
|
|
88354
|
+
else console.warn("[dev-inspector] [acp] No active MCP transport available, tools will not be loaded");
|
|
87933
88355
|
const mode = agent.acpMode ?? acpOptions?.acpMode;
|
|
87934
88356
|
const model = agent.acpModel ?? acpOptions?.acpModel;
|
|
87935
88357
|
const delay = agent.acpDelay ?? acpOptions?.acpDelay;
|
|
87936
|
-
if (mode !== void 0) await provider.setMode(mode);
|
|
87937
|
-
if (model !== void 0) await provider.setModel(model);
|
|
87938
88358
|
if (delay !== void 0 && delay > 0) {
|
|
87939
88359
|
console.log(`[dev-inspector] [acp] Delaying response by ${delay}ms, agent: ${agent.name}`);
|
|
87940
|
-
await new Promise((resolve$
|
|
88360
|
+
await new Promise((resolve$3) => setTimeout(resolve$3, delay));
|
|
87941
88361
|
}
|
|
87942
88362
|
const abortController = new AbortController();
|
|
87943
88363
|
req.on("close", () => {
|
|
@@ -87946,15 +88366,15 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
87946
88366
|
provider.cleanup();
|
|
87947
88367
|
});
|
|
87948
88368
|
const response = streamText({
|
|
87949
|
-
model: provider.languageModel(),
|
|
88369
|
+
model: provider.languageModel(model, mode),
|
|
87950
88370
|
includeRawChunks: true,
|
|
87951
88371
|
messages: convertToModelMessages(messages),
|
|
87952
88372
|
abortSignal: abortController.signal,
|
|
88373
|
+
tools: acpTools(mcpTools),
|
|
87953
88374
|
onError: (error$1) => {
|
|
87954
88375
|
console.error("Error occurred while streaming text:", JSON.stringify(error$1, null, 2));
|
|
87955
88376
|
provider.cleanup();
|
|
87956
|
-
}
|
|
87957
|
-
tools: provider.tools
|
|
88377
|
+
}
|
|
87958
88378
|
}).toUIMessageStreamResponse({
|
|
87959
88379
|
messageMetadata: ({ part }) => {
|
|
87960
88380
|
if (part.type === "raw" && part.rawValue) {
|
|
@@ -87998,13 +88418,13 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
87998
88418
|
});
|
|
87999
88419
|
}
|
|
88000
88420
|
function readBody(req) {
|
|
88001
|
-
return new Promise((resolve$
|
|
88421
|
+
return new Promise((resolve$3, reject) => {
|
|
88002
88422
|
let body = "";
|
|
88003
88423
|
req.on("data", (chunk) => {
|
|
88004
88424
|
body += chunk.toString();
|
|
88005
88425
|
});
|
|
88006
88426
|
req.on("end", () => {
|
|
88007
|
-
resolve$
|
|
88427
|
+
resolve$3(body);
|
|
88008
88428
|
});
|
|
88009
88429
|
req.on("error", (err) => {
|
|
88010
88430
|
reject(err);
|