import type { ChatModelAdapter } from "@assistant-ui/react"; import { type CodeAgentTranscriptEvent as CoreCodeAgentTranscriptEvent } from "../code-agents/transcript-normalizer.js"; import { type CodeAgentRunStateLike } from "../code-agents/transcript-order.js"; import type { ReasoningEffort } from "../shared/reasoning-effort.js"; import type { ContentPart } from "./sse-event-processor.js"; export type CodeAgentChatFollowUpMode = "immediate" | "queued"; export interface CodeAgentChatTranscriptEvent { id: string; runId: string; kind?: CoreCodeAgentTranscriptEvent["kind"]; type?: CoreCodeAgentTranscriptEvent["kind"] | "note"; message?: string; text?: string; createdAt: string; metadata?: Record; artifactPath?: string; artifactUrl?: string; } export interface CodeAgentChatControlResult { ok: boolean; run?: CodeAgentRunStateLike | null; queued?: boolean; message?: string; error?: string; } export interface CodeAgentChatController { get(runId: string): Promise; transcript(runId: string): Promise; sendFollowUp(input: { runId: string; prompt: string; mode?: CodeAgentChatFollowUpMode; permissionMode?: string; engine?: string; model?: string; reasoningEffort?: ReasoningEffort; source?: string; metadata?: Record; }): Promise; control(input: { runId: string; /** * `"approve"` resolves the run's current pending `needsApproval` gate * (see `requestCodeAgentApproval` in `cli/code-agent-executor.ts`) — the * same effect as the host UI's "Approve" control. Deny / always-allow are * intentionally NOT routed through this method; hosts wire those directly * via `AssistantChatProps.approvalActions` instead (see CodeAgentsApp). */ command: "stop" | "approve"; }): Promise; } export interface CreateCodeAgentChatAdapterOptions { controller: CodeAgentChatController; runIdRef: { current: string | null; }; permissionModeRef?: { current: string | undefined; }; modelRef?: { current: string | undefined; }; engineRef?: { current: string | undefined; }; effortRef?: { current: ReasoningEffort | undefined; }; followUpModeRef?: { current: CodeAgentChatFollowUpMode | undefined; }; attachOnlyRef?: { current: boolean; }; tabId?: string; pollIntervalMs?: number; idlePollIntervalMs?: number; terminalIdlePolls?: number; /** * Assistant-ui may abort a run for UI lifecycle reasons, such as switching * selected sessions. Code sessions keep running unless the host sends an * explicit stop command. */ stopOnAbort?: boolean; } export declare function createCodeAgentChatAdapter(options: CreateCodeAgentChatAdapterOptions): ChatModelAdapter; /** * Whether any tool-call in this Code transcript currently carries an * unresolved approval (see `NormalizedCodeAgentToolEvent.pendingApprovalKey`). * Hosts (e.g. `CodeAgentsApp`) use this to keep their standalone approval * banner as a fallback only for transcripts where the inline * `ApprovalAffordance` cannot be joined to a tool-call part, instead of * showing both at once. */ export declare function codeAgentTranscriptHasPendingApproval(events: readonly CodeAgentChatTranscriptEvent[]): boolean; export declare function codeAgentTranscriptEventsToContent(events: readonly CodeAgentChatTranscriptEvent[]): ContentPart[]; //# sourceMappingURL=code-agent-chat-adapter.d.ts.map