@hashgraphonline/conversational-agent
Version:
Hashgraph Online conversational AI agent implementing HCS-10 communication, HCS-2 registries, and content inscription on Hedera. https://hol.org
71 lines (70 loc) • 2.19 kB
JavaScript
import { BasePlugin, HederaAirdropTokenTool } from "hedera-agent-kit";
import { TransferHbarTool } from "./index38.js";
import { AirdropToolWrapper } from "./index39.js";
class HbarPlugin extends BasePlugin {
constructor() {
super(...arguments);
this.id = "hbar";
this.name = "HBAR Plugin";
this.description = "HBAR operations: transfer tool with robust decimal handling and compatibility with airdrop improvements";
this.version = "1.0.0";
this.author = "Hashgraph Online";
this.namespace = "account";
this.tools = [];
this.originalAirdropTool = null;
}
async initialize(context) {
await super.initialize(context);
const hederaKit = context.config.hederaKit;
if (!hederaKit) {
this.context.logger.warn(
"HederaKit not found in context. HBAR tools will not be available."
);
return;
}
try {
this.initializeTools();
this.context.logger.info("HBAR Plugin initialized successfully");
} catch (error) {
this.context.logger.error("Failed to initialize HBAR plugin:", error);
}
}
initializeTools() {
const hederaKit = this.context.config.hederaKit;
if (!hederaKit) {
throw new Error("HederaKit not found in context config");
}
const transfer = new TransferHbarTool({
hederaKit,
logger: this.context.logger
});
this.tools = [transfer];
try {
this.context.logger.info(
"Creating wrapper for passed original airdrop tool"
);
const airdropTool = new HederaAirdropTokenTool({
hederaKit,
logger: this.context.logger
});
const wrappedAirdropTool = new AirdropToolWrapper(airdropTool, hederaKit);
this.tools.push(wrappedAirdropTool);
this.context.logger.info("Added wrapped airdrop tool to HBAR Plugin");
} catch (error) {
this.context.logger.error("Error creating airdrop tool wrapper:", error);
}
this.context.logger.info(
`HBAR Plugin tools initialized with ${this.tools.length} tools`
);
}
getTools() {
return this.tools;
}
async shutdown() {
this.tools = [];
}
}
export {
HbarPlugin
};
//# sourceMappingURL=index5.js.map