import type { ModelMessage, ToolSet, TypedToolCall } from "ai"; import type { RuntimeActionRequest } from "#runtime/actions/types.js"; import { type JsonObject } from "#shared/json.js"; import type { HarnessEmitFn, HarnessSession, HarnessToolMap, SessionStateMap, StepInput } from "#harness/types.js"; /** * Serializable event coordinates for one pending runtime-action batch. * * Runtime action results are projected back onto the parent stream using the * same turn and step identity as the originating `actions.requested` batch. */ interface PendingRuntimeActionEventMetadata { readonly sequence: number; readonly stepIndex: number; readonly turnId: string; } /** * Serializable pending runtime-action batch stored on `session.state`. * * Child ownership does not live here: the agent handle store records every * dispatched child (from before its start side effect) and is the sole * authority for continuing, settling, and cancelling children. */ export interface PendingRuntimeActionBatch { readonly actions: readonly RuntimeActionRequest[]; readonly event: PendingRuntimeActionEventMetadata; readonly responseMessages: readonly ModelMessage[]; } /** * Outcome of resolving a pending runtime-action batch. */ interface ResolvePendingRuntimeActionsResult { readonly messages: ModelMessage[]; readonly outcome: "continue" | "resolved" | "unresolved"; readonly session: HarnessSession; } /** Returns the pending runtime-action batch stored on the session, if any. */ export declare function getPendingRuntimeActionBatch(state: SessionStateMap | undefined): PendingRuntimeActionBatch | undefined; /** * Returns true when the session is parked on a pending runtime-action batch. */ export declare function hasPendingRuntimeActionBatch(state: SessionStateMap | undefined): boolean; export declare function clearPendingRuntimeActionBatch(session: HarnessSession): HarnessSession; /** * Stores one pending runtime-action batch on the session. */ export declare function setPendingRuntimeActionBatch(input: { readonly actions: readonly RuntimeActionRequest[]; readonly event: PendingRuntimeActionEventMetadata; readonly responseMessages: readonly ModelMessage[]; readonly session: HarnessSession; }): HarnessSession; /** * Resolves one pending runtime-action batch back into model history. * * When all expected runtime action results are present, this appends the * stored assistant tool-call messages plus synthesized tool-result messages to * history, clears the pending batch, and emits `subagent.completed` and * `action.result` events back onto the parent stream. */ export declare function resolvePendingRuntimeActions(input: { readonly emit?: HarnessEmitFn; readonly session: HarnessSession; readonly stepInput?: StepInput; }): Promise; /** * Projects one AI SDK tool call into the eve runtime-action contract. */ export declare function createRuntimeActionRequestFromToolCall(input: { readonly toolCall: TypedToolCall; readonly tools: HarnessToolMap; }): RuntimeActionRequest; /** * Coerces an AI SDK tool-call `input` into the runtime-action `JsonObject` * contract, throwing a `TypeError` (with the original as `cause`) that names * the offending tool when the payload is not a JSON object. * * String inputs are parsed as JSON first: the model protocol carries tool * arguments as text, and provider-executed tool calls can surface that raw * string — or an empty string when the model sends no arguments. */ export declare function resolveToolCallInputObject(value: unknown, context: { readonly callId: string; readonly toolName: string; }): JsonObject; export {};