@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
111 lines • 4.22 kB
TypeScript
import type { MastraLanguageModel } from '../../../llm/model/shared.types.js';
import type { MemoryConfig } from '../../../memory/types.js';
import type { CoreTool } from '../../../tools/types.js';
import type { MessageList } from '../../message-list/index.js';
import type { AgentModelManagerConfig } from '../../types.js';
import type { SerializableToolMetadata, SerializableModelConfig, SerializableModelListEntry, SerializableDurableState, SerializableDurableOptions, SerializableScorersConfig, DurableAgenticWorkflowInput } from '../types.js';
/**
* Extract serializable metadata from a CoreTool
* This strips out the execute function and converts the schema to JSON Schema
*/
export declare function serializeToolMetadata(name: string, tool: CoreTool): SerializableToolMetadata;
/**
* Extract serializable metadata from all tools
*/
export declare function serializeToolsMetadata(tools: Record<string, CoreTool>): SerializableToolMetadata[];
/**
* Extract serializable model configuration
*/
export declare function serializeModelConfig(model: MastraLanguageModel): SerializableModelConfig;
/**
* Extract serializable model list entry from AgentModelManagerConfig
*/
export declare function serializeModelListEntry(entry: AgentModelManagerConfig): SerializableModelListEntry;
/**
* Serialize an array of model configs into a model list.
* Filters out disabled models since they shouldn't be included in durable execution.
*/
export declare function serializeModelList(models: AgentModelManagerConfig[]): SerializableModelListEntry[];
/**
* Serialize scorers configuration for durable execution.
*
* This extracts the scorer name (for resolution at runtime) and sampling config.
* The actual scorer objects are resolved from Mastra at step execution time.
*
* @param scorers The agent's scorers configuration (from agent.scorers or options.scorers)
* @returns Serializable scorer configuration
*/
export declare function serializeScorersConfig(scorers: Record<string, {
scorer: {
name: string;
} | string;
sampling?: {
type: 'none';
} | {
type: 'ratio';
rate: number;
};
}>): SerializableScorersConfig;
/**
* Extract serializable state from _internal-like objects
*/
export declare function serializeDurableState(params: {
memoryConfig?: MemoryConfig;
threadId?: string;
resourceId?: string;
threadExists?: boolean;
savePerStep?: boolean;
observationalMemory?: boolean;
}): SerializableDurableState;
/**
* Extract serializable options from agent execution options
*/
export declare function serializeDurableOptions(options: {
maxSteps?: number;
toolChoice?: any;
activeTools?: string[];
temperature?: number;
requireToolApproval?: boolean;
toolCallConcurrency?: number;
autoResumeSuspendedTools?: boolean;
maxProcessorRetries?: number;
includeRawChunks?: boolean;
returnScorerData?: boolean;
hasErrorProcessors?: boolean;
providerOptions?: SerializableDurableOptions['providerOptions'];
structuredOutput?: SerializableDurableOptions['structuredOutput'];
skipBgTaskWait?: boolean;
}): SerializableDurableOptions;
/**
* Create the full workflow input from all components
*/
export declare function createWorkflowInput(params: {
runId: string;
agentId: string;
agentName?: string;
messageList: MessageList;
tools: Record<string, CoreTool>;
model: MastraLanguageModel;
modelList?: AgentModelManagerConfig[];
scorers?: Parameters<typeof serializeScorersConfig>[0];
options: Parameters<typeof serializeDurableOptions>[0];
state: Parameters<typeof serializeDurableState>[0];
messageId: string;
}): DurableAgenticWorkflowInput;
/**
* Serialize an error for workflow state
*/
export declare function serializeError(error: unknown): {
name: string;
message: string;
stack?: string;
};
/**
* Serialize a Date to ISO string for workflow state
*/
export declare function serializeDate(date: Date | undefined): string | undefined;
/**
* Deserialize an ISO string back to Date
*/
export declare function deserializeDate(isoString: string | undefined): Date | undefined;
//# sourceMappingURL=serialize-state.d.ts.map