@hashgraphonline/conversational-agent 0.2.103 → 0.2.106

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.
Files changed (70) hide show
  1. package/dist/cjs/conversational-agent.d.ts +11 -2
  2. package/dist/cjs/core/tool-registry.d.ts +3 -0
  3. package/dist/cjs/forms/field-guidance-registry.d.ts +33 -0
  4. package/dist/cjs/index.cjs +1 -1
  5. package/dist/cjs/index.cjs.map +1 -1
  6. package/dist/cjs/index.d.ts +1 -0
  7. package/dist/cjs/plugins/inscribe/InscribePlugin.d.ts +1 -0
  8. package/dist/cjs/runtime/wallet-bridge.d.ts +23 -0
  9. package/dist/cjs/signers/browser-signer.d.ts +32 -0
  10. package/dist/esm/index.js +3 -0
  11. package/dist/esm/index.js.map +1 -1
  12. package/dist/esm/index10.js +13 -5
  13. package/dist/esm/index10.js.map +1 -1
  14. package/dist/esm/index13.js +157 -179
  15. package/dist/esm/index13.js.map +1 -1
  16. package/dist/esm/index2.js +29 -25
  17. package/dist/esm/index2.js.map +1 -1
  18. package/dist/esm/index21.js +1 -1
  19. package/dist/esm/index23.js +3 -3
  20. package/dist/esm/index3.js.map +1 -1
  21. package/dist/esm/index33.js +5 -5
  22. package/dist/esm/index33.js.map +1 -1
  23. package/dist/esm/index36.js +8 -45
  24. package/dist/esm/index36.js.map +1 -1
  25. package/dist/esm/index37.js +41 -102
  26. package/dist/esm/index37.js.map +1 -1
  27. package/dist/esm/index38.js +107 -21
  28. package/dist/esm/index38.js.map +1 -1
  29. package/dist/esm/index39.js +66 -12
  30. package/dist/esm/index39.js.map +1 -1
  31. package/dist/esm/index4.js +43 -0
  32. package/dist/esm/index4.js.map +1 -1
  33. package/dist/esm/index40.js +21 -7
  34. package/dist/esm/index40.js.map +1 -1
  35. package/dist/esm/index41.js +11 -4
  36. package/dist/esm/index41.js.map +1 -1
  37. package/dist/esm/index42.js +7 -255
  38. package/dist/esm/index42.js.map +1 -1
  39. package/dist/esm/index43.js +5 -184
  40. package/dist/esm/index43.js.map +1 -1
  41. package/dist/esm/index44.js +254 -75
  42. package/dist/esm/index44.js.map +1 -1
  43. package/dist/esm/index45.js +181 -24
  44. package/dist/esm/index45.js.map +1 -1
  45. package/dist/esm/index46.js +30 -0
  46. package/dist/esm/index46.js.map +1 -0
  47. package/dist/esm/index47.js +95 -0
  48. package/dist/esm/index47.js.map +1 -0
  49. package/dist/esm/index5.js +2 -2
  50. package/dist/esm/index6.js +153 -46
  51. package/dist/esm/index6.js.map +1 -1
  52. package/dist/types/conversational-agent.d.ts +11 -2
  53. package/dist/types/core/tool-registry.d.ts +3 -0
  54. package/dist/types/forms/field-guidance-registry.d.ts +33 -0
  55. package/dist/types/index.d.ts +1 -0
  56. package/dist/types/plugins/inscribe/InscribePlugin.d.ts +1 -0
  57. package/dist/types/runtime/wallet-bridge.d.ts +23 -0
  58. package/dist/types/signers/browser-signer.d.ts +32 -0
  59. package/package.json +19 -10
  60. package/src/conversational-agent.ts +181 -59
  61. package/src/core/tool-registry.ts +25 -0
  62. package/src/forms/field-guidance-registry.ts +215 -188
  63. package/src/forms/form-generator.ts +28 -12
  64. package/src/index.ts +1 -0
  65. package/src/langchain/langchain-agent.ts +1 -1
  66. package/src/plugins/hcs-10/HCS10Plugin.ts +32 -28
  67. package/src/plugins/hcs-2/HCS2Plugin.ts +4 -2
  68. package/src/plugins/inscribe/InscribePlugin.ts +47 -2
  69. package/src/runtime/wallet-bridge.ts +41 -0
  70. package/src/signers/browser-signer.ts +112 -0
