@hashgraphonline/conversational-agent 0.1.218 → 0.1.220
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/dist/cjs/base-agent.d.ts +2 -0
- package/dist/cjs/core/tool-registry.d.ts +7 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/langchain/form-aware-agent-executor.d.ts +14 -3
- package/dist/cjs/langchain/form-validating-tool-wrapper.d.ts +81 -0
- package/dist/cjs/langchain/index.d.ts +1 -0
- package/dist/esm/index.js +7 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index10.js +2 -2
- package/dist/esm/index21.js +1 -1
- package/dist/esm/index23.js +3 -3
- package/dist/esm/index25.js +0 -4
- package/dist/esm/index25.js.map +1 -1
- package/dist/esm/index29.js +78 -9
- package/dist/esm/index29.js.map +1 -1
- package/dist/esm/index30.js +184 -1215
- package/dist/esm/index30.js.map +1 -1
- package/dist/esm/index31.js +1193 -116
- package/dist/esm/index31.js.map +1 -1
- package/dist/esm/index32.js +120 -99
- package/dist/esm/index32.js.map +1 -1
- package/dist/esm/index33.js +106 -38
- package/dist/esm/index33.js.map +1 -1
- package/dist/esm/index34.js +41 -98
- package/dist/esm/index34.js.map +1 -1
- package/dist/esm/index35.js +103 -21
- package/dist/esm/index35.js.map +1 -1
- package/dist/esm/index36.js +21 -12
- package/dist/esm/index36.js.map +1 -1
- package/dist/esm/index37.js +11 -6
- package/dist/esm/index37.js.map +1 -1
- package/dist/esm/index38.js +6 -4
- package/dist/esm/index38.js.map +1 -1
- package/dist/esm/index39.js +5 -224
- package/dist/esm/index39.js.map +1 -1
- package/dist/esm/index40.js +213 -142
- package/dist/esm/index40.js.map +1 -1
- package/dist/esm/index41.js +181 -24
- package/dist/esm/index41.js.map +1 -1
- package/dist/esm/index42.js +24 -89
- package/dist/esm/index42.js.map +1 -1
- package/dist/esm/index43.js +95 -0
- package/dist/esm/index43.js.map +1 -0
- package/dist/esm/index5.js +2 -2
- package/dist/esm/index6.js +3 -7
- package/dist/esm/index6.js.map +1 -1
- package/dist/esm/index7.js.map +1 -1
- package/dist/esm/index8.js +1 -1
- package/dist/types/base-agent.d.ts +2 -0
- package/dist/types/core/tool-registry.d.ts +7 -0
- package/dist/types/langchain/form-aware-agent-executor.d.ts +14 -3
- package/dist/types/langchain/form-validating-tool-wrapper.d.ts +81 -0
- package/dist/types/langchain/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/base-agent.ts +4 -0
- package/src/conversational-agent.ts +3 -14
- package/src/core/tool-registry.ts +45 -1
- package/src/langchain/form-aware-agent-executor.ts +219 -80
- package/src/langchain/form-validating-tool-wrapper.ts +356 -0
- package/src/langchain/index.ts +1 -0
- package/src/langchain/langchain-agent.ts +24 -104
- package/src/services/formatters/format-converter-registry.ts +0 -5
package/dist/esm/index33.js
CHANGED
|
@@ -1,49 +1,117 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
class ResponseFormatter {
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a parsed response contains HashLink block data for interactive rendering
|
|
4
|
+
*/
|
|
5
|
+
static isHashLinkResponse(parsed) {
|
|
6
|
+
if (!parsed || typeof parsed !== "object") {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
const responseObj = parsed;
|
|
10
|
+
return !!(responseObj.success === true && responseObj.type === "inscription" && responseObj.hashLinkBlock && typeof responseObj.hashLinkBlock === "object");
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Formats HashLink block response with simple text confirmation
|
|
14
|
+
* HTML template rendering is handled by HashLinkBlockRenderer component via metadata
|
|
15
|
+
*/
|
|
16
|
+
static formatHashLinkResponse(parsed) {
|
|
17
|
+
const hashLinkBlock = parsed.hashLinkBlock;
|
|
18
|
+
const metadata = parsed.metadata || {};
|
|
19
|
+
const inscription = parsed.inscription || {};
|
|
20
|
+
let message = "✅ Interactive content created successfully!\n\n";
|
|
21
|
+
if (metadata.name) {
|
|
22
|
+
message += `**${metadata.name}**
|
|
23
|
+
`;
|
|
24
|
+
}
|
|
25
|
+
if (metadata.description) {
|
|
26
|
+
message += `${metadata.description}
|
|
27
|
+
|
|
28
|
+
`;
|
|
29
|
+
}
|
|
30
|
+
if (inscription.topicId || hashLinkBlock.attributes.topicId) {
|
|
31
|
+
message += `📍 **Topic ID:** ${inscription.topicId || hashLinkBlock.attributes.topicId}
|
|
32
|
+
`;
|
|
33
|
+
}
|
|
34
|
+
if (inscription.hrl || hashLinkBlock.attributes.hrl) {
|
|
35
|
+
message += `🔗 **HRL:** ${inscription.hrl || hashLinkBlock.attributes.hrl}
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
if (inscription.cdnUrl) {
|
|
39
|
+
message += `🌐 **CDN URL:** ${inscription.cdnUrl}
|
|
40
|
+
`;
|
|
41
|
+
}
|
|
42
|
+
if (metadata.creator) {
|
|
43
|
+
message += `👤 **Creator:** ${metadata.creator}
|
|
44
|
+
`;
|
|
45
|
+
}
|
|
46
|
+
message += "\n⚡ Interactive content will load below";
|
|
47
|
+
return message.trim();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Checks if a parsed response is an inscription response that needs formatting
|
|
51
|
+
*/
|
|
52
|
+
static isInscriptionResponse(parsed) {
|
|
53
|
+
if (!parsed || typeof parsed !== "object") {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
const responseObj = parsed;
|
|
57
|
+
return !!(responseObj.success === true && responseObj.type === "inscription" && responseObj.inscription && typeof responseObj.inscription === "object");
|
|
23
58
|
}
|
|
24
59
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* @returns BaseServiceBuilder instance configured for account operations
|
|
60
|
+
* Formats inscription response into user-friendly message
|
|
28
61
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
62
|
+
static formatInscriptionResponse(parsed) {
|
|
63
|
+
const inscription = parsed.inscription;
|
|
64
|
+
const metadata = parsed.metadata || {};
|
|
65
|
+
const title = parsed.title || "Inscription Complete";
|
|
66
|
+
let message = `✅ ${title}
|
|
67
|
+
|
|
68
|
+
`;
|
|
69
|
+
if (metadata.name) {
|
|
70
|
+
message += `**${metadata.name}**
|
|
71
|
+
`;
|
|
72
|
+
}
|
|
73
|
+
if (metadata.description) {
|
|
74
|
+
message += `${metadata.description}
|
|
75
|
+
|
|
76
|
+
`;
|
|
77
|
+
}
|
|
78
|
+
if (inscription.topicId) {
|
|
79
|
+
message += `📍 **Topic ID:** ${inscription.topicId}
|
|
80
|
+
`;
|
|
81
|
+
}
|
|
82
|
+
if (inscription.hrl) {
|
|
83
|
+
message += `🔗 **HRL:** ${inscription.hrl}
|
|
84
|
+
`;
|
|
85
|
+
}
|
|
86
|
+
if (inscription.cdnUrl) {
|
|
87
|
+
message += `🌐 **CDN URL:** ${inscription.cdnUrl}
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
if (metadata.creator) {
|
|
91
|
+
message += `👤 **Creator:** ${metadata.creator}
|
|
92
|
+
`;
|
|
93
|
+
}
|
|
94
|
+
return message.trim();
|
|
31
95
|
}
|
|
32
96
|
/**
|
|
33
|
-
*
|
|
34
|
-
* Validates that all transfers sum to zero before execution.
|
|
35
|
-
*
|
|
36
|
-
* @param builder - The service builder instance for executing transactions
|
|
37
|
-
* @param specificArgs - The validated transfer parameters including transfers array and optional memo
|
|
38
|
-
* @returns Promise that resolves when the transfer is complete
|
|
97
|
+
* Main formatting method that determines the best response format
|
|
39
98
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
99
|
+
static formatResponse(toolOutput) {
|
|
100
|
+
try {
|
|
101
|
+
const parsed = JSON.parse(toolOutput);
|
|
102
|
+
if (ResponseFormatter.isHashLinkResponse(parsed)) {
|
|
103
|
+
return ResponseFormatter.formatHashLinkResponse(parsed);
|
|
104
|
+
}
|
|
105
|
+
if (ResponseFormatter.isInscriptionResponse(parsed)) {
|
|
106
|
+
return ResponseFormatter.formatInscriptionResponse(parsed);
|
|
107
|
+
}
|
|
108
|
+
return toolOutput;
|
|
109
|
+
} catch {
|
|
110
|
+
return toolOutput;
|
|
111
|
+
}
|
|
44
112
|
}
|
|
45
113
|
}
|
|
46
114
|
export {
|
|
47
|
-
|
|
115
|
+
ResponseFormatter
|
|
48
116
|
};
|
|
49
117
|
//# sourceMappingURL=index33.js.map
|
package/dist/esm/index33.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index33.js","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"index33.js","sources":["../../src/utils/response-formatter.ts"],"sourcesContent":["/**\n * HCS-12 HashLink block structure for interactive content rendering\n */\ninterface HCS12BlockResult {\n blockId: string;\n hashLink: string;\n template: string;\n attributes: Record<string, unknown>;\n}\n\n/**\n * Utility class for formatting tool responses into user-friendly messages\n */\nexport class ResponseFormatter {\n /**\n * Checks if a parsed response contains HashLink block data for interactive rendering\n */\n static isHashLinkResponse(parsed: unknown): boolean {\n if (!parsed || typeof parsed !== 'object') {\n return false;\n }\n\n const responseObj = parsed as Record<string, unknown>;\n return !!(\n responseObj.success === true &&\n responseObj.type === 'inscription' &&\n responseObj.hashLinkBlock &&\n typeof responseObj.hashLinkBlock === 'object'\n );\n }\n\n /**\n * Formats HashLink block response with simple text confirmation\n * HTML template rendering is handled by HashLinkBlockRenderer component via metadata\n */\n static formatHashLinkResponse(parsed: Record<string, unknown>): string {\n const hashLinkBlock = parsed.hashLinkBlock as HCS12BlockResult;\n const metadata = parsed.metadata as Record<string, unknown> || {};\n const inscription = parsed.inscription as Record<string, unknown> || {};\n\n let message = '✅ Interactive content created successfully!\\n\\n';\n\n if (metadata.name) {\n message += `**${metadata.name}**\\n`;\n }\n\n if (metadata.description) {\n message += `${metadata.description}\\n\\n`;\n }\n\n if (inscription.topicId || hashLinkBlock.attributes.topicId) {\n message += `📍 **Topic ID:** ${inscription.topicId || hashLinkBlock.attributes.topicId}\\n`;\n }\n\n if (inscription.hrl || hashLinkBlock.attributes.hrl) {\n message += `🔗 **HRL:** ${inscription.hrl || hashLinkBlock.attributes.hrl}\\n`;\n }\n\n if (inscription.cdnUrl) {\n message += `🌐 **CDN URL:** ${inscription.cdnUrl}\\n`;\n }\n\n if (metadata.creator) {\n message += `👤 **Creator:** ${metadata.creator}\\n`;\n }\n\n message += '\\n⚡ Interactive content will load below';\n\n return message.trim();\n }\n\n /**\n * Checks if a parsed response is an inscription response that needs formatting\n */\n static isInscriptionResponse(parsed: unknown): boolean {\n if (!parsed || typeof parsed !== 'object') {\n return false;\n }\n\n const responseObj = parsed as Record<string, unknown>;\n return !!(\n responseObj.success === true &&\n responseObj.type === 'inscription' &&\n responseObj.inscription &&\n typeof responseObj.inscription === 'object'\n );\n }\n\n /**\n * Formats inscription response into user-friendly message\n */\n static formatInscriptionResponse(parsed: Record<string, unknown>): string {\n const inscription = parsed.inscription as Record<string, unknown>;\n const metadata = parsed.metadata as Record<string, unknown> || {};\n const title = parsed.title as string || 'Inscription Complete';\n\n let message = `✅ ${title}\\n\\n`;\n\n if (metadata.name) {\n message += `**${metadata.name}**\\n`;\n }\n\n if (metadata.description) {\n message += `${metadata.description}\\n\\n`;\n }\n\n if (inscription.topicId) {\n message += `📍 **Topic ID:** ${inscription.topicId}\\n`;\n }\n\n if (inscription.hrl) {\n message += `🔗 **HRL:** ${inscription.hrl}\\n`;\n }\n\n if (inscription.cdnUrl) {\n message += `🌐 **CDN URL:** ${inscription.cdnUrl}\\n`;\n }\n\n if (metadata.creator) {\n message += `👤 **Creator:** ${metadata.creator}\\n`;\n }\n\n return message.trim();\n }\n\n /**\n * Main formatting method that determines the best response format\n */\n static formatResponse(toolOutput: string): string {\n try {\n const parsed = JSON.parse(toolOutput);\n \n if (ResponseFormatter.isHashLinkResponse(parsed)) {\n return ResponseFormatter.formatHashLinkResponse(parsed);\n }\n \n if (ResponseFormatter.isInscriptionResponse(parsed)) {\n return ResponseFormatter.formatInscriptionResponse(parsed);\n }\n \n return toolOutput;\n } catch {\n return toolOutput;\n }\n }\n}"],"names":[],"mappings":"AAaO,MAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA,EAI7B,OAAO,mBAAmB,QAA0B;AAClD,QAAI,CAAC,UAAU,OAAO,WAAW,UAAU;AACzC,aAAO;AAAA,IACT;AAEA,UAAM,cAAc;AACpB,WAAO,CAAC,EACN,YAAY,YAAY,QACxB,YAAY,SAAS,iBACrB,YAAY,iBACZ,OAAO,YAAY,kBAAkB;AAAA,EAEzC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,uBAAuB,QAAyC;AACrE,UAAM,gBAAgB,OAAO;AAC7B,UAAM,WAAW,OAAO,YAAuC,CAAA;AAC/D,UAAM,cAAc,OAAO,eAA0C,CAAA;AAErE,QAAI,UAAU;AAEd,QAAI,SAAS,MAAM;AACjB,iBAAW,KAAK,SAAS,IAAI;AAAA;AAAA,IAC/B;AAEA,QAAI,SAAS,aAAa;AACxB,iBAAW,GAAG,SAAS,WAAW;AAAA;AAAA;AAAA,IACpC;AAEA,QAAI,YAAY,WAAW,cAAc,WAAW,SAAS;AAC3D,iBAAW,oBAAoB,YAAY,WAAW,cAAc,WAAW,OAAO;AAAA;AAAA,IACxF;AAEA,QAAI,YAAY,OAAO,cAAc,WAAW,KAAK;AACnD,iBAAW,eAAe,YAAY,OAAO,cAAc,WAAW,GAAG;AAAA;AAAA,IAC3E;AAEA,QAAI,YAAY,QAAQ;AACtB,iBAAW,mBAAmB,YAAY,MAAM;AAAA;AAAA,IAClD;AAEA,QAAI,SAAS,SAAS;AACpB,iBAAW,mBAAmB,SAAS,OAAO;AAAA;AAAA,IAChD;AAEA,eAAW;AAEX,WAAO,QAAQ,KAAA;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,sBAAsB,QAA0B;AACrD,QAAI,CAAC,UAAU,OAAO,WAAW,UAAU;AACzC,aAAO;AAAA,IACT;AAEA,UAAM,cAAc;AACpB,WAAO,CAAC,EACN,YAAY,YAAY,QACxB,YAAY,SAAS,iBACrB,YAAY,eACZ,OAAO,YAAY,gBAAgB;AAAA,EAEvC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,0BAA0B,QAAyC;AACxE,UAAM,cAAc,OAAO;AAC3B,UAAM,WAAW,OAAO,YAAuC,CAAA;AAC/D,UAAM,QAAQ,OAAO,SAAmB;AAExC,QAAI,UAAU,KAAK,KAAK;AAAA;AAAA;AAExB,QAAI,SAAS,MAAM;AACjB,iBAAW,KAAK,SAAS,IAAI;AAAA;AAAA,IAC/B;AAEA,QAAI,SAAS,aAAa;AACxB,iBAAW,GAAG,SAAS,WAAW;AAAA;AAAA;AAAA,IACpC;AAEA,QAAI,YAAY,SAAS;AACvB,iBAAW,oBAAoB,YAAY,OAAO;AAAA;AAAA,IACpD;AAEA,QAAI,YAAY,KAAK;AACnB,iBAAW,eAAe,YAAY,GAAG;AAAA;AAAA,IAC3C;AAEA,QAAI,YAAY,QAAQ;AACtB,iBAAW,mBAAmB,YAAY,MAAM;AAAA;AAAA,IAClD;AAEA,QAAI,SAAS,SAAS;AACpB,iBAAW,mBAAmB,SAAS,OAAO;AAAA;AAAA,IAChD;AAEA,WAAO,QAAQ,KAAA;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,eAAe,YAA4B;AAChD,QAAI;AACF,YAAM,SAAS,KAAK,MAAM,UAAU;AAEpC,UAAI,kBAAkB,mBAAmB,MAAM,GAAG;AAChD,eAAO,kBAAkB,uBAAuB,MAAM;AAAA,MACxD;AAEA,UAAI,kBAAkB,sBAAsB,MAAM,GAAG;AACnD,eAAO,kBAAkB,0BAA0B,MAAM;AAAA,MAC3D;AAEA,aAAO;AAAA,IACT,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AACF;"}
|
package/dist/esm/index34.js
CHANGED
|
@@ -1,106 +1,49 @@
|
|
|
1
|
-
import { StructuredTool } from "@langchain/core/tools";
|
|
2
1
|
import { z } from "zod";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
2
|
+
import { AccountBuilder } from "./index43.js";
|
|
3
|
+
import { BaseHederaTransactionTool } from "hedera-agent-kit";
|
|
4
|
+
const HbarTransferInputSchema = z.object({
|
|
5
|
+
accountId: z.string().describe('Account ID for the transfer (e.g., "0.0.xxxx").'),
|
|
6
|
+
amount: z.union([z.number(), z.string()]).describe(
|
|
7
|
+
"HBAR amount in decimal format (e.g., 1 for 1 HBAR, 0.5 for 0.5 HBAR). Positive for credit, negative for debit. DO NOT multiply by 10^8 for tinybars - just use the HBAR amount directly."
|
|
8
|
+
)
|
|
9
|
+
});
|
|
10
|
+
const TransferHbarZodSchemaCore = z.object({
|
|
11
|
+
transfers: z.array(HbarTransferInputSchema).min(1).describe(
|
|
12
|
+
'Array of transfers. For simple transfers from your operator account, just include the recipient with positive amount: [{accountId: "0.0.800", amount: 1}]. For complex multi-party transfers, include all parties with negative amounts for senders and positive for receivers.'
|
|
13
|
+
),
|
|
14
|
+
memo: z.string().optional().describe("Optional. Memo for the transaction.")
|
|
15
|
+
});
|
|
16
|
+
class TransferHbarTool extends BaseHederaTransactionTool {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.name = "hedera-account-transfer-hbar-v2";
|
|
20
|
+
this.description = 'PRIMARY TOOL FOR HBAR TRANSFERS: Transfers HBAR between accounts. For simple transfers from the operator account, just specify the recipient with a positive amount (e.g., [{accountId: "0.0.800", amount: 1}] to send 1 HBAR to 0.0.800). The sender will be automatically added. For multi-party transfers (e.g., "A sends 5 HBAR to C and B sends 3 HBAR to C"), include ALL transfers with their amounts (negative for senders, positive for receivers).';
|
|
21
|
+
this.specificInputSchema = TransferHbarZodSchemaCore;
|
|
22
|
+
this.namespace = "account";
|
|
24
23
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.logger.info(`Token ${input.tokenId} has ${decimals} decimal places`);
|
|
33
|
-
const convertedRecipients = input.recipients.map((recipient) => {
|
|
34
|
-
const humanAmount = typeof recipient.amount === "string" ? parseFloat(recipient.amount) : recipient.amount;
|
|
35
|
-
const smallestUnitAmount = this.convertToSmallestUnits(
|
|
36
|
-
humanAmount,
|
|
37
|
-
decimals
|
|
38
|
-
);
|
|
39
|
-
this.logger.info(
|
|
40
|
-
`Converting amount for ${recipient.accountId}: ${humanAmount} tokens → ${smallestUnitAmount} smallest units`
|
|
41
|
-
);
|
|
42
|
-
return {
|
|
43
|
-
...recipient,
|
|
44
|
-
amount: smallestUnitAmount.toString()
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
const convertedInput = {
|
|
48
|
-
...input,
|
|
49
|
-
recipients: convertedRecipients
|
|
50
|
-
};
|
|
51
|
-
this.logger.info(`Calling original airdrop tool with converted amounts`);
|
|
52
|
-
return await this.originalTool._call(convertedInput);
|
|
53
|
-
} catch (error) {
|
|
54
|
-
this.logger.error("Error in airdrop tool wrapper:", error);
|
|
55
|
-
throw error;
|
|
56
|
-
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates and returns the service builder for account operations.
|
|
26
|
+
*
|
|
27
|
+
* @returns BaseServiceBuilder instance configured for account operations
|
|
28
|
+
*/
|
|
29
|
+
getServiceBuilder() {
|
|
30
|
+
return new AccountBuilder(this.hederaKit);
|
|
57
31
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"MirrorNode not found in agentKit, attempting to access via fetch"
|
|
71
|
-
);
|
|
72
|
-
const network = this.agentKit.network || "testnet";
|
|
73
|
-
const mirrorNodeUrl = network === "mainnet" ? "https://mainnet.mirrornode.hedera.com" : "https://testnet.mirrornode.hedera.com";
|
|
74
|
-
const response = await fetch(
|
|
75
|
-
`${mirrorNodeUrl}/api/v1/tokens/${tokenId}`
|
|
76
|
-
);
|
|
77
|
-
if (response.ok) {
|
|
78
|
-
const tokenData = await response.json();
|
|
79
|
-
const decimals = parseInt(String(tokenData.decimals || "0"));
|
|
80
|
-
this.logger.info(
|
|
81
|
-
`Token ${tokenId} found with ${decimals} decimals via API`
|
|
82
|
-
);
|
|
83
|
-
return { ...tokenData, decimals };
|
|
84
|
-
}
|
|
85
|
-
} else {
|
|
86
|
-
const tokenData = await mirrorNode.getTokenInfo(tokenId);
|
|
87
|
-
if (tokenData && typeof tokenData.decimals !== "undefined") {
|
|
88
|
-
const decimals = parseInt(tokenData.decimals.toString()) || 0;
|
|
89
|
-
this.logger.info(`Token ${tokenId} found with ${decimals} decimals`);
|
|
90
|
-
return { ...tokenData, decimals };
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
throw new Error(`Token data not found or missing decimals field`);
|
|
94
|
-
} catch (error) {
|
|
95
|
-
this.logger.warn(`Failed to query token info for ${tokenId}:`, error);
|
|
96
|
-
this.logger.info(
|
|
97
|
-
"Falling back to assumed 0 decimal places (smallest units)"
|
|
98
|
-
);
|
|
99
|
-
return { decimals: 0 };
|
|
100
|
-
}
|
|
32
|
+
/**
|
|
33
|
+
* Executes the HBAR transfer using the provided builder and arguments.
|
|
34
|
+
* Validates that all transfers sum to zero before execution.
|
|
35
|
+
*
|
|
36
|
+
* @param builder - The service builder instance for executing transactions
|
|
37
|
+
* @param specificArgs - The validated transfer parameters including transfers array and optional memo
|
|
38
|
+
* @returns Promise that resolves when the transfer is complete
|
|
39
|
+
*/
|
|
40
|
+
async callBuilderMethod(builder, specificArgs) {
|
|
41
|
+
await builder.transferHbar(
|
|
42
|
+
specificArgs
|
|
43
|
+
);
|
|
101
44
|
}
|
|
102
45
|
}
|
|
103
46
|
export {
|
|
104
|
-
|
|
47
|
+
TransferHbarTool
|
|
105
48
|
};
|
|
106
49
|
//# sourceMappingURL=index34.js.map
|
package/dist/esm/index34.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index34.js","sources":["../../src/plugins/hbar/
|
|
1
|
+
{"version":3,"file":"index34.js","sources":["../../src/plugins/hbar/TransferHbarTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { HbarTransferParams } from './types';\nimport { AccountBuilder } from './AccountBuilder';\nimport { BaseHederaTransactionTool, BaseServiceBuilder } from 'hedera-agent-kit';\n\nconst HbarTransferInputSchema = z.object({\n accountId: z\n .string()\n .describe('Account ID for the transfer (e.g., \"0.0.xxxx\").'),\n amount: z\n .union([z.number(), z.string()])\n .describe(\n 'HBAR amount in decimal format (e.g., 1 for 1 HBAR, 0.5 for 0.5 HBAR). Positive for credit, negative for debit. DO NOT multiply by 10^8 for tinybars - just use the HBAR amount directly.'\n ),\n});\n\nconst TransferHbarZodSchemaCore = z.object({\n transfers: z\n .array(HbarTransferInputSchema)\n .min(1)\n .describe(\n 'Array of transfers. For simple transfers from your operator account, just include the recipient with positive amount: [{accountId: \"0.0.800\", amount: 1}]. For complex multi-party transfers, include all parties with negative amounts for senders and positive for receivers.'\n ),\n memo: z.string().optional().describe('Optional. Memo for the transaction.'),\n});\n\n/**\n * A Hedera transaction tool for transferring HBAR between accounts.\n * Supports single and multi-party transfers with automatic balance validation.\n * Extends BaseHederaTransactionTool to handle HBAR transfer transactions on the Hedera Hashgraph.\n */\nexport class TransferHbarTool extends BaseHederaTransactionTool<\n typeof TransferHbarZodSchemaCore\n> {\n name = 'hedera-account-transfer-hbar-v2';\n description =\n 'PRIMARY TOOL FOR HBAR TRANSFERS: Transfers HBAR between accounts. For simple transfers from the operator account, just specify the recipient with a positive amount (e.g., [{accountId: \"0.0.800\", amount: 1}] to send 1 HBAR to 0.0.800). The sender will be automatically added. For multi-party transfers (e.g., \"A sends 5 HBAR to C and B sends 3 HBAR to C\"), include ALL transfers with their amounts (negative for senders, positive for receivers).';\n specificInputSchema = TransferHbarZodSchemaCore;\n namespace = 'account';\n\n\n /**\n * Creates and returns the service builder for account operations.\n * \n * @returns BaseServiceBuilder instance configured for account operations\n */\n protected getServiceBuilder(): BaseServiceBuilder {\n return new AccountBuilder(this.hederaKit) as BaseServiceBuilder;\n }\n\n /**\n * Executes the HBAR transfer using the provided builder and arguments.\n * Validates that all transfers sum to zero before execution.\n * \n * @param builder - The service builder instance for executing transactions\n * @param specificArgs - The validated transfer parameters including transfers array and optional memo\n * @returns Promise that resolves when the transfer is complete\n */\n protected async callBuilderMethod(\n builder: BaseServiceBuilder,\n specificArgs: z.infer<typeof TransferHbarZodSchemaCore>\n ): Promise<void> {\n await (builder as AccountBuilder).transferHbar(\n specificArgs as unknown as HbarTransferParams\n );\n }\n}"],"names":[],"mappings":";;;AAKA,MAAM,0BAA0B,EAAE,OAAO;AAAA,EACvC,WAAW,EACR,SACA,SAAS,iDAAiD;AAAA,EAC7D,QAAQ,EACL,MAAM,CAAC,EAAE,OAAA,GAAU,EAAE,QAAQ,CAAC,EAC9B;AAAA,IACC;AAAA,EAAA;AAEN,CAAC;AAED,MAAM,4BAA4B,EAAE,OAAO;AAAA,EACzC,WAAW,EACR,MAAM,uBAAuB,EAC7B,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,MAAM,EAAE,OAAA,EAAS,SAAA,EAAW,SAAS,qCAAqC;AAC5E,CAAC;AAOM,MAAM,yBAAyB,0BAEpC;AAAA,EAFK,cAAA;AAAA,UAAA,GAAA,SAAA;AAGL,SAAA,OAAO;AACP,SAAA,cACE;AACF,SAAA,sBAAsB;AACtB,SAAA,YAAY;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQF,oBAAwC;AAChD,WAAO,IAAI,eAAe,KAAK,SAAS;AAAA,EAC1C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAgB,kBACd,SACA,cACe;AACf,UAAO,QAA2B;AAAA,MAChC;AAAA,IAAA;AAAA,EAEJ;AACF;"}
|
package/dist/esm/index35.js
CHANGED
|
@@ -1,24 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { StructuredTool } from "@langchain/core/tools";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { Logger } from "@hashgraphonline/standards-sdk";
|
|
4
|
+
class AirdropToolWrapper extends StructuredTool {
|
|
5
|
+
constructor(originalTool, agentKit) {
|
|
6
|
+
super();
|
|
7
|
+
this.name = "hedera-hts-airdrop-token";
|
|
8
|
+
this.description = "Airdrops fungible tokens to multiple recipients. Automatically converts human-readable amounts to smallest units based on token decimals.";
|
|
9
|
+
this.schema = z.object({
|
|
10
|
+
tokenId: z.string().describe('The ID of the fungible token to airdrop (e.g., "0.0.yyyy").'),
|
|
11
|
+
recipients: z.array(
|
|
12
|
+
z.object({
|
|
13
|
+
accountId: z.string().describe('Recipient account ID (e.g., "0.0.xxxx").'),
|
|
14
|
+
amount: z.union([z.number(), z.string()]).describe(
|
|
15
|
+
'Amount in human-readable format (e.g., "10" for 10 tokens).'
|
|
16
|
+
)
|
|
17
|
+
})
|
|
18
|
+
).min(1).describe("Array of recipient objects, each with accountId and amount."),
|
|
19
|
+
memo: z.string().optional().describe("Optional. Memo for the transaction.")
|
|
20
|
+
});
|
|
21
|
+
this.originalTool = originalTool;
|
|
22
|
+
this.agentKit = agentKit;
|
|
23
|
+
this.logger = new Logger({ module: "AirdropToolWrapper" });
|
|
24
|
+
}
|
|
25
|
+
async _call(input) {
|
|
26
|
+
try {
|
|
27
|
+
this.logger.info(
|
|
28
|
+
`Processing airdrop request for token ${input.tokenId} with ${input.recipients.length} recipients`
|
|
29
|
+
);
|
|
30
|
+
const tokenInfo = await this.getTokenInfo(input.tokenId);
|
|
31
|
+
const decimals = tokenInfo.decimals || 0;
|
|
32
|
+
this.logger.info(`Token ${input.tokenId} has ${decimals} decimal places`);
|
|
33
|
+
const convertedRecipients = input.recipients.map((recipient) => {
|
|
34
|
+
const humanAmount = typeof recipient.amount === "string" ? parseFloat(recipient.amount) : recipient.amount;
|
|
35
|
+
const smallestUnitAmount = this.convertToSmallestUnits(
|
|
36
|
+
humanAmount,
|
|
37
|
+
decimals
|
|
38
|
+
);
|
|
39
|
+
this.logger.info(
|
|
40
|
+
`Converting amount for ${recipient.accountId}: ${humanAmount} tokens → ${smallestUnitAmount} smallest units`
|
|
41
|
+
);
|
|
42
|
+
return {
|
|
43
|
+
...recipient,
|
|
44
|
+
amount: smallestUnitAmount.toString()
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
const convertedInput = {
|
|
48
|
+
...input,
|
|
49
|
+
recipients: convertedRecipients
|
|
50
|
+
};
|
|
51
|
+
this.logger.info(`Calling original airdrop tool with converted amounts`);
|
|
52
|
+
return await this.originalTool._call(convertedInput);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
this.logger.error("Error in airdrop tool wrapper:", error);
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
convertToSmallestUnits(amount, decimals) {
|
|
59
|
+
return Math.floor(amount * Math.pow(10, decimals));
|
|
60
|
+
}
|
|
61
|
+
async getTokenInfo(tokenId) {
|
|
62
|
+
return await this.queryTokenInfo(tokenId);
|
|
63
|
+
}
|
|
64
|
+
async queryTokenInfo(tokenId) {
|
|
65
|
+
try {
|
|
66
|
+
this.logger.info("Querying token info using mirror node");
|
|
67
|
+
const mirrorNode = this.agentKit.mirrorNode;
|
|
68
|
+
if (!mirrorNode) {
|
|
69
|
+
this.logger.info(
|
|
70
|
+
"MirrorNode not found in agentKit, attempting to access via fetch"
|
|
71
|
+
);
|
|
72
|
+
const network = this.agentKit.network || "testnet";
|
|
73
|
+
const mirrorNodeUrl = network === "mainnet" ? "https://mainnet.mirrornode.hedera.com" : "https://testnet.mirrornode.hedera.com";
|
|
74
|
+
const response = await fetch(
|
|
75
|
+
`${mirrorNodeUrl}/api/v1/tokens/${tokenId}`
|
|
76
|
+
);
|
|
77
|
+
if (response.ok) {
|
|
78
|
+
const tokenData = await response.json();
|
|
79
|
+
const decimals = parseInt(String(tokenData.decimals || "0"));
|
|
80
|
+
this.logger.info(
|
|
81
|
+
`Token ${tokenId} found with ${decimals} decimals via API`
|
|
82
|
+
);
|
|
83
|
+
return { ...tokenData, decimals };
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
const tokenData = await mirrorNode.getTokenInfo(tokenId);
|
|
87
|
+
if (tokenData && typeof tokenData.decimals !== "undefined") {
|
|
88
|
+
const decimals = parseInt(tokenData.decimals.toString()) || 0;
|
|
89
|
+
this.logger.info(`Token ${tokenId} found with ${decimals} decimals`);
|
|
90
|
+
return { ...tokenData, decimals };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
throw new Error(`Token data not found or missing decimals field`);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
this.logger.warn(`Failed to query token info for ${tokenId}:`, error);
|
|
96
|
+
this.logger.info(
|
|
97
|
+
"Falling back to assumed 0 decimal places (smallest units)"
|
|
98
|
+
);
|
|
99
|
+
return { decimals: 0 };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
21
103
|
export {
|
|
22
|
-
|
|
104
|
+
AirdropToolWrapper
|
|
23
105
|
};
|
|
24
106
|
//# sourceMappingURL=index35.js.map
|
package/dist/esm/index35.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index35.js","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"index35.js","sources":["../../src/plugins/hbar/AirdropToolWrapper.ts"],"sourcesContent":["import { StructuredTool } from '@langchain/core/tools';\nimport { z } from 'zod';\nimport { HederaAgentKit } from 'hedera-agent-kit';\nimport { Logger } from '@hashgraphonline/standards-sdk';\n\ninterface TokenInfo {\n decimals: number;\n [key: string]: unknown;\n}\n\ninterface ToolWithCall {\n _call(input: unknown): Promise<string>;\n}\n\ninterface AgentKitWithMirrorNode {\n mirrorNode?: {\n getTokenInfo(tokenId: string): Promise<TokenInfo>;\n };\n network: string;\n}\n\nexport class AirdropToolWrapper extends StructuredTool {\n name = 'hedera-hts-airdrop-token';\n description =\n 'Airdrops fungible tokens to multiple recipients. Automatically converts human-readable amounts to smallest units based on token decimals.';\n\n schema = z.object({\n tokenId: z\n .string()\n .describe('The ID of the fungible token to airdrop (e.g., \"0.0.yyyy\").'),\n recipients: z\n .array(\n z.object({\n accountId: z\n .string()\n .describe('Recipient account ID (e.g., \"0.0.xxxx\").'),\n amount: z\n .union([z.number(), z.string()])\n .describe(\n 'Amount in human-readable format (e.g., \"10\" for 10 tokens).'\n ),\n })\n )\n .min(1)\n .describe('Array of recipient objects, each with accountId and amount.'),\n memo: z.string().optional().describe('Optional. Memo for the transaction.'),\n });\n\n private originalTool: StructuredTool & ToolWithCall;\n private agentKit: HederaAgentKit & AgentKitWithMirrorNode;\n private logger: Logger;\n\n constructor(originalTool: StructuredTool, agentKit: unknown) {\n super();\n this.originalTool = originalTool as StructuredTool & ToolWithCall;\n this.agentKit = agentKit as HederaAgentKit & AgentKitWithMirrorNode;\n this.logger = new Logger({ module: 'AirdropToolWrapper' });\n }\n\n async _call(input: z.infer<typeof this.schema>): Promise<string> {\n try {\n this.logger.info(\n `Processing airdrop request for token ${input.tokenId} with ${input.recipients.length} recipients`\n );\n\n const tokenInfo = await this.getTokenInfo(input.tokenId);\n const decimals = tokenInfo.decimals || 0;\n\n this.logger.info(`Token ${input.tokenId} has ${decimals} decimal places`);\n\n const convertedRecipients = input.recipients.map((recipient) => {\n const humanAmount =\n typeof recipient.amount === 'string'\n ? parseFloat(recipient.amount)\n : recipient.amount;\n const smallestUnitAmount = this.convertToSmallestUnits(\n humanAmount,\n decimals\n );\n\n this.logger.info(\n `Converting amount for ${recipient.accountId}: ${humanAmount} tokens → ${smallestUnitAmount} smallest units`\n );\n\n return {\n ...recipient,\n amount: smallestUnitAmount.toString(),\n };\n });\n\n const convertedInput = {\n ...input,\n recipients: convertedRecipients,\n };\n\n this.logger.info(`Calling original airdrop tool with converted amounts`);\n return await this.originalTool._call(convertedInput);\n } catch (error) {\n this.logger.error('Error in airdrop tool wrapper:', error);\n throw error;\n }\n }\n\n private convertToSmallestUnits(amount: number, decimals: number): number {\n return Math.floor(amount * Math.pow(10, decimals));\n }\n\n private async getTokenInfo(tokenId: string): Promise<TokenInfo> {\n return await this.queryTokenInfo(tokenId);\n }\n\n private async queryTokenInfo(tokenId: string): Promise<TokenInfo> {\n try {\n this.logger.info('Querying token info using mirror node');\n const mirrorNode = this.agentKit.mirrorNode;\n if (!mirrorNode) {\n this.logger.info(\n 'MirrorNode not found in agentKit, attempting to access via fetch'\n );\n const network = this.agentKit.network || 'testnet';\n const mirrorNodeUrl =\n network === 'mainnet'\n ? 'https://mainnet.mirrornode.hedera.com'\n : 'https://testnet.mirrornode.hedera.com';\n\n const response = await fetch(\n `${mirrorNodeUrl}/api/v1/tokens/${tokenId}`\n );\n if (response.ok) {\n const tokenData = (await response.json()) as Record<string, unknown>;\n const decimals = parseInt(String(tokenData.decimals || '0'));\n this.logger.info(\n `Token ${tokenId} found with ${decimals} decimals via API`\n );\n return { ...tokenData, decimals };\n }\n } else {\n const tokenData = await mirrorNode.getTokenInfo(tokenId);\n\n if (tokenData && typeof tokenData.decimals !== 'undefined') {\n const decimals = parseInt(tokenData.decimals.toString()) || 0;\n this.logger.info(`Token ${tokenId} found with ${decimals} decimals`);\n return { ...tokenData, decimals };\n }\n }\n\n throw new Error(`Token data not found or missing decimals field`);\n } catch (error) {\n this.logger.warn(`Failed to query token info for ${tokenId}:`, error);\n\n this.logger.info(\n 'Falling back to assumed 0 decimal places (smallest units)'\n );\n return { decimals: 0 };\n }\n }\n}\n"],"names":[],"mappings":";;;AAqBO,MAAM,2BAA2B,eAAe;AAAA,EA+BrD,YAAY,cAA8B,UAAmB;AAC3D,UAAA;AA/BF,SAAA,OAAO;AACP,SAAA,cACE;AAEF,SAAA,SAAS,EAAE,OAAO;AAAA,MAChB,SAAS,EACN,SACA,SAAS,6DAA6D;AAAA,MACzE,YAAY,EACT;AAAA,QACC,EAAE,OAAO;AAAA,UACP,WAAW,EACR,SACA,SAAS,0CAA0C;AAAA,UACtD,QAAQ,EACL,MAAM,CAAC,EAAE,OAAA,GAAU,EAAE,QAAQ,CAAC,EAC9B;AAAA,YACC;AAAA,UAAA;AAAA,QACF,CACH;AAAA,MAAA,EAEF,IAAI,CAAC,EACL,SAAS,6DAA6D;AAAA,MACzE,MAAM,EAAE,OAAA,EAAS,SAAA,EAAW,SAAS,qCAAqC;AAAA,IAAA,CAC3E;AAQC,SAAK,eAAe;AACpB,SAAK,WAAW;AAChB,SAAK,SAAS,IAAI,OAAO,EAAE,QAAQ,sBAAsB;AAAA,EAC3D;AAAA,EAEA,MAAM,MAAM,OAAqD;AAC/D,QAAI;AACF,WAAK,OAAO;AAAA,QACV,wCAAwC,MAAM,OAAO,SAAS,MAAM,WAAW,MAAM;AAAA,MAAA;AAGvF,YAAM,YAAY,MAAM,KAAK,aAAa,MAAM,OAAO;AACvD,YAAM,WAAW,UAAU,YAAY;AAEvC,WAAK,OAAO,KAAK,SAAS,MAAM,OAAO,QAAQ,QAAQ,iBAAiB;AAExE,YAAM,sBAAsB,MAAM,WAAW,IAAI,CAAC,cAAc;AAC9D,cAAM,cACJ,OAAO,UAAU,WAAW,WACxB,WAAW,UAAU,MAAM,IAC3B,UAAU;AAChB,cAAM,qBAAqB,KAAK;AAAA,UAC9B;AAAA,UACA;AAAA,QAAA;AAGF,aAAK,OAAO;AAAA,UACV,yBAAyB,UAAU,SAAS,KAAK,WAAW,aAAa,kBAAkB;AAAA,QAAA;AAG7F,eAAO;AAAA,UACL,GAAG;AAAA,UACH,QAAQ,mBAAmB,SAAA;AAAA,QAAS;AAAA,MAExC,CAAC;AAED,YAAM,iBAAiB;AAAA,QACrB,GAAG;AAAA,QACH,YAAY;AAAA,MAAA;AAGd,WAAK,OAAO,KAAK,sDAAsD;AACvE,aAAO,MAAM,KAAK,aAAa,MAAM,cAAc;AAAA,IACrD,SAAS,OAAO;AACd,WAAK,OAAO,MAAM,kCAAkC,KAAK;AACzD,YAAM;AAAA,IACR;AAAA,EACF;AAAA,EAEQ,uBAAuB,QAAgB,UAA0B;AACvE,WAAO,KAAK,MAAM,SAAS,KAAK,IAAI,IAAI,QAAQ,CAAC;AAAA,EACnD;AAAA,EAEA,MAAc,aAAa,SAAqC;AAC9D,WAAO,MAAM,KAAK,eAAe,OAAO;AAAA,EAC1C;AAAA,EAEA,MAAc,eAAe,SAAqC;AAChE,QAAI;AACF,WAAK,OAAO,KAAK,uCAAuC;AACxD,YAAM,aAAa,KAAK,SAAS;AACjC,UAAI,CAAC,YAAY;AACf,aAAK,OAAO;AAAA,UACV;AAAA,QAAA;AAEF,cAAM,UAAU,KAAK,SAAS,WAAW;AACzC,cAAM,gBACJ,YAAY,YACR,0CACA;AAEN,cAAM,WAAW,MAAM;AAAA,UACrB,GAAG,aAAa,kBAAkB,OAAO;AAAA,QAAA;AAE3C,YAAI,SAAS,IAAI;AACf,gBAAM,YAAa,MAAM,SAAS,KAAA;AAClC,gBAAM,WAAW,SAAS,OAAO,UAAU,YAAY,GAAG,CAAC;AAC3D,eAAK,OAAO;AAAA,YACV,SAAS,OAAO,eAAe,QAAQ;AAAA,UAAA;AAEzC,iBAAO,EAAE,GAAG,WAAW,SAAA;AAAA,QACzB;AAAA,MACF,OAAO;AACL,cAAM,YAAY,MAAM,WAAW,aAAa,OAAO;AAEvD,YAAI,aAAa,OAAO,UAAU,aAAa,aAAa;AAC1D,gBAAM,WAAW,SAAS,UAAU,SAAS,SAAA,CAAU,KAAK;AAC5D,eAAK,OAAO,KAAK,SAAS,OAAO,eAAe,QAAQ,WAAW;AACnE,iBAAO,EAAE,GAAG,WAAW,SAAA;AAAA,QACzB;AAAA,MACF;AAEA,YAAM,IAAI,MAAM,gDAAgD;AAAA,IAClE,SAAS,OAAO;AACd,WAAK,OAAO,KAAK,kCAAkC,OAAO,KAAK,KAAK;AAEpE,WAAK,OAAO;AAAA,QACV;AAAA,MAAA;AAEF,aAAO,EAAE,UAAU,EAAA;AAAA,IACrB;AAAA,EACF;AACF;"}
|
package/dist/esm/index36.js
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
1
|
+
const getSystemMessage = (accountId) => `You are a helpful assistant managing Hashgraph Online HCS-10 connections, messages, HCS-2 registries, content inscription, and Hedera Hashgraph operations.
|
|
2
|
+
|
|
3
|
+
You have access to tools for:
|
|
4
|
+
- HCS-10: registering agents, finding registered agents, initiating connections, listing active connections, sending messages over connections, and checking for new messages
|
|
5
|
+
- HCS-2: creating registries, registering entries, updating entries, deleting entries, migrating registries, and querying registry contents
|
|
6
|
+
- Inscription: inscribing content from URLs, files, or buffers, creating Hashinal NFTs, and retrieving inscriptions
|
|
7
|
+
- Hedera Token Service (HTS): creating tokens, transferring tokens, airdropping tokens, and managing token operations
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
*** IMPORTANT CONTEXT ***
|
|
11
|
+
You are currently operating as agent: ${accountId} on the Hedera Hashgraph
|
|
12
|
+
When users ask about "my profile", "my account", "my connections", etc., use this account ID: ${accountId}
|
|
13
|
+
|
|
14
|
+
*** CRITICAL ENTITY HANDLING RULES ***
|
|
15
|
+
- When users refer to entities (tokens, topics, accounts) with pronouns like "it", "that", "the token/topic", etc., ALWAYS use the most recently created entity of that type
|
|
16
|
+
- Entity IDs look like "0.0.XXXXXX" and are stored in memory after creation
|
|
17
|
+
- NEVER use example or placeholder IDs like "0.0.123456" - always use actual created entity IDs
|
|
18
|
+
- Account ID ${accountId} is NOT a token - tokens and accounts are different entities
|
|
19
|
+
|
|
20
|
+
Remember the connection numbers when listing connections, as users might refer to them.`;
|
|
12
21
|
export {
|
|
13
|
-
|
|
22
|
+
getSystemMessage
|
|
14
23
|
};
|
|
15
24
|
//# sourceMappingURL=index36.js.map
|
package/dist/esm/index36.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index36.js","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"index36.js","sources":["../../src/config/system-message.ts"],"sourcesContent":["export const getSystemMessage = (\n accountId: string\n): string => `You are a helpful assistant managing Hashgraph Online HCS-10 connections, messages, HCS-2 registries, content inscription, and Hedera Hashgraph operations.\n\nYou have access to tools for:\n- HCS-10: registering agents, finding registered agents, initiating connections, listing active connections, sending messages over connections, and checking for new messages\n- HCS-2: creating registries, registering entries, updating entries, deleting entries, migrating registries, and querying registry contents\n- Inscription: inscribing content from URLs, files, or buffers, creating Hashinal NFTs, and retrieving inscriptions\n- Hedera Token Service (HTS): creating tokens, transferring tokens, airdropping tokens, and managing token operations\n\n\n*** IMPORTANT CONTEXT ***\nYou are currently operating as agent: ${accountId} on the Hedera Hashgraph\nWhen users ask about \"my profile\", \"my account\", \"my connections\", etc., use this account ID: ${accountId}\n\n*** CRITICAL ENTITY HANDLING RULES ***\n- When users refer to entities (tokens, topics, accounts) with pronouns like \"it\", \"that\", \"the token/topic\", etc., ALWAYS use the most recently created entity of that type\n- Entity IDs look like \"0.0.XXXXXX\" and are stored in memory after creation\n- NEVER use example or placeholder IDs like \"0.0.123456\" - always use actual created entity IDs\n- Account ID ${accountId} is NOT a token - tokens and accounts are different entities\n\n Remember the connection numbers when listing connections, as users might refer to them.`;\n"],"names":[],"mappings":"AAAO,MAAM,mBAAmB,CAC9B,cACW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAU2B,SAAS;AAAA,gGAC+C,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAM1F,SAAS;AAAA;AAAA;"}
|