@hashgraphonline/standards-agent-kit 0.2.112 → 0.2.113
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/index.d.ts +1 -1
- package/dist/cjs/standards-agent-kit.cjs +1 -1
- package/dist/cjs/standards-agent-kit.cjs.map +1 -1
- package/dist/cjs/tools/hcs6/CreateDynamicRegistryTool.d.ts +44 -0
- package/dist/cjs/tools/hcs6/QueryDynamicRegistryTool.d.ts +50 -0
- package/dist/cjs/tools/hcs6/RegisterDynamicHashinalTool.d.ts +102 -0
- package/dist/cjs/tools/hcs6/UpdateDynamicHashinalTool.d.ts +96 -0
- package/dist/cjs/tools/hcs6/base-hcs6-tools.d.ts +28 -0
- package/dist/cjs/tools/hcs6/hcs6-tool-params.d.ts +18 -0
- package/dist/cjs/tools/hcs6/index.d.ts +6 -0
- package/dist/cjs/tools/index.d.ts +1 -0
- package/dist/cjs/tools/inscriber/InscribeFromBufferTool.d.ts +4 -4
- package/dist/es/index.d.ts +1 -1
- package/dist/es/standards-agent-kit.es.js +44 -31
- package/dist/es/standards-agent-kit.es.js.map +1 -1
- package/dist/es/standards-agent-kit.es10.js +27 -27
- package/dist/es/standards-agent-kit.es10.js.map +1 -1
- package/dist/es/standards-agent-kit.es11.js +20 -30
- package/dist/es/standards-agent-kit.es11.js.map +1 -1
- package/dist/es/standards-agent-kit.es12.js +27 -37
- package/dist/es/standards-agent-kit.es12.js.map +1 -1
- package/dist/es/standards-agent-kit.es13.js +48 -60
- package/dist/es/standards-agent-kit.es13.js.map +1 -1
- package/dist/es/standards-agent-kit.es14.js +60 -23
- package/dist/es/standards-agent-kit.es14.js.map +1 -1
- package/dist/es/standards-agent-kit.es15.js +23 -23
- package/dist/es/standards-agent-kit.es15.js.map +1 -1
- package/dist/es/standards-agent-kit.es16.js +23 -33
- package/dist/es/standards-agent-kit.es16.js.map +1 -1
- package/dist/es/standards-agent-kit.es17.js +34 -10
- package/dist/es/standards-agent-kit.es17.js.map +1 -1
- package/dist/es/standards-agent-kit.es18.js +16 -155
- package/dist/es/standards-agent-kit.es18.js.map +1 -1
- package/dist/es/standards-agent-kit.es19.js +150 -22
- package/dist/es/standards-agent-kit.es19.js.map +1 -1
- package/dist/es/standards-agent-kit.es20.js +25 -39
- package/dist/es/standards-agent-kit.es20.js.map +1 -1
- package/dist/es/standards-agent-kit.es21.js +26 -28
- package/dist/es/standards-agent-kit.es21.js.map +1 -1
- package/dist/es/standards-agent-kit.es22.js +16 -19
- package/dist/es/standards-agent-kit.es22.js.map +1 -1
- package/dist/es/standards-agent-kit.es23.js +21 -15
- package/dist/es/standards-agent-kit.es23.js.map +1 -1
- package/dist/es/standards-agent-kit.es24.js +18 -21
- package/dist/es/standards-agent-kit.es24.js.map +1 -1
- package/dist/es/standards-agent-kit.es25.js +35 -32
- package/dist/es/standards-agent-kit.es25.js.map +1 -1
- package/dist/es/standards-agent-kit.es26.js +38 -25
- package/dist/es/standards-agent-kit.es26.js.map +1 -1
- package/dist/es/standards-agent-kit.es27.js +25 -116
- package/dist/es/standards-agent-kit.es27.js.map +1 -1
- package/dist/es/standards-agent-kit.es28.js +33 -166
- package/dist/es/standards-agent-kit.es28.js.map +1 -1
- package/dist/es/standards-agent-kit.es29.js +42 -121
- package/dist/es/standards-agent-kit.es29.js.map +1 -1
- package/dist/es/standards-agent-kit.es30.js +40 -77
- package/dist/es/standards-agent-kit.es30.js.map +1 -1
- package/dist/es/standards-agent-kit.es31.js +42 -37
- package/dist/es/standards-agent-kit.es31.js.map +1 -1
- package/dist/es/standards-agent-kit.es32.js +20 -237
- package/dist/es/standards-agent-kit.es32.js.map +1 -1
- package/dist/es/standards-agent-kit.es33.js +154 -135
- package/dist/es/standards-agent-kit.es33.js.map +1 -1
- package/dist/es/standards-agent-kit.es34.js +168 -23
- package/dist/es/standards-agent-kit.es34.js.map +1 -1
- package/dist/es/standards-agent-kit.es35.js +126 -21
- package/dist/es/standards-agent-kit.es35.js.map +1 -1
- package/dist/es/standards-agent-kit.es36.js +86 -3
- package/dist/es/standards-agent-kit.es36.js.map +1 -1
- package/dist/es/standards-agent-kit.es37.js +45 -0
- package/dist/es/standards-agent-kit.es37.js.map +1 -0
- package/dist/es/standards-agent-kit.es38.js +249 -0
- package/dist/es/standards-agent-kit.es38.js.map +1 -0
- package/dist/es/standards-agent-kit.es39.js +141 -0
- package/dist/es/standards-agent-kit.es39.js.map +1 -0
- package/dist/es/standards-agent-kit.es4.js +65 -32
- package/dist/es/standards-agent-kit.es4.js.map +1 -1
- package/dist/es/standards-agent-kit.es40.js +33 -0
- package/dist/es/standards-agent-kit.es40.js.map +1 -0
- package/dist/es/standards-agent-kit.es41.js +28 -0
- package/dist/es/standards-agent-kit.es41.js.map +1 -0
- package/dist/es/standards-agent-kit.es42.js +7 -0
- package/dist/es/standards-agent-kit.es42.js.map +1 -0
- package/dist/es/standards-agent-kit.es5.js +35 -311
- package/dist/es/standards-agent-kit.es5.js.map +1 -1
- package/dist/es/standards-agent-kit.es6.js +320 -20
- package/dist/es/standards-agent-kit.es6.js.map +1 -1
- package/dist/es/standards-agent-kit.es7.js +19 -227
- package/dist/es/standards-agent-kit.es7.js.map +1 -1
- package/dist/es/standards-agent-kit.es8.js +216 -65
- package/dist/es/standards-agent-kit.es8.js.map +1 -1
- package/dist/es/standards-agent-kit.es9.js +72 -23
- package/dist/es/standards-agent-kit.es9.js.map +1 -1
- package/dist/es/tools/hcs6/CreateDynamicRegistryTool.d.ts +44 -0
- package/dist/es/tools/hcs6/QueryDynamicRegistryTool.d.ts +50 -0
- package/dist/es/tools/hcs6/RegisterDynamicHashinalTool.d.ts +102 -0
- package/dist/es/tools/hcs6/UpdateDynamicHashinalTool.d.ts +96 -0
- package/dist/es/tools/hcs6/base-hcs6-tools.d.ts +28 -0
- package/dist/es/tools/hcs6/hcs6-tool-params.d.ts +18 -0
- package/dist/es/tools/hcs6/index.d.ts +6 -0
- package/dist/es/tools/index.d.ts +1 -0
- package/dist/es/tools/inscriber/InscribeFromBufferTool.d.ts +4 -4
- package/dist/umd/index.d.ts +1 -1
- 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/hcs6/CreateDynamicRegistryTool.d.ts +44 -0
- package/dist/umd/tools/hcs6/QueryDynamicRegistryTool.d.ts +50 -0
- package/dist/umd/tools/hcs6/RegisterDynamicHashinalTool.d.ts +102 -0
- package/dist/umd/tools/hcs6/UpdateDynamicHashinalTool.d.ts +96 -0
- package/dist/umd/tools/hcs6/base-hcs6-tools.d.ts +28 -0
- package/dist/umd/tools/hcs6/hcs6-tool-params.d.ts +18 -0
- package/dist/umd/tools/hcs6/index.d.ts +6 -0
- package/dist/umd/tools/index.d.ts +1 -0
- package/dist/umd/tools/inscriber/InscribeFromBufferTool.d.ts +4 -4
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/tools/hcs6/CreateDynamicRegistryTool.ts +66 -0
- package/src/tools/hcs6/QueryDynamicRegistryTool.ts +72 -0
- package/src/tools/hcs6/RegisterDynamicHashinalTool.ts +79 -0
- package/src/tools/hcs6/UpdateDynamicHashinalTool.ts +74 -0
- package/src/tools/hcs6/base-hcs6-tools.ts +63 -0
- package/src/tools/hcs6/hcs6-tool-params.ts +21 -0
- package/src/tools/hcs6/index.ts +6 -0
- package/src/tools/index.ts +1 -0
- package/src/tools/inscriber/InscribeFromBufferTool.ts +1 -1
- package/src/tools/inscriber/InscribeFromUrlTool.ts +60 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es7.js","sources":["../../src/tools/hcs10/RegisterAgentTool.ts"],"sourcesContent":["import { AIAgentCapability } from '@hashgraphonline/standards-sdk';\nimport { z } from 'zod';\nimport { BaseServiceBuilder } from 'hedera-agent-kit';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\nimport {\n HCS10Builder,\n RegisterAgentParams,\n} from '../../builders/hcs10/hcs10-builder';\nimport { BaseHCS10TransactionTool } from './base-hcs10-tools';\nimport { HCS10TransactionToolParams } from './hcs10-tool-params';\nimport { RegisteredAgent } from '../../state/state-types';\nimport { NaturalLanguageMapper } from './natural-language-mapper';\n\nconst RegisterAgentZodSchema = z.object({\n name: z\n .string()\n .min(1)\n .max(50)\n .describe('A unique name for the agent (1-50 characters)'),\n description: z\n .string()\n .max(500)\n .optional()\n .describe('Optional bio description for the agent (max 500 characters)'),\n alias: z\n .string()\n .optional()\n .transform((val) => {\n if (!val || val.toLowerCase().includes('random')) {\n const timestamp = Date.now().toString(36);\n const randomChars = Math.random().toString(36);\n return `bot${timestamp}${randomChars}`;\n }\n return val;\n })\n .describe(\n 'Optional custom username/alias for the agent. Use \"random\" to generate a unique alias'\n ),\n type: z\n .enum(['autonomous', 'manual'])\n .optional()\n .describe('Agent type (default: autonomous)'),\n model: z\n .string()\n .optional()\n .describe('AI model identifier (default: agent-model-2024)'),\n capabilities: z\n .union([\n z.array(z.nativeEnum(AIAgentCapability)),\n z.array(z.string()),\n z.string(),\n ])\n .optional()\n .transform((val) => {\n if (!val) return undefined;\n if (typeof val === 'string') {\n return NaturalLanguageMapper.parseCapabilities(val);\n }\n if (Array.isArray(val) && val.length > 0 && typeof val[0] === 'string') {\n return NaturalLanguageMapper.parseTagsOrCapabilities(val);\n }\n return val as AIAgentCapability[];\n })\n .describe('Agent capabilities - can be capability names (e.g. \"ai\", \"data processing\"), capability enum values, or array of either. Common values: \"ai\"/\"text\" (TEXT_GENERATION), \"data\" (DATA_INTEGRATION), \"analytics\" (TRANSACTION_ANALYTICS)'),\n tags: z\n .union([\n z.array(z.string()),\n z.string(),\n ])\n .optional()\n .transform((val) => {\n if (!val) return undefined;\n if (typeof val === 'string') {\n return NaturalLanguageMapper.parseCapabilities(val);\n }\n return NaturalLanguageMapper.parseTagsOrCapabilities(val);\n })\n .describe('Tags for the agent (alternative to capabilities) - e.g. \"ai\", \"data\", \"analytics\". Will be converted to appropriate capabilities.'),\n creator: z.string().optional().describe('Creator attribution for the agent'),\n socials: z\n .record(\n z.enum([\n 'twitter',\n 'github',\n 'discord',\n 'telegram',\n 'linkedin',\n 'youtube',\n 'website',\n 'x',\n ] as const),\n z.string()\n )\n .optional()\n .describe(\n 'Social media links (e.g., {\"twitter\": \"@handle\", \"discord\": \"username\"})'\n ),\n properties: z\n .record(z.unknown())\n .optional()\n .describe('Custom metadata properties for the agent'),\n profilePicture: z\n .union([\n z.string().describe('URL or local file path to profile picture'),\n z.object({\n url: z.string().optional(),\n path: z.string().optional(),\n filename: z.string().optional(),\n }),\n ])\n .optional()\n .describe(\n 'Optional profile picture as URL, file path, or object with url/path/filename'\n ),\n existingProfilePictureTopicId: z\n .string()\n .optional()\n .describe(\n 'Topic ID of an existing profile picture to reuse (e.g., 0.0.12345)'\n ),\n initialBalance: z\n .number()\n .positive()\n .optional()\n .describe(\n 'Optional initial HBAR balance for the new agent account (will create new account if provided)'\n ),\n userAccountId: z\n .string()\n .optional()\n .describe(\n 'Optional account ID (e.g., 0.0.12345) to use as the agent account instead of creating a new one'\n ),\n hbarFee: z\n .number()\n .positive()\n .optional()\n .describe(\n 'Optional HBAR fee amount to charge per message on the inbound topic'\n ),\n tokenFees: z\n .array(\n z.object({\n amount: z.number().positive(),\n tokenId: z.string(),\n })\n )\n .optional()\n .describe('Optional token fees to charge per message'),\n exemptAccountIds: z\n .array(z.string())\n .optional()\n .describe('Optional account IDs to exempt from fees'),\n setAsCurrent: z\n .boolean()\n .optional()\n .describe('Whether to set as current agent (default: true)'),\n persistence: z\n .object({\n prefix: z.string().optional(),\n })\n .optional()\n .describe('Optional persistence configuration'),\n});\n\nexport class RegisterAgentTool extends BaseHCS10TransactionTool<\n typeof RegisterAgentZodSchema\n> {\n name = 'register_agent';\n description =\n 'Creates and registers the AI agent on the Hedera network. Returns JSON string with agent details (accountId, privateKey, topics) on success. Supports natural language for capabilities/tags like \"ai\", \"data processing\", \"analytics\". Note: This tool requires multiple transactions and cannot be used in returnBytes mode. If alias is set to \"random\" or contains \"random\", a unique alias will be generated.';\n specificInputSchema = RegisterAgentZodSchema;\n private specificArgs: z.infer<typeof RegisterAgentZodSchema> | undefined;\n\n constructor(params: HCS10TransactionToolParams) {\n super(params);\n this.neverScheduleThisTool = true;\n this.requiresMultipleTransactions = true;\n }\n\n protected async callBuilderMethod(\n builder: BaseServiceBuilder,\n specificArgs: z.infer<typeof RegisterAgentZodSchema>\n ): Promise<void> {\n const hcs10Builder = builder as HCS10Builder;\n this.specificArgs = specificArgs;\n const params: RegisterAgentParams = {\n name: specificArgs.name,\n };\n\n if (specificArgs.description !== undefined) {\n params.bio = specificArgs.description;\n }\n if (specificArgs.alias !== undefined) {\n params.alias = specificArgs.alias;\n } else {\n const randomSuffix = Date.now().toString(36);\n params.alias = `${specificArgs.name}${randomSuffix}`;\n }\n if (specificArgs.type !== undefined) {\n params.type = specificArgs.type;\n }\n if (specificArgs.model !== undefined) {\n params.model = specificArgs.model;\n }\n // Handle both capabilities and tags (tags takes precedence if both provided)\n if (specificArgs.tags !== undefined) {\n params.capabilities = specificArgs.tags as AIAgentCapability[];\n } else if (specificArgs.capabilities !== undefined) {\n params.capabilities = specificArgs.capabilities as AIAgentCapability[];\n }\n if (specificArgs.creator !== undefined) {\n params.creator = specificArgs.creator;\n }\n if (specificArgs.socials !== undefined) {\n params.socials = specificArgs.socials;\n }\n if (specificArgs.properties !== undefined) {\n params.properties = specificArgs.properties;\n }\n if (specificArgs.profilePicture !== undefined) {\n if (typeof specificArgs.profilePicture === 'string') {\n params.profilePicture = specificArgs.profilePicture;\n } else {\n const profilePicObj: {\n url?: string;\n path?: string;\n filename?: string;\n } = {};\n if (specificArgs.profilePicture.url !== undefined) {\n profilePicObj.url = specificArgs.profilePicture.url;\n }\n if (specificArgs.profilePicture.path !== undefined) {\n profilePicObj.path = specificArgs.profilePicture.path;\n }\n if (specificArgs.profilePicture.filename !== undefined) {\n profilePicObj.filename = specificArgs.profilePicture.filename;\n }\n params.profilePicture = profilePicObj;\n }\n }\n if (specificArgs.existingProfilePictureTopicId !== undefined) {\n params.existingProfilePictureTopicId =\n specificArgs.existingProfilePictureTopicId;\n }\n if (specificArgs.userAccountId !== undefined) {\n params.userAccountId = specificArgs.userAccountId;\n }\n if (specificArgs.hbarFee !== undefined) {\n params.hbarFee = specificArgs.hbarFee;\n }\n if (specificArgs.tokenFees !== undefined) {\n params.tokenFees = specificArgs.tokenFees;\n }\n if (specificArgs.exemptAccountIds !== undefined) {\n params.exemptAccountIds = specificArgs.exemptAccountIds;\n }\n if (specificArgs.initialBalance !== undefined) {\n params.initialBalance = specificArgs.initialBalance;\n }\n\n await hcs10Builder.registerAgent(params);\n }\n\n /**\n * Override _call to intercept the result and save agent to state if needed\n */\n protected override async _call(\n args: z.infer<ReturnType<this['schema']>>,\n runManager?: CallbackManagerForToolRun\n ): Promise<string> {\n const result = await super._call(args, runManager);\n\n const shouldSetAsCurrent = this.specificArgs?.setAsCurrent !== false;\n\n if (this.specificArgs && shouldSetAsCurrent) {\n try {\n const parsed = JSON.parse(result);\n if (parsed.rawResult) {\n this._handleRegistrationResult(parsed.rawResult);\n } else if (parsed.state || parsed.accountId || parsed.metadata) {\n this._handleRegistrationResult(parsed);\n }\n } catch (e) {}\n }\n\n return result;\n }\n\n /**\n * Extract agent data from registration result and save to state\n */\n private _handleRegistrationResult(rawResult: any): void {\n let accountId = rawResult.accountId || rawResult.metadata?.accountId;\n\n if (!accountId && rawResult.state?.createdResources) {\n const accountResource = rawResult.state.createdResources.find(\n (r: string) => r.startsWith('account:')\n );\n if (accountResource) {\n accountId = accountResource.split(':')[1];\n }\n }\n\n const inboundTopicId =\n rawResult.inboundTopicId ||\n rawResult.metadata?.inboundTopicId ||\n rawResult.state?.inboundTopicId;\n\n const outboundTopicId =\n rawResult.outboundTopicId ||\n rawResult.metadata?.outboundTopicId ||\n rawResult.state?.outboundTopicId;\n\n const profileTopicId =\n rawResult.profileTopicId ||\n rawResult.metadata?.profileTopicId ||\n rawResult.state?.profileTopicId;\n\n const privateKey = rawResult.privateKey || rawResult.metadata?.privateKey;\n\n if (accountId && inboundTopicId && outboundTopicId && this.specificArgs) {\n const registeredAgent: RegisteredAgent = {\n name: this.specificArgs.name,\n accountId,\n inboundTopicId,\n outboundTopicId,\n profileTopicId,\n privateKey,\n };\n\n const hcs10Builder = this.getServiceBuilder() as HCS10Builder;\n const stateManager = hcs10Builder.getStateManager();\n if (stateManager) {\n stateManager.setCurrentAgent(registeredAgent);\n\n if (stateManager.persistAgentData) {\n const prefix =\n this.specificArgs.persistence?.prefix ||\n this.specificArgs.name.toUpperCase().replace(/[^A-Z0-9]/g, '_');\n stateManager\n .persistAgentData(registeredAgent, {\n type: 'env-file',\n prefix: prefix,\n })\n .catch(() => {});\n }\n }\n }\n }\n}\n"],"names":[],"mappings":";;;;AAaA,MAAM,yBAAyB,EAAE,OAAO;AAAA,EACtC,MAAM,EACH,OAAA,EACA,IAAI,CAAC,EACL,IAAI,EAAE,EACN,SAAS,+CAA+C;AAAA,EAC3D,aAAa,EACV,OAAA,EACA,IAAI,GAAG,EACP,SAAA,EACA,SAAS,6DAA6D;AAAA,EACzE,OAAO,EACJ,OAAA,EACA,WACA,UAAU,CAAC,QAAQ;AAClB,QAAI,CAAC,OAAO,IAAI,cAAc,SAAS,QAAQ,GAAG;AAChD,YAAM,YAAY,KAAK,IAAA,EAAM,SAAS,EAAE;AACxC,YAAM,cAAc,KAAK,OAAA,EAAS,SAAS,EAAE;AAC7C,aAAO,MAAM,SAAS,GAAG,WAAW;AAAA,IACtC;AACA,WAAO;AAAA,EACT,CAAC,EACA;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,MAAM,EACH,KAAK,CAAC,cAAc,QAAQ,CAAC,EAC7B,SAAA,EACA,SAAS,kCAAkC;AAAA,EAC9C,OAAO,EACJ,OAAA,EACA,SAAA,EACA,SAAS,iDAAiD;AAAA,EAC7D,cAAc,EACX,MAAM;AAAA,IACL,EAAE,MAAM,EAAE,WAAW,iBA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BACV,UAAU,UAAU,kBACpB,UAAU,OAAO;AAEnB,UAAM,aAAa,UAAU,cAAc,UAAU,UAAU;AAE/D,QAAI,aAAa,kBAAkB,mBAAmB,KAAK,cAAc;AACvE,YAAM,kBAAmC;AAAA,QACvC,MAAM,KAAK,aAAa;AAAA,QACxB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAGF,YAAM,eAAe,KAAK,kBAAA;AAC1B,YAAM,eAAe,aAAa,gBAAA;AAClC,UAAI,cAAc;AAChB,qBAAa,gBAAgB,eAAe;AAE5C,YAAI,aAAa,kBAAkB;AACjC,gBAAM,SACJ,KAAK,aAAa,aAAa,UAC/B,KAAK,aAAa,KAAK,YAAA,EAAc,QAAQ,cAAc,GAAG;AAChE,uBACG,iBAAiB,iBAAiB;AAAA,YACjC,MAAM;AAAA,YACN;AAAA,UAAA,CACD,EACA,MAAM,MAAM;AAAA,UAAC,CAAC;AAAA,QACnB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;"}
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es7.js","sources":["../../src/tools/hcs10/base-hcs10-tools.ts"],"sourcesContent":["import {\n BaseHederaTransactionTool,\n BaseHederaQueryTool,\n BaseServiceBuilder,\n} from 'hedera-agent-kit';\nimport { HCS10Builder } from '../../builders/hcs10/hcs10-builder';\nimport {\n HCS10TransactionToolParams,\n HCS10QueryToolParams,\n} from './hcs10-tool-params';\nimport { z } from 'zod';\n\n/**\n * Base class for HCS10 transaction tools\n */\nexport abstract class BaseHCS10TransactionTool<\n T extends z.ZodObject<\n z.ZodRawShape,\n z.UnknownKeysParam,\n z.ZodTypeAny\n > = z.ZodObject<z.ZodRawShape>\n> extends BaseHederaTransactionTool<T> {\n protected hcs10Builder: HCS10Builder;\n namespace = 'hcs10' as const;\n\n constructor(params: HCS10TransactionToolParams) {\n super(params);\n this.hcs10Builder = params.hcs10Builder;\n }\n\n /**\n * Override to return the HCS10Builder\n */\n protected getServiceBuilder(): BaseServiceBuilder {\n return this.hcs10Builder;\n }\n}\n\n/**\n * Base class for HCS10 query tools\n */\nexport abstract class BaseHCS10QueryTool<\n T extends z.ZodObject<\n z.ZodRawShape,\n z.UnknownKeysParam,\n z.ZodTypeAny\n > = z.ZodObject<z.ZodRawShape>\n> extends BaseHederaQueryTool<T> {\n protected hcs10Builder: HCS10Builder;\n namespace = 'hcs10' as const;\n\n constructor(params: HCS10QueryToolParams) {\n super(params);\n this.hcs10Builder = params.hcs10Builder;\n }\n\n /**\n * Override to return the HCS10Builder\n */\n protected getServiceBuilder(): BaseServiceBuilder {\n return this.hcs10Builder;\n }\n}\n"],"names":[],"mappings":";AAeO,MAAe,iCAMZ,0BAA6B;AAAA,EAIrC,YAAY,QAAoC;AAC9C,UAAM,MAAM;AAHd,SAAA,YAAY;AAIV,SAAK,eAAe,OAAO;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA,EAKU,oBAAwC;AAChD,WAAO,KAAK;AAAA,EACd;AACF;AAKO,MAAe,2BAMZ,oBAAuB;AAAA,EAI/B,YAAY,QAA8B;AACxC,UAAM,MAAM;AAHd,SAAA,YAAY;AAIV,SAAK,eAAe,OAAO;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA,EAKU,oBAAwC;AAChD,WAAO,KAAK;AAAA,EACd;AACF;"}
|
|
@@ -1,89 +1,240 @@
|
|
|
1
|
+
import { AIAgentCapability } from "@hashgraphonline/standards-sdk";
|
|
1
2
|
import { z } from "zod";
|
|
2
|
-
import { BaseHCS10TransactionTool } from "./standards-agent-kit.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { BaseHCS10TransactionTool } from "./standards-agent-kit.es7.js";
|
|
4
|
+
import { NaturalLanguageMapper } from "./standards-agent-kit.es19.js";
|
|
5
|
+
const RegisterAgentZodSchema = z.object({
|
|
6
|
+
name: z.string().min(1).max(50).describe("A unique name for the agent (1-50 characters)"),
|
|
7
|
+
description: z.string().max(500).optional().describe("Optional bio description for the agent (max 500 characters)"),
|
|
8
|
+
alias: z.string().optional().transform((val) => {
|
|
9
|
+
if (!val || val.toLowerCase().includes("random")) {
|
|
10
|
+
const timestamp = Date.now().toString(36);
|
|
11
|
+
const randomChars = Math.random().toString(36);
|
|
12
|
+
return `bot${timestamp}${randomChars}`;
|
|
13
|
+
}
|
|
14
|
+
return val;
|
|
15
|
+
}).describe(
|
|
16
|
+
'Optional custom username/alias for the agent. Use "random" to generate a unique alias'
|
|
17
|
+
),
|
|
18
|
+
type: z.enum(["autonomous", "manual"]).optional().describe("Agent type (default: autonomous)"),
|
|
19
|
+
model: z.string().optional().describe("AI model identifier (default: agent-model-2024)"),
|
|
20
|
+
capabilities: z.union([
|
|
21
|
+
z.array(z.nativeEnum(AIAgentCapability)),
|
|
22
|
+
z.array(z.string()),
|
|
23
|
+
z.string()
|
|
24
|
+
]).optional().transform((val) => {
|
|
25
|
+
if (!val) return void 0;
|
|
26
|
+
if (typeof val === "string") {
|
|
27
|
+
return NaturalLanguageMapper.parseCapabilities(val);
|
|
28
|
+
}
|
|
29
|
+
if (Array.isArray(val) && val.length > 0 && typeof val[0] === "string") {
|
|
30
|
+
return NaturalLanguageMapper.parseTagsOrCapabilities(val);
|
|
31
|
+
}
|
|
32
|
+
return val;
|
|
33
|
+
}).describe('Agent capabilities - can be capability names (e.g. "ai", "data processing"), capability enum values, or array of either. Common values: "ai"/"text" (TEXT_GENERATION), "data" (DATA_INTEGRATION), "analytics" (TRANSACTION_ANALYTICS)'),
|
|
34
|
+
tags: z.union([
|
|
35
|
+
z.array(z.string()),
|
|
36
|
+
z.string()
|
|
37
|
+
]).optional().transform((val) => {
|
|
38
|
+
if (!val) return void 0;
|
|
39
|
+
if (typeof val === "string") {
|
|
40
|
+
return NaturalLanguageMapper.parseCapabilities(val);
|
|
41
|
+
}
|
|
42
|
+
return NaturalLanguageMapper.parseTagsOrCapabilities(val);
|
|
43
|
+
}).describe('Tags for the agent (alternative to capabilities) - e.g. "ai", "data", "analytics". Will be converted to appropriate capabilities.'),
|
|
44
|
+
creator: z.string().optional().describe("Creator attribution for the agent"),
|
|
45
|
+
socials: z.record(
|
|
46
|
+
z.enum([
|
|
47
|
+
"twitter",
|
|
48
|
+
"github",
|
|
49
|
+
"discord",
|
|
50
|
+
"telegram",
|
|
51
|
+
"linkedin",
|
|
52
|
+
"youtube",
|
|
53
|
+
"website",
|
|
54
|
+
"x"
|
|
55
|
+
]),
|
|
56
|
+
z.string()
|
|
57
|
+
).optional().describe(
|
|
58
|
+
'Social media links (e.g., {"twitter": "@handle", "discord": "username"})'
|
|
59
|
+
),
|
|
60
|
+
properties: z.record(z.unknown()).optional().describe("Custom metadata properties for the agent"),
|
|
61
|
+
profilePicture: z.union([
|
|
62
|
+
z.string().describe("URL or local file path to profile picture"),
|
|
63
|
+
z.object({
|
|
64
|
+
url: z.string().optional(),
|
|
65
|
+
path: z.string().optional(),
|
|
66
|
+
filename: z.string().optional()
|
|
67
|
+
})
|
|
68
|
+
]).optional().describe(
|
|
69
|
+
"Optional profile picture as URL, file path, or object with url/path/filename"
|
|
70
|
+
),
|
|
71
|
+
existingProfilePictureTopicId: z.string().optional().describe(
|
|
72
|
+
"Topic ID of an existing profile picture to reuse (e.g., 0.0.12345)"
|
|
73
|
+
),
|
|
74
|
+
initialBalance: z.number().positive().optional().describe(
|
|
75
|
+
"Optional initial HBAR balance for the new agent account (will create new account if provided)"
|
|
76
|
+
),
|
|
77
|
+
userAccountId: z.string().optional().describe(
|
|
78
|
+
"Optional account ID (e.g., 0.0.12345) to use as the agent account instead of creating a new one"
|
|
6
79
|
),
|
|
7
|
-
|
|
8
|
-
"
|
|
80
|
+
hbarFee: z.number().positive().optional().describe(
|
|
81
|
+
"Optional HBAR fee amount to charge per message on the inbound topic"
|
|
9
82
|
),
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
83
|
+
tokenFees: z.array(
|
|
84
|
+
z.object({
|
|
85
|
+
amount: z.number().positive(),
|
|
86
|
+
tokenId: z.string()
|
|
87
|
+
})
|
|
88
|
+
).optional().describe("Optional token fees to charge per message"),
|
|
89
|
+
exemptAccountIds: z.array(z.string()).optional().describe("Optional account IDs to exempt from fees"),
|
|
90
|
+
setAsCurrent: z.boolean().optional().describe("Whether to set as current agent (default: true)"),
|
|
91
|
+
persistence: z.object({
|
|
92
|
+
prefix: z.string().optional()
|
|
93
|
+
}).optional().describe("Optional persistence configuration")
|
|
13
94
|
});
|
|
14
|
-
class
|
|
95
|
+
class RegisterAgentTool extends BaseHCS10TransactionTool {
|
|
15
96
|
constructor(params) {
|
|
16
97
|
super(params);
|
|
17
|
-
this.name = "
|
|
18
|
-
this.description =
|
|
19
|
-
this.specificInputSchema =
|
|
20
|
-
this.requiresMultipleTransactions = true;
|
|
98
|
+
this.name = "register_agent";
|
|
99
|
+
this.description = 'Creates and registers the AI agent on the Hedera network. Returns JSON string with agent details (accountId, privateKey, topics) on success. Supports natural language for capabilities/tags like "ai", "data processing", "analytics". Note: This tool requires multiple transactions and cannot be used in returnBytes mode. If alias is set to "random" or contains "random", a unique alias will be generated.';
|
|
100
|
+
this.specificInputSchema = RegisterAgentZodSchema;
|
|
21
101
|
this.neverScheduleThisTool = true;
|
|
102
|
+
this.requiresMultipleTransactions = true;
|
|
22
103
|
}
|
|
23
104
|
async callBuilderMethod(builder, specificArgs) {
|
|
24
105
|
const hcs10Builder = builder;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
106
|
+
this.specificArgs = specificArgs;
|
|
107
|
+
const params = {
|
|
108
|
+
name: specificArgs.name
|
|
109
|
+
};
|
|
110
|
+
if (specificArgs.description !== void 0) {
|
|
111
|
+
params.bio = specificArgs.description;
|
|
112
|
+
}
|
|
113
|
+
if (specificArgs.alias !== void 0) {
|
|
114
|
+
params.alias = specificArgs.alias;
|
|
115
|
+
} else {
|
|
116
|
+
const randomSuffix = Date.now().toString(36);
|
|
117
|
+
params.alias = `${specificArgs.name}${randomSuffix}`;
|
|
118
|
+
}
|
|
119
|
+
if (specificArgs.type !== void 0) {
|
|
120
|
+
params.type = specificArgs.type;
|
|
121
|
+
}
|
|
122
|
+
if (specificArgs.model !== void 0) {
|
|
123
|
+
params.model = specificArgs.model;
|
|
124
|
+
}
|
|
125
|
+
if (specificArgs.tags !== void 0) {
|
|
126
|
+
params.capabilities = specificArgs.tags;
|
|
127
|
+
} else if (specificArgs.capabilities !== void 0) {
|
|
128
|
+
params.capabilities = specificArgs.capabilities;
|
|
129
|
+
}
|
|
130
|
+
if (specificArgs.creator !== void 0) {
|
|
131
|
+
params.creator = specificArgs.creator;
|
|
30
132
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
133
|
+
if (specificArgs.socials !== void 0) {
|
|
134
|
+
params.socials = specificArgs.socials;
|
|
135
|
+
}
|
|
136
|
+
if (specificArgs.properties !== void 0) {
|
|
137
|
+
params.properties = specificArgs.properties;
|
|
138
|
+
}
|
|
139
|
+
if (specificArgs.profilePicture !== void 0) {
|
|
140
|
+
if (typeof specificArgs.profilePicture === "string") {
|
|
141
|
+
params.profilePicture = specificArgs.profilePicture;
|
|
142
|
+
} else {
|
|
143
|
+
const profilePicObj = {};
|
|
144
|
+
if (specificArgs.profilePicture.url !== void 0) {
|
|
145
|
+
profilePicObj.url = specificArgs.profilePicture.url;
|
|
146
|
+
}
|
|
147
|
+
if (specificArgs.profilePicture.path !== void 0) {
|
|
148
|
+
profilePicObj.path = specificArgs.profilePicture.path;
|
|
44
149
|
}
|
|
150
|
+
if (specificArgs.profilePicture.filename !== void 0) {
|
|
151
|
+
profilePicObj.filename = specificArgs.profilePicture.filename;
|
|
152
|
+
}
|
|
153
|
+
params.profilePicture = profilePicObj;
|
|
45
154
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
155
|
+
}
|
|
156
|
+
if (specificArgs.existingProfilePictureTopicId !== void 0) {
|
|
157
|
+
params.existingProfilePictureTopicId = specificArgs.existingProfilePictureTopicId;
|
|
158
|
+
}
|
|
159
|
+
if (specificArgs.userAccountId !== void 0) {
|
|
160
|
+
params.userAccountId = specificArgs.userAccountId;
|
|
161
|
+
}
|
|
162
|
+
if (specificArgs.hbarFee !== void 0) {
|
|
163
|
+
params.hbarFee = specificArgs.hbarFee;
|
|
164
|
+
}
|
|
165
|
+
if (specificArgs.tokenFees !== void 0) {
|
|
166
|
+
params.tokenFees = specificArgs.tokenFees;
|
|
167
|
+
}
|
|
168
|
+
if (specificArgs.exemptAccountIds !== void 0) {
|
|
169
|
+
params.exemptAccountIds = specificArgs.exemptAccountIds;
|
|
170
|
+
}
|
|
171
|
+
if (specificArgs.initialBalance !== void 0) {
|
|
172
|
+
params.initialBalance = specificArgs.initialBalance;
|
|
173
|
+
}
|
|
174
|
+
await hcs10Builder.registerAgent(params);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Override _call to intercept the result and save agent to state if needed
|
|
178
|
+
*/
|
|
179
|
+
async _call(args, runManager) {
|
|
180
|
+
const result = await super._call(args, runManager);
|
|
181
|
+
const shouldSetAsCurrent = this.specificArgs?.setAsCurrent !== false;
|
|
182
|
+
if (this.specificArgs && shouldSetAsCurrent) {
|
|
183
|
+
try {
|
|
184
|
+
const parsed = JSON.parse(result);
|
|
185
|
+
if (parsed.rawResult) {
|
|
186
|
+
this._handleRegistrationResult(parsed.rawResult);
|
|
187
|
+
} else if (parsed.state || parsed.accountId || parsed.metadata) {
|
|
188
|
+
this._handleRegistrationResult(parsed);
|
|
62
189
|
}
|
|
190
|
+
} catch (e) {
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return result;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Extract agent data from registration result and save to state
|
|
197
|
+
*/
|
|
198
|
+
_handleRegistrationResult(rawResult) {
|
|
199
|
+
let accountId = rawResult.accountId || rawResult.metadata?.accountId;
|
|
200
|
+
if (!accountId && rawResult.state?.createdResources) {
|
|
201
|
+
const accountResource = rawResult.state.createdResources.find(
|
|
202
|
+
(r) => r.startsWith("account:")
|
|
203
|
+
);
|
|
204
|
+
if (accountResource) {
|
|
205
|
+
accountId = accountResource.split(":")[1];
|
|
63
206
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
207
|
+
}
|
|
208
|
+
const inboundTopicId = rawResult.inboundTopicId || rawResult.metadata?.inboundTopicId || rawResult.state?.inboundTopicId;
|
|
209
|
+
const outboundTopicId = rawResult.outboundTopicId || rawResult.metadata?.outboundTopicId || rawResult.state?.outboundTopicId;
|
|
210
|
+
const profileTopicId = rawResult.profileTopicId || rawResult.metadata?.profileTopicId || rawResult.state?.profileTopicId;
|
|
211
|
+
const privateKey = rawResult.privateKey || rawResult.metadata?.privateKey;
|
|
212
|
+
if (accountId && inboundTopicId && outboundTopicId && this.specificArgs) {
|
|
213
|
+
const registeredAgent = {
|
|
214
|
+
name: this.specificArgs.name,
|
|
215
|
+
accountId,
|
|
216
|
+
inboundTopicId,
|
|
217
|
+
outboundTopicId,
|
|
218
|
+
profileTopicId,
|
|
219
|
+
privateKey
|
|
220
|
+
};
|
|
221
|
+
const hcs10Builder = this.getServiceBuilder();
|
|
222
|
+
const stateManager = hcs10Builder.getStateManager();
|
|
223
|
+
if (stateManager) {
|
|
224
|
+
stateManager.setCurrentAgent(registeredAgent);
|
|
225
|
+
if (stateManager.persistAgentData) {
|
|
226
|
+
const prefix = this.specificArgs.persistence?.prefix || this.specificArgs.name.toUpperCase().replace(/[^A-Z0-9]/g, "_");
|
|
227
|
+
stateManager.persistAgentData(registeredAgent, {
|
|
228
|
+
type: "env-file",
|
|
229
|
+
prefix
|
|
230
|
+
}).catch(() => {
|
|
74
231
|
});
|
|
75
|
-
return;
|
|
76
232
|
}
|
|
77
233
|
}
|
|
78
234
|
}
|
|
79
|
-
await hcs10Builder.sendMessageToConnection({
|
|
80
|
-
targetIdentifier,
|
|
81
|
-
message: specificArgs.message,
|
|
82
|
-
disableMonitoring: specificArgs.disableMonitoring
|
|
83
|
-
});
|
|
84
235
|
}
|
|
85
236
|
}
|
|
86
237
|
export {
|
|
87
|
-
|
|
238
|
+
RegisterAgentTool
|
|
88
239
|
};
|
|
89
240
|
//# sourceMappingURL=standards-agent-kit.es8.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es8.js","sources":["../../src/tools/hcs10/SendMessageToConnectionTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseHCS10TransactionTool } from './base-hcs10-tools';\nimport { HCS10Builder } from '../../builders/hcs10/hcs10-builder';\nimport { HCS10TransactionToolParams } from './hcs10-tool-params';\nimport { BaseServiceBuilder } from 'hedera-agent-kit';\n\nconst SendMessageToConnectionZodSchema = z.object({\n targetIdentifier: z\n .string()\n .optional()\n .describe(\n \"The request key (e.g., 'req-1:0.0.6155171@0.0.6154875'), account ID (e.g., 0.0.12345) of the target agent, OR the connection number (e.g., '1', '2') from the 'list_connections' tool. Request key is most deterministic.\"\n ),\n connectionId: z\n .string()\n .optional()\n .describe(\n \"The connection number (e.g., '1', '2') from the 'list_connections' tool.\"\n ),\n agentId: z\n .string()\n .optional()\n .describe('The account ID (e.g., 0.0.12345) of the target agent.'),\n message: z.string().describe('The text message content to send.'),\n disableMonitoring: z.boolean().optional().default(false),\n});\n\n/**\n * A tool to send a message to an agent over an established HCS-10 connection.\n */\nexport class SendMessageToConnectionTool extends BaseHCS10TransactionTool<\n typeof SendMessageToConnectionZodSchema\n> {\n name = 'send_message_to_connection';\n description =\n \"Use this to send a message to an agent you already have an active connection with. Provide the target agent's account ID (e.g., 0.0.12345) and your message. If no active connection exists, this will fail - use initiate_connection instead to create a new connection first.\";\n specificInputSchema = SendMessageToConnectionZodSchema;\n constructor(params: HCS10TransactionToolParams) {\n super(params);\n this.requiresMultipleTransactions = true;\n this.neverScheduleThisTool = true;\n }\n\n protected async callBuilderMethod(\n builder: BaseServiceBuilder,\n specificArgs: z.infer<typeof SendMessageToConnectionZodSchema>\n ): Promise<void> {\n const hcs10Builder = builder as HCS10Builder;\n\n const targetIdentifier =\n specificArgs.targetIdentifier ||\n specificArgs.agentId ||\n specificArgs.connectionId;\n\n if (!targetIdentifier) {\n throw new Error(\n 'Either targetIdentifier, connectionId, or agentId must be provided'\n );\n }\n\n const stateManager = hcs10Builder.getStateManager();\n if (stateManager) {\n const connectionsManager = stateManager.getConnectionsManager();\n if (connectionsManager) {\n try {\n const currentAgent = stateManager.getCurrentAgent();\n if (currentAgent && currentAgent.accountId) {\n await connectionsManager.fetchConnectionData(\n currentAgent.accountId\n );\n }\n } catch (error) {\n console.debug('Could not refresh connections:', error);\n }\n }\n\n if (targetIdentifier.match(/^\\d+$/)) {\n const connections = stateManager.listConnections();\n const connectionIndex = parseInt(targetIdentifier) - 1; // Connection numbers are 1-based\n\n const establishedConnections = connections.filter(\n (conn) =>\n conn.status === 'established' &&\n !conn.isPending &&\n !conn.needsConfirmation\n );\n\n if (\n connectionIndex >= 0 &&\n connectionIndex < establishedConnections.length\n ) {\n const selectedConnection = establishedConnections[connectionIndex];\n if (selectedConnection && selectedConnection.connectionTopicId) {\n await hcs10Builder.sendMessageToConnection({\n targetIdentifier: selectedConnection.connectionTopicId,\n message: specificArgs.message,\n disableMonitoring: specificArgs.disableMonitoring,\n });\n return;\n }\n }\n }\n\n if (targetIdentifier.match(/^\\d+\\.\\d+\\.\\d+$/)) {\n const connections = stateManager.listConnections();\n const establishedConnection = connections.find(\n (conn) =>\n (conn.targetAccountId === targetIdentifier ||\n conn.targetAccountId === `0.0.${targetIdentifier}`) &&\n conn.status === 'established' &&\n !conn.isPending &&\n !conn.needsConfirmation\n );\n\n if (establishedConnection && establishedConnection.connectionTopicId) {\n await hcs10Builder.sendMessageToConnection({\n targetIdentifier: establishedConnection.connectionTopicId,\n message: specificArgs.message,\n disableMonitoring: specificArgs.disableMonitoring,\n });\n return;\n }\n }\n }\n\n await hcs10Builder.sendMessageToConnection({\n targetIdentifier: targetIdentifier,\n message: specificArgs.message,\n disableMonitoring: specificArgs.disableMonitoring,\n });\n }\n}\n"],"names":[],"mappings":";;AAMA,MAAM,mCAAmC,EAAE,OAAO;AAAA,EAChD,kBAAkB,EACf,SACA,WACA;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,cAAc,EACX,SACA,WACA;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,SAAS,EACN,OAAA,EACA,SAAA,EACA,SAAS,uDAAuD;AAAA,EACnE,SAAS,EAAE,SAAS,SAAS,mCAAmC;AAAA,EAChE,mBAAmB,EAAE,QAAA,EAAU,SAAA,EAAW,QAAQ,KAAK;AACzD,CAAC;AAKM,MAAM,oCAAoC,yBAE/C;AAAA,EAKA,YAAY,QAAoC;AAC9C,UAAM,MAAM;AALd,SAAA,OAAO;AACP,SAAA,cACE;AACF,SAAA,sBAAsB;AAGpB,SAAK,+BAA+B;AACpC,SAAK,wBAAwB;AAAA,EAC/B;AAAA,EAEA,MAAgB,kBACd,SACA,cACe;AACf,UAAM,eAAe;AAErB,UAAM,mBACJ,aAAa,oBACb,aAAa,WACb,aAAa;AAEf,QAAI,CAAC,kBAAkB;AACrB,YAAM,IAAI;AAAA,QACR;AAAA,MAAA;AAAA,IAEJ;AAEA,UAAM,eAAe,aAAa,gBAAA;AAClC,QAAI,cAAc;AAChB,YAAM,qBAAqB,aAAa,sBAAA;AACxC,UAAI,oBAAoB;AACtB,YAAI;AACF,gBA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AAAA,IAAA,CACjC;AAAA,EACH;AACF;"}
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es8.js","sources":["../../src/tools/hcs10/RegisterAgentTool.ts"],"sourcesContent":["import { AIAgentCapability } from '@hashgraphonline/standards-sdk';\nimport { z } from 'zod';\nimport { BaseServiceBuilder } from 'hedera-agent-kit';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\nimport {\n HCS10Builder,\n RegisterAgentParams,\n} from '../../builders/hcs10/hcs10-builder';\nimport { BaseHCS10TransactionTool } from './base-hcs10-tools';\nimport { HCS10TransactionToolParams } from './hcs10-tool-params';\nimport { RegisteredAgent } from '../../state/state-types';\nimport { NaturalLanguageMapper } from './natural-language-mapper';\n\nconst RegisterAgentZodSchema = z.object({\n name: z\n .string()\n .min(1)\n .max(50)\n .describe('A unique name for the agent (1-50 characters)'),\n description: z\n .string()\n .max(500)\n .optional()\n .describe('Optional bio description for the agent (max 500 characters)'),\n alias: z\n .string()\n .optional()\n .transform((val) => {\n if (!val || val.toLowerCase().includes('random')) {\n const timestamp = Date.now().toString(36);\n const randomChars = Math.random().toString(36);\n return `bot${timestamp}${randomChars}`;\n }\n return val;\n })\n .describe(\n 'Optional custom username/alias for the agent. Use \"random\" to generate a unique alias'\n ),\n type: z\n .enum(['autonomous', 'manual'])\n .optional()\n .describe('Agent type (default: autonomous)'),\n model: z\n .string()\n .optional()\n .describe('AI model identifier (default: agent-model-2024)'),\n capabilities: z\n .union([\n z.array(z.nativeEnum(AIAgentCapability)),\n z.array(z.string()),\n z.string(),\n ])\n .optional()\n .transform((val) => {\n if (!val) return undefined;\n if (typeof val === 'string') {\n return NaturalLanguageMapper.parseCapabilities(val);\n }\n if (Array.isArray(val) && val.length > 0 && typeof val[0] === 'string') {\n return NaturalLanguageMapper.parseTagsOrCapabilities(val);\n }\n return val as AIAgentCapability[];\n })\n .describe('Agent capabilities - can be capability names (e.g. \"ai\", \"data processing\"), capability enum values, or array of either. Common values: \"ai\"/\"text\" (TEXT_GENERATION), \"data\" (DATA_INTEGRATION), \"analytics\" (TRANSACTION_ANALYTICS)'),\n tags: z\n .union([\n z.array(z.string()),\n z.string(),\n ])\n .optional()\n .transform((val) => {\n if (!val) return undefined;\n if (typeof val === 'string') {\n return NaturalLanguageMapper.parseCapabilities(val);\n }\n return NaturalLanguageMapper.parseTagsOrCapabilities(val);\n })\n .describe('Tags for the agent (alternative to capabilities) - e.g. \"ai\", \"data\", \"analytics\". Will be converted to appropriate capabilities.'),\n creator: z.string().optional().describe('Creator attribution for the agent'),\n socials: z\n .record(\n z.enum([\n 'twitter',\n 'github',\n 'discord',\n 'telegram',\n 'linkedin',\n 'youtube',\n 'website',\n 'x',\n ] as const),\n z.string()\n )\n .optional()\n .describe(\n 'Social media links (e.g., {\"twitter\": \"@handle\", \"discord\": \"username\"})'\n ),\n properties: z\n .record(z.unknown())\n .optional()\n .describe('Custom metadata properties for the agent'),\n profilePicture: z\n .union([\n z.string().describe('URL or local file path to profile picture'),\n z.object({\n url: z.string().optional(),\n path: z.string().optional(),\n filename: z.string().optional(),\n }),\n ])\n .optional()\n .describe(\n 'Optional profile picture as URL, file path, or object with url/path/filename'\n ),\n existingProfilePictureTopicId: z\n .string()\n .optional()\n .describe(\n 'Topic ID of an existing profile picture to reuse (e.g., 0.0.12345)'\n ),\n initialBalance: z\n .number()\n .positive()\n .optional()\n .describe(\n 'Optional initial HBAR balance for the new agent account (will create new account if provided)'\n ),\n userAccountId: z\n .string()\n .optional()\n .describe(\n 'Optional account ID (e.g., 0.0.12345) to use as the agent account instead of creating a new one'\n ),\n hbarFee: z\n .number()\n .positive()\n .optional()\n .describe(\n 'Optional HBAR fee amount to charge per message on the inbound topic'\n ),\n tokenFees: z\n .array(\n z.object({\n amount: z.number().positive(),\n tokenId: z.string(),\n })\n )\n .optional()\n .describe('Optional token fees to charge per message'),\n exemptAccountIds: z\n .array(z.string())\n .optional()\n .describe('Optional account IDs to exempt from fees'),\n setAsCurrent: z\n .boolean()\n .optional()\n .describe('Whether to set as current agent (default: true)'),\n persistence: z\n .object({\n prefix: z.string().optional(),\n })\n .optional()\n .describe('Optional persistence configuration'),\n});\n\nexport class RegisterAgentTool extends BaseHCS10TransactionTool<\n typeof RegisterAgentZodSchema\n> {\n name = 'register_agent';\n description =\n 'Creates and registers the AI agent on the Hedera network. Returns JSON string with agent details (accountId, privateKey, topics) on success. Supports natural language for capabilities/tags like \"ai\", \"data processing\", \"analytics\". Note: This tool requires multiple transactions and cannot be used in returnBytes mode. If alias is set to \"random\" or contains \"random\", a unique alias will be generated.';\n specificInputSchema = RegisterAgentZodSchema;\n private specificArgs: z.infer<typeof RegisterAgentZodSchema> | undefined;\n\n constructor(params: HCS10TransactionToolParams) {\n super(params);\n this.neverScheduleThisTool = true;\n this.requiresMultipleTransactions = true;\n }\n\n protected async callBuilderMethod(\n builder: BaseServiceBuilder,\n specificArgs: z.infer<typeof RegisterAgentZodSchema>\n ): Promise<void> {\n const hcs10Builder = builder as HCS10Builder;\n this.specificArgs = specificArgs;\n const params: RegisterAgentParams = {\n name: specificArgs.name,\n };\n\n if (specificArgs.description !== undefined) {\n params.bio = specificArgs.description;\n }\n if (specificArgs.alias !== undefined) {\n params.alias = specificArgs.alias;\n } else {\n const randomSuffix = Date.now().toString(36);\n params.alias = `${specificArgs.name}${randomSuffix}`;\n }\n if (specificArgs.type !== undefined) {\n params.type = specificArgs.type;\n }\n if (specificArgs.model !== undefined) {\n params.model = specificArgs.model;\n }\n // Handle both capabilities and tags (tags takes precedence if both provided)\n if (specificArgs.tags !== undefined) {\n params.capabilities = specificArgs.tags as AIAgentCapability[];\n } else if (specificArgs.capabilities !== undefined) {\n params.capabilities = specificArgs.capabilities as AIAgentCapability[];\n }\n if (specificArgs.creator !== undefined) {\n params.creator = specificArgs.creator;\n }\n if (specificArgs.socials !== undefined) {\n params.socials = specificArgs.socials;\n }\n if (specificArgs.properties !== undefined) {\n params.properties = specificArgs.properties;\n }\n if (specificArgs.profilePicture !== undefined) {\n if (typeof specificArgs.profilePicture === 'string') {\n params.profilePicture = specificArgs.profilePicture;\n } else {\n const profilePicObj: {\n url?: string;\n path?: string;\n filename?: string;\n } = {};\n if (specificArgs.profilePicture.url !== undefined) {\n profilePicObj.url = specificArgs.profilePicture.url;\n }\n if (specificArgs.profilePicture.path !== undefined) {\n profilePicObj.path = specificArgs.profilePicture.path;\n }\n if (specificArgs.profilePicture.filename !== undefined) {\n profilePicObj.filename = specificArgs.profilePicture.filename;\n }\n params.profilePicture = profilePicObj;\n }\n }\n if (specificArgs.existingProfilePictureTopicId !== undefined) {\n params.existingProfilePictureTopicId =\n specificArgs.existingProfilePictureTopicId;\n }\n if (specificArgs.userAccountId !== undefined) {\n params.userAccountId = specificArgs.userAccountId;\n }\n if (specificArgs.hbarFee !== undefined) {\n params.hbarFee = specificArgs.hbarFee;\n }\n if (specificArgs.tokenFees !== undefined) {\n params.tokenFees = specificArgs.tokenFees;\n }\n if (specificArgs.exemptAccountIds !== undefined) {\n params.exemptAccountIds = specificArgs.exemptAccountIds;\n }\n if (specificArgs.initialBalance !== undefined) {\n params.initialBalance = specificArgs.initialBalance;\n }\n\n await hcs10Builder.registerAgent(params);\n }\n\n /**\n * Override _call to intercept the result and save agent to state if needed\n */\n protected override async _call(\n args: z.infer<ReturnType<this['schema']>>,\n runManager?: CallbackManagerForToolRun\n ): Promise<string> {\n const result = await super._call(args, runManager);\n\n const shouldSetAsCurrent = this.specificArgs?.setAsCurrent !== false;\n\n if (this.specificArgs && shouldSetAsCurrent) {\n try {\n const parsed = JSON.parse(result);\n if (parsed.rawResult) {\n this._handleRegistrationResult(parsed.rawResult);\n } else if (parsed.state || parsed.accountId || parsed.metadata) {\n this._handleRegistrationResult(parsed);\n }\n } catch (e) {}\n }\n\n return result;\n }\n\n /**\n * Extract agent data from registration result and save to state\n */\n private _handleRegistrationResult(rawResult: any): void {\n let accountId = rawResult.accountId || rawResult.metadata?.accountId;\n\n if (!accountId && rawResult.state?.createdResources) {\n const accountResource = rawResult.state.createdResources.find(\n (r: string) => r.startsWith('account:')\n );\n if (accountResource) {\n accountId = accountResource.split(':')[1];\n }\n }\n\n const inboundTopicId =\n rawResult.inboundTopicId ||\n rawResult.metadata?.inboundTopicId ||\n rawResult.state?.inboundTopicId;\n\n const outboundTopicId =\n rawResult.outboundTopicId ||\n rawResult.metadata?.outboundTopicId ||\n rawResult.state?.outboundTopicId;\n\n const profileTopicId =\n rawResult.profileTopicId ||\n rawResult.metadata?.profileTopicId ||\n rawResult.state?.profileTopicId;\n\n const privateKey = rawResult.privateKey || rawResult.metadata?.privateKey;\n\n if (accountId && inboundTopicId && outboundTopicId && this.specificArgs) {\n const registeredAgent: RegisteredAgent = {\n name: this.specificArgs.name,\n accountId,\n inboundTopicId,\n outboundTopicId,\n profileTopicId,\n privateKey,\n };\n\n const hcs10Builder = this.getServiceBuilder() as HCS10Builder;\n const stateManager = hcs10Builder.getStateManager();\n if (stateManager) {\n stateManager.setCurrentAgent(registeredAgent);\n\n if (stateManager.persistAgentData) {\n const prefix =\n this.specificArgs.persistence?.prefix ||\n this.specificArgs.name.toUpperCase().replace(/[^A-Z0-9]/g, '_');\n stateManager\n .persistAgentData(registeredAgent, {\n type: 'env-file',\n prefix: prefix,\n })\n .catch(() => {});\n }\n }\n }\n }\n}\n"],"names":[],"mappings":";;;;AAaA,MAAM,yBAAyB,EAAE,OAAO;AAAA,EACtC,MAAM,EACH,OAAA,EACA,IAAI,CAAC,EACL,IAAI,EAAE,EACN,SAAS,+CAA+C;AAAA,EAC3D,aAAa,EACV,OAAA,EACA,IAAI,GAAG,EACP,SAAA,EACA,SAAS,6DAA6D;AAAA,EACzE,OAAO,EACJ,OAAA,EACA,WACA,UAAU,CAAC,QAAQ;AAClB,QAAI,CAAC,OAAO,IAAI,cAAc,SAAS,QAAQ,GAAG;AAChD,YAAM,YAAY,KAAK,IAAA,EAAM,SAAS,EAAE;AACxC,YAAM,cAAc,KAAK,OAAA,EAAS,SAAS,EAAE;AAC7C,aAA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AAM,iBAAiB;AAAA,QACvD,CAAC,MAAc,EAAE,WAAW,UAAU;AAAA,MAAA;AAExC,UAAI,iBAAiB;AACnB,oBAAY,gBAAgB,MAAM,GAAG,EAAE,CAAC;AAAA,MAC1C;AAAA,IACF;AAEA,UAAM,iBACJ,UAAU,kBACV,UAAU,UAAU,kBACpB,UAAU,OAAO;AAEnB,UAAM,kBACJ,UAAU,mBACV,UAAU,UAAU,mBACpB,UAAU,OAAO;AAEnB,UAAM,iBACJ,UAAU,kBACV,UAAU,UAAU,kBACpB,UAAU,OAAO;AAEnB,UAAM,aAAa,UAAU,cAAc,UAAU,UAAU;AAE/D,QAAI,aAAa,kBAAkB,mBAAmB,KAAK,cAAc;AACvE,YAAM,kBAAmC;AAAA,QACvC,MAAM,KAAK,aAAa;AAAA,QACxB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAGF,YAAM,eAAe,KAAK,kBAAA;AAC1B,YAAM,eAAe,aAAa,gBAAA;AAClC,UAAI,cAAc;AAChB,qBAAa,gBAAgB,eAAe;AAE5C,YAAI,aAAa,kBAAkB;AACjC,gBAAM,SACJ,KAAK,aAAa,aAAa,UAC/B,KAAK,aAAa,KAAK,YAAA,EAAc,QAAQ,cAAc,GAAG;AAChE,uBACG,iBAAiB,iBAAiB;AAAA,YACjC,MAAM;AAAA,YACN;AAAA,UAAA,CACD,EACA,MAAM,MAAM;AAAA,UAAC,CAAC;AAAA,QACnB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;"}
|
|
@@ -1,40 +1,89 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { BaseHCS10TransactionTool } from "./standards-agent-kit.
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
"The
|
|
2
|
+
import { BaseHCS10TransactionTool } from "./standards-agent-kit.es7.js";
|
|
3
|
+
const SendMessageToConnectionZodSchema = z.object({
|
|
4
|
+
targetIdentifier: z.string().optional().describe(
|
|
5
|
+
"The request key (e.g., 'req-1:0.0.6155171@0.0.6154875'), account ID (e.g., 0.0.12345) of the target agent, OR the connection number (e.g., '1', '2') from the 'list_connections' tool. Request key is most deterministic."
|
|
6
6
|
),
|
|
7
|
-
|
|
8
|
-
"
|
|
7
|
+
connectionId: z.string().optional().describe(
|
|
8
|
+
"The connection number (e.g., '1', '2') from the 'list_connections' tool."
|
|
9
9
|
),
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
)
|
|
10
|
+
agentId: z.string().optional().describe("The account ID (e.g., 0.0.12345) of the target agent."),
|
|
11
|
+
message: z.string().describe("The text message content to send."),
|
|
12
|
+
disableMonitoring: z.boolean().optional().default(false)
|
|
13
13
|
});
|
|
14
|
-
class
|
|
14
|
+
class SendMessageToConnectionTool extends BaseHCS10TransactionTool {
|
|
15
15
|
constructor(params) {
|
|
16
16
|
super(params);
|
|
17
|
-
this.name = "
|
|
18
|
-
this.description = "
|
|
19
|
-
this.specificInputSchema =
|
|
20
|
-
this.neverScheduleThisTool = true;
|
|
17
|
+
this.name = "send_message_to_connection";
|
|
18
|
+
this.description = "Use this to send a message to an agent you already have an active connection with. Provide the target agent's account ID (e.g., 0.0.12345) and your message. If no active connection exists, this will fail - use initiate_connection instead to create a new connection first.";
|
|
19
|
+
this.specificInputSchema = SendMessageToConnectionZodSchema;
|
|
21
20
|
this.requiresMultipleTransactions = true;
|
|
21
|
+
this.neverScheduleThisTool = true;
|
|
22
22
|
}
|
|
23
23
|
async callBuilderMethod(builder, specificArgs) {
|
|
24
24
|
const hcs10Builder = builder;
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const targetIdentifier = specificArgs.targetIdentifier || specificArgs.agentId || specificArgs.connectionId;
|
|
26
|
+
if (!targetIdentifier) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
"Either targetIdentifier, connectionId, or agentId must be provided"
|
|
29
|
+
);
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const stateManager = hcs10Builder.getStateManager();
|
|
32
|
+
if (stateManager) {
|
|
33
|
+
const connectionsManager = stateManager.getConnectionsManager();
|
|
34
|
+
if (connectionsManager) {
|
|
35
|
+
try {
|
|
36
|
+
const currentAgent = stateManager.getCurrentAgent();
|
|
37
|
+
if (currentAgent && currentAgent.accountId) {
|
|
38
|
+
await connectionsManager.fetchConnectionData(
|
|
39
|
+
currentAgent.accountId
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.debug("Could not refresh connections:", error);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (targetIdentifier.match(/^\d+$/)) {
|
|
47
|
+
const connections = stateManager.listConnections();
|
|
48
|
+
const connectionIndex = parseInt(targetIdentifier) - 1;
|
|
49
|
+
const establishedConnections = connections.filter(
|
|
50
|
+
(conn) => conn.status === "established" && !conn.isPending && !conn.needsConfirmation
|
|
51
|
+
);
|
|
52
|
+
if (connectionIndex >= 0 && connectionIndex < establishedConnections.length) {
|
|
53
|
+
const selectedConnection = establishedConnections[connectionIndex];
|
|
54
|
+
if (selectedConnection && selectedConnection.connectionTopicId) {
|
|
55
|
+
await hcs10Builder.sendMessageToConnection({
|
|
56
|
+
targetIdentifier: selectedConnection.connectionTopicId,
|
|
57
|
+
message: specificArgs.message,
|
|
58
|
+
disableMonitoring: specificArgs.disableMonitoring
|
|
59
|
+
});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (targetIdentifier.match(/^\d+\.\d+\.\d+$/)) {
|
|
65
|
+
const connections = stateManager.listConnections();
|
|
66
|
+
const establishedConnection = connections.find(
|
|
67
|
+
(conn) => (conn.targetAccountId === targetIdentifier || conn.targetAccountId === `0.0.${targetIdentifier}`) && conn.status === "established" && !conn.isPending && !conn.needsConfirmation
|
|
68
|
+
);
|
|
69
|
+
if (establishedConnection && establishedConnection.connectionTopicId) {
|
|
70
|
+
await hcs10Builder.sendMessageToConnection({
|
|
71
|
+
targetIdentifier: establishedConnection.connectionTopicId,
|
|
72
|
+
message: specificArgs.message,
|
|
73
|
+
disableMonitoring: specificArgs.disableMonitoring
|
|
74
|
+
});
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
33
78
|
}
|
|
34
|
-
await hcs10Builder.
|
|
79
|
+
await hcs10Builder.sendMessageToConnection({
|
|
80
|
+
targetIdentifier,
|
|
81
|
+
message: specificArgs.message,
|
|
82
|
+
disableMonitoring: specificArgs.disableMonitoring
|
|
83
|
+
});
|
|
35
84
|
}
|
|
36
85
|
}
|
|
37
86
|
export {
|
|
38
|
-
|
|
87
|
+
SendMessageToConnectionTool
|
|
39
88
|
};
|
|
40
89
|
//# sourceMappingURL=standards-agent-kit.es9.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es9.js","sources":["../../src/tools/hcs10/
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es9.js","sources":["../../src/tools/hcs10/SendMessageToConnectionTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseHCS10TransactionTool } from './base-hcs10-tools';\nimport { HCS10Builder } from '../../builders/hcs10/hcs10-builder';\nimport { HCS10TransactionToolParams } from './hcs10-tool-params';\nimport { BaseServiceBuilder } from 'hedera-agent-kit';\n\nconst SendMessageToConnectionZodSchema = z.object({\n targetIdentifier: z\n .string()\n .optional()\n .describe(\n \"The request key (e.g., 'req-1:0.0.6155171@0.0.6154875'), account ID (e.g., 0.0.12345) of the target agent, OR the connection number (e.g., '1', '2') from the 'list_connections' tool. Request key is most deterministic.\"\n ),\n connectionId: z\n .string()\n .optional()\n .describe(\n \"The connection number (e.g., '1', '2') from the 'list_connections' tool.\"\n ),\n agentId: z\n .string()\n .optional()\n .describe('The account ID (e.g., 0.0.12345) of the target agent.'),\n message: z.string().describe('The text message content to send.'),\n disableMonitoring: z.boolean().optional().default(false),\n});\n\n/**\n * A tool to send a message to an agent over an established HCS-10 connection.\n */\nexport class SendMessageToConnectionTool extends BaseHCS10TransactionTool<\n typeof SendMessageToConnectionZodSchema\n> {\n name = 'send_message_to_connection';\n description =\n \"Use this to send a message to an agent you already have an active connection with. Provide the target agent's account ID (e.g., 0.0.12345) and your message. If no active connection exists, this will fail - use initiate_connection instead to create a new connection first.\";\n specificInputSchema = SendMessageToConnectionZodSchema;\n constructor(params: HCS10TransactionToolParams) {\n super(params);\n this.requiresMultipleTransactions = true;\n this.neverScheduleThisTool = true;\n }\n\n protected async callBuilderMethod(\n builder: BaseServiceBuilder,\n specificArgs: z.infer<typeof SendMessageToConnectionZodSchema>\n ): Promise<void> {\n const hcs10Builder = builder as HCS10Builder;\n\n const targetIdentifier =\n specificArgs.targetIdentifier ||\n specificArgs.agentId ||\n specificArgs.connectionId;\n\n if (!targetIdentifier) {\n throw new Error(\n 'Either targetIdentifier, connectionId, or agentId must be provided'\n );\n }\n\n const stateManager = hcs10Builder.getStateManager();\n if (stateManager) {\n const connectionsManager = stateManager.getConnectionsManager();\n if (connectionsManager) {\n try {\n const currentAgent = stateManager.getCurrentAgent();\n if (currentAgent && currentAgent.accountId) {\n await connectionsManager.fetchConnectionData(\n currentAgent.accountId\n );\n }\n } catch (error) {\n console.debug('Could not refresh connections:', error);\n }\n }\n\n if (targetIdentifier.match(/^\\d+$/)) {\n const connections = stateManager.listConnections();\n const connectionIndex = parseInt(targetIdentifier) - 1; // Connection numbers are 1-based\n\n const establishedConnections = connections.filter(\n (conn) =>\n conn.status === 'established' &&\n !conn.isPending &&\n !conn.needsConfirmation\n );\n\n if (\n connectionIndex >= 0 &&\n connectionIndex < establishedConnections.length\n ) {\n const selectedConnection = establishedConnections[connectionIndex];\n if (selectedConnection && selectedConnection.connectionTopicId) {\n await hcs10Builder.sendMessageToConnection({\n targetIdentifier: selectedConnection.connectionTopicId,\n message: specificArgs.message,\n disableMonitoring: specificArgs.disableMonitoring,\n });\n return;\n }\n }\n }\n\n if (targetIdentifier.match(/^\\d+\\.\\d+\\.\\d+$/)) {\n const connections = stateManager.listConnections();\n const establishedConnection = connections.find(\n (conn) =>\n (conn.targetAccountId === targetIdentifier ||\n conn.targetAccountId === `0.0.${targetIdentifier}`) &&\n conn.status === 'established' &&\n !conn.isPending &&\n !conn.needsConfirmation\n );\n\n if (establishedConnection && establishedConnection.connectionTopicId) {\n await hcs10Builder.sendMessageToConnection({\n targetIdentifier: establishedConnection.connectionTopicId,\n message: specificArgs.message,\n disableMonitoring: specificArgs.disableMonitoring,\n });\n return;\n }\n }\n }\n\n await hcs10Builder.sendMessageToConnection({\n targetIdentifier: targetIdentifier,\n message: specificArgs.message,\n disableMonitoring: specificArgs.disableMonitoring,\n });\n }\n}\n"],"names":[],"mappings":";;AAMA,MAAM,mCAAmC,EAAE,OAAO;AAAA,EAChD,kBAAkB,EACf,SACA,WACA;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,cAAc,EACX,SACA,WACA;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,SAAS,EACN,OAAA,EACA,SAAA,EACA,SAAS,uDAAuD;AAAA,EACnE,SAAS,EAAE,SAAS,SAAS,mCAAmC;AAAA,EAChE,mBAAmB,EAAE,QAAA,EAAU,SAAA,EAAW,QAAQ,KAAK;AACzD,CAAC;AAKM,MAAM,oCAAoC,yBAE/C;AAAA,EAKA,YAAY,QAAoC;AAC9C,UAAM,MAAM;AALd,SAAA,OAAO;AACP,SAAA,cACE;AACF,SAAA,sBAAsB;AAGpB,SAAK,+BAA+B;AACpC,SAAK,wBAAwB;AAAA,EAC/B;AAAA,EAEA,MAAgB,kBACd,SACA,cACe;AACf,UAAM,eAAe;AAErB,UAAM,mBACJ,aAAa,oBACb,aAAa,WACb,aAAa;AAEf,QAAI,CAAC,kBAAkB;AACrB,YAAM,IAAI;AAAA,QACR;AAAA,MAAA;AAAA,IAEJ;AAEA,UAAM,eAAe,aAAa,gBAAA;AAClC,QAAI,cAAc;AAChB,YAAM,qBAAqB,aAAa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AAAA,MACA,SAAS,aAAa;AAAA,MACtB,mBAAmB,aAAa;AAAA,IAAA,CACjC;AAAA,EACH;AACF;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseHCS6TransactionTool } from './base-hcs6-tools';
|
|
3
|
+
import { HCS6TransactionToolParams } from './hcs6-tool-params';
|
|
4
|
+
import { TransactionResponse } from 'hedera-agent-kit';
|
|
5
|
+
/**
|
|
6
|
+
* Schema for creating a dynamic hashinal registry
|
|
7
|
+
*/
|
|
8
|
+
declare const CreateDynamicRegistrySchema: z.ZodObject<{
|
|
9
|
+
ttl: z.ZodDefault<z.ZodNumber>;
|
|
10
|
+
adminKey: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
11
|
+
submitKey: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
ttl: number;
|
|
14
|
+
adminKey?: string | boolean | undefined;
|
|
15
|
+
submitKey?: string | boolean | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
ttl?: number | undefined;
|
|
18
|
+
adminKey?: string | boolean | undefined;
|
|
19
|
+
submitKey?: string | boolean | undefined;
|
|
20
|
+
}>;
|
|
21
|
+
export type CreateDynamicRegistryInput = z.infer<typeof CreateDynamicRegistrySchema>;
|
|
22
|
+
/**
|
|
23
|
+
* Tool for creating HCS-6 dynamic registries
|
|
24
|
+
*/
|
|
25
|
+
export declare class CreateDynamicRegistryTool extends BaseHCS6TransactionTool<typeof CreateDynamicRegistrySchema> {
|
|
26
|
+
name: string;
|
|
27
|
+
description: string;
|
|
28
|
+
schema: z.ZodObject<{
|
|
29
|
+
ttl: z.ZodDefault<z.ZodNumber>;
|
|
30
|
+
adminKey: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
31
|
+
submitKey: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
32
|
+
}, "strip", z.ZodTypeAny, {
|
|
33
|
+
ttl: number;
|
|
34
|
+
adminKey?: string | boolean | undefined;
|
|
35
|
+
submitKey?: string | boolean | undefined;
|
|
36
|
+
}, {
|
|
37
|
+
ttl?: number | undefined;
|
|
38
|
+
adminKey?: string | boolean | undefined;
|
|
39
|
+
submitKey?: string | boolean | undefined;
|
|
40
|
+
}>;
|
|
41
|
+
constructor(params: HCS6TransactionToolParams);
|
|
42
|
+
protected _call(params: CreateDynamicRegistryInput): Promise<TransactionResponse>;
|
|
43
|
+
}
|
|
44
|
+
export {};
|