@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
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./chunk-CjcI7cDX.mjs";
2
- import { t as logger } from "./logger-BmWzC2lM.mjs";
2
+ import { t as logger } from "./logger-Dh_xb7_2.mjs";
3
3
  import koffi from "koffi";
4
4
  //#region src/native/platform/darwin/DarwinAPI.ts
5
5
  /**
@@ -0,0 +1,217 @@
1
+ import { t as logger } from "./logger-Dh_xb7_2.mjs";
2
+ import { L as DETAILED_DATA_DEFAULT_TTL_MS, R as DETAILED_DATA_MAX_TTL_MS, z as DETAILED_DATA_SMART_THRESHOLD_BYTES } from "./constants-CDZLOoVv.mjs";
3
+ //#region src/utils/DetailedDataManager.ts
4
+ var DetailedDataManager = class DetailedDataManager {
5
+ static instance;
6
+ cache = /* @__PURE__ */ new Map();
7
+ cleanupInterval = null;
8
+ DEFAULT_TTL = DETAILED_DATA_DEFAULT_TTL_MS;
9
+ MAX_TTL = DETAILED_DATA_MAX_TTL_MS;
10
+ MAX_CACHE_SIZE = 100;
11
+ AUTO_EXTEND_ON_ACCESS = true;
12
+ EXTEND_DURATION = 900 * 1e3;
13
+ /** Memo cache to avoid re-serializing the same object within a single call chain */
14
+ serializationMemo = /* @__PURE__ */ new WeakMap();
15
+ constructor() {
16
+ this.cleanupInterval = setInterval(() => this.cleanup(), 300 * 1e3);
17
+ if (typeof this.cleanupInterval === "object" && "unref" in this.cleanupInterval) this.cleanupInterval.unref();
18
+ }
19
+ /** @deprecated Use constructor injection. Kept for backward compatibility. */
20
+ static getInstance() {
21
+ if (!this.instance) this.instance = new DetailedDataManager();
22
+ return this.instance;
23
+ }
24
+ shutdown() {
25
+ if (this.cleanupInterval) {
26
+ clearInterval(this.cleanupInterval);
27
+ this.cleanupInterval = null;
28
+ }
29
+ this.cache.clear();
30
+ DetailedDataManager.instance = void 0;
31
+ logger.info("DetailedDataManager shut down");
32
+ }
33
+ /**
34
+ * Serialize data with memoization to avoid redundant JSON.stringify calls.
35
+ * Objects are cached in a WeakMap so the memo is automatically GC'd.
36
+ */
37
+ serializeWithMemo(data) {
38
+ if (data !== null && typeof data === "object") {
39
+ const cached = this.serializationMemo.get(data);
40
+ if (cached) return cached;
41
+ }
42
+ const json = JSON.stringify(data);
43
+ const result = {
44
+ json,
45
+ size: json.length
46
+ };
47
+ if (data !== null && typeof data === "object") this.serializationMemo.set(data, result);
48
+ return result;
49
+ }
50
+ isRecord(value) {
51
+ return value !== null && typeof value === "object";
52
+ }
53
+ readPathSegment(value, key) {
54
+ return Object(value)[key];
55
+ }
56
+ smartHandle(data, threshold = DETAILED_DATA_SMART_THRESHOLD_BYTES) {
57
+ if (data === null || data === void 0) return data;
58
+ if (typeof data !== "object" && typeof data !== "string") return data;
59
+ if (typeof data === "string") {
60
+ if (data.length <= threshold) return data;
61
+ }
62
+ const { json: jsonStr, size } = this.serializeWithMemo(data);
63
+ if (size <= threshold) return data;
64
+ logger.info(`Data too large (${(size / 1024).toFixed(1)}KB), returning summary with detailId`);
65
+ return this.createDetailedResponseWithSize(data, jsonStr, size);
66
+ }
67
+ createDetailedResponseWithSize(data, jsonStr, size) {
68
+ const detailId = this.storeWithSize(data, size);
69
+ return {
70
+ summary: this.generateSummaryFromJson(data, jsonStr, size),
71
+ detailId,
72
+ hint: `Data too large. Use get_detailed_data("${detailId}") to retrieve full data, or get_detailed_data("${detailId}", path="key.subkey") for specific part.`,
73
+ expiresAt: Date.now() + this.DEFAULT_TTL
74
+ };
75
+ }
76
+ store(data, customTTL) {
77
+ const { size } = this.serializeWithMemo(data);
78
+ return this.storeWithSize(data, size, customTTL);
79
+ }
80
+ storeWithSize(data, size, customTTL) {
81
+ if (this.cache.size >= this.MAX_CACHE_SIZE) this.evictLRU();
82
+ const detailId = `detail_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
83
+ const now = Date.now();
84
+ const ttl = customTTL || this.DEFAULT_TTL;
85
+ const entry = {
86
+ data,
87
+ expiresAt: now + ttl,
88
+ createdAt: now,
89
+ lastAccessedAt: now,
90
+ accessCount: 0,
91
+ size
92
+ };
93
+ this.cache.set(detailId, entry);
94
+ logger.debug(`Stored detailed data: ${detailId}, size: ${(size / 1024).toFixed(1)}KB, expires in ${ttl / 1e3}s`);
95
+ return detailId;
96
+ }
97
+ retrieve(detailId, path) {
98
+ const cached = this.cache.get(detailId);
99
+ if (!cached) throw new Error(`DetailId not found or expired: ${detailId}`);
100
+ const now = Date.now();
101
+ if (now > cached.expiresAt) {
102
+ this.cache.delete(detailId);
103
+ throw new Error(`DetailId expired: ${detailId}`);
104
+ }
105
+ cached.lastAccessedAt = now;
106
+ cached.accessCount++;
107
+ if (this.AUTO_EXTEND_ON_ACCESS) {
108
+ if (cached.expiresAt - now < 300 * 1e3) {
109
+ cached.expiresAt = Math.min(now + this.EXTEND_DURATION, now + this.MAX_TTL);
110
+ logger.debug(`Auto-extended detailId ${detailId}, new expiry: ${new Date(cached.expiresAt).toISOString()}`);
111
+ }
112
+ }
113
+ if (path) return this.getByPath(cached.data, path);
114
+ return cached.data;
115
+ }
116
+ getByPath(obj, path) {
117
+ const keys = path.split(".");
118
+ let current = obj;
119
+ for (const key of keys) {
120
+ if (current === null || current === void 0) throw new Error(`Path not found: ${path} (stopped at ${key})`);
121
+ current = this.readPathSegment(current, key);
122
+ }
123
+ return current;
124
+ }
125
+ generateSummaryFromJson(data, jsonStr, size) {
126
+ const summary = {
127
+ type: Array.isArray(data) ? "array" : typeof data,
128
+ size,
129
+ sizeKB: (size / 1024).toFixed(1) + "KB",
130
+ preview: jsonStr.substring(0, 200) + (size > 200 ? "..." : "")
131
+ };
132
+ if (this.isRecord(data)) {
133
+ const keys = Object.keys(data);
134
+ summary.structure = { keys: keys.slice(0, 50) };
135
+ if (!Array.isArray(data)) {
136
+ const methods = keys.filter((k) => typeof data[k] === "function");
137
+ const properties = keys.filter((k) => typeof data[k] !== "function");
138
+ summary.structure.methods = methods.slice(0, 30);
139
+ summary.structure.properties = properties.slice(0, 50);
140
+ } else summary.structure.length = data.length;
141
+ }
142
+ return summary;
143
+ }
144
+ cleanup() {
145
+ const now = Date.now();
146
+ let cleaned = 0;
147
+ for (const [id, cached] of this.cache.entries()) if (now > cached.expiresAt) {
148
+ this.cache.delete(id);
149
+ cleaned++;
150
+ }
151
+ if (cleaned > 0) logger.debug(`Cleaned ${cleaned} expired detailed data entries`);
152
+ }
153
+ evictLRU() {
154
+ if (this.cache.size === 0) return;
155
+ let oldestId = null;
156
+ let oldestAccessTime = Infinity;
157
+ for (const [id, entry] of this.cache.entries()) if (entry.lastAccessedAt < oldestAccessTime) {
158
+ oldestAccessTime = entry.lastAccessedAt;
159
+ oldestId = id;
160
+ }
161
+ if (oldestId) {
162
+ const entry = this.cache.get(oldestId);
163
+ this.cache.delete(oldestId);
164
+ logger.info(`Evicted LRU entry: ${oldestId}, last accessed: ${new Date(entry.lastAccessedAt).toISOString()}, access count: ${entry.accessCount}`);
165
+ }
166
+ }
167
+ extend(detailId, additionalTime) {
168
+ const cached = this.cache.get(detailId);
169
+ if (!cached) throw new Error(`DetailId not found: ${detailId}`);
170
+ const now = Date.now();
171
+ if (now > cached.expiresAt) throw new Error(`DetailId already expired: ${detailId}`);
172
+ const extendBy = additionalTime || this.EXTEND_DURATION;
173
+ const newExpiresAt = Math.min(cached.expiresAt + extendBy, now + this.MAX_TTL);
174
+ cached.expiresAt = newExpiresAt;
175
+ logger.info(`Extended detailId ${detailId} by ${extendBy / 1e3}s, new expiry: ${new Date(newExpiresAt).toISOString()}`);
176
+ }
177
+ getStats() {
178
+ let totalSize = 0;
179
+ let totalAccessCount = 0;
180
+ const entries = Array.from(this.cache.values());
181
+ for (const entry of entries) {
182
+ totalSize += entry.size;
183
+ totalAccessCount += entry.accessCount;
184
+ }
185
+ return {
186
+ cacheSize: this.cache.size,
187
+ maxCacheSize: this.MAX_CACHE_SIZE,
188
+ defaultTTLSeconds: this.DEFAULT_TTL / 1e3,
189
+ maxTTLSeconds: this.MAX_TTL / 1e3,
190
+ totalSizeKB: (totalSize / 1024).toFixed(1),
191
+ avgAccessCount: entries.length > 0 ? (totalAccessCount / entries.length).toFixed(1) : "0",
192
+ autoExtendEnabled: this.AUTO_EXTEND_ON_ACCESS,
193
+ extendDurationSeconds: this.EXTEND_DURATION / 1e3
194
+ };
195
+ }
196
+ getDetailedStats() {
197
+ const now = Date.now();
198
+ const entries = Array.from(this.cache.entries()).map(([id, entry]) => ({
199
+ detailId: id,
200
+ sizeKB: (entry.size / 1024).toFixed(1),
201
+ createdAt: new Date(entry.createdAt).toISOString(),
202
+ lastAccessedAt: new Date(entry.lastAccessedAt).toISOString(),
203
+ expiresAt: new Date(entry.expiresAt).toISOString(),
204
+ remainingSeconds: Math.max(0, Math.floor((entry.expiresAt - now) / 1e3)),
205
+ accessCount: entry.accessCount,
206
+ isExpired: now > entry.expiresAt
207
+ }));
208
+ entries.sort((a, b) => new Date(b.lastAccessedAt).getTime() - new Date(a.lastAccessedAt).getTime());
209
+ return entries;
210
+ }
211
+ clear() {
212
+ this.cache.clear();
213
+ logger.info("Cleared all detailed data cache");
214
+ }
215
+ };
216
+ //#endregion
217
+ export { DetailedDataManager as t };
@@ -0,0 +1,141 @@
1
+ //#region src/server/EventBus.ts
2
+ var EventBus = class {
3
+ listeners = /* @__PURE__ */ new Map();
4
+ wildcardListeners = [];
5
+ /**
6
+ * Subscribe to a specific event.
7
+ * Returns an unsubscribe function.
8
+ */
9
+ on(event, handler) {
10
+ const subs = this.listeners.get(event) ?? [];
11
+ const subscription = {
12
+ handler,
13
+ once: false
14
+ };
15
+ subs.push(subscription);
16
+ this.listeners.set(event, subs);
17
+ return () => {
18
+ const list = this.listeners.get(event);
19
+ if (list) {
20
+ const idx = list.indexOf(subscription);
21
+ if (idx >= 0) list.splice(idx, 1);
22
+ }
23
+ };
24
+ }
25
+ /**
26
+ * Subscribe to a specific event, auto-unsubscribing after the first fire.
27
+ */
28
+ once(event, handler) {
29
+ const subs = this.listeners.get(event) ?? [];
30
+ const subscription = {
31
+ handler,
32
+ once: true
33
+ };
34
+ subs.push(subscription);
35
+ this.listeners.set(event, subs);
36
+ return () => {
37
+ const list = this.listeners.get(event);
38
+ if (list) {
39
+ const idx = list.indexOf(subscription);
40
+ if (idx >= 0) list.splice(idx, 1);
41
+ }
42
+ };
43
+ }
44
+ /**
45
+ * Subscribe to all events (wildcard listener).
46
+ */
47
+ onAny(handler) {
48
+ const subscription = {
49
+ handler,
50
+ once: false
51
+ };
52
+ this.wildcardListeners.push(subscription);
53
+ return () => {
54
+ const idx = this.wildcardListeners.indexOf(subscription);
55
+ if (idx >= 0) this.wildcardListeners.splice(idx, 1);
56
+ };
57
+ }
58
+ /**
59
+ * Emit an event to all registered listeners.
60
+ *
61
+ * Named listeners run sequentially (preserving ordering semantics).
62
+ * Wildcard listeners run in parallel via Promise.allSettled since they
63
+ * are observability/telemetry side-effects whose ordering does not matter.
64
+ * Errors in one listener never prevent others from running.
65
+ */
66
+ async emit(event, payload) {
67
+ const subs = this.listeners.get(event);
68
+ if (subs) {
69
+ const toRemove = [];
70
+ for (let i = 0; i < subs.length; i++) {
71
+ const sub = subs[i];
72
+ if (!sub) continue;
73
+ try {
74
+ await sub.handler(payload);
75
+ } catch {}
76
+ if (sub.once) toRemove.push(i);
77
+ }
78
+ for (let i = toRemove.length - 1; i >= 0; i--) subs.splice(toRemove[i], 1);
79
+ }
80
+ if (this.wildcardListeners.length > 0) {
81
+ const wildPayload = {
82
+ event,
83
+ payload
84
+ };
85
+ const promises = this.wildcardListeners.map((sub) => {
86
+ try {
87
+ return Promise.resolve(sub.handler(wildPayload));
88
+ } catch {
89
+ return Promise.resolve();
90
+ }
91
+ });
92
+ await Promise.allSettled(promises);
93
+ }
94
+ }
95
+ /**
96
+ * Remove all listeners for a specific event, or all listeners if no event specified.
97
+ */
98
+ removeAllListeners(event) {
99
+ if (event) this.listeners.delete(event);
100
+ else {
101
+ this.listeners.clear();
102
+ this.wildcardListeners.length = 0;
103
+ }
104
+ }
105
+ /**
106
+ * Get the number of listeners for a specific event.
107
+ */
108
+ listenerCount(event) {
109
+ return this.listeners.get(event)?.length ?? 0;
110
+ }
111
+ };
112
+ /**
113
+ * Singleton-style factory for the server event bus.
114
+ * Call `createServerEventBus()` once during server init.
115
+ */
116
+ function createServerEventBus() {
117
+ return new EventBus();
118
+ }
119
+ /**
120
+ * Creates a debounced progress emitter for tool handlers.
121
+ * @param eventBus The server event bus
122
+ * @param progressToken The progress token from args._meta.progressToken
123
+ * @param debounceMs Minimum time between emissions (defaults to 500ms)
124
+ */
125
+ function createProgressDebouncer(eventBus, progressToken, debounceMs = 500) {
126
+ let lastEmit = 0;
127
+ return (progress, total) => {
128
+ const now = Date.now();
129
+ if (now - lastEmit >= debounceMs || progress === total) {
130
+ lastEmit = now;
131
+ eventBus.emit("tool:progress", {
132
+ progressToken,
133
+ progress,
134
+ total,
135
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
136
+ });
137
+ }
138
+ };
139
+ }
140
+ //#endregion
141
+ export { createServerEventBus as n, createProgressDebouncer as t };
@@ -0,0 +1,153 @@
1
+ //#region src/server/instrumentation/EvidenceGraphBridge.ts
2
+ var EvidenceGraphBridge = class {
3
+ /** Maps operationId → primary evidence node ID for edge linking. */
4
+ operationNodeMap = /* @__PURE__ */ new Map();
5
+ /** Maps operationId → request node ID for manual linking / replay chaining. */
6
+ requestNodeMap = /* @__PURE__ */ new Map();
7
+ constructor(graph) {
8
+ this.graph = graph;
9
+ }
10
+ getString(value) {
11
+ return typeof value === "string" && value.length > 0 ? value : void 0;
12
+ }
13
+ getInitiatorLabel(config) {
14
+ const directInitiator = this.getString(config.initiator);
15
+ if (directInitiator) return directInitiator;
16
+ const directStack = this.getString(config.initiatorStack);
17
+ if (directStack) return directStack;
18
+ const initiator = config.initiator;
19
+ if (initiator && typeof initiator === "object") {
20
+ const record = initiator;
21
+ return this.getString(record.stack) ?? this.getString(record.url) ?? this.getString(record.type) ?? this.getString(record.name);
22
+ }
23
+ }
24
+ /** Manually link a request node to an initiator-stack node. */
25
+ linkRequestToInitiator(requestNodeId, initiatorStackNodeId) {
26
+ this.graph.addEdge(requestNodeId, initiatorStackNodeId, "initiates");
27
+ }
28
+ /**
29
+ * Called when a new operation is registered.
30
+ * Creates evidence node(s) based on operation type.
31
+ * Returns the primary evidence node ID (or null if no mapping).
32
+ */
33
+ onOperation(op) {
34
+ let primaryNodeId = null;
35
+ switch (op.type) {
36
+ case "runtime-hook": {
37
+ const funcNode = this.graph.addNode("function", op.target, {
38
+ functionName: op.target,
39
+ sessionId: op.sessionId,
40
+ operationId: op.id
41
+ });
42
+ const scriptId = this.getString(op.config.scriptId);
43
+ if (scriptId) {
44
+ const scriptNode = this.graph.addNode("script", `script:${scriptId}`, {
45
+ scriptId,
46
+ sessionId: op.sessionId,
47
+ operationId: op.id
48
+ });
49
+ this.graph.addEdge(scriptNode.id, funcNode.id, "contains");
50
+ }
51
+ const hookNode = this.graph.addNode("breakpoint-hook", `hook:${op.target}`, {
52
+ hookType: "runtime-hook",
53
+ sessionId: op.sessionId,
54
+ operationId: op.id,
55
+ config: op.config
56
+ });
57
+ this.graph.addEdge(funcNode.id, hookNode.id, "triggers");
58
+ primaryNodeId = hookNode.id;
59
+ break;
60
+ }
61
+ case "network-intercept": {
62
+ const reqNode = this.graph.addNode("request", op.target, {
63
+ url: op.target,
64
+ sessionId: op.sessionId,
65
+ operationId: op.id,
66
+ config: op.config
67
+ });
68
+ this.requestNodeMap.set(op.id, reqNode.id);
69
+ const initiatorLabel = this.getInitiatorLabel(op.config);
70
+ let initiatorNodeId = null;
71
+ if (initiatorLabel) {
72
+ const initiatorNode = this.graph.addNode("initiator-stack", initiatorLabel, {
73
+ sessionId: op.sessionId,
74
+ operationId: op.id,
75
+ initiator: op.config.initiator,
76
+ initiatorStack: op.config.initiatorStack
77
+ });
78
+ this.linkRequestToInitiator(reqNode.id, initiatorNode.id);
79
+ initiatorNodeId = initiatorNode.id;
80
+ }
81
+ const initiatorScriptId = this.getString(op.config.initiatorScriptId);
82
+ if (initiatorNodeId && initiatorScriptId) {
83
+ const scriptNode = this.graph.addNode("script", `script:${initiatorScriptId}`, {
84
+ scriptId: initiatorScriptId,
85
+ sessionId: op.sessionId,
86
+ operationId: op.id
87
+ });
88
+ this.graph.addEdge(initiatorNodeId, scriptNode.id, "loads");
89
+ }
90
+ primaryNodeId = reqNode.id;
91
+ break;
92
+ }
93
+ case "function-trace": {
94
+ const funcNode = this.graph.addNode("function", op.target, {
95
+ functionName: op.target,
96
+ sessionId: op.sessionId,
97
+ operationId: op.id,
98
+ traceMode: true
99
+ });
100
+ const scriptId = this.getString(op.config.scriptId);
101
+ if (scriptId) {
102
+ const scriptNode = this.graph.addNode("script", `script:${scriptId}`, {
103
+ scriptId,
104
+ sessionId: op.sessionId,
105
+ operationId: op.id
106
+ });
107
+ this.graph.addEdge(scriptNode.id, funcNode.id, "contains");
108
+ }
109
+ primaryNodeId = funcNode.id;
110
+ break;
111
+ }
112
+ case "before-load-inject":
113
+ primaryNodeId = this.graph.addNode("script", op.target, {
114
+ injectionPoint: "before-load",
115
+ sessionId: op.sessionId,
116
+ operationId: op.id
117
+ }).id;
118
+ break;
119
+ }
120
+ if (primaryNodeId) this.operationNodeMap.set(op.id, primaryNodeId);
121
+ return primaryNodeId;
122
+ }
123
+ /**
124
+ * Called when an artifact is captured.
125
+ * Creates a captured-data node and links it to the operation's evidence node.
126
+ * If the artifact represents a live replay, also creates a replay-artifact node.
127
+ */
128
+ onArtifact(artifact) {
129
+ const operationNodeId = this.operationNodeMap.get(artifact.operationId);
130
+ const dataNode = this.graph.addNode("captured-data", `data:${artifact.operationId}`, {
131
+ sessionId: artifact.sessionId,
132
+ operationId: artifact.operationId,
133
+ artifactType: artifact.type,
134
+ ...artifact.data
135
+ });
136
+ if (operationNodeId) this.graph.addEdge(operationNodeId, dataNode.id, "captures");
137
+ if (artifact.data.replayMode === "live") {
138
+ const replayNode = this.graph.addNode("replay-artifact", `replay:${artifact.operationId}`, {
139
+ sessionId: artifact.sessionId,
140
+ operationId: artifact.operationId,
141
+ artifactType: artifact.type,
142
+ replayMode: artifact.data.replayMode,
143
+ requestId: artifact.data.requestId,
144
+ url: artifact.data.url,
145
+ method: artifact.data.method,
146
+ statusCode: artifact.data.statusCode
147
+ });
148
+ this.graph.addEdge(dataNode.id, replayNode.id, "replays");
149
+ }
150
+ }
151
+ };
152
+ //#endregion
153
+ export { EvidenceGraphBridge };
@@ -1,10 +1,12 @@
1
- import { t as logger } from "./logger-BmWzC2lM.mjs";
2
- import { f as INSTALLED_EXTENSION_METADATA_FILENAME, t as allTools } from "./ToolCatalog-Bq4V2sbJ.mjs";
3
- import { readFile } from "node:fs/promises";
4
- import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
5
- import { fileURLToPath, pathToFileURL } from "node:url";
1
+ import { t as __exportAll } from "./chunk-CjcI7cDX.mjs";
2
+ import { t as logger } from "./logger-Dh_xb7_2.mjs";
3
+ import { t as allTools } from "./ToolCatalog-5OJdMiF0.mjs";
4
+ import { t as INSTALLED_EXTENSION_METADATA_FILENAME } from "./types-Bx92KJfT.mjs";
6
5
  import { createHash } from "node:crypto";
7
6
  import { existsSync, readFileSync } from "node:fs";
7
+ import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
8
+ import { fileURLToPath, pathToFileURL } from "node:url";
9
+ import { readFile } from "node:fs/promises";
8
10
  import { glob } from "tinyglobby";
9
11
  //#region src/server/extensions/ExtensionManager.roots.ts
10
12
  /**
@@ -152,6 +154,12 @@ function isWorkflowContract(value) {
152
154
  * Extension file discovery — prefers installed registry metadata, then falls back
153
155
  * to scanning plugin/workflow roots for legacy manifest files.
154
156
  */
157
+ function isJavaScriptLikeFile(file) {
158
+ return file.endsWith(".js") || file.endsWith(".mjs") || file.endsWith(".cjs");
159
+ }
160
+ function isTypeScriptLikeFile(file) {
161
+ return file.endsWith(".ts") || file.endsWith(".mts") || file.endsWith(".cts");
162
+ }
155
163
  async function collectMatchingFiles(roots, matcher) {
156
164
  const files = /* @__PURE__ */ new Set();
157
165
  for (const root of roots) {
@@ -161,6 +169,7 @@ async function collectMatchingFiles(roots, matcher) {
161
169
  cwd: root,
162
170
  absolute: true,
163
171
  onlyFiles: true,
172
+ dot: true,
164
173
  ignore: [
165
174
  "**/node_modules/**",
166
175
  "**/.git/**",
@@ -213,8 +222,8 @@ async function collectInstalledEntryCandidates(roots, kind) {
213
222
  candidates.push({
214
223
  file,
215
224
  key: normalizeExtensionCandidateKey(root, file),
216
- isJs: file.endsWith(".js"),
217
- isTs: file.endsWith(".ts"),
225
+ isJs: isJavaScriptLikeFile(file),
226
+ isTs: isTypeScriptLikeFile(file),
218
227
  rootIndex,
219
228
  priority: 0
220
229
  });
@@ -247,8 +256,8 @@ async function discoverPluginFiles(pluginRoots) {
247
256
  for (const file of files) candidates.push({
248
257
  file,
249
258
  key: normalizeExtensionCandidateKey(root, file),
250
- isJs: file.endsWith(".js"),
251
- isTs: file.endsWith(".ts"),
259
+ isJs: isJavaScriptLikeFile(file),
260
+ isTs: isTypeScriptLikeFile(file),
252
261
  rootIndex,
253
262
  priority: 1
254
263
  });
@@ -258,12 +267,12 @@ async function discoverPluginFiles(pluginRoots) {
258
267
  async function discoverWorkflowFiles(workflowRoots) {
259
268
  const candidates = await collectInstalledEntryCandidates(workflowRoots, "workflow");
260
269
  for (const [rootIndex, root] of workflowRoots.entries()) {
261
- const files = await collectMatchingFiles([root], (filename) => filename.endsWith(".workflow.js") || filename.endsWith(".workflow.ts") || filename === "workflow.js" || filename === "workflow.ts");
270
+ const files = await collectMatchingFiles([root], (filename) => filename.endsWith(".workflow.js") || filename.endsWith(".workflow.mjs") || filename.endsWith(".workflow.cjs") || filename.endsWith(".workflow.ts") || filename.endsWith(".workflow.mts") || filename.endsWith(".workflow.cts") || filename === "workflow.js" || filename === "workflow.mjs" || filename === "workflow.cjs" || filename === "workflow.ts" || filename === "workflow.mts" || filename === "workflow.cts");
262
271
  for (const file of files) candidates.push({
263
272
  file,
264
273
  key: normalizeExtensionCandidateKey(root, file),
265
- isJs: file.endsWith(".js"),
266
- isTs: file.endsWith(".ts"),
274
+ isJs: isJavaScriptLikeFile(file),
275
+ isTs: isTypeScriptLikeFile(file),
267
276
  rootIndex,
268
277
  priority: 1
269
278
  });
@@ -344,6 +353,11 @@ function buildListResult(ctx, pluginRoots, workflowRoots) {
344
353
  }
345
354
  //#endregion
346
355
  //#region src/server/extensions/ExtensionManager.ts
356
+ var ExtensionManager_exports = /* @__PURE__ */ __exportAll({
357
+ ensureWorkflowsLoaded: () => ensureWorkflowsLoaded,
358
+ listExtensions: () => listExtensions,
359
+ reloadExtensions: () => reloadExtensions
360
+ });
347
361
  function listExtensions(ctx) {
348
362
  return buildListResult(ctx, resolveRoots(parseRoots(process.env.MCP_PLUGIN_ROOTS, DEFAULT_PLUGIN_ROOTS)), resolveRoots(parseRoots(process.env.MCP_WORKFLOW_ROOTS, DEFAULT_WORKFLOW_ROOTS)));
349
363
  }
@@ -704,4 +718,4 @@ async function reloadExtensionsInner(ctx) {
704
718
  };
705
719
  }
706
720
  //#endregion
707
- export { listExtensions as n, reloadExtensions as r, ensureWorkflowsLoaded as t };
721
+ export { reloadExtensions as i, ensureWorkflowsLoaded as n, listExtensions as r, ExtensionManager_exports as t };
@@ -1,5 +1,5 @@
1
1
  import { n as __require } from "./chunk-CjcI7cDX.mjs";
2
- import { t as logger } from "./logger-BmWzC2lM.mjs";
2
+ import { t as logger } from "./logger-Dh_xb7_2.mjs";
3
3
  //#region src/modules/stealth/FingerprintManager.ts
4
4
  var FingerprintManager = class FingerprintManager {
5
5
  static instance = null;
@@ -1,6 +1,6 @@
1
- import { _ as BREAKPOINT_TRACE_MAX_HITS, g as BREAKPOINT_HIT_TIMEOUT_MS } from "./constants-CCvsN80K.mjs";
2
- import { t as CloseHandle } from "./Win32API-Bc0QnQsN.mjs";
3
- import { _ as openThreadForDebug, a as DebugActiveProcessStop, c as EnumerateProcessThreads, d as ResumeThread, f as SetThreadContext, g as encodeDR7, h as WaitForDebugEvent, i as DebugActiveProcess, n as ContinueDebugEvent, o as DebugSetProcessKillOnExit, p as SuspendThread, r as DBG, s as EXCEPTION_CODE, t as CONTEXT_FLAGS, u as GetThreadContext, v as parseContext, y as writeContext } from "./Win32Debug-DUHt9XUn.mjs";
1
+ import { _ as BREAKPOINT_HIT_TIMEOUT_MS, v as BREAKPOINT_TRACE_MAX_HITS } from "./constants-CDZLOoVv.mjs";
2
+ import { t as CloseHandle } from "./Win32API-C2kjj0ze.mjs";
3
+ import { _ as openThreadForDebug, a as DebugActiveProcessStop, c as EnumerateProcessThreads, d as ResumeThread, f as SetThreadContext, g as encodeDR7, h as WaitForDebugEvent, i as DebugActiveProcess, n as ContinueDebugEvent, o as DebugSetProcessKillOnExit, p as SuspendThread, r as DBG, s as EXCEPTION_CODE, t as CONTEXT_FLAGS, u as GetThreadContext, v as parseContext, y as writeContext } from "./Win32Debug-CKrGOTpo.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  //#region src/native/HardwareBreakpoint.ts
6
6
  /**