hybrid 1.4.2 → 1.4.4

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.
@@ -170,4 +170,4 @@ var import_types = require("@hybrd/types");
170
170
  reactWith,
171
171
  threadedReply
172
172
  });
173
- //# sourceMappingURL=index.cjs.map
173
+ //# sourceMappingURL=behaviors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/behaviors/index.ts","../src/behaviors/filter-messages.ts","../src/behaviors/react-with.ts","../src/behaviors/threaded-reply.ts"],"sourcesContent":["// Re-export XMTP Agent SDK filters for convenience\nexport { filter } from \"@hybrd/xmtp\"\n\nexport * from \"./filter-messages\"\nexport * from \"./react-with\"\nexport * from \"./threaded-reply\"\n\n// Re-export behavior types for convenience\nexport { BehaviorRegistryImpl } from \"@hybrd/types\"\nexport type {\n\tBehavior,\n\tBehaviorConfig,\n\tBehaviorContext,\n\tBehaviorObject,\n\tBehaviorRegistry\n} from \"@hybrd/types\"\n","import type { BehaviorContext, BehaviorObject } from \"@hybrd/types\"\nimport { logger } from \"@hybrd/utils\"\nimport { filter } from \"@hybrd/xmtp\"\n\n// Filter interface that matches XMTP SDK signatures\ninterface FilterAPI {\n\tfromSelf(): boolean\n\thasContent(): boolean\n\tisDM(): boolean\n\tisGroup(): boolean\n\tisGroupAdmin(): boolean\n\tisGroupSuperAdmin(): boolean\n\tisReaction(): boolean\n\tisReaction(emoji?: string, action?: \"added\" | \"removed\"): boolean\n\tisRemoteAttachment(): boolean\n\tisReply(): boolean\n\tisText(): boolean\n\tisTextReply(): boolean\n\thasMention(mention: string): boolean\n}\n\nexport function filterMessages(\n\tfilters: (api: FilterAPI) => boolean\n): BehaviorObject {\n\treturn {\n\t\tid: \"filter-messages\",\n\t\tconfig: {\n\t\t\tenabled: true,\n\t\t\tconfig: {\n\t\t\t\tfilters: 1\n\t\t\t}\n\t\t},\n\t\tasync before(context: BehaviorContext) {\n\t\t\tconst messageContent =\n\t\t\t\ttypeof context.message.content === \"string\"\n\t\t\t\t\t? context.message.content.substring(0, 100)\n\t\t\t\t\t: String(context.message.content || \"unknown\")\n\t\t\tlogger.debug(\n\t\t\t\t`🔍 [filter-messages] Processing message: ${messageContent}...`\n\t\t\t)\n\n\t\t\t// Create filter API wrapper\n\t\t\tconst filterAPI: FilterAPI = {\n\t\t\t\tfromSelf: () =>\n\t\t\t\t\tfilter.fromSelf(context.message as any, context.client as any),\n\t\t\t\thasContent: () => filter.hasContent(context.message as any),\n\t\t\t\tisDM: () => filter.isDM(context.conversation as any),\n\t\t\t\tisGroup: () => filter.isGroup(context.conversation as any),\n\t\t\t\tisGroupAdmin: () =>\n\t\t\t\t\tfilter.isGroupAdmin(\n\t\t\t\t\t\tcontext.conversation as any,\n\t\t\t\t\t\tcontext.message as any\n\t\t\t\t\t),\n\t\t\t\tisGroupSuperAdmin: () =>\n\t\t\t\t\tfilter.isGroupSuperAdmin(\n\t\t\t\t\t\tcontext.conversation as any,\n\t\t\t\t\t\tcontext.message as any\n\t\t\t\t\t),\n\t\t\t\tisReaction: (emoji?: string, action?: \"added\" | \"removed\") => {\n\t\t\t\t\tconst isReaction = filter.isReaction(context.message as any)\n\t\t\t\t\tif (!isReaction) return false\n\n\t\t\t\t\t// Check if message has reaction content\n\t\t\t\t\tif (\n\t\t\t\t\t\t!context.message.content ||\n\t\t\t\t\t\ttypeof context.message.content !== \"object\"\n\t\t\t\t\t)\n\t\t\t\t\t\treturn false\n\n\t\t\t\t\tconst reactionContent = context.message.content as any\n\n\t\t\t\t\t// Validate reaction content structure\n\t\t\t\t\tif (!reactionContent.content) return false\n\n\t\t\t\t\t// Check emoji if specified\n\t\t\t\t\tif (emoji && reactionContent.content !== emoji) return false\n\n\t\t\t\t\t// Check action if specified\n\t\t\t\t\tif (action && reactionContent.action !== action) return false\n\n\t\t\t\t\t// If no specific checks requested, just return true\n\t\t\t\t\tif (!emoji && !action) return true\n\n\t\t\t\t\treturn true\n\t\t\t\t},\n\t\t\t\tisRemoteAttachment: () =>\n\t\t\t\t\tfilter.isRemoteAttachment(context.message as any),\n\t\t\t\tisReply: () => filter.isReply(context.message as any),\n\t\t\t\tisText: () => filter.isText(context.message as any),\n\t\t\t\tisTextReply: () => filter.isTextReply(context.message as any),\n\t\t\t\thasMention: (mention: string) => {\n\t\t\t\t\tconst content =\n\t\t\t\t\t\ttypeof context.message.content === \"string\"\n\t\t\t\t\t\t\t? context.message.content\n\t\t\t\t\t\t\t: String(context.message.content || \"\")\n\t\t\t\t\treturn content.includes(mention)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst passes = filters(filterAPI)\n\n\t\t\t\tif (!passes) {\n\t\t\t\t\tlogger.debug(\n\t\t\t\t\t\t`🔇 [filter-messages] Filter failed - message filtered out`\n\t\t\t\t\t)\n\t\t\t\t\t// Message filtered, set flag and stop the chain\n\t\t\t\t\tif (!context.sendOptions) {\n\t\t\t\t\t\tcontext.sendOptions = {}\n\t\t\t\t\t}\n\t\t\t\t\tcontext.sendOptions.filtered = true\n\t\t\t\t\t// Don't call next() - this stops the middleware chain\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tlogger.debug(`✅ [filter-messages] Filter passed`)\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error(\"Error executing message filter:\", error)\n\t\t\t\tthrow error // Re-throw to propagate the error\n\t\t\t}\n\n\t\t\tlogger.debug(`✅ [filter-messages] Filter passed, continuing chain`)\n\t\t\t// Filter passed, continue to next behavior\n\t\t\tawait context.next?.()\n\t\t}\n\t}\n}\n","import type { BehaviorContext, BehaviorObject } from \"@hybrd/types\"\nimport { logger } from \"@hybrd/utils\"\nimport { ContentTypeReaction } from \"@hybrd/xmtp\"\n\nexport interface ReactWithOptions {\n\treactToAll?: boolean\n\tenabled?: boolean\n}\n\nexport function reactWith(\n\treaction: string,\n\toptions: ReactWithOptions = {}\n): BehaviorObject {\n\treturn {\n\t\tid: `react-with-${reaction}`,\n\t\tconfig: {\n\t\t\tenabled: options.enabled ?? true,\n\t\t\tconfig: {\n\t\t\t\treaction,\n\t\t\t\treactToAll: options.reactToAll ?? true\n\t\t\t}\n\t\t},\n\t\tasync before(context: BehaviorContext) {\n\t\t\tif (!this.config.enabled) return\n\n\t\t\ttry {\n\t\t\t\tconst reactionMessage = {\n\t\t\t\t\tschema: \"unicode\",\n\t\t\t\t\treference: context.message.id,\n\t\t\t\t\taction: \"added\",\n\t\t\t\t\tcontentType: ContentTypeReaction,\n\t\t\t\t\tcontent: reaction\n\t\t\t\t}\n\n\t\t\t\tawait context.conversation.send(reactionMessage, ContentTypeReaction)\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`✅ [react-with] Reacted with ${reaction} to message ${context.message.id}`\n\t\t\t\t)\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error(\n\t\t\t\t\t`❌ [react-with] Failed to add reaction ${reaction}:`,\n\t\t\t\t\terror\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n}\n","import type { BehaviorContext, BehaviorObject } from \"@hybrd/types\"\n\nexport interface ThreadedReplyOptions {\n\tenabled?: boolean\n}\n\nexport function threadedReply(\n\toptions: ThreadedReplyOptions = {}\n): BehaviorObject {\n\treturn {\n\t\tid: \"threaded-reply\",\n\t\tconfig: {\n\t\t\tenabled: options.enabled ?? true,\n\t\t\tconfig: {\n\t\t\t\talwaysThread: true\n\t\t\t}\n\t\t},\n\t\tasync after(context: BehaviorContext) {\n\t\t\tif (!this.config.enabled) return\n\n\t\t\tif (!context.sendOptions) {\n\t\t\t\tcontext.sendOptions = {}\n\t\t\t}\n\t\t\tcontext.sendOptions.threaded = true\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAAA,eAAuB;;;ACAvB,mBAAuB;AACvB,kBAAuB;AAmBhB,SAAS,eACf,SACiB;AACjB,SAAO;AAAA,IACN,IAAI;A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AACpE,6BAAO;AAAA,UACN,oCAA+B,QAAQ,eAAe,QAAQ,QAAQ,EAAE;AAAA,QACzE;AAAA,MACD,SAAS,OAAO;AACf,6BAAO;AAAA,UACN,8CAAyC,QAAQ;AAAA,UACjD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;;;ACxCO,SAAS,cACf,UAAgC,CAAC,GAChB;AACjB,SAAO;AAAA,IACN,IAAI;AAAA,IACJ,QAAQ;AAAA,MACP,SAAS,QAAQ,WAAW;AAAA,MAC5B,QAAQ;AAAA,QACP,cAAc;AAAA,MACf;AAAA,IACD;AAAA,IACA,MAAM,MAAM,SAA0B;AACrC,UAAI,CAAC,KAAK,OAAO,QAAS;AAE1B,UAAI,CAAC,QAAQ,aAAa;AACzB,gBAAQ,cAAc,CAAC;AAAA,MACxB;AACA,cAAQ,YAAY,WAAW;AAAA,IAChC;AAAA,EACD;AACD;;;AHlBA,mBAAqC;","names":["import_xmtp","import_utils","import_xmtp"]}
@@ -141,4 +141,4 @@ export {
141
141
  reactWith,
142
142
  threadedReply
143
143
  };
144
- //# sourceMappingURL=index.js.map
144
+ //# sourceMappingURL=behaviors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/behaviors/index.ts","../src/behaviors/filter-messages.ts","../src/behaviors/react-with.ts","../src/behaviors/threaded-reply.ts"],"sourcesContent":["// Re-export XMTP Agent SDK filters for convenience\nexport { filter } from \"@hybrd/xmtp\"\n\nexport * from \"./filter-messages\"\nexport * from \"./react-with\"\nexport * from \"./threaded-reply\"\n\n// Re-export behavior types for convenience\nexport { BehaviorRegistryImpl } from \"@hybrd/types\"\nexport type {\n\tBehavior,\n\tBehaviorConfig,\n\tBehaviorContext,\n\tBehaviorObject,\n\tBehaviorRegistry\n} from \"@hybrd/types\"\n","import type { BehaviorContext, BehaviorObject } from \"@hybrd/types\"\nimport { logger } from \"@hybrd/utils\"\nimport { filter } from \"@hybrd/xmtp\"\n\n// Filter interface that matches XMTP SDK signatures\ninterface FilterAPI {\n\tfromSelf(): boolean\n\thasContent(): boolean\n\tisDM(): boolean\n\tisGroup(): boolean\n\tisGroupAdmin(): boolean\n\tisGroupSuperAdmin(): boolean\n\tisReaction(): boolean\n\tisReaction(emoji?: string, action?: \"added\" | \"removed\"): boolean\n\tisRemoteAttachment(): boolean\n\tisReply(): boolean\n\tisText(): boolean\n\tisTextReply(): boolean\n\thasMention(mention: string): boolean\n}\n\nexport function filterMessages(\n\tfilters: (api: FilterAPI) => boolean\n): BehaviorObject {\n\treturn {\n\t\tid: \"filter-messages\",\n\t\tconfig: {\n\t\t\tenabled: true,\n\t\t\tconfig: {\n\t\t\t\tfilters: 1\n\t\t\t}\n\t\t},\n\t\tasync before(context: BehaviorContext) {\n\t\t\tconst messageContent =\n\t\t\t\ttypeof context.message.content === \"string\"\n\t\t\t\t\t? context.message.content.substring(0, 100)\n\t\t\t\t\t: String(context.message.content || \"unknown\")\n\t\t\tlogger.debug(\n\t\t\t\t`🔍 [filter-messages] Processing message: ${messageContent}...`\n\t\t\t)\n\n\t\t\t// Create filter API wrapper\n\t\t\tconst filterAPI: FilterAPI = {\n\t\t\t\tfromSelf: () =>\n\t\t\t\t\tfilter.fromSelf(context.message as any, context.client as any),\n\t\t\t\thasContent: () => filter.hasContent(context.message as any),\n\t\t\t\tisDM: () => filter.isDM(context.conversation as any),\n\t\t\t\tisGroup: () => filter.isGroup(context.conversation as any),\n\t\t\t\tisGroupAdmin: () =>\n\t\t\t\t\tfilter.isGroupAdmin(\n\t\t\t\t\t\tcontext.conversation as any,\n\t\t\t\t\t\tcontext.message as any\n\t\t\t\t\t),\n\t\t\t\tisGroupSuperAdmin: () =>\n\t\t\t\t\tfilter.isGroupSuperAdmin(\n\t\t\t\t\t\tcontext.conversation as any,\n\t\t\t\t\t\tcontext.message as any\n\t\t\t\t\t),\n\t\t\t\tisReaction: (emoji?: string, action?: \"added\" | \"removed\") => {\n\t\t\t\t\tconst isReaction = filter.isReaction(context.message as any)\n\t\t\t\t\tif (!isReaction) return false\n\n\t\t\t\t\t// Check if message has reaction content\n\t\t\t\t\tif (\n\t\t\t\t\t\t!context.message.content ||\n\t\t\t\t\t\ttypeof context.message.content !== \"object\"\n\t\t\t\t\t)\n\t\t\t\t\t\treturn false\n\n\t\t\t\t\tconst reactionContent = context.message.content as any\n\n\t\t\t\t\t// Validate reaction content structure\n\t\t\t\t\tif (!reactionContent.content) return false\n\n\t\t\t\t\t// Check emoji if specified\n\t\t\t\t\tif (emoji && reactionContent.content !== emoji) return false\n\n\t\t\t\t\t// Check action if specified\n\t\t\t\t\tif (action && reactionContent.action !== action) return false\n\n\t\t\t\t\t// If no specific checks requested, just return true\n\t\t\t\t\tif (!emoji && !action) return true\n\n\t\t\t\t\treturn true\n\t\t\t\t},\n\t\t\t\tisRemoteAttachment: () =>\n\t\t\t\t\tfilter.isRemoteAttachment(context.message as any),\n\t\t\t\tisReply: () => filter.isReply(context.message as any),\n\t\t\t\tisText: () => filter.isText(context.message as any),\n\t\t\t\tisTextReply: () => filter.isTextReply(context.message as any),\n\t\t\t\thasMention: (mention: string) => {\n\t\t\t\t\tconst content =\n\t\t\t\t\t\ttypeof context.message.content === \"string\"\n\t\t\t\t\t\t\t? context.message.content\n\t\t\t\t\t\t\t: String(context.message.content || \"\")\n\t\t\t\t\treturn content.includes(mention)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst passes = filters(filterAPI)\n\n\t\t\t\tif (!passes) {\n\t\t\t\t\tlogger.debug(\n\t\t\t\t\t\t`🔇 [filter-messages] Filter failed - message filtered out`\n\t\t\t\t\t)\n\t\t\t\t\t// Message filtered, set flag and stop the chain\n\t\t\t\t\tif (!context.sendOptions) {\n\t\t\t\t\t\tcontext.sendOptions = {}\n\t\t\t\t\t}\n\t\t\t\t\tcontext.sendOptions.filtered = true\n\t\t\t\t\t// Don't call next() - this stops the middleware chain\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tlogger.debug(`✅ [filter-messages] Filter passed`)\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error(\"Error executing message filter:\", error)\n\t\t\t\tthrow error // Re-throw to propagate the error\n\t\t\t}\n\n\t\t\tlogger.debug(`✅ [filter-messages] Filter passed, continuing chain`)\n\t\t\t// Filter passed, continue to next behavior\n\t\t\tawait context.next?.()\n\t\t}\n\t}\n}\n","import type { BehaviorContext, BehaviorObject } from \"@hybrd/types\"\nimport { logger } from \"@hybrd/utils\"\nimport { ContentTypeReaction } from \"@hybrd/xmtp\"\n\nexport interface ReactWithOptions {\n\treactToAll?: boolean\n\tenabled?: boolean\n}\n\nexport function reactWith(\n\treaction: string,\n\toptions: ReactWithOptions = {}\n): BehaviorObject {\n\treturn {\n\t\tid: `react-with-${reaction}`,\n\t\tconfig: {\n\t\t\tenabled: options.enabled ?? true,\n\t\t\tconfig: {\n\t\t\t\treaction,\n\t\t\t\treactToAll: options.reactToAll ?? true\n\t\t\t}\n\t\t},\n\t\tasync before(context: BehaviorContext) {\n\t\t\tif (!this.config.enabled) return\n\n\t\t\ttry {\n\t\t\t\tconst reactionMessage = {\n\t\t\t\t\tschema: \"unicode\",\n\t\t\t\t\treference: context.message.id,\n\t\t\t\t\taction: \"added\",\n\t\t\t\t\tcontentType: ContentTypeReaction,\n\t\t\t\t\tcontent: reaction\n\t\t\t\t}\n\n\t\t\t\tawait context.conversation.send(reactionMessage, ContentTypeReaction)\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`✅ [react-with] Reacted with ${reaction} to message ${context.message.id}`\n\t\t\t\t)\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error(\n\t\t\t\t\t`❌ [react-with] Failed to add reaction ${reaction}:`,\n\t\t\t\t\terror\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n}\n","import type { BehaviorContext, BehaviorObject } from \"@hybrd/types\"\n\nexport interface ThreadedReplyOptions {\n\tenabled?: boolean\n}\n\nexport function threadedReply(\n\toptions: ThreadedReplyOptions = {}\n): BehaviorObject {\n\treturn {\n\t\tid: \"threaded-reply\",\n\t\tconfig: {\n\t\t\tenabled: options.enabled ?? true,\n\t\t\tconfig: {\n\t\t\t\talwaysThread: true\n\t\t\t}\n\t\t},\n\t\tasync after(context: BehaviorContext) {\n\t\t\tif (!this.config.enabled) return\n\n\t\t\tif (!context.sendOptions) {\n\t\t\t\tcontext.sendOptions = {}\n\t\t\t}\n\t\t\tcontext.sendOptions.threaded = true\n\t\t}\n\t}\n}\n"],"mappings":";AACA,SAAS,UAAAA,eAAc;;;ACAvB,SAAS,cAAc;AACvB,SAAS,cAAc;AAmBhB,SAAS,eACf,SACiB;AACjB,SAAO;AAAA,IACN,IAAI;AAAA,IACJ,QAAQ;AAAA,MACP,SAAS;AAAA,MACT,QAAQ;AAAA,QACP,SAAS;AAAA,MACV;AAAA,IACD;AAAA,IACA,MAAM,OAAO,SAA0B;AACtC,YAAM,iBACL,OAAO,QAAQ,QAAQ,YAAY,WAChC,QAAQ,QAAQ,QAAQ,UAAU,GAAG,GAAG,IACxC,OAAO,QAAQ,QAAQ,WAAW,SAAS;AAC/C,aAAO;AAAA,QACN,mDAA4C,cAAc;AAAA,MAC3D;AAGA,YAAM,YAAuB;AAAA,QAC5B,UAAU,MACT,OAAO,SAAS,QAAQ,SAAgB,QAAQ,MAAa;AAAA,QAC9D,YAAY,MAAM,OAAO,WAAW,QAAQ,OAAc;AAAA,QAC1D,MAAM,MAAM,OAAO,KAAK,QAAQ,YAAmB;AAAA,QACnD,SAAS,MAAM,OAAO,QAAQ,QAAQ,YAAmB;AAAA,QACzD,cAAc,MACb,OAAO;AAAA,UACN,QAAQ;AAAA,UACR,QAAQ;AAAA,QACT;AAAA,QACD,mBAAmB,MAClB,OAAO;AAAA,UACN,QAAQ;AAAA,UACR,QAAQ;AAAA,QACT;AAAA,QACD,YAAY,CAAC,OAAgB,WAAiC;AAC7D,gBAAM,aAAa,OAAO,WAAW,QAAQ,OAAc;AAC3D,cAAI,CAAC,WAAY,QAAO;A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AAc,QAAQ;AAAA,IAC1B,QAAQ;AAAA,MACP,SAAS,QAAQ,WAAW;AAAA,MAC5B,QAAQ;AAAA,QACP;AAAA,QACA,YAAY,QAAQ,cAAc;AAAA,MACnC;AAAA,IACD;AAAA,IACA,MAAM,OAAO,SAA0B;AACtC,UAAI,CAAC,KAAK,OAAO,QAAS;AAE1B,UAAI;AACH,cAAM,kBAAkB;AAAA,UACvB,QAAQ;AAAA,UACR,WAAW,QAAQ,QAAQ;AAAA,UAC3B,QAAQ;AAAA,UACR,aAAa;AAAA,UACb,SAAS;AAAA,QACV;AAEA,cAAM,QAAQ,aAAa,KAAK,iBAAiB,mBAAmB;AACpE,QAAAA,QAAO;AAAA,UACN,oCAA+B,QAAQ,eAAe,QAAQ,QAAQ,EAAE;AAAA,QACzE;AAAA,MACD,SAAS,OAAO;AACf,QAAAA,QAAO;AAAA,UACN,8CAAyC,QAAQ;AAAA,UACjD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;;;ACxCO,SAAS,cACf,UAAgC,CAAC,GAChB;AACjB,SAAO;AAAA,IACN,IAAI;AAAA,IACJ,QAAQ;AAAA,MACP,SAAS,QAAQ,WAAW;AAAA,MAC5B,QAAQ;AAAA,QACP,cAAc;AAAA,MACf;AAAA,IACD;AAAA,IACA,MAAM,MAAM,SAA0B;AACrC,UAAI,CAAC,KAAK,OAAO,QAAS;AAE1B,UAAI,CAAC,QAAQ,aAAa;AACzB,gBAAQ,cAAc,CAAC;AAAA,MACxB;AACA,cAAQ,YAAY,WAAW;AAAA,IAChC;AAAA,EACD;AACD;;;AHlBA,SAAS,4BAA4B;","names":["filter","logger"]}
package/dist/index.cjs CHANGED
@@ -493,11 +493,11 @@ var Agent = class {
493
493
  };
