@hashgraphonline/conversational-agent 0.2.210 → 0.2.212
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/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/package.json +25 -33
- package/cli/readme.md +0 -181
|
@@ -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,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CAAC,CAAC;IAC3B,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,GAAG,EAAE;QAC1B,MAAM,OAAO,GAAG,EAAE,CAAC;QACnB,IAAI,KAAK,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC;YACtC,MAAM,gBAAgB,GAAG;gBACxB,IAAI,EAAE,YAAY;gBAClB,OAAO,EAAE,KAAK;gBACd,IAAI,EAAE;oBACL,IAAI;oBACJ,yCAAyC;oBACzC,KAAK,CAAC,SAAS,CAAC,cAAc;iBAC9B;gBACD,SAAS,EAAE,OAAgB;gBAC3B,WAAW,EAAE,IAAI;aACjB,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QAC/C,aAAa,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC,CAAC;IAEF,MAAM,cAAc,GAAG,OAAO,CAC7B,GAAG,EAAE,CAAC,CAAC;QACN,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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
|
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
|
+
};
|