@jshookmcp/jshook 0.2.8 → 0.3.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.
Files changed (162) hide show
  1. package/README.md +36 -5
  2. package/README.zh.md +36 -5
  3. package/dist/{AntiCheatDetector-S8VRj-dD.mjs → AntiCheatDetector-CqGDXmfc.mjs} +160 -54
  4. package/dist/{CodeInjector-4Z3ngPoX.mjs → CodeInjector-BdjRfNx7.mjs} +5 -5
  5. package/dist/ConsoleMonitor-DykL3IAw.mjs +2269 -0
  6. package/dist/{DarwinAPI-B8hg_yhz.mjs → DarwinAPI-ETyy0xyo.mjs} +1 -1
  7. package/dist/DetailedDataManager-HT49OrvF.mjs +217 -0
  8. package/dist/EventBus-DFKvADm3.mjs +141 -0
  9. package/dist/EvidenceGraphBridge-318Oi0Lf.mjs +153 -0
  10. package/dist/{ExtensionManager-D5-bO9D8.mjs → ExtensionManager-BDMsY2Dz.mjs} +27 -13
  11. package/dist/{FingerprintManager-BVxFJL2-.mjs → FingerprintManager-BN4UQWnX.mjs} +1 -1
  12. package/dist/{HardwareBreakpoint-DK1yjWkV.mjs → HardwareBreakpoint-Cc2AFq1Y.mjs} +3 -3
  13. package/dist/{HeapAnalyzer-CEbo10xU.mjs → HeapAnalyzer-DruMgsgj.mjs} +21 -21
  14. package/dist/HookGeneratorBuilders.core.generators.storage-CTbB4Lcx.mjs +566 -0
  15. package/dist/InstrumentationSession-DLH0vd-z.mjs +244 -0
  16. package/dist/{MemoryController-DdtnBdD4.mjs → MemoryController-CMtviNW_.mjs} +3 -3
  17. package/dist/{MemoryScanSession-RMixN3bX.mjs → MemoryScanSession-ITgb_NMi.mjs} +81 -78
  18. package/dist/{MemoryScanner-QjK4ld0B.mjs → MemoryScanner-CiL7Z3ey.mjs} +50 -21
  19. package/dist/{NativeMemoryManager.impl-CB6gJ0NM.mjs → NativeMemoryManager.impl-D9Lkovvn.mjs} +20 -56
  20. package/dist/{NativeMemoryManager.utils-BML4q1ry.mjs → NativeMemoryManager.utils-BBlAixF5.mjs} +1 -1
  21. package/dist/{PEAnalyzer-CK0xe0Fs.mjs → PEAnalyzer-DMQ44gen.mjs} +16 -16
  22. package/dist/PageController-BPJNqqBN.mjs +431 -0
  23. package/dist/{PointerChainEngine-Cd73qu5b.mjs → PointerChainEngine-K7wN8Z-w.mjs} +10 -7
  24. package/dist/PrerequisiteError-TuyZIs6n.mjs +20 -0
  25. package/dist/ProcessRegistry-zGg12QbE.mjs +74 -0
  26. package/dist/ResponseBuilder-CJXWmWNw.mjs +143 -0
  27. package/dist/ReverseEvidenceGraph-C02-gXOh.mjs +269 -0
  28. package/dist/ScriptManager-ZuWD-0Jg.mjs +3003 -0
  29. package/dist/{Speedhack-CeF0XmEz.mjs → Speedhack-D-z0umeT.mjs} +2 -2
  30. package/dist/{StructureAnalyzer-D4GkMduU.mjs → StructureAnalyzer-Cav5AVSL.mjs} +9 -6
  31. package/dist/ToolCatalog-5OJdMiF0.mjs +582 -0
  32. package/dist/ToolError-jh9whhMd.mjs +15 -0
  33. package/dist/ToolProbe-DbCFGyrg.mjs +45 -0
  34. package/dist/ToolRegistry-B9krbTtI.mjs +180 -0
  35. package/dist/ToolRouter.policy-BGDAGyeH.mjs +344 -0
  36. package/dist/TraceRecorder-B41Z5XBj.mjs +1286 -0
  37. package/dist/{Win32API-Bc0QnQsN.mjs → Win32API-C2kjj0ze.mjs} +19 -13
  38. package/dist/{Win32Debug-DUHt9XUn.mjs → Win32Debug-CKrGOTpo.mjs} +3 -3
  39. package/dist/WorkflowEngine-DJ6M4opp.mjs +569 -0
  40. package/dist/analysis-BHeJW2Nb.mjs +1234 -0
  41. package/dist/antidebug-BRKeyt27.mjs +1081 -0
  42. package/dist/artifactRetention-CPXkUJXp.mjs +598 -0
  43. package/dist/artifacts-DkfosXH3.mjs +59 -0
  44. package/dist/authorization-schema-DRqyJMSk.mjs +31 -0
  45. package/dist/betterSqlite3-DLSBZodi.mjs +74 -0
  46. package/dist/binary-instrument--V3MAhJ4.mjs +971 -0
  47. package/dist/bind-helpers-ClV34xdn.mjs +42 -0
  48. package/dist/boringssl-inspector-Bo_LOLaS.mjs +180 -0
  49. package/dist/browser-Dx3_S2cG.mjs +4369 -0
  50. package/dist/capabilities-CcHlvWgK.mjs +33 -0
  51. package/dist/concurrency-Drev_Vz9.mjs +41 -0
  52. package/dist/{constants-CCvsN80K.mjs → constants-CDZLOoVv.mjs} +105 -48
  53. package/dist/coordination-DgItD9DL.mjs +259 -0
  54. package/dist/debugger-RS3RSAqs.mjs +1288 -0
  55. package/dist/definitions-BEoYofW5.mjs +47 -0
  56. package/dist/definitions-BRaefg3u.mjs +365 -0
  57. package/dist/definitions-BbkvZkiv.mjs +96 -0
  58. package/dist/definitions-BtWSHJ3o.mjs +17 -0
  59. package/dist/definitions-C1gCHO0i.mjs +43 -0
  60. package/dist/definitions-CDOg_b-l.mjs +138 -0
  61. package/dist/definitions-CVPD9hzZ.mjs +54 -0
  62. package/dist/definitions-Cea8Lgl7.mjs +94 -0
  63. package/dist/definitions-DAgIyjxM.mjs +10 -0
  64. package/dist/definitions-DJA27nsL.mjs +66 -0
  65. package/dist/definitions-DKPFU3LW.mjs +25 -0
  66. package/dist/definitions-DPRpZQ96.mjs +47 -0
  67. package/dist/definitions-DUE5gmdn.mjs +18 -0
  68. package/dist/definitions-DYVjOtxa.mjs +26 -0
  69. package/dist/definitions-DcYLVLCo.mjs +37 -0
  70. package/dist/definitions-Pp5LI2H4.mjs +27 -0
  71. package/dist/definitions-j9KdHVNR.mjs +14 -0
  72. package/dist/definitions-uzkjBwa7.mjs +258 -0
  73. package/dist/definitions-va-AnLuQ.mjs +28 -0
  74. package/dist/encoding-DJeqHmpd.mjs +1079 -0
  75. package/dist/evidence-graph-bridge-DcYizFk2.mjs +136 -0
  76. package/dist/{factory-CibqTNC8.mjs → factory-C90tBff6.mjs} +41 -56
  77. package/dist/flat-target-session-Dgax2Cy3.mjs +29 -0
  78. package/dist/graphql-CoHrhweh.mjs +1197 -0
  79. package/dist/handlers-4jmR0nMs.mjs +898 -0
  80. package/dist/handlers-BAHPxcch.mjs +789 -0
  81. package/dist/handlers-BOs9b907.mjs +2600 -0
  82. package/dist/handlers-BWXEy6ef.mjs +917 -0
  83. package/dist/handlers-Bndn6QvE.mjs +111 -0
  84. package/dist/handlers-BqC4bD4s.mjs +681 -0
  85. package/dist/handlers-BtYq60bM2.mjs +276 -0
  86. package/dist/handlers-BzgcB4iv.mjs +799 -0
  87. package/dist/handlers-CRyRWj2b.mjs +859 -0
  88. package/dist/handlers-CVv2H1uq.mjs +592 -0
  89. package/dist/handlers-Dl5a7JS4.mjs +572 -0
  90. package/dist/handlers-Dx2d7jt7.mjs +2537 -0
  91. package/dist/handlers-Dz9PYsCa.mjs +2805 -0
  92. package/dist/handlers-HujRKC3b.mjs +661 -0
  93. package/dist/handlers.impl-XWXkQfyi.mjs +807 -0
  94. package/dist/hooks-B1B8NRHL.mjs +898 -0
  95. package/dist/index.mjs +491 -259
  96. package/dist/{logger-BmWzC2lM.mjs → logger-Dh_xb7_2.mjs} +14 -6
  97. package/dist/maintenance-PRMkLVRW.mjs +835 -0
  98. package/dist/manifest-67Bok-Si.mjs +58 -0
  99. package/dist/manifest-6lNTMZAB2.mjs +87 -0
  100. package/dist/manifest-B2duEHiH.mjs +90 -0
  101. package/dist/manifest-B6EY9Vm8.mjs +57 -0
  102. package/dist/manifest-B6nKSbyY.mjs +95 -0
  103. package/dist/manifest-BL8AQNPF.mjs +106 -0
  104. package/dist/manifest-BSZvJJmV.mjs +47 -0
  105. package/dist/manifest-BU7qzUyX.mjs +418 -0
  106. package/dist/manifest-Bl62e8WK.mjs +49 -0
  107. package/dist/manifest-Bo5cXjdt.mjs +82 -0
  108. package/dist/manifest-BpS4gtUK.mjs +1347 -0
  109. package/dist/manifest-Bv65_e2W.mjs +101 -0
  110. package/dist/manifest-BytNIF4Z.mjs +117 -0
  111. package/dist/manifest-C-xtsjS3.mjs +81 -0
  112. package/dist/manifest-CDYl7OhA.mjs +66 -0
  113. package/dist/manifest-CRZ3xmkD.mjs +61 -0
  114. package/dist/manifest-CoW6u4Tp.mjs +132 -0
  115. package/dist/manifest-Cq5zN_8A.mjs +50 -0
  116. package/dist/manifest-D7YZM_2e.mjs +194 -0
  117. package/dist/manifest-DE_VrAeQ.mjs +314 -0
  118. package/dist/manifest-DGsXSCpT.mjs +39 -0
  119. package/dist/manifest-DJ2vfEuW.mjs +156 -0
  120. package/dist/manifest-DPXDYhEu.mjs +80 -0
  121. package/dist/manifest-Dd4fQb0a.mjs +322 -0
  122. package/dist/manifest-Deq6opGg.mjs +223 -0
  123. package/dist/manifest-DfJTafJK.mjs +37 -0
  124. package/dist/manifest-DgOdgN_j.mjs +50 -0
  125. package/dist/manifest-DlbMW4v4.mjs +47 -0
  126. package/dist/manifest-DmVfbH0w.mjs +374 -0
  127. package/dist/manifest-Dog6Ddjr.mjs +109 -0
  128. package/dist/manifest-DvgU5FWb.mjs +58 -0
  129. package/dist/manifest-HsfDBs7j.mjs +50 -0
  130. package/dist/manifest-I8oQHvCG.mjs +186 -0
  131. package/dist/manifest-NvH_a-av.mjs +786 -0
  132. package/dist/manifest-cEJU1v0Z.mjs +129 -0
  133. package/dist/manifest-wOl5XLB12.mjs +112 -0
  134. package/dist/modules-tZozf0LQ.mjs +10635 -0
  135. package/dist/mojo-ipc-DXNEXEqb.mjs +640 -0
  136. package/dist/network-CPVvwvFg.mjs +3852 -0
  137. package/dist/{artifacts-BbdOMET5.mjs → outputPaths-um7lCRY3.mjs} +219 -216
  138. package/dist/parse-args-B4cY5Vx5.mjs +39 -0
  139. package/dist/platform-CYeFoTWp.mjs +2161 -0
  140. package/dist/process-BTbgcVc6.mjs +1306 -0
  141. package/dist/proxy-r8YN6nP1.mjs +192 -0
  142. package/dist/registry-Bl8ZQW61.mjs +34 -0
  143. package/dist/response-CWhh2aLo.mjs +34 -0
  144. package/dist/server/plugin-api.mjs +2 -2
  145. package/dist/shared-state-board-BoZnSoj-.mjs +586 -0
  146. package/dist/sourcemap-BIDHUVXy.mjs +934 -0
  147. package/dist/ssrf-policy-Dsqd-DTX.mjs +166 -0
  148. package/dist/streaming-Dal6utPp.mjs +725 -0
  149. package/dist/tool-builder-BHJp32mV.mjs +186 -0
  150. package/dist/transform-DRVgGG90.mjs +1011 -0
  151. package/dist/types-Bx92KJfT.mjs +4 -0
  152. package/dist/wasm-BYx5UOeG.mjs +1044 -0
  153. package/dist/webcrack-Be0_FccV.mjs +747 -0
  154. package/dist/workflow-BpuKEtvn.mjs +725 -0
  155. package/package.json +82 -49
  156. package/dist/ExtensionManager-CPTJhHFg.mjs +0 -2
  157. package/dist/ToolCatalog-Bq4V2sbJ.mjs +0 -67201
  158. package/dist/{CacheAdapters-CzFNpD9a.mjs → CacheAdapters-jJFy20G-.mjs} +0 -0
  159. package/dist/{StealthVerifier-BzBCFiwx.mjs → StealthVerifier-BWmPgQsv.mjs} +0 -0
  160. package/dist/{VersionDetector-CNXcvD46.mjs → VersionDetector-K3V4vGsw.mjs} +0 -0
  161. package/dist/{formatAddress-ChCSIRWT.mjs → formatAddress-nnMvEohD.mjs} +0 -0
  162. package/dist/{types-BBjOqye-.mjs → types-DDBWs9UP.mjs} +1 -1
