rea-agents 1.7.0 → 2.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.
Files changed (156) hide show
  1. package/README.md +38 -31
  2. package/dist/application/CapabilityInventory.js +18 -0
  3. package/dist/application/CrossVersionInvestigation.js +10 -6
  4. package/dist/application/Doctor.js +56 -6
  5. package/dist/application/ElectronBoundaryAnalysis.js +96 -0
  6. package/dist/application/ElectronBoundaryGraph.js +9 -0
  7. package/dist/application/ElectronBoundaryGraphContext.js +62 -0
  8. package/dist/application/ElectronBoundaryGraphIpc.js +242 -0
  9. package/dist/application/ElectronBoundaryGraphNative.js +86 -0
  10. package/dist/application/ElectronBoundaryGraphWindows.js +199 -0
  11. package/dist/application/EnhancedTools.js +38 -13
  12. package/dist/application/InvestigationProviders.js +30 -0
  13. package/dist/application/JavaScriptApplicationEvidence.js +26 -0
  14. package/dist/application/JavaScriptApplicationEvidenceGraph.js +89 -0
  15. package/dist/application/JavaScriptApplicationService.js +74 -0
  16. package/dist/application/JavaScriptApplicationWorkflowEvidence.js +29 -0
  17. package/dist/application/JavaScriptApplicationWorkflowService.js +90 -0
  18. package/dist/application/JavaScriptArtifactAnalysis.js +7 -1
  19. package/dist/application/JavaScriptArtifactGraphBuilder.js +59 -16
  20. package/dist/application/JavaScriptArtifactGraphEvidence.js +24 -14
  21. package/dist/application/JavaScriptArtifactReconstruction.js +3 -0
  22. package/dist/application/JavaScriptArtifactReconstructionInput.js +2 -83
  23. package/dist/application/JavaScriptReplayPlanning.js +201 -0
  24. package/dist/application/JavaScriptReplayService.js +266 -0
  25. package/dist/application/JavaScriptRuntimeReconciliationEvidence.js +25 -0
  26. package/dist/application/JavaScriptRuntimeReconciliationService.js +27 -0
  27. package/dist/application/ManagedApplicationGraphService.js +55 -0
  28. package/dist/application/ManagedMemberComparisonService.js +122 -0
  29. package/dist/application/ManagedNativeVerificationService.js +39 -0
  30. package/dist/application/ManagedReconstructionService.js +58 -0
  31. package/dist/application/ManagedRuntimeCorrelationService.js +103 -0
  32. package/dist/application/PermissionAuthority.js +1 -1
  33. package/dist/application/ProcessSampling.js +15 -11
  34. package/dist/application/ProjectPermissionStore.js +1 -0
  35. package/dist/application/runtime.js +2 -0
  36. package/dist/browser/CdpCaptureEvents.js +49 -0
  37. package/dist/browser/CdpElectronInspection.js +106 -162
  38. package/dist/browser/CdpElectronProvider.js +5 -1
  39. package/dist/browser/CdpElectronScriptEvents.js +69 -0
  40. package/dist/browser/CdpElectronScripts.js +94 -0
  41. package/dist/browser/CdpElectronWorkers.js +56 -0
  42. package/dist/browser/CdpPageCapture.js +8 -4
  43. package/dist/catalogIdentity.js +4 -1
  44. package/dist/cli.js +388 -0
  45. package/dist/cliApplicationCommands.js +62 -0
  46. package/dist/cliCommandNames.js +13 -0
  47. package/dist/cliElectronCommands.js +103 -1
  48. package/dist/cliJsonInput.js +54 -0
  49. package/dist/config.js +83 -0
  50. package/dist/contracts/applicationToolContracts.js +91 -0
  51. package/dist/contracts/artifactToolContracts.js +5 -9
  52. package/dist/contracts/browserToolContracts.js +14 -62
  53. package/dist/contracts/electronToolContracts.js +45 -19
  54. package/dist/contracts/errorSchemas.js +1 -0
  55. package/dist/contracts/investigationExamples.js +0 -6
  56. package/dist/contracts/javascriptApplicationWorkflowExamples.js +46 -0
  57. package/dist/contracts/javascriptRuntimeReconciliationExample.js +208 -0
  58. package/dist/contracts/managedToolContracts.js +153 -0
  59. package/dist/contracts/managedWorkflowExamples.js +346 -0
  60. package/dist/contracts/managedWorkflowToolContracts.js +203 -0
  61. package/dist/contracts/nativeToolContracts.js +2 -6
  62. package/dist/contracts/promptContracts.js +18 -2
  63. package/dist/contracts/toolContractExamples.js +10 -25
  64. package/dist/contracts/toolContracts.js +47 -45
  65. package/dist/contracts/toolEffects.js +160 -0
  66. package/dist/contracts/toolOutputSchemas.js +46 -31
  67. package/dist/doctorRuntime.js +42 -1
  68. package/dist/domain/artifactComparison.js +3 -4
  69. package/dist/domain/browserObservation.js +3 -0
  70. package/dist/domain/bundleComparison.js +4 -4
  71. package/dist/domain/electronObservation.js +13 -0
  72. package/dist/domain/electronStaticAnalysis.js +9 -0
  73. package/dist/domain/electronStaticAnalysisBrowser.js +194 -0
  74. package/dist/domain/electronStaticAnalysisIpc.js +171 -0
  75. package/dist/domain/electronStaticAnalysisNative.js +164 -0
  76. package/dist/domain/electronStaticAnalysisTypes.js +1 -0
  77. package/dist/domain/electronStaticAnalysisValues.js +103 -0
  78. package/dist/domain/errors.js +67 -1
  79. package/dist/domain/functionComparisonSchemas.js +3 -8
  80. package/dist/domain/inputIssueProjection.js +52 -0
  81. package/dist/domain/javascriptApplicationAnalysis.js +155 -0
  82. package/dist/domain/javascriptApplicationChangeGraph.js +231 -0
  83. package/dist/domain/javascriptApplicationEvidenceSchemas.js +18 -0
  84. package/dist/domain/javascriptApplicationGraph.js +2 -1
  85. package/dist/domain/javascriptApplicationGraphSchemas.js +7 -0
  86. package/dist/domain/javascriptApplicationVersionComparison.js +116 -0
  87. package/dist/domain/javascriptApplicationVersionComparisonSchemas.js +139 -0
  88. package/dist/domain/javascriptApplicationVersionItems.js +221 -0
  89. package/dist/domain/javascriptApplicationVersionKeys.js +170 -0
  90. package/dist/domain/javascriptFeatureSeed.js +140 -0
  91. package/dist/domain/javascriptFeatureTrace.js +232 -0
  92. package/dist/domain/javascriptFeatureTraceSchemas.js +136 -0
  93. package/dist/domain/javascriptFeatureTraversal.js +88 -0
  94. package/dist/domain/javascriptNativeHandoff.js +85 -0
  95. package/dist/domain/javascriptReplay.js +361 -0
  96. package/dist/domain/javascriptRuntimeLoadState.js +106 -0
  97. package/dist/domain/javascriptRuntimeReconciliation.js +42 -0
  98. package/dist/domain/javascriptRuntimeReconciliationGraph.js +169 -0
  99. package/dist/domain/javascriptRuntimeReconciliationMatching.js +247 -0
  100. package/dist/domain/javascriptRuntimeReconciliationParsing.js +160 -0
  101. package/dist/domain/javascriptRuntimeReconciliationResult.js +119 -0
  102. package/dist/domain/javascriptRuntimeReconciliationRuntime.js +316 -0
  103. package/dist/domain/javascriptRuntimeReconciliationSchemas.js +245 -0
  104. package/dist/domain/javascriptRuntimeStaticCandidates.js +191 -0
  105. package/dist/domain/javascriptStaticAnalysis.js +31 -43
  106. package/dist/domain/javascriptStaticAnalysisFindings.js +39 -0
  107. package/dist/domain/javascriptStaticAnalysisHelpers.js +10 -0
  108. package/dist/domain/javascriptStaticAnalysisState.js +6 -0
  109. package/dist/domain/managedApplicationGraph.js +556 -0
  110. package/dist/domain/managedArtifact.js +444 -0
  111. package/dist/domain/managedMemberComparison.js +565 -0
  112. package/dist/domain/managedNativeVerification.js +408 -0
  113. package/dist/domain/managedReconstruction.js +183 -0
  114. package/dist/domain/managedRuntimeCorrelation.js +175 -0
  115. package/dist/domain/reconstructionVerificationSchemas.js +1 -3
  116. package/dist/dotnet/ManagedArtifactInspector.js +318 -0
  117. package/dist/dotnet/ManagedMemberInspector.js +887 -0
  118. package/dist/dotnet/ManagedMetadataHeaps.js +131 -0
  119. package/dist/dotnet/ManagedMetadataInventory.js +368 -0
  120. package/dist/dotnet/ManagedMetadataLayout.js +322 -0
  121. package/dist/dotnet/ManagedNativeBoundaryInspector.js +391 -0
  122. package/dist/dotnet/ManagedPeReader.js +157 -0
  123. package/dist/dotnet/ManagedReaderFailure.js +10 -0
  124. package/dist/dotnet/ManagedStaticProvider.js +203 -0
  125. package/dist/generatedPackageMetadata.js +2 -2
  126. package/dist/ghidra/GhidraProvider.js +6 -0
  127. package/dist/main.js +14 -0
  128. package/dist/replay/JavaScriptReplayWorker.js +286 -0
  129. package/dist/replay/LinuxJavaScriptReplayRunner.js +434 -0
  130. package/dist/replay/LinuxRuntimeClosure.js +46 -0
  131. package/dist/replay/LinuxSeccompPolicy.js +40 -0
  132. package/dist/replay/ReplayWorkerProtocol.js +55 -0
  133. package/dist/replay/SystemJavaScriptReplayHost.js +182 -0
  134. package/dist/server/createServer.js +52 -0
  135. package/dist/server/registerApplicationTools.js +115 -0
  136. package/dist/server/registerArtifactComparisonTool.js +16 -9
  137. package/dist/server/registerBrowserTools.js +33 -8
  138. package/dist/server/registerBundleComparisonTool.js +17 -20
  139. package/dist/server/registerElectronTools.js +45 -3
  140. package/dist/server/registerEnhancedTools.js +58 -13
  141. package/dist/server/registerEvidenceTools.js +5 -1
  142. package/dist/server/registerFunctionComparisonTool.js +14 -7
  143. package/dist/server/registerInvestigationTools.js +21 -17
  144. package/dist/server/registerManagedTools.js +6 -0
  145. package/dist/server/registerManagedWorkflowTools.js +277 -0
  146. package/dist/server/registerOfficialTools.js +8 -8
  147. package/dist/server/registerProcessComparisonTool.js +25 -47
  148. package/dist/server/registerSessionStatusTool.js +7 -7
  149. package/dist/server/registerSessionTools.js +51 -86
  150. package/dist/server/sessionEvidence.js +14 -19
  151. package/dist/server/toolInputValidation.js +77 -0
  152. package/dist/server/toolRegistrationOptions.js +79 -2
  153. package/dist/server/toolResult.js +25 -17
  154. package/package.json +12 -4
  155. package/scripts/rea.mjs +1 -1
  156. package/skills/rea-analysis/SKILL.md +59 -3
