@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,217 @@
|
|
|
1
|
+
import { t as logger } from "./logger-Dh_xb7_2.mjs";
|
|
2
|
+
import { I as DETAILED_DATA_DEFAULT_TTL_MS, L as DETAILED_DATA_MAX_TTL_MS, R as DETAILED_DATA_SMART_THRESHOLD_BYTES } from "./constants-B0OANIBL.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
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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-C0JGZoOm.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
|
/**
|
|
@@ -344,6 +346,11 @@ function buildListResult(ctx, pluginRoots, workflowRoots) {
|
|
|
344
346
|
}
|
|
345
347
|
//#endregion
|
|
346
348
|
//#region src/server/extensions/ExtensionManager.ts
|
|
349
|
+
var ExtensionManager_exports = /* @__PURE__ */ __exportAll({
|
|
350
|
+
ensureWorkflowsLoaded: () => ensureWorkflowsLoaded,
|
|
351
|
+
listExtensions: () => listExtensions,
|
|
352
|
+
reloadExtensions: () => reloadExtensions
|
|
353
|
+
});
|
|
347
354
|
function listExtensions(ctx) {
|
|
348
355
|
return buildListResult(ctx, resolveRoots(parseRoots(process.env.MCP_PLUGIN_ROOTS, DEFAULT_PLUGIN_ROOTS)), resolveRoots(parseRoots(process.env.MCP_WORKFLOW_ROOTS, DEFAULT_WORKFLOW_ROOTS)));
|
|
349
356
|
}
|
|
@@ -704,4 +711,4 @@ async function reloadExtensionsInner(ctx) {
|
|
|
704
711
|
};
|
|
705
712
|
}
|
|
706
713
|
//#endregion
|
|
707
|
-
export {
|
|
714
|
+
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-
|
|
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-
|
|
2
|
-
import { t as CloseHandle } from "./Win32API-
|
|
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-
|
|
1
|
+
import { _ as BREAKPOINT_TRACE_MAX_HITS, g as BREAKPOINT_HIT_TIMEOUT_MS } from "./constants-B0OANIBL.mjs";
|
|
2
|
+
import { t as CloseHandle } from "./Win32API-CePkipZY.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-BvKs-gxc.mjs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
//#region src/native/HardwareBreakpoint.ts
|
|
6
6
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as logger } from "./logger-
|
|
2
|
-
import { at as
|
|
3
|
-
import { b as openProcessForMemory, d as ReadProcessMemory, t as CloseHandle } from "./Win32API-
|
|
4
|
-
import { m as TH32CS } from "./Win32Debug-
|
|
1
|
+
import { t as logger } from "./logger-Dh_xb7_2.mjs";
|
|
2
|
+
import { at as HEAP_ENUMERATE_MAX_BLOCKS, ct as HEAP_SUSPICIOUS_BLOCK_SIZE, ot as HEAP_SPRAY_SIZE_TOLERANCE, st as HEAP_SPRAY_THRESHOLD } from "./constants-B0OANIBL.mjs";
|
|
3
|
+
import { b as openProcessForMemory, d as ReadProcessMemory, t as CloseHandle } from "./Win32API-CePkipZY.mjs";
|
|
4
|
+
import { m as TH32CS } from "./Win32Debug-BvKs-gxc.mjs";
|
|
5
5
|
import koffi from "koffi";
|
|
6
6
|
//#region src/native/HeapAnalyzer.types.ts
|
|
7
7
|
/** Heap block flags */
|