feat(ghidra): implement read-only inventory operations

This commit is contained in:
N0zoM1z0
2026-07-16 02:59:37 +09:00
committed by N0zoM1z0
parent f0e625d7ee
commit b1c07dd9c6
101 changed files with 3825 additions and 377 deletions
+50
View File
@@ -13,12 +13,14 @@ export type GhidraSessionFailureKind =
/** Additional structured context for a Ghidra session failure. */
export interface GhidraSessionErrorOptions extends ErrorOptions {
readonly timeoutMs?: number;
readonly remoteCode?: string;
}
/** Provider-owned failure with bounded, token-redacted local diagnostics. */
export class GhidraSessionError extends Error {
readonly diagnostics: Readonly<Record<string, JsonValue>>;
readonly timeoutMs: number | undefined;
readonly remoteCode: string | undefined;
constructor(
readonly kind: GhidraSessionFailureKind,
@@ -30,5 +32,53 @@ export class GhidraSessionError extends Error {
this.name = "GhidraSessionError";
this.diagnostics = structuredClone(diagnostics);
this.timeoutMs = options.timeoutMs;
this.remoteCode = options.remoteCode;
}
}
/** Build a session failure while preserving bounded remote failure metadata. */
const createGhidraSessionError = (failure: {
readonly kind: GhidraSessionFailureKind;
readonly message: string;
readonly diagnostics: Readonly<Record<string, JsonValue>>;
readonly cause?: unknown;
readonly timeoutMs?: number;
readonly remoteCode?: string;
}): GhidraSessionError =>
new GhidraSessionError(
failure.kind,
failure.message,
failure.remoteCode === undefined
? failure.diagnostics
: {
...failure.diagnostics,
remote_code: failure.remoteCode,
remote_message: failure.message,
},
{
...(failure.cause === undefined ? {} : { cause: failure.cause }),
...(failure.timeoutMs === undefined
? {}
: { timeoutMs: failure.timeoutMs }),
...(failure.remoteCode === undefined
? {}
: { remoteCode: failure.remoteCode }),
},
);
/** Bind session-failure construction to a live, token-redacted diagnostic view. */
export const bindGhidraSessionFailure =
(diagnostics: () => Readonly<Record<string, JsonValue>>) =>
(
kind: GhidraSessionFailureKind,
message: string,
cause?: unknown,
options: Pick<GhidraSessionErrorOptions, "timeoutMs" | "remoteCode"> = {},
): GhidraSessionError =>
createGhidraSessionError({
kind,
message,
diagnostics: diagnostics(),
...(cause === undefined ? {} : { cause }),
...options,
});