@eyeauras/insight-cli 0.2.0 → 0.2.2

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 (387) hide show
  1. package/.cli-package-build.json +1 -1
  2. package/README.md +25 -0
  3. package/SKILL.md +38 -54
  4. package/dist/src/binary.d.ts +3 -0
  5. package/dist/src/binary.js +74 -0
  6. package/dist/src/capture.d.ts +3 -0
  7. package/dist/src/capture.js +220 -0
  8. package/dist/src/cli.js +57 -12
  9. package/dist/src/contexts.d.ts +5 -0
  10. package/dist/src/contexts.js +42 -16
  11. package/dist/src/debugger-caller.d.ts +17 -0
  12. package/dist/src/debugger-caller.js +129 -0
  13. package/dist/src/debugger-launch.d.ts +2 -0
  14. package/dist/src/debugger-launch.js +17 -0
  15. package/dist/src/debugger-results.d.ts +1 -0
  16. package/dist/src/debugger-results.js +8 -0
  17. package/dist/src/debugger-supervisor.js +56 -13
  18. package/dist/src/debugger.js +16 -7
  19. package/dist/src/die.d.ts +12 -0
  20. package/dist/src/die.js +127 -0
  21. package/dist/src/dnspy-runtime.d.ts +8 -0
  22. package/dist/src/dnspy-runtime.js +46 -0
  23. package/dist/src/dnspy.d.ts +22 -0
  24. package/dist/src/dnspy.js +160 -0
  25. package/dist/src/dotnet-diagnostics.d.ts +13 -0
  26. package/dist/src/dotnet-diagnostics.js +101 -0
  27. package/dist/src/frida-worker.d.ts +1 -0
  28. package/dist/src/frida-worker.js +125 -0
  29. package/dist/src/frida.d.ts +16 -0
  30. package/dist/src/frida.js +125 -0
  31. package/dist/src/ghidra-debugger-runtime.d.ts +7 -0
  32. package/dist/src/ghidra-debugger-runtime.js +31 -0
  33. package/dist/src/ghidra-processes.d.ts +6 -0
  34. package/dist/src/ghidra-processes.js +121 -0
  35. package/dist/src/ghidra.js +6 -6
  36. package/dist/src/ilspy.d.ts +7 -0
  37. package/dist/src/ilspy.js +122 -0
  38. package/dist/src/lldb.d.ts +10 -0
  39. package/dist/src/lldb.js +99 -0
  40. package/dist/src/llvm.d.ts +6 -0
  41. package/dist/src/llvm.js +133 -0
  42. package/dist/src/managed-heap.d.ts +4 -0
  43. package/dist/src/managed-heap.js +73 -0
  44. package/dist/src/managed-metadata.d.ts +11 -0
  45. package/dist/src/managed-metadata.js +66 -0
  46. package/dist/src/mitmproxy.d.ts +55 -0
  47. package/dist/src/mitmproxy.js +172 -0
  48. package/dist/src/native-inputs.d.ts +3 -2
  49. package/dist/src/native-inputs.js +9 -4
  50. package/dist/src/package-version.d.ts +1 -0
  51. package/dist/src/package-version.js +3 -0
  52. package/dist/src/procmon-config.d.ts +2 -0
  53. package/dist/src/procmon-config.js +15 -0
  54. package/dist/src/procmon-events.d.ts +13 -0
  55. package/dist/src/procmon-events.js +82 -0
  56. package/dist/src/procmon.d.ts +4 -0
  57. package/dist/src/procmon.js +107 -0
  58. package/dist/src/research.d.ts +11 -2
  59. package/dist/src/research.js +5 -3
  60. package/dist/src/runtime-catalog.d.ts +5 -10
  61. package/dist/src/runtime-catalog.js +4 -5
  62. package/dist/src/runtime-manager.d.ts +27 -3
  63. package/dist/src/runtime-manager.js +100 -159
  64. package/dist/src/runtime-selection.js +21 -4
  65. package/dist/src/server.d.ts +13 -0
  66. package/dist/src/server.js +21 -45
  67. package/dist/src/sevenzip.d.ts +15 -0
  68. package/dist/src/sevenzip.js +119 -0
  69. package/dist/src/strace.d.ts +10 -0
  70. package/dist/src/strace.js +71 -0
  71. package/dist/src/text-window.d.ts +11 -0
  72. package/dist/src/text-window.js +6 -0
  73. package/dist/src/tool-runtime/archives.d.ts +10 -0
  74. package/dist/src/{runtime-archives.js → tool-runtime/archives.js} +91 -24
  75. package/dist/src/tool-runtime/catalog.d.ts +3 -0
  76. package/dist/src/tool-runtime/catalog.js +13 -0
  77. package/dist/src/tool-runtime/commands.d.ts +9 -0
  78. package/dist/src/tool-runtime/commands.js +39 -0
  79. package/dist/src/tool-runtime/deadline.d.ts +11 -0
  80. package/dist/src/tool-runtime/deadline.js +32 -0
  81. package/dist/src/tool-runtime/definition.d.ts +73 -0
  82. package/dist/src/tool-runtime/definition.js +49 -0
  83. package/dist/src/tool-runtime/dotnet.d.ts +4 -0
  84. package/dist/src/tool-runtime/dotnet.js +22 -0
  85. package/dist/src/tool-runtime/identity.d.ts +6 -0
  86. package/dist/src/tool-runtime/identity.js +50 -0
  87. package/dist/src/tool-runtime/installer.d.ts +101 -0
  88. package/dist/src/tool-runtime/installer.js +180 -0
  89. package/dist/src/tool-runtime/java-arguments.d.ts +6 -0
  90. package/dist/src/tool-runtime/java-arguments.js +44 -0
  91. package/dist/src/tool-runtime/launch-worker.d.ts +1 -0
  92. package/dist/src/tool-runtime/launch-worker.js +58 -0
  93. package/dist/src/tool-runtime/run.d.ts +51 -0
  94. package/dist/src/tool-runtime/run.js +159 -0
  95. package/dist/src/tool-runtime/store.d.ts +15 -0
  96. package/dist/src/tool-runtime/store.js +219 -0
  97. package/dist/src/tool-runtime/supervisor.d.ts +57 -0
  98. package/dist/src/tool-runtime/supervisor.js +269 -0
  99. package/dist/src/tool-runtime/windows-job.d.ts +22 -0
  100. package/dist/src/tool-runtime/windows-job.js +43 -0
  101. package/dist/src/toolbox.d.ts +84 -0
  102. package/dist/src/toolbox.js +35 -0
  103. package/dist/src/tshark.d.ts +23 -0
  104. package/dist/src/tshark.js +174 -0
  105. package/dist/src/windbg.d.ts +14 -0
  106. package/dist/src/windbg.js +119 -0
  107. package/dist/src/workspace.d.ts +1 -0
  108. package/dist/src/workspace.js +6 -0
  109. package/package.json +5 -4
  110. package/references/agent-execution.md +36 -0
  111. package/references/agent-setup.md +61 -0
  112. package/references/artifacts.md +5 -0
  113. package/references/debugger.md +22 -0
  114. package/references/ilspy.md +33 -0
  115. package/references/managed-runtime.md +53 -7
  116. package/references/native/InsightPythonWheels.java +283 -2
  117. package/references/native/InsightTraceState.java +28 -13
  118. package/references/native-workflows.md +10 -0
  119. package/references/setup.md +2 -1
  120. package/runtime/managed/insight-heap/Azure.Core.dll +0 -0
  121. package/runtime/managed/insight-heap/Azure.Identity.dll +0 -0
  122. package/runtime/managed/insight-heap/Insight.Heap.csproj +1 -0
  123. package/runtime/managed/insight-heap/Insight.Heap.deps.json +391 -0
  124. package/runtime/managed/insight-heap/Insight.Heap.dll +0 -0
  125. package/runtime/managed/insight-heap/Insight.Heap.runtimeconfig.json +13 -0
  126. package/runtime/managed/insight-heap/Microsoft.Bcl.AsyncInterfaces.dll +0 -0
  127. package/runtime/managed/insight-heap/Microsoft.Diagnostics.NETCore.Client.dll +0 -0
  128. package/runtime/managed/insight-heap/Microsoft.Diagnostics.Runtime.dll +0 -0
  129. package/runtime/managed/insight-heap/Microsoft.Extensions.Configuration.Abstractions.dll +0 -0
  130. package/runtime/managed/insight-heap/Microsoft.Extensions.DependencyInjection.Abstractions.dll +0 -0
  131. package/runtime/managed/insight-heap/Microsoft.Extensions.Diagnostics.Abstractions.dll +0 -0
  132. package/runtime/managed/insight-heap/Microsoft.Extensions.FileProviders.Abstractions.dll +0 -0
  133. package/runtime/managed/insight-heap/Microsoft.Extensions.Hosting.Abstractions.dll +0 -0
  134. package/runtime/managed/insight-heap/Microsoft.Extensions.Logging.Abstractions.dll +0 -0
  135. package/runtime/managed/insight-heap/Microsoft.Extensions.Options.dll +0 -0
  136. package/runtime/managed/insight-heap/Microsoft.Extensions.Primitives.dll +0 -0
  137. package/runtime/managed/insight-heap/Microsoft.Identity.Client.Extensions.Msal.dll +0 -0
  138. package/runtime/managed/insight-heap/Microsoft.Identity.Client.dll +0 -0
  139. package/runtime/managed/insight-heap/Microsoft.IdentityModel.Abstractions.dll +0 -0
  140. package/runtime/managed/insight-heap/Microsoft.Security.AntiSSRF.dll +0 -0
  141. package/runtime/managed/insight-heap/NuGet.Config +1 -0
  142. package/runtime/managed/insight-heap/Program.cs +20 -0
  143. package/runtime/managed/insight-heap/README.md +16 -0
  144. package/runtime/managed/insight-heap/System.ClientModel.dll +0 -0
  145. package/runtime/managed/insight-heap/System.Memory.Data.dll +0 -0
  146. package/runtime/managed/insight-heap/System.Security.Cryptography.ProtectedData.dll +0 -0
  147. package/runtime/managed/insight-heap/dependencies.json +436 -0
  148. package/runtime/managed/insight-heap/notices/Azure.Core-LICENSE.txt +21 -0
  149. package/runtime/managed/insight-heap/notices/Azure.Identity-LICENSE.txt +21 -0
  150. package/runtime/managed/insight-heap/notices/Microsoft.Bcl.AsyncInterfaces-LICENSE.txt +23 -0
  151. package/runtime/managed/insight-heap/notices/Microsoft.Bcl.AsyncInterfaces-THIRD-PARTY-NOTICES.TXT +1418 -0
  152. package/runtime/managed/insight-heap/notices/Microsoft.Diagnostics.NETCore.Client-LICENSE.txt +23 -0
  153. package/runtime/managed/insight-heap/notices/Microsoft.Diagnostics.Runtime-LICENSE.txt +23 -0
  154. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Configuration.Abstractions-LICENSE.txt +23 -0
  155. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Configuration.Abstractions-THIRD-PARTY-NOTICES.TXT +1418 -0
  156. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.DependencyInjection.Abstractions-LICENSE.txt +23 -0
  157. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.DependencyInjection.Abstractions-THIRD-PARTY-NOTICES.TXT +1418 -0
  158. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Diagnostics.Abstractions-LICENSE.txt +23 -0
  159. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Diagnostics.Abstractions-THIRD-PARTY-NOTICES.TXT +1418 -0
  160. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.FileProviders.Abstractions-LICENSE.txt +23 -0
  161. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.FileProviders.Abstractions-THIRD-PARTY-NOTICES.TXT +1418 -0
  162. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Hosting.Abstractions-LICENSE.txt +23 -0
  163. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Hosting.Abstractions-THIRD-PARTY-NOTICES.TXT +1418 -0
  164. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Logging.Abstractions-LICENSE.txt +23 -0
  165. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Logging.Abstractions-THIRD-PARTY-NOTICES.TXT +1418 -0
  166. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Options-LICENSE.txt +23 -0
  167. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Options-THIRD-PARTY-NOTICES.TXT +1418 -0
  168. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Primitives-LICENSE.txt +23 -0
  169. package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Primitives-THIRD-PARTY-NOTICES.TXT +1418 -0
  170. package/runtime/managed/insight-heap/notices/Microsoft.Identity.Client-LICENSE.txt +21 -0
  171. package/runtime/managed/insight-heap/notices/Microsoft.Identity.Client.Extensions.Msal-LICENSE.txt +21 -0
  172. package/runtime/managed/insight-heap/notices/Microsoft.IdentityModel.Abstractions-LICENSE.txt +21 -0
  173. package/runtime/managed/insight-heap/notices/Microsoft.Security.AntiSSRF-LICENSE.txt +21 -0
  174. package/runtime/managed/insight-heap/notices/System.ClientModel-LICENSE.txt +21 -0
  175. package/runtime/managed/insight-heap/notices/System.Memory.Data-LICENSE.txt +23 -0
  176. package/runtime/managed/insight-heap/notices/System.Memory.Data-THIRD-PARTY-NOTICES.TXT +1418 -0
  177. package/runtime/managed/insight-heap/notices/System.Security.Cryptography.ProtectedData-LICENSE.TXT +23 -0
  178. package/runtime/managed/insight-heap/notices/System.Security.Cryptography.ProtectedData-THIRD-PARTY-NOTICES.TXT +309 -0
  179. package/runtime/managed/insight-heap/packages.lock.json +165 -0
  180. package/runtime/managed/insight-heap/provenance.json +146 -0
  181. package/runtime/managed/insight-heap/runtimes/win/lib/netstandard2.0/System.Security.Cryptography.ProtectedData.dll +0 -0
  182. package/runtime/managed/insight-managed/Insight.Managed.csproj +4 -0
  183. package/runtime/managed/insight-managed/Insight.Managed.deps.json +41 -0
  184. package/runtime/managed/insight-managed/Insight.Managed.dll +0 -0
  185. package/runtime/managed/insight-managed/Insight.Managed.runtimeconfig.json +13 -0
  186. package/runtime/managed/insight-managed/LICENSE.dnlib.txt +20 -0
  187. package/runtime/managed/insight-managed/NuGet.Config +1 -0
  188. package/runtime/managed/insight-managed/Program.cs +31 -0
  189. package/runtime/managed/insight-managed/README.md +16 -0
  190. package/runtime/managed/insight-managed/dnlib.dll +0 -0
  191. package/runtime/managed/insight-managed/packages.lock.json +13 -0
  192. package/runtime/managed/insight-managed/provenance.json +40 -0
  193. package/runtime/native/binary/README.md +22 -0
  194. package/runtime/native/binary/dependencies.json +166 -0
  195. package/runtime/native/binary/helper.cpp +44 -0
  196. package/runtime/native/binary/insight-binary-darwin-arm64 +0 -0
  197. package/runtime/native/binary/notices/Catch2-3.12.0--Catch2-3.12.0__LICENSE.txt +23 -0
  198. package/runtime/native/binary/notices/LIEF-LICENSE.txt +202 -0
  199. package/runtime/native/binary/notices/LIEF-attribution.txt +37 -0
  200. package/runtime/native/binary/notices/Melkor_ELF_Fuzzer-ac2495b--elf_fuzzer-master__LICENSE.txt +674 -0
  201. package/runtime/native/binary/notices/expected-1.3.1--expected-1.3.1__COPYING +121 -0
  202. package/runtime/native/binary/notices/frozen-61dce5a--frozen-61dce5ae18ca59931e27675c468e64118aba8744__AUTHORS +3 -0
  203. package/runtime/native/binary/notices/frozen-61dce5a--frozen-61dce5ae18ca59931e27675c468e64118aba8744__LICENSE +202 -0
  204. package/runtime/native/binary/notices/json-LICENSE.MIT +21 -0
  205. package/runtime/native/binary/notices/mbedtls-4.0.0.r0.gec4044008d--LICENSE +553 -0
  206. package/runtime/native/binary/notices/mbedtls-4.0.0.r0.gec4044008d--framework__LICENSE +553 -0
  207. package/runtime/native/binary/notices/mbedtls-4.0.0.r0.gec4044008d--tf-psa-crypto__LICENSE +552 -0
  208. package/runtime/native/binary/notices/mbedtls-4.0.0.r0.gec4044008d--tf-psa-crypto__framework__LICENSE +553 -0
  209. package/runtime/native/binary/notices/nanobind-2.13.0.r18.g4db9ed3f--LICENSE +26 -0
  210. package/runtime/native/binary/notices/nanobind-2.13.0.r18.g4db9ed3f--ext__robin_map__LICENSE +21 -0
  211. package/runtime/native/binary/notices/span-LICENSE_1_0.txt +23 -0
  212. package/runtime/native/binary/notices/span-attribution.txt +11 -0
  213. package/runtime/native/binary/notices/spdlog-1.17.0--spdlog-1.17.0__LICENSE +25 -0
  214. package/runtime/native/binary/notices/utfcpp-4.0.9--utfcpp-4.0.9__LICENSE +23 -0
  215. package/runtime/native/binary/provenance.json +48 -0
  216. package/runtime/native/child-deadline-linux-x64 +0 -0
  217. package/runtime/native/child-deadline-linux.c +24 -0
  218. package/runtime/native/child-deadline-linux.provenance.json +17 -0
  219. package/runtime/native/deadline-alarm-darwin-universal.dylib +0 -0
  220. package/runtime/native/deadline-alarm.c +33 -0
  221. package/runtime/native/deadline-alarm.provenance.json +22 -0
  222. package/runtime/native/deadline-exec-darwin-arm64 +0 -0
  223. package/runtime/native/deadline-exec.c +24 -0
  224. package/runtime/native/deadline-exec.provenance.json +17 -0
  225. package/runtime/native/dnspy-extension/Bridge.cs +58 -0
  226. package/runtime/native/dnspy-extension/Insight.DnSpy.csproj +13 -0
  227. package/runtime/native/dnspy-extension/Insight.DnSpy.x.dll +0 -0
  228. package/runtime/native/dnspy-extension/NuGet.Config +1 -0
  229. package/runtime/native/dnspy-extension/UNICODE-LOADER.md +26 -0
  230. package/runtime/native/dnspy-extension/packages.lock.json +6 -0
  231. package/runtime/native/dnspy-extension/provenance.json +27 -0
  232. package/runtime/native/dnspy-extension/upstream-public-build.snk +0 -0
  233. package/runtime/native/dnspy-extension/vendor-files.json +4341 -0
  234. package/runtime/native/file-version.ps1 +7 -0
  235. package/runtime/native/insight-registry-win-x64.dll +0 -0
  236. package/runtime/native/mitmproxy/bridge.py +180 -0
  237. package/runtime/native/mitmproxy/notices.json +476 -0
  238. package/runtime/native/sources/detours-LICENSE.md +23 -0
  239. package/runtime/native/sources/detours-e4bfd6b.tar.gz +0 -0
  240. package/runtime/native/sources/detours-provenance.json +10 -0
  241. package/runtime/native/tshark-layout.json +2247 -0
  242. package/runtime/native/windows-job/DirectoryAlias.cs +24 -0
  243. package/runtime/native/windows-job/Insight.WindowsJob.csproj +1 -0
  244. package/runtime/native/windows-job/Insight.WindowsJob.dll +0 -0
  245. package/runtime/native/windows-job/NuGet.Config +1 -0
  246. package/runtime/native/windows-job/OwnedJob.cs +79 -0
  247. package/runtime/native/windows-job/RegistryRedirect.cs +45 -0
  248. package/runtime/native/windows-job/packages.lock.json +21 -0
  249. package/runtime/native/windows-job/provenance.json +16 -0
  250. package/runtime/native/windows-job/windows-job.ps1 +8 -0
  251. package/runtime/native/windows-registry.c +21 -0
  252. package/runtime/native/windows-registry.def +3 -0
  253. package/runtime/native/windows-registry.provenance.json +14 -0
  254. package/runtime/notices/diagnostics-10.0.750501.txt +23 -0
  255. package/runtime/tool-catalog.json +290 -0
  256. package/runtime/toolbox.json +1401 -0
  257. package/skill-bundle/insight-artifacts/SKILL.md +30 -0
  258. package/skill-bundle/insight-artifacts/references/agent-execution.md +36 -0
  259. package/skill-bundle/insight-artifacts/references/artifacts.md +52 -0
  260. package/skill-bundle/insight-binary/SKILL.md +46 -0
  261. package/skill-bundle/insight-binary/references/agent-execution.md +36 -0
  262. package/skill-bundle/insight-capture/SKILL.md +56 -0
  263. package/skill-bundle/insight-capture/references/agent-execution.md +36 -0
  264. package/skill-bundle/insight-cli/SKILL.md +42 -0
  265. package/skill-bundle/insight-cli/references/agent-execution.md +36 -0
  266. package/skill-bundle/insight-cli/references/agent-setup.md +61 -0
  267. package/skill-bundle/insight-die/SKILL.md +49 -0
  268. package/skill-bundle/insight-die/references/agent-execution.md +36 -0
  269. package/skill-bundle/insight-dnspy/SKILL.md +65 -0
  270. package/skill-bundle/insight-dnspy/references/agent-execution.md +36 -0
  271. package/skill-bundle/insight-dotnet-dump/SKILL.md +46 -0
  272. package/skill-bundle/insight-dotnet-dump/references/agent-execution.md +36 -0
  273. package/skill-bundle/insight-dotnet-stack/SKILL.md +39 -0
  274. package/skill-bundle/insight-dotnet-stack/references/agent-execution.md +36 -0
  275. package/skill-bundle/insight-dotnet-trace/SKILL.md +45 -0
  276. package/skill-bundle/insight-dotnet-trace/references/agent-execution.md +36 -0
  277. package/skill-bundle/insight-frida/SKILL.md +67 -0
  278. package/skill-bundle/insight-frida/references/agent-execution.md +36 -0
  279. package/skill-bundle/insight-ghidra/SKILL.md +91 -0
  280. package/skill-bundle/insight-ghidra/references/administration.md +34 -0
  281. package/skill-bundle/insight-ghidra/references/agent-execution.md +36 -0
  282. package/skill-bundle/insight-ghidra/references/archive.md +32 -0
  283. package/skill-bundle/insight-ghidra/references/artifacts.md +52 -0
  284. package/skill-bundle/insight-ghidra/references/debugger.md +62 -0
  285. package/skill-bundle/insight-ghidra/references/extensions-and-sync.md +124 -0
  286. package/skill-bundle/insight-ghidra/references/managed-runtime.md +162 -0
  287. package/skill-bundle/insight-ghidra/references/native-workflows.md +122 -0
  288. package/skill-bundle/insight-ghidra/references/query-semantics.md +96 -0
  289. package/skill-bundle/insight-ghidra/references/recovery.md +53 -0
  290. package/skill-bundle/insight-ghidra/references/research.md +101 -0
  291. package/skill-bundle/insight-ghidra/references/setup.md +50 -0
  292. package/skill-bundle/insight-ilspy/SKILL.md +45 -0
  293. package/skill-bundle/insight-ilspy/references/agent-execution.md +36 -0
  294. package/skill-bundle/insight-ilspy/references/ilspy.md +33 -0
  295. package/skill-bundle/insight-interop/SKILL.md +54 -0
  296. package/skill-bundle/insight-interop/references/agent-execution.md +36 -0
  297. package/skill-bundle/insight-lldb/SKILL.md +54 -0
  298. package/skill-bundle/insight-lldb/references/agent-execution.md +36 -0
  299. package/skill-bundle/insight-llvm/SKILL.md +56 -0
  300. package/skill-bundle/insight-llvm/references/agent-execution.md +36 -0
  301. package/skill-bundle/insight-managed-heap/SKILL.md +43 -0
  302. package/skill-bundle/insight-managed-heap/references/agent-execution.md +36 -0
  303. package/skill-bundle/insight-managed-metadata/SKILL.md +52 -0
  304. package/skill-bundle/insight-managed-metadata/references/agent-execution.md +36 -0
  305. package/skill-bundle/insight-mitmproxy/SKILL.md +62 -0
  306. package/skill-bundle/insight-mitmproxy/references/agent-execution.md +36 -0
  307. package/skill-bundle/insight-overview/SKILL.md +79 -0
  308. package/skill-bundle/insight-overview/references/agent-execution.md +36 -0
  309. package/skill-bundle/insight-procmon/SKILL.md +49 -0
  310. package/skill-bundle/insight-procmon/references/agent-execution.md +36 -0
  311. package/skill-bundle/insight-re/SKILL.md +121 -0
  312. package/skill-bundle/insight-re/references/agent-execution.md +36 -0
  313. package/skill-bundle/insight-re/references/artifacts.md +52 -0
  314. package/skill-bundle/insight-re/references/recovery.md +53 -0
  315. package/skill-bundle/insight-sevenzip/SKILL.md +42 -0
  316. package/skill-bundle/insight-sevenzip/references/agent-execution.md +36 -0
  317. package/skill-bundle/insight-strace/SKILL.md +46 -0
  318. package/skill-bundle/insight-strace/references/agent-execution.md +36 -0
  319. package/skill-bundle/insight-tshark/SKILL.md +49 -0
  320. package/skill-bundle/insight-tshark/references/agent-execution.md +36 -0
  321. package/skill-bundle/insight-windbg/SKILL.md +46 -0
  322. package/skill-bundle/insight-windbg/references/agent-execution.md +36 -0
  323. package/skill-bundle/manifest.json +32 -0
  324. package/skills/insight-artifacts/SKILL.md +30 -0
  325. package/skills/insight-artifacts/references/agent-execution.md +36 -0
  326. package/skills/insight-artifacts/references/artifacts.md +52 -0
  327. package/skills/insight-binary/SKILL.md +46 -0
  328. package/skills/insight-binary/references/agent-execution.md +36 -0
  329. package/skills/insight-capture/SKILL.md +56 -0
  330. package/skills/insight-capture/references/agent-execution.md +36 -0
  331. package/skills/insight-die/SKILL.md +49 -0
  332. package/skills/insight-die/references/agent-execution.md +36 -0
  333. package/skills/insight-dnspy/SKILL.md +65 -0
  334. package/skills/insight-dnspy/references/agent-execution.md +36 -0
  335. package/skills/insight-dotnet-dump/SKILL.md +46 -0
  336. package/skills/insight-dotnet-dump/references/agent-execution.md +36 -0
  337. package/skills/insight-dotnet-stack/SKILL.md +39 -0
  338. package/skills/insight-dotnet-stack/references/agent-execution.md +36 -0
  339. package/skills/insight-dotnet-trace/SKILL.md +45 -0
  340. package/skills/insight-dotnet-trace/references/agent-execution.md +36 -0
  341. package/skills/insight-frida/SKILL.md +67 -0
  342. package/skills/insight-frida/references/agent-execution.md +36 -0
  343. package/skills/insight-ghidra/SKILL.md +91 -0
  344. package/skills/insight-ghidra/references/administration.md +34 -0
  345. package/skills/insight-ghidra/references/agent-execution.md +36 -0
  346. package/skills/insight-ghidra/references/archive.md +32 -0
  347. package/skills/insight-ghidra/references/artifacts.md +52 -0
  348. package/skills/insight-ghidra/references/debugger.md +62 -0
  349. package/skills/insight-ghidra/references/extensions-and-sync.md +124 -0
  350. package/skills/insight-ghidra/references/managed-runtime.md +162 -0
  351. package/skills/insight-ghidra/references/native-workflows.md +122 -0
  352. package/skills/insight-ghidra/references/query-semantics.md +96 -0
  353. package/skills/insight-ghidra/references/recovery.md +53 -0
  354. package/skills/insight-ghidra/references/research.md +101 -0
  355. package/skills/insight-ghidra/references/setup.md +50 -0
  356. package/skills/insight-ilspy/SKILL.md +45 -0
  357. package/skills/insight-ilspy/references/agent-execution.md +36 -0
  358. package/skills/insight-ilspy/references/ilspy.md +33 -0
  359. package/skills/insight-interop/SKILL.md +54 -0
  360. package/skills/insight-interop/references/agent-execution.md +36 -0
  361. package/skills/insight-lldb/SKILL.md +54 -0
  362. package/skills/insight-lldb/references/agent-execution.md +36 -0
  363. package/skills/insight-llvm/SKILL.md +56 -0
  364. package/skills/insight-llvm/references/agent-execution.md +36 -0
  365. package/skills/insight-managed-heap/SKILL.md +43 -0
  366. package/skills/insight-managed-heap/references/agent-execution.md +36 -0
  367. package/skills/insight-managed-metadata/SKILL.md +52 -0
  368. package/skills/insight-managed-metadata/references/agent-execution.md +36 -0
  369. package/skills/insight-mitmproxy/SKILL.md +62 -0
  370. package/skills/insight-mitmproxy/references/agent-execution.md +36 -0
  371. package/skills/insight-overview/SKILL.md +79 -0
  372. package/skills/insight-overview/references/agent-execution.md +36 -0
  373. package/skills/insight-procmon/SKILL.md +49 -0
  374. package/skills/insight-procmon/references/agent-execution.md +36 -0
  375. package/skills/insight-re/SKILL.md +22 -9
  376. package/skills/insight-re/references/agent-execution.md +36 -0
  377. package/skills/insight-re/references/artifacts.md +52 -0
  378. package/skills/insight-re/references/recovery.md +53 -0
  379. package/skills/insight-sevenzip/SKILL.md +42 -0
  380. package/skills/insight-sevenzip/references/agent-execution.md +36 -0
  381. package/skills/insight-strace/SKILL.md +46 -0
  382. package/skills/insight-strace/references/agent-execution.md +36 -0
  383. package/skills/insight-tshark/SKILL.md +49 -0
  384. package/skills/insight-tshark/references/agent-execution.md +36 -0
  385. package/skills/insight-windbg/SKILL.md +46 -0
  386. package/skills/insight-windbg/references/agent-execution.md +36 -0
  387. package/dist/src/runtime-archives.d.ts +0 -5
