@hashgraphonline/standards-agent-kit 0.2.131 → 0.2.134
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.
- package/dist/cjs/builders/hcs10/hcs10-builder.d.ts +0 -2
- package/dist/cjs/builders/inscriber/inscriber-builder.d.ts +4 -10
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/interfaces/FormValidatable.d.ts +45 -0
- package/dist/cjs/interfaces/index.d.ts +1 -0
- package/dist/cjs/lib/index.d.ts +1 -0
- package/dist/cjs/lib/zod-render/config-extractor.d.ts +50 -0
- package/dist/cjs/lib/zod-render/index.d.ts +6 -0
- package/dist/cjs/lib/zod-render/schema-extension.d.ts +94 -0
- package/dist/cjs/lib/zod-render/types.d.ts +286 -0
- package/dist/cjs/standards-agent-kit.cjs +1 -1
- package/dist/cjs/standards-agent-kit.cjs.map +1 -1
- package/dist/cjs/tools/hcs10/natural-language-mapper.d.ts +6 -1
- package/dist/cjs/tools/hcs2/CreateRegistryTool.d.ts +1 -16
- package/dist/cjs/tools/hcs2/DeleteEntryTool.d.ts +1 -13
- package/dist/cjs/tools/hcs2/RegisterEntryTool.d.ts +1 -16
- package/dist/cjs/tools/hcs2/UpdateEntryTool.d.ts +1 -19
- package/dist/cjs/tools/hcs6/CreateDynamicRegistryTool.d.ts +1 -10
- package/dist/cjs/tools/inscriber/InscribeHashinalTool.d.ts +82 -132
- package/dist/cjs/tools/inscriber/RetrieveInscriptionTool.d.ts +20 -1
- package/dist/cjs/types/inscription-response.d.ts +172 -0
- package/dist/cjs/validation/hip412-schemas.d.ts +1 -1
- package/dist/es/builders/hcs10/hcs10-builder.d.ts +0 -2
- package/dist/es/builders/inscriber/inscriber-builder.d.ts +4 -10
- package/dist/es/index.d.ts +2 -0
- package/dist/es/interfaces/FormValidatable.d.ts +45 -0
- package/dist/es/interfaces/index.d.ts +1 -0
- package/dist/es/lib/index.d.ts +1 -0
- package/dist/es/lib/zod-render/config-extractor.d.ts +50 -0
- package/dist/es/lib/zod-render/index.d.ts +6 -0
- package/dist/es/lib/zod-render/schema-extension.d.ts +94 -0
- package/dist/es/lib/zod-render/types.d.ts +286 -0
- package/dist/es/standards-agent-kit.es.js +24 -1
- package/dist/es/standards-agent-kit.es.js.map +1 -1
- package/dist/es/standards-agent-kit.es10.js +3 -1
- package/dist/es/standards-agent-kit.es10.js.map +1 -1
- package/dist/es/standards-agent-kit.es14.js +3 -1
- package/dist/es/standards-agent-kit.es14.js.map +1 -1
- package/dist/es/standards-agent-kit.es20.js +3 -20
- package/dist/es/standards-agent-kit.es20.js.map +1 -1
- package/dist/es/standards-agent-kit.es22.js.map +1 -1
- package/dist/es/standards-agent-kit.es23.js.map +1 -1
- package/dist/es/standards-agent-kit.es24.js.map +1 -1
- package/dist/es/standards-agent-kit.es25.js.map +1 -1
- package/dist/es/standards-agent-kit.es29.js.map +1 -1
- package/dist/es/standards-agent-kit.es3.js +0 -4
- package/dist/es/standards-agent-kit.es3.js.map +1 -1
- package/dist/es/standards-agent-kit.es30.js.map +1 -1
- package/dist/es/standards-agent-kit.es31.js.map +1 -1
- package/dist/es/standards-agent-kit.es32.js.map +1 -1
- package/dist/es/standards-agent-kit.es33.js +0 -4
- package/dist/es/standards-agent-kit.es33.js.map +1 -1
- package/dist/es/standards-agent-kit.es34.js +13 -17
- package/dist/es/standards-agent-kit.es34.js.map +1 -1
- package/dist/es/standards-agent-kit.es35.js +2 -8
- package/dist/es/standards-agent-kit.es35.js.map +1 -1
- package/dist/es/standards-agent-kit.es36.js +2 -2
- package/dist/es/standards-agent-kit.es37.js +451 -92
- package/dist/es/standards-agent-kit.es37.js.map +1 -1
- package/dist/es/standards-agent-kit.es38.js +12 -11
- package/dist/es/standards-agent-kit.es38.js.map +1 -1
- package/dist/es/standards-agent-kit.es39.js +1 -1
- package/dist/es/standards-agent-kit.es39.js.map +1 -1
- package/dist/es/standards-agent-kit.es40.js +7 -7
- package/dist/es/standards-agent-kit.es40.js.map +1 -1
- package/dist/es/standards-agent-kit.es41.js.map +1 -1
- package/dist/es/standards-agent-kit.es42.js +423 -24
- package/dist/es/standards-agent-kit.es42.js.map +1 -1
- package/dist/es/standards-agent-kit.es43.js +185 -3
- package/dist/es/standards-agent-kit.es43.js.map +1 -1
- package/dist/es/standards-agent-kit.es44.js +3 -53
- package/dist/es/standards-agent-kit.es44.js.map +1 -1
- package/dist/es/standards-agent-kit.es45.js +25 -3
- package/dist/es/standards-agent-kit.es45.js.map +1 -1
- package/dist/es/standards-agent-kit.es46.js +3 -39
- package/dist/es/standards-agent-kit.es46.js.map +1 -1
- package/dist/es/standards-agent-kit.es47.js +51 -9
- package/dist/es/standards-agent-kit.es47.js.map +1 -1
- package/dist/es/standards-agent-kit.es48.js +6 -0
- package/dist/es/standards-agent-kit.es48.js.map +1 -0
- package/dist/es/standards-agent-kit.es49.js +43 -0
- package/dist/es/standards-agent-kit.es49.js.map +1 -0
- package/dist/es/standards-agent-kit.es50.js +22 -0
- package/dist/es/standards-agent-kit.es50.js.map +1 -0
- package/dist/es/standards-agent-kit.es51.js +57 -0
- package/dist/es/standards-agent-kit.es51.js.map +1 -0
- package/dist/es/standards-agent-kit.es6.js +1 -1
- package/dist/es/standards-agent-kit.es6.js.map +1 -1
- package/dist/es/standards-agent-kit.es7.js +1 -1
- package/dist/es/standards-agent-kit.es7.js.map +1 -1
- package/dist/es/standards-agent-kit.es9.js +6 -2
- package/dist/es/standards-agent-kit.es9.js.map +1 -1
- package/dist/es/tools/hcs10/natural-language-mapper.d.ts +6 -1
- package/dist/es/tools/hcs2/CreateRegistryTool.d.ts +1 -16
- package/dist/es/tools/hcs2/DeleteEntryTool.d.ts +1 -13
- package/dist/es/tools/hcs2/RegisterEntryTool.d.ts +1 -16
- package/dist/es/tools/hcs2/UpdateEntryTool.d.ts +1 -19
- package/dist/es/tools/hcs6/CreateDynamicRegistryTool.d.ts +1 -10
- package/dist/es/tools/inscriber/InscribeHashinalTool.d.ts +82 -132
- package/dist/es/tools/inscriber/RetrieveInscriptionTool.d.ts +20 -1
- package/dist/es/types/inscription-response.d.ts +172 -0
- package/dist/es/validation/hip412-schemas.d.ts +1 -1
- package/dist/umd/builders/hcs10/hcs10-builder.d.ts +0 -2
- package/dist/umd/builders/inscriber/inscriber-builder.d.ts +4 -10
- package/dist/umd/index.d.ts +2 -0
- package/dist/umd/interfaces/FormValidatable.d.ts +45 -0
- package/dist/umd/interfaces/index.d.ts +1 -0
- package/dist/umd/lib/index.d.ts +1 -0
- package/dist/umd/lib/zod-render/config-extractor.d.ts +50 -0
- package/dist/umd/lib/zod-render/index.d.ts +6 -0
- package/dist/umd/lib/zod-render/schema-extension.d.ts +94 -0
- package/dist/umd/lib/zod-render/types.d.ts +286 -0
- package/dist/umd/standards-agent-kit.umd.js +1 -1
- package/dist/umd/standards-agent-kit.umd.js.map +1 -1
- package/dist/umd/tools/hcs10/natural-language-mapper.d.ts +6 -1
- package/dist/umd/tools/hcs2/CreateRegistryTool.d.ts +1 -16
- package/dist/umd/tools/hcs2/DeleteEntryTool.d.ts +1 -13
- package/dist/umd/tools/hcs2/RegisterEntryTool.d.ts +1 -16
- package/dist/umd/tools/hcs2/UpdateEntryTool.d.ts +1 -19
- package/dist/umd/tools/hcs6/CreateDynamicRegistryTool.d.ts +1 -10
- package/dist/umd/tools/inscriber/InscribeHashinalTool.d.ts +82 -132
- package/dist/umd/tools/inscriber/RetrieveInscriptionTool.d.ts +20 -1
- package/dist/umd/types/inscription-response.d.ts +172 -0
- package/dist/umd/validation/hip412-schemas.d.ts +1 -1
- package/package.json +5 -4
- package/src/builders/hcs10/hcs10-builder.ts +0 -4
- package/src/builders/inscriber/inscriber-builder.ts +5 -12
- package/src/hcs10/HCS10Client.ts +2 -5
- package/src/hcs10/types.ts +1 -15
- package/src/index.ts +2 -0
- package/src/init/init.ts +7 -10
- package/src/interfaces/FormValidatable.ts +57 -0
- package/src/interfaces/index.ts +1 -0
- package/src/lib/index.ts +1 -0
- package/src/lib/zod-render/config-extractor.ts +351 -0
- package/src/lib/zod-render/index.ts +36 -0
- package/src/lib/zod-render/schema-extension.ts +544 -0
- package/src/lib/zod-render/types.ts +333 -0
- package/src/plugins/PluginInterface.ts +1 -2
- package/src/plugins/PluginRegistry.ts +1 -1
- package/src/plugins/hedera/HbarPricePlugin.ts +1 -1
- package/src/plugins/weather/index.ts +15 -4
- package/src/state/open-convai-state.ts +1 -11
- package/src/tools/hcs10/FindRegistrationsTool.ts +1 -1
- package/src/tools/hcs10/RegisterAgentTool.ts +3 -3
- package/src/tools/hcs10/SendMessageToConnectionTool.ts +4 -1
- package/src/tools/hcs10/natural-language-mapper.ts +35 -53
- package/src/tools/hcs2/CreateRegistryTool.ts +1 -1
- package/src/tools/hcs2/DeleteEntryTool.ts +1 -1
- package/src/tools/hcs2/RegisterEntryTool.ts +1 -1
- package/src/tools/hcs2/UpdateEntryTool.ts +1 -1
- package/src/tools/hcs6/CreateDynamicRegistryTool.ts +2 -2
- package/src/tools/hcs6/QueryDynamicRegistryTool.ts +1 -1
- package/src/tools/hcs6/RegisterDynamicHashinalTool.ts +1 -1
- package/src/tools/hcs6/UpdateDynamicHashinalTool.ts +2 -2
- package/src/tools/inscriber/InscribeFromFileTool.ts +2 -11
- package/src/tools/inscriber/InscribeFromUrlTool.ts +15 -19
- package/src/tools/inscriber/InscribeHashinalTool.ts +681 -153
- package/src/tools/inscriber/RetrieveInscriptionTool.ts +34 -12
- package/src/tools/inscriber/base-inscriber-tools.ts +2 -24
- package/src/types/content-resolver.ts +3 -3
- package/src/types/inscription-response.ts +234 -0
- package/src/utils/Encryption.ts +1 -1
- package/src/utils/HederaClient.ts +1 -2
- package/src/utils/metadata-defaults.ts +15 -4
- package/src/utils/state-tools.ts +1 -2
- package/src/validation/content-ref-schemas.ts +2 -2
- package/src/validation/hip412-schemas.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es37.js","sources":["../../src/tools/inscriber/InscribeHashinalTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseInscriberQueryTool } from './base-inscriber-tools';\nimport {\n InscriptionOptions,\n ContentResolverRegistry,\n} from '@hashgraphonline/standards-sdk';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\nimport { validateHIP412Metadata } from '../../validation/hip412-schemas';\nimport { contentRefSchema } from '../../validation/content-ref-schemas';\nimport { generateDefaultMetadata } from '../../utils/metadata-defaults';\n\n\n/**\n * Schema for inscribing Hashinal NFT\n */\nconst inscribeHashinalSchema = z.object({\n url: z\n .string()\n .optional()\n .describe(\n 'The URL of the content to inscribe as Hashinal NFT (use this OR contentRef)'\n ),\n contentRef: contentRefSchema\n .optional()\n .describe(\n 'Content reference ID in format \"content-ref:[id]\" for already stored content (use this OR url)'\n ),\n base64Data: z\n .string()\n .optional()\n .describe(\n 'Base64 encoded content data (use this if neither url nor contentRef provided)'\n ),\n fileName: z\n .string()\n .optional()\n .describe(\n 'File name for the content (required when using base64Data or contentRef)'\n ),\n mimeType: z\n .string()\n .optional()\n .describe('MIME type of the content (e.g., \"image/png\", \"image/jpeg\")'),\n name: z\n .string()\n .optional()\n .describe(\n 'Name of the Hashinal NFT (defaults to filename if not provided)'\n ),\n creator: z\n .string()\n .optional()\n .describe('Creator account ID or name (defaults to operator account)'),\n description: z\n .string()\n .optional()\n .describe(\n 'Description of the Hashinal NFT (auto-generated if not provided)'\n ),\n type: z\n .string()\n .optional()\n .describe('Type of NFT (auto-detected from MIME type if not provided)'),\n attributes: z\n .array(\n z.object({\n trait_type: z.string(),\n value: z.union([z.string(), z.number()]),\n })\n )\n .optional()\n .describe('NFT attributes'),\n properties: z\n .record(z.unknown())\n .optional()\n .describe('Additional properties'),\n jsonFileURL: z\n .string()\n .url()\n .optional()\n .describe('URL to JSON metadata file'),\n fileStandard: z\n .enum(['1', '6'])\n .optional()\n .default('1')\n .describe(\n 'HCS file standard: 1 for static Hashinals (HCS-5), 6 for dynamic Hashinals (HCS-6)'\n ),\n tags: z.array(z.string()).optional().describe('Tags to categorize the NFT'),\n chunkSize: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Chunk size for large files'),\n waitForConfirmation: z\n .boolean()\n .optional()\n .describe('Whether to wait for inscription confirmation'),\n timeoutMs: z\n .number()\n .int()\n .positive()\n .optional()\n .describe(\n 'Timeout in milliseconds for inscription (default: no timeout - waits until completion)'\n ),\n apiKey: z.string().optional().describe('API key for inscription service'),\n quoteOnly: z\n .boolean()\n .optional()\n .default(false)\n .describe(\n 'If true, returns a cost quote instead of executing the inscription'\n ),\n});\n\n/**\n * Tool for inscribing Hashinal NFTs\n */\nexport class InscribeHashinalTool extends BaseInscriberQueryTool<\n typeof inscribeHashinalSchema\n> {\n name = 'inscribeHashinal';\n description =\n 'Use this tool when user wants to inscribe content as a Hashinal for NFT minting (includes keywords: hashinal, dynamic hashinal, static hashinal, NFT inscription, mint). STEP 1: Inscribe content as Hashinal NFT. This tool creates the inscription and returns metadataForMinting (HRL format). CRITICAL: You MUST use the metadataForMinting field from this tool output as the metadata parameter when calling mint NFT tools. DO NOT use the original content reference for minting. This tool only inscribes - call minting tools separately after this completes. IMPORTANT: Set fileStandard=\"6\" for dynamic Hashinals (when user says \"dynamic\") or fileStandard=\"1\" for static Hashinals (default). Accepts base64Data, contentRef, or URL.';\n\n get specificInputSchema() {\n return inscribeHashinalSchema;\n }\n\n protected async executeQuery(\n params: z.infer<typeof inscribeHashinalSchema>,\n _runManager?: CallbackManagerForToolRun\n ): Promise<unknown> {\n // Validate input - must have either url, contentRef, or base64Data\n if (!params.url && !params.contentRef && !params.base64Data) {\n throw new Error(\n 'Must provide either url, contentRef, or base64Data for the Hashinal NFT content'\n );\n }\n\n const operatorAccount =\n this.inscriberBuilder['hederaKit']?.client?.operatorAccountId?.toString() || '0.0.unknown';\n\n const rawMetadata = {\n ...generateDefaultMetadata({\n name: params.name,\n creator: params.creator,\n description: params.description,\n type: params.type,\n fileName: params.fileName,\n mimeType: params.mimeType,\n operatorAccount,\n }),\n attributes: params.attributes,\n properties: params.properties,\n };\n\n // Validate metadata against HIP-412 standard\n let validatedMetadata;\n try {\n validatedMetadata = validateHIP412Metadata(rawMetadata);\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n throw new Error(`Metadata validation error: ${errorMessage}`);\n }\n\n const options: InscriptionOptions = {\n mode: 'hashinal',\n metadata: validatedMetadata,\n jsonFileURL: params.jsonFileURL,\n fileStandard: params.fileStandard,\n tags: params.tags,\n chunkSize: params.chunkSize,\n waitForConfirmation: params.quoteOnly\n ? false\n : params.waitForConfirmation ?? true,\n waitMaxAttempts: 30,\n waitIntervalMs: 5000,\n apiKey: params.apiKey,\n network: this.inscriberBuilder['hederaKit'].client.network\n .toString()\n .includes('mainnet')\n ? 'mainnet'\n : 'testnet',\n quoteOnly: params.quoteOnly,\n };\n\n // Determine inscription data based on input type\n let inscriptionData: any;\n\n if (params.url) {\n inscriptionData = { type: 'url', url: params.url };\n } else if (params.contentRef || params.base64Data) {\n // Handle content reference or base64 data\n const inputData = params.contentRef || params.base64Data || '';\n const { buffer, mimeType, fileName } = await this.resolveContent(\n inputData,\n params.mimeType,\n params.fileName\n );\n\n inscriptionData = {\n type: 'buffer' as const,\n buffer,\n fileName: fileName || params.fileName || 'hashinal-content',\n mimeType: mimeType || params.mimeType,\n };\n }\n\n if (params.quoteOnly) {\n try {\n const quote = await this.generateInscriptionQuote(\n inscriptionData,\n options\n );\n\n return {\n success: true,\n quote: {\n totalCostHbar: quote.totalCostHbar,\n validUntil: quote.validUntil,\n breakdown: quote.breakdown,\n },\n contentInfo: {\n url: params.url,\n name: params.name,\n creator: params.creator,\n type: params.type,\n },\n message: `Estimated Quote for Hashinal NFT: ${params.name}\\nCreator: ${params.creator}\\nTotal cost: ${quote.totalCostHbar} HBAR`,\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : 'Failed to generate inscription quote';\n throw new Error(`Quote generation failed: ${errorMessage}`);\n }\n }\n\n try {\n let result: Awaited<ReturnType<typeof this.inscriberBuilder.inscribe>>;\n\n if (params.timeoutMs) {\n const timeoutPromise = new Promise<never>((_, reject) => {\n setTimeout(\n () =>\n reject(\n new Error(`Inscription timed out after ${params.timeoutMs}ms`)\n ),\n params.timeoutMs\n );\n });\n\n result = await Promise.race([\n this.inscriberBuilder.inscribe(inscriptionData, options),\n timeoutPromise,\n ]);\n } else {\n result = await this.inscriberBuilder.inscribe(inscriptionData, options);\n }\n\n if (result.confirmed && !result.quote) {\n const imageTopicId = result.inscription?.topic_id;\n const jsonTopicId = result.inscription?.jsonTopicId;\n const network = options.network || 'testnet';\n\n const cdnUrl = jsonTopicId\n ? `https://kiloscribe.com/api/inscription-cdn/${jsonTopicId}?network=${network}`\n : null;\n\n const fileStandard = params.fileStandard || '1';\n const hrl = jsonTopicId ? `hcs://${fileStandard}/${jsonTopicId}` : null;\n const standardType = fileStandard === '6' ? 'Dynamic' : 'Static';\n\n return {\n success: true,\n transactionId: (result.result as any).transactionId,\n imageTopicId: imageTopicId || 'N/A',\n jsonTopicId: jsonTopicId || 'N/A',\n metadataForMinting: hrl,\n hcsStandard: `hcs://${fileStandard}`,\n fileStandard: fileStandard,\n standardType: standardType,\n message: `STEP 1 COMPLETE: ${standardType} Hashinal inscription finished! NOW FOR STEP 2: Use EXACTLY this metadata for minting: \"${hrl}\". DO NOT use the original content reference.`,\n cdnUrl: cdnUrl,\n NEXT_STEP_INSTRUCTIONS: `Call mint NFT tool with metadata: [\"${hrl}\"]`,\n WARNING:\n 'DO NOT use content-ref for minting - only use the metadataForMinting value above',\n };\n } else if (!result.quote && !result.confirmed) {\n return `Successfully submitted Hashinal NFT inscription to the Hedera network!\\n\\nTransaction ID: ${\n (result.result as any).transactionId\n }\\n\\nThe inscription is processing and will be confirmed shortly.`;\n } else {\n return 'Inscription operation completed.';\n }\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : 'Failed to inscribe Hashinal NFT';\n throw new Error(`Inscription failed: ${errorMessage}`);\n }\n }\n\n private async resolveContent(\n input: string,\n providedMimeType?: string,\n providedFileName?: string\n ): Promise<{\n buffer: Buffer;\n mimeType?: string;\n fileName?: string;\n wasReference?: boolean;\n }> {\n const trimmedInput = input.trim();\n\n const resolver =\n this.getContentResolver() || ContentResolverRegistry.getResolver();\n\n if (!resolver) {\n return this.handleDirectContent(\n trimmedInput,\n providedMimeType,\n providedFileName\n );\n }\n\n const referenceId = resolver.extractReferenceId(trimmedInput);\n\n if (referenceId) {\n try {\n const resolution = await resolver.resolveReference(referenceId);\n\n return {\n buffer: resolution.content,\n mimeType: resolution.metadata?.mimeType || providedMimeType,\n fileName: resolution.metadata?.fileName || providedFileName,\n wasReference: true,\n };\n } catch (error) {\n const errorMsg =\n error instanceof Error\n ? error.message\n : 'Unknown error resolving reference';\n throw new Error(`Reference resolution failed: ${errorMsg}`);\n }\n }\n\n return this.handleDirectContent(\n trimmedInput,\n providedMimeType,\n providedFileName\n );\n }\n\n private handleDirectContent(\n input: string,\n providedMimeType?: string,\n providedFileName?: string\n ): {\n buffer: Buffer;\n mimeType?: string;\n fileName?: string;\n wasReference?: boolean;\n } {\n const isValidBase64 = /^[A-Za-z0-9+/]*={0,2}$/.test(input);\n\n if (isValidBase64) {\n try {\n const buffer = Buffer.from(input, 'base64');\n return {\n buffer,\n mimeType: providedMimeType,\n fileName: providedFileName,\n wasReference: false,\n };\n } catch (error) {\n throw new Error(\n 'Failed to decode base64 data. Please ensure the data is properly encoded.'\n );\n }\n }\n\n const buffer = Buffer.from(input, 'utf8');\n return {\n buffer,\n mimeType: providedMimeType || 'text/plain',\n fileName: providedFileName,\n wasReference: false,\n };\n }\n}\n"],"names":["buffer"],"mappings":";;;;;;AAeA,MAAM,yBAAyB,EAAE,OAAO;AAAA,EACtC,KAAK,EACF,SACA,WACA;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,YAAY,iBACT,SAAA,EACA;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,YAAY,EACT,SACA,WACA;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MAAM,KAAA;AAE3B,UAAM,WACJ,KAAK,mBAAA,KAAwB,wBAAwB,YAAA;AAEvD,QAAI,CAAC,UAAU;AACb,aAAO,KAAK;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IAEJ;AAEA,UAAM,cAAc,SAAS,mBAAmB,YAAY;AAE5D,QAAI,aAAa;AACf,UAAI;AACF,cAAM,aAAa,MAAM,SAAS,iBAAiB,WAAW;AAE9D,eAAO;AAAA,UACL,QAAQ,WAAW;AAAA,UACnB,UAAU,WAAW,UAAU,YAAY;AAAA,UAC3C,UAAU,WAAW,UAAU,YAAY;AAAA,UAC3C,cAAc;AAAA,QAAA;AAAA,MAElB,SAAS,OAAO;AACd,cAAM,WACJ,iBAAiB,QACb,MAAM,UACN;AACN,cAAM,IAAI,MAAM,gCAAgC,QAAQ,EAAE;AAAA,MAC5D;AAAA,IACF;AAEA,WAAO,KAAK;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AAAA,EAEQ,oBACN,OACA,kBACA,kBAMA;AACA,UAAM,gBAAgB,yBAAyB,KAAK,KAAK;AAEzD,QAAI,eAAe;AACjB,UAAI;AACF,cAAMA,UAAS,OAAO,KAAK,OAAO,QAAQ;AAC1C,eAAO;AAAA,UACL,QAAAA;AAAAA,UACA,UAAU;AAAA,UACV,UAAU;AAAA,UACV,cAAc;AAAA,QAAA;AAAA,MAElB,SAAS,OAAO;AACd,cAAM,IAAI;AAAA,UACR;AAAA,QAAA;AAAA,MAEJ;AAAA,IACF;AAEA,UAAM,SAAS,OAAO,KAAK,OAAO,MAAM;AACxC,WAAO;AAAA,MACL;AAAA,MACA,UAAU,oBAAoB;AAAA,MAC9B,UAAU;AAAA,MACV,cAAc;AAAA,IAAA;AAAA,EAElB;AACF;"}
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es37.js","sources":["../../src/tools/inscriber/InscribeHashinalTool.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { z } from 'zod';\nimport { BaseInscriberQueryTool } from './base-inscriber-tools';\nimport {\n InscriptionOptions,\n InscriptionInput,\n ContentResolverRegistry,\n Logger,\n} from '@hashgraphonline/standards-sdk';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\nimport { validateHIP412Metadata } from '../../validation/hip412-schemas';\nimport { contentRefSchema } from '../../validation/content-ref-schemas';\nimport { generateDefaultMetadata } from '../../utils/metadata-defaults';\nimport {\n extendZodSchema,\n renderConfigs,\n} from '../../lib/zod-render/schema-extension';\nimport type { EnhancedRenderConfig } from '../../lib/zod-render/types';\nimport {\n createInscriptionSuccess,\n createInscriptionQuote,\n createInscriptionError,\n InscriptionResponse,\n} from '../../types/inscription-response';\nimport { FormValidatable } from '../../interfaces/FormValidatable';\n\n/**\n * Network-specific Hashinal block configuration for HashLink blocks\n */\nconst HASHLINK_BLOCK_CONFIG = {\n testnet: {\n blockId: '0.0.6617393',\n hashLink: 'hcs://12/0.0.6617393',\n template: '0.0.6617393',\n },\n mainnet: {\n blockId: '0.0.TBD',\n hashLink: 'hcs://12/0.0.TBD',\n template: '0.0.TBD',\n },\n} as const;\n\n/**\n * Gets the appropriate HashLink block configuration for the specified network.\n * Provides graceful fallback to testnet for unknown networks or undeployed mainnet blocks.\n *\n * @param network The network type to get configuration for\n * @returns Network-specific block configuration with blockId, hashLink, and template\n */\nfunction getHashLinkBlockId(network: 'mainnet' | 'testnet') {\n const config = HASHLINK_BLOCK_CONFIG[network];\n if (!config || config.blockId === '0.0.TBD') {\n return HASHLINK_BLOCK_CONFIG.testnet;\n }\n return config;\n}\n\n/**\n * Result of HCS-12 block lookup\n */\ninterface HCS12BlockResult {\n blockId: string;\n hashLink: string;\n template: string;\n attributes: Record<string, unknown>;\n}\n\n/**\n * Schema for inscribing Hashinal NFT\n */\nconst inscribeHashinalSchema = extendZodSchema(\n z.object({\n url: z\n .string()\n .optional()\n .describe(\n 'The URL of the content to inscribe as Hashinal NFT (use this OR contentRef)'\n ),\n contentRef: contentRefSchema\n .optional()\n .describe(\n 'Content reference ID in format \"content-ref:[id]\" for already stored content (use this OR url)'\n ),\n base64Data: z\n .string()\n .optional()\n .describe(\n 'Base64 encoded content data (use this if neither url nor contentRef provided)'\n ),\n fileName: z\n .string()\n .optional()\n .describe(\n 'File name for the content (required when using base64Data or contentRef)'\n ),\n mimeType: z\n .string()\n .optional()\n .describe('MIME type of the content (e.g., \"image/png\", \"image/jpeg\")'),\n name: z\n .string()\n .optional()\n .describe(\n 'Display name for the NFT (e.g., \"Sunset Landscape #42\", \"Digital Abstract Art\")'\n ),\n creator: z\n .string()\n .optional()\n .describe(\n 'Creator account ID, artist name, or brand (e.g., \"0.0.123456\", \"ArtistName\", \"StudioBrand\")'\n ),\n description: z\n .string()\n .optional()\n .describe(\n 'Meaningful description of the artwork, story, or concept behind this NFT'\n ),\n type: z\n .string()\n .optional()\n .describe(\n 'Category or genre of the NFT (e.g., \"Digital Art\", \"Photography\", \"Collectible Card\")'\n ),\n attributes: extendZodSchema(\n z.array(\n z.object({\n trait_type: z.string(),\n value: z.union([z.string(), z.number()]),\n })\n )\n )\n .withRender(renderConfigs.array('NFT Attributes', 'Attribute'))\n .optional()\n .describe(\n 'Collectible traits and characteristics (e.g., \"Rarity\": \"Epic\", \"Color\": \"Blue\", \"Style\": \"Abstract\")'\n ),\n properties: z\n .record(z.unknown())\n .optional()\n .describe('Additional properties'),\n jsonFileURL: z\n .string()\n .url()\n .optional()\n .describe('URL to JSON metadata file'),\n fileStandard: z\n .enum(['1', '6'])\n .optional()\n .default('1')\n .describe(\n 'HCS file standard: 1 for static Hashinals (HCS-5), 6 for dynamic Hashinals (HCS-6)'\n ),\n tags: z.array(z.string()).optional().describe('Tags to categorize the NFT'),\n chunkSize: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Chunk size for large files'),\n waitForConfirmation: z\n .boolean()\n .optional()\n .describe('Whether to wait for inscription confirmation'),\n timeoutMs: z\n .number()\n .int()\n .positive()\n .optional()\n .describe(\n 'Timeout in milliseconds for inscription (default: no timeout - waits until completion)'\n ),\n quoteOnly: z\n .boolean()\n .optional()\n .default(false)\n .describe(\n 'If true, returns a cost quote instead of executing the inscription'\n ),\n withHashLinkBlocks: z\n .boolean()\n .optional()\n .default(true)\n .describe(\n 'If true, creates interactive HashLink blocks for the inscribed content and returns block data alongside the inscription response'\n ),\n renderForm: z\n .boolean()\n .optional()\n .default(true)\n .describe(\n 'Whether to show a form to collect metadata. Set to false only if user provided complete metadata including name, description, creator, and attributes.'\n ),\n })\n).withRender({\n fieldType: 'object',\n ui: {\n label: 'Inscribe Hashinal NFT',\n description: 'Create a Hashinal inscription for NFT minting',\n },\n});\n\n/**\n * Tool for inscribing Hashinal NFTs\n */\nexport class InscribeHashinalTool\n extends BaseInscriberQueryTool\n implements FormValidatable\n{\n name = 'inscribeHashinal';\n description =\n 'Tool for inscribing Hashinal NFTs. CRITICAL: When user provides content (url/contentRef/base64Data), call with ONLY the content parameters - DO NOT auto-generate name, description, creator, or attributes. A form will be automatically shown to collect metadata from the user. Only include metadata parameters if the user explicitly provided them in their message.';\n\n get specificInputSchema(): z.ZodObject<z.ZodRawShape> {\n const baseSchema =\n (inscribeHashinalSchema as z.ZodType & { _def?: { schema?: z.ZodType } })\n ._def?.schema || inscribeHashinalSchema;\n return baseSchema as z.ZodObject<z.ZodRawShape>;\n }\n\n private _schemaWithRenderConfig?: z.ZodObject<z.ZodRawShape>;\n\n override get schema(): z.ZodObject<z.ZodRawShape> {\n if (!this._schemaWithRenderConfig) {\n const baseSchema = this.specificInputSchema;\n const schemaWithRender = baseSchema as z.ZodObject<z.ZodRawShape> & {\n _renderConfig?: {\n fieldType: string;\n ui: { label: string; description: string };\n };\n };\n\n if (!schemaWithRender._renderConfig) {\n schemaWithRender._renderConfig = {\n fieldType: 'object',\n ui: {\n label: 'Inscribe Hashinal NFT',\n description: 'Create a Hashinal inscription for NFT minting',\n },\n };\n }\n this._schemaWithRenderConfig = baseSchema;\n }\n return this._schemaWithRenderConfig;\n }\n\n /**\n * Implementation of FormValidatable interface\n * Determines if a form should be generated for the given input\n */\n shouldGenerateForm(input: unknown): boolean {\n const logger = new Logger({ module: 'InscribeHashinalTool' });\n const inputObj = input as Record<string, unknown>;\n\n logger.info('InscribeHashinalTool: Checking if form should be generated', {\n inputKeys: Object.keys(inputObj || {}),\n hasContent: !!(\n inputObj.url ||\n inputObj.contentRef ||\n inputObj.base64Data\n ),\n renderFormProvided: 'renderForm' in inputObj,\n renderFormValue: inputObj.renderForm,\n });\n\n const hasContentSource = !!(\n inputObj.url ||\n inputObj.contentRef ||\n inputObj.base64Data\n );\n\n if (!hasContentSource) {\n logger.info('InscribeHashinalTool: No content source provided');\n return false;\n }\n\n if ('renderForm' in inputObj && inputObj.renderForm === false) {\n logger.info(\n 'InscribeHashinalTool: renderForm=false, skipping form generation'\n );\n return false;\n }\n\n const isNonEmptyString = (v: unknown): v is string => {\n if (typeof v !== 'string') {\n return false;\n }\n if (v.trim().length === 0) {\n return false;\n }\n return true;\n };\n\n const hasRequiredMetadata =\n isNonEmptyString(inputObj.name) &&\n isNonEmptyString(inputObj.description) &&\n isNonEmptyString(inputObj.creator);\n\n if (hasRequiredMetadata) {\n logger.info(\n 'InscribeHashinalTool: Required metadata present, skipping form generation'\n );\n return false;\n }\n\n logger.info(\n 'InscribeHashinalTool: Content provided, showing form for metadata collection'\n );\n return true;\n }\n\n /**\n * Implementation of FormValidatable interface\n * Returns the focused schema for form generation\n */\n getFormSchema(): z.ZodObject<z.ZodRawShape> {\n const focusedSchema = extendZodSchema(\n z.object({\n name: z\n .string()\n .min(1, 'Name is required')\n .describe(\n 'Display name for the NFT (e.g., \"Sunset Landscape #42\", \"Digital Abstract Art\")'\n ),\n\n description: z\n .string()\n .min(1, 'Description is required')\n .describe(\n 'Meaningful description of the artwork, story, or concept behind this NFT'\n ),\n\n creator: z\n .string()\n .min(1, 'Creator is required')\n .describe(\n 'Creator account ID, artist name, or brand (e.g., \"0.0.123456\", \"ArtistName\", \"StudioBrand\")'\n ),\n\n attributes: extendZodSchema(\n z.array(\n z.object({\n trait_type: z\n .string()\n .describe('Trait name (e.g., \"Rarity\", \"Color\", \"Style\")'),\n value: z\n .union([z.string(), z.number()])\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .describe('Trait value (e.g., \"Epic\", \"Blue\", 85)'),\n })\n )\n )\n .withRender(\n renderConfigs.array(\n 'NFT Attributes',\n 'Attribute'\n ) as EnhancedRenderConfig\n )\n .optional()\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .describe('Collectible traits and characteristics.'),\n\n type: z\n .string()\n .optional()\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .describe(\n 'Category or genre of the NFT (e.g., \"Digital Art\", \"Photography\", \"Collectible Card)'\n ),\n })\n ).withRender({\n fieldType: 'object',\n ui: {\n label: 'Complete NFT Metadata',\n description: 'Provide meaningful metadata to create a valuable NFT',\n },\n });\n\n return focusedSchema as unknown as z.ZodObject<z.ZodRawShape>;\n }\n\n /**\n * Implementation of FormValidatable interface\n * Validates metadata quality and provides detailed feedback\n */\n validateMetadataQuality(input: unknown): {\n needsForm: boolean;\n reason: string;\n } {\n const inputObj = input as Record<string, unknown>;\n const hasRequiredMetadata = !!(\n inputObj.name &&\n inputObj.description &&\n inputObj.creator\n );\n\n if (!hasRequiredMetadata) {\n return {\n needsForm: true,\n reason:\n 'Missing essential metadata (name, description, creator) for NFT creation',\n };\n }\n\n return {\n needsForm: false,\n reason: 'All required metadata fields present',\n };\n }\n\n protected async executeQuery(\n params: z.infer<typeof inscribeHashinalSchema>,\n _runManager?: CallbackManagerForToolRun\n ): Promise<InscriptionResponse> {\n if (!params.url && !params.contentRef && !params.base64Data) {\n return createInscriptionError({\n code: 'MISSING_CONTENT',\n details: 'No content source provided',\n suggestions: [\n 'Provide a URL to content you want to inscribe',\n 'Upload a file and use the content reference',\n 'Provide base64-encoded content data',\n ],\n });\n }\n\n const operatorAccount =\n this.inscriberBuilder[\n 'hederaKit'\n ]?.client?.operatorAccountId?.toString() || '0.0.unknown';\n\n const rawMetadata = {\n ...generateDefaultMetadata({\n name: params.name,\n creator: params.creator,\n description: params.description,\n type: params.type,\n fileName: params.fileName,\n mimeType: params.mimeType,\n operatorAccount,\n }),\n attributes: Array.isArray(params.attributes) ? params.attributes : [],\n properties:\n (params.properties as Record<string, unknown> | undefined) || {},\n };\n\n let validatedMetadata;\n try {\n validatedMetadata = validateHIP412Metadata(rawMetadata);\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n return createInscriptionError({\n code: 'METADATA_VALIDATION_FAILED',\n details: `Metadata validation error: ${errorMessage}`,\n suggestions: [\n 'Ensure all required metadata fields are provided',\n 'Check that attribute values are valid',\n 'Verify metadata follows HIP-412 standard',\n ],\n });\n }\n\n const options: InscriptionOptions = {\n mode: 'hashinal',\n metadata: validatedMetadata,\n jsonFileURL: params.jsonFileURL,\n fileStandard: params.fileStandard,\n tags: params.tags,\n chunkSize: params.chunkSize,\n waitForConfirmation: params.quoteOnly\n ? false\n : params.waitForConfirmation ?? true,\n waitMaxAttempts: 30,\n waitIntervalMs: 5000,\n network: this.inscriberBuilder['hederaKit'].client.network\n .toString()\n .includes('mainnet')\n ? 'mainnet'\n : 'testnet',\n quoteOnly: params.quoteOnly,\n };\n\n let inscriptionData: InscriptionInput;\n\n if (params.url) {\n inscriptionData = { type: 'url', url: params.url };\n } else if (params.contentRef || params.base64Data) {\n const inputData = params.contentRef || params.base64Data || '';\n const { buffer, mimeType, fileName } = await this.resolveContent(\n inputData,\n params.mimeType,\n params.fileName\n );\n\n inscriptionData = {\n type: 'buffer' as const,\n buffer,\n fileName: fileName || params.fileName || 'hashinal-content',\n mimeType: mimeType || params.mimeType,\n };\n } else {\n throw new Error('No valid input data provided for inscription');\n }\n\n if (params.quoteOnly) {\n try {\n const quote = await this.generateInscriptionQuote(\n inscriptionData,\n options\n );\n\n return createInscriptionQuote({\n totalCostHbar: quote.totalCostHbar,\n validUntil: quote.validUntil,\n breakdown: quote.breakdown,\n content: {\n name: params.name,\n creator: params.creator,\n type: params.type,\n },\n });\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : 'Failed to generate inscription quote';\n return createInscriptionError({\n code: 'QUOTE_GENERATION_FAILED',\n details: `Quote generation failed: ${errorMessage}`,\n suggestions: [\n 'Check network connectivity',\n 'Verify content is accessible',\n 'Try again in a moment',\n ],\n });\n }\n }\n\n try {\n let result: Awaited<ReturnType<typeof this.inscriberBuilder.inscribe>>;\n\n if (params.timeoutMs) {\n const timeoutPromise = new Promise<never>((_, reject) => {\n setTimeout(\n () =>\n reject(\n new Error(`Inscription timed out after ${params.timeoutMs}ms`)\n ),\n params.timeoutMs\n );\n });\n\n result = await Promise.race([\n this.inscriberBuilder.inscribe(inscriptionData, options),\n timeoutPromise,\n ]);\n } else {\n result = await this.inscriberBuilder.inscribe(inscriptionData, options);\n }\n\n if (result.confirmed && !result.quote) {\n const imageTopicId = (\n result.inscription as { topic_id?: string; jsonTopicId?: string }\n )?.topic_id;\n const jsonTopicId = (\n result.inscription as { topic_id?: string; jsonTopicId?: string }\n )?.jsonTopicId;\n const network = options.network || 'testnet';\n\n const cdnUrl = jsonTopicId\n ? `https://kiloscribe.com/api/inscription-cdn/${jsonTopicId}?network=${network}`\n : null;\n\n const fileStandard = params.fileStandard || '1';\n const hrl = jsonTopicId ? `hcs://${fileStandard}/${jsonTopicId}` : null;\n const standardType = fileStandard === '6' ? 'Dynamic' : 'Static';\n\n if (!hrl) {\n return createInscriptionError({\n code: 'MISSING_TOPIC_ID',\n details: 'Inscription completed but topic ID is missing',\n suggestions: [\n 'Try the inscription again',\n 'Contact support if the issue persists',\n ],\n });\n }\n\n const inscriptionResponse = createInscriptionSuccess({\n hrl,\n topicId: jsonTopicId || imageTopicId || 'unknown',\n standard: standardType as 'Static' | 'Dynamic',\n cdnUrl: cdnUrl || undefined,\n transactionId: (result.result as { transactionId?: string })\n ?.transactionId,\n metadata: {\n name: params.name,\n creator: params.creator,\n description: params.description,\n type: params.type,\n attributes: params.attributes,\n },\n });\n\n if (params.withHashLinkBlocks) {\n try {\n const blockData = await this.createHashLinkBlock(\n inscriptionResponse,\n inscriptionData.type === 'buffer'\n ? inscriptionData.mimeType\n : undefined\n );\n\n inscriptionResponse.hashLinkBlock = blockData;\n } catch (blockError) {\n // Log error but don't fail the inscription\n const logger = new Logger({ module: 'InscribeHashinalTool' });\n logger.error('Failed to create HashLink block', {\n error: blockError,\n });\n }\n }\n\n return inscriptionResponse;\n } else if (!result.quote && !result.confirmed) {\n const imageTopicId = (\n result.inscription as { topic_id?: string; jsonTopicId?: string }\n )?.topic_id;\n const jsonTopicId = (\n result.inscription as { topic_id?: string; jsonTopicId?: string }\n )?.jsonTopicId;\n\n if (jsonTopicId || imageTopicId) {\n const network = options.network || 'testnet';\n const cdnUrl = jsonTopicId\n ? `https://kiloscribe.com/api/inscription-cdn/${jsonTopicId}?network=${network}`\n : null;\n\n const fileStandard = params.fileStandard || '1';\n const hrl = jsonTopicId\n ? `hcs://${fileStandard}/${jsonTopicId}`\n : null;\n const standardType = fileStandard === '6' ? 'Dynamic' : 'Static';\n\n if (hrl) {\n const inscriptionResponse = createInscriptionSuccess({\n hrl,\n topicId: jsonTopicId || imageTopicId || 'unknown',\n standard: standardType as 'Static' | 'Dynamic',\n cdnUrl: cdnUrl || undefined,\n transactionId: (result.result as { transactionId?: string })\n ?.transactionId,\n metadata: {\n name: params.name,\n creator: params.creator,\n description: params.description,\n type: params.type,\n attributes: params.attributes,\n },\n });\n\n if (params.withHashLinkBlocks) {\n try {\n const blockData = await this.createHashLinkBlock(\n inscriptionResponse,\n inscriptionData.type === 'buffer'\n ? inscriptionData.mimeType\n : undefined\n );\n\n inscriptionResponse.hashLinkBlock = blockData;\n } catch (blockError) {\n // Log error but don't fail the inscription\n const logger = new Logger({ module: 'InscribeHashinalTool' });\n logger.error('Failed to create HashLink block', {\n error: blockError,\n });\n }\n }\n\n return inscriptionResponse;\n }\n }\n\n const transactionId =\n (result.result as { transactionId?: string })?.transactionId ||\n 'unknown';\n return createInscriptionError({\n code: 'INSCRIPTION_PENDING',\n details: `Inscription submitted but not yet confirmed. Transaction ID: ${transactionId}`,\n suggestions: [\n 'Wait a few moments for confirmation',\n 'Check the transaction status on a Hedera explorer',\n \"Try the inscription again if it doesn't confirm within 5 minutes\",\n ],\n });\n } else {\n return createInscriptionError({\n code: 'UNKNOWN_STATE',\n details: 'Inscription completed but result state is unclear',\n suggestions: [\n 'Check if the inscription was successful manually',\n 'Try the inscription again',\n ],\n });\n }\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : 'Failed to inscribe Hashinal NFT';\n return createInscriptionError({\n code: 'INSCRIPTION_FAILED',\n details: `Inscription failed: ${errorMessage}`,\n suggestions: [\n 'Check network connectivity',\n 'Verify you have sufficient HBAR balance',\n 'Ensure content is accessible and valid',\n 'Try again in a moment',\n ],\n });\n }\n }\n\n /**\n * Creates HashLink block configuration for Hashinal inscriptions.\n * Automatically detects network and selects appropriate block ID configuration.\n * Uses testnet block as fallback for unknown networks or undeployed mainnet blocks.\n *\n * @param response The inscription response containing metadata and network information\n * @param _mimeType Optional MIME type (currently unused, preserved for compatibility)\n * @returns HCS12BlockResult with network-specific block configuration\n *\n * @example\n * ```typescript\n * // Testnet usage (automatic detection from client)\n * const testnetClient = Client.forTestnet();\n * const tool = new InscribeHashinalTool(testnetClient);\n * const block = await tool.createHashLinkBlock(inscriptionResponse);\n * console.log(block.blockId); // '0.0.6617393'\n * console.log(block.hashLink); // 'hcs://12/0.0.6617393'\n *\n * // Mainnet usage (automatic detection from client)\n * const mainnetClient = Client.forMainnet();\n * const tool = new InscribeHashinalTool(mainnetClient);\n * const block = await tool.createHashLinkBlock(inscriptionResponse);\n * console.log(block.blockId); // Network-specific mainnet block ID\n *\n * // HashLink Block Response Structure:\n * {\n * blockId: string; // Hedera account ID format (e.g., '0.0.6617393')\n * hashLink: string; // HCS-12 URL format: 'hcs://12/{blockId}'\n * template: string; // Block template reference matching blockId\n * attributes: { // Metadata for client-side processing\n * name: string; // Content display name\n * creator: string; // Creator account ID\n * topicId: string; // HCS topic containing the inscription\n * hrl: string; // Hedera Resource Locator\n * network: string; // Network type: 'testnet' | 'mainnet'\n * }\n * }\n *\n * // Render function usage in HashLink blocks:\n * // The block's JavaScript render function receives this structure\n * // and can access network-specific resources through attributes.network\n * ```\n */\n private async createHashLinkBlock(\n response: ReturnType<typeof createInscriptionSuccess>,\n _mimeType?: string\n ): Promise<HCS12BlockResult> {\n const clientNetwork = this.inscriberBuilder['hederaKit'].client.network\n .toString()\n .includes('mainnet')\n ? 'mainnet'\n : 'testnet';\n\n const cdnNetwork = response.inscription.cdnUrl?.includes('mainnet')\n ? 'mainnet'\n : 'testnet';\n\n if (clientNetwork !== cdnNetwork) {\n const logger = new Logger({ module: 'InscribeHashinalTool' });\n logger.warn(\n `Network mismatch detected: client=${clientNetwork}, cdn=${cdnNetwork}. Using client network.`\n );\n }\n\n const network = clientNetwork;\n const config = getHashLinkBlockId(network);\n\n return {\n blockId: config.blockId,\n hashLink: config.hashLink,\n template: config.template,\n attributes: {\n name: response.metadata.name || 'Untitled Content',\n creator: response.metadata.creator || '',\n topicId: response.inscription.topicId,\n hrl: response.inscription.hrl,\n network: network,\n },\n };\n }\n\n private async resolveContent(\n input: string,\n providedMimeType?: string,\n providedFileName?: string\n ): Promise<{\n buffer: Buffer;\n mimeType?: string;\n fileName?: string;\n wasReference?: boolean;\n }> {\n const trimmedInput = input.trim();\n\n const resolver =\n this.getContentResolver() || ContentResolverRegistry.getResolver();\n\n if (!resolver) {\n return this.handleDirectContent(\n trimmedInput,\n providedMimeType,\n providedFileName\n );\n }\n\n const referenceId = resolver.extractReferenceId(trimmedInput);\n\n if (referenceId) {\n try {\n const resolution = await resolver.resolveReference(referenceId);\n\n return {\n buffer: resolution.content,\n mimeType: resolution.metadata?.mimeType || providedMimeType,\n fileName: resolution.metadata?.fileName || providedFileName,\n wasReference: true,\n };\n } catch (error) {\n const errorMsg =\n error instanceof Error\n ? error.message\n : 'Unknown error resolving reference';\n throw new Error(`Reference resolution failed: ${errorMsg}`);\n }\n }\n\n return this.handleDirectContent(\n trimmedInput,\n providedMimeType,\n providedFileName\n );\n }\n\n private handleDirectContent(\n input: string,\n providedMimeType?: string,\n providedFileName?: string\n ): {\n buffer: Buffer;\n mimeType?: string;\n fileName?: string;\n wasReference?: boolean;\n } {\n const isValidBase64 = /^[A-Za-z0-9+/]*={0,2}$/.test(input);\n\n if (isValidBase64) {\n try {\n const buffer = Buffer.from(input, 'base64');\n return {\n buffer,\n mimeType: providedMimeType,\n fileName: providedFileName,\n wasReference: false,\n };\n } catch (error) {\n throw new Error(\n 'Failed to decode base64 data. Please ensure the data is properly encoded.'\n );\n }\n }\n\n const buffer = Buffer.from(input, 'utf8');\n return {\n buffer,\n mimeType: providedMimeType || 'text/plain',\n fileName: providedFileName,\n wasReference: false,\n };\n }\n\n /**\n * Implementation of FormValidatable interface\n * Returns essential fields that should always be shown in forms\n */\n getEssentialFields(): string[] {\n return ['name', 'description', 'creator', 'attributes'];\n }\n\n /**\n * Implementation of FormValidatable interface\n * Determines if a field value should be considered empty for this tool\n */\n isFieldEmpty(fieldName: string, value: unknown): boolean {\n if (value === undefined || value === null || value === '') {\n return true;\n }\n\n if (Array.isArray(value) && value.length === 0) {\n return true;\n }\n\n if (fieldName === 'attributes' && Array.isArray(value)) {\n return value.every(\n (attr) =>\n !attr ||\n (typeof attr === 'object' && (!attr.trait_type || !attr.value))\n );\n }\n\n return false;\n }\n}\n"],"names":["buffer"],"mappings":";;;;;;;;AA6BA,MAAM,wBAAwB;AAAA,EAC5B,SAAS;AAAA,IACP,SAAS;AAAA,IACT,UAAU;AAAA,IACV,UAAU;AAAA,EAAA;AAAA,EAEZ,SAAS;AAAA,IACP,SAAS;AAAA,IACT,UAAU;AAAA,IACV,UAAU;AAAA,EAAA;AAEd;AASA,SAAS,mBAAmB,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AAA,EAMA,aAAa,WAAmB,OAAyB;AACvD,QAAI,UAAU,UAAa,UAAU,QAAQ,UAAU,IAAI;AACzD,aAAO;AAAA,IACT;AAEA,QAAI,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW,GAAG;AAC9C,aAAO;AAAA,IACT;AAEA,QAAI,cAAc,gBAAgB,MAAM,QAAQ,KAAK,GAAG;AACtD,aAAO,MAAM;AAAA,QACX,CAAC,SACC,CAAC,QACA,OAAO,SAAS,aAAa,CAAC,KAAK,cAAc,CAAC,KAAK;AAAA,MAAA;AAAA,IAE9D;AAEA,WAAO;AAAA,EACT;AACF;"}
|
|
@@ -21,21 +21,22 @@ class RetrieveInscriptionTool extends BaseInscriberQueryTool {
|
|
|
21
21
|
network: this.inscriberBuilder["hederaKit"].client.network.toString().includes("mainnet") ? "mainnet" : "testnet"
|
|
22
22
|
}
|
|
23
23
|
);
|
|
24
|
+
const typedResult = result;
|
|
24
25
|
return {
|
|
25
|
-
inscriptionId:
|
|
26
|
-
transactionId: result.transactionId,
|
|
27
|
-
topicId:
|
|
28
|
-
status: result.status,
|
|
29
|
-
holderId:
|
|
26
|
+
inscriptionId: typedResult.inscriptionId,
|
|
27
|
+
transactionId: result.transactionId || "unknown",
|
|
28
|
+
topicId: typedResult.topic_id,
|
|
29
|
+
status: result.status || "unknown",
|
|
30
|
+
holderId: typedResult.holderId,
|
|
30
31
|
metadata: result.metadata,
|
|
31
|
-
tags:
|
|
32
|
+
tags: typedResult.tags,
|
|
32
33
|
mode: result.mode,
|
|
33
|
-
chunks:
|
|
34
|
-
createdAt:
|
|
35
|
-
completedAt:
|
|
34
|
+
chunks: typedResult.chunks,
|
|
35
|
+
createdAt: typedResult.createdAt,
|
|
36
|
+
completedAt: typedResult.completed || typedResult.completedAt,
|
|
36
37
|
fileUrl: result.fileUrl,
|
|
37
|
-
mimeType:
|
|
38
|
-
fileSize:
|
|
38
|
+
mimeType: typedResult.mimeType,
|
|
39
|
+
fileSize: typedResult.fileSize
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es38.js","sources":["../../src/tools/inscriber/RetrieveInscriptionTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseInscriberQueryTool } from './base-inscriber-tools';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\n\n/**\n * Schema for retrieving inscription\n */\nconst retrieveInscriptionSchema = z.object({\n transactionId: z\n .string()\n .describe('The transaction ID of the inscription to retrieve'),\n apiKey: z\n .string()\n .optional()\n .describe('API key for inscription service'),\n});\n\n\n/**\n * Tool for retrieving inscriptions\n */\nexport class RetrieveInscriptionTool extends BaseInscriberQueryTool<typeof retrieveInscriptionSchema> {\n name = 'retrieveInscription';\n description = 'Retrieve details of an existing inscription from the Hedera network';\n\n get specificInputSchema() {\n return retrieveInscriptionSchema;\n }\n\n protected async executeQuery(\n params: z.infer<typeof retrieveInscriptionSchema>,\n _runManager?: CallbackManagerForToolRun\n ): Promise<
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es38.js","sources":["../../src/tools/inscriber/RetrieveInscriptionTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseInscriberQueryTool } from './base-inscriber-tools';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\n\n/**\n * Schema for retrieving inscription\n */\nconst retrieveInscriptionSchema = z.object({\n transactionId: z\n .string()\n .describe('The transaction ID of the inscription to retrieve'),\n apiKey: z\n .string()\n .optional()\n .describe('API key for inscription service'),\n});\n\n/**\n * Type definition for inscription retrieval result\n */\ninterface InscriptionRetrievalResult {\n inscriptionId?: string;\n transactionId: string;\n topicId?: string;\n status?: string;\n holderId?: string;\n metadata?: unknown;\n tags?: unknown;\n mode?: string;\n chunks?: unknown;\n createdAt?: string;\n completedAt?: string;\n fileUrl?: string;\n mimeType?: string;\n fileSize?: number;\n}\n\n\n/**\n * Tool for retrieving inscriptions\n */\nexport class RetrieveInscriptionTool extends BaseInscriberQueryTool<typeof retrieveInscriptionSchema> {\n name = 'retrieveInscription';\n description = 'Retrieve details of an existing inscription from the Hedera network';\n\n get specificInputSchema() {\n return retrieveInscriptionSchema;\n }\n\n protected async executeQuery(\n params: z.infer<typeof retrieveInscriptionSchema>,\n _runManager?: CallbackManagerForToolRun\n ): Promise<InscriptionRetrievalResult> {\n const result = await this.inscriberBuilder.retrieveInscription(\n params.transactionId,\n {\n apiKey: params.apiKey,\n network: this.inscriberBuilder['hederaKit'].client.network.toString().includes('mainnet') ? 'mainnet' : 'testnet',\n }\n );\n\n const typedResult = result as unknown as Record<string, unknown>;\n\n return {\n inscriptionId: typedResult.inscriptionId as string | undefined,\n transactionId: result.transactionId || 'unknown',\n topicId: typedResult.topic_id as string | undefined,\n status: result.status || 'unknown',\n holderId: typedResult.holderId as string | undefined,\n metadata: result.metadata,\n tags: typedResult.tags,\n mode: result.mode,\n chunks: typedResult.chunks,\n createdAt: typedResult.createdAt as string | undefined,\n completedAt: (typedResult.completed || typedResult.completedAt) as string | undefined,\n fileUrl: result.fileUrl,\n mimeType: typedResult.mimeType as string | undefined,\n fileSize: typedResult.fileSize as number | undefined,\n };\n }\n}"],"names":[],"mappings":";;AAOA,MAAM,4BAA4B,EAAE,OAAO;AAAA,EACzC,eAAe,EACZ,SACA,SAAS,mDAAmD;AAAA,EAC/D,QAAQ,EACL,OAAA,EACA,SAAA,EACA,SAAS,iCAAiC;AAC/C,CAAC;AA0BM,MAAM,gCAAgC,uBAAyD;AAAA,EAA/F,cAAA;AAAA,UAAA,GAAA,SAAA;AACL,SAAA,OAAO;AACP,SAAA,cAAc;AAAA,EAAA;AAAA,EAEd,IAAI,sBAAsB;AACxB,WAAO;AAAA,EACT;AAAA,EAEA,MAAgB,aACd,QACA,aACqC;AACrC,UAAM,SAAS,MAAM,KAAK,iBAAiB;AAAA,MACzC,OAAO;AAAA,MACP;AAAA,QACE,QAAQ,OAAO;AAAA,QACf,SAAS,KAAK,iBAAiB,WAAW,EAAE,OAAO,QAAQ,WAAW,SAAS,SAAS,IAAI,YAAY;AAAA,MAAA;AAAA,IAC1G;AAGF,UAAM,cAAc;AAEpB,WAAO;AAAA,MACL,eAAe,YAAY;AAAA,MAC3B,eAAe,OAAO,iBAAiB;AAAA,MACvC,SAAS,YAAY;AAAA,MACrB,QAAQ,OAAO,UAAU;AAAA,MACzB,UAAU,YAAY;AAAA,MACtB,UAAU,OAAO;AAAA,MACjB,MAAM,YAAY;AAAA,MAClB,MAAM,OAAO;AAAA,MACb,QAAQ,YAAY;AAAA,MACpB,WAAW,YAAY;AAAA,MACvB,aAAc,YAAY,aAAa,YAAY;AAAA,MACnD,SAAS,OAAO;AAAA,MAChB,UAAU,YAAY;AAAA,MACtB,UAAU,YAAY;AAAA,IAAA;AAAA,EAE1B;AACF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es39.js","sources":["../../src/state/open-convai-state.ts"],"sourcesContent":["import { updateEnvFile } from '../utils/state-tools';\nimport {\n RegisteredAgent,\n ActiveConnection,\n IStateManager,\n AgentPersistenceOptions,\n EnvFilePersistenceOptions,\n ConnectionStatus,\n} from './state-types';\nimport {\n ConnectionsManager,\n HCS10BaseClient,\n Connection,\n Logger,\n IConnectionsManager,\n} from '@hashgraphonline/standards-sdk';\n\n/**\n * Implementation of the IStateManager interface for the OpenConvai system.\n * Manages agent state and connection information with thread safety and\n * proper timestamp tracking.\n */\nexport class OpenConvaiState implements IStateManager {\n private currentAgent: RegisteredAgent | null = null;\n private connectionMessageTimestamps: Record<string, number> = {};\n private defaultEnvFilePath?: string;\n private defaultPrefix: string;\n private connectionsManager: IConnectionsManager | null = null;\n private logger: Logger;\n\n /**\n * Creates a new OpenConvaiState instance\n * @param options - Options for environment variable persistence\n */\n constructor(options?: {\n defaultEnvFilePath?: string;\n defaultPrefix?: string;\n baseClient?: HCS10BaseClient;\n disableLogging?: boolean;\n }) {\n this.defaultEnvFilePath = options?.defaultEnvFilePath;\n this.defaultPrefix = options?.defaultPrefix ?? 'TODD';\n const shouldSilence = options?.disableLogging || process.env.DISABLE_LOGGING === 'true';\n this.logger = new Logger({ module: 'OpenConvaiState', silent: shouldSilence });\n\n // Initialize ConnectionsManager immediately if baseClient is provided\n if (options?.baseClient) {\n this.initializeConnectionsManager(options.baseClient);\n }\n }\n\n /**\n * Initializes the ConnectionsManager\n * @param baseClient - HCS10BaseClient instance to use\n */\n initializeConnectionsManager(\n baseClient: HCS10BaseClient\n ): IConnectionsManager {\n if (!this.connectionsManager) {\n this.logger.debug('Initializing ConnectionsManager');\n this.connectionsManager = new ConnectionsManager({\n baseClient,\n logLevel: 'error',\n });\n } else {\n this.logger.debug('ConnectionsManager already initialized');\n }\n return this.connectionsManager;\n }\n\n /**\n * Gets the ConnectionsManager instance\n * @returns The ConnectionsManager instance, or null if not initialized\n */\n getConnectionsManager(): IConnectionsManager | null {\n return this.connectionsManager;\n }\n\n /**\n * Sets the current active agent and clears any previous connection data.\n * This should be called when switching between agents.\n */\n setCurrentAgent(agent: RegisteredAgent | null): void {\n this.currentAgent = agent;\n this.connectionMessageTimestamps = {};\n\n // Clear connections manager when changing agents\n if (this.connectionsManager) {\n this.connectionsManager.clearAll();\n }\n }\n\n /**\n * Returns the currently active agent or null if none is set.\n */\n getCurrentAgent(): RegisteredAgent | null {\n return this.currentAgent;\n }\n\n /**\n * Adds a new connection to the active connections list.\n * Ensures no duplicates are added based on connectionTopicId.\n * Initializes timestamp tracking for the connection.\n */\n addActiveConnection(connection: ActiveConnection): void {\n if (!this.connectionsManager) {\n this.logger.error(\n 'ConnectionsManager not initialized. Call initializeConnectionsManager before adding connections.'\n );\n throw new Error(\n 'ConnectionsManager not initialized. Call initializeConnectionsManager before adding connections.'\n );\n }\n\n // Convert from ActiveConnection to Connection\n const sdkConnection: Connection = {\n connectionTopicId: connection.connectionTopicId,\n targetAccountId: connection.targetAccountId,\n targetAgentName: connection.targetAgentName,\n targetInboundTopicId: connection.targetInboundTopicId,\n status: this.convertConnectionStatus(connection.status || 'established'),\n isPending: connection.isPending || false,\n needsConfirmation: connection.needsConfirmation || false,\n created: connection.created || new Date(),\n lastActivity: connection.lastActivity,\n profileInfo: connection.profileInfo,\n connectionRequestId: connection.connectionRequestId,\n processed: true,\n };\n\n // Add to ConnectionsManager\n this.connectionsManager.updateOrAddConnection(sdkConnection);\n\n // Initialize timestamp tracking\n this.initializeTimestampIfNeeded(connection.connectionTopicId);\n }\n\n /**\n * Updates an existing connection or adds it if not found.\n * Preserves existing properties when updating by merging objects.\n */\n updateOrAddConnection(connection: ActiveConnection): void {\n this.addActiveConnection(connection);\n }\n\n /**\n * Returns a copy of all active connections.\n */\n listConnections(): ActiveConnection[] {\n if (!this.connectionsManager) {\n this.logger.debug(\n 'ConnectionsManager not initialized, returning empty connections list'\n );\n return [];\n }\n\n // Convert SDK Connections to ActiveConnection\n return this.connectionsManager\n .getAllConnections()\n .map((conn) => this.convertToActiveConnection(conn));\n }\n\n /**\n * Finds a connection by its identifier, which can be:\n * - A 1-based index as displayed in the connection list\n * - A target account ID string\n * - A connection topic ID string\n */\n getConnectionByIdentifier(identifier: string): ActiveConnection | undefined {\n if (!this.connectionsManager) {\n return undefined;\n }\n\n const connections = this.listConnections();\n\n // Check if it's a 1-based index\n const numericIndex = parseInt(identifier) - 1;\n if (\n !isNaN(numericIndex) &&\n numericIndex >= 0 &&\n numericIndex < connections.length\n ) {\n return connections[numericIndex];\n }\n\n // Check if it's a topic ID\n const byTopicId =\n this.connectionsManager.getConnectionByTopicId(identifier);\n if (byTopicId) {\n return this.convertToActiveConnection(byTopicId);\n }\n\n // Check if it's an account ID\n const byAccountId =\n this.connectionsManager.getConnectionByAccountId(identifier);\n if (byAccountId) {\n return this.convertToActiveConnection(byAccountId);\n }\n\n return undefined;\n }\n\n /**\n * Gets the last processed message timestamp for a connection.\n * Returns 0 if no timestamp has been recorded.\n */\n getLastTimestamp(connectionTopicId: string): number {\n return this.connectionMessageTimestamps[connectionTopicId] || 0;\n }\n\n /**\n * Updates the last processed message timestamp for a connection,\n * but only if the new timestamp is more recent than the existing one.\n */\n updateTimestamp(connectionTopicId: string, timestampNanos: number): void {\n // Initialize if this is first update and skip the comparison logic\n if (!(connectionTopicId in this.connectionMessageTimestamps)) {\n this.connectionMessageTimestamps[connectionTopicId] = timestampNanos;\n return;\n }\n\n // Otherwise, only update if newer\n const currentTimestamp =\n this.connectionMessageTimestamps[connectionTopicId];\n if (timestampNanos > currentTimestamp) {\n this.connectionMessageTimestamps[connectionTopicId] = timestampNanos;\n }\n }\n\n /**\n * Helper method to initialize timestamp tracking for a connection\n * if it doesn't already exist.\n */\n private initializeTimestampIfNeeded(connectionTopicId: string): void {\n if (!(connectionTopicId in this.connectionMessageTimestamps)) {\n this.connectionMessageTimestamps[connectionTopicId] =\n Date.now() * 1_000_000;\n }\n }\n\n /**\n * Converts ConnectionStatus to SDK status format\n */\n private convertConnectionStatus(\n status: string\n ): 'pending' | 'established' | 'needs_confirmation' | 'closed' {\n switch (status) {\n case 'pending':\n return 'pending';\n case 'established':\n return 'established';\n case 'needs confirmation':\n return 'needs_confirmation';\n default:\n return 'established';\n }\n }\n\n /**\n * Converts SDK Connection to ActiveConnection\n */\n private convertToActiveConnection(conn: Connection): ActiveConnection {\n return {\n targetAccountId: conn.targetAccountId,\n targetAgentName: conn.targetAgentName || `Agent ${conn.targetAccountId}`,\n targetInboundTopicId: conn.targetInboundTopicId || '',\n connectionTopicId: conn.connectionTopicId,\n status: this.convertToStateStatus(conn.status),\n created: conn.created,\n lastActivity: conn.lastActivity,\n isPending: conn.isPending,\n needsConfirmation: conn.needsConfirmation,\n profileInfo: conn.profileInfo,\n connectionRequestId: conn.connectionRequestId,\n };\n }\n\n /**\n * Converts SDK status to state status format\n */\n private convertToStateStatus(status: string): ConnectionStatus {\n switch (status) {\n case 'pending':\n return 'pending';\n case 'established':\n return 'established';\n case 'needs_confirmation':\n return 'needs confirmation';\n case 'closed':\n return 'established'; // Mapping closed to established for compatibility\n default:\n return 'unknown';\n }\n }\n\n /**\n * Persists agent data to environment variables\n * @param agent - The agent data to persist\n * @param options - Environment file persistence options\n */\n async persistAgentData(\n agent: RegisteredAgent,\n options?: AgentPersistenceOptions\n ): Promise<void> {\n if (options?.type && options.type !== 'env-file') {\n throw new Error(\n `Unsupported persistence type: ${options.type}. Only 'env-file' is supported.`\n );\n }\n\n const envFilePath =\n (options as EnvFilePersistenceOptions)?.envFilePath ||\n this.defaultEnvFilePath ||\n process.env.ENV_FILE_PATH ||\n '.env';\n\n if (!envFilePath) {\n throw new Error(\n 'Environment file path could not be determined for agent data persistence'\n );\n }\n\n const prefix =\n (options as EnvFilePersistenceOptions)?.prefix || this.defaultPrefix;\n\n if (!agent.accountId || !agent.inboundTopicId || !agent.outboundTopicId) {\n throw new Error('Agent data incomplete, cannot persist to environment');\n }\n\n const updates: Record<string, string> = {\n [`${prefix}_ACCOUNT_ID`]: agent.accountId,\n [`${prefix}_INBOUND_TOPIC_ID`]: agent.inboundTopicId,\n [`${prefix}_OUTBOUND_TOPIC_ID`]: agent.outboundTopicId,\n };\n\n if (agent.privateKey) {\n updates[`${prefix}_PRIVATE_KEY`] = agent.privateKey;\n }\n\n if (agent.profileTopicId) {\n updates[`${prefix}_PROFILE_TOPIC_ID`] = agent.profileTopicId;\n }\n\n await updateEnvFile(envFilePath, updates);\n }\n}\n"],"names":[],"mappings":";;AAsBO,MAAM,gBAAyC;AAAA;AAAA;AAAA;AAAA;AAAA,EAYpD,YAAY,SAKT;AAhBH,SAAQ,eAAuC;AAC/C,SAAQ,8BAAsD,CAAA;AAG9D,SAAQ,qBAAiD;AAavD,SAAK,qBAAqB,SAAS;AACnC,SAAK,gBAAgB,SAAS,iBAAiB;AAC/C,UAAM,gBAAgB,SAAS,kBAAkB,QAAQ,IAAI,oBAAoB;AACjF,SAAK,SAAS,IAAI,OAAO,EAAE,QAAQ,mBAAmB,QAAQ,eAAe;AAG7E,QAAI,SAAS,YAAY;A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M,IAAI;AAAA,QACR,iCAAiC,QAAQ,IAAI;AAAA,MAAA;AAAA,IAEjD;AAEA,UAAM,cACH,SAAuC,eACxC,KAAK,sBACL,QAAQ,IAAI,iBACZ;AAQF,UAAM,SACH,SAAuC,UAAU,KAAK;AAEzD,QAAI,CAAC,MAAM,aAAa,CAAC,MAAM,kBAAkB,CAAC,MAAM,iBAAiB;AACvE,YAAM,IAAI,MAAM,sDAAsD;AAAA,IACxE;AAEA,UAAM,UAAkC;AAAA,MACtC,CAAC,GAAG,MAAM,aAAa,GAAG,MAAM;AAAA,MAChC,CAAC,GAAG,MAAM,mBAAmB,GAAG,MAAM;AAAA,MACtC,CAAC,GAAG,MAAM,oBAAoB,GAAG,MAAM;AAAA,IAAA;AAGzC,QAAI,MAAM,YAAY;AACpB,cAAQ,GAAG,MAAM,cAAc,IAAI,MAAM;AAAA,IAC3C;AAEA,QAAI,MAAM,gBAAgB;AACxB,cAAQ,GAAG,MAAM,mBAAmB,IAAI,MAAM;AAAA,IAChD;AAEA,UAAM,cAAc,aAAa,OAAO;AAAA,EAC1C;AACF;"}
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es39.js","sources":["../../src/state/open-convai-state.ts"],"sourcesContent":["import { updateEnvFile } from '../utils/state-tools';\nimport {\n RegisteredAgent,\n ActiveConnection,\n IStateManager,\n AgentPersistenceOptions,\n EnvFilePersistenceOptions,\n ConnectionStatus,\n} from './state-types';\nimport {\n ConnectionsManager,\n HCS10BaseClient,\n Connection,\n Logger,\n IConnectionsManager,\n} from '@hashgraphonline/standards-sdk';\n\n/**\n * Implementation of the IStateManager interface for the OpenConvai system.\n * Manages agent state and connection information with thread safety and\n * proper timestamp tracking.\n */\nexport class OpenConvaiState implements IStateManager {\n private currentAgent: RegisteredAgent | null = null;\n private connectionMessageTimestamps: Record<string, number> = {};\n private defaultEnvFilePath?: string;\n private defaultPrefix: string;\n private connectionsManager: IConnectionsManager | null = null;\n private logger: Logger;\n\n /**\n * Creates a new OpenConvaiState instance\n * @param options - Options for environment variable persistence\n */\n constructor(options?: {\n defaultEnvFilePath?: string;\n defaultPrefix?: string;\n baseClient?: HCS10BaseClient;\n disableLogging?: boolean;\n }) {\n this.defaultEnvFilePath = options?.defaultEnvFilePath;\n this.defaultPrefix = options?.defaultPrefix ?? 'TODD';\n const shouldSilence = options?.disableLogging || process.env.DISABLE_LOGGING === 'true';\n this.logger = new Logger({ module: 'OpenConvaiState', silent: shouldSilence });\n\n if (options?.baseClient) {\n this.initializeConnectionsManager(options.baseClient);\n }\n }\n\n /**\n * Initializes the ConnectionsManager\n * @param baseClient - HCS10BaseClient instance to use\n */\n initializeConnectionsManager(\n baseClient: HCS10BaseClient\n ): IConnectionsManager {\n if (!this.connectionsManager) {\n this.logger.debug('Initializing ConnectionsManager');\n this.connectionsManager = new ConnectionsManager({\n baseClient,\n logLevel: 'error',\n });\n } else {\n this.logger.debug('ConnectionsManager already initialized');\n }\n return this.connectionsManager;\n }\n\n /**\n * Gets the ConnectionsManager instance\n * @returns The ConnectionsManager instance, or null if not initialized\n */\n getConnectionsManager(): IConnectionsManager | null {\n return this.connectionsManager;\n }\n\n /**\n * Sets the current active agent and clears any previous connection data.\n * This should be called when switching between agents.\n */\n setCurrentAgent(agent: RegisteredAgent | null): void {\n this.currentAgent = agent;\n this.connectionMessageTimestamps = {};\n\n if (this.connectionsManager) {\n this.connectionsManager.clearAll();\n }\n }\n\n /**\n * Returns the currently active agent or null if none is set.\n */\n getCurrentAgent(): RegisteredAgent | null {\n return this.currentAgent;\n }\n\n /**\n * Adds a new connection to the active connections list.\n * Ensures no duplicates are added based on connectionTopicId.\n * Initializes timestamp tracking for the connection.\n */\n addActiveConnection(connection: ActiveConnection): void {\n if (!this.connectionsManager) {\n this.logger.error(\n 'ConnectionsManager not initialized. Call initializeConnectionsManager before adding connections.'\n );\n throw new Error(\n 'ConnectionsManager not initialized. Call initializeConnectionsManager before adding connections.'\n );\n }\n\n const sdkConnection: Connection = {\n connectionTopicId: connection.connectionTopicId,\n targetAccountId: connection.targetAccountId,\n targetAgentName: connection.targetAgentName,\n targetInboundTopicId: connection.targetInboundTopicId,\n status: this.convertConnectionStatus(connection.status || 'established'),\n isPending: connection.isPending || false,\n needsConfirmation: connection.needsConfirmation || false,\n created: connection.created || new Date(),\n lastActivity: connection.lastActivity,\n profileInfo: connection.profileInfo,\n connectionRequestId: connection.connectionRequestId,\n processed: true,\n };\n\n this.connectionsManager.updateOrAddConnection(sdkConnection);\n\n this.initializeTimestampIfNeeded(connection.connectionTopicId);\n }\n\n /**\n * Updates an existing connection or adds it if not found.\n * Preserves existing properties when updating by merging objects.\n */\n updateOrAddConnection(connection: ActiveConnection): void {\n this.addActiveConnection(connection);\n }\n\n /**\n * Returns a copy of all active connections.\n */\n listConnections(): ActiveConnection[] {\n if (!this.connectionsManager) {\n this.logger.debug(\n 'ConnectionsManager not initialized, returning empty connections list'\n );\n return [];\n }\n\n return this.connectionsManager\n .getAllConnections()\n .map((conn) => this.convertToActiveConnection(conn));\n }\n\n /**\n * Finds a connection by its identifier, which can be:\n * - A 1-based index as displayed in the connection list\n * - A target account ID string\n * - A connection topic ID string\n */\n getConnectionByIdentifier(identifier: string): ActiveConnection | undefined {\n if (!this.connectionsManager) {\n return undefined;\n }\n\n const connections = this.listConnections();\n\n const numericIndex = parseInt(identifier) - 1;\n if (\n !isNaN(numericIndex) &&\n numericIndex >= 0 &&\n numericIndex < connections.length\n ) {\n return connections[numericIndex];\n }\n\n const byTopicId =\n this.connectionsManager.getConnectionByTopicId(identifier);\n if (byTopicId) {\n return this.convertToActiveConnection(byTopicId);\n }\n\n const byAccountId =\n this.connectionsManager.getConnectionByAccountId(identifier);\n if (byAccountId) {\n return this.convertToActiveConnection(byAccountId);\n }\n\n return undefined;\n }\n\n /**\n * Gets the last processed message timestamp for a connection.\n * Returns 0 if no timestamp has been recorded.\n */\n getLastTimestamp(connectionTopicId: string): number {\n return this.connectionMessageTimestamps[connectionTopicId] || 0;\n }\n\n /**\n * Updates the last processed message timestamp for a connection,\n * but only if the new timestamp is more recent than the existing one.\n */\n updateTimestamp(connectionTopicId: string, timestampNanos: number): void {\n\n if (!(connectionTopicId in this.connectionMessageTimestamps)) {\n this.connectionMessageTimestamps[connectionTopicId] = timestampNanos;\n return;\n }\n\n const currentTimestamp =\n this.connectionMessageTimestamps[connectionTopicId];\n if (timestampNanos > currentTimestamp) {\n this.connectionMessageTimestamps[connectionTopicId] = timestampNanos;\n }\n }\n\n /**\n * Helper method to initialize timestamp tracking for a connection\n * if it doesn't already exist.\n */\n private initializeTimestampIfNeeded(connectionTopicId: string): void {\n if (!(connectionTopicId in this.connectionMessageTimestamps)) {\n this.connectionMessageTimestamps[connectionTopicId] =\n Date.now() * 1_000_000;\n }\n }\n\n /**\n * Converts ConnectionStatus to SDK status format\n */\n private convertConnectionStatus(\n status: string\n ): 'pending' | 'established' | 'needs_confirmation' | 'closed' {\n switch (status) {\n case 'pending':\n return 'pending';\n case 'established':\n return 'established';\n case 'needs confirmation':\n return 'needs_confirmation';\n default:\n return 'established';\n }\n }\n\n /**\n * Converts SDK Connection to ActiveConnection\n */\n private convertToActiveConnection(conn: Connection): ActiveConnection {\n return {\n targetAccountId: conn.targetAccountId,\n targetAgentName: conn.targetAgentName || `Agent ${conn.targetAccountId}`,\n targetInboundTopicId: conn.targetInboundTopicId || '',\n connectionTopicId: conn.connectionTopicId,\n status: this.convertToStateStatus(conn.status),\n created: conn.created,\n lastActivity: conn.lastActivity,\n isPending: conn.isPending,\n needsConfirmation: conn.needsConfirmation,\n profileInfo: conn.profileInfo,\n connectionRequestId: conn.connectionRequestId,\n };\n }\n\n /**\n * Converts SDK status to state status format\n */\n private convertToStateStatus(status: string): ConnectionStatus {\n switch (status) {\n case 'pending':\n return 'pending';\n case 'established':\n return 'established';\n case 'needs_confirmation':\n return 'needs confirmation';\n case 'closed':\n return 'established'; // Mapping closed to established for compatibility\n default:\n return 'unknown';\n }\n }\n\n /**\n * Persists agent data to environment variables\n * @param agent - The agent data to persist\n * @param options - Environment file persistence options\n */\n async persistAgentData(\n agent: RegisteredAgent,\n options?: AgentPersistenceOptions\n ): Promise<void> {\n if (options?.type && options.type !== 'env-file') {\n throw new Error(\n `Unsupported persistence type: ${options.type}. Only 'env-file' is supported.`\n );\n }\n\n const envFilePath =\n (options as EnvFilePersistenceOptions)?.envFilePath ||\n this.defaultEnvFilePath ||\n process.env.ENV_FILE_PATH ||\n '.env';\n\n if (!envFilePath) {\n throw new Error(\n 'Environment file path could not be determined for agent data persistence'\n );\n }\n\n const prefix =\n (options as EnvFilePersistenceOptions)?.prefix || this.defaultPrefix;\n\n if (!agent.accountId || !agent.inboundTopicId || !agent.outboundTopicId) {\n throw new Error('Agent data incomplete, cannot persist to environment');\n }\n\n const updates: Record<string, string> = {\n [`${prefix}_ACCOUNT_ID`]: agent.accountId,\n [`${prefix}_INBOUND_TOPIC_ID`]: agent.inboundTopicId,\n [`${prefix}_OUTBOUND_TOPIC_ID`]: agent.outboundTopicId,\n };\n\n if (agent.privateKey) {\n updates[`${prefix}_PRIVATE_KEY`] = agent.privateKey;\n }\n\n if (agent.profileTopicId) {\n updates[`${prefix}_PROFILE_TOPIC_ID`] = agent.profileTopicId;\n }\n\n await updateEnvFile(envFilePath, updates);\n }\n}\n"],"names":[],"mappings":";;AAsBO,MAAM,gBAAyC;AAAA;AAAA;AAAA;AAAA;AAAA,EAYpD,YAAY,SAKT;AAhBH,SAAQ,eAAuC;AAC/C,SAAQ,8BAAsD,CAAA;AAG9D,SAAQ,qBAAiD;AAavD,SAAK,qBAAqB,SAAS;AACnC,SAAK,gBAAgB,SAAS,iBAAiB;AAC/C,UAAM,gBAAgB,SAAS,kBAAkB,QAAQ,IAAI,oBAAoB;AACjF,SAAK,SAAS,IAAI,OAAO,EAAE,QAAQ,mBAAmB,QAAQ,eAAe;AAE7E,QAAI,SAAS,YAAY;AACvB,WAAK,6BAA6B,QAAQ,UAAU;AAAA,IACtD;AAAA,EACF;AAAA;AAAA;AAAA;AAA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,cACH,SAAuC,eACxC,KAAK,sBACL,QAAQ,IAAI,iBACZ;AAQF,UAAM,SACH,SAAuC,UAAU,KAAK;AAEzD,QAAI,CAAC,MAAM,aAAa,CAAC,MAAM,kBAAkB,CAAC,MAAM,iBAAiB;AACvE,YAAM,IAAI,MAAM,sDAAsD;AAAA,IACxE;AAEA,UAAM,UAAkC;AAAA,MACtC,CAAC,GAAG,MAAM,aAAa,GAAG,MAAM;AAAA,MAChC,CAAC,GAAG,MAAM,mBAAmB,GAAG,MAAM;AAAA,MACtC,CAAC,GAAG,MAAM,oBAAoB,GAAG,MAAM;AAAA,IAAA;AAGzC,QAAI,MAAM,YAAY;AACpB,cAAQ,GAAG,MAAM,cAAc,IAAI,MAAM;AAAA,IAC3C;AAEA,QAAI,MAAM,gBAAgB;AACxB,cAAQ,GAAG,MAAM,mBAAmB,IAAI,MAAM;AAAA,IAChD;AAEA,UAAM,cAAc,aAAa,OAAO;AAAA,EAC1C;AACF;"}
|
|
@@ -13,19 +13,24 @@ import { RetrieveProfileTool } from "./standards-agent-kit.es18.js";
|
|
|
13
13
|
import { ListUnapprovedConnectionRequestsTool } from "./standards-agent-kit.es19.js";
|
|
14
14
|
import { OpenConvaiState } from "./standards-agent-kit.es39.js";
|
|
15
15
|
import { Logger } from "@hashgraphonline/standards-sdk";
|
|
16
|
-
import { ENV_FILE_PATH } from "./standards-agent-kit.
|
|
16
|
+
import { ENV_FILE_PATH } from "./standards-agent-kit.es45.js";
|
|
17
17
|
const initializeStandardsAgentKit = async (options) => {
|
|
18
18
|
const config = options?.clientConfig || {};
|
|
19
19
|
const operatorId = config.operatorId || process.env.HEDERA_OPERATOR_ID;
|
|
20
20
|
const operatorPrivateKey = config.operatorKey || process.env.HEDERA_OPERATOR_KEY;
|
|
21
21
|
const networkEnv = config.network || process.env.HEDERA_NETWORK || "testnet";
|
|
22
|
+
const shouldSilence = process.env.DISABLE_LOGGING === "true";
|
|
23
|
+
const logger = Logger.getInstance({
|
|
24
|
+
level: config.logLevel || "info",
|
|
25
|
+
silent: shouldSilence
|
|
26
|
+
});
|
|
22
27
|
let network;
|
|
23
28
|
if (networkEnv === "mainnet") {
|
|
24
29
|
network = "mainnet";
|
|
25
30
|
} else if (networkEnv === "testnet") {
|
|
26
31
|
network = "testnet";
|
|
27
32
|
} else {
|
|
28
|
-
|
|
33
|
+
logger.warn(
|
|
29
34
|
`Unsupported network specified: '${networkEnv}'. Defaulting to 'testnet'.`
|
|
30
35
|
);
|
|
31
36
|
network = "testnet";
|
|
@@ -35,11 +40,6 @@ const initializeStandardsAgentKit = async (options) => {
|
|
|
35
40
|
"Operator ID and private key must be provided either through options or environment variables."
|
|
36
41
|
);
|
|
37
42
|
}
|
|
38
|
-
const shouldSilence = process.env.DISABLE_LOGGING === "true";
|
|
39
|
-
const logger = Logger.getInstance({
|
|
40
|
-
level: config.logLevel || "info",
|
|
41
|
-
silent: shouldSilence
|
|
42
|
-
});
|
|
43
43
|
const stateManager = options?.stateManager || new OpenConvaiState({
|
|
44
44
|
defaultEnvFilePath: ENV_FILE_PATH,
|
|
45
45
|
defaultPrefix: "TODD"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es40.js","sources":["../../src/init/init.ts"],"sourcesContent":["import { HederaAgentKit, ServerSigner } from 'hedera-agent-kit';\nimport { HCS10Builder } from '../builders/hcs10/hcs10-builder';\nimport { RegisterAgentTool } from '../tools/hcs10/RegisterAgentTool';\nimport { FindRegistrationsTool } from '../tools/hcs10/FindRegistrationsTool';\nimport { InitiateConnectionTool } from '../tools/hcs10/InitiateConnectionTool';\nimport { ListConnectionsTool } from '../tools/hcs10/ListConnectionsTool';\nimport { SendMessageToConnectionTool } from '../tools/hcs10/SendMessageToConnectionTool';\nimport { CheckMessagesTool } from '../tools/hcs10/CheckMessagesTool';\nimport { ConnectionMonitorTool } from '../tools/hcs10/ConnectionMonitorTool';\nimport { ManageConnectionRequestsTool } from '../tools/hcs10/ManageConnectionRequestsTool';\nimport { AcceptConnectionRequestTool } from '../tools/hcs10/AcceptConnectionRequestTool';\nimport { RetrieveProfileTool } from '../tools/hcs10/RetrieveProfileTool';\nimport { ListUnapprovedConnectionRequestsTool } from '../tools/hcs10/ListUnapprovedConnectionRequestsTool';\nimport { IStateManager } from '../state/state-types';\nimport { OpenConvaiState } from '../state/open-convai-state';\nimport { Logger } from '@hashgraphonline/standards-sdk';\nimport { ENV_FILE_PATH } from '../utils/state-tools';\n\nexport interface HCS10ClientConfig {\n operatorId?: string;\n operatorKey?: string;\n network?: 'mainnet' | 'testnet';\n useEncryption?: boolean;\n registryUrl?: string;\n logLevel?: 'debug' | 'info' | 'warn' | 'error';\n}\n\nexport interface HCS10InitializationOptions {\n clientConfig?: HCS10ClientConfig;\n stateManager?: IStateManager;\n createAllTools?: boolean;\n monitoringClient?: boolean;\n}\n\n/**\n * Tool collection containing all available tools from the standards-agent-kit\n */\nexport interface HCS10Tools {\n registerAgentTool: RegisterAgentTool;\n findRegistrationsTool: FindRegistrationsTool;\n retrieveProfileTool: RetrieveProfileTool;\n initiateConnectionTool: InitiateConnectionTool;\n listConnectionsTool: ListConnectionsTool;\n sendMessageToConnectionTool: SendMessageToConnectionTool;\n checkMessagesTool: CheckMessagesTool;\n connectionMonitorTool: ConnectionMonitorTool;\n manageConnectionRequestsTool: ManageConnectionRequestsTool;\n acceptConnectionRequestTool: AcceptConnectionRequestTool;\n listUnapprovedConnectionRequestsTool: ListUnapprovedConnectionRequestsTool;\n}\n\n/**\n * Initializes the HCS10 client and returns pre-registered LangChain tools.\n *\n * @param options - Initialization options\n * @returns Object containing hederaKit, hcs10Builder and requested tools\n */\nexport const initializeStandardsAgentKit = async (\n options?: HCS10InitializationOptions\n): Promise<{\n hederaKit: HederaAgentKit;\n hcs10Builder: HCS10Builder;\n monitoringHederaKit?: HederaAgentKit;\n monitoringHcs10Builder?: HCS10Builder;\n tools: Partial<HCS10Tools>;\n stateManager: IStateManager;\n}> => {\n const config = options?.clientConfig || {};\n\n const operatorId = config.operatorId || process.env.HEDERA_OPERATOR_ID;\n const operatorPrivateKey =\n config.operatorKey || process.env.HEDERA_OPERATOR_KEY;\n\n const networkEnv = config.network || process.env.HEDERA_NETWORK || 'testnet';\n\n let network: 'mainnet' | 'testnet';\n if (networkEnv === 'mainnet') {\n network = 'mainnet';\n } else if (networkEnv === 'testnet') {\n network = 'testnet';\n } else {\n
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es40.js","sources":["../../src/init/init.ts"],"sourcesContent":["import { HederaAgentKit, ServerSigner } from 'hedera-agent-kit';\nimport { HCS10Builder } from '../builders/hcs10/hcs10-builder';\nimport { RegisterAgentTool } from '../tools/hcs10/RegisterAgentTool';\nimport { FindRegistrationsTool } from '../tools/hcs10/FindRegistrationsTool';\nimport { InitiateConnectionTool } from '../tools/hcs10/InitiateConnectionTool';\nimport { ListConnectionsTool } from '../tools/hcs10/ListConnectionsTool';\nimport { SendMessageToConnectionTool } from '../tools/hcs10/SendMessageToConnectionTool';\nimport { CheckMessagesTool } from '../tools/hcs10/CheckMessagesTool';\nimport { ConnectionMonitorTool } from '../tools/hcs10/ConnectionMonitorTool';\nimport { ManageConnectionRequestsTool } from '../tools/hcs10/ManageConnectionRequestsTool';\nimport { AcceptConnectionRequestTool } from '../tools/hcs10/AcceptConnectionRequestTool';\nimport { RetrieveProfileTool } from '../tools/hcs10/RetrieveProfileTool';\nimport { ListUnapprovedConnectionRequestsTool } from '../tools/hcs10/ListUnapprovedConnectionRequestsTool';\nimport { IStateManager } from '../state/state-types';\nimport { OpenConvaiState } from '../state/open-convai-state';\nimport { Logger } from '@hashgraphonline/standards-sdk';\nimport { ENV_FILE_PATH } from '../utils/state-tools';\n\nexport interface HCS10ClientConfig {\n operatorId?: string;\n operatorKey?: string;\n network?: 'mainnet' | 'testnet';\n useEncryption?: boolean;\n registryUrl?: string;\n logLevel?: 'debug' | 'info' | 'warn' | 'error';\n}\n\nexport interface HCS10InitializationOptions {\n clientConfig?: HCS10ClientConfig;\n stateManager?: IStateManager;\n createAllTools?: boolean;\n monitoringClient?: boolean;\n}\n\n/**\n * Tool collection containing all available tools from the standards-agent-kit\n */\nexport interface HCS10Tools {\n registerAgentTool: RegisterAgentTool;\n findRegistrationsTool: FindRegistrationsTool;\n retrieveProfileTool: RetrieveProfileTool;\n initiateConnectionTool: InitiateConnectionTool;\n listConnectionsTool: ListConnectionsTool;\n sendMessageToConnectionTool: SendMessageToConnectionTool;\n checkMessagesTool: CheckMessagesTool;\n connectionMonitorTool: ConnectionMonitorTool;\n manageConnectionRequestsTool: ManageConnectionRequestsTool;\n acceptConnectionRequestTool: AcceptConnectionRequestTool;\n listUnapprovedConnectionRequestsTool: ListUnapprovedConnectionRequestsTool;\n}\n\n/**\n * Initializes the HCS10 client and returns pre-registered LangChain tools.\n *\n * @param options - Initialization options\n * @returns Object containing hederaKit, hcs10Builder and requested tools\n */\nexport const initializeStandardsAgentKit = async (\n options?: HCS10InitializationOptions\n): Promise<{\n hederaKit: HederaAgentKit;\n hcs10Builder: HCS10Builder;\n monitoringHederaKit?: HederaAgentKit;\n monitoringHcs10Builder?: HCS10Builder;\n tools: Partial<HCS10Tools>;\n stateManager: IStateManager;\n}> => {\n const config = options?.clientConfig || {};\n\n const operatorId = config.operatorId || process.env.HEDERA_OPERATOR_ID;\n const operatorPrivateKey =\n config.operatorKey || process.env.HEDERA_OPERATOR_KEY;\n\n const networkEnv = config.network || process.env.HEDERA_NETWORK || 'testnet';\n\n const shouldSilence = process.env.DISABLE_LOGGING === 'true';\n const logger = Logger.getInstance({\n level: config.logLevel || 'info',\n silent: shouldSilence,\n });\n\n let network: 'mainnet' | 'testnet';\n if (networkEnv === 'mainnet') {\n network = 'mainnet';\n } else if (networkEnv === 'testnet') {\n network = 'testnet';\n } else {\n logger.warn(\n `Unsupported network specified: '${networkEnv}'. Defaulting to 'testnet'.`\n );\n network = 'testnet';\n }\n\n if (!operatorId || !operatorPrivateKey) {\n throw new Error(\n 'Operator ID and private key must be provided either through options or environment variables.'\n );\n }\n\n const stateManager =\n options?.stateManager ||\n new OpenConvaiState({\n defaultEnvFilePath: ENV_FILE_PATH,\n defaultPrefix: 'TODD',\n });\n logger.info('State manager initialized');\n\n const signer = new ServerSigner(operatorId, operatorPrivateKey, network);\n const hederaKit = new HederaAgentKit(signer);\n await hederaKit.initialize();\n logger.info(`HederaAgentKit initialized for ${operatorId} on ${network}`);\n\n const hcs10Builder = new HCS10Builder(hederaKit, stateManager, {\n useEncryption: config.useEncryption,\n registryUrl: config.registryUrl,\n logLevel: config.logLevel,\n });\n\n let monitoringHederaKit: HederaAgentKit | undefined;\n let monitoringHcs10Builder: HCS10Builder | undefined;\n\n if (options?.monitoringClient) {\n const monitoringSigner = new ServerSigner(operatorId, operatorPrivateKey, network);\n monitoringHederaKit = new HederaAgentKit(monitoringSigner);\n await monitoringHederaKit.initialize();\n monitoringHcs10Builder = new HCS10Builder(monitoringHederaKit, stateManager, {\n useEncryption: config.useEncryption,\n registryUrl: config.registryUrl,\n logLevel: 'error',\n });\n logger.info('Monitoring client initialized');\n }\n\n const tools: Partial<HCS10Tools> = {};\n\n tools.registerAgentTool = new RegisterAgentTool({\n hederaKit,\n hcs10Builder,\n logger: undefined,\n });\n\n if (options?.createAllTools) {\n tools.findRegistrationsTool = new FindRegistrationsTool({\n hederaKit,\n hcs10Builder,\n logger: undefined,\n });\n tools.retrieveProfileTool = new RetrieveProfileTool({\n hederaKit,\n hcs10Builder,\n logger: undefined,\n });\n tools.initiateConnectionTool = new InitiateConnectionTool({\n hederaKit,\n hcs10Builder,\n logger: undefined,\n });\n tools.listConnectionsTool = new ListConnectionsTool({\n hederaKit,\n hcs10Builder,\n logger: undefined,\n });\n tools.sendMessageToConnectionTool = new SendMessageToConnectionTool({\n hederaKit,\n hcs10Builder,\n logger: undefined,\n });\n tools.checkMessagesTool = new CheckMessagesTool({\n hederaKit,\n hcs10Builder,\n logger: undefined,\n });\n tools.connectionMonitorTool = new ConnectionMonitorTool({\n hederaKit: monitoringHederaKit || hederaKit,\n hcs10Builder: monitoringHcs10Builder || hcs10Builder,\n logger: undefined,\n });\n tools.manageConnectionRequestsTool = new ManageConnectionRequestsTool({\n hederaKit,\n hcs10Builder,\n logger: undefined,\n });\n tools.acceptConnectionRequestTool = new AcceptConnectionRequestTool({\n hederaKit,\n hcs10Builder,\n logger: undefined,\n });\n tools.listUnapprovedConnectionRequestsTool =\n new ListUnapprovedConnectionRequestsTool({\n hederaKit,\n hcs10Builder,\n logger: undefined,\n });\n\n logger.info('All tools initialized');\n }\n\n return {\n hederaKit,\n hcs10Builder,\n monitoringHederaKit,\n monitoringHcs10Builder,\n tools,\n stateManager,\n };\n};"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAyDO,MAAM,8BAA8B,OACzC,YAQI;AACJ,QAAM,SAAS,SAAS,gBAAgB,CAAA;AAExC,QAAM,aAAa,OAAO,cAAc,QAAQ,IAAI;AACpD,QAAM,qBACJ,OAAO,eAAe,QAAQ,IAAI;AAEpC,QAAM,aAAa,OAAO,WAAW,QAAQ,IAAI,kBAAkB;AAEnE,QAAM,gBAAgB,QAAQ,IAAI,oBAAoB;AACtD,QAAM,SAAS,OAAO,YAAY;AAAA,IAChC,OAAO,OAAO,YAAY;AAAA,IAC1B,QAAQ;AAAA,EAAA,CACT;AAED,MAAI;AACJ,MAAI,eAAe,WAAW;AAC5B,cAAU;AAAA,EACZ,WAAW,eAAe,WAAW;AACnC,cAAU;AAAA,EACZ,OAAO;AACL,WAAO;AAAA,MACL,mCAAmC,UAAU;AAAA,IAAA;AAE/C,cAAU;AAAA,EACZ;AAEA,MAAI,CAAC,cAAc,CAAC,oBAAoB;AACtC,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAAA,EAEJ;AAEA,QAAM,eACJ,SAAS,gBACT,IAAI,gBAAgB;AAAA,IAClB,oBAAoB;AAAA,IACpB,eAAe;AAAA,EAAA,CAChB;AACH,SAAO,KAAK,2BAA2B;AAEvC,QAAM,SAAS,IAAI,a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kBAAkB;AAAA,MAC9C;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,IAAA,CACT;AACD,UAAM,wBAAwB,IAAI,sBAAsB;AAAA,MACtD,WAAW,uBAAuB;AAAA,MAClC,cAAc,0BAA0B;AAAA,MACxC,QAAQ;AAAA,IAAA,CACT;AACD,UAAM,+BAA+B,IAAI,6BAA6B;AAAA,MACpE;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,IAAA,CACT;AACD,UAAM,8BAA8B,IAAI,4BAA4B;AAAA,MAClE;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,IAAA,CACT;AACD,UAAM,uCACJ,IAAI,qCAAqC;AAAA,MACvC;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,IAAA,CACT;AAEH,WAAO,KAAK,uBAAuB;AAAA,EACrC;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es41.js","sources":["../../src/plugins/hedera/HbarPricePlugin.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es41.js","sources":["../../src/plugins/hedera/HbarPricePlugin.ts"],"sourcesContent":["\nexport { HederaGetHbarPriceTool as GetHbarPriceTool } from 'hedera-agent-kit';\n\nimport { BasePlugin, GenericPluginContext, HederaTool, HederaAgentKit } from 'hedera-agent-kit';\nimport { HederaGetHbarPriceTool } from 'hedera-agent-kit';\n\n/**\n * Plugin to provide tools related to Hedera network information, like HBAR price.\n * Uses the built-in HederaGetHbarPriceTool from hedera-agent-kit.\n */\nexport class HbarPricePlugin extends BasePlugin<GenericPluginContext> {\n id = 'hedera-hbar-price';\n name = 'Hedera HBAR Price Plugin';\n description = 'Provides tools to interact with Hedera network data, specifically HBAR price.';\n version = '1.0.0';\n author = 'Hashgraph Online';\n\n private tools: HederaTool[] = [];\n\n override async initialize(context: GenericPluginContext): Promise<void> {\n await super.initialize(context);\n this.initializeTools();\n }\n\n private initializeTools(): void {\n this.tools = [\n new HederaGetHbarPriceTool({\n hederaKit: this.context.config.hederaKit as HederaAgentKit,\n logger: this.context.logger\n })\n ];\n }\n\n getTools(): HederaTool[] {\n return this.tools;\n }\n}"],"names":["HederaGetHbarPriceTool"],"mappings":";;AAUO,MAAM,wBAAwB,WAAiC;AAAA,EAA/D,cAAA;AAAA,UAAA,GAAA,SAAA;AACL,SAAA,KAAK;AACL,SAAA,OAAO;AACP,SAAA,cAAc;AACd,SAAA,UAAU;AACV,SAAA,SAAS;AAET,SAAQ,QAAsB,CAAA;AAAA,EAAC;AAAA,EAE/B,MAAe,WAAW,SAA8C;AACtE,UAAM,MAAM,WAAW,OAAO;AAC9B,SAAK,gBAAA;AAAA,EACP;AAAA,EAEQ,kBAAwB;AAC9B,SAAK,QAAQ;AAAA,MACX,IAAIA,uBAAuB;AAAA,QACzB,WAAW,KAAK,QAAQ,OAAO;AAAA,QAC/B,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,IAAA;AAAA,EAEL;AAAA,EAEA,WAAyB;AACvB,WAAO,KAAK;AAAA,EACd;AACF;"}
|