@hashgraphonline/conversational-agent 0.1.217 → 0.1.218
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/readme.md +181 -0
- package/dist/cjs/constants/entity-references.d.ts +18 -0
- package/dist/cjs/constants/form-priorities.d.ts +24 -0
- package/dist/cjs/constants/index.d.ts +4 -0
- package/dist/cjs/constants/messages.d.ts +19 -0
- package/dist/cjs/constants/test-constants.d.ts +42 -0
- package/dist/cjs/conversational-agent.d.ts +3 -8
- package/dist/cjs/core/{ToolRegistry.d.ts → tool-registry.d.ts} +10 -7
- package/dist/{types/execution/ExecutionPipeline.d.ts → cjs/execution/execution-pipeline.d.ts} +3 -3
- package/dist/cjs/forms/field-guidance-registry.d.ts +108 -0
- package/dist/cjs/forms/form-generator.d.ts +2 -7
- package/dist/cjs/forms/index.d.ts +3 -0
- package/dist/cjs/forms/types.d.ts +9 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +7 -12
- package/dist/cjs/langchain/external-tool-wrapper.d.ts +101 -0
- package/dist/{types/langchain/FormAwareAgentExecutor.d.ts → cjs/langchain/form-aware-agent-executor.d.ts} +19 -12
- package/dist/cjs/langchain/index.d.ts +2 -0
- package/dist/{types → cjs/langchain}/langchain-agent.d.ts +15 -7
- package/dist/cjs/mcp/adapters/index.d.ts +1 -0
- package/dist/cjs/mcp/adapters/langchain.d.ts +1 -1
- package/dist/{types/mcp/ContentProcessor.d.ts → cjs/mcp/content-processor.d.ts} +1 -1
- package/dist/cjs/mcp/index.d.ts +5 -0
- package/dist/{types/mcp/MCPClientManager.d.ts → cjs/mcp/mcp-client-manager.d.ts} +1 -1
- package/dist/cjs/memory/{ContentStorage.d.ts → content-storage.d.ts} +4 -4
- package/dist/cjs/memory/index.d.ts +5 -7
- package/dist/{types/memory/MemoryWindow.d.ts → cjs/memory/memory-window.d.ts} +1 -1
- package/dist/{types/memory/SmartMemoryManager.d.ts → cjs/memory/smart-memory-manager.d.ts} +1 -1
- package/dist/cjs/services/{ContentStoreManager.d.ts → content-store-manager.d.ts} +6 -6
- package/dist/cjs/services/context/resolution-context.d.ts +49 -0
- package/dist/cjs/services/entity-resolver.d.ts +58 -0
- package/dist/cjs/services/formatters/converters/index.d.ts +2 -0
- package/dist/cjs/services/formatters/converters/string-normalization-converter.d.ts +13 -0
- package/dist/cjs/services/formatters/converters/topic-id-to-hrl-converter.d.ts +17 -0
- package/dist/cjs/services/formatters/format-converter-registry.d.ts +66 -0
- package/dist/cjs/services/formatters/index.d.ts +3 -0
- package/dist/cjs/services/formatters/types.d.ts +29 -0
- package/dist/cjs/services/index.d.ts +3 -0
- package/dist/cjs/services/resolution/resolution-pipeline.d.ts +44 -0
- package/dist/cjs/tools/index.d.ts +1 -0
- package/dist/cjs/utils/index.d.ts +1 -0
- package/dist/esm/index.js +40 -16
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index10.js +669 -13
- package/dist/esm/index10.js.map +1 -1
- package/dist/esm/index11.js +310 -95
- package/dist/esm/index11.js.map +1 -1
- package/dist/esm/index12.js +130 -95
- package/dist/esm/index12.js.map +1 -1
- package/dist/esm/index13.js +262 -153
- package/dist/esm/index13.js.map +1 -1
- package/dist/esm/index14.js +100 -664
- package/dist/esm/index14.js.map +1 -1
- package/dist/esm/index15.js +135 -408
- package/dist/esm/index15.js.map +1 -1
- package/dist/esm/index16.js +240 -122
- package/dist/esm/index16.js.map +1 -1
- package/dist/esm/index17.js +147 -135
- package/dist/esm/index17.js.map +1 -1
- package/dist/esm/index18.js +376 -533
- package/dist/esm/index18.js.map +1 -1
- package/dist/esm/index19.js +87 -214
- package/dist/esm/index19.js.map +1 -1
- package/dist/esm/index2.js +21 -4
- package/dist/esm/index2.js.map +1 -1
- package/dist/esm/index20.js +158 -92
- package/dist/esm/index20.js.map +1 -1
- package/dist/esm/index21.js +717 -44
- package/dist/esm/index21.js.map +1 -1
- package/dist/esm/index22.js +58 -96
- package/dist/esm/index22.js.map +1 -1
- package/dist/esm/index23.js +324 -34
- package/dist/esm/index23.js.map +1 -1
- package/dist/esm/index24.js +125 -712
- package/dist/esm/index24.js.map +1 -1
- package/dist/esm/index25.js +113 -133
- package/dist/esm/index25.js.map +1 -1
- package/dist/esm/index26.js +18 -152
- package/dist/esm/index26.js.map +1 -1
- package/dist/esm/index27.js +14 -210
- package/dist/esm/index27.js.map +1 -1
- package/dist/esm/index28.js +70 -173
- package/dist/esm/index28.js.map +1 -1
- package/dist/esm/index29.js +811 -224
- package/dist/esm/index29.js.map +1 -1
- package/dist/esm/index30.js +1245 -122
- package/dist/esm/index30.js.map +1 -1
- package/dist/esm/index31.js +126 -56
- package/dist/esm/index31.js.map +1 -1
- package/dist/esm/index32.js +111 -24
- package/dist/esm/index32.js.map +1 -1
- package/dist/esm/index33.js +41 -87
- package/dist/esm/index33.js.map +1 -1
- package/dist/esm/index34.js +88 -227
- package/dist/esm/index34.js.map +1 -1
- package/dist/esm/index35.js +24 -0
- package/dist/esm/index35.js.map +1 -0
- package/dist/esm/index36.js +15 -0
- package/dist/esm/index36.js.map +1 -0
- package/dist/esm/index37.js +10 -0
- package/dist/esm/index37.js.map +1 -0
- package/dist/esm/index38.js +8 -0
- package/dist/esm/index38.js.map +1 -0
- package/dist/esm/index39.js +227 -0
- package/dist/esm/index39.js.map +1 -0
- package/dist/esm/index40.js +187 -0
- package/dist/esm/index40.js.map +1 -0
- package/dist/esm/index41.js +30 -0
- package/dist/esm/index41.js.map +1 -0
- package/dist/esm/index42.js +95 -0
- package/dist/esm/index42.js.map +1 -0
- package/dist/esm/index5.js +2 -2
- package/dist/esm/index5.js.map +1 -1
- package/dist/esm/index6.js +44 -67
- package/dist/esm/index6.js.map +1 -1
- package/dist/esm/index7.js +9 -0
- package/dist/esm/index7.js.map +1 -1
- package/dist/esm/index8.js +13 -1095
- package/dist/esm/index8.js.map +1 -1
- package/dist/esm/index9.js +17 -13
- package/dist/esm/index9.js.map +1 -1
- package/dist/types/constants/entity-references.d.ts +18 -0
- package/dist/types/constants/form-priorities.d.ts +24 -0
- package/dist/types/constants/index.d.ts +4 -0
- package/dist/types/constants/messages.d.ts +19 -0
- package/dist/types/constants/test-constants.d.ts +42 -0
- package/dist/types/conversational-agent.d.ts +3 -8
- package/dist/types/core/{ToolRegistry.d.ts → tool-registry.d.ts} +10 -7
- package/dist/{cjs/execution/ExecutionPipeline.d.ts → types/execution/execution-pipeline.d.ts} +3 -3
- package/dist/types/forms/field-guidance-registry.d.ts +108 -0
- package/dist/types/forms/form-generator.d.ts +2 -7
- package/dist/types/forms/index.d.ts +3 -0
- package/dist/types/forms/types.d.ts +9 -1
- package/dist/types/index.d.ts +7 -12
- package/dist/types/langchain/external-tool-wrapper.d.ts +101 -0
- package/dist/{cjs/langchain/FormAwareAgentExecutor.d.ts → types/langchain/form-aware-agent-executor.d.ts} +19 -12
- package/dist/types/langchain/index.d.ts +2 -0
- package/dist/{cjs → types/langchain}/langchain-agent.d.ts +15 -7
- package/dist/types/mcp/adapters/index.d.ts +1 -0
- package/dist/types/mcp/adapters/langchain.d.ts +1 -1
- package/dist/{cjs/mcp/ContentProcessor.d.ts → types/mcp/content-processor.d.ts} +1 -1
- package/dist/types/mcp/index.d.ts +5 -0
- package/dist/{cjs/mcp/MCPClientManager.d.ts → types/mcp/mcp-client-manager.d.ts} +1 -1
- package/dist/types/memory/{ContentStorage.d.ts → content-storage.d.ts} +4 -4
- package/dist/types/memory/index.d.ts +5 -7
- package/dist/{cjs/memory/MemoryWindow.d.ts → types/memory/memory-window.d.ts} +1 -1
- package/dist/{cjs/memory/SmartMemoryManager.d.ts → types/memory/smart-memory-manager.d.ts} +1 -1
- package/dist/types/services/{ContentStoreManager.d.ts → content-store-manager.d.ts} +6 -6
- package/dist/types/services/context/resolution-context.d.ts +49 -0
- package/dist/types/services/entity-resolver.d.ts +58 -0
- package/dist/types/services/formatters/converters/index.d.ts +2 -0
- package/dist/types/services/formatters/converters/string-normalization-converter.d.ts +13 -0
- package/dist/types/services/formatters/converters/topic-id-to-hrl-converter.d.ts +17 -0
- package/dist/types/services/formatters/format-converter-registry.d.ts +66 -0
- package/dist/types/services/formatters/index.d.ts +3 -0
- package/dist/types/services/formatters/types.d.ts +29 -0
- package/dist/types/services/index.d.ts +3 -0
- package/dist/types/services/resolution/resolution-pipeline.d.ts +44 -0
- package/dist/types/tools/index.d.ts +1 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/package.json +30 -27
- package/src/agent-factory.ts +1 -1
- package/src/base-agent.ts +9 -0
- package/src/config/system-message.ts +2 -15
- package/src/constants/entity-references.ts +23 -0
- package/src/constants/form-priorities.ts +25 -0
- package/src/constants/index.ts +4 -0
- package/src/constants/messages.ts +20 -0
- package/src/constants/test-constants.ts +49 -0
- package/src/conversational-agent.ts +42 -69
- package/src/core/{ToolRegistry.ts → tool-registry.ts} +70 -44
- package/src/examples/external-tool-wrapper-example.ts +56 -0
- package/src/execution/{ExecutionPipeline.ts → execution-pipeline.ts} +3 -3
- package/src/forms/field-guidance-registry.ts +415 -0
- package/src/forms/field-type-registry.ts +49 -48
- package/src/forms/{FormEngine.ts → form-engine.ts} +66 -43
- package/src/forms/form-generator.ts +91 -17
- package/src/forms/index.ts +4 -1
- package/src/forms/types.ts +9 -1
- package/src/index.ts +7 -37
- package/src/langchain/external-tool-wrapper.ts +90 -0
- package/src/langchain/{FormAwareAgentExecutor.ts → form-aware-agent-executor.ts} +579 -351
- package/src/langchain/index.ts +2 -0
- package/src/{langchain-agent.ts → langchain/langchain-agent.ts} +389 -113
- package/src/mcp/adapters/index.ts +1 -0
- package/src/mcp/adapters/langchain.ts +27 -18
- package/src/mcp/{ContentProcessor.ts → content-processor.ts} +71 -47
- package/src/mcp/index.ts +5 -0
- package/src/mcp/{MCPClientManager.ts → mcp-client-manager.ts} +2 -2
- package/src/memory/{ContentStorage.ts → content-storage.ts} +263 -167
- package/src/memory/index.ts +5 -8
- package/src/memory/{MemoryWindow.ts → memory-window.ts} +47 -24
- package/src/memory/{SmartMemoryManager.ts → smart-memory-manager.ts} +49 -22
- package/src/plugins/hbar/HbarPlugin.ts +1 -1
- package/src/plugins/hcs-10/HCS10Plugin.ts +46 -28
- package/src/scripts/test-external-tool-wrapper.ts +6 -6
- package/src/scripts/test-inscribe-form-generation.ts +22 -21
- package/src/scripts/test-inscribe-wrapper-verification.ts +5 -4
- package/src/services/{ContentStoreManager.ts → content-store-manager.ts} +75 -33
- package/src/services/context/resolution-context.ts +80 -0
- package/src/services/entity-resolver.ts +425 -0
- package/src/services/formatters/converters/index.ts +2 -0
- package/src/services/formatters/converters/string-normalization-converter.ts +106 -0
- package/src/services/formatters/converters/topic-id-to-hrl-converter.ts +25 -0
- package/src/services/formatters/format-converter-registry.ts +229 -0
- package/src/services/formatters/index.ts +3 -0
- package/src/services/formatters/types.ts +31 -0
- package/src/services/index.ts +3 -0
- package/src/services/resolution/resolution-pipeline.ts +106 -0
- package/src/tools/index.ts +1 -0
- package/src/types/content-reference.ts +87 -60
- package/src/utils/index.ts +1 -0
- package/cli/dist/CLIApp.d.ts +0 -9
- package/cli/dist/CLIApp.js +0 -127
- package/cli/dist/LocalConversationalAgent.d.ts +0 -37
- package/cli/dist/LocalConversationalAgent.js +0 -58
- package/cli/dist/app.d.ts +0 -16
- package/cli/dist/app.js +0 -13
- package/cli/dist/cli.d.ts +0 -2
- package/cli/dist/cli.js +0 -51
- package/cli/dist/components/AppContainer.d.ts +0 -16
- package/cli/dist/components/AppContainer.js +0 -24
- package/cli/dist/components/AppScreens.d.ts +0 -2
- package/cli/dist/components/AppScreens.js +0 -259
- package/cli/dist/components/ChatScreen.d.ts +0 -15
- package/cli/dist/components/ChatScreen.js +0 -39
- package/cli/dist/components/DebugLoadingScreen.d.ts +0 -5
- package/cli/dist/components/DebugLoadingScreen.js +0 -31
- package/cli/dist/components/LoadingScreen.d.ts +0 -2
- package/cli/dist/components/LoadingScreen.js +0 -16
- package/cli/dist/components/LoadingScreenDebug.d.ts +0 -5
- package/cli/dist/components/LoadingScreenDebug.js +0 -27
- package/cli/dist/components/MCPConfigScreen.d.ts +0 -28
- package/cli/dist/components/MCPConfigScreen.js +0 -168
- package/cli/dist/components/ScreenRouter.d.ts +0 -12
- package/cli/dist/components/ScreenRouter.js +0 -22
- package/cli/dist/components/SetupScreen.d.ts +0 -15
- package/cli/dist/components/SetupScreen.js +0 -65
- package/cli/dist/components/SingleLoadingScreen.d.ts +0 -5
- package/cli/dist/components/SingleLoadingScreen.js +0 -27
- package/cli/dist/components/StatusBadge.d.ts +0 -7
- package/cli/dist/components/StatusBadge.js +0 -28
- package/cli/dist/components/TerminalWindow.d.ts +0 -8
- package/cli/dist/components/TerminalWindow.js +0 -24
- package/cli/dist/components/WelcomeScreen.d.ts +0 -11
- package/cli/dist/components/WelcomeScreen.js +0 -47
- package/cli/dist/context/AppContext.d.ts +0 -68
- package/cli/dist/context/AppContext.js +0 -363
- package/cli/dist/hooks/useInitializeAgent.d.ts +0 -19
- package/cli/dist/hooks/useInitializeAgent.js +0 -28
- package/cli/dist/hooks/useStableState.d.ts +0 -38
- package/cli/dist/hooks/useStableState.js +0 -68
- package/cli/dist/managers/AgentManager.d.ts +0 -57
- package/cli/dist/managers/AgentManager.js +0 -119
- package/cli/dist/managers/ConfigManager.d.ts +0 -53
- package/cli/dist/managers/ConfigManager.js +0 -173
- package/cli/dist/types.d.ts +0 -31
- package/cli/dist/types.js +0 -19
- package/dist/cjs/context/ReferenceContextManager.d.ts +0 -84
- package/dist/cjs/context/ReferenceResponseProcessor.d.ts +0 -76
- package/dist/cjs/langchain/FormValidatingToolWrapper.d.ts +0 -81
- package/dist/cjs/services/EntityResolver.d.ts +0 -26
- package/dist/types/context/ReferenceContextManager.d.ts +0 -84
- package/dist/types/context/ReferenceResponseProcessor.d.ts +0 -76
- package/dist/types/langchain/FormValidatingToolWrapper.d.ts +0 -81
- package/dist/types/services/EntityResolver.d.ts +0 -26
- package/src/context/ReferenceContextManager.ts +0 -350
- package/src/context/ReferenceResponseProcessor.ts +0 -295
- package/src/langchain/FormValidatingToolWrapper.ts +0 -355
- package/src/scripts/test-hedera-kit-wrapper.ts +0 -265
- package/src/services/EntityResolver.ts +0 -128
- /package/dist/cjs/forms/{FormEngine.d.ts → form-engine.d.ts} +0 -0
- /package/dist/cjs/memory/{ReferenceIdGenerator.d.ts → reference-id-generator.d.ts} +0 -0
- /package/dist/cjs/memory/{TokenCounter.d.ts → token-counter.d.ts} +0 -0
- /package/dist/cjs/tools/{EntityResolverTool.d.ts → entity-resolver-tool.d.ts} +0 -0
- /package/dist/cjs/utils/{ResponseFormatter.d.ts → response-formatter.d.ts} +0 -0
- /package/dist/types/forms/{FormEngine.d.ts → form-engine.d.ts} +0 -0
- /package/dist/types/memory/{ReferenceIdGenerator.d.ts → reference-id-generator.d.ts} +0 -0
- /package/dist/types/memory/{TokenCounter.d.ts → token-counter.d.ts} +0 -0
- /package/dist/types/tools/{EntityResolverTool.d.ts → entity-resolver-tool.d.ts} +0 -0
- /package/dist/types/utils/{ResponseFormatter.d.ts → response-formatter.d.ts} +0 -0
- /package/src/memory/{ReferenceIdGenerator.ts → reference-id-generator.ts} +0 -0
- /package/src/memory/{TokenCounter.ts → token-counter.ts} +0 -0
- /package/src/tools/{EntityResolverTool.ts → entity-resolver-tool.ts} +0 -0
- /package/src/utils/{ResponseFormatter.ts → response-formatter.ts} +0 -0
package/src/memory/index.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
export type { SmartMemoryConfig, SearchOptions, MemoryStats, EntityAssociation, EntityResolutionOptions } from './SmartMemoryManager';
|
|
7
|
-
export type { AddMessageResult } from './MemoryWindow';
|
|
8
|
-
export type { StorageStats } from './ContentStorage';
|
|
1
|
+
export * from './smart-memory-manager';
|
|
2
|
+
export * from './token-counter';
|
|
3
|
+
export * from './memory-window';
|
|
4
|
+
export * from './content-storage';
|
|
5
|
+
export * from './reference-id-generator';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BaseMessage } from '@langchain/core/messages';
|
|
2
|
-
import { TokenCounter } from './
|
|
2
|
+
import { TokenCounter } from './token-counter';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Result of adding a message to the memory window
|
|
@@ -52,19 +52,19 @@ export class MemoryWindow {
|
|
|
52
52
|
*/
|
|
53
53
|
addMessage(message: BaseMessage): AddMessageResult {
|
|
54
54
|
this.tokenCounter.countMessageTokens(message);
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
this.messages.push(message);
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
const currentTokens = this.getCurrentTokenCount();
|
|
59
59
|
const availableTokens = this.maxTokens - this.reserveTokens;
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
let prunedMessages: BaseMessage[] = [];
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
if (currentTokens > availableTokens) {
|
|
64
64
|
this.messages.pop();
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
prunedMessages = this.pruneToFit();
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
this.messages.push(message);
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -72,7 +72,7 @@ export class MemoryWindow {
|
|
|
72
72
|
added: true,
|
|
73
73
|
prunedMessages,
|
|
74
74
|
currentTokenCount: this.getCurrentTokenCount(),
|
|
75
|
-
remainingCapacity: this.getRemainingTokenCapacity()
|
|
75
|
+
remainingCapacity: this.getRemainingTokenCapacity(),
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -84,17 +84,23 @@ export class MemoryWindow {
|
|
|
84
84
|
pruneToFit(): BaseMessage[] {
|
|
85
85
|
const prunedMessages: BaseMessage[] = [];
|
|
86
86
|
const targetTokens = this.maxTokens - this.reserveTokens;
|
|
87
|
-
|
|
88
|
-
while (
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
|
|
88
|
+
while (
|
|
89
|
+
this.getCurrentTokenCount() > targetTokens &&
|
|
90
|
+
this.messages.length > 0
|
|
91
|
+
) {
|
|
92
|
+
const batchSize = Math.min(
|
|
93
|
+
MemoryWindow.PRUNING_BATCH_SIZE,
|
|
94
|
+
this.messages.length
|
|
95
|
+
);
|
|
96
|
+
|
|
91
97
|
for (let i = 0; i < batchSize; i++) {
|
|
92
98
|
const prunedMessage = this.messages.shift();
|
|
93
99
|
if (prunedMessage) {
|
|
94
100
|
prunedMessages.push(prunedMessage);
|
|
95
101
|
}
|
|
96
102
|
}
|
|
97
|
-
|
|
103
|
+
|
|
98
104
|
if (prunedMessages.length > 1000) {
|
|
99
105
|
break;
|
|
100
106
|
}
|
|
@@ -128,12 +134,13 @@ export class MemoryWindow {
|
|
|
128
134
|
canAddMessage(message: BaseMessage): boolean {
|
|
129
135
|
const messageTokens = this.tokenCounter.countMessageTokens(message);
|
|
130
136
|
const currentTokens = this.getCurrentTokenCount();
|
|
131
|
-
const wouldExceedReserve =
|
|
132
|
-
|
|
137
|
+
const wouldExceedReserve =
|
|
138
|
+
currentTokens + messageTokens > this.maxTokens - this.reserveTokens;
|
|
139
|
+
|
|
133
140
|
if (messageTokens > this.maxTokens) {
|
|
134
141
|
return false;
|
|
135
142
|
}
|
|
136
|
-
|
|
143
|
+
|
|
137
144
|
return !wouldExceedReserve || this.messages.length > 0;
|
|
138
145
|
}
|
|
139
146
|
|
|
@@ -158,7 +165,8 @@ export class MemoryWindow {
|
|
|
158
165
|
*/
|
|
159
166
|
setSystemPrompt(systemPrompt: string): void {
|
|
160
167
|
this.systemPrompt = systemPrompt;
|
|
161
|
-
this.systemPromptTokens =
|
|
168
|
+
this.systemPromptTokens =
|
|
169
|
+
this.tokenCounter.estimateSystemPromptTokens(systemPrompt);
|
|
162
170
|
}
|
|
163
171
|
|
|
164
172
|
/**
|
|
@@ -173,13 +181,19 @@ export class MemoryWindow {
|
|
|
173
181
|
* Get current configuration
|
|
174
182
|
* @returns Memory window configuration
|
|
175
183
|
*/
|
|
176
|
-
getConfig() {
|
|
184
|
+
getConfig(): {
|
|
185
|
+
maxTokens: number;
|
|
186
|
+
reserveTokens: number;
|
|
187
|
+
currentTokens: number;
|
|
188
|
+
messageCount: number;
|
|
189
|
+
systemPromptTokens: number;
|
|
190
|
+
} {
|
|
177
191
|
return {
|
|
178
192
|
maxTokens: this.maxTokens,
|
|
179
193
|
reserveTokens: this.reserveTokens,
|
|
180
194
|
currentTokens: this.getCurrentTokenCount(),
|
|
181
195
|
messageCount: this.messages.length,
|
|
182
|
-
systemPromptTokens: this.systemPromptTokens
|
|
196
|
+
systemPromptTokens: this.systemPromptTokens,
|
|
183
197
|
};
|
|
184
198
|
}
|
|
185
199
|
|
|
@@ -198,7 +212,7 @@ export class MemoryWindow {
|
|
|
198
212
|
this.reserveTokens = reserveTokens;
|
|
199
213
|
}
|
|
200
214
|
|
|
201
|
-
if (this.getCurrentTokenCount() >
|
|
215
|
+
if (this.getCurrentTokenCount() > this.maxTokens - this.reserveTokens) {
|
|
202
216
|
this.pruneToFit();
|
|
203
217
|
}
|
|
204
218
|
}
|
|
@@ -207,11 +221,20 @@ export class MemoryWindow {
|
|
|
207
221
|
* Get statistics about the memory window
|
|
208
222
|
* @returns Memory usage statistics
|
|
209
223
|
*/
|
|
210
|
-
getStats() {
|
|
224
|
+
getStats(): {
|
|
225
|
+
totalMessages: number;
|
|
226
|
+
currentTokens: number;
|
|
227
|
+
maxTokens: number;
|
|
228
|
+
reserveTokens: number;
|
|
229
|
+
systemPromptTokens: number;
|
|
230
|
+
usagePercentage: number;
|
|
231
|
+
remainingCapacity: number;
|
|
232
|
+
canAcceptMore: boolean;
|
|
233
|
+
} {
|
|
211
234
|
const currentTokens = this.getCurrentTokenCount();
|
|
212
235
|
const capacity = this.maxTokens;
|
|
213
236
|
const usagePercentage = (currentTokens / capacity) * 100;
|
|
214
|
-
|
|
237
|
+
|
|
215
238
|
return {
|
|
216
239
|
totalMessages: this.messages.length,
|
|
217
240
|
currentTokens,
|
|
@@ -220,7 +243,7 @@ export class MemoryWindow {
|
|
|
220
243
|
systemPromptTokens: this.systemPromptTokens,
|
|
221
244
|
usagePercentage: Math.round(usagePercentage * 100) / 100,
|
|
222
245
|
remainingCapacity: this.getRemainingTokenCapacity(),
|
|
223
|
-
canAcceptMore: this.getRemainingTokenCapacity() > this.reserveTokens
|
|
246
|
+
canAcceptMore: this.getRemainingTokenCapacity() > this.reserveTokens,
|
|
224
247
|
};
|
|
225
248
|
}
|
|
226
249
|
|
|
@@ -231,4 +254,4 @@ export class MemoryWindow {
|
|
|
231
254
|
this.clear();
|
|
232
255
|
this.tokenCounter.dispose();
|
|
233
256
|
}
|
|
234
|
-
}
|
|
257
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { BaseMessage } from '@langchain/core/messages';
|
|
2
|
+
import { SystemMessage } from '@langchain/core/messages';
|
|
2
3
|
import { Logger } from '@hashgraphonline/standards-sdk';
|
|
3
|
-
import { MemoryWindow } from './
|
|
4
|
-
import { ContentStorage } from './
|
|
5
|
-
import { TokenCounter } from './
|
|
4
|
+
import { MemoryWindow } from './memory-window';
|
|
5
|
+
import { ContentStorage } from './content-storage';
|
|
6
|
+
import { TokenCounter } from './token-counter';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Entity association for storing blockchain entity contexts
|
|
@@ -78,7 +79,6 @@ export interface MemoryStats {
|
|
|
78
79
|
|
|
79
80
|
const IS_ENTITY_ASSOCIATION_FLAG = '"isEntityAssociation":true';
|
|
80
81
|
|
|
81
|
-
|
|
82
82
|
/**
|
|
83
83
|
* TODO: investigate using chroma / rag for long term memory
|
|
84
84
|
* Smart memory manager that combines active memory window with long-term storage
|
|
@@ -412,19 +412,36 @@ export class SmartMemoryManager {
|
|
|
412
412
|
const sanitizedEntityName = entityName.trim().substring(0, 100);
|
|
413
413
|
const sanitizedEntityType = entityType.trim().toLowerCase();
|
|
414
414
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
415
|
+
let usageHint = '';
|
|
416
|
+
if (sanitizedEntityType === 'tokenid') {
|
|
417
|
+
usageHint = 'Use this as tokenId for HTS operations';
|
|
418
|
+
} else if (sanitizedEntityType === 'topicid') {
|
|
419
|
+
usageHint =
|
|
420
|
+
'Can be used for HCS operations, HRLs for minting with the format hcs://1/<topicId>, etc.';
|
|
421
|
+
} else if (sanitizedEntityType === 'accountid') {
|
|
422
|
+
usageHint = 'Can be used for account based operations';
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
const association: EntityAssociation & {
|
|
426
|
+
isEntityAssociation: boolean;
|
|
427
|
+
usage?: string;
|
|
428
|
+
hrl?: string;
|
|
429
|
+
} = {
|
|
430
|
+
entityId: sanitizedEntityId,
|
|
431
|
+
entityName: sanitizedEntityName,
|
|
432
|
+
entityType: sanitizedEntityType,
|
|
433
|
+
createdAt: new Date(),
|
|
434
|
+
isEntityAssociation: true,
|
|
435
|
+
...(usageHint ? { usage: usageHint } : {}),
|
|
436
|
+
...(sanitizedEntityType === 'topicid'
|
|
437
|
+
? { hrl: `hcs://1/${sanitizedEntityId}` }
|
|
438
|
+
: {}),
|
|
439
|
+
...(transactionId !== undefined &&
|
|
440
|
+
transactionId !== null &&
|
|
441
|
+
transactionId.trim() !== ''
|
|
442
|
+
? { transactionId: transactionId.trim() }
|
|
443
|
+
: {}),
|
|
444
|
+
};
|
|
428
445
|
|
|
429
446
|
const content = JSON.stringify(association);
|
|
430
447
|
type LangChainLikeMessage = {
|
|
@@ -448,13 +465,17 @@ export class SmartMemoryManager {
|
|
|
448
465
|
},
|
|
449
466
|
};
|
|
450
467
|
|
|
468
|
+
try {
|
|
469
|
+
this.memoryWindow.addMessage(new SystemMessage(content));
|
|
470
|
+
} catch {}
|
|
471
|
+
|
|
451
472
|
this._contentStorage.storeMessages([entityMessage as BaseMessage]);
|
|
452
473
|
} catch (error) {
|
|
453
474
|
this.logger.error('Failed to store entity association', {
|
|
454
475
|
entityId,
|
|
455
476
|
entityName,
|
|
456
477
|
entityType,
|
|
457
|
-
error: error instanceof Error ? error.message : String(error)
|
|
478
|
+
error: error instanceof Error ? error.message : String(error),
|
|
458
479
|
});
|
|
459
480
|
}
|
|
460
481
|
}
|
|
@@ -577,7 +598,7 @@ export class SmartMemoryManager {
|
|
|
577
598
|
this.logger.error('Failed to resolve entity reference', {
|
|
578
599
|
query,
|
|
579
600
|
options,
|
|
580
|
-
error: error instanceof Error ? error.message : String(error)
|
|
601
|
+
error: error instanceof Error ? error.message : String(error),
|
|
581
602
|
});
|
|
582
603
|
return [];
|
|
583
604
|
}
|
|
@@ -633,8 +654,14 @@ export class SmartMemoryManager {
|
|
|
633
654
|
}
|
|
634
655
|
} catch (parseError) {
|
|
635
656
|
this.logger.warn('Failed to parse entity association from message', {
|
|
636
|
-
messageContent:
|
|
637
|
-
|
|
657
|
+
messageContent:
|
|
658
|
+
typeof message.content === 'string'
|
|
659
|
+
? message.content.substring(0, 100)
|
|
660
|
+
: 'non-string',
|
|
661
|
+
error:
|
|
662
|
+
parseError instanceof Error
|
|
663
|
+
? parseError.message
|
|
664
|
+
: String(parseError),
|
|
638
665
|
});
|
|
639
666
|
continue;
|
|
640
667
|
}
|
|
@@ -657,7 +684,7 @@ export class SmartMemoryManager {
|
|
|
657
684
|
} catch (error) {
|
|
658
685
|
this.logger.error('Failed to get entity associations', {
|
|
659
686
|
entityType,
|
|
660
|
-
error: error instanceof Error ? error.message : String(error)
|
|
687
|
+
error: error instanceof Error ? error.message : String(error),
|
|
661
688
|
});
|
|
662
689
|
return [];
|
|
663
690
|
}
|
|
@@ -22,6 +22,41 @@ import {
|
|
|
22
22
|
} from '@hashgraphonline/standards-agent-kit';
|
|
23
23
|
import { HCS10Client } from '@hashgraphonline/standards-sdk';
|
|
24
24
|
|
|
25
|
+
interface HCS10ClientManager {
|
|
26
|
+
initializeConnectionsManager(client: HCS10Client): void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Extracts private key string from operator key
|
|
31
|
+
*/
|
|
32
|
+
function extractPrivateKey(opKey: unknown): string {
|
|
33
|
+
const key = opKey as {
|
|
34
|
+
toString?: () => string;
|
|
35
|
+
toStringRaw?: () => string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
if (typeof key?.toStringRaw === 'function') {
|
|
39
|
+
return key.toStringRaw();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (typeof key?.toString === 'function') {
|
|
43
|
+
return key.toString();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return String(key);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function hasInitializeConnectionsManager(
|
|
50
|
+
stateManager: IStateManager
|
|
51
|
+
): stateManager is IStateManager & HCS10ClientManager {
|
|
52
|
+
return (
|
|
53
|
+
typeof stateManager === 'object' &&
|
|
54
|
+
stateManager !== null &&
|
|
55
|
+
'initializeConnectionsManager' in stateManager &&
|
|
56
|
+
typeof stateManager.initializeConnectionsManager === 'function'
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
25
60
|
export class HCS10Plugin extends BasePlugin {
|
|
26
61
|
id = 'hcs-10';
|
|
27
62
|
name = 'HCS-10 Plugin';
|
|
@@ -58,15 +93,8 @@ export class HCS10Plugin extends BasePlugin {
|
|
|
58
93
|
let outboundTopicId = '';
|
|
59
94
|
|
|
60
95
|
try {
|
|
61
|
-
const opKey = hederaKit.signer.getOperatorPrivateKey()
|
|
62
|
-
|
|
63
|
-
toStringRaw?: () => string;
|
|
64
|
-
};
|
|
65
|
-
const privateKey = typeof opKey?.toStringRaw === 'function'
|
|
66
|
-
? opKey.toStringRaw()
|
|
67
|
-
: typeof opKey?.toString === 'function'
|
|
68
|
-
? opKey.toString()
|
|
69
|
-
: String(opKey);
|
|
96
|
+
const opKey = hederaKit.signer.getOperatorPrivateKey();
|
|
97
|
+
const privateKey = extractPrivateKey(opKey);
|
|
70
98
|
|
|
71
99
|
const hcs10Client = new HCS10Client({
|
|
72
100
|
network: hederaKit.network as 'mainnet' | 'testnet',
|
|
@@ -93,15 +121,8 @@ export class HCS10Plugin extends BasePlugin {
|
|
|
93
121
|
inboundTopicId,
|
|
94
122
|
outboundTopicId,
|
|
95
123
|
privateKey: ((): string => {
|
|
96
|
-
const opKey = hederaKit.signer.getOperatorPrivateKey()
|
|
97
|
-
|
|
98
|
-
toStringRaw?: () => string;
|
|
99
|
-
};
|
|
100
|
-
return typeof opKey?.toStringRaw === 'function'
|
|
101
|
-
? opKey.toStringRaw()
|
|
102
|
-
: typeof opKey?.toString === 'function'
|
|
103
|
-
? opKey.toString()
|
|
104
|
-
: String(opKey);
|
|
124
|
+
const opKey = hederaKit.signer.getOperatorPrivateKey();
|
|
125
|
+
return extractPrivateKey(opKey);
|
|
105
126
|
})(),
|
|
106
127
|
});
|
|
107
128
|
|
|
@@ -111,15 +132,8 @@ export class HCS10Plugin extends BasePlugin {
|
|
|
111
132
|
|
|
112
133
|
if (this.stateManager && !this.stateManager.getConnectionsManager()) {
|
|
113
134
|
try {
|
|
114
|
-
const opKey = hederaKit.signer.getOperatorPrivateKey()
|
|
115
|
-
|
|
116
|
-
toStringRaw?: () => string;
|
|
117
|
-
};
|
|
118
|
-
const privateKey = typeof opKey?.toStringRaw === 'function'
|
|
119
|
-
? opKey.toStringRaw()
|
|
120
|
-
: typeof opKey?.toString === 'function'
|
|
121
|
-
? opKey.toString()
|
|
122
|
-
: String(opKey);
|
|
135
|
+
const opKey = hederaKit.signer.getOperatorPrivateKey();
|
|
136
|
+
const privateKey = extractPrivateKey(opKey);
|
|
123
137
|
const hcs10Client = new HCS10Client({
|
|
124
138
|
network: hederaKit.network as 'mainnet' | 'testnet',
|
|
125
139
|
operatorId: accountId,
|
|
@@ -127,7 +141,11 @@ export class HCS10Plugin extends BasePlugin {
|
|
|
127
141
|
logLevel: 'error',
|
|
128
142
|
});
|
|
129
143
|
|
|
130
|
-
this.stateManager
|
|
144
|
+
if (hasInitializeConnectionsManager(this.stateManager)) {
|
|
145
|
+
this.stateManager.initializeConnectionsManager(hcs10Client);
|
|
146
|
+
} else {
|
|
147
|
+
this.context.logger.warn('StateManager does not support connection manager initialization');
|
|
148
|
+
}
|
|
131
149
|
this.context.logger.info(
|
|
132
150
|
'ConnectionsManager initialized in HCS10Plugin'
|
|
133
151
|
);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { examples } from '../examples/external-tool-wrapper-example';
|
|
7
7
|
|
|
8
|
-
async function testExternalToolWrapper() {
|
|
8
|
+
async function testExternalToolWrapper(): Promise<void> {
|
|
9
9
|
console.log('🧪 Testing External Tool Wrapper\n');
|
|
10
10
|
|
|
11
11
|
try {
|
|
@@ -23,7 +23,7 @@ async function testExternalToolWrapper() {
|
|
|
23
23
|
memo: 'Test transfer'
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
const result = await (basicTool as
|
|
26
|
+
const result = await (basicTool as { _call: (input: unknown) => Promise<string> })._call(testInput);
|
|
27
27
|
console.log(` Execution result: ${result}\n`);
|
|
28
28
|
|
|
29
29
|
console.log('📝 Test 2: Preset configurations');
|
|
@@ -47,10 +47,10 @@ async function testExternalToolWrapper() {
|
|
|
47
47
|
const incompleteInput = {
|
|
48
48
|
fromAccountId: '0.0.123'
|
|
49
49
|
|
|
50
|
-
} as
|
|
50
|
+
} as { fromAccountId: string };
|
|
51
51
|
|
|
52
52
|
try {
|
|
53
|
-
const formResult = await (formTool as
|
|
53
|
+
const formResult = await (formTool as { _call: (input: unknown) => Promise<string> })._call(incompleteInput);
|
|
54
54
|
const parsedResult = JSON.parse(formResult);
|
|
55
55
|
if (parsedResult.requiresForm) {
|
|
56
56
|
console.log(` ✅ Form generation triggered for missing fields`);
|
|
@@ -68,11 +68,11 @@ async function testExternalToolWrapper() {
|
|
|
68
68
|
console.log(`✅ Tool "${customTool.name}" wrapped with custom configs`);
|
|
69
69
|
console.log(` Description: ${customTool.description}`);
|
|
70
70
|
|
|
71
|
-
const schema = customTool.schema as
|
|
71
|
+
const schema = customTool.schema as { _def: { shape: () => Record<string, { _renderConfig?: unknown }> } };
|
|
72
72
|
const shape = schema._def.shape();
|
|
73
73
|
let fieldConfigCount = 0;
|
|
74
74
|
for (const [, fieldSchema] of Object.entries(shape)) {
|
|
75
|
-
if (
|
|
75
|
+
if (fieldSchema._renderConfig) {
|
|
76
76
|
fieldConfigCount++;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -17,6 +17,7 @@ import dotenv from 'dotenv';
|
|
|
17
17
|
import { ConversationalAgent } from '../conversational-agent';
|
|
18
18
|
import type { ChatResponse } from '../base-agent';
|
|
19
19
|
import type { FormMessage } from '../forms/types';
|
|
20
|
+
import { NetworkType } from '@hashgraphonline/standards-sdk';
|
|
20
21
|
|
|
21
22
|
dotenv.config();
|
|
22
23
|
|
|
@@ -65,7 +66,7 @@ async function createTestAgent(): Promise<ConversationalAgent> {
|
|
|
65
66
|
const options = {
|
|
66
67
|
accountId: process.env.HEDERA_OPERATOR_ID!,
|
|
67
68
|
privateKey: process.env.HEDERA_OPERATOR_KEY!,
|
|
68
|
-
network: (process.env.HEDERA_NETWORK as
|
|
69
|
+
network: (process.env.HEDERA_NETWORK as NetworkType) || NetworkType.TESTNET,
|
|
69
70
|
openAIApiKey: process.env.OPENAI_API_KEY!,
|
|
70
71
|
openAIModelName: 'gpt-4o-mini',
|
|
71
72
|
verbose: true, // Enable verbose for debugging
|
|
@@ -87,11 +88,11 @@ async function testDirectToolAccess(agent: ConversationalAgent): Promise<FormGen
|
|
|
87
88
|
|
|
88
89
|
try {
|
|
89
90
|
const underlyingAgent = agent.getAgent();
|
|
90
|
-
const tools = (underlyingAgent as
|
|
91
|
+
const tools = (underlyingAgent as unknown as { tools: Array<{ name: string; constructor: { name: string }; _call: (input: unknown) => Promise<string> }> }).tools;
|
|
91
92
|
|
|
92
|
-
console.log('Available tools:', tools.map(
|
|
93
|
+
console.log('Available tools:', tools.map(t => t.name));
|
|
93
94
|
|
|
94
|
-
const inscribeHashinalTool = tools.find(
|
|
95
|
+
const inscribeHashinalTool = tools.find(t => t.name === 'inscribeHashinal');
|
|
95
96
|
|
|
96
97
|
if (!inscribeHashinalTool) {
|
|
97
98
|
console.log('❌ InscribeHashinal tool not found in tools array');
|
|
@@ -114,7 +115,7 @@ async function testDirectToolAccess(agent: ConversationalAgent): Promise<FormGen
|
|
|
114
115
|
};
|
|
115
116
|
|
|
116
117
|
console.log('🧪 Calling tool directly with incomplete input...');
|
|
117
|
-
const result = await
|
|
118
|
+
const result = await inscribeHashinalTool._call(incompleteInput);
|
|
118
119
|
|
|
119
120
|
console.log('📋 Direct tool call result:', {
|
|
120
121
|
resultType: typeof result,
|
|
@@ -128,20 +129,20 @@ async function testDirectToolAccess(agent: ConversationalAgent): Promise<FormGen
|
|
|
128
129
|
console.log('🎉 Form generated by direct tool call!');
|
|
129
130
|
const formMessage = parsed.formMessage;
|
|
130
131
|
|
|
131
|
-
const formConfig = (formMessage as
|
|
132
|
+
const formConfig = (formMessage as { formConfig?: { fields?: Array<{ name: string; type: string }> } }).formConfig;
|
|
132
133
|
const attributesField = formConfig?.fields?.find(
|
|
133
|
-
|
|
134
|
+
field => field.name === 'attributes'
|
|
134
135
|
);
|
|
135
136
|
|
|
136
137
|
const hasAttributesField = !!attributesField;
|
|
137
138
|
|
|
138
139
|
console.log('📝 Form analysis (direct call):', {
|
|
139
|
-
formId: (formMessage as
|
|
140
|
-
toolName: (formMessage as
|
|
140
|
+
formId: (formMessage as { id?: string }).id,
|
|
141
|
+
toolName: (formMessage as { toolName?: string }).toolName,
|
|
141
142
|
fieldCount: formConfig?.fields?.length || 0,
|
|
142
143
|
hasAttributesField,
|
|
143
144
|
attributesFieldType: attributesField?.type,
|
|
144
|
-
fieldsPresent: formConfig?.fields?.map(
|
|
145
|
+
fieldsPresent: formConfig?.fields?.map(f => f.name) || []
|
|
145
146
|
});
|
|
146
147
|
|
|
147
148
|
return {
|
|
@@ -214,20 +215,20 @@ async function testInscribeFormGeneration(agent: ConversationalAgent): Promise<F
|
|
|
214
215
|
console.log('📝 Found form in tool call output!');
|
|
215
216
|
const formMessage = parsed.formMessage;
|
|
216
217
|
|
|
217
|
-
const formConfig = (formMessage as
|
|
218
|
+
const formConfig = (formMessage as { formConfig?: { fields?: Array<{ name: string; type: string }> } }).formConfig;
|
|
218
219
|
const attributesField = formConfig?.fields?.find(
|
|
219
|
-
|
|
220
|
+
field => field.name === 'attributes'
|
|
220
221
|
);
|
|
221
222
|
|
|
222
223
|
const hasAttributesField = !!attributesField;
|
|
223
224
|
|
|
224
225
|
console.log('📝 Form analysis:', {
|
|
225
|
-
formId: (formMessage as
|
|
226
|
-
toolName: (formMessage as
|
|
226
|
+
formId: (formMessage as { id?: string }).id,
|
|
227
|
+
toolName: (formMessage as { toolName?: string }).toolName,
|
|
227
228
|
fieldCount: formConfig?.fields?.length || 0,
|
|
228
229
|
hasAttributesField,
|
|
229
230
|
attributesFieldType: attributesField?.type,
|
|
230
|
-
fieldsPresent: formConfig?.fields?.map(
|
|
231
|
+
fieldsPresent: formConfig?.fields?.map(f => f.name) || []
|
|
231
232
|
});
|
|
232
233
|
|
|
233
234
|
return {
|
|
@@ -237,7 +238,7 @@ async function testInscribeFormGeneration(agent: ConversationalAgent): Promise<F
|
|
|
237
238
|
originalResponse: response
|
|
238
239
|
};
|
|
239
240
|
}
|
|
240
|
-
} catch {
|
|
241
|
+
} catch (parseError) {
|
|
241
242
|
console.log('Could not parse tool output as JSON:', parseError);
|
|
242
243
|
}
|
|
243
244
|
}
|
|
@@ -247,20 +248,20 @@ async function testInscribeFormGeneration(agent: ConversationalAgent): Promise<F
|
|
|
247
248
|
if (response.requiresForm && response.formMessage) {
|
|
248
249
|
const formMessage = response.formMessage;
|
|
249
250
|
|
|
250
|
-
const formConfig = (formMessage as
|
|
251
|
+
const formConfig = (formMessage as { formConfig?: { fields?: Array<{ name: string; type: string }> } }).formConfig;
|
|
251
252
|
const attributesField = formConfig?.fields?.find(
|
|
252
|
-
|
|
253
|
+
field => field.name === 'attributes'
|
|
253
254
|
);
|
|
254
255
|
|
|
255
256
|
const hasAttributesField = !!attributesField;
|
|
256
257
|
|
|
257
258
|
console.log('📝 Form analysis (top-level):', {
|
|
258
|
-
formId: (formMessage as
|
|
259
|
-
toolName: (formMessage as
|
|
259
|
+
formId: (formMessage as { id?: string }).id,
|
|
260
|
+
toolName: (formMessage as { toolName?: string }).toolName,
|
|
260
261
|
fieldCount: formConfig?.fields?.length || 0,
|
|
261
262
|
hasAttributesField,
|
|
262
263
|
attributesFieldType: attributesField?.type,
|
|
263
|
-
fieldsPresent: formConfig?.fields?.map(
|
|
264
|
+
fieldsPresent: formConfig?.fields?.map(f => f.name) || []
|
|
264
265
|
});
|
|
265
266
|
|
|
266
267
|
return {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import dotenv from 'dotenv';
|
|
15
15
|
import { ConversationalAgent } from '../conversational-agent';
|
|
16
|
+
import { NetworkType } from '@hashgraphonline/standards-sdk';
|
|
16
17
|
|
|
17
18
|
dotenv.config();
|
|
18
19
|
|
|
@@ -60,7 +61,7 @@ async function createTestAgent(): Promise<ConversationalAgent> {
|
|
|
60
61
|
const options = {
|
|
61
62
|
accountId: process.env.HEDERA_OPERATOR_ID!,
|
|
62
63
|
privateKey: process.env.HEDERA_OPERATOR_KEY!,
|
|
63
|
-
network: (process.env.HEDERA_NETWORK as
|
|
64
|
+
network: (process.env.HEDERA_NETWORK as NetworkType) || NetworkType.TESTNET,
|
|
64
65
|
openAIApiKey: process.env.OPENAI_API_KEY!,
|
|
65
66
|
openAIModelName: 'gpt-4o-mini',
|
|
66
67
|
verbose: false, // Reduce verbosity
|
|
@@ -82,12 +83,12 @@ async function testInscribeHashinalWrapper(agent: ConversationalAgent): Promise<
|
|
|
82
83
|
|
|
83
84
|
try {
|
|
84
85
|
const underlyingAgent = agent.getAgent();
|
|
85
|
-
const tools = (underlyingAgent as
|
|
86
|
+
const tools = (underlyingAgent as unknown as { tools: Array<{ name: string; constructor: { name: string }; schema?: { _renderConfig?: unknown } }> }).tools;
|
|
86
87
|
|
|
87
88
|
const toolsCount = tools.length;
|
|
88
89
|
console.log(`📊 Total tools loaded: ${toolsCount}`);
|
|
89
90
|
|
|
90
|
-
const inscribeHashinalTool = tools.find(
|
|
91
|
+
const inscribeHashinalTool = tools.find(t => t.name === 'inscribeHashinal');
|
|
91
92
|
|
|
92
93
|
if (!inscribeHashinalTool) {
|
|
93
94
|
return {
|
|
@@ -103,7 +104,7 @@ async function testInscribeHashinalWrapper(agent: ConversationalAgent): Promise<
|
|
|
103
104
|
|
|
104
105
|
const toolType = inscribeHashinalTool.constructor.name;
|
|
105
106
|
const isFormValidatingWrapper = toolType === 'FormValidatingToolWrapper';
|
|
106
|
-
const hasRenderConfig = !!
|
|
107
|
+
const hasRenderConfig = !!inscribeHashinalTool.schema?._renderConfig;
|
|
107
108
|
|
|
108
109
|
console.log('🔧 InscribeHashinal tool analysis:', {
|
|
109
110
|
name: inscribeHashinalTool.name,
|