@@ -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,5 +1,7 @@
1
+ import { launchProcess, terminateProcess } from './tool-runtime/supervisor.js';
2
+ import { runTool } from './tool-runtime/run.js';
3
+ import { verifyGhidraProcess } from './ghidra-processes.js';
1
4
  import { runtimeProcesses } from './runtime-manager.js';
2
- import { spawn } from 'node:child_process';
3
5
  import { randomUUID, randomBytes } from 'node:crypto';
4
6
  import { mkdir, open, readFile, readdir, rename, link, realpath, copyFile, chmod, writeFile } from 'node:fs/promises';
5
7
  import { constants } from 'node:fs';
@@ -13,14 +15,14 @@ import { HttpBridge } from './transport.js';
13
15
  import { scriptInventory, scriptPath } from './scripts.js';
14
16
  import { logicalPrograms } from './cross-results.js';
15
17
  import { uiResult } from './ui-results.js';
16
- import { execFile } from 'node:child_process';
17
- import { promisify } from 'node:util';
18
18
  import { fileURLToPath } from 'node:url';
19
+ import { readCallerGoal, awaitCaller } from './debugger-caller.js';
19
20
  import { debuggerProgramMetadata } from './debugger-results.js';
20
21
  import { nativeQueries } from './query-policy.js';
