diff --git a/src/cli/adbCommands.ts b/src/cli/adbCommands.ts index 2329b843728..05582503ad4 100644 --- a/src/cli/adbCommands.ts +++ b/src/cli/adbCommands.ts @@ -19,11 +19,11 @@ import type { CliContractProjection, ContractField, } from "./contractCliDescriptionTypes.js"; +import { registerContractCommand } from "./contractCommand.js"; import { analyzeWithService, - registerContractCommand, type EvidenceInspectionService, -} from "./contractCommand.js"; +} from "./contractCommandRunners.js"; type AdbContract = Extract< (typeof ADB_TOOL_CONTRACTS)[number], diff --git a/src/cli/apiContractCommand.ts b/src/cli/apiContractCommand.ts index a83b335ed19..fd1317d5394 100644 --- a/src/cli/apiContractCommand.ts +++ b/src/cli/apiContractCommand.ts @@ -10,11 +10,11 @@ import { API_CONTRACT_PROVIDER, } from "../domain/apiContract/apiContract.js"; import { contractNamed } from "./contractCliDescription.js"; +import { registerContractCommand } from "./contractCommand.js"; import { deliverWithService, - registerContractCommand, type EvidenceInspectionService, -} from "./contractCommand.js"; +} from "./contractCommandRunners.js"; /** Standard one-shot publication keeps complete inventory Evidence for later offline pages. */ export const registerApiContractCommand = ( diff --git a/src/cli/apkSignatureCommands.ts b/src/cli/apkSignatureCommands.ts index f4761c8d057..32e3d7e2d33 100644 --- a/src/cli/apkSignatureCommands.ts +++ b/src/cli/apkSignatureCommands.ts @@ -2,10 +2,8 @@ import type { Logger } from "pino"; import { APK_SIGNATURE_PROVIDER_IDENTITY } from "../apkSignature/ApkSignatureRelease.js"; import { apkSignatureModule } from "../composition/apkSignature.js"; -import { - deliverWithService, - registerContractCommand, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { deliverWithService } from "./contractCommandRunners.js"; import type { CliInstance } from "./types.js"; /** CLI shares selected delivery and complete-Evidence publication with other artifact tools. */ diff --git a/src/cli/apktoolCommands.ts b/src/cli/apktoolCommands.ts index 473c5ab886a..f171efba8fd 100644 --- a/src/cli/apktoolCommands.ts +++ b/src/cli/apktoolCommands.ts @@ -6,11 +6,11 @@ import { APKTOOL_TOOL_CONTRACTS } from "../contracts/apktool/apktoolToolContract import type { ApktoolOperation } from "../domain/apktool/apktoolResourceAnalysis.js"; import type { Logger } from "pino"; import { contractNamed } from "./contractCliDescription.js"; +import { registerContractCommand } from "./contractCommand.js"; import { analyzeWithService, - registerContractCommand, type EvidenceInspectionService, -} from "./contractCommand.js"; +} from "./contractCommandRunners.js"; import { finishCliEvidenceCommand } from "./cliEvidenceCallerPath.js"; import { projectCliAnalysisResult } from "./projectCliAnalysisResult.js"; import type { CliInstance } from "./types.js"; diff --git a/src/cli/artifactCommands.ts b/src/cli/artifactCommands.ts index cf98abfcc38..47a4973a164 100644 --- a/src/cli/artifactCommands.ts +++ b/src/cli/artifactCommands.ts @@ -2,10 +2,8 @@ import { ARTIFACT_TOOL_CONTRACTS } from "../contracts/artifactToolContracts.js"; import { OPEN_BINARY_TOOL_CONTRACT } from "../contracts/openBinaryToolContract.js"; import { contractNamed } from "./contractCliDescription.js"; import type { CliSessionTarget } from "./contractCliDescriptionTypes.js"; -import { - registerContractCommand, - runOnSessionTarget, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { runOnSessionTarget } from "./contractCommandRunners.js"; import type { DirectAnalysis } from "../composition/directAnalysis.js"; import { createArtifactExtractionDestination } from "../application/artifacts/ArtifactExtractionDestination.js"; diff --git a/src/cli/binaryDiagnosticsCommands.ts b/src/cli/binaryDiagnosticsCommands.ts index 42fa90918b0..9497537414e 100644 --- a/src/cli/binaryDiagnosticsCommands.ts +++ b/src/cli/binaryDiagnosticsCommands.ts @@ -7,10 +7,12 @@ import { BINARY_DIAGNOSTICS_TOOL_CONTRACTS } from "../contracts/native/binaryDia import { contractNamed } from "./contractCliDescription.js"; import { callerTargetPath, - deliverWithService, - inspectWithService, registerContractCommand, } from "./contractCommand.js"; +import { + deliverWithService, + inspectWithService, +} from "./contractCommandRunners.js"; import { PRODUCER_LIMITS_HELP } from "./producerLimitsOption.js"; type BinaryDiagnosticsOperation = diff --git a/src/cli/captureCommands.ts b/src/cli/captureCommands.ts index b15a2cc1bcd..e21a11813e5 100644 --- a/src/cli/captureCommands.ts +++ b/src/cli/captureCommands.ts @@ -4,11 +4,11 @@ import type { PacketCaptureService } from "../application/captures/PacketCapture import { createPacketCaptureService } from "../composition/captures.js"; import { CAPTURE_TOOL_CONTRACTS } from "../contracts/captures/captureToolContracts.js"; import { contractNamed } from "./contractCliDescription.js"; +import { registerContractCommand } from "./contractCommand.js"; import { analyzeWithService, inspectWithService, - registerContractCommand, -} from "./contractCommand.js"; +} from "./contractCommandRunners.js"; import { PRODUCER_LIMITS_HELP } from "./producerLimitsOption.js"; import type { CliInstance } from "./types.js"; diff --git a/src/cli/contractCommand.ts b/src/cli/contractCommand.ts index 0b27ca89143..6379c3307f3 100644 --- a/src/cli/contractCommand.ts +++ b/src/cli/contractCommand.ts @@ -4,28 +4,13 @@ import type { Logger } from "pino"; import { logCliCommand } from "../cliLogging.js"; import type { AnalysisError } from "../domain/analysisErrorBase.js"; -import { - AnalysisInputError, - AnalysisOutputError, -} from "../domain/analysisErrorCore.js"; -import type { AnalysisProviderSelector } from "../domain/providerSelection.js"; +import { AnalysisInputError } from "../domain/analysisErrorCore.js"; import { projectAnalysisError } from "../domain/analysisErrorProjection.js"; import { analysisInputErrorFromIssues } from "../domain/inputIssueProjection.js"; -import type { DirectAnalysis } from "../composition/directAnalysis.js"; -import type { CallerInputPaths, Evidence } from "../domain/evidence.js"; +import type { CallerInputPaths } from "../domain/evidence.js"; import type { JsonValue } from "../domain/jsonValue.js"; import { err, ok, type Result } from "../domain/result.js"; -import type { ArtifactAnalysisOperation } from "../contracts/artifactToolContracts.js"; -import { openBinaryTargetSelection } from "../contracts/sessionLifecycleInputs.js"; -import { - deliverCliAnalysisEvidence, - publishCliAnalysisEvidence, -} from "./analysisEvidenceDelivery.js"; -import { finishCliEvidenceCommand } from "./cliEvidenceCallerPath.js"; -import { finishAnalysisCommand } from "./finishAnalysisCommand.js"; import { withCommandCancellation } from "./commandCancellation.js"; -import { dispatchQueuedInterrupts } from "../process/queuedInterrupts.js"; -import { finalizedResult, runOwned } from "../providers/runOwned.js"; import { parseCliJsonInput } from "./cliJsonInput.js"; import { describeContractCommand, @@ -52,7 +37,6 @@ import { import { cliResultControlsIn, failurePartialObservation, - projectCliAnalysisResult, projectCliInputFields, } from "./projectCliAnalysisResult.js"; import { @@ -162,15 +146,6 @@ export interface CliEvidenceTargetSelection { }[]; } -/** A closeable one-shot service that inspects one contract input. */ -export interface EvidenceInspectionService { - inspect( - input: unknown, - options: { readonly signal: AbortSignal }, - ): Promise>; - close(): Promise; -} - /** The caller's spelling of the selected target `path`. */ export const callerTargetPath = ({ operation, @@ -182,181 +157,6 @@ export const callerTargetPath = ({ return path; }; -/** - * The caller's spelling of the primary caller-path field (`path` unless the - * command names another), and of each other caller-path field keyed by its - * contract field name. - */ -const callerSpellings = ( - context: ContractCommandContext, - primary = "path", -): { - readonly path: string; - readonly others: CallerInputPaths | undefined; -} => { - const { [primary]: path, ...others } = context.callerInputs; - if (typeof path !== "string") - throw new Error( - `${context.operation} has no caller path field named ${primary}`, - ); - return { - path, - others: Object.keys(others).length === 0 ? undefined : others, - }; -}; - -/** - * Inspect through a closeable service, finish its cleanup, and record the - * caller's spelling of each selected path in the Evidence; `primary` names - * the contract field recorded as the Evidence's caller input path. - */ -export const inspectWithService = - ( - service: () => - | EvidenceInspectionService - | Promise, - providerId: string, - primary = "path", - ) => - async (input: unknown, context: ContractCommandContext) => { - const spellings = callerSpellings(context, primary); - const owned = await service(); - return finishCliEvidenceCommand( - spellings.path, - () => owned.inspect(input, { signal: context.signal }), - owned, - providerId, - context.operation, - context.signal, - spellings.others, - ).then(projectCliAnalysisResult); - }; - -/** - * Open the session target as an MCP session would hold it, with the opening - * fields the caller selected, and run the contract operation on the - * remaining input. A projection with `evidenceDelivery` delivers complete - * Evidence or a summary beside its bundle. - */ -export const runOnSessionTarget = - ( - runProviderAnalysis: DirectAnalysis["runProviderAnalysis"], - logger: Logger, - ) => - async (input: object, context: ContractCommandContext) => { - const { sessionTarget, operation, signal, delivery, opening } = context; - if (sessionTarget === undefined) - throw new Error(`${operation} declares no session target`); - // Argv values are decoded text, and absent options are left out. - const values = input as Readonly>; - const result = await (Object.keys(opening).length === 0 - ? runProviderAnalysis( - sessionTarget, - operation as SessionTargetOperation, - values, - logger, - signal, - ) - : runProviderAnalysis( - sessionTarget, - // Only artifact operations take an opening selection. - operation as ArtifactAnalysisOperation, - values, - logger, - signal, - openBinaryTargetSelection(opening), - )); - if (delivery === undefined) return projectCliAnalysisResult(result); - return publishCliAnalysisEvidence(result, { - operation, - signal, - detail: delivery.detail, - evidenceOutput: delivery.evidenceOutput, - ...(delivery.view === undefined ? {} : { view: delivery.view }), - }); - }; - -/** Operations `runProviderAnalysis` runs on an opened session target. */ -type SessionTargetOperation = Parameters< - DirectAnalysis["runProviderAnalysis"] ->[1]; - -/** Operations `runDirectAnalysis` runs on a target it opens. */ -type DirectAnalysisOperation = Parameters< - DirectAnalysis["runDirectAnalysis"] ->[1]; - -/** - * The one-shot open the caller selected with `open_binary` fields: its - * target interpretation, provider and analysis snapshot. - */ -const directAnalysisOpening = ({ - provider_id: providerId, - snapshot_path: snapshotPath, - ...selection -}: Readonly>) => ({ - ...openBinaryTargetSelection(selection), - ...(providerId === undefined - ? {} - : { providerId: providerId as AnalysisProviderSelector }), - ...(snapshotPath === undefined - ? {} - : { snapshotPath: snapshotPath as string }), -}); - -/** - * Open the session target for one operation with the `open_binary` fields - * the caller selected, run it, and release the provider. A projection with - * `evidenceDelivery` delivers complete Evidence or a summary beside its - * bundle. `requireSourceEvidence` refuses a bundle whose composed result did - * not return the source Evidence it cites. - */ -export const runDirectOnTarget = - ( - runDirectAnalysis: DirectAnalysis["runDirectAnalysis"], - logger: Logger, - options: { readonly requireSourceEvidence?: true } = {}, - ) => - async (input: object, context: ContractCommandContext) => { - const { sessionTarget, operation, signal, delivery, opening } = context; - if (sessionTarget === undefined) - throw new Error(`${operation} declares no session target`); - const evidenceOutput = delivery?.evidenceOutput; - const result = await runDirectAnalysis( - sessionTarget, - operation as DirectAnalysisOperation, - // Argv values are decoded text, and absent options are left out. - input as Readonly>, - { - logger, - signal, - ...directAnalysisOpening(opening), - ...(evidenceOutput === undefined - ? {} - : { includeEvidenceSources: true }), - }, - ); - if (delivery === undefined) return projectCliAnalysisResult(result); - if ( - options.requireSourceEvidence === true && - result.ok && - evidenceOutput !== undefined && - result.sourceEvidence === undefined - ) - return projectAnalysisError( - new AnalysisOutputError( - operation, - "The CLI session did not return its source Evidence.", - ).retainPartialObservation(result.value), - ); - return publishCliAnalysisEvidence(result, { - operation, - signal, - detail: delivery.detail, - evidenceOutput, - }); - }; - /** * A command's output named for the CLI: renamed issue paths and failure * flags (`projectCliInputFields`), and the flags of controls its result @@ -385,147 +185,6 @@ export const projectCliResult = ( return projectCliInputFields(output, binding); }; -/** - * Run the source contract on each Evidence target in argv order with the - * source fields the caller selected, then compose the contract from that - * Evidence. A target's failure names its positional; any failure retains - * each completed target's Evidence under its contract field beside the - * failure's own partial observation. - */ -export const runOnEvidenceTargets = - ( - runSource: ( - target: string, - parameters: Readonly>, - signal: AbortSignal, - ) => Promise>, - compose: ( - input: Readonly>, - context: ContractCommandContext & { - readonly evidenceTargets: CliEvidenceTargetSelection; - }, - ) => Promise>, - ) => - async (input: object, context: ContractCommandContext) => { - const { evidenceTargets, operation, signal } = context; - if (evidenceTargets === undefined) - throw new Error(`${operation} declares no Evidence targets`); - // Argv values are decoded text, and absent options are left out. - const parameters = context.opening as Readonly>; - const sources: Record = {}; - const retainSources = (failure: AnalysisError) => { - for (const [field, evidence] of Object.entries(sources)) - failure.retainArgumentObservation(field, evidence); - return failure; - }; - for (const { field, key, target } of evidenceTargets.targets) { - const source = await runSource(target, parameters, signal); - if (!source.ok) - return projectCliInputFields( - { - error: "Analysis failed", - ...projectAnalysisError(retainSources(source.error), "invocation"), - }, - { - operation: evidenceTargets.source, - fields: { path: key }, - flags: evidenceTargets.sourceFlags, - }, - ); - sources[field] = source.value; - } - // A cancellation that arrives as the composition settles keeps its - // most complete Evidence. The composition owns no resource of its own, - // so its close only lets queued interrupts reach the signal first. - const result = finalizedResult( - await runOwned( - async (): Promise> => { - try { - return await compose( - { ...input, ...sources }, - { ...context, evidenceTargets }, - ); - } catch (cause: unknown) { - // The completed source Evidence outlives a defect in the composition. - return { - ok: false, - error: new AnalysisOutputError( - operation, - `${operation} produced invalid output`, - { cause }, - ), - }; - } - }, - { - providerId: evidenceTargets.source, - operation, - signal, - close: dispatchQueuedInterrupts, - partial: (value) => value, - }, - ), - ); - if (result.ok) return result.value; - return { - error: "Analysis failed", - ...projectAnalysisError(retainSources(result.error), "invocation"), - }; - }; - -/** - * Run an analysis that selects no target path through a closeable service - * and finish its cleanup. - */ -export const analyzeWithService = - (service: () => EvidenceInspectionService, providerId: string) => - (input: unknown, context: ContractCommandContext) => { - if (Object.keys(context.callerInputs).length > 0) - throw new Error(`${context.operation} selects a caller path`); - const owned = service(); - return finishAnalysisCommand( - () => owned.inspect(input, { signal: context.signal }), - owned, - providerId, - context.operation, - context.signal, - ).then(projectCliAnalysisResult); - }; - -/** - * Inspect through a closeable service, then deliver complete Evidence or a - * summary with its bundle, recording the caller's spelling of each selected - * path. - */ -export const deliverWithService = - ( - service: () => - | EvidenceInspectionService - | Promise, - providerId: string, - ) => - async (input: unknown, context: ContractCommandContext) => { - const spellings = callerSpellings(context); - const { delivery } = context; - if (delivery === undefined) - throw new Error(`${context.operation} does not declare evidenceDelivery`); - const owned = await service(); - return deliverCliAnalysisEvidence({ - callerInputPath: spellings.path, - ...(spellings.others === undefined - ? {} - : { callerInputPaths: spellings.others }), - run: () => owned.inspect(input, { signal: context.signal }), - service: owned, - providerId, - operation: context.operation, - signal: context.signal, - detail: delivery.detail, - evidenceOutput: delivery.evidenceOutput, - ...(delivery.view === undefined ? {} : { view: delivery.view }), - }); - }; - /** * The session target's opening fields, or the Evidence targets' source * fields, when the command declares any. diff --git a/src/cli/contractCommandRunners.ts b/src/cli/contractCommandRunners.ts new file mode 100644 index 00000000000..6599dd5e4b0 --- /dev/null +++ b/src/cli/contractCommandRunners.ts @@ -0,0 +1,353 @@ +import type { Logger } from "pino"; + +import type { DirectAnalysis } from "../composition/directAnalysis.js"; +import type { ArtifactAnalysisOperation } from "../contracts/artifactToolContracts.js"; +import { openBinaryTargetSelection } from "../contracts/sessionLifecycleInputs.js"; +import type { AnalysisError } from "../domain/analysisErrorBase.js"; +import { AnalysisOutputError } from "../domain/analysisErrorCore.js"; +import { projectAnalysisError } from "../domain/analysisErrorProjection.js"; +import type { CallerInputPaths, Evidence } from "../domain/evidence.js"; +import type { JsonValue } from "../domain/jsonValue.js"; +import type { AnalysisProviderSelector } from "../domain/providerSelection.js"; +import type { Result } from "../domain/result.js"; +import { dispatchQueuedInterrupts } from "../process/queuedInterrupts.js"; +import { finalizedResult, runOwned } from "../providers/runOwned.js"; +import { + deliverCliAnalysisEvidence, + publishCliAnalysisEvidence, +} from "./analysisEvidenceDelivery.js"; +import { finishCliEvidenceCommand } from "./cliEvidenceCallerPath.js"; +import type { + CliEvidenceTargetSelection, + ContractCommandContext, +} from "./contractCommand.js"; +import { finishAnalysisCommand } from "./finishAnalysisCommand.js"; +import { + projectCliAnalysisResult, + projectCliInputFields, +} from "./projectCliAnalysisResult.js"; + +/** A closeable one-shot service that inspects one contract input. */ +export interface EvidenceInspectionService { + inspect( + input: unknown, + options: { readonly signal: AbortSignal }, + ): Promise>; + close(): Promise; +} + +/** + * The caller's spelling of the primary caller-path field (`path` unless the + * command names another), and of each other caller-path field keyed by its + * contract field name. + */ +const callerSpellings = ( + context: ContractCommandContext, + primary = "path", +): { + readonly path: string; + readonly others: CallerInputPaths | undefined; +} => { + const { [primary]: path, ...others } = context.callerInputs; + if (typeof path !== "string") + throw new Error( + `${context.operation} has no caller path field named ${primary}`, + ); + return { + path, + others: Object.keys(others).length === 0 ? undefined : others, + }; +}; + +/** + * Inspect through a closeable service, finish its cleanup, and record the + * caller's spelling of each selected path in the Evidence; `primary` names + * the contract field recorded as the Evidence's caller input path. + */ +export const inspectWithService = + ( + service: () => + | EvidenceInspectionService + | Promise, + providerId: string, + primary = "path", + ) => + async (input: unknown, context: ContractCommandContext) => { + const spellings = callerSpellings(context, primary); + const owned = await service(); + return finishCliEvidenceCommand( + spellings.path, + () => owned.inspect(input, { signal: context.signal }), + owned, + providerId, + context.operation, + context.signal, + spellings.others, + ).then(projectCliAnalysisResult); + }; + +/** + * Open the session target as an MCP session would hold it, with the opening + * fields the caller selected, and run the contract operation on the + * remaining input. A projection with `evidenceDelivery` delivers complete + * Evidence or a summary beside its bundle. + */ +export const runOnSessionTarget = + ( + runProviderAnalysis: DirectAnalysis["runProviderAnalysis"], + logger: Logger, + ) => + async (input: object, context: ContractCommandContext) => { + const { sessionTarget, operation, signal, delivery, opening } = context; + if (sessionTarget === undefined) + throw new Error(`${operation} declares no session target`); + // Argv values are decoded text, and absent options are left out. + const values = input as Readonly>; + const result = await (Object.keys(opening).length === 0 + ? runProviderAnalysis( + sessionTarget, + operation as SessionTargetOperation, + values, + logger, + signal, + ) + : runProviderAnalysis( + sessionTarget, + // Only artifact operations take an opening selection. + operation as ArtifactAnalysisOperation, + values, + logger, + signal, + openBinaryTargetSelection(opening), + )); + if (delivery === undefined) return projectCliAnalysisResult(result); + return publishCliAnalysisEvidence(result, { + operation, + signal, + detail: delivery.detail, + evidenceOutput: delivery.evidenceOutput, + ...(delivery.view === undefined ? {} : { view: delivery.view }), + }); + }; + +/** Operations `runProviderAnalysis` runs on an opened session target. */ +type SessionTargetOperation = Parameters< + DirectAnalysis["runProviderAnalysis"] +>[1]; + +/** Operations `runDirectAnalysis` runs on a target it opens. */ +type DirectAnalysisOperation = Parameters< + DirectAnalysis["runDirectAnalysis"] +>[1]; + +/** + * The one-shot open the caller selected with `open_binary` fields: its + * target interpretation, provider and analysis snapshot. + */ +const directAnalysisOpening = ({ + provider_id: providerId, + snapshot_path: snapshotPath, + ...selection +}: Readonly>) => ({ + ...openBinaryTargetSelection(selection), + ...(providerId === undefined + ? {} + : { providerId: providerId as AnalysisProviderSelector }), + ...(snapshotPath === undefined + ? {} + : { snapshotPath: snapshotPath as string }), +}); + +/** + * Open the session target for one operation with the `open_binary` fields + * the caller selected, run it, and release the provider. A projection with + * `evidenceDelivery` delivers complete Evidence or a summary beside its + * bundle. `requireSourceEvidence` refuses a bundle whose composed result did + * not return the source Evidence it cites. + */ +export const runDirectOnTarget = + ( + runDirectAnalysis: DirectAnalysis["runDirectAnalysis"], + logger: Logger, + options: { readonly requireSourceEvidence?: true } = {}, + ) => + async (input: object, context: ContractCommandContext) => { + const { sessionTarget, operation, signal, delivery, opening } = context; + if (sessionTarget === undefined) + throw new Error(`${operation} declares no session target`); + const evidenceOutput = delivery?.evidenceOutput; + const result = await runDirectAnalysis( + sessionTarget, + operation as DirectAnalysisOperation, + // Argv values are decoded text, and absent options are left out. + input as Readonly>, + { + logger, + signal, + ...directAnalysisOpening(opening), + ...(evidenceOutput === undefined + ? {} + : { includeEvidenceSources: true }), + }, + ); + if (delivery === undefined) return projectCliAnalysisResult(result); + if ( + options.requireSourceEvidence === true && + result.ok && + evidenceOutput !== undefined && + result.sourceEvidence === undefined + ) + return projectAnalysisError( + new AnalysisOutputError( + operation, + "The CLI session did not return its source Evidence.", + ).retainPartialObservation(result.value), + ); + return publishCliAnalysisEvidence(result, { + operation, + signal, + detail: delivery.detail, + evidenceOutput, + }); + }; + +/** + * Run the source contract on each Evidence target in argv order with the + * source fields the caller selected, then compose the contract from that + * Evidence. A target's failure names its positional; any failure retains + * each completed target's Evidence under its contract field beside the + * failure's own partial observation. + */ +export const runOnEvidenceTargets = + ( + runSource: ( + target: string, + parameters: Readonly>, + signal: AbortSignal, + ) => Promise>, + compose: ( + input: Readonly>, + context: ContractCommandContext & { + readonly evidenceTargets: CliEvidenceTargetSelection; + }, + ) => Promise>, + ) => + async (input: object, context: ContractCommandContext) => { + const { evidenceTargets, operation, signal } = context; + if (evidenceTargets === undefined) + throw new Error(`${operation} declares no Evidence targets`); + // Argv values are decoded text, and absent options are left out. + const parameters = context.opening as Readonly>; + const sources: Record = {}; + const retainSources = (failure: AnalysisError) => { + for (const [field, evidence] of Object.entries(sources)) + failure.retainArgumentObservation(field, evidence); + return failure; + }; + for (const { field, key, target } of evidenceTargets.targets) { + const source = await runSource(target, parameters, signal); + if (!source.ok) + return projectCliInputFields( + { + error: "Analysis failed", + ...projectAnalysisError(retainSources(source.error), "invocation"), + }, + { + operation: evidenceTargets.source, + fields: { path: key }, + flags: evidenceTargets.sourceFlags, + }, + ); + sources[field] = source.value; + } + // A cancellation that arrives as the composition settles keeps its + // most complete Evidence. The composition owns no resource of its own, + // so its close only lets queued interrupts reach the signal first. + const result = finalizedResult( + await runOwned( + async (): Promise> => { + try { + return await compose( + { ...input, ...sources }, + { ...context, evidenceTargets }, + ); + } catch (cause: unknown) { + // The completed source Evidence outlives a defect in the composition. + return { + ok: false, + error: new AnalysisOutputError( + operation, + `${operation} produced invalid output`, + { cause }, + ), + }; + } + }, + { + providerId: evidenceTargets.source, + operation, + signal, + close: dispatchQueuedInterrupts, + partial: (value) => value, + }, + ), + ); + if (result.ok) return result.value; + return { + error: "Analysis failed", + ...projectAnalysisError(retainSources(result.error), "invocation"), + }; + }; + +/** + * Run an analysis that selects no target path through a closeable service + * and finish its cleanup. + */ +export const analyzeWithService = + (service: () => EvidenceInspectionService, providerId: string) => + (input: unknown, context: ContractCommandContext) => { + if (Object.keys(context.callerInputs).length > 0) + throw new Error(`${context.operation} selects a caller path`); + const owned = service(); + return finishAnalysisCommand( + () => owned.inspect(input, { signal: context.signal }), + owned, + providerId, + context.operation, + context.signal, + ).then(projectCliAnalysisResult); + }; + +/** + * Inspect through a closeable service, then deliver complete Evidence or a + * summary with its bundle, recording the caller's spelling of each selected + * path. + */ +export const deliverWithService = + ( + service: () => + | EvidenceInspectionService + | Promise, + providerId: string, + ) => + async (input: unknown, context: ContractCommandContext) => { + const spellings = callerSpellings(context); + const { delivery } = context; + if (delivery === undefined) + throw new Error(`${context.operation} does not declare evidenceDelivery`); + const owned = await service(); + return deliverCliAnalysisEvidence({ + callerInputPath: spellings.path, + ...(spellings.others === undefined + ? {} + : { callerInputPaths: spellings.others }), + run: () => owned.inspect(input, { signal: context.signal }), + service: owned, + providerId, + operation: context.operation, + signal: context.signal, + detail: delivery.detail, + evidenceOutput: delivery.evidenceOutput, + ...(delivery.view === undefined ? {} : { view: delivery.view }), + }); + }; diff --git a/src/cli/coreBinaryCommands.ts b/src/cli/coreBinaryCommands.ts index cd189f6fe8f..18c23bf383c 100644 --- a/src/cli/coreBinaryCommands.ts +++ b/src/cli/coreBinaryCommands.ts @@ -21,10 +21,8 @@ import { registerDecompileDirectoryCommand } from "./decompileDirectoryCommand.j import { OFFICIAL_TOOL_CONTRACTS } from "../contracts/officialToolContracts.js"; import { ENHANCED_TOOL_CONTRACTS } from "../contracts/enhancedToolContracts.js"; import { ELECTRON_TOOL_CONTRACTS } from "../contracts/javascript/electronToolContracts.js"; -import { - registerContractCommand, - runDirectOnTarget, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { runDirectOnTarget } from "./contractCommandRunners.js"; import { commandRoute, registerRoutedCommand, diff --git a/src/cli/coreNativeCommands.ts b/src/cli/coreNativeCommands.ts index eb2cd268e3f..610244c7f1e 100644 --- a/src/cli/coreNativeCommands.ts +++ b/src/cli/coreNativeCommands.ts @@ -11,10 +11,8 @@ import type { CliInstance } from "./types.js"; import { contractNamed } from "./contractCliDescription.js"; import { ENHANCED_TOOL_CONTRACTS } from "../contracts/enhancedToolContracts.js"; import { OFFICIAL_TOOL_CONTRACTS } from "../contracts/officialToolContracts.js"; -import { - registerContractCommand, - runDirectOnTarget, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { runDirectOnTarget } from "./contractCommandRunners.js"; const executable = nativeTarget("Local executable path"); const nativeApplication = nativeTarget("Local native executable or app path"); diff --git a/src/cli/cutterCommands.ts b/src/cli/cutterCommands.ts index 7fc3403ac22..cbae31a09b4 100644 --- a/src/cli/cutterCommands.ts +++ b/src/cli/cutterCommands.ts @@ -3,10 +3,8 @@ import type { Logger } from "pino"; import { createCutterBridgeService } from "../composition/cutter.js"; import { CUTTER_TOOL_CONTRACTS } from "../contracts/cutterToolContracts.js"; import { contractNamed } from "./contractCliDescription.js"; -import { - analyzeWithService, - registerContractCommand, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { analyzeWithService } from "./contractCommandRunners.js"; import { finishAnalysisCommand } from "./finishAnalysisCommand.js"; import { projectCliAnalysisResult } from "./projectCliAnalysisResult.js"; import type { CliInstance } from "./types.js"; diff --git a/src/cli/decompileDirectoryCommand.ts b/src/cli/decompileDirectoryCommand.ts index aafe2121e63..84487e0b658 100644 --- a/src/cli/decompileDirectoryCommand.ts +++ b/src/cli/decompileDirectoryCommand.ts @@ -2,10 +2,8 @@ import { contractNamed } from "./contractCliDescription.js"; import type { Logger } from "pino"; import { ENHANCED_TOOL_CONTRACTS } from "../contracts/enhancedToolContracts.js"; -import { - registerContractCommand, - type runDirectOnTarget, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import type { runDirectOnTarget } from "./contractCommandRunners.js"; import { nativeTarget } from "./nativeTargetOption.js"; import type { CliInstance } from "./types.js"; diff --git a/src/cli/desktopApplicationCommands.ts b/src/cli/desktopApplicationCommands.ts index ff4a2de59ad..9adf16b7a5b 100644 --- a/src/cli/desktopApplicationCommands.ts +++ b/src/cli/desktopApplicationCommands.ts @@ -3,10 +3,8 @@ import type { Logger } from "pino"; import { createDesktopApplicationService } from "../composition/desktop.js"; import { DESKTOP_APPLICATION_TOOL_CONTRACTS } from "../contracts/desktopApplicationToolContracts.js"; import { contractNamed } from "./contractCliDescription.js"; -import { - deliverWithService, - registerContractCommand, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { deliverWithService } from "./contractCommandRunners.js"; import type { CliInstance } from "./types.js"; /** One-shot complete Evidence can be saved and queried with inspect-analysis-view. */ diff --git a/src/cli/electronCommands.ts b/src/cli/electronCommands.ts index 546038b1f6c..7a59f0828fc 100644 --- a/src/cli/electronCommands.ts +++ b/src/cli/electronCommands.ts @@ -8,10 +8,10 @@ import { ELECTRON_TOOL_CONTRACTS } from "../contracts/javascript/electronToolCon import { contractNamed } from "./contractCliDescription.js"; import { admittedContractInput, - inspectWithService, registerContractCommand, type ContractCommandContext, } from "./contractCommand.js"; +import { inspectWithService } from "./contractCommandRunners.js"; import type { AnalysisError } from "../domain/analysisErrorBase.js"; import type { Evidence } from "../domain/evidence.js"; import type { Result } from "../domain/result.js"; diff --git a/src/cli/erlangCommands.ts b/src/cli/erlangCommands.ts index 064af79c655..22cd857c138 100644 --- a/src/cli/erlangCommands.ts +++ b/src/cli/erlangCommands.ts @@ -3,10 +3,8 @@ import type { Logger } from "pino"; import { createBeamService } from "../composition/erlang.js"; import { ERLANG_BEAM_TOOL_CONTRACTS } from "../contracts/erlang/beamToolContracts.js"; import { contractNamed } from "./contractCliDescription.js"; -import { - deliverWithService, - registerContractCommand, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { deliverWithService } from "./contractCommandRunners.js"; import type { CliInstance } from "./types.js"; /** Inspect operator-selected BEAM files through the same shared workflow as MCP. */ diff --git a/src/cli/evmCommands.ts b/src/cli/evmCommands.ts index 2aee2358d67..ce8bca60c0d 100644 --- a/src/cli/evmCommands.ts +++ b/src/cli/evmCommands.ts @@ -1,10 +1,8 @@ import type { Logger } from "pino"; import { evmInterfaceModule } from "../composition/evm.js"; -import { - inspectWithService, - registerContractCommand, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { inspectWithService } from "./contractCommandRunners.js"; import { PRODUCER_LIMITS_HELP } from "./producerLimitsOption.js"; import type { CliInstance } from "./types.js"; diff --git a/src/cli/firmwareCommands.ts b/src/cli/firmwareCommands.ts index 9f67dfd5502..4213929fff7 100644 --- a/src/cli/firmwareCommands.ts +++ b/src/cli/firmwareCommands.ts @@ -6,10 +6,8 @@ import { FIRMWARE_TOOL_CONTRACTS } from "../contracts/firmware/firmwareToolContr import { FIRMWARE_OPERATION_ENGINES } from "../contracts/firmware/firmwareToolRequirements.js"; import type { FirmwareOperation } from "../domain/firmware/firmwareAnalysis.js"; import { contractNamed } from "./contractCliDescription.js"; -import { - inspectWithService, - registerContractCommand, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { inspectWithService } from "./contractCommandRunners.js"; import type { CliInstance } from "./types.js"; const FIRMWARE_PATH_HELP = "Local firmware path; never executed"; diff --git a/src/cli/goCommands.ts b/src/cli/goCommands.ts index 1aa7e0e5a7e..37057e35e4f 100644 --- a/src/cli/goCommands.ts +++ b/src/cli/goCommands.ts @@ -3,10 +3,8 @@ import type { Logger } from "pino"; import { createGoBinaryService } from "../composition/go.js"; import { GO_TOOL_CONTRACTS } from "../contracts/go/goToolContracts.js"; import { contractNamed } from "./contractCliDescription.js"; -import { - deliverWithService, - registerContractCommand, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { deliverWithService } from "./contractCommandRunners.js"; import type { CliInstance } from "./types.js"; /** Resolve caller paths and inspect static build metadata through the shared workflow. */ diff --git a/src/cli/gpuCommands.ts b/src/cli/gpuCommands.ts index fab2168c973..9e3ec4ca318 100644 --- a/src/cli/gpuCommands.ts +++ b/src/cli/gpuCommands.ts @@ -3,10 +3,8 @@ import type { Logger } from "pino"; import { createGpuCodeObjectsService } from "../composition/gpu.js"; import { GPU_TOOL_CONTRACTS } from "../contracts/gpu/gpuToolContracts.js"; import { contractNamed } from "./contractCliDescription.js"; -import { - deliverWithService, - registerContractCommand, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { deliverWithService } from "./contractCommandRunners.js"; import type { CliInstance } from "./types.js"; /** One-shot summaries export the same complete observations used by MCP retained pages. */ diff --git a/src/cli/il2cppCommands.ts b/src/cli/il2cppCommands.ts index 8664092d38e..66ad4d63ced 100644 --- a/src/cli/il2cppCommands.ts +++ b/src/cli/il2cppCommands.ts @@ -8,10 +8,8 @@ import { localPathStringSchema } from "../domain/localPath.js"; import { err } from "../domain/result.js"; import { absoluteCallerPath } from "../filesystem/callerPath.js"; import { contractNamed } from "./contractCliDescription.js"; -import { - deliverWithService, - registerContractCommand, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { deliverWithService } from "./contractCommandRunners.js"; import type { CliInstance } from "./types.js"; /** diff --git a/src/cli/jebCommands.ts b/src/cli/jebCommands.ts index 9ff79ba89b9..6c0a9f78d4b 100644 --- a/src/cli/jebCommands.ts +++ b/src/cli/jebCommands.ts @@ -6,11 +6,11 @@ import type { JebOperation } from "../domain/jeb/jebAnalysis.js"; import type { Logger } from "pino"; import type { CliInstance } from "./types.js"; import { contractNamed } from "./contractCliDescription.js"; +import { registerContractCommand } from "./contractCommand.js"; import { analyzeWithService, - registerContractCommand, type EvidenceInspectionService, -} from "./contractCommand.js"; +} from "./contractCommandRunners.js"; import { finishCliEvidenceCommand } from "./cliEvidenceCallerPath.js"; import { projectCliAnalysisResult } from "./projectCliAnalysisResult.js"; diff --git a/src/cli/managedCommands.ts b/src/cli/managedCommands.ts index 6502177e38d..3a8c4b8a7e3 100644 --- a/src/cli/managedCommands.ts +++ b/src/cli/managedCommands.ts @@ -7,11 +7,11 @@ import { projectManagedApplicationGraphEvidence } from "../application/managed/M import type { EvidenceLookup } from "../application/EvidenceInputResolver.js"; import { MANAGED_WORKFLOW_TOOL_CONTRACTS } from "../contracts/managed/managedWorkflowToolContracts.js"; import { contractNamed } from "./contractCliDescription.js"; +import { registerContractCommand } from "./contractCommand.js"; import { - registerContractCommand, runOnEvidenceTargets, runOnSessionTarget, -} from "./contractCommand.js"; +} from "./contractCommandRunners.js"; import type { DirectAnalysis } from "../composition/directAnalysis.js"; import { ok } from "../domain/result.js"; import { diff --git a/src/cli/mavenGradleMetadataCommands.ts b/src/cli/mavenGradleMetadataCommands.ts index d2a910068fe..6ea28b42541 100644 --- a/src/cli/mavenGradleMetadataCommands.ts +++ b/src/cli/mavenGradleMetadataCommands.ts @@ -3,10 +3,8 @@ import type { Logger } from "pino"; import { createMavenGradleMetadataService } from "../composition/mavenGradleMetadata.js"; import { MAVEN_GRADLE_METADATA_TOOL_CONTRACTS } from "../contracts/java/mavenGradleMetadataToolContracts.js"; import { contractNamed } from "./contractCliDescription.js"; -import { - inspectWithService, - registerContractCommand, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { inspectWithService } from "./contractCommandRunners.js"; import type { CliInstance } from "./types.js"; /** Inspect operator-selected POM or module metadata through the same shared workflow as MCP. */ diff --git a/src/cli/modelCommands.ts b/src/cli/modelCommands.ts index 56fcee88234..8681f16ce0d 100644 --- a/src/cli/modelCommands.ts +++ b/src/cli/modelCommands.ts @@ -2,10 +2,8 @@ import type { Logger } from "pino"; import { createModelArtifactService } from "../composition/model.js"; import { INSPECT_MODEL_ARTIFACT_CONTRACT } from "../contracts/model/modelToolContracts.js"; -import { - deliverWithService, - registerContractCommand, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { deliverWithService } from "./contractCommandRunners.js"; import type { CliInstance } from "./types.js"; /** One-shot summaries export the same complete observations used by MCP retained pages. */ diff --git a/src/cli/ntfsJournalCommand.ts b/src/cli/ntfsJournalCommand.ts index a7d4be9bfd8..a46956a538d 100644 --- a/src/cli/ntfsJournalCommand.ts +++ b/src/cli/ntfsJournalCommand.ts @@ -10,11 +10,11 @@ import { NTFS_JOURNAL_PROVIDER, } from "../domain/windows/ntfsJournalQuery.js"; import { contractNamed } from "./contractCliDescription.js"; +import { registerContractCommand } from "./contractCommand.js"; import { inspectWithService, - registerContractCommand, type EvidenceInspectionService, -} from "./contractCommand.js"; +} from "./contractCommandRunners.js"; import type { CliInstance } from "./types.js"; export const registerNtfsJournalCommand = ( diff --git a/src/cli/nugetNupkgCommands.ts b/src/cli/nugetNupkgCommands.ts index d06d8f4d0a1..65415ab35ed 100644 --- a/src/cli/nugetNupkgCommands.ts +++ b/src/cli/nugetNupkgCommands.ts @@ -3,10 +3,8 @@ import type { Logger } from "pino"; import { createNugetNupkgService } from "../composition/nugetNupkg.js"; import { NUGET_NUPKG_TOOL_CONTRACTS } from "../contracts/nuget/nupkgToolContracts.js"; import { contractNamed } from "./contractCliDescription.js"; -import { - deliverWithService, - registerContractCommand, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { deliverWithService } from "./contractCommandRunners.js"; import type { CliInstance } from "./types.js"; /** Inspect operator-selected NuGet packages through the same shared workflow as MCP. */ diff --git a/src/cli/pcapCommands.ts b/src/cli/pcapCommands.ts index 0b4a904b701..3f3db095510 100644 --- a/src/cli/pcapCommands.ts +++ b/src/cli/pcapCommands.ts @@ -7,12 +7,12 @@ import { createPcapAnalysisProvider } from "../composition/pcap.js"; import { PCAP_TOOL_CONTRACTS } from "../contracts/pcap/pcapToolContracts.js"; import type { PcapOperation } from "../domain/pcap/pcapAnalysis.js"; import { contractNamed } from "./contractCliDescription.js"; +import { registerContractCommand } from "./contractCommand.js"; import { analyzeWithService, inspectWithService, - registerContractCommand, type EvidenceInspectionService, -} from "./contractCommand.js"; +} from "./contractCommandRunners.js"; import type { CliInstance } from "./types.js"; /** Expose the same explicit pcap requests through one-shot CLI commands. */ diff --git a/src/cli/playwrightTraceCommand.ts b/src/cli/playwrightTraceCommand.ts index e0596315056..42d260f047f 100644 --- a/src/cli/playwrightTraceCommand.ts +++ b/src/cli/playwrightTraceCommand.ts @@ -10,11 +10,11 @@ import { PLAYWRIGHT_TRACE_PROVIDER, } from "../domain/playwrightTrace/playwrightTrace.js"; import { contractNamed } from "./contractCliDescription.js"; +import { registerContractCommand } from "./contractCommand.js"; import { deliverWithService, - registerContractCommand, type EvidenceInspectionService, -} from "./contractCommand.js"; +} from "./contractCommandRunners.js"; import type { CliInstance } from "./types.js"; /** Standard one-shot publication keeps complete inventory Evidence for later offline pages. */ diff --git a/src/cli/pythonPycCommands.ts b/src/cli/pythonPycCommands.ts index fae015251f7..1a83f155621 100644 --- a/src/cli/pythonPycCommands.ts +++ b/src/cli/pythonPycCommands.ts @@ -3,10 +3,8 @@ import type { Logger } from "pino"; import { createPythonPycService } from "../composition/pythonPyc.js"; import { PYTHON_PYC_TOOL_CONTRACTS } from "../contracts/python/pythonPycToolContracts.js"; import { contractNamed } from "./contractCliDescription.js"; -import { - deliverWithService, - registerContractCommand, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { deliverWithService } from "./contractCommandRunners.js"; import type { CliInstance } from "./types.js"; /** Inspect operator-selected pyc files through the same shared workflow as MCP. */ diff --git a/src/cli/releaseExposureCommands.ts b/src/cli/releaseExposureCommands.ts index 1bba9c771eb..e2fcea9f1f0 100644 --- a/src/cli/releaseExposureCommands.ts +++ b/src/cli/releaseExposureCommands.ts @@ -8,10 +8,8 @@ import { releaseExposureReportSchema, } from "../domain/releaseExposure.js"; import { contractNamed } from "./contractCliDescription.js"; -import { - inspectWithService, - registerContractCommand, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { inspectWithService } from "./contractCommandRunners.js"; import type { CliInstance } from "./types.js"; /** Report what static analysis recovers from one shipped artifact. */ diff --git a/src/cli/rustCommands.ts b/src/cli/rustCommands.ts index f4ed35567c3..59023b5b097 100644 --- a/src/cli/rustCommands.ts +++ b/src/cli/rustCommands.ts @@ -3,10 +3,8 @@ import type { Logger } from "pino"; import { createRustBinaryService } from "../composition/rust.js"; import { RUST_TOOL_CONTRACTS } from "../contracts/rust/rustToolContracts.js"; import { contractNamed } from "./contractCliDescription.js"; -import { - deliverWithService, - registerContractCommand, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { deliverWithService } from "./contractCommandRunners.js"; import { PRODUCER_LIMITS_HELP } from "./producerLimitsOption.js"; import type { CliInstance } from "./types.js"; diff --git a/src/cli/signalCommands.ts b/src/cli/signalCommands.ts index 64638631e33..f98674132d1 100644 --- a/src/cli/signalCommands.ts +++ b/src/cli/signalCommands.ts @@ -4,11 +4,11 @@ import type { SignalRecordingService } from "../application/signals/SignalRecord import { createSignalRecordingService } from "../composition/signals.js"; import { SIGNAL_TOOL_CONTRACTS } from "../contracts/signals/signalToolContracts.js"; import { contractNamed } from "./contractCliDescription.js"; +import { registerContractCommand } from "./contractCommand.js"; import { analyzeWithService, inspectWithService, - registerContractCommand, -} from "./contractCommand.js"; +} from "./contractCommandRunners.js"; import { PRODUCER_LIMITS_HELP } from "./producerLimitsOption.js"; import type { CliInstance } from "./types.js"; diff --git a/src/cli/sqliteCommands.ts b/src/cli/sqliteCommands.ts index 34ec154d2bb..04a222c5b32 100644 --- a/src/cli/sqliteCommands.ts +++ b/src/cli/sqliteCommands.ts @@ -3,10 +3,8 @@ import type { Logger } from "pino"; import { createSqliteDatabaseService } from "../composition/sqlite.js"; import { SQLITE_TOOL_CONTRACTS } from "../contracts/sqlite/sqliteToolContracts.js"; import { contractNamed } from "./contractCliDescription.js"; -import { - inspectWithService, - registerContractCommand, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { inspectWithService } from "./contractCommandRunners.js"; import type { CliInstance } from "./types.js"; /** Resolve an operator-selected SQLite snapshot through the shared inspection workflow. */ diff --git a/src/cli/uefiCommands.ts b/src/cli/uefiCommands.ts index abc2be601e4..4eb355737c1 100644 --- a/src/cli/uefiCommands.ts +++ b/src/cli/uefiCommands.ts @@ -9,10 +9,8 @@ import { projectAnalysisError } from "../domain/analysisErrorProjection.js"; import type { UefiOperation } from "../domain/uefi/uefiFirmwareAnalysis.js"; import { UEFI_PROVIDER_IDENTITY } from "../uefi/UefiProviderIdentity.js"; import { contractNamed } from "./contractCliDescription.js"; -import { - inspectWithService, - registerContractCommand, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { inspectWithService } from "./contractCommandRunners.js"; import { cliDecimalField } from "./options.js"; import type { CliInstance } from "./types.js"; diff --git a/src/cli/utilityCommands.ts b/src/cli/utilityCommands.ts index c734b0f5841..41938ad2465 100644 --- a/src/cli/utilityCommands.ts +++ b/src/cli/utilityCommands.ts @@ -32,10 +32,8 @@ import { registerCliCommand } from "./commandRegistry.js"; import type { CliInstance } from "./types.js"; import { registerNativeCallCommands } from "./nativeCallCommands.js"; import { NATIVE_TOOL_CONTRACTS } from "../contracts/native/nativeToolContracts.js"; -import { - registerContractCommand, - runOnSessionTarget, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { runOnSessionTarget } from "./contractCommandRunners.js"; export const registerUtilityCommands = ( cli: CliInstance, diff --git a/src/cli/v8CodeCacheCommands.ts b/src/cli/v8CodeCacheCommands.ts index a15bebdf0a4..05598903580 100644 --- a/src/cli/v8CodeCacheCommands.ts +++ b/src/cli/v8CodeCacheCommands.ts @@ -3,10 +3,8 @@ import type { Logger } from "pino"; import { createV8CodeCacheService } from "../composition/v8CodeCache.js"; import { V8_CODE_CACHE_TOOL_CONTRACTS } from "../contracts/v8/v8CodeCacheToolContracts.js"; import { contractNamed } from "./contractCliDescription.js"; -import { - inspectWithService, - registerContractCommand, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { inspectWithService } from "./contractCommandRunners.js"; import type { CliInstance } from "./types.js"; /** Inspect operator-selected V8 code caches through the same shared workflow as MCP. */ diff --git a/src/cli/wasmCommands.ts b/src/cli/wasmCommands.ts index 459925cf318..9820e1c6776 100644 --- a/src/cli/wasmCommands.ts +++ b/src/cli/wasmCommands.ts @@ -5,10 +5,8 @@ import { wasmArtifactModule } from "../composition/wasm.js"; import { COMPARE_WASM_INTERFACES_CONTRACT } from "../contracts/wasm/wasmComparisonContracts.js"; import type { Logger } from "pino"; import type { CliInstance } from "./types.js"; -import { - inspectWithService, - registerContractCommand, -} from "./contractCommand.js"; +import { registerContractCommand } from "./contractCommand.js"; +import { inspectWithService } from "./contractCommandRunners.js"; import { evidenceBundleOption, runEvidenceInputCommand,