@hashgraphonline/conversational-agent 0.2.211 → 0.2.213
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/dist/esm/index10.js +1 -1
- package/dist/esm/index21.js +1 -1
- package/dist/esm/index23.js +1 -1
- package/dist/esm/index33.js +4 -4
- package/dist/esm/index42.js +26 -4
- package/dist/esm/index42.js.map +1 -1
- package/dist/esm/index43.js +4 -11
- package/dist/esm/index43.js.map +1 -1
- package/dist/esm/index44.js +12 -322
- package/dist/esm/index44.js.map +1 -1
- package/dist/esm/index45.js +280 -142
- package/dist/esm/index45.js.map +1 -1
- package/dist/esm/index46.js +181 -24
- package/dist/esm/index46.js.map +1 -1
- package/package.json +25 -33
- package/cli/readme.md +0 -181
package/dist/esm/index46.js
CHANGED
|
@@ -1,30 +1,187 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
storageBackend: "memory",
|
|
10
|
-
cleanupPolicies: {
|
|
11
|
-
recent: { maxAgeMs: 30 * 60 * 1e3, priority: 1 },
|
|
12
|
-
userContent: { maxAgeMs: 2 * 60 * 60 * 1e3, priority: 2 },
|
|
13
|
-
agentGenerated: { maxAgeMs: 60 * 60 * 1e3, priority: 3 },
|
|
14
|
-
default: { maxAgeMs: 60 * 60 * 1e3, priority: 4 }
|
|
1
|
+
import { ZodError } from "zod";
|
|
2
|
+
import { Logger } from "@hashgraphonline/standards-sdk";
|
|
3
|
+
class ExecutionPipeline {
|
|
4
|
+
constructor(toolRegistry, formEngine, memory, logger) {
|
|
5
|
+
this.toolRegistry = toolRegistry;
|
|
6
|
+
this.formEngine = formEngine;
|
|
7
|
+
this.memory = memory;
|
|
8
|
+
this.logger = logger || new Logger({ module: "ExecutionPipeline" });
|
|
15
9
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Execute a tool through the pipeline
|
|
12
|
+
*/
|
|
13
|
+
async execute(toolName, input, sessionContext) {
|
|
14
|
+
const traceId = `trace-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
15
|
+
const startTime = Date.now();
|
|
16
|
+
const toolEntry = this.toolRegistry.getTool(toolName);
|
|
17
|
+
if (!toolEntry) {
|
|
18
|
+
throw new Error(`Tool not found in registry: ${toolName}`);
|
|
19
|
+
}
|
|
20
|
+
const context = {
|
|
21
|
+
toolName,
|
|
22
|
+
input,
|
|
23
|
+
session: sessionContext || this.buildDefaultSession(),
|
|
24
|
+
memory: this.memory,
|
|
25
|
+
traceId,
|
|
26
|
+
toolEntry
|
|
27
|
+
};
|
|
28
|
+
try {
|
|
29
|
+
const shouldGenerateForm = await this.checkFormGeneration(context);
|
|
30
|
+
if (shouldGenerateForm.requiresForm && shouldGenerateForm.formMessage) {
|
|
31
|
+
return {
|
|
32
|
+
success: false,
|
|
33
|
+
output: "Form generation required",
|
|
34
|
+
requiresForm: true,
|
|
35
|
+
formMessage: shouldGenerateForm.formMessage,
|
|
36
|
+
traceId,
|
|
37
|
+
executionTime: Date.now() - startTime
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const result = await this.executeToolDirect(context);
|
|
41
|
+
return {
|
|
42
|
+
success: true,
|
|
43
|
+
output: result,
|
|
44
|
+
traceId,
|
|
45
|
+
executionTime: Date.now() - startTime
|
|
46
|
+
};
|
|
47
|
+
} catch (error) {
|
|
48
|
+
return this.handleExecutionError(
|
|
49
|
+
error,
|
|
50
|
+
context,
|
|
51
|
+
traceId,
|
|
52
|
+
Date.now() - startTime
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Execute tool with validation
|
|
58
|
+
*/
|
|
59
|
+
async executeWithValidation(toolName, input, sessionContext) {
|
|
60
|
+
return this.execute(toolName, input, sessionContext);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Process form submission
|
|
64
|
+
*/
|
|
65
|
+
async processFormSubmission(toolName, formId, parameters, sessionContext) {
|
|
66
|
+
const traceId = `form-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
67
|
+
const startTime = Date.now();
|
|
68
|
+
try {
|
|
69
|
+
const formSubmission = {
|
|
70
|
+
formId,
|
|
71
|
+
toolName,
|
|
72
|
+
parameters,
|
|
73
|
+
timestamp: Date.now()
|
|
74
|
+
};
|
|
75
|
+
const processedInput = await this.formEngine.processSubmission(
|
|
76
|
+
formSubmission
|
|
77
|
+
);
|
|
78
|
+
return this.execute(toolName, processedInput, sessionContext);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
return {
|
|
81
|
+
success: false,
|
|
82
|
+
output: "Form submission processing failed",
|
|
83
|
+
error: error instanceof Error ? error.message : String(error),
|
|
84
|
+
traceId,
|
|
85
|
+
executionTime: Date.now() - startTime
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Check if form generation is required
|
|
91
|
+
*/
|
|
92
|
+
async checkFormGeneration(context) {
|
|
93
|
+
const inputRecord = context.input;
|
|
94
|
+
if (inputRecord?.__fromForm === true || inputRecord?.renderForm === false) {
|
|
95
|
+
return { requiresForm: false };
|
|
96
|
+
}
|
|
97
|
+
if (!this.formEngine.shouldGenerateForm(context.toolEntry.tool, context.input)) {
|
|
98
|
+
return { requiresForm: false };
|
|
99
|
+
}
|
|
100
|
+
const formMessage = await this.formEngine.generateForm(
|
|
101
|
+
context.toolName,
|
|
102
|
+
context.toolEntry.tool,
|
|
103
|
+
context.input
|
|
104
|
+
);
|
|
105
|
+
if (formMessage) {
|
|
106
|
+
return { requiresForm: true, formMessage };
|
|
107
|
+
}
|
|
108
|
+
return { requiresForm: false };
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Execute tool directly
|
|
112
|
+
*/
|
|
113
|
+
async executeToolDirect(context) {
|
|
114
|
+
const { toolEntry, input } = context;
|
|
115
|
+
const parameters = input || {};
|
|
116
|
+
const mergedArgs = { ...parameters, renderForm: false };
|
|
117
|
+
if (toolEntry.wrapper) {
|
|
118
|
+
return this.executeWrappedTool(toolEntry, mergedArgs);
|
|
119
|
+
}
|
|
120
|
+
return await toolEntry.tool.call(mergedArgs);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Execute wrapped tool
|
|
124
|
+
*/
|
|
125
|
+
async executeWrappedTool(toolEntry, mergedArgs) {
|
|
126
|
+
const wrapper = toolEntry.wrapper;
|
|
127
|
+
if (!wrapper) {
|
|
128
|
+
throw new Error("Tool wrapper not found");
|
|
129
|
+
}
|
|
130
|
+
const wrapperAsAny = wrapper;
|
|
131
|
+
if (wrapperAsAny.executeOriginal) {
|
|
132
|
+
return await wrapperAsAny.executeOriginal(mergedArgs);
|
|
133
|
+
}
|
|
134
|
+
if (wrapperAsAny.originalTool?.call) {
|
|
135
|
+
return await wrapperAsAny.originalTool.call(mergedArgs);
|
|
136
|
+
}
|
|
137
|
+
return await toolEntry.originalTool.call(mergedArgs);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Handle execution error
|
|
141
|
+
*/
|
|
142
|
+
handleExecutionError(error, context, traceId, executionTime) {
|
|
143
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
144
|
+
if (error instanceof ZodError) {
|
|
145
|
+
return {
|
|
146
|
+
success: false,
|
|
147
|
+
output: "Validation error occurred",
|
|
148
|
+
error: errorMessage,
|
|
149
|
+
traceId,
|
|
150
|
+
executionTime
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
this.logger.error(`Tool execution failed: ${context.toolName}`, {
|
|
154
|
+
traceId,
|
|
155
|
+
error: errorMessage
|
|
156
|
+
});
|
|
157
|
+
return {
|
|
158
|
+
success: false,
|
|
159
|
+
output: "Tool execution failed",
|
|
160
|
+
error: errorMessage,
|
|
161
|
+
traceId,
|
|
162
|
+
executionTime
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Build default session context
|
|
167
|
+
*/
|
|
168
|
+
buildDefaultSession() {
|
|
169
|
+
return {
|
|
170
|
+
sessionId: `session-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
171
|
+
timestamp: Date.now()
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Get statistics about the pipeline
|
|
176
|
+
*/
|
|
177
|
+
getStatistics() {
|
|
178
|
+
return {
|
|
179
|
+
totalMiddleware: 0,
|
|
180
|
+
registeredMiddleware: []
|
|
181
|
+
};
|
|
24
182
|
}
|
|
25
183
|
}
|
|
26
184
|
export {
|
|
27
|
-
|
|
28
|
-
DEFAULT_CONTENT_REFERENCE_CONFIG
|
|
185
|
+
ExecutionPipeline
|
|
29
186
|
};
|
|
30
187
|
//# sourceMappingURL=index46.js.map
|
package/dist/esm/index46.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index46.js","sources":["../../src/types/content-reference.ts"],"sourcesContent":["/**\n * Content Reference System Types\n *\n * Shared interfaces for the Reference-Based Content System that handles\n * large content storage with unique reference IDs to optimize context window usage.\n */\n\n/**\n * Unique identifier for stored content references\n * Format: Cryptographically secure 32-byte identifier with base64url encoding\n */\nexport type ReferenceId = string;\n\n/**\n * Lifecycle state of a content reference\n */\nexport type ReferenceLifecycleState =\n | 'active'\n | 'expired'\n | 'cleanup_pending'\n | 'invalid';\n\n/**\n * Content types supported by the reference system\n */\nexport type ContentType =\n | 'text'\n | 'json'\n | 'html'\n | 'markdown'\n | 'binary'\n | 'unknown';\n\n/**\n * Sources that created the content reference\n */\nexport type ContentSource =\n | 'mcp_tool'\n | 'user_upload'\n | 'agent_generated'\n | 'system';\n\n/**\n * Metadata associated with stored content\n */\nexport interface ContentMetadata {\n /** Content type classification */\n contentType: ContentType;\n\n /** MIME type of the original content */\n mimeType?: string;\n\n /** Size in bytes of the stored content */\n sizeBytes: number;\n\n /** When the content was originally stored */\n createdAt: Date;\n\n /** Last time the content was accessed via reference resolution */\n lastAccessedAt: Date;\n\n /** Source that created this content reference */\n source: ContentSource;\n\n /** Name of the MCP tool that generated the content (if applicable) */\n mcpToolName?: string;\n\n /** Original filename or suggested name for the content */\n fileName?: string;\n\n /** Number of times this reference has been resolved */\n accessCount: number;\n\n /** Tags for categorization and cleanup policies */\n tags?: string[];\n\n /** Custom metadata from the source */\n customMetadata?: Record<string, unknown>;\n}\n\n/**\n * Core content reference object passed through agent context\n * Designed to be lightweight (<100 tokens) while providing enough\n * information for agent decision-making\n */\nexport interface ContentReference {\n /** Unique identifier for resolving the content */\n referenceId: ReferenceId;\n\n /** Current lifecycle state */\n state: ReferenceLifecycleState;\n\n /** Brief description or preview of the content (max 200 chars) */\n preview: string;\n\n /** Essential metadata for agent decision-making */\n metadata: Pick<\n ContentMetadata,\n 'contentType' | 'sizeBytes' | 'source' | 'fileName' | 'mimeType'\n >;\n\n /** When this reference was created */\n createdAt: Date;\n\n /** Special format indicator for reference IDs in content */\n readonly format: 'ref://{id}';\n}\n\n/**\n * Result of attempting to resolve a content reference\n */\nexport interface ReferenceResolutionResult {\n /** Whether the resolution was successful */\n success: boolean;\n\n /** The resolved content if successful */\n content?: Buffer;\n\n /** Complete metadata if successful */\n metadata?: ContentMetadata;\n\n /** Error message if resolution failed */\n error?: string;\n\n /** Specific error type for targeted error handling */\n errorType?:\n | 'not_found'\n | 'expired'\n | 'corrupted'\n | 'access_denied'\n | 'system_error';\n\n /** Suggested actions for recovery */\n suggestedActions?: string[];\n}\n\n/**\n * Configuration for content reference storage and lifecycle\n */\nexport interface ContentReferenceConfig {\n /** Size threshold above which content should be stored as references (default: 10KB) */\n sizeThresholdBytes: number;\n\n /** Maximum age for unused references before cleanup (default: 1 hour) */\n maxAgeMs: number;\n\n /** Maximum number of references to store simultaneously */\n maxReferences: number;\n\n /** Maximum total storage size for all references */\n maxTotalStorageBytes: number;\n\n /** Whether to enable automatic cleanup */\n enableAutoCleanup: boolean;\n\n /** Interval for cleanup checks in milliseconds */\n cleanupIntervalMs: number;\n\n /** Whether to persist references across restarts */\n enablePersistence: boolean;\n\n /** Storage backend configuration */\n storageBackend: 'memory' | 'filesystem' | 'hybrid';\n\n /** Cleanup policies for different content types */\n cleanupPolicies: {\n /** Policy for content marked as \"recent\" from MCP tools */\n recent: { maxAgeMs: number; priority: number };\n\n /** Policy for user-uploaded content */\n userContent: { maxAgeMs: number; priority: number };\n\n /** Policy for agent-generated content */\n agentGenerated: { maxAgeMs: number; priority: number };\n\n /** Default policy for other content */\n default: { maxAgeMs: number; priority: number };\n };\n}\n\n/**\n * Default configuration values\n */\nexport const DEFAULT_CONTENT_REFERENCE_CONFIG: ContentReferenceConfig = {\n sizeThresholdBytes: 10 * 1024,\n maxAgeMs: 60 * 60 * 1000,\n maxReferences: 100,\n maxTotalStorageBytes: 100 * 1024 * 1024,\n enableAutoCleanup: true,\n cleanupIntervalMs: 5 * 60 * 1000,\n enablePersistence: false,\n storageBackend: 'memory',\n cleanupPolicies: {\n recent: { maxAgeMs: 30 * 60 * 1000, priority: 1 },\n userContent: { maxAgeMs: 2 * 60 * 60 * 1000, priority: 2 },\n agentGenerated: { maxAgeMs: 60 * 60 * 1000, priority: 3 },\n default: { maxAgeMs: 60 * 60 * 1000, priority: 4 },\n },\n};\n\n/**\n * Statistics about content reference usage and storage\n */\nexport interface ContentReferenceStats {\n /** Total number of active references */\n activeReferences: number;\n\n /** Total storage used by all references in bytes */\n totalStorageBytes: number;\n\n /** Number of references cleaned up in last cleanup cycle */\n recentlyCleanedUp: number;\n\n /** Number of successful reference resolutions since startup */\n totalResolutions: number;\n\n /** Number of failed resolution attempts */\n failedResolutions: number;\n\n /** Average content size in bytes */\n averageContentSize: number;\n\n /** Most frequently accessed reference ID */\n mostAccessedReferenceId?: ReferenceId;\n\n /** Storage utilization percentage */\n storageUtilization: number;\n\n /** Performance metrics */\n performanceMetrics: {\n /** Average time to create a reference in milliseconds */\n averageCreationTimeMs: number;\n\n /** Average time to resolve a reference in milliseconds */\n averageResolutionTimeMs: number;\n\n /** Average cleanup time in milliseconds */\n averageCleanupTimeMs: number;\n };\n}\n\n/**\n * Error types for content reference operations\n */\nexport class ContentReferenceError extends Error {\n constructor(\n message: string,\n public readonly type: ReferenceResolutionResult['errorType'],\n public readonly referenceId?: ReferenceId,\n public readonly suggestedActions?: string[]\n ) {\n super(message);\n this.name = 'ContentReferenceError';\n }\n}\n\n/**\n * Interface for content reference storage implementations\n */\nexport interface ContentReferenceStore {\n /**\n * Store content and return a reference\n */\n storeContent(\n content: Buffer,\n metadata: Omit<\n ContentMetadata,\n 'createdAt' | 'lastAccessedAt' | 'accessCount'\n >\n ): Promise<ContentReference>;\n\n /**\n * Resolve a reference to its content\n */\n resolveReference(\n referenceId: ReferenceId\n ): Promise<ReferenceResolutionResult>;\n\n /**\n * Check if a reference exists and is valid\n */\n hasReference(referenceId: ReferenceId): Promise<boolean>;\n\n /**\n * Mark a reference for cleanup\n */\n cleanupReference(referenceId: ReferenceId): Promise<boolean>;\n\n /**\n * Get current storage statistics\n */\n getStats(): Promise<ContentReferenceStats>;\n\n /**\n * Update configuration\n */\n updateConfig(config: Partial<ContentReferenceConfig>): Promise<void>;\n\n /**\n * Perform cleanup based on current policies\n */\n performCleanup(): Promise<{ cleanedUp: number; errors: string[] }>;\n\n /**\n * Dispose of resources\n */\n dispose(): Promise<void>;\n}\n"],"names":[],"mappings":"AAuLO,MAAM,mCAA2D;AAAA,EACtE,oBAAoB,KAAK;AAAA,EACzB,UAAU,KAAK,KAAK;AAAA,EACpB,eAAe;AAAA,EACf,sBAAsB,MAAM,OAAO;AAAA,EACnC,mBAAmB;AAAA,EACnB,mBAAmB,IAAI,KAAK;AAAA,EAC5B,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,IACf,QAAQ,EAAE,UAAU,KAAK,KAAK,KAAM,UAAU,EAAA;AAAA,IAC9C,aAAa,EAAE,UAAU,IAAI,KAAK,KAAK,KAAM,UAAU,EAAA;AAAA,IACvD,gBAAgB,EAAE,UAAU,KAAK,KAAK,KAAM,UAAU,EAAA;AAAA,IACtD,SAAS,EAAE,UAAU,KAAK,KAAK,KAAM,UAAU,EAAA;AAAA,EAAE;AAErD;AA8CO,MAAM,8BAA8B,MAAM;AAAA,EAC/C,YACE,SACgB,MACA,aACA,kBAChB;AACA,UAAM,OAAO;AAJG,SAAA,OAAA;AACA,SAAA,cAAA;AACA,SAAA,mBAAA;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;"}
|
|
1
|
+
{"version":3,"file":"index46.js","sources":["../../src/execution/execution-pipeline.ts"],"sourcesContent":["import { ZodError } from 'zod';\nimport { Logger } from '@hashgraphonline/standards-sdk';\nimport { SmartMemoryManager } from '../memory/smart-memory-manager';\nimport { FormEngine, ToolExecutionResult } from '../forms/form-engine';\nimport type { FormMessage, FormSubmission } from '../forms/types';\nimport type { ToolRegistry, ToolRegistryEntry } from '../core/tool-registry';\n\n/**\n * Session context for tool execution\n */\nexport interface SessionContext {\n sessionId: string;\n userId?: string;\n timestamp: number;\n conversationId?: string;\n}\n\n/**\n * Context passed through execution pipeline\n */\nexport interface ExecutionContext {\n toolName: string;\n input: unknown;\n session: SessionContext;\n memory: SmartMemoryManager;\n traceId: string;\n toolEntry: ToolRegistryEntry;\n}\n\n/**\n * Result of tool execution with metadata\n */\nexport interface ExecutionResult extends ToolExecutionResult {\n traceId: string;\n executionTime: number;\n}\n\n/**\n * ExecutionPipeline handles tool execution coordination\n */\nexport class ExecutionPipeline {\n private logger: Logger;\n private toolRegistry: ToolRegistry;\n private formEngine: FormEngine;\n private memory: SmartMemoryManager;\n\n constructor(\n toolRegistry: ToolRegistry,\n formEngine: FormEngine,\n memory: SmartMemoryManager,\n logger?: Logger\n ) {\n this.toolRegistry = toolRegistry;\n this.formEngine = formEngine;\n this.memory = memory;\n this.logger = logger || new Logger({ module: 'ExecutionPipeline' });\n }\n\n /**\n * Execute a tool through the pipeline\n */\n async execute(\n toolName: string,\n input: unknown,\n sessionContext?: SessionContext\n ): Promise<ExecutionResult> {\n const traceId = `trace-${Date.now()}-${Math.random()\n .toString(36)\n .substr(2, 9)}`;\n const startTime = Date.now();\n\n const toolEntry = this.toolRegistry.getTool(toolName);\n if (!toolEntry) {\n throw new Error(`Tool not found in registry: ${toolName}`);\n }\n\n const context: ExecutionContext = {\n toolName,\n input,\n session: sessionContext || this.buildDefaultSession(),\n memory: this.memory,\n traceId,\n toolEntry,\n };\n\n try {\n const shouldGenerateForm = await this.checkFormGeneration(context);\n if (shouldGenerateForm.requiresForm && shouldGenerateForm.formMessage) {\n return {\n success: false,\n output: 'Form generation required',\n requiresForm: true,\n formMessage: shouldGenerateForm.formMessage,\n traceId,\n executionTime: Date.now() - startTime,\n };\n }\n\n const result = await this.executeToolDirect(context);\n\n return {\n success: true,\n output: result,\n traceId,\n executionTime: Date.now() - startTime,\n };\n } catch (error) {\n return this.handleExecutionError(\n error,\n context,\n traceId,\n Date.now() - startTime\n );\n }\n }\n\n /**\n * Execute tool with validation\n */\n async executeWithValidation(\n toolName: string,\n input: unknown,\n sessionContext?: SessionContext\n ): Promise<ExecutionResult> {\n return this.execute(toolName, input, sessionContext);\n }\n\n /**\n * Process form submission\n */\n async processFormSubmission(\n toolName: string,\n formId: string,\n parameters: Record<string, unknown>,\n sessionContext?: SessionContext\n ): Promise<ExecutionResult> {\n const traceId = `form-${Date.now()}-${Math.random()\n .toString(36)\n .substr(2, 9)}`;\n const startTime = Date.now();\n\n try {\n const formSubmission: FormSubmission = {\n formId,\n toolName,\n parameters,\n timestamp: Date.now(),\n };\n\n const processedInput = await this.formEngine.processSubmission(\n formSubmission\n );\n\n return this.execute(toolName, processedInput, sessionContext);\n } catch (error) {\n return {\n success: false,\n output: 'Form submission processing failed',\n error: error instanceof Error ? error.message : String(error),\n traceId,\n executionTime: Date.now() - startTime,\n };\n }\n }\n\n /**\n * Check if form generation is required\n */\n private async checkFormGeneration(context: ExecutionContext): Promise<{\n requiresForm: boolean;\n formMessage?: FormMessage;\n }> {\n const inputRecord = context.input as Record<string, unknown>;\n if (inputRecord?.__fromForm === true || inputRecord?.renderForm === false) {\n return { requiresForm: false };\n }\n\n if (\n !this.formEngine.shouldGenerateForm(context.toolEntry.tool, context.input)\n ) {\n return { requiresForm: false };\n }\n\n const formMessage = await this.formEngine.generateForm(\n context.toolName,\n context.toolEntry.tool,\n context.input\n );\n\n if (formMessage) {\n return { requiresForm: true, formMessage };\n }\n\n return { requiresForm: false };\n }\n\n /**\n * Execute tool directly\n */\n private async executeToolDirect(context: ExecutionContext): Promise<string> {\n const { toolEntry, input } = context;\n const parameters = (input as Record<string, unknown>) || {};\n const mergedArgs = { ...parameters, renderForm: false };\n\n if (toolEntry.wrapper) {\n return this.executeWrappedTool(toolEntry, mergedArgs);\n }\n\n return await toolEntry.tool.call(mergedArgs);\n }\n\n /**\n * Execute wrapped tool\n */\n private async executeWrappedTool(\n toolEntry: ToolRegistryEntry,\n mergedArgs: Record<string, unknown>\n ): Promise<string> {\n const wrapper = toolEntry.wrapper;\n if (!wrapper) {\n throw new Error('Tool wrapper not found');\n }\n\n const wrapperAsAny = wrapper as unknown as {\n executeOriginal?: (args: Record<string, unknown>) => Promise<string>;\n originalTool?: {\n call?: (args: Record<string, unknown>) => Promise<string>;\n };\n };\n\n if (wrapperAsAny.executeOriginal) {\n return await wrapperAsAny.executeOriginal(mergedArgs);\n }\n\n if (wrapperAsAny.originalTool?.call) {\n return await wrapperAsAny.originalTool.call(mergedArgs);\n }\n\n return await toolEntry.originalTool.call(mergedArgs);\n }\n\n /**\n * Handle execution error\n */\n private handleExecutionError(\n error: unknown,\n context: ExecutionContext,\n traceId: string,\n executionTime: number\n ): ExecutionResult {\n const errorMessage = error instanceof Error ? error.message : String(error);\n\n if (error instanceof ZodError) {\n return {\n success: false,\n output: 'Validation error occurred',\n error: errorMessage,\n traceId,\n executionTime,\n };\n }\n\n this.logger.error(`Tool execution failed: ${context.toolName}`, {\n traceId,\n error: errorMessage,\n });\n\n return {\n success: false,\n output: 'Tool execution failed',\n error: errorMessage,\n traceId,\n executionTime,\n };\n }\n\n /**\n * Build default session context\n */\n private buildDefaultSession(): SessionContext {\n return {\n sessionId: `session-${Date.now()}-${Math.random()\n .toString(36)\n .substr(2, 9)}`,\n timestamp: Date.now(),\n };\n }\n\n /**\n * Get statistics about the pipeline\n */\n getStatistics(): {\n totalMiddleware: number;\n registeredMiddleware: string[];\n } {\n return {\n totalMiddleware: 0,\n registeredMiddleware: [],\n };\n }\n}\n"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hashgraphonline/conversational-agent",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.213",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/cjs/index.cjs",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -28,30 +28,6 @@
|
|
|
28
28
|
"LICENSE",
|
|
29
29
|
"README.md"
|
|
30
30
|
],
|
|
31
|
-
"scripts": {
|
|
32
|
-
"test": "jest --detectOpenHandles",
|
|
33
|
-
"test:integration": "jest tests/integration",
|
|
34
|
-
"clean": "rimraf dist",
|
|
35
|
-
"build:es": "BUILD_FORMAT=es vite build",
|
|
36
|
-
"build:cjs": "BUILD_FORMAT=cjs vite build",
|
|
37
|
-
"build:umd": "BUILD_FORMAT=umd vite build",
|
|
38
|
-
"build": "pnpm run clean && pnpm run build:es && pnpm run build:cjs",
|
|
39
|
-
"build:all": "pnpm run build && pnpm run cli:build",
|
|
40
|
-
"prepublishOnly": "pnpm run build",
|
|
41
|
-
"release": "pnpm publish --access public",
|
|
42
|
-
"release:canary": "pnpm run prepublishOnly && pnpm publish --tag canary --access public",
|
|
43
|
-
"version:canary": "pnpm version prerelease --preid canary --no-git-tag-version",
|
|
44
|
-
"publish:canary": "pnpm run version:canary && pnpm run release:canary",
|
|
45
|
-
"lint": "eslint .",
|
|
46
|
-
"lint:fix": "eslint . --fix",
|
|
47
|
-
"typecheck": "tsc --noEmit",
|
|
48
|
-
"cli:build": "cd cli && pnpm install && pnpm build",
|
|
49
|
-
"cli": "tsx cli/scripts/run-cli.ts",
|
|
50
|
-
"cli:dev": "cd cli && pnpm dev",
|
|
51
|
-
"example:mcp-filesystem": "tsx examples/mcp-filesystem-demo.ts",
|
|
52
|
-
"example:mcp-multi": "tsx examples/mcp-multi-server-demo.ts",
|
|
53
|
-
"postinstall": "cd cli && pnpm install --silent 2>/dev/null || true"
|
|
54
|
-
},
|
|
55
31
|
"keywords": [
|
|
56
32
|
"hedera",
|
|
57
33
|
"hashgraph",
|
|
@@ -100,7 +76,7 @@
|
|
|
100
76
|
"dependencies": {
|
|
101
77
|
"@hashgraph/sdk": "^2.72.0",
|
|
102
78
|
"@hashgraphonline/hashinal-wc": "^1.0.107",
|
|
103
|
-
"@hashgraphonline/standards-agent-kit": "^0.2.
|
|
79
|
+
"@hashgraphonline/standards-agent-kit": "^0.2.159",
|
|
104
80
|
"@hashgraphonline/standards-sdk": "0.1.110",
|
|
105
81
|
"@langchain/anthropic": "^0.3.28",
|
|
106
82
|
"@langchain/core": "^0.3.77",
|
|
@@ -127,11 +103,27 @@
|
|
|
127
103
|
"url": "https://github.com/hashgraph-online/conversational-agent/issues"
|
|
128
104
|
},
|
|
129
105
|
"homepage": "https://github.com/hashgraph-online/conversational-agent#readme",
|
|
130
|
-
"
|
|
131
|
-
|
|
132
|
-
"
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
106
|
+
"scripts": {
|
|
107
|
+
"test": "jest --detectOpenHandles",
|
|
108
|
+
"test:integration": "jest tests/integration",
|
|
109
|
+
"clean": "rimraf dist",
|
|
110
|
+
"build:es": "BUILD_FORMAT=es vite build",
|
|
111
|
+
"build:cjs": "BUILD_FORMAT=cjs vite build",
|
|
112
|
+
"build:umd": "BUILD_FORMAT=umd vite build",
|
|
113
|
+
"build": "pnpm run clean && pnpm run build:es && pnpm run build:cjs",
|
|
114
|
+
"build:all": "pnpm run build && pnpm run cli:build",
|
|
115
|
+
"release": "pnpm publish --access public",
|
|
116
|
+
"release:canary": "pnpm run prepublishOnly && pnpm publish --tag canary --access public",
|
|
117
|
+
"version:canary": "pnpm version prerelease --preid canary --no-git-tag-version",
|
|
118
|
+
"publish:canary": "pnpm run version:canary && pnpm run release:canary",
|
|
119
|
+
"lint": "eslint .",
|
|
120
|
+
"lint:fix": "eslint . --fix",
|
|
121
|
+
"typecheck": "tsc --noEmit",
|
|
122
|
+
"cli:build": "cd cli && pnpm install && pnpm build",
|
|
123
|
+
"cli": "tsx cli/scripts/run-cli.ts",
|
|
124
|
+
"cli:dev": "cd cli && pnpm dev",
|
|
125
|
+
"example:mcp-filesystem": "tsx examples/mcp-filesystem-demo.ts",
|
|
126
|
+
"example:mcp-multi": "tsx examples/mcp-multi-server-demo.ts",
|
|
127
|
+
"postinstall": "cd cli && pnpm install --silent 2>/dev/null || true"
|
|
136
128
|
}
|
|
137
|
-
}
|
|
129
|
+
}
|
package/cli/readme.md
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
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
|