UNPKG

@mastra/core

Version:

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

60 lines 1.89 kB
import type { DurableAgenticExecutionOutput } from '../../types.js'; import type { AccumulatedUsage, BaseIterationState } from './schemas.js'; /** * Input for creating iteration state update */ export interface IterationStateUpdateInput { /** Current iteration state */ currentState: BaseIterationState; /** Output from the current iteration's execution */ executionOutput: DurableAgenticExecutionOutput; } /** * Step record for tracking iteration history */ export interface StepRecord { text?: string; toolCalls?: unknown[]; toolResults?: unknown[]; usage?: unknown; finishReason?: string; } /** * Calculate accumulated usage from current state and new execution output. */ export declare function calculateAccumulatedUsage(currentUsage: AccumulatedUsage, executionUsage?: { inputTokens?: number; outputTokens?: number; totalTokens?: number; }): AccumulatedUsage; /** * Build a step record from execution output. */ export declare function buildStepRecord(executionOutput: DurableAgenticExecutionOutput): StepRecord; /** * Create the base iteration state update. * * This returns the common fields for iteration state updates. * Implementations can extend this with their specific fields. * * @example * ```typescript * const baseUpdate = createBaseIterationStateUpdate({ * currentState: initData, * executionOutput, * }); * * // Core extends with modelList * const coreState = { ...baseUpdate, modelList: initData.modelList }; * * // Inngest extends with observability * const inngestState = { * ...baseUpdate, * agentSpanData: initData.agentSpanData, * modelSpanData: initData.modelSpanData, * stepIndex: initData.stepIndex + 1, * }; * ``` */ export declare function createBaseIterationStateUpdate(input: IterationStateUpdateInput): BaseIterationState; //# sourceMappingURL=iteration-state.d.ts.map