eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
56 lines (55 loc) • 2.36 kB
TypeScript
import type { ModelMessage, UserContent } from "ai";
import type { DeliverPayload, SessionAuthContext } from "#channel/types.js";
import type { StepInput } from "#harness/types.js";
/**
* Merges two {@link StepInput} values into one.
*
* Used by the harness to coalesce deferred step input with the current
* turn's input, and by the execution layer after calling `onDeliver`
* for each queued delivery payload.
*/
export declare function coalesceTurnInputs(a: StepInput, b: StepInput): StepInput;
/**
* Removes text parts with no model-visible content from a user message.
*
* Returns `undefined` when no parts remain, allowing callers to omit the user
* turn entirely rather than create an empty model prompt block.
*/
export declare function normalizeUserContent(content: string | UserContent | undefined): string | UserContent | undefined;
/**
* Extracts the final visible assistant text from model response messages.
*
* Prefers text extracted from the last assistant message that contains visible
* text. Falls back to the raw `text` property from the AI SDK result when no
* assistant message contains text. Returns `null` when neither source contains
* text.
*/
export declare function resolveAssistantStepText(messages: readonly ModelMessage[], fallback: string | undefined): string | null;
/**
* Appends user content while preserving structured attachment parts.
*/
export declare function appendUserContent(input: {
readonly appended: string | UserContent;
readonly existing: string | UserContent;
}): string | UserContent;
/**
* Structural shape of the workflow `DeliverHookPayload`. Using a
* structural type keeps this helper decoupled from the concrete
* runtime type.
*/
interface DeliverLike {
readonly auth?: SessionAuthContext | null;
readonly kind: "deliver";
readonly payloads: readonly DeliverPayload[];
}
/**
* Coalesces an array of deliver-like items into a single item by
* collecting all payloads and keeping the most recent auth value.
*
* Used by the workflow runtime to batch follow-up deliveries that
* arrived while a turn or subagent delegation was in progress. Each
* payload is later passed to `onDeliver` individually so channel-
* specific fields are never lost.
*/
export declare function coalesceDeliveries<T extends DeliverLike>(items: readonly T[]): T;
export {};