vite-plugin-aipanel 1.2.8 → 1.2.10
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/es/core/chrome-project.d.ts +15 -0
- package/es/core/chrome-project.mjs +13 -0
- package/es/core/mcp-chrome.d.ts +12 -8
- package/es/core/mcp-chrome.mjs +52 -10
- package/es/core/mcp-proxy.d.ts +21 -1
- package/es/core/mcp-proxy.mjs +83 -12
- package/es/core/mcp-tools.d.ts +51 -3
- package/es/core/mcp-tools.mjs +109 -659
- package/es/core/official-meta.d.ts +9 -0
- package/es/core/official-meta.mjs +62 -0
- package/es/core/official-tools.d.ts +7 -0
- package/es/core/official-tools.mjs +54 -0
- package/es/core/proxy-server.mjs +16 -13
- package/es/core/service.mjs +4 -5
- package/es/endpoints/context.mjs +2 -2
- package/es/endpoints/host-events.mjs +1 -2
- package/es/endpoints/index.d.ts +2 -2
- package/es/endpoints/index.mjs +2 -2
- package/es/endpoints/mcp.d.ts +2 -2
- package/es/endpoints/mcp.mjs +116 -87
- package/es/endpoints/sse.mjs +3 -3
- package/es/endpoints/vue-devtools.d.ts +5 -2
- package/es/endpoints/vue-devtools.mjs +3 -4
- package/es/index.mjs +29 -6
- package/lib/client.js +2380 -2369
- package/lib/core/chrome-project.cjs +36 -0
- package/lib/core/chrome-project.d.ts +15 -0
- package/lib/core/mcp-chrome.cjs +64 -10
- package/lib/core/mcp-chrome.d.ts +12 -8
- package/lib/core/mcp-proxy.cjs +87 -13
- package/lib/core/mcp-proxy.d.ts +21 -1
- package/lib/core/mcp-tools.cjs +124 -660
- package/lib/core/mcp-tools.d.ts +51 -3
- package/lib/core/official-meta.cjs +85 -0
- package/lib/core/official-meta.d.ts +9 -0
- package/lib/core/official-tools.cjs +70 -0
- package/lib/core/official-tools.d.ts +7 -0
- package/lib/core/proxy-server.cjs +16 -13
- package/lib/core/service.cjs +4 -5
- package/lib/endpoints/context.cjs +1 -1
- package/lib/endpoints/host-events.cjs +0 -1
- package/lib/endpoints/index.cjs +2 -2
- package/lib/endpoints/index.d.ts +2 -2
- package/lib/endpoints/mcp.cjs +114 -85
- package/lib/endpoints/mcp.d.ts +2 -2
- package/lib/endpoints/sse.cjs +2 -2
- package/lib/endpoints/vue-devtools.cjs +4 -5
- package/lib/endpoints/vue-devtools.d.ts +5 -2
- package/lib/index.cjs +29 -7
- package/package.json +10 -7
- package/es/utils/format-bridge.d.ts +0 -9
- package/es/utils/format-bridge.mjs +0 -80
- package/es/utils/system.d.ts +0 -3
- package/es/utils/system.mjs +0 -76
- package/lib/utils/format-bridge.cjs +0 -102
- package/lib/utils/format-bridge.d.ts +0 -9
- package/lib/utils/system.cjs +0 -110
- package/lib/utils/system.d.ts +0 -3
package/es/utils/system.mjs
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import http from "http";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { SERVER_CHECK_INTERVAL } from "@aipanel/core";
|
|
5
|
-
import { PerformanceTimer, createLogger } from "@aipanel/core/node";
|
|
6
|
-
const log = createLogger("Utils");
|
|
7
|
-
function waitForServer(url, timeout = 1e4, process) {
|
|
8
|
-
const timer = new PerformanceTimer("waitForServer", { url, timeout });
|
|
9
|
-
return new Promise((resolve, reject) => {
|
|
10
|
-
const startTime = Date.now();
|
|
11
|
-
let attempts = 0;
|
|
12
|
-
const check = () => {
|
|
13
|
-
attempts++;
|
|
14
|
-
log.debug(`Checking server availability (attempt ${attempts})`, { url });
|
|
15
|
-
if (process?.exitCode !== null && process?.exitCode !== void 0) {
|
|
16
|
-
timer.end(`\u274C Process exited with code ${process.exitCode}`);
|
|
17
|
-
reject(new Error(`Process exited with code ${process.exitCode}`));
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const req = http.get(url, (res) => {
|
|
21
|
-
if (res.statusCode && res.statusCode < 500) {
|
|
22
|
-
timer.end(`\u2713 Server ready after ${attempts} attempts`);
|
|
23
|
-
resolve();
|
|
24
|
-
} else {
|
|
25
|
-
log.debug(`Server returned status ${res.statusCode}, retrying...`);
|
|
26
|
-
retryOrReject();
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
req.on("error", (err) => {
|
|
30
|
-
log.debug(`Server check failed: ${err.message}`);
|
|
31
|
-
retryOrReject();
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
const retryOrReject = () => {
|
|
35
|
-
const elapsed = Date.now() - startTime;
|
|
36
|
-
if (elapsed < timeout) {
|
|
37
|
-
setTimeout(check, SERVER_CHECK_INTERVAL);
|
|
38
|
-
} else {
|
|
39
|
-
timer.end("\u274C Timeout");
|
|
40
|
-
reject(new Error(`Server not ready after ${timeout}ms (${attempts} attempts)`));
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
check();
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
function findGitRoot(startDir, maxDepth = 10) {
|
|
47
|
-
const timer = log.timer("findGitRoot", { startDir, maxDepth });
|
|
48
|
-
let currentDir = startDir;
|
|
49
|
-
let depth = 0;
|
|
50
|
-
while (depth < maxDepth) {
|
|
51
|
-
const gitDir = path.join(currentDir, ".git");
|
|
52
|
-
try {
|
|
53
|
-
if (fs.existsSync(gitDir)) {
|
|
54
|
-
timer.end(`\u2713 Found git root at depth ${depth}: ${currentDir}`);
|
|
55
|
-
return currentDir;
|
|
56
|
-
}
|
|
57
|
-
} catch (err) {
|
|
58
|
-
log.debug(`Error checking .git directory at ${currentDir}`, {
|
|
59
|
-
error: err.message
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
const parentDir = path.dirname(currentDir);
|
|
63
|
-
if (parentDir === currentDir) {
|
|
64
|
-
log.debug("Reached filesystem root");
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
currentDir = parentDir;
|
|
68
|
-
depth++;
|
|
69
|
-
}
|
|
70
|
-
timer.end(`\u274C No git root found after ${depth} levels, using start directory`);
|
|
71
|
-
return startDir;
|
|
72
|
-
}
|
|
73
|
-
export {
|
|
74
|
-
findGitRoot,
|
|
75
|
-
waitForServer
|
|
76
|
-
};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
|
-
var import_fs = __toESM(require("fs"));
|
|
25
|
-
var import_http = __toESM(require("http"));
|
|
26
|
-
var import_path = __toESM(require("path"));
|
|
27
|
-
const filePath = process.argv[2];
|
|
28
|
-
if (!filePath) {
|
|
29
|
-
console.error("Usage: node format-bridge.cjs <filePath>");
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
const absPath = import_path.default.resolve(filePath);
|
|
33
|
-
const PORT = parseInt(process.env.AIPANEL_VSCODE_PORT || "", 10) || 51939;
|
|
34
|
-
function touchFile() {
|
|
35
|
-
const now = /* @__PURE__ */ new Date();
|
|
36
|
-
import_fs.default.utimesSync(absPath, now, now);
|
|
37
|
-
}
|
|
38
|
-
function probeHealth() {
|
|
39
|
-
return new Promise((resolve) => {
|
|
40
|
-
const req = import_http.default.get(`http://127.0.0.1:${PORT}/health`, (res) => {
|
|
41
|
-
res.resume();
|
|
42
|
-
resolve(res.statusCode === 200);
|
|
43
|
-
});
|
|
44
|
-
req.setTimeout(500, () => {
|
|
45
|
-
req.destroy();
|
|
46
|
-
resolve(false);
|
|
47
|
-
});
|
|
48
|
-
req.on("error", () => resolve(false));
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function formatViaExtension() {
|
|
52
|
-
return new Promise((resolve, reject) => {
|
|
53
|
-
const body = JSON.stringify({ filePath: absPath });
|
|
54
|
-
const req = import_http.default.request(
|
|
55
|
-
{
|
|
56
|
-
hostname: "127.0.0.1",
|
|
57
|
-
port: PORT,
|
|
58
|
-
path: "/format",
|
|
59
|
-
method: "POST",
|
|
60
|
-
headers: { "Content-Type": "application/json" },
|
|
61
|
-
timeout: 5e3
|
|
62
|
-
},
|
|
63
|
-
(res) => {
|
|
64
|
-
const chunks = [];
|
|
65
|
-
res.on("data", (c) => chunks.push(c));
|
|
66
|
-
res.on("end", () => {
|
|
67
|
-
try {
|
|
68
|
-
const result = JSON.parse(Buffer.concat(chunks).toString());
|
|
69
|
-
if (result.error) {
|
|
70
|
-
reject(new Error(result.error));
|
|
71
|
-
} else {
|
|
72
|
-
resolve(result);
|
|
73
|
-
}
|
|
74
|
-
} catch (e) {
|
|
75
|
-
reject(e);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
);
|
|
80
|
-
req.on("error", reject);
|
|
81
|
-
req.on("timeout", () => {
|
|
82
|
-
req.destroy();
|
|
83
|
-
reject(new Error("Timeout"));
|
|
84
|
-
});
|
|
85
|
-
req.write(body);
|
|
86
|
-
req.end();
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
async function main() {
|
|
90
|
-
const healthy = await probeHealth();
|
|
91
|
-
if (!healthy) {
|
|
92
|
-
touchFile();
|
|
93
|
-
process.exit(0);
|
|
94
|
-
}
|
|
95
|
-
try {
|
|
96
|
-
await formatViaExtension();
|
|
97
|
-
} catch {
|
|
98
|
-
}
|
|
99
|
-
touchFile();
|
|
100
|
-
process.exit(0);
|
|
101
|
-
}
|
|
102
|
-
main();
|
package/lib/utils/system.cjs
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var system_exports = {};
|
|
29
|
-
__export(system_exports, {
|
|
30
|
-
findGitRoot: () => findGitRoot,
|
|
31
|
-
waitForServer: () => waitForServer
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(system_exports);
|
|
34
|
-
var import_fs = __toESM(require("fs"));
|
|
35
|
-
var import_http = __toESM(require("http"));
|
|
36
|
-
var import_path = __toESM(require("path"));
|
|
37
|
-
var import_core = require("@aipanel/core");
|
|
38
|
-
var import_node = require("@aipanel/core/node");
|
|
39
|
-
const log = (0, import_node.createLogger)("Utils");
|
|
40
|
-
function waitForServer(url, timeout = 1e4, process) {
|
|
41
|
-
const timer = new import_node.PerformanceTimer("waitForServer", { url, timeout });
|
|
42
|
-
return new Promise((resolve, reject) => {
|
|
43
|
-
const startTime = Date.now();
|
|
44
|
-
let attempts = 0;
|
|
45
|
-
const check = () => {
|
|
46
|
-
attempts++;
|
|
47
|
-
log.debug(`Checking server availability (attempt ${attempts})`, { url });
|
|
48
|
-
if (process?.exitCode !== null && process?.exitCode !== void 0) {
|
|
49
|
-
timer.end(`\u274C Process exited with code ${process.exitCode}`);
|
|
50
|
-
reject(new Error(`Process exited with code ${process.exitCode}`));
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const req = import_http.default.get(url, (res) => {
|
|
54
|
-
if (res.statusCode && res.statusCode < 500) {
|
|
55
|
-
timer.end(`\u2713 Server ready after ${attempts} attempts`);
|
|
56
|
-
resolve();
|
|
57
|
-
} else {
|
|
58
|
-
log.debug(`Server returned status ${res.statusCode}, retrying...`);
|
|
59
|
-
retryOrReject();
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
req.on("error", (err) => {
|
|
63
|
-
log.debug(`Server check failed: ${err.message}`);
|
|
64
|
-
retryOrReject();
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
const retryOrReject = () => {
|
|
68
|
-
const elapsed = Date.now() - startTime;
|
|
69
|
-
if (elapsed < timeout) {
|
|
70
|
-
setTimeout(check, import_core.SERVER_CHECK_INTERVAL);
|
|
71
|
-
} else {
|
|
72
|
-
timer.end("\u274C Timeout");
|
|
73
|
-
reject(new Error(`Server not ready after ${timeout}ms (${attempts} attempts)`));
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
check();
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
function findGitRoot(startDir, maxDepth = 10) {
|
|
80
|
-
const timer = log.timer("findGitRoot", { startDir, maxDepth });
|
|
81
|
-
let currentDir = startDir;
|
|
82
|
-
let depth = 0;
|
|
83
|
-
while (depth < maxDepth) {
|
|
84
|
-
const gitDir = import_path.default.join(currentDir, ".git");
|
|
85
|
-
try {
|
|
86
|
-
if (import_fs.default.existsSync(gitDir)) {
|
|
87
|
-
timer.end(`\u2713 Found git root at depth ${depth}: ${currentDir}`);
|
|
88
|
-
return currentDir;
|
|
89
|
-
}
|
|
90
|
-
} catch (err) {
|
|
91
|
-
log.debug(`Error checking .git directory at ${currentDir}`, {
|
|
92
|
-
error: err.message
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
const parentDir = import_path.default.dirname(currentDir);
|
|
96
|
-
if (parentDir === currentDir) {
|
|
97
|
-
log.debug("Reached filesystem root");
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
currentDir = parentDir;
|
|
101
|
-
depth++;
|
|
102
|
-
}
|
|
103
|
-
timer.end(`\u274C No git root found after ${depth} levels, using start directory`);
|
|
104
|
-
return startDir;
|
|
105
|
-
}
|
|
106
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
107
|
-
0 && (module.exports = {
|
|
108
|
-
findGitRoot,
|
|
109
|
-
waitForServer
|
|
110
|
-
});
|
package/lib/utils/system.d.ts
DELETED