/** * [WHO]: Provides BashRunner, BashRunnerDeps — bash execution + pending-message queue for a session * [FROM]: Depends on core/platform/exec/bash-executor (execution), core/messages (BashExecutionMessage), * core/tools/bash (BashOperations); host wiring passed in via closures (no agent/session import) * [TO]: Consumed by core/runtime/agent-session.ts (composition root delegates executeBash/abortBash/…) * [HERE]: core/runtime/agent-session.ts split — owns _bashAbortController + _pendingBashMessages * * Extracted from AgentSession (P4.1). Behavior-identical: the session's executeBash / * recordBashResult / abortBash / isBashRunning / hasPendingBashMessages / flushPending methods * now delegate here. Dependencies are injected as closures so this module stays decoupled from * Agent / SessionManager / SettingsManager. */ import { type BashResult } from "../platform/exec/bash-executor.js"; import type { BashExecutionMessage } from "../messages.js"; import type { BashOperations } from "../tools/bash.js"; export interface BashRunnerDeps { /** Current working directory (read lazily — may change across session switches). */ getCwd: () => string; /** Optional shell command prefix (e.g. alias expansion) from settings. */ getShellCommandPrefix: () => string | undefined; /** Append a message to live agent state. */ appendToAgent: (message: BashExecutionMessage) => void; /** Persist a message to the session. */ appendToSession: (message: BashExecutionMessage) => void; /** Whether the agent is mid-stream (defer message to preserve tool ordering). */ isStreaming: () => boolean; } export declare class BashRunner { private readonly deps; private _abortController; private _pending; constructor(deps: BashRunnerDeps); /** Run a bash command, recording its result in session history. */ execute(command: string, onChunk?: (chunk: string) => void, options?: { excludeFromContext?: boolean; operations?: BashOperations; }): Promise; /** * Record a bash execution result in session history. * Used by execute() and by extensions that handle bash execution themselves. */ recordResult(command: string, result: BashResult, options?: { excludeFromContext?: boolean; }): void; /** Cancel running bash command. */ abort(): void; /** Whether a bash command is currently running. */ get isRunning(): boolean; /** Whether there are pending bash messages waiting to be flushed. */ get hasPending(): boolean; /** * Flush pending bash messages to agent state and session. * Called after agent turn completes to maintain proper message ordering. */ flushPending(): void; }