@mcpc-tech/unplugin-dev-inspector-mcp 0.0.2-beta.8 → 0.0.2-beta.9

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.
Files changed (3) hide show
  1. package/dist/index.cjs +670 -100
  2. package/dist/index.js +687 -118
  3. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -52,7 +52,9 @@ let crypto$1 = require("crypto");
52
52
  let __modelcontextprotocol_sdk_server_index_js = require("@modelcontextprotocol/sdk/server/index.js");
53
53
  let __modelcontextprotocol_sdk_types_js = require("@modelcontextprotocol/sdk/types.js");
54
54
  let zod = require("zod");
55
+ zod = __toESM(zod);
55
56
  let node_module = require("node:module");
57
+ let node_stream = require("node:stream");
56
58
  let stream = require("stream");
57
59
  let node_crypto = require("node:crypto");
58
60
  let node_path = require("node:path");
@@ -77,8 +79,8 @@ let path = require("path");
77
79
  path = __toESM(path);
78
80
  let url = require("url");
79
81
  let ai = require("ai");
80
- let __mcpc_tech_acp_ai_provider = require("@mcpc-tech/acp-ai-provider");
81
82
  let __agentclientprotocol_sdk = require("@agentclientprotocol/sdk");
83
+ let node_child_process = require("node:child_process");
82
84
  let node_fs = require("node:fs");
83
85
  let __vue_compiler_sfc = require("@vue/compiler-sfc");
84
86
 
