eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
41 lines (40 loc) • 1.92 kB
TypeScript
import type { ModelMessage, ToolSet, TypedToolResult } from "ai";
import type { RuntimeToolResultActionResult } from "#runtime/actions/types.js";
type ToolResponsePart = Extract<ModelMessage, {
role: "tool";
}>["content"][number];
type ToolResultPart = Extract<ToolResponsePart, {
type: "tool-result";
}>;
/**
* Builds a `RuntimeToolResultActionResult` from a raw tool output value.
*
* This is the single coercion point for `action.result` projection. Both
* native tool execution (via {@link createRuntimeToolResultFromStepResult} /
* {@link createRuntimeToolResultFromMessagePart}) and code-mode nested tool
* calls funnel through here, so the raw-output-vs-`toModelOutput` decision —
* always raw — is decided once. The output is passed through structurally
* because it is already JSON-serialized (the AI SDK tool result, or the
* code-mode worker bridge).
*/
export declare function createRuntimeToolResultFromValue(input: {
readonly callId: string;
readonly toolName: string;
readonly output: unknown;
readonly isError?: boolean;
}): RuntimeToolResultActionResult;
/**
* Builds a `RuntimeToolResultActionResult` from one AI SDK
* {@link TypedToolResult}. Used for tool results captured on the AI SDK
* step result and for `tool-result` parts that arrive on the stream.
*/
export declare function createRuntimeToolResultFromStepResult(toolResult: TypedToolResult<ToolSet>): RuntimeToolResultActionResult;
/**
* Builds a `RuntimeToolResultActionResult` from one tool-result message
* part as it appears on `step.response.messages`. Used as a fallback when
* the result is missing from `step.toolResults` (some providers — notably
* after `tool-output-denied` chunks — surface the result only on the
* response messages array).
*/
export declare function createRuntimeToolResultFromMessagePart(part: ToolResultPart): RuntimeToolResultActionResult;
export {};