21
22
  import { nativeQuery } from './native-queries.js';
22
23
  import { sdkWrites } from './sdk-contracts.js';
23
24
  import { initialIntent, initializeModel } from './initial-model.js';
25
+ import { managedGhidraDebugger, prepareGhidraDebugger } from './ghidra-debugger-runtime.js';
24
26
  const alive = (pid) => {
25
27
  try {
26
28
  process.kill(pid, 0);
@@ -91,16 +93,19 @@ export class GhidraContexts {
91
93
  return root;
92
94
  }
93
95
  async launch(root, target, kind, program, mode, context, credentials = {}) {
94
- 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)
95
97
  fail('binding', 'Native runtime inputs changed; stop the owner before using a different build.');
96
98
  const endpointPort = await port(), tokenSecret = 'context-' + randomUUID(), token = randomBytes(32).toString('hex');
97
99
  await this.c.secrets.set(tokenSecret, token);
98
- const classes = await nativeHelpers(this.workspace.directory, this.inputs);
99
- let debuggerEnvironment = {};
100
+ const classes = await nativeHelpers(this.workspace.directory, this.inputs, this.c);
101
+ let debuggerEnvironment = {}, debuggerPython, debuggerRuntime;
100
102
  if (mode === 'gui') {
103
+ if (managedGhidraDebugger())
104
+ debuggerRuntime = await prepareGhidraDebugger(this.c);
101
105
  const python = join(root, 'debug-python-' + randomUUID());
102
106
  await mkdir(python, { mode: 0o700 });
103
- 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 });
104
109
  if (object(JSON.parse(prepared.stdout)).state !== 'prepared')
105
110
  fail('configuration', 'Owned debugger Python dependencies could not be prepared.');
106
111
  debuggerEnvironment = { INSIGHT_DEBUGGER_PYTHON: python, PYTHONPATH: python, PYTHONNOUSERSITE: '1', PYTHONDONTWRITEBYTECODE: '1', PYTHONPYCACHEPREFIX: join(python, 'isolated-cache') };
@@ -117,19 +122,23 @@ export class GhidraContexts {
117
122
  const main = mode === 'gui' ? 'InsightGuiMain' : 'InsightHeadlessMain';
118
123
  const args = mode === 'gui' ? [root, 'view', String(endpointPort)] : ['--bind', '127.0.0.1', '--port', String(endpointPort)];
119
124
  const log = await open(join(root, 'runtime.log'), 'a', 0o600);
120
- 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,
121
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],
122
128
  env: { PATH: this.c.environment.PATH ?? process.env.PATH, HOME: root, TMPDIR: root, XDG_RUNTIME_DIR: root,
123
- GHIDRA_MCP_AUTH_TOKEN: token, GHIDRA_MCP_FILE_ROOT: root, GHIDRA_MCP_SHARED_PROJECT_DIR: root,
124
- 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
+ } });
125
137
  child.on('error', () => { });
