UNPKG

@hashgraphonline/standards-agent-kit

Version:

A modular SDK for building on-chain autonomous agents using Hashgraph Online Standards, including HCS-10 for agent discovery and communication.

49 lines (46 loc) 1.78 kB
import { z } from "zod"; import { BaseHCS2QueryTool } from "./standards-agent-kit.es20.js"; const registerEntrySchema = z.object({ registryTopicId: z.string().regex(/^\d+\.\d+\.\d+$/).describe("The HCS-2 registry topic ID (e.g., 0.0.123456)"), targetTopicId: z.string().regex(/^\d+\.\d+\.\d+$/).describe("The target topic ID to register (e.g., 0.0.123456)"), metadata: z.string().optional().describe("Optional metadata URI (HIP-412 format)"), memo: z.string().max(500).optional().describe("Optional memo (max 500 characters)") }); class RegisterEntryTool extends BaseHCS2QueryTool { constructor() { super(...arguments); this.name = "registerHCS2Entry"; this.description = "Register a new entry in an HCS-2 registry"; } get specificInputSchema() { return registerEntrySchema; } async executeQuery(params, _runManager) { try { const result = await this.hcs2Builder.registerEntry( params.registryTopicId, { targetTopicId: params.targetTopicId, metadata: params.metadata, memo: params.memo } ); if (!result.success) { throw new Error(result.error || "Failed to register entry"); } return `Successfully registered entry in HCS-2 registry! Registry Topic: ${params.registryTopicId} Target Topic ID: ${params.targetTopicId}${params.metadata ? ` Metadata: ${params.metadata}` : ""}${params.memo ? ` Memo: ${params.memo}` : ""} The entry has been added to the registry.`; } catch (error) { const errorMessage = error instanceof Error ? error.message : "Failed to register entry"; throw new Error(`Entry registration failed: ${errorMessage}`); } } } export { RegisterEntryTool }; //# sourceMappingURL=standards-agent-kit.es22.js.map