windows-exe-decompiler-mcp-server 0.1.0 → 0.1.3
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/CLAUDE_INSTALLATION.md +129 -0
- package/CODEX_INSTALLATION.md +25 -1
- package/COPILOT_INSTALLATION.md +29 -1
- package/LICENSE +21 -21
- package/README.md +232 -110
- package/dist/analysis-provenance.d.ts +50 -2
- package/dist/analysis-provenance.js +1 -0
- package/dist/analysis-task-runner.js +92 -0
- package/dist/config.d.ts +35 -16
- package/dist/config.js +37 -3
- package/dist/database.js +115 -115
- package/dist/decompiler-worker.d.ts +10 -5
- package/dist/decompiler-worker.js +240 -58
- package/dist/dynamic-trace.d.ts +6 -0
- package/dist/dynamic-trace.js +52 -1
- package/dist/ghidra-config.js +17 -1
- package/dist/index.js +38 -8
- package/dist/pe-runtime-functions.d.ts +90 -0
- package/dist/pe-runtime-functions.js +452 -0
- package/dist/prompts/module-reconstruction-review.d.ts +5 -0
- package/dist/prompts/module-reconstruction-review.js +65 -0
- package/dist/runtime-correlation.d.ts +5 -0
- package/dist/runtime-correlation.js +179 -2
- package/dist/sample-workspace.d.ts +28 -0
- package/dist/sample-workspace.js +186 -0
- package/dist/semantic-name-suggestion-artifacts.d.ts +56 -0
- package/dist/semantic-name-suggestion-artifacts.js +87 -0
- package/dist/server.js +1 -1
- package/dist/setup-guidance.d.ts +73 -0
- package/dist/setup-guidance.js +211 -0
- package/dist/tools/artifact-read.d.ts +10 -10
- package/dist/tools/artifacts-diff.d.ts +8 -8
- package/dist/tools/artifacts-list.d.ts +16 -16
- package/dist/tools/attack-map.d.ts +8 -8
- package/dist/tools/binary-role-profile.d.ts +1197 -0
- package/dist/tools/binary-role-profile.js +575 -0
- package/dist/tools/code-function-explain-apply.d.ts +12 -12
- package/dist/tools/code-function-explain-prepare.d.ts +12 -12
- package/dist/tools/code-function-explain-review.d.ts +58 -58
- package/dist/tools/code-function-rename-apply.d.ts +12 -12
- package/dist/tools/code-function-rename-prepare.d.ts +14 -14
- package/dist/tools/code-function-rename-review.d.ts +66 -66
- package/dist/tools/code-functions-define.d.ts +337 -0
- package/dist/tools/code-functions-define.js +337 -0
- package/dist/tools/code-functions-list.js +1 -1
- package/dist/tools/code-functions-rank.js +1 -1
- package/dist/tools/code-functions-reconstruct.d.ts +368 -58
- package/dist/tools/code-functions-reconstruct.js +130 -10
- package/dist/tools/code-functions-smart-recover.d.ts +352 -0
- package/dist/tools/code-functions-smart-recover.js +190 -0
- package/dist/tools/code-module-review-apply.d.ts +233 -0
- package/dist/tools/code-module-review-apply.js +209 -0
- package/dist/tools/code-module-review-prepare.d.ts +756 -0
- package/dist/tools/code-module-review-prepare.js +343 -0
- package/dist/tools/code-module-review.d.ts +474 -0
- package/dist/tools/code-module-review.js +566 -0
- package/dist/tools/code-reconstruct-export.d.ts +193 -21
- package/dist/tools/code-reconstruct-export.js +578 -21
- package/dist/tools/code-reconstruct-plan.d.ts +20 -20
- package/dist/tools/com-role-profile.d.ts +353 -0
- package/dist/tools/com-role-profile.js +186 -0
- package/dist/tools/dll-export-profile.d.ts +625 -0
- package/dist/tools/dll-export-profile.js +230 -0
- package/dist/tools/dotnet-metadata-extract.d.ts +122 -122
- package/dist/tools/dotnet-reconstruct-export.d.ts +49 -49
- package/dist/tools/dotnet-types-list.d.ts +66 -66
- package/dist/tools/dynamic-dependencies.d.ts +144 -8
- package/dist/tools/dynamic-dependencies.js +20 -1
- package/dist/tools/dynamic-memory-import.js +105 -2
- package/dist/tools/ghidra-analyze.d.ts +20 -0
- package/dist/tools/ghidra-analyze.js +10 -2
- package/dist/tools/ghidra-health.d.ts +177 -0
- package/dist/tools/ghidra-health.js +28 -0
- package/dist/tools/ioc-export.d.ts +8 -8
- package/dist/tools/packer-detect.d.ts +14 -14
- package/dist/tools/packer-detect.js +6 -9
- package/dist/tools/pe-exports-extract.d.ts +8 -8
- package/dist/tools/pe-exports-extract.js +6 -9
- package/dist/tools/pe-fingerprint.d.ts +36 -36
- package/dist/tools/pe-imports-extract.d.ts +8 -8
- package/dist/tools/pe-imports-extract.js +6 -9
- package/dist/tools/pe-pdata-extract.d.ts +448 -0
- package/dist/tools/pe-pdata-extract.js +219 -0
- package/dist/tools/pe-symbols-recover.d.ts +227 -0
- package/dist/tools/pe-symbols-recover.js +316 -0
- package/dist/tools/report-generate.d.ts +15 -1
- package/dist/tools/report-generate.js +139 -16
- package/dist/tools/report-summarize.d.ts +2242 -8
- package/dist/tools/report-summarize.js +246 -10
- package/dist/tools/runtime-detect.d.ts +8 -8
- package/dist/tools/runtime-detect.js +2 -12
- package/dist/tools/rust-binary-analyze.d.ts +2047 -0
- package/dist/tools/rust-binary-analyze.js +443 -0
- package/dist/tools/sample-profile-get.d.ts +135 -16
- package/dist/tools/sample-profile-get.js +35 -32
- package/dist/tools/sandbox-execute.d.ts +10 -10
- package/dist/tools/strings-extract.d.ts +8 -8
- package/dist/tools/strings-extract.js +2 -12
- package/dist/tools/strings-floss-decode.d.ts +8 -8
- package/dist/tools/system-health.d.ts +172 -36
- package/dist/tools/system-health.js +14 -0
- package/dist/tools/system-setup-guide.d.ts +179 -0
- package/dist/tools/system-setup-guide.js +62 -0
- package/dist/tools/tool-help.d.ts +16 -16
- package/dist/tools/tool-help.js +172 -0
- package/dist/tools/yara-scan.d.ts +8 -8
- package/dist/types.d.ts +2 -0
- package/dist/workflows/function-explanation-review.d.ts +3034 -76
- package/dist/workflows/function-explanation-review.js +172 -42
- package/dist/workflows/function-index-recover.d.ts +333 -0
- package/dist/workflows/function-index-recover.js +291 -0
- package/dist/workflows/module-reconstruction-review.d.ts +3537 -0
- package/dist/workflows/module-reconstruction-review.js +354 -0
- package/dist/workflows/reconstruct.d.ts +2182 -223
- package/dist/workflows/reconstruct.js +575 -32
- package/dist/workflows/semantic-name-review.d.ts +1436 -85
- package/dist/workflows/semantic-name-review.js +150 -58
- package/dist/workflows/triage.d.ts +8 -8
- package/ghidra_scripts/DecompileFunction.java +487 -487
- package/ghidra_scripts/ExtractCFG.java +256 -256
- package/ghidra_scripts/ExtractFunctions.java +442 -442
- package/ghidra_scripts/README.md +112 -112
- package/ghidra_scripts/SearchFunctionReferences.java +380 -380
- package/helpers/DotNetMetadataProbe/DotNetMetadataProbe.csproj +9 -9
- package/helpers/DotNetMetadataProbe/Program.cs +566 -566
- package/install-to-claude.ps1 +432 -0
- package/install-to-codex.ps1 +256 -178
- package/install-to-copilot.ps1 +389 -303
- package/package.json +4 -2
- package/requirements.txt +9 -9
- package/workers/requirements-dynamic.txt +11 -11
- package/workers/requirements.txt +8 -8
- package/workers/speakeasy_compat.py +175 -175
- package/workers/static_worker.py +3474 -3474
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* workflow.module_reconstruction_review
|
|
3
|
+
* High-level orchestration for module reconstruction review plus optional export refresh.
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { createCodeModuleReviewHandler } from '../tools/code-module-review.js';
|
|
7
|
+
import { createReconstructWorkflowHandler } from './reconstruct.js';
|
|
8
|
+
import { AnalysisProvenanceSchema } from '../analysis-provenance.js';
|
|
9
|
+
import { AnalysisSelectionDiffSchema } from '../selection-diff.js';
|
|
10
|
+
import { BinaryRoleProfileDataSchema } from '../tools/binary-role-profile.js';
|
|
11
|
+
import { RequiredUserInputSchema, SetupActionSchema, collectSetupGuidanceFromWorkerResult, mergeRequiredUserInputs, mergeSetupActions, } from '../setup-guidance.js';
|
|
12
|
+
const TOOL_NAME = 'workflow.module_reconstruction_review';
|
|
13
|
+
export const moduleReconstructionReviewWorkflowInputSchema = z
|
|
14
|
+
.object({
|
|
15
|
+
sample_id: z.string().describe('Sample ID (format: sha256:<hex>)'),
|
|
16
|
+
topk: z.number().int().min(1).max(40).default(12),
|
|
17
|
+
module_limit: z.number().int().min(1).max(12).default(6),
|
|
18
|
+
min_module_size: z.number().int().min(1).max(20).default(2),
|
|
19
|
+
include_imports: z.boolean().default(true),
|
|
20
|
+
include_strings: z.boolean().default(true),
|
|
21
|
+
analysis_goal: z
|
|
22
|
+
.string()
|
|
23
|
+
.min(1)
|
|
24
|
+
.max(400)
|
|
25
|
+
.default('Review reconstructed modules, refine their role labels, and propose evidence-grounded rewrite guidance.'),
|
|
26
|
+
session_tag: z.string().optional(),
|
|
27
|
+
evidence_scope: z.enum(['all', 'latest', 'session']).default('all'),
|
|
28
|
+
evidence_session_tag: z.string().optional(),
|
|
29
|
+
semantic_scope: z.enum(['all', 'latest', 'session']).default('all'),
|
|
30
|
+
semantic_session_tag: z.string().optional(),
|
|
31
|
+
compare_evidence_scope: z.enum(['all', 'latest', 'session']).optional(),
|
|
32
|
+
compare_evidence_session_tag: z.string().optional(),
|
|
33
|
+
compare_semantic_scope: z.enum(['all', 'latest', 'session']).optional(),
|
|
34
|
+
compare_semantic_session_tag: z.string().optional(),
|
|
35
|
+
role_target: z.string().min(1).max(64).optional(),
|
|
36
|
+
role_focus_areas: z.array(z.string().min(1).max(96)).max(16).default([]),
|
|
37
|
+
role_priority_order: z.array(z.string().min(1).max(96)).max(24).default([]),
|
|
38
|
+
persist_artifact: z.boolean().default(true),
|
|
39
|
+
auto_apply: z.boolean().default(true),
|
|
40
|
+
temperature: z.number().min(0).max(1).default(0.2),
|
|
41
|
+
max_tokens: z.number().int().min(200).max(8000).default(2400),
|
|
42
|
+
include_context: z.enum(['none', 'thisServer', 'allServers']).default('none'),
|
|
43
|
+
model_hint: z.string().min(1).max(120).optional(),
|
|
44
|
+
cost_priority: z.number().min(0).max(1).default(0.1),
|
|
45
|
+
speed_priority: z.number().min(0).max(1).default(0.2),
|
|
46
|
+
intelligence_priority: z.number().min(0).max(1).default(0.95),
|
|
47
|
+
system_prompt: z.string().min(1).max(800).optional(),
|
|
48
|
+
rerun_export: z.boolean().default(true),
|
|
49
|
+
export_path: z.enum(['auto', 'native', 'dotnet']).default('auto'),
|
|
50
|
+
export_topk: z.number().int().min(1).max(40).default(12),
|
|
51
|
+
export_name: z.string().min(1).max(64).optional(),
|
|
52
|
+
include_preflight: z.boolean().default(true),
|
|
53
|
+
auto_recover_function_index: z.boolean().default(true),
|
|
54
|
+
include_plan: z.boolean().default(false),
|
|
55
|
+
include_obfuscation_fallback: z.boolean().default(true),
|
|
56
|
+
fallback_on_error: z.boolean().default(true),
|
|
57
|
+
allow_partial: z.boolean().default(true),
|
|
58
|
+
validate_build: z.boolean().default(false),
|
|
59
|
+
run_harness: z.boolean().default(false),
|
|
60
|
+
compiler_path: z.string().min(1).max(260).optional(),
|
|
61
|
+
build_timeout_ms: z.number().int().min(5000).max(300000).default(60000),
|
|
62
|
+
run_timeout_ms: z.number().int().min(5000).max(300000).default(30000),
|
|
63
|
+
reuse_cached: z.boolean().default(true),
|
|
64
|
+
})
|
|
65
|
+
.refine((value) => value.evidence_scope !== 'session' || Boolean(value.evidence_session_tag?.trim()), {
|
|
66
|
+
message: 'evidence_session_tag is required when evidence_scope=session',
|
|
67
|
+
path: ['evidence_session_tag'],
|
|
68
|
+
})
|
|
69
|
+
.refine((value) => value.semantic_scope !== 'session' || Boolean(value.semantic_session_tag?.trim()), {
|
|
70
|
+
message: 'semantic_session_tag is required when semantic_scope=session',
|
|
71
|
+
path: ['semantic_session_tag'],
|
|
72
|
+
})
|
|
73
|
+
.refine((value) => value.compare_evidence_scope !== 'session' || Boolean(value.compare_evidence_session_tag?.trim()), {
|
|
74
|
+
message: 'compare_evidence_session_tag is required when compare_evidence_scope=session',
|
|
75
|
+
path: ['compare_evidence_session_tag'],
|
|
76
|
+
})
|
|
77
|
+
.refine((value) => value.compare_semantic_scope !== 'session' || Boolean(value.compare_semantic_session_tag?.trim()), {
|
|
78
|
+
message: 'compare_semantic_session_tag is required when compare_semantic_scope=session',
|
|
79
|
+
path: ['compare_semantic_session_tag'],
|
|
80
|
+
});
|
|
81
|
+
export const moduleReconstructionReviewWorkflowOutputSchema = z.object({
|
|
82
|
+
ok: z.boolean(),
|
|
83
|
+
data: z
|
|
84
|
+
.union([
|
|
85
|
+
z.object({
|
|
86
|
+
job_id: z.string(),
|
|
87
|
+
status: z.literal('queued'),
|
|
88
|
+
tool: z.literal(TOOL_NAME),
|
|
89
|
+
sample_id: z.string(),
|
|
90
|
+
progress: z.number().int().min(0).max(100),
|
|
91
|
+
}),
|
|
92
|
+
z.object({
|
|
93
|
+
sample_id: z.string(),
|
|
94
|
+
review: z.any(),
|
|
95
|
+
export: z.object({
|
|
96
|
+
attempted: z.boolean(),
|
|
97
|
+
status: z.enum(['completed', 'failed', 'skipped']),
|
|
98
|
+
selected_path: z.enum(['native', 'dotnet']).nullable(),
|
|
99
|
+
export_tool: z.string().nullable(),
|
|
100
|
+
export_root: z.string().nullable(),
|
|
101
|
+
manifest_path: z.string().nullable(),
|
|
102
|
+
build_validation_status: z.string().nullable(),
|
|
103
|
+
harness_validation_status: z.string().nullable(),
|
|
104
|
+
preflight: z
|
|
105
|
+
.object({
|
|
106
|
+
binary_profile: BinaryRoleProfileDataSchema.nullable(),
|
|
107
|
+
rust_profile: z.unknown().nullable(),
|
|
108
|
+
function_index_recovery: z.unknown().nullable(),
|
|
109
|
+
})
|
|
110
|
+
.nullable(),
|
|
111
|
+
provenance: AnalysisProvenanceSchema.nullable(),
|
|
112
|
+
selection_diffs: AnalysisSelectionDiffSchema.nullable(),
|
|
113
|
+
notes: z.array(z.string()),
|
|
114
|
+
}),
|
|
115
|
+
setup_actions: z.array(SetupActionSchema).optional(),
|
|
116
|
+
required_user_inputs: z.array(RequiredUserInputSchema).optional(),
|
|
117
|
+
next_steps: z.array(z.string()),
|
|
118
|
+
}),
|
|
119
|
+
])
|
|
120
|
+
.optional(),
|
|
121
|
+
warnings: z.array(z.string()).optional(),
|
|
122
|
+
errors: z.array(z.string()).optional(),
|
|
123
|
+
artifacts: z.array(z.any()).optional(),
|
|
124
|
+
setup_actions: z.array(SetupActionSchema).optional(),
|
|
125
|
+
required_user_inputs: z.array(RequiredUserInputSchema).optional(),
|
|
126
|
+
metrics: z.object({
|
|
127
|
+
elapsed_ms: z.number(),
|
|
128
|
+
tool: z.string(),
|
|
129
|
+
}).optional(),
|
|
130
|
+
});
|
|
131
|
+
export const moduleReconstructionReviewWorkflowToolDefinition = {
|
|
132
|
+
name: TOOL_NAME,
|
|
133
|
+
description: 'Run module-level reconstruction review end-to-end for any MCP-capable LLM client, then optionally refresh reconstruct/export output with the applied module reviews.',
|
|
134
|
+
inputSchema: moduleReconstructionReviewWorkflowInputSchema,
|
|
135
|
+
outputSchema: moduleReconstructionReviewWorkflowOutputSchema,
|
|
136
|
+
};
|
|
137
|
+
export function createModuleReconstructionReviewWorkflowHandler(workspaceManager, database, cacheManager, mcpServer, dependencies, jobQueue) {
|
|
138
|
+
const moduleReviewHandler = dependencies?.moduleReviewHandler ||
|
|
139
|
+
createCodeModuleReviewHandler(workspaceManager, database, cacheManager, mcpServer);
|
|
140
|
+
const reconstructWorkflowHandler = dependencies?.reconstructWorkflowHandler ||
|
|
141
|
+
createReconstructWorkflowHandler(workspaceManager, database, cacheManager);
|
|
142
|
+
return async (args) => {
|
|
143
|
+
const startTime = Date.now();
|
|
144
|
+
const warnings = [];
|
|
145
|
+
const errors = [];
|
|
146
|
+
const artifacts = [];
|
|
147
|
+
let setupActions = [];
|
|
148
|
+
let requiredUserInputs = [];
|
|
149
|
+
try {
|
|
150
|
+
const input = moduleReconstructionReviewWorkflowInputSchema.parse(args);
|
|
151
|
+
const sample = database.findSample(input.sample_id);
|
|
152
|
+
if (!sample) {
|
|
153
|
+
return {
|
|
154
|
+
ok: false,
|
|
155
|
+
errors: [`Sample not found: ${input.sample_id}`],
|
|
156
|
+
metrics: { elapsed_ms: Date.now() - startTime, tool: TOOL_NAME },
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
if (jobQueue) {
|
|
160
|
+
const jobTimeoutMs = Math.max(input.build_timeout_ms + input.run_timeout_ms + 45 * 60 * 1000, 60 * 60 * 1000);
|
|
161
|
+
const jobId = jobQueue.enqueue({
|
|
162
|
+
type: 'static',
|
|
163
|
+
tool: TOOL_NAME,
|
|
164
|
+
sampleId: input.sample_id,
|
|
165
|
+
args: input,
|
|
166
|
+
priority: 5,
|
|
167
|
+
timeout: jobTimeoutMs,
|
|
168
|
+
retryPolicy: {
|
|
169
|
+
maxRetries: 1,
|
|
170
|
+
backoffMs: 5000,
|
|
171
|
+
retryableErrors: ['E_TIMEOUT', 'E_RESOURCE_EXHAUSTED'],
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
return {
|
|
175
|
+
ok: true,
|
|
176
|
+
data: {
|
|
177
|
+
job_id: jobId,
|
|
178
|
+
status: 'queued',
|
|
179
|
+
tool: TOOL_NAME,
|
|
180
|
+
sample_id: input.sample_id,
|
|
181
|
+
progress: 0,
|
|
182
|
+
},
|
|
183
|
+
metrics: { elapsed_ms: Date.now() - startTime, tool: TOOL_NAME },
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
const reviewResult = await moduleReviewHandler({
|
|
187
|
+
sample_id: input.sample_id,
|
|
188
|
+
topk: input.topk,
|
|
189
|
+
module_limit: input.module_limit,
|
|
190
|
+
min_module_size: input.min_module_size,
|
|
191
|
+
include_imports: input.include_imports,
|
|
192
|
+
include_strings: input.include_strings,
|
|
193
|
+
analysis_goal: input.analysis_goal,
|
|
194
|
+
session_tag: input.session_tag,
|
|
195
|
+
evidence_scope: input.evidence_scope,
|
|
196
|
+
evidence_session_tag: input.evidence_session_tag,
|
|
197
|
+
semantic_scope: input.semantic_scope,
|
|
198
|
+
semantic_session_tag: input.semantic_session_tag,
|
|
199
|
+
role_target: input.role_target,
|
|
200
|
+
role_focus_areas: input.role_focus_areas,
|
|
201
|
+
role_priority_order: input.role_priority_order,
|
|
202
|
+
persist_artifact: input.persist_artifact,
|
|
203
|
+
auto_apply: input.auto_apply,
|
|
204
|
+
temperature: input.temperature,
|
|
205
|
+
max_tokens: input.max_tokens,
|
|
206
|
+
include_context: input.include_context,
|
|
207
|
+
model_hint: input.model_hint,
|
|
208
|
+
cost_priority: input.cost_priority,
|
|
209
|
+
speed_priority: input.speed_priority,
|
|
210
|
+
intelligence_priority: input.intelligence_priority,
|
|
211
|
+
system_prompt: input.system_prompt,
|
|
212
|
+
});
|
|
213
|
+
warnings.push(...(reviewResult.warnings || []));
|
|
214
|
+
artifacts.push(...(reviewResult.artifacts || []));
|
|
215
|
+
{
|
|
216
|
+
const setupGuidance = collectSetupGuidanceFromWorkerResult(reviewResult);
|
|
217
|
+
setupActions = mergeSetupActions(setupActions, setupGuidance.setupActions);
|
|
218
|
+
requiredUserInputs = mergeRequiredUserInputs(requiredUserInputs, setupGuidance.requiredUserInputs);
|
|
219
|
+
}
|
|
220
|
+
if (!reviewResult.ok) {
|
|
221
|
+
return {
|
|
222
|
+
ok: false,
|
|
223
|
+
errors: reviewResult.errors || ['code.module.review failed'],
|
|
224
|
+
warnings: warnings.length > 0 ? warnings : undefined,
|
|
225
|
+
setup_actions: setupActions.length > 0 ? setupActions : undefined,
|
|
226
|
+
required_user_inputs: requiredUserInputs.length > 0 ? requiredUserInputs : undefined,
|
|
227
|
+
artifacts: artifacts.length > 0 ? artifacts : undefined,
|
|
228
|
+
metrics: { elapsed_ms: Date.now() - startTime, tool: TOOL_NAME },
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
const reviewData = (reviewResult.data || {});
|
|
232
|
+
const acceptedCount = Number(reviewData?.apply?.accepted_count || 0);
|
|
233
|
+
const canRefreshExport = input.rerun_export &&
|
|
234
|
+
reviewData.review_status === 'sampled_and_applied' &&
|
|
235
|
+
acceptedCount > 0;
|
|
236
|
+
let exportSummary = {
|
|
237
|
+
attempted: false,
|
|
238
|
+
status: 'skipped',
|
|
239
|
+
selected_path: null,
|
|
240
|
+
export_tool: null,
|
|
241
|
+
export_root: null,
|
|
242
|
+
manifest_path: null,
|
|
243
|
+
build_validation_status: null,
|
|
244
|
+
harness_validation_status: null,
|
|
245
|
+
preflight: null,
|
|
246
|
+
provenance: null,
|
|
247
|
+
selection_diffs: null,
|
|
248
|
+
notes: [],
|
|
249
|
+
};
|
|
250
|
+
if (canRefreshExport) {
|
|
251
|
+
const exportResult = await reconstructWorkflowHandler({
|
|
252
|
+
sample_id: input.sample_id,
|
|
253
|
+
path: input.export_path,
|
|
254
|
+
topk: input.export_topk,
|
|
255
|
+
export_name: input.export_name,
|
|
256
|
+
validate_build: input.validate_build,
|
|
257
|
+
run_harness: input.run_harness,
|
|
258
|
+
compiler_path: input.compiler_path,
|
|
259
|
+
build_timeout_ms: input.build_timeout_ms,
|
|
260
|
+
run_timeout_ms: input.run_timeout_ms,
|
|
261
|
+
evidence_scope: input.evidence_scope,
|
|
262
|
+
evidence_session_tag: input.evidence_session_tag,
|
|
263
|
+
compare_evidence_scope: input.compare_evidence_scope,
|
|
264
|
+
compare_evidence_session_tag: input.compare_evidence_session_tag,
|
|
265
|
+
semantic_scope: input.semantic_scope === 'all' && input.session_tag ? 'session' : input.semantic_scope,
|
|
266
|
+
semantic_session_tag: input.semantic_session_tag || input.session_tag,
|
|
267
|
+
compare_semantic_scope: input.compare_semantic_scope,
|
|
268
|
+
compare_semantic_session_tag: input.compare_semantic_session_tag,
|
|
269
|
+
include_preflight: input.include_preflight,
|
|
270
|
+
auto_recover_function_index: input.auto_recover_function_index,
|
|
271
|
+
include_plan: input.include_plan,
|
|
272
|
+
include_obfuscation_fallback: input.include_obfuscation_fallback,
|
|
273
|
+
fallback_on_error: input.fallback_on_error,
|
|
274
|
+
allow_partial: input.allow_partial,
|
|
275
|
+
reuse_cached: input.reuse_cached,
|
|
276
|
+
});
|
|
277
|
+
warnings.push(...(exportResult.warnings || []));
|
|
278
|
+
artifacts.push(...(exportResult.artifacts || []));
|
|
279
|
+
{
|
|
280
|
+
const setupGuidance = collectSetupGuidanceFromWorkerResult(exportResult);
|
|
281
|
+
setupActions = mergeSetupActions(setupActions, setupGuidance.setupActions);
|
|
282
|
+
requiredUserInputs = mergeRequiredUserInputs(requiredUserInputs, setupGuidance.requiredUserInputs);
|
|
283
|
+
}
|
|
284
|
+
if (!exportResult.ok) {
|
|
285
|
+
errors.push(...(exportResult.errors || ['workflow.reconstruct failed during export refresh']));
|
|
286
|
+
exportSummary = {
|
|
287
|
+
attempted: true,
|
|
288
|
+
status: 'failed',
|
|
289
|
+
selected_path: null,
|
|
290
|
+
export_tool: null,
|
|
291
|
+
export_root: null,
|
|
292
|
+
manifest_path: null,
|
|
293
|
+
build_validation_status: null,
|
|
294
|
+
harness_validation_status: null,
|
|
295
|
+
preflight: null,
|
|
296
|
+
provenance: null,
|
|
297
|
+
selection_diffs: null,
|
|
298
|
+
notes: ['Refresh export failed after module review apply.'],
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
const exportData = (exportResult.data || {});
|
|
303
|
+
exportSummary = {
|
|
304
|
+
attempted: true,
|
|
305
|
+
status: 'completed',
|
|
306
|
+
selected_path: exportData.selected_path || null,
|
|
307
|
+
export_tool: exportData.export?.tool || null,
|
|
308
|
+
export_root: exportData.export?.export_root || null,
|
|
309
|
+
manifest_path: exportData.export?.manifest_path || null,
|
|
310
|
+
build_validation_status: exportData.export?.build_validation_status || null,
|
|
311
|
+
harness_validation_status: exportData.export?.harness_validation_status || null,
|
|
312
|
+
preflight: exportData.preflight || null,
|
|
313
|
+
provenance: exportData.provenance || null,
|
|
314
|
+
selection_diffs: exportData.selection_diffs || null,
|
|
315
|
+
notes: Array.isArray(exportData.notes) ? exportData.notes : [],
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
else if (input.rerun_export) {
|
|
320
|
+
exportSummary.notes.push(reviewData.review_status === 'prompt_contract_only'
|
|
321
|
+
? 'Refresh export skipped because no sampled module reviews were applied yet.'
|
|
322
|
+
: 'Refresh export skipped because no module review artifacts were applied.');
|
|
323
|
+
}
|
|
324
|
+
return {
|
|
325
|
+
ok: errors.length === 0,
|
|
326
|
+
data: {
|
|
327
|
+
sample_id: input.sample_id,
|
|
328
|
+
review: reviewData,
|
|
329
|
+
export: exportSummary,
|
|
330
|
+
setup_actions: setupActions.length > 0 ? setupActions : undefined,
|
|
331
|
+
required_user_inputs: requiredUserInputs.length > 0 ? requiredUserInputs : undefined,
|
|
332
|
+
next_steps: [
|
|
333
|
+
...(Array.isArray(reviewData.next_steps) ? reviewData.next_steps : []),
|
|
334
|
+
...exportSummary.notes,
|
|
335
|
+
],
|
|
336
|
+
},
|
|
337
|
+
warnings: warnings.length > 0 ? warnings : undefined,
|
|
338
|
+
errors: errors.length > 0 ? errors : undefined,
|
|
339
|
+
setup_actions: setupActions.length > 0 ? setupActions : undefined,
|
|
340
|
+
required_user_inputs: requiredUserInputs.length > 0 ? requiredUserInputs : undefined,
|
|
341
|
+
artifacts: artifacts.length > 0 ? artifacts : undefined,
|
|
342
|
+
metrics: { elapsed_ms: Date.now() - startTime, tool: TOOL_NAME },
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
catch (error) {
|
|
346
|
+
return {
|
|
347
|
+
ok: false,
|
|
348
|
+
errors: [error instanceof Error ? error.message : String(error)],
|
|
349
|
+
metrics: { elapsed_ms: Date.now() - startTime, tool: TOOL_NAME },
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
//# sourceMappingURL=module-reconstruction-review.js.map
|