@eyeauras/insight-cli 0.8.2 → 0.8.4
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 +53 -7
- package/SKILL.md +4 -8
- package/dist/src/administration.js +1 -1
- package/dist/src/archive.js +1 -1
- package/dist/src/artifacts.d.ts +2 -1
- package/dist/src/artifacts.js +6 -5
- package/dist/src/binary.js +1 -1
- package/dist/src/capture.js +3 -3
- package/dist/src/cli.js +17 -16
- package/dist/src/contexts.js +14 -17
- package/dist/src/cross.js +1 -1
- package/dist/src/debugger.js +1 -1
- package/dist/src/die.js +1 -1
- package/dist/src/dnspy.js +1 -1
- package/dist/src/dotnet-diagnostics.js +1 -1
- package/dist/src/ilspy.js +1 -1
- package/dist/src/lifecycle.js +5 -5
- package/dist/src/lldb.js +1 -1
- package/dist/src/llvm.js +1 -1
- package/dist/src/managed-heap.js +1 -1
- package/dist/src/managed-metadata.js +1 -1
- package/dist/src/mitmproxy.js +1 -1
- package/dist/src/model.d.ts +6 -1
- package/dist/src/model.js +9 -2
- package/dist/src/mutations.js +1 -1
- package/dist/src/projects.js +3 -3
- package/dist/src/prototype-cli.js +4 -4
- package/dist/src/research.js +1 -1
- package/dist/src/runtime-manager.d.ts +2 -2
- package/dist/src/runtime-manager.js +28 -4
- package/dist/src/sdk-files.js +3 -3
- package/dist/src/sdk.js +1 -1
- package/dist/src/server.d.ts +1 -0
- package/dist/src/server.js +17 -7
- package/dist/src/sevenzip.js +1 -1
- package/dist/src/strace.js +1 -1
- package/dist/src/sync-policy.js +4 -4
- package/dist/src/tool-runtime/identity.d.ts +7 -0
- package/dist/src/tool-runtime/identity.js +35 -0
- package/dist/src/tool-runtime/store.js +3 -0
- package/dist/src/tool-runtime/supervisor.d.ts +8 -0
- package/dist/src/tool-runtime/supervisor.js +58 -10
- package/dist/src/tshark.js +1 -1
- package/dist/src/ui.js +3 -3
- package/dist/src/version-tracking.js +2 -2
- package/dist/src/windbg.js +1 -1
- package/dist/src/work/backup.js +17 -5
- package/dist/src/work/commands.js +51 -14
- package/dist/src/work/model.d.ts +43 -1
- package/dist/src/work/model.js +128 -0
- package/dist/src/work/store.d.ts +34 -3
- package/dist/src/work/store.js +78 -21
- package/dist/src/work/timing.d.ts +9 -0
- package/dist/src/work/timing.js +10 -1
- package/package.json +1 -1
- package/references/agent-setup.md +2 -11
- package/references/debugger.md +1 -1
- package/references/managed-runtime.md +1 -2
- package/references/native/InsightNativeCheckout.java +24 -8
- package/references/recovery.md +2 -34
- package/references/research.md +5 -5
- package/references/setup.md +0 -4
- package/references/work-tracking.md +61 -3
- package/skill-bundle/insight-artifacts/SKILL.md +3 -7
- package/skill-bundle/insight-artifacts/references/recovery.md +2 -34
- package/skill-bundle/insight-binary/SKILL.md +3 -7
- package/skill-bundle/insight-capture/SKILL.md +3 -7
- package/skill-bundle/insight-cli/SKILL.md +4 -8
- package/skill-bundle/insight-cli/references/agent-setup.md +2 -11
- package/skill-bundle/insight-cli/references/managed-runtime.md +1 -2
- package/skill-bundle/insight-cli/references/recovery.md +2 -34
- package/skill-bundle/insight-cli/references/setup.md +0 -4
- package/skill-bundle/insight-die/SKILL.md +3 -7
- package/skill-bundle/insight-dnspy/SKILL.md +3 -7
- package/skill-bundle/insight-dotnet-dump/SKILL.md +3 -7
- package/skill-bundle/insight-dotnet-stack/SKILL.md +3 -7
- package/skill-bundle/insight-dotnet-trace/SKILL.md +3 -7
- package/skill-bundle/insight-frida/SKILL.md +3 -7
- package/skill-bundle/insight-ghidra/SKILL.md +13 -36
- package/skill-bundle/insight-ghidra/references/debugger.md +1 -1
- package/skill-bundle/insight-ghidra/references/managed-runtime.md +1 -2
- package/skill-bundle/insight-ghidra/references/recovery.md +2 -34
- package/skill-bundle/insight-ghidra/references/research.md +5 -5
- package/skill-bundle/insight-ghidra/references/setup.md +0 -4
- package/skill-bundle/insight-ilspy/SKILL.md +3 -7
- package/skill-bundle/insight-interop/SKILL.md +3 -7
- package/skill-bundle/insight-lldb/SKILL.md +3 -7
- package/skill-bundle/insight-llvm/SKILL.md +3 -7
- package/skill-bundle/insight-managed-heap/SKILL.md +3 -7
- package/skill-bundle/insight-managed-metadata/SKILL.md +3 -7
- package/skill-bundle/insight-mitmproxy/SKILL.md +3 -7
- package/skill-bundle/insight-overview/SKILL.md +3 -7
- package/skill-bundle/insight-procmon/SKILL.md +3 -7
- package/skill-bundle/insight-re/SKILL.md +4 -8
- package/skill-bundle/insight-re/references/recovery.md +2 -34
- package/skill-bundle/insight-re/references/work-tracking.md +61 -3
- package/skill-bundle/insight-sevenzip/SKILL.md +3 -7
- package/skill-bundle/insight-strace/SKILL.md +3 -7
- package/skill-bundle/insight-tshark/SKILL.md +3 -7
- package/skill-bundle/insight-windbg/SKILL.md +3 -7
- package/skill-bundle/manifest.json +1 -1
- package/skills/insight-artifacts/SKILL.md +3 -7
- package/skills/insight-artifacts/references/recovery.md +2 -34
- package/skills/insight-binary/SKILL.md +3 -7
- package/skills/insight-capture/SKILL.md +3 -7
- package/skills/insight-die/SKILL.md +3 -7
- package/skills/insight-dnspy/SKILL.md +3 -7
- package/skills/insight-dotnet-dump/SKILL.md +3 -7
- package/skills/insight-dotnet-stack/SKILL.md +3 -7
- package/skills/insight-dotnet-trace/SKILL.md +3 -7
- package/skills/insight-frida/SKILL.md +3 -7
- package/skills/insight-ghidra/SKILL.md +13 -36
- package/skills/insight-ghidra/references/debugger.md +1 -1
- package/skills/insight-ghidra/references/managed-runtime.md +1 -2
- package/skills/insight-ghidra/references/recovery.md +2 -34
- package/skills/insight-ghidra/references/research.md +5 -5
- package/skills/insight-ghidra/references/setup.md +0 -4
- package/skills/insight-ilspy/SKILL.md +3 -7
- package/skills/insight-interop/SKILL.md +3 -7
- package/skills/insight-lldb/SKILL.md +3 -7
- package/skills/insight-llvm/SKILL.md +3 -7
- package/skills/insight-managed-heap/SKILL.md +3 -7
- package/skills/insight-managed-metadata/SKILL.md +3 -7
- package/skills/insight-mitmproxy/SKILL.md +3 -7
- package/skills/insight-overview/SKILL.md +3 -7
- package/skills/insight-procmon/SKILL.md +3 -7
- package/skills/insight-re/SKILL.md +4 -8
- package/skills/insight-re/references/recovery.md +2 -34
- package/skills/insight-re/references/work-tracking.md +61 -3
- package/skills/insight-sevenzip/SKILL.md +3 -7
- package/skills/insight-strace/SKILL.md +3 -7
- package/skills/insight-tshark/SKILL.md +3 -7
- package/skills/insight-windbg/SKILL.md +3 -7
package/dist/src/model.js
CHANGED
|
@@ -17,10 +17,17 @@ export function text(value, max = 512) {
|
|
|
17
17
|
fail('invalid', 'Expected a bounded non-empty string.');
|
|
18
18
|
return value;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* A validated identifier. `option` names the command-line option it came from, so a refusal says which value was
|
|
22
|
+
* wrong and shows it: a caller's script that passes the wrong variable sees what it actually sent. The value appears only
|
|
23
|
+
* in the message, which Factory redacts; the structured result names the option alone.
|
|
24
|
+
*/
|
|
25
|
+
export function id(value, option) {
|
|
26
|
+
if (option && typeof value === 'string' && value.length > 128)
|
|
27
|
+
fail('invalid', `${option} is longer than 128 characters.`, { option });
|
|
21
28
|
const result = text(value, 128);
|
|
22
29
|
if (!/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/.test(result))
|
|
23
|
-
fail('invalid', 'ID must use letters, digits, dot, underscore or hyphen.
|
|
30
|
+
fail('invalid', `${option ?? 'ID'} must use letters, digits, dot, underscore or hyphen; received ${JSON.stringify(result)}.`, option ? { option } : undefined);
|
|
24
31
|
return result;
|
|
25
32
|
}
|
|
26
33
|
export function version(value) {
|
package/dist/src/mutations.js
CHANGED
|
@@ -41,7 +41,7 @@ export function mutationCommands(research) {
|
|
|
41
41
|
parsed({ name: 'address', type: 'string', required: true, semantic: 'address' }, item.address);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
const selected = scope(o), request = o.requestId === undefined ? undefined : id(o.requestId);
|
|
44
|
+
const selected = scope(o), request = o.requestId === undefined ? undefined : id(o.requestId, '--request-id');
|
|
45
45
|
mutationInputs(m.path, values);
|
|
46
46
|
if (['/set_program_option', '/remove_program_option'].includes(m.path) && values.group === 'Program Information' && values.name === 'Executable SHA256')
|
|
47
47
|
fail('binding', 'The immutable consumed input identity cannot be rewritten as a program option.');
|
package/dist/src/projects.js
CHANGED
|
@@ -292,11 +292,11 @@ export function projectCommands(service) {
|
|
|
292
292
|
for (const key of ['input', 'output'])
|
|
293
293
|
if (o[key] !== undefined)
|
|
294
294
|
p[key] = resolve(c.cwd, text(o[key], 4096));
|
|
295
|
-
return changing ? service(c).change(op, projectName(o.project), p, o.requestId === undefined ? undefined : id(o.requestId)) : service(c).read(op, projectName(o.project), p);
|
|
295
|
+
return changing ? service(c).change(op, projectName(o.project), p, o.requestId === undefined ? undefined : id(o.requestId, '--request-id')) : service(c).read(op, projectName(o.project), p);
|
|
296
296
|
}, { permission, options }));
|
|
297
297
|
}
|
|
298
298
|
return [command('projects', 'Manage isolated Ghidra projects in the selected profile', leaves), command('program', 'Program files', [
|
|
299
|
-
command('export', 'Export the selected private program to a new GZF file', ({ options: o }, c) => service(c).export(scope(o), resolve(c.cwd, text(o.output, 4096)), o.requestId === undefined ? undefined : id(o.requestId)), { permission: Permission.Update, options: [...selectedOptions, { flags: '--output <file>', description: 'New output file; existing files are preserved', required: true }, requestOption] }),
|
|
300
|
-
command('import', 'Import a GZF into a managed project', ({ options: o }, c) => service(c).change('import', projectName(o.project), { input: resolve(c.cwd, text(o.input, 4096)), path: repositoryPath(o.path) }, o.requestId === undefined ? undefined : id(o.requestId)), { permission: Permission.Update, options: [projectOption, { flags: '--input <file>', description: 'Saved Ghidra program file', required: true }, { flags: '--path <path>', description: 'New file path inside the project', required: true }, requestOption] }),
|
|
299
|
+
command('export', 'Export the selected private program to a new GZF file', ({ options: o }, c) => service(c).export(scope(o), resolve(c.cwd, text(o.output, 4096)), o.requestId === undefined ? undefined : id(o.requestId, '--request-id')), { permission: Permission.Update, options: [...selectedOptions, { flags: '--output <file>', description: 'New output file; existing files are preserved', required: true }, requestOption] }),
|
|
300
|
+
command('import', 'Import a GZF into a managed project', ({ options: o }, c) => service(c).change('import', projectName(o.project), { input: resolve(c.cwd, text(o.input, 4096)), path: repositoryPath(o.path) }, o.requestId === undefined ? undefined : id(o.requestId, '--request-id')), { permission: Permission.Update, options: [projectOption, { flags: '--input <file>', description: 'Saved Ghidra program file', required: true }, { flags: '--path <path>', description: 'New file path inside the project', required: true }, requestOption] }),
|
|
301
301
|
])];
|
|
302
302
|
}
|
|
@@ -110,11 +110,11 @@ export function createDefinition(options = {}) {
|
|
|
110
110
|
command('targets', 'Select versioned programs', [
|
|
111
111
|
command('register', 'Register a complete program identity', async ({ options: o }, c) => owner.selected(c).store.register(await jsonFile(c, o.file)), { permission: Permission.Update, options: fileOption }),
|
|
112
112
|
command('list', 'List registered program identities', (_i, c) => owner.selected(c).store.targets(), { permission: Permission.ReadOnly }),
|
|
113
|
-
command('show <target>', 'Show a registered program identity', ({ args }, c) => owner.selected(c).store.target(id(args.target)), { permission: Permission.ReadOnly }),
|
|
113
|
+
command('show <target>', 'Show a registered program identity', ({ args }, c) => owner.selected(c).store.target(id(args.target, 'target')), { permission: Permission.ReadOnly }),
|
|
114
114
|
]),
|
|
115
115
|
command('workers', 'Manage independent reader processes', [
|
|
116
116
|
command('start <target> <worker>', 'Start a reader and dedicated bridge', async ({ args }, c) => {
|
|
117
|
-
const selected = owner.selected(c), target = selected.store.target(id(args.target)), worker = id(args.worker);
|
|
117
|
+
const selected = owner.selected(c), target = selected.store.target(id(args.target, 'target')), worker = id(args.worker);
|
|
118
118
|
if (selected.store.workers().some(w => w.id === worker))
|
|
119
119
|
fail('workerExists', 'Worker ID is already registered.');
|
|
120
120
|
const binding = await selected.ghidra.startReader(target, worker);
|
|
@@ -143,10 +143,10 @@ export function createDefinition(options = {}) {
|
|
|
143
143
|
}, { permission: Permission.ReadOnly, options: [{ flags: '--functions <selectors>', description: 'Select up to eight function references', required: true }] }),
|
|
144
144
|
command('findings', 'Journal scoped comment proposals', [
|
|
145
145
|
command('submit', 'Persist an idempotent finding proposal', async ({ options: o }, c) => owner.selected(c).store.submit(await jsonFile(c, o.file)), { permission: Permission.Update, options: fileOption }),
|
|
146
|
-
command('list', 'List durable findings', ({ options: o }, c) => owner.selected(c).store.findings(o.target ? id(o.target) : undefined), { permission: Permission.ReadOnly, options: [{ flags: '--target <id>', description: 'Filter by registered target' }] }),
|
|
146
|
+
command('list', 'List durable findings', ({ options: o }, c) => owner.selected(c).store.findings(o.target ? id(o.target, '--target') : undefined), { permission: Permission.ReadOnly, options: [{ flags: '--target <id>', description: 'Filter by registered target' }] }),
|
|
147
147
|
command('show <finding>', 'Show a finding and its outcome', ({ args }, c) => owner.selected(c).store.getFinding(id(args.finding)), { permission: Permission.ReadOnly }),
|
|
148
148
|
]),
|
|
149
|
-
command('integrate <target>', 'Publish queued comments for one program', ({ args }, c) => owner.selected(c).coordinator.integrate(id(args.target)), { permission: Permission.Update }),
|
|
149
|
+
command('integrate <target>', 'Publish queued comments for one program', ({ args }, c) => owner.selected(c).coordinator.integrate(id(args.target, 'target')), { permission: Permission.Update }),
|
|
150
150
|
command('status', 'Show durable publication state', (_i, c) => { const selected = owner.selected(c); return { ownerPid: process.pid, profile: c.profile.name, targets: selected.store.targets(), workers: selected.store.workers(), batches: selected.store.batches() }; }, { permission: Permission.ReadOnly }),
|
|
151
151
|
command('recover <batch>', 'Reconcile an interrupted publication batch', ({ args, options: o }, c) => owner.selected(c).coordinator.recover(id(args.batch), Boolean(o.abandonStaged)), { permission: Permission.Update, options: [{ flags: '--abandon-staged', description: 'Abandon a stopped pre-publication stage' }] }),
|
|
152
152
|
],
|
package/dist/src/research.js
CHANGED
|
@@ -40,7 +40,7 @@ export function number(value, maximum, minimum = 0) {
|
|
|
40
40
|
fail('invalid', 'Numeric argument is outside its declared range.');
|
|
41
41
|
return result;
|
|
42
42
|
}
|
|
43
|
-
export function scope(options) { return { session: id(options.session), target: id(options.target) }; }
|
|
43
|
+
export function scope(options) { return { session: id(options.session, '--session'), target: id(options.target, '--target') }; }
|
|
44
44
|
const count = (context) => context.scalars.length + context.complexChanges.length;
|
|
45
45
|
const revision = (value) => value === undefined ? undefined : 'R' + value;
|
|
46
46
|
function comments(value) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type CommandContext, type CommandDefinition } from '@eyeauras/cli-factory';
|
|
2
2
|
import { atomicWrite } from './tool-runtime/store.js';
|
|
3
3
|
export declare const runtimeWrite: typeof atomicWrite;
|
|
4
|
-
/** Passive, conservative inventory:
|
|
5
|
-
export declare function runtimeProcesses(directory: string): Promise<Record<string, unknown>[]>;
|
|
4
|
+
/** Passive, conservative inventory: an unproved PID blocks deletion; it never grants kill authority. */
|
|
5
|
+
export declare function runtimeProcesses(directory: string, control?: string): Promise<Record<string, unknown>[]>;
|
|
6
6
|
export declare function externalGhidra(path: string): Promise<string>;
|
|
7
7
|
export declare class RuntimeManager {
|
|
8
8
|
private readonly c;
|
|
@@ -13,6 +13,7 @@ import { GhidraServer, stopLocalServer } from './server.js';
|
|
|
13
13
|
import { fail, text, digest, object } from './model.js';
|
|
14
14
|
import { atomicWrite, installationStage, removeInstallation, withToolLock, assertUnused } from './tool-runtime/store.js';
|
|
15
15
|
import { lifecycleCommands as sharedLifecycle } from './tool-runtime/definition.js';
|
|
16
|
+
import { recordedProcessGone } from './tool-runtime/supervisor.js';
|
|
16
17
|
import { managedGhidraDebugger, ghidraDebuggerInstaller, prepareGhidraDebugger } from './ghidra-debugger-runtime.js';
|
|
17
18
|
const suffix = process.platform === 'win32' ? '.exe' : '';
|
|
18
19
|
export const runtimeWrite = atomicWrite;
|
|
@@ -26,8 +27,30 @@ catch (error) {
|
|
|
26
27
|
return false;
|
|
27
28
|
throw error;
|
|
28
29
|
} };
|
|
29
|
-
/**
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
* A Ghidra binding bound to a supervisor receipt is settled by that receipt when it is the same Ghidra role, PID and
|
|
32
|
+
* root and has provably ended (including a proven PID reuse). Bindings without a matching receipt stay conservative.
|
|
33
|
+
* Receipts live in the Factory control directory, which can differ from the scanned analysis directory.
|
|
34
|
+
*/
|
|
35
|
+
async function supervisorEnded(control, binding, role, root, rootKey) {
|
|
36
|
+
if (typeof binding.toolProcessId !== 'string')
|
|
37
|
+
return false;
|
|
38
|
+
try {
|
|
39
|
+
// The binding's PID is alive: only a fresh proof, on one validated receipt snapshot, settles it.
|
|
40
|
+
const row = await recordedProcessGone(control, binding.toolProcessId), recorded = row?.metadata?.[rootKey];
|
|
41
|
+
if (!row || row.tool !== 'ghidra' || row.role !== role || row.pid !== binding.pid || typeof recorded !== 'string')
|
|
42
|
+
return false;
|
|
43
|
+
const scanned = await realpath(root);
|
|
44
|
+
if (typeof binding.root === 'string' && await realpath(binding.root) !== scanned)
|
|
45
|
+
return false;
|
|
46
|
+
return await realpath(recorded) === scanned;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** Passive, conservative inventory: an unproved PID blocks deletion; it never grants kill authority. */
|
|
53
|
+
export async function runtimeProcesses(directory, control = directory) {
|
|
31
54
|
const items = [];
|
|
32
55
|
async function walk(path, depth = 0) {
|
|
33
56
|
if (depth > 6)
|
|
@@ -56,7 +79,8 @@ export async function runtimeProcesses(directory) {
|
|
|
56
79
|
if (error.code !== 'ENOENT')
|
|
57
80
|
throw error;
|
|
58
81
|
}
|
|
59
|
-
|
|
82
|
+
// A GUI worker can own debugger state; it is settled only with debugger cleanup evidence (#153).
|
|
83
|
+
if (!stopped && live(p.pid) && (p.mode === 'gui' || !await supervisorEnded(control, p, String(p.kind), path, 'contextRoot')))
|
|
60
84
|
items.push({ kind: p.kind, pid: p.pid, sessionContext: p.context, ...(typeof p.session === 'string' ? { session: p.session } : {}), target: p.target, mode: p.mode });
|
|
61
85
|
}
|
|
62
86
|
}
|
|
@@ -64,7 +88,7 @@ export async function runtimeProcesses(directory) {
|
|
|
64
88
|
await walk(join(directory, 'workspace', 'ghidra-native'));
|
|
65
89
|
try {
|
|
66
90
|
const s = object(JSON.parse(await readFile(join(directory, 'workspace/server/local.json'), 'utf8')));
|
|
67
|
-
if (live(s.pid))
|
|
91
|
+
if (live(s.pid) && !await supervisorEnded(control, s, 'server', join(directory, 'workspace'), 'serverDirectory'))
|
|
68
92
|
items.push({ kind: 'server', pid: s.pid });
|
|
69
93
|
}
|
|
70
94
|
catch (error) {
|
package/dist/src/sdk-files.js
CHANGED
|
@@ -202,7 +202,7 @@ export function sdkFileCommands(service) {
|
|
|
202
202
|
{ flags: '--request-id <id>', description: 'Retrieve retained export bytes without repeating native export' }];
|
|
203
203
|
const databases = [];
|
|
204
204
|
for (const kind of ['fid', 'bsim']) {
|
|
205
|
-
databases.push(command('build-' + kind, 'Build a genuine native ' + kind + ' database from the saved private snapshot', ({ options: o }, c) => service(c).export(scope(o), kind + '-build', { library: text(o.library, 512), ...(kind === 'fid' ? { version: text(o.libraryVersion, 128) } : {}) }, resolve(c.cwd, text(o.outputDirectory, 4096)), o.requestId === undefined ? undefined : id(o.requestId)), { permission: Permission.Update, options: [...outputs, { flags: '--library <name>', description: 'Native library/database name', required: true }, ...(kind === 'fid' ? [{ flags: '--library-version <version>', description: 'Native library version', required: true }] : [])] }));
|
|
205
|
+
databases.push(command('build-' + kind, 'Build a genuine native ' + kind + ' database from the saved private snapshot', ({ options: o }, c) => service(c).export(scope(o), kind + '-build', { library: text(o.library, 512), ...(kind === 'fid' ? { version: text(o.libraryVersion, 128) } : {}) }, resolve(c.cwd, text(o.outputDirectory, 4096)), o.requestId === undefined ? undefined : id(o.requestId, '--request-id')), { permission: Permission.Update, options: [...outputs, { flags: '--library <name>', description: 'Native library/database name', required: true }, ...(kind === 'fid' ? [{ flags: '--library-version <version>', description: 'Native library version', required: true }] : [])] }));
|
|
206
206
|
databases.push(command(kind + '-query', 'Query one explicitly consumed native ' + kind + ' database with provenance and no-match semantics', ({ options: o }, c) => {
|
|
207
207
|
const p = { limit: number(o.limit, 1000, 1) };
|
|
208
208
|
if (o.function !== undefined)
|
|
@@ -236,14 +236,14 @@ export function sdkFileCommands(service) {
|
|
|
236
236
|
fail('invalid', 'Export ranges require 1–64 start/end objects.');
|
|
237
237
|
p.ranges = ranges;
|
|
238
238
|
}
|
|
239
|
-
return service(c).export(scope(o), 'export', p, resolve(c.cwd, text(o.outputDirectory, 4096)), o.requestId === undefined ? undefined : id(o.requestId));
|
|
239
|
+
return service(c).export(scope(o), 'export', p, resolve(c.cwd, text(o.outputDirectory, 4096)), o.requestId === undefined ? undefined : id(o.requestId, '--request-id'));
|
|
240
240
|
}, { permission: Permission.Update, options: [...outputs, { flags: '--exporter <id>', description: 'Explicit native exporter name/ID', required: true }, { flags: '--options <json>', description: 'Named primitive native options', defaultValue: '{}' }, { flags: '--ranges <json>', description: 'Address ranges with start/end; exporter must support restricted output' }] }),
|
|
241
241
|
]), command('types', 'Native type archives', [
|
|
242
242
|
command('archive-export', 'Export 1–256 explicit type paths to a native GDT with checked layout', ({ options: o }, c) => {
|
|
243
243
|
const types = json(o.types);
|
|
244
244
|
if (!Array.isArray(types) || !types.length || types.length > 256 || types.some(v => typeof v !== 'string' || !v.startsWith('/')))
|
|
245
245
|
fail('invalid', 'Types must be 1–256 absolute type paths.');
|
|
246
|
-
return service(c).export(scope(o), 'archive-export', { types }, resolve(c.cwd, text(o.outputDirectory, 4096)), o.requestId === undefined ? undefined : id(o.requestId));
|
|
246
|
+
return service(c).export(scope(o), 'archive-export', { types }, resolve(c.cwd, text(o.outputDirectory, 4096)), o.requestId === undefined ? undefined : id(o.requestId, '--request-id'));
|
|
247
247
|
}, { permission: Permission.Update, options: [...outputs, { flags: '--types <json>', description: 'Selected native type paths', required: true }] }),
|
|
248
248
|
])];
|
|
249
249
|
}
|
package/dist/src/sdk.js
CHANGED
|
@@ -111,7 +111,7 @@ export function sdkCommands(research) {
|
|
|
111
111
|
p.archive = archive;
|
|
112
112
|
}
|
|
113
113
|
if (entry.write)
|
|
114
|
-
return api.mutate(selected, operation, p, async () => ({}), o.requestId === undefined ? undefined : id(o.requestId), (backend, snapshot, response) => verifyMutation(backend, snapshot, operation, p, response));
|
|
114
|
+
return api.mutate(selected, operation, p, async () => ({}), o.requestId === undefined ? undefined : id(o.requestId, '--request-id'), (backend, snapshot, response) => verifyMutation(backend, snapshot, operation, p, response));
|
|
115
115
|
const other = entry.pair ? { session: o.otherSession === undefined ? selected.session : id(o.otherSession), target: id(o.otherTarget) } : undefined;
|
|
116
116
|
const value = object(other ? await api.crossRead(selected, other, operation, p) : await api.read(selected, operation, p));
|
|
117
117
|
if (Buffer.byteLength(JSON.stringify(value)) > 1048576)
|
package/dist/src/server.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ interface LocalServer extends ServerBinding {
|
|
|
23
23
|
pid?: number;
|
|
24
24
|
}
|
|
25
25
|
export declare function retireReusedServer(directory: string, control: string, local: LocalServer): Promise<boolean>;
|
|
26
|
+
export declare function interpret(result: Record<string, unknown>): Record<string, unknown>;
|
|
26
27
|
/** Own local startup; external profiles connect without taking ownership of their server. */
|
|
27
28
|
export declare class GhidraServer {
|
|
28
29
|
readonly directory: string;
|
package/dist/src/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ghidraBudget } from './budgets.js';
|
|
2
2
|
import { CliError } from '@eyeauras/cli-factory';
|
|
3
|
-
import { launchProcess, terminateProcess,
|
|
3
|
+
import { launchProcess, terminateProcess, listProcesses, recordedProcessGone } from './tool-runtime/supervisor.js';
|
|
4
4
|
import { processIdentity } from './tool-runtime/identity.js';
|
|
5
5
|
import { runTool } from './tool-runtime/run.js';
|
|
6
6
|
import { randomUUID, randomBytes, createHash } from 'node:crypto';
|
|
@@ -30,13 +30,20 @@ async function forgetAuthority(directory) { await rm(join(directory, 'server', '
|
|
|
30
30
|
export async function retireReusedServer(directory, control, local) {
|
|
31
31
|
if (!local.pid || !local.toolProcessId)
|
|
32
32
|
return false;
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
// Proved freshly from the PID's current holder on one validated receipt snapshot, never from its stored state or phase.
|
|
34
|
+
const row = await recordedProcessGone(control, local.toolProcessId);
|
|
35
|
+
if (!row || row.tool !== 'ghidra' || row.role !== 'server' || row.pid !== local.pid || typeof row.metadata?.serverDirectory !== 'string')
|
|
35
36
|
return false;
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
// A missing historical directory proves nothing; the authenticated stop path decides instead.
|
|
38
|
+
try {
|
|
39
|
+
if (await realpath(row.metadata.serverDirectory) !== await realpath(directory))
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
38
43
|
return false;
|
|
39
|
-
|
|
44
|
+
}
|
|
45
|
+
const observed = await processIdentity(local.pid);
|
|
46
|
+
await durable(join(directory, 'server', 'retired-local-' + randomUUID() + '.json'), { schema: 1, reason: 'Original server birth is no longer alive; reused PID was not signaled.', local: { ...local }, process: row, observedBirth: observed?.birth ?? null });
|
|
40
47
|
local.phase = 'stopped';
|
|
41
48
|
delete local.pid;
|
|
42
49
|
delete local.toolProcessId;
|
|
@@ -51,7 +58,10 @@ function operationLabel(value) { return typeof value === 'string' && /^[a-z][a-z
|
|
|
51
58
|
const outOfMemoryText = /OutOfMemoryError|Could not reserve enough space|insufficient memory for the Java Runtime|Native memory allocation \((m?malloc|mmap)\) failed|unable to create (new )?native thread|paging file is too small|errno=1455|os::commit_memory\(.*\) failed/i;
|
|
52
59
|
/** Roles of the processes that can write native checkout journals: the one-shot helper and the publisher service. */
|
|
53
60
|
const nativeWriterRoles = ['native-checkout', 'native-publisher'];
|
|
54
|
-
function interpret(result) {
|
|
61
|
+
export function interpret(result) {
|
|
62
|
+
// The helper refused before writing the operation journal, so Ghidra was never called.
|
|
63
|
+
if (result.state === 'unknown' && result.code === 'not-sent' && typeof result.reason === 'string')
|
|
64
|
+
throw new CliError(result.reason, { code: 'tool.notSent', result: { diagnostic: result.diagnostic } });
|
|
55
65
|
if (result.state === 'unknown' && typeof result.reason === 'string')
|
|
56
66
|
fail(result.code === 'migration' ? 'migration' : 'unknown', result.reason, { diagnostic: result.diagnostic });
|
|
57
67
|
if (result.error || result.state === 'failed')
|
package/dist/src/sevenzip.js
CHANGED
|
@@ -61,7 +61,7 @@ export function sevenzipCommands(workspace) {
|
|
|
61
61
|
const operation = (name) => command(name + ' [input]', name === 'list' ? 'Inspect a bounded archive inventory' : name === 'test' ? 'Check container integrity without extracting' : 'Recover regular files into a new ordinary directory', async ({ args, options: o }, c) => {
|
|
62
62
|
if (Boolean(args.input) === Boolean(o.target))
|
|
63
63
|
fail('invalid', 'Supply exactly one input path or --target.');
|
|
64
|
-
const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target));
|
|
64
|
+
const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target, '--target'));
|
|
65
65
|
const input = await w.artifacts.verify(target.input), timeoutMs = number(o.timeoutSeconds, 600, 1) * 1000;
|
|
66
66
|
return sevenzipInstaller(c).use(async (selected) => {
|
|
67
67
|
const invoke = (role, parameters, extra = {}) => runTool(c, { tool: 'sevenzip', role, installation: selected.id, executable: selected.executable, arguments: [...selected.arguments, ...parameters], environment: selected.environment, target: target.id, timeoutMs, ...extra });
|
package/dist/src/strace.js
CHANGED
|
@@ -41,7 +41,7 @@ export function straceCommands(workspace) {
|
|
|
41
41
|
if (o.path)
|
|
42
42
|
o = { ...o, path: resolve(c.cwd, text(o.path, 4096)) };
|
|
43
43
|
const plan = stracePlan(o), limit = number(o.limit ?? 200, 1000, 1), offset = number(o.offset ?? 0, 1000000), timeoutMs = number(o.timeoutSeconds ?? 30, 600, 1) * 1000;
|
|
44
|
-
const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target)), input = await w.artifacts.verify(target.input), header = Buffer.alloc(64), handle = await open(input, 'r');
|
|
44
|
+
const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target, '--target')), input = await w.artifacts.verify(target.input), header = Buffer.alloc(64), handle = await open(input, 'r');
|
|
45
45
|
try {
|
|
46
46
|
const { bytesRead } = await handle.read(header, 0, 64, 0);
|
|
47
47
|
if (bytesRead < 64 || header.subarray(0, 4).toString('hex') !== '7f454c46' || header[4] !== 2 || header[5] !== 1 || header.readUInt16LE(18) !== 62)
|
package/dist/src/sync-policy.js
CHANGED
|
@@ -40,13 +40,13 @@ export class Synchronization {
|
|
|
40
40
|
* research queues remain unchanged, including their cross-context ordering and shared lane. */
|
|
41
41
|
async execute(selected, path, input, run) {
|
|
42
42
|
const configured = this.workspace.context(selected).syncPolicy ?? manualPolicy;
|
|
43
|
-
const caller = input.requestId === undefined ? undefined : id(input.requestId);
|
|
43
|
+
const caller = input.requestId === undefined ? undefined : id(input.requestId, '--request-id');
|
|
44
44
|
const recorded = caller ? this.workspace.scopedRequest(selected, caller) : undefined;
|
|
45
45
|
if (caller && recorded?.id === caller)
|
|
46
46
|
return run(caller);
|
|
47
47
|
const previous = caller ? this.workspace.administrationByCaller(caller) : undefined;
|
|
48
|
-
if (!previous && (configured.publish === 'manual' && configured.refresh === 'manual' || input.requestId !== undefined && this.workspace.requestByCaller(id(input.requestId))))
|
|
49
|
-
return run(input.requestId === undefined ? '' : id(input.requestId));
|
|
48
|
+
if (!previous && (configured.publish === 'manual' && configured.refresh === 'manual' || input.requestId !== undefined && this.workspace.requestByCaller(id(input.requestId, '--request-id'))))
|
|
49
|
+
return run(input.requestId === undefined ? '' : id(input.requestId, '--request-id'));
|
|
50
50
|
if (previous && previous.operation !== 'ghidra.automatic')
|
|
51
51
|
fail('idempotency', 'Request ID already identifies another profile administration operation.');
|
|
52
52
|
const policy = previous ? syncPolicy(object(object(previous.intent).parameters).policy) : configured;
|
|
@@ -123,7 +123,7 @@ export class Synchronization {
|
|
|
123
123
|
export function synchronizationCommands(service) {
|
|
124
124
|
return [command('sync-policy', 'Configure opt-in synchronization for one saved tool context', [
|
|
125
125
|
command('get', 'Read the persisted policy; default is manual', ({ options: o }, c) => service(c).get(scope(o)), { permission: Permission.ReadOnly, options: selectedOptions }),
|
|
126
|
-
command('set', 'Choose manual, publication after edit/save and optional refresh before edit', ({ options: o }, c) => service(c).set(scope(o), syncPolicy({ publish: text(o.publish), refresh: text(o.refresh) }), o.requestId === undefined ? undefined : id(o.requestId)), { permission: Permission.Update, options: [...selectedOptions,
|
|
126
|
+
command('set', 'Choose manual, publication after edit/save and optional refresh before edit', ({ options: o }, c) => service(c).set(scope(o), syncPolicy({ publish: text(o.publish), refresh: text(o.refresh) }), o.requestId === undefined ? undefined : id(o.requestId, '--request-id')), { permission: Permission.Update, options: [...selectedOptions,
|
|
127
127
|
{ flags: '--publish <mode>', description: 'manual, after-edit or after-save', required: true }, { flags: '--refresh <mode>', description: 'manual or before-edit', required: true }, { flags: '--request-id <id>', description: 'Retrieve the recorded policy change' }] }),
|
|
128
128
|
])];
|
|
129
129
|
}
|
|
@@ -3,4 +3,11 @@ export interface ProcessIdentity {
|
|
|
3
3
|
strong: boolean;
|
|
4
4
|
group?: number;
|
|
5
5
|
}
|
|
6
|
+
/** Exactly what this platform's probe emits; placeholders and foreign, malformed or non-canonical values never compare. */
|
|
7
|
+
export declare function comparableBirth(birth: unknown): birth is string;
|
|
8
|
+
/**
|
|
9
|
+
* The process now at a recorded PID has a different start identity of the same comparable shape: the recorded
|
|
10
|
+
* process ended and the PID was reused. This proves absence only; it never grants authority over the new holder.
|
|
11
|
+
*/
|
|
12
|
+
export declare function birthChanged(recorded: unknown, current: ProcessIdentity | undefined): boolean;
|
|
6
13
|
export declare function processIdentity(pid: number): Promise<ProcessIdentity | undefined>;
|
|
@@ -11,6 +11,41 @@ catch (e) {
|
|
|
11
11
|
if (e.code === 'ESRCH')
|
|
12
12
|
return;
|
|
13
13
|
} return { birth: 'unavailable', strong: false }; }
|
|
14
|
+
const weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
15
|
+
/** macOS `ps -o lstart` in the C locale and UTC, e.g. `Thu Dec 3 21:56:45 2026`, naming a real instant. */
|
|
16
|
+
function canonicalDarwinBirth(birth) {
|
|
17
|
+
const m = /^([A-Z][a-z]{2}) ([A-Z][a-z]{2}) ([ 1-3]\d) (\d{2}):(\d{2}):(\d{2}) (\d{4})$/.exec(birth);
|
|
18
|
+
if (!m)
|
|
19
|
+
return false;
|
|
20
|
+
const [, weekday, monthName, day, hours, minutes, seconds, year] = m, month = months.indexOf(monthName);
|
|
21
|
+
if (month < 0)
|
|
22
|
+
return false;
|
|
23
|
+
const at = new Date(Date.UTC(Number(year), month, Number(day), Number(hours), Number(minutes), Number(seconds)));
|
|
24
|
+
return at.getUTCFullYear() === Number(year) && at.getUTCMonth() === month && at.getUTCDate() === Number(day) && at.getUTCHours() === Number(hours) &&
|
|
25
|
+
at.getUTCMinutes() === Number(minutes) && at.getUTCSeconds() === Number(seconds) && weekdays[at.getUTCDay()] === weekday && String(Number(day)).padStart(2, ' ') === day;
|
|
26
|
+
}
|
|
27
|
+
/** Exactly what this platform's probe emits; placeholders and foreign, malformed or non-canonical values never compare. */
|
|
28
|
+
export function comparableBirth(birth) {
|
|
29
|
+
if (typeof birth !== 'string')
|
|
30
|
+
return false;
|
|
31
|
+
const counter = (value, max) => /^(0|[1-9]\d{0,19})$/.test(value) && BigInt(value) <= max;
|
|
32
|
+
if (process.platform === 'linux') { // boot ID : start ticks (unsigned 64-bit)
|
|
33
|
+
const m = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}:(\d+)$/.exec(birth);
|
|
34
|
+
return Boolean(m && counter(m[1], 18446744073709551615n));
|
|
35
|
+
}
|
|
36
|
+
if (process.platform === 'win32')
|
|
37
|
+
return counter(birth, 3155378975999999999n); // UTC creation ticks up to DateTime.MaxValue
|
|
38
|
+
if (process.platform === 'darwin')
|
|
39
|
+
return canonicalDarwinBirth(birth);
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The process now at a recorded PID has a different start identity of the same comparable shape: the recorded
|
|
44
|
+
* process ended and the PID was reused. This proves absence only; it never grants authority over the new holder.
|
|
45
|
+
*/
|
|
46
|
+
export function birthChanged(recorded, current) {
|
|
47
|
+
return comparableBirth(recorded) && current !== undefined && comparableBirth(current.birth) && current.birth !== recorded;
|
|
48
|
+
}
|
|
14
49
|
export async function processIdentity(pid) {
|
|
15
50
|
return timed('tool.identity', process.platform, () => probeIdentity(pid));
|
|
16
51
|
}
|
|
@@ -118,6 +118,9 @@ export async function assertUnused(directory, tool) {
|
|
|
118
118
|
const { processStatus } = await import('./supervisor.js'), record = await processStatus(directory, name.slice(0, -5));
|
|
119
119
|
if (['exited', 'failed'].includes(record.state))
|
|
120
120
|
continue;
|
|
121
|
+
// A moved collector's helper receipts cannot be inspected; its own PID says nothing about its helpers.
|
|
122
|
+
if (record.phase === 'profile_binding_changed' && record.metadata?.nativeChildDeadlines === true)
|
|
123
|
+
fail('busy', 'Tool has a moved collector whose native helpers cannot be inspected; inspect its retained records before changing installations.');
|
|
121
124
|
if (record.phase === 'native_children_pending' || record.phase === 'native_children_unverified')
|
|
122
125
|
fail('busy', 'Tool has an active or unverified native helper; inspect its retained records before changing installations.');
|
|
123
126
|
if (!record.pid) {
|
|
@@ -26,6 +26,14 @@ export interface TrackedChild extends ChildProcess {
|
|
|
26
26
|
toolClosed: Promise<void>;
|
|
27
27
|
}
|
|
28
28
|
export type OwnershipVerifier = (record: ProcessRecord) => Promise<boolean | undefined>;
|
|
29
|
+
/**
|
|
30
|
+
* The process a receipt recorded is gone from its PID, proved freshly and never from the receipt's stored state or
|
|
31
|
+
* phase: no process holds the PID, or its holder has a different canonical birth. A child this owner still holds
|
|
32
|
+
* alive is never gone. Grants no authority over the PID's current holder.
|
|
33
|
+
*/
|
|
34
|
+
export declare function recordedProcessGone(directory: string, id: string): Promise<ProcessRecord | undefined>;
|
|
35
|
+
/** Exactly what the receipt writer emits (`Date#toISOString`); impossible dates are not normalized into evidence. */
|
|
36
|
+
export declare function validEnd(value: unknown): boolean;
|
|
29
37
|
export declare function launchProcess(directory: string, spec: ProcessSpec, executable: string, args: string[], options?: SpawnOptions, control?: {
|
|
30
38
|
id?: string;
|
|
31
39
|
finalize?: boolean;
|
|
@@ -8,12 +8,57 @@ import { randomUUID } from 'node:crypto';
|
|
|
8
8
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
9
9
|
import { CliError } from '@eyeauras/cli-factory';
|
|
10
10
|
import { atomicWrite, readJson, toolRoot, withToolLock, prepareRunRoot } from './store.js';
|
|
11
|
-
import { processIdentity } from './identity.js';
|
|
11
|
+
import { processIdentity, birthChanged } from './identity.js';
|
|
12
12
|
import { javaClasspathArguments } from './java-arguments.js';
|
|
13
13
|
import { digest } from '../model.js';
|
|
14
14
|
import { timed } from '../internal-timing.js';
|
|
15
15
|
const owned = new Map();
|
|
16
16
|
const ownedKey = (directory, id) => resolve(directory) + '\0' + id;
|
|
17
|
+
/**
|
|
18
|
+
* The process a receipt recorded is gone from its PID, proved freshly and never from the receipt's stored state or
|
|
19
|
+
* phase: no process holds the PID, or its holder has a different canonical birth. A child this owner still holds
|
|
20
|
+
* alive is never gone. Grants no authority over the PID's current holder.
|
|
21
|
+
*/
|
|
22
|
+
export async function recordedProcessGone(directory, id) {
|
|
23
|
+
if (!/^[a-f0-9-]{36}$/.test(id))
|
|
24
|
+
return undefined;
|
|
25
|
+
// One snapshot: the receipt whose profile is checked is the one whose birth is compared, and callers validate
|
|
26
|
+
// their own fields (tool, role, PID, root) on this returned snapshot.
|
|
27
|
+
const stored = await readJson(join(directory, 'runtime/processes', id + '.json'));
|
|
28
|
+
if (!stored || stored.id !== id || !Number.isSafeInteger(stored.pid) || Number(stored.pid) < 1 || heldByThisOwner(id) || !ownedByProfile(directory, id, stored))
|
|
29
|
+
return undefined;
|
|
30
|
+
// A stored terminal state without its exact recorded end is ambiguous; a stored phase is never proof.
|
|
31
|
+
if (['exited', 'failed'].includes(stored.state) && !validEnd(stored.endedAt))
|
|
32
|
+
return undefined;
|
|
33
|
+
const current = await processIdentity(Number(stored.pid));
|
|
34
|
+
return !current || birthChanged(stored.identity, current) ? stored : undefined;
|
|
35
|
+
}
|
|
36
|
+
/** The receipt belongs to this profile directory, directly or through a proven alias of it. */
|
|
37
|
+
function ownedByProfile(directory, id, record) {
|
|
38
|
+
if (record.root === join(directory, 'runtime/runs', id) && record.profileBinding === digest(resolve(directory)))
|
|
39
|
+
return true;
|
|
40
|
+
try {
|
|
41
|
+
const recorded = resolve(record.root, '../../..');
|
|
42
|
+
return record.root === join(recorded, 'runtime/runs', id) && record.profileBinding === digest(recorded) && sameDirectory(recorded, directory);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Exactly what the receipt writer emits (`Date#toISOString`); impossible dates are not normalized into evidence. */
|
|
49
|
+
export function validEnd(value) {
|
|
50
|
+
if (typeof value !== 'string')
|
|
51
|
+
return false;
|
|
52
|
+
const at = Date.parse(value);
|
|
53
|
+
return Number.isFinite(at) && new Date(at).toISOString() === value;
|
|
54
|
+
}
|
|
55
|
+
/** This owner launched the record's process and still holds it alive, whatever the record or its path spelling now says. */
|
|
56
|
+
function heldByThisOwner(id) {
|
|
57
|
+
for (const current of owned.values())
|
|
58
|
+
if (current.record.id === id && current.child.exitCode === null && current.child.signalCode === null)
|
|
59
|
+
return true;
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
17
62
|
/** Receipts report pending lifetime only; they never authorize a signal to another PID. */
|
|
18
63
|
async function nativeChildren(record) {
|
|
19
64
|
if (record.metadata?.nativeChildDeadlines !== true)
|
|
@@ -195,13 +240,8 @@ export async function processStatus(directory, id, verify) {
|
|
|
195
240
|
throw new CliError('Unknown tool process.', { code: 'tool.process.missing' });
|
|
196
241
|
if (record.root !== join(directory, 'runtime/runs', id) || record.profileBinding !== digest(resolve(directory))) {
|
|
197
242
|
// Retain the recorded spelling/digest, but prove its owner is this same directory.
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const recorded = resolve(record.root, '../../..');
|
|
201
|
-
alias = record.root === join(recorded, 'runtime/runs', id) && record.profileBinding === digest(recorded) && sameDirectory(recorded, directory);
|
|
202
|
-
}
|
|
203
|
-
catch { }
|
|
204
|
-
if (!alias)
|
|
243
|
+
// A moved or copied receipt grants no authority and stays unresolved; storage migration has its own stricter proof.
|
|
244
|
+
if (!ownedByProfile(directory, id, record))
|
|
205
245
|
return { ...record, state: 'unverified', phase: 'profile_binding_changed' };
|
|
206
246
|
}
|
|
207
247
|
const finishing = owned.get(ownedKey(directory, id));
|
|
@@ -232,8 +272,13 @@ export async function processStatus(directory, id, verify) {
|
|
|
232
272
|
const identity = await processIdentity(record.pid);
|
|
233
273
|
if (!identity)
|
|
234
274
|
return { ...observed, state: pending ? 'unverified' : 'exited', phase: pending ? 'native_children_pending' : 'observed_exit', outcome: 'unknown' };
|
|
235
|
-
if (identity.birth !== record.identity)
|
|
236
|
-
|
|
275
|
+
if (identity.birth !== record.identity) {
|
|
276
|
+
// A different comparable birth proves the recorded process ended and its PID was reused. The new holder is never
|
|
277
|
+
// adopted or signalled; pending native helpers keep the record unresolved.
|
|
278
|
+
if (!pending && !heldByThisOwner(record.id) && birthChanged(record.identity, identity))
|
|
279
|
+
return { ...observed, state: 'exited', phase: 'pid_identity_changed', outcome: record.outcome ?? 'unknown' };
|
|
280
|
+
return { ...observed, state: 'unverified', phase: pending ? 'native_children_pending' : 'pid_identity_changed' };
|
|
281
|
+
}
|
|
237
282
|
const current = owned.get(ownedKey(directory, id)), local = current?.child.pid === record.pid && current.record.identity === record.identity && current.child.exitCode === null && current.child.signalCode === null;
|
|
238
283
|
const proof = verify ? await verify(record) : undefined;
|
|
239
284
|
if (local || proof === true || proof === undefined && record.strongIdentity && identity.strong)
|
|
@@ -270,6 +315,9 @@ export async function terminateProcess(directory, id, force, verify, graceful) {
|
|
|
270
315
|
if (!force && graceful)
|
|
271
316
|
await graceful(record);
|
|
272
317
|
let current = await processStatus(directory, id, verify);
|
|
318
|
+
// The PID was proven reused before any signal: report the ended process without claiming a stop or kill.
|
|
319
|
+
if (current.state === 'exited' && current.phase === 'pid_identity_changed')
|
|
320
|
+
return { process: id, state: 'already_exited' };
|
|
273
321
|
if (!['exited', 'failed'].includes(current.state)) {
|
|
274
322
|
if (current.state !== 'running' || current.pid !== record.pid)
|
|
275
323
|
throw new CliError('Process identity changed during stop.', { code: 'tool.process.unverified' });
|
package/dist/src/tshark.js
CHANGED
|
@@ -94,7 +94,7 @@ export function tsharkCommands(workspace) {
|
|
|
94
94
|
const transport = view === 'follow' ? text(o.transport, 8) : undefined, stream = view === 'follow' ? number(o.stream, 1000000) : undefined;
|
|
95
95
|
if (transport && !['tcp', 'udp'].includes(transport))
|
|
96
96
|
fail('invalid', 'Follow transport must be tcp or udp.');
|
|
97
|
-
const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target)), input = await w.artifacts.verify(target.input);
|
|
97
|
+
const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target, '--target')), input = await w.artifacts.verify(target.input);
|
|
98
98
|
if (target.input.size > 64 * 1024 ** 2)
|
|
99
99
|
fail('limit', 'Capture input exceeds 64 MiB.');
|
|
100
100
|
const file = await open(input, 'r'), header = Buffer.alloc(4);
|
package/dist/src/ui.js
CHANGED
|
@@ -69,12 +69,12 @@ export function uiCommands(service) {
|
|
|
69
69
|
return service(c).read(scope(o), 'cursor', type);
|
|
70
70
|
}, { permission: Permission.ReadOnly, options: [...selectedOptions, { flags: '--type <facet>', description: 'Cursor facet or all', defaultValue: 'all' }] }),
|
|
71
71
|
command('tools', 'Read tools in the owned GUI context', ({ options: o }, c) => service(c).read(scope(o), 'tools'), { permission: Permission.ReadOnly, options: selectedOptions }),
|
|
72
|
-
command('goto', 'Navigate the owned browser and verify the cursor', ({ options: o }, c) => service(c).change(scope(o), 'goto', { address: address(o.address) }, o.requestId === undefined ? undefined : id(o.requestId)), { permission: Permission.Update, options: [...selectedOptions, { flags: '--address <address>', description: 'Explicit address', required: true }, request] }),
|
|
72
|
+
command('goto', 'Navigate the owned browser and verify the cursor', ({ options: o }, c) => service(c).change(scope(o), 'goto', { address: address(o.address) }, o.requestId === undefined ? undefined : id(o.requestId, '--request-id')), { permission: Permission.Update, options: [...selectedOptions, { flags: '--address <address>', description: 'Explicit address', required: true }, request] }),
|
|
73
73
|
command('prompt-policy', 'Temporarily control the owned GUI prompt policy', ({ options: o }, c) => {
|
|
74
74
|
const action = text(o.action);
|
|
75
75
|
if (!['status', 'enable', 'disable'].includes(action))
|
|
76
76
|
fail('invalid', 'Prompt policy action must be status, enable or disable.');
|
|
77
|
-
return service(c).change(scope(o), 'prompt_policy', { action, reason: text(o.reason, 512), seconds: number(o.seconds, 300, 1) }, o.requestId === undefined ? undefined : id(o.requestId));
|
|
77
|
+
return service(c).change(scope(o), 'prompt_policy', { action, reason: text(o.reason, 512), seconds: number(o.seconds, 300, 1) }, o.requestId === undefined ? undefined : id(o.requestId, '--request-id'));
|
|
78
78
|
}, { permission: Permission.Update, options: [...selectedOptions, { flags: '--action <action>', description: 'status, enable or disable', defaultValue: 'status' },
|
|
79
79
|
{ flags: '--reason <text>', description: 'Recorded policy reason', defaultValue: 'automation' }, { flags: '--seconds <count>', description: 'Requested duration (1–300 seconds)', defaultValue: 120 }, request] }),
|
|
80
80
|
])];
|
|
@@ -83,6 +83,6 @@ export function pluginCommands(service) {
|
|
|
83
83
|
return [command('plugins', 'Configure plugins from enabled managed modules in an owned GUI', [
|
|
84
84
|
command('list', 'Read enabled managed plugins in this GUI tool', ({ options: o }, c) => service(c).read(scope(o), 'plugins_list'), { permission: Permission.ReadOnly, options: selectedOptions }),
|
|
85
85
|
command('set', 'Enable or disable one installed managed plugin with immediate readback', ({ options: o }, c) => { if (o.enabled !== 'true' && o.enabled !== 'false')
|
|
86
|
-
fail('invalid', 'enabled must be true or false.'); return service(c).change(scope(o), 'plugins_set', { plugin: text(o.plugin, 512), enabled: o.enabled === 'true' }, o.requestId === undefined ? undefined : id(o.requestId)); }, { permission: 'Destructive', options: [...selectedOptions, { flags: '--plugin <class>', description: 'Managed plugin ID from extensions capabilities', required: true }, { flags: '--enabled <boolean>', description: 'true or false', required: true }, { flags: '--request-id <id>', description: 'Retrieve the original plugin outcome without replay' }] })
|
|
86
|
+
fail('invalid', 'enabled must be true or false.'); return service(c).change(scope(o), 'plugins_set', { plugin: text(o.plugin, 512), enabled: o.enabled === 'true' }, o.requestId === undefined ? undefined : id(o.requestId, '--request-id')); }, { permission: 'Destructive', options: [...selectedOptions, { flags: '--plugin <class>', description: 'Managed plugin ID from extensions capabilities', required: true }, { flags: '--enabled <boolean>', description: 'true or false', required: true }, { flags: '--request-id <id>', description: 'Retrieve the original plugin outcome without replay' }] })
|
|
87
87
|
])];
|
|
88
88
|
}
|
|
@@ -187,7 +187,7 @@ export function trackingCommands(service) {
|
|
|
187
187
|
command('list', 'List VT objects owned by this destination research scope, including retained creation stages', ({ options: o }, c) => service(c).list(scope(o), number(o.offset, 1000000), number(o.limit, 1000, 1)), { permission: Permission.ReadOnly, options: [...selectedOptions, { flags: '--limit <count>', description: 'Maximum returned owned VT objects', defaultValue: 100 }, { flags: '--offset <count>', description: 'Inventory offset; use nextOffset after a partial scan', defaultValue: 0 }] }),
|
|
188
188
|
command('create', 'Correlate immutable source/destination snapshots in a persistent owned native VT project', ({ options: o }, c) => {
|
|
189
189
|
const selected = scope(o), source = { session: o.sourceSession === undefined ? selected.session : id(o.sourceSession), target: id(o.sourceTarget) };
|
|
190
|
-
return service(c).create(selected, source, o.requestId === undefined ? undefined : id(o.requestId));
|
|
190
|
+
return service(c).create(selected, source, o.requestId === undefined ? undefined : id(o.requestId, '--request-id'));
|
|
191
191
|
}, { permission: Permission.Update, options: [...selectedOptions, { flags: '--source-target <id>', description: 'Source immutable target', required: true }, { flags: '--source-session <id>', description: 'Source research session (default destination session)' }, request] }),
|
|
192
192
|
command('matches', 'Read native match sets and correlator-specific scores from the saved VT object', ({ options: o }, c) => service(c).read(scope(o), id(o.tracking), 'matches', { limit: number(o.limit, 1000, 1), offset: number(o.offset, 100000) }), { permission: Permission.ReadOnly, options: [...selectedOptions, tracking, { flags: '--limit <count>', description: 'Match page size 1–1000', defaultValue: 100 }, { flags: '--offset <count>', description: 'Page offset', defaultValue: 0 }] }),
|
|
193
193
|
command('markup', 'Inspect native markup values for one association before agent-directed edits', ({ options: o }, c) => service(c).read(scope(o), id(o.tracking), 'markup', { source_address: address(o.sourceAddress), destination_address: address(o.destinationAddress) }), { permission: Permission.ReadOnly, options: [...selectedOptions, tracking, ...association] }),
|
|
@@ -195,7 +195,7 @@ export function trackingCommands(service) {
|
|
|
195
195
|
const decision = text(o.decision);
|
|
196
196
|
if (!['accepted', 'rejected', 'available'].includes(decision))
|
|
197
197
|
fail('invalid', 'Decision must be accepted, rejected or available.');
|
|
198
|
-
return service(c).decide(scope(o), id(o.tracking), { source_address: address(o.sourceAddress), destination_address: address(o.destinationAddress), decision }, o.requestId === undefined ? undefined : id(o.requestId));
|
|
198
|
+
return service(c).decide(scope(o), id(o.tracking), { source_address: address(o.sourceAddress), destination_address: address(o.destinationAddress), decision }, o.requestId === undefined ? undefined : id(o.requestId, '--request-id'));
|
|
199
199
|
}, { permission: Permission.Update, options: [...selectedOptions, tracking, ...association, { flags: '--decision <state>', description: 'accepted, rejected or available', required: true }, request] }),
|
|
200
200
|
])];
|
|
201
201
|
}
|
package/dist/src/windbg.js
CHANGED
|
@@ -86,7 +86,7 @@ export function windbgCommands(workspace) {
|
|
|
86
86
|
if (Boolean(args.input) === Boolean(o.target))
|
|
87
87
|
fail('invalid', 'Supply exactly one dump path or --target.');
|
|
88
88
|
const nonce = randomUUID().replaceAll('-', ''), plan = windbgPlan(o, nonce), limit = number(o.limit ?? 200, 1000, 1), offset = number(o.offset ?? 0, 1000000), timeoutMs = number(o.timeoutSeconds ?? 30, 600, 1) * 1000;
|
|
89
|
-
const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target)), input = await w.artifacts.verify(target.input), header = Buffer.alloc(32), handle = await open(input, 'r');
|
|
89
|
+
const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target, '--target')), input = await w.artifacts.verify(target.input), header = Buffer.alloc(32), handle = await open(input, 'r');
|
|
90
90
|
try {
|
|
91
91
|
const { bytesRead } = await handle.read(header, 0, 32, 0);
|
|
92
92
|
if (bytesRead < 32 || header.subarray(0, 4).toString('ascii') !== 'MDMP')
|