rea-agents 2.5.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/README.md +20 -12
  2. package/bridge/ghidra/ReaGhidraBridge.java +477 -4
  3. package/bridge/hopper_bridge.py +54 -4
  4. package/dist/application/AnalysisContextQueries.js +142 -0
  5. package/dist/application/AnalysisSnapshotCache.js +4 -2
  6. package/dist/application/ApplicationWorkflowEvidenceResolver.js +19 -11
  7. package/dist/application/ArtifactInventory/policy.js +17 -0
  8. package/dist/application/ArtifactInventory/reader.js +1 -4
  9. package/dist/application/ArtifactInventory/scanCanonical.js +0 -3
  10. package/dist/application/ArtifactInventory/scanReader.js +7 -7
  11. package/dist/application/ArtifactInventory/types.js +1 -5
  12. package/dist/application/BinarySession.js +19 -20
  13. package/dist/application/BinarySessionComposition.js +21 -0
  14. package/dist/application/BinarySessionRecords.js +106 -10
  15. package/dist/application/BinarySessionStatus.js +11 -5
  16. package/dist/application/BrowserEvidence.js +3 -5
  17. package/dist/application/CapabilityClientRequirements.js +26 -0
  18. package/dist/application/CapabilityInventory.js +140 -55
  19. package/dist/application/ClientRegistrationStatus.js +4 -1
  20. package/dist/application/CrossVersionInventory.js +7 -6
  21. package/dist/application/DirectAnalysis.js +6 -2
  22. package/dist/application/ElectronActiveEvidence.js +55 -0
  23. package/dist/application/ElectronActiveObservationPort.js +1 -0
  24. package/dist/application/ElectronActiveObservationService.js +81 -0
  25. package/dist/application/EnhancedTools.js +49 -17
  26. package/dist/application/EvidenceBundleCommands.js +5 -1
  27. package/dist/application/EvidenceLedger.js +53 -17
  28. package/dist/application/JavaScriptArtifactAnalysis.js +13 -4
  29. package/dist/application/JavaScriptReplayPermission.js +1 -1
  30. package/dist/application/JavaScriptReplayService.js +23 -15
  31. package/dist/application/LazyAnalysisProvider.js +77 -0
  32. package/dist/application/LoopbackReplay.js +1 -1
  33. package/dist/application/ManagedRuntimeCorrelationService.js +9 -5
  34. package/dist/application/NativeApiInspection.js +80 -0
  35. package/dist/application/NodeRuntimeCharacterizationService.js +8 -9
  36. package/dist/application/ProcessCaptureLifecycle.js +5 -0
  37. package/dist/application/ProcessCli.js +2 -1
  38. package/dist/application/ProcessHarness.js +8 -3
  39. package/dist/application/ProcessNormalization.js +2 -1
  40. package/dist/application/ProjectPermissionStore.js +1 -0
  41. package/dist/application/ReferenceSourceImport.js +2 -2
  42. package/dist/application/SessionProviderRouter.js +6 -6
  43. package/dist/application/SetupClientConfiguration.js +10 -3
  44. package/dist/application/WindowsCapabilities.js +5 -4
  45. package/dist/application/runtime.js +26 -9
  46. package/dist/artifacts/ArtifactProvider.js +8 -10
  47. package/dist/artifacts/SafeOutputTree.js +7 -8
  48. package/dist/browser/CdpCaptureStorageFingerprints.js +10 -7
  49. package/dist/browser/CdpElectronInspection.js +3 -1
  50. package/dist/browser/JavaScriptRuntimeScope.js +5 -0
  51. package/dist/browser/PlaywrightBrowserScenarioProvider.js +8 -2
  52. package/dist/browser/PlaywrightElectronActiveActions.js +324 -0
  53. package/dist/browser/PlaywrightElectronActiveProvider.js +294 -0
  54. package/dist/browser/PlaywrightScenarioBrowser.js +4 -4
  55. package/dist/browser/PlaywrightScenarioSession.js +4 -4
  56. package/dist/browser/SensitiveTextCapture.js +1 -1
  57. package/dist/browser/V8InspectorCaptureProjection.js +1 -0
  58. package/dist/browser/V8InspectorProvider.js +3 -3
  59. package/dist/catalogIdentity.js +15 -9
  60. package/dist/cli/artifactCommands.js +5 -3
  61. package/dist/cli/coreAnalysisCommands.js +41 -0
  62. package/dist/cli/managedCommands.js +1 -1
  63. package/dist/cliApplicationCommands.js +2 -2
  64. package/dist/cliBrowserAdvancedCommands.js +11 -5
  65. package/dist/cliBrowserCommands.js +14 -7
  66. package/dist/cliCommandNames.js +2 -0
  67. package/dist/cliElectronCommands.js +46 -4
  68. package/dist/cliJavaScriptRuntimeCommands.js +14 -6
  69. package/dist/cliObservationOptions.js +4 -0
  70. package/dist/cliPolicyCommands.js +1 -0
  71. package/dist/config/browserScenario.js +77 -0
  72. package/dist/config/electronAutomation.js +35 -0
  73. package/dist/config/environment.js +6 -0
  74. package/dist/config/javascriptReplay.js +41 -0
  75. package/dist/config/managedRuntime.js +25 -0
  76. package/dist/config/parseConfig.js +56 -200
  77. package/dist/config/parsers.js +10 -1
  78. package/dist/config/passiveObservation.js +157 -0
  79. package/dist/config/processCapture.js +47 -0
  80. package/dist/contracts/applicationToolContracts.js +2 -5
  81. package/dist/contracts/applicationWorkflowInputContracts.js +86 -96
  82. package/dist/contracts/artifactToolContracts.js +35 -37
  83. package/dist/contracts/browserToolContracts.js +2 -2
  84. package/dist/contracts/electronToolContracts.js +30 -1
  85. package/dist/contracts/enhancedInputs.js +21 -27
  86. package/dist/contracts/functionWorkflowToolContracts.js +29 -0
  87. package/dist/contracts/managedToolContracts.js +4 -9
  88. package/dist/contracts/managedWorkflowExamples.js +12 -9
  89. package/dist/contracts/managedWorkflowToolContracts.js +30 -27
  90. package/dist/contracts/nativeToolContracts.js +2 -3
  91. package/dist/contracts/promptContracts.js +14 -15
  92. package/dist/contracts/sessionToolSchemas.js +61 -0
  93. package/dist/contracts/toolContractExamples.js +4 -0
  94. package/dist/contracts/toolContractHelpers.js +23 -0
  95. package/dist/contracts/toolContracts.js +12 -67
  96. package/dist/contracts/toolEffects.js +19 -0
  97. package/dist/contracts/toolOutputSchemaGroups.js +66 -11
  98. package/dist/contracts/toolOutputSchemaPrimitives.js +76 -26
  99. package/dist/contracts/toolSchemaMetadata.js +128 -0
  100. package/dist/doctorRuntime.js +1 -1
  101. package/dist/domain/analysisErrorPresentation.js +8 -2
  102. package/dist/domain/analysisErrorProjection.js +1 -0
  103. package/dist/domain/androidApplication.js +2 -0
  104. package/dist/domain/appleApplication.js +2 -0
  105. package/dist/domain/binaryTarget.js +7 -5
  106. package/dist/domain/binaryTargetTypes.js +1 -0
  107. package/dist/domain/browserCaptureComparison.js +21 -69
  108. package/dist/domain/browserObservation.js +22 -9
  109. package/dist/domain/bytecodeProvider.js +177 -0
  110. package/dist/domain/callPath.js +3 -2
  111. package/dist/domain/conformancePackage.js +169 -0
  112. package/dist/domain/conformanceReplay.js +104 -0
  113. package/dist/domain/conformanceTrustGate.js +328 -0
  114. package/dist/domain/customProtocolCapture.js +137 -0
  115. package/dist/domain/electronActiveObservation.js +277 -0
  116. package/dist/domain/electronObservation.js +15 -11
  117. package/dist/domain/electronStaticAnalysisValues.js +4 -1
  118. package/dist/domain/eventProcessTree.js +217 -0
  119. package/dist/domain/evidenceBundle.js +47 -0
  120. package/dist/domain/functionComparisonNormalization.js +15 -8
  121. package/dist/domain/functionDossierEvidence.js +9 -4
  122. package/dist/domain/hopperStartupFailure.js +1 -1
  123. package/dist/domain/hopperValues.js +68 -68
  124. package/dist/domain/inputIssueProjection.js +11 -2
  125. package/dist/domain/investigationWorkspace.js +16 -15
  126. package/dist/domain/javascriptExportShapeComparisonSchemas.js +2 -2
  127. package/dist/domain/javascriptReplay.js +79 -63
  128. package/dist/domain/javascriptRuntimeObservation.js +1 -0
  129. package/dist/domain/javascriptRuntimeReconciliationActive.js +89 -0
  130. package/dist/domain/javascriptRuntimeReconciliationGraph.js +11 -10
  131. package/dist/domain/javascriptRuntimeReconciliationMatching.js +57 -49
  132. package/dist/domain/javascriptRuntimeReconciliationParsing.js +5 -1
  133. package/dist/domain/javascriptRuntimeReconciliationResult.js +21 -14
  134. package/dist/domain/javascriptRuntimeReconciliationSchemas.js +1 -1
  135. package/dist/domain/javascriptSemanticAnalysis.js +8 -12
  136. package/dist/domain/javascriptSourceParser.js +15 -0
  137. package/dist/domain/javascriptStaticAnalysis.js +8 -12
  138. package/dist/domain/knownPageCoverage.js +15 -7
  139. package/dist/domain/mobileApplicationInvestigation.js +159 -0
  140. package/dist/domain/nativeApiBoundary.js +138 -0
  141. package/dist/domain/nodeRuntimeCharacterization.js +14 -13
  142. package/dist/domain/objcSwiftMetadata.js +150 -0
  143. package/dist/domain/packageAnalysis.js +123 -0
  144. package/dist/domain/peInspection.js +196 -0
  145. package/dist/domain/processCaptureReactiveValidation.js +8 -3
  146. package/dist/domain/processCaptureValidation.js +7 -3
  147. package/dist/domain/processComparison.js +12 -7
  148. package/dist/domain/processObservation.js +5 -6
  149. package/dist/domain/processReactiveMatching.js +14 -7
  150. package/dist/domain/processReactiveTransition.js +9 -3
  151. package/dist/domain/processScenario.js +6 -3
  152. package/dist/domain/processTraceComparison.js +3 -2
  153. package/dist/domain/protocolCapture.js +245 -0
  154. package/dist/domain/reconstructionReadinessSchemas.js +30 -2
  155. package/dist/domain/referenceSourceImportParsing.js +2 -2
  156. package/dist/domain/replayMachineRuntime.js +5 -3
  157. package/dist/domain/sourceToBundleComparison.js +2 -2
  158. package/dist/domain/sourceToBundleComparisonSchemas.js +8 -8
  159. package/dist/domain/sourceToBundleSignals.js +7 -1
  160. package/dist/domain/staticRuntimeCorrelation.js +7 -5
  161. package/dist/domain/webBundleAnalysis.js +14 -14
  162. package/dist/domain/webCaptureDiff.js +15 -12
  163. package/dist/dotnet/ManagedNativeBoundaryInspector.js +2 -3
  164. package/dist/dotnet/ManagedStaticProvider.js +34 -5
  165. package/dist/generatedMcpToolCatalog.js +37 -0
  166. package/dist/generatedPackageMetadata.js +4 -4
  167. package/dist/ghidra/GhidraClient.js +1 -1
  168. package/dist/ghidra/GhidraClientStartup.js +1 -1
  169. package/dist/ghidra/GhidraDefaults.js +1 -1
  170. package/dist/ghidra/GhidraFunctionValues.js +44 -16
  171. package/dist/ghidra/GhidraInventoryValues.js +57 -47
  172. package/dist/ghidra/GhidraProvider.js +18 -10
  173. package/dist/ghidra/GhidraProviderCapabilities.js +45 -39
  174. package/dist/ghidra/GhidraSocketConnection.js +1 -1
  175. package/dist/ghidra/protocol.js +19 -42
  176. package/dist/hopper/BridgeLauncher.js +3 -1
  177. package/dist/hopper/HopperAnalysisProfile.js +2 -4
  178. package/dist/hopper/HopperCleanup.js +5 -6
  179. package/dist/hopper/HopperClient.js +27 -3
  180. package/dist/hopper/HopperProvider.js +42 -44
  181. package/dist/hopper/HopperRequestQueue.js +32 -4
  182. package/dist/hopper/HopperResponseStream.js +2 -2
  183. package/dist/hopper/LinuxPrivateDisplayProbe.js +16 -10
  184. package/dist/hopper/protocol.js +63 -21
  185. package/dist/main/reload.js +1 -6
  186. package/dist/main/state.js +0 -14
  187. package/dist/main/transport.js +31 -41
  188. package/dist/main.js +17 -13
  189. package/dist/mcpDoctor.js +4 -26
  190. package/dist/mcpStartupPolicy.js +14 -0
  191. package/dist/process/PrivateRuntimeRoot.js +17 -0
  192. package/dist/process/ProcessOwnership.js +64 -128
  193. package/dist/process/ProcessOwnershipIdentity.js +13 -0
  194. package/dist/process/ProcessOwnershipObservation.js +88 -0
  195. package/dist/process/ProcessOwnershipProcessTree.js +22 -0
  196. package/dist/process/ProviderDeadline.js +8 -12
  197. package/dist/process/WindowsAuthority.js +32 -0
  198. package/dist/reference/ReferenceSourceReader.js +3 -3
  199. package/dist/reference/ReferenceSourceReaderEntries.js +2 -2
  200. package/dist/replay/JavaScriptReplayWorker.js +95 -11
  201. package/dist/replay/JavaScriptReplayWorkerTypes.js +1 -0
  202. package/dist/replay/LinuxJavaScriptReplayRunner.js +10 -15
  203. package/dist/replay/ReplayOutcome.js +26 -15
  204. package/dist/replay/ReplayWorkerProtocol.js +34 -29
  205. package/dist/server/createServer.js +101 -144
  206. package/dist/server/mcpClientMetadata.js +32 -0
  207. package/dist/server/registerApplicationTools/characterization.js +6 -13
  208. package/dist/server/registerApplicationTools/compareExportShapes.js +2 -7
  209. package/dist/server/registerApplicationTools/compareSourceToBundle.js +2 -7
  210. package/dist/server/registerApplicationTools/compareVersions.js +3 -8
  211. package/dist/server/registerApplicationTools/controlledReplay.js +6 -11
  212. package/dist/server/registerApplicationTools/coverage.js +13 -19
  213. package/dist/server/registerApplicationTools/obligationLedger.js +1 -6
  214. package/dist/server/registerApplicationTools/readiness.js +1 -6
  215. package/dist/server/registerApplicationTools/traceFeature.js +3 -8
  216. package/dist/server/registerApplicationTools/traceSemantics.js +1 -6
  217. package/dist/server/registerArtifactComparisonTool.js +12 -16
  218. package/dist/server/registerBrowserScenarioTool.js +1 -6
  219. package/dist/server/registerBrowserTools.js +37 -79
  220. package/dist/server/registerBundleComparisonTool.js +10 -14
  221. package/dist/server/registerCloseLifecycleTool.js +6 -14
  222. package/dist/server/registerElectronTools.js +30 -47
  223. package/dist/server/registerEnhancedTools.js +124 -122
  224. package/dist/server/registerEvidenceResources.js +50 -101
  225. package/dist/server/registerEvidenceTools.js +5 -9
  226. package/dist/server/registerFunctionComparisonTool.js +11 -15
  227. package/dist/server/registerInvestigationTools.js +42 -59
  228. package/dist/server/registerJavaScriptApplicationGraphResource.js +0 -4
  229. package/dist/server/registerJavaScriptRuntimeObservationTools.js +13 -27
  230. package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +4 -9
  231. package/dist/server/registerManagedWorkflowTools/contract.js +2 -3
  232. package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +3 -8
  233. package/dist/server/registerManagedWorkflowTools/planManagedRuntimeCorrelation.js +3 -8
  234. package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +8 -13
  235. package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +4 -9
  236. package/dist/server/registerOfficialTools.js +8 -9
  237. package/dist/server/registerProcessComparisonTool.js +19 -24
  238. package/dist/server/registerReconstructionObligationLedgerResource.js +0 -7
  239. package/dist/server/registerReconstructionReadinessResource.js +0 -7
  240. package/dist/server/registerReplayMachineTool.js +4 -10
  241. package/dist/server/registerSessionRecordTools.js +146 -47
  242. package/dist/server/registerSessionStatusTool.js +14 -29
  243. package/dist/server/registerSessionTools.js +45 -41
  244. package/dist/server/sessionAvailabilityPolicy.js +2 -1
  245. package/dist/server/sessionToolPolicies.js +1 -5
  246. package/dist/server/toolRegistrationOptions.js +4 -177
  247. package/dist/server/toolResult.js +14 -18
  248. package/package.json +35 -16
  249. package/scripts/electron-active-hook-boundaries.cjs +394 -0
  250. package/scripts/electron-active-hook.cjs +501 -0
  251. package/skills/reverse-engineer-anything/SKILL.md +10 -3
  252. package/dist/server/DynamicToolAvailability.js +0 -70
  253. package/dist/server/toolInputValidation.js +0 -77
