@eyeauras/insight-cli 0.8.4 → 0.9.1

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 (609) hide show
  1. package/.cli-package-build.json +1 -1
  2. package/README.md +16 -23
  3. package/SKILL.md +6 -44
  4. package/dist/src/activity-audit.d.ts +33 -46
  5. package/dist/src/activity-audit.js +120 -195
  6. package/dist/src/analysis-default.d.ts +10 -2
  7. package/dist/src/analysis-default.js +62 -47
  8. package/dist/src/analysis-storage.d.ts +13 -13
  9. package/dist/src/analysis-storage.js +127 -258
  10. package/dist/src/artifacts.d.ts +5 -1
  11. package/dist/src/artifacts.js +31 -46
  12. package/dist/src/audit-commands.d.ts +6 -1
  13. package/dist/src/audit-commands.js +9 -2
  14. package/dist/src/audit-retention.d.ts +5 -23
  15. package/dist/src/audit-retention.js +37 -150
  16. package/dist/src/binary.js +4 -13
  17. package/dist/src/budgets.d.ts +2 -2
  18. package/dist/src/budgets.js +7 -9
  19. package/dist/src/capture.js +17 -30
  20. package/dist/src/cli.d.ts +9 -4
  21. package/dist/src/cli.js +288 -473
  22. package/dist/src/code-references.d.ts +2 -13
  23. package/dist/src/code-references.js +7 -99
  24. package/dist/src/context-diagnostics.d.ts +1 -23
  25. package/dist/src/context-diagnostics.js +1 -83
  26. package/dist/src/core/coordinator.d.ts +298 -0
  27. package/dist/src/core/coordinator.js +591 -0
  28. package/dist/src/core/layout.d.ts +51 -0
  29. package/dist/src/core/layout.js +55 -0
  30. package/dist/src/core/legacy-import.d.ts +55 -0
  31. package/dist/src/core/legacy-import.js +193 -0
  32. package/dist/src/cross-results.d.ts +3 -3
  33. package/dist/src/cross-results.js +4 -42
  34. package/dist/src/cross.js +2 -3
  35. package/dist/src/debugger-results.d.ts +1 -6
  36. package/dist/src/debugger-results.js +21 -153
  37. package/dist/src/debugger.d.ts +21 -11
  38. package/dist/src/debugger.js +106 -168
  39. package/dist/src/decode-results.d.ts +2 -1
  40. package/dist/src/decode-results.js +4 -20
  41. package/dist/src/diagnostic-error.d.ts +1 -1
  42. package/dist/src/diagnostic-error.js +4 -23
  43. package/dist/src/die.js +1 -23
  44. package/dist/src/dnspy-runtime.js +5 -12
  45. package/dist/src/dnspy.js +13 -28
  46. package/dist/src/dotnet-diagnostics.js +1 -1
  47. package/dist/src/extensions.d.ts +2 -3
  48. package/dist/src/extensions.js +14 -91
  49. package/dist/src/frida-worker.js +0 -20
  50. package/dist/src/frida.js +3 -26
  51. package/dist/src/function-boundaries.d.ts +2 -2
  52. package/dist/src/function-boundaries.js +9 -61
  53. package/dist/src/function-entries.d.ts +2 -2
  54. package/dist/src/function-entries.js +6 -36
  55. package/dist/src/function-inspection.d.ts +2 -2
  56. package/dist/src/function-inspection.js +17 -33
  57. package/dist/src/function-results.d.ts +1 -3
  58. package/dist/src/function-results.js +2 -13
  59. package/dist/src/hub/admin.d.ts +101 -0
  60. package/dist/src/hub/admin.js +314 -0
  61. package/dist/src/hub/autostart.d.ts +111 -0
  62. package/dist/src/hub/autostart.js +207 -0
  63. package/dist/src/hub/bundle.d.ts +33 -0
  64. package/dist/src/hub/bundle.js +25 -0
  65. package/dist/src/hub/client.d.ts +90 -0
  66. package/dist/src/hub/client.js +256 -0
  67. package/dist/src/hub/commands.d.ts +13 -0
  68. package/dist/src/hub/commands.js +280 -0
  69. package/dist/src/hub/contract.d.ts +87 -0
  70. package/dist/src/hub/contract.js +3 -0
  71. package/dist/src/hub/extensions.d.ts +41 -0
  72. package/dist/src/hub/extensions.js +3 -0
  73. package/dist/src/hub/ghidra.d.ts +70 -0
  74. package/dist/src/hub/ghidra.js +197 -0
  75. package/dist/src/hub/index.d.ts +6 -0
  76. package/dist/src/hub/index.js +7 -0
  77. package/dist/src/{work/store.d.ts → hub/ledger-store.d.ts} +57 -94
  78. package/dist/src/hub/ledger-store.js +919 -0
  79. package/dist/src/hub/ledger.d.ts +4 -0
  80. package/dist/src/hub/ledger.js +173 -0
  81. package/dist/src/hub/lock.d.ts +7 -0
  82. package/dist/src/hub/lock.js +53 -0
  83. package/dist/src/hub/repository.d.ts +45 -0
  84. package/dist/src/hub/repository.js +130 -0
  85. package/dist/src/hub/server.d.ts +86 -0
  86. package/dist/src/hub/server.js +414 -0
  87. package/dist/src/hub/settings.d.ts +36 -0
  88. package/dist/src/hub/settings.js +112 -0
  89. package/dist/src/hub/storage.d.ts +13 -0
  90. package/dist/src/hub/storage.js +46 -0
  91. package/dist/src/hub/store.d.ts +75 -0
  92. package/dist/src/hub/store.js +188 -0
  93. package/dist/src/ilspy.js +1 -1
  94. package/dist/src/internal-timing.d.ts +2 -9
  95. package/dist/src/internal-timing.js +2 -95
  96. package/dist/src/lldb.js +3 -15
  97. package/dist/src/llvm.js +0 -9
  98. package/dist/src/managed-heap.js +3 -7
  99. package/dist/src/managed-metadata.js +2 -5
  100. package/dist/src/memory-inputs.d.ts +1 -4
  101. package/dist/src/memory-inputs.js +10 -40
  102. package/dist/src/mitmproxy.d.ts +35 -4
  103. package/dist/src/mitmproxy.js +59 -40
  104. package/dist/src/model.d.ts +0 -73
  105. package/dist/src/model.js +0 -45
  106. package/dist/src/mutations.d.ts +1 -1
  107. package/dist/src/mutations.js +5 -10
  108. package/dist/src/native/contract.d.ts +130 -0
  109. package/dist/src/native/ghidra.d.ts +58 -0
  110. package/dist/src/native/ghidra.js +77 -0
  111. package/dist/src/native/host.d.ts +71 -0
  112. package/dist/src/native/host.js +265 -0
  113. package/dist/src/native/index.d.ts +13 -0
  114. package/dist/src/native/index.js +19 -0
  115. package/dist/src/native/jvm.d.ts +54 -0
  116. package/dist/src/native/jvm.js +47 -0
  117. package/dist/src/native/worker.d.ts +70 -0
  118. package/dist/src/native/worker.js +240 -0
  119. package/dist/src/native-inputs.d.ts +9 -14
  120. package/dist/src/native-inputs.js +22 -110
  121. package/dist/src/native-merge-patches.d.ts +2 -2
  122. package/dist/src/native-merge-patches.js +14 -14
  123. package/dist/src/persistent-client.js +53 -25
  124. package/dist/src/procmon.js +17 -31
  125. package/dist/src/program-files.d.ts +42 -0
  126. package/dist/src/program-files.js +148 -0
  127. package/dist/src/queries.js +2 -15
  128. package/dist/src/query-policy.d.ts +0 -2
  129. package/dist/src/query-policy.js +1 -14
  130. package/dist/src/research.d.ts +59 -238
  131. package/dist/src/research.js +212 -906
  132. package/dist/src/runtime-identity.d.ts +8 -0
  133. package/dist/src/runtime-identity.js +26 -0
  134. package/dist/src/runtime-manager.d.ts +1 -11
  135. package/dist/src/runtime-manager.js +10 -145
  136. package/dist/src/runtime-selection.d.ts +1 -1
  137. package/dist/src/runtime-selection.js +5 -37
  138. package/dist/src/saved-materials.js +8 -51
  139. package/dist/src/scripts.d.ts +1 -1
  140. package/dist/src/scripts.js +15 -15
  141. package/dist/src/sdk-contracts.js +2 -2
  142. package/dist/src/sdk.js +8 -8
  143. package/dist/src/sevenzip.js +1 -3
  144. package/dist/src/strace.js +0 -3
  145. package/dist/src/string-anchors.d.ts +2 -3
  146. package/dist/src/string-anchors.js +8 -101
  147. package/dist/src/text-window.d.ts +5 -4
  148. package/dist/src/text-window.js +4 -4
  149. package/dist/src/tool-runtime/archives.d.ts +1 -1
  150. package/dist/src/tool-runtime/archives.js +11 -20
  151. package/dist/src/tool-runtime/catalog.js +2 -5
  152. package/dist/src/tool-runtime/commands.js +1 -3
  153. package/dist/src/tool-runtime/deadline.js +2 -7
  154. package/dist/src/tool-runtime/definition.js +1 -31
  155. package/dist/src/tool-runtime/identity.js +6 -87
  156. package/dist/src/tool-runtime/installer.d.ts +2 -6
  157. package/dist/src/tool-runtime/installer.js +14 -76
  158. package/dist/src/tool-runtime/java-arguments.js +4 -10
  159. package/dist/src/tool-runtime/launch-worker.js +2 -8
  160. package/dist/src/tool-runtime/run.d.ts +2 -0
  161. package/dist/src/tool-runtime/run.js +20 -8
  162. package/dist/src/tool-runtime/store.d.ts +3 -3
  163. package/dist/src/tool-runtime/store.js +21 -83
  164. package/dist/src/tool-runtime/supervisor.d.ts +6 -11
  165. package/dist/src/tool-runtime/supervisor.js +155 -214
  166. package/dist/src/tool-runtime/windows-helper.d.ts +5 -0
  167. package/dist/src/tool-runtime/windows-helper.js +13 -0
  168. package/dist/src/tool-runtime/windows-job.d.ts +5 -5
  169. package/dist/src/tool-runtime/windows-job.js +13 -31
  170. package/dist/src/tshark.js +14 -27
  171. package/dist/src/ui-results.d.ts +3 -2
  172. package/dist/src/ui-results.js +16 -53
  173. package/dist/src/ui.d.ts +12 -13
  174. package/dist/src/ui.js +32 -70
  175. package/dist/src/version-tracking.d.ts +25 -39
  176. package/dist/src/version-tracking.js +70 -174
  177. package/dist/src/windbg.d.ts +1 -1
  178. package/dist/src/windbg.js +2 -8
  179. package/dist/src/work/client.d.ts +63 -0
  180. package/dist/src/work/client.js +163 -0
  181. package/dist/src/work/commands.d.ts +3 -1
  182. package/dist/src/work/commands.js +158 -184
  183. package/dist/src/work/dashboard.d.ts +2 -2
  184. package/dist/src/work/dashboard.js +7 -8
  185. package/dist/src/work/legacy.d.ts +8 -0
  186. package/dist/src/work/legacy.js +70 -0
  187. package/dist/src/work/model.d.ts +0 -3
  188. package/dist/src/work/model.js +0 -10
  189. package/dist/src/work/timing.d.ts +3 -3
  190. package/dist/src/work/timing.js +21 -25
  191. package/dist/src/workspace.d.ts +4 -250
  192. package/dist/src/workspace.js +11 -699
  193. package/node_modules/@eyeauras/cli-factory/README.md +6 -0
  194. package/node_modules/@eyeauras/cli-factory/dist/src/cli.d.ts.map +1 -1
  195. package/node_modules/@eyeauras/cli-factory/dist/src/cli.js +76 -28
  196. package/node_modules/@eyeauras/cli-factory/dist/src/cli.js.map +1 -1
  197. package/node_modules/@eyeauras/cli-factory/dist/src/command.d.ts +1 -1
  198. package/node_modules/@eyeauras/cli-factory/dist/src/command.d.ts.map +1 -1
  199. package/node_modules/@eyeauras/cli-factory/dist/src/command.js +1 -0
  200. package/node_modules/@eyeauras/cli-factory/dist/src/command.js.map +1 -1
  201. package/node_modules/@eyeauras/cli-factory/dist/src/errors.d.ts +1 -1
  202. package/node_modules/@eyeauras/cli-factory/dist/src/errors.d.ts.map +1 -1
  203. package/node_modules/@eyeauras/cli-factory/dist/src/errors.js +18 -6
  204. package/node_modules/@eyeauras/cli-factory/dist/src/errors.js.map +1 -1
  205. package/node_modules/@eyeauras/cli-factory/dist/src/file-publication.d.ts +44 -0
  206. package/node_modules/@eyeauras/cli-factory/dist/src/file-publication.d.ts.map +1 -0
  207. package/node_modules/@eyeauras/cli-factory/dist/src/{profile-file.js → file-publication.js} +41 -113
  208. package/node_modules/@eyeauras/cli-factory/dist/src/file-publication.js.map +1 -0
  209. package/node_modules/@eyeauras/cli-factory/dist/src/help.d.ts +5 -0
  210. package/node_modules/@eyeauras/cli-factory/dist/src/help.d.ts.map +1 -0
  211. package/node_modules/@eyeauras/cli-factory/dist/src/help.js +17 -0
  212. package/node_modules/@eyeauras/cli-factory/dist/src/help.js.map +1 -0
  213. package/node_modules/@eyeauras/cli-factory/dist/src/index.d.ts +9 -4
  214. package/node_modules/@eyeauras/cli-factory/dist/src/index.d.ts.map +1 -1
  215. package/node_modules/@eyeauras/cli-factory/dist/src/index.js +5 -2
  216. package/node_modules/@eyeauras/cli-factory/dist/src/index.js.map +1 -1
  217. package/node_modules/@eyeauras/cli-factory/dist/src/json-rpc.d.ts.map +1 -1
  218. package/node_modules/@eyeauras/cli-factory/dist/src/json-rpc.js +11 -18
  219. package/node_modules/@eyeauras/cli-factory/dist/src/json-rpc.js.map +1 -1
  220. package/node_modules/@eyeauras/cli-factory/dist/src/output-write.d.ts +10 -0
  221. package/node_modules/@eyeauras/cli-factory/dist/src/output-write.d.ts.map +1 -0
  222. package/node_modules/@eyeauras/cli-factory/dist/src/output-write.js +69 -0
  223. package/node_modules/@eyeauras/cli-factory/dist/src/output-write.js.map +1 -0
  224. package/node_modules/@eyeauras/cli-factory/dist/src/output.d.ts +3 -1
  225. package/node_modules/@eyeauras/cli-factory/dist/src/output.d.ts.map +1 -1
  226. package/node_modules/@eyeauras/cli-factory/dist/src/output.js +74 -14
  227. package/node_modules/@eyeauras/cli-factory/dist/src/output.js.map +1 -1
  228. package/node_modules/@eyeauras/cli-factory/dist/src/pagination.d.ts +3 -0
  229. package/node_modules/@eyeauras/cli-factory/dist/src/pagination.d.ts.map +1 -0
  230. package/node_modules/@eyeauras/cli-factory/dist/src/pagination.js +9 -0
  231. package/node_modules/@eyeauras/cli-factory/dist/src/pagination.js.map +1 -0
  232. package/node_modules/@eyeauras/cli-factory/dist/src/permissions.d.ts.map +1 -1
  233. package/node_modules/@eyeauras/cli-factory/dist/src/permissions.js +3 -1
  234. package/node_modules/@eyeauras/cli-factory/dist/src/permissions.js.map +1 -1
  235. package/node_modules/@eyeauras/cli-factory/dist/src/stream-result.d.ts +16 -0
  236. package/node_modules/@eyeauras/cli-factory/dist/src/stream-result.d.ts.map +1 -0
  237. package/node_modules/@eyeauras/cli-factory/dist/src/stream-result.js +83 -0
  238. package/node_modules/@eyeauras/cli-factory/dist/src/stream-result.js.map +1 -0
  239. package/node_modules/@eyeauras/cli-factory/dist/src/types.d.ts +5 -0
  240. package/node_modules/@eyeauras/cli-factory/dist/src/types.d.ts.map +1 -1
  241. package/node_modules/@eyeauras/cli-factory/dist/src/view.d.ts +49 -7
  242. package/node_modules/@eyeauras/cli-factory/dist/src/view.d.ts.map +1 -1
  243. package/node_modules/@eyeauras/cli-factory/dist/src/view.js +83 -6
  244. package/node_modules/@eyeauras/cli-factory/dist/src/view.js.map +1 -1
  245. package/node_modules/@eyeauras/cli-factory/package.json +1 -1
  246. package/node_modules/@eyeauras/cli-factory-ipc/dist/cli-host.proto +19 -19
  247. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/build.d.ts +7 -1
  248. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/build.d.ts.map +1 -1
  249. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/build.js +9 -4
  250. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/build.js.map +1 -1
  251. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/host.d.ts.map +1 -1
  252. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/host.js +5 -4
  253. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/host.js.map +1 -1
  254. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/package-build.d.ts +11 -1
  255. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/package-build.d.ts.map +1 -1
  256. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/package-build.js +85 -57
  257. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/package-build.js.map +1 -1
  258. package/node_modules/@eyeauras/cli-factory-ipc/package.json +2 -2
  259. package/package.json +4 -5
  260. package/references/native/InsightAnalyzerOptions.java +10 -0
  261. package/references/native/InsightAnchorScan.java +1 -11
  262. package/references/native/InsightCodeReferences.java +2 -3
  263. package/references/native/InsightCopyType.java +24 -0
  264. package/references/native/InsightFunctionBoundaries.java +0 -1
  265. package/references/native/InsightFunctionDatabases.java +20 -16
  266. package/references/native/InsightHelperCall.java +17 -0
  267. package/references/native/InsightHubServer.java +214 -0
  268. package/references/native/InsightNativeHost.java +112 -0
  269. package/references/native/InsightPlugins.java +0 -1
  270. package/references/native/InsightPythonWheels.java +3 -2
  271. package/references/native/InsightResearchQueries.java +3 -4
  272. package/references/native/InsightResearchView.java +4 -10
  273. package/references/native/InsightSdkFiles.java +7 -15
  274. package/references/native/InsightSdkScript.java +1 -4
  275. package/references/native/InsightSdkTools.java +36 -97
  276. package/references/native/InsightSdkTypes.java +13 -43
  277. package/references/native/InsightStringAnchors.java +1 -3
  278. package/references/native/InsightTraceState.java +13 -96
  279. package/references/native/InsightTraceTools.java +3 -5
  280. package/references/native/InsightVersionTracking.java +0 -6
  281. package/references/native/{HeadlessProgramMergeManager.java → InsightWcMerge.java} +17 -24
  282. package/references/native/InsightWcOps.java +449 -0
  283. package/references/native/InsightWcWorker.java +142 -0
  284. package/references/native/NATIVE-MERGE-NOTICE.txt +4 -8
  285. package/runtime/GhidraMCP-7.0.0.jar +0 -0
  286. package/runtime/managed/insight-heap/README.md +3 -3
  287. package/runtime/managed/insight-managed/README.md +3 -3
  288. package/runtime/native/binary/README.md +5 -4
  289. package/runtime/native/windows/DirectoryAlias.cs +24 -0
  290. package/runtime/native/windows/Insight.Windows.csproj +27 -0
  291. package/runtime/native/windows/Native.cs +36 -0
  292. package/runtime/native/windows/OwnedJob.cs +86 -0
  293. package/runtime/native/windows/Program.cs +50 -0
  294. package/runtime/native/windows/RegistryRedirect.cs +42 -0
  295. package/runtime/native/windows/insight-windows-x64.exe +0 -0
  296. package/runtime/native/windows/packages.lock.json +35 -0
  297. package/runtime/native/windows/provenance.json +17 -0
  298. package/runtime/research-view.provenance.json +6 -7
  299. package/runtime/toolbox.json +33 -114
  300. package/skill-bundle/insight-artifacts/SKILL.md +5 -19
  301. package/skill-bundle/insight-binary/SKILL.md +5 -35
  302. package/skill-bundle/insight-capture/SKILL.md +5 -45
  303. package/skill-bundle/insight-cli/SKILL.md +6 -44
  304. package/skill-bundle/insight-die/SKILL.md +5 -38
  305. package/skill-bundle/insight-dnspy/SKILL.md +5 -54
  306. package/skill-bundle/insight-dotnet-dump/SKILL.md +5 -35
  307. package/skill-bundle/insight-dotnet-stack/SKILL.md +5 -28
  308. package/skill-bundle/insight-dotnet-trace/SKILL.md +5 -34
  309. package/skill-bundle/insight-frida/SKILL.md +5 -56
  310. package/skill-bundle/insight-ghidra/SKILL.md +14 -113
  311. package/skill-bundle/insight-ilspy/SKILL.md +5 -34
  312. package/skill-bundle/insight-interop/SKILL.md +5 -43
  313. package/skill-bundle/insight-lldb/SKILL.md +5 -43
  314. package/skill-bundle/insight-llvm/SKILL.md +5 -45
  315. package/skill-bundle/insight-managed-heap/SKILL.md +5 -32
  316. package/skill-bundle/insight-managed-metadata/SKILL.md +5 -41
  317. package/skill-bundle/insight-mitmproxy/SKILL.md +5 -51
  318. package/skill-bundle/insight-overview/SKILL.md +5 -68
  319. package/skill-bundle/insight-procmon/SKILL.md +5 -38
  320. package/skill-bundle/insight-re/SKILL.md +10 -127
  321. package/skill-bundle/insight-sevenzip/SKILL.md +5 -31
  322. package/skill-bundle/insight-strace/SKILL.md +5 -35
  323. package/skill-bundle/insight-tshark/SKILL.md +5 -38
  324. package/skill-bundle/insight-windbg/SKILL.md +5 -35
  325. package/skill-bundle/manifest.json +1 -1
  326. package/skills/insight-artifacts/SKILL.md +5 -19
  327. package/skills/insight-binary/SKILL.md +5 -35
  328. package/skills/insight-capture/SKILL.md +5 -45
  329. package/skills/insight-die/SKILL.md +5 -38
  330. package/skills/insight-dnspy/SKILL.md +5 -54
  331. package/skills/insight-dotnet-dump/SKILL.md +5 -35
  332. package/skills/insight-dotnet-stack/SKILL.md +5 -28
  333. package/skills/insight-dotnet-trace/SKILL.md +5 -34
  334. package/skills/insight-frida/SKILL.md +5 -56
  335. package/skills/insight-ghidra/SKILL.md +14 -113
  336. package/skills/insight-ilspy/SKILL.md +5 -34
  337. package/skills/insight-interop/SKILL.md +5 -43
  338. package/skills/insight-lldb/SKILL.md +5 -43
  339. package/skills/insight-llvm/SKILL.md +5 -45
  340. package/skills/insight-managed-heap/SKILL.md +5 -32
  341. package/skills/insight-managed-metadata/SKILL.md +5 -41
  342. package/skills/insight-mitmproxy/SKILL.md +5 -51
  343. package/skills/insight-overview/SKILL.md +5 -68
  344. package/skills/insight-procmon/SKILL.md +5 -38
  345. package/skills/insight-re/SKILL.md +10 -127
  346. package/skills/insight-sevenzip/SKILL.md +5 -31
  347. package/skills/insight-strace/SKILL.md +5 -35
  348. package/skills/insight-tshark/SKILL.md +5 -38
  349. package/skills/insight-windbg/SKILL.md +5 -35
  350. package/dist/src/administration-results.d.ts +0 -1
  351. package/dist/src/administration-results.js +0 -84
  352. package/dist/src/administration.d.ts +0 -14
  353. package/dist/src/administration.js +0 -134
  354. package/dist/src/archive-contract.d.ts +0 -6
  355. package/dist/src/archive-contract.js +0 -108
  356. package/dist/src/archive.d.ts +0 -12
  357. package/dist/src/archive.js +0 -116
  358. package/dist/src/comment-effects.d.ts +0 -3
  359. package/dist/src/comment-effects.js +0 -55
  360. package/dist/src/context-credential.d.ts +0 -18
  361. package/dist/src/context-credential.js +0 -44
  362. package/dist/src/contexts.d.ts +0 -387
  363. package/dist/src/contexts.js +0 -2805
  364. package/dist/src/coordinator.d.ts +0 -41
  365. package/dist/src/coordinator.js +0 -160
  366. package/dist/src/cross-peer.d.ts +0 -20
  367. package/dist/src/cross-peer.js +0 -53
  368. package/dist/src/data-effects.d.ts +0 -3
  369. package/dist/src/data-effects.js +0 -103
  370. package/dist/src/debugger-caller.d.ts +0 -17
  371. package/dist/src/debugger-caller.js +0 -129
  372. package/dist/src/debugger-launch.d.ts +0 -2
  373. package/dist/src/debugger-launch.js +0 -17
  374. package/dist/src/debugger-supervisor.js +0 -179
  375. package/dist/src/directory-identity.d.ts +0 -6
  376. package/dist/src/directory-identity.js +0 -45
  377. package/dist/src/documentation-effects.d.ts +0 -5
  378. package/dist/src/documentation-effects.js +0 -56
  379. package/dist/src/function-effects.d.ts +0 -4
  380. package/dist/src/function-effects.js +0 -112
  381. package/dist/src/ghidra-processes.d.ts +0 -6
  382. package/dist/src/ghidra-processes.js +0 -138
  383. package/dist/src/ghidra.d.ts +0 -50
  384. package/dist/src/ghidra.js +0 -468
  385. package/dist/src/initial-model.d.ts +0 -7
  386. package/dist/src/initial-model.js +0 -115
  387. package/dist/src/initial-progress.d.ts +0 -4
  388. package/dist/src/initial-progress.js +0 -74
  389. package/dist/src/inline-script.d.ts +0 -15
  390. package/dist/src/inline-script.js +0 -61
  391. package/dist/src/legacy-migration.d.ts +0 -37
  392. package/dist/src/legacy-migration.js +0 -238
  393. package/dist/src/lifecycle.d.ts +0 -77
  394. package/dist/src/lifecycle.js +0 -315
  395. package/dist/src/merge.d.ts +0 -29
  396. package/dist/src/merge.js +0 -66
  397. package/dist/src/mutation-effects.d.ts +0 -4
  398. package/dist/src/mutation-effects.js +0 -321
  399. package/dist/src/native-queries.d.ts +0 -2
  400. package/dist/src/native-queries.js +0 -24
  401. package/dist/src/native-service.d.ts +0 -40
  402. package/dist/src/native-service.js +0 -406
  403. package/dist/src/projects.d.ts +0 -31
  404. package/dist/src/projects.js +0 -302
  405. package/dist/src/prototype-cli.d.ts +0 -8
  406. package/dist/src/prototype-cli.js +0 -155
  407. package/dist/src/query-results.d.ts +0 -2
  408. package/dist/src/query-results.js +0 -224
  409. package/dist/src/research-view.d.ts +0 -6
  410. package/dist/src/research-view.js +0 -9
  411. package/dist/src/sdk-files.d.ts +0 -29
  412. package/dist/src/sdk-files.js +0 -249
  413. package/dist/src/server.d.ts +0 -102
  414. package/dist/src/server.js +0 -663
  415. package/dist/src/storage-gc.d.ts +0 -23
  416. package/dist/src/storage-gc.js +0 -600
  417. package/dist/src/store.d.ts +0 -33
  418. package/dist/src/store.js +0 -178
  419. package/dist/src/sync-policy.d.ts +0 -22
  420. package/dist/src/sync-policy.js +0 -129
  421. package/dist/src/timed-backend.d.ts +0 -3
  422. package/dist/src/timed-backend.js +0 -24
  423. package/dist/src/timing-report.d.ts +0 -32
  424. package/dist/src/timing-report.js +0 -74
  425. package/dist/src/tool-runtime/native-process-proof.d.ts +0 -2
  426. package/dist/src/tool-runtime/native-process-proof.js +0 -26
  427. package/dist/src/transport.d.ts +0 -60
  428. package/dist/src/transport.js +0 -223
  429. package/dist/src/unresolved-guidance.d.ts +0 -46
  430. package/dist/src/unresolved-guidance.js +0 -55
  431. package/dist/src/work/backup.d.ts +0 -66
  432. package/dist/src/work/backup.js +0 -446
  433. package/dist/src/work/store.js +0 -1107
  434. package/dist/src/worker-lease.d.ts +0 -17
  435. package/dist/src/worker-lease.js +0 -50
  436. package/node_modules/@eyeauras/cli-factory/dist/src/profile-file.d.ts +0 -37
  437. package/node_modules/@eyeauras/cli-factory/dist/src/profile-file.d.ts.map +0 -1
  438. package/node_modules/@eyeauras/cli-factory/dist/src/profile-file.js.map +0 -1
  439. package/references/InsightRepositoryProbe.java +0 -55
  440. package/references/administration.md +0 -34
  441. package/references/agent-execution.md +0 -36
  442. package/references/agent-setup.md +0 -60
  443. package/references/archive.md +0 -32
  444. package/references/artifacts.md +0 -52
  445. package/references/debugger.md +0 -64
  446. package/references/extensions-and-sync.md +0 -125
  447. package/references/ilspy.md +0 -33
  448. package/references/managed-runtime.md +0 -162
  449. package/references/native/InsightArchivePayloads.java +0 -36
  450. package/references/native/InsightBlockTransfer.java +0 -57
  451. package/references/native/InsightGuiMain.java +0 -33
  452. package/references/native/InsightHeadlessMain.java +0 -18
  453. package/references/native/InsightImportProgress.java +0 -60
  454. package/references/native/InsightInitialImport.java +0 -48
  455. package/references/native/InsightInitialJournal.java +0 -57
  456. package/references/native/InsightInitialPublication.java +0 -142
  457. package/references/native/InsightInitialRecovery.java +0 -131
  458. package/references/native/InsightInlineExecutor.java +0 -143
  459. package/references/native/InsightInlineScript.java +0 -14
  460. package/references/native/InsightNativeCheckout.java +0 -487
  461. package/references/native/InsightNativeFingerprint.java +0 -80
  462. package/references/native/InsightNativeMigration.java +0 -155
  463. package/references/native/InsightNativeRead.java +0 -80
  464. package/references/native/InsightNativeReceipt.java +0 -31
  465. package/references/native/InsightNativeService.java +0 -43
  466. package/references/native/InsightNativeView.java +0 -40
  467. package/references/native/InsightOfflineAuthenticator.java +0 -20
  468. package/references/native/InsightOwnedScripts.java +0 -170
  469. package/references/native/InsightProjectFiles.java +0 -92
  470. package/references/native/InsightPublicationRecovery.java +0 -63
  471. package/references/native/InsightServerAdministration.java +0 -82
  472. package/references/native/InsightServerInit.java +0 -62
  473. package/references/native/InsightServerMain.java +0 -43
  474. package/references/native/InsightServerProbe.java +0 -29
  475. package/references/native/InsightSnapshotFields.java +0 -74
  476. package/references/native/InsightSnapshotInspect.java +0 -191
  477. package/references/native/InsightSnapshotPublisher.java +0 -123
  478. package/references/native/InsightStopDebugger.java +0 -20
  479. package/references/native/InsightTraceInspect.java +0 -24
  480. package/references/native/InsightWorkerLease.java +0 -132
  481. package/references/native-workflows.md +0 -124
  482. package/references/persistent-client.mjs +0 -147
  483. package/references/persistent.md +0 -90
  484. package/references/query-semantics.md +0 -109
  485. package/references/recovery.md +0 -235
  486. package/references/research.md +0 -296
  487. package/references/setup.md +0 -135
  488. package/references/sparse-navigation.md +0 -173
  489. package/references/storage.md +0 -139
  490. package/references/work-tracking.md +0 -261
  491. package/runtime/native/file-version.ps1 +0 -7
  492. package/runtime/native/mitmproxy/bridge.py +0 -180
  493. package/runtime/native/windows-job/DirectoryAlias.cs +0 -24
  494. package/runtime/native/windows-job/Insight.WindowsJob.csproj +0 -1
  495. package/runtime/native/windows-job/Insight.WindowsJob.dll +0 -0
  496. package/runtime/native/windows-job/OwnedJob.cs +0 -79
  497. package/runtime/native/windows-job/RegistryRedirect.cs +0 -45
  498. package/runtime/native/windows-job/packages.lock.json +0 -21
  499. package/runtime/native/windows-job/provenance.json +0 -16
  500. package/runtime/native/windows-job/windows-job.ps1 +0 -8
  501. package/skill-bundle/insight-artifacts/references/agent-execution.md +0 -36
  502. package/skill-bundle/insight-artifacts/references/artifacts.md +0 -52
  503. package/skill-bundle/insight-artifacts/references/recovery.md +0 -235
  504. package/skill-bundle/insight-artifacts/references/storage.md +0 -139
  505. package/skill-bundle/insight-binary/references/agent-execution.md +0 -36
  506. package/skill-bundle/insight-capture/references/agent-execution.md +0 -36
  507. package/skill-bundle/insight-cli/references/agent-execution.md +0 -36
  508. package/skill-bundle/insight-cli/references/agent-setup.md +0 -60
  509. package/skill-bundle/insight-cli/references/archive.md +0 -32
  510. package/skill-bundle/insight-cli/references/managed-runtime.md +0 -162
  511. package/skill-bundle/insight-cli/references/persistent-client.mjs +0 -147
  512. package/skill-bundle/insight-cli/references/persistent.md +0 -90
  513. package/skill-bundle/insight-cli/references/recovery.md +0 -235
  514. package/skill-bundle/insight-cli/references/setup.md +0 -135
  515. package/skill-bundle/insight-cli/references/storage.md +0 -139
  516. package/skill-bundle/insight-die/references/agent-execution.md +0 -36
  517. package/skill-bundle/insight-dnspy/references/agent-execution.md +0 -36
  518. package/skill-bundle/insight-dotnet-dump/references/agent-execution.md +0 -36
  519. package/skill-bundle/insight-dotnet-stack/references/agent-execution.md +0 -36
  520. package/skill-bundle/insight-dotnet-trace/references/agent-execution.md +0 -36
  521. package/skill-bundle/insight-frida/references/agent-execution.md +0 -36
  522. package/skill-bundle/insight-ghidra/references/administration.md +0 -34
  523. package/skill-bundle/insight-ghidra/references/agent-execution.md +0 -36
  524. package/skill-bundle/insight-ghidra/references/archive.md +0 -32
  525. package/skill-bundle/insight-ghidra/references/artifacts.md +0 -52
  526. package/skill-bundle/insight-ghidra/references/debugger.md +0 -64
  527. package/skill-bundle/insight-ghidra/references/extensions-and-sync.md +0 -125
  528. package/skill-bundle/insight-ghidra/references/managed-runtime.md +0 -162
  529. package/skill-bundle/insight-ghidra/references/native-workflows.md +0 -124
  530. package/skill-bundle/insight-ghidra/references/persistent-client.mjs +0 -147
  531. package/skill-bundle/insight-ghidra/references/persistent.md +0 -90
  532. package/skill-bundle/insight-ghidra/references/query-semantics.md +0 -109
  533. package/skill-bundle/insight-ghidra/references/recovery.md +0 -235
  534. package/skill-bundle/insight-ghidra/references/research.md +0 -296
  535. package/skill-bundle/insight-ghidra/references/setup.md +0 -135
  536. package/skill-bundle/insight-ghidra/references/sparse-navigation.md +0 -173
  537. package/skill-bundle/insight-ghidra/references/storage.md +0 -139
  538. package/skill-bundle/insight-ilspy/references/agent-execution.md +0 -36
  539. package/skill-bundle/insight-ilspy/references/ilspy.md +0 -33
  540. package/skill-bundle/insight-interop/references/agent-execution.md +0 -36
  541. package/skill-bundle/insight-lldb/references/agent-execution.md +0 -36
  542. package/skill-bundle/insight-llvm/references/agent-execution.md +0 -36
  543. package/skill-bundle/insight-managed-heap/references/agent-execution.md +0 -36
  544. package/skill-bundle/insight-managed-metadata/references/agent-execution.md +0 -36
  545. package/skill-bundle/insight-mitmproxy/references/agent-execution.md +0 -36
  546. package/skill-bundle/insight-overview/references/agent-execution.md +0 -36
  547. package/skill-bundle/insight-procmon/references/agent-execution.md +0 -36
  548. package/skill-bundle/insight-re/references/agent-execution.md +0 -36
  549. package/skill-bundle/insight-re/references/artifacts.md +0 -52
  550. package/skill-bundle/insight-re/references/persistent-client.mjs +0 -147
  551. package/skill-bundle/insight-re/references/persistent.md +0 -90
  552. package/skill-bundle/insight-re/references/recovery.md +0 -235
  553. package/skill-bundle/insight-re/references/storage.md +0 -139
  554. package/skill-bundle/insight-re/references/work-tracking.md +0 -261
  555. package/skill-bundle/insight-sevenzip/references/agent-execution.md +0 -36
  556. package/skill-bundle/insight-strace/references/agent-execution.md +0 -36
  557. package/skill-bundle/insight-tshark/references/agent-execution.md +0 -36
  558. package/skill-bundle/insight-windbg/references/agent-execution.md +0 -36
  559. package/skills/insight-artifacts/references/agent-execution.md +0 -36
  560. package/skills/insight-artifacts/references/artifacts.md +0 -52
  561. package/skills/insight-artifacts/references/recovery.md +0 -235
  562. package/skills/insight-artifacts/references/storage.md +0 -139
  563. package/skills/insight-binary/references/agent-execution.md +0 -36
  564. package/skills/insight-capture/references/agent-execution.md +0 -36
  565. package/skills/insight-die/references/agent-execution.md +0 -36
  566. package/skills/insight-dnspy/references/agent-execution.md +0 -36
  567. package/skills/insight-dotnet-dump/references/agent-execution.md +0 -36
  568. package/skills/insight-dotnet-stack/references/agent-execution.md +0 -36
  569. package/skills/insight-dotnet-trace/references/agent-execution.md +0 -36
  570. package/skills/insight-frida/references/agent-execution.md +0 -36
  571. package/skills/insight-ghidra/references/administration.md +0 -34
  572. package/skills/insight-ghidra/references/agent-execution.md +0 -36
  573. package/skills/insight-ghidra/references/archive.md +0 -32
  574. package/skills/insight-ghidra/references/artifacts.md +0 -52
  575. package/skills/insight-ghidra/references/debugger.md +0 -64
  576. package/skills/insight-ghidra/references/extensions-and-sync.md +0 -125
  577. package/skills/insight-ghidra/references/managed-runtime.md +0 -162
  578. package/skills/insight-ghidra/references/native-workflows.md +0 -124
  579. package/skills/insight-ghidra/references/persistent-client.mjs +0 -147
  580. package/skills/insight-ghidra/references/persistent.md +0 -90
  581. package/skills/insight-ghidra/references/query-semantics.md +0 -109
  582. package/skills/insight-ghidra/references/recovery.md +0 -235
  583. package/skills/insight-ghidra/references/research.md +0 -296
  584. package/skills/insight-ghidra/references/setup.md +0 -135
  585. package/skills/insight-ghidra/references/sparse-navigation.md +0 -173
  586. package/skills/insight-ghidra/references/storage.md +0 -139
  587. package/skills/insight-ilspy/references/agent-execution.md +0 -36
  588. package/skills/insight-ilspy/references/ilspy.md +0 -33
  589. package/skills/insight-interop/references/agent-execution.md +0 -36
  590. package/skills/insight-lldb/references/agent-execution.md +0 -36
  591. package/skills/insight-llvm/references/agent-execution.md +0 -36
  592. package/skills/insight-managed-heap/references/agent-execution.md +0 -36
  593. package/skills/insight-managed-metadata/references/agent-execution.md +0 -36
  594. package/skills/insight-mitmproxy/references/agent-execution.md +0 -36
  595. package/skills/insight-overview/references/agent-execution.md +0 -36
  596. package/skills/insight-procmon/references/agent-execution.md +0 -36
  597. package/skills/insight-re/references/agent-execution.md +0 -36
  598. package/skills/insight-re/references/artifacts.md +0 -52
  599. package/skills/insight-re/references/persistent-client.mjs +0 -147
  600. package/skills/insight-re/references/persistent.md +0 -90
  601. package/skills/insight-re/references/recovery.md +0 -235
  602. package/skills/insight-re/references/storage.md +0 -139
  603. package/skills/insight-re/references/work-tracking.md +0 -261
  604. package/skills/insight-sevenzip/references/agent-execution.md +0 -36
  605. package/skills/insight-strace/references/agent-execution.md +0 -36
  606. package/skills/insight-tshark/references/agent-execution.md +0 -36
  607. package/skills/insight-windbg/references/agent-execution.md +0 -36
  608. /package/dist/src/{debugger-supervisor.d.ts → native/contract.js} +0 -0
  609. /package/runtime/native/{windows-job → windows}/NuGet.Config +0 -0
