rea-agents 1.7.0 → 2.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.
- package/README.md +112 -59
- package/bridge/ghidra/ReaGhidraBridge.java +96 -11
- package/dist/application/ArtifactExtraction.js +1 -1
- package/dist/application/ArtifactInventory/classify.js +42 -0
- package/dist/application/ArtifactInventory/hash.js +43 -0
- package/dist/application/ArtifactInventory/reader.js +41 -0
- package/dist/application/ArtifactInventory/scanCanonical.js +155 -0
- package/dist/application/ArtifactInventory/scanReader.js +124 -0
- package/dist/application/ArtifactInventory/types.js +10 -0
- package/dist/application/ArtifactInventory.js +9 -351
- package/dist/application/AuthorizedArtifactInventory.js +2 -2
- package/dist/application/BinarySession.js +47 -270
- package/dist/application/BinarySessionExecution.js +28 -0
- package/dist/application/BinarySessionOpen.js +39 -0
- package/dist/application/BinarySessionRecords.js +149 -0
- package/dist/application/BinarySessionStatus.js +75 -0
- package/dist/application/CapabilityInventory.js +42 -2
- package/dist/application/ClientRegistrationStatus.js +1 -1
- package/dist/application/CrossVersionInventory.js +8 -2
- package/dist/application/CrossVersionInvestigation.js +11 -29
- package/dist/application/CrossVersionInvestigationCollections.js +23 -0
- package/dist/application/DirectAnalysis.js +47 -44
- package/dist/application/Doctor.js +165 -197
- package/dist/application/DoctorDiagnostics.js +180 -0
- package/dist/application/ElectronBoundaryAnalysis.js +112 -0
- package/dist/application/ElectronBoundaryGraph.js +9 -0
- package/dist/application/ElectronBoundaryGraphContext.js +62 -0
- package/dist/application/ElectronBoundaryGraphIpc.js +242 -0
- package/dist/application/ElectronBoundaryGraphNative.js +86 -0
- package/dist/application/ElectronBoundaryGraphWindows.js +223 -0
- package/dist/application/EnhancedToolPagination.js +22 -0
- package/dist/application/EnhancedToolTypes.js +4 -0
- package/dist/application/EnhancedTools.js +58 -50
- package/dist/application/InstrumentedJavaScriptReplayHost.js +36 -0
- package/dist/application/InvestigationProviders.js +30 -0
- package/dist/application/InvestigationWorkspaceStore.js +24 -10
- package/dist/application/JavaScriptApplicationEvidence.js +26 -0
- package/dist/application/JavaScriptApplicationEvidenceGraph.js +89 -0
- package/dist/application/JavaScriptApplicationService.js +74 -0
- package/dist/application/JavaScriptApplicationWorkflowEvidence.js +29 -0
- package/dist/application/JavaScriptApplicationWorkflowService.js +90 -0
- package/dist/application/JavaScriptArtifactAnalysis.js +52 -7
- package/dist/application/JavaScriptArtifactFiles.js +6 -2
- package/dist/application/JavaScriptArtifactGraphBuilder.js +82 -17
- package/dist/application/JavaScriptArtifactGraphBundlers.js +225 -0
- package/dist/application/JavaScriptArtifactGraphContext.js +37 -36
- package/dist/application/JavaScriptArtifactGraphDocuments.js +27 -4
- package/dist/application/JavaScriptArtifactGraphEvidence.js +24 -14
- package/dist/application/JavaScriptArtifactGraphFindings.js +54 -8
- package/dist/application/JavaScriptArtifactGraphStructure.js +29 -101
- package/dist/application/JavaScriptArtifactPathResolution.js +269 -0
- package/dist/application/JavaScriptArtifactReconstruction.js +4 -1
- package/dist/application/JavaScriptArtifactReconstructionInput.js +2 -83
- package/dist/application/JavaScriptJsonModules.js +39 -0
- package/dist/application/JavaScriptModuleRelationships.js +262 -0
- package/dist/application/JavaScriptReplayPermission.js +16 -0
- package/dist/application/JavaScriptReplayPlanning.js +201 -0
- package/dist/application/JavaScriptReplayService.js +292 -0
- package/dist/application/JavaScriptRuntimeReconciliationEvidence.js +25 -0
- package/dist/application/JavaScriptRuntimeReconciliationService.js +27 -0
- package/dist/application/LinuxHopper.js +10 -0
- package/dist/application/MacHopper.js +22 -11
- package/dist/application/ManagedApplicationGraphService.js +55 -0
- package/dist/application/ManagedMemberComparisonService.js +122 -0
- package/dist/application/ManagedNativeVerificationService.js +39 -0
- package/dist/application/ManagedReconstructionService.js +58 -0
- package/dist/application/ManagedRuntimeCorrelationService.js +103 -0
- package/dist/application/NodeRuntimeCharacterizationService.js +196 -0
- package/dist/application/PermissionAuthority.js +106 -63
- package/dist/application/ProcessCaptureCapability.js +1 -1
- package/dist/application/ProcessCapturePermission.js +13 -0
- package/dist/application/ProcessCli.js +2 -12
- package/dist/application/ProcessHarness.js +1 -1
- package/dist/application/ProcessSampling.js +15 -11
- package/dist/application/ProjectPermissionStore.js +49 -9
- package/dist/application/RealHopperAssertions.js +76 -0
- package/dist/application/ReconstructionCoverageService.js +69 -0
- package/dist/application/ReconstructionCoverageWorkspaceStore.js +31 -0
- package/dist/application/RuntimeExecutableDiagnostics.js +172 -0
- package/dist/application/Setup.js +147 -259
- package/dist/application/SetupClientConfiguration.js +220 -0
- package/dist/application/SetupClients.js +24 -2
- package/dist/application/SetupPlan.js +123 -12
- package/dist/application/SetupSkill.js +26 -12
- package/dist/application/SupportedClients.js +1 -0
- package/dist/application/Uninstall.js +6 -3
- package/dist/application/WindowsCapabilities.js +86 -0
- package/dist/application/runtime.js +2 -0
- package/dist/artifacts/AsarArtifactReader.js +11 -0
- package/dist/browser/BrowserProcessStartup.js +88 -0
- package/dist/browser/CdpCaptureDocuments.js +12 -8
- package/dist/browser/CdpCaptureEventBodyShapes.js +75 -0
- package/dist/browser/CdpCaptureEventHandlers.js +336 -0
- package/dist/browser/CdpCaptureEventHelpers.js +71 -0
- package/dist/browser/CdpCaptureEventState.js +1 -0
- package/dist/browser/CdpCaptureEventTypes.js +1 -0
- package/dist/browser/CdpCaptureEvents.js +46 -464
- package/dist/browser/CdpElectronInspection.js +106 -162
- package/dist/browser/CdpElectronProvider.js +5 -1
- package/dist/browser/CdpElectronScriptEvents.js +69 -0
- package/dist/browser/CdpElectronScripts.js +94 -0
- package/dist/browser/CdpElectronWorkers.js +56 -0
- package/dist/browser/CdpObservationSession.js +51 -8
- package/dist/browser/CdpPageCapture.js +12 -129
- package/dist/browser/CdpPageCaptureScripts.js +97 -0
- package/dist/browser/CdpPageCaptureWorkers.js +46 -0
- package/dist/browser/CdpWebMcpDiscovery.js +38 -14
- package/dist/browser/PngVisualDiff.js +9 -2
- package/dist/catalogIdentity.js +8 -1
- package/dist/cli/artifactCommands.js +82 -0
- package/dist/cli/coreAnalysisCommands.js +232 -0
- package/dist/cli/managedCommands.js +397 -0
- package/dist/cli/managedProjectGraphCommand.js +24 -0
- package/dist/cli/options.js +9 -0
- package/dist/cli/setupCommands.js +108 -0
- package/dist/cli/types.js +1 -0
- package/dist/cli/utilityCommands.js +122 -0
- package/dist/cli.js +13 -383
- package/dist/cliApplicationCommands.js +176 -0
- package/dist/cliBrowserAdvancedCommands.js +73 -16
- package/dist/cliBrowserCommands.js +39 -115
- package/dist/cliCommandNames.js +17 -0
- package/dist/cliElectronCommands.js +100 -27
- package/dist/cliEvidenceCommands.js +13 -2
- package/dist/cliInvestigationCommands.js +53 -10
- package/dist/cliJsonInput.js +54 -0
- package/dist/cliObservationOptions.js +137 -0
- package/dist/cliPolicyCommands.js +80 -46
- package/dist/cliSetup.js +289 -0
- package/dist/config/environment.js +107 -0
- package/dist/config/parseConfig.js +228 -0
- package/dist/config/parsers.js +68 -0
- package/dist/config/permissions.js +30 -0
- package/dist/config/types.js +1 -0
- package/dist/config.js +1 -292
- package/dist/contracts/applicationToolContracts.js +225 -0
- package/dist/contracts/artifactToolContracts.js +5 -9
- package/dist/contracts/browserToolContracts.js +14 -62
- package/dist/contracts/electronToolContracts.js +45 -19
- package/dist/contracts/errorSchemas.js +1 -0
- package/dist/contracts/investigationExamples.js +0 -6
- package/dist/contracts/javascriptApplicationWorkflowExamples.js +46 -0
- package/dist/contracts/javascriptRuntimeReconciliationExample.js +208 -0
- package/dist/contracts/managedToolContracts.js +153 -0
- package/dist/contracts/managedWorkflowExamples.js +346 -0
- package/dist/contracts/managedWorkflowToolContracts.js +203 -0
- package/dist/contracts/nativeToolContracts.js +2 -6
- package/dist/contracts/promptContracts.js +18 -2
- package/dist/contracts/providerSelection.js +2 -0
- package/dist/contracts/toolContractExamples.js +10 -25
- package/dist/contracts/toolContracts.js +49 -47
- package/dist/contracts/toolEffects.js +174 -0
- package/dist/contracts/toolOutputSchemaGroups.js +232 -0
- package/dist/contracts/toolOutputSchemaPrimitives.js +327 -0
- package/dist/contracts/toolOutputSchemas.js +2 -535
- package/dist/doctorRuntime.js +42 -1
- package/dist/domain/analysisErrorPresentation.js +234 -0
- package/dist/domain/analysisErrorProjection.js +284 -0
- package/dist/domain/artifactComparison.js +37 -19
- package/dist/domain/binaryTarget.js +87 -37
- package/dist/domain/browserObservation.js +1 -282
- package/dist/domain/browserObservationSchemas.js +286 -0
- package/dist/domain/bundleComparison.js +4 -4
- package/dist/domain/electronObservation.js +13 -0
- package/dist/domain/electronStaticAnalysis.js +9 -0
- package/dist/domain/electronStaticAnalysisBrowser.js +206 -0
- package/dist/domain/electronStaticAnalysisIpc.js +171 -0
- package/dist/domain/electronStaticAnalysisNative.js +164 -0
- package/dist/domain/electronStaticAnalysisTypes.js +1 -0
- package/dist/domain/electronStaticAnalysisValues.js +103 -0
- package/dist/domain/errors.js +32 -448
- package/dist/domain/functionComparison.js +4 -165
- package/dist/domain/functionComparisonDimensions.js +164 -0
- package/dist/domain/functionComparisonSchemas.js +3 -8
- package/dist/domain/inputIssueProjection.js +52 -0
- package/dist/domain/javascriptApplicationAnalysis.js +155 -0
- package/dist/domain/javascriptApplicationChangeGraph.js +231 -0
- package/dist/domain/javascriptApplicationEvidenceSchemas.js +18 -0
- package/dist/domain/javascriptApplicationGraph.js +2 -1
- package/dist/domain/javascriptApplicationGraphSchemas.js +7 -0
- package/dist/domain/javascriptApplicationVersionComparison.js +116 -0
- package/dist/domain/javascriptApplicationVersionComparisonSchemas.js +139 -0
- package/dist/domain/javascriptApplicationVersionItems.js +233 -0
- package/dist/domain/javascriptApplicationVersionKeys.js +170 -0
- package/dist/domain/javascriptExportInstrumentation.js +97 -0
- package/dist/domain/javascriptFeatureSeed.js +140 -0
- package/dist/domain/javascriptFeatureTrace.js +232 -0
- package/dist/domain/javascriptFeatureTraceSchemas.js +136 -0
- package/dist/domain/javascriptFeatureTraversal.js +100 -0
- package/dist/domain/javascriptNativeHandoff.js +85 -0
- package/dist/domain/javascriptReplay.js +361 -0
- package/dist/domain/javascriptRuntimeLoadState.js +106 -0
- package/dist/domain/javascriptRuntimeReconciliation.js +42 -0
- package/dist/domain/javascriptRuntimeReconciliationGraph.js +169 -0
- package/dist/domain/javascriptRuntimeReconciliationMatching.js +247 -0
- package/dist/domain/javascriptRuntimeReconciliationParsing.js +160 -0
- package/dist/domain/javascriptRuntimeReconciliationResult.js +119 -0
- package/dist/domain/javascriptRuntimeReconciliationRuntime.js +316 -0
- package/dist/domain/javascriptRuntimeReconciliationSchemas.js +245 -0
- package/dist/domain/javascriptRuntimeStaticCandidates.js +193 -0
- package/dist/domain/javascriptSemanticAnalysis.js +386 -0
- package/dist/domain/javascriptSemanticIr.js +30 -0
- package/dist/domain/javascriptSemanticProjection.js +366 -0
- package/dist/domain/javascriptSemanticState.js +40 -0
- package/dist/domain/javascriptSemanticTraversal.js +22 -0
- package/dist/domain/javascriptSemanticValues.js +352 -0
- package/dist/domain/javascriptStaticAnalysis.js +26 -254
- package/dist/domain/javascriptStaticAnalysisBundler.js +209 -0
- package/dist/domain/javascriptStaticAnalysisCalls.js +180 -0
- package/dist/domain/javascriptStaticAnalysisFindings.js +39 -0
- package/dist/domain/javascriptStaticAnalysisHelpers.js +81 -2
- package/dist/domain/javascriptStaticAnalysisState.js +6 -0
- package/dist/domain/knownPageCoverage.js +21 -0
- package/dist/domain/managedApplicationGraph.js +206 -0
- package/dist/domain/managedApplicationGraphCoverage.js +170 -0
- package/dist/domain/managedApplicationGraphNodeCoverage.js +6 -0
- package/dist/domain/managedApplicationGraphNodes.js +336 -0
- package/dist/domain/managedArtifact.js +452 -0
- package/dist/domain/managedMemberComparison.js +211 -0
- package/dist/domain/managedMemberComparisonCoverage.js +72 -0
- package/dist/domain/managedMemberComparisonMatch.js +356 -0
- package/dist/domain/managedNativeVerification.js +46 -0
- package/dist/domain/managedNativeVerificationMatch.js +272 -0
- package/dist/domain/managedNativeVerificationSchemas.js +141 -0
- package/dist/domain/managedReconstruction.js +196 -0
- package/dist/domain/managedRuntimeCorrelation.js +184 -0
- package/dist/domain/nodeRuntimeCharacterization.js +66 -0
- package/dist/domain/permissionPolicy.js +2 -0
- package/dist/domain/reconstructionCoverage.js +387 -0
- package/dist/domain/reconstructionCoverageEvaluation.js +212 -0
- package/dist/domain/reconstructionVerificationSchemas.js +9 -3
- package/dist/domain/runtimeCharacterization.js +85 -0
- package/dist/domain/webBundleAnalyzer.js +3 -409
- package/dist/domain/webBundleAnalyzerAst.js +77 -0
- package/dist/domain/webBundleAnalyzerInspection.js +307 -0
- package/dist/domain/webBundleAnalyzerResult.js +120 -0
- package/dist/dotnet/ManagedArtifactInspector.js +339 -0
- package/dist/dotnet/ManagedMemberInspector.js +153 -0
- package/dist/dotnet/ManagedMemberInspectorCore.js +297 -0
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +427 -0
- package/dist/dotnet/ManagedMemberRows.js +120 -0
- package/dist/dotnet/ManagedMetadataHeaps.js +131 -0
- package/dist/dotnet/ManagedMetadataInventory.js +104 -0
- package/dist/dotnet/ManagedMetadataInventoryRows.js +292 -0
- package/dist/dotnet/ManagedMetadataLayout.js +259 -0
- package/dist/dotnet/ManagedMetadataRowSizes.js +54 -0
- package/dist/dotnet/ManagedMethodBodyReader.js +143 -0
- package/dist/dotnet/ManagedNativeBoundaryHelpers.js +311 -0
- package/dist/dotnet/ManagedNativeBoundaryInspector.js +143 -0
- package/dist/dotnet/ManagedPeReader.js +188 -0
- package/dist/dotnet/ManagedReaderFailure.js +10 -0
- package/dist/dotnet/ManagedStaticProvider.js +203 -0
- package/dist/generatedPackageMetadata.js +2 -2
- package/dist/ghidra/GhidraClient.js +76 -91
- package/dist/ghidra/GhidraClientStartup.js +29 -0
- package/dist/ghidra/GhidraClientWire.js +34 -0
- package/dist/ghidra/GhidraDefaults.js +1 -1
- package/dist/ghidra/GhidraDiagnostics.js +6 -1
- package/dist/ghidra/GhidraInstallation.js +20 -15
- package/dist/ghidra/GhidraLauncher.js +93 -29
- package/dist/ghidra/GhidraProvider.js +67 -161
- package/dist/ghidra/GhidraProviderCapabilities.js +173 -0
- package/dist/ghidra/GhidraSessionValues.js +2 -0
- package/dist/ghidra/GhidraSocketConnection.js +44 -7
- package/dist/ghidra/GhidraTargetSnapshot.js +30 -0
- package/dist/ghidra/GhidraTransport.js +71 -0
- package/dist/identity.js +3 -2
- package/dist/main/messages.js +5 -0
- package/dist/main/reload.js +49 -0
- package/dist/main/shutdown.js +25 -0
- package/dist/main/startup.js +14 -0
- package/dist/main/state.js +26 -0
- package/dist/main/transport.js +61 -0
- package/dist/main/types.js +1 -0
- package/dist/main.js +35 -132
- package/dist/process/PrivateRuntimeRoot.js +3 -2
- package/dist/process/ProcessOwnership.js +35 -0
- package/dist/process/ProviderProcess.js +2 -0
- package/dist/replay/JavaScriptReplayWorker.js +300 -0
- package/dist/replay/LinuxJavaScriptReplayRunner.js +217 -0
- package/dist/replay/LinuxJavaScriptReplaySandbox.js +140 -0
- package/dist/replay/LinuxRuntimeClosure.js +46 -0
- package/dist/replay/LinuxSeccompPolicy.js +40 -0
- package/dist/replay/ReplayOutcome.js +95 -0
- package/dist/replay/ReplayProcessLifecycle.js +71 -0
- package/dist/replay/ReplayWorkerProtocol.js +55 -0
- package/dist/replay/SystemJavaScriptReplayHost.js +182 -0
- package/dist/server/ProcessCaptureElicitation.js +157 -0
- package/dist/server/createServer.js +158 -41
- package/dist/server/registerApplicationTools/characterization.js +57 -0
- package/dist/server/registerApplicationTools/compareVersions.js +34 -0
- package/dist/server/registerApplicationTools/controlledReplay.js +38 -0
- package/dist/server/registerApplicationTools/coverage.js +84 -0
- package/dist/server/registerApplicationTools/helpers.js +42 -0
- package/dist/server/registerApplicationTools/traceFeature.js +26 -0
- package/dist/server/registerApplicationTools/types.js +1 -0
- package/dist/server/registerApplicationTools.js +13 -0
- package/dist/server/registerArtifactComparisonTool.js +16 -9
- package/dist/server/registerBrowserTools.js +61 -60
- package/dist/server/registerBundleComparisonTool.js +17 -20
- package/dist/server/registerElectronTools.js +39 -12
- package/dist/server/registerEnhancedTools.js +52 -15
- package/dist/server/registerEvidenceResources.js +54 -0
- package/dist/server/registerEvidenceTools.js +5 -1
- package/dist/server/registerFunctionComparisonTool.js +14 -7
- package/dist/server/registerInvestigationTools/helpers.js +74 -0
- package/dist/server/registerInvestigationTools/types.js +1 -0
- package/dist/server/registerInvestigationTools.js +103 -132
- package/dist/server/registerManagedTools.js +6 -0
- package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +65 -0
- package/dist/server/registerManagedWorkflowTools/contract.js +8 -0
- package/dist/server/registerManagedWorkflowTools/evidence.js +43 -0
- package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +39 -0
- package/dist/server/registerManagedWorkflowTools/planManagedRuntimeCorrelation.js +39 -0
- package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +52 -0
- package/dist/server/registerManagedWorkflowTools/types.js +1 -0
- package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +75 -0
- package/dist/server/registerManagedWorkflowTools.js +13 -0
- package/dist/server/registerOfficialTools.js +81 -67
- package/dist/server/registerProcessComparisonTool.js +25 -47
- package/dist/server/registerSessionRecordTools.js +137 -0
- package/dist/server/registerSessionStatusTool.js +9 -8
- package/dist/server/registerSessionTools.js +77 -216
- package/dist/server/sessionAvailabilityPolicy.js +10 -0
- package/dist/server/sessionEvidence.js +14 -19
- package/dist/server/toolInputValidation.js +77 -0
- package/dist/server/toolRegistrationOptions.js +177 -2
- package/dist/server/toolResult.js +30 -17
- package/package.json +21 -14
- package/scripts/rea.mjs +1 -1
- package/skills/{rea-analysis → reverse-engineer-anything}/SKILL.md +75 -6
- package/scripts/prepare-node-pty.mjs +0 -35
- package/scripts/rebuild-native.mjs +0 -22
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { BrowserObservationError, } from "../domain/errors.js";
|
|
2
|
-
import {
|
|
2
|
+
import { stableWebResources } from "../domain/webInventory.js";
|
|
3
3
|
import { CdpConnection } from "./CdpConnection.js";
|
|
4
4
|
import { CdpCaptureEvents } from "./CdpCaptureEvents.js";
|
|
5
5
|
import { captureStorage } from "./CdpCaptureStorage.js";
|
|
6
6
|
import { optionalCdpCommand } from "./CdpOptionalCommand.js";
|
|
7
7
|
import { captureAccessibility, captureDom, captureFrames, captureResources, mainFrameUrl, } from "./CdpCaptureDocuments.js";
|
|
8
|
-
import { allowedSanitizedUrl, delayWithCancellation, isHttpUrl,
|
|
8
|
+
import { allowedSanitizedUrl, delayWithCancellation, isHttpUrl, } from "./CdpCaptureValues.js";
|
|
9
|
+
import { captureScripts } from "./CdpPageCaptureScripts.js";
|
|
10
|
+
import { captureWorkers } from "./CdpPageCaptureWorkers.js";
|
|
9
11
|
/** Capture and normalize one attached page without evaluating page JavaScript. */
|
|
10
12
|
export const capturePage = async (context) => {
|
|
11
13
|
const allowedOrigins = new Set(context.input.allowed_origins);
|
|
@@ -59,8 +61,14 @@ const captureAuthorizedPage = async (state) => {
|
|
|
59
61
|
const accessibility = await accessibilityForFrames(state, frames);
|
|
60
62
|
if (accessibility.total > accessibility.nodes.length)
|
|
61
63
|
state.events.completeness.truncate("accessibility");
|
|
62
|
-
const scripts = await captureScripts(
|
|
63
|
-
|
|
64
|
+
const scripts = await captureScripts({
|
|
65
|
+
context,
|
|
66
|
+
events: state.events,
|
|
67
|
+
rawResources: resourceCapture.items,
|
|
68
|
+
resources,
|
|
69
|
+
frameIds: new Set(frames.map((frame) => frame.frame_id)),
|
|
70
|
+
});
|
|
71
|
+
const workerCapture = await captureWorkers({ context, allowedOrigins, limitations, events: state.events }, new Set(frames.map((frame) => frame.frame_id)));
|
|
64
72
|
if (workerCapture.total > workerCapture.items.length)
|
|
65
73
|
state.events.completeness.truncate("workers");
|
|
66
74
|
const storageCapture = await captureStorage(context, frames[0]?.origin ?? new URL(attachedUrl).origin, limitations);
|
|
@@ -220,86 +228,6 @@ const accessibilityForFrames = async (state, frames) => {
|
|
|
220
228
|
events.completeness.truncate("accessibility");
|
|
221
229
|
return capture;
|
|
222
230
|
};
|
|
223
|
-
const captureScripts = async (context, events, rawResources, resources) => {
|
|
224
|
-
let totalSourceBytes = 0;
|
|
225
|
-
const drafts = [];
|
|
226
|
-
for (const script of events.scripts.values()) {
|
|
227
|
-
let source = sourceExcluded("source capture was not approved");
|
|
228
|
-
if (context.input.include_script_sources) {
|
|
229
|
-
if (script.length > context.input.limits.max_script_source_bytes) {
|
|
230
|
-
source = sourceExcluded("declared script length exceeds per-script limit");
|
|
231
|
-
events.completeness.truncate("script_sources");
|
|
232
|
-
}
|
|
233
|
-
else if (totalSourceBytes + script.length >
|
|
234
|
-
context.input.limits.max_total_script_source_bytes) {
|
|
235
|
-
source = sourceExcluded("total script source limit reached");
|
|
236
|
-
events.completeness.truncate("script_sources");
|
|
237
|
-
}
|
|
238
|
-
else {
|
|
239
|
-
const result = requiredRecord(await context.connection.send("Debugger.getScriptSource", { scriptId: script.scriptId }, context.sessionId, context.signal));
|
|
240
|
-
const content = stringValue(result.scriptSource) ?? "";
|
|
241
|
-
const bytes = Buffer.byteLength(content);
|
|
242
|
-
if (bytes > context.input.limits.max_script_source_bytes ||
|
|
243
|
-
totalSourceBytes + bytes >
|
|
244
|
-
context.input.limits.max_total_script_source_bytes) {
|
|
245
|
-
source = sourceExcluded("actual source exceeds configured byte limits");
|
|
246
|
-
events.completeness.truncate("script_sources");
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
source = sourceResult(content);
|
|
250
|
-
totalSourceBytes += bytes;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
const inventoryScript = {
|
|
255
|
-
url: script.url,
|
|
256
|
-
cdp_hash: script.hash,
|
|
257
|
-
length: script.length,
|
|
258
|
-
is_module: script.isModule,
|
|
259
|
-
language: script.language,
|
|
260
|
-
source_map_url: script.sourceMapUrl,
|
|
261
|
-
};
|
|
262
|
-
drafts.push({
|
|
263
|
-
item: {
|
|
264
|
-
...inventoryScript,
|
|
265
|
-
origin: script.origin,
|
|
266
|
-
resource_reconciliation: reconcileCapturedWebScript({ ...inventoryScript, rawUrl: script.rawUrl }, rawResources, resources),
|
|
267
|
-
source,
|
|
268
|
-
},
|
|
269
|
-
sourceMapRawUrl: script.sourceMapRawUrl,
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
if (!context.input.include_script_sources)
|
|
273
|
-
events.completeness.exclude("script_sources", "not_approved", events.scripts.size);
|
|
274
|
-
const keyed = drafts.map((draft) => ({
|
|
275
|
-
...draft,
|
|
276
|
-
base: stableWebScriptKey(draft.item),
|
|
277
|
-
}));
|
|
278
|
-
keyed.sort((left, right) => left.base.localeCompare(right.base) ||
|
|
279
|
-
sourceDigest(left.item.source).localeCompare(sourceDigest(right.item.source)));
|
|
280
|
-
const totals = new Map();
|
|
281
|
-
for (const { base } of keyed)
|
|
282
|
-
totals.set(base, (totals.get(base) ?? 0) + 1);
|
|
283
|
-
const seen = new Map();
|
|
284
|
-
const sourceMapRequests = [];
|
|
285
|
-
const items = keyed.map(({ base, item, sourceMapRawUrl }) => {
|
|
286
|
-
const occurrence = (seen.get(base) ?? 0) + 1;
|
|
287
|
-
seen.set(base, occurrence);
|
|
288
|
-
const scriptKey = totals.get(base) === 1 ? base : `${base}_${String(occurrence)}`;
|
|
289
|
-
if (item.source_map_url !== null && sourceMapRawUrl !== null)
|
|
290
|
-
sourceMapRequests.push({
|
|
291
|
-
scriptKey,
|
|
292
|
-
declaredUrl: item.source_map_url,
|
|
293
|
-
fetchUrl: sourceMapRawUrl,
|
|
294
|
-
});
|
|
295
|
-
return { script_key: scriptKey, ...item };
|
|
296
|
-
});
|
|
297
|
-
return {
|
|
298
|
-
inventory: { total: events.scripts.size, items },
|
|
299
|
-
sourceMapRequests,
|
|
300
|
-
};
|
|
301
|
-
};
|
|
302
|
-
const sourceDigest = (source) => (source.included ? source.artifact.sha256 : source.reason);
|
|
303
231
|
const publicResource = ({ rawUrl: _rawUrl, ...resource }) => resource;
|
|
304
232
|
const deduplicatedAgentHints = (hints) => {
|
|
305
233
|
const seen = new Set();
|
|
@@ -311,51 +239,6 @@ const deduplicatedAgentHints = (hints) => {
|
|
|
311
239
|
return true;
|
|
312
240
|
});
|
|
313
241
|
};
|
|
314
|
-
const captureWorkers = async (state, frameIds) => {
|
|
315
|
-
const { context, allowedOrigins, limitations, events } = state;
|
|
316
|
-
const completeness = events.completeness;
|
|
317
|
-
const result = await optionalCdpCommand({ ...context, sessionId: undefined }, "Target.getTargets", {}, limitations);
|
|
318
|
-
const items = [];
|
|
319
|
-
let total = 0;
|
|
320
|
-
if (result === undefined)
|
|
321
|
-
completeness.unavailable("workers");
|
|
322
|
-
for (const target of recordsValue(recordValue(result)?.targetInfos)) {
|
|
323
|
-
const type = stringValue(target.type) ?? "";
|
|
324
|
-
const url = allowedSanitizedUrl(target.url, allowedOrigins);
|
|
325
|
-
const relatedToPage = stringValue(target.openerId) === context.target.id ||
|
|
326
|
-
(stringValue(target.parentFrameId) !== undefined &&
|
|
327
|
-
frameIds.has(stringValue(target.parentFrameId) ?? ""));
|
|
328
|
-
if (!type.includes("worker"))
|
|
329
|
-
continue;
|
|
330
|
-
if (!relatedToPage) {
|
|
331
|
-
completeness.exclude("workers", "out_of_target_scope");
|
|
332
|
-
continue;
|
|
333
|
-
}
|
|
334
|
-
if (url === undefined) {
|
|
335
|
-
const rawUrl = stringValue(target.url);
|
|
336
|
-
completeness.exclude("workers", rawUrl === undefined || rawUrl === ""
|
|
337
|
-
? "unattributed_origin"
|
|
338
|
-
: isHttpUrl(rawUrl)
|
|
339
|
-
? "disallowed_origin"
|
|
340
|
-
: "unsupported_url");
|
|
341
|
-
continue;
|
|
342
|
-
}
|
|
343
|
-
total += 1;
|
|
344
|
-
if (items.length >= context.input.limits.max_workers)
|
|
345
|
-
continue;
|
|
346
|
-
items.push({
|
|
347
|
-
target_id: (stringValue(target.targetId) ?? "").slice(0, 256),
|
|
348
|
-
type: type.slice(0, 100),
|
|
349
|
-
url: url.url,
|
|
350
|
-
origin: url.origin,
|
|
351
|
-
attached: target.attached === true,
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
return {
|
|
355
|
-
total,
|
|
356
|
-
items,
|
|
357
|
-
};
|
|
358
|
-
};
|
|
359
242
|
const normalizedTarget = (target, currentUrl, allowedOrigins) => {
|
|
360
243
|
const url = allowedSanitizedUrl(currentUrl, allowedOrigins);
|
|
361
244
|
return {
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { reconcileCapturedWebScript, stableWebScriptKey, } from "../domain/webInventory.js";
|
|
2
|
+
import { requiredRecord, sourceExcluded, sourceResult, stringValue, } from "./CdpCaptureValues.js";
|
|
3
|
+
export const captureScripts = async (options) => {
|
|
4
|
+
const { context, events, rawResources, resources, frameIds } = options;
|
|
5
|
+
const state = {
|
|
6
|
+
context,
|
|
7
|
+
events,
|
|
8
|
+
frameIds,
|
|
9
|
+
rawResources,
|
|
10
|
+
resources,
|
|
11
|
+
totalSourceBytes: 0,
|
|
12
|
+
};
|
|
13
|
+
const drafts = [];
|
|
14
|
+
for (const script of events.scripts.values())
|
|
15
|
+
drafts.push(await buildScriptDraft(script, state));
|
|
16
|
+
if (!context.input.include_script_sources)
|
|
17
|
+
events.completeness.exclude("script_sources", "not_approved", events.scripts.size);
|
|
18
|
+
return keyAndBuildInventory(drafts, events.scripts.size);
|
|
19
|
+
};
|
|
20
|
+
const buildScriptDraft = async (script, state) => {
|
|
21
|
+
let source = state
|
|
22
|
+
.context.input.include_script_sources
|
|
23
|
+
? await captureScriptSource(script, state)
|
|
24
|
+
: sourceExcluded("source capture was not approved");
|
|
25
|
+
const inventoryScript = {
|
|
26
|
+
frame_id: state.events.frameForScript(script, state.frameIds),
|
|
27
|
+
url: script.url,
|
|
28
|
+
cdp_hash: script.hash,
|
|
29
|
+
length: script.length,
|
|
30
|
+
is_module: script.isModule,
|
|
31
|
+
language: script.language,
|
|
32
|
+
source_map_url: script.sourceMapUrl,
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
item: {
|
|
36
|
+
...inventoryScript,
|
|
37
|
+
origin: script.origin,
|
|
38
|
+
resource_reconciliation: reconcileCapturedWebScript({ ...inventoryScript, rawUrl: script.rawUrl }, state.rawResources, state.resources),
|
|
39
|
+
source,
|
|
40
|
+
},
|
|
41
|
+
sourceMapRawUrl: script.sourceMapRawUrl,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
const captureScriptSource = async (script, state) => {
|
|
45
|
+
const { context, events } = state;
|
|
46
|
+
if (script.length > context.input.limits.max_script_source_bytes) {
|
|
47
|
+
events.completeness.truncate("script_sources");
|
|
48
|
+
return sourceExcluded("declared script length exceeds per-script limit");
|
|
49
|
+
}
|
|
50
|
+
if (state.totalSourceBytes + script.length >
|
|
51
|
+
context.input.limits.max_total_script_source_bytes) {
|
|
52
|
+
events.completeness.truncate("script_sources");
|
|
53
|
+
return sourceExcluded("total script source limit reached");
|
|
54
|
+
}
|
|
55
|
+
const result = requiredRecord(await context.connection.send("Debugger.getScriptSource", { scriptId: script.scriptId }, context.sessionId, context.signal));
|
|
56
|
+
const content = stringValue(result.scriptSource) ?? "";
|
|
57
|
+
const bytes = Buffer.byteLength(content);
|
|
58
|
+
if (bytes > context.input.limits.max_script_source_bytes ||
|
|
59
|
+
state.totalSourceBytes + bytes >
|
|
60
|
+
context.input.limits.max_total_script_source_bytes) {
|
|
61
|
+
events.completeness.truncate("script_sources");
|
|
62
|
+
return sourceExcluded("actual source exceeds configured byte limits");
|
|
63
|
+
}
|
|
64
|
+
state.totalSourceBytes += bytes;
|
|
65
|
+
return sourceResult(content);
|
|
66
|
+
};
|
|
67
|
+
const keyAndBuildInventory = (drafts, scriptCount) => {
|
|
68
|
+
const keyed = drafts.map((draft) => ({
|
|
69
|
+
...draft,
|
|
70
|
+
base: stableWebScriptKey(draft.item),
|
|
71
|
+
}));
|
|
72
|
+
keyed.sort((left, right) => left.base.localeCompare(right.base) ||
|
|
73
|
+
sourceDigest(left.item.source).localeCompare(sourceDigest(right.item.source)) ||
|
|
74
|
+
(left.item.frame_id ?? "").localeCompare(right.item.frame_id ?? ""));
|
|
75
|
+
const totals = new Map();
|
|
76
|
+
for (const { base } of keyed)
|
|
77
|
+
totals.set(base, (totals.get(base) ?? 0) + 1);
|
|
78
|
+
const seen = new Map();
|
|
79
|
+
const sourceMapRequests = [];
|
|
80
|
+
const items = keyed.map(({ base, item, sourceMapRawUrl }) => {
|
|
81
|
+
const occurrence = (seen.get(base) ?? 0) + 1;
|
|
82
|
+
seen.set(base, occurrence);
|
|
83
|
+
const scriptKey = totals.get(base) === 1 ? base : `${base}_${String(occurrence)}`;
|
|
84
|
+
if (item.source_map_url !== null && sourceMapRawUrl !== null)
|
|
85
|
+
sourceMapRequests.push({
|
|
86
|
+
scriptKey,
|
|
87
|
+
declaredUrl: item.source_map_url,
|
|
88
|
+
fetchUrl: sourceMapRawUrl,
|
|
89
|
+
});
|
|
90
|
+
return { script_key: scriptKey, ...item };
|
|
91
|
+
});
|
|
92
|
+
return {
|
|
93
|
+
inventory: { total: scriptCount, items },
|
|
94
|
+
sourceMapRequests,
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
const sourceDigest = (source) => (source.included ? source.artifact.sha256 : source.reason);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { allowedSanitizedUrl, boundedText, isHttpUrl, recordValue, recordsValue, stringValue, } from "./CdpCaptureValues.js";
|
|
2
|
+
import { optionalCdpCommand } from "./CdpOptionalCommand.js";
|
|
3
|
+
export const captureWorkers = async (input, frameIds) => {
|
|
4
|
+
const { context, allowedOrigins, limitations, events } = input;
|
|
5
|
+
const completeness = events.completeness;
|
|
6
|
+
const result = await optionalCdpCommand({ ...context, sessionId: undefined }, "Target.getTargets", {}, limitations);
|
|
7
|
+
const items = [];
|
|
8
|
+
let total = 0;
|
|
9
|
+
if (result === undefined)
|
|
10
|
+
completeness.unavailable("workers");
|
|
11
|
+
for (const target of recordsValue(recordValue(result)?.targetInfos)) {
|
|
12
|
+
const type = stringValue(target.type) ?? "";
|
|
13
|
+
const url = allowedSanitizedUrl(target.url, allowedOrigins);
|
|
14
|
+
const relatedToPage = stringValue(target.openerId) === context.target.id ||
|
|
15
|
+
(stringValue(target.parentFrameId) !== undefined &&
|
|
16
|
+
frameIds.has(stringValue(target.parentFrameId) ?? ""));
|
|
17
|
+
if (!type.includes("worker"))
|
|
18
|
+
continue;
|
|
19
|
+
if (!relatedToPage) {
|
|
20
|
+
completeness.exclude("workers", "out_of_target_scope");
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (url === undefined) {
|
|
24
|
+
const rawUrl = stringValue(target.url);
|
|
25
|
+
completeness.exclude("workers", rawUrl === undefined || rawUrl === ""
|
|
26
|
+
? "unattributed_origin"
|
|
27
|
+
: isHttpUrl(rawUrl)
|
|
28
|
+
? "disallowed_origin"
|
|
29
|
+
: "unsupported_url");
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
total += 1;
|
|
33
|
+
if (items.length >= context.input.limits.max_workers)
|
|
34
|
+
continue;
|
|
35
|
+
items.push({
|
|
36
|
+
target_id: (stringValue(target.targetId) ?? "").slice(0, 256),
|
|
37
|
+
type: type.slice(0, 100),
|
|
38
|
+
url: url.url,
|
|
39
|
+
origin: url.origin,
|
|
40
|
+
attached: target.attached === true,
|
|
41
|
+
opener_target_id: boundedText(target.openerId, 256) ?? null,
|
|
42
|
+
parent_frame_id: boundedText(target.parentFrameId, 256) ?? null,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return { total, items };
|
|
46
|
+
};
|
|
@@ -35,7 +35,13 @@ export const discoverWebMcp = async (context) => {
|
|
|
35
35
|
return;
|
|
36
36
|
if (ingestFrameScopeEvent(event, frameScope))
|
|
37
37
|
return;
|
|
38
|
-
ingestWebMcpEvent(
|
|
38
|
+
ingestWebMcpEvent({
|
|
39
|
+
event,
|
|
40
|
+
input: context.input,
|
|
41
|
+
frames: frameUrls,
|
|
42
|
+
tools,
|
|
43
|
+
completeness,
|
|
44
|
+
});
|
|
39
45
|
});
|
|
40
46
|
await context.progress?.report({
|
|
41
47
|
phase: "browser_observation",
|
|
@@ -53,7 +59,14 @@ export const discoverWebMcp = async (context) => {
|
|
|
53
59
|
// CDP sends the enable response before the required toolsAdded replay.
|
|
54
60
|
await delayWithCancellation(Math.max(context.input.observation_ms, 25), "discover_webmcp_tools", context.signal);
|
|
55
61
|
await assertStableAuthorizedFrame(context, initialUrl, origins);
|
|
56
|
-
return
|
|
62
|
+
return buildWebMcpResult({
|
|
63
|
+
context,
|
|
64
|
+
frameTree,
|
|
65
|
+
tools,
|
|
66
|
+
completeness,
|
|
67
|
+
limitations,
|
|
68
|
+
available,
|
|
69
|
+
});
|
|
57
70
|
}
|
|
58
71
|
finally {
|
|
59
72
|
removeListener();
|
|
@@ -70,18 +83,27 @@ const ingestFrameScopeEvent = (event, state) => {
|
|
|
70
83
|
const params = recordValue(event.params);
|
|
71
84
|
if (params === undefined)
|
|
72
85
|
return false;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
86
|
+
switch (event.method) {
|
|
87
|
+
case "Page.frameDetached":
|
|
88
|
+
return handleFrameDetached(params, state);
|
|
89
|
+
case "Page.frameNavigated":
|
|
90
|
+
return handleFrameUpdate(recordValue(params.frame), state);
|
|
91
|
+
case "Page.navigatedWithinDocument":
|
|
92
|
+
return handleFrameUpdate(params, state);
|
|
93
|
+
default:
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const handleFrameDetached = (params, state) => {
|
|
98
|
+
const frameId = stringValue(params.frameId);
|
|
99
|
+
if (frameId === undefined || frameId.length > 256) {
|
|
100
|
+
state.completeness.exclude("webmcp_tools", "invalid_protocol_value");
|
|
79
101
|
return true;
|
|
80
102
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
103
|
+
removeFrame(frameId, state.frames, state.tools);
|
|
104
|
+
return true;
|
|
105
|
+
};
|
|
106
|
+
const handleFrameUpdate = (frame, state) => {
|
|
85
107
|
const frameId = stringValue(frame?.id) ?? stringValue(frame?.frameId);
|
|
86
108
|
if (frameId === undefined || frameId.length > 256) {
|
|
87
109
|
state.completeness.exclude("webmcp_tools", "invalid_protocol_value");
|
|
@@ -128,7 +150,8 @@ const assertStableAuthorizedFrame = async (context, initialUrl, origins) => {
|
|
|
128
150
|
if (finalUrl !== initialUrl)
|
|
129
151
|
throw new BrowserObservationError("inspect_web_page", "target_changed");
|
|
130
152
|
};
|
|
131
|
-
const ingestWebMcpEvent = (
|
|
153
|
+
const ingestWebMcpEvent = (options) => {
|
|
154
|
+
const { event, input, frames, tools, completeness } = options;
|
|
132
155
|
const params = recordValue(event.params);
|
|
133
156
|
if (params === undefined)
|
|
134
157
|
return;
|
|
@@ -214,7 +237,8 @@ const registrationSource = (stack, allowedOrigins) => {
|
|
|
214
237
|
column: integerOrNull(frame.columnNumber),
|
|
215
238
|
};
|
|
216
239
|
};
|
|
217
|
-
const
|
|
240
|
+
const buildWebMcpResult = (options) => {
|
|
241
|
+
const { context, frameTree, tools, completeness, limitations, available } = options;
|
|
218
242
|
const targetUrl = mainFrameUrl(frameTree) ?? context.target.url;
|
|
219
243
|
const sanitized = allowedSanitizedUrl(targetUrl, new Set(context.input.allowed_origins));
|
|
220
244
|
return {
|
|
@@ -128,7 +128,13 @@ const unfilter = (raw, width, height, channels) => {
|
|
|
128
128
|
const upperLeft = row > 0 && column >= channels
|
|
129
129
|
? (decoded[outputOffset + column - rowBytes - channels] ?? 0)
|
|
130
130
|
: 0;
|
|
131
|
-
decoded[outputOffset + column] = applyFilter(
|
|
131
|
+
decoded[outputOffset + column] = applyFilter({
|
|
132
|
+
filter,
|
|
133
|
+
source,
|
|
134
|
+
left,
|
|
135
|
+
above,
|
|
136
|
+
upperLeft,
|
|
137
|
+
});
|
|
132
138
|
}
|
|
133
139
|
}
|
|
134
140
|
if (channels === 4)
|
|
@@ -142,7 +148,8 @@ const unfilter = (raw, width, height, channels) => {
|
|
|
142
148
|
}
|
|
143
149
|
return rgba;
|
|
144
150
|
};
|
|
145
|
-
const applyFilter = (
|
|
151
|
+
const applyFilter = (options) => {
|
|
152
|
+
const { filter, source, left, above, upperLeft } = options;
|
|
146
153
|
switch (filter) {
|
|
147
154
|
case 0:
|
|
148
155
|
return source;
|
package/dist/catalogIdentity.js
CHANGED
|
@@ -7,8 +7,10 @@ import { CLI_COMMAND_NAMES } from "./cliCommandNames.js";
|
|
|
7
7
|
export { CLI_COMMAND_NAMES } from "./cliCommandNames.js";
|
|
8
8
|
const toolCatalog = TOOL_CONTRACTS.map((contract) => ({
|
|
9
9
|
name: contract.name,
|
|
10
|
+
title: contract.title,
|
|
10
11
|
surface: contract.kind,
|
|
11
12
|
description: contract.description,
|
|
13
|
+
effects: { ...contract.effects },
|
|
12
14
|
annotations: contract.annotations,
|
|
13
15
|
input_schema: z.toJSONSchema(contract.inputSchema, {
|
|
14
16
|
unrepresentable: "any",
|
|
@@ -51,6 +53,10 @@ const resourceTemplateCatalog = [
|
|
|
51
53
|
name: "investigation-workspace-revision",
|
|
52
54
|
uri_template: "rea://workspace/{workspaceId}/revision/{revision}",
|
|
53
55
|
},
|
|
56
|
+
{
|
|
57
|
+
name: "reconstruction-coverage-revision",
|
|
58
|
+
uri_template: "rea://reconstruction-coverage/{workspaceId}/revision/{revision}",
|
|
59
|
+
},
|
|
54
60
|
];
|
|
55
61
|
const digest = (value) => {
|
|
56
62
|
const encoded = canonicalize(value);
|
|
@@ -79,9 +85,10 @@ export const CATALOG_IDENTITY = {
|
|
|
79
85
|
resource_templates: resourceTemplateCatalog,
|
|
80
86
|
}),
|
|
81
87
|
},
|
|
82
|
-
tools: toolCatalog.map(({ name, surface, annotations }) => ({
|
|
88
|
+
tools: toolCatalog.map(({ name, surface, effects, annotations }) => ({
|
|
83
89
|
name,
|
|
84
90
|
surface,
|
|
91
|
+
effects,
|
|
85
92
|
annotations: {
|
|
86
93
|
read_only: annotations.readOnlyHint ?? false,
|
|
87
94
|
destructive: annotations.destructiveHint ?? false,
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from "incur";
|
|
2
|
+
import { runProviderAnalysis } from "../application/DirectAnalysis.js";
|
|
3
|
+
import { logCliCommand } from "../cliLogging.js";
|
|
4
|
+
import { CLI_COMMANDS } from "../cliCommandNames.js";
|
|
5
|
+
export const registerArtifactCommands = (cli, logger) => {
|
|
6
|
+
cli.command(CLI_COMMANDS.inventoryArtifact, {
|
|
7
|
+
description: "Build a bounded deterministic artifact graph",
|
|
8
|
+
args: z.object({
|
|
9
|
+
path: z.string().describe("Application or package path"),
|
|
10
|
+
}),
|
|
11
|
+
options: z.object({
|
|
12
|
+
offset: z
|
|
13
|
+
.number()
|
|
14
|
+
.int()
|
|
15
|
+
.min(0)
|
|
16
|
+
.default(0)
|
|
17
|
+
.describe("Zero-based offset for graph nodes, occurrences, and edges"),
|
|
18
|
+
limit: z
|
|
19
|
+
.number()
|
|
20
|
+
.int()
|
|
21
|
+
.min(1)
|
|
22
|
+
.max(500)
|
|
23
|
+
.default(100)
|
|
24
|
+
.describe("Maximum nodes, occurrences, and edges per result section"),
|
|
25
|
+
integrityPolicy: z
|
|
26
|
+
.enum(["fail", "record-and-continue"])
|
|
27
|
+
.default("fail")
|
|
28
|
+
.describe("Behavior when declared artifact integrity does not match"),
|
|
29
|
+
integrityContinueApproved: z
|
|
30
|
+
.boolean()
|
|
31
|
+
.default(false)
|
|
32
|
+
.describe("Approve continuing after recorded integrity mismatches"),
|
|
33
|
+
maxIntegrityMismatches: z
|
|
34
|
+
.number()
|
|
35
|
+
.int()
|
|
36
|
+
.min(1)
|
|
37
|
+
.max(100)
|
|
38
|
+
.default(10)
|
|
39
|
+
.describe("Maximum integrity mismatches to record before stopping"),
|
|
40
|
+
nativeMountApproved: z
|
|
41
|
+
.boolean()
|
|
42
|
+
.default(false)
|
|
43
|
+
.describe("Approve read-only native mounting when required"),
|
|
44
|
+
}),
|
|
45
|
+
alias: {
|
|
46
|
+
integrityPolicy: "integrity-policy",
|
|
47
|
+
integrityContinueApproved: "integrity-continue-approved",
|
|
48
|
+
maxIntegrityMismatches: "max-integrity-mismatches",
|
|
49
|
+
nativeMountApproved: "native-mount-approved",
|
|
50
|
+
},
|
|
51
|
+
run: ({ args, options }) => logCliCommand(logger, "inventory-artifact", () => runProviderAnalysis(args.path, "inventory_artifact", {
|
|
52
|
+
node_offset: options.offset,
|
|
53
|
+
node_limit: options.limit,
|
|
54
|
+
occurrence_offset: options.offset,
|
|
55
|
+
occurrence_limit: options.limit,
|
|
56
|
+
edge_offset: options.offset,
|
|
57
|
+
edge_limit: options.limit,
|
|
58
|
+
integrity_policy: options.integrityPolicy,
|
|
59
|
+
integrity_continue_approved: options.integrityContinueApproved,
|
|
60
|
+
max_integrity_mismatches: options.maxIntegrityMismatches,
|
|
61
|
+
native_mount_approved: options.nativeMountApproved,
|
|
62
|
+
}, logger)),
|
|
63
|
+
});
|
|
64
|
+
cli.command(CLI_COMMANDS.extractArtifact, {
|
|
65
|
+
description: "Extract explicitly selected artifact occurrences safely",
|
|
66
|
+
args: z.object({
|
|
67
|
+
path: z.string().describe("Application or package path"),
|
|
68
|
+
outputRoot: z.string().describe("Absent absolute output root"),
|
|
69
|
+
occurrenceIds: z
|
|
70
|
+
.array(z.string().regex(/^occ_[a-f0-9]{64}$/u))
|
|
71
|
+
.min(1)
|
|
72
|
+
.max(500)
|
|
73
|
+
.describe("Exact artifact occurrence IDs selected for extraction"),
|
|
74
|
+
}),
|
|
75
|
+
alias: { outputRoot: "output-root", occurrenceIds: "occurrence-ids" },
|
|
76
|
+
run: ({ args }) => logCliCommand(logger, "extract-artifact", () => runProviderAnalysis(args.path, "extract_artifact", {
|
|
77
|
+
approved: true,
|
|
78
|
+
output_root: args.outputRoot,
|
|
79
|
+
occurrence_ids: args.occurrenceIds,
|
|
80
|
+
}, logger)),
|
|
81
|
+
});
|
|
82
|
+
};
|