@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
59 lines (56 loc) • 2.1 kB
JavaScript
import { z } from "zod";
import { BaseHCS2QueryTool } from "./standards-agent-kit.es23.js";
import { isWalletBytesResponse } from "./standards-agent-kit.es50.js";
const deleteEntrySchema = z.object({
registryTopicId: z.string().regex(/^\d+\.\d+\.\d+$/).describe("The HCS-2 registry topic ID (must be indexed)"),
uid: z.string().describe("The unique ID of the entry to delete"),
memo: z.string().max(500).optional().describe("Optional memo (max 500 characters)")
});
class DeleteEntryTool extends BaseHCS2QueryTool {
constructor() {
super(...arguments);
this.name = "deleteHCS2Entry";
this.description = "Delete an entry from an indexed HCS-2 registry";
}
get specificInputSchema() {
return deleteEntrySchema;
}
async executeQuery(params, _runManager) {
try {
const result = await this.hcs2Builder.deleteEntry(
params.registryTopicId,
{
uid: params.uid,
memo: params.memo
}
);
if (!("success" in result) || !result.success) {
throw new Error(result.error || "Failed to delete entry");
}
if (isWalletBytesResponse(result)) {
const txBytes = result.transactionBytes;
return {
message: "I prepared an unsigned transaction to delete the HCS-2 registry entry. Please review and approve to submit.",
transactionBytes: txBytes,
metadata: {
transactionBytes: txBytes,
pendingApproval: true,
description: `Delete HCS-2 entry (registry ${params.registryTopicId}, uid ${params.uid})`
}
};
}
return `Successfully deleted entry from HCS-2 registry!
Registry Topic: ${params.registryTopicId}
UID: ${params.uid}${params.memo ? `
Memo: ${params.memo}` : ""}
The entry has been removed from the registry.`;
} catch (error) {
const errorMessage = error instanceof Error ? error.message : "Failed to delete entry";
throw new Error(`Entry deletion failed: ${errorMessage}`);
}
}
}
export {
DeleteEntryTool
};
//# sourceMappingURL=standards-agent-kit.es27.js.map