@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.
- package/.cli-package-build.json +1 -1
- package/README.md +33 -2
- package/SKILL.md +38 -51
- package/dist/src/administration-results.js +1 -1
- package/dist/src/administration.d.ts +1 -1
- package/dist/src/administration.js +16 -2
- package/dist/src/binary.d.ts +3 -0
- package/dist/src/binary.js +74 -0
- package/dist/src/capture.d.ts +3 -0
- package/dist/src/capture.js +220 -0
- package/dist/src/cli.js +91 -14
- package/dist/src/contexts.d.ts +5 -0
- package/dist/src/contexts.js +54 -18
- package/dist/src/debugger-caller.d.ts +17 -0
- package/dist/src/debugger-caller.js +129 -0
- package/dist/src/debugger-launch.d.ts +2 -0
- package/dist/src/debugger-launch.js +17 -0
- package/dist/src/debugger-results.d.ts +1 -0
- package/dist/src/debugger-results.js +8 -0
- package/dist/src/debugger-supervisor.js +56 -13
- package/dist/src/debugger.js +16 -7
- package/dist/src/die.d.ts +12 -0
- package/dist/src/die.js +127 -0
- package/dist/src/dnspy-runtime.d.ts +8 -0
- package/dist/src/dnspy-runtime.js +46 -0
- package/dist/src/dnspy.d.ts +22 -0
- package/dist/src/dnspy.js +160 -0
- package/dist/src/dotnet-diagnostics.d.ts +13 -0
- package/dist/src/dotnet-diagnostics.js +101 -0
- package/dist/src/frida-worker.d.ts +1 -0
- package/dist/src/frida-worker.js +125 -0
- package/dist/src/frida.d.ts +16 -0
- package/dist/src/frida.js +125 -0
- package/dist/src/ghidra-debugger-runtime.d.ts +7 -0
- package/dist/src/ghidra-debugger-runtime.js +31 -0
- package/dist/src/ghidra-processes.d.ts +6 -0
- package/dist/src/ghidra-processes.js +121 -0
- package/dist/src/ghidra.js +6 -6
- package/dist/src/ilspy.d.ts +7 -0
- package/dist/src/ilspy.js +122 -0
- package/dist/src/lifecycle.d.ts +1 -1
- package/dist/src/lifecycle.js +8 -2
- package/dist/src/lldb.d.ts +10 -0
- package/dist/src/lldb.js +99 -0
- package/dist/src/llvm.d.ts +6 -0
- package/dist/src/llvm.js +133 -0
- package/dist/src/managed-heap.d.ts +4 -0
- package/dist/src/managed-heap.js +73 -0
- package/dist/src/managed-metadata.d.ts +11 -0
- package/dist/src/managed-metadata.js +66 -0
- package/dist/src/mitmproxy.d.ts +55 -0
- package/dist/src/mitmproxy.js +172 -0
- package/dist/src/native-inputs.d.ts +3 -2
- package/dist/src/native-inputs.js +21 -5
- package/dist/src/package-version.d.ts +1 -0
- package/dist/src/package-version.js +3 -0
- package/dist/src/procmon-config.d.ts +2 -0
- package/dist/src/procmon-config.js +15 -0
- package/dist/src/procmon-events.d.ts +13 -0
- package/dist/src/procmon-events.js +82 -0
- package/dist/src/procmon.d.ts +4 -0
- package/dist/src/procmon.js +107 -0
- package/dist/src/research.d.ts +11 -2
- package/dist/src/research.js +5 -3
- package/dist/src/runtime-catalog.d.ts +13 -0
- package/dist/src/runtime-catalog.js +26 -0
- package/dist/src/runtime-manager.d.ts +125 -0
- package/dist/src/runtime-manager.js +385 -0
- package/dist/src/runtime-selection.d.ts +13 -0
- package/dist/src/runtime-selection.js +42 -0
- package/dist/src/server.d.ts +15 -0
- package/dist/src/server.js +77 -96
- package/dist/src/sevenzip.d.ts +15 -0
- package/dist/src/sevenzip.js +119 -0
- package/dist/src/strace.d.ts +10 -0
- package/dist/src/strace.js +71 -0
- package/dist/src/text-window.d.ts +11 -0
- package/dist/src/text-window.js +6 -0
- package/dist/src/tool-runtime/archives.d.ts +10 -0
- package/dist/src/tool-runtime/archives.js +194 -0
- package/dist/src/tool-runtime/catalog.d.ts +3 -0
- package/dist/src/tool-runtime/catalog.js +13 -0
- package/dist/src/tool-runtime/commands.d.ts +9 -0
- package/dist/src/tool-runtime/commands.js +39 -0
- package/dist/src/tool-runtime/deadline.d.ts +11 -0
- package/dist/src/tool-runtime/deadline.js +32 -0
- package/dist/src/tool-runtime/definition.d.ts +73 -0
- package/dist/src/tool-runtime/definition.js +49 -0
- package/dist/src/tool-runtime/dotnet.d.ts +4 -0
- package/dist/src/tool-runtime/dotnet.js +22 -0
- package/dist/src/tool-runtime/identity.d.ts +6 -0
- package/dist/src/tool-runtime/identity.js +50 -0
- package/dist/src/tool-runtime/installer.d.ts +101 -0
- package/dist/src/tool-runtime/installer.js +180 -0
- package/dist/src/tool-runtime/launch-worker.d.ts +1 -0
- package/dist/src/tool-runtime/launch-worker.js +58 -0
- package/dist/src/tool-runtime/run.d.ts +51 -0
- package/dist/src/tool-runtime/run.js +159 -0
- package/dist/src/tool-runtime/store.d.ts +15 -0
- package/dist/src/tool-runtime/store.js +219 -0
- package/dist/src/tool-runtime/supervisor.d.ts +57 -0
- package/dist/src/tool-runtime/supervisor.js +266 -0
- package/dist/src/tool-runtime/windows-job.d.ts +22 -0
- package/dist/src/tool-runtime/windows-job.js +43 -0
- package/dist/src/toolbox.d.ts +84 -0
- package/dist/src/toolbox.js +35 -0
- package/dist/src/tshark.d.ts +23 -0
- package/dist/src/tshark.js +174 -0
- package/dist/src/windbg.d.ts +14 -0
- package/dist/src/windbg.js +119 -0
- package/dist/src/workspace.d.ts +1 -0
- package/dist/src/workspace.js +6 -0
- package/package.json +7 -4
- package/references/administration.md +2 -1
- package/references/agent-execution.md +36 -0
- package/references/agent-setup.md +61 -0
- package/references/artifacts.md +5 -0
- package/references/debugger.md +22 -0
- package/references/ilspy.md +33 -0
- package/references/managed-runtime.md +157 -0
- package/references/native/InsightPythonWheels.java +283 -2
- package/references/native/InsightRuntimeDoctor.java +33 -0
- package/references/native/InsightTraceState.java +28 -13
- package/references/setup.md +6 -3
- package/runtime/managed/insight-heap/Azure.Core.dll +0 -0
- package/runtime/managed/insight-heap/Azure.Identity.dll +0 -0
- package/runtime/managed/insight-heap/Insight.Heap.csproj +1 -0
- package/runtime/managed/insight-heap/Insight.Heap.deps.json +391 -0
- package/runtime/managed/insight-heap/Insight.Heap.dll +0 -0
- package/runtime/managed/insight-heap/Insight.Heap.runtimeconfig.json +13 -0
- package/runtime/managed/insight-heap/Microsoft.Bcl.AsyncInterfaces.dll +0 -0
- package/runtime/managed/insight-heap/Microsoft.Diagnostics.NETCore.Client.dll +0 -0
- package/runtime/managed/insight-heap/Microsoft.Diagnostics.Runtime.dll +0 -0
- package/runtime/managed/insight-heap/Microsoft.Extensions.Configuration.Abstractions.dll +0 -0
- package/runtime/managed/insight-heap/Microsoft.Extensions.DependencyInjection.Abstractions.dll +0 -0
- package/runtime/managed/insight-heap/Microsoft.Extensions.Diagnostics.Abstractions.dll +0 -0
- package/runtime/managed/insight-heap/Microsoft.Extensions.FileProviders.Abstractions.dll +0 -0
- package/runtime/managed/insight-heap/Microsoft.Extensions.Hosting.Abstractions.dll +0 -0
- package/runtime/managed/insight-heap/Microsoft.Extensions.Logging.Abstractions.dll +0 -0
- package/runtime/managed/insight-heap/Microsoft.Extensions.Options.dll +0 -0
- package/runtime/managed/insight-heap/Microsoft.Extensions.Primitives.dll +0 -0
- package/runtime/managed/insight-heap/Microsoft.Identity.Client.Extensions.Msal.dll +0 -0
- package/runtime/managed/insight-heap/Microsoft.Identity.Client.dll +0 -0
- package/runtime/managed/insight-heap/Microsoft.IdentityModel.Abstractions.dll +0 -0
- package/runtime/managed/insight-heap/Microsoft.Security.AntiSSRF.dll +0 -0
- package/runtime/managed/insight-heap/NuGet.Config +1 -0
- package/runtime/managed/insight-heap/Program.cs +20 -0
- package/runtime/managed/insight-heap/README.md +16 -0
- package/runtime/managed/insight-heap/System.ClientModel.dll +0 -0
- package/runtime/managed/insight-heap/System.Memory.Data.dll +0 -0
- package/runtime/managed/insight-heap/System.Security.Cryptography.ProtectedData.dll +0 -0
- package/runtime/managed/insight-heap/dependencies.json +436 -0
- package/runtime/managed/insight-heap/notices/Azure.Core-LICENSE.txt +21 -0
- package/runtime/managed/insight-heap/notices/Azure.Identity-LICENSE.txt +21 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Bcl.AsyncInterfaces-LICENSE.txt +23 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Bcl.AsyncInterfaces-THIRD-PARTY-NOTICES.TXT +1418 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Diagnostics.NETCore.Client-LICENSE.txt +23 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Diagnostics.Runtime-LICENSE.txt +23 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Configuration.Abstractions-LICENSE.txt +23 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Configuration.Abstractions-THIRD-PARTY-NOTICES.TXT +1418 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Extensions.DependencyInjection.Abstractions-LICENSE.txt +23 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Extensions.DependencyInjection.Abstractions-THIRD-PARTY-NOTICES.TXT +1418 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Diagnostics.Abstractions-LICENSE.txt +23 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Diagnostics.Abstractions-THIRD-PARTY-NOTICES.TXT +1418 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Extensions.FileProviders.Abstractions-LICENSE.txt +23 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Extensions.FileProviders.Abstractions-THIRD-PARTY-NOTICES.TXT +1418 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Hosting.Abstractions-LICENSE.txt +23 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Hosting.Abstractions-THIRD-PARTY-NOTICES.TXT +1418 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Logging.Abstractions-LICENSE.txt +23 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Logging.Abstractions-THIRD-PARTY-NOTICES.TXT +1418 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Options-LICENSE.txt +23 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Options-THIRD-PARTY-NOTICES.TXT +1418 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Primitives-LICENSE.txt +23 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Extensions.Primitives-THIRD-PARTY-NOTICES.TXT +1418 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Identity.Client-LICENSE.txt +21 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Identity.Client.Extensions.Msal-LICENSE.txt +21 -0
- package/runtime/managed/insight-heap/notices/Microsoft.IdentityModel.Abstractions-LICENSE.txt +21 -0
- package/runtime/managed/insight-heap/notices/Microsoft.Security.AntiSSRF-LICENSE.txt +21 -0
- package/runtime/managed/insight-heap/notices/System.ClientModel-LICENSE.txt +21 -0
- package/runtime/managed/insight-heap/notices/System.Memory.Data-LICENSE.txt +23 -0
- package/runtime/managed/insight-heap/notices/System.Memory.Data-THIRD-PARTY-NOTICES.TXT +1418 -0
- package/runtime/managed/insight-heap/notices/System.Security.Cryptography.ProtectedData-LICENSE.TXT +23 -0
- package/runtime/managed/insight-heap/notices/System.Security.Cryptography.ProtectedData-THIRD-PARTY-NOTICES.TXT +309 -0
- package/runtime/managed/insight-heap/packages.lock.json +165 -0
- package/runtime/managed/insight-heap/provenance.json +146 -0
- package/runtime/managed/insight-heap/runtimes/win/lib/netstandard2.0/System.Security.Cryptography.ProtectedData.dll +0 -0
- package/runtime/managed/insight-managed/Insight.Managed.csproj +4 -0
- package/runtime/managed/insight-managed/Insight.Managed.deps.json +41 -0
- package/runtime/managed/insight-managed/Insight.Managed.dll +0 -0
- package/runtime/managed/insight-managed/Insight.Managed.runtimeconfig.json +13 -0
- package/runtime/managed/insight-managed/LICENSE.dnlib.txt +20 -0
- package/runtime/managed/insight-managed/NuGet.Config +1 -0
- package/runtime/managed/insight-managed/Program.cs +31 -0
- package/runtime/managed/insight-managed/README.md +16 -0
- package/runtime/managed/insight-managed/dnlib.dll +0 -0
- package/runtime/managed/insight-managed/packages.lock.json +13 -0
- package/runtime/managed/insight-managed/provenance.json +40 -0
- package/runtime/native/binary/README.md +22 -0
- package/runtime/native/binary/dependencies.json +166 -0
- package/runtime/native/binary/helper.cpp +44 -0
- package/runtime/native/binary/insight-binary-darwin-arm64 +0 -0
- package/runtime/native/binary/notices/Catch2-3.12.0--Catch2-3.12.0__LICENSE.txt +23 -0
- package/runtime/native/binary/notices/LIEF-LICENSE.txt +202 -0
- package/runtime/native/binary/notices/LIEF-attribution.txt +37 -0
- package/runtime/native/binary/notices/Melkor_ELF_Fuzzer-ac2495b--elf_fuzzer-master__LICENSE.txt +674 -0
- package/runtime/native/binary/notices/expected-1.3.1--expected-1.3.1__COPYING +121 -0
- package/runtime/native/binary/notices/frozen-61dce5a--frozen-61dce5ae18ca59931e27675c468e64118aba8744__AUTHORS +3 -0
- package/runtime/native/binary/notices/frozen-61dce5a--frozen-61dce5ae18ca59931e27675c468e64118aba8744__LICENSE +202 -0
- package/runtime/native/binary/notices/json-LICENSE.MIT +21 -0
- package/runtime/native/binary/notices/mbedtls-4.0.0.r0.gec4044008d--LICENSE +553 -0
- package/runtime/native/binary/notices/mbedtls-4.0.0.r0.gec4044008d--framework__LICENSE +553 -0
- package/runtime/native/binary/notices/mbedtls-4.0.0.r0.gec4044008d--tf-psa-crypto__LICENSE +552 -0
- package/runtime/native/binary/notices/mbedtls-4.0.0.r0.gec4044008d--tf-psa-crypto__framework__LICENSE +553 -0
- package/runtime/native/binary/notices/nanobind-2.13.0.r18.g4db9ed3f--LICENSE +26 -0
- package/runtime/native/binary/notices/nanobind-2.13.0.r18.g4db9ed3f--ext__robin_map__LICENSE +21 -0
- package/runtime/native/binary/notices/span-LICENSE_1_0.txt +23 -0
- package/runtime/native/binary/notices/span-attribution.txt +11 -0
- package/runtime/native/binary/notices/spdlog-1.17.0--spdlog-1.17.0__LICENSE +25 -0
- package/runtime/native/binary/notices/utfcpp-4.0.9--utfcpp-4.0.9__LICENSE +23 -0
- package/runtime/native/binary/provenance.json +48 -0
- package/runtime/native/child-deadline-linux-x64 +0 -0
- package/runtime/native/child-deadline-linux.c +24 -0
- package/runtime/native/child-deadline-linux.provenance.json +17 -0
- package/runtime/native/deadline-alarm-darwin-universal.dylib +0 -0
- package/runtime/native/deadline-alarm.c +33 -0
- package/runtime/native/deadline-alarm.provenance.json +22 -0
- package/runtime/native/deadline-exec-darwin-arm64 +0 -0
- package/runtime/native/deadline-exec.c +24 -0
- package/runtime/native/deadline-exec.provenance.json +17 -0
- package/runtime/native/dnspy-extension/Bridge.cs +58 -0
- package/runtime/native/dnspy-extension/Insight.DnSpy.csproj +13 -0
- package/runtime/native/dnspy-extension/Insight.DnSpy.x.dll +0 -0
- package/runtime/native/dnspy-extension/NuGet.Config +1 -0
- package/runtime/native/dnspy-extension/UNICODE-LOADER.md +26 -0
- package/runtime/native/dnspy-extension/packages.lock.json +6 -0
- package/runtime/native/dnspy-extension/provenance.json +27 -0
- package/runtime/native/dnspy-extension/upstream-public-build.snk +0 -0
- package/runtime/native/dnspy-extension/vendor-files.json +4341 -0
- package/runtime/native/file-version.ps1 +7 -0
- package/runtime/native/insight-registry-win-x64.dll +0 -0
- package/runtime/native/mitmproxy/bridge.py +180 -0
- package/runtime/native/mitmproxy/notices.json +476 -0
- package/runtime/native/sources/detours-LICENSE.md +23 -0
- package/runtime/native/sources/detours-e4bfd6b.tar.gz +0 -0
- package/runtime/native/sources/detours-provenance.json +10 -0
- package/runtime/native/tshark-layout.json +2247 -0
- package/runtime/native/windows-job/DirectoryAlias.cs +24 -0
- package/runtime/native/windows-job/Insight.WindowsJob.csproj +1 -0
- package/runtime/native/windows-job/Insight.WindowsJob.dll +0 -0
- package/runtime/native/windows-job/NuGet.Config +1 -0
- package/runtime/native/windows-job/OwnedJob.cs +79 -0
- package/runtime/native/windows-job/RegistryRedirect.cs +45 -0
- package/runtime/native/windows-job/packages.lock.json +21 -0
- package/runtime/native/windows-job/provenance.json +16 -0
- package/runtime/native/windows-job/windows-job.ps1 +8 -0
- package/runtime/native/windows-registry.c +21 -0
- package/runtime/native/windows-registry.def +3 -0
- package/runtime/native/windows-registry.provenance.json +14 -0
- package/runtime/notices/diagnostics-10.0.750501.txt +23 -0
- package/runtime/tool-catalog.json +290 -0
- package/runtime/toolbox.json +1401 -0
- package/skill-bundle/insight-artifacts/SKILL.md +30 -0
- package/skill-bundle/insight-artifacts/references/agent-execution.md +36 -0
- package/skill-bundle/insight-artifacts/references/artifacts.md +52 -0
- package/skill-bundle/insight-binary/SKILL.md +46 -0
- package/skill-bundle/insight-binary/references/agent-execution.md +36 -0
- package/skill-bundle/insight-capture/SKILL.md +56 -0
- package/skill-bundle/insight-capture/references/agent-execution.md +36 -0
- package/skill-bundle/insight-cli/SKILL.md +42 -0
- package/skill-bundle/insight-cli/references/agent-execution.md +36 -0
- package/skill-bundle/insight-cli/references/agent-setup.md +61 -0
- package/skill-bundle/insight-die/SKILL.md +49 -0
- package/skill-bundle/insight-die/references/agent-execution.md +36 -0
- package/skill-bundle/insight-dnspy/SKILL.md +65 -0
- package/skill-bundle/insight-dnspy/references/agent-execution.md +36 -0
- package/skill-bundle/insight-dotnet-dump/SKILL.md +46 -0
- package/skill-bundle/insight-dotnet-dump/references/agent-execution.md +36 -0
- package/skill-bundle/insight-dotnet-stack/SKILL.md +39 -0
- package/skill-bundle/insight-dotnet-stack/references/agent-execution.md +36 -0
- package/skill-bundle/insight-dotnet-trace/SKILL.md +45 -0
- package/skill-bundle/insight-dotnet-trace/references/agent-execution.md +36 -0
- package/skill-bundle/insight-frida/SKILL.md +67 -0
- package/skill-bundle/insight-frida/references/agent-execution.md +36 -0
- package/skill-bundle/insight-ghidra/SKILL.md +91 -0
- package/skill-bundle/insight-ghidra/references/administration.md +34 -0
- package/skill-bundle/insight-ghidra/references/agent-execution.md +36 -0
- package/skill-bundle/insight-ghidra/references/archive.md +32 -0
- package/skill-bundle/insight-ghidra/references/artifacts.md +52 -0
- package/skill-bundle/insight-ghidra/references/debugger.md +62 -0
- package/skill-bundle/insight-ghidra/references/extensions-and-sync.md +124 -0
- package/skill-bundle/insight-ghidra/references/managed-runtime.md +157 -0
- package/skill-bundle/insight-ghidra/references/native-workflows.md +112 -0
- package/skill-bundle/insight-ghidra/references/query-semantics.md +96 -0
- package/skill-bundle/insight-ghidra/references/recovery.md +53 -0
- package/skill-bundle/insight-ghidra/references/research.md +101 -0
- package/skill-bundle/insight-ghidra/references/setup.md +50 -0
- package/skill-bundle/insight-ilspy/SKILL.md +45 -0
- package/skill-bundle/insight-ilspy/references/agent-execution.md +36 -0
- package/skill-bundle/insight-ilspy/references/ilspy.md +33 -0
- package/skill-bundle/insight-interop/SKILL.md +54 -0
- package/skill-bundle/insight-interop/references/agent-execution.md +36 -0
- package/skill-bundle/insight-lldb/SKILL.md +54 -0
- package/skill-bundle/insight-lldb/references/agent-execution.md +36 -0
- package/skill-bundle/insight-llvm/SKILL.md +56 -0
- package/skill-bundle/insight-llvm/references/agent-execution.md +36 -0
- package/skill-bundle/insight-managed-heap/SKILL.md +43 -0
- package/skill-bundle/insight-managed-heap/references/agent-execution.md +36 -0
- package/skill-bundle/insight-managed-metadata/SKILL.md +52 -0
- package/skill-bundle/insight-managed-metadata/references/agent-execution.md +36 -0
- package/skill-bundle/insight-mitmproxy/SKILL.md +62 -0
- package/skill-bundle/insight-mitmproxy/references/agent-execution.md +36 -0
- package/skill-bundle/insight-overview/SKILL.md +79 -0
- package/skill-bundle/insight-overview/references/agent-execution.md +36 -0
- package/skill-bundle/insight-procmon/SKILL.md +49 -0
- package/skill-bundle/insight-procmon/references/agent-execution.md +36 -0
- package/skill-bundle/insight-re/SKILL.md +121 -0
- package/skill-bundle/insight-re/references/agent-execution.md +36 -0
- package/skill-bundle/insight-re/references/artifacts.md +52 -0
- package/skill-bundle/insight-re/references/recovery.md +53 -0
- package/skill-bundle/insight-sevenzip/SKILL.md +42 -0
- package/skill-bundle/insight-sevenzip/references/agent-execution.md +36 -0
- package/skill-bundle/insight-strace/SKILL.md +46 -0
- package/skill-bundle/insight-strace/references/agent-execution.md +36 -0
- package/skill-bundle/insight-tshark/SKILL.md +49 -0
- package/skill-bundle/insight-tshark/references/agent-execution.md +36 -0
- package/skill-bundle/insight-windbg/SKILL.md +46 -0
- package/skill-bundle/insight-windbg/references/agent-execution.md +36 -0
- package/skill-bundle/manifest.json +32 -0
- package/skills/insight-artifacts/SKILL.md +30 -0
- package/skills/insight-artifacts/references/agent-execution.md +36 -0
- package/skills/insight-artifacts/references/artifacts.md +52 -0
- package/skills/insight-binary/SKILL.md +46 -0
- package/skills/insight-binary/references/agent-execution.md +36 -0
- package/skills/insight-capture/SKILL.md +56 -0
- package/skills/insight-capture/references/agent-execution.md +36 -0
- package/skills/insight-die/SKILL.md +49 -0
- package/skills/insight-die/references/agent-execution.md +36 -0
- package/skills/insight-dnspy/SKILL.md +65 -0
- package/skills/insight-dnspy/references/agent-execution.md +36 -0
- package/skills/insight-dotnet-dump/SKILL.md +46 -0
- package/skills/insight-dotnet-dump/references/agent-execution.md +36 -0
- package/skills/insight-dotnet-stack/SKILL.md +39 -0
- package/skills/insight-dotnet-stack/references/agent-execution.md +36 -0
- package/skills/insight-dotnet-trace/SKILL.md +45 -0
- package/skills/insight-dotnet-trace/references/agent-execution.md +36 -0
- package/skills/insight-frida/SKILL.md +67 -0
- package/skills/insight-frida/references/agent-execution.md +36 -0
- package/skills/insight-ghidra/SKILL.md +91 -0
- package/skills/insight-ghidra/references/administration.md +34 -0
- package/skills/insight-ghidra/references/agent-execution.md +36 -0
- package/skills/insight-ghidra/references/archive.md +32 -0
- package/skills/insight-ghidra/references/artifacts.md +52 -0
- package/skills/insight-ghidra/references/debugger.md +62 -0
- package/skills/insight-ghidra/references/extensions-and-sync.md +124 -0
- package/skills/insight-ghidra/references/managed-runtime.md +157 -0
- package/skills/insight-ghidra/references/native-workflows.md +112 -0
- package/skills/insight-ghidra/references/query-semantics.md +96 -0
- package/skills/insight-ghidra/references/recovery.md +53 -0
- package/skills/insight-ghidra/references/research.md +101 -0
- package/skills/insight-ghidra/references/setup.md +50 -0
- package/skills/insight-ilspy/SKILL.md +45 -0
- package/skills/insight-ilspy/references/agent-execution.md +36 -0
- package/skills/insight-ilspy/references/ilspy.md +33 -0
- package/skills/insight-interop/SKILL.md +54 -0
- package/skills/insight-interop/references/agent-execution.md +36 -0
- package/skills/insight-lldb/SKILL.md +54 -0
- package/skills/insight-lldb/references/agent-execution.md +36 -0
- package/skills/insight-llvm/SKILL.md +56 -0
- package/skills/insight-llvm/references/agent-execution.md +36 -0
- package/skills/insight-managed-heap/SKILL.md +43 -0
- package/skills/insight-managed-heap/references/agent-execution.md +36 -0
- package/skills/insight-managed-metadata/SKILL.md +52 -0
- package/skills/insight-managed-metadata/references/agent-execution.md +36 -0
- package/skills/insight-mitmproxy/SKILL.md +62 -0
- package/skills/insight-mitmproxy/references/agent-execution.md +36 -0
- package/skills/insight-overview/SKILL.md +79 -0
- package/skills/insight-overview/references/agent-execution.md +36 -0
- package/skills/insight-procmon/SKILL.md +49 -0
- package/skills/insight-procmon/references/agent-execution.md +36 -0
- package/skills/insight-re/SKILL.md +22 -9
- package/skills/insight-re/references/agent-execution.md +36 -0
- package/skills/insight-re/references/artifacts.md +52 -0
- package/skills/insight-re/references/recovery.md +53 -0
- package/skills/insight-sevenzip/SKILL.md +42 -0
- package/skills/insight-sevenzip/references/agent-execution.md +36 -0
- package/skills/insight-strace/SKILL.md +46 -0
- package/skills/insight-strace/references/agent-execution.md +36 -0
- package/skills/insight-tshark/SKILL.md +49 -0
- package/skills/insight-tshark/references/agent-execution.md +36 -0
- package/skills/insight-windbg/SKILL.md +46 -0
- package/skills/insight-windbg/references/agent-execution.md +36 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { mkdir, stat, rm, readdir, writeFile, readFile } from 'node:fs/promises';
|
|
2
|
+
import { join, resolve, sep, dirname } from 'node:path';
|
|
3
|
+
import { cacheArtifact, consumeArchive, extractArchive, fileSha256, archiveName } from './archives.js';
|
|
4
|
+
import { atomicWrite, readJson, toolRoot, withToolLock, installationStage, removeInstallation, treeFingerprint, assertUnused, withToolUse } from './store.js';
|
|
5
|
+
import { listProcesses } from './supervisor.js';
|
|
6
|
+
import { digest, fail, text } from '../model.js';
|
|
7
|
+
/** Read-only verification used by an owned child after the command owner has staged a runtime. */
|
|
8
|
+
export async function verifyManagedInstallation(directory, tool, selected) {
|
|
9
|
+
const root = join(toolRoot(directory, tool), 'installations', selected.id);
|
|
10
|
+
if (selected.schema !== 1 || selected.tool !== tool || selected.mode !== 'managed' || selected.uninstalledAt || !/^[a-f0-9]{64}$/.test(selected.id) || selected.root !== root || !resolve(selected.executable).startsWith(resolve(root) + sep))
|
|
11
|
+
fail('binding', 'Invalid managed tool installation receipt.');
|
|
12
|
+
const ready = await readJson(join(root, 'ready.json'));
|
|
13
|
+
const binding = (v) => { const { selectedAt, uninstalledAt, ...rest } = v; return rest; };
|
|
14
|
+
if (!ready || digest(binding(ready)) !== digest(binding(selected)))
|
|
15
|
+
fail('binding', 'Managed tool receipt differs from its verified installation.');
|
|
16
|
+
if (await treeFingerprint(root) !== selected.fingerprint)
|
|
17
|
+
fail('binding', 'Managed tool code differs from its verified installation.');
|
|
18
|
+
}
|
|
19
|
+
/** Standard archive-based tools supply layout and a real probe; exceptional tools reuse the stage primitives. */
|
|
20
|
+
export class ToolInstaller {
|
|
21
|
+
c;
|
|
22
|
+
descriptor;
|
|
23
|
+
directory;
|
|
24
|
+
root;
|
|
25
|
+
cache;
|
|
26
|
+
constructor(c, descriptor) {
|
|
27
|
+
this.c = c;
|
|
28
|
+
this.descriptor = descriptor;
|
|
29
|
+
this.directory = c.appArguments.AppDataDirectory;
|
|
30
|
+
this.root = toolRoot(this.directory, descriptor.id);
|
|
31
|
+
this.cache = join(this.directory, 'runtime/cache');
|
|
32
|
+
}
|
|
33
|
+
async receipt() { return readJson(join(this.root, 'selection.json')); }
|
|
34
|
+
async status() {
|
|
35
|
+
const selected = await this.receipt();
|
|
36
|
+
let present = false;
|
|
37
|
+
if (selected && !selected.uninstalledAt)
|
|
38
|
+
try {
|
|
39
|
+
present = (await stat(selected.executable)).isFile() && (selected.mode === 'external' || Boolean(await readJson(join(this.root, 'installations', selected.id, 'ready.json'))));
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
if (e.code !== 'ENOENT')
|
|
43
|
+
throw e;
|
|
44
|
+
}
|
|
45
|
+
const stages = await readdir(join(this.root, 'stages')).catch(e => { if (e.code === 'ENOENT')
|
|
46
|
+
return []; throw e; });
|
|
47
|
+
const processes = (await listProcesses(this.directory, { tool: this.descriptor.id })).filter(r => !['exited', 'failed'].includes(r.state));
|
|
48
|
+
return { retainedStages: stages.slice(0, 100), processes, tool: this.descriptor.id, state: present ? 'installed' : 'not_ready', mode: selected?.mode ?? 'unconfigured', installation: selected?.id, executable: selected?.executable, components: selected?.components ?? {}, lastProbe: selected?.lastProbe, recommended: 'managed' };
|
|
49
|
+
}
|
|
50
|
+
async download(offline = false, vendorDirect = false) {
|
|
51
|
+
const items = [];
|
|
52
|
+
for (const [component, a] of Object.entries(this.descriptor.components()))
|
|
53
|
+
items.push({ component, path: await cacheArtifact(a, this.cache, this.c.fetch, this.c.signal, offline, vendorDirect), sha256: a.sha256, license: a.license, url: a.url, delivery: a.delivery ?? { kind: 'owned-release' } });
|
|
54
|
+
return { tool: this.descriptor.id, state: 'downloaded', items };
|
|
55
|
+
}
|
|
56
|
+
async install(o) {
|
|
57
|
+
return withToolLock(this.directory, this.descriptor.id, async () => {
|
|
58
|
+
await assertUnused(this.directory, this.descriptor.id);
|
|
59
|
+
if (o.executable && o.archive)
|
|
60
|
+
fail('invalid', 'Choose --executable or --archive.');
|
|
61
|
+
const external = o.executable ? resolve(this.c.cwd, text(o.executable, 4096)) : undefined, parts = external ? {} : this.descriptor.components(), consumed = {};
|
|
62
|
+
for (const [id, artifact] of Object.entries(parts)) {
|
|
63
|
+
const key = id === this.descriptor.primary ? 'archive' : id + 'Archive', checksum = id === this.descriptor.primary ? 'archiveSha256' : id + 'ArchiveSha256';
|
|
64
|
+
if (o[checksum] && !o[key])
|
|
65
|
+
fail('invalid', 'Archive checksum requires its archive path.');
|
|
66
|
+
consumed[id] = o[key] ? await consumeArchive(resolve(this.c.cwd, text(o[key], 4096)), this.cache, artifact, o[checksum] === undefined ? undefined : text(o[checksum], 64), this.c.signal) : { path: await cacheArtifact(artifact, this.cache, this.c.fetch, this.c.signal, Boolean(o.offline), Boolean(o.vendorDirect)), artifact };
|
|
67
|
+
}
|
|
68
|
+
const components = Object.fromEntries(Object.entries(consumed).map(([id, v]) => [id, v.artifact.sha256]));
|
|
69
|
+
const externalDigest = external ? await fileSha256(external, this.c.signal) : undefined;
|
|
70
|
+
const externalInputs = external && this.descriptor.externalInputs ? await this.descriptor.externalInputs(external, this.c) : undefined;
|
|
71
|
+
const noticeDigest = this.descriptor.noticeFiles ? digest(this.descriptor.noticeFiles) : undefined;
|
|
72
|
+
const id = digest({ tool: this.descriptor.id, schema: 1, platform: process.platform, architecture: process.arch, external, externalDigest, components, ...(externalInputs ? { externalInputs } : {}), ...(noticeDigest ? { noticeDigest } : {}), ...(this.descriptor.preparationId ? { preparationId: this.descriptor.preparationId } : {}) });
|
|
73
|
+
const rootsAt = (directory) => Object.fromEntries(Object.entries(consumed).map(([part, v]) => { archiveName(v.artifact.root); return [part, join(directory, part, v.artifact.root)]; }));
|
|
74
|
+
const selected = await installationStage(this.root, id, async (stage, installed) => {
|
|
75
|
+
for (const [part, v] of Object.entries(consumed))
|
|
76
|
+
await extractArchive(v.path, join(stage, part), v.artifact.format, this.c.signal);
|
|
77
|
+
if (!external)
|
|
78
|
+
await this.descriptor.prepare?.(rootsAt(stage), this.c);
|
|
79
|
+
const execution = external ? await this.descriptor.prepareExternal?.(external, stage, this.c) : undefined;
|
|
80
|
+
if (execution && !resolve(execution.executable).startsWith(resolve(stage) + sep))
|
|
81
|
+
fail('binding', 'Prepared external execution must use owned staging.');
|
|
82
|
+
for (const [name, body] of Object.entries(this.descriptor.noticeFiles ?? {})) {
|
|
83
|
+
archiveName(name);
|
|
84
|
+
if (!name || Buffer.byteLength(body) > 1024 ** 2)
|
|
85
|
+
fail('configuration', 'Invalid bundled license notice.');
|
|
86
|
+
const destination = join(stage, name);
|
|
87
|
+
await mkdir(dirname(destination), { recursive: true, mode: 0o700 });
|
|
88
|
+
await writeFile(destination, body, { flag: 'wx', mode: 0o600 });
|
|
89
|
+
}
|
|
90
|
+
const stageLaunch = external ? { executable: external, arguments: [], environment: {} } : this.descriptor.launch(rootsAt(stage));
|
|
91
|
+
const lastProbe = await this.descriptor.probe(execution ?? stageLaunch, this.c), launch = external ? stageLaunch : this.descriptor.launch(rootsAt(installed));
|
|
92
|
+
const fingerprint = external ? await fileSha256(external, this.c.signal) : await treeFingerprint(stage);
|
|
93
|
+
if (external && fingerprint !== externalDigest)
|
|
94
|
+
fail('binding', 'External tool changed during installation.');
|
|
95
|
+
if (externalInputs && digest(await this.descriptor.externalInputs(external, this.c)) !== digest(externalInputs))
|
|
96
|
+
fail('binding', 'External tool family changed during installation.');
|
|
97
|
+
const installedExecution = execution ? { ...execution, executable: join(installed, execution.executable.slice(stage.length + 1)) } : undefined;
|
|
98
|
+
return { schema: 1, tool: this.descriptor.id, id, mode: external ? 'external' : 'managed', root: installed, ...launch, roots: rootsAt(installed), components, fingerprint, lastProbe, ...(externalInputs ? { externalInputs } : {}), ...(noticeDigest ? { noticeDigest } : {}), ...(installedExecution ? { execution: installedExecution, executionFingerprint: await treeFingerprint(stage) } : {}), selectedAt: new Date().toISOString() };
|
|
99
|
+
}, value => this.verify(value), this.c.signal);
|
|
100
|
+
await atomicWrite(join(this.root, 'selection.json'), { ...selected, selectedAt: new Date().toISOString() });
|
|
101
|
+
return { tool: this.descriptor.id, state: 'installed', mode: selected.mode, installation: id, executable: selected.executable, components, checks: selected.lastProbe };
|
|
102
|
+
}, this.c.signal);
|
|
103
|
+
}
|
|
104
|
+
async verify(selected) {
|
|
105
|
+
if (selected.schema !== 1 || selected.tool !== this.descriptor.id || !/^[a-f0-9]{64}$/.test(selected.id))
|
|
106
|
+
fail('binding', 'Invalid tool installation receipt.');
|
|
107
|
+
const root = join(this.root, 'installations', selected.id);
|
|
108
|
+
if (selected.root !== root || selected.mode === 'managed' && !resolve(selected.executable).startsWith(resolve(root) + sep))
|
|
109
|
+
fail('binding', 'Selected tool points outside its owned installation.');
|
|
110
|
+
const ready = await readJson(join(root, 'ready.json'));
|
|
111
|
+
const binding = (v) => { const { selectedAt, uninstalledAt, ...rest } = v; return rest; };
|
|
112
|
+
if (!ready || digest(binding(ready)) !== digest(binding(selected)))
|
|
113
|
+
fail('binding', 'Selected tool receipt differs from its verified installation.');
|
|
114
|
+
if (this.descriptor.noticeFiles) {
|
|
115
|
+
if (selected.noticeDigest !== digest(this.descriptor.noticeFiles))
|
|
116
|
+
fail('binding', 'Bundled license notices changed; reinstall the selected tool.');
|
|
117
|
+
for (const [name, body] of Object.entries(this.descriptor.noticeFiles)) {
|
|
118
|
+
archiveName(name);
|
|
119
|
+
try {
|
|
120
|
+
if (await readFile(join(root, name), 'utf8') !== body)
|
|
121
|
+
fail('binding', 'Installed license notice differs from its retained text.');
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
if (error.code === 'ENOENT')
|
|
125
|
+
fail('binding', 'Installed license notice is missing.');
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (selected.mode === 'managed')
|
|
131
|
+
await verifyManagedInstallation(this.directory, this.descriptor.id, selected);
|
|
132
|
+
else if (await fileSha256(selected.executable, this.c.signal) !== selected.fingerprint)
|
|
133
|
+
fail('binding', 'Selected tool code differs from its verified installation.');
|
|
134
|
+
if (selected.execution && (!resolve(selected.execution.executable).startsWith(resolve(root) + sep) || await treeFingerprint(root) !== selected.executionFingerprint))
|
|
135
|
+
fail('binding', 'Owned external-tool execution copy differs from its verified installation.');
|
|
136
|
+
if (selected.mode === 'external' && this.descriptor.externalInputs && (!selected.externalInputs || digest(await this.descriptor.externalInputs(selected.executable, this.c)) !== digest(selected.externalInputs)))
|
|
137
|
+
fail('binding', 'External tool family differs from its verified installation.');
|
|
138
|
+
}
|
|
139
|
+
async use(action) {
|
|
140
|
+
const lease = await withToolUse(this.directory, this.descriptor.id, () => this.selected(), this.c.signal);
|
|
141
|
+
try {
|
|
142
|
+
return await action({ ...lease.value, ...lease.value.execution });
|
|
143
|
+
}
|
|
144
|
+
finally {
|
|
145
|
+
lease.release();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
async selected() {
|
|
149
|
+
const selected = await this.receipt();
|
|
150
|
+
if (!selected || selected.uninstalledAt)
|
|
151
|
+
fail('configuration', 'Tool is not installed; run insight-cli ' + this.descriptor.id + ' install.');
|
|
152
|
+
await this.verify(selected);
|
|
153
|
+
return selected;
|
|
154
|
+
}
|
|
155
|
+
async doctor() {
|
|
156
|
+
return withToolLock(this.directory, this.descriptor.id, async () => {
|
|
157
|
+
const selected = await this.selected(), checks = await this.descriptor.probe(selected.execution ?? selected, this.c);
|
|
158
|
+
await atomicWrite(join(this.root, 'last-check.json'), { fingerprint: selected.fingerprint, checkedAt: new Date().toISOString(), checks });
|
|
159
|
+
return { tool: this.descriptor.id, state: 'verified', installation: selected.id, checks };
|
|
160
|
+
}, this.c.signal);
|
|
161
|
+
}
|
|
162
|
+
async uninstall(purgeCache = false) {
|
|
163
|
+
return withToolLock(this.directory, this.descriptor.id, async () => {
|
|
164
|
+
await assertUnused(this.directory, this.descriptor.id);
|
|
165
|
+
const selected = await this.receipt();
|
|
166
|
+
if (!selected)
|
|
167
|
+
fail('configuration', 'No selected tool installation exists.');
|
|
168
|
+
await removeInstallation(this.root, selected.id);
|
|
169
|
+
if (purgeCache)
|
|
170
|
+
for (const sha of Object.values(selected.components)) {
|
|
171
|
+
if (!/^[a-f0-9]{64}$/.test(sha))
|
|
172
|
+
fail('binding', 'Invalid component digest.');
|
|
173
|
+
for (const extension of ['zip', 'tgz'])
|
|
174
|
+
await rm(join(this.cache, sha + '.' + extension), { force: true });
|
|
175
|
+
}
|
|
176
|
+
await atomicWrite(join(this.root, 'selection.json'), { ...selected, uninstalledAt: new Date().toISOString() });
|
|
177
|
+
return { tool: this.descriptor.id, state: 'uninstalled', externalInstallationPreserved: selected.mode === 'external', researchPreserved: true, materialsPreserved: true };
|
|
178
|
+
}, this.c.signal);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** Internal POSIX exec gate, not a daemon. The record exists before the requested executable runs. */
|
|
2
|
+
import { createReadStream } from 'node:fs';
|
|
3
|
+
import { realpath } from 'node:fs/promises';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
6
|
+
import { atomicWrite, readJson } from './store.js';
|
|
7
|
+
import { processIdentity } from './identity.js';
|
|
8
|
+
async function main() {
|
|
9
|
+
const [directory, id, fd] = process.argv.slice(2);
|
|
10
|
+
if (!directory || !id || !/^[a-f0-9-]{36}$/.test(id))
|
|
11
|
+
throw Error('Invalid launch identity');
|
|
12
|
+
const root = await realpath(directory), path = join(root, 'runtime/processes', id + '.json');
|
|
13
|
+
const record = await readJson(path);
|
|
14
|
+
if (!record || record.id !== id || record.pid || record.ownerPid !== process.ppid)
|
|
15
|
+
throw Error('Launch owner changed');
|
|
16
|
+
let input = '';
|
|
17
|
+
for await (const b of createReadStream('', { fd: Number(fd), autoClose: true })) {
|
|
18
|
+
input += b.toString();
|
|
19
|
+
if (input.length > 4 * 1024 ** 2)
|
|
20
|
+
throw Error('Launch input exceeds its bound');
|
|
21
|
+
}
|
|
22
|
+
if (await realpath(String(record.root)) !== join(root, 'runtime/runs', id))
|
|
23
|
+
throw Error('Launch storage changed');
|
|
24
|
+
const plan = JSON.parse(input);
|
|
25
|
+
if (plan.executable !== record.executable)
|
|
26
|
+
throw Error('Launch executable changed');
|
|
27
|
+
const identity = await processIdentity(process.pid);
|
|
28
|
+
if (!identity)
|
|
29
|
+
throw Error('Launch process identity unavailable');
|
|
30
|
+
Object.assign(record, { pid: process.pid, identity: identity.birth, strongIdentity: identity.strong, processGroup: identity.group, phase: 'armed' });
|
|
31
|
+
await atomicWrite(path, record);
|
|
32
|
+
await atomicWrite(join(String(record.root), 'armed.json'), { pid: process.pid, nonce: plan.nonce });
|
|
33
|
+
for (let i = 0; i < 400; i++) {
|
|
34
|
+
const grant = await readJson(join(String(record.root), 'go.json'));
|
|
35
|
+
if (grant?.nonce === plan.nonce) {
|
|
36
|
+
try {
|
|
37
|
+
process.execve(plan.executable, [plan.executable, ...plan.arguments], plan.environment);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
Object.assign(record, { state: 'failed', phase: 'exec_failed', launchError: error.code ?? 'exec', endedAt: new Date().toISOString() });
|
|
41
|
+
await atomicWrite(path, record);
|
|
42
|
+
throw Error('Owned executable could not start');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
process.kill(Number(record.ownerPid), 0);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
Object.assign(record, { state: 'failed', phase: 'owner_lost_before_exec' });
|
|
50
|
+
await atomicWrite(path, record);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
await delay(25);
|
|
54
|
+
}
|
|
55
|
+
Object.assign(record, { state: 'failed', phase: 'launch_grant_timeout' });
|
|
56
|
+
await atomicWrite(path, record);
|
|
57
|
+
}
|
|
58
|
+
await main().catch(() => { process.stderr.write('Owned tool launch gate failed.\n'); process.exitCode = 1; });
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type CommandContext } from '@eyeauras/cli-factory';
|
|
2
|
+
export interface RunSpec {
|
|
3
|
+
tool: string;
|
|
4
|
+
role: string;
|
|
5
|
+
installation?: string;
|
|
6
|
+
executable: string;
|
|
7
|
+
arguments?: string[];
|
|
8
|
+
environment?: Record<string, string | undefined>;
|
|
9
|
+
cwd?: string;
|
|
10
|
+
input?: string | Uint8Array;
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
maxOutputBytes?: number;
|
|
13
|
+
outputFile?: string;
|
|
14
|
+
acceptedCodes?: number[];
|
|
15
|
+
session?: string;
|
|
16
|
+
target?: string;
|
|
17
|
+
/** Adapter opt-in only after verifying its native signal/child cleanup contract. */
|
|
18
|
+
nativeDeadline?: boolean;
|
|
19
|
+
/** Adapter opt-in for exact bounded stdout/stderr bytes, including failure prefixes. */
|
|
20
|
+
retainRawOutput?: boolean;
|
|
21
|
+
/** Adapter's native helper constructor persists per-exec deadline receipts in the run root. */
|
|
22
|
+
nativeChildDeadlines?: boolean;
|
|
23
|
+
/** Hold an authenticated borrowed Windows subject handle; never assign it to the owned job. */
|
|
24
|
+
observedSubject?: {
|
|
25
|
+
pid: number;
|
|
26
|
+
birth: string;
|
|
27
|
+
};
|
|
28
|
+
/** Serialize the native singleton without introducing another service. */
|
|
29
|
+
nativeMutex?: 'procmon';
|
|
30
|
+
/** Private process-local HKCU for the admitted ProcMon child. */
|
|
31
|
+
nativeRegistry?: 'procmon';
|
|
32
|
+
metadata?: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
export interface RunResult {
|
|
35
|
+
process: string;
|
|
36
|
+
stdout: string;
|
|
37
|
+
stderr: string;
|
|
38
|
+
exitCode: number | null;
|
|
39
|
+
signal: string | null;
|
|
40
|
+
elapsedMs: number;
|
|
41
|
+
truncated: boolean;
|
|
42
|
+
diagnostics: string;
|
|
43
|
+
rawStdout?: string;
|
|
44
|
+
rawStderr?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface RunContext {
|
|
47
|
+
appArguments: Pick<CommandContext['appArguments'], 'AppDataDirectory'>;
|
|
48
|
+
signal: AbortSignal;
|
|
49
|
+
environment: CommandContext['environment'];
|
|
50
|
+
}
|
|
51
|
+
export declare function runTool(c: RunContext, spec: RunSpec): Promise<RunResult>;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { join, isAbsolute, resolve } from 'node:path';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import { performance } from 'node:perf_hooks';
|
|
5
|
+
import { CliError } from '@eyeauras/cli-factory';
|
|
6
|
+
import { atomicWrite, withToolUse, toolRoot, readJson } from './store.js';
|
|
7
|
+
import { launchProcess } from './supervisor.js';
|
|
8
|
+
import { digest } from '../model.js';
|
|
9
|
+
import { deadlineLaunch } from './deadline.js';
|
|
10
|
+
import { windowsJobLaunch, windowsJobResult } from './windows-job.js';
|
|
11
|
+
export async function runTool(c, spec) {
|
|
12
|
+
c.signal.throwIfAborted();
|
|
13
|
+
const directory = c.appArguments.AppDataDirectory;
|
|
14
|
+
toolRoot(directory, spec.tool);
|
|
15
|
+
if (!isAbsolute(spec.executable))
|
|
16
|
+
throw new CliError('Tool executable must be an absolute path.', { code: 'tool.configuration' });
|
|
17
|
+
if ((spec.observedSubject || spec.nativeMutex || spec.nativeRegistry) && (!spec.nativeDeadline || process.platform !== 'win32'))
|
|
18
|
+
throw new CliError('Native subject/mutex/registry binding requires an owned Windows job.', { code: 'tool.configuration' });
|
|
19
|
+
if (spec.nativeChildDeadlines && !spec.nativeDeadline)
|
|
20
|
+
throw new CliError('Native child deadlines require the native collector deadline.', { code: 'tool.configuration' });
|
|
21
|
+
let launch = { executable: spec.executable, arguments: spec.arguments ?? [] };
|
|
22
|
+
const id = randomUUID(), root = join(directory, 'runtime/runs', id), path = join(directory, 'runtime/processes', id + '.json');
|
|
23
|
+
const started = performance.now(), limit = spec.maxOutputBytes ?? 4 * 1024 ** 2;
|
|
24
|
+
let child, outcome, truncated = false, bytes = 0;
|
|
25
|
+
const stdout = [], stderr = [], record = { schema: 1, id, tool: spec.tool, role: spec.role, installation: spec.installation ?? 'probe', state: 'starting', executable: spec.executable, createdAt: new Date().toISOString(), root, ownerPid: process.pid, profileBinding: digest(resolve(directory)), gated: process.platform !== 'win32' && typeof process.execve === 'function', phase: 'reserved', ...(spec.session ? { session: spec.session } : {}), ...(spec.target ? { target: spec.target } : {}) };
|
|
26
|
+
const lease = await withToolUse(directory, spec.tool, async () => { await mkdir(root, { recursive: true, mode: 0o700 }); }, c.signal);
|
|
27
|
+
const environment = { PATH: c.environment.PATH ?? process.env.PATH, HOME: root, TMPDIR: root, ...(process.platform === 'win32' ? { SystemRoot: process.env.SystemRoot, WINDIR: process.env.WINDIR, ComSpec: process.env.ComSpec, TEMP: root, TMP: root, USERPROFILE: root, LOCALAPPDATA: root, APPDATA: root } : {}), ...spec.environment };
|
|
28
|
+
const secrets = Object.entries(environment).filter(([key, value]) => /TOKEN|PASSWORD|SECRET|KEY/i.test(key) && value && value.length >= 4).map(([, v]) => v);
|
|
29
|
+
const redact = (value) => secrets.reduce((text, secret) => text.split(secret).join('[redacted]'), value);
|
|
30
|
+
let timer, force, drain, hard, settled = false, abandon;
|
|
31
|
+
const signal = (name) => {
|
|
32
|
+
if (!child?.pid || settled)
|
|
33
|
+
return;
|
|
34
|
+
try {
|
|
35
|
+
if (process.platform !== 'win32')
|
|
36
|
+
process.kill(-child.pid, name);
|
|
37
|
+
else if (child.exitCode === null && child.signalCode === null)
|
|
38
|
+
child.kill(name);
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
if (e.code === 'ESRCH')
|
|
42
|
+
return;
|
|
43
|
+
record.terminationError = e.code ?? 'signal_failed';
|
|
44
|
+
if (child.exitCode === null && child.signalCode === null)
|
|
45
|
+
try {
|
|
46
|
+
child.kill(name);
|
|
47
|
+
}
|
|
48
|
+
catch { }
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const stop = (reason) => { if (settled)
|
|
52
|
+
return; outcome ??= reason; signal('SIGTERM'); force ??= setTimeout(() => { signal('SIGKILL'); hard = setTimeout(() => { if (settled)
|
|
53
|
+
return; outcome = 'termination_unverified'; record.state = 'unverified'; child?.stdin?.destroy(); child?.stdout?.destroy(); child?.stderr?.destroy(); child?.unref(); abandon?.(new Error('termination_unverified')); }, 1000); hard.unref(); }, 1000); force.unref(); };
|
|
54
|
+
const aborted = () => stop('cancelled');
|
|
55
|
+
try {
|
|
56
|
+
c.signal.throwIfAborted();
|
|
57
|
+
if (spec.nativeDeadline)
|
|
58
|
+
launch = process.platform === 'win32' ? await windowsJobLaunch(root, id, spec.executable, spec.arguments ?? [], spec.cwd ?? root, spec.timeoutMs ?? 120000, { observedSubject: spec.observedSubject, nativeMutex: spec.nativeMutex, nativeRegistry: spec.nativeRegistry }) : await deadlineLaunch(spec.executable, spec.arguments ?? [], spec.timeoutMs ?? 120000);
|
|
59
|
+
child = await launchProcess(directory, { tool: spec.tool, role: spec.role, installation: spec.installation ?? 'probe', session: spec.session, target: spec.target, ...(spec.metadata || spec.nativeDeadline ? { metadata: { ...spec.metadata, ...(spec.observedSubject ? { observedSubject: spec.observedSubject } : {}), ...(spec.nativeMutex ? { nativeMutex: spec.nativeMutex } : {}), ...(spec.nativeRegistry ? { nativeRegistry: spec.nativeRegistry } : {}), ...(spec.nativeDeadline ? { nativeDeadlineSeconds: Math.ceil((spec.timeoutMs ?? 120000) / 1000), nativeExecutable: spec.executable, ...(spec.nativeChildDeadlines ? { nativeChildDeadlines: true } : {}) } : {}) } } : {}) }, launch.executable, launch.arguments, { cwd: spec.cwd ?? root, env: environment, windowsHide: true, detached: process.platform !== 'win32', stdio: ['pipe', 'pipe', 'pipe'] }, { id, finalize: false, signal: c.signal, onSpawn: launched => {
|
|
60
|
+
child = launched;
|
|
61
|
+
child.once('close', () => { settled = true; });
|
|
62
|
+
child.once('exit', () => { drain = setTimeout(() => stop('background_output'), 300); drain.unref(); });
|
|
63
|
+
const capture = (chunks, b) => { const available = Math.max(0, limit - bytes); if (available)
|
|
64
|
+
chunks.push(Buffer.from(b.subarray(0, available))); bytes += b.length; if (bytes > limit) {
|
|
65
|
+
truncated = true;
|
|
66
|
+
stop('output_limit');
|
|
67
|
+
} };
|
|
68
|
+
child.stdout.on('data', b => capture(stdout, b));
|
|
69
|
+
child.stderr.on('data', b => capture(stderr, b));
|
|
70
|
+
child.stdin.on('error', () => { });
|
|
71
|
+
child.stdin.end(spec.input);
|
|
72
|
+
c.signal.addEventListener('abort', aborted, { once: true });
|
|
73
|
+
if (c.signal.aborted)
|
|
74
|
+
aborted();
|
|
75
|
+
timer = setTimeout(() => stop('timeout'), spec.timeoutMs ?? 120000);
|
|
76
|
+
timer.unref();
|
|
77
|
+
} });
|
|
78
|
+
await Promise.race([child.toolClosed, new Promise((_ok, bad) => { abandon = bad; })]);
|
|
79
|
+
settled = true;
|
|
80
|
+
Object.assign(record, await readJson(path));
|
|
81
|
+
if (record.launchError)
|
|
82
|
+
outcome = 'launch_failed';
|
|
83
|
+
let exitCode = child.exitCode;
|
|
84
|
+
if (spec.nativeDeadline && process.platform === 'win32' && !outcome) {
|
|
85
|
+
try {
|
|
86
|
+
const job = await windowsJobResult(root, id, child.pid, Boolean(spec.nativeRegistry));
|
|
87
|
+
exitCode = job.childExitCode;
|
|
88
|
+
Object.assign(record, { windowsJob: job });
|
|
89
|
+
if (job.phase !== 'completed')
|
|
90
|
+
outcome = job.phase;
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
outcome = 'job_result_unverified';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (!outcome && spec.nativeDeadline && child.signalCode === 'SIGALRM')
|
|
97
|
+
outcome = 'timeout';
|
|
98
|
+
if (!outcome && (exitCode === null || !(spec.acceptedCodes ?? [0]).includes(exitCode)))
|
|
99
|
+
outcome = 'exit_code';
|
|
100
|
+
const result = { process: id, stdout: redact(Buffer.concat(stdout).toString('utf8')), stderr: redact(Buffer.concat(stderr).toString('utf8')), exitCode, signal: child.signalCode, elapsedMs: Math.round(performance.now() - started), truncated, diagnostics: root };
|
|
101
|
+
if (spec.retainRawOutput) {
|
|
102
|
+
result.rawStdout = join(root, 'stdout.bin');
|
|
103
|
+
result.rawStderr = join(root, 'stderr.bin');
|
|
104
|
+
await writeFile(result.rawStdout, Buffer.concat(stdout), { mode: 0o600 });
|
|
105
|
+
await writeFile(result.rawStderr, Buffer.concat(stderr), { mode: 0o600 });
|
|
106
|
+
}
|
|
107
|
+
await writeFile(join(root, 'stdout.log'), result.stdout, { mode: 0o600 });
|
|
108
|
+
await writeFile(join(root, 'stderr.log'), result.stderr, { mode: 0o600 });
|
|
109
|
+
Object.assign(record, { state: outcome ? 'failed' : 'exited', outcome: outcome ?? 'completed', exitCode: result.exitCode, signal: result.signal, elapsedMs: result.elapsedMs, endedAt: new Date().toISOString() });
|
|
110
|
+
await atomicWrite(path, record);
|
|
111
|
+
if (outcome)
|
|
112
|
+
throw new CliError('Tool execution did not complete successfully: ' + outcome + '.', { code: 'tool.' + outcome.replaceAll('_', '.'), result });
|
|
113
|
+
if (spec.outputFile)
|
|
114
|
+
try {
|
|
115
|
+
await writeFile(spec.outputFile, Buffer.concat(stdout), { flag: 'wx', mode: 0o600 });
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
throw new CliError('Tool completed, but its binary output could not be written to a new file.', { code: 'tool.output', cause: error, result: { process: id, diagnostics: root } });
|
|
119
|
+
}
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
const failure = error;
|
|
124
|
+
await atomicWrite(join(root, 'error.json'), { name: failure.name, code: failure.code, message: redact(failure.message ?? String(error)), ...(failure.cause ? { cause: { name: failure.cause.name, message: redact(failure.cause.message) } } : {}) });
|
|
125
|
+
if (child && !settled && record.state !== 'unverified') {
|
|
126
|
+
stop('failed');
|
|
127
|
+
await new Promise(ok => { if (settled) {
|
|
128
|
+
ok();
|
|
129
|
+
return;
|
|
130
|
+
} child.once('close', () => ok()); setTimeout(() => { signal('SIGKILL'); ok(); }, 1500).unref(); });
|
|
131
|
+
}
|
|
132
|
+
Object.assign(record, await readJson(path));
|
|
133
|
+
if (c.signal.aborted && !outcome)
|
|
134
|
+
outcome = 'cancelled';
|
|
135
|
+
if (record.state === 'starting' || record.state === 'running' || record.state === 'failed') {
|
|
136
|
+
Object.assign(record, { state: 'failed', outcome: outcome ?? 'launch_failed', endedAt: new Date().toISOString(), elapsedMs: Math.round(performance.now() - started) });
|
|
137
|
+
await atomicWrite(path, record);
|
|
138
|
+
}
|
|
139
|
+
if (record.state === 'unverified')
|
|
140
|
+
await atomicWrite(path, record);
|
|
141
|
+
if (error instanceof CliError)
|
|
142
|
+
throw error;
|
|
143
|
+
if (record.state === 'unverified')
|
|
144
|
+
throw new CliError('Tool termination could not be verified; its process record blocks removal.', { code: 'tool.termination.unverified', result: { process: id, diagnostics: root } });
|
|
145
|
+
throw new CliError('Tool execution failed; inspect its retained process record.', { code: outcome ? 'tool.' + outcome.replaceAll('_', '.') : 'tool.launch', cause: error, result: { process: id, diagnostics: root } });
|
|
146
|
+
}
|
|
147
|
+
finally {
|
|
148
|
+
if (timer)
|
|
149
|
+
clearTimeout(timer);
|
|
150
|
+
if (force)
|
|
151
|
+
clearTimeout(force);
|
|
152
|
+
if (drain)
|
|
153
|
+
clearTimeout(drain);
|
|
154
|
+
if (hard)
|
|
155
|
+
clearTimeout(hard);
|
|
156
|
+
c.signal.removeEventListener('abort', aborted);
|
|
157
|
+
lease.release();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare function atomicWrite(path: string, value: unknown): Promise<void>;
|
|
2
|
+
export declare function readJson<T>(path: string): Promise<T | undefined>;
|
|
3
|
+
export declare function toolRoot(directory: string, tool: string): string;
|
|
4
|
+
/** CLI clients already share Factory's elected owner. Do not create another IPC/lease protocol. */
|
|
5
|
+
export declare function withToolLock<T>(directory: string, tool: string, action: () => Promise<T>, signal?: AbortSignal): Promise<T>;
|
|
6
|
+
export declare function toolProfileBusy(directory: string): boolean;
|
|
7
|
+
export declare function toolUseCount(directory: string, tool: string): number;
|
|
8
|
+
export declare function withToolUse<T>(directory: string, tool: string, acquire: () => Promise<T>, signal?: AbortSignal): Promise<{
|
|
9
|
+
value: T;
|
|
10
|
+
release: () => void;
|
|
11
|
+
}>;
|
|
12
|
+
export declare function assertUnused(directory: string, tool: string): Promise<void>;
|
|
13
|
+
export declare function installationStage<T>(root: string, id: string, prepare: (stage: string, installed: string) => Promise<T>, verify: (receipt: T) => Promise<void>, signal?: AbortSignal): Promise<T>;
|
|
14
|
+
export declare function removeInstallation(root: string, id: string): Promise<void>;
|
|
15
|
+
export declare function treeFingerprint(root: string): Promise<string>;
|