UNPKG

@mastra/core

Version:

Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.

55 lines 2.17 kB
import type { RequestContext } from '../../../../request-context/index.js'; import type { Workspace } from '../../../../workspace/index.js'; import type { DurableToolCallInput, DurableToolCallOutput } from '../../types.js'; /** * Context for tool execution */ export interface ToolExecutionContext { /** Tool calls from the LLM output */ toolCalls: DurableToolCallInput[]; /** Resolved tools with execute functions */ tools: Record<string, any>; /** Run identifier */ runId: string; /** Agent identifier */ agentId: string; /** Message identifier */ messageId: string; /** Serializable state */ state: any; /** Workspace for file/sandbox operations */ workspace?: Workspace; /** Request context for auth data, feature flags, etc. */ requestContext?: RequestContext; /** * Optional hooks for observability/streaming. * All hooks can be sync or async. */ /** Called before starting tool execution (for span creation) */ onToolStart?: (toolCall: DurableToolCallInput) => void | Promise<void>; /** Called after successful tool execution (for span close, pubsub emit) */ onToolResult?: (toolCall: DurableToolCallInput, result: unknown) => void | Promise<void>; /** Called on tool execution error (for span error, pubsub emit) */ onToolError?: (toolCall: DurableToolCallInput, error: ToolExecutionError) => void | Promise<void>; } /** * Error structure for tool execution failures */ export interface ToolExecutionError { name: string; message: string; stack?: string; } /** * Execute tool calls durably with optional hooks for observability and streaming. * * This is the shared implementation used by: * - Core DurableAgent workflow * - Inngest durable agent workflow (with observability hooks) * - Evented durable agent workflow * * @param ctx - Tool execution context with tool calls, resolved tools, and optional hooks * @returns Array of tool call outputs with results or errors */ export declare function executeDurableToolCalls(ctx: ToolExecutionContext): Promise<DurableToolCallOutput[]>; //# sourceMappingURL=execute-tool-calls.d.ts.map