@hashgraphonline/conversational-agent 0.2.106 → 0.2.109

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/cjs/config/system-message.d.ts +1 -1
  2. package/dist/cjs/conversational-agent.d.ts +16 -0
  3. package/dist/cjs/core/tool-registry.d.ts +26 -0
  4. package/dist/cjs/index.cjs +1 -1
  5. package/dist/cjs/index.cjs.map +1 -1
  6. package/dist/cjs/runtime/wallet-bridge.d.ts +3 -0
  7. package/dist/cjs/services/attachment-processor.d.ts +1 -2
  8. package/dist/cjs/services/content-store-manager.d.ts +1 -1
  9. package/dist/cjs/services/formatters/types.d.ts +3 -1
  10. package/dist/cjs/services/index.d.ts +1 -1
  11. package/dist/esm/index10.js +2 -2
  12. package/dist/esm/index13.js.map +1 -1
  13. package/dist/esm/index18.js.map +1 -1
  14. package/dist/esm/index2.js.map +1 -1
  15. package/dist/esm/index21.js +1 -1
  16. package/dist/esm/index21.js.map +1 -1
  17. package/dist/esm/index23.js +1 -1
  18. package/dist/esm/index24.js.map +1 -1
  19. package/dist/esm/index26.js.map +1 -1
  20. package/dist/esm/index3.js.map +1 -1
  21. package/dist/esm/index30.js.map +1 -1
  22. package/dist/esm/index33.js +4 -4
  23. package/dist/esm/index36.js.map +1 -1
  24. package/dist/esm/index37.js +1 -1
  25. package/dist/esm/index39.js.map +1 -1
  26. package/dist/esm/index4.js +1 -1
  27. package/dist/esm/index4.js.map +1 -1
  28. package/dist/esm/index40.js +2 -2
  29. package/dist/esm/index40.js.map +1 -1
  30. package/dist/esm/index41.js +4 -11
  31. package/dist/esm/index41.js.map +1 -1
  32. package/dist/esm/index42.js +11 -6
  33. package/dist/esm/index42.js.map +1 -1
  34. package/dist/esm/index43.js +322 -5
  35. package/dist/esm/index43.js.map +1 -1
  36. package/dist/esm/index44.js +142 -229
  37. package/dist/esm/index44.js.map +1 -1
  38. package/dist/esm/index45.js +7 -184
  39. package/dist/esm/index45.js.map +1 -1
  40. package/dist/esm/index46.js +89 -24
  41. package/dist/esm/index46.js.map +1 -1
  42. package/dist/esm/index47.js +24 -89
  43. package/dist/esm/index47.js.map +1 -1
  44. package/dist/esm/index6.js +96 -30
  45. package/dist/esm/index6.js.map +1 -1
  46. package/dist/types/config/system-message.d.ts +1 -1
  47. package/dist/types/conversational-agent.d.ts +16 -0
  48. package/dist/types/core/tool-registry.d.ts +26 -0
  49. package/dist/types/runtime/wallet-bridge.d.ts +3 -0
  50. package/dist/types/services/attachment-processor.d.ts +1 -2
  51. package/dist/types/services/content-store-manager.d.ts +1 -1
  52. package/dist/types/services/formatters/types.d.ts +3 -1
  53. package/dist/types/services/index.d.ts +1 -1
  54. package/package.json +7 -6
  55. package/src/config/system-message.ts +3 -3
  56. package/src/conversational-agent.ts +224 -63
  57. package/src/core/tool-registry.ts +61 -1
  58. package/src/forms/field-guidance-registry.ts +0 -2
  59. package/src/memory/content-storage.ts +19 -6
  60. package/src/memory/smart-memory-manager.ts +0 -1
  61. package/src/plugins/hcs-10/HCS10Plugin.ts +0 -2
  62. package/src/plugins/hcs-2/HCS2Plugin.ts +0 -2
  63. package/src/plugins/inscribe/InscribePlugin.ts +1 -2
  64. package/src/runtime/wallet-bridge.ts +5 -0
  65. package/src/services/attachment-processor.ts +1 -1
  66. package/src/services/content-store-manager.ts +1 -1
  67. package/src/services/formatters/types.ts +3 -1
  68. package/src/services/index.ts +1 -1
  69. package/src/signers/browser-signer.ts +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index21.js","sources":["../../src/memory/content-storage.ts"],"sourcesContent":["import type { BaseMessage } from '@langchain/core/messages';\nimport { ReferenceIdGenerator } from './reference-id-generator';\nimport {\n ReferenceId,\n ContentReference,\n ContentMetadata,\n ReferenceResolutionResult,\n ContentReferenceConfig,\n ContentReferenceStore,\n ContentReferenceStats,\n ContentReferenceError,\n ContentType,\n ContentSource,\n ReferenceLifecycleState,\n DEFAULT_CONTENT_REFERENCE_CONFIG,\n} from '../types/content-reference';\n\n/**\n * Stored message with metadata\n */\ninterface StoredMessage {\n message: BaseMessage;\n storedAt: Date;\n id: string;\n}\n\n/**\n * Search options for message queries\n */\ninterface SearchOptions {\n /** Whether to perform case-sensitive search */\n caseSensitive?: boolean;\n /** Maximum number of results to return */\n limit?: number;\n /** Whether to use regex pattern matching */\n useRegex?: boolean;\n}\n\n/**\n * Result of storing messages\n */\ninterface StoreResult {\n /** Number of messages successfully stored */\n stored: number;\n /** Number of old messages dropped to make room */\n dropped: number;\n}\n\n/**\n * Storage statistics\n */\nexport interface StorageStats {\n /** Total number of messages currently stored */\n totalMessages: number;\n /** Maximum storage capacity */\n maxStorageLimit: number;\n /** Percentage of storage used */\n usagePercentage: number;\n /** Timestamp of oldest message */\n oldestMessageTime: Date | undefined;\n /** Timestamp of newest message */\n newestMessageTime: Date | undefined;\n}\n\n/**\n * Stored content with reference metadata\n */\ninterface StoredContent {\n /** The actual content buffer */\n content: Buffer;\n\n /** Complete metadata */\n metadata: ContentMetadata;\n\n /** Current lifecycle state */\n state: ReferenceLifecycleState;\n\n /** When this reference expires (if applicable) */\n expiresAt?: Date;\n}\n\n/**\n * Content storage for managing pruned conversation messages and large content references\n * Provides searchable storage with time-based querying and automatic cleanup.\n *\n * Extended to support reference-based storage for large content to optimize context window usage.\n */\nexport class ContentStorage implements ContentReferenceStore {\n private messages: StoredMessage[] = [];\n private maxStorage: number;\n private idCounter: number = 0;\n\n private contentStore: Map<ReferenceId, StoredContent> = new Map();\n private referenceConfig: ContentReferenceConfig;\n private cleanupTimer?: NodeJS.Timeout;\n private referenceStats: Omit<ContentReferenceStats, 'performanceMetrics'> & {\n performanceMetrics: ContentReferenceStats['performanceMetrics'] & {\n creationTimes: number[];\n resolutionTimes: number[];\n cleanupTimes: number[];\n };\n };\n\n public static readonly DEFAULT_MAX_STORAGE = 1000;\n\n constructor(\n maxStorage: number = ContentStorage.DEFAULT_MAX_STORAGE,\n referenceConfig?: Partial<ContentReferenceConfig>\n ) {\n this.maxStorage = maxStorage;\n\n this.referenceConfig = {\n ...DEFAULT_CONTENT_REFERENCE_CONFIG,\n ...referenceConfig,\n };\n this.referenceStats = {\n activeReferences: 0,\n totalStorageBytes: 0,\n recentlyCleanedUp: 0,\n totalResolutions: 0,\n failedResolutions: 0,\n averageContentSize: 0,\n storageUtilization: 0,\n performanceMetrics: {\n averageCreationTimeMs: 0,\n averageResolutionTimeMs: 0,\n averageCleanupTimeMs: 0,\n creationTimes: [],\n resolutionTimes: [],\n cleanupTimes: [],\n },\n };\n\n if (this.referenceConfig.enableAutoCleanup) {\n this.startReferenceCleanupTimer();\n }\n }\n\n /**\n * Store messages in the content storage\n * Automatically drops oldest messages if storage limit is exceeded\n * @param messages - Messages to store\n * @returns Result indicating how many messages were stored and dropped\n */\n storeMessages(messages: BaseMessage[]): StoreResult {\n if (messages.length === 0) {\n return { stored: 0, dropped: 0 };\n }\n\n const now = new Date();\n let dropped = 0;\n\n const storedMessages: StoredMessage[] = messages.map((message) => ({\n message,\n storedAt: now,\n id: this.generateId(),\n }));\n\n this.messages.push(...storedMessages);\n\n while (this.messages.length > this.maxStorage) {\n this.messages.shift();\n dropped++;\n }\n\n return {\n stored: storedMessages.length,\n dropped,\n };\n }\n\n /**\n * Get the most recent messages from storage\n * @param count - Number of recent messages to retrieve\n * @returns Array of recent messages in chronological order\n */\n getRecentMessages(count: number): BaseMessage[] {\n if (count <= 0 || this.messages.length === 0) {\n return [];\n }\n\n const startIndex = Math.max(0, this.messages.length - count);\n return this.messages.slice(startIndex).map((stored) => stored.message);\n }\n\n /**\n * Search for messages containing specific text or patterns\n * @param query - Search term or regex pattern\n * @param options - Search configuration options\n * @returns Array of matching messages\n */\n searchMessages(query: string, options: SearchOptions = {}): BaseMessage[] {\n if (!query || this.messages.length === 0) {\n return [];\n }\n\n const { caseSensitive = false, limit, useRegex = false } = options;\n\n let matches: BaseMessage[] = [];\n\n if (useRegex) {\n try {\n const regex = new RegExp(query, caseSensitive ? 'g' : 'gi');\n matches = this.messages\n .filter((stored) => regex.test(stored.message.content as string))\n .map((stored) => stored.message);\n } catch {\n return [];\n }\n } else {\n const searchTerm = caseSensitive ? query : query.toLowerCase();\n matches = this.messages\n .filter((stored) => {\n const content = stored.message.content as string;\n const searchContent = caseSensitive ? content : content.toLowerCase();\n return searchContent.includes(searchTerm);\n })\n .map((stored) => stored.message);\n }\n\n return limit ? matches.slice(0, limit) : matches;\n }\n\n /**\n * Get messages from a specific time range\n * @param startTime - Start of time range (inclusive)\n * @param endTime - End of time range (inclusive)\n * @returns Array of messages within the time range\n */\n getMessagesFromTimeRange(startTime: Date, endTime: Date): BaseMessage[] {\n if (startTime > endTime || this.messages.length === 0) {\n return [];\n }\n\n return this.messages\n .filter(\n (stored) => stored.storedAt >= startTime && stored.storedAt <= endTime\n )\n .map((stored) => stored.message);\n }\n\n /**\n * Get storage statistics and usage information\n * @returns Current storage statistics\n */\n getStorageStats(): StorageStats {\n const totalMessages = this.messages.length;\n const usagePercentage =\n totalMessages > 0\n ? Math.round((totalMessages / this.maxStorage) * 100)\n : 0;\n\n let oldestMessageTime: Date | undefined;\n let newestMessageTime: Date | undefined;\n\n if (totalMessages > 0) {\n oldestMessageTime = this.messages[0].storedAt;\n newestMessageTime = this.messages[totalMessages - 1].storedAt;\n }\n\n return {\n totalMessages,\n maxStorageLimit: this.maxStorage,\n usagePercentage,\n oldestMessageTime,\n newestMessageTime,\n };\n }\n\n /**\n * Clear all stored messages\n */\n clear(): void {\n this.messages = [];\n this.idCounter = 0;\n }\n\n /**\n * Get total number of stored messages\n * @returns Number of messages currently in storage\n */\n getTotalStoredMessages(): number {\n return this.messages.length;\n }\n\n /**\n * Update the maximum storage limit\n * @param newLimit - New maximum storage limit\n */\n updateStorageLimit(newLimit: number): void {\n if (newLimit <= 0) {\n throw new Error('Storage limit must be greater than 0');\n }\n\n this.maxStorage = newLimit;\n\n while (this.messages.length > this.maxStorage) {\n this.messages.shift();\n }\n }\n\n /**\n * Get messages by message type\n * @param messageType - Type of messages to retrieve ('human', 'ai', 'system', etc.)\n * @param limit - Maximum number of messages to return\n * @returns Array of messages of the specified type\n */\n getMessagesByType(messageType: string, limit?: number): BaseMessage[] {\n const filtered = this.messages\n .filter((stored) => stored.message._getType() === messageType)\n .map((stored) => stored.message);\n\n return limit ? filtered.slice(0, limit) : filtered;\n }\n\n /**\n * Get the current storage configuration\n * @returns Storage configuration object\n */\n getConfig(): { maxStorage: number; currentUsage: number; utilizationPercentage: number } {\n return {\n maxStorage: this.maxStorage,\n currentUsage: this.messages.length,\n utilizationPercentage: (this.messages.length / this.maxStorage) * 100,\n };\n }\n\n /**\n * Generate a unique ID for stored messages\n * @returns Unique string identifier\n */\n private generateId(): string {\n return `msg_${++this.idCounter}_${Date.now()}`;\n }\n\n /**\n * Get messages stored within the last N minutes\n * @param minutes - Number of minutes to look back\n * @returns Array of messages from the last N minutes\n */\n getRecentMessagesByTime(minutes: number): BaseMessage[] {\n if (minutes <= 0 || this.messages.length === 0) {\n return [];\n }\n\n const cutoffTime = new Date(Date.now() - minutes * 60 * 1000);\n\n return this.messages\n .filter((stored) => stored.storedAt >= cutoffTime)\n .map((stored) => stored.message);\n }\n\n /**\n * Export messages to a JSON-serializable format\n * @returns Serializable representation of stored messages\n */\n exportMessages(): Array<{ content: string; type: string; storedAt: string; id: string }> {\n return this.messages.map((stored) => ({\n content: typeof stored.message.content === 'string' \n ? stored.message.content \n : JSON.stringify(stored.message.content),\n type: stored.message._getType(),\n storedAt: stored.storedAt.toISOString(),\n id: stored.id,\n }));\n }\n\n /**\n * Determine if content should be stored as a reference based on size\n */\n shouldUseReference(content: Buffer | string): boolean {\n const size = Buffer.isBuffer(content)\n ? content.length\n : Buffer.byteLength(content, 'utf8');\n return size > this.referenceConfig.sizeThresholdBytes;\n }\n\n /**\n * Store content and return a reference if it exceeds the size threshold\n * Otherwise returns null to indicate direct content should be used\n *\n * Special case: Image files are ALWAYS stored as references regardless of size\n * because they need special handling for inscription tools\n */\n async storeContentIfLarge(\n content: Buffer | string,\n metadata: {\n contentType?: ContentType;\n mimeType?: string;\n source: ContentSource;\n mcpToolName?: string;\n fileName?: string;\n tags?: string[];\n customMetadata?: Record<string, unknown>;\n }\n ): Promise<ContentReference | null> {\n const buffer = Buffer.isBuffer(content)\n ? content\n : Buffer.from(content, 'utf8');\n\n const isImageFile = this.isImageContent(\n metadata.mimeType,\n metadata.fileName\n );\n\n if (!isImageFile && !this.shouldUseReference(buffer)) {\n return null;\n }\n\n const storeMetadata: Omit<\n ContentMetadata,\n 'createdAt' | 'lastAccessedAt' | 'accessCount'\n > = {\n contentType:\n metadata.contentType ||\n this.detectContentType(buffer, metadata.mimeType),\n sizeBytes: buffer.length,\n source: metadata.source,\n tags: [],\n };\n\n if (metadata.mimeType !== undefined) {\n storeMetadata.mimeType = metadata.mimeType;\n }\n if (metadata.mcpToolName !== undefined) {\n storeMetadata.mcpToolName = metadata.mcpToolName;\n }\n if (metadata.fileName !== undefined) {\n storeMetadata.fileName = metadata.fileName;\n }\n if (metadata.tags !== undefined) {\n storeMetadata.tags = metadata.tags;\n }\n if (metadata.customMetadata !== undefined) {\n storeMetadata.customMetadata = metadata.customMetadata;\n }\n\n return await this.storeContent(buffer, storeMetadata);\n }\n\n /**\n * Store content and return a reference (implements ContentReferenceStore)\n */\n async storeContent(\n content: Buffer,\n metadata: Omit<\n ContentMetadata,\n 'createdAt' | 'lastAccessedAt' | 'accessCount'\n >\n ): Promise<ContentReference> {\n const startTime = Date.now();\n\n try {\n const now = new Date();\n const referenceId = ReferenceIdGenerator.generateId(content);\n\n const fullMetadata: ContentMetadata = {\n ...metadata,\n createdAt: now,\n lastAccessedAt: now,\n accessCount: 0,\n };\n\n const storedContent: StoredContent = {\n content,\n metadata: fullMetadata,\n state: 'active',\n };\n\n const expirationTime = this.calculateExpirationTime(metadata.source);\n if (expirationTime !== undefined) {\n storedContent.expiresAt = expirationTime;\n }\n\n this.contentStore.set(referenceId, storedContent);\n\n this.updateStatsAfterStore(content.length);\n\n await this.enforceReferenceStorageLimits();\n\n const preview = this.createContentPreview(\n content,\n fullMetadata.contentType\n );\n\n const referenceMetadata: Pick<\n ContentMetadata,\n 'contentType' | 'sizeBytes' | 'source' | 'fileName' | 'mimeType'\n > = {\n contentType: fullMetadata.contentType,\n sizeBytes: fullMetadata.sizeBytes,\n source: fullMetadata.source,\n };\n\n if (fullMetadata.fileName !== undefined) {\n referenceMetadata.fileName = fullMetadata.fileName;\n }\n if (fullMetadata.mimeType !== undefined) {\n referenceMetadata.mimeType = fullMetadata.mimeType;\n }\n\n const reference: ContentReference = {\n referenceId,\n state: 'active',\n preview,\n metadata: referenceMetadata,\n createdAt: now,\n format: 'ref://{id}' as const,\n };\n\n const duration = Date.now() - startTime;\n this.recordPerformanceMetric('creation', duration);\n\n return reference;\n } catch (error) {\n const duration = Date.now() - startTime;\n this.recordPerformanceMetric('creation', duration);\n\n throw new ContentReferenceError(\n `Failed to store content: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`,\n 'system_error',\n undefined,\n ['Try again', 'Check storage limits', 'Contact administrator']\n );\n }\n }\n\n /**\n * Resolve a reference to its content (implements ContentReferenceStore)\n */\n async resolveReference(\n referenceId: ReferenceId\n ): Promise<ReferenceResolutionResult> {\n const startTime = Date.now();\n\n try {\n if (!ReferenceIdGenerator.isValidReferenceId(referenceId)) {\n this.referenceStats.failedResolutions++;\n return {\n success: false,\n error: 'Invalid reference ID format',\n errorType: 'not_found',\n suggestedActions: [\n 'Check the reference ID format',\n 'Ensure the reference ID is complete',\n ],\n };\n }\n\n const storedContent = this.contentStore.get(referenceId);\n\n if (!storedContent) {\n this.referenceStats.failedResolutions++;\n return {\n success: false,\n error: 'Reference not found',\n errorType: 'not_found',\n suggestedActions: [\n 'Verify the reference ID',\n 'Check if the content has expired',\n 'Request fresh content',\n ],\n };\n }\n\n if (storedContent.expiresAt && storedContent.expiresAt < new Date()) {\n storedContent.state = 'expired';\n this.referenceStats.failedResolutions++;\n return {\n success: false,\n error: 'Reference has expired',\n errorType: 'expired',\n suggestedActions: [\n 'Request fresh content',\n 'Use alternative content source',\n ],\n };\n }\n\n if (storedContent.state !== 'active') {\n this.referenceStats.failedResolutions++;\n return {\n success: false,\n error: `Reference is ${storedContent.state}`,\n errorType:\n storedContent.state === 'expired' ? 'expired' : 'corrupted',\n suggestedActions: [\n 'Request fresh content',\n 'Check reference validity',\n ],\n };\n }\n\n storedContent.metadata.lastAccessedAt = new Date();\n storedContent.metadata.accessCount++;\n\n this.referenceStats.totalResolutions++;\n\n const duration = Date.now() - startTime;\n this.recordPerformanceMetric('resolution', duration);\n\n return {\n success: true,\n content: storedContent.content,\n metadata: storedContent.metadata,\n };\n } catch (error) {\n const duration = Date.now() - startTime;\n this.recordPerformanceMetric('resolution', duration);\n\n this.referenceStats.failedResolutions++;\n\n return {\n success: false,\n error: `System error resolving reference: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`,\n errorType: 'system_error',\n suggestedActions: ['Try again', 'Contact administrator'],\n };\n }\n }\n\n /**\n * Check if a reference exists and is valid\n */\n async hasReference(referenceId: ReferenceId): Promise<boolean> {\n if (!ReferenceIdGenerator.isValidReferenceId(referenceId)) {\n return false;\n }\n\n const storedContent = this.contentStore.get(referenceId);\n if (!storedContent) {\n return false;\n }\n\n if (storedContent.expiresAt && storedContent.expiresAt < new Date()) {\n storedContent.state = 'expired';\n return false;\n }\n\n return storedContent.state === 'active';\n }\n\n /**\n * Mark a reference for cleanup\n */\n async cleanupReference(referenceId: ReferenceId): Promise<boolean> {\n const storedContent = this.contentStore.get(referenceId);\n if (!storedContent) {\n return false;\n }\n\n this.referenceStats.totalStorageBytes -= storedContent.content.length;\n this.referenceStats.activeReferences--;\n this.referenceStats.recentlyCleanedUp++;\n\n this.contentStore.delete(referenceId);\n\n return true;\n }\n\n /**\n * Get current reference storage statistics (implements ContentReferenceStore)\n */\n async getStats(): Promise<ContentReferenceStats> {\n this.updateReferenceStorageStats();\n\n return {\n ...this.referenceStats,\n performanceMetrics: {\n averageCreationTimeMs: this.calculateAverage(\n this.referenceStats.performanceMetrics.creationTimes\n ),\n averageResolutionTimeMs: this.calculateAverage(\n this.referenceStats.performanceMetrics.resolutionTimes\n ),\n averageCleanupTimeMs: this.calculateAverage(\n this.referenceStats.performanceMetrics.cleanupTimes\n ),\n },\n };\n }\n\n /**\n * Update reference configuration\n */\n async updateConfig(config: Partial<ContentReferenceConfig>): Promise<void> {\n this.referenceConfig = { ...this.referenceConfig, ...config };\n\n if (this.cleanupTimer) {\n clearInterval(this.cleanupTimer);\n delete this.cleanupTimer;\n }\n\n if (this.referenceConfig.enableAutoCleanup) {\n this.startReferenceCleanupTimer();\n }\n }\n\n /**\n * Perform cleanup based on current policies (implements ContentReferenceStore)\n */\n async performCleanup(): Promise<{ cleanedUp: number; errors: string[] }> {\n const startTime = Date.now();\n const errors: string[] = [];\n let cleanedUp = 0;\n\n try {\n const now = new Date();\n const toCleanup: ReferenceId[] = [];\n\n for (const [referenceId, storedContent] of this.contentStore.entries()) {\n let shouldCleanup = false;\n\n if (storedContent.expiresAt && storedContent.expiresAt < now) {\n shouldCleanup = true;\n storedContent.state = 'expired';\n }\n\n const ageMs =\n now.getTime() - storedContent.metadata.createdAt.getTime();\n const policy = this.getCleanupPolicy(storedContent.metadata.source);\n\n if (ageMs > policy.maxAgeMs) {\n shouldCleanup = true;\n }\n\n if (storedContent.state === 'cleanup_pending') {\n shouldCleanup = true;\n }\n\n if (shouldCleanup) {\n toCleanup.push(referenceId);\n }\n }\n\n toCleanup.sort((a, b) => {\n const aContent = this.contentStore.get(a)!;\n const bContent = this.contentStore.get(b)!;\n const aPriority = this.getCleanupPolicy(\n aContent.metadata.source\n ).priority;\n const bPriority = this.getCleanupPolicy(\n bContent.metadata.source\n ).priority;\n return bPriority - aPriority;\n });\n\n for (const referenceId of toCleanup) {\n try {\n const success = await this.cleanupReference(referenceId);\n if (success) {\n cleanedUp++;\n }\n } catch (error) {\n errors.push(\n `Failed to cleanup ${referenceId}: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`\n );\n }\n }\n\n if (this.contentStore.size > this.referenceConfig.maxReferences) {\n const sortedByAge = Array.from(this.contentStore.entries()).sort(\n ([, a], [, b]) =>\n a.metadata.lastAccessedAt.getTime() -\n b.metadata.lastAccessedAt.getTime()\n );\n\n const excessCount =\n this.contentStore.size - this.referenceConfig.maxReferences;\n for (let i = 0; i < excessCount && i < sortedByAge.length; i++) {\n const [referenceId] = sortedByAge[i];\n try {\n const success = await this.cleanupReference(referenceId);\n if (success) {\n cleanedUp++;\n }\n } catch (error) {\n errors.push(\n `Failed to cleanup excess reference ${referenceId}: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`\n );\n }\n }\n }\n\n const duration = Date.now() - startTime;\n this.recordPerformanceMetric('cleanup', duration);\n\n return { cleanedUp, errors };\n } catch (error) {\n const duration = Date.now() - startTime;\n this.recordPerformanceMetric('cleanup', duration);\n\n const errorMessage = `Cleanup process failed: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`;\n errors.push(errorMessage);\n\n return { cleanedUp, errors };\n }\n }\n\n /**\n * Get reference configuration for debugging\n */\n getReferenceConfig(): ContentReferenceConfig {\n return { ...this.referenceConfig };\n }\n\n private async enforceReferenceStorageLimits(): Promise<void> {\n if (this.contentStore.size >= this.referenceConfig.maxReferences) {\n await this.performCleanup();\n }\n\n if (\n this.referenceStats.totalStorageBytes >=\n this.referenceConfig.maxTotalStorageBytes\n ) {\n await this.performCleanup();\n }\n }\n\n private calculateExpirationTime(source: ContentSource): Date | undefined {\n const policy = this.getCleanupPolicy(source);\n return new Date(Date.now() + policy.maxAgeMs);\n }\n\n private getCleanupPolicy(source: ContentSource): { maxAgeMs: number; priority: number } {\n switch (source) {\n case 'mcp_tool':\n return this.referenceConfig.cleanupPolicies.recent;\n case 'user_upload':\n return this.referenceConfig.cleanupPolicies.userContent;\n case 'agent_generated':\n return this.referenceConfig.cleanupPolicies.agentGenerated;\n default:\n return this.referenceConfig.cleanupPolicies.default;\n }\n }\n\n private detectContentType(content: Buffer, mimeType?: string): ContentType {\n if (mimeType) {\n if (mimeType === 'text/html') return 'html';\n if (mimeType === 'text/markdown') return 'markdown';\n if (mimeType === 'application/json') return 'json';\n if (mimeType.startsWith('text/')) return 'text';\n return 'binary';\n }\n\n const contentStr = content.toString(\n 'utf8',\n 0,\n Math.min(content.length, 1000)\n );\n if (contentStr.startsWith('{') || contentStr.startsWith('[')) return 'json';\n if (contentStr.includes('<html>') || contentStr.includes('<!DOCTYPE'))\n return 'html';\n if (contentStr.includes('#') && contentStr.includes('\\n'))\n return 'markdown';\n\n return 'text';\n }\n\n private createContentPreview(\n content: Buffer,\n contentType: ContentType\n ): string {\n const maxLength = 200;\n let preview = content.toString(\n 'utf8',\n 0,\n Math.min(content.length, maxLength * 2)\n );\n\n if (contentType === 'html') {\n preview = preview\n .replace(/<[^>]*>/g, '')\n .replace(/\\s+/g, ' ')\n .trim();\n } else if (contentType === 'json') {\n try {\n const parsed = JSON.parse(preview);\n preview = JSON.stringify(parsed, null, 0);\n } catch {}\n }\n\n preview = preview.trim();\n if (preview.length > maxLength) {\n preview = preview.substring(0, maxLength) + '...';\n }\n\n return preview || '[Binary content]';\n }\n\n private updateStatsAfterStore(sizeBytes: number): void {\n this.referenceStats.activeReferences++;\n this.referenceStats.totalStorageBytes += sizeBytes;\n this.updateReferenceStorageStats();\n }\n\n private updateReferenceStorageStats(): void {\n if (this.referenceStats.activeReferences > 0) {\n this.referenceStats.averageContentSize =\n this.referenceStats.totalStorageBytes /\n this.referenceStats.activeReferences;\n }\n\n this.referenceStats.storageUtilization =\n (this.referenceStats.totalStorageBytes /\n this.referenceConfig.maxTotalStorageBytes) *\n 100;\n\n let mostAccessedId: ReferenceId | undefined;\n let maxAccess = 0;\n\n for (const [referenceId, storedContent] of this.contentStore.entries()) {\n if (storedContent.metadata.accessCount > maxAccess) {\n maxAccess = storedContent.metadata.accessCount;\n mostAccessedId = referenceId;\n }\n }\n\n if (mostAccessedId !== undefined) {\n this.referenceStats.mostAccessedReferenceId = mostAccessedId;\n } else {\n delete this.referenceStats.mostAccessedReferenceId;\n }\n }\n\n /**\n * Check if content is an image file based on MIME type or filename\n */\n private isImageContent(mimeType?: string, fileName?: string): boolean {\n if (mimeType && mimeType.startsWith('image/')) {\n return true;\n }\n\n if (fileName) {\n const lowerFileName = fileName.toLowerCase();\n const imageExtensions = [\n '.png',\n '.jpg',\n '.jpeg',\n '.gif',\n '.bmp',\n '.webp',\n '.svg',\n '.tiff',\n '.ico',\n ];\n return imageExtensions.some((ext) => lowerFileName.endsWith(ext));\n }\n\n return false;\n }\n\n private recordPerformanceMetric(\n type: 'creation' | 'resolution' | 'cleanup',\n timeMs: number\n ): void {\n const metrics = this.referenceStats.performanceMetrics;\n const maxRecords = 100;\n\n switch (type) {\n case 'creation':\n metrics.creationTimes.push(timeMs);\n if (metrics.creationTimes.length > maxRecords) {\n metrics.creationTimes.shift();\n }\n break;\n case 'resolution':\n metrics.resolutionTimes.push(timeMs);\n if (metrics.resolutionTimes.length > maxRecords) {\n metrics.resolutionTimes.shift();\n }\n break;\n case 'cleanup':\n metrics.cleanupTimes.push(timeMs);\n if (metrics.cleanupTimes.length > maxRecords) {\n metrics.cleanupTimes.shift();\n }\n break;\n }\n }\n\n private calculateAverage(times: number[]): number {\n if (times.length === 0) return 0;\n return times.reduce((sum, time) => sum + time, 0) / times.length;\n }\n\n private startReferenceCleanupTimer(): void {\n this.cleanupTimer = setInterval(async () => {\n try {\n await this.performCleanup();\n } catch {}\n }, this.referenceConfig.cleanupIntervalMs);\n }\n\n /**\n * Clean up resources (enhanced to include reference cleanup)\n */\n async dispose(): Promise<void> {\n if (this.cleanupTimer) {\n clearInterval(this.cleanupTimer);\n delete this.cleanupTimer;\n }\n\n this.contentStore.clear();\n\n this.clear();\n }\n}\n"],"names":[],"mappings":";;AAuFO,MAAM,kBAAN,MAAM,gBAAgD;AAAA,EAkB3D,YACE,aAAqB,gBAAe,qBACpC,iBAC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Ac,SAAS,YAAY;AAC7C,kBAAQ,cAAc,MAAA;AAAA,QACxB;AACA;AAAA,MACF,KAAK;AACH,gBAAQ,gBAAgB,KAAK,MAAM;AACnC,YAAI,QAAQ,gBAAgB,SAAS,YAAY;AAC/C,kBAAQ,gBAAgB,MAAA;AAAA,QAC1B;AACA;AAAA,MACF,KAAK;AACH,gBAAQ,aAAa,KAAK,MAAM;AAChC,YAAI,QAAQ,aAAa,SAAS,YAAY;AAC5C,kBAAQ,aAAa,MAAA;AAAA,QACvB;AACA;AAAA,IAAA;AAAA,EAEN;AAAA,EAEQ,iBAAiB,OAAyB;AAChD,QAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,WAAO,MAAM,OAAO,CAAC,KAAK,SAAS,MAAM,MAAM,CAAC,IAAI,MAAM;AAAA,EAC5D;AAAA,EAEQ,6BAAmC;AACzC,SAAK,eAAe,YAAY,YAAY;AAC1C,UAAI;AACF,cAAM,KAAK,eAAA;AAAA,MACb,QAAQ;AAAA,MAAC;AAAA,IACX,GAAG,KAAK,gBAAgB,iBAAiB;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,UAAyB;AAC7B,QAAI,KAAK,cAAc;AACrB,oBAAc,KAAK,YAAY;AAC/B,aAAO,KAAK;AAAA,IACd;AAEA,SAAK,aAAa,MAAA;AAElB,SAAK,MAAA;AAAA,EACP;AACF;AAn5BE,gBAAuB,sBAAsB;AAhBxC,IAAM,iBAAN;"}
