@voltagent/core 0.1.2 → 0.1.4

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/LICENCE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 VoltAgent Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,44 +1,190 @@
1
- # @voltagent/core
1
+ <div align="center">
2
+ <a href="https://voltagent.dev/">
3
+ <img width="1800" alt="435380213-b6253409-8741-462b-a346-834cd18565a9" src="https://github.com/user-attachments/assets/452a03e7-eeda-4394-9ee7-0ffbcf37245c" />
4
+ </a>
2
5
 
3
- Core package for the VoltAgent framework - a framework for building AI-powered agents.
6
+ <br/>
7
+ <br/>
4
8
 
5
- ## Installation
9
+ <div align="center">
10
+ <a href="https://voltagent.dev">Home Page</a> |
11
+ <a href="https://voltagent.dev/docs/">Documentation</a> |
12
+ <a href="https://github.com/voltagent/voltagent/tree/main/examples">Examples</a> |
13
+ <a href="https://s.voltagent.dev/discord">Discord</a> |
14
+ <a href="https://voltagent.dev/blog/">Blog</a>
15
+ </div>
16
+ </div>
6
17
 
7
- You can install the package via npm, yarn, or pnpm:
18
+ <br/>
8
19
 
9
- ```bash
10
- # npm
11
- npm install @voltagent/core
20
+ <div align="center">
21
+ <strong>VoltAgent is an open source TypeScript framework for building and orchestrating AI agents.</strong><br>
22
+ Escape the limitations of no-code builders and the complexity of starting from scratch.
23
+ <br />
24
+ <br />
25
+ </div>
26
+
27
+ <div align="center">
28
+
29
+ [![npm version](https://img.shields.io/npm/v/@voltagent/core.svg)](https://www.npmjs.com/package/@voltagent/core)
30
+ [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](CODE_OF_CONDUCT.md)
31
+ [![Discord](https://img.shields.io/discord/1361559153780195478.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://s.voltagent.dev/discord)
32
+ [![Twitter Follow](https://img.shields.io/twitter/follow/voltagent_dev?style=social)](https://twitter.com/voltagent_dev)
33
+
34
+ </div>
35
+
36
+ <br/>
37
+
38
+ <div align="center">
39
+ <a href="https://voltagent.dev/">
40
+ <img width="896" alt="flow" src="https://github.com/user-attachments/assets/f0627868-6153-4f63-ba7f-bdfcc5dd603d" />
41
+ </a>
42
+
43
+ </div>
44
+
45
+ ## What is VoltAgent?
46
+
47
+ > An **AI Agent Framework** provides the foundational structure and tools needed to build applications powered by autonomous agents. These agents, often driven by Large Language Models (LLMs), can perceive their environment, make decisions, and take actions to achieve specific goals. Building such agents from scratch involves managing complex interactions with LLMs, handling state, connecting to external tools and data, and orchestrating workflows.
48
+
49
+ **VoltAgent** is an open-source TypeScript framework that acts as this essential toolkit. It simplifies the development of AI agent applications by providing modular building blocks, standardized patterns, and abstractions. Whether you're creating chatbots, virtual assistants, automated workflows, or complex multi-agent systems, VoltAgent handles the underlying complexity, allowing you to focus on defining your agents' capabilities and logic.
50
+
51
+ Instead of building everything from scratch, VoltAgent provides ready-made, modular building blocks:
52
+
53
+ - **Core Engine (`@voltagent/core`)**: The heart of VoltAgent, providing fundamental capabilities for your AI agents Define individual agents with specific roles, tools, and memory.
54
+ - **Multi-Agent Systems**: Architect complex applications by coordinating multiple specialized agents using Supervisors.
55
+ - **Extensible Packages**: Enhance functionality with packages like `@voltagent/voice` for voice interactions.
56
+ - **Tooling & Integrations**: Equip agents with tools to connect to external APIs, databases, and services, enabling them to perform real-world tasks. **Supports the [Model Control Protocol (MCP)](https://modelcontextprotocol.io/) for standardized tool interactions.**
57
+ - **Data Retrieval & RAG**: Implement specialized retriever agents for efficient information fetching and **Retrieval-Augmented Generation (RAG)**.
58
+ - **Memory**: Enable agents to remember past interactions for more natural and context-aware conversations.
59
+ - **LLM Compatibility**: Works with popular AI models from OpenAI, Google, Anthropic, and more, allowing easy switching.
60
+ - **Developer Ecosystem**: Includes helpers like `create-voltagent-app`, `@voltagent/cli`, and the visual [VoltAgent Console](https://console.voltagent.dev) for quick setup, monitoring, and debugging.
61
+
62
+ In essence, VoltAgent helps developers build sophisticated AI applications faster and more reliably, avoiding repetitive setup and the limitations of simpler tools.
63
+
64
+ ## Why VoltAgent?
65
+
66
+ Building AI applications often involves a trade-off:
67
+
68
+ 1. **DIY Approach:** Using basic AI provider tools offers control but leads to complex, hard-to-manage code and repeated effort.
69
+ 2. **No-Code Builders:** Simpler initially but often restrictive, limiting customization, provider choice, and complexity.
70
+
71
+ VoltAgent provides a middle ground, offering structure and components without sacrificing flexibility:
72
+
73
+ - **Build Faster:** Accelerate development with pre-built components compared to starting from scratch.
74
+ - **Maintainable Code:** Encourages organization for easier updates and debugging.
75
+ - **Scalability:** Start simple and easily scale to complex, multi-agent systems handling intricate workflows.
76
+ - **Flexibility:** Full control over agent behavior, LLM choice, tool integrations, and UI connections.
77
+ - **Avoid Lock-in:** Freedom to switch AI providers and models as needed.
78
+ - **Cost Efficiency:** Features designed to optimize AI service usage and reduce redundant calls.
79
+ - **Visual Monitoring:** Use the [VoltAgent Console](https://console.voltagent.dev) to track agent performance, inspect state, and debug visually.
80
+
81
+ VoltAgent empowers developers to build their envisioned AI applications efficiently, from simple helpers to complex systems.
82
+
83
+ ## ⚡ Quick Start
12
84
 
13
- # yarn
14
- yarn add @voltagent/core
85
+ Create a new VoltAgent project in seconds using the `create-voltagent-app` CLI tool:
15
86
 
16
- # pnpm
17
- pnpm add @voltagent/core
87
+ ```bash
88
+ npm create voltagent-app@latest
18
89
  ```
19
90
 
20
- ## Basic Usage
91
+ This command guides you through setup.
92
+
93
+ You'll see the starter code in `src/index.ts` to get you started with the VoltAgent framework.
21
94
 
22
95
  ```typescript
