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

47 lines (40 loc) 1.28 kB
import type { ChatConversationHandle, ConversationMode, SessionEncryptionSummary, } from '@hashgraphonline/standards-sdk/services/registry-broker'; export interface StoredConversationHandle { handleId: string; sessionId: string; mode: ConversationMode; summary: SessionEncryptionSummary | null | undefined; } export class RegistryBrokerConversationStore { private readonly handles = new Map<string, ChatConversationHandle>(); register(handle: ChatConversationHandle): StoredConversationHandle { const handleId = this.createHandleId(); this.handles.set(handleId, handle); return { handleId, sessionId: handle.sessionId, mode: handle.mode, summary: handle.summary ?? null, }; } get(handleId: string): ChatConversationHandle { const handle = this.handles.get(handleId); if (!handle) { throw new Error(`Conversation handle not found: ${handleId}`); } return handle; } release(handleId: string): boolean { return this.handles.delete(handleId); } private createHandleId(): string { if (typeof globalThis.crypto?.randomUUID === 'function') { return globalThis.crypto.randomUUID(); } return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`; } }