vite-plugin-aipanel 1.2.0-beta.0
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 +72 -0
- package/es/client/vue-devtools-bridge.d.ts +58 -0
- package/es/client/vue-devtools-bridge.mjs +150 -0
- package/es/core/injector.d.ts +2 -0
- package/es/core/injector.mjs +15 -0
- package/es/core/mcp-chrome.d.ts +56 -0
- package/es/core/mcp-chrome.mjs +133 -0
- package/es/core/mcp-proxy.d.ts +23 -0
- package/es/core/mcp-proxy.mjs +212 -0
- package/es/core/mcp-tools.d.ts +15 -0
- package/es/core/mcp-tools.mjs +671 -0
- package/es/core/provider-loader.d.ts +19 -0
- package/es/core/provider-loader.mjs +30 -0
- package/es/core/proxy-server.d.ts +12 -0
- package/es/core/proxy-server.mjs +148 -0
- package/es/core/service.d.ts +39 -0
- package/es/core/service.mjs +267 -0
- package/es/endpoints/context.d.ts +3 -0
- package/es/endpoints/context.mjs +106 -0
- package/es/endpoints/index.d.ts +9 -0
- package/es/endpoints/index.mjs +30 -0
- package/es/endpoints/logs.d.ts +9 -0
- package/es/endpoints/logs.mjs +86 -0
- package/es/endpoints/mcp.d.ts +6 -0
- package/es/endpoints/mcp.mjs +610 -0
- package/es/endpoints/sessions.d.ts +3 -0
- package/es/endpoints/sessions.mjs +62 -0
- package/es/endpoints/sse.d.ts +3 -0
- package/es/endpoints/sse.mjs +44 -0
- package/es/endpoints/start.d.ts +3 -0
- package/es/endpoints/start.mjs +21 -0
- package/es/endpoints/types.d.ts +34 -0
- package/es/endpoints/types.mjs +0 -0
- package/es/endpoints/vue-devtools.d.ts +9 -0
- package/es/endpoints/vue-devtools.mjs +107 -0
- package/es/endpoints/warmup.d.ts +3 -0
- package/es/endpoints/warmup.mjs +42 -0
- package/es/endpoints/widget.d.ts +3 -0
- package/es/endpoints/widget.mjs +36 -0
- package/es/env.d.ts +1 -0
- package/es/index.d.ts +22 -0
- package/es/index.mjs +342 -0
- package/es/utils/format-bridge.d.ts +9 -0
- package/es/utils/format-bridge.mjs +80 -0
- package/es/utils/paths.d.ts +3 -0
- package/es/utils/paths.mjs +45 -0
- package/es/utils/system.d.ts +3 -0
- package/es/utils/system.mjs +76 -0
- package/lib/client/vue-devtools-bridge.cjs +150 -0
- package/lib/client/vue-devtools-bridge.d.ts +58 -0
- package/lib/client.css +2 -0
- package/lib/client.js +6950 -0
- package/lib/core/injector.cjs +34 -0
- package/lib/core/injector.d.ts +2 -0
- package/lib/core/mcp-chrome.cjs +161 -0
- package/lib/core/mcp-chrome.d.ts +56 -0
- package/lib/core/mcp-proxy.cjs +244 -0
- package/lib/core/mcp-proxy.d.ts +23 -0
- package/lib/core/mcp-tools.cjs +694 -0
- package/lib/core/mcp-tools.d.ts +15 -0
- package/lib/core/provider-loader.cjs +53 -0
- package/lib/core/provider-loader.d.ts +19 -0
- package/lib/core/proxy-server.cjs +181 -0
- package/lib/core/proxy-server.d.ts +12 -0
- package/lib/core/service.cjs +289 -0
- package/lib/core/service.d.ts +39 -0
- package/lib/endpoints/context.cjs +129 -0
- package/lib/endpoints/context.d.ts +3 -0
- package/lib/endpoints/index.cjs +58 -0
- package/lib/endpoints/index.d.ts +9 -0
- package/lib/endpoints/logs.cjs +107 -0
- package/lib/endpoints/logs.d.ts +9 -0
- package/lib/endpoints/mcp.cjs +624 -0
- package/lib/endpoints/mcp.d.ts +6 -0
- package/lib/endpoints/sessions.cjs +85 -0
- package/lib/endpoints/sessions.d.ts +3 -0
- package/lib/endpoints/sse.cjs +67 -0
- package/lib/endpoints/sse.d.ts +3 -0
- package/lib/endpoints/start.cjs +44 -0
- package/lib/endpoints/start.d.ts +3 -0
- package/lib/endpoints/types.cjs +15 -0
- package/lib/endpoints/types.d.ts +34 -0
- package/lib/endpoints/vue-devtools.cjs +132 -0
- package/lib/endpoints/vue-devtools.d.ts +9 -0
- package/lib/endpoints/warmup.cjs +65 -0
- package/lib/endpoints/warmup.d.ts +3 -0
- package/lib/endpoints/widget.cjs +69 -0
- package/lib/endpoints/widget.d.ts +3 -0
- package/lib/env.d.ts +1 -0
- package/lib/index.cjs +361 -0
- package/lib/index.d.ts +22 -0
- package/lib/utils/format-bridge.cjs +102 -0
- package/lib/utils/format-bridge.d.ts +9 -0
- package/lib/utils/paths.cjs +80 -0
- package/lib/utils/paths.d.ts +3 -0
- package/lib/utils/system.cjs +110 -0
- package/lib/utils/system.d.ts +3 -0
- package/package.json +68 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var context_exports = {};
|
|
19
|
+
__export(context_exports, {
|
|
20
|
+
setupContextEndpoint: () => setupContextEndpoint
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(context_exports);
|
|
23
|
+
var import_core = require("@aipanel/core");
|
|
24
|
+
var import_node = require("@aipanel/core/node");
|
|
25
|
+
const log = (0, import_node.createLogger)("Endpoints:Context");
|
|
26
|
+
function setupContextEndpoint(server, ctx) {
|
|
27
|
+
server.middlewares.use(import_core.CONTEXT_API_PATH, async (req, res) => {
|
|
28
|
+
const reqCtx = new import_node.RequestContext(req.method || "GET", import_core.CONTEXT_API_PATH);
|
|
29
|
+
res.setHeader("Content-Type", "application/json");
|
|
30
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
31
|
+
res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
|
|
32
|
+
res.setHeader("Access-Control-Allow-Headers", "Content-Type");
|
|
33
|
+
if (req.method === "OPTIONS") {
|
|
34
|
+
res.writeHead(200);
|
|
35
|
+
res.end();
|
|
36
|
+
reqCtx.end(200);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (req.method === "GET") {
|
|
40
|
+
const pc = ctx.getPageContext();
|
|
41
|
+
res.writeHead(200);
|
|
42
|
+
res.end(JSON.stringify(pc));
|
|
43
|
+
reqCtx.end(200);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (req.method === "DELETE") {
|
|
47
|
+
ctx.clearSelectedElements();
|
|
48
|
+
log.debug("Selected elements cleared", { sseClients: ctx.sseClients.size });
|
|
49
|
+
let sentCount = 0;
|
|
50
|
+
ctx.sseClients.forEach((client) => {
|
|
51
|
+
try {
|
|
52
|
+
client.write(`data: ${JSON.stringify({ type: "CLEAR_ELEMENTS" })}
|
|
53
|
+
|
|
54
|
+
`);
|
|
55
|
+
sentCount++;
|
|
56
|
+
} catch (e) {
|
|
57
|
+
log.debug("Failed to send SSE message", { error: e });
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
log.debug("SSE messages sent", {
|
|
61
|
+
count: sentCount,
|
|
62
|
+
totalClients: ctx.sseClients.size
|
|
63
|
+
});
|
|
64
|
+
res.writeHead(200);
|
|
65
|
+
res.end(JSON.stringify({ success: true }));
|
|
66
|
+
reqCtx.end(200);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (req.method === "POST") {
|
|
70
|
+
let body = "";
|
|
71
|
+
req.on("data", (chunk) => body += chunk.toString());
|
|
72
|
+
req.on("error", () => {
|
|
73
|
+
res.writeHead(400);
|
|
74
|
+
res.end(JSON.stringify({ error: "Request error" }));
|
|
75
|
+
});
|
|
76
|
+
req.on("end", () => {
|
|
77
|
+
try {
|
|
78
|
+
const data = JSON.parse(body);
|
|
79
|
+
const tabId = data.tabId != null ? String(data.tabId) : "default";
|
|
80
|
+
const existing = ctx.getPageContext();
|
|
81
|
+
const newCtx = {
|
|
82
|
+
url: data.url || "",
|
|
83
|
+
title: data.title || "",
|
|
84
|
+
sessionId: data.sessionId,
|
|
85
|
+
tabId: data.tabId ?? existing.tabId,
|
|
86
|
+
tabIndex: data.tabIndex ?? existing.tabIndex,
|
|
87
|
+
selectedElements: data.selectedElements || []
|
|
88
|
+
};
|
|
89
|
+
ctx.setPageContext(tabId, newCtx);
|
|
90
|
+
if (data.active) {
|
|
91
|
+
ctx.setActiveTabId(tabId);
|
|
92
|
+
}
|
|
93
|
+
log.debug("Context updated", {
|
|
94
|
+
tabId,
|
|
95
|
+
url: newCtx.url,
|
|
96
|
+
title: newCtx.title,
|
|
97
|
+
sessionId: newCtx.sessionId,
|
|
98
|
+
selectedElementsCount: newCtx.selectedElements?.length || 0
|
|
99
|
+
});
|
|
100
|
+
if (newCtx.selectedElements && newCtx.selectedElements.length > 0) {
|
|
101
|
+
log.debug("Selected elements details", {
|
|
102
|
+
elements: newCtx.selectedElements.map((el) => ({
|
|
103
|
+
filePath: el.filePath,
|
|
104
|
+
line: el.line,
|
|
105
|
+
text: el.innerText?.substring(0, 50)
|
|
106
|
+
}))
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
res.writeHead(200);
|
|
110
|
+
res.end(JSON.stringify({ success: true }));
|
|
111
|
+
reqCtx.end(200);
|
|
112
|
+
} catch (e) {
|
|
113
|
+
log.debug("Invalid JSON in request body", { error: e });
|
|
114
|
+
res.writeHead(400);
|
|
115
|
+
res.end(JSON.stringify({ error: "Invalid JSON" }));
|
|
116
|
+
reqCtx.error(e);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
res.writeHead(405);
|
|
122
|
+
res.end(JSON.stringify({ error: "Method not allowed" }));
|
|
123
|
+
reqCtx.end(405);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
127
|
+
0 && (module.exports = {
|
|
128
|
+
setupContextEndpoint
|
|
129
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var endpoints_exports = {};
|
|
20
|
+
__export(endpoints_exports, {
|
|
21
|
+
LOGS_API_PATH: () => import_core.LOGS_API_PATH,
|
|
22
|
+
MCP_API_PATH: () => import_mcp.MCP_API_PATH,
|
|
23
|
+
VUE_DEVTOOLS_API_PATH: () => import_vue_devtools.VUE_DEVTOOLS_API_PATH,
|
|
24
|
+
setupMiddlewares: () => setupMiddlewares
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(endpoints_exports);
|
|
27
|
+
var import_widget = require("./widget.cjs");
|
|
28
|
+
var import_context = require("./context.cjs");
|
|
29
|
+
var import_start = require("./start.cjs");
|
|
30
|
+
var import_sse = require("./sse.cjs");
|
|
31
|
+
var import_sessions = require("./sessions.cjs");
|
|
32
|
+
var import_warmup = require("./warmup.cjs");
|
|
33
|
+
var import_logs = require("./logs.cjs");
|
|
34
|
+
var import_mcp = require("./mcp.cjs");
|
|
35
|
+
var import_vue_devtools = require("./vue-devtools.cjs");
|
|
36
|
+
var import_core = require("@aipanel/core");
|
|
37
|
+
__reExport(endpoints_exports, require("./types.cjs"), module.exports);
|
|
38
|
+
function setupMiddlewares(server, ctx, mcp, logFiles) {
|
|
39
|
+
(0, import_widget.setupWidgetEndpoints)(server, ctx);
|
|
40
|
+
(0, import_context.setupContextEndpoint)(server, ctx);
|
|
41
|
+
(0, import_start.setupStartEndpoint)(server, ctx);
|
|
42
|
+
(0, import_sse.setupSseEndpoint)(server, ctx);
|
|
43
|
+
(0, import_sessions.setupSessionsEndpoint)(server, ctx);
|
|
44
|
+
(0, import_warmup.setupWarmupEndpoint)(server, ctx);
|
|
45
|
+
(0, import_logs.setupLogsEndpoint)(server);
|
|
46
|
+
if (mcp) {
|
|
47
|
+
(0, import_mcp.setupMcpEndpoint)(server, mcp, () => ctx.getPageContext(), logFiles ?? []);
|
|
48
|
+
(0, import_vue_devtools.setupVueDevtoolsEndpoint)(server, mcp);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
LOGS_API_PATH,
|
|
54
|
+
MCP_API_PATH,
|
|
55
|
+
VUE_DEVTOOLS_API_PATH,
|
|
56
|
+
setupMiddlewares,
|
|
57
|
+
...require("./types.cjs")
|
|
58
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ViteDevServer } from "vite";
|
|
2
|
+
import type { EndpointContext } from "./types";
|
|
3
|
+
import { MCP_API_PATH } from "./mcp";
|
|
4
|
+
import { VUE_DEVTOOLS_API_PATH } from "./vue-devtools";
|
|
5
|
+
import type { McpProxy } from "../core/mcp-proxy";
|
|
6
|
+
import { LOGS_API_PATH, type LogFileConfig } from "@aipanel/core";
|
|
7
|
+
export * from "./types";
|
|
8
|
+
export { LOGS_API_PATH, MCP_API_PATH, VUE_DEVTOOLS_API_PATH };
|
|
9
|
+
export declare function setupMiddlewares(server: ViteDevServer, ctx: EndpointContext, mcp?: McpProxy, logFiles?: LogFileConfig[]): void;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var logs_exports = {};
|
|
19
|
+
__export(logs_exports, {
|
|
20
|
+
setupLogsEndpoint: () => setupLogsEndpoint
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(logs_exports);
|
|
23
|
+
var import_node = require("@aipanel/core/node");
|
|
24
|
+
var import_node2 = require("@aipanel/core/node");
|
|
25
|
+
var import_core = require("@aipanel/core");
|
|
26
|
+
const log = (0, import_node2.createLogger)("Endpoints:Logs");
|
|
27
|
+
function setupLogsEndpoint(server) {
|
|
28
|
+
server.middlewares.use(import_core.LOGS_API_PATH, async (req, res) => {
|
|
29
|
+
const reqCtx = new import_node2.RequestContext(req.method || "GET", import_core.LOGS_API_PATH);
|
|
30
|
+
res.setHeader("Content-Type", "application/json");
|
|
31
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
32
|
+
res.setHeader("Access-Control-Allow-Methods", "GET, DELETE, OPTIONS");
|
|
33
|
+
res.setHeader("Access-Control-Allow-Headers", "Content-Type");
|
|
34
|
+
if (req.method === "OPTIONS") {
|
|
35
|
+
res.writeHead(200);
|
|
36
|
+
res.end();
|
|
37
|
+
reqCtx.end(200);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const buffer = (0, import_node.getProcessLogBuffer)();
|
|
41
|
+
if (req.method === "GET") {
|
|
42
|
+
try {
|
|
43
|
+
const url = new URL(req.url || "", `http://${req.headers.host || "localhost"}`);
|
|
44
|
+
const levelParam = url.searchParams.get("level");
|
|
45
|
+
const limitParam = url.searchParams.get("limit");
|
|
46
|
+
const sourceParam = url.searchParams.get("source");
|
|
47
|
+
const sinceParam = url.searchParams.get("since");
|
|
48
|
+
const options = {};
|
|
49
|
+
if (levelParam) {
|
|
50
|
+
const levels = levelParam.split(",").map((l) => l.trim());
|
|
51
|
+
options.level = levels.length === 1 ? levels[0] : levels;
|
|
52
|
+
}
|
|
53
|
+
if (limitParam) {
|
|
54
|
+
const limit = parseInt(limitParam, 10);
|
|
55
|
+
if (limit > 0 && limit <= 1e3) {
|
|
56
|
+
options.limit = limit;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (sourceParam) {
|
|
60
|
+
options.source = sourceParam;
|
|
61
|
+
}
|
|
62
|
+
if (sinceParam) {
|
|
63
|
+
options.since = sinceParam;
|
|
64
|
+
}
|
|
65
|
+
const logs = buffer.getLogs(options);
|
|
66
|
+
log.debug("Logs requested", {
|
|
67
|
+
params: { level: levelParam, limit: limitParam, source: sourceParam, since: sinceParam },
|
|
68
|
+
resultCount: logs.length,
|
|
69
|
+
bufferSize: buffer.size()
|
|
70
|
+
});
|
|
71
|
+
res.writeHead(200);
|
|
72
|
+
res.end(
|
|
73
|
+
JSON.stringify({
|
|
74
|
+
logs,
|
|
75
|
+
meta: {
|
|
76
|
+
total: buffer.size(),
|
|
77
|
+
returned: logs.length,
|
|
78
|
+
filters: options
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
);
|
|
82
|
+
reqCtx.end(200);
|
|
83
|
+
} catch (e) {
|
|
84
|
+
log.error("Failed to get logs", { error: e });
|
|
85
|
+
res.writeHead(500);
|
|
86
|
+
res.end(JSON.stringify({ error: "Internal server error" }));
|
|
87
|
+
reqCtx.error(e);
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (req.method === "DELETE") {
|
|
92
|
+
buffer.clear();
|
|
93
|
+
log.debug("Log buffer cleared");
|
|
94
|
+
res.writeHead(200);
|
|
95
|
+
res.end(JSON.stringify({ success: true, message: "Log buffer cleared" }));
|
|
96
|
+
reqCtx.end(200);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
res.writeHead(405);
|
|
100
|
+
res.end(JSON.stringify({ error: "Method not allowed" }));
|
|
101
|
+
reqCtx.end(405);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
+
0 && (module.exports = {
|
|
106
|
+
setupLogsEndpoint
|
|
107
|
+
});
|