@hashgraphonline/conversational-agent
Version:
Hashgraph Online conversational AI agent implementing HCS-10 communication, HCS-2 registries, and content inscription on Hedera
85 lines (83 loc) • 2.58 kB
TypeScript
import { ContentReference, ReferenceId } from '../types/content-reference';
import { ContentStorage } from '../memory/ContentStorage';
import { Logger } from '@hashgraphonline/standards-sdk';
export interface ReferenceContext {
reference: ContentReference;
displayedAt: Date;
lastAccessedAt: Date;
contextId: string;
conversationTurn: number;
}
export interface ReferenceDisplayOptions {
maxPreviewLength?: number;
showMetadata?: boolean;
showSize?: boolean;
includeActions?: boolean;
format?: 'inline' | 'card' | 'compact';
}
export interface DisplayResult {
displayText: string;
hasValidReference: boolean;
contextId?: string;
suggestedActions?: string[];
}
/**
* Manages content references within agent conversation context
* Tracks reference usage, provides display formatting, and handles reference validation
*/
export declare class ReferenceContextManager {
private activeReferences;
private contentStorage;
private logger;
private conversationTurn;
constructor(contentStorage: ContentStorage, logger: Logger);
/**
* Add a reference to the current conversation context
*/
addReference(reference: ContentReference): string;
/**
* Generate display text for a content reference
*/
displayReference(reference: ContentReference, options?: ReferenceDisplayOptions): Promise<DisplayResult>;
/**
* Get the most recent reference for "inscribe it" commands
*/
getMostRecentReference(): ContentReference | null;
/**
* Get reference by context ID
*/
getReferenceByContextId(contextId: string): ContentReference | null;
/**
* Validate all active references and remove invalid ones
*/
validateReferences(): Promise<{
valid: number;
invalid: number;
removed: ReferenceId[];
}>;
/**
* Clear old references based on age and usage
*/
cleanupOldReferences(maxAgeMs?: number): number;
/**
* Get current context statistics
*/
getContextStats(): {
activeReferences: number;
conversationTurn: number;
oldestReference: number | null;
mostRecentReference: number | null;
};
/**
* Clear all references from context
*/
clear(): void;
private formatCardReference;
private formatInlineReference;
private formatCompactReference;
private formatInvalidReference;
private formatErrorReference;
private truncateText;
private getOldestReferenceAge;
private getMostRecentReferenceAge;
}