@@ -42,11 +42,8 @@ export const targetKindSchema = z.enum([
42
42
  "archive",
43
43
  "artifact",
44
44
  ]);
45
- const providerCapability = z.object({
45
+ const providerCapabilityFacts = {
46
46
  operation: z.string(),
47
- available: z.boolean(),
48
- reason: z.string().nullable(),
49
- availability_code: z.enum(PROVIDER_REJECTION_CODES).nullable(),
50
47
  input_contract_version: z.number().int().min(1),
51
48
  output_contract_version: z.number().int().min(1),
52
49
  pagination: z.enum(["none", "offset", "cursor"]),
@@ -66,7 +63,21 @@ const providerCapability = z.object({
66
63
  timeout_ms: z.number().int().min(0).nullable(),
67
64
  }),
68
65
  limitations: z.array(z.string()),
69
- });
66
+ };
67
+ export const providerCapability = z.discriminatedUnion("available", [
68
+ z.object({
69
+ ...providerCapabilityFacts,
70
+ available: z.literal(true),
71
+ reason: z.null(),
72
+ availability_code: z.null(),
73
+ }),
74
+ z.object({
75
+ ...providerCapabilityFacts,
76
+ available: z.literal(false),
77
+ reason: z.string().nullable(),
78
+ availability_code: z.enum(PROVIDER_REJECTION_CODES).nullable(),
79
+ }),
80
+ ]);
70
81
  export const providerIdentity = z.object({
71
82
  id: z.string(),
72
83
  name: z.string(),
@@ -182,21 +193,25 @@ export const clientFeatureAvailabilitySchema = z.object({
182
193
  roots: z.boolean(),
183
194
  sampling: z.boolean(),
184
195
  });
185
- export const toolAvailability = z.object({
196
+ const toolAvailabilityMode = z.discriminatedUnion("available", [
197
+ z.object({
198
+ name: z.string(),
199
+ available: z.literal(true),
200
+ missing_operations: z.array(z.string()).max(0),
201
+ remediation: z.null(),
202
+ }),
203
+ z.object({
204
+ name: z.string(),
205
+ available: z.literal(false),
206
+ missing_operations: z.array(z.string()).min(1),
207
+ remediation: z.string().nullable(),
208
+ }),
209
+ ]);
210
+ const toolAvailabilityFacts = {
186
211
  name: z.string(),
187
212
  surface: z.string(),
188
- available: z.boolean(),
189
- reason: z.enum([
190
- "available",
191
- "client_capability_missing",
192
- "target_required",
193
- "provider_missing",
194
- "provider_unavailable",
195
- "target_unsupported",
196
- "unsupported_host",
197
- "policy_disabled",
198
- ]),
199
- remediation: z.string().nullable(),
213
+ default_mode_available: z.boolean().optional(),
214
+ modes: z.array(toolAvailabilityMode).optional(),
200
215
  client_requirements: z.object({
201
216
  required: z.array(clientFeatureNameSchema),
202
217
  optional: z.array(clientFeatureNameSchema),
@@ -219,7 +234,30 @@ export const toolAvailability = z.object({
219
234
  idempotent: z.boolean(),
220
235
  open_world: z.boolean(),
221
236
  }),
222
- });
237
+ };
238
+ export const toolUnavailabilityReason = z.enum([
239
+ "client_capability_missing",
240
+ "target_required",
241
+ "provider_missing",
242
+ "provider_unavailable",
243
+ "target_unsupported",
244
+ "unsupported_host",
245
+ "policy_disabled",
246
+ ]);
247
+ export const toolAvailability = z.discriminatedUnion("available", [
248
+ z.object({
249
+ ...toolAvailabilityFacts,
250
+ available: z.literal(true),
251
+ reason: z.literal("available"),
252
+ remediation: z.null(),
253
+ }),
254
+ z.object({
255
+ ...toolAvailabilityFacts,
256
+ available: z.literal(false),
257
+ reason: toolUnavailabilityReason,
258
+ remediation: z.string().nullable(),
259
+ }),
260
+ ]);
223
261
  export const sessionProvider = z.object({
224
262
  provider: providerIdentity,
225
263
  providers: z.array(providerIdentity),
@@ -315,13 +353,25 @@ const availableMemoryPermissions = z.object({
315
353
  available: z.literal(true),
316
354
  source: z.literal("ghidra-memory-block"),
317
355
  });
318
- export const bounded = (item) => z.object({
319
- items: z.array(item),
320
- total: z.number().int().min(0).nullable(),
321
- returned: z.number().int().min(0),
322
- truncated: z.boolean(),
323
- next_offset: z.number().int().min(0).nullable(),
324
- });
356
+ export const bounded = (item) => {
357
+ const facts = {
358
+ items: z.array(item),
359
+ total: z.number().int().min(0).nullable(),
360
+ returned: z.number().int().min(0),
361
+ };
362
+ return z.discriminatedUnion("truncated", [
363
+ z.object({
364
+ ...facts,
365
+ truncated: z.literal(false),
366
+ next_offset: z.null(),
367
+ }),
368
+ z.object({
369
+ ...facts,
370
+ truncated: z.literal(true),
371
+ next_offset: z.number().int().min(0).nullable(),
372
+ }),
373
+ ]);
374
+ };
325
375
  const addressedValue = z.object({
326
376
  address: z.string(),
327
377
  value: z.string(),
@@ -0,0 +1,128 @@
1
+ import { z } from "zod";
2
+ const PROPERTY_DESCRIPTIONS = {
3
+ addresses: "Ordered provider-normalized procedure addresses to analyze.",
4
+ approved: "Explicit operator approval to perform this operation.",
5
+ after: "The later or right-hand observation to compare.",
6
+ before: "The earlier or left-hand observation to compare.",
7
+ boundary_id: "Exact reconstruction boundary identifier to evaluate.",
8
+ case_sensitive: "Whether text matching distinguishes uppercase and lowercase.",
9
+ cdp_endpoint: "Approved literal loopback Chrome DevTools Protocol endpoint.",
10
+ comment: "Exact analyst comment text to write.",
11
+ comparisons: "Validated comparison Evidence records to aggregate.",
12
+ coverage: "Exact reconstruction-coverage commitment to verify.",
13
+ detail: "Requested response detail level.",
14
+ direction: "Direction in which to traverse or compare relationships.",
15
+ document: "Exact provider document or program identity.",
16
+ error: "Structured, caller-actionable error when the operation fails.",
17
+ evidence: "Evidence v2 record produced by this operation.",
18
+ evidence_id: "Stable identifier of the recorded Evidence v2 observation.",
19
+ evidence_uri: "Session resource URI for the recorded Evidence v2 observation.",
20
+ executable: "Approved absolute path of the executable to run.",
21
+ format: "Declared input artifact format.",
22
+ name: "Exact name used by this operation.",
23
+ pattern: "Text or bounded pattern used to filter matching results.",
24
+ phase: "Current plan or execution phase of the operation.",
25
+ plan: "Content-bound execution plan and its approval commitment.",
26
+ query: "Non-empty feature or text query to investigate.",
27
+ question: "Concrete unresolved question to retain for later investigation.",
28
+ result: "Primary structured result returned by this operation.",
29
+ left: "Left-hand input used for comparison or differential execution.",
30
+ limit: "Maximum number of results to return in this page.",
31
+ limits: "Bounded resource-consumption and result-size limits for this operation.",
32
+ mode: "Operation mode that selects the requested behavior.",
33
+ offset: "Zero-based index of the first result to return.",
34
+ overwrite: "Whether an existing destination may be replaced.",
35
+ path: "Local filesystem path used by this operation.",
36
+ provider_id: "Exact deep-analysis provider ID, or automatic selection when omitted.",
37
+ right: "Right-hand input used for comparison or differential execution.",
38
+ schema_version: "Version of this structured result schema.",
39
+ source_evidence: "Evidence records supporting the prepared source transformation.",
40
+ status: "Current lifecycle or verification status.",
41
+ summary: "Concise evidence-backed summary of the result.",
42
+ symbols: "Ordered bounded Swift symbols to demangle.",
43
+ target_id: "Exact authorized CDP target identifier.",
44
+ unknown_id: "Exact residual-unknown identifier.",
45
+ unknown_registry_approved: "Explicit approval to record bounded residual uncertainty in the session registry.",
46
+ workspace_path: "Approved local path of the persistent investigation workspace.",
47
+ };
48
+ /** Attach caller guidance to a canonical schema for the SDK wire projection. */
49
+ export const toolInputSchemaWithMetadata = (contract) => {
50
+ const schema = contract.inputSchema.meta(z.globalRegistry.get(contract.inputSchema) ?? {});
51
+ const standard = schema["~standard"];
52
+ const inputJsonSchema = standard.jsonSchema?.input;
53
+ if (inputJsonSchema === undefined)
54
+ throw new TypeError("Tool input schema does not expose Standard JSON Schema");
55
+ // Zod's input projection drops root metadata when a descendant transforms.
56
+ // Preserve the parser and let the SDK own conversion of everything else.
57
+ Object.defineProperty(schema, "~standard", {
58
+ value: {
59
+ ...standard,
60
+ jsonSchema: {
61
+ ...standard.jsonSchema,
62
+ input: (options) => ({
63
+ ...describeProperties(inputJsonSchema(options)),
64
+ examples: contract.examples.map(({ input }) => input),
65
+ }),
66
+ },
67
+ },
68
+ });
69
+ return schema;
70
+ };
71
+ const describeProperties = (value) => Object.fromEntries(Object.entries(value).map(([key, child]) => {
72
+ if (key !== "properties" || !isObject(child))
73
+ return [key, describeValue(child)];
74
+ return [
75
+ key,
76
+ Object.fromEntries(Object.entries(child).map(([property, propertySchema]) => [
77
+ property,
78
+ isObject(propertySchema) &&
79
+ typeof propertySchema.description !== "string"
80
+ ? {
81
+ ...describeProperties(propertySchema),
82
+ description: fallbackPropertyDescription(property),
83
+ }
84
+ : describeValue(propertySchema),
85
+ ])),
86
+ ];
87
+ }));
88
+ const describeValue = (value) => {
89
+ if (Array.isArray(value))
90
+ return value.map(describeValue);
91
+ return isObject(value) ? describeProperties(value) : value;
92
+ };
93
+ const fallbackPropertyDescription = (property) => {
94
+ const explicit = PROPERTY_DESCRIPTIONS[property];
95
+ if (explicit !== undefined)
96
+ return explicit;
97
+ const words = property.replaceAll("_", " ");
98
+ if (property.endsWith("_approved"))
99
+ return `Explicit operator approval for ${words.slice(0, -9)}.`;
100
+ if (property.endsWith("_offset"))
101
+ return `Zero-based index of the first ${words.slice(0, -7)} to return.`;
102
+ if (property.endsWith("_limit"))
103
+ return `Maximum number of ${words.slice(0, -6)} entries to return.`;
104
+ if (property.startsWith("max_"))
105
+ return `Maximum permitted ${words.slice(4)} for this operation.`;
106
+ if (property.startsWith("include_"))
107
+ return `Whether to include ${words.slice(8)} in the result.`;
108
+ if (property.startsWith("expected_"))
109
+ return `Expected ${words.slice(9)} used to reject stale or mismatched input.`;
110
+ if (property.endsWith("_sha256"))
111
+ return `Exact SHA-256 digest of ${words.slice(0, -7)}.`;
112
+ if (property.endsWith("_evidence_id"))
113
+ return `Exact Evidence v2 identifier for the ${words.slice(0, -12)} observation.`;
114
+ if (property.endsWith("_evidence_ids"))
115
+ return `Ordered Evidence v2 identifiers for the ${words.slice(0, -13)} observations.`;
116
+ if (property.endsWith("_path"))
117
+ return `Local filesystem path for ${words.slice(0, -5)}.`;
118
+ if (property.endsWith("_uri"))
119
+ return `Canonical URI for ${words.slice(0, -4)}.`;
120
+ if (property.endsWith("_bytes"))
121
+ return `Bounded byte count for ${words.slice(0, -6)}.`;
122
+ if (property.endsWith("_root") || property.endsWith("_roots"))
123
+ return `Approved canonical filesystem ${words}.`;
124
+ if (property.startsWith("is_") || property.startsWith("has_"))
125
+ return `Whether ${words}.`;
126
+ return `Value for ${words}.`;
127
+ };
128
+ const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
@@ -58,7 +58,7 @@ const inspectJavaScriptReplay = async () => {
58
58
  detail: config.error.message,
59
59
  remediation: "Fix the reported REA_JAVASCRIPT_REPLAY_* configuration.",
60
60
  };
61
- if (!config.value.javascriptReplayPolicy.enabled)
61
+ if (config.value.javascriptReplayPolicy.status === "disabled")
62
62
  return {
63
63
  name: "javascript-replay",
64
64
  ok: true,
@@ -2,6 +2,8 @@ import { AnalysisInputError, ArtifactOperationError, BinaryTargetError, BrowserO
2
2
  export const analysisErrorRemediationAction = (error) => {
3
3
  if (error instanceof AnalysisInputError)
4
4
  return "Correct the listed arguments and retry.";
5
+ if (error instanceof UnknownRegistryError && error.reason === "not-found")
6
+ return "Check that the unknown_id belongs to this session, then retry.";
5
7
  if (error instanceof ReplayPlanStaleError)
6
8
  return "Review the rebuilt replay plan and explicitly approve its new digest.";
7
9
  if (error instanceof PermissionRequiredError)
@@ -64,7 +66,7 @@ const artifactErrorCategory = (reason) => {
64
66
  return "truncated";
65
67
  if (reason === "cancelled")
66
68
  return "cancelled";
67
- if (reason === "unavailable")
69
+ if (reason === "policy" || reason === "unavailable")
68
70
  return "unavailable";
69
71
  return "execution_failure";
70
72
  };
@@ -103,6 +105,8 @@ export const analysisErrorUserMessage = (error) => {
103
105
  return evidenceFileMessage(error.reason);
104
106
  if (error instanceof InvestigationWorkspaceError)
105
107
  return investigationWorkspaceMessage(error.reason);
108
+ if (error instanceof UnknownRegistryError && error.reason === "not-found")
109
+ return "The requested residual unknown does not exist in this session. Check the unknown_id and try again.";
106
110
  if (error instanceof UnknownRegistryError)
107
111
  return "Evidence state changed before the update completed. Refresh the current state and try again.";
108
112
  if (error instanceof ConfigurationError)
@@ -163,8 +167,10 @@ const artifactMessage = (reason) => {
163
167
  return "Artifact is too large to process safely. Narrow the requested path or use a smaller artifact.";
164
168
  if (reason === "path")
165
169
  return "Artifact path is not allowed. Choose a path inside the artifact and try again.";
170
+ if (reason === "policy")
171
+ return "Artifact integrity continuation is disabled by policy. Configure REA_ARTIFACT_INTEGRITY_CONTINUE_ENABLED=true and retry only if continuing after mismatches is approved.";
166
172
  if (reason === "unavailable")
167
- return "Artifact format is not available on this system. Choose another artifact or supported environment.";
173
+ return "Artifact processing is unavailable for the current target or policy. Check artifact support and required approvals.";
168
174
  if (reason === "format" || reason === "integrity")
169
175
  return "Artifact is invalid or has changed. Get a fresh copy and try again.";
170
176
  return "Artifact could not be read or written. Check file access and try again.";
@@ -152,6 +152,7 @@ const requestErrorDetails = (error) => {
152
152
  issues: error.issues.map((issue) => ({
153
153
  path: [...issue.path],
154
154
  reason: issue.reason,
155
+ ...(issue.message === undefined ? {} : { message: issue.message }),
155
156
  ...(issue.expected === undefined ? {} : { expected: issue.expected }),
156
157
  ...(issue.minimum === undefined ? {} : { minimum: issue.minimum }),
157
158
  ...(issue.maximum === undefined ? {} : { maximum: issue.maximum }),
@@ -146,6 +146,8 @@ const classify = (all) => ({
146
146
  });
147
147
  const retain = (groups, maximum) => {
148
148
  let remaining = maximum;
149
+ // SAFETY: the projection preserves every key from Groups and replaces only
150
+ // each readonly Component array with a bounded mutable Component array.
149
151
  return Object.fromEntries(Object.entries(groups).map(([key, values]) => {
150
152
  const selected = [...values]
151
153
  .sort((left, right) => compare(left.path, right.path))
@@ -140,6 +140,8 @@ const classifyComponents = (all, roots) => {
140
140
  };
141
141
  const retainComponents = (groups, maximum) => {
142
142
  let remaining = maximum;
143
+ // SAFETY: the projection preserves every key from Groups and replaces only
144
+ // each readonly Component array with a bounded mutable Component array.
143
145
  return Object.fromEntries(Object.entries(groups).map(([key, values]) => {
144
146
  const retained = [...values]
145
147
  .sort((left, right) => compare(left.path, right.path))
@@ -36,14 +36,16 @@ export const parseBinaryTarget = async (input, cwd = process.cwd(), hostArchitec
36
36
  format: "analysis-database",
37
37
  });
38
38
  const artifactFormat = await detectArtifactFormat(path, handle);
39
- if (artifactFormat !== undefined)
40
- return ok({
39
+ if (artifactFormat !== undefined) {
40
+ const identity = {
41
41
  path,
42
42
  sourcePath: canonical,
43
43
  sha256: await sha256Handle(handle),
44
- kind: isArchiveFormat(artifactFormat) ? "archive" : "artifact",
45
- format: artifactFormat,
46
- });
44
+ };
45
+ return isArchiveFormat(artifactFormat)
46
+ ? ok({ ...identity, kind: "archive", format: artifactFormat })
47
+ : ok({ ...identity, kind: "artifact", format: artifactFormat });
48
+ }
47
49
  const detected = await readExecutableMetadata(handle, hostArchitecture);
48
50
  if (!detected.ok)
49
51
  return err(new BinaryTargetError(path, detected.error));
@@ -0,0 +1 @@
1
+ export {};
@@ -1,75 +1,27 @@
1
1
  import { z } from "zod";
2
2
  import { browserScenarioDiffSchema, compareBrowserScenarios, compareBrowserScenariosInputSchema, } from "./browserScenarioDiff.js";
3
3
  import { compareWebCaptures, captureSnapshotSchema, webCaptureDiffSchema, } from "./webCaptureDiff.js";
4
- /** Top-level MCP shape for legacy page or step-indexed scenario comparison. */
5
- export const browserCaptureComparisonWireSchema = z
6
- .strictObject({
7
- before: captureSnapshotSchema
8
- .optional()
9
- .describe("Earlier passive web-page capture; pair with after."),
10
- after: captureSnapshotSchema
11
- .optional()
12
- .describe("Later passive web-page capture; pair with before."),
13
- before_scenario: compareBrowserScenariosInputSchema.shape.before_scenario
14
- .optional()
15
- .describe("Earlier browser scenario capture; pair with after_scenario."),
16
- after_scenario: compareBrowserScenariosInputSchema.shape.after_scenario
17
- .optional()
18
- .describe("Later browser scenario capture; pair with before_scenario."),
19
- normalization: compareBrowserScenariosInputSchema.shape.normalization.describe("Scenario-only exact-literal normalization policy."),
20
- max_changes: z
21
- .number()
22
- .int()
23
- .min(1)
24
- .max(20_000)
25
- .default(2_000)
26
- .describe("Maximum normalized change records to retain."),
27
- })
28
- .superRefine((input, context) => {
29
- const hasPassive = input.before !== undefined || input.after !== undefined;
30
- const hasScenario = input.before_scenario !== undefined || input.after_scenario !== undefined;
31
- if (hasPassive === hasScenario)
32
- context.addIssue({
33
- code: "custom",
34
- message: "Provide exactly one complete pair: before/after or before_scenario/after_scenario",
35
- });
36
- if (hasPassive && (input.before === undefined || input.after === undefined))
37
- context.addIssue({
38
- code: "custom",
39
- message: "Passive comparison requires both before and after",
40
- });
41
- if (hasScenario &&
42
- (input.before_scenario === undefined ||
43
- input.after_scenario === undefined))
44
- context.addIssue({
45
- code: "custom",
46
- message: "Browser scenario comparison requires both before_scenario and after_scenario",
47
- });
48
- if (hasPassive && input.normalization.rules.length > 0)
49
- context.addIssue({
50
- code: "custom",
51
- path: ["normalization"],
52
- message: "Literal normalization rules apply only to browser scenario captures",
53
- });
54
- });
55
- /** Parsed legacy page snapshots or step-indexed browser scenarios. */
56
- export const browserCaptureComparisonInputSchema = browserCaptureComparisonWireSchema.transform((input) => {
57
- if (input.before_scenario !== undefined &&
58
- input.after_scenario !== undefined)
59
- return {
60
- before_scenario: input.before_scenario,
61
- after_scenario: input.after_scenario,
62
- normalization: input.normalization,
63
- max_changes: input.max_changes,
64
- };
65
- if (input.before !== undefined && input.after !== undefined)
66
- return {
67
- before: input.before,
68
- after: input.after,
69
- max_changes: input.max_changes,
70
- };
71
- throw new TypeError("Capture comparison pair refinement failed");
72
- });
4
+ const maxChangesSchema = z
5
+ .number()
6
+ .int()
7
+ .min(1)
8
+ .max(20_000)
9
+ .default(2_000)
10
+ .describe("Maximum normalized change records to retain.");
11
+ /** Top-level MCP shape for exactly one complete passive or scenario pair. */
12
+ export const browserCaptureComparisonInputSchema = z.union([
13
+ z.strictObject({
14
+ before: captureSnapshotSchema.describe("Earlier passive web-page capture."),
15
+ after: captureSnapshotSchema.describe("Later passive web-page capture."),
16
+ max_changes: maxChangesSchema,
17
+ }),
18
+ z.strictObject({
19
+ before_scenario: compareBrowserScenariosInputSchema.shape.before_scenario.describe("Earlier browser scenario capture."),
20
+ after_scenario: compareBrowserScenariosInputSchema.shape.after_scenario.describe("Later browser scenario capture."),
21
+ normalization: compareBrowserScenariosInputSchema.shape.normalization.describe("Exact-literal normalization policy."),
22
+ max_changes: maxChangesSchema,
23
+ }),
24
+ ]);
73
25
  /** Result from passive page or browser scenario comparison. */
74
26
  export const browserCaptureComparisonSchema = z.union([
75
27
  browserScenarioDiffSchema,
@@ -186,9 +186,7 @@ const DEFAULT_BROWSER_INSPECTION_LIMITS = {
186
186
  max_websocket_shape_bytes: 64 * 1_024,
187
187
  max_total_websocket_shape_bytes: 1_024 * 1_024,
188
188
  };
189
- /** Public input for one passive, bounded inspection of an existing page. */
190
- export const inspectWebPageInputSchema = z
191
- .object({
189
+ const inspectWebPageInputFacts = {
192
190
  ...approvedBrowserInput,
193
191
  target_id: z.string().trim().min(1).max(256),
194
192
  observation_ms: z.number().int().min(0).max(10_000).default(500),
@@ -199,12 +197,21 @@ export const inspectWebPageInputSchema = z
199
197
  json_body_schema_approved: z.boolean().default(false),
200
198
  include_websocket_shapes: z.boolean().default(false),
201
199
  websocket_shape_approved: z.boolean().default(false),
202
- include_script_sources: z.boolean().default(false),
203
200
  include_storage_keys: z.boolean().default(false),
204
201
  include_storage_fingerprints: z.boolean().default(false),
205
202
  limits: browserInspectionLimitsSchema.default(DEFAULT_BROWSER_INSPECTION_LIMITS),
206
- })
207
- .superRefine((input, context) => {
203
+ };
204
+ const inspectWebPageWithoutSourceSchema = z.strictObject({
205
+ ...inspectWebPageInputFacts,
206
+ include_script_sources: z.literal(false).default(false),
207
+ source_capture_approved: z.literal(false).default(false),
208
+ });
209
+ const inspectWebPageWithSourceShapeSchema = z.strictObject({
210
+ ...inspectWebPageInputFacts,
211
+ include_script_sources: z.literal(true).default(true),
212
+ source_capture_approved: z.literal(true),
213
+ });
214
+ const refineInspectWebPageInput = (input, context) => {
208
215
  if (input.include_storage_fingerprints && !input.include_storage_keys)
209
216
  context.addIssue({
210
217
  code: "custom",
@@ -260,14 +267,20 @@ export const inspectWebPageInputSchema = z
260
267
  path: ["limits", "max_websocket_shape_bytes"],
261
268
  message: "Per-frame WebSocket limit cannot exceed the total frame limit",
262
269
  });
263
- if (input.limits.max_ax_text_field_bytes >
264
- input.limits.max_total_ax_text_bytes)
270
+ if (input.limits.max_ax_text_field_bytes > input.limits.max_total_ax_text_bytes)
265
271
  context.addIssue({
266
272
  code: "custom",
267
273
  path: ["limits", "max_ax_text_field_bytes"],
268
274
  message: "Per-field accessibility text limit cannot exceed the total text limit",
269
275
  });
270
- });
276
+ };
277
+ /** Source-capturing inspection input, reusable by static bundle analysis. */
278
+ export const inspectWebPageWithSourceInputSchema = inspectWebPageWithSourceShapeSchema.superRefine(refineInspectWebPageInput);
279
+ /** Public input for one passive, bounded inspection of an existing page. */
280
+ export const inspectWebPageInputSchema = z.union([
281
+ inspectWebPageWithoutSourceSchema.superRefine(refineInspectWebPageInput),
282
+ inspectWebPageWithSourceInputSchema,
283
+ ]);
271
284
  export const sanitizedBrowserUrlSchema = z.object({
272
285
  url: z.string().max(MAX_SANITIZED_BROWSER_URL_CHARS),
273
286
  origin: z.string().max(2_048).nullable(),