@voltagent/core 0.1.26 → 0.1.27

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
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { Span } from '@opentelemetry/api';
3
+ import { Context } from 'hono';
3
4
  import { SpanExporter } from '@opentelemetry/sdk-trace-base';
4
5
  import { ClientCapabilities } from '@modelcontextprotocol/sdk/types.js';
5
6
  import { EventEmitter } from 'node:events';
@@ -2522,6 +2523,43 @@ declare class Agent<TProvider extends {
2522
2523
  _INTERNAL_setVoltAgentExporter(exporter: VoltAgentExporter): void;
2523
2524
  }
2524
2525
 
2526
+ /**
2527
+ * HTTP methods supported by custom endpoints
2528
+ */
2529
+ type HttpMethod = "get" | "post" | "put" | "patch" | "delete" | "options" | "head";
2530
+ /**
2531
+ * Handler function for custom endpoints
2532
+ */
2533
+ type CustomEndpointHandler = (c: Context) => Promise<Response> | Response;
2534
+ /**
2535
+ * Definition for a custom endpoint
2536
+ */
2537
+ interface CustomEndpointDefinition {
2538
+ /**
2539
+ * The path for the endpoint, relative to the API root
2540
+ * Example: "/custom-endpoint" or "/custom/:param"
2541
+ */
2542
+ path: string;
2543
+ /**
2544
+ * The HTTP method for the endpoint
2545
+ */
2546
+ method: HttpMethod;
2547
+ /**
2548
+ * The handler function for the endpoint
2549
+ */
2550
+ handler: CustomEndpointHandler;
2551
+ /**
2552
+ * Optional description for the endpoint
2553
+ */
2554
+ description?: string;
2555
+ }
2556
+ /**
2557
+ * Error thrown when a custom endpoint definition is invalid
2558
+ */
2559
+ declare class CustomEndpointError extends Error {
2560
+ constructor(message: string);
2561
+ }
2562
+
2525
2563
  /**
2526
2564
  * Enum defining the next action to take after a reasoning step.
2527
2565
  */
@@ -3220,13 +3258,30 @@ declare class AgentRegistry {
3220
3258
  getGlobalVoltAgentExporter(): VoltAgentExporter | undefined;
3221
3259
  }
3222
3260
 