1
+ {"version":3,"file":"index21.js","sources":["../../src/memory/content-storage.ts"],"sourcesContent":["import type { BaseMessage } from '@langchain/core/messages';\nimport { ReferenceIdGenerator } from './reference-id-generator';\nimport {\n ReferenceId,\n ContentReference,\n ContentMetadata,\n ReferenceResolutionResult,\n ContentReferenceConfig,\n ContentReferenceStore,\n ContentReferenceStats,\n ContentReferenceError,\n ContentType,\n ContentSource,\n ReferenceLifecycleState,\n DEFAULT_CONTENT_REFERENCE_CONFIG,\n} from '../types/content-reference';\n\n/**\n * Stored message with metadata\n */\ninterface StoredMessage {\n message: BaseMessage;\n storedAt: Date;\n id: string;\n}\n\n/**\n * Search options for message queries\n */\ninterface SearchOptions {\n /** Whether to perform case-sensitive search */\n caseSensitive?: boolean;\n /** Maximum number of results to return */\n limit?: number;\n /** Whether to use regex pattern matching */\n useRegex?: boolean;\n}\n\n/**\n * Result of storing messages\n */\ninterface StoreResult {\n /** Number of messages successfully stored */\n stored: number;\n /** Number of old messages dropped to make room */\n dropped: number;\n}\n\n/**\n * Storage statistics\n */\nexport interface StorageStats {\n /** Total number of messages currently stored */\n totalMessages: number;\n /** Maximum storage capacity */\n maxStorageLimit: number;\n /** Percentage of storage used */\n usagePercentage: number;\n /** Timestamp of oldest message */\n oldestMessageTime: Date | undefined;\n /** Timestamp of newest message */\n newestMessageTime: Date | undefined;\n}\n\n/**\n * Stored content with reference metadata\n */\ninterface StoredContent {\n /** The actual content buffer */\n content: Buffer;\n\n /** Complete metadata */\n metadata: ContentMetadata;\n\n /** Current lifecycle state */\n state: ReferenceLifecycleState;\n\n /** When this reference expires (if applicable) */\n expiresAt?: Date;\n}\n\n/**\n * Content storage for managing pruned conversation messages and large content references\n * Provides searchable storage with time-based querying and automatic cleanup.\n *\n * Extended to support reference-based storage for large content to optimize context window usage.\n */\nexport class ContentStorage implements ContentReferenceStore {\n private messages: StoredMessage[] = [];\n private maxStorage: number;\n private idCounter: number = 0;\n\n private contentStore: Map<ReferenceId, StoredContent> = new Map();\n private referenceConfig: ContentReferenceConfig;\n private cleanupTimer?: NodeJS.Timeout;\n private referenceStats: Omit<ContentReferenceStats, 'performanceMetrics'> & {\n performanceMetrics: ContentReferenceStats['performanceMetrics'] & {\n creationTimes: number[];\n resolutionTimes: number[];\n cleanupTimes: number[];\n };\n };\n\n public static readonly DEFAULT_MAX_STORAGE = 1000;\n\n constructor(\n maxStorage: number = ContentStorage.DEFAULT_MAX_STORAGE,\n referenceConfig?: Partial<ContentReferenceConfig>\n ) {\n this.maxStorage = maxStorage;\n\n this.referenceConfig = {\n ...DEFAULT_CONTENT_REFERENCE_CONFIG,\n ...referenceConfig,\n };\n this.referenceStats = {\n activeReferences: 0,\n totalStorageBytes: 0,\n recentlyCleanedUp: 0,\n totalResolutions: 0,\n failedResolutions: 0,\n averageContentSize: 0,\n storageUtilization: 0,\n performanceMetrics: {\n averageCreationTimeMs: 0,\n averageResolutionTimeMs: 0,\n averageCleanupTimeMs: 0,\n creationTimes: [],\n resolutionTimes: [],\n cleanupTimes: [],\n },\n };\n\n if (this.referenceConfig.enableAutoCleanup) {\n this.startReferenceCleanupTimer();\n }\n }\n\n /**\n * Store messages in the content storage\n * Automatically drops oldest messages if storage limit is exceeded\n * @param messages - Messages to store\n * @returns Result indicating how many messages were stored and dropped\n */\n storeMessages(messages: BaseMessage[]): StoreResult {\n if (messages.length === 0) {\n return { stored: 0, dropped: 0 };\n }\n\n const now = new Date();\n let dropped = 0;\n\n const storedMessages: StoredMessage[] = messages.map((message) => ({\n message,\n storedAt: now,\n id: this.generateId(),\n }));\n\n this.messages.push(...storedMessages);\n\n while (this.messages.length > this.maxStorage) {\n this.messages.shift();\n dropped++;\n }\n\n return {\n stored: storedMessages.length,\n dropped,\n };\n }\n\n /**\n * Get the most recent messages from storage\n * @param count - Number of recent messages to retrieve\n * @returns Array of recent messages in chronological order\n */\n getRecentMessages(count: number): BaseMessage[] {\n if (count <= 0 || this.messages.length === 0) {\n return [];\n }\n\n const startIndex = Math.max(0, this.messages.length - count);\n return this.messages.slice(startIndex).map((stored) => stored.message);\n }\n\n /**\n * Search for messages containing specific text or patterns\n * @param query - Search term or regex pattern\n * @param options - Search configuration options\n * @returns Array of matching messages\n */\n searchMessages(query: string, options: SearchOptions = {}): BaseMessage[] {\n if (!query || this.messages.length === 0) {\n return [];\n }\n\n const { caseSensitive = false, limit, useRegex = false } = options;\n\n let matches: BaseMessage[] = [];\n\n if (useRegex) {\n try {\n const regex = new RegExp(query, caseSensitive ? 'g' : 'gi');\n matches = this.messages\n .filter((stored) => regex.test(stored.message.content as string))\n .map((stored) => stored.message);\n } catch {\n return [];\n }\n } else {\n const searchTerm = caseSensitive ? query : query.toLowerCase();\n matches = this.messages\n .filter((stored) => {\n const content = stored.message.content as string;\n const searchContent = caseSensitive ? content : content.toLowerCase();\n return searchContent.includes(searchTerm);\n })\n .map((stored) => stored.message);\n }\n\n return limit ? matches.slice(0, limit) : matches;\n }\n\n /**\n * Get messages from a specific time range\n * @param startTime - Start of time range (inclusive)\n * @param endTime - End of time range (inclusive)\n * @returns Array of messages within the time range\n */\n getMessagesFromTimeRange(startTime: Date, endTime: Date): BaseMessage[] {\n if (startTime > endTime || this.messages.length === 0) {\n return [];\n }\n\n return this.messages\n .filter(\n (stored) => stored.storedAt >= startTime && stored.storedAt <= endTime\n )\n .map((stored) => stored.message);\n }\n\n /**\n * Get storage statistics and usage information\n * @returns Current storage statistics\n */\n getStorageStats(): StorageStats {\n const totalMessages = this.messages.length;\n const usagePercentage =\n totalMessages > 0\n ? Math.round((totalMessages / this.maxStorage) * 100)\n : 0;\n\n let oldestMessageTime: Date | undefined;\n let newestMessageTime: Date | undefined;\n\n if (totalMessages > 0) {\n oldestMessageTime = this.messages[0].storedAt;\n newestMessageTime = this.messages[totalMessages - 1].storedAt;\n }\n\n return {\n totalMessages,\n maxStorageLimit: this.maxStorage,\n usagePercentage,\n oldestMessageTime,\n newestMessageTime,\n };\n }\n\n /**\n * Clear all stored messages\n */\n clear(): void {\n this.messages = [];\n this.idCounter = 0;\n }\n\n /**\n * Get total number of stored messages\n * @returns Number of messages currently in storage\n */\n getTotalStoredMessages(): number {\n return this.messages.length;\n }\n\n /**\n * Update the maximum storage limit\n * @param newLimit - New maximum storage limit\n */\n updateStorageLimit(newLimit: number): void {\n if (newLimit <= 0) {\n throw new Error('Storage limit must be greater than 0');\n }\n\n this.maxStorage = newLimit;\n\n while (this.messages.length > this.maxStorage) {\n this.messages.shift();\n }\n }\n\n /**\n * Get messages by message type\n * @param messageType - Type of messages to retrieve ('human', 'ai', 'system', etc.)\n * @param limit - Maximum number of messages to return\n * @returns Array of messages of the specified type\n */\n getMessagesByType(messageType: string, limit?: number): BaseMessage[] {\n const filtered = this.messages\n .filter((stored) => stored.message._getType() === messageType)\n .map((stored) => stored.message);\n\n return limit ? filtered.slice(0, limit) : filtered;\n }\n\n /**\n * Get the current storage configuration\n * @returns Storage configuration object\n */\n getConfig(): {\n maxStorage: number;\n currentUsage: number;\n utilizationPercentage: number;\n } {\n return {\n maxStorage: this.maxStorage,\n currentUsage: this.messages.length,\n utilizationPercentage: (this.messages.length / this.maxStorage) * 100,\n };\n }\n\n /**\n * Generate a unique ID for stored messages\n * @returns Unique string identifier\n */\n private generateId(): string {\n return `msg_${++this.idCounter}_${Date.now()}`;\n }\n\n /**\n * Get messages stored within the last N minutes\n * @param minutes - Number of minutes to look back\n * @returns Array of messages from the last N minutes\n */\n getRecentMessagesByTime(minutes: number): BaseMessage[] {\n if (minutes <= 0 || this.messages.length === 0) {\n return [];\n }\n\n const cutoffTime = new Date(Date.now() - minutes * 60 * 1000);\n\n return this.messages\n .filter((stored) => stored.storedAt >= cutoffTime)\n .map((stored) => stored.message);\n }\n\n /**\n * Export messages to a JSON-serializable format\n * @returns Serializable representation of stored messages\n */\n exportMessages(): Array<{\n content: string;\n type: string;\n storedAt: string;\n id: string;\n }> {\n return this.messages.map((stored) => ({\n content:\n typeof stored.message.content === 'string'\n ? stored.message.content\n : JSON.stringify(stored.message.content),\n type: stored.message._getType(),\n storedAt: stored.storedAt.toISOString(),\n id: stored.id,\n }));\n }\n\n /**\n * Determine if content should be stored as a reference based on size\n */\n shouldUseReference(content: Buffer | string): boolean {\n const size = Buffer.isBuffer(content)\n ? content.length\n : Buffer.byteLength(content, 'utf8');\n return size > this.referenceConfig.sizeThresholdBytes;\n }\n\n /**\n * Store content and return a reference if it exceeds the size threshold\n * Otherwise returns null to indicate direct content should be used\n *\n * Special case: Image files are ALWAYS stored as references regardless of size\n * because they need special handling for inscription tools\n */\n async storeContentIfLarge(\n content: Buffer | string,\n metadata: {\n contentType?: ContentType;\n mimeType?: string;\n source: ContentSource;\n mcpToolName?: string;\n fileName?: string;\n tags?: string[];\n customMetadata?: Record<string, unknown>;\n }\n ): Promise<ContentReference | null> {\n const buffer = Buffer.isBuffer(content)\n ? content\n : Buffer.from(content, 'utf8');\n\n const isImageFile = this.isImageContent(\n metadata.mimeType,\n metadata.fileName\n );\n\n if (!isImageFile && !this.shouldUseReference(buffer)) {\n return null;\n }\n\n const storeMetadata: Omit<\n ContentMetadata,\n 'createdAt' | 'lastAccessedAt' | 'accessCount'\n > = {\n contentType:\n metadata.contentType ||\n this.detectContentType(buffer, metadata.mimeType),\n sizeBytes: buffer.length,\n source: metadata.source,\n tags: [],\n };\n\n if (metadata.mimeType !== undefined) {\n storeMetadata.mimeType = metadata.mimeType;\n }\n if (metadata.mcpToolName !== undefined) {\n storeMetadata.mcpToolName = metadata.mcpToolName;\n }\n if (metadata.fileName !== undefined) {\n storeMetadata.fileName = metadata.fileName;\n }\n if (metadata.tags !== undefined) {\n storeMetadata.tags = metadata.tags;\n }\n if (metadata.customMetadata !== undefined) {\n storeMetadata.customMetadata = metadata.customMetadata;\n }\n\n return await this.storeContent(buffer, storeMetadata);\n }\n\n /**\n * Store content and return a reference (implements ContentReferenceStore)\n */\n async storeContent(\n content: Buffer,\n metadata: Omit<\n ContentMetadata,\n 'createdAt' | 'lastAccessedAt' | 'accessCount'\n >\n ): Promise<ContentReference> {\n const startTime = Date.now();\n\n try {\n const now = new Date();\n const referenceId = ReferenceIdGenerator.generateId(content);\n\n const fullMetadata: ContentMetadata = {\n ...metadata,\n createdAt: now,\n lastAccessedAt: now,\n accessCount: 0,\n };\n\n const storedContent: StoredContent = {\n content,\n metadata: fullMetadata,\n state: 'active',\n };\n\n const expirationTime = this.calculateExpirationTime(metadata.source);\n if (expirationTime !== undefined) {\n storedContent.expiresAt = expirationTime;\n }\n\n this.contentStore.set(referenceId, storedContent);\n\n this.updateStatsAfterStore(content.length);\n\n await this.enforceReferenceStorageLimits();\n\n const preview = this.createContentPreview(\n content,\n fullMetadata.contentType\n );\n\n const referenceMetadata: Pick<\n ContentMetadata,\n 'contentType' | 'sizeBytes' | 'source' | 'fileName' | 'mimeType'\n > = {\n contentType: fullMetadata.contentType,\n sizeBytes: fullMetadata.sizeBytes,\n source: fullMetadata.source,\n };\n\n if (fullMetadata.fileName !== undefined) {\n referenceMetadata.fileName = fullMetadata.fileName;\n }\n if (fullMetadata.mimeType !== undefined) {\n referenceMetadata.mimeType = fullMetadata.mimeType;\n }\n\n const reference: ContentReference = {\n referenceId,\n state: 'active',\n preview,\n metadata: referenceMetadata,\n createdAt: now,\n format: 'ref://{id}' as const,\n };\n\n const duration = Date.now() - startTime;\n this.recordPerformanceMetric('creation', duration);\n\n return reference;\n } catch (error) {\n const duration = Date.now() - startTime;\n this.recordPerformanceMetric('creation', duration);\n\n throw new ContentReferenceError(\n `Failed to store content: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`,\n 'system_error',\n undefined,\n ['Try again', 'Check storage limits', 'Contact administrator']\n );\n }\n }\n\n /**\n * Resolve a reference to its content (implements ContentReferenceStore)\n */\n async resolveReference(\n referenceId: ReferenceId\n ): Promise<ReferenceResolutionResult> {\n const startTime = Date.now();\n\n try {\n if (!ReferenceIdGenerator.isValidReferenceId(referenceId)) {\n this.referenceStats.failedResolutions++;\n return {\n success: false,\n error: 'Invalid reference ID format',\n errorType: 'not_found',\n suggestedActions: [\n 'Check the reference ID format',\n 'Ensure the reference ID is complete',\n ],\n };\n }\n\n const storedContent = this.contentStore.get(referenceId);\n\n if (!storedContent) {\n this.referenceStats.failedResolutions++;\n return {\n success: false,\n error: 'Reference not found',\n errorType: 'not_found',\n suggestedActions: [\n 'Verify the reference ID',\n 'Check if the content has expired',\n 'Request fresh content',\n ],\n };\n }\n\n if (storedContent.expiresAt && storedContent.expiresAt < new Date()) {\n storedContent.state = 'expired';\n this.referenceStats.failedResolutions++;\n return {\n success: false,\n error: 'Reference has expired',\n errorType: 'expired',\n suggestedActions: [\n 'Request fresh content',\n 'Use alternative content source',\n ],\n };\n }\n\n if (storedContent.state !== 'active') {\n this.referenceStats.failedResolutions++;\n return {\n success: false,\n error: `Reference is ${storedContent.state}`,\n errorType:\n storedContent.state === 'expired' ? 'expired' : 'corrupted',\n suggestedActions: [\n 'Request fresh content',\n 'Check reference validity',\n ],\n };\n }\n\n storedContent.metadata.lastAccessedAt = new Date();\n storedContent.metadata.accessCount++;\n\n this.referenceStats.totalResolutions++;\n\n const duration = Date.now() - startTime;\n this.recordPerformanceMetric('resolution', duration);\n\n return {\n success: true,\n content: storedContent.content,\n metadata: storedContent.metadata,\n };\n } catch (error) {\n const duration = Date.now() - startTime;\n this.recordPerformanceMetric('resolution', duration);\n\n this.referenceStats.failedResolutions++;\n\n return {\n success: false,\n error: `System error resolving reference: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`,\n errorType: 'system_error',\n suggestedActions: ['Try again', 'Contact administrator'],\n };\n }\n }\n\n /**\n * Check if a reference exists and is valid\n */\n async hasReference(referenceId: ReferenceId): Promise<boolean> {\n if (!ReferenceIdGenerator.isValidReferenceId(referenceId)) {\n return false;\n }\n\n const storedContent = this.contentStore.get(referenceId);\n if (!storedContent) {\n return false;\n }\n\n if (storedContent.expiresAt && storedContent.expiresAt < new Date()) {\n storedContent.state = 'expired';\n return false;\n }\n\n return storedContent.state === 'active';\n }\n\n /**\n * Mark a reference for cleanup\n */\n async cleanupReference(referenceId: ReferenceId): Promise<boolean> {\n const storedContent = this.contentStore.get(referenceId);\n if (!storedContent) {\n return false;\n }\n\n this.referenceStats.totalStorageBytes -= storedContent.content.length;\n this.referenceStats.activeReferences--;\n this.referenceStats.recentlyCleanedUp++;\n\n this.contentStore.delete(referenceId);\n\n return true;\n }\n\n /**\n * Get current reference storage statistics (implements ContentReferenceStore)\n */\n async getStats(): Promise<ContentReferenceStats> {\n this.updateReferenceStorageStats();\n\n return {\n ...this.referenceStats,\n performanceMetrics: {\n averageCreationTimeMs: this.calculateAverage(\n this.referenceStats.performanceMetrics.creationTimes\n ),\n averageResolutionTimeMs: this.calculateAverage(\n this.referenceStats.performanceMetrics.resolutionTimes\n ),\n averageCleanupTimeMs: this.calculateAverage(\n this.referenceStats.performanceMetrics.cleanupTimes\n ),\n },\n };\n }\n\n /**\n * Update reference configuration\n */\n async updateConfig(config: Partial<ContentReferenceConfig>): Promise<void> {\n this.referenceConfig = { ...this.referenceConfig, ...config };\n\n if (this.cleanupTimer) {\n clearInterval(this.cleanupTimer);\n delete this.cleanupTimer;\n }\n\n if (this.referenceConfig.enableAutoCleanup) {\n this.startReferenceCleanupTimer();\n }\n }\n\n /**\n * Perform cleanup based on current policies (implements ContentReferenceStore)\n */\n async performCleanup(): Promise<{ cleanedUp: number; errors: string[] }> {\n const startTime = Date.now();\n const errors: string[] = [];\n let cleanedUp = 0;\n\n try {\n const now = new Date();\n const toCleanup: ReferenceId[] = [];\n\n for (const [referenceId, storedContent] of this.contentStore.entries()) {\n let shouldCleanup = false;\n\n if (storedContent.expiresAt && storedContent.expiresAt < now) {\n shouldCleanup = true;\n storedContent.state = 'expired';\n }\n\n const ageMs =\n now.getTime() - storedContent.metadata.createdAt.getTime();\n const policy = this.getCleanupPolicy(storedContent.metadata.source);\n\n if (ageMs > policy.maxAgeMs) {\n shouldCleanup = true;\n }\n\n if (storedContent.state === 'cleanup_pending') {\n shouldCleanup = true;\n }\n\n if (shouldCleanup) {\n toCleanup.push(referenceId);\n }\n }\n\n toCleanup.sort((a, b) => {\n const aContent = this.contentStore.get(a)!;\n const bContent = this.contentStore.get(b)!;\n const aPriority = this.getCleanupPolicy(\n aContent.metadata.source\n ).priority;\n const bPriority = this.getCleanupPolicy(\n bContent.metadata.source\n ).priority;\n return bPriority - aPriority;\n });\n\n for (const referenceId of toCleanup) {\n try {\n const success = await this.cleanupReference(referenceId);\n if (success) {\n cleanedUp++;\n }\n } catch (error) {\n errors.push(\n `Failed to cleanup ${referenceId}: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`\n );\n }\n }\n\n if (this.contentStore.size > this.referenceConfig.maxReferences) {\n const sortedByAge = Array.from(this.contentStore.entries()).sort(\n ([, a], [, b]) =>\n a.metadata.lastAccessedAt.getTime() -\n b.metadata.lastAccessedAt.getTime()\n );\n\n const excessCount =\n this.contentStore.size - this.referenceConfig.maxReferences;\n for (let i = 0; i < excessCount && i < sortedByAge.length; i++) {\n const [referenceId] = sortedByAge[i];\n try {\n const success = await this.cleanupReference(referenceId);\n if (success) {\n cleanedUp++;\n }\n } catch (error) {\n errors.push(\n `Failed to cleanup excess reference ${referenceId}: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`\n );\n }\n }\n }\n\n const duration = Date.now() - startTime;\n this.recordPerformanceMetric('cleanup', duration);\n\n return { cleanedUp, errors };\n } catch (error) {\n const duration = Date.now() - startTime;\n this.recordPerformanceMetric('cleanup', duration);\n\n const errorMessage = `Cleanup process failed: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`;\n errors.push(errorMessage);\n\n return { cleanedUp, errors };\n }\n }\n\n /**\n * Get reference configuration for debugging\n */\n getReferenceConfig(): ContentReferenceConfig {\n return { ...this.referenceConfig };\n }\n\n private async enforceReferenceStorageLimits(): Promise<void> {\n if (this.contentStore.size >= this.referenceConfig.maxReferences) {\n await this.performCleanup();\n }\n\n if (\n this.referenceStats.totalStorageBytes >=\n this.referenceConfig.maxTotalStorageBytes\n ) {\n await this.performCleanup();\n }\n }\n\n private calculateExpirationTime(source: ContentSource): Date | undefined {\n const policy = this.getCleanupPolicy(source);\n return new Date(Date.now() + policy.maxAgeMs);\n }\n\n private getCleanupPolicy(source: ContentSource): {\n maxAgeMs: number;\n priority: number;\n } {\n switch (source) {\n case 'mcp_tool':\n return this.referenceConfig.cleanupPolicies.recent;\n case 'user_upload':\n return this.referenceConfig.cleanupPolicies.userContent;\n case 'agent_generated':\n return this.referenceConfig.cleanupPolicies.agentGenerated;\n default:\n return this.referenceConfig.cleanupPolicies.default;\n }\n }\n\n private detectContentType(content: Buffer, mimeType?: string): ContentType {\n if (mimeType) {\n if (mimeType === 'text/html') return 'html';\n if (mimeType === 'text/markdown') return 'markdown';\n if (mimeType === 'application/json') return 'json';\n if (mimeType.startsWith('text/')) return 'text';\n return 'binary';\n }\n\n const contentStr = content.toString(\n 'utf8',\n 0,\n Math.min(content.length, 1000)\n );\n if (contentStr.startsWith('{') || contentStr.startsWith('[')) return 'json';\n if (contentStr.includes('<html>') || contentStr.includes('<!DOCTYPE'))\n return 'html';\n if (contentStr.includes('#') && contentStr.includes('\\n'))\n return 'markdown';\n\n return 'text';\n }\n\n private createContentPreview(\n content: Buffer,\n contentType: ContentType\n ): string {\n const maxLength = 200;\n let preview = content.toString(\n 'utf8',\n 0,\n Math.min(content.length, maxLength * 2)\n );\n\n if (contentType === 'html') {\n preview = preview\n .replace(/<[^>]*>/g, '')\n .replace(/\\s+/g, ' ')\n .trim();\n } else if (contentType === 'json') {\n try {\n const parsed = JSON.parse(preview);\n preview = JSON.stringify(parsed, null, 0);\n } catch {}\n }\n\n preview = preview.trim();\n if (preview.length > maxLength) {\n preview = preview.substring(0, maxLength) + '...';\n }\n\n return preview || '[Binary content]';\n }\n\n private updateStatsAfterStore(sizeBytes: number): void {\n this.referenceStats.activeReferences++;\n this.referenceStats.totalStorageBytes += sizeBytes;\n this.updateReferenceStorageStats();\n }\n\n private updateReferenceStorageStats(): void {\n if (this.referenceStats.activeReferences > 0) {\n this.referenceStats.averageContentSize =\n this.referenceStats.totalStorageBytes /\n this.referenceStats.activeReferences;\n }\n\n this.referenceStats.storageUtilization =\n (this.referenceStats.totalStorageBytes /\n this.referenceConfig.maxTotalStorageBytes) *\n 100;\n\n let mostAccessedId: ReferenceId | undefined;\n let maxAccess = 0;\n\n for (const [referenceId, storedContent] of this.contentStore.entries()) {\n if (storedContent.metadata.accessCount > maxAccess) {\n maxAccess = storedContent.metadata.accessCount;\n mostAccessedId = referenceId;\n }\n }\n\n if (mostAccessedId !== undefined) {\n this.referenceStats.mostAccessedReferenceId = mostAccessedId;\n } else {\n delete this.referenceStats.mostAccessedReferenceId;\n }\n }\n\n /**\n * Check if content is an image file based on MIME type or filename\n */\n private isImageContent(mimeType?: string, fileName?: string): boolean {\n if (mimeType && mimeType.startsWith('image/')) {\n return true;\n }\n\n if (fileName) {\n const lowerFileName = fileName.toLowerCase();\n const imageExtensions = [\n '.png',\n '.jpg',\n '.jpeg',\n '.gif',\n '.bmp',\n '.webp',\n '.svg',\n '.tiff',\n '.ico',\n ];\n return imageExtensions.some((ext) => lowerFileName.endsWith(ext));\n }\n\n return false;\n }\n\n private recordPerformanceMetric(\n type: 'creation' | 'resolution' | 'cleanup',\n timeMs: number\n ): void {\n const metrics = this.referenceStats.performanceMetrics;\n const maxRecords = 100;\n\n switch (type) {\n case 'creation':\n metrics.creationTimes.push(timeMs);\n if (metrics.creationTimes.length > maxRecords) {\n metrics.creationTimes.shift();\n }\n break;\n case 'resolution':\n metrics.resolutionTimes.push(timeMs);\n if (metrics.resolutionTimes.length > maxRecords) {\n metrics.resolutionTimes.shift();\n }\n break;\n case 'cleanup':\n metrics.cleanupTimes.push(timeMs);\n if (metrics.cleanupTimes.length > maxRecords) {\n metrics.cleanupTimes.shift();\n }\n break;\n }\n }\n\n private calculateAverage(times: number[]): number {\n if (times.length === 0) return 0;\n return times.reduce((sum, time) => sum + time, 0) / times.length;\n }\n\n private startReferenceCleanupTimer(): void {\n this.cleanupTimer = setInterval(async () => {\n try {\n await this.performCleanup();\n } catch {}\n }, this.referenceConfig.cleanupIntervalMs);\n }\n\n /**\n * Clean up resources (enhanced to include reference cleanup)\n */\n async dispose(): Promise<void> {\n if (this.cleanupTimer) {\n clearInterval(this.cleanupTimer);\n delete this.cleanupTimer;\n }\n\n this.contentStore.clear();\n\n this.clear();\n }\n}\n"],"names":[],"mappings":";;AAuFO,MAAM,kBAAN,MAAM,gBAAgD;AAAA,EAkB3D,YACE,aAAqB,gBAAe,qBACpC,i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,SAAS,YAAY;AAC7C,kBAAQ,cAAc,MAAA;AAAA,QACxB;AACA;AAAA,MACF,KAAK;AACH,gBAAQ,gBAAgB,KAAK,MAAM;AACnC,YAAI,QAAQ,gBAAgB,SAAS,YAAY;AAC/C,kBAAQ,gBAAgB,MAAA;AAAA,QAC1B;AACA;AAAA,MACF,KAAK;AACH,gBAAQ,aAAa,KAAK,MAAM;AAChC,YAAI,QAAQ,aAAa,SAAS,YAAY;AAC5C,kBAAQ,aAAa,MAAA;AAAA,QACvB;AACA;AAAA,IAAA;AAAA,EAEN;AAAA,EAEQ,iBAAiB,OAAyB;AAChD,QAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,WAAO,MAAM,OAAO,CAAC,KAAK,SAAS,MAAM,MAAM,CAAC,IAAI,MAAM;AAAA,EAC5D;AAAA,EAEQ,6BAAmC;AACzC,SAAK,eAAe,YAAY,YAAY;AAC1C,UAAI;AACF,cAAM,KAAK,eAAA;AAAA,MACb,QAAQ;AAAA,MAAC;AAAA,IACX,GAAG,KAAK,gBAAgB,iBAAiB;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,UAAyB;AAC7B,QAAI,KAAK,cAAc;AACrB,oBAAc,KAAK,YAAY;AAC/B,aAAO,KAAK;AAAA,IACd;AAEA,SAAK,aAAa,MAAA;AAElB,SAAK,MAAA;AAAA,EACP;AACF;AAh6BE,gBAAuB,sBAAsB;AAhBxC,IAAM,iBAAN;"}
@@ -1,6 +1,6 @@
1
1
  import { ChatOpenAI } from "@langchain/openai";