@@ -4,12 +4,11 @@ import type { Workspace } from './workspace.js';
4
4
  export declare function mitmproxyInstaller(c: CommandContext): ToolInstaller;
5
5
  export declare function mitmproxyStatus(c: CommandContext): Promise<{
6
6
  captures: {
7
- endpoint?: string | undefined;
8
- archive?: string | undefined;
9
- caCertificate?: string | undefined;
10
7
  process: string;
11
8
  state: string;
12
- ready: boolean;
9
+ endpoint: string;
10
+ archive: string;
11
+ caCertificate: string;
13
12
  }[];
14
13
  retainedStages: string[];
15
14
  processes: import("./tool-runtime/supervisor.js").ProcessRecord[];
@@ -23,6 +22,7 @@ export declare function mitmproxyStatus(c: CommandContext): Promise<{
23
22
  recommended: string;
24
23
  }>;
25
24
  interface Message {
25
+ httpVersion?: string;
26
26
  bodyAvailable: boolean;
27
27
  bodySha256: string | null;
28
28
  bodyBase64: string | null;
@@ -37,13 +37,18 @@ export interface HttpObservation {
37
37
  request: Message & {
38
38
  method: string;
39
39
  url: string;
40
+ scheme?: string;
40
41
  host: string;
42
+ port?: number;
41
43
  path: string;
42
44
  };
43
45
  response: (Message & {
44
46
  statusCode: number;
45
47
  }) | null;
46
48
  error: string | null;
49
+ timestampStart?: number;
50
+ timestampEnd?: number;
51
+ websocketPayloadObserved?: boolean;
47
52
  pending: boolean;
48
53
  }
49
54
  export declare function compareHttp(left: HttpObservation[], right: HttpObservation[]): {
@@ -51,5 +56,31 @@ export declare function compareHttp(left: HttpObservation[], right: HttpObservat
51
56
  unchanged: number;
52
57
  scope: string;
53
58
  };
59
+ /**
60
+ * HTTP observations from a savehar HAR, bounded here: the first max-flows entries and a body-bytes prefix of each
61
+ * body. HAR bodies are mitmproxy's decoded content (text as UTF-8, binary as base64); savehar keeps a request body
62
+ * only for POST/PUT/PATCH, so other methods with a non-empty body report it unavailable. HAR carries no flow UUID:
63
+ * ids are 1-based entry ordinals of this exact HAR.
64
+ */
65
+ export declare function harObservations(har: unknown, bodyBytes: number, maxFlows: number): {
66
+ items: HttpObservation[];
67
+ flowLimited: boolean;
68
+ };
69
+ /** mitmdump's own log lines (termlog) for the facts an addon used to report. */
70
+ export declare function mitmdumpLog(output: string): {
71
+ tlsFailures: {
72
+ side: string;
73
+ error: string;
74
+ }[];
75
+ skippedFlows: number;
76
+ readError: string | null;
77
+ };
78
+ /** Built-in mitmdump options only: savehar's `hardump`, save's `save_stream_file` and readfile's `rfile`; no addon script. */
79
+ export declare function mitmdumpArguments(mode: 'record' | 'inspect', paths: {
80
+ conf: string;
81
+ har: string;
82
+ capture?: string;
83
+ input?: string;
84
+ }, port?: number): string[];
54
85
  export declare function mitmproxyCommands(workspace: (c: CommandContext) => Workspace): CommandDefinition[];
55
86
  export {};
@@ -4,23 +4,19 @@ import { fileURLToPath } from 'node:url';
4
4
  import { release } from 'node:os';
5
5
  import { mkdir, readFile, stat, lstat, copyFile, cp, writeFile } from 'node:fs/promises';
6
6
  import { readFileSync, constants } from 'node:fs';
7
- import { randomUUID } from 'node:crypto';
7
+ import { randomUUID, createHash } from 'node:crypto';
8
8
  import { ToolInstaller } from './tool-runtime/installer.js';
9
9
  import { defineTool, lifecycleCommands } from './tool-runtime/definition.js';
10
10
  import { catalogArtifact } from './tool-runtime/catalog.js';
11
11
  import { runTool } from './tool-runtime/run.js';
12
- import { atomicWrite, treeFingerprint, readJson } from './tool-runtime/store.js';
13
- import { fileSha256 } from './tool-runtime/archives.js';
14
12
  import { fail, text, id } from './model.js';
15
13
  import { number } from './research.js';
16
14
  const native = fileURLToPath(new URL('../../runtime/native/mitmproxy/', import.meta.url)), runtimeSha = '4bed6d0d2a0bcdc4afeb7408881c9b30e5f81b7c232c2ff9c987babcbed90125';
17
- let notices;
18
15
  function supported() { if (process.platform !== 'darwin' || process.arch !== 'arm64' || Number(release().split('.')[0]) < 24)
19
16
  fail('unsupported', 'The pinned mitmproxy facade requires macOS 15+ ARM64. It uses only an owned loopback HTTP proxy and private profile CA; system proxy/trust settings are not installed.'); }
20
17
  function bundle(executable) { if (basename(executable) !== 'mitmdump' || basename(dirname(executable)) !== 'MacOS' || basename(resolve(dirname(executable), '../..')) !== 'mitmproxy.app')
21
18
  fail('configuration', 'Select the pinned mitmproxy.app/Contents/MacOS/mitmdump and its complete adjacent runtime.'); return resolve(dirname(executable), '../..'); }
22
- export function mitmproxyInstaller(c) { return new ToolInstaller(c, { id: 'mitmproxy', primary: 'mitmproxy', preparationId: 'external-owned-copy-v1', prepareExternal: async (executable, stage) => { const source = bundle(executable), before = await treeFingerprint(source), owned = join(stage, 'execution/mitmproxy.app'); await cp(source, owned, { recursive: true, dereference: false, verbatimSymlinks: true, errorOnExist: true, force: false }); if (await treeFingerprint(source) !== before || await treeFingerprint(owned) !== before)
23
- fail('binding', 'External mitmproxy runtime changed while making its owned execution copy.'); return { executable: join(owned, 'Contents/MacOS/mitmdump'), arguments: [], environment: {} }; }, components: () => { supported(); return { mitmproxy: catalogArtifact(runtimeSha) }; }, noticeFiles: notices ??= JSON.parse(readFileSync(join(native, 'notices.json'), 'utf8')), launch: roots => ({ executable: join(roots.mitmproxy, 'mitmproxy.app/Contents/MacOS/mitmdump'), arguments: [], environment: {} }), externalInputs: async (executable) => { supported(); return { runtimeFamily: await treeFingerprint(bundle(executable)) }; }, probe: async (launch, context) => { supported(); const result = await runTool(context, { tool: 'mitmproxy', role: 'version', executable: launch.executable, arguments: ['--version'], timeoutMs: 15000, maxOutputBytes: 65536, nativeDeadline: true }); if (!/^Mitmproxy: 12\.2\.3(?: binary)?\s*$/m.test(result.stdout))
19
+ export function mitmproxyInstaller(c) { return new ToolInstaller(c, { id: 'mitmproxy', primary: 'mitmproxy', preparationId: 'external-owned-copy-v1', prepareExternal: async (executable, stage) => { const source = bundle(executable), owned = join(stage, 'execution/mitmproxy.app'); await cp(source, owned, { recursive: true, dereference: false, verbatimSymlinks: true, errorOnExist: true, force: false }); return { executable: join(owned, 'Contents/MacOS/mitmdump'), arguments: [], environment: {} }; }, components: () => { supported(); return { mitmproxy: catalogArtifact(runtimeSha) }; }, noticeFiles: () => JSON.parse(readFileSync(join(native, 'notices.json'), 'utf8')), launch: roots => ({ executable: join(roots.mitmproxy, 'mitmproxy.app/Contents/MacOS/mitmdump'), arguments: [], environment: {} }), probe: async (launch, context) => { supported(); const result = await runTool(context, { tool: 'mitmproxy', role: 'version', executable: launch.executable, arguments: ['--version'], timeoutMs: 15000, maxOutputBytes: 65536, nativeDeadline: true }); if (!/^Mitmproxy: 12\.2\.3(?: binary)?\s*$/m.test(result.stdout))
24
20
  fail('configuration', 'Select mitmproxy 12.2.3.'); return { version: '12.2.3', privatePython: '3.14.4', minimumSystem: 'macOS 15+ ARM64', typedHttpOnly: true, loopbackProxy: true, systemTrustInstalled: false, systemProxyInstalled: false }; } }); }
25
21
  export async function mitmproxyStatus(c) {
26
22
  const status = await mitmproxyInstaller(c).status(), captures = [];
@@ -30,13 +26,7 @@ export async function mitmproxyStatus(c) {
30
26
  const metadata = process.metadata ?? {}, directory = metadata.query;
31
27
  if (typeof directory !== 'string' || !/^[-a-f0-9]{36}$/.test(basename(directory)) || directory !== join(c.appArguments.AppDataDirectory, 'runtime/mitmproxy/queries', basename(directory)))
32
28
  continue;
33
- let ready = false;
34
- try {
35
- const receipt = await readJson(join(directory, 'ready.json'));
36
- ready = receipt?.schema === 1 && receipt.nonce === metadata.nonce && receipt.host === '127.0.0.1' && receipt.port === metadata.listenPort;
37
- }
38
- catch { }
39
- captures.push({ process: process.id, state: ready ? 'ready' : 'starting', ready, ...(ready ? { endpoint: 'http://127.0.0.1:' + metadata.listenPort, archive: join(directory, 'capture.mitm'), caCertificate: join(directory, 'conf/mitmproxy-ca-cert.pem') } : {}) });
29
+ captures.push({ process: process.id, state: 'running', endpoint: 'http://127.0.0.1:' + metadata.listenPort, archive: join(directory, 'capture.mitm'), caCertificate: join(directory, 'conf/mitmproxy-ca-cert.pem') });
40
30
  }
41
31
  return { ...status, captures };
42
32
  }
@@ -79,12 +69,52 @@ export function compareHttp(left, right) {
79
69
  }
80
70
  return { items, unchanged, scope: 'Literal method + URL, then occurrence order; selected body SHA256/status/error fields only. This alignment is a comparison aid, not proof of causal request correspondence. Volatile headers/timestamps are excluded; unavailable bodies remain unknown. Unmatched rows in a partial input do not prove absence.' };
81
71
  }
72
+ const sha256 = (bytes) => createHash('sha256').update(bytes).digest('hex');
73
+ function harHeaders(list) { const rows = list ?? []; return { headers: rows.slice(0, 64).map(h => [h.name.slice(0, 256), h.value.slice(0, 4096)]), headersTruncated: rows.length > 64 || rows.some(h => h.name.length > 256 || h.value.length > 4096) }; }
74
+ function harBody(bytes, limit) { return bytes ? { bodyAvailable: true, bodySha256: sha256(bytes), bodyBase64: bytes.subarray(0, limit).toString('base64'), bodyTruncated: bytes.length > limit, bodyBytes: bytes.length } : { bodyAvailable: false, bodySha256: null, bodyBase64: null, bodyTruncated: null, bodyBytes: null }; }
75
+ /**
76
+ * HTTP observations from a savehar HAR, bounded here: the first max-flows entries and a body-bytes prefix of each
77
+ * body. HAR bodies are mitmproxy's decoded content (text as UTF-8, binary as base64); savehar keeps a request body
78
+ * only for POST/PUT/PATCH, so other methods with a non-empty body report it unavailable. HAR carries no flow UUID:
79
+ * ids are 1-based entry ordinals of this exact HAR.
80
+ */
81
+ export function harObservations(har, bodyBytes, maxFlows) {
82
+ const entries = har?.log?.entries;
83
+ if (!Array.isArray(entries))
84
+ fail('partial', 'mitmdump HAR output has no entries.');
85
+ const items = entries.slice(0, maxFlows).map((entry, index) => {
86
+ const request = entry.request, response = entry.response, text = request.postData?.text;
87
+ let url;
88
+ try {
89
+ url = new URL(request.url);
90
+ }
91
+ catch { }
92
+ const requestBody = typeof text === 'string' ? Buffer.from(text, 'utf8') : request.bodySize === 0 ? Buffer.alloc(0) : undefined;
93
+ const answered = response.status > 0 || response.headersSize >= 0, content = response.content?.text;
94
+ const responseBody = typeof content === 'string' ? Buffer.from(content, response.content.encoding === 'base64' ? 'base64' : 'utf8') : undefined;
95
+ const start = Date.parse(entry.startedDateTime) / 1000;
96
+ return { kind: 'http', id: 'flow-' + (index + 1), request: { httpVersion: request.httpVersion, ...harHeaders(request.headers), ...harBody(requestBody, bodyBytes), method: request.method, scheme: url?.protocol.replace(/:$/, ''), host: url?.hostname ?? '', port: url ? Number(url.port || (url.protocol === 'https:' ? 443 : 80)) : undefined, path: url ? url.pathname + url.search : '', url: request.url },
97
+ response: answered ? { httpVersion: response.httpVersion, ...harHeaders(response.headers), ...harBody(responseBody, bodyBytes), statusCode: response.status } : null,
98
+ error: typeof response._error === 'string' ? response._error.slice(0, 4096) : null, timestampStart: start, timestampEnd: start + entry.time / 1000, websocketPayloadObserved: false, pending: false };
99
+ });
100
+ return { items, flowLimited: entries.length > maxFlows };
101
+ }
102
+ /** mitmdump's own log lines (termlog) for the facts an addon used to report. */
103
+ export function mitmdumpLog(output) {
104
+ const tlsFailures = [...output.matchAll(/(Client|Server) TLS handshake failed\.\s*(.*)/g)].slice(0, 64).map(m => ({ side: m[1].toLowerCase(), error: (m[2] || 'TLS handshake failed').slice(0, 4096) }));
105
+ const skipped = /Skipped (\d+) flows that weren't HTTP flows/.exec(output), readError = /(Failed to read .*|Flow file corrupted.*|Cannot load flows.*)/.exec(output);
106
+ return { tlsFailures, skippedFlows: skipped ? Number(skipped[1]) : 0, readError: readError ? readError[1].slice(0, 4096) : null };
107
+ }
108
+ /** Built-in mitmdump options only: savehar's `hardump`, save's `save_stream_file` and readfile's `rfile`; no addon script. */
109
+ export function mitmdumpArguments(mode, paths, port) {
110
+ return ['--set', 'confdir=' + paths.conf, '--set', 'flow_detail=0', '--set', 'termlog_verbosity=' + (mode === 'record' ? 'warn' : 'info'), '--set', 'body_size_limit=1m', '--set', 'websocket=false', '--set', 'rawtcp=false', '--set', 'hardump=' + paths.har,
111
+ ...(mode === 'record' ? ['--mode', 'regular', '--listen-host', '127.0.0.1', '--listen-port', String(port), '--set', 'save_stream_file=' + paths.capture] : ['--set', 'server=false', '--set', 'rfile=' + paths.input])];
112
+ }
82
113
  async function bridge(c, selected, w, mode, o, input) {
83
- const directory = join(c.appArguments.AppDataDirectory, 'runtime/mitmproxy/queries', randomUUID()), conf = join(directory, 'conf'), script = join(directory, 'bridge.py'), plan = join(directory, 'plan.json'), nonce = randomUUID(), bodyBytes = number(o.bodyBytes ?? 1024, 65536), maxFlows = number(o.maxFlows ?? 1000, 1000, 1), durationSeconds = mode === 'record' ? number(o.durationSeconds ?? 10, 300, 1) : undefined, port = mode === 'record' ? number(o.listenPort, 65535, 1) : undefined;
114
+ const directory = join(c.appArguments.AppDataDirectory, 'runtime/mitmproxy/queries', randomUUID()), conf = join(directory, 'conf'), har = join(directory, 'flows.har'), bodyBytes = number(o.bodyBytes ?? 1024, 65536), maxFlows = number(o.maxFlows ?? 1000, 1000, 1), durationSeconds = mode === 'record' ? number(o.durationSeconds ?? 10, 300, 1) : undefined, port = mode === 'record' ? number(o.listenPort, 65535, 1) : undefined;
84
115
  await mkdir(conf, { recursive: true, mode: 0o700 });
85
- await copyFile(join(native, 'bridge.py'), script, constants.COPYFILE_EXCL);
86
- const scriptSha = await fileSha256(script), capture = join(directory, 'capture.mitm'), caCertificate = join(conf, 'mitmproxy-ca-cert.pem');
87
- const arguments_ = ['--set', 'confdir=' + conf, '--set', 'flow_detail=0', '--set', 'termlog_verbosity=error', '--set', 'body_size_limit=1m', '--set', 'websocket=false', '--set', 'rawtcp=false', '-s', script, ...(mode === 'record' ? ['--mode', 'regular', '--listen-host', '127.0.0.1', '--listen-port', String(port)] : ['--set', 'server=false'])];
116
+ const capture = join(directory, 'capture.mitm'), caCertificate = join(conf, 'mitmproxy-ca-cert.pem');
117
+ const arguments_ = mitmdumpArguments(mode, { conf, har, capture, input: input?.path }, port);
88
118
  let upstreamCaSha256;
89
119
  if (o.upstreamCa) {
90
120
  const path = resolve(c.cwd, text(o.upstreamCa, 4096)), artifact = await w.artifacts.capture(path, 'input');
@@ -98,31 +128,23 @@ async function bridge(c, selected, w, mode, o, input) {
98
128
  await copyFile(await w.artifacts.verify(artifact), captured, constants.COPYFILE_EXCL);
99
129
  arguments_.push('--set', 'ssl_verify_upstream_trusted_ca=' + captured);
100
130
  }
101
- await atomicWrite(plan, { schema: 1, nonce, mode, bodyBytes, maxFlows, ...(mode === 'record' ? { durationSeconds, port } : { input: input.path }) });
131
+ // A record window ends with SIGTERM: mitmdump shuts down gracefully, so savehar and save write their files.
102
132
  let processResult;
103
133
  try {
104
- processResult = await runTool(c, { tool: 'mitmproxy', role: mode, installation: selected.id, executable: selected.executable, arguments: arguments_, environment: { HOME: join(directory, 'home'), INSIGHT_MITMPROXY_PLAN: plan }, nativeDeadline: true, timeoutMs: mode === 'record' ? durationSeconds * 1000 + 15000 : 60000, maxOutputBytes: 65536, target: input?.target, metadata: { mode, nonce, query: directory, bodyBytes, maxFlows, upstreamCaSha256, bridgeSha256: scriptSha, ...(mode === 'record' ? { listenHost: '127.0.0.1', listenPort: port, caCertificate, archive: capture, ready: join(directory, 'ready.json') } : { inputSha256: input.sha256 }) } });
134
+ processResult = await runTool(c, { tool: 'mitmproxy', role: mode, installation: selected.id, executable: selected.executable, arguments: arguments_, environment: { HOME: join(directory, 'home') }, nativeDeadline: true, timeoutMs: mode === 'record' ? durationSeconds * 1000 + 15000 : 60000, ...(mode === 'record' ? { stopAfterMs: durationSeconds * 1000 } : {}), maxOutputBytes: 1024 ** 2, target: input?.target, metadata: { mode, query: directory, bodyBytes, maxFlows, upstreamCaSha256, ...(mode === 'record' ? { listenHost: '127.0.0.1', listenPort: port, caCertificate, archive: capture } : { inputSha256: input.sha256 }) } });
105
135
  }
106
136
  catch (error) {
107
137
  if (error instanceof CliError)
108
138
  throw new CliError(error.message, { code: error.code, cause: error, result: { ...error.result, diagnostics: directory, retainedArchive: mode === 'record' ? capture : input.path, coverage: 'Interrupted or failed operation. Retained observations may be incomplete; no automatic recollection or traffic replay.', next: mode === 'record' ? ['insight-cli', 'mitmproxy', 'inspect', capture, '--json'] : undefined } });
109
139
  throw error;
110
140
  }
111
- if ((await stat(join(directory, 'result.json'))).size > 512 * 1024)
112
- fail('limit', 'Native observation receipt exceeds 512 KiB.');
113
- const receipt = await readJson(join(directory, 'result.json'));
114
- if (receipt?.schema !== 1 || receipt.nonce !== nonce || receipt.mode !== mode || typeof receipt.complete !== 'boolean' || !Number.isSafeInteger(receipt.httpFlows) || receipt.httpFlows < 0 || receipt.httpFlows > maxFlows)
115
- fail('partial', 'Native HTTP observation receipt could not be verified.', { diagnostics: directory, process: processResult.process });
116
- const report = join(directory, 'flows.jsonl');
117
- if ((await stat(report)).size > 8 * 1024 ** 2)
118
- fail('limit', 'Native HTTP report exceeds 8 MiB.');
119
- const lines = (await readFile(report, 'utf8')).trim().split('\n').map(line => JSON.parse(line)), header = lines.shift();
120
- if (header?.kind !== 'header' || header.schema !== 1 || header.nonce !== nonce || header.mode !== mode || lines.length !== receipt.httpFlows || lines.some(row => row.kind !== 'http' || typeof row.id !== 'string' || typeof row.request?.method !== 'string' || typeof row.request?.url !== 'string'))
121
- fail('partial', 'Native HTTP report does not match its completed receipt.', { diagnostics: directory });
122
- if (input && await fileSha256(input.path) !== input.sha256)
123
- fail('binding', 'Captured native flow input changed during inspection.');
124
- return { state: receipt.complete ? 'completed' : 'partial', complete: receipt.complete, reason: receipt.reason, skippedFlows: receipt.skippedFlows, pendingRequests: receipt.pendingRequests, error: receipt.error, tlsFailures: receipt.tlsFailures, upstreamCaSha256, process: processResult.process, elapsedMs: processResult.elapsedMs, diagnostics: directory, bodyBytes, maxFlows, items: lines, coverage: mode === 'record' ? 'One explicit loopback proxy observation window; HTTP request/response only. No system proxy/trust change, WebSocket payload or global absence claim. Native bodies are limited to 1 MiB each; archive to 64 MiB, JSON to 8 MiB.' : 'HTTP observations from one immutable native archive/HAR, bounded by max-flows/output. Partial/unsupported records and unavailable bodies remain unknown. An empty archive can reflect TLS/interception failure; retain its original window summary before inferring anything about traffic.', archive: mode === 'record' ? capture : undefined, ...(mode === 'record' ? { caCertificate, listenHost: '127.0.0.1', listenPort: port } : { target: input.target, inputSha256: input.sha256 }) };
141
+ if ((await stat(har)).size > 256 * 1024 ** 2)
142
+ fail('limit', 'mitmdump HAR output exceeds 256 MiB.', { diagnostics: directory, process: processResult.process });
143
+ const { items, flowLimited } = harObservations(JSON.parse(await readFile(har, 'utf8')), bodyBytes, maxFlows), log = mitmdumpLog(processResult.stdout + '\n' + processResult.stderr);
144
+ const [complete, reason] = log.readError ? [false, 'read_error'] : log.skippedFlows ? [false, 'unsupported_flow_types'] : flowLimited ? [false, 'flow_limit'] : log.tlsFailures.length ? [false, 'tls_handshake_failure'] : [true, mode === 'record' ? 'duration' : 'eof'];
145
+ return { state: complete ? 'completed' : 'partial', complete, reason, skippedFlows: log.skippedFlows, pendingRequests: null, error: log.readError, tlsFailures: log.tlsFailures, upstreamCaSha256, process: processResult.process, elapsedMs: processResult.elapsedMs, diagnostics: directory, bodyBytes, maxFlows, items, coverage: mode === 'record' ? 'One explicit loopback proxy observation window; HTTP request/response only. No system proxy/trust change, WebSocket payload or global absence claim. Native bodies are limited to 1 MiB each. Requests still in flight when the window closed are kept in the archive but not in these rows.' : 'HTTP observations from one immutable native archive/HAR, bounded by max-flows/output. Partial/unsupported records and unavailable bodies remain unknown. An empty archive can reflect TLS/interception failure; retain its original window summary before inferring anything about traffic.', archive: mode === 'record' ? capture : undefined, ...(mode === 'record' ? { caCertificate, listenHost: '127.0.0.1', listenPort: port } : { target: input.target, inputSha256: input.sha256 }) };
125
146
  }
147
+ const emptySha256 = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855';
126
148
  async function captureInput(c, w, path, targetId) { if (Boolean(path) === Boolean(targetId))
127
149
  fail('invalid', 'Supply one native flow archive/HAR path or --target.'); if (path) {
128
150
  const source = resolve(c.cwd, text(path, 4096)), info = await lstat(source);
@@ -131,9 +153,7 @@ async function captureInput(c, w, path, targetId) { if (Boolean(path) === Boolea
131
153
  await mkdir(directory, { recursive: true, mode: 0o700 });
132
154
  const copy = join(directory, 'empty.mitm');
133
155
  await copyFile(source, copy, constants.COPYFILE_EXCL);
134
- if ((await stat(copy)).size !== 0 || (await stat(source)).size !== 0)
135
- fail('binding', 'Empty archive changed while being captured.');
136
- return { path: copy, sha256: await fileSha256(copy), target: undefined };
156
+ return { path: copy, sha256: emptySha256, target: undefined };
137
157
  }
138
158
  } const target = path ? await w.importTarget(resolve(c.cwd, text(path, 4096))) : w.target(id(targetId, '--target')); if (target.input.size > 64 * 1024 ** 2)
139
159
  fail('limit', 'Native flow input exceeds 64 MiB.'); return { path: await w.artifacts.verify(target.input), target: target.id, sha256: target.binarySha256 }; }
@@ -149,12 +169,11 @@ export function mitmproxyCommands(workspace) {
149
169
  catch (error) {
150
170
  if (error.code !== 'ENOENT')
151
171
  throw error;
152
- } const w = workspace(c); return installer(c).use(async (selected) => { const result = await bridge(c, selected, w, 'record', o); if (result.reason === 'interrupted')
153
- throw new CliError('HTTP observation window was interrupted; inspect the retained archive explicitly.', { code: 'tool.interrupted', result: { state: 'partial', complete: false, reason: result.reason, process: result.process, diagnostics: result.diagnostics, retainedArchive: result.archive, totalFlows: result.items.length } }); const archiveSize = (await stat(result.archive)).size, target = archiveSize ? await w.importTarget(result.archive) : undefined; let output; if (o.output) {
172
+ } const w = workspace(c); return installer(c).use(async (selected) => { const result = await bridge(c, selected, w, 'record', o); const archiveSize = (await stat(result.archive)).size, target = archiveSize ? await w.importTarget(result.archive) : undefined; let output; if (o.output) {
154
173
  output = resolve(c.cwd, text(o.output, 4096));
155
174
  await mkdir(dirname(output), { recursive: true, mode: 0o700 });
156
175
  await copyFile(result.archive, output, constants.COPYFILE_EXCL);
157
- } const { items, ...base } = result; return { ...base, target: target?.id, inputSha256: target?.binarySha256 ?? await fileSha256(result.archive), archiveEmpty: archiveSize === 0, totalFlows: items.length, ...(output ? { output } : {}) }; }); }, { permission: Permission.Update, options: [...bounds, { flags: '--listen-port <port>', description: 'Required owned loopback HTTP proxy port' }, { flags: '--duration-seconds <seconds>', description: 'Observation window (1–300 seconds)', defaultValue: 10 }, { flags: '--upstream-ca <file>', description: 'Explicit public PEM CA for an owned HTTPS origin; never installed globally' }, { flags: '--output <file>', description: 'Copy completed native flow archive to a new ordinary file' }] }),
176
+ } const { items, ...base } = result; return { ...base, target: target?.id, inputSha256: target?.binarySha256 ?? emptySha256, archiveEmpty: archiveSize === 0, totalFlows: items.length, ...(output ? { output } : {}) }; }); }, { permission: Permission.Update, options: [...bounds, { flags: '--listen-port <port>', description: 'Required owned loopback HTTP proxy port' }, { flags: '--duration-seconds <seconds>', description: 'Observation window (1–300 seconds)', defaultValue: 10 }, { flags: '--upstream-ca <file>', description: 'Explicit public PEM CA for an owned HTTPS origin; never installed globally' }, { flags: '--output <file>', description: 'Copy completed native flow archive to a new ordinary file' }] }),
158
177
  command('inspect [input]', 'Read retained native flow/HAR evidence without reconnecting or replaying traffic', async ({ args, options: o }, c) => { supported(); const view = text(o.view ?? 'overview', 16); if (!['overview', 'flows', 'flow'].includes(view) || (view === 'flow') !== Boolean(o.flowId))
159
178
  fail('invalid', 'Use overview, flows or flow; only flow requires --flow-id.'); const limit = number(o.limit ?? 50, 1000, 1), offset = number(o.offset ?? 0, 1000000), w = workspace(c), input = await captureInput(c, w, args.input, o.target); return installer(c).use(async (selected) => { const result = await bridge(c, selected, w, 'inspect', o, input), { items: all, ...base } = result, items = all.filter(row => (!o.method || row.request.method === text(o.method, 32)) && (!o.urlContains || row.request.url.includes(text(o.urlContains, 4096))) && (!o.flowId || row.id === text(o.flowId, 128))); if (view === 'flow' && !items.length)
160
179
  fail(result.complete ? 'notFound' : 'partial', 'Flow identity was not found in the inspected bounded input prefix.'); if (o.output)
@@ -166,7 +185,7 @@ export function mitmproxyCommands(workspace) {
166
185
  statuses[status] = (statuses[status] ?? 0) + 1;
167
186
  }
168
187
  return { ...base, totalFlows: all.length, matchingFlows: items.length, methods, statuses, errors: items.filter(r => r.error).length, bodyPrefixesTruncated: items.filter(r => r.request.bodyTruncated || r.response?.bodyTruncated).length };
169
- } return { ...base, items: view === 'flow' ? items : items.slice(offset, offset + limit), total: items.length, limit, offset, truncated: view !== 'flow' && offset + limit < items.length }; }); }, { permission: Permission.Update, options: [...bounds, ...paging, { flags: '--target <id>', description: 'Reuse an immutable native flow/HAR target' }, { flags: '--view <kind>', description: 'overview, flows or flow', defaultValue: 'overview' }, { flags: '--flow-id <id>', description: 'Native flow UUID from this exact archive' }, { flags: '--method <name>', description: 'Literal HTTP method filter' }, { flags: '--url-contains <text>', description: 'Literal URL substring filter, applied before pagination' }, { flags: '--output <file>', description: 'Save the full bounded selected HTTP rows to a new JSON file' }] }),
188
+ } return { ...base, items: view === 'flow' ? items : items.slice(offset, offset + limit), total: items.length, limit, offset, truncated: view !== 'flow' && offset + limit < items.length }; }); }, { permission: Permission.Update, options: [...bounds, ...paging, { flags: '--target <id>', description: 'Reuse an immutable native flow/HAR target' }, { flags: '--view <kind>', description: 'overview, flows or flow', defaultValue: 'overview' }, { flags: '--flow-id <id>', description: 'Flow id (flow-<ordinal>) from this exact archive' }, { flags: '--method <name>', description: 'Literal HTTP method filter' }, { flags: '--url-contains <text>', description: 'Literal URL substring filter, applied before pagination' }, { flags: '--output <file>', description: 'Save the full bounded selected HTTP rows to a new JSON file' }] }),
170
189
  command('compare <left> <right>', 'Compare two retained HTTP observations without sending or replaying requests', async ({ args, options: o }, c) => { supported(); const limit = number(o.limit ?? 50, 1000, 1), offset = number(o.offset ?? 0, 1000000), w = workspace(c), left = await captureInput(c, w, args.left, undefined), right = await captureInput(c, w, args.right, undefined); return installer(c).use(async (selected) => { const a = await bridge(c, selected, w, 'inspect', o, left), b = await bridge(c, selected, w, 'inspect', o, right), compared = compareHttp(a.items, b.items), unknown = compared.items.some(row => row.state === 'unknown' || Array.isArray(row.unknown) && row.unknown.length), complete = a.complete && b.complete && !unknown, base = { state: complete ? 'completed' : 'partial', complete, left: { target: left.target, inputSha256: left.sha256, process: a.process, diagnostics: a.diagnostics, complete: a.complete }, right: { target: right.target, inputSha256: right.sha256, process: b.process, diagnostics: b.diagnostics, complete: b.complete }, unchanged: compared.unchanged, total: compared.items.length, scope: compared.scope }; if (o.output)
171
190
  return { ...base, ...await ordinary(c, o.output, { ...base, items: compared.items }) }; return { ...base, items: compared.items.slice(offset, offset + limit), limit, offset, truncated: offset + limit < compared.items.length }; }); }, { permission: Permission.Update, options: [...bounds, ...paging, { flags: '--output <file>', description: 'Save full bounded comparison to a new ordinary JSON file' }] })])];
