@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
52 lines • 2.33 kB
TypeScript
import type { MastraDBMessage } from '../state/types.js';
import type { AIV5Type } from '../types.js';
/**
* StepContentExtractor - Handles extraction of step content from response messages
*
* This class encapsulates the complex logic for:
* - Finding step boundaries by looking for step-start markers
* - Handling special cases like -1 (last step) and tool-only steps
* - Converting UI messages to model messages and extracting content
*/
export declare class StepContentExtractor {
/**
* Extract content for a specific step number from UI messages
*
* @param uiMessages - Array of AI SDK V5 UI messages
* @param stepNumber - Step number to extract (1-indexed, or -1 for last step)
* @param stepContentFn - Function to convert model messages to step content
* @returns Step content array
*/
static extractStepContent(uiMessages: AIV5Type.UIMessage[], stepNumber: number, stepContentFn: (message?: AIV5Type.ModelMessage) => AIV5Type.StepResult<any>['content']): AIV5Type.StepResult<any>['content'];
/**
* Extract the last step content (stepNumber === -1)
*/
private static extractLastStep;
/**
* Extract the first step content (stepNumber === 1)
*/
private static extractFirstStep;
/**
* Extract content for steps 2+ (between step-start markers)
*/
private static extractMiddleStep;
/**
* Convert UI message parts to step content
*/
private static convertPartsToContent;
/**
* Convert a single model message content to step result content
*
* This handles:
* - Tool results: adding input field from DB messages
* - Files: converting to GeneratedFile format
* - Images: converting to file format with proper media type
* - Other content: passed through as-is
*
* @param message - Model message to convert (or undefined to use latest)
* @param dbMessages - Database messages for looking up tool call args
* @param getLatestMessage - Function to get the latest model message if not provided
*/
static convertToStepContent(message: AIV5Type.ModelMessage | undefined, dbMessages: MastraDBMessage[], getLatestMessage: () => AIV5Type.ModelMessage | undefined): AIV5Type.StepResult<any>['content'];
}
//# sourceMappingURL=step-content.d.ts.map