import type { ModelMessage, TextStreamPart, ToolSet, TypedToolResult } from "ai"; type ToolResponsePart = Extract["content"][number]; type InlineToolResultPart = Extract; import type { AssistantStepFinishReason, RuntimeIdentity } from "#protocol/message.js"; import type { RunMode } from "#shared/run-mode.js"; import type { JsonObject } from "#shared/json.js"; import type { HarnessEmissionState } from "#harness/emission-state.js"; import type { HarnessEmitFn, HarnessToolMap, StepInput } from "#harness/types.js"; export { getHarnessEmissionState, isHarnessBetweenTurns, setHarnessEmissionState, } from "#harness/emission-state.js"; export type { HarnessEmissionState } from "#harness/emission-state.js"; /** * Emits `session.started` (once), `turn.started`, and `message.received` at the * beginning of a new turn. Returns updated emission state. */ export declare function emitTurnPreamble(emitFn: HarnessEmitFn, input: StepInput, state: HarnessEmissionState, runtimeIdentity?: RuntimeIdentity): Promise; /** * Emits `step.started` for one model call. */ export declare function emitStepStarted(emitFn: HarnessEmitFn, state: HarnessEmissionState, messages?: readonly import("ai").ModelMessage[]): Promise; interface FailedStepPayload { readonly code: string; readonly details?: JsonObject; readonly message: string; } /** * Emits the full terminal failure cascade: `step.failed` → * `turn.failed` → `session.failed`. * * Use this when the session cannot be salvaged (structural config * error, auth misconfig, non-recoverable provider response). The * `session.failed` tail tells adapters the session is dead and no * further follow-up is possible on the same continuation token. */ export declare function emitFailedStep(emitFn: HarnessEmitFn, state: HarnessEmissionState, input: FailedStepPayload & { readonly sessionId: string; }): Promise; /** * Emits the recoverable failure cascade: `step.failed` → * `turn.failed` → `session.waiting`. */ export declare function emitRecoverableFailedTurn(emitFn: HarnessEmitFn, state: HarnessEmissionState, input: FailedStepPayload & { readonly continuationToken: string; }): Promise; /** * Returns updated emission state for the next step in the current turn. */ export declare function advanceStep(state: HarnessEmissionState): HarnessEmissionState; /** * Emits `turn.completed` and either `session.waiting` or `session.completed`. * Returns updated emission state with an incremented sequence. */ export declare function emitTurnEpilogue(emitFn: HarnessEmitFn, state: HarnessEmissionState, mode: RunMode): Promise; /** * Maps an AI SDK finish reason string to the eve-owned * {@link AssistantStepFinishReason} union. Unknown values become `"other"`. */ export declare function normalizeAssistantStepFinishReason(value: string | undefined): AssistantStepFinishReason; /** * Result of consuming one step's `fullStream`. * * Inline results avoid duplicate post-step events. Approval-resume * authorization results also route back to the park detector. */ interface EmittedStreamContent { readonly emittedActionCallIds: ReadonlySet; readonly handledInlineToolResultCallIds: ReadonlySet; readonly invalidInputToolCallIds: ReadonlySet; readonly inlineAuthorizationResults: readonly TypedToolResult[]; readonly trailingInlineToolResultParts: readonly InlineToolResultPart[]; } interface StreamActionEmissionOptions { readonly excludedActionToolNames: ReadonlySet; readonly tools: HarnessToolMap; } /** * Consumes the AI SDK `fullStream` and emits real-time text and reasoning * events. * * Emits local tool events in source order. Provider calls that arrive in one * stream batch into one request event before their first result. A result * without a streamed call resumes a call from an earlier step. */ export declare function emitStreamContent(emitFn: HarnessEmitFn, state: HarnessEmissionState, fullStream: AsyncIterable>, options?: StreamActionEmissionOptions): Promise;