126
138
  child.unref();
127
139
  await log.close();
128
140
  if (!child.pid)
129
141
  fail('launch', 'Owned Ghidra context could not be launched.');
130
- const binding = { pid: child.pid, endpoint: `http://127.0.0.1:${endpointPort}`, root, target: target.id,
131
- ...(context ? { context } : {}), kind, mode, program, tokenSecret, runtimeFingerprint: this.inputs.fingerprint };
132
- await durable(join(root, 'process.json'), binding);
133
142
  const record = { binding, http: new HttpBridge(binding.endpoint, this.c.fetch, this.c.signal, token), child };
134
143
  this.running.set(root, record);
135
144
  const deadline = Date.now() + 90000;
@@ -192,7 +201,10 @@ export class GhidraContexts {
192
201
  const token = await this.c.secrets.require(binding.tokenSecret), http = new HttpBridge(binding.endpoint, this.c.fetch, new AbortController().signal, token, 60000);
193
202
  await this.debuggerHelperRecord({ ...record, http }, 'Stop', 'INSIGHT_DEBUGGER_STOPPED');
194
203
  }
195
- 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');
196
208
  for (let i = 0; i < 100 && alive(binding.pid); i++)
197
209
  await delay(50);
198
210
  if (alive(binding.pid))
@@ -731,7 +743,20 @@ public class ${name} extends GhidraScript {
731
743
  if (operation === 'read_memory')
732
744
  await this.traceHelper(scope, { operation: 'read_memory', address: p.address, size: p.size });
733
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;
734
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
+ }
735
760
  const label = this.workspace.target(scope.target).name;
