import { PermissionOutcome } from '../utils/agent.js'; import { ProjectContext } from '../utils/project.js'; import { ToolCall } from '../utils/tools.js'; import type { FsCallbacks, TrustBearingWrite } from '../utils/toolExecution.js'; import type { Message } from '../config/index.js'; export interface AgentSessionOptions { prompt: string; workspaceRoot: string; conversationId: string; abortSignal: AbortSignal; onChunk: (text: string) => void; onThought?: (text: string) => void; onToolCall?: (toolCallId: string, toolName: string, kind: string, title: string, status: 'pending' | 'running' | 'finished' | 'error', locations?: string[], rawOutput?: string) => void; /** * Ask the user about one tool call. Handed straight to runAgent, so the * signature is runAgent's: `trustBearing` is what the agent's own gate * already worked out about the call — the file it would write that decides * what runs later, or null when it writes no such file — and the dialog * words itself from that instead of resolving the path a second time. * * Declared with one parameter, this type said the second argument did not * exist while runAgent passed it on every call, so the one caller that * needs it had to cast its way back to the truth. */ onRequestPermission?: (toolCall: ToolCall, trustBearing?: TrustBearingWrite | null) => Promise; /** Tools to force into the per-run dangerous set (ACP manual mode). */ extraDangerousTools?: string[]; onExecuteCommand?: (command: string, args: string[], cwd: string) => Promise<{ stdout: string; stderr: string; exitCode: number; }>; /** Optional fs delegation when the ACP client advertises `fs` capability. */ fs?: FsCallbacks; /** * Earlier turns of this conversation. ACP clients send only the new * message, so without this the agent would start every turn blind to a * loaded, rewound or compacted session. */ chatHistory?: Message[]; } /** * The part of a session's history the agent sees: user and assistant turns, * as the TUI passes them (`App.getChatHistory`). */ export declare function toAgentChatHistory(history: Message[]): Array<{ role: 'user' | 'assistant'; content: string; }>; /** * Build a ProjectContext from a workspace root directory. * Falls back to a minimal synthetic context if scanning fails. */ export declare function buildProjectContext(workspaceRoot: string): ProjectContext; export declare function toolCallMeta(toolName: string, params: Record, workspaceRoot: string): { kind: string; title: string; }; export declare function buildRawOutput(toolName: string, params: Record, toolResult: { success: boolean; output: string; error?: string; }): string | undefined; export declare function runAgentSession(opts: AgentSessionOptions): Promise;