@jshookmcp/jshook 0.2.8 → 0.2.9
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 +36 -5
- package/README.zh.md +36 -5
- package/dist/{AntiCheatDetector-S8VRj-dD.mjs → AntiCheatDetector-BNk-EoBt.mjs} +3 -3
- package/dist/{CodeInjector-4Z3ngPoX.mjs → CodeInjector-Cq8q01kp.mjs} +5 -5
- package/dist/ConsoleMonitor-CPVQW1Y-.mjs +2201 -0
- package/dist/{DarwinAPI-B8hg_yhz.mjs → DarwinAPI-BNPxu0RH.mjs} +1 -1
- package/dist/DetailedDataManager-BQQcxh64.mjs +217 -0
- package/dist/EventBus-DgPmwpeu.mjs +141 -0
- package/dist/EvidenceGraphBridge-SFesNera.mjs +153 -0
- package/dist/{ExtensionManager-D5-bO9D8.mjs → ExtensionManager-CWYgw0YW.mjs} +13 -6
- package/dist/{FingerprintManager-BVxFJL2-.mjs → FingerprintManager-gzWtkKuf.mjs} +1 -1
- package/dist/{HardwareBreakpoint-DK1yjWkV.mjs → HardwareBreakpoint-B9gZCdFP.mjs} +3 -3
- package/dist/{HeapAnalyzer-CEbo10xU.mjs → HeapAnalyzer-BLDH0dCv.mjs} +4 -4
- package/dist/HookGeneratorBuilders.core.generators.storage-CtcdK78Q.mjs +639 -0
- package/dist/InstrumentationSession-CvPC7Jwy.mjs +244 -0
- package/dist/{MemoryController-DdtnBdD4.mjs → MemoryController-CbVdCIJF.mjs} +3 -3
- package/dist/{MemoryScanSession-RMixN3bX.mjs → MemoryScanSession-BsDZbLYm.mjs} +81 -78
- package/dist/{MemoryScanner-QjK4ld0B.mjs → MemoryScanner-Bcpml6II.mjs} +44 -18
- package/dist/{NativeMemoryManager.impl-CB6gJ0NM.mjs → NativeMemoryManager.impl-dZtA1ZGn.mjs} +14 -53
- package/dist/{NativeMemoryManager.utils-BML4q1ry.mjs → NativeMemoryManager.utils-B-FjA2mJ.mjs} +1 -1
- package/dist/{PEAnalyzer-CK0xe0Fs.mjs → PEAnalyzer-D1lzJ_VG.mjs} +2 -2
- package/dist/PageController-Bqm2kZ_X.mjs +417 -0
- package/dist/{PointerChainEngine-Cd73qu5b.mjs → PointerChainEngine-BOhyVsjx.mjs} +4 -4
- package/dist/PrerequisiteError-Dl33Svkz.mjs +20 -0
- package/dist/ResponseBuilder-D3iFYx2N.mjs +143 -0
- package/dist/ReverseEvidenceGraph-Dlsk94LC.mjs +269 -0
- package/dist/ScriptManager-aHHq0X7U.mjs +3000 -0
- package/dist/{Speedhack-CeF0XmEz.mjs → Speedhack-CqdIFlQl.mjs} +2 -2
- package/dist/{StructureAnalyzer-D4GkMduU.mjs → StructureAnalyzer-DhFaPvRO.mjs} +3 -3
- package/dist/ToolCatalog-C0JGZoOm.mjs +582 -0
- package/dist/ToolError-jh9whhMd.mjs +15 -0
- package/dist/ToolProbe-oC7aPrkv.mjs +45 -0
- package/dist/ToolRegistry-BjaF4oNz.mjs +131 -0
- package/dist/ToolRouter.policy-BWV67ZK-.mjs +304 -0
- package/dist/TraceRecorder-DgxyVbdQ.mjs +519 -0
- package/dist/{Win32API-Bc0QnQsN.mjs → Win32API-CePkipZY.mjs} +1 -1
- package/dist/{Win32Debug-DUHt9XUn.mjs → Win32Debug-BvKs-gxc.mjs} +2 -2
- package/dist/WorkflowEngine-CuvkZtWu.mjs +598 -0
- package/dist/analysis-CL9uACt9.mjs +463 -0
- package/dist/antidebug-CqDTB_uk.mjs +1081 -0
- package/dist/artifactRetention-CFEprwPw.mjs +591 -0
- package/dist/artifacts-Bk2-_uPq.mjs +59 -0
- package/dist/betterSqlite3-0pqusHHH.mjs +74 -0
- package/dist/binary-instrument-CXfpx6fT.mjs +979 -0
- package/dist/bind-helpers-xFfRF-qm.mjs +22 -0
- package/dist/boringssl-inspector-BH2D3VKc.mjs +180 -0
- package/dist/browser-BpOr5PEx.mjs +4082 -0
- package/dist/concurrency-Bt0yv1kJ.mjs +41 -0
- package/dist/{constants-CCvsN80K.mjs → constants-B0OANIBL.mjs} +88 -46
- package/dist/coordination-qUbyF8KU.mjs +259 -0
- package/dist/debugger-gnKxRSN0.mjs +1271 -0
- package/dist/definitions-6M-eejaT.mjs +53 -0
- package/dist/definitions-B18eyf0B.mjs +18 -0
- package/dist/definitions-B3QdlrHv.mjs +34 -0
- package/dist/definitions-B4rAvHNZ.mjs +63 -0
- package/dist/definitions-BB_4jnmy.mjs +37 -0
- package/dist/definitions-BMfYXoNC.mjs +43 -0
- package/dist/definitions-Beid2EB3.mjs +27 -0
- package/dist/definitions-C1UvM5Iy.mjs +126 -0
- package/dist/definitions-CXEI7QC72.mjs +216 -0
- package/dist/definitions-C_4r7Fo-2.mjs +14 -0
- package/dist/definitions-CkFDALoa.mjs +26 -0
- package/dist/definitions-Cke7zEb8.mjs +94 -0
- package/dist/definitions-ClJLzsJQ.mjs +25 -0
- package/dist/definitions-Cq-zroAU.mjs +28 -0
- package/dist/definitions-Cy3Sl6gV.mjs +34 -0
- package/dist/definitions-D3VsGcvz.mjs +47 -0
- package/dist/definitions-DVGfrn7y.mjs +96 -0
- package/dist/definitions-LKpC3-nL.mjs +9 -0
- package/dist/definitions-bAhHQJq9.mjs +359 -0
- package/dist/encoding-Bvz5jLRv.mjs +1065 -0
- package/dist/evidence-graph-bridge-C_fv9PuC.mjs +135 -0
- package/dist/{factory-CibqTNC8.mjs → factory-DxlGh9Xf.mjs} +37 -52
- package/dist/graphql-DYWzJ29s.mjs +1026 -0
- package/dist/handlers-9sAbfIg-.mjs +2552 -0
- package/dist/handlers-Bl8zkwz1.mjs +2716 -0
- package/dist/handlers-C67ktuRN.mjs +710 -0
- package/dist/handlers-C87g8oCe.mjs +276 -0
- package/dist/handlers-CTsDAO6p.mjs +681 -0
- package/dist/handlers-Cgyg6c0U.mjs +645 -0
- package/dist/handlers-D6j6yka7.mjs +2124 -0
- package/dist/handlers-DdFzXLvF.mjs +446 -0
- package/dist/handlers-DeLOCd5m.mjs +799 -0
- package/dist/handlers-DlCJN4Td.mjs +757 -0
- package/dist/handlers-DxGIq15_2.mjs +917 -0
- package/dist/handlers-U6L4xhuF.mjs +585 -0
- package/dist/handlers-tB9Mp9ZK.mjs +84 -0
- package/dist/handlers-tiy7EIBp.mjs +572 -0
- package/dist/handlers.impl-DS0d9fUw.mjs +761 -0
- package/dist/hooks-CzCWByww.mjs +898 -0
- package/dist/index.mjs +377 -155
- package/dist/{logger-BmWzC2lM.mjs → logger-Dh_xb7_2.mjs} +14 -6
- package/dist/maintenance-P7ePRXQC.mjs +830 -0
- package/dist/manifest-2ToTpjv8.mjs +106 -0
- package/dist/manifest-3g71z6Bg.mjs +79 -0
- package/dist/manifest-82baTv4U.mjs +45 -0
- package/dist/manifest-B3QVVeBS.mjs +82 -0
- package/dist/manifest-BB2J8IMJ.mjs +149 -0
- package/dist/manifest-BKbgbSiY.mjs +60 -0
- package/dist/manifest-Bcf-TJzH.mjs +848 -0
- package/dist/manifest-BmtZzQiQ2.mjs +45 -0
- package/dist/manifest-Bnd7kqEY.mjs +55 -0
- package/dist/manifest-BqQX6OQC2.mjs +65 -0
- package/dist/manifest-BqrQ4Tpj.mjs +81 -0
- package/dist/manifest-Br4RPFt5.mjs +370 -0
- package/dist/manifest-C5qDjysN.mjs +107 -0
- package/dist/manifest-C9RT5nk32.mjs +34 -0
- package/dist/manifest-CAhOuvSl.mjs +204 -0
- package/dist/manifest-CBYWCUBJ.mjs +51 -0
- package/dist/manifest-CFADCRa1.mjs +37 -0
- package/dist/manifest-CQVhavRF.mjs +114 -0
- package/dist/manifest-CT7zZBV1.mjs +48 -0
- package/dist/manifest-CV12bcrF.mjs +121 -0
- package/dist/manifest-CXsRWjjI.mjs +224 -0
- package/dist/manifest-CZLUCfG02.mjs +95 -0
- package/dist/manifest-D6phHKFd.mjs +131 -0
- package/dist/manifest-DCyjf4n2.mjs +294 -0
- package/dist/manifest-DHsnKgP6.mjs +60 -0
- package/dist/manifest-Df_dliIe.mjs +55 -0
- package/dist/manifest-Dh8WBmEW.mjs +129 -0
- package/dist/manifest-DhKRAT8_.mjs +92 -0
- package/dist/manifest-DlpTj4ic2.mjs +193 -0
- package/dist/manifest-DrbmZcFl2.mjs +253 -0
- package/dist/manifest-DuwHjUa5.mjs +70 -0
- package/dist/manifest-DzwvxPJX.mjs +38 -0
- package/dist/manifest-NXctwWQq.mjs +68 -0
- package/dist/manifest-Sc_0JQ13.mjs +418 -0
- package/dist/manifest-gZ4s_UtG.mjs +96 -0
- package/dist/manifest-qSleDqdO.mjs +1023 -0
- package/dist/modules-C184v-S9.mjs +11365 -0
- package/dist/mojo-ipc-B_H61Afw.mjs +525 -0
- package/dist/network-671Cw6hV.mjs +3346 -0
- package/dist/{artifacts-BbdOMET5.mjs → outputPaths-B1uGmrWZ.mjs} +219 -212
- package/dist/parse-args-BlRjqlkL.mjs +39 -0
- package/dist/platform-WmNn8Sxb.mjs +2070 -0
- package/dist/process-QcbIy5Zq.mjs +1401 -0
- package/dist/proxy-DqNs0bAd.mjs +170 -0
- package/dist/registry-D-6e18lB.mjs +34 -0
- package/dist/response-BQVP-xUn.mjs +28 -0
- package/dist/server/plugin-api.mjs +2 -2
- package/dist/shared-state-board-DV-dpHFJ.mjs +586 -0
- package/dist/sourcemap-Dq8ez8vS.mjs +650 -0
- package/dist/ssrf-policy-ZaUfvhq7.mjs +166 -0
- package/dist/streaming-BUQ0VJsg.mjs +725 -0
- package/dist/tool-builder-DCbIC5Eo.mjs +186 -0
- package/dist/transform-CiYJfNX0.mjs +1007 -0
- package/dist/types-Bx92KJfT.mjs +4 -0
- package/dist/wasm-DQTnHDs4.mjs +531 -0
- package/dist/workflow-f3xJOcjx.mjs +725 -0
- package/package.json +16 -16
- package/dist/ExtensionManager-CPTJhHFg.mjs +0 -2
- package/dist/ToolCatalog-Bq4V2sbJ.mjs +0 -67201
- package/dist/{CacheAdapters-CzFNpD9a.mjs → CacheAdapters-CDe5WPSV.mjs} +0 -0
- package/dist/{StealthVerifier-BzBCFiwx.mjs → StealthVerifier-Bo4T3bz8.mjs} +0 -0
- package/dist/{VersionDetector-CNXcvD46.mjs → VersionDetector-CwVLVdDM.mjs} +0 -0
- package/dist/{formatAddress-ChCSIRWT.mjs → formatAddress-DVkj9kpI.mjs} +0 -0
- package/dist/{types-BBjOqye-.mjs → types-CPhOReNX.mjs} +1 -1
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { a as argString, r as argNumber, s as argStringRequired, t as argBool } from "./parse-args-BlRjqlkL.mjs";
|
|
2
|
+
import { t as R } from "./ResponseBuilder-D3iFYx2N.mjs";
|
|
3
|
+
import "./definitions-C_4r7Fo-2.mjs";
|
|
4
|
+
import * as fs from "fs";
|
|
5
|
+
import * as path$1 from "path";
|
|
6
|
+
//#region src/server/domains/proxy/handlers.impl.ts
|
|
7
|
+
const ResponseBuilder = {
|
|
8
|
+
success: (data) => R.ok().merge(data).json(),
|
|
9
|
+
error: (msg) => R.fail(msg).mcpError().json()
|
|
10
|
+
};
|
|
11
|
+
var ProxyHandlers = class {
|
|
12
|
+
server = null;
|
|
13
|
+
caPathDir;
|
|
14
|
+
currentPort = null;
|
|
15
|
+
captureBuffer = [];
|
|
16
|
+
mockttpModule = null;
|
|
17
|
+
constructor() {
|
|
18
|
+
const home = process.env.HOME || process.env.USERPROFILE || "/tmp";
|
|
19
|
+
this.caPathDir = path$1.join(home, ".jshookmcp", "ca");
|
|
20
|
+
fs.mkdirSync(this.caPathDir, { recursive: true });
|
|
21
|
+
}
|
|
22
|
+
async handleProxyStart(args) {
|
|
23
|
+
const port = argNumber(args, "port") || 8080;
|
|
24
|
+
const useHttps = argBool(args, "useHttps") ?? true;
|
|
25
|
+
if (this.server) return ResponseBuilder.error(`Proxy is already running on port ${this.currentPort}`);
|
|
26
|
+
try {
|
|
27
|
+
const mockttp = this.mockttpModule ?? await import("mockttp");
|
|
28
|
+
this.mockttpModule = mockttp;
|
|
29
|
+
if (useHttps) {
|
|
30
|
+
const keyPath = path$1.join(this.caPathDir, "ca.key");
|
|
31
|
+
const certPath = path$1.join(this.caPathDir, "ca.pem");
|
|
32
|
+
if (!fs.existsSync(keyPath) || !fs.existsSync(certPath)) {
|
|
33
|
+
console.log("[Proxy] generating new CA certificates...");
|
|
34
|
+
const ca = await mockttp.generateCACertificate();
|
|
35
|
+
fs.writeFileSync(keyPath, ca.key);
|
|
36
|
+
fs.writeFileSync(certPath, ca.cert);
|
|
37
|
+
}
|
|
38
|
+
this.server = mockttp.getLocal({
|
|
39
|
+
https: {
|
|
40
|
+
keyPath,
|
|
41
|
+
certPath
|
|
42
|
+
},
|
|
43
|
+
cors: true
|
|
44
|
+
});
|
|
45
|
+
} else this.server = mockttp.getLocal();
|
|
46
|
+
this.server.on("request", (req) => {
|
|
47
|
+
this.captureBuffer.push({
|
|
48
|
+
type: "request",
|
|
49
|
+
id: req.id,
|
|
50
|
+
method: req.method,
|
|
51
|
+
url: req.url,
|
|
52
|
+
headers: req.headers,
|
|
53
|
+
timestamp: Date.now()
|
|
54
|
+
});
|
|
55
|
+
if (this.captureBuffer.length > 5e3) this.captureBuffer.shift();
|
|
56
|
+
});
|
|
57
|
+
this.server.on("response", (res) => {
|
|
58
|
+
this.captureBuffer.push({
|
|
59
|
+
type: "response",
|
|
60
|
+
id: res.id,
|
|
61
|
+
status: res.statusCode,
|
|
62
|
+
headers: res.headers,
|
|
63
|
+
timestamp: Date.now()
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
await this.server.start(port);
|
|
67
|
+
this.currentPort = port;
|
|
68
|
+
return ResponseBuilder.success({
|
|
69
|
+
message: `Proxy started.`,
|
|
70
|
+
port: this.currentPort,
|
|
71
|
+
caCertPath: useHttps ? path$1.join(this.caPathDir, "ca.pem") : null
|
|
72
|
+
});
|
|
73
|
+
} catch (e) {
|
|
74
|
+
this.server = null;
|
|
75
|
+
return ResponseBuilder.error(`Failed to start proxy: ${e.message}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async handleProxyStop(_args) {
|
|
79
|
+
if (!this.server) return ResponseBuilder.error("Proxy is not running.");
|
|
80
|
+
await this.server.stop();
|
|
81
|
+
this.server = null;
|
|
82
|
+
this.currentPort = null;
|
|
83
|
+
return ResponseBuilder.success({ message: "Proxy stopped successfully" });
|
|
84
|
+
}
|
|
85
|
+
async handleProxyStatus(_args) {
|
|
86
|
+
return ResponseBuilder.success({
|
|
87
|
+
running: !!this.server,
|
|
88
|
+
port: this.currentPort,
|
|
89
|
+
caDir: this.caPathDir,
|
|
90
|
+
caCertPath: path$1.join(this.caPathDir, "ca.pem")
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async handleProxyExportCa(_args) {
|
|
94
|
+
const certPath = path$1.join(this.caPathDir, "ca.pem");
|
|
95
|
+
if (!fs.existsSync(certPath)) return ResponseBuilder.error("CA certificate not found. Start the proxy with HTTPS enabled first.");
|
|
96
|
+
const certContent = fs.readFileSync(certPath, "utf8");
|
|
97
|
+
return ResponseBuilder.success({
|
|
98
|
+
path: certPath,
|
|
99
|
+
content: certContent
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
async handleProxyAddRule(args) {
|
|
103
|
+
if (!this.server) return ResponseBuilder.error("Proxy must be running to add rules.");
|
|
104
|
+
const action = argStringRequired(args, "action");
|
|
105
|
+
const method = (argString(args, "method") || "GET").toUpperCase();
|
|
106
|
+
const urlPattern = argString(args, "urlPattern") || ".*";
|
|
107
|
+
try {
|
|
108
|
+
let builder;
|
|
109
|
+
if (method === "GET") builder = this.server.forGet(new RegExp(urlPattern));
|
|
110
|
+
else if (method === "POST") builder = this.server.forPost(new RegExp(urlPattern));
|
|
111
|
+
else if (method === "PUT") builder = this.server.forPut(new RegExp(urlPattern));
|
|
112
|
+
else if (method === "DELETE") builder = this.server.forDelete(new RegExp(urlPattern));
|
|
113
|
+
else builder = this.server.forAnyRequest();
|
|
114
|
+
let endpoint;
|
|
115
|
+
if (action === "forward") endpoint = await builder.thenForward();
|
|
116
|
+
else if (action === "block") endpoint = await builder.thenCloseConnection();
|
|
117
|
+
else if (action === "mock_response") {
|
|
118
|
+
const mockStatus = argNumber(args, "mockStatus") || 200;
|
|
119
|
+
const mockBody = argString(args, "mockBody") || "";
|
|
120
|
+
endpoint = await builder.thenReply(mockStatus, mockBody);
|
|
121
|
+
} else return ResponseBuilder.error(`Unknown action: ${action}`);
|
|
122
|
+
return ResponseBuilder.success({
|
|
123
|
+
message: "Rule added successfully",
|
|
124
|
+
endpointId: endpoint.id
|
|
125
|
+
});
|
|
126
|
+
} catch (e) {
|
|
127
|
+
return ResponseBuilder.error(`Failed to add rule: ${e.message}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async handleProxyGetRequests(args) {
|
|
131
|
+
const urlFilter = argString(args, "urlFilter");
|
|
132
|
+
let results = this.captureBuffer;
|
|
133
|
+
if (urlFilter) results = results.filter((r) => r.url && r.url.includes(urlFilter));
|
|
134
|
+
return ResponseBuilder.success({
|
|
135
|
+
count: results.length,
|
|
136
|
+
logs: results.slice(-100)
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
async handleProxyClearLogs(_args) {
|
|
140
|
+
this.captureBuffer = [];
|
|
141
|
+
return ResponseBuilder.success({ message: "Captured proxy logs cleared." });
|
|
142
|
+
}
|
|
143
|
+
async handleProxySetupAdbDevice(args) {
|
|
144
|
+
const port = this.currentPort;
|
|
145
|
+
if (!port) return ResponseBuilder.error("Proxy must be running locally to setup ADB device reverse tethering.");
|
|
146
|
+
const certPath = path$1.join(this.caPathDir, "ca.pem");
|
|
147
|
+
if (!fs.existsSync(certPath)) return ResponseBuilder.error("CA certificate not found. Start the proxy with HTTPS enabled first.");
|
|
148
|
+
const { exec } = await import("child_process");
|
|
149
|
+
const { promisify } = await import("util");
|
|
150
|
+
const execAsync = promisify(exec);
|
|
151
|
+
const deviceSerial = argString(args, "deviceSerial");
|
|
152
|
+
const deviceFlag = deviceSerial ? `-s ${deviceSerial}` : "";
|
|
153
|
+
try {
|
|
154
|
+
await execAsync(`adb ${deviceFlag} get-state`);
|
|
155
|
+
await execAsync(`adb ${deviceFlag} push "${certPath}" /data/local/tmp/ca.pem`);
|
|
156
|
+
await execAsync(`adb ${deviceFlag} reverse tcp:${port} tcp:${port}`);
|
|
157
|
+
await execAsync(`adb ${deviceFlag} shell settings put global http_proxy 127.0.0.1:${port}`);
|
|
158
|
+
const instructions = `ADB Configuration Applied Automatically:\n- Verified device connection.\n- Pushed CA to /data/local/tmp/ca.pem\n- Reversed forwarded tcp:${port} -> tcp:${port}\n- Set global http_proxy to 127.0.0.1:${port}\n\nNote: For HTTPS decryption, you still need to manually install the CA cert from /data/local/tmp/ca.pem in Android Settings (due to security restrictions) unless device is rooted.`;
|
|
159
|
+
return ResponseBuilder.success({
|
|
160
|
+
message: "ADB device successfully configured.",
|
|
161
|
+
deviceId: deviceSerial || "default",
|
|
162
|
+
instructions
|
|
163
|
+
});
|
|
164
|
+
} catch (e) {
|
|
165
|
+
return ResponseBuilder.error(`Failed to configure ADB device: ${e.message}`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
//#endregion
|
|
170
|
+
export { ProxyHandlers };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { n as DOMInspector, r as CodeCollector, t as ScriptManager } from "./ScriptManager-aHHq0X7U.mjs";
|
|
2
|
+
import { t as PageController } from "./PageController-Bqm2kZ_X.mjs";
|
|
3
|
+
//#region src/server/registry/types.ts
|
|
4
|
+
/**
|
|
5
|
+
* Helper: create a name-based lookup from a Tool array.
|
|
6
|
+
* Throws at module load time if a tool name is missing — acts as a build-time guard.
|
|
7
|
+
*/
|
|
8
|
+
function toolLookup(tools) {
|
|
9
|
+
const map = new Map(tools.map((t) => [t.name, t]));
|
|
10
|
+
return (name) => {
|
|
11
|
+
const tool = map.get(name);
|
|
12
|
+
if (!tool) throw new Error(`[registry] Tool definition not found: "${name}"`);
|
|
13
|
+
return tool;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/server/registry/ensure-browser-core.ts
|
|
18
|
+
let ConsoleMonitorClass = null;
|
|
19
|
+
async function getConsoleMonitorClass() {
|
|
20
|
+
if (!ConsoleMonitorClass) ConsoleMonitorClass = (await import("./ConsoleMonitor-CPVQW1Y-.mjs").then((n) => n.t)).ConsoleMonitor;
|
|
21
|
+
return ConsoleMonitorClass;
|
|
22
|
+
}
|
|
23
|
+
async function ensureBrowserCore(ctx) {
|
|
24
|
+
if (!ctx.collector) {
|
|
25
|
+
ctx.collector = new CodeCollector(ctx.config.puppeteer);
|
|
26
|
+
ctx.registerCaches();
|
|
27
|
+
}
|
|
28
|
+
if (!ctx.pageController) ctx.pageController = new PageController(ctx.collector);
|
|
29
|
+
if (!ctx.domInspector) ctx.domInspector = new DOMInspector(ctx.collector);
|
|
30
|
+
if (!ctx.scriptManager) ctx.scriptManager = new ScriptManager(ctx.collector);
|
|
31
|
+
if (!ctx.consoleMonitor) ctx.consoleMonitor = new (await (getConsoleMonitorClass()))(ctx.collector);
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { toolLookup as n, ensureBrowserCore as t };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/server/domains/shared/response.ts
|
|
2
|
+
function toErrorMessage(error) {
|
|
3
|
+
if (error instanceof Error) return error.message;
|
|
4
|
+
return String(error);
|
|
5
|
+
}
|
|
6
|
+
function asTextResponse(text, isError = false) {
|
|
7
|
+
return {
|
|
8
|
+
content: [{
|
|
9
|
+
type: "text",
|
|
10
|
+
text
|
|
11
|
+
}],
|
|
12
|
+
...isError ? { isError: true } : {}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function asJsonResponse(payload) {
|
|
16
|
+
return asTextResponse(JSON.stringify(payload, null, 2));
|
|
17
|
+
}
|
|
18
|
+
function asErrorResponse(error) {
|
|
19
|
+
return asTextResponse(`Error: ${toErrorMessage(error)}`, true);
|
|
20
|
+
}
|
|
21
|
+
function serializeError(error) {
|
|
22
|
+
return {
|
|
23
|
+
success: false,
|
|
24
|
+
error: toErrorMessage(error)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { serializeError as i, asJsonResponse as n, asTextResponse as r, asErrorResponse as t };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "node:fs
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
+
import "node:fs/promises";
|
|
4
5
|
import dotenv from "dotenv";
|
|
5
6
|
import { execFile } from "node:child_process";
|
|
6
7
|
import { promisify } from "node:util";
|
|
7
|
-
import { existsSync } from "node:fs";
|
|
8
8
|
//#region src/server/extensions/plugin-config.ts
|
|
9
9
|
function normalizeSegment(value) {
|
|
10
10
|
return value.trim().replace(/[^a-zA-Z0-9]+/g, "_").replace(/^_+|_+$/g, "").toUpperCase();
|