@@ -170,31 +172,31 @@ var ClientExecServer = class {
170
172
  const registeredTools = [];
171
173
  const conflicts = [];
172
174
  const clientToolNames = /* @__PURE__ */ new Set();
173
- for (const tool of tools) {
174
- const toolName = this.getToolName(clientId, tool.name);
175
+ for (const tool$1 of tools) {
176
+ const toolName = this.getToolName(clientId, tool$1.name);
175
177
  if (this.tools.has(toolName)) {
176
178
  const existingOwner = this.toolToClient.get(toolName);
177
179
  const isPredefined = this.predefinedTools.has(toolName);
178
180
  if (this.useNamespacing) {
179
181
  console.error(`Unexpected tool name conflict with namespacing: ${toolName}`);
180
- conflicts.push(tool.name);
182
+ conflicts.push(tool$1.name);
181
183
  continue;
182
184
  } else if (isPredefined && existingOwner === this.clientId) {
183
- console.log(`Client ${clientId} providing implementation for predefined tool: ${tool.name}`);
185
+ console.log(`Client ${clientId} providing implementation for predefined tool: ${tool$1.name}`);
184
186
  this.predefinedTools.delete(toolName);
185
187
  } else {
186
- console.warn(`Tool ${tool.name} already exists, owned by client ${existingOwner}. Skipping registration for client ${clientId}`);
187
- conflicts.push(tool.name);
188
+ console.warn(`Tool ${tool$1.name} already exists, owned by client ${existingOwner}. Skipping registration for client ${clientId}`);
189
+ conflicts.push(tool$1.name);
188
190
  continue;
189
191
  }
190
192
  }
191
193
  this.tools.set(toolName, {
192
- name: this.useNamespacing ? tool.name : toolName,
193
- description: this.useNamespacing ? `[${clientId}] ${tool.description}` : tool.description,
194
- inputSchema: tool.inputSchema
194
+ name: this.useNamespacing ? tool$1.name : toolName,
195
+ description: this.useNamespacing ? `[${clientId}] ${tool$1.description}` : tool$1.description,
196
+ inputSchema: tool$1.inputSchema
195
197
  });
196
198
  clientToolNames.add(toolName);
197
- registeredTools.push(tool.name);
199
+ registeredTools.push(tool$1.name);
198
200
  this.toolToClient.set(toolName, clientId);
199
201
  }
200
202
  this.clientTools.set(clientId, clientToolNames);
@@ -226,12 +228,12 @@ var ClientExecServer = class {
226
228
  registerClientToolSchemas(tools) {
227
229
  this.unregisterClientTools(this.clientId);
228
230
  const clientToolNames = /* @__PURE__ */ new Set();
229
- for (const tool of tools) {
230
- const toolName = this.getToolName(this.clientId, tool.name);
231
+ for (const tool$1 of tools) {
232
+ const toolName = this.getToolName(this.clientId, tool$1.name);
231
233
  this.tools.set(toolName, {
232
- name: tool.name,
233
- description: tool.description,
234
- inputSchema: tool.inputSchema
234
+ name: tool$1.name,
235
+ description: tool$1.description,
236
+ inputSchema: tool$1.inputSchema
235
237
  });
236
238
  this.toolToClient.set(toolName, this.clientId);
237
239
  this.predefinedTools.add(toolName);
@@ -32811,7 +32813,7 @@ var require_h2c_client = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/
32811
32813
  //#region ../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/api/readable.js
32812
32814
  var require_readable = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/api/readable.js": ((exports, module) => {
32813
32815
  const assert$20 = require("node:assert");
32814
- const { Readable: Readable$5 } = require("node:stream");
32816
+ const { Readable: Readable$6 } = require("node:stream");
32815
32817
  const { RequestAbortedError: RequestAbortedError$4, NotSupportedError, InvalidArgumentError: InvalidArgumentError$19, AbortError: AbortError$1 } = require_errors$1();
32816
32818
  const util$23 = require_util$8();
32817
32819
  const { ReadableStreamFrom } = require_util$8();
@@ -32829,7 +32831,7 @@ var require_readable = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/un
32829
32831
  * @extends {Readable}
32830
32832
  * @see https://fetch.spec.whatwg.org/#body
32831
32833
  */
32832
- var BodyReadable = class extends Readable$5 {
32834
+ var BodyReadable = class extends Readable$6 {
32833
32835
  /**
32834
32836
  * @param {object} opts
32835
32837
  * @param {(this: Readable, size: number) => void} opts.resume
@@ -33226,7 +33228,7 @@ var require_readable = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/un
33226
33228
  var require_api_request = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/api/api-request.js": ((exports, module) => {
33227
33229
  const assert$19 = require("node:assert");
33228
33230
  const { AsyncResource: AsyncResource$4 } = require("node:async_hooks");
33229
- const { Readable: Readable$4 } = require_readable();
33231
+ const { Readable: Readable$5 } = require_readable();
33230
33232
  const { InvalidArgumentError: InvalidArgumentError$18, RequestAbortedError: RequestAbortedError$3 } = require_errors$1();
33231
33233
  const util$22 = require_util$8();
33232
33234
  function noop$5() {}
@@ -33287,7 +33289,7 @@ var require_api_request = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm
33287
33289
  const parsedHeaders = responseHeaders === "raw" ? util$22.parseHeaders(rawHeaders) : headers;
33288
33290
  const contentType = parsedHeaders["content-type"];
33289
33291
  const contentLength = parsedHeaders["content-length"];
33290
- const res = new Readable$4({
33292
+ const res = new Readable$5({
33291
33293
  resume: resume$1,
33292
33294
  abort: abort$1,
33293
33295
  contentType,
@@ -33544,7 +33546,7 @@ var require_api_stream = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/
33544
33546
  //#endregion
33545
33547
  //#region ../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/api/api-pipeline.js
33546
33548
  var require_api_pipeline = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/api/api-pipeline.js": ((exports, module) => {
33547
- const { Readable: Readable$3, Duplex, PassThrough } = require("node:stream");
33549
+ const { Readable: Readable$4, Duplex, PassThrough } = require("node:stream");
33548
33550
  const assert$17 = require("node:assert");
33549
33551
  const { AsyncResource: AsyncResource$2 } = require("node:async_hooks");
33550
33552
  const { InvalidArgumentError: InvalidArgumentError$16, InvalidReturnValueError, RequestAbortedError: RequestAbortedError$1 } = require_errors$1();
@@ -33552,7 +33554,7 @@ var require_api_pipeline = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnp
33552
33554
  const { addSignal: addSignal$2, removeSignal: removeSignal$2 } = require_abort_signal();
33553
33555
  function noop$3() {}
33554
33556
  const kResume = Symbol("resume");
33555
- var PipelineRequest = class extends Readable$3 {
33557
+ var PipelineRequest = class extends Readable$4 {
33556
33558
  constructor() {
33557
33559
  super({ autoDestroy: true });
33558
33560
  this[kResume] = null;
@@ -33569,7 +33571,7 @@ var require_api_pipeline = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnp
33569
33571
  callback(err);
33570
33572
  }
33571
33573
  };
33572
- var PipelineResponse = class extends Readable$3 {
33574
+ var PipelineResponse = class extends Readable$4 {
33573
33575
  constructor(resume$1) {
33574
33576
  super({ autoDestroy: true });
33575
33577
  this[kResume] = resume$1;
@@ -37028,7 +37030,7 @@ var require_cache_handler = /* @__PURE__ */ __commonJS({ "../../node_modules/.pn
37028
37030
  //#endregion
37029
37031
  //#region ../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/cache/memory-cache-store.js
37030
37032
  var require_memory_cache_store = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/cache/memory-cache-store.js": ((exports, module) => {
37031
- const { Writable: Writable$3 } = require("node:stream");
37033
+ const { Writable: Writable$4 } = require("node:stream");
37032
37034
  const { EventEmitter: EventEmitter$1 } = require("node:events");
37033
37035
  const { assertCacheKey: assertCacheKey$1, assertCacheValue: assertCacheValue$1 } = require_cache$2();
37034
37036
  /**
@@ -37123,7 +37125,7 @@ var require_memory_cache_store = /* @__PURE__ */ __commonJS({ "../../node_module
37123
37125
  body: [],
37124
37126
  size: 0
37125
37127
  };
37126
- return new Writable$3({
37128
+ return new Writable$4({
37127
37129
  write(chunk, encoding, callback) {
37128
37130
  if (typeof chunk === "string") chunk = Buffer.from(chunk, encoding);
37129
37131
  entry.size += chunk.byteLength;
@@ -37276,7 +37278,7 @@ var require_cache_revalidation_handler = /* @__PURE__ */ __commonJS({ "../../nod
37276
37278
  //#region ../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/interceptor/cache.js
37277
37279
  var require_cache$1 = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/interceptor/cache.js": ((exports, module) => {
37278
37280
  const assert$11 = require("node:assert");
37279
- const { Readable: Readable$2 } = require("node:stream");
37281
+ const { Readable: Readable$3 } = require("node:stream");
37280
37282
  const util$15 = require_util$8();
37281
37283
  const CacheHandler = require_cache_handler();
37282
37284
  const MemoryCacheStore = require_memory_cache_store();
@@ -37351,7 +37353,7 @@ var require_cache$1 = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/und
37351
37353
  * @param {boolean} isStale
37352
37354
  */
37353
37355
  function sendCachedValue(handler, opts, result, age, context$1, isStale) {
37354
- const stream$3 = util$15.isStream(result.body) ? result.body : Readable$2.from(result.body ?? []);
37356
+ const stream$3 = util$15.isStream(result.body) ? result.body : Readable$3.from(result.body ?? []);
37355
37357
  assert$11(!stream$3.destroyed, "stream should not be destroyed");
37356
37358
  assert$11(!stream$3.readableDidRead, "stream should not be readableDidRead");
37357
37359
  const controller = {
@@ -37706,7 +37708,7 @@ var require_decompress = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/
37706
37708
  //#endregion
37707
37709
  //#region ../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/cache/sqlite-cache-store.js
37708
37710
  var require_sqlite_cache_store = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/cache/sqlite-cache-store.js": ((exports, module) => {
37709
- const { Writable: Writable$2 } = require("node:stream");
37711
+ const { Writable: Writable$3 } = require("node:stream");
37710
37712
  const { assertCacheKey, assertCacheValue } = require_cache$2();
37711
37713
  let DatabaseSync;
37712
37714
  const VERSION$3 = 3;
@@ -37928,7 +37930,7 @@ var require_sqlite_cache_store = /* @__PURE__ */ __commonJS({ "../../node_module
37928
37930
  */
37929
37931
  const body = [];
37930
37932
  const store = this;
37931
- return new Writable$2({
37933
+ return new Writable$3({
37932
37934
  decodeStrings: true,
37933
37935
  write(chunk, encoding, callback) {
37934
37936
  size += chunk.byteLength;
@@ -39520,7 +39522,7 @@ var require_fetch = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/undic
39520
39522
  const { safelyExtractBody, extractBody } = require_body();
39521
39523
  const { redirectStatusSet, nullBodyStatus, safeMethodsSet, requestBodyHeader, subresourceSet } = require_constants$6();
39522
39524
  const EE = require("node:events");
39523
- const { Readable: Readable$1, pipeline: pipeline$1, finished: finished$1, isErrored, isReadable } = require("node:stream");
39525
+ const { Readable: Readable$2, pipeline: pipeline$1, finished: finished$1, isErrored, isReadable } = require("node:stream");
39524
39526
  const { addAbortListener, bufferToLowerCasedHeaderName } = require_util$8();
39525
39527
  const { dataURLProcessor, serializeAMimeType: serializeAMimeType$1, minimizeSupportedMimeType } = require_data_url();
39526
39528
  const { getGlobalDispatcher: getGlobalDispatcher$2 } = require_global();
@@ -40123,7 +40125,7 @@ var require_fetch = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/undic
40123
40125
  const headersList = new HeadersList();
40124
40126
  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);
40125
40127
  const location = headersList.get("location", true);
40126
- this.body = new Readable$1({ read: resume$1 });
40128
+ this.body = new Readable$2({ read: resume$1 });
40127
40129
  const willFollow = location && request$1.redirect === "follow" && redirectStatusSet.has(status);
40128
40130
  const decoders = [];
40129
40131
  if (request$1.method !== "HEAD" && request$1.method !== "CONNECT" && !nullBodyStatus.includes(status) && !willFollow) {
@@ -42155,14 +42157,14 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJS({ "../../node_module
42155
42157
  //#endregion
42156
42158
  //#region ../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/web/websocket/receiver.js
42157
42159
  var require_receiver = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/web/websocket/receiver.js": ((exports, module) => {
42158
- const { Writable: Writable$1 } = require("node:stream");
42160
+ const { Writable: Writable$2 } = require("node:stream");
42159
42161
  const assert$1 = require("node:assert");
42160
42162
  const { parserStates, opcodes: opcodes$3, states: states$2, emptyBuffer, sentCloseFrameState: sentCloseFrameState$2 } = require_constants$4();
42161
42163
  const { isValidStatusCode, isValidOpcode, websocketMessageReceived, utf8Decode: utf8Decode$2, isControlFrame, isTextBinaryFrame, isContinuationFrame } = require_util$4();
42162
42164
  const { failWebsocketConnection: failWebsocketConnection$2 } = require_connection();
42163
42165
  const { WebsocketFrameSend: WebsocketFrameSend$3 } = require_frame();
42164
42166
  const { PerMessageDeflate } = require_permessage_deflate();
42165
- var ByteParser$2 = class extends Writable$1 {
42167
+ var ByteParser$2 = class extends Writable$2 {
42166
42168
  #buffers = [];
42167
42169
  #fragmentsBytes = 0;
42168
42170
  #byteOffset = 0;
@@ -58129,13 +58131,13 @@ var require_getMachineId_bsd$1 = /* @__PURE__ */ __commonJS({ "../../node_module
58129
58131
  var require_getMachineId_win$1 = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@opentelemetry+resources@1.30.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-win.js": ((exports) => {
58130
58132
  Object.defineProperty(exports, "__esModule", { value: true });
58131
58133
  exports.getMachineId = void 0;
58132
- const process$4 = require("process");
58134
+ const process$5 = require("process");
58133
58135
  const execAsync_1$3 = require_execAsync$1();
58134
58136
  const api_1$37 = (init_esm$2(), __toCommonJS(esm_exports$2));
58135
58137
  async function getMachineId$8() {
58136
58138
  const args = "QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid";
58137
58139
  let command = "%windir%\\System32\\REG.exe";
58138
- if (process$4.arch === "ia32" && "PROCESSOR_ARCHITEW6432" in process$4.env) command = "%windir%\\sysnative\\cmd.exe /c " + command;
58140
+ if (process$5.arch === "ia32" && "PROCESSOR_ARCHITEW6432" in process$5.env) command = "%windir%\\sysnative\\cmd.exe /c " + command;
58139
58141
  try {
58140
58142
  const parts = (await (0, execAsync_1$3.execAsync)(`${command} ${args}`)).stdout.split("REG_SZ");
58141
58143
  if (parts.length === 2) return parts[1].trim();
@@ -58165,10 +58167,10 @@ var require_getMachineId_unsupported$1 = /* @__PURE__ */ __commonJS({ "../../nod
58165
58167
  var require_getMachineId$1 = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@opentelemetry+resources@1.30.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId.js": ((exports) => {
58166
58168
  Object.defineProperty(exports, "__esModule", { value: true });
58167
58169
  exports.getMachineId = void 0;
58168
- const process$3 = require("process");
58170
+ const process$4 = require("process");
58169
58171
  let getMachineId$6;
58170
58172
  exports.getMachineId = getMachineId$6;
58171
- switch (process$3.platform) {
58173
+ switch (process$4.platform) {
58172
58174
  case "darwin":
58173
58175
  exports.getMachineId = getMachineId$6 = require_getMachineId_darwin$1().getMachineId;
58174
58176
  break;
@@ -60237,14 +60239,14 @@ var require_range = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/semve
60237
60239
  const replaceCaret = (comp, options) => {
60238
60240
  debug$1("caret", comp, options);
60239
60241
  const r = options.loose ? re$1[t$1.CARETLOOSE] : re$1[t$1.CARET];
60240
- const z$2 = options.includePrerelease ? "-0" : "";
60242
+ const z$3 = options.includePrerelease ? "-0" : "";
60241
60243
  return comp.replace(r, (_$1, M, m, p$1, pr) => {
60242
60244
  debug$1("caret", comp, _$1, M, m, p$1, pr);
60243
60245
  let ret;
60244
60246
  if (isX(M)) ret = "";
60245
- else if (isX(m)) ret = `>=${M}.0.0${z$2} <${+M + 1}.0.0-0`;
60246
- else if (isX(p$1)) if (M === "0") ret = `>=${M}.${m}.0${z$2} <${M}.${+m + 1}.0-0`;
60247
- else ret = `>=${M}.${m}.0${z$2} <${+M + 1}.0.0-0`;
60247
+ else if (isX(m)) ret = `>=${M}.0.0${z$3} <${+M + 1}.0.0-0`;
60248
+ else if (isX(p$1)) if (M === "0") ret = `>=${M}.${m}.0${z$3} <${M}.${+m + 1}.0-0`;
60249
+ else ret = `>=${M}.${m}.0${z$3} <${+M + 1}.0.0-0`;
60248
60250
  else if (pr) {
60249
60251
  debug$1("replaceCaret pr", pr);
60250
60252
  if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p$1}-${pr} <${M}.${m}.${+p$1 + 1}-0`;
@@ -60252,8 +60254,8 @@ var require_range = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/semve
60252
60254
  else ret = `>=${M}.${m}.${p$1}-${pr} <${+M + 1}.0.0-0`;
60253
60255
  } else {
60254
60256
  debug$1("no pr");
60255
- if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p$1}${z$2} <${M}.${m}.${+p$1 + 1}-0`;
60256
- else ret = `>=${M}.${m}.${p$1}${z$2} <${M}.${+m + 1}.0-0`;
60257
+ if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p$1}${z$3} <${M}.${m}.${+p$1 + 1}-0`;
60258
+ else ret = `>=${M}.${m}.${p$1}${z$3} <${M}.${+m + 1}.0-0`;
60257
60259
  else ret = `>=${M}.${m}.${p$1} <${+M + 1}.0.0-0`;
60258
60260
  }
60259
60261
  debug$1("caret return", ret);
@@ -66281,13 +66283,13 @@ var require_getMachineId_bsd = /* @__PURE__ */ __commonJS({ "../../node_modules/
66281
66283
  var require_getMachineId_win = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@opentelemetry+resources@1.29.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-win.js": ((exports) => {
66282
66284
  Object.defineProperty(exports, "__esModule", { value: true });
66283
66285
  exports.getMachineId = void 0;
66284
- const process$2 = require("process");
66286
+ const process$3 = require("process");
66285
66287
  const execAsync_1 = require_execAsync();
66286
66288
  const api_1$10 = (init_esm$2(), __toCommonJS(esm_exports$2));
66287
66289
  async function getMachineId$2() {
66288
66290
  const args = "QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid";
66289
66291
  let command = "%windir%\\System32\\REG.exe";
66290
- if (process$2.arch === "ia32" && "PROCESSOR_ARCHITEW6432" in process$2.env) command = "%windir%\\sysnative\\cmd.exe /c " + command;
66292
+ if (process$3.arch === "ia32" && "PROCESSOR_ARCHITEW6432" in process$3.env) command = "%windir%\\sysnative\\cmd.exe /c " + command;
66291
66293
  try {
66292
66294
  const parts = (await (0, execAsync_1.execAsync)(`${command} ${args}`)).stdout.split("REG_SZ");
66293
66295
  if (parts.length === 2) return parts[1].trim();
@@ -66317,10 +66319,10 @@ var require_getMachineId_unsupported = /* @__PURE__ */ __commonJS({ "../../node_
66317
66319
  var require_getMachineId = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@opentelemetry+resources@1.29.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId.js": ((exports) => {
66318
66320
  Object.defineProperty(exports, "__esModule", { value: true });
66319
66321
  exports.getMachineId = void 0;
66320
- const process$1 = require("process");
66322
+ const process$2 = require("process");
66321
66323
  let getMachineId;
66322
66324
  exports.getMachineId = getMachineId;
66323
- switch (process$1.platform) {
66325
+ switch (process$2.platform) {
66324
66326
  case "darwin":
66325
66327
  exports.getMachineId = getMachineId = require_getMachineId_darwin().getMachineId;
66326
66328
  break;
@@ -83277,7 +83279,7 @@ var import_json_schema_traverse = /* @__PURE__ */ __toESM(require_json_schema_tr
83277
83279
  var schemaSymbol = Symbol.for("mcpc.schema");
83278
83280
  var vercelSchemaSymbol = Symbol.for("vercel.ai.schema");
83279
83281
  var validatorSymbol = Symbol.for("mcpc.validator");
83280
- function jsonSchema(schema, options = {}) {
83282
+ function jsonSchema$1(schema, options = {}) {
83281
83283
  if (isWrappedSchema(schema)) return schema;
83282
83284
  return {
83283
83285
  [schemaSymbol]: true,
@@ -83530,13 +83532,13 @@ async function composeMcpDepTools(mcpConfig, filterIn) {
83530
83532
  acquiredKeys.push(defKey);
83531
83533
  allClients[serverId] = client;
83532
83534
  const { tools } = await client.listTools();
83533
- tools.forEach((tool) => {
83534
- const toolNameWithScope = `${name}.${tool.name}`;
83535
- const internalToolName = tool.name;
83535
+ tools.forEach((tool$1) => {
83536
+ const toolNameWithScope = `${name}.${tool$1.name}`;
83537
+ const internalToolName = tool$1.name;
83536
83538
  const toolId = sanitizePropertyKey(`${serverId}_${internalToolName}`);
83537
83539
  if (filterIn && !filterIn({
83538
83540
  action: internalToolName,
83539
- tool,
83541
+ tool: tool$1,
83540
83542
  mcpName: name,
83541
83543
  toolNameWithScope,
83542
83544
  internalToolName,
@@ -83547,7 +83549,7 @@ async function composeMcpDepTools(mcpConfig, filterIn) {
83547
83549
  arguments: args
83548
83550
  }, void 0, { timeout: def$30.toolCallTimeout });
83549
83551
  allTools[toolId] = {
83550
- ...tool,
83552
+ ...tool$1,
83551
83553
  execute,
83552
83554
  _originalName: toolNameWithScope
83553
83555
  };
@@ -83599,10 +83601,10 @@ var createConfigPlugin = () => ({
83599
83601
  name: "built-in-config",
83600
83602
  version: "1.0.0",
83601
83603
  enforce: "pre",
83602
- transformTool: (tool, context2) => {
83604
+ transformTool: (tool$1, context2) => {
83603
83605
  const config = context2.server.findToolConfig?.(context2.toolName);
83604
- if (config?.description) tool.description = config.description;
83605
- return tool;
83606
+ if (config?.description) tool$1.description = config.description;
83607
+ return tool$1;
83606
83608
  }
83607
83609
  });
83608
83610
  var config_plugin_default = createConfigPlugin();
@@ -83610,16 +83612,16 @@ var createToolNameMappingPlugin = () => ({
83610
83612
  name: "built-in-tool-name-mapping",
83611
83613
  version: "1.0.0",
83612
83614
  enforce: "pre",
83613
- transformTool: (tool, context2) => {
83615
+ transformTool: (tool$1, context2) => {
83614
83616
  const server = context2.server;
83615
83617
  const toolName = context2.toolName;
83616
- const originalName = tool._originalName || toolName;
83618
+ const originalName = tool$1._originalName || toolName;
83617
83619
  const dotNotation = originalName.replace(/_/g, ".");
83618
83620
  const underscoreNotation = originalName.replace(/\./g, "_");
83619
83621
  if (dotNotation !== originalName && server.toolNameMapping) server.toolNameMapping.set(dotNotation, toolName);
83620
83622
  if (underscoreNotation !== originalName && server.toolNameMapping) server.toolNameMapping.set(underscoreNotation, toolName);
83621
83623
  if (originalName !== toolName && server.toolNameMapping) server.toolNameMapping.set(originalName, toolName);
83622
- return tool;
83624
+ return tool$1;
83623
83625
  }
83624
83626
  });
83625
83627
  var tool_name_mapping_plugin_default = createToolNameMappingPlugin();
@@ -83968,10 +83970,10 @@ var CompiledPrompts = {
83968
83970
  };
83969
83971
  var PromptUtils = {
83970
83972
  generateToolList: (tools) => {
83971
- return tools.filter((tool) => !tool.hide).map((tool) => `<tool name="${tool.name}"${tool.description ? ` description="${tool.description}"` : ""}/>`).join("\n");
83973
+ return tools.filter((tool$1) => !tool$1.hide).map((tool$1) => `<tool name="${tool$1.name}"${tool$1.description ? ` description="${tool$1.description}"` : ""}/>`).join("\n");
83972
83974
  },
83973
83975
  generateHiddenToolList: (tools) => {
83974
- return tools.filter((tool) => tool.hide).map((tool) => `<tool name="${tool.name}" hide/>`).join("\n");
83976
+ return tools.filter((tool$1) => tool$1.hide).map((tool$1) => `<tool name="${tool$1.name}" hide/>`).join("\n");
83975
83977
  },
83976
83978
  formatWorkflowSteps: (steps) => {
83977
83979
  if (!steps.length) return "";
@@ -84546,7 +84548,7 @@ function registerAgenticTool(server, { description, name, allToolNames, depGroup
84546
84548
  type: "object",
84547
84549
  properties: {}
84548
84550
  };
84549
- server.tool(name, description, jsonSchema(createGoogleCompatibleJSONSchema(schema)), async (args) => {
84551
+ server.tool(name, description, jsonSchema$1(createGoogleCompatibleJSONSchema(schema)), async (args) => {
84550
84552
  return await agenticExecutor.execute(args, schema);
84551
84553
  });
84552
84554
  }
@@ -84951,7 +84953,7 @@ function registerAgenticWorkflowTool(server, { description, name, allToolNames,
84951
84953
  });
84952
84954
  const argsDef = createArgsDef.forTool();
84953
84955
  const toolDescription = createArgsDef.forToolDescription(baseDescription, workflowState);
84954
- server.tool(name, toolDescription, jsonSchema(createGoogleCompatibleJSONSchema(argsDef)), async (args) => {
84956
+ server.tool(name, toolDescription, jsonSchema$1(createGoogleCompatibleJSONSchema(argsDef)), async (args) => {
84955
84957
  try {
84956
84958
  return await workflowExecutor.execute(args, workflowState);
84957
84959
  } catch (error$1) {
@@ -85321,11 +85323,11 @@ var SamplingExecutor = class extends BaseSamplingExecutor {
85321
85323
  }
85322
85324
  buildDepGroups() {
85323
85325
  const depGroups = {};
85324
- this.toolNameToDetailList.forEach(([toolName, tool]) => {
85325
- if (tool?.inputSchema) depGroups[toolName] = {
85326
+ this.toolNameToDetailList.forEach(([toolName, tool$1]) => {
85327
+ if (tool$1?.inputSchema) depGroups[toolName] = {
85326
85328
  type: "object",
85327
- description: tool.description || `Tool: ${toolName}`,
85328
- ...tool.inputSchema
85329
+ description: tool$1.description || `Tool: ${toolName}`,
85330
+ ...tool$1.inputSchema
85329
85331
  };
85330
85332
  else {
85331
85333
  const toolSchema = this.server.getHiddenToolSchema(toolName);
@@ -85371,9 +85373,9 @@ var SamplingExecutor = class extends BaseSamplingExecutor {
85371
85373
  }
85372
85374
  buildSystemPrompt(userRequest, agenticSchema, context2) {
85373
85375
  const toolList = this.allToolNames.map((name) => {
85374
- const tool = this.toolNameToDetailList.find(([toolName]) => toolName === name);
85376
+ const tool$1 = this.toolNameToDetailList.find(([toolName]) => toolName === name);
85375
85377
  const toolSchema = this.server.getHiddenToolSchema(name);
85376
- if (tool && tool[1]) return `- ${name}: ${tool[1].description || `Tool: ${name}`}`;
85378
+ if (tool$1 && tool$1[1]) return `- ${name}: ${tool$1[1].description || `Tool: ${name}`}`;
85377
85379
  else if (toolSchema) return `- ${name}: ${toolSchema.description}`;
85378
85380
  return `- ${name}`;
85379
85381
  }).join("\n");
@@ -85412,7 +85414,7 @@ function registerAgenticSamplingTool(server, { description, name, allToolNames,
85412
85414
  type: "object",
85413
85415
  properties: {}
85414
85416
  };
85415
- server.tool(name, description, jsonSchema(createGoogleCompatibleJSONSchema(schema)), async (args) => {
85417
+ server.tool(name, description, jsonSchema$1(createGoogleCompatibleJSONSchema(schema)), async (args) => {
85416
85418
  return await samplingExecutor.executeSampling(args, schema);
85417
85419
  });
85418
85420
  }
@@ -85505,7 +85507,7 @@ function registerWorkflowSamplingTool(server, { description, name, allToolNames,
85505
85507
  type: "object",
85506
85508
  properties: {}
85507
85509
  };
85508
- server.tool(name, baseDescription, jsonSchema(createGoogleCompatibleJSONSchema(schema)), async (args) => {
85510
+ server.tool(name, baseDescription, jsonSchema$1(createGoogleCompatibleJSONSchema(schema)), async (args) => {
85509
85511
  try {
85510
85512
  return await workflowSamplingExecutor.executeWorkflowSampling(args, schema, workflowState);
85511
85513
  } catch (error$1) {
@@ -85760,11 +85762,11 @@ var PluginManager = class {
85760
85762
  /**
85761
85763
  * Apply transformTool hooks to a tool during composition
85762
85764
  */
85763
- async applyTransformToolHooks(tool, context2) {
85765
+ async applyTransformToolHooks(tool$1, context2) {
85764
85766
  const transformPlugins = this.plugins.filter((p2) => p2.transformTool && shouldApplyPlugin(p2, context2.mode));
85765
- if (transformPlugins.length === 0) return tool;
85767
+ if (transformPlugins.length === 0) return tool$1;
85766
85768
  const sortedPlugins = sortPluginsByOrder(transformPlugins);
85767
- let currentTool = tool;
85769
+ let currentTool = tool$1;
85768
85770
  for (const plugin of sortedPlugins) if (plugin.transformTool) try {
85769
85771
  const result = await plugin.transformTool(currentTool, context2);
85770
85772
  if (result) currentTool = result;
@@ -85957,11 +85959,11 @@ var ToolManager = class {
85957
85959
  * Get tool schema if it's hidden (for internal access)
85958
85960
  */
85959
85961
  getHiddenToolSchema(name) {
85960
- const tool = this.toolRegistry.get(name);
85962
+ const tool$1 = this.toolRegistry.get(name);
85961
85963
  const config = this.toolConfigs.get(name);
85962
- if (tool && config?.visibility?.hidden && tool.schema) return {
85963
- description: tool.description,
85964
- schema: tool.schema
85964
+ if (tool$1 && config?.visibility?.hidden && tool$1.schema) return {
85965
+ description: tool$1.description,
85966
+ schema: tool$1.schema
85965
85967
  };
85966
85968
  }
85967
85969
  /**
@@ -85988,16 +85990,16 @@ var ToolManager = class {
85988
85990
  */
85989
85991
  getRegisteredToolsAsComposed() {
85990
85992
  const composedTools = {};
85991
- for (const [name, tool] of this.toolRegistry.entries()) {
85993
+ for (const [name, tool$1] of this.toolRegistry.entries()) {
85992
85994
  if (this.toolConfigs.get(name)?.visibility?.public === true) continue;
85993
85995
  composedTools[name] = {
85994
85996
  name,
85995
- description: tool.description,
85996
- inputSchema: jsonSchema(tool.schema || {
85997
+ description: tool$1.description,
85998
+ inputSchema: jsonSchema$1(tool$1.schema || {
85997
85999
  type: "object",
85998
86000
  properties: {}
85999
86001
  }),
86000
- execute: tool.callback
86002
+ execute: tool$1.callback
86001
86003
  };
86002
86004
  }
86003
86005
  return composedTools;
@@ -86051,14 +86053,14 @@ async function processToolsWithPlugins(server, _externalTools, mode) {
86051
86053
  function buildDependencyGroups(toolNameToDetailList, hiddenToolNames, publicToolNames, server) {
86052
86054
  const depGroups = {};
86053
86055
  const toolManager = server.toolManager;
86054
- toolNameToDetailList.forEach(([toolName, tool]) => {
86056
+ toolNameToDetailList.forEach(([toolName, tool$1]) => {
86055
86057
  const resolvedName = toolManager.resolveToolName(toolName);
86056
86058
  if (hiddenToolNames.includes(resolvedName ?? "") || publicToolNames.includes(resolvedName ?? "")) return;
86057
- if (!tool) {
86059
+ if (!tool$1) {
86058
86060
  const allToolNames = [...toolNameToDetailList.map(([n$1]) => n$1)];
86059
86061
  throw new Error(`Action ${toolName} not found, available action list: ${allToolNames.join(", ")}`);
86060
86062
  }
86061
- const baseSchema = tool.inputSchema.jsonSchema ?? tool.inputSchema ?? {
86063
+ const baseSchema = tool$1.inputSchema.jsonSchema ?? tool$1.inputSchema ?? {
86062
86064
  type: "object",
86063
86065
  properties: {},
86064
86066
  required: []
@@ -86069,7 +86071,7 @@ function buildDependencyGroups(toolNameToDetailList, hiddenToolNames, publicTool
86069
86071
  const sanitizedKey = sanitizePropertyKey(toolName);
86070
86072
  depGroups[sanitizedKey] = {
86071
86073
  type: "object",
86072
- description: tool.description,
86074
+ description: tool$1.description,
86073
86075
  properties: updatedProperties,
86074
86076
  required: [...baseRequired],
86075
86077
  additionalProperties: false
@@ -86304,9 +86306,9 @@ var ComposableMCPServer = class extends __modelcontextprotocol_sdk_server_index_
86304
86306
  const requestedToolNames = /* @__PURE__ */ new Set();
86305
86307
  const availableToolNames = /* @__PURE__ */ new Set();
86306
86308
  const allPlaceholderUsages = [];
86307
- tagToResults.tool.forEach((tool) => {
86308
- if (tool.attribs.name) {
86309
- const originalName = tool.attribs.name;
86309
+ tagToResults.tool.forEach((tool$1) => {
86310
+ if (tool$1.attribs.name) {
86311
+ const originalName = tool$1.attribs.name;
86310
86312
  const toolName = sanitizePropertyKey(originalName);
86311
86313
  if (toolName.endsWith(`_${ALL_TOOLS_PLACEHOLDER2}`) || toolName === ALL_TOOLS_PLACEHOLDER2) allPlaceholderUsages.push(originalName);
86312
86314
  else requestedToolNames.add(toolName);
@@ -86325,18 +86327,18 @@ var ComposableMCPServer = class extends __modelcontextprotocol_sdk_server_index_
86325
86327
  if (actionIndex !== -1) matchingStep.actions[actionIndex] = toolId;
86326
86328
  return true;
86327
86329
  }
86328
- return tagToResults.tool.find((tool) => {
86329
- if (tool.attribs.name === `${mcpName}.${ALL_TOOLS_PLACEHOLDER2}` || tool.attribs.name === `${mcpName}`) return true;
86330
- return tool.attribs.name === toolNameWithScope || tool.attribs.name === toolId;
86330
+ return tagToResults.tool.find((tool$1) => {
86331
+ if (tool$1.attribs.name === `${mcpName}.${ALL_TOOLS_PLACEHOLDER2}` || tool$1.attribs.name === `${mcpName}`) return true;
86332
+ return tool$1.attribs.name === toolNameWithScope || tool$1.attribs.name === toolId;
86331
86333
  });
86332
86334
  });
86333
- Object.entries(tools).forEach(([toolId, tool]) => {
86334
- this.toolManager.registerTool(toolId, tool.description || "", tool.inputSchema, tool.execute);
86335
+ Object.entries(tools).forEach(([toolId, tool$1]) => {
86336
+ this.toolManager.registerTool(toolId, tool$1.description || "", tool$1.inputSchema, tool$1.execute);
86335
86337
  });
86336
86338
  const registeredTools = this.toolManager.getRegisteredToolsAsComposed();
86337
86339
  const allTools = { ...tools };
86338
- Object.entries(registeredTools).forEach(([toolName, tool]) => {
86339
- if (!allTools[toolName]) allTools[toolName] = tool;
86340
+ Object.entries(registeredTools).forEach(([toolName, tool$1]) => {
86341
+ if (!allTools[toolName]) allTools[toolName] = tool$1;
86340
86342
  availableToolNames.add(toolName);
86341
86343
  });
86342
86344
  if (allPlaceholderUsages.length > 0) {
@@ -86370,9 +86372,9 @@ var ComposableMCPServer = class extends __modelcontextprotocol_sdk_server_index_
86370
86372
  const hiddenToolNames = this.getHiddenToolNames();
86371
86373
  const contextToolNames = toolNameToDetailList.map(([name2]) => name2).filter((n$1) => !hiddenToolNames.includes(n$1));
86372
86374
  publicToolNames.forEach((toolId) => {
86373
- const tool = allTools[toolId];
86374
- if (!tool) throw new Error(`Public tool ${toolId} not found in registry, available: ${Object.keys(allTools).join(", ")}`);
86375
- this.tool(toolId, tool.description || "", jsonSchema(tool.inputSchema), tool.execute, { internal: false });
86375
+ const tool$1 = allTools[toolId];
86376
+ if (!tool$1) throw new Error(`Public tool ${toolId} not found in registry, available: ${Object.keys(allTools).join(", ")}`);
86377
+ this.tool(toolId, tool$1.description || "", jsonSchema$1(tool$1.inputSchema), tool$1.execute, { internal: false });
86376
86378
  });
86377
86379
  await this.pluginManager.triggerComposeEnd({
86378
86380
  toolName: name,
@@ -87125,6 +87127,574 @@ function setupInspectorMiddleware(middlewares, config) {
87125
87127
  });
87126
87128
  }
87127
87129
 
87130
+ //#endregion
87131
+ //#region ../../node_modules/.pnpm/@mcpc-tech+acp-ai-provider@0.1.23/node_modules/@mcpc-tech/acp-ai-provider/index.mjs
87132
+ (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
87133
+ function formatToolError(toolResult) {
87134
+ if (!toolResult || toolResult.length === 0) return "Unknown tool error";
87135
+ const parts = [];
87136
+ for (const blk of toolResult) if (blk.type === "content") {
87137
+ if (blk.content.type === "text") parts.push(blk.content.text);
87138
+ }
87139
+ return parts.join("\n");
87140
+ }
87141
+ function extractBase64Data(data$1) {
87142
+ return data$1.includes(",") ? data$1.split(",")[1] : data$1;
87143
+ }
87144
+ var ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME = "acp.acp_provider_agent_dynamic_tool";
87145
+ var providerAgentDynamicToolSchema = zod.default.object({
87146
+ toolCallId: zod.default.string().describe("The unique ID of the tool call."),
87147
+ toolName: zod.default.string().describe("The name of the tool being called."),
87148
+ args: zod.default.record(zod.default.unknown()).describe("The input arguments for the tool call.")
87149
+ });
87150
+ var ACPAISDKClient = class {
87151
+ onSessionUpdateCallback;
87152
+ onPermissionRequestCallback;
87153
+ setSessionUpdateHandler(handler) {
87154
+ this.onSessionUpdateCallback = handler;
87155
+ }
87156
+ setPermissionRequestHandler(handler) {
87157
+ this.onPermissionRequestCallback = handler;
87158
+ }
87159
+ sessionUpdate(params) {
87160
+ if (this.onSessionUpdateCallback) this.onSessionUpdateCallback(params);
87161
+ return Promise.resolve();
87162
+ }
87163
+ async requestPermission(params) {
87164
+ if (this.onPermissionRequestCallback) return await this.onPermissionRequestCallback(params);
87165
+ return { outcome: {
87166
+ outcome: "selected",
87167
+ optionId: params.options[0]?.optionId || "allow"
87168
+ } };
87169
+ }
87170
+ writeTextFile(params) {
87171
+ console.log("Write file request (not implemented):", params.path);
87172
+ throw new Error("File operations not implemented in language model client");
87173
+ }
87174
+ readTextFile(params) {
87175
+ console.log("Read file request (not implemented):", params.path);
87176
+ throw new Error("File operations not implemented in language model client");
87177
+ }
87178
+ };
87179
+ var ACPLanguageModel = class {
87180
+ specificationVersion = "v2";
87181
+ provider = "acp";
87182
+ modelId;
87183
+ supportedUrls = {};
87184
+ config;
87185
+ agentProcess = null;
87186
+ connection = null;
87187
+ sessionId = null;
87188
+ sessionResponse = null;
87189
+ client = null;
87190
+ textBlockIndex = 0;
87191
+ thinkBlockIndex = 0;
87192
+ currentTextId = null;
87193
+ currentThinkingId = null;
87194
+ toolCallsMap = /* @__PURE__ */ new Map();
87195
+ constructor(modelId, config) {
87196
+ this.modelId = modelId;
87197
+ this.config = config;
87198
+ }
87199
+ /**
87200
+ * Resets the internal state used for stream conversion.
87201
+ */
87202
+ resetStreamState() {
87203
+ this.textBlockIndex = 0;
87204
+ this.thinkBlockIndex = 0;
87205
+ this.currentTextId = null;
87206
+ this.currentThinkingId = null;
87207
+ this.toolCallsMap.clear();
87208
+ }
87209
+ /**
87210
+ * Parses a 'tool_call' notification update into a structured object.
87211
+ */
87212
+ parseToolCall(update$1) {
87213
+ if (update$1.sessionUpdate !== "tool_call") throw new Error("Invalid update type for parseToolCall");
87214
+ const toolCallId = update$1.toolCallId;
87215
+ const toolName = update$1.title || update$1.toolCallId;
87216
+ let toolInput = {};
87217
+ if (update$1.content && update$1.content.length > 0) toolInput = update$1.content;
87218
+ else if (update$1.rawInput) toolInput = update$1.rawInput;
87219
+ return {
87220
+ toolCallId,
87221
+ toolName,
87222
+ toolInput
87223
+ };
87224
+ }
87225
+ /**
87226
+ * Parses a 'tool_call_update' notification update into a structured object.
87227
+ */
87228
+ parseToolResult(update$1) {
87229
+ if (update$1.sessionUpdate !== "tool_call_update") throw new Error("Invalid update type for parseToolResult");
87230
+ const toolCallId = update$1.toolCallId;
87231
+ const toolName = update$1.title || update$1.toolCallId;
87232
+ let toolResult = null;
87233
+ if (update$1.content && update$1.content.length > 0) toolResult = update$1.content;
87234
+ else if (update$1.rawOutput) toolResult = update$1.rawOutput;
87235
+ const isError = update$1.status === "failed";
87236
+ return {
87237
+ toolCallId,
87238
+ toolName,
87239
+ toolResult,
87240
+ isError,
87241
+ status: update$1.status
87242
+ };
87243
+ }
87244
+ /**
87245
+ * Converts AI SDK prompt messages into ACP ContentBlock objects.
87246
+ * When session exists, only extracts the last user message (history is in session).
87247
+ * Prefixes text with role since ACP ContentBlock has no role field.
87248
+ */
87249
+ getPromptContent(options) {
87250
+ const messages = this.sessionId ? options.prompt.filter((m) => m.role === "user").slice(-1) : options.prompt;
87251
+ const contentBlocks = [];
87252
+ for (const msg of messages) {
87253
+ if (msg.role === "tool") continue;
87254
+ const prefix$1 = msg.role === "system" ? "System: " : msg.role === "assistant" ? "Assistant: " : "";
87255
+ if (Array.isArray(msg.content)) {
87256
+ let isFirst = true;
87257
+ for (const part of msg.content) if (part.type === "text") {
87258
+ const text$2 = isFirst ? `${prefix$1}${part.text}` : part.text;
87259
+ contentBlocks.push({
87260
+ type: "text",
87261
+ text: text$2
87262
+ });
87263
+ isFirst = false;
87264
+ } else if (part.type === "file" && typeof part.data === "string") {
87265
+ const type = part.mediaType.startsWith("image/") ? "image" : part.mediaType.startsWith("audio/") ? "audio" : null;
87266
+ if (type) contentBlocks.push({
87267
+ type,
87268
+ mimeType: part.mediaType,
87269
+ data: extractBase64Data(part.data)
87270
+ });
87271
+ }
87272
+ } else if (typeof msg.content === "string") contentBlocks.push({
87273
+ type: "text",
87274
+ text: `${prefix$1}${msg.content}`
87275
+ });
87276
+ }
87277
+ return contentBlocks;
87278
+ }
87279
+ /**
87280
+ * Ensures the ACP agent process is running and a session is established.
87281
+ */
87282
+ async ensureConnected() {
87283
+ if (this.connection && this.sessionId) return;
87284
+ const sessionCwd = this.config.session?.cwd || node_process.default.cwd();
87285
+ this.agentProcess = (0, node_child_process.spawn)(this.config.command, this.config.args ?? [], {
87286
+ stdio: [
87287
+ "pipe",
87288
+ "pipe",
87289
+ "inherit"
87290
+ ],
87291
+ env: {
87292
+ ...node_process.default.env,
87293
+ ...this.config.env
87294
+ },
87295
+ cwd: sessionCwd
87296
+ });
87297
+ const input = node_stream.Writable.toWeb(this.agentProcess.stdin);
87298
+ const output = node_stream.Readable.toWeb(this.agentProcess.stdout);
87299
+ this.client = new ACPAISDKClient();
87300
+ this.connection = new __agentclientprotocol_sdk.ClientSideConnection(() => this.client, (0, __agentclientprotocol_sdk.ndJsonStream)(input, output));
87301
+ const initConfig = {
87302
+ ...this.config.initialize ?? {},
87303
+ protocolVersion: this.config.initialize?.protocolVersion ?? __agentclientprotocol_sdk.PROTOCOL_VERSION,
87304
+ clientCapabilities: this.config.initialize?.clientCapabilities ?? {
87305
+ fs: {
87306
+ readTextFile: false,
87307
+ writeTextFile: false
87308
+ },
87309
+ terminal: false
87310
+ }
87311
+ };
87312
+ const initResult = await this.connection.initialize(initConfig);
87313
+ const validAuthMethods = initResult.authMethods?.find((a) => a.id === this.config.authMethodId)?.id;
87314
+ if (initResult.authMethods?.length ?? false) {
87315
+ if (!this.config.authMethodId || !validAuthMethods) console.log("⚠️ 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));
87316
+ if (this.config.authMethodId && validAuthMethods) await this.connection.authenticate({ methodId: this.config.authMethodId ?? initResult.authMethods?.[0].id });
87317
+ } else console.log(`\u26A0\uFE0F No authentication methods required by the ACP agent, skipping authentication step.`);
87318
+ if (this.config.existingSessionId) {
87319
+ await this.connection.loadSession({
87320
+ sessionId: this.config.existingSessionId,
87321
+ cwd: this.config.session?.cwd ?? sessionCwd,
87322
+ mcpServers: this.config.session?.mcpServers ?? []
87323
+ });
87324
+ this.sessionId = this.config.existingSessionId;
87325
+ this.sessionResponse = { sessionId: this.config.existingSessionId };
87326
+ } else {
87327
+ this.sessionResponse = await this.connection.newSession({
87328
+ ...this.config.session,
87329
+ cwd: this.config.session?.cwd ?? sessionCwd,
87330
+ mcpServers: this.config.session?.mcpServers ?? []
87331
+ });
87332
+ this.sessionId = this.sessionResponse.sessionId;
87333
+ }
87334
+ }
87335
+ /**
87336
+ * Clears connection state. Skips if persistSession is enabled.
87337
+ */
87338
+ cleanup() {
87339
+ if (this.config.persistSession) return;
87340
+ this.forceCleanup();
87341
+ }
87342
+ /**
87343
+ * Returns the current session ID.
87344
+ */
87345
+ getSessionId() {
87346
+ return this.sessionId;
87347
+ }
87348
+ /**
87349
+ * Initializes the session and returns session info (models, modes, meta).
87350
+ * Call this before prompting to discover available options.
87351
+ */
87352
+ async initSession() {
87353
+ await this.ensureConnected();
87354
+ return this.sessionResponse;
87355
+ }
87356
+ /**
87357
+ * Sets the session mode (e.g., "ask", "plan").
87358
+ */
87359
+ async setMode(modeId) {
87360
+ if (!this.connection || !this.sessionId) throw new Error("Not connected. Call preconnect() first.");
87361
+ await this.connection.setSessionMode({
87362
+ sessionId: this.sessionId,
87363
+ modeId
87364
+ });
87365
+ }
87366
+ /**
87367
+ * Sets the session model.
87368
+ */
87369
+ async setModel(modelId) {
87370
+ if (!this.connection || !this.sessionId) throw new Error("Not connected. Call preconnect() first.");
87371
+ await this.connection.setSessionModel({
87372
+ sessionId: this.sessionId,
87373
+ modelId
87374
+ });
87375
+ }
87376
+ /**
87377
+ * Forces cleanup regardless of persistSession setting.
87378
+ */
87379
+ forceCleanup() {
87380
+ if (this.agentProcess) {
87381
+ this.agentProcess.kill();
87382
+ this.agentProcess.stdin?.end();
87383
+ this.agentProcess.stdout?.destroy();
87384
+ this.agentProcess = null;
87385
+ }
87386
+ this.connection = null;
87387
+ this.sessionId = null;
87388
+ this.sessionResponse = null;
87389
+ this.client = null;
87390
+ }
87391
+ /**
87392
+ * Standardized handler for converting SessionNotifications into
87393
+ * LanguageModelV2StreamPart objects, pushing them onto a stream controller.
87394
+ */
87395
+ handleStreamNotification(controller, notification) {
87396
+ const update$1 = notification.update;
87397
+ switch (update$1.sessionUpdate) {
87398
+ case "plan":
87399
+ controller.enqueue({
87400
+ type: "raw",
87401
+ rawValue: JSON.stringify(update$1.entries)
87402
+ });
87403
+ break;
87404
+ case "agent_thought_chunk":
87405
+ if (!this.currentThinkingId) {
87406
+ this.currentThinkingId = `reasoning-${this.thinkBlockIndex++}`;
87407
+ controller.enqueue({
87408
+ type: "reasoning-start",
87409
+ id: this.currentThinkingId
87410
+ });
87411
+ }
87412
+ controller.enqueue({
87413
+ type: "reasoning-delta",
87414
+ id: this.currentThinkingId,
87415
+ delta: update$1.content.type === "text" ? update$1.content.text : ""
87416
+ });
87417
+ break;
87418
+ case "agent_message_chunk":
87419
+ if (this.currentThinkingId) {
87420
+ controller.enqueue({
87421
+ type: "reasoning-end",
87422
+ id: this.currentThinkingId
87423
+ });
87424
+ this.currentThinkingId = null;
87425
+ }
87426
+ if (update$1.content.type === "text") {
87427
+ const textChunk = update$1.content.text;
87428
+ if (!this.currentTextId) {
87429
+ this.currentTextId = `text-${this.textBlockIndex++}`;
87430
+ controller.enqueue({
87431
+ type: "text-start",
87432
+ id: this.currentTextId
87433
+ });
87434
+ }
87435
+ controller.enqueue({
87436
+ type: "text-delta",
87437
+ id: this.currentTextId,
87438
+ delta: textChunk
87439
+ });
87440
+ }
87441
+ break;
87442
+ case "tool_call": {
87443
+ if (this.currentTextId) {
87444
+ controller.enqueue({
87445
+ type: "text-end",
87446
+ id: this.currentTextId
87447
+ });
87448
+ this.currentTextId = null;
87449
+ }
87450
+ if (this.currentThinkingId) {
87451
+ controller.enqueue({
87452
+ type: "reasoning-end",
87453
+ id: this.currentThinkingId
87454
+ });
87455
+ this.currentThinkingId = null;
87456
+ }
87457
+ const { toolCallId, toolName, toolInput } = this.parseToolCall(update$1);
87458
+ controller.enqueue({
87459
+ type: "tool-call",
87460
+ toolCallId,
87461
+ toolName: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME,
87462
+ input: JSON.stringify({
87463
+ toolCallId,
87464
+ toolName,
87465
+ args: toolInput
87466
+ })
87467
+ });
87468
+ this.toolCallsMap.set(toolCallId, {
87469
+ index: this.toolCallsMap.size,
87470
+ name: toolName
87471
+ });
87472
+ break;
87473
+ }
87474
+ case "tool_call_update": {
87475
+ const { toolCallId, toolName, toolResult, isError, status } = this.parseToolResult(update$1);
87476
+ if (!["completed", "failed"].includes(status)) break;
87477
+ let toolInfo = this.toolCallsMap.get(toolCallId);
87478
+ if (!toolInfo) {
87479
+ toolInfo = {
87480
+ index: this.toolCallsMap.size,
87481
+ name: toolName
87482
+ };
87483
+ this.toolCallsMap.set(toolCallId, toolInfo);
87484
+ controller.enqueue({
87485
+ type: "tool-call",
87486
+ toolCallId,
87487
+ toolName: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME,
87488
+ input: JSON.stringify({
87489
+ toolCallId,
87490
+ toolName
87491
+ })
87492
+ });
87493
+ }
87494
+ controller.enqueue({
87495
+ type: "tool-result",
87496
+ toolCallId,
87497
+ toolName: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME,
87498
+ result: toolResult,
87499
+ providerExecuted: true,
87500
+ ...isError && {
87501
+ isError: true,
87502
+ result: new Error(formatToolError(toolResult))
87503
+ }
87504
+ });
87505
+ break;
87506
+ }
87507
+ }
87508
+ }
87509
+ /**
87510
+ * Implements the non-streaming generation method.
87511
+ */
87512
+ async doGenerate(options) {
87513
+ try {
87514
+ await this.ensureConnected();
87515
+ const promptContent = this.getPromptContent(options);
87516
+ let accumulatedText = "";
87517
+ const toolCalls = [];
87518
+ const toolResults = /* @__PURE__ */ new Map();
87519
+ const mockController = { enqueue: (part) => {
87520
+ switch (part.type) {
87521
+ case "text-delta":
87522
+ accumulatedText += part.delta;
87523
+ break;
87524
+ case "tool-call": {
87525
+ const inputData = JSON.parse(part.input);
87526
+ toolCalls.push({
87527
+ id: part.toolCallId,
87528
+ name: inputData.toolName,
87529
+ input: inputData.args
87530
+ });
87531
+ break;
87532
+ }
87533
+ case "tool-result": {
87534
+ const matchingToolCall = toolCalls.find((tc) => tc.id === part.toolCallId);
87535
+ toolResults.set(part.toolCallId, {
87536
+ name: matchingToolCall?.name || matchingToolCall?.id,
87537
+ result: part.result,
87538
+ isError: part.isError
87539
+ });
87540
+ break;
87541
+ }
87542
+ default: break;
87543
+ }
87544
+ } };
87545
+ const streamHandler = this.handleStreamNotification.bind(this);
87546
+ this.resetStreamState();
87547
+ if (this.client) this.client.setSessionUpdateHandler((notification) => {
87548
+ streamHandler(mockController, notification);
87549
+ });
87550
+ const response = await this.connection.prompt({
87551
+ sessionId: this.sessionId,
87552
+ prompt: promptContent
87553
+ });
87554
+ const content = [];
87555
+ if (accumulatedText.trim()) content.push({
87556
+ type: "text",
87557
+ text: accumulatedText
87558
+ });
87559
+ for (const toolCall of toolCalls) content.push({
87560
+ type: "tool-call",
87561
+ toolCallId: toolCall.id,
87562
+ toolName: toolCall.name,
87563
+ args: JSON.stringify(toolCall.input),
87564
+ input: toolCall.input,
87565
+ output: toolResults.get(toolCall.id)?.result
87566
+ });
87567
+ const result = {
87568
+ content,
87569
+ finishReason: response.stopReason === "end_turn" ? "stop" : "other",
87570
+ usage: {
87571
+ inputTokens: 0,
87572
+ outputTokens: 0,
87573
+ totalTokens: 0
87574
+ },
87575
+ warnings: []
87576
+ };
87577
+ this.cleanup();
87578
+ return result;
87579
+ } catch (error$1) {
87580
+ this.cleanup();
87581
+ throw error$1;
87582
+ }
87583
+ }
87584
+ /**
87585
+ * Implements the streaming generation method.
87586
+ */
87587
+ async doStream(options) {
87588
+ await this.ensureConnected();
87589
+ const promptContent = this.getPromptContent(options);
87590
+ const connection = this.connection;
87591
+ const sessionId = this.sessionId;
87592
+ const client = this.client;
87593
+ const cleanup = () => this.cleanup();
87594
+ const streamHandler = this.handleStreamNotification.bind(this);
87595
+ return {
87596
+ stream: new ReadableStream({
87597
+ start: async (controller) => {
87598
+ controller.enqueue({
87599
+ type: "stream-start",
87600
+ warnings: []
87601
+ });
87602
+ this.resetStreamState();
87603
+ try {
87604
+ if (client) client.setSessionUpdateHandler((notification) => {
87605
+ streamHandler(controller, notification);
87606
+ });
87607
+ const response = await connection.prompt({
87608
+ sessionId,
87609
+ prompt: promptContent
87610
+ });
87611
+ controller.enqueue({
87612
+ type: "finish",
87613
+ finishReason: response.stopReason === "end_turn" ? "stop" : "other",
87614
+ usage: {
87615
+ inputTokens: 0,
87616
+ outputTokens: 0,
87617
+ totalTokens: 0
87618
+ }
87619
+ });
87620
+ controller.close();
87621
+ cleanup();
87622
+ } catch (error$1) {
87623
+ cleanup();
87624
+ controller.enqueue({
87625
+ type: "error",
87626
+ error: error$1
87627
+ });
87628
+ }
87629
+ },
87630
+ cancel: () => {
87631
+ cleanup();
87632
+ }
87633
+ }),
87634
+ warnings: []
87635
+ };
87636
+ }
87637
+ /**
87638
+ * Defines the provider agent dynamic tool used to bridge ACP's agent-side tool calls
87639
+ * with the AI SDK's tool execution flow.
87640
+ */
87641
+ get tools() {
87642
+ return { [ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME]: (0, ai.tool)({
87643
+ name: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME,
87644
+ type: "provider-defined",
87645
+ inputSchema: (0, ai.jsonSchema)({}),
87646
+ id: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME,
87647
+ args: (0, ai.jsonSchema)({})
87648
+ }) };
87649
+ }
87650
+ };
87651
+ var ACPProvider = class {
87652
+ config;
87653
+ model = null;
87654
+ constructor(config) {
87655
+ this.config = config;
87656
+ }
87657
+ /**
87658
+ * Create a language model instance for a specific ACP agent
87659
+ *
87660
+ * @returns A LanguageModelV2 instance
87661
+ */
87662
+ languageModel() {
87663
+ const model = new ACPLanguageModel("acp-agent", this.config);
87664
+ this.model = model;
87665
+ return model;
87666
+ }
87667
+ /**
87668
+ * Shorthand for creating a language model
87669
+ */
87670
+ call() {
87671
+ return this.languageModel();
87672
+ }
87673
+ /**
87674
+ * Provider tools
87675
+ */
87676
+ get tools() {
87677
+ return this.model?.tools;
87678
+ }
87679
+ /**
87680
+ * Returns the current session ID if one is active.
87681
+ * Useful when `persistSession` is enabled and you need to reference the session later.
87682
+ */
87683
+ getSessionId() {
87684
+ return this.model?.getSessionId() ?? null;
87685
+ }
87686
+ /**
87687
+ * Forces cleanup of the connection and session.
87688
+ * Call this when you're done with the provider instance, especially when using `persistSession`.
87689
+ */
87690
+ cleanup() {
87691
+ this.model?.forceCleanup();
87692
+ }
87693
+ };
87694
+ function createACPProvider(config) {
87695
+ return new ACPProvider(config);
87696
+ }
87697
+
87128
87698
  //#endregion
87129
87699
  //#region src/utils/resolve-bin.ts
87130
87700
  /**
@@ -87187,7 +87757,7 @@ function setupAcpMiddleware(middlewares, serverContext) {
87187
87757
  const { messages, agent, envVars } = JSON.parse(body);
87188
87758
  const cwd$1 = process.cwd();
87189
87759
  const mcpRemote = resolveMcpRemote(cwd$1);
87190
- const provider = (0, __mcpc_tech_acp_ai_provider.createACPProvider)({
87760
+ const provider = createACPProvider({
87191
87761
  command: agent.command,
87192
87762
  args: agent.args,
87193
87763
  env: envVars,