2
2
  import { Logger } from "@hashgraphonline/standards-sdk";
3
- import { ENTITY_PATTERNS } from "./index41.js";
3
+ import { ENTITY_PATTERNS } from "./index42.js";
4
4
  import "hedera-agent-kit";
5
5
  import "@hashgraphonline/standards-agent-kit";
6
6
  import "./index13.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index24.js","sources":["../../src/services/content-store-manager.ts"],"sourcesContent":["import { ContentStorage } from '../memory/content-storage';\nimport {\n ContentStoreService,\n extractReferenceId,\n shouldUseReference,\n ContentResolverRegistry,\n type ContentStoreInterface,\n type ContentResolverInterface,\n type ReferenceResolutionResult,\n} from '@hashgraphonline/standards-sdk';\nimport type {\n ContentReference,\n ContentReferenceConfig,\n ContentReferenceStats,\n} from '../types/content-reference';\nimport { Logger } from '@hashgraphonline/standards-sdk';\n\n/**\n * Content metadata interface for adapter compatibility\n */\ninterface AdapterContentMetadata {\n mimeType?: string;\n fileName?: string;\n sizeBytes?: number;\n [key: string]: unknown;\n}\n\n/**\n * Configuration interface for content storage\n */\ninterface ContentStoreConfig {\n maxSize?: number;\n enableCompression?: boolean;\n [key: string]: unknown;\n}\n\n/**\n * Adapter to make ContentStorage compatible with ContentStoreInterface\n */\nclass ContentStorageAdapter implements ContentStoreInterface {\n constructor(private storage: ContentStorage) {}\n\n async storeContent(\n content: Buffer,\n metadata: AdapterContentMetadata\n ): Promise<string> {\n const storeMetadata = {\n contentType: 'binary' as const,\n sizeBytes: content.length,\n source: 'system' as const,\n ...metadata,\n };\n const contentRef = await this.storage.storeContent(content, storeMetadata);\n return contentRef.referenceId;\n }\n\n async resolveReference(\n referenceId: string\n ): Promise<ReferenceResolutionResult> {\n const result = await this.storage.resolveReference(referenceId);\n if (result.success && result.content) {\n const response: ReferenceResolutionResult = {\n content: result.content,\n };\n if (result.metadata) {\n response.metadata = {\n ...(result.metadata.mimeType !== undefined && {\n mimeType: result.metadata.mimeType,\n }),\n ...(result.metadata.fileName !== undefined && {\n fileName: result.metadata.fileName,\n }),\n originalSize: result.metadata.sizeBytes,\n };\n }\n return response;\n } else {\n throw new Error(result.error || 'Reference not found');\n }\n }\n\n async hasReference(referenceId: string): Promise<boolean> {\n return await this.storage.hasReference(referenceId);\n }\n\n async cleanupReference(referenceId: string): Promise<void> {\n await this.storage.cleanupReference(referenceId);\n }\n\n async getStats(): Promise<unknown> {\n return await this.storage.getStats();\n }\n\n async updateConfig(config: ContentStoreConfig): Promise<void> {\n const referenceConfig = {\n sizeThresholdBytes: config.maxSize || 10240,\n enableAutoCleanup: config.enableCompression || true,\n ...config,\n };\n return await this.storage.updateConfig(referenceConfig);\n }\n\n async performCleanup(): Promise<void> {\n await this.storage.performCleanup();\n }\n\n async dispose(): Promise<void> {\n return Promise.resolve(this.storage.dispose());\n }\n}\n\n/**\n * Content resolver implementation for dependency injection\n */\nclass ContentResolver implements ContentResolverInterface {\n constructor(private adapter: ContentStorageAdapter) {}\n\n async resolveReference(\n referenceId: string\n ): Promise<ReferenceResolutionResult> {\n return await this.adapter.resolveReference(referenceId);\n }\n\n shouldUseReference(content: string | Buffer): boolean {\n return shouldUseReference(content);\n }\n\n extractReferenceId(input: string): string | null {\n return extractReferenceId(input);\n }\n}\n\n/**\n * Manages content store lifecycle and cross-package registration\n */\nexport class ContentStoreManager {\n private contentStorage: ContentStorage;\n private adapter: ContentStorageAdapter;\n private resolver: ContentResolver;\n private logger: Logger;\n private isRegistered = false;\n\n constructor(\n maxMessageStorage: number = 1000,\n referenceConfig?: Partial<ContentReferenceConfig>,\n logger?: Logger\n ) {\n this.logger = logger || new Logger({ module: 'ContentStoreManager' });\n\n this.contentStorage = new ContentStorage(\n maxMessageStorage,\n referenceConfig\n );\n this.adapter = new ContentStorageAdapter(this.contentStorage);\n this.resolver = new ContentResolver(this.adapter);\n }\n\n /**\n * Initialize and register content storage for cross-package access\n */\n async initialize(): Promise<void> {\n if (this.isRegistered) {\n this.logger.warn('ContentStoreManager is already initialized');\n return;\n }\n\n try {\n if (\n ContentStoreService &&\n typeof (ContentStoreService as unknown as { setInstance?: Function }).setInstance === 'function'\n ) {\n await (ContentStoreService as unknown as { setInstance: (adapter: unknown) => Promise<void> }).setInstance(\n this.adapter\n );\n } else {\n this.logger.warn('ContentStoreService.setInstance is unavailable; skipping registration');\n }\n if (\n ContentResolverRegistry &&\n typeof (ContentResolverRegistry as unknown as { register?: Function }).register === 'function'\n ) {\n (ContentResolverRegistry as unknown as { register: (resolver: unknown) => void }).register(\n this.resolver\n );\n } else {\n this.logger.warn('ContentResolverRegistry.register is unavailable; skipping registration');\n }\n this.isRegistered = true;\n this.logger.info(\n 'ContentStoreManager initialized and registered for cross-package access'\n );\n } catch (error) {\n this.logger.error('Failed to initialize ContentStoreManager:', error);\n throw error;\n }\n }\n\n /**\n * Get the underlying ContentStorage instance\n */\n getContentStorage(): ContentStorage {\n return this.contentStorage;\n }\n\n /**\n * Get storage statistics\n */\n async getStats(): Promise<ContentReferenceStats> {\n return await this.contentStorage.getStats();\n }\n\n /**\n * Update configuration\n */\n async updateConfig(config: Partial<ContentReferenceConfig>): Promise<void> {\n return await this.contentStorage.updateConfig(config);\n }\n\n /**\n * Perform manual cleanup\n */\n async performCleanup(): Promise<{ cleanedUp: number; errors: string[] }> {\n return await this.contentStorage.performCleanup();\n }\n\n /**\n * Check if content should be stored as reference\n */\n shouldUseReference(content: Buffer | string): boolean {\n return this.contentStorage.shouldUseReference(content);\n }\n\n /**\n * Store content if it's large enough\n */\n async storeContentIfLarge(\n content: Buffer | string,\n metadata: AdapterContentMetadata\n ): Promise<ContentReference | null> {\n const storeMetadata = {\n source: 'system' as const,\n contentType: 'binary' as const,\n ...metadata,\n };\n return await this.contentStorage.storeContentIfLarge(\n content,\n storeMetadata\n );\n }\n\n /**\n * Cleanup and unregister\n */\n async dispose(): Promise<void> {\n if (this.isRegistered) {\n this.contentStorage.dispose();\n if (\n ContentStoreService &&\n typeof (ContentStoreService as unknown as { dispose?: Function }).dispose === 'function'\n ) {\n (ContentStoreService as unknown as { dispose: () => void }).dispose();\n }\n if (\n ContentResolverRegistry &&\n typeof (ContentResolverRegistry as unknown as { unregister?: Function }).unregister === 'function'\n ) {\n (ContentResolverRegistry as unknown as { unregister: () => void }).unregister();\n }\n this.isRegistered = false;\n this.logger.info('ContentStoreManager disposed and unregistered');\n }\n }\n\n /**\n * Check if the manager is initialized\n */\n isInitialized(): boolean {\n return this.isRegistered;\n }\n}\n"],"names":[],"mappings":";;AAuCA,MAAM,sBAAuD;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;AAAA,EACd;AACF;"}
