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. https://hol.org

48 lines (47 loc) 1.98 kB
import { z } from "zod"; import { BaseHCS2QueryTool } from "./standards-agent-kit.es23.js"; const queryRegistrySchema = z.object({ topicId: z.string().regex(/^\d+\.\d+\.\d+$/).describe("The HCS-2 registry topic ID to query"), limit: z.number().int().positive().optional().describe("Maximum number of entries to return"), order: z.enum(["asc", "desc"]).optional().describe("Order of results (ascending or descending)"), skip: z.number().int().min(0).optional().describe("Number of entries to skip") }); class QueryRegistryTool extends BaseHCS2QueryTool { constructor() { super(...arguments); this.name = "queryHCS2Registry"; this.description = "Query entries from an HCS-2 registry (standard HCS-2). Retrieves indexed or latest entries and returns a structured summary."; } get specificInputSchema() { return queryRegistrySchema; } async executeQuery(params, _runManager) { const registry = await this.hcs2Builder.getRegistry(params.topicId, { limit: params.limit, order: params.order, skip: params.skip }); const typeVal = registry.registryType; const isIndexed = typeVal === 0 || typeVal === "0" || String(typeVal).toLowerCase() === "indexed" || String(typeVal).toLowerCase() === "index" || String(typeVal).toLowerCase() === "index_topic" || String(typeVal).toLowerCase() === "indexed_registry"; return { topicId: registry.topicId, registryType: isIndexed ? "indexed" : "non-indexed", ttl: registry.ttl, totalEntries: registry.entries.length, entries: registry.entries.map((entry) => ({ sequence: entry.sequence, timestamp: entry.timestamp, payer: entry.payer, operation: entry.message.op, targetTopicId: entry.message.t_id, uid: entry.message.uid, metadata: entry.message.metadata, memo: entry.message.m })) }; } } export { QueryRegistryTool }; //# sourceMappingURL=standards-agent-kit.es29.js.map