rea-agents 2.4.0 → 3.0.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.
- package/README.md +91 -19
- package/bridge/ghidra/ReaGhidraBridge.java +524 -4
- package/bridge/hopper_bridge.py +313 -28
- package/dist/application/AnalysisClientCleanup.js +14 -0
- package/dist/application/AnalysisContextQueries.js +130 -0
- package/dist/application/AnalysisSnapshotCache.js +4 -2
- package/dist/application/ApplicationWorkflowEvidenceResolver.js +31 -13
- package/dist/application/ArtifactInventory/scanCanonical.js +1 -1
- package/dist/application/BinarySession.js +20 -8
- package/dist/application/BinarySessionComposition.js +21 -0
- package/dist/application/BinarySessionRecords.js +79 -9
- package/dist/application/BinarySessionStatus.js +31 -1
- package/dist/application/BrowserEvidence.js +14 -0
- package/dist/application/BrowserScenarioCapturePort.js +1 -0
- package/dist/application/BrowserScenarioCaptureService.js +53 -0
- package/dist/application/BrowserScenarioEvidence.js +40 -0
- package/dist/application/CallPathTracing.js +160 -0
- package/dist/application/CapabilityInventory.js +84 -14
- package/dist/application/ClientRegistrationStatus.js +4 -1
- package/dist/application/CompositeProvider.js +10 -1
- package/dist/application/DirectAnalysis.js +13 -4
- package/dist/application/EnhancedLiteralTracing.js +118 -0
- package/dist/application/EnhancedTools.js +71 -127
- package/dist/application/EvidenceLedger.js +45 -16
- package/dist/application/JavaScriptApplicationWorkflowEvidence.js +13 -0
- package/dist/application/JavaScriptApplicationWorkflowService.js +27 -1
- package/dist/application/JavaScriptArtifactAnalysis.js +13 -4
- package/dist/application/JavaScriptRuntimeObservationEvidence.js +34 -0
- package/dist/application/JavaScriptRuntimeObservationPort.js +1 -0
- package/dist/application/JavaScriptRuntimeObservationService.js +46 -0
- package/dist/application/JavaScriptSemanticGraphAsyncProjection.js +147 -0
- package/dist/application/JavaScriptSemanticGraphBuilder.js +34 -6
- package/dist/application/JavaScriptSemanticGraphChildProcessProjection.js +156 -0
- package/dist/application/JavaScriptSemanticGraphConstruction.js +2 -2
- package/dist/application/JavaScriptSemanticGraphDataProjection.js +203 -0
- package/dist/application/JavaScriptSemanticGraphFingerprintProjection.js +25 -0
- package/dist/application/JavaScriptSemanticGraphFlowProjection.js +129 -8
- package/dist/application/JavaScriptSemanticGraphObjectProjection.js +81 -0
- package/dist/application/JavaScriptSemanticGraphProjection.js +14 -7
- package/dist/application/JavaScriptSemanticGraphResourceProjection.js +59 -0
- package/dist/application/JavaScriptSemanticGraphValueProjection.js +77 -0
- package/dist/application/LazyAnalysisProvider.js +77 -0
- package/dist/application/LoopbackReplay.js +1 -1
- package/dist/application/NativeApiInspection.js +80 -0
- package/dist/application/ProcessReactiveEffects.js +6 -0
- package/dist/application/ProcessReactiveHarness.js +16 -1
- package/dist/application/ProjectPermissionStore.js +1 -0
- package/dist/application/ReconstructionObligationAuthority.js +72 -0
- package/dist/application/ReconstructionObligationCandidates.js +265 -0
- package/dist/application/ReconstructionObligationLedgerDiagnostics.js +47 -0
- package/dist/application/ReconstructionObligationLedgerEvaluation.js +263 -0
- package/dist/application/ReconstructionObligationLedgerProjection.js +86 -0
- package/dist/application/ReconstructionObligationLedgerService.js +72 -0
- package/dist/application/ReconstructionObligationOriginalCases.js +33 -0
- package/dist/application/ReconstructionObligationPolicies.js +132 -0
- package/dist/application/ReconstructionReadinessService.js +48 -0
- package/dist/application/SessionProviderRouter.js +6 -6
- package/dist/application/SetupClientConfiguration.js +4 -2
- package/dist/application/runtime.js +26 -9
- package/dist/artifacts/ArtifactProvider.js +87 -22
- package/dist/browser/BrowserScenarioSecrets.js +53 -0
- package/dist/browser/BrowserScenarioSessionPort.js +1 -0
- package/dist/browser/CdpBrowserProvider.js +2 -2
- package/dist/browser/CdpCaptureDocuments.js +57 -0
- package/dist/browser/CdpCaptureStorage.js +71 -29
- package/dist/browser/CdpCaptureStorageFingerprints.js +328 -0
- package/dist/browser/CdpEndpoint.js +8 -6
- package/dist/browser/CdpPageCapture.js +2 -0
- package/dist/browser/JavaScriptRuntimeScope.js +38 -0
- package/dist/browser/PlaywrightBrowserScenarioProvider.js +259 -0
- package/dist/browser/PlaywrightExecutionBoundary.js +42 -0
- package/dist/browser/PlaywrightScenarioActions.js +62 -0
- package/dist/browser/PlaywrightScenarioArtifacts.js +238 -0
- package/dist/browser/PlaywrightScenarioBrowser.js +144 -0
- package/dist/browser/PlaywrightScenarioEvents.js +301 -0
- package/dist/browser/PlaywrightScenarioSession.js +300 -0
- package/dist/browser/V8InspectorCaptureProjection.js +110 -0
- package/dist/browser/V8InspectorEndpoint.js +72 -0
- package/dist/browser/V8InspectorProvider.js +267 -0
- package/dist/catalogIdentity.js +11 -3
- package/dist/cli/artifactCommands.js +44 -3
- package/dist/cli/coreAnalysisCommands.js +78 -0
- package/dist/cli.js +4 -0
- package/dist/cliApplicationCommands.js +30 -2
- package/dist/cliBrowserAdvancedCommands.js +17 -5
- package/dist/cliBrowserCommands.js +1 -0
- package/dist/cliBrowserScenarioCommands.js +43 -0
- package/dist/cliCommandNames.js +9 -0
- package/dist/cliJavaScriptRuntimeCommands.js +164 -0
- package/dist/cliObservationOptions.js +4 -0
- package/dist/cliPolicyCommands.js +1 -0
- package/dist/config/environment.js +12 -0
- package/dist/config/parseConfig.js +88 -17
- package/dist/contracts/analysisSearchContract.js +14 -0
- package/dist/contracts/applicationToolContracts.js +86 -2
- package/dist/contracts/applicationWorkflowInputContracts.js +18 -0
- package/dist/contracts/artifactToolContracts.js +29 -2
- package/dist/contracts/browserProviderToolContracts.js +7 -0
- package/dist/contracts/browserScenarioToolContracts.js +81 -0
- package/dist/contracts/browserToolContracts.js +88 -98
- package/dist/contracts/enhancedInputs.js +35 -6
- package/dist/contracts/functionInstructionContract.js +8 -0
- package/dist/contracts/functionWorkflowToolContracts.js +30 -0
- package/dist/contracts/hopperMemoryContracts.js +22 -0
- package/dist/contracts/javascriptApplicationWorkflowExamples.js +42 -0
- package/dist/contracts/javascriptRuntimeObservationToolContracts.js +58 -0
- package/dist/contracts/promptContracts.js +14 -15
- package/dist/contracts/reconstructionReadinessExample.js +436 -0
- package/dist/contracts/toolContractExamples.js +8 -0
- package/dist/contracts/toolContractTypes.js +1 -0
- package/dist/contracts/toolContracts.js +34 -25
- package/dist/contracts/toolEffects.js +25 -0
- package/dist/contracts/toolOutputSchemaGroups.js +120 -30
- package/dist/contracts/toolOutputSchemaPrimitives.js +37 -0
- package/dist/domain/analysisErrorPresentation.js +8 -2
- package/dist/domain/analysisErrorProjection.js +9 -0
- package/dist/domain/artifactInspection.js +347 -0
- package/dist/domain/browserCaptureComparison.js +82 -0
- package/dist/domain/browserObservation.js +8 -1
- package/dist/domain/browserObservationErrors.js +1 -0
- package/dist/domain/browserObservationSchemas.js +26 -0
- package/dist/domain/browserScenario.js +165 -0
- package/dist/domain/browserScenarioCapture.js +57 -0
- package/dist/domain/browserScenarioCaptureValues.js +204 -0
- package/dist/domain/browserScenarioDiff.js +324 -0
- package/dist/domain/browserScenarioDiffValues.js +157 -0
- package/dist/domain/browserScenarioNormalization.js +45 -0
- package/dist/domain/browserScenarioValues.js +372 -0
- package/dist/domain/bytecodeProvider.js +179 -0
- package/dist/domain/conformancePackage.js +169 -0
- package/dist/domain/conformanceReplay.js +104 -0
- package/dist/domain/conformanceTrustGate.js +193 -0
- package/dist/domain/customProtocolCapture.js +137 -0
- package/dist/domain/eventProcessTree.js +214 -0
- package/dist/domain/evidenceBundle.js +47 -0
- package/dist/domain/hopperStartupFailure.js +1 -1
- package/dist/domain/hopperValues.js +14 -1
- package/dist/domain/inputIssueProjection.js +7 -1
- package/dist/domain/javascriptRuntimeObservation.js +170 -0
- package/dist/domain/javascriptRuntimeReconciliationParsing.js +120 -2
- package/dist/domain/javascriptRuntimeReconciliationResult.js +3 -3
- package/dist/domain/javascriptRuntimeReconciliationRuntime.js +2 -2
- package/dist/domain/javascriptRuntimeReconciliationSchemas.js +1 -1
- package/dist/domain/javascriptSemanticAnalysis.js +13 -16
- package/dist/domain/javascriptSemanticAsyncEffects.js +253 -0
- package/dist/domain/javascriptSemanticChildProcesses.js +237 -0
- package/dist/domain/javascriptSemanticDataEffectHelpers.js +125 -0
- package/dist/domain/javascriptSemanticDataEffects.js +284 -0
- package/dist/domain/javascriptSemanticDerivedAnalysis.js +41 -0
- package/dist/domain/javascriptSemanticFingerprints.js +174 -0
- package/dist/domain/javascriptSemanticIr.js +21 -1
- package/dist/domain/javascriptSemanticObjects.js +115 -0
- package/dist/domain/javascriptSemanticPromises.js +290 -0
- package/dist/domain/javascriptSemanticResources.js +136 -0
- package/dist/domain/javascriptSourceParser.js +15 -0
- package/dist/domain/javascriptStaticAnalysis.js +12 -15
- package/dist/domain/javascriptStaticAnalysisBundler.js +38 -0
- package/dist/domain/javascriptStaticAnalysisCalls.js +23 -1
- package/dist/domain/javascriptStaticAnalysisHelpers.js +8 -0
- package/dist/domain/mobileApplicationInvestigation.js +159 -0
- package/dist/domain/nativeApiBoundary.js +130 -0
- package/dist/domain/objcSwiftMetadata.js +150 -0
- package/dist/domain/packageAnalysis.js +123 -0
- package/dist/domain/peInspection.js +196 -0
- package/dist/domain/processCapture.js +8 -2
- package/dist/domain/processReactiveScenario.js +1 -0
- package/dist/domain/processReactiveTransition.js +9 -4
- package/dist/domain/protocolCapture.js +243 -0
- package/dist/domain/providerCleanupError.js +11 -0
- package/dist/domain/reconstructionObligationLedgerSchemas.js +278 -0
- package/dist/domain/reconstructionReadiness.js +121 -0
- package/dist/domain/reconstructionReadinessFindingHelpers.js +17 -0
- package/dist/domain/reconstructionReadinessIntegrityFindings.js +118 -0
- package/dist/domain/reconstructionReadinessJourneyFindings.js +193 -0
- package/dist/domain/reconstructionReadinessSchemas.js +240 -0
- package/dist/domain/sourceToBundleComparison.js +335 -0
- package/dist/domain/sourceToBundleComparisonSchemas.js +133 -0
- package/dist/domain/sourceToBundleSignals.js +202 -0
- package/dist/domain/webCaptureDiff.js +141 -27
- package/dist/domain/webScreenshot.js +1 -1
- package/dist/dotnet/ManagedStaticProvider.js +34 -5
- package/dist/generatedMcpToolCatalog.js +37 -0
- package/dist/generatedPackageMetadata.js +4 -4
- package/dist/ghidra/GhidraDefaults.js +1 -1
- package/dist/ghidra/GhidraFunctionValues.js +40 -2
- package/dist/ghidra/GhidraProviderCapabilities.js +47 -38
- package/dist/hopper/HopperCleanup.js +158 -0
- package/dist/hopper/HopperClient.js +93 -99
- package/dist/hopper/HopperProvider.js +61 -30
- package/dist/hopper/HopperRequestQueue.js +215 -0
- package/dist/hopper/HopperResponseStream.js +46 -0
- package/dist/hopper/protocol.js +63 -20
- package/dist/main/transport.js +24 -27
- package/dist/main.js +14 -6
- package/dist/mcpDoctor.js +27 -4
- package/dist/mcpStartupPolicy.js +14 -0
- package/dist/process/ProcessCommandIdentity.js +19 -0
- package/dist/process/ProcessOwnership.js +11 -8
- package/dist/server/DynamicToolAvailability.js +70 -0
- package/dist/server/LazyToolCatalog.js +134 -0
- package/dist/server/createServer.js +92 -154
- package/dist/server/hydrateServerTools.js +191 -0
- package/dist/server/lifecycleProgress.js +10 -0
- package/dist/server/permissionFailure.js +12 -0
- package/dist/server/registerApplicationTools/compareSourceToBundle.js +35 -0
- package/dist/server/registerApplicationTools/helpers.js +11 -7
- package/dist/server/registerApplicationTools/obligationLedger.js +27 -0
- package/dist/server/registerApplicationTools/readiness.js +55 -0
- package/dist/server/registerApplicationTools.js +6 -0
- package/dist/server/registerArtifactTools.js +9 -1
- package/dist/server/registerBrowserScenarioTool.js +25 -0
- package/dist/server/registerBrowserTools.js +2 -2
- package/dist/server/registerCloseLifecycleTool.js +57 -0
- package/dist/server/registerEnhancedTools.js +28 -7
- package/dist/server/registerEvidenceResources.js +54 -101
- package/dist/server/registerEvidenceTools.js +9 -2
- package/dist/server/registerInvestigationTools.js +1 -2
- package/dist/server/registerJavaScriptApplicationGraphResource.js +0 -4
- package/dist/server/registerJavaScriptRuntimeObservationTools.js +37 -0
- package/dist/server/registerReconstructionObligationLedgerResource.js +32 -0
- package/dist/server/registerReconstructionReadinessResource.js +32 -0
- package/dist/server/registerSessionRecordTools.js +82 -12
- package/dist/server/registerSessionStatusTool.js +11 -8
- package/dist/server/registerSessionTools.js +32 -58
- package/dist/server/sessionAvailabilityPolicy.js +10 -8
- package/dist/server/toolRegistrationOptions.js +21 -6
- package/dist/server/toolResult.js +12 -0
- package/package.json +28 -11
- package/scripts/package-runner-bootstrap.mjs +72 -0
- package/scripts/rea.mjs +11 -1
- package/skills/reverse-engineer-anything/SKILL.md +10 -3
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import canonicalize from "canonicalize";
|
|
3
|
+
export const obligationLedgerCoverage = (omittedCount, maxObligations, incomplete) => ({
|
|
4
|
+
status: incomplete ? "partial" : "complete",
|
|
5
|
+
truncated: omittedCount > 0,
|
|
6
|
+
omitted_count: omittedCount,
|
|
7
|
+
max_obligations: maxObligations,
|
|
8
|
+
});
|
|
9
|
+
export const summarizeObligations = (obligations) => ({
|
|
10
|
+
total: obligations.length,
|
|
11
|
+
required: obligations.filter(({ required }) => required).length,
|
|
12
|
+
verified: obligations.filter(({ status }) => status === "verified").length,
|
|
13
|
+
required_open: obligations.filter(({ required, status }) => required && status !== "verified").length,
|
|
14
|
+
by_status: countBy(obligations, [
|
|
15
|
+
"unowned",
|
|
16
|
+
"characterized",
|
|
17
|
+
"implemented",
|
|
18
|
+
"verified",
|
|
19
|
+
"contradicted",
|
|
20
|
+
"blocked",
|
|
21
|
+
"out-of-scope",
|
|
22
|
+
"unknown",
|
|
23
|
+
], ({ status }) => status),
|
|
24
|
+
by_application_layer: countBy(obligations, [
|
|
25
|
+
"cli",
|
|
26
|
+
"protocol",
|
|
27
|
+
"electron",
|
|
28
|
+
"persistence",
|
|
29
|
+
"process",
|
|
30
|
+
"runtime",
|
|
31
|
+
"packaging",
|
|
32
|
+
"native-abi",
|
|
33
|
+
"application",
|
|
34
|
+
"other",
|
|
35
|
+
], ({ application_layer: layer }) => layer),
|
|
36
|
+
by_evidence_authority: countBy(obligations, ["candidate", "observed", "reviewed", "unknown"], ({ source_state: state }) => state),
|
|
37
|
+
});
|
|
38
|
+
export const obligationReports = (obligations) => ({
|
|
39
|
+
missing_owner_obligation_ids: obligationIdsWith(obligations, "missing-owner"),
|
|
40
|
+
missing_verifier_obligation_ids: obligationIdsWith(obligations, "missing-verifier"),
|
|
41
|
+
contradicted_obligation_ids: obligationIdsWith(obligations, "contradiction"),
|
|
42
|
+
residual_unknown_ids: [
|
|
43
|
+
...new Set(obligations.flatMap(({ residual_unknown_ids: ids }) => ids)),
|
|
44
|
+
].sort(),
|
|
45
|
+
});
|
|
46
|
+
export const obligationLedgerEvidenceLinks = (obligations, manifest) => [
|
|
47
|
+
...new Set([
|
|
48
|
+
...obligations.flatMap(({ authority_references: references }) => references.map(({ evidence_id: id }) => id)),
|
|
49
|
+
...manifest.bindings.flatMap((binding) => [
|
|
50
|
+
...binding.original_cases.map(({ evidence_id: id }) => id),
|
|
51
|
+
...binding.fixtures.flatMap(({ evidence_ids: ids }) => ids),
|
|
52
|
+
...(binding.verifier === null
|
|
53
|
+
? []
|
|
54
|
+
: [binding.verifier.result_evidence_id]),
|
|
55
|
+
]),
|
|
56
|
+
...manifest.contradictions.flatMap(({ evidence_ids: ids }) => ids),
|
|
57
|
+
]),
|
|
58
|
+
].sort();
|
|
59
|
+
export const obligationLedgerStatus = (obligations, omittedCount) => {
|
|
60
|
+
if (obligations.length === 0)
|
|
61
|
+
return "unknown";
|
|
62
|
+
const requiredOpen = obligations.filter(({ required, status }) => required && status !== "verified");
|
|
63
|
+
if (requiredOpen.some(({ status, diagnostics }) => status === "contradicted" ||
|
|
64
|
+
hasDiagnostic(diagnostics, "verifier-failed")))
|
|
65
|
+
return "failed";
|
|
66
|
+
if (omittedCount > 0 ||
|
|
67
|
+
requiredOpen.some(({ status }) => status === "unknown"))
|
|
68
|
+
return "unknown";
|
|
69
|
+
return requiredOpen.length === 0 ? "ready" : "open";
|
|
70
|
+
};
|
|
71
|
+
export const obligationEdgeOrder = (left, right) => JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
72
|
+
export const digestObligationLedgerValue = (value) => {
|
|
73
|
+
const encoded = canonicalize(value);
|
|
74
|
+
if (encoded === undefined)
|
|
75
|
+
throw new TypeError("Reconstruction obligation ledger is not canonical JSON");
|
|
76
|
+
return createHash("sha256").update(encoded).digest("hex");
|
|
77
|
+
};
|
|
78
|
+
const countBy = (items, values, valueFor) => values.map((value) => ({
|
|
79
|
+
key: value,
|
|
80
|
+
count: items.filter((item) => valueFor(item) === value).length,
|
|
81
|
+
}));
|
|
82
|
+
const obligationIdsWith = (obligations, code) => obligations
|
|
83
|
+
.filter(({ diagnostics }) => hasDiagnostic(diagnostics, code))
|
|
84
|
+
.map(({ obligation_id: id }) => id)
|
|
85
|
+
.sort();
|
|
86
|
+
const hasDiagnostic = (diagnostics, code) => diagnostics.some((diagnostic) => diagnostic.code === code);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AnalysisInputError, AnalysisProtocolError, } from "../domain/errors.js";
|
|
3
|
+
import { createEvidence } from "../domain/evidence.js";
|
|
4
|
+
import { jsonObjectSchema, jsonValueSchema } from "../domain/jsonValue.js";
|
|
5
|
+
import { reconstructionObligationLedgerInputSchema, reconstructionObligationLedgerPageSchema, } from "../domain/reconstructionObligationLedgerSchemas.js";
|
|
6
|
+
import { err, ok } from "../domain/result.js";
|
|
7
|
+
import { JAVASCRIPT_APPLICATION_WORKFLOW_PROVIDER } from "./InvestigationProviders.js";
|
|
8
|
+
import { deriveReconstructionObligationCandidates } from "./ReconstructionObligationCandidates.js";
|
|
9
|
+
import { evaluateReconstructionObligationLedger } from "./ReconstructionObligationLedgerEvaluation.js";
|
|
10
|
+
const OPERATION = "build_reconstruction_obligation_ledger";
|
|
11
|
+
/** Parse one portable ledger request for both CLI and MCP adapters. */
|
|
12
|
+
export const resolveReconstructionObligationLedgerRequest = (input) => {
|
|
13
|
+
const parsed = reconstructionObligationLedgerInputSchema.safeParse(input);
|
|
14
|
+
return parsed.success
|
|
15
|
+
? ok(parsed.data)
|
|
16
|
+
: err(new AnalysisInputError(OPERATION, { cause: parsed.error }));
|
|
17
|
+
};
|
|
18
|
+
/** Build one deterministic ledger page and wrap it in portable Evidence v2. */
|
|
19
|
+
export const buildReconstructionObligationLedgerEvidenceValidated = (input) => {
|
|
20
|
+
try {
|
|
21
|
+
const generated = deriveReconstructionObligationCandidates(input.evidence_bundle, input.reviewed_obligations);
|
|
22
|
+
const ledger = evaluateReconstructionObligationLedger({
|
|
23
|
+
candidates: generated.candidates,
|
|
24
|
+
bundle: input.evidence_bundle,
|
|
25
|
+
manifest: input.manifest,
|
|
26
|
+
maxObligations: input.limits.max_obligations,
|
|
27
|
+
generationLimitations: generated.limitations,
|
|
28
|
+
});
|
|
29
|
+
const page = pageLedger(ledger, input.page.offset, input.page.limit);
|
|
30
|
+
return ok(createLedgerEvidence(input, page));
|
|
31
|
+
}
|
|
32
|
+
catch (cause) {
|
|
33
|
+
if (cause instanceof z.ZodError)
|
|
34
|
+
return err(new AnalysisInputError(OPERATION, { cause }));
|
|
35
|
+
return err(new AnalysisProtocolError("Reconstruction obligation ledger generation failed", { cause }));
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const pageLedger = (ledger, offset, limit) => {
|
|
39
|
+
const obligations = ledger.obligations.slice(offset, offset + limit);
|
|
40
|
+
const nextOffset = offset + obligations.length < ledger.obligations.length
|
|
41
|
+
? offset + obligations.length
|
|
42
|
+
: null;
|
|
43
|
+
const { obligations: _allObligations, ...summary } = ledger;
|
|
44
|
+
return reconstructionObligationLedgerPageSchema.parse({
|
|
45
|
+
...summary,
|
|
46
|
+
page: {
|
|
47
|
+
offset,
|
|
48
|
+
limit,
|
|
49
|
+
total: ledger.obligations.length,
|
|
50
|
+
returned: obligations.length,
|
|
51
|
+
next_offset: nextOffset,
|
|
52
|
+
},
|
|
53
|
+
obligations,
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
const createLedgerEvidence = (input, page) => createEvidence(undefined, JAVASCRIPT_APPLICATION_WORKFLOW_PROVIDER, {
|
|
57
|
+
predicateType: "rea.reconstruction-obligation-ledger/v1",
|
|
58
|
+
operation: OPERATION,
|
|
59
|
+
parameters: jsonObjectSchema.parse({
|
|
60
|
+
ledger_id: page.ledger_id,
|
|
61
|
+
closure_digest: page.closure_digest,
|
|
62
|
+
limits: input.limits,
|
|
63
|
+
page: input.page,
|
|
64
|
+
}),
|
|
65
|
+
result: jsonValueSchema.parse(page),
|
|
66
|
+
rawResult: null,
|
|
67
|
+
confidence: "inferred",
|
|
68
|
+
authority: "analyst-inference",
|
|
69
|
+
environment: null,
|
|
70
|
+
limitations: page.limitations,
|
|
71
|
+
evidenceLinks: page.evidence_links,
|
|
72
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { evidenceSupportsOriginalAuthority } from "./ReconstructionObligationAuthority.js";
|
|
2
|
+
/** Merge generated and manifest-supplied original observations canonically. */
|
|
3
|
+
export const originalCasesFor = (candidate, binding) => [
|
|
4
|
+
...new Map([...candidate.observed_cases, ...(binding?.original_cases ?? [])].map((observed) => [
|
|
5
|
+
`${observed.kind}:${observed.evidence_id}:${observed.location}`,
|
|
6
|
+
observed,
|
|
7
|
+
])).values(),
|
|
8
|
+
].sort((left, right) => `${left.kind}:${left.evidence_id}:${left.location}`.localeCompare(`${right.kind}:${right.evidence_id}:${right.location}`));
|
|
9
|
+
/** Report original cases that are absent or lack comparable Evidence authority. */
|
|
10
|
+
export const originalCaseDiagnostics = (candidate, binding, evidenceById) => {
|
|
11
|
+
const diagnostics = [];
|
|
12
|
+
const originalCases = originalCasesFor(candidate, binding);
|
|
13
|
+
for (const caseKind of candidate.required_case_kinds) {
|
|
14
|
+
const cases = originalCases.filter(({ kind }) => kind === caseKind);
|
|
15
|
+
if (cases.length === 0) {
|
|
16
|
+
diagnostics.push({
|
|
17
|
+
code: "missing-original-case",
|
|
18
|
+
detail: `Original ${caseKind} behavior has not been observed.`,
|
|
19
|
+
});
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (!cases.some(({ evidence_id: evidenceId }) => {
|
|
23
|
+
const evidence = evidenceById.get(evidenceId);
|
|
24
|
+
return (evidence !== undefined &&
|
|
25
|
+
evidenceSupportsOriginalAuthority(evidence, candidate.required_original_authority));
|
|
26
|
+
}))
|
|
27
|
+
diagnostics.push({
|
|
28
|
+
code: "weak-original-case-authority",
|
|
29
|
+
detail: `Original ${caseKind} behavior lacks ${candidate.required_original_authority} Evidence.`,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return diagnostics;
|
|
33
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
const APPLICATION_NODE_POLICIES = {
|
|
2
|
+
package: policy("packaging", "package-lifecycle", "packaged-process", [
|
|
3
|
+
"positive",
|
|
4
|
+
"negative",
|
|
5
|
+
"teardown",
|
|
6
|
+
]),
|
|
7
|
+
installer: policy("packaging", "installer", "packaged-process", [
|
|
8
|
+
"positive",
|
|
9
|
+
"negative",
|
|
10
|
+
"teardown",
|
|
11
|
+
]),
|
|
12
|
+
"context-bridge-api": policy("electron", "context-bridge", "renderer", [
|
|
13
|
+
"positive",
|
|
14
|
+
"negative",
|
|
15
|
+
"malformed",
|
|
16
|
+
]),
|
|
17
|
+
"ipc-channel": policy("electron", "ipc", "renderer", [
|
|
18
|
+
"positive",
|
|
19
|
+
"negative",
|
|
20
|
+
"malformed",
|
|
21
|
+
]),
|
|
22
|
+
"ipc-handler": policy("electron", "ipc", "renderer", [
|
|
23
|
+
"positive",
|
|
24
|
+
"negative",
|
|
25
|
+
"malformed",
|
|
26
|
+
]),
|
|
27
|
+
endpoint: policy("protocol", "endpoint", "protocol", [
|
|
28
|
+
"positive",
|
|
29
|
+
"negative",
|
|
30
|
+
"malformed",
|
|
31
|
+
]),
|
|
32
|
+
storage: policy("persistence", "persistence", "integration", [
|
|
33
|
+
"positive",
|
|
34
|
+
"negative",
|
|
35
|
+
"malformed",
|
|
36
|
+
]),
|
|
37
|
+
worker: policy("process", "worker-lifecycle", "packaged-process", [
|
|
38
|
+
"positive",
|
|
39
|
+
"cancellation",
|
|
40
|
+
"teardown",
|
|
41
|
+
]),
|
|
42
|
+
"service-worker": policy("process", "worker-lifecycle", "packaged-process", [
|
|
43
|
+
"positive",
|
|
44
|
+
"cancellation",
|
|
45
|
+
"teardown",
|
|
46
|
+
]),
|
|
47
|
+
"native-addon": nativePolicy("native-addon"),
|
|
48
|
+
"native-export": nativePolicy("native-export"),
|
|
49
|
+
"managed-pinvoke-import": nativePolicy("managed-pinvoke"),
|
|
50
|
+
"managed-native-implementation": nativePolicy("managed-native"),
|
|
51
|
+
};
|
|
52
|
+
const SEMANTIC_NODE_POLICIES = {
|
|
53
|
+
"child-process": policy("process", "child-process", "packaged-process", [
|
|
54
|
+
"positive",
|
|
55
|
+
"negative",
|
|
56
|
+
"cancellation",
|
|
57
|
+
"teardown",
|
|
58
|
+
]),
|
|
59
|
+
stdio: policy("process", "stdio", "packaged-process", [
|
|
60
|
+
"positive",
|
|
61
|
+
"negative",
|
|
62
|
+
"teardown",
|
|
63
|
+
]),
|
|
64
|
+
signal: policy("process", "signal", "packaged-process", [
|
|
65
|
+
"positive",
|
|
66
|
+
"cancellation",
|
|
67
|
+
"teardown",
|
|
68
|
+
]),
|
|
69
|
+
"config-source": parserPolicy("cli", "configuration", "integration"),
|
|
70
|
+
request: parserPolicy("protocol", "request", "protocol"),
|
|
71
|
+
response: parserPolicy("protocol", "response", "protocol"),
|
|
72
|
+
boundary: parserPolicy("application", "parser-boundary", "integration"),
|
|
73
|
+
resource: policy("persistence", "resource-lifecycle", "integration", [
|
|
74
|
+
"positive",
|
|
75
|
+
"negative",
|
|
76
|
+
"teardown",
|
|
77
|
+
]),
|
|
78
|
+
event: policy("runtime", "event", "packaged-process", [
|
|
79
|
+
"positive",
|
|
80
|
+
"negative",
|
|
81
|
+
"cancellation",
|
|
82
|
+
]),
|
|
83
|
+
timer: policy("runtime", "timer", "packaged-process", [
|
|
84
|
+
"positive",
|
|
85
|
+
"cancellation",
|
|
86
|
+
"teardown",
|
|
87
|
+
]),
|
|
88
|
+
promise: policy("runtime", "promise-ownership", "packaged-process", [
|
|
89
|
+
"positive",
|
|
90
|
+
"negative",
|
|
91
|
+
"cancellation",
|
|
92
|
+
]),
|
|
93
|
+
task: policy("runtime", "task-lifecycle", "packaged-process", [
|
|
94
|
+
"positive",
|
|
95
|
+
"cancellation",
|
|
96
|
+
"teardown",
|
|
97
|
+
]),
|
|
98
|
+
};
|
|
99
|
+
export const applicationObligationPolicy = (nodeKind) => APPLICATION_NODE_POLICIES[nodeKind];
|
|
100
|
+
export const semanticObligationPolicy = (nodeKind) => SEMANTIC_NODE_POLICIES[nodeKind];
|
|
101
|
+
function policy(applicationLayer, family, authority, cases) {
|
|
102
|
+
return {
|
|
103
|
+
applicationLayer,
|
|
104
|
+
family,
|
|
105
|
+
fixtureAuthority: authority,
|
|
106
|
+
verifierAuthority: authority,
|
|
107
|
+
originalAuthority: "runtime",
|
|
108
|
+
cases,
|
|
109
|
+
requiresParserType: false,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function parserPolicy(applicationLayer, family, authority) {
|
|
113
|
+
return {
|
|
114
|
+
...policy(applicationLayer, family, authority, [
|
|
115
|
+
"positive",
|
|
116
|
+
"negative",
|
|
117
|
+
"malformed",
|
|
118
|
+
]),
|
|
119
|
+
requiresParserType: true,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function nativePolicy(family) {
|
|
123
|
+
return {
|
|
124
|
+
applicationLayer: "native-abi",
|
|
125
|
+
family,
|
|
126
|
+
fixtureAuthority: "native-abi",
|
|
127
|
+
verifierAuthority: "native-abi",
|
|
128
|
+
originalAuthority: "static",
|
|
129
|
+
cases: ["positive", "negative"],
|
|
130
|
+
requiresParserType: false,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AnalysisInputError, AnalysisProtocolError, } from "../domain/errors.js";
|
|
3
|
+
import { createEvidence } from "../domain/evidence.js";
|
|
4
|
+
import { jsonObjectSchema, jsonValueSchema } from "../domain/jsonValue.js";
|
|
5
|
+
import { createReconstructionReadinessReport } from "../domain/reconstructionReadiness.js";
|
|
6
|
+
import { reconstructionReadinessInputSchema, } from "../domain/reconstructionReadinessSchemas.js";
|
|
7
|
+
import { err, ok } from "../domain/result.js";
|
|
8
|
+
import { JAVASCRIPT_APPLICATION_WORKFLOW_PROVIDER } from "./InvestigationProviders.js";
|
|
9
|
+
const OPERATION = "evaluate_reconstruction_readiness";
|
|
10
|
+
/** Parse one portable readiness request for both CLI and MCP adapters. */
|
|
11
|
+
export const resolveReconstructionReadinessRequest = (input) => {
|
|
12
|
+
const parsed = reconstructionReadinessInputSchema.safeParse(input);
|
|
13
|
+
return parsed.success
|
|
14
|
+
? ok(parsed.data)
|
|
15
|
+
: err(new AnalysisInputError(OPERATION, { cause: parsed.error }));
|
|
16
|
+
};
|
|
17
|
+
/** Evaluate and wrap one deterministic readiness report in Evidence v2. */
|
|
18
|
+
export const evaluateReconstructionReadinessValidated = (input) => {
|
|
19
|
+
try {
|
|
20
|
+
const report = createReconstructionReadinessReport(input);
|
|
21
|
+
return ok(createEvidence(undefined, JAVASCRIPT_APPLICATION_WORKFLOW_PROVIDER, {
|
|
22
|
+
predicateType: "rea.reconstruction-readiness-report/v1",
|
|
23
|
+
operation: OPERATION,
|
|
24
|
+
parameters: jsonObjectSchema.parse({
|
|
25
|
+
source_digest: report.source_digest,
|
|
26
|
+
expected_source_digest: input.replay.expected_source_digest,
|
|
27
|
+
}),
|
|
28
|
+
result: jsonValueSchema.parse(report),
|
|
29
|
+
rawResult: null,
|
|
30
|
+
confidence: "inferred",
|
|
31
|
+
authority: "analyst-inference",
|
|
32
|
+
environment: null,
|
|
33
|
+
limitations: report.status === "pass"
|
|
34
|
+
? []
|
|
35
|
+
: [
|
|
36
|
+
"Aggregate pass is withheld until every required conformance stage passes.",
|
|
37
|
+
],
|
|
38
|
+
evidenceLinks: report.evidence_links,
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
catch (cause) {
|
|
42
|
+
if (cause instanceof z.ZodError)
|
|
43
|
+
return err(new AnalysisInputError(OPERATION, { cause }));
|
|
44
|
+
return err(new AnalysisProtocolError("Reconstruction readiness evaluation failed", {
|
|
45
|
+
cause,
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
};
|
|
@@ -26,7 +26,7 @@ export class SessionProviderRouter {
|
|
|
26
26
|
: (target, resolutionOptions) => provider.resolveAnalysisProfile?.(target, resolutionOptions) ??
|
|
27
27
|
Promise.resolve(ok({ profile: null, compatibility: {} })));
|
|
28
28
|
return new SessionProviderRouter({
|
|
29
|
-
kind: "
|
|
29
|
+
kind: "single",
|
|
30
30
|
provider,
|
|
31
31
|
identity,
|
|
32
32
|
capabilities,
|
|
@@ -61,7 +61,7 @@ export class SessionProviderRouter {
|
|
|
61
61
|
}
|
|
62
62
|
/** Provider identities exposed through the flat 1.x compatibility field. */
|
|
63
63
|
providerIdentities(route) {
|
|
64
|
-
if (this.runtime.kind === "
|
|
64
|
+
if (this.runtime.kind === "single") {
|
|
65
65
|
if (route.capabilities === undefined)
|
|
66
66
|
return [route.identity];
|
|
67
67
|
return uniqueProviderIdentities([...route.capabilities.values()].map(({ provider }) => provider));
|
|
@@ -86,7 +86,7 @@ export class SessionProviderRouter {
|
|
|
86
86
|
compatibility: {},
|
|
87
87
|
binding: null,
|
|
88
88
|
selection: undefined,
|
|
89
|
-
createClient: (target, context) =>
|
|
89
|
+
createClient: (target, context) => createSingleProviderClient(runtime, target, undefined, context),
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
92
|
/** Resolve target routes before any provider client is created. */
|
|
@@ -122,12 +122,12 @@ export class SessionProviderRouter {
|
|
|
122
122
|
compatibility: normalized.value.compatibility,
|
|
123
123
|
binding: null,
|
|
124
124
|
selection: undefined,
|
|
125
|
-
createClient: (openedTarget, context) =>
|
|
125
|
+
createClient: (openedTarget, context) => createSingleProviderClient(runtime, openedTarget, normalized.value.profile ?? undefined, context),
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
128
|
/** Candidate status authoritative for the active or target-free route. */
|
|
129
129
|
candidateStatuses(route) {
|
|
130
|
-
if (this.runtime.kind === "
|
|
130
|
+
if (this.runtime.kind === "single")
|
|
131
131
|
return [];
|
|
132
132
|
return route.selection?.candidates ?? this.runtime.registry.candidates();
|
|
133
133
|
}
|
|
@@ -160,7 +160,7 @@ const selectableRoute = (auxiliaryProviders, selection) => {
|
|
|
160
160
|
emptyClient(identity),
|
|
161
161
|
};
|
|
162
162
|
};
|
|
163
|
-
const
|
|
163
|
+
const createSingleProviderClient = (runtime, target, profile, context) => typeof runtime.provider === "function"
|
|
164
164
|
? runtime.provider(target, profile, context)
|
|
165
165
|
: runtime.provider.createClient(target, profile, context);
|
|
166
166
|
const emptyClient = (identity) => ({
|
|
@@ -5,6 +5,7 @@ import { z } from "zod";
|
|
|
5
5
|
import writeFileAtomic from "write-file-atomic";
|
|
6
6
|
import { parse as parseToml, stringify as stringifyToml } from "smol-toml";
|
|
7
7
|
import { PRODUCT_IDENTITY } from "../identity.js";
|
|
8
|
+
import { MCP_STARTUP_POLICY } from "../mcpStartupPolicy.js";
|
|
8
9
|
import { resolveClientConfigTransactionPath } from "./ClientConfigPath.js";
|
|
9
10
|
const defaultCommand = () => [
|
|
10
11
|
"npx",
|
|
@@ -12,7 +13,6 @@ const defaultCommand = () => [
|
|
|
12
13
|
PRODUCT_IDENTITY.registrationPackageSpecifier,
|
|
13
14
|
"mcp",
|
|
14
15
|
];
|
|
15
|
-
const CODEX_STARTUP_TIMEOUT_SECONDS = 30;
|
|
16
16
|
/** Back up, atomically update, and semantically read back one JSON MCP configuration. */
|
|
17
17
|
export const configureJsonClient = async (client, environment = {}, command = defaultCommand()) => {
|
|
18
18
|
const transactionPath = await resolveClientConfigTransactionPath(client.configPath);
|
|
@@ -214,7 +214,9 @@ const clientConfigurationDesired = (client, providerEnvironment, command) => {
|
|
|
214
214
|
command: command[0] ?? PRODUCT_IDENTITY.cliBinary,
|
|
215
215
|
args: command.slice(1),
|
|
216
216
|
...(client.name === "codex"
|
|
217
|
-
? {
|
|
217
|
+
? {
|
|
218
|
+
startup_timeout_sec: MCP_STARTUP_POLICY.codexStartupTimeoutSeconds,
|
|
219
|
+
}
|
|
218
220
|
: {}),
|
|
219
221
|
...(Object.keys(environment).length === 0 ? {} : { env: environment }),
|
|
220
222
|
};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { BinarySession } from "./BinarySession.js";
|
|
2
1
|
import { HopperProvider } from "../hopper/HopperProvider.js";
|
|
3
2
|
import { GhidraProvider } from "../ghidra/GhidraProvider.js";
|
|
4
|
-
import { NativeMacOSProvider } from "../native/NativeMacOSProvider.js";
|
|
5
|
-
import { ArtifactProvider } from "../artifacts/ArtifactProvider.js";
|
|
6
|
-
import { ManagedStaticProvider } from "../dotnet/ManagedStaticProvider.js";
|
|
7
3
|
import { silentLogger } from "../logger.js";
|
|
4
|
+
import { GENERATED_AUXILIARY_PROVIDERS } from "../generatedMcpToolCatalog.js";
|
|
8
5
|
import { AnalysisProviderRegistry } from "./AnalysisProviderRegistry.js";
|
|
9
|
-
import {
|
|
6
|
+
import { composeBinarySession } from "./BinarySessionComposition.js";
|
|
7
|
+
import { LazyAnalysisProvider } from "./LazyAnalysisProvider.js";
|
|
10
8
|
/**
|
|
11
9
|
* Compose the target-switching runtime shared directly by CLI and MCP adapters.
|
|
12
10
|
* This is the sole production wiring point, so both adapters share identical
|
|
@@ -15,9 +13,28 @@ import { SessionProviderRouter } from "./SessionProviderRouter.js";
|
|
|
15
13
|
export const createBinarySession = (config, logger = silentLogger) => {
|
|
16
14
|
const hopper = new HopperProvider(config, logger);
|
|
17
15
|
const ghidra = new GhidraProvider(config, logger);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
new ManagedStaticProvider(),
|
|
16
|
+
const auxiliary = new Map(GENERATED_AUXILIARY_PROVIDERS.map((provider) => [
|
|
17
|
+
provider.identity.id,
|
|
18
|
+
provider,
|
|
22
19
|
]));
|
|
20
|
+
const lazyProvider = (id, load) => {
|
|
21
|
+
const generated = auxiliary.get(id);
|
|
22
|
+
if (generated === undefined)
|
|
23
|
+
throw new TypeError(`Missing generated provider metadata for ${id}`);
|
|
24
|
+
return new LazyAnalysisProvider({ ...generated, load });
|
|
25
|
+
};
|
|
26
|
+
return composeBinarySession(new AnalysisProviderRegistry([hopper, ghidra], config.analysisProvider), [
|
|
27
|
+
lazyProvider("rea-artifact-graph", async () => {
|
|
28
|
+
const { ArtifactProvider } = await import("../artifacts/ArtifactProvider.js");
|
|
29
|
+
return new ArtifactProvider(config.artifactNativeMountEnabled, config.artifactIntegrityContinueEnabled);
|
|
30
|
+
}),
|
|
31
|
+
lazyProvider("native-macos", async () => {
|
|
32
|
+
const { NativeMacOSProvider } = await import("../native/NativeMacOSProvider.js");
|
|
33
|
+
return new NativeMacOSProvider();
|
|
34
|
+
}),
|
|
35
|
+
lazyProvider("rea-dotnet-static", async () => {
|
|
36
|
+
const { ManagedStaticProvider } = await import("../dotnet/ManagedStaticProvider.js");
|
|
37
|
+
return new ManagedStaticProvider();
|
|
38
|
+
}),
|
|
39
|
+
]);
|
|
23
40
|
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { createAnalysisExecution, } from "../application/AnalysisProvider.js";
|
|
2
2
|
import { inventoryArtifact } from "../application/ArtifactInventory.js";
|
|
3
3
|
import { extractArtifact } from "../application/ArtifactExtraction.js";
|
|
4
|
-
import { ARTIFACT_TOOL_CONTRACTS, artifactInventoryInputSchema, artifactExtractionInputSchema, } from "../contracts/artifactToolContracts.js";
|
|
4
|
+
import { ARTIFACT_TOOL_CONTRACTS, artifactInspectionInputSchema, artifactInventoryInputSchema, artifactExtractionInputSchema, } from "../contracts/artifactToolContracts.js";
|
|
5
5
|
import { AnalysisCapabilityUnavailableError, ArtifactOperationError, } from "../domain/errors.js";
|
|
6
6
|
import { err, ok } from "../domain/result.js";
|
|
7
7
|
import { ArtifactReaderFailure, } from "./ArtifactReader.js";
|
|
8
8
|
import { ARTIFACT_GRAPH_PROVIDER } from "../application/InvestigationProviders.js";
|
|
9
|
+
import { createEvidence } from "../domain/evidence.js";
|
|
10
|
+
import { createArtifactInspection } from "../domain/artifactInspection.js";
|
|
9
11
|
const IDENTITY = Object.freeze(ARTIFACT_GRAPH_PROVIDER);
|
|
10
12
|
/** Read-only inventory and exclusively owned extraction provider. */
|
|
11
13
|
export class ArtifactProvider {
|
|
@@ -22,7 +24,9 @@ export class ArtifactProvider {
|
|
|
22
24
|
outputContractVersion: 1,
|
|
23
25
|
available: true,
|
|
24
26
|
reason: null,
|
|
25
|
-
pagination: "
|
|
27
|
+
pagination: contract.name === "inspect_artifact"
|
|
28
|
+
? "none"
|
|
29
|
+
: "offset",
|
|
26
30
|
exhaustive: false,
|
|
27
31
|
effects: Object.freeze({
|
|
28
32
|
mutatesArtifact: false,
|
|
@@ -68,6 +72,10 @@ class ArtifactClient {
|
|
|
68
72
|
if (!isArtifactOperation(operation))
|
|
69
73
|
return err(new AnalysisCapabilityUnavailableError(IDENTITY.id, operation, "Operation is not implemented by artifact graph provider."));
|
|
70
74
|
try {
|
|
75
|
+
if (operation === "inspect_artifact") {
|
|
76
|
+
const inspected = await this.inspectArtifact(parameters, options);
|
|
77
|
+
return inspected;
|
|
78
|
+
}
|
|
71
79
|
if (operation === "extract_artifact") {
|
|
72
80
|
const parsed = artifactExtractionInputSchema.parse(parameters);
|
|
73
81
|
const result = await extractArtifact({
|
|
@@ -90,26 +98,7 @@ class ArtifactClient {
|
|
|
90
98
|
}));
|
|
91
99
|
}
|
|
92
100
|
const parsed = artifactInventoryInputSchema.parse(parameters);
|
|
93
|
-
const result = await
|
|
94
|
-
nodeOffset: parsed.node_offset,
|
|
95
|
-
nodeLimit: parsed.node_limit,
|
|
96
|
-
occurrenceOffset: parsed.occurrence_offset,
|
|
97
|
-
occurrenceLimit: parsed.occurrence_limit,
|
|
98
|
-
edgeOffset: parsed.edge_offset,
|
|
99
|
-
edgeLimit: parsed.edge_limit,
|
|
100
|
-
}, {
|
|
101
|
-
...(options?.signal === undefined ? {} : { signal: options.signal }),
|
|
102
|
-
nativeMount: {
|
|
103
|
-
nativeMountApproved: parsed.native_mount_approved === true,
|
|
104
|
-
nativeMountEnabled: this.nativeMountEnabled,
|
|
105
|
-
},
|
|
106
|
-
integrity: {
|
|
107
|
-
mode: parsed.integrity_policy,
|
|
108
|
-
approved: parsed.integrity_continue_approved === true,
|
|
109
|
-
enabled: this.integrityContinueEnabled,
|
|
110
|
-
maxMismatches: parsed.max_integrity_mismatches,
|
|
111
|
-
},
|
|
112
|
-
});
|
|
101
|
+
const result = await this.inventory(parsed, options);
|
|
113
102
|
return ok(createAnalysisExecution(result, IDENTITY, {
|
|
114
103
|
rawResult: null,
|
|
115
104
|
limitations: result.limitations,
|
|
@@ -127,6 +116,82 @@ class ArtifactClient {
|
|
|
127
116
|
close() {
|
|
128
117
|
return Promise.resolve();
|
|
129
118
|
}
|
|
119
|
+
async inspectArtifact(parameters, options) {
|
|
120
|
+
const parsed = artifactInspectionInputSchema.parse(parameters);
|
|
121
|
+
const inventoryParameters = artifactInventoryInputSchema.parse({
|
|
122
|
+
node_offset: 0,
|
|
123
|
+
node_limit: parsed.max_observations,
|
|
124
|
+
occurrence_offset: 0,
|
|
125
|
+
occurrence_limit: parsed.max_observations,
|
|
126
|
+
edge_offset: 0,
|
|
127
|
+
edge_limit: parsed.max_relationships,
|
|
128
|
+
native_mount_approved: parsed.native_mount_approved,
|
|
129
|
+
integrity_policy: parsed.integrity_policy,
|
|
130
|
+
integrity_continue_approved: parsed.integrity_continue_approved,
|
|
131
|
+
max_integrity_mismatches: parsed.max_integrity_mismatches,
|
|
132
|
+
max_entries: parsed.max_entries,
|
|
133
|
+
max_total_bytes: parsed.max_total_bytes,
|
|
134
|
+
max_entry_bytes: parsed.max_entry_bytes,
|
|
135
|
+
max_compression_ratio: parsed.max_compression_ratio,
|
|
136
|
+
max_depth: parsed.max_depth,
|
|
137
|
+
max_path_bytes: parsed.max_path_bytes,
|
|
138
|
+
});
|
|
139
|
+
await options?.progress?.report({
|
|
140
|
+
phase: "inspect_artifact.inventory",
|
|
141
|
+
completed: 0,
|
|
142
|
+
total: 1,
|
|
143
|
+
message: "inventory substep started",
|
|
144
|
+
});
|
|
145
|
+
const inventory = await this.inventory(inventoryParameters, options);
|
|
146
|
+
const subject = subjectFor(this.target.sourcePath ?? this.target.path, inventory.manifest);
|
|
147
|
+
const locations = inventory.occurrences.items.map(({ logical_path: path }) => ({
|
|
148
|
+
kind: "artifact-path",
|
|
149
|
+
path,
|
|
150
|
+
}));
|
|
151
|
+
const inventoryEvidence = createEvidence(subject, IDENTITY, {
|
|
152
|
+
operation: "inventory_artifact",
|
|
153
|
+
parameters: inventoryParameters,
|
|
154
|
+
result: inventory,
|
|
155
|
+
rawResult: null,
|
|
156
|
+
limitations: inventory.limitations,
|
|
157
|
+
locations,
|
|
158
|
+
});
|
|
159
|
+
const result = createArtifactInspection(inventoryEvidence, parsed);
|
|
160
|
+
await options?.progress?.report({
|
|
161
|
+
phase: "inspect_artifact.inventory",
|
|
162
|
+
completed: 1,
|
|
163
|
+
total: 1,
|
|
164
|
+
message: "inventory substep completed",
|
|
165
|
+
});
|
|
166
|
+
return ok(createAnalysisExecution(result, IDENTITY, {
|
|
167
|
+
rawResult: null,
|
|
168
|
+
limitations: result.limitations,
|
|
169
|
+
subject,
|
|
170
|
+
locations,
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
inventory(parsed, options) {
|
|
174
|
+
return inventoryArtifact(this.target.sourcePath ?? this.target.path, limitsFrom(parsed), {
|
|
175
|
+
nodeOffset: parsed.node_offset,
|
|
176
|
+
nodeLimit: parsed.node_limit,
|
|
177
|
+
occurrenceOffset: parsed.occurrence_offset,
|
|
178
|
+
occurrenceLimit: parsed.occurrence_limit,
|
|
179
|
+
edgeOffset: parsed.edge_offset,
|
|
180
|
+
edgeLimit: parsed.edge_limit,
|
|
181
|
+
}, {
|
|
182
|
+
...(options?.signal === undefined ? {} : { signal: options.signal }),
|
|
183
|
+
nativeMount: {
|
|
184
|
+
nativeMountApproved: parsed.native_mount_approved === true,
|
|
185
|
+
nativeMountEnabled: this.nativeMountEnabled,
|
|
186
|
+
},
|
|
187
|
+
integrity: {
|
|
188
|
+
mode: parsed.integrity_policy,
|
|
189
|
+
approved: parsed.integrity_continue_approved === true,
|
|
190
|
+
enabled: this.integrityContinueEnabled,
|
|
191
|
+
maxMismatches: parsed.max_integrity_mismatches,
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
}
|
|
130
195
|
}
|
|
131
196
|
const limitsFrom = (input) => ({
|
|
132
197
|
maxEntries: input.max_entries,
|