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.

47 lines (44 loc) 1.91 kB
import { z } from "zod"; import { BaseHCS2QueryTool } from "./standards-agent-kit.es20.js"; import { HCS2RegistryType } from "@hashgraphonline/standards-sdk"; const createRegistrySchema = z.object({ registryType: z.nativeEnum(HCS2RegistryType).optional().describe("Registry type: 0 for indexed, 1 for non-indexed (default: 0)"), ttl: z.number().int().positive().optional().describe("Time to live in seconds (default: 86400)"), adminKey: z.union([z.string(), z.boolean()]).optional().describe("Admin key: public key string or true to use operator key"), submitKey: z.union([z.string(), z.boolean()]).optional().describe("Submit key: public key string or true to use operator key") }); class CreateRegistryTool extends BaseHCS2QueryTool { constructor() { super(...arguments); this.name = "createHCS2Registry"; this.description = "Create a new HCS-2 registry topic for storing decentralized data"; } get specificInputSchema() { return createRegistrySchema; } async executeQuery(params, _runManager) { try { const result = await this.hcs2Builder.createRegistry({ registryType: params.registryType, ttl: params.ttl, adminKey: params.adminKey, submitKey: params.submitKey }); if (!result.success) { throw new Error(result.error || "Failed to create registry"); } return `Successfully created HCS-2 registry! Topic ID: ${result.topicId} Registry Type: ${params.registryType === 1 ? "Non-Indexed" : "Indexed"} TTL: ${params.ttl || 86400} seconds You can now register entries to this registry using the topic ID.`; } catch (error) { const errorMessage = error instanceof Error ? error.message : "Failed to create HCS-2 registry"; throw new Error(`Registry creation failed: ${errorMessage}`); } } } export { CreateRegistryTool }; //# sourceMappingURL=standards-agent-kit.es21.js.map