@voltagent/core 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -2211,24 +2211,28 @@ declare const getNodeTypeFromNodeId: (nodeId: string) => NodeType | null;
2211
2211
  /**
2212
2212
  * Prompt management utilities for agent prompt tuning
2213
2213
  */
2214
- /**
2215
- * Type for prompt template variables
2216
- */
2217
- type PromptVariables = Record<string, string | number | boolean | undefined>;
2218
- /**
2219
- * Type for prompt template definition
2220
- */
2221
- type PromptTemplate = {
2222
- template: string;
2223
- variables?: PromptVariables;
2214
+ type ExtractVariableNames<T extends string> = T extends `${string}{{${infer Param}}}${infer Rest}` ? Param | ExtractVariableNames<Rest> : never;
2215
+ type AllowedVariableValue = string | number | boolean | undefined | null;
2216
+ type TemplateVariables<T extends string> = {
2217
+ [K in ExtractVariableNames<T>]: AllowedVariableValue;
2218
+ };
2219
+ type PromptTemplate<T extends string> = [ExtractVariableNames<T>] extends [never] ? {
2220
+ template: T;
2221
+ variables?: Record<string, never>;
2222
+ } : {
2223
+ template: T;
2224
+ variables: TemplateVariables<T>;
2224
2225
  };
2226
+ type PromptCreator<T extends string> = (extraVariables?: Partial<TemplateVariables<T>>) => string;
2225
2227
  /**
2226
- * Creates a customizable prompt from a template with variable placeholders
2228
+ * Creates a type-safe, customizable prompt function from a template string.
2229
+ * Variable names are automatically inferred from the template `{{variable}}` syntax.
2227
2230
  *
2228
- * @param options - Template configuration with default variables
2229
- * @returns Function that generates the prompt with provided variables
2231
+ * @param template - The template string with `{{variable}}` placeholders.
2232
+ * @param variables - An object containing the default values for the template variables.
2233
+ * @returns A function that takes optional extra variables and returns the processed prompt string.
2230
2234
  */
2231
- declare const createPrompt: (options: PromptTemplate) => (customVariables?: PromptVariables) => string;
2235
+ declare const createPrompt: <T extends string>({ template, variables, }: PromptTemplate<T>) => PromptCreator<T>;
2232
2236
 
2233
2237
  /**
2234
2238
  * Creates an AgentTool from a retriever, allowing it to be used as a tool in an agent.
@@ -2770,4 +2774,4 @@ declare class VoltAgent {
2770
2774
  getAgentCount(): number;
2771
2775
  }
2772
2776
 
2773
- export { Agent, AgentHooks, AgentOptions, AgentRegistry, AgentResponse, AgentTool, AnyToolConfig, BaseLLMOptions, BaseMessage, BaseRetriever, BaseTool, BaseToolCall, ClientInfo, Conversation, CreateConversationInput, CreateReasoningToolsOptions, DEFAULT_INSTRUCTIONS, DataContent, FEW_SHOT_EXAMPLES, FilePart, GenerateObjectOptions, GenerateTextOptions, HTTPServerConfig, ImagePart, InMemoryStorage, InferGenerateObjectResponse, InferGenerateTextResponse, InferMessage, InferModel, InferProviderParams, InferStreamResponse, InferTool, LLMProvider, LibSQLStorage, MCPClient, MCPClientConfig, MCPClientEvents, MCPConfiguration, MCPOptions, MCPServerConfig, MCPToolCall, MCPToolResult, Memory, MemoryManager, MemoryMessage, MemoryOptions, MessageContent, MessageFilterOptions, MessageRole, ModelToolCall, NextAction, NodeType, PackageUpdateInfo, PromptTemplate, PromptVariables, ProviderObjectResponse, ProviderObjectStreamResponse, ProviderParams, ProviderResponse, ProviderTextResponse, ProviderTextStreamResponse, ReadableStreamType, ReasoningStep, ReasoningStepSchema, ReasoningToolExecuteOptions, Retriever, RetrieverOptions, RetryConfig, StdioServerConfig, StepChunkCallback, StepFinishCallback, StepWithContent, StreamObjectOptions, StreamTextOptions, TextPart, Tool, ToolCall, ToolExecuteOptions, ToolManager, ToolOptions, ToolSchema, ToolStatus, ToolStatusInfo, Toolkit, ToolsetMap, ToolsetWithTools, TransportError, UsageInfo, Voice, VoiceEventData, VoiceEventType, VoiceMetadata, VoiceOptions, VoltAgent, checkForUpdates, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createTool, VoltAgent as default, getNodeTypeFromNodeId, tool, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };
2777
+ export { Agent, AgentHooks, AgentOptions, AgentRegistry, AgentResponse, AgentTool, AllowedVariableValue, AnyToolConfig, BaseLLMOptions, BaseMessage, BaseRetriever, BaseTool, BaseToolCall, ClientInfo, Conversation, CreateConversationInput, CreateReasoningToolsOptions, DEFAULT_INSTRUCTIONS, DataContent, ExtractVariableNames, FEW_SHOT_EXAMPLES, FilePart, GenerateObjectOptions, GenerateTextOptions, HTTPServerConfig, ImagePart, InMemoryStorage, InferGenerateObjectResponse, InferGenerateTextResponse, InferMessage, InferModel, InferProviderParams, InferStreamResponse, InferTool, LLMProvider, LibSQLStorage, MCPClient, MCPClientConfig, MCPClientEvents, MCPConfiguration, MCPOptions, MCPServerConfig, MCPToolCall, MCPToolResult, Memory, MemoryManager, MemoryMessage, MemoryOptions, MessageContent, MessageFilterOptions, MessageRole, ModelToolCall, NextAction, NodeType, PackageUpdateInfo, PromptCreator, PromptTemplate, ProviderObjectResponse, ProviderObjectStreamResponse, ProviderParams, ProviderResponse, ProviderTextResponse, ProviderTextStreamResponse, ReadableStreamType, ReasoningStep, ReasoningStepSchema, ReasoningToolExecuteOptions, Retriever, RetrieverOptions, RetryConfig, StdioServerConfig, StepChunkCallback, StepFinishCallback, StepWithContent, StreamObjectOptions, StreamTextOptions, TemplateVariables, TextPart, Tool, ToolCall, ToolExecuteOptions, ToolManager, ToolOptions, ToolSchema, ToolStatus, ToolStatusInfo, Toolkit, ToolsetMap, ToolsetWithTools, TransportError, UsageInfo, Voice, VoiceEventData, VoiceEventType, VoiceMetadata, VoiceOptions, VoltAgent, checkForUpdates, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createTool, VoltAgent as default, getNodeTypeFromNodeId, tool, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };