@mcpc-tech/unplugin-dev-inspector-mcp 0.0.24 → 0.0.27

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.
@@ -87261,7 +87261,7 @@ function setupInspectorMiddleware(middlewares, config) {
87261
87261
  }
87262
87262
 
87263
87263
  //#endregion
87264
- //#region ../../node_modules/.pnpm/@mcpc-tech+acp-ai-provider@0.1.31/node_modules/@mcpc-tech/acp-ai-provider/index.mjs
87264
+ //#region ../../node_modules/.pnpm/@mcpc-tech+acp-ai-provider@0.1.33/node_modules/@mcpc-tech/acp-ai-provider/index.mjs
87265
87265
  createRequire(import.meta.url);
87266
87266
  function formatToolError(toolResult) {
87267
87267
  if (!toolResult || toolResult.length === 0) return "Unknown tool error";
@@ -87271,9 +87271,6 @@ function formatToolError(toolResult) {
87271
87271
  }
87272
87272
  return parts.join("\n");
87273
87273
  }
87274
- function extractBase64Data(data$1) {
87275
- return data$1.includes(",") ? data$1.split(",")[1] : data$1;
87276
- }
87277
87274
  function createResponse(id, result) {
87278
87275
  return {
87279
87276
  jsonrpc: "2.0",
@@ -87551,6 +87548,65 @@ function getExecuteByName(name) {
87551
87548
  function hasRegisteredExecute(name) {
87552
87549
  return executeRegistry.has(name);
87553
87550
  }
87551
+ function extractBase64Data(data$1) {
87552
+ return data$1.includes(",") ? data$1.split(",")[1] : data$1;
87553
+ }
87554
+ function convertAiSdkMessagesToAcp(options, isFreshSession) {
87555
+ const messages = !isFreshSession ? options.prompt.filter((m) => m.role === "user").slice(-1) : options.prompt;
87556
+ const contentBlocks = [];
87557
+ for (const msg of messages) {
87558
+ let prefix = "";
87559
+ if (msg.role === "system") prefix = "System: ";
87560
+ else if (msg.role === "assistant") prefix = "Assistant: ";
87561
+ else if (msg.role === "tool") prefix = "Result: ";
87562
+ if (Array.isArray(msg.content)) {
87563
+ let isFirst = true;
87564
+ for (const part of msg.content) if (part.type === "text") {
87565
+ const text$2 = isFirst ? `${prefix}${part.text} ` : part.text;
87566
+ contentBlocks.push({
87567
+ type: "text",
87568
+ text: text$2
87569
+ });
87570
+ isFirst = false;
87571
+ } else if (part.type === "tool-result") {
87572
+ const resultText = JSON.stringify(part.result);
87573
+ const text$2 = isFirst ? `${prefix}${resultText} ` : resultText;
87574
+ contentBlocks.push({
87575
+ type: "text",
87576
+ text: text$2
87577
+ });
87578
+ isFirst = false;
87579
+ } else if (part.type === "file" && typeof part.data === "string") {
87580
+ const type = part.mediaType.startsWith("image/") ? "image" : part.mediaType.startsWith("audio/") ? "audio" : null;
87581
+ if (type) contentBlocks.push({
87582
+ type,
87583
+ mimeType: part.mediaType,
87584
+ data: extractBase64Data(part.data)
87585
+ });
87586
+ }
87587
+ } else if (typeof msg.content === "string") contentBlocks.push({
87588
+ type: "text",
87589
+ text: `${prefix}${msg.content} `
87590
+ });
87591
+ }
87592
+ return contentBlocks;
87593
+ }
87594
+ function extractACPTools(tools) {
87595
+ const acpTools2 = [];
87596
+ if (!tools) return acpTools2;
87597
+ for (const t$5 of tools) if (t$5.type === "function") {
87598
+ const toolInputSchema = t$5.inputSchema;
87599
+ if (hasRegisteredExecute(t$5.name) && toolInputSchema) {
87600
+ const execute = getExecuteByName(t$5.name);
87601
+ if (execute) acpTools2.push({
87602
+ ...t$5,
87603
+ name: t$5.name,
87604
+ execute
87605
+ });
87606
+ }
87607
+ }
87608
+ return acpTools2;
87609
+ }
87554
87610
  var ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME2 = "acp.acp_provider_agent_dynamic_tool";
87555
87611
  var providerAgentDynamicToolSchema = z$1.object({
87556
87612
  toolCallId: z$1.string().describe("The unique ID of the tool call."),
@@ -87600,6 +87656,7 @@ var ACPLanguageModel = class {
87600
87656
  client = null;
87601
87657
  currentModelId = null;
87602
87658
  currentModeId = null;
87659
+ isFreshSession = true;
87603
87660
  textBlockIndex = 0;
87604
87661
  thinkBlockIndex = 0;
87605
87662
  currentTextId = null;
@@ -87623,36 +87680,27 @@ var ACPLanguageModel = class {
87623
87680
  }
87624
87681
  /**
87625
87682
  * Parses a 'tool_call' notification update into a structured object.
87683
+ * Note: We only use rawInput for tool input (content is for UI display).
87626
87684
  */
87627
87685
  parseToolCall(update$1) {
87628
87686
  if (update$1.sessionUpdate !== "tool_call") throw new Error("Invalid update type for parseToolCall");
87629
- const toolCallId = update$1.toolCallId;
87630
- const toolName = update$1.title || update$1.toolCallId;
87631
- let toolInput = {};
87632
- if (update$1.content && update$1.content.length > 0) toolInput = update$1.content;
87633
- else if (update$1.rawInput) toolInput = update$1.rawInput;
87634
87687
  return {
87635
- toolCallId,
87636
- toolName,
87637
- toolInput
87688
+ toolCallId: update$1.toolCallId,
87689
+ toolName: update$1.title || update$1.toolCallId,
87690
+ toolInput: update$1.rawInput ?? {}
87638
87691
  };
87639
87692
  }
87640
87693
  /**
87641
87694
  * Parses a 'tool_call_update' notification update into a structured object.
87695
+ * Note: We only use rawOutput for tool result (content is for UI display).
87642
87696
  */
87643
87697
  parseToolResult(update$1) {
87644
87698
  if (update$1.sessionUpdate !== "tool_call_update") throw new Error("Invalid update type for parseToolResult");
87645
- const toolCallId = update$1.toolCallId;
87646
- const toolName = update$1.title || update$1.toolCallId;
87647
- let toolResult = null;
87648
- if (update$1.content && update$1.content.length > 0) toolResult = update$1.content;
87649
- else if (update$1.rawOutput) toolResult = update$1.rawOutput;
87650
- const isError = update$1.status === "failed";
87651
87699
  return {
87652
- toolCallId,
87653
- toolName,
87654
- toolResult,
87655
- isError,
87700
+ toolCallId: update$1.toolCallId,
87701
+ toolName: update$1.title || update$1.toolCallId,
87702
+ toolResult: update$1.rawOutput ?? null,
87703
+ isError: update$1.status === "failed",
87656
87704
  status: update$1.status
87657
87705
  };
87658
87706
  }
@@ -87661,36 +87709,6 @@ var ACPLanguageModel = class {
87661
87709
  * When session exists, only extracts the last user message (history is in session).
87662
87710
  * Prefixes text with role since ACP ContentBlock has no role field.
87663
87711
  */
87664
- getPromptContent(options) {
87665
- const messages = this.sessionId ? options.prompt.filter((m) => m.role === "user").slice(-1) : options.prompt;
87666
- const contentBlocks = [];
87667
- for (const msg of messages) {
87668
- if (msg.role === "tool") continue;
87669
- const prefix = msg.role === "system" ? "System: " : msg.role === "assistant" ? "Assistant: " : "";
87670
- if (Array.isArray(msg.content)) {
87671
- let isFirst = true;
87672
- for (const part of msg.content) if (part.type === "text") {
87673
- const text$2 = isFirst ? `${prefix}${part.text} ` : part.text;
87674
- contentBlocks.push({
87675
- type: "text",
87676
- text: text$2
87677
- });
87678
- isFirst = false;
87679
- } else if (part.type === "file" && typeof part.data === "string") {
87680
- const type = part.mediaType.startsWith("image/") ? "image" : part.mediaType.startsWith("audio/") ? "audio" : null;
87681
- if (type) contentBlocks.push({
87682
- type,
87683
- mimeType: part.mediaType,
87684
- data: extractBase64Data(part.data)
87685
- });
87686
- }
87687
- } else if (typeof msg.content === "string") contentBlocks.push({
87688
- type: "text",
87689
- text: `${prefix}${msg.content} `
87690
- });
87691
- }
87692
- return contentBlocks;
87693
- }
87694
87712
  /**
87695
87713
  * Ensures the ACP agent process is running and a session is established.
87696
87714
  * @param acpTools - Tools from streamText options to proxy
@@ -87741,30 +87759,6 @@ var ACPLanguageModel = class {
87741
87759
  } else console.log(`[acp-ai-provider] No authentication methods required by the ACP agent, skipping authentication step.`);
87742
87760
  }
87743
87761
  /**
87744
- * Prepares the list of MCP servers, including the tool proxy if needed.
87745
- */
87746
- async prepareMcpServers(acpTools2) {
87747
- const mcpServers = [...this.config.session?.mcpServers ?? []];
87748
- if (acpTools2 && acpTools2.length > 0) {
87749
- if (!this.toolProxyHost) this.toolProxyHost = new ToolProxyHost("acp-ai-sdk-tools");
87750
- for (const t$5 of acpTools2) this.toolProxyHost.registerTool(t$5.name, t$5);
87751
- if (!this.toolProxyHost) {
87752
- this.toolProxyHost = new ToolProxyHost("acp-ai-sdk-tools");
87753
- for (const t$5 of acpTools2) this.toolProxyHost.registerTool(t$5.name, t$5);
87754
- const proxyConfig = await this.toolProxyHost.start();
87755
- mcpServers.push(proxyConfig);
87756
- }
87757
- }
87758
- return mcpServers;
87759
- }
87760
- async prepareToolProxy(acpTools2, mcpServers) {
87761
- if (this.toolProxyHost) return;
87762
- this.toolProxyHost = new ToolProxyHost("acp-ai-sdk-tools");
87763
- for (const t$5 of acpTools2) this.toolProxyHost.registerTool(t$5.name, t$5);
87764
- const proxyConfig = await this.toolProxyHost.start();
87765
- mcpServers.push(proxyConfig);
87766
- }
87767
- /**
87768
87762
  * Starts a new session or updates the existing one.
87769
87763
  * Assumes connectClient() has been called.
87770
87764
  */
@@ -87789,6 +87783,7 @@ var ACPLanguageModel = class {
87789
87783
  mcpServers
87790
87784
  });
87791
87785
  this.sessionId = this.sessionResponse.sessionId;
87786
+ this.isFreshSession = true;
87792
87787
  await this.applySessionDelay();
87793
87788
  return;
87794
87789
  }
@@ -87801,6 +87796,7 @@ var ACPLanguageModel = class {
87801
87796
  });
87802
87797
  this.sessionId = this.config.existingSessionId;
87803
87798
  this.sessionResponse = { sessionId: this.config.existingSessionId };
87799
+ this.isFreshSession = false;
87804
87800
  } else {
87805
87801
  this.sessionResponse = await this.connection.newSession({
87806
87802
  ...this.config.session,
@@ -87808,6 +87804,7 @@ var ACPLanguageModel = class {
87808
87804
  mcpServers
87809
87805
  });
87810
87806
  this.sessionId = this.sessionResponse.sessionId;
87807
+ this.isFreshSession = true;
87811
87808
  }
87812
87809
  const { models, modes } = this.sessionResponse ?? {};
87813
87810
  if (models?.currentModelId) this.currentModelId = models.currentModelId;
@@ -87993,30 +87990,84 @@ var ACPLanguageModel = class {
87993
87990
  this.currentThinkingId = null;
87994
87991
  }
87995
87992
  const { toolCallId, toolName, toolInput } = this.parseToolCall(update$1);
87996
- controller.enqueue({
87997
- type: "tool-call",
87998
- toolCallId,
87999
- toolName: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME2,
88000
- input: JSON.stringify({
87993
+ const existingToolCall = this.toolCallsMap.get(toolCallId);
87994
+ const hasInput = toolInput && typeof toolInput === "object" && Object.keys(toolInput).length > 0;
87995
+ if (!existingToolCall) {
87996
+ this.toolCallsMap.set(toolCallId, {
87997
+ index: this.toolCallsMap.size,
87998
+ name: toolName,
87999
+ inputStarted: true,
88000
+ inputAvailable: !!hasInput
88001
+ });
88002
+ controller.enqueue({
88003
+ type: "tool-input-start",
88004
+ id: toolCallId,
88005
+ toolName
88006
+ });
88007
+ if (hasInput) controller.enqueue({
88008
+ type: "tool-call",
88001
88009
  toolCallId,
88002
- toolName,
88003
- args: toolInput
88004
- })
88005
- });
88006
- this.toolCallsMap.set(toolCallId, {
88007
- index: this.toolCallsMap.size,
88008
- name: toolName
88009
- });
88010
+ toolName: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME2,
88011
+ input: JSON.stringify({
88012
+ toolCallId,
88013
+ toolName,
88014
+ args: toolInput
88015
+ })
88016
+ });
88017
+ } else if (!existingToolCall.inputAvailable && hasInput) {
88018
+ existingToolCall.inputAvailable = true;
88019
+ controller.enqueue({
88020
+ type: "tool-call",
88021
+ toolCallId,
88022
+ toolName: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME2,
88023
+ input: JSON.stringify({
88024
+ toolCallId,
88025
+ toolName,
88026
+ args: toolInput
88027
+ })
88028
+ });
88029
+ }
88010
88030
  break;
88011
88031
  }
88012
88032
  case "tool_call_update": {
88013
88033
  const { toolCallId, toolName, toolResult, isError, status } = this.parseToolResult(update$1);
88014
- if (!["completed", "failed"].includes(status)) break;
88015
88034
  let toolInfo = this.toolCallsMap.get(toolCallId);
88035
+ if (status === "in_progress") {
88036
+ if (!toolInfo) {
88037
+ toolInfo = {
88038
+ index: this.toolCallsMap.size,
88039
+ name: toolName,
88040
+ inputStarted: true,
88041
+ inputAvailable: true
88042
+ };
88043
+ this.toolCallsMap.set(toolCallId, toolInfo);
88044
+ controller.enqueue({
88045
+ type: "tool-input-start",
88046
+ id: toolCallId,
88047
+ toolName
88048
+ });
88049
+ }
88050
+ if (!toolInfo.inputAvailable) {
88051
+ toolInfo.inputAvailable = true;
88052
+ controller.enqueue({
88053
+ type: "tool-call",
88054
+ toolCallId,
88055
+ toolName: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME2,
88056
+ input: JSON.stringify({
88057
+ toolCallId,
88058
+ toolName,
88059
+ args: {}
88060
+ })
88061
+ });
88062
+ }
88063
+ break;
88064
+ }
88065
+ if (!["completed", "failed"].includes(status)) break;
88016
88066
  if (!toolInfo) {
88017
88067
  toolInfo = {
88018
88068
  index: this.toolCallsMap.size,
88019
- name: toolName
88069
+ name: toolName,
88070
+ inputAvailable: true
88020
88071
  };
88021
88072
  this.toolCallsMap.set(toolCallId, toolInfo);
88022
88073
  controller.enqueue({
@@ -88028,6 +88079,18 @@ var ACPLanguageModel = class {
88028
88079
  toolName
88029
88080
  })
88030
88081
  });
88082
+ } else if (!toolInfo.inputAvailable) {
88083
+ toolInfo.inputAvailable = true;
88084
+ controller.enqueue({
88085
+ type: "tool-call",
88086
+ toolCallId,
88087
+ toolName: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME2,
88088
+ input: JSON.stringify({
88089
+ toolCallId,
88090
+ toolName,
88091
+ args: {}
88092
+ })
88093
+ });
88031
88094
  }
88032
88095
  controller.enqueue({
88033
88096
  type: "tool-result",
@@ -88050,7 +88113,8 @@ var ACPLanguageModel = class {
88050
88113
  async doGenerate(options) {
88051
88114
  try {
88052
88115
  await this.ensureConnected();
88053
- const promptContent = this.getPromptContent(options);
88116
+ const promptContent = convertAiSdkMessagesToAcp(options, this.isFreshSession);
88117
+ this.isFreshSession = false;
88054
88118
  let accumulatedText = "";
88055
88119
  const toolCalls = [];
88056
88120
  const toolResults = /* @__PURE__ */ new Map();
@@ -88123,22 +88187,10 @@ var ACPLanguageModel = class {
88123
88187
  * Implements the streaming generation method.
88124
88188
  */
88125
88189
  async doStream(options) {
88126
- const acpTools2 = [];
88127
- if (options.tools) {
88128
- for (const t$5 of options.tools) if (t$5.type === "function") {
88129
- const toolInputSchema = t$5.inputSchema;
88130
- if (hasRegisteredExecute(t$5.name) && toolInputSchema) {
88131
- const execute = getExecuteByName(t$5.name);
88132
- if (execute) acpTools2.push({
88133
- ...t$5,
88134
- name: t$5.name,
88135
- execute
88136
- });
88137
- }
88138
- }
88139
- }
88190
+ const acpTools2 = extractACPTools(options.tools);
88140
88191
  await this.ensureConnected(acpTools2.length > 0 ? acpTools2 : void 0);
88141
- const promptContent = this.getPromptContent(options);
88192
+ const promptContent = convertAiSdkMessagesToAcp(options, this.isFreshSession);
88193
+ this.isFreshSession = false;
88142
88194
  const connection = this.connection;
88143
88195
  const sessionId = this.sessionId;
88144
88196
  const client = this.client;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as unplugin1 from "unplugin";
1
+ import * as unplugin0 from "unplugin";
2
2
 
3
3
  //#region src/utils/config-updater.d.ts
4
4
  type EditorId = "cursor" | "vscode" | "windsurf" | "claude-code" | "antigravity";
@@ -134,10 +134,10 @@ interface DevInspectorOptions extends McpConfigOptions, AcpOptions {
134
134
  }
135
135
  //#endregion
136
136
  //#region src/core.d.ts
137
- declare const unplugin: unplugin1.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
137
+ declare const unplugin: unplugin0.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
138
138
  //#endregion
139
139
  //#region src/core-external.d.ts
140
- declare const unpluginExternal: unplugin1.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
140
+ declare const unpluginExternal: unplugin0.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
141
141
  //#endregion
142
142
  //#region src/turbopack.d.ts
143
143
  interface TurbopackDevInspectorOptions extends DevInspectorOptions {
@@ -162,7 +162,7 @@ interface TurbopackDevInspectorOptions extends DevInspectorOptions {
162
162
  declare function turbopackDevInspector(options?: TurbopackDevInspectorOptions): any;
163
163
  //#endregion
164
164
  //#region src/index.d.ts
165
- declare const external: unplugin1.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
165
+ declare const external: unplugin0.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
166
166
  declare module "virtual:dev-inspector-mcp" {}
167
167
  //#endregion
168
168
  export { type CustomEditorConfig, type DevInspectorOptions, type EditorId, type McpConfigOptions, type TurbopackDevInspectorOptions, unplugin as default, unplugin, external, turbopackDevInspector, unpluginExternal };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpc-tech/unplugin-dev-inspector-mcp",
3
- "version": "0.0.24",
3
+ "version": "0.0.27",
4
4
  "description": "Universal dev inspector plugin for React/Vue - inspect component sources and API calls in any bundler",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -113,7 +113,7 @@
113
113
  "@babel/parser": "^7.28.5",
114
114
  "@babel/traverse": "^7.28.5",
115
115
  "@code-inspector/core": "^1.3.0",
116
- "@mcpc-tech/acp-ai-provider": "^0.1.31",
116
+ "@mcpc-tech/acp-ai-provider": "^0.1.33",
117
117
  "@mcpc-tech/cmcp": "^0.0.15",
118
118
  "@mcpc-tech/core": "^0.3.8",
119
119
  "@modelcontextprotocol/sdk": "^1.20.1",