@@ -0,0 +1,192 @@
1
+ import { a as argString, r as argNumber, s as argStringRequired, t as argBool } from "./parse-args-B4cY5Vx5.mjs";
2
+ import { t as R } from "./ResponseBuilder-CJXWmWNw.mjs";
3
+ import "./definitions-j9KdHVNR.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
+ function compileUrlPattern(urlPattern) {
12
+ const trimmed = urlPattern.trim();
13
+ const regexLiteral = /^\/(.+)\/([a-z]*)$/.exec(trimmed);
14
+ if (regexLiteral && regexLiteral[1] !== void 0) {
15
+ const source = regexLiteral[1];
16
+ const flags = regexLiteral[2] ?? "";
17
+ return new RegExp(source, flags);
18
+ }
19
+ return new RegExp(trimmed);
20
+ }
21
+ var ProxyHandlers = class {
22
+ server = null;
23
+ caPathDir;
24
+ currentPort = null;
25
+ captureBuffer = [];
26
+ mockttpModule = null;
27
+ constructor() {
28
+ const home = process.env.HOME || process.env.USERPROFILE || "/tmp";
29
+ this.caPathDir = path$1.join(home, ".jshookmcp", "ca");
30
+ fs.mkdirSync(this.caPathDir, { recursive: true });
31
+ }
32
+ async handleProxyStart(args) {
33
+ const port = argNumber(args, "port") || 8080;
34
+ const useHttps = argBool(args, "useHttps") ?? true;
35
+ if (this.server) return ResponseBuilder.error(`Proxy is already running on port ${this.currentPort}`);
36
+ try {
37
+ const mockttp = this.mockttpModule ?? await import("mockttp");
38
+ this.mockttpModule = mockttp;
39
+ if (useHttps) {
40
+ const keyPath = path$1.join(this.caPathDir, "ca.key");
41
+ const certPath = path$1.join(this.caPathDir, "ca.pem");
42
+ if (!fs.existsSync(keyPath) || !fs.existsSync(certPath)) {
43
+ console.log("[Proxy] generating new CA certificates...");
44
+ const ca = await mockttp.generateCACertificate();
45
+ fs.writeFileSync(keyPath, ca.key);
46
+ fs.writeFileSync(certPath, ca.cert);
47
+ }
48
+ this.server = mockttp.getLocal({
49
+ https: {
50
+ keyPath,
51
+ certPath
52
+ },
53
+ cors: true
54
+ });
55
+ } else this.server = mockttp.getLocal();
56
+ this.server.on("request", (req) => {
57
+ this.captureBuffer.push({
58
+ type: "request",
59
+ id: req.id,
60
+ method: req.method,
61
+ url: req.url,
62
+ headers: req.headers,
63
+ timestamp: Date.now()
64
+ });
65
+ if (this.captureBuffer.length > 5e3) this.captureBuffer.shift();
66
+ });
67
+ this.server.on("response", (res) => {
68
+ this.captureBuffer.push({
69
+ type: "response",
70
+ id: res.id,
71
+ status: res.statusCode,
72
+ headers: res.headers,
73
+ timestamp: Date.now()
74
+ });
75
+ });
76
+ await this.server.start(port);
77
+ this.currentPort = port;
78
+ return ResponseBuilder.success({
79
+ message: `Proxy started.`,
80
+ port: this.currentPort,
81
+ caCertPath: useHttps ? path$1.join(this.caPathDir, "ca.pem") : null
82
+ });
83
+ } catch (e) {
84
+ this.server = null;
85
+ return ResponseBuilder.error(`Failed to start proxy: ${e.message}`);
86
+ }
87
+ }
88
+ async handleProxyStop(_args) {
89
+ if (!this.server) return ResponseBuilder.error("Proxy is not running.");
90
+ await this.server.stop();
91
+ this.server = null;
92
+ this.currentPort = null;
93
+ return ResponseBuilder.success({ message: "Proxy stopped successfully" });
94
+ }
95
+ async handleProxyStatus(_args) {
96
+ return ResponseBuilder.success({
97
+ running: !!this.server,
98
+ port: this.currentPort,
99
+ caDir: this.caPathDir,
100
+ caCertPath: path$1.join(this.caPathDir, "ca.pem")
101
+ });
102
+ }
103
+ async handleProxyExportCa(_args) {
104
+ const certPath = path$1.join(this.caPathDir, "ca.pem");
105
+ if (!fs.existsSync(certPath)) return ResponseBuilder.error("CA certificate not found. Start the proxy with HTTPS enabled first.");
106
+ const certContent = fs.readFileSync(certPath, "utf8");
107
+ return ResponseBuilder.success({
108
+ path: certPath,
109
+ content: certContent
110
+ });
111
+ }
112
+ async handleProxyAddRule(args) {
113
+ if (!this.server) return ResponseBuilder.error("Proxy must be running to add rules.");
114
+ const action = argStringRequired(args, "action");
115
+ const method = (argString(args, "method") || "GET").toUpperCase();
116
+ const urlPattern = argString(args, "urlPattern") || ".*";
117
+ try {
118
+ const matcher = compileUrlPattern(urlPattern);
119
+ let builder;
120
+ if (method === "GET") builder = this.server.forGet(matcher);
121
+ else if (method === "POST") builder = this.server.forPost(matcher);
122
+ else if (method === "PUT") builder = this.server.forPut(matcher);
123
+ else if (method === "DELETE") builder = this.server.forDelete(matcher);
124
+ else builder = this.server.forAnyRequest();
125
+ let endpoint;
126
+ if (action === "forward") endpoint = await builder.thenPassThrough();
127
+ else if (action === "block") endpoint = await builder.thenCloseConnection();
128
+ else if (action === "mock_response") {
129
+ const mockStatus = argNumber(args, "mockStatus") || 200;
130
+ const mockBody = argString(args, "mockBody") || "";
131
+ endpoint = await builder.thenReply(mockStatus, mockBody);
132
+ } else return ResponseBuilder.error(`Unknown action: ${action}`);
133
+ return ResponseBuilder.success({
134
+ message: "Rule added successfully",
135
+ endpointId: endpoint.id
136
+ });
137
+ } catch (e) {
138
+ return ResponseBuilder.error(`Failed to add rule: ${e.message}`);
139
+ }
140
+ }
141
+ async handleProxyGetRequests(args) {
142
+ const urlFilter = argString(args, "urlFilter");
143
+ let results = this.captureBuffer;
144
+ if (urlFilter) results = results.filter((r) => r.url && r.url.includes(urlFilter));
145
+ return ResponseBuilder.success({
146
+ count: results.length,
147
+ logs: results.slice(-100)
148
+ });
149
+ }
150
+ async handleProxyClearLogs(_args) {
151
+ this.captureBuffer = [];
152
+ return ResponseBuilder.success({ message: "Captured proxy logs cleared." });
153
+ }
154
+ async handleProxySetupAdbDevice(args) {
155
+ const port = this.currentPort;
156
+ if (!port) return ResponseBuilder.error("Proxy must be running locally to setup ADB device reverse tethering.");
157
+ const certPath = path$1.join(this.caPathDir, "ca.pem");
158
+ if (!fs.existsSync(certPath)) return ResponseBuilder.error("CA certificate not found. Start the proxy with HTTPS enabled first.");
159
+ const { exec } = await import("child_process");
160
+ const { promisify } = await import("util");
161
+ const execAsync = promisify(exec);
162
+ const deviceSerial = argString(args, "deviceSerial");
163
+ const deviceFlag = deviceSerial ? `-s ${deviceSerial}` : "";
164
+ try {
165
+ try {
166
+ await execAsync("adb version");
167
+ } catch (error) {
168
+ const message = error instanceof Error ? error.message : String(error);
169
+ return R.fail(`ADB binary not available: ${message}`).merge({
170
+ available: false,
171
+ capability: "adb_binary",
172
+ status: "unavailable",
173
+ fix: "Install Android Platform Tools and ensure `adb` is available on PATH."
174
+ }).json();
175
+ }
176
+ await execAsync(`adb ${deviceFlag} get-state`);
177
+ await execAsync(`adb ${deviceFlag} push "${certPath}" /data/local/tmp/ca.pem`);
178
+ await execAsync(`adb ${deviceFlag} reverse tcp:${port} tcp:${port}`);
179
+ await execAsync(`adb ${deviceFlag} shell settings put global http_proxy 127.0.0.1:${port}`);
180
+ 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.`;
181
+ return ResponseBuilder.success({
182
+ message: "ADB device successfully configured.",
183
+ deviceId: deviceSerial || "default",
184
+ instructions
185
+ });
186
+ } catch (e) {
187
+ return ResponseBuilder.error(`Failed to configure ADB device: ${e.message}`);
188
+ }
189
+ }
190
+ };
191
+ //#endregion
192
+ export { ProxyHandlers };
@@ -0,0 +1,34 @@
1
+ import { n as DOMInspector, r as CodeCollector, t as ScriptManager } from "./ScriptManager-ZuWD-0Jg.mjs";
2
+ import { t as PageController } from "./PageController-BPJNqqBN.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-DykL3IAw.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,34 @@
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 isToolResponse(value) {
19
+ return value !== null && typeof value === "object" && Array.isArray(value.content);
20
+ }
21
+ function asToolResponse(payload) {
22
+ return isToolResponse(payload) ? payload : asJsonResponse(payload);
23
+ }
24
+ function asErrorResponse(error) {
25
+ return asTextResponse(`Error: ${toErrorMessage(error)}`, true);
26
+ }
27
+ function serializeError(error) {
28
+ return {
29
+ success: false,
30
+ error: toErrorMessage(error)
31
+ };
32
+ }
33
+ //#endregion
34
+ export { serializeError as a, asToolResponse as i, asJsonResponse as n, asTextResponse as r, asErrorResponse as t };
@@ -1,10 +1,10 @@
1
- import "node:fs/promises";
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();