172
191
  }
@@ -1,67 +1,3 @@
1
- export type State = 'queued' | 'applying' | 'staged' | 'checking_in' | 'publication_unknown' | 'published_verified' | 'conflict_pending' | 'failed';
2
- export interface Identity {
3
- profile: string;
4
- server: string;
5
- repository: string;
6
- programPath: string;
7
- binarySha256: string;
8
- language: string;
9
- compilerSpec: string;
10
- imageBase: string;
11
- }
12
- export interface Target extends Identity {
13
- id: string;
14
- lane: string;
15
- }
16
- export type CommentKind = 'eol' | 'pre' | 'post' | 'plate' | 'repeatable';
17
- export interface Finding {
18
- requestId: string;
19
- findingId: string;
20
- targetId: string;
21
- identity: Identity;
22
- workerId: string;
23
- baselineVersion: number;
24
- address: string;
25
- kind: CommentKind;
26
- before: string | null;
27
- after: string;
28
- evidence: string;
29
- resolves?: string;
30
- }
31
- export interface FindingRecord extends Finding {
32
- state: State;
33
- batchId?: string;
34
- conflict?: unknown;
35
- }
36
- export interface Binding {
37
- pid: number;
38
- endpoint: string;
39
- projectDirectory: string;
40
- identity: Identity;
41
- version: number;
42
- role: 'reader' | 'publisher';
43
- bridgeSecret?: string;
44
- bridgePid?: number;
45
- readEpoch?: string;
46
- openingVersion?: number;
47
- }
48
- export interface Batch {
49
- id: string;
50
- targetId: string;
51
- state: State;
52
- ownerPid: number;
53
- binding?: Binding;
54
- baselineVersion?: number;
55
- publishedVersion?: number;
56
- findings: FindingRecord[];
57
- detail?: unknown;
58
- }
59
- export interface Snapshot {
60
- identity: Identity;
61
- version: number;
62
- values: Record<string, string | null>;
63
- }
64
- export declare const key: (f: Pick<Finding, "address" | "kind">) => string;
65
1
  export declare const stable: (value: unknown) => string;
