UNPKG

mastra-af-letta

Version:

Letta .af (Agent File) format support for Mastra - enables importing and exporting agents in Letta's portable format

1,575 lines (1,571 loc) 58.1 kB
import { z } from 'zod'; /** * @fileoverview TypeScript type definitions for Letta's .af (Agent File) format * * The Agent File (.af) format is an open standard for serializing AI agents, * including their configuration, memory, tools, and conversation history. * This file provides TypeScript interfaces that match the .af specification. * * @see https://github.com/letta-ai/agent-file - Official .af specification * @module @mastra/portability-af-letta */ /** * ISO 8601 date-time string format * @example "2024-01-01T00:00:00Z" */ type ISO8601 = string; /** * Supported message roles in conversations */ type MessageRole = 'user' | 'assistant' | 'system' | 'tool'; /** * Supported tool implementation types */ type ToolType = 'python' | 'javascript' | 'json_schema'; /** * Main agent schema - represents a complete serialized agent * * This is the root object of an .af file, containing all information * needed to reconstruct an agent's state and behavior. */ interface AfAgentSchema { /** * Type identifier for the agent framework * @example "memgpt", "letta" */ agent_type: string; /** * Human-readable name for the agent * @example "Customer Support Assistant" */ name: string; /** * Optional description of the agent's purpose and capabilities */ description?: string; /** * System prompt that defines the agent's behavior and personality * This is the core instruction set for the agent. */ system: string; /** * Language model configuration */ llm_config: AfLLMConfig; /** * Optional embedding model configuration for semantic memory */ embedding_config?: AfEmbeddingConfig; /** * Core memory blocks that persist across conversations * Object with named memory blocks (persona, human, and custom blocks). */ core_memory: Record<string, AfCoreMemoryBlock>; /** * Complete message history for the agent */ messages: AfMessage[]; /** * Indices of messages currently in the agent's context window * This allows recreating the exact context state. */ in_context_message_indices?: number[]; /** * Tool definitions available to the agent */ tools: AfTool[]; /** * Optional rules constraining tool usage */ tool_rules?: AfToolRule[]; /** * Environment variables available during tool execution */ tool_exec_environment_variables?: Record<string, string>; /** * Tags for categorizing and filtering agents */ tags?: string[]; /** * Additional metadata (the underscore suffix avoids conflicts) */ metadata_?: Record<string, unknown>; /** * Schema version for migration support * @example "0.1.0" */ version: string; /** * Timestamp when the agent was created */ created_at: ISO8601; /** * Timestamp of last modification */ updated_at: ISO8601; } /** * Language model configuration * * Defines which LLM to use and its parameters. The configuration * is intentionally flexible to support various providers. */ interface AfLLMConfig { /** * LLM provider identifier * @example "openai", "anthropic", "local" */ provider: string; /** * Model identifier within the provider * @example "gpt-4", "claude-3-opus" */ model: string; /** * Temperature for response randomness (0-2, typically 0-1) */ temperature?: number; /** * Maximum tokens in response */ max_tokens?: number; /** * Nucleus sampling parameter */ top_p?: number; /** * Frequency penalty for reducing repetition */ frequency_penalty?: number; /** * Presence penalty for encouraging topic diversity */ presence_penalty?: number; /** * Provider-specific additional parameters */ [key: string]: unknown; } /** * Embedding model configuration for semantic memory */ interface AfEmbeddingConfig { /** * Embedding provider identifier */ provider: string; /** * Embedding model identifier */ model: string; /** * Embedding vector dimensions */ dimensions?: number; /** * Provider-specific additional parameters */ [key: string]: unknown; } /** * Core memory block - persistent agent state * * Core memory represents information that should always be * available to the agent, like personality or user preferences. */ interface AfCoreMemoryBlock { /** * Memory block identifier * @example "personality", "user_info" */ label: string; /** * Content of the memory block */ value: string; /** * Optional character limit for this block */ character_limit?: number; /** * Additional metadata for the block */ metadata?: Record<string, unknown>; } /** * Message in the conversation history */ interface AfMessage { /** * Unique message identifier */ id: string; /** * Role of the message sender */ role: MessageRole; /** * Message content */ text: string; /** * When the message was created */ timestamp: ISO8601; /** * Tool invocations requested in this message */ tool_calls?: AfToolCall[]; /** * Results from tool executions */ tool_results?: AfToolResult[]; /** * Additional message metadata */ metadata?: Record<string, unknown>; } /** * Tool invocation request */ interface AfToolCall { /** * Unique identifier for this tool call */ id: string; /** * Name of the tool to invoke */ name: string; /** * Arguments to pass to the tool */ arguments: Record<string, unknown>; } /** * Result from a tool execution */ interface AfToolResult { /** * ID of the tool call this result corresponds to */ id: string; /** * Name of the tool that was executed */ name: string; /** * Result data from the tool */ result?: unknown; /** * Error message if the tool execution failed */ error?: string; /** * Additional metadata about the tool result */ metadata?: Record<string, unknown>; } /** * Tool definition * * Tools extend the agent's capabilities beyond conversation. * They can be implemented in various languages or as schemas. */ interface AfTool { /** * Unique tool identifier */ name: string; /** * Human-readable description of what the tool does */ description: string; /** * Implementation type of the tool */ type: ToolType; /** * JSON Schema defining the tool's parameters */ parameters: AfToolParameters; /** * Optional source code for the tool implementation * Required for 'python' and 'javascript' tool types. */ source_code?: string; /** * Additional tool metadata * * Can include Mastra-specific extensions like: * - `_mastra_tool`: MCP or URL-based tool configuration * - Custom provider-specific metadata */ metadata?: Record<string, unknown> & { /** * Mastra tool extension for MCP and external tools */ _mastra_tool?: MastraToolMetadata; }; } /** * Tool parameter schema (JSON Schema format) */ interface AfToolParameters { /** * Must be 'object' for tool parameters */ type: 'object'; /** * Property definitions */ properties: Record<string, AfParameterProperty>; /** * List of required property names */ required?: string[]; /** * Whether additional properties are allowed */ additionalProperties?: boolean; } /** * Individual parameter property definition * * Follows JSON Schema specification for describing data structures. */ interface AfParameterProperty { /** * JSON Schema type * @example "string", "number", "boolean", "array", "object" */ type: string; /** * Human-readable description */ description?: string; /** * Enumerated valid values */ enum?: unknown[]; /** * Array item schema (when type is "array") */ items?: AfParameterProperty; /** * Object property schemas (when type is "object") */ properties?: Record<string, AfParameterProperty>; /** * Additional JSON Schema properties */ [key: string]: unknown; } /** * Tool usage rule * * Rules constrain how and when tools can be used by the agent. */ interface AfToolRule { /** * Name of the tool this rule applies to */ tool_name: string; /** * Type of rule to apply */ rule_type: string; /** * Rule content as string * * @example * "max_calls_per_conversation: 10" * "require_approval: true" */ rule_content: string; } /** * Mastra-specific tool metadata for external tools * * This extension enables MCP (Model Context Protocol) and URL-based tools * while maintaining backward compatibility with the standard .af format. */ interface MastraToolMetadata { /** * Tool type extension */ type: 'mcp' | 'url' | 'reference'; /** * MCP server configuration */ server?: string; /** * Tool name on the MCP server */ tool_name?: string; /** * MCP transport type */ transport?: 'stdio' | 'http'; /** * URL endpoint for HTTP-based tools */ endpoint?: string; /** * HTTP method for URL-based tools */ method?: 'GET' | 'POST'; /** * Authentication reference (never store actual credentials) */ auth_ref?: AuthReference; } /** * Authentication reference for secure credential management * * Instead of embedding credentials, we reference where to find them. */ interface AuthReference { /** * Authentication provider type */ provider: 'env' | 'vault' | 'oauth2' | 'keychain' | 'dynamic'; /** * Configuration identifier * * @example * - For 'env': "GITHUB_TOKEN" (environment variable name) * - For 'vault': "secret/api-keys/github" (vault path) * - For 'oauth2': "github_oauth" (OAuth config name) */ config_id: string; /** * Authentication metadata (non-secret information) */ metadata?: { /** * Type of authentication to use */ auth_type?: 'bearer' | 'api_key' | 'oauth2' | 'basic' | 'custom'; /** * Required OAuth scopes */ required_scopes?: string[]; /** * Token expiration time in seconds */ expires_in?: number; /** * Prompt to show when using dynamic auth */ prompt?: string; /** * Whether to cache the credential */ cache_duration?: number; }; } /** * @fileoverview Zod schemas for validating Letta .af (Agent File) format * * These schemas provide runtime validation with detailed error messages * to help users understand and fix issues with their .af files. * * @module @mastra/portability-af-letta */ /** * LLM configuration schema * Validates language model settings with provider flexibility. */ declare const llmConfigSchema: z.ZodObject<{ provider: z.ZodString; model: z.ZodString; temperature: z.ZodOptional<z.ZodNumber>; max_tokens: z.ZodOptional<z.ZodNumber>; top_p: z.ZodOptional<z.ZodNumber>; frequency_penalty: z.ZodOptional<z.ZodNumber>; presence_penalty: z.ZodOptional<z.ZodNumber>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ provider: z.ZodString; model: z.ZodString; temperature: z.ZodOptional<z.ZodNumber>; max_tokens: z.ZodOptional<z.ZodNumber>; top_p: z.ZodOptional<z.ZodNumber>; frequency_penalty: z.ZodOptional<z.ZodNumber>; presence_penalty: z.ZodOptional<z.ZodNumber>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ provider: z.ZodString; model: z.ZodString; temperature: z.ZodOptional<z.ZodNumber>; max_tokens: z.ZodOptional<z.ZodNumber>; top_p: z.ZodOptional<z.ZodNumber>; frequency_penalty: z.ZodOptional<z.ZodNumber>; presence_penalty: z.ZodOptional<z.ZodNumber>; }, z.ZodTypeAny, "passthrough">>; /** * Embedding configuration schema */ declare const embeddingConfigSchema: z.ZodObject<{ provider: z.ZodString; model: z.ZodString; dimensions: z.ZodOptional<z.ZodNumber>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ provider: z.ZodString; model: z.ZodString; dimensions: z.ZodOptional<z.ZodNumber>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ provider: z.ZodString; model: z.ZodString; dimensions: z.ZodOptional<z.ZodNumber>; }, z.ZodTypeAny, "passthrough">>; /** * Core memory block schema * Validates persistent memory segments. */ declare const coreMemoryBlockSchema: z.ZodObject<{ label: z.ZodString; value: z.ZodString; character_limit: z.ZodOptional<z.ZodNumber>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; }, "strip", z.ZodTypeAny, { value: string; label: string; character_limit?: number | undefined; metadata?: Record<string, unknown> | undefined; }, { value: string; label: string; character_limit?: number | undefined; metadata?: Record<string, unknown> | undefined; }>; /** * Tool call schema */ declare const toolCallSchema: z.ZodObject<{ id: z.ZodString; name: z.ZodString; arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; }, "strip", z.ZodTypeAny, { id: string; name: string; arguments: Record<string, unknown>; metadata?: Record<string, unknown> | undefined; }, { id: string; name: string; arguments: Record<string, unknown>; metadata?: Record<string, unknown> | undefined; }>; /** * Tool result schema */ declare const toolResultSchema: z.ZodObject<{ id: z.ZodString; name: z.ZodString; result: z.ZodOptional<z.ZodUnknown>; error: z.ZodOptional<z.ZodString>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; }, "strip", z.ZodTypeAny, { id: string; name: string; metadata?: Record<string, unknown> | undefined; result?: unknown; error?: string | undefined; }, { id: string; name: string; metadata?: Record<string, unknown> | undefined; result?: unknown; error?: string | undefined; }>; /** * Message schema * Validates conversation messages with all their components. */ declare const messageSchema: z.ZodObject<{ id: z.ZodString; role: z.ZodEnum<["user", "assistant", "system", "tool"]>; text: z.ZodString; timestamp: z.ZodString; tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{ id: z.ZodString; name: z.ZodString; arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; }, "strip", z.ZodTypeAny, { id: string; name: string; arguments: Record<string, unknown>; metadata?: Record<string, unknown> | undefined; }, { id: string; name: string; arguments: Record<string, unknown>; metadata?: Record<string, unknown> | undefined; }>, "many">>; tool_results: z.ZodOptional<z.ZodArray<z.ZodObject<{ id: z.ZodString; name: z.ZodString; result: z.ZodOptional<z.ZodUnknown>; error: z.ZodOptional<z.ZodString>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; }, "strip", z.ZodTypeAny, { id: string; name: string; metadata?: Record<string, unknown> | undefined; result?: unknown; error?: string | undefined; }, { id: string; name: string; metadata?: Record<string, unknown> | undefined; result?: unknown; error?: string | undefined; }>, "many">>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; }, "strip", z.ZodTypeAny, { id: string; role: "user" | "assistant" | "system" | "tool"; text: string; timestamp: string; metadata?: Record<string, unknown> | undefined; tool_calls?: { id: string; name: string; arguments: Record<string, unknown>; metadata?: Record<string, unknown> | undefined; }[] | undefined; tool_results?: { id: string; name: string; metadata?: Record<string, unknown> | undefined; result?: unknown; error?: string | undefined; }[] | undefined; }, { id: string; role: "user" | "assistant" | "system" | "tool"; text: string; timestamp: string; metadata?: Record<string, unknown> | undefined; tool_calls?: { id: string; name: string; arguments: Record<string, unknown>; metadata?: Record<string, unknown> | undefined; }[] | undefined; tool_results?: { id: string; name: string; metadata?: Record<string, unknown> | undefined; result?: unknown; error?: string | undefined; }[] | undefined; }>; /** * Tool parameters schema (JSON Schema format) */ declare const toolParametersSchema: z.ZodObject<{ type: z.ZodLiteral<"object">; properties: z.ZodRecord<z.ZodString, z.ZodType<AfParameterProperty, z.ZodTypeDef, AfParameterProperty>>; required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; additionalProperties: z.ZodOptional<z.ZodBoolean>; }, "strip", z.ZodTypeAny, { type: "object"; properties: Record<string, AfParameterProperty>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }, { type: "object"; properties: Record<string, AfParameterProperty>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }>; /** * Authentication reference schema * Validates secure credential references without storing actual secrets. */ declare const authReferenceSchema: z.ZodObject<{ provider: z.ZodEnum<["env", "vault", "oauth2", "keychain", "dynamic"]>; config_id: z.ZodString; metadata: z.ZodOptional<z.ZodObject<{ auth_type: z.ZodOptional<z.ZodEnum<["bearer", "api_key", "oauth2", "basic", "custom"]>>; required_scopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; expires_in: z.ZodOptional<z.ZodNumber>; prompt: z.ZodOptional<z.ZodString>; cache_duration: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { auth_type?: "oauth2" | "bearer" | "api_key" | "basic" | "custom" | undefined; required_scopes?: string[] | undefined; expires_in?: number | undefined; prompt?: string | undefined; cache_duration?: number | undefined; }, { auth_type?: "oauth2" | "bearer" | "api_key" | "basic" | "custom" | undefined; required_scopes?: string[] | undefined; expires_in?: number | undefined; prompt?: string | undefined; cache_duration?: number | undefined; }>>; }, "strip", z.ZodTypeAny, { provider: "env" | "vault" | "oauth2" | "keychain" | "dynamic"; config_id: string; metadata?: { auth_type?: "oauth2" | "bearer" | "api_key" | "basic" | "custom" | undefined; required_scopes?: string[] | undefined; expires_in?: number | undefined; prompt?: string | undefined; cache_duration?: number | undefined; } | undefined; }, { provider: "env" | "vault" | "oauth2" | "keychain" | "dynamic"; config_id: string; metadata?: { auth_type?: "oauth2" | "bearer" | "api_key" | "basic" | "custom" | undefined; required_scopes?: string[] | undefined; expires_in?: number | undefined; prompt?: string | undefined; cache_duration?: number | undefined; } | undefined; }>; /** * Mastra tool metadata schema * Validates MCP and external tool configurations. */ declare const mastraToolMetadataSchema: z.ZodEffects<z.ZodObject<{ type: z.ZodEnum<["mcp", "url", "reference"]>; server: z.ZodOptional<z.ZodString>; tool_name: z.ZodOptional<z.ZodString>; transport: z.ZodOptional<z.ZodEnum<["stdio", "http"]>>; endpoint: z.ZodOptional<z.ZodString>; method: z.ZodOptional<z.ZodEnum<["GET", "POST"]>>; auth_ref: z.ZodOptional<z.ZodObject<{ provider: z.ZodEnum<["env", "vault", "oauth2", "keychain", "dynamic"]>; config_id: z.ZodString; metadata: z.ZodOptional<z.ZodObject<{ auth_type: z.ZodOptional<z.ZodEnum<["bearer", "api_key", "oauth2", "basic", "custom"]>>; required_scopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; expires_in: z.ZodOptional<z.ZodNumber>; prompt: z.ZodOptional<z.ZodString>; cache_duration: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { auth_type?: "oauth2" | "bearer" | "api_key" | "basic" | "custom" | undefined; required_scopes?: string[] | undefined; expires_in?: number | undefined; prompt?: string | undefined; cache_duration?: number | undefined; }, { auth_type?: "oauth2" | "bearer" | "api_key" | "basic" | "custom" | undefined; required_scopes?: string[] | undefined; expires_in?: number | undefined; prompt?: string | undefined; cache_duration?: number | undefined; }>>; }, "strip", z.ZodTypeAny, { provider: "env" | "vault" | "oauth2" | "keychain" | "dynamic"; config_id: string; metadata?: { auth_type?: "oauth2" | "bearer" | "api_key" | "basic" | "custom" | undefined; required_scopes?: string[] | undefined; expires_in?: number | undefined; prompt?: string | undefined; cache_duration?: number | undefined; } | undefined; }, { provider: "env" | "vault" | "oauth2" | "keychain" | "dynamic"; config_id: string; metadata?: { auth_type?: "oauth2" | "bearer" | "api_key" | "basic" | "custom" | undefined; required_scopes?: string[] | undefined; expires_in?: number | undefined; prompt?: string | undefined; cache_duration?: number | undefined; } | undefined; }>>; }, "strip", z.ZodTypeAny, { type: "mcp" | "url" | "reference"; server?: string | undefined; tool_name?: string | undefined; transport?: "stdio" | "http" | undefined; endpoint?: string | undefined; method?: "GET" | "POST" | undefined; auth_ref?: { provider: "env" | "vault" | "oauth2" | "keychain" | "dynamic"; config_id: string; metadata?: { auth_type?: "oauth2" | "bearer" | "api_key" | "basic" | "custom" | undefined; required_scopes?: string[] | undefined; expires_in?: number | undefined; prompt?: string | undefined; cache_duration?: number | undefined; } | undefined; } | undefined; }, { type: "mcp" | "url" | "reference"; server?: string | undefined; tool_name?: string | undefined; transport?: "stdio" | "http" | undefined; endpoint?: string | undefined; method?: "GET" | "POST" | undefined; auth_ref?: { provider: "env" | "vault" | "oauth2" | "keychain" | "dynamic"; config_id: string; metadata?: { auth_type?: "oauth2" | "bearer" | "api_key" | "basic" | "custom" | undefined; required_scopes?: string[] | undefined; expires_in?: number | undefined; prompt?: string | undefined; cache_duration?: number | undefined; } | undefined; } | undefined; }>, { type: "mcp" | "url" | "reference"; server?: string | undefined; tool_name?: string | undefined; transport?: "stdio" | "http" | undefined; endpoint?: string | undefined; method?: "GET" | "POST" | undefined; auth_ref?: { provider: "env" | "vault" | "oauth2" | "keychain" | "dynamic"; config_id: string; metadata?: { auth_type?: "oauth2" | "bearer" | "api_key" | "basic" | "custom" | undefined; required_scopes?: string[] | undefined; expires_in?: number | undefined; prompt?: string | undefined; cache_duration?: number | undefined; } | undefined; } | undefined; }, { type: "mcp" | "url" | "reference"; server?: string | undefined; tool_name?: string | undefined; transport?: "stdio" | "http" | undefined; endpoint?: string | undefined; method?: "GET" | "POST" | undefined; auth_ref?: { provider: "env" | "vault" | "oauth2" | "keychain" | "dynamic"; config_id: string; metadata?: { auth_type?: "oauth2" | "bearer" | "api_key" | "basic" | "custom" | undefined; required_scopes?: string[] | undefined; expires_in?: number | undefined; prompt?: string | undefined; cache_duration?: number | undefined; } | undefined; } | undefined; }>; /** * Tool schema * Validates tool definitions with appropriate constraints. */ declare const toolSchema: z.ZodEffects<z.ZodObject<{ name: z.ZodString; description: z.ZodString; type: z.ZodEnum<["python", "javascript", "json_schema"]>; parameters: z.ZodObject<{ type: z.ZodLiteral<"object">; properties: z.ZodRecord<z.ZodString, z.ZodType<AfParameterProperty, z.ZodTypeDef, AfParameterProperty>>; required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; additionalProperties: z.ZodOptional<z.ZodBoolean>; }, "strip", z.ZodTypeAny, { type: "object"; properties: Record<string, AfParameterProperty>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }, { type: "object"; properties: Record<string, AfParameterProperty>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }>; source_code: z.ZodOptional<z.ZodString>; metadata: z.ZodEffects<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>, Record<string, unknown> | undefined, Record<string, unknown> | undefined>; }, "strip", z.ZodTypeAny, { type: "python" | "javascript" | "json_schema"; description: string; name: string; parameters: { type: "object"; properties: Record<string, AfParameterProperty>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }; metadata?: Record<string, unknown> | undefined; source_code?: string | undefined; }, { type: "python" | "javascript" | "json_schema"; description: string; name: string; parameters: { type: "object"; properties: Record<string, AfParameterProperty>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }; metadata?: Record<string, unknown> | undefined; source_code?: string | undefined; }>, { type: "python" | "javascript" | "json_schema"; description: string; name: string; parameters: { type: "object"; properties: Record<string, AfParameterProperty>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }; metadata?: Record<string, unknown> | undefined; source_code?: string | undefined; }, { type: "python" | "javascript" | "json_schema"; description: string; name: string; parameters: { type: "object"; properties: Record<string, AfParameterProperty>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }; metadata?: Record<string, unknown> | undefined; source_code?: string | undefined; }>; /** * Tool rule schema */ declare const toolRuleSchema: z.ZodObject<{ tool_name: z.ZodString; rule_type: z.ZodString; rule_content: z.ZodString; }, "strip", z.ZodTypeAny, { tool_name: string; rule_type: string; rule_content: string; }, { tool_name: string; rule_type: string; rule_content: string; }>; /** * Main agent schema * Validates the complete .af file structure with all components. */ declare const afAgentSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{ agent_type: z.ZodString; name: z.ZodString; description: z.ZodOptional<z.ZodString>; system: z.ZodString; llm_config: z.ZodObject<{ provider: z.ZodString; model: z.ZodString; temperature: z.ZodOptional<z.ZodNumber>; max_tokens: z.ZodOptional<z.ZodNumber>; top_p: z.ZodOptional<z.ZodNumber>; frequency_penalty: z.ZodOptional<z.ZodNumber>; presence_penalty: z.ZodOptional<z.ZodNumber>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ provider: z.ZodString; model: z.ZodString; temperature: z.ZodOptional<z.ZodNumber>; max_tokens: z.ZodOptional<z.ZodNumber>; top_p: z.ZodOptional<z.ZodNumber>; frequency_penalty: z.ZodOptional<z.ZodNumber>; presence_penalty: z.ZodOptional<z.ZodNumber>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ provider: z.ZodString; model: z.ZodString; temperature: z.ZodOptional<z.ZodNumber>; max_tokens: z.ZodOptional<z.ZodNumber>; top_p: z.ZodOptional<z.ZodNumber>; frequency_penalty: z.ZodOptional<z.ZodNumber>; presence_penalty: z.ZodOptional<z.ZodNumber>; }, z.ZodTypeAny, "passthrough">>; embedding_config: z.ZodOptional<z.ZodObject<{ provider: z.ZodString; model: z.ZodString; dimensions: z.ZodOptional<z.ZodNumber>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ provider: z.ZodString; model: z.ZodString; dimensions: z.ZodOptional<z.ZodNumber>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ provider: z.ZodString; model: z.ZodString; dimensions: z.ZodOptional<z.ZodNumber>; }, z.ZodTypeAny, "passthrough">>>; core_memory: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodObject<{ label: z.ZodString; value: z.ZodString; character_limit: z.ZodOptional<z.ZodNumber>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; }, "strip", z.ZodTypeAny, { value: string; label: string; character_limit?: number | undefined; metadata?: Record<string, unknown> | undefined; }, { value: string; label: string; character_limit?: number | undefined; metadata?: Record<string, unknown> | undefined; }>>, Record<string, { value: string; label: string; character_limit?: number | undefined; metadata?: Record<string, unknown> | undefined; }>, Record<string, { value: string; label: string; character_limit?: number | undefined; metadata?: Record<string, unknown> | undefined; }>>; messages: z.ZodArray<z.ZodObject<{ id: z.ZodString; role: z.ZodEnum<["user", "assistant", "system", "tool"]>; text: z.ZodString; timestamp: z.ZodString; tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{ id: z.ZodString; name: z.ZodString; arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; }, "strip", z.ZodTypeAny, { id: string; name: string; arguments: Record<string, unknown>; metadata?: Record<string, unknown> | undefined; }, { id: string; name: string; arguments: Record<string, unknown>; metadata?: Record<string, unknown> | undefined; }>, "many">>; tool_results: z.ZodOptional<z.ZodArray<z.ZodObject<{ id: z.ZodString; name: z.ZodString; result: z.ZodOptional<z.ZodUnknown>; error: z.ZodOptional<z.ZodString>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; }, "strip", z.ZodTypeAny, { id: string; name: string; metadata?: Record<string, unknown> | undefined; result?: unknown; error?: string | undefined; }, { id: string; name: string; metadata?: Record<string, unknown> | undefined; result?: unknown; error?: string | undefined; }>, "many">>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; }, "strip", z.ZodTypeAny, { id: string; role: "user" | "assistant" | "system" | "tool"; text: string; timestamp: string; metadata?: Record<string, unknown> | undefined; tool_calls?: { id: string; name: string; arguments: Record<string, unknown>; metadata?: Record<string, unknown> | undefined; }[] | undefined; tool_results?: { id: string; name: string; metadata?: Record<string, unknown> | undefined; result?: unknown; error?: string | undefined; }[] | undefined; }, { id: string; role: "user" | "assistant" | "system" | "tool"; text: string; timestamp: string; metadata?: Record<string, unknown> | undefined; tool_calls?: { id: string; name: string; arguments: Record<string, unknown>; metadata?: Record<string, unknown> | undefined; }[] | undefined; tool_results?: { id: string; name: string; metadata?: Record<string, unknown> | undefined; result?: unknown; error?: string | undefined; }[] | undefined; }>, "many">; in_context_message_indices: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>; tools: z.ZodArray<z.ZodEffects<z.ZodObject<{ name: z.ZodString; description: z.ZodString; type: z.ZodEnum<["python", "javascript", "json_schema"]>; parameters: z.ZodObject<{ type: z.ZodLiteral<"object">; properties: z.ZodRecord<z.ZodString, z.ZodType<AfParameterProperty, z.ZodTypeDef, AfParameterProperty>>; required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; additionalProperties: z.ZodOptional<z.ZodBoolean>; }, "strip", z.ZodTypeAny, { type: "object"; properties: Record<string, AfParameterProperty>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }, { type: "object"; properties: Record<string, AfParameterProperty>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }>; source_code: z.ZodOptional<z.ZodString>; metadata: z.ZodEffects<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>, Record<string, unknown> | undefined, Record<string, unknown> | undefined>; }, "strip", z.ZodTypeAny, { type: "python" | "javascript" | "json_schema"; description: string; name: string; parameters: { type: "object"; properties: Record<string, AfParameterProperty>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }; metadata?: Record<string, unknown> | undefined; source_code?: string | undefined; }, { type: "python" | "javascript" | "json_schema"; description: string; name: string; parameters: { type: "object"; properties: Record<string, AfParameterProperty>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }; metadata?: Record<string, unknown> | undefined; source_code?: string | undefined; }>, { type: "python" | "javascript" | "json_schema"; description: string; name: string; parameters: { type: "object"; properties: Record<string, AfParameterProperty>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }; metadata?: Record<string, unknown> | undefined; source_code?: string | undefined; }, { type: "python" | "javascript" | "json_schema"; description: string; name: string; parameters: { type: "object"; properties: Record<string, AfParameterProperty>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }; metadata?: Record<string, unknown> | undefined; source_code?: string | undefined; }>, "many">; tool_rules: z.ZodOptional<z.ZodArray<z.ZodObject<{ tool_name: z.ZodString; rule_type: z.ZodString; rule_content: z.ZodString; }, "strip", z.ZodTypeAny, { tool_name: string; rule_type: string; rule_content: string; }, { tool_name: string; rule_type: string; rule_content: string; }>, "many">>; tool_exec_environment_variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; metadata_: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; version: z.ZodString; created_at: z.ZodString; updated_at: z.ZodString; }, "strip", z.ZodTypeAny, { system: string; name: string; agent_type: string; llm_config: { provider: string; model: string; temperature?: number | undefined; max_tokens?: number | undefined; top_p?: number | undefined; frequency_penalty?: number | undefined; presence_penalty?: number | undefined; } & { [k: string]: unknown; }; core_memory: Record<string, { value: string; label: string; character_limit?: number | undefined; metadata?: Record<string, unknown> | undefined; }>; messages: { id: string; role: "user" | "assistant" | "system" | "tool"; text: string; timestamp: string; metadata?: Record<string, unknown> | undefined; tool_calls?: { id: string; name: string; arguments: Record<string, unknown>; metadata?: Record<string, unknown> | undefined; }[] | undefined; tool_results?: { id: string; name: string; metadata?: Record<string, unknown> | undefined; result?: unknown; error?: string | undefined; }[] | undefined; }[]; tools: { type: "python" | "javascript" | "json_schema"; description: string; name: string; parameters: { type: "object"; properties: Record<string, AfParameterProperty>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }; metadata?: Record<string, unknown> | undefined; source_code?: string | undefined; }[]; version: string; created_at: string; updated_at: string; description?: string | undefined; embedding_config?: z.objectOutputType<{ provider: z.ZodString; model: z.ZodString; dimensions: z.ZodOptional<z.ZodNumber>; }, z.ZodTypeAny, "passthrough"> | undefined; in_context_message_indices?: number[] | undefined; tool_rules?: { tool_name: string; rule_type: string; rule_content: string; }[] | undefined; tool_exec_environment_variables?: Record<string, string> | undefined; tags?: string[] | undefined; metadata_?: Record<string, unknown> | undefined; }, { system: string; name: string; agent_type: string; llm_config: { provider: string; model: string; temperature?: number | undefined; max_tokens?: number | undefined; top_p?: number | undefined; frequency_penalty?: number | undefined; presence_penalty?: number | undefined; } & { [k: string]: unknown; }; core_memory: Record<string, { value: string; label: string; character_limit?: number | undefined; metadata?: Record<string, unknown> | undefined; }>; messages: { id: string; role: "user" | "assistant" | "system" | "tool"; text: string; timestamp: string; metadata?: Record<string, unknown> | undefined; tool_calls?: { id: string; name: string; arguments: Record<string, unknown>; metadata?: Record<string, unknown> | undefined; }[] | undefined; tool_results?: { id: string; name: string; metadata?: Record<string, unknown> | undefined; result?: unknown; error?: string | undefined; }[] | undefined; }[]; tools: { type: "python" | "javascript" | "json_schema"; description: string; name: string; parameters: { type: "object"; properties: Record<string, AfParameterProperty>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }; metadata?: Record<string, unknown> | undefined; source_code?: string | undefined; }[]; version: string; created_at: string; updated_at: string; description?: string | undefined; embedding_config?: z.objectInputType<{ provider: z.ZodString; model: z.ZodString; dimensions: z.ZodOptional<z.ZodNumber>; }, z.ZodTypeAny, "passthrough"> | undefined; in_context_message_indices?: number[] | undefined; tool_rules?: { tool_name: string; rule_type: string; rule_content: string; }[] | undefined; tool_exec_environment_variables?: Record<string, string> | undefined; tags?: string[] | undefined; metadata_?: Record<string, unknown> | undefined; }>, { system: string; name: string; agent_type: string; llm_config: { provider: string; model: string; temperature?: number | undefined; max_tokens?: number | undefined; top_p?: number | undefined; frequency_penalty?: number | undefined; presence_penalty?: number | undefined; } & { [k: string]: unknown; }; core_memory: Record<string, { value: string; label: string; character_limit?: number | undefined; metadata?: Record<string, unknown> | undefined; }>; messages: { id: string; role: "user" | "assistant" | "system" | "tool"; text: string; timestamp: string; metadata?: Record<string, unknown> | undefined; tool_calls?: { id: string; name: string; arguments: Record<string, unknown>; metadata?: Record<string, unknown> | undefined; }[] | undefined; tool_results?: { id: string; name: string; metadata?: Record<string, unknown> | undefined; result?: unknown; error?: string | undefined; }[] | undefined; }[]; tools: { type: "python" | "javascript" | "json_schema"; description: string; name: string; parameters: { type: "object"; properties: Record<string, AfParameterProperty>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }; metadata?: Record<string, unknown> | undefined; source_code?: string | undefined; }[]; version: string; created_at: string; updated_at: string; description?: string | undefined; embedding_config?: z.objectOutputType<{ provider: z.ZodString; model: z.ZodString; dimensions: z.ZodOptional<z.ZodNumber>; }, z.ZodTypeAny, "passthrough"> | undefined; in_context_message_indices?: number[] | undefined; tool_rules?: { tool_name: string; rule_type: string; rule_content: string; }[] | undefined; tool_exec_environment_variables?: Record<string, string> | undefined; tags?: string[] | undefined; metadata_?: Record<string, unknown> | undefined; }, { system: string; name: string; agent_type: string; llm_config: { provider: string; model: string; temperature?: number | undefined; max_tokens?: number | undefined; top_p?: number | undefined; frequency_penalty?: number | undefined; presence_penalty?: number | undefined; } & { [k: string]: unknown; }; core_memory: Record<string, { value: string; label: string; character_limit?: number | undefined; metadata?: Record<string, unknown> | undefined; }>; messages: { id: string; role: "user" | "assistant" | "system" | "tool"; text: string; timestamp: string; metadata?: Record<string, unknown> | undefined; tool_calls?: { id: string; name: string; arguments: Record<string, unknown>; metadata?: Record<string, unknown> | undefined; }[] | undefined; tool_results?: { id: string; name: string; metadata?: Record<string, unknown> | undefined; result?: unknown; error?: string | undefined; }[] | undefined; }[]; tools: { type: "python" | "javascript" | "json_schema"; description: string; name: string; parameters: { type: "object"; properties: Record<string, AfParameterProperty>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }; metadata?: Record<string, unknown> | undefined; source_code?: string | undefined; }[]; version: string; created_at: string; updated_at: string; description?: string | undefined; embedding_config?: z.objectInputType<{ provider: z.ZodString; model: z.ZodString; dimensions: z.ZodOptional<z.ZodNumber>; }, z.ZodTypeAny, "passthrough"> | undefined; in_context_message_indices?: number[] | undefined; tool_rules?: { tool_name: string; rule_type: string; rule_content: string; }[] | undefined; tool_exec_environment_variables?: Record<string, string> | undefined; tags?: string[] | undefined; metadata_?: Record<string, unknown> | undefined; }>, { system: string; name: string; agent_type: string; llm_config: { provider: string; model: string; temperature?: number | undefined; max_tokens?: number | undefined; top_p?: number | undefined; frequency_penalty?: number | undefined; presence_penalty?: number | undefined; } & { [k: string]: unknown; }; core_memory: Record<string, { value: string; label: string; character_limit?: number | undefined; metadata?: Record<string, unknown> | undefined; }>; messages: { id: string; role: "user" | "assistant" | "system" | "tool"; text: string; timestamp: string; metadata?: Record<string, unknown> | undefined; tool_calls?: { id: string; name: string; arguments: Record<string, unknown>; metadata?: Record<string, unknown> | undefined; }[] | undefined; tool_results?: { id: string; name: string; metadata?: Record<string, unknown> | undefined; result?: unknown; error?: string | undefined; }[] | undefined; }[]; tools: { type: "python" | "javascript" | "json_schema"; description: string; name: string; parameters: { type: "object"; properties: Record<string, AfParameterProperty>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }; metadata?: Record<string, unknown> | undefined; source_code?: string | undefined; }[]; version: string; created_at: string; updated_at: string; description?: string | undefined; embedding_config?: z.objectOutputType<{ provider: z.ZodString; model: z.ZodString; dimensions: z.ZodOptional<z.ZodNumber>; }, z.ZodTypeAny, "passthrough"> | undefined; in_context_message_indices?: number[] | undefined; tool_rules?: { tool_name: string; rule_type: string; rule_content: string; }[] | undefined; tool_exec_environment_variables?: Record<string, string> | undefined; tags?: string[] | undefined; metadata_?: Record<string, unknown> | undefined; }, { system: string; name: string; agent_type: string; llm_config: { provider: string; model: string; temperature?: number | undefined; max_tokens?: number | undefined; top_p?: number | undefined; frequency_penalty?: number | undefined; presence_penalty?: number | undefined; } & { [k: string]: unknown; }; core_memory: Record<string, { value: string;