@mcpc-tech/unplugin-dev-inspector-mcp 0.0.33 → 0.0.35
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/README.md +1 -1
- package/client/dist/inspector.iife.js +241 -238
- package/dist/config-updater.cjs +242 -39
- package/dist/config-updater.js +243 -40
- package/dist/index.cjs +26 -19
- package/dist/index.js +26 -19
- package/package.json +6 -6
package/dist/config-updater.js
CHANGED
|
@@ -24,7 +24,7 @@ import * as zlib from "zlib";
|
|
|
24
24
|
import { fileURLToPath } from "node:url";
|
|
25
25
|
import path$1, { dirname, join } from "path";
|
|
26
26
|
import { fileURLToPath as fileURLToPath$1 } from "url";
|
|
27
|
-
import { convertToModelMessages, jsonSchema, streamText, tool } from "ai";
|
|
27
|
+
import { asSchema, convertToModelMessages, jsonSchema, streamText, tool } from "ai";
|
|
28
28
|
import { ClientSideConnection, PROTOCOL_VERSION, ndJsonStream, planEntrySchema } from "@agentclientprotocol/sdk";
|
|
29
29
|
import { spawn } from "node:child_process";
|
|
30
30
|
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
@@ -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.
|
|
87264
|
+
//#region ../../node_modules/.pnpm/@mcpc-tech+acp-ai-provider@0.1.41/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";
|
|
@@ -87418,8 +87418,13 @@ var ToolProxyHost = class {
|
|
|
87418
87418
|
* Start TCP server and return MCP server config for ACP
|
|
87419
87419
|
*/
|
|
87420
87420
|
async start() {
|
|
87421
|
-
if (this.server)
|
|
87422
|
-
|
|
87421
|
+
if (!this.server) await this.startServer();
|
|
87422
|
+
return this.getServerConfig();
|
|
87423
|
+
}
|
|
87424
|
+
/**
|
|
87425
|
+
* Get MCP server configuration
|
|
87426
|
+
*/
|
|
87427
|
+
getServerConfig() {
|
|
87423
87428
|
return {
|
|
87424
87429
|
name: this.serverName,
|
|
87425
87430
|
command: "node",
|
|
@@ -87499,8 +87504,10 @@ var ToolProxyHost = class {
|
|
|
87499
87504
|
text: typeof result === "string" ? result : JSON.stringify(result)
|
|
87500
87505
|
}] };
|
|
87501
87506
|
this.sendResponse(socket, createResponse(request.id, toolResult));
|
|
87502
|
-
} else if (request.method === "getTools")
|
|
87503
|
-
|
|
87507
|
+
} else if (request.method === "getTools") {
|
|
87508
|
+
const definitions = this.getToolDefinitions();
|
|
87509
|
+
this.sendResponse(socket, createResponse(request.id, definitions));
|
|
87510
|
+
} else this.sendResponse(socket, createErrorResponse(request.id, JsonRpcErrorCode.METHOD_NOT_FOUND, `Unknown method: ${request.method}`));
|
|
87504
87511
|
} catch (error) {
|
|
87505
87512
|
this.sendResponse(socket, createErrorResponse(request.id, JsonRpcErrorCode.INTERNAL_ERROR, error instanceof Error ? error.message : String(error)));
|
|
87506
87513
|
}
|
|
@@ -87600,16 +87607,22 @@ function convertAiSdkMessagesToAcp(options, isFreshSession) {
|
|
|
87600
87607
|
}
|
|
87601
87608
|
return contentBlocks;
|
|
87602
87609
|
}
|
|
87603
|
-
function extractACPTools(tools) {
|
|
87610
|
+
function extractACPTools(tools, prepared = true) {
|
|
87604
87611
|
const acpTools2 = [];
|
|
87605
87612
|
if (!tools) return acpTools2;
|
|
87606
|
-
|
|
87613
|
+
const toolsArray = Array.isArray(tools) ? tools : Object.entries(tools).map(([name, tool2]) => ({
|
|
87614
|
+
type: "function",
|
|
87615
|
+
name,
|
|
87616
|
+
...tool2
|
|
87617
|
+
}));
|
|
87618
|
+
for (const t of toolsArray) if (t.type === "function") {
|
|
87607
87619
|
const toolInputSchema = t.inputSchema;
|
|
87608
87620
|
if (hasRegisteredExecute(t.name) && toolInputSchema) {
|
|
87609
87621
|
const execute = getExecuteByName(t.name);
|
|
87610
87622
|
if (execute) acpTools2.push({
|
|
87611
87623
|
...t,
|
|
87612
87624
|
name: t.name,
|
|
87625
|
+
inputSchema: prepared ? toolInputSchema : asSchema(toolInputSchema).jsonSchema,
|
|
87613
87626
|
execute
|
|
87614
87627
|
});
|
|
87615
87628
|
}
|
|
@@ -87642,12 +87655,10 @@ var ACPAISDKClient = class {
|
|
|
87642
87655
|
optionId: params.options[0]?.optionId || "allow"
|
|
87643
87656
|
} };
|
|
87644
87657
|
}
|
|
87645
|
-
writeTextFile(
|
|
87646
|
-
console.log("[acp-ai-provider] Write file request (not implemented):", params.path);
|
|
87658
|
+
writeTextFile(_params) {
|
|
87647
87659
|
throw new Error("File operations not implemented in language model client");
|
|
87648
87660
|
}
|
|
87649
|
-
readTextFile(
|
|
87650
|
-
console.log("[acp-ai-provider] Read file request (not implemented):", params.path);
|
|
87661
|
+
readTextFile(_params) {
|
|
87651
87662
|
throw new Error("File operations not implemented in language model client");
|
|
87652
87663
|
}
|
|
87653
87664
|
};
|
|
@@ -87693,6 +87704,7 @@ var ACPLanguageModel = class {
|
|
|
87693
87704
|
*/
|
|
87694
87705
|
parseToolCall(update$1) {
|
|
87695
87706
|
if (update$1.sessionUpdate !== "tool_call") throw new Error("Invalid update type for parseToolCall");
|
|
87707
|
+
console.log("Parsing tool call update:", JSON.stringify(update$1, null, 2));
|
|
87696
87708
|
return {
|
|
87697
87709
|
toolCallId: update$1.toolCallId,
|
|
87698
87710
|
toolName: update$1.title || update$1.toolCallId,
|
|
@@ -87765,7 +87777,7 @@ var ACPLanguageModel = class {
|
|
|
87765
87777
|
if (initResult.authMethods?.length ?? false) {
|
|
87766
87778
|
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));
|
|
87767
87779
|
if (this.config.authMethodId && validAuthMethods) await this.connection.authenticate({ methodId: this.config.authMethodId ?? initResult.authMethods?.[0].id });
|
|
87768
|
-
}
|
|
87780
|
+
}
|
|
87769
87781
|
}
|
|
87770
87782
|
/**
|
|
87771
87783
|
* Starts a new session or updates the existing one.
|
|
@@ -87773,19 +87785,19 @@ var ACPLanguageModel = class {
|
|
|
87773
87785
|
*/
|
|
87774
87786
|
async startSession(acpTools2) {
|
|
87775
87787
|
if (!this.connection) throw new Error("Not connected");
|
|
87776
|
-
console.log(`[acp-ai-provider] startSession called with ${acpTools2?.length ?? 0} tools`);
|
|
87777
87788
|
const mcpServers = [...this.config.session?.mcpServers ?? []];
|
|
87778
87789
|
let toolsAdded = false;
|
|
87779
87790
|
if (acpTools2 && acpTools2.length > 0 && !this.toolProxyHost) {
|
|
87780
|
-
console.log("[acp-ai-provider] Setting up tool proxy for client-side tools...");
|
|
87791
|
+
console.log("[acp-ai-provider] Setting up tool proxy for client-side tools...", acpTools2.map((t) => t.name));
|
|
87781
87792
|
this.toolProxyHost = new ToolProxyHost("acp-ai-sdk-tools");
|
|
87782
87793
|
for (const t of acpTools2) this.toolProxyHost.registerTool(t.name, t);
|
|
87794
|
+
toolsAdded = true;
|
|
87795
|
+
}
|
|
87796
|
+
if (this.toolProxyHost) {
|
|
87783
87797
|
const proxyConfig = await this.toolProxyHost.start();
|
|
87784
87798
|
mcpServers.push(proxyConfig);
|
|
87785
|
-
toolsAdded = true;
|
|
87786
87799
|
}
|
|
87787
87800
|
if (this.sessionId && toolsAdded) {
|
|
87788
|
-
console.log("[acp-ai-provider] Updating session to include new tools...");
|
|
87789
87801
|
this.sessionResponse = await this.connection.newSession({
|
|
87790
87802
|
...this.config.session,
|
|
87791
87803
|
cwd: this.config.session?.cwd ?? process$1.cwd(),
|
|
@@ -87830,7 +87842,7 @@ var ACPLanguageModel = class {
|
|
|
87830
87842
|
}
|
|
87831
87843
|
async applySessionDelay() {
|
|
87832
87844
|
if (this.config.sessionDelayMs) {
|
|
87833
|
-
console.log(`[acp-ai-provider] Waiting
|
|
87845
|
+
console.log(`[acp-ai-provider] Waiting ${this.config.sessionDelayMs}ms after session setup...`);
|
|
87834
87846
|
await new Promise((resolve$2) => setTimeout(resolve$2, this.config.sessionDelayMs));
|
|
87835
87847
|
}
|
|
87836
87848
|
}
|
|
@@ -87865,14 +87877,9 @@ var ACPLanguageModel = class {
|
|
|
87865
87877
|
*
|
|
87866
87878
|
* @param acpTools - Optional list of tools to register during session initialization.
|
|
87867
87879
|
*/
|
|
87868
|
-
async initSession(
|
|
87869
|
-
|
|
87870
|
-
|
|
87871
|
-
else toolsArray = Object.entries(acpTools2).map(([name, tool2]) => ({
|
|
87872
|
-
...tool2,
|
|
87873
|
-
name
|
|
87874
|
-
}));
|
|
87875
|
-
await this.ensureConnected(toolsArray);
|
|
87880
|
+
async initSession(tools) {
|
|
87881
|
+
const acpTools2 = extractACPTools(tools, false);
|
|
87882
|
+
await this.ensureConnected(acpTools2.length > 0 ? acpTools2 : void 0);
|
|
87876
87883
|
return this.sessionResponse;
|
|
87877
87884
|
}
|
|
87878
87885
|
/**
|
|
@@ -87999,6 +88006,11 @@ var ACPLanguageModel = class {
|
|
|
87999
88006
|
this.currentThinkingId = null;
|
|
88000
88007
|
}
|
|
88001
88008
|
const { toolCallId, toolName, toolInput } = this.parseToolCall(update$1);
|
|
88009
|
+
console.log(`Parsing tool call: ${JSON.stringify({
|
|
88010
|
+
toolCallId,
|
|
88011
|
+
toolName,
|
|
88012
|
+
toolInput
|
|
88013
|
+
}, null, 2)}`);
|
|
88002
88014
|
const existingToolCall = this.toolCallsMap.get(toolCallId);
|
|
88003
88015
|
const hasInput = toolInput && typeof toolInput === "object" && Object.keys(toolInput).length > 0;
|
|
88004
88016
|
if (!existingToolCall) {
|
|
@@ -88291,9 +88303,9 @@ var ACPProvider = class {
|
|
|
88291
88303
|
* Initializes the session and returns session info (models, modes, meta).
|
|
88292
88304
|
* Call this before prompting to discover available options.
|
|
88293
88305
|
*/
|
|
88294
|
-
initSession(
|
|
88306
|
+
initSession(tools) {
|
|
88295
88307
|
if (!this.model) this.languageModel();
|
|
88296
|
-
return this.model.initSession(
|
|
88308
|
+
return this.model.initSession(tools);
|
|
88297
88309
|
}
|
|
88298
88310
|
/**
|
|
88299
88311
|
* Initializes the connection to the agent process without starting a session.
|
|
@@ -88332,6 +88344,22 @@ function createACPProvider(config) {
|
|
|
88332
88344
|
//#endregion
|
|
88333
88345
|
//#region src/middleware/acp-middleware.ts
|
|
88334
88346
|
/**
|
|
88347
|
+
* Provider manager - stores one provider per agent config
|
|
88348
|
+
* Key: agentKey (command:args), Value: ProviderEntry
|
|
88349
|
+
*/
|
|
88350
|
+
const providerManager = /* @__PURE__ */ new Map();
|
|
88351
|
+
/**
|
|
88352
|
+
* Session to provider mapping for quick lookup
|
|
88353
|
+
* Key: sessionId, Value: agentKey
|
|
88354
|
+
*/
|
|
88355
|
+
const sessionToProvider = /* @__PURE__ */ new Map();
|
|
88356
|
+
/**
|
|
88357
|
+
* Generate a unique key for an agent configuration
|
|
88358
|
+
*/
|
|
88359
|
+
function getAgentKey(command, args) {
|
|
88360
|
+
return `${command}:${(args || []).join(",")}`;
|
|
88361
|
+
}
|
|
88362
|
+
/**
|
|
88335
88363
|
* Call MCP method via transport and wait for response
|
|
88336
88364
|
*/
|
|
88337
88365
|
function callMcpMethodViaTransport(transport, method, params) {
|
|
@@ -88389,6 +88417,163 @@ function getActiveTransport() {
|
|
|
88389
88417
|
return connectionManager.transports[sessionIds[0]];
|
|
88390
88418
|
}
|
|
88391
88419
|
function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
88420
|
+
/**
|
|
88421
|
+
* Initialize a session for an agent
|
|
88422
|
+
* POST /api/acp/init-session
|
|
88423
|
+
* Body: { agent, envVars }
|
|
88424
|
+
* Returns: { sessionId }
|
|
88425
|
+
*/
|
|
88426
|
+
middlewares.use("/api/acp/init-session", async (req, res) => {
|
|
88427
|
+
if (handleCors(res, req.method)) return;
|
|
88428
|
+
if (req.method !== "POST") {
|
|
88429
|
+
res.statusCode = 405;
|
|
88430
|
+
res.end("Method Not Allowed");
|
|
88431
|
+
return;
|
|
88432
|
+
}
|
|
88433
|
+
try {
|
|
88434
|
+
const body = await readBody(req);
|
|
88435
|
+
const { agent, envVars } = JSON.parse(body);
|
|
88436
|
+
const cwd$1 = process.cwd();
|
|
88437
|
+
const agentKey = getAgentKey(agent.command, agent.args);
|
|
88438
|
+
console.log(`[dev-inspector] [acp] Requesting session for agent: ${agent.name} (${agentKey})`);
|
|
88439
|
+
let providerEntry = providerManager.get(agentKey);
|
|
88440
|
+
let sessionId = "";
|
|
88441
|
+
if (providerEntry) {
|
|
88442
|
+
if (providerEntry.sessions.size > 0) {
|
|
88443
|
+
const firstSession = providerEntry.sessions.values().next().value;
|
|
88444
|
+
if (firstSession) {
|
|
88445
|
+
sessionId = firstSession.sessionId;
|
|
88446
|
+
console.log(`[dev-inspector] [acp] Reusing existing session: ${sessionId} for ${agent.name}`);
|
|
88447
|
+
}
|
|
88448
|
+
}
|
|
88449
|
+
if (!sessionId && providerEntry.initializationPromise) {
|
|
88450
|
+
console.log(`[dev-inspector] [acp] Joining pending initialization for ${agent.name}`);
|
|
88451
|
+
try {
|
|
88452
|
+
sessionId = await providerEntry.initializationPromise;
|
|
88453
|
+
} catch (e) {
|
|
88454
|
+
throw e;
|
|
88455
|
+
}
|
|
88456
|
+
}
|
|
88457
|
+
}
|
|
88458
|
+
if (!sessionId) {
|
|
88459
|
+
let provider;
|
|
88460
|
+
if (providerEntry) {
|
|
88461
|
+
console.log(`[dev-inspector] [acp] Reusing existing provider for ${agent.name}`);
|
|
88462
|
+
provider = providerEntry.provider;
|
|
88463
|
+
} else {
|
|
88464
|
+
console.log(`[dev-inspector] [acp] Creating new global provider for ${agent.name}`);
|
|
88465
|
+
provider = createACPProvider({
|
|
88466
|
+
command: agent.command,
|
|
88467
|
+
args: agent.args,
|
|
88468
|
+
env: {
|
|
88469
|
+
...process.env,
|
|
88470
|
+
...envVars
|
|
88471
|
+
},
|
|
88472
|
+
session: {
|
|
88473
|
+
cwd: cwd$1,
|
|
88474
|
+
mcpServers: []
|
|
88475
|
+
},
|
|
88476
|
+
authMethodId: agent.authMethodId,
|
|
88477
|
+
persistSession: true
|
|
88478
|
+
});
|
|
88479
|
+
providerEntry = {
|
|
88480
|
+
provider,
|
|
88481
|
+
agentKey,
|
|
88482
|
+
sessions: /* @__PURE__ */ new Map(),
|
|
88483
|
+
createdAt: Date.now(),
|
|
88484
|
+
initializationPromise: void 0
|
|
88485
|
+
};
|
|
88486
|
+
providerManager.set(agentKey, providerEntry);
|
|
88487
|
+
}
|
|
88488
|
+
console.log(`[dev-inspector] [acp] Spawning new process/session for ${agent.name}`);
|
|
88489
|
+
const initPromise = (async () => {
|
|
88490
|
+
const transport = getActiveTransport();
|
|
88491
|
+
let initialTools = {};
|
|
88492
|
+
if (transport) try {
|
|
88493
|
+
const rawTools = await loadMcpToolsV5(transport);
|
|
88494
|
+
initialTools = acpTools(rawTools);
|
|
88495
|
+
console.log(`[dev-inspector] [acp] Pre-loading ${Object.keys(rawTools).length} tools for session init`);
|
|
88496
|
+
} catch (e) {
|
|
88497
|
+
console.warn("[dev-inspector] [acp] Failed to pre-load tools:", e);
|
|
88498
|
+
}
|
|
88499
|
+
const sid = (await provider.initSession(initialTools)).sessionId || `session-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
88500
|
+
if (providerEntry) {
|
|
88501
|
+
providerEntry.sessions.set(sid, {
|
|
88502
|
+
sessionId: sid,
|
|
88503
|
+
createdAt: Date.now()
|
|
88504
|
+
});
|
|
88505
|
+
providerEntry.initializationPromise = void 0;
|
|
88506
|
+
}
|
|
88507
|
+
sessionToProvider.set(sid, agentKey);
|
|
88508
|
+
return sid;
|
|
88509
|
+
})();
|
|
88510
|
+
if (providerEntry) providerEntry.initializationPromise = initPromise;
|
|
88511
|
+
try {
|
|
88512
|
+
sessionId = await initPromise;
|
|
88513
|
+
console.log(`[dev-inspector] [acp] Session initialized: ${sessionId}`);
|
|
88514
|
+
} catch (error) {
|
|
88515
|
+
if (providerEntry) providerEntry.initializationPromise = void 0;
|
|
88516
|
+
throw error;
|
|
88517
|
+
}
|
|
88518
|
+
}
|
|
88519
|
+
res.setHeader("Content-Type", "application/json");
|
|
88520
|
+
res.end(JSON.stringify({ sessionId }));
|
|
88521
|
+
} catch (error) {
|
|
88522
|
+
console.error("ACP Init Session Error:", error);
|
|
88523
|
+
if (!res.headersSent) {
|
|
88524
|
+
res.statusCode = 500;
|
|
88525
|
+
res.end(JSON.stringify({ error: error instanceof Error ? error.message : "Internal Server Error" }));
|
|
88526
|
+
}
|
|
88527
|
+
}
|
|
88528
|
+
});
|
|
88529
|
+
/**
|
|
88530
|
+
* Cleanup a session
|
|
88531
|
+
* POST /api/acp/cleanup-session
|
|
88532
|
+
* Body: { sessionId }
|
|
88533
|
+
*/
|
|
88534
|
+
middlewares.use("/api/acp/cleanup-session", async (req, res) => {
|
|
88535
|
+
if (handleCors(res, req.method)) return;
|
|
88536
|
+
if (req.method !== "POST") {
|
|
88537
|
+
res.statusCode = 405;
|
|
88538
|
+
res.end("Method Not Allowed");
|
|
88539
|
+
return;
|
|
88540
|
+
}
|
|
88541
|
+
try {
|
|
88542
|
+
const body = await readBody(req);
|
|
88543
|
+
const { sessionId } = JSON.parse(body);
|
|
88544
|
+
const agentKey = sessionToProvider.get(sessionId);
|
|
88545
|
+
if (agentKey) {
|
|
88546
|
+
const providerEntry = providerManager.get(agentKey);
|
|
88547
|
+
if (providerEntry) {
|
|
88548
|
+
console.log(`[dev-inspector] [acp] Cleaning up session: ${sessionId} (Provider sessions left: ${providerEntry.sessions.size - 1})`);
|
|
88549
|
+
providerEntry.sessions.delete(sessionId);
|
|
88550
|
+
if (providerEntry.sessions.size === 0) {
|
|
88551
|
+
console.log(`[dev-inspector] [acp] No active sessions for ${agentKey}, cleaning up provider`);
|
|
88552
|
+
try {
|
|
88553
|
+
providerEntry.provider.cleanup();
|
|
88554
|
+
} catch (e) {
|
|
88555
|
+
console.error("Error cleaning up provider:", e);
|
|
88556
|
+
}
|
|
88557
|
+
providerManager.delete(agentKey);
|
|
88558
|
+
}
|
|
88559
|
+
}
|
|
88560
|
+
sessionToProvider.delete(sessionId);
|
|
88561
|
+
}
|
|
88562
|
+
res.setHeader("Content-Type", "application/json");
|
|
88563
|
+
res.end(JSON.stringify({ success: true }));
|
|
88564
|
+
} catch (error) {
|
|
88565
|
+
console.error("ACP Cleanup Session Error:", error);
|
|
88566
|
+
if (!res.headersSent) {
|
|
88567
|
+
res.statusCode = 500;
|
|
88568
|
+
res.end(JSON.stringify({ error: "Internal Server Error" }));
|
|
88569
|
+
}
|
|
88570
|
+
}
|
|
88571
|
+
});
|
|
88572
|
+
/**
|
|
88573
|
+
* Chat endpoint
|
|
88574
|
+
* POST /api/acp/chat
|
|
88575
|
+
* Body: { messages, agent, envVars, sessionId? }
|
|
88576
|
+
*/
|
|
88392
88577
|
middlewares.use("/api/acp/chat", async (req, res) => {
|
|
88393
88578
|
if (handleCors(res, req.method)) return;
|
|
88394
88579
|
if (req.method !== "POST") {
|
|
@@ -88398,18 +88583,36 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
88398
88583
|
}
|
|
88399
88584
|
try {
|
|
88400
88585
|
const body = await readBody(req);
|
|
88401
|
-
const { messages, agent, envVars } = JSON.parse(body);
|
|
88586
|
+
const { messages, agent, envVars, sessionId } = JSON.parse(body);
|
|
88402
88587
|
const cwd$1 = process.cwd();
|
|
88403
|
-
|
|
88404
|
-
|
|
88405
|
-
|
|
88406
|
-
|
|
88407
|
-
|
|
88408
|
-
|
|
88409
|
-
|
|
88410
|
-
|
|
88411
|
-
|
|
88412
|
-
|
|
88588
|
+
let provider;
|
|
88589
|
+
let shouldCleanupProvider = true;
|
|
88590
|
+
let existingProviderEntry;
|
|
88591
|
+
if (sessionId) {
|
|
88592
|
+
const agentKey = sessionToProvider.get(sessionId);
|
|
88593
|
+
if (agentKey) existingProviderEntry = providerManager.get(agentKey);
|
|
88594
|
+
}
|
|
88595
|
+
if (existingProviderEntry) {
|
|
88596
|
+
console.log(`[dev-inspector] [acp] Using existing global provider for session: ${sessionId}`);
|
|
88597
|
+
provider = existingProviderEntry.provider;
|
|
88598
|
+
shouldCleanupProvider = false;
|
|
88599
|
+
} else {
|
|
88600
|
+
console.log(`[dev-inspector] [acp] Creating new provider (no session found or provided)`);
|
|
88601
|
+
provider = createACPProvider({
|
|
88602
|
+
command: agent.command,
|
|
88603
|
+
args: agent.args,
|
|
88604
|
+
env: {
|
|
88605
|
+
...process.env,
|
|
88606
|
+
...envVars
|
|
88607
|
+
},
|
|
88608
|
+
session: {
|
|
88609
|
+
cwd: cwd$1,
|
|
88610
|
+
mcpServers: []
|
|
88611
|
+
},
|
|
88612
|
+
authMethodId: agent.authMethodId
|
|
88613
|
+
});
|
|
88614
|
+
await provider.initSession();
|
|
88615
|
+
}
|
|
88413
88616
|
const transport = getActiveTransport();
|
|
88414
88617
|
let mcpTools = {};
|
|
88415
88618
|
if (transport) mcpTools = await loadMcpToolsV5(transport);
|
|
@@ -88425,7 +88628,7 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
88425
88628
|
req.on("close", () => {
|
|
88426
88629
|
console.log("[dev-inspector] [acp] Client disconnected, aborting stream");
|
|
88427
88630
|
abortController.abort();
|
|
88428
|
-
provider.cleanup();
|
|
88631
|
+
if (shouldCleanupProvider) provider.cleanup();
|
|
88429
88632
|
});
|
|
88430
88633
|
const response = streamText({
|
|
88431
88634
|
model: provider.languageModel(model, mode),
|
package/dist/index.cjs
CHANGED
|
@@ -91,28 +91,35 @@ export function registerInspectorTool(tool) {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
94
|
-
//
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
// Skip if already loaded (e.g., by HTML injection)
|
|
95
|
+
if (window.__DEV_INSPECTOR_LOADED__) {
|
|
96
|
+
// Already initialized, skip
|
|
97
|
+
} else {
|
|
98
|
+
window.__DEV_INSPECTOR_LOADED__ = true;
|
|
99
|
+
|
|
100
|
+
// Create inspector element
|
|
101
|
+
const inspector = document.createElement('dev-inspector-mcp');
|
|
102
|
+
document.body.appendChild(inspector);
|
|
97
103
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
// Store dev server config globally
|
|
105
|
+
window.__DEV_INSPECTOR_CONFIG__ = {
|
|
106
|
+
host: '${resolvedHost}',
|
|
107
|
+
port: '${resolvedPort}',
|
|
108
|
+
base: '/',
|
|
109
|
+
showInspectorBar: ${options.showInspectorBar ?? true}
|
|
110
|
+
};
|
|
105
111
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
+
// Dynamically load inspector script
|
|
113
|
+
const script = document.createElement('script');
|
|
114
|
+
const config = window.__DEV_INSPECTOR_CONFIG__;
|
|
115
|
+
let baseUrl = 'http://' + config.host + ':' + config.port + config.base;
|
|
116
|
+
if (baseUrl.endsWith('/')) {
|
|
117
|
+
baseUrl = baseUrl.slice(0, -1);
|
|
118
|
+
}
|
|
119
|
+
script.src = baseUrl + '/__inspector__/inspector.iife.js';
|
|
120
|
+
script.type = 'module';
|
|
121
|
+
document.head.appendChild(script);
|
|
112
122
|
}
|
|
113
|
-
script.src = baseUrl + '/__inspector__/inspector.iife.js';
|
|
114
|
-
script.type = 'module';
|
|
115
|
-
document.head.appendChild(script);
|
|
116
123
|
}
|
|
117
124
|
`;
|
|
118
125
|
},
|
package/dist/index.js
CHANGED
|
@@ -87,28 +87,35 @@ export function registerInspectorTool(tool) {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
90
|
-
//
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
// Skip if already loaded (e.g., by HTML injection)
|
|
91
|
+
if (window.__DEV_INSPECTOR_LOADED__) {
|
|
92
|
+
// Already initialized, skip
|
|
93
|
+
} else {
|
|
94
|
+
window.__DEV_INSPECTOR_LOADED__ = true;
|
|
95
|
+
|
|
96
|
+
// Create inspector element
|
|
97
|
+
const inspector = document.createElement('dev-inspector-mcp');
|
|
98
|
+
document.body.appendChild(inspector);
|
|
93
99
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
// Store dev server config globally
|
|
101
|
+
window.__DEV_INSPECTOR_CONFIG__ = {
|
|
102
|
+
host: '${resolvedHost}',
|
|
103
|
+
port: '${resolvedPort}',
|
|
104
|
+
base: '/',
|
|
105
|
+
showInspectorBar: ${options.showInspectorBar ?? true}
|
|
106
|
+
};
|
|
101
107
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
// Dynamically load inspector script
|
|
109
|
+
const script = document.createElement('script');
|
|
110
|
+
const config = window.__DEV_INSPECTOR_CONFIG__;
|
|
111
|
+
let baseUrl = 'http://' + config.host + ':' + config.port + config.base;
|
|
112
|
+
if (baseUrl.endsWith('/')) {
|
|
113
|
+
baseUrl = baseUrl.slice(0, -1);
|
|
114
|
+
}
|
|
115
|
+
script.src = baseUrl + '/__inspector__/inspector.iife.js';
|
|
116
|
+
script.type = 'module';
|
|
117
|
+
document.head.appendChild(script);
|
|
108
118
|
}
|
|
109
|
-
script.src = baseUrl + '/__inspector__/inspector.iife.js';
|
|
110
|
-
script.type = 'module';
|
|
111
|
-
document.head.appendChild(script);
|
|
112
119
|
}
|
|
113
120
|
`;
|
|
114
121
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcpc-tech/unplugin-dev-inspector-mcp",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.35",
|
|
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.
|
|
116
|
+
"@mcpc-tech/acp-ai-provider": "^0.1.41",
|
|
117
117
|
"@mcpc-tech/cmcp": "^0.0.15",
|
|
118
118
|
"@mcpc-tech/core": "^0.3.8",
|
|
119
119
|
"@modelcontextprotocol/sdk": "^1.20.1",
|
|
@@ -141,6 +141,7 @@
|
|
|
141
141
|
"@radix-ui/react-tooltip": "^1.2.8",
|
|
142
142
|
"@radix-ui/react-use-controllable-state": "^1.2.2",
|
|
143
143
|
"@radix-ui/react-visually-hidden": "^1.2.4",
|
|
144
|
+
"@vue/compiler-sfc": "^3.5.25",
|
|
144
145
|
"@xyflow/react": "^12.9.3",
|
|
145
146
|
"ai": "^5.0.95",
|
|
146
147
|
"aria-hidden": "^1.2.6",
|
|
@@ -160,13 +161,12 @@
|
|
|
160
161
|
"shiki": "^3.15.0",
|
|
161
162
|
"sonner": "^2.0.7",
|
|
162
163
|
"streamdown": "^1.5.1",
|
|
164
|
+
"svelte": "^5.45.8",
|
|
163
165
|
"tailwind-merge": "^3.3.1",
|
|
164
166
|
"tokenlens": "^1.3.1",
|
|
165
167
|
"unplugin": "^2.3.10",
|
|
166
168
|
"use-stick-to-bottom": "^1.1.1",
|
|
167
|
-
"
|
|
168
|
-
"zod": "^3.24.1",
|
|
169
|
-
"svelte": "^5.45.8"
|
|
169
|
+
"zod": "^3.24.1"
|
|
170
170
|
},
|
|
171
171
|
"devDependencies": {
|
|
172
172
|
"@babel/types": "^7.28.5",
|
|
@@ -186,4 +186,4 @@
|
|
|
186
186
|
"publishConfig": {
|
|
187
187
|
"access": "public"
|
|
188
188
|
}
|
|
189
|
-
}
|
|
189
|
+
}
|