windows-exe-decompiler-mcp-server 0.1.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 (190) hide show
  1. package/CODEX_INSTALLATION.md +69 -0
  2. package/COPILOT_INSTALLATION.md +77 -0
  3. package/LICENSE +21 -0
  4. package/README.md +314 -0
  5. package/bin/windows-exe-decompiler-mcp-server.js +3 -0
  6. package/dist/analysis-provenance.d.ts +184 -0
  7. package/dist/analysis-provenance.js +74 -0
  8. package/dist/analysis-task-runner.d.ts +31 -0
  9. package/dist/analysis-task-runner.js +160 -0
  10. package/dist/artifact-inventory.d.ts +23 -0
  11. package/dist/artifact-inventory.js +175 -0
  12. package/dist/cache-manager.d.ts +128 -0
  13. package/dist/cache-manager.js +454 -0
  14. package/dist/confidence-semantics.d.ts +66 -0
  15. package/dist/confidence-semantics.js +122 -0
  16. package/dist/config.d.ts +335 -0
  17. package/dist/config.js +193 -0
  18. package/dist/database.d.ts +227 -0
  19. package/dist/database.js +601 -0
  20. package/dist/decompiler-worker.d.ts +441 -0
  21. package/dist/decompiler-worker.js +1962 -0
  22. package/dist/dynamic-trace.d.ts +95 -0
  23. package/dist/dynamic-trace.js +629 -0
  24. package/dist/env-validator.d.ts +15 -0
  25. package/dist/env-validator.js +249 -0
  26. package/dist/error-handler.d.ts +28 -0
  27. package/dist/error-handler.example.d.ts +22 -0
  28. package/dist/error-handler.example.js +141 -0
  29. package/dist/error-handler.js +139 -0
  30. package/dist/ghidra-analysis-status.d.ts +49 -0
  31. package/dist/ghidra-analysis-status.js +178 -0
  32. package/dist/ghidra-config.d.ts +134 -0
  33. package/dist/ghidra-config.js +464 -0
  34. package/dist/index.d.ts +9 -0
  35. package/dist/index.js +200 -0
  36. package/dist/job-queue.d.ts +169 -0
  37. package/dist/job-queue.js +407 -0
  38. package/dist/logger.d.ts +106 -0
  39. package/dist/logger.js +176 -0
  40. package/dist/policy-guard.d.ts +115 -0
  41. package/dist/policy-guard.js +243 -0
  42. package/dist/process-output.d.ts +15 -0
  43. package/dist/process-output.js +90 -0
  44. package/dist/prompts/function-explanation-review.d.ts +5 -0
  45. package/dist/prompts/function-explanation-review.js +64 -0
  46. package/dist/prompts/semantic-name-review.d.ts +5 -0
  47. package/dist/prompts/semantic-name-review.js +63 -0
  48. package/dist/runtime-correlation.d.ts +34 -0
  49. package/dist/runtime-correlation.js +279 -0
  50. package/dist/runtime-paths.d.ts +3 -0
  51. package/dist/runtime-paths.js +11 -0
  52. package/dist/selection-diff.d.ts +667 -0
  53. package/dist/selection-diff.js +53 -0
  54. package/dist/semantic-name-suggestion-artifacts.d.ts +116 -0
  55. package/dist/semantic-name-suggestion-artifacts.js +314 -0
  56. package/dist/server.d.ts +129 -0
  57. package/dist/server.js +578 -0
  58. package/dist/tools/artifact-read.d.ts +235 -0
  59. package/dist/tools/artifact-read.js +317 -0
  60. package/dist/tools/artifacts-diff.d.ts +728 -0
  61. package/dist/tools/artifacts-diff.js +304 -0
  62. package/dist/tools/artifacts-list.d.ts +515 -0
  63. package/dist/tools/artifacts-list.js +389 -0
  64. package/dist/tools/attack-map.d.ts +290 -0
  65. package/dist/tools/attack-map.js +519 -0
  66. package/dist/tools/cache-observability.d.ts +4 -0
  67. package/dist/tools/cache-observability.js +36 -0
  68. package/dist/tools/code-function-cfg.d.ts +50 -0
  69. package/dist/tools/code-function-cfg.js +102 -0
  70. package/dist/tools/code-function-decompile.d.ts +55 -0
  71. package/dist/tools/code-function-decompile.js +103 -0
  72. package/dist/tools/code-function-disassemble.d.ts +43 -0
  73. package/dist/tools/code-function-disassemble.js +185 -0
  74. package/dist/tools/code-function-explain-apply.d.ts +255 -0
  75. package/dist/tools/code-function-explain-apply.js +225 -0
  76. package/dist/tools/code-function-explain-prepare.d.ts +535 -0
  77. package/dist/tools/code-function-explain-prepare.js +276 -0
  78. package/dist/tools/code-function-explain-review.d.ts +397 -0
  79. package/dist/tools/code-function-explain-review.js +589 -0
  80. package/dist/tools/code-function-rename-apply.d.ts +248 -0
  81. package/dist/tools/code-function-rename-apply.js +220 -0
  82. package/dist/tools/code-function-rename-prepare.d.ts +506 -0
  83. package/dist/tools/code-function-rename-prepare.js +279 -0
  84. package/dist/tools/code-function-rename-review.d.ts +574 -0
  85. package/dist/tools/code-function-rename-review.js +761 -0
  86. package/dist/tools/code-functions-list.d.ts +37 -0
  87. package/dist/tools/code-functions-list.js +91 -0
  88. package/dist/tools/code-functions-rank.d.ts +34 -0
  89. package/dist/tools/code-functions-rank.js +90 -0
  90. package/dist/tools/code-functions-reconstruct.d.ts +2725 -0
  91. package/dist/tools/code-functions-reconstruct.js +2807 -0
  92. package/dist/tools/code-functions-search.d.ts +39 -0
  93. package/dist/tools/code-functions-search.js +90 -0
  94. package/dist/tools/code-reconstruct-export.d.ts +1212 -0
  95. package/dist/tools/code-reconstruct-export.js +4002 -0
  96. package/dist/tools/code-reconstruct-plan.d.ts +274 -0
  97. package/dist/tools/code-reconstruct-plan.js +342 -0
  98. package/dist/tools/dotnet-metadata-extract.d.ts +541 -0
  99. package/dist/tools/dotnet-metadata-extract.js +355 -0
  100. package/dist/tools/dotnet-reconstruct-export.d.ts +567 -0
  101. package/dist/tools/dotnet-reconstruct-export.js +1151 -0
  102. package/dist/tools/dotnet-types-list.d.ts +325 -0
  103. package/dist/tools/dotnet-types-list.js +201 -0
  104. package/dist/tools/dynamic-dependencies.d.ts +115 -0
  105. package/dist/tools/dynamic-dependencies.js +213 -0
  106. package/dist/tools/dynamic-memory-import.d.ts +10 -0
  107. package/dist/tools/dynamic-memory-import.js +567 -0
  108. package/dist/tools/dynamic-trace-import.d.ts +10 -0
  109. package/dist/tools/dynamic-trace-import.js +235 -0
  110. package/dist/tools/entrypoint-fallback-disasm.d.ts +30 -0
  111. package/dist/tools/entrypoint-fallback-disasm.js +89 -0
  112. package/dist/tools/ghidra-analyze.d.ts +88 -0
  113. package/dist/tools/ghidra-analyze.js +208 -0
  114. package/dist/tools/ghidra-health.d.ts +37 -0
  115. package/dist/tools/ghidra-health.js +212 -0
  116. package/dist/tools/ioc-export.d.ts +209 -0
  117. package/dist/tools/ioc-export.js +542 -0
  118. package/dist/tools/packer-detect.d.ts +165 -0
  119. package/dist/tools/packer-detect.js +284 -0
  120. package/dist/tools/pe-exports-extract.d.ts +175 -0
  121. package/dist/tools/pe-exports-extract.js +253 -0
  122. package/dist/tools/pe-fingerprint.d.ts +234 -0
  123. package/dist/tools/pe-fingerprint.js +269 -0
  124. package/dist/tools/pe-imports-extract.d.ts +105 -0
  125. package/dist/tools/pe-imports-extract.js +245 -0
  126. package/dist/tools/report-generate.d.ts +157 -0
  127. package/dist/tools/report-generate.js +457 -0
  128. package/dist/tools/report-summarize.d.ts +2131 -0
  129. package/dist/tools/report-summarize.js +596 -0
  130. package/dist/tools/runtime-detect.d.ts +135 -0
  131. package/dist/tools/runtime-detect.js +247 -0
  132. package/dist/tools/sample-ingest.d.ts +94 -0
  133. package/dist/tools/sample-ingest.js +327 -0
  134. package/dist/tools/sample-profile-get.d.ts +183 -0
  135. package/dist/tools/sample-profile-get.js +121 -0
  136. package/dist/tools/sandbox-execute.d.ts +441 -0
  137. package/dist/tools/sandbox-execute.js +392 -0
  138. package/dist/tools/strings-extract.d.ts +375 -0
  139. package/dist/tools/strings-extract.js +314 -0
  140. package/dist/tools/strings-floss-decode.d.ts +143 -0
  141. package/dist/tools/strings-floss-decode.js +259 -0
  142. package/dist/tools/system-health.d.ts +434 -0
  143. package/dist/tools/system-health.js +446 -0
  144. package/dist/tools/task-cancel.d.ts +21 -0
  145. package/dist/tools/task-cancel.js +70 -0
  146. package/dist/tools/task-status.d.ts +27 -0
  147. package/dist/tools/task-status.js +106 -0
  148. package/dist/tools/task-sweep.d.ts +22 -0
  149. package/dist/tools/task-sweep.js +77 -0
  150. package/dist/tools/tool-help.d.ts +340 -0
  151. package/dist/tools/tool-help.js +261 -0
  152. package/dist/tools/yara-scan.d.ts +554 -0
  153. package/dist/tools/yara-scan.js +313 -0
  154. package/dist/types.d.ts +266 -0
  155. package/dist/types.js +41 -0
  156. package/dist/worker-pool.d.ts +204 -0
  157. package/dist/worker-pool.js +650 -0
  158. package/dist/workflows/deep-static.d.ts +104 -0
  159. package/dist/workflows/deep-static.js +276 -0
  160. package/dist/workflows/function-explanation-review.d.ts +655 -0
  161. package/dist/workflows/function-explanation-review.js +440 -0
  162. package/dist/workflows/reconstruct.d.ts +2053 -0
  163. package/dist/workflows/reconstruct.js +666 -0
  164. package/dist/workflows/semantic-name-review.d.ts +2418 -0
  165. package/dist/workflows/semantic-name-review.js +521 -0
  166. package/dist/workflows/triage.d.ts +659 -0
  167. package/dist/workflows/triage.js +1374 -0
  168. package/dist/workspace-manager.d.ts +150 -0
  169. package/dist/workspace-manager.js +411 -0
  170. package/ghidra_scripts/DecompileFunction.java +487 -0
  171. package/ghidra_scripts/DecompileFunction.py +150 -0
  172. package/ghidra_scripts/ExtractCFG.java +256 -0
  173. package/ghidra_scripts/ExtractCFG.py +233 -0
  174. package/ghidra_scripts/ExtractFunctions.java +442 -0
  175. package/ghidra_scripts/ExtractFunctions.py +101 -0
  176. package/ghidra_scripts/README.md +125 -0
  177. package/ghidra_scripts/SearchFunctionReferences.java +380 -0
  178. package/helpers/DotNetMetadataProbe/DotNetMetadataProbe.csproj +9 -0
  179. package/helpers/DotNetMetadataProbe/Program.cs +566 -0
  180. package/install-to-codex.ps1 +178 -0
  181. package/install-to-copilot.ps1 +303 -0
  182. package/package.json +101 -0
  183. package/requirements.txt +9 -0
  184. package/workers/requirements-dynamic.txt +11 -0
  185. package/workers/requirements.txt +8 -0
  186. package/workers/speakeasy_compat.py +175 -0
  187. package/workers/static_worker.py +5183 -0
  188. package/workers/yara_rules/default.yar +33 -0
  189. package/workers/yara_rules/malware_families.yar +93 -0
  190. package/workers/yara_rules/packers.yar +80 -0
