import { type TruncationResult } from "@caupulican/pi-agent-core/truncate"; import { type AgentTool } from "@caupulican/pi-agent-core/types"; import { type Static, Type } from "typebox"; import type { ToolDefinition } from "../extensions/types.ts"; import { type FileFailureRecoveryAuthority } from "./file-failure-recovery.ts"; import { type ShellOutputProjectionDetails } from "./shell-output-projection.ts"; import { type WindowsShellEngineOptions } from "./windows-shell-engine.ts"; /** Agent-facing wall-clock bound: continuously producing output must not make a command immortal. */ export declare const DEFAULT_COMMAND_TIMEOUT_SECONDS = 120; export declare const MAX_COMMAND_TIMEOUT_SECONDS = 3600; /** Test hook: override the low-level silence threshold. Pass undefined to restore the default. */ export declare function setCommandSilenceMsForTests(ms: number | undefined): void; /** Test hook: override the agent tool's default wall-clock bound. Pass undefined to restore it. */ export declare function setCommandTimeoutMsForTests(ms: number | undefined): void; export declare function resolveCommandTimeoutSeconds(timeout: number | undefined): number; declare const bashSchema: Type.TObject<{ command: Type.TString; timeout: Type.TOptional; broadSearch: Type.TOptional>; }>; export type BashToolInput = Static; export interface BashToolDetails { truncation?: TruncationResult; fullOutputPath?: string; fullOutputError?: string; persistedOutputTruncated?: boolean; persistedOutputBytes?: number; preview?: { content: string; skippedLines: number; }; outputProjection?: ShellOutputProjectionDetails; } /** * Pluggable operations for the bash tool. * Override these to delegate command execution to remote systems (for example SSH). */ export interface BashOperations { /** * Execute a command and stream output. * @param command The command to execute * @param cwd Working directory * @param options Execution options * @returns Promise resolving to exit code (null if killed) plus, when the backend tracks it, * the shell-reported working directory after the command ran */ exec: (command: string, cwd: string, options: { onData: (data: Buffer) => void; signal?: AbortSignal; timeout?: number; env?: NodeJS.ProcessEnv; }) => Promise<{ exitCode: number | null; cwd?: string; }>; } /** * Create bash operations using pi's built-in local shell execution backend. * * This is useful for extensions that intercept user_bash and still want pi's * standard local shell behavior while wrapping or rewriting commands. */ export declare function createLocalBashOperations(options?: { shellPath?: string; sessionKey?: string; }): BashOperations; /** Create PowerShell operations using pi's built-in local execution backend. */ export declare function createLocalPowerShellOperations(options?: { shellPath?: string; sessionKey?: string; }): BashOperations; /** Create the platform shell backend without requiring callers or the model to choose a shell. */ export declare function createLocalPlatformShellOperations(options?: { shellPath?: string; commandPrefix?: string; operations?: BashOperations; sessionKey?: string; /** Route complex/state-mutating Bash constructs and portable builtins to the Python engine on Windows. Default: true. */ pythonEngine?: boolean; /** Test/embedding hook: overrides the engine tier's runtime/spawn/state resolution. */ engineOptions?: WindowsShellEngineOptions; }, platform?: NodeJS.Platform): BashOperations; export interface BashSpawnContext { command: string; cwd: string; env: NodeJS.ProcessEnv; } export type BashSpawnHook = (context: BashSpawnContext) => BashSpawnContext; export interface BashToolOptions { /** Platform used to choose the default backend and contract router. Defaults to process.platform. */ platform?: NodeJS.Platform; /** Custom operations for command execution. Default: local platform shell */ operations?: BashOperations; /** Shared backend identity for exact cross-tool recovery with custom operations. */ failureRecoveryAuthority?: FileFailureRecoveryAuthority; /** Command prefix prepended to every command (for example shell setup commands) */ commandPrefix?: string; /** Optional explicit shell path from settings */ shellPath?: string; /** Hook to adjust command, cwd, or env before execution */ spawnHook?: BashSpawnHook; /** * Stable key for this agent's persistent shell session. The host passes its per-agent key so * the session survives runtime reloads and user `!` commands share it; separately created * tool instances (subagents) auto-generate their own key and stay isolated. */ sessionKey?: string; /** Route complex/state-mutating Bash constructs and portable builtins to the Python engine on Windows. Default: true. */ windowsShellPythonEngine?: boolean; /** Test/embedding hook: overrides the engine tier's runtime/spawn/state resolution. */ windowsShellEngineOptions?: WindowsShellEngineOptions; /** Start the native Windows PowerShell session during runtime initialization. Default: false. */ prewarmWindowsShell?: boolean; /** Test/embedding hook: override the managed directory used for complete command output. */ outputDirectory?: string; } export declare function createBashToolDefinition(cwd: string, options?: BashToolOptions): ToolDefinition; export declare function createBashTool(cwd: string, options?: BashToolOptions): AgentTool; export {}; //# sourceMappingURL=bash.d.ts.map