23
- import { log, initVoltAgent } from "@voltagent/core";
96
+ import { VoltAgent, Agent } from "@voltagent/core";
97
+ import { VercelAIProvider } from "@voltagent/vercel-ai"; // Example provider
98
+ import { openai } from "@ai-sdk/openai"; // Example model
99
+
100
+ // Define a simple agent
101
+ const agent = new Agent({
102
+ name: "my-agent",
103
+ description: "A helpful assistant that answers questions without using tools",
104
+ // Note: You can swap VercelAIProvider and openai with other supported providers/models
105
+ llm: new VercelAIProvider(),
106
+ model: openai("gpt-4o-mini"),
107
+ });
108
+
109
+ // Initialize VoltAgent with your agent(s)
110
+ new VoltAgent({
111
+ agents: {
112
+ agent,
113
+ },
114
+ });
115
+ ```
24
116
 
25
- // Initialize the framework with debug mode
26
- initVoltAgent({ debug: true });
117
+ Afterwards, navigate to your project and run:
118
+
119
+ ```bash
120
+ npm run dev
121
+ ```
122
+
123
+ When you run the dev command, tsx will compile and run your code. You should see the VoltAgent server startup message in your terminal:
124
+
125
+ ```
126
+ ══════════════════════════════════════════════════
127
+ VOLTAGENT SERVER STARTED SUCCESSFULLY
128
+ ══════════════════════════════════════════════════
129
+ ✓ HTTP Server: http://localhost:3141
27
130
 