@@ -0,0 +1,208 @@
1
+ import { createEvidence } from "../domain/evidence.js";
2
+ import { createJavaScriptApplicationGraph, createJavaScriptApplicationNode, } from "../domain/javascriptApplicationGraph.js";
3
+ import { createWebTextArtifact } from "../domain/webContentArtifact.js";
4
+ const applicationSha256 = "1".repeat(64);
5
+ const script = createWebTextArtifact("export const example = true;\n", "text/javascript");
6
+ const inputPath = "/Applications/Example.app/Contents/Resources/app";
7
+ const scriptPath = `${inputPath}/renderer.js`;
8
+ const completeCoverage = {
9
+ status: "complete",
10
+ truncated: false,
11
+ omitted_count: 0,
12
+ limits: [],
13
+ };
14
+ const graphEvidence = {
15
+ authority: "artifact-bytes",
16
+ state: "observed",
17
+ confidence: "exact",
18
+ artifact: {
19
+ available: true,
20
+ artifact_id: `art_${script.sha256}`,
21
+ sha256: script.sha256,
22
+ },
23
+ location: {
24
+ available: true,
25
+ value: { kind: "artifact-path", path: "renderer.js" },
26
+ },
27
+ extractor: {
28
+ name: "rea-javascript-application",
29
+ version: "1",
30
+ operation: "inventory-relevant-file",
31
+ executable_sha256: null,
32
+ },
33
+ coverage: completeCoverage,
34
+ limitations: [],
35
+ evidence_ids: [],
36
+ };
37
+ const asset = createJavaScriptApplicationNode({
38
+ kind: "javascript-asset",
39
+ identity: {
40
+ strategy: "content-digest",
41
+ stability: "global-exact",
42
+ sha256: script.sha256,
43
+ },
44
+ observations: [
45
+ {
46
+ label: "renderer.js",
47
+ properties: { path: "renderer.js", bytes: script.bytes },
48
+ evidence: graphEvidence,
49
+ },
50
+ ],
51
+ });
52
+ const graph = createJavaScriptApplicationGraph({
53
+ schema: "JavaScriptApplicationGraph",
54
+ schema_version: 1,
55
+ root_node_ids: [asset.node_id],
56
+ nodes: [asset],
57
+ edges: [],
58
+ coverage: completeCoverage,
59
+ limitations: [],
60
+ });
61
+ const staticEvidence = createEvidence({ path: inputPath, sha256: applicationSha256, format: "directory" }, {
62
+ id: "rea-javascript-application",
63
+ name: "REA JavaScript application analyzer",
64
+ version: "1",
65
+ }, {
66
+ predicateType: "rea.javascript-application-analysis/v1",
67
+ operation: "analyze_javascript_application",
68
+ parameters: { approved: true, source_map_read_approved: false },
69
+ result: {
70
+ schema_version: 1,
71
+ input_path: inputPath,
72
+ format: "directory",
73
+ root_artifact_sha256: applicationSha256,
74
+ inventory_manifest_id: `agm_${"2".repeat(64)}`,
75
+ inventory_graph_sha256: "3".repeat(64),
76
+ graph,
77
+ summary: {
78
+ browser_windows: 0,
79
+ explicit_web_preferences: 0,
80
+ preload_entrypoints: 0,
81
+ context_bridge_apis: 0,
82
+ exposed_api_members: 0,
83
+ ipc: {
84
+ operations: 0,
85
+ literal_channels: 0,
86
+ dynamic_channel_operations: 0,
87
+ renderer_transmissions: 0,
88
+ renderer_listeners: 0,
89
+ main_handlers: 0,
90
+ paired_renderer_transmissions: 0,
91
+ ambiguous_renderer_transmissions: 0,
92
+ unpaired_literal_renderer_transmissions: 0,
93
+ },
94
+ sender_validation_observations: 0,
95
+ utility_processes: 0,
96
+ resolved_utility_entrypoints: 0,
97
+ native_addon_bindings: 0,
98
+ resolved_native_addon_bindings: 0,
99
+ },
100
+ statistics: {
101
+ relevant_files: 1,
102
+ nested_asar_containers: 0,
103
+ text_files_selected: 1,
104
+ text_bytes_read: script.bytes,
105
+ omitted_text_files: 0,
106
+ limit_omitted_text_files: 0,
107
+ policy_filtered_text_files: 0,
108
+ invalid_utf8_files: 0,
109
+ parsed_javascript_files: 1,
110
+ visited_ast_nodes: 1,
111
+ findings: 0,
112
+ modules: 0,
113
+ parse_failures: 0,
114
+ truncated_scopes: 0,
115
+ },
116
+ limitations: [],
117
+ },
118
+ confidence: "derived",
119
+ authority: "shipped-artifact",
120
+ });
121
+ /** Minimal valid static application Evidence for graph workflow examples. */
122
+ export const JAVASCRIPT_APPLICATION_EVIDENCE_EXAMPLE = staticEvidence;
123
+ const runtimeEvidence = createEvidence(undefined, {
124
+ id: "rea-cdp-electron",
125
+ name: "REA Electron file-page CDP observation provider",
126
+ version: "1",
127
+ }, {
128
+ predicateType: "rea.electron-page-inspection/v1",
129
+ operation: "inspect_electron_page",
130
+ parameters: {
131
+ cdp_endpoint: "http://127.0.0.1:9223",
132
+ allowed_file_roots: [inputPath],
133
+ target_id: "example-target",
134
+ include_script_sources: true,
135
+ source_capture_approved: true,
136
+ },
137
+ result: {
138
+ schema_version: 1,
139
+ browser: {
140
+ product: "Electron/example",
141
+ protocol_version: "1.3",
142
+ revision: "example",
143
+ user_agent: "Electron example",
144
+ js_version: "1",
145
+ },
146
+ target: {
147
+ target_id: "example-target",
148
+ type: "page",
149
+ title: "Example",
150
+ file_path: `${inputPath}/index.html`,
151
+ attached: false,
152
+ },
153
+ capture_window: {
154
+ started_at: "2026-07-15T00:00:00.000Z",
155
+ ended_at: "2026-07-15T00:00:00.100Z",
156
+ observation_ms: 100,
157
+ },
158
+ completeness: browserCompleteness(),
159
+ frames: [],
160
+ dom: { total_nodes: 0, nodes: [] },
161
+ scripts: {
162
+ total: 1,
163
+ items: [
164
+ {
165
+ script_key: `electron_script_${"4".repeat(64)}`,
166
+ frame_id: null,
167
+ file_path: scriptPath,
168
+ cdp_hash: "example",
169
+ length: script.bytes,
170
+ is_module: true,
171
+ language: "JavaScript",
172
+ source: { included: true, artifact: script },
173
+ },
174
+ ],
175
+ },
176
+ resources: [],
177
+ workers: [],
178
+ limitations: ["Example passive capture."],
179
+ },
180
+ confidence: "observed",
181
+ authority: "external-service",
182
+ });
183
+ /** Compact valid Evidence pair used by the public reconciliation contract. */
184
+ export const JAVASCRIPT_RUNTIME_RECONCILIATION_EXAMPLE = {
185
+ static_layers: [{ role: "application", analysis: staticEvidence }],
186
+ runtime_observations: [runtimeEvidence],
187
+ };
188
+ function browserCompleteness() {
189
+ return {
190
+ status: "complete_within_window",
191
+ conditions: ["complete_within_window"],
192
+ policy_filtered_sections: [],
193
+ attach_limited_sections: [],
194
+ truncated_sections: [],
195
+ unavailable_sections: [],
196
+ excluded: [],
197
+ dropped_events: {
198
+ scripts: 0,
199
+ network_requests: 0,
200
+ console_events: 0,
201
+ websocket_connections: 0,
202
+ websocket_frames: 0,
203
+ webmcp_tools: 0,
204
+ timeline_events: 0,
205
+ total: 0,
206
+ },
207
+ };
208
+ }
@@ -0,0 +1,153 @@
1
+ import { z } from "zod";
2
+ import { managedOutputSchemas } from "./toolOutputSchemas.js";
3
+ import { toolContractMetadata } from "./toolEffects.js";
4
+ /** Exact caller boundary for execution-free PE/CLI triage and identity. */
5
+ export const managedArtifactInputSchema = z.object({
6
+ reference_offset: z.number().int().min(0).default(0),
7
+ reference_limit: z.number().int().min(1).max(500).default(100),
8
+ resource_offset: z.number().int().min(0).default(0),
9
+ resource_limit: z.number().int().min(1).max(500).default(100),
10
+ attribute_offset: z.number().int().min(0).default(0),
11
+ attribute_limit: z.number().int().min(1).max(500).default(100),
12
+ max_file_bytes: z
13
+ .number()
14
+ .int()
15
+ .min(4_096)
16
+ .max(1_073_741_824)
17
+ .default(268_435_456),
18
+ max_metadata_bytes: z
19
+ .number()
20
+ .int()
21
+ .min(256)
22
+ .max(268_435_456)
23
+ .default(67_108_864),
24
+ max_table_rows: z.number().int().min(1).max(1_000_000).default(100_000),
25
+ max_heap_item_bytes: z
26
+ .number()
27
+ .int()
28
+ .min(1)
29
+ .max(16_777_216)
30
+ .default(1_048_576),
31
+ });
32
+ /** Exact caller boundary for execution-free metadata/signature/IL inspection. */
33
+ export const managedMemberInputSchema = z.object({
34
+ type_offset: z.number().int().min(0).default(0),
35
+ type_limit: z.number().int().min(1).max(500).default(100),
36
+ method_offset: z.number().int().min(0).default(0),
37
+ method_limit: z.number().int().min(1).max(500).default(100),
38
+ field_offset: z.number().int().min(0).default(0),
39
+ field_limit: z.number().int().min(1).max(500).default(100),
40
+ member_ref_offset: z.number().int().min(0).default(0),
41
+ member_ref_limit: z.number().int().min(1).max(500).default(100),
42
+ edge_offset: z.number().int().min(0).default(0),
43
+ edge_limit: z.number().int().min(1).max(1_000).default(250),
44
+ instruction_anchor_limit: z.number().int().min(0).max(500).default(100),
45
+ max_file_bytes: z
46
+ .number()
47
+ .int()
48
+ .min(4_096)
49
+ .max(1_073_741_824)
50
+ .default(268_435_456),
51
+ max_metadata_bytes: z
52
+ .number()
53
+ .int()
54
+ .min(256)
55
+ .max(268_435_456)
56
+ .default(67_108_864),
57
+ max_table_rows: z.number().int().min(1).max(1_000_000).default(100_000),
58
+ max_heap_item_bytes: z
59
+ .number()
60
+ .int()
61
+ .min(1)
62
+ .max(16_777_216)
63
+ .default(1_048_576),
64
+ max_method_body_bytes: z
65
+ .number()
66
+ .int()
67
+ .min(1)
68
+ .max(16_777_216)
69
+ .default(1_048_576),
70
+ max_method_instructions: z.number().int().min(1).max(100_000).default(10_000),
71
+ });
72
+ /** Exact caller boundary for execution-free managed/native boundary inspection. */
73
+ export const managedNativeBoundaryInputSchema = z.object({
74
+ module_ref_offset: z.number().int().min(0).default(0),
75
+ module_ref_limit: z.number().int().min(1).max(500).default(100),
76
+ import_offset: z.number().int().min(0).default(0),
77
+ import_limit: z.number().int().min(1).max(500).default(100),
78
+ implementation_offset: z.number().int().min(0).default(0),
79
+ implementation_limit: z.number().int().min(1).max(500).default(100),
80
+ max_file_bytes: z
81
+ .number()
82
+ .int()
83
+ .min(4_096)
84
+ .max(1_073_741_824)
85
+ .default(268_435_456),
86
+ max_metadata_bytes: z
87
+ .number()
88
+ .int()
89
+ .min(256)
90
+ .max(268_435_456)
91
+ .default(67_108_864),
92
+ max_table_rows: z.number().int().min(1).max(1_000_000).default(100_000),
93
+ max_heap_item_bytes: z
94
+ .number()
95
+ .int()
96
+ .min(1)
97
+ .max(16_777_216)
98
+ .default(1_048_576),
99
+ });
100
+ const outputSchema = managedOutputSchemas.inspect_managed_artifact;
101
+ if (outputSchema === undefined)
102
+ throw new Error("Missing managed output schema for inspect_managed_artifact");
103
+ const memberOutputSchema = managedOutputSchemas.inspect_managed_members;
104
+ if (memberOutputSchema === undefined)
105
+ throw new Error("Missing managed output schema for inspect_managed_members");
106
+ const nativeBoundaryOutputSchema = managedOutputSchemas.inspect_managed_native_boundaries;
107
+ if (nativeBoundaryOutputSchema === undefined)
108
+ throw new Error("Missing managed output schema for inspect_managed_native_boundaries");
109
+ /** Read-only managed artifact contracts. */
110
+ export const MANAGED_TOOL_CONTRACTS = [
111
+ {
112
+ name: "inspect_managed_artifact",
113
+ ...toolContractMetadata("inspect_managed_artifact"),
114
+ description: "Classify the active PE/CLI artifact and inventory exact assembly/module identity, target framework evidence, references, resources, and custom attributes without loading or executing target code. Returns bounded pages and explicit partial or malformed coverage.",
115
+ kind: "managed-provider",
116
+ inputSchema: managedArtifactInputSchema,
117
+ outputSchema,
118
+ examples: [
119
+ {
120
+ title: "Example inspect managed artifact request",
121
+ input: {},
122
+ },
123
+ ],
124
+ },
125
+ {
126
+ name: "inspect_managed_members",
127
+ ...toolContractMetadata("inspect_managed_members"),
128
+ description: "Inspect bounded PE/CLI metadata members, signatures, method body IL hashes, exception regions, call edges, and field-access anchors without loading or executing target code. Metadata tokens are reported as build-local coordinates bound to the artifact SHA-256 and MVID.",
129
+ kind: "managed-provider",
130
+ inputSchema: managedMemberInputSchema,
131
+ outputSchema: memberOutputSchema,
132
+ examples: [
133
+ {
134
+ title: "Example inspect managed members request",
135
+ input: { method_limit: 25, edge_limit: 100 },
136
+ },
137
+ ],
138
+ },
139
+ {
140
+ name: "inspect_managed_native_boundaries",
141
+ ...toolContractMetadata("inspect_managed_native_boundaries"),
142
+ description: "Inspect PE/CLI ModuleRef, ImplMap/PInvoke declarations, CLI native-header indicators, and non-IL method implementation flags without loading or executing target code. Results are managed declarations and degraded native-boundary observations, not verified native exports or addresses.",
143
+ kind: "managed-provider",
144
+ inputSchema: managedNativeBoundaryInputSchema,
145
+ outputSchema: nativeBoundaryOutputSchema,
146
+ examples: [
147
+ {
148
+ title: "Example inspect managed/native boundary request",
149
+ input: { import_limit: 50, implementation_limit: 50 },
150
+ },
151
+ ],
152
+ },
153
+ ];
@@ -0,0 +1,346 @@
1
+ import { createEvidence } from "../domain/evidence.js";
2
+ const MANAGED_STATIC_EXAMPLE_PROVIDER = {
3
+ id: "rea-dotnet-static",
4
+ name: "REA managed static analysis provider",
5
+ version: "1",
6
+ };
7
+ const NATIVE_EXAMPLE_PROVIDER = {
8
+ id: "native-macos",
9
+ name: "REA native macOS provider",
10
+ version: "1",
11
+ };
12
+ const emptyManagedMembers = (sha256, mvid) => ({
13
+ schema_version: 1,
14
+ artifact: {
15
+ path: `/examples/${sha256.slice(0, 8)}.dll`,
16
+ sha256,
17
+ byte_length: 4096,
18
+ format: "pe",
19
+ },
20
+ module: {
21
+ name: "Example.dll",
22
+ generation: 0,
23
+ mvid,
24
+ enc_id: null,
25
+ enc_base_id: null,
26
+ token: "0x00000001",
27
+ row_offset: 0,
28
+ },
29
+ metadata: {
30
+ status: "complete",
31
+ version: "v4.0.30319",
32
+ table_row_counts: {},
33
+ },
34
+ identity_scope: {
35
+ token_identity: "build-local",
36
+ requires_artifact_sha256: sha256,
37
+ requires_mvid: mvid,
38
+ },
39
+ types: emptyPage(100),
40
+ fields: emptyPage(100),
41
+ methods: emptyPage(100),
42
+ member_refs: emptyPage(100),
43
+ call_edges: emptyPage(250),
44
+ field_accesses: emptyPage(250),
45
+ coverage: { state: "complete", issues: [] },
46
+ limitations: [],
47
+ });
48
+ const emptyPage = (limit) => ({
49
+ items: [],
50
+ offset: 0,
51
+ limit,
52
+ total: 0,
53
+ returned: 0,
54
+ dropped: 0,
55
+ complete: true,
56
+ });
57
+ const evidence = (result) => createEvidence(undefined, MANAGED_STATIC_EXAMPLE_PROVIDER, {
58
+ operation: "inspect_managed_members",
59
+ parameters: {},
60
+ result,
61
+ rawResult: null,
62
+ limitations: result.limitations,
63
+ });
64
+ const runtimeMembers = () => {
65
+ const result = emptyManagedMembers("2".repeat(64), "11112222-3333-4444-9555-666677778888");
66
+ return {
67
+ ...result,
68
+ methods: {
69
+ ...result.methods,
70
+ items: [
71
+ {
72
+ token: "0x06000001",
73
+ row_offset: 128,
74
+ declaring_type_token: "0x02000001",
75
+ declaring_type: "Example.Program",
76
+ name: "Main",
77
+ rva: 8192,
78
+ impl_flags: 0,
79
+ flags: 22,
80
+ signature: {
81
+ raw_length: 3,
82
+ raw_sha256: "3".repeat(64),
83
+ kind: "method",
84
+ parse_status: "decoded",
85
+ calling_convention: "default",
86
+ generic_parameter_count: 0,
87
+ parameter_count: 0,
88
+ return_type: "void",
89
+ parameter_types: [],
90
+ field_type: null,
91
+ issue: null,
92
+ },
93
+ body: {
94
+ status: "present",
95
+ header_format: "tiny",
96
+ rva: 8192,
97
+ file_offset: 512,
98
+ max_stack: 8,
99
+ init_locals: false,
100
+ local_var_sig_token: null,
101
+ il_size: 1,
102
+ il_sha256: "4".repeat(64),
103
+ normalized_il_sha256: "5".repeat(64),
104
+ instruction_count: 1,
105
+ decoded_instruction_count: 1,
106
+ truncated_instructions: 0,
107
+ opcode_counts: { ret: 1 },
108
+ anchors: [],
109
+ exception_regions: [],
110
+ issue: null,
111
+ },
112
+ },
113
+ ],
114
+ total: 1,
115
+ returned: 1,
116
+ },
117
+ };
118
+ };
119
+ /** Minimal valid managed member comparison request for public contracts. */
120
+ export const MANAGED_MEMBER_COMPARISON_EXAMPLE = {
121
+ left: evidence(emptyManagedMembers("0".repeat(64), "00112233-4455-6677-8899-aabbccddeeff")),
122
+ right: evidence(emptyManagedMembers("1".repeat(64), "ffeeddcc-bbaa-4988-9766-554433221100")),
123
+ limits: {
124
+ max_method_matches: 100,
125
+ max_field_matches: 50,
126
+ max_candidates: 25,
127
+ },
128
+ };
129
+ const runtimeExampleEvidence = evidence(runtimeMembers());
130
+ /** Minimal valid managed application graph projection request. */
131
+ export const MANAGED_APPLICATION_GRAPH_EXAMPLE = {
132
+ managed_members: runtimeExampleEvidence,
133
+ limits: {
134
+ max_types: 100,
135
+ max_methods: 100,
136
+ max_fields: 100,
137
+ max_pinvoke_imports: 100,
138
+ max_native_implementations: 100,
139
+ },
140
+ };
141
+ const boundaryEvidence = () => {
142
+ const result = {
143
+ schema_version: 1,
144
+ artifact: {
145
+ path: "/examples/ManagedInterop.exe",
146
+ sha256: "6".repeat(64),
147
+ byte_length: 8192,
148
+ format: "pe",
149
+ },
150
+ module: {
151
+ name: "ManagedInterop.exe",
152
+ generation: 0,
153
+ mvid: "00112233-4455-4677-8899-aabbccddeeff",
154
+ enc_id: null,
155
+ enc_base_id: null,
156
+ token: "0x00000001",
157
+ row_offset: 0,
158
+ },
159
+ metadata: {
160
+ status: "complete",
161
+ version: "v4.0.30319",
162
+ table_row_counts: {},
163
+ },
164
+ identity_scope: {
165
+ token_identity: "build-local",
166
+ requires_artifact_sha256: "6".repeat(64),
167
+ requires_mvid: "00112233-4455-4677-8899-aabbccddeeff",
168
+ },
169
+ cli_native: {
170
+ il_only: true,
171
+ requires_32bit: false,
172
+ strong_name_signed: false,
173
+ native_entry_point: false,
174
+ ready_to_run_signature: false,
175
+ managed_native_header_rva: 0,
176
+ managed_native_header_size: 0,
177
+ },
178
+ module_refs: {
179
+ items: [
180
+ {
181
+ token: "0x1a000001",
182
+ row_offset: 256,
183
+ name: "nativehelper.dll",
184
+ },
185
+ ],
186
+ offset: 0,
187
+ limit: 100,
188
+ total: 1,
189
+ returned: 1,
190
+ dropped: 0,
191
+ complete: true,
192
+ },
193
+ pinvoke_imports: {
194
+ items: [
195
+ {
196
+ token: "0x1c000001",
197
+ row_offset: 288,
198
+ mapping_flags: 0,
199
+ mapping_flags_hex: "0x0000",
200
+ member_token: "0x06000001",
201
+ member_kind: "method",
202
+ member_name: "OpenNative",
203
+ import_name: "open_native",
204
+ import_scope_token: "0x1a000001",
205
+ import_scope_name: "nativehelper.dll",
206
+ no_mangle: true,
207
+ char_set: "not-specified",
208
+ call_convention: "cdecl",
209
+ supports_last_error: false,
210
+ best_fit: "assembly-default",
211
+ throw_on_unmappable_char: "assembly-default",
212
+ verification: "managed-declaration-only",
213
+ },
214
+ ],
215
+ offset: 0,
216
+ limit: 100,
217
+ total: 1,
218
+ returned: 1,
219
+ dropped: 0,
220
+ complete: true,
221
+ },
222
+ native_implementations: emptyPage(100),
223
+ summary: {
224
+ module_ref_count: 1,
225
+ pinvoke_import_count: 1,
226
+ native_implementation_count: 0,
227
+ ready_to_run: false,
228
+ mixed_mode_or_native_header: false,
229
+ },
230
+ coverage: { state: "complete", issues: [] },
231
+ limitations: [],
232
+ };
233
+ return createEvidence(undefined, MANAGED_STATIC_EXAMPLE_PROVIDER, {
234
+ operation: "inspect_managed_native_boundaries",
235
+ parameters: {},
236
+ result,
237
+ rawResult: null,
238
+ limitations: result.limitations,
239
+ });
240
+ };
241
+ const nativeExportEvidence = () => {
242
+ const result = {
243
+ format: "mach-o",
244
+ endian: "little",
245
+ word_size: 64,
246
+ file_type: "dylib",
247
+ flags: [],
248
+ uuid: null,
249
+ entrypoints: coverage([]),
250
+ architectures: coverage([]),
251
+ build_metadata: coverage([]),
252
+ load_commands: coverage([]),
253
+ dependencies: coverage([]),
254
+ imports: coverage([]),
255
+ exports: coverage([
256
+ {
257
+ name: "open_native",
258
+ address: "0x1000",
259
+ weak: false,
260
+ reexport: false,
261
+ source: "nm",
262
+ },
263
+ ]),
264
+ segments: coverage([]),
265
+ provenance: [],
266
+ limitations: [],
267
+ };
268
+ return createEvidence({
269
+ path: "/examples/nativehelper.dll",
270
+ sha256: "7".repeat(64),
271
+ format: "mach-o",
272
+ architecture: "x86_64",
273
+ }, NATIVE_EXAMPLE_PROVIDER, {
274
+ operation: "inspect_macho",
275
+ parameters: {},
276
+ result,
277
+ rawResult: null,
278
+ limitations: result.limitations,
279
+ });
280
+ };
281
+ const coverage = (items) => ({
282
+ items: [...items],
283
+ total: items.length,
284
+ exhaustive: true,
285
+ limitations: [],
286
+ });
287
+ /** Minimal valid managed decompiler reconstruction import request. */
288
+ export const MANAGED_RECONSTRUCTION_IMPORT_EXAMPLE = {
289
+ static_members: runtimeExampleEvidence,
290
+ decompiler: {
291
+ name: "ilspycmd",
292
+ version: "9.1.0.7988",
293
+ family: "ilspy",
294
+ executable_sha256: null,
295
+ options: ["--disable-updatecheck", "--type", "Example.Program"],
296
+ },
297
+ methods: [
298
+ {
299
+ token: "0x06000001",
300
+ signature_sha256: "3".repeat(64),
301
+ normalized_il_sha256: "5".repeat(64),
302
+ reconstruction: {
303
+ kind: "decompiled-csharp",
304
+ language: "csharp",
305
+ text: "internal static void Main() { }",
306
+ source_path: "/examples/Example.Program.cs",
307
+ start_line: 1,
308
+ end_line: 1,
309
+ },
310
+ },
311
+ ],
312
+ notes: [
313
+ "Synthetic example only; decompiler output is imported as inference.",
314
+ ],
315
+ };
316
+ /** Minimal valid managed/native verification request. */
317
+ export const MANAGED_NATIVE_VERIFICATION_EXAMPLE = {
318
+ managed_boundaries: boundaryEvidence(),
319
+ native_observations: [nativeExportEvidence()],
320
+ limits: {
321
+ max_native_observations: 20,
322
+ max_candidates_per_import: 25,
323
+ },
324
+ };
325
+ /** Minimal valid managed runtime-correlation planning request. */
326
+ export const MANAGED_RUNTIME_CORRELATION_EXAMPLE = {
327
+ static_members: runtimeExampleEvidence,
328
+ method: {
329
+ token: "0x06000001",
330
+ signature_sha256: "3".repeat(64),
331
+ normalized_il_sha256: "5".repeat(64),
332
+ },
333
+ requested_effect: "attach",
334
+ host: {
335
+ os: "linux",
336
+ clr_family: "dotnet",
337
+ architecture: "x86_64",
338
+ },
339
+ bounds: {
340
+ timeout_ms: 5_000,
341
+ max_threads: 32,
342
+ max_output_bytes: 65_536,
343
+ allow_network: false,
344
+ allow_ui: false,
345
+ },
346
+ };