@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.
52 lines (49 loc) • 1.86 kB
JavaScript
import { z } from "zod";
import { BaseHCS2QueryTool } from "./standards-agent-kit.es20.js";
const updateEntrySchema = z.object({
registryTopicId: z.string().regex(/^\d+\.\d+\.\d+$/).describe("The HCS-2 registry topic ID (must be indexed)"),
targetTopicId: z.string().regex(/^\d+\.\d+\.\d+$/).describe("The new topic ID to point to"),
uid: z.string().describe("The unique ID of the entry to update"),
metadata: z.string().optional().describe("Optional metadata URI (HIP-412 format)"),
memo: z.string().max(500).optional().describe("Optional memo (max 500 characters)")
});
class UpdateEntryTool extends BaseHCS2QueryTool {
constructor() {
super(...arguments);
this.name = "updateHCS2Entry";
this.description = "Update an existing entry in an indexed HCS-2 registry";
}
get specificInputSchema() {
return updateEntrySchema;
}
async executeQuery(params, _runManager) {
try {
const result = await this.hcs2Builder.updateEntry(
params.registryTopicId,
{
targetTopicId: params.targetTopicId,
uid: params.uid,
metadata: params.metadata,
memo: params.memo
}
);
if (!result.success) {
throw new Error(result.error || "Failed to update entry");
}
return `Successfully updated entry in HCS-2 registry!
Registry Topic: ${params.registryTopicId}
UID: ${params.uid}
New Target Topic ID: ${params.targetTopicId}${params.metadata ? `
Metadata: ${params.metadata}` : ""}${params.memo ? `
Memo: ${params.memo}` : ""}
The entry has been updated in the registry.`;
} catch (error) {
const errorMessage = error instanceof Error ? error.message : "Failed to update entry";
throw new Error(`Entry update failed: ${errorMessage}`);
}
}
}
export {
UpdateEntryTool
};
//# sourceMappingURL=standards-agent-kit.es23.js.map