@eyeauras/insight-cli 0.1.0 → 0.2.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 (391) hide show
  1. package/.cli-package-build.json +1 -1
  2. package/README.md +33 -2
  3. package/SKILL.md +38 -51
  4. package/dist/src/administration-results.js +1 -1
  5. package/dist/src/administration.d.ts +1 -1
  6. package/dist/src/administration.js +16 -2
  7. package/dist/src/binary.d.ts +3 -0
  8. package/dist/src/binary.js +74 -0
  9. package/dist/src/capture.d.ts +3 -0
  10. package/dist/src/capture.js +220 -0
  11. package/dist/src/cli.js +91 -14
  12. package/dist/src/contexts.d.ts +5 -0
  13. package/dist/src/contexts.js +54 -18
  14. package/dist/src/debugger-caller.d.ts +17 -0
  15. package/dist/src/debugger-caller.js +129 -0
  16. package/dist/src/debugger-launch.d.ts +2 -0
  17. package/dist/src/debugger-launch.js +17 -0
  18. package/dist/src/debugger-results.d.ts +1 -0
  19. package/dist/src/debugger-results.js +8 -0
  20. package/dist/src/debugger-supervisor.js +56 -13
  21. package/dist/src/debugger.js +16 -7
  22. package/dist/src/die.d.ts +12 -0
  23. package/dist/src/die.js +127 -0
  24. package/dist/src/dnspy-runtime.d.ts +8 -0
  25. package/dist/src/dnspy-runtime.js +46 -0
  26. package/dist/src/dnspy.d.ts +22 -0
  27. package/dist/src/dnspy.js +160 -0
  28. package/dist/src/dotnet-diagnostics.d.ts +13 -0
  29. package/dist/src/dotnet-diagnostics.js +101 -0
  30. package/dist/src/frida-worker.d.ts +1 -0
  31. package/dist/src/frida-worker.js +125 -0
  32. package/dist/src/frida.d.ts +16 -0
  33. package/dist/src/frida.js +125 -0
  34. package/dist/src/ghidra-debugger-runtime.d.ts +7 -0
  35. package/dist/src/ghidra-debugger-runtime.js +31 -0
  36. package/dist/src/ghidra-processes.d.ts +6 -0
  37. package/dist/src/ghidra-processes.js +121 -0
  38. package/dist/src/ghidra.js +6 -6
  39. package/dist/src/ilspy.d.ts +7 -0
  40. package/dist/src/ilspy.js +122 -0
  41. package/dist/src/lifecycle.d.ts +1 -1
  42. package/dist/src/lifecycle.js +8 -2
  43. package/dist/src/lldb.d.ts +10 -0
  44. package/dist/src/lldb.js +99 -0
  45. package/dist/src/llvm.d.ts +6 -0
  46. package/dist/src/llvm.js +133 -0
  47. package/dist/src/managed-heap.d.ts +4 -0
  48. package/dist/src/managed-heap.js +73 -0
  49. package/dist/src/managed-metadata.d.ts +11 -0
  50. package/dist/src/managed-metadata.js +66 -0
  51. package/dist/src/mitmproxy.d.ts +55 -0
  52. package/dist/src/mitmproxy.js +172 -0
  53. package/dist/src/native-inputs.d.ts +3 -2
  54. package/dist/src/native-inputs.js +21 -5
  55. package/dist/src/package-version.d.ts +1 -0
  56. package/dist/src/package-version.js +3 -0
  57. package/dist/src/procmon-config.d.ts +2 -0
  58. package/dist/src/procmon-config.js +15 -0
  59. package/dist/src/procmon-events.d.ts +13 -0
  60. package/dist/src/procmon-events.js +82 -0
  61. package/dist/src/procmon.d.ts +4 -0
  62. package/dist/src/procmon.js +107 -0
  63. package/dist/src/research.d.ts +11 -2
  64. package/dist/src/research.js +5 -3
  65. package/dist/src/runtime-catalog.d.ts +13 -0
  66. package/dist/src/runtime-catalog.js +26 -0
  67. package/dist/src/runtime-manager.d.ts +125 -0
  68. package/dist/src/runtime-manager.js +385 -0
  69. package/dist/src/runtime-selection.d.ts +13 -0
  70. package/dist/src/runtime-selection.js +42 -0
  71. package/dist/src/server.d.ts +15 -0
  72. package/dist/src/server.js +77 -96
  73. package/dist/src/sevenzip.d.ts +15 -0
  74. package/dist/src/sevenzip.js +119 -0
  75. package/dist/src/strace.d.ts +10 -0
  76. package/dist/src/strace.js +71 -0
  77. package/dist/src/text-window.d.ts +11 -0
  78. package/dist/src/text-window.js +6 -0
  79. package/dist/src/tool-runtime/archives.d.ts +10 -0
  80. package/dist/src/tool-runtime/archives.js +194 -0
  81. package/dist/src/tool-runtime/catalog.d.ts +3 -0
  82. package/dist/src/tool-runtime/catalog.js +13 -0
  83. package/dist/src/tool-runtime/commands.d.ts +9 -0
  84. package/dist/src/tool-runtime/commands.js +39 -0
  85. package/dist/src/tool-runtime/deadline.d.ts +11 -0
  86. package/dist/src/tool-runtime/deadline.js +32 -0
  87. package/dist/src/tool-runtime/definition.d.ts +73 -0
  88. package/dist/src/tool-runtime/definition.js +49 -0
  89. package/dist/src/tool-runtime/dotnet.d.ts +4 -0
  90. package/dist/src/tool-runtime/dotnet.js +22 -0
  91. package/dist/src/tool-runtime/identity.d.ts +6 -0
  92. package/dist/src/tool-runtime/identity.js +50 -0
  93. package/dist/src/tool-runtime/installer.d.ts +101 -0
  94. package/dist/src/tool-runtime/installer.js +180 -0
  95. package/dist/src/tool-runtime/launch-worker.d.ts +1 -0
  96. package/dist/src/tool-runtime/launch-worker.js +58 -0
  97. package/dist/src/tool-runtime/run.d.ts +51 -0
  98. package/dist/src/tool-runtime/run.js +159 -0
  99. package/dist/src/tool-runtime/store.d.ts +15 -0
  100. package/dist/src/tool-runtime/store.js +219 -0
  101. package/dist/src/tool-runtime/supervisor.d.ts +57 -0
  102. package/dist/src/tool-runtime/supervisor.js +266 -0
  103. package/dist/src/tool-runtime/windows-job.d.ts +22 -0
  104. package/dist/src/tool-runtime/windows-job.js +43 -0
  105. package/dist/src/toolbox.d.ts +84 -0
  106. package/dist/src/toolbox.js +35 -0
  107. package/dist/src/tshark.d.ts +23 -0
  108. package/dist/src/tshark.js +174 -0
  109. package/dist/src/windbg.d.ts +14 -0
  110. package/dist/src/windbg.js +119 -0
  111. package/dist/src/workspace.d.ts +1 -0
  112. package/dist/src/workspace.js +6 -0
  113. package/package.json +7 -4
  114. package/references/administration.md +2 -1
  115. package/references/agent-execution.md +36 -0
  116. package/references/agent-setup.md +61 -0
  117. package/references/artifacts.md +5 -0
  118. package/references/debugger.md +22 -0
  119. package/references/ilspy.md +33 -0
  120. package/references/managed-runtime.md +157 -0
  121. package/references/native/InsightPythonWheels.java +283 -2
  122. package/references/native/InsightRuntimeDoctor.java +33 -0
  123. package/references/native/InsightTraceState.java +28 -13
  124. package/references/setup.md +6 -3
  125. package/runtime/managed/insight-heap/Azure.Core.dll +0 -0
  126. package/runtime/managed/insight-heap/Azure.Identity.dll +0 -0
  127. package/runtime/managed/insight-heap/Insight.Heap.csproj +1 -0
  128. package/runtime/managed/insight-heap/Insight.Heap.deps.json +391 -0
  129. package/runtime/managed/insight-heap/Insight.Heap.dll +0 -0
  130. package/runtime/managed/insight-heap/Insight.Heap.runtimeconfig.json +13 -0
  131. package/runtime/managed/insight-heap/Microsoft.Bcl.AsyncInterfaces.dll +0 -0
  132. package/runtime/managed/insight-heap/Microsoft.Diagnostics.NETCore.Client.dll +0 -0
  133. package/runtime/managed/insight-heap/Microsoft.Diagnostics.Runtime.dll +0 -0
  134. package/runtime/managed/insight-heap/Microsoft.Extensions.Configuration.Abstractions.dll +0 -0
  135. package/runtime/managed/insight-heap/Microsoft.Extensions.DependencyInjection.Abstractions.dll +0 -0
  136. package/runtime/managed/insight-heap/Microsoft.Extensions.Diagnostics.Abstractions.dll +0 -0
  137. package/runtime/managed/insight-heap/Microsoft.Extensions.FileProviders.Abstractions.dll +0 -0
  138. package/runtime/managed/insight-heap/Microsoft.Extensions.Hosting.Abstractions.dll +0 -0
  139. package/runtime/managed/insight-heap/Microsoft.Extensions.Logging.Abstractions.dll +0 -0
  140. package/runtime/managed/insight-heap/Microsoft.Extensions.Options.dll +0 -0
  141. package/runtime/managed/insight-heap/Microsoft.Extensions.Primitives.dll +0 -0
  142. package/runtime/managed/insight-heap/Microsoft.Identity.Client.Extensions.Msal.dll +0 -0
  143. package/runtime/managed/insight-heap/Microsoft.Identity.Client.dll +0 -0
  144. package/runtime/managed/insight-heap/Microsoft.IdentityModel.Abstractions.dll +0 -0
  145. package/runtime/managed/insight-heap/Microsoft.Security.AntiSSRF.dll +0 -0
  146. package/runtime/managed/insight-heap/NuGet.Config +1 -0
  147. package/runtime/managed/insight-heap/Program.cs +20 -0
  148. package/runtime/managed/insight-heap/README.md +16 -0
  149. package/runtime/managed/insight-heap/System.ClientModel.dll +0 -0
  150. package/runtime/managed/insight-heap/System.Memory.Data.dll +0 -0
  151. package/runtime/managed/insight-heap/System.Security.Cryptography.ProtectedData.dll +0 -0
  152. package/runtime/managed/insight-heap/dependencies.json +436 -0
  153. package/runtime/managed/insight-heap/notices/Azure.Core-LICENSE.txt +21 -0
  154. package/runtime/managed/insight-heap/notices/Azure.Identity-LICENSE.txt +21 -0
  155. package/runtime/managed/insight-heap/notices/Microsoft.Bcl.AsyncInterfaces-LICENSE.txt +23 -0
  156. package/runtime/managed/insight-heap/notices/Microsoft.Bcl.AsyncInterfaces-THIRD-PARTY-NOTICES.TXT +1418 -0
  157. package/runtime/managed/insight-heap/notices/Microsoft.Diagnostics.NETCore.Client-LICENSE.txt +23 -0
  158. package/runtime/managed/insight-heap/notices/Microsoft.Diagnostics.Runtime-LICENSE.txt +23 -0
  159. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Configuration.Abstractions-LICENSE.txt +23 -0
  160. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Configuration.Abstractions-THIRD-PARTY-NOTICES.TXT +1418 -0
  161. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.DependencyInjection.Abstractions-LICENSE.txt +23 -0
  162. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.DependencyInjection.Abstractions-THIRD-PARTY-NOTICES.TXT +1418 -0
  163. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Diagnostics.Abstractions-LICENSE.txt +23 -0
  164. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Diagnostics.Abstractions-THIRD-PARTY-NOTICES.TXT +1418 -0
  165. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.FileProviders.Abstractions-LICENSE.txt +23 -0
  166. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.FileProviders.Abstractions-THIRD-PARTY-NOTICES.TXT +1418 -0
  167. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Hosting.Abstractions-LICENSE.txt +23 -0
  168. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Hosting.Abstractions-THIRD-PARTY-NOTICES.TXT +1418 -0
  169. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Logging.Abstractions-LICENSE.txt +23 -0
  170. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Logging.Abstractions-THIRD-PARTY-NOTICES.TXT +1418 -0
  171. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Options-LICENSE.txt +23 -0
  172. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Options-THIRD-PARTY-NOTICES.TXT +1418 -0
  173. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Primitives-LICENSE.txt +23 -0
  174. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Primitives-THIRD-PARTY-NOTICES.TXT +1418 -0
  175. package/runtime/managed/insight-heap/notices/Microsoft.Identity.Client-LICENSE.txt +21 -0
  176. package/runtime/managed/insight-heap/notices/Microsoft.Identity.Client.Extensions.Msal-LICENSE.txt +21 -0
  177. package/runtime/managed/insight-heap/notices/Microsoft.IdentityModel.Abstractions-LICENSE.txt +21 -0
  178. package/runtime/managed/insight-heap/notices/Microsoft.Security.AntiSSRF-LICENSE.txt +21 -0
  179. package/runtime/managed/insight-heap/notices/System.ClientModel-LICENSE.txt +21 -0
  180. package/runtime/managed/insight-heap/notices/System.Memory.Data-LICENSE.txt +23 -0
  181. package/runtime/managed/insight-heap/notices/System.Memory.Data-THIRD-PARTY-NOTICES.TXT +1418 -0
  182. package/runtime/managed/insight-heap/notices/System.Security.Cryptography.ProtectedData-LICENSE.TXT +23 -0
  183. package/runtime/managed/insight-heap/notices/System.Security.Cryptography.ProtectedData-THIRD-PARTY-NOTICES.TXT +309 -0
  184. package/runtime/managed/insight-heap/packages.lock.json +165 -0
  185. package/runtime/managed/insight-heap/provenance.json +146 -0
  186. package/runtime/managed/insight-heap/runtimes/win/lib/netstandard2.0/System.Security.Cryptography.ProtectedData.dll +0 -0
  187. package/runtime/managed/insight-managed/Insight.Managed.csproj +4 -0
  188. package/runtime/managed/insight-managed/Insight.Managed.deps.json +41 -0
  189. package/runtime/managed/insight-managed/Insight.Managed.dll +0 -0
  190. package/runtime/managed/insight-managed/Insight.Managed.runtimeconfig.json +13 -0
  191. package/runtime/managed/insight-managed/LICENSE.dnlib.txt +20 -0
  192. package/runtime/managed/insight-managed/NuGet.Config +1 -0
  193. package/runtime/managed/insight-managed/Program.cs +31 -0
  194. package/runtime/managed/insight-managed/README.md +16 -0
  195. package/runtime/managed/insight-managed/dnlib.dll +0 -0
  196. package/runtime/managed/insight-managed/packages.lock.json +13 -0
  197. package/runtime/managed/insight-managed/provenance.json +40 -0
  198. package/runtime/native/binary/README.md +22 -0
  199. package/runtime/native/binary/dependencies.json +166 -0
  200. package/runtime/native/binary/helper.cpp +44 -0
  201. package/runtime/native/binary/insight-binary-darwin-arm64 +0 -0
  202. package/runtime/native/binary/notices/Catch2-3.12.0--Catch2-3.12.0__LICENSE.txt +23 -0
  203. package/runtime/native/binary/notices/LIEF-LICENSE.txt +202 -0
  204. package/runtime/native/binary/notices/LIEF-attribution.txt +37 -0
  205. package/runtime/native/binary/notices/Melkor_ELF_Fuzzer-ac2495b--elf_fuzzer-master__LICENSE.txt +674 -0
  206. package/runtime/native/binary/notices/expected-1.3.1--expected-1.3.1__COPYING +121 -0
  207. package/runtime/native/binary/notices/frozen-61dce5a--frozen-61dce5ae18ca59931e27675c468e64118aba8744__AUTHORS +3 -0
  208. package/runtime/native/binary/notices/frozen-61dce5a--frozen-61dce5ae18ca59931e27675c468e64118aba8744__LICENSE +202 -0
  209. package/runtime/native/binary/notices/json-LICENSE.MIT +21 -0
  210. package/runtime/native/binary/notices/mbedtls-4.0.0.r0.gec4044008d--LICENSE +553 -0
  211. package/runtime/native/binary/notices/mbedtls-4.0.0.r0.gec4044008d--framework__LICENSE +553 -0
  212. package/runtime/native/binary/notices/mbedtls-4.0.0.r0.gec4044008d--tf-psa-crypto__LICENSE +552 -0
  213. package/runtime/native/binary/notices/mbedtls-4.0.0.r0.gec4044008d--tf-psa-crypto__framework__LICENSE +553 -0
  214. package/runtime/native/binary/notices/nanobind-2.13.0.r18.g4db9ed3f--LICENSE +26 -0
  215. package/runtime/native/binary/notices/nanobind-2.13.0.r18.g4db9ed3f--ext__robin_map__LICENSE +21 -0
  216. package/runtime/native/binary/notices/span-LICENSE_1_0.txt +23 -0
  217. package/runtime/native/binary/notices/span-attribution.txt +11 -0
  218. package/runtime/native/binary/notices/spdlog-1.17.0--spdlog-1.17.0__LICENSE +25 -0
  219. package/runtime/native/binary/notices/utfcpp-4.0.9--utfcpp-4.0.9__LICENSE +23 -0
  220. package/runtime/native/binary/provenance.json +48 -0
  221. package/runtime/native/child-deadline-linux-x64 +0 -0
  222. package/runtime/native/child-deadline-linux.c +24 -0
  223. package/runtime/native/child-deadline-linux.provenance.json +17 -0
  224. package/runtime/native/deadline-alarm-darwin-universal.dylib +0 -0
  225. package/runtime/native/deadline-alarm.c +33 -0
  226. package/runtime/native/deadline-alarm.provenance.json +22 -0
  227. package/runtime/native/deadline-exec-darwin-arm64 +0 -0
  228. package/runtime/native/deadline-exec.c +24 -0
  229. package/runtime/native/deadline-exec.provenance.json +17 -0
  230. package/runtime/native/dnspy-extension/Bridge.cs +58 -0
  231. package/runtime/native/dnspy-extension/Insight.DnSpy.csproj +13 -0
  232. package/runtime/native/dnspy-extension/Insight.DnSpy.x.dll +0 -0
  233. package/runtime/native/dnspy-extension/NuGet.Config +1 -0
  234. package/runtime/native/dnspy-extension/UNICODE-LOADER.md +26 -0
  235. package/runtime/native/dnspy-extension/packages.lock.json +6 -0
  236. package/runtime/native/dnspy-extension/provenance.json +27 -0
  237. package/runtime/native/dnspy-extension/upstream-public-build.snk +0 -0
  238. package/runtime/native/dnspy-extension/vendor-files.json +4341 -0
  239. package/runtime/native/file-version.ps1 +7 -0
  240. package/runtime/native/insight-registry-win-x64.dll +0 -0
  241. package/runtime/native/mitmproxy/bridge.py +180 -0
  242. package/runtime/native/mitmproxy/notices.json +476 -0
  243. package/runtime/native/sources/detours-LICENSE.md +23 -0
  244. package/runtime/native/sources/detours-e4bfd6b.tar.gz +0 -0
  245. package/runtime/native/sources/detours-provenance.json +10 -0
  246. package/runtime/native/tshark-layout.json +2247 -0
  247. package/runtime/native/windows-job/DirectoryAlias.cs +24 -0
  248. package/runtime/native/windows-job/Insight.WindowsJob.csproj +1 -0
  249. package/runtime/native/windows-job/Insight.WindowsJob.dll +0 -0
  250. package/runtime/native/windows-job/NuGet.Config +1 -0
  251. package/runtime/native/windows-job/OwnedJob.cs +79 -0
  252. package/runtime/native/windows-job/RegistryRedirect.cs +45 -0
  253. package/runtime/native/windows-job/packages.lock.json +21 -0
  254. package/runtime/native/windows-job/provenance.json +16 -0
  255. package/runtime/native/windows-job/windows-job.ps1 +8 -0
  256. package/runtime/native/windows-registry.c +21 -0
  257. package/runtime/native/windows-registry.def +3 -0
  258. package/runtime/native/windows-registry.provenance.json +14 -0
  259. package/runtime/notices/diagnostics-10.0.750501.txt +23 -0
  260. package/runtime/tool-catalog.json +290 -0
  261. package/runtime/toolbox.json +1401 -0
  262. package/skill-bundle/insight-artifacts/SKILL.md +30 -0
  263. package/skill-bundle/insight-artifacts/references/agent-execution.md +36 -0
  264. package/skill-bundle/insight-artifacts/references/artifacts.md +52 -0
  265. package/skill-bundle/insight-binary/SKILL.md +46 -0
  266. package/skill-bundle/insight-binary/references/agent-execution.md +36 -0
  267. package/skill-bundle/insight-capture/SKILL.md +56 -0
  268. package/skill-bundle/insight-capture/references/agent-execution.md +36 -0
  269. package/skill-bundle/insight-cli/SKILL.md +42 -0
  270. package/skill-bundle/insight-cli/references/agent-execution.md +36 -0
  271. package/skill-bundle/insight-cli/references/agent-setup.md +61 -0
  272. package/skill-bundle/insight-die/SKILL.md +49 -0
  273. package/skill-bundle/insight-die/references/agent-execution.md +36 -0
  274. package/skill-bundle/insight-dnspy/SKILL.md +65 -0
  275. package/skill-bundle/insight-dnspy/references/agent-execution.md +36 -0
  276. package/skill-bundle/insight-dotnet-dump/SKILL.md +46 -0
  277. package/skill-bundle/insight-dotnet-dump/references/agent-execution.md +36 -0
  278. package/skill-bundle/insight-dotnet-stack/SKILL.md +39 -0
  279. package/skill-bundle/insight-dotnet-stack/references/agent-execution.md +36 -0
  280. package/skill-bundle/insight-dotnet-trace/SKILL.md +45 -0
  281. package/skill-bundle/insight-dotnet-trace/references/agent-execution.md +36 -0
  282. package/skill-bundle/insight-frida/SKILL.md +67 -0
  283. package/skill-bundle/insight-frida/references/agent-execution.md +36 -0
  284. package/skill-bundle/insight-ghidra/SKILL.md +91 -0
  285. package/skill-bundle/insight-ghidra/references/administration.md +34 -0
  286. package/skill-bundle/insight-ghidra/references/agent-execution.md +36 -0
  287. package/skill-bundle/insight-ghidra/references/archive.md +32 -0
  288. package/skill-bundle/insight-ghidra/references/artifacts.md +52 -0
  289. package/skill-bundle/insight-ghidra/references/debugger.md +62 -0
  290. package/skill-bundle/insight-ghidra/references/extensions-and-sync.md +124 -0
  291. package/skill-bundle/insight-ghidra/references/managed-runtime.md +157 -0
  292. package/skill-bundle/insight-ghidra/references/native-workflows.md +112 -0
  293. package/skill-bundle/insight-ghidra/references/query-semantics.md +96 -0
  294. package/skill-bundle/insight-ghidra/references/recovery.md +53 -0
  295. package/skill-bundle/insight-ghidra/references/research.md +101 -0
  296. package/skill-bundle/insight-ghidra/references/setup.md +50 -0
  297. package/skill-bundle/insight-ilspy/SKILL.md +45 -0
  298. package/skill-bundle/insight-ilspy/references/agent-execution.md +36 -0
  299. package/skill-bundle/insight-ilspy/references/ilspy.md +33 -0
  300. package/skill-bundle/insight-interop/SKILL.md +54 -0
  301. package/skill-bundle/insight-interop/references/agent-execution.md +36 -0
  302. package/skill-bundle/insight-lldb/SKILL.md +54 -0
  303. package/skill-bundle/insight-lldb/references/agent-execution.md +36 -0
  304. package/skill-bundle/insight-llvm/SKILL.md +56 -0
  305. package/skill-bundle/insight-llvm/references/agent-execution.md +36 -0
  306. package/skill-bundle/insight-managed-heap/SKILL.md +43 -0
  307. package/skill-bundle/insight-managed-heap/references/agent-execution.md +36 -0
  308. package/skill-bundle/insight-managed-metadata/SKILL.md +52 -0
  309. package/skill-bundle/insight-managed-metadata/references/agent-execution.md +36 -0
  310. package/skill-bundle/insight-mitmproxy/SKILL.md +62 -0
  311. package/skill-bundle/insight-mitmproxy/references/agent-execution.md +36 -0
  312. package/skill-bundle/insight-overview/SKILL.md +79 -0
  313. package/skill-bundle/insight-overview/references/agent-execution.md +36 -0
  314. package/skill-bundle/insight-procmon/SKILL.md +49 -0
  315. package/skill-bundle/insight-procmon/references/agent-execution.md +36 -0
  316. package/skill-bundle/insight-re/SKILL.md +121 -0
  317. package/skill-bundle/insight-re/references/agent-execution.md +36 -0
  318. package/skill-bundle/insight-re/references/artifacts.md +52 -0
  319. package/skill-bundle/insight-re/references/recovery.md +53 -0
  320. package/skill-bundle/insight-sevenzip/SKILL.md +42 -0
  321. package/skill-bundle/insight-sevenzip/references/agent-execution.md +36 -0
  322. package/skill-bundle/insight-strace/SKILL.md +46 -0
  323. package/skill-bundle/insight-strace/references/agent-execution.md +36 -0
  324. package/skill-bundle/insight-tshark/SKILL.md +49 -0
  325. package/skill-bundle/insight-tshark/references/agent-execution.md +36 -0
  326. package/skill-bundle/insight-windbg/SKILL.md +46 -0
  327. package/skill-bundle/insight-windbg/references/agent-execution.md +36 -0
  328. package/skill-bundle/manifest.json +32 -0
  329. package/skills/insight-artifacts/SKILL.md +30 -0
  330. package/skills/insight-artifacts/references/agent-execution.md +36 -0
  331. package/skills/insight-artifacts/references/artifacts.md +52 -0
  332. package/skills/insight-binary/SKILL.md +46 -0
  333. package/skills/insight-binary/references/agent-execution.md +36 -0
  334. package/skills/insight-capture/SKILL.md +56 -0
  335. package/skills/insight-capture/references/agent-execution.md +36 -0
  336. package/skills/insight-die/SKILL.md +49 -0
  337. package/skills/insight-die/references/agent-execution.md +36 -0
  338. package/skills/insight-dnspy/SKILL.md +65 -0
  339. package/skills/insight-dnspy/references/agent-execution.md +36 -0
  340. package/skills/insight-dotnet-dump/SKILL.md +46 -0
  341. package/skills/insight-dotnet-dump/references/agent-execution.md +36 -0
  342. package/skills/insight-dotnet-stack/SKILL.md +39 -0
  343. package/skills/insight-dotnet-stack/references/agent-execution.md +36 -0
  344. package/skills/insight-dotnet-trace/SKILL.md +45 -0
  345. package/skills/insight-dotnet-trace/references/agent-execution.md +36 -0
  346. package/skills/insight-frida/SKILL.md +67 -0
  347. package/skills/insight-frida/references/agent-execution.md +36 -0
  348. package/skills/insight-ghidra/SKILL.md +91 -0
  349. package/skills/insight-ghidra/references/administration.md +34 -0
  350. package/skills/insight-ghidra/references/agent-execution.md +36 -0
  351. package/skills/insight-ghidra/references/archive.md +32 -0
  352. package/skills/insight-ghidra/references/artifacts.md +52 -0
  353. package/skills/insight-ghidra/references/debugger.md +62 -0
  354. package/skills/insight-ghidra/references/extensions-and-sync.md +124 -0
  355. package/skills/insight-ghidra/references/managed-runtime.md +157 -0
  356. package/skills/insight-ghidra/references/native-workflows.md +112 -0
  357. package/skills/insight-ghidra/references/query-semantics.md +96 -0
  358. package/skills/insight-ghidra/references/recovery.md +53 -0
  359. package/skills/insight-ghidra/references/research.md +101 -0
  360. package/skills/insight-ghidra/references/setup.md +50 -0
  361. package/skills/insight-ilspy/SKILL.md +45 -0
  362. package/skills/insight-ilspy/references/agent-execution.md +36 -0
  363. package/skills/insight-ilspy/references/ilspy.md +33 -0
  364. package/skills/insight-interop/SKILL.md +54 -0
  365. package/skills/insight-interop/references/agent-execution.md +36 -0
  366. package/skills/insight-lldb/SKILL.md +54 -0
  367. package/skills/insight-lldb/references/agent-execution.md +36 -0
  368. package/skills/insight-llvm/SKILL.md +56 -0
  369. package/skills/insight-llvm/references/agent-execution.md +36 -0
  370. package/skills/insight-managed-heap/SKILL.md +43 -0
  371. package/skills/insight-managed-heap/references/agent-execution.md +36 -0
  372. package/skills/insight-managed-metadata/SKILL.md +52 -0
  373. package/skills/insight-managed-metadata/references/agent-execution.md +36 -0
  374. package/skills/insight-mitmproxy/SKILL.md +62 -0
  375. package/skills/insight-mitmproxy/references/agent-execution.md +36 -0
  376. package/skills/insight-overview/SKILL.md +79 -0
  377. package/skills/insight-overview/references/agent-execution.md +36 -0
  378. package/skills/insight-procmon/SKILL.md +49 -0
  379. package/skills/insight-procmon/references/agent-execution.md +36 -0
  380. package/skills/insight-re/SKILL.md +22 -9
  381. package/skills/insight-re/references/agent-execution.md +36 -0
  382. package/skills/insight-re/references/artifacts.md +52 -0
  383. package/skills/insight-re/references/recovery.md +53 -0
  384. package/skills/insight-sevenzip/SKILL.md +42 -0
  385. package/skills/insight-sevenzip/references/agent-execution.md +36 -0
  386. package/skills/insight-strace/SKILL.md +46 -0
  387. package/skills/insight-strace/references/agent-execution.md +36 -0
  388. package/skills/insight-tshark/SKILL.md +49 -0
  389. package/skills/insight-tshark/references/agent-execution.md +36 -0
  390. package/skills/insight-windbg/SKILL.md +46 -0
  391. package/skills/insight-windbg/references/agent-execution.md +36 -0
