UNPKG

@mastra/core

Version:
128 lines 5.25 kB
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, SerializableModelSettings, 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; /** * Pick the JSON-safe call settings out of an arbitrary `modelSettings` input. * Drops any field that is not a primitive value of the expected type so that * non-serializable fields (functions, AbortSignal, etc.) never reach the * workflow input. */ export declare function serializeModelSettings(settings: SerializableModelSettings | Record<string, unknown> | undefined): SerializableModelSettings | undefined; /** * Extract serializable options from agent execution options */ export declare function serializeDurableOptions(options: { maxSteps?: number; toolChoice?: any; activeTools?: string[]; modelSettings?: SerializableModelSettings | Record<string, unknown>; requireToolApproval?: boolean; toolCallConcurrency?: number; autoResumeSuspendedTools?: boolean; maxProcessorRetries?: number; includeRawChunks?: boolean; returnScorerData?: boolean; hasErrorProcessors?: boolean; providerOptions?: SerializableDurableOptions['providerOptions']; structuredOutput?: SerializableDurableOptions['structuredOutput']; skipBgTaskWait?: boolean; disableBackgroundTasks?: boolean; tracingOptions?: SerializableDurableOptions['tracingOptions']; actor?: SerializableDurableOptions['actor']; instructionsOverride?: SerializableDurableOptions['instructionsOverride']; systemMessage?: SerializableDurableOptions['systemMessage']; transform?: SerializableDurableOptions['transform']; isTaskComplete?: SerializableDurableOptions['isTaskComplete']; }): 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; agentSpanData?: unknown; modelSpanData?: unknown; requestContextEntries?: Record<string, unknown>; }): 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