736
761
  if (operation === 'modules' && Array.isArray(raw))
737
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 } : {}) }; });
@@ -824,8 +849,9 @@ public class ${name} extends GhidraScript {
824
849
  const cwd = p.cwd === undefined ? root : text(p.cwd, 4096);
825
850
  if (/[\r\n\0]/.test(cwd))
826
851
  fail('invalid', 'Debugger working directory must be a single filesystem path.');
827
- await durable(join(record.binding.root, 'debugger-run', 'current.json'), { request, target: scope.target, context: record.binding.context, executable, cwd });
828
- 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,
829
855
  ...(this.c.profile.values.debuggerPython ? { python_executable: text(this.c.profile.values.debuggerPython, 4096) } : {}),
830
856
  ...(this.c.profile.values.windbgDir ? { windbg_dir: text(this.c.profile.values.windbgDir, 4096) } : {}) });
831
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;
@@ -1,9 +1,13 @@
1
1
  /** Internal LLDB child owner. It has no public command or independent product IPC host. */
2
- import { spawn } from 'node:child_process';
2
+ import { launchProcess, registerExistingProcess } from './tool-runtime/supervisor.js';
3
+ import { createServer } from 'node:http';
3
4
  import { readFile, writeFile, mkdir, open, rename, realpath } from 'node:fs/promises';