3261
+ /**
3262
+ * Register a single custom endpoint with the API server
3263
+ * @param endpoint The custom endpoint definition
3264
+ * @throws CustomEndpointError if the endpoint definition is invalid or registration fails
3265
+ */
3266
+ declare function registerCustomEndpoint(endpoint: CustomEndpointDefinition): void;
3267
+ /**
3268
+ * Register multiple custom endpoints with the API server
3269
+ * @param endpoints Array of custom endpoint definitions
3270
+ * @throws CustomEndpointError if any endpoint definition is invalid or registration fails
3271
+ */
3272
+ declare function registerCustomEndpoints(endpoints: CustomEndpointDefinition[]): void;
3273
+
3223
3274
  type VoltAgentOptions = {
3224
3275
  agents: Record<string, Agent<any>>;
3225
3276
  port?: number;
3226
3277
  autoStart?: boolean;
3227
3278
  checkDependencies?: boolean;
3228
3279
  /**
3229
- * Optional OpenTelemetry SpanExporter instance or array of instances,
3280
+ * Optional array of custom endpoint definitions to register with the API server
3281
+ */
3282
+ customEndpoints?: CustomEndpointDefinition[];
3283
+ /**
3284
+ * Optional OpenTelemetry SpanExporter instance or array of instances.
3230
3285
  * or a VoltAgentExporter instance or array of instances.
3231
3286
  * If provided, VoltAgent will attempt to initialize and register
3232
3287
  * a NodeTracerProvider with a BatchSpanProcessor for the given exporter(s).
@@ -3240,6 +3295,7 @@ type VoltAgentOptions = {
3240
3295
  declare class VoltAgent {
3241
3296
  private registry;
3242
3297
  private serverStarted;
3298
+ private customEndpoints;
3243
3299
  constructor(options: VoltAgentOptions);
3244
3300
  /**
3245
3301
  * Check for dependency updates
@@ -3257,6 +3313,18 @@ declare class VoltAgent {
3257
3313
  * Start the server
3258
3314
  */
3259
3315
  startServer(): Promise<void>;
3316
+ /**
3317
+ * Register a custom endpoint with the API server
3318
+ * @param endpoint The custom endpoint definition
3319
+ * @throws Error if the endpoint definition is invalid or registration fails
3320
+ */
3321
+ registerCustomEndpoint(endpoint: CustomEndpointDefinition): void;
3322
+ /**
3323
+ * Register multiple custom endpoints with the API server
3324
+ * @param endpoints Array of custom endpoint definitions
3325
+ * @throws Error if any endpoint definition is invalid or registration fails
3326
+ */
3327
+ registerCustomEndpoints(endpoints: CustomEndpointDefinition[]): void;
3260
3328
  /**
3261
3329
  * Get all registered agents
3262
3330
  */
@@ -3273,4 +3341,4 @@ declare class VoltAgent {
3273
3341
  shutdownTelemetry(): Promise<void>;
3274
3342
  }
3275
3343
 
3276
- export { Agent, AgentErrorEvent, AgentHistoryEntry, AgentHookOnEnd, AgentHookOnHandoff, AgentHookOnStart, AgentHookOnToolEnd, AgentHookOnToolStart, AgentHooks, AgentOptions, AgentRegistry, AgentResponse, AgentStartEvent, AgentStartEventMetadata, AgentSuccessEvent, AgentSuccessEventMetadata, AgentTool, AllowedVariableValue, AnyToolConfig, BaseEventMetadata, BaseLLMOptions, BaseMessage, BaseRetriever, BaseTimelineEvent, BaseTool, BaseToolCall, ClientInfo, Conversation, CreateConversationInput, CreateReasoningToolsOptions, DEFAULT_INSTRUCTIONS, DataContent, EventStatus, ExtractVariableNames, FEW_SHOT_EXAMPLES, FilePart, GenerateObjectOptions, GenerateTextOptions, HTTPServerConfig, HistoryStatus, ImagePart, InMemoryStorage, InferGenerateObjectResponse, InferGenerateTextResponse, InferMessage, InferModel, InferProviderParams, InferStreamResponse, InferTool, LLMProvider, LibSQLStorage, MCPClient, MCPClientConfig, MCPClientEvents, MCPConfiguration, MCPOptions, MCPServerConfig, MCPToolCall, MCPToolResult, Memory, MemoryEventMetadata, MemoryManager, MemoryMessage, MemoryOptions, MemoryReadErrorEvent, MemoryReadStartEvent, MemoryReadSuccessEvent, MemoryWriteErrorEvent, MemoryWriteStartEvent, MemoryWriteSuccessEvent, MessageContent, MessageFilterOptions, MessageRole, ModelToolCall, NewTimelineEvent, NextAction, NodeType, OnEndHookArgs, OnHandoffHookArgs, OnStartHookArgs, OnToolEndHookArgs, OnToolStartHookArgs, OperationContext, PackageUpdateInfo, PromptCreator, PromptTemplate, ProviderObjectResponse, ProviderObjectStreamResponse, ProviderParams, ProviderResponse, ProviderTextResponse, ProviderTextStreamResponse, ReadableStreamType, ReasoningStep, ReasoningStepSchema, ReasoningToolExecuteOptions, Retriever, RetrieverErrorEvent, RetrieverOptions, RetrieverStartEvent, RetrieverSuccessEvent, RetryConfig, StandardEventData, StandardTimelineEvent, StdioServerConfig, StepChunkCallback, StepFinishCallback, StepWithContent, StreamObjectFinishResult, StreamObjectOnFinishCallback, StreamObjectOptions, StreamTextFinishResult, StreamTextOnFinishCallback, StreamTextOptions, TemplateVariables, TextPart, TimelineEventCoreLevel, TimelineEventCoreStatus, TimelineEventCoreType, Tool, ToolCall, ToolErrorEvent, ToolErrorInfo, ToolExecuteOptions, ToolExecutionContext, ToolManager, ToolOptions, ToolSchema, ToolStartEvent, ToolStatus, ToolStatusInfo, ToolSuccessEvent, Toolkit, ToolsetMap, ToolsetWithTools, TransportError, Usage, UsageInfo, Voice, VoiceEventData, VoiceEventType, VoiceMetadata, VoiceOptions, VoltAgent, VoltAgentError, VoltAgentExporter, VoltAgentExporterOptions, checkForUpdates, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createTool, createToolkit, VoltAgent as default, getNodeTypeFromNodeId, safeJsonParse, serializeValueForDebug, tool, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };
3344
+ export { Agent, AgentErrorEvent, AgentHistoryEntry, AgentHookOnEnd, AgentHookOnHandoff, AgentHookOnStart, AgentHookOnToolEnd, AgentHookOnToolStart, AgentHooks, AgentOptions, AgentRegistry, AgentResponse, AgentStartEvent, AgentStartEventMetadata, AgentSuccessEvent, AgentSuccessEventMetadata, AgentTool, AllowedVariableValue, AnyToolConfig, BaseEventMetadata, BaseLLMOptions, BaseMessage, BaseRetriever, BaseTimelineEvent, BaseTool, BaseToolCall, ClientInfo, Conversation, CreateConversationInput, CreateReasoningToolsOptions, CustomEndpointDefinition, CustomEndpointError, CustomEndpointHandler, DEFAULT_INSTRUCTIONS, DataContent, EventStatus, ExtractVariableNames, FEW_SHOT_EXAMPLES, FilePart, GenerateObjectOptions, GenerateTextOptions, HTTPServerConfig, HistoryStatus, HttpMethod, ImagePart, InMemoryStorage, InferGenerateObjectResponse, InferGenerateTextResponse, InferMessage, InferModel, InferProviderParams, InferStreamResponse, InferTool, LLMProvider, LibSQLStorage, MCPClient, MCPClientConfig, MCPClientEvents, MCPConfiguration, MCPOptions, MCPServerConfig, MCPToolCall, MCPToolResult, Memory, MemoryEventMetadata, MemoryManager, MemoryMessage, MemoryOptions, MemoryReadErrorEvent, MemoryReadStartEvent, MemoryReadSuccessEvent, MemoryWriteErrorEvent, MemoryWriteStartEvent, MemoryWriteSuccessEvent, MessageContent, MessageFilterOptions, MessageRole, ModelToolCall, NewTimelineEvent, NextAction, NodeType, OnEndHookArgs, OnHandoffHookArgs, OnStartHookArgs, OnToolEndHookArgs, OnToolStartHookArgs, OperationContext, PackageUpdateInfo, PromptCreator, PromptTemplate, ProviderObjectResponse, ProviderObjectStreamResponse, ProviderParams, ProviderResponse, ProviderTextResponse, ProviderTextStreamResponse, ReadableStreamType, ReasoningStep, ReasoningStepSchema, ReasoningToolExecuteOptions, Retriever, RetrieverErrorEvent, RetrieverOptions, RetrieverStartEvent, RetrieverSuccessEvent, RetryConfig, StandardEventData, StandardTimelineEvent, StdioServerConfig, StepChunkCallback, StepFinishCallback, StepWithContent, StreamObjectFinishResult, StreamObjectOnFinishCallback, StreamObjectOptions, StreamTextFinishResult, StreamTextOnFinishCallback, StreamTextOptions, TemplateVariables, TextPart, TimelineEventCoreLevel, TimelineEventCoreStatus, TimelineEventCoreType, Tool, ToolCall, ToolErrorEvent, ToolErrorInfo, ToolExecuteOptions, ToolExecutionContext, ToolManager, ToolOptions, ToolSchema, ToolStartEvent, ToolStatus, ToolStatusInfo, ToolSuccessEvent, Toolkit, ToolsetMap, ToolsetWithTools, TransportError, Usage, UsageInfo, Voice, VoiceEventData, VoiceEventType, VoiceMetadata, VoiceOptions, VoltAgent, VoltAgentError, VoltAgentExporter, VoltAgentExporterOptions, checkForUpdates, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createTool, createToolkit, VoltAgent as default, getNodeTypeFromNodeId, registerCustomEndpoint, registerCustomEndpoints, safeJsonParse, serializeValueForDebug, tool, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };
package/dist/index.js CHANGED
@@ -96,6 +96,7 @@ __export(src_exports, {
96
96
  Agent: () => Agent,
97
97
  AgentRegistry: () => AgentRegistry,
98
98
  BaseRetriever: () => BaseRetriever,
99
+ CustomEndpointError: () => CustomEndpointError,
99
100
  DEFAULT_INSTRUCTIONS: () => DEFAULT_INSTRUCTIONS,
100
101
  FEW_SHOT_EXAMPLES: () => FEW_SHOT_EXAMPLES,
101
102
  InMemoryStorage: () => InMemoryStorage,
@@ -120,6 +121,8 @@ __export(src_exports, {
120
121
  createToolkit: () => createToolkit,
121
122
  default: () => src_default,
122
123
  getNodeTypeFromNodeId: () => getNodeTypeFromNodeId,
124
+ registerCustomEndpoint: () => registerCustomEndpoint,
125
+ registerCustomEndpoints: () => registerCustomEndpoints,
123
126
  safeJsonParse: () => safeJsonParse,
124
127
  serializeValueForDebug: () => serializeValueForDebug,
125
128
  tool: () => tool,
@@ -1175,6 +1178,43 @@ Example event: 'data: {"partialUpdate": {...}}
1175
1178
  tags: ["Agent Generation"]
1176
1179
  });
1177
1180
 
1181
+ // src/server/custom-endpoints/index.ts
1182
+ var import_zod = require("zod");
1183
+ var CustomEndpointSchema = import_zod.z.object({
1184
+ path: import_zod.z.string().startsWith("/"),
1185
+ method: import_zod.z.enum(["get", "post", "put", "patch", "delete", "options", "head"]),
1186
+ handler: import_zod.z.function().args(import_zod.z.any()).returns(import_zod.z.any()),
1187
+ description: import_zod.z.string().optional()
1188
+ });
1189
+ var CustomEndpointError = class extends Error {
1190
+ constructor(message) {
1191
+ super(message);
1192
+ this.name = "CustomEndpointError";
1193
+ }
1194
+ };
1195
+ __name(CustomEndpointError, "CustomEndpointError");
1196
+ function validateCustomEndpoint(endpoint) {
1197
+ try {
1198
+ return CustomEndpointSchema.parse(endpoint);
1199
+ } catch (error) {
1200
+ if (error instanceof import_zod.z.ZodError) {
1201
+ throw new CustomEndpointError(`Invalid custom endpoint definition: ${error.message}`);
1202
+ }
1203
+ throw error;
1204
+ }
1205
+ }
1206
+ __name(validateCustomEndpoint, "validateCustomEndpoint");
1207
+ function validateCustomEndpoints(endpoints) {
1208
+ if (!endpoints || !Array.isArray(endpoints)) {
1209
+ throw new CustomEndpointError("Custom endpoints must be an array");
1210
+ }
1211
+ if (endpoints.length === 0) {
1212
+ return [];
1213
+ }
1214
+ return endpoints.map(validateCustomEndpoint);
1215
+ }
1216
+ __name(validateCustomEndpoints, "validateCustomEndpoints");
1217
+
1178
1218
  // src/server/api.ts
1179
1219
  var import_zod_from_json_schema = require("zod-from-json-schema");
1180
1220
  var app = new import_zod_openapi2.OpenAPIHono();
@@ -1826,6 +1866,91 @@ app.doc("/doc", {
1826
1866
  servers: [{ url: "http://localhost:3141", description: "Local development server" }]
1827
1867
  });
1828
1868
  app.get("/ui", (0, import_swagger_ui.swaggerUI)({ url: "/doc" }));
1869
+ function registerCustomEndpoint(endpoint) {
1870
+ try {
1871
+ const validatedEndpoint = validateCustomEndpoint(endpoint);
1872
+ const { path: path2, method, handler } = validatedEndpoint;
1873
+ switch (method) {
1874
+ case "get":
1875
+ app.get(path2, handler);
1876
+ break;
1877
+ case "post":
1878
+ app.post(path2, handler);
1879
+ break;
1880
+ case "put":
1881
+ app.put(path2, handler);
1882
+ break;
1883
+ case "patch":
1884
+ app.patch(path2, handler);
1885
+ break;
1886
+ case "delete":
1887
+ app.delete(path2, handler);
1888
+ break;
1889
+ case "options":
1890
+ app.options(path2, handler);
1891
+ break;
1892
+ default:
1893
+ throw new CustomEndpointError(`Unsupported HTTP method: ${method}`);
1894
+ }
1895
+ if (!global.__voltAgentCustomEndpoints) {
1896
+ global.__voltAgentCustomEndpoints = [];
1897
+ }
1898
+ global.__voltAgentCustomEndpoints.push(validatedEndpoint);
1899
+ } catch (error) {
1900
+ if (error instanceof CustomEndpointError) {
1901
+ throw error;
1902
+ }
1903
+ throw new CustomEndpointError(
1904
+ `Failed to register custom endpoint: ${error instanceof Error ? error.message : String(error)}`
1905
+ );
1906
+ }
1907
+ }
1908
+ __name(registerCustomEndpoint, "registerCustomEndpoint");
1909
+ function registerCustomEndpoints(endpoints) {
1910
+ try {
1911
+ const validatedEndpoints = validateCustomEndpoints(endpoints);
1912
+ if (validatedEndpoints.length === 0) {
1913
+ return;
1914
+ }
1915
+ for (const endpoint of validatedEndpoints) {
1916
+ const { path: path2, method, handler } = endpoint;
1917
+ switch (method) {
1918
+ case "get":
1919
+ app.get(path2, handler);
1920
+ break;
1921
+ case "post":
1922
+ app.post(path2, handler);
1923
+ break;
1924
+ case "put":
1925
+ app.put(path2, handler);
1926
+ break;
1927
+ case "patch":
1928
+ app.patch(path2, handler);
1929
+ break;
1930
+ case "delete":
1931
+ app.delete(path2, handler);
1932
+ break;
1933
+ case "options":
1934
+ app.options(path2, handler);
1935
+ break;
1936
+ default:
1937
+ throw new CustomEndpointError(`Unsupported HTTP method: ${method}`);
1938
+ }
1939
+ }
1940
+ if (!global.__voltAgentCustomEndpoints) {
1941
+ global.__voltAgentCustomEndpoints = [];
1942
+ }
1943
+ global.__voltAgentCustomEndpoints.push(...validatedEndpoints);
1944
+ } catch (error) {
1945
+ if (error instanceof CustomEndpointError) {
1946
+ throw error;
1947
+ }
1948
+ throw new CustomEndpointError(
1949
+ `Failed to register custom endpoints: ${error instanceof Error ? error.message : String(error)}`
1950
+ );
1951
+ }
1952
+ }
1953
+ __name(registerCustomEndpoints, "registerCustomEndpoints");
1829
1954
  var createWebSocketServer = /* @__PURE__ */ __name(() => {
1830
1955
  const wss = new import_ws.WebSocketServer({ noServer: true });
1831
1956
  AgentEventEmitter.getInstance().onHistoryUpdate((agentId, historyEntry) => {
@@ -1999,6 +2124,31 @@ var printServerStartup = /* @__PURE__ */ __name((port) => {
1999
2124
  console.log(
2000
2125
  `${colors.green} \u2713 ${colors.bright}Swagger UI: ${colors.reset}${colors.white}http://localhost:${port}/ui${colors.reset}`
2001
2126
  );
2127
+ const customEndpoints = global.__voltAgentCustomEndpoints;
2128
+ if (customEndpoints && customEndpoints.length > 0) {
2129
+ console.log();
2130
+ console.log(
2131
+ `${colors.green} \u2713 ${colors.bright}Custom Endpoints: ${colors.reset}${colors.dim}${customEndpoints.length} registered${colors.reset}`
2132
+ );
2133
+ const methodGroups = {};
2134
+ customEndpoints.forEach((endpoint) => {
2135
+ const method = endpoint.method.toUpperCase();
2136
+ if (!methodGroups[method]) {
2137
+ methodGroups[method] = [];
2138
+ }
2139
+ methodGroups[method].push(endpoint.path);
2140
+ });
2141
+ const methodOrder = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"];
2142
+ methodOrder.forEach((method) => {
2143
+ if (methodGroups[method]) {
2144
+ methodGroups[method].forEach((path2) => {
2145
+ console.log(
2146
+ `${colors.dim} ${method.padEnd(6)} ${colors.reset}${colors.white}${path2}${colors.reset}`
2147
+ );
2148
+ });
2149
+ }
2150
+ });
2151
+ }
2002
2152
  console.log();
2003
2153
  console.log(
2004
2154
  `${colors.bright}${colors.yellow} ${colors.bright}Developer Console: ${colors.reset}${colors.white}https://console.voltagent.dev${colors.reset}`
@@ -5097,7 +5247,7 @@ function createHooks(hooks = {}) {
5097
5247
  __name(createHooks, "createHooks");
5098
5248
 
5099
5249
  // src/agent/subagent/index.ts
5100
- var import_zod = require("zod");
5250
+ var import_zod2 = require("zod");
5101
5251
  var SubAgentManager = class {
5102
5252
  /**
5103
5253
  * Creates a new SubAgentManager instance
@@ -5324,10 +5474,10 @@ Context: ${JSON.stringify(context)}`
5324
5474
  id: "delegate_task",
5325
5475
  name: "delegate_task",
5326
5476
  description: "Delegate a task to one or more specialized agents",
5327
- parameters: import_zod.z.object({
5328
- task: import_zod.z.string().describe("The task to delegate"),
5329
- targetAgents: import_zod.z.array(import_zod.z.string()).describe("List of agent names to delegate the task to"),
5330
- context: import_zod.z.record(import_zod.z.unknown()).optional().describe("Additional context for the task")
5477
+ parameters: import_zod2.z.object({
5478
+ task: import_zod2.z.string().describe("The task to delegate"),
5479
+ targetAgents: import_zod2.z.array(import_zod2.z.string()).describe("List of agent names to delegate the task to"),
5480
+ context: import_zod2.z.record(import_zod2.z.unknown()).optional().describe("Additional context for the task")
5331
5481
  }),
5332
5482
  execute: (_0) => __async(this, [_0], function* ({ task, targetAgents, context = {} }) {
5333
5483
  try {
@@ -7362,48 +7512,48 @@ ${context}`;
7362
7512
  __name(Agent, "Agent");
7363
7513
 
7364
7514
  // src/tool/reasoning/tools.ts
7365
- var import_zod3 = require("zod");
7515
+ var import_zod4 = require("zod");
7366
7516
  var import_uuid4 = require("uuid");
7367
7517
 
7368
7518
  // src/tool/reasoning/types.ts
7369
- var import_zod2 = require("zod");
7519
+ var import_zod3 = require("zod");
7370
7520
  var NextAction = /* @__PURE__ */ ((NextAction2) => {
7371
7521
  NextAction2["CONTINUE"] = "continue";
7372
7522
  NextAction2["VALIDATE"] = "validate";
7373
7523
  NextAction2["FINAL_ANSWER"] = "final_answer";
7374
7524
  return NextAction2;
7375
7525
  })(NextAction || {});
7376
- var ReasoningStepSchema = import_zod2.z.object({
7377
- id: import_zod2.z.string().uuid(),
7526
+ var ReasoningStepSchema = import_zod3.z.object({
7527
+ id: import_zod3.z.string().uuid(),
7378
7528
  // Unique ID for the step
7379
- type: import_zod2.z.enum(["thought", "analysis"]),
7529
+ type: import_zod3.z.enum(["thought", "analysis"]),
7380
7530
  // Type of step
7381
- title: import_zod2.z.string(),
7531
+ title: import_zod3.z.string(),
7382
7532
  // Concise title for the step
7383
- reasoning: import_zod2.z.string(),
7533
+ reasoning: import_zod3.z.string(),
7384
7534
  // The detailed thought or analysis
7385
- action: import_zod2.z.string().optional(),
7535
+ action: import_zod3.z.string().optional(),
7386
7536
  // The action planned based on the thought (for 'thought' type)
7387
- result: import_zod2.z.string().optional(),
7537
+ result: import_zod3.z.string().optional(),
7388
7538
  // The result being analyzed (for 'analysis' type)
7389
- next_action: import_zod2.z.nativeEnum(NextAction).optional(),
7539
+ next_action: import_zod3.z.nativeEnum(NextAction).optional(),
7390
7540
  // What to do next (for 'analysis' type)
7391
- confidence: import_zod2.z.number().min(0).max(1).optional().default(0.8),
7541
+ confidence: import_zod3.z.number().min(0).max(1).optional().default(0.8),
7392
7542
  // Confidence level
7393
- timestamp: import_zod2.z.string().datetime(),
7543
+ timestamp: import_zod3.z.string().datetime(),
7394
7544
  // Timestamp of the step creation
7395
- historyEntryId: import_zod2.z.string(),
7545
+ historyEntryId: import_zod3.z.string(),
7396
7546
  // Link to the main history entry
7397
- agentId: import_zod2.z.string()
7547
+ agentId: import_zod3.z.string()
7398
7548
  // ID of the agent performing the step
7399
7549
  });
7400
7550
 
7401
7551
  // src/tool/reasoning/tools.ts
7402
- var thinkParametersSchema = import_zod3.z.object({
7403
- title: import_zod3.z.string().describe("A concise title for this thinking step"),
7404
- thought: import_zod3.z.string().describe("Your detailed thought or reasoning for this step"),
7405
- action: import_zod3.z.string().optional().describe("Optional: What you plan to do next based on this thought"),
7406
- confidence: import_zod3.z.number().min(0).max(1).optional().default(0.8).describe("Optional: How confident you are about this thought (0.0 to 1.0)")
7552
+ var thinkParametersSchema = import_zod4.z.object({
7553
+ title: import_zod4.z.string().describe("A concise title for this thinking step"),
7554
+ thought: import_zod4.z.string().describe("Your detailed thought or reasoning for this step"),
7555
+ action: import_zod4.z.string().optional().describe("Optional: What you plan to do next based on this thought"),
7556
+ confidence: import_zod4.z.number().min(0).max(1).optional().default(0.8).describe("Optional: How confident you are about this thought (0.0 to 1.0)")
7407
7557
  });
7408
7558
  var thinkTool = createTool({
7409
7559
  name: "think",
@@ -7439,14 +7589,14 @@ var thinkTool = createTool({
7439
7589
  }
7440
7590
  })
7441
7591
  });
7442
- var analyzeParametersSchema = import_zod3.z.object({
7443
- title: import_zod3.z.string().describe("A concise title for this analysis step"),
7444
- result: import_zod3.z.string().describe("The outcome or result of the previous action/thought being analyzed"),
7445
- analysis: import_zod3.z.string().describe("Your analysis of the result"),
7446
- next_action: import_zod3.z.nativeEnum(NextAction).describe(
7592
+ var analyzeParametersSchema = import_zod4.z.object({
7593
+ title: import_zod4.z.string().describe("A concise title for this analysis step"),
7594
+ result: import_zod4.z.string().describe("The outcome or result of the previous action/thought being analyzed"),
7595
+ analysis: import_zod4.z.string().describe("Your analysis of the result"),
7596
+ next_action: import_zod4.z.nativeEnum(NextAction).describe(
7447
7597
  `What to do next based on the analysis: "${"continue" /* CONTINUE */}", "${"validate" /* VALIDATE */}", or "${"final_answer" /* FINAL_ANSWER */}"`
7448
7598
  ),
7449
- confidence: import_zod3.z.number().min(0).max(1).optional().default(0.8).describe("Optional: How confident you are in this analysis (0.0 to 1.0)")
7599
+ confidence: import_zod4.z.number().min(0).max(1).optional().default(0.8).describe("Optional: How confident you are in this analysis (0.0 to 1.0)")
7450
7600
  });
7451
7601
  var analyzeTool = createTool({
7452
7602
  name: "analyze",
@@ -7647,15 +7797,15 @@ ${fewShotExamples != null ? fewShotExamples : FEW_SHOT_EXAMPLES}`;
7647
7797
  }, "createReasoningTools");
7648
7798
 
7649
7799
  // src/retriever/tools/index.ts
7650
- var import_zod4 = require("zod");
7800
+ var import_zod5 = require("zod");
7651
7801
  var createRetrieverTool = /* @__PURE__ */ __name((retriever, options = {}) => {
7652
7802
  const toolName = options.name || "search_knowledge";
7653
7803
  const toolDescription = options.description || "Searches for relevant information in the knowledge base based on the query.";
7654
7804
  return createTool({
7655
7805
  name: toolName,
7656
7806
  description: toolDescription,
7657
- parameters: import_zod4.z.object({
7658
- query: import_zod4.z.string().describe("The search query to find relevant information")
7807
+ parameters: import_zod5.z.object({
7808
+ query: import_zod5.z.string().describe("The search query to find relevant information")
7659
7809
  }),
7660
7810
  execute: (_0) => __async(void 0, [_0], function* ({ query }) {
7661
7811
  const result = yield retriever.retrieve(query);
@@ -8474,8 +8624,12 @@ var VoltAgent = class {
8474
8624
  constructor(options) {
8475
8625
  __publicField(this, "registry");
8476
8626
  __publicField(this, "serverStarted", false);
8627
+ __publicField(this, "customEndpoints", []);
8477
8628
  this.registry = AgentRegistry.getInstance();
8478
8629
  this.registerAgents(options.agents);
8630
+ if (options.customEndpoints && Array.isArray(options.customEndpoints)) {
8631
+ this.customEndpoints = [...options.customEndpoints];
8632
+ }
8479
8633
  if (options.telemetryExporter) {
8480
8634
  const exporters = Array.isArray(options.telemetryExporter) ? options.telemetryExporter : [options.telemetryExporter];
8481
8635
  const voltExporter = exporters.find(
@@ -8548,10 +8702,59 @@ var VoltAgent = class {
8548
8702
  console.log("[VoltAgent] Server is already running");
8549
8703
  return;
8550
8704
  }
8551
- yield startServer();
8552
- this.serverStarted = true;
8705
+ try {
8706
+ if (this.customEndpoints.length > 0) {
8707
+ registerCustomEndpoints(this.customEndpoints);
8708
+ }
8709
+ yield startServer();
8710
+ this.serverStarted = true;
8711
+ } catch (error) {
8712
+ console.error(
8713
+ `[VoltAgent] Failed to start server: ${error instanceof Error ? error.message : String(error)}`
8714
+ );
8715
+ throw error;
8716
+ }
8553
8717
  });
8554
8718
  }
8719
+ /**
8720
+ * Register a custom endpoint with the API server
8721
+ * @param endpoint The custom endpoint definition
8722
+ * @throws Error if the endpoint definition is invalid or registration fails
8723
+ */
8724
+ registerCustomEndpoint(endpoint) {
8725
+ try {
8726
+ this.customEndpoints.push(endpoint);
8727
+ if (this.serverStarted) {
8728
+ registerCustomEndpoint(endpoint);
8729
+ }
8730
+ } catch (error) {
8731
+ console.error(
8732
+ `Failed to register custom endpoint: ${error instanceof Error ? error.message : String(error)}`
8733
+ );
8734
+ throw error;
8735
+ }
8736
+ }
8737
+ /**
8738
+ * Register multiple custom endpoints with the API server
8739
+ * @param endpoints Array of custom endpoint definitions
8740
+ * @throws Error if any endpoint definition is invalid or registration fails
8741
+ */
8742
+ registerCustomEndpoints(endpoints) {
8743
+ try {
8744
+ if (!endpoints || !Array.isArray(endpoints) || endpoints.length === 0) {
8745
+ return;
8746
+ }
8747
+ this.customEndpoints.push(...endpoints);
8748
+ if (this.serverStarted) {
8749
+ registerCustomEndpoints(endpoints);
8750
+ }
8751
+ } catch (error) {
8752
+ console.error(
8753
+ `Failed to register custom endpoints: ${error instanceof Error ? error.message : String(error)}`
8754
+ );
8755
+ throw error;
8756
+ }
8757
+ }
8555
8758
  /**
8556
8759
  * Get all registered agents
8557
8760
  */
@@ -8635,6 +8838,7 @@ if (typeof require !== "undefined" && typeof module !== "undefined" && require.m
8635
8838
  Agent,
8636
8839
  AgentRegistry,
8637
8840
  BaseRetriever,
8841
+ CustomEndpointError,
8638
8842
  DEFAULT_INSTRUCTIONS,
8639
8843
  FEW_SHOT_EXAMPLES,
8640
8844
  InMemoryStorage,
@@ -8658,6 +8862,8 @@ if (typeof require !== "undefined" && typeof module !== "undefined" && require.m
8658
8862
  createTool,
8659
8863
  createToolkit,
8660
8864
  getNodeTypeFromNodeId,
8865
+ registerCustomEndpoint,
8866
+ registerCustomEndpoints,
8661
8867
  safeJsonParse,
8662
8868
  serializeValueForDebug,
8663
8869
  tool,