1
+ {"version":3,"file":"index24.js","sources":["../../src/services/content-store-manager.ts"],"sourcesContent":["import { ContentStorage } from '../memory/content-storage';\nimport {\n ContentStoreService,\n extractReferenceId,\n shouldUseReference,\n ContentResolverRegistry,\n type ContentStoreInterface,\n type ContentResolverInterface,\n type ReferenceResolutionResult,\n} from '@hashgraphonline/standards-sdk';\nimport type {\n ContentReference,\n ContentReferenceConfig,\n ContentReferenceStats,\n} from '../types/content-reference';\nimport { Logger } from '@hashgraphonline/standards-sdk';\n\n/**\n * Content metadata interface for adapter compatibility\n */\ninterface AdapterContentMetadata {\n mimeType?: string;\n fileName?: string;\n sizeBytes?: number;\n [key: string]: unknown;\n}\n\n/**\n * Configuration interface for content storage\n */\ninterface ContentStoreConfig {\n maxSize?: number;\n enableCompression?: boolean;\n [key: string]: unknown;\n}\n\n/**\n * Adapter to make ContentStorage compatible with ContentStoreInterface\n */\nclass ContentStorageAdapter implements ContentStoreInterface {\n constructor(private storage: ContentStorage) {}\n\n async storeContent(\n content: Buffer,\n metadata: AdapterContentMetadata\n ): Promise<string> {\n const storeMetadata = {\n contentType: 'binary' as const,\n sizeBytes: content.length,\n source: 'system' as const,\n ...metadata,\n };\n const contentRef = await this.storage.storeContent(content, storeMetadata);\n return contentRef.referenceId;\n }\n\n async resolveReference(\n referenceId: string\n ): Promise<ReferenceResolutionResult> {\n const result = await this.storage.resolveReference(referenceId);\n if (result.success && result.content) {\n const response: ReferenceResolutionResult = {\n content: result.content,\n };\n if (result.metadata) {\n response.metadata = {\n ...(result.metadata.mimeType !== undefined && {\n mimeType: result.metadata.mimeType,\n }),\n ...(result.metadata.fileName !== undefined && {\n fileName: result.metadata.fileName,\n }),\n originalSize: result.metadata.sizeBytes,\n };\n }\n return response;\n } else {\n throw new Error(result.error || 'Reference not found');\n }\n }\n\n async hasReference(referenceId: string): Promise<boolean> {\n return await this.storage.hasReference(referenceId);\n }\n\n async cleanupReference(referenceId: string): Promise<void> {\n await this.storage.cleanupReference(referenceId);\n }\n\n async getStats(): Promise<unknown> {\n return await this.storage.getStats();\n }\n\n async updateConfig(config: ContentStoreConfig): Promise<void> {\n const referenceConfig = {\n sizeThresholdBytes: config.maxSize || 10240,\n enableAutoCleanup: config.enableCompression || true,\n ...config,\n };\n return await this.storage.updateConfig(referenceConfig);\n }\n\n async performCleanup(): Promise<void> {\n await this.storage.performCleanup();\n }\n\n async dispose(): Promise<void> {\n return Promise.resolve(this.storage.dispose());\n }\n}\n\n/**\n * Content resolver implementation for dependency injection\n */\nclass ContentResolver implements ContentResolverInterface {\n constructor(private adapter: ContentStorageAdapter) {}\n\n async resolveReference(\n referenceId: string\n ): Promise<ReferenceResolutionResult> {\n return await this.adapter.resolveReference(referenceId);\n }\n\n shouldUseReference(content: string | Buffer): boolean {\n return shouldUseReference(content);\n }\n\n extractReferenceId(input: string): string | null {\n return extractReferenceId(input);\n }\n}\n\n/**\n * Manages content store lifecycle and cross-package registration\n */\nexport class ContentStoreManager {\n private contentStorage: ContentStorage;\n private adapter: ContentStorageAdapter;\n private resolver: ContentResolver;\n private logger: Logger;\n protected isRegistered = false;\n\n constructor(\n maxMessageStorage: number = 1000,\n referenceConfig?: Partial<ContentReferenceConfig>,\n logger?: Logger\n ) {\n this.logger = logger || new Logger({ module: 'ContentStoreManager' });\n\n this.contentStorage = new ContentStorage(\n maxMessageStorage,\n referenceConfig\n );\n this.adapter = new ContentStorageAdapter(this.contentStorage);\n this.resolver = new ContentResolver(this.adapter);\n }\n\n /**\n * Initialize and register content storage for cross-package access\n */\n async initialize(): Promise<void> {\n if (this.isRegistered) {\n this.logger.warn('ContentStoreManager is already initialized');\n return;\n }\n\n try {\n if (\n ContentStoreService &&\n typeof (ContentStoreService as unknown as { setInstance?: Function }).setInstance === 'function'\n ) {\n await (ContentStoreService as unknown as { setInstance: (adapter: unknown) => Promise<void> }).setInstance(\n this.adapter\n );\n } else {\n this.logger.warn('ContentStoreService.setInstance is unavailable; skipping registration');\n }\n if (\n ContentResolverRegistry &&\n typeof (ContentResolverRegistry as unknown as { register?: Function }).register === 'function'\n ) {\n (ContentResolverRegistry as unknown as { register: (resolver: unknown) => void }).register(\n this.resolver\n );\n } else {\n this.logger.warn('ContentResolverRegistry.register is unavailable; skipping registration');\n }\n this.isRegistered = true;\n this.logger.info(\n 'ContentStoreManager initialized and registered for cross-package access'\n );\n } catch (error) {\n this.logger.error('Failed to initialize ContentStoreManager:', error);\n throw error;\n }\n }\n\n /**\n * Get the underlying ContentStorage instance\n */\n getContentStorage(): ContentStorage {\n return this.contentStorage;\n }\n\n /**\n * Get storage statistics\n */\n async getStats(): Promise<ContentReferenceStats> {\n return await this.contentStorage.getStats();\n }\n\n /**\n * Update configuration\n */\n async updateConfig(config: Partial<ContentReferenceConfig>): Promise<void> {\n return await this.contentStorage.updateConfig(config);\n }\n\n /**\n * Perform manual cleanup\n */\n async performCleanup(): Promise<{ cleanedUp: number; errors: string[] }> {\n return await this.contentStorage.performCleanup();\n }\n\n /**\n * Check if content should be stored as reference\n */\n shouldUseReference(content: Buffer | string): boolean {\n return this.contentStorage.shouldUseReference(content);\n }\n\n /**\n * Store content if it's large enough\n */\n async storeContentIfLarge(\n content: Buffer | string,\n metadata: AdapterContentMetadata\n ): Promise<ContentReference | null> {\n const storeMetadata = {\n source: 'system' as const,\n contentType: 'binary' as const,\n ...metadata,\n };\n return await this.contentStorage.storeContentIfLarge(\n content,\n storeMetadata\n );\n }\n\n /**\n * Cleanup and unregister\n */\n async dispose(): Promise<void> {\n if (this.isRegistered) {\n this.contentStorage.dispose();\n if (\n ContentStoreService &&\n typeof (ContentStoreService as unknown as { dispose?: Function }).dispose === 'function'\n ) {\n (ContentStoreService as unknown as { dispose: () => void }).dispose();\n }\n if (\n ContentResolverRegistry &&\n typeof (ContentResolverRegistry as unknown as { unregister?: Function }).unregister === 'function'\n ) {\n (ContentResolverRegistry as unknown as { unregister: () => void }).unregister();\n }\n this.isRegistered = false;\n this.logger.info('ContentStoreManager disposed and unregistered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AACpB,WAAK,OAAO,KAAK,+CAA+C;AAAA,IAClE;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,gBAAyB;AACvB,WAAO,KAAK;AAAA,EACd;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index26.js","sources":["../../src/services/formatters/types.ts"],"sourcesContent":["export enum EntityFormat {\n TOPIC_ID = 'topicId',\n HRL = 'hrl',\n SCHEDULE_ID = 'scheduleId',\n TOKEN_ID = 'tokenId',\n ADDRESS = 'address',\n SYMBOL = 'symbol',\n SERIAL_NUMBER = 'serialNumber',\n METADATA = 'metadata',\n ACCOUNT_ID = 'accountId',\n ALIAS = 'alias',\n EVM_ADDRESS = 'evmAddress',\n CONTRACT_ID = 'contractId',\n FILE_ID = 'fileId',\n ANY = 'any'\n}\n\nexport interface ConversionContext {\n networkType?: string;\n sessionId?: string;\n toolName?: string;\n toolPreferences?: Record<string, string>;\n [key: string]: unknown;\n}\n\nexport interface FormatConverter<TSource = string, TTarget = string> {\n sourceFormat: EntityFormat;\n targetFormat: EntityFormat;\n canConvert(source: string, context: ConversionContext): boolean;\n convert(entity: TSource, context: ConversionContext): Promise<TTarget>;\n}"],"names":["EntityFormat"],"mappings":"AAAO,IAAK,iCAAAA,kBAAL;AACLA,gBAAA,UAAA,IAAW;AACXA,gBAAA,KAAA,IAAM;AACNA,gBAAA,aAAA,IAAc;AACdA,gBAAA,UAAA,IAAW;AACXA,gBAAA,SAAA,IAAU;AACVA,gBAAA,QAAA,IAAS;AACTA,gBAAA,eAAA,IAAgB;AAChBA,gBAAA,UAAA,IAAW;AACXA,gBAAA,YAAA,IAAa;AACbA,gBAAA,OAAA,IAAQ;AACRA,gBAAA,aAAA,IAAc;AACdA,gBAAA,aAAA,IAAc;AACdA,gBAAA,SAAA,IAAU;AACVA,gBAAA,KAAA,IAAM;AAdI,SAAAA;AAAA,GAAA,gBAAA,CAAA,CAAA;"}
1
+ {"version":3,"file":"index26.js","sources":["../../src/services/formatters/types.ts"],"sourcesContent":["import { NetworkType } from '@hashgraphonline/standards-sdk';\n\nexport enum EntityFormat {\n TOPIC_ID = 'topicId',\n HRL = 'hrl',\n SCHEDULE_ID = 'scheduleId',\n TOKEN_ID = 'tokenId',\n ADDRESS = 'address',\n SYMBOL = 'symbol',\n SERIAL_NUMBER = 'serialNumber',\n METADATA = 'metadata',\n ACCOUNT_ID = 'accountId',\n ALIAS = 'alias',\n EVM_ADDRESS = 'evmAddress',\n CONTRACT_ID = 'contractId',\n FILE_ID = 'fileId',\n ANY = 'any'\n}\n\nexport interface ConversionContext {\n networkType?: NetworkType;\n sessionId?: string;\n toolName?: string;\n toolPreferences?: Record<string, string>;\n [key: string]: unknown;\n}\n\nexport interface FormatConverter<TSource = string, TTarget = string> {\n sourceFormat: EntityFormat;\n targetFormat: EntityFormat;\n canConvert(source: string, context: ConversionContext): boolean;\n convert(entity: TSource, context: ConversionContext): Promise<TTarget>;\n}"],"names":["EntityFormat"],"mappings":"AAEO,IAAK,iCAAAA,kBAAL;AACLA,gBAAA,UAAA,IAAW;AACXA,gBAAA,KAAA,IAAM;AACNA,gBAAA,aAAA,IAAc;AACdA,gBAAA,UAAA,IAAW;AACXA,gBAAA,SAAA,IAAU;AACVA,gBAAA,QAAA,IAAS;AACTA,gBAAA,eAAA,IAAgB;AAChBA,gBAAA,UAAA,IAAW;AACXA,gBAAA,YAAA,IAAa;AACbA,gBAAA,OAAA,IAAQ;AACRA,gBAAA,aAAA,IAAc;AACdA,gBAAA,aAAA,IAAc;AACdA,gBAAA,SAAA,IAAU;AACVA,gBAAA,KAAA,IAAM;AAdI,SAAAA;AAAA,GAAA,gBAAA,CAAA,CAAA;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index3.js","sources":["../../src/plugins/hcs-2/HCS2Plugin.ts"],"sourcesContent":["import {\n GenericPluginContext,\n HederaTool,\n BasePlugin,\n HederaAgentKit,\n} from 'hedera-agent-kit';\nimport {\n HCS2Builder,\n CreateRegistryTool,\n RegisterEntryTool,\n UpdateEntryTool,\n DeleteEntryTool,\n MigrateRegistryTool,\n QueryRegistryTool,\n} from '@hashgraphonline/standards-agent-kit';\n\n/**\n * Plugin providing HCS-2 registry management tools\n */\nexport class HCS2Plugin extends BasePlugin {\n id = 'hcs-2';\n name = 'HCS-2 Plugin';\n description =\n 'HCS-2 registry management tools for decentralized registries on Hedera';\n version = '1.0.0';\n author = 'Hashgraph Online';\n namespace = 'hcs2';\n\n private tools: any[] = [];\n\n override async initialize(context: GenericPluginContext): Promise<void> {\n await super.initialize(context);\n\n const hederaKit = context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n this.context.logger.warn(\n 'HederaKit not found in context. HCS-2 tools will not be available.'\n );\n return;\n }\n\n try {\n // Always initialize HCS-2 tools, even in bytes mode. Some tools may execute directly when\n // returnBytes/provideBytes is active, which is acceptable.\n this.initializeTools();\n\n this.context.logger.info(\n 'HCS-2 Plugin initialized successfully'\n );\n } catch (error) {\n this.context.logger.error(\n 'Failed to initialize HCS-2 plugin:',\n error\n );\n }\n }\n\n private initializeTools(): void {\n const hederaKit = this.context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n throw new Error('HederaKit not found in context config');\n }\n\n const hcs2Builder = new HCS2Builder(hederaKit);\n\n this.tools = [\n new CreateRegistryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n new RegisterEntryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n new UpdateEntryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n new DeleteEntryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n new MigrateRegistryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n new QueryRegistryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n ];\n }\n\n getTools(): HederaTool[] {\n return this.tools;\n }\n\n override async cleanup(): Promise<void> {\n this.tools = [];\n if (this.context?.logger) {\n this.context.logger.info('HCS-2 Plugin cleaned up');\n }\n }\n}\n"],"names":[],"mappings":";;AAmBO,MAAM,mBAAmB,WAAW;AAAA,EAApC,cAAA;AAAA,UAAA,GAAA,SAAA;AACL,SAAA,KAAK;AACL,SAAA,OAAO;AACP,SAAA,cACE;AACF,SAAA,UAAU;AACV,SAAA,SAAS;AACT,SAAA,YAAY;AAEZ,SAAQ,QAAe,CAAA;AAAA,EAAC;AAAA,EAExB,MAAe,WAAW,SAA8C;AACtE,UAAM,MAAM,WAAW,OAAO;AAE9B,UAAM,YAAY,QAAQ,OAAO;AACjC,QAAI,CAAC,WAAW;AACd,WAAK,QAAQ,OAAO;AAAA,QAClB;AAAA,MAAA;AAEF;AAAA,IACF;AAEA,QAAI;AAGF,WAAK,gBAAA;AAEL,WAAK,QAAQ,OAAO;AAAA,QAClB;AAAA,MAAA;AAAA,IAEJ,SAAS,OAAO;AACd,WAAK,QAAQ,OAAO;AAAA,QAClB;AAAA,QACA;AAAA,MAAA;AAAA,IAEJ;AAAA,EACF;AAAA,EAEQ,kBAAwB;AAC9B,UAAM,YAAY,KAAK,QAAQ,OAAO;AACtC,QAAI,CAAC,WAAW;AACd,YAAM,IAAI,MAAM,uCAAuC;AAAA,IACzD;AAEA,UAAM,cAAc,IAAI,YAAY,SAAS;AAE7C,SAAK,QAAQ;AAAA,MACX,IAAI,mBAAmB;AAAA,QACrB;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,kBAAkB;AAAA,QACpB;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,gBAAgB;AAAA,QAClB;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,gBAAgB;AAAA,QAClB;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,oBAAoB;AAAA,QACtB;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,kBAAkB;AAAA,QACpB;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,IAAA;AAAA,EAEL;AAAA,EAEA,WAAyB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAe,UAAyB;AACtC,SAAK,QAAQ,CAAA;AACb,QAAI,KAAK,SAAS,QAAQ;AACxB,WAAK,QAAQ,OAAO,KAAK,yBAAyB;AAAA,IACpD;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"index3.js","sources":["../../src/plugins/hcs-2/HCS2Plugin.ts"],"sourcesContent":["import {\n GenericPluginContext,\n HederaTool,\n BasePlugin,\n HederaAgentKit,\n} from 'hedera-agent-kit';\nimport {\n HCS2Builder,\n CreateRegistryTool,\n RegisterEntryTool,\n UpdateEntryTool,\n DeleteEntryTool,\n MigrateRegistryTool,\n QueryRegistryTool,\n} from '@hashgraphonline/standards-agent-kit';\n\n/**\n * Plugin providing HCS-2 registry management tools\n */\nexport class HCS2Plugin extends BasePlugin {\n id = 'hcs-2';\n name = 'HCS-2 Plugin';\n description =\n 'HCS-2 registry management tools for decentralized registries on Hedera';\n version = '1.0.0';\n author = 'Hashgraph Online';\n namespace = 'hcs2';\n\n private tools: any[] = [];\n\n override async initialize(context: GenericPluginContext): Promise<void> {\n await super.initialize(context);\n\n const hederaKit = context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n this.context.logger.warn(\n 'HederaKit not found in context. HCS-2 tools will not be available.'\n );\n return;\n }\n\n try {\n this.initializeTools();\n\n this.context.logger.info(\n 'HCS-2 Plugin initialized successfully'\n );\n } catch (error) {\n this.context.logger.error(\n 'Failed to initialize HCS-2 plugin:',\n error\n );\n }\n }\n\n private initializeTools(): void {\n const hederaKit = this.context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n throw new Error('HederaKit not found in context config');\n }\n\n const hcs2Builder = new HCS2Builder(hederaKit);\n\n this.tools = [\n new CreateRegistryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n new RegisterEntryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n new UpdateEntryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n new DeleteEntryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n new MigrateRegistryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n new QueryRegistryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n ];\n }\n\n getTools(): HederaTool[] {\n return this.tools;\n }\n\n override async cleanup(): Promise<void> {\n this.tools = [];\n if (this.context?.logger) {\n this.context.logger.info('HCS-2 Plugin cleaned up');\n }\n }\n}\n"],"names":[],"mappings":";;AAmBO,MAAM,mBAAmB,WAAW;AAAA,EAApC,cAAA;AAAA,UAAA,GAAA,SAAA;AACL,SAAA,KAAK;AACL,SAAA,OAAO;AACP,SAAA,cACE;AACF,SAAA,UAAU;AACV,SAAA,SAAS;AACT,SAAA,YAAY;AAEZ,SAAQ,QAAe,CAAA;AAAA,EAAC;AAAA,EAExB,MAAe,WAAW,SAA8C;AACtE,UAAM,MAAM,WAAW,OAAO;AAE9B,UAAM,YAAY,QAAQ,OAAO;AACjC,QAAI,CAAC,WAAW;AACd,WAAK,QAAQ,OAAO;AAAA,QAClB;AAAA,MAAA;AAEF;AAAA,IACF;AAEA,QAAI;AACF,WAAK,gBAAA;AAEL,WAAK,QAAQ,OAAO;AAAA,QAClB;AAAA,MAAA;AAAA,IAEJ,SAAS,OAAO;AACd,WAAK,QAAQ,OAAO;AAAA,QAClB;AAAA,QACA;AAAA,MAAA;AAAA,IAEJ;AAAA,EACF;AAAA,EAEQ,kBAAwB;AAC9B,UAAM,YAAY,KAAK,QAAQ,OAAO;AACtC,QAAI,CAAC,WAAW;AACd,YAAM,IAAI,MAAM,uCAAuC;AAAA,IACzD;AAEA,UAAM,cAAc,IAAI,YAAY,SAAS;AAE7C,SAAK,QAAQ;AAAA,MACX,IAAI,mBAAmB;AAAA,QACrB;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,kBAAkB;AAAA,QACpB;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,gBAAgB;AAAA,QAClB;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,gBAAgB;AAAA,QAClB;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,oBAAoB;AAAA,QACtB;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,kBAAkB;AAAA,QACpB;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,IAAA;AAAA,EAEL;AAAA,EAEA,WAAyB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAe,UAAyB;AACtC,SAAK,QAAQ,CAAA;AACb,QAAI,KAAK,SAAS,QAAQ;AACxB,WAAK,QAAQ,OAAO,KAAK,yBAAyB;AAAA,IACpD;AAAA,EACF;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index30.js","sources":["../../src/services/attachment-processor.ts"],"sourcesContent":["import { Logger } from '@hashgraphonline/standards-sdk';\nimport type { ContentStoreManager as PackageContentStoreManager } from './content-store-manager';\n\nexport interface AttachmentData {\n name: string;\n data: string;\n type: string;\n size: number;\n}\n\ntype ContentStoreManager = PackageContentStoreManager;\n\n/**\n * Utility for processing file attachments and content references\n */\nexport class AttachmentProcessor {\n private logger: Logger;\n\n constructor() {\n this.logger = new Logger({ module: 'AttachmentProcessor' });\n }\n\n /**\n * Process attachments and create content references\n */\n async processAttachments(\n content: string,\n attachments: AttachmentData[],\n contentStoreManager?: ContentStoreManager\n ): Promise<string> {\n if (attachments.length === 0) {\n return content;\n }\n\n this.logger.info('Processing attachments with content reference system:', {\n attachmentCount: attachments.length,\n totalSize: attachments.reduce((sum, att) => sum + att.size, 0),\n });\n\n if (contentStoreManager && contentStoreManager.isInitialized()) {\n return this.processWithContentStore(content, attachments, contentStoreManager);\n } else {\n this.logger.warn('Content storage not available, creating simple file references');\n return this.processWithSimpleReferences(content, attachments);\n }\n }\n\n /**\n * Process attachments using content store manager\n */\n private async processWithContentStore(\n content: string,\n attachments: AttachmentData[],\n contentStoreManager: ContentStoreManager\n ): Promise<string> {\n const contentReferences: string[] = [];\n\n for (const attachment of attachments) {\n try {\n const base64Data = attachment.data.includes('base64,')\n ? attachment.data.split('base64,')[1]\n : attachment.data;\n const buffer = Buffer.from(base64Data, 'base64');\n\n const contentRef = await contentStoreManager.storeContentIfLarge(\n buffer,\n {\n mimeType: attachment.type,\n source: 'user_upload',\n fileName: attachment.name,\n tags: ['attachment', 'user_file'],\n }\n );\n\n if (contentRef) {\n if (attachment.type.startsWith('image/')) {\n contentReferences.push(\n `[Image File: ${attachment.name}] (content-ref:${contentRef.referenceId})`\n );\n } else {\n contentReferences.push(\n `[File: ${attachment.name}] (content-ref:${contentRef.referenceId})`\n );\n }\n } else {\n contentReferences.push(\n this.createInlineReference(attachment, base64Data)\n );\n }\n } catch (error) {\n this.logger.error('Failed to process attachment:', {\n fileName: attachment.name,\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n contentReferences.push(\n `[File: ${attachment.name} - Error processing file: ${\n error instanceof Error ? error.message : 'Unknown error'\n }]`\n );\n }\n }\n\n const fileList = this.createFileList(attachments);\n return content\n ? `${content}\\n\\nAttached files:\\n${fileList}\\n\\n${contentReferences.join('\\n')}`\n : `Attached files:\\n${fileList}\\n\\n${contentReferences.join('\\n')}`;\n }\n\n /**\n * Process attachments with simple file references\n */\n private processWithSimpleReferences(content: string, attachments: AttachmentData[]): string {\n const fileReferences = attachments.map((attachment) => {\n const sizeStr = this.formatFileSize(attachment.size);\n\n if (attachment.type.startsWith('image/')) {\n return `📎 Image: ${attachment.name} (${sizeStr}, ${attachment.type})`;\n } else {\n return `📎 File: ${attachment.name} (${sizeStr}, ${attachment.type})`;\n }\n });\n\n return content\n ? `${content}\\n\\nAttached files:\\n${fileReferences.join('\\n')}`\n : `Attached files:\\n${fileReferences.join('\\n')}`;\n }\n\n /**\n * Create inline reference for small files\n */\n private createInlineReference(attachment: AttachmentData, base64Data: string): string {\n if (attachment.size < 50000) {\n if (attachment.type.startsWith('image/')) {\n return `![${attachment.name}](data:${attachment.type};base64,${base64Data})`;\n } else {\n return `[File: ${attachment.name} (${this.formatFileSize(attachment.size)})]\\nContent: ${base64Data}`;\n }\n } else {\n return `[File: ${attachment.name} (${this.formatFileSize(attachment.size)}) - Content too large to include inline]`;\n }\n }\n\n /**\n * Create formatted file list\n */\n private createFileList(attachments: AttachmentData[]): string {\n return attachments\n .map((file) => {\n const sizeStr = this.formatFileSize(file.size);\n return `📎 ${file.name} (${sizeStr})`;\n })\n .join('\\n');\n }\n\n /**\n * Format file size for display\n */\n private formatFileSize(size: number): string {\n return size >= 1024 * 1024\n ? `${(size / (1024 * 1024)).toFixed(1)}MB`\n : `${(size / 1024).toFixed(1)}KB`;\n }\n}\n"],"names":[],"mappings":";AAeO,MAAM,oBAAoB;AAAA,EAG/B,cAAc;AACZ,SAAK,SAAS,IAAI,OAAO,EAAE,QAAQ,uBAAuB;AAAA,EAC5D;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,mBACJ,SACA,aACA,qBACi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MACrG;AAAA,IACF,OAAO;AACL,aAAO,UAAU,WAAW,IAAI,KAAK,KAAK,eAAe,WAAW,IAAI,CAAC;AAAA,IAC3E;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKQ,eAAe,aAAuC;AAC5D,WAAO,YACJ,IAAI,CAAC,SAAS;AACb,YAAM,UAAU,KAAK,eAAe,KAAK,IAAI;AAC7C,aAAO,MAAM,KAAK,IAAI,KAAK,OAAO;AAAA,IACpC,CAAC,EACA,KAAK,IAAI;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKQ,eAAe,MAAsB;AAC3C,WAAO,QAAQ,OAAO,OAClB,IAAI,QAAQ,OAAO,OAAO,QAAQ,CAAC,CAAC,OACpC,IAAI,OAAO,MAAM,QAAQ,CAAC,CAAC;AAAA,EACjC;AACF;"}
1
+ {"version":3,"file":"index30.js","sources":["../../src/services/attachment-processor.ts"],"sourcesContent":["import { Logger } from '@hashgraphonline/standards-sdk';\nimport type { ContentStoreManager as PackageContentStoreManager } from './content-store-manager';\n\nexport interface AttachmentData {\n name: string;\n data: string;\n type: string;\n size: number;\n}\n\nexport type ContentStoreManager = PackageContentStoreManager;\n\n/**\n * Utility for processing file attachments and content references\n */\nexport class AttachmentProcessor {\n private logger: Logger;\n\n constructor() {\n this.logger = new Logger({ module: 'AttachmentProcessor' });\n }\n\n /**\n * Process attachments and create content references\n */\n async processAttachments(\n content: string,\n attachments: AttachmentData[],\n contentStoreManager?: ContentStoreManager\n ): Promise<string> {\n if (attachments.length === 0) {\n return content;\n }\n\n this.logger.info('Processing attachments with content reference system:', {\n attachmentCount: attachments.length,\n totalSize: attachments.reduce((sum, att) => sum + att.size, 0),\n });\n\n if (contentStoreManager && contentStoreManager.isInitialized()) {\n return this.processWithContentStore(content, attachments, contentStoreManager);\n } else {\n this.logger.warn('Content storage not available, creating simple file references');\n return this.processWithSimpleReferences(content, attachments);\n }\n }\n\n /**\n * Process attachments using content store manager\n */\n private async processWithContentStore(\n content: string,\n attachments: AttachmentData[],\n contentStoreManager: ContentStoreManager\n ): Promise<string> {\n const contentReferences: string[] = [];\n\n for (const attachment of attachments) {\n try {\n const base64Data = attachment.data.includes('base64,')\n ? attachment.data.split('base64,')[1]\n : attachment.data;\n const buffer = Buffer.from(base64Data, 'base64');\n\n const contentRef = await contentStoreManager.storeContentIfLarge(\n buffer,\n {\n mimeType: attachment.type,\n source: 'user_upload',\n fileName: attachment.name,\n tags: ['attachment', 'user_file'],\n }\n );\n\n if (contentRef) {\n if (attachment.type.startsWith('image/')) {\n contentReferences.push(\n `[Image File: ${attachment.name}] (content-ref:${contentRef.referenceId})`\n );\n } else {\n contentReferences.push(\n `[File: ${attachment.name}] (content-ref:${contentRef.referenceId})`\n );\n }\n } else {\n contentReferences.push(\n this.createInlineReference(attachment, base64Data)\n );\n }\n } catch (error) {\n this.logger.error('Failed to process attachment:', {\n fileName: attachment.name,\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n contentReferences.push(\n `[File: ${attachment.name} - Error processing file: ${\n error instanceof Error ? error.message : 'Unknown error'\n }]`\n );\n }\n }\n\n const fileList = this.createFileList(attachments);\n return content\n ? `${content}\\n\\nAttached files:\\n${fileList}\\n\\n${contentReferences.join('\\n')}`\n : `Attached files:\\n${fileList}\\n\\n${contentReferences.join('\\n')}`;\n }\n\n /**\n * Process attachments with simple file references\n */\n private processWithSimpleReferences(content: string, attachments: AttachmentData[]): string {\n const fileReferences = attachments.map((attachment) => {\n const sizeStr = this.formatFileSize(attachment.size);\n\n if (attachment.type.startsWith('image/')) {\n return `📎 Image: ${attachment.name} (${sizeStr}, ${attachment.type})`;\n } else {\n return `📎 File: ${attachment.name} (${sizeStr}, ${attachment.type})`;\n }\n });\n\n return content\n ? `${content}\\n\\nAttached files:\\n${fileReferences.join('\\n')}`\n : `Attached files:\\n${fileReferences.join('\\n')}`;\n }\n\n /**\n * Create inline reference for small files\n */\n private createInlineReference(attachment: AttachmentData, base64Data: string): string {\n if (attachment.size < 50000) {\n if (attachment.type.startsWith('image/')) {\n return `![${attachment.name}](data:${attachment.type};base64,${base64Data})`;\n } else {\n return `[File: ${attachment.name} (${this.formatFileSize(attachment.size)})]\\nContent: ${base64Data}`;\n }\n } else {\n return `[File: ${attachment.name} (${this.formatFileSize(attachment.size)}) - Content too large to include inline]`;\n }\n }\n\n /**\n * Create formatted file list\n */\n private createFileList(attachments: AttachmentData[]): string {\n return attachments\n .map((file) => {\n const sizeStr = this.formatFileSize(file.size);\n return `📎 ${file.name} (${sizeStr})`;\n })\n .join('\\n');\n }\n\n /**\n * Format file size for display\n */\n private formatFileSize(size: number): string {\n return size >= 1024 * 1024\n ? `${(size / (1024 * 1024)).toFixed(1)}MB`\n : `${(size / 1024).toFixed(1)}KB`;\n }\n}\n"],"names":[],"mappings":";AAeO,MAAM,oBAAoB;AAAA,EAG/B,cAAc;AACZ,SAAK,SAAS,IAAI,OAAO,EAAE,QAAQ,uBAAuB;AAAA,EAC5D;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,mBACJ,SACA,aACA,qBACiB;AACjB,QAAI,YAAY,WAAW,GAAG;AAC5B,aAAO;AAAA,IACT;AAEA,SAAK,OAAO,KAAK,yDAAyD;AAAA,MACxE,iBAAiB,YAAY;AAAA,MAC7B,WAAW,YAAY,OAAO,CAAC,KAAK,QAAQ,MAAM,IAAI,MAAM,CAAC;AAAA,IAAA,CAC9D;AAED,QAAI,uBAAuB,oBAAoB,iBAAiB;AAC9D,aAAO,KAAK,wBAAwB,SAAS,aAAa,mBAAmB;AAAA,IAC/E,OAAO;AACL,WAAK,OAAO,KAAK,gEAAgE;AACjF,aAAO,KAAK,4BAA4B,SAAS,WAAW;AAAA,IAC9D;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAc,wBACZ,SACA,aACA,qBACiB;AACjB,UAAM,oBAA8B,CAAA;AAEpC,eAAW,cAAc,aAAa;AACpC,UAAI;AACF,cAAM,aAAa,WAAW,KAAK,SAAS,SAAS,IACjD,WAAW,KA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9
9
  import { SmartMemoryManager } from "./index18.js";
10
10
  import { ResponseFormatter } from "./index35.js";
11
- import { ERROR_MESSAGES } from "./index43.js";
12
- import "./index41.js";
11
+ import { ERROR_MESSAGES } from "./index41.js";
12
+ import "./index42.js";
13
13
  import { SystemMessage, AIMessage, HumanMessage } from "@langchain/core/messages";
14
- import { ToolRegistry } from "./index44.js";
15
- import { ExecutionPipeline } from "./index45.js";
14
+ import { ToolRegistry } from "./index43.js";
15
+ import { ExecutionPipeline } from "./index44.js";
16
16
  import { FormEngine } from "./index11.js";
17
17
  function hasHashLinkBlock(metadata) {
18
18
  if (!metadata || typeof metadata !== "object") {
@@ -1 +1 @@
1
- {"version":3,"file":"index36.js","sources":["../../src/runtime/wallet-bridge.ts"],"sourcesContent":["export type WalletNetwork = 'mainnet' | 'testnet';\n\nexport interface WalletStatus {\n connected: boolean;\n accountId?: string;\n network?: WalletNetwork;\n}\n\nexport interface WalletExecutorResult {\n transactionId: string;\n}\n\nexport interface StartInscriptionResult {\n transactionBytes: string;\n tx_id?: string;\n topic_id?: string;\n status?: string;\n completed?: boolean;\n}\n\nexport interface WalletBridgeProvider {\n status: () => Promise<WalletStatus> | WalletStatus;\n executeBytes: (\n base64: string,\n network: WalletNetwork\n ) => Promise<WalletExecutorResult>;\n startInscription?: (\n request: Record<string, unknown>,\n network: WalletNetwork\n ) => Promise<StartInscriptionResult>;\n}\n\nlet providerRef: WalletBridgeProvider | null = null;\n\nexport function setWalletBridgeProvider(provider: WalletBridgeProvider): void {\n providerRef = provider;\n}\n\nexport function getWalletBridgeProvider(): WalletBridgeProvider | null {\n return providerRef;\n}\n"],"names":[],"mappings":"AAgCA,IAAI,cAA2C;AAExC,SAAS,wBAAwB,UAAsC;AAC5E,gBAAc;AAChB;AAEO,SAAS,0BAAuD;AACrE,SAAO;AACT;"}
1
+ {"version":3,"file":"index36.js","sources":["../../src/runtime/wallet-bridge.ts"],"sourcesContent":["export type WalletNetwork = 'mainnet' | 'testnet';\n\nexport interface WalletStatus {\n connected: boolean;\n accountId?: string;\n network?: WalletNetwork;\n}\n\nexport interface WalletExecutorResult {\n transactionId: string;\n}\n\nexport interface StartInscriptionResult {\n transactionBytes: string;\n tx_id?: string;\n topic_id?: string;\n status?: string;\n completed?: boolean;\n}\n\nexport interface WalletBridgeProvider {\n status: () => Promise<WalletStatus> | WalletStatus;\n executeBytes: (\n base64: string,\n network: WalletNetwork\n ) => Promise<WalletExecutorResult>;\n startInscription?: (\n request: Record<string, unknown>,\n network: WalletNetwork\n ) => Promise<StartInscriptionResult>;\n startHCS?: (\n op: string,\n request: Record<string, unknown>,\n network: WalletNetwork\n ) => Promise<{ transactionBytes: string }>;\n}\n\nlet providerRef: WalletBridgeProvider | null = null;\n\nexport function setWalletBridgeProvider(provider: WalletBridgeProvider): void {\n providerRef = provider;\n}\n\nexport function getWalletBridgeProvider(): WalletBridgeProvider | null {\n return providerRef;\n}\n"],"names":[],"mappings":"AAqCA,IAAI,cAA2C;AAExC,SAAS,wBAAwB,UAAsC;AAC5E,gBAAc;AAChB;AAEO,SAAS,0BAAuD;AACrE,SAAO;AACT;"}
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { AccountBuilder } from "./index47.js";
2
+ import { AccountBuilder } from "./index46.js";
3
3
  import { BaseHederaTransactionTool } from "hedera-agent-kit";
4
4
  const HbarTransferInputSchema = z.object({
5
5
  accountId: z.string().describe('Account ID for the transfer (e.g., "0.0.xxxx").'),
@@ -1 +1 @@
1
- {"version":3,"file":"index39.js","sources":["../../src/signers/browser-signer.ts"],"sourcesContent":["import {\n AccountId,\n Client,\n PrivateKey,\n PublicKey,\n Transaction,\n TransactionReceipt,\n} from '@hashgraph/sdk';\nimport { AbstractSigner } from 'hedera-agent-kit';\nimport {\n HederaMirrorNode,\n Logger,\n type NetworkType,\n} from '@hashgraphonline/standards-sdk';\n\n/**\n * BrowserSigner (bytes-only)\n *\n * Minimal signer compatible with HederaAgentKit in bytes/Provide Bytes mode.\n * - Does NOT hold a private key\n * - Cannot execute transactions; only provides identity and network context\n * - getOperatorPrivateKey() throws to signal absence of a local key\n */\nexport class BrowserSigner extends AbstractSigner {\n private readonly account: AccountId;\n private readonly network: 'mainnet' | 'testnet';\n private readonly client: Client;\n private readonly exec: ((\n base64: string,\n network: 'mainnet' | 'testnet'\n ) => Promise<{ transactionId: string }>) | null;\n private readonly ephemeralKey: PrivateKey;\n\n getAccountId(): AccountId {\n return this.account;\n }\n\n getNetwork(): 'mainnet' | 'testnet' {\n return this.network;\n }\n\n constructor(\n accountId: string,\n network: 'mainnet' | 'testnet',\n executor?: (\n base64: string,\n network: 'mainnet' | 'testnet'\n ) => Promise<{ transactionId: string }>\n ) {\n super();\n this.account = AccountId.fromString(accountId);\n this.network = network;\n this.client =\n network === 'mainnet' ? Client.forMainnet() : Client.forTestnet();\n this.exec = executor ?? null;\n this.ephemeralKey = PrivateKey.generateED25519();\n }\n\n /**\n * Returns an auto-generated ED25519 key for client wiring only.\n * Do not use for signing; wallet performs signing in renderer.\n */\n getOperatorPrivateKey(): PrivateKey {\n return this.ephemeralKey;\n }\n\n getClient(): Client {\n return this.client;\n }\n\n async signAndExecuteTransaction(\n tx: Transaction\n ): Promise<TransactionReceipt> {\n if (!this.exec) {\n throw new Error('BrowserSigner executor not available');\n }\n if (!tx.isFrozen()) {\n await tx.freezeWith(this.client);\n }\n const base64 = Buffer.from(tx.toBytes()).toString('base64');\n const { transactionId } = await this.exec(base64, this.network);\n const mirror = new HederaMirrorNode(this.network);\n const deadline = Date.now() + 60000;\n while (Date.now() < deadline) {\n try {\n const details = await mirror.getTransaction(transactionId);\n if (details && details.result) {\n return TransactionReceipt.fromBytes(\n Buffer.from(details.result, 'base64')\n );\n }\n } catch {}\n await new Promise((r) => setTimeout(r, 1200));\n }\n return TransactionReceipt.fromBytes(Buffer.from(''));\n }\n\n override async getPublicKey(): Promise<PublicKey> {\n const network: NetworkType =\n this.network === 'mainnet' ? 'mainnet' : 'testnet';\n const mirror = new HederaMirrorNode(\n network,\n new Logger({ module: 'BrowserSigner' })\n );\n // Avoid cross-package PublicKey type incompatibility by reconstructing from string\n const anyKey: any = await mirror.getPublicKey(this.account.toString());\n const keyStr = typeof anyKey?.toString === 'function' ? anyKey.toString() : String(anyKey);\n return PublicKey.fromString(keyStr);\n }\n}\n\nexport default BrowserSigner;\n"],"names":[],"mappings":";;;AAuBO,MAAM,sBAAsB,eAAe;AAAA,EAUhD,eAA0B;AACxB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,aAAoC;AAClC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,YACE,WACA,SACA,UAIA;AACA,UAAA;AACA,SAAK,UAAU,UAAU,WAAW,SAAS;AAC7C,SAAK,UAAU;AACf,SAAK,SACH,YAAY,YAAY,OAAO,WAAA,IAAe,OAAO,WAAA;AACvD,SAAK,OAAO,YAAY;AACxB,SAAK,eAAe,WAAW,gBAAA;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,wBAAoC;AAClC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,YAAoB;AAClB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,0BACJ,IAC6B;AAC7B,QAAI,CAAC,KAAK,MAAM;AACd,YAAM,IAAI,MAAM,sCAAsC;AAAA,IACxD;AACA,QAAI,CAAC,GAAG,YAAY;AAClB,YAAM,GAAG,WAAW,KAAK,MAAM;AAAA,IACjC;AACA,UAAM,SAAS,OAAO,KAAK,GAAG,SAAS,EAAE,SAAS,QAAQ;AAC1D,UAAM,EAAE,kBAAkB,MAAM,KAAK,KAAK,QAAQ,KAAK,OAAO;AAC9D,UAAM,SAAS,IAAI,iBAAiB,KAAK,OAAO;AAChD,UAAM,WAAW,KAAK,IAAA,IAAQ;AAC9B,WAAO,KAAK,IAAA,IAAQ,UAAU;AAC5B,UAAI;AACF,cAAM,UAAU,MAAM,OAAO,eAAe,aAAa;AACzD,YAAI,WAAW,QAAQ,QAAQ;AAC7B,iBAAO,mBAAmB;AAAA,YACxB,OAAO,KAAK,QAAQ,QAAQ,QAAQ;AAAA,UAAA;AAAA,QAExC;AAAA,MACF,QAAQ;AAAA,MAAC;AACT,YAAM,IAAI,QAAQ,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC;AAAA,IAC9C;AACA,WAAO,mBAAmB,UAAU,OAAO,KAAK,EAAE,CAAC;AAAA,EACrD;AAAA,EAEA,MAAe,eAAmC;AAChD,UAAM,UACJ,KAAK,YAAY,YAAY,YAAY;AAC3C,UAAM,SAAS,IAAI;AAAA,MACjB;AAAA,MACA,IAAI,OAAO,EAAE,QAAQ,iBAAiB;AAAA,IAAA;AAGxC,UAAM,SAAc,MAAM,OAAO,aAAa,KAAK,QAAQ,UAAU;AACrE,UAAM,SAAS,OAAO,QAAQ,aAAa,aAAa,OAAO,SAAA,IAAa,OAAO,MAAM;AACzF,WAAO,UAAU,WAAW,MAAM;AAAA,EACpC;AACF;"}
1
+ {"version":3,"file":"index39.js","sources":["../../src/signers/browser-signer.ts"],"sourcesContent":["import {\n AccountId,\n Client,\n PrivateKey,\n PublicKey,\n Transaction,\n TransactionReceipt,\n} from '@hashgraph/sdk';\nimport { AbstractSigner } from 'hedera-agent-kit';\nimport {\n HederaMirrorNode,\n Logger,\n type NetworkType,\n} from '@hashgraphonline/standards-sdk';\n\n/**\n * BrowserSigner (bytes-only)\n *\n * Minimal signer compatible with HederaAgentKit in bytes/Provide Bytes mode.\n * - Does NOT hold a private key\n * - Cannot execute transactions; only provides identity and network context\n * - getOperatorPrivateKey() throws to signal absence of a local key\n */\nexport class BrowserSigner extends AbstractSigner {\n private readonly account: AccountId;\n private readonly network: 'mainnet' | 'testnet';\n private readonly client: Client;\n private readonly exec: ((\n base64: string,\n network: 'mainnet' | 'testnet'\n ) => Promise<{ transactionId: string }>) | null;\n private readonly ephemeralKey: PrivateKey;\n\n getAccountId(): AccountId {\n return this.account;\n }\n\n getNetwork(): 'mainnet' | 'testnet' {\n return this.network;\n }\n\n constructor(\n accountId: string,\n network: 'mainnet' | 'testnet',\n executor?: (\n base64: string,\n network: 'mainnet' | 'testnet'\n ) => Promise<{ transactionId: string }>\n ) {\n super();\n this.account = AccountId.fromString(accountId);\n this.network = network;\n this.client =\n network === 'mainnet' ? Client.forMainnet() : Client.forTestnet();\n this.exec = executor ?? null;\n this.ephemeralKey = PrivateKey.generateED25519();\n }\n\n /**\n * Returns an auto-generated ED25519 key for client wiring only.\n * Do not use for signing; wallet performs signing in renderer.\n */\n getOperatorPrivateKey(): PrivateKey {\n return this.ephemeralKey;\n }\n\n getClient(): Client {\n return this.client;\n }\n\n async signAndExecuteTransaction(\n tx: Transaction\n ): Promise<TransactionReceipt> {\n if (!this.exec) {\n throw new Error('BrowserSigner executor not available');\n }\n if (!tx.isFrozen()) {\n await tx.freezeWith(this.client);\n }\n const base64 = Buffer.from(tx.toBytes()).toString('base64');\n const { transactionId } = await this.exec(base64, this.network);\n const mirror = new HederaMirrorNode(this.network);\n const deadline = Date.now() + 60000;\n while (Date.now() < deadline) {\n try {\n const details = await mirror.getTransaction(transactionId);\n if (details && details.result) {\n return TransactionReceipt.fromBytes(\n Buffer.from(details.result, 'base64')\n );\n }\n } catch {}\n await new Promise((r) => setTimeout(r, 1200));\n }\n return TransactionReceipt.fromBytes(Buffer.from(''));\n }\n\n override async getPublicKey(): Promise<PublicKey> {\n const network: NetworkType =\n this.network === 'mainnet' ? 'mainnet' : 'testnet';\n const mirror = new HederaMirrorNode(\n network,\n new Logger({ module: 'BrowserSigner' })\n );\n const anyKey: any = await mirror.getPublicKey(this.account.toString());\n const keyStr = typeof anyKey?.toString === 'function' ? anyKey.toString() : String(anyKey);\n return PublicKey.fromString(keyStr);\n }\n}\n\nexport default BrowserSigner;\n"],"names":[],"mappings":";;;AAuBO,MAAM,sBAAsB,eAAe;AAAA,EAUhD,eAA0B;AACxB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,aAAoC;AAClC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,YACE,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AE,QAAQ,iBAAiB;AAAA,IAAA;AAExC,UAAM,SAAc,MAAM,OAAO,aAAa,KAAK,QAAQ,UAAU;AACrE,UAAM,SAAS,OAAO,QAAQ,aAAa,aAAa,OAAO,SAAA,IAAa,OAAO,MAAM;AACzF,WAAO,UAAU,WAAW,MAAM;AAAA,EACpC;AACF;"}
@@ -51,7 +51,7 @@ class InscribePlugin extends BasePlugin {
51
51
  })
52
52
  };
53
53
  this.providerId = fieldGuidanceRegistry.registerToolProvider(
54
- /inscribe.*hashinal/i,
54
+ /hashinal/i,
55
55
  provider,
56
56
  { id: "inscribe:hashinal:provider", priority: 1 }
57
57
  );
@@ -1 +1 @@
1
- {"version":3,"file":"index4.js","sources":["../../src/plugins/inscribe/InscribePlugin.ts"],"sourcesContent":["import {\n GenericPluginContext,\n HederaTool,\n BasePlugin,\n HederaAgentKit,\n} from 'hedera-agent-kit';\nimport {\n InscriberBuilder,\n InscribeFromUrlTool,\n InscribeFromFileTool,\n InscribeFromBufferTool,\n InscribeHashinalTool,\n RetrieveInscriptionTool,\n} from '@hashgraphonline/standards-agent-kit';\nimport { fieldGuidanceRegistry, type FieldGuidance } from '../../forms/field-guidance-registry';\n\n/**\n * Plugin providing content inscription tools for Hedera\n */\nexport class InscribePlugin extends BasePlugin {\n id = 'inscribe';\n name = 'Inscribe Plugin';\n description =\n 'Content inscription tools for storing data on Hedera Consensus Service';\n version = '1.0.0';\n author = 'Hashgraph Online';\n namespace = 'inscribe';\n\n private tools: any[] = [];\n private providerId: string | null = null;\n\n override async initialize(context: GenericPluginContext): Promise<void> {\n await super.initialize(context);\n\n const hederaKit = context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n this.context.logger.warn(\n 'HederaKit not found in context. Inscription tools will not be available.'\n );\n return;\n }\n\n try {\n this.initializeTools();\n\n // Register field guidance provider for inscribe hashinal tools\n try {\n const provider = {\n getFieldGuidance: (fieldName: string): FieldGuidance | null => {\n if (fieldName === 'name') {\n return {\n suggestions: [\n 'Sunset Landscape #42',\n 'Digital Abstract Art',\n ],\n contextualHelpText:\n 'Create a distinctive name that collectors will find appealing',\n };\n }\n if (fieldName === 'description') {\n return {\n fieldTypeOverride: 'textarea',\n suggestions: ['A beautiful piece representing...'],\n };\n }\n return null;\n },\n getGlobalGuidance: () => ({\n qualityStandards: [\n 'Use meaningful names that describe the artwork or content',\n ],\n }),\n };\n this.providerId = fieldGuidanceRegistry.registerToolProvider(\n /inscribe.*hashinal/i,\n provider,\n { id: 'inscribe:hashinal:provider', priority: 1 }\n );\n } catch (e) {\n this.context.logger.warn('Could not register Inscribe field guidance provider');\n }\n\n this.context.logger.info(\n 'Inscribe Plugin initialized successfully'\n );\n } catch (error) {\n this.context.logger.error(\n 'Failed to initialize Inscribe plugin:',\n error\n );\n }\n }\n\n private initializeTools(): void {\n const hederaKit = this.context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n throw new Error('HederaKit not found in context config');\n }\n\n const inscriberBuilder = new InscriberBuilder(hederaKit);\n\n this.tools = [\n new InscribeFromUrlTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new InscribeFromFileTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new InscribeFromBufferTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new InscribeHashinalTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new RetrieveInscriptionTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n ];\n }\n\n getTools(): HederaTool[] {\n return this.tools;\n }\n\n override async cleanup(): Promise<void> {\n this.tools = [];\n if (this.providerId) {\n try {\n fieldGuidanceRegistry.unregisterProvider(this.providerId);\n } catch {}\n this.providerId = null;\n }\n if (this.context?.logger) {\n this.context.logger.info('Inscribe Plugin cleaned up');\n }\n }\n}\n"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AAA,EAEQ,kBAAwB;AAC9B,UAAM,YAAY,KAAK,QAAQ,OAAO;AACtC,QAAI,CAAC,WAAW;AACd,YAAM,IAAI,MAAM,uCAAuC;AAAA,IACzD;AAEA,UAAM,mBAAmB,IAAI,iBAAiB,SAAS;AAEvD,SAAK,QAAQ;AAAA,MACX,IAAI,oBAAoB;AAAA,QACtB;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,qBAAqB;AAAA,QACvB;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,uBAAuB;AAAA,QACzB;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,qBAAqB;AAAA,QACvB;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,wBAAwB;AAAA,QAC1B;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,IAAA;AAAA,EAEL;AAAA,EAEA,WAAyB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAe,UAAyB;AACtC,SAAK,QAAQ,CAAA;AACb,QAAI,KAAK,YAAY;AACnB,UAAI;AACF,8BAAsB,mBAAmB,KAAK,UAAU;AAAA,MAC1D,QAAQ;AAAA,MAAC;AACT,WAAK,aAAa;AAAA,IACpB;AACA,QAAI,KAAK,SAAS,QAAQ;AACxB,WAAK,QAAQ,OAAO,KAAK,4BAA4B;AAAA,IACvD;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"index4.js","sources":["../../src/plugins/inscribe/InscribePlugin.ts"],"sourcesContent":["import {\n GenericPluginContext,\n HederaTool,\n BasePlugin,\n HederaAgentKit,\n} from 'hedera-agent-kit';\nimport {\n InscriberBuilder,\n InscribeFromUrlTool,\n InscribeFromFileTool,\n InscribeFromBufferTool,\n InscribeHashinalTool,\n RetrieveInscriptionTool,\n} from '@hashgraphonline/standards-agent-kit';\nimport { fieldGuidanceRegistry, type FieldGuidance } from '../../forms/field-guidance-registry';\n\n/**\n * Plugin providing content inscription tools for Hedera\n */\nexport class InscribePlugin extends BasePlugin {\n id = 'inscribe';\n name = 'Inscribe Plugin';\n description =\n 'Content inscription tools for storing data on Hedera Consensus Service';\n version = '1.0.0';\n author = 'Hashgraph Online';\n namespace = 'inscribe';\n\n private tools: any[] = [];\n private providerId: string | null = null;\n\n override async initialize(context: GenericPluginContext): Promise<void> {\n await super.initialize(context);\n\n const hederaKit = context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n this.context.logger.warn(\n 'HederaKit not found in context. Inscription tools will not be available.'\n );\n return;\n }\n\n try {\n this.initializeTools();\n\n try {\n const provider = {\n getFieldGuidance: (fieldName: string): FieldGuidance | null => {\n if (fieldName === 'name') {\n return {\n suggestions: [\n 'Sunset Landscape #42',\n 'Digital Abstract Art',\n ],\n contextualHelpText:\n 'Create a distinctive name that collectors will find appealing',\n };\n }\n if (fieldName === 'description') {\n return {\n fieldTypeOverride: 'textarea',\n suggestions: ['A beautiful piece representing...'],\n };\n }\n return null;\n },\n getGlobalGuidance: () => ({\n qualityStandards: [\n 'Use meaningful names that describe the artwork or content',\n ],\n }),\n };\n this.providerId = fieldGuidanceRegistry.registerToolProvider(\n /hashinal/i,\n provider,\n { id: 'inscribe:hashinal:provider', priority: 1 }\n );\n } catch (e) {\n this.context.logger.warn('Could not register Inscribe field guidance provider');\n }\n\n this.context.logger.info(\n 'Inscribe Plugin initialized successfully'\n );\n } catch (error) {\n this.context.logger.error(\n 'Failed to initialize Inscribe plugin:',\n error\n );\n }\n }\n\n private initializeTools(): void {\n const hederaKit = this.context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n throw new Error('HederaKit not found in context config');\n }\n\n const inscriberBuilder = new InscriberBuilder(hederaKit);\n\n this.tools = [\n new InscribeFromUrlTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new InscribeFromFileTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new InscribeFromBufferTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new InscribeHashinalTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new RetrieveInscriptionTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n ];\n }\n\n getTools(): HederaTool[] {\n return this.tools;\n }\n\n override async cleanup(): Promise<void> {\n this.tools = [];\n if (this.providerId) {\n try {\n fieldGuidanceRegistry.unregisterProvider(this.providerId);\n } catch {}\n this.providerId = null;\n }\n if (this.context?.logger) {\n this.context.logger.info('Inscribe Plugin cleaned up');\n }\n }\n}\n"],"names":[],"mappings":";;;AAmBO,MAAM,uBAAuB,WAAW;AAAA,EAAxC,cAAA;AAAA,UAAA,GAAA,SAAA;AACL,SAAA,KAAK;AACL,SAAA,OAAO;AACP,SAAA,cACE;AACF,SAAA,UAAU;AACV,SAAA,SAAS;AACT,SAAA,YAAY;AAEZ,SAAQ,QAAe,CAAA;AACvB,SAAQ,aAA4B;AAAA,EAAA;AAAA,EAEpC,MAAe,WAAW,SAA8C;AACtE,UAAM,MAAM,WAAW,OAAO;AAE9B,UAAM,YAAY,QAAQ,OAAO;AACjC,QAAI,CAAC,WAAW;AACd,WAAK,QAAQ,OAAO;AAAA,QAClB;AAAA,MAAA;AAEF;AAAA,IACF;AAEA,QAAI;AACF,WAAK,gBAAA;AAEL,UAAI;AACF,cAAM,WAAW;AAAA,UACf,kBAAkB,CAAC,cAA4C;AAC7D,gBAAI,cAAc,QAAQ;AACxB,qBAAO;AAAA,gBACL,aAAa;AAAA,kBACX;AAAA,kBACA;AAAA,gBAAA;AAAA,gBAEF,oBACE;AAAA,cAAA;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,QAAQ;AAAA,MAAA,CACtB;AAAA,IAAA;AAAA,EAEL;AAAA,EAEA,WAAyB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAe,UAAyB;AACtC,SAAK,QAAQ,CAAA;AACb,QAAI,KAAK,YAAY;AACnB,UAAI;AACF,8BAAsB,mBAAmB,KAAK,UAAU;AAAA,MAC1D,QAAQ;AAAA,MAAC;AACT,WAAK,aAAa;AAAA,IACpB;AACA,QAAI,KAAK,SAAS,QAAQ;AACxB,WAAK,QAAQ,OAAO,KAAK,4BAA4B;AAAA,IACvD;AAAA,EACF;AACF;"}
@@ -8,8 +8,8 @@ You have access to tools for:
8
8
 
9
9
 
10
10
  *** IMPORTANT CONTEXT ***
11
- You are currently operating as agent: ${accountId} on the Hedera Hashgraph
12
- When users ask about "my profile", "my account", "my connections", etc., use this account ID: ${accountId}
11
+ You are currently operating as agent: ${accountId || "unknown"} on the Hedera Hashgraph
12
+ When users ask about "my profile", "my account", "my connections", etc., use this account ID: ${accountId || "unknown"}
13
13
 
14
14
  *** CRITICAL ENTITY HANDLING RULES ***
15
15
  - When users refer to entities (tokens, topics, accounts) with pronouns like "it", "that", "the token/topic", etc., ALWAYS use the most recently created entity of that type
@@ -1 +1 @@
1
- {"version":3,"file":"index40.js","sources":["../../src/config/system-message.ts"],"sourcesContent":["export const getSystemMessage = (\n accountId: string\n): string => `You are a helpful assistant managing Hashgraph Online HCS-10 connections, messages, HCS-2 registries, content inscription, and Hedera Hashgraph operations.\n\nYou have access to tools for:\n- HCS-10: registering agents, finding registered agents, initiating connections, listing active connections, sending messages over connections, and checking for new messages\n- HCS-2: creating registries, registering entries, updating entries, deleting entries, migrating registries, and querying registry contents\n- Inscription: inscribing content from URLs, files, or buffers, creating Hashinal NFTs, and retrieving inscriptions\n- Hedera Token Service (HTS): creating tokens, transferring tokens, airdropping tokens, and managing token operations\n\n\n*** IMPORTANT CONTEXT ***\nYou are currently operating as agent: ${accountId} on the Hedera Hashgraph\nWhen users ask about \"my profile\", \"my account\", \"my connections\", etc., use this account ID: ${accountId}\n\n*** CRITICAL ENTITY HANDLING RULES ***\n- When users refer to entities (tokens, topics, accounts) with pronouns like \"it\", \"that\", \"the token/topic\", etc., ALWAYS use the most recently created entity of that type\n- Entity IDs look like \"0.0.XXXXXX\" and are stored in memory after creation\n- NEVER use example or placeholder IDs like \"0.0.123456\" - always use actual created entity IDs\n- Account ID ${accountId} is NOT a token - tokens and accounts are different entities\n\n Remember the connection numbers when listing connections, as users might refer to them.`;\n"],"names":[],"mappings":"AAAO,MAAM,mBAAmB,CAC9B,cACW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAU2B,SAAS;AAAA,gGAC+C,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAM1F,SAAS;AAAA;AAAA;"}
1
+ {"version":3,"file":"index40.js","sources":["../../src/config/system-message.ts"],"sourcesContent":["export const getSystemMessage = (\n accountId?: string\n): string => `You are a helpful assistant managing Hashgraph Online HCS-10 connections, messages, HCS-2 registries, content inscription, and Hedera Hashgraph operations.\n\nYou have access to tools for:\n- HCS-10: registering agents, finding registered agents, initiating connections, listing active connections, sending messages over connections, and checking for new messages\n- HCS-2: creating registries, registering entries, updating entries, deleting entries, migrating registries, and querying registry contents\n- Inscription: inscribing content from URLs, files, or buffers, creating Hashinal NFTs, and retrieving inscriptions\n- Hedera Token Service (HTS): creating tokens, transferring tokens, airdropping tokens, and managing token operations\n\n\n*** IMPORTANT CONTEXT ***\nYou are currently operating as agent: ${accountId || 'unknown'} on the Hedera Hashgraph\nWhen users ask about \"my profile\", \"my account\", \"my connections\", etc., use this account ID: ${accountId || 'unknown'}\n\n*** CRITICAL ENTITY HANDLING RULES ***\n- When users refer to entities (tokens, topics, accounts) with pronouns like \"it\", \"that\", \"the token/topic\", etc., ALWAYS use the most recently created entity of that type\n- Entity IDs look like \"0.0.XXXXXX\" and are stored in memory after creation\n- NEVER use example or placeholder IDs like \"0.0.123456\" - always use actual created entity IDs\n- Account ID ${accountId} is NOT a token - tokens and accounts are different entities\n\n Remember the connection numbers when listing connections, as users might refer to them.`;\n"],"names":[],"mappings":"AAAO,MAAM,mBAAmB,CAC9B,cACW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAU2B,aAAa,SAAS;AAAA,gGACkC,aAAa,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAMvG,SAAS;AAAA;AAAA;"}
@@ -1,15 +1,8 @@
1
- import { EntityFormat } from "./index26.js";
2
- const ENTITY_PATTERNS = {
3
- TOPIC_REFERENCE: "the topic",
4
- TOKEN_REFERENCE: "the token"
1
+ const ERROR_MESSAGES = {
2
+ TOO_MANY_REQUESTS: "Too many requests. Please wait a moment and try again.",
3
+ RATE_LIMITED: "I'm receiving too many requests right now. Please wait a moment and try again."
5
4
  };
6
- ({
7
- TOPIC: EntityFormat.TOPIC_ID,
8
- TOKEN: EntityFormat.TOKEN_ID,
9
- ACCOUNT: EntityFormat.ACCOUNT_ID,
10
- CONTRACT: EntityFormat.CONTRACT_ID
11
- });
12
5
  export {
13
- ENTITY_PATTERNS
6
+ ERROR_MESSAGES
14
7
  };
15
8
  //# sourceMappingURL=index41.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index41.js","sources":["../../src/constants/entity-references.ts"],"sourcesContent":["/**\n * Common entity reference patterns used across the application\n */\nexport const ENTITY_PATTERNS = {\n TOPIC_REFERENCE: 'the topic',\n TOKEN_REFERENCE: 'the token',\n ACCOUNT_REFERENCE: 'the account',\n TRANSACTION_REFERENCE: 'the transaction',\n CONTRACT_REFERENCE: 'the contract',\n} as const;\n\n/**\n * Entity type identifiers\n */\nimport { EntityFormat } from '../services/formatters/types';\n\nexport const ENTITY_TYPES = {\n TOPIC: EntityFormat.TOPIC_ID,\n TOKEN: EntityFormat.TOKEN_ID,\n ACCOUNT: EntityFormat.ACCOUNT_ID,\n TRANSACTION: 'transaction',\n CONTRACT: EntityFormat.CONTRACT_ID,\n} as const;\n"],"names":[],"mappings":";AAGO,MAAM,kBAAkB;AAAA,EAC7B,iBAAiB;AAAA,EACjB,iBAAiB;AAInB;AAAA,CAO4B;AAAA,EAC1B,OAAO,aAAa;AAAA,EACpB,OAAO,aAAa;AAAA,EACpB,SAAS,aAAa;AAAA,EAEtB,UAAU,aAAa;AACzB;"}
1
+ {"version":3,"file":"index41.js","sources":["../../src/constants/messages.ts"],"sourcesContent":["/**\n * Common error messages and user feedback strings\n */\nexport const ERROR_MESSAGES = {\n TOO_MANY_REQUESTS: 'Too many requests. Please wait a moment and try again.',\n RATE_LIMITED: \"I'm receiving too many requests right now. Please wait a moment and try again.\",\n SYSTEM_ERROR: 'System error occurred',\n INVALID_INPUT: 'Invalid input provided',\n NETWORK_ERROR: 'Network error occurred',\n} as const;\n\n/**\n * Common success and status messages\n */\nexport const STATUS_MESSAGES = {\n OPERATION_SUCCESSFUL: 'Operation completed successfully',\n PROCESSING: 'Processing your request...',\n READY: 'Ready to process requests',\n INITIALIZING: 'Initializing...',\n} as const;"],"names":[],"mappings":"AAGO,MAAM,iBAAiB;AAAA,EAC5B,mBAAmB;AAAA,EACnB,cAAc;AAIhB;"}
@@ -1,10 +1,15 @@
1
- const FIELD_PRIORITIES = {
2
- ESSENTIAL: "essential",
3
- COMMON: "common",
4
- ADVANCED: "advanced",
5
- EXPERT: "expert"
1
+ import { EntityFormat } from "./index26.js";
2
+ const ENTITY_PATTERNS = {
3
+ TOPIC_REFERENCE: "the topic",
4
+ TOKEN_REFERENCE: "the token"
6
5
  };
6
+ ({
7
+ TOPIC: EntityFormat.TOPIC_ID,
8
+ TOKEN: EntityFormat.TOKEN_ID,
9
+ ACCOUNT: EntityFormat.ACCOUNT_ID,
10
+ CONTRACT: EntityFormat.CONTRACT_ID
11
+ });
7
12
  export {
8
- FIELD_PRIORITIES
13
+ ENTITY_PATTERNS
9
14
  };
10
15
  //# sourceMappingURL=index42.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index42.js","sources":["../../src/constants/form-priorities.ts"],"sourcesContent":["/**\n * Form field priorities for progressive disclosure\n */\nexport const FIELD_PRIORITIES = {\n ESSENTIAL: 'essential',\n COMMON: 'common', \n ADVANCED: 'advanced',\n EXPERT: 'expert'\n} as const;\n\n/**\n * Form field types\n */\nexport const FORM_FIELD_TYPES = {\n TEXT: 'text',\n NUMBER: 'number',\n SELECT: 'select',\n CHECKBOX: 'checkbox',\n TEXTAREA: 'textarea',\n FILE: 'file',\n ARRAY: 'array',\n OBJECT: 'object',\n CURRENCY: 'currency',\n PERCENTAGE: 'percentage',\n} as const;"],"names":[],"mappings":"AAGO,MAAM,mBAAmB;AAAA,EAC9B,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,QAAQ;AACV;"}
1
+ {"version":3,"file":"index42.js","sources":["../../src/constants/entity-references.ts"],"sourcesContent":["/**\n * Common entity reference patterns used across the application\n */\nexport const ENTITY_PATTERNS = {\n TOPIC_REFERENCE: 'the topic',\n TOKEN_REFERENCE: 'the token',\n ACCOUNT_REFERENCE: 'the account',\n TRANSACTION_REFERENCE: 'the transaction',\n CONTRACT_REFERENCE: 'the contract',\n} as const;\n\n/**\n * Entity type identifiers\n */\nimport { EntityFormat } from '../services/formatters/types';\n\nexport const ENTITY_TYPES = {\n TOPIC: EntityFormat.TOPIC_ID,\n TOKEN: EntityFormat.TOKEN_ID,\n ACCOUNT: EntityFormat.ACCOUNT_ID,\n TRANSACTION: 'transaction',\n CONTRACT: EntityFormat.CONTRACT_ID,\n} as const;\n"],"names":[],"mappings":";AAGO,MAAM,kBAAkB;AAAA,EAC7B,iBAAiB;AAAA,EACjB,iBAAiB;AAInB;AAAA,CAO4B;AAAA,EAC1B,OAAO,aAAa;AAAA,EACpB,OAAO,aAAa;AAAA,EACpB,SAAS,aAAa;AAAA,EAEtB,UAAU,aAAa;AACzB;"}