@@ -1,110 +1,49 @@
1
- import { StructuredTool } from "@langchain/core/tools";
2
1
  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" });
2
+ import { AccountBuilder } from "./index47.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
- 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
- }
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
- convertToSmallestUnits(amount, decimals) {
59
- return Math.floor(amount * Math.pow(10, decimals));
60
- }
61
- async getTokenInfo(tokenId) {
62
- try {
63
- return await this.queryTokenInfo(tokenId);
64
- } catch (error) {
65
- throw error;
66
- }
67
- }
68
- async queryTokenInfo(tokenId) {
69
- try {
70
- this.logger.info("Querying token info using mirror node");
71
- const mirrorNode = this.agentKit.mirrorNode;
72
- if (!mirrorNode) {
73
- this.logger.info(
74
- "MirrorNode not found in agentKit, attempting to access via fetch"
75
- );
76
- const network = this.agentKit.network || "testnet";
77
- const mirrorNodeUrl = network === "mainnet" ? "https://mainnet.mirrornode.hedera.com" : "https://testnet.mirrornode.hedera.com";
78
- const response = await fetch(
79
- `${mirrorNodeUrl}/api/v1/tokens/${tokenId}`
80
- );
81
- if (response.ok) {
82
- const tokenData = await response.json();
83
- const decimals = parseInt(String(tokenData.decimals || "0"));
84
- this.logger.info(
85
- `Token ${tokenId} found with ${decimals} decimals via API`
86
- );
87
- return { ...tokenData, decimals };
88
- }
89
- } else {
90
- const tokenData = await mirrorNode.getTokenInfo(tokenId);
91
- if (tokenData && typeof tokenData.decimals !== "undefined") {
92
- const decimals = parseInt(tokenData.decimals.toString()) || 0;
93
- this.logger.info(`Token ${tokenId} found with ${decimals} decimals`);
94
- return { ...tokenData, decimals };
95
- }
96
- }
97
- throw new Error(`Token data not found or missing decimals field`);
98
- } catch (error) {
99
- this.logger.warn(`Failed to query token info for ${tokenId}:`, error);
100
- this.logger.info(
101
- "Falling back to assumed 0 decimal places (smallest units)"
102
- );
103
- return { decimals: 0 };
104
- }
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
+ );
105
44
  }
106
45
  }
107
46
  export {
108
- AirdropToolWrapper
47
+ TransferHbarTool
109
48
  };
110
49
  //# sourceMappingURL=index37.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index37.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 try {\n return await this.queryTokenInfo(tokenId);\n } catch (error) {\n throw error;\n }\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,E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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;"}
