@mcpc-tech/unplugin-dev-inspector-mcp 0.0.37 → 0.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/dist/inspector.iife.js +358 -416
- package/dist/config-updater.cjs +76 -12
- package/dist/config-updater.js +72 -8
- package/dist/index.d.cts +21 -4
- package/dist/index.d.ts +21 -4
- package/package.json +1 -1
package/dist/config-updater.cjs
CHANGED
|
@@ -21,6 +21,7 @@ let _modelcontextprotocol_sdk_inMemory_js = require("@modelcontextprotocol/sdk/i
|
|
|
21
21
|
let node_process = require("node:process");
|
|
22
22
|
node_process = require_chunk.__toESM(node_process);
|
|
23
23
|
let os = require("os");
|
|
24
|
+
let child_process = require("child_process");
|
|
24
25
|
let fs = require("fs");
|
|
25
26
|
fs = require_chunk.__toESM(fs);
|
|
26
27
|
let http = require("http");
|
|
@@ -58015,9 +58016,9 @@ var require_utils$5 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =>
|
|
|
58015
58016
|
var require_execAsync$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
58016
58017
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58017
58018
|
exports.execAsync = void 0;
|
|
58018
|
-
const child_process$
|
|
58019
|
+
const child_process$2 = require("child_process");
|
|
58019
58020
|
const util$1 = require("util");
|
|
58020
|
-
exports.execAsync = util$1.promisify(child_process$
|
|
58021
|
+
exports.execAsync = util$1.promisify(child_process$2.exec);
|
|
58021
58022
|
}));
|
|
58022
58023
|
|
|
58023
58024
|
//#endregion
|
|
@@ -66167,9 +66168,9 @@ var require_utils$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =>
|
|
|
66167
66168
|
var require_execAsync = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
66168
66169
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66169
66170
|
exports.execAsync = void 0;
|
|
66170
|
-
const child_process = require("child_process");
|
|
66171
|
+
const child_process$1 = require("child_process");
|
|
66171
66172
|
const util = require("util");
|
|
66172
|
-
exports.execAsync = util.promisify(child_process.exec);
|
|
66173
|
+
exports.execAsync = util.promisify(child_process$1.exec);
|
|
66173
66174
|
}));
|
|
66174
66175
|
|
|
66175
66176
|
//#endregion
|
|
@@ -86816,6 +86817,7 @@ var ConnectionManager = class {
|
|
|
86816
86817
|
transport.onclose = () => this.removeTransport(sessionId);
|
|
86817
86818
|
}
|
|
86818
86819
|
removeTransport(sessionId) {
|
|
86820
|
+
console.log(`[dev-inspector] [connection-manager] Removing transport: ${sessionId}`);
|
|
86819
86821
|
delete this.transports[sessionId];
|
|
86820
86822
|
for (const [_clientId, sessionIds] of this.watchersByClientId) if (sessionIds.has(sessionId)) {
|
|
86821
86823
|
sessionIds.delete(sessionId);
|
|
@@ -86846,6 +86848,7 @@ var ConnectionManager = class {
|
|
|
86846
86848
|
}
|
|
86847
86849
|
sessionsToRemove.push(existingSessionId);
|
|
86848
86850
|
}
|
|
86851
|
+
if (sessionsToRemove.length > 0) console.log(`[dev-inspector] [connection-manager] Cleaned up ${sessionsToRemove.length} previous sessions for clientId=${clientId} (new session=${newSessionId})`);
|
|
86849
86852
|
for (const sessionId of sessionsToRemove) sessionIds.delete(sessionId);
|
|
86850
86853
|
}
|
|
86851
86854
|
handleInspectorConnection(sessionId) {
|
|
@@ -87056,11 +87059,17 @@ async function handleSseConnection(req, res, serverContext, connectionManager) {
|
|
|
87056
87059
|
const url$1 = new URL(req.url ?? "", `http://${host}:${port}`);
|
|
87057
87060
|
const transport = new _modelcontextprotocol_sdk_server_sse_js.SSEServerTransport("/__mcp__/messages", res);
|
|
87058
87061
|
const sessionId = transport.sessionId;
|
|
87059
|
-
const clientId = url$1.searchParams.get("clientId") ||
|
|
87062
|
+
const clientId = url$1.searchParams.get("clientId") || `agent-${sessionId}`;
|
|
87060
87063
|
const puppetId = url$1.searchParams.get("puppetId") || "inspector";
|
|
87064
|
+
console.log(`[dev-inspector] [sse] New connection request: clientId=${clientId}, puppetId=${puppetId}, sessionId=${sessionId}`);
|
|
87061
87065
|
connectionManager.registerTransport(sessionId, transport);
|
|
87062
|
-
if (clientId === "inspector")
|
|
87063
|
-
|
|
87066
|
+
if (clientId === "inspector") {
|
|
87067
|
+
console.log(`[dev-inspector] [sse] Handling Inspector connection: ${sessionId}`);
|
|
87068
|
+
connectionManager.handleInspectorConnection(sessionId);
|
|
87069
|
+
} else {
|
|
87070
|
+
console.log(`[dev-inspector] [sse] Handling Watcher connection: ${sessionId} (binding to ${puppetId})`);
|
|
87071
|
+
connectionManager.handleWatcherConnection(sessionId, clientId, puppetId, transport);
|
|
87072
|
+
}
|
|
87064
87073
|
await mcpServer.connect(transport);
|
|
87065
87074
|
} catch (error) {
|
|
87066
87075
|
console.error("Error establishing SSE connection:", error);
|
|
@@ -88074,6 +88083,7 @@ var ACPLanguageModel = class {
|
|
|
88074
88083
|
try {
|
|
88075
88084
|
await this.ensureConnected();
|
|
88076
88085
|
const promptContent = convertAiSdkMessagesToAcp(options, this.isFreshSession);
|
|
88086
|
+
console.log(`###########`, promptContent);
|
|
88077
88087
|
this.isFreshSession = false;
|
|
88078
88088
|
let accumulatedText = "";
|
|
88079
88089
|
const toolCalls = [];
|
|
@@ -88283,6 +88293,19 @@ function createACPProvider(config) {
|
|
|
88283
88293
|
//#endregion
|
|
88284
88294
|
//#region src/middleware/acp-middleware.ts
|
|
88285
88295
|
/**
|
|
88296
|
+
* Check if a command exists in the system PATH
|
|
88297
|
+
* Skips check for npx since it always exists
|
|
88298
|
+
*/
|
|
88299
|
+
function checkCommandExists(command) {
|
|
88300
|
+
if (command === "npx" || command === "node") return true;
|
|
88301
|
+
try {
|
|
88302
|
+
(0, child_process.execSync)(`which ${command}`, { stdio: "ignore" });
|
|
88303
|
+
return true;
|
|
88304
|
+
} catch {
|
|
88305
|
+
return false;
|
|
88306
|
+
}
|
|
88307
|
+
}
|
|
88308
|
+
/**
|
|
88286
88309
|
* Provider manager - stores one provider per agent config
|
|
88287
88310
|
* Key: agentKey (command:args), Value: ProviderEntry
|
|
88288
88311
|
*/
|
|
@@ -88346,12 +88369,33 @@ async function loadMcpToolsV5(transport) {
|
|
|
88346
88369
|
return tools;
|
|
88347
88370
|
}
|
|
88348
88371
|
/**
|
|
88349
|
-
*
|
|
88372
|
+
* Default system instructions for DevInspector - provides AI guidance
|
|
88373
|
+
*/
|
|
88374
|
+
const DEFAULT_SYSTEM_INSTRUCTIONS = `# DevInspector Context
|
|
88375
|
+
|
|
88376
|
+
You are connected to a web app with DevInspector. Available tools:
|
|
88377
|
+
|
|
88378
|
+
- **list_inspections**: Check pending element inspections from user
|
|
88379
|
+
- **capture_element_context**: Activate visual selector to capture UI elements
|
|
88380
|
+
- **update_inspection_status**: Update inspection status with progress/results
|
|
88381
|
+
- **execute_page_script**: Run JavaScript in browser context
|
|
88382
|
+
- **chrome_devtools**: Access Chrome DevTools for network, console, performance
|
|
88383
|
+
|
|
88384
|
+
Workflow: Check \`list_inspections\` first. If there are pending items, help resolve them. Otherwise, assist with the user's request.`;
|
|
88385
|
+
/**
|
|
88386
|
+
* Get an active transport from the connection manager
|
|
88350
88387
|
*/
|
|
88351
88388
|
function getActiveTransport() {
|
|
88352
88389
|
const connectionManager = getConnectionManager();
|
|
88353
88390
|
if (!connectionManager) return null;
|
|
88354
|
-
return connectionManager.getInspectorTransport();
|
|
88391
|
+
return connectionManager.getInspectorTransport() || connectionManager.transports[Object.keys(connectionManager.transports)[0]];
|
|
88392
|
+
}
|
|
88393
|
+
/**
|
|
88394
|
+
* Get specifically the inspector transport for context and tools
|
|
88395
|
+
*/
|
|
88396
|
+
function getInspectorTransport() {
|
|
88397
|
+
const connectionManager = getConnectionManager();
|
|
88398
|
+
return connectionManager ? connectionManager.getInspectorTransport() : null;
|
|
88355
88399
|
}
|
|
88356
88400
|
function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
88357
88401
|
/**
|
|
@@ -88398,6 +88442,14 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
88398
88442
|
console.log(`[dev-inspector] [acp] Reusing existing provider for ${agent.name}`);
|
|
88399
88443
|
provider = providerEntry.provider;
|
|
88400
88444
|
} else {
|
|
88445
|
+
if (!checkCommandExists(agent.command)) {
|
|
88446
|
+
const hints = [`Agent "${agent.name}" command not found: "${agent.command}"`];
|
|
88447
|
+
if (agent.installCommand) hints.push(`Install with: ${agent.installCommand}`);
|
|
88448
|
+
if (agent.configHint) hints.push(agent.configHint);
|
|
88449
|
+
if (agent.configLink) hints.push(`Documentation: ${agent.configLink}`);
|
|
88450
|
+
console.error(`\n${hints.join("\n")}\n`);
|
|
88451
|
+
return;
|
|
88452
|
+
}
|
|
88401
88453
|
console.log(`[dev-inspector] [acp] Creating new global provider for ${agent.name}`);
|
|
88402
88454
|
provider = createACPProvider({
|
|
88403
88455
|
command: agent.command,
|
|
@@ -88424,7 +88476,7 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
88424
88476
|
}
|
|
88425
88477
|
console.log(`[dev-inspector] [acp] Spawning new process/session for ${agent.name}`);
|
|
88426
88478
|
const initPromise = (async () => {
|
|
88427
|
-
const transport = getActiveTransport();
|
|
88479
|
+
const transport = getInspectorTransport() || getActiveTransport();
|
|
88428
88480
|
let initialTools = {};
|
|
88429
88481
|
if (transport) try {
|
|
88430
88482
|
const rawTools = await loadMcpToolsV5(transport);
|
|
@@ -88456,6 +88508,7 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
88456
88508
|
res.setHeader("Content-Type", "application/json");
|
|
88457
88509
|
res.end(JSON.stringify({ sessionId }));
|
|
88458
88510
|
} catch (error) {
|
|
88511
|
+
if (error instanceof Error && error.message.includes("command not found")) throw error;
|
|
88459
88512
|
console.error("ACP Init Session Error:", error);
|
|
88460
88513
|
if (!res.headersSent) {
|
|
88461
88514
|
res.statusCode = 500;
|
|
@@ -88550,7 +88603,7 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
88550
88603
|
});
|
|
88551
88604
|
await provider.initSession();
|
|
88552
88605
|
}
|
|
88553
|
-
const transport = getActiveTransport();
|
|
88606
|
+
const transport = getInspectorTransport() || getActiveTransport();
|
|
88554
88607
|
let mcpTools = {};
|
|
88555
88608
|
if (transport) mcpTools = await loadMcpToolsV5(transport);
|
|
88556
88609
|
else console.warn("[dev-inspector] [acp] No active MCP transport available, tools will not be loaded");
|
|
@@ -88567,10 +88620,21 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
88567
88620
|
abortController.abort();
|
|
88568
88621
|
if (shouldCleanupProvider) provider.cleanup();
|
|
88569
88622
|
});
|
|
88623
|
+
const systemPrompt = agent.acpSystemPrompt ?? acpOptions?.acpSystemPrompt ?? DEFAULT_SYSTEM_INSTRUCTIONS;
|
|
88624
|
+
const enhancedMessages = (0, ai.convertToModelMessages)(messages).map((msg, index$1) => {
|
|
88625
|
+
if (index$1 === 0 && msg.role === "user" && Array.isArray(msg.content)) return {
|
|
88626
|
+
...msg,
|
|
88627
|
+
content: [{
|
|
88628
|
+
type: "text",
|
|
88629
|
+
text: `<system_instructions>\n${systemPrompt}\n</system_instructions>\n\n`
|
|
88630
|
+
}, ...msg.content]
|
|
88631
|
+
};
|
|
88632
|
+
return msg;
|
|
88633
|
+
});
|
|
88570
88634
|
const response = (0, ai.streamText)({
|
|
88571
88635
|
model: provider.languageModel(model, mode),
|
|
88572
88636
|
includeRawChunks: true,
|
|
88573
|
-
messages:
|
|
88637
|
+
messages: enhancedMessages,
|
|
88574
88638
|
abortSignal: abortController.signal,
|
|
88575
88639
|
tools: acpTools(mcpTools),
|
|
88576
88640
|
onError: (error) => {
|
package/dist/config-updater.js
CHANGED
|
@@ -17,6 +17,7 @@ import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/
|
|
|
17
17
|
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
|
|
18
18
|
import process$1, { cwd } from "node:process";
|
|
19
19
|
import { homedir } from "os";
|
|
20
|
+
import { execSync } from "child_process";
|
|
20
21
|
import fs, { existsSync } from "fs";
|
|
21
22
|
import * as http from "http";
|
|
22
23
|
import * as https from "https";
|
|
@@ -86851,6 +86852,7 @@ var ConnectionManager = class {
|
|
|
86851
86852
|
transport.onclose = () => this.removeTransport(sessionId);
|
|
86852
86853
|
}
|
|
86853
86854
|
removeTransport(sessionId) {
|
|
86855
|
+
console.log(`[dev-inspector] [connection-manager] Removing transport: ${sessionId}`);
|
|
86854
86856
|
delete this.transports[sessionId];
|
|
86855
86857
|
for (const [_clientId, sessionIds] of this.watchersByClientId) if (sessionIds.has(sessionId)) {
|
|
86856
86858
|
sessionIds.delete(sessionId);
|
|
@@ -86881,6 +86883,7 @@ var ConnectionManager = class {
|
|
|
86881
86883
|
}
|
|
86882
86884
|
sessionsToRemove.push(existingSessionId);
|
|
86883
86885
|
}
|
|
86886
|
+
if (sessionsToRemove.length > 0) console.log(`[dev-inspector] [connection-manager] Cleaned up ${sessionsToRemove.length} previous sessions for clientId=${clientId} (new session=${newSessionId})`);
|
|
86884
86887
|
for (const sessionId of sessionsToRemove) sessionIds.delete(sessionId);
|
|
86885
86888
|
}
|
|
86886
86889
|
handleInspectorConnection(sessionId) {
|
|
@@ -87091,11 +87094,17 @@ async function handleSseConnection(req, res, serverContext, connectionManager) {
|
|
|
87091
87094
|
const url = new URL(req.url ?? "", `http://${host}:${port}`);
|
|
87092
87095
|
const transport = new SSEServerTransport("/__mcp__/messages", res);
|
|
87093
87096
|
const sessionId = transport.sessionId;
|
|
87094
|
-
const clientId = url.searchParams.get("clientId") ||
|
|
87097
|
+
const clientId = url.searchParams.get("clientId") || `agent-${sessionId}`;
|
|
87095
87098
|
const puppetId = url.searchParams.get("puppetId") || "inspector";
|
|
87099
|
+
console.log(`[dev-inspector] [sse] New connection request: clientId=${clientId}, puppetId=${puppetId}, sessionId=${sessionId}`);
|
|
87096
87100
|
connectionManager.registerTransport(sessionId, transport);
|
|
87097
|
-
if (clientId === "inspector")
|
|
87098
|
-
|
|
87101
|
+
if (clientId === "inspector") {
|
|
87102
|
+
console.log(`[dev-inspector] [sse] Handling Inspector connection: ${sessionId}`);
|
|
87103
|
+
connectionManager.handleInspectorConnection(sessionId);
|
|
87104
|
+
} else {
|
|
87105
|
+
console.log(`[dev-inspector] [sse] Handling Watcher connection: ${sessionId} (binding to ${puppetId})`);
|
|
87106
|
+
connectionManager.handleWatcherConnection(sessionId, clientId, puppetId, transport);
|
|
87107
|
+
}
|
|
87099
87108
|
await mcpServer.connect(transport);
|
|
87100
87109
|
} catch (error) {
|
|
87101
87110
|
console.error("Error establishing SSE connection:", error);
|
|
@@ -88109,6 +88118,7 @@ var ACPLanguageModel = class {
|
|
|
88109
88118
|
try {
|
|
88110
88119
|
await this.ensureConnected();
|
|
88111
88120
|
const promptContent = convertAiSdkMessagesToAcp(options, this.isFreshSession);
|
|
88121
|
+
console.log(`###########`, promptContent);
|
|
88112
88122
|
this.isFreshSession = false;
|
|
88113
88123
|
let accumulatedText = "";
|
|
88114
88124
|
const toolCalls = [];
|
|
@@ -88318,6 +88328,19 @@ function createACPProvider(config) {
|
|
|
88318
88328
|
//#endregion
|
|
88319
88329
|
//#region src/middleware/acp-middleware.ts
|
|
88320
88330
|
/**
|
|
88331
|
+
* Check if a command exists in the system PATH
|
|
88332
|
+
* Skips check for npx since it always exists
|
|
88333
|
+
*/
|
|
88334
|
+
function checkCommandExists(command) {
|
|
88335
|
+
if (command === "npx" || command === "node") return true;
|
|
88336
|
+
try {
|
|
88337
|
+
execSync(`which ${command}`, { stdio: "ignore" });
|
|
88338
|
+
return true;
|
|
88339
|
+
} catch {
|
|
88340
|
+
return false;
|
|
88341
|
+
}
|
|
88342
|
+
}
|
|
88343
|
+
/**
|
|
88321
88344
|
* Provider manager - stores one provider per agent config
|
|
88322
88345
|
* Key: agentKey (command:args), Value: ProviderEntry
|
|
88323
88346
|
*/
|
|
@@ -88381,12 +88404,33 @@ async function loadMcpToolsV5(transport) {
|
|
|
88381
88404
|
return tools;
|
|
88382
88405
|
}
|
|
88383
88406
|
/**
|
|
88384
|
-
*
|
|
88407
|
+
* Default system instructions for DevInspector - provides AI guidance
|
|
88408
|
+
*/
|
|
88409
|
+
const DEFAULT_SYSTEM_INSTRUCTIONS = `# DevInspector Context
|
|
88410
|
+
|
|
88411
|
+
You are connected to a web app with DevInspector. Available tools:
|
|
88412
|
+
|
|
88413
|
+
- **list_inspections**: Check pending element inspections from user
|
|
88414
|
+
- **capture_element_context**: Activate visual selector to capture UI elements
|
|
88415
|
+
- **update_inspection_status**: Update inspection status with progress/results
|
|
88416
|
+
- **execute_page_script**: Run JavaScript in browser context
|
|
88417
|
+
- **chrome_devtools**: Access Chrome DevTools for network, console, performance
|
|
88418
|
+
|
|
88419
|
+
Workflow: Check \`list_inspections\` first. If there are pending items, help resolve them. Otherwise, assist with the user's request.`;
|
|
88420
|
+
/**
|
|
88421
|
+
* Get an active transport from the connection manager
|
|
88385
88422
|
*/
|
|
88386
88423
|
function getActiveTransport() {
|
|
88387
88424
|
const connectionManager = getConnectionManager();
|
|
88388
88425
|
if (!connectionManager) return null;
|
|
88389
|
-
return connectionManager.getInspectorTransport();
|
|
88426
|
+
return connectionManager.getInspectorTransport() || connectionManager.transports[Object.keys(connectionManager.transports)[0]];
|
|
88427
|
+
}
|
|
88428
|
+
/**
|
|
88429
|
+
* Get specifically the inspector transport for context and tools
|
|
88430
|
+
*/
|
|
88431
|
+
function getInspectorTransport() {
|
|
88432
|
+
const connectionManager = getConnectionManager();
|
|
88433
|
+
return connectionManager ? connectionManager.getInspectorTransport() : null;
|
|
88390
88434
|
}
|
|
88391
88435
|
function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
88392
88436
|
/**
|
|
@@ -88433,6 +88477,14 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
88433
88477
|
console.log(`[dev-inspector] [acp] Reusing existing provider for ${agent.name}`);
|
|
88434
88478
|
provider = providerEntry.provider;
|
|
88435
88479
|
} else {
|
|
88480
|
+
if (!checkCommandExists(agent.command)) {
|
|
88481
|
+
const hints = [`Agent "${agent.name}" command not found: "${agent.command}"`];
|
|
88482
|
+
if (agent.installCommand) hints.push(`Install with: ${agent.installCommand}`);
|
|
88483
|
+
if (agent.configHint) hints.push(agent.configHint);
|
|
88484
|
+
if (agent.configLink) hints.push(`Documentation: ${agent.configLink}`);
|
|
88485
|
+
console.error(`\n${hints.join("\n")}\n`);
|
|
88486
|
+
return;
|
|
88487
|
+
}
|
|
88436
88488
|
console.log(`[dev-inspector] [acp] Creating new global provider for ${agent.name}`);
|
|
88437
88489
|
provider = createACPProvider({
|
|
88438
88490
|
command: agent.command,
|
|
@@ -88459,7 +88511,7 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
88459
88511
|
}
|
|
88460
88512
|
console.log(`[dev-inspector] [acp] Spawning new process/session for ${agent.name}`);
|
|
88461
88513
|
const initPromise = (async () => {
|
|
88462
|
-
const transport = getActiveTransport();
|
|
88514
|
+
const transport = getInspectorTransport() || getActiveTransport();
|
|
88463
88515
|
let initialTools = {};
|
|
88464
88516
|
if (transport) try {
|
|
88465
88517
|
const rawTools = await loadMcpToolsV5(transport);
|
|
@@ -88491,6 +88543,7 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
88491
88543
|
res.setHeader("Content-Type", "application/json");
|
|
88492
88544
|
res.end(JSON.stringify({ sessionId }));
|
|
88493
88545
|
} catch (error) {
|
|
88546
|
+
if (error instanceof Error && error.message.includes("command not found")) throw error;
|
|
88494
88547
|
console.error("ACP Init Session Error:", error);
|
|
88495
88548
|
if (!res.headersSent) {
|
|
88496
88549
|
res.statusCode = 500;
|
|
@@ -88585,7 +88638,7 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
88585
88638
|
});
|
|
88586
88639
|
await provider.initSession();
|
|
88587
88640
|
}
|
|
88588
|
-
const transport = getActiveTransport();
|
|
88641
|
+
const transport = getInspectorTransport() || getActiveTransport();
|
|
88589
88642
|
let mcpTools = {};
|
|
88590
88643
|
if (transport) mcpTools = await loadMcpToolsV5(transport);
|
|
88591
88644
|
else console.warn("[dev-inspector] [acp] No active MCP transport available, tools will not be loaded");
|
|
@@ -88602,10 +88655,21 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
88602
88655
|
abortController.abort();
|
|
88603
88656
|
if (shouldCleanupProvider) provider.cleanup();
|
|
88604
88657
|
});
|
|
88658
|
+
const systemPrompt = agent.acpSystemPrompt ?? acpOptions?.acpSystemPrompt ?? DEFAULT_SYSTEM_INSTRUCTIONS;
|
|
88659
|
+
const enhancedMessages = convertToModelMessages(messages).map((msg, index$1) => {
|
|
88660
|
+
if (index$1 === 0 && msg.role === "user" && Array.isArray(msg.content)) return {
|
|
88661
|
+
...msg,
|
|
88662
|
+
content: [{
|
|
88663
|
+
type: "text",
|
|
88664
|
+
text: `<system_instructions>\n${systemPrompt}\n</system_instructions>\n\n`
|
|
88665
|
+
}, ...msg.content]
|
|
88666
|
+
};
|
|
88667
|
+
return msg;
|
|
88668
|
+
});
|
|
88605
88669
|
const response = streamText({
|
|
88606
88670
|
model: provider.languageModel(model, mode),
|
|
88607
88671
|
includeRawChunks: true,
|
|
88608
|
-
messages:
|
|
88672
|
+
messages: enhancedMessages,
|
|
88609
88673
|
abortSignal: abortController.signal,
|
|
88610
88674
|
tools: acpTools(mcpTools),
|
|
88611
88675
|
onError: (error) => {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
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";
|
|
@@ -52,6 +52,11 @@ interface AcpOptions {
|
|
|
52
52
|
* @default undefined (skipped if not specified)
|
|
53
53
|
*/
|
|
54
54
|
acpDelay?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Custom system instructions to prepend to user messages
|
|
57
|
+
* @default undefined (uses built-in DevInspector context)
|
|
58
|
+
*/
|
|
59
|
+
acpSystemPrompt?: string;
|
|
55
60
|
}
|
|
56
61
|
interface Agent extends AcpOptions {
|
|
57
62
|
name: string;
|
|
@@ -65,6 +70,18 @@ interface Agent extends AcpOptions {
|
|
|
65
70
|
meta?: {
|
|
66
71
|
icon?: string;
|
|
67
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* Configuration hint text to help users set up the agent
|
|
75
|
+
*/
|
|
76
|
+
configHint?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Link to configuration documentation or setup guide
|
|
79
|
+
*/
|
|
80
|
+
configLink?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Installation command for the agent (shown in error messages)
|
|
83
|
+
*/
|
|
84
|
+
installCommand?: string;
|
|
68
85
|
}
|
|
69
86
|
//#endregion
|
|
70
87
|
//#region src/utils/create-plugin.d.ts
|
|
@@ -134,10 +151,10 @@ interface DevInspectorOptions extends McpConfigOptions, AcpOptions {
|
|
|
134
151
|
}
|
|
135
152
|
//#endregion
|
|
136
153
|
//#region src/core.d.ts
|
|
137
|
-
declare const unplugin:
|
|
154
|
+
declare const unplugin: unplugin0.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
|
|
138
155
|
//#endregion
|
|
139
156
|
//#region src/core-external.d.ts
|
|
140
|
-
declare const unpluginExternal:
|
|
157
|
+
declare const unpluginExternal: unplugin0.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
|
|
141
158
|
//#endregion
|
|
142
159
|
//#region src/turbopack.d.ts
|
|
143
160
|
interface TurbopackDevInspectorOptions extends DevInspectorOptions {
|
|
@@ -162,7 +179,7 @@ interface TurbopackDevInspectorOptions extends DevInspectorOptions {
|
|
|
162
179
|
declare function turbopackDevInspector(options?: TurbopackDevInspectorOptions): any;
|
|
163
180
|
//#endregion
|
|
164
181
|
//#region src/index.d.ts
|
|
165
|
-
declare const external:
|
|
182
|
+
declare const external: unplugin0.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
|
|
166
183
|
declare module "virtual:dev-inspector-mcp" {}
|
|
167
184
|
//#endregion
|
|
168
185
|
export { type CustomEditorConfig, type DevInspectorOptions, type EditorId, type McpConfigOptions, type TurbopackDevInspectorOptions, unplugin as default, unplugin, external, turbopackDevInspector, unpluginExternal };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as unplugin1 from "unplugin";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/config-updater.d.ts
|
|
4
4
|
type EditorId = "cursor" | "vscode" | "windsurf" | "claude-code" | "antigravity";
|
|
@@ -52,6 +52,11 @@ interface AcpOptions {
|
|
|
52
52
|
* @default undefined (skipped if not specified)
|
|
53
53
|
*/
|
|
54
54
|
acpDelay?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Custom system instructions to prepend to user messages
|
|
57
|
+
* @default undefined (uses built-in DevInspector context)
|
|
58
|
+
*/
|
|
59
|
+
acpSystemPrompt?: string;
|
|
55
60
|
}
|
|
56
61
|
interface Agent extends AcpOptions {
|
|
57
62
|
name: string;
|
|
@@ -65,6 +70,18 @@ interface Agent extends AcpOptions {
|
|
|
65
70
|
meta?: {
|
|
66
71
|
icon?: string;
|
|
67
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* Configuration hint text to help users set up the agent
|
|
75
|
+
*/
|
|
76
|
+
configHint?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Link to configuration documentation or setup guide
|
|
79
|
+
*/
|
|
80
|
+
configLink?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Installation command for the agent (shown in error messages)
|
|
83
|
+
*/
|
|
84
|
+
installCommand?: string;
|
|
68
85
|
}
|
|
69
86
|
//#endregion
|
|
70
87
|
//#region src/utils/create-plugin.d.ts
|
|
@@ -134,10 +151,10 @@ interface DevInspectorOptions extends McpConfigOptions, AcpOptions {
|
|
|
134
151
|
}
|
|
135
152
|
//#endregion
|
|
136
153
|
//#region src/core.d.ts
|
|
137
|
-
declare const unplugin:
|
|
154
|
+
declare const unplugin: unplugin1.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
|
|
138
155
|
//#endregion
|
|
139
156
|
//#region src/core-external.d.ts
|
|
140
|
-
declare const unpluginExternal:
|
|
157
|
+
declare const unpluginExternal: unplugin1.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
|
|
141
158
|
//#endregion
|
|
142
159
|
//#region src/turbopack.d.ts
|
|
143
160
|
interface TurbopackDevInspectorOptions extends DevInspectorOptions {
|
|
@@ -162,7 +179,7 @@ interface TurbopackDevInspectorOptions extends DevInspectorOptions {
|
|
|
162
179
|
declare function turbopackDevInspector(options?: TurbopackDevInspectorOptions): any;
|
|
163
180
|
//#endregion
|
|
164
181
|
//#region src/index.d.ts
|
|
165
|
-
declare const external:
|
|
182
|
+
declare const external: unplugin1.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
|
|
166
183
|
declare module "virtual:dev-inspector-mcp" {}
|
|
167
184
|
//#endregion
|
|
168
185
|
export { type CustomEditorConfig, type DevInspectorOptions, type EditorId, type McpConfigOptions, type TurbopackDevInspectorOptions, unplugin as default, unplugin, external, turbopackDevInspector, unpluginExternal };
|
package/package.json
CHANGED