66
2
  export declare const digest: (value: unknown) => string;
67
3
  export declare function fail(code: string, message: string, result?: unknown): never;
@@ -73,12 +9,3 @@ export declare function text(value: unknown, max?: number): string;
73
9
  * in the message, which Factory redacts; the structured result names the option alone.
74
10
  */
75
11
  export declare function id(value: unknown, option?: string): string;
76
- export declare function version(value: unknown): number;
77
- export declare function identity(value: unknown): Identity;
78
- export declare function assertIdentity(actual: Identity, expected: Identity): void;
79
- export declare function finding(value: unknown): Finding;
80
- /** Diagnostic field identity; no merge policy. */
81
- export declare const fieldKey: (change: {
82
- address: string;
83
- field: string;
84
- }) => string;
package/dist/src/model.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { CliError } from '@eyeauras/cli-factory';
3
- export const key = (f) => `${f.address}:${f.kind}`;
4
3
  export const stable = (value) => JSON.stringify(value, (_key, item) => item && typeof item === 'object' && !Array.isArray(item)
5
4
  ? Object.fromEntries(Object.entries(item).sort(([a], [b]) => a.localeCompare(b))) : item);
6
5
  export const digest = (value) => createHash('sha256').update(stable(value)).digest('hex');
@@ -30,47 +29,3 @@ export function id(value, option) {
30
29
  fail('invalid', `${option ?? 'ID'} must use letters, digits, dot, underscore or hyphen; received ${JSON.stringify(result)}.`, option ? { option } : undefined);
31
30
  return result;
32
31
  }
