@voltagent/core 1.1.33 → 1.1.34
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.mts +42 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -4590,6 +4590,48 @@ declare class Agent {
|
|
|
4590
4590
|
* Get Memory instance if available
|
|
4591
4591
|
*/
|
|
4592
4592
|
getMemory(): Memory | false | undefined;
|
|
4593
|
+
/**
|
|
4594
|
+
* Convert this agent into a tool that can be used by other agents.
|
|
4595
|
+
* This enables supervisor/coordinator patterns where one agent can delegate
|
|
4596
|
+
* work to other specialized agents.
|
|
4597
|
+
*
|
|
4598
|
+
* @param options - Optional configuration for the tool
|
|
4599
|
+
* @param options.name - Custom name for the tool (defaults to `${agent.id}_tool`)
|
|
4600
|
+
* @param options.description - Custom description (defaults to agent's purpose or auto-generated)
|
|
4601
|
+
* @param options.parametersSchema - Custom input schema (defaults to { prompt: string })
|
|
4602
|
+
*
|
|
4603
|
+
* @returns A Tool instance that executes this agent
|
|
4604
|
+
*
|
|
4605
|
+
* @example
|
|
4606
|
+
* ```typescript
|
|
4607
|
+
* const writerAgent = new Agent({
|
|
4608
|
+
* id: "writer",
|
|
4609
|
+
* purpose: "Writes blog posts",
|
|
4610
|
+
* // ... other config
|
|
4611
|
+
* });
|
|
4612
|
+
*
|
|
4613
|
+
* const editorAgent = new Agent({
|
|
4614
|
+
* id: "editor",
|
|
4615
|
+
* purpose: "Edits content",
|
|
4616
|
+
* // ... other config
|
|
4617
|
+
* });
|
|
4618
|
+
*
|
|
4619
|
+
* // Supervisor agent that uses both as tools
|
|
4620
|
+
* const supervisorAgent = new Agent({
|
|
4621
|
+
* id: "supervisor",
|
|
4622
|
+
* instructions: "First call writer, then editor",
|
|
4623
|
+
* tools: [
|
|
4624
|
+
* writerAgent.toTool(),
|
|
4625
|
+
* editorAgent.toTool()
|
|
4626
|
+
* ]
|
|
4627
|
+
* });
|
|
4628
|
+
* ```
|
|
4629
|
+
*/
|
|
4630
|
+
toTool(options?: {
|
|
4631
|
+
name?: string;
|
|
4632
|
+
description?: string;
|
|
4633
|
+
parametersSchema?: z.ZodObject<any>;
|
|
4634
|
+
}): Tool<any, any>;
|
|
4593
4635
|
/**
|
|
4594
4636
|
* Check if working memory is supported
|
|
4595
4637
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -4590,6 +4590,48 @@ declare class Agent {
|
|
|
4590
4590
|
* Get Memory instance if available
|
|
4591
4591
|
*/
|
|
4592
4592
|
getMemory(): Memory | false | undefined;
|
|
4593
|
+
/**
|
|
4594
|
+
* Convert this agent into a tool that can be used by other agents.
|
|
4595
|
+
* This enables supervisor/coordinator patterns where one agent can delegate
|
|
4596
|
+
* work to other specialized agents.
|
|
4597
|
+
*
|
|
4598
|
+
* @param options - Optional configuration for the tool
|
|
4599
|
+
* @param options.name - Custom name for the tool (defaults to `${agent.id}_tool`)
|
|
4600
|
+
* @param options.description - Custom description (defaults to agent's purpose or auto-generated)
|
|
4601
|
+
* @param options.parametersSchema - Custom input schema (defaults to { prompt: string })
|
|
4602
|
+
*
|
|
4603
|
+
* @returns A Tool instance that executes this agent
|
|
4604
|
+
*
|
|
4605
|
+
* @example
|
|
4606
|
+
* ```typescript
|
|
4607
|
+
* const writerAgent = new Agent({
|
|
4608
|
+
* id: "writer",
|
|
4609
|
+
* purpose: "Writes blog posts",
|
|
4610
|
+
* // ... other config
|
|
4611
|
+
* });
|
|
4612
|
+
*
|
|
4613
|
+
* const editorAgent = new Agent({
|
|
4614
|
+
* id: "editor",
|
|
4615
|
+
* purpose: "Edits content",
|
|
4616
|
+
* // ... other config
|
|
4617
|
+
* });
|
|
4618
|
+
*
|
|
4619
|
+
* // Supervisor agent that uses both as tools
|
|
4620
|
+
* const supervisorAgent = new Agent({
|
|
4621
|
+
* id: "supervisor",
|
|
4622
|
+
* instructions: "First call writer, then editor",
|
|
4623
|
+
* tools: [
|
|
4624
|
+
* writerAgent.toTool(),
|
|
4625
|
+
* editorAgent.toTool()
|
|
4626
|
+
* ]
|
|
4627
|
+
* });
|
|
4628
|
+
* ```
|
|
4629
|
+
*/
|
|
4630
|
+
toTool(options?: {
|
|
4631
|
+
name?: string;
|
|
4632
|
+
description?: string;
|
|
4633
|
+
parametersSchema?: z.ZodObject<any>;
|
|
4634
|
+
}): Tool<any, any>;
|
|
4593
4635
|
/**
|
|
4594
4636
|
* Check if working memory is supported
|
|
4595
4637
|
*/
|
package/dist/index.js
CHANGED
|
@@ -16615,6 +16615,68 @@ ${toolkit.instructions}`;
|
|
|
16615
16615
|
}
|
|
16616
16616
|
return this.memory ?? this.memoryManager.getMemory();
|
|
16617
16617
|
}
|
|
16618
|
+
/**
|
|
16619
|
+
* Convert this agent into a tool that can be used by other agents.
|
|
16620
|
+
* This enables supervisor/coordinator patterns where one agent can delegate
|
|
16621
|
+
* work to other specialized agents.
|
|
16622
|
+
*
|
|
16623
|
+
* @param options - Optional configuration for the tool
|
|
16624
|
+
* @param options.name - Custom name for the tool (defaults to `${agent.id}_tool`)
|
|
16625
|
+
* @param options.description - Custom description (defaults to agent's purpose or auto-generated)
|
|
16626
|
+
* @param options.parametersSchema - Custom input schema (defaults to { prompt: string })
|
|
16627
|
+
*
|
|
16628
|
+
* @returns A Tool instance that executes this agent
|
|
16629
|
+
*
|
|
16630
|
+
* @example
|
|
16631
|
+
* ```typescript
|
|
16632
|
+
* const writerAgent = new Agent({
|
|
16633
|
+
* id: "writer",
|
|
16634
|
+
* purpose: "Writes blog posts",
|
|
16635
|
+
* // ... other config
|
|
16636
|
+
* });
|
|
16637
|
+
*
|
|
16638
|
+
* const editorAgent = new Agent({
|
|
16639
|
+
* id: "editor",
|
|
16640
|
+
* purpose: "Edits content",
|
|
16641
|
+
* // ... other config
|
|
16642
|
+
* });
|
|
16643
|
+
*
|
|
16644
|
+
* // Supervisor agent that uses both as tools
|
|
16645
|
+
* const supervisorAgent = new Agent({
|
|
16646
|
+
* id: "supervisor",
|
|
16647
|
+
* instructions: "First call writer, then editor",
|
|
16648
|
+
* tools: [
|
|
16649
|
+
* writerAgent.toTool(),
|
|
16650
|
+
* editorAgent.toTool()
|
|
16651
|
+
* ]
|
|
16652
|
+
* });
|
|
16653
|
+
* ```
|
|
16654
|
+
*/
|
|
16655
|
+
toTool(options) {
|
|
16656
|
+
const toolName = options?.name || `${this.id}_tool`;
|
|
16657
|
+
const toolDescription = options?.description || this.purpose || `Executes the ${this.name} agent to complete a task`;
|
|
16658
|
+
const parametersSchema = options?.parametersSchema || import_zod3.z.object({
|
|
16659
|
+
prompt: import_zod3.z.string().describe("The prompt or task to send to the agent")
|
|
16660
|
+
});
|
|
16661
|
+
return createTool({
|
|
16662
|
+
name: toolName,
|
|
16663
|
+
description: toolDescription,
|
|
16664
|
+
parameters: parametersSchema,
|
|
16665
|
+
execute: /* @__PURE__ */ __name(async (args, context8) => {
|
|
16666
|
+
const prompt = args.prompt || args;
|
|
16667
|
+
const result = await this.generateText(prompt, {
|
|
16668
|
+
// Pass through the operation context if available
|
|
16669
|
+
parentOperationContext: context8,
|
|
16670
|
+
conversationId: context8?.conversationId,
|
|
16671
|
+
userId: context8?.userId
|
|
16672
|
+
});
|
|
16673
|
+
return {
|
|
16674
|
+
text: result.text,
|
|
16675
|
+
usage: result.usage
|
|
16676
|
+
};
|
|
16677
|
+
}, "execute")
|
|
16678
|
+
});
|
|
16679
|
+
}
|
|
16618
16680
|
/**
|
|
16619
16681
|
* Check if working memory is supported
|
|
16620
16682
|
*/
|