@hashgraphonline/standards-agent-kit 0.0.33 → 0.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/standards-agent-kit.cjs +1 -1
- package/dist/cjs/standards-agent-kit.cjs.map +1 -1
- package/dist/{umd/src → cjs}/tools/AcceptConnectionRequestTool.d.ts +6 -6
- package/dist/cjs/{src/tools → tools}/CheckMessagesTool.d.ts +6 -6
- package/dist/{es/src → cjs}/tools/ConnectionMonitorTool.d.ts +34 -34
- package/dist/{umd/src → cjs}/tools/FindRegistrationsTool.d.ts +4 -4
- package/dist/cjs/{src/tools → tools}/InitiateConnectionTool.d.ts +2 -2
- package/dist/{umd/src → cjs}/tools/ListConnectionsTool.d.ts +4 -4
- package/dist/{es/src → cjs}/tools/ListUnapprovedConnectionRequestsTool.d.ts +4 -4
- package/dist/{es/src → cjs}/tools/ManageConnectionRequestsTool.d.ts +4 -4
- package/dist/cjs/{src/tools → tools}/RegisterAgentTool.d.ts +76 -76
- package/dist/{es/src → cjs}/tools/RetrieveProfileTool.d.ts +4 -4
- package/dist/{es/src → cjs}/tools/SendMessageToConnectionTool.d.ts +6 -6
- package/dist/cjs/{src/tools → tools}/SendMessageTool.d.ts +6 -6
- package/dist/es/index.d.ts +5 -2
- package/dist/es/standards-agent-kit.es16.js +1 -1
- package/dist/es/standards-agent-kit.es17.js +1 -1
- package/dist/es/standards-agent-kit.es2.js +1 -1
- package/dist/es/standards-agent-kit.es2.js.map +1 -1
- package/dist/es/standards-agent-kit.es24.js +81 -3
- package/dist/es/standards-agent-kit.es24.js.map +1 -1
- package/dist/es/standards-agent-kit.es25.js +22 -79
- package/dist/es/standards-agent-kit.es25.js.map +1 -1
- package/dist/es/standards-agent-kit.es26.js +3 -24
- package/dist/es/standards-agent-kit.es26.js.map +1 -1
- package/dist/es/standards-agent-kit.es3.js +1 -1
- package/dist/es/standards-agent-kit.es7.js +12 -13
- package/dist/es/standards-agent-kit.es7.js.map +1 -1
- package/dist/es/{src/tools → tools}/AcceptConnectionRequestTool.d.ts +6 -6
- package/dist/{umd/src → es}/tools/CheckMessagesTool.d.ts +6 -6
- package/dist/{umd/src → es}/tools/ConnectionMonitorTool.d.ts +34 -34
- package/dist/{cjs/src → es}/tools/FindRegistrationsTool.d.ts +4 -4
- package/dist/{umd/src → es}/tools/InitiateConnectionTool.d.ts +2 -2
- package/dist/{cjs/src → es}/tools/ListConnectionsTool.d.ts +4 -4
- package/dist/{umd/src → es}/tools/ListUnapprovedConnectionRequestsTool.d.ts +4 -4
- package/dist/{umd/src → es}/tools/ManageConnectionRequestsTool.d.ts +4 -4
- package/dist/{umd/src → es}/tools/RegisterAgentTool.d.ts +76 -76
- package/dist/{cjs/src → es}/tools/RetrieveProfileTool.d.ts +4 -4
- package/dist/{umd/src → es}/tools/SendMessageToConnectionTool.d.ts +6 -6
- package/dist/{umd/src → es}/tools/SendMessageTool.d.ts +6 -6
- package/dist/umd/standards-agent-kit.umd.js +15 -14
- package/dist/umd/standards-agent-kit.umd.js.map +1 -1
- package/dist/{cjs/src → umd}/tools/AcceptConnectionRequestTool.d.ts +6 -6
- package/dist/{es/src → umd}/tools/CheckMessagesTool.d.ts +6 -6
- package/dist/{cjs/src → umd}/tools/ConnectionMonitorTool.d.ts +34 -34
- package/dist/{es/src → umd}/tools/FindRegistrationsTool.d.ts +4 -4
- package/dist/{es/src → umd}/tools/InitiateConnectionTool.d.ts +2 -2
- package/dist/{es/src → umd}/tools/ListConnectionsTool.d.ts +4 -4
- package/dist/{cjs/src → umd}/tools/ListUnapprovedConnectionRequestsTool.d.ts +4 -4
- package/dist/{cjs/src → umd}/tools/ManageConnectionRequestsTool.d.ts +4 -4
- package/dist/{es/src → umd}/tools/RegisterAgentTool.d.ts +76 -76
- package/dist/umd/{src/tools → tools}/RetrieveProfileTool.d.ts +4 -4
- package/dist/{cjs/src → umd}/tools/SendMessageToConnectionTool.d.ts +6 -6
- package/dist/{es/src → umd}/tools/SendMessageTool.d.ts +6 -6
- package/package.json +2 -2
- package/src/hcs10/HCS10Client.ts +3 -7
- package/src/index.ts +1 -1
- package/src/tools/InitiateConnectionTool.ts +13 -13
- package/dist/umd/src/index.d.ts +0 -5
- /package/dist/cjs/{src/agents → agents}/index.d.ts +0 -0
- /package/dist/cjs/{src/hcs10 → hcs10}/HCS10Client.d.ts +0 -0
- /package/dist/cjs/{src/hcs10 → hcs10}/index.d.ts +0 -0
- /package/dist/cjs/{src/hcs10 → hcs10}/types.d.ts +0 -0
- /package/dist/cjs/{src/index.d.ts → index.d.ts} +0 -0
- /package/dist/cjs/{src/init → init}/index.d.ts +0 -0
- /package/dist/cjs/{src/init → init}/init.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/BasePlugin.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/GenericPlugin.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/HCS10Plugin.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/PluginInterface.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/PluginLoader.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/PluginRegistry.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/defi/index.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/hedera/HbarPricePlugin.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/hedera/index.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/index.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/openconvai/OpenConvAIPlugin.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/openconvai/index.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/weather/index.d.ts +0 -0
- /package/dist/cjs/{src/state → state}/index.d.ts +0 -0
- /package/dist/cjs/{src/state → state}/open-convai-state.d.ts +0 -0
- /package/dist/cjs/{src/state → state}/state-types.d.ts +0 -0
- /package/dist/cjs/{src/tools → tools}/ConnectionTool.d.ts +0 -0
- /package/dist/cjs/{src/tools → tools}/index.d.ts +0 -0
- /package/dist/cjs/{src/utils → utils}/Encryption.d.ts +0 -0
- /package/dist/cjs/{src/utils → utils}/HederaClient.d.ts +0 -0
- /package/dist/cjs/{src/utils → utils}/connectionUtils.d.ts +0 -0
- /package/dist/cjs/{src/utils → utils}/ensure-agent-has-hbar.d.ts +0 -0
- /package/dist/cjs/{src/utils → utils}/state-tools.d.ts +0 -0
- /package/dist/es/{src/agents → agents}/index.d.ts +0 -0
- /package/dist/es/{src/hcs10 → hcs10}/HCS10Client.d.ts +0 -0
- /package/dist/es/{src/hcs10 → hcs10}/index.d.ts +0 -0
- /package/dist/es/{src/hcs10 → hcs10}/types.d.ts +0 -0
- /package/dist/es/{src/init → init}/index.d.ts +0 -0
- /package/dist/es/{src/init → init}/init.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/BasePlugin.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/GenericPlugin.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/HCS10Plugin.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/PluginInterface.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/PluginLoader.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/PluginRegistry.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/defi/index.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/hedera/HbarPricePlugin.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/hedera/index.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/index.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/openconvai/OpenConvAIPlugin.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/openconvai/index.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/weather/index.d.ts +0 -0
- /package/dist/es/{src/state → state}/index.d.ts +0 -0
- /package/dist/es/{src/state → state}/open-convai-state.d.ts +0 -0
- /package/dist/es/{src/state → state}/state-types.d.ts +0 -0
- /package/dist/es/{src/tools → tools}/ConnectionTool.d.ts +0 -0
- /package/dist/es/{src/tools → tools}/index.d.ts +0 -0
- /package/dist/es/{src/utils → utils}/Encryption.d.ts +0 -0
- /package/dist/es/{src/utils → utils}/HederaClient.d.ts +0 -0
- /package/dist/es/{src/utils → utils}/connectionUtils.d.ts +0 -0
- /package/dist/es/{src/utils → utils}/ensure-agent-has-hbar.d.ts +0 -0
- /package/dist/es/{src/utils → utils}/state-tools.d.ts +0 -0
- /package/dist/umd/{src/agents → agents}/index.d.ts +0 -0
- /package/dist/umd/{src/hcs10 → hcs10}/HCS10Client.d.ts +0 -0
- /package/dist/umd/{src/hcs10 → hcs10}/index.d.ts +0 -0
- /package/dist/umd/{src/hcs10 → hcs10}/types.d.ts +0 -0
- /package/dist/{es/src → umd}/index.d.ts +0 -0
- /package/dist/umd/{src/init → init}/index.d.ts +0 -0
- /package/dist/umd/{src/init → init}/init.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/BasePlugin.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/GenericPlugin.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/HCS10Plugin.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/PluginInterface.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/PluginLoader.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/PluginRegistry.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/defi/index.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/hedera/HbarPricePlugin.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/hedera/index.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/index.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/openconvai/OpenConvAIPlugin.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/openconvai/index.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/weather/index.d.ts +0 -0
- /package/dist/umd/{src/state → state}/index.d.ts +0 -0
- /package/dist/umd/{src/state → state}/open-convai-state.d.ts +0 -0
- /package/dist/umd/{src/state → state}/state-types.d.ts +0 -0
- /package/dist/umd/{src/tools → tools}/ConnectionTool.d.ts +0 -0
- /package/dist/umd/{src/tools → tools}/index.d.ts +0 -0
- /package/dist/umd/{src/utils → utils}/Encryption.d.ts +0 -0
- /package/dist/umd/{src/utils → utils}/HederaClient.d.ts +0 -0
- /package/dist/umd/{src/utils → utils}/connectionUtils.d.ts +0 -0
- /package/dist/umd/{src/utils → utils}/ensure-agent-has-hbar.d.ts +0 -0
- /package/dist/umd/{src/utils → utils}/state-tools.d.ts +0 -0
|
@@ -1,7 +1,85 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { TransferTransaction, Hbar } from "@hashgraph/sdk";
|
|
2
|
+
import { HederaMirrorNode } from "@hashgraphonline/standards-sdk";
|
|
3
|
+
const MIN_REQUIRED_USD = 2;
|
|
4
|
+
const MIN_REQUIRED_HBAR_USD = 10;
|
|
5
|
+
async function ensureAgentHasEnoughHbar(logger, baseClient, accountId, agentName) {
|
|
6
|
+
try {
|
|
7
|
+
const account = await baseClient.requestAccount(accountId);
|
|
8
|
+
const balance = account.balance.balance;
|
|
9
|
+
const hbarBalance = balance / 1e8;
|
|
10
|
+
logger.info(`${agentName} account ${accountId} has ${hbarBalance} HBAR`);
|
|
11
|
+
try {
|
|
12
|
+
const mirrorNode = new HederaMirrorNode("testnet", logger);
|
|
13
|
+
const hbarPrice = await mirrorNode.getHBARPrice(/* @__PURE__ */ new Date());
|
|
14
|
+
if (hbarPrice) {
|
|
15
|
+
const balanceInUsd = hbarBalance * hbarPrice;
|
|
16
|
+
logger.info(`${agentName} balance in USD: $${balanceInUsd.toFixed(2)}`);
|
|
17
|
+
if (balanceInUsd < MIN_REQUIRED_USD) {
|
|
18
|
+
logger.warn(
|
|
19
|
+
`${agentName} account ${accountId} has less than $${MIN_REQUIRED_USD} (${balanceInUsd.toFixed(
|
|
20
|
+
2
|
|
21
|
+
)}). Attempting to fund.`
|
|
22
|
+
);
|
|
23
|
+
try {
|
|
24
|
+
const funder = baseClient.getAccountAndSigner();
|
|
25
|
+
const targetHbar = MIN_REQUIRED_HBAR_USD / hbarPrice;
|
|
26
|
+
const amountToTransferHbar = Math.max(0, targetHbar - hbarBalance);
|
|
27
|
+
if (amountToTransferHbar > 0) {
|
|
28
|
+
const transferTx = new TransferTransaction().addHbarTransfer(
|
|
29
|
+
funder.accountId,
|
|
30
|
+
Hbar.fromTinybars(
|
|
31
|
+
Math.round(amountToTransferHbar * -1e8)
|
|
32
|
+
)
|
|
33
|
+
).addHbarTransfer(
|
|
34
|
+
accountId,
|
|
35
|
+
Hbar.fromTinybars(
|
|
36
|
+
Math.round(amountToTransferHbar * 1e8)
|
|
37
|
+
)
|
|
38
|
+
);
|
|
39
|
+
logger.info(
|
|
40
|
+
`Funding ${agentName} account ${accountId} with ${amountToTransferHbar.toFixed(
|
|
41
|
+
2
|
|
42
|
+
)} HBAR from ${funder.accountId}`
|
|
43
|
+
);
|
|
44
|
+
const fundTxResponse = await transferTx.execute(
|
|
45
|
+
baseClient.getClient()
|
|
46
|
+
);
|
|
47
|
+
await fundTxResponse.getReceipt(baseClient.getClient());
|
|
48
|
+
logger.info(
|
|
49
|
+
`Successfully funded ${agentName} account ${accountId}.`
|
|
50
|
+
);
|
|
51
|
+
} else {
|
|
52
|
+
logger.info(
|
|
53
|
+
`${agentName} account ${accountId} does not require additional funding.`
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
} catch (fundingError) {
|
|
57
|
+
logger.error(
|
|
58
|
+
`Failed to automatically fund ${agentName} account ${accountId}:`,
|
|
59
|
+
fundingError
|
|
60
|
+
);
|
|
61
|
+
logger.warn(
|
|
62
|
+
`Please fund the account ${accountId} manually with at least ${(MIN_REQUIRED_HBAR_USD / hbarPrice).toFixed(2)} HBAR.`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
logger.warn(
|
|
68
|
+
"Failed to get HBAR price from Mirror Node. Please ensure the account has enough HBAR."
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
} catch (error) {
|
|
72
|
+
logger.warn(
|
|
73
|
+
"Failed to check USD balance. Please ensure the account has enough HBAR."
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
} catch (error) {
|
|
77
|
+
logger.error(`Failed to check ${agentName} account balance:`, error);
|
|
78
|
+
}
|
|
3
79
|
}
|
|
4
80
|
export {
|
|
5
|
-
|
|
81
|
+
MIN_REQUIRED_HBAR_USD,
|
|
82
|
+
MIN_REQUIRED_USD,
|
|
83
|
+
ensureAgentHasEnoughHbar
|
|
6
84
|
};
|
|
7
85
|
//# sourceMappingURL=standards-agent-kit.es24.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es24.js","sources":["../../src/utils/
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es24.js","sources":["../../src/utils/ensure-agent-has-hbar.ts"],"sourcesContent":["import { Hbar } from \"@hashgraph/sdk\";\nimport { TransferTransaction } from \"@hashgraph/sdk\";\nimport { Logger, HCS10Client, HederaMirrorNode } from \"@hashgraphonline/standards-sdk\";\n\nexport const MIN_REQUIRED_USD = 2.0;\nexport const MIN_REQUIRED_HBAR_USD = 10.0;\n\nexport async function ensureAgentHasEnoughHbar(\n logger: Logger,\n baseClient: HCS10Client,\n accountId: string,\n agentName: string\n): Promise<void> {\n try {\n const account = await baseClient.requestAccount(accountId);\n const balance = account.balance.balance;\n const hbarBalance = balance / 100_000_000;\n\n logger.info(`${agentName} account ${accountId} has ${hbarBalance} HBAR`);\n\n try {\n const mirrorNode = new HederaMirrorNode('testnet', logger);\n const hbarPrice = await mirrorNode.getHBARPrice(new Date());\n\n if (hbarPrice) {\n const balanceInUsd = hbarBalance * hbarPrice;\n logger.info(`${agentName} balance in USD: $${balanceInUsd.toFixed(2)}`);\n\n if (balanceInUsd < MIN_REQUIRED_USD) {\n logger.warn(\n `${agentName} account ${accountId} has less than $${MIN_REQUIRED_USD} (${balanceInUsd.toFixed(\n 2\n )}). Attempting to fund.`\n );\n\n try {\n const funder = baseClient.getAccountAndSigner();\n const targetHbar = MIN_REQUIRED_HBAR_USD / hbarPrice;\n const amountToTransferHbar = Math.max(0, targetHbar - hbarBalance);\n\n if (amountToTransferHbar > 0) {\n const transferTx = new TransferTransaction()\n .addHbarTransfer(\n funder.accountId,\n Hbar.fromTinybars(\n Math.round(amountToTransferHbar * -100_000_000)\n )\n )\n .addHbarTransfer(\n accountId,\n Hbar.fromTinybars(\n Math.round(amountToTransferHbar * 100_000_000)\n )\n );\n\n logger.info(\n `Funding ${agentName} account ${accountId} with ${amountToTransferHbar.toFixed(\n 2\n )} HBAR from ${funder.accountId}`\n );\n\n const fundTxResponse = await transferTx.execute(\n baseClient.getClient() as any\n );\n await fundTxResponse.getReceipt(baseClient.getClient() as any);\n logger.info(\n `Successfully funded ${agentName} account ${accountId}.`\n );\n } else {\n logger.info(\n `${agentName} account ${accountId} does not require additional funding.`\n );\n }\n } catch (fundingError) {\n logger.error(\n `Failed to automatically fund ${agentName} account ${accountId}:`,\n fundingError\n );\n logger.warn(\n `Please fund the account ${accountId} manually with at least ${(\n MIN_REQUIRED_HBAR_USD / hbarPrice\n ).toFixed(2)} HBAR.`\n );\n }\n }\n } else {\n logger.warn(\n 'Failed to get HBAR price from Mirror Node. Please ensure the account has enough HBAR.'\n );\n }\n } catch (error) {\n logger.warn(\n 'Failed to check USD balance. Please ensure the account has enough HBAR.'\n );\n }\n } catch (error) {\n logger.error(`Failed to check ${agentName} account balance:`, error);\n }\n}"],"names":[],"mappings":";;AAIO,MAAM,mBAAmB;AACzB,MAAM,wBAAwB;AAErC,eAAsB,yBACpB,QACA,YACA,WACA,WACe;AACX,MAAA;AACF,UAAM,UAAU,MAAM,WAAW,eAAe,SAAS;AACnD,UAAA,UAAU,QAAQ,QAAQ;AAChC,UAAM,cAAc,UAAU;AAE9B,WAAO,KAAK,GAAG,SAAS,YAAY,SAAS,QAAQ,WAAW,OAAO;AAEnE,QAAA;AACF,YAAM,aAAa,IAAI,iBAAiB,WAAW,MAAM;AACzD,YAAM,YAAY,MAAM,WAAW,aAAa,oBAAI,MAAM;AAE1D,UAAI,WAAW;AACb,cAAM,eAAe,cAAc;AAC5B,eAAA,KAAK,GAAG,SAAS,qBAAqB,aAAa,QAAQ,CAAC,CAAC,EAAE;AAEtE,YAAI,eAAe,kBAAkB;AAC5B,iBAAA;AAAA,YACL,GAAG,SAAS,YAAY,SAAS,mBAAmB,gBAAgB,KAAK,aAAa;AAAA,cACpF;AAAA,YAAA,CACD;AAAA,UACH;AAEI,cAAA;AACI,kBAAA,SAAS,WAAW,oBAAoB;AAC9C,kBAAM,aAAa,wBAAwB;AAC3C,kBAAM,uBAAuB,KAAK,IAAI,GAAG,aAAa,WAAW;AAEjE,gBAAI,uBAAuB,GAAG;AACtB,oBAAA,aAAa,IAAI,oBAAA,EACpB;AAAA,gBACC,OAAO;AAAA,gBACP,KAAK;AAAA,kBACH,KAAK,MAAM,uBAAuB,IAAY;AAAA,gBAAA;AAAA,cAChD,EAED;AAAA,gBACC;AAAA,gBACA,KAAK;AAAA,kBACH,KAAK,MAAM,uBAAuB,GAAW;AAAA,gBAAA;AAAA,cAEjD;AAEK,qBAAA;AAAA,gBACL,WAAW,SAAS,YAAY,SAAS,SAAS,qBAAqB;AAAA,kBACrE;AAAA,gBAAA,CACD,cAAc,OAAO,SAAS;AAAA,cACjC;AAEM,oBAAA,iBAAiB,MAAM,WAAW;AAAA,gBACtC,WAAW,UAAU;AAAA,cACvB;AACA,oBAAM,eAAe,WAAW,WAAW,UAAA,CAAkB;AACtD,qBAAA;AAAA,gBACL,uBAAuB,SAAS,YAAY,SAAS;AAAA,cACvD;AAAA,YAAA,OACK;AACE,qBAAA;AAAA,gBACL,GAAG,SAAS,YAAY,SAAS;AAAA,cACnC;AAAA,YAAA;AAAA,mBAEK,cAAc;AACd,mBAAA;AAAA,cACL,gCAAgC,SAAS,YAAY,SAAS;AAAA,cAC9D;AAAA,YACF;AACO,mBAAA;AAAA,cACL,2BAA2B,SAAS,4BAClC,wBAAwB,WACxB,QAAQ,CAAC,CAAC;AAAA,YACd;AAAA,UAAA;AAAA,QACF;AAAA,MACF,OACK;AACE,eAAA;AAAA,UACL;AAAA,QACF;AAAA,MAAA;AAAA,aAEK,OAAO;AACP,aAAA;AAAA,QACL;AAAA,MACF;AAAA,IAAA;AAAA,WAEK,OAAO;AACd,WAAO,MAAM,mBAAmB,SAAS,qBAAqB,KAAK;AAAA,EAAA;AAEvE;"}
|
|
@@ -1,85 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
async function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
2
|
|
21
|
-
)}). Attempting to fund.`
|
|
22
|
-
);
|
|
23
|
-
try {
|
|
24
|
-
const funder = baseClient.getAccountAndSigner();
|
|
25
|
-
const targetHbar = MIN_REQUIRED_HBAR_USD / hbarPrice;
|
|
26
|
-
const amountToTransferHbar = Math.max(0, targetHbar - hbarBalance);
|
|
27
|
-
if (amountToTransferHbar > 0) {
|
|
28
|
-
const transferTx = new TransferTransaction().addHbarTransfer(
|
|
29
|
-
funder.accountId,
|
|
30
|
-
Hbar.fromTinybars(
|
|
31
|
-
Math.round(amountToTransferHbar * -1e8)
|
|
32
|
-
)
|
|
33
|
-
).addHbarTransfer(
|
|
34
|
-
accountId,
|
|
35
|
-
Hbar.fromTinybars(
|
|
36
|
-
Math.round(amountToTransferHbar * 1e8)
|
|
37
|
-
)
|
|
38
|
-
);
|
|
39
|
-
logger.info(
|
|
40
|
-
`Funding ${agentName} account ${accountId} with ${amountToTransferHbar.toFixed(
|
|
41
|
-
2
|
|
42
|
-
)} HBAR from ${funder.accountId}`
|
|
43
|
-
);
|
|
44
|
-
const fundTxResponse = await transferTx.execute(
|
|
45
|
-
baseClient.getClient()
|
|
46
|
-
);
|
|
47
|
-
await fundTxResponse.getReceipt(baseClient.getClient());
|
|
48
|
-
logger.info(
|
|
49
|
-
`Successfully funded ${agentName} account ${accountId}.`
|
|
50
|
-
);
|
|
51
|
-
} else {
|
|
52
|
-
logger.info(
|
|
53
|
-
`${agentName} account ${accountId} does not require additional funding.`
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
} catch (fundingError) {
|
|
57
|
-
logger.error(
|
|
58
|
-
`Failed to automatically fund ${agentName} account ${accountId}:`,
|
|
59
|
-
fundingError
|
|
60
|
-
);
|
|
61
|
-
logger.warn(
|
|
62
|
-
`Please fund the account ${accountId} manually with at least ${(MIN_REQUIRED_HBAR_USD / hbarPrice).toFixed(2)} HBAR.`
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
} else {
|
|
67
|
-
logger.warn(
|
|
68
|
-
"Failed to get HBAR price from Mirror Node. Please ensure the account has enough HBAR."
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
} catch (error) {
|
|
72
|
-
logger.warn(
|
|
73
|
-
"Failed to check USD balance. Please ensure the account has enough HBAR."
|
|
74
|
-
);
|
|
1
|
+
import "@hashgraphonline/standards-sdk";
|
|
2
|
+
import fs__default 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__default.existsSync(envFilePath)) {
|
|
8
|
+
envContent = fs__default.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}`);
|
|
75
20
|
}
|
|
76
|
-
} catch (error) {
|
|
77
|
-
logger.error(`Failed to check ${agentName} account balance:`, error);
|
|
78
21
|
}
|
|
22
|
+
fs__default.writeFileSync(envFilePath, updatedLines.join("\n"));
|
|
79
23
|
}
|
|
80
24
|
export {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
ensureAgentHasEnoughHbar
|
|
25
|
+
ENV_FILE_PATH,
|
|
26
|
+
updateEnvFile
|
|
84
27
|
};
|
|
85
28
|
//# sourceMappingURL=standards-agent-kit.es25.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es25.js","sources":["../../src/utils/
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es25.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","fs"],"mappings":";;;AASO,MAAM,gBAAgBA,cAAK,KAAK,QAAQ,OAAO,MAAM;AA4HtC,eAAA,cACpB,aACA,WACe;AACf,MAAI,aAAa;AAEb,MAAAC,YAAG,WAAW,WAAW,GAAG;AACjB,iBAAAA,YAAG,aAAa,aAAa,MAAM;AAAA,EAAA;AAG5C,QAAA,WAAW,WAAW,MAAM,IAAI;AAChC,QAAA,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,IAC3B;AAEA,QAAI,cAAc,IAAI;AACpB,mBAAa,SAAS,IAAI,GAAG,GAAG,IAAI,KAAK;AAAA,IAAA,OACpC;AACL,mBAAa,KAAK,GAAG,GAAG,IAAI,KAAK,EAAE;AAAA,IAAA;AAAA,EACrC;AAGFA,cAAG,cAAc,aAAa,aAAa,KAAK,IAAI,CAAC;AACvD;"}
|
|
@@ -1,28 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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__default.existsSync(envFilePath)) {
|
|
8
|
-
envContent = fs__default.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__default.writeFileSync(envFilePath, updatedLines.join("\n"));
|
|
1
|
+
function encryptMessage(message) {
|
|
2
|
+
return message;
|
|
23
3
|
}
|
|
24
4
|
export {
|
|
25
|
-
|
|
26
|
-
updateEnvFile
|
|
5
|
+
encryptMessage
|
|
27
6
|
};
|
|
28
7
|
//# sourceMappingURL=standards-agent-kit.es26.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es26.js","sources":["../../src/utils/
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es26.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;AAE7C,SAAA;AACX;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Logger, AIAgentCapability, FeeConfigBuilder } from "@hashgraphonline/standards-sdk";
|
|
2
|
-
import { ensureAgentHasEnoughHbar } from "./standards-agent-kit.
|
|
2
|
+
import { ensureAgentHasEnoughHbar } from "./standards-agent-kit.es24.js";
|
|
3
3
|
import { StructuredTool } from "@langchain/core/tools";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import fs__default from "fs";
|
|
@@ -43,22 +43,21 @@ class InitiateConnectionTool extends StructuredTool {
|
|
|
43
43
|
targetInboundTopicId,
|
|
44
44
|
currentAgent.name
|
|
45
45
|
);
|
|
46
|
-
let connectionRequestId = null;
|
|
47
46
|
const sequenceNumberLong = requestResult?.topicSequenceNumber;
|
|
48
|
-
if (sequenceNumberLong
|
|
49
|
-
try {
|
|
50
|
-
connectionRequestId = sequenceNumberLong.toNumber();
|
|
51
|
-
if (isNaN(connectionRequestId)) {
|
|
52
|
-
throw new Error("Converted sequence number is NaN.");
|
|
53
|
-
}
|
|
54
|
-
} catch (conversionError) {
|
|
55
|
-
throw new Error(
|
|
56
|
-
`Failed to convert connection request sequence number: ${conversionError}`
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
} else {
|
|
47
|
+
if (!sequenceNumberLong) {
|
|
60
48
|
throw new Error("Connection request sequence number not found.");
|
|
61
49
|
}
|
|
50
|
+
let connectionRequestId;
|
|
51
|
+
try {
|
|
52
|
+
connectionRequestId = sequenceNumberLong.toNumber();
|
|
53
|
+
if (isNaN(connectionRequestId)) {
|
|
54
|
+
throw new Error("Converted sequence number is NaN.");
|
|
55
|
+
}
|
|
56
|
+
} catch (conversionError) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
`Failed to convert connection request sequence number: ${conversionError}`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
62
61
|
const confirmationTimeoutMs = 6e4;
|
|
63
62
|
const delayMs = 2e3;
|
|
64
63
|
const maxAttempts = Math.ceil(confirmationTimeoutMs / delayMs);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es7.js","sources":["../../src/tools/InitiateConnectionTool.ts"],"sourcesContent":["import { StructuredTool, ToolParams } from '@langchain/core/tools';\nimport { z } from 'zod';\nimport { HCS10Client } from '../hcs10/HCS10Client';\nimport { IStateManager, ActiveConnection } from '../state/state-types';\nimport { Logger } from '@hashgraphonline/standards-sdk';\n\nexport interface InitiateConnectionToolParams extends ToolParams {\n hcsClient: HCS10Client;\n stateManager: IStateManager;\n}\n\n/**\n * A tool to actively START a NEW HCS-10 connection TO a target agent.\n * Requires the target agent's account ID.\n * It retrieves their profile, sends a connection request, waits for confirmation, and stores the connection using the provided stateManager.\n * Use this tool ONLY to actively INITIATE an OUTGOING connection.\n */\nexport class InitiateConnectionTool extends StructuredTool {\n name = 'initiate_connection';\n description =\n 'Actively STARTS a NEW HCS-10 connection TO a specific target agent identified by their account ID. Requires the targetAccountId parameter. Use this ONLY to INITIATE an OUTGOING connection request.';\n schema = z.object({\n targetAccountId: z\n .string()\n .describe(\n 'The Hedera account ID (e.g., 0.0.12345) of the agent you want to connect with.'\n )\n });\n\n private hcsClient: HCS10Client;\n private stateManager: IStateManager;\n private logger: Logger;\n\n constructor({\n hcsClient,\n stateManager,\n ...rest\n }: InitiateConnectionToolParams) {\n super(rest);\n this.hcsClient = hcsClient;\n this.stateManager = stateManager;\n this.logger = Logger.getInstance({ module: 'InitiateConnectionTool' });\n }\n\n protected async _call({\n targetAccountId\n }: z.infer<this['schema']>): Promise<string> {\n const currentAgent = this.stateManager.getCurrentAgent();\n if (!currentAgent) {\n return 'Error: Cannot initiate connection. No agent is currently active. Please register or select an agent first.';\n }\n\n this.logger.info(\n `Attempting connection from ${currentAgent.accountId} to ${targetAccountId}`\n );\n\n try {\n this.logger.debug(`Retrieving profile for ${targetAccountId}...`);\n const targetProfile = await this.hcsClient.getAgentProfile(\n targetAccountId\n );\n if (!targetProfile?.topicInfo?.inboundTopic) {\n return `Error: Could not retrieve profile or find inbound topic ID for target agent ${targetAccountId}. They might not be registered or have a public profile.`;\n }\n const targetInboundTopicId = targetProfile.topicInfo.inboundTopic;\n const targetAgentName =\n targetProfile.profile.name || `Agent ${targetAccountId}`;\n\n const requestResult = await this.hcsClient.submitConnectionRequest(\n targetInboundTopicId,\n currentAgent.name\n );\n
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es7.js","sources":["../../src/tools/InitiateConnectionTool.ts"],"sourcesContent":["import { StructuredTool, ToolParams } from '@langchain/core/tools';\nimport { z } from 'zod';\nimport { HCS10Client } from '../hcs10/HCS10Client';\nimport { IStateManager, ActiveConnection } from '../state/state-types';\nimport { Logger } from '@hashgraphonline/standards-sdk';\n\nexport interface InitiateConnectionToolParams extends ToolParams {\n hcsClient: HCS10Client;\n stateManager: IStateManager;\n}\n\n/**\n * A tool to actively START a NEW HCS-10 connection TO a target agent.\n * Requires the target agent's account ID.\n * It retrieves their profile, sends a connection request, waits for confirmation, and stores the connection using the provided stateManager.\n * Use this tool ONLY to actively INITIATE an OUTGOING connection.\n */\nexport class InitiateConnectionTool extends StructuredTool {\n name = 'initiate_connection';\n description =\n 'Actively STARTS a NEW HCS-10 connection TO a specific target agent identified by their account ID. Requires the targetAccountId parameter. Use this ONLY to INITIATE an OUTGOING connection request.';\n schema = z.object({\n targetAccountId: z\n .string()\n .describe(\n 'The Hedera account ID (e.g., 0.0.12345) of the agent you want to connect with.'\n )\n });\n\n private hcsClient: HCS10Client;\n private stateManager: IStateManager;\n private logger: Logger;\n\n constructor({\n hcsClient,\n stateManager,\n ...rest\n }: InitiateConnectionToolParams) {\n super(rest);\n this.hcsClient = hcsClient;\n this.stateManager = stateManager;\n this.logger = Logger.getInstance({ module: 'InitiateConnectionTool' });\n }\n\n protected async _call({\n targetAccountId\n }: z.infer<this['schema']>): Promise<string> {\n const currentAgent = this.stateManager.getCurrentAgent();\n if (!currentAgent) {\n return 'Error: Cannot initiate connection. No agent is currently active. Please register or select an agent first.';\n }\n\n this.logger.info(\n `Attempting connection from ${currentAgent.accountId} to ${targetAccountId}`\n );\n\n try {\n this.logger.debug(`Retrieving profile for ${targetAccountId}...`);\n const targetProfile = await this.hcsClient.getAgentProfile(\n targetAccountId\n );\n if (!targetProfile?.topicInfo?.inboundTopic) {\n return `Error: Could not retrieve profile or find inbound topic ID for target agent ${targetAccountId}. They might not be registered or have a public profile.`;\n }\n const targetInboundTopicId = targetProfile.topicInfo.inboundTopic;\n const targetAgentName =\n targetProfile.profile.name || `Agent ${targetAccountId}`;\n\n const requestResult = await this.hcsClient.submitConnectionRequest(\n targetInboundTopicId,\n currentAgent.name\n );\n const sequenceNumberLong = requestResult?.topicSequenceNumber;\n if (!sequenceNumberLong) {\n throw new Error('Connection request sequence number not found.');\n }\n \n let connectionRequestId: number;\n try {\n connectionRequestId = sequenceNumberLong.toNumber();\n if (isNaN(connectionRequestId)) {\n throw new Error('Converted sequence number is NaN.');\n }\n } catch (conversionError) {\n throw new Error(\n `Failed to convert connection request sequence number: ${conversionError}`\n );\n }\n\n const confirmationTimeoutMs = 60000;\n const delayMs = 2000;\n const maxAttempts = Math.ceil(confirmationTimeoutMs / delayMs);\n\n const confirmationResult =\n await this.hcsClient.waitForConnectionConfirmation(\n targetInboundTopicId,\n connectionRequestId,\n maxAttempts,\n delayMs\n );\n\n if (!confirmationResult?.connectionTopicId) {\n return `Error: Connection confirmation not received from ${targetAccountId} (for request ${connectionRequestId}) within ${\n confirmationTimeoutMs / 1000\n } seconds.`;\n }\n\n const connectionTopicId = confirmationResult.connectionTopicId;\n this.logger.info(`Connection confirmed! Topic ID: ${connectionTopicId}`);\n\n const newConnection: ActiveConnection = {\n targetAccountId: targetAccountId,\n targetAgentName: targetAgentName,\n targetInboundTopicId: targetInboundTopicId,\n connectionTopicId: connectionTopicId,\n };\n this.stateManager.addActiveConnection(newConnection);\n\n const connections = this.stateManager.listConnections();\n const addedEntry = connections.find(\n (c) => c.connectionTopicId === connectionTopicId\n );\n const localConnectionId = addedEntry\n ? connections.indexOf(addedEntry) + 1\n : null;\n\n const idString = localConnectionId ? `#${localConnectionId}` : '';\n\n return `Successfully established connection ${idString} with ${targetAgentName} (${targetAccountId}). Connection Topic: ${connectionTopicId}. You can now send messages using this connection.`;\n } catch (error) {\n this.logger.error(`Connection initiation failed: ${error}`);\n return `Error initiating connection with ${targetAccountId}: ${\n error instanceof Error ? error.message : String(error)\n }`;\n }\n }\n}\n"],"names":[],"mappings":";;;AAiBO,MAAM,+BAA+B,eAAe;AAAA,EAgBzD,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,GAC4B;AAC/B,UAAM,IAAI;AApBL,SAAA,OAAA;AAEL,SAAA,cAAA;AACF,SAAA,SAAS,EAAE,OAAO;AAAA,MAChB,iBAAiB,EACd,OAAA,EACA;AAAA,QACC;AAAA,MAAA;AAAA,IACF,CACH;AAYC,SAAK,YAAY;AACjB,SAAK,eAAe;AACpB,SAAK,SAAS,OAAO,YAAY,EAAE,QAAQ,0BAA0B;AAAA,EAAA;AAAA,EAGvE,MAAgB,MAAM;AAAA,IACpB;AAAA,EAAA,GAC2C;AACrC,UAAA,eAAe,KAAK,aAAa,gBAAgB;AACvD,QAAI,CAAC,cAAc;AACV,aAAA;AAAA,IAAA;AAGT,SAAK,OAAO;AAAA,MACV,8BAA8B,aAAa,SAAS,OAAO,eAAe;AAAA,IAC5E;AAEI,QAAA;AACF,WAAK,OAAO,MAAM,0BAA0B,eAAe,KAAK;AAC1D,YAAA,gBAAgB,MAAM,KAAK,UAAU;AAAA,QACzC;AAAA,MACF;AACI,UAAA,CAAC,eAAe,WAAW,cAAc;AAC3C,eAAO,+EAA+E,eAAe;AAAA,MAAA;AAEjG,YAAA,uBAAuB,cAAc,UAAU;AACrD,YAAM,kBACJ,cAAc,QAAQ,QAAQ,SAAS,eAAe;AAElD,YAAA,gBAAgB,MAAM,KAAK,UAAU;AAAA,QACzC;AAAA,QACA,aAAa;AAAA,MACf;AACA,YAAM,qBAAqB,eAAe;AAC1C,UAAI,CAAC,oBAAoB;AACjB,cAAA,IAAI,MAAM,+CAA+C;AAAA,MAAA;AAG7D,UAAA;AACA,UAAA;AACF,8BAAsB,mBAAmB,SAAS;AAC9C,YAAA,MAAM,mBAAmB,GAAG;AACxB,gBAAA,IAAI,MAAM,mCAAmC;AAAA,QAAA;AAAA,eAE9C,iBAAiB;AACxB,cAAM,IAAI;AAAA,UACR,yDAAyD,eAAe;AAAA,QAC1E;AAAA,MAAA;AAGF,YAAM,wBAAwB;AAC9B,YAAM,UAAU;AAChB,YAAM,cAAc,KAAK,KAAK,wBAAwB,OAAO;AAEvD,YAAA,qBACJ,MAAM,KAAK,UAAU;AAAA,QACnB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAEE,UAAA,CAAC,oBAAoB,mBAAmB;AAC1C,eAAO,oDAAoD,eAAe,iBAAiB,mBAAmB,YAC5G,wBAAwB,GAC1B;AAAA,MAAA;AAGF,YAAM,oBAAoB,mBAAmB;AAC7C,WAAK,OAAO,KAAK,mCAAmC,iBAAiB,EAAE;AAEvE,YAAM,gBAAkC;AAAA,QACtC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACK,WAAA,aAAa,oBAAoB,aAAa;AAE7C,YAAA,cAAc,KAAK,aAAa,gBAAgB;AACtD,YAAM,aAAa,YAAY;AAAA,QAC7B,CAAC,MAAM,EAAE,sBAAsB;AAAA,MACjC;AACA,YAAM,oBAAoB,aACtB,YAAY,QAAQ,UAAU,IAAI,IAClC;AAEJ,YAAM,WAAW,oBAAoB,IAAI,iBAAiB,KAAK;AAE/D,aAAO,uCAAuC,QAAQ,SAAS,eAAe,KAAK,eAAe,wBAAwB,iBAAiB;AAAA,aACpI,OAAO;AACd,WAAK,OAAO,MAAM,iCAAiC,KAAK,EAAE;AACnD,aAAA,oCAAoC,eAAe,KACxD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CACvD;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
|
@@ -17,13 +17,13 @@ export declare class AcceptConnectionRequestTool extends StructuredTool {
|
|
|
17
17
|
hbarFee: z.ZodOptional<z.ZodNumber>;
|
|
18
18
|
exemptAccountIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
19
19
|
}, "strip", z.ZodTypeAny, {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
hbarFee?: number;
|
|
21
|
+
exemptAccountIds?: string[];
|
|
22
|
+
requestKey?: string;
|
|
23
23
|
}, {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
hbarFee?: number;
|
|
25
|
+
exemptAccountIds?: string[];
|
|
26
|
+
requestKey?: string;
|
|
27
27
|
}>;
|
|
28
28
|
private hcsClient;
|
|
29
29
|
private stateManager;
|
|
@@ -18,13 +18,13 @@ export declare class CheckMessagesTool extends StructuredTool {
|
|
|
18
18
|
fetchLatest: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
19
19
|
lastMessagesCount: z.ZodOptional<z.ZodNumber>;
|
|
20
20
|
}, "strip", z.ZodTypeAny, {
|
|
21
|
-
targetIdentifier
|
|
22
|
-
fetchLatest
|
|
23
|
-
lastMessagesCount?: number
|
|
21
|
+
targetIdentifier?: string;
|
|
22
|
+
fetchLatest?: boolean;
|
|
23
|
+
lastMessagesCount?: number;
|
|
24
24
|
}, {
|
|
25
|
-
targetIdentifier
|
|
26
|
-
fetchLatest?: boolean
|
|
27
|
-
lastMessagesCount?: number
|
|
25
|
+
targetIdentifier?: string;
|
|
26
|
+
fetchLatest?: boolean;
|
|
27
|
+
lastMessagesCount?: number;
|
|
28
28
|
}>;
|
|
29
29
|
hcsClient: HCS10Client;
|
|
30
30
|
private stateManager;
|
|
@@ -26,58 +26,58 @@ export declare class ConnectionMonitorTool extends StructuredTool {
|
|
|
26
26
|
amount: z.ZodNumber;
|
|
27
27
|
collectorAccount: z.ZodOptional<z.ZodString>;
|
|
28
28
|
}, "strip", z.ZodTypeAny, {
|
|
29
|
-
amount
|
|
30
|
-
collectorAccount?: string
|
|
29
|
+
amount?: number;
|
|
30
|
+
collectorAccount?: string;
|
|
31
31
|
}, {
|
|
32
|
-
amount
|
|
33
|
-
collectorAccount?: string
|
|
32
|
+
amount?: number;
|
|
33
|
+
collectorAccount?: string;
|
|
34
34
|
}>, "many">>;
|
|
35
35
|
tokenFees: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
36
36
|
amount: z.ZodNumber;
|
|
37
37
|
tokenId: z.ZodString;
|
|
38
38
|
collectorAccount: z.ZodOptional<z.ZodString>;
|
|
39
39
|
}, "strip", z.ZodTypeAny, {
|
|
40
|
-
amount
|
|
41
|
-
tokenId
|
|
42
|
-
collectorAccount?: string
|
|
40
|
+
amount?: number;
|
|
41
|
+
tokenId?: string;
|
|
42
|
+
collectorAccount?: string;
|
|
43
43
|
}, {
|
|
44
|
-
amount
|
|
45
|
-
tokenId
|
|
46
|
-
collectorAccount?: string
|
|
44
|
+
amount?: number;
|
|
45
|
+
tokenId?: string;
|
|
46
|
+
collectorAccount?: string;
|
|
47
47
|
}>, "many">>;
|
|
48
48
|
exemptAccountIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
49
49
|
monitorDurationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
50
50
|
defaultCollectorAccount: z.ZodOptional<z.ZodString>;
|
|
51
51
|
}, "strip", z.ZodTypeAny, {
|
|
52
52
|
hbarFees?: {
|
|
53
|
-
amount
|
|
54
|
-
collectorAccount?: string
|
|
55
|
-
}[]
|
|
53
|
+
amount?: number;
|
|
54
|
+
collectorAccount?: string;
|
|
55
|
+
}[];
|
|
56
56
|
tokenFees?: {
|
|
57
|
-
amount
|
|
58
|
-
tokenId
|
|
59
|
-
collectorAccount?: string
|
|
60
|
-
}[]
|
|
61
|
-
exemptAccountIds?: string[]
|
|
62
|
-
targetAccountId?: string
|
|
63
|
-
acceptAll?: boolean
|
|
64
|
-
monitorDurationSeconds?: number
|
|
65
|
-
defaultCollectorAccount?: string
|
|
57
|
+
amount?: number;
|
|
58
|
+
tokenId?: string;
|
|
59
|
+
collectorAccount?: string;
|
|
60
|
+
}[];
|
|
61
|
+
exemptAccountIds?: string[];
|
|
62
|
+
targetAccountId?: string;
|
|
63
|
+
acceptAll?: boolean;
|
|
64
|
+
monitorDurationSeconds?: number;
|
|
65
|
+
defaultCollectorAccount?: string;
|
|
66
66
|
}, {
|
|
67
67
|
hbarFees?: {
|
|
68
|
-
amount
|
|
69
|
-
collectorAccount?: string
|
|
70
|
-
}[]
|
|
68
|
+
amount?: number;
|
|
69
|
+
collectorAccount?: string;
|
|
70
|
+
}[];
|
|
71
71
|
tokenFees?: {
|
|
72
|
-
amount
|
|
73
|
-
tokenId
|
|
74
|
-
collectorAccount?: string
|
|
75
|
-
}[]
|
|
76
|
-
exemptAccountIds?: string[]
|
|
77
|
-
targetAccountId?: string
|
|
78
|
-
acceptAll?: boolean
|
|
79
|
-
monitorDurationSeconds?: number
|
|
80
|
-
defaultCollectorAccount?: string
|
|
72
|
+
amount?: number;
|
|
73
|
+
tokenId?: string;
|
|
74
|
+
collectorAccount?: string;
|
|
75
|
+
}[];
|
|
76
|
+
exemptAccountIds?: string[];
|
|
77
|
+
targetAccountId?: string;
|
|
78
|
+
acceptAll?: boolean;
|
|
79
|
+
monitorDurationSeconds?: number;
|
|
80
|
+
defaultCollectorAccount?: string;
|
|
81
81
|
}>;
|
|
82
82
|
private hcsClient;
|
|
83
83
|
private stateManager;
|
|
@@ -15,11 +15,11 @@ export declare class FindRegistrationsTool extends StructuredTool {
|
|
|
15
15
|
accountId: z.ZodOptional<z.ZodString>;
|
|
16
16
|
tags: z.ZodOptional<z.ZodArray<z.ZodNativeEnum<typeof AIAgentCapability>, "many">>;
|
|
17
17
|
}, "strip", z.ZodTypeAny, {
|
|
18
|
-
accountId?: string
|
|
19
|
-
tags?: AIAgentCapability[]
|
|
18
|
+
accountId?: string;
|
|
19
|
+
tags?: AIAgentCapability[];
|
|
20
20
|
}, {
|
|
21
|
-
accountId?: string
|
|
22
|
-
tags?: AIAgentCapability[]
|
|
21
|
+
accountId?: string;
|
|
22
|
+
tags?: AIAgentCapability[];
|
|
23
23
|
}>;
|
|
24
24
|
private hcsClient;
|
|
25
25
|
private logger;
|
|
@@ -18,9 +18,9 @@ export declare class InitiateConnectionTool extends StructuredTool {
|
|
|
18
18
|
schema: z.ZodObject<{
|
|
19
19
|
targetAccountId: z.ZodString;
|
|
20
20
|
}, "strip", z.ZodTypeAny, {
|
|
21
|
-
targetAccountId
|
|
21
|
+
targetAccountId?: string;
|
|
22
22
|
}, {
|
|
23
|
-
targetAccountId
|
|
23
|
+
targetAccountId?: string;
|
|
24
24
|
}>;
|
|
25
25
|
private hcsClient;
|
|
26
26
|
private stateManager;
|
|
@@ -17,11 +17,11 @@ export declare class ListConnectionsTool extends StructuredTool {
|
|
|
17
17
|
includeDetails: z.ZodOptional<z.ZodBoolean>;
|
|
18
18
|
showPending: z.ZodOptional<z.ZodBoolean>;
|
|
19
19
|
}, "strip", z.ZodTypeAny, {
|
|
20
|
-
includeDetails?: boolean
|
|
21
|
-
showPending?: boolean
|
|
20
|
+
includeDetails?: boolean;
|
|
21
|
+
showPending?: boolean;
|
|
22
22
|
}, {
|
|
23
|
-
includeDetails?: boolean
|
|
24
|
-
showPending?: boolean
|
|
23
|
+
includeDetails?: boolean;
|
|
24
|
+
showPending?: boolean;
|
|
25
25
|
}>;
|
|
26
26
|
private stateManager;
|
|
27
27
|
private hcsClient?;
|
|
@@ -13,11 +13,11 @@ export declare class ListUnapprovedConnectionRequestsTool extends StructuredTool
|
|
|
13
13
|
sortBy: z.ZodOptional<z.ZodEnum<["time_asc", "time_desc", "name_asc", "name_desc"]>>;
|
|
14
14
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
15
15
|
}, "strip", z.ZodTypeAny, {
|
|
16
|
-
sortBy?: "time_asc" | "time_desc" | "name_asc" | "name_desc"
|
|
17
|
-
limit?: number
|
|
16
|
+
sortBy?: "time_asc" | "time_desc" | "name_asc" | "name_desc";
|
|
17
|
+
limit?: number;
|
|
18
18
|
}, {
|
|
19
|
-
sortBy?: "time_asc" | "time_desc" | "name_asc" | "name_desc"
|
|
20
|
-
limit?: number
|
|
19
|
+
sortBy?: "time_asc" | "time_desc" | "name_asc" | "name_desc";
|
|
20
|
+
limit?: number;
|
|
21
21
|
}>;
|
|
22
22
|
private hcsClient;
|
|
23
23
|
private stateManager;
|
|
@@ -17,11 +17,11 @@ export declare class ManageConnectionRequestsTool extends StructuredTool {
|
|
|
17
17
|
action: z.ZodEnum<["list", "view", "reject"]>;
|
|
18
18
|
requestKey: z.ZodOptional<z.ZodString>;
|
|
19
19
|
}, "strip", z.ZodTypeAny, {
|
|
20
|
-
action
|
|
21
|
-
requestKey?: string
|
|
20
|
+
action?: "list" | "view" | "reject";
|
|
21
|
+
requestKey?: string;
|
|
22
22
|
}, {
|
|
23
|
-
action
|
|
24
|
-
requestKey?: string
|
|
23
|
+
action?: "list" | "view" | "reject";
|
|
24
|
+
requestKey?: string;
|
|
25
25
|
}>;
|
|
26
26
|
private hcsClient;
|
|
27
27
|
private stateManager;
|