rea-agents 3.2.1 → 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,105 +0,0 @@
|
|
|
1
|
-
import { createProcessObservation, processObservationSubject, } from "../domain/processObservation.js";
|
|
2
|
-
const terminalObservation = (options, entry) => {
|
|
3
|
-
const value = options.frames[entry.index];
|
|
4
|
-
return value === undefined
|
|
5
|
-
? undefined
|
|
6
|
-
: createProcessObservation({
|
|
7
|
-
source: "terminal_raw",
|
|
8
|
-
source_sequence: value.sequence,
|
|
9
|
-
captured_at_ms: value.at_ms,
|
|
10
|
-
subject_id: null,
|
|
11
|
-
location: entry,
|
|
12
|
-
payload: value,
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
const interactionObservation = (options, entry) => {
|
|
16
|
-
const value = options.interactions[entry.index];
|
|
17
|
-
return value === undefined
|
|
18
|
-
? undefined
|
|
19
|
-
: createProcessObservation({
|
|
20
|
-
source: "interaction",
|
|
21
|
-
source_sequence: value.sequence,
|
|
22
|
-
captured_at_ms: value.dispatched_at_ms,
|
|
23
|
-
subject_id: null,
|
|
24
|
-
location: entry,
|
|
25
|
-
payload: value,
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
const filesystemObservation = (options, entry) => {
|
|
29
|
-
const value = options.checkpointAt(entry.index);
|
|
30
|
-
return value === undefined
|
|
31
|
-
? undefined
|
|
32
|
-
: createProcessObservation({
|
|
33
|
-
source: "filesystem",
|
|
34
|
-
source_sequence: entry.index,
|
|
35
|
-
captured_at_ms: value.at_ms,
|
|
36
|
-
subject_id: processObservationSubject("filesystem", value),
|
|
37
|
-
location: entry,
|
|
38
|
-
payload: value,
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
const processObservation = (options, entry) => {
|
|
42
|
-
const value = options.processSampleAt(entry.index);
|
|
43
|
-
return value === undefined
|
|
44
|
-
? undefined
|
|
45
|
-
: createProcessObservation({
|
|
46
|
-
source: "process",
|
|
47
|
-
source_sequence: entry.index,
|
|
48
|
-
captured_at_ms: value.at_ms,
|
|
49
|
-
subject_id: processObservationSubject("process", value),
|
|
50
|
-
location: entry,
|
|
51
|
-
payload: value,
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
const protocolObservation = (options, entry) => {
|
|
55
|
-
const value = options.protocolEventAt(entry.index);
|
|
56
|
-
return value === undefined
|
|
57
|
-
? undefined
|
|
58
|
-
: createProcessObservation({
|
|
59
|
-
source: value.protocol,
|
|
60
|
-
source_sequence: value.sequence,
|
|
61
|
-
captured_at_ms: value.at_ms,
|
|
62
|
-
subject_id: processObservationSubject(value.protocol, value),
|
|
63
|
-
location: entry,
|
|
64
|
-
payload: value,
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
const shimObservation = (options, entry) => {
|
|
68
|
-
const normalized = options.shimEventAt(entry.index);
|
|
69
|
-
if (normalized === undefined)
|
|
70
|
-
return undefined;
|
|
71
|
-
return createProcessObservation({
|
|
72
|
-
source: "shim",
|
|
73
|
-
source_sequence: normalized.sequence,
|
|
74
|
-
captured_at_ms: normalized.at_ms,
|
|
75
|
-
subject_id: processObservationSubject("shim", normalized),
|
|
76
|
-
location: entry,
|
|
77
|
-
payload: normalized,
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
const observationFor = (options, entry) => {
|
|
81
|
-
if (entry.collection === "frames")
|
|
82
|
-
return terminalObservation(options, entry);
|
|
83
|
-
if (entry.collection === "interaction_events")
|
|
84
|
-
return interactionObservation(options, entry);
|
|
85
|
-
if (entry.collection === "filesystem_checkpoints")
|
|
86
|
-
return filesystemObservation(options, entry);
|
|
87
|
-
if (entry.collection === "process_samples")
|
|
88
|
-
return processObservation(options, entry);
|
|
89
|
-
if (entry.collection === "protocol_events")
|
|
90
|
-
return protocolObservation(options, entry);
|
|
91
|
-
if (entry.collection === "shim_events")
|
|
92
|
-
return shimObservation(options, entry);
|
|
93
|
-
return undefined;
|
|
94
|
-
};
|
|
95
|
-
/** Subscribe the reactive coordinator to admitted normalized journal records. */
|
|
96
|
-
export const subscribeProcessReactiveObservations = (options) => {
|
|
97
|
-
const enqueue = (entry) => {
|
|
98
|
-
const observation = observationFor(options, entry);
|
|
99
|
-
if (observation !== undefined)
|
|
100
|
-
options.sink.enqueue({ kind: "observation", observation });
|
|
101
|
-
};
|
|
102
|
-
for (const entry of options.journal.entries)
|
|
103
|
-
enqueue(entry);
|
|
104
|
-
return options.journal.subscribe(enqueue);
|
|
105
|
-
};
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import { createStoreFileLock, removeStaleStoreFileLock, } from "./StoreFileLock.js";
|
|
2
|
-
import { createHash } from "node:crypto";
|
|
3
|
-
import { constants } from "node:fs";
|
|
4
|
-
import { lstat, mkdir, open, realpath, } from "node:fs/promises";
|
|
5
|
-
import { dirname } from "node:path";
|
|
6
|
-
import { setTimeout as delay } from "node:timers/promises";
|
|
7
|
-
import writeFileAtomic from "write-file-atomic";
|
|
8
|
-
import { z } from "zod";
|
|
9
|
-
import { PERMISSION_CAPABILITIES, } from "../domain/permissionPolicy.js";
|
|
10
|
-
import { err, ok } from "../domain/result.js";
|
|
11
|
-
const grantSchema = z.object({
|
|
12
|
-
grant_id: z.string().min(1),
|
|
13
|
-
capability: z.enum(PERMISSION_CAPABILITIES),
|
|
14
|
-
roots: z.array(z.string()),
|
|
15
|
-
executables: z.array(z.string()),
|
|
16
|
-
environment_names: z.array(z.string()),
|
|
17
|
-
origins: z.array(z.string()).optional(),
|
|
18
|
-
network: z.enum(["none", "loopback", "external"]),
|
|
19
|
-
mount: z.boolean(),
|
|
20
|
-
lifetime: z.literal("project"),
|
|
21
|
-
operation_identity: z.string().nullable(),
|
|
22
|
-
expires_at: z.iso.datetime().nullable(),
|
|
23
|
-
});
|
|
24
|
-
const storeSchema = z.object({
|
|
25
|
-
project_id: z.string().regex(/^project_[a-f0-9]{64}$/u),
|
|
26
|
-
project_root: z.string(),
|
|
27
|
-
grants: z.array(grantSchema),
|
|
28
|
-
});
|
|
29
|
-
/** Owner-only project policy persistence failure. */
|
|
30
|
-
export class ProjectPermissionStoreError extends Error {
|
|
31
|
-
reason;
|
|
32
|
-
_tag = "ProjectPermissionStoreError";
|
|
33
|
-
constructor(reason, options) {
|
|
34
|
-
super(`Project permission store failed: ${reason}`, options);
|
|
35
|
-
this.reason = reason;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
/** Derive relocation-explicit project identity from its canonical root. */
|
|
39
|
-
const identifyPermissionProject = async (projectRoot) => {
|
|
40
|
-
try {
|
|
41
|
-
const root = await realpath(projectRoot);
|
|
42
|
-
return ok({
|
|
43
|
-
id: `project_${createHash("sha256").update(root).digest("hex")}`,
|
|
44
|
-
root,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
catch (cause) {
|
|
48
|
-
return err(new ProjectPermissionStoreError("project_not_found", { cause }));
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
/** Read and validate an owner-only store bound to the requested project. */
|
|
52
|
-
export const readProjectPermissionStore = async (path, projectRoot) => {
|
|
53
|
-
const project = await identifyPermissionProject(projectRoot);
|
|
54
|
-
if (!project.ok)
|
|
55
|
-
return project;
|
|
56
|
-
if (process.getuid === undefined)
|
|
57
|
-
return err(new ProjectPermissionStoreError("not_owner_only"));
|
|
58
|
-
let handle;
|
|
59
|
-
try {
|
|
60
|
-
const opened = await openPrivateStore(path);
|
|
61
|
-
if (!opened.ok)
|
|
62
|
-
return opened;
|
|
63
|
-
if (opened.value === null)
|
|
64
|
-
return ok(null);
|
|
65
|
-
handle = opened.value;
|
|
66
|
-
const encoded = await handle.readFile("utf8");
|
|
67
|
-
let decoded;
|
|
68
|
-
try {
|
|
69
|
-
decoded = JSON.parse(encoded);
|
|
70
|
-
}
|
|
71
|
-
catch (cause) {
|
|
72
|
-
return err(new ProjectPermissionStoreError("invalid", { cause }));
|
|
73
|
-
}
|
|
74
|
-
const parsed = storeSchema.safeParse(decoded);
|
|
75
|
-
if (!parsed.success ||
|
|
76
|
-
parsed.data.project_id !== project.value.id ||
|
|
77
|
-
parsed.data.project_root !== project.value.root)
|
|
78
|
-
return err(new ProjectPermissionStoreError("invalid"));
|
|
79
|
-
return ok(parsed.data);
|
|
80
|
-
}
|
|
81
|
-
catch (cause) {
|
|
82
|
-
if (isNotFound(cause))
|
|
83
|
-
return ok(null);
|
|
84
|
-
return err(new ProjectPermissionStoreError("io", { cause }));
|
|
85
|
-
}
|
|
86
|
-
finally {
|
|
87
|
-
await handle?.close().catch(() => undefined);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
/** Atomically replace explicit project grants with owner-only permissions. */
|
|
91
|
-
export const writeProjectPermissionStore = async (path, projectRoot, grants) => {
|
|
92
|
-
const project = await identifyPermissionProject(projectRoot);
|
|
93
|
-
if (!project.ok)
|
|
94
|
-
return project;
|
|
95
|
-
const candidate = storeSchema.safeParse({
|
|
96
|
-
project_id: project.value.id,
|
|
97
|
-
project_root: project.value.root,
|
|
98
|
-
grants,
|
|
99
|
-
});
|
|
100
|
-
if (!candidate.success)
|
|
101
|
-
return err(new ProjectPermissionStoreError("invalid", { cause: candidate.error }));
|
|
102
|
-
if (process.getuid === undefined)
|
|
103
|
-
return err(new ProjectPermissionStoreError("not_owner_only"));
|
|
104
|
-
return withPermissionStoreLock(path, () => writePreparedPermissionStore(path, projectRoot, candidate.data));
|
|
105
|
-
};
|
|
106
|
-
const writePreparedPermissionStore = async (path, projectRoot, candidate) => {
|
|
107
|
-
await writeFileAtomic(path, `${JSON.stringify(candidate, null, 2)}\n`, {
|
|
108
|
-
encoding: "utf8",
|
|
109
|
-
mode: 0o600,
|
|
110
|
-
});
|
|
111
|
-
const verified = await readProjectPermissionStore(path, projectRoot);
|
|
112
|
-
if (!verified.ok)
|
|
113
|
-
return verified;
|
|
114
|
-
if (verified.value === null ||
|
|
115
|
-
JSON.stringify(verified.value) !== JSON.stringify(candidate))
|
|
116
|
-
return err(new ProjectPermissionStoreError("invalid"));
|
|
117
|
-
return ok(candidate);
|
|
118
|
-
};
|
|
119
|
-
/** Revoke one grant while serializing the complete read-modify-write cycle. */
|
|
120
|
-
export const revokeProjectPermissionGrant = async (path, projectRoot, grantId) => withPermissionStoreLock(path, async () => {
|
|
121
|
-
const current = await readProjectPermissionStore(path, projectRoot);
|
|
122
|
-
if (!current.ok)
|
|
123
|
-
return current;
|
|
124
|
-
if (current.value === null)
|
|
125
|
-
return ok(false);
|
|
126
|
-
const retained = current.value.grants.filter(({ grant_id }) => grant_id !== grantId);
|
|
127
|
-
if (retained.length === current.value.grants.length)
|
|
128
|
-
return ok(false);
|
|
129
|
-
const written = await writePreparedPermissionStore(path, projectRoot, {
|
|
130
|
-
...current.value,
|
|
131
|
-
grants: retained,
|
|
132
|
-
});
|
|
133
|
-
return written.ok ? ok(true) : written;
|
|
134
|
-
});
|
|
135
|
-
const withPermissionStoreLock = async (path, action) => {
|
|
136
|
-
let lock;
|
|
137
|
-
try {
|
|
138
|
-
await mkdir(dirname(path), { recursive: true, mode: 0o700 });
|
|
139
|
-
const acquired = await acquirePermissionStoreLock(path);
|
|
140
|
-
if (!acquired.ok)
|
|
141
|
-
return acquired;
|
|
142
|
-
lock = acquired.value;
|
|
143
|
-
return await action();
|
|
144
|
-
}
|
|
145
|
-
catch (cause) {
|
|
146
|
-
return err(new ProjectPermissionStoreError("io", { cause }));
|
|
147
|
-
}
|
|
148
|
-
finally {
|
|
149
|
-
if (lock !== undefined)
|
|
150
|
-
await lock.release();
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
const acquirePermissionStoreLock = async (destination) => {
|
|
154
|
-
const path = `${destination}.lock`;
|
|
155
|
-
for (let attempt = 0; attempt < 100; attempt += 1) {
|
|
156
|
-
try {
|
|
157
|
-
return ok(await createStoreFileLock(path));
|
|
158
|
-
}
|
|
159
|
-
catch (cause) {
|
|
160
|
-
if (!isAlreadyExists(cause))
|
|
161
|
-
return err(new ProjectPermissionStoreError("io", { cause }));
|
|
162
|
-
if (await removeStaleStoreFileLock(path))
|
|
163
|
-
continue;
|
|
164
|
-
if (attempt === 99)
|
|
165
|
-
return err(new ProjectPermissionStoreError("locked", { cause }));
|
|
166
|
-
await delay(10);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return err(new ProjectPermissionStoreError("locked"));
|
|
170
|
-
};
|
|
171
|
-
const isNotFound = (cause) => errorCode(cause) === "ENOENT";
|
|
172
|
-
const openPrivateStore = async (path) => {
|
|
173
|
-
let handle;
|
|
174
|
-
try {
|
|
175
|
-
handle = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
176
|
-
const metadata = await handle.stat();
|
|
177
|
-
if (!privateRegularFile(metadata)) {
|
|
178
|
-
await handle.close();
|
|
179
|
-
return err(new ProjectPermissionStoreError("not_owner_only"));
|
|
180
|
-
}
|
|
181
|
-
return ok(handle);
|
|
182
|
-
}
|
|
183
|
-
catch (cause) {
|
|
184
|
-
await handle?.close().catch(() => undefined);
|
|
185
|
-
if (isNotFound(cause))
|
|
186
|
-
return ok(null);
|
|
187
|
-
return err(new ProjectPermissionStoreError(isSymlinkRefusal(cause) ? "not_owner_only" : "io", { cause }));
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
const privateRegularFile = (metadata) => metadata.isFile() &&
|
|
191
|
-
!metadata.isSymbolicLink() &&
|
|
192
|
-
(Number(metadata.mode) & 0o077) === 0 &&
|
|
193
|
-
process.getuid !== undefined &&
|
|
194
|
-
metadata.uid === process.getuid();
|
|
195
|
-
const isAlreadyExists = (cause) => errorCode(cause) === "EEXIST";
|
|
196
|
-
const errorCode = (cause) => typeof cause === "object" && cause !== null && "code" in cause
|
|
197
|
-
? cause.code
|
|
198
|
-
: undefined;
|
|
199
|
-
const isSymlinkRefusal = (cause) => errorCode(cause) === "ELOOP" || errorCode(cause) === "EMLINK";
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
import { constants } from "node:fs";
|
|
3
|
-
import { access, realpath } from "node:fs/promises";
|
|
4
|
-
import { delimiter, join } from "node:path";
|
|
5
|
-
const TOOL_NAMES = ["node", "npm", "npx"];
|
|
6
|
-
const PROBE_CONCURRENCY = 4;
|
|
7
|
-
/** Inventory and probe Node toolchain candidates under one exact PATH. */
|
|
8
|
-
export const inspectRuntimeExecutables = async (options) => {
|
|
9
|
-
const pathEntries = unique(options.path.split(delimiter).filter(Boolean));
|
|
10
|
-
const candidates = [
|
|
11
|
-
{
|
|
12
|
-
tool: "node",
|
|
13
|
-
path: options.launcherNode,
|
|
14
|
-
pathIndex: null,
|
|
15
|
-
selection: "rea-launcher",
|
|
16
|
-
},
|
|
17
|
-
];
|
|
18
|
-
for (const tool of TOOL_NAMES) {
|
|
19
|
-
const discovered = await discoverToolCandidates(tool, pathEntries, options.platform, options.pathExtensions);
|
|
20
|
-
for (const [index, candidate] of discovered.entries())
|
|
21
|
-
candidates.push({
|
|
22
|
-
tool,
|
|
23
|
-
path: candidate.path,
|
|
24
|
-
pathIndex: candidate.pathIndex,
|
|
25
|
-
selection: index === 0 ? "path-primary" : "path-shadowed",
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
const seen = new Set();
|
|
29
|
-
const uniqueCandidates = [];
|
|
30
|
-
for (const candidate of candidates) {
|
|
31
|
-
const key = `${candidate.tool}\0${candidate.path}`;
|
|
32
|
-
if (seen.has(key))
|
|
33
|
-
continue;
|
|
34
|
-
seen.add(key);
|
|
35
|
-
uniqueCandidates.push(candidate);
|
|
36
|
-
}
|
|
37
|
-
const diagnostics = await mapConcurrentBounded(uniqueCandidates, PROBE_CONCURRENCY, (candidate) => probeCandidate(candidate, options.timeoutMs, options.path));
|
|
38
|
-
return {
|
|
39
|
-
launcher_node: await canonicalPath(options.launcherNode),
|
|
40
|
-
candidates: diagnostics,
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
const discoverToolCandidates = async (tool, pathEntries, platform, configuredExtensions) => {
|
|
44
|
-
const extensions = platform === "win32"
|
|
45
|
-
? (configuredExtensions ?? [".COM", ".EXE", ".BAT", ".CMD"])
|
|
46
|
-
: [""];
|
|
47
|
-
const candidates = [];
|
|
48
|
-
for (const [pathIndex, directory] of pathEntries.entries()) {
|
|
49
|
-
for (const extension of extensions) {
|
|
50
|
-
const path = join(directory, `${tool}${extension}`);
|
|
51
|
-
if (await isExecutable(path, platform)) {
|
|
52
|
-
candidates.push({ path, pathIndex });
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return candidates;
|
|
58
|
-
};
|
|
59
|
-
const probeCandidate = async (candidate, timeoutMs, effectivePath) => {
|
|
60
|
-
const canonical = await canonicalPath(candidate.path);
|
|
61
|
-
const result = await executeVersion(candidate.path, timeoutMs, effectivePath);
|
|
62
|
-
const identity = {
|
|
63
|
-
tool: candidate.tool,
|
|
64
|
-
lexical_path: candidate.path,
|
|
65
|
-
canonical_path: canonical,
|
|
66
|
-
path_index: candidate.pathIndex,
|
|
67
|
-
selection: candidate.selection,
|
|
68
|
-
};
|
|
69
|
-
return result.ok
|
|
70
|
-
? { ...identity, version: result.version, healthy: true, failure: null }
|
|
71
|
-
: {
|
|
72
|
-
...identity,
|
|
73
|
-
version: null,
|
|
74
|
-
healthy: false,
|
|
75
|
-
failure: result.failure,
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
const executeVersion = (path, timeoutMs, effectivePath) => new Promise((resolve) => {
|
|
79
|
-
const child = spawn(path, ["--version"], {
|
|
80
|
-
windowsHide: true,
|
|
81
|
-
env: environmentWithPath(effectivePath),
|
|
82
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
83
|
-
});
|
|
84
|
-
let stdout = "";
|
|
85
|
-
let stderr = "";
|
|
86
|
-
let spawnError;
|
|
87
|
-
let timeout;
|
|
88
|
-
let timedOut = false;
|
|
89
|
-
child.stdout?.setEncoding("utf8");
|
|
90
|
-
child.stderr?.setEncoding("utf8");
|
|
91
|
-
child.stdout?.on("data", (chunk) => {
|
|
92
|
-
stdout += chunk;
|
|
93
|
-
});
|
|
94
|
-
child.stderr?.on("data", (chunk) => {
|
|
95
|
-
stderr += chunk;
|
|
96
|
-
});
|
|
97
|
-
child.once("error", (cause) => {
|
|
98
|
-
spawnError = cause;
|
|
99
|
-
});
|
|
100
|
-
if (timeoutMs !== undefined && timeoutMs > 0) {
|
|
101
|
-
timeout = setTimeout(() => {
|
|
102
|
-
timedOut = true;
|
|
103
|
-
child.kill();
|
|
104
|
-
}, timeoutMs);
|
|
105
|
-
timeout.unref();
|
|
106
|
-
}
|
|
107
|
-
child.once("close", () => {
|
|
108
|
-
if (timeout !== undefined)
|
|
109
|
-
clearTimeout(timeout);
|
|
110
|
-
if (spawnError === undefined && child.exitCode === 0) {
|
|
111
|
-
const version = firstNonemptyLine(stdout) ?? firstNonemptyLine(stderr);
|
|
112
|
-
if (version !== undefined) {
|
|
113
|
-
resolve({ ok: true, version });
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
resolve({
|
|
117
|
-
ok: false,
|
|
118
|
-
failure: failure("runtime_invalid_version_output", child, stderr),
|
|
119
|
-
});
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
const cause = spawnError ??
|
|
123
|
-
new Error("Runtime version probe did not exit successfully");
|
|
124
|
-
resolve({
|
|
125
|
-
ok: false,
|
|
126
|
-
failure: timedOut
|
|
127
|
-
? failure("runtime_timeout", child, stderr)
|
|
128
|
-
: classifyProbeFailure(cause, child, stderr),
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
const classifyProbeFailure = (cause, child, stderr) => {
|
|
133
|
-
const dependency = missingDynamicLibrary(stderr);
|
|
134
|
-
if (dependency !== null)
|
|
135
|
-
return failure("runtime_dynamic_library_missing", child, stderr, dependency);
|
|
136
|
-
if ("killed" in cause && cause.killed === true)
|
|
137
|
-
return failure("runtime_timeout", child, stderr);
|
|
138
|
-
if (child.signalCode !== null)
|
|
139
|
-
return failure("runtime_signal", child, stderr);
|
|
140
|
-
if ("code" in cause && typeof cause.code === "string")
|
|
141
|
-
return failure("runtime_spawn_failed", child, stderr);
|
|
142
|
-
return failure("runtime_nonzero_exit", child, stderr);
|
|
143
|
-
};
|
|
144
|
-
const failure = (code, child, stderr, dependency = null) => ({
|
|
145
|
-
code,
|
|
146
|
-
exit_code: child.exitCode,
|
|
147
|
-
signal: child.signalCode,
|
|
148
|
-
dependency,
|
|
149
|
-
stderr: stderr.trim(),
|
|
150
|
-
});
|
|
151
|
-
const missingDynamicLibrary = (stderr) => /(?:dyld(?:\[[^\]]+\])?: )?Library not loaded:\s*([^\r\n]+)/u
|
|
152
|
-
.exec(stderr)?.[1]
|
|
153
|
-
?.trim() ?? null;
|
|
154
|
-
const isExecutable = async (path, platform) => {
|
|
155
|
-
try {
|
|
156
|
-
await access(path, platform === "win32" ? constants.F_OK : constants.X_OK);
|
|
157
|
-
return true;
|
|
158
|
-
}
|
|
159
|
-
catch {
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
const canonicalPath = async (path) => {
|
|
164
|
-
try {
|
|
165
|
-
return await realpath(path);
|
|
166
|
-
}
|
|
167
|
-
catch {
|
|
168
|
-
return path;
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
const firstNonemptyLine = (value) => value
|
|
172
|
-
.split(/\r?\n/u)
|
|
173
|
-
.find((line) => line.trim().length > 0)
|
|
174
|
-
?.trim();
|
|
175
|
-
const unique = (values) => [...new Set(values)];
|
|
176
|
-
const environmentWithPath = (path) => {
|
|
177
|
-
const environment = {};
|
|
178
|
-
for (const [name, value] of Object.entries(process.env))
|
|
179
|
-
if (name.toUpperCase() !== "PATH")
|
|
180
|
-
environment[name] = value;
|
|
181
|
-
environment.PATH = path;
|
|
182
|
-
return environment;
|
|
183
|
-
};
|
|
184
|
-
const mapConcurrentBounded = async (inputs, concurrency, operation) => {
|
|
185
|
-
const outputs = [];
|
|
186
|
-
let nextIndex = 0;
|
|
187
|
-
const workers = Array.from({ length: Math.min(concurrency, inputs.length) }, async () => {
|
|
188
|
-
while (nextIndex < inputs.length) {
|
|
189
|
-
const index = nextIndex;
|
|
190
|
-
nextIndex += 1;
|
|
191
|
-
const input = inputs[index];
|
|
192
|
-
if (input !== undefined)
|
|
193
|
-
outputs[index] = await operation(input);
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
await Promise.all(workers);
|
|
197
|
-
return outputs;
|
|
198
|
-
};
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { execFile, spawn } from "node:child_process";
|
|
2
|
-
import { realpath } from "node:fs/promises";
|
|
3
|
-
import { basename, dirname, resolve } from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { promisify } from "node:util";
|
|
6
|
-
import { gt, valid } from "semver";
|
|
7
|
-
import { z } from "zod";
|
|
8
|
-
import { PRODUCT_IDENTITY } from "../identity.js";
|
|
9
|
-
const execFileAsync = promisify(execFile);
|
|
10
|
-
const registryResponseSchema = z.object({ version: z.string().min(1) });
|
|
11
|
-
const UPGRADE_COMMAND = "npm install --global rea-agents@latest";
|
|
12
|
-
const CLI_SCRIPT_PATH = fileURLToPath(new URL("../../scripts/rea.mjs", import.meta.url));
|
|
13
|
-
/** Check the npm registry and update the same global REA installation. */
|
|
14
|
-
export const runUpgrade = async (currentVersion, host = systemUpgradeHost(), output = "human") => {
|
|
15
|
-
const latestVersion = await host.latestVersion();
|
|
16
|
-
const currentIsValid = valid(currentVersion) !== null;
|
|
17
|
-
const latestIsValid = latestVersion !== undefined && valid(latestVersion) !== null;
|
|
18
|
-
if (!currentIsValid || !latestIsValid)
|
|
19
|
-
return {
|
|
20
|
-
status: "failed",
|
|
21
|
-
currentVersion,
|
|
22
|
-
latestVersion: latestVersion ?? null,
|
|
23
|
-
reason: "version-check",
|
|
24
|
-
remediation: "REA could not verify a newer registry release. Check npm registry access and version metadata, then rerun rea upgrade.",
|
|
25
|
-
};
|
|
26
|
-
if (!gt(latestVersion, currentVersion))
|
|
27
|
-
return {
|
|
28
|
-
status: "current",
|
|
29
|
-
currentVersion,
|
|
30
|
-
latestVersion,
|
|
31
|
-
installMethod: "npm",
|
|
32
|
-
};
|
|
33
|
-
const installation = await host.installation();
|
|
34
|
-
if (installation === undefined)
|
|
35
|
-
return {
|
|
36
|
-
status: "failed",
|
|
37
|
-
currentVersion,
|
|
38
|
-
latestVersion: latestVersion ?? null,
|
|
39
|
-
reason: "unknown-install-method",
|
|
40
|
-
remediation: `Update manually with: ${UPGRADE_COMMAND}`,
|
|
41
|
-
};
|
|
42
|
-
if (!(await host.installLatest(installation, output)))
|
|
43
|
-
return {
|
|
44
|
-
status: "failed",
|
|
45
|
-
currentVersion,
|
|
46
|
-
latestVersion: latestVersion ?? null,
|
|
47
|
-
reason: "install",
|
|
48
|
-
remediation: `REA could not update through npm. Check npm registry access and global install permissions, then run: ${UPGRADE_COMMAND}`,
|
|
49
|
-
};
|
|
50
|
-
const integrationSyncResult = await host.syncAgentIntegration(output);
|
|
51
|
-
const integrationSync = integrationSyncResult === undefined
|
|
52
|
-
? "deferred"
|
|
53
|
-
: integrationSyncResult
|
|
54
|
-
? "setup_invoked"
|
|
55
|
-
: "failed";
|
|
56
|
-
return {
|
|
57
|
-
status: "upgraded",
|
|
58
|
-
previousVersion: currentVersion,
|
|
59
|
-
latestVersion,
|
|
60
|
-
versionCheck: "available",
|
|
61
|
-
installMethod: "npm",
|
|
62
|
-
command: UPGRADE_COMMAND,
|
|
63
|
-
integrationSync,
|
|
64
|
-
clientRestartRequired: true,
|
|
65
|
-
remediation: integrationSync === "setup_invoked"
|
|
66
|
-
? "The updated setup journey was opened to align registrations and the skill. Restart clients whose approved registration changed."
|
|
67
|
-
: "Run rea setup --all-detected to align registrations and the skill, then restart clients that may retain an older MCP server.",
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
/** Create the npm registry and subprocess effects for a production upgrade. */
|
|
71
|
-
export const systemUpgradeHost = () => ({
|
|
72
|
-
latestVersion: async () => {
|
|
73
|
-
try {
|
|
74
|
-
const response = await fetch(`https://registry.npmjs.org/${PRODUCT_IDENTITY.packageName}/latest`, { signal: AbortSignal.timeout(10_000) });
|
|
75
|
-
if (!response.ok)
|
|
76
|
-
return undefined;
|
|
77
|
-
const parsed = registryResponseSchema.safeParse(await response.json());
|
|
78
|
-
return parsed.success ? parsed.data.version : undefined;
|
|
79
|
-
}
|
|
80
|
-
catch {
|
|
81
|
-
return undefined;
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
installation: () => detectNpmInstallation(fileURLToPath(new URL("../..", import.meta.url)), systemNpmInstallationHost),
|
|
85
|
-
installLatest: ({ prefix }, output) => runCommand("npm", [
|
|
86
|
-
"install",
|
|
87
|
-
"--global",
|
|
88
|
-
"--prefix",
|
|
89
|
-
prefix,
|
|
90
|
-
`${PRODUCT_IDENTITY.packageName}@latest`,
|
|
91
|
-
], output),
|
|
92
|
-
syncAgentIntegration: (output) => output === "structured" ||
|
|
93
|
-
process.stdin.isTTY !== true ||
|
|
94
|
-
process.stderr.isTTY !== true
|
|
95
|
-
? Promise.resolve(undefined)
|
|
96
|
-
: runCommand(process.execPath, [CLI_SCRIPT_PATH, "setup", "--all-detected"], "human"),
|
|
97
|
-
});
|
|
98
|
-
const systemNpmInstallationHost = {
|
|
99
|
-
canonicalPath: realpath,
|
|
100
|
-
globalRoot: async () => (await execFileAsync("npm", ["root", "--global"])).stdout.trim(),
|
|
101
|
-
globalPrefix: async () => (await execFileAsync("npm", ["prefix", "--global"])).stdout.trim(),
|
|
102
|
-
};
|
|
103
|
-
/** Identify the npm prefix only when it owns the running package. */
|
|
104
|
-
export const detectNpmInstallation = async (packageRoot, host) => {
|
|
105
|
-
try {
|
|
106
|
-
const canonicalPackageRoot = await host.canonicalPath(packageRoot);
|
|
107
|
-
const npmRoot = await host.globalRoot();
|
|
108
|
-
const globalPackageRoot = await host.canonicalPath(resolve(npmRoot, PRODUCT_IDENTITY.packageName));
|
|
109
|
-
if (canonicalPackageRoot === globalPackageRoot) {
|
|
110
|
-
const prefix = await host.globalPrefix();
|
|
111
|
-
return prefix.length === 0 ? undefined : { prefix };
|
|
112
|
-
}
|
|
113
|
-
return inferUnixGlobalPrefix(canonicalPackageRoot);
|
|
114
|
-
}
|
|
115
|
-
catch {
|
|
116
|
-
return inferUnixGlobalPrefix(packageRoot);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
const inferUnixGlobalPrefix = (packageRoot) => {
|
|
120
|
-
const nodeModules = dirname(packageRoot);
|
|
121
|
-
const library = dirname(nodeModules);
|
|
122
|
-
if (basename(packageRoot) !== PRODUCT_IDENTITY.packageName ||
|
|
123
|
-
basename(nodeModules) !== "node_modules" ||
|
|
124
|
-
basename(library) !== "lib")
|
|
125
|
-
return undefined;
|
|
126
|
-
return { prefix: dirname(library) };
|
|
127
|
-
};
|
|
128
|
-
const runCommand = (command, arguments_, output) => new Promise((resolveResult) => {
|
|
129
|
-
const child = spawn(command, [...arguments_], {
|
|
130
|
-
stdio: output === "human" ? "inherit" : ["inherit", "ignore", "inherit"],
|
|
131
|
-
});
|
|
132
|
-
child.once("error", () => resolveResult(false));
|
|
133
|
-
child.once("exit", (code) => resolveResult(code === 0));
|
|
134
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
const SECRET_ASSIGNMENT = /\b(authorization|api[_-]?key|access[_-]?token|refresh[_-]?token|token|password|passwd|secret|cookie|session)\b\s*[:=]\s*(?:Bearer\s+[A-Za-z0-9._~+/=-]+|"[^"]*"|'[^']*'|[^\s,;]+)/giu;
|
|
2
|
-
const BEARER = /\bBearer\s+[A-Za-z0-9._~+/=-]+/giu;
|
|
3
|
-
const JWT = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/gu;
|
|
4
|
-
/** Redact credential-shaped substrings before approved console text is retained. */
|
|
5
|
-
export const redactSensitiveText = (value) => value
|
|
6
|
-
.replace(SECRET_ASSIGNMENT, (_match, name) => `${name}=[REDACTED]`)
|
|
7
|
-
.replace(BEARER, "Bearer [REDACTED]")
|
|
8
|
-
.replace(JWT, "[REDACTED_JWT]");
|