4
5
  import { join, resolve, delimiter } from 'node:path';
5
6
  import { randomUUID } from 'node:crypto';
6
7
  import { HttpBridge } from './transport.js';
8
+ import { callerMonitor } from './debugger-caller.js';
9
+ import { debuggerLaunchArguments } from './debugger-launch.js';
10
+ import { verifyManagedInstallation } from './tool-runtime/installer.js';
7
11
  async function main() {
8
12
  const root = await realpath(process.argv[2]), binding = JSON.parse(await readFile(join(root, 'process.json'), 'utf8'));
9
13
  if (root !== resolve(root) || binding.root !== root || binding.mode !== 'gui' || !Number.isSafeInteger(binding.pid))
@@ -38,6 +42,23 @@ async function main() {
38
42
  finally {
39
43
  await parent.close();
40
44
  } }
45
+ const appData = process.env.INSIGHT_TOOL_APPDATA, canonicalAppData = appData ? await realpath(appData) : undefined;
46
+ if (!appData || !canonicalAppData || !root.startsWith(join(canonicalAppData, 'workspace', 'ghidra-native') + '/'))
47
+ throw Error('Invalid tool profile');
48
+ if (binding.debuggerRuntime)
49
+ await verifyManagedInstallation(appData, 'ghidra-debugger', binding.debuggerRuntime);
50
+ const authority = createServer((req, res) => { if (req.url !== '/identity' || req.headers.authorization !== 'Bearer ' + token) {
51
+ res.writeHead(403).end();
52
+ return;
53
+ } res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify({ id, pid: process.pid, childPid: receipt.childPid, state: receipt.state })); });
54
+ await new Promise(ok => authority.listen(0, '127.0.0.1', ok));
55
+ authority.unref();
56
+ const address = authority.address();
57
+ if (!address || typeof address === 'string')
58
+ throw Error('No debugger identity port');
59
+ Object.assign(receipt, { identityPort: address.port });
60
+ const processSpec = { tool: 'ghidra', installation: binding.runtimeFingerprint, target: binding.target, session: binding.session, metadata: { debuggerReceipt: path, debuggerDiagnostics: join(directory, id + '.diagnostic.log'), contextRoot: root, ...(binding.debuggerRuntime ? { debuggerInstallation: binding.debuggerRuntime.id, debuggerFingerprint: binding.debuggerRuntime.fingerprint } : {}) } };
61
+ const helperProcess = await registerExistingProcess(appData, { ...processSpec, role: 'debugger-supervisor' }, process.execPath, process.pid, async () => true);
41
62
  await saved();
