@hashgraphonline/standards-agent-kit 0.0.18 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (430) hide show
  1. package/README.md +83 -0
  2. package/dist/_virtual/_commonjsHelpers.js +7 -0
  3. package/dist/_virtual/_commonjsHelpers.js.map +1 -0
  4. package/dist/_virtual/index.js +8 -0
  5. package/dist/_virtual/index.js.map +1 -0
  6. package/dist/_virtual/index10.js +5 -0
  7. package/dist/_virtual/index10.js.map +1 -0
  8. package/dist/_virtual/index11.js +5 -0
  9. package/dist/_virtual/index11.js.map +1 -0
  10. package/dist/_virtual/index12.js +8 -0
  11. package/dist/_virtual/index12.js.map +1 -0
  12. package/dist/_virtual/index13.js +5 -0
  13. package/dist/_virtual/index13.js.map +1 -0
  14. package/dist/_virtual/index14.js +5 -0
  15. package/dist/_virtual/index14.js.map +1 -0
  16. package/dist/_virtual/index2.js +3 -0
  17. package/dist/_virtual/index2.js.map +1 -0
  18. package/dist/_virtual/index3.js +8 -0
  19. package/dist/_virtual/index3.js.map +1 -0
  20. package/dist/_virtual/index4.js +8 -0
  21. package/dist/_virtual/index4.js.map +1 -0
  22. package/dist/_virtual/index5.js +6 -0
  23. package/dist/_virtual/index5.js.map +1 -0
  24. package/dist/_virtual/index6.js +8 -0
  25. package/dist/_virtual/index6.js.map +1 -0
  26. package/dist/_virtual/index7.js +5 -0
  27. package/dist/_virtual/index7.js.map +1 -0
  28. package/dist/_virtual/index8.js +5 -0
  29. package/dist/_virtual/index8.js.map +1 -0
  30. package/dist/_virtual/index9.js +5 -0
  31. package/dist/_virtual/index9.js.map +1 -0
  32. package/dist/_virtual/lower-bound.js +5 -0
  33. package/dist/_virtual/lower-bound.js.map +1 -0
  34. package/dist/_virtual/priority-queue.js +5 -0
  35. package/dist/_virtual/priority-queue.js.map +1 -0
  36. package/dist/_virtual/re.js +5 -0
  37. package/dist/_virtual/re.js.map +1 -0
  38. package/dist/_virtual/retry.js +5 -0
  39. package/dist/_virtual/retry.js.map +1 -0
  40. package/dist/agents/index.d.ts +0 -0
  41. package/dist/hcs10/HCS10Client.d.ts +117 -0
  42. package/dist/hcs10/HCS10Client.js +251 -0
  43. package/dist/hcs10/HCS10Client.js.map +1 -0
  44. package/dist/hcs10/index.d.ts +1 -0
  45. package/dist/hcs10/types.d.ts +35 -0
  46. package/dist/index.d.ts +5 -2
  47. package/dist/index.es.js +9747 -11699
  48. package/dist/index.es.js.map +1 -1
  49. package/dist/index.js +44 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/init.d.ts +59 -0
  52. package/dist/init.js +92 -0
  53. package/dist/init.js.map +1 -0
  54. package/dist/node_modules/@langchain/core/dist/callbacks/base.js +98 -0
  55. package/dist/node_modules/@langchain/core/dist/callbacks/base.js.map +1 -0
  56. package/dist/node_modules/@langchain/core/dist/callbacks/manager.js +419 -0
  57. package/dist/node_modules/@langchain/core/dist/callbacks/manager.js.map +1 -0
  58. package/dist/node_modules/@langchain/core/dist/callbacks/promises.js +16 -0
  59. package/dist/node_modules/@langchain/core/dist/callbacks/promises.js.map +1 -0
  60. package/dist/node_modules/@langchain/core/dist/language_models/base.js +42 -0
  61. package/dist/node_modules/@langchain/core/dist/language_models/base.js.map +1 -0
  62. package/dist/node_modules/@langchain/core/dist/load/map_keys.js +16 -0
  63. package/dist/node_modules/@langchain/core/dist/load/map_keys.js.map +1 -0
  64. package/dist/node_modules/@langchain/core/dist/load/serializable.js +121 -0
  65. package/dist/node_modules/@langchain/core/dist/load/serializable.js.map +1 -0
  66. package/dist/node_modules/@langchain/core/dist/messages/ai.js +95 -0
  67. package/dist/node_modules/@langchain/core/dist/messages/ai.js.map +1 -0
  68. package/dist/node_modules/@langchain/core/dist/messages/base.js +112 -0
  69. package/dist/node_modules/@langchain/core/dist/messages/base.js.map +1 -0
  70. package/dist/node_modules/@langchain/core/dist/messages/utils.js +30 -0
  71. package/dist/node_modules/@langchain/core/dist/messages/utils.js.map +1 -0
  72. package/dist/node_modules/@langchain/core/dist/runnables/base.js +1277 -0
  73. package/dist/node_modules/@langchain/core/dist/runnables/base.js.map +1 -0
  74. package/dist/node_modules/@langchain/core/dist/runnables/config.js +83 -0
  75. package/dist/node_modules/@langchain/core/dist/runnables/config.js.map +1 -0
  76. package/dist/node_modules/@langchain/core/dist/runnables/graph.js +106 -0
  77. package/dist/node_modules/@langchain/core/dist/runnables/graph.js.map +1 -0
  78. package/dist/node_modules/@langchain/core/dist/runnables/iter.js +33 -0
  79. package/dist/node_modules/@langchain/core/dist/runnables/iter.js.map +1 -0
  80. package/dist/node_modules/@langchain/core/dist/runnables/utils.js +54 -0
  81. package/dist/node_modules/@langchain/core/dist/runnables/utils.js.map +1 -0
  82. package/dist/node_modules/@langchain/core/dist/runnables/wrappers.js +20 -0
  83. package/dist/node_modules/@langchain/core/dist/runnables/wrappers.js.map +1 -0
  84. package/dist/node_modules/@langchain/core/dist/singletons/index.js +34 -0
  85. package/dist/node_modules/@langchain/core/dist/singletons/index.js.map +1 -0
  86. package/dist/node_modules/@langchain/core/dist/tools.js +69 -0
  87. package/dist/node_modules/@langchain/core/dist/tools.js.map +1 -0
  88. package/dist/node_modules/@langchain/core/dist/tracers/base.js +299 -0
  89. package/dist/node_modules/@langchain/core/dist/tracers/base.js.map +1 -0
  90. package/dist/node_modules/@langchain/core/dist/tracers/console.js +193 -0
  91. package/dist/node_modules/@langchain/core/dist/tracers/console.js.map +1 -0
  92. package/dist/node_modules/@langchain/core/dist/tracers/initialize.js +10 -0
  93. package/dist/node_modules/@langchain/core/dist/tracers/initialize.js.map +1 -0
  94. package/dist/node_modules/@langchain/core/dist/tracers/log_stream.js +284 -0
  95. package/dist/node_modules/@langchain/core/dist/tracers/log_stream.js.map +1 -0
  96. package/dist/node_modules/@langchain/core/dist/tracers/root_listener.js +54 -0
  97. package/dist/node_modules/@langchain/core/dist/tracers/root_listener.js.map +1 -0
  98. package/dist/node_modules/@langchain/core/dist/tracers/tracer_langchain.js +68 -0
  99. package/dist/node_modules/@langchain/core/dist/tracers/tracer_langchain.js.map +1 -0
  100. package/dist/node_modules/@langchain/core/dist/utils/async_caller.js +86 -0
  101. package/dist/node_modules/@langchain/core/dist/utils/async_caller.js.map +1 -0
  102. package/dist/node_modules/@langchain/core/dist/utils/env.js +33 -0
  103. package/dist/node_modules/@langchain/core/dist/utils/env.js.map +1 -0
  104. package/dist/node_modules/@langchain/core/dist/utils/fast-json-patch/core.js +218 -0
  105. package/dist/node_modules/@langchain/core/dist/utils/fast-json-patch/core.js.map +1 -0
  106. package/dist/node_modules/@langchain/core/dist/utils/fast-json-patch/helpers.js +117 -0
  107. package/dist/node_modules/@langchain/core/dist/utils/fast-json-patch/helpers.js.map +1 -0
  108. package/dist/node_modules/@langchain/core/dist/utils/json.js +40 -0
  109. package/dist/node_modules/@langchain/core/dist/utils/json.js.map +1 -0
  110. package/dist/node_modules/@langchain/core/dist/utils/stream.js +164 -0
  111. package/dist/node_modules/@langchain/core/dist/utils/stream.js.map +1 -0
  112. package/dist/node_modules/@langchain/core/node_modules/ansi-styles/index.js +111 -0
  113. package/dist/node_modules/@langchain/core/node_modules/ansi-styles/index.js.map +1 -0
  114. package/dist/node_modules/@langchain/core/node_modules/camelcase/index.js +30 -0
  115. package/dist/node_modules/@langchain/core/node_modules/camelcase/index.js.map +1 -0
  116. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/client.js +2002 -0
  117. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/client.js.map +1 -0
  118. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/index.js +8 -0
  119. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/index.js.map +1 -0
  120. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/singletons/fetch.js +5 -0
  121. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/singletons/fetch.js.map +1 -0
  122. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/utils/_uuid.js +12 -0
  123. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/utils/_uuid.js.map +1 -0
  124. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/utils/async_caller.js +94 -0
  125. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/utils/async_caller.js.map +1 -0
  126. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/utils/env.js +96 -0
  127. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/utils/env.js.map +1 -0
  128. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/utils/error.js +20 -0
  129. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/utils/error.js.map +1 -0
  130. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/utils/fast-safe-stringify/index.js +82 -0
  131. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/utils/fast-safe-stringify/index.js.map +1 -0
  132. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/utils/messages.js +15 -0
  133. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/utils/messages.js.map +1 -0
  134. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/utils/prompts.js +27 -0
  135. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/utils/prompts.js.map +1 -0
  136. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/utils/warn.js +8 -0
  137. package/dist/node_modules/@langchain/core/node_modules/langsmith/dist/utils/warn.js.map +1 -0
  138. package/dist/node_modules/@langchain/core/node_modules/langsmith/node_modules/uuid/dist/esm-browser/native.js +8 -0
  139. package/dist/node_modules/@langchain/core/node_modules/langsmith/node_modules/uuid/dist/esm-browser/native.js.map +1 -0
  140. package/dist/node_modules/@langchain/core/node_modules/langsmith/node_modules/uuid/dist/esm-browser/regex.js +5 -0
  141. package/dist/node_modules/@langchain/core/node_modules/langsmith/node_modules/uuid/dist/esm-browser/regex.js.map +1 -0
  142. package/dist/node_modules/@langchain/core/node_modules/langsmith/node_modules/uuid/dist/esm-browser/rng.js +10 -0
  143. package/dist/node_modules/@langchain/core/node_modules/langsmith/node_modules/uuid/dist/esm-browser/rng.js.map +1 -0
  144. package/dist/node_modules/@langchain/core/node_modules/langsmith/node_modules/uuid/dist/esm-browser/stringify.js +10 -0
  145. package/dist/node_modules/@langchain/core/node_modules/langsmith/node_modules/uuid/dist/esm-browser/stringify.js.map +1 -0
  146. package/dist/node_modules/@langchain/core/node_modules/langsmith/node_modules/uuid/dist/esm-browser/v4.js +14 -0
  147. package/dist/node_modules/@langchain/core/node_modules/langsmith/node_modules/uuid/dist/esm-browser/v4.js.map +1 -0
  148. package/dist/node_modules/@langchain/core/node_modules/langsmith/node_modules/uuid/dist/esm-browser/validate.js +8 -0
  149. package/dist/node_modules/@langchain/core/node_modules/langsmith/node_modules/uuid/dist/esm-browser/validate.js.map +1 -0
  150. package/dist/node_modules/@langchain/core/node_modules/uuid/dist/esm-browser/native.js +7 -0
  151. package/dist/node_modules/@langchain/core/node_modules/uuid/dist/esm-browser/native.js.map +1 -0
  152. package/dist/node_modules/@langchain/core/node_modules/uuid/dist/esm-browser/regex.js +5 -0
  153. package/dist/node_modules/@langchain/core/node_modules/uuid/dist/esm-browser/regex.js.map +1 -0
  154. package/dist/node_modules/@langchain/core/node_modules/uuid/dist/esm-browser/rng.js +11 -0
  155. package/dist/node_modules/@langchain/core/node_modules/uuid/dist/esm-browser/rng.js.map +1 -0
  156. package/dist/node_modules/@langchain/core/node_modules/uuid/dist/esm-browser/stringify.js +10 -0
  157. package/dist/node_modules/@langchain/core/node_modules/uuid/dist/esm-browser/stringify.js.map +1 -0
  158. package/dist/node_modules/@langchain/core/node_modules/uuid/dist/esm-browser/v4.js +14 -0
  159. package/dist/node_modules/@langchain/core/node_modules/uuid/dist/esm-browser/v4.js.map +1 -0
  160. package/dist/node_modules/@langchain/core/node_modules/uuid/dist/esm-browser/validate.js +8 -0
  161. package/dist/node_modules/@langchain/core/node_modules/uuid/dist/esm-browser/validate.js.map +1 -0
  162. package/dist/node_modules/base64-js/index.js +53 -0
  163. package/dist/node_modules/base64-js/index.js.map +1 -0
  164. package/dist/node_modules/decamelize/index.js +12 -0
  165. package/dist/node_modules/decamelize/index.js.map +1 -0
  166. package/dist/node_modules/eventemitter3/index.js +112 -0
  167. package/dist/node_modules/eventemitter3/index.js.map +1 -0
  168. package/dist/node_modules/js-tiktoken/dist/chunk-Z5MDQTGX.js +117 -0
  169. package/dist/node_modules/js-tiktoken/dist/chunk-Z5MDQTGX.js.map +1 -0
  170. package/dist/node_modules/p-finally/index.js +18 -0
  171. package/dist/node_modules/p-finally/index.js.map +1 -0
  172. package/dist/node_modules/p-queue/dist/index.js +198 -0
  173. package/dist/node_modules/p-queue/dist/index.js.map +1 -0
  174. package/dist/node_modules/p-queue/dist/lower-bound.js +20 -0
  175. package/dist/node_modules/p-queue/dist/lower-bound.js.map +1 -0
  176. package/dist/node_modules/p-queue/dist/priority-queue.js +41 -0
  177. package/dist/node_modules/p-queue/dist/priority-queue.js.map +1 -0
  178. package/dist/node_modules/p-retry/index.js +63 -0
  179. package/dist/node_modules/p-retry/index.js.map +1 -0
  180. package/dist/node_modules/p-timeout/index.js +45 -0
  181. package/dist/node_modules/p-timeout/index.js.map +1 -0
  182. package/dist/node_modules/retry/index.js +9 -0
  183. package/dist/node_modules/retry/index.js.map +1 -0
  184. package/dist/node_modules/retry/lib/retry.js +59 -0
  185. package/dist/node_modules/retry/lib/retry.js.map +1 -0
  186. package/dist/node_modules/retry/lib/retry_operation.js +58 -0
  187. package/dist/node_modules/retry/lib/retry_operation.js.map +1 -0
  188. package/dist/node_modules/semver/classes/comparator.js +57 -0
  189. package/dist/node_modules/semver/classes/comparator.js.map +1 -0
  190. package/dist/node_modules/semver/classes/range.js +149 -0
  191. package/dist/node_modules/semver/classes/range.js.map +1 -0
  192. package/dist/node_modules/semver/classes/semver.js +170 -0
  193. package/dist/node_modules/semver/classes/semver.js.map +1 -0
  194. package/dist/node_modules/semver/functions/clean.js +15 -0
  195. package/dist/node_modules/semver/functions/clean.js.map +1 -0
  196. package/dist/node_modules/semver/functions/cmp.js +40 -0
  197. package/dist/node_modules/semver/functions/cmp.js.map +1 -0
  198. package/dist/node_modules/semver/functions/coerce.js +34 -0
  199. package/dist/node_modules/semver/functions/coerce.js.map +1 -0
  200. package/dist/node_modules/semver/functions/compare-build.js +15 -0
  201. package/dist/node_modules/semver/functions/compare-build.js.map +1 -0
  202. package/dist/node_modules/semver/functions/compare-loose.js +12 -0
  203. package/dist/node_modules/semver/functions/compare-loose.js.map +1 -0
  204. package/dist/node_modules/semver/functions/compare.js +12 -0
  205. package/dist/node_modules/semver/functions/compare.js.map +1 -0
  206. package/dist/node_modules/semver/functions/diff.js +25 -0
  207. package/dist/node_modules/semver/functions/diff.js.map +1 -0
  208. package/dist/node_modules/semver/functions/eq.js +12 -0
  209. package/dist/node_modules/semver/functions/eq.js.map +1 -0
  210. package/dist/node_modules/semver/functions/gt.js +12 -0
  211. package/dist/node_modules/semver/functions/gt.js.map +1 -0
  212. package/dist/node_modules/semver/functions/gte.js +12 -0
  213. package/dist/node_modules/semver/functions/gte.js.map +1 -0
  214. package/dist/node_modules/semver/functions/inc.js +22 -0
  215. package/dist/node_modules/semver/functions/inc.js.map +1 -0
  216. package/dist/node_modules/semver/functions/lt.js +12 -0
  217. package/dist/node_modules/semver/functions/lt.js.map +1 -0
  218. package/dist/node_modules/semver/functions/lte.js +12 -0
  219. package/dist/node_modules/semver/functions/lte.js.map +1 -0
  220. package/dist/node_modules/semver/functions/major.js +12 -0
  221. package/dist/node_modules/semver/functions/major.js.map +1 -0
  222. package/dist/node_modules/semver/functions/minor.js +12 -0
  223. package/dist/node_modules/semver/functions/minor.js.map +1 -0
  224. package/dist/node_modules/semver/functions/neq.js +12 -0
  225. package/dist/node_modules/semver/functions/neq.js.map +1 -0
  226. package/dist/node_modules/semver/functions/parse.js +22 -0
  227. package/dist/node_modules/semver/functions/parse.js.map +1 -0
  228. package/dist/node_modules/semver/functions/patch.js +12 -0
  229. package/dist/node_modules/semver/functions/patch.js.map +1 -0
  230. package/dist/node_modules/semver/functions/prerelease.js +15 -0
  231. package/dist/node_modules/semver/functions/prerelease.js.map +1 -0
  232. package/dist/node_modules/semver/functions/rcompare.js +12 -0
  233. package/dist/node_modules/semver/functions/rcompare.js.map +1 -0
  234. package/dist/node_modules/semver/functions/rsort.js +12 -0
  235. package/dist/node_modules/semver/functions/rsort.js.map +1 -0
  236. package/dist/node_modules/semver/functions/satisfies.js +19 -0
  237. package/dist/node_modules/semver/functions/satisfies.js.map +1 -0
  238. package/dist/node_modules/semver/functions/sort.js +12 -0
  239. package/dist/node_modules/semver/functions/sort.js.map +1 -0
  240. package/dist/node_modules/semver/functions/valid.js +15 -0
  241. package/dist/node_modules/semver/functions/valid.js.map +1 -0
  242. package/dist/node_modules/semver/index.js +98 -0
  243. package/dist/node_modules/semver/index.js.map +1 -0
  244. package/dist/node_modules/semver/internal/constants.js +29 -0
  245. package/dist/node_modules/semver/internal/constants.js.map +1 -0
  246. package/dist/node_modules/semver/internal/debug.js +9 -0
  247. package/dist/node_modules/semver/internal/debug.js.map +1 -0
  248. package/dist/node_modules/semver/internal/identifiers.js +17 -0
  249. package/dist/node_modules/semver/internal/identifiers.js.map +1 -0
  250. package/dist/node_modules/semver/internal/lrucache.js +33 -0
  251. package/dist/node_modules/semver/internal/lrucache.js.map +1 -0
  252. package/dist/node_modules/semver/internal/parse-options.js +11 -0
  253. package/dist/node_modules/semver/internal/parse-options.js.map +1 -0
  254. package/dist/node_modules/semver/internal/re.js +33 -0
  255. package/dist/node_modules/semver/internal/re.js.map +1 -0
  256. package/dist/node_modules/semver/ranges/gtr.js +12 -0
  257. package/dist/node_modules/semver/ranges/gtr.js.map +1 -0
  258. package/dist/node_modules/semver/ranges/intersects.js +12 -0
  259. package/dist/node_modules/semver/ranges/intersects.js.map +1 -0
  260. package/dist/node_modules/semver/ranges/ltr.js +12 -0
  261. package/dist/node_modules/semver/ranges/ltr.js.map +1 -0
  262. package/dist/node_modules/semver/ranges/max-satisfying.js +23 -0
  263. package/dist/node_modules/semver/ranges/max-satisfying.js.map +1 -0
  264. package/dist/node_modules/semver/ranges/min-satisfying.js +23 -0
  265. package/dist/node_modules/semver/ranges/min-satisfying.js.map +1 -0
  266. package/dist/node_modules/semver/ranges/min-version.js +43 -0
  267. package/dist/node_modules/semver/ranges/min-version.js.map +1 -0
  268. package/dist/node_modules/semver/ranges/outside.js +45 -0
  269. package/dist/node_modules/semver/ranges/outside.js.map +1 -0
  270. package/dist/node_modules/semver/ranges/simplify.js +25 -0
  271. package/dist/node_modules/semver/ranges/simplify.js.map +1 -0
  272. package/dist/node_modules/semver/ranges/subset.js +95 -0
  273. package/dist/node_modules/semver/ranges/subset.js.map +1 -0
  274. package/dist/node_modules/semver/ranges/to-comparators.js +12 -0
  275. package/dist/node_modules/semver/ranges/to-comparators.js.map +1 -0
  276. package/dist/node_modules/semver/ranges/valid.js +18 -0
  277. package/dist/node_modules/semver/ranges/valid.js.map +1 -0
  278. package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js +32 -0
  279. package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js.map +1 -0
  280. package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js +22 -0
  281. package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js.map +1 -0
  282. package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js +14 -0
  283. package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js.map +1 -0
  284. package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js +44 -0
  285. package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js.map +1 -0
  286. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js +7 -0
  287. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js.map +1 -0
  288. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js +17 -0
  289. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js.map +1 -0
  290. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js +26 -0
  291. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js.map +1 -0
  292. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js +9 -0
  293. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js.map +1 -0
  294. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js +8 -0
  295. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js.map +1 -0
  296. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js +6 -0
  297. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js.map +1 -0
  298. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js +59 -0
  299. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js.map +1 -0
  300. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js +11 -0
  301. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js.map +1 -0
  302. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js +8 -0
  303. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js.map +1 -0
  304. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js +10 -0
  305. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js.map +1 -0
  306. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js +36 -0
  307. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js.map +1 -0
  308. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js +16 -0
  309. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js.map +1 -0
  310. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js +27 -0
  311. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js.map +1 -0
  312. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js +11 -0
  313. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js.map +1 -0
  314. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js +9 -0
  315. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js.map +1 -0
  316. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js +12 -0
  317. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js.map +1 -0
  318. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js +30 -0
  319. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js.map +1 -0
  320. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js +28 -0
  321. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js.map +1 -0
  322. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js +50 -0
  323. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js.map +1 -0
  324. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js +22 -0
  325. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js.map +1 -0
  326. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js +21 -0
  327. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js.map +1 -0
  328. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js +8 -0
  329. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js.map +1 -0
  330. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js +6 -0
  331. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js.map +1 -0
  332. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js +56 -0
  333. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js.map +1 -0
  334. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js +17 -0
  335. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js.map +1 -0
  336. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +245 -0
  337. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js.map +1 -0
  338. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js +27 -0
  339. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js.map +1 -0
  340. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js +9 -0
  341. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js.map +1 -0
  342. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js +69 -0
  343. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js.map +1 -0
  344. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js +7 -0
  345. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js.map +1 -0
  346. package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js +110 -0
  347. package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js.map +1 -0
  348. package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js +26 -0
  349. package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js.map +1 -0
  350. package/dist/plugins/BasePlugin.d.ts +28 -0
  351. package/dist/plugins/BasePlugin.js +19 -0
  352. package/dist/plugins/BasePlugin.js.map +1 -0
  353. package/dist/plugins/PluginInterface.d.ts +64 -0
  354. package/dist/plugins/PluginLoader.d.ts +38 -0
  355. package/dist/plugins/PluginLoader.js +60 -0
  356. package/dist/plugins/PluginLoader.js.map +1 -0
  357. package/dist/plugins/PluginRegistry.d.ts +47 -0
  358. package/dist/plugins/PluginRegistry.js +71 -0
  359. package/dist/plugins/PluginRegistry.js.map +1 -0
  360. package/dist/plugins/__tests__/BasePlugin.test.d.ts +1 -0
  361. package/dist/plugins/__tests__/PluginLoader.test.d.ts +1 -0
  362. package/dist/plugins/__tests__/PluginRegistry.test.d.ts +1 -0
  363. package/dist/plugins/defi/index.d.ts +13 -0
  364. package/dist/plugins/hedera/HbarPricePlugin.d.ts +45 -0
  365. package/dist/plugins/hedera/HbarPricePlugin.js +70 -0
  366. package/dist/plugins/hedera/HbarPricePlugin.js.map +1 -0
  367. package/dist/plugins/hedera/__tests__/HbarPricePlugin.test.d.ts +1 -0
  368. package/dist/plugins/index.d.ts +5 -0
  369. package/dist/plugins/weather/index.d.ts +15 -0
  370. package/dist/src/agents/index.d.ts +0 -0
  371. package/dist/src/plugins/hedera/HbarPricePlugin.d.ts +45 -0
  372. package/dist/src/plugins/index.d.ts +1 -0
  373. package/dist/src/tools/CheckMessagesTool.d.ts +9 -2
  374. package/dist/src/utils/state-tools.d.ts +23 -0
  375. package/dist/state/index.d.ts +2 -0
  376. package/dist/state/open-convai-state.d.ts +84 -0
  377. package/dist/state/open-convai-state.js +132 -0
  378. package/dist/state/open-convai-state.js.map +1 -0
  379. package/dist/state/state-types.d.ts +143 -0
  380. package/dist/tools/AcceptConnectionRequestTool.d.ts +33 -0
  381. package/dist/tools/AcceptConnectionRequestTool.js +116 -0
  382. package/dist/tools/AcceptConnectionRequestTool.js.map +1 -0
  383. package/dist/tools/CheckMessagesTool.d.ts +34 -0
  384. package/dist/tools/CheckMessagesTool.js +96 -0
  385. package/dist/tools/CheckMessagesTool.js.map +1 -0
  386. package/dist/tools/ConnectionMonitorTool.d.ts +96 -0
  387. package/dist/tools/ConnectionMonitorTool.js +289 -0
  388. package/dist/tools/ConnectionMonitorTool.js.map +1 -0
  389. package/dist/tools/ConnectionTool.d.ts +40 -0
  390. package/dist/tools/ConnectionTool.js +114 -0
  391. package/dist/tools/ConnectionTool.js.map +1 -0
  392. package/dist/tools/FindRegistrationsTool.d.ts +27 -0
  393. package/dist/tools/FindRegistrationsTool.js +64 -0
  394. package/dist/tools/FindRegistrationsTool.js.map +1 -0
  395. package/dist/tools/InitiateConnectionTool.d.ts +30 -0
  396. package/dist/tools/InitiateConnectionTool.js +79 -0
  397. package/dist/tools/InitiateConnectionTool.js.map +1 -0
  398. package/dist/tools/ListConnectionsTool.d.ts +33 -0
  399. package/dist/tools/ListConnectionsTool.js +327 -0
  400. package/dist/tools/ListConnectionsTool.js.map +1 -0
  401. package/dist/tools/ListUnapprovedConnectionRequestsTool.d.ts +53 -0
  402. package/dist/tools/ListUnapprovedConnectionRequestsTool.js +177 -0
  403. package/dist/tools/ListUnapprovedConnectionRequestsTool.js.map +1 -0
  404. package/dist/tools/ManageConnectionRequestsTool.d.ts +39 -0
  405. package/dist/tools/ManageConnectionRequestsTool.js +161 -0
  406. package/dist/tools/ManageConnectionRequestsTool.js.map +1 -0
  407. package/dist/tools/RegisterAgentTool.d.ts +188 -0
  408. package/dist/tools/RegisterAgentTool.js +331 -0
  409. package/dist/tools/RegisterAgentTool.js.map +1 -0
  410. package/dist/tools/RetrieveProfileTool.d.ts +34 -0
  411. package/dist/tools/RetrieveProfileTool.js +53 -0
  412. package/dist/tools/RetrieveProfileTool.js.map +1 -0
  413. package/dist/tools/SendMessageToConnectionTool.d.ts +31 -0
  414. package/dist/tools/SendMessageToConnectionTool.js +74 -0
  415. package/dist/tools/SendMessageToConnectionTool.js.map +1 -0
  416. package/dist/tools/SendMessageTool.d.ts +44 -0
  417. package/dist/tools/SendMessageTool.js +75 -0
  418. package/dist/tools/SendMessageTool.js.map +1 -0
  419. package/dist/tools/index.d.ts +13 -0
  420. package/dist/utils/Encryption.d.ts +7 -0
  421. package/dist/utils/Encryption.js +7 -0
  422. package/dist/utils/Encryption.js.map +1 -0
  423. package/dist/utils/HederaClient.d.ts +18 -0
  424. package/dist/utils/connectionUtils.d.ts +15 -0
  425. package/dist/utils/connectionUtils.js +64 -0
  426. package/dist/utils/connectionUtils.js.map +1 -0
  427. package/dist/utils/state-tools.d.ts +23 -0
  428. package/dist/utils/state-tools.js +90 -0
  429. package/dist/utils/state-tools.js.map +1 -0
  430. package/package.json +20 -10
