{"version":3,"sources":["../src/index.ts","../src/data/call_template.ts","../src/interfaces/serializer.ts","../src/data/utcp_manual.ts","../src/data/tool.ts","../src/version.ts","../src/interfaces/communication_protocol.ts","../src/client/utcp_client_config.ts","../src/data/auth.ts","../src/data/auth_implementations/api_key_auth.ts","../src/data/auth_implementations/basic_auth.ts","../src/data/auth_implementations/oauth2_auth.ts","../src/data/auth_implementations/oauth2_user_auth.ts","../src/implementations/in_mem_concurrent_tool_repository.ts","../src/interfaces/concurrent_tool_repository.ts","../src/implementations/tag_search_strategy.ts","../src/interfaces/tool_search_strategy.ts","../src/implementations/post_processors/filter_dict_post_processor.ts","../src/implementations/post_processors/limit_strings_post_processor.ts","../src/interfaces/tool_post_processor.ts","../src/plugins/plugin_loader.ts","../src/data/variable_loader.ts","../src/exceptions/utcp_variable_not_found_error.ts","../src/implementations/default_variable_substitutor.ts","../src/client/utcp_client.ts"],"sourcesContent":["// packages/core/src/index.ts\r\n// Client\r\nexport * from './client/utcp_client';\r\nexport * from './client/utcp_client_config';\r\n\r\n// Data Models\r\nexport * from './data/auth';\r\nexport * from './data/auth_implementations/api_key_auth';\r\nexport * from './data/auth_implementations/basic_auth';\r\nexport * from './data/auth_implementations/oauth2_auth';\r\nexport * from './data/auth_implementations/oauth2_user_auth';\r\nexport * from './data/call_template';\r\nexport * from './data/tool';\r\nexport * from './data/utcp_manual';\r\nexport * from './data/register_manual_result'; \r\nexport * from './data/variable_loader';\r\n\r\n// Interfaces\r\nexport * from './interfaces';\r\n\r\n// Implementations\r\nexport * from './implementations/in_mem_concurrent_tool_repository';\r\nexport * from './implementations/tag_search_strategy';\r\nexport * from './implementations/default_variable_substitutor';\r\nexport * from './implementations/post_processors/filter_dict_post_processor';\r\nexport * from './implementations/post_processors/limit_strings_post_processor';\r\n\r\n// Plugins\r\nexport * from './plugins/plugin_loader';","// packages/core/src/data/call_template.ts\r\nimport { z } from 'zod';\r\nimport { Auth, AuthSchema } from './auth';\r\nimport { Serializer } from '../interfaces/serializer';\r\n\r\n/**\r\n * Base interface for all CallTemplates. Each protocol plugin will implement this structure.\r\n * It provides the common fields every call template must have.\r\n */\r\nexport interface CallTemplate {\r\n  /**\r\n   * Unique identifier for the CallTemplate/Manual. Recommended to be a human-readable name.\r\n   */\r\n  name?: string;\r\n\r\n  /**\r\n   * The transport protocol type used by this call template (e.g., 'http', 'mcp', 'text').\r\n   */\r\n  call_template_type: string;\r\n\r\n  /**\r\n   * Optional authentication configuration for the provider.\r\n   */\r\n  auth?: Auth;\r\n\r\n  /**\r\n   * Optional list of allowed communication protocol types for tools within this manual.\r\n   * \r\n   * Behavior:\r\n   * - If undefined, null, or empty array → defaults to only allowing the manual's own call_template_type\r\n   * - If set to a non-empty array → only those protocol types are allowed\r\n   * \r\n   * This provides secure-by-default behavior where a manual can only register/call tools\r\n   * that use its own protocol unless explicitly configured otherwise.\r\n   */\r\n  allowed_communication_protocols?: string[];\r\n\r\n  [key: string]: any;\r\n}\r\n\r\nexport class CallTemplateSerializer extends Serializer<CallTemplate> {\r\n  private static serializers: Record<string, Serializer<CallTemplate>> = {};\r\n\r\n  // No need for the whole plugin registry. Plugins just need to call this to register a new call template type\r\n  static registerCallTemplate(\r\n    callTemplateType: string,\r\n    serializer: Serializer<CallTemplate>,\r\n    override = false\r\n  ): boolean {\r\n    if (!override && CallTemplateSerializer.serializers[callTemplateType]) {\r\n      return false;\r\n    }\r\n    CallTemplateSerializer.serializers[callTemplateType] = serializer;\r\n    return true;\r\n  }\r\n\r\n  toDict(obj: CallTemplate): Record<string, unknown> {\r\n    const serializer = CallTemplateSerializer.serializers[obj.call_template_type];\r\n    if (!serializer) {\r\n      throw new Error(`No serializer found for call_template_type: ${obj.call_template_type}`);\r\n    }\r\n    return serializer.toDict(obj);\r\n  }\r\n\r\n  validateDict(obj: Record<string, unknown>): CallTemplate {\r\n    const serializer = CallTemplateSerializer.serializers[obj.call_template_type as string];\r\n    if (!serializer) {\r\n      throw new Error(`Invalid call_template_type: ${obj.call_template_type}`);\r\n    }\r\n    return serializer.validateDict(obj);\r\n  }\r\n}\r\n\r\nexport const CallTemplateSchema = z\r\n  .custom<CallTemplate>((obj) => {\r\n    try {\r\n      // Use the centralized serializer to validate & return the correct subtype\r\n      const validated = new CallTemplateSerializer().validateDict(obj as Record<string, unknown>);\r\n      return validated;\r\n    } catch (e) {\r\n      return false; // z.custom treats false as validation failure\r\n    }\r\n  }, {\r\n    message: \"Invalid CallTemplate object\",\r\n  });","let ensurePluginsInitialized: (() => void) | null = null;\r\n\r\nexport function setPluginInitializer(fn: () => void): void {\r\n  ensurePluginsInitialized = fn;\r\n}\r\n\r\nexport abstract class Serializer<T> {\r\n  constructor() {\r\n    // Use lazy initialization to avoid circular dependency during module loading\r\n    if (ensurePluginsInitialized) {\r\n      ensurePluginsInitialized();\r\n    }\r\n  }\r\n\r\n  abstract toDict(obj: T): { [key: string]: any };\r\n\r\n  abstract validateDict(obj: { [key: string]: any }): T;\r\n\r\n  copy(obj: T): T {\r\n    return this.validateDict(this.toDict(obj));\r\n  }\r\n}","// packages/core/src/data/utcp_manual.ts\r\nimport { z } from 'zod';\r\nimport { ToolSchema, Tool } from './tool';\r\nimport { Serializer } from '../interfaces/serializer';\r\nimport { LIB_VERSION } from '../version';\r\n\r\n/**\r\n * The default UTCP protocol version used throughout the library.\r\n * This is replaced at build time with the actual package version.\r\n * Use this constant when creating UtcpManual objects to ensure version consistency.\r\n */\r\nexport const UTCP_PACKAGE_VERSION = LIB_VERSION;\r\n\r\n/**\r\n * Interface for the standard format for tool provider responses during discovery.\r\n * Represents the complete set of tools available from a provider, along\r\n * with version information for compatibility checking.\r\n */\r\nexport interface UtcpManual {\r\n  /**\r\n   * The UTCP protocol version supported by the provider.\r\n   */\r\n  utcp_version: string;\r\n\r\n  /**\r\n   * The version of this specific manual/specification.\r\n   */\r\n  manual_version: string;\r\n\r\n  /**\r\n   * List of available tools with their complete configurations.\r\n   */\r\n  tools: Tool[];\r\n}\r\n\r\n/**\r\n * The standard format for tool provider responses during discovery.\r\n * This schema is used for runtime validation and parsing of UTCP manuals.\r\n */\r\nexport const UtcpManualSchema: z.ZodType<UtcpManual> = z.object({\r\n  // Use .optional() to allow missing in input, then .default() to satisfy the interface.\r\n  utcp_version: z.string().optional().default(UTCP_PACKAGE_VERSION)\r\n    .describe('UTCP protocol version supported by the provider.'),\r\n  manual_version: z.string().optional().default('1.0.0')\r\n    .describe('Version of this specific manual.'),\r\n  tools: z.array(ToolSchema)\r\n    .describe('List of available tools with their complete configurations.'),\r\n}).strict() as z.ZodType<UtcpManual>;\r\n\r\n/**\r\n * Serializer for UtcpManual objects.\r\n * Handles serialization and deserialization of complete UTCP manual definitions.\r\n */\r\nexport class UtcpManualSerializer extends Serializer<UtcpManual> {\r\n  toDict(obj: UtcpManual): Record<string, unknown> {\r\n    return {\r\n      utcp_version: obj.utcp_version,\r\n      manual_version: obj.manual_version,\r\n      tools: obj.tools,\r\n    };\r\n  }\r\n\r\n  validateDict(obj: Record<string, unknown>): UtcpManual {\r\n    return UtcpManualSchema.parse(obj);\r\n  }\r\n}","// packages/core/src/data/tool.ts\r\nimport { z } from 'zod';\r\nimport { CallTemplate, CallTemplateSchema } from './call_template';\r\nimport { Serializer } from '../interfaces/serializer';\r\n\r\n// Define a recursive type for basic JSON values\r\n/**\r\n * A recursive type representing any valid JSON value: string, number, boolean, null, object, or array.\r\n */\r\ntype JsonValue = string | number | boolean | null | { [key: string]: JsonValue } | JsonValue[];\r\n\r\n// --- JSON Schema Typing and Validation ---\r\n\r\n/**\r\n * Zod type for basic JSON primitive or recursive structure.\r\n */\r\nexport const JsonTypeSchema: z.ZodType<JsonValue> = z.lazy(() => z.union([\r\n  z.string(),\r\n  z.number(),\r\n  z.boolean(),\r\n  z.null(),\r\n  z.record(z.string(), JsonTypeSchema),\r\n  z.array(JsonTypeSchema),\r\n]));\r\nexport type JsonType = z.infer<typeof JsonTypeSchema>;\r\n\r\n\r\n/**\r\n * Interface for a JSON Schema definition (based on draft-07).\r\n * This defines the structure for tool inputs and outputs.\r\n */\r\nexport interface JsonSchema {\r\n  /**\r\n   * Optional schema identifier.\r\n   */\r\n  $schema?: string;\r\n  /**\r\n   * Optional schema identifier.\r\n   */\r\n  $id?: string;\r\n  /**\r\n   * Optional schema title.\r\n   */\r\n  title?: string;\r\n  /**\r\n   * Optional schema description.\r\n   */\r\n  description?: string;\r\n  /**\r\n   * The JSON data type (e.g., 'object', 'string', 'number').\r\n   */\r\n  type?: 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null' | string[];\r\n  /**\r\n   * Defines properties if type is 'object'.\r\n   */\r\n  properties?: { [key: string]: JsonSchema };\r\n  /**\r\n   * Defines item structure if type is 'array'.\r\n   */\r\n  items?: JsonSchema | JsonSchema[];\r\n  /**\r\n   * List of required properties if type is 'object'.\r\n   */\r\n  required?: string[];\r\n  /**\r\n   * List of allowable values.\r\n   */\r\n  enum?: JsonType[];\r\n  /**\r\n   * The exact required value.\r\n   */\r\n  const?: JsonType;\r\n  /**\r\n   * A default value for the property.\r\n   */\r\n  default?: JsonType;\r\n  /**\r\n   * Example values for the schema (JSON Schema 'examples' keyword).\r\n   */\r\n  examples?: JsonType[];\r\n  /**\r\n   * Optional format hint (e.g., 'date-time', 'email').\r\n   */\r\n  format?: string;\r\n  /**\r\n   * Allows or specifies schema for additional properties.\r\n   */\r\n  additionalProperties?: boolean | JsonSchema;\r\n  /**\r\n   * Regex pattern for string validation.\r\n   */\r\n  pattern?: string;\r\n  /**\r\n   * Minimum numeric value.\r\n   */\r\n  minimum?: number;\r\n  /**\r\n   * Maximum numeric value.\r\n   */\r\n  maximum?: number;\r\n  /**\r\n   * Minimum string length.\r\n   */\r\n  minLength?: number;\r\n  /**\r\n   * Maximum string length.\r\n   */\r\n  maxLength?: number;\r\n  [k: string]: unknown;\r\n}\r\n\r\n\r\n/**\r\n * Zod schema corresponding to the JsonSchema interface.\r\n */\r\nexport const JsonSchemaSchema: z.ZodType<JsonSchema> = z.lazy(() => z.object({\r\n  $schema: z.string().optional().describe('JSON Schema version URI.'),\r\n  $id: z.string().optional().describe('A URI for the schema.'),\r\n  title: z.string().optional().describe('A short explanation about the purpose of the data described by this schema.'),\r\n  description: z.string().optional().describe('A more lengthy explanation about the purpose of the data described by this schema.'),\r\n  type: z.union([\r\n    z.literal('string'), z.literal('number'), z.literal('integer'), z.literal('boolean'),\r\n    z.literal('object'), z.literal('array'), z.literal('null'), z.array(z.string())\r\n  ]).optional(),\r\n  properties: z.record(z.string(), z.lazy(() => JsonSchemaSchema)).optional(),\r\n  items: z.union([z.lazy(() => JsonSchemaSchema), z.array(z.lazy(() => JsonSchemaSchema))]).optional(),\r\n  required: z.array(z.string()).optional(),\r\n  enum: z.array(JsonTypeSchema).optional(),\r\n  const: JsonTypeSchema.optional(),\r\n  default: JsonTypeSchema.optional(),\r\n  examples: z.array(JsonTypeSchema).optional(),\r\n  format: z.string().optional(),\r\n  additionalProperties: z.union([z.boolean(), z.lazy(() => JsonSchemaSchema)]).optional(),\r\n  pattern: z.string().optional(),\r\n  minimum: z.number().optional(),\r\n  maximum: z.number().optional(),\r\n  minLength: z.number().optional(),\r\n  maxLength: z.number().optional(),\r\n}).catchall(z.unknown()));\r\n\r\n\r\n// --- Tool Typing and Validation ---\r\n\r\n/**\r\n * Interface for a UTCP Tool.\r\n * Represents a callable tool with its metadata, input/output schemas,\r\n * and associated call template. Tools are the fundamental units of\r\n * functionality in the UTCP ecosystem.\r\n */\r\nexport interface Tool {\r\n  /**\r\n   * Unique identifier for the tool, typically in format \"manual_name.tool_name\".\r\n   */\r\n  name: string;\r\n  /**\r\n   * Human-readable description of what the tool does.\r\n   */\r\n  description: string;\r\n  /**\r\n   * JSON Schema defining the tool's input parameters.\r\n   */\r\n  inputs: JsonSchema;\r\n  /**\r\n   * JSON Schema defining the tool's return value structure.\r\n   */\r\n  outputs: JsonSchema;\r\n  /**\r\n   * List of tags for categorization and search.\r\n   */\r\n  tags: string[];\r\n  /**\r\n   * Optional hint about typical response size in bytes.\r\n   */\r\n  average_response_size?: number;\r\n  /**\r\n   * CallTemplate configuration for accessing this tool.\r\n   */\r\n  tool_call_template: CallTemplate;\r\n}\r\n\r\n/**\r\n * Zod schema corresponding to the Tool interface.\r\n */\r\nexport const ToolSchema: z.ZodType<Tool> = z.object({\r\n  name: z.string().describe('Unique identifier for the tool, typically in format \"manual_name.tool_name\".'),\r\n  description: z.string().default('').describe('Human-readable description of what the tool does.'),\r\n  inputs: JsonSchemaSchema.default({}).describe('JSON Schema defining the tool\\'s input parameters.'),\r\n  outputs: JsonSchemaSchema.default({}).describe('JSON Schema defining the tool\\'s return value structure.'),\r\n  tags: z.array(z.string()).default([]).describe('List of tags for categorization and search.'),\r\n  average_response_size: z.number().optional().describe('Optional hint about typical response size in bytes.'),\r\n  tool_call_template: CallTemplateSchema.describe('CallTemplate configuration for accessing this tool.'),\r\n}).strict() as z.ZodType<Tool>;\r\n\r\n/**\r\n * Serializer for JsonSchema objects.\r\n * Since JsonSchema is a standard format without subtypes, this is a simple passthrough serializer.\r\n */\r\nexport class JsonSchemaSerializer extends Serializer<JsonSchema> {\r\n  toDict(obj: JsonSchema): Record<string, unknown> {\r\n    return { ...obj };\r\n  }\r\n\r\n  validateDict(obj: Record<string, unknown>): JsonSchema {\r\n    return JsonSchemaSchema.parse(obj);\r\n  }\r\n}\r\n\r\n/**\r\n * Serializer for Tool objects.\r\n * Handles serialization and deserialization of complete tool definitions.\r\n */\r\nexport class ToolSerializer extends Serializer<Tool> {\r\n  toDict(obj: Tool): Record<string, unknown> {\r\n    return {\r\n      name: obj.name,\r\n      description: obj.description,\r\n      inputs: obj.inputs,\r\n      outputs: obj.outputs,\r\n      tags: obj.tags,\r\n      ...(obj.average_response_size !== undefined && { average_response_size: obj.average_response_size }),\r\n      tool_call_template: obj.tool_call_template,\r\n    };\r\n  }\r\n\r\n  validateDict(obj: Record<string, unknown>): Tool {\r\n    return ToolSchema.parse(obj);\r\n  }\r\n}","/**\r\n * Library version - replaced during build process.\r\n * Do not modify this file manually.\r\n */\r\nconst _VERSION = \"__LIB_VERSION__\";\r\n\r\n/**\r\n * The library version. Falls back to \"1.0.0\" if the build script hasn't replaced the placeholder.\r\n */\r\nexport const LIB_VERSION = _VERSION === \"__LIB_VERSION__\" ? \"1.0.0\" : _VERSION;\r\n","// packages/core/src/interfaces/communication_protocol.ts\r\nimport { CallTemplate } from '../data/call_template';\r\nimport { RegisterManualResult } from '../data/register_manual_result';\r\nimport { IUtcpClient } from './utcp_client_interface';\r\n\r\n/**\r\n * Abstract interface for UTCP client transport implementations (Communication Protocols).\r\n *\r\n * Defines the contract that all transport implementations must follow to\r\n * integrate with the UTCP client. Each transport handles communication\r\n * with a specific type of provider (HTTP, CLI, WebSocket, etc.).\r\n */\r\nexport abstract class CommunicationProtocol {\r\n\r\n  /**\r\n   * Mapping of communication protocol types to their respective implementations.\r\n   */\r\n  static communicationProtocols: { [type: string]: CommunicationProtocol } = {};\r\n\r\n  /**\r\n   * Registers a manual and its tools.\r\n   *\r\n   * Connects to the provider and retrieves the list of tools it offers.\r\n   * This may involve making discovery requests, parsing configuration files,\r\n   * or initializing connections depending on the provider type.\r\n   *\r\n   * @param caller The UTCP client that is calling this method. (Type will be properly defined in UtcpClient).\r\n   * @param manualCallTemplate The call template of the manual to register.\r\n   * @returns A RegisterManualResult object containing the call template and manual.\r\n   */\r\n  abstract registerManual(caller: IUtcpClient, manualCallTemplate: CallTemplate): Promise<RegisterManualResult>;\r\n\r\n  /**\r\n   * Deregisters a manual and its tools.\r\n   *\r\n   * Cleanly disconnects from the provider and releases any associated\r\n   * resources such as connections, processes, or file handles.\r\n   *\r\n   * @param caller The UTCP client that is calling this method.\r\n   * @param manualCallTemplate The call template of the manual to deregister.\r\n   */\r\n  abstract deregisterManual(caller: IUtcpClient, manualCallTemplate: CallTemplate): Promise<void>;\r\n\r\n  /**\r\n   * Executes a tool call through this transport.\r\n   *\r\n   * Sends a tool invocation request to the provider using the appropriate\r\n   * protocol and returns the result. Handles serialization of arguments\r\n   * and deserialization of responses according to the transport type.\r\n   *\r\n   * @param caller The UTCP client that is calling this method.\r\n   * @param toolName Name of the tool to call (may include provider prefix).\r\n   * @param toolArgs Dictionary of arguments to pass to the tool.\r\n   * @param toolCallTemplate Call template of the tool to call.\r\n   * @returns The tool's response.\r\n   */\r\n  abstract callTool(caller: IUtcpClient, toolName: string, toolArgs: Record<string, any>, toolCallTemplate: CallTemplate): Promise<any>;\r\n\r\n  /**\r\n   * Executes a tool call through this transport streamingly.\r\n   *\r\n   * Sends a tool invocation request to the provider using the appropriate\r\n   * protocol and returns an async generator for streaming results.\r\n   *\r\n   * @param caller The UTCP client that is calling this method.\r\n   * @param toolName Name of the tool to call.\r\n   * @param toolArgs Arguments to pass to the tool.\r\n   * @param toolCallTemplate Call template of the tool to call.\r\n   * @returns An async generator that yields chunks of the tool's response.\r\n   */\r\n  abstract callToolStreaming(caller: IUtcpClient, toolName: string, toolArgs: Record<string, any>, toolCallTemplate: CallTemplate): AsyncGenerator<any, void, unknown>;\r\n\r\n  /**\r\n   * Closes any persistent connections or resources held by the communication protocol.\r\n   * This is a cleanup method that should be called when the client is shut down.\r\n   */\r\n  async close(): Promise<void> {}\r\n}","// packages/core/src/client/utcp_client_config.ts\r\nimport { z } from 'zod';\r\nimport { ensureCorePluginsInitialized } from '../plugins/plugin_loader';\r\nimport { CallTemplate, CallTemplateSchema, CallTemplateSerializer } from '../data/call_template';\r\nimport { ToolSearchStrategy, ToolSearchStrategyConfigSerializer } from '../interfaces/tool_search_strategy';\r\nimport { VariableLoader, VariableLoaderSchema, VariableLoaderSerializer } from '../data/variable_loader';\r\nimport { ConcurrentToolRepository, ConcurrentToolRepositoryConfigSerializer } from '../interfaces/concurrent_tool_repository';\r\nimport { ToolPostProcessor, ToolPostProcessorConfigSerializer } from '../interfaces/tool_post_processor';\r\nimport { Serializer } from '../interfaces/serializer';\r\n\r\n// Ensure core plugins are initialized before this module uses any serializers\r\nensureCorePluginsInitialized();\r\n\r\n/**\r\n * REQUIRED\r\n * Configuration model for UTCP client setup.\r\n *\r\n * Provides comprehensive configuration options for UTCP clients including\r\n * variable definitions, provider file locations, and variable loading\r\n * mechanisms. Supports hierarchical variable resolution with multiple\r\n * sources.\r\n *\r\n * Variable Resolution Order:\r\n *     1. Direct variables dictionary\r\n *     2. Custom variable loaders (in order)\r\n *     3. Environment variables\r\n *\r\n * Attributes:\r\n *     variables: A dictionary of directly-defined\r\n *         variables for substitution.\r\n *     load_variables_from: A list of\r\n *         variable loader configurations for loading variables from external\r\n *         sources like .env files or remote services.\r\n *     tool_repository: Configuration for the tool\r\n *         repository, which manages the storage and retrieval of tools.\r\n *         Defaults to an in-memory repository.\r\n *     tool_search_strategy: Configuration for the tool\r\n *         search strategy, defining how tools are looked up. Defaults to a\r\n *         tag and description-based search.\r\n *     post_processing: A list of tool post-processor\r\n *         configurations to be applied after a tool call.\r\n *     manual_call_templates: A list of manually defined\r\n *         call templates for registering tools that don't have a provider.\r\n *\r\n * Example:\r\n *     ```typescript\r\n *     const config: UtcpClientConfig = {\r\n *         variables: {\"MANUAL__NAME_API_KEY_NAME\": \"$REMAPPED_API_KEY\"},\r\n *         load_variables_from: [\r\n *             new VariableLoaderSerializer().validateDict({\"variable_loader_type\": \"dotenv\", \"env_file_path\": \".env\"})\r\n *         ],\r\n *         tool_repository: new ConcurrentToolRepositoryConfigSerializer().validateDict({\r\n *             \"tool_repository_type\": \"in_memory\"\r\n *         }),\r\n *         tool_search_strategy: new ToolSearchStrategyConfigSerializer().validateDict({\r\n *             \"tool_search_strategy_type\": \"tag_and_description_word_match\"\r\n *         }),\r\n *         post_processing: [],\r\n *         manual_call_templates: []\r\n *     };\r\n *     ```\r\n */\r\nexport interface UtcpClientConfig {\r\n  /**\r\n   * A dictionary of directly-defined variables for substitution.\r\n   */\r\n  variables: Record<string, string>;\r\n\r\n  /**\r\n   * A list of variable loader configurations for loading variables from external\r\n   * sources like .env files. Loaders are processed in order.\r\n   */\r\n  load_variables_from: VariableLoader[] | null;\r\n\r\n  /**\r\n   * Configuration for the tool repository.\r\n   * Defaults to an in-memory repository.\r\n   */\r\n  tool_repository: ConcurrentToolRepository;\r\n\r\n  /**\r\n   * Configuration for the tool search strategy.\r\n   * Defaults to a tag and description-based search.\r\n   */\r\n  tool_search_strategy: ToolSearchStrategy;\r\n\r\n  /**\r\n   * A list of tool post-processor configurations to be applied after a tool call.\r\n   */\r\n  post_processing: ToolPostProcessor[];\r\n\r\n  /**\r\n   * A list of manually defined call templates for registering tools at client initialization.\r\n   */\r\n  manual_call_templates: CallTemplate[];\r\n}\r\n\r\n/**\r\n * The main configuration schema for the UTCP client.\r\n */\r\nexport const UtcpClientConfigSchema = z.object({\r\n  variables: z.record(z.string(), z.string()).optional().default({}),\r\n  \r\n  load_variables_from: z.array(VariableLoaderSchema).nullable().optional().default(null)\r\n    .transform((val) => {\r\n      if (val === null) return null;\r\n      return val.map(item => {\r\n        if ('variable_loader_type' in item) {\r\n          return new VariableLoaderSerializer().validateDict(item as Record<string, unknown>);\r\n        }\r\n        return item as VariableLoader;\r\n      });\r\n    }),\r\n  \r\n  tool_repository: z.any()\r\n    .transform((val) => {\r\n      if (typeof val === 'object' && val !== null && 'tool_repository_type' in val) {\r\n        return new ConcurrentToolRepositoryConfigSerializer().validateDict(val as Record<string, unknown>);\r\n      }\r\n      return val as ConcurrentToolRepository;\r\n    })\r\n    .optional()\r\n    .default(new ConcurrentToolRepositoryConfigSerializer().validateDict({\r\n      tool_repository_type: ConcurrentToolRepositoryConfigSerializer.default_strategy,\r\n    })),\r\n\r\n  tool_search_strategy: z.any()\r\n    .transform((val) => {\r\n      if (typeof val === 'object' && val !== null && 'tool_search_strategy_type' in val) {\r\n        return new ToolSearchStrategyConfigSerializer().validateDict(val as Record<string, unknown>);\r\n      }\r\n      return val as ToolSearchStrategy;\r\n    })\r\n    .optional()\r\n    .default(new ToolSearchStrategyConfigSerializer().validateDict({\r\n      tool_search_strategy_type: ToolSearchStrategyConfigSerializer.default_strategy,\r\n    })),\r\n\r\n  post_processing: z.array(z.any())\r\n    .transform((val) => {\r\n      return val.map(item => {\r\n        if (typeof item === 'object' && item !== null && 'tool_post_processor_type' in item) {\r\n          return new ToolPostProcessorConfigSerializer().validateDict(item as Record<string, unknown>);\r\n        }\r\n        return item as ToolPostProcessor;\r\n      });\r\n    })\r\n    .optional()\r\n    .default([]),\r\n\r\n  manual_call_templates: z.array(CallTemplateSchema)\r\n    .transform((val) => {\r\n      return val.map(item => {\r\n        if (typeof item === 'object' && item !== null && 'call_template_type' in item) {\r\n          return new CallTemplateSerializer().validateDict(item as Record<string, unknown>);\r\n        }\r\n        return item as CallTemplate;\r\n      });\r\n    })\r\n    .optional()\r\n    .default([]),\r\n}).strict();\r\n\r\n/**\r\n * REQUIRED\r\n * Serializer for UTCP client configurations.\r\n *\r\n * Defines the contract for serializers that convert UTCP client configurations to and from\r\n * dictionaries for storage or transmission. Serializers are responsible for:\r\n * - Converting UTCP client configurations to dictionaries for storage or transmission\r\n * - Converting dictionaries back to UTCP client configurations\r\n * - Ensuring data consistency during serialization and deserialization\r\n */\r\nexport class UtcpClientConfigSerializer extends Serializer<UtcpClientConfig> {\r\n  /**\r\n   * REQUIRED\r\n   * Convert a UtcpClientConfig object to a dictionary.\r\n   *\r\n   * @param obj The UtcpClientConfig object to convert.\r\n   * @returns The dictionary converted from the UtcpClientConfig object.\r\n   */\r\n  toDict(obj: UtcpClientConfig): Record<string, unknown> {\r\n    return {\r\n      variables: obj.variables,\r\n      load_variables_from: obj.load_variables_from === null ? null : \r\n        obj.load_variables_from?.map(item => new VariableLoaderSerializer().toDict(item)),\r\n      tool_repository: new ConcurrentToolRepositoryConfigSerializer().toDict(obj.tool_repository),\r\n      tool_search_strategy: new ToolSearchStrategyConfigSerializer().toDict(obj.tool_search_strategy),\r\n      post_processing: obj.post_processing.map(item => new ToolPostProcessorConfigSerializer().toDict(item)),\r\n      manual_call_templates: obj.manual_call_templates.map(item => new CallTemplateSerializer().toDict(item)),\r\n    };\r\n  }\r\n  \r\n  /**\r\n   * REQUIRED\r\n   * Validate a dictionary and convert it to a UtcpClientConfig object.\r\n   *\r\n   * @param data The dictionary to validate and convert.\r\n   * @returns The UtcpClientConfig object converted from the dictionary.\r\n   * @throws Error if validation fails\r\n   */\r\n  validateDict(data: Record<string, unknown>): UtcpClientConfig {\r\n    try {\r\n      return UtcpClientConfigSchema.parse(data) as UtcpClientConfig;\r\n    } catch (e: any) {\r\n      throw new Error(`Invalid UtcpClientConfig: ${e.message}\\n${e.stack || ''}`);\r\n    }\r\n  }\r\n}","// packages/core/src/data/auth.ts\r\nimport { z } from 'zod';\r\nimport { Serializer } from '../interfaces/serializer';\r\n\r\nexport interface Auth {\r\n  /** Authentication type identifier */\r\n  auth_type: string;\r\n}\r\n\r\nexport class AuthSerializer extends Serializer<Auth> {\r\n  private static serializers: Record<string, Serializer<Auth>> = {};\r\n\r\n  // No need for the whole plugin registry. Plugins just need to call this to register a new auth type\r\n  static registerAuth(\r\n    authType: string,\r\n    serializer: Serializer<Auth>,\r\n    override = false\r\n  ): boolean {\r\n    if (!override && AuthSerializer.serializers[authType]) {\r\n      return false;\r\n    }\r\n    AuthSerializer.serializers[authType] = serializer;\r\n    return true;\r\n  }\r\n\r\n  toDict(obj: Auth): Record<string, unknown> {\r\n    const serializer = AuthSerializer.serializers[obj.auth_type];\r\n    if (!serializer) {\r\n      throw new Error(`No serializer found for auth_type: ${obj.auth_type}`);\r\n    }\r\n    return serializer.toDict(obj);\r\n  }\r\n\r\n  validateDict(obj: Record<string, unknown>): Auth {\r\n    const serializer = AuthSerializer.serializers[obj.auth_type as string];\r\n    if (!serializer) {\r\n      throw new Error(`Invalid auth_type: ${obj.auth_type}`);\r\n    }\r\n    return serializer.validateDict(obj);\r\n  }\r\n}\r\n\r\nexport const AuthSchema = z\r\n  .custom<Auth>((obj) => {\r\n    try {\r\n      // Use the centralized serializer to validate & return the correct subtype\r\n      const validated = new AuthSerializer().validateDict(obj as Record<string, unknown>);\r\n      return validated;\r\n    } catch (e) {\r\n      return false; // z.custom treats false as validation failure\r\n    }\r\n  }, {\r\n    message: \"Invalid Auth object\",\r\n  });","import { Auth } from \"../auth\";\r\nimport { Serializer } from \"../../interfaces/serializer\";\r\nimport { z } from \"zod\";\r\n\r\nexport interface ApiKeyAuth extends Auth {\r\n  auth_type: \"api_key\";\r\n  api_key: string;\r\n  var_name: string; // header, query param, etc.\r\n  location: \"header\" | \"query\" | \"cookie\";\r\n}\r\n\r\nexport class ApiKeyAuthSerializer extends Serializer<ApiKeyAuth> {\r\n  toDict(obj: ApiKeyAuth): { [key: string]: any } {\r\n    return { ...obj };\r\n  }\r\n\r\n  validateDict(obj: { [key: string]: any }): ApiKeyAuth {\r\n    return ApiKeyAuthSchema.parse(obj);\r\n  }\r\n}\r\n  \r\nconst ApiKeyAuthSchema = z.object({\r\n  auth_type: z.literal(\"api_key\"),\r\n  api_key: z.string(),\r\n  var_name: z.string().default(\"X-Api-Key\"),\r\n  location: z.enum([\"header\", \"query\", \"cookie\"]).default(\"header\"),\r\n});","// packages/core/src/data/auth.ts\r\nimport { z } from 'zod';\r\nimport { Serializer } from '../../interfaces/serializer';\r\nimport { Auth } from '../auth';\r\n\r\n/**\r\n * Interface for Basic authentication details.\r\n */\r\nexport interface BasicAuth extends Auth {\r\n  auth_type: 'basic';\r\n  username: string;\r\n  password: string;\r\n}\r\n\r\nexport class BasicAuthSerializer extends Serializer<BasicAuth> {\r\n  toDict(obj: BasicAuth): { [key: string]: any } {\r\n    // Just spread the object since it's already validated\r\n    return { ...obj };\r\n  }\r\n\r\n  validateDict(obj: { [key: string]: any }): BasicAuth {\r\n      return BasicAuthSchema.parse(obj);\r\n  }\r\n}\r\n\r\n/**\r\n * Authentication using HTTP Basic Authentication.\r\n * Credentials typically contain variable placeholders for substitution.\r\n */\r\nconst BasicAuthSchema: z.ZodType<BasicAuth> = z.object({\r\n  auth_type: z.literal('basic'),\r\n  username: z.string().describe('The username for basic authentication. Recommended to use injected variables.'),\r\n  password: z.string().describe('The password for basic authentication. Recommended to use injected variables.'),\r\n}).strict() as z.ZodType<BasicAuth>;\r\n","// packages/core/src/data/auth.ts\r\nimport { z } from 'zod';\r\nimport { Serializer } from '../../interfaces/serializer';\r\nimport { Auth } from '../auth';\r\n\r\n/**\r\n * Interface for OAuth2 authentication details (Client Credentials Flow).\r\n */\r\nexport interface OAuth2Auth extends Auth {\r\n  auth_type: 'oauth2';\r\n  token_url: string;\r\n  client_id: string;\r\n  client_secret: string;\r\n  scope?: string;\r\n}\r\n\r\nexport class OAuth2AuthSerializer extends Serializer<OAuth2Auth> {\r\n  toDict(obj: OAuth2Auth): { [key: string]: any } {\r\n    // Just spread the object since it's already validated\r\n    return { ...obj };\r\n  }\r\n\r\n  validateDict(obj: { [key: string]: any }): OAuth2Auth {\r\n      return OAuth2AuthSchema.parse(obj);\r\n  }\r\n}\r\n\r\n/**\r\n * Authentication using OAuth2 client credentials flow.\r\n * The client automatically handles token acquisition and refresh.\r\n */\r\nconst OAuth2AuthSchema: z.ZodType<OAuth2Auth> = z.object({\r\n  auth_type: z.literal('oauth2'),\r\n  token_url: z.string().describe('The URL to fetch the OAuth2 access token from. Recommended to use injected variables.'),\r\n  client_id: z.string().describe('The OAuth2 client ID. Recommended to use injected variables.'),\r\n  client_secret: z.string().describe('The OAuth2 client secret. Recommended to use injected variables.'),\r\n  scope: z.string().optional().describe('Optional scope parameter to limit the access token\\'s permissions.'),\r\n}).strict() as z.ZodType<OAuth2Auth>;\r\n","// packages/core/src/data/auth_implementations/oauth2_user_auth.ts\nimport { z } from 'zod';\nimport { Serializer } from '../../interfaces/serializer';\nimport { Auth } from '../auth';\n\n/**\n * Interface for interactive (user sign-in) OAuth2 authentication.\n *\n * This variant is DECLARATIVE ONLY: it describes how a user-delegated token is\n * obtained (device-code or authorization-code flow) and carries the runtime\n * bearer token once provisioned. UTCP itself NEVER runs the interactive flow —\n * that requires a user channel and token persistence which a transport handler\n * does not have. An external tool (e.g. `@utcp/code-mode-cli login`) performs\n * the sign-in and writes the token into a variable referenced by `access_token`\n * (typically `\"${MY_TOKEN}\"`). At call time UTCP simply injects the resolved\n * token as a bearer header.\n *\n * For MCP manuals the endpoints are discovered from the server, so `grant_type`,\n * `token_endpoint`, `client_id` and the endpoint fields are optional — only\n * `access_token` is always required.\n */\nexport interface OAuth2UserAuth extends Auth {\n  auth_type: 'oauth2_user';\n  /** Runtime bearer token, normally an injected variable like \"${MY_TOKEN}\". */\n  access_token: string;\n  /** Which interactive flow the login tool should run. */\n  grant_type?: 'device_code' | 'authorization_code';\n  /** OAuth2 token endpoint (for HTTP manuals; discovered for MCP). */\n  token_endpoint?: string;\n  /** Public OAuth2 client id (omit for MCP dynamic client registration). */\n  client_id?: string;\n  /** Optional requested scope. */\n  scope?: string;\n  /** Device authorization endpoint — required for the device_code flow. */\n  device_authorization_endpoint?: string;\n  /** Authorization endpoint — required for the authorization_code flow. */\n  authorization_endpoint?: string;\n  /** Header name to inject the token into. Defaults to \"Authorization\". */\n  var_name?: string;\n  /** Token prefix. Defaults to \"Bearer \". */\n  prefix?: string;\n}\n\nexport class OAuth2UserAuthSerializer extends Serializer<OAuth2UserAuth> {\n  toDict(obj: OAuth2UserAuth): { [key: string]: any } {\n    // Just spread the object since it's already validated\n    return { ...obj };\n  }\n\n  validateDict(obj: { [key: string]: any }): OAuth2UserAuth {\n    return OAuth2UserAuthSchema.parse(obj);\n  }\n}\n\n/**\n * Authentication using an interactive (user-delegated) OAuth2 token.\n * The token is provisioned out-of-band by a login tool and injected as a\n * bearer header at call time. Not `.strict()` so providers can carry the\n * declarative flow metadata used by the login tool.\n */\nconst OAuth2UserAuthSchema: z.ZodType<OAuth2UserAuth> = z.object({\n  auth_type: z.literal('oauth2_user'),\n  access_token: z.string().describe('Runtime bearer token. Recommended to use an injected variable like \"${MY_TOKEN}\".'),\n  grant_type: z.enum(['device_code', 'authorization_code']).optional().describe('Interactive flow the login tool should run.'),\n  token_endpoint: z.string().optional().describe('OAuth2 token endpoint (discovered for MCP manuals).'),\n  client_id: z.string().optional().describe('Public OAuth2 client id (omit for MCP dynamic client registration).'),\n  scope: z.string().optional().describe('Optional requested scope.'),\n  device_authorization_endpoint: z.string().optional().describe('Device authorization endpoint — required for the device_code flow.'),\n  authorization_endpoint: z.string().optional().describe('Authorization endpoint — required for the authorization_code flow.'),\n  var_name: z.string().optional().describe('Header name to inject the token into. Defaults to \"Authorization\".'),\n  prefix: z.string().optional().describe('Token prefix. Defaults to \"Bearer \".'),\n}) as z.ZodType<OAuth2UserAuth>;\n","// packages/core/src/implementations/in_mem_concurrent_tool_repository.ts\r\nimport { CallTemplate } from '../data/call_template';\r\nimport { Tool } from '../data/tool';\r\nimport { UtcpManual } from '../data/utcp_manual';\r\nimport { ConcurrentToolRepository } from '../interfaces/concurrent_tool_repository';\r\nimport { Serializer } from '../interfaces/serializer';\r\nimport { z } from 'zod';\r\n\r\n/**\r\n * An in-memory implementation of the ConcurrentToolRepository.\r\n * Stores tools, manuals, and manual call templates in local maps.\r\n * Uses an `AsyncMutex` to serialize write operations, ensuring data consistency\r\n * across concurrent asynchronous calls, and returns deep copies to prevent\r\n * external modification of internal state.\r\n */\r\nexport class InMemConcurrentToolRepository implements ConcurrentToolRepository {\r\n  public readonly tool_repository_type: string = \"in_memory\";\r\n  private _config: InMemConcurrentToolRepositoryConfig; // Store the config to return in toDict\r\n\r\n  private _toolsByName: Map<string, Tool> = new Map();\r\n  private _manuals: Map<string, UtcpManual> = new Map();\r\n  private _manualCallTemplates: Map<string, CallTemplate> = new Map();\r\n  private _writeMutex: AsyncMutex = new AsyncMutex();\r\n\r\n  /**\r\n   * The constructor must accept the config type to match the factory signature, \r\n   * even if the implementation does not use it.\r\n   */\r\n  constructor(config: InMemConcurrentToolRepositoryConfig = { tool_repository_type: 'in_memory' }) {\r\n    this._config = config;\r\n    // Intentionally left empty as all state is initialized via field initializers.\r\n  }\r\n\r\n  /**\r\n   * Converts the repository instance's configuration to a dictionary.\r\n   */\r\n    public toDict(): InMemConcurrentToolRepositoryConfig {\r\n      return this._config;\r\n  }\r\n\r\n  /**\r\n   * Saves a manual's call template and its associated tools in the repository.\r\n   * This operation replaces any existing manual with the same name.\r\n   * @param manualCallTemplate The call template associated with the manual to save.\r\n   * @param manual The complete UTCP Manual object to save.\r\n   */\r\n  public async saveManual(manualCallTemplate: CallTemplate, manual: UtcpManual): Promise<void> {\r\n    const release = await this._writeMutex.acquire();\r\n    try {\r\n      const manualName = manualCallTemplate.name!;\r\n      const oldManual = this._manuals.get(manualName);\r\n      if (oldManual) {\r\n        for (const tool of oldManual.tools) {\r\n          this._toolsByName.delete(tool.name);\r\n        }\r\n      }\r\n      this._manualCallTemplates.set(manualName, { ...manualCallTemplate });\r\n      this._manuals.set(manualName, { ...manual, tools: manual.tools.map(t => ({ ...t })) });\r\n      for (const tool of manual.tools) {\r\n        this._toolsByName.set(tool.name, { ...tool });\r\n      }\r\n    } finally {\r\n      release();\r\n    }\r\n  }\r\n\r\n  /**\r\n   * Removes a manual and its tools from the repository.\r\n   * @param manualName The name of the manual to remove.\r\n   * @returns True if the manual was removed, False otherwise.\r\n   */\r\n  public async removeManual(manualName: string): Promise<boolean> {\r\n    const release = await this._writeMutex.acquire();\r\n    try {\r\n      const oldManual = this._manuals.get(manualName);\r\n      if (!oldManual) {\r\n        return false;\r\n      }\r\n\r\n      for (const tool of oldManual.tools) {\r\n        this._toolsByName.delete(tool.name);\r\n      }\r\n\r\n      this._manuals.delete(manualName);\r\n      this._manualCallTemplates.delete(manualName);\r\n      return true;\r\n    } finally {\r\n      release();\r\n    }\r\n  }\r\n\r\n  /**\r\n   * Removes a specific tool from the repository.\r\n   * Note: This also attempts to remove the tool from any associated manual.\r\n   * @param toolName The full namespaced name of the tool to remove.\r\n   * @returns True if the tool was removed, False otherwise.\r\n   */\r\n  public async removeTool(toolName: string): Promise<boolean> {\r\n    const release = await this._writeMutex.acquire();\r\n    try {\r\n      const toolRemoved = this._toolsByName.delete(toolName);\r\n      if (!toolRemoved) {\r\n        return false;\r\n      }\r\n\r\n      const manualName = toolName.split('.')[0];\r\n      if (manualName) {\r\n        const manual = this._manuals.get(manualName);\r\n        if (manual) {\r\n          manual.tools = manual.tools.filter(t => t.name !== toolName);\r\n        }\r\n      }\r\n      return true;\r\n    } finally {\r\n      release();\r\n    }\r\n  }\r\n\r\n  /**\r\n   * Retrieves a tool by its full namespaced name.\r\n   * @param toolName The full namespaced name of the tool to retrieve.\r\n   * @returns The tool if found, otherwise undefined.\r\n   */\r\n  public async getTool(toolName: string): Promise<Tool | undefined> {\r\n    const tool = this._toolsByName.get(toolName);\r\n    return tool ? { ...tool } : undefined;\r\n  }\r\n\r\n  /**\r\n   * Retrieves all tools from the repository.\r\n   * @returns A list of all registered tools.\r\n   */\r\n  public async getTools(): Promise<Tool[]> {\r\n    return Array.from(this._toolsByName.values()).map(t => ({ ...t }));\r\n  }\r\n\r\n  /**\r\n   * Retrieves all tools associated with a specific manual.\r\n   * @param manualName The name of the manual.\r\n   * @returns A list of tools associated with the manual, or undefined if the manual is not found.\r\n   */\r\n  public async getToolsByManual(manualName: string): Promise<Tool[] | undefined> {\r\n    const manual = this._manuals.get(manualName);\r\n    return manual ? manual.tools.map(t => ({ ...t })) : undefined;\r\n  }\r\n\r\n  /**\r\n   * Retrieves a complete UTCP Manual object by its name.\r\n   * @param manualName The name of the manual to retrieve.\r\n   * @returns The manual if found, otherwise undefined.\r\n   */\r\n  public async getManual(manualName: string): Promise<UtcpManual | undefined> {\r\n    const manual = this._manuals.get(manualName);\r\n    return manual ? { ...manual, tools: manual.tools.map(t => ({ ...t })) } : undefined;\r\n  }\r\n\r\n  /**\r\n   * Retrieves all registered manuals from the repository.\r\n   * @returns A list of all registered UtcpManual objects.\r\n   */\r\n  public async getManuals(): Promise<UtcpManual[]> {\r\n    return Array.from(this._manuals.values()).map(m => ({ ...m, tools: m.tools.map(t => ({ ...t })) }));\r\n  }\r\n\r\n  /**\r\n   * Retrieves a manual's CallTemplate by its name.\r\n   * @param manualCallTemplateName The name of the manual's CallTemplate to retrieve.\r\n   * @returns The CallTemplate if found, otherwise undefined.\r\n   */\r\n  public async getManualCallTemplate(manualCallTemplateName: string): Promise<CallTemplate | undefined> {\r\n    const template = this._manualCallTemplates.get(manualCallTemplateName);\r\n    return template ? { ...template } : undefined;\r\n  }\r\n\r\n  /**\r\n   * Retrieves all registered manual CallTemplates from the repository.\r\n   * @returns A list of all registered CallTemplateBase objects.\r\n   */\r\n  public async getManualCallTemplates(): Promise<CallTemplate[]> {\r\n    return Array.from(this._manualCallTemplates.values()).map(t => ({ ...t }));\r\n  }\r\n}\r\n\r\nexport class InMemConcurrentToolRepositorySerializer extends Serializer<InMemConcurrentToolRepository> {\r\n  toDict(obj: InMemConcurrentToolRepository): { [key: string]: any } {\r\n    return {\r\n      tool_repository_type: obj.tool_repository_type\r\n    }\r\n  }\r\n\r\n  validateDict(data: { [key: string]: any }): InMemConcurrentToolRepository {\r\n    try {\r\n      return new InMemConcurrentToolRepository(InMemConcurrentToolRepositoryConfigSchema.parse(data));\r\n    } catch (e) {\r\n      if (e instanceof z.ZodError) {\r\n        throw new Error(`Invalid configuration: ${e.message}`);\r\n      }\r\n      throw new Error(\"Unexpected error during validation\");\r\n    }\r\n  }\r\n}\r\n\r\n/**\r\n * A simple asynchronous mutex to serialize write access to shared resources.\r\n * In a single-threaded JavaScript environment, this primarily ensures that\r\n * compound asynchronous operations on shared state do not interleave incorrectly.\r\n */\r\nclass AsyncMutex {\r\n  private queue: (() => void)[] = [];\r\n  private locked: boolean = false;\r\n\r\n  /**\r\n   * Acquires the mutex. If the mutex is already locked, waits until it's released.\r\n   * @returns A function to call to release the mutex.\r\n   */\r\n  async acquire(): Promise<() => void> {\r\n    if (!this.locked) {\r\n      this.locked = true;\r\n      return this._release.bind(this);\r\n    } else {\r\n      return new Promise<() => void>(resolve => {\r\n        this.queue.push(() => {\r\n          this.locked = true;\r\n          resolve(this._release.bind(this));\r\n        });\r\n      });\r\n    }\r\n  }\r\n\r\n  /**\r\n   * Releases the mutex, allowing the next queued operation (if any) to proceed.\r\n   */\r\n  private _release(): void {\r\n    this.locked = false;\r\n    if (this.queue.length > 0) {\r\n      const next = this.queue.shift();\r\n      if (next) {\r\n        next();\r\n      }\r\n    }\r\n  }\r\n}\r\n\r\n/**\r\n * Schema for the InMemConcurrentToolRepository configuration.\r\n */\r\nconst InMemConcurrentToolRepositoryConfigSchema = z.object({\r\n  tool_repository_type: z.literal('in_memory'),\r\n}).passthrough();\r\n\r\ntype InMemConcurrentToolRepositoryConfig = z.infer<typeof InMemConcurrentToolRepositoryConfigSchema>;\r\n","// packages/core/src/interfaces/concurrent_tool_repository.ts\r\nimport { CallTemplate } from '../data/call_template';\r\nimport { Tool } from '../data/tool';\r\nimport { UtcpManual } from '../data/utcp_manual';\r\nimport { Serializer } from './serializer';\r\nimport z from 'zod';\r\n\r\n\r\n/**\r\n * Defines the contract for tool repositories that store and manage UTCP tools\r\n * and their associated call templates.\r\n *\r\n * Repositories are responsible for:\r\n * - Persisting call template configurations and their associated tools.\r\n * - Providing efficient lookup and retrieval operations.\r\n * - Managing relationships between call templates and tools.\r\n * - Ensuring data consistency across concurrent asynchronous calls.\r\n */\r\nexport interface ConcurrentToolRepository {\r\n  /**\r\n   * A string identifying the type of this tool repository (e.g., 'in_memory', 'database').\r\n   * This is used for configuration and plugin lookup.\r\n   */\r\n  tool_repository_type: string;\r\n\r\n  /**\r\n   * Saves a manual's call template and its associated tools in the repository.\r\n   * This operation replaces any existing manual with the same name.\r\n   *\r\n   * @param manualCallTemplate The call template associated with the manual to save.\r\n   * @param manual The complete UTCP Manual object to save.\r\n   * @returns A Promise that resolves when the operation is complete.\r\n   */\r\n  saveManual(manualCallTemplate: CallTemplate, manual: UtcpManual): Promise<void>;\r\n\r\n  /**\r\n   * Removes a manual and its tools from the repository.\r\n   *\r\n   * @param manualName The name of the manual (which corresponds to the CallTemplate name) to remove.\r\n   * @returns A Promise resolving to true if the manual was removed, False otherwise.\r\n   */\r\n  removeManual(manualName: string): Promise<boolean>;\r\n\r\n  /**\r\n   * Removes a specific tool from the repository.\r\n   *\r\n   * @param toolName The full namespaced name of the tool to remove (e.g., \"my_manual.my_tool\").\r\n   * @returns A Promise resolving to true if the tool was removed, False otherwise.\r\n   */\r\n  removeTool(toolName: string): Promise<boolean>;\r\n\r\n  /**\r\n   * Retrieves a tool by its full namespaced name.\r\n   *\r\n   * @param toolName The full namespaced name of the tool to retrieve.\r\n   * @returns A Promise resolving to the tool if found, otherwise undefined.\r\n   */\r\n  getTool(toolName: string): Promise<Tool | undefined>;\r\n\r\n  /**\r\n   * Retrieves all tools from the repository.\r\n   *\r\n   * @returns A Promise resolving to a list of all registered tools.\r\n   */\r\n  getTools(): Promise<Tool[]>;\r\n\r\n  /**\r\n   * Retrieves all tools associated with a specific manual.\r\n   *\r\n   * @param manualName The name of the manual.\r\n   * @returns A Promise resolving to a list of tools associated with the manual, or undefined if the manual is not found.\r\n   */\r\n  getToolsByManual(manualName: string): Promise<Tool[] | undefined>;\r\n\r\n  /**\r\n   * Retrieves a complete UTCP Manual object by its name.\r\n   *\r\n   * @param manualName The name of the manual to retrieve.\r\n   * @returns A Promise resolving to the manual if found, otherwise undefined.\r\n   */\r\n  getManual(manualName: string): Promise<UtcpManual | undefined>;\r\n\r\n  /**\r\n   * Retrieves all registered manuals from the repository.\r\n   *\r\n   * @returns A Promise resolving to a list of all registered UtcpManual objects.\r\n   */\r\n  getManuals(): Promise<UtcpManual[]>;\r\n\r\n  /**\r\n   * Retrieves a manual's CallTemplate by its name.\r\n   *\r\n   * @param manualCallTemplateName The name of the manual's CallTemplate to retrieve.\r\n   * @returns A Promise resolving to the CallTemplate if found, otherwise undefined.\r\n   */\r\n  getManualCallTemplate(manualCallTemplateName: string): Promise<CallTemplate | undefined>;\r\n\r\n  /**\r\n   * Retrieves all registered manual CallTemplates from the repository.\r\n   *\r\n   * @returns A Promise resolving to a list of all registered CallTemplateBase objects.\r\n   */\r\n  getManualCallTemplates(): Promise<CallTemplate[]>;\r\n}\r\n\r\nexport class ConcurrentToolRepositoryConfigSerializer extends Serializer<ConcurrentToolRepository> {\r\n  private static implementations: Record<string, Serializer<ConcurrentToolRepository>> = {};\r\n  static default_strategy = \"in_memory\";\r\n\r\n  // No need for the whole plugin registry. Plugins just need to call this to register a new repository\r\n  static registerRepository(type: string, serializer: Serializer<ConcurrentToolRepository>, override = false): boolean {\r\n    if (!override && ConcurrentToolRepositoryConfigSerializer.implementations[type]) {\r\n      return false;\r\n    }\r\n    ConcurrentToolRepositoryConfigSerializer.implementations[type] = serializer;\r\n    return true;\r\n  }\r\n\r\n  toDict(obj: ConcurrentToolRepository): Record<string, unknown> {\r\n    const serializer = ConcurrentToolRepositoryConfigSerializer.implementations[obj.tool_repository_type];\r\n    if (!serializer) throw new Error(`No serializer for type: ${obj.tool_repository_type}`);\r\n    return serializer.toDict(obj);\r\n  }\r\n\r\n  validateDict(data: Record<string, unknown>): ConcurrentToolRepository {\r\n    const serializer = ConcurrentToolRepositoryConfigSerializer.implementations[data[\"tool_repository_type\"] as string];\r\n    if (!serializer) throw new Error(`Invalid tool repository type: ${data[\"tool_repository_type\"]}`);\r\n    return serializer.validateDict(data);\r\n  }\r\n}\r\n\r\nexport const ConcurrentToolRepositorySchema = z\r\n  .custom<ConcurrentToolRepository>((obj) => {\r\n    try {\r\n      // Use the centralized serializer to validate & return the correct subtype\r\n      const validated = new ConcurrentToolRepositoryConfigSerializer().validateDict(obj as Record<string, unknown>);\r\n      return validated;\r\n    } catch (e) {\r\n      return false; // z.custom treats false as validation failure\r\n    }\r\n  }, {\r\n    message: \"Invalid ConcurrentToolRepository object\",\r\n  });","// packages/core/src/implementations/tag_search_strategy.ts\r\nimport { Tool } from '../data/tool';\r\nimport { ConcurrentToolRepository } from '../interfaces/concurrent_tool_repository';\r\nimport { ToolSearchStrategy } from '../interfaces/tool_search_strategy';\r\nimport { z } from 'zod';\r\nimport { Serializer } from '../interfaces/serializer';\r\n\r\n/**\r\n * Implements a tool search strategy based on tag and description matching.\r\n * Tools are scored based on the occurrence of query words in their tags and description.\r\n */\r\nexport class TagSearchStrategy implements ToolSearchStrategy {\r\n  public readonly tool_search_strategy_type: 'tag_and_description_word_match' = 'tag_and_description_word_match';\r\n  public readonly descriptionWeight: number;\r\n  public readonly tagWeight: number;\r\n  private readonly _config: TagSearchStrategyConfig; \r\n\r\n   /**\r\n   * Creates an instance of TagSearchStrategy.\r\n   *\r\n   * @param descriptionWeight The weight to apply to words found in the tool's description.\r\n   * @param tagWeight The weight to apply to words found in the tool's tags.\r\n   */\r\n  constructor(config: TagSearchStrategyConfig) {\r\n    this._config = TagSearchStrategyConfigSchema.parse(config);\r\n    this.descriptionWeight = this._config.description_weight;\r\n    this.tagWeight = this._config.tag_weight;\r\n  }\r\n\r\n  /**\r\n   * Converts the search strategy instance's configuration to a dictionary.\r\n   */\r\n  public toDict(): TagSearchStrategyConfig {\r\n      return this._config;\r\n  }\r\n\r\n  /**\r\n   * Searches for tools by matching tags and description content against a query.\r\n   *\r\n   * @param concurrentToolRepository The repository to search for tools.\r\n   * @param query The search query string.\r\n   * @param limit The maximum number of tools to return. If 0, all matched tools are returned.\r\n   * @param anyOfTagsRequired Optional list of tags where one of them must be present in the tool's tags.\r\n   * @returns A promise that resolves to a list of tools ordered by relevance.\r\n   */\r\n  public async searchTools(\r\n    concurrentToolRepository: ConcurrentToolRepository,\r\n    query: string,\r\n    limit: number = 10,\r\n    anyOfTagsRequired?: string[]\r\n  ): Promise<Tool[]> {\r\n    const queryLower = query.toLowerCase();\r\n    const queryWords = new Set(queryLower.match(/\\w+/g) || []);\r\n\r\n    let tools = await concurrentToolRepository.getTools();\r\n\r\n    if (anyOfTagsRequired && anyOfTagsRequired.length > 0) {\r\n      const requiredTagsLower = new Set(anyOfTagsRequired.map(tag => tag.toLowerCase()));\r\n      tools = tools.filter(tool =>\r\n        tool.tags && tool.tags.some(tag => requiredTagsLower.has(tag.toLowerCase()))\r\n      );\r\n    }\r\n\r\n    const toolScores = tools.map(tool => {\r\n      let score = 0.0;\r\n\r\n      // Check tool name (highest priority)\r\n      const toolNameLower = tool.name.toLowerCase();\r\n      // Extract just the tool name without the manual prefix (e.g., \"manual.echo\" -> \"echo\")\r\n      const toolNameOnly = toolNameLower.includes('.') \r\n        ? toolNameLower.split('.').pop() || toolNameLower\r\n        : toolNameLower;\r\n      \r\n      // Full match or substring match on tool name\r\n      if (queryLower === toolNameOnly || queryLower.includes(toolNameOnly) || toolNameOnly.includes(queryLower)) {\r\n        score += this.tagWeight * 2; // High weight for name matches\r\n      }\r\n\r\n      // Word-by-word match on tool name\r\n      const toolNameWords = new Set(toolNameOnly.match(/\\w+/g) || []);\r\n      for (const word of toolNameWords) {\r\n        if (queryWords.has(word)) {\r\n          score += this.tagWeight;\r\n        }\r\n      }\r\n\r\n      if (tool.tags) {\r\n        for (const tag of tool.tags) {\r\n          const tagLower = tag.toLowerCase();\r\n          if (queryLower.includes(tagLower) || tagLower.includes(queryLower)) {\r\n            score += this.tagWeight;\r\n          }\r\n\r\n          const tagWords = new Set(tagLower.match(/\\w+/g) || []);\r\n          \r\n          // Exact word matches\r\n          for (const word of tagWords) {\r\n            if (queryWords.has(word)) {\r\n              score += this.tagWeight * 0.5;\r\n            }\r\n          }\r\n          \r\n          // Partial/substring word matches (e.g., \"author\" matches \"authors\")\r\n          for (const queryWord of queryWords) {\r\n            if (queryWord.length > 2) {\r\n              for (const tagWord of tagWords) {\r\n                if (tagWord.length > 2 && (tagWord.includes(queryWord) || queryWord.includes(tagWord))) {\r\n                  score += this.tagWeight * 0.3; // Lower weight for partial matches in tags\r\n                  break; // Only count once per query word\r\n                }\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n\r\n      if (tool.description) {\r\n        const descriptionLower = tool.description.toLowerCase();\r\n        const descriptionWords = new Set(\r\n          descriptionLower.match(/\\w+/g) || []\r\n        );\r\n        \r\n        // Exact word matches\r\n        for (const word of descriptionWords) {\r\n          if (queryWords.has(word) && word.length > 2) {\r\n            score += this.descriptionWeight;\r\n          }\r\n        }\r\n        \r\n        // Partial/substring word matches (e.g., \"author\" matches \"authors\")\r\n        for (const queryWord of queryWords) {\r\n          if (queryWord.length > 2) {\r\n            for (const descWord of descriptionWords) {\r\n              if (descWord.length > 2 && (descWord.includes(queryWord) || queryWord.includes(descWord))) {\r\n                score += this.descriptionWeight * 0.5; // Lower weight for partial matches\r\n                break; // Only count once per query word\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n\r\n      return { tool, score };\r\n    });\r\n\r\n    const sortedTools = toolScores\r\n      .sort((a, b) => b.score - a.score)\r\n      .map(item => item.tool);\r\n\r\n    return limit > 0 ? sortedTools.slice(0, limit) : sortedTools;\r\n  }\r\n}\r\n\r\n\r\nexport class TagSearchStrategyConfigSerializer extends Serializer<TagSearchStrategy> {\r\n  toDict(obj: TagSearchStrategy): { [key: string]: any } {\r\n    return {\r\n      tool_search_strategy_type: obj.tool_search_strategy_type,\r\n      description_weight: obj.descriptionWeight,\r\n      tag_weight: obj.tagWeight\r\n    }\r\n  }\r\n\r\n  validateDict(data: { [key: string]: any }): TagSearchStrategy {\r\n    try {\r\n      return new TagSearchStrategy(TagSearchStrategyConfigSchema.parse(data));\r\n    } catch (e) {\r\n      if (e instanceof z.ZodError) {\r\n        throw new Error(`Invalid configuration: ${e.message}`);\r\n      }\r\n      throw new Error(\"Unexpected error during validation\");\r\n    }\r\n  }\r\n}\r\n\r\n/**\r\n * Schema for the TagSearchStrategy configuration.\r\n */\r\nconst TagSearchStrategyConfigSchema = z.object({\r\n  tool_search_strategy_type: z.literal('tag_and_description_word_match'),\r\n  description_weight: z.number().optional().default(1),\r\n  tag_weight: z.number().optional().default(3),\r\n}).passthrough();\r\n\r\ntype TagSearchStrategyConfig = z.infer<typeof TagSearchStrategyConfigSchema>;\r\n","// packages/core/src/interfaces/tool_search_strategy.ts\r\nimport { Tool } from '../data/tool';\r\nimport { ConcurrentToolRepository } from './concurrent_tool_repository';\r\nimport { Serializer } from './serializer';\r\nimport z from 'zod';\r\n\r\n\r\n/**\r\n * Defines the contract for tool search strategies that can be plugged into\r\n * the UTCP client. Implementations provide algorithms for searching and ranking tools.\r\n */\r\nexport interface ToolSearchStrategy {\r\n  /**\r\n   * A string identifying the type of this tool search strategy (e.g., 'tag_and_description_word_match', 'in_mem_embeddings').\r\n   * This is used for configuration and plugin lookup.\r\n   */\r\n  tool_search_strategy_type: string;\r\n\r\n  /**\r\n   * Searches for tools relevant to the query within a given tool repository.\r\n   *\r\n   * @param toolRepository The repository to search within.\r\n   * @param query The search query string. Format depends on the strategy (e.g., keywords, natural language).\r\n   * @param limit Maximum number of tools to return. Use 0 for no limit.\r\n   * @param anyOfTagsRequired Optional list of tags where one of them must be present in the tool's tags.\r\n   * @returns A Promise resolving to a list of Tool objects ranked by relevance.\r\n   */\r\n  searchTools(\r\n    toolRepository: ConcurrentToolRepository,\r\n    query: string,\r\n    limit?: number,\r\n    anyOfTagsRequired?: string[]\r\n  ): Promise<Tool[]>;\r\n}\r\n\r\nexport class ToolSearchStrategyConfigSerializer extends Serializer<ToolSearchStrategy> {\r\n  private static implementations: Record<string, Serializer<ToolSearchStrategy>> = {};\r\n  static default_strategy = \"tag_and_description_word_match\";\r\n\r\n  // No need for the whole plugin registry. Plugins just need to call this to register a new strategy\r\n  static registerStrategy(type: string, serializer: Serializer<ToolSearchStrategy>, override = false): boolean  {\r\n    if (!override && ToolSearchStrategyConfigSerializer.implementations[type]) {\r\n      return false;\r\n    }\r\n    ToolSearchStrategyConfigSerializer.implementations[type] = serializer;\r\n    return true;\r\n  }\r\n\r\n  toDict(obj: ToolSearchStrategy): Record<string, unknown> {\r\n    const serializer = ToolSearchStrategyConfigSerializer.implementations[obj.tool_search_strategy_type];\r\n    if (!serializer) throw new Error(`No serializer for type: ${obj.tool_search_strategy_type}`);\r\n    return serializer.toDict(obj);\r\n  }\r\n\r\n  validateDict(data: Record<string, unknown>): ToolSearchStrategy {\r\n    const serializer = ToolSearchStrategyConfigSerializer.implementations[data[\"tool_search_strategy_type\"] as string];\r\n    if (!serializer) throw new Error(`Invalid tool search strategy type: ${data[\"tool_search_strategy_type\"]}`);\r\n    return serializer.validateDict(data);\r\n  }\r\n}\r\n\r\nexport const ToolSearchStrategySchema = z\r\n  .custom<ToolSearchStrategy>((obj) => {\r\n    try {\r\n      // Use the centralized serializer to validate & return the correct subtype\r\n      const validated = new ToolSearchStrategyConfigSerializer().validateDict(obj as Record<string, unknown>);\r\n      return validated;\r\n    } catch (e) {\r\n      return false; // z.custom treats false as validation failure\r\n    }\r\n  }, {\r\n    message: \"Invalid ToolSearchStrategy object\",\r\n  });","// packages/core/src/implementations/post_processors/filter_dict_post_processor.ts\r\nimport { z } from 'zod';\r\nimport { ToolPostProcessor } from '../../interfaces/tool_post_processor';\r\nimport { Tool } from '../../data/tool';\r\nimport { CallTemplate } from '../../data/call_template';\r\nimport { IUtcpClient } from '../../interfaces/utcp_client_interface';\r\nimport { Serializer } from '../../interfaces/serializer';\r\n\r\n/**\r\n * Implements a tool post-processor that filters dictionary keys from tool results.\r\n * It can recursively process nested dictionaries and arrays.\r\n * Filtering can be configured to exclude specific keys, or only include specific keys.\r\n * Processing can also be conditional based on the tool's or manual's name.\r\n */\r\nexport class FilterDictPostProcessor implements ToolPostProcessor {\r\n  public readonly tool_post_processor_type: 'filter_dict' = 'filter_dict';\r\n  private readonly excludeKeys?: Set<string>;\r\n  private readonly onlyIncludeKeys?: Set<string>;\r\n  private readonly excludeTools?: Set<string>;\r\n  private readonly onlyIncludeTools?: Set<string>;\r\n  private readonly excludeManuals?: Set<string>;\r\n  private readonly onlyIncludeManuals?: Set<string>;\r\n  private readonly _config: FilterDictPostProcessorConfig; \r\n\r\n  constructor(config: FilterDictPostProcessorConfig) {\r\n    this._config = FilterDictPostProcessorConfigSchema.parse(config);\r\n    this.excludeKeys = config.exclude_keys ? new Set(config.exclude_keys) : undefined;\r\n    this.onlyIncludeKeys = config.only_include_keys ? new Set(config.only_include_keys) : undefined;\r\n    this.excludeTools = config.exclude_tools ? new Set(config.exclude_tools) : undefined;\r\n    this.onlyIncludeTools = config.only_include_tools ? new Set(config.only_include_tools) : undefined;\r\n    this.excludeManuals = config.exclude_manuals ? new Set(config.exclude_manuals) : undefined;\r\n    this.onlyIncludeManuals = config.only_include_manuals ? new Set(config.only_include_manuals) : undefined;\r\n    \r\n\r\n    if (this.excludeKeys && this.onlyIncludeKeys) {\r\n      console.warn(\"FilterDictPostProcessor configured with both 'exclude_keys' and 'only_include_keys'. 'exclude_keys' will be ignored.\");\r\n    }\r\n    if (this.excludeTools && this.onlyIncludeTools) {\r\n      console.warn(\"FilterDictPostProcessor configured with both 'exclude_tools' and 'only_include_tools'. 'exclude_tools' will be ignored.\");\r\n    }\r\n    if (this.excludeManuals && this.onlyIncludeManuals) {\r\n      console.warn(\"FilterDictPostProcessor configured with both 'exclude_manuals' and 'only_include_manuals'. 'exclude_manuals' will be ignored.\");\r\n    }\r\n  }\r\n\r\n    /**\r\n   * Converts the post-processor instance's configuration to a dictionary.\r\n   */\r\n    public toDict(): FilterDictPostProcessorConfig {\r\n      return this._config;\r\n  }\r\n\r\n  /**\r\n   * Processes the result of a tool call, applying filtering logic.\r\n   * @param caller The UTCP client instance.\r\n   * @param tool The Tool object that was called.\r\n   * @param manualCallTemplate The CallTemplateBase object of the manual that owns the tool.\r\n   * @param result The raw result returned by the tool's communication protocol.\r\n   * @returns The processed result.\r\n   */\r\n  public postProcess(caller: IUtcpClient, tool: Tool, manualCallTemplate: CallTemplate, result: any): any {\r\n    if (this.shouldSkipProcessing(tool, manualCallTemplate)) {\r\n      return result;\r\n    }\r\n\r\n    if (this.onlyIncludeKeys) {\r\n      return this._filterDictOnlyIncludeKeys(result);\r\n    }\r\n    if (this.excludeKeys) {\r\n      return this._filterDictExcludeKeys(result);\r\n    }\r\n    return result;\r\n  }\r\n\r\n  /**\r\n   * Determines if processing should be skipped based on tool and manual filters.\r\n   * @param tool The Tool object.\r\n   * @param manualCallTemplate The CallTemplateBase object of the manual.\r\n   * @returns True if processing should be skipped, false otherwise.\r\n   */\r\n  private shouldSkipProcessing(tool: Tool, manualCallTemplate: CallTemplate): boolean {\r\n    if (this.onlyIncludeTools && !this.onlyIncludeTools.has(tool.name)) {\r\n      return true;\r\n    }\r\n    if (this.excludeTools && this.excludeTools.has(tool.name)) {\r\n      return true;\r\n    }\r\n    const manualName = manualCallTemplate.name;\r\n    if (manualName) {\r\n        if (this.onlyIncludeManuals && !this.onlyIncludeManuals.has(manualName)) {\r\n            return true;\r\n        }\r\n        if (this.excludeManuals && this.excludeManuals.has(manualName)) {\r\n            return true;\r\n        }\r\n    }\r\n    return false;\r\n  }\r\n\r\n  /**\r\n   * Recursively filters a dictionary, keeping only specified keys.\r\n   * @param data The data to filter.\r\n   * @returns The filtered data.\r\n   */\r\n  private _filterDictOnlyIncludeKeys(data: any): any {\r\n    if (typeof data !== 'object' || data === null) {\r\n      return data;\r\n    }\r\n\r\n    if (Array.isArray(data)) {\r\n      return data.map(item => this._filterDictOnlyIncludeKeys(item)).filter(item => {\r\n        if (typeof item === 'object' && item !== null) {\r\n          if (Array.isArray(item)) return item.length > 0;\r\n          return Object.keys(item).length > 0;\r\n        }\r\n        return true;\r\n      });\r\n    }\r\n\r\n    const newObject: { [key: string]: any } = {};\r\n    for (const key in data) {\r\n      if (Object.prototype.hasOwnProperty.call(data, key)) {\r\n        if (this.onlyIncludeKeys?.has(key)) {\r\n          newObject[key] = this._filterDictOnlyIncludeKeys(data[key]);\r\n        } else {\r\n          const processedValue = this._filterDictOnlyIncludeKeys(data[key]);\r\n          if (typeof processedValue === 'object' && processedValue !== null) {\r\n            if (Array.isArray(processedValue) && processedValue.length > 0) {\r\n              newObject[key] = processedValue;\r\n            } else if (Object.keys(processedValue).length > 0) {\r\n              newObject[key] = processedValue;\r\n            }\r\n          }\r\n        }\r\n      }\r\n    }\r\n    return newObject;\r\n  }\r\n\r\n  /**\r\n   * Recursively filters a dictionary, excluding specified keys.\r\n   * @param data The data to filter.\r\n   * @returns The filtered data.\r\n   */\r\n  private _filterDictExcludeKeys(data: any): any {\r\n    if (typeof data !== 'object' || data === null) {\r\n      return data;\r\n    }\r\n\r\n    if (Array.isArray(data)) {\r\n      return data.map(item => this._filterDictExcludeKeys(item)).filter(item => {\r\n        if (typeof item === 'object' && item !== null) {\r\n          if (Array.isArray(item)) return item.length > 0;\r\n          return Object.keys(item).length > 0;\r\n        }\r\n        return true;\r\n      });\r\n    }\r\n\r\n    const newObject: { [key: string]: any } = {};\r\n    for (const key in data) {\r\n      if (Object.prototype.hasOwnProperty.call(data, key)) {\r\n        if (!this.excludeKeys?.has(key)) {\r\n          newObject[key] = this._filterDictExcludeKeys(data[key]);\r\n        }\r\n      }\r\n    }\r\n    return newObject;\r\n  }\r\n}\r\n\r\n/**\r\n * Schema for the FilterDictPostProcessor configuration.\r\n */\r\nconst FilterDictPostProcessorConfigSchema = z.object({\r\n  tool_post_processor_type: z.literal('filter_dict'),\r\n  exclude_keys: z.array(z.string()).optional(),\r\n  only_include_keys: z.array(z.string()).optional(),\r\n  exclude_tools: z.array(z.string()).optional(),\r\n  only_include_tools: z.array(z.string()).optional(),\r\n  exclude_manuals: z.array(z.string()).optional(),\r\n  only_include_manuals: z.array(z.string()).optional(),\r\n}).passthrough();\r\n\r\ntype FilterDictPostProcessorConfig = z.infer<typeof FilterDictPostProcessorConfigSchema>;\r\n\r\nexport class FilterDictPostProcessorSerializer extends Serializer<FilterDictPostProcessor> {\r\n  toDict(obj: FilterDictPostProcessor): { [key: string]: any } {\r\n    const filterDictConfig = obj.toDict()\r\n    return {\r\n      tool_post_processor_type: filterDictConfig.tool_post_processor_type,\r\n      exclude_keys: filterDictConfig.exclude_keys,\r\n      only_include_keys: filterDictConfig.only_include_keys,\r\n      exclude_tools: filterDictConfig.exclude_tools,\r\n      only_include_tools: filterDictConfig.only_include_tools,\r\n      exclude_manuals: filterDictConfig.exclude_manuals,\r\n      only_include_manuals: filterDictConfig.only_include_manuals,\r\n    };\r\n  }\r\n\r\n  validateDict(data: { [key: string]: any }): FilterDictPostProcessor {\r\n    try {\r\n      return new FilterDictPostProcessor(FilterDictPostProcessorConfigSchema.parse(data));\r\n    } catch (e) {\r\n      if (e instanceof z.ZodError) {\r\n        throw new Error(`Invalid configuration: ${e.message}`);\r\n      }\r\n      throw new Error(\"Unexpected error during validation\");\r\n    }\r\n  }\r\n}","// packages/core/src/implementations/post_processors/limit_strings_post_processor.ts\r\nimport { z } from 'zod';\r\nimport { ToolPostProcessor } from '../../interfaces/tool_post_processor';\r\nimport { Tool } from '../../data/tool';\r\nimport { CallTemplate } from '../../data/call_template';\r\nimport { IUtcpClient } from '../../interfaces/utcp_client_interface';\r\nimport { Serializer } from '../../interfaces/serializer';\r\n\r\n/**\r\n * Implements a tool post-processor that truncates string values within a tool's result.\r\n * It recursively processes nested objects and arrays, limiting the length of any string encountered.\r\n * Processing can be conditional based on the tool's or manual's name.\r\n */\r\nexport class LimitStringsPostProcessor implements ToolPostProcessor {\r\n  public readonly tool_post_processor_type: 'limit_strings' = 'limit_strings';\r\n  private readonly limit: number;\r\n  private readonly excludeTools?: Set<string>;\r\n  private readonly onlyIncludeTools?: Set<string>;\r\n  private readonly excludeManuals?: Set<string>;\r\n  private readonly onlyIncludeManuals?: Set<string>;\r\n  private readonly _config: LimitStringsPostProcessorConfig; \r\n\r\n  constructor(config: LimitStringsPostProcessorConfig) {\r\n    this._config = LimitStringsPostProcessorConfigSchema.parse(config);\r\n    this.limit = config.limit;\r\n    this.excludeTools = config.exclude_tools ? new Set(config.exclude_tools) : undefined;\r\n    this.onlyIncludeTools = config.only_include_tools ? new Set(config.only_include_tools) : undefined;\r\n    this.excludeManuals = config.exclude_manuals ? new Set(config.exclude_manuals) : undefined;\r\n    this.onlyIncludeManuals = config.only_include_manuals ? new Set(config.only_include_manuals) : undefined;\r\n\r\n    if (this.excludeTools && this.onlyIncludeTools) {\r\n      console.warn(\"LimitStringsPostProcessor configured with both 'exclude_tools' and 'only_include_tools'. 'exclude_tools' will be ignored.\");\r\n    }\r\n    if (this.excludeManuals && this.onlyIncludeManuals) {\r\n      console.warn(\"LimitStringsPostProcessor configured with both 'exclude_manuals' and 'only_include_manuals'. 'exclude_manuals' will be ignored.\");\r\n    }\r\n  }\r\n\r\n    /**\r\n   * Converts the post-processor instance's configuration to a dictionary.\r\n   */\r\n    public toDict(): LimitStringsPostProcessorConfig {\r\n      return this._config;\r\n  }\r\n\r\n  /**\r\n   * Processes the result of a tool call, truncating string values if applicable.\r\n   * @param caller The UTCP client instance.\r\n   * @param tool The Tool object that was called.\r\n   * @param manualCallTemplate The CallTemplateBase object of the manual that owns the tool.\r\n   * @param result The raw result returned by the tool's communication protocol.\r\n   * @returns The processed result.\r\n   */\r\n  public postProcess(caller: IUtcpClient, tool: Tool, manualCallTemplate: CallTemplate, result: any): any {\r\n    if (this.shouldSkipProcessing(tool, manualCallTemplate)) {\r\n      return result;\r\n    }\r\n    return this._processObject(result);\r\n  }\r\n\r\n  /**\r\n   * Determines if processing should be skipped based on tool and manual filters.\r\n   * @param tool The Tool object.\r\n   * @param manualCallTemplate The CallTemplateBase object of the manual.\r\n   * @returns True if processing should be skipped, false otherwise.\r\n   */\r\n  private shouldSkipProcessing(tool: Tool, manualCallTemplate: CallTemplate): boolean {\r\n    if (this.onlyIncludeTools && !this.onlyIncludeTools.has(tool.name)) {\r\n      return true;\r\n    }\r\n    if (this.excludeTools && this.excludeTools.has(tool.name)) {\r\n      return true;\r\n    }\r\n    const manualName = manualCallTemplate.name;\r\n    if (manualName) {\r\n        if (this.onlyIncludeManuals && !this.onlyIncludeManuals.has(manualName)) {\r\n            return true;\r\n        }\r\n        if (this.excludeManuals && this.excludeManuals.has(manualName)) {\r\n            return true;\r\n        }\r\n    }\r\n    return false;\r\n  }\r\n\r\n  /**\r\n   * Recursively processes an object, truncating strings.\r\n   * @param obj The object to process.\r\n   * @returns The processed object.\r\n   */\r\n  private _processObject(obj: any): any {\r\n    if (typeof obj === 'string') {\r\n      return obj.length > this.limit ? obj.substring(0, this.limit) : obj;\r\n    }\r\n    if (Array.isArray(obj)) {\r\n      return obj.map(item => this._processObject(item));\r\n    }\r\n    if (typeof obj === 'object' && obj !== null) {\r\n      const newObj: { [key: string]: any } = {};\r\n      for (const key in obj) {\r\n        if (Object.prototype.hasOwnProperty.call(obj, key)) {\r\n          newObj[key] = this._processObject(obj[key]);\r\n        }\r\n      }\r\n      return newObj;\r\n    }\r\n    return obj;\r\n  }\r\n}\r\n\r\n/**\r\n * Schema for the LimitStringsPostProcessor configuration.\r\n */\r\nconst LimitStringsPostProcessorConfigSchema = z.object({\r\n  tool_post_processor_type: z.literal('limit_strings'),\r\n  limit: z.number().int().positive().default(10000), \r\n  exclude_tools: z.array(z.string()).optional(),\r\n  only_include_tools: z.array(z.string()).optional(),\r\n  exclude_manuals: z.array(z.string()).optional(),\r\n  only_include_manuals: z.array(z.string()).optional(),\r\n}).passthrough();\r\n\r\ntype LimitStringsPostProcessorConfig = z.infer<typeof LimitStringsPostProcessorConfigSchema>;\r\n\r\nexport class LimitStringsPostProcessorSerializer extends Serializer<LimitStringsPostProcessor> {\r\n  toDict(obj: LimitStringsPostProcessor): { [key: string]: any } {\r\n    const limitStringsConfig = obj.toDict()\r\n    return {\r\n      tool_post_processor_type: limitStringsConfig.tool_post_processor_type,\r\n      limit: limitStringsConfig.limit,\r\n      exclude_tools: limitStringsConfig.exclude_tools,\r\n      only_include_tools: limitStringsConfig.only_include_tools,\r\n      exclude_manuals: limitStringsConfig.exclude_manuals,\r\n      only_include_manuals: limitStringsConfig.only_include_manuals,\r\n    };\r\n  }\r\n\r\n  validateDict(data: { [key: string]: any }): LimitStringsPostProcessor {\r\n    try {\r\n      return new LimitStringsPostProcessor(LimitStringsPostProcessorConfigSchema.parse(data));\r\n    } catch (e) {\r\n      if (e instanceof z.ZodError) {\r\n        throw new Error(`Invalid configuration: ${e.message}`);\r\n      }\r\n      throw new Error(\"Unexpected error during validation\");\r\n    }\r\n  }\r\n}\r\n","// packages/core/src/interfaces/tool_post_processor.ts\r\nimport { Tool } from '../data/tool';\r\nimport { CallTemplate } from '../data/call_template';\r\nimport { IUtcpClient } from './utcp_client_interface';\r\nimport { Serializer } from './serializer';\r\nimport z from 'zod';\r\n\r\n/**\r\n * Defines the contract for tool post-processors that can modify the result of a tool call.\r\n * Implementations can apply transformations, filtering, or other logic to the raw tool output.\r\n * Post-processors are configured in the UtcpClientConfig and executed in order after a successful tool call.\r\n */\r\nexport interface ToolPostProcessor {\r\n  /**\r\n   * A string identifying the type of this tool post-processor (e.g., 'filter_dict', 'limit_strings').\r\n   * This is used for configuration and plugin lookup.\r\n   */\r\n  tool_post_processor_type: string;\r\n\r\n  /**\r\n   * Processes the result of a tool call.\r\n   *\r\n   * @param caller The UTCP client instance that initiated the tool call.\r\n   * @param tool The Tool object that was called.\r\n   * @param manualCallTemplate The CallTemplateBase object of the manual that owns the tool.\r\n   * @param result The raw result returned by the tool's communication protocol (can be a final result or a chunk from a stream).\r\n   * @returns The processed result, which is then passed to the next processor in the chain or returned to the caller.\r\n   */\r\n  postProcess(caller: IUtcpClient, tool: Tool, manualCallTemplate: CallTemplate, result: any): any;\r\n}\r\n\r\nexport class ToolPostProcessorConfigSerializer extends Serializer<ToolPostProcessor> {\r\n  private static implementations: Record<string, Serializer<ToolPostProcessor>> = {};\r\n\r\n  // No need for the whole plugin registry. Plugins just need to call this to register a new post-processor\r\n  static registerPostProcessor(type: string, serializer: Serializer<ToolPostProcessor>, override = false): boolean {\r\n    if (!override && ToolPostProcessorConfigSerializer.implementations[type]) {\r\n      return false;\r\n    }\r\n    ToolPostProcessorConfigSerializer.implementations[type] = serializer;\r\n    return true;\r\n  }\r\n\r\n  toDict(obj: ToolPostProcessor): Record<string, unknown> {\r\n    const serializer = ToolPostProcessorConfigSerializer.implementations[obj.tool_post_processor_type];\r\n    if (!serializer) throw new Error(`No serializer for type: ${obj.tool_post_processor_type}`);\r\n    return serializer.toDict(obj);\r\n  }\r\n\r\n  validateDict(data: Record<string, unknown>): ToolPostProcessor {\r\n    const serializer = ToolPostProcessorConfigSerializer.implementations[data[\"tool_post_processor_type\"] as string];\r\n    if (!serializer) throw new Error(`Invalid tool post-processor type: ${data[\"tool_post_processor_type\"]}`);\r\n    return serializer.validateDict(data);\r\n  }\r\n}\r\n\r\nexport const ToolPostProcessorSchema = z\r\n  .custom<ToolPostProcessor>((obj) => {\r\n    try {\r\n      // Use the centralized serializer to validate & return the correct subtype\r\n      const validated = new ToolPostProcessorConfigSerializer().validateDict(obj as Record<string, unknown>);\r\n      return validated;\r\n    } catch (e) {\r\n      return false; // z.custom treats false as validation failure\r\n    }\r\n  }, {\r\n    message: \"Invalid ToolPostProcessor object\",\r\n  });","// Core Auth\r\nimport { AuthSerializer } from '../data/auth';\r\nimport { ApiKeyAuthSerializer } from '../data/auth_implementations/api_key_auth';\r\nimport { BasicAuthSerializer } from '../data/auth_implementations/basic_auth';\r\nimport { OAuth2AuthSerializer } from '../data/auth_implementations/oauth2_auth';\r\nimport { OAuth2UserAuthSerializer } from '../data/auth_implementations/oauth2_user_auth';\r\nimport { setPluginInitializer } from '../interfaces/serializer';\r\n\r\n// Core Tool Repository\r\nimport { InMemConcurrentToolRepositorySerializer } from '../implementations/in_mem_concurrent_tool_repository';\r\nimport { ConcurrentToolRepositoryConfigSerializer } from '../interfaces/concurrent_tool_repository';\r\n\r\n// Core Search Strategy\r\nimport { TagSearchStrategyConfigSerializer } from '../implementations/tag_search_strategy';\r\nimport { ToolSearchStrategyConfigSerializer } from '../interfaces/tool_search_strategy';\r\n\r\n// Core Post Processors\r\nimport { FilterDictPostProcessorSerializer } from '../implementations/post_processors/filter_dict_post_processor';\r\nimport { LimitStringsPostProcessorSerializer } from '../implementations/post_processors/limit_strings_post_processor';\r\nimport { ToolPostProcessorConfigSerializer } from '../interfaces/tool_post_processor';\r\n\r\nlet corePluginsInitialized = false;\r\nlet initializing = false;\r\n\r\n// Register the initialization function with Serializer to break circular dependency\r\nsetPluginInitializer(() => ensureCorePluginsInitialized());\r\n\r\nfunction _registerCorePlugins(): void {\r\n  // Register Core Auth Serializers\r\n  AuthSerializer.registerAuth('api_key', new ApiKeyAuthSerializer());\r\n  AuthSerializer.registerAuth('basic', new BasicAuthSerializer());\r\n  AuthSerializer.registerAuth('oauth2', new OAuth2AuthSerializer());\r\n  AuthSerializer.registerAuth('oauth2_user', new OAuth2UserAuthSerializer());\r\n\r\n  // Register Tool Repository Serializers\r\n  ConcurrentToolRepositoryConfigSerializer.registerRepository('in_memory', new InMemConcurrentToolRepositorySerializer());\r\n\r\n  // Register Tool Search Strategy Serializers\r\n  ToolSearchStrategyConfigSerializer.registerStrategy('tag_and_description_word_match', new TagSearchStrategyConfigSerializer());\r\n  \r\n  // Register Tool Post-Processor Serializers\r\n  ToolPostProcessorConfigSerializer.registerPostProcessor('filter_dict', new FilterDictPostProcessorSerializer());\r\n  ToolPostProcessorConfigSerializer.registerPostProcessor('limit_strings', new LimitStringsPostProcessorSerializer());\r\n}\r\n\r\n/**\r\n * Ensures that all core UTCP plugins (auth serializers, default repository, \r\n * search strategy, and post-processors) are registered with the plugin registry.\r\n * \r\n * This function is called automatically when needed and should not be called manually.\r\n * \r\n * Note: Optional plugins like HTTP, MCP, Text, File, etc. are NOT auto-registered.\r\n * Users must explicitly import the plugins they need:\r\n * \r\n * @example\r\n * // Browser application\r\n * import { UtcpClient } from '@utcp/sdk';\r\n * import '@utcp/http';     // Auto-registers HTTP protocol\r\n * import '@utcp/text';     // Auto-registers text content protocol\r\n * \r\n * @example\r\n * // Node.js application\r\n * import { UtcpClient } from '@utcp/sdk';\r\n * import '@utcp/http';\r\n * import '@utcp/mcp';\r\n * import '@utcp/file';\r\n * import '@utcp/dotenv-loader';\r\n */\r\nexport function ensureCorePluginsInitialized(): void {\r\n  if (!corePluginsInitialized && !initializing) {\r\n    initializing = true;\r\n    _registerCorePlugins();\r\n    corePluginsInitialized = true;\r\n    initializing = false;\r\n  }\r\n}","// packages/core/src/data/variable_loader.ts\r\nimport { z } from 'zod';\r\nimport { Serializer } from '../interfaces/serializer';\r\n\r\n/**\r\n * Base interface for all VariableLoaders.\r\n * Variable loaders are responsible for loading configuration variables from external sources.\r\n */\r\nexport interface VariableLoader {\r\n  /**\r\n   * The type identifier for this variable loader (e.g., 'dotenv').\r\n   */\r\n  variable_loader_type: string;\r\n\r\n  [key: string]: any;\r\n\r\n    /**\r\n     * Retrieves a variable value by key.\r\n     * @abstract\r\n     * @param key Variable name to retrieve.\r\n     * @returns Variable value if found, None otherwise.\r\n     */\r\n    get(key: string): Promise<string | null>;\r\n}\r\n\r\n/**\r\n * Serializer for VariableLoader objects.\r\n * Uses a registry pattern to delegate to type-specific serializers.\r\n */\r\nexport class VariableLoaderSerializer extends Serializer<VariableLoader> {\r\n  private static serializers: Record<string, Serializer<VariableLoader>> = {};\r\n\r\n  /**\r\n   * Registers a variable loader serializer for a specific type.\r\n   * @param type The variable_loader_type identifier\r\n   * @param serializer The serializer instance for this type\r\n   * @param override Whether to override an existing registration\r\n   * @returns true if registration succeeded, false if already exists and override is false\r\n   */\r\n  static registerVariableLoader(\r\n    type: string,\r\n    serializer: Serializer<VariableLoader>,\r\n    override = false\r\n  ): boolean {\r\n    if (!override && VariableLoaderSerializer.serializers[type]) {\r\n      return false;\r\n    }\r\n    VariableLoaderSerializer.serializers[type] = serializer;\r\n    return true;\r\n  }\r\n\r\n  toDict(obj: VariableLoader): Record<string, unknown> {\r\n    const serializer = VariableLoaderSerializer.serializers[obj.variable_loader_type];\r\n    if (!serializer) {\r\n      throw new Error(`No serializer found for variable_loader_type: ${obj.variable_loader_type}`);\r\n    }\r\n    return serializer.toDict(obj);\r\n  }\r\n\r\n  validateDict(obj: Record<string, unknown>): VariableLoader {\r\n    const serializer = VariableLoaderSerializer.serializers[obj.variable_loader_type as string];\r\n    if (!serializer) {\r\n      throw new Error(`Invalid variable_loader_type: ${obj.variable_loader_type}`);\r\n    }\r\n    return serializer.validateDict(obj);\r\n  }\r\n}\r\n\r\n/**\r\n * Zod schema for VariableLoader using custom validation.\r\n */\r\nexport const VariableLoaderSchema = z\r\n  .custom<VariableLoader>((obj) => {\r\n    try {\r\n      const validated = new VariableLoaderSerializer().validateDict(obj as Record<string, unknown>);\r\n      return validated;\r\n    } catch (e) {\r\n      return false;\r\n    }\r\n  }, {\r\n    message: \"Invalid VariableLoader object\",\r\n  });\r\n","export class UtcpVariableNotFoundError extends Error {\r\n  public variableName: string;\r\n\r\n  /**\r\n   * Initializes the exception with the missing variable name.\r\n   * \r\n   * @param variableName The name of the variable that could not be found.\r\n   */\r\n  constructor(variableName: string) {\r\n    super(\r\n      `Variable '${variableName}' referenced in call template configuration not found. ` +\r\n      `Please ensure it's defined in client.config.variables, environment variables, or a configured variable loader.`\r\n    );\r\n    this.variableName = variableName;\r\n    this.name = 'UtcpVariableNotFoundError';\r\n  }\r\n}","// packages/core/src/implementations/default_variable_substitutor.ts\r\nimport { UtcpClientConfig } from '../client/utcp_client_config';\r\nimport { VariableSubstitutor } from '../interfaces/variable_substitutor';\r\nimport { UtcpVariableNotFoundError } from '../exceptions/utcp_variable_not_found_error';\r\n\r\n/**\r\n * Default implementation of the VariableSubstitutor interface.\r\n * Provides a hierarchical variable resolution system that searches for\r\n * variables in the following order:\r\n * 1. Configuration variables (exact match from config.variables)\r\n * 2. Custom variable loaders (in order, from config.load_variables_from)\r\n * 3. Environment variables (process.env)\r\n *\r\n * It supports variable placeholders using ${VAR_NAME} or $VAR_NAME syntax\r\n * and applies namespacing (e.g., manual__name__VAR_NAME) for isolation,\r\n * mirroring the Python UTCP SDK's convention.\r\n */\r\nexport class DefaultVariableSubstitutor implements VariableSubstitutor {\r\n\r\n  /**\r\n   * Retrieves a variable value from configured sources, respecting namespaces.\r\n   * \r\n   * @param key The variable name to look up (without namespace prefix).\r\n   * @param config The UTCP client configuration.\r\n   * @param namespace An optional namespace to prepend to the variable name for lookup.\r\n   * @returns The resolved variable value.\r\n   * @throws UtcpVariableNotFoundError if the variable cannot be found.\r\n   */\r\n  private async _getVariable(key: string, config: UtcpClientConfig, namespace?: string): Promise<string> {\r\n    // Apply namespacing: namespace.replace(\"_\", \"!\").replace(\"!\", \"__\") + \"_\" + key\r\n    let effectiveKey = key;\r\n    if (namespace) {\r\n      effectiveKey = namespace.replace(/_/g, '!').replace(/!/g, '__') + '_' + key;\r\n    }\r\n\r\n    // --- Search Hierarchy ---\r\n\r\n    // 1. Check config.variables (highest precedence)\r\n    if (config.variables && effectiveKey in config.variables) {\r\n      return config.variables[effectiveKey];\r\n    }\r\n\r\n    // 2. Check custom variable loaders (in order)\r\n    if (config.load_variables_from) {\r\n      for (const varLoader of config.load_variables_from) {\r\n        const varValue = await varLoader.get(effectiveKey);\r\n        if (varValue) {\r\n          return varValue;\r\n        }\r\n      }\r\n    }\r\n\r\n    // 3. Check environment variables (lowest precedence)\r\n    try {\r\n      const envVar = process.env[effectiveKey];\r\n      if (envVar) {\r\n        return envVar;\r\n      }\r\n    } catch (e) {\r\n      // Ignore environment variable access errors\r\n    }\r\n\r\n    throw new UtcpVariableNotFoundError(effectiveKey);\r\n  }\r\n\r\n  /**\r\n   * Recursively substitutes variables in the given object.\r\n   * \r\n   * @param obj The object (can be string, array, or object) containing potential variable references to substitute.\r\n   * @param config The UTCP client configuration containing variable definitions and loaders.\r\n   * @param namespace An optional namespace (e.g., manual name) to prefix variable lookups for isolation.\r\n   * @returns The object with all variable references replaced by their values.\r\n   * @throws UtcpVariableNotFoundError if a referenced variable cannot be resolved.\r\n   */\r\n  public async substitute<T>(obj: T, config: UtcpClientConfig, namespace?: string): Promise<T> {\r\n    if (namespace && !/^[a-zA-Z0-9_]+$/.test(namespace)) {\r\n      throw new Error(`Variable namespace '${namespace}' contains invalid characters. Only alphanumeric characters and underscores are allowed.`);\r\n    }\r\n\r\n    if (typeof obj === 'string') {\r\n      if (obj.includes('$ref')) {\r\n        return obj;\r\n      }\r\n      let currentString: string = obj;\r\n      const regex = /\\$\\{([a-zA-Z0-9_]+)\\}|\\$([a-zA-Z0-9_]+)/g;\r\n      let match: RegExpExecArray | null;\r\n      let lastIndex = 0;\r\n      const parts: string[] = [];\r\n\r\n      regex.lastIndex = 0;\r\n\r\n      while ((match = regex.exec(currentString)) !== null) {\r\n        const varNameInTemplate = match[1] || match[2];\r\n        const fullMatch = match[0];\r\n\r\n        parts.push(currentString.substring(lastIndex, match.index));\r\n\r\n        try {\r\n          const replacement = await this._getVariable(varNameInTemplate, config, namespace);\r\n          parts.push(replacement);\r\n        } catch (error: any) {\r\n          if (error instanceof UtcpVariableNotFoundError) {\r\n            throw new UtcpVariableNotFoundError(error.variableName);\r\n          }\r\n          throw error;\r\n        }\r\n\r\n        lastIndex = match.index + fullMatch.length;\r\n      }\r\n      parts.push(currentString.substring(lastIndex));\r\n\r\n      return parts.join('') as T;\r\n    }\r\n\r\n    if (Array.isArray(obj)) {\r\n      return Promise.all(obj.map(item => this.substitute(item, config, namespace))) as Promise<T>;\r\n    }\r\n\r\n    if (obj !== null && typeof obj === 'object') {\r\n      const newObj: { [key: string]: any } = {};\r\n      for (const key in obj) {\r\n        if (Object.prototype.hasOwnProperty.call(obj, key)) {\r\n          newObj[key] = await this.substitute((obj as any)[key], config, namespace);\r\n        }\r\n      }\r\n      return newObj as T;\r\n    }\r\n\r\n    return obj;\r\n  }\r\n\r\n  /**\r\n   * Recursively finds all variable references in the given object.\r\n   *\r\n   * @param obj The object (can be string, array, or object) to scan for variable references.\r\n   * @param namespace An optional namespace (e.g., manual name) to prefix variable lookups for isolation.\r\n   * @returns A list of fully-qualified variable names found in the object.\r\n   */\r\n  public findRequiredVariables(obj: any, namespace?: string): string[] {\r\n    if (namespace && !/^[a-zA-Z0-9_]+$/.test(namespace)) {\r\n      throw new Error(`Variable namespace '${namespace}' contains invalid characters. Only alphanumeric characters and underscores are allowed.`);\r\n    }\r\n\r\n    const variables: string[] = [];\r\n    const regex = /\\$\\{([a-zA-Z0-9_]+)\\}|\\$([a-zA-Z0-9_]+)/g;\r\n\r\n    if (typeof obj === 'string') {\r\n      if (obj.includes('$ref')) {\r\n        return [];\r\n      }\r\n\r\n      let match;\r\n      while ((match = regex.exec(obj)) !== null) {\r\n        const varNameInTemplate = match[1] || match[2];\r\n        \r\n        // Apply Python SDK's double underscore namespacing:\r\n        // Replaces underscores in namespace with double underscores, then adds single underscore before variable\r\n        const effectiveNamespace = namespace ? namespace.replace(/_/g, '__') : undefined;\r\n        const prefixedVarName = effectiveNamespace ? `${effectiveNamespace}_${varNameInTemplate}` : varNameInTemplate;\r\n        \r\n        variables.push(prefixedVarName);\r\n      }\r\n    } else if (Array.isArray(obj)) {\r\n      for (const item of obj) {\r\n        variables.push(...this.findRequiredVariables(item, namespace));\r\n      }\r\n    } else if (obj !== null && typeof obj === 'object') {\r\n      for (const key in obj) {\r\n        if (Object.prototype.hasOwnProperty.call(obj, key)) {\r\n          variables.push(...this.findRequiredVariables(obj[key], namespace));\r\n        }\r\n      }\r\n    }\r\n\r\n    return Array.from(new Set(variables));\r\n  }\r\n}","// packages/core/src/client/utcp_client.ts\r\nimport { CallTemplate, CallTemplateSchema } from '../data/call_template';\r\nimport { Tool } from '../data/tool';\r\nimport { UtcpManualSchema } from '../data/utcp_manual';\r\nimport { CommunicationProtocol } from '../interfaces/communication_protocol';\r\nimport { RegisterManualResult } from '../data/register_manual_result';\r\nimport { ConcurrentToolRepository } from '../interfaces/concurrent_tool_repository';\r\nimport { ToolSearchStrategy } from '../interfaces/tool_search_strategy';\r\nimport { VariableSubstitutor } from '../interfaces/variable_substitutor';\r\nimport { ToolPostProcessor } from '../interfaces/tool_post_processor';\r\nimport {\r\n  UtcpClientConfig,\r\n  UtcpClientConfigSchema,\r\n  UtcpClientConfigSerializer,\r\n} from './utcp_client_config';\r\nimport { DefaultVariableSubstitutor } from '../implementations/default_variable_substitutor';\r\nimport { ensureCorePluginsInitialized } from '../plugins/plugin_loader';\r\nimport { IUtcpClient } from '../interfaces/utcp_client_interface';\r\nimport { ToolSearchStrategyConfigSerializer } from '../interfaces/tool_search_strategy';\r\nimport { ToolPostProcessorConfigSerializer } from '../interfaces/tool_post_processor';\r\nimport { ConcurrentToolRepositoryConfigSerializer } from '../interfaces/concurrent_tool_repository';\r\n\r\n/**\r\n * REQUIRED\r\n * Abstract interface for UTCP client implementations.\r\n *\r\n * Defines the core contract for UTCP clients, including CallTemplate management,\r\n * tool execution, search capabilities, and variable handling. This interface\r\n * allows for different client implementations while maintaining consistency.\r\n */\r\nexport class UtcpClient implements IUtcpClient {\r\n  private _registeredCommProtocols: Map<string, CommunicationProtocol> = new Map();\r\n  public readonly postProcessors: ToolPostProcessor[];\r\n\r\n  protected constructor(\r\n    public readonly config: UtcpClientConfig,\r\n    public readonly variableSubstitutor: VariableSubstitutor,\r\n    public readonly root_dir: string | null = null,\r\n  ) {\r\n    // Dynamically populate registered protocols from the global registry\r\n    for (const [type, protocol] of Object.entries(CommunicationProtocol.communicationProtocols)) {\r\n      this._registeredCommProtocols.set(type, protocol);\r\n    }\r\n    // Instantiate post-processors dynamically based on registered factories\r\n    this.postProcessors = config.post_processing.map(ppConfig => {\r\n      const serializer = new ToolPostProcessorConfigSerializer();\r\n      return serializer.validateDict(ppConfig as any) as ToolPostProcessor;\r\n    });\r\n  }\r\n\r\n  /**\r\n   * REQUIRED\r\n   * Create a new instance of UtcpClient.\r\n   * \r\n   * @param root_dir The root directory for the client to resolve relative paths from. Defaults to the current working directory.\r\n   * @param config The configuration for the client. Can be a path to a configuration file, a dictionary, or UtcpClientConfig object.\r\n   * @returns A new instance of UtcpClient.\r\n   */\r\n  public static async create(\r\n    root_dir: string = process.cwd(),\r\n    config: UtcpClientConfig | null = null\r\n  ): Promise<UtcpClient> {\r\n    // Ensure core plugins are initialized before parsing config\r\n    ensureCorePluginsInitialized();\r\n\r\n    let loadedConfig: Partial<UtcpClientConfig>;\r\n    if (config === null) {\r\n        loadedConfig = new UtcpClientConfigSerializer().validateDict({});\r\n    } else {\r\n        loadedConfig = config;\r\n    }\r\n\r\n    const validatedConfig = UtcpClientConfigSchema.parse(loadedConfig);\r\n\r\n    // Dynamically instantiate ConcurrentToolRepository\r\n    const repoSerializer = new ConcurrentToolRepositoryConfigSerializer();\r\n    const concurrentToolRepository = repoSerializer.validateDict(validatedConfig.tool_repository as any) as ConcurrentToolRepository;\r\n\r\n    // Dynamically instantiate ToolSearchStrategy\r\n    const searchStrategySerializer = new ToolSearchStrategyConfigSerializer();\r\n    const searchStrategy = searchStrategySerializer.validateDict(validatedConfig.tool_search_strategy as any) as ToolSearchStrategy;\r\n\r\n    const variableSubstitutor = new DefaultVariableSubstitutor();\r\n\r\n    const client = new UtcpClient(\r\n      validatedConfig,\r\n      variableSubstitutor,\r\n      root_dir\r\n    );\r\n    const tempConfigWithoutOwnVars: UtcpClientConfig = { ...client.config, variables: {} };\r\n    client.config.variables = await client.variableSubstitutor.substitute(client.config.variables, tempConfigWithoutOwnVars);\r\n\r\n    // Register initial manuals specified in the config\r\n    await client.registerManuals(client.config.manual_call_templates || []);\r\n\r\n    return client;\r\n  }\r\n\r\n    /**\r\n   * Retrieves a tool by its full namespaced name.\r\n   * @param toolName The full namespaced name of the tool to retrieve.\r\n   * @returns A Promise resolving to the tool if found, otherwise undefined.\r\n   */\r\n    public async getTool(toolName: string): Promise<Tool | undefined> {\r\n      return this.config.tool_repository.getTool(toolName);\r\n    }\r\n  \r\n    /**\r\n     * Retrieves all tools from the repository.\r\n     * @returns A Promise resolving to a list of all registered tools.\r\n     */\r\n    public async getTools(): Promise<Tool[]> {\r\n      return this.config.tool_repository.getTools();\r\n    }\r\n\r\n  /**\r\n   * Registers a single tool manual.\r\n   * @param manualCallTemplate The call template describing how to discover and connect to the manual.\r\n   * @returns A promise that resolves to a result object indicating success or failure.\r\n   */\r\n  public async registerManual(manualCallTemplate: CallTemplate): Promise<RegisterManualResult> {\r\n    if (!manualCallTemplate.name) {\r\n      manualCallTemplate.name = crypto.randomUUID();\r\n    }\r\n    manualCallTemplate.name = manualCallTemplate.name.replace(/[^\\w]/g, '_');\r\n\r\n    if (await this.config.tool_repository.getManual(manualCallTemplate.name)) {\r\n      throw new Error(`Manual '${manualCallTemplate.name}' already registered. Please use a different name or deregister the existing manual.`);\r\n    }\r\n\r\n    const processedCallTemplate = await this.substituteCallTemplateVariables(manualCallTemplate, manualCallTemplate.name);\r\n\r\n    const protocol = this._registeredCommProtocols.get(processedCallTemplate.call_template_type);\r\n    if (!protocol) {\r\n      throw new Error(`No communication protocol registered for type: '${processedCallTemplate.call_template_type}'`);\r\n    }\r\n\r\n    const result = await protocol.registerManual(this, processedCallTemplate);\r\n\r\n    if (result.success) {\r\n      // Determine allowed protocols: use explicit list if provided, otherwise default to manual's own protocol\r\n      const allowedProtocols = (processedCallTemplate.allowed_communication_protocols?.length)\r\n        ? processedCallTemplate.allowed_communication_protocols\r\n        : [processedCallTemplate.call_template_type];\r\n\r\n      // Filter tools based on allowed protocols and prefix names\r\n      const filteredTools = [];\r\n      for (const tool of result.manual.tools) {\r\n        const toolProtocol = tool.tool_call_template.call_template_type;\r\n        if (!allowedProtocols.includes(toolProtocol)) {\r\n          console.warn(`Tool '${tool.name}' uses communication protocol '${toolProtocol}' which is not in allowed protocols [${allowedProtocols.map(p => `'${p}'`).join(', ')}] for manual '${manualCallTemplate.name}'. Tool will not be registered.`);\r\n          continue;\r\n        }\r\n        if (!tool.name.startsWith(`${processedCallTemplate.name}.`)) {\r\n          tool.name = `${processedCallTemplate.name}.${tool.name}`;\r\n        }\r\n        filteredTools.push(tool);\r\n      }\r\n      result.manual.tools = filteredTools;\r\n\r\n      await this.config.tool_repository.saveManual(processedCallTemplate, result.manual);\r\n      console.log(`Successfully registered manual '${manualCallTemplate.name}' with ${result.manual.tools.length} tools.`);\r\n    } else {\r\n      console.error(`Error registering manual '${manualCallTemplate.name}': ${result.errors.join(', ')}`);\r\n    }\r\n\r\n    return result;\r\n  }\r\n\r\n  /**\r\n   * Registers a list of tool manuals in parallel.\r\n   * @param manualCallTemplates An array of call templates to register.\r\n   * @returns A promise that resolves to an array of registration results.\r\n   */\r\n  public async registerManuals(manualCallTemplates: CallTemplate[]): Promise<RegisterManualResult[]> {\r\n    const registrationPromises = manualCallTemplates.map(async (template) => {\r\n      try {\r\n        return await this.registerManual(template);\r\n      } catch (error: any) {\r\n        console.error(`Error during batch registration for manual '${template.name}':`, error.message);\r\n        return {\r\n          manualCallTemplate: template,\r\n          manual: UtcpManualSchema.parse({ tools: [] }),\r\n          success: false,\r\n          errors: [error.message],\r\n        };\r\n      }\r\n    });\r\n    return Promise.all(registrationPromises);\r\n  }\r\n\r\n  /**\r\n   * Deregisters a tool manual and all of its associated tools.\r\n   * @param manualName The name of the manual to deregister.\r\n   * @returns A promise that resolves to true if the manual was found and removed, otherwise false.\r\n   */\r\n  public async deregisterManual(manualName: string): Promise<boolean> {\r\n    const manualCallTemplate = await this.config.tool_repository.getManualCallTemplate(manualName);\r\n    if (!manualCallTemplate) {\r\n      console.warn(`Manual '${manualName}' not found for deregistration.`);\r\n      return false;\r\n    }\r\n\r\n    const protocol = this._registeredCommProtocols.get(manualCallTemplate.call_template_type);\r\n    if (protocol) {\r\n      await protocol.deregisterManual(this, manualCallTemplate);\r\n      console.log(`Deregistered communication protocol for manual '${manualName}'.`);\r\n    } else {\r\n      console.warn(`No communication protocol found for type '${manualCallTemplate.call_template_type}' of manual '${manualName}'.`);\r\n    }\r\n\r\n    const removed = await this.config.tool_repository.removeManual(manualName);\r\n    if (removed) {\r\n      console.log(`Successfully deregistered manual '${manualName}' from repository.`);\r\n    } else {\r\n      console.warn(`Manual '${manualName}' was not found in the repository during deregistration.`);\r\n    }\r\n    return removed;\r\n  }\r\n\r\n  /**\r\n   * Calls a registered tool by its full namespaced name.\r\n   * @param toolName The full name of the tool (e.g., 'my_manual.my_tool').\r\n   * @param toolArgs A JSON object of arguments for the tool call.\r\n   * @returns A promise that resolves to the result of the tool call, with post-processing applied.\r\n   */\r\n  public async callTool(toolName: string, toolArgs: Record<string, any>): Promise<any> {\r\n    const manualName = toolName.split('.')[0];\r\n    if (!manualName) {\r\n      throw new Error(`Invalid tool name format for '${toolName}'. Expected 'manual_name.tool_name'.`);\r\n    }\r\n\r\n    const tool = await this.config.tool_repository.getTool(toolName);\r\n    if (!tool) {\r\n      throw new Error(`Tool '${toolName}' not found in the repository.`);\r\n    }\r\n    const manualCallTemplate = await this.config.tool_repository.getManualCallTemplate(manualName);\r\n    if (!manualCallTemplate) {\r\n        throw new Error(`Could not find manual call template for manual '${manualName}'.`);\r\n    }\r\n\r\n    // Validate protocol is allowed\r\n    const toolProtocol = tool.tool_call_template.call_template_type;\r\n    const allowedProtocols = (manualCallTemplate.allowed_communication_protocols?.length)\r\n      ? manualCallTemplate.allowed_communication_protocols\r\n      : [manualCallTemplate.call_template_type];\r\n    \r\n    if (!allowedProtocols.includes(toolProtocol)) {\r\n      throw new Error(`Tool '${toolName}' uses communication protocol '${toolProtocol}' which is not allowed by manual '${manualName}'. Allowed protocols: [${allowedProtocols.map(p => `'${p}'`).join(', ')}]`);\r\n    }\r\n\r\n    const processedToolCallTemplate = await this.substituteCallTemplateVariables(tool.tool_call_template, manualName);\r\n\r\n    const protocol = this._registeredCommProtocols.get(processedToolCallTemplate.call_template_type);\r\n    if (!protocol) {\r\n      throw new Error(`No communication protocol registered for type: '${processedToolCallTemplate.call_template_type}'.`);\r\n    }\r\n\r\n    console.log(`Calling tool '${toolName}' via protocol '${processedToolCallTemplate.call_template_type}'.`);\r\n    let result = await protocol.callTool(this, toolName, toolArgs, processedToolCallTemplate);\r\n    \r\n    // Apply post-processors\r\n    for (const processor of this.postProcessors) {\r\n        result = processor.postProcess(this, tool, manualCallTemplate, result);\r\n    }\r\n    \r\n    return result;\r\n  }\r\n\r\n  /**\r\n   * Calls a registered tool and streams the results.\r\n   * @param toolName The full name of the tool (e.g., 'my_manual.my_tool').\r\n   * @param toolArgs A JSON object of arguments for the tool call.\r\n   * @returns An async generator that yields chunks of the tool's response, with post-processing applied to each chunk.\r\n   */\r\n  public async *callToolStreaming(toolName: string, toolArgs: Record<string, any>): AsyncGenerator<any, void, unknown> {\r\n    const manualName = toolName.split('.')[0];\r\n    if (!manualName) {\r\n      throw new Error(`Invalid tool name format for '${toolName}'. Expected 'manual_name.tool_name'.`);\r\n    }\r\n\r\n    const tool = await this.config.tool_repository.getTool(toolName);\r\n    if (!tool) {\r\n      throw new Error(`Tool '${toolName}' not found in the repository.`);\r\n    }\r\n    const manualCallTemplate = await this.config.tool_repository.getManualCallTemplate(manualName);\r\n    if (!manualCallTemplate) {\r\n        throw new Error(`Could not find manual call template for manual '${manualName}'.`);\r\n    }\r\n\r\n    // Validate protocol is allowed\r\n    const toolProtocol = tool.tool_call_template.call_template_type;\r\n    const allowedProtocols = (manualCallTemplate.allowed_communication_protocols?.length)\r\n      ? manualCallTemplate.allowed_communication_protocols\r\n      : [manualCallTemplate.call_template_type];\r\n    \r\n    if (!allowedProtocols.includes(toolProtocol)) {\r\n      throw new Error(`Tool '${toolName}' uses communication protocol '${toolProtocol}' which is not allowed by manual '${manualName}'. Allowed protocols: [${allowedProtocols.map(p => `'${p}'`).join(', ')}]`);\r\n    }\r\n\r\n    const processedToolCallTemplate = await this.substituteCallTemplateVariables(tool.tool_call_template, manualName);\r\n\r\n    const protocol = this._registeredCommProtocols.get(processedToolCallTemplate.call_template_type);\r\n    if (!protocol) {\r\n      throw new Error(`No communication protocol registered for type: '${processedToolCallTemplate.call_template_type}'.`);\r\n    }\r\n\r\n    console.log(`Calling tool '${toolName}' streamingly via protocol '${processedToolCallTemplate.call_template_type}'.`);\r\n    for await (let chunk of protocol.callToolStreaming(this, toolName, toolArgs, processedToolCallTemplate)) {\r\n      // Apply post-processors to each chunk\r\n      for (const processor of this.postProcessors) {\r\n        chunk = processor.postProcess(this, tool, manualCallTemplate, chunk);\r\n      }\r\n      yield chunk;\r\n    }\r\n  }\r\n\r\n  /**\r\n   * Searches for relevant tools based on a task description.\r\n   * @param query A natural language description of the task.\r\n   * @param limit The maximum number of tools to return.\r\n   * @param anyOfTagsRequired An optional list of tags, where at least one must be present on a tool for it to be included.\r\n   * @returns A promise that resolves to a list of relevant `Tool` objects.\r\n   */\r\n  public async searchTools(query: string, limit?: number, anyOfTagsRequired?: string[]): Promise<Tool[]> {\r\n    console.log(`Searching for tools with query: '${query}'`);\r\n    return this.config.tool_search_strategy.searchTools(this.config.tool_repository, query, limit, anyOfTagsRequired);\r\n  }\r\n\r\n  /**\r\n   * Gets the required variables for a manual CallTemplate and its tools.\r\n   *\r\n   * @param manualCallTemplate The manual CallTemplate.\r\n   * @returns A list of required variables for the manual CallTemplate and its tools.\r\n   */\r\n    public async getRequiredVariablesForManualAndTools(manualCallTemplate: CallTemplate): Promise<string[]> {\r\n      const rawCallTemplate = manualCallTemplate as any;\r\n      return this.variableSubstitutor.findRequiredVariables(rawCallTemplate, manualCallTemplate.name);\r\n    }\r\n\r\n  /**\r\n   * Gets the required variables for a registered tool.\r\n   *\r\n   * @param toolName The name of a registered tool.\r\n   * @returns A list of required variables for the tool.\r\n   */\r\n  public async getRequiredVariablesForRegisteredTool(toolName: string): Promise<string[]> {\r\n    const manualName = toolName.split('.')[0];\r\n    if (!manualName) {\r\n      throw new Error(`Invalid tool name format for '${toolName}'. Expected 'manual_name.tool_name'.`);\r\n    }\r\n\r\n    const tool = await this.config.tool_repository.getTool(toolName);\r\n    if (!tool) {\r\n      throw new Error(`Tool '${toolName}' not found in the repository.`);\r\n    }\r\n\r\n    return this.variableSubstitutor.findRequiredVariables(tool.tool_call_template, manualName);\r\n  }\r\n\r\n  /**\r\n   * Substitutes variables in a given call template.\r\n   * @param callTemplate The call template to process.\r\n   * @param namespace An optional namespace for variable lookup.\r\n   * @returns A new call template instance with all variables substituted.\r\n   */\r\n  public async substituteCallTemplateVariables<T extends CallTemplate>(callTemplate: T, namespace?: string): Promise<T> {\r\n    // Use the variable substitutor to handle the replacement logic\r\n    const rawSubstituted = await this.variableSubstitutor.substitute(callTemplate, this.config, namespace);\r\n\r\n    const result = CallTemplateSchema.safeParse(rawSubstituted);\r\n\r\n    if (!result.success) {\r\n      console.error(`Zod validation failed for call template '${callTemplate.name}' after variable substitution.`, result.error.issues);\r\n      throw new Error(`Invalid call template after variable substitution: ${result.error.message}`);\r\n    }\r\n\r\n    return result.data as T;\r\n  }\r\n\r\n  /**\r\n   * Closes the UTCP client and releases any resources held by its communication protocols.\r\n   */\r\n  public async close(): Promise<void> {\r\n    const closePromises: Promise<void>[] = [];\r\n    for (const protocol of this._registeredCommProtocols.values()) {\r\n      if (typeof protocol.close === 'function') {\r\n        closePromises.push(protocol.close());\r\n      }\r\n    }\r\n    await Promise.all(closePromises);\r\n    console.log('UTCP Client and all registered protocols closed.');\r\n  }\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,iBAAkB;;;ACDlB,IAAI,2BAAgD;AAE7C,SAAS,qBAAqB,IAAsB;AACzD,6BAA2B;AAC7B;AAEO,IAAe,aAAf,MAA6B;AAAA,EAClC,cAAc;AAEZ,QAAI,0BAA0B;AAC5B,+BAAyB;AAAA,IAC3B;AAAA,EACF;AAAA,EAMA,KAAK,KAAW;AACd,WAAO,KAAK,aAAa,KAAK,OAAO,GAAG,CAAC;AAAA,EAC3C;AACF;;;ADmBO,IAAM,yBAAN,MAAM,gCAA+B,WAAyB;AAAA,EACnE,OAAe,cAAwD,CAAC;AAAA;AAAA,EAGxE,OAAO,qBACL,kBACA,YACA,WAAW,OACF;AACT,QAAI,CAAC,YAAY,wBAAuB,YAAY,gBAAgB,GAAG;AACrE,aAAO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OAAO,GAAG;AAC7D,UAAI,OAAO,SAAS,UAAU,YAAY;AACxC,sBAAc,KAAK,SAAS,MAAM,CAAC;AAAA,MACrC;AAAA,IACF;AACA,UAAM,QAAQ,IAAI,aAAa;AAC/B,YAAQ,IAAI,kDAAkD;AAAA,EAChE;AACF;","names":["import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","z","import_zod","import_zod","z","import_zod","import_zod","import_zod","z","import_zod"]}