33
- export function version(value) {
34
- if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 1)
35
- fail('invalid', 'Version must be a positive integer.');
36
- return value;
37
- }
38
- export function identity(value) {
39
- const o = object(value);
40
- const result = {
41
- profile: text(o.profile), server: text(o.server), repository: text(o.repository),
42
- programPath: text(o.programPath), binarySha256: text(o.binarySha256).toLowerCase(),
43
- language: text(o.language), compilerSpec: text(o.compilerSpec), imageBase: text(o.imageBase).toLowerCase(),
44
- };
45
- if (!/^ghidra:\/\/[^/]+$/.test(result.server) || /[@?#]/.test(result.server))
46
- fail('invalid', 'Server must be a ghidra://host:port origin without credentials.');
47
- if (/[\\/]/.test(result.repository) || result.repository.startsWith('.'))
48
- fail('invalid', 'Repository name must be a single non-hidden component.');
49
- if (!result.programPath.startsWith('/') || result.programPath.split('/').slice(1).some(p => !p || p.startsWith('.')))
50
- fail('invalid', 'Program path must be absolute with non-hidden components.');
51
- if (!/^[a-f0-9]{64}$/.test(result.binarySha256) || !/^[a-f0-9]+$/.test(result.imageBase))
52
- fail('invalid', 'SHA256 or image base is malformed.');
53
- return result;
54
- }
55
- export function assertIdentity(actual, expected) {
56
- if (stable(identity(actual)) !== stable(identity(expected)))
57
- fail('binding', 'Program, binary or connection identity does not match.');
58
- }
59
- export function finding(value) {
60
- const o = object(value);
61
- const kind = text(o.kind);
62
- if (!['eol', 'pre', 'post', 'plate', 'repeatable'].includes(kind))
63
- fail('invalid', 'Only scoped comment operations are supported.');
64
- const address = text(o.address).toLowerCase();
65
- if (!/^(?:[a-z0-9_]+:)?[a-f0-9]+$/.test(address))
66
- fail('invalid', 'An explicit hexadecimal address is required.');
67
- const comment = (v) => v === null ? null : typeof v === 'string' && v.length <= 16000 && !v.includes('\0') ? v : fail('invalid', 'Comment must be a string or null.');
68
- return {
69
- requestId: id(o.requestId), findingId: id(o.findingId), targetId: id(o.targetId),
70
- identity: identity(o.identity), workerId: id(o.workerId), baselineVersion: version(o.baselineVersion),
71
- address, kind, before: comment(o.before), after: text(o.after, 16000), evidence: text(o.evidence, 4000),
72
- ...(o.resolves === undefined ? {} : { resolves: id(o.resolves) }),
73
- };
74
- }
75
- /** Diagnostic field identity; no merge policy. */
76
- export const fieldKey = (change) => change.address + '@' + change.field;
@@ -1,4 +1,4 @@
1
1
  import { type CommandDefinition, type CommandContext } from '@eyeauras/cli-factory';
2
2
  import { Research } from './research.js';
3
- /** Concrete pinned edit leaves with durable intent and independent saved-state effect checks. */
3
+ /** Concrete pinned edit leaves; each runs on the context's worker. Edits reach the working copy on save, stop, merge or close. */
4
4
  export declare function mutationCommands(research: (context: CommandContext) => Research): CommandDefinition[];
@@ -2,13 +2,10 @@ import { readFileSync } from 'node:fs';
2
2
  import { command, Permission } from '@eyeauras/cli-factory';
3
3
  import { key, flag, parsed, option, selectedOptions } from './arguments.js';
4
4
  import { scope } from './research.js';
5
- import { id, fail } from './model.js';
6
- import { verifyMutation } from './mutation-effects.js';
5
+ import { fail } from './model.js';
7
6
  import { mutationInputs } from './mutation-inputs.js';
8
7
  const catalog = JSON.parse(readFileSync(new URL('../../references/mutations.json', import.meta.url), 'utf8'));
9
- if (catalog.source !== '57e37a8bf388b1279cff46378f85be1554548f61')
10
- throw Error('Installed mutation contracts differ from the pinned build.');
11
- /** Concrete pinned edit leaves with durable intent and independent saved-state effect checks. */
8
+ /** Concrete pinned edit leaves; each runs on the context's worker. Edits reach the working copy on save, stop, merge or close. */
12
9
  export function mutationCommands(research) {
13
10
  const groups = new Map();
14
11
  for (const m of catalog.tools) {
@@ -41,13 +38,11 @@ export function mutationCommands(research) {
41
38
  parsed({ name: 'address', type: 'string', required: true, semantic: 'address' }, item.address);
42
39
  }
43
40
  }
44
- const selected = scope(o), request = o.requestId === undefined ? undefined : id(o.requestId, '--request-id');
41
+ const selected = scope(o);
45
42
  mutationInputs(m.path, values);
46
- if (['/set_program_option', '/remove_program_option'].includes(m.path) && values.group === 'Program Information' && values.name === 'Executable SHA256')
47
- fail('binding', 'The immutable consumed input identity cannot be rewritten as a program option.');
48
- return research(c).mutate(selected, m.path, values, async (_backend, response) => response, request, (backend, snapshot, response) => verifyMutation(backend, snapshot, m.path, values, response));
43
+ return research(c).mutate(selected, m.path, values);
49
44
  }, { permission: m.access === 'DESTRUCTIVE' || ['/recreate_struct', '/resize_struct', '/clone_data_type', '/set_global'].includes(m.path) ? 'Destructive' : Permission.Update,
50
- options: [...selectedOptions, ...options, { flags: '--request-id <id>', description: 'Retrieve this changing intent after a lost response' }] }));
45
+ options: [...selectedOptions, ...options] }));
51
46
  }