@@ -0,0 +1,84 @@
1
+ import { RegisteredAgent, ActiveConnection, ConnectionRequestInfo, IStateManager, AgentPersistenceOptions } from './state-types';
2
+ /**
3
+ * Implementation of the IStateManager interface for the OpenConvai system.
4
+ * Manages agent state and connection information with thread safety and
5
+ * proper timestamp tracking.
6
+ */
7
+ export declare class OpenConvaiState implements IStateManager {
8
+ private currentAgent;
9
+ private activeConnections;
10
+ private connectionMessageTimestamps;
11
+ private connectionRequests;
12
+ private defaultEnvFilePath?;
13
+ private defaultPrefix;
14
+ /**
15
+ * Creates a new OpenConvaiState instance
16
+ * @param options - Options for environment variable persistence
17
+ */
18
+ constructor(options?: {
19
+ defaultEnvFilePath?: string;
20
+ defaultPrefix?: string;
21
+ });
22
+ /**
23
+ * Sets the current active agent and clears any previous connection data.
24
+ * This should be called when switching between agents.
25
+ */
26
+ setCurrentAgent(agent: RegisteredAgent | null): void;
27
+ /**
28
+ * Returns the currently active agent or null if none is set.
29
+ */
30
+ getCurrentAgent(): RegisteredAgent | null;
31
+ /**
32
+ * Adds a new connection to the active connections list.
33
+ * Ensures no duplicates are added based on connectionTopicId.
34
+ * Initializes timestamp tracking for the connection.
35
+ */
36
+ addActiveConnection(connection: ActiveConnection): void;
37
+ /**
38
+ * Updates an existing connection or adds it if not found.
39
+ * Preserves existing properties when updating by merging objects.
40
+ */
41
+ updateOrAddConnection(connection: ActiveConnection): void;
42
+ /**
43
+ * Returns a copy of all active connections.
44
+ */
45
+ listConnections(): ActiveConnection[];
46
+ /**
47
+ * Finds a connection by its identifier, which can be:
48
+ * - A 1-based index as displayed in the connection list
49
+ * - A target account ID string
50
+ * - A connection topic ID string
51
+ */
52
+ getConnectionByIdentifier(identifier: string): ActiveConnection | undefined;
53
+ /**
54
+ * Gets the last processed message timestamp for a connection.
55
+ * Returns 0 if no timestamp has been recorded.
56
+ */
57
+ getLastTimestamp(connectionTopicId: string): number;
58
+ /**
59
+ * Updates the last processed message timestamp for a connection,
60
+ * but only if the new timestamp is more recent than the existing one.
61
+ */
62
+ updateTimestamp(connectionTopicId: string, timestampNanos: number): void;
63
+ /**
64
+ * Helper method to find a connection's index by its topic ID.
65
+ * Returns -1 if not found.
66
+ */
67
+ private findConnectionIndex;
68
+ /**
69
+ * Helper method to initialize timestamp tracking for a connection
70
+ * if it doesn't already exist.
71
+ */
72
+ private initializeTimestampIfNeeded;
73
+ addConnectionRequest(request: ConnectionRequestInfo): void;
74
+ listConnectionRequests(): ConnectionRequestInfo[];
75
+ getConnectionRequestById(requestId: number): ConnectionRequestInfo | undefined;
76
+ removeConnectionRequest(requestId: number): void;
77
+ clearConnectionRequests(): void;
78
+ /**
79
+ * Persists agent data to environment variables
80
+ * @param agent - The agent data to persist
81
+ * @param options - Environment file persistence options
82
+ */
83
+ persistAgentData(agent: RegisteredAgent, options?: AgentPersistenceOptions): Promise<void>;
84
+ }
@@ -0,0 +1,132 @@
1
+ import { updateEnvFile as c } from "../utils/state-tools.js";
2
+ class o {
3
+ /**
4
+ * Creates a new OpenConvaiState instance
5
+ * @param options - Options for environment variable persistence
6
+ */
7
+ constructor(e) {
8
+ this.currentAgent = null, this.activeConnections = [], this.connectionMessageTimestamps = {}, this.connectionRequests = /* @__PURE__ */ new Map(), this.defaultEnvFilePath = e == null ? void 0 : e.defaultEnvFilePath, this.defaultPrefix = (e == null ? void 0 : e.defaultPrefix) ?? "TODD";
9
+ }
10
+ /**
11
+ * Sets the current active agent and clears any previous connection data.
12
+ * This should be called when switching between agents.
13
+ */
14
+ setCurrentAgent(e) {
15
+ this.currentAgent = e, this.activeConnections = [], this.connectionMessageTimestamps = {}, this.connectionRequests.clear();
16
+ }
17
+ /**
18
+ * Returns the currently active agent or null if none is set.
19
+ */
20
+ getCurrentAgent() {
21
+ return this.currentAgent;
22
+ }
23
+ /**
24
+ * Adds a new connection to the active connections list.
25
+ * Ensures no duplicates are added based on connectionTopicId.
26
+ * Initializes timestamp tracking for the connection.
27
+ */
28
+ addActiveConnection(e) {
29
+ this.findConnectionIndex(e.connectionTopicId) === -1 && (this.activeConnections.push({ ...e }), this.initializeTimestampIfNeeded(e.connectionTopicId));
30
+ }
31
+ /**
32
+ * Updates an existing connection or adds it if not found.
33
+ * Preserves existing properties when updating by merging objects.
34
+ */
35
+ updateOrAddConnection(e) {
36
+ const t = this.findConnectionIndex(e.connectionTopicId);
37
+ t !== -1 ? this.activeConnections[t] = {
38
+ ...this.activeConnections[t],
39
+ ...e
40
+ } : this.addActiveConnection(e), this.initializeTimestampIfNeeded(e.connectionTopicId);
41
+ }
42
+ /**
43
+ * Returns a copy of all active connections.
44
+ */
45
+ listConnections() {
46
+ return [...this.activeConnections];
47
+ }
48
+ /**
49
+ * Finds a connection by its identifier, which can be:
50
+ * - A 1-based index as displayed in the connection list
51
+ * - A target account ID string
52
+ * - A connection topic ID string
53
+ */
54
+ getConnectionByIdentifier(e) {
55
+ const t = parseInt(e) - 1;
56
+ return !isNaN(t) && t >= 0 && t < this.activeConnections.length ? this.activeConnections[t] : this.activeConnections.find(
57
+ (n) => n.targetAccountId === e || n.connectionTopicId === e
58
+ );
59
+ }
60
+ /**
61
+ * Gets the last processed message timestamp for a connection.
62
+ * Returns 0 if no timestamp has been recorded.
63
+ */
64
+ getLastTimestamp(e) {
65
+ return this.connectionMessageTimestamps[e] || 0;
66
+ }
67
+ /**
68
+ * Updates the last processed message timestamp for a connection,
69
+ * but only if the new timestamp is more recent than the existing one.
70
+ */
71
+ updateTimestamp(e, t) {
72
+ if (e in this.connectionMessageTimestamps) {
73
+ const n = this.connectionMessageTimestamps[e];
74
+ t > n && (this.connectionMessageTimestamps[e] = t);
75
+ }
76
+ }
77
+ /**
78
+ * Helper method to find a connection's index by its topic ID.
79
+ * Returns -1 if not found.
80
+ */
81
+ findConnectionIndex(e) {
82
+ return this.activeConnections.findIndex(
83
+ (t) => t.connectionTopicId === e
84
+ );
85
+ }
86
+ /**
87
+ * Helper method to initialize timestamp tracking for a connection
88
+ * if it doesn't already exist.
89
+ */
90
+ initializeTimestampIfNeeded(e) {
91
+ e in this.connectionMessageTimestamps || (this.connectionMessageTimestamps[e] = Date.now() * 1e6);
92
+ }
93
+ addConnectionRequest(e) {
94
+ this.connectionRequests.set(e.id, { ...e });
95
+ }
96
+ listConnectionRequests() {
97
+ return Array.from(this.connectionRequests.values());
98
+ }
99
+ getConnectionRequestById(e) {
100
+ return this.connectionRequests.get(e);
101
+ }
102
+ removeConnectionRequest(e) {
103
+ this.connectionRequests.delete(e);
104
+ }
105
+ clearConnectionRequests() {
106
+ this.connectionRequests.clear();
107
+ }
108
+ /**
109
+ * Persists agent data to environment variables
110
+ * @param agent - The agent data to persist
111
+ * @param options - Environment file persistence options
112
+ */
113
+ async persistAgentData(e, t) {
114
+ if (t != null && t.type && t.type !== "env-file")
115
+ throw new Error(
116
+ `Unsupported persistence type: ${t.type}. Only 'env-file' is supported.`
117
+ );
118
+ const n = (t == null ? void 0 : t.envFilePath) || this.defaultEnvFilePath || process.env.ENV_FILE_PATH || ".env", i = (t == null ? void 0 : t.prefix) || this.defaultPrefix;
119
+ if (!e.accountId || !e.inboundTopicId || !e.outboundTopicId)
120
+ throw new Error("Agent data incomplete, cannot persist to environment");
121
+ const s = {
122
+ [`${i}_ACCOUNT_ID`]: e.accountId,
123
+ [`${i}_INBOUND_TOPIC_ID`]: e.inboundTopicId,
124
+ [`${i}_OUTBOUND_TOPIC_ID`]: e.outboundTopicId
125
+ };
126
+ e.privateKey && (s[`${i}_PRIVATE_KEY`] = e.privateKey), e.profileTopicId && (s[`${i}_PROFILE_TOPIC_ID`] = e.profileTopicId), await c(n, s);
127
+ }
128
+ }
129
+ export {
130
+ o as OpenConvaiState
131
+ };
132
+ //# sourceMappingURL=open-convai-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-convai-state.js","sources":["../../src/state/open-convai-state.ts"],"sourcesContent":["import { updateEnvFile } from '../utils/state-tools';\nimport {\n RegisteredAgent,\n ActiveConnection,\n ConnectionRequestInfo,\n IStateManager,\n AgentPersistenceOptions,\n EnvFilePersistenceOptions,\n} from './state-types';\n\n/**\n * Implementation of the IStateManager interface for the OpenConvai system.\n * Manages agent state and connection information with thread safety and\n * proper timestamp tracking.\n */\nexport class OpenConvaiState implements IStateManager {\n private currentAgent: RegisteredAgent | null = null;\n private activeConnections: ActiveConnection[] = [];\n private connectionMessageTimestamps: Record<string, number> = {};\n private connectionRequests: Map<number, ConnectionRequestInfo> = new Map();\n private defaultEnvFilePath?: string;\n private defaultPrefix: string;\n\n /**\n * Creates a new OpenConvaiState instance\n * @param options - Options for environment variable persistence\n */\n constructor(options?: {\n defaultEnvFilePath?: string;\n defaultPrefix?: string;\n }) {\n this.defaultEnvFilePath = options?.defaultEnvFilePath;\n this.defaultPrefix = options?.defaultPrefix ?? 'TODD';\n }\n\n /**\n * Sets the current active agent and clears any previous connection data.\n * This should be called when switching between agents.\n */\n setCurrentAgent(agent: RegisteredAgent | null): void {\n this.currentAgent = agent;\n this.activeConnections = [];\n this.connectionMessageTimestamps = {};\n this.connectionRequests.clear();\n }\n\n /**\n * Returns the currently active agent or null if none is set.\n */\n getCurrentAgent(): RegisteredAgent | null {\n return this.currentAgent;\n }\n\n /**\n * Adds a new connection to the active connections list.\n * Ensures no duplicates are added based on connectionTopicId.\n * Initializes timestamp tracking for the connection.\n */\n addActiveConnection(connection: ActiveConnection): void {\n if (this.findConnectionIndex(connection.connectionTopicId) !== -1) {\n return;\n }\n\n this.activeConnections.push({ ...connection });\n\n this.initializeTimestampIfNeeded(connection.connectionTopicId);\n }\n\n /**\n * Updates an existing connection or adds it if not found.\n * Preserves existing properties when updating by merging objects.\n */\n updateOrAddConnection(connection: ActiveConnection): void {\n const index = this.findConnectionIndex(connection.connectionTopicId);\n\n if (index !== -1) {\n this.activeConnections[index] = {\n ...this.activeConnections[index],\n ...connection,\n };\n } else {\n this.addActiveConnection(connection);\n }\n\n this.initializeTimestampIfNeeded(connection.connectionTopicId);\n }\n\n /**\n * Returns a copy of all active connections.\n */\n listConnections(): ActiveConnection[] {\n return [...this.activeConnections];\n }\n\n /**\n * Finds a connection by its identifier, which can be:\n * - A 1-based index as displayed in the connection list\n * - A target account ID string\n * - A connection topic ID string\n */\n getConnectionByIdentifier(identifier: string): ActiveConnection | undefined {\n const numericIndex = parseInt(identifier) - 1;\n if (\n !isNaN(numericIndex) &&\n numericIndex >= 0 &&\n numericIndex < this.activeConnections.length\n ) {\n return this.activeConnections[numericIndex];\n }\n\n return this.activeConnections.find(\n (conn) =>\n conn.targetAccountId === identifier ||\n conn.connectionTopicId === identifier\n );\n }\n\n /**\n * Gets the last processed message timestamp for a connection.\n * Returns 0 if no timestamp has been recorded.\n */\n getLastTimestamp(connectionTopicId: string): number {\n return this.connectionMessageTimestamps[connectionTopicId] || 0;\n }\n\n /**\n * Updates the last processed message timestamp for a connection,\n * but only if the new timestamp is more recent than the existing one.\n */\n updateTimestamp(connectionTopicId: string, timestampNanos: number): void {\n if (connectionTopicId in this.connectionMessageTimestamps) {\n const currentTimestamp =\n this.connectionMessageTimestamps[connectionTopicId];\n if (timestampNanos > currentTimestamp) {\n this.connectionMessageTimestamps[connectionTopicId] = timestampNanos;\n }\n }\n }\n\n /**\n * Helper method to find a connection's index by its topic ID.\n * Returns -1 if not found.\n */\n private findConnectionIndex(connectionTopicId: string): number {\n return this.activeConnections.findIndex(\n (conn) => conn.connectionTopicId === connectionTopicId\n );\n }\n\n /**\n * Helper method to initialize timestamp tracking for a connection\n * if it doesn't already exist.\n */\n private initializeTimestampIfNeeded(connectionTopicId: string): void {\n if (!(connectionTopicId in this.connectionMessageTimestamps)) {\n this.connectionMessageTimestamps[connectionTopicId] =\n Date.now() * 1_000_000;\n }\n }\n\n addConnectionRequest(request: ConnectionRequestInfo): void {\n this.connectionRequests.set(request.id, { ...request });\n }\n\n listConnectionRequests(): ConnectionRequestInfo[] {\n return Array.from(this.connectionRequests.values());\n }\n\n getConnectionRequestById(\n requestId: number\n ): ConnectionRequestInfo | undefined {\n return this.connectionRequests.get(requestId);\n }\n\n removeConnectionRequest(requestId: number): void {\n this.connectionRequests.delete(requestId);\n }\n\n clearConnectionRequests(): void {\n this.connectionRequests.clear();\n }\n\n /**\n * Persists agent data to environment variables\n * @param agent - The agent data to persist\n * @param options - Environment file persistence options\n */\n async persistAgentData(\n agent: RegisteredAgent,\n options?: AgentPersistenceOptions\n ): Promise<void> {\n if (options?.type && options.type !== 'env-file') {\n throw new Error(\n `Unsupported persistence type: ${options.type}. Only 'env-file' is supported.`\n );\n }\n\n const envFilePath =\n (options as EnvFilePersistenceOptions)?.envFilePath ||\n this.defaultEnvFilePath ||\n process.env.ENV_FILE_PATH ||\n '.env';\n\n if (!envFilePath) {\n throw new Error(\n 'Environment file path could not be determined for agent data persistence'\n );\n }\n\n const prefix =\n (options as EnvFilePersistenceOptions)?.prefix || this.defaultPrefix;\n\n if (!agent.accountId || !agent.inboundTopicId || !agent.outboundTopicId) {\n throw new Error('Agent data incomplete, cannot persist to environment');\n }\n\n const updates: Record<string, string> = {\n [`${prefix}_ACCOUNT_ID`]: agent.accountId,\n [`${prefix}_INBOUND_TOPIC_ID`]: agent.inboundTopicId,\n [`${prefix}_OUTBOUND_TOPIC_ID`]: agent.outboundTopicId,\n };\n\n if (agent.privateKey) {\n updates[`${prefix}_PRIVATE_KEY`] = agent.privateKey;\n }\n\n if (agent.profileTopicId) {\n updates[`${prefix}_PROFILE_TOPIC_ID`] = agent.profileTopicId;\n }\n\n await updateEnvFile(envFilePath, updates);\n }\n}\n"],"names":["OpenConvaiState","options","agent","connection","index","identifier","numericIndex","conn","connectionTopicId","timestampNanos","currentTimestamp","request","requestId","envFilePath","prefix","updates","updateEnvFile"],"mappings":";AAeO,MAAMA,EAAyC;AAAA;AAAA;AAAA;AAAA;AAAA,EAYpD,YAAYC,GAGT;AAdH,SAAQ,eAAuC,MAC/C,KAAQ,oBAAwC,CAAC,GACjD,KAAQ,8BAAsD,CAAC,GACvD,KAAA,yCAA6D,IAAI,GAYvE,KAAK,qBAAqBA,KAAA,gBAAAA,EAAS,oBAC9B,KAAA,iBAAgBA,KAAA,gBAAAA,EAAS,kBAAiB;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOjD,gBAAgBC,GAAqC;AACnD,SA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kBAAkB,CAACA,EAAM;AAChD,YAAA,IAAI,MAAM,sDAAsD;AAGxE,UAAMa,IAAkC;AAAA,MACtC,CAAC,GAAGD,CAAM,aAAa,GAAGZ,EAAM;AAAA,MAChC,CAAC,GAAGY,CAAM,mBAAmB,GAAGZ,EAAM;AAAA,MACtC,CAAC,GAAGY,CAAM,oBAAoB,GAAGZ,EAAM;AAAA,IACzC;AAEA,IAAIA,EAAM,eACRa,EAAQ,GAAGD,CAAM,cAAc,IAAIZ,EAAM,aAGvCA,EAAM,mBACRa,EAAQ,GAAGD,CAAM,mBAAmB,IAAIZ,EAAM,iBAG1C,MAAAc,EAAcH,GAAaE,CAAO;AAAA,EAAA;AAE5C;"}
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Basic registered agent information
3
+ */
4
+ export interface RegisteredAgent {
5
+ name: string;
6
+ accountId: string;
7
+ inboundTopicId: string;
8
+ outboundTopicId: string;
9
+ profileTopicId?: string;
10
+ privateKey?: string;
11
+ }
12
+ /**
13
+ * Connection status types
14
+ */
15
+ export type ConnectionStatus = 'established' | 'pending' | 'needs confirmation' | 'unknown';
16
+ /**
17
+ * Basic agent profile information
18
+ */
19
+ export interface AgentProfileInfo {
20
+ name?: string;
21
+ bio?: string;
22
+ avatar?: string;
23
+ type?: string;
24
+ }
25
+ /**
26
+ * Information about a connection request
27
+ */
28
+ export interface ConnectionRequestInfo {
29
+ id: number;
30
+ requestorId: string;
31
+ requestorName: string;
32
+ timestamp: Date;
33
+ memo?: string;
34
+ profile?: AgentProfileInfo;
35
+ }
36
+ /**
37
+ * Information about an active connection
38
+ */
39
+ export interface ActiveConnection {
40
+ targetAccountId: string;
41
+ targetAgentName: string;
42
+ targetInboundTopicId: string;
43
+ connectionTopicId: string;
44
+ status?: ConnectionStatus;
45
+ created?: Date;
46
+ lastActivity?: Date;
47
+ isPending?: boolean;
48
+ needsConfirmation?: boolean;
49
+ profileInfo?: AgentProfileInfo;
50
+ }
51
+ /**
52
+ * Options for environment variable persistence
53
+ */
54
+ export interface EnvPersistenceOptions {
55
+ prefix?: string;
56
+ envFilePath?: string;
57
+ }
58
+ /**
59
+ * Base persistence options interface
60
+ */
61
+ export interface PersistenceOptions {
62
+ type: string;
63
+ }
64
+ /**
65
+ * Environment file persistence options
66
+ */
67
+ export interface EnvFilePersistenceOptions extends PersistenceOptions {
68
+ type: 'env-file';
69
+ prefix?: string;
70
+ envFilePath?: string;
71
+ }
72
+ /**
73
+ * Persistence options union type
74
+ */
75
+ export type AgentPersistenceOptions = EnvFilePersistenceOptions;
76
+ /**
77
+ * Core state management interface for the standards agent toolkit.
78
+ * All tools that need to maintain state should use an implementation of this interface.
79
+ */
80
+ export interface IStateManager {
81
+ /**
82
+ * Sets the current active agent, clearing any previous connections.
83
+ */
84
+ setCurrentAgent(agent: RegisteredAgent | null): void;
85
+ /**
86
+ * Gets the current active agent.
87
+ */
88
+ getCurrentAgent(): RegisteredAgent | null;
89
+ /**
90
+ * Adds a new active connection to the state.
91
+ * Will not add duplicates based on connectionTopicId.
92
+ */
93
+ addActiveConnection(connection: ActiveConnection): void;
94
+ /**
95
+ * Updates an existing connection or adds it if not found.
96
+ * Preserves existing properties when updating.
97
+ */
98
+ updateOrAddConnection(connection: ActiveConnection): void;
99
+ /**
100
+ * Lists all active connections for the current agent.
101
+ */
102
+ listConnections(): ActiveConnection[];
103
+ /**
104
+ * Finds a connection by identifier, which can be:
105
+ * - A 1-based index number as shown in the connection list
106
+ * - A target account ID
107
+ * - A connection topic ID
108
+ */
109
+ getConnectionByIdentifier(identifier: string): ActiveConnection | undefined;
110
+ /**
111
+ * Gets the last processed message timestamp for a connection.
112
+ */
113
+ getLastTimestamp(connectionTopicId: string): number;
114
+ /**
115
+ * Updates the last processed message timestamp for a connection.
116
+ */
117
+ updateTimestamp(connectionTopicId: string, timestampNanos: number): void;
118
+ /**
119
+ * Stores a connection request in the state.
120
+ */
121
+ addConnectionRequest(request: ConnectionRequestInfo): void;
122
+ /**
123
+ * Lists all pending connection requests.
124
+ */
125
+ listConnectionRequests(): ConnectionRequestInfo[];
126
+ /**
127
+ * Finds a connection request by its ID.
128
+ */
129
+ getConnectionRequestById(requestId: number): ConnectionRequestInfo | undefined;
130
+ /**
131
+ * Removes a connection request from the state.
132
+ */
133
+ removeConnectionRequest(requestId: number): void;
134
+ /**
135
+ * Clears all connection requests from the state.
136
+ */
137
+ clearConnectionRequests(): void;
138
+ /**
139
+ * Persists agent data to storage
140
+ * Implementation may vary depending on the state manager
141
+ */
142
+ persistAgentData?(agent: RegisteredAgent, options?: AgentPersistenceOptions): Promise<void>;
143
+ }
@@ -0,0 +1,33 @@
1
+ import { StructuredTool, ToolParams } from '@langchain/core/tools';
2
+ import { z } from 'zod';
3
+ import { HCS10Client } from '../hcs10/HCS10Client';
4
+ import { IStateManager } from '../state/state-types';
5
+ export interface AcceptConnectionRequestToolParams extends ToolParams {
6
+ hcsClient: HCS10Client;
7
+ stateManager: IStateManager;
8
+ }
9
+ /**
10
+ * A tool specifically for accepting incoming connection requests.
11
+ */
12
+ export declare class AcceptConnectionRequestTool extends StructuredTool {
13
+ name: string;
14
+ description: string;
15
+ schema: z.ZodObject<{
16
+ requestId: z.ZodNumber;
17
+ hbarFee: z.ZodOptional<z.ZodNumber>;
18
+ exemptAccountIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ requestId: number;
21
+ hbarFee?: number | undefined;
22
+ exemptAccountIds?: string[] | undefined;
23
+ }, {
24
+ requestId: number;
25
+ hbarFee?: number | undefined;
26
+ exemptAccountIds?: string[] | undefined;
27
+ }>;
28
+ private hcsClient;
29
+ private stateManager;
30
+ private logger;
31
+ constructor({ hcsClient, stateManager, ...rest }: AcceptConnectionRequestToolParams);
32
+ protected _call({ requestId, hbarFee, exemptAccountIds, }: z.infer<this['schema']>): Promise<string>;
33
+ }
@@ -0,0 +1,116 @@
1
+ import { StructuredTool as p } from "../node_modules/@langchain/core/dist/tools.js";
2
+ import { z as s } from "zod";
3
+ import { Logger as m, FeeConfigBuilder as q } from "@hashgraphonline/standards-sdk";
4
+ import { ManageConnectionRequestsTool as C } from "./ManageConnectionRequestsTool.js";
5
+ class y extends p {
6
+ constructor({
7
+ hcsClient: e,
8
+ stateManager: o,
9
+ ...a
10
+ }) {
11
+ super(a), this.name = "accept_connection_request", this.description = "Accepts a specific pending connection request from another agent, establishing a communication channel.", this.schema = s.object({
12
+ requestId: s.number().describe(
13
+ 'The ID of the specific request to accept. Use the "manage_connection_requests" tool with action="list" first to get valid IDs.'
14
+ ),
15
+ hbarFee: s.number().optional().describe(
16
+ "Optional HBAR fee amount to charge the connecting agent per message on the new connection topic."
17
+ ),
18
+ exemptAccountIds: s.array(s.string()).optional().describe(
19
+ "Optional list of account IDs to exempt from any configured fees on the new connection topic."
20
+ )
21
+ }), this.hcsClient = e, this.stateManager = o, this.logger = m.getInstance({
22
+ module: "AcceptConnectionRequestTool"
23
+ });
24
+ }
25
+ async _call({
26
+ requestId: e,
27
+ hbarFee: o,
28
+ exemptAccountIds: a
29
+ }) {
30
+ var u;
31
+ if (!this.stateManager.getCurrentAgent())
32
+ return "Error: Cannot accept connection request. No agent is currently active. Please register or select an agent first.";
33
+ await new C({
34
+ hcsClient: this.hcsClient,
35
+ stateManager: this.stateManager
36
+ }).refreshRequests();
37
+ const t = this.stateManager.getConnectionRequestById(e);
38
+ if (!t)
39
+ return `Error: Request ID ${e} not found or no longer pending. Use the manage_connection_requests tool with action="list" to verify.`;
40
+ try {
41
+ const r = await this.hcsClient.getInboundTopicId();
42
+ let c;
43
+ if (o && o > 0) {
44
+ const n = this.hcsClient.getAccountAndSigner().accountId;
45
+ try {
46
+ c = new q({
47
+ network: this.hcsClient.getNetwork(),
48
+ logger: this.logger,
49
+ defaultCollectorAccountId: n
50
+ });
51
+ const l = [
52
+ ...a || [],
53
+ t.requestorId
54
+ ];
55
+ c.addHbarFee(o, n, l), this.logger.info(
56
+ `Setting HBAR fee: ${o} HBAR to be collected by ${n}`
57
+ );
58
+ } catch (l) {
59
+ this.logger.error(
60
+ `Error creating fee configuration: ${l}`
61
+ ), c = void 0, this.logger.warn(
62
+ "Proceeding to accept request without fees due to configuration error."
63
+ );
64
+ }
65
+ }
66
+ this.logger.info(
67
+ `Attempting to accept request ID: ${e} from ${t.requestorId}`
68
+ );
69
+ const i = await this.hcsClient.handleConnectionRequest(
70
+ r,
71
+ t.requestorId,
72
+ e,
73
+ c
74
+ );
75
+ if (!(i != null && i.connectionTopicId))
76
+ return `Error: Failed to accept connection request #${e}. The SDK did not return a connection topic ID.`;
77
+ this.logger.info(
78
+ `Successfully created connection topic: ${i.connectionTopicId}`
79
+ );
80
+ const f = i.connectionTopicId;
81
+ let g = "";
82
+ try {
83
+ const n = await this.hcsClient.getAgentProfile(
84
+ t.requestorId
85
+ );
86
+ g = ((u = n == null ? void 0 : n.topicInfo) == null ? void 0 : u.inboundTopic) || "", g || this.logger.warn(
87
+ `Could not resolve target inbound topic for ${t.requestorId}`
88
+ );
89
+ } catch (n) {
90
+ this.logger.warn(
91
+ `Error fetching target profile/topic for ${t.requestorId}: ${n}`
92
+ );
93
+ }
94
+ const h = {
95
+ targetAccountId: t.requestorId,
96
+ targetAgentName: t.requestorName,
97
+ targetInboundTopicId: g,
98
+ connectionTopicId: f,
99
+ profileInfo: t.profile,
100
+ created: /* @__PURE__ */ new Date(),
101
+ status: "established"
102
+ };
103
+ this.stateManager.addActiveConnection(h), this.stateManager.removeConnectionRequest(e), this.logger.info(`Removed request ${e} from pending requests`);
104
+ let d = "";
105
+ return o && o > 0 && c && (d = ` with a ${o} HBAR fee per message`), `Successfully accepted connection request #${e} from ${t.requestorName}${d}. Connection established on topic: ${f}.`;
106
+ } catch (r) {
107
+ return this.logger.error(
108
+ `Error accepting connection request #${e}: ${r}`
109
+ ), `Error accepting connection request #${e}: ${r instanceof Error ? r.message : String(r)}`;
110
+ }
111
+ }
112
+ }
113
+ export {
114
+ y as AcceptConnectionRequestTool
115
+ };
116
+ //# sourceMappingURL=AcceptConnectionRequestTool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcceptConnectionRequestTool.js","sources":["../../src/tools/AcceptConnectionRequestTool.ts"],"sourcesContent":["import { StructuredTool, ToolParams } from '@langchain/core/tools';\nimport { z } from 'zod';\nimport { HCS10Client } from '../hcs10/HCS10Client';\nimport { IStateManager, ActiveConnection } from '../state/state-types';\nimport { Logger, FeeConfigBuilder } from '@hashgraphonline/standards-sdk';\nimport { ManageConnectionRequestsTool } from './ManageConnectionRequestsTool';\n\nexport interface AcceptConnectionRequestToolParams extends ToolParams {\n hcsClient: HCS10Client;\n stateManager: IStateManager;\n}\n\n/**\n * A tool specifically for accepting incoming connection requests.\n */\nexport class AcceptConnectionRequestTool extends StructuredTool {\n name = 'accept_connection_request';\n description =\n 'Accepts a specific pending connection request from another agent, establishing a communication channel.';\n schema = z.object({\n requestId: z\n .number()\n .describe(\n 'The ID of the specific request to accept. Use the \"manage_connection_requests\" tool with action=\"list\" first to get valid IDs.'\n ),\n hbarFee: z\n .number()\n .optional()\n .describe(\n 'Optional HBAR fee amount to charge the connecting agent per message on the new connection topic.'\n ),\n exemptAccountIds: z\n .array(z.string())\n .optional()\n .describe(\n 'Optional list of account IDs to exempt from any configured fees on the new connection topic.'\n ),\n });\n\n private hcsClient: HCS10Client;\n private stateManager: IStateManager;\n private logger: Logger;\n\n constructor({\n hcsClient,\n stateManager,\n ...rest\n }: AcceptConnectionRequestToolParams) {\n super(rest);\n this.hcsClient = hcsClient;\n this.stateManager = stateManager;\n this.logger = Logger.getInstance({\n module: 'AcceptConnectionRequestTool',\n });\n }\n\n protected async _call({\n requestId,\n hbarFee,\n exemptAccountIds,\n }: z.infer<this['schema']>): Promise<string> {\n const currentAgent = this.stateManager.getCurrentAgent();\n if (!currentAgent) {\n return 'Error: Cannot accept connection request. No agent is currently active. Please register or select an agent first.';\n }\n\n const manageConnectionRequestsTool = new ManageConnectionRequestsTool({\n hcsClient: this.hcsClient,\n stateManager: this.stateManager,\n });\n\n await manageConnectionRequestsTool.refreshRequests();\n\n const request = this.stateManager.getConnectionRequestById(requestId);\n if (!request) {\n return `Error: Request ID ${requestId} not found or no longer pending. Use the manage_connection_requests tool with action=\"list\" to verify.`;\n }\n\n try {\n const inboundTopicId = await this.hcsClient.getInboundTopicId();\n let feeConfigBuilder = undefined;\n\n if (hbarFee && hbarFee > 0) {\n const collectorId = this.hcsClient.getAccountAndSigner().accountId;\n try {\n feeConfigBuilder = new FeeConfigBuilder({\n network: this.hcsClient.getNetwork(),\n logger: this.logger,\n defaultCollectorAccountId: collectorId,\n });\n\n const finalExemptions = [\n ...(exemptAccountIds || []),\n request.requestorId,\n ];\n feeConfigBuilder.addHbarFee(hbarFee, collectorId, finalExemptions);\n this.logger.info(\n `Setting HBAR fee: ${hbarFee} HBAR to be collected by ${collectorId}`\n );\n } catch (feeConfigError) {\n this.logger.error(\n `Error creating fee configuration: ${feeConfigError}`\n );\n\n feeConfigBuilder = undefined;\n this.logger.warn(\n 'Proceeding to accept request without fees due to configuration error.'\n );\n }\n }\n\n this.logger.info(\n `Attempting to accept request ID: ${requestId} from ${request.requestorId}`\n );\n const result = await this.hcsClient.handleConnectionRequest(\n inboundTopicId,\n request.requestorId,\n requestId,\n feeConfigBuilder\n );\n\n if (!result?.connectionTopicId) {\n return `Error: Failed to accept connection request #${requestId}. The SDK did not return a connection topic ID.`;\n }\n this.logger.info(\n `Successfully created connection topic: ${result.connectionTopicId}`\n );\n\n const connectionTopicId = result.connectionTopicId;\n\n let targetInboundTopic = '';\n try {\n const targetProfileData = await this.hcsClient.getAgentProfile(\n request.requestorId\n );\n targetInboundTopic =\n targetProfileData?.['topicInfo']?.['inboundTopic'] || '';\n if (!targetInboundTopic) {\n this.logger.warn(\n `Could not resolve target inbound topic for ${request.requestorId}`\n );\n }\n } catch (e) {\n this.logger.warn(\n `Error fetching target profile/topic for ${request.requestorId}: ${e}`\n );\n }\n\n const newConnection: ActiveConnection = {\n targetAccountId: request.requestorId,\n targetAgentName: request.requestorName,\n targetInboundTopicId: targetInboundTopic,\n connectionTopicId,\n profileInfo: request.profile,\n created: new Date(),\n status: 'established',\n };\n\n this.stateManager.addActiveConnection(newConnection);\n this.stateManager.removeConnectionRequest(requestId);\n this.logger.info(`Removed request ${requestId} from pending requests`);\n\n let feeMessage = '';\n if (hbarFee && hbarFee > 0 && feeConfigBuilder) {\n feeMessage = ` with a ${hbarFee} HBAR fee per message`;\n }\n\n return `Successfully accepted connection request #${requestId} from ${request.requestorName}${feeMessage}. Connection established on topic: ${connectionTopicId}.`;\n } catch (error) {\n this.logger.error(\n `Error accepting connection request #${requestId}: ${error}`\n );\n\n return `Error accepting connection request #${requestId}: ${\n error instanceof Error ? error.message : String(error)\n }`;\n }\n }\n}\n"],"names":["AcceptConnectionRequestTool","StructuredTool","hcsClient","stateManager","rest","z","Logger","requestId","hbarFee","exemptAccountIds","ManageConnectionRequestsTool","request","inboundTopicId","feeConfigBuilder","collectorId","FeeConfigBuilder","finalExemptions","feeConfigError","result","connectionTopicId","targetInboundTopic","targetProfileData","_a","e","newConnection","feeMessage","error"],"mappings":";;;;AAeO,MAAMA,UAAoCC,EAAe;AAAA,EA4B9D,YAAY;AAAA,IACV,WAAAC;AAAA,IACA,cAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,GACiC;AACpC,UAAMA,CAAI,GAhCL,KAAA,OAAA,6BAEL,KAAA,cAAA,2GACF,KAAA,SAASC,EAAE,OAAO;AAAA,MAChB,WAAWA,EACR,OAAA,EACA;AAAA,QACC;AAAA,MACF;AAAA,MACF,SAASA,EACN,SACA,SACA,EAAA;AAAA,QACC;AAAA,MACF;AAAA,MACF,kBAAkBA,EACf,MAAMA,EAAE,QAAQ,EAChB,WACA;AAAA,QACC;AAAA,MAAA;AAAA,IACF,CACH,GAYC,KAAK,YAAYH,GACjB,KAAK,eAAeC,GACf,KAAA,SAASG,EAAO,YAAY;AAAA,MAC/B,QAAQ;AAAA,IAAA,CACT;AAAA,E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from 'zod';
3
+ import { HCS10Client } from '../hcs10/HCS10Client';
4
+ import { IStateManager } from '../state/state-types';
5
+ export interface CheckMessagesToolParams extends ToolParams {
6
+ hcsClient: HCS10Client;
7
+ stateManager: IStateManager;
8
+ }
9
+ /**
10
+ * A tool to check for new messages on an active HCS-10 connection topic,
11
+ * or optionally fetch the latest messages regardless of timestamp.
12
+ */
13
+ export declare class CheckMessagesTool extends StructuredTool {
14
+ name: string;
15
+ description: string;
16
+ schema: z.ZodObject<{
17
+ targetIdentifier: z.ZodString;
18
+ fetchLatest: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
19
+ lastMessagesCount: z.ZodOptional<z.ZodNumber>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ targetIdentifier: string;
22
+ fetchLatest: boolean;
23
+ lastMessagesCount?: number | undefined;
24
+ }, {
25
+ targetIdentifier: string;
26
+ fetchLatest?: boolean | undefined;
27
+ lastMessagesCount?: number | undefined;
28
+ }>;
29
+ hcsClient: HCS10Client;
30
+ private stateManager;
31
+ private logger;
32
+ constructor({ hcsClient, stateManager, ...rest }: CheckMessagesToolParams);
33
+ protected _call({ targetIdentifier, fetchLatest, lastMessagesCount, }: z.infer<this['schema']>): Promise<string>;
34
+ }