494
494
 
495
495
  // src/tools/blockchain.ts
496
+ var import_utils5 = require("@hybrd/utils");
496
497
  var import_viem = require("viem");
497
498
  var import_accounts = require("viem/accounts");
498
499
  var import_chains = require("viem/chains");
499
500
  var import_zod = require("zod");
500
- var import_utils5 = require("@hybrd/utils");
501
501
  var SUPPORTED_CHAINS = {
502
502
  mainnet: import_chains.mainnet,
503
503
  sepolia: import_chains.sepolia,
@@ -507,7 +507,6 @@ var SUPPORTED_CHAINS = {
507
507
  base: import_chains.base
508
508
  };
509
509
  var getBalanceTool = createTool({
510
- id: "getBalance",
511
510
  description: "Get the native token balance for a wallet address on a blockchain",
512
511
  inputSchema: import_zod.z.object({
513
512
  address: import_zod.z.string().describe("The wallet address to check balance for"),
@@ -530,7 +529,9 @@ var getBalanceTool = createTool({
530
529
  chain: chainConfig,
531
530
  transport: (0, import_viem.http)(rpcUrl)
532
531
  });
533
- import_utils5.logger.debug(`\u{1F50D} [getBalance] Checking balance for ${address} on ${chain}`);
532
+ import_utils5.logger.debug(
533
+ `\u{1F50D} [getBalance] Checking balance for ${address} on ${chain}`
534
+ );
534
535
  const balanceWei = await client.getBalance({
535
536
  address
536
537
  });
@@ -560,7 +561,6 @@ var getBalanceTool = createTool({
560
561
  }
561
562
  });
562
563
  var getTransactionTool = createTool({
563
- id: "getTransaction",
564
564
  description: "Get transaction details by transaction hash",
565
565
  inputSchema: import_zod.z.object({
566
566
  hash: import_zod.z.string().describe("The transaction hash to look up"),
@@ -625,7 +625,6 @@ var getTransactionTool = createTool({
625
625
  }
626
626
  });
627
627
  var sendTransactionTool = createTool({
628
- id: "sendTransaction",
629
628
  description: "Send native tokens to another address",
630
629
  inputSchema: import_zod.z.object({
631
630
  to: import_zod.z.string().describe("The recipient address"),
@@ -692,7 +691,6 @@ var sendTransactionTool = createTool({
692
691
  }
693
692
  });
694
693
  var getBlockTool = createTool({
695
- id: "getBlock",
696
694
  description: "Get information about a blockchain block",
697
695
  inputSchema: import_zod.z.object({
698
696
  blockNumber: import_zod.z.string().optional().describe("Block number (defaults to latest)"),
@@ -750,7 +748,6 @@ var getBlockTool = createTool({
750
748
  }
751
749
  });
752
750
  var getGasPriceTool = createTool({
753
- id: "getGasPrice",
754
751
  description: "Get current gas price for a blockchain",
755
752
  inputSchema: import_zod.z.object({
756
753
  chain: import_zod.z.enum(["mainnet", "sepolia", "polygon", "arbitrum", "optimism", "base"]).default("mainnet").describe("The blockchain network to check on")
@@ -793,7 +790,6 @@ var getGasPriceTool = createTool({
793
790
  }
794
791
  });
795
792
  var estimateGasTool = createTool({
796
- id: "estimateGas",
797
793
  description: "Estimate gas required for a transaction",
798
794
  inputSchema: import_zod.z.object({
799
795
  to: import_zod.z.string().describe("The recipient address"),
@@ -873,7 +869,6 @@ var import_utils6 = require("@hybrd/utils");
873
869
  var import_xmtp2 = require("@hybrd/xmtp");
874
870
  var import_zod2 = require("zod");
875
871
  var getMessageTool = createTool({
876
- id: "getMessage",
877
872
  description: "Get a specific message by ID from XMTP",
878
873
  inputSchema: import_zod2.z.object({
879
874
  messageId: import_zod2.z.string().describe("The message ID to retrieve")
@@ -883,7 +878,7 @@ var getMessageTool = createTool({
883
878
  message: import_zod2.z.object({
884
879
  id: import_zod2.z.string(),
885
880
  conversationId: import_zod2.z.string(),
886
- content: import_zod2.z.union([import_zod2.z.string(), import_zod2.z.record(import_zod2.z.unknown()), import_zod2.z.unknown()]).optional(),
881
+ content: import_zod2.z.union([import_zod2.z.string(), import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()), import_zod2.z.unknown()]).optional(),
887
882
  senderInboxId: import_zod2.z.string(),
888
883
  sentAt: import_zod2.z.date(),
889
884
  contentType: import_zod2.z.object({
@@ -956,7 +951,6 @@ var getMessageTool = createTool({
956
951
  }
957
952
  });
958
953
  var sendReactionTool = createTool({
959
- id: "sendReaction",
960
954
  description: "Send an emoji reaction to a message to indicate it has been seen",
961
955
  inputSchema: import_zod2.z.object({
962
956
  emoji: import_zod2.z.string().default("\u{1F440}").describe(
@@ -1044,7 +1038,6 @@ var sendReactionTool = createTool({
1044
1038
  }
1045
1039
  });
1046
1040
  var sendMessageTool = createTool({
1047
- id: "sendMessage",
1048
1041
  description: "Send a message to an XMTP conversation",
1049
1042
  inputSchema: import_zod2.z.object({
1050
1043
  content: import_zod2.z.string().describe("The message content to send"),
@@ -1091,7 +1084,7 @@ var sendMessageTool = createTool({
1091
1084
  targetConversationId = recipientAddress;
1092
1085
  }
1093
1086
  const sendStartTime = performance.now();
1094
- const messageId = await conversation.send(content);
1087
+ const messageId = await conversation.send(content, import_xmtp2.ContentTypeText);
1095
1088
  const sendEndTime = performance.now();
1096
1089
  import_utils6.logger.debug(
1097
1090
  `\u{1F4AC} [Tool:sendMessage] XMTP client sendMessage completed in ${(sendEndTime - sendStartTime).toFixed(2)}ms`
@@ -1134,7 +1127,6 @@ var sendMessageTool = createTool({
1134
1127
  }
1135
1128
  });
1136
1129
  var sendReplyTool = createTool({
1137
- id: "sendReply",
1138
1130
  description: "Send a reply to a specific message in an XMTP conversation",
1139
1131
  inputSchema: import_zod2.z.object({
1140
1132
  content: import_zod2.z.string().describe("The reply content to send"),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/core/agent.ts","../src/lib/render.ts","../src/server/listen.ts","../src/core/plugin.ts","../src/core/tool.ts","../src/tools/blockchain.ts","../src/tools/xmtp.ts"],"sourcesContent":["export type { AgentRuntime } from \"@hybrd/types\"\nexport { Agent } from \"./core/agent\"\nexport type { AgentConfig, DefaultRuntimeExtension } from \"./core/agent\"\nexport { PluginRegistry } from \"./core/plugin\"\nexport type { Plugin } from \"./core/plugin\"\nexport { createTool, toolFactory } from \"./core/tool\"\nexport type { Tool, ToolConfig } from \"./core/tool\"\nexport { listen } from \"./server/listen\"\nexport type { ListenOptions } from \"./server/listen\"\n\n// Re-export tools standard library\nexport * from \"./tools\"\n","import type {\n\tAgentConfig,\n\tAgentRuntime,\n\tAnyTool,\n\tDefaultRuntimeExtension,\n\tGenerateOptions,\n\tAgent as IAgent,\n\tPlugin,\n\tPluginContext,\n\tStreamOptions,\n\tToolGenerator\n} from \"@hybrd/types\"\nimport { randomUUID } from \"@hybrd/utils\"\nimport {\n\tLanguageModel,\n\tUIMessage,\n\tconvertToModelMessages,\n\tgenerateText,\n\tsmoothStream,\n\tstepCountIs,\n\tstreamText\n} from \"ai\"\nimport { render } from \"../lib/render\"\nimport { ListenOptions, listen } from \"../server/listen\"\nimport { PluginRegistry as PluginRegistryImpl } from \"./plugin\"\nimport { toAISDKTools } from \"./tool\"\n\n// Re-export types from @hybrd/types for backward compatibility\nexport type {\n\tAgentConfig,\n\tDefaultRuntimeExtension,\n\tGenerateOptions,\n\tStreamOptions,\n\tToolGenerator\n}\n\n/**\n * Core Agent implementation using AI SDK 5 directly.\n * This class provides a flexible interface for creating AI agents with\n * dynamic configuration, tool support, and streaming capabilities.\n */\nexport class Agent<TRuntimeExtension = DefaultRuntimeExtension>\n\timplements IAgent<TRuntimeExtension, PluginContext>\n{\n\t/** Agent's unique identifier */\n\tpublic readonly name: string\n\t/** Agent configuration */\n\tprivate readonly config: AgentConfig<TRuntimeExtension>\n\t/** Default parameters for text generation */\n\tprivate readonly generationDefaults: Partial<\n\t\tPick<\n\t\t\tParameters<typeof generateText>[0],\n\t\t\t| \"model\"\n\t\t\t| \"messages\"\n\t\t\t| \"tools\"\n\t\t\t| \"toolChoice\"\n\t\t\t| \"stopWhen\"\n\t\t\t| \"maxOutputTokens\"\n\t\t\t| \"temperature\"\n\t\t>\n\t>\n\t/** Default parameters for text streaming */\n\tprivate readonly streamDefaults: Partial<\n\t\tPick<\n\t\t\tParameters<typeof streamText>[0],\n\t\t\t| \"model\"\n\t\t\t| \"messages\"\n\t\t\t| \"tools\"\n\t\t\t| \"toolChoice\"\n\t\t\t| \"stopWhen\"\n\t\t\t| \"experimental_transform\"\n\t\t\t| \"maxOutputTokens\"\n\t\t\t| \"temperature\"\n\t\t>\n\t>\n\t/** Plugin registry for extending the agent's HTTP server */\n\tpublic readonly plugins: PluginRegistryImpl<PluginContext>\n\n\t/**\n\t * Creates a new Agent instance with the specified configuration.\n\t * @param config - Configuration object for the agent\n\t */\n\tconstructor(config: AgentConfig<TRuntimeExtension>) {\n\t\tthis.name = config.name\n\t\tthis.config = config\n\t\tthis.plugins = new PluginRegistryImpl<PluginContext>()\n\n\t\tthis.generationDefaults = {\n\t\t\tmaxOutputTokens: config.maxTokens,\n\t\t\ttemperature: config.temperature\n\t\t}\n\n\t\tthis.streamDefaults = {\n\t\t\tmaxOutputTokens: config.maxTokens,\n\t\t\ttemperature: config.temperature\n\t\t}\n\t}\n\n\t/**\n\t * Resolves dynamic configuration properties (model, tools, instructions) with runtime context.\n\t * @param messages - Current conversation messages\n\t * @param runtime - Runtime context for the agent\n\t * @returns Resolved configuration with model, tools, and instructions\n\t */\n\tprivate async resolveConfig(\n\t\tmessages: UIMessage[],\n\t\truntime: AgentRuntime & TRuntimeExtension\n\t): Promise<{\n\t\tmodel: LanguageModel\n\t\ttools?: Record<string, AnyTool<TRuntimeExtension>>\n\t\tinstructions?: string\n\t}> {\n\t\tconst props = { messages, runtime }\n\n\t\tconst model =\n\t\t\ttypeof this.config.model === \"function\"\n\t\t\t\t? await this.config.model(props)\n\t\t\t\t: this.config.model\n\n\t\tconst tools =\n\t\t\ttypeof this.config.tools === \"function\"\n\t\t\t\t? await this.config.tools(props)\n\t\t\t\t: this.config.tools\n\n\t\tconst instructions =\n\t\t\ttypeof this.config.instructions === \"function\"\n\t\t\t\t? await this.config.instructions(props)\n\t\t\t\t: this.config.instructions\n\n\t\treturn {\n\t\t\tmodel,\n\t\t\ttools,\n\t\t\tinstructions: render(instructions, runtime as Record<string, unknown>)\n\t\t}\n\t}\n\n\t/**\n\t * Prepares messages by adding system instructions if provided.\n\t * Merges instructions with existing system messages or creates new ones.\n\t * @param messages - Current conversation messages\n\t * @param instructions - System instructions to add\n\t * @returns Messages with system instructions properly integrated\n\t */\n\tprivate prepareMessages(\n\t\tmessages: UIMessage[],\n\t\tinstructions?: string\n\t): UIMessage[] {\n\t\tif (!instructions) {\n\t\t\treturn messages\n\t\t}\n\n\t\tif (messages[0]?.role === \"system\") {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\t...messages[0],\n\t\t\t\t\tparts: [{ type: \"text\", text: instructions }]\n\t\t\t\t},\n\t\t\t\t...messages.slice(1)\n\t\t\t]\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: \"system\",\n\t\t\t\tid: randomUUID(),\n\t\t\t\tparts: [{ type: \"text\", text: instructions }]\n\t\t\t},\n\t\t\t...messages\n\t\t]\n\t}\n\n\t/**\n\t * Generates a text completion using the agent's configuration.\n\t * @param messages - Conversation messages to generate from\n\t * @param options - Generation options including runtime context\n\t * @returns Generated text completion result\n\t */\n\tasync generate(\n\t\tmessages: UIMessage[],\n\t\toptions: GenerateOptions<TRuntimeExtension>\n\t) {\n\t\t// Ensure runtime is properly extended with createRuntime function\n\t\tconst extendedRuntime = await this.createRuntimeContext(options.runtime)\n\n\t\tconst { model, tools, instructions } = await this.resolveConfig(\n\t\t\tmessages,\n\t\t\textendedRuntime\n\t\t)\n\n\t\tconst preparedMessages = this.prepareMessages(messages, instructions)\n\n\t\tconst { runtime, maxTokens, telemetry, prompt, ...aiSdkOptions } = options\n\n\t\tconst aiSDKTools = tools\n\t\t\t? toAISDKTools<TRuntimeExtension>(\n\t\t\t\t\ttools,\n\t\t\t\t\textendedRuntime,\n\t\t\t\t\tpreparedMessages\n\t\t\t\t)\n\t\t\t: undefined\n\n\t\tconst result = await generateText({\n\t\t\t...this.generationDefaults,\n\t\t\t...aiSdkOptions,\n\t\t\tmodel,\n\t\t\tmessages: convertToModelMessages(preparedMessages),\n\t\t\ttools: aiSDKTools,\n\t\t\ttoolChoice:\n\t\t\t\taiSDKTools && Object.keys(aiSDKTools).length > 0 ? \"auto\" : undefined,\n\t\t\tstopWhen: [stepCountIs(this.config.maxSteps ?? 5)],\n\t\t\tmaxOutputTokens: maxTokens\n\t\t})\n\n\t\treturn result\n\t}\n\n\t/**\n\t * Streams a text completion using the agent's configuration.\n\t * @param messages - Conversation messages to generate from\n\t * @param options - Streaming options including runtime context\n\t * @returns Streaming response that can be consumed\n\t */\n\tasync stream(\n\t\tmessages: UIMessage[],\n\t\toptions: StreamOptions<TRuntimeExtension>\n\t) {\n\t\t// Ensure runtime is properly extended with createRuntime function\n\t\tconst extendedRuntime = await this.createRuntimeContext(options.runtime)\n\n\t\tconst { model, tools, instructions } = await this.resolveConfig(\n\t\t\tmessages,\n\t\t\textendedRuntime\n\t\t)\n\n\t\tconst preparedMessages = this.prepareMessages(messages, instructions)\n\n\t\tconst { runtime, onFinish, maxTokens, telemetry, prompt, ...aiSdkOptions } =\n\t\t\toptions\n\n\t\tconst aiSDKTools = tools\n\t\t\t? toAISDKTools<TRuntimeExtension>(\n\t\t\t\t\ttools,\n\t\t\t\t\textendedRuntime,\n\t\t\t\t\tpreparedMessages\n\t\t\t\t)\n\t\t\t: undefined\n\n\t\tconst result = await streamText({\n\t\t\t...this.streamDefaults,\n\t\t\t...aiSdkOptions,\n\t\t\tmodel,\n\t\t\tmessages: convertToModelMessages(preparedMessages),\n\t\t\ttools: aiSDKTools,\n\t\t\ttoolChoice:\n\t\t\t\taiSDKTools && Object.keys(aiSDKTools).length > 0 ? \"auto\" : undefined,\n\t\t\tstopWhen: [stepCountIs(this.config.maxSteps ?? 5)],\n\t\t\texperimental_transform: smoothStream(),\n\t\t\tmaxOutputTokens: maxTokens\n\t\t})\n\n\t\treturn result.toUIMessageStreamResponse({\n\t\t\toriginalMessages: messages,\n\t\t\tonFinish\n\t\t})\n\t}\n\n\t/**\n\t * Gets the agent's configuration for debugging and inspection.\n\t * @returns Object containing agent configuration details\n\t */\n\tgetConfig() {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\thasModel: !!this.config.model,\n\t\t\thasTools: !!this.config.tools,\n\t\t\thasInstructions: !!this.config.instructions\n\t\t}\n\t}\n\n\t/**\n\t * Gets the agent's instructions without running generation.\n\t * Useful for external integrations that need instructions separately.\n\t * @param options - Options containing runtime context and optional messages\n\t * @returns Resolved instructions string\n\t */\n\tasync getInstructions(options: {\n\t\truntime: AgentRuntime & TRuntimeExtension\n\t\tmessages?: UIMessage[]\n\t}) {\n\t\t// Ensure runtime is properly extended with createRuntime function\n\t\tconst extendedRuntime = await this.createRuntimeContext(options.runtime)\n\n\t\tconst messages = options.messages || []\n\t\tconst props = { messages, runtime: extendedRuntime }\n\n\t\tif (typeof this.config.instructions === \"function\") {\n\t\t\treturn await this.config.instructions(props)\n\t\t}\n\t\treturn this.config.instructions\n\t}\n\n\t/**\n\t * Gets the agent's tools without running generation.\n\t * Useful for external integrations that need tools separately.\n\t * @param options - Options containing runtime context and optional messages\n\t * @returns Resolved tools object\n\t */\n\tasync getTools(options: {\n\t\truntime: AgentRuntime & TRuntimeExtension\n\t\tmessages?: UIMessage[]\n\t}) {\n\t\t// Ensure runtime is properly extended with createRuntime function\n\t\tconst extendedRuntime = await this.createRuntimeContext(options.runtime)\n\n\t\tconst messages = options.messages || []\n\t\tconst props = { messages, runtime: extendedRuntime }\n\n\t\tif (typeof this.config.tools === \"function\") {\n\t\t\treturn await this.config.tools(props)\n\t\t}\n\t\treturn this.config.tools\n\t}\n\n\t/**\n\t * Creates the complete runtime context by merging base runtime with custom extension.\n\t * @param baseRuntime - The base runtime context containing XMTP properties\n\t * @returns Complete runtime context with custom extensions applied\n\t */\n\t/**\n\t * Creates the complete runtime context by merging base runtime with custom extension.\n\t * @param baseRuntime - The base runtime context containing XMTP properties\n\t * @returns Complete runtime context with custom extensions applied\n\t */\n\tasync createRuntimeContext(\n\t\tbaseRuntime: AgentRuntime\n\t): Promise<AgentRuntime & TRuntimeExtension> {\n\t\t// Always start with the default runtime (baseRuntime)\n\t\tlet completeRuntime = { ...baseRuntime } as AgentRuntime & TRuntimeExtension\n\n\t\t// If user provided createRuntime function, extend the default runtime\n\t\tif (this.config.createRuntime) {\n\t\t\tconst userExtension = await this.config.createRuntime(completeRuntime)\n\t\t\tcompleteRuntime = {\n\t\t\t\t...completeRuntime,\n\t\t\t\t...userExtension\n\t\t\t} as AgentRuntime & TRuntimeExtension\n\t\t}\n\n\t\treturn completeRuntime\n\t}\n\n\t/**\n\t * Registers a plugin with the agent\n\t *\n\t * @param plugin - The plugin to register\n\t */\n\tuse(plugin: Plugin<PluginContext>): void {\n\t\tthis.plugins.register(plugin)\n\t}\n\n\t/**\n\t * Starts listening for messages and events using the agent instance.\n\t * @param opts - Configuration options for the listener, excluding the agent property\n\t */\n\tasync listen(opts: Omit<ListenOptions, \"agent\">) {\n\t\tlisten({ ...opts, agent: this as Agent<DefaultRuntimeExtension> })\n\t}\n}\n","import { Eta } from \"eta\"\n\nexport const eta = new Eta({\n\tviews: \"templates\"\n})\n\nexport const render = (template: string, runtime: Record<string, unknown>) => {\n\treturn eta.renderString(template, runtime)\n}\n","import { serve } from \"@hono/node-server\"\nimport type {\n\tBehaviorObject,\n\tDefaultRuntimeExtension,\n\tHonoVariables,\n\tPluginContext,\n\tXmtpClient\n} from \"@hybrd/types\"\nimport { BehaviorRegistryImpl } from \"@hybrd/types\"\nimport { logger } from \"@hybrd/utils\"\nimport { XMTPPlugin } from \"@hybrd/xmtp\"\nimport { Context, Hono, Next } from \"hono\"\nimport type { Agent } from \"../core/agent\"\nimport type { Plugin } from \"../core/plugin\"\n\nexport type { HonoVariables }\n\n/**\n * Creates Hono middleware to inject XMTP client into request context\n *\n * @description\n * This middleware function sets the XMTP client instance in the Hono context,\n * making it available to all subsequent middleware and route handlers.\n * The client can be accessed via `c.get(\"xmtpClient\")` in route handlers.\n *\n * @param client - The XMTP client instance to inject into the context\n * @returns Hono middleware function that sets the XMTP client in context\n *\n * @example\n * ```typescript\n * app.use(createHonoMiddleware(xmtpClient))\n *\n * app.get(\"/messages\", (c) => {\n * const client = c.get(\"xmtpClient\")\n * // Use the client to interact with XMTP\n * })\n * ```\n */\nexport function createHonoMiddleware(client: XmtpClient) {\n\treturn async (c: Context, next: Next) => {\n\t\tc.set(\"xmtpClient\", client)\n\t\treturn next()\n\t}\n}\n\n/**\n * Options for creating a Hono app with XMTP integration\n *\n * @description\n * Configuration object for setting up a Hono application that includes\n * XMTP client middleware, background message processing, and XMTP tools routes.\n *\n * @template TRuntimeExtension - Runtime extension type for the agent\n * @property agent - The agent instance to use for message processing\n */\nexport type CreateHonoAppOptions<TRuntimeExtension = DefaultRuntimeExtension> =\n\t{\n\t\tagent: Agent<TRuntimeExtension>\n\t}\n\n/**\n * Creates a Hono app with full XMTP integration and background message processing\n *\n * @description\n * This function creates a complete Hono application configured with:\n * - XMTP client middleware for request context\n * - Background message processor for handling XMTP messages\n * - XMTP tools routes for external integrations\n * - Environment variable validation for required XMTP credentials\n *\n * The app automatically starts a background message processor that listens for\n * XMTP messages and forwards them to the provided agent for processing.\n *\n * @template TRuntimeExtension - Runtime extension type for the agent\n * @param options - Configuration options for the Hono app\n * @param options.agent - The agent instance to handle XMTP messages\n * @returns Promise that resolves to a configured Hono app instance\n *\n * @throws {Error} When XMTP_WALLET_KEY environment variable is not set\n * @throws {Error} When XMTP_DB_ENCRYPTION_KEY environment variable is not set\n *\n * @example\n * ```typescript\n * const app = await createHonoApp({ agent: myAgent })\n *\n * // The app now has XMTP integration and background processing\n * app.get(\"/health\", (c) => c.json({ status: \"ok\" }))\n * ```\n */\nexport async function createHonoApp<\n\tTRuntimeExtension = DefaultRuntimeExtension\n>({ agent }: CreateHonoAppOptions<TRuntimeExtension>) {\n\tconst app = new Hono<{ Variables: HonoVariables }>()\n\n\t// Mount XMTP tools routes\n\t// app.route(\"/xmtp-tools\", xmtpApp) // This line is removed as per the edit hint\n\n\treturn app\n}\n\n/**\n * Options for starting the XMTP tools HTTP server\n *\n * @description\n * Configuration object for the standalone XMTP tools server that provides\n * basic HTTP endpoints for health checks and XMTP operations.\n *\n * @property agent - The agent instance to associate with the server\n * @property port - The port number to listen on (defaults to 8454)\n * @property filter - Optional message filter for XMTP messages\n * @property plugins - Optional array of plugins to apply to the server\n * @property behaviors - Optional array of behaviors to apply to message processing\n */\nexport type ListenOptions = {\n\tagent: Agent\n\tport: string\n\tplugins?: Plugin<PluginContext>[]\n\tbehaviors?: BehaviorObject[]\n}\n\n/**\n * Starts a standalone XMTP tools HTTP server\n *\n * @description\n * This function creates and starts a minimal HTTP server specifically for\n * XMTP tools operations. It includes:\n * - Health check endpoint at `/health`\n * - 404 handler for unmatched routes\n * - Automatic port parsing from string input\n * - Plugin-based route mounting\n *\n * The server runs independently and is useful for scenarios where you need\n * XMTP tools functionality without the full Hono app integration.\n *\n * @param options - Configuration options for the server\n * @param options.agent - The agent instance to associate with the server\n * @param options.port - The port number to listen on (parsed as integer)\n *\n * @example\n * ```typescript\n * listen({\n * agent: myAgent,\n * port: \"3000\"\n * })\n *\n * // Server starts on port 3000 with health endpoint at /health\n * // and all registered plugins applied\n * ```\n */\nexport async function listen({\n\tagent,\n\tport,\n\tplugins = [],\n\tbehaviors = []\n}: ListenOptions) {\n\tconst app = new Hono<{ Variables: HonoVariables }>()\n\tconst context = {\n\t\tagent,\n\t\tbehaviors: behaviors.length > 0 ? new BehaviorRegistryImpl() : undefined\n\t} as PluginContext & { behaviors?: BehaviorRegistryImpl }\n\n\t// Register behaviors if provided\n\tif (behaviors.length > 0 && context.behaviors) {\n\t\tcontext.behaviors.registerAll(behaviors)\n\t}\n\n\tconst xmtpPlugin = XMTPPlugin()\n\n\t// Right now we always apply the XMTP plugin, but this may change in the future.\n\tawait xmtpPlugin.apply(app, context)\n\n\t// Apply plugins from agent registry first\n\tawait agent.plugins.applyAll(app, context)\n\n\t// Apply plugins from listen options\n\tfor (const plugin of plugins) {\n\t\tawait plugin.apply(app, context)\n\t}\n\n\tapp.get(\"/health\", (c) => {\n\t\treturn c.json({\n\t\t\tstatus: \"healthy\",\n\t\t\tservice: agent.name,\n\t\t\ttimestamp: new Date().toISOString()\n\t\t})\n\t})\n\n\tapp.notFound((c) => {\n\t\treturn c.json({ error: \"Not found\" }, 404)\n\t})\n\n\tconst httpPort = Number.parseInt(port || \"8454\")\n\n\t// Setup graceful shutdown\n\tconst shutdown = async () => {\n\t\tlogger.debug(\"Waiting for graceful termination...\")\n\n\t\t// Stop background processor first\n\t\t// try {\n\t\t// \tstopBackground()\n\t\t// } catch (error) {\n\t\t// \tconsole.error(\"Error stopping background processor:\", error)\n\t\t// }\n\n\t\t// Give some time for cleanup\n\t\tawait new Promise((resolve) => setTimeout(resolve, 1000))\n\t}\n\n\t// Register shutdown handlers\n\tprocess.once(\"SIGINT\", async () => {\n\t\tawait shutdown()\n\t\tprocess.exit(0)\n\t})\n\n\tprocess.once(\"SIGTERM\", async () => {\n\t\tawait shutdown()\n\t\tprocess.exit(0)\n\t})\n\n\t// Handle uncaught errors\n\tprocess.on(\"uncaughtException\", async (error) => {\n\t\tconsole.error(\"Uncaught exception:\", error)\n\t\tawait shutdown()\n\t\tprocess.exit(1)\n\t})\n\n\tprocess.on(\"unhandledRejection\", async (reason) => {\n\t\tconsole.error(\"Unhandled rejection:\", reason)\n\t\tawait shutdown()\n\t\tprocess.exit(1)\n\t})\n\n\ttry {\n\t\tserve({\n\t\t\tfetch: app.fetch,\n\t\t\tport: httpPort\n\t\t})\n\n\t\t// Clean startup messaging\n\t\tconsole.log(`Starting hybrid ... ✅ DONE`)\n\t\tconsole.log(`Hybrid listening on http://localhost:${httpPort}`)\n\n\t\t// Get XMTP info for \"We are online\" message\n\t\tconst xmtpWalletKey = process.env.XMTP_WALLET_KEY\n\t\tconst xmtpEnv = process.env.XMTP_ENV || \"production\"\n\n\t\tif (xmtpWalletKey) {\n\t\t\tconst walletAddress = xmtpWalletKey.replace(/^0x/, \"\") // Remove 0x prefix if present\n\t\t\tconsole.log(\n\t\t\t\t`Chat with your agent: http://xmtp.chat/dm/${walletAddress}?env=${xmtpEnv}`\n\t\t\t)\n\t\t}\n\n\t\tlogger.debug(`✅ Hybrid server running on port ${httpPort}`)\n\t\tlogger.debug(`🎧 Background message listener is active`)\n\t} catch (error: any) {\n\t\tif (error.code === \"EADDRINUSE\") {\n\t\t\tconsole.error(\n\t\t\t\t`❌ Port ${httpPort} is already in use. Please stop the existing server or use a different port.`\n\t\t\t)\n\t\t\tprocess.exit(1)\n\t\t} else {\n\t\t\tconsole.error(\"Server error:\", error)\n\t\t\tprocess.exit(1)\n\t\t}\n\t}\n}\n","import type { HonoVariables, Plugin } from \"@hybrd/types\"\nimport type { Hono } from \"hono\"\nimport { logger } from \"@hybrd/utils\"\n\n// Re-export types from @hybrd/types for backward compatibility\nexport type { Plugin }\n\n/**\n * Plugin registry that manages all registered plugins\n *\n * @description\n * The plugin registry allows you to register, configure, and apply\n * plugins to Hono apps. It provides a centralized way to manage\n * plugin dependencies and execution order.\n */\nexport class PluginRegistry<T = Record<string, never>> {\n\tprivate plugins: Map<string, Plugin<T>> = new Map()\n\n\t/**\n\t * Registers a plugin with the registry\n\t *\n\t * @param plugin - The plugin to register\n\t * @throws {Error} If a plugin with the same name is already registered\n\t */\n\tregister(plugin: Plugin<T>): void {\n\t\tif (this.plugins.has(plugin.name)) {\n\t\t\tthrow new Error(`Plugin \"${plugin.name}\" is already registered`)\n\t\t}\n\n\t\tthis.plugins.set(plugin.name, plugin)\n\t}\n\n\t/**\n\t * Unregisters a plugin from the registry\n\t *\n\t * @param name - The name of the plugin to unregister\n\t * @returns True if the plugin was unregistered, false if it wasn't found\n\t */\n\tunregister(name: string): boolean {\n\t\treturn this.plugins.delete(name)\n\t}\n\n\t/**\n\t * Gets a plugin by name\n\t *\n\t * @param name - The name of the plugin to retrieve\n\t * @returns The plugin if found, undefined otherwise\n\t */\n\tget(name: string): Plugin<T> | undefined {\n\t\treturn this.plugins.get(name)\n\t}\n\n\t/**\n\t * Gets all registered plugins\n\t *\n\t * @returns Array of all registered plugins\n\t */\n\tgetAll(): Plugin<T>[] {\n\t\treturn Array.from(this.plugins.values())\n\t}\n\n\t/**\n\t * Checks if a plugin is registered\n\t *\n\t * @param name - The name of the plugin to check\n\t * @returns True if the plugin is registered, false otherwise\n\t */\n\thas(name: string): boolean {\n\t\treturn this.plugins.has(name)\n\t}\n\n\t/**\n\t * Applies all registered plugins to a Hono app\n\t *\n\t * @param app - The Hono app instance to extend\n\t * @param context - Optional context data passed to all plugins\n\t */\n\tasync applyAll(\n\t\tapp: Hono<{ Variables: HonoVariables }>,\n\t\tcontext: T\n\t): Promise<void> {\n\t\tconst plugins = this.getAll()\n\n\t\tfor (const plugin of plugins) {\n\t\t\ttry {\n\t\t\t\tlogger.debug(`🔌 Applying plugin: ${plugin.name}`)\n\t\t\t\tawait plugin.apply(app, context)\n\t\t\t\tlogger.debug(`✅ Plugin applied: ${plugin.name}`)\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(`❌ Failed to apply plugin ${plugin.name}:`, error)\n\t\t\t\tthrow error\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Clears all registered plugins\n\t */\n\tclear(): void {\n\t\tthis.plugins.clear()\n\t}\n\n\t/**\n\t * Gets the number of registered plugins\n\t */\n\tget size(): number {\n\t\treturn this.plugins.size\n\t}\n}\n\n/**\n * Creates a plugin that mounts routes at a specific path\n *\n * @param name - Plugin name\n * @param path - Path to mount the routes at\n * @param routes - Hono app containing the routes to mount\n * @returns A plugin that mounts the routes\n */\nexport function createRoutePlugin(\n\tname: string,\n\tpath: string,\n\troutes: Hono<{ Variables: HonoVariables }>\n): Plugin {\n\treturn {\n\t\tname,\n\t\tdescription: `Mounts routes at ${path}`,\n\t\tapply: (app: Hono<{ Variables: HonoVariables }>) => {\n\t\t\tapp.route(path, routes)\n\t\t}\n\t}\n}\n\n/**\n * Creates a plugin that applies middleware\n *\n * @param name - Plugin name\n * @param middleware - Middleware function to apply\n * @returns A plugin that applies the middleware\n */\nexport function createMiddlewarePlugin(\n\tname: string,\n\tmiddleware: (app: Hono<{ Variables: HonoVariables }>) => void\n): Plugin {\n\treturn {\n\t\tname,\n\t\tdescription: `Applies middleware: ${name}`,\n\t\tapply: middleware\n\t}\n}\n","import type {\n\tAgentRuntime,\n\tAnyTool,\n\tDefaultRuntimeExtension,\n\tTool,\n\tToolConfig\n} from \"@hybrd/types\"\nimport { logger } from \"@hybrd/utils\"\nimport { Tool as AISDKTool, type UIMessage } from \"ai\"\nimport { z } from \"zod\"\n\n// Re-export types from @hybrd/types for backward compatibility\nexport type { AnyTool, DefaultRuntimeExtension, Tool, ToolConfig }\n\n/**\n * Factory function to create tools with custom runtime extensions.\n * Provides proper type inference for input/output schemas and runtime extensions.\n */\nexport function toolFactory<TRuntimeExtension = DefaultRuntimeExtension>() {\n\treturn <\n\t\tTInput extends z.ZodTypeAny = z.ZodTypeAny,\n\t\tTOutput extends z.ZodTypeAny = z.ZodTypeAny\n\t>(\n\t\tconfig: ToolConfig<TInput, TOutput, TRuntimeExtension>\n\t): Tool<TInput, TOutput, TRuntimeExtension> => {\n\t\treturn {\n\t\t\tdescription: config.description,\n\t\t\tinputSchema: config.inputSchema,\n\t\t\toutputSchema: config.outputSchema,\n\t\t\texecute: async (args) => {\n\t\t\t\tconst input = config.inputSchema.parse(args.input)\n\t\t\t\tconst result = await config.execute({\n\t\t\t\t\tinput,\n\t\t\t\t\truntime: args.runtime,\n\t\t\t\t\tmessages: args.messages\n\t\t\t\t})\n\t\t\t\tif (config.outputSchema) {\n\t\t\t\t\treturn config.outputSchema.parse(result)\n\t\t\t\t}\n\t\t\t\treturn result\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Default tool factory with no runtime extensions.\n * Type-safe at creation time with proper schema inference.\n */\nexport const createTool = toolFactory()\n\n/**\n * Converts a custom Tool instance to AI SDK's tool format.\n * This adapter enables our tools to work with AI SDK's generateText/streamText functions.\n */\nexport function toAISDKTool<\n\tTInput extends z.ZodTypeAny = z.ZodTypeAny,\n\tTOutput extends z.ZodTypeAny = z.ZodTypeAny,\n\tTRuntimeExtension = DefaultRuntimeExtension\n>(\n\ttool: Tool<TInput, TOutput, TRuntimeExtension>,\n\truntime: AgentRuntime & TRuntimeExtension,\n\tmessages: UIMessage[]\n): AISDKTool {\n\treturn {\n\t\tdescription: tool.description,\n\t\tinputSchema: tool.inputSchema,\n\t\texecute: async (args: z.infer<TInput>) => {\n\t\t\tconst startTime = performance.now()\n\t\t\tlogger.debug(`🔧 [${tool.description}] Executing with input:`, args)\n\n\t\t\tconst result = await tool.execute({\n\t\t\t\tinput: args,\n\t\t\t\truntime,\n\t\t\t\tmessages\n\t\t\t})\n\n\t\t\tconst endTime = performance.now()\n\t\t\tlogger.debug(\n\t\t\t\t`✅ [${tool.description}] Completed in ${(endTime - startTime).toFixed(2)}ms with result:`,\n\t\t\t\tresult\n\t\t\t)\n\n\t\t\treturn result\n\t\t}\n\t}\n}\n\n/**\n * Converts a collection of custom tools to AI SDK format.\n * Useful for batch conversion when setting up multiple tools for AI SDK usage.\n */\nexport function toAISDKTools<TRuntimeExtension = DefaultRuntimeExtension>(\n\ttools: Record<string, AnyTool<TRuntimeExtension>>,\n\truntime: AgentRuntime & TRuntimeExtension,\n\tmessages: UIMessage[]\n): Record<string, AISDKTool> {\n\tconst convertedTools: Record<string, AISDKTool> = {}\n\n\tfor (const [name, tool] of Object.entries(tools)) {\n\t\tconvertedTools[name] = toAISDKTool(tool, runtime, messages)\n\t}\n\n\treturn convertedTools\n}\n","/**\n * @fileoverview Blockchain Tools for Crypto Agents\n *\n * This module provides comprehensive blockchain interaction tools for crypto-enabled agents.\n * Supports Ethereum and other EVM-compatible chains with features like balance checking,\n * transaction sending, contract interaction, and more.\n *\n * @module BlockchainTools\n */\n\nimport {\n\tcreatePublicClient,\n\tcreateWalletClient,\n\tformatEther,\n\thttp,\n\tparseEther,\n\ttype Address,\n\ttype Hash\n} from \"viem\"\nimport { privateKeyToAccount } from \"viem/accounts\"\nimport {\n\tarbitrum,\n\tbase,\n\tmainnet,\n\toptimism,\n\tpolygon,\n\tsepolia\n} from \"viem/chains\"\nimport { z } from \"zod\"\nimport { createTool } from \"../core/tool\"\nimport { logger } from \"@hybrd/utils\"\n\n// Supported chains configuration\nconst SUPPORTED_CHAINS = {\n\tmainnet,\n\tsepolia,\n\tpolygon,\n\tarbitrum,\n\toptimism,\n\tbase\n} as const\n\ntype SupportedChain = keyof typeof SUPPORTED_CHAINS\n\n// Runtime extension interface for blockchain tools\nexport interface BlockchainRuntimeExtension {\n\trpcUrl?: string\n\tprivateKey?: string\n\tdefaultChain?: SupportedChain\n}\n\n/**\n * Get Balance Tool\n *\n * Retrieves the native token balance for a given address on a specified chain.\n *\n * @tool getBalance\n * @category Blockchain\n *\n * @param {string} address - The wallet address to check balance for\n * @param {string} [chain] - The blockchain network (defaults to mainnet)\n *\n * @returns {Promise<{success: boolean, balance: string, balanceWei: string, address: string, chain: string, error?: string}>}\n */\nexport const getBalanceTool = createTool({\n\tid: \"getBalance\",\n\tdescription:\n\t\t\"Get the native token balance for a wallet address on a blockchain\",\n\tinputSchema: z.object({\n\t\taddress: z.string().describe(\"The wallet address to check balance for\"),\n\t\tchain: z\n\t\t\t.enum([\"mainnet\", \"sepolia\", \"polygon\", \"arbitrum\", \"optimism\", \"base\"])\n\t\t\t.default(\"mainnet\")\n\t\t\t.describe(\"The blockchain network to check on\")\n\t}),\n\toutputSchema: z.object({\n\t\tsuccess: z.boolean(),\n\t\tbalance: z\n\t\t\t.string()\n\t\t\t.describe(\"Balance in human readable format (ETH, MATIC, etc.)\"),\n\t\tbalanceWei: z.string().describe(\"Balance in wei (smallest unit)\"),\n\t\taddress: z.string(),\n\t\tchain: z.string(),\n\t\terror: z.string().optional()\n\t}),\n\texecute: async ({ input, runtime }) => {\n\t\ttry {\n\t\t\tconst { address, chain } = input\n\t\t\tconst chainConfig = SUPPORTED_CHAINS[chain]\n\n\t\t\t// Use runtime RPC URL if provided, otherwise use default\n\t\t\tconst rpcUrl =\n\t\t\t\t(runtime as any).rpcUrl || chainConfig.rpcUrls.default.http[0]\n\n\t\t\tconst client = createPublicClient({\n\t\t\t\tchain: chainConfig,\n\t\t\t\ttransport: http(rpcUrl)\n\t\t\t})\n\n\t\t\tlogger.debug(`🔍 [getBalance] Checking balance for ${address} on ${chain}`)\n\n\t\t\tconst balanceWei = await client.getBalance({\n\t\t\t\taddress: address as Address\n\t\t\t})\n\n\t\t\tconst balance = formatEther(balanceWei)\n\n\t\t\tlogger.debug(\n\t\t\t\t`✅ [getBalance] Balance: ${balance} ${chainConfig.nativeCurrency.symbol}`\n\t\t\t)\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tbalance: `${balance} ${chainConfig.nativeCurrency.symbol}`,\n\t\t\t\tbalanceWei: balanceWei.toString(),\n\t\t\t\taddress,\n\t\t\t\tchain\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\tconsole.error(\"❌ [getBalance] Error:\", errorMessage)\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tbalance: \"0\",\n\t\t\t\tbalanceWei: \"0\",\n\t\t\t\taddress: input.address,\n\t\t\t\tchain: input.chain,\n\t\t\t\terror: errorMessage\n\t\t\t}\n\t\t}\n\t}\n})\n\n/**\n * Get Transaction Tool\n *\n * Retrieves transaction details by transaction hash.\n *\n * @tool getTransaction\n * @category Blockchain\n *\n * @param {string} hash - The transaction hash to look up\n * @param {string} [chain] - The blockchain network (defaults to mainnet)\n *\n * @returns {Promise<{success: boolean, transaction?: object, error?: string}>}\n */\nexport const getTransactionTool = createTool({\n\tid: \"getTransaction\",\n\tdescription: \"Get transaction details by transaction hash\",\n\tinputSchema: z.object({\n\t\thash: z.string().describe(\"The transaction hash to look up\"),\n\t\tchain: z\n\t\t\t.enum([\"mainnet\", \"sepolia\", \"polygon\", \"arbitrum\", \"optimism\", \"base\"])\n\t\t\t.default(\"mainnet\")\n\t\t\t.describe(\"The blockchain network to check on\")\n\t}),\n\toutputSchema: z.object({\n\t\tsuccess: z.boolean(),\n\t\ttransaction: z\n\t\t\t.object({\n\t\t\t\thash: z.string(),\n\t\t\t\tfrom: z.string(),\n\t\t\t\tto: z.string().nullable(),\n\t\t\t\tvalue: z.string(),\n\t\t\t\tgasUsed: z.string().optional(),\n\t\t\t\tgasPrice: z.string().optional(),\n\t\t\t\tblockNumber: z.string().optional(),\n\t\t\t\tstatus: z.string().optional()\n\t\t\t})\n\t\t\t.optional(),\n\t\terror: z.string().optional()\n\t}),\n\texecute: async ({ input, runtime }) => {\n\t\ttry {\n\t\t\tconst { hash, chain } = input\n\t\t\tconst chainConfig = SUPPORTED_CHAINS[chain]\n\n\t\t\tconst rpcUrl =\n\t\t\t\t(runtime as any).rpcUrl || chainConfig.rpcUrls.default.http[0]\n\n\t\t\tconst client = createPublicClient({\n\t\t\t\tchain: chainConfig,\n\t\t\t\ttransport: http(rpcUrl)\n\t\t\t})\n\n\t\t\tlogger.debug(\n\t\t\t\t`🔍 [getTransaction] Looking up transaction ${hash} on ${chain}`\n\t\t\t)\n\n\t\t\tconst transaction = await client.getTransaction({\n\t\t\t\thash: hash as Hash\n\t\t\t})\n\n\t\t\tconst receipt = await client\n\t\t\t\t.getTransactionReceipt({\n\t\t\t\t\thash: hash as Hash\n\t\t\t\t})\n\t\t\t\t.catch(() => null) // Transaction might be pending\n\n\t\t\tlogger.debug(\n\t\t\t\t`✅ [getTransaction] Found transaction from ${transaction.from} to ${transaction.to}`\n\t\t\t)\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\ttransaction: {\n\t\t\t\t\thash: transaction.hash,\n\t\t\t\t\tfrom: transaction.from,\n\t\t\t\t\tto: transaction.to,\n\t\t\t\t\tvalue: formatEther(transaction.value),\n\t\t\t\t\tgasUsed: receipt?.gasUsed.toString(),\n\t\t\t\t\tgasPrice: transaction.gasPrice?.toString(),\n\t\t\t\t\tblockNumber: transaction.blockNumber?.toString(),\n\t\t\t\t\tstatus:\n\t\t\t\t\t\treceipt?.status === \"success\"\n\t\t\t\t\t\t\t? \"success\"\n\t\t\t\t\t\t\t: receipt?.status === \"reverted\"\n\t\t\t\t\t\t\t\t? \"failed\"\n\t\t\t\t\t\t\t\t: \"pending\"\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\tconsole.error(\"❌ [getTransaction] Error:\", errorMessage)\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: errorMessage\n\t\t\t}\n\t\t}\n\t}\n})\n\n/**\n * Send Transaction Tool\n *\n * Sends a native token transaction to another address.\n * Requires a private key to be configured in the runtime.\n *\n * @tool sendTransaction\n * @category Blockchain\n *\n * @param {string} to - The recipient address\n * @param {string} amount - The amount to send (in ETH, MATIC, etc.)\n * @param {string} [chain] - The blockchain network (defaults to mainnet)\n *\n * @returns {Promise<{success: boolean, hash?: string, error?: string}>}\n */\nexport const sendTransactionTool = createTool({\n\tid: \"sendTransaction\",\n\tdescription: \"Send native tokens to another address\",\n\tinputSchema: z.object({\n\t\tto: z.string().describe(\"The recipient address\"),\n\t\tamount: z.string().describe(\"The amount to send (in ETH, MATIC, etc.)\"),\n\t\tchain: z\n\t\t\t.enum([\"mainnet\", \"sepolia\", \"polygon\", \"arbitrum\", \"optimism\", \"base\"])\n\t\t\t.default(\"mainnet\")\n\t\t\t.describe(\"The blockchain network to send on\")\n\t}),\n\toutputSchema: z.object({\n\t\tsuccess: z.boolean(),\n\t\thash: z.string().optional(),\n\t\tfrom: z.string().optional(),\n\t\tto: z.string(),\n\t\tamount: z.string(),\n\t\tchain: z.string(),\n\t\terror: z.string().optional()\n\t}),\n\texecute: async ({ input, runtime }) => {\n\t\ttry {\n\t\t\tconst { to, amount, chain } = input\n\t\t\tconst chainConfig = SUPPORTED_CHAINS[chain]\n\n\t\t\tconst privateKey = (runtime as any).privateKey\n\t\t\tif (!privateKey) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tto,\n\t\t\t\t\tamount,\n\t\t\t\t\tchain,\n\t\t\t\t\terror: \"Private key not configured in runtime\"\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst rpcUrl =\n\t\t\t\t(runtime as any).rpcUrl || chainConfig.rpcUrls.default.http[0]\n\t\t\tconst account = privateKeyToAccount(privateKey as `0x${string}`)\n\n\t\t\tconst client = createWalletClient({\n\t\t\t\taccount,\n\t\t\t\tchain: chainConfig,\n\t\t\t\ttransport: http(rpcUrl)\n\t\t\t})\n\n\t\t\tlogger.debug(\n\t\t\t\t`💸 [sendTransaction] Sending ${amount} ${chainConfig.nativeCurrency.symbol} to ${to} on ${chain}`\n\t\t\t)\n\n\t\t\tconst hash = await client.sendTransaction({\n\t\t\t\tto: to as Address,\n\t\t\t\tvalue: parseEther(amount)\n\t\t\t})\n\n\t\t\tlogger.debug(`✅ [sendTransaction] Transaction sent: ${hash}`)\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\thash,\n\t\t\t\tfrom: account.address,\n\t\t\t\tto,\n\t\t\t\tamount,\n\t\t\t\tchain\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\tconsole.error(\"❌ [sendTransaction] Error:\", errorMessage)\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tto: input.to,\n\t\t\t\tamount: input.amount,\n\t\t\t\tchain: input.chain,\n\t\t\t\terror: errorMessage\n\t\t\t}\n\t\t}\n\t}\n})\n\n/**\n * Get Block Tool\n *\n * Retrieves information about a specific block.\n *\n * @tool getBlock\n * @category Blockchain\n *\n * @param {string} [blockNumber] - Block number (defaults to latest)\n * @param {string} [chain] - The blockchain network (defaults to mainnet)\n *\n * @returns {Promise<{success: boolean, block?: object, error?: string}>}\n */\nexport const getBlockTool = createTool({\n\tid: \"getBlock\",\n\tdescription: \"Get information about a blockchain block\",\n\tinputSchema: z.object({\n\t\tblockNumber: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\"Block number (defaults to latest)\"),\n\t\tchain: z\n\t\t\t.enum([\"mainnet\", \"sepolia\", \"polygon\", \"arbitrum\", \"optimism\", \"base\"])\n\t\t\t.default(\"mainnet\")\n\t\t\t.describe(\"The blockchain network to check on\")\n\t}),\n\toutputSchema: z.object({\n\t\tsuccess: z.boolean(),\n\t\tblock: z\n\t\t\t.object({\n\t\t\t\tnumber: z.string(),\n\t\t\t\thash: z.string(),\n\t\t\t\ttimestamp: z.string(),\n\t\t\t\ttransactionCount: z.number(),\n\t\t\t\tgasUsed: z.string(),\n\t\t\t\tgasLimit: z.string()\n\t\t\t})\n\t\t\t.optional(),\n\t\terror: z.string().optional()\n\t}),\n\texecute: async ({ input, runtime }) => {\n\t\ttry {\n\t\t\tconst { blockNumber, chain } = input\n\t\t\tconst chainConfig = SUPPORTED_CHAINS[chain]\n\n\t\t\tconst rpcUrl =\n\t\t\t\t(runtime as any).rpcUrl || chainConfig.rpcUrls.default.http[0]\n\n\t\t\tconst client = createPublicClient({\n\t\t\t\tchain: chainConfig,\n\t\t\t\ttransport: http(rpcUrl)\n\t\t\t})\n\n\t\t\tlogger.debug(\n\t\t\t\t`🔍 [getBlock] Getting block ${blockNumber || \"latest\"} on ${chain}`\n\t\t\t)\n\n\t\t\tconst block = await client.getBlock({\n\t\t\t\tblockNumber: blockNumber ? BigInt(blockNumber) : undefined\n\t\t\t})\n\n\t\t\tlogger.debug(\n\t\t\t\t`✅ [getBlock] Found block ${block.number} with ${block.transactions.length} transactions`\n\t\t\t)\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tblock: {\n\t\t\t\t\tnumber: block.number.toString(),\n\t\t\t\t\thash: block.hash,\n\t\t\t\t\ttimestamp: block.timestamp.toString(),\n\t\t\t\t\ttransactionCount: block.transactions.length,\n\t\t\t\t\tgasUsed: block.gasUsed.toString(),\n\t\t\t\t\tgasLimit: block.gasLimit.toString()\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\tconsole.error(\"❌ [getBlock] Error:\", errorMessage)\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: errorMessage\n\t\t\t}\n\t\t}\n\t}\n})\n\n/**\n * Get Gas Price Tool\n *\n * Retrieves current gas price information for a blockchain.\n *\n * @tool getGasPrice\n * @category Blockchain\n *\n * @param {string} [chain] - The blockchain network (defaults to mainnet)\n *\n * @returns {Promise<{success: boolean, gasPrice?: string, error?: string}>}\n */\nexport const getGasPriceTool = createTool({\n\tid: \"getGasPrice\",\n\tdescription: \"Get current gas price for a blockchain\",\n\tinputSchema: z.object({\n\t\tchain: z\n\t\t\t.enum([\"mainnet\", \"sepolia\", \"polygon\", \"arbitrum\", \"optimism\", \"base\"])\n\t\t\t.default(\"mainnet\")\n\t\t\t.describe(\"The blockchain network to check on\")\n\t}),\n\toutputSchema: z.object({\n\t\tsuccess: z.boolean(),\n\t\tgasPrice: z.string().optional().describe(\"Gas price in gwei\"),\n\t\tgasPriceWei: z.string().optional().describe(\"Gas price in wei\"),\n\t\tchain: z.string(),\n\t\terror: z.string().optional()\n\t}),\n\texecute: async ({ input, runtime }) => {\n\t\ttry {\n\t\t\tconst { chain } = input\n\t\t\tconst chainConfig = SUPPORTED_CHAINS[chain]\n\n\t\t\tconst rpcUrl =\n\t\t\t\t(runtime as any).rpcUrl || chainConfig.rpcUrls.default.http[0]\n\n\t\t\tconst client = createPublicClient({\n\t\t\t\tchain: chainConfig,\n\t\t\t\ttransport: http(rpcUrl)\n\t\t\t})\n\n\t\t\tlogger.debug(`⛽ [getGasPrice] Getting gas price for ${chain}`)\n\n\t\t\tconst gasPrice = await client.getGasPrice()\n\t\t\tconst gasPriceGwei = formatEther(gasPrice * BigInt(1000000000)) // Convert to gwei\n\n\t\t\tlogger.debug(`✅ [getGasPrice] Current gas price: ${gasPriceGwei} gwei`)\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tgasPrice: `${gasPriceGwei} gwei`,\n\t\t\t\tgasPriceWei: gasPrice.toString(),\n\t\t\t\tchain\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\tconsole.error(\"❌ [getGasPrice] Error:\", errorMessage)\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tchain: input.chain,\n\t\t\t\terror: errorMessage\n\t\t\t}\n\t\t}\n\t}\n})\n\n/**\n * Estimate Gas Tool\n *\n * Estimates gas required for a transaction.\n *\n * @tool estimateGas\n * @category Blockchain\n *\n * @param {string} to - The recipient address\n * @param {string} [amount] - The amount to send (defaults to 0)\n * @param {string} [data] - Transaction data (for contract calls)\n * @param {string} [chain] - The blockchain network (defaults to mainnet)\n *\n * @returns {Promise<{success: boolean, gasEstimate?: string, error?: string}>}\n */\nexport const estimateGasTool = createTool({\n\tid: \"estimateGas\",\n\tdescription: \"Estimate gas required for a transaction\",\n\tinputSchema: z.object({\n\t\tto: z.string().describe(\"The recipient address\"),\n\t\tamount: z\n\t\t\t.string()\n\t\t\t.default(\"0\")\n\t\t\t.describe(\"The amount to send (defaults to 0)\"),\n\t\tdata: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\"Transaction data (for contract calls)\"),\n\t\tchain: z\n\t\t\t.enum([\"mainnet\", \"sepolia\", \"polygon\", \"arbitrum\", \"optimism\", \"base\"])\n\t\t\t.default(\"mainnet\")\n\t\t\t.describe(\"The blockchain network to estimate on\")\n\t}),\n\toutputSchema: z.object({\n\t\tsuccess: z.boolean(),\n\t\tgasEstimate: z.string().optional(),\n\t\tto: z.string(),\n\t\tamount: z.string(),\n\t\tchain: z.string(),\n\t\terror: z.string().optional()\n\t}),\n\texecute: async ({ input, runtime }) => {\n\t\ttry {\n\t\t\tconst { to, amount, data, chain } = input\n\t\t\tconst chainConfig = SUPPORTED_CHAINS[chain]\n\n\t\t\tconst privateKey = (runtime as any).privateKey\n\t\t\tif (!privateKey) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tto,\n\t\t\t\t\tamount,\n\t\t\t\t\tchain,\n\t\t\t\t\terror: \"Private key not configured in runtime\"\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst rpcUrl =\n\t\t\t\t(runtime as any).rpcUrl || chainConfig.rpcUrls.default.http[0]\n\t\t\tconst account = privateKeyToAccount(privateKey as `0x${string}`)\n\n\t\t\tconst client = createPublicClient({\n\t\t\t\tchain: chainConfig,\n\t\t\t\ttransport: http(rpcUrl)\n\t\t\t})\n\n\t\t\tconsole.log(\n\t\t\t\t`⛽ [estimateGas] Estimating gas for transaction to ${to} on ${chain}`\n\t\t\t)\n\n\t\t\tconst gasEstimate = await client.estimateGas({\n\t\t\t\taccount: account.address,\n\t\t\t\tto: to as Address,\n\t\t\t\tvalue: parseEther(amount),\n\t\t\t\tdata: data as `0x${string}` | undefined\n\t\t\t})\n\n\t\t\tconsole.log(`✅ [estimateGas] Estimated gas: ${gasEstimate.toString()}`)\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tgasEstimate: gasEstimate.toString(),\n\t\t\t\tto,\n\t\t\t\tamount,\n\t\t\t\tchain\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\tconsole.error(\"❌ [estimateGas] Error:\", errorMessage)\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tto: input.to,\n\t\t\t\tamount: input.amount,\n\t\t\t\tchain: input.chain,\n\t\t\t\terror: errorMessage\n\t\t\t}\n\t\t}\n\t}\n})\n\n/**\n * Collection of blockchain tools for crypto agents\n *\n * These tools provide comprehensive blockchain interaction capabilities including\n * balance checking, transaction sending, gas estimation, and more.\n *\n * @namespace blockchainTools\n *\n * @property {Tool} getBalance - Get native token balance for an address\n * @property {Tool} getTransaction - Get transaction details by hash\n * @property {Tool} sendTransaction - Send native tokens to another address\n * @property {Tool} getBlock - Get information about a blockchain block\n * @property {Tool} getGasPrice - Get current gas price for a blockchain\n * @property {Tool} estimateGas - Estimate gas required for a transaction\n */\nexport const blockchainTools = {\n\tgetBalance: getBalanceTool,\n\tgetTransaction: getTransactionTool,\n\tsendTransaction: sendTransactionTool,\n\tgetBlock: getBlockTool,\n\tgetGasPrice: getGasPriceTool,\n\testimateGas: estimateGasTool\n}\n","/**\n * @fileoverview XMTP Communication Tools for Crypto Agents\n *\n * This module provides comprehensive XMTP messaging tools for crypto-enabled agents.\n * Includes capabilities for sending messages, replies, reactions, and managing conversations.\n *\n * @module XMTPTools\n */\n\nimport { logger } from \"@hybrd/utils\"\nimport {\n\tContentTypeReaction,\n\tContentTypeReply,\n\tContentTypeText,\n\tReply\n} from \"@hybrd/xmtp\"\nimport { z } from \"zod\"\nimport { createTool } from \"../core/tool\"\n\n/**\n * Get Message Tool\n *\n * Retrieves a specific message by ID from the XMTP service.\n *\n * @tool getMessage\n * @category Communication\n *\n * @param {string} messageId - The message ID to retrieve\n *\n * @returns {Promise<{success: boolean, message?: object, error?: string}>}\n */\nexport const getMessageTool = createTool({\n\tid: \"getMessage\",\n\tdescription: \"Get a specific message by ID from XMTP\",\n\tinputSchema: z.object({\n\t\tmessageId: z.string().describe(\"The message ID to retrieve\")\n\t}),\n\toutputSchema: z.object({\n\t\tsuccess: z.boolean(),\n\t\tmessage: z\n\t\t\t.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tconversationId: z.string(),\n\t\t\t\tcontent: z\n\t\t\t\t\t.union([z.string(), z.record(z.unknown()), z.unknown()])\n\t\t\t\t\t.optional(),\n\t\t\t\tsenderInboxId: z.string(),\n\t\t\t\tsentAt: z.date(),\n\t\t\t\tcontentType: z\n\t\t\t\t\t.object({\n\t\t\t\t\t\ttypeId: z.string(),\n\t\t\t\t\t\tauthorityId: z.string().optional(),\n\t\t\t\t\t\tversionMajor: z.number().optional(),\n\t\t\t\t\t\tversionMinor: z.number().optional()\n\t\t\t\t\t})\n\t\t\t\t\t.optional()\n\t\t\t})\n\t\t\t.optional(),\n\t\terror: z.string().optional()\n\t}),\n\texecute: async ({ input, runtime }) => {\n\t\tconst startTime = performance.now()\n\t\tlogger.debug(\n\t\t\t`📜 [Tool:getMessage] Starting execution for message: ${input.messageId}`\n\t\t)\n\n\t\ttry {\n\t\t\tconst { xmtpClient, conversation } = runtime\n\t\t\tconst { messageId } = input\n\n\t\t\tif (!xmtpClient) {\n\t\t\t\tconst endTime = performance.now()\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`📜 [Tool:getMessage] Failed - no XMTP client in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t\t)\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: \"XMTP service not available\"\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlogger.debug(`📜 [getMessage] Retrieving message ${messageId}`)\n\n\t\t\tconst sendStartTime = performance.now()\n\t\t\tconst message = await xmtpClient.conversations.getMessageById(messageId)\n\t\t\tconst sendEndTime = performance.now()\n\t\t\tlogger.debug(\n\t\t\t\t`📜 [Tool:getMessage] XMTP client getMessage completed in ${(sendEndTime - sendStartTime).toFixed(2)}ms`\n\t\t\t)\n\n\t\t\tif (!message) {\n\t\t\t\tconst endTime = performance.now()\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`📜 [Tool:getMessage] Failed in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t\t)\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: \"Failed to get message\"\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlogger.debug(\n\t\t\t\t`✅ [getMessage] Retrieved message from ${message.senderInboxId}`\n\t\t\t)\n\n\t\t\tconst endTime = performance.now()\n\t\t\tlogger.debug(\n\t\t\t\t`📜 [Tool:getMessage] Total execution completed in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t)\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tmessage: message\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\tconst endTime = performance.now()\n\t\t\tlogger.error(\n\t\t\t\t`❌ [Tool:getMessage] Error in ${(endTime - startTime).toFixed(2)}ms:`,\n\t\t\t\terrorMessage\n\t\t\t)\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: errorMessage\n\t\t\t}\n\t\t}\n\t}\n})\n\n/**\n * Send Reaction Tool\n *\n * Sends an emoji reaction to a specific message to indicate the message has been seen.\n * This is used to acknowledge receipt of messages before responding.\n *\n * @tool sendReaction\n * @category Communication\n *\n * @param {string} emoji - The emoji to send as a reaction (defaults to 👀)\n * @param {string} [referenceMessageId] - The message ID to react to (uses current message if not provided)\n *\n * @returns {Promise<{success: boolean, emoji: string, error?: string}>}\n */\nexport const sendReactionTool = createTool({\n\tid: \"sendReaction\",\n\tdescription:\n\t\t\"Send an emoji reaction to a message to indicate it has been seen\",\n\tinputSchema: z.object({\n\t\temoji: z\n\t\t\t.string()\n\t\t\t.default(\"👀\")\n\t\t\t.describe(\n\t\t\t\t\"The emoji to send as a reaction (supports common emoji like 👍, ❤️, 🔥, etc.)\"\n\t\t\t),\n\t\treferenceMessageId: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\n\t\t\t\t\"The message ID to react to (uses current message if not provided)\"\n\t\t\t)\n\t}),\n\toutputSchema: z.object({\n\t\tsuccess: z.boolean(),\n\t\temoji: z.string(),\n\t\terror: z.string().optional()\n\t}),\n\texecute: async ({ input, runtime }) => {\n\t\tconst startTime = performance.now()\n\n\t\tlogger.debug(\n\t\t\t`👀 [Tool:sendReaction] Starting execution with emoji: ${input.emoji}`\n\t\t)\n\n\t\ttry {\n\t\t\tconst xmtpClient = runtime.xmtpClient\n\t\t\tconst { referenceMessageId, emoji = \"👀\" } = input\n\t\t\tconst { message, conversation } = runtime\n\n\t\t\tif (!xmtpClient) {\n\t\t\t\tconst endTime = performance.now()\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`👀 [Tool:sendReaction] Failed - no XMTP client in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t\t)\n\t\t\t\tconst errorMsg = \"❌ XMTP service not available\"\n\t\t\t\treturn { success: false, emoji: input.emoji, error: errorMsg }\n\t\t\t}\n\n\t\t\tconst messageIdToReactTo = input.referenceMessageId || runtime.message.id\n\n\t\t\tif (!messageIdToReactTo) {\n\t\t\t\tconst endTime = performance.now()\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`👀 [Tool:sendReaction] Failed - no message ID to react to in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t\t)\n\t\t\t\tconst errorMsg = \"❌ No message ID available for reaction\"\n\t\t\t\treturn { success: false, emoji: input.emoji, error: errorMsg }\n\t\t\t}\n\n\t\t\tlogger.debug(\n\t\t\t\t`👀 [sendReaction] Sending ${input.emoji} reaction to message ${messageIdToReactTo}`\n\t\t\t)\n\n\t\t\tconst sendStartTime = performance.now()\n\n\t\t\tconst reaction = {\n\t\t\t\tschema: \"unicode\",\n\t\t\t\treference: messageIdToReactTo,\n\t\t\t\taction: \"added\",\n\t\t\t\tcontentType: ContentTypeReaction,\n\t\t\t\tcontent: emoji\n\t\t\t}\n\n\t\t\tconst reactionResult = await conversation.send(\n\t\t\t\treaction,\n\t\t\t\tContentTypeReaction\n\t\t\t)\n\n\t\t\tconst sendEndTime = performance.now()\n\t\t\tlogger.debug(\n\t\t\t\t`👀 [Tool:sendReaction] XMTP client sendReaction completed in ${(sendEndTime - sendStartTime).toFixed(2)}ms`\n\t\t\t)\n\n\t\t\tif (!reactionResult) {\n\t\t\t\tconst endTime = performance.now()\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`👀 [Tool:sendReaction] Failed in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t\t)\n\t\t\t\tconst errorMsg = `❌ Failed to send reaction`\n\t\t\t\treturn { success: false, emoji: input.emoji, error: errorMsg }\n\t\t\t}\n\n\t\t\tlogger.debug(\n\t\t\t\t`✅ [sendReaction] Successfully sent ${input.emoji} reaction`\n\t\t\t)\n\n\t\t\tconst endTime = performance.now()\n\t\t\tlogger.debug(\n\t\t\t\t`👀 [Tool:sendReaction] Total execution completed in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t)\n\n\t\t\treturn { success: true, emoji: input.emoji }\n\t\t} catch (error) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\tconst endTime = performance.now()\n\t\t\tlogger.error(\n\t\t\t\t`❌ [Tool:sendReaction] Error in ${(endTime - startTime).toFixed(2)}ms:`,\n\t\t\t\terrorMessage\n\t\t\t)\n\t\t\treturn { success: false, emoji: input.emoji, error: errorMessage }\n\t\t}\n\t}\n})\n\n/**\n * Send Message Tool\n *\n * Sends a message to an XMTP conversation or creates a new conversation.\n *\n * @tool sendMessage\n * @category Communication\n *\n * @param {string} content - The message content to send\n * @param {string} [recipientAddress] - Recipient address for new conversations\n * @param {string} [conversationId] - Existing conversation ID to send to\n *\n * @returns {Promise<{success: boolean, messageId?: string, conversationId?: string, error?: string}>}\n */\nexport const sendMessageTool = createTool({\n\tid: \"sendMessage\",\n\tdescription: \"Send a message to an XMTP conversation\",\n\tinputSchema: z\n\t\t.object({\n\t\t\tcontent: z.string().describe(\"The message content to send\"),\n\t\t\trecipientAddress: z\n\t\t\t\t.string()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Recipient address for new conversations\"),\n\t\t\tconversationId: z\n\t\t\t\t.string()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Existing conversation ID to send to\")\n\t\t})\n\t\t.refine((data) => data.recipientAddress || data.conversationId, {\n\t\t\tmessage: \"Either recipientAddress or conversationId must be provided\"\n\t\t}),\n\toutputSchema: z.object({\n\t\tsuccess: z.boolean(),\n\t\tmessageId: z.string().optional(),\n\t\tconversationId: z.string().optional(),\n\t\tcontent: z.string(),\n\t\terror: z.string().optional()\n\t}),\n\texecute: async ({ input, runtime }) => {\n\t\tconst startTime = performance.now()\n\t\tlogger.debug(\n\t\t\t`💬 [Tool:sendMessage] Starting execution with content: \"${input.content.substring(0, 50)}${input.content.length > 50 ? \"...\" : \"\"}\"`\n\t\t)\n\n\t\ttry {\n\t\t\tconst xmtpClient = runtime.xmtpClient\n\t\t\tconst { content, recipientAddress, conversationId } = input\n\t\t\tconst { conversation } = runtime\n\n\t\t\tif (!xmtpClient) {\n\t\t\t\tconst endTime = performance.now()\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`💬 [Tool:sendMessage] Failed - no XMTP client in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t\t)\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tcontent,\n\t\t\t\t\terror: \"XMTP service not available\"\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlogger.debug(\n\t\t\t\t`💬 [sendMessage] Sending message: \"${content.substring(0, 50)}${content.length > 50 ? \"...\" : \"\"}\"`\n\t\t\t)\n\n\t\t\tlet targetConversationId = conversationId\n\n\t\t\t// If no conversation ID provided, create or find conversation with recipient\n\t\t\tif (!targetConversationId && recipientAddress) {\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`🔍 [sendMessage] Creating/finding conversation with ${recipientAddress}`\n\t\t\t\t)\n\t\t\t\t// This would depend on your XMTP client implementation\n\t\t\t\t// For now, we'll assume the client handles conversation creation\n\t\t\t\ttargetConversationId = recipientAddress // Simplified for this example\n\t\t\t}\n\n\t\t\t// Send the message using the XMTP client\n\t\t\tconst sendStartTime = performance.now()\n\t\t\tconst messageId = await conversation.send(content)\n\t\t\tconst sendEndTime = performance.now()\n\t\t\tlogger.debug(\n\t\t\t\t`💬 [Tool:sendMessage] XMTP client sendMessage completed in ${(sendEndTime - sendStartTime).toFixed(2)}ms`\n\t\t\t)\n\n\t\t\tif (!messageId) {\n\t\t\t\tconst endTime = performance.now()\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`💬 [Tool:sendMessage] Failed in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t\t)\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tcontent,\n\t\t\t\t\terror: \"Failed to send message\"\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlogger.debug(`✅ [sendMessage] Message sent successfully`)\n\n\t\t\tconst endTime = performance.now()\n\t\t\tlogger.debug(\n\t\t\t\t`💬 [Tool:sendMessage] Total execution completed in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t)\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tmessageId,\n\t\t\t\tconversationId: conversation.id,\n\t\t\t\tcontent\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\tconst endTime = performance.now()\n\t\t\tlogger.error(\n\t\t\t\t`❌ [Tool:sendMessage] Error in ${(endTime - startTime).toFixed(2)}ms:`,\n\t\t\t\terrorMessage\n\t\t\t)\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tcontent: input.content,\n\t\t\t\terror: errorMessage\n\t\t\t}\n\t\t}\n\t}\n})\n\n/**\n * Send Reply Tool\n *\n * Sends a reply to a specific message in an XMTP conversation.\n *\n * @tool sendReply\n * @category Communication\n *\n * @param {string} content - The reply content to send\n * @param {string} [replyToMessageId] - Message ID to reply to (uses current message if not provided)\n *\n * @returns {Promise<{success: boolean, messageId?: string, replyToMessageId?: string, error?: string}>}\n */\nexport const sendReplyTool = createTool({\n\tid: \"sendReply\",\n\tdescription: \"Send a reply to a specific message in an XMTP conversation\",\n\tinputSchema: z.object({\n\t\tcontent: z.string().describe(\"The reply content to send\"),\n\t\treplyToMessageId: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\"Message ID to reply to (uses current message if not provided)\")\n\t}),\n\toutputSchema: z.object({\n\t\tsuccess: z.boolean(),\n\t\tmessageId: z.string().optional(),\n\t\treplyToMessageId: z.string().optional(),\n\t\tcontent: z.string(),\n\t\terror: z.string().optional()\n\t}),\n\texecute: async ({ input, runtime }) => {\n\t\tconst startTime = performance.now()\n\t\tlogger.debug(\n\t\t\t`↩️ [Tool:sendReply] Starting execution with content: \"${input.content.substring(0, 50)}${input.content.length > 50 ? \"...\" : \"\"}\"`\n\t\t)\n\n\t\ttry {\n\t\t\tconst { xmtpClient, conversation } = runtime\n\t\t\tconst { content, replyToMessageId } = input\n\n\t\t\tif (!xmtpClient) {\n\t\t\t\tconst endTime = performance.now()\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`↩️ [Tool:sendReply] Failed - no XMTP client in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t\t)\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tcontent,\n\t\t\t\t\treplyToMessageId: replyToMessageId || \"\",\n\t\t\t\t\terror: \"XMTP service not available\"\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!replyToMessageId) {\n\t\t\t\tconst endTime = performance.now()\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`↩️ [Tool:sendReply] Failed - no message to reply to in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t\t)\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tcontent,\n\t\t\t\t\treplyToMessageId: \"\",\n\t\t\t\t\terror: \"No message to reply to\"\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst targetMessageId = replyToMessageId //|| currentMessage?.id\n\n\t\t\tlogger.debug(\n\t\t\t\t`↩️ [sendReply] Sending reply to message ${targetMessageId}: \"${content.substring(0, 50)}${content.length > 50 ? \"...\" : \"\"}\"`\n\t\t\t)\n\n\t\t\tconst reply: Reply = {\n\t\t\t\treference: replyToMessageId,\n\t\t\t\tcontentType: ContentTypeText,\n\t\t\t\tcontent\n\t\t\t}\n\n\t\t\tconst sendStartTime = performance.now()\n\t\t\tconst replyMessageId = await conversation.send(reply, ContentTypeReply)\n\t\t\tconst sendEndTime = performance.now()\n\t\t\tlogger.debug(\n\t\t\t\t`↩️ [Tool:sendReply] XMTP client sendReply completed in ${(sendEndTime - sendStartTime).toFixed(2)}ms`\n\t\t\t)\n\n\t\t\tif (!replyMessageId) {\n\t\t\t\tconst endTime = performance.now()\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`↩️ [Tool:sendReply] Failed in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t\t)\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tcontent,\n\t\t\t\t\tmessageId: replyMessageId,\n\t\t\t\t\treplyToMessageId: targetMessageId,\n\t\t\t\t\terror: \"Failed to send reply\"\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlogger.debug(`✅ [sendReply] Reply sent successfully`)\n\n\t\t\tconst endTime = performance.now()\n\t\t\tlogger.debug(\n\t\t\t\t`↩️ [Tool:sendReply] Total execution completed in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t)\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tmessageId: replyMessageId,\n\t\t\t\treplyToMessageId: targetMessageId,\n\t\t\t\tcontent\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\tconst endTime = performance.now()\n\t\t\tlogger.error(\n\t\t\t\t`❌ [Tool:sendReply] Error in ${(endTime - startTime).toFixed(2)}ms:`,\n\t\t\t\terrorMessage\n\t\t\t)\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tcontent: input.content,\n\t\t\t\treplyToMessageId: input.replyToMessageId || \"\",\n\t\t\t\tmessageId: \"\",\n\t\t\t\terror: errorMessage\n\t\t\t}\n\t\t}\n\t}\n})\n\n/**\n * Collection of XMTP communication tools for crypto agents\n *\n * These tools provide comprehensive messaging capabilities including sending messages,\n * replies, reactions, and retrieving message information.\n *\n * @namespace xmtpTools\n *\n * @property {Tool} sendMessage - Send a message to an XMTP conversation\n * @property {Tool} sendReply - Send a reply to a specific message\n * @property {Tool} sendReaction - Send an emoji reaction to a message\n * @property {Tool} getMessage - Get a specific message by ID\n */\nexport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F;AAEA,aAAO;AAAA,QACN,SAAS;AAAA,QACT,WAAW;AAAA,QACX,kBAAkB;AAAA,QAClB;AAAA,MACD;AAAA,IACD,SAAS,OAAO;AACf,YAAM,eACL,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACtD,YAAM,UAAU,YAAY,IAAI;AAChC,2BAAO;AAAA,QACN,qCAAgC,UAAU,WAAW,QAAQ,CAAC,CAAC;AAAA,QAC/D;AAAA,MACD;AACA,aAAO;AAAA,QACN,SAAS;AAAA,QACT,SAAS,MAAM;AAAA,QACf,kBAAkB,MAAM,oBAAoB;AAAA,QAC5C,WAAW;AAAA,QACX,OAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD;AACD,CAAC;AAeM,IAAM,YAAY;AAAA,EACxB,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,WAAW;AAAA,EACX,cAAc;AACf;","names":["import_utils","import_utils","import_utils","import_utils","import_utils","import_xmtp","import_zod","endTime"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/core/agent.ts","../src/lib/render.ts","../src/server/listen.ts","../src/core/plugin.ts","../src/core/tool.ts","../src/tools/blockchain.ts","../src/tools/xmtp.ts"],"sourcesContent":["export type { AgentRuntime } from \"@hybrd/types\"\nexport { Agent } from \"./core/agent\"\nexport type { AgentConfig, DefaultRuntimeExtension } from \"./core/agent\"\nexport { PluginRegistry } from \"./core/plugin\"\nexport type { Plugin } from \"./core/plugin\"\nexport { createTool, toolFactory } from \"./core/tool\"\nexport { listen } from \"./server/listen\"\nexport type { ListenOptions } from \"./server/listen\"\n\n// Re-export tools standard library\nexport * from \"./tools\"\n","import type {\n\tAgentConfig,\n\tAgentRuntime,\n\tAnyTool,\n\tDefaultRuntimeExtension,\n\tGenerateOptions,\n\tAgent as IAgent,\n\tPlugin,\n\tPluginContext,\n\tStreamOptions,\n\tToolGenerator\n} from \"@hybrd/types\"\nimport { randomUUID } from \"@hybrd/utils\"\nimport {\n\tLanguageModel,\n\tUIMessage,\n\tconvertToModelMessages,\n\tgenerateText,\n\tsmoothStream,\n\tstepCountIs,\n\tstreamText\n} from \"ai\"\nimport { render } from \"../lib/render\"\nimport { ListenOptions, listen } from \"../server/listen\"\nimport { PluginRegistry as PluginRegistryImpl } from \"./plugin\"\nimport { toAISDKTools } from \"./tool\"\n\n// Re-export types from @hybrd/types for backward compatibility\nexport type {\n\tAgentConfig,\n\tDefaultRuntimeExtension,\n\tGenerateOptions,\n\tStreamOptions,\n\tToolGenerator\n}\n\n/**\n * Core Agent implementation using AI SDK 5 directly.\n * This class provides a flexible interface for creating AI agents with\n * dynamic configuration, tool support, and streaming capabilities.\n */\nexport class Agent<TRuntimeExtension = DefaultRuntimeExtension>\n\timplements IAgent<TRuntimeExtension, PluginContext>\n{\n\t/** Agent's unique identifier */\n\tpublic readonly name: string\n\t/** Agent configuration */\n\tprivate readonly config: AgentConfig<TRuntimeExtension>\n\t/** Default parameters for text generation */\n\tprivate readonly generationDefaults: Partial<\n\t\tPick<\n\t\t\tParameters<typeof generateText>[0],\n\t\t\t| \"model\"\n\t\t\t| \"messages\"\n\t\t\t| \"tools\"\n\t\t\t| \"toolChoice\"\n\t\t\t| \"stopWhen\"\n\t\t\t| \"maxOutputTokens\"\n\t\t\t| \"temperature\"\n\t\t>\n\t>\n\t/** Default parameters for text streaming */\n\tprivate readonly streamDefaults: Partial<\n\t\tPick<\n\t\t\tParameters<typeof streamText>[0],\n\t\t\t| \"model\"\n\t\t\t| \"messages\"\n\t\t\t| \"tools\"\n\t\t\t| \"toolChoice\"\n\t\t\t| \"stopWhen\"\n\t\t\t| \"experimental_transform\"\n\t\t\t| \"maxOutputTokens\"\n\t\t\t| \"temperature\"\n\t\t>\n\t>\n\t/** Plugin registry for extending the agent's HTTP server */\n\tpublic readonly plugins: PluginRegistryImpl<PluginContext>\n\n\t/**\n\t * Creates a new Agent instance with the specified configuration.\n\t * @param config - Configuration object for the agent\n\t */\n\tconstructor(config: AgentConfig<TRuntimeExtension>) {\n\t\tthis.name = config.name\n\t\tthis.config = config\n\t\tthis.plugins = new PluginRegistryImpl<PluginContext>()\n\n\t\tthis.generationDefaults = {\n\t\t\tmaxOutputTokens: config.maxTokens,\n\t\t\ttemperature: config.temperature\n\t\t}\n\n\t\tthis.streamDefaults = {\n\t\t\tmaxOutputTokens: config.maxTokens,\n\t\t\ttemperature: config.temperature\n\t\t}\n\t}\n\n\t/**\n\t * Resolves dynamic configuration properties (model, tools, instructions) with runtime context.\n\t * @param messages - Current conversation messages\n\t * @param runtime - Runtime context for the agent\n\t * @returns Resolved configuration with model, tools, and instructions\n\t */\n\tprivate async resolveConfig(\n\t\tmessages: UIMessage[],\n\t\truntime: AgentRuntime & TRuntimeExtension\n\t): Promise<{\n\t\tmodel: LanguageModel\n\t\ttools?: Record<string, AnyTool<TRuntimeExtension>>\n\t\tinstructions?: string\n\t}> {\n\t\tconst props = { messages, runtime }\n\n\t\tconst model =\n\t\t\ttypeof this.config.model === \"function\"\n\t\t\t\t? await this.config.model(props)\n\t\t\t\t: this.config.model\n\n\t\tconst tools =\n\t\t\ttypeof this.config.tools === \"function\"\n\t\t\t\t? await this.config.tools(props)\n\t\t\t\t: this.config.tools\n\n\t\tconst instructions =\n\t\t\ttypeof this.config.instructions === \"function\"\n\t\t\t\t? await this.config.instructions(props)\n\t\t\t\t: this.config.instructions\n\n\t\treturn {\n\t\t\tmodel,\n\t\t\ttools,\n\t\t\tinstructions: render(instructions, runtime as Record<string, unknown>)\n\t\t}\n\t}\n\n\t/**\n\t * Prepares messages by adding system instructions if provided.\n\t * Merges instructions with existing system messages or creates new ones.\n\t * @param messages - Current conversation messages\n\t * @param instructions - System instructions to add\n\t * @returns Messages with system instructions properly integrated\n\t */\n\tprivate prepareMessages(\n\t\tmessages: UIMessage[],\n\t\tinstructions?: string\n\t): UIMessage[] {\n\t\tif (!instructions) {\n\t\t\treturn messages\n\t\t}\n\n\t\tif (messages[0]?.role === \"system\") {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\t...messages[0],\n\t\t\t\t\tparts: [{ type: \"text\", text: instructions }]\n\t\t\t\t},\n\t\t\t\t...messages.slice(1)\n\t\t\t]\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: \"system\",\n\t\t\t\tid: randomUUID(),\n\t\t\t\tparts: [{ type: \"text\", text: instructions }]\n\t\t\t},\n\t\t\t...messages\n\t\t]\n\t}\n\n\t/**\n\t * Generates a text completion using the agent's configuration.\n\t * @param messages - Conversation messages to generate from\n\t * @param options - Generation options including runtime context\n\t * @returns Generated text completion result\n\t */\n\tasync generate(\n\t\tmessages: UIMessage[],\n\t\toptions: GenerateOptions<TRuntimeExtension>\n\t) {\n\t\t// Ensure runtime is properly extended with createRuntime function\n\t\tconst extendedRuntime = await this.createRuntimeContext(options.runtime)\n\n\t\tconst { model, tools, instructions } = await this.resolveConfig(\n\t\t\tmessages,\n\t\t\textendedRuntime\n\t\t)\n\n\t\tconst preparedMessages = this.prepareMessages(messages, instructions)\n\n\t\tconst { runtime, maxTokens, telemetry, prompt, ...aiSdkOptions } = options\n\n\t\tconst aiSDKTools = tools\n\t\t\t? toAISDKTools<TRuntimeExtension>(\n\t\t\t\t\ttools,\n\t\t\t\t\textendedRuntime,\n\t\t\t\t\tpreparedMessages\n\t\t\t\t)\n\t\t\t: undefined\n\n\t\tconst result = await generateText({\n\t\t\t...this.generationDefaults,\n\t\t\t...aiSdkOptions,\n\t\t\tmodel,\n\t\t\tmessages: convertToModelMessages(preparedMessages),\n\t\t\ttools: aiSDKTools,\n\t\t\ttoolChoice:\n\t\t\t\taiSDKTools && Object.keys(aiSDKTools).length > 0 ? \"auto\" : undefined,\n\t\t\tstopWhen: [stepCountIs(this.config.maxSteps ?? 5)],\n\t\t\tmaxOutputTokens: maxTokens\n\t\t})\n\n\t\treturn result\n\t}\n\n\t/**\n\t * Streams a text completion using the agent's configuration.\n\t * @param messages - Conversation messages to generate from\n\t * @param options - Streaming options including runtime context\n\t * @returns Streaming response that can be consumed\n\t */\n\tasync stream(\n\t\tmessages: UIMessage[],\n\t\toptions: StreamOptions<TRuntimeExtension>\n\t) {\n\t\t// Ensure runtime is properly extended with createRuntime function\n\t\tconst extendedRuntime = await this.createRuntimeContext(options.runtime)\n\n\t\tconst { model, tools, instructions } = await this.resolveConfig(\n\t\t\tmessages,\n\t\t\textendedRuntime\n\t\t)\n\n\t\tconst preparedMessages = this.prepareMessages(messages, instructions)\n\n\t\tconst { runtime, onFinish, maxTokens, telemetry, prompt, ...aiSdkOptions } =\n\t\t\toptions\n\n\t\tconst aiSDKTools = tools\n\t\t\t? toAISDKTools<TRuntimeExtension>(\n\t\t\t\t\ttools,\n\t\t\t\t\textendedRuntime,\n\t\t\t\t\tpreparedMessages\n\t\t\t\t)\n\t\t\t: undefined\n\n\t\tconst result = await streamText({\n\t\t\t...this.streamDefaults,\n\t\t\t...aiSdkOptions,\n\t\t\tmodel,\n\t\t\tmessages: convertToModelMessages(preparedMessages),\n\t\t\ttools: aiSDKTools,\n\t\t\ttoolChoice:\n\t\t\t\taiSDKTools && Object.keys(aiSDKTools).length > 0 ? \"auto\" : undefined,\n\t\t\tstopWhen: [stepCountIs(this.config.maxSteps ?? 5)],\n\t\t\texperimental_transform: smoothStream(),\n\t\t\tmaxOutputTokens: maxTokens\n\t\t})\n\n\t\treturn result.toUIMessageStreamResponse({\n\t\t\toriginalMessages: messages,\n\t\t\tonFinish\n\t\t})\n\t}\n\n\t/**\n\t * Gets the agent's configuration for debugging and inspection.\n\t * @returns Object containing agent configuration details\n\t */\n\tgetConfig() {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\thasModel: !!this.config.model,\n\t\t\thasTools: !!this.config.tools,\n\t\t\thasInstructions: !!this.config.instructions\n\t\t}\n\t}\n\n\t/**\n\t * Gets the agent's instructions without running generation.\n\t * Useful for external integrations that need instructions separately.\n\t * @param options - Options containing runtime context and optional messages\n\t * @returns Resolved instructions string\n\t */\n\tasync getInstructions(options: {\n\t\truntime: AgentRuntime & TRuntimeExtension\n\t\tmessages?: UIMessage[]\n\t}) {\n\t\t// Ensure runtime is properly extended with createRuntime function\n\t\tconst extendedRuntime = await this.createRuntimeContext(options.runtime)\n\n\t\tconst messages = options.messages || []\n\t\tconst props = { messages, runtime: extendedRuntime }\n\n\t\tif (typeof this.config.instructions === \"function\") {\n\t\t\treturn await this.config.instructions(props)\n\t\t}\n\t\treturn this.config.instructions\n\t}\n\n\t/**\n\t * Gets the agent's tools without running generation.\n\t * Useful for external integrations that need tools separately.\n\t * @param options - Options containing runtime context and optional messages\n\t * @returns Resolved tools object\n\t */\n\tasync getTools(options: {\n\t\truntime: AgentRuntime & TRuntimeExtension\n\t\tmessages?: UIMessage[]\n\t}) {\n\t\t// Ensure runtime is properly extended with createRuntime function\n\t\tconst extendedRuntime = await this.createRuntimeContext(options.runtime)\n\n\t\tconst messages = options.messages || []\n\t\tconst props = { messages, runtime: extendedRuntime }\n\n\t\tif (typeof this.config.tools === \"function\") {\n\t\t\treturn await this.config.tools(props)\n\t\t}\n\t\treturn this.config.tools\n\t}\n\n\t/**\n\t * Creates the complete runtime context by merging base runtime with custom extension.\n\t * @param baseRuntime - The base runtime context containing XMTP properties\n\t * @returns Complete runtime context with custom extensions applied\n\t */\n\t/**\n\t * Creates the complete runtime context by merging base runtime with custom extension.\n\t * @param baseRuntime - The base runtime context containing XMTP properties\n\t * @returns Complete runtime context with custom extensions applied\n\t */\n\tasync createRuntimeContext(\n\t\tbaseRuntime: AgentRuntime\n\t): Promise<AgentRuntime & TRuntimeExtension> {\n\t\t// Always start with the default runtime (baseRuntime)\n\t\tlet completeRuntime = { ...baseRuntime } as AgentRuntime & TRuntimeExtension\n\n\t\t// If user provided createRuntime function, extend the default runtime\n\t\tif (this.config.createRuntime) {\n\t\t\tconst userExtension = await this.config.createRuntime(completeRuntime)\n\t\t\tcompleteRuntime = {\n\t\t\t\t...completeRuntime,\n\t\t\t\t...userExtension\n\t\t\t} as AgentRuntime & TRuntimeExtension\n\t\t}\n\n\t\treturn completeRuntime\n\t}\n\n\t/**\n\t * Registers a plugin with the agent\n\t *\n\t * @param plugin - The plugin to register\n\t */\n\tuse(plugin: Plugin<PluginContext>): void {\n\t\tthis.plugins.register(plugin)\n\t}\n\n\t/**\n\t * Starts listening for messages and events using the agent instance.\n\t * @param opts - Configuration options for the listener, excluding the agent property\n\t */\n\tasync listen(opts: Omit<ListenOptions, \"agent\">) {\n\t\tlisten({ ...opts, agent: this as Agent<DefaultRuntimeExtension> })\n\t}\n}\n","import { Eta } from \"eta\"\n\nexport const eta = new Eta({\n\tviews: \"templates\"\n})\n\nexport const render = (template: string, runtime: Record<string, unknown>) => {\n\treturn eta.renderString(template, runtime)\n}\n","import { serve } from \"@hono/node-server\"\nimport type {\n\tBehaviorObject,\n\tDefaultRuntimeExtension,\n\tHonoVariables,\n\tPluginContext,\n\tXmtpClient\n} from \"@hybrd/types\"\nimport { BehaviorRegistryImpl } from \"@hybrd/types\"\nimport { logger } from \"@hybrd/utils\"\nimport { XMTPPlugin } from \"@hybrd/xmtp\"\nimport { Context, Hono, Next } from \"hono\"\nimport type { Agent } from \"../core/agent\"\nimport type { Plugin } from \"../core/plugin\"\n\nexport type { HonoVariables }\n\n/**\n * Creates Hono middleware to inject XMTP client into request context\n *\n * @description\n * This middleware function sets the XMTP client instance in the Hono context,\n * making it available to all subsequent middleware and route handlers.\n * The client can be accessed via `c.get(\"xmtpClient\")` in route handlers.\n *\n * @param client - The XMTP client instance to inject into the context\n * @returns Hono middleware function that sets the XMTP client in context\n *\n * @example\n * ```typescript\n * app.use(createHonoMiddleware(xmtpClient))\n *\n * app.get(\"/messages\", (c) => {\n * const client = c.get(\"xmtpClient\")\n * // Use the client to interact with XMTP\n * })\n * ```\n */\nexport function createHonoMiddleware(client: XmtpClient) {\n\treturn async (c: Context, next: Next) => {\n\t\tc.set(\"xmtpClient\", client)\n\t\treturn next()\n\t}\n}\n\n/**\n * Options for creating a Hono app with XMTP integration\n *\n * @description\n * Configuration object for setting up a Hono application that includes\n * XMTP client middleware, background message processing, and XMTP tools routes.\n *\n * @template TRuntimeExtension - Runtime extension type for the agent\n * @property agent - The agent instance to use for message processing\n */\nexport type CreateHonoAppOptions<TRuntimeExtension = DefaultRuntimeExtension> =\n\t{\n\t\tagent: Agent<TRuntimeExtension>\n\t}\n\n/**\n * Creates a Hono app with full XMTP integration and background message processing\n *\n * @description\n * This function creates a complete Hono application configured with:\n * - XMTP client middleware for request context\n * - Background message processor for handling XMTP messages\n * - XMTP tools routes for external integrations\n * - Environment variable validation for required XMTP credentials\n *\n * The app automatically starts a background message processor that listens for\n * XMTP messages and forwards them to the provided agent for processing.\n *\n * @template TRuntimeExtension - Runtime extension type for the agent\n * @param options - Configuration options for the Hono app\n * @param options.agent - The agent instance to handle XMTP messages\n * @returns Promise that resolves to a configured Hono app instance\n *\n * @throws {Error} When XMTP_WALLET_KEY environment variable is not set\n * @throws {Error} When XMTP_DB_ENCRYPTION_KEY environment variable is not set\n *\n * @example\n * ```typescript\n * const app = await createHonoApp({ agent: myAgent })\n *\n * // The app now has XMTP integration and background processing\n * app.get(\"/health\", (c) => c.json({ status: \"ok\" }))\n * ```\n */\nexport async function createHonoApp<\n\tTRuntimeExtension = DefaultRuntimeExtension\n>({ agent }: CreateHonoAppOptions<TRuntimeExtension>) {\n\tconst app = new Hono<{ Variables: HonoVariables }>()\n\n\t// Mount XMTP tools routes\n\t// app.route(\"/xmtp-tools\", xmtpApp) // This line is removed as per the edit hint\n\n\treturn app\n}\n\n/**\n * Options for starting the XMTP tools HTTP server\n *\n * @description\n * Configuration object for the standalone XMTP tools server that provides\n * basic HTTP endpoints for health checks and XMTP operations.\n *\n * @property agent - The agent instance to associate with the server\n * @property port - The port number to listen on (defaults to 8454)\n * @property filter - Optional message filter for XMTP messages\n * @property plugins - Optional array of plugins to apply to the server\n * @property behaviors - Optional array of behaviors to apply to message processing\n */\nexport type ListenOptions = {\n\tagent: Agent\n\tport: string\n\tplugins?: Plugin<PluginContext>[]\n\tbehaviors?: BehaviorObject[]\n}\n\n/**\n * Starts a standalone XMTP tools HTTP server\n *\n * @description\n * This function creates and starts a minimal HTTP server specifically for\n * XMTP tools operations. It includes:\n * - Health check endpoint at `/health`\n * - 404 handler for unmatched routes\n * - Automatic port parsing from string input\n * - Plugin-based route mounting\n *\n * The server runs independently and is useful for scenarios where you need\n * XMTP tools functionality without the full Hono app integration.\n *\n * @param options - Configuration options for the server\n * @param options.agent - The agent instance to associate with the server\n * @param options.port - The port number to listen on (parsed as integer)\n *\n * @example\n * ```typescript\n * listen({\n * agent: myAgent,\n * port: \"3000\"\n * })\n *\n * // Server starts on port 3000 with health endpoint at /health\n * // and all registered plugins applied\n * ```\n */\nexport async function listen({\n\tagent,\n\tport,\n\tplugins = [],\n\tbehaviors = []\n}: ListenOptions) {\n\tconst app = new Hono<{ Variables: HonoVariables }>()\n\tconst context = {\n\t\tagent,\n\t\tbehaviors: behaviors.length > 0 ? new BehaviorRegistryImpl() : undefined\n\t} as PluginContext & { behaviors?: BehaviorRegistryImpl }\n\n\t// Register behaviors if provided\n\tif (behaviors.length > 0 && context.behaviors) {\n\t\tcontext.behaviors.registerAll(behaviors)\n\t}\n\n\tconst xmtpPlugin = XMTPPlugin()\n\n\t// Right now we always apply the XMTP plugin, but this may change in the future.\n\tawait xmtpPlugin.apply(app, context)\n\n\t// Apply plugins from agent registry first\n\tawait agent.plugins.applyAll(app, context)\n\n\t// Apply plugins from listen options\n\tfor (const plugin of plugins) {\n\t\tawait plugin.apply(app, context)\n\t}\n\n\tapp.get(\"/health\", (c) => {\n\t\treturn c.json({\n\t\t\tstatus: \"healthy\",\n\t\t\tservice: agent.name,\n\t\t\ttimestamp: new Date().toISOString()\n\t\t})\n\t})\n\n\tapp.notFound((c) => {\n\t\treturn c.json({ error: \"Not found\" }, 404)\n\t})\n\n\tconst httpPort = Number.parseInt(port || \"8454\")\n\n\t// Setup graceful shutdown\n\tconst shutdown = async () => {\n\t\tlogger.debug(\"Waiting for graceful termination...\")\n\n\t\t// Stop background processor first\n\t\t// try {\n\t\t// \tstopBackground()\n\t\t// } catch (error) {\n\t\t// \tconsole.error(\"Error stopping background processor:\", error)\n\t\t// }\n\n\t\t// Give some time for cleanup\n\t\tawait new Promise((resolve) => setTimeout(resolve, 1000))\n\t}\n\n\t// Register shutdown handlers\n\tprocess.once(\"SIGINT\", async () => {\n\t\tawait shutdown()\n\t\tprocess.exit(0)\n\t})\n\n\tprocess.once(\"SIGTERM\", async () => {\n\t\tawait shutdown()\n\t\tprocess.exit(0)\n\t})\n\n\t// Handle uncaught errors\n\tprocess.on(\"uncaughtException\", async (error) => {\n\t\tconsole.error(\"Uncaught exception:\", error)\n\t\tawait shutdown()\n\t\tprocess.exit(1)\n\t})\n\n\tprocess.on(\"unhandledRejection\", async (reason) => {\n\t\tconsole.error(\"Unhandled rejection:\", reason)\n\t\tawait shutdown()\n\t\tprocess.exit(1)\n\t})\n\n\ttry {\n\t\tserve({\n\t\t\tfetch: app.fetch,\n\t\t\tport: httpPort\n\t\t})\n\n\t\t// Clean startup messaging\n\t\tconsole.log(`Starting hybrid ... ✅ DONE`)\n\t\tconsole.log(`Hybrid listening on http://localhost:${httpPort}`)\n\n\t\t// Get XMTP info for \"We are online\" message\n\t\tconst xmtpWalletKey = process.env.XMTP_WALLET_KEY\n\t\tconst xmtpEnv = process.env.XMTP_ENV || \"production\"\n\n\t\tif (xmtpWalletKey) {\n\t\t\tconst walletAddress = xmtpWalletKey.replace(/^0x/, \"\") // Remove 0x prefix if present\n\t\t\tconsole.log(\n\t\t\t\t`Chat with your agent: http://xmtp.chat/dm/${walletAddress}?env=${xmtpEnv}`\n\t\t\t)\n\t\t}\n\n\t\tlogger.debug(`✅ Hybrid server running on port ${httpPort}`)\n\t\tlogger.debug(`🎧 Background message listener is active`)\n\t} catch (error: any) {\n\t\tif (error.code === \"EADDRINUSE\") {\n\t\t\tconsole.error(\n\t\t\t\t`❌ Port ${httpPort} is already in use. Please stop the existing server or use a different port.`\n\t\t\t)\n\t\t\tprocess.exit(1)\n\t\t} else {\n\t\t\tconsole.error(\"Server error:\", error)\n\t\t\tprocess.exit(1)\n\t\t}\n\t}\n}\n","import type { HonoVariables, Plugin } from \"@hybrd/types\"\nimport type { Hono } from \"hono\"\nimport { logger } from \"@hybrd/utils\"\n\n// Re-export types from @hybrd/types for backward compatibility\nexport type { Plugin }\n\n/**\n * Plugin registry that manages all registered plugins\n *\n * @description\n * The plugin registry allows you to register, configure, and apply\n * plugins to Hono apps. It provides a centralized way to manage\n * plugin dependencies and execution order.\n */\nexport class PluginRegistry<T = Record<string, never>> {\n\tprivate plugins: Map<string, Plugin<T>> = new Map()\n\n\t/**\n\t * Registers a plugin with the registry\n\t *\n\t * @param plugin - The plugin to register\n\t * @throws {Error} If a plugin with the same name is already registered\n\t */\n\tregister(plugin: Plugin<T>): void {\n\t\tif (this.plugins.has(plugin.name)) {\n\t\t\tthrow new Error(`Plugin \"${plugin.name}\" is already registered`)\n\t\t}\n\n\t\tthis.plugins.set(plugin.name, plugin)\n\t}\n\n\t/**\n\t * Unregisters a plugin from the registry\n\t *\n\t * @param name - The name of the plugin to unregister\n\t * @returns True if the plugin was unregistered, false if it wasn't found\n\t */\n\tunregister(name: string): boolean {\n\t\treturn this.plugins.delete(name)\n\t}\n\n\t/**\n\t * Gets a plugin by name\n\t *\n\t * @param name - The name of the plugin to retrieve\n\t * @returns The plugin if found, undefined otherwise\n\t */\n\tget(name: string): Plugin<T> | undefined {\n\t\treturn this.plugins.get(name)\n\t}\n\n\t/**\n\t * Gets all registered plugins\n\t *\n\t * @returns Array of all registered plugins\n\t */\n\tgetAll(): Plugin<T>[] {\n\t\treturn Array.from(this.plugins.values())\n\t}\n\n\t/**\n\t * Checks if a plugin is registered\n\t *\n\t * @param name - The name of the plugin to check\n\t * @returns True if the plugin is registered, false otherwise\n\t */\n\thas(name: string): boolean {\n\t\treturn this.plugins.has(name)\n\t}\n\n\t/**\n\t * Applies all registered plugins to a Hono app\n\t *\n\t * @param app - The Hono app instance to extend\n\t * @param context - Optional context data passed to all plugins\n\t */\n\tasync applyAll(\n\t\tapp: Hono<{ Variables: HonoVariables }>,\n\t\tcontext: T\n\t): Promise<void> {\n\t\tconst plugins = this.getAll()\n\n\t\tfor (const plugin of plugins) {\n\t\t\ttry {\n\t\t\t\tlogger.debug(`🔌 Applying plugin: ${plugin.name}`)\n\t\t\t\tawait plugin.apply(app, context)\n\t\t\t\tlogger.debug(`✅ Plugin applied: ${plugin.name}`)\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(`❌ Failed to apply plugin ${plugin.name}:`, error)\n\t\t\t\tthrow error\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Clears all registered plugins\n\t */\n\tclear(): void {\n\t\tthis.plugins.clear()\n\t}\n\n\t/**\n\t * Gets the number of registered plugins\n\t */\n\tget size(): number {\n\t\treturn this.plugins.size\n\t}\n}\n\n/**\n * Creates a plugin that mounts routes at a specific path\n *\n * @param name - Plugin name\n * @param path - Path to mount the routes at\n * @param routes - Hono app containing the routes to mount\n * @returns A plugin that mounts the routes\n */\nexport function createRoutePlugin(\n\tname: string,\n\tpath: string,\n\troutes: Hono<{ Variables: HonoVariables }>\n): Plugin {\n\treturn {\n\t\tname,\n\t\tdescription: `Mounts routes at ${path}`,\n\t\tapply: (app: Hono<{ Variables: HonoVariables }>) => {\n\t\t\tapp.route(path, routes)\n\t\t}\n\t}\n}\n\n/**\n * Creates a plugin that applies middleware\n *\n * @param name - Plugin name\n * @param middleware - Middleware function to apply\n * @returns A plugin that applies the middleware\n */\nexport function createMiddlewarePlugin(\n\tname: string,\n\tmiddleware: (app: Hono<{ Variables: HonoVariables }>) => void\n): Plugin {\n\treturn {\n\t\tname,\n\t\tdescription: `Applies middleware: ${name}`,\n\t\tapply: middleware\n\t}\n}\n","import type {\n\tAgentRuntime,\n\tAnyTool,\n\tDefaultRuntimeExtension,\n\tTool\n} from \"@hybrd/types\"\nimport { logger } from \"@hybrd/utils\"\nimport { Tool as AISDKTool, type UIMessage } from \"ai\"\nimport { z } from \"zod\"\n\n// Re-export types from @hybrd/types for backward compatibility\nexport type { AnyTool, DefaultRuntimeExtension, Tool }\n\n/**\n * Factory function to create tools with custom runtime extensions.\n * Provides proper type inference for input/output schemas and runtime extensions.\n */\nexport function toolFactory<TRuntimeExtension = DefaultRuntimeExtension>() {\n\treturn <\n\t\tTInput extends z.ZodTypeAny = z.ZodTypeAny,\n\t\tTOutput extends z.ZodTypeAny = z.ZodTypeAny\n\t>(\n\t\tconfig: Tool<TInput, TOutput, TRuntimeExtension>\n\t): Tool<TInput, TOutput, TRuntimeExtension> => {\n\t\treturn {\n\t\t\tdescription: config.description,\n\t\t\tinputSchema: config.inputSchema,\n\t\t\toutputSchema: config.outputSchema,\n\t\t\texecute: async (args) => {\n\t\t\t\tconst input = config.inputSchema.parse(args.input)\n\t\t\t\tconst result = await config.execute({\n\t\t\t\t\tinput,\n\t\t\t\t\truntime: args.runtime,\n\t\t\t\t\tmessages: args.messages\n\t\t\t\t})\n\t\t\t\tif (config.outputSchema) {\n\t\t\t\t\treturn config.outputSchema.parse(result)\n\t\t\t\t}\n\t\t\t\treturn result\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Default tool factory with no runtime extensions.\n * Type-safe at creation time with proper schema inference.\n */\nexport const createTool = toolFactory()\n\n/**\n * Converts a custom Tool instance to AI SDK's tool format.\n * This adapter enables our tools to work with AI SDK's generateText/streamText functions.\n */\nexport function toAISDKTool<\n\tTInput extends z.ZodTypeAny = z.ZodTypeAny,\n\tTOutput extends z.ZodTypeAny = z.ZodTypeAny,\n\tTRuntimeExtension = DefaultRuntimeExtension\n>(\n\ttool: Tool<TInput, TOutput, TRuntimeExtension>,\n\truntime: AgentRuntime & TRuntimeExtension,\n\tmessages: UIMessage[]\n): AISDKTool {\n\treturn {\n\t\tdescription: tool.description,\n\t\tinputSchema: tool.inputSchema,\n\t\texecute: async (args: z.infer<TInput>) => {\n\t\t\tconst startTime = performance.now()\n\t\t\tlogger.debug(`🔧 [${tool.description}] Executing with input:`, args)\n\n\t\t\tconst result = await tool.execute({\n\t\t\t\tinput: args,\n\t\t\t\truntime,\n\t\t\t\tmessages\n\t\t\t})\n\n\t\t\tconst endTime = performance.now()\n\t\t\tlogger.debug(\n\t\t\t\t`✅ [${tool.description}] Completed in ${(endTime - startTime).toFixed(2)}ms with result:`,\n\t\t\t\tresult\n\t\t\t)\n\n\t\t\treturn result\n\t\t}\n\t}\n}\n\n/**\n * Converts a collection of custom tools to AI SDK format.\n * Useful for batch conversion when setting up multiple tools for AI SDK usage.\n */\nexport function toAISDKTools<TRuntimeExtension = DefaultRuntimeExtension>(\n\ttools: Record<string, AnyTool<TRuntimeExtension>>,\n\truntime: AgentRuntime & TRuntimeExtension,\n\tmessages: UIMessage[]\n): Record<string, AISDKTool> {\n\tconst convertedTools: Record<string, AISDKTool> = {}\n\n\tfor (const [name, tool] of Object.entries(tools)) {\n\t\tconvertedTools[name] = toAISDKTool(tool, runtime, messages)\n\t}\n\n\treturn convertedTools\n}\n","/**\n * @fileoverview Blockchain Tools for Crypto Agents\n *\n * This module provides comprehensive blockchain interaction tools for crypto-enabled agents.\n * Supports Ethereum and other EVM-compatible chains with features like balance checking,\n * transaction sending, contract interaction, and more.\n *\n * @module BlockchainTools\n */\n\nimport { logger } from \"@hybrd/utils\"\nimport {\n\tcreatePublicClient,\n\tcreateWalletClient,\n\tformatEther,\n\thttp,\n\tparseEther,\n\ttype Address,\n\ttype Hash\n} from \"viem\"\nimport { privateKeyToAccount } from \"viem/accounts\"\nimport {\n\tarbitrum,\n\tbase,\n\tmainnet,\n\toptimism,\n\tpolygon,\n\tsepolia\n} from \"viem/chains\"\nimport { z } from \"zod\"\nimport { createTool } from \"../core/tool\"\n\n// Supported chains configuration\nconst SUPPORTED_CHAINS = {\n\tmainnet,\n\tsepolia,\n\tpolygon,\n\tarbitrum,\n\toptimism,\n\tbase\n} as const\n\ntype SupportedChain = keyof typeof SUPPORTED_CHAINS\n\n// Runtime extension interface for blockchain tools\nexport interface BlockchainRuntimeExtension {\n\trpcUrl?: string\n\tprivateKey?: string\n\tdefaultChain?: SupportedChain\n}\n\n/**\n * Get Balance Tool\n *\n * Retrieves the native token balance for a given address on a specified chain.\n *\n * @tool getBalance\n * @category Blockchain\n *\n * @param {string} address - The wallet address to check balance for\n * @param {string} [chain] - The blockchain network (defaults to mainnet)\n *\n * @returns {Promise<{success: boolean, balance: string, balanceWei: string, address: string, chain: string, error?: string}>}\n */\nexport const getBalanceTool = createTool({\n\tdescription:\n\t\t\"Get the native token balance for a wallet address on a blockchain\",\n\tinputSchema: z.object({\n\t\taddress: z.string().describe(\"The wallet address to check balance for\"),\n\t\tchain: z\n\t\t\t.enum([\"mainnet\", \"sepolia\", \"polygon\", \"arbitrum\", \"optimism\", \"base\"])\n\t\t\t.default(\"mainnet\")\n\t\t\t.describe(\"The blockchain network to check on\")\n\t}),\n\toutputSchema: z.object({\n\t\tsuccess: z.boolean(),\n\t\tbalance: z\n\t\t\t.string()\n\t\t\t.describe(\"Balance in human readable format (ETH, MATIC, etc.)\"),\n\t\tbalanceWei: z.string().describe(\"Balance in wei (smallest unit)\"),\n\t\taddress: z.string(),\n\t\tchain: z.string(),\n\t\terror: z.string().optional()\n\t}),\n\texecute: async ({ input, runtime }) => {\n\t\ttry {\n\t\t\tconst { address, chain } = input\n\t\t\tconst chainConfig = SUPPORTED_CHAINS[chain]\n\n\t\t\t// Use runtime RPC URL if provided, otherwise use default\n\t\t\tconst rpcUrl =\n\t\t\t\t(runtime as any).rpcUrl || chainConfig.rpcUrls.default.http[0]\n\n\t\t\tconst client = createPublicClient({\n\t\t\t\tchain: chainConfig,\n\t\t\t\ttransport: http(rpcUrl)\n\t\t\t})\n\n\t\t\tlogger.debug(\n\t\t\t\t`🔍 [getBalance] Checking balance for ${address} on ${chain}`\n\t\t\t)\n\n\t\t\tconst balanceWei = await client.getBalance({\n\t\t\t\taddress: address as Address\n\t\t\t})\n\n\t\t\tconst balance = formatEther(balanceWei)\n\n\t\t\tlogger.debug(\n\t\t\t\t`✅ [getBalance] Balance: ${balance} ${chainConfig.nativeCurrency.symbol}`\n\t\t\t)\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tbalance: `${balance} ${chainConfig.nativeCurrency.symbol}`,\n\t\t\t\tbalanceWei: balanceWei.toString(),\n\t\t\t\taddress,\n\t\t\t\tchain\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\tconsole.error(\"❌ [getBalance] Error:\", errorMessage)\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tbalance: \"0\",\n\t\t\t\tbalanceWei: \"0\",\n\t\t\t\taddress: input.address,\n\t\t\t\tchain: input.chain,\n\t\t\t\terror: errorMessage\n\t\t\t}\n\t\t}\n\t}\n})\n\n/**\n * Get Transaction Tool\n *\n * Retrieves transaction details by transaction hash.\n *\n * @tool getTransaction\n * @category Blockchain\n *\n * @param {string} hash - The transaction hash to look up\n * @param {string} [chain] - The blockchain network (defaults to mainnet)\n *\n * @returns {Promise<{success: boolean, transaction?: object, error?: string}>}\n */\nexport const getTransactionTool = createTool({\n\tdescription: \"Get transaction details by transaction hash\",\n\tinputSchema: z.object({\n\t\thash: z.string().describe(\"The transaction hash to look up\"),\n\t\tchain: z\n\t\t\t.enum([\"mainnet\", \"sepolia\", \"polygon\", \"arbitrum\", \"optimism\", \"base\"])\n\t\t\t.default(\"mainnet\")\n\t\t\t.describe(\"The blockchain network to check on\")\n\t}),\n\toutputSchema: z.object({\n\t\tsuccess: z.boolean(),\n\t\ttransaction: z\n\t\t\t.object({\n\t\t\t\thash: z.string(),\n\t\t\t\tfrom: z.string(),\n\t\t\t\tto: z.string().nullable(),\n\t\t\t\tvalue: z.string(),\n\t\t\t\tgasUsed: z.string().optional(),\n\t\t\t\tgasPrice: z.string().optional(),\n\t\t\t\tblockNumber: z.string().optional(),\n\t\t\t\tstatus: z.string().optional()\n\t\t\t})\n\t\t\t.optional(),\n\t\terror: z.string().optional()\n\t}),\n\texecute: async ({ input, runtime }) => {\n\t\ttry {\n\t\t\tconst { hash, chain } = input\n\t\t\tconst chainConfig = SUPPORTED_CHAINS[chain]\n\n\t\t\tconst rpcUrl =\n\t\t\t\t(runtime as any).rpcUrl || chainConfig.rpcUrls.default.http[0]\n\n\t\t\tconst client = createPublicClient({\n\t\t\t\tchain: chainConfig,\n\t\t\t\ttransport: http(rpcUrl)\n\t\t\t})\n\n\t\t\tlogger.debug(\n\t\t\t\t`🔍 [getTransaction] Looking up transaction ${hash} on ${chain}`\n\t\t\t)\n\n\t\t\tconst transaction = await client.getTransaction({\n\t\t\t\thash: hash as Hash\n\t\t\t})\n\n\t\t\tconst receipt = await client\n\t\t\t\t.getTransactionReceipt({\n\t\t\t\t\thash: hash as Hash\n\t\t\t\t})\n\t\t\t\t.catch(() => null) // Transaction might be pending\n\n\t\t\tlogger.debug(\n\t\t\t\t`✅ [getTransaction] Found transaction from ${transaction.from} to ${transaction.to}`\n\t\t\t)\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\ttransaction: {\n\t\t\t\t\thash: transaction.hash,\n\t\t\t\t\tfrom: transaction.from,\n\t\t\t\t\tto: transaction.to,\n\t\t\t\t\tvalue: formatEther(transaction.value),\n\t\t\t\t\tgasUsed: receipt?.gasUsed.toString(),\n\t\t\t\t\tgasPrice: transaction.gasPrice?.toString(),\n\t\t\t\t\tblockNumber: transaction.blockNumber?.toString(),\n\t\t\t\t\tstatus:\n\t\t\t\t\t\treceipt?.status === \"success\"\n\t\t\t\t\t\t\t? \"success\"\n\t\t\t\t\t\t\t: receipt?.status === \"reverted\"\n\t\t\t\t\t\t\t\t? \"failed\"\n\t\t\t\t\t\t\t\t: \"pending\"\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\tconsole.error(\"❌ [getTransaction] Error:\", errorMessage)\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: errorMessage\n\t\t\t}\n\t\t}\n\t}\n})\n\n/**\n * Send Transaction Tool\n *\n * Sends a native token transaction to another address.\n * Requires a private key to be configured in the runtime.\n *\n * @tool sendTransaction\n * @category Blockchain\n *\n * @param {string} to - The recipient address\n * @param {string} amount - The amount to send (in ETH, MATIC, etc.)\n * @param {string} [chain] - The blockchain network (defaults to mainnet)\n *\n * @returns {Promise<{success: boolean, hash?: string, error?: string}>}\n */\nexport const sendTransactionTool = createTool({\n\tdescription: \"Send native tokens to another address\",\n\tinputSchema: z.object({\n\t\tto: z.string().describe(\"The recipient address\"),\n\t\tamount: z.string().describe(\"The amount to send (in ETH, MATIC, etc.)\"),\n\t\tchain: z\n\t\t\t.enum([\"mainnet\", \"sepolia\", \"polygon\", \"arbitrum\", \"optimism\", \"base\"])\n\t\t\t.default(\"mainnet\")\n\t\t\t.describe(\"The blockchain network to send on\")\n\t}),\n\toutputSchema: z.object({\n\t\tsuccess: z.boolean(),\n\t\thash: z.string().optional(),\n\t\tfrom: z.string().optional(),\n\t\tto: z.string(),\n\t\tamount: z.string(),\n\t\tchain: z.string(),\n\t\terror: z.string().optional()\n\t}),\n\texecute: async ({ input, runtime }) => {\n\t\ttry {\n\t\t\tconst { to, amount, chain } = input\n\t\t\tconst chainConfig = SUPPORTED_CHAINS[chain]\n\n\t\t\tconst privateKey = (runtime as any).privateKey\n\t\t\tif (!privateKey) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tto,\n\t\t\t\t\tamount,\n\t\t\t\t\tchain,\n\t\t\t\t\terror: \"Private key not configured in runtime\"\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst rpcUrl =\n\t\t\t\t(runtime as any).rpcUrl || chainConfig.rpcUrls.default.http[0]\n\t\t\tconst account = privateKeyToAccount(privateKey as `0x${string}`)\n\n\t\t\tconst client = createWalletClient({\n\t\t\t\taccount,\n\t\t\t\tchain: chainConfig,\n\t\t\t\ttransport: http(rpcUrl)\n\t\t\t})\n\n\t\t\tlogger.debug(\n\t\t\t\t`💸 [sendTransaction] Sending ${amount} ${chainConfig.nativeCurrency.symbol} to ${to} on ${chain}`\n\t\t\t)\n\n\t\t\tconst hash = await client.sendTransaction({\n\t\t\t\tto: to as Address,\n\t\t\t\tvalue: parseEther(amount)\n\t\t\t})\n\n\t\t\tlogger.debug(`✅ [sendTransaction] Transaction sent: ${hash}`)\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\thash,\n\t\t\t\tfrom: account.address,\n\t\t\t\tto,\n\t\t\t\tamount,\n\t\t\t\tchain\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\tconsole.error(\"❌ [sendTransaction] Error:\", errorMessage)\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tto: input.to,\n\t\t\t\tamount: input.amount,\n\t\t\t\tchain: input.chain,\n\t\t\t\terror: errorMessage\n\t\t\t}\n\t\t}\n\t}\n})\n\n/**\n * Get Block Tool\n *\n * Retrieves information about a specific block.\n *\n * @tool getBlock\n * @category Blockchain\n *\n * @param {string} [blockNumber] - Block number (defaults to latest)\n * @param {string} [chain] - The blockchain network (defaults to mainnet)\n *\n * @returns {Promise<{success: boolean, block?: object, error?: string}>}\n */\nexport const getBlockTool = createTool({\n\tdescription: \"Get information about a blockchain block\",\n\tinputSchema: z.object({\n\t\tblockNumber: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\"Block number (defaults to latest)\"),\n\t\tchain: z\n\t\t\t.enum([\"mainnet\", \"sepolia\", \"polygon\", \"arbitrum\", \"optimism\", \"base\"])\n\t\t\t.default(\"mainnet\")\n\t\t\t.describe(\"The blockchain network to check on\")\n\t}),\n\toutputSchema: z.object({\n\t\tsuccess: z.boolean(),\n\t\tblock: z\n\t\t\t.object({\n\t\t\t\tnumber: z.string(),\n\t\t\t\thash: z.string(),\n\t\t\t\ttimestamp: z.string(),\n\t\t\t\ttransactionCount: z.number(),\n\t\t\t\tgasUsed: z.string(),\n\t\t\t\tgasLimit: z.string()\n\t\t\t})\n\t\t\t.optional(),\n\t\terror: z.string().optional()\n\t}),\n\texecute: async ({ input, runtime }) => {\n\t\ttry {\n\t\t\tconst { blockNumber, chain } = input\n\t\t\tconst chainConfig = SUPPORTED_CHAINS[chain]\n\n\t\t\tconst rpcUrl =\n\t\t\t\t(runtime as any).rpcUrl || chainConfig.rpcUrls.default.http[0]\n\n\t\t\tconst client = createPublicClient({\n\t\t\t\tchain: chainConfig,\n\t\t\t\ttransport: http(rpcUrl)\n\t\t\t})\n\n\t\t\tlogger.debug(\n\t\t\t\t`🔍 [getBlock] Getting block ${blockNumber || \"latest\"} on ${chain}`\n\t\t\t)\n\n\t\t\tconst block = await client.getBlock({\n\t\t\t\tblockNumber: blockNumber ? BigInt(blockNumber) : undefined\n\t\t\t})\n\n\t\t\tlogger.debug(\n\t\t\t\t`✅ [getBlock] Found block ${block.number} with ${block.transactions.length} transactions`\n\t\t\t)\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tblock: {\n\t\t\t\t\tnumber: block.number.toString(),\n\t\t\t\t\thash: block.hash,\n\t\t\t\t\ttimestamp: block.timestamp.toString(),\n\t\t\t\t\ttransactionCount: block.transactions.length,\n\t\t\t\t\tgasUsed: block.gasUsed.toString(),\n\t\t\t\t\tgasLimit: block.gasLimit.toString()\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\tconsole.error(\"❌ [getBlock] Error:\", errorMessage)\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: errorMessage\n\t\t\t}\n\t\t}\n\t}\n})\n\n/**\n * Get Gas Price Tool\n *\n * Retrieves current gas price information for a blockchain.\n *\n * @tool getGasPrice\n * @category Blockchain\n *\n * @param {string} [chain] - The blockchain network (defaults to mainnet)\n *\n * @returns {Promise<{success: boolean, gasPrice?: string, error?: string}>}\n */\nexport const getGasPriceTool = createTool({\n\tdescription: \"Get current gas price for a blockchain\",\n\tinputSchema: z.object({\n\t\tchain: z\n\t\t\t.enum([\"mainnet\", \"sepolia\", \"polygon\", \"arbitrum\", \"optimism\", \"base\"])\n\t\t\t.default(\"mainnet\")\n\t\t\t.describe(\"The blockchain network to check on\")\n\t}),\n\toutputSchema: z.object({\n\t\tsuccess: z.boolean(),\n\t\tgasPrice: z.string().optional().describe(\"Gas price in gwei\"),\n\t\tgasPriceWei: z.string().optional().describe(\"Gas price in wei\"),\n\t\tchain: z.string(),\n\t\terror: z.string().optional()\n\t}),\n\texecute: async ({ input, runtime }) => {\n\t\ttry {\n\t\t\tconst { chain } = input\n\t\t\tconst chainConfig = SUPPORTED_CHAINS[chain]\n\n\t\t\tconst rpcUrl =\n\t\t\t\t(runtime as any).rpcUrl || chainConfig.rpcUrls.default.http[0]\n\n\t\t\tconst client = createPublicClient({\n\t\t\t\tchain: chainConfig,\n\t\t\t\ttransport: http(rpcUrl)\n\t\t\t})\n\n\t\t\tlogger.debug(`⛽ [getGasPrice] Getting gas price for ${chain}`)\n\n\t\t\tconst gasPrice = await client.getGasPrice()\n\t\t\tconst gasPriceGwei = formatEther(gasPrice * BigInt(1000000000)) // Convert to gwei\n\n\t\t\tlogger.debug(`✅ [getGasPrice] Current gas price: ${gasPriceGwei} gwei`)\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tgasPrice: `${gasPriceGwei} gwei`,\n\t\t\t\tgasPriceWei: gasPrice.toString(),\n\t\t\t\tchain\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\tconsole.error(\"❌ [getGasPrice] Error:\", errorMessage)\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tchain: input.chain,\n\t\t\t\terror: errorMessage\n\t\t\t}\n\t\t}\n\t}\n})\n\n/**\n * Estimate Gas Tool\n *\n * Estimates gas required for a transaction.\n *\n * @tool estimateGas\n * @category Blockchain\n *\n * @param {string} to - The recipient address\n * @param {string} [amount] - The amount to send (defaults to 0)\n * @param {string} [data] - Transaction data (for contract calls)\n * @param {string} [chain] - The blockchain network (defaults to mainnet)\n *\n * @returns {Promise<{success: boolean, gasEstimate?: string, error?: string}>}\n */\nexport const estimateGasTool = createTool({\n\tdescription: \"Estimate gas required for a transaction\",\n\tinputSchema: z.object({\n\t\tto: z.string().describe(\"The recipient address\"),\n\t\tamount: z\n\t\t\t.string()\n\t\t\t.default(\"0\")\n\t\t\t.describe(\"The amount to send (defaults to 0)\"),\n\t\tdata: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\"Transaction data (for contract calls)\"),\n\t\tchain: z\n\t\t\t.enum([\"mainnet\", \"sepolia\", \"polygon\", \"arbitrum\", \"optimism\", \"base\"])\n\t\t\t.default(\"mainnet\")\n\t\t\t.describe(\"The blockchain network to estimate on\")\n\t}),\n\toutputSchema: z.object({\n\t\tsuccess: z.boolean(),\n\t\tgasEstimate: z.string().optional(),\n\t\tto: z.string(),\n\t\tamount: z.string(),\n\t\tchain: z.string(),\n\t\terror: z.string().optional()\n\t}),\n\texecute: async ({ input, runtime }) => {\n\t\ttry {\n\t\t\tconst { to, amount, data, chain } = input\n\t\t\tconst chainConfig = SUPPORTED_CHAINS[chain]\n\n\t\t\tconst privateKey = (runtime as any).privateKey\n\t\t\tif (!privateKey) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tto,\n\t\t\t\t\tamount,\n\t\t\t\t\tchain,\n\t\t\t\t\terror: \"Private key not configured in runtime\"\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst rpcUrl =\n\t\t\t\t(runtime as any).rpcUrl || chainConfig.rpcUrls.default.http[0]\n\t\t\tconst account = privateKeyToAccount(privateKey as `0x${string}`)\n\n\t\t\tconst client = createPublicClient({\n\t\t\t\tchain: chainConfig,\n\t\t\t\ttransport: http(rpcUrl)\n\t\t\t})\n\n\t\t\tconsole.log(\n\t\t\t\t`⛽ [estimateGas] Estimating gas for transaction to ${to} on ${chain}`\n\t\t\t)\n\n\t\t\tconst gasEstimate = await client.estimateGas({\n\t\t\t\taccount: account.address,\n\t\t\t\tto: to as Address,\n\t\t\t\tvalue: parseEther(amount),\n\t\t\t\tdata: data as `0x${string}` | undefined\n\t\t\t})\n\n\t\t\tconsole.log(`✅ [estimateGas] Estimated gas: ${gasEstimate.toString()}`)\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tgasEstimate: gasEstimate.toString(),\n\t\t\t\tto,\n\t\t\t\tamount,\n\t\t\t\tchain\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\tconsole.error(\"❌ [estimateGas] Error:\", errorMessage)\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tto: input.to,\n\t\t\t\tamount: input.amount,\n\t\t\t\tchain: input.chain,\n\t\t\t\terror: errorMessage\n\t\t\t}\n\t\t}\n\t}\n})\n\n/**\n * Collection of blockchain tools for crypto agents\n *\n * These tools provide comprehensive blockchain interaction capabilities including\n * balance checking, transaction sending, gas estimation, and more.\n *\n * @namespace blockchainTools\n *\n * @property {Tool} getBalance - Get native token balance for an address\n * @property {Tool} getTransaction - Get transaction details by hash\n * @property {Tool} sendTransaction - Send native tokens to another address\n * @property {Tool} getBlock - Get information about a blockchain block\n * @property {Tool} getGasPrice - Get current gas price for a blockchain\n * @property {Tool} estimateGas - Estimate gas required for a transaction\n */\nexport const blockchainTools = {\n\tgetBalance: getBalanceTool,\n\tgetTransaction: getTransactionTool,\n\tsendTransaction: sendTransactionTool,\n\tgetBlock: getBlockTool,\n\tgetGasPrice: getGasPriceTool,\n\testimateGas: estimateGasTool\n}\n","/**\n * @fileoverview XMTP Communication Tools for Crypto Agents\n *\n * This module provides comprehensive XMTP messaging tools for crypto-enabled agents.\n * Includes capabilities for sending messages, replies, reactions, and managing conversations.\n *\n * @module XMTPTools\n */\n\nimport { logger } from \"@hybrd/utils\"\nimport {\n\tContentTypeReaction,\n\tContentTypeReply,\n\tContentTypeText,\n\tReply\n} from \"@hybrd/xmtp\"\nimport { z } from \"zod\"\nimport { createTool } from \"../core/tool\"\n\n/**\n * Get Message Tool\n *\n * Retrieves a specific message by ID from the XMTP service.\n *\n * @tool getMessage\n * @category Communication\n *\n * @param {string} messageId - The message ID to retrieve\n *\n * @returns {Promise<{success: boolean, message?: object, error?: string}>}\n */\nexport const getMessageTool = createTool({\n\tdescription: \"Get a specific message by ID from XMTP\",\n\tinputSchema: z.object({\n\t\tmessageId: z.string().describe(\"The message ID to retrieve\")\n\t}),\n\toutputSchema: z.object({\n\t\tsuccess: z.boolean(),\n\t\tmessage: z\n\t\t\t.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tconversationId: z.string(),\n\t\t\t\tcontent: z\n\t\t\t\t\t.union([z.string(), z.record(z.string(), z.unknown()), z.unknown()])\n\t\t\t\t\t.optional(),\n\t\t\t\tsenderInboxId: z.string(),\n\t\t\t\tsentAt: z.date(),\n\t\t\t\tcontentType: z\n\t\t\t\t\t.object({\n\t\t\t\t\t\ttypeId: z.string(),\n\t\t\t\t\t\tauthorityId: z.string().optional(),\n\t\t\t\t\t\tversionMajor: z.number().optional(),\n\t\t\t\t\t\tversionMinor: z.number().optional()\n\t\t\t\t\t})\n\t\t\t\t\t.optional()\n\t\t\t})\n\t\t\t.optional(),\n\t\terror: z.string().optional()\n\t}),\n\texecute: async ({ input, runtime }) => {\n\t\tconst startTime = performance.now()\n\t\tlogger.debug(\n\t\t\t`📜 [Tool:getMessage] Starting execution for message: ${input.messageId}`\n\t\t)\n\n\t\ttry {\n\t\t\tconst { xmtpClient, conversation } = runtime\n\t\t\tconst { messageId } = input\n\n\t\t\tif (!xmtpClient) {\n\t\t\t\tconst endTime = performance.now()\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`📜 [Tool:getMessage] Failed - no XMTP client in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t\t)\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: \"XMTP service not available\"\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlogger.debug(`📜 [getMessage] Retrieving message ${messageId}`)\n\n\t\t\tconst sendStartTime = performance.now()\n\t\t\tconst message = await xmtpClient.conversations.getMessageById(messageId)\n\t\t\tconst sendEndTime = performance.now()\n\t\t\tlogger.debug(\n\t\t\t\t`📜 [Tool:getMessage] XMTP client getMessage completed in ${(sendEndTime - sendStartTime).toFixed(2)}ms`\n\t\t\t)\n\n\t\t\tif (!message) {\n\t\t\t\tconst endTime = performance.now()\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`📜 [Tool:getMessage] Failed in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t\t)\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: \"Failed to get message\"\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlogger.debug(\n\t\t\t\t`✅ [getMessage] Retrieved message from ${message.senderInboxId}`\n\t\t\t)\n\n\t\t\tconst endTime = performance.now()\n\t\t\tlogger.debug(\n\t\t\t\t`📜 [Tool:getMessage] Total execution completed in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t)\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tmessage: message\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\tconst endTime = performance.now()\n\t\t\tlogger.error(\n\t\t\t\t`❌ [Tool:getMessage] Error in ${(endTime - startTime).toFixed(2)}ms:`,\n\t\t\t\terrorMessage\n\t\t\t)\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: errorMessage\n\t\t\t}\n\t\t}\n\t}\n})\n\n/**\n * Send Reaction Tool\n *\n * Sends an emoji reaction to a specific message to indicate the message has been seen.\n * This is used to acknowledge receipt of messages before responding.\n *\n * @tool sendReaction\n * @category Communication\n *\n * @param {string} emoji - The emoji to send as a reaction (defaults to 👀)\n * @param {string} [referenceMessageId] - The message ID to react to (uses current message if not provided)\n *\n * @returns {Promise<{success: boolean, emoji: string, error?: string}>}\n */\nexport const sendReactionTool = createTool({\n\tdescription:\n\t\t\"Send an emoji reaction to a message to indicate it has been seen\",\n\tinputSchema: z.object({\n\t\temoji: z\n\t\t\t.string()\n\t\t\t.default(\"👀\")\n\t\t\t.describe(\n\t\t\t\t\"The emoji to send as a reaction (supports common emoji like 👍, ❤️, 🔥, etc.)\"\n\t\t\t),\n\t\treferenceMessageId: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\n\t\t\t\t\"The message ID to react to (uses current message if not provided)\"\n\t\t\t)\n\t}),\n\toutputSchema: z.object({\n\t\tsuccess: z.boolean(),\n\t\temoji: z.string(),\n\t\terror: z.string().optional()\n\t}),\n\texecute: async ({ input, runtime }) => {\n\t\tconst startTime = performance.now()\n\n\t\tlogger.debug(\n\t\t\t`👀 [Tool:sendReaction] Starting execution with emoji: ${input.emoji}`\n\t\t)\n\n\t\ttry {\n\t\t\tconst xmtpClient = runtime.xmtpClient\n\t\t\tconst { referenceMessageId, emoji = \"👀\" } = input\n\t\t\tconst { message, conversation } = runtime\n\n\t\t\tif (!xmtpClient) {\n\t\t\t\tconst endTime = performance.now()\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`👀 [Tool:sendReaction] Failed - no XMTP client in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t\t)\n\t\t\t\tconst errorMsg = \"❌ XMTP service not available\"\n\t\t\t\treturn { success: false, emoji: input.emoji, error: errorMsg }\n\t\t\t}\n\n\t\t\tconst messageIdToReactTo = input.referenceMessageId || runtime.message.id\n\n\t\t\tif (!messageIdToReactTo) {\n\t\t\t\tconst endTime = performance.now()\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`👀 [Tool:sendReaction] Failed - no message ID to react to in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t\t)\n\t\t\t\tconst errorMsg = \"❌ No message ID available for reaction\"\n\t\t\t\treturn { success: false, emoji: input.emoji, error: errorMsg }\n\t\t\t}\n\n\t\t\tlogger.debug(\n\t\t\t\t`👀 [sendReaction] Sending ${input.emoji} reaction to message ${messageIdToReactTo}`\n\t\t\t)\n\n\t\t\tconst sendStartTime = performance.now()\n\n\t\t\tconst reaction = {\n\t\t\t\tschema: \"unicode\",\n\t\t\t\treference: messageIdToReactTo,\n\t\t\t\taction: \"added\",\n\t\t\t\tcontentType: ContentTypeReaction,\n\t\t\t\tcontent: emoji\n\t\t\t}\n\n\t\t\tconst reactionResult = await conversation.send(\n\t\t\t\treaction,\n\t\t\t\tContentTypeReaction\n\t\t\t)\n\n\t\t\tconst sendEndTime = performance.now()\n\t\t\tlogger.debug(\n\t\t\t\t`👀 [Tool:sendReaction] XMTP client sendReaction completed in ${(sendEndTime - sendStartTime).toFixed(2)}ms`\n\t\t\t)\n\n\t\t\tif (!reactionResult) {\n\t\t\t\tconst endTime = performance.now()\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`👀 [Tool:sendReaction] Failed in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t\t)\n\t\t\t\tconst errorMsg = `❌ Failed to send reaction`\n\t\t\t\treturn { success: false, emoji: input.emoji, error: errorMsg }\n\t\t\t}\n\n\t\t\tlogger.debug(\n\t\t\t\t`✅ [sendReaction] Successfully sent ${input.emoji} reaction`\n\t\t\t)\n\n\t\t\tconst endTime = performance.now()\n\t\t\tlogger.debug(\n\t\t\t\t`👀 [Tool:sendReaction] Total execution completed in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t)\n\n\t\t\treturn { success: true, emoji: input.emoji }\n\t\t} catch (error) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\tconst endTime = performance.now()\n\t\t\tlogger.error(\n\t\t\t\t`❌ [Tool:sendReaction] Error in ${(endTime - startTime).toFixed(2)}ms:`,\n\t\t\t\terrorMessage\n\t\t\t)\n\t\t\treturn { success: false, emoji: input.emoji, error: errorMessage }\n\t\t}\n\t}\n})\n\n/**\n * Send Message Tool\n *\n * Sends a message to an XMTP conversation or creates a new conversation.\n *\n * @tool sendMessage\n * @category Communication\n *\n * @param {string} content - The message content to send\n * @param {string} [recipientAddress] - Recipient address for new conversations\n * @param {string} [conversationId] - Existing conversation ID to send to\n *\n * @returns {Promise<{success: boolean, messageId?: string, conversationId?: string, error?: string}>}\n */\nexport const sendMessageTool = createTool({\n\tdescription: \"Send a message to an XMTP conversation\",\n\tinputSchema: z\n\t\t.object({\n\t\t\tcontent: z.string().describe(\"The message content to send\"),\n\t\t\trecipientAddress: z\n\t\t\t\t.string()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Recipient address for new conversations\"),\n\t\t\tconversationId: z\n\t\t\t\t.string()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Existing conversation ID to send to\")\n\t\t})\n\t\t.refine((data) => data.recipientAddress || data.conversationId, {\n\t\t\tmessage: \"Either recipientAddress or conversationId must be provided\"\n\t\t}),\n\toutputSchema: z.object({\n\t\tsuccess: z.boolean(),\n\t\tmessageId: z.string().optional(),\n\t\tconversationId: z.string().optional(),\n\t\tcontent: z.string(),\n\t\terror: z.string().optional()\n\t}),\n\texecute: async ({ input, runtime }) => {\n\t\tconst startTime = performance.now()\n\t\tlogger.debug(\n\t\t\t`💬 [Tool:sendMessage] Starting execution with content: \"${input.content.substring(0, 50)}${input.content.length > 50 ? \"...\" : \"\"}\"`\n\t\t)\n\n\t\ttry {\n\t\t\tconst xmtpClient = runtime.xmtpClient\n\t\t\tconst { content, recipientAddress, conversationId } = input\n\t\t\tconst { conversation } = runtime\n\n\t\t\tif (!xmtpClient) {\n\t\t\t\tconst endTime = performance.now()\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`💬 [Tool:sendMessage] Failed - no XMTP client in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t\t)\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tcontent,\n\t\t\t\t\terror: \"XMTP service not available\"\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlogger.debug(\n\t\t\t\t`💬 [sendMessage] Sending message: \"${content.substring(0, 50)}${content.length > 50 ? \"...\" : \"\"}\"`\n\t\t\t)\n\n\t\t\tlet targetConversationId = conversationId\n\n\t\t\t// If no conversation ID provided, create or find conversation with recipient\n\t\t\tif (!targetConversationId && recipientAddress) {\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`🔍 [sendMessage] Creating/finding conversation with ${recipientAddress}`\n\t\t\t\t)\n\t\t\t\t// This would depend on your XMTP client implementation\n\t\t\t\t// For now, we'll assume the client handles conversation creation\n\t\t\t\ttargetConversationId = recipientAddress // Simplified for this example\n\t\t\t}\n\n\t\t\t// Send the message using the XMTP client\n\t\t\tconst sendStartTime = performance.now()\n\t\t\tconst messageId = await conversation.send(content, ContentTypeText)\n\t\t\tconst sendEndTime = performance.now()\n\t\t\tlogger.debug(\n\t\t\t\t`💬 [Tool:sendMessage] XMTP client sendMessage completed in ${(sendEndTime - sendStartTime).toFixed(2)}ms`\n\t\t\t)\n\n\t\t\tif (!messageId) {\n\t\t\t\tconst endTime = performance.now()\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`💬 [Tool:sendMessage] Failed in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t\t)\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tcontent,\n\t\t\t\t\terror: \"Failed to send message\"\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlogger.debug(`✅ [sendMessage] Message sent successfully`)\n\n\t\t\tconst endTime = performance.now()\n\t\t\tlogger.debug(\n\t\t\t\t`💬 [Tool:sendMessage] Total execution completed in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t)\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tmessageId,\n\t\t\t\tconversationId: conversation.id,\n\t\t\t\tcontent\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\tconst endTime = performance.now()\n\t\t\tlogger.error(\n\t\t\t\t`❌ [Tool:sendMessage] Error in ${(endTime - startTime).toFixed(2)}ms:`,\n\t\t\t\terrorMessage\n\t\t\t)\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tcontent: input.content,\n\t\t\t\terror: errorMessage\n\t\t\t}\n\t\t}\n\t}\n})\n\n/**\n * Send Reply Tool\n *\n * Sends a reply to a specific message in an XMTP conversation.\n *\n * @tool sendReply\n * @category Communication\n *\n * @param {string} content - The reply content to send\n * @param {string} [replyToMessageId] - Message ID to reply to (uses current message if not provided)\n *\n * @returns {Promise<{success: boolean, messageId?: string, replyToMessageId?: string, error?: string}>}\n */\nexport const sendReplyTool = createTool({\n\tdescription: \"Send a reply to a specific message in an XMTP conversation\",\n\tinputSchema: z.object({\n\t\tcontent: z.string().describe(\"The reply content to send\"),\n\t\treplyToMessageId: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\"Message ID to reply to (uses current message if not provided)\")\n\t}),\n\toutputSchema: z.object({\n\t\tsuccess: z.boolean(),\n\t\tmessageId: z.string().optional(),\n\t\treplyToMessageId: z.string().optional(),\n\t\tcontent: z.string(),\n\t\terror: z.string().optional()\n\t}),\n\texecute: async ({ input, runtime }) => {\n\t\tconst startTime = performance.now()\n\t\tlogger.debug(\n\t\t\t`↩️ [Tool:sendReply] Starting execution with content: \"${input.content.substring(0, 50)}${input.content.length > 50 ? \"...\" : \"\"}\"`\n\t\t)\n\n\t\ttry {\n\t\t\tconst { xmtpClient, conversation } = runtime\n\t\t\tconst { content, replyToMessageId } = input\n\n\t\t\tif (!xmtpClient) {\n\t\t\t\tconst endTime = performance.now()\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`↩️ [Tool:sendReply] Failed - no XMTP client in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t\t)\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tcontent,\n\t\t\t\t\treplyToMessageId: replyToMessageId || \"\",\n\t\t\t\t\terror: \"XMTP service not available\"\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!replyToMessageId) {\n\t\t\t\tconst endTime = performance.now()\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`↩️ [Tool:sendReply] Failed - no message to reply to in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t\t)\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tcontent,\n\t\t\t\t\treplyToMessageId: \"\",\n\t\t\t\t\terror: \"No message to reply to\"\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst targetMessageId = replyToMessageId //|| currentMessage?.id\n\n\t\t\tlogger.debug(\n\t\t\t\t`↩️ [sendReply] Sending reply to message ${targetMessageId}: \"${content.substring(0, 50)}${content.length > 50 ? \"...\" : \"\"}\"`\n\t\t\t)\n\n\t\t\tconst reply: Reply = {\n\t\t\t\treference: replyToMessageId,\n\t\t\t\tcontentType: ContentTypeText,\n\t\t\t\tcontent\n\t\t\t}\n\n\t\t\tconst sendStartTime = performance.now()\n\t\t\tconst replyMessageId = await conversation.send(reply, ContentTypeReply)\n\t\t\tconst sendEndTime = performance.now()\n\t\t\tlogger.debug(\n\t\t\t\t`↩️ [Tool:sendReply] XMTP client sendReply completed in ${(sendEndTime - sendStartTime).toFixed(2)}ms`\n\t\t\t)\n\n\t\t\tif (!replyMessageId) {\n\t\t\t\tconst endTime = performance.now()\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`↩️ [Tool:sendReply] Failed in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t\t)\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tcontent,\n\t\t\t\t\tmessageId: replyMessageId,\n\t\t\t\t\treplyToMessageId: targetMessageId,\n\t\t\t\t\terror: \"Failed to send reply\"\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlogger.debug(`✅ [sendReply] Reply sent successfully`)\n\n\t\t\tconst endTime = performance.now()\n\t\t\tlogger.debug(\n\t\t\t\t`↩️ [Tool:sendReply] Total execution completed in ${(endTime - startTime).toFixed(2)}ms`\n\t\t\t)\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tmessageId: replyMessageId,\n\t\t\t\treplyToMessageId: targetMessageId,\n\t\t\t\tcontent\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\tconst endTime = performance.now()\n\t\t\tlogger.error(\n\t\t\t\t`❌ [Tool:sendReply] Error in ${(endTime - startTime).toFixed(2)}ms:`,\n\t\t\t\terrorMessage\n\t\t\t)\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tcontent: input.content,\n\t\t\t\treplyToMessageId: input.replyToMessageId || \"\",\n\t\t\t\tmessageId: \"\",\n\t\t\t\terror: errorMessage\n\t\t\t}\n\t\t}\n\t}\n})\n\n/**\n * Collection of XMTP communication tools for crypto agents\n *\n * These tools provide comprehensive messaging capabilities including sending messages,\n * replies, reactions, and retrieving message information.\n *\n * @namespace xmtpTools\n *\n * @property {Tool} sendMessage - Send a message to an XMTP conversation\n * @property {Tool} sendReply - Send a reply to a specific message\n * @property {Tool} sendReaction - Send an emoji reaction to a message\n * @property {Tool} getMessage - Get a specific message by ID\n */\nexport const xmtpTools = {\n\tgetMessage: getMessageTool,\n\tsendMessage: sendMessageTool,\n\tsendReply: sendReplyTool,\n\tsendReaction: sendReactionTool\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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S;AAAA,QACT,SAAS,MAAM;AAAA,QACf,kBAAkB,MAAM,oBAAoB;AAAA,QAC5C,WAAW;AAAA,QACX,OAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD;AACD,CAAC;AAeM,IAAM,YAAY;AAAA,EACxB,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,WAAW;AAAA,EACX,cAAc;AACf;","names":["import_utils","import_utils","import_utils","import_utils","import_utils","import_xmtp","import_zod","endTime"]}