52
47
  return [...groups].map(([name, children]) => command(name, `${name} changes`, children));
53
48
  }
@@ -0,0 +1,130 @@
1
+ import type { GhidraEndpoint } from '../hub/contract.js';
2
+ /** A repository on a Ghidra Server reached through the hub. */
3
+ export interface RepositoryRef extends GhidraEndpoint {
4
+ repository: string;
5
+ }
6
+ /** A working copy: a private Ghidra project directory holding one checkout of one program. */
7
+ export interface WorkingCopy {
8
+ root: string;
9
+ programPath: string;
10
+ }
11
+ export interface CheckoutStatus {
12
+ /** False when the working copy has no project or no checkout yet. */
13
+ checkedOut: boolean;
14
+ /** Version the checkout is based on. */
15
+ version: number;
16
+ /** Latest version on the server. */
17
+ latestVersion: number;
18
+ /** Ghidra's modified flag of the checked-out file (unsaved-to-server work exists). */
19
+ modified: boolean;
20
+ checkoutId: string | null;
21
+ }
22
+ export type NativeConflict = {
23
+ state: 'conflict';
24
+ conflicts: number;
25
+ summary: string;
26
+ };
27
+ export interface NativeWorker {
28
+ pid: number;
29
+ /** Program path the worker serves (optional for fakes). */
30
+ program?: string;
31
+ /** Calls the GhidraMCP bridge of this worker (loopback HTTP, no token). */
32
+ request(method: 'GET' | 'POST', path: string, parameters: Record<string, unknown>): Promise<unknown>;
33
+ /** Saves the program into the working copy (not to the server). */
34
+ save(): Promise<void>;
35
+ stop(): Promise<void>;
36
+ /** Resolves when the worker process has exited, whether stopped or crashed. */
37
+ readonly exited?: Promise<void>;
38
+ /**
39
+ * NativeGhidra.checkin / update on the open program, which stays open: Ghidra moves it onto the new version. The caller
40
+ * saves first. `undefined` = this worker cannot (another repository address, a lost check-in, an open transaction);
41
+ * the caller stops it and uses NativeGhidra. Optional for fakes.
42
+ */
43
+ checkin?(repository: RepositoryRef, comment: string): Promise<{
44
+ state: 'published' | 'unchanged';
45
+ version: number;
46
+ } | NativeConflict | undefined>;
47
+ update?(repository: RepositoryRef): Promise<{
48
+ state: 'updated' | 'current';
49
+ version: number;
50
+ } | NativeConflict | undefined>;
51
+ /** True when the open program has edits not yet saved into the working copy. Optional for fakes. */
52
+ changed?(): Promise<boolean>;
53
+ }
54
+ /** Explicit loader choices for the first import of a program (all optional). */
55
+ export interface LoaderInputs {
56
+ language?: string;
57
+ compilerSpec?: string;
58
+ imageBase?: string;
59
+ loader?: string;
60
+ loaderOptions?: Record<string, string | number | boolean>;
61
+ }
62
+ export interface NativeGhidra {
63
+ /** Installation and managed extension roots (script inventory); optional for fakes. */
64
+ readonly ghidraHome?: string;
65
+ /** Java of the runtime; with ghidraHome it is offered to a local hub that has no runtime yet. Optional for fakes. */
66
+ readonly java?: string;
67
+ readonly extensionRoots?: readonly string[];
68
+ /** Runs one file-level helper (InsightSdkFiles, InsightFunctionDatabases, InsightVersionTracking) in the native host; returns its value. */
69
+ helper?(main: string, request: Record<string, unknown>, timeoutMs?: number): Promise<unknown>;
70
+ /** Writes version `version` (0 = latest) of programPath from the repository as a packed GZF file. */
71
+ exportVersion?(repository: RepositoryRef, programPath: string, version: number, output: string): Promise<{
72
+ version: number;
73
+ }>;
74
+ /** True if the program exists in the repository. */
75
+ exists(repository: RepositoryRef, programPath: string): Promise<boolean>;
76
+ /**
77
+ * Imports `file`, optionally runs auto-analysis, and creates version 1 at programPath.
78
+ * Atomic first-writer-wins: if the item already exists (another machine won), the local import is
79
+ * discarded and the result is 'exists'.
80
+ */
81
+ importPublish(input: {
82
+ repository: RepositoryRef;
83
+ file: string;
84
+ programPath: string;
85
+ name: string;
86
+ analysis: boolean;
87
+ timeoutSeconds?: number;
88
+ loader?: LoaderInputs;
89
+ }): Promise<{
90
+ state: 'published' | 'exists';
91
+ version: number;
92
+ }>;
93
+ /**
94
+ * Ensures the working copy holds a checkout of programPath. Idempotent: an existing copy is kept,
95
+ * re-bound to the current repository address (ProjectData.updateRepositoryInfo) and its Ghidra recovery
96
+ * data is applied. Creates the project and checks out the latest version otherwise.
97
+ */
98
+ checkout(repository: RepositoryRef, copy: WorkingCopy): Promise<CheckoutStatus>;
99
+ status(repository: RepositoryRef, copy: WorkingCopy): Promise<CheckoutStatus>;
100
+ /**
101
+ * Starts a headless (or GUI) worker on the working copy. At most one worker per copy. It needs no server: the copy keeps
102
+ * the address it is bound to, and its checkin/update decline another address, so the caller re-binds through checkout.
103
+ */
104
+ startWorker(copy: WorkingCopy, mode: 'headless' | 'gui'): Promise<NativeWorker>;
105
+ /**
106
+ * Publishes the working copy's changes with Ghidra's native merge, keeping the checkout.
107
+ * Unmodified copy -> 'unchanged' with the current version (this is what makes repeats safe).
108
+ * The caller stops the copy's worker first, or uses NativeWorker.checkin.
109
+ */
110
+ checkin(repository: RepositoryRef, copy: WorkingCopy, comment: string): Promise<{
111
+ state: 'published' | 'unchanged';
112
+ version: number;
113
+ } | NativeConflict>;
114
+ /** Merges newer server versions into the working copy (Ghidra Update). Caller stops the worker first, or uses NativeWorker.update. */
115
+ update(repository: RepositoryRef, copy: WorkingCopy): Promise<{
116
+ state: 'updated' | 'current';
117
+ version: number;
118
+ } | NativeConflict>;
119
+ /** Drops local changes: undo checkout and check out the latest version again. Caller stops the worker first. */
120
+ discard(repository: RepositoryRef, copy: WorkingCopy): Promise<CheckoutStatus>;
121
+ /**
122
+ * Undoes the checkout and deletes the working copy. Refuses a modified copy with `native.modified` unless force;
123
+ * `modified` says whether forced release dropped unpublished changes.
124
+ */
125
+ release(repository: RepositoryRef, copy: WorkingCopy, force: boolean): Promise<{
126
+ modified: boolean;
127
+ }>;
128
+ /** Stops the layer's long-lived Ghidra JVM after its running operations (owner shutdown, runtime change). Optional for fakes. */
129
+ close?(): Promise<void>;
130
+ }