rea-agents 3.2.0 → 4.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 +183 -332
- package/bridge/ghidra/ReaGhidraBridge.java +561 -74
- package/bridge/hopper_bridge.py +70 -27
- package/bridge/native/ReaNativeUI.swift +157 -0
- package/dist/application/AnalysisContextQueries.js +19 -5
- package/dist/application/AnalysisSnapshotCache.js +30 -11
- package/dist/application/AppleAssetCatalogAnalysis.js +171 -0
- package/dist/application/ArtifactExtractionDestination.js +0 -12
- package/dist/application/ArtifactGraphConstruction.js +44 -11
- package/dist/application/ArtifactInventory/classify.js +7 -15
- package/dist/application/ArtifactInventory/hash.js +4 -2
- package/dist/application/ArtifactInventory/policy.js +2 -17
- package/dist/application/ArtifactInventory/reader.js +3 -3
- package/dist/application/ArtifactInventory/scanCanonical.js +2 -2
- package/dist/application/ArtifactInventory/scanReader.js +12 -4
- package/dist/application/ArtifactInventory/types.js +0 -3
- package/dist/application/BinarySession.js +28 -43
- package/dist/application/BinarySessionExecution.js +37 -1
- package/dist/application/BinaryTargetResolver.js +50 -4
- package/dist/application/BrowserEvidence.js +36 -7
- package/dist/application/BrowserObservationService.js +17 -44
- package/dist/application/BrowserScenarioCaptureService.js +2 -35
- package/dist/application/BrowserScenarioEvidence.js +13 -9
- package/dist/application/CapabilityClientRequirements.js +2 -11
- package/dist/application/CapabilityInventory.js +21 -35
- package/dist/application/ClientConfigurationDocument.js +84 -7
- package/dist/application/ClientRegistrationIdentity.js +32 -0
- package/dist/application/ClientRegistrationStatus.js +59 -6
- package/dist/application/DirectAnalysis.js +37 -58
- package/dist/application/DirectAnalysisStatus.js +4 -4
- package/dist/application/Doctor.js +89 -80
- package/dist/application/DoctorDiagnostics.js +2 -26
- package/dist/application/DoctorScope.js +8 -14
- package/dist/application/ElectronActiveEvidence.js +10 -27
- package/dist/application/ElectronActiveObservationService.js +9 -36
- package/dist/application/ElectronBoundaryAnalysis.js +2 -0
- package/dist/application/ElectronBoundaryGraphNative.js +1 -1
- package/dist/application/ElectronEvidence.js +8 -3
- package/dist/application/ElectronObservationService.js +9 -25
- package/dist/application/EnhancedLiteralTracing.js +4 -8
- package/dist/application/EnhancedTools.js +15 -35
- package/dist/application/FilesystemSnapshot.js +7 -8
- package/dist/application/JavaScriptApplicationEvidenceGraph.js +2 -1
- package/dist/application/JavaScriptApplicationWorkflowService.js +31 -7
- package/dist/application/JavaScriptArtifactAnalysis.js +6 -4
- package/dist/application/JavaScriptArtifactFiles.js +5 -0
- package/dist/application/JavaScriptArtifactPathResolution.js +179 -47
- package/dist/application/JavaScriptRuntimeObservationEvidence.js +6 -3
- package/dist/application/JavaScriptRuntimeObservationService.js +9 -25
- package/dist/application/JavaScriptRuntimeReconciliationService.js +45 -4
- package/dist/application/JavaScriptSemanticGraphAsyncProjection.js +11 -0
- package/dist/application/JavaScriptSemanticGraphChildProcessProjection.js +11 -0
- package/dist/application/JavaScriptSemanticGraphDataProjection.js +11 -0
- package/dist/application/JavaScriptSemanticGraphFlowProjection.js +14 -5
- package/dist/application/JsonFiles.js +1 -1
- package/dist/application/LazyAnalysisProvider.js +27 -6
- package/dist/application/ManagedMemberComparisonService.js +19 -6
- package/dist/application/NativeApiInspection.js +2 -0
- package/dist/application/NativeCallRoutes.js +72 -0
- package/dist/application/NativeDispatchMetadataInspection.js +33 -0
- package/dist/application/NativeUiActionTrace.js +73 -49
- package/dist/application/NativeValueTrace.js +320 -0
- package/dist/application/ProcessCaptureCapability.js +32 -5
- package/dist/application/ProcessCaptureEnvironment.js +9 -26
- package/dist/application/ProcessCaptureError.js +1 -5
- package/dist/application/ProcessCaptureJournal.js +3 -40
- package/dist/application/ProcessCaptureLifecycle.js +102 -111
- package/dist/application/ProcessCli.js +18 -25
- package/dist/application/ProcessEvidence.js +5 -7
- package/dist/application/ProcessFilesystemEffects.js +36 -0
- package/dist/application/ProcessHarness.js +41 -120
- package/dist/application/ProcessNormalization.js +2 -17
- package/dist/application/ProcessScenarioRuntimeValidation.js +76 -0
- package/dist/application/ReferenceSourceImport.js +3 -4
- package/dist/application/Setup.js +236 -84
- package/dist/application/SetupClientConfiguration.js +14 -9
- package/dist/application/SetupPlan.js +138 -86
- package/dist/application/SetupSkill.js +0 -1
- package/dist/application/SupportedClients.js +102 -21
- package/dist/application/Uninstall.js +31 -20
- package/dist/application/Update.js +93 -0
- package/dist/application/UpdateMaintenance.js +108 -0
- package/dist/application/UpdateRuntime.js +126 -0
- package/dist/application/runtime.js +13 -2
- package/dist/artifacts/ArtifactPaths.js +6 -8
- package/dist/artifacts/ArtifactProvider.js +94 -41
- package/dist/artifacts/AsarArtifactReader.js +19 -4
- package/dist/artifacts/KeyedArchiveReader.js +110 -0
- package/dist/artifacts/MachOSliceArtifactReader.js +53 -5
- package/dist/artifacts/ZipArtifactReader.js +18 -1
- package/dist/browser/BrowserScenarioSecrets.js +28 -1
- package/dist/browser/CdpBrowserProvider.js +36 -15
- package/dist/browser/CdpCaptureDocuments.js +22 -8
- package/dist/browser/CdpCaptureEventHandlers.js +14 -5
- package/dist/browser/CdpCaptureEventHelpers.js +13 -0
- package/dist/browser/CdpCaptureEvents.js +10 -1
- package/dist/browser/CdpElectronInspection.js +5 -10
- package/dist/browser/CdpElectronProvider.js +1 -5
- package/dist/browser/CdpElectronScripts.js +1 -1
- package/dist/browser/CdpEndpoint.js +3 -2
- package/dist/browser/CdpObservationSession.js +14 -10
- package/dist/browser/CdpPageCapture.js +1 -1
- package/dist/browser/CdpPageCaptureScripts.js +1 -1
- package/dist/browser/CdpSafeMetadata.js +5 -4
- package/dist/browser/CdpScreenshot.js +16 -5
- package/dist/browser/CdpTargetSession.js +25 -4
- package/dist/browser/CdpWebMcpDiscovery.js +93 -20
- package/dist/browser/JavaScriptRuntimeScope.js +28 -2
- package/dist/browser/PlaywrightBrowserScenarioProvider.js +9 -8
- package/dist/browser/PlaywrightElectronActiveActions.js +3 -10
- package/dist/browser/PlaywrightElectronActiveProvider.js +5 -5
- package/dist/browser/PlaywrightScenarioActions.js +1 -1
- package/dist/browser/PlaywrightScenarioArtifacts.js +13 -25
- package/dist/browser/PlaywrightScenarioBrowser.js +28 -25
- package/dist/browser/PlaywrightScenarioEvents.js +82 -93
- package/dist/browser/PlaywrightScenarioSession.js +27 -123
- package/dist/browser/PngVisualDiff.js +22 -3
- package/dist/browser/V8InspectorCaptureProjection.js +7 -1
- package/dist/browser/V8InspectorProvider.js +60 -7
- package/dist/browser/WebSourceMapFetcher.js +99 -53
- package/dist/cli/artifactCommands.js +56 -12
- package/dist/cli/coreAnalysisCommands.js +110 -0
- package/dist/cli/managedCommands.js +1 -31
- package/dist/cli/setupCommands.js +16 -14
- package/dist/cli/utilityCommands.js +61 -4
- package/dist/cli.js +5 -7
- package/dist/cliApplicationCommands.js +0 -83
- package/dist/cliBrowserAdvancedCommands.js +7 -11
- package/dist/cliBrowserCommands.js +15 -23
- package/dist/cliBrowserContext.js +3 -24
- package/dist/cliBrowserScenarioCommands.js +2 -10
- package/dist/cliCommandNames.js +82 -7
- package/dist/cliElectronCommands.js +10 -36
- package/dist/cliJavaScriptRuntimeCommands.js +6 -30
- package/dist/cliJsonInput.js +4 -2
- package/dist/cliLogging.js +16 -7
- package/dist/cliObservationOptions.js +1 -1
- package/dist/cliOutput.js +2 -4
- package/dist/cliProcessCommands.js +6 -33
- package/dist/cliSetup.js +90 -160
- package/dist/config/environment.js +2 -78
- package/dist/config/parseConfig.js +18 -109
- package/dist/config/parsers.js +0 -23
- package/dist/contracts/applicationToolContracts.js +1 -118
- package/dist/contracts/artifactToolContracts.js +11 -19
- package/dist/contracts/browserScenarioToolContracts.js +1 -5
- package/dist/contracts/browserToolContracts.js +9 -16
- package/dist/contracts/electronToolContracts.js +5 -6
- package/dist/contracts/enhancedInputs.js +3 -2
- package/dist/contracts/errorSchemas.js +16 -40
- package/dist/contracts/functionWorkflowToolContracts.js +2 -2
- package/dist/contracts/javascriptApplicationWorkflowExamples.js +2 -2
- package/dist/contracts/javascriptRuntimeObservationToolContracts.js +4 -4
- package/dist/contracts/javascriptRuntimeReconciliationExample.js +1 -1
- package/dist/contracts/managedToolContracts.js +7 -4
- package/dist/contracts/managedWorkflowExamples.js +0 -22
- package/dist/contracts/managedWorkflowToolContracts.js +16 -31
- package/dist/contracts/nativeToolContracts.js +9 -0
- package/dist/contracts/promptContracts.js +6 -6
- package/dist/contracts/sessionToolSchemas.js +3 -3
- package/dist/contracts/toolContractExamples.js +4 -3
- package/dist/contracts/toolContracts.js +18 -7
- package/dist/contracts/toolEffects.js +34 -21
- package/dist/contracts/toolOutputSchemaGroups.js +18 -5
- package/dist/contracts/toolOutputSchemaPrimitives.js +9 -6
- package/dist/contracts/toolSchemaMetadata.js +5 -8
- package/dist/doctorRuntime.js +0 -41
- package/dist/domain/analysisErrorPresentation.js +4 -28
- package/dist/domain/analysisErrorProjection.js +33 -50
- package/dist/domain/analysisProfile.js +1 -1
- package/dist/domain/analysisSnapshot.js +77 -3
- package/dist/domain/androidApplication.js +5 -4
- package/dist/domain/appleApplication.js +5 -4
- package/dist/domain/appleAssetCatalog.js +127 -0
- package/dist/domain/artifactComparison.js +7 -11
- package/dist/domain/artifactGraph.js +8 -6
- package/dist/domain/artifactInspection.js +13 -12
- package/dist/domain/binaryTarget.js +23 -9
- package/dist/domain/browserObservation.js +43 -24
- package/dist/domain/browserObservationSchemas.js +2 -1
- package/dist/domain/browserScenario.js +7 -107
- package/dist/domain/browserScenarioCapture.js +0 -1
- package/dist/domain/browserScenarioCaptureValues.js +5 -4
- package/dist/domain/browserScenarioDiff.js +1 -3
- package/dist/domain/browserScenarioValues.js +16 -107
- package/dist/domain/bundleComparison.js +18 -17
- package/dist/domain/callPathSchemas.js +17 -7
- package/dist/domain/changedBehavior.js +2 -3
- package/dist/domain/comparisonSemantics.js +19 -0
- package/dist/domain/completionLedgerGeneration.js +3 -2
- package/dist/domain/conformancePackage.js +2 -1
- package/dist/domain/conformanceTrustGate.js +3 -5
- package/dist/domain/customProtocolCapture.js +2 -2
- package/dist/domain/digests.js +30 -0
- package/dist/domain/dosMz.js +83 -0
- package/dist/domain/electronActiveObservation.js +7 -5
- package/dist/domain/electronObservation.js +3 -2
- package/dist/domain/electronStaticAnalysisNative.js +15 -6
- package/dist/domain/emptyArraySchema.js +3 -0
- package/dist/domain/errors.js +10 -28
- package/dist/domain/evidence.js +5 -3
- package/dist/domain/evidenceCompletionLedger.js +3 -2
- package/dist/domain/functionComparisonNormalization.js +24 -18
- package/dist/domain/functionComparisonResults.js +3 -7
- package/dist/domain/functionComparisonSchemas.js +3 -2
- package/dist/domain/hopperValues.js +108 -8
- package/dist/domain/javascriptApplicationAnalysis.js +4 -7
- package/dist/domain/javascriptApplicationEvidenceSchemas.js +4 -3
- package/dist/domain/javascriptApplicationGraphSchemas.js +8 -7
- package/dist/domain/javascriptApplicationVersionComparisonSchemas.js +9 -7
- package/dist/domain/javascriptApplicationVersionItems.js +12 -18
- package/dist/domain/javascriptAstValues.js +4 -0
- package/dist/domain/javascriptExportShapeComparison.js +1 -6
- package/dist/domain/javascriptExportShapeComparisonSchemas.js +6 -10
- package/dist/domain/javascriptExportShapeVariants.js +15 -2
- package/dist/domain/javascriptFeatureTraceSchemas.js +8 -7
- package/dist/domain/javascriptRuntimeObservation.js +14 -2
- package/dist/domain/javascriptRuntimeReconciliationMatching.js +8 -0
- package/dist/domain/javascriptRuntimeReconciliationParsing.js +4 -2
- package/dist/domain/javascriptRuntimeReconciliationResult.js +6 -4
- package/dist/domain/javascriptRuntimeReconciliationRuntime.js +15 -4
- package/dist/domain/javascriptRuntimeReconciliationSchemas.js +19 -18
- package/dist/domain/javascriptRuntimeStaticCandidates.js +18 -6
- package/dist/domain/javascriptSemanticAnalysis.js +57 -19
- package/dist/domain/javascriptSemanticAsyncEffects.js +39 -40
- package/dist/domain/javascriptSemanticCalls.js +46 -27
- package/dist/domain/javascriptSemanticChildProcesses.js +43 -50
- package/dist/domain/javascriptSemanticDataEffectHelpers.js +91 -18
- package/dist/domain/javascriptSemanticDataEffects.js +22 -10
- package/dist/domain/javascriptSemanticGraphSchemas.js +8 -6
- package/dist/domain/javascriptSemanticObjects.js +13 -3
- package/dist/domain/javascriptSemanticProjection.js +144 -38
- package/dist/domain/javascriptSemanticPromises.js +14 -27
- package/dist/domain/javascriptSemanticQuerySchemas.js +6 -9
- package/dist/domain/javascriptSemanticResources.js +2 -5
- package/dist/domain/javascriptSemanticState.js +4 -0
- package/dist/domain/javascriptSemanticTraceSchemas.js +2 -1
- package/dist/domain/javascriptSemanticTraversal.js +13 -5
- package/dist/domain/javascriptSemanticValues.js +10 -9
- package/dist/domain/javascriptSourceParser.js +5 -1
- package/dist/domain/javascriptStaticAnalysisCalls.js +8 -5
- package/dist/domain/javascriptStaticAnalysisHelpers.js +16 -7
- package/dist/domain/keyedArchive.js +181 -0
- package/dist/domain/managedApplicationGraph.js +4 -3
- package/dist/domain/managedArtifact.js +2 -1
- package/dist/domain/managedMemberComparison.js +18 -13
- package/dist/domain/managedMemberComparisonCoverage.js +2 -1
- package/dist/domain/managedMemberComparisonItems.js +27 -7
- package/dist/domain/managedMemberComparisonMatch.js +22 -6
- package/dist/domain/managedNativeVerificationMatch.js +2 -2
- package/dist/domain/managedNativeVerificationSchemas.js +7 -5
- package/dist/domain/managedReconstruction.js +6 -5
- package/dist/domain/nativeApiBoundary.js +7 -0
- package/dist/domain/nativeDataType.js +51 -0
- package/dist/domain/nativeInspection.js +0 -1
- package/dist/domain/nativeInstruction.js +82 -0
- package/dist/domain/nativeInvestigationGraph.js +9 -5
- package/dist/domain/nativeUiObservation.js +123 -0
- package/dist/domain/nativeValueFlow.js +17 -0
- package/dist/domain/nativeValueTrace.js +64 -0
- package/dist/domain/objcSwiftMetadata.js +39 -0
- package/dist/domain/peInspection.js +1 -0
- package/dist/domain/processCapture.js +5 -55
- package/dist/domain/processCaptureExample.js +0 -9
- package/dist/domain/processCaptureValidation.js +13 -144
- package/dist/domain/processComparison.js +3 -25
- package/dist/domain/processObservation.js +0 -29
- package/dist/domain/processScenario.js +28 -228
- package/dist/domain/processTraceDimensionProjection.js +0 -15
- package/dist/domain/processTraceEvaluation.js +0 -6
- package/dist/domain/protocolCapture.js +8 -36
- package/dist/domain/reconstructionCoverage.js +3 -2
- package/dist/domain/reconstructionObligationLedgerSchemas.js +4 -12
- package/dist/domain/reconstructionReadinessSchemas.js +4 -3
- package/dist/domain/reconstructionVerification.js +2 -1
- package/dist/domain/reconstructionVerificationSchemas.js +6 -13
- package/dist/domain/referenceSourceClassification.js +0 -110
- package/dist/domain/referenceSourceGraph.js +15 -5
- package/dist/domain/residualUnknown.js +3 -2
- package/dist/domain/runtimeIdentification.js +6 -5
- package/dist/domain/sourceMapContents.js +5 -0
- package/dist/domain/sourceToBundleComparison.js +3 -10
- package/dist/domain/sourceToBundleComparisonSchemas.js +7 -6
- package/dist/domain/sourceToBundleSignals.js +9 -3
- package/dist/domain/staticRuntimeCorrelation.js +5 -11
- package/dist/domain/webBundleAnalysis.js +17 -9
- package/dist/domain/webBundleAnalyzer.js +1 -1
- package/dist/domain/webCaptureDiff.js +5 -11
- package/dist/domain/webCaptureDiffSchemas.js +2 -1
- package/dist/domain/webMcpDiscovery.js +2 -1
- package/dist/dotnet/ManagedMemberInspectorCore.js +15 -7
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +57 -40
- package/dist/dotnet/ManagedMemberRows.js +2 -0
- package/dist/dotnet/ManagedMethodBodyReader.js +15 -8
- package/dist/dotnet/ManagedPeReader.js +2 -0
- package/dist/generatedMcpToolCatalog.js +1 -1
- package/dist/generatedPackageMetadata.js +2 -2
- package/dist/ghidra/GhidraAnalysisProfile.js +15 -5
- package/dist/ghidra/GhidraClient.js +38 -8
- package/dist/ghidra/GhidraFunctionValues.js +56 -20
- package/dist/ghidra/GhidraInstallation.js +7 -4
- package/dist/ghidra/GhidraInventoryValues.js +44 -9
- package/dist/ghidra/GhidraLauncher.js +18 -3
- package/dist/ghidra/GhidraProvider.js +23 -2
- package/dist/ghidra/GhidraRequestQueue.js +45 -4
- package/dist/ghidra/GhidraSessionValues.js +5 -0
- package/dist/hopper/HopperAnalysisProfile.js +2 -0
- package/dist/hopper/HopperProvider.js +29 -6
- package/dist/hopper/HopperTargetLease.js +18 -4
- package/dist/logger.js +0 -13
- package/dist/main/messages.js +0 -1
- package/dist/main/reload.js +3 -32
- package/dist/main/shutdown.js +1 -2
- package/dist/main/transport.js +0 -17
- package/dist/main.js +0 -10
- package/dist/native/AppleDispatchMetadata.js +582 -0
- package/dist/native/AppleObjcProtocols.js +88 -0
- package/dist/native/AppleSwiftVtables.js +86 -0
- package/dist/native/CommandRunner.js +1 -1
- package/dist/native/NativeHostCapabilities.js +23 -0
- package/dist/native/NativeMacOSProvider.js +61 -9
- package/dist/native/NativeMachoInspection.js +39 -6
- package/dist/native/NativeUiHelperRuntime.js +42 -0
- package/dist/native/NativeUiObservation.js +174 -0
- package/dist/native/parsers/codesign.js +4 -1
- package/dist/native/parsers/dyldInfo.js +51 -25
- package/dist/native/parsers/lipo.js +13 -4
- package/dist/native/parsers/otool.js +84 -39
- package/dist/native/parsers/plist.js +2 -1
- package/dist/process/ExecFileOutput.js +5 -1
- package/dist/process/ProcessOwnership.js +69 -33
- package/dist/process/ProcessOwnershipObservation.js +31 -12
- package/dist/process/ProviderProcess.js +4 -2
- package/dist/reference/ReferenceSourceReaderEntries.js +48 -31
- package/dist/reference/ReferenceSourceReaderErrors.js +24 -0
- package/dist/reference/ReferenceSourceReaderFile.js +11 -5
- package/dist/reference/ReferenceSourceReaderValidate.js +22 -8
- package/dist/server/createServer.js +7 -62
- package/dist/server/registerApplicationTools/helpers.js +2 -9
- package/dist/server/registerApplicationTools.js +0 -4
- package/dist/server/registerArtifactComparisonTool.js +1 -1
- package/dist/server/registerBrowserScenarioTool.js +4 -2
- package/dist/server/registerBrowserTools.js +7 -7
- package/dist/server/registerBundleComparisonTool.js +1 -1
- package/dist/server/registerCloseLifecycleTool.js +1 -1
- package/dist/server/registerElectronTools.js +10 -4
- package/dist/server/registerEnhancedTools.js +20 -12
- package/dist/server/registerEvidenceTools.js +4 -28
- package/dist/server/registerFunctionComparisonTool.js +1 -1
- package/dist/server/registerInvestigationTools.js +6 -6
- package/dist/server/registerJavaScriptRuntimeObservationTools.js +2 -2
- package/dist/server/registerManagedTools.js +28 -14
- package/dist/server/registerManagedWorkflowTools.js +0 -2
- package/dist/server/registerProcessComparisonTool.js +1 -3
- package/dist/server/registerSessionRecordTools.js +9 -9
- package/dist/server/registerSessionStatusTool.js +1 -1
- package/dist/server/registerSessionTools.js +28 -57
- package/dist/server/sessionAvailabilityPolicy.js +2 -3
- package/dist/server/sessionToolPolicies.js +0 -4
- package/dist/server/toolResult.js +8 -10
- package/package.json +32 -22
- package/skills/reverse-engineer-anything/SKILL.md +15 -11
- package/skills/reverse-engineer-anything/references/evidence-workflows.md +3 -2
- package/skills/reverse-engineer-anything/references/javascript-applications.md +3 -2
- package/skills/reverse-engineer-anything/references/native-and-artifacts.md +8 -6
- package/skills/reverse-engineer-anything/references/runtime-observation.md +15 -11
- package/dist/application/CommandShimReplay.js +0 -152
- package/dist/application/ConfiguredRoots.js +0 -19
- package/dist/application/InstrumentedJavaScriptReplayHost.js +0 -36
- package/dist/application/JavaScriptReplayPermission.js +0 -16
- package/dist/application/JavaScriptReplayPlanning.js +0 -207
- package/dist/application/JavaScriptReplayService.js +0 -274
- package/dist/application/LoopbackReplay.js +0 -389
- package/dist/application/LoopbackReplayRecorder.js +0 -129
- package/dist/application/ManagedRuntimeCorrelationService.js +0 -104
- package/dist/application/NodeRuntimeCharacterizationService.js +0 -191
- package/dist/application/PermissionAuthority.js +0 -268
- package/dist/application/PermissionConfiguration.js +0 -26
- package/dist/application/PermissionFailure.js +0 -5
- package/dist/application/ProcessCaptureAuthority.js +0 -24
- package/dist/application/ProcessCapturePermission.js +0 -13
- package/dist/application/ProcessCheckpoints.js +0 -178
- package/dist/application/ProcessReactiveCoordinator.js +0 -223
- package/dist/application/ProcessReactiveEffects.js +0 -153
- package/dist/application/ProcessReactiveHarness.js +0 -106
- package/dist/application/ProcessReactiveObservations.js +0 -105
- package/dist/application/ProjectPermissionStore.js +0 -199
- package/dist/application/RuntimeExecutableDiagnostics.js +0 -198
- package/dist/application/Upgrade.js +0 -134
- package/dist/browser/SensitiveTextCapture.js +0 -8
- package/dist/cliPolicyCommands.js +0 -185
- package/dist/config/browserScenario.js +0 -77
- package/dist/config/electronAutomation.js +0 -35
- package/dist/config/javascriptReplay.js +0 -41
- package/dist/config/managedRuntime.js +0 -25
- package/dist/config/passiveObservation.js +0 -87
- package/dist/config/permissions.js +0 -23
- package/dist/config/processCapture.js +0 -47
- package/dist/contracts/replayMachineExample.js +0 -37
- package/dist/domain/javascriptExportInstrumentation.js +0 -95
- package/dist/domain/javascriptReplay.js +0 -360
- package/dist/domain/managedRuntimeCorrelation.js +0 -181
- package/dist/domain/nodeRuntimeCharacterization.js +0 -63
- package/dist/domain/permissionPolicy.js +0 -176
- package/dist/domain/processCaptureReactiveSchema.js +0 -68
- package/dist/domain/processCaptureReactiveValidation.js +0 -180
- package/dist/domain/processReactiveCheckpointDataflow.js +0 -32
- package/dist/domain/processReactiveMatching.js +0 -196
- package/dist/domain/processReactiveRuntime.js +0 -116
- package/dist/domain/processReactiveScenario.js +0 -296
- package/dist/domain/processReactiveScenarioPreflight.js +0 -95
- package/dist/domain/processReactiveTransition.js +0 -187
- package/dist/domain/replayMachine.js +0 -320
- package/dist/domain/replayMachineRun.js +0 -168
- package/dist/domain/replayMachineRuntime.js +0 -296
- package/dist/domain/replayMachineValues.js +0 -84
- package/dist/domain/runtimeCharacterization.js +0 -84
- package/dist/replay/JavaScriptReplayWorker.js +0 -382
- package/dist/replay/JavaScriptReplayWorkerTypes.js +0 -1
- package/dist/replay/LinuxJavaScriptReplayRunner.js +0 -216
- package/dist/replay/LinuxJavaScriptReplaySandbox.js +0 -121
- package/dist/replay/LinuxRuntimeClosure.js +0 -44
- package/dist/replay/LinuxSeccompPolicy.js +0 -40
- package/dist/replay/ReplayOutcome.js +0 -104
- package/dist/replay/ReplayProcessLifecycle.js +0 -96
- package/dist/replay/ReplaySeccompFile.js +0 -29
- package/dist/replay/ReplayWorkerProtocol.js +0 -58
- package/dist/replay/SystemJavaScriptReplayHost.js +0 -153
- package/dist/server/ProcessCaptureElicitation.js +0 -153
- package/dist/server/registerApplicationTools/characterization.js +0 -46
- package/dist/server/registerApplicationTools/controlledReplay.js +0 -31
- package/dist/server/registerManagedWorkflowTools/planManagedRuntimeCorrelation.js +0 -29
- package/dist/server/registerReplayMachineTool.js +0 -14
- package/skills/reverse-engineer-anything/references/controlled-replay.md +0 -12
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { nodeCharacterizationExecutionInputSchema, nodeCharacterizationExecutionOutputSchema, nodeCharacterizationPreparationInputSchema, nodeCharacterizationPreparationOutputSchema, } from "../domain/nodeRuntimeCharacterization.js";
|
|
4
|
-
import { AnalysisInputError, AnalysisProtocolError, ReplayPlanStaleError, } from "../domain/errors.js";
|
|
5
|
-
import { createEvidence } from "../domain/evidence.js";
|
|
6
|
-
import { controlledReplayOutputSchema, } from "../domain/javascriptReplay.js";
|
|
7
|
-
import { createRuntimeCharacterizationPlan, } from "../domain/runtimeCharacterization.js";
|
|
8
|
-
import { err, ok } from "../domain/result.js";
|
|
9
|
-
import { jsonValueSchema } from "../domain/jsonValue.js";
|
|
10
|
-
import { InstrumentedJavaScriptReplayHost } from "./InstrumentedJavaScriptReplayHost.js";
|
|
11
|
-
import { runControlledReplayValidated, } from "./JavaScriptReplayService.js";
|
|
12
|
-
const PREPARE_OPERATION = "prepare_node_characterization";
|
|
13
|
-
const EXECUTE_OPERATION = "execute_node_characterization";
|
|
14
|
-
const PROVIDER = {
|
|
15
|
-
id: "rea-node-characterization",
|
|
16
|
-
name: "REA Node runtime characterization",
|
|
17
|
-
version: "1",
|
|
18
|
-
};
|
|
19
|
-
/** Prepare exact Node/JavaScript characterization without executing target code. */
|
|
20
|
-
export const prepareNodeCharacterization = async (dependencies, rawInput, options = {}) => {
|
|
21
|
-
const parsed = nodeCharacterizationPreparationInputSchema.safeParse(rawInput);
|
|
22
|
-
if (!parsed.success)
|
|
23
|
-
return err(new AnalysisInputError(PREPARE_OPERATION, { cause: parsed.error }));
|
|
24
|
-
const prepared = await prepareValidated(dependencies, parsed.data, options);
|
|
25
|
-
return prepared.ok
|
|
26
|
-
? ok(jsonValueSchema.parse(nodeCharacterizationPreparationOutputSchema.parse(prepared.value)))
|
|
27
|
-
: prepared;
|
|
28
|
-
};
|
|
29
|
-
/** Execute only a freshly recomputed and separately approved characterization plan. */
|
|
30
|
-
export const executeNodeCharacterization = async (dependencies, rawInput, options = {}) => {
|
|
31
|
-
const parsed = nodeCharacterizationExecutionInputSchema.safeParse(rawInput);
|
|
32
|
-
if (!parsed.success)
|
|
33
|
-
return err(new AnalysisInputError(EXECUTE_OPERATION, { cause: parsed.error }));
|
|
34
|
-
const prepared = await prepareValidated(dependencies, parsed.data.preparation, options);
|
|
35
|
-
if (!prepared.ok)
|
|
36
|
-
return prepared;
|
|
37
|
-
if (prepared.value.plan.plan_sha256 !== parsed.data.approved_plan_sha256)
|
|
38
|
-
return err(new ReplayPlanStaleError(parsed.data.approved_plan_sha256, prepared.value.plan.plan_sha256));
|
|
39
|
-
const plannedReplay = controlledReplayOutputSchema.parse(prepared.value.replay);
|
|
40
|
-
if (plannedReplay.phase !== "plan")
|
|
41
|
-
return err(new AnalysisProtocolError("Node characterization preparation did not produce a replay plan"));
|
|
42
|
-
const host = new InstrumentedJavaScriptReplayHost(dependencies.host, parsed.data.preparation.instrumentation);
|
|
43
|
-
const executed = await runControlledReplayValidated({ ...dependencies, host }, {
|
|
44
|
-
...parsed.data.preparation.replay,
|
|
45
|
-
mode: "execute",
|
|
46
|
-
plan_digest: plannedReplay.plan.plan_digest,
|
|
47
|
-
}, options);
|
|
48
|
-
if (!executed.ok)
|
|
49
|
-
return executed;
|
|
50
|
-
const replayOutput = controlledReplayOutputSchema.parse(executed.value);
|
|
51
|
-
if (replayOutput.phase !== "execute")
|
|
52
|
-
return err(new AnalysisProtocolError("Node characterization execution omitted replay Evidence"));
|
|
53
|
-
if (host.instrumentation === null)
|
|
54
|
-
return err(new AnalysisProtocolError("Node characterization execution omitted instrumentation evidence"));
|
|
55
|
-
return ok(jsonValueSchema.parse(nodeCharacterizationExecutionOutputSchema.parse({
|
|
56
|
-
phase: "execution",
|
|
57
|
-
plan: prepared.value.plan,
|
|
58
|
-
transformation: host.instrumentation.manifest,
|
|
59
|
-
transformation_evidence: prepared.value.transformation_evidence,
|
|
60
|
-
evidence: createCharacterizationEvidence(prepared.value, replayOutput),
|
|
61
|
-
replay: replayOutput,
|
|
62
|
-
})));
|
|
63
|
-
};
|
|
64
|
-
const prepareValidated = async (dependencies, input, options) => {
|
|
65
|
-
const host = new InstrumentedJavaScriptReplayHost(dependencies.host, input.instrumentation);
|
|
66
|
-
const replay = await runControlledReplayValidated({ ...dependencies, host }, input.replay, options);
|
|
67
|
-
if (!replay.ok)
|
|
68
|
-
return replay;
|
|
69
|
-
const output = controlledReplayOutputSchema.parse(replay.value);
|
|
70
|
-
if (output.phase !== "plan" || host.instrumentation === null)
|
|
71
|
-
return err(new AnalysisProtocolError("Node characterization preparation omitted committed plan evidence"));
|
|
72
|
-
const module = output.plan.left.modules.find(({ alias }) => alias === input.selected_alias);
|
|
73
|
-
if (module === undefined)
|
|
74
|
-
return err(new AnalysisProtocolError("Node characterization replay plan omitted selected module"));
|
|
75
|
-
const plan = createCharacterizationPlan(input, host.instrumentation, output.plan);
|
|
76
|
-
return ok({
|
|
77
|
-
phase: "preparation",
|
|
78
|
-
plan,
|
|
79
|
-
transformation: host.instrumentation.manifest,
|
|
80
|
-
transformation_evidence: createTransformationEvidence(input, host.instrumentation),
|
|
81
|
-
replay: output,
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
const createTransformationEvidence = (input, instrumentation) => createEvidence({
|
|
85
|
-
path: input.instrumentation.artifact_path,
|
|
86
|
-
sha256: input.instrumentation.artifact_sha256,
|
|
87
|
-
format: "javascript-bundle",
|
|
88
|
-
}, PROVIDER, {
|
|
89
|
-
predicateType: "rea.javascript-export-transformation",
|
|
90
|
-
operation: PREPARE_OPERATION,
|
|
91
|
-
parameters: {
|
|
92
|
-
selected_alias: input.selected_alias,
|
|
93
|
-
selected_sha256: input.instrumentation.selection.selected_sha256,
|
|
94
|
-
},
|
|
95
|
-
result: jsonValueSchema.parse(instrumentation.manifest),
|
|
96
|
-
confidence: "derived",
|
|
97
|
-
authority: "shipped-artifact",
|
|
98
|
-
locations: [
|
|
99
|
-
{
|
|
100
|
-
kind: "file-offset-range",
|
|
101
|
-
start: input.instrumentation.selection.byte_start,
|
|
102
|
-
end: input.instrumentation.selection.byte_end,
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
limitations: [
|
|
106
|
-
"The transformation is deterministic derived evidence; execution authority is established only by a separately approved characterization run.",
|
|
107
|
-
],
|
|
108
|
-
});
|
|
109
|
-
const createCharacterizationEvidence = (prepared, replay) => {
|
|
110
|
-
return createEvidence({
|
|
111
|
-
path: prepared.plan.artifact.path,
|
|
112
|
-
sha256: prepared.plan.artifact.sha256,
|
|
113
|
-
format: "javascript-bundle",
|
|
114
|
-
}, PROVIDER, {
|
|
115
|
-
predicateType: "rea.runtime-characterization",
|
|
116
|
-
operation: EXECUTE_OPERATION,
|
|
117
|
-
parameters: {
|
|
118
|
-
plan_sha256: prepared.plan.plan_sha256,
|
|
119
|
-
replay_evidence_id: replay.evidence.evidence_id,
|
|
120
|
-
},
|
|
121
|
-
result: jsonValueSchema.parse({
|
|
122
|
-
plan: prepared.plan,
|
|
123
|
-
transformation_evidence_id: prepared.transformation_evidence.evidence_id,
|
|
124
|
-
replay_evidence_id: replay.evidence.evidence_id,
|
|
125
|
-
execution: replay.evidence.normalized_result,
|
|
126
|
-
}),
|
|
127
|
-
confidence: "observed",
|
|
128
|
-
authority: "controlled-replay",
|
|
129
|
-
environment: replay.evidence.environment,
|
|
130
|
-
limitations: [
|
|
131
|
-
"This Evidence proves only the finite approved characterization plan and transformed controlled-replay authority, not unmodified shipped-runtime equivalence.",
|
|
132
|
-
...replay.evidence.limitations,
|
|
133
|
-
],
|
|
134
|
-
evidenceLinks: [
|
|
135
|
-
prepared.transformation_evidence.evidence_id,
|
|
136
|
-
replay.evidence.evidence_id,
|
|
137
|
-
],
|
|
138
|
-
});
|
|
139
|
-
};
|
|
140
|
-
const createCharacterizationPlan = (input, instrumentation, replayPlan) => createRuntimeCharacterizationPlan({
|
|
141
|
-
preparation_sha256: digestPreparation(instrumentation.manifest.instrumented_sha256, replayPlan.plan_digest),
|
|
142
|
-
artifact: {
|
|
143
|
-
path: input.instrumentation.artifact_path,
|
|
144
|
-
sha256: input.instrumentation.artifact_sha256,
|
|
145
|
-
byte_length: instrumentation.manifest.original_byte_length,
|
|
146
|
-
},
|
|
147
|
-
runtime: {
|
|
148
|
-
family: "ecmascript",
|
|
149
|
-
provider_id: "node-javascript",
|
|
150
|
-
executable_path: replayPlan.runtime.executable.path,
|
|
151
|
-
executable_sha256: replayPlan.runtime.executable.sha256,
|
|
152
|
-
version: replayPlan.runtime.executable.version,
|
|
153
|
-
profile_sha256: replayPlan.policy_sha256,
|
|
154
|
-
},
|
|
155
|
-
callable: {
|
|
156
|
-
callable_id: `callable/${input.instrumentation.selection.selected_sha256}`,
|
|
157
|
-
module_id: stableModuleId(input.selected_alias),
|
|
158
|
-
export_name: input.instrumentation.selection.export_name,
|
|
159
|
-
semantic_evidence_id: null,
|
|
160
|
-
selector_sha256: input.instrumentation.selection.selected_sha256,
|
|
161
|
-
},
|
|
162
|
-
working_directory: "/work",
|
|
163
|
-
isolated_home: "/work",
|
|
164
|
-
expected_effect: input.expected_effect,
|
|
165
|
-
allowed_boundaries: [],
|
|
166
|
-
limits: {
|
|
167
|
-
max_calls: replayPlan.cases.length,
|
|
168
|
-
max_processes: 0,
|
|
169
|
-
max_files: 0,
|
|
170
|
-
max_bytes: replayPlan.limits.output_bytes,
|
|
171
|
-
max_handles: replayPlan.limits.tasks,
|
|
172
|
-
timeout_ms: replayPlan.limits.wall_time_ms,
|
|
173
|
-
idle_timeout_ms: replayPlan.limits.wall_time_ms,
|
|
174
|
-
},
|
|
175
|
-
determinism: {
|
|
176
|
-
clock: "fixed",
|
|
177
|
-
randomness: "seeded",
|
|
178
|
-
identifiers: "deterministic",
|
|
179
|
-
seed: replayPlan.determinism.random_seed,
|
|
180
|
-
},
|
|
181
|
-
authority: {
|
|
182
|
-
preparation_approved: true,
|
|
183
|
-
execution_approved: false,
|
|
184
|
-
network: "none",
|
|
185
|
-
provider_owned_process_only: true,
|
|
186
|
-
},
|
|
187
|
-
});
|
|
188
|
-
const digestPreparation = (instrumentedSha256, replayPlanDigest) => createHash("sha256")
|
|
189
|
-
.update(`rea.node-characterization-preparation\0${instrumentedSha256}\0${replayPlanDigest}`)
|
|
190
|
-
.digest("hex");
|
|
191
|
-
const stableModuleId = (alias) => `module/${createHash("sha256").update(alias).digest("hex")}`;
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { realpath } from "node:fs/promises";
|
|
2
|
-
import { basename, dirname, join, resolve } from "node:path";
|
|
3
|
-
import { consumePermission, clearSessionPermissions, createPermissionPolicy, evaluatePermission, grantPermission, reloadPermissionCeilings, revokePermission, } from "../domain/permissionPolicy.js";
|
|
4
|
-
import { PermissionRequiredError, } from "../domain/errors.js";
|
|
5
|
-
import { err, ok } from "../domain/result.js";
|
|
6
|
-
/** Failure to establish a filesystem object's canonical authorization identity. */
|
|
7
|
-
export class PermissionPathError extends Error {
|
|
8
|
-
path;
|
|
9
|
-
reason;
|
|
10
|
-
_tag = "PermissionPathError";
|
|
11
|
-
constructor(path, reason, options) {
|
|
12
|
-
super(`Cannot canonicalize permission path: ${path}`, options);
|
|
13
|
-
this.path = path;
|
|
14
|
-
this.reason = reason;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
/** Canonicalize administrator ceilings before they become authorization state. */
|
|
18
|
-
export const canonicalizePermissionCeilings = async (ceilings) => {
|
|
19
|
-
const normalized = [];
|
|
20
|
-
for (const ceiling of ceilings) {
|
|
21
|
-
const canonical = await canonicalizeScope(ceiling, "read");
|
|
22
|
-
if (!canonical.ok)
|
|
23
|
-
return canonical;
|
|
24
|
-
normalized.push(canonical.value);
|
|
25
|
-
}
|
|
26
|
-
return ok(normalized);
|
|
27
|
-
};
|
|
28
|
-
/** Canonicalize one exact operation request before subset evaluation. */
|
|
29
|
-
export const canonicalizePermissionRequest = async (request, access) => {
|
|
30
|
-
const canonical = await canonicalizeScope(request, access);
|
|
31
|
-
return canonical.ok
|
|
32
|
-
? ok({ ...canonical.value, operation_identity: request.operation_identity })
|
|
33
|
-
: canonical;
|
|
34
|
-
};
|
|
35
|
-
const canonicalizeScope = async (scope, access) => {
|
|
36
|
-
const roots = await canonicalizePaths(scope.roots, access);
|
|
37
|
-
if (!roots.ok)
|
|
38
|
-
return roots;
|
|
39
|
-
const executables = await canonicalizePaths(scope.executables, "read");
|
|
40
|
-
if (!executables.ok)
|
|
41
|
-
return executables;
|
|
42
|
-
return ok({ ...scope, roots: roots.value, executables: executables.value });
|
|
43
|
-
};
|
|
44
|
-
const canonicalizePaths = async (paths, access) => {
|
|
45
|
-
const canonical = [];
|
|
46
|
-
for (const path of paths) {
|
|
47
|
-
const result = await canonicalizePath(path, access);
|
|
48
|
-
if (!result.ok)
|
|
49
|
-
return result;
|
|
50
|
-
canonical.push(result.value);
|
|
51
|
-
}
|
|
52
|
-
return ok(canonical);
|
|
53
|
-
};
|
|
54
|
-
const canonicalizePath = async (path, access) => {
|
|
55
|
-
const requested = resolve(path);
|
|
56
|
-
try {
|
|
57
|
-
return ok(await realpath(requested));
|
|
58
|
-
}
|
|
59
|
-
catch (cause) {
|
|
60
|
-
if (access !== "write" || !isNotFound(cause))
|
|
61
|
-
return err(new PermissionPathError(path, errorReason(cause), { cause }));
|
|
62
|
-
}
|
|
63
|
-
try {
|
|
64
|
-
const parent = await realpath(dirname(requested));
|
|
65
|
-
return ok(join(parent, basename(requested)));
|
|
66
|
-
}
|
|
67
|
-
catch (cause) {
|
|
68
|
-
return err(new PermissionPathError(path, errorReason(cause), { cause }));
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
const isNotFound = (error) => error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
72
|
-
const errorReason = (error) => isNotFound(error) ? "not_found" : "io";
|
|
73
|
-
/** Stateful owner for permission evaluation, consumption, reload, and revoke. */
|
|
74
|
-
export class PermissionAuthority {
|
|
75
|
-
policy;
|
|
76
|
-
configuredAuthority;
|
|
77
|
-
outsideCeilingRemediation;
|
|
78
|
-
constructor(policy, configuredAuthority, outsideCeilingRemediation = "configure") {
|
|
79
|
-
this.policy = policy;
|
|
80
|
-
this.configuredAuthority = configuredAuthority;
|
|
81
|
-
this.outsideCeilingRemediation = outsideCeilingRemediation;
|
|
82
|
-
}
|
|
83
|
-
/** Create a connection-owned overlay for once and session grants. */
|
|
84
|
-
createConnectionAuthority() {
|
|
85
|
-
return new PermissionAuthority(createPermissionPolicy([]), this.configuredAuthority ?? this, "restart");
|
|
86
|
-
}
|
|
87
|
-
/** Canonicalize and authorize one exact operation before its side effect. */
|
|
88
|
-
async authorize(request, access, options = {}) {
|
|
89
|
-
const evaluated = await this.evaluateRequest(request, access, options);
|
|
90
|
-
if (!evaluated.ok)
|
|
91
|
-
return evaluated;
|
|
92
|
-
const { decision, owner, request: canonicalRequest } = evaluated.value;
|
|
93
|
-
owner.policy = consumePermission(owner.policy, decision);
|
|
94
|
-
return ok({ ...decision, request: canonicalRequest });
|
|
95
|
-
}
|
|
96
|
-
/** Dry-run the exact shared evaluation without consuming a once grant. */
|
|
97
|
-
async explain(request, access, options = {}) {
|
|
98
|
-
const evaluated = await this.evaluateRequest(request, access, options);
|
|
99
|
-
return evaluated.ok
|
|
100
|
-
? ok({
|
|
101
|
-
...evaluated.value.decision,
|
|
102
|
-
request: evaluated.value.request,
|
|
103
|
-
})
|
|
104
|
-
: evaluated;
|
|
105
|
-
}
|
|
106
|
-
async evaluateRequest(request, access, options) {
|
|
107
|
-
const canonical = await canonicalizePermissionRequest(request, access);
|
|
108
|
-
if (!canonical.ok)
|
|
109
|
-
return canonical;
|
|
110
|
-
const evaluated = this.evaluateCanonical(canonical.value, options);
|
|
111
|
-
return evaluated.ok
|
|
112
|
-
? ok({ ...evaluated.value, request: canonical.value })
|
|
113
|
-
: evaluated;
|
|
114
|
-
}
|
|
115
|
-
/** Add authority beneath the administrator ceiling. */
|
|
116
|
-
grant(grant) {
|
|
117
|
-
const policy = this.configuredAuthority === undefined
|
|
118
|
-
? this.policy
|
|
119
|
-
: {
|
|
120
|
-
...this.policy,
|
|
121
|
-
ceilings: this.configuredAuthority.effectivePolicy().ceilings,
|
|
122
|
-
};
|
|
123
|
-
const result = grantPermission(policy, grant);
|
|
124
|
-
if (result.ok)
|
|
125
|
-
this.policy = result.value;
|
|
126
|
-
return result;
|
|
127
|
-
}
|
|
128
|
-
/** Revoke authority immediately for subsequent operations. */
|
|
129
|
-
revoke(grantId) {
|
|
130
|
-
this.policy = revokePermission(this.policy, grantId);
|
|
131
|
-
}
|
|
132
|
-
/** Drop once/session authority when its owning connection ends. */
|
|
133
|
-
clearSessionGrants() {
|
|
134
|
-
this.policy = clearSessionPermissions(this.policy);
|
|
135
|
-
}
|
|
136
|
-
effectivePolicy() {
|
|
137
|
-
if (this.configuredAuthority === undefined)
|
|
138
|
-
return this.policy;
|
|
139
|
-
const configured = this.configuredAuthority.effectivePolicy();
|
|
140
|
-
return {
|
|
141
|
-
ceilings: configured.ceilings,
|
|
142
|
-
grants: [...configured.grants, ...this.policy.grants],
|
|
143
|
-
revoked_grant_ids: new Set([
|
|
144
|
-
...configured.revoked_grant_ids,
|
|
145
|
-
...this.policy.revoked_grant_ids,
|
|
146
|
-
]),
|
|
147
|
-
consumed_grant_ids: new Set([
|
|
148
|
-
...configured.consumed_grant_ids,
|
|
149
|
-
...this.policy.consumed_grant_ids,
|
|
150
|
-
]),
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
evaluateCanonical(request, options) {
|
|
154
|
-
const configured = this.configuredAuthority;
|
|
155
|
-
if (configured !== undefined) {
|
|
156
|
-
const configuredDecision = evaluatePermission(configured.effectivePolicy(), request);
|
|
157
|
-
if (configuredDecision.allowed)
|
|
158
|
-
return ok({ decision: configuredDecision, owner: configured });
|
|
159
|
-
}
|
|
160
|
-
const localPolicy = configured === undefined
|
|
161
|
-
? this.policy
|
|
162
|
-
: { ...this.policy, ceilings: configured.effectivePolicy().ceilings };
|
|
163
|
-
const localDecision = evaluatePermission(localPolicy, request);
|
|
164
|
-
if (localDecision.allowed)
|
|
165
|
-
return ok({ decision: localDecision, owner: this });
|
|
166
|
-
const effective = this.effectivePolicy();
|
|
167
|
-
const denied = evaluatePermission(effective, request);
|
|
168
|
-
if (denied.allowed)
|
|
169
|
-
return ok({ decision: denied, owner: this });
|
|
170
|
-
const outsideAdministratorCeiling = denied.reason === "outside_administrator_ceiling";
|
|
171
|
-
const requestedRemediation = options.remediation ?? "configure";
|
|
172
|
-
const remediation = outsideAdministratorCeiling && requestedRemediation !== "restart"
|
|
173
|
-
? this.outsideCeilingRemediation
|
|
174
|
-
: requestedRemediation;
|
|
175
|
-
return err(new PermissionRequiredError({
|
|
176
|
-
requested: request,
|
|
177
|
-
missing: denied.missing,
|
|
178
|
-
ceiling: ceilingFor(effective, request.capability),
|
|
179
|
-
remediation,
|
|
180
|
-
}));
|
|
181
|
-
}
|
|
182
|
-
/** Atomically replace optional persisted project grants. */
|
|
183
|
-
async replaceProjectGrants(grants) {
|
|
184
|
-
return this.replaceGrants(grants, "project");
|
|
185
|
-
}
|
|
186
|
-
/** Replace grants derived from the currently loaded administrator ceiling. */
|
|
187
|
-
async replaceAdministratorGrants(grants) {
|
|
188
|
-
return this.replaceGrants(grants, "administrator");
|
|
189
|
-
}
|
|
190
|
-
async replaceGrants(grants, lifetime) {
|
|
191
|
-
const canonical = await canonicalizeGrants(grants);
|
|
192
|
-
if (!canonical.ok)
|
|
193
|
-
return canonical;
|
|
194
|
-
const replaced = addGrantsToPolicy({
|
|
195
|
-
...this.policy,
|
|
196
|
-
grants: this.policy.grants.filter((grant) => grant.lifetime !== lifetime),
|
|
197
|
-
}, canonical.value);
|
|
198
|
-
if (!replaced.ok)
|
|
199
|
-
return replaced;
|
|
200
|
-
this.policy = replaced.value;
|
|
201
|
-
return ok(null);
|
|
202
|
-
}
|
|
203
|
-
/** Atomically replace reloadable ceilings and persisted grants. */
|
|
204
|
-
async replaceConfiguredPolicy(configuration) {
|
|
205
|
-
const ceilings = await canonicalizePermissionCeilings(configuration.ceilings);
|
|
206
|
-
if (!ceilings.ok)
|
|
207
|
-
return ceilings;
|
|
208
|
-
const grants = await canonicalizeGrants([
|
|
209
|
-
...configuration.administratorGrants,
|
|
210
|
-
...configuration.projectGrants,
|
|
211
|
-
]);
|
|
212
|
-
if (!grants.ok)
|
|
213
|
-
return grants;
|
|
214
|
-
const candidate = {
|
|
215
|
-
...reloadPermissionCeilings(this.policy, ceilings.value),
|
|
216
|
-
grants: this.policy.grants.filter(({ lifetime }) => lifetime !== "administrator" && lifetime !== "project"),
|
|
217
|
-
};
|
|
218
|
-
const replaced = addGrantsToPolicy(candidate, grants.value);
|
|
219
|
-
if (!replaced.ok)
|
|
220
|
-
return replaced;
|
|
221
|
-
this.policy = replaced.value;
|
|
222
|
-
return ok(null);
|
|
223
|
-
}
|
|
224
|
-
/** Replace ceilings without restarting the MCP process. */
|
|
225
|
-
async reload(ceilings) {
|
|
226
|
-
const canonical = await canonicalizePermissionCeilings(ceilings);
|
|
227
|
-
if (!canonical.ok)
|
|
228
|
-
return canonical;
|
|
229
|
-
this.policy = reloadPermissionCeilings(this.policy, canonical.value);
|
|
230
|
-
return ok(null);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
/** Create one canonical policy and optional grants at the composition root. */
|
|
234
|
-
export const createPermissionAuthority = async (ceilings, grants = []) => {
|
|
235
|
-
const canonical = await canonicalizePermissionCeilings(ceilings);
|
|
236
|
-
if (!canonical.ok)
|
|
237
|
-
return canonical;
|
|
238
|
-
const canonicalGrants = await canonicalizeGrants(grants);
|
|
239
|
-
if (!canonicalGrants.ok)
|
|
240
|
-
return canonicalGrants;
|
|
241
|
-
const policy = addGrantsToPolicy(createPermissionPolicy(canonical.value), canonicalGrants.value);
|
|
242
|
-
return policy.ok ? ok(new PermissionAuthority(policy.value)) : policy;
|
|
243
|
-
};
|
|
244
|
-
const canonicalizeGrants = async (grants) => {
|
|
245
|
-
const canonical = [];
|
|
246
|
-
for (const grant of grants) {
|
|
247
|
-
const canonicalGrant = await canonicalizeGrant(grant);
|
|
248
|
-
if (!canonicalGrant.ok)
|
|
249
|
-
return canonicalGrant;
|
|
250
|
-
canonical.push(canonicalGrant.value);
|
|
251
|
-
}
|
|
252
|
-
return ok(canonical);
|
|
253
|
-
};
|
|
254
|
-
const addGrantsToPolicy = (initial, grants) => {
|
|
255
|
-
let policy = initial;
|
|
256
|
-
for (const grant of grants) {
|
|
257
|
-
const added = grantPermission(policy, grant);
|
|
258
|
-
if (!added.ok)
|
|
259
|
-
return err(new PermissionPathError(grant.grant_id, "io", { cause: added.error }));
|
|
260
|
-
policy = added.value;
|
|
261
|
-
}
|
|
262
|
-
return ok(policy);
|
|
263
|
-
};
|
|
264
|
-
const canonicalizeGrant = async (grant) => {
|
|
265
|
-
const scope = await canonicalizeScope(grant, "read");
|
|
266
|
-
return scope.ok ? ok({ ...grant, ...scope.value }) : scope;
|
|
267
|
-
};
|
|
268
|
-
const ceilingFor = (policy, capability) => policy.ceilings.find((ceiling) => ceiling.capability === capability) ?? null;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ConfigurationError } from "../domain/errors.js";
|
|
2
|
-
import { err, ok } from "../domain/result.js";
|
|
3
|
-
import { createPermissionAuthority, } from "./PermissionAuthority.js";
|
|
4
|
-
import { readProjectPermissionStore } from "./ProjectPermissionStore.js";
|
|
5
|
-
/** Load the same administrator and optional project policy for CLI and MCP. */
|
|
6
|
-
export const loadConfiguredPermissionAuthority = async (config) => {
|
|
7
|
-
const authority = await createPermissionAuthority(config.permissionCeilings, config.administratorPermissionGrants);
|
|
8
|
-
if (!authority.ok)
|
|
9
|
-
return err(new ConfigurationError("Permission policy could not be loaded", {
|
|
10
|
-
cause: authority.error,
|
|
11
|
-
}));
|
|
12
|
-
if (config.permissionProjectRoot === undefined ||
|
|
13
|
-
config.permissionProjectStore === undefined)
|
|
14
|
-
return ok(authority.value);
|
|
15
|
-
const project = await readProjectPermissionStore(config.permissionProjectStore, config.permissionProjectRoot);
|
|
16
|
-
if (!project.ok)
|
|
17
|
-
return err(new ConfigurationError("Project permission policy could not be loaded", {
|
|
18
|
-
cause: project.error,
|
|
19
|
-
}));
|
|
20
|
-
const replaced = await authority.value.replaceProjectGrants(project.value?.grants ?? []);
|
|
21
|
-
return replaced.ok
|
|
22
|
-
? ok(authority.value)
|
|
23
|
-
: err(new ConfigurationError("Project permission policy could not be applied", {
|
|
24
|
-
cause: replaced.error,
|
|
25
|
-
}));
|
|
26
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { AnalysisProtocolError, PermissionRequiredError, } from "../domain/errors.js";
|
|
2
|
-
/** Preserve permission denials and project failed path resolution for callers. */
|
|
3
|
-
export const projectPermissionFailure = (error) => error instanceof PermissionRequiredError
|
|
4
|
-
? error
|
|
5
|
-
: new AnalysisProtocolError(error.message, { cause: error });
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { realpath } from "node:fs/promises";
|
|
2
|
-
import { isPathWithinRoot } from "../domain/localPath.js";
|
|
3
|
-
import { ProcessCaptureError, processCaptureCancelled, } from "./ProcessCaptureError.js";
|
|
4
|
-
import { canonicalizeConfiguredRoots } from "./ConfiguredRoots.js";
|
|
5
|
-
export const assertRealPathAuthority = async (scenario, policy) => {
|
|
6
|
-
const executable = await realpath(scenario.executable);
|
|
7
|
-
const executableRoots = await canonicalizeConfiguredRoots(policy.executableRoots);
|
|
8
|
-
if (!executableRoots.some((root) => isPathWithinRoot(root, executable)))
|
|
9
|
-
throw new ProcessCaptureError("resolved executable is outside approved roots");
|
|
10
|
-
const workingDirectory = await realpath(scenario.working_directory);
|
|
11
|
-
const workingRoots = await canonicalizeConfiguredRoots(policy.workingRoots);
|
|
12
|
-
if (!workingRoots.some((root) => isPathWithinRoot(root, workingDirectory)))
|
|
13
|
-
throw new ProcessCaptureError("resolved working directory is outside approved roots");
|
|
14
|
-
for (const root of scenario.filesystem_roots) {
|
|
15
|
-
const resolvedRoot = await realpath(root);
|
|
16
|
-
if (!workingRoots.some((approved) => isPathWithinRoot(approved, resolvedRoot)))
|
|
17
|
-
throw new ProcessCaptureError("resolved filesystem root is outside approved roots");
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
/** Reject cancellation before a process capture operation begins. */
|
|
21
|
-
export const assertNotCancelled = (signal) => {
|
|
22
|
-
if (signal?.aborted === true)
|
|
23
|
-
throw processCaptureCancelled();
|
|
24
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/** Build the exact permission request shared by process-capture adapters. */
|
|
2
|
-
export const processCapturePermissionRequest = (scenario) => ({
|
|
3
|
-
capability: "process_capture",
|
|
4
|
-
roots: [scenario.working_directory, ...scenario.filesystem_roots],
|
|
5
|
-
executables: [scenario.executable],
|
|
6
|
-
environment_names: [
|
|
7
|
-
...Object.keys(scenario.environment),
|
|
8
|
-
...scenario.inherit_environment,
|
|
9
|
-
],
|
|
10
|
-
network: scenario.network_access === "host" ? "external" : "none",
|
|
11
|
-
mount: false,
|
|
12
|
-
operation_identity: `capture_process_scenario:${scenario.executable}`,
|
|
13
|
-
});
|