package/dist/src/cli.js CHANGED
@@ -1,8 +1,27 @@
1
+ import { captureCommands } from './capture.js';
2
+ import { binaryCommands } from './binary.js';
3
+ import { skillCommand, toolboxCommands } from './toolbox.js';
4
+ import { listProcesses } from './tool-runtime/supervisor.js';
5
+ import { diagnosticsCommands } from './dotnet-diagnostics.js';
6
+ import { fridaCommands } from './frida.js';
7
+ import { mitmproxyCommands } from './mitmproxy.js';
8
+ import { tsharkCommands } from './tshark.js';
9
+ import { dnspyCommands } from './dnspy.js';
10
+ import { procmonCommands } from './procmon.js';
11
+ import { straceCommands } from './strace.js';
12
+ import { windbgCommands } from './windbg.js';
13
+ import { lldbCommands } from './lldb.js';
14
+ import { dieCommands } from './die.js';
15
+ import { llvmCommands } from './llvm.js';
16
+ import { sevenzipCommands } from './sevenzip.js';
17
+ import { ilspyCommands } from './ilspy.js';
18
+ import { toolProcessCommands } from './tool-runtime/commands.js';
19
+ import { ghidraProcessHooks } from './ghidra-processes.js';
20
+ import { withToolLock, toolProfileBusy } from './tool-runtime/store.js';
1
21
  import { command, createCli, Permission, CliError, ProfileStore } from '@eyeauras/cli-factory';
