eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
103 lines (102 loc) • 4.46 kB
TypeScript
import type { ModelMessage, ToolSet, TypedToolCall } from "ai";
import type { RuntimeActionRequest, RuntimeActionResult } 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`.
*
* `childContinuationTokens` lets the harness clear local proxy-input entries
* on result resolution. `childSessionIds` lets the turn workflow cancel every
* successfully adopted local or remote child before dropping the batch.
*/
export interface PendingRuntimeActionBatch {
readonly actions: readonly RuntimeActionRequest[];
readonly childContinuationTokens?: Readonly<Record<string, string>>;
readonly childSessionIds?: Readonly<Record<string, string>>;
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;
type PendingSubagentChildIdentity = {
readonly continuationToken: string;
readonly kind: "local";
readonly sessionId: string;
} | {
readonly kind: "remote";
readonly sessionId: string;
};
/** Records one successfully dispatched child's durable identities. */
export declare function recordPendingSubagentChild(input: {
readonly callId: string;
readonly child: PendingSubagentChildIdentity;
readonly session: HarnessSession;
}): HarnessSession;
/** Returns results in pending-key order once every requested action has completed. */
export declare function resolveRuntimeActionResultsForKeys(input: {
readonly pendingKeys: readonly string[];
readonly results: readonly RuntimeActionResult[];
}): RuntimeActionResult[] | undefined;
/**
* 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<ResolvePendingRuntimeActionsResult>;
/**
* Projects one AI SDK tool call into the eve runtime-action contract.
*/
export declare function createRuntimeActionRequestFromToolCall(input: {
readonly toolCall: TypedToolCall<ToolSet>;
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.
*/
export declare function resolveToolCallInputObject(value: unknown, context: {
readonly callId: string;
readonly toolName: string;
}): JsonObject;
export {};