import type { MinimizerOptions } from "@gajae-code/natives"; import { Settings, type ShellMinimizerSettings } from "../config/settings"; import { type TerminalArtifactPublisher } from "../session/streaming-output"; export interface BashArtifactSaveSummary { artifactId: string; complete: boolean; omittedBytes?: number; } export type BashMinimizedSaveReturn = BashArtifactSaveResult | BashArtifactSaveSummary | string | undefined; export type BashArtifactSaveResult = { status: "saved"; artifactId: string; complete: true; omittedBytes?: undefined; } | { status: "saved"; artifactId: string; complete: false; omittedBytes: number; } | { status: "unavailable"; } | { status: "failed"; diagnostic: string; }; export declare function normalizeMinimizedSaveResultForTests(value: BashMinimizedSaveReturn, originalText: string): BashArtifactSaveResult; export interface BashExecutorOptions { /** * Invoked when the native minimizer rewrote the command's output, giving * the caller a chance to persist the lossless original capture (typically * via the session's `ArtifactManager`). Complete saves preserve the * historical `[raw output: artifact://]` footer; capped saves carry an * honest retained/omitted reference. A legacy string id is still accepted * for non-tool callers and is classified from the original UTF-8 byte count. */ onMinimizedSave?: (originalText: string, info: { filter: string; inputBytes: number; outputBytes: number; }) => Promise; cwd?: string; timeout?: number | null; onChunk?: (chunk: string) => void; /** * Unthrottled per-chunk callback that fires for every sanitized stdout/stderr * chunk *before* preview throttling. Background-job substrate uses this to * record the complete process stream for the Monitor tool while keeping * `onChunk` cheap for UI/progress rendering. */ onRawChunk?: (chunk: string) => void; signal?: AbortSignal; /** Session settings used for shell policy and output limits. */ settings?: Settings; /** Session key suffix to isolate shell sessions per agent */ sessionKey?: string; /** Additional environment variables to inject */ env?: Record; /** Artifact path/id for full output storage */ artifactPath?: string; artifactId?: string; /** Optional terminal publisher for managed artifacts without writable paths. */ artifactPublisher?: TerminalArtifactPublisher; /** Optional Bash-specific retained tail budget in bytes. */ spillThreshold?: number; /** Optional Bash-specific retained head budget in bytes. */ headBytes?: number; /** Execute without retaining a native Shell in the persistent session registry. */ oneShot?: boolean; /** Ignore user-configured shell command prefixes. Used by constrained read-only shells. */ ignoreShellPrefix?: boolean; /** Skip sourced shell snapshots. Used by constrained read-only shells. */ disableShellSnapshot?: boolean; } export interface BashResult { output: string; exitCode: number | undefined; cancelled: boolean; truncated: boolean; totalLines: number; totalBytes: number; outputLines: number; outputBytes: number; artifactId?: string; artifactTruncatedBytes?: number; artifactFailureDiagnostic?: string; } /** Number of persistent shell sessions currently retained (owner gauge). */ export declare function getShellSessionCount(): number; /** * Dispose all persistent shell sessions: abort in-flight work and drop the * strong references so the native shells can be finalized. Healthy persistent * sessions are otherwise retained for the whole process lifetime (MEM-7). This * is registered as a postmortem cleanup so shutdown/signals release native * shell resources, and is also callable directly (e.g. on owner teardown). */ export declare function disposeAllShellSessions(): Promise; /** Translate `ShellMinimizerSettings` into native `MinimizerOptions`, or `undefined` when disabled. */ export declare function buildMinimizerOptions(group: ShellMinimizerSettings): MinimizerOptions | undefined; export declare function executeBash(command: string, options?: BashExecutorOptions): Promise;