@hashgraphonline/conversational-agent 0.1.209 → 0.1.211
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/bin/conversational-agent-cli.js +30 -0
- package/cli/readme.md +181 -0
- package/dist/cjs/base-agent.d.ts +3 -1
- package/dist/cjs/conversational-agent.d.ts +14 -22
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +5 -3
- package/dist/cjs/langchain-agent.d.ts +6 -3
- package/dist/cjs/memory/SmartMemoryManager.d.ts +7 -1
- package/dist/cjs/memory/TokenCounter.d.ts +1 -1
- package/dist/cjs/plugins/hbar/AirdropToolWrapper.d.ts +43 -0
- package/dist/{types/plugins/hbar-transfer/HbarTransferPlugin.d.ts → cjs/plugins/hbar/HbarPlugin.d.ts} +2 -1
- package/dist/{types/plugins/hbar-transfer → cjs/plugins/hbar}/TransferHbarTool.d.ts +1 -1
- package/dist/cjs/plugins/hbar/index.d.ts +3 -0
- package/dist/cjs/plugins/index.d.ts +2 -1
- package/dist/cjs/services/EntityResolver.d.ts +26 -0
- package/dist/cjs/tools/EntityResolverTool.d.ts +104 -0
- package/dist/cjs/types/inscription.d.ts +37 -0
- package/dist/esm/index.js +8 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index12.js +1 -4
- package/dist/esm/index12.js.map +1 -1
- package/dist/esm/index13.js +0 -1
- package/dist/esm/index13.js.map +1 -1
- package/dist/esm/index14.js +2 -7
- package/dist/esm/index14.js.map +1 -1
- package/dist/esm/index15.js +31 -69
- package/dist/esm/index15.js.map +1 -1
- package/dist/esm/index16.js +126 -39
- package/dist/esm/index16.js.map +1 -1
- package/dist/esm/index17.js +148 -13
- package/dist/esm/index17.js.map +1 -1
- package/dist/esm/index18.js +44 -146
- package/dist/esm/index18.js.map +1 -1
- package/dist/esm/index19.js +100 -6
- package/dist/esm/index19.js.map +1 -1
- package/dist/esm/index20.js +20 -174
- package/dist/esm/index20.js.map +1 -1
- package/dist/esm/index21.js +7 -151
- package/dist/esm/index21.js.map +1 -1
- package/dist/esm/index22.js +154 -45
- package/dist/esm/index22.js.map +1 -1
- package/dist/esm/index23.js +149 -24
- package/dist/esm/index23.js.map +1 -1
- package/dist/esm/index24.js +56 -83
- package/dist/esm/index24.js.map +1 -1
- package/dist/esm/index25.js +24 -236
- package/dist/esm/index25.js.map +1 -1
- package/dist/esm/index26.js +95 -0
- package/dist/esm/index26.js.map +1 -0
- package/dist/esm/index27.js +242 -0
- package/dist/esm/index27.js.map +1 -0
- package/dist/esm/index5.js +32 -19
- package/dist/esm/index5.js.map +1 -1
- package/dist/esm/index6.js +156 -195
- package/dist/esm/index6.js.map +1 -1
- package/dist/esm/index7.js +2 -2
- package/dist/esm/index7.js.map +1 -1
- package/dist/esm/index8.js +80 -48
- package/dist/esm/index8.js.map +1 -1
- package/dist/types/base-agent.d.ts +3 -1
- package/dist/types/conversational-agent.d.ts +14 -22
- package/dist/types/index.d.ts +5 -3
- package/dist/types/langchain-agent.d.ts +6 -3
- package/dist/types/memory/SmartMemoryManager.d.ts +7 -1
- package/dist/types/memory/TokenCounter.d.ts +1 -1
- package/dist/types/plugins/hbar/AirdropToolWrapper.d.ts +43 -0
- package/dist/{cjs/plugins/hbar-transfer/HbarTransferPlugin.d.ts → types/plugins/hbar/HbarPlugin.d.ts} +2 -1
- package/dist/{cjs/plugins/hbar-transfer → types/plugins/hbar}/TransferHbarTool.d.ts +1 -1
- package/dist/types/plugins/hbar/index.d.ts +3 -0
- package/dist/types/plugins/index.d.ts +2 -1
- package/dist/types/services/EntityResolver.d.ts +26 -0
- package/dist/types/tools/EntityResolverTool.d.ts +104 -0
- package/dist/types/types/inscription.d.ts +37 -0
- package/package.json +13 -4
- package/src/base-agent.ts +14 -9
- package/src/config/system-message.ts +11 -2
- package/src/context/ReferenceContextManager.ts +1 -1
- package/src/conversational-agent.ts +221 -254
- package/src/index.ts +17 -3
- package/src/langchain-agent.ts +130 -78
- package/src/mcp/ContentProcessor.ts +0 -2
- package/src/mcp/adapters/langchain.ts +0 -1
- package/src/memory/ContentStorage.ts +0 -5
- package/src/memory/MemoryWindow.ts +0 -1
- package/src/memory/ReferenceIdGenerator.ts +4 -4
- package/src/memory/SmartMemoryManager.ts +53 -92
- package/src/memory/TokenCounter.ts +4 -7
- package/src/plugins/hbar/AirdropToolWrapper.ts +157 -0
- package/src/plugins/hbar/HbarPlugin.ts +86 -0
- package/src/plugins/{hbar-transfer → hbar}/TransferHbarTool.ts +3 -3
- package/src/plugins/hbar/index.ts +3 -0
- package/src/plugins/index.ts +2 -1
- package/src/services/EntityResolver.ts +135 -0
- package/src/tools/EntityResolverTool.ts +170 -0
- package/src/types/inscription.ts +40 -0
- package/dist/cjs/plugins/hbar-transfer/index.d.ts +0 -1
- package/dist/types/plugins/hbar-transfer/index.d.ts +0 -1
- package/src/plugins/hbar-transfer/HbarTransferPlugin.ts +0 -66
- package/src/plugins/hbar-transfer/index.ts +0 -1
- /package/dist/cjs/plugins/{hbar-transfer → hbar}/AccountBuilder.d.ts +0 -0
- /package/dist/cjs/plugins/{hbar-transfer → hbar}/types.d.ts +0 -0
- /package/dist/types/plugins/{hbar-transfer → hbar}/AccountBuilder.d.ts +0 -0
- /package/dist/types/plugins/{hbar-transfer → hbar}/types.d.ts +0 -0
- /package/src/plugins/{hbar-transfer → hbar}/AccountBuilder.ts +0 -0
- /package/src/plugins/{hbar-transfer → hbar}/types.ts +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CLI executable for Conversational Agent
|
|
5
|
+
* This file enables running the CLI via npx
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { spawn } from 'child_process';
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
import { dirname, join } from 'path';
|
|
11
|
+
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = dirname(__filename);
|
|
14
|
+
|
|
15
|
+
// Run the actual CLI from the cli directory
|
|
16
|
+
const cliPath = join(__dirname, '..', 'cli', 'dist', 'cli.js');
|
|
17
|
+
|
|
18
|
+
const child = spawn('node', [cliPath, ...process.argv.slice(2)], {
|
|
19
|
+
stdio: 'inherit',
|
|
20
|
+
shell: false
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
child.on('exit', (code) => {
|
|
24
|
+
process.exit(code || 0);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
child.on('error', (err) => {
|
|
28
|
+
console.error('Failed to start CLI:', err);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
});
|
package/cli/readme.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Hedera Conversational Agent CLI
|
|
2
|
+
|
|
3
|
+
A beautiful command-line interface for the Hedera Conversational Agent, built with [Ink](https://github.com/vadimdemedes/ink) and styled following Hashgraph Online design patterns.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🎨 **Beautiful Terminal UI** - Styled with HCS improvement proposals design patterns
|
|
8
|
+
- 💬 **Interactive Chat** - Chat with your Hedera agent in a clean terminal interface
|
|
9
|
+
- 🔐 **Secure Configuration** - Masked input for sensitive credentials
|
|
10
|
+
- 🌈 **Gradient Text & Colors** - Brand-consistent color scheme
|
|
11
|
+
- 🚀 **Fast & Responsive** - Built with React for smooth interactions
|
|
12
|
+
- 📊 **Transaction Details** - See transaction IDs and network responses
|
|
13
|
+
- 🎯 **HCS-10 Support** - Full support for agent connections and messaging
|
|
14
|
+
- 🔧 **MCP Integration** - Configure Model Context Protocol servers for extended capabilities
|
|
15
|
+
- 📁 **File Operations** - Built-in filesystem MCP server for file management
|
|
16
|
+
- ⚙️ **Custom MCP Servers** - Add your own MCP servers for specialized tools
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
For local development, the CLI uses the actual ConversationalAgent from the parent package:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# 1. Build the parent package first
|
|
24
|
+
cd /path/to/conversational-agent
|
|
25
|
+
pnpm install
|
|
26
|
+
pnpm build
|
|
27
|
+
|
|
28
|
+
# 2. The CLI will be built automatically via postinstall hook
|
|
29
|
+
# Or build manually:
|
|
30
|
+
cd cli
|
|
31
|
+
pnpm install
|
|
32
|
+
pnpm build
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
### Interactive Mode (Recommended)
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# From the parent conversational-agent directory
|
|
41
|
+
pnpm cli
|
|
42
|
+
|
|
43
|
+
# This automatically builds if needed and runs the CLI
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### With Command Line Arguments
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
conversational-agent \
|
|
50
|
+
--account-id=0.0.12345 \
|
|
51
|
+
--private-key=your-private-key \
|
|
52
|
+
--network=testnet \
|
|
53
|
+
--openai-api-key=sk-...
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Using Environment Variables
|
|
57
|
+
|
|
58
|
+
The CLI automatically loads configuration from `.env` in the conversational-agent root:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# .env file in conversational-agent directory
|
|
62
|
+
HEDERA_ACCOUNT_ID=0.0.12345
|
|
63
|
+
HEDERA_PRIVATE_KEY=your-private-key
|
|
64
|
+
HEDERA_NETWORK=testnet
|
|
65
|
+
OPENAI_API_KEY=sk-...
|
|
66
|
+
MCP_SERVERS=[{"name":"filesystem","command":"npx","args":["-y","@modelcontextprotocol/server-filesystem","/tmp"]}]
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Then simply run: `pnpm cli`
|
|
70
|
+
|
|
71
|
+
## Interface Overview
|
|
72
|
+
|
|
73
|
+
### Welcome Screen
|
|
74
|
+
- Beautiful ASCII art logo with gradient colors
|
|
75
|
+
- Simple menu navigation with arrow keys
|
|
76
|
+
- Options: Start Chat, Configure, MCP Servers, Exit
|
|
77
|
+
|
|
78
|
+
### Configuration Screen
|
|
79
|
+
- Terminal-style window with macOS-like controls
|
|
80
|
+
- Secure input masking for sensitive data
|
|
81
|
+
- Tab navigation between fields
|
|
82
|
+
- Real-time validation
|
|
83
|
+
|
|
84
|
+
### MCP Servers Screen
|
|
85
|
+
- Configure Model Context Protocol servers
|
|
86
|
+
- Enable/disable filesystem server with custom path
|
|
87
|
+
- Add custom MCP servers with command and arguments
|
|
88
|
+
- Live preview of available tools
|
|
89
|
+
- Save configuration to environment
|
|
90
|
+
|
|
91
|
+
### Chat Interface
|
|
92
|
+
- Clean terminal aesthetic with prompt symbols
|
|
93
|
+
- Color-coded messages (user, assistant, system)
|
|
94
|
+
- Loading indicators with spinners
|
|
95
|
+
- Transaction ID display
|
|
96
|
+
- MCP server status and available tools
|
|
97
|
+
- Escape key to return to menu
|
|
98
|
+
|
|
99
|
+
## Design Features
|
|
100
|
+
|
|
101
|
+
The CLI follows Hashgraph Online's design system:
|
|
102
|
+
|
|
103
|
+
- **Brand Colors**: Primary blue (#5599fe), Green (#48df7b), Purple (#b56cff)
|
|
104
|
+
- **Hedera Colors**: Purple (#8259ef), Blue (#2d84eb), Green (#3ec878)
|
|
105
|
+
- **Terminal Window**: Rounded borders with window control dots
|
|
106
|
+
- **Status Badges**: Color-coded status indicators
|
|
107
|
+
- **Typography**: Monospace throughout with clear hierarchy
|
|
108
|
+
|
|
109
|
+
## Keyboard Shortcuts
|
|
110
|
+
|
|
111
|
+
- `↑/↓` - Navigate menus
|
|
112
|
+
- `Enter` - Select/Submit
|
|
113
|
+
- `Tab` - Next field (in configuration)
|
|
114
|
+
- `Escape` - Return to main menu (from chat)
|
|
115
|
+
- `Ctrl+C` - Exit application
|
|
116
|
+
|
|
117
|
+
## Development
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# Watch mode for development
|
|
121
|
+
pnpm dev
|
|
122
|
+
|
|
123
|
+
# Run tests
|
|
124
|
+
pnpm test
|
|
125
|
+
|
|
126
|
+
# Build for production
|
|
127
|
+
pnpm build
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Examples
|
|
131
|
+
|
|
132
|
+
### Basic Chat Interaction
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
$ Find all AI agents on the network
|
|
136
|
+
→ I'll search for AI agents registered on the Hedera network...
|
|
137
|
+
|
|
138
|
+
[INFO] Found 5 agents with AI capabilities
|
|
139
|
+
→ Here are the AI agents I found:
|
|
140
|
+
1. Agent: 0.0.12345 - "GPT Assistant"
|
|
141
|
+
2. Agent: 0.0.23456 - "Code Helper"
|
|
142
|
+
...
|
|
143
|
+
|
|
144
|
+
$ Connect to agent 0.0.12345
|
|
145
|
+
→ Initiating connection to agent 0.0.12345...
|
|
146
|
+
[INFO] Transaction ID: 0.0.98765@1234567890.123
|
|
147
|
+
→ Successfully connected! You can now send messages to this agent.
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### MCP File Operations
|
|
151
|
+
|
|
152
|
+
With filesystem MCP server enabled:
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
$ Create a new file called notes.txt with my meeting notes
|
|
156
|
+
→ I'll create a notes.txt file for you with meeting notes...
|
|
157
|
+
|
|
158
|
+
[INFO] MCP servers enabled: filesystem
|
|
159
|
+
→ I've created notes.txt in your configured directory with the meeting notes.
|
|
160
|
+
|
|
161
|
+
$ List all files in the current directory
|
|
162
|
+
→ Here are the files in /tmp:
|
|
163
|
+
- notes.txt (created just now)
|
|
164
|
+
- data.json
|
|
165
|
+
- config.yaml
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Custom MCP Server
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
$ Add GitHub repository operations
|
|
172
|
+
→ I can help you interact with GitHub repositories...
|
|
173
|
+
|
|
174
|
+
[INFO] MCP servers enabled: filesystem, github
|
|
175
|
+
→ I now have access to GitHub operations. I can help you create issues,
|
|
176
|
+
manage repositories, and work with pull requests.
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## License
|
|
180
|
+
|
|
181
|
+
Apache-2.0
|
package/dist/cjs/base-agent.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { TransactionReceipt } from '@hashgraph/sdk';
|
|
|
4
4
|
import { HederaAgentKit, ServerSigner, TokenUsageCallbackHandler, TokenUsage, BasePlugin, CostCalculation } from 'hedera-agent-kit';
|
|
5
5
|
import { AIProvider, VercelAIProvider, BAMLProvider } from './providers';
|
|
6
6
|
import { Logger } from '@hashgraphonline/standards-sdk';
|
|
7
|
-
import { MCPServerConfig } from './mcp/types';
|
|
7
|
+
import { MCPServerConfig, MCPConnectionStatus } from './mcp/types';
|
|
8
8
|
|
|
9
9
|
export interface ToolFilterConfig {
|
|
10
10
|
namespaceWhitelist?: string[];
|
|
@@ -93,6 +93,8 @@ export declare abstract class BaseAgent {
|
|
|
93
93
|
abstract getUsageStats(): UsageStats;
|
|
94
94
|
abstract getUsageLog(): UsageStats[];
|
|
95
95
|
abstract clearUsageStats(): void;
|
|
96
|
+
abstract connectMCPServers(): Promise<void>;
|
|
97
|
+
abstract getMCPConnectionStatus(): Map<string, MCPConnectionStatus>;
|
|
96
98
|
getCore(): HederaAgentKit | undefined;
|
|
97
99
|
protected filterTools(tools: StructuredTool[]): StructuredTool[];
|
|
98
100
|
protected buildSystemPrompt(): string;
|
|
@@ -5,10 +5,11 @@ import { ChatResponse } from './base-agent';
|
|
|
5
5
|
import { HCS10Plugin } from './plugins/hcs-10/HCS10Plugin';
|
|
6
6
|
import { HCS2Plugin } from './plugins/hcs-2/HCS2Plugin';
|
|
7
7
|
import { InscribePlugin } from './plugins/inscribe/InscribePlugin';
|
|
8
|
-
import {
|
|
8
|
+
import { HbarPlugin } from './plugins/hbar/HbarPlugin';
|
|
9
9
|
import { IStateManager } from '@hashgraphonline/standards-agent-kit';
|
|
10
10
|
import { MCPServerConfig, MCPConnectionStatus } from './mcp/types';
|
|
11
|
-
import {
|
|
11
|
+
import { ContentStoreManager } from './services/ContentStoreManager';
|
|
12
|
+
import { SmartMemoryManager, SmartMemoryConfig } from './memory';
|
|
12
13
|
|
|
13
14
|
export type ToolDescriptor = {
|
|
14
15
|
name: string;
|
|
@@ -26,6 +27,7 @@ export interface ConversationalAgentOptions {
|
|
|
26
27
|
network?: NetworkType;
|
|
27
28
|
openAIApiKey: string;
|
|
28
29
|
openAIModelName?: string;
|
|
30
|
+
llmProvider?: 'openai' | 'anthropic';
|
|
29
31
|
verbose?: boolean;
|
|
30
32
|
operationalMode?: AgentOperationalMode;
|
|
31
33
|
userAccountId?: string;
|
|
@@ -61,16 +63,16 @@ export declare class ConversationalAgent {
|
|
|
61
63
|
hcs10Plugin: HCS10Plugin;
|
|
62
64
|
hcs2Plugin: HCS2Plugin;
|
|
63
65
|
inscribePlugin: InscribePlugin;
|
|
64
|
-
|
|
66
|
+
hbarPlugin: HbarPlugin;
|
|
65
67
|
stateManager: IStateManager;
|
|
66
68
|
private options;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
private
|
|
69
|
+
logger: Logger;
|
|
70
|
+
contentStoreManager?: ContentStoreManager;
|
|
71
|
+
memoryManager?: SmartMemoryManager | undefined;
|
|
72
|
+
private entityTools?;
|
|
71
73
|
constructor(options: ConversationalAgentOptions);
|
|
72
74
|
/**
|
|
73
|
-
* Initialize the conversational agent with Hedera
|
|
75
|
+
* Initialize the conversational agent with Hedera Hashgraph connection and AI configuration
|
|
74
76
|
* @throws {Error} If account ID or private key is missing
|
|
75
77
|
* @throws {Error} If initialization fails
|
|
76
78
|
*/
|
|
@@ -186,18 +188,18 @@ export declare class ConversationalAgent {
|
|
|
186
188
|
* Detect the private key type by querying the account info from mirror node
|
|
187
189
|
* @param {string} accountId - The Hedera account ID
|
|
188
190
|
* @param {string} privateKey - The private key string
|
|
189
|
-
* @param {NetworkType} network - The Hedera
|
|
191
|
+
* @param {NetworkType} network - The Hedera Hashgraph
|
|
190
192
|
* @returns {Promise<PrivateKey>} The appropriate PrivateKey instance
|
|
191
193
|
*/
|
|
192
194
|
private detectPrivateKeyType;
|
|
193
195
|
/**
|
|
194
|
-
* Resolve entity references
|
|
196
|
+
* Resolve entity references using LLM-based resolver
|
|
195
197
|
* @param content - Message content to resolve
|
|
196
198
|
* @returns Resolved message content with entity IDs replaced
|
|
197
199
|
*/
|
|
198
200
|
private resolveEntitiesInMessage;
|
|
199
201
|
/**
|
|
200
|
-
* Extract and store
|
|
202
|
+
* Extract and store entities from agent responses
|
|
201
203
|
* @param response - Agent response containing potential entity information
|
|
202
204
|
* @param originalMessage - Original user message for context
|
|
203
205
|
*/
|
|
@@ -213,17 +215,6 @@ export declare class ConversationalAgent {
|
|
|
213
215
|
* @private
|
|
214
216
|
*/
|
|
215
217
|
private connectMCP;
|
|
216
|
-
/**
|
|
217
|
-
* Start MCP connections without blocking initialization
|
|
218
|
-
* @private
|
|
219
|
-
*/
|
|
220
|
-
private startConnections;
|
|
221
|
-
/**
|
|
222
|
-
* Connect to a single MCP server
|
|
223
|
-
* @param {MCPServerConfig} server - Server configuration
|
|
224
|
-
* @private
|
|
225
|
-
*/
|
|
226
|
-
private connectServer;
|
|
227
218
|
/**
|
|
228
219
|
* Get MCP connection status for all servers
|
|
229
220
|
* @returns {Map<string, MCPConnectionStatus>} Connection status map
|
|
@@ -239,4 +230,5 @@ export declare class ConversationalAgent {
|
|
|
239
230
|
* Clean up resources
|
|
240
231
|
*/
|
|
241
232
|
cleanup(): Promise<void>;
|
|
233
|
+
private extractResponseText;
|
|
242
234
|
}
|