@@ -0,0 +1,276 @@
1
+ import { z } from 'zod';
2
+ import { createCodeFunctionsReconstructHandler } from './code-functions-reconstruct.js';
3
+ import { persistSemanticExplanationPrepareBundleArtifact, SEMANTIC_EXPLANATION_PREPARE_BUNDLE_ARTIFACT_TYPE, } from '../semantic-name-suggestion-artifacts.js';
4
+ import { buildFunctionExplanationReviewPromptText } from '../prompts/function-explanation-review.js';
5
+ const TOOL_NAME = 'code.function.explain.prepare';
6
+ const PreparedExplanationFunctionSchema = z.object({
7
+ function: z.string(),
8
+ address: z.string(),
9
+ confidence: z.number().min(0).max(1),
10
+ validated_name: z.string().nullable(),
11
+ resolution_source: z.string().nullable(),
12
+ semantic_summary: z.string(),
13
+ confidence_profile: z.any().optional(),
14
+ runtime_confidence_profile: z.any().nullable().optional(),
15
+ naming_confidence_profile: z.any().optional(),
16
+ behavior_tags: z.array(z.string()).optional(),
17
+ xref_signals: z.array(z.any()).optional(),
18
+ call_relationships: z.any().optional(),
19
+ runtime_context: z.any().nullable().optional(),
20
+ semantic_evidence: z.any().optional(),
21
+ source_like_snippet: z.string().nullable().optional(),
22
+ assembly_excerpt: z.string().nullable().optional(),
23
+ gaps: z.array(z.string()).optional(),
24
+ });
25
+ const PreparedExplanationBundleSchema = z.object({
26
+ schema_version: z.literal(1),
27
+ sample_id: z.string(),
28
+ analysis_goal: z.string(),
29
+ generated_at: z.string(),
30
+ selection: z.object({
31
+ address: z.string().nullable(),
32
+ symbol: z.string().nullable(),
33
+ topk: z.number().int().positive(),
34
+ max_functions: z.number().int().positive(),
35
+ include_resolved: z.boolean(),
36
+ evidence_scope: z.enum(['all', 'latest', 'session']),
37
+ evidence_session_tag: z.string().nullable(),
38
+ }),
39
+ output_contract: z.object({
40
+ output_root: z.literal('explanations'),
41
+ required_fields: z.array(z.string()),
42
+ }),
43
+ functions: z.array(PreparedExplanationFunctionSchema),
44
+ });
45
+ export const codeFunctionExplainPrepareInputSchema = z
46
+ .object({
47
+ sample_id: z.string().describe('Sample ID (format: sha256:<hex>)'),
48
+ address: z.string().optional().describe('Optional specific function address'),
49
+ symbol: z.string().optional().describe('Optional specific function symbol'),
50
+ topk: z
51
+ .number()
52
+ .int()
53
+ .min(1)
54
+ .max(20)
55
+ .default(6)
56
+ .describe('When address/symbol not provided, prepare up to top-K reconstructed functions'),
57
+ max_functions: z
58
+ .number()
59
+ .int()
60
+ .min(1)
61
+ .max(20)
62
+ .default(6)
63
+ .describe('Maximum number of functions included in the prepared explanation bundle'),
64
+ include_resolved: z
65
+ .boolean()
66
+ .default(true)
67
+ .describe('Include already resolved functions so the external LLM can explain stable names and unresolved ones together'),
68
+ analysis_goal: z
69
+ .string()
70
+ .min(1)
71
+ .max(400)
72
+ .default('Explain the prepared functions in plain language and propose evidence-grounded rewrite guidance.')
73
+ .describe('Human-readable analysis goal injected into the prompt contract for any external LLM'),
74
+ persist_artifact: z
75
+ .boolean()
76
+ .default(true)
77
+ .describe('Persist the prepared explanation bundle as a JSON artifact for later review and provenance'),
78
+ session_tag: z
79
+ .string()
80
+ .optional()
81
+ .describe('Optional semantic explanation session tag used for artifact grouping'),
82
+ evidence_scope: z
83
+ .enum(['all', 'latest', 'session'])
84
+ .default('all')
85
+ .describe('Runtime evidence scope forwarded to code.functions.reconstruct for explanation preparation'),
86
+ evidence_session_tag: z
87
+ .string()
88
+ .optional()
89
+ .describe('Optional runtime evidence session selector used when evidence_scope=session or to narrow all/latest results'),
90
+ })
91
+ .refine((value) => value.evidence_scope !== 'session' || Boolean(value.evidence_session_tag?.trim()), {
92
+ message: 'evidence_session_tag is required when evidence_scope=session',
93
+ path: ['evidence_session_tag'],
94
+ });
95
+ export const codeFunctionExplainPrepareOutputSchema = z.object({
96
+ ok: z.boolean(),
97
+ data: z
98
+ .object({
99
+ sample_id: z.string(),
100
+ analysis_goal: z.string(),
101
+ prepared_count: z.number().int().nonnegative(),
102
+ prompt_name: z.literal('reverse.function_explanation_review'),
103
+ prompt_arguments: z.object({
104
+ analysis_goal: z.string(),
105
+ prepared_bundle_json: z.string(),
106
+ }),
107
+ task_prompt: z.string(),
108
+ prepared_bundle: PreparedExplanationBundleSchema,
109
+ artifact: z
110
+ .object({
111
+ id: z.string(),
112
+ type: z.literal(SEMANTIC_EXPLANATION_PREPARE_BUNDLE_ARTIFACT_TYPE),
113
+ path: z.string(),
114
+ sha256: z.string(),
115
+ mime: z.string().optional(),
116
+ })
117
+ .optional(),
118
+ })
119
+ .optional(),
120
+ warnings: z.array(z.string()).optional(),
121
+ errors: z.array(z.string()).optional(),
122
+ artifacts: z.array(z.any()).optional(),
123
+ metrics: z
124
+ .object({
125
+ elapsed_ms: z.number(),
126
+ tool: z.string(),
127
+ })
128
+ .optional(),
129
+ });
130
+ export const codeFunctionExplainPrepareToolDefinition = {
131
+ name: TOOL_NAME,
132
+ description: 'Prepare a structured evidence bundle and MCP prompt contract so any tool-calling LLM can explain reconstructed functions and produce a universal output layer.',
133
+ inputSchema: codeFunctionExplainPrepareInputSchema,
134
+ outputSchema: codeFunctionExplainPrepareOutputSchema,
135
+ };
136
+ function dedupePreparedFunctions(functions) {
137
+ const seen = new Set();
138
+ const deduped = [];
139
+ for (const item of functions) {
140
+ const key = `${String(item?.address || 'unknown').toLowerCase()}::${String(item?.function || 'unknown').toLowerCase()}`;
141
+ if (seen.has(key)) {
142
+ continue;
143
+ }
144
+ seen.add(key);
145
+ deduped.push(item);
146
+ }
147
+ return deduped;
148
+ }
149
+ export function createCodeFunctionExplainPrepareHandler(workspaceManager, database, cacheManager, dependencies) {
150
+ const reconstructHandler = dependencies?.reconstructHandler ||
151
+ createCodeFunctionsReconstructHandler(workspaceManager, database, cacheManager);
152
+ return async (args) => {
153
+ const startTime = Date.now();
154
+ try {
155
+ const input = codeFunctionExplainPrepareInputSchema.parse(args);
156
+ const reconstructResult = await reconstructHandler({
157
+ sample_id: input.sample_id,
158
+ address: input.address,
159
+ symbol: input.symbol,
160
+ topk: input.topk,
161
+ include_xrefs: true,
162
+ max_pseudocode_lines: 80,
163
+ max_assembly_lines: 60,
164
+ timeout: 45,
165
+ evidence_scope: input.evidence_scope,
166
+ evidence_session_tag: input.evidence_session_tag,
167
+ });
168
+ if (!reconstructResult.ok) {
169
+ return {
170
+ ok: false,
171
+ errors: reconstructResult.errors || ['code.functions.reconstruct failed'],
172
+ warnings: reconstructResult.warnings,
173
+ metrics: {
174
+ elapsed_ms: Date.now() - startTime,
175
+ tool: TOOL_NAME,
176
+ },
177
+ };
178
+ }
179
+ const functions = dedupePreparedFunctions((reconstructResult.data?.functions || []))
180
+ .filter((item) => input.include_resolved || !item?.name_resolution?.validated_name)
181
+ .slice(0, input.max_functions)
182
+ .map((item) => ({
183
+ function: item.function,
184
+ address: item.address,
185
+ confidence: item.confidence,
186
+ validated_name: item?.name_resolution?.validated_name || null,
187
+ resolution_source: item?.name_resolution?.resolution_source || null,
188
+ semantic_summary: item.semantic_summary || '',
189
+ confidence_profile: item.confidence_profile,
190
+ runtime_confidence_profile: item.runtime_confidence_profile || null,
191
+ naming_confidence_profile: item.naming_confidence_profile,
192
+ behavior_tags: Array.isArray(item.behavior_tags) ? item.behavior_tags : [],
193
+ xref_signals: Array.isArray(item.xref_signals) ? item.xref_signals : [],
194
+ call_relationships: item.call_relationships || { callers: [], callees: [] },
195
+ runtime_context: item.runtime_context || null,
196
+ semantic_evidence: item.semantic_evidence || {},
197
+ source_like_snippet: item.source_like_snippet || null,
198
+ assembly_excerpt: item.assembly_excerpt || null,
199
+ gaps: Array.isArray(item.gaps) ? item.gaps : [],
200
+ }));
201
+ const preparedBundle = {
202
+ schema_version: 1,
203
+ sample_id: input.sample_id,
204
+ analysis_goal: input.analysis_goal,
205
+ generated_at: new Date().toISOString(),
206
+ selection: {
207
+ address: input.address || null,
208
+ symbol: input.symbol || null,
209
+ topk: input.topk,
210
+ max_functions: input.max_functions,
211
+ include_resolved: input.include_resolved,
212
+ evidence_scope: input.evidence_scope,
213
+ evidence_session_tag: input.evidence_session_tag || null,
214
+ },
215
+ output_contract: {
216
+ output_root: 'explanations',
217
+ required_fields: [
218
+ 'address_or_function',
219
+ 'summary',
220
+ 'behavior',
221
+ 'confidence',
222
+ 'assumptions',
223
+ 'evidence_used',
224
+ 'rewrite_guidance',
225
+ ],
226
+ },
227
+ functions,
228
+ };
229
+ const preparedBundleJson = JSON.stringify(preparedBundle, null, 2);
230
+ const taskPrompt = buildFunctionExplanationReviewPromptText(preparedBundleJson, input.analysis_goal);
231
+ const warnings = [...(reconstructResult.warnings || [])];
232
+ const artifacts = [];
233
+ let artifact;
234
+ if (functions.length === 0) {
235
+ warnings.push('No functions matched the explanation preparation filter. Consider include_resolved=true or a larger topk.');
236
+ }
237
+ if (input.persist_artifact) {
238
+ artifact = await persistSemanticExplanationPrepareBundleArtifact(workspaceManager, database, input.sample_id, preparedBundle, input.session_tag);
239
+ artifacts.push(artifact);
240
+ }
241
+ return {
242
+ ok: true,
243
+ data: {
244
+ sample_id: input.sample_id,
245
+ analysis_goal: input.analysis_goal,
246
+ prepared_count: functions.length,
247
+ prompt_name: 'reverse.function_explanation_review',
248
+ prompt_arguments: {
249
+ analysis_goal: input.analysis_goal,
250
+ prepared_bundle_json: preparedBundleJson,
251
+ },
252
+ task_prompt: taskPrompt,
253
+ prepared_bundle: preparedBundle,
254
+ artifact,
255
+ },
256
+ warnings: warnings.length > 0 ? warnings : undefined,
257
+ artifacts: artifacts.length > 0 ? artifacts : undefined,
258
+ metrics: {
259
+ elapsed_ms: Date.now() - startTime,
260
+ tool: TOOL_NAME,
261
+ },
262
+ };
263
+ }
264
+ catch (error) {
265
+ return {
266
+ ok: false,
267
+ errors: [error instanceof Error ? error.message : String(error)],
268
+ metrics: {
269
+ elapsed_ms: Date.now() - startTime,
270
+ tool: TOOL_NAME,
271
+ },
272
+ };
273
+ }
274
+ };
275
+ }
276
+ //# sourceMappingURL=code-function-explain-prepare.js.map
@@ -0,0 +1,397 @@
1
+ import { z } from 'zod';
2
+ import type { ClientCapabilities, CreateMessageRequest, CreateMessageResult, CreateMessageResultWithTools, Implementation } from '@modelcontextprotocol/sdk/types.js';
3
+ import type { ToolArgs, ToolDefinition, WorkerResult } from '../types.js';
4
+ import type { WorkspaceManager } from '../workspace-manager.js';
5
+ import type { DatabaseManager } from '../database.js';
6
+ import type { CacheManager } from '../cache-manager.js';
7
+ import type { MCPServer } from '../server.js';
8
+ export declare const codeFunctionExplainReviewInputSchema: z.ZodEffects<z.ZodObject<{
9
+ sample_id: z.ZodString;
10
+ address: z.ZodOptional<z.ZodString>;
11
+ symbol: z.ZodOptional<z.ZodString>;
12
+ topk: z.ZodDefault<z.ZodNumber>;
13
+ max_functions: z.ZodDefault<z.ZodNumber>;
14
+ include_resolved: z.ZodDefault<z.ZodBoolean>;
15
+ analysis_goal: z.ZodDefault<z.ZodString>;
16
+ session_tag: z.ZodOptional<z.ZodString>;
17
+ evidence_scope: z.ZodDefault<z.ZodEnum<["all", "latest", "session"]>>;
18
+ evidence_session_tag: z.ZodOptional<z.ZodString>;
19
+ persist_artifact: z.ZodDefault<z.ZodBoolean>;
20
+ auto_apply: z.ZodDefault<z.ZodBoolean>;
21
+ temperature: z.ZodDefault<z.ZodNumber>;
22
+ max_tokens: z.ZodDefault<z.ZodNumber>;
23
+ include_context: z.ZodDefault<z.ZodEnum<["none", "thisServer", "allServers"]>>;
24
+ model_hint: z.ZodOptional<z.ZodString>;
25
+ cost_priority: z.ZodDefault<z.ZodNumber>;
26
+ speed_priority: z.ZodDefault<z.ZodNumber>;
27
+ intelligence_priority: z.ZodDefault<z.ZodNumber>;
28
+ system_prompt: z.ZodOptional<z.ZodString>;
29
+ }, "strip", z.ZodTypeAny, {
30
+ sample_id: string;
31
+ evidence_scope: "all" | "latest" | "session";
32
+ temperature: number;
33
+ topk: number;
34
+ analysis_goal: string;
35
+ include_resolved: boolean;
36
+ max_functions: number;
37
+ persist_artifact: boolean;
38
+ auto_apply: boolean;
39
+ max_tokens: number;
40
+ include_context: "none" | "thisServer" | "allServers";
41
+ cost_priority: number;
42
+ speed_priority: number;
43
+ intelligence_priority: number;
44
+ symbol?: string | undefined;
45
+ address?: string | undefined;
46
+ session_tag?: string | undefined;
47
+ evidence_session_tag?: string | undefined;
48
+ model_hint?: string | undefined;
49
+ system_prompt?: string | undefined;
50
+ }, {
51
+ sample_id: string;
52
+ symbol?: string | undefined;
53
+ address?: string | undefined;
54
+ session_tag?: string | undefined;
55
+ evidence_scope?: "all" | "latest" | "session" | undefined;
56
+ temperature?: number | undefined;
57
+ topk?: number | undefined;
58
+ evidence_session_tag?: string | undefined;
59
+ analysis_goal?: string | undefined;
60
+ include_resolved?: boolean | undefined;
61
+ max_functions?: number | undefined;
62
+ persist_artifact?: boolean | undefined;
63
+ auto_apply?: boolean | undefined;
64
+ max_tokens?: number | undefined;
65
+ include_context?: "none" | "thisServer" | "allServers" | undefined;
66
+ model_hint?: string | undefined;
67
+ cost_priority?: number | undefined;
68
+ speed_priority?: number | undefined;
69
+ intelligence_priority?: number | undefined;
70
+ system_prompt?: string | undefined;
71
+ }>, {
72
+ sample_id: string;
73
+ evidence_scope: "all" | "latest" | "session";
74
+ temperature: number;
75
+ topk: number;
76
+ analysis_goal: string;
77
+ include_resolved: boolean;
78
+ max_functions: number;
79
+ persist_artifact: boolean;
80
+ auto_apply: boolean;
81
+ max_tokens: number;
82
+ include_context: "none" | "thisServer" | "allServers";
83
+ cost_priority: number;
84
+ speed_priority: number;
85
+ intelligence_priority: number;
86
+ symbol?: string | undefined;
87
+ address?: string | undefined;
88
+ session_tag?: string | undefined;
89
+ evidence_session_tag?: string | undefined;
90
+ model_hint?: string | undefined;
91
+ system_prompt?: string | undefined;
92
+ }, {
93
+ sample_id: string;
94
+ symbol?: string | undefined;
95
+ address?: string | undefined;
96
+ session_tag?: string | undefined;
97
+ evidence_scope?: "all" | "latest" | "session" | undefined;
98
+ temperature?: number | undefined;
99
+ topk?: number | undefined;
100
+ evidence_session_tag?: string | undefined;
101
+ analysis_goal?: string | undefined;
102
+ include_resolved?: boolean | undefined;
103
+ max_functions?: number | undefined;
104
+ persist_artifact?: boolean | undefined;
105
+ auto_apply?: boolean | undefined;
106
+ max_tokens?: number | undefined;
107
+ include_context?: "none" | "thisServer" | "allServers" | undefined;
108
+ model_hint?: string | undefined;
109
+ cost_priority?: number | undefined;
110
+ speed_priority?: number | undefined;
111
+ intelligence_priority?: number | undefined;
112
+ system_prompt?: string | undefined;
113
+ }>;
114
+ export declare const codeFunctionExplainReviewOutputSchema: z.ZodObject<{
115
+ ok: z.ZodBoolean;
116
+ data: z.ZodOptional<z.ZodObject<{
117
+ sample_id: z.ZodString;
118
+ review_status: z.ZodEnum<["sampled_and_applied", "sampled_only", "prompt_contract_only", "no_targets", "sampling_parse_failed"]>;
119
+ prompt_name: z.ZodLiteral<"reverse.function_explanation_review">;
120
+ prompt_arguments: z.ZodObject<{
121
+ analysis_goal: z.ZodString;
122
+ prepared_bundle_json: z.ZodString;
123
+ }, "strip", z.ZodTypeAny, {
124
+ prepared_bundle_json: string;
125
+ analysis_goal: string;
126
+ }, {
127
+ prepared_bundle_json: string;
128
+ analysis_goal: string;
129
+ }>;
130
+ task_prompt: z.ZodString;
131
+ client: z.ZodObject<{
132
+ name: z.ZodNullable<z.ZodString>;
133
+ version: z.ZodNullable<z.ZodString>;
134
+ sampling_available: z.ZodBoolean;
135
+ }, "strip", z.ZodTypeAny, {
136
+ name: string | null;
137
+ version: string | null;
138
+ sampling_available: boolean;
139
+ }, {
140
+ name: string | null;
141
+ version: string | null;
142
+ sampling_available: boolean;
143
+ }>;
144
+ prepare: z.ZodObject<{
145
+ prepared_count: z.ZodNumber;
146
+ artifact_id: z.ZodNullable<z.ZodString>;
147
+ }, "strip", z.ZodTypeAny, {
148
+ artifact_id: string | null;
149
+ prepared_count: number;
150
+ }, {
151
+ artifact_id: string | null;
152
+ prepared_count: number;
153
+ }>;
154
+ sampling: z.ZodObject<{
155
+ attempted: z.ZodBoolean;
156
+ model: z.ZodNullable<z.ZodString>;
157
+ stop_reason: z.ZodNullable<z.ZodString>;
158
+ response_text: z.ZodNullable<z.ZodString>;
159
+ parsed_explanation_count: z.ZodNumber;
160
+ }, "strip", z.ZodTypeAny, {
161
+ model: string | null;
162
+ attempted: boolean;
163
+ stop_reason: string | null;
164
+ response_text: string | null;
165
+ parsed_explanation_count: number;
166
+ }, {
167
+ model: string | null;
168
+ attempted: boolean;
169
+ stop_reason: string | null;
170
+ response_text: string | null;
171
+ parsed_explanation_count: number;
172
+ }>;
173
+ apply: z.ZodObject<{
174
+ attempted: z.ZodBoolean;
175
+ accepted_count: z.ZodNumber;
176
+ rejected_count: z.ZodNumber;
177
+ artifact_id: z.ZodNullable<z.ZodString>;
178
+ }, "strip", z.ZodTypeAny, {
179
+ artifact_id: string | null;
180
+ attempted: boolean;
181
+ accepted_count: number;
182
+ rejected_count: number;
183
+ }, {
184
+ artifact_id: string | null;
185
+ attempted: boolean;
186
+ accepted_count: number;
187
+ rejected_count: number;
188
+ }>;
189
+ confidence_policy: z.ZodObject<{
190
+ calibrated: z.ZodBoolean;
191
+ explanation_scores_are_heuristic: z.ZodBoolean;
192
+ meaning: z.ZodString;
193
+ }, "strip", z.ZodTypeAny, {
194
+ calibrated: boolean;
195
+ meaning: string;
196
+ explanation_scores_are_heuristic: boolean;
197
+ }, {
198
+ calibrated: boolean;
199
+ meaning: string;
200
+ explanation_scores_are_heuristic: boolean;
201
+ }>;
202
+ next_steps: z.ZodArray<z.ZodString, "many">;
203
+ }, "strip", z.ZodTypeAny, {
204
+ sample_id: string;
205
+ sampling: {
206
+ model: string | null;
207
+ attempted: boolean;
208
+ stop_reason: string | null;
209
+ response_text: string | null;
210
+ parsed_explanation_count: number;
211
+ };
212
+ client: {
213
+ name: string | null;
214
+ version: string | null;
215
+ sampling_available: boolean;
216
+ };
217
+ prompt_name: "reverse.function_explanation_review";
218
+ prompt_arguments: {
219
+ prepared_bundle_json: string;
220
+ analysis_goal: string;
221
+ };
222
+ task_prompt: string;
223
+ next_steps: string[];
224
+ review_status: "sampled_and_applied" | "sampled_only" | "prompt_contract_only" | "no_targets" | "sampling_parse_failed";
225
+ prepare: {
226
+ artifact_id: string | null;
227
+ prepared_count: number;
228
+ };
229
+ apply: {
230
+ artifact_id: string | null;
231
+ attempted: boolean;
232
+ accepted_count: number;
233
+ rejected_count: number;
234
+ };
235
+ confidence_policy: {
236
+ calibrated: boolean;
237
+ meaning: string;
238
+ explanation_scores_are_heuristic: boolean;
239
+ };
240
+ }, {
241
+ sample_id: string;
242
+ sampling: {
243
+ model: string | null;
244
+ attempted: boolean;
245
+ stop_reason: string | null;
246
+ response_text: string | null;
247
+ parsed_explanation_count: number;
248
+ };
249
+ client: {
250
+ name: string | null;
251
+ version: string | null;
252
+ sampling_available: boolean;
253
+ };
254
+ prompt_name: "reverse.function_explanation_review";
255
+ prompt_arguments: {
256
+ prepared_bundle_json: string;
257
+ analysis_goal: string;
258
+ };
259
+ task_prompt: string;
260
+ next_steps: string[];
261
+ review_status: "sampled_and_applied" | "sampled_only" | "prompt_contract_only" | "no_targets" | "sampling_parse_failed";
262
+ prepare: {
263
+ artifact_id: string | null;
264
+ prepared_count: number;
265
+ };
266
+ apply: {
267
+ artifact_id: string | null;
268
+ attempted: boolean;
269
+ accepted_count: number;
270
+ rejected_count: number;
271
+ };
272
+ confidence_policy: {
273
+ calibrated: boolean;
274
+ meaning: string;
275
+ explanation_scores_are_heuristic: boolean;
276
+ };
277
+ }>>;
278
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
279
+ errors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
280
+ artifacts: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
281
+ metrics: z.ZodOptional<z.ZodObject<{
282
+ elapsed_ms: z.ZodNumber;
283
+ tool: z.ZodString;
284
+ }, "strip", z.ZodTypeAny, {
285
+ elapsed_ms: number;
286
+ tool: string;
287
+ }, {
288
+ elapsed_ms: number;
289
+ tool: string;
290
+ }>>;
291
+ }, "strip", z.ZodTypeAny, {
292
+ ok: boolean;
293
+ metrics?: {
294
+ elapsed_ms: number;
295
+ tool: string;
296
+ } | undefined;
297
+ data?: {
298
+ sample_id: string;
299
+ sampling: {
300
+ model: string | null;
301
+ attempted: boolean;
302
+ stop_reason: string | null;
303
+ response_text: string | null;
304
+ parsed_explanation_count: number;
305
+ };
306
+ client: {
307
+ name: string | null;
308
+ version: string | null;
309
+ sampling_available: boolean;
310
+ };
311
+ prompt_name: "reverse.function_explanation_review";
312
+ prompt_arguments: {
313
+ prepared_bundle_json: string;
314
+ analysis_goal: string;
315
+ };
316
+ task_prompt: string;
317
+ next_steps: string[];
318
+ review_status: "sampled_and_applied" | "sampled_only" | "prompt_contract_only" | "no_targets" | "sampling_parse_failed";
319
+ prepare: {
320
+ artifact_id: string | null;
321
+ prepared_count: number;
322
+ };
323
+ apply: {
324
+ artifact_id: string | null;
325
+ attempted: boolean;
326
+ accepted_count: number;
327
+ rejected_count: number;
328
+ };
329
+ confidence_policy: {
330
+ calibrated: boolean;
331
+ meaning: string;
332
+ explanation_scores_are_heuristic: boolean;
333
+ };
334
+ } | undefined;
335
+ warnings?: string[] | undefined;
336
+ errors?: string[] | undefined;
337
+ artifacts?: any[] | undefined;
338
+ }, {
339
+ ok: boolean;
340
+ metrics?: {
341
+ elapsed_ms: number;
342
+ tool: string;
343
+ } | undefined;
344
+ data?: {
345
+ sample_id: string;
346
+ sampling: {
347
+ model: string | null;
348
+ attempted: boolean;
349
+ stop_reason: string | null;
350
+ response_text: string | null;
351
+ parsed_explanation_count: number;
352
+ };
353
+ client: {
354
+ name: string | null;
355
+ version: string | null;
356
+ sampling_available: boolean;
357
+ };
358
+ prompt_name: "reverse.function_explanation_review";
359
+ prompt_arguments: {
360
+ prepared_bundle_json: string;
361
+ analysis_goal: string;
362
+ };
363
+ task_prompt: string;
364
+ next_steps: string[];
365
+ review_status: "sampled_and_applied" | "sampled_only" | "prompt_contract_only" | "no_targets" | "sampling_parse_failed";
366
+ prepare: {
367
+ artifact_id: string | null;
368
+ prepared_count: number;
369
+ };
370
+ apply: {
371
+ artifact_id: string | null;
372
+ attempted: boolean;
373
+ accepted_count: number;
374
+ rejected_count: number;
375
+ };
376
+ confidence_policy: {
377
+ calibrated: boolean;
378
+ meaning: string;
379
+ explanation_scores_are_heuristic: boolean;
380
+ };
381
+ } | undefined;
382
+ warnings?: string[] | undefined;
383
+ errors?: string[] | undefined;
384
+ artifacts?: any[] | undefined;
385
+ }>;
386
+ export declare const codeFunctionExplainReviewToolDefinition: ToolDefinition;
387
+ type SamplingResult = CreateMessageResult | CreateMessageResultWithTools;
388
+ interface CodeFunctionExplainReviewDependencies {
389
+ prepareHandler?: (args: ToolArgs) => Promise<WorkerResult>;
390
+ applyHandler?: (args: ToolArgs) => Promise<WorkerResult>;
391
+ samplingRequester?: (params: CreateMessageRequest['params']) => Promise<SamplingResult>;
392
+ clientCapabilitiesProvider?: () => ClientCapabilities | undefined;
393
+ clientVersionProvider?: () => Implementation | undefined;
394
+ }
395
+ export declare function createCodeFunctionExplainReviewHandler(workspaceManager: WorkspaceManager, database: DatabaseManager, cacheManager: CacheManager, mcpServer?: MCPServer, dependencies?: CodeFunctionExplainReviewDependencies): (args: ToolArgs) => Promise<WorkerResult>;
396
+ export {};
397
+ //# sourceMappingURL=code-function-explain-review.d.ts.map