/** * Standalone bash-command execution (the `/bash` path + extension-driven bash). * * Extracted verbatim from agent-session.ts (god-file decomposition). Owns the bash abort controller * and the pending-message queue that defers appending a bash result while the agent is streaming (so * tool_use/tool_result ordering is never broken); the deferred messages are flushed by the session on * agent turn completion. Persists results through the session log via deps. */ import type { Agent } from "@caupulican/pi-agent-core"; import type { SessionManager } from "@caupulican/pi-agent-core/node"; import { type BashResult } from "./bash-executor.ts"; import type { SettingsManager } from "./settings-manager.ts"; import { type BashOperations } from "./tools/bash.ts"; export interface BashExecutionControllerDeps { getAgent(): Agent; getSessionManager(): SessionManager; getSettingsManager(): SettingsManager; /** Whether the agent is currently streaming — defers appending a bash result if so. */ isStreaming(): boolean; /** Per-agent persistent shell session key — user `!` commands share the agent's shell state. */ getShellSessionKey?(): string; /** Owner-authorized credential environment resolved for the current project. */ getEnvironment?(cwd: string): NodeJS.ProcessEnv; /** Exact-value redaction applied before owner shell results enter model/session history. */ redactSensitiveText?(text: string): string; } export interface BashExecutionOptions { excludeFromContext?: boolean; operations?: BashOperations; /** Injectable target platform for tests and embedded runtimes. */ platform?: NodeJS.Platform; /** Wall-clock timeout in seconds; non-positive values use the bounded default. */ timeout?: number; /** Route complex/state-mutating Bash constructs to the Python engine on Windows. Default: true. */ pythonEngine?: boolean; } export declare class BashExecutionController { private _bashAbortControllers; private _pendingBashMessages; private readonly shellSessionKey; private readonly deps; constructor(deps: BashExecutionControllerDeps); executeBash(command: string, onChunk?: (chunk: string) => void, options?: BashExecutionOptions): Promise; /** * Record a bash execution result in session history. * Used by executeBash and by extensions that handle bash execution themselves. */ recordBashResult(command: string, result: BashResult, options?: { excludeFromContext?: boolean; }): void; /** * Cancel running bash command. */ abortBash(): void; /** Whether a bash command is currently running */ get isBashRunning(): boolean; /** Whether there are pending bash messages waiting to be flushed */ get hasPendingBashMessages(): boolean; /** * Flush pending bash messages to agent state and session. * Called after agent turn completes to maintain proper message ordering. */ flushPendingBashMessages(): void; } //# sourceMappingURL=bash-execution-controller.d.ts.map