1
+ {"version":3,"file":"index37.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;"}
@@ -1,24 +1,110 @@
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.`;
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
+ try {
63
+ return await this.queryTokenInfo(tokenId);
64
+ } catch (error) {
65
+ throw error;
66
+ }
67
+ }
68
+ async queryTokenInfo(tokenId) {
69
+ try {
70
+ this.logger.info("Querying token info using mirror node");
71
+ const mirrorNode = this.agentKit.mirrorNode;
72
+ if (!mirrorNode) {
73
+ this.logger.info(
74
+ "MirrorNode not found in agentKit, attempting to access via fetch"
75
+ );
76
+ const network = this.agentKit.network || "testnet";
77
+ const mirrorNodeUrl = network === "mainnet" ? "https://mainnet.mirrornode.hedera.com" : "https://testnet.mirrornode.hedera.com";
78
+ const response = await fetch(
79
+ `${mirrorNodeUrl}/api/v1/tokens/${tokenId}`
80
+ );
81
+ if (response.ok) {
82
+ const tokenData = await response.json();
83
+ const decimals = parseInt(String(tokenData.decimals || "0"));
84
+ this.logger.info(
85
+ `Token ${tokenId} found with ${decimals} decimals via API`
86
+ );
87
+ return { ...tokenData, decimals };
88
+ }
89
+ } else {
90
+ const tokenData = await mirrorNode.getTokenInfo(tokenId);
91
+ if (tokenData && typeof tokenData.decimals !== "undefined") {
92
+ const decimals = parseInt(tokenData.decimals.toString()) || 0;
93
+ this.logger.info(`Token ${tokenId} found with ${decimals} decimals`);
94
+ return { ...tokenData, decimals };
95
+ }
96
+ }
97
+ throw new Error(`Token data not found or missing decimals field`);
98
+ } catch (error) {
99
+ this.logger.warn(`Failed to query token info for ${tokenId}:`, error);
100
+ this.logger.info(
101
+ "Falling back to assumed 0 decimal places (smallest units)"
102
+ );
103
+ return { decimals: 0 };
104
+ }
105
+ }
106
+ }
21
107
  export {
22
- getSystemMessage
108
+ AirdropToolWrapper
23
109
  };
24
110
  //# sourceMappingURL=index38.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index38.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;"}
1
+ {"version":3,"file":"index38.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 try {\n return await this.queryTokenInfo(tokenId);\n } catch (error) {\n throw error;\n }\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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N_REFERENCE: "the token"
5
- };
6
- ({
7
- TOPIC: EntityFormat.TOPIC_ID,
8
- TOKEN: EntityFormat.TOKEN_ID,
9
- ACCOUNT: EntityFormat.ACCOUNT_ID,
10
- CONTRACT: EntityFormat.CONTRACT_ID
11
- });
1
+ import { AccountId, Client, PrivateKey, TransactionReceipt, PublicKey } from "@hashgraph/sdk";
2
+ import { AbstractSigner } from "hedera-agent-kit";
3
+ import { HederaMirrorNode, Logger } from "@hashgraphonline/standards-sdk";
4
+ class BrowserSigner extends AbstractSigner {
5
+ getAccountId() {
6
+ return this.account;
7
+ }
8
+ getNetwork() {
9
+ return this.network;
10
+ }
11
+ constructor(accountId, network, executor) {
12
+ super();
13
+ this.account = AccountId.fromString(accountId);
14
+ this.network = network;
15
+ this.client = network === "mainnet" ? Client.forMainnet() : Client.forTestnet();
16
+ this.exec = executor ?? null;
17
+ this.ephemeralKey = PrivateKey.generateED25519();
18
+ }
19
+ /**
20
+ * Returns an auto-generated ED25519 key for client wiring only.
21
+ * Do not use for signing; wallet performs signing in renderer.
22
+ */
23
+ getOperatorPrivateKey() {
24
+ return this.ephemeralKey;
25
+ }
26
+ getClient() {
27
+ return this.client;
28
+ }
29
+ async signAndExecuteTransaction(tx) {
30
+ if (!this.exec) {
31
+ throw new Error("BrowserSigner executor not available");
32
+ }
33
+ if (!tx.isFrozen()) {
34
+ await tx.freezeWith(this.client);
35
+ }
36
+ const base64 = Buffer.from(tx.toBytes()).toString("base64");
37
+ const { transactionId } = await this.exec(base64, this.network);
38
+ const mirror = new HederaMirrorNode(this.network);
39
+ const deadline = Date.now() + 6e4;
40
+ while (Date.now() < deadline) {
41
+ try {
42
+ const details = await mirror.getTransaction(transactionId);
43
+ if (details && details.result) {
44
+ return TransactionReceipt.fromBytes(
45
+ Buffer.from(details.result, "base64")
46
+ );
47
+ }
48
+ } catch {
49
+ }
50
+ await new Promise((r) => setTimeout(r, 1200));
51
+ }
52
+ return TransactionReceipt.fromBytes(Buffer.from(""));
53
+ }
54
+ async getPublicKey() {
55
+ const network = this.network === "mainnet" ? "mainnet" : "testnet";
56
+ const mirror = new HederaMirrorNode(
57
+ network,
58
+ new Logger({ module: "BrowserSigner" })
59
+ );
60
+ const anyKey = await mirror.getPublicKey(this.account.toString());
61
+ const keyStr = typeof anyKey?.toString === "function" ? anyKey.toString() : String(anyKey);
62
+ return PublicKey.fromString(keyStr);
63
+ }
64
+ }
12
65
  export {
13
- ENTITY_PATTERNS
66
+ BrowserSigner,
67
+ BrowserSigner as default
14
68
  };
15
69
  //# sourceMappingURL=index39.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index39.js","sources":["../../src/constants/entity-references.ts"],"sourcesContent":["/**\n * Common entity reference patterns used across the application\n */\nexport const ENTITY_PATTERNS = {\n TOPIC_REFERENCE: 'the topic',\n TOKEN_REFERENCE: 'the token',\n ACCOUNT_REFERENCE: 'the account',\n TRANSACTION_REFERENCE: 'the transaction',\n CONTRACT_REFERENCE: 'the contract',\n} as const;\n\n/**\n * Entity type identifiers\n */\nimport { EntityFormat } from '../services/formatters/types';\n\nexport const ENTITY_TYPES = {\n TOPIC: EntityFormat.TOPIC_ID,\n TOKEN: EntityFormat.TOKEN_ID,\n ACCOUNT: EntityFormat.ACCOUNT_ID,\n TRANSACTION: 'transaction',\n CONTRACT: EntityFormat.CONTRACT_ID,\n} as const;\n"],"names":[],"mappings":";AAGO,MAAM,kBAAkB;AAAA,EAC7B,iBAAiB;AAAA,EACjB,iBAAiB;AAInB;AAAA,CAO4B;AAAA,EAC1B,OAAO,aAAa;AAAA,EACpB,OAAO,aAAa;AAAA,EACpB,SAAS,aAAa;AAAA,EAEtB,UAAU,aAAa;AACzB;"}
1
+ {"version":3,"file":"index39.js","sources":["../../src/signers/browser-signer.ts"],"sourcesContent":["import {\n AccountId,\n Client,\n PrivateKey,\n PublicKey,\n Transaction,\n TransactionReceipt,\n} from '@hashgraph/sdk';\nimport { AbstractSigner } from 'hedera-agent-kit';\nimport {\n HederaMirrorNode,\n Logger,\n type NetworkType,\n} from '@hashgraphonline/standards-sdk';\n\n/**\n * BrowserSigner (bytes-only)\n *\n * Minimal signer compatible with HederaAgentKit in bytes/Provide Bytes mode.\n * - Does NOT hold a private key\n * - Cannot execute transactions; only provides identity and network context\n * - getOperatorPrivateKey() throws to signal absence of a local key\n */\nexport class BrowserSigner extends AbstractSigner {\n private readonly account: AccountId;\n private readonly network: 'mainnet' | 'testnet';\n private readonly client: Client;\n private readonly exec: ((\n base64: string,\n network: 'mainnet' | 'testnet'\n ) => Promise<{ transactionId: string }>) | null;\n private readonly ephemeralKey: PrivateKey;\n\n getAccountId(): AccountId {\n return this.account;\n }\n\n getNetwork(): 'mainnet' | 'testnet' {\n return this.network;\n }\n\n constructor(\n accountId: string,\n network: 'mainnet' | 'testnet',\n executor?: (\n base64: string,\n network: 'mainnet' | 'testnet'\n ) => Promise<{ transactionId: string }>\n ) {\n super();\n this.account = AccountId.fromString(accountId);\n this.network = network;\n this.client =\n network === 'mainnet' ? Client.forMainnet() : Client.forTestnet();\n this.exec = executor ?? null;\n this.ephemeralKey = PrivateKey.generateED25519();\n }\n\n /**\n * Returns an auto-generated ED25519 key for client wiring only.\n * Do not use for signing; wallet performs signing in renderer.\n */\n getOperatorPrivateKey(): PrivateKey {\n return this.ephemeralKey;\n }\n\n getClient(): Client {\n return this.client;\n }\n\n async signAndExecuteTransaction(\n tx: Transaction\n ): Promise<TransactionReceipt> {\n if (!this.exec) {\n throw new Error('BrowserSigner executor not available');\n }\n if (!tx.isFrozen()) {\n await tx.freezeWith(this.client);\n }\n const base64 = Buffer.from(tx.toBytes()).toString('base64');\n const { transactionId } = await this.exec(base64, this.network);\n const mirror = new HederaMirrorNode(this.network);\n const deadline = Date.now() + 60000;\n while (Date.now() < deadline) {\n try {\n const details = await mirror.getTransaction(transactionId);\n if (details && details.result) {\n return TransactionReceipt.fromBytes(\n Buffer.from(details.result, 'base64')\n );\n }\n } catch {}\n await new Promise((r) => setTimeout(r, 1200));\n }\n return TransactionReceipt.fromBytes(Buffer.from(''));\n }\n\n override async getPublicKey(): Promise<PublicKey> {\n const network: NetworkType =\n this.network === 'mainnet' ? 'mainnet' : 'testnet';\n const mirror = new HederaMirrorNode(\n network,\n new Logger({ module: 'BrowserSigner' })\n );\n // Avoid cross-package PublicKey type incompatibility by reconstructing from string\n const anyKey: any = await mirror.getPublicKey(this.account.toString());\n const keyStr = typeof anyKey?.toString === 'function' ? anyKey.toString() : String(anyKey);\n return PublicKey.fromString(keyStr);\n }\n}\n\nexport default BrowserSigner;\n"],"names":[],"mappings":";;;AAuBO,MAAM,sBAAsB,eAAe;AAAA,EAUhD,eAA0B;AACxB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,aAAoC;AAClC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,YACE,WACA,SACA,UAIA;AACA,UAAA;AACA,SAAK,UAAU,UAAU,WAAW,SAAS;AAC7C,SAAK,UAAU;AACf,SAAK,SACH,YAAY,YAAY,OAAO,WAAA,IAAe,OAAO,WAAA;AACvD,SAAK,OAAO,YAAY;AACxB,SAAK,eAAe,WAAW,gBAAA;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,wBAAoC;AAClC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,YAAoB;AAClB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,0BACJ,IAC6B;AAC7B,QAAI,CAAC,KAAK,MAAM;AACd,YAAM,IAAI,MAAM,sCAAsC;AAAA,IACxD;AACA,QAAI,CAAC,GAAG,YAAY;AAClB,YAAM,GAAG,WAAW,KAAK,MAAM;AAAA,IACjC;AACA,UAAM,SAAS,OAAO,KAAK,GAAG,SAAS,EAAE,SAAS,QAAQ;AAC1D,UAAM,EAAE,kBAAkB,MAAM,KAAK,KAAK,QAAQ,KAAK,OAAO;AAC9D,UAAM,SAAS,IAAI,iBAAiB,KAAK,OAAO;AAChD,UAAM,WAAW,KAAK,IAAA,IAAQ;AAC9B,WAAO,KAAK,IAAA,IAAQ,UAAU;AAC5B,UAAI;AACF,cAAM,UAAU,MAAM,OAAO,eAAe,aAAa;AACzD,YAAI,WAAW,QAAQ,QAAQ;AAC7B,iBAAO,mBAAmB;AAAA,YACxB,OAAO,KAAK,QAAQ,QAAQ,QAAQ;AAAA,UAAA;AAAA,QAExC;AAAA,MACF,QAAQ;AAAA,MAAC;AACT,YAAM,IAAI,QAAQ,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC;AAAA,IAC9C;AACA,WAAO,mBAAmB,UAAU,OAAO,KAAK,EAAE,CAAC;AAAA,EACrD;AAAA,EAEA,MAAe,eAAmC;AAChD,UAAM,UACJ,KAAK,YAAY,YAAY,YAAY;AAC3C,UAAM,SAAS,IAAI;AAAA,MACjB;AAAA,MACA,IAAI,OAAO,EAAE,QAAQ,iBAAiB;AAAA,IAAA;AAGxC,UAAM,SAAc,MAAM,OAAO,aAAa,KAAK,QAAQ,UAAU;AACrE,UAAM,SAAS,OAAO,QAAQ,aAAa,aAAa,OAAO,SAAA,IAAa,OAAO,MAAM;AACzF,WAAO,UAAU,WAAW,MAAM;AAAA,EACpC;AACF;"}
@@ -1,5 +1,6 @@
1
1
  import { BasePlugin } from "hedera-agent-kit";
2
2
  import { InscriberBuilder, InscribeFromUrlTool, InscribeFromFileTool, InscribeFromBufferTool, InscribeHashinalTool, RetrieveInscriptionTool } from "@hashgraphonline/standards-agent-kit";
3
+ import { fieldGuidanceRegistry } from "./index13.js";
3
4
  class InscribePlugin extends BasePlugin {
4
5
  constructor() {
5
6
  super(...arguments);
@@ -10,6 +11,7 @@ class InscribePlugin extends BasePlugin {
10
11
  this.author = "Hashgraph Online";
11
12
  this.namespace = "inscribe";
12
13
  this.tools = [];
14
+ this.providerId = null;
13
15
  }
14
16
  async initialize(context) {
15
17
  await super.initialize(context);
@@ -22,6 +24,40 @@ class InscribePlugin extends BasePlugin {
22
24
  }
23
25
  try {
24
26
  this.initializeTools();
27
+ try {
28
+ const provider = {
29
+ getFieldGuidance: (fieldName) => {
30
+ if (fieldName === "name") {
31
+ return {
32
+ suggestions: [
33
+ "Sunset Landscape #42",
34
+ "Digital Abstract Art"
35
+ ],
36
+ contextualHelpText: "Create a distinctive name that collectors will find appealing"
37
+ };
38
+ }
39
+ if (fieldName === "description") {
40
+ return {
41
+ fieldTypeOverride: "textarea",
42
+ suggestions: ["A beautiful piece representing..."]
43
+ };
44
+ }
45
+ return null;
46
+ },
47
+ getGlobalGuidance: () => ({
48
+ qualityStandards: [
49
+ "Use meaningful names that describe the artwork or content"
50
+ ]
51
+ })
52
+ };
53
+ this.providerId = fieldGuidanceRegistry.registerToolProvider(
54
+ /inscribe.*hashinal/i,
55
+ provider,
56
+ { id: "inscribe:hashinal:provider", priority: 1 }
57
+ );
58
+ } catch (e) {
59
+ this.context.logger.warn("Could not register Inscribe field guidance provider");
60
+ }
25
61
  this.context.logger.info(
26
62
  "Inscribe Plugin initialized successfully"
27
63
  );
@@ -71,6 +107,13 @@ class InscribePlugin extends BasePlugin {
71
107
  }
72
108
  async cleanup() {
73
109
  this.tools = [];
110
+ if (this.providerId) {
111
+ try {
112
+ fieldGuidanceRegistry.unregisterProvider(this.providerId);
113
+ } catch {
114
+ }
115
+ this.providerId = null;
116
+ }
74
117
  if (this.context?.logger) {
75
118
  this.context.logger.info("Inscribe Plugin cleaned up");
76
119
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index4.js","sources":["../../src/plugins/inscribe/InscribePlugin.ts"],"sourcesContent":["import {\n GenericPluginContext,\n HederaTool,\n BasePlugin,\n HederaAgentKit,\n} from 'hedera-agent-kit';\nimport {\n InscriberBuilder,\n InscribeFromUrlTool,\n InscribeFromFileTool,\n InscribeFromBufferTool,\n InscribeHashinalTool,\n RetrieveInscriptionTool,\n} from '@hashgraphonline/standards-agent-kit';\n\n/**\n * Plugin providing content inscription tools for Hedera\n */\nexport class InscribePlugin extends BasePlugin {\n id = 'inscribe';\n name = 'Inscribe Plugin';\n description =\n 'Content inscription tools for storing data on Hedera Consensus Service';\n version = '1.0.0';\n author = 'Hashgraph Online';\n namespace = 'inscribe';\n\n private tools: HederaTool[] = [];\n\n override async initialize(context: GenericPluginContext): Promise<void> {\n await super.initialize(context);\n\n const hederaKit = context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n this.context.logger.warn(\n 'HederaKit not found in context. Inscription tools will not be available.'\n );\n return;\n }\n\n try {\n this.initializeTools();\n\n this.context.logger.info(\n 'Inscribe Plugin initialized successfully'\n );\n } catch (error) {\n this.context.logger.error(\n 'Failed to initialize Inscribe plugin:',\n error\n );\n }\n }\n\n private initializeTools(): void {\n const hederaKit = this.context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n throw new Error('HederaKit not found in context config');\n }\n\n const inscriberBuilder = new InscriberBuilder(hederaKit);\n\n this.tools = [\n new InscribeFromUrlTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new InscribeFromFileTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new InscribeFromBufferTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new InscribeHashinalTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new RetrieveInscriptionTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n ];\n }\n\n getTools(): HederaTool[] {\n return this.tools;\n }\n\n override async cleanup(): Promise<void> {\n this.tools = [];\n if (this.context?.logger) {\n this.context.logger.info('Inscribe Plugin cleaned up');\n }\n }\n}"],"names":[],"mappings":";;AAkBO,MAAM,uBAAuB,WAAW;AAAA,EAAxC,cAAA;AAAA,UAAA,GAAA,SAAA;AACL,SAAA,KAAK;AACL,SAAA,OAAO;AACP,SAAA,cACE;AACF,SAAA,UAAU;AACV,SAAA,SAAS;AACT,SAAA,YAAY;AAEZ,SAAQ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xB,WAAK,QAAQ,OAAO,KAAK,4BAA4B;AAAA,IACvD;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"index4.js","sources":["../../src/plugins/inscribe/InscribePlugin.ts"],"sourcesContent":["import {\n GenericPluginContext,\n HederaTool,\n BasePlugin,\n HederaAgentKit,\n} from 'hedera-agent-kit';\nimport {\n InscriberBuilder,\n InscribeFromUrlTool,\n InscribeFromFileTool,\n InscribeFromBufferTool,\n InscribeHashinalTool,\n RetrieveInscriptionTool,\n} from '@hashgraphonline/standards-agent-kit';\nimport { fieldGuidanceRegistry, type FieldGuidance } from '../../forms/field-guidance-registry';\n\n/**\n * Plugin providing content inscription tools for Hedera\n */\nexport class InscribePlugin extends BasePlugin {\n id = 'inscribe';\n name = 'Inscribe Plugin';\n description =\n 'Content inscription tools for storing data on Hedera Consensus Service';\n version = '1.0.0';\n author = 'Hashgraph Online';\n namespace = 'inscribe';\n\n private tools: any[] = [];\n private providerId: string | null = null;\n\n override async initialize(context: GenericPluginContext): Promise<void> {\n await super.initialize(context);\n\n const hederaKit = context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n this.context.logger.warn(\n 'HederaKit not found in context. Inscription tools will not be available.'\n );\n return;\n }\n\n try {\n this.initializeTools();\n\n // Register field guidance provider for inscribe hashinal tools\n try {\n const provider = {\n getFieldGuidance: (fieldName: string): FieldGuidance | null => {\n if (fieldName === 'name') {\n return {\n suggestions: [\n 'Sunset Landscape #42',\n 'Digital Abstract Art',\n ],\n contextualHelpText:\n 'Create a distinctive name that collectors will find appealing',\n };\n }\n if (fieldName === 'description') {\n return {\n fieldTypeOverride: 'textarea',\n suggestions: ['A beautiful piece representing...'],\n };\n }\n return null;\n },\n getGlobalGuidance: () => ({\n qualityStandards: [\n 'Use meaningful names that describe the artwork or content',\n ],\n }),\n };\n this.providerId = fieldGuidanceRegistry.registerToolProvider(\n /inscribe.*hashinal/i,\n provider,\n { id: 'inscribe:hashinal:provider', priority: 1 }\n );\n } catch (e) {\n this.context.logger.warn('Could not register Inscribe field guidance provider');\n }\n\n this.context.logger.info(\n 'Inscribe Plugin initialized successfully'\n );\n } catch (error) {\n this.context.logger.error(\n 'Failed to initialize Inscribe plugin:',\n error\n );\n }\n }\n\n private initializeTools(): void {\n const hederaKit = this.context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n throw new Error('HederaKit not found in context config');\n }\n\n const inscriberBuilder = new InscriberBuilder(hederaKit);\n\n this.tools = [\n new InscribeFromUrlTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new InscribeFromFileTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new InscribeFromBufferTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new InscribeHashinalTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new RetrieveInscriptionTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n ];\n }\n\n getTools(): HederaTool[] {\n return this.tools;\n }\n\n override async cleanup(): Promise<void> {\n this.tools = [];\n if (this.providerId) {\n try {\n fieldGuidanceRegistry.unregisterProvider(this.providerId);\n } catch {}\n this.providerId = null;\n }\n if (this.context?.logger) {\n this.context.logger.info('Inscribe Plugin cleaned up');\n }\n }\n}\n"],"names":[],"mappings":";;;AAmBO,MAAM,uBAAuB,WAAW;AAAA,EAAxC,cAAA;AAAA,UAAA,GAAA,SAAA;AACL,SAAA,KAAK;AACL,SAAA,OAAO;AACP,SAAA,cACE;AACF,SAAA,UAAU;AACV,SAAA,SAAS;AACT,SAAA,YAAY;AAEZ,SAAQ,QAAe,CAAA;AACvB,SAAQ,aAA4B;AAAA,EAAA;AAAA,EAEpC,MAAe,WAAW,SAA8C;AACtE,UAAM,MAAM,WAAW,OAAO;AAE9B,UAAM,YAAY,QAAQ,OAAO;AACj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AAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,uBAAuB;AAAA,QACzB;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,qBAAqB;AAAA,QACvB;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,wBAAwB;AAAA,QAC1B;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,IAAA;AAAA,EAEL;AAAA,EAEA,WAAyB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAe,UAAyB;AACtC,SAAK,QAAQ,CAAA;AACb,QAAI,KAAK,YAAY;AACnB,UAAI;AACF,8BAAsB,mBAAmB,KAAK,UAAU;AAAA,MAC1D,QAAQ;AAAA,MAAC;AACT,WAAK,aAAa;AAAA,IACpB;AACA,QAAI,KAAK,SAAS,QAAQ;AACxB,WAAK,QAAQ,OAAO,KAAK,4BAA4B;AAAA,IACvD;AAAA,EACF;AACF;"}
@@ -1,10 +1,24 @@
1
- const FIELD_PRIORITIES = {
2
- ESSENTIAL: "essential",
3
- COMMON: "common",
4
- ADVANCED: "advanced",
5
- EXPERT: "expert"
6
- };
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.`;
7
21
  export {
8
- FIELD_PRIORITIES
22
+ getSystemMessage
9
23
  };
10
24
  //# sourceMappingURL=index40.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index40.js","sources":["../../src/constants/form-priorities.ts"],"sourcesContent":["/**\n * Form field priorities for progressive disclosure\n */\nexport const FIELD_PRIORITIES = {\n ESSENTIAL: 'essential',\n COMMON: 'common', \n ADVANCED: 'advanced',\n EXPERT: 'expert'\n} as const;\n\n/**\n * Form field types\n */\nexport const FORM_FIELD_TYPES = {\n TEXT: 'text',\n NUMBER: 'number',\n SELECT: 'select',\n CHECKBOX: 'checkbox',\n TEXTAREA: 'textarea',\n FILE: 'file',\n ARRAY: 'array',\n OBJECT: 'object',\n CURRENCY: 'currency',\n PERCENTAGE: 'percentage',\n} as const;"],"names":[],"mappings":"AAGO,MAAM,mBAAmB;AAAA,EAC9B,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,QAAQ;AACV;"}
1
+ {"version":3,"file":"index40.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;"}