@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
62 lines (59 loc) • 2.37 kB
JavaScript
import { z } from "zod";
import { BaseHCS2QueryTool } from "./standards-agent-kit.es23.js";
import { isWalletBytesResponse } from "./standards-agent-kit.es50.js";
const migrateRegistrySchema = z.object({
registryTopicId: z.string().regex(/^\d+\.\d+\.\d+$/).describe("The current HCS-2 registry topic ID"),
targetTopicId: z.string().regex(/^\d+\.\d+\.\d+$/).describe("The new topic ID to migrate to"),
metadata: z.string().optional().describe("Optional metadata URI for migration details"),
memo: z.string().max(500).optional().describe("Optional memo (max 500 characters)")
});
class MigrateRegistryTool extends BaseHCS2QueryTool {
constructor() {
super(...arguments);
this.name = "migrateHCS2Registry";
this.description = "Migrate an HCS-2 registry to a new topic";
}
get specificInputSchema() {
return migrateRegistrySchema;
}
async executeQuery(params, _runManager) {
try {
const result = await this.hcs2Builder.migrateRegistry(
params.registryTopicId,
{
targetTopicId: params.targetTopicId,
metadata: params.metadata,
memo: params.memo
}
);
if (!("success" in result) || !result.success) {
throw new Error(result.error || "Failed to migrate registry");
}
if (isWalletBytesResponse(result)) {
const txBytes = result.transactionBytes;
return {
message: "I prepared an unsigned transaction to migrate the HCS-2 registry. Please review and approve to submit.",
transactionBytes: txBytes,
metadata: {
transactionBytes: txBytes,
pendingApproval: true,
description: `Migrate HCS-2 registry (from ${params.registryTopicId} to ${params.targetTopicId})`
}
};
}
return `Successfully migrated HCS-2 registry!
From Registry Topic: ${params.registryTopicId}
To Target Topic: ${params.targetTopicId}${params.metadata ? `
Metadata: ${params.metadata}` : ""}${params.memo ? `
Memo: ${params.memo}` : ""}
The registry has been migrated to the new topic.`;
} catch (error) {
const errorMessage = error instanceof Error ? error.message : "Failed to migrate registry";
throw new Error(`Registry migration failed: ${errorMessage}`);
}
}
}
export {
MigrateRegistryTool
};
//# sourceMappingURL=standards-agent-kit.es28.js.map