@hashgraphonline/conversational-agent 0.2.107 → 0.2.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -27
- package/dist/cjs/config/system-message.d.ts +1 -1
- package/dist/cjs/conversational-agent.d.ts +16 -0
- package/dist/cjs/core/tool-registry.d.ts +26 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/mcp/types.d.ts +1 -1
- package/dist/cjs/services/attachment-processor.d.ts +1 -2
- package/dist/cjs/services/content-store-manager.d.ts +1 -1
- package/dist/cjs/services/formatters/types.d.ts +3 -1
- package/dist/cjs/services/index.d.ts +1 -1
- package/dist/esm/index15.js +2 -2
- package/dist/esm/index15.js.map +1 -1
- package/dist/esm/index2.js +33 -39
- package/dist/esm/index2.js.map +1 -1
- package/dist/esm/index21.js.map +1 -1
- package/dist/esm/index23.js +2 -2
- package/dist/esm/index24.js.map +1 -1
- package/dist/esm/index26.js.map +1 -1
- package/dist/esm/index30.js.map +1 -1
- package/dist/esm/index4.js +1 -1
- package/dist/esm/index4.js.map +1 -1
- package/dist/esm/index40.js +2 -2
- package/dist/esm/index40.js.map +1 -1
- package/dist/esm/index43.js +52 -1
- package/dist/esm/index43.js.map +1 -1
- package/dist/esm/index47.js +1 -1
- package/dist/esm/index47.js.map +1 -1
- package/dist/esm/index6.js +75 -17
- package/dist/esm/index6.js.map +1 -1
- package/dist/types/config/system-message.d.ts +1 -1
- package/dist/types/conversational-agent.d.ts +16 -0
- package/dist/types/core/tool-registry.d.ts +26 -0
- package/dist/types/mcp/types.d.ts +1 -1
- package/dist/types/services/attachment-processor.d.ts +1 -2
- package/dist/types/services/content-store-manager.d.ts +1 -1
- package/dist/types/services/formatters/types.d.ts +3 -1
- package/dist/types/services/index.d.ts +1 -1
- package/package.json +12 -10
- package/src/config/system-message.ts +3 -3
- package/src/conversational-agent.ts +164 -56
- package/src/core/tool-registry.ts +61 -0
- package/src/mcp/mcp-client-manager.ts +2 -2
- package/src/mcp/types.ts +1 -1
- package/src/memory/content-storage.ts +19 -6
- package/src/plugins/hbar/AccountBuilder.ts +1 -1
- package/src/plugins/hcs-10/HCS10Plugin.ts +50 -52
- package/src/plugins/inscribe/InscribePlugin.ts +1 -1
- package/src/services/attachment-processor.ts +1 -1
- package/src/services/content-store-manager.ts +1 -1
- package/src/services/formatters/types.ts +3 -1
- package/src/services/index.ts +1 -1
|
@@ -19,33 +19,15 @@ import {
|
|
|
19
19
|
AcceptConnectionRequestTool,
|
|
20
20
|
RetrieveProfileTool,
|
|
21
21
|
ListUnapprovedConnectionRequestsTool,
|
|
22
|
+
RegisteredAgent,
|
|
22
23
|
} from '@hashgraphonline/standards-agent-kit';
|
|
23
24
|
import { HCS10Client } from '@hashgraphonline/standards-sdk';
|
|
25
|
+
import { PrivateKey } from 'node_modules/@hashgraph/sdk/lib/Mnemonic';
|
|
24
26
|
|
|
25
27
|
interface HCS10ClientManager {
|
|
26
28
|
initializeConnectionsManager(client: HCS10Client): void;
|
|
27
29
|
}
|
|
28
30
|
|
|
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
31
|
function hasInitializeConnectionsManager(
|
|
50
32
|
stateManager: IStateManager
|
|
51
33
|
): stateManager is IStateManager & HCS10ClientManager {
|
|
@@ -89,30 +71,40 @@ export class HCS10Plugin extends BasePlugin {
|
|
|
89
71
|
new OpenConvaiState();
|
|
90
72
|
|
|
91
73
|
const accountId = hederaKit.signer.getAccountId().toString();
|
|
92
|
-
const isBytesMode =
|
|
74
|
+
const isBytesMode =
|
|
75
|
+
String(hederaKit.operationalMode || 'returnBytes') === 'returnBytes';
|
|
93
76
|
let inboundTopicId = '';
|
|
94
77
|
let outboundTopicId = '';
|
|
95
78
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
79
|
+
let operatorPrivateKeyRef: PrivateKey =
|
|
80
|
+
hederaKit.signer.getOperatorPrivateKey();
|
|
81
|
+
let operatorPrivateKeySerialized: string | undefined;
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
const resolved =
|
|
85
|
+
typeof operatorPrivateKeyRef?.toString === 'function'
|
|
86
|
+
? operatorPrivateKeyRef.toString()
|
|
87
|
+
: '';
|
|
88
|
+
|
|
89
|
+
operatorPrivateKeySerialized = resolved;
|
|
90
|
+
|
|
91
|
+
const hcs10Client = new HCS10Client({
|
|
92
|
+
network: hederaKit.network as 'mainnet' | 'testnet',
|
|
93
|
+
operatorId: accountId,
|
|
94
|
+
operatorPrivateKey: operatorPrivateKeyRef,
|
|
95
|
+
logLevel: 'error',
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const profileResponse = await hcs10Client.retrieveProfile(accountId);
|
|
99
|
+
if (profileResponse.success && profileResponse.topicInfo) {
|
|
100
|
+
inboundTopicId = profileResponse.topicInfo.inboundTopic;
|
|
101
|
+
outboundTopicId = profileResponse.topicInfo.outboundTopic;
|
|
115
102
|
}
|
|
103
|
+
} catch (profileError) {
|
|
104
|
+
this.context.logger.warn(
|
|
105
|
+
'Skipping profile topic discovery',
|
|
106
|
+
profileError
|
|
107
|
+
);
|
|
116
108
|
}
|
|
117
109
|
|
|
118
110
|
const agentRecord: Record<string, unknown> = {
|
|
@@ -121,39 +113,45 @@ export class HCS10Plugin extends BasePlugin {
|
|
|
121
113
|
inboundTopicId,
|
|
122
114
|
outboundTopicId,
|
|
123
115
|
};
|
|
124
|
-
if (!isBytesMode) {
|
|
125
|
-
|
|
126
|
-
const opKey = hederaKit.signer.getOperatorPrivateKey();
|
|
127
|
-
agentRecord.privateKey = extractPrivateKey(opKey);
|
|
128
|
-
} catch {}
|
|
116
|
+
if (!isBytesMode && operatorPrivateKeySerialized) {
|
|
117
|
+
agentRecord.privateKey = operatorPrivateKeySerialized;
|
|
129
118
|
}
|
|
130
|
-
this.stateManager.setCurrentAgent(
|
|
119
|
+
this.stateManager.setCurrentAgent(
|
|
120
|
+
agentRecord as unknown as RegisteredAgent
|
|
121
|
+
);
|
|
131
122
|
|
|
132
123
|
this.context.logger.info(
|
|
133
124
|
`Set current agent: ${accountId} with topics ${inboundTopicId}/${outboundTopicId}`
|
|
134
125
|
);
|
|
135
126
|
|
|
136
|
-
if (
|
|
127
|
+
if (
|
|
128
|
+
!isBytesMode &&
|
|
129
|
+
this.stateManager &&
|
|
130
|
+
!this.stateManager.getConnectionsManager()
|
|
131
|
+
) {
|
|
137
132
|
try {
|
|
138
|
-
const opKey = hederaKit.signer.getOperatorPrivateKey();
|
|
139
|
-
const privateKey = extractPrivateKey(opKey);
|
|
140
133
|
const hcs10Client = new HCS10Client({
|
|
141
134
|
network: hederaKit.network as 'mainnet' | 'testnet',
|
|
142
135
|
operatorId: accountId,
|
|
143
|
-
operatorPrivateKey:
|
|
136
|
+
operatorPrivateKey: operatorPrivateKeyRef ?? '',
|
|
144
137
|
logLevel: 'error',
|
|
145
138
|
});
|
|
146
139
|
|
|
147
140
|
if (hasInitializeConnectionsManager(this.stateManager)) {
|
|
148
141
|
this.stateManager.initializeConnectionsManager(hcs10Client);
|
|
149
142
|
} else {
|
|
150
|
-
this.context.logger.warn(
|
|
143
|
+
this.context.logger.warn(
|
|
144
|
+
'StateManager does not support connection manager initialization'
|
|
145
|
+
);
|
|
151
146
|
}
|
|
152
147
|
this.context.logger.info(
|
|
153
148
|
'ConnectionsManager initialized in HCS10Plugin'
|
|
154
149
|
);
|
|
155
150
|
} catch (cmError) {
|
|
156
|
-
this.context.logger.warn(
|
|
151
|
+
this.context.logger.warn(
|
|
152
|
+
'Could not initialize ConnectionsManager:',
|
|
153
|
+
cmError
|
|
154
|
+
);
|
|
157
155
|
}
|
|
158
156
|
}
|
|
159
157
|
|
|
@@ -138,7 +138,7 @@ export class ContentStoreManager {
|
|
|
138
138
|
private adapter: ContentStorageAdapter;
|
|
139
139
|
private resolver: ContentResolver;
|
|
140
140
|
private logger: Logger;
|
|
141
|
-
|
|
141
|
+
protected isRegistered = false;
|
|
142
142
|
|
|
143
143
|
constructor(
|
|
144
144
|
maxMessageStorage: number = 1000,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { NetworkType } from '@hashgraphonline/standards-sdk';
|
|
2
|
+
|
|
1
3
|
export enum EntityFormat {
|
|
2
4
|
TOPIC_ID = 'topicId',
|
|
3
5
|
HRL = 'hrl',
|
|
@@ -16,7 +18,7 @@ export enum EntityFormat {
|
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
export interface ConversionContext {
|
|
19
|
-
networkType?:
|
|
21
|
+
networkType?: NetworkType;
|
|
20
22
|
sessionId?: string;
|
|
21
23
|
toolName?: string;
|
|
22
24
|
toolPreferences?: Record<string, string>;
|
package/src/services/index.ts
CHANGED
|
@@ -2,4 +2,4 @@ export * from './entity-resolver';
|
|
|
2
2
|
export * from './content-store-manager';
|
|
3
3
|
export * from './formatters';
|
|
4
4
|
export * from './parameter-service';
|
|
5
|
-
export
|
|
5
|
+
export { AttachmentProcessor, type AttachmentData } from './attachment-processor';
|