28
- // Use logging function
29
- log("Application started");
131
+ Developer Console: https://console.voltagent.dev
132
+ ══════════════════════════════════════════════════
30
133
  ```
31
134
 
32
- ## API Reference
135
+ Your agent is now running! To interact with it:
136
+
137
+ 1. Open the Console: Click the [VoltAgent Console](https://console.voltagent.dev) link in your terminal output (or copy-paste it into your browser).
138
+ 2. Find Your Agent: On the VoltAgent Console page, you should see your agent listed (e.g., "my-agent").
139
+ 3. Open Agent Details: Click on your agent's name.
140
+ 4. Start Chatting: On the agent detail page, click the chat icon in the bottom right corner to open the chat window.
141
+ 5. Send a Message: Type a message like "Hello" and press Enter.
142
+
143
+ ![VoltAgent Developer Console Demo](https://github.com/user-attachments/assets/0adbec33-1373-4cf4-b67d-825f7baf1cb4)
144
+
145
+ ## Key Features
146
+
147
+ - **Agent Core:** Define agents with descriptions, LLM providers, tools, and memory management.
148
+ - **Multi-Agent Systems:** Build complex workflows using Supervisor Agents coordinating multiple specialized Sub-Agents.
149
+ - **Tool Usage & Lifecycle:** Equip agents with custom or pre-built tools (functions) with type-safety (Zod), lifecycle hooks, and cancellation support to interact with external systems.
150
+ - **Flexible LLM Support:** Integrate seamlessly with various LLM providers (OpenAI, Anthropic, Google, etc.) and easily switch between models.
151
+ - **Memory Management:** Enable agents to retain context across interactions using different configurable memory providers.
152
+ - **Observability & Debugging:** Visually monitor agent states, interactions, logs, and performance via the [VoltAgent Console](https://console.voltagent.dev).
153
+ - **Voice Interaction:** Build voice-enabled agents capable of speech recognition and synthesis using the `@voltagent/voice` package.
154
+ - **Data Retrieval & RAG:** Integrate specialized retriever agents for efficient information fetching and **Retrieval-Augmented Generation (RAG)** from various sources.
155
+ - **Model Control Protocol (MCP) Support:** Connect to external tool servers (HTTP/stdio) adhering to the [MCP standard](https://modelcontextprotocol.io/) for extended capabilities.
156
+ - **Prompt Engineering Tools:** Leverage utilities like `createPrompt` for crafting and managing effective prompts for your agents.
157
+ - **Framework Compatibility:** Designed for easy integration into existing Node.js applications and popular frameworks.
158
+
159
+ ## Use Cases
160
+
161
+ VoltAgent is versatile and can power a wide range of AI-driven applications:
162
+
163
+ - **Complex Workflow Automation:** Orchestrate multi-step processes involving various tools, APIs, and decision points using coordinated agents.
164
+ - **Intelligent Data Pipelines:** Build agents that fetch, process, analyze, and transform data from diverse sources.
165
+ - **AI-Powered Internal Tools & Dashboards:** Create interactive internal applications that leverage AI for analysis, reporting, or task automation, often integrated with UIs using hooks.
166
+ - **Automated Customer Support Agents:** Develop sophisticated chatbots that can understand context (memory), use tools (e.g., check order status), and escalate complex issues.
167
+ - **Repository Analysis & Codebase Automation:** Analyze code repositories, automate refactoring tasks, generate documentation, or manage CI/CD processes.
168
+ - **Retrieval-Augmented Generation (RAG) Systems:** Build agents that retrieve relevant information from knowledge bases (using retriever agents) before generating informed responses.
169
+ - **Voice-Controlled Interfaces & Applications:** Utilize the `@voltagent/voice` package to create applications that respond to and generate spoken language.
170
+ - **Personalized User Experiences:** Develop agents that adapt responses and actions based on user history and preferences stored in memory.
171
+ - **Real-time Monitoring & Alerting:** Design agents that continuously monitor data streams or systems and trigger actions or notifications based on defined conditions.
172
+ - **And Virtually Anything Else...**: If you can imagine an AI agent doing it, VoltAgent can likely help you build it! ⚡
173
+
174
+ ## Learning VoltAgent
175
+
176
+ - **[Documentation](https://voltagent.dev/docs/)**: Dive into guides, concepts, and tutorials.
177
+ - **[Examples](https://github.com/voltagent/voltagent/tree/main/examples)**: Explore practical implementations.
178
+ - **[Blog](https://voltagent.dev/blog/)**: Read more about technical insights, and best practices.
33
179
 
34
- ### `initVoltAgent(options?: VoltAgentOptions)`
180
+ ## Contribution
35
181
 
36
- Initializes the VoltAgent framework.
182
+ We welcome contributions! Please refer to the contribution guidelines (link needed if available). Join our [Discord](https://s.voltagent.dev/discord) server for questions and discussions.
37
183
 
38
- ### `log(message: string, level?: LogLevel)`
184
+ ## Community ♥️ Thanks
39
185
 
40
- Logs a message with the VoltAgent prefix.
186
+ Your stars help us reach more developers! If you find VoltAgent useful, please consider giving us a star on GitHub to support the project and help others discover it.
41
187
 
42
188
  ## License
43
189
 
44
- MIT
190
+ Licensed under the MIT License, Copyright © 2025-present VoltAgent.
package/dist/index.d.ts CHANGED
@@ -1148,22 +1148,30 @@ type AgentHandoffOptions = {
1148
1148
  parentHistoryEntryId?: string;
1149
1149
  };
1150
1150
  /**
1151
- * Agent handoff result
1151
+ * Result of a handoff to another agent
1152
1152
  */
1153
- type AgentHandoffResult = {
1153
+ interface AgentHandoffResult {
1154
1154
  /**
1155
- * The result of the handoff operation
1155
+ * Result text from the agent
1156
1156
  */
1157
1157
  result: string;
1158
1158
  /**
1159
- * The conversation ID of the handoff
1159
+ * Conversation ID used for the interaction
1160
1160
  */
1161
1161
  conversationId: string;
1162
1162
  /**
1163
- * The messages exchanged during the handoff
1163
+ * Messages exchanged during the handoff
1164
1164
  */
1165
1165
  messages: BaseMessage[];
1166
- };
1166
+ /**
1167
+ * Status of the handoff operation
1168
+ */
1169
+ status?: "success" | "error";
1170
+ /**
1171
+ * Error information if the handoff failed
1172
+ */
1173
+ error?: Error | string;
1174
+ }
1167
1175
  /**
1168
1176
  * Operation context to isolate state for concurrent operations
1169
1177
  * Prevents race conditions when the same agent instance is used concurrently
@@ -1553,8 +1561,9 @@ declare class SubAgentManager {
1553
1561
  /**
1554
1562
  * Generate enhanced system message for supervisor role
1555
1563
  * @param baseDescription - The base description of the agent
1564
+ * @param agentsMemory - Optional string containing formatted memory from previous agent interactions
1556
1565
  */
1557
- generateSupervisorSystemMessage(baseDescription: string): string;
1566
+ generateSupervisorSystemMessage(baseDescription: string, agentsMemory?: string): string;
1558
1567
  /**
1559
1568
  * Check if the agent has sub-agents
1560
1569
  */
@@ -1841,10 +1850,16 @@ declare class Agent<TProvider extends {
1841
1850
  /**
1842
1851
  * Get the system message for the agent
1843
1852
  */
1844
- protected getSystemMessage({ input, historyEntryId, }: {
1853
+ protected getSystemMessage({ input, historyEntryId, contextMessages, }: {
1845
1854
  input?: string | BaseMessage[];
1846
1855
  historyEntryId: string;
1856
+ contextMessages: BaseMessage[];
1847
1857
  }): Promise<BaseMessage>;
1858
+ /**
1859
+ * Prepare agents memory for the supervisor system message
1860
+ * This fetches and formats recent interactions with sub-agents
1861
+ */
1862
+ private prepareAgentsMemory;
1848
1863
  /**
1849
1864
  * Add input to messages array based on type
1850
1865
  */
@@ -1911,7 +1926,7 @@ declare class Agent<TProvider extends {
1911
1926
  */
1912
1927
  private createStandardTimelineEvent;
1913
1928
  /**
1914
- * Tool event creator
1929
+ * Fix delete operator usage for better performance
1915
1930
  */
1916
1931
  private addToolEvent;
1917
1932
  /**
@@ -2039,7 +2054,7 @@ interface ToolCall {
2039
2054
  declare function zodSchemaToJsonUI(schema: any): any;
2040
2055
 
2041
2056
  /**
2042
- * Ajanlar, araçlar ve diğer bileşenler için node tipleri
2057
+ * Node types for agents, tools, and other components
2043
2058
  */
2044
2059
  declare enum NodeType {
2045
2060
  AGENT = "agent",
@@ -2051,17 +2066,17 @@ declare enum NodeType {
2051
2066
  RETRIEVER = "retriever"
2052
2067
  }
2053
2068
  /**
2054
- * Standart node ID oluşturma fonksiyonu
2055
- * @param type Node tipi
2056
- * @param name Ana tanımlayıcı (tool adı, agent adı vb.)
2057
- * @param ownerId Sahibinin ID'si (isteğe bağlı)
2058
- * @returns Standart formatlanmış node ID
2069
+ * Standard node ID creation function
2070
+ * @param type Node type
2071
+ * @param name Main identifier (tool name, agent name, etc.)
2072
+ * @param ownerId Owner ID (optional)
2073
+ * @returns Standard formatted node ID
2059
2074
  */
2060
2075
  declare const createNodeId: (type: NodeType, name: string, ownerId?: string) => string;
2061
2076
  /**
2062
- * NodeID'den node tipini çıkaran fonksiyon
2077
+ * Function to extract node type from NodeID
2063
2078
  * @param nodeId Node ID
2064
- * @returns NodeType veya null (tip bulunamazsa)
2079
+ * @returns NodeType or null (if type cannot be found)
2065
2080
  */
2066
2081
  declare const getNodeTypeFromNodeId: (nodeId: string) => NodeType | null;
2067
2082