@eyeauras/insight-cli 0.8.4 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cli-package-build.json +1 -1
- package/README.md +16 -23
- package/SKILL.md +6 -44
- package/dist/src/activity-audit.d.ts +33 -46
- package/dist/src/activity-audit.js +120 -195
- package/dist/src/analysis-default.d.ts +10 -2
- package/dist/src/analysis-default.js +62 -47
- package/dist/src/analysis-storage.d.ts +13 -13
- package/dist/src/analysis-storage.js +127 -258
- package/dist/src/artifacts.d.ts +5 -1
- package/dist/src/artifacts.js +31 -46
- package/dist/src/audit-commands.d.ts +6 -1
- package/dist/src/audit-commands.js +9 -2
- package/dist/src/audit-retention.d.ts +5 -23
- package/dist/src/audit-retention.js +37 -150
- package/dist/src/binary.js +4 -13
- package/dist/src/budgets.d.ts +2 -2
- package/dist/src/budgets.js +7 -9
- package/dist/src/capture.js +17 -30
- package/dist/src/cli.d.ts +9 -4
- package/dist/src/cli.js +288 -473
- package/dist/src/code-references.d.ts +2 -13
- package/dist/src/code-references.js +7 -99
- package/dist/src/context-diagnostics.d.ts +1 -23
- package/dist/src/context-diagnostics.js +1 -83
- package/dist/src/core/coordinator.d.ts +298 -0
- package/dist/src/core/coordinator.js +591 -0
- package/dist/src/core/layout.d.ts +51 -0
- package/dist/src/core/layout.js +55 -0
- package/dist/src/core/legacy-import.d.ts +55 -0
- package/dist/src/core/legacy-import.js +193 -0
- package/dist/src/cross-results.d.ts +3 -3
- package/dist/src/cross-results.js +4 -42
- package/dist/src/cross.js +2 -3
- package/dist/src/debugger-results.d.ts +1 -6
- package/dist/src/debugger-results.js +21 -153
- package/dist/src/debugger.d.ts +21 -11
- package/dist/src/debugger.js +106 -168
- package/dist/src/decode-results.d.ts +2 -1
- package/dist/src/decode-results.js +4 -20
- package/dist/src/diagnostic-error.d.ts +1 -1
- package/dist/src/diagnostic-error.js +4 -23
- package/dist/src/die.js +1 -23
- package/dist/src/dnspy-runtime.js +5 -12
- package/dist/src/dnspy.js +13 -28
- package/dist/src/dotnet-diagnostics.js +1 -1
- package/dist/src/extensions.d.ts +2 -3
- package/dist/src/extensions.js +14 -91
- package/dist/src/frida-worker.js +0 -20
- package/dist/src/frida.js +3 -26
- package/dist/src/function-boundaries.d.ts +2 -2
- package/dist/src/function-boundaries.js +9 -61
- package/dist/src/function-entries.d.ts +2 -2
- package/dist/src/function-entries.js +6 -36
- package/dist/src/function-inspection.d.ts +2 -2
- package/dist/src/function-inspection.js +17 -33
- package/dist/src/function-results.d.ts +1 -3
- package/dist/src/function-results.js +2 -13
- package/dist/src/hub/admin.d.ts +101 -0
- package/dist/src/hub/admin.js +314 -0
- package/dist/src/hub/autostart.d.ts +111 -0
- package/dist/src/hub/autostart.js +207 -0
- package/dist/src/hub/bundle.d.ts +33 -0
- package/dist/src/hub/bundle.js +25 -0
- package/dist/src/hub/client.d.ts +90 -0
- package/dist/src/hub/client.js +256 -0
- package/dist/src/hub/commands.d.ts +13 -0
- package/dist/src/hub/commands.js +280 -0
- package/dist/src/hub/contract.d.ts +87 -0
- package/dist/src/hub/contract.js +3 -0
- package/dist/src/hub/extensions.d.ts +41 -0
- package/dist/src/hub/extensions.js +3 -0
- package/dist/src/hub/ghidra.d.ts +70 -0
- package/dist/src/hub/ghidra.js +197 -0
- package/dist/src/hub/index.d.ts +6 -0
- package/dist/src/hub/index.js +7 -0
- package/dist/src/{work/store.d.ts → hub/ledger-store.d.ts} +57 -94
- package/dist/src/hub/ledger-store.js +919 -0
- package/dist/src/hub/ledger.d.ts +4 -0
- package/dist/src/hub/ledger.js +173 -0
- package/dist/src/hub/lock.d.ts +7 -0
- package/dist/src/hub/lock.js +53 -0
- package/dist/src/hub/repository.d.ts +45 -0
- package/dist/src/hub/repository.js +130 -0
- package/dist/src/hub/server.d.ts +86 -0
- package/dist/src/hub/server.js +414 -0
- package/dist/src/hub/settings.d.ts +36 -0
- package/dist/src/hub/settings.js +112 -0
- package/dist/src/hub/storage.d.ts +13 -0
- package/dist/src/hub/storage.js +46 -0
- package/dist/src/hub/store.d.ts +75 -0
- package/dist/src/hub/store.js +188 -0
- package/dist/src/ilspy.js +1 -1
- package/dist/src/internal-timing.d.ts +2 -9
- package/dist/src/internal-timing.js +2 -95
- package/dist/src/lldb.js +3 -15
- package/dist/src/llvm.js +0 -9
- package/dist/src/managed-heap.js +3 -7
- package/dist/src/managed-metadata.js +2 -5
- package/dist/src/memory-inputs.d.ts +1 -4
- package/dist/src/memory-inputs.js +10 -40
- package/dist/src/mitmproxy.d.ts +35 -4
- package/dist/src/mitmproxy.js +59 -40
- package/dist/src/model.d.ts +0 -73
- package/dist/src/model.js +0 -45
- package/dist/src/mutations.d.ts +1 -1
- package/dist/src/mutations.js +5 -10
- package/dist/src/native/contract.d.ts +130 -0
- package/dist/src/native/ghidra.d.ts +58 -0
- package/dist/src/native/ghidra.js +77 -0
- package/dist/src/native/host.d.ts +71 -0
- package/dist/src/native/host.js +265 -0
- package/dist/src/native/index.d.ts +13 -0
- package/dist/src/native/index.js +19 -0
- package/dist/src/native/jvm.d.ts +54 -0
- package/dist/src/native/jvm.js +47 -0
- package/dist/src/native/worker.d.ts +70 -0
- package/dist/src/native/worker.js +240 -0
- package/dist/src/native-inputs.d.ts +9 -14
- package/dist/src/native-inputs.js +22 -110
- package/dist/src/native-merge-patches.d.ts +2 -2
- package/dist/src/native-merge-patches.js +14 -14
- package/dist/src/persistent-client.js +53 -25
- package/dist/src/procmon.js +17 -31
- package/dist/src/program-files.d.ts +42 -0
- package/dist/src/program-files.js +148 -0
- package/dist/src/queries.js +2 -15
- package/dist/src/query-policy.d.ts +0 -2
- package/dist/src/query-policy.js +1 -14
- package/dist/src/research.d.ts +59 -238
- package/dist/src/research.js +212 -906
- package/dist/src/runtime-identity.d.ts +8 -0
- package/dist/src/runtime-identity.js +26 -0
- package/dist/src/runtime-manager.d.ts +1 -11
- package/dist/src/runtime-manager.js +10 -145
- package/dist/src/runtime-selection.d.ts +1 -1
- package/dist/src/runtime-selection.js +5 -37
- package/dist/src/saved-materials.js +8 -51
- package/dist/src/scripts.d.ts +1 -1
- package/dist/src/scripts.js +15 -15
- package/dist/src/sdk-contracts.js +2 -2
- package/dist/src/sdk.js +8 -8
- package/dist/src/sevenzip.js +1 -3
- package/dist/src/strace.js +0 -3
- package/dist/src/string-anchors.d.ts +2 -3
- package/dist/src/string-anchors.js +8 -101
- package/dist/src/text-window.d.ts +5 -4
- package/dist/src/text-window.js +4 -4
- package/dist/src/tool-runtime/archives.d.ts +1 -1
- package/dist/src/tool-runtime/archives.js +11 -20
- package/dist/src/tool-runtime/catalog.js +2 -5
- package/dist/src/tool-runtime/commands.js +1 -3
- package/dist/src/tool-runtime/deadline.js +2 -7
- package/dist/src/tool-runtime/definition.js +1 -31
- package/dist/src/tool-runtime/identity.js +6 -87
- package/dist/src/tool-runtime/installer.d.ts +2 -6
- package/dist/src/tool-runtime/installer.js +14 -76
- package/dist/src/tool-runtime/java-arguments.js +4 -10
- package/dist/src/tool-runtime/launch-worker.js +2 -8
- package/dist/src/tool-runtime/run.d.ts +2 -0
- package/dist/src/tool-runtime/run.js +20 -8
- package/dist/src/tool-runtime/store.d.ts +3 -3
- package/dist/src/tool-runtime/store.js +21 -83
- package/dist/src/tool-runtime/supervisor.d.ts +6 -11
- package/dist/src/tool-runtime/supervisor.js +155 -214
- package/dist/src/tool-runtime/windows-helper.d.ts +5 -0
- package/dist/src/tool-runtime/windows-helper.js +13 -0
- package/dist/src/tool-runtime/windows-job.d.ts +5 -5
- package/dist/src/tool-runtime/windows-job.js +13 -31
- package/dist/src/tshark.js +14 -27
- package/dist/src/ui-results.d.ts +3 -2
- package/dist/src/ui-results.js +16 -53
- package/dist/src/ui.d.ts +12 -13
- package/dist/src/ui.js +32 -70
- package/dist/src/version-tracking.d.ts +25 -39
- package/dist/src/version-tracking.js +70 -174
- package/dist/src/windbg.d.ts +1 -1
- package/dist/src/windbg.js +2 -8
- package/dist/src/work/client.d.ts +63 -0
- package/dist/src/work/client.js +163 -0
- package/dist/src/work/commands.d.ts +3 -1
- package/dist/src/work/commands.js +158 -184
- package/dist/src/work/dashboard.d.ts +2 -2
- package/dist/src/work/dashboard.js +7 -8
- package/dist/src/work/legacy.d.ts +8 -0
- package/dist/src/work/legacy.js +70 -0
- package/dist/src/work/model.d.ts +0 -3
- package/dist/src/work/model.js +0 -10
- package/dist/src/work/timing.d.ts +3 -3
- package/dist/src/work/timing.js +21 -25
- package/dist/src/workspace.d.ts +4 -250
- package/dist/src/workspace.js +11 -699
- package/node_modules/@eyeauras/cli-factory/README.md +6 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/cli.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/cli.js +76 -28
- package/node_modules/@eyeauras/cli-factory/dist/src/cli.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/command.d.ts +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/command.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/command.js +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/command.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/errors.d.ts +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/errors.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/errors.js +18 -6
- package/node_modules/@eyeauras/cli-factory/dist/src/errors.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/file-publication.d.ts +44 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/file-publication.d.ts.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/{profile-file.js → file-publication.js} +41 -113
- package/node_modules/@eyeauras/cli-factory/dist/src/file-publication.js.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/help.d.ts +5 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/help.d.ts.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/help.js +17 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/help.js.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/index.d.ts +9 -4
- package/node_modules/@eyeauras/cli-factory/dist/src/index.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/index.js +5 -2
- package/node_modules/@eyeauras/cli-factory/dist/src/index.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/json-rpc.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/json-rpc.js +11 -18
- package/node_modules/@eyeauras/cli-factory/dist/src/json-rpc.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/output-write.d.ts +10 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/output-write.d.ts.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/output-write.js +69 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/output-write.js.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/output.d.ts +3 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/output.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/output.js +74 -14
- package/node_modules/@eyeauras/cli-factory/dist/src/output.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/pagination.d.ts +3 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/pagination.d.ts.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/pagination.js +9 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/pagination.js.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/permissions.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/permissions.js +3 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/permissions.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/stream-result.d.ts +16 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/stream-result.d.ts.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/stream-result.js +83 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/stream-result.js.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/types.d.ts +5 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/types.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/view.d.ts +49 -7
- package/node_modules/@eyeauras/cli-factory/dist/src/view.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/view.js +83 -6
- package/node_modules/@eyeauras/cli-factory/dist/src/view.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/package.json +1 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/cli-host.proto +19 -19
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/build.d.ts +7 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/build.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/build.js +9 -4
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/build.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/host.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/host.js +5 -4
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/host.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/package-build.d.ts +11 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/package-build.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/package-build.js +85 -57
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/package-build.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory-ipc/package.json +2 -2
- package/package.json +4 -5
- package/references/native/InsightAnalyzerOptions.java +10 -0
- package/references/native/InsightAnchorScan.java +1 -11
- package/references/native/InsightCodeReferences.java +2 -3
- package/references/native/InsightCopyType.java +24 -0
- package/references/native/InsightFunctionBoundaries.java +0 -1
- package/references/native/InsightFunctionDatabases.java +20 -16
- package/references/native/InsightHelperCall.java +17 -0
- package/references/native/InsightHubServer.java +214 -0
- package/references/native/InsightNativeHost.java +112 -0
- package/references/native/InsightPlugins.java +0 -1
- package/references/native/InsightPythonWheels.java +3 -2
- package/references/native/InsightResearchQueries.java +3 -4
- package/references/native/InsightResearchView.java +4 -10
- package/references/native/InsightSdkFiles.java +7 -15
- package/references/native/InsightSdkScript.java +1 -4
- package/references/native/InsightSdkTools.java +36 -97
- package/references/native/InsightSdkTypes.java +13 -43
- package/references/native/InsightStringAnchors.java +1 -3
- package/references/native/InsightTraceState.java +13 -96
- package/references/native/InsightTraceTools.java +3 -5
- package/references/native/InsightVersionTracking.java +0 -6
- package/references/native/{HeadlessProgramMergeManager.java → InsightWcMerge.java} +17 -24
- package/references/native/InsightWcOps.java +449 -0
- package/references/native/InsightWcWorker.java +142 -0
- package/references/native/NATIVE-MERGE-NOTICE.txt +4 -8
- package/runtime/GhidraMCP-7.0.0.jar +0 -0
- package/runtime/managed/insight-heap/README.md +3 -3
- package/runtime/managed/insight-managed/README.md +3 -3
- package/runtime/native/binary/README.md +5 -4
- package/runtime/native/windows/DirectoryAlias.cs +24 -0
- package/runtime/native/windows/Insight.Windows.csproj +27 -0
- package/runtime/native/windows/Native.cs +36 -0
- package/runtime/native/windows/OwnedJob.cs +86 -0
- package/runtime/native/windows/Program.cs +50 -0
- package/runtime/native/windows/RegistryRedirect.cs +42 -0
- package/runtime/native/windows/insight-windows-x64.exe +0 -0
- package/runtime/native/windows/packages.lock.json +35 -0
- package/runtime/native/windows/provenance.json +17 -0
- package/runtime/research-view.provenance.json +6 -7
- package/runtime/toolbox.json +33 -114
- package/skill-bundle/insight-artifacts/SKILL.md +5 -19
- package/skill-bundle/insight-binary/SKILL.md +5 -35
- package/skill-bundle/insight-capture/SKILL.md +5 -45
- package/skill-bundle/insight-cli/SKILL.md +6 -44
- package/skill-bundle/insight-die/SKILL.md +5 -38
- package/skill-bundle/insight-dnspy/SKILL.md +5 -54
- package/skill-bundle/insight-dotnet-dump/SKILL.md +5 -35
- package/skill-bundle/insight-dotnet-stack/SKILL.md +5 -28
- package/skill-bundle/insight-dotnet-trace/SKILL.md +5 -34
- package/skill-bundle/insight-frida/SKILL.md +5 -56
- package/skill-bundle/insight-ghidra/SKILL.md +14 -113
- package/skill-bundle/insight-ilspy/SKILL.md +5 -34
- package/skill-bundle/insight-interop/SKILL.md +5 -43
- package/skill-bundle/insight-lldb/SKILL.md +5 -43
- package/skill-bundle/insight-llvm/SKILL.md +5 -45
- package/skill-bundle/insight-managed-heap/SKILL.md +5 -32
- package/skill-bundle/insight-managed-metadata/SKILL.md +5 -41
- package/skill-bundle/insight-mitmproxy/SKILL.md +5 -51
- package/skill-bundle/insight-overview/SKILL.md +5 -68
- package/skill-bundle/insight-procmon/SKILL.md +5 -38
- package/skill-bundle/insight-re/SKILL.md +10 -127
- package/skill-bundle/insight-sevenzip/SKILL.md +5 -31
- package/skill-bundle/insight-strace/SKILL.md +5 -35
- package/skill-bundle/insight-tshark/SKILL.md +5 -38
- package/skill-bundle/insight-windbg/SKILL.md +5 -35
- package/skill-bundle/manifest.json +1 -1
- package/skills/insight-artifacts/SKILL.md +5 -19
- package/skills/insight-binary/SKILL.md +5 -35
- package/skills/insight-capture/SKILL.md +5 -45
- package/skills/insight-die/SKILL.md +5 -38
- package/skills/insight-dnspy/SKILL.md +5 -54
- package/skills/insight-dotnet-dump/SKILL.md +5 -35
- package/skills/insight-dotnet-stack/SKILL.md +5 -28
- package/skills/insight-dotnet-trace/SKILL.md +5 -34
- package/skills/insight-frida/SKILL.md +5 -56
- package/skills/insight-ghidra/SKILL.md +14 -113
- package/skills/insight-ilspy/SKILL.md +5 -34
- package/skills/insight-interop/SKILL.md +5 -43
- package/skills/insight-lldb/SKILL.md +5 -43
- package/skills/insight-llvm/SKILL.md +5 -45
- package/skills/insight-managed-heap/SKILL.md +5 -32
- package/skills/insight-managed-metadata/SKILL.md +5 -41
- package/skills/insight-mitmproxy/SKILL.md +5 -51
- package/skills/insight-overview/SKILL.md +5 -68
- package/skills/insight-procmon/SKILL.md +5 -38
- package/skills/insight-re/SKILL.md +10 -127
- package/skills/insight-sevenzip/SKILL.md +5 -31
- package/skills/insight-strace/SKILL.md +5 -35
- package/skills/insight-tshark/SKILL.md +5 -38
- package/skills/insight-windbg/SKILL.md +5 -35
- package/dist/src/administration-results.d.ts +0 -1
- package/dist/src/administration-results.js +0 -84
- package/dist/src/administration.d.ts +0 -14
- package/dist/src/administration.js +0 -134
- package/dist/src/archive-contract.d.ts +0 -6
- package/dist/src/archive-contract.js +0 -108
- package/dist/src/archive.d.ts +0 -12
- package/dist/src/archive.js +0 -116
- package/dist/src/comment-effects.d.ts +0 -3
- package/dist/src/comment-effects.js +0 -55
- package/dist/src/context-credential.d.ts +0 -18
- package/dist/src/context-credential.js +0 -44
- package/dist/src/contexts.d.ts +0 -387
- package/dist/src/contexts.js +0 -2805
- package/dist/src/coordinator.d.ts +0 -41
- package/dist/src/coordinator.js +0 -160
- package/dist/src/cross-peer.d.ts +0 -20
- package/dist/src/cross-peer.js +0 -53
- package/dist/src/data-effects.d.ts +0 -3
- package/dist/src/data-effects.js +0 -103
- package/dist/src/debugger-caller.d.ts +0 -17
- package/dist/src/debugger-caller.js +0 -129
- package/dist/src/debugger-launch.d.ts +0 -2
- package/dist/src/debugger-launch.js +0 -17
- package/dist/src/debugger-supervisor.js +0 -179
- package/dist/src/directory-identity.d.ts +0 -6
- package/dist/src/directory-identity.js +0 -45
- package/dist/src/documentation-effects.d.ts +0 -5
- package/dist/src/documentation-effects.js +0 -56
- package/dist/src/function-effects.d.ts +0 -4
- package/dist/src/function-effects.js +0 -112
- package/dist/src/ghidra-processes.d.ts +0 -6
- package/dist/src/ghidra-processes.js +0 -138
- package/dist/src/ghidra.d.ts +0 -50
- package/dist/src/ghidra.js +0 -468
- package/dist/src/initial-model.d.ts +0 -7
- package/dist/src/initial-model.js +0 -115
- package/dist/src/initial-progress.d.ts +0 -4
- package/dist/src/initial-progress.js +0 -74
- package/dist/src/inline-script.d.ts +0 -15
- package/dist/src/inline-script.js +0 -61
- package/dist/src/legacy-migration.d.ts +0 -37
- package/dist/src/legacy-migration.js +0 -238
- package/dist/src/lifecycle.d.ts +0 -77
- package/dist/src/lifecycle.js +0 -315
- package/dist/src/merge.d.ts +0 -29
- package/dist/src/merge.js +0 -66
- package/dist/src/mutation-effects.d.ts +0 -4
- package/dist/src/mutation-effects.js +0 -321
- package/dist/src/native-queries.d.ts +0 -2
- package/dist/src/native-queries.js +0 -24
- package/dist/src/native-service.d.ts +0 -40
- package/dist/src/native-service.js +0 -406
- package/dist/src/projects.d.ts +0 -31
- package/dist/src/projects.js +0 -302
- package/dist/src/prototype-cli.d.ts +0 -8
- package/dist/src/prototype-cli.js +0 -155
- package/dist/src/query-results.d.ts +0 -2
- package/dist/src/query-results.js +0 -224
- package/dist/src/research-view.d.ts +0 -6
- package/dist/src/research-view.js +0 -9
- package/dist/src/sdk-files.d.ts +0 -29
- package/dist/src/sdk-files.js +0 -249
- package/dist/src/server.d.ts +0 -102
- package/dist/src/server.js +0 -663
- package/dist/src/storage-gc.d.ts +0 -23
- package/dist/src/storage-gc.js +0 -600
- package/dist/src/store.d.ts +0 -33
- package/dist/src/store.js +0 -178
- package/dist/src/sync-policy.d.ts +0 -22
- package/dist/src/sync-policy.js +0 -129
- package/dist/src/timed-backend.d.ts +0 -3
- package/dist/src/timed-backend.js +0 -24
- package/dist/src/timing-report.d.ts +0 -32
- package/dist/src/timing-report.js +0 -74
- package/dist/src/tool-runtime/native-process-proof.d.ts +0 -2
- package/dist/src/tool-runtime/native-process-proof.js +0 -26
- package/dist/src/transport.d.ts +0 -60
- package/dist/src/transport.js +0 -223
- package/dist/src/unresolved-guidance.d.ts +0 -46
- package/dist/src/unresolved-guidance.js +0 -55
- package/dist/src/work/backup.d.ts +0 -66
- package/dist/src/work/backup.js +0 -446
- package/dist/src/work/store.js +0 -1107
- package/dist/src/worker-lease.d.ts +0 -17
- package/dist/src/worker-lease.js +0 -50
- package/node_modules/@eyeauras/cli-factory/dist/src/profile-file.d.ts +0 -37
- package/node_modules/@eyeauras/cli-factory/dist/src/profile-file.d.ts.map +0 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/profile-file.js.map +0 -1
- package/references/InsightRepositoryProbe.java +0 -55
- package/references/administration.md +0 -34
- package/references/agent-execution.md +0 -36
- package/references/agent-setup.md +0 -60
- package/references/archive.md +0 -32
- package/references/artifacts.md +0 -52
- package/references/debugger.md +0 -64
- package/references/extensions-and-sync.md +0 -125
- package/references/ilspy.md +0 -33
- package/references/managed-runtime.md +0 -162
- package/references/native/InsightArchivePayloads.java +0 -36
- package/references/native/InsightBlockTransfer.java +0 -57
- package/references/native/InsightGuiMain.java +0 -33
- package/references/native/InsightHeadlessMain.java +0 -18
- package/references/native/InsightImportProgress.java +0 -60
- package/references/native/InsightInitialImport.java +0 -48
- package/references/native/InsightInitialJournal.java +0 -57
- package/references/native/InsightInitialPublication.java +0 -142
- package/references/native/InsightInitialRecovery.java +0 -131
- package/references/native/InsightInlineExecutor.java +0 -143
- package/references/native/InsightInlineScript.java +0 -14
- package/references/native/InsightNativeCheckout.java +0 -487
- package/references/native/InsightNativeFingerprint.java +0 -80
- package/references/native/InsightNativeMigration.java +0 -155
- package/references/native/InsightNativeRead.java +0 -80
- package/references/native/InsightNativeReceipt.java +0 -31
- package/references/native/InsightNativeService.java +0 -43
- package/references/native/InsightNativeView.java +0 -40
- package/references/native/InsightOfflineAuthenticator.java +0 -20
- package/references/native/InsightOwnedScripts.java +0 -170
- package/references/native/InsightProjectFiles.java +0 -92
- package/references/native/InsightPublicationRecovery.java +0 -63
- package/references/native/InsightServerAdministration.java +0 -82
- package/references/native/InsightServerInit.java +0 -62
- package/references/native/InsightServerMain.java +0 -43
- package/references/native/InsightServerProbe.java +0 -29
- package/references/native/InsightSnapshotFields.java +0 -74
- package/references/native/InsightSnapshotInspect.java +0 -191
- package/references/native/InsightSnapshotPublisher.java +0 -123
- package/references/native/InsightStopDebugger.java +0 -20
- package/references/native/InsightTraceInspect.java +0 -24
- package/references/native/InsightWorkerLease.java +0 -132
- package/references/native-workflows.md +0 -124
- package/references/persistent-client.mjs +0 -147
- package/references/persistent.md +0 -90
- package/references/query-semantics.md +0 -109
- package/references/recovery.md +0 -235
- package/references/research.md +0 -296
- package/references/setup.md +0 -135
- package/references/sparse-navigation.md +0 -173
- package/references/storage.md +0 -139
- package/references/work-tracking.md +0 -261
- package/runtime/native/file-version.ps1 +0 -7
- package/runtime/native/mitmproxy/bridge.py +0 -180
- package/runtime/native/windows-job/DirectoryAlias.cs +0 -24
- package/runtime/native/windows-job/Insight.WindowsJob.csproj +0 -1
- package/runtime/native/windows-job/Insight.WindowsJob.dll +0 -0
- package/runtime/native/windows-job/OwnedJob.cs +0 -79
- package/runtime/native/windows-job/RegistryRedirect.cs +0 -45
- package/runtime/native/windows-job/packages.lock.json +0 -21
- package/runtime/native/windows-job/provenance.json +0 -16
- package/runtime/native/windows-job/windows-job.ps1 +0 -8
- package/skill-bundle/insight-artifacts/references/agent-execution.md +0 -36
- package/skill-bundle/insight-artifacts/references/artifacts.md +0 -52
- package/skill-bundle/insight-artifacts/references/recovery.md +0 -235
- package/skill-bundle/insight-artifacts/references/storage.md +0 -139
- package/skill-bundle/insight-binary/references/agent-execution.md +0 -36
- package/skill-bundle/insight-capture/references/agent-execution.md +0 -36
- package/skill-bundle/insight-cli/references/agent-execution.md +0 -36
- package/skill-bundle/insight-cli/references/agent-setup.md +0 -60
- package/skill-bundle/insight-cli/references/archive.md +0 -32
- package/skill-bundle/insight-cli/references/managed-runtime.md +0 -162
- package/skill-bundle/insight-cli/references/persistent-client.mjs +0 -147
- package/skill-bundle/insight-cli/references/persistent.md +0 -90
- package/skill-bundle/insight-cli/references/recovery.md +0 -235
- package/skill-bundle/insight-cli/references/setup.md +0 -135
- package/skill-bundle/insight-cli/references/storage.md +0 -139
- package/skill-bundle/insight-die/references/agent-execution.md +0 -36
- package/skill-bundle/insight-dnspy/references/agent-execution.md +0 -36
- package/skill-bundle/insight-dotnet-dump/references/agent-execution.md +0 -36
- package/skill-bundle/insight-dotnet-stack/references/agent-execution.md +0 -36
- package/skill-bundle/insight-dotnet-trace/references/agent-execution.md +0 -36
- package/skill-bundle/insight-frida/references/agent-execution.md +0 -36
- package/skill-bundle/insight-ghidra/references/administration.md +0 -34
- package/skill-bundle/insight-ghidra/references/agent-execution.md +0 -36
- package/skill-bundle/insight-ghidra/references/archive.md +0 -32
- package/skill-bundle/insight-ghidra/references/artifacts.md +0 -52
- package/skill-bundle/insight-ghidra/references/debugger.md +0 -64
- package/skill-bundle/insight-ghidra/references/extensions-and-sync.md +0 -125
- package/skill-bundle/insight-ghidra/references/managed-runtime.md +0 -162
- package/skill-bundle/insight-ghidra/references/native-workflows.md +0 -124
- package/skill-bundle/insight-ghidra/references/persistent-client.mjs +0 -147
- package/skill-bundle/insight-ghidra/references/persistent.md +0 -90
- package/skill-bundle/insight-ghidra/references/query-semantics.md +0 -109
- package/skill-bundle/insight-ghidra/references/recovery.md +0 -235
- package/skill-bundle/insight-ghidra/references/research.md +0 -296
- package/skill-bundle/insight-ghidra/references/setup.md +0 -135
- package/skill-bundle/insight-ghidra/references/sparse-navigation.md +0 -173
- package/skill-bundle/insight-ghidra/references/storage.md +0 -139
- package/skill-bundle/insight-ilspy/references/agent-execution.md +0 -36
- package/skill-bundle/insight-ilspy/references/ilspy.md +0 -33
- package/skill-bundle/insight-interop/references/agent-execution.md +0 -36
- package/skill-bundle/insight-lldb/references/agent-execution.md +0 -36
- package/skill-bundle/insight-llvm/references/agent-execution.md +0 -36
- package/skill-bundle/insight-managed-heap/references/agent-execution.md +0 -36
- package/skill-bundle/insight-managed-metadata/references/agent-execution.md +0 -36
- package/skill-bundle/insight-mitmproxy/references/agent-execution.md +0 -36
- package/skill-bundle/insight-overview/references/agent-execution.md +0 -36
- package/skill-bundle/insight-procmon/references/agent-execution.md +0 -36
- package/skill-bundle/insight-re/references/agent-execution.md +0 -36
- package/skill-bundle/insight-re/references/artifacts.md +0 -52
- package/skill-bundle/insight-re/references/persistent-client.mjs +0 -147
- package/skill-bundle/insight-re/references/persistent.md +0 -90
- package/skill-bundle/insight-re/references/recovery.md +0 -235
- package/skill-bundle/insight-re/references/storage.md +0 -139
- package/skill-bundle/insight-re/references/work-tracking.md +0 -261
- package/skill-bundle/insight-sevenzip/references/agent-execution.md +0 -36
- package/skill-bundle/insight-strace/references/agent-execution.md +0 -36
- package/skill-bundle/insight-tshark/references/agent-execution.md +0 -36
- package/skill-bundle/insight-windbg/references/agent-execution.md +0 -36
- package/skills/insight-artifacts/references/agent-execution.md +0 -36
- package/skills/insight-artifacts/references/artifacts.md +0 -52
- package/skills/insight-artifacts/references/recovery.md +0 -235
- package/skills/insight-artifacts/references/storage.md +0 -139
- package/skills/insight-binary/references/agent-execution.md +0 -36
- package/skills/insight-capture/references/agent-execution.md +0 -36
- package/skills/insight-die/references/agent-execution.md +0 -36
- package/skills/insight-dnspy/references/agent-execution.md +0 -36
- package/skills/insight-dotnet-dump/references/agent-execution.md +0 -36
- package/skills/insight-dotnet-stack/references/agent-execution.md +0 -36
- package/skills/insight-dotnet-trace/references/agent-execution.md +0 -36
- package/skills/insight-frida/references/agent-execution.md +0 -36
- package/skills/insight-ghidra/references/administration.md +0 -34
- package/skills/insight-ghidra/references/agent-execution.md +0 -36
- package/skills/insight-ghidra/references/archive.md +0 -32
- package/skills/insight-ghidra/references/artifacts.md +0 -52
- package/skills/insight-ghidra/references/debugger.md +0 -64
- package/skills/insight-ghidra/references/extensions-and-sync.md +0 -125
- package/skills/insight-ghidra/references/managed-runtime.md +0 -162
- package/skills/insight-ghidra/references/native-workflows.md +0 -124
- package/skills/insight-ghidra/references/persistent-client.mjs +0 -147
- package/skills/insight-ghidra/references/persistent.md +0 -90
- package/skills/insight-ghidra/references/query-semantics.md +0 -109
- package/skills/insight-ghidra/references/recovery.md +0 -235
- package/skills/insight-ghidra/references/research.md +0 -296
- package/skills/insight-ghidra/references/setup.md +0 -135
- package/skills/insight-ghidra/references/sparse-navigation.md +0 -173
- package/skills/insight-ghidra/references/storage.md +0 -139
- package/skills/insight-ilspy/references/agent-execution.md +0 -36
- package/skills/insight-ilspy/references/ilspy.md +0 -33
- package/skills/insight-interop/references/agent-execution.md +0 -36
- package/skills/insight-lldb/references/agent-execution.md +0 -36
- package/skills/insight-llvm/references/agent-execution.md +0 -36
- package/skills/insight-managed-heap/references/agent-execution.md +0 -36
- package/skills/insight-managed-metadata/references/agent-execution.md +0 -36
- package/skills/insight-mitmproxy/references/agent-execution.md +0 -36
- package/skills/insight-overview/references/agent-execution.md +0 -36
- package/skills/insight-procmon/references/agent-execution.md +0 -36
- package/skills/insight-re/references/agent-execution.md +0 -36
- package/skills/insight-re/references/artifacts.md +0 -52
- package/skills/insight-re/references/persistent-client.mjs +0 -147
- package/skills/insight-re/references/persistent.md +0 -90
- package/skills/insight-re/references/recovery.md +0 -235
- package/skills/insight-re/references/storage.md +0 -139
- package/skills/insight-re/references/work-tracking.md +0 -261
- package/skills/insight-sevenzip/references/agent-execution.md +0 -36
- package/skills/insight-strace/references/agent-execution.md +0 -36
- package/skills/insight-tshark/references/agent-execution.md +0 -36
- package/skills/insight-windbg/references/agent-execution.md +0 -36
- /package/dist/src/{debugger-supervisor.d.ts → native/contract.js} +0 -0
- /package/runtime/native/{windows-job → windows}/NuGet.Config +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { resolve, join, isAbsolute } from 'node:path';
|
|
3
|
-
import { fail, object
|
|
3
|
+
import { fail, object } from './model.js';
|
|
4
4
|
import { functionResult } from './function-results.js';
|
|
5
5
|
import { timed } from './internal-timing.js';
|
|
6
6
|
import { textWindow } from './text-window.js';
|
|
@@ -8,7 +8,7 @@ import { CliError } from '@eyeauras/cli-factory';
|
|
|
8
8
|
import { entryAddress, entryRequest, functionSelectors, locatedEntries } from './function-entries.js';
|
|
9
9
|
import { locatedBoundaries } from './function-boundaries.js';
|
|
10
10
|
const fields = new Set('signature classification return_type entry_point body_start body_end decompiled_code plate_comment comments labels tags parameters locals callers call_context callees xrefs disassembly jump_targets refs'.split(' '));
|
|
11
|
-
export async function inspectFunctions(backend, scope, parameters, options, view
|
|
11
|
+
export async function inspectFunctions(backend, scope, parameters, options, view) {
|
|
12
12
|
if (options.saveDirectory !== undefined && !isAbsolute(options.saveDirectory))
|
|
13
13
|
fail('invalid', 'Save directory must be an absolute path on the owner host.');
|
|
14
14
|
const selectors = functionSelectors(parameters), lookup = entryRequest(parameters, options);
|
|
@@ -17,35 +17,21 @@ export async function inspectFunctions(backend, scope, parameters, options, view
|
|
|
17
17
|
fail('invalid', 'Unknown function field. Allowed fields: ' + [...fields].join(', '));
|
|
18
18
|
if (options.expectView !== undefined && options.expectView !== view.identity)
|
|
19
19
|
fail('binding', 'Function continuation view changed.', { reason: 'changed_view', view });
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (!observeAfter || typeof object(observation ?? {}).modification !== 'string')
|
|
27
|
-
fail('unsupported', 'Address resolution requires guarded native observations.');
|
|
28
|
-
if ('unwindMaximum' in lookup) {
|
|
29
|
-
const result = locatedBoundaries(await backend.call(scope, '/insight/function-boundaries/v1', { addresses: lookup.addresses.join(','), max_unwind_bytes: lookup.unwindMaximum }), lookup, String(object(observation).modification));
|
|
30
|
-
entries = result.entries;
|
|
31
|
-
boundaryLookup = result.boundaryLookup;
|
|
32
|
-
}
|
|
33
|
-
else
|
|
34
|
-
entries = locatedEntries(await backend.call(scope, '/insight/function-entries/v1', { addresses: lookup.addresses.join(','), max_entry_distance: lookup.maximum }), lookup, String(object(observation).modification));
|
|
20
|
+
let entries, boundaryLookup;
|
|
21
|
+
if (lookup) {
|
|
22
|
+
if ('unwindMaximum' in lookup) {
|
|
23
|
+
const result = locatedBoundaries(await backend.call(scope, '/insight/function-boundaries/v1', { addresses: lookup.addresses.join(','), max_unwind_bytes: lookup.unwindMaximum }), lookup);
|
|
24
|
+
entries = result.entries;
|
|
25
|
+
boundaryLookup = result.boundaryLookup;
|
|
35
26
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
raw = nativeSelectors.length ? object(await backend.call(scope, '/get_functions', nativeParameters)) : { functions: {} };
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
await guard();
|
|
42
|
-
throw error;
|
|
27
|
+
else
|
|
28
|
+
entries = locatedEntries(await backend.call(scope, '/insight/function-entries/v1', { addresses: lookup.addresses.join(','), max_entry_distance: lookup.maximum }), lookup);
|
|
43
29
|
}
|
|
44
|
-
|
|
30
|
+
const nativeSelectors = entries ? [...new Set([...entries.values()].flatMap(row => row.entry ? [row.entry] : []))] : selectors;
|
|
31
|
+
const nativeParameters = { ...parameters, ...(entries ? { function: '' } : {}), functions: nativeSelectors.join(','), ...(entries && selectedFields.length ? { fields: [...new Set([...selectedFields, 'entry_point'])].join(',') } : {}) };
|
|
32
|
+
const raw = nativeSelectors.length ? object(await backend.call(scope, '/get_functions', nativeParameters)) : { functions: {} };
|
|
45
33
|
return timed('adapter.normalize', 'functions.inspect', async () => {
|
|
46
34
|
const functions = object(raw.functions);
|
|
47
|
-
if (Object.keys(functions).length !== nativeSelectors.length || nativeSelectors.some(s => !Object.hasOwn(functions, s)))
|
|
48
|
-
fail('partial', 'Bulk function selectors changed.');
|
|
49
35
|
const output = Object.create(null), saved = [];
|
|
50
36
|
let remaining = options.total;
|
|
51
37
|
for (const [index, selector] of selectors.entries()) {
|
|
@@ -57,7 +43,7 @@ export async function inspectFunctions(backend, scope, parameters, options, view
|
|
|
57
43
|
}
|
|
58
44
|
let found;
|
|
59
45
|
try {
|
|
60
|
-
found = functionResult({ functions: { [selected]: functions[selected] } }, selected
|
|
46
|
+
found = functionResult({ functions: { [selected]: functions[selected] } }, selected);
|
|
61
47
|
}
|
|
62
48
|
catch (error) {
|
|
63
49
|
if (!(error instanceof CliError))
|
|
@@ -66,15 +52,13 @@ export async function inspectFunctions(backend, scope, parameters, options, view
|
|
|
66
52
|
output[selector] = { error: error.message, ...detail, ...provenance, ...(entries ? { selector } : {}), status: detail.reason === 'function_not_found' ? 'not_found' : 'failed' };
|
|
67
53
|
continue;
|
|
68
54
|
}
|
|
69
|
-
if (located?.entry && entryAddress(found.entry_point) !== located.entry)
|
|
70
|
-
fail('binding', 'Inspected function differs from the resolved entry.', { reason: 'selector_mismatch' });
|
|
71
55
|
const row = { ...found, ...provenance, status: 'success' };
|
|
72
56
|
if (typeof row.decompiled_code === 'string') {
|
|
73
|
-
const source = row.decompiled_code, window = textWindow(source, options.saveDirectory ? 0 : Math.min(options.limit, remaining), options.saveDirectory ? 0 : options.offset, Boolean(object(row.truncation ?? {}).decompiled_code));
|
|
57
|
+
const source = row.decompiled_code, window = textWindow(source, options.saveDirectory ? 0 : Math.min(options.limit, remaining), options.saveDirectory ? 0 : options.offset, Boolean(object(row.truncation ?? {}).decompiled_code), Boolean(options.saveDirectory));
|
|
74
58
|
const { content, ...metadata } = window;
|
|
75
|
-
remaining -=
|
|
59
|
+
remaining -= window.returnedCharacters;
|
|
76
60
|
row.decompiled_code = content;
|
|
77
|
-
row.text = { ...metadata,
|
|
61
|
+
row.text = { ...metadata, nextOffset: Math.min(window.totalCharacters, window.offset + window.returnedCharacters) };
|
|
78
62
|
if (options.saveDirectory) {
|
|
79
63
|
if (Buffer.byteLength(source) > 4 * 1024 ** 2)
|
|
80
64
|
fail('limit', 'Native function text exceeds the four MiB saved-file bound.');
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
export declare function functionFailure(selector: string, reason: string, diagnostic?: unknown): never;
|
|
2
|
-
export declare function functionResult(value: unknown, selector: string,
|
|
3
|
-
requireEntryPoint?: boolean;
|
|
4
|
-
}): Record<string, unknown>;
|
|
2
|
+
export declare function functionResult(value: unknown, selector: string): Record<string, unknown>;
|
|
@@ -6,22 +6,11 @@ export function functionFailure(selector, reason, diagnostic) {
|
|
|
6
6
|
reason === 'native_function_failure' || reason === 'missing_decompiler_text' ? ' For an existing function entry, try ghidra functions force-decompile --function <entry> with the same session/target. This refreshes decompiler output, not Listing instructions or stored xrefs; use functions decode for bounded local bytes.' : '';
|
|
7
7
|
fail('partial', 'Function inspection failed: ' + reason + '.' + recovery, { selector, reason, ...(nativeDiagnostic ? { nativeDiagnostic } : {}) });
|
|
8
8
|
}
|
|
9
|
-
export function functionResult(value, selector
|
|
10
|
-
|
|
11
|
-
functionFailure(selector, 'invalid_native_shape');
|
|
12
|
-
const functions = value.functions;
|
|
13
|
-
if (Object.keys(functions).length !== 1 || !Object.hasOwn(functions, selector))
|
|
14
|
-
functionFailure(selector, 'selector_mismatch');
|
|
15
|
-
const found = functions[selector];
|
|
9
|
+
export function functionResult(value, selector) {
|
|
10
|
+
const found = record(value) && record(value.functions) ? value.functions[selector] : undefined;
|
|
16
11
|
if (!record(found))
|
|
17
12
|
functionFailure(selector, 'invalid_native_shape');
|
|
18
13
|
if (found.error !== undefined)
|
|
19
14
|
functionFailure(selector, typeof found.error === 'string' && /^Function not found\b/i.test(found.error) ? 'function_not_found' : 'native_function_failure', found.error);
|
|
20
|
-
if (typeof found.name !== 'string' || !found.name)
|
|
21
|
-
functionFailure(selector, 'invalid_native_shape');
|
|
22
|
-
if (options.requireEntryPoint !== false || found.entry_point !== undefined) {
|
|
23
|
-
if (typeof found.entry_point !== 'string' || found.entry_point.length > 128 || !/^(?:[A-Za-z0-9_]+:)?(?:0x)?[a-fA-F0-9]+$/.test(found.entry_point))
|
|
24
|
-
functionFailure(selector, 'invalid_native_shape');
|
|
25
|
-
}
|
|
26
15
|
return found;
|
|
27
16
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { CliError } from '@eyeauras/cli-factory';
|
|
2
|
+
import type { HubProject } from './contract.js';
|
|
3
|
+
import type { Hub } from './server.js';
|
|
4
|
+
import type { ProjectState } from './store.js';
|
|
5
|
+
export declare const frozenError: (p: HubProject) => CliError;
|
|
6
|
+
export declare const movedError: (p: HubProject, to: string) => CliError;
|
|
7
|
+
/** Refuses requests for a moved project, and changes of a frozen one. `known`: the state the caller already read. */
|
|
8
|
+
export declare function gate(hub: Hub, projectId: string, write: boolean, known?: ProjectState): ProjectState;
|
|
9
|
+
export declare function exportProject(hub: Hub, body: Record<string, unknown>): Promise<{
|
|
10
|
+
state: string;
|
|
11
|
+
output: string;
|
|
12
|
+
project: string;
|
|
13
|
+
projectId: string;
|
|
14
|
+
targets: number;
|
|
15
|
+
programs: import("./bundle.js").BundleProgram[];
|
|
16
|
+
message?: undefined;
|
|
17
|
+
} | {
|
|
18
|
+
state: string;
|
|
19
|
+
output: string;
|
|
20
|
+
project: string;
|
|
21
|
+
projectId: string;
|
|
22
|
+
targets: number;
|
|
23
|
+
programs: import("./bundle.js").BundleProgram[];
|
|
24
|
+
message: string;
|
|
25
|
+
}>;
|
|
26
|
+
export declare function importProject(hub: Hub, body: Record<string, unknown>): Promise<{
|
|
27
|
+
state: string;
|
|
28
|
+
project: string;
|
|
29
|
+
projectId: string;
|
|
30
|
+
targets: number;
|
|
31
|
+
programs?: undefined;
|
|
32
|
+
} | {
|
|
33
|
+
state: string;
|
|
34
|
+
project: string;
|
|
35
|
+
projectId: string;
|
|
36
|
+
targets: number;
|
|
37
|
+
programs: import("./bundle.js").BundleProgram[];
|
|
38
|
+
}>;
|
|
39
|
+
export declare function setState(hub: Hub, body: Record<string, unknown>): Promise<{
|
|
40
|
+
state: "active" | "frozen" | "moved";
|
|
41
|
+
movedTo: string | null;
|
|
42
|
+
project: string;
|
|
43
|
+
projectId: string;
|
|
44
|
+
}>;
|
|
45
|
+
/** Deletes the repository, target registrations and extension data of a moved project; its tombstone stays. */
|
|
46
|
+
export declare function purgeProject(hub: Hub, body: Record<string, unknown>): Promise<{
|
|
47
|
+
project: string;
|
|
48
|
+
projectId: string;
|
|
49
|
+
repositoryDeleted: boolean;
|
|
50
|
+
targetsRemoved: number;
|
|
51
|
+
movedTo: string | null;
|
|
52
|
+
}>;
|
|
53
|
+
export declare function removeTarget(hub: Hub, body: Record<string, unknown>): Promise<{
|
|
54
|
+
project: string;
|
|
55
|
+
target: string;
|
|
56
|
+
removed: boolean;
|
|
57
|
+
}>;
|
|
58
|
+
export declare function listCheckouts(hub: Hub, body: Record<string, unknown>): Promise<{
|
|
59
|
+
checkouts: {
|
|
60
|
+
project: string;
|
|
61
|
+
projectId: string;
|
|
62
|
+
target: string | null;
|
|
63
|
+
path: string;
|
|
64
|
+
checkout: string;
|
|
65
|
+
user: string;
|
|
66
|
+
host: string;
|
|
67
|
+
version: number;
|
|
68
|
+
latestVersion: number;
|
|
69
|
+
checkedOutAt: string;
|
|
70
|
+
workingCopy: string;
|
|
71
|
+
}[];
|
|
72
|
+
}>;
|
|
73
|
+
export declare function releaseCheckout(hub: Hub, body: Record<string, unknown>): Promise<{
|
|
74
|
+
project: string;
|
|
75
|
+
target: string;
|
|
76
|
+
checkout: string;
|
|
77
|
+
}>;
|
|
78
|
+
/** Removes only what nothing references: programs of removed targets, unreferenced binaries, and (explicitly) old versions. */
|
|
79
|
+
export declare function collectGarbage(hub: Hub, body: Record<string, unknown>, now?: number): Promise<{
|
|
80
|
+
dryRun: boolean;
|
|
81
|
+
items: {
|
|
82
|
+
project: string;
|
|
83
|
+
path: string;
|
|
84
|
+
}[];
|
|
85
|
+
versions: {
|
|
86
|
+
project: string;
|
|
87
|
+
path: string;
|
|
88
|
+
versions: number[];
|
|
89
|
+
}[];
|
|
90
|
+
blobs: {
|
|
91
|
+
sha256: string;
|
|
92
|
+
size: number;
|
|
93
|
+
}[];
|
|
94
|
+
skipped: {
|
|
95
|
+
project: string;
|
|
96
|
+
path: string;
|
|
97
|
+
reason: string;
|
|
98
|
+
}[];
|
|
99
|
+
}>;
|
|
100
|
+
/** Admin routes: POST /admin/<operation>. Paths in a body are paths on the hub machine, so those need a local caller. */
|
|
101
|
+
export declare function adminRoute(hub: Hub, operation: string, body: Record<string, unknown>, local: boolean): Promise<unknown>;
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
// Hub-side administration (#161, docs/HUB.md Moving between hubs, Storage and garbage collection): project export,
|
|
2
|
+
// import, freeze and tombstone, checkouts, target removal and GC. Ghidra Server state is read from Ghidra itself.
|
|
3
|
+
import { CliError } from '@eyeauras/cli-factory';
|
|
4
|
+
import { createReadStream } from 'node:fs';
|
|
5
|
+
import { copyFile, mkdir, rename, rm, writeFile } from 'node:fs/promises';
|
|
6
|
+
import { dirname, join, resolve } from 'node:path';
|
|
7
|
+
import { hubPaths, programPath } from '../core/layout.js';
|
|
8
|
+
import { BUNDLE_FILE, programOf, readBundle } from './bundle.js';
|
|
9
|
+
import { copyTree, exists, listFiles, repositoryDirectory, scanRepository } from './repository.js';
|
|
10
|
+
import { installationHash } from '../runtime-identity.js';
|
|
11
|
+
import { hubError, invalid, remoteAddress } from './settings.js';
|
|
12
|
+
/** A blob younger than this may belong to an upload whose target is not registered yet. */
|
|
13
|
+
const BLOB_GRACE_MS = 3_600_000;
|
|
14
|
+
const targetPattern = /^\/(t_[a-f0-9]{32})\.bin$/;
|
|
15
|
+
export const frozenError = (p) => new CliError(`Project ${p.name} is frozen for a move to another hub; it is read-only until the move completes (or \`insight-cli hub thaw --project ${p.name}\`).`, { code: 'hub.frozen' });
|
|
16
|
+
export const movedError = (p, to) => new CliError(`Project ${p.name} moved to the hub at ${to}; point this machine there with \`insight-cli hub config set --hub remote --remote ${to}\`.`, { code: 'hub.moved' });
|
|
17
|
+
/** Refuses requests for a moved project, and changes of a frozen one. `known`: the state the caller already read. */
|
|
18
|
+
export function gate(hub, projectId, write, known) {
|
|
19
|
+
const state = known ?? hub.store.projectState(projectId);
|
|
20
|
+
if (state.state === 'moved')
|
|
21
|
+
throw movedError(hub.store.project(projectId), state.movedTo);
|
|
22
|
+
if (write && state.state === 'frozen')
|
|
23
|
+
throw frozenError(hub.store.project(projectId));
|
|
24
|
+
return state;
|
|
25
|
+
}
|
|
26
|
+
const text = (v, name) => { if (typeof v !== 'string' || !v)
|
|
27
|
+
invalid(name + ' is required.'); return v; };
|
|
28
|
+
function projectRef(hub, ref) {
|
|
29
|
+
const value = text(ref, 'project'), p = hub.store.projectByName(value) ?? (/^[a-f0-9]{32}$/.test(value) ? hub.store.project(value) : undefined);
|
|
30
|
+
if (!p)
|
|
31
|
+
throw hubError('hub.not_found', 'Project ' + value + ' does not exist on this hub.');
|
|
32
|
+
return { ...p, ...hub.store.projectState(p.id) };
|
|
33
|
+
}
|
|
34
|
+
const repositoryOf = (hub, p) => repositoryDirectory(hub.o.dataRoot, p.repository);
|
|
35
|
+
/** Blobs the extensions' data refers to (e.g. Work ledger attachments), of one project or of all. */
|
|
36
|
+
async function extensionBlobs(hub, projectId) {
|
|
37
|
+
const found = new Set();
|
|
38
|
+
for (const e of hub.extensions)
|
|
39
|
+
if (e.referencedBlobs)
|
|
40
|
+
for (const sha256 of await e.referencedBlobs(projectId))
|
|
41
|
+
found.add(sha256);
|
|
42
|
+
return found;
|
|
43
|
+
}
|
|
44
|
+
/** Every blob something references: targets and extension data. */
|
|
45
|
+
async function referencedBlobs(hub) { const found = hub.store.referencedBlobs(); for (const sha256 of await extensionBlobs(hub))
|
|
46
|
+
found.add(sha256); return found; }
|
|
47
|
+
export async function exportProject(hub, body) {
|
|
48
|
+
const p = projectRef(hub, body.project), output = resolve(text(body.output, 'output'));
|
|
49
|
+
if (p.state === 'moved')
|
|
50
|
+
throw movedError(p, p.movedTo);
|
|
51
|
+
if (await exists(join(output, BUNDLE_FILE))) {
|
|
52
|
+
const bundle = await readBundle(output);
|
|
53
|
+
if (bundle.project.id !== p.id)
|
|
54
|
+
invalid(`${output} holds a bundle of another project (${bundle.project.name}).`);
|
|
55
|
+
return { state: 'present', output, project: p.name, projectId: p.id, targets: bundle.targets.length, programs: bundle.programs };
|
|
56
|
+
}
|
|
57
|
+
if (await exists(output) && (await listFiles(output)).length)
|
|
58
|
+
invalid(`Output ${output} exists and is not empty.`);
|
|
59
|
+
// Frozen first: the hub refuses target and extension writes, Ghidra makes every user read-only (no checkouts, no check-ins).
|
|
60
|
+
await hub.ghidra.ensure();
|
|
61
|
+
hub.store.setProjectState(p.id, 'frozen');
|
|
62
|
+
await hub.ghidra.call('freeze', { repository: p.repository, frozen: true });
|
|
63
|
+
const items = await hub.ghidra.inspect(p.repository);
|
|
64
|
+
if (items.some(i => i.checkinActive))
|
|
65
|
+
throw hubError('hub.unavailable', 'A check-in into ' + p.name + ' is in progress; repeat the export after it ends.');
|
|
66
|
+
const stage = output + '.partial';
|
|
67
|
+
await rm(stage, { recursive: true, force: true });
|
|
68
|
+
await mkdir(stage, { recursive: true });
|
|
69
|
+
await copyTree(repositoryOf(hub, p), join(stage, 'repository'));
|
|
70
|
+
const programs = items.map(programOf), targets = hub.store.targets(p.id), blobs = new Set();
|
|
71
|
+
/** Copies one blob into the bundle; false when the hub has no such blob. */
|
|
72
|
+
const copyBlob = async (sha256) => {
|
|
73
|
+
const copy = join(stage, 'blobs', sha256);
|
|
74
|
+
await mkdir(dirname(copy), { recursive: true });
|
|
75
|
+
try {
|
|
76
|
+
await copyFile(hub.blobs.path(sha256), copy);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
if (error.code === 'ENOENT')
|
|
80
|
+
return false;
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
blobs.add(sha256);
|
|
84
|
+
return true;
|
|
85
|
+
};
|
|
86
|
+
for (const t of targets)
|
|
87
|
+
if (!blobs.has(t.sha256) && !await copyBlob(t.sha256))
|
|
88
|
+
invalid(`Binary ${t.sha256} of target ${t.id} is missing from the hub.`);
|
|
89
|
+
// Blobs of the project's extension data (Work ledger attachments). A referenced value that is no blob here was never
|
|
90
|
+
// uploaded (or is another kind of hash) and is not part of the project's data.
|
|
91
|
+
for (const sha256 of [...await extensionBlobs(hub, p.id)].sort())
|
|
92
|
+
if (!blobs.has(sha256))
|
|
93
|
+
await copyBlob(sha256);
|
|
94
|
+
const extensions = [];
|
|
95
|
+
for (const e of hub.extensions)
|
|
96
|
+
if (e.exportProject) {
|
|
97
|
+
const directory = join(stage, 'extensions', e.prefix);
|
|
98
|
+
await mkdir(directory, { recursive: true });
|
|
99
|
+
await e.exportProject(p.id, directory);
|
|
100
|
+
extensions.push(e.prefix);
|
|
101
|
+
}
|
|
102
|
+
const bundle = { schema: 1, format: 'insight-hub-project', createdAt: new Date().toISOString(), source: { hubId: hub.store.hubId, address: `${hub.o.listen}:${hub.o.port}` },
|
|
103
|
+
runtimeFingerprint: hub.ghidra.runtime?.fingerprint ?? null, project: { id: p.id, name: p.name, repository: p.repository, createdAt: p.createdAt }, targets, programs,
|
|
104
|
+
blobs: [...blobs].map(sha256 => ({ sha256 })), extensions };
|
|
105
|
+
await writeFile(join(stage, BUNDLE_FILE), JSON.stringify(bundle, null, 1));
|
|
106
|
+
await rm(output, { recursive: true, force: true });
|
|
107
|
+
await rename(stage, output);
|
|
108
|
+
return { state: 'exported', output, project: p.name, projectId: p.id, targets: targets.length, programs,
|
|
109
|
+
message: `Project ${p.name} is frozen here. Import it on the destination with \`insight-cli hub import --input <dir>\`, then run \`insight-cli hub tombstone --project ${p.name} --moved-to <host:port>\` here.` };
|
|
110
|
+
}
|
|
111
|
+
export async function importProject(hub, body) {
|
|
112
|
+
const input = resolve(text(body.input, 'input')), bundle = await readBundle(input), p = bundle.project;
|
|
113
|
+
const present = hub.store.projects().find(x => x.id === p.id);
|
|
114
|
+
if (present) {
|
|
115
|
+
const ids = hub.store.targets(p.id).map(t => t.id).sort().join(','), state = hub.store.projectState(p.id).state;
|
|
116
|
+
if (present.name === p.name && state === 'active' && ids === bundle.targets.map(t => t.id).sort().join(','))
|
|
117
|
+
return { state: 'present', project: p.name, projectId: p.id, targets: bundle.targets.length };
|
|
118
|
+
invalid(`Project id ${p.id} already exists on this hub (${present.name}, ${state}); it is not replaced.`);
|
|
119
|
+
}
|
|
120
|
+
if (hub.store.projectByName(p.name))
|
|
121
|
+
invalid(`A different project named ${p.name} already exists on this hub.`);
|
|
122
|
+
const missing = bundle.extensions.filter(prefix => !hub.extensions.some(e => e.prefix === prefix && e.importProject));
|
|
123
|
+
if (missing.length)
|
|
124
|
+
invalid(`This hub cannot import extension data of ${missing.join(', ')}.`);
|
|
125
|
+
await hub.ghidra.ensure();
|
|
126
|
+
const runtime = hub.ghidra.runtime?.fingerprint;
|
|
127
|
+
// A bundle of an older version names its runtime by an installation hash, which compares with nothing.
|
|
128
|
+
if (bundle.runtimeFingerprint && !installationHash(bundle.runtimeFingerprint) && runtime !== bundle.runtimeFingerprint)
|
|
129
|
+
throw hubError('hub.runtime_mismatch', `The bundle comes from Ghidra runtime ${bundle.runtimeFingerprint}; this hub runs ${runtime}. Both hubs must run the same runtime.`);
|
|
130
|
+
const directory = repositoryDirectory(hub.o.dataRoot, p.repository);
|
|
131
|
+
// A directory without a project row is a previous interrupted import of this bundle.
|
|
132
|
+
if (await exists(directory)) {
|
|
133
|
+
await hub.ghidra.call('drop', { repository: p.repository, delete: false });
|
|
134
|
+
await rm(directory, { recursive: true, force: true });
|
|
135
|
+
}
|
|
136
|
+
const stage = join(hub.o.dataRoot, 'incoming', p.id);
|
|
137
|
+
await rm(stage, { recursive: true, force: true });
|
|
138
|
+
await copyTree(join(input, 'repository'), stage);
|
|
139
|
+
await mkdir(hubPaths(hub.o.dataRoot).ghidra, { recursive: true });
|
|
140
|
+
await rename(stage, directory);
|
|
141
|
+
for (const b of bundle.blobs)
|
|
142
|
+
await hub.blobs.put(b.sha256, createReadStream(join(input, 'blobs', b.sha256)));
|
|
143
|
+
try {
|
|
144
|
+
await hub.ghidra.call('adopt', { repository: p.repository });
|
|
145
|
+
for (const prefix of bundle.extensions)
|
|
146
|
+
await hub.extensions.find(e => e.prefix === prefix).importProject(p.id, join(input, 'extensions', prefix));
|
|
147
|
+
hub.store.importProject(p, bundle.targets);
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
await hub.ghidra.call('drop', { repository: p.repository, delete: false }).catch(() => { });
|
|
151
|
+
await rm(directory, { recursive: true, force: true });
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
return { state: 'imported', project: p.name, projectId: p.id, targets: bundle.targets.length, programs: bundle.programs };
|
|
155
|
+
}
|
|
156
|
+
export async function setState(hub, body) {
|
|
157
|
+
const p = projectRef(hub, body.project), action = text(body.action, 'action');
|
|
158
|
+
if (action === 'tombstone') {
|
|
159
|
+
const to = remoteAddress(text(body.movedTo, 'movedTo'));
|
|
160
|
+
if (p.state === 'active')
|
|
161
|
+
invalid(`Project ${p.name} is not frozen; export it before marking it moved.`);
|
|
162
|
+
if (p.state !== 'moved' || p.movedTo !== to)
|
|
163
|
+
await verifyDestination(p, to);
|
|
164
|
+
hub.store.setProjectState(p.id, 'moved', to);
|
|
165
|
+
}
|
|
166
|
+
else if (action === 'thaw') {
|
|
167
|
+
if (p.state === 'moved')
|
|
168
|
+
throw movedError(p, p.movedTo);
|
|
169
|
+
await hub.ghidra.call('freeze', { repository: p.repository, frozen: false });
|
|
170
|
+
hub.store.setProjectState(p.id, 'active');
|
|
171
|
+
}
|
|
172
|
+
else
|
|
173
|
+
invalid('Unknown project action ' + action + '.');
|
|
174
|
+
return { project: p.name, projectId: p.id, ...hub.store.projectState(p.id) };
|
|
175
|
+
}
|
|
176
|
+
/** The hub at `to` must list the project id before the source names it as the new home. */
|
|
177
|
+
async function verifyDestination(p, to) {
|
|
178
|
+
let projects;
|
|
179
|
+
try {
|
|
180
|
+
const response = await fetch('http://' + to + '/projects', { signal: AbortSignal.timeout(15_000) });
|
|
181
|
+
if (!response.ok)
|
|
182
|
+
throw new Error('HTTP ' + response.status);
|
|
183
|
+
projects = await response.json();
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
invalid(`The destination hub ${to} cannot be reached: ${error.message}`);
|
|
187
|
+
}
|
|
188
|
+
if (!Array.isArray(projects) || !projects.some(x => x?.id === p.id))
|
|
189
|
+
invalid(`The hub at ${to} has no project ${p.id}; import the bundle there first.`);
|
|
190
|
+
}
|
|
191
|
+
/** Deletes the repository, target registrations and extension data of a moved project; its tombstone stays. */
|
|
192
|
+
export async function purgeProject(hub, body) {
|
|
193
|
+
const p = projectRef(hub, body.project);
|
|
194
|
+
if (p.state !== 'moved')
|
|
195
|
+
invalid(`Project ${p.name} has not moved; only the source data of a moved project is deleted.`);
|
|
196
|
+
const directory = repositoryOf(hub, p), present = await exists(directory);
|
|
197
|
+
if (present) {
|
|
198
|
+
await hub.ghidra.call('drop', { repository: p.repository, delete: true });
|
|
199
|
+
await rm(directory, { recursive: true, force: true });
|
|
200
|
+
}
|
|
201
|
+
const targets = hub.store.targets(p.id).length;
|
|
202
|
+
hub.store.removeTargets(p.id);
|
|
203
|
+
// Extension data (ledger rows) goes too, so hub gc can remove the blobs only it referenced.
|
|
204
|
+
for (const e of hub.extensions)
|
|
205
|
+
if (e.purgeProject)
|
|
206
|
+
await e.purgeProject(p.id);
|
|
207
|
+
return { project: p.name, projectId: p.id, repositoryDeleted: present, targetsRemoved: targets, movedTo: p.movedTo };
|
|
208
|
+
}
|
|
209
|
+
export async function removeTarget(hub, body) {
|
|
210
|
+
const p = projectRef(hub, body.project);
|
|
211
|
+
gate(hub, p.id, true);
|
|
212
|
+
const target = text(body.target, 'target');
|
|
213
|
+
return { project: p.name, target, removed: hub.store.removeTarget(p.id, target) };
|
|
214
|
+
}
|
|
215
|
+
export async function listCheckouts(hub, body) {
|
|
216
|
+
const projects = body.project ? [projectRef(hub, body.project)] : hub.store.projects().map(p => ({ ...p, ...hub.store.projectState(p.id) }));
|
|
217
|
+
const checkouts = [];
|
|
218
|
+
for (const p of projects) {
|
|
219
|
+
if (p.state === 'moved')
|
|
220
|
+
continue;
|
|
221
|
+
for (const item of await scanRepository(repositoryOf(hub, p)))
|
|
222
|
+
for (const c of item.checkouts)
|
|
223
|
+
checkouts.push({ project: p.name, projectId: p.id, target: targetPattern.exec(item.path)?.[1] ?? null, path: item.path, checkout: c.id, user: c.user, host: c.host,
|
|
224
|
+
version: c.version, latestVersion: item.versions.at(-1) ?? 0, checkedOutAt: new Date(c.time).toISOString(), workingCopy: c.project.slice(c.host.length + 2) });
|
|
225
|
+
}
|
|
226
|
+
return { checkouts };
|
|
227
|
+
}
|
|
228
|
+
export async function releaseCheckout(hub, body) {
|
|
229
|
+
const p = projectRef(hub, body.project);
|
|
230
|
+
gate(hub, p.id, true);
|
|
231
|
+
const target = text(body.target, 'target'), checkout = text(body.checkout, 'checkout'), path = programPath(target);
|
|
232
|
+
if (!/^\d+$/.test(checkout))
|
|
233
|
+
invalid('checkout must be a checkout id.');
|
|
234
|
+
const released = await hub.ghidra.call('release', { repository: p.repository, path, checkout: Number(checkout) });
|
|
235
|
+
return { project: p.name, target, checkout, ...released };
|
|
236
|
+
}
|
|
237
|
+
/** Removes only what nothing references: programs of removed targets, unreferenced binaries, and (explicitly) old versions. */
|
|
238
|
+
export async function collectGarbage(hub, body, now = Date.now()) {
|
|
239
|
+
const dryRun = body.dryRun === true, keep = body.versions === undefined ? undefined : Number(body.versions);
|
|
240
|
+
if (keep !== undefined && (!Number.isSafeInteger(keep) || keep < 1))
|
|
241
|
+
invalid('--versions must be a positive integer.');
|
|
242
|
+
const items = [], versions = [], skipped = [];
|
|
243
|
+
const calls = [];
|
|
244
|
+
for (const p of hub.store.projects()) {
|
|
245
|
+
const state = hub.store.projectState(p.id).state;
|
|
246
|
+
if (state === 'moved')
|
|
247
|
+
continue;
|
|
248
|
+
const known = new Set(hub.store.targets(p.id).map(t => t.id));
|
|
249
|
+
for (const item of await scanRepository(repositoryOf(hub, p))) {
|
|
250
|
+
const target = targetPattern.exec(item.path)?.[1], removed = !!target && !known.has(target);
|
|
251
|
+
if (!removed && (keep === undefined || item.versions.length <= keep))
|
|
252
|
+
continue;
|
|
253
|
+
if (state === 'frozen') {
|
|
254
|
+
skipped.push({ project: p.name, path: item.path, reason: 'project is frozen for a move' });
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if (removed) {
|
|
258
|
+
if (item.checkouts.length) {
|
|
259
|
+
skipped.push({ project: p.name, path: item.path, reason: `target removed but checked out by ${item.checkouts.map(c => c.user + '@' + c.host).join(', ')}; release the checkouts first` });
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
items.push({ project: p.name, path: item.path });
|
|
263
|
+
calls.push({ repository: p.repository, op: 'deleteItem', path: item.path });
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
// A checkout needs its base version for merging; only versions older than every checkout base go.
|
|
267
|
+
const base = Math.min(...item.checkouts.map(c => c.version), Infinity), drop = item.versions.slice(0, item.versions.length - keep).filter(v => v < base);
|
|
268
|
+
if (drop.length < item.versions.length - keep)
|
|
269
|
+
skipped.push({ project: p.name, path: item.path, reason: `versions from ${base} are kept for open checkouts` });
|
|
270
|
+
if (drop.length) {
|
|
271
|
+
versions.push({ project: p.name, path: item.path, versions: drop });
|
|
272
|
+
for (const version of drop)
|
|
273
|
+
calls.push({ repository: p.repository, op: 'deleteVersion', path: item.path, version });
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
// Targets and extension data (e.g. Work ledger attachments) reference blobs.
|
|
278
|
+
// The directory is listed before the lock: a blob added later is newer than the grace period anyway.
|
|
279
|
+
const listed = await hub.blobs.list(), unreferenced = async () => { const referenced = await referencedBlobs(hub); return listed.filter(b => !referenced.has(b.sha256) && now - b.modified >= BLOB_GRACE_MS); };
|
|
280
|
+
let blobs;
|
|
281
|
+
if (dryRun)
|
|
282
|
+
blobs = await unreferenced();
|
|
283
|
+
else {
|
|
284
|
+
for (const c of calls)
|
|
285
|
+
await hub.ghidra.call(c.op, { repository: c.repository, path: c.path, ...(c.version === undefined ? {} : { version: c.version }) });
|
|
286
|
+
// References are read right before the removal, exclusive of target registrations and extension writes.
|
|
287
|
+
blobs = await hub.blobRemoval(async () => { const gone = await unreferenced(); for (const b of gone)
|
|
288
|
+
await hub.blobs.remove(b.sha256); return gone; });
|
|
289
|
+
}
|
|
290
|
+
return { dryRun, items, versions, blobs: blobs.map(b => ({ sha256: b.sha256, size: b.size })), skipped };
|
|
291
|
+
}
|
|
292
|
+
/** Admin routes: POST /admin/<operation>. Paths in a body are paths on the hub machine, so those need a local caller. */
|
|
293
|
+
export async function adminRoute(hub, operation, body, local) {
|
|
294
|
+
const needsLocal = (o) => { if (!local)
|
|
295
|
+
invalid(`hub ${o} reads and writes paths on the hub machine; run it there.`); };
|
|
296
|
+
switch (operation) {
|
|
297
|
+
case 'export':
|
|
298
|
+
needsLocal('export');
|
|
299
|
+
return exportProject(hub, body);
|
|
300
|
+
case 'import':
|
|
301
|
+
needsLocal('import');
|
|
302
|
+
return importProject(hub, body);
|
|
303
|
+
case 'state': return setState(hub, body);
|
|
304
|
+
case 'purge': return purgeProject(hub, body);
|
|
305
|
+
case 'remove-target': return removeTarget(hub, body);
|
|
306
|
+
case 'checkouts': return listCheckouts(hub, body);
|
|
307
|
+
case 'release': return releaseCheckout(hub, body);
|
|
308
|
+
case 'gc': return collectGarbage(hub, body);
|
|
309
|
+
case 'runtime':
|
|
310
|
+
needsLocal('config set --runtime');
|
|
311
|
+
return hub.replaceRuntime(body);
|
|
312
|
+
}
|
|
313
|
+
throw hubError('hub.not_found', 'No admin operation ' + operation + '.');
|
|
314
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export type AutostartAt = 'logon' | 'boot';
|
|
2
|
+
export interface AutostartState {
|
|
3
|
+
installed: boolean;
|
|
4
|
+
at?: AutostartAt;
|
|
5
|
+
name: string;
|
|
6
|
+
mechanism: string;
|
|
7
|
+
}
|
|
8
|
+
export interface Autostart {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
probe(): Promise<AutostartState>;
|
|
11
|
+
/** `args` are appended to `hub run` (e.g. the initial runtime). */
|
|
12
|
+
install(at: AutostartAt, args?: string[]): Promise<AutostartState>;
|
|
13
|
+
uninstall(): Promise<AutostartState>;
|
|
14
|
+
/** Asks the OS to start the registered hub now. */
|
|
15
|
+
start(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export interface Exec {
|
|
18
|
+
(file: string, args: string[]): Promise<{
|
|
19
|
+
code: number;
|
|
20
|
+
stdout: string;
|
|
21
|
+
stderr: string;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
export declare const exec: Exec;
|
|
25
|
+
/** Command line the registration runs: the installed CLI entry point, so an upgrade applies on the next start. */
|
|
26
|
+
export declare const hubCommandLine: () => {
|
|
27
|
+
executable: string;
|
|
28
|
+
arguments: string[];
|
|
29
|
+
};
|
|
30
|
+
export declare const autostartName: (appName?: string) => string;
|
|
31
|
+
/** Task Scheduler definition. `logon` runs as the interactive user without admin; `boot` uses S4U and needs admin. */
|
|
32
|
+
export declare function windowsTaskXml(input: {
|
|
33
|
+
at: AutostartAt;
|
|
34
|
+
user: string;
|
|
35
|
+
executable: string;
|
|
36
|
+
arguments: string[];
|
|
37
|
+
}): string;
|
|
38
|
+
export declare function systemdUnit(input: {
|
|
39
|
+
executable: string;
|
|
40
|
+
arguments: string[];
|
|
41
|
+
}): string;
|
|
42
|
+
export declare function launchdPlist(input: {
|
|
43
|
+
label: string;
|
|
44
|
+
executable: string;
|
|
45
|
+
arguments: string[];
|
|
46
|
+
}): string;
|
|
47
|
+
export declare class WindowsAutostart implements Autostart {
|
|
48
|
+
readonly name: string;
|
|
49
|
+
private readonly run;
|
|
50
|
+
private readonly command;
|
|
51
|
+
readonly mechanism = "Task Scheduler";
|
|
52
|
+
constructor(name: string, run?: Exec, command?: () => {
|
|
53
|
+
executable: string;
|
|
54
|
+
arguments: string[];
|
|
55
|
+
});
|
|
56
|
+
probe(): Promise<AutostartState>;
|
|
57
|
+
install(at: AutostartAt, extra?: string[]): Promise<{
|
|
58
|
+
installed: true;
|
|
59
|
+
at: AutostartAt;
|
|
60
|
+
name: string;
|
|
61
|
+
mechanism: string;
|
|
62
|
+
}>;
|
|
63
|
+
uninstall(): Promise<AutostartState>;
|
|
64
|
+
start(): Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
export declare class SystemdAutostart implements Autostart {
|
|
67
|
+
readonly name: string;
|
|
68
|
+
private readonly run;
|
|
69
|
+
private readonly command;
|
|
70
|
+
private readonly home;
|
|
71
|
+
readonly mechanism = "systemd user unit";
|
|
72
|
+
constructor(name: string, run?: Exec, command?: () => {
|
|
73
|
+
executable: string;
|
|
74
|
+
arguments: string[];
|
|
75
|
+
}, home?: string);
|
|
76
|
+
get unit(): string;
|
|
77
|
+
get file(): string;
|
|
78
|
+
probe(): Promise<AutostartState>;
|
|
79
|
+
install(at: AutostartAt, extra?: string[]): Promise<{
|
|
80
|
+
installed: true;
|
|
81
|
+
at: AutostartAt;
|
|
82
|
+
name: string;
|
|
83
|
+
mechanism: string;
|
|
84
|
+
}>;
|
|
85
|
+
uninstall(): Promise<AutostartState>;
|
|
86
|
+
start(): Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
export declare class LaunchdAutostart implements Autostart {
|
|
89
|
+
readonly name: string;
|
|
90
|
+
private readonly run;
|
|
91
|
+
private readonly command;
|
|
92
|
+
private readonly home;
|
|
93
|
+
private readonly uid;
|
|
94
|
+
readonly mechanism = "launchd LaunchAgent";
|
|
95
|
+
constructor(name: string, run?: Exec, command?: () => {
|
|
96
|
+
executable: string;
|
|
97
|
+
arguments: string[];
|
|
98
|
+
}, home?: string, uid?: number);
|
|
99
|
+
get label(): string;
|
|
100
|
+
get file(): string;
|
|
101
|
+
probe(): Promise<AutostartState>;
|
|
102
|
+
install(at: AutostartAt, extra?: string[]): Promise<{
|
|
103
|
+
installed: true;
|
|
104
|
+
at: "logon";
|
|
105
|
+
name: string;
|
|
106
|
+
mechanism: string;
|
|
107
|
+
}>;
|
|
108
|
+
uninstall(): Promise<AutostartState>;
|
|
109
|
+
start(): Promise<void>;
|
|
110
|
+
}
|
|
111
|
+
export declare function platformAutostart(name?: string, platform?: NodeJS.Platform, run?: Exec): Autostart;
|