@voltagent/core 0.1.16 → 0.1.18
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 +19 -1
- package/dist/index.js +63 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -35,6 +35,14 @@ type Toolkit = {
|
|
|
35
35
|
*/
|
|
36
36
|
tools: Tool<ToolSchema>[];
|
|
37
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* Helper function for creating a new toolkit.
|
|
40
|
+
* Provides default values and ensures the basic structure is met.
|
|
41
|
+
*
|
|
42
|
+
* @param options - The configuration options for the toolkit.
|
|
43
|
+
* @returns A Toolkit object.
|
|
44
|
+
*/
|
|
45
|
+
declare const createToolkit: (options: Toolkit) => Toolkit;
|
|
38
46
|
|
|
39
47
|
/**
|
|
40
48
|
* Status of a tool at any given time
|
|
@@ -457,6 +465,10 @@ type AgentOptions = {
|
|
|
457
465
|
* Sub-agents that this agent can delegate tasks to
|
|
458
466
|
*/
|
|
459
467
|
subAgents?: any[];
|
|
468
|
+
/**
|
|
469
|
+
* Optional user-defined context to be passed around
|
|
470
|
+
*/
|
|
471
|
+
userContext?: Map<string | symbol, unknown>;
|
|
460
472
|
} & ({
|
|
461
473
|
/**
|
|
462
474
|
* @deprecated Use `instructions` instead.
|
|
@@ -528,6 +540,7 @@ interface CommonGenerateOptions {
|
|
|
528
540
|
signal?: AbortSignal;
|
|
529
541
|
historyEntryId?: string;
|
|
530
542
|
operationContext?: OperationContext;
|
|
543
|
+
userContext?: Map<string | symbol, unknown>;
|
|
531
544
|
}
|
|
532
545
|
/**
|
|
533
546
|
* Public-facing generate options for external users
|
|
@@ -623,6 +636,10 @@ type AgentHandoffOptions = {
|
|
|
623
636
|
* Parent history entry ID
|
|
624
637
|
*/
|
|
625
638
|
parentHistoryEntryId?: string;
|
|
639
|
+
/**
|
|
640
|
+
* Optional user-defined context to be passed from the supervisor agent
|
|
641
|
+
*/
|
|
642
|
+
userContext?: Map<string | symbol, unknown>;
|
|
626
643
|
};
|
|
627
644
|
/**
|
|
628
645
|
* Result of a handoff to another agent
|
|
@@ -1805,6 +1822,7 @@ declare class SubAgentManager {
|
|
|
1805
1822
|
*/
|
|
1806
1823
|
handoffToMultiple(options: Omit<AgentHandoffOptions, "targetAgent"> & {
|
|
1807
1824
|
targetAgents: Agent<any>[];
|
|
1825
|
+
userContext?: Map<string | symbol, unknown>;
|
|
1808
1826
|
}): Promise<AgentHandoffResult[]>;
|
|
1809
1827
|
/**
|
|
1810
1828
|
* Create a delegate tool for sub-agents
|
|
@@ -2975,4 +2993,4 @@ declare class VoltAgent {
|
|
|
2975
2993
|
shutdownTelemetry(): Promise<void>;
|
|
2976
2994
|
}
|
|
2977
2995
|
|
|
2978
|
-
export { Agent, AgentHistoryEntry, AgentHookOnEnd, AgentHookOnHandoff, AgentHookOnStart, AgentHookOnToolEnd, AgentHookOnToolStart, 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, OnEndHookArgs, OnHandoffHookArgs, OnStartHookArgs, OnToolEndHookArgs, OnToolStartHookArgs, OperationContext, PackageUpdateInfo, PromptCreator, PromptTemplate, ProviderObjectResponse, ProviderObjectStreamResponse, ProviderParams, ProviderResponse, ProviderTextResponse, ProviderTextStreamResponse, ReadableStreamType, ReasoningStep, ReasoningStepSchema, ReasoningToolExecuteOptions, Retriever, RetrieverOptions, RetryConfig, StdioServerConfig, StepChunkCallback, StepFinishCallback, StepWithContent, StreamObjectFinishResult, StreamObjectOnFinishCallback, StreamObjectOptions, StreamTextFinishResult, StreamTextOnFinishCallback, StreamTextOptions, TemplateVariables, TextPart, Tool, ToolCall, ToolErrorInfo, ToolExecuteOptions, ToolExecutionContext, ToolManager, ToolOptions, ToolSchema, ToolStatus, ToolStatusInfo, Toolkit, ToolsetMap, ToolsetWithTools, TransportError, UsageInfo, Voice, VoiceEventData, VoiceEventType, VoiceMetadata, VoiceOptions, VoltAgent, VoltAgentError, checkForUpdates, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createTool, VoltAgent as default, getNodeTypeFromNodeId, serializeValueForDebug, tool, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };
|
|
2996
|
+
export { Agent, AgentHistoryEntry, AgentHookOnEnd, AgentHookOnHandoff, AgentHookOnStart, AgentHookOnToolEnd, AgentHookOnToolStart, 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, OnEndHookArgs, OnHandoffHookArgs, OnStartHookArgs, OnToolEndHookArgs, OnToolStartHookArgs, OperationContext, PackageUpdateInfo, PromptCreator, PromptTemplate, ProviderObjectResponse, ProviderObjectStreamResponse, ProviderParams, ProviderResponse, ProviderTextResponse, ProviderTextStreamResponse, ReadableStreamType, ReasoningStep, ReasoningStepSchema, ReasoningToolExecuteOptions, Retriever, RetrieverOptions, RetryConfig, StdioServerConfig, StepChunkCallback, StepFinishCallback, StepWithContent, StreamObjectFinishResult, StreamObjectOnFinishCallback, StreamObjectOptions, StreamTextFinishResult, StreamTextOnFinishCallback, StreamTextOptions, TemplateVariables, TextPart, Tool, ToolCall, ToolErrorInfo, ToolExecuteOptions, ToolExecutionContext, ToolManager, ToolOptions, ToolSchema, ToolStatus, ToolStatusInfo, Toolkit, ToolsetMap, ToolsetWithTools, TransportError, UsageInfo, Voice, VoiceEventData, VoiceEventType, VoiceMetadata, VoiceOptions, VoltAgent, VoltAgentError, checkForUpdates, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createTool, createToolkit, VoltAgent as default, getNodeTypeFromNodeId, serializeValueForDebug, tool, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };
|
package/dist/index.js
CHANGED
|
@@ -112,6 +112,7 @@ __export(src_exports, {
|
|
|
112
112
|
createReasoningTools: () => createReasoningTools,
|
|
113
113
|
createRetrieverTool: () => createRetrieverTool,
|
|
114
114
|
createTool: () => createTool,
|
|
115
|
+
createToolkit: () => createToolkit,
|
|
115
116
|
default: () => src_default,
|
|
116
117
|
getNodeTypeFromNodeId: () => getNodeTypeFromNodeId,
|
|
117
118
|
serializeValueForDebug: () => serializeValueForDebug,
|
|
@@ -3959,6 +3960,26 @@ var ToolManager = class {
|
|
|
3959
3960
|
};
|
|
3960
3961
|
__name(ToolManager, "ToolManager");
|
|
3961
3962
|
|
|
3963
|
+
// src/tool/toolkit.ts
|
|
3964
|
+
var createToolkit = /* @__PURE__ */ __name((options) => {
|
|
3965
|
+
if (!options.name) {
|
|
3966
|
+
throw new Error("Toolkit name is required");
|
|
3967
|
+
}
|
|
3968
|
+
if (!options.tools || options.tools.length === 0) {
|
|
3969
|
+
console.warn(`Toolkit '${options.name}' created without any tools.`);
|
|
3970
|
+
}
|
|
3971
|
+
return {
|
|
3972
|
+
name: options.name,
|
|
3973
|
+
description: options.description || "",
|
|
3974
|
+
// Default empty description
|
|
3975
|
+
instructions: options.instructions,
|
|
3976
|
+
addInstructions: options.addInstructions || false,
|
|
3977
|
+
// Default to false
|
|
3978
|
+
tools: options.tools || []
|
|
3979
|
+
// Default to empty array if not provided (though warned above)
|
|
3980
|
+
};
|
|
3981
|
+
}, "createToolkit");
|
|
3982
|
+
|
|
3962
3983
|
// src/tool/index.ts
|
|
3963
3984
|
var Tool = class {
|
|
3964
3985
|
/**
|
|
@@ -4380,7 +4401,8 @@ ${agentsMemory || "No previous agent interactions available."}
|
|
|
4380
4401
|
userId,
|
|
4381
4402
|
sourceAgent,
|
|
4382
4403
|
parentAgentId,
|
|
4383
|
-
parentHistoryEntryId
|
|
4404
|
+
parentHistoryEntryId,
|
|
4405
|
+
userContext
|
|
4384
4406
|
} = options;
|
|
4385
4407
|
const handoffConversationId = conversationId || crypto.randomUUID();
|
|
4386
4408
|
try {
|
|
@@ -4398,7 +4420,8 @@ Context: ${JSON.stringify(context)}`
|
|
|
4398
4420
|
conversationId: handoffConversationId,
|
|
4399
4421
|
userId,
|
|
4400
4422
|
parentAgentId: (sourceAgent == null ? void 0 : sourceAgent.id) || parentAgentId,
|
|
4401
|
-
parentHistoryEntryId
|
|
4423
|
+
parentHistoryEntryId,
|
|
4424
|
+
userContext
|
|
4402
4425
|
});
|
|
4403
4426
|
return {
|
|
4404
4427
|
result: response.text,
|
|
@@ -4429,7 +4452,19 @@ Context: ${JSON.stringify(context)}`
|
|
|
4429
4452
|
*/
|
|
4430
4453
|
handoffToMultiple(options) {
|
|
4431
4454
|
return __async(this, null, function* () {
|
|
4432
|
-
const _a = options, {
|
|
4455
|
+
const _a = options, {
|
|
4456
|
+
targetAgents,
|
|
4457
|
+
conversationId,
|
|
4458
|
+
parentAgentId,
|
|
4459
|
+
parentHistoryEntryId,
|
|
4460
|
+
userContext
|
|
4461
|
+
} = _a, restOptions = __objRest(_a, [
|
|
4462
|
+
"targetAgents",
|
|
4463
|
+
"conversationId",
|
|
4464
|
+
"parentAgentId",
|
|
4465
|
+
"parentHistoryEntryId",
|
|
4466
|
+
"userContext"
|
|
4467
|
+
]);
|
|
4433
4468
|
const handoffConversationId = conversationId || crypto.randomUUID();
|
|
4434
4469
|
const results = yield Promise.all(
|
|
4435
4470
|
targetAgents.map((agent) => __async(this, null, function* () {
|
|
@@ -4438,7 +4473,8 @@ Context: ${JSON.stringify(context)}`
|
|
|
4438
4473
|
targetAgent: agent,
|
|
4439
4474
|
conversationId: handoffConversationId,
|
|
4440
4475
|
parentAgentId,
|
|
4441
|
-
parentHistoryEntryId
|
|
4476
|
+
parentHistoryEntryId,
|
|
4477
|
+
userContext
|
|
4442
4478
|
}));
|
|
4443
4479
|
} catch (error) {
|
|
4444
4480
|
console.error(`Error in handoffToMultiple for agent ${agent.name}:`, error);
|
|
@@ -4497,6 +4533,8 @@ Context: ${JSON.stringify(context)}`
|
|
|
4497
4533
|
);
|
|
4498
4534
|
}
|
|
4499
4535
|
const sourceAgent = options.sourceAgent;
|
|
4536
|
+
const operationContext = options.operationContext;
|
|
4537
|
+
const supervisorUserContext = operationContext == null ? void 0 : operationContext.userContext;
|
|
4500
4538
|
const currentHistoryEntryId = options.currentHistoryEntryId;
|
|
4501
4539
|
const results = yield this.handoffToMultiple(__spreadValues({
|
|
4502
4540
|
task,
|
|
@@ -4505,7 +4543,9 @@ Context: ${JSON.stringify(context)}`
|
|
|
4505
4543
|
sourceAgent,
|
|
4506
4544
|
// Pass parent context for event propagation
|
|
4507
4545
|
parentAgentId: sourceAgent == null ? void 0 : sourceAgent.id,
|
|
4508
|
-
parentHistoryEntryId: currentHistoryEntryId
|
|
4546
|
+
parentHistoryEntryId: currentHistoryEntryId,
|
|
4547
|
+
// Pass the supervisor's userContext to the handoff options
|
|
4548
|
+
userContext: supervisorUserContext
|
|
4509
4549
|
}, options));
|
|
4510
4550
|
return results.map((result, index) => {
|
|
4511
4551
|
const status = result.status || "success";
|
|
@@ -5137,7 +5177,7 @@ ${context}`;
|
|
|
5137
5177
|
});
|
|
5138
5178
|
const opContext = {
|
|
5139
5179
|
operationId: historyEntry.id,
|
|
5140
|
-
userContext: /* @__PURE__ */ new Map(),
|
|
5180
|
+
userContext: options.userContext ? new Map(options.userContext) : /* @__PURE__ */ new Map(),
|
|
5141
5181
|
historyEntry,
|
|
5142
5182
|
eventUpdaters: /* @__PURE__ */ new Map(),
|
|
5143
5183
|
isActive: true,
|
|
@@ -5240,12 +5280,14 @@ ${context}`;
|
|
|
5240
5280
|
conversationId: initialConversationId,
|
|
5241
5281
|
parentAgentId,
|
|
5242
5282
|
parentHistoryEntryId,
|
|
5243
|
-
contextLimit = 10
|
|
5283
|
+
contextLimit = 10,
|
|
5284
|
+
userContext
|
|
5244
5285
|
} = internalOptions;
|
|
5245
5286
|
const operationContext = yield this.initializeHistory(input, "working", {
|
|
5246
5287
|
parentAgentId,
|
|
5247
5288
|
parentHistoryEntryId,
|
|
5248
|
-
operationName: "generateText"
|
|
5289
|
+
operationName: "generateText",
|
|
5290
|
+
userContext
|
|
5249
5291
|
});
|
|
5250
5292
|
const { messages: contextMessages, conversationId: finalConversationId } = yield this.memoryManager.prepareConversationContext(
|
|
5251
5293
|
operationContext,
|
|
@@ -5438,12 +5480,14 @@ ${context}`;
|
|
|
5438
5480
|
conversationId: initialConversationId,
|
|
5439
5481
|
parentAgentId,
|
|
5440
5482
|
parentHistoryEntryId,
|
|
5441
|
-
contextLimit = 10
|
|
5483
|
+
contextLimit = 10,
|
|
5484
|
+
userContext
|
|
5442
5485
|
} = internalOptions;
|
|
5443
5486
|
const operationContext = yield this.initializeHistory(input, "working", {
|
|
5444
5487
|
parentAgentId,
|
|
5445
5488
|
parentHistoryEntryId,
|
|
5446
|
-
operationName: "streamText"
|
|
5489
|
+
operationName: "streamText",
|
|
5490
|
+
userContext
|
|
5447
5491
|
});
|
|
5448
5492
|
const { messages: contextMessages, conversationId: finalConversationId } = yield this.memoryManager.prepareConversationContext(
|
|
5449
5493
|
operationContext,
|
|
@@ -5687,12 +5731,14 @@ ${context}`;
|
|
|
5687
5731
|
conversationId: initialConversationId,
|
|
5688
5732
|
parentAgentId,
|
|
5689
5733
|
parentHistoryEntryId,
|
|
5690
|
-
contextLimit = 10
|
|
5734
|
+
contextLimit = 10,
|
|
5735
|
+
userContext
|
|
5691
5736
|
} = internalOptions;
|
|
5692
5737
|
const operationContext = yield this.initializeHistory(input, "working", {
|
|
5693
5738
|
parentAgentId,
|
|
5694
5739
|
parentHistoryEntryId,
|
|
5695
|
-
operationName: "generateObject"
|
|
5740
|
+
operationName: "generateObject",
|
|
5741
|
+
userContext
|
|
5696
5742
|
});
|
|
5697
5743
|
const { messages: contextMessages, conversationId: finalConversationId } = yield this.memoryManager.prepareConversationContext(
|
|
5698
5744
|
operationContext,
|
|
@@ -5823,12 +5869,14 @@ ${context}`;
|
|
|
5823
5869
|
parentAgentId,
|
|
5824
5870
|
parentHistoryEntryId,
|
|
5825
5871
|
provider,
|
|
5826
|
-
contextLimit = 10
|
|
5872
|
+
contextLimit = 10,
|
|
5873
|
+
userContext
|
|
5827
5874
|
} = internalOptions;
|
|
5828
5875
|
const operationContext = yield this.initializeHistory(input, "working", {
|
|
5829
5876
|
parentAgentId,
|
|
5830
5877
|
parentHistoryEntryId,
|
|
5831
|
-
operationName: "streamObject"
|
|
5878
|
+
operationName: "streamObject",
|
|
5879
|
+
userContext
|
|
5832
5880
|
});
|
|
5833
5881
|
const { messages: contextMessages, conversationId: finalConversationId } = yield this.memoryManager.prepareConversationContext(
|
|
5834
5882
|
operationContext,
|
|
@@ -6209,26 +6257,6 @@ var analyzeTool = createTool({
|
|
|
6209
6257
|
})
|
|
6210
6258
|
});
|
|
6211
6259
|
|
|
6212
|
-
// src/tool/toolkit.ts
|
|
6213
|
-
var createToolkit = /* @__PURE__ */ __name((options) => {
|
|
6214
|
-
if (!options.name) {
|
|
6215
|
-
throw new Error("Toolkit name is required");
|
|
6216
|
-
}
|
|
6217
|
-
if (!options.tools || options.tools.length === 0) {
|
|
6218
|
-
console.warn(`Toolkit '${options.name}' created without any tools.`);
|
|
6219
|
-
}
|
|
6220
|
-
return {
|
|
6221
|
-
name: options.name,
|
|
6222
|
-
description: options.description || "",
|
|
6223
|
-
// Default empty description
|
|
6224
|
-
instructions: options.instructions,
|
|
6225
|
-
addInstructions: options.addInstructions || false,
|
|
6226
|
-
// Default to false
|
|
6227
|
-
tools: options.tools || []
|
|
6228
|
-
// Default to empty array if not provided (though warned above)
|
|
6229
|
-
};
|
|
6230
|
-
}, "createToolkit");
|
|
6231
|
-
|
|
6232
6260
|
// src/tool/reasoning/index.ts
|
|
6233
6261
|
var DEFAULT_INSTRUCTIONS = `
|
|
6234
6262
|
You are equipped with 'think' and 'analyze' capabilities to methodically tackle problems and organize your reasoning process. ALWAYS utilize 'think' before initiating any tool calls or formulating a response.
|
|
@@ -7140,6 +7168,7 @@ if (typeof require !== "undefined" && typeof module !== "undefined" && require.m
|
|
|
7140
7168
|
createReasoningTools,
|
|
7141
7169
|
createRetrieverTool,
|
|
7142
7170
|
createTool,
|
|
7171
|
+
createToolkit,
|
|
7143
7172
|
getNodeTypeFromNodeId,
|
|
7144
7173
|
serializeValueForDebug,
|
|
7145
7174
|
tool,
|