eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
95 lines (94 loc) • 3.82 kB
TypeScript
import type { ModelMessage, ToolSet, TypedToolCall } from "ai";
import type { RuntimeToolCallActionRequest, RuntimeToolResultActionResult } from "#runtime/actions/types.js";
import type { InputRequest } from "#runtime/input/types.js";
import type { HarnessSession, SessionStateMap, StepInput } from "#harness/types.js";
/**
* Stream-emit coordinates carried so a parked batch's resolution can attribute
* its events to the turn and step that requested the input.
*/
interface PendingInputBatchEvent {
readonly sequence: number;
readonly stepIndex: number;
readonly turnId: string;
}
/**
* Denied tool-call approvals from one resolved batch, ready for the caller to
* emit as `rejected` `action.result` events against the originating turn.
*/
export interface RejectedActionBatch {
readonly event: PendingInputBatchEvent;
readonly results: readonly RuntimeToolResultActionResult[];
}
/**
* Returns true when the step input carries user-facing turn input.
*/
export declare function hasStepInput(input?: StepInput): boolean;
/**
* Merges any queued follow-up input into the current step input and clears it
* from session state.
*
* Used when the harness has to process a pending tool-approval response first
* and defer the user's new message to the next internal model step.
*/
export declare function consumeDeferredStepInput(input: {
readonly input?: StepInput;
readonly session: HarnessSession;
}): {
readonly input?: StepInput;
readonly session: HarnessSession;
};
/**
* Returns true when the session carries queued follow-up input for the next
* internal harness step.
*/
export declare function hasDeferredStepInput(session: HarnessSession): boolean;
/**
* Resolves pending input at the start of a harness step.
*
* When the pending batch contains tool-approval requests and the step input
* also carries a follow-up user message, the message is deferred to the next
* internal harness step rather than appended to the current turn. This is
* necessary because AI SDK cannot process tool-approval responses and a new
* user message in the same request -- the approval must be resolved in
* isolation first, and the user message replayed on the subsequent step via
* {@link consumeDeferredStepInput}.
*/
export declare function resolvePendingInput(input: {
readonly history?: readonly ModelMessage[];
readonly resolveApprovalKey?: (request: InputRequest) => string | undefined;
readonly session: HarnessSession;
readonly stepInput?: StepInput;
}): ResolvePendingInputResult;
type ResolvePendingInputResult = {
readonly deferredMessage?: boolean;
readonly outcome: "resolved" | "continue" | "unresolved";
readonly messages: ModelMessage[];
readonly rejectedActions?: RejectedActionBatch;
readonly session: HarnessSession;
};
/**
* Returns true when the session is parked on a pending HITL batch
* (tool approvals or `ask_question` prompts).
*/
export declare function hasPendingInputBatch(state: SessionStateMap | undefined): boolean;
/**
* Stores one pending HITL batch on the session until the user responds.
*/
export declare function setPendingInputBatch(input: {
readonly event?: PendingInputBatchEvent;
readonly requests: readonly InputRequest[];
readonly responseMessages: readonly ModelMessage[];
readonly session: HarnessSession;
}): HarnessSession;
/**
* Returns the set of tool names that have been approved at least once
* during this session.
*/
export declare function getApprovedTools(session: HarnessSession): ReadonlySet<string>;
/**
* Creates a runtime tool-call action shape from an AI SDK tool call.
*/
export declare function createRuntimeToolCallActionFromToolCall(input: {
readonly toolCall: TypedToolCall<ToolSet>;
}): RuntimeToolCallActionRequest;
export {};