mirror of
https://github.com/morluto/rea
synced 2026-10-27 14:42:18 -04:00
12c416005f
* feat(javascript): recover code-split bundles from multiple inputs recover_javascript_sources accepted a single path, and validateModuleSet bound every module's provenance to that one snapshot. A code-split app (runtime + chunks, or an Electron main/preload/renderer set) had to be recovered one file per call, and modules recovered alone could not resolve imports across chunks: cross-chunk require(id) references stayed as numeric ids with property reads. Add an optional additional_paths input. The listed files are concatenated, in order after path, into the single engine snapshot, so one Wakaru run sees every module and cross-chunk imports resolve. validateModuleSet's single-snapshot binding is unchanged. Module provenance is attributed back to the input file its first extraction range starts in, with byte ranges rebased to that file's own offsets; a module whose ranges cross an input boundary keeps the concatenated snapshot identity and offsets, recorded as an explicit limitation. Single-path behavior is byte-for-byte unchanged (one segment, offset 0). Fixes #1605 * fix(javascript): preserve source identity in multi-input recovery --------- Co-authored-by: JingHao-Leon <w15909130000@gmail.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
42 lines
2.0 KiB
TypeScript
42 lines
2.0 KiB
TypeScript
import {
|
|
javascriptRecoveryInputSchema,
|
|
javascriptRecoveryResultSchema,
|
|
} from "../../domain/javascript/javascriptRecovery.js";
|
|
import { toolContractMetadata } from "../toolEffects.js";
|
|
import { evidenceResultOf } from "../toolOutputSchemaPrimitives.js";
|
|
import type { ToolContract } from "../toolContractTypes.js";
|
|
|
|
/** Derived script artifacts from optional upstream recovery adapters. */
|
|
export const JAVASCRIPT_RECOVERY_TOOL_CONTRACTS = [
|
|
{
|
|
name: "recover_javascript_sources",
|
|
...toolContractMetadata("recover_javascript_sources"),
|
|
kind: "application",
|
|
description:
|
|
"Recover readable modules from local UTF-8 JavaScript scripts/bundles into an absent directory, using caller-supplied Wakaru ^1.13.0 (verified with 1.14.0) on Linux x64. Use additional_paths for related chunks; each input retains its own snapshot and provenance. Returns original/derived digests, extraction byte ranges, emitted source maps, warnings and analysis_input inline. Structural splitting may fall back to one module; original names and runtime equivalence remain unknown. No application code execution. Requires util-linux prlimit; one worker, 1 GiB address-space ceiling, 120-second deadline, 64 MiB total input, 128 MiB output, 10000 entries and 8 MiB per diagnostic/report stream.",
|
|
inputSchema: javascriptRecoveryInputSchema,
|
|
outputSchema: evidenceResultOf(javascriptRecoveryResultSchema),
|
|
examples: [
|
|
{
|
|
title: "Recover a captured production bundle",
|
|
input: {
|
|
path: "/tmp/web-scripts/app.js",
|
|
output_directory: "/tmp/recovered-app",
|
|
},
|
|
},
|
|
{
|
|
title: "Recover a code-split bundle together",
|
|
input: {
|
|
path: "/tmp/web-scripts/main.js",
|
|
additional_paths: [
|
|
"/tmp/web-scripts/runtime.js",
|
|
"/tmp/web-scripts/shared.js",
|
|
"/tmp/web-scripts/checkout.chunk.js",
|
|
],
|
|
output_directory: "/tmp/recovered-chunks",
|
|
},
|
|
},
|
|
],
|
|
},
|
|
] as const satisfies readonly ToolContract[];
|