UNPKG

@hashgraphonline/conversational-agent

Version:

Hashgraph Online conversational AI agent implementing HCS-10 communication, HCS-2 registries, and content inscription on Hedera. https://hol.org

126 lines (125 loc) 3.68 kB
import { BasePlugin } from "hedera-agent-kit"; import { InscriberBuilder, InscribeFromUrlTool, InscribeFromFileTool, InscribeFromBufferTool, InscribeHashinalTool, RetrieveInscriptionTool } from "@hashgraphonline/standards-agent-kit"; import { fieldGuidanceRegistry } from "./index14.js"; class InscribePlugin extends BasePlugin { constructor() { super(...arguments); this.id = "inscribe"; this.name = "Inscribe Plugin"; this.description = "Content inscription tools for storing data on Hedera Consensus Service"; this.version = "1.0.0"; this.author = "Hashgraph Online"; this.namespace = "inscribe"; this.tools = []; this.providerId = null; } async initialize(context) { await super.initialize(context); const hederaKit = context.config.hederaKit; if (!hederaKit) { this.context.logger.warn( "HederaKit not found in context. Inscription tools will not be available." ); return; } try { this.initializeTools(); try { const provider = { getFieldGuidance: (fieldName) => { if (fieldName === "name") { return { suggestions: [ "Sunset Landscape #42", "Digital Abstract Art" ], contextualHelpText: "Create a distinctive name that collectors will find appealing" }; } if (fieldName === "description") { return { fieldTypeOverride: "textarea", suggestions: ["A beautiful piece representing..."] }; } return null; }, getGlobalGuidance: () => ({ qualityStandards: [ "Use meaningful names that describe the artwork or content" ] }) }; this.providerId = fieldGuidanceRegistry.registerToolProvider( /hashinal/i, provider, { id: "inscribe:hashinal:provider", priority: 1 } ); } catch (e) { this.context.logger.warn("Could not register Inscribe field guidance provider"); } this.context.logger.info( "Inscribe Plugin initialized successfully" ); } catch (error) { this.context.logger.error( "Failed to initialize Inscribe plugin:", error ); } } initializeTools() { const hederaKit = this.context.config.hederaKit; if (!hederaKit) { throw new Error("HederaKit not found in context config"); } const inscriberBuilder = new InscriberBuilder(hederaKit); this.tools = [ new InscribeFromUrlTool({ hederaKit, inscriberBuilder, logger: this.context.logger }), new InscribeFromFileTool({ hederaKit, inscriberBuilder, logger: this.context.logger }), new InscribeFromBufferTool({ hederaKit, inscriberBuilder, logger: this.context.logger }), new InscribeHashinalTool({ hederaKit, inscriberBuilder, logger: this.context.logger }), new RetrieveInscriptionTool({ hederaKit, inscriberBuilder, logger: this.context.logger }) ]; } getTools() { return this.tools; } async cleanup() { this.tools = []; if (this.providerId) { try { fieldGuidanceRegistry.unregisterProvider(this.providerId); } catch { } this.providerId = null; } if (this.context?.logger) { this.context.logger.info("Inscribe Plugin cleaned up"); } } } export { InscribePlugin }; //# sourceMappingURL=index4.js.map