@hashgraphonline/standards-agent-kit 0.2.112 → 0.2.113

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 (126) hide show
  1. package/dist/cjs/index.d.ts +1 -1
  2. package/dist/cjs/standards-agent-kit.cjs +1 -1
  3. package/dist/cjs/standards-agent-kit.cjs.map +1 -1
  4. package/dist/cjs/tools/hcs6/CreateDynamicRegistryTool.d.ts +44 -0
  5. package/dist/cjs/tools/hcs6/QueryDynamicRegistryTool.d.ts +50 -0
  6. package/dist/cjs/tools/hcs6/RegisterDynamicHashinalTool.d.ts +102 -0
  7. package/dist/cjs/tools/hcs6/UpdateDynamicHashinalTool.d.ts +96 -0
  8. package/dist/cjs/tools/hcs6/base-hcs6-tools.d.ts +28 -0
  9. package/dist/cjs/tools/hcs6/hcs6-tool-params.d.ts +18 -0
  10. package/dist/cjs/tools/hcs6/index.d.ts +6 -0
  11. package/dist/cjs/tools/index.d.ts +1 -0
  12. package/dist/cjs/tools/inscriber/InscribeFromBufferTool.d.ts +4 -4
  13. package/dist/es/index.d.ts +1 -1
  14. package/dist/es/standards-agent-kit.es.js +44 -31
  15. package/dist/es/standards-agent-kit.es.js.map +1 -1
  16. package/dist/es/standards-agent-kit.es10.js +27 -27
  17. package/dist/es/standards-agent-kit.es10.js.map +1 -1
  18. package/dist/es/standards-agent-kit.es11.js +20 -30
  19. package/dist/es/standards-agent-kit.es11.js.map +1 -1
  20. package/dist/es/standards-agent-kit.es12.js +27 -37
  21. package/dist/es/standards-agent-kit.es12.js.map +1 -1
  22. package/dist/es/standards-agent-kit.es13.js +48 -60
  23. package/dist/es/standards-agent-kit.es13.js.map +1 -1
  24. package/dist/es/standards-agent-kit.es14.js +60 -23
  25. package/dist/es/standards-agent-kit.es14.js.map +1 -1
  26. package/dist/es/standards-agent-kit.es15.js +23 -23
  27. package/dist/es/standards-agent-kit.es15.js.map +1 -1
  28. package/dist/es/standards-agent-kit.es16.js +23 -33
  29. package/dist/es/standards-agent-kit.es16.js.map +1 -1
  30. package/dist/es/standards-agent-kit.es17.js +34 -10
  31. package/dist/es/standards-agent-kit.es17.js.map +1 -1
  32. package/dist/es/standards-agent-kit.es18.js +16 -155
  33. package/dist/es/standards-agent-kit.es18.js.map +1 -1
  34. package/dist/es/standards-agent-kit.es19.js +150 -22
  35. package/dist/es/standards-agent-kit.es19.js.map +1 -1
  36. package/dist/es/standards-agent-kit.es20.js +25 -39
  37. package/dist/es/standards-agent-kit.es20.js.map +1 -1
  38. package/dist/es/standards-agent-kit.es21.js +26 -28
  39. package/dist/es/standards-agent-kit.es21.js.map +1 -1
  40. package/dist/es/standards-agent-kit.es22.js +16 -19
  41. package/dist/es/standards-agent-kit.es22.js.map +1 -1
  42. package/dist/es/standards-agent-kit.es23.js +21 -15
  43. package/dist/es/standards-agent-kit.es23.js.map +1 -1
  44. package/dist/es/standards-agent-kit.es24.js +18 -21
  45. package/dist/es/standards-agent-kit.es24.js.map +1 -1
  46. package/dist/es/standards-agent-kit.es25.js +35 -32
  47. package/dist/es/standards-agent-kit.es25.js.map +1 -1
  48. package/dist/es/standards-agent-kit.es26.js +38 -25
  49. package/dist/es/standards-agent-kit.es26.js.map +1 -1
  50. package/dist/es/standards-agent-kit.es27.js +25 -116
  51. package/dist/es/standards-agent-kit.es27.js.map +1 -1
  52. package/dist/es/standards-agent-kit.es28.js +33 -166
  53. package/dist/es/standards-agent-kit.es28.js.map +1 -1
  54. package/dist/es/standards-agent-kit.es29.js +42 -121
  55. package/dist/es/standards-agent-kit.es29.js.map +1 -1
  56. package/dist/es/standards-agent-kit.es30.js +40 -77
  57. package/dist/es/standards-agent-kit.es30.js.map +1 -1
  58. package/dist/es/standards-agent-kit.es31.js +42 -37
  59. package/dist/es/standards-agent-kit.es31.js.map +1 -1
  60. package/dist/es/standards-agent-kit.es32.js +20 -237
  61. package/dist/es/standards-agent-kit.es32.js.map +1 -1
  62. package/dist/es/standards-agent-kit.es33.js +154 -135
  63. package/dist/es/standards-agent-kit.es33.js.map +1 -1
  64. package/dist/es/standards-agent-kit.es34.js +168 -23
  65. package/dist/es/standards-agent-kit.es34.js.map +1 -1
  66. package/dist/es/standards-agent-kit.es35.js +126 -21
  67. package/dist/es/standards-agent-kit.es35.js.map +1 -1
  68. package/dist/es/standards-agent-kit.es36.js +86 -3
  69. package/dist/es/standards-agent-kit.es36.js.map +1 -1
  70. package/dist/es/standards-agent-kit.es37.js +45 -0
  71. package/dist/es/standards-agent-kit.es37.js.map +1 -0
  72. package/dist/es/standards-agent-kit.es38.js +249 -0
  73. package/dist/es/standards-agent-kit.es38.js.map +1 -0
  74. package/dist/es/standards-agent-kit.es39.js +141 -0
  75. package/dist/es/standards-agent-kit.es39.js.map +1 -0
  76. package/dist/es/standards-agent-kit.es4.js +65 -32
  77. package/dist/es/standards-agent-kit.es4.js.map +1 -1
  78. package/dist/es/standards-agent-kit.es40.js +33 -0
  79. package/dist/es/standards-agent-kit.es40.js.map +1 -0
  80. package/dist/es/standards-agent-kit.es41.js +28 -0
  81. package/dist/es/standards-agent-kit.es41.js.map +1 -0
  82. package/dist/es/standards-agent-kit.es42.js +7 -0
  83. package/dist/es/standards-agent-kit.es42.js.map +1 -0
  84. package/dist/es/standards-agent-kit.es5.js +35 -311
  85. package/dist/es/standards-agent-kit.es5.js.map +1 -1
  86. package/dist/es/standards-agent-kit.es6.js +320 -20
  87. package/dist/es/standards-agent-kit.es6.js.map +1 -1
  88. package/dist/es/standards-agent-kit.es7.js +19 -227
  89. package/dist/es/standards-agent-kit.es7.js.map +1 -1
  90. package/dist/es/standards-agent-kit.es8.js +216 -65
  91. package/dist/es/standards-agent-kit.es8.js.map +1 -1
  92. package/dist/es/standards-agent-kit.es9.js +72 -23
  93. package/dist/es/standards-agent-kit.es9.js.map +1 -1
  94. package/dist/es/tools/hcs6/CreateDynamicRegistryTool.d.ts +44 -0
  95. package/dist/es/tools/hcs6/QueryDynamicRegistryTool.d.ts +50 -0
  96. package/dist/es/tools/hcs6/RegisterDynamicHashinalTool.d.ts +102 -0
  97. package/dist/es/tools/hcs6/UpdateDynamicHashinalTool.d.ts +96 -0
  98. package/dist/es/tools/hcs6/base-hcs6-tools.d.ts +28 -0
  99. package/dist/es/tools/hcs6/hcs6-tool-params.d.ts +18 -0
  100. package/dist/es/tools/hcs6/index.d.ts +6 -0
  101. package/dist/es/tools/index.d.ts +1 -0
  102. package/dist/es/tools/inscriber/InscribeFromBufferTool.d.ts +4 -4
  103. package/dist/umd/index.d.ts +1 -1
  104. package/dist/umd/standards-agent-kit.umd.js +1 -1
  105. package/dist/umd/standards-agent-kit.umd.js.map +1 -1
  106. package/dist/umd/tools/hcs6/CreateDynamicRegistryTool.d.ts +44 -0
  107. package/dist/umd/tools/hcs6/QueryDynamicRegistryTool.d.ts +50 -0
  108. package/dist/umd/tools/hcs6/RegisterDynamicHashinalTool.d.ts +102 -0
  109. package/dist/umd/tools/hcs6/UpdateDynamicHashinalTool.d.ts +96 -0
  110. package/dist/umd/tools/hcs6/base-hcs6-tools.d.ts +28 -0
  111. package/dist/umd/tools/hcs6/hcs6-tool-params.d.ts +18 -0
  112. package/dist/umd/tools/hcs6/index.d.ts +6 -0
  113. package/dist/umd/tools/index.d.ts +1 -0
  114. package/dist/umd/tools/inscriber/InscribeFromBufferTool.d.ts +4 -4
  115. package/package.json +1 -1
  116. package/src/index.ts +1 -1
  117. package/src/tools/hcs6/CreateDynamicRegistryTool.ts +66 -0
  118. package/src/tools/hcs6/QueryDynamicRegistryTool.ts +72 -0
  119. package/src/tools/hcs6/RegisterDynamicHashinalTool.ts +79 -0
  120. package/src/tools/hcs6/UpdateDynamicHashinalTool.ts +74 -0
  121. package/src/tools/hcs6/base-hcs6-tools.ts +63 -0
  122. package/src/tools/hcs6/hcs6-tool-params.ts +21 -0
  123. package/src/tools/hcs6/index.ts +6 -0
  124. package/src/tools/index.ts +1 -0
  125. package/src/tools/inscriber/InscribeFromBufferTool.ts +1 -1
  126. package/src/tools/inscriber/InscribeFromUrlTool.ts +60 -7
