@hashgraphonline/conversational-agent 0.2.103 → 0.2.105
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/README.md +64 -27
- package/cli/dist/CLIApp.d.ts +11 -0
- package/cli/dist/CLIApp.d.ts.map +1 -0
- package/cli/dist/CLIApp.js +128 -0
- package/cli/dist/CLIApp.js.map +1 -0
- package/cli/dist/LocalConversationalAgent.d.ts +37 -0
- package/cli/dist/LocalConversationalAgent.js +58 -0
- package/cli/dist/app.d.ts +18 -0
- package/cli/dist/app.d.ts.map +1 -0
- package/cli/dist/app.js +14 -0
- package/cli/dist/app.js.map +1 -0
- package/cli/dist/cli.d.ts +3 -0
- package/cli/dist/cli.d.ts.map +1 -0
- package/cli/dist/cli.js +87 -0
- package/cli/dist/cli.js.map +1 -0
- package/cli/dist/components/AppContainer.d.ts +16 -0
- package/cli/dist/components/AppContainer.js +24 -0
- package/cli/dist/components/AppScreens.d.ts +2 -0
- package/cli/dist/components/AppScreens.js +259 -0
- package/cli/dist/components/ChatScreen.d.ts +21 -0
- package/cli/dist/components/ChatScreen.d.ts.map +1 -0
- package/cli/dist/components/ChatScreen.js +40 -0
- package/cli/dist/components/ChatScreen.js.map +1 -0
- package/cli/dist/components/DebugLoadingScreen.d.ts +5 -0
- package/cli/dist/components/DebugLoadingScreen.js +31 -0
- package/cli/dist/components/LoadingScreen.d.ts +3 -0
- package/cli/dist/components/LoadingScreen.d.ts.map +1 -0
- package/cli/dist/components/LoadingScreen.js +17 -0
- package/cli/dist/components/LoadingScreen.js.map +1 -0
- package/cli/dist/components/LoadingScreenDebug.d.ts +5 -0
- package/cli/dist/components/LoadingScreenDebug.js +27 -0
- package/cli/dist/components/MCPConfigScreen.d.ts +28 -0
- package/cli/dist/components/MCPConfigScreen.d.ts.map +1 -0
- package/cli/dist/components/MCPConfigScreen.js +186 -0
- package/cli/dist/components/MCPConfigScreen.js.map +1 -0
- package/cli/dist/components/ScreenRouter.d.ts +13 -0
- package/cli/dist/components/ScreenRouter.d.ts.map +1 -0
- package/cli/dist/components/ScreenRouter.js +23 -0
- package/cli/dist/components/ScreenRouter.js.map +1 -0
- package/cli/dist/components/SetupScreen.d.ts +16 -0
- package/cli/dist/components/SetupScreen.d.ts.map +1 -0
- package/cli/dist/components/SetupScreen.js +67 -0
- package/cli/dist/components/SetupScreen.js.map +1 -0
- package/cli/dist/components/SingleLoadingScreen.d.ts +5 -0
- package/cli/dist/components/SingleLoadingScreen.js +27 -0
- package/cli/dist/components/StatusBadge.d.ts +10 -0
- package/cli/dist/components/StatusBadge.d.ts.map +1 -0
- package/cli/dist/components/StatusBadge.js +24 -0
- package/cli/dist/components/StatusBadge.js.map +1 -0
- package/cli/dist/components/TerminalWindow.d.ts +9 -0
- package/cli/dist/components/TerminalWindow.d.ts.map +1 -0
- package/cli/dist/components/TerminalWindow.js +19 -0
- package/cli/dist/components/TerminalWindow.js.map +1 -0
- package/cli/dist/components/WelcomeScreen.d.ts +12 -0
- package/cli/dist/components/WelcomeScreen.d.ts.map +1 -0
- package/cli/dist/components/WelcomeScreen.js +47 -0
- package/cli/dist/components/WelcomeScreen.js.map +1 -0
- package/cli/dist/context/AppContext.d.ts +68 -0
- package/cli/dist/context/AppContext.js +363 -0
- package/cli/dist/headless-runner.d.ts +17 -0
- package/cli/dist/headless-runner.d.ts.map +1 -0
- package/cli/dist/headless-runner.js +128 -0
- package/cli/dist/headless-runner.js.map +1 -0
- package/cli/dist/hooks/useInitializeAgent.d.ts +19 -0
- package/cli/dist/hooks/useInitializeAgent.d.ts.map +1 -0
- package/cli/dist/hooks/useInitializeAgent.js +29 -0
- package/cli/dist/hooks/useInitializeAgent.js.map +1 -0
- package/cli/dist/hooks/useStableState.d.ts +38 -0
- package/cli/dist/hooks/useStableState.d.ts.map +1 -0
- package/cli/dist/hooks/useStableState.js +69 -0
- package/cli/dist/hooks/useStableState.js.map +1 -0
- package/cli/dist/managers/AgentManager.d.ts +58 -0
- package/cli/dist/managers/AgentManager.d.ts.map +1 -0
- package/cli/dist/managers/AgentManager.js +121 -0
- package/cli/dist/managers/AgentManager.js.map +1 -0
- package/cli/dist/managers/ConfigManager.d.ts +54 -0
- package/cli/dist/managers/ConfigManager.d.ts.map +1 -0
- package/cli/dist/managers/ConfigManager.js +188 -0
- package/cli/dist/managers/ConfigManager.js.map +1 -0
- package/cli/dist/types.d.ts +52 -0
- package/cli/dist/types.d.ts.map +1 -0
- package/cli/dist/types.js +34 -0
- package/cli/dist/types.js.map +1 -0
- package/dist/cjs/config/system-message.d.ts +1 -1
- package/dist/cjs/conversational-agent.d.ts +30 -2
- package/dist/cjs/core/tool-registry.d.ts +29 -0
- package/dist/cjs/forms/field-guidance-registry.d.ts +33 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/mcp/types.d.ts +14 -3
- package/dist/cjs/plugins/index.d.ts +1 -0
- package/dist/cjs/plugins/inscribe/InscribePlugin.d.ts +1 -0
- package/dist/cjs/plugins/web-browser/WebBrowserPlugin.d.ts +14 -0
- package/dist/cjs/runtime/wallet-bridge.d.ts +26 -0
- package/dist/cjs/services/attachment-processor.d.ts +1 -2
- package/dist/cjs/services/content-store-manager.d.ts +1 -1
- package/dist/cjs/services/formatters/types.d.ts +3 -1
- package/dist/cjs/services/index.d.ts +1 -1
- package/dist/cjs/signers/browser-signer.d.ts +32 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index10.js +13 -5
- package/dist/esm/index10.js.map +1 -1
- package/dist/esm/index13.js +157 -179
- package/dist/esm/index13.js.map +1 -1
- package/dist/esm/index15.js +9 -4
- package/dist/esm/index15.js.map +1 -1
- package/dist/esm/index18.js.map +1 -1
- package/dist/esm/index2.js +25 -27
- package/dist/esm/index2.js.map +1 -1
- package/dist/esm/index21.js +1 -1
- package/dist/esm/index21.js.map +1 -1
- package/dist/esm/index23.js +3 -3
- package/dist/esm/index24.js.map +1 -1
- package/dist/esm/index26.js.map +1 -1
- package/dist/esm/index3.js.map +1 -1
- package/dist/esm/index30.js.map +1 -1
- package/dist/esm/index31.js +6 -3
- package/dist/esm/index31.js.map +1 -1
- package/dist/esm/index33.js +5 -5
- package/dist/esm/index33.js.map +1 -1
- package/dist/esm/index36.js +8 -45
- package/dist/esm/index36.js.map +1 -1
- package/dist/esm/index37.js +41 -102
- package/dist/esm/index37.js.map +1 -1
- package/dist/esm/index38.js +107 -21
- package/dist/esm/index38.js.map +1 -1
- package/dist/esm/index39.js +66 -12
- package/dist/esm/index39.js.map +1 -1
- package/dist/esm/index4.js +43 -0
- package/dist/esm/index4.js.map +1 -1
- package/dist/esm/index40.js +79 -7
- package/dist/esm/index40.js.map +1 -1
- package/dist/esm/index41.js +21 -5
- package/dist/esm/index41.js.map +1 -1
- package/dist/esm/index42.js +5 -255
- package/dist/esm/index42.js.map +1 -1
- package/dist/esm/index43.js +12 -184
- package/dist/esm/index43.js.map +1 -1
- package/dist/esm/index44.js +309 -79
- package/dist/esm/index44.js.map +1 -1
- package/dist/esm/index45.js +181 -24
- package/dist/esm/index45.js.map +1 -1
- package/dist/esm/index46.js +30 -0
- package/dist/esm/index46.js.map +1 -0
- package/dist/esm/index47.js +10 -0
- package/dist/esm/index47.js.map +1 -0
- package/dist/esm/index48.js +98 -0
- package/dist/esm/index48.js.map +1 -0
- package/dist/esm/index5.js +2 -2
- package/dist/esm/index6.js +231 -52
- package/dist/esm/index6.js.map +1 -1
- package/dist/types/config/system-message.d.ts +1 -1
- package/dist/types/conversational-agent.d.ts +30 -2
- package/dist/types/core/tool-registry.d.ts +29 -0
- package/dist/types/forms/field-guidance-registry.d.ts +33 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/mcp/types.d.ts +14 -3
- package/dist/types/plugins/index.d.ts +1 -0
- package/dist/types/plugins/inscribe/InscribePlugin.d.ts +1 -0
- package/dist/types/plugins/web-browser/WebBrowserPlugin.d.ts +14 -0
- package/dist/types/runtime/wallet-bridge.d.ts +26 -0
- package/dist/types/services/attachment-processor.d.ts +1 -2
- package/dist/types/services/content-store-manager.d.ts +1 -1
- package/dist/types/services/formatters/types.d.ts +3 -1
- package/dist/types/services/index.d.ts +1 -1
- package/dist/types/signers/browser-signer.d.ts +32 -0
- package/package.json +40 -37
- package/src/config/system-message.ts +3 -3
- package/src/conversational-agent.ts +356 -61
- package/src/core/tool-registry.ts +85 -0
- package/src/forms/field-guidance-registry.ts +213 -188
- package/src/forms/form-generator.ts +28 -12
- package/src/index.ts +1 -0
- package/src/langchain/form-aware-agent-executor.ts +6 -6
- package/src/langchain/langchain-agent.ts +1 -1
- package/src/mcp/mcp-client-manager.ts +12 -5
- package/src/mcp/types.ts +15 -3
- package/src/memory/content-storage.ts +19 -6
- package/src/memory/smart-memory-manager.ts +0 -1
- package/src/plugins/hbar/AccountBuilder.ts +16 -16
- package/src/plugins/hcs-10/HCS10Plugin.ts +38 -38
- package/src/plugins/hcs-2/HCS2Plugin.ts +2 -2
- package/src/plugins/index.ts +2 -1
- package/src/plugins/inscribe/InscribePlugin.ts +46 -2
- package/src/plugins/web-browser/WebBrowserPlugin.ts +128 -0
- package/src/runtime/wallet-bridge.ts +46 -0
- package/src/services/attachment-processor.ts +1 -1
- package/src/services/content-store-manager.ts +1 -1
- package/src/services/formatters/types.ts +3 -1
- package/src/services/index.ts +1 -1
- package/src/signers/browser-signer.ts +111 -0
- package/cli/readme.md +0 -181
package/README.md
CHANGED
|
@@ -133,7 +133,7 @@ When using `returnBytes` mode:
|
|
|
133
133
|
|
|
134
134
|
- **Automatic Key Detection**: Smart detection of ED25519 and ECDSA key types via mirror node
|
|
135
135
|
- **Multiple HCS Standards**: Built-in support for HCS-10, HCS-2, and inscription standards
|
|
136
|
-
- **
|
|
136
|
+
- **Core Plugin Suite**: HCS10Plugin, HCS2Plugin, InscribePlugin, and HbarPlugin
|
|
137
137
|
- **TypeScript Support**: Full type definitions for all components
|
|
138
138
|
- **State Management**: Integrated state management for agent operations
|
|
139
139
|
- **CLI Interface**: Beautiful terminal interface for interactive agent communication
|
|
@@ -188,16 +188,19 @@ The Conversational Agent includes all tools from the `hedera-agent-kit` v2 packa
|
|
|
188
188
|
This package includes a beautiful terminal interface built with [Ink](https://github.com/vadimdemedes/ink) that follows Hashgraph Consensus Standards design patterns.
|
|
189
189
|
|
|
190
190
|
```bash
|
|
191
|
-
# Run the interactive CLI
|
|
191
|
+
# Run the interactive CLI from the source workspace
|
|
192
192
|
pnpm cli
|
|
193
193
|
|
|
194
|
-
# Or with
|
|
194
|
+
# Or invoke the published binary with npx (no local build required)
|
|
195
|
+
npx @hashgraphonline/conversational-agent
|
|
196
|
+
|
|
197
|
+
# Provide credentials via environment variables (works for pnpm cli and npx)
|
|
195
198
|
export HEDERA_ACCOUNT_ID=0.0.12345
|
|
196
199
|
export HEDERA_PRIVATE_KEY=your-private-key
|
|
197
200
|
export OPENAI_API_KEY=sk-your-openai-key
|
|
198
201
|
pnpm cli
|
|
199
202
|
|
|
200
|
-
#
|
|
203
|
+
# Supply configuration through CLI flags
|
|
201
204
|
pnpm cli -- --account-id=0.0.12345 --private-key=... --openai-api-key=sk-...
|
|
202
205
|
```
|
|
203
206
|
|
|
@@ -210,13 +213,34 @@ pnpm cli -- --account-id=0.0.12345 --private-key=... --openai-api-key=sk-...
|
|
|
210
213
|
- 🚀 **Fast & Responsive** - Built with React for smooth interactions
|
|
211
214
|
- 📊 **Transaction Details** - See transaction IDs and network responses
|
|
212
215
|
|
|
216
|
+
### Headless Mode
|
|
217
|
+
|
|
218
|
+
Use the same executable to run a single command without the interactive UI. Headless mode activates automatically when you pass a command argument or when the CLI receives non-interactive input.
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
# Pass the command immediately after the binary
|
|
222
|
+
npx @hashgraphonline/conversational-agent "Register me as an AI agent named TestBot"
|
|
223
|
+
|
|
224
|
+
# Or use the explicit flag (useful when the command contains leading dashes)
|
|
225
|
+
npx @hashgraphonline/conversational-agent \
|
|
226
|
+
--account-id=0.0.12345 \
|
|
227
|
+
--private-key=... \
|
|
228
|
+
--openai-api-key=sk-... \
|
|
229
|
+
--command "Transfer 1 HBAR to 0.0.800"
|
|
230
|
+
|
|
231
|
+
# From the workspace helper script
|
|
232
|
+
pnpm cli -- --command "Find my pending connection requests"
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Headless execution prints structured output prefixed with the speaker (for example `[assistant]`, `[error]`, `[transaction]`) and returns a non-zero exit code when an error occurs. This makes it suitable for automation, CI tasks, or scripting flows that need machine-readable responses.
|
|
236
|
+
|
|
213
237
|
## Creating Custom Plugins
|
|
214
238
|
|
|
215
239
|
You can extend the conversational agent with custom plugins. Here's how to create one:
|
|
216
240
|
|
|
217
241
|
### Plugin Structure
|
|
218
242
|
|
|
219
|
-
See
|
|
243
|
+
See the [Conversational Agent documentation](https://hashgraphonline.com/docs/libraries/conversational-agent/) for detailed plugin development guidance.
|
|
220
244
|
|
|
221
245
|
```typescript
|
|
222
246
|
import {
|
|
@@ -320,28 +344,39 @@ const response = await agent.processMessage(
|
|
|
320
344
|
4. **State Management**: If your plugin needs state, consider implementing a custom state manager
|
|
321
345
|
5. **Documentation**: Provide clear descriptions for your plugin and tools
|
|
322
346
|
|
|
323
|
-
For more details, see
|
|
347
|
+
For more details, see the [Conversational Agent documentation](https://hashgraphonline.com/docs/libraries/conversational-agent/).
|
|
324
348
|
|
|
325
349
|
## Configuration Options
|
|
326
350
|
|
|
327
|
-
| Option
|
|
328
|
-
|
|
|
329
|
-
| `accountId`
|
|
330
|
-
| `privateKey`
|
|
331
|
-
| `network`
|
|
332
|
-
| `openAIApiKey`
|
|
333
|
-
| `openAIModelName`
|
|
334
|
-
| `
|
|
335
|
-
| `
|
|
336
|
-
| `
|
|
337
|
-
| `
|
|
338
|
-
| `
|
|
339
|
-
| `
|
|
340
|
-
| `
|
|
341
|
-
| `
|
|
342
|
-
| `
|
|
343
|
-
| `
|
|
344
|
-
| `
|
|
351
|
+
| Option | Type | Default | Description |
|
|
352
|
+
| --- | --- | --- | --- |
|
|
353
|
+
| `accountId` | string | **required** | Hedera account ID (e.g., `0.0.12345`) |
|
|
354
|
+
| `privateKey` | string | **required** | Private key for the account |
|
|
355
|
+
| `network` | `NetworkType` | `'testnet'` | Network to connect to (`'mainnet'`, `'testnet'`, or `'previewnet'`) |
|
|
356
|
+
| `openAIApiKey` | string | **required** | API key used for the default LLM provider and entity memory |
|
|
357
|
+
| `openAIModelName` | string | `'gpt-4o'` | Preferred OpenAI model when `llmProvider` is `openai` |
|
|
358
|
+
| `llmProvider` | `'openai' \| 'anthropic' \| 'openrouter'` | `'openai'` | Primary LLM provider for conversational responses |
|
|
359
|
+
| `verbose` | boolean | false | Enable verbose logging |
|
|
360
|
+
| `operationalMode` | `AgentOperationalMode` | `'autonomous'` | `'autonomous'` or `'returnBytes'` |
|
|
361
|
+
| `userAccountId` | string | undefined | Account ID applied to scheduled transactions in returnBytes mode |
|
|
362
|
+
| `customSystemMessagePreamble` | string | Hashgraph Online system prompt | Custom system message prefix |
|
|
363
|
+
| `customSystemMessagePostamble` | string | undefined | Custom system message suffix |
|
|
364
|
+
| `additionalPlugins` | `BasePlugin[]` | [] | Additional plugins to load |
|
|
365
|
+
| `stateManager` | `IStateManager` | `OpenConvaiState` | Custom state manager |
|
|
366
|
+
| `scheduleUserTransactionsInBytesMode` | boolean | false | Schedule transactions automatically in returnBytes mode |
|
|
367
|
+
| `mirrorNodeConfig` | `MirrorNodeConfig` | undefined | Custom mirror node configuration |
|
|
368
|
+
| `disableLogging` | boolean | false | Disable all logging |
|
|
369
|
+
| `enabledPlugins` | string[] | undefined | Filter which plugins to enable by ID |
|
|
370
|
+
| `toolFilter` | `(tool: { name: string; namespace?: string }) => boolean` | undefined | Predicate to include or exclude tools dynamically |
|
|
371
|
+
| `mcpServers` | `MCPServerConfig[]` | undefined | Configure MCP servers for Model Context Protocol support |
|
|
372
|
+
| `walletExecutor` | `(base64, network) => Promise<{ transactionId: string }>` | undefined | Custom executor for wallet-driven transaction submission |
|
|
373
|
+
| `customSignerFactory` | `(args) => AbstractSigner` | undefined | Override signer selection when initializing the agent |
|
|
374
|
+
| `entityMemoryEnabled` | boolean | true | Enable automatic entity extraction and storage |
|
|
375
|
+
| `entityMemoryConfig` | `SmartMemoryConfig` | undefined | Custom configuration for entity memory |
|
|
376
|
+
| `entityMemoryProvider` | `'openai' \| 'anthropic' \| 'openrouter'` | Matches `llmProvider` | Provider used for entity extraction and resolution |
|
|
377
|
+
| `entityMemoryModelName` | string | Provider-specific default | Override model used for entity memory operations |
|
|
378
|
+
| `openRouterApiKey` | string | undefined | API key when using OpenRouter (falls back to `openAIApiKey`) |
|
|
379
|
+
| `openRouterBaseURL` | string | `'https://openrouter.ai/api/v1'` | Base URL for OpenRouter requests |
|
|
345
380
|
|
|
346
381
|
## Environment Variables
|
|
347
382
|
|
|
@@ -369,6 +404,7 @@ await agent.initialize();
|
|
|
369
404
|
const hcs10Plugin = agent.hcs10Plugin;
|
|
370
405
|
const hcs2Plugin = agent.hcs2Plugin;
|
|
371
406
|
const inscribePlugin = agent.inscribePlugin;
|
|
407
|
+
const hbarPlugin = agent.hbarPlugin;
|
|
372
408
|
|
|
373
409
|
// Access the underlying Hedera agent
|
|
374
410
|
const hederaAgent = agent.getConversationalAgent();
|
|
@@ -421,6 +457,7 @@ const hcs2Agent = ConversationalAgent.withHCS2({
|
|
|
421
457
|
// ConversationalAgent.withSmartContract() - Only smart contract tools
|
|
422
458
|
// ConversationalAgent.withAllStandards() - All HCS standards plugins (HCS-10, HCS-2, Inscribe)
|
|
423
459
|
// ConversationalAgent.minimal() - Only basic account tools
|
|
460
|
+
// ConversationalAgent.withMCP(options, mcpServers) - Configure Model Context Protocol servers
|
|
424
461
|
```
|
|
425
462
|
|
|
426
463
|
### Plugin Filtering
|
|
@@ -441,7 +478,7 @@ const agent = new ConversationalAgent({
|
|
|
441
478
|
Available plugin IDs:
|
|
442
479
|
|
|
443
480
|
- Standard plugins: `hcs-10`, `hcs-2`, `inscribe`
|
|
444
|
-
- Core Hedera plugins: `hts-token`, `account`, `file-service`, `consensus-service`, `smart-contract`, `network`
|
|
481
|
+
- Core Hedera plugins: `hts-token`, `account`, `file-service`, `consensus-service`, `smart-contract`, `network`, `hbar`
|
|
445
482
|
|
|
446
483
|
### Legacy Plugin Usage (hedera-agent-kit 2.0.3 only)
|
|
447
484
|
|
|
@@ -490,7 +527,7 @@ If you've created a plugin that extends the Conversational Agent's capabilities,
|
|
|
490
527
|
|
|
491
528
|
2. **Create Your Plugin**
|
|
492
529
|
- Place your plugin in `src/plugins/community/[your-plugin-name]/`
|
|
493
|
-
- Follow the plugin structure outlined in the [
|
|
530
|
+
- Follow the plugin structure outlined in the [Conversational Agent documentation](https://hashgraphonline.com/docs/libraries/conversational-agent/)
|
|
494
531
|
- Include comprehensive tests in `src/plugins/community/[your-plugin-name]/__tests__/`
|
|
495
532
|
- Add documentation in `src/plugins/community/[your-plugin-name]/README.md`
|
|
496
533
|
|
|
@@ -545,7 +582,7 @@ src/plugins/community/your-plugin/
|
|
|
545
582
|
|
|
546
583
|
### Getting Help
|
|
547
584
|
|
|
548
|
-
- Join our [
|
|
585
|
+
- Join our [Telegram community](https://t.me/hashinals) for discussions
|
|
549
586
|
- Check existing issues and PRs before starting work
|
|
550
587
|
- Ask questions in the #development channel
|
|
551
588
|
- Review the [HCS Standards](https://hashgraphonline.com/docs/standards) for protocol details
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type Network } from './types';
|
|
3
|
+
interface Props {
|
|
4
|
+
accountId?: string;
|
|
5
|
+
privateKey?: string;
|
|
6
|
+
network?: Network;
|
|
7
|
+
openAIApiKey?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const CLIApp: React.FC<Props>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=CLIApp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CLIApp.d.ts","sourceRoot":"","sources":["../src/CLIApp.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAO5D,OAAO,EAA4B,KAAK,OAAO,EAAC,MAAM,SAAS,CAAC;AAEhE,UAAU,KAAK;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAiKlC,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import React, { useState, useMemo, useCallback } from 'react';
|
|
2
|
+
import { useApp } from 'ink';
|
|
3
|
+
import { ScreenRouter } from './components/ScreenRouter';
|
|
4
|
+
import { ConfigManager } from './managers/ConfigManager';
|
|
5
|
+
import { AgentManager } from './managers/AgentManager';
|
|
6
|
+
import { useStableState } from './hooks/useStableState';
|
|
7
|
+
import { useInitializeAgent } from './hooks/useInitializeAgent';
|
|
8
|
+
export const CLIApp = props => {
|
|
9
|
+
const { exit } = useApp();
|
|
10
|
+
const configManager = useMemo(() => ConfigManager.getInstance(), []);
|
|
11
|
+
const agentManager = useMemo(() => AgentManager.getInstance(), []);
|
|
12
|
+
const initialConfig = useMemo(() => configManager.getConfig(props), [
|
|
13
|
+
configManager,
|
|
14
|
+
props.accountId,
|
|
15
|
+
props.privateKey,
|
|
16
|
+
props.network,
|
|
17
|
+
props.openAIApiKey,
|
|
18
|
+
]);
|
|
19
|
+
const initialMcpServers = useMemo(() => configManager.getMCPServers(), [configManager]);
|
|
20
|
+
const { state, actions } = useStableState(initialMcpServers);
|
|
21
|
+
const [currentConfig, setCurrentConfig] = useState(initialConfig);
|
|
22
|
+
const initializeAgent = useInitializeAgent({
|
|
23
|
+
configManager,
|
|
24
|
+
agentManager,
|
|
25
|
+
actions,
|
|
26
|
+
});
|
|
27
|
+
const handleInitializeAgent = useCallback(() => {
|
|
28
|
+
initializeAgent(currentConfig, state.mcpConfig);
|
|
29
|
+
}, [initializeAgent, currentConfig, state.mcpConfig]);
|
|
30
|
+
const sendMessage = useCallback(async (message) => {
|
|
31
|
+
if (!message.trim())
|
|
32
|
+
return;
|
|
33
|
+
const userMessage = {
|
|
34
|
+
role: 'user',
|
|
35
|
+
content: message,
|
|
36
|
+
timestamp: new Date(),
|
|
37
|
+
};
|
|
38
|
+
actions.addMessages([userMessage]);
|
|
39
|
+
actions.setInput('');
|
|
40
|
+
actions.setLoading(true);
|
|
41
|
+
try {
|
|
42
|
+
const chatHistory = state.messages
|
|
43
|
+
.filter((m) => m.role !== 'system')
|
|
44
|
+
.map((m) => ({
|
|
45
|
+
type: m.role === 'user' ? 'human' : 'ai',
|
|
46
|
+
content: m.content,
|
|
47
|
+
}));
|
|
48
|
+
const response = await agentManager.sendMessage(message, chatHistory);
|
|
49
|
+
const assistantMessage = {
|
|
50
|
+
role: 'assistant',
|
|
51
|
+
content: response.message ||
|
|
52
|
+
response.output ||
|
|
53
|
+
response.error ||
|
|
54
|
+
'No response received',
|
|
55
|
+
timestamp: new Date(),
|
|
56
|
+
};
|
|
57
|
+
const newMessages = [assistantMessage];
|
|
58
|
+
if (response.transactionId) {
|
|
59
|
+
newMessages.push({
|
|
60
|
+
role: 'system',
|
|
61
|
+
content: `Transaction ID: ${response.transactionId}`,
|
|
62
|
+
timestamp: new Date(),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (response.scheduleId) {
|
|
66
|
+
newMessages.push({
|
|
67
|
+
role: 'system',
|
|
68
|
+
content: `Schedule ID: ${response.scheduleId}`,
|
|
69
|
+
timestamp: new Date(),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (response.notes && response.notes.length > 0) {
|
|
73
|
+
response.notes.forEach((note) => {
|
|
74
|
+
newMessages.push({
|
|
75
|
+
role: 'system',
|
|
76
|
+
content: note,
|
|
77
|
+
timestamp: new Date(),
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
actions.addMessages(newMessages);
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
actions.addMessages([
|
|
85
|
+
{
|
|
86
|
+
role: 'system',
|
|
87
|
+
content: `Error: ${err instanceof Error ? err.message : 'Unknown error'}`,
|
|
88
|
+
timestamp: new Date(),
|
|
89
|
+
},
|
|
90
|
+
]);
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
actions.setLoading(false);
|
|
94
|
+
}
|
|
95
|
+
}, [agentManager, state.messages, actions]);
|
|
96
|
+
const updateConfig = (field, value) => {
|
|
97
|
+
const updated = { ...currentConfig, [field]: value };
|
|
98
|
+
setCurrentConfig(updated);
|
|
99
|
+
};
|
|
100
|
+
const saveMCPConfig = () => {
|
|
101
|
+
const servers = [];
|
|
102
|
+
if (state.mcpConfig.enableFilesystem) {
|
|
103
|
+
const filesystemServer = {
|
|
104
|
+
name: 'filesystem',
|
|
105
|
+
command: 'npx',
|
|
106
|
+
args: [
|
|
107
|
+
'-y',
|
|
108
|
+
'@modelcontextprotocol/server-filesystem',
|
|
109
|
+
state.mcpConfig.filesystemPath,
|
|
110
|
+
],
|
|
111
|
+
transport: 'stdio',
|
|
112
|
+
autoConnect: true,
|
|
113
|
+
};
|
|
114
|
+
servers.push(filesystemServer);
|
|
115
|
+
}
|
|
116
|
+
servers.push(...state.mcpConfig.customServers);
|
|
117
|
+
configManager.saveMCPConfig(servers);
|
|
118
|
+
};
|
|
119
|
+
const stableHandlers = useMemo(() => ({
|
|
120
|
+
initializeAgent: handleInitializeAgent,
|
|
121
|
+
sendMessage,
|
|
122
|
+
updateConfig,
|
|
123
|
+
saveMCPConfig,
|
|
124
|
+
getMCPConfigPath: () => configManager.getMCPConfigPathForDisplay(),
|
|
125
|
+
}), [handleInitializeAgent, sendMessage]);
|
|
126
|
+
return (React.createElement(ScreenRouter, { state: state, currentConfig: currentConfig, actions: actions, stableHandlers: stableHandlers, exit: exit }));
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=CLIApp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CLIApp.js","sourceRoot":"","sources":["../src/CLIApp.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAC,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAC,MAAM,EAAC,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAC,kBAAkB,EAAC,MAAM,4BAA4B,CAAC;AAU9D,MAAM,CAAC,MAAM,MAAM,GAAoB,KAAK,CAAC,EAAE;IAC9C,MAAM,EAAC,IAAI,EAAC,GAAG,MAAM,EAAE,CAAC;IAExB,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;IACrE,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;IAEnE,MAAM,aAAa,GAAG,OAAO,CAC5B,GAAG,EAAE,CAAC,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,EACpC;QACC,aAAa;QACb,KAAK,CAAC,SAAS;QACf,KAAK,CAAC,UAAU;QAChB,KAAK,CAAC,OAAO;QACb,KAAK,CAAC,YAAY;KAClB,CACD,CAAC;IACF,MAAM,iBAAiB,GAAG,OAAO,CAChC,GAAG,EAAE,CAAC,aAAa,CAAC,aAAa,EAAE,EACnC,CA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,eAAe,EAAE,qBAAqB;QACtC,WAAW;QACX,YAAY;QACZ,aAAa;QACb,gBAAgB,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,0BAA0B,EAAE;KAClE,CAAC,EACF,CAAC,qBAAqB,EAAE,WAAW,CAAC,CACpC,CAAC;IAEF,OAAO,CACN,oBAAC,YAAY,IACZ,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,cAAc,EAC9B,IAAI,EAAE,IAAI,GACT,CACF,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal ConversationalAgent implementation for CLI use
|
|
3
|
+
* This avoids complex dependencies while providing the core functionality
|
|
4
|
+
*
|
|
5
|
+
* For local development, this allows the CLI to work without needing to publish
|
|
6
|
+
* the main package, while still providing a functional demo of the interface.
|
|
7
|
+
*/
|
|
8
|
+
export interface ConversationalAgentOptions {
|
|
9
|
+
accountId: string;
|
|
10
|
+
privateKey: string;
|
|
11
|
+
network: 'testnet' | 'mainnet';
|
|
12
|
+
openAIApiKey: string;
|
|
13
|
+
openAIModelName?: string;
|
|
14
|
+
plugins?: any[];
|
|
15
|
+
verbose?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface AgentResponse {
|
|
18
|
+
message?: string;
|
|
19
|
+
output?: string;
|
|
20
|
+
error?: string;
|
|
21
|
+
transactionId?: string;
|
|
22
|
+
scheduleId?: string;
|
|
23
|
+
notes?: string[];
|
|
24
|
+
}
|
|
25
|
+
export declare class ConversationalAgent {
|
|
26
|
+
private config;
|
|
27
|
+
private initialized;
|
|
28
|
+
constructor(config: ConversationalAgentOptions);
|
|
29
|
+
initialize(): Promise<void>;
|
|
30
|
+
processMessage(message: string, _chatHistory?: Array<{
|
|
31
|
+
type: 'human' | 'ai';
|
|
32
|
+
content: string;
|
|
33
|
+
}>): Promise<AgentResponse>;
|
|
34
|
+
}
|
|
35
|
+
export declare class OpenConvAIPlugin {
|
|
36
|
+
constructor();
|
|
37
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal ConversationalAgent implementation for CLI use
|
|
3
|
+
* This avoids complex dependencies while providing the core functionality
|
|
4
|
+
*
|
|
5
|
+
* For local development, this allows the CLI to work without needing to publish
|
|
6
|
+
* the main package, while still providing a functional demo of the interface.
|
|
7
|
+
*/
|
|
8
|
+
export class ConversationalAgent {
|
|
9
|
+
constructor(config) {
|
|
10
|
+
Object.defineProperty(this, "config", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
value: void 0
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(this, "initialized", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
value: false
|
|
21
|
+
});
|
|
22
|
+
this.config = config;
|
|
23
|
+
}
|
|
24
|
+
async initialize() {
|
|
25
|
+
if (!this.config.accountId || !this.config.privateKey || !this.config.openAIApiKey) {
|
|
26
|
+
throw new Error('Missing required configuration: accountId, privateKey, or openAIApiKey');
|
|
27
|
+
}
|
|
28
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
29
|
+
this.initialized = true;
|
|
30
|
+
}
|
|
31
|
+
async processMessage(message, _chatHistory) {
|
|
32
|
+
if (!this.initialized) {
|
|
33
|
+
throw new Error('Agent not initialized. Call initialize() first.');
|
|
34
|
+
}
|
|
35
|
+
const responses = [
|
|
36
|
+
"I'm a demo version of the Conversational Agent. In the full version, I would help you interact with the Hedera network.",
|
|
37
|
+
"This CLI demonstrates the interface for the Hashgraph Online Conversational Agent. Full functionality requires the complete implementation.",
|
|
38
|
+
"I understand you want to use Hedera network features. The production version would process this request using real network calls.",
|
|
39
|
+
"Demo mode: Your message has been received. The full agent would analyze this and execute appropriate Hedera operations.",
|
|
40
|
+
"This is a placeholder response. The actual Conversational Agent would provide real Hedera network functionality."
|
|
41
|
+
];
|
|
42
|
+
const randomResponse = responses[Math.floor(Math.random() * responses.length)];
|
|
43
|
+
return {
|
|
44
|
+
message: randomResponse,
|
|
45
|
+
output: `Demo response for: ${message}`,
|
|
46
|
+
notes: [
|
|
47
|
+
`Connected to ${this.config.network}`,
|
|
48
|
+
`Using account ${this.config.accountId}`,
|
|
49
|
+
`Model: ${this.config.openAIModelName || 'gpt-4o-mini'}`,
|
|
50
|
+
'Running in CLI demo mode'
|
|
51
|
+
]
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export class OpenConvAIPlugin {
|
|
56
|
+
constructor() {
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type Network } from './types';
|
|
3
|
+
type Props = {
|
|
4
|
+
accountId?: string;
|
|
5
|
+
privateKey?: string;
|
|
6
|
+
network?: Network;
|
|
7
|
+
openAIApiKey?: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Main App component for the Hashgraph Online Conversational Agent CLI
|
|
11
|
+
* @param accountId - Hedera account ID
|
|
12
|
+
* @param privateKey - Hedera private key
|
|
13
|
+
* @param network - Network to connect to (testnet or mainnet)
|
|
14
|
+
* @param openAIApiKey - OpenAI API key for the conversational agent
|
|
15
|
+
*/
|
|
16
|
+
export default function App({ accountId, privateKey, network, openAIApiKey, }: Props): React.JSX.Element;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,KAAK,OAAO,EAAC,MAAM,SAAS,CAAC;AAErC,KAAK,KAAK,GAAG;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAIF;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,GAAG,CAAC,EAC3B,SAAS,EACT,UAAU,EACV,OAAmB,EACnB,YAAY,GACZ,EAAE,KAAK,qBASP"}
|
package/cli/dist/app.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CLIApp } from './CLIApp';
|
|
3
|
+
process.setMaxListeners(20);
|
|
4
|
+
/**
|
|
5
|
+
* Main App component for the Hashgraph Online Conversational Agent CLI
|
|
6
|
+
* @param accountId - Hedera account ID
|
|
7
|
+
* @param privateKey - Hedera private key
|
|
8
|
+
* @param network - Network to connect to (testnet or mainnet)
|
|
9
|
+
* @param openAIApiKey - OpenAI API key for the conversational agent
|
|
10
|
+
*/
|
|
11
|
+
export default function App({ accountId, privateKey, network = 'testnet', openAIApiKey, }) {
|
|
12
|
+
return (React.createElement(CLIApp, { accountId: accountId, privateKey: privateKey, network: network, openAIApiKey: openAIApiKey }));
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAUhC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;AAE5B;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,GAAG,CAAC,EAC3B,SAAS,EACT,UAAU,EACV,OAAO,GAAG,SAAS,EACnB,YAAY,GACL;IACP,OAAO,CACN,oBAAC,MAAM,IACN,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,GACzB,CACF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.tsx"],"names":[],"mappings":""}
|
package/cli/dist/cli.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { render } from 'ink';
|
|
4
|
+
import meow from 'meow';
|
|
5
|
+
import App from './app';
|
|
6
|
+
import { runHeadless } from './headless-runner';
|
|
7
|
+
const cli = meow(`
|
|
8
|
+
Usage
|
|
9
|
+
$ conversational-agent
|
|
10
|
+
|
|
11
|
+
Options
|
|
12
|
+
--account-id Hedera account ID (e.g., 0.0.12345)
|
|
13
|
+
--private-key Private key for the account
|
|
14
|
+
--network Network to connect to (mainnet or testnet) [default: testnet]
|
|
15
|
+
--openai-api-key OpenAI API key for the LLM
|
|
16
|
+
--command Execute a single command in headless mode
|
|
17
|
+
|
|
18
|
+
Examples
|
|
19
|
+
$ conversational-agent
|
|
20
|
+
Interactive mode - will prompt for configuration
|
|
21
|
+
|
|
22
|
+
$ conversational-agent --account-id=0.0.12345 --private-key=... --openai-api-key=sk-...
|
|
23
|
+
Start with provided configuration
|
|
24
|
+
|
|
25
|
+
$ export HEDERA_ACCOUNT_ID=0.0.12345
|
|
26
|
+
$ export HEDERA_PRIVATE_KEY=...
|
|
27
|
+
$ export OPENAI_API_KEY=sk-...
|
|
28
|
+
$ conversational-agent
|
|
29
|
+
Uses environment variables for Hedera credentials
|
|
30
|
+
`, {
|
|
31
|
+
importMeta: import.meta,
|
|
32
|
+
flags: {
|
|
33
|
+
accountId: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
default: process.env['HEDERA_ACCOUNT_ID'] || '',
|
|
36
|
+
},
|
|
37
|
+
privateKey: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
default: process.env['HEDERA_PRIVATE_KEY'] || '',
|
|
40
|
+
},
|
|
41
|
+
network: {
|
|
42
|
+
type: 'string',
|
|
43
|
+
default: process.env['HEDERA_NETWORK'] || 'testnet',
|
|
44
|
+
choices: ['testnet', 'mainnet'],
|
|
45
|
+
},
|
|
46
|
+
openaiApiKey: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
default: process.env['OPENAI_API_KEY'] || '',
|
|
49
|
+
},
|
|
50
|
+
command: {
|
|
51
|
+
type: 'string',
|
|
52
|
+
default: '',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
const commandInput = (cli.flags.command || cli.input.join(' ')).trim();
|
|
57
|
+
const shouldRunHeadless = commandInput.length > 0 || !process.stdin.isTTY;
|
|
58
|
+
const parseNetwork = (value) => value === 'mainnet' ? 'mainnet' : 'testnet';
|
|
59
|
+
const selectedNetwork = parseNetwork(cli.flags.network);
|
|
60
|
+
if (shouldRunHeadless) {
|
|
61
|
+
(async () => {
|
|
62
|
+
try {
|
|
63
|
+
const result = await runHeadless({
|
|
64
|
+
accountId: cli.flags.accountId,
|
|
65
|
+
privateKey: cli.flags.privateKey,
|
|
66
|
+
network: selectedNetwork,
|
|
67
|
+
openAIApiKey: cli.flags.openaiApiKey,
|
|
68
|
+
command: commandInput,
|
|
69
|
+
});
|
|
70
|
+
if (result.stdout) {
|
|
71
|
+
const output = result.stdout.endsWith('\n') ? result.stdout : `${result.stdout}\n`;
|
|
72
|
+
process.stdout.write(output);
|
|
73
|
+
}
|
|
74
|
+
process.exit(result.exitCode);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
78
|
+
process.stderr.write(`${message}\n`);
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
})();
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const { waitUntilExit } = render(React.createElement(App, { accountId: cli.flags.accountId, privateKey: cli.flags.privateKey, network: selectedNetwork, openAIApiKey: cli.flags.openaiApiKey }));
|
|
85
|
+
waitUntilExit().then(() => process.exit(0));
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAC,MAAM,KAAK,CAAC;AAC3B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,GAAG,MAAM,OAAO,CAAC;AACxB,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAG9C,MAAM,GAAG,GAAG,IAAI,CACf;;;;;;;;;;;;;;;;;;;;;;;CAuBA,EACA;IACC,UAAU,EAAE,MAAM,CAAC,IAAI;IACvB,KAAK,EAAE;QACN,SAAS,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,EAAE;SAC/C;QACD,UAAU,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,EAAE;SAChD;QACD,OAAO,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,SAAS;YACnD,OAAO,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;SAC/B;QACD,YAAY,EAAE;YACb,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,EAAE;SAC5C;QACD,OAAO,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE;SACX;KACD;CACD,CACD,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GA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KAAK,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;YACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC;IACF,CAAC,CAAC,EAAE,CAAC;AACN,CAAC;KAAM,CAAC;IACP,MAAM,EAAC,aAAa,EAAC,GAAG,MAAM,CAC7B,oBAAC,GAAG,IACH,SAAS,EAAE,GAAG,CAAC,KAAK,CAAC,SAAS,EAC9B,UAAU,EAAE,GAAG,CAAC,KAAK,CAAC,UAAU,EAChC,OAAO,EAAE,eAAe,EACxB,YAAY,EAAE,GAAG,CAAC,KAAK,CAAC,YAAY,GACnC,CACF,CAAC;IAEF,aAAa,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type Config } from '../types.js';
|
|
3
|
+
import { type AppState } from '../hooks/useStableState.js';
|
|
4
|
+
interface Props {
|
|
5
|
+
state: AppState;
|
|
6
|
+
currentConfig: Config;
|
|
7
|
+
actions: any;
|
|
8
|
+
stableHandlers: any;
|
|
9
|
+
exit: () => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* App container that keeps all screens mounted but only displays one
|
|
13
|
+
* This prevents unmounting/remounting which causes double renders
|
|
14
|
+
*/
|
|
15
|
+
export declare const AppContainer: React.FC<Props>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box } from 'ink';
|
|
3
|
+
import { WelcomeScreen } from './WelcomeScreen.js';
|
|
4
|
+
import { ChatScreen } from './ChatScreen.js';
|
|
5
|
+
import { LoadingScreen } from './LoadingScreen.js';
|
|
6
|
+
import { SetupScreen } from './SetupScreen.js';
|
|
7
|
+
import { MCPConfigScreen } from './MCPConfigScreen.js';
|
|
8
|
+
/**
|
|
9
|
+
* App container that keeps all screens mounted but only displays one
|
|
10
|
+
* This prevents unmounting/remounting which causes double renders
|
|
11
|
+
*/
|
|
12
|
+
export const AppContainer = ({ state, currentConfig, actions, stableHandlers, exit, }) => {
|
|
13
|
+
return (React.createElement(React.Fragment, null,
|
|
14
|
+
React.createElement(Box, { display: state.screen === 'welcome' ? 'flex' : 'none' },
|
|
15
|
+
React.createElement(WelcomeScreen, { config: currentConfig, onExit: exit, onInitializeAgent: stableHandlers.initializeAgent, onSetScreen: actions.setScreen })),
|
|
16
|
+
React.createElement(Box, { display: state.screen === 'loading' ? 'flex' : 'none' },
|
|
17
|
+
React.createElement(LoadingScreen, null)),
|
|
18
|
+
React.createElement(Box, { display: state.screen === 'setup' ? 'flex' : 'none' },
|
|
19
|
+
React.createElement(SetupScreen, { config: currentConfig, currentField: state.currentField, error: state.error, onUpdateConfig: stableHandlers.updateConfig, onSetCurrentField: actions.setCurrentField, onInitializeAgent: stableHandlers.initializeAgent })),
|
|
20
|
+
React.createElement(Box, { display: state.screen === 'mcp-config' ? 'flex' : 'none' },
|
|
21
|
+
React.createElement(MCPConfigScreen, { mcpConfig: state.mcpConfig, editingFilesystemPath: state.editingFilesystemPath, onSetMcpConfig: actions.setMcpConfig, onSetEditingFilesystemPath: actions.setEditingFilesystemPath, onSetScreen: actions.setScreen, onSaveMCPConfig: stableHandlers.saveMCPConfig, getMCPConfigPath: stableHandlers.getMCPConfigPath })),
|
|
22
|
+
React.createElement(Box, { display: state.screen === 'chat' ? 'flex' : 'none' },
|
|
23
|
+
React.createElement(ChatScreen, { config: currentConfig, messages: state.messages, input: state.input, isLoading: state.isLoading, setInput: actions.setInput, sendMessage: stableHandlers.sendMessage, showLogs: false, logs: state.logs }))));
|
|
24
|
+
};
|