@eyeauras/insight-cli 0.5.8 → 0.6.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/SKILL.md +1 -1
- package/dist/src/artifacts.d.ts +1 -1
- package/dist/src/artifacts.js +3 -3
- package/dist/src/cli.js +74 -15
- package/dist/src/contexts.d.ts +120 -10
- package/dist/src/contexts.js +510 -107
- package/dist/src/legacy-migration.d.ts +37 -0
- package/dist/src/legacy-migration.js +238 -0
- package/dist/src/lifecycle.d.ts +16 -5
- package/dist/src/lifecycle.js +43 -6
- package/dist/src/merge.d.ts +1 -1
- package/dist/src/merge.js +2 -2
- package/dist/src/model.d.ts +5 -0
- package/dist/src/model.js +2 -0
- package/dist/src/native-inputs.js +12 -2
- package/dist/src/native-merge-patches.d.ts +6 -0
- package/dist/src/native-merge-patches.js +100 -0
- package/dist/src/persistent-client.d.ts +8 -2
- package/dist/src/persistent-client.js +30 -8
- package/dist/src/projects.js +5 -4
- package/dist/src/research.d.ts +77 -14
- package/dist/src/research.js +99 -123
- package/dist/src/sdk-files.js +3 -3
- package/dist/src/server.d.ts +5 -1
- package/dist/src/server.js +46 -6
- package/dist/src/storage-gc.d.ts +23 -0
- package/dist/src/storage-gc.js +358 -0
- package/dist/src/sync-policy.js +4 -2
- package/dist/src/version-tracking.js +2 -1
- package/dist/src/workspace.d.ts +35 -2
- package/dist/src/workspace.js +91 -7
- package/package.json +1 -1
- package/references/native/APACHE-2.0.txt +202 -0
- package/references/native/HeadlessProgramMergeManager.java +86 -0
- package/references/native/InsightGuiMain.java +1 -0
- package/references/native/InsightHeadlessMain.java +1 -0
- package/references/native/InsightInitialImport.java +1 -1
- package/references/native/InsightNativeCheckout.java +214 -0
- package/references/native/InsightNativeFingerprint.java +53 -0
- package/references/native/InsightNativeMigration.java +155 -0
- package/references/native/InsightNativeRead.java +57 -0
- package/references/native/InsightNativeView.java +29 -0
- package/references/native/InsightOfflineAuthenticator.java +20 -0
- package/references/native/InsightSdkFiles.java +4 -0
- package/references/native/InsightSnapshotFields.java +17 -11
- package/references/native/InsightSnapshotInspect.java +4 -2
- package/references/native/NATIVE-MERGE-NOTICE.txt +15 -0
- package/references/persistent-client.mjs +30 -8
- package/references/persistent.md +47 -7
- package/references/recovery.md +50 -12
- package/references/research.md +25 -22
- package/references/setup.md +13 -3
- package/skill-bundle/insight-artifacts/SKILL.md +1 -1
- package/skill-bundle/insight-artifacts/references/recovery.md +50 -12
- package/skill-bundle/insight-binary/SKILL.md +1 -1
- package/skill-bundle/insight-capture/SKILL.md +1 -1
- package/skill-bundle/insight-cli/SKILL.md +1 -1
- package/skill-bundle/insight-cli/references/persistent-client.mjs +30 -8
- package/skill-bundle/insight-cli/references/persistent.md +47 -7
- package/skill-bundle/insight-cli/references/recovery.md +50 -12
- package/skill-bundle/insight-cli/references/setup.md +13 -3
- package/skill-bundle/insight-die/SKILL.md +1 -1
- package/skill-bundle/insight-dnspy/SKILL.md +1 -1
- package/skill-bundle/insight-dotnet-dump/SKILL.md +1 -1
- package/skill-bundle/insight-dotnet-stack/SKILL.md +1 -1
- package/skill-bundle/insight-dotnet-trace/SKILL.md +1 -1
- package/skill-bundle/insight-frida/SKILL.md +1 -1
- package/skill-bundle/insight-ghidra/SKILL.md +8 -1
- package/skill-bundle/insight-ghidra/references/persistent-client.mjs +30 -8
- package/skill-bundle/insight-ghidra/references/persistent.md +47 -7
- package/skill-bundle/insight-ghidra/references/recovery.md +50 -12
- package/skill-bundle/insight-ghidra/references/research.md +25 -22
- package/skill-bundle/insight-ghidra/references/setup.md +13 -3
- package/skill-bundle/insight-ilspy/SKILL.md +1 -1
- package/skill-bundle/insight-interop/SKILL.md +1 -1
- package/skill-bundle/insight-lldb/SKILL.md +1 -1
- package/skill-bundle/insight-llvm/SKILL.md +1 -1
- package/skill-bundle/insight-managed-heap/SKILL.md +1 -1
- package/skill-bundle/insight-managed-metadata/SKILL.md +1 -1
- package/skill-bundle/insight-mitmproxy/SKILL.md +1 -1
- package/skill-bundle/insight-overview/SKILL.md +1 -1
- package/skill-bundle/insight-procmon/SKILL.md +1 -1
- package/skill-bundle/insight-re/SKILL.md +1 -1
- package/skill-bundle/insight-re/references/persistent-client.mjs +30 -8
- package/skill-bundle/insight-re/references/persistent.md +47 -7
- package/skill-bundle/insight-re/references/recovery.md +50 -12
- package/skill-bundle/insight-sevenzip/SKILL.md +1 -1
- package/skill-bundle/insight-strace/SKILL.md +1 -1
- package/skill-bundle/insight-tshark/SKILL.md +1 -1
- package/skill-bundle/insight-windbg/SKILL.md +1 -1
- package/skill-bundle/manifest.json +1 -1
- package/skills/insight-artifacts/SKILL.md +1 -1
- package/skills/insight-artifacts/references/recovery.md +50 -12
- package/skills/insight-binary/SKILL.md +1 -1
- package/skills/insight-capture/SKILL.md +1 -1
- package/skills/insight-die/SKILL.md +1 -1
- package/skills/insight-dnspy/SKILL.md +1 -1
- package/skills/insight-dotnet-dump/SKILL.md +1 -1
- package/skills/insight-dotnet-stack/SKILL.md +1 -1
- package/skills/insight-dotnet-trace/SKILL.md +1 -1
- package/skills/insight-frida/SKILL.md +1 -1
- package/skills/insight-ghidra/SKILL.md +8 -1
- package/skills/insight-ghidra/references/persistent-client.mjs +30 -8
- package/skills/insight-ghidra/references/persistent.md +47 -7
- package/skills/insight-ghidra/references/recovery.md +50 -12
- package/skills/insight-ghidra/references/research.md +25 -22
- package/skills/insight-ghidra/references/setup.md +13 -3
- package/skills/insight-ilspy/SKILL.md +1 -1
- package/skills/insight-interop/SKILL.md +1 -1
- package/skills/insight-lldb/SKILL.md +1 -1
- package/skills/insight-llvm/SKILL.md +1 -1
- package/skills/insight-managed-heap/SKILL.md +1 -1
- package/skills/insight-managed-metadata/SKILL.md +1 -1
- package/skills/insight-mitmproxy/SKILL.md +1 -1
- package/skills/insight-overview/SKILL.md +1 -1
- package/skills/insight-procmon/SKILL.md +1 -1
- package/skills/insight-re/SKILL.md +1 -1
- package/skills/insight-re/references/persistent-client.mjs +30 -8
- package/skills/insight-re/references/persistent.md +47 -7
- package/skills/insight-re/references/recovery.md +50 -12
- package/skills/insight-sevenzip/SKILL.md +1 -1
- package/skills/insight-strace/SKILL.md +1 -1
- package/skills/insight-tshark/SKILL.md +1 -1
- package/skills/insight-windbg/SKILL.md +1 -1
|
@@ -10,12 +10,24 @@ export class InsightCommandError extends Error {
|
|
|
10
10
|
}
|
|
11
11
|
export class InsightTransportError extends Error {
|
|
12
12
|
dispatched;
|
|
13
|
-
|
|
13
|
+
termination;
|
|
14
|
+
constructor(message, dispatched, termination) {
|
|
14
15
|
super(message);
|
|
15
16
|
this.dispatched = dispatched;
|
|
17
|
+
this.termination = termination;
|
|
16
18
|
this.name = 'InsightTransportError';
|
|
17
19
|
}
|
|
18
20
|
}
|
|
21
|
+
const transportDiagnostics = [
|
|
22
|
+
['host_incompatible', 'Host build/protocol mismatch or closing.', 'Factory rejected the host build/protocol or it is closing.'],
|
|
23
|
+
['host_incompatible', 'Host build mismatch.', 'Factory rejected the host build.'],
|
|
24
|
+
['host_incompatible', 'Existing host build mismatch or closing.', 'Factory rejected the host build or it is closing.'],
|
|
25
|
+
['host_closing', 'Host is closing; no command was sent.', 'Factory reports that the host is closing.'],
|
|
26
|
+
['host_startup_timeout', 'CLI host startup timed out; no command was sent.', 'Factory host startup timed out.'],
|
|
27
|
+
['invalid_rpc_launch', 'The --json-rpc transport must be started without a CLI command.', 'Start the JSON-RPC transport without CLI command or profile flags.'],
|
|
28
|
+
['host_build_invalid', 'CLI host could not validate its build.', 'Factory could not validate the installed build.'],
|
|
29
|
+
['ipc_disconnected', 'IPC invocation failed; command outcome may be unknown. No replay was attempted.', 'Factory lost the IPC invocation; the command outcome may be unknown.']
|
|
30
|
+
];
|
|
19
31
|
/** A thin client of Factory's existing stream, with no reconnect or command replay. */
|
|
20
32
|
export async function connectInsight(options) {
|
|
21
33
|
const child = spawn(options.executable, [...(options.arguments ?? []), '--json-rpc'], { cwd: options.cwd, env: options.env, stdio: ['pipe', 'pipe', 'pipe'], shell: false });
|
|
@@ -23,15 +35,23 @@ export async function connectInsight(options) {
|
|
|
23
35
|
let buffer = '', bytes = 0, sequence = 0, accepting = true, failed = false, ended = false;
|
|
24
36
|
let closePromise, tail = Promise.resolve();
|
|
25
37
|
const pending = new Map();
|
|
26
|
-
//
|
|
27
|
-
|
|
38
|
+
// Classify fixed transport diagnostics through a bounded window; never expose raw stderr.
|
|
39
|
+
const diagnosticDecoder = new StringDecoder('utf8');
|
|
40
|
+
let diagnosticWindow = '', recognizedDiagnostic;
|
|
41
|
+
let termination;
|
|
42
|
+
child.stderr.on('data', (chunk) => {
|
|
43
|
+
const text = diagnosticWindow + diagnosticDecoder.write(chunk);
|
|
44
|
+
recognizedDiagnostic ??= transportDiagnostics.find(([, message]) => text.includes(message));
|
|
45
|
+
diagnosticWindow = text.slice(-512);
|
|
46
|
+
});
|
|
47
|
+
const transportError = (message, dispatched) => new InsightTransportError(message + (recognizedDiagnostic ? ' ' + recognizedDiagnostic[2] : '') + (termination ? ' (' + (termination.signal ? 'signal ' + termination.signal : 'exit ' + termination.exitCode) + ').' : ''), dispatched, termination);
|
|
28
48
|
const fail = (message) => {
|
|
29
49
|
if (failed)
|
|
30
50
|
return;
|
|
31
51
|
failed = true;
|
|
32
52
|
accepting = false;
|
|
33
53
|
for (const p of pending.values())
|
|
34
|
-
p.reject(
|
|
54
|
+
p.reject(transportError(message, true));
|
|
35
55
|
pending.clear();
|
|
36
56
|
child.stdin.destroy();
|
|
37
57
|
child.stdout.destroy();
|
|
@@ -43,12 +63,14 @@ export async function connectInsight(options) {
|
|
|
43
63
|
const exited = new Promise((resolve, reject) => {
|
|
44
64
|
child.once('close', (code, signal) => {
|
|
45
65
|
ended = true;
|
|
66
|
+
diagnosticWindow = '';
|
|
67
|
+
termination = Object.freeze({ exitCode: code, signal, ...(recognizedDiagnostic ? { reason: recognizedDiagnostic[0] } : {}) });
|
|
46
68
|
if (code !== 0 || signal || pending.size || buffer.trim()) {
|
|
47
69
|
fail('Persistent CLI closed without a complete acknowledged response.');
|
|
48
|
-
reject(
|
|
70
|
+
reject(transportError('Persistent CLI transport ended unexpectedly.', false));
|
|
49
71
|
}
|
|
50
72
|
else if (failed)
|
|
51
|
-
reject(
|
|
73
|
+
reject(transportError('Persistent CLI transport failed.', false));
|
|
52
74
|
else
|
|
53
75
|
resolve();
|
|
54
76
|
});
|
|
@@ -97,11 +119,11 @@ export async function connectInsight(options) {
|
|
|
97
119
|
if (!Array.isArray(argv) || argv.length > 512 || argv.some(x => typeof x !== 'string' || x.includes('\0')) || Buffer.byteLength(JSON.stringify(argv)) > 1024 ** 2)
|
|
98
120
|
return Promise.reject(new TypeError('argv must be a bounded array of strings without NUL.'));
|
|
99
121
|
if (!accepting || failed || ended)
|
|
100
|
-
return Promise.reject(
|
|
122
|
+
return Promise.reject(transportError('Persistent CLI connection is closed.', false));
|
|
101
123
|
const args = [...argv];
|
|
102
124
|
const request = tail.then(() => {
|
|
103
125
|
if (failed || ended)
|
|
104
|
-
throw
|
|
126
|
+
throw transportError('Persistent CLI connection was lost before dispatch.', false);
|
|
105
127
|
const id = ++sequence;
|
|
106
128
|
return new Promise((resolve, reject) => {
|
|
107
129
|
pending.set(id, { resolve, reject });
|
|
@@ -10,8 +10,15 @@ The package exports a small stdio client, independent of the facade's eager impo
|
|
|
10
10
|
import {connectInsight, InsightCommandError, InsightTransportError}
|
|
11
11
|
from '@eyeauras/insight-cli/persistent';
|
|
12
12
|
|
|
13
|
-
const cli = await connectInsight({
|
|
13
|
+
const cli = await connectInsight({
|
|
14
|
+
executable: nodeExecutable,
|
|
15
|
+
arguments: [installedBin],
|
|
16
|
+
cwd: projectDirectory
|
|
17
|
+
});
|
|
18
|
+
// If reporting READY, first await a discovery RPC on this connection.
|
|
19
|
+
await cli.execute(['--profile', profile, 'tools', 'list']);
|
|
14
20
|
const result = await cli.execute([
|
|
21
|
+
'--profile', profile,
|
|
15
22
|
'ghidra', 'functions', 'inspect', '--session', session, '--target', target,
|
|
16
23
|
'--function', 'main', '--fields', 'entry_point', '--include-call-context', 'false'
|
|
17
24
|
]);
|
|
@@ -22,9 +29,35 @@ When package-name resolution is unavailable in the agent host, dynamically impor
|
|
|
22
29
|
[`persistent-client.mjs`](persistent-client.mjs) beside this reference by its absolute file URL.
|
|
23
30
|
It is generated from the same canonical package module. In a persistent REPL retain `cli` as a
|
|
24
31
|
binding across tool invocations. A new Node process per query does not retain this connection.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
Here `installedBin` is the absolute installed `dist/src/bin.js` path and `nodeExecutable` is
|
|
33
|
+
the Node executable used for this shared installation. Factory includes the Node version,
|
|
34
|
+
platform and architecture in its build identity. Use the same Node version and installed
|
|
35
|
+
artifact as the existing owner; an agent host's `process.execPath` or `PATH` can select a
|
|
36
|
+
different Node installation. `ipc-server status` reports the owner's build; a matching CLI
|
|
37
|
+
package version alone does not establish compatibility. A shared owner does not need to be
|
|
38
|
+
stopped merely to connect a client through the matching Node runtime. An idle owner may
|
|
39
|
+
exit and a later caller may start a new owner with a different Node installation: a previously
|
|
40
|
+
matching executable is not a permanent profile binding. Use one agreed Node runtime across
|
|
41
|
+
the shared clients, and inspect the current owner again after a compatibility failure.
|
|
42
|
+
|
|
43
|
+
The helper appends `--json-rpc` to its launch arguments. Factory requires that transport
|
|
44
|
+
flag to be the entire CLI invocation: `arguments` contains only the installed bin and any
|
|
45
|
+
Node runtime flags, with Node flags before the bin. Put `--profile <name>` in **every**
|
|
46
|
+
`execute(argv)` call as shown above. Adding profile flags to the frontend launch exits with
|
|
47
|
+
usage error before any request is dispatched. `env` optionally supplies the child environment.
|
|
48
|
+
There is no shell or separate profile/config.
|
|
49
|
+
|
|
50
|
+
A consumer that prints `READY` should first await an acknowledged RPC on that same connection,
|
|
51
|
+
as in the metadata call above. `connectInsight()` alone warrants a `SPAWNED` label. Discovery
|
|
52
|
+
confirms that the frontend reached Factory and returned a result; it does not start Ghidra or
|
|
53
|
+
prove native context readiness. Handle its failure before reporting readiness, preserve
|
|
54
|
+
`name`, `message`, `dispatched` and `termination` in the diagnostic receipt, and do not resend
|
|
55
|
+
research calls automatically. A later transport failure still requires ordinary outcome checks.
|
|
56
|
+
|
|
57
|
+
The helper code comes from the module actually imported by the consumer. Merging a newer
|
|
58
|
+
client into source does not update an older installed package or a long-lived imported module.
|
|
59
|
+
Check the installed version and loaded module when new diagnostic fields are absent; keep
|
|
60
|
+
original failure receipts rather than treating a new connection as recovery evidence.
|
|
28
61
|
|
|
29
62
|
`execute(argv)` returns the CLI result unchanged, without a JSON-RPC envelope. Calls are queued
|
|
30
63
|
in admission order. Native work can be long: await the original promise through the agent host's
|
|
@@ -33,6 +66,12 @@ reconnect/retry. Factory permissions, command validation, IDs and native budgets
|
|
|
33
66
|
|
|
34
67
|
* `InsightCommandError.rpc` preserves the JSON-RPC error code, message and data, including typed
|
|
35
68
|
CLI error results. A command failure leaves a healthy connection usable for the next command.
|
|
69
|
+
* `connectInsight()` confirms that the frontend process spawned; it does not perform a
|
|
70
|
+
readiness command or promise compatibility with the current Factory owner.
|
|
71
|
+
* `InsightTransportError.termination`, when the frontend has exited, reports its `exitCode`,
|
|
72
|
+
`signal`, and a recognized `reason` category when available. The error message
|
|
73
|
+
includes the fixed transport explanation and exit information, without raw stderr. These
|
|
74
|
+
observations diagnose transport failure; they do not establish a command's outcome.
|
|
36
75
|
* `InsightTransportError.dispatched === true` means the request was handed to the stream and its
|
|
37
76
|
acknowledgment is unavailable; it does not prove execution. Changing commands require their
|
|
38
77
|
existing request-ID/status recovery. The client never resends them.
|
|
@@ -40,9 +79,10 @@ reconnect/retry. Factory permissions, command validation, IDs and native budgets
|
|
|
40
79
|
after a transport failure. Reconnection is an explicit new connection, not an implicit replay.
|
|
41
80
|
|
|
42
81
|
The client bounds each response line to four MiB, validates IDs and envelopes, and fails the
|
|
43
|
-
connection on malformed, uncorrelated or oversized replies. It
|
|
44
|
-
|
|
45
|
-
and
|
|
82
|
+
connection on malformed, uncorrelated or oversized replies. It classifies recognized Factory
|
|
83
|
+
transport errors from a small rolling stderr window, clears that window on process exit, and
|
|
84
|
+
exposes only fixed explanations and exit metadata. Read command-level diagnostics from their
|
|
85
|
+
typed results and the existing profile diagnostic locations.
|
|
46
86
|
|
|
47
87
|
Finish owned Ghidra contexts with the normal scoped commands, following the project's shared
|
|
48
88
|
server policy. Then `await cli.close()` drains already admitted requests and ends this stdio
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
# Continue saved work
|
|
2
2
|
|
|
3
3
|
Retain the session/target returned by initial open. Continue the tuple through
|
|
4
|
-
`insight-cli ghidra open --session <id> --target <id> --json`.
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
`insight-cli ghidra open --session <id> --target <id> --json`. The native working project, checkout ID/base
|
|
5
|
+
and native change sets persist independently of the worker. Reopening uses that exact project
|
|
6
|
+
without importing a snapshot or silently receiving a newer shared version. Private workers
|
|
7
|
+
have no publisher credentials; service-only Update/check-in temporarily owns the stopped project.
|
|
8
|
+
Legacy detached contexts require explicit migration and remain retained.
|
|
9
|
+
|
|
10
|
+
If native `changes discard` loses its response, retry its original request ID or continue
|
|
11
|
+
the same session/target. Recovery requires a completed native discard journal and matching
|
|
12
|
+
new checkout identity/base and saved buffers, followed by independent server readback.
|
|
13
|
+
It does not repeat discard. An incomplete journal or mismatched checkout stays unknown;
|
|
14
|
+
preserve the project and any `.keep` file.
|
|
7
15
|
|
|
8
16
|
First-import recovery uses the same scoped `ghidra open` or the original request ID/input.
|
|
9
17
|
Import/analysis writes a private snapshot and completion receipt before any initial publication.
|
|
@@ -39,12 +47,12 @@ independent readback. The old project, intent and original session/target remain
|
|
|
39
47
|
## Unresponsive headless backend
|
|
40
48
|
|
|
41
49
|
Continue the same session/target with ordinary `ghidra open` or a research read. When the
|
|
42
|
-
backend fails its identity preflight, the facade verifies the
|
|
43
|
-
and independently authenticates the exact worker before retiring it and
|
|
50
|
+
backend fails its identity preflight, the facade verifies the saved-view receipt
|
|
51
|
+
and independently authenticates the exact worker before retiring it and reopening the same native project.
|
|
44
52
|
This automatic retirement is limited to headless contexts without uncertain mutations, active
|
|
45
53
|
publication or a connected debugger. A failed health preflight is never permission to repeat a
|
|
46
54
|
script, save or publication. Journals, original projects and acknowledged pending edits remain.
|
|
47
|
-
Lifecycle diagnostics record `backend_unresponsive` followed by
|
|
55
|
+
Lifecycle diagnostics record `backend_unresponsive` followed by saved-project reopen.
|
|
48
56
|
|
|
49
57
|
On macOS ARM64 the packaged read-only kernel helper checks the same-user process, executable,
|
|
50
58
|
private root and digest of its unique context token without entering the JVM. It emits no token,
|
|
@@ -102,17 +110,17 @@ for adversarial same-JVM Java, and existing unknown script attempts are not recl
|
|
|
102
110
|
their exception strings or an unchanged program snapshot. File/Python scripts retain their
|
|
103
111
|
existing conservative recovery semantics.
|
|
104
112
|
|
|
105
|
-
An unknown or partial effect retains its request intent,
|
|
113
|
+
An unknown or partial effect retains its request intent, receipts and native project. Open the
|
|
106
114
|
same tuple to reconcile supported outcomes. A committed merge is verified against its recorded
|
|
107
115
|
server version and complete saved buffers through independent read authority; it is never
|
|
108
116
|
checked in again merely because its response was lost. Until verification succeeds, publication
|
|
109
117
|
for this shared target is blocked across sessions. Saved private work remains retained.
|
|
110
118
|
|
|
111
119
|
Scalar reconciliation observes and saves an already present effect; it does not execute the
|
|
112
|
-
setter again. Supported structural/function edits retain a
|
|
113
|
-
response
|
|
114
|
-
|
|
115
|
-
|
|
120
|
+
setter again. Supported structural/function edits can retain a saved-view receipt after an incomplete
|
|
121
|
+
response. For native contexts inspection must still match that receipt on the original saved
|
|
122
|
+
project; the receipt cannot recreate an older DB. Continuation adopts only fully verified effects
|
|
123
|
+
without replay. Unproved native work stays blocked and retained. An unproved program/script/external outcome remains unresolved. Preserve the profile
|
|
116
124
|
storage and credential store. Do not delete another session's project, stop a process by guessed
|
|
117
125
|
PID/port, or blindly repeat a script/external action to turn uncertainty into success.
|
|
118
126
|
|
|
@@ -125,7 +133,17 @@ as disconnected and retains saved program work. It does not recreate the old cur
|
|
|
125
133
|
a previous prompt policy. Other unproved live UI effects remain retained until their outcome is
|
|
126
134
|
established or the original process is known to have ended.
|
|
127
135
|
|
|
128
|
-
##
|
|
136
|
+
## Native unknown attempts and legacy abandonment
|
|
137
|
+
|
|
138
|
+
For native contexts the snapshot-based `ghidra abandon` rollback is unsupported: replacing the
|
|
139
|
+
DB from a detached snapshot would lose native ancestry and could discard acknowledged private
|
|
140
|
+
work. Preserve the original project/journal and reconcile provable effects. Do not use discard,
|
|
141
|
+
GC, another request ID or a new server checkout as evidence that an unknown script did nothing.
|
|
142
|
+
|
|
143
|
+
The historical snapshot-based abandonment contract below applies only to its retained legacy
|
|
144
|
+
fixtures, not to native contexts admitted by the primary CLI.
|
|
145
|
+
|
|
146
|
+
### Historical detached abandonment
|
|
129
147
|
|
|
130
148
|
A post-mutation save timeout does not repeat the script or issue another save in the
|
|
131
149
|
error handler. Status exposes the original request identity and retained phase/budget.
|
|
@@ -150,3 +168,23 @@ result. Earlier saved private edits remain pending. The original changing reques
|
|
|
150
168
|
execute again. Abandoning never undoes external effects or establishes what an arbitrary
|
|
151
169
|
script did; the acknowledgement explicitly accepts that uncertainty. Publication recovery,
|
|
152
170
|
initial import, UI and debugger attempts use their own protocols and cannot use this command.
|
|
171
|
+
|
|
172
|
+
## Explicit legacy migration
|
|
173
|
+
|
|
174
|
+
Legacy models require `ghidra migrate --target <target> --dry-run`, then the same
|
|
175
|
+
command without `--dry-run` (Destructive permission). Use `--all` for the profile.
|
|
176
|
+
Close selected workers first. Repeating migration resumes its retained journal; it never
|
|
177
|
+
retries an uncertain native check-in. Independent exact-version readback precedes checkout
|
|
178
|
+
release. Existing native models are unchanged. Detached snapshots with unproved native
|
|
179
|
+
ancestry/change sets are explicitly reported and retained, including private work.
|
|
180
|
+
A verified no-work failed open can be recovered without abandoning an arbitrary effect;
|
|
181
|
+
continue its original session/target with an ordinary new open request afterwards.
|
|
182
|
+
|
|
183
|
+
## Reclaim redundant storage
|
|
184
|
+
|
|
185
|
+
`ghidra gc --dry-run` reports reclaimable and retained copies by category. `ghidra gc`
|
|
186
|
+
(Destructive permission) removes unreferenced snapshots, duplicate exports, stopped detached
|
|
187
|
+
projects and caches, and releases checkouts Ghidra itself verifies as unchanged. Close workers
|
|
188
|
+
first; it never stops one. Pending, conflicted, uncertain and unverified work is retained with
|
|
189
|
+
a reason. Repeat the command after an interruption. Collection is not recovery: resolve an
|
|
190
|
+
unknown operation first.
|
|
@@ -34,7 +34,17 @@ artifact provenance. Its pinned functionality catalog is from source
|
|
|
34
34
|
`f4a9272e911466ed774c8cf73bc1adf1daef6009d895fda57aa0b28522fcdf32`.
|
|
35
35
|
`mcpJar` optionally selects another copy of those exact verified bytes. Runtime startup needs no
|
|
36
36
|
bridge/Factory source checkout or Python MCP bridge. Packaged native helper sources compile
|
|
37
|
-
against the installed Ghidra/JDK.
|
|
37
|
+
against the installed Ghidra/JDK. Native merge additionally requires that installation's
|
|
38
|
+
unaltered Ghidra 12.1.2 source archives. Six upstream sources are hash-pinned before compiling
|
|
39
|
+
owned headless adapter classes; installed Ghidra JARs are not rewritten. License/provenance
|
|
40
|
+
is retained in `references/native/NATIVE-MERGE-NOTICE.txt` and the generated helper cache.
|
|
41
|
+
|
|
42
|
+
Fresh models use native checkouts/Update/check-in. Existing detached contexts and unmarked
|
|
43
|
+
legacy models are rejected for explicit migration; opening them does not auto-convert or clean
|
|
44
|
+
research. Do not mix an older snapshot writer with a native item. Use explicit `ghidra migrate --target <target> --dry-run`, then the same command
|
|
45
|
+
without `--dry-run` with Destructive permission; `--all` selects the whole profile.
|
|
46
|
+
Repeat execution to resume its journal. Detached private work without provable native
|
|
47
|
+
ancestry is explicitly refused and retained. See [migration](recovery.md#explicit-legacy-migration).
|
|
38
48
|
|
|
39
49
|
Omitting `server` enables owned local startup. The facade creates profile storage, a private
|
|
40
50
|
repository and distinct read-only/publisher accounts with random credentials in Factory's secret
|
|
@@ -62,7 +72,7 @@ Changing those runtime inputs requires stopping the old owner before continuing
|
|
|
62
72
|
|
|
63
73
|
Native acceptance separates macOS GUI/LLDB workflows from selected headless Windows/Linux
|
|
64
74
|
SDK, Version Tracking and FID/BSim workflows. Native Windows/Linux debugger/GUI acceptance
|
|
65
|
-
remains deferred.
|
|
75
|
+
remains deferred. CI stays offline and refuses native proofs.
|
|
66
76
|
|
|
67
77
|
On macOS 15+ ARM64, `ghidra install` delivers an owned LLDB/Python debugger backend;
|
|
68
78
|
OS debugger authorization remains required. Other host profiles need their supported debugger. Its
|
|
@@ -81,7 +91,7 @@ defaults to 120 (1–3600 seconds). Configure them with `ghidra budgets set
|
|
|
81
91
|
This uses Factory ProfileStore without invalidating research or stopping native contexts.
|
|
82
92
|
Active requests retain their original budget. Generic `profile set` remains guarded for
|
|
83
93
|
profiles containing research; initial profile creation also accepts these fields. Both are execution policy, independent
|
|
84
|
-
of immutable target/load identity.
|
|
94
|
+
of immutable target/load identity. Native save, Update/check-in, exact-version verification and explicit packed export use the save budget;
|
|
85
95
|
discovery and ordinary HTTP queries keep their 30-second budget. Each native request has
|
|
86
96
|
its own budget, not a total command deadline. Cancellation remains independent.
|
|
87
97
|
|
|
@@ -3,7 +3,7 @@ name: insight-die
|
|
|
3
3
|
description: Classify unknown executable or container inputs by format, architecture and compiler/runtime/packer signatures with Detect It Easy before choosing managed or native analysis. Use insight-cli die for static triage and preserve scan uncertainty.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Insight Detect It Easy 0.
|
|
6
|
+
# Insight Detect It Easy 0.6.1
|
|
7
7
|
|
|
8
8
|
If local help/status reports AppData or IPC access denied, retry that **read-only probe**
|
|
9
9
|
with the agent host's normal permission escalation, then use that route for later authorized
|
|
@@ -3,7 +3,7 @@ name: insight-dnspy
|
|
|
3
3
|
description: Debug a managed Windows EXE at an IL breakpoint and read primitive arguments, or change one expected IL Int32 constant in a new assembly copy through insight-cli dnspy. Use when C# decompilation needs observed execution or a controlled binary edit.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Insight dnSpyEx 0.
|
|
6
|
+
# Insight dnSpyEx 0.6.1
|
|
7
7
|
|
|
8
8
|
If local help/status reports AppData or IPC access denied, retry that **read-only probe**
|
|
9
9
|
with the agent host's normal permission escalation, then use that route for later authorized
|
|
@@ -3,7 +3,7 @@ name: insight-dotnet-dump
|
|
|
3
3
|
description: Capture a managed heap dump or inspect compatible .NET dumps with SOS to recover waiting stacks, objects, fields and retention evidence.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Insight .NET Dump 0.
|
|
6
|
+
# Insight .NET Dump 0.6.1
|
|
7
7
|
|
|
8
8
|
If local help/status reports AppData or IPC access denied, retry that **read-only probe**
|
|
9
9
|
with the agent host's normal permission escalation, then use that route for later authorized
|
|
@@ -3,7 +3,7 @@ name: insight-dotnet-stack
|
|
|
3
3
|
description: Inspect live managed thread stacks to identify active or waiting work in an explicitly selected .NET process without taking a dump.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Insight .NET Stack 0.
|
|
6
|
+
# Insight .NET Stack 0.6.1
|
|
7
7
|
|
|
8
8
|
If local help/status reports AppData or IPC access denied, retry that **read-only probe**
|
|
9
9
|
with the agent host's normal permission escalation, then use that route for later authorized
|
|
@@ -3,7 +3,7 @@ name: insight-dotnet-trace
|
|
|
3
3
|
description: Collect and inspect bounded .NET EventPipe traces to identify sampled thread work, waits or runtime activity; distinguish wall-clock samples from CPU consumption.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Insight .NET Trace 0.
|
|
6
|
+
# Insight .NET Trace 0.6.1
|
|
7
7
|
|
|
8
8
|
If local help/status reports AppData or IPC access denied, retry that **read-only probe**
|
|
9
9
|
with the agent host's normal permission escalation, then use that route for later authorized
|
|
@@ -3,7 +3,7 @@ name: insight-frida
|
|
|
3
3
|
description: Observe native call arguments/results or inspect runtime modules and exports in an explicitly selected authorized process with bounded Frida scripts. Use insight-cli frida to corroborate static findings with actual execution on macOS ARM64.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Insight Frida 0.
|
|
6
|
+
# Insight Frida 0.6.1
|
|
7
7
|
|
|
8
8
|
If local help/status reports AppData or IPC access denied, retry that **read-only probe**
|
|
9
9
|
with the agent host's normal permission escalation, then use that route for later authorized
|
|
@@ -3,7 +3,7 @@ name: insight-ghidra
|
|
|
3
3
|
description: Inspect or edit native binaries with Ghidra through insight-cli; use isolated contexts, multi-agent merge/refresh, server, GUI or debugger workflows. Choose this for static native behavior and references, not C# recovery from managed IL.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Insight Ghidra 0.
|
|
6
|
+
# Insight Ghidra 0.6.1
|
|
7
7
|
|
|
8
8
|
If local help/status reports AppData or IPC access denied, retry that **read-only probe**
|
|
9
9
|
with the agent host's normal permission escalation, then use that route for later authorized
|
|
@@ -17,6 +17,13 @@ session/cell ID, await that same execution with the host's wait/poll facility un
|
|
|
17
17
|
status and read its stdout/stderr. An empty first chunk is not a lost CLI response. Do not
|
|
18
18
|
start another open or repeat a CPU mutation while the original command is still running.
|
|
19
19
|
|
|
20
|
+
Each session/target owns one saved native checkout. Reopen the same selectors to keep its
|
|
21
|
+
project, checkout ID/base and native changes. `refresh` runs Ghidra Update; `merge` runs native
|
|
22
|
+
Update/check-in through the service and drops the project after independent verification.
|
|
23
|
+
Private workers have no repository password. Ordinary save does not export another `.gzf`.
|
|
24
|
+
Conflicts/unknown results retain the copy. Legacy detached contexts need explicit migration;
|
|
25
|
+
Close unchanged work to release its checkout; `ghidra gc --dry-run` reports redundant copies. See [research](references/research.md) and [recovery](references/recovery.md).
|
|
26
|
+
|
|
20
27
|
For research loops, use the packaged [persistent client](references/persistent.md) and keep
|
|
21
28
|
one connection across queries. It uses the existing CLI transport and preserves typed errors;
|
|
22
29
|
lost mutation replies still require request/status recovery.
|
|
@@ -10,12 +10,24 @@ export class InsightCommandError extends Error {
|
|
|
10
10
|
}
|
|
11
11
|
export class InsightTransportError extends Error {
|
|
12
12
|
dispatched;
|
|
13
|
-
|
|
13
|
+
termination;
|
|
14
|
+
constructor(message, dispatched, termination) {
|
|
14
15
|
super(message);
|
|
15
16
|
this.dispatched = dispatched;
|
|
17
|
+
this.termination = termination;
|
|
16
18
|
this.name = 'InsightTransportError';
|
|
17
19
|
}
|
|
18
20
|
}
|
|
21
|
+
const transportDiagnostics = [
|
|
22
|
+
['host_incompatible', 'Host build/protocol mismatch or closing.', 'Factory rejected the host build/protocol or it is closing.'],
|
|
23
|
+
['host_incompatible', 'Host build mismatch.', 'Factory rejected the host build.'],
|
|
24
|
+
['host_incompatible', 'Existing host build mismatch or closing.', 'Factory rejected the host build or it is closing.'],
|
|
25
|
+
['host_closing', 'Host is closing; no command was sent.', 'Factory reports that the host is closing.'],
|
|
26
|
+
['host_startup_timeout', 'CLI host startup timed out; no command was sent.', 'Factory host startup timed out.'],
|
|
27
|
+
['invalid_rpc_launch', 'The --json-rpc transport must be started without a CLI command.', 'Start the JSON-RPC transport without CLI command or profile flags.'],
|
|
28
|
+
['host_build_invalid', 'CLI host could not validate its build.', 'Factory could not validate the installed build.'],
|
|
29
|
+
['ipc_disconnected', 'IPC invocation failed; command outcome may be unknown. No replay was attempted.', 'Factory lost the IPC invocation; the command outcome may be unknown.']
|
|
30
|
+
];
|
|
19
31
|
/** A thin client of Factory's existing stream, with no reconnect or command replay. */
|
|
20
32
|
export async function connectInsight(options) {
|
|
21
33
|
const child = spawn(options.executable, [...(options.arguments ?? []), '--json-rpc'], { cwd: options.cwd, env: options.env, stdio: ['pipe', 'pipe', 'pipe'], shell: false });
|
|
@@ -23,15 +35,23 @@ export async function connectInsight(options) {
|
|
|
23
35
|
let buffer = '', bytes = 0, sequence = 0, accepting = true, failed = false, ended = false;
|
|
24
36
|
let closePromise, tail = Promise.resolve();
|
|
25
37
|
const pending = new Map();
|
|
26
|
-
//
|
|
27
|
-
|
|
38
|
+
// Classify fixed transport diagnostics through a bounded window; never expose raw stderr.
|
|
39
|
+
const diagnosticDecoder = new StringDecoder('utf8');
|
|
40
|
+
let diagnosticWindow = '', recognizedDiagnostic;
|
|
41
|
+
let termination;
|
|
42
|
+
child.stderr.on('data', (chunk) => {
|
|
43
|
+
const text = diagnosticWindow + diagnosticDecoder.write(chunk);
|
|
44
|
+
recognizedDiagnostic ??= transportDiagnostics.find(([, message]) => text.includes(message));
|
|
45
|
+
diagnosticWindow = text.slice(-512);
|
|
46
|
+
});
|
|
47
|
+
const transportError = (message, dispatched) => new InsightTransportError(message + (recognizedDiagnostic ? ' ' + recognizedDiagnostic[2] : '') + (termination ? ' (' + (termination.signal ? 'signal ' + termination.signal : 'exit ' + termination.exitCode) + ').' : ''), dispatched, termination);
|
|
28
48
|
const fail = (message) => {
|
|
29
49
|
if (failed)
|
|
30
50
|
return;
|
|
31
51
|
failed = true;
|
|
32
52
|
accepting = false;
|
|
33
53
|
for (const p of pending.values())
|
|
34
|
-
p.reject(
|
|
54
|
+
p.reject(transportError(message, true));
|
|
35
55
|
pending.clear();
|
|
36
56
|
child.stdin.destroy();
|
|
37
57
|
child.stdout.destroy();
|
|
@@ -43,12 +63,14 @@ export async function connectInsight(options) {
|
|
|
43
63
|
const exited = new Promise((resolve, reject) => {
|
|
44
64
|
child.once('close', (code, signal) => {
|
|
45
65
|
ended = true;
|
|
66
|
+
diagnosticWindow = '';
|
|
67
|
+
termination = Object.freeze({ exitCode: code, signal, ...(recognizedDiagnostic ? { reason: recognizedDiagnostic[0] } : {}) });
|
|
46
68
|
if (code !== 0 || signal || pending.size || buffer.trim()) {
|
|
47
69
|
fail('Persistent CLI closed without a complete acknowledged response.');
|
|
48
|
-
reject(
|
|
70
|
+
reject(transportError('Persistent CLI transport ended unexpectedly.', false));
|
|
49
71
|
}
|
|
50
72
|
else if (failed)
|
|
51
|
-
reject(
|
|
73
|
+
reject(transportError('Persistent CLI transport failed.', false));
|
|
52
74
|
else
|
|
53
75
|
resolve();
|
|
54
76
|
});
|
|
@@ -97,11 +119,11 @@ export async function connectInsight(options) {
|
|
|
97
119
|
if (!Array.isArray(argv) || argv.length > 512 || argv.some(x => typeof x !== 'string' || x.includes('\0')) || Buffer.byteLength(JSON.stringify(argv)) > 1024 ** 2)
|
|
98
120
|
return Promise.reject(new TypeError('argv must be a bounded array of strings without NUL.'));
|
|
99
121
|
if (!accepting || failed || ended)
|
|
100
|
-
return Promise.reject(
|
|
122
|
+
return Promise.reject(transportError('Persistent CLI connection is closed.', false));
|
|
101
123
|
const args = [...argv];
|
|
102
124
|
const request = tail.then(() => {
|
|
103
125
|
if (failed || ended)
|
|
104
|
-
throw
|
|
126
|
+
throw transportError('Persistent CLI connection was lost before dispatch.', false);
|
|
105
127
|
const id = ++sequence;
|
|
106
128
|
return new Promise((resolve, reject) => {
|
|
107
129
|
pending.set(id, { resolve, reject });
|
|
@@ -10,8 +10,15 @@ The package exports a small stdio client, independent of the facade's eager impo
|
|
|
10
10
|
import {connectInsight, InsightCommandError, InsightTransportError}
|
|
11
11
|
from '@eyeauras/insight-cli/persistent';
|
|
12
12
|
|
|
13
|
-
const cli = await connectInsight({
|
|
13
|
+
const cli = await connectInsight({
|
|
14
|
+
executable: nodeExecutable,
|
|
15
|
+
arguments: [installedBin],
|
|
16
|
+
cwd: projectDirectory
|
|
17
|
+
});
|
|
18
|
+
// If reporting READY, first await a discovery RPC on this connection.
|
|
19
|
+
await cli.execute(['--profile', profile, 'tools', 'list']);
|
|
14
20
|
const result = await cli.execute([
|
|
21
|
+
'--profile', profile,
|
|
15
22
|
'ghidra', 'functions', 'inspect', '--session', session, '--target', target,
|
|
16
23
|
'--function', 'main', '--fields', 'entry_point', '--include-call-context', 'false'
|
|
17
24
|
]);
|
|
@@ -22,9 +29,35 @@ When package-name resolution is unavailable in the agent host, dynamically impor
|
|
|
22
29
|
[`persistent-client.mjs`](persistent-client.mjs) beside this reference by its absolute file URL.
|
|
23
30
|
It is generated from the same canonical package module. In a persistent REPL retain `cli` as a
|
|
24
31
|
binding across tool invocations. A new Node process per query does not retain this connection.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
Here `installedBin` is the absolute installed `dist/src/bin.js` path and `nodeExecutable` is
|
|
33
|
+
the Node executable used for this shared installation. Factory includes the Node version,
|
|
34
|
+
platform and architecture in its build identity. Use the same Node version and installed
|
|
35
|
+
artifact as the existing owner; an agent host's `process.execPath` or `PATH` can select a
|
|
36
|
+
different Node installation. `ipc-server status` reports the owner's build; a matching CLI
|
|
37
|
+
package version alone does not establish compatibility. A shared owner does not need to be
|
|
38
|
+
stopped merely to connect a client through the matching Node runtime. An idle owner may
|
|
39
|
+
exit and a later caller may start a new owner with a different Node installation: a previously
|
|
40
|
+
matching executable is not a permanent profile binding. Use one agreed Node runtime across
|
|
41
|
+
the shared clients, and inspect the current owner again after a compatibility failure.
|
|
42
|
+
|
|
43
|
+
The helper appends `--json-rpc` to its launch arguments. Factory requires that transport
|
|
44
|
+
flag to be the entire CLI invocation: `arguments` contains only the installed bin and any
|
|
45
|
+
Node runtime flags, with Node flags before the bin. Put `--profile <name>` in **every**
|
|
46
|
+
`execute(argv)` call as shown above. Adding profile flags to the frontend launch exits with
|
|
47
|
+
usage error before any request is dispatched. `env` optionally supplies the child environment.
|
|
48
|
+
There is no shell or separate profile/config.
|
|
49
|
+
|
|
50
|
+
A consumer that prints `READY` should first await an acknowledged RPC on that same connection,
|
|
51
|
+
as in the metadata call above. `connectInsight()` alone warrants a `SPAWNED` label. Discovery
|
|
52
|
+
confirms that the frontend reached Factory and returned a result; it does not start Ghidra or
|
|
53
|
+
prove native context readiness. Handle its failure before reporting readiness, preserve
|
|
54
|
+
`name`, `message`, `dispatched` and `termination` in the diagnostic receipt, and do not resend
|
|
55
|
+
research calls automatically. A later transport failure still requires ordinary outcome checks.
|
|
56
|
+
|
|
57
|
+
The helper code comes from the module actually imported by the consumer. Merging a newer
|
|
58
|
+
client into source does not update an older installed package or a long-lived imported module.
|
|
59
|
+
Check the installed version and loaded module when new diagnostic fields are absent; keep
|
|
60
|
+
original failure receipts rather than treating a new connection as recovery evidence.
|
|
28
61
|
|
|
29
62
|
`execute(argv)` returns the CLI result unchanged, without a JSON-RPC envelope. Calls are queued
|
|
30
63
|
in admission order. Native work can be long: await the original promise through the agent host's
|
|
@@ -33,6 +66,12 @@ reconnect/retry. Factory permissions, command validation, IDs and native budgets
|
|
|
33
66
|
|
|
34
67
|
* `InsightCommandError.rpc` preserves the JSON-RPC error code, message and data, including typed
|
|
35
68
|
CLI error results. A command failure leaves a healthy connection usable for the next command.
|
|
69
|
+
* `connectInsight()` confirms that the frontend process spawned; it does not perform a
|
|
70
|
+
readiness command or promise compatibility with the current Factory owner.
|
|
71
|
+
* `InsightTransportError.termination`, when the frontend has exited, reports its `exitCode`,
|
|
72
|
+
`signal`, and a recognized `reason` category when available. The error message
|
|
73
|
+
includes the fixed transport explanation and exit information, without raw stderr. These
|
|
74
|
+
observations diagnose transport failure; they do not establish a command's outcome.
|
|
36
75
|
* `InsightTransportError.dispatched === true` means the request was handed to the stream and its
|
|
37
76
|
acknowledgment is unavailable; it does not prove execution. Changing commands require their
|
|
38
77
|
existing request-ID/status recovery. The client never resends them.
|
|
@@ -40,9 +79,10 @@ reconnect/retry. Factory permissions, command validation, IDs and native budgets
|
|
|
40
79
|
after a transport failure. Reconnection is an explicit new connection, not an implicit replay.
|
|
41
80
|
|
|
42
81
|
The client bounds each response line to four MiB, validates IDs and envelopes, and fails the
|
|
43
|
-
connection on malformed, uncorrelated or oversized replies. It
|
|
44
|
-
|
|
45
|
-
and
|
|
82
|
+
connection on malformed, uncorrelated or oversized replies. It classifies recognized Factory
|
|
83
|
+
transport errors from a small rolling stderr window, clears that window on process exit, and
|
|
84
|
+
exposes only fixed explanations and exit metadata. Read command-level diagnostics from their
|
|
85
|
+
typed results and the existing profile diagnostic locations.
|
|
46
86
|
|
|
47
87
|
Finish owned Ghidra contexts with the normal scoped commands, following the project's shared
|
|
48
88
|
server policy. Then `await cli.close()` drains already admitted requests and ends this stdio
|