42
63
  const environment = { ...process.env };
43
64
  delete environment.GHIDRA_MCP_AUTH_TOKEN;
@@ -47,14 +68,22 @@ async function main() {
47
68
  const python = await realpath(environment.INSIGHT_DEBUGGER_PYTHON ?? '');
48
69
  if (!python.startsWith(root + '/debug-python-') || python !== environment.INSIGHT_DEBUGGER_PYTHON)
49
70
  throw Error('Owned debugger Python identity changed');
71
+ let debuggerExecutable = '/usr/bin/lldb';
72
+ if (binding.debuggerRuntime) {
73
+ debuggerExecutable = binding.debuggerRuntime.executable;
74
+ Object.assign(environment, binding.debuggerRuntime.environment);
75
+ Object.assign(receipt, { debuggerInstallation: binding.debuggerRuntime.id, debuggerFingerprint: binding.debuggerRuntime.fingerprint });
76
+ }
50
77
  environment.PYTHONPATH = python + delimiter + (environment.PYTHONPATH ?? '');
51
78
  delete environment.INSIGHT_DEBUGGER_PYTHON;
52
- let closing = false, finished = false;
79
+ let closing = false, finished = false, launchComplete = false;
53
80
  process.once('SIGHUP', close);
54
81
  process.once('SIGTERM', close);
55
82
  // A separate session keeps the GUI terminal's SIGHUP from bypassing our orderly kill.
56
- const child = spawn('/usr/bin/lldb', ['--no-lldbinit', '-o', 'settings set auto-confirm true', ...process.argv.slice(3)], { env: environment, detached: true, stdio: ['pipe', 'pipe', 'pipe'] });
57
- const exited = new Promise((ok, bad) => { child.once('error', bad); child.once('exit', () => { finished = true; ok(); }); });
83
+ const launchArguments = process.argv.slice(3), usesGhidra = launchArguments.includes('script import os, ghidralldb');
84
+ const child = await launchProcess(appData, { ...processSpec, role: 'debugger' }, debuggerExecutable, ['--no-lldbinit', '-o', 'settings set auto-confirm true', '-o', 'settings set target.detach-on-error false', ...debuggerLaunchArguments(launchArguments, launch.stopAtEntry === true, usesGhidra ? python : undefined)], { env: environment, detached: true, stdio: ['pipe', 'pipe', 'pipe'] });
85
+ launchComplete = true;
86
+ const exited = child.toolClosed.then(() => { finished = true; });
58
87
  void exited.catch(() => { });
59
88
  receipt.childPid = child.pid ?? 0;
60
89
  receipt.state = 'running';
@@ -87,6 +116,10 @@ async function main() {
87
116
  function close() {
88
117
  if (closing || finished)
89
118
  return;
119
+ if (!launchComplete) {
120
+ setTimeout(close, 10).unref();
121
+ return;
122
+ }
90
123
  closing = true;
91
124
  process.stdin.pause();
92
125
  child.stdout.unpipe(process.stdout);
@@ -104,13 +137,23 @@ async function main() {
104
137
  child.kill('SIGINT'); });
105
138
  process.stdin.once('end', close);
106
139
  process.stdin.once('error', close);
107
- const monitor = setInterval(() => { try {
108
- process.kill(binding.pid, 0);
109
- }
110
- catch (error) {
111
- if (error.code === 'ESRCH')
112
- close();
113
- } }, 250);
140
+ const observeCaller = callerMonitor(python, command => { if (!closing && !finished)
141
+ child.stdin.write(command); });
142
+ let callerDiagnostic = false;
143
+ const monitor = setInterval(() => {
144
+ try {
145
+ process.kill(binding.pid, 0);
146
+ }
147
+ catch (error) {
148
+ if (error.code === 'ESRCH')
149
+ close();
150
+ }
151
+ if (!closing && !finished)
152
+ void observeCaller().catch(() => { if (!callerDiagnostic) {
153
+ callerDiagnostic = true;
154
+ process.stderr.write('Native caller observation failed; its request is retained.\n');
155
+ } });
156
+ }, 250);
114
157
  try {
115
158
  await saved();
116
159
  await exited;
@@ -122,13 +165,13 @@ async function main() {
122
165
  receipt.inferiorTerminated = result?.id === id && result.inferiorTerminated === true;
123
166
  receipt.state = receipt.inferiorTerminated ? 'closed' : 'failed';
124
167
  Object.assign(receipt, { exitCode: child.exitCode, signalCode: child.signalCode });
125
- if (!receipt.inferiorTerminated)
126
- await writeFile(join(directory, id + '.diagnostic.log'), diagnostics, { mode: 0o600 });
168
+ await writeFile(join(directory, id + '.diagnostic.log'), diagnostics, { mode: 0o600 });
127
169
  await saved();
128
170
  }
129
171
  finally {
130
172
  clearInterval(monitor);
131
173
  process.stdin.pause();
174
+ authority.close();
132
175
  }
133
176
  // Keep a failed child outcome observable; never claim that killing LLDB proves inferior exit.
134
177
  process.exitCode = receipt.inferiorTerminated ? 0 : 1;
@@ -3,7 +3,7 @@ import { resolve } from 'node:path';
3
3
  import { scope, address, number } from './research.js';
4
4
  import { id, text, object, fail } from './model.js';
5
5
  import { selectedOptions } from './arguments.js';
6
- import { debuggerResult, debuggerProgramMetadata as metadata } from './debugger-results.js';
6
+ import { debuggerResult, debuggerExecutionSettled, debuggerProgramMetadata as metadata } from './debugger-results.js';
7
7
  import { setTimeout as delay } from 'node:timers/promises';
8
8
  import { randomUUID } from 'node:crypto';
9
9
  const lists = ['launch_offers', 'modules', 'list_breakpoints', 'stack_trace'];
@@ -89,7 +89,7 @@ export class Debugger {
89
89
  if (request.state === 'failed' && result.reason === 'disconnected')
90
90
  fail('disconnected', 'Selected trace has no live target.', result);
91
91
  if (request.state === 'failed' && result.reason === 'busy')
92
- fail('busy', 'This context already has a live debug target; use another session for another process.', result);
92
+ fail('busy', 'This context still has a connected debugger; close/reopen it or use another session before a new launch.', result);
93
93
  if (request.state === 'failed' && result.reason === 'native_precondition')
94
94
  fail('rejected', 'The native live precondition failed; the target write was not started.', result);
95
95
  fail('unknown', 'Debugger action is retained and is not repeated.', request.result);
@@ -98,7 +98,7 @@ export class Debugger {
98
98
  if (operation === 'launch' && (await backend.debuggerSaved(selected)).connected) {
99
99
  const result = { ...selected, state: 'not_started', reason: 'busy' };
100
100
  this.workspace.recordRequest(request.id, 'failed', result);
101
- fail('busy', 'This context already has a live debug target; use another session for another process.', result);
101
+ fail('busy', 'This context still has a connected debugger; close/reopen it or use another session before a new launch.', result);
102
102
  }
103
103
  const before = debuggerResult('status', {}, await backend.debuggerCall(selected, 'status'));
104
104
  if (operation !== 'launch' && object(before).target_connected !== true) {
@@ -125,11 +125,10 @@ export class Debugger {
125
125
  }
126
126
  const value = debuggerResult(operation, p, raw);
127
127
  if (['resume', 'interrupt', 'step'].includes(operation)) {
128
- const wanted = operation === 'resume' ? 'RUNNING' : 'STOPPED';
129
128
  let observed = false;
130
129
  for (let attempt = 0; attempt < 40; attempt++) {
131
130
  const status = object(debuggerResult('status', {}, await backend.debuggerCall(selected, 'status')));
132
- if (status.execution_state === wanted || operation === 'resume' && status.execution_state === 'STOPPED' && BigInt(String(status.snap ?? 0)) > BigInt(String(object(before).snap ?? 0))) {
131
+ if (debuggerExecutionSettled(operation, object(before), status)) {
133
132
  observed = true;
134
133
  break;
135
134
  }
@@ -151,11 +150,16 @@ export class Debugger {
151
150
  if (!observed)
152
151
  fail('partial', 'Breakpoint inventory did not verify the action.');
153
152
  }
153
+ if (operation === 'launch' && p.stop_at_entry === true) {
154
+ const stopped = object(debuggerResult('status', {}, await backend.debuggerCall(selected, 'status')));
155
+ if (stopped.target_connected !== true || stopped.execution_state !== 'STOPPED')
156
+ fail('partial', 'Entry-stop launch did not verify a stopped live target.');
157
+ }
154
158
  saved = await backend.debuggerSaved(selected);
155
159
  savedSnapshot = await backend.saved(selected);
156
160
  metadataChanged = beforeMetadata !== undefined && beforeMetadata !== await metadata(backend, savedSnapshot);
157
161
  const complexChanges = metadataChanged ? [...context.complexChanges, request.id] : context.complexChanges;
158
- const result = { ...selected, state: 'applied', ...(saved.active ? { trace: saved.active } : {}), pendingChanges: context.scalars.length + complexChanges.length, sharedState: context.scalars.length || complexChanges.length ? 'pending' : 'shared', value };
162
+ const result = { ...selected, state: 'applied', ...(operation === 'launch' && p.stop_at_entry === true ? { stoppedAtEntry: true } : {}), ...(saved.active ? { trace: saved.active } : {}), pendingChanges: context.scalars.length + complexChanges.length, sharedState: context.scalars.length || complexChanges.length ? 'pending' : 'shared', value };
159
163
  this.workspace.completeSavedRequest(selected, request.id, context.generation, { debugger: saved, workingSnapshot: savedSnapshot, complexChanges }, result);
160
164
  return result;
161
165
  }
@@ -195,7 +199,7 @@ export function debuggerCommands(service) {
195
199
  ...(operation === 'schedule' ? [{ flags: '--schedule <time>', description: 'Parse and validate a native time schedule without executing it', required: true }] : []),
196
200
  ...(paged ? [{ flags: '--limit <count>', description: 'Page size 1–100', defaultValue: 50 }, { flags: '--offset <count>', description: 'Page offset', defaultValue: 0 }] : []),
197
201
  ...(operation === 'step' ? [{ flags: '--kind <kind>', description: 'into, over or out', defaultValue: 'into' }] : []),
198
- ...(operation === 'launch' ? [{ flags: '--args <text>', description: 'Target command-line arguments', defaultValue: '' }, { flags: '--cwd <directory>', description: 'Target working directory (default owned run folder)' },
202
+ ...(operation === 'launch' ? [{ flags: '--stop-at-entry', description: 'macOS local LLDB: launch stopped at entry for inspection before running' }, { flags: '--args <text>', description: 'Target command-line arguments', defaultValue: '' }, { flags: '--cwd <directory>', description: 'Target working directory (default owned run folder)' },
199
203
  { flags: '--offer <name>', description: 'Launch offer title or configuration name', defaultValue: process.platform === 'win32' ? 'dbgeng' : process.platform === 'darwin' ? 'lldb' : 'gdb' }, { flags: '--timeout-seconds <count>', description: 'Launch wait 1–300 seconds', defaultValue: 60 }] : []), ...(changing ? [request] : [])];
200
204
  leaves.push(command(operation.replaceAll('_', '-'), 'Use the selected context debugger', ({ options: o }, c) => {
201
205
  const p = {};
@@ -248,6 +252,11 @@ export function debuggerCommands(service) {
248
252
  fail('invalid', 'Step kind must be into, over or out.');
249
253
  }
250
254
  if (operation === 'launch') {
255
+ if (o.stopAtEntry === true) {
256
+ if (process.platform !== 'darwin' || o.offer !== 'lldb')
257
+ fail('unsupported', '--stop-at-entry requires the local macOS lldb offer.');
258
+ p.stop_at_entry = true;
259
+ }
251
260
  if (typeof o.args !== 'string' || o.args.length > 8192 || o.args.includes('\0'))
252
261
  fail('invalid', 'Arguments must be bounded text.');
253
262
  p.args = o.args;
@@ -0,0 +1,12 @@
1
+ import { type CommandContext, type CommandDefinition } from '@eyeauras/cli-factory';
2
+ import { ToolInstaller } from './tool-runtime/installer.js';
3
+ import type { Workspace } from './workspace.js';
4
+ export declare function dieInstaller(c: CommandContext): ToolInstaller;
5
+ /** Upstream may append signature errors after its JSON while exiting zero. Never discard them. */
6
+ export declare function dieJson(stdout: string, stderr: string): {
7
+ data: Record<string, unknown>;
8
+ diagnostics: string[];
9
+ complete: boolean;
10
+ };
11
+ export declare function dieFindings(data: Record<string, unknown>): Record<string, string>[];
12
+ export declare function dieCommands(workspace: (c: CommandContext) => Workspace): CommandDefinition[];