2
22
  import { join, resolve } from 'node:path';
3
23
  import { readFile, readdir } from 'node:fs/promises';
4
24
  import { existsSync } from 'node:fs';
5
- import { fileURLToPath } from 'node:url';
6
25
  import { Workspace } from './workspace.js';
7
26
  import { GhidraContexts } from './contexts.js';
8
27
  import { nativeInputs } from './native-inputs.js';
@@ -27,16 +46,47 @@ import { VersionTracking, trackingCommands } from './version-tracking.js';
27
46
  import { Extensions, extensionCommands, extensionState, extensionInventoryCommands, managedExtensions } from './extensions.js';
28
47
  import { Synchronization, synchronizationCommands } from './sync-policy.js';
29
48
  import { artifactsCommands } from './saved-materials.js';
49
+ import { RuntimeManager, runtimeCommands, runtimeProcesses } from './runtime-manager.js';
50
+ import { packageVersion } from './package-version.js';
51
+ import { runtimeSelection } from './runtime-selection.js';
30
52
  const bindingFields = ['java', 'ghidraHome', 'mcpJar', 'mcpJarSha256', 'server', 'repository', 'readerUser', 'publisherUser', 'maxContexts', 'debuggerPython', 'windbgDir', 'archiveUrl'];
31
53
  class Owner {
32
54
  options;
33
55
  profiles = new Map();
56
+ runtimeChanging = new Set();
57
+ async runtime(c, action, quiescent = true) {
58
+ const directory = c.appArguments.AppDataDirectory;
59
+ if (this.runtimeChanging.has(directory))
60
+ fail('busy', 'Another runtime operation is in progress.');
61
+ const current = this.profiles.get(directory);
62
+ if (quiescent && current?.tasks.size)
63
+ fail('busy', 'Research operations are in progress; finish them before managing the runtime.');
64
+ this.runtimeChanging.add(directory);
65
+ try {
66
+ if (!quiescent)
67
+ return await action();
68
+ const processes = await runtimeProcesses(directory);
69
+ if (processes.length)
70
+ fail('busy', 'Close Ghidra contexts and stop the owned server before changing or checking the runtime.', { processes });
71
+ if (current) {
72
+ await (await current.backend)?.dispose();
73
+ current.workspace.close();
74
+ this.profiles.delete(directory);
75
+ }
76
+ return await withToolLock(directory, 'ghidra', action, c.signal);
77
+ }
78
+ finally {
79
+ this.runtimeChanging.delete(directory);
80
+ }
81
+ }
34
82
  constructor(options) {
35
83
  this.options = options;
36
84
  }
37
85
  selected(c) {
38
86
  const directory = c.appArguments.AppDataDirectory;
39
- const configuration = digest({ profile: Object.fromEntries(bindingFields.map(key => [key, c.profile.values[key]])), extensions: extensionState(join(directory, 'workspace')).modules.filter(m => m.enabled).map(m => [m.name, m.sha256]) });
87
+ if (this.runtimeChanging.has(directory))
88
+ fail('busy', 'Runtime preparation is in progress.');
89
+ const configuration = digest({ runtime: runtimeSelection(directory), profile: Object.fromEntries(bindingFields.map(key => [key, c.profile.values[key]])), extensions: extensionState(join(directory, 'workspace')).modules.filter(m => m.enabled).map(m => [m.name, m.sha256]) });
40
90
  let profile = this.profiles.get(directory);
41
91
  if (!profile) {
42
92
  profile = { workspace: new Workspace(join(directory, 'workspace'), c.profile.name), tasks: new Map(), configuration };
@@ -48,7 +98,7 @@ class Owner {
48
98
  const backend = async () => {
49
99
  if (!selected.backend)
50
100
  selected.backend = Promise.resolve(this.options.backend ?
51
- this.options.backend(selected.workspace, c) : nativeInputs(c.profile.values, selected.workspace.directory).then(inputs => new GhidraContexts(selected.workspace, inputs, c)))
101
+ this.options.backend(selected.workspace, c) : nativeInputs(c.profile.values, selected.workspace.directory, c).then(inputs => new GhidraContexts(selected.workspace, inputs, c)))
52
102
  .catch(error => { selected.backend = undefined; throw error; });
53
103
  const result = await selected.backend;
54
104
  if (result instanceof GhidraContexts)
@@ -64,6 +114,12 @@ class Owner {
64
114
  }
65
115
  async invalidateProfile(app) {
66
116
  const directory = app.AppDataDirectory, profile = this.profiles.get(directory);
117
+ if (this.runtimeChanging.has(directory))
118
+ fail('busy', 'Runtime preparation is in progress; finish it before changing or deleting the profile.');
119
+ if (toolProfileBusy(directory))
120
+ fail('busy', 'A tool operation is active.');
121
+ if ((await listProcesses(directory)).some(r => !['exited', 'failed'].includes(r.state)))
122
+ fail('busy', 'The profile has active or unverified tool processes.');
67
123
  const materials = await readdir(join(directory, 'materials')).catch(error => { if (error.code === 'ENOENT')
68
124
  return []; throw error; });
69
125
  if (existsSync(join(directory, 'workspace', 'workspace.sqlite')) || materials.length)
@@ -166,6 +222,17 @@ function scopedFailures(entry, owner, parents = []) {
166
222
  if (!selected)
167
223
  return await run(input, c);
168
224
  const services = owner.selected(c);
225
+ // First open of an already known target reserves its context inside Research.open.
226
+ // Existing contexts still use the command boundary to order automatic sync phases.
227
+ if (path[1] === 'open')
228
+ try {
229
+ services.workspace.context(selected);
230
+ }
231
+ catch (error) {
232
+ if (error instanceof CliError && error.code === 'coordinator.notFound')
233
+ return await run(input, c);
234
+ throw error;
235
+ }
169
236
  return await services.research.boundary(selected, async () => {
170
237
  const excluded = ['open', 'merge', 'refresh', 'sync-policy', 'close', 'changes', 'debugger', 'ui', 'version-tracking', 'archive', 'projects', 'repository', 'server', 'formats', 'libraries', 'plugins'];
171
238
  const eligible = entry.permission !== Permission.ReadOnly && entry.permission !== undefined && !excluded.includes(path[1]) && !['ghidra types archive-export', 'ghidra documentation transfer'].includes(name);
@@ -190,7 +257,7 @@ function scopedFailures(entry, owner, parents = []) {
190
257
  export function createDefinition(options = {}) {
191
258
  const owner = new Owner(options);
192
259
  const definition = {
193
- name: 'insight-cli', applicationId: 'insight-cli', version: '0.1.0', description: 'Isolated research contexts and coordinated Ghidra analysis',
260
+ name: 'insight-cli', applicationId: 'insight-cli', version: packageVersion, description: 'Isolated research contexts and coordinated Ghidra analysis',
194
261
  resources: [owner], permissions: { categories: [{ name: 'Destructive', description: 'Explicit deletion or replacement of retained research data', enabledByDefault: false }] }, ...(options.runtime ? { runtime: options.runtime } : {}),
195
262
  profile: { fields: fields.map(([name, flags, description]) => ({ name: name, flags: flags, description: description,
196
263
  ...(name === 'maxContexts' ? { normalize: (value) => number(value, 16, 1) } : {}) })) },
@@ -245,15 +312,25 @@ export function createDefinition(options = {}) {
245
312
  await c.secrets.delete('publisherPassword');
246
313
  },
247
314
  },
248
- builtins: [command('skill [name]', 'Locate the installed insight-cli or insight-re skill', ({ args }) => {
249
- const name = args.name === undefined ? 'insight-cli' : text(args.name);
250
- if (!['insight-cli', 'insight-re'].includes(name))
251
- fail('notFound', 'Unknown skill; choose insight-cli or insight-re.');
252
- return { version: '0.1.0', name, path: fileURLToPath(new URL(name === 'insight-re' ? '../../skills/insight-re/SKILL.md' : '../../SKILL.md', import.meta.url)),
253
- skills: ['insight-cli', 'insight-re'] };
254
- })],
315
+ builtins: [skillCommand()],
255
316
  commands: [
256
317
  ...artifactsCommands(),
318
+ ...diagnosticsCommands(c => owner.selected(c).workspace),
319
+ ...llvmCommands(c => owner.selected(c).workspace),
320
+ ...dieCommands(c => owner.selected(c).workspace),
321
+ ...lldbCommands(c => owner.selected(c).workspace),
322
+ ...windbgCommands(c => owner.selected(c).workspace),
323
+ ...procmonCommands(),
324
+ ...dnspyCommands(c => owner.selected(c).workspace),
325
+ ...tsharkCommands(c => owner.selected(c).workspace),
326
+ ...mitmproxyCommands(c => owner.selected(c).workspace),
327
+ ...straceCommands(c => owner.selected(c).workspace),
328
+ ...fridaCommands(c => owner.selected(c).workspace),
329
+ ...sevenzipCommands(c => owner.selected(c).workspace),
330
+ ...ilspyCommands(c => owner.selected(c).workspace),
331
+ ...binaryCommands(c => owner.selected(c).workspace),
332
+ ...captureCommands(c => owner.selected(c).workspace),
333
+ ...toolProcessCommands({ ghidra: ghidraProcessHooks(c => owner.selected(c).workspace, (scope, c) => owner.selected(c).lifecycle.change(scope, 'close')) }, toolboxCommands()),
257
334
  command('targets', 'Inspect immutable inputs', [
258
335
  command('add <input>', 'Consume input without starting a tool', async ({ args }, c) => targetView(await owner.selected(c).workspace.importTarget(resolve(c.cwd, text(args.input, 4096)))), { permission: Permission.Update }),
259
336
  command('list', 'List known inputs', ({ options: o }, c) => {
@@ -360,7 +437,7 @@ export function createDefinition(options = {}) {
360
437
  }, { permission: Permission.Update, options: [...scoped, at, { flags: '--prototype <signature>', description: 'Complete C prototype', required: true },
361
438
  { flags: '--calling-convention <name>', description: 'Explicit convention supported by the selected compiler specification' }, request] }),
362
439
  command('get', 'Read a function and entry comments', ({ options: o }, c) => owner.selected(c).research.function(scope(o), address(o.address)), { permission: Permission.ReadOnly, options: [...scoped, at] }),
363
- command('decompile', 'Read decompiled function text', ({ options: o }, c) => owner.selected(c).research.function(scope(o), address(o.address), true), { permission: Permission.ReadOnly, options: [...scoped, at] }),
440
+ command('decompile', 'Read a bounded Unicode window of one decompiled function', ({ options: o }, c) => owner.selected(c).research.function(scope(o), address(o.address), true, { limit: number(o.limitChars ?? 16000, 32768, 1), offset: number(o.offsetChars ?? 0, 4 * 1024 ** 2) }), { permission: Permission.ReadOnly, options: [...scoped, at, { flags: '--limit-chars <count>', description: 'Return 1–32768 Unicode characters', defaultValue: 16000 }, { flags: '--offset-chars <count>', description: 'Skip Unicode characters in the returned native text', defaultValue: 0 }] }),
364
441
  command('rename', 'Record a saved private name', ({ options: o }, c) => {
365
442
  const name = text(o.name, 512);
366
443
  if (name !== name.trim())
@@ -381,7 +458,7 @@ export function createDefinition(options = {}) {
381
458
  ],
382
459
  };
383
460
  return { ...definition, commands: definition.commands?.map(entry => entry.name === 'ghidra' ?
384
- scopedFailures({ ...entry, children: extendQueries(extendQueries(extendQueries(entry.children ?? [], queryCommands(c => owner.selected(c).research)), mutationCommands(c => owner.selected(c).research)), [...sdkCommands(c => owner.selected(c).research), ...sdkFileCommands(c => owner.selected(c).sdkFiles), ...trackingCommands(c => owner.selected(c).tracking), ...crossCommands(c => owner.selected(c).research), ...administrationCommands(c => owner.selected(c).administration),
385
- ...extensionCommands(c => new Extensions(join(c.appArguments.AppDataDirectory, 'workspace'))), ...extensionInventoryCommands(c => owner.selected(c).backend), ...pluginCommands(c => owner.selected(c).ui), ...synchronizationCommands(c => owner.selected(c).synchronization), ...utilityCommands(), ...lifecycleCommands(c => owner.selected(c).lifecycle), ...projectCommands(c => owner.selected(c).projects), ...uiCommands(c => owner.selected(c).ui), ...debuggerCommands(c => owner.selected(c).debugger), ...archiveCommands(c => owner.selected(c).archive)]) }, owner) : entry) };
461
+ scopedFailures({ ...entry, children: extendQueries(extendQueries(extendQueries(entry.children ?? [], queryCommands(c => owner.selected(c).research)), mutationCommands(c => owner.selected(c).research)), [...sdkCommands(c => owner.selected(c).research), ...sdkFileCommands(c => owner.selected(c).sdkFiles), ...trackingCommands(c => owner.selected(c).tracking), ...crossCommands(c => owner.selected(c).research), ...administrationCommands(c => owner.selected(c).administration, options.backend ? undefined : async (c) => { const status = await new RuntimeManager(c).status(); return status.state === 'not_ready' ? { ...status.server, connected: false, state: 'runtime_not_ready', missing: status.missing } : undefined; }),
462
+ ...extensionCommands(c => new Extensions(join(c.appArguments.AppDataDirectory, 'workspace'))), ...extensionInventoryCommands(c => owner.selected(c).backend), ...pluginCommands(c => owner.selected(c).ui), ...synchronizationCommands(c => owner.selected(c).synchronization), ...utilityCommands(), ...runtimeCommands((c, action, quiescent) => owner.runtime(c, action, quiescent)), ...lifecycleCommands(c => owner.selected(c).lifecycle, c => new RuntimeManager(c).status()), ...projectCommands(c => owner.selected(c).projects), ...uiCommands(c => owner.selected(c).ui), ...debuggerCommands(c => owner.selected(c).debugger), ...archiveCommands(c => owner.selected(c).archive)]) }, owner) : entry) };
386
463
  }
387
464
  export const createInsightCli = (options = {}) => createCli(createDefinition(options));
@@ -5,14 +5,19 @@ import { GhidraServer } from './server.js';
5
5
  import { Workspace, type Scope, type GhidraContext, type ScalarChange, type Publication, type DebuggerState } from './workspace.js';
6
6
  import { type Artifact } from './artifacts.js';
7
7
  import { HttpBridge } from './transport.js';
8
+ import type { SelectedTool } from './tool-runtime/installer.js';
8
9
  export type ToolMode = 'headless' | 'gui';
9
10
  interface ProcessBinding {
11
+ toolProcessId?: string;
10
12
  pid: number;
11
13
  endpoint: string;
12
14
  root: string;
13
15
  target: string;
14
16
  context?: string;
17
+ session?: string;
15
18
  mode: ToolMode;
19
+ debuggerPython?: string;
20
+ debuggerRuntime?: SelectedTool;
16
21
  program: string;
17
22
  tokenSecret: string;
18
23
  runtimeFingerprint: string;
@@ -1,8 +1,11 @@
1
- import { spawn } from 'node:child_process';
1
+ import { launchProcess, terminateProcess } from './tool-runtime/supervisor.js';
2
+ import { runTool } from './tool-runtime/run.js';
3
+ import { verifyGhidraProcess } from './ghidra-processes.js';
4
+ import { runtimeProcesses } from './runtime-manager.js';
2
5
  import { randomUUID, randomBytes } from 'node:crypto';
3
6
  import { mkdir, open, readFile, readdir, rename, link, realpath, copyFile, chmod, writeFile } from 'node:fs/promises';
4
7
  import { constants } from 'node:fs';
5
- import { join, delimiter, sep, resolve } from 'node:path';
8
+ import { join, delimiter, sep, resolve, dirname } from 'node:path';
6
9
  import { createServer } from 'node:net';
7
10
  import { setTimeout as delay } from 'node:timers/promises';
8
11
  import { nativeHelpers, nativeInputs, nativeJvmDirectories, nativeExtensionArguments } from './native-inputs.js';
@@ -12,14 +15,14 @@ import { HttpBridge } from './transport.js';
12
15
  import { scriptInventory, scriptPath } from './scripts.js';
13
16
  import { logicalPrograms } from './cross-results.js';
14
17
  import { uiResult } from './ui-results.js';
15
- import { execFile } from 'node:child_process';
16
- import { promisify } from 'node:util';
17
18
  import { fileURLToPath } from 'node:url';
19
+ import { readCallerGoal, awaitCaller } from './debugger-caller.js';
18
20
  import { debuggerProgramMetadata } from './debugger-results.js';
19
21
  import { nativeQueries } from './query-policy.js';
20
22
  import { nativeQuery } from './native-queries.js';
21
23
  import { sdkWrites } from './sdk-contracts.js';
22
24
  import { initialIntent, initializeModel } from './initial-model.js';
25
+ import { managedGhidraDebugger, prepareGhidraDebugger } from './ghidra-debugger-runtime.js';
23
26
  const alive = (pid) => {
24
27
  try {
25
28
  process.kill(pid, 0);
@@ -73,7 +76,16 @@ export class GhidraContexts {
73
76
  fork(c) { return new GhidraContexts(this.workspace, this.inputs, c, this.running, this.modelTasks, this.ownedServer.fork(c), this.capacity); }
74
77
  directory() { return join(this.workspace.directory, 'ghidra-native'); }
75
78
  server() { return this.ownedServer; }
76
- async administration(operation, parameters) { return this.server().administration(operation, parameters); }
79
+ async administration(operation, parameters) {
80
+ if (operation === 'stop') {
81
+ if (this.c.profile.values.server)
82
+ fail('authorization', 'External server lifecycle is owned by its operator. Use server disconnect.');
83
+ const processes = await runtimeProcesses(dirname(this.workspace.directory));
84
+ if (processes.some(p => p.kind !== 'server'))
85
+ fail('busy', 'Close active Ghidra contexts before stopping their server.');
86
+ }
87
+ return this.server().administration(operation, parameters);
88
+ }
77
89
  async sdkFile(operation, parameters) { return this.server().sdkFile(operation, parameters); }
78
90
  async prepareRoot(kind, target, context) {
79
91
  const root = join(this.directory(), kind, context ?? target, randomUUID());
@@ -81,16 +93,19 @@ export class GhidraContexts {
81
93
  return root;
82
94
  }
83
95
  async launch(root, target, kind, program, mode, context, credentials = {}) {
84
- if ((await nativeInputs(this.c.profile.values, this.workspace.directory)).fingerprint !== this.inputs.fingerprint)
96
+ if ((await nativeInputs(this.c.profile.values, this.workspace.directory, this.c)).fingerprint !== this.inputs.fingerprint)
85
97
  fail('binding', 'Native runtime inputs changed; stop the owner before using a different build.');
86
98
  const endpointPort = await port(), tokenSecret = 'context-' + randomUUID(), token = randomBytes(32).toString('hex');
87
99
  await this.c.secrets.set(tokenSecret, token);
88
- const classes = await nativeHelpers(this.workspace.directory, this.inputs);
89
- let debuggerEnvironment = {};
100
+ const classes = await nativeHelpers(this.workspace.directory, this.inputs, this.c);
101
+ let debuggerEnvironment = {}, debuggerPython, debuggerRuntime;
90
102
  if (mode === 'gui') {
103
+ if (managedGhidraDebugger())
104
+ debuggerRuntime = await prepareGhidraDebugger(this.c);
91
105
  const python = join(root, 'debug-python-' + randomUUID());
92
106
  await mkdir(python, { mode: 0o700 });
93
- const prepared = await promisify(execFile)(this.inputs.java, ['-cp', classes, 'InsightPythonWheels', python, ...this.inputs.debuggerWheels], { timeout: 30000, maxBuffer: 65536 });
107
+ debuggerPython = python;
108
+ const prepared = await runTool(this.c, { tool: 'ghidra', role: 'debugger-wheels', installation: this.inputs.fingerprint, executable: this.inputs.java, arguments: ['-cp', classes, 'InsightPythonWheels', python, ...this.inputs.debuggerWheels], timeoutMs: 30000, maxOutputBytes: 65536 });
94
109
  if (object(JSON.parse(prepared.stdout)).state !== 'prepared')
95
110
  fail('configuration', 'Owned debugger Python dependencies could not be prepared.');
96
111
  debuggerEnvironment = { INSIGHT_DEBUGGER_PYTHON: python, PYTHONPATH: python, PYTHONNOUSERSITE: '1', PYTHONDONTWRITEBYTECODE: '1', PYTHONPYCACHEPREFIX: join(python, 'isolated-cache') };
@@ -107,19 +122,23 @@ export class GhidraContexts {
107
122
  const main = mode === 'gui' ? 'InsightGuiMain' : 'InsightHeadlessMain';
108
123
  const args = mode === 'gui' ? [root, 'view', String(endpointPort)] : ['--bind', '127.0.0.1', '--port', String(endpointPort)];
109
124
  const log = await open(join(root, 'runtime.log'), 'a', 0o600);
110
- const child = spawn(this.inputs.java, ['-Xmx768m', '-Djava.awt.headless=' + String(mode !== 'gui'), '-Dghidra.home=' + this.inputs.ghidraHome,
125
+ let binding;
126
+ const child = await launchProcess(this.c.appArguments.AppDataDirectory, { tool: 'ghidra', role: mode === 'gui' ? 'gui' : kind, installation: this.inputs.fingerprint, target: target.id, session: context ? this.workspace.contextById(context).session : undefined, metadata: { contextRoot: root } }, this.inputs.java, ['-Xmx768m', '-Djava.awt.headless=' + String(mode !== 'gui'), '-Dghidra.home=' + this.inputs.ghidraHome,
111
127
  ...nativeJvmDirectories(root), ...nativeExtensionArguments(this.inputs), '-cp', classes + delimiter + this.inputs.classpath, main, ...args], { cwd: root, detached: true, windowsHide: true, stdio: ['ignore', log.fd, log.fd],
112
128
  env: { PATH: this.c.environment.PATH ?? process.env.PATH, HOME: root, TMPDIR: root, XDG_RUNTIME_DIR: root,
113
- GHIDRA_MCP_AUTH_TOKEN: token, GHIDRA_MCP_FILE_ROOT: root, GHIDRA_MCP_SHARED_PROJECT_DIR: root,
114
- GHIDRA_MCP_ALLOW_SCRIPTS: '1', ...debuggerEnvironment, ...credentials } });
129
+ INSIGHT_TOOL_APPDATA: this.c.appArguments.AppDataDirectory, GHIDRA_MCP_AUTH_TOKEN: token, GHIDRA_MCP_FILE_ROOT: root, GHIDRA_MCP_SHARED_PROJECT_DIR: root,
130
+ GHIDRA_MCP_ALLOW_SCRIPTS: '1', ...debuggerEnvironment, ...credentials } }, { signal: this.c.signal, onSpawn: async (spawned) => {
131
+ if (!spawned.pid)
132
+ fail('launch', 'Owned context did not obtain a PID.');
133
+ binding = { toolProcessId: spawned.toolProcessId, pid: spawned.pid, endpoint: `http://127.0.0.1:${endpointPort}`, root, ...(debuggerPython ? { debuggerPython } : {}), ...(debuggerRuntime ? { debuggerRuntime } : {}), target: target.id,
134
+ ...(context ? { context, session: this.workspace.contextById(context).session } : {}), kind, mode, program, tokenSecret, runtimeFingerprint: this.inputs.fingerprint };
135
+ await durable(join(root, 'process.json'), binding);
136
+ } });
115
137
  child.on('error', () => { });
116
138
  child.unref();
117
139
  await log.close();
118
140
  if (!child.pid)
119
141
  fail('launch', 'Owned Ghidra context could not be launched.');
120
- const binding = { pid: child.pid, endpoint: `http://127.0.0.1:${endpointPort}`, root, target: target.id,
121
- ...(context ? { context } : {}), kind, mode, program, tokenSecret, runtimeFingerprint: this.inputs.fingerprint };
122
- await durable(join(root, 'process.json'), binding);
123
142
  const record = { binding, http: new HttpBridge(binding.endpoint, this.c.fetch, this.c.signal, token), child };
124
143
  this.running.set(root, record);
125
144
  const deadline = Date.now() + 90000;
@@ -182,7 +201,10 @@ export class GhidraContexts {
182
201
  const token = await this.c.secrets.require(binding.tokenSecret), http = new HttpBridge(binding.endpoint, this.c.fetch, new AbortController().signal, token, 60000);
183
202
  await this.debuggerHelperRecord({ ...record, http }, 'Stop', 'INSIGHT_DEBUGGER_STOPPED');
184
203
  }
185
- process.kill(binding.pid, 'SIGTERM');
204
+ if (binding.toolProcessId)
205
+ await terminateProcess(this.c.appArguments.AppDataDirectory, binding.toolProcessId, false, r => verifyGhidraProcess(r, this.c));
206
+ else
207
+ process.kill(binding.pid, 'SIGTERM');
186
208
  for (let i = 0; i < 100 && alive(binding.pid); i++)
187
209
  await delay(50);
188
210
  if (alive(binding.pid))
@@ -721,7 +743,20 @@ public class ${name} extends GhidraScript {
721
743
  if (operation === 'read_memory')
722
744
  await this.traceHelper(scope, { operation: 'read_memory', address: p.address, size: p.size });
723
745
  const token = await this.c.secrets.require(record.binding.tokenSecret), timeout = operation === 'launch' ? (Number(p.timeout_seconds ?? 60) + 90) * 1000 : 45000;
746
+ const callerPython = process.platform === 'darwin' && operation === 'step' && p.kind === 'out' ? record.binding.debuggerPython : undefined;
747
+ if (callerPython && (dirname(callerPython) !== record.binding.root || await realpath(callerPython) !== callerPython))
748
+ fail('binding', 'Native caller Python scope changed.');
749
+ const priorCaller = callerPython ? await readCallerGoal(callerPython) : undefined;
724
750
  const raw = await new HttpBridge(record.binding.endpoint, this.c.fetch, this.c.signal, token, timeout).call('/debugger/' + operation, { ...p, ...(['launch', 'launch_offers', 'static_to_dynamic'].includes(operation) ? { program: record.binding.program } : {}) });
751
+ if (callerPython) {
752
+ const goal = await readCallerGoal(callerPython);
753
+ if (goal && goal.id !== priorCaller?.id) {
754
+ const launch = object(JSON.parse(await readFile(join(record.binding.root, 'debugger-run', 'current.json'), 'utf8')));
755
+ if (goal.executable !== launch.executable || launch.context !== record.binding.context || launch.target !== scope.target)
756
+ fail('binding', 'Native caller belongs to another launch.');
757
+ await awaitCaller(callerPython, goal, this.c.signal);
758
+ }
759
+ }
725
760
  const label = this.workspace.target(scope.target).name;
726
761
  if (operation === 'modules' && Array.isArray(raw))
727
762
  return raw.map(value => { const row = object(value), { path, ...rest } = row; return { ...rest, ...(typeof row.name === 'string' && (row.name.includes(record.binding.root) || ['image', 'image.exe'].includes(row.name)) ? { name: label } : {}) }; });
@@ -814,8 +849,9 @@ public class ${name} extends GhidraScript {
814
849
  const cwd = p.cwd === undefined ? root : text(p.cwd, 4096);
815
850
  if (/[\r\n\0]/.test(cwd))
816
851
  fail('invalid', 'Debugger working directory must be a single filesystem path.');
817
- await durable(join(record.binding.root, 'debugger-run', 'current.json'), { request, target: scope.target, context: record.binding.context, executable, cwd });
818
- return this.debuggerCall(scope, 'launch', { ...p, executable_path: executable, cwd,
852
+ await durable(join(record.binding.root, 'debugger-run', 'current.json'), { request, target: scope.target, context: record.binding.context, executable, cwd, ...(p.stop_at_entry === true ? { stopAtEntry: true } : {}) });
853
+ const { stop_at_entry, ...parameters } = p;
854
+ return this.debuggerCall(scope, 'launch', { ...parameters, executable_path: executable, cwd,
819
855
  ...(this.c.profile.values.debuggerPython ? { python_executable: text(this.c.profile.values.debuggerPython, 4096) } : {}),
820
856
  ...(this.c.profile.values.windbgDir ? { windbg_dir: text(this.c.profile.values.windbgDir, 4096) } : {}) });
821
857
  }
@@ -0,0 +1,17 @@
1
+ export interface CallerGoal {
2
+ schema: 1;
3
+ id: string;
4
+ pid: number;
5
+ thread: string;
6
+ pc: string;
7
+ sp: string;
8
+ stop: number;
9
+ executable: string;
10
+ breakpoint: number;
11
+ }
12
+ export declare function readCallerGoal(python: string): Promise<CallerGoal | undefined>;
13
+ export declare function callerVerified(goal: CallerGoal, value: Record<string, unknown>): boolean;
14
+ export declare function awaitCaller(python: string, goal: CallerGoal, signal?: AbortSignal, budgetMs?: number): Promise<void>;
15
+ /** Runs from the owned LLDB CLI after the MCP action has returned and released its locks. */
16
+ export declare function callerObservationCommand(python: string, goal: CallerGoal, sample: string): string;
17
+ export declare function callerMonitor(python: string, send: (command: string) => void): () => Promise<void>;
@@ -0,0 +1,129 @@
1
+ /** Private, profile-owned LLDB completion receipts. No CPU operation is retried. */
2
+ import { lstat, open, readFile, realpath, rename } from 'node:fs/promises';
3
+ import { join, resolve } from 'node:path';
4
+ import { randomUUID } from 'node:crypto';
5
+ import { setTimeout as delay } from 'node:timers/promises';
6
+ import { fail, object } from './model.js';
7
+ const uuid = /^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/;
8
+ const hex = /^0x[a-fA-F0-9]{1,16}$/;
9
+ async function json(path) {
10
+ try {
11
+ const stat = await lstat(path);
12
+ if (!stat.isFile() || stat.size > 16384 || await realpath(path) !== resolve(path))
13
+ fail('binding', 'Native caller receipt is not an owned regular file.');
14
+ return object(JSON.parse(await readFile(path, 'utf8')));
15
+ }
16
+ catch (error) {
17
+ if (error.code === 'ENOENT')
18
+ return;
19
+ throw error;
20
+ }
21
+ }
22
+ async function atomic(path, value) { const temporary = path + '.new-' + randomUUID(), file = await open(temporary, 'wx', 0o600); try {
23
+ await file.writeFile(JSON.stringify(value));
24
+ await file.sync();
25
+ }
26
+ finally {
27
+ await file.close();
28
+ } await rename(temporary, path); }
29
+ export async function readCallerGoal(python) {
30
+ const value = await json(join(python, 'caller-goal.json'));
31
+ if (!value)
32
+ return;
33
+ if (value.schema !== 1 || typeof value.id !== 'string' || !uuid.test(value.id) || !Number.isSafeInteger(value.pid) || Number(value.pid) <= 0 || typeof value.thread !== 'string' || !/^\d{1,20}$/.test(value.thread) || BigInt(value.thread) <= 0n || typeof value.pc !== 'string' || !hex.test(value.pc) || typeof value.sp !== 'string' || !hex.test(value.sp) || !Number.isSafeInteger(value.stop) || Number(value.stop) < 0 || typeof value.executable !== 'string' || !Number.isSafeInteger(value.breakpoint) || Number(value.breakpoint) <= 0)
34
+ fail('binding', 'Native caller goal is malformed.');
35
+ return value;
36
+ }
37
+ export function callerVerified(goal, value) {
38
+ return value.schema === 1 && value.goal === goal.id && value.state === 'verified' && value.pid === goal.pid && value.thread === goal.thread && typeof value.pc === 'string' && hex.test(value.pc) && BigInt(value.pc) === BigInt(goal.pc) && typeof value.sp === 'string' && hex.test(value.sp) && BigInt(value.sp) === BigInt(goal.sp) && Number.isSafeInteger(value.stop) && Number(value.stop) > goal.stop;
39
+ }
40
+ export async function awaitCaller(python, goal, signal, budgetMs = 12000) {
41
+ await atomic(join(python, 'caller-armed.json'), { schema: 1, id: goal.id });
42
+ const deadline = Date.now() + budgetMs;
43
+ while (Date.now() < deadline) {
44
+ signal?.throwIfAborted();
45
+ const value = await json(join(python, 'caller-observation.json'));
46
+ if (value?.goal === goal.id) {
47
+ if (callerVerified(goal, value))
48
+ return;
49
+ if (value.state === 'verified' || value.state === 'failed')
50
+ fail('partial', 'Native caller observation did not verify the requested return.', { goal: goal.id, observation: value });
51
+ }
52
+ await delay(Math.min(50, Math.max(1, deadline - Date.now())), undefined, { signal });
53
+ }
54
+ fail('partial', 'Native caller was not verified within the action budget; execution was not repeated.', { goal: goal.id });
55
+ }
56
+ /** Runs from the owned LLDB CLI after the MCP action has returned and released its locks. */
57
+ export function callerObservationCommand(python, goal, sample) {
58
+ const code = [
59
+ 'import lldb,json,os,pathlib',
60
+ 'goal=json.loads(' + JSON.stringify(JSON.stringify(goal)) + ')',
61
+ 'output=pathlib.Path(' + JSON.stringify(join(python, 'caller-observation.json')) + ')',
62
+ 'value={"schema":1,"goal":goal["id"],"sample":' + JSON.stringify(sample) + ',"state":"pending"}',
63
+ 'def inspect_caller():',
64
+ ' p=lldb.debugger.GetSelectedTarget().GetProcess()',
65
+ ' if p.GetProcessID()!=goal["pid"]: raise RuntimeError("Native process identity changed")',
66
+ ' state=p.GetState()',
67
+ ' if state in (lldb.eStateExited,lldb.eStateDetached,lldb.eStateInvalid): raise RuntimeError("Native target ended before caller verification")',
68
+ ' if state!=lldb.eStateStopped: return',
69
+ ' stop=p.GetStopID(); t=p.GetThreadByID(int(goal["thread"])); f=t.GetFrameAtIndex(0)',
70
+ ' if not f.IsValid(): return',
71
+ ' pc=f.FindRegister("pc"); sp=f.FindRegister("sp")',
72
+ ' if not pc.IsValid() or not sp.IsValid() or pc.GetError().Fail() or sp.GetError().Fail(): return',
73
+ ' value.update(pid=p.GetProcessID(),thread=str(t.GetThreadID()),pc=hex(pc.GetValueAsUnsigned()),sp=hex(sp.GetValueAsUnsigned()),frame_pc=hex(f.GetPC()),stop=stop)',
74
+ ' if stop<=goal["stop"] or pc.GetValueAsUnsigned()!=int(goal["pc"],16) or sp.GetValueAsUnsigned()!=int(goal["sp"],16) or p.GetState()!=lldb.eStateStopped or p.GetStopID()!=stop: return',
75
+ ' from ghidralldb import commands',
76
+ ' client=commands.STATE.require_client(); batch=client.cur_batch',
77
+ ' value.update(trace_batch_count=batch.count if batch is not None else 0,trace_batch_mutex=client._block.locked())',
78
+ ' if batch is not None or client._block.locked(): return',
79
+ ' result=lldb.SBCommandReturnObject()',
80
+ ' lldb.debugger.GetCommandInterpreter().HandleCommand("ghidra trace sync-synth-stopped",result)',
81
+ ' if not result.Succeeded(): raise RuntimeError("Native stopped trace could not be synchronized")',
82
+ ' batch=client.cur_batch',
83
+ ' value.update(trace_batch_count=batch.count if batch is not None else 0,trace_batch_mutex=client._block.locked())',
84
+ ' if batch is not None or client._block.locked(): return',
85
+ ' f=p.GetThreadByID(int(goal["thread"])).GetFrameAtIndex(0)',
86
+ ' pc=f.FindRegister("pc"); sp=f.FindRegister("sp")',
87
+ ' if p.GetState()==lldb.eStateStopped and p.GetStopID()==stop and f.IsValid() and pc.IsValid() and sp.IsValid() and pc.GetError().Success() and sp.GetError().Success() and pc.GetValueAsUnsigned()==int(goal["pc"],16) and sp.GetValueAsUnsigned()==int(goal["sp"],16): value["state"]="verified"',
88
+ 'try: inspect_caller()',
89
+ 'except Exception as error: value.update(state="failed",error=str(error)[:1024])',
90
+ 'temporary=str(output)+".new-"+value["sample"]',
91
+ 'fd=os.open(temporary,os.O_CREAT|os.O_EXCL|os.O_WRONLY,0o600)',
92
+ 'try: os.write(fd,json.dumps(value).encode("utf-8")); os.fsync(fd)',
93
+ 'finally: os.close(fd)',
94
+ 'os.replace(temporary,output)',
95
+ ].join('\n');
96
+ return 'script exec(' + JSON.stringify(code) + ')\n';
97
+ }
98
+ export function callerMonitor(python, send) {
99
+ let goalId = '', sample = '', inflight = false, terminal = false, deadline = 0;
100
+ return async () => {
101
+ const armed = await json(join(python, 'caller-armed.json'));
102
+ if (!armed || typeof armed.id !== 'string' || !uuid.test(armed.id))
103
+ return;
104
+ const goal = await readCallerGoal(python);
105
+ if (!goal || goal.id !== armed.id)
106
+ return;
107
+ if (goalId !== goal.id) {
108
+ goalId = goal.id;
109
+ inflight = false;
110
+ terminal = false;
111
+ deadline = Date.now() + 15000;
112
+ }
113
+ if (terminal || Date.now() >= deadline)
114
+ return;
115
+ if (inflight) {
116
+ const value = await json(join(python, 'caller-observation.json'));
117
+ if (value?.goal !== goal.id || value.sample !== sample)
118
+ return;
119
+ inflight = false;
120
+ if (value.state === 'verified' || value.state === 'failed') {
121
+ terminal = true;
122
+ return;
123
+ }
124
+ }
125
+ sample = randomUUID();
126
+ inflight = true;
127
+ send(callerObservationCommand(python, goal, sample));
128
+ };
129
+ }
@@ -0,0 +1,2 @@
1
+ /** Preserve the pinned Ghidra launcher except its one explicit local LLDB run command. */
2
+ export declare function debuggerLaunchArguments(arguments_: readonly string[], stopAtEntry: boolean, ownedPython?: string): string[];
@@ -0,0 +1,17 @@
1
+ /** Preserve the pinned Ghidra launcher except its one explicit local LLDB run command. */
2
+ export function debuggerLaunchArguments(arguments_, stopAtEntry, ownedPython) {
3
+ const result = [...arguments_];
4
+ if (ownedPython) {
5
+ const imports = result.flatMap((value, index) => index > 0 && ['-o', '--one-line'].includes(result[index - 1]) && value === 'script import os, ghidralldb' ? [index] : []);
6
+ if (imports.length !== 1)
7
+ throw Error('Pinned LLDB launcher must supply exactly one adapter import');
8
+ result[imports[0]] = "script import sys,os; sys.path.insert(0," + JSON.stringify(ownedPython) + "); import ghidralldb,ghidralldb.methods; os._exit(253) if os.path.realpath(ghidralldb.methods.__file__) != " + JSON.stringify(ownedPython + '/ghidralldb/methods.py') + " else None; print('Insight owned LLDB adapter verified')";
9
+ }
10
+ if (!stopAtEntry)
11
+ return result;
12
+ const launches = result.flatMap((value, index) => index > 0 && ['-o', '--one-line'].includes(result[index - 1]) && value.startsWith('process launch') ? [index] : []);
13
+ if (launches.length !== 1 || !['process launch', 'process launch --stop-at-entry'].includes(result[launches[0]]))
14
+ throw Error('Pinned LLDB launcher must supply exactly one supported launch command');
15
+ result[launches[0]] = 'process launch --stop-at-entry';
16
+ return result;
17
+ }
@@ -1,4 +1,5 @@
1
1
  import type { ResearchBackend } from './research.js';
2
2
  import type { Artifact } from './artifacts.js';
3
+ export declare function debuggerExecutionSettled(operation: string, before: Record<string, unknown>, after: Record<string, unknown>): boolean;
3
4
  export declare function debuggerProgramMetadata(backend: Pick<ResearchBackend, 'inspect'>, snapshot: Artifact): Promise<string | undefined>;
4
5
  export declare function debuggerResult(operation: string, p: Record<string, unknown>, raw: unknown): Record<string, unknown> | Record<string, unknown>[];
@@ -4,6 +4,14 @@ const array = (raw) => { if (!Array.isArray(raw))
4
4
  fail('partial', 'Debugger inventory is absent.'); return raw.map(object); };
5
5
  const count = (value) => { if (!Number.isSafeInteger(value) || Number(value) < 0)
6
6
  fail('partial', 'Debugger count is invalid.'); };
7
+ export function debuggerExecutionSettled(operation, before, after) {
8
+ if (after.target_connected !== true)
9
+ return false;
10
+ const advanced = /^\d+$/.test(String(after.snap)) && /^\d+$/.test(String(before.snap)) && BigInt(String(after.snap)) > BigInt(String(before.snap));
11
+ if (operation === 'resume')
12
+ return after.execution_state === 'RUNNING' || after.execution_state === 'STOPPED' && advanced;
13
+ return after.execution_state === 'STOPPED' && (operation !== 'step' || advanced);
14
+ }
7
15
  export async function debuggerProgramMetadata(backend, snapshot) {
8
16
  if (!backend.inspect)
9
17
  return undefined;