@@ -0,0 +1,33 @@
1
+ import { BasePlugin, HederaGetHbarPriceTool } from "hedera-agent-kit";
2
+ import { HederaGetHbarPriceTool as HederaGetHbarPriceTool2 } from "hedera-agent-kit";
3
+ class HbarPricePlugin extends BasePlugin {
4
+ constructor() {
5
+ super(...arguments);
6
+ this.id = "hedera-hbar-price";
7
+ this.name = "Hedera HBAR Price Plugin";
8
+ this.description = "Provides tools to interact with Hedera network data, specifically HBAR price.";
9
+ this.version = "1.0.0";
10
+ this.author = "Hashgraph Online";
11
+ this.tools = [];
12
+ }
13
+ async initialize(context) {
14
+ await super.initialize(context);
15
+ this.initializeTools();
16
+ }
17
+ initializeTools() {
18
+ this.tools = [
19
+ new HederaGetHbarPriceTool({
20
+ hederaKit: this.context.config.hederaKit,
21
+ logger: this.context.logger
22
+ })
23
+ ];
24
+ }
25
+ getTools() {
26
+ return this.tools;
27
+ }
28
+ }
29
+ export {
30
+ HederaGetHbarPriceTool2 as GetHbarPriceTool,
31
+ HbarPricePlugin
32
+ };
33
+ //# sourceMappingURL=standards-agent-kit.es40.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standards-agent-kit.es40.js","sources":["../../src/plugins/hedera/HbarPricePlugin.ts"],"sourcesContent":["// Re-export the HBAR price tool from hedera-agent-kit\nexport { HederaGetHbarPriceTool as GetHbarPriceTool } from 'hedera-agent-kit';\n\nimport { BasePlugin, GenericPluginContext, HederaTool, HederaAgentKit } from 'hedera-agent-kit';\nimport { HederaGetHbarPriceTool } from 'hedera-agent-kit';\n\n/**\n * Plugin to provide tools related to Hedera network information, like HBAR price.\n * Uses the built-in HederaGetHbarPriceTool from hedera-agent-kit.\n */\nexport class HbarPricePlugin extends BasePlugin<GenericPluginContext> {\n id = 'hedera-hbar-price';\n name = 'Hedera HBAR Price Plugin';\n description = 'Provides tools to interact with Hedera network data, specifically HBAR price.';\n version = '1.0.0';\n author = 'Hashgraph Online';\n\n private tools: HederaTool[] = [];\n\n override async initialize(context: GenericPluginContext): Promise<void> {\n await super.initialize(context);\n this.initializeTools();\n }\n\n private initializeTools(): void {\n this.tools = [\n new HederaGetHbarPriceTool({\n hederaKit: this.context.config.hederaKit as HederaAgentKit,\n logger: this.context.logger\n })\n ];\n }\n\n getTools(): HederaTool[] {\n return this.tools;\n }\n}"],"names":["HederaGetHbarPriceTool"],"mappings":";;AAUO,MAAM,wBAAwB,WAAiC;AAAA,EAA/D,cAAA;AAAA,UAAA,GAAA,SAAA;AACL,SAAA,KAAK;AACL,SAAA,OAAO;AACP,SAAA,cAAc;AACd,SAAA,UAAU;AACV,SAAA,SAAS;AAET,SAAQ,QAAsB,CAAA;AAAA,EAAC;AAAA,EAE/B,MAAe,WAAW,SAA8C;AACtE,UAAM,MAAM,WAAW,OAAO;AAC9B,SAAK,gBAAA;AAAA,EACP;AAAA,EAEQ,kBAAwB;AAC9B,SAAK,QAAQ;AAAA,MACX,IAAIA,uBAAuB;AAAA,QACzB,WAAW,KAAK,QAAQ,OAAO;AAAA,QAC/B,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,IAAA;AAAA,EAEL;AAAA,EAEA,WAAyB;AACvB,WAAO,KAAK;AAAA,EACd;AACF;"}
@@ -0,0 +1,28 @@
1
+ import "@hashgraphonline/standards-sdk";
2
+ import fs from "fs";
3
+ import path__default from "path";
4
+ const ENV_FILE_PATH = path__default.join(process.cwd(), ".env");
5
+ async function updateEnvFile(envFilePath, variables) {
6
+ let envContent = "";
7
+ if (fs.existsSync(envFilePath)) {
8
+ envContent = fs.readFileSync(envFilePath, "utf8");
9
+ }
10
+ const envLines = envContent.split("\n");
11
+ const updatedLines = [...envLines];
12
+ for (const [key, value] of Object.entries(variables)) {
13
+ const lineIndex = updatedLines.findIndex(
14
+ (line) => line.startsWith(`${key}=`)
15
+ );
16
+ if (lineIndex !== -1) {
17
+ updatedLines[lineIndex] = `${key}=${value}`;
18
+ } else {
19
+ updatedLines.push(`${key}=${value}`);
20
+ }
21
+ }
22
+ fs.writeFileSync(envFilePath, updatedLines.join("\n"));
23
+ }
24
+ export {
25
+ ENV_FILE_PATH,
26
+ updateEnvFile
27
+ };
28
+ //# sourceMappingURL=standards-agent-kit.es41.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standards-agent-kit.es41.js","sources":["../../src/utils/state-tools.ts"],"sourcesContent":["import {\n HCS10Client,\n AgentBuilder,\n Logger,\n} from '@hashgraphonline/standards-sdk';\nimport fs from 'fs';\nimport path from 'path';\nimport { ensureAgentHasEnoughHbar } from './ensure-agent-has-hbar';\n\nexport const ENV_FILE_PATH = path.join(process.cwd(), '.env');\n\nexport interface AgentData {\n accountId: string;\n operatorId: string;\n inboundTopicId: string;\n outboundTopicId: string;\n client: HCS10Client;\n}\n\nexport interface RegistrationProgressData {\n registered: boolean;\n accountId?: string;\n privateKey?: string;\n publicKey?: string;\n inboundTopicId?: string;\n outboundTopicId?: string;\n}\n\nexport async function getAgentFromEnv(\n logger: Logger,\n baseClient: HCS10Client,\n agentName: string,\n envPrefix: string\n): Promise<AgentData | null> {\n const accountIdEnvVar = `${envPrefix}_ACCOUNT_ID`;\n const privateKeyEnvVar = `${envPrefix}_PRIVATE_KEY`;\n const inboundTopicIdEnvVar = `${envPrefix}_INBOUND_TOPIC_ID`;\n const outboundTopicIdEnvVar = `${envPrefix}_OUTBOUND_TOPIC_ID`;\n\n const accountId = process.env[accountIdEnvVar];\n const privateKey = process.env[privateKeyEnvVar];\n const inboundTopicId = process.env[inboundTopicIdEnvVar];\n const outboundTopicId = process.env[outboundTopicIdEnvVar];\n\n if (!accountId || !privateKey || !inboundTopicId || !outboundTopicId) {\n logger.info(`${agentName} agent not found in environment variables`);\n return null;\n }\n\n logger.info(`${agentName} agent found in environment variables`);\n logger.info(`${agentName} account ID: ${accountId}`);\n logger.info(`${agentName} inbound topic ID: ${inboundTopicId}`);\n logger.info(`${agentName} outbound topic ID: ${outboundTopicId}`);\n\n const client = new HCS10Client({\n network: 'testnet',\n operatorId: accountId,\n operatorPrivateKey: privateKey,\n guardedRegistryBaseUrl: process.env.REGISTRY_URL,\n prettyPrint: true,\n logLevel: 'debug',\n });\n\n await ensureAgentHasEnoughHbar(logger, baseClient, accountId, agentName);\n\n return {\n accountId,\n operatorId: `${inboundTopicId}@${accountId}`,\n inboundTopicId,\n outboundTopicId,\n client,\n };\n}\n\nexport async function createAgent(\n logger: Logger,\n baseClient: HCS10Client,\n agentName: string,\n agentBuilder: AgentBuilder,\n envPrefix: string\n): Promise<AgentData | null> {\n try {\n logger.info(`Creating ${agentName} agent...`);\n\n const result = await baseClient.createAndRegisterAgent(agentBuilder);\n\n if (!result.metadata) {\n logger.error(`${agentName} agent creation failed`);\n return null;\n }\n\n logger.info(`${agentName} agent created successfully`);\n logger.info(`${agentName} account ID: ${result.metadata.accountId}`);\n logger.info(`${agentName} private key: ${result.metadata.privateKey}`);\n logger.info(\n `${agentName} inbound topic ID: ${result.metadata.inboundTopicId}`\n );\n logger.info(\n `${agentName} outbound topic ID: ${result.metadata.outboundTopicId}`\n );\n\n const envVars = {\n [`${envPrefix}_ACCOUNT_ID`]: result.metadata.accountId,\n [`${envPrefix}_PRIVATE_KEY`]: result.metadata.privateKey,\n [`${envPrefix}_INBOUND_TOPIC_ID`]: result.metadata.inboundTopicId,\n [`${envPrefix}_OUTBOUND_TOPIC_ID`]: result.metadata.outboundTopicId,\n };\n\n await updateEnvFile(ENV_FILE_PATH, envVars);\n\n const client = new HCS10Client({\n network: 'testnet',\n operatorId: result.metadata.accountId,\n operatorPrivateKey: result.metadata.privateKey,\n guardedRegistryBaseUrl: process.env.REGISTRY_URL,\n prettyPrint: true,\n logLevel: 'debug',\n });\n\n return {\n accountId: result.metadata.accountId,\n operatorId: `${result.metadata.inboundTopicId}@${result.metadata.accountId}`,\n inboundTopicId: result.metadata.inboundTopicId,\n outboundTopicId: result.metadata.outboundTopicId,\n client,\n };\n } catch (error) {\n console.log('error', error, baseClient);\n logger.error(`Error creating ${agentName} agent:`, error);\n return null;\n }\n}\n\nexport async function updateEnvFile(\n envFilePath: string,\n variables: Record<string, string>\n): Promise<void> {\n let envContent = '';\n\n if (fs.existsSync(envFilePath)) {\n envContent = fs.readFileSync(envFilePath, 'utf8');\n }\n\n const envLines = envContent.split('\\n');\n const updatedLines = [...envLines];\n\n for (const [key, value] of Object.entries(variables)) {\n const lineIndex = updatedLines.findIndex((line) =>\n line.startsWith(`${key}=`)\n );\n\n if (lineIndex !== -1) {\n updatedLines[lineIndex] = `${key}=${value}`;\n } else {\n updatedLines.push(`${key}=${value}`);\n }\n }\n\n fs.writeFileSync(envFilePath, updatedLines.join('\\n'));\n}\n"],"names":["path"],"mappings":";;;AASO,MAAM,gBAAgBA,cAAK,KAAK,QAAQ,IAAA,GAAO,MAAM;AA4H5D,eAAsB,cACpB,aACA,WACe;AACf,MAAI,aAAa;AAEjB,MAAI,GAAG,WAAW,WAAW,GAAG;AAC9B,iBAAa,GAAG,aAAa,aAAa,MAAM;AAAA,EAClD;AAEA,QAAM,WAAW,WAAW,MAAM,IAAI;AACtC,QAAM,eAAe,CAAC,GAAG,QAAQ;AAEjC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,SAAS,GAAG;AACpD,UAAM,YAAY,aAAa;AAAA,MAAU,CAAC,SACxC,KAAK,WAAW,GAAG,GAAG,GAAG;AAAA,IAAA;AAG3B,QAAI,cAAc,IAAI;AACpB,mBAAa,SAAS,IAAI,GAAG,GAAG,IAAI,KAAK;AAAA,IAC3C,OAAO;AACL,mBAAa,KAAK,GAAG,GAAG,IAAI,KAAK,EAAE;AAAA,IACrC;AAAA,EACF;AAEA,KAAG,cAAc,aAAa,aAAa,KAAK,IAAI,CAAC;AACvD;"}
@@ -0,0 +1,7 @@
1
+ function encryptMessage(message) {
2
+ return message;
3
+ }
4
+ export {
5
+ encryptMessage
6
+ };
7
+ //# sourceMappingURL=standards-agent-kit.es42.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standards-agent-kit.es42.js","sources":["../../src/utils/Encryption.ts"],"sourcesContent":["// src/utils/Encryption.ts\n/**\n * Placeholder for encryption functionality.\n * Currently, encryption is disabled. The useEncryption flag is false by default.\n * TODO: Implement actual encryption/decryption logic.\n */\n\nexport function encryptMessage(message: string): string {\n // TODO: Add encryption logic here if useEncryption flag is true.\n return message; // currently returns plaintext.\n}\n\nexport function decryptMessage(encryptedMessage: string): string {\n // TODO: Add decryption logic here.\n return encryptedMessage;\n}\n"],"names":[],"mappings":"AAOO,SAAS,eAAe,SAAyB;AAEpD,SAAO;AACX;"}
@@ -1,332 +1,56 @@
1
- import { HCS10Client as HCS10Client$1, Logger, AgentBuilder, AIAgentCapability, InboundTopicType } from "@hashgraphonline/standards-sdk";
2
- import { encryptMessage } from "./standards-agent-kit.es36.js";
3
- class HCS10Client {
4
- constructor(operatorId, operatorPrivateKey, network, options) {
5
- this.standardClient = new HCS10Client$1({
6
- network,
7
- operatorId,
8
- operatorPrivateKey,
9
- guardedRegistryBaseUrl: options?.registryUrl,
10
- logLevel: options?.logLevel
11
- });
12
- this.guardedRegistryBaseUrl = options?.registryUrl || "";
13
- this.useEncryption = options?.useEncryption || false;
14
- const shouldSilence = process.env.DISABLE_LOGGING === "true";
15
- this.logger = new Logger({
16
- level: options?.logLevel || "info",
17
- silent: shouldSilence
18
- });
19
- }
20
- getOperatorId() {
21
- const operator = this.standardClient.getClient().operatorAccountId;
22
- if (!operator) {
23
- throw new Error("Operator Account ID not configured in standard client.");
24
- }
25
- return operator.toString();
26
- }
27
- getNetwork() {
28
- return this.standardClient.getNetwork();
29
- }
30
- async handleConnectionRequest(inboundTopicId, requestingAccountId, connectionRequestId, feeConfig) {
31
- try {
32
- const result = await this.standardClient.handleConnectionRequest(
33
- inboundTopicId,
34
- requestingAccountId,
35
- connectionRequestId,
36
- feeConfig
37
- );
38
- return result;
39
- } catch (error) {
40
- this.logger.error(
41
- `Error handling connection request #${connectionRequestId} for topic ${inboundTopicId}:`,
42
- error
43
- );
44
- throw new Error(
45
- `Failed to handle connection request: ${error instanceof Error ? error.message : String(error)}`
46
- );
47
- }
48
- }
49
- /**
50
- * Retrieves the profile for a given account ID using the standard SDK.
51
- */
52
- async getAgentProfile(accountId) {
53
- return this.standardClient.retrieveProfile(accountId);
54
- }
55
- /**
56
- * Exposes the standard SDK's submitConnectionRequest method.
57
- */
58
- async submitConnectionRequest(inboundTopicId, memo) {
59
- return this.standardClient.submitConnectionRequest(
60
- inboundTopicId,
61
- memo
62
- );
63
- }
64
- /**
65
- * Exposes the standard SDK's waitForConnectionConfirmation method.
66
- */
67
- async waitForConnectionConfirmation(outboundTopicId, connectionRequestId, maxAttempts = 60, delayMs = 2e3) {
68
- return this.standardClient.waitForConnectionConfirmation(
69
- outboundTopicId,
70
- connectionRequestId,
71
- maxAttempts,
72
- delayMs
73
- );
1
+ import { BaseServiceBuilder } from "hedera-agent-kit";
2
+ import { inscribe, inscribeWithSigner, retrieveInscription } from "@hashgraphonline/standards-sdk";
3
+ class InscriberBuilder extends BaseServiceBuilder {
4
+ constructor(hederaKit) {
5
+ super(hederaKit);
74
6
  }
75
7
  /**
76
- * Creates and registers an agent using the standard SDK's HCS10Client.
77
- * This handles account creation, key generation, topic setup, and registration.
78
- *
79
- * When metadata includes fee configuration:
80
- * 1. The properties.feeConfig will be passed to the AgentBuilder
81
- * 2. The properties.inboundTopicType will be set to FEE_BASED
82
- * 3. The SDK's createAndRegisterAgent will apply the fees to the agent's inbound topic
83
- *
84
- * @param metadata - The agent's metadata, potentially including pfpBuffer, pfpFileName,
85
- * and fee configuration in properties.feeConfig
86
- * @returns The registration result from the standard SDK, containing accountId, keys, topics etc.
8
+ * Get or create Inscription SDK - temporarily returns null since we don't have the actual SDK
87
9
  */
88
- async createAndRegisterAgent(metadata) {
89
- const builder = new AgentBuilder().setName(metadata.name).setBio(metadata.description || "").setCapabilities(
90
- metadata.capabilities ? metadata.capabilities : [AIAgentCapability.TEXT_GENERATION]
91
- ).setType(metadata.type || "autonomous").setModel(metadata.model || "agent-model-2024").setNetwork(this.getNetwork()).setInboundTopicType(InboundTopicType.PUBLIC);
92
- if (metadata?.feeConfig) {
93
- builder.setInboundTopicType(InboundTopicType.FEE_BASED);
94
- builder.setFeeConfig(metadata.feeConfig);
95
- }
96
- if (metadata.pfpBuffer && metadata.pfpFileName) {
97
- if (metadata.pfpBuffer.byteLength === 0) {
98
- this.logger.warn(
99
- "Provided PFP buffer is empty. Skipping profile picture."
100
- );
101
- } else {
102
- this.logger.info(
103
- `Setting profile picture: ${metadata.pfpFileName} (${metadata.pfpBuffer.byteLength} bytes)`
104
- );
105
- builder.setProfilePicture(metadata.pfpBuffer, metadata.pfpFileName);
106
- }
107
- } else {
108
- this.logger.warn(
109
- "Profile picture not provided in metadata. Agent creation might fail if required by the underlying SDK builder."
110
- );
111
- }
112
- if (metadata.social) {
113
- Object.entries(metadata.social).forEach(([platform, handle]) => {
114
- builder.addSocial(platform, handle);
115
- });
116
- }
117
- if (metadata.properties) {
118
- Object.entries(metadata.properties).forEach(([key, value]) => {
119
- builder.addProperty(key, value);
120
- });
121
- }
122
- try {
123
- const hasFees = Boolean(metadata?.feeConfig);
124
- const result = await this.standardClient.createAndRegisterAgent(builder, {
125
- initialBalance: hasFees ? 50 : void 0
126
- });
127
- if (result?.metadata?.inboundTopicId && result?.metadata?.outboundTopicId) {
128
- this.agentChannels = {
129
- inboundTopicId: result.metadata.inboundTopicId,
130
- outboundTopicId: result.metadata.outboundTopicId
131
- };
132
- }
133
- return result;
134
- } catch (error) {
135
- this.logger.error("Error during agent creation/registration:", error);
136
- throw new Error(
137
- `Failed to create/register agent: ${error instanceof Error ? error.message : String(error)}`
138
- );
139
- }
10
+ async getInscriptionSDK(options) {
11
+ return null;
140
12
  }
141
13
  /**
142
- * Sends a structured HCS-10 message to the specified topic using the standard SDK client.
143
- * Handles potential inscription for large messages.
144
- *
145
- * @param topicId - The target topic ID (likely a connection topic).
146
- * @param operatorId - The operator ID string (e.g., "inboundTopic@accountId").
147
- * @param data - The actual message content/data.
148
- * @param memo - Optional memo for the message.
149
- * @param submitKey - Optional private key for topics requiring specific submit keys.
150
- * @returns A confirmation status string from the transaction receipt.
14
+ * Inscribe content using server-side authentication
151
15
  */
152
- async sendMessage(topicId, data, memo, submitKey) {
153
- if (this.useEncryption) {
154
- data = encryptMessage(data);
155
- }
156
- try {
157
- const messageResponse = await this.standardClient.sendMessage(
158
- topicId,
159
- data,
160
- memo,
161
- submitKey
162
- );
163
- return messageResponse.topicSequenceNumber?.toNumber();
164
- } catch (error) {
165
- this.logger.error(`Error sending message to topic ${topicId}:`, error);
166
- throw new Error(
167
- `Failed to send message: ${error instanceof Error ? error.message : String(error)}`
168
- );
169
- }
170
- }
171
- /**
172
- * Retrieves messages from a topic using the standard SDK client.
173
- *
174
- * @param topicId - The topic ID to get messages from.
175
- * @returns Messages from the topic, mapped to the expected format.
176
- */
177
- async getMessages(topicId) {
178
- try {
179
- const result = await this.standardClient.getMessages(topicId);
180
- const mappedMessages = result.messages.map((sdkMessage) => {
181
- const timestamp = sdkMessage?.created?.getTime() || 0;
182
- return {
183
- ...sdkMessage,
184
- timestamp,
185
- data: sdkMessage.data,
186
- sequence_number: sdkMessage.sequence_number
187
- };
188
- });
189
- mappedMessages.sort(
190
- (a, b) => a.timestamp - b.timestamp
191
- );
192
- return { messages: mappedMessages };
193
- } catch (error) {
194
- this.logger.error(`Error getting messages from topic ${topicId}:`, error);
195
- return { messages: [] };
196
- }
197
- }
198
- async getMessageStream(topicId) {
199
- const result = this.standardClient.getMessageStream(topicId);
200
- return result;
201
- }
202
- /**
203
- * Retrieves content from an inscribed message using the standard SDK client.
204
- * @param inscriptionIdOrData - The inscription ID (hcs://...) or potentially raw data string.
205
- * @returns The resolved message content.
206
- */
207
- async getMessageContent(inscriptionIdOrData) {
208
- try {
209
- const content = await this.standardClient.getMessageContent(
210
- inscriptionIdOrData
211
- );
212
- return content;
213
- } catch (error) {
214
- this.logger.error(
215
- `Error retrieving message content for: ${inscriptionIdOrData}`,
216
- error
217
- );
218
- throw new Error(
219
- `Failed to retrieve message content: ${error instanceof Error ? error.message : String(error)}`
220
- );
221
- }
16
+ async inscribe(input, options) {
17
+ const operatorId = this.hederaKit.signer.getAccountId().toString();
18
+ const operatorPrivateKey = this.hederaKit.signer?.getOperatorPrivateKey() ? this.hederaKit.signer.getOperatorPrivateKey().toStringRaw() : "";
19
+ const network = this.hederaKit.client.network;
20
+ const networkType = network.toString().includes("mainnet") ? "mainnet" : "testnet";
21
+ const clientConfig = {
22
+ accountId: operatorId,
23
+ privateKey: operatorPrivateKey,
24
+ network: networkType
25
+ };
26
+ return await inscribe(input, clientConfig, options);
222
27
  }
223
28
  /**
224
- * Retrieves the inbound topic ID associated with the current operator.
225
- * This typically involves fetching the operator's own HCS-10 profile.
226
- * @returns A promise that resolves to the operator's inbound topic ID.
227
- * @throws {Error} If the operator ID cannot be determined or the profile/topic cannot be retrieved.
29
+ * Inscribe content using a DApp signer
228
30
  */
229
- async getInboundTopicId() {
230
- try {
231
- const operatorId = this.getOperatorId();
232
- this.logger.info(
233
- `[HCS10Client] Retrieving profile for operator ${operatorId} to find inbound topic...`
234
- );
235
- const profileResponse = await this.getAgentProfile(operatorId);
236
- if (profileResponse.success && profileResponse.topicInfo?.inboundTopic) {
237
- this.logger.info(
238
- `[HCS10Client] Found inbound topic for operator ${operatorId}: ${profileResponse.topicInfo.inboundTopic}`
239
- );
240
- return profileResponse.topicInfo.inboundTopic;
241
- } else {
242
- throw new Error(
243
- `Could not retrieve inbound topic from profile for ${operatorId}. Profile success: ${profileResponse.success}, Error: ${profileResponse.error}`
244
- );
245
- }
246
- } catch (error) {
247
- this.logger.error(
248
- `[HCS10Client] Error fetching operator's inbound topic ID (${this.getOperatorId()}):`,
249
- error
250
- );
251
- const operatorId = this.getOperatorId();
252
- let detailedMessage = `Failed to get inbound topic ID for operator ${operatorId}.`;
253
- if (error instanceof Error && error.message.includes("does not have a valid HCS-11 memo")) {
254
- detailedMessage += ` The account profile may not exist or is invalid. Please ensure this operator account (${operatorId}) is registered as an HCS-10 agent. You might need to register it first (e.g., using the 'register_agent' tool or SDK function).`;
255
- } else if (error instanceof Error) {
256
- detailedMessage += ` Reason: ${error.message}`;
257
- } else {
258
- detailedMessage += ` Unexpected error: ${String(error)}`;
259
- }
260
- throw new Error(detailedMessage);
261
- }
31
+ async inscribeWithSigner(input, signer, options) {
32
+ return await inscribeWithSigner(input, signer, options);
262
33
  }
263
34
  /**
264
- * Retrieves the configured operator account ID and private key.
265
- * Required by tools needing to identify the current agent instance.
35
+ * Retrieve an existing inscription
266
36
  */
267
- getAccountAndSigner() {
268
- const result = this.standardClient.getAccountAndSigner();
269
- return {
270
- accountId: result.accountId,
271
- signer: result.signer
272
- };
273
- }
274
- /**
275
- * Retrieves the outbound topic ID for the current operator.
276
- * Fetches the operator's profile if necessary.
277
- * @returns The outbound topic ID string.
278
- * @throws If the outbound topic cannot be determined.
279
- */
280
- async getOutboundTopicId() {
281
- const operatorId = this.getOperatorId();
282
- const profile = await this.getAgentProfile(operatorId);
283
- if (profile.success && profile.topicInfo?.outboundTopic) {
284
- return profile.topicInfo.outboundTopic;
285
- } else {
286
- throw new Error(
287
- `Could not retrieve outbound topic from profile for ${operatorId}. Profile success: ${profile.success}, Error: ${profile.error}`
288
- );
289
- }
290
- }
291
- setClient(accountId, privateKey) {
292
- this.standardClient = new HCS10Client$1({
293
- network: this.getNetwork(),
294
- operatorId: accountId,
295
- operatorPrivateKey: privateKey,
296
- guardedRegistryBaseUrl: this.guardedRegistryBaseUrl
37
+ async retrieveInscription(transactionId, options) {
38
+ const operatorId = this.hederaKit.signer.getAccountId().toString();
39
+ const operatorPrivateKey = this.hederaKit.signer?.getOperatorPrivateKey() ? this.hederaKit.signer.getOperatorPrivateKey().toStringRaw() : "";
40
+ return await retrieveInscription(transactionId, {
41
+ ...options,
42
+ accountId: operatorId,
43
+ privateKey: operatorPrivateKey
297
44
  });
298
- return this.standardClient;
299
45
  }
300
46
  /**
301
- * Validates that the operator account exists and has proper access for agent operations
47
+ * Close the inscription SDK
302
48
  */
303
- async validateOperator(options) {
304
- try {
305
- this.setClient(options.accountId, options.privateKey);
306
- const operatorId = this.getOperatorId();
307
- return {
308
- isValid: true,
309
- operator: { accountId: operatorId }
310
- };
311
- } catch (error) {
312
- this.logger.error(`Validation error: ${error}`);
313
- return {
314
- isValid: false,
315
- error: error instanceof Error ? error.message : String(error)
316
- };
317
- }
318
- }
319
- async initializeWithValidation(options) {
320
- const validationResult = await this.validateOperator(options);
321
- if (validationResult.isValid) {
322
- if (options.stateManager) {
323
- options.stateManager.initializeConnectionsManager(this.standardClient);
324
- }
325
- }
326
- return validationResult;
49
+ async close() {
50
+ this.inscriptionSDK = void 0;
327
51
  }
328
52
  }
329
53
  export {
330
- HCS10Client
54
+ InscriberBuilder
331
55
  };
332
56
  //# sourceMappingURL=standards-agent-kit.es5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standards-agent-kit.es5.js","sources":["../../src/hcs10/HCS10Client.ts"],"sourcesContent":["import { TransactionReceipt, PrivateKey } from '@hashgraph/sdk';\nimport {\n HCS10Client as StandardSDKClient,\n AgentBuilder,\n InboundTopicType as StandardInboundTopicType,\n AIAgentCapability as StandardAIAgentCapability,\n AgentRegistrationResult,\n WaitForConnectionConfirmationResponse,\n ProfileResponse as SDKProfileResponse,\n HCSMessage,\n LogLevel,\n Logger,\n FeeConfigBuilderInterface,\n SocialPlatform,\n} from '@hashgraphonline/standards-sdk';\nimport { AgentMetadata, AgentChannels } from './types';\nimport { encryptMessage } from '../utils/Encryption';\nimport { IStateManager } from '../state/state-types';\n\n// Keep type alias as they were removed accidentally\ntype StandardHandleConnectionRequest = InstanceType<\n typeof StandardSDKClient\n>['handleConnectionRequest'];\ntype HandleConnectionRequestResponse = Awaited<\n ReturnType<StandardHandleConnectionRequest>\n>;\nexport type StandardNetworkType = 'mainnet' | 'testnet';\n\nexport interface ClientValidationOptions {\n accountId: string;\n privateKey: string;\n network?: StandardNetworkType;\n stateManager?: IStateManager;\n}\n\nexport interface HCSMessageWithTimestamp extends HCSMessage {\n timestamp: number;\n data?: string;\n sequence_number: number;\n}\n\nexport interface ExtendedAgentMetadata extends AgentMetadata {\n pfpBuffer?: Buffer;\n pfpFileName?: string;\n feeConfig?: FeeConfigBuilderInterface;\n}\n\n/**\n * HCS10Client wraps the HCS-10 functionalities using the @hashgraphonline/standards-sdk.\n * - Creates and registers agents using the standard SDK flow.\n * - Manages agent communication channels (handled by standard SDK).\n * - Sends messages on Hedera topics (currently manual, potential for standard SDK integration).\n */\nexport class HCS10Client {\n public standardClient: StandardSDKClient;\n private useEncryption: boolean;\n public agentChannels?: AgentChannels;\n public guardedRegistryBaseUrl: string;\n public logger: Logger;\n\n constructor(\n operatorId: string,\n operatorPrivateKey: string,\n network: StandardNetworkType,\n options?: {\n useEncryption?: boolean;\n registryUrl?: string;\n logLevel?: LogLevel;\n }\n ) {\n this.standardClient = new StandardSDKClient({\n network: network,\n operatorId: operatorId,\n operatorPrivateKey: operatorPrivateKey,\n guardedRegistryBaseUrl: options?.registryUrl,\n logLevel: options?.logLevel,\n });\n this.guardedRegistryBaseUrl = options?.registryUrl || '';\n this.useEncryption = options?.useEncryption || false;\n const shouldSilence = process.env.DISABLE_LOGGING === 'true';\n this.logger = new Logger({\n level: options?.logLevel || 'info',\n silent: shouldSilence,\n });\n }\n\n public getOperatorId(): string {\n const operator = this.standardClient.getClient().operatorAccountId;\n if (!operator) {\n throw new Error('Operator Account ID not configured in standard client.');\n }\n return operator.toString();\n }\n\n public getNetwork(): StandardNetworkType {\n return this.standardClient.getNetwork() as StandardNetworkType;\n }\n\n public async handleConnectionRequest(\n inboundTopicId: string,\n requestingAccountId: string,\n connectionRequestId: number,\n feeConfig?: FeeConfigBuilderInterface\n ): Promise<HandleConnectionRequestResponse> {\n try {\n const result = await this.standardClient.handleConnectionRequest(\n inboundTopicId,\n requestingAccountId,\n connectionRequestId,\n feeConfig\n );\n return result;\n } catch (error) {\n this.logger.error(\n `Error handling connection request #${connectionRequestId} for topic ${inboundTopicId}:`,\n error\n );\n throw new Error(\n `Failed to handle connection request: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n }\n\n /**\n * Retrieves the profile for a given account ID using the standard SDK.\n */\n public async getAgentProfile(accountId: string): Promise<SDKProfileResponse> {\n return this.standardClient.retrieveProfile(accountId);\n }\n\n /**\n * Exposes the standard SDK's submitConnectionRequest method.\n */\n public async submitConnectionRequest(\n inboundTopicId: string,\n memo: string\n ): Promise<TransactionReceipt> {\n return this.standardClient.submitConnectionRequest(\n inboundTopicId,\n memo\n ) as Promise<TransactionReceipt>;\n }\n\n /**\n * Exposes the standard SDK's waitForConnectionConfirmation method.\n */\n public async waitForConnectionConfirmation(\n outboundTopicId: string,\n connectionRequestId: number,\n maxAttempts = 60,\n delayMs = 2000\n ): Promise<WaitForConnectionConfirmationResponse> {\n return this.standardClient.waitForConnectionConfirmation(\n outboundTopicId,\n connectionRequestId,\n maxAttempts,\n delayMs\n );\n }\n\n /**\n * Creates and registers an agent using the standard SDK's HCS10Client.\n * This handles account creation, key generation, topic setup, and registration.\n *\n * When metadata includes fee configuration:\n * 1. The properties.feeConfig will be passed to the AgentBuilder\n * 2. The properties.inboundTopicType will be set to FEE_BASED\n * 3. The SDK's createAndRegisterAgent will apply the fees to the agent's inbound topic\n *\n * @param metadata - The agent's metadata, potentially including pfpBuffer, pfpFileName,\n * and fee configuration in properties.feeConfig\n * @returns The registration result from the standard SDK, containing accountId, keys, topics etc.\n */\n public async createAndRegisterAgent(\n metadata: ExtendedAgentMetadata\n ): Promise<AgentRegistrationResult> {\n const builder = new AgentBuilder()\n .setName(metadata.name)\n .setBio(metadata.description || '')\n .setCapabilities(\n metadata.capabilities\n ? metadata.capabilities\n : [StandardAIAgentCapability.TEXT_GENERATION]\n )\n .setType((metadata.type || 'autonomous') as 'autonomous' | 'manual')\n .setModel(metadata.model || 'agent-model-2024')\n .setNetwork(this.getNetwork())\n .setInboundTopicType(StandardInboundTopicType.PUBLIC);\n\n if (metadata?.feeConfig) {\n builder.setInboundTopicType(StandardInboundTopicType.FEE_BASED);\n builder.setFeeConfig(metadata.feeConfig);\n }\n\n if (metadata.pfpBuffer && metadata.pfpFileName) {\n if (metadata.pfpBuffer.byteLength === 0) {\n this.logger.warn(\n 'Provided PFP buffer is empty. Skipping profile picture.'\n );\n } else {\n this.logger.info(\n `Setting profile picture: ${metadata.pfpFileName} (${metadata.pfpBuffer.byteLength} bytes)`\n );\n builder.setProfilePicture(metadata.pfpBuffer, metadata.pfpFileName);\n }\n } else {\n this.logger.warn(\n 'Profile picture not provided in metadata. Agent creation might fail if required by the underlying SDK builder.'\n );\n }\n\n if (metadata.social) {\n Object.entries(metadata.social).forEach(([platform, handle]) => {\n builder.addSocial(platform as SocialPlatform, handle);\n });\n }\n\n if (metadata.properties) {\n Object.entries(metadata.properties).forEach(([key, value]) => {\n builder.addProperty(key, value);\n });\n }\n\n try {\n const hasFees = Boolean(metadata?.feeConfig);\n const result = await this.standardClient.createAndRegisterAgent(builder, {\n initialBalance: hasFees ? 50 : undefined,\n });\n if (\n result?.metadata?.inboundTopicId &&\n result?.metadata?.outboundTopicId\n ) {\n this.agentChannels = {\n inboundTopicId: result.metadata.inboundTopicId,\n outboundTopicId: result.metadata.outboundTopicId,\n };\n }\n return result;\n } catch (error) {\n this.logger.error('Error during agent creation/registration:', error);\n throw new Error(\n `Failed to create/register agent: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n }\n\n /**\n * Sends a structured HCS-10 message to the specified topic using the standard SDK client.\n * Handles potential inscription for large messages.\n *\n * @param topicId - The target topic ID (likely a connection topic).\n * @param operatorId - The operator ID string (e.g., \"inboundTopic@accountId\").\n * @param data - The actual message content/data.\n * @param memo - Optional memo for the message.\n * @param submitKey - Optional private key for topics requiring specific submit keys.\n * @returns A confirmation status string from the transaction receipt.\n */\n public async sendMessage(\n topicId: string,\n data: string,\n memo?: string,\n submitKey?: PrivateKey\n ): Promise<number | undefined> {\n if (this.useEncryption) {\n data = encryptMessage(data);\n }\n\n try {\n const messageResponse = await this.standardClient.sendMessage(\n topicId,\n data,\n memo,\n submitKey\n );\n return messageResponse.topicSequenceNumber?.toNumber();\n } catch (error) {\n this.logger.error(`Error sending message to topic ${topicId}:`, error);\n throw new Error(\n `Failed to send message: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n }\n\n /**\n * Retrieves messages from a topic using the standard SDK client.\n *\n * @param topicId - The topic ID to get messages from.\n * @returns Messages from the topic, mapped to the expected format.\n */\n public async getMessages(topicId: string): Promise<{\n messages: HCSMessageWithTimestamp[];\n }> {\n try {\n const result = await this.standardClient.getMessages(topicId);\n\n const mappedMessages = result.messages.map((sdkMessage) => {\n const timestamp = sdkMessage?.created?.getTime() || 0;\n\n return {\n ...sdkMessage,\n timestamp: timestamp,\n data: sdkMessage.data,\n sequence_number: sdkMessage.sequence_number,\n };\n });\n mappedMessages.sort(\n (a: { timestamp: number }, b: { timestamp: number }) =>\n a.timestamp - b.timestamp\n );\n return { messages: mappedMessages as HCSMessageWithTimestamp[] };\n } catch (error) {\n this.logger.error(`Error getting messages from topic ${topicId}:`, error);\n return { messages: [] };\n }\n }\n\n public async getMessageStream(topicId: string): Promise<{\n messages: HCSMessage[];\n }> {\n const result = this.standardClient.getMessageStream(topicId);\n return result as Promise<{ messages: HCSMessage[] }>;\n }\n\n /**\n * Retrieves content from an inscribed message using the standard SDK client.\n * @param inscriptionIdOrData - The inscription ID (hcs://...) or potentially raw data string.\n * @returns The resolved message content.\n */\n public async getMessageContent(inscriptionIdOrData: string): Promise<string> {\n try {\n const content = await this.standardClient.getMessageContent(\n inscriptionIdOrData\n );\n return content as string;\n } catch (error) {\n this.logger.error(\n `Error retrieving message content for: ${inscriptionIdOrData}`,\n error\n );\n throw new Error(\n `Failed to retrieve message content: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n }\n\n /**\n * Retrieves the inbound topic ID associated with the current operator.\n * This typically involves fetching the operator's own HCS-10 profile.\n * @returns A promise that resolves to the operator's inbound topic ID.\n * @throws {Error} If the operator ID cannot be determined or the profile/topic cannot be retrieved.\n */\n public async getInboundTopicId(): Promise<string> {\n try {\n const operatorId = this.getOperatorId();\n this.logger.info(\n `[HCS10Client] Retrieving profile for operator ${operatorId} to find inbound topic...`\n );\n const profileResponse = await this.getAgentProfile(operatorId);\n if (profileResponse.success && profileResponse.topicInfo?.inboundTopic) {\n this.logger.info(\n `[HCS10Client] Found inbound topic for operator ${operatorId}: ${profileResponse.topicInfo.inboundTopic}`\n );\n return profileResponse.topicInfo.inboundTopic;\n } else {\n throw new Error(\n `Could not retrieve inbound topic from profile for ${operatorId}. Profile success: ${profileResponse.success}, Error: ${profileResponse.error}`\n );\n }\n } catch (error) {\n this.logger.error(\n `[HCS10Client] Error fetching operator's inbound topic ID (${this.getOperatorId()}):`,\n error\n );\n const operatorId = this.getOperatorId();\n let detailedMessage = `Failed to get inbound topic ID for operator ${operatorId}.`;\n if (\n error instanceof Error &&\n error.message.includes('does not have a valid HCS-11 memo')\n ) {\n detailedMessage += ` The account profile may not exist or is invalid. Please ensure this operator account (${operatorId}) is registered as an HCS-10 agent. You might need to register it first (e.g., using the 'register_agent' tool or SDK function).`;\n } else if (error instanceof Error) {\n detailedMessage += ` Reason: ${error.message}`;\n } else {\n detailedMessage += ` Unexpected error: ${String(error)}`;\n }\n throw new Error(detailedMessage);\n }\n }\n\n /**\n * Retrieves the configured operator account ID and private key.\n * Required by tools needing to identify the current agent instance.\n */\n public getAccountAndSigner(): { accountId: string; signer: PrivateKey } {\n const result = this.standardClient.getAccountAndSigner();\n return {\n accountId: result.accountId,\n signer: result.signer as unknown as PrivateKey,\n };\n }\n\n /**\n * Retrieves the outbound topic ID for the current operator.\n * Fetches the operator's profile if necessary.\n * @returns The outbound topic ID string.\n * @throws If the outbound topic cannot be determined.\n */\n public async getOutboundTopicId(): Promise<string> {\n const operatorId = this.getOperatorId();\n const profile = await this.getAgentProfile(operatorId);\n if (profile.success && profile.topicInfo?.outboundTopic) {\n return profile.topicInfo.outboundTopic;\n } else {\n throw new Error(\n `Could not retrieve outbound topic from profile for ${operatorId}. Profile success: ${profile.success}, Error: ${profile.error}`\n );\n }\n }\n\n public setClient(accountId: string, privateKey: string): StandardSDKClient {\n this.standardClient = new StandardSDKClient({\n network: this.getNetwork(),\n operatorId: accountId,\n operatorPrivateKey: privateKey,\n guardedRegistryBaseUrl: this.guardedRegistryBaseUrl,\n });\n return this.standardClient;\n }\n\n /**\n * Validates that the operator account exists and has proper access for agent operations\n */\n private async validateOperator(options: ClientValidationOptions): Promise<{\n isValid: boolean;\n operator?: { accountId: string };\n error?: string;\n }> {\n try {\n // Set up client with provided operator details\n this.setClient(options.accountId, options.privateKey);\n\n // Check if we can retrieve the operator ID\n const operatorId = this.getOperatorId();\n\n // If we got this far, basic validation passed\n return {\n isValid: true,\n operator: { accountId: operatorId },\n };\n } catch (error) {\n this.logger.error(`Validation error: ${error}`);\n return {\n isValid: false,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n }\n\n async initializeWithValidation(options: ClientValidationOptions): Promise<{\n isValid: boolean;\n operator?: { accountId: string };\n error?: string;\n }> {\n const validationResult = await this.validateOperator(options);\n\n if (validationResult.isValid) {\n // If we have access to the state manager, initialize its connections manager\n if (options.stateManager) {\n options.stateManager.initializeConnectionsManager(this.standardClient);\n }\n }\n\n return validationResult;\n }\n}\n"],"names":["StandardSDKClient","StandardAIAgentCapability","StandardInboundTopicType"],"mappings":";;AAqDO,MAAM,YAAY;AAAA,EAOvB,YACE,YACA,oBACA,SACA,SAKA;AACA,SAAK,iBAAiB,IAAIA,cAAkB;AAAA,MAC1C;AAAA,MACA;AAAA,MACA;AAAA,MACA,wBAAwB,SAAS;AAAA,MACjC,UAAU,SAAS;AAAA,IAAA,CACpB;AACD,SAAK,yBAAyB,SAAS,eAAe;AACtD,SAAK,gBAAgB,SAAS,iBAAiB;AAC/C,UAAM,gBAAgB,QAAQ,IAA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ACL,SAAS;AAAA,QACT,UAAU,EAAE,WAAW,WAAA;AAAA,MAAW;AAAA,IAEtC,SAAS,OAAO;AACd,WAAK,OAAO,MAAM,qBAAqB,KAAK,EAAE;AAC9C,aAAO;AAAA,QACL,SAAS;AAAA,QACT,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,MAAA;AAAA,IAEhE;AAAA,EACF;AAAA,EAEA,MAAM,yBAAyB,SAI5B;AACD,UAAM,mBAAmB,MAAM,KAAK,iBAAiB,OAAO;AAE5D,QAAI,iBAAiB,SAAS;AAE5B,UAAI,QAAQ,cAAc;AACxB,gBAAQ,aAAa,6BAA6B,KAAK,cAAc;AAAA,MACvE;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;"}
1
+ {"version":3,"file":"standards-agent-kit.es5.js","sources":["../../src/builders/inscriber/inscriber-builder.ts"],"sourcesContent":["import { BaseServiceBuilder } from 'hedera-agent-kit';\nimport type { HederaAgentKit } from 'hedera-agent-kit';\nimport {\n inscribe,\n inscribeWithSigner,\n retrieveInscription,\n InscriptionInput,\n InscriptionOptions,\n InscriptionResponse,\n RetrievedInscriptionResult,\n HederaClientConfig,\n NetworkType,\n} from '@hashgraphonline/standards-sdk';\n\n/**\n * Type definition for DAppSigner since we don't have the actual package\n */\ninterface DAppSigner {\n getAccountId(): { toString(): string };\n}\n\n/**\n * Type definition for InscriptionSDK since we don't have the actual package\n */\ninterface InscriptionSDK {\n inscribeAndExecute(request: any, config: any): Promise<any>;\n inscribe(request: any, signer: any): Promise<any>;\n waitForInscription(txId: string, maxAttempts: number, intervalMs: number, checkCompletion: boolean, progressCallback?: Function): Promise<any>;\n}\n\n/**\n * Builder for Inscription operations\n */\nexport class InscriberBuilder extends BaseServiceBuilder {\n protected inscriptionSDK?: InscriptionSDK;\n\n constructor(hederaKit: HederaAgentKit) {\n super(hederaKit);\n }\n\n /**\n * Get or create Inscription SDK - temporarily returns null since we don't have the actual SDK\n */\n protected async getInscriptionSDK(\n options: InscriptionOptions\n ): Promise<InscriptionSDK | null> {\n return null;\n }\n\n /**\n * Inscribe content using server-side authentication\n */\n async inscribe(\n input: InscriptionInput,\n options: InscriptionOptions\n ): Promise<InscriptionResponse> {\n const operatorId = this.hederaKit.signer.getAccountId().toString();\n const operatorPrivateKey = this.hederaKit.signer?.getOperatorPrivateKey()\n ? this.hederaKit.signer.getOperatorPrivateKey().toStringRaw()\n : '';\n\n const network = this.hederaKit.client.network;\n const networkType: NetworkType = network.toString().includes('mainnet')\n ? 'mainnet'\n : 'testnet';\n\n const clientConfig: HederaClientConfig = {\n accountId: operatorId,\n privateKey: operatorPrivateKey,\n network: networkType,\n };\n\n return await inscribe(input, clientConfig, options);\n }\n\n /**\n * Inscribe content using a DApp signer\n */\n async inscribeWithSigner(\n input: InscriptionInput,\n signer: DAppSigner,\n options: InscriptionOptions\n ): Promise<InscriptionResponse> {\n return await inscribeWithSigner(input, signer as any, options);\n }\n\n /**\n * Retrieve an existing inscription\n */\n async retrieveInscription(\n transactionId: string,\n options: InscriptionOptions\n ): Promise<RetrievedInscriptionResult> {\n const operatorId = this.hederaKit.signer.getAccountId().toString();\n const operatorPrivateKey = this.hederaKit.signer?.getOperatorPrivateKey()\n ? this.hederaKit.signer.getOperatorPrivateKey().toStringRaw()\n : '';\n\n return await retrieveInscription(transactionId, {\n ...options,\n accountId: operatorId,\n privateKey: operatorPrivateKey,\n });\n }\n\n /**\n * Close the inscription SDK\n */\n async close(): Promise<void> {\n this.inscriptionSDK = undefined;\n }\n}"],"names":[],"mappings":";;AAiCO,MAAM,yBAAyB,mBAAmB;AAAA,EAGvD,YAAY,WAA2B;AACrC,UAAM,SAAS;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAgB,kBACd,SACgC;AAChC,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,SACJ,OACA,SAC8B;AAC9B,UAAM,aAAa,KAAK,UAAU,OAAO,aAAA,EAAe,SAAA;AACxD,UAAM,qBAAqB,KAAK,UAAU,QAAQ,sBAAA,IAC9C,KAAK,UAAU,OAAO,wBAAwB,YAAA,IAC9C;AAEJ,UAAM,UAAU,KAAK,UAAU,OAAO;AACtC,UAAM,cAA2B,QAAQ,SAAA,EAAW,SAAS,SAAS,IAClE,YACA;AAEJ,UAAM,eAAmC;AAAA,MACvC,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,SAAS;AAAA,IAAA;AAGX,WAAO,MAAM,SAAS,OAAO,cAAc,OAAO;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,mBACJ,OACA,QACA,SAC8B;AAC9B,WAAO,MAAM,mBAAmB,OAAO,QAAe,OAAO;AAAA,EAC/D;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,oBACJ,eACA,SACqC;AACrC,UAAM,aAAa,KAAK,UAAU,OAAO,aAAA,EAAe,SAAA;AACxD,UAAM,qBAAqB,KAAK,UAAU,QAAQ,sBAAA,IAC9C,KAAK,UAAU,OAAO,wBAAwB,YAAA,IAC9C;AAEJ,WAAO,MAAM,oBAAoB,eAAe;AAAA,MAC9C,GAAG;AAAA,MACH,WAAW;AAAA,MACX,YAAY;AAAA,IAAA,CACb;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,QAAuB;AAC3B,SAAK,iBAAiB;AAAA,EACxB;AACF;"}