@robota-sdk/agent-core 3.0.0-beta.7 → 3.0.0-beta.71

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 (511) hide show
  1. package/CHANGELOG.md +122 -0
  2. package/README.md +41 -12
  3. package/dist/browser/index.d.ts +3736 -3090
  4. package/dist/browser/index.d.ts.map +1 -0
  5. package/dist/browser/index.js +12 -5
  6. package/dist/browser/index.js.map +1 -0
  7. package/dist/node/index.cjs +11 -5
  8. package/dist/node/index.d.ts +3736 -3090
  9. package/dist/node/index.d.ts.map +1 -0
  10. package/dist/node/index.js +12 -5
  11. package/dist/node/index.js.map +1 -0
  12. package/package.json +8 -5
  13. package/dist/abstracts/abstract-agent.d.ts +0 -56
  14. package/dist/abstracts/abstract-agent.d.ts.map +0 -1
  15. package/dist/abstracts/abstract-agent.js +0 -55
  16. package/dist/abstracts/abstract-agent.js.map +0 -1
  17. package/dist/abstracts/abstract-ai-provider.d.ts +0 -187
  18. package/dist/abstracts/abstract-ai-provider.d.ts.map +0 -1
  19. package/dist/abstracts/abstract-ai-provider.js +0 -252
  20. package/dist/abstracts/abstract-ai-provider.js.map +0 -1
  21. package/dist/abstracts/abstract-executor.d.ts +0 -110
  22. package/dist/abstracts/abstract-executor.d.ts.map +0 -1
  23. package/dist/abstracts/abstract-executor.js +0 -156
  24. package/dist/abstracts/abstract-executor.js.map +0 -1
  25. package/dist/abstracts/abstract-manager.d.ts +0 -42
  26. package/dist/abstracts/abstract-manager.d.ts.map +0 -1
  27. package/dist/abstracts/abstract-manager.js +0 -49
  28. package/dist/abstracts/abstract-manager.js.map +0 -1
  29. package/dist/abstracts/abstract-module.d.ts +0 -365
  30. package/dist/abstracts/abstract-module.d.ts.map +0 -1
  31. package/dist/abstracts/abstract-module.js +0 -474
  32. package/dist/abstracts/abstract-module.js.map +0 -1
  33. package/dist/abstracts/abstract-plugin.d.ts +0 -369
  34. package/dist/abstracts/abstract-plugin.d.ts.map +0 -1
  35. package/dist/abstracts/abstract-plugin.js +0 -258
  36. package/dist/abstracts/abstract-plugin.js.map +0 -1
  37. package/dist/abstracts/abstract-tool.d.ts +0 -175
  38. package/dist/abstracts/abstract-tool.d.ts.map +0 -1
  39. package/dist/abstracts/abstract-tool.js +0 -140
  40. package/dist/abstracts/abstract-tool.js.map +0 -1
  41. package/dist/abstracts/abstract-workflow-converter.d.ts +0 -136
  42. package/dist/abstracts/abstract-workflow-converter.d.ts.map +0 -1
  43. package/dist/abstracts/abstract-workflow-converter.js +0 -252
  44. package/dist/abstracts/abstract-workflow-converter.js.map +0 -1
  45. package/dist/abstracts/abstract-workflow-validator.d.ts +0 -203
  46. package/dist/abstracts/abstract-workflow-validator.d.ts.map +0 -1
  47. package/dist/abstracts/abstract-workflow-validator.js +0 -447
  48. package/dist/abstracts/abstract-workflow-validator.js.map +0 -1
  49. package/dist/abstracts/index.d.ts +0 -6
  50. package/dist/abstracts/index.d.ts.map +0 -1
  51. package/dist/abstracts/index.js +0 -9
  52. package/dist/abstracts/index.js.map +0 -1
  53. package/dist/agents/constants.d.ts +0 -23
  54. package/dist/agents/constants.d.ts.map +0 -1
  55. package/dist/agents/constants.js +0 -22
  56. package/dist/agents/constants.js.map +0 -1
  57. package/dist/agents/index.d.ts +0 -1
  58. package/dist/agents/index.d.ts.map +0 -1
  59. package/dist/agents/index.js +0 -4
  60. package/dist/agents/index.js.map +0 -1
  61. package/dist/agents/robota.test.d.ts +0 -2
  62. package/dist/agents/robota.test.d.ts.map +0 -1
  63. package/dist/agents/robota.test.js +0 -416
  64. package/dist/agents/robota.test.js.map +0 -1
  65. package/dist/browser/builtin-templates.json +0 -107
  66. package/dist/core/robota.d.ts +0 -694
  67. package/dist/core/robota.d.ts.map +0 -1
  68. package/dist/core/robota.js +0 -1277
  69. package/dist/core/robota.js.map +0 -1
  70. package/dist/executors/local-executor.d.ts +0 -96
  71. package/dist/executors/local-executor.d.ts.map +0 -1
  72. package/dist/executors/local-executor.js +0 -197
  73. package/dist/executors/local-executor.js.map +0 -1
  74. package/dist/executors/local-executor.test.d.ts +0 -2
  75. package/dist/executors/local-executor.test.d.ts.map +0 -1
  76. package/dist/executors/local-executor.test.js +0 -192
  77. package/dist/executors/local-executor.test.js.map +0 -1
  78. package/dist/index.d.ts +0 -274
  79. package/dist/index.d.ts.map +0 -1
  80. package/dist/index.js +0 -235
  81. package/dist/index.js.map +0 -1
  82. package/dist/interfaces/agent.d.ts +0 -198
  83. package/dist/interfaces/agent.d.ts.map +0 -1
  84. package/dist/interfaces/agent.js +0 -2
  85. package/dist/interfaces/agent.js.map +0 -1
  86. package/dist/interfaces/event-service.d.ts +0 -79
  87. package/dist/interfaces/event-service.d.ts.map +0 -1
  88. package/dist/interfaces/event-service.js +0 -2
  89. package/dist/interfaces/event-service.js.map +0 -1
  90. package/dist/interfaces/executor.d.ts +0 -128
  91. package/dist/interfaces/executor.d.ts.map +0 -1
  92. package/dist/interfaces/executor.js +0 -2
  93. package/dist/interfaces/executor.js.map +0 -1
  94. package/dist/interfaces/history-module.d.ts +0 -19
  95. package/dist/interfaces/history-module.d.ts.map +0 -1
  96. package/dist/interfaces/history-module.js +0 -2
  97. package/dist/interfaces/history-module.js.map +0 -1
  98. package/dist/interfaces/index.d.ts +0 -13
  99. package/dist/interfaces/index.d.ts.map +0 -1
  100. package/dist/interfaces/index.js +0 -4
  101. package/dist/interfaces/index.js.map +0 -1
  102. package/dist/interfaces/manager.d.ts +0 -142
  103. package/dist/interfaces/manager.d.ts.map +0 -1
  104. package/dist/interfaces/manager.js +0 -2
  105. package/dist/interfaces/manager.js.map +0 -1
  106. package/dist/interfaces/messages.d.ts +0 -75
  107. package/dist/interfaces/messages.d.ts.map +0 -1
  108. package/dist/interfaces/messages.js +0 -29
  109. package/dist/interfaces/messages.js.map +0 -1
  110. package/dist/interfaces/progress-reporting.d.ts +0 -86
  111. package/dist/interfaces/progress-reporting.d.ts.map +0 -1
  112. package/dist/interfaces/progress-reporting.js +0 -37
  113. package/dist/interfaces/progress-reporting.js.map +0 -1
  114. package/dist/interfaces/provider.d.ts +0 -217
  115. package/dist/interfaces/provider.d.ts.map +0 -1
  116. package/dist/interfaces/provider.js +0 -2
  117. package/dist/interfaces/provider.js.map +0 -1
  118. package/dist/interfaces/service.d.ts +0 -205
  119. package/dist/interfaces/service.d.ts.map +0 -1
  120. package/dist/interfaces/service.js +0 -6
  121. package/dist/interfaces/service.js.map +0 -1
  122. package/dist/interfaces/tool.d.ts +0 -248
  123. package/dist/interfaces/tool.d.ts.map +0 -1
  124. package/dist/interfaces/tool.js +0 -2
  125. package/dist/interfaces/tool.js.map +0 -1
  126. package/dist/interfaces/types.d.ts +0 -71
  127. package/dist/interfaces/types.d.ts.map +0 -1
  128. package/dist/interfaces/types.js +0 -33
  129. package/dist/interfaces/types.js.map +0 -1
  130. package/dist/interfaces/workflow-converter.d.ts +0 -193
  131. package/dist/interfaces/workflow-converter.d.ts.map +0 -1
  132. package/dist/interfaces/workflow-converter.js +0 -11
  133. package/dist/interfaces/workflow-converter.js.map +0 -1
  134. package/dist/interfaces/workflow-validator.d.ts +0 -209
  135. package/dist/interfaces/workflow-validator.d.ts.map +0 -1
  136. package/dist/interfaces/workflow-validator.js +0 -16
  137. package/dist/interfaces/workflow-validator.js.map +0 -1
  138. package/dist/managers/agent-factory.d.ts +0 -132
  139. package/dist/managers/agent-factory.d.ts.map +0 -1
  140. package/dist/managers/agent-factory.js +0 -284
  141. package/dist/managers/agent-factory.js.map +0 -1
  142. package/dist/managers/agent-factory.test.d.ts +0 -2
  143. package/dist/managers/agent-factory.test.d.ts.map +0 -1
  144. package/dist/managers/agent-factory.test.js +0 -249
  145. package/dist/managers/agent-factory.test.js.map +0 -1
  146. package/dist/managers/agent-templates.d.ts +0 -84
  147. package/dist/managers/agent-templates.d.ts.map +0 -1
  148. package/dist/managers/agent-templates.js +0 -159
  149. package/dist/managers/agent-templates.js.map +0 -1
  150. package/dist/managers/ai-provider-manager.d.ts +0 -80
  151. package/dist/managers/ai-provider-manager.d.ts.map +0 -1
  152. package/dist/managers/ai-provider-manager.js +0 -226
  153. package/dist/managers/ai-provider-manager.js.map +0 -1
  154. package/dist/managers/conversation-history-manager.d.ts +0 -455
  155. package/dist/managers/conversation-history-manager.d.ts.map +0 -1
  156. package/dist/managers/conversation-history-manager.js +0 -578
  157. package/dist/managers/conversation-history-manager.js.map +0 -1
  158. package/dist/managers/conversation-history-manager.test.d.ts +0 -2
  159. package/dist/managers/conversation-history-manager.test.d.ts.map +0 -1
  160. package/dist/managers/conversation-history-manager.test.js +0 -374
  161. package/dist/managers/conversation-history-manager.test.js.map +0 -1
  162. package/dist/managers/index.d.ts +0 -8
  163. package/dist/managers/index.d.ts.map +0 -1
  164. package/dist/managers/index.js +0 -8
  165. package/dist/managers/index.js.map +0 -1
  166. package/dist/managers/module-registry.d.ts +0 -161
  167. package/dist/managers/module-registry.d.ts.map +0 -1
  168. package/dist/managers/module-registry.js +0 -519
  169. package/dist/managers/module-registry.js.map +0 -1
  170. package/dist/managers/module-type-registry.d.ts +0 -113
  171. package/dist/managers/module-type-registry.d.ts.map +0 -1
  172. package/dist/managers/module-type-registry.js +0 -439
  173. package/dist/managers/module-type-registry.js.map +0 -1
  174. package/dist/managers/plugins.d.ts +0 -166
  175. package/dist/managers/plugins.d.ts.map +0 -1
  176. package/dist/managers/plugins.js +0 -339
  177. package/dist/managers/plugins.js.map +0 -1
  178. package/dist/managers/tool-manager.d.ts +0 -70
  179. package/dist/managers/tool-manager.d.ts.map +0 -1
  180. package/dist/managers/tool-manager.js +0 -138
  181. package/dist/managers/tool-manager.js.map +0 -1
  182. package/dist/managers/tool-manager.test.d.ts +0 -2
  183. package/dist/managers/tool-manager.test.d.ts.map +0 -1
  184. package/dist/managers/tool-manager.test.js +0 -186
  185. package/dist/managers/tool-manager.test.js.map +0 -1
  186. package/dist/node/builtin-templates.json +0 -107
  187. package/dist/node/index.d.cts +0 -4238
  188. package/dist/plugins/conversation-history/conversation-history-plugin.d.ts +0 -67
  189. package/dist/plugins/conversation-history/conversation-history-plugin.d.ts.map +0 -1
  190. package/dist/plugins/conversation-history/conversation-history-plugin.js +0 -270
  191. package/dist/plugins/conversation-history/conversation-history-plugin.js.map +0 -1
  192. package/dist/plugins/conversation-history/index.d.ts +0 -3
  193. package/dist/plugins/conversation-history/index.d.ts.map +0 -1
  194. package/dist/plugins/conversation-history/index.js +0 -2
  195. package/dist/plugins/conversation-history/index.js.map +0 -1
  196. package/dist/plugins/conversation-history/storages/database-storage.d.ts +0 -19
  197. package/dist/plugins/conversation-history/storages/database-storage.d.ts.map +0 -1
  198. package/dist/plugins/conversation-history/storages/database-storage.js +0 -94
  199. package/dist/plugins/conversation-history/storages/database-storage.js.map +0 -1
  200. package/dist/plugins/conversation-history/storages/file-storage.d.ts +0 -15
  201. package/dist/plugins/conversation-history/storages/file-storage.d.ts.map +0 -1
  202. package/dist/plugins/conversation-history/storages/file-storage.js +0 -94
  203. package/dist/plugins/conversation-history/storages/file-storage.js.map +0 -1
  204. package/dist/plugins/conversation-history/storages/index.d.ts +0 -4
  205. package/dist/plugins/conversation-history/storages/index.d.ts.map +0 -1
  206. package/dist/plugins/conversation-history/storages/index.js +0 -4
  207. package/dist/plugins/conversation-history/storages/index.js.map +0 -1
  208. package/dist/plugins/conversation-history/storages/memory-storage.d.ts +0 -15
  209. package/dist/plugins/conversation-history/storages/memory-storage.d.ts.map +0 -1
  210. package/dist/plugins/conversation-history/storages/memory-storage.js +0 -33
  211. package/dist/plugins/conversation-history/storages/memory-storage.js.map +0 -1
  212. package/dist/plugins/conversation-history/types.d.ts +0 -61
  213. package/dist/plugins/conversation-history/types.d.ts.map +0 -1
  214. package/dist/plugins/conversation-history/types.js +0 -2
  215. package/dist/plugins/conversation-history/types.js.map +0 -1
  216. package/dist/plugins/error-handling/context-adapter.d.ts +0 -30
  217. package/dist/plugins/error-handling/context-adapter.d.ts.map +0 -1
  218. package/dist/plugins/error-handling/context-adapter.js +0 -41
  219. package/dist/plugins/error-handling/context-adapter.js.map +0 -1
  220. package/dist/plugins/error-handling/error-handling-plugin.d.ts +0 -49
  221. package/dist/plugins/error-handling/error-handling-plugin.d.ts.map +0 -1
  222. package/dist/plugins/error-handling/error-handling-plugin.js +0 -229
  223. package/dist/plugins/error-handling/error-handling-plugin.js.map +0 -1
  224. package/dist/plugins/error-handling/index.d.ts +0 -10
  225. package/dist/plugins/error-handling/index.d.ts.map +0 -1
  226. package/dist/plugins/error-handling/index.js +0 -10
  227. package/dist/plugins/error-handling/index.js.map +0 -1
  228. package/dist/plugins/error-handling/types.d.ts +0 -73
  229. package/dist/plugins/error-handling/types.d.ts.map +0 -1
  230. package/dist/plugins/error-handling/types.js +0 -14
  231. package/dist/plugins/error-handling/types.js.map +0 -1
  232. package/dist/plugins/event-emitter/metrics.d.ts +0 -17
  233. package/dist/plugins/event-emitter/metrics.d.ts.map +0 -1
  234. package/dist/plugins/event-emitter/metrics.js +0 -17
  235. package/dist/plugins/event-emitter/metrics.js.map +0 -1
  236. package/dist/plugins/event-emitter/types.d.ts +0 -112
  237. package/dist/plugins/event-emitter/types.d.ts.map +0 -1
  238. package/dist/plugins/event-emitter/types.js +0 -65
  239. package/dist/plugins/event-emitter/types.js.map +0 -1
  240. package/dist/plugins/event-emitter-plugin.d.ts +0 -222
  241. package/dist/plugins/event-emitter-plugin.d.ts.map +0 -1
  242. package/dist/plugins/event-emitter-plugin.js +0 -432
  243. package/dist/plugins/event-emitter-plugin.js.map +0 -1
  244. package/dist/plugins/event-emitter-plugin.test.d.ts +0 -2
  245. package/dist/plugins/event-emitter-plugin.test.d.ts.map +0 -1
  246. package/dist/plugins/event-emitter-plugin.test.js +0 -94
  247. package/dist/plugins/event-emitter-plugin.test.js.map +0 -1
  248. package/dist/plugins/execution/execution-analytics-plugin.d.ts +0 -129
  249. package/dist/plugins/execution/execution-analytics-plugin.d.ts.map +0 -1
  250. package/dist/plugins/execution/execution-analytics-plugin.js +0 -517
  251. package/dist/plugins/execution/execution-analytics-plugin.js.map +0 -1
  252. package/dist/plugins/execution/index.d.ts +0 -3
  253. package/dist/plugins/execution/index.d.ts.map +0 -1
  254. package/dist/plugins/execution/index.js +0 -2
  255. package/dist/plugins/execution/index.js.map +0 -1
  256. package/dist/plugins/execution/types.d.ts +0 -90
  257. package/dist/plugins/execution/types.d.ts.map +0 -1
  258. package/dist/plugins/execution/types.js +0 -2
  259. package/dist/plugins/execution/types.js.map +0 -1
  260. package/dist/plugins/index.d.ts +0 -10
  261. package/dist/plugins/index.d.ts.map +0 -1
  262. package/dist/plugins/index.js +0 -11
  263. package/dist/plugins/index.js.map +0 -1
  264. package/dist/plugins/limits/types.d.ts +0 -61
  265. package/dist/plugins/limits/types.d.ts.map +0 -1
  266. package/dist/plugins/limits/types.js +0 -2
  267. package/dist/plugins/limits/types.js.map +0 -1
  268. package/dist/plugins/limits-plugin.d.ts +0 -113
  269. package/dist/plugins/limits-plugin.d.ts.map +0 -1
  270. package/dist/plugins/limits-plugin.js +0 -380
  271. package/dist/plugins/limits-plugin.js.map +0 -1
  272. package/dist/plugins/logging/formatters.d.ts +0 -14
  273. package/dist/plugins/logging/formatters.d.ts.map +0 -1
  274. package/dist/plugins/logging/formatters.js +0 -24
  275. package/dist/plugins/logging/formatters.js.map +0 -1
  276. package/dist/plugins/logging/index.d.ts +0 -3
  277. package/dist/plugins/logging/index.d.ts.map +0 -1
  278. package/dist/plugins/logging/index.js +0 -2
  279. package/dist/plugins/logging/index.js.map +0 -1
  280. package/dist/plugins/logging/logging-plugin.d.ts +0 -91
  281. package/dist/plugins/logging/logging-plugin.d.ts.map +0 -1
  282. package/dist/plugins/logging/logging-plugin.js +0 -335
  283. package/dist/plugins/logging/logging-plugin.js.map +0 -1
  284. package/dist/plugins/logging/storages/console-storage.d.ts +0 -14
  285. package/dist/plugins/logging/storages/console-storage.d.ts.map +0 -1
  286. package/dist/plugins/logging/storages/console-storage.js +0 -38
  287. package/dist/plugins/logging/storages/console-storage.js.map +0 -1
  288. package/dist/plugins/logging/storages/file-storage.d.ts +0 -14
  289. package/dist/plugins/logging/storages/file-storage.d.ts.map +0 -1
  290. package/dist/plugins/logging/storages/file-storage.js +0 -41
  291. package/dist/plugins/logging/storages/file-storage.js.map +0 -1
  292. package/dist/plugins/logging/storages/index.d.ts +0 -5
  293. package/dist/plugins/logging/storages/index.d.ts.map +0 -1
  294. package/dist/plugins/logging/storages/index.js +0 -5
  295. package/dist/plugins/logging/storages/index.js.map +0 -1
  296. package/dist/plugins/logging/storages/remote-storage.d.ts +0 -20
  297. package/dist/plugins/logging/storages/remote-storage.d.ts.map +0 -1
  298. package/dist/plugins/logging/storages/remote-storage.js +0 -61
  299. package/dist/plugins/logging/storages/remote-storage.js.map +0 -1
  300. package/dist/plugins/logging/storages/silent-storage.d.ts +0 -10
  301. package/dist/plugins/logging/storages/silent-storage.d.ts.map +0 -1
  302. package/dist/plugins/logging/storages/silent-storage.js +0 -15
  303. package/dist/plugins/logging/storages/silent-storage.js.map +0 -1
  304. package/dist/plugins/logging/types.d.ts +0 -84
  305. package/dist/plugins/logging/types.d.ts.map +0 -1
  306. package/dist/plugins/logging/types.js +0 -2
  307. package/dist/plugins/logging/types.js.map +0 -1
  308. package/dist/plugins/performance/collectors/system-metrics-collector.d.ts +0 -12
  309. package/dist/plugins/performance/collectors/system-metrics-collector.d.ts.map +0 -1
  310. package/dist/plugins/performance/collectors/system-metrics-collector.js +0 -65
  311. package/dist/plugins/performance/collectors/system-metrics-collector.js.map +0 -1
  312. package/dist/plugins/performance/index.d.ts +0 -5
  313. package/dist/plugins/performance/index.d.ts.map +0 -1
  314. package/dist/plugins/performance/index.js +0 -4
  315. package/dist/plugins/performance/index.js.map +0 -1
  316. package/dist/plugins/performance/performance-plugin.d.ts +0 -49
  317. package/dist/plugins/performance/performance-plugin.d.ts.map +0 -1
  318. package/dist/plugins/performance/performance-plugin.js +0 -293
  319. package/dist/plugins/performance/performance-plugin.js.map +0 -1
  320. package/dist/plugins/performance/storages/index.d.ts +0 -2
  321. package/dist/plugins/performance/storages/index.d.ts.map +0 -1
  322. package/dist/plugins/performance/storages/index.js +0 -4
  323. package/dist/plugins/performance/storages/index.js.map +0 -1
  324. package/dist/plugins/performance/storages/memory-storage.d.ts +0 -19
  325. package/dist/plugins/performance/storages/memory-storage.d.ts.map +0 -1
  326. package/dist/plugins/performance/storages/memory-storage.js +0 -69
  327. package/dist/plugins/performance/storages/memory-storage.js.map +0 -1
  328. package/dist/plugins/performance/types.d.ts +0 -154
  329. package/dist/plugins/performance/types.d.ts.map +0 -1
  330. package/dist/plugins/performance/types.js +0 -2
  331. package/dist/plugins/performance/types.js.map +0 -1
  332. package/dist/plugins/usage/aggregate-usage-stats.d.ts +0 -12
  333. package/dist/plugins/usage/aggregate-usage-stats.d.ts.map +0 -1
  334. package/dist/plugins/usage/aggregate-usage-stats.js +0 -115
  335. package/dist/plugins/usage/aggregate-usage-stats.js.map +0 -1
  336. package/dist/plugins/usage/index.d.ts +0 -5
  337. package/dist/plugins/usage/index.d.ts.map +0 -1
  338. package/dist/plugins/usage/index.js +0 -4
  339. package/dist/plugins/usage/index.js.map +0 -1
  340. package/dist/plugins/usage/storages/file-storage.d.ts +0 -22
  341. package/dist/plugins/usage/storages/file-storage.d.ts.map +0 -1
  342. package/dist/plugins/usage/storages/file-storage.js +0 -111
  343. package/dist/plugins/usage/storages/file-storage.js.map +0 -1
  344. package/dist/plugins/usage/storages/index.d.ts +0 -5
  345. package/dist/plugins/usage/storages/index.d.ts.map +0 -1
  346. package/dist/plugins/usage/storages/index.js +0 -5
  347. package/dist/plugins/usage/storages/index.js.map +0 -1
  348. package/dist/plugins/usage/storages/memory-storage.d.ts +0 -22
  349. package/dist/plugins/usage/storages/memory-storage.d.ts.map +0 -1
  350. package/dist/plugins/usage/storages/memory-storage.js +0 -42
  351. package/dist/plugins/usage/storages/memory-storage.js.map +0 -1
  352. package/dist/plugins/usage/storages/remote-storage.d.ts +0 -26
  353. package/dist/plugins/usage/storages/remote-storage.d.ts.map +0 -1
  354. package/dist/plugins/usage/storages/remote-storage.js +0 -115
  355. package/dist/plugins/usage/storages/remote-storage.js.map +0 -1
  356. package/dist/plugins/usage/storages/silent-storage.d.ts +0 -19
  357. package/dist/plugins/usage/storages/silent-storage.d.ts.map +0 -1
  358. package/dist/plugins/usage/storages/silent-storage.js +0 -26
  359. package/dist/plugins/usage/storages/silent-storage.js.map +0 -1
  360. package/dist/plugins/usage/types.d.ts +0 -127
  361. package/dist/plugins/usage/types.d.ts.map +0 -1
  362. package/dist/plugins/usage/types.js +0 -2
  363. package/dist/plugins/usage/types.js.map +0 -1
  364. package/dist/plugins/usage/usage-plugin.d.ts +0 -67
  365. package/dist/plugins/usage/usage-plugin.d.ts.map +0 -1
  366. package/dist/plugins/usage/usage-plugin.js +0 -309
  367. package/dist/plugins/usage/usage-plugin.js.map +0 -1
  368. package/dist/plugins/webhook/http-client.d.ts +0 -30
  369. package/dist/plugins/webhook/http-client.d.ts.map +0 -1
  370. package/dist/plugins/webhook/http-client.js +0 -110
  371. package/dist/plugins/webhook/http-client.js.map +0 -1
  372. package/dist/plugins/webhook/index.d.ts +0 -9
  373. package/dist/plugins/webhook/index.d.ts.map +0 -1
  374. package/dist/plugins/webhook/index.js +0 -9
  375. package/dist/plugins/webhook/index.js.map +0 -1
  376. package/dist/plugins/webhook/transformer.d.ts +0 -63
  377. package/dist/plugins/webhook/transformer.d.ts.map +0 -1
  378. package/dist/plugins/webhook/transformer.js +0 -157
  379. package/dist/plugins/webhook/transformer.js.map +0 -1
  380. package/dist/plugins/webhook/types.d.ts +0 -183
  381. package/dist/plugins/webhook/types.d.ts.map +0 -1
  382. package/dist/plugins/webhook/types.js +0 -2
  383. package/dist/plugins/webhook/types.js.map +0 -1
  384. package/dist/plugins/webhook/webhook-plugin.d.ts +0 -92
  385. package/dist/plugins/webhook/webhook-plugin.d.ts.map +0 -1
  386. package/dist/plugins/webhook/webhook-plugin.js +0 -328
  387. package/dist/plugins/webhook/webhook-plugin.js.map +0 -1
  388. package/dist/schemas/agent-template-schema.d.ts +0 -137
  389. package/dist/schemas/agent-template-schema.d.ts.map +0 -1
  390. package/dist/schemas/agent-template-schema.js +0 -87
  391. package/dist/schemas/agent-template-schema.js.map +0 -1
  392. package/dist/services/conversation-service/index.d.ts +0 -88
  393. package/dist/services/conversation-service/index.d.ts.map +0 -1
  394. package/dist/services/conversation-service/index.js +0 -441
  395. package/dist/services/conversation-service/index.js.map +0 -1
  396. package/dist/services/conversation-service/types.d.ts +0 -32
  397. package/dist/services/conversation-service/types.d.ts.map +0 -1
  398. package/dist/services/conversation-service/types.js +0 -8
  399. package/dist/services/conversation-service/types.js.map +0 -1
  400. package/dist/services/event-service.d.ts +0 -61
  401. package/dist/services/event-service.d.ts.map +0 -1
  402. package/dist/services/event-service.js +0 -110
  403. package/dist/services/event-service.js.map +0 -1
  404. package/dist/services/event-service.test.d.ts +0 -2
  405. package/dist/services/event-service.test.d.ts.map +0 -1
  406. package/dist/services/event-service.test.js +0 -86
  407. package/dist/services/event-service.test.js.map +0 -1
  408. package/dist/services/execution-service.d.ts +0 -151
  409. package/dist/services/execution-service.d.ts.map +0 -1
  410. package/dist/services/execution-service.js +0 -1262
  411. package/dist/services/execution-service.js.map +0 -1
  412. package/dist/services/execution-service.test.d.ts +0 -2
  413. package/dist/services/execution-service.test.d.ts.map +0 -1
  414. package/dist/services/execution-service.test.js +0 -338
  415. package/dist/services/execution-service.test.js.map +0 -1
  416. package/dist/services/history-module.d.ts +0 -15
  417. package/dist/services/history-module.d.ts.map +0 -1
  418. package/dist/services/history-module.js +0 -42
  419. package/dist/services/history-module.js.map +0 -1
  420. package/dist/services/in-memory-history-store.d.ts +0 -12
  421. package/dist/services/in-memory-history-store.d.ts.map +0 -1
  422. package/dist/services/in-memory-history-store.js +0 -41
  423. package/dist/services/in-memory-history-store.js.map +0 -1
  424. package/dist/services/index.d.ts +0 -7
  425. package/dist/services/index.d.ts.map +0 -1
  426. package/dist/services/index.js +0 -13
  427. package/dist/services/index.js.map +0 -1
  428. package/dist/services/task-events.d.ts +0 -6
  429. package/dist/services/task-events.d.ts.map +0 -1
  430. package/dist/services/task-events.js +0 -6
  431. package/dist/services/task-events.js.map +0 -1
  432. package/dist/services/tool-execution-service.d.ts +0 -74
  433. package/dist/services/tool-execution-service.d.ts.map +0 -1
  434. package/dist/services/tool-execution-service.js +0 -189
  435. package/dist/services/tool-execution-service.js.map +0 -1
  436. package/dist/services/user-events.d.ts +0 -7
  437. package/dist/services/user-events.d.ts.map +0 -1
  438. package/dist/services/user-events.js +0 -6
  439. package/dist/services/user-events.js.map +0 -1
  440. package/dist/tools/implementations/function-tool/index.d.ts +0 -9
  441. package/dist/tools/implementations/function-tool/index.d.ts.map +0 -1
  442. package/dist/tools/implementations/function-tool/index.js +0 -13
  443. package/dist/tools/implementations/function-tool/index.js.map +0 -1
  444. package/dist/tools/implementations/function-tool/schema-converter.d.ts +0 -32
  445. package/dist/tools/implementations/function-tool/schema-converter.d.ts.map +0 -1
  446. package/dist/tools/implementations/function-tool/schema-converter.js +0 -164
  447. package/dist/tools/implementations/function-tool/schema-converter.js.map +0 -1
  448. package/dist/tools/implementations/function-tool/types.d.ts +0 -72
  449. package/dist/tools/implementations/function-tool/types.d.ts.map +0 -1
  450. package/dist/tools/implementations/function-tool/types.js +0 -14
  451. package/dist/tools/implementations/function-tool/types.js.map +0 -1
  452. package/dist/tools/implementations/function-tool.d.ts +0 -49
  453. package/dist/tools/implementations/function-tool.d.ts.map +0 -1
  454. package/dist/tools/implementations/function-tool.js +0 -223
  455. package/dist/tools/implementations/function-tool.js.map +0 -1
  456. package/dist/tools/implementations/index.d.ts +0 -4
  457. package/dist/tools/implementations/index.d.ts.map +0 -1
  458. package/dist/tools/implementations/index.js +0 -5
  459. package/dist/tools/implementations/index.js.map +0 -1
  460. package/dist/tools/implementations/mcp-tool.d.ts +0 -72
  461. package/dist/tools/implementations/mcp-tool.d.ts.map +0 -1
  462. package/dist/tools/implementations/mcp-tool.js +0 -246
  463. package/dist/tools/implementations/mcp-tool.js.map +0 -1
  464. package/dist/tools/implementations/openapi-tool.d.ts +0 -56
  465. package/dist/tools/implementations/openapi-tool.d.ts.map +0 -1
  466. package/dist/tools/implementations/openapi-tool.js +0 -324
  467. package/dist/tools/implementations/openapi-tool.js.map +0 -1
  468. package/dist/tools/implementations/relay-mcp-tool.d.ts +0 -38
  469. package/dist/tools/implementations/relay-mcp-tool.d.ts.map +0 -1
  470. package/dist/tools/implementations/relay-mcp-tool.js +0 -46
  471. package/dist/tools/implementations/relay-mcp-tool.js.map +0 -1
  472. package/dist/tools/index.d.ts +0 -3
  473. package/dist/tools/index.d.ts.map +0 -1
  474. package/dist/tools/index.js +0 -4
  475. package/dist/tools/index.js.map +0 -1
  476. package/dist/tools/registry/index.d.ts +0 -2
  477. package/dist/tools/registry/index.d.ts.map +0 -1
  478. package/dist/tools/registry/index.js +0 -3
  479. package/dist/tools/registry/index.js.map +0 -1
  480. package/dist/tools/registry/tool-registry.d.ts +0 -54
  481. package/dist/tools/registry/tool-registry.d.ts.map +0 -1
  482. package/dist/tools/registry/tool-registry.js +0 -146
  483. package/dist/tools/registry/tool-registry.js.map +0 -1
  484. package/dist/utils/errors.d.ts +0 -155
  485. package/dist/utils/errors.d.ts.map +0 -1
  486. package/dist/utils/errors.js +0 -203
  487. package/dist/utils/errors.js.map +0 -1
  488. package/dist/utils/execution-proxy.d.ts +0 -75
  489. package/dist/utils/execution-proxy.d.ts.map +0 -1
  490. package/dist/utils/execution-proxy.js +0 -230
  491. package/dist/utils/execution-proxy.js.map +0 -1
  492. package/dist/utils/index.d.ts +0 -11
  493. package/dist/utils/index.d.ts.map +0 -1
  494. package/dist/utils/index.js +0 -7
  495. package/dist/utils/index.js.map +0 -1
  496. package/dist/utils/logger.d.ts +0 -74
  497. package/dist/utils/logger.d.ts.map +0 -1
  498. package/dist/utils/logger.js +0 -143
  499. package/dist/utils/logger.js.map +0 -1
  500. package/dist/utils/message-converter.d.ts +0 -68
  501. package/dist/utils/message-converter.d.ts.map +0 -1
  502. package/dist/utils/message-converter.js +0 -87
  503. package/dist/utils/message-converter.js.map +0 -1
  504. package/dist/utils/periodic-task.d.ts +0 -14
  505. package/dist/utils/periodic-task.d.ts.map +0 -1
  506. package/dist/utils/periodic-task.js +0 -26
  507. package/dist/utils/periodic-task.js.map +0 -1
  508. package/dist/utils/validation.d.ts +0 -40
  509. package/dist/utils/validation.d.ts.map +0 -1
  510. package/dist/utils/validation.js +0 -162
  511. package/dist/utils/validation.js.map +0 -1
@@ -1,4238 +0,0 @@
1
- /**
2
- * Message Contracts (Single Source of Truth)
3
- *
4
- * IMPORTANT:
5
- * - This module is owned by the `interfaces` layer.
6
- * - All message types used across the SDK must be defined here to avoid drift.
7
- * - Runtime values (variables/classes/objects) and compile-time types can share the same name in TypeScript.
8
- * Prefixing type aliases (`T*`) and interfaces (`I*`) reduces value/type name collision risk and review overhead.
9
- */
10
- /**
11
- * Universal message role type - provider-independent neutral role.
12
- */
13
- type TUniversalMessageRole = 'user' | 'assistant' | 'system' | 'tool';
14
- /**
15
- * Message metadata used across conversation history and provider adapters.
16
- */
17
- type TUniversalMessageMetadata = Record<string, string | number | boolean | Date | string[] | number[] | Record<string, number>>;
18
- /**
19
- * Universal multimodal message part contracts.
20
- */
21
- interface ITextMessagePart {
22
- type: 'text';
23
- text: string;
24
- }
25
- interface IInlineImageMessagePart {
26
- type: 'image_inline';
27
- mimeType: string;
28
- data: string;
29
- }
30
- interface IUriImageMessagePart {
31
- type: 'image_uri';
32
- uri: string;
33
- mimeType?: string;
34
- }
35
- type TUniversalMessagePart = ITextMessagePart | IInlineImageMessagePart | IUriImageMessagePart;
36
- /**
37
- * Tool call (OpenAI tool calling format).
38
- */
39
- interface IToolCall {
40
- id: string;
41
- type: 'function';
42
- function: {
43
- name: string;
44
- arguments: string;
45
- };
46
- }
47
- /**
48
- * Base message contract shared by all message variants.
49
- */
50
- interface IBaseMessage {
51
- /** Message creation timestamp */
52
- timestamp: Date;
53
- /** Additional metadata */
54
- metadata?: TUniversalMessageMetadata;
55
- }
56
- interface IUserMessage extends IBaseMessage {
57
- role: 'user';
58
- content: string;
59
- parts?: TUniversalMessagePart[];
60
- name?: string;
61
- }
62
- interface IAssistantMessage extends IBaseMessage {
63
- role: 'assistant';
64
- /** Assistant response content (can be null when making tool calls) */
65
- content: string | null;
66
- parts?: TUniversalMessagePart[];
67
- toolCalls?: IToolCall[];
68
- }
69
- interface ISystemMessage extends IBaseMessage {
70
- role: 'system';
71
- content: string;
72
- parts?: TUniversalMessagePart[];
73
- name?: string;
74
- }
75
- interface IToolMessage extends IBaseMessage {
76
- role: 'tool';
77
- content: string;
78
- parts?: TUniversalMessagePart[];
79
- toolCallId: string;
80
- name?: string;
81
- }
82
- /**
83
- * Universal message union used across the SDK as the canonical contract.
84
- */
85
- type TUniversalMessage = IUserMessage | IAssistantMessage | ISystemMessage | IToolMessage;
86
- /**
87
- * Type guards for the canonical TUniversalMessage union.
88
- *
89
- * NOTE:
90
- * - These guards are owned by the `interfaces` layer and must not depend on managers/services.
91
- * - Call sites should use these guards instead of importing from manager layers.
92
- */
93
- declare function isUserMessage(message: TUniversalMessage): message is IUserMessage;
94
- declare function isAssistantMessage(message: TUniversalMessage): message is IAssistantMessage;
95
- declare function isSystemMessage(message: TUniversalMessage): message is ISystemMessage;
96
- declare function isToolMessage(message: TUniversalMessage): message is IToolMessage;
97
-
98
- /**
99
- * Agent-specific type definitions
100
- * Local types for agent functionality - not forced to use base types unless needed for cross-connections
101
- */
102
-
103
- /**
104
- * Primitive value types - foundation for all other types
105
- * Extended to include null/undefined for agent contexts
106
- */
107
- type TPrimitiveValue = string | number | boolean | null | undefined;
108
- /**
109
- * Universal value type axis (recursive, JSON-like + Date).
110
- *
111
- * IMPORTANT:
112
- * - This axis is the single source of truth for payload/context/result values.
113
- * - It must support nested objects/arrays without `any`/`unknown`.
114
- */
115
- type TUniversalValue = TPrimitiveValue | Date | TUniversalArrayValue | IUniversalObjectValue;
116
- type TUniversalArrayValue = TUniversalValue[];
117
- interface IUniversalObjectValue {
118
- [key: string]: TUniversalValue;
119
- }
120
- /**
121
- * Metadata type - consistent across agent components
122
- */
123
- type TMetadataValue = TPrimitiveValue | TUniversalArrayValue | Date;
124
- type TMetadata = Record<string, TMetadataValue>;
125
- /**
126
- * Context data type - for execution contexts
127
- */
128
- type TContextData = Record<string, TUniversalValue>;
129
- /**
130
- * Logger data type - for logging contexts
131
- */
132
- type TLoggerData = Record<string, TUniversalValue | Date | Error>;
133
- /**
134
- * Configuration types - for agent configuration
135
- */
136
- type TComplexConfigValue = Record<string, TPrimitiveValue | TUniversalArrayValue | IUniversalObjectValue>;
137
- type TConfigValue = TPrimitiveValue | TUniversalArrayValue | IUniversalObjectValue | Array<TComplexConfigValue> | Array<Record<string, TPrimitiveValue | TUniversalArrayValue | IUniversalObjectValue>> | Array<TComplexConfigValue> | TComplexConfigValue;
138
- type TConfigData = Record<string, TConfigValue>;
139
- /**
140
- * Tool parameter value type - specific for tool parameters
141
- */
142
- type TToolParameters = Record<string, TUniversalValue>;
143
- /**
144
- * Tool result data type - for tool execution results
145
- */
146
- /**
147
- * Plugin context type - for plugin execution contexts
148
- */
149
- interface IPluginContext {
150
- input?: string;
151
- response?: string;
152
- messages?: TUniversalMessage[];
153
- responseMessage?: TUniversalMessage;
154
- metadata?: TMetadata;
155
- error?: Error;
156
- executionContext?: TContextData;
157
- }
158
-
159
- /**
160
- * Reusable type definitions for provider layer
161
- */
162
- /**
163
- * Provider configuration value type
164
- * Used for storing provider-specific configuration values
165
- */
166
- type TProviderConfigValue = string | number | boolean;
167
- /**
168
- * JSON Schema parameter default value type
169
- * Used for default values in parameter schemas
170
- */
171
- type TParameterDefaultValue = string | number | boolean | null;
172
- /**
173
- * JSON Schema primitive types
174
- */
175
- type TJSONSchemaKind = 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object' | 'null';
176
- /**
177
- * JSON Schema enum values
178
- */
179
- type TJSONSchemaEnum = string[] | number[] | boolean[] | (string | number | boolean)[];
180
- /**
181
- * Tool schema definition
182
- */
183
- interface IToolSchema {
184
- name: string;
185
- description: string;
186
- parameters: {
187
- type: 'object';
188
- properties: Record<string, IParameterSchema>;
189
- required?: string[];
190
- };
191
- }
192
- /**
193
- * Parameter schema for tools
194
- */
195
- interface IParameterSchema {
196
- type: TJSONSchemaKind;
197
- description?: string;
198
- enum?: TJSONSchemaEnum;
199
- items?: IParameterSchema;
200
- properties?: Record<string, IParameterSchema>;
201
- additionalProperties?: IParameterSchema;
202
- minimum?: number;
203
- maximum?: number;
204
- pattern?: string;
205
- format?: string;
206
- default?: TParameterDefaultValue;
207
- }
208
- /**
209
- * Token usage statistics
210
- */
211
- interface ITokenUsage {
212
- promptTokens: number;
213
- completionTokens: number;
214
- totalTokens: number;
215
- }
216
- /**
217
- * Raw provider response interface
218
- */
219
- interface IRawProviderResponse {
220
- content: string | null;
221
- toolCalls?: IToolCall[];
222
- usage?: ITokenUsage;
223
- finishReason?: string;
224
- model?: string;
225
- metadata?: Record<string, TProviderConfigValue>;
226
- }
227
- /**
228
- * Provider request payload
229
- */
230
- interface IProviderRequest {
231
- messages: TUniversalMessage[];
232
- model?: string;
233
- temperature?: number;
234
- maxTokens?: number;
235
- tools?: IToolSchema[];
236
- systemMessage?: string;
237
- metadata?: Record<string, string | number | boolean>;
238
- }
239
- /**
240
- * Provider-specific configuration options
241
- */
242
- interface IProviderSpecificOptions {
243
- /** OpenAI specific options */
244
- openai?: {
245
- organization?: string;
246
- user?: string;
247
- stop?: string | string[];
248
- presencePenalty?: number;
249
- frequencyPenalty?: number;
250
- logitBias?: Record<string, number>;
251
- topP?: number;
252
- n?: number;
253
- stream?: boolean;
254
- suffix?: string;
255
- echo?: boolean;
256
- bestOf?: number;
257
- logprobs?: number;
258
- };
259
- /** Anthropic specific options */
260
- anthropic?: {
261
- stopSequences?: string[];
262
- topP?: number;
263
- topK?: number;
264
- metadata?: {
265
- userId?: string;
266
- };
267
- };
268
- /** Google specific options */
269
- google?: {
270
- candidateCount?: number;
271
- stopSequences?: string[];
272
- safetySettings?: Array<{
273
- category: string;
274
- threshold: string;
275
- }>;
276
- responseModalities?: Array<'TEXT' | 'IMAGE'>;
277
- topP?: number;
278
- topK?: number;
279
- };
280
- }
281
- /**
282
- * Callback for receiving text deltas during streaming.
283
- * Called for each text chunk as the model generates output.
284
- */
285
- type TTextDeltaCallback = (delta: string) => void;
286
- /**
287
- * Options for AI provider chat requests
288
- */
289
- interface IChatOptions extends IProviderSpecificOptions {
290
- /** Tool schemas to provide to the AI provider */
291
- tools?: IToolSchema[];
292
- /** Maximum number of tokens to generate */
293
- maxTokens?: number;
294
- /** Temperature for response randomness (0-1) */
295
- temperature?: number;
296
- /** Model to use for the request */
297
- model?: string;
298
- /** Callback for text deltas during streaming. When provided, the provider
299
- * should use streaming internally and call this for each text chunk,
300
- * while still returning the complete assembled message. */
301
- onTextDelta?: TTextDeltaCallback;
302
- }
303
- /**
304
- * Provider-agnostic AI Provider interface
305
- * This interface uses only TUniversalMessage types and avoids provider-specific types
306
- */
307
- interface IAIProvider {
308
- /** Provider identifier */
309
- readonly name: string;
310
- /** Provider version */
311
- readonly version: string;
312
- /**
313
- * Generate response from AI model using TUniversalMessage
314
- * @param messages - Array of TUniversalMessage from conversation history
315
- * @param options - Chat options including tools, model settings, etc.
316
- * @returns Promise resolving to a TUniversalMessage response
317
- */
318
- chat(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
319
- /**
320
- * Generate streaming response from AI model using TUniversalMessage
321
- * @param messages - Array of TUniversalMessage from conversation history
322
- * @param options - Chat options including tools, model settings, etc.
323
- * @returns AsyncIterable of TUniversalMessage chunks
324
- */
325
- chatStream?(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
326
- /**
327
- * Generate response from AI model (raw provider response)
328
- * @param payload - Provider request payload
329
- * @returns Promise resolving to raw provider response
330
- */
331
- generateResponse(payload: IProviderRequest): Promise<IRawProviderResponse>;
332
- /**
333
- * Generate streaming response from AI model (raw provider response)
334
- * @param payload - Provider request payload
335
- * @returns AsyncIterable of raw provider response chunks
336
- */
337
- generateStreamingResponse?(payload: IProviderRequest): AsyncIterable<IRawProviderResponse>;
338
- /**
339
- * Check if the provider supports tool calling
340
- * @returns true if tool calling is supported
341
- */
342
- supportsTools(): boolean;
343
- /**
344
- * Validate provider configuration
345
- * @returns true if configuration is valid
346
- */
347
- validateConfig(): boolean;
348
- /**
349
- * Clean up resources when provider is no longer needed
350
- */
351
- dispose?(): Promise<void>;
352
- /**
353
- * Close provider connections and cleanup resources
354
- */
355
- close?(): Promise<void>;
356
- }
357
- /**
358
- * Provider options interface
359
- */
360
- interface IProviderOptions {
361
- apiKey?: string;
362
- baseURL?: string;
363
- timeout?: number;
364
- retries?: number;
365
- maxConcurrentRequests?: number;
366
- defaultModel?: string;
367
- organization?: string;
368
- project?: string;
369
- /** Additional provider-specific configuration */
370
- extra?: Record<string, TProviderConfigValue>;
371
- }
372
- /**
373
- * Base union for provider option values.
374
- *
375
- * Purpose:
376
- * - Enable provider packages to compose their own option value unions without redefining the primitives.
377
- * - Keep the shared axis in @robota-sdk/agent-core (SSOT).
378
- *
379
- * Note:
380
- * - Provider packages may extend this with provider-specific runtime objects (e.g., OpenAI/Anthropic clients).
381
- */
382
- type TProviderOptionValueBase = string | number | boolean | undefined | null | TProviderOptionValueBase[] | {
383
- [key: string]: TProviderOptionValueBase;
384
- };
385
-
386
- /**
387
- * @fileoverview Event service interface definitions.
388
- *
389
- * These interfaces are the single source of truth for event-related contracts
390
- * within @robota-sdk/agent-core.
391
- */
392
- /**
393
- * Primitive value types for event payloads.
394
- */
395
- type TEventPrimitiveValue = string | number | boolean | null | undefined;
396
- /**
397
- * Recursive universal value type for event payloads (JSON-like + Date).
398
- */
399
- type TEventUniversalValue = TEventPrimitiveValue | Date | TEventUniversalValue[] | IEventObjectValue;
400
- interface IEventObjectValue {
401
- [key: string]: TEventUniversalValue;
402
- }
403
- /**
404
- * Logger data type for event metadata.
405
- */
406
- type TEventLoggerData = Record<string, TEventUniversalValue | Date | Error>;
407
- /**
408
- * A single segment in an explicit ownerPath.
409
- *
410
- * Path-only rule:
411
- * - Relationships must be derived from these explicit segments, not from parsing IDs.
412
- */
413
- interface IOwnerPathSegment {
414
- type: string;
415
- id: string;
416
- }
417
- /**
418
- * Event context that accompanies an emitted event.
419
- * This is the single source of truth for deterministic linking in subscribers.
420
- */
421
- interface IEventContext {
422
- ownerType: string;
423
- ownerId: string;
424
- ownerPath: IOwnerPathSegment[];
425
- /** Depth of the current execution in the hierarchy (0 = root) */
426
- depth?: number;
427
- /** Unique span identifier for distributed tracing correlation */
428
- spanId?: string;
429
- /** Optional structured metadata for debugging/observability */
430
- metadata?: TEventLoggerData;
431
- }
432
- /**
433
- * Allowed extension values for event payloads.
434
- */
435
- type TEventExtensionValue = TEventUniversalValue | TEventLoggerData | Error | IEventContext | IOwnerPathSegment[];
436
- /**
437
- * Base event payload shape.
438
- * Emitters may add additional fields, but MUST keep linkage information explicit.
439
- */
440
- interface IBaseEventData {
441
- /** Timestamp when the event was emitted. This is required for deterministic ordering. */
442
- timestamp: Date;
443
- /** Optional structured metadata */
444
- metadata?: TEventLoggerData;
445
- /** Extensible fields for event-specific payloads */
446
- [key: string]: TEventExtensionValue | undefined;
447
- }
448
- /**
449
- * Execution-related event payload.
450
- */
451
- interface IExecutionEventData extends IBaseEventData {
452
- }
453
- /**
454
- * Tool-related event payload.
455
- */
456
- interface IToolEventData extends IBaseEventData {
457
- toolName?: string;
458
- parameters?: Record<string, TEventUniversalValue>;
459
- }
460
- /**
461
- * Agent-related event payload.
462
- */
463
- interface IAgentEventData extends IBaseEventData {
464
- agentId?: string;
465
- }
466
- type TEventListener = (eventType: string, data: IBaseEventData, context?: IEventContext) => void;
467
- /**
468
- * Minimal EventService contract for emitting events.
469
- */
470
- interface IEventService {
471
- emit(eventType: string, data: IBaseEventData, context?: IEventContext): void;
472
- subscribe(listener: TEventListener): void;
473
- unsubscribe(listener: TEventListener): void;
474
- }
475
- /**
476
- * Explicit owner binding information used for scoped event emission.
477
- */
478
- interface IEventServiceOwnerBinding {
479
- ownerType: string;
480
- ownerId: string;
481
- ownerPath: IOwnerPathSegment[];
482
- }
483
-
484
- type TToolContextExtensionValue = TUniversalValue | Date | Error | TLoggerData | TContextData | TToolParameters | TToolMetadata;
485
- /**
486
- * Tool metadata structure - specific type definition
487
- */
488
- type TToolMetadata = Record<string, string | number | boolean | string[] | number[] | boolean[] | TToolParameters>;
489
- /**
490
- * Tool execution data - domain payload for tool results.
491
- *
492
- * IMPORTANT:
493
- * - This must support structured tool outputs without resorting to `any`.
494
- * - Prefer `ToolResultData` (derived from the canonical `UniversalValue` axis).
495
- */
496
- /**
497
- * Tool execution result - extended for ToolExecutionData compatibility
498
- */
499
- interface IToolResult {
500
- success: boolean;
501
- data?: TUniversalValue;
502
- error?: string;
503
- metadata?: TToolMetadata;
504
- [key: string]: TToolContextExtensionValue | undefined;
505
- }
506
- /**
507
- * Enhanced tool execution result with additional metadata
508
- */
509
- interface IToolExecutionResult {
510
- /** Whether execution was successful */
511
- success: boolean;
512
- /** Tool name that was executed */
513
- toolName?: string;
514
- /** Execution result or data */
515
- result?: TUniversalValue;
516
- /** Error message if execution failed */
517
- error?: string;
518
- /** Execution duration in milliseconds */
519
- duration?: number;
520
- /** Unique execution ID */
521
- executionId?: string;
522
- /** Additional metadata */
523
- metadata?: TToolMetadata;
524
- }
525
- /**
526
- * Tool execution context - type-safe context for tool execution
527
- * Enhanced with hierarchical execution tracking support
528
- */
529
- interface IToolExecutionContext {
530
- toolName: string;
531
- parameters: TToolParameters;
532
- executionId?: string;
533
- userId?: string;
534
- sessionId?: string;
535
- metadata?: TToolMetadata;
536
- /** Parent execution ID for hierarchical tool execution tracking */
537
- parentExecutionId?: string;
538
- /** Root execution ID (Team/Agent level) for complete execution tree tracking */
539
- rootExecutionId?: string;
540
- /** Execution depth level (0: Team, 1: Agent, 2: Tool, etc.) */
541
- executionLevel?: number;
542
- /** Execution path array showing the complete execution hierarchy */
543
- executionPath?: string[];
544
- /** Real-time execution data for accurate tracking (no simulation) */
545
- realTimeData?: {
546
- /** Actual execution start time */
547
- startTime: Date;
548
- /** Actual input parameters passed to the tool */
549
- actualParameters: TToolParameters;
550
- /** Tool-provided estimated duration (optional) */
551
- estimatedDuration?: number;
552
- };
553
- /**
554
- * Additional tool execution context extensions.
555
- *
556
- * IMPORTANT:
557
- * - Avoid ad-hoc top-level fields to keep the contract stable.
558
- * - Use this map for forward-compatible extra data with constrained value types.
559
- */
560
- extensions?: Record<string, TToolContextExtensionValue>;
561
- /** Owner context propagated from EventService */
562
- ownerType?: string;
563
- ownerId?: string;
564
- ownerPath?: IOwnerPathSegment[];
565
- sourceId?: string;
566
- /**
567
- * Tool-call scoped EventService instance.
568
- * Caller (ExecutionService/ToolExecutionService) is responsible for providing
569
- * an ownerPath-bound EventService for this tool call.
570
- */
571
- eventService?: IEventService;
572
- /**
573
- * Unbound base EventService instance.
574
- *
575
- * Required when a tool needs to create another owner-bound EventService
576
- * for a different owner (e.g., creating an agent from a tool call).
577
- *
578
- * NOTE: Do not wrap an already owner-bound EventService to bind a different owner.
579
- * Owner-bound instances must not be layered across different owners.
580
- */
581
- baseEventService?: IEventService;
582
- }
583
- /**
584
- * Parameter validation result
585
- */
586
- interface IParameterValidationResult {
587
- /** Whether parameters are valid */
588
- isValid: boolean;
589
- /** Validation error messages */
590
- errors: string[];
591
- }
592
- /**
593
- * Generic tool executor function
594
- */
595
- type TToolExecutor<TParams = TToolParameters, TResult = TUniversalValue> = (parameters: TParams, context?: IToolExecutionContext) => Promise<TResult>;
596
- /**
597
- * OpenAPI specification configuration
598
- */
599
- interface IOpenAPIToolConfig {
600
- /** OpenAPI 3.0 specification */
601
- spec: {
602
- openapi: string;
603
- info: {
604
- title: string;
605
- version: string;
606
- description?: string;
607
- };
608
- servers?: Array<{
609
- url: string;
610
- description?: string;
611
- }>;
612
- paths: Record<string, Record<string, string | number | boolean | Record<string, string | number | boolean>>>;
613
- components?: Record<string, Record<string, string | number | boolean>>;
614
- };
615
- /** Operation ID from the OpenAPI spec */
616
- operationId: string;
617
- /** Base URL for API calls */
618
- baseURL: string;
619
- /** Authentication configuration */
620
- auth?: {
621
- type: 'bearer' | 'apiKey' | 'basic';
622
- token?: string;
623
- apiKey?: string;
624
- header?: string;
625
- username?: string;
626
- password?: string;
627
- };
628
- }
629
- /**
630
- * MCP (Model Context Protocol) configuration
631
- */
632
- interface IMCPToolConfig {
633
- /** MCP server endpoint */
634
- endpoint: string;
635
- /** Protocol version */
636
- version?: string;
637
- /** Authentication configuration */
638
- auth?: {
639
- type: 'bearer' | 'apiKey';
640
- token: string;
641
- };
642
- /** Tool-specific configuration */
643
- toolConfig?: Record<string, string | number | boolean>;
644
- /** Timeout in milliseconds */
645
- timeout?: number;
646
- }
647
- /**
648
- * Base tool interface
649
- */
650
- interface ITool {
651
- /** Tool schema */
652
- schema: IToolSchema;
653
- /**
654
- * Execute the tool with given parameters
655
- */
656
- execute(parameters: TToolParameters, context?: IToolExecutionContext): Promise<IToolResult>;
657
- /**
658
- * Validate tool parameters
659
- */
660
- validate(parameters: TToolParameters): boolean;
661
- /**
662
- * Validate tool parameters with detailed result
663
- */
664
- validateParameters(parameters: TToolParameters): IParameterValidationResult;
665
- /**
666
- * Get tool description
667
- */
668
- getDescription(): string;
669
- }
670
- /**
671
- * Function tool implementation
672
- */
673
- interface IFunctionTool extends ITool {
674
- /** Function to execute */
675
- fn: TToolExecutor;
676
- }
677
- /**
678
- * Tool registry interface
679
- */
680
- interface IToolRegistry {
681
- /**
682
- * Register a tool
683
- */
684
- register(tool: ITool): void;
685
- /**
686
- * Unregister a tool
687
- */
688
- unregister(name: string): void;
689
- /**
690
- * Get tool by name
691
- */
692
- get(name: string): ITool | undefined;
693
- /**
694
- * Get all registered tools
695
- */
696
- getAll(): ITool[];
697
- /**
698
- * Get tool schemas
699
- */
700
- getSchemas(): IToolSchema[];
701
- /**
702
- * Check if tool exists
703
- */
704
- has(name: string): boolean;
705
- /**
706
- * Clear all tools
707
- */
708
- clear(): void;
709
- }
710
- /**
711
- * Tool factory interface
712
- */
713
- interface IToolFactory {
714
- /**
715
- * Create function tool from schema and function
716
- */
717
- createFunctionTool(schema: IToolSchema, fn: TToolExecutor): IFunctionTool;
718
- /**
719
- * Create tool from OpenAPI specification
720
- */
721
- createOpenAPITool(config: IOpenAPIToolConfig): ITool;
722
- /**
723
- * Create MCP tool
724
- */
725
- createMCPTool(config: IMCPToolConfig): ITool;
726
- }
727
-
728
- declare const EXECUTION_EVENT_NAMES: {
729
- readonly START: "execution.start";
730
- readonly COMPLETE: "execution.complete";
731
- readonly ERROR: "execution.error";
732
- };
733
- declare const TOOL_EVENT_NAMES: {
734
- readonly CALL_START: "tool.call_start";
735
- readonly CALL_COMPLETE: "tool.call_complete";
736
- readonly CALL_ERROR: "tool.call_error";
737
- };
738
- declare const AGENT_EVENT_NAMES: {
739
- readonly EXECUTION_START: "agent.execution_start";
740
- readonly EXECUTION_COMPLETE: "agent.execution_complete";
741
- readonly EXECUTION_ERROR: "agent.execution_error";
742
- readonly CREATED: "agent.created";
743
- };
744
- type TExecutionEventName = (typeof EXECUTION_EVENT_NAMES)[keyof typeof EXECUTION_EVENT_NAMES];
745
- type TToolEventName = (typeof TOOL_EVENT_NAMES)[keyof typeof TOOL_EVENT_NAMES];
746
- type TAgentEventName = (typeof AGENT_EVENT_NAMES)[keyof typeof AGENT_EVENT_NAMES];
747
- /**
748
- * Event types that can be emitted.
749
- *
750
- * IMPORTANT:
751
- * - Do not use string literals for event names outside this module.
752
- * - Import and use EVENT_EMITTER_EVENTS instead.
753
- */
754
- declare const EVENT_EMITTER_EVENTS: {
755
- readonly EXECUTION_START: "execution.start";
756
- readonly EXECUTION_COMPLETE: "execution.complete";
757
- readonly EXECUTION_ERROR: "execution.error";
758
- readonly TOOL_BEFORE_EXECUTE: "tool.beforeExecute";
759
- readonly TOOL_AFTER_EXECUTE: "tool.afterExecute";
760
- readonly TOOL_SUCCESS: "tool.success";
761
- readonly TOOL_ERROR: "tool.call_error";
762
- readonly CONVERSATION_START: "conversation.start";
763
- readonly CONVERSATION_COMPLETE: "conversation.complete";
764
- readonly CONVERSATION_ERROR: "conversation.error";
765
- readonly AGENT_EXECUTION_START: "agent.execution_start";
766
- readonly AGENT_EXECUTION_COMPLETE: "agent.execution_complete";
767
- readonly AGENT_EXECUTION_ERROR: "agent.execution_error";
768
- readonly AGENT_CREATED: "agent.created";
769
- readonly AGENT_DESTROYED: "agent.destroyed";
770
- readonly PLUGIN_LOADED: "plugin.loaded";
771
- readonly PLUGIN_UNLOADED: "plugin.unloaded";
772
- readonly PLUGIN_ERROR: "plugin.error";
773
- readonly ERROR_OCCURRED: "error.occurred";
774
- readonly WARNING_OCCURRED: "warning.occurred";
775
- readonly MODULE_INITIALIZE_START: "module.initialize.start";
776
- readonly MODULE_INITIALIZE_COMPLETE: "module.initialize.complete";
777
- readonly MODULE_INITIALIZE_ERROR: "module.initialize.error";
778
- readonly MODULE_EXECUTION_START: "module.execution.start";
779
- readonly MODULE_EXECUTION_COMPLETE: "module.execution.complete";
780
- readonly MODULE_EXECUTION_ERROR: "module.execution.error";
781
- readonly MODULE_DISPOSE_START: "module.dispose.start";
782
- readonly MODULE_DISPOSE_COMPLETE: "module.dispose.complete";
783
- readonly MODULE_DISPOSE_ERROR: "module.dispose.error";
784
- readonly MODULE_REGISTERED: "module.registered";
785
- readonly MODULE_UNREGISTERED: "module.unregistered";
786
- readonly EXECUTION_HIERARCHY: "execution.hierarchy";
787
- readonly EXECUTION_REALTIME: "execution.realtime";
788
- readonly TOOL_REALTIME: "tool.realtime";
789
- readonly CUSTOM: "custom";
790
- };
791
- type TEventName = TExecutionEventName | TToolEventName | TAgentEventName | 'tool.beforeExecute' | 'tool.afterExecute' | 'tool.success' | 'conversation.start' | 'conversation.complete' | 'conversation.error' | 'agent.destroyed' | 'plugin.loaded' | 'plugin.unloaded' | 'plugin.error' | 'error.occurred' | 'warning.occurred' | 'module.initialize.start' | 'module.initialize.complete' | 'module.initialize.error' | 'module.execution.start' | 'module.execution.complete' | 'module.execution.error' | 'module.dispose.start' | 'module.dispose.complete' | 'module.dispose.error' | 'module.registered' | 'module.unregistered' | 'execution.hierarchy' | 'execution.realtime' | 'tool.realtime' | 'custom';
792
- /**
793
- * Valid event data value types
794
- */
795
- type TEventDataValue = string | number | boolean | Date | null | undefined | TEventDataValue[] | {
796
- [key: string]: TEventDataValue;
797
- };
798
- /**
799
- * Event data structure
800
- */
801
- interface IEventEmitterEventData {
802
- type: TEventName;
803
- timestamp: Date;
804
- executionId?: string;
805
- sessionId?: string;
806
- userId?: string;
807
- data?: Record<string, TEventDataValue>;
808
- error?: Error;
809
- metadata?: Record<string, TEventDataValue>;
810
- }
811
- /**
812
- * Event listener function
813
- */
814
- type TEventEmitterListener = (event: IEventEmitterEventData) => void | Promise<void>;
815
- /**
816
- * Console-like interface for the EventEmitterPlugin.
817
- *
818
- * Use this interface for typing instead of the concrete EventEmitterPlugin class.
819
- */
820
- interface IEventEmitterPlugin {
821
- on(eventType: TEventName, listener: TEventEmitterListener, options?: {
822
- once?: boolean;
823
- filter?: (event: IEventEmitterEventData) => boolean;
824
- }): string;
825
- once(eventType: TEventName, listener: TEventEmitterListener, filter?: (event: IEventEmitterEventData) => boolean): string;
826
- off(eventType: TEventName, handlerIdOrListener: string | TEventEmitterListener): boolean;
827
- emit(eventType: TEventName, eventData?: Partial<IEventEmitterEventData>): Promise<void>;
828
- }
829
-
830
- /**
831
- * Reusable type definitions for logger utility
832
- */
833
- /**
834
- * Log levels for the logger
835
- */
836
- type TUtilLogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
837
- /**
838
- * Log entry structure
839
- */
840
- interface IUtilLogEntry {
841
- timestamp: string;
842
- level: TUtilLogLevel;
843
- message: string;
844
- context?: TLoggerData;
845
- packageName?: string;
846
- }
847
- /**
848
- * Logger interface
849
- */
850
- interface ILogger {
851
- debug(...args: Array<TUniversalValue | TLoggerData | Error>): void;
852
- info(...args: Array<TUniversalValue | TLoggerData | Error>): void;
853
- warn(...args: Array<TUniversalValue | TLoggerData | Error>): void;
854
- error(...args: Array<TUniversalValue | TLoggerData | Error>): void;
855
- log(...args: Array<TUniversalValue | TLoggerData | Error>): void;
856
- group?(label?: string): void;
857
- groupEnd?(): void;
858
- }
859
- /**
860
- * Silent logger that does nothing (Null Object Pattern)
861
- *
862
- * IMPORTANT:
863
- * - This library must not write to stdio by default.
864
- * - Inject a real logger explicitly if you want output.
865
- */
866
- declare const SilentLogger: ILogger;
867
- /**
868
- * Create a named logger instance for a package or module.
869
- * Use this to create loggers with a specific name prefix for easy log filtering.
870
- */
871
- declare function createLogger(packageName: string, logger?: ILogger): ILogger;
872
- /**
873
- * Set global log level for all loggers
874
- */
875
- declare function setGlobalLogLevel(level: TUtilLogLevel): void;
876
- /**
877
- * Get global log level
878
- */
879
- declare function getGlobalLogLevel(): TUtilLogLevel;
880
- /**
881
- * Default logger for the agents package
882
- */
883
- declare const logger: ILogger;
884
-
885
- /**
886
- * Type definitions for AbstractPlugin.
887
- *
888
- * Extracted from abstract-plugin.ts to keep each file under 300 lines.
889
- */
890
-
891
- /** Plugin categories for classification */
892
- declare enum PluginCategory {
893
- MONITORING = "monitoring",
894
- LOGGING = "logging",
895
- STORAGE = "storage",
896
- NOTIFICATION = "notification",
897
- SECURITY = "security",
898
- PERFORMANCE = "performance",
899
- ERROR_HANDLING = "error_handling",
900
- LIMITS = "limits",
901
- EVENT_PROCESSING = "event_processing",
902
- CUSTOM = "custom"
903
- }
904
- /** Plugin priority levels */
905
- declare enum PluginPriority {
906
- CRITICAL = 1000,
907
- HIGH = 800,
908
- NORMAL = 500,
909
- LOW = 200,
910
- MINIMAL = 100
911
- }
912
- /** Plugin execution context for all plugins */
913
- interface IPluginExecutionContext {
914
- executionId?: string;
915
- sessionId?: string;
916
- userId?: string;
917
- messages?: TUniversalMessage[];
918
- config?: Record<string, string | number | boolean>;
919
- metadata?: Record<string, string | number | boolean | Date>;
920
- [key: string]: string | number | boolean | Date | string[] | number[] | boolean[] | TUniversalMessage[] | Record<string, string | number | boolean> | Record<string, string | number | boolean | Date> | undefined;
921
- }
922
- /** Plugin execution result for all plugins */
923
- interface IPluginExecutionResult {
924
- response?: string;
925
- content?: string;
926
- duration?: number;
927
- tokensUsed?: number;
928
- toolsExecuted?: number;
929
- success?: boolean;
930
- usage?: {
931
- totalTokens?: number;
932
- promptTokens?: number;
933
- completionTokens?: number;
934
- };
935
- toolCalls?: Array<{
936
- id?: string;
937
- name?: string;
938
- arguments?: Record<string, string | number | boolean>;
939
- result?: string | number | boolean | null;
940
- }>;
941
- results?: Array<{
942
- id?: string;
943
- type?: string;
944
- data?: string | number | boolean | null;
945
- success?: boolean;
946
- }>;
947
- error?: Error;
948
- metadata?: Record<string, string | number | boolean | Date>;
949
- }
950
- /** Error context for plugin error handling */
951
- interface IPluginErrorContext {
952
- action: string;
953
- tool?: string;
954
- parameters?: TToolParameters;
955
- result?: IToolExecutionResult;
956
- error?: Error;
957
- executionId?: string;
958
- sessionId?: string;
959
- userId?: string;
960
- timestamp?: Date;
961
- attempt?: number;
962
- stack?: string;
963
- metadata?: Record<string, string | number | boolean>;
964
- }
965
- /** Plugin configuration interface */
966
- interface IPluginConfig extends IPluginOptions {
967
- options?: Record<string, string | number | boolean>;
968
- }
969
- /** Plugin options that all plugin options should extend */
970
- interface IPluginOptions {
971
- enabled?: boolean;
972
- category?: PluginCategory;
973
- priority?: PluginPriority | number;
974
- moduleEvents?: TEventName[];
975
- subscribeToAllModuleEvents?: boolean;
976
- }
977
- /** Plugin data interface */
978
- interface IPluginData {
979
- name: string;
980
- version: string;
981
- enabled: boolean;
982
- category: PluginCategory;
983
- priority: number;
984
- subscribedEvents: TEventName[];
985
- metadata?: Record<string, string | number | boolean>;
986
- }
987
- /** Type-safe plugin interface with specific type parameters */
988
- interface IPluginContract<TOptions extends IPluginOptions = IPluginOptions, TStats = IPluginStats> {
989
- name: string;
990
- version: string;
991
- enabled: boolean;
992
- category: PluginCategory;
993
- priority: number;
994
- initialize(options?: TOptions): Promise<void>;
995
- cleanup?(): Promise<void>;
996
- getData?(): IPluginData;
997
- getStats?(): TStats;
998
- subscribeToModuleEvents?(eventEmitter: IEventEmitterPlugin): Promise<void>;
999
- unsubscribeFromModuleEvents?(eventEmitter: IEventEmitterPlugin): Promise<void>;
1000
- onModuleEvent?(eventName: TEventName, eventData: IEventEmitterEventData): Promise<void> | void;
1001
- }
1002
- /** Plugin statistics base interface with common metrics */
1003
- interface IPluginStats {
1004
- enabled: boolean;
1005
- calls: number;
1006
- errors: number;
1007
- lastActivity?: Date;
1008
- moduleEventsReceived?: number;
1009
- [key: string]: string | number | boolean | Date | string[] | number[] | boolean[] | Record<string, string | number | boolean | Date> | undefined;
1010
- }
1011
- /** Plugin interface extending IPluginContract */
1012
- interface IPlugin extends IPluginContract<IPluginConfig, IPluginStats> {
1013
- }
1014
- /** Plugin lifecycle hooks */
1015
- interface IPluginHooks {
1016
- beforeRun?(input: string, options?: IRunOptions): Promise<void> | void;
1017
- afterRun?(input: string, response: string, options?: IRunOptions): Promise<void> | void;
1018
- beforeExecution?(context: IPluginExecutionContext): Promise<void> | void;
1019
- afterExecution?(context: IPluginExecutionContext, result: IPluginExecutionResult): Promise<void> | void;
1020
- beforeConversation?(context: IPluginExecutionContext): Promise<void> | void;
1021
- afterConversation?(context: IPluginExecutionContext, result: IPluginExecutionResult): Promise<void> | void;
1022
- beforeToolCall?(toolName: string, parameters: TToolParameters): Promise<void> | void;
1023
- beforeToolExecution?(context: IPluginExecutionContext, toolData: IToolExecutionContext): Promise<void> | void;
1024
- afterToolCall?(toolName: string, parameters: TToolParameters, result: IToolExecutionResult): Promise<void> | void;
1025
- afterToolExecution?(context: IPluginExecutionContext, toolResults: IPluginExecutionResult): Promise<void> | void;
1026
- beforeProviderCall?(messages: TUniversalMessage[]): Promise<void> | void;
1027
- afterProviderCall?(messages: TUniversalMessage[], response: TUniversalMessage): Promise<void> | void;
1028
- onStreamingChunk?(chunk: TUniversalMessage): Promise<void> | void;
1029
- onError?(error: Error, context?: IPluginErrorContext): Promise<void> | void;
1030
- onMessageAdded?(message: TUniversalMessage): Promise<void> | void;
1031
- onModuleEvent?(eventName: TEventName, eventData: IEventEmitterEventData): Promise<void> | void;
1032
- }
1033
-
1034
- /**
1035
- * Abstract class for all plugins with type parameter support.
1036
- *
1037
- * Type definitions live in ./abstract-plugin-types.ts.
1038
- */
1039
-
1040
- /**
1041
- * Abstract class for all plugins with type parameter support.
1042
- * Provides plugin lifecycle management and common functionality.
1043
- * @template TOptions - Plugin options type that extends IPluginOptions
1044
- * @template TStats - Plugin statistics type
1045
- */
1046
- declare abstract class AbstractPlugin<TOptions extends IPluginOptions = IPluginOptions, TStats extends IPluginStats = IPluginStats> implements IPluginContract<TOptions, TStats>, IPluginHooks {
1047
- abstract readonly name: string;
1048
- abstract readonly version: string;
1049
- enabled: boolean;
1050
- category: PluginCategory;
1051
- priority: number;
1052
- protected options: TOptions | undefined;
1053
- protected eventEmitter: IEventEmitterPlugin | undefined;
1054
- protected subscribedEvents: TEventName[];
1055
- protected eventHandlers: Map<TEventName, string[]>;
1056
- protected readonly pluginLogger: ILogger;
1057
- protected stats: {
1058
- calls: number;
1059
- errors: number;
1060
- moduleEventsReceived: number;
1061
- lastActivity: Date | undefined;
1062
- };
1063
- initialize(options?: TOptions): Promise<void>;
1064
- subscribeToModuleEvents(eventEmitter: IEventEmitterPlugin): Promise<void>;
1065
- unsubscribeFromModuleEvents(eventEmitter: IEventEmitterPlugin): Promise<void>;
1066
- dispose(): Promise<void>;
1067
- enable(): void;
1068
- disable(): void;
1069
- isEnabled(): boolean;
1070
- getConfig(): IPluginConfig;
1071
- updateConfig(_config: IPluginConfig): void;
1072
- getData(): IPluginData;
1073
- clearData?(): void;
1074
- getStatus(): {
1075
- name: string;
1076
- version: string;
1077
- enabled: boolean;
1078
- initialized: boolean;
1079
- category: PluginCategory;
1080
- priority: number;
1081
- subscribedEventsCount: number;
1082
- hasEventEmitter: boolean;
1083
- };
1084
- getStats(): TStats;
1085
- protected updateCallStats(): void;
1086
- protected updateErrorStats(): void;
1087
- beforeRun?(input: string, options?: IRunOptions): Promise<void>;
1088
- afterRun?(input: string, response: string, options?: IRunOptions): Promise<void>;
1089
- beforeExecution?(context: IPluginExecutionContext): Promise<void>;
1090
- afterExecution?(context: IPluginExecutionContext, result: IPluginExecutionResult): Promise<void>;
1091
- beforeConversation?(context: IPluginExecutionContext): Promise<void>;
1092
- afterConversation?(context: IPluginExecutionContext, result: IPluginExecutionResult): Promise<void>;
1093
- beforeToolCall?(toolName: string, parameters: TToolParameters): Promise<void>;
1094
- beforeToolExecution?(context: IPluginExecutionContext, toolData: IToolExecutionContext): Promise<void>;
1095
- afterToolCall?(toolName: string, parameters: TToolParameters, result: IToolExecutionResult): Promise<void>;
1096
- afterToolExecution?(context: IPluginExecutionContext, toolResults: IPluginExecutionResult): Promise<void>;
1097
- beforeProviderCall?(messages: TUniversalMessage[]): Promise<void>;
1098
- afterProviderCall?(messages: TUniversalMessage[], response: TUniversalMessage): Promise<void>;
1099
- onStreamingChunk?(chunk: TUniversalMessage): Promise<void>;
1100
- onError?(error: Error, context?: IPluginErrorContext): Promise<void>;
1101
- onMessageAdded?(message: TUniversalMessage): Promise<void>;
1102
- onModuleEvent?(eventName: TEventName, eventData: IEventEmitterEventData): Promise<void>;
1103
- }
1104
-
1105
- /**
1106
- * Type definitions, interfaces, and enums for the module system.
1107
- *
1108
- * Extracted from abstract-module.ts to keep each file under 300 lines.
1109
- */
1110
-
1111
- /** Module execution context */
1112
- interface IModuleExecutionContext {
1113
- executionId?: string;
1114
- sessionId?: string;
1115
- userId?: string;
1116
- agentName?: string;
1117
- metadata?: Record<string, string | number | boolean | Date>;
1118
- [key: string]: string | number | boolean | Date | Record<string, string | number | boolean | Date> | undefined;
1119
- }
1120
- /** Module execution result */
1121
- interface IModuleExecutionResult {
1122
- success: boolean;
1123
- data?: IModuleResultData;
1124
- error?: Error;
1125
- duration?: number;
1126
- metadata?: Record<string, string | number | boolean | Date>;
1127
- }
1128
- /** Module result data */
1129
- interface IModuleResultData {
1130
- [key: string]: string | number | boolean | Record<string, string | number | boolean> | undefined;
1131
- }
1132
- /** Base module options */
1133
- interface IBaseModuleOptions {
1134
- enabled?: boolean;
1135
- config?: Record<string, string | number | boolean>;
1136
- }
1137
- /** Module capabilities */
1138
- interface IModuleCapabilities {
1139
- capabilities: string[];
1140
- dependencies?: string[];
1141
- optionalDependencies?: string[];
1142
- }
1143
- /** Module type descriptor */
1144
- interface IModuleDescriptor {
1145
- type: string;
1146
- category: ModuleCategory;
1147
- layer: ModuleLayer;
1148
- dependencies?: string[];
1149
- capabilities?: string[];
1150
- }
1151
- /** Module categories */
1152
- declare enum ModuleCategory {
1153
- CORE = "core",
1154
- STORAGE = "storage",
1155
- PROCESSING = "processing",
1156
- INTEGRATION = "integration",
1157
- INTERFACE = "interface",
1158
- CAPABILITY = "capability"
1159
- }
1160
- /** Module layers */
1161
- declare enum ModuleLayer {
1162
- INFRASTRUCTURE = "infrastructure",
1163
- CORE = "core",
1164
- APPLICATION = "application",
1165
- DOMAIN = "domain",
1166
- PRESENTATION = "presentation"
1167
- }
1168
- /** Module data for introspection */
1169
- interface IModuleData {
1170
- name: string;
1171
- version: string;
1172
- type: string;
1173
- enabled: boolean;
1174
- initialized: boolean;
1175
- capabilities: IModuleCapabilities;
1176
- metadata?: Record<string, string | number | boolean>;
1177
- }
1178
- /** Module statistics */
1179
- interface IModuleStats {
1180
- enabled: boolean;
1181
- initialized: boolean;
1182
- executionCount: number;
1183
- errorCount: number;
1184
- lastActivity?: Date;
1185
- averageExecutionTime?: number;
1186
- [key: string]: string | number | boolean | Date | undefined;
1187
- }
1188
- /** Type-safe module interface */
1189
- interface IModule<TOptions extends IBaseModuleOptions = IBaseModuleOptions, TStats = IModuleStats> {
1190
- name: string;
1191
- version: string;
1192
- enabled: boolean;
1193
- initialize(options?: TOptions, eventEmitter?: IEventEmitterPlugin): Promise<void>;
1194
- dispose?(): Promise<void>;
1195
- execute?(context: IModuleExecutionContext): Promise<IModuleExecutionResult>;
1196
- getModuleType(): IModuleDescriptor;
1197
- getCapabilities(): IModuleCapabilities;
1198
- getData?(): IModuleData;
1199
- getStats?(): TStats;
1200
- isEnabled(): boolean;
1201
- isInitialized(): boolean;
1202
- }
1203
-
1204
- /**
1205
- * @fileoverview Abstract Tool Base Class
1206
- *
1207
- * 🎯 ABSTRACT CLASS - DO NOT DEPEND ON CONCRETE IMPLEMENTATIONS
1208
- *
1209
- * This is a pure abstract base class that defines the interface and common behavior
1210
- * for all tools. It follows strict architectural principles:
1211
- *
1212
- * - Depends ONLY on interfaces (EventService interface, not concrete implementations)
1213
- * - Does NOT import concrete classes
1214
- * - Uses Dependency Injection for all dependencies
1215
- * - Handles undefined dependencies gracefully (Null Object Pattern)
1216
- *
1217
- * Concrete implementations should be handled
1218
- * by the caller who creates the tool instance, not by this abstract class.
1219
- *
1220
- * @example
1221
- * ```typescript
1222
- * // ✅ CORRECT: Caller prepares an owner-bound EventService and injects it
1223
- * // (Example: bind to the current tool call identity and ownerPath.)
1224
- * const toolEventService = bindWithOwnerPath(baseEventService, {
1225
- * ownerType: 'tool',
1226
- * ownerId: toolCallId,
1227
- * ownerPath,
1228
- * });
1229
- * const tool = new MyTool({ eventService: toolEventService });
1230
- *
1231
- * // ❌ WRONG: AbstractTool creates concrete EventService
1232
- * // This violates Dependency Inversion Principle
1233
- * ```
1234
- */
1235
-
1236
- /**
1237
- * Options for AbstractTool construction
1238
- */
1239
- interface IAbstractToolOptions {
1240
- /**
1241
- * Optional logger for tool operations
1242
- * Defaults to SilentLogger if not provided
1243
- */
1244
- logger?: ILogger;
1245
- /**
1246
- * Optional event service for unified event emission
1247
- * If not provided, tool will operate silently without emitting events
1248
- *
1249
- * The caller should provide an EventService configured with appropriate settings
1250
- * (e.g., ownerPrefix='tool' for tool events)
1251
- *
1252
- * @since 2.1.0
1253
- */
1254
- eventService?: IEventService;
1255
- }
1256
- /**
1257
- * Tool execution function type with proper parameter constraints
1258
- */
1259
- type TToolExecutionFunction<TParams = TToolParameters, TResult = IToolResult> = (parameters: TParams) => Promise<TResult> | TResult;
1260
- /**
1261
- * Abstract tool interface with type parameters for enhanced type safety
1262
- *
1263
- * @template TParams - Tool parameters type (defaults to AbstractToolParameters for backward compatibility)
1264
- * @template TResult - Tool result type (defaults to ToolResult for backward compatibility)
1265
- */
1266
- interface IAbstractTool<TParams = TToolParameters, TResult = IToolResult> {
1267
- name: string;
1268
- description: string;
1269
- parameters: IToolSchema['parameters'];
1270
- execute: TToolExecutionFunction<TParams, TResult>;
1271
- }
1272
- /**
1273
- * Type-safe tool interface with type parameters
1274
- *
1275
- * @template TParameters - Tool parameters type (defaults to AbstractToolParameters for backward compatibility)
1276
- * @template TResult - Tool result type (defaults to ToolResult for backward compatibility)
1277
- */
1278
- interface IToolContract<TParameters = TToolParameters, TResult = IToolResult> {
1279
- readonly schema: IToolSchema;
1280
- execute(parameters: TParameters, context: IToolExecutionContext): Promise<TResult>;
1281
- validate(parameters: TParameters): boolean;
1282
- validateParameters(parameters: TParameters): IParameterValidationResult;
1283
- getDescription(): string;
1284
- getName(): string;
1285
- }
1286
- /**
1287
- * Runtime tool instance contract used by Robota internals.
1288
- *
1289
- * Tools passed into Agent configuration must support EventService injection
1290
- * so Robota can emit unified tool lifecycle events.
1291
- */
1292
- interface IToolWithEventService<TParameters = TToolParameters, TResult = IToolResult> extends IToolContract<TParameters, TResult> {
1293
- setEventService(eventService: IEventService | undefined): void;
1294
- }
1295
- /**
1296
- * Abstract base class for tools with type parameter support
1297
- * Provides type-safe parameter handling and result processing
1298
- *
1299
- * 🎯 ARCHITECTURAL PRINCIPLES:
1300
- * - Pure abstract class - depends only on interfaces
1301
- * - No concrete class dependencies (EventService interface only)
1302
- * - Dependency Injection for all external dependencies
1303
- * - Graceful degradation (undefined dependencies = silent operation)
1304
- *
1305
- * @template TParameters - Tool parameters type (defaults to TToolParameters)
1306
- * @template TResult - Tool result type (defaults to ToolResult for backward compatibility)
1307
- */
1308
- declare abstract class AbstractTool<TParameters = TToolParameters, TResult = IToolResult> implements IToolWithEventService<TParameters, TResult> {
1309
- abstract readonly schema: IToolSchema;
1310
- /**
1311
- * Logger for tool operations
1312
- */
1313
- protected readonly logger: ILogger;
1314
- /**
1315
- * EventService for direct event emission (optional)
1316
- * If undefined, tool operates silently without emitting events
1317
- */
1318
- private eventService;
1319
- /**
1320
- * Constructor with simplified options
1321
- *
1322
- * 🎯 DEPENDENCY INJECTION:
1323
- * All dependencies are injected via options parameter
1324
- * No concrete classes are instantiated within this constructor
1325
- *
1326
- * @param options - Configuration options for the tool
1327
- */
1328
- constructor(options?: IAbstractToolOptions);
1329
- /**
1330
- * Set EventService for post-construction injection
1331
- *
1332
- * 🎯 DEPENDENCY INJECTION:
1333
- * Accepts EventService as-is without transformation
1334
- * Caller is responsible for providing properly configured EventService
1335
- *
1336
- * @param eventService - EventService instance to use for event emission (or undefined for silent operation)
1337
- */
1338
- setEventService(eventService: IEventService | undefined): void;
1339
- /**
1340
- * Get current EventService (for testing/inspection)
1341
- */
1342
- protected getEventService(): IEventService | undefined;
1343
- /**
1344
- * Emit event through EventService (if available)
1345
- * If EventService is not available, silently ignores the event (Null Object Pattern)
1346
- *
1347
- * @param eventType - Type of event to emit
1348
- * @param data - Event data
1349
- */
1350
- protected emitEvent(eventType: string, data: IBaseEventData): void;
1351
- /**
1352
- * Execute tool with simplified lifecycle
1353
- * @param parameters - Tool parameters
1354
- * @param context - Optional execution context
1355
- * @returns Promise resolving to tool result
1356
- */
1357
- execute(parameters: TParameters, context: IToolExecutionContext): Promise<TResult>;
1358
- /**
1359
- * Concrete implementation of tool execution
1360
- * This method should be implemented by subclasses to provide actual tool logic
1361
- *
1362
- * @param parameters - Tool parameters
1363
- * @param context - Optional execution context
1364
- * @returns Promise resolving to tool result
1365
- */
1366
- protected abstract executeImpl(parameters: TParameters, context: IToolExecutionContext): Promise<TResult>;
1367
- validate(parameters: TParameters): boolean;
1368
- /**
1369
- * Validate tool parameters with detailed result (default implementation)
1370
- */
1371
- validateParameters(parameters: TParameters): IParameterValidationResult;
1372
- getDescription(): string;
1373
- getName(): string;
1374
- }
1375
-
1376
- /**
1377
- * Cache key identifying a unique LLM execution request
1378
- */
1379
- interface ICacheKey {
1380
- /** SHA-256 hash of the serialized request */
1381
- hash: string;
1382
- /** Model identifier */
1383
- model: string;
1384
- /** Provider name */
1385
- provider: string;
1386
- }
1387
- /**
1388
- * Cached LLM response entry
1389
- */
1390
- interface ICacheEntry {
1391
- /** Cache key that produced this entry */
1392
- key: ICacheKey;
1393
- /** Cached response content */
1394
- response: string;
1395
- /** When the entry was cached */
1396
- timestamp: number;
1397
- /** SHA-256 integrity hash of the response */
1398
- integrityHash: string;
1399
- }
1400
- /**
1401
- * Cache storage interface for pluggable backends
1402
- */
1403
- interface ICacheStorage {
1404
- /** Retrieve a cached entry by key hash */
1405
- get(hash: string): ICacheEntry | undefined;
1406
- /** Store a cache entry */
1407
- set(entry: ICacheEntry): void;
1408
- /** Delete a cached entry by key hash */
1409
- delete(hash: string): boolean;
1410
- /** Clear all cached entries */
1411
- clear(): void;
1412
- /** Get cache statistics */
1413
- getStats(): ICacheStats;
1414
- }
1415
- /**
1416
- * Cache performance statistics
1417
- */
1418
- interface ICacheStats {
1419
- /** Number of cache hits */
1420
- hits: number;
1421
- /** Number of cache misses */
1422
- misses: number;
1423
- /** Current number of cached entries */
1424
- entries: number;
1425
- /** Hit rate (hits / (hits + misses)), 0 if no lookups */
1426
- hitRate: number;
1427
- }
1428
- /**
1429
- * Configuration options for execution caching
1430
- */
1431
- interface ICacheOptions {
1432
- /** Whether caching is enabled */
1433
- enabled: boolean;
1434
- /** Maximum number of cached entries */
1435
- maxEntries: number;
1436
- /** Time-to-live in milliseconds */
1437
- ttlMs: number;
1438
- }
1439
-
1440
- /**
1441
- * IExecutionContextInjection
1442
- *
1443
- * Minimal context payload used to inject an existing ownerPath into a new agent instance
1444
- * (e.g., when a tool creates an agent and must preserve absolute ownerPath semantics).
1445
- *
1446
- * NOTE: This is intentionally NOT ToolExecutionContext. ToolExecutionContext is for tool calls
1447
- * and requires toolName/parameters; agent creation only needs ownerPath and execution linkage.
1448
- */
1449
- interface IExecutionContextInjection {
1450
- ownerPath?: IOwnerPathSegment[];
1451
- parentExecutionId?: string;
1452
- rootExecutionId?: string;
1453
- executionLevel?: number;
1454
- sourceId?: string;
1455
- }
1456
- /**
1457
- * Provider-specific configuration
1458
- */
1459
- interface IAgentProviderConfig {
1460
- openai?: {
1461
- apiKey?: string;
1462
- baseURL?: string;
1463
- organization?: string;
1464
- [key: string]: TProviderConfigValue | undefined;
1465
- };
1466
- anthropic?: {
1467
- apiKey?: string;
1468
- baseURL?: string;
1469
- [key: string]: TProviderConfigValue | undefined;
1470
- };
1471
- google?: {
1472
- apiKey?: string;
1473
- projectId?: string;
1474
- location?: string;
1475
- [key: string]: TProviderConfigValue | undefined;
1476
- };
1477
- [provider: string]: Record<string, TProviderConfigValue | undefined> | undefined;
1478
- }
1479
- /**
1480
- * Agent configuration options - New design with aiProviders array and defaultModel
1481
- */
1482
- interface IAgentConfig {
1483
- id?: string;
1484
- name: string;
1485
- aiProviders: IAIProvider[];
1486
- defaultModel: {
1487
- provider: string;
1488
- model: string;
1489
- temperature?: number;
1490
- maxTokens?: number;
1491
- topP?: number;
1492
- systemMessage?: string;
1493
- };
1494
- tools?: Array<IToolWithEventService>;
1495
- plugins?: Array<IPluginContract<IPluginOptions, IPluginStats>>;
1496
- modules?: IModule[];
1497
- systemMessage?: string;
1498
- systemPrompt?: string;
1499
- conversationId?: string;
1500
- sessionId?: string;
1501
- userId?: string;
1502
- metadata?: TUniversalMessageMetadata;
1503
- context?: Record<string, TConfigValue>;
1504
- logging?: {
1505
- level?: TUtilLogLevel;
1506
- enabled?: boolean;
1507
- format?: string;
1508
- destination?: string;
1509
- };
1510
- providerConfig?: IAgentProviderConfig;
1511
- stream?: boolean;
1512
- toolChoice?: 'auto' | 'none' | string;
1513
- responseFormat?: IResponseFormatConfig;
1514
- safetySettings?: ISafetySetting[];
1515
- timeout?: number;
1516
- retryAttempts?: number;
1517
- rateLimiting?: {
1518
- enabled?: boolean;
1519
- maxRequests?: number;
1520
- windowMs?: number;
1521
- };
1522
- eventService?: IEventService;
1523
- executionContext?: IExecutionContextInjection;
1524
- cache?: ICacheOptions;
1525
- }
1526
- /**
1527
- * Agent template interface
1528
- */
1529
- interface IAgentTemplate {
1530
- id: string;
1531
- name: string;
1532
- description?: string;
1533
- category?: string;
1534
- tags?: string[];
1535
- config: IAgentConfig;
1536
- version?: string;
1537
- author?: string;
1538
- createdAt?: Date;
1539
- updatedAt?: Date;
1540
- }
1541
- /**
1542
- * Agent run options - type-safe interface for all agent execution options
1543
- */
1544
- interface IRunOptions {
1545
- temperature?: number;
1546
- maxTokens?: number;
1547
- stream?: boolean;
1548
- toolChoice?: 'auto' | 'none' | string;
1549
- sessionId?: string;
1550
- userId?: string;
1551
- metadata?: TMetadata;
1552
- }
1553
- /**
1554
- * Generic agent interface with type parameters for enhanced type safety
1555
- *
1556
- * @template TConfig - Agent configuration type (defaults to IAgentConfig for backward compatibility)
1557
- * @template TContext - Execution context type (defaults to IRunOptions for backward compatibility)
1558
- * @template TUniversalMessage - Message type (defaults to TUniversalMessage for backward compatibility)
1559
- */
1560
- interface IAgent<TConfig = IAgentConfig, TContext = IRunOptions, TMessage = TUniversalMessage> {
1561
- /**
1562
- * Configure the agent with type-safe configuration
1563
- */
1564
- configure?(config: TConfig): Promise<void>;
1565
- /**
1566
- * Run agent with user input and type-safe context
1567
- */
1568
- run(input: string, context?: TContext): Promise<string>;
1569
- /**
1570
- * Run agent with streaming response and type-safe context
1571
- */
1572
- runStream(input: string, context?: TContext): AsyncGenerator<string, void, never>;
1573
- /**
1574
- * Get conversation history with type-safe messages
1575
- */
1576
- getHistory(): TMessage[];
1577
- /**
1578
- * Clear conversation history
1579
- */
1580
- clearHistory(): void;
1581
- }
1582
- /**
1583
- * Response format configuration
1584
- */
1585
- interface IResponseFormatConfig {
1586
- type?: 'text' | 'json_object';
1587
- schema?: Record<string, TConfigValue>;
1588
- }
1589
- /**
1590
- * Safety setting configuration
1591
- */
1592
- interface ISafetySetting {
1593
- category: string;
1594
- threshold: string;
1595
- [key: string]: TConfigValue;
1596
- }
1597
-
1598
- /**
1599
- * Provider-agnostic media output reference.
1600
- * Providers must not return raw binary payloads in this contract.
1601
- */
1602
- interface IMediaOutputRef {
1603
- kind: 'asset' | 'uri';
1604
- assetId?: string;
1605
- uri?: string;
1606
- mimeType?: string;
1607
- bytes?: number;
1608
- }
1609
- interface IProviderMediaError {
1610
- code: 'PROVIDER_AUTH_ERROR' | 'PROVIDER_RATE_LIMITED' | 'PROVIDER_TIMEOUT' | 'PROVIDER_INVALID_REQUEST' | 'PROVIDER_UPSTREAM_ERROR' | 'PROVIDER_JOB_NOT_FOUND' | 'PROVIDER_JOB_NOT_CANCELLABLE';
1611
- message: string;
1612
- details?: Record<string, TUniversalValue>;
1613
- }
1614
- type TProviderMediaResult<TValue> = {
1615
- ok: true;
1616
- value: TValue;
1617
- } | {
1618
- ok: false;
1619
- error: IProviderMediaError;
1620
- };
1621
- interface IInlineImageInputSource {
1622
- kind: 'inline';
1623
- mimeType: string;
1624
- data: string;
1625
- }
1626
- interface IUriImageInputSource {
1627
- kind: 'uri';
1628
- uri: string;
1629
- mimeType?: string;
1630
- }
1631
- type TImageInputSource = IInlineImageInputSource | IUriImageInputSource;
1632
- interface IImageGenerationRequest {
1633
- prompt: string;
1634
- model: string;
1635
- }
1636
- interface IImageEditRequest {
1637
- image: TImageInputSource;
1638
- prompt: string;
1639
- model: string;
1640
- }
1641
- interface IImageComposeRequest {
1642
- images: TImageInputSource[];
1643
- prompt: string;
1644
- model: string;
1645
- }
1646
- interface IImageGenerationResult {
1647
- outputs: IMediaOutputRef[];
1648
- model: string;
1649
- }
1650
- interface IImageGenerationProvider {
1651
- generateImage(request: IImageGenerationRequest): Promise<TProviderMediaResult<IImageGenerationResult>>;
1652
- editImage?(request: IImageEditRequest): Promise<TProviderMediaResult<IImageGenerationResult>>;
1653
- composeImage?(request: IImageComposeRequest): Promise<TProviderMediaResult<IImageGenerationResult>>;
1654
- }
1655
- interface IVideoGenerationRequest {
1656
- prompt: string;
1657
- model: string;
1658
- durationSeconds?: number;
1659
- aspectRatio?: string;
1660
- seed?: number;
1661
- inputImages?: TImageInputSource[];
1662
- }
1663
- interface IVideoJobAccepted {
1664
- jobId: string;
1665
- status: 'queued' | 'running';
1666
- createdAt: string;
1667
- }
1668
- interface IVideoJobSnapshot {
1669
- jobId: string;
1670
- status: 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled';
1671
- output?: IMediaOutputRef;
1672
- error?: IProviderMediaError;
1673
- updatedAt: string;
1674
- }
1675
- interface IVideoGenerationProvider {
1676
- createVideo(request: IVideoGenerationRequest): Promise<TProviderMediaResult<IVideoJobAccepted>>;
1677
- getVideoJob(jobId: string): Promise<TProviderMediaResult<IVideoJobSnapshot>>;
1678
- cancelVideoJob(jobId: string): Promise<TProviderMediaResult<IVideoJobSnapshot>>;
1679
- }
1680
- declare function isImageGenerationProvider(provider: object): provider is IImageGenerationProvider;
1681
- declare function isVideoGenerationProvider(provider: object): provider is IVideoGenerationProvider;
1682
-
1683
- /**
1684
- * Reusable type definitions for manager layer
1685
- */
1686
- /**
1687
- * Agent creation metadata type
1688
- * Used for storing additional information about agent creation and configuration
1689
- */
1690
- type TAgentCreationMetadata = Record<string, string | number | boolean | Date>;
1691
- /**
1692
- * Tool execution parameters for manager operations
1693
- * Used for tool parameter validation and execution in manager context
1694
- */
1695
- type TManagerToolParameters = Record<string, string | number | boolean | string[] | number[] | boolean[]>;
1696
- /**
1697
- * Configuration validation result
1698
- */
1699
- interface IConfigValidationResult {
1700
- isValid: boolean;
1701
- errors: string[];
1702
- warnings?: string[];
1703
- }
1704
- /**
1705
- * AI Provider Manager interface for provider registration and selection
1706
- */
1707
- interface IAIProviderManager {
1708
- /**
1709
- * Register an AI provider
1710
- */
1711
- addProvider(name: string, provider: IAIProvider): void;
1712
- /**
1713
- * Remove an AI provider
1714
- */
1715
- removeProvider(name: string): void;
1716
- /**
1717
- * Get registered provider by name
1718
- */
1719
- getProvider(name: string): IAIProvider | undefined;
1720
- /**
1721
- * Get all registered providers
1722
- */
1723
- getProviders(): Record<string, IAIProvider>;
1724
- /**
1725
- * Set current provider and model
1726
- */
1727
- setCurrentProvider(name: string, model: string): void;
1728
- /**
1729
- * Get current provider and model
1730
- */
1731
- getCurrentProvider(): {
1732
- provider: string;
1733
- model: string;
1734
- } | undefined;
1735
- /**
1736
- * Check if provider is configured
1737
- */
1738
- isConfigured(): boolean;
1739
- /**
1740
- * Get available models for a provider
1741
- */
1742
- getAvailableModels(providerName: string): string[];
1743
- }
1744
- /**
1745
- * Tool Manager interface for tool registration and management
1746
- */
1747
- interface IToolManager {
1748
- /**
1749
- * Register a tool
1750
- */
1751
- addTool(schema: IToolSchema, executor: TToolExecutor): void;
1752
- /**
1753
- * Remove a tool by name
1754
- */
1755
- removeTool(name: string): void;
1756
- /**
1757
- * Get tool interface by name
1758
- */
1759
- getTool(name: string): ITool | undefined;
1760
- /**
1761
- * Get tool schema by name
1762
- */
1763
- getToolSchema(name: string): IToolSchema | undefined;
1764
- /**
1765
- * Get all registered tools
1766
- */
1767
- getTools(): IToolSchema[];
1768
- /**
1769
- * Execute a tool
1770
- */
1771
- executeTool(name: string, parameters: TToolParameters, context?: IToolExecutionContext): Promise<TUniversalValue>;
1772
- /**
1773
- * Check if tool exists
1774
- */
1775
- hasTool(name: string): boolean;
1776
- /**
1777
- * Set allowed tools (for filtering)
1778
- */
1779
- setAllowedTools(tools: string[]): void;
1780
- /**
1781
- * Get allowed tools
1782
- */
1783
- getAllowedTools(): string[] | undefined;
1784
- }
1785
- /**
1786
- * Agent creation options
1787
- */
1788
- interface IAgentCreationOptions {
1789
- /** Override default configuration */
1790
- overrides?: Partial<IAgentConfig>;
1791
- /** Validation options */
1792
- validation?: {
1793
- strict?: boolean;
1794
- skipOptional?: boolean;
1795
- };
1796
- /** Additional metadata */
1797
- metadata?: TAgentCreationMetadata;
1798
- }
1799
- /**
1800
- * Agent Factory interface for agent creation and configuration
1801
- */
1802
- interface IAgentFactory {
1803
- /**
1804
- * Create agent instance
1805
- */
1806
- createAgent(config: IAgentConfig, options?: IAgentCreationOptions): IAgent<IAgentConfig>;
1807
- /**
1808
- * Validate agent configuration
1809
- */
1810
- validateConfig(config: IAgentConfig): IConfigValidationResult;
1811
- /**
1812
- * Get default configuration
1813
- */
1814
- getDefaultConfig(): IAgentConfig;
1815
- /**
1816
- * Merge configurations
1817
- */
1818
- mergeConfig(base: IAgentConfig, override: Partial<IAgentConfig>): IAgentConfig;
1819
- }
1820
-
1821
- /**
1822
- * Execution step definition for tools that support step-by-step progress reporting
1823
- */
1824
- interface IToolExecutionStep {
1825
- /** Unique identifier for this step */
1826
- id: string;
1827
- /** Human-readable name of the step */
1828
- name: string;
1829
- /** Tool-provided estimated duration for this step in milliseconds */
1830
- estimatedDuration: number;
1831
- /** Optional description of what this step does */
1832
- description?: string;
1833
- }
1834
- /**
1835
- * Progress callback function type for real-time progress updates
1836
- */
1837
- type TToolProgressCallback = (step: string, progress: number) => void;
1838
- /**
1839
- * 🆕 IProgressReportingTool - Optional interface for tools that can provide their own progress information
1840
- *
1841
- * This interface extends the standard ITool to allow tools to optionally provide:
1842
- * - Estimated execution duration
1843
- * - Step-by-step execution plans
1844
- * - Real-time progress callbacks
1845
- *
1846
- * Benefits:
1847
- * - Tools can provide accurate progress information based on their internal knowledge
1848
- * - No simulation or fake progress - only real tool-provided estimates
1849
- * - Completely optional - existing tools work unchanged
1850
- * - Tools can self-report progress for better user experience
1851
- */
1852
- interface IProgressReportingTool extends ITool {
1853
- /**
1854
- * Get estimated execution duration for given parameters (optional)
1855
- *
1856
- * Tools can implement this to provide accurate time estimates based on:
1857
- * - Parameter complexity (e.g., search query length, file size)
1858
- * - Historical execution data
1859
- * - Internal optimization knowledge
1860
- *
1861
- * @param parameters - The parameters that will be passed to execute()
1862
- * @returns Estimated duration in milliseconds, or undefined if not available
1863
- */
1864
- getEstimatedDuration?(parameters: TToolParameters): number;
1865
- /**
1866
- * Get execution steps for given parameters (optional)
1867
- *
1868
- * Tools can implement this to provide step-by-step execution plans:
1869
- * - webSearch: [query processing, API call, result parsing, filtering]
1870
- * - fileSearch: [file scanning, content reading, pattern matching, result formatting]
1871
- * - github-mcp: [authentication, API request, response processing, data transformation]
1872
- *
1873
- * @param parameters - The parameters that will be passed to execute()
1874
- * @returns Array of execution steps, or undefined if not available
1875
- */
1876
- getExecutionSteps?(parameters: TToolParameters): IToolExecutionStep[];
1877
- /**
1878
- * Set progress callback for real-time updates (optional)
1879
- *
1880
- * Tools can implement this to provide real-time progress updates during execution:
1881
- * - Called when each step starts/completes
1882
- * - Progress value between 0-100 representing completion percentage
1883
- * - Step name helps users understand what's currently happening
1884
- *
1885
- * @param callback - Function to call with progress updates
1886
- */
1887
- setProgressCallback?(callback: TToolProgressCallback): void;
1888
- }
1889
- /**
1890
- * Type guard to check if a tool implements progress reporting
1891
- */
1892
- declare function isProgressReportingTool(tool: ITool): tool is IProgressReportingTool;
1893
- /**
1894
- * Helper function to safely get estimated duration from any tool
1895
- */
1896
- declare function getToolEstimatedDuration(tool: ITool, parameters: TToolParameters): number | undefined;
1897
- /**
1898
- * Helper function to safely get execution steps from any tool
1899
- */
1900
- declare function getToolExecutionSteps(tool: ITool, parameters: TToolParameters): IToolExecutionStep[] | undefined;
1901
- /**
1902
- * Helper function to safely set progress callback on any tool
1903
- */
1904
- declare function setToolProgressCallback(tool: ITool, callback: TToolProgressCallback): boolean;
1905
-
1906
- /**
1907
- * Service layer interfaces for the agents package
1908
- * Defines contracts for stateless service implementations
1909
- */
1910
-
1911
- /**
1912
- * Reusable type definitions for service layer
1913
- */
1914
- /**
1915
- * Metadata type for conversation and execution context
1916
- * Used for storing additional information about conversations, responses, and execution
1917
- */
1918
- type TConversationContextMetadata = Record<string, string | number | boolean | Date>;
1919
- /**
1920
- * Tool execution parameters type
1921
- * Used for passing parameters to tool execution methods
1922
- */
1923
- type TToolExecutionParameters = Record<string, string | number | boolean | string[] | number[] | boolean[]>;
1924
- /**
1925
- * Execution metadata type
1926
- * Used for storing metadata about execution processes and options
1927
- */
1928
- type TExecutionMetadata = Record<string, string | number | boolean | Date>;
1929
- /**
1930
- * Response metadata type
1931
- * Used for storing metadata about AI provider responses and streaming chunks
1932
- */
1933
- type TResponseMetadata = Record<string, string | number | boolean | Date>;
1934
- /**
1935
- * Tool call data structure for function calls
1936
- */
1937
- /**
1938
- * Tool execution request
1939
- */
1940
- interface IToolExecutionRequest {
1941
- toolName: string;
1942
- parameters: TToolParameters;
1943
- executionId?: string;
1944
- metadata?: TToolMetadata;
1945
- ownerType?: string;
1946
- ownerId?: string;
1947
- ownerPath?: IOwnerPathSegment[];
1948
- eventService?: IEventService;
1949
- baseEventService?: IEventService;
1950
- }
1951
- /**
1952
- * Conversation context containing messages and metadata
1953
- */
1954
- interface IConversationContext {
1955
- /** All messages in the conversation */
1956
- messages: TUniversalMessage[];
1957
- /** System message for the conversation */
1958
- systemMessage?: string;
1959
- /** Model to use for generation */
1960
- model: string;
1961
- /** Provider to use for generation */
1962
- provider: string;
1963
- /** Temperature for generation */
1964
- temperature?: number;
1965
- /** Maximum tokens to generate */
1966
- maxTokens?: number;
1967
- /** Available tools */
1968
- tools?: IToolSchema[];
1969
- /** Additional metadata */
1970
- metadata?: TConversationContextMetadata;
1971
- }
1972
- /**
1973
- * Response from AI provider
1974
- */
1975
- interface IConversationResponse {
1976
- /** Generated content */
1977
- content: string;
1978
- /** Tool calls if any */
1979
- toolCalls?: IToolCall[];
1980
- /** Usage statistics */
1981
- usage?: {
1982
- promptTokens: number;
1983
- completionTokens: number;
1984
- totalTokens: number;
1985
- };
1986
- /** Response metadata */
1987
- metadata?: TResponseMetadata;
1988
- /** Finish reason */
1989
- finishReason?: string;
1990
- }
1991
- /**
1992
- * Streaming response chunk
1993
- */
1994
- interface IStreamingChunk {
1995
- /** Content delta */
1996
- delta: string;
1997
- /** Whether this is the final chunk */
1998
- done: boolean;
1999
- /** Tool calls if any */
2000
- toolCalls?: IToolCall[];
2001
- /** Usage statistics (only in final chunk) */
2002
- usage?: {
2003
- promptTokens: number;
2004
- completionTokens: number;
2005
- totalTokens: number;
2006
- };
2007
- }
2008
- /**
2009
- * Service options for conversation operations
2010
- */
2011
- interface IConversationServiceOptions {
2012
- /** Maximum conversation history length */
2013
- maxHistoryLength?: number;
2014
- /** Whether to automatically retry on failure */
2015
- enableRetry?: boolean;
2016
- /** Maximum number of retries */
2017
- maxRetries?: number;
2018
- /** Retry delay in milliseconds */
2019
- retryDelay?: number;
2020
- /** Request timeout in milliseconds */
2021
- timeout?: number;
2022
- }
2023
- /**
2024
- * Context options for conversation preparation
2025
- */
2026
- interface IContextOptions {
2027
- systemMessage?: string;
2028
- temperature?: number;
2029
- maxTokens?: number;
2030
- tools?: IToolSchema[];
2031
- metadata?: TConversationContextMetadata;
2032
- }
2033
- /**
2034
- * Execution service options
2035
- */
2036
- interface IExecutionServiceOptions {
2037
- /** Maximum number of tool execution rounds */
2038
- maxToolRounds?: number;
2039
- /** Tool execution timeout */
2040
- toolTimeout?: number;
2041
- /** Whether to enable parallel tool execution */
2042
- enableParallelExecution?: boolean;
2043
- /** Additional execution metadata */
2044
- metadata?: TExecutionMetadata;
2045
- }
2046
- /**
2047
- * Interface for conversation service operations
2048
- * All methods should be stateless and pure functions
2049
- */
2050
- interface IConversationService {
2051
- /**
2052
- * Prepare conversation context from messages and configuration
2053
- * Pure function that transforms inputs to context object
2054
- */
2055
- prepareContext(messages: TUniversalMessage[], model: string, provider: string, contextOptions?: IContextOptions, serviceOptions?: IConversationServiceOptions): IConversationContext;
2056
- /**
2057
- * Generate a response using the AI provider
2058
- * Stateless operation that handles the full request-response cycle
2059
- */
2060
- generateResponse(provider: IAIProvider, context: IConversationContext, serviceOptions?: IConversationServiceOptions): Promise<IConversationResponse>;
2061
- /**
2062
- * Generate streaming response using the AI provider
2063
- * Stateless streaming operation
2064
- */
2065
- generateStreamingResponse(provider: IAIProvider, context: IConversationContext, serviceOptions?: IConversationServiceOptions): AsyncGenerator<IStreamingChunk, void, never>;
2066
- /**
2067
- * Validate conversation context
2068
- * Pure validation function
2069
- */
2070
- validateContext(context: IConversationContext): {
2071
- isValid: boolean;
2072
- errors: string[];
2073
- };
2074
- }
2075
- /**
2076
- * Interface for tool execution service operations
2077
- */
2078
- interface IToolExecutionService {
2079
- /**
2080
- * Execute a single tool
2081
- */
2082
- executeTool(toolName: string, parameters: TToolParameters): Promise<TUniversalValue>;
2083
- /**
2084
- * Execute multiple tools in parallel
2085
- */
2086
- executeToolsParallel(toolCalls: IToolExecutionRequest[]): Promise<TUniversalValue[]>;
2087
- /**
2088
- * Execute multiple tools sequentially
2089
- */
2090
- executeToolsSequential(toolCalls: IToolExecutionRequest[]): Promise<TUniversalValue[]>;
2091
- }
2092
- /**
2093
- * Interface for execution service operations
2094
- */
2095
- interface IExecutionService {
2096
- /**
2097
- * Execute complete agent pipeline
2098
- */
2099
- execute(input: string, context: IConversationContext, options?: IExecutionServiceOptions): Promise<string>;
2100
- /**
2101
- * Execute streaming agent pipeline
2102
- */
2103
- executeStream(input: string, context: IConversationContext, options?: IExecutionServiceOptions): AsyncGenerator<string, void, never>;
2104
- }
2105
-
2106
- /**
2107
- * Request for executing a streaming chat completion through an executor
2108
- */
2109
- interface IChatExecutionRequest {
2110
- /** Array of messages in the conversation */
2111
- messages: TUniversalMessage[];
2112
- /** Chat options including model, temperature, etc. */
2113
- options?: IChatOptions;
2114
- /** Available tools for the AI to use */
2115
- tools?: IToolSchema[];
2116
- /** Target AI provider (e.g., 'openai', 'anthropic', 'google') */
2117
- provider: string;
2118
- /** Specific model to use */
2119
- model: string;
2120
- }
2121
- /**
2122
- * Request for executing a streaming chat completion through an executor
2123
- */
2124
- interface IStreamExecutionRequest extends IChatExecutionRequest {
2125
- /** Indicates this is a streaming request */
2126
- stream: true;
2127
- }
2128
- /**
2129
- * Interface for executing AI provider operations
2130
- *
2131
- * Executors abstract the execution mechanism, allowing providers to work
2132
- * with either local API calls or remote server calls transparently.
2133
- *
2134
- * Implementation patterns:
2135
- * - LocalExecutor: Direct API calls using provider SDKs
2136
- * - RemoteExecutor: HTTP/WebSocket calls to remote server
2137
- * - CacheExecutor: Cached responses with explicit error propagation
2138
- * - HybridExecutor: Conditional local/remote execution
2139
- */
2140
- interface IExecutor {
2141
- /**
2142
- * Execute a chat completion request
2143
- *
2144
- * @param request - Chat execution request with messages, options, and tools
2145
- * @returns Promise resolving to assistant message response
2146
- *
2147
- * @example
2148
- * ```typescript
2149
- * const response = await executor.executeChat({
2150
- * messages: [{ role: 'user', content: 'Hello!' }],
2151
- * options: { model: 'gpt-4', temperature: 0.7 },
2152
- * provider: 'openai',
2153
- * model: 'gpt-4'
2154
- * });
2155
- * ```
2156
- */
2157
- executeChat(request: IChatExecutionRequest): Promise<IAssistantMessage>;
2158
- /**
2159
- * Execute a streaming chat completion request
2160
- *
2161
- * @param request - Streaming chat execution request
2162
- * @returns AsyncIterable of message chunks
2163
- *
2164
- * @example
2165
- * ```typescript
2166
- * for await (const chunk of executor.executeChatStream({
2167
- * messages: [{ role: 'user', content: 'Tell me a story' }],
2168
- * options: { model: 'gpt-4' },
2169
- * provider: 'openai',
2170
- * model: 'gpt-4',
2171
- * stream: true
2172
- * })) {
2173
- * console.log(chunk.content);
2174
- * }
2175
- * ```
2176
- */
2177
- executeChatStream?(request: IStreamExecutionRequest): AsyncIterable<TUniversalMessage>;
2178
- /**
2179
- * Check if the executor supports tool calling
2180
- * @returns true if tool calling is supported
2181
- */
2182
- supportsTools(): boolean;
2183
- /**
2184
- * Validate executor configuration
2185
- * @returns true if configuration is valid
2186
- */
2187
- validateConfig(): boolean;
2188
- /**
2189
- * Clean up resources when executor is no longer needed
2190
- */
2191
- dispose?(): Promise<void>;
2192
- /**
2193
- * Get executor name/identifier
2194
- */
2195
- readonly name: string;
2196
- /**
2197
- * Get executor version
2198
- */
2199
- readonly version: string;
2200
- }
2201
- /**
2202
- * Configuration options for local executor
2203
- */
2204
- interface ILocalExecutorConfig {
2205
- /** Timeout for API requests in milliseconds */
2206
- timeout?: number;
2207
- /** Maximum number of retry attempts */
2208
- maxRetries?: number;
2209
- /** Base delay between retries in milliseconds */
2210
- retryDelay?: number;
2211
- /** Whether to enable request/response logging */
2212
- enableLogging?: boolean;
2213
- }
2214
- /**
2215
- * Configuration options for remote executor
2216
- */
2217
- interface IRemoteExecutorConfig {
2218
- /** Remote server URL */
2219
- serverUrl: string;
2220
- /** User authentication token */
2221
- userApiKey: string;
2222
- /** Timeout for HTTP requests in milliseconds */
2223
- timeout?: number;
2224
- /** Maximum number of retry attempts */
2225
- maxRetries?: number;
2226
- /** Whether to enable WebSocket for streaming */
2227
- enableWebSocket?: boolean;
2228
- /** Custom headers to include in requests */
2229
- headers?: Record<string, string>;
2230
- }
2231
-
2232
- interface IEventHistoryRecord {
2233
- eventName: string;
2234
- sequenceId: number;
2235
- timestamp: Date;
2236
- eventData: IBaseEventData;
2237
- context: IEventContext;
2238
- }
2239
- interface IEventHistorySnapshot {
2240
- lastSequenceId: number;
2241
- createdAt: Date;
2242
- }
2243
- interface IEventHistoryModule {
2244
- append(record: IEventHistoryRecord): void;
2245
- read(fromSequenceId: number, toSequenceId?: number): IEventHistoryRecord[];
2246
- readStream(fromSequenceId: number, toSequenceId?: number): AsyncIterable<IEventHistoryRecord>;
2247
- getSnapshot?(): IEventHistorySnapshot | undefined;
2248
- }
2249
-
2250
- /**
2251
- * @fileoverview Abstract Agent Base Class
2252
- *
2253
- * 🎯 ABSTRACT CLASS - DO NOT DEPEND ON CONCRETE IMPLEMENTATIONS
2254
- *
2255
- * This class defines the foundational lifecycle for agent implementations.
2256
- * Subclasses provide provider/tool-specific behavior while inheriting the
2257
- * shared guarantees around initialization, history, and disposal.
2258
- */
2259
-
2260
- declare abstract class AbstractAgent<TConfig = IAgentConfig, TContext = IRunOptions, TMessage = TUniversalMessage> implements IAgent<TConfig, TContext, TMessage> {
2261
- protected history: TMessage[];
2262
- protected isInitialized: boolean;
2263
- protected config?: TConfig;
2264
- /**
2265
- * Initialize the agent (subclass responsibility)
2266
- */
2267
- protected abstract initialize(): Promise<void>;
2268
- /**
2269
- * Configure the agent with type-safe configuration
2270
- */
2271
- configure(config: TConfig): Promise<void>;
2272
- /**
2273
- * Run agent with user input and type-safe context
2274
- */
2275
- abstract run(input: string, context?: TContext): Promise<string>;
2276
- /**
2277
- * Run agent with streaming response and type-safe context
2278
- */
2279
- abstract runStream(input: string, context?: TContext): AsyncGenerator<string, void, never>;
2280
- /**
2281
- * Get conversation history with type-safe messages
2282
- */
2283
- getHistory(): TMessage[];
2284
- /**
2285
- * Clear conversation history
2286
- */
2287
- clearHistory(): void;
2288
- /**
2289
- * Add message to history
2290
- */
2291
- protected addMessage(message: TMessage): void;
2292
- /**
2293
- * Validate user input
2294
- */
2295
- protected validateInput(input: string): void;
2296
- /**
2297
- * Ensure agent is initialized before running
2298
- */
2299
- protected ensureInitialized(): Promise<void>;
2300
- /**
2301
- * Cleanup resources
2302
- */
2303
- dispose(): Promise<void>;
2304
- }
2305
-
2306
- /**
2307
- * @fileoverview Abstract Manager Base Class
2308
- *
2309
- * 🎯 ABSTRACT CLASS - DO NOT IMPORT CONCRETE IMPLEMENTATIONS
2310
- *
2311
- * This class defines the common lifecycle contract for all manager implementations.
2312
- * It enforces explicit initialization/disposal semantics so that subclasses can
2313
- * provide their own resource management logic while sharing guard rails.
2314
- *
2315
- * Architectural rules:
2316
- * - Depends only on abstractions (no concrete manager implementations)
2317
- * - Provides finalize hooks (`doInitialize`, `doDispose`) for subclasses
2318
- * - Guards public APIs via `ensureInitialized`
2319
- */
2320
- declare abstract class AbstractManager {
2321
- protected initialized: boolean;
2322
- /**
2323
- * Initialize the manager (idempotent)
2324
- */
2325
- initialize(): Promise<void>;
2326
- /**
2327
- * Subclass-specific initialization logic
2328
- */
2329
- protected abstract doInitialize(): Promise<void>;
2330
- /**
2331
- * Dispose manager resources (idempotent)
2332
- */
2333
- dispose(): Promise<void>;
2334
- /**
2335
- * Subclass-specific disposal logic
2336
- */
2337
- protected abstract doDispose(): Promise<void>;
2338
- /**
2339
- * Whether the manager completed initialization
2340
- */
2341
- isInitialized(): boolean;
2342
- /**
2343
- * Ensure manager is initialized before performing operations
2344
- */
2345
- protected ensureInitialized(): void;
2346
- }
2347
-
2348
- /**
2349
- * @fileoverview Abstract AI Provider Base Class
2350
- *
2351
- * 🎯 ABSTRACT CLASS - DO NOT DEPEND ON CONCRETE IMPLEMENTATIONS
2352
- *
2353
- * Defines the shared contract and helper utilities for all AI provider implementations.
2354
- * Concrete providers should extend this class and inject their own dependencies.
2355
- */
2356
-
2357
- /**
2358
- * Provider logging data type
2359
- * Used for storing logging information in provider operations
2360
- */
2361
- type TProviderLoggingData = Record<string, string | number | boolean | Date | string[]>;
2362
- /**
2363
- * Provider configuration base interface
2364
- */
2365
- interface IProviderConfig {
2366
- apiKey?: string;
2367
- baseUrl?: string;
2368
- timeout?: number;
2369
- [key: string]: string | number | boolean | undefined;
2370
- }
2371
- /**
2372
- * Enhanced provider configuration that supports executor injection
2373
- */
2374
- interface IExecutorAwareProviderConfig {
2375
- apiKey?: string;
2376
- baseUrl?: string;
2377
- timeout?: number;
2378
- /**
2379
- * Optional executor for handling AI requests
2380
- * When provided, the provider will delegate all chat operations to this executor
2381
- * instead of making direct API calls. This enables remote execution capabilities.
2382
- */
2383
- executor?: IExecutor;
2384
- [key: string]: string | number | boolean | IExecutor | undefined;
2385
- }
2386
- /**
2387
- * Base AI provider implementation with proper type constraints
2388
- * All AI providers should extend this class
2389
- *
2390
- * ========================================
2391
- * CRITICAL IMPLEMENTATION GUIDELINES
2392
- * ========================================
2393
- *
2394
- * ALL AI PROVIDER IMPLEMENTATIONS (OpenAI, Anthropic, Google, etc.) MUST:
2395
- *
2396
- * 1. EXTEND THIS CLASS:
2397
- * ```typescript
2398
- * export class OpenAIProvider extends AbstractAIProvider {
2399
- * override readonly name = 'openai';
2400
- * override readonly version = '1.0.0';
2401
- * ```
2402
- *
2403
- * 2. USE IMPORTS FROM @robota-sdk/agent-core:
2404
- * ```typescript
2405
- * import { AbstractAIProvider } from '@robota-sdk/agent-core';
2406
- * import type {
2407
- * TUniversalMessage,
2408
- * ChatOptions,
2409
- * IToolCall,
2410
- * ToolSchema,
2411
- * AssistantMessage
2412
- * } from '@robota-sdk/agent-core';
2413
- * ```
2414
- *
2415
- * 3. USE OVERRIDE KEYWORD FOR ALL INHERITED METHODS:
2416
- * - override async chat(...)
2417
- * - override async *chatStream(...)
2418
- * - override supportsTools()
2419
- * - override validateConfig()
2420
- * - override async dispose()
2421
- *
2422
- * 4. DO NOT REDEFINE TYPES THAT EXIST IN @robota-sdk/agent-core:
2423
- * - TUniversalMessage
2424
- * - ChatOptions
2425
- * - IToolCall
2426
- * - ToolSchema
2427
- * - AssistantMessage
2428
- * - SystemMessage
2429
- * - UserMessage
2430
- * - ToolMessage
2431
- *
2432
- * 5. HANDLE MESSAGE CONTENT PROPERLY:
2433
- * - For tool calls: content should be null (not empty string)
2434
- * - For regular messages: content can be string or null
2435
- * - Always preserve null values from API responses
2436
- *
2437
- * 6. CALL SUPER() IN CONSTRUCTOR:
2438
- * ```typescript
2439
- * constructor(options: IProviderOptions) {
2440
- * super();
2441
- * // provider-specific initialization
2442
- * }
2443
- * ```
2444
- *
2445
- * This ensures ExecutionService can properly identify providers
2446
- * and prevents type conflicts across the codebase.
2447
- *
2448
- * ========================================
2449
- *
2450
- * @template TConfig - Provider configuration type (defaults to IProviderConfig for type safety)
2451
- * @template TUniversalMessage - Message type (defaults to TUniversalMessage for backward compatibility)
2452
- * @template TResponse - Response type (defaults to TUniversalMessage for backward compatibility)
2453
- */
2454
- declare abstract class AbstractAIProvider<TConfig = IProviderConfig> implements IAIProvider {
2455
- abstract readonly name: string;
2456
- abstract readonly version: string;
2457
- protected config?: TConfig;
2458
- protected executor?: IExecutor;
2459
- protected readonly logger: ILogger;
2460
- constructor(logger?: ILogger);
2461
- /**
2462
- * Configure the provider with type-safe configuration
2463
- */
2464
- configure(config: TConfig): Promise<void>;
2465
- private hasExecutor;
2466
- /**
2467
- * Each provider must implement chat using their own native SDK types internally
2468
- * @param messages - Array of messages from conversation history
2469
- * @param options - Chat options including tools, model settings, etc.
2470
- * @returns Promise resolving to a response
2471
- */
2472
- abstract chat(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
2473
- /**
2474
- * Each provider must implement streaming chat using their own native SDK types internally
2475
- * @param messages - Array of messages from conversation history
2476
- * @param options - Chat options including tools, model settings, etc.
2477
- * @returns AsyncIterable of response chunks
2478
- */
2479
- chatStream?(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
2480
- /**
2481
- * Provider-agnostic raw response API.
2482
- *
2483
- * This is the canonical "raw payload" entrypoint required by the AIProvider contract.
2484
- * The default implementation delegates to `chat()` and adapts the result into a
2485
- * RawProviderResponse shape.
2486
- */
2487
- generateResponse(payload: IProviderRequest): Promise<IRawProviderResponse>;
2488
- /**
2489
- * Provider-agnostic raw streaming API.
2490
- *
2491
- * If a provider does not implement chatStream, it does not support streaming.
2492
- */
2493
- generateStreamingResponse(payload: IProviderRequest): AsyncIterable<IRawProviderResponse>;
2494
- /**
2495
- * Default implementation - most modern providers support tools
2496
- * @returns true if tool calling is supported
2497
- */
2498
- supportsTools(): boolean;
2499
- /**
2500
- * Default implementation - providers can override for specific validation
2501
- * @returns true if configuration is valid
2502
- */
2503
- validateConfig(): boolean;
2504
- /**
2505
- * Utility method for validating TUniversalMessage array
2506
- * @param messages - Messages to validate
2507
- */
2508
- protected validateMessages(messages: TUniversalMessage[]): void;
2509
- /**
2510
- * Utility method for validating tool schemas
2511
- * @param tools - Tool schemas to validate
2512
- */
2513
- protected validateTools(tools?: IToolSchema[]): void;
2514
- /**
2515
- * Execute chat via executor.
2516
- *
2517
- * Subclasses should call this only when an executor is configured.
2518
- */
2519
- protected executeViaExecutorOrDirect(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
2520
- /**
2521
- * Execute streaming chat via executor.
2522
- *
2523
- * Subclasses should call this only when an executor is configured.
2524
- */
2525
- protected executeStreamViaExecutorOrDirect(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
2526
- /**
2527
- * Clean up resources when provider is no longer needed
2528
- * Override this method in subclasses for additional cleanup
2529
- */
2530
- dispose(): Promise<void>;
2531
- }
2532
-
2533
- /**
2534
- * @fileoverview Abstract Executor Base Class
2535
- *
2536
- * 🎯 ABSTRACT CLASS - DO NOT DEPEND ON CONCRETE IMPLEMENTATIONS
2537
- *
2538
- * Provides shared execution helpers (retry, timeout, validation, logging) for all
2539
- * executor implementations. Concrete executors should extend this class and inject
2540
- * their own logger implementation if they need custom logging behavior.
2541
- *
2542
- * @example
2543
- * ```typescript
2544
- * export class MyCustomExecutor extends AbstractExecutor {
2545
- * async executeChat(request: IChatExecutionRequest): Promise<AssistantMessage> {
2546
- * return this.withRetry(() => this.performChat(request));
2547
- * }
2548
- * }
2549
- * ```
2550
- */
2551
- declare abstract class AbstractExecutor implements IExecutor {
2552
- /**
2553
- * Logger injected via constructor (defaults to abstract logger)
2554
- */
2555
- protected readonly logger: ILogger;
2556
- constructor(logger?: ILogger);
2557
- abstract readonly name: string;
2558
- abstract readonly version: string;
2559
- /**
2560
- * Execute a chat completion request
2561
- * Must be implemented by concrete executor classes
2562
- */
2563
- abstract executeChat(request: IChatExecutionRequest): Promise<IAssistantMessage>;
2564
- /**
2565
- * Execute a streaming chat completion request
2566
- * Optional - can be implemented by concrete executor classes
2567
- */
2568
- abstract executeChatStream?(request: IStreamExecutionRequest): AsyncIterable<TUniversalMessage>;
2569
- /**
2570
- * Check if the executor supports tool calling
2571
- * Default implementation returns false, can be overridden
2572
- */
2573
- supportsTools(): boolean;
2574
- /**
2575
- * Validate executor configuration
2576
- * Default implementation returns true, can be overridden
2577
- */
2578
- validateConfig(): boolean;
2579
- /**
2580
- * Clean up resources when executor is no longer needed
2581
- * Default implementation does nothing, can be overridden
2582
- */
2583
- dispose?(): Promise<void>;
2584
- /**
2585
- * Execute function with retry logic
2586
- *
2587
- * @param fn - Function to execute with retries
2588
- * @param maxRetries - Maximum number of retry attempts (default: 3)
2589
- * @param retryDelay - Delay between retries in milliseconds (default: 1000)
2590
- * @returns Promise resolving to function result
2591
- */
2592
- protected withRetry<T>(fn: () => Promise<T>, maxRetries?: number, retryDelay?: number): Promise<T>;
2593
- /**
2594
- * Execute function with timeout
2595
- *
2596
- * @param promise - Promise to execute with timeout
2597
- * @param timeoutMs - Timeout in milliseconds
2598
- * @returns Promise resolving to function result
2599
- */
2600
- protected withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T>;
2601
- /**
2602
- * Delay execution for specified milliseconds
2603
- *
2604
- * @param ms - Milliseconds to delay
2605
- * @returns Promise that resolves after the delay
2606
- */
2607
- protected delay(ms: number): Promise<void>;
2608
- /**
2609
- * Log debug information (only if logging is enabled)
2610
- *
2611
- * @param message - Log message
2612
- * @param data - Optional data to log
2613
- */
2614
- protected logDebug(message: string, data?: TLoggerData): void;
2615
- /**
2616
- * Log error information
2617
- *
2618
- * @param message - Log message
2619
- * @param error - Error object
2620
- * @param data - Optional additional data
2621
- */
2622
- protected logError(message: string, error: Error, data?: TLoggerData): void;
2623
- /**
2624
- * Validate that request has required fields
2625
- *
2626
- * @param request - Chat execution request to validate
2627
- * @throws Error if validation fails
2628
- */
2629
- protected validateRequest(request: IChatExecutionRequest): void;
2630
- /**
2631
- * Validate that response is properly formatted
2632
- *
2633
- * @param response - Response to validate
2634
- * @throws Error if validation fails
2635
- */
2636
- protected validateResponse(response: TUniversalMessage): void;
2637
- }
2638
-
2639
- interface IOpenAIMessage {
2640
- role: 'system' | 'user' | 'assistant' | 'tool';
2641
- content: string | null;
2642
- tool_calls?: {
2643
- id: string;
2644
- type: 'function';
2645
- function: {
2646
- name: string;
2647
- arguments: string;
2648
- };
2649
- }[];
2650
- tool_call_id?: string;
2651
- name?: string;
2652
- }
2653
- interface IAnthropicProviderMessage {
2654
- role: 'user' | 'assistant';
2655
- content: string;
2656
- }
2657
- interface IGoogleProviderMessage {
2658
- role: 'user' | 'model';
2659
- parts: {
2660
- text: string;
2661
- }[];
2662
- }
2663
- /**
2664
- * Provider message format union type
2665
- */
2666
- type TProviderMessage = IOpenAIMessage | IAnthropicProviderMessage | IGoogleProviderMessage | TUniversalMessage;
2667
- /**
2668
- * Universal message converter utility
2669
- * Handles message format conversion between different providers
2670
- */
2671
- declare class MessageConverter {
2672
- /**
2673
- * Convert messages to provider-specific format
2674
- */
2675
- static toProviderFormat(messages: TUniversalMessage[], providerName: string): TProviderMessage[];
2676
- /**
2677
- * Convert to OpenAI format
2678
- */
2679
- private static toOpenAIFormat;
2680
- /**
2681
- * Convert to Anthropic format
2682
- */
2683
- private static toAnthropicFormat;
2684
- /**
2685
- * Convert to Google format
2686
- */
2687
- private static toGoogleFormat;
2688
- /**
2689
- * Convert to universal format (no conversion)
2690
- */
2691
- private static toUniversalFormat;
2692
- /**
2693
- * Extract system message from messages
2694
- */
2695
- static extractSystemMessage(messages: TUniversalMessage[]): string | undefined;
2696
- /**
2697
- * Filter non-system messages
2698
- */
2699
- static filterNonSystemMessages(messages: TUniversalMessage[]): TUniversalMessage[];
2700
- }
2701
-
2702
- /**
2703
- * Validation result interface
2704
- */
2705
- interface ISimpleValidationResult {
2706
- isValid: boolean;
2707
- errors: string[];
2708
- warnings?: string[];
2709
- }
2710
- /**
2711
- * Validation utility class
2712
- */
2713
- declare class Validator {
2714
- /**
2715
- * Validate agent configuration
2716
- */
2717
- static validateAgentConfig(config: Partial<IAgentConfig>): ISimpleValidationResult;
2718
- /**
2719
- * Validate user input string
2720
- */
2721
- static validateUserInput(input: string): ISimpleValidationResult;
2722
- /**
2723
- * Validate provider name
2724
- */
2725
- static validateProviderName(name: string): ISimpleValidationResult;
2726
- /**
2727
- * Validate model name
2728
- */
2729
- static validateModelName(name: string): ISimpleValidationResult;
2730
- /**
2731
- * Validate API key format (basic check)
2732
- */
2733
- static validateApiKey(apiKey: string, provider?: string): ISimpleValidationResult;
2734
- }
2735
- declare const validateAgentConfig: typeof Validator.validateAgentConfig;
2736
- declare const validateUserInput: typeof Validator.validateUserInput;
2737
- declare const validateProviderName: typeof Validator.validateProviderName;
2738
- declare const validateModelName: typeof Validator.validateModelName;
2739
- declare const validateApiKey: typeof Validator.validateApiKey;
2740
-
2741
- /**
2742
- * Reusable type definitions for error utilities
2743
- */
2744
- /**
2745
- * Error context data type
2746
- * Used for storing contextual information in error instances
2747
- */
2748
- type TErrorContextData = Record<string, string | number | boolean | Date | Error | string[] | undefined>;
2749
- /**
2750
- * Error external input type
2751
- * Used for handling external errors from unknown sources
2752
- */
2753
- type TErrorExternalInput = Error | string | Record<string, string | number | boolean> | null | undefined;
2754
- /**
2755
- * Base error class for all Robota errors
2756
- */
2757
- declare abstract class RobotaError extends Error {
2758
- readonly context?: TErrorContextData | undefined;
2759
- abstract readonly code: string;
2760
- abstract readonly category: 'user' | 'system' | 'provider';
2761
- abstract readonly recoverable: boolean;
2762
- constructor(message: string, context?: TErrorContextData | undefined);
2763
- }
2764
- /**
2765
- * Configuration related errors
2766
- */
2767
- declare class ConfigurationError extends RobotaError {
2768
- readonly code = "CONFIGURATION_ERROR";
2769
- readonly category: "user";
2770
- readonly recoverable = false;
2771
- constructor(message: string, context?: TErrorContextData);
2772
- }
2773
- /**
2774
- * Input validation errors
2775
- */
2776
- declare class ValidationError extends RobotaError {
2777
- readonly field?: string | undefined;
2778
- readonly code = "VALIDATION_ERROR";
2779
- readonly category: "user";
2780
- readonly recoverable = false;
2781
- constructor(message: string, field?: string | undefined, context?: TErrorContextData);
2782
- }
2783
- /**
2784
- * Provider related errors
2785
- */
2786
- declare class ProviderError extends RobotaError {
2787
- readonly provider: string;
2788
- readonly originalError?: Error | undefined;
2789
- readonly code = "PROVIDER_ERROR";
2790
- readonly category: "provider";
2791
- readonly recoverable = true;
2792
- constructor(message: string, provider: string, originalError?: Error | undefined, context?: TErrorContextData);
2793
- }
2794
- /**
2795
- * Authentication errors
2796
- */
2797
- declare class AuthenticationError extends RobotaError {
2798
- readonly provider?: string | undefined;
2799
- readonly code = "AUTHENTICATION_ERROR";
2800
- readonly category: "user";
2801
- readonly recoverable = false;
2802
- constructor(message: string, provider?: string | undefined, context?: TErrorContextData);
2803
- }
2804
- /**
2805
- * Rate limit errors
2806
- */
2807
- declare class RateLimitError extends RobotaError {
2808
- readonly retryAfter?: number | undefined;
2809
- readonly provider?: string | undefined;
2810
- readonly code = "RATE_LIMIT_ERROR";
2811
- readonly category: "provider";
2812
- readonly recoverable = true;
2813
- constructor(message: string, retryAfter?: number | undefined, provider?: string | undefined, context?: TErrorContextData);
2814
- }
2815
- /**
2816
- * Network/connectivity errors
2817
- */
2818
- declare class NetworkError extends RobotaError {
2819
- readonly originalError?: Error | undefined;
2820
- readonly code = "NETWORK_ERROR";
2821
- readonly category: "system";
2822
- readonly recoverable = true;
2823
- constructor(message: string, originalError?: Error | undefined, context?: TErrorContextData);
2824
- }
2825
- /**
2826
- * Tool execution errors
2827
- */
2828
- declare class ToolExecutionError extends RobotaError {
2829
- readonly toolName: string;
2830
- readonly originalError?: Error | undefined;
2831
- readonly code = "TOOL_EXECUTION_ERROR";
2832
- readonly category: "system";
2833
- readonly recoverable = false;
2834
- constructor(message: string, toolName: string, originalError?: Error | undefined, context?: TErrorContextData);
2835
- }
2836
- /**
2837
- * Model not available errors
2838
- */
2839
- declare class ModelNotAvailableError extends RobotaError {
2840
- readonly availableModels?: string[] | undefined;
2841
- readonly code = "MODEL_NOT_AVAILABLE";
2842
- readonly category: "user";
2843
- readonly recoverable = false;
2844
- constructor(model: string, provider: string, availableModels?: string[] | undefined, context?: TErrorContextData);
2845
- }
2846
- /**
2847
- * Circuit breaker open error
2848
- */
2849
- declare class CircuitBreakerOpenError extends RobotaError {
2850
- readonly code = "CIRCUIT_BREAKER_OPEN";
2851
- readonly category: "system";
2852
- readonly recoverable = true;
2853
- constructor(message?: string, context?: TErrorContextData);
2854
- }
2855
- /**
2856
- * Plugin errors
2857
- */
2858
- declare class PluginError extends RobotaError {
2859
- readonly pluginName: string;
2860
- readonly code = "PLUGIN_ERROR";
2861
- readonly category: "system";
2862
- readonly recoverable = false;
2863
- constructor(message: string, pluginName: string, context?: TErrorContextData);
2864
- }
2865
- /**
2866
- * Storage related errors
2867
- */
2868
- declare class StorageError extends RobotaError {
2869
- readonly code = "STORAGE_ERROR";
2870
- readonly category: "system";
2871
- readonly recoverable = true;
2872
- constructor(message: string, context?: TErrorContextData);
2873
- }
2874
- /**
2875
- * Cache integrity validation errors
2876
- */
2877
- declare class CacheIntegrityError extends RobotaError {
2878
- readonly code = "CACHE_INTEGRITY_ERROR";
2879
- readonly category: "system";
2880
- readonly recoverable = false;
2881
- constructor(message: string, context?: TErrorContextData);
2882
- }
2883
- /**
2884
- * Error utility functions
2885
- */
2886
- declare class ErrorUtils {
2887
- /**
2888
- * Check if error is recoverable
2889
- */
2890
- static isRecoverable(error: Error): boolean;
2891
- /**
2892
- * Extract error code from any error
2893
- */
2894
- static getErrorCode(error: Error): string;
2895
- /**
2896
- * Create error from unknown value
2897
- */
2898
- static fromUnknown(error: TErrorExternalInput, defaultMessage?: string): RobotaError;
2899
- /**
2900
- * Wrap external errors
2901
- */
2902
- static wrapProviderError(error: TErrorExternalInput, provider: string, operation: string): ProviderError;
2903
- }
2904
-
2905
- interface IPeriodicTaskOptions {
2906
- name: string;
2907
- intervalMs: number;
2908
- }
2909
- /**
2910
- * Start a periodic async task with consistent error logging.
2911
- * SSOT helper to avoid duplicating setInterval(async () => ...) patterns.
2912
- */
2913
- declare function startPeriodicTask(logger: ILogger, options: IPeriodicTaskOptions, task: () => Promise<void>): TTimerId;
2914
- declare function stopPeriodicTask(timer: TTimerId | undefined): void;
2915
-
2916
- /**
2917
- * Cross-platform timer identifier type
2918
- * Works in both Node.js and browser environments
2919
- */
2920
- type TTimerId = ReturnType<typeof setTimeout>;
2921
-
2922
- /**
2923
- * Local executor that directly delegates to AI provider instances
2924
- *
2925
- * This executor maintains a registry of AI provider instances and delegates
2926
- * chat execution requests to the appropriate provider based on the provider
2927
- * name in the request. This is the "traditional" execution mode where
2928
- * API calls are made directly from the client.
2929
- *
2930
- * @example
2931
- * ```typescript
2932
- * import { LocalExecutor } from '@robota-sdk/agent-core';
2933
- * import { OpenAIProvider } from '@robota-sdk/agent-provider-openai';
2934
- *
2935
- * const executor = new LocalExecutor();
2936
- * executor.registerProvider('openai', new OpenAIProvider({ apiKey: 'sk-...' }));
2937
- *
2938
- * const response = await executor.executeChat({
2939
- * messages: [{ role: 'user', content: 'Hello!' }],
2940
- * provider: 'openai',
2941
- * model: 'gpt-4'
2942
- * });
2943
- * ```
2944
- */
2945
- declare class LocalExecutor extends AbstractExecutor {
2946
- readonly name = "local";
2947
- readonly version = "1.0.0";
2948
- private providers;
2949
- private config;
2950
- constructor(config?: ILocalExecutorConfig);
2951
- /**
2952
- * Register an AI provider instance for use with this executor
2953
- *
2954
- * @param name - Provider name (e.g., 'openai', 'anthropic', 'google')
2955
- * @param provider - Provider instance that implements the required chat methods
2956
- */
2957
- registerProvider(name: string, provider: IAIProviderInstance): void;
2958
- /**
2959
- * Unregister an AI provider
2960
- *
2961
- * @param name - Provider name to remove
2962
- */
2963
- unregisterProvider(name: string): void;
2964
- /**
2965
- * Get registered provider instance
2966
- *
2967
- * @param name - Provider name
2968
- * @returns Provider instance or undefined if not registered
2969
- */
2970
- getProvider(name: string): IAIProviderInstance | undefined;
2971
- /**
2972
- * Execute a chat completion request by delegating to the appropriate provider
2973
- */
2974
- executeChat(request: IChatExecutionRequest): Promise<IAssistantMessage>;
2975
- /**
2976
- * Execute a streaming chat completion request
2977
- */
2978
- executeChatStream(request: IStreamExecutionRequest): AsyncIterable<TUniversalMessage>;
2979
- /**
2980
- * Check if any registered providers support tools
2981
- */
2982
- supportsTools(): boolean;
2983
- /**
2984
- * Validate executor configuration and all registered providers
2985
- */
2986
- validateConfig(): boolean;
2987
- /**
2988
- * Clean up all registered providers
2989
- */
2990
- dispose(): Promise<void>;
2991
- }
2992
- /**
2993
- * Interface that AI provider instances must implement to work with LocalExecutor
2994
- *
2995
- * This interface represents the subset of AI provider methods that LocalExecutor
2996
- * needs to delegate to. It's designed to be compatible with existing BaseAIProvider
2997
- * implementations from @robota-sdk packages.
2998
- */
2999
- interface IAIProviderInstance {
3000
- /** Provider name */
3001
- readonly name?: string;
3002
- /** Chat completion method */
3003
- chat?(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
3004
- /** Streaming chat completion method */
3005
- chatStream?(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
3006
- /** Check if provider supports tools */
3007
- supportsTools?(): boolean;
3008
- /** Validate provider configuration */
3009
- validateConfig?(): boolean;
3010
- /** Clean up provider resources */
3011
- dispose?(): Promise<void>;
3012
- }
3013
-
3014
- interface IEventEmitterMetricsSnapshot {
3015
- totalEmitted: number;
3016
- totalErrors: number;
3017
- }
3018
- interface IEventEmitterMetrics {
3019
- incrementEmitted(): void;
3020
- incrementErrors(): void;
3021
- getSnapshot(): IEventEmitterMetricsSnapshot;
3022
- }
3023
- declare class InMemoryEventEmitterMetrics implements IEventEmitterMetrics {
3024
- private totalEmitted;
3025
- private totalErrors;
3026
- incrementEmitted(): void;
3027
- incrementErrors(): void;
3028
- getSnapshot(): IEventEmitterMetricsSnapshot;
3029
- }
3030
-
3031
- /**
3032
- * Type definitions for EventEmitterPlugin.
3033
- *
3034
- * Extracted from event-emitter-plugin.ts to keep each file under 300 lines.
3035
- */
3036
-
3037
- /** Enhanced event data for hierarchical execution tracking */
3038
- interface IEventEmitterHierarchicalEventData extends IEventEmitterEventData {
3039
- parentExecutionId?: string;
3040
- rootExecutionId?: string;
3041
- executionLevel: number;
3042
- executionPath: string[];
3043
- realTimeData?: {
3044
- startTime: Date;
3045
- actualDuration?: number;
3046
- actualParameters?: TToolParameters;
3047
- actualResult?: IToolResult;
3048
- };
3049
- }
3050
-
3051
- /** Event emitter configuration */
3052
- interface IEventEmitterPluginOptions extends IPluginOptions {
3053
- events?: TEventName[];
3054
- maxListeners?: number;
3055
- async?: boolean;
3056
- catchErrors?: boolean;
3057
- filters?: Record<TEventName, (event: IEventEmitterEventData) => boolean>;
3058
- buffer?: {
3059
- enabled: boolean;
3060
- maxSize: number;
3061
- flushInterval: number;
3062
- };
3063
- metrics?: IEventEmitterMetrics;
3064
- }
3065
- /** Event emitter plugin statistics */
3066
- interface IEventEmitterPluginStats extends IPluginStats {
3067
- eventTypes: TEventName[];
3068
- listenerCounts: Partial<Record<TEventName, number>>;
3069
- totalListeners: number;
3070
- bufferedEvents: number;
3071
- totalEmitted: number;
3072
- totalErrors: number;
3073
- }
3074
-
3075
- /**
3076
- * Provides pub/sub event coordination during the agent execution lifecycle.
3077
- * @extends AbstractPlugin
3078
- * @see IEventEmitterPluginOptions
3079
- * @see EVENT_EMITTER_EVENTS
3080
- */
3081
- declare class EventEmitterPlugin extends AbstractPlugin<IEventEmitterPluginOptions, IEventEmitterPluginStats> {
3082
- name: string;
3083
- version: string;
3084
- private pluginOptions;
3085
- private logger;
3086
- private handlers;
3087
- private eventBuffer;
3088
- private nextHandlerId;
3089
- private bufferTimer?;
3090
- private metrics;
3091
- constructor(options?: IEventEmitterPluginOptions);
3092
- beforeExecution(context: IPluginExecutionContext): Promise<void>;
3093
- afterExecution(context: IPluginExecutionContext, result: IPluginExecutionResult): Promise<void>;
3094
- beforeConversation(context: IPluginExecutionContext): Promise<void>;
3095
- afterConversation(context: IPluginExecutionContext, result: IPluginExecutionResult): Promise<void>;
3096
- beforeToolExecution(context: IPluginExecutionContext, toolData: IToolExecutionContext): Promise<void>;
3097
- afterToolExecution(context: IPluginExecutionContext, toolResults: IPluginExecutionResult): Promise<void>;
3098
- onError(error: Error, context?: IPluginErrorContext): Promise<void>;
3099
- on(eventType: TEventName, listener: TEventEmitterListener, options?: {
3100
- once?: boolean;
3101
- filter?: (event: IEventEmitterEventData) => boolean;
3102
- }): string;
3103
- once(eventType: TEventName, listener: TEventEmitterListener, filter?: (event: IEventEmitterEventData) => boolean): string;
3104
- off(eventType: TEventName, handlerIdOrListener: string | TEventEmitterListener): boolean;
3105
- emit(eventType: TEventName, eventData?: Partial<IEventEmitterEventData>): Promise<void>;
3106
- private processEvent;
3107
- private executeHandler;
3108
- flushBuffer(): Promise<void>;
3109
- getStats(): IEventEmitterPluginStats;
3110
- clearAllListeners(): void;
3111
- destroy(): Promise<void>;
3112
- private validateOptions;
3113
- }
3114
-
3115
- /** Agent statistics metadata type */
3116
- type TAgentStatsMetadata = Record<string, string | number | boolean | Date | string[]>;
3117
-
3118
- /**
3119
- * Core AI agent integrating multiple AI providers, tools, and plugins
3120
- * into a unified conversational interface.
3121
- * @public
3122
- */
3123
- declare class Robota extends AbstractAgent<IAgentConfig, IRunOptions, TUniversalMessage> implements IAgent<IAgentConfig, IRunOptions, TUniversalMessage> {
3124
- readonly name: string;
3125
- readonly version: string;
3126
- private aiProviders;
3127
- private tools;
3128
- private agentFactory;
3129
- private conversationHistory;
3130
- private moduleRegistry;
3131
- private eventEmitter;
3132
- private executionService;
3133
- private eventService;
3134
- private agentEventService;
3135
- protected config: IAgentConfig;
3136
- private conversationId;
3137
- private logger;
3138
- private initializationPromise?;
3139
- private isFullyInitialized;
3140
- private startTime;
3141
- private configVersion;
3142
- private configUpdatedAt;
3143
- private moduleManager;
3144
- private pluginManager;
3145
- private configManager;
3146
- constructor(config: IAgentConfig);
3147
- private initDelegates;
3148
- private emitCreatedEvent;
3149
- run(input: string, options?: IRunOptions): Promise<string>;
3150
- runStream(input: string, options?: IRunOptions): AsyncGenerator<string, void, undefined>;
3151
- private executionDeps;
3152
- getHistory(): TUniversalMessage[];
3153
- clearHistory(): void;
3154
- updateTools(next: Array<IToolWithEventService>): Promise<{
3155
- version: number;
3156
- }>;
3157
- updateConfiguration(patch: Partial<IAgentConfig>): Promise<{
3158
- version: number;
3159
- }>;
3160
- getConfiguration(): Promise<{
3161
- version: number;
3162
- tools: Array<{
3163
- name: string;
3164
- parameters?: string[];
3165
- }>;
3166
- updatedAt: number;
3167
- }>;
3168
- setModel(mc: {
3169
- provider: string;
3170
- model: string;
3171
- temperature?: number;
3172
- maxTokens?: number;
3173
- topP?: number;
3174
- systemMessage?: string;
3175
- }): void;
3176
- getModel(): {
3177
- provider: string;
3178
- model: string;
3179
- temperature?: number;
3180
- maxTokens?: number;
3181
- topP?: number;
3182
- systemMessage?: string;
3183
- };
3184
- registerTool(tool: AbstractTool): void;
3185
- unregisterTool(toolName: string): void;
3186
- getConfig(): IAgentConfig;
3187
- addPlugin(plugin: IPluginContract<IPluginOptions, IPluginStats> & IPluginHooks): void;
3188
- removePlugin(pluginName: string): boolean;
3189
- getPlugin(pluginName: string): (IPluginContract<IPluginOptions, IPluginStats> & IPluginHooks) | undefined;
3190
- getPlugins(): Array<IPluginContract<IPluginOptions, IPluginStats> & IPluginHooks>;
3191
- getPluginNames(): string[];
3192
- registerModule(module: IModule, options?: {
3193
- autoInitialize?: boolean;
3194
- validateDependencies?: boolean;
3195
- }): Promise<void>;
3196
- unregisterModule(moduleName: string): Promise<boolean>;
3197
- getModule(moduleName: string): IModule | undefined;
3198
- getModulesByType(moduleType: string): IModule[];
3199
- getModules(): IModule[];
3200
- getModuleNames(): string[];
3201
- hasModule(moduleName: string): boolean;
3202
- executeModule(moduleName: string, context: {
3203
- executionId?: string;
3204
- sessionId?: string;
3205
- userId?: string;
3206
- metadata?: Record<string, string | number | boolean | Date>;
3207
- }): Promise<{
3208
- success: boolean;
3209
- data?: IModuleResultData;
3210
- error?: Error;
3211
- duration?: number;
3212
- }>;
3213
- getModuleStats(moduleName: string): {
3214
- totalExecutions: number;
3215
- successfulExecutions: number;
3216
- failedExecutions: number;
3217
- averageExecutionTime: number;
3218
- lastExecutionTime?: Date;
3219
- } | undefined;
3220
- getStats(): {
3221
- name: string;
3222
- version: string;
3223
- conversationId: string;
3224
- providers: string[];
3225
- currentProvider: string | null;
3226
- tools: string[];
3227
- plugins: string[];
3228
- modules: string[];
3229
- historyLength: number;
3230
- historyStats: TAgentStatsMetadata;
3231
- uptime: number;
3232
- };
3233
- destroy(): Promise<void>;
3234
- protected initialize(): Promise<void>;
3235
- private ensureFullyInitialized;
3236
- private doAsyncInit;
3237
- private emitAgentEvent;
3238
- private buildOwnerPath;
3239
- }
3240
-
3241
- /**
3242
- * Template application result
3243
- */
3244
- interface ITemplateApplicationResult {
3245
- /** Applied configuration */
3246
- config: IAgentConfig;
3247
- /** Template that was applied */
3248
- template: IAgentTemplate;
3249
- /** Any warnings during application */
3250
- warnings: string[];
3251
- /** Whether config was modified during application */
3252
- modified: boolean;
3253
- }
3254
- /**
3255
- * Agent Templates implementation
3256
- * Manages agent templates for AgentFactory
3257
- * Instance-based for isolated template management
3258
- */
3259
- declare class AgentTemplates {
3260
- private templates;
3261
- private logger;
3262
- constructor();
3263
- /**
3264
- * Register a template
3265
- */
3266
- registerTemplate(template: IAgentTemplate): void;
3267
- /**
3268
- * Unregister a template
3269
- */
3270
- unregisterTemplate(templateId: string): boolean;
3271
- /**
3272
- * Get all templates
3273
- */
3274
- getTemplates(): IAgentTemplate[];
3275
- /**
3276
- * Get template by ID
3277
- */
3278
- getTemplate(templateId: string): IAgentTemplate | undefined;
3279
- /**
3280
- * Find templates by criteria
3281
- */
3282
- findTemplates(criteria: {
3283
- category?: string;
3284
- tags?: string[];
3285
- provider?: string;
3286
- model?: string;
3287
- }): IAgentTemplate[];
3288
- /**
3289
- * Apply template to configuration
3290
- */
3291
- applyTemplate(template: IAgentTemplate, overrides?: Partial<IAgentConfig>): ITemplateApplicationResult;
3292
- /**
3293
- * Check if template exists
3294
- */
3295
- hasTemplate(templateId: string): boolean;
3296
- /**
3297
- * Get template count
3298
- */
3299
- getTemplateCount(): number;
3300
- /**
3301
- * Clear all templates
3302
- */
3303
- clearAll(): void;
3304
- /**
3305
- * Get template statistics
3306
- */
3307
- getStats(): {
3308
- totalTemplates: number;
3309
- categories: string[];
3310
- tags: string[];
3311
- providers: string[];
3312
- models: string[];
3313
- };
3314
- }
3315
-
3316
- /**
3317
- * Configuration options for AgentFactory
3318
- */
3319
- interface IAgentFactoryOptions {
3320
- /** Default model to use if not specified in config */
3321
- defaultModel?: string;
3322
- /** Default provider to use if not specified in config */
3323
- defaultProvider?: string;
3324
- /** Maximum number of concurrent agents */
3325
- maxConcurrentAgents?: number;
3326
- /** Default system message for agents */
3327
- defaultSystemMessage?: string;
3328
- /** Enable strict configuration validation */
3329
- strictValidation?: boolean;
3330
- }
3331
- /**
3332
- * Agent creation statistics
3333
- */
3334
- interface IAgentCreationStats {
3335
- /** Total number of agents created */
3336
- totalCreated: number;
3337
- /** Number of currently active agents */
3338
- activeCount: number;
3339
- /** Number of agents created from templates */
3340
- fromTemplates: number;
3341
- /** Number of custom configured agents */
3342
- customConfigured: number;
3343
- /** Template vs custom creation ratio (fromTemplates / totalCreated) */
3344
- templateUsageRatio: number;
3345
- }
3346
- /**
3347
- * Agent lifecycle events
3348
- */
3349
- interface IAgentLifecycleEvents {
3350
- /** Called before agent creation */
3351
- beforeCreate?: (config: IAgentConfig) => Promise<void> | void;
3352
- /** Called after successful agent creation */
3353
- afterCreate?: (agent: IAgent<IAgentConfig>, config: IAgentConfig) => Promise<void> | void;
3354
- /** Called when agent creation fails */
3355
- onCreateError?: (error: Error, config: IAgentConfig) => Promise<void> | void;
3356
- /** Called when agent is destroyed */
3357
- onDestroy?: (agentId: string) => Promise<void> | void;
3358
- }
3359
- /**
3360
- * Agent Factory for creating and managing agents
3361
- * Instance-based for isolated agent factory management
3362
- */
3363
- declare class AgentFactory {
3364
- private agentTemplates;
3365
- private initialized;
3366
- private logger;
3367
- private options;
3368
- private activeAgents;
3369
- private creationStats;
3370
- private lifecycleEvents;
3371
- constructor(options?: IAgentFactoryOptions, lifecycleEvents?: IAgentLifecycleEvents);
3372
- /**
3373
- * Initialize the factory
3374
- */
3375
- initialize(): Promise<void>;
3376
- /**
3377
- * Create a new agent instance
3378
- */
3379
- createAgent(AgentClass: new (config: IAgentConfig) => IAgent<IAgentConfig>, config: Partial<IAgentConfig>, fromTemplate?: boolean): Promise<IAgent<IAgentConfig>>;
3380
- /**
3381
- * Create agent from template
3382
- */
3383
- createFromTemplate(AgentClass: new (config: IAgentConfig) => IAgent<IAgentConfig>, templateId: string, overrides?: Partial<IAgentConfig>): Promise<IAgent<IAgentConfig>>;
3384
- /**
3385
- * Register a template
3386
- */
3387
- registerTemplate(template: IAgentTemplate): void;
3388
- /**
3389
- * Unregister a template
3390
- */
3391
- unregisterTemplate(templateId: string): boolean;
3392
- /**
3393
- * Get all templates
3394
- */
3395
- getTemplates(): IAgentTemplate[];
3396
- /**
3397
- * Get template by ID
3398
- */
3399
- getTemplate(templateId: string): IAgentTemplate | undefined;
3400
- /**
3401
- * Find templates by criteria
3402
- */
3403
- findTemplates(criteria: {
3404
- category?: string;
3405
- tags?: string[];
3406
- provider?: string;
3407
- model?: string;
3408
- }): IAgentTemplate[];
3409
- /**
3410
- * Apply template to configuration
3411
- */
3412
- applyTemplate(template: IAgentTemplate, overrides?: Partial<IAgentConfig>): ITemplateApplicationResult;
3413
- /**
3414
- * Destroy an agent
3415
- */
3416
- destroyAgent(agentId: string): Promise<boolean>;
3417
- /**
3418
- * Get creation statistics
3419
- */
3420
- getCreationStats(): IAgentCreationStats;
3421
- /**
3422
- * Get all active agents
3423
- */
3424
- getActiveAgents(): Map<string, IAgent<IAgentConfig>>;
3425
- /**
3426
- * Validate agent configuration
3427
- */
3428
- validateConfiguration(config: Partial<IAgentConfig>): {
3429
- isValid: boolean;
3430
- errors: string[];
3431
- };
3432
- /**
3433
- * Apply default configuration values
3434
- */
3435
- private applyDefaults;
3436
- /**
3437
- * Generate unique agent ID
3438
- */
3439
- private generateAgentId;
3440
- /**
3441
- * Update creation statistics
3442
- */
3443
- private updateCreationStats;
3444
- }
3445
-
3446
- /**
3447
- * Conversation session implementations.
3448
- *
3449
- * Extracted from conversation-history-manager.ts.
3450
- */
3451
-
3452
- /** API message format for provider consumption */
3453
- interface IProviderApiMessage {
3454
- role: string;
3455
- content: string | null;
3456
- tool_calls?: Array<{
3457
- id: string;
3458
- type: 'function';
3459
- function: {
3460
- name: string;
3461
- arguments: string;
3462
- };
3463
- }>;
3464
- tool_call_id?: string;
3465
- }
3466
- /**
3467
- * Conversation session with duplicate prevention and API format conversion.
3468
- * @public
3469
- */
3470
- declare class ConversationSession implements IConversationHistory {
3471
- private history;
3472
- private toolCallIds;
3473
- constructor(maxMessages?: number);
3474
- addMessage(message: TUniversalMessage): void;
3475
- addUserMessage(content: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
3476
- addAssistantMessage(content: string | null, toolCalls?: IToolCall[], metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
3477
- addSystemMessage(content: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
3478
- addToolMessage(content: string, toolCallId: string, toolName?: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
3479
- addToolMessageWithId(content: string, toolCallId: string, toolName: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
3480
- getMessages(): TUniversalMessage[];
3481
- getMessagesByRole(role: TUniversalMessageRole): TUniversalMessage[];
3482
- getRecentMessages(count: number): TUniversalMessage[];
3483
- getMessageCount(): number;
3484
- getMessagesForAPI(): IProviderApiMessage[];
3485
- clear(): void;
3486
- }
3487
-
3488
- /** Interface for managing conversation history. @public */
3489
- interface IConversationHistory {
3490
- addMessage(message: TUniversalMessage): void;
3491
- addUserMessage(content: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
3492
- addAssistantMessage(content: string | null, toolCalls?: IToolCall[], metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
3493
- addSystemMessage(content: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
3494
- addToolMessageWithId(content: string, toolCallId: string, toolName: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
3495
- getMessages(): TUniversalMessage[];
3496
- getMessagesByRole(role: TUniversalMessageRole): TUniversalMessage[];
3497
- getRecentMessages(count: number): TUniversalMessage[];
3498
- clear(): void;
3499
- getMessageCount(): number;
3500
- }
3501
- /** Configuration options for ConversationHistory manager */
3502
- interface IConversationHistoryOptions {
3503
- maxMessagesPerConversation?: number;
3504
- maxConversations?: number;
3505
- }
3506
- /** Multi-session conversation history manager. @public */
3507
- declare class ConversationHistory {
3508
- private conversations;
3509
- private logger;
3510
- private readonly maxMessagesPerConversation;
3511
- private readonly maxConversations;
3512
- constructor(options?: IConversationHistoryOptions);
3513
- getConversationSession(conversationId: string): ConversationSession;
3514
- hasConversation(conversationId: string): boolean;
3515
- removeConversation(conversationId: string): boolean;
3516
- clearAll(): void;
3517
- getStats(): {
3518
- totalConversations: number;
3519
- conversationIds: string[];
3520
- totalMessages: number;
3521
- };
3522
- }
3523
-
3524
- declare class EventHistoryModule implements IEventHistoryModule {
3525
- private readonly store;
3526
- private readonly listener;
3527
- private sequenceId;
3528
- constructor(store: IEventHistoryModule, eventService: IEventService);
3529
- append(record: IEventHistoryRecord): void;
3530
- read(fromSequenceId: number, toSequenceId?: number): IEventHistoryRecord[];
3531
- readStream(fromSequenceId: number, toSequenceId?: number): AsyncIterable<IEventHistoryRecord>;
3532
- getSnapshot(): IEventHistorySnapshot | undefined;
3533
- detach(eventService: IEventService): void;
3534
- private nextSequenceId;
3535
- }
3536
-
3537
- /**
3538
- * ExecutionService owned events.
3539
- * Local event names only (no dots). Full names are composed at emit time.
3540
- */
3541
- declare const EXECUTION_EVENTS: {
3542
- readonly START: "start";
3543
- readonly COMPLETE: "complete";
3544
- readonly ERROR: "error";
3545
- readonly ASSISTANT_MESSAGE_START: "assistant_message_start";
3546
- readonly ASSISTANT_MESSAGE_COMPLETE: "assistant_message_complete";
3547
- readonly USER_MESSAGE: "user_message";
3548
- readonly TOOL_RESULTS_TO_LLM: "tool_results_to_llm";
3549
- readonly TOOL_RESULTS_READY: "tool_results_ready";
3550
- };
3551
- declare const EXECUTION_EVENT_PREFIX: "execution";
3552
-
3553
- /**
3554
- * ToolExecutionService owned events
3555
- * Local event names only (no dots). Full names are composed at emit time.
3556
- */
3557
- declare const TOOL_EVENTS: {
3558
- readonly CALL_START: "call_start";
3559
- readonly CALL_COMPLETE: "call_complete";
3560
- readonly CALL_ERROR: "call_error";
3561
- readonly CALL_RESPONSE_READY: "call_response_ready";
3562
- };
3563
- declare const TOOL_EVENT_PREFIX: "tool";
3564
-
3565
- /**
3566
- * Agent event constants
3567
- *
3568
- * Events emitted by Agent instances themselves.
3569
- * Event names are local (no dots) and must be used via constants (no string literals).
3570
- */
3571
- declare const AGENT_EVENTS: {
3572
- /** Agent instance has been created and initialized */
3573
- readonly CREATED: "created";
3574
- /** Agent execution lifecycle - start */
3575
- readonly EXECUTION_START: "execution_start";
3576
- /** Agent execution lifecycle - complete */
3577
- readonly EXECUTION_COMPLETE: "execution_complete";
3578
- /** Agent execution lifecycle - error */
3579
- readonly EXECUTION_ERROR: "execution_error";
3580
- /** Agent aggregation process completed */
3581
- readonly AGGREGATION_COMPLETE: "aggregation_complete";
3582
- /** Agent configuration (e.g., tools) has been updated by the agent */
3583
- readonly CONFIG_UPDATED: "config_updated";
3584
- };
3585
- declare const AGENT_EVENT_PREFIX: "agent";
3586
-
3587
- /**
3588
- * Workflow Converter Interface
3589
- *
3590
- * Defines the contract for all workflow converters in the Robota SDK.
3591
- * Follows Interface Segregation Principle by providing minimal, focused interface.
3592
- *
3593
- * @template TInput - Input workflow data type
3594
- * @template TOutput - Output workflow data type
3595
- */
3596
-
3597
- /**
3598
- * Workflow configuration - uses base type for cross-converter compatibility
3599
- * Step 1: ❌ Can't assign number/boolean to config value type directly (index signature conflict)
3600
- * Step 2: ✅ TConfigValue already includes primitive types (number, boolean)
3601
- * Step 3: ✅ Fix index signature to allow optional properties
3602
- * Step 4: ✅ Use proper intersection type for compatibility
3603
- */
3604
- interface IWorkflowConfig {
3605
- timeout?: number;
3606
- retries?: number;
3607
- validateInput?: boolean;
3608
- validateOutput?: boolean;
3609
- [key: string]: TConfigValue | undefined;
3610
- }
3611
- /**
3612
- * Workflow metadata - uses base type for cross-converter compatibility
3613
- * Step 1: ❌ Can't assign Date/number/string to metadata value type directly (index signature conflict)
3614
- * Step 2: ✅ TMetadataValue already includes Date, primitive types
3615
- * Step 3: ✅ Fix index signature to allow optional properties
3616
- * Step 4: ✅ Use proper intersection type for compatibility
3617
- */
3618
- interface IWorkflowMetadata {
3619
- convertedAt?: Date;
3620
- processingTime?: number;
3621
- executionId?: string;
3622
- [key: string]: TMetadataValue | undefined;
3623
- }
3624
- /**
3625
- * Base workflow data constraint with flexible typing
3626
- * All workflow data must extend this interface for type safety
3627
- */
3628
- interface IWorkflowData {
3629
- readonly __workflowType?: string;
3630
- [key: string]: TUniversalValue | undefined;
3631
- }
3632
- /**
3633
- * Conversion options for workflow transformations
3634
- * Step 1: ❌ Can't assign IWorkflowConversionOptions to metadata value type (missing index signature)
3635
- * Step 2: ✅ Add index signature to make it compatible with MetadataValue
3636
- * Step 3: ✅ Maintain type safety while allowing metadata storage
3637
- * Step 4: ✅ Use MetadataValue compatibility for dynamic properties
3638
- */
3639
- interface IWorkflowConversionOptions {
3640
- /** Include debug information in output */
3641
- includeDebug?: boolean;
3642
- /** Validate input before conversion */
3643
- validateInput?: boolean;
3644
- /** Validate output after conversion */
3645
- validateOutput?: boolean;
3646
- /** Custom logger for conversion process */
3647
- logger?: ILogger;
3648
- /** Additional metadata to include */
3649
- metadata?: IWorkflowMetadata;
3650
- /** Platform-specific options */
3651
- platformOptions?: IWorkflowConfig;
3652
- /** Additional dynamic options compatible with TUniversalValue */
3653
- [key: string]: TUniversalValue | ILogger | IWorkflowMetadata | IWorkflowConfig | undefined;
3654
- }
3655
- /**
3656
- * Conversion result with metadata and validation info
3657
- */
3658
- interface IWorkflowConversionResult<TOutput> {
3659
- /** Converted workflow data */
3660
- data: TOutput;
3661
- /** Conversion success status */
3662
- success: boolean;
3663
- /** Validation errors (if any) */
3664
- errors: string[];
3665
- /** Validation warnings (if any) */
3666
- warnings: string[];
3667
- /** Conversion metadata */
3668
- metadata: IWorkflowConversionResultMetadata;
3669
- }
3670
- /**
3671
- * Workflow conversion metadata.
3672
- *
3673
- * IMPORTANT:
3674
- * - Do NOT intersect this object with `TMetadata`.
3675
- * - `TMetadata` has an index signature with a restricted value axis (`TMetadataValue`),
3676
- * which would force every property on this object to be assignable to `TMetadataValue`.
3677
- * - Keep structured fields here, and store additional key/value pairs under `extensions`.
3678
- */
3679
- interface IWorkflowConversionResultMetadata {
3680
- /** Conversion timestamp */
3681
- convertedAt: Date;
3682
- /** Processing time in milliseconds */
3683
- processingTime: number;
3684
- /** Input data statistics */
3685
- inputStats: {
3686
- nodeCount: number;
3687
- edgeCount: number;
3688
- };
3689
- /** Output data statistics */
3690
- outputStats: {
3691
- nodeCount: number;
3692
- edgeCount: number;
3693
- };
3694
- /** Converter name */
3695
- converter: string;
3696
- /** Converter version */
3697
- version: string;
3698
- /** Conversion options (optional, typically gated by includeDebug) */
3699
- options?: IWorkflowConversionOptions;
3700
- /**
3701
- * Additional key/value metadata (SSOT axis).
3702
- * Use this for dynamic metadata, not top-level ad-hoc fields.
3703
- */
3704
- extensions?: TMetadata;
3705
- }
3706
- /**
3707
- * Workflow Converter Interface
3708
- *
3709
- * Core interface for converting between different workflow representations.
3710
- * All workflow converters must implement this interface.
3711
- *
3712
- * @template TInput - Input workflow data type
3713
- * @template TOutput - Output workflow data type
3714
- */
3715
- interface IWorkflowConverter<TInput extends IWorkflowData, TOutput extends IWorkflowData> {
3716
- /** Converter name for identification */
3717
- readonly name: string;
3718
- /** Converter version */
3719
- readonly version: string;
3720
- /** Source format that this converter accepts */
3721
- readonly sourceFormat: string;
3722
- /** Target format that this converter produces */
3723
- readonly targetFormat: string;
3724
- /**
3725
- * Convert workflow data from input format to output format
3726
- *
3727
- * @param input - Input workflow data
3728
- * @param options - Conversion options
3729
- * @returns Promise resolving to conversion result
3730
- */
3731
- convert(input: TInput, options?: IWorkflowConversionOptions): Promise<IWorkflowConversionResult<TOutput>>;
3732
- /**
3733
- * Validate input data before conversion
3734
- *
3735
- * @param input - Input workflow data
3736
- * @returns Promise resolving to validation result
3737
- */
3738
- validateInput(input: TInput): Promise<{
3739
- isValid: boolean;
3740
- errors: string[];
3741
- warnings: string[];
3742
- }>;
3743
- /**
3744
- * Validate output data after conversion
3745
- *
3746
- * @param output - Output workflow data
3747
- * @returns Promise resolving to validation result
3748
- */
3749
- validateOutput(output: TOutput): Promise<{
3750
- isValid: boolean;
3751
- errors: string[];
3752
- warnings: string[];
3753
- }>;
3754
- /**
3755
- * Check if this converter supports the given input format
3756
- *
3757
- * @param input - Input data to check
3758
- * @returns True if converter can handle this input
3759
- */
3760
- canConvert(input: IWorkflowData): input is TInput;
3761
- /**
3762
- * Get conversion statistics and metrics
3763
- *
3764
- * @returns Converter performance metrics
3765
- */
3766
- getStats(): {
3767
- totalConversions: number;
3768
- successfulConversions: number;
3769
- failedConversions: number;
3770
- averageProcessingTime: number;
3771
- lastConversionAt?: Date;
3772
- };
3773
- /**
3774
- * Reset converter statistics
3775
- */
3776
- resetStats(): void;
3777
- }
3778
-
3779
- /**
3780
- * Workflow Validator Interface
3781
- *
3782
- * Defines the contract for workflow validation systems in the Robota SDK.
3783
- * Follows Single Responsibility Principle by focusing only on validation logic.
3784
- */
3785
-
3786
- /**
3787
- * Validation severity levels
3788
- */
3789
- declare enum ValidationSeverity {
3790
- ERROR = "error",
3791
- WARNING = "warning",
3792
- INFO = "info"
3793
- }
3794
- /**
3795
- * Individual validation issue
3796
- */
3797
- interface IValidationIssue {
3798
- /** Unique identifier for this issue */
3799
- id: string;
3800
- /** Issue severity level */
3801
- severity: ValidationSeverity;
3802
- /** Human-readable message */
3803
- message: string;
3804
- /** Technical details or suggestion */
3805
- details?: string;
3806
- /** Location where issue was found */
3807
- location?: {
3808
- nodeId?: string;
3809
- edgeId?: string;
3810
- field?: string;
3811
- line?: number;
3812
- column?: number;
3813
- };
3814
- /** Rule that triggered this issue */
3815
- rule: string;
3816
- /** Suggested fix (if available) */
3817
- suggestedFix?: {
3818
- description: string;
3819
- action: 'modify' | 'remove' | 'add';
3820
- target?: IWorkflowConfig;
3821
- };
3822
- /** Timestamp when issue was detected */
3823
- detectedAt: Date;
3824
- }
3825
- /**
3826
- * Validation options
3827
- */
3828
- interface IValidationOptions {
3829
- /** Validation strictness level */
3830
- strict?: boolean;
3831
- /** Skip specific validation rules */
3832
- skipRules?: string[];
3833
- /** Include only specific validation rules */
3834
- includeRules?: string[];
3835
- /** Maximum number of errors to collect */
3836
- maxErrors?: number;
3837
- /** Include warnings in results */
3838
- includeWarnings?: boolean;
3839
- /** Include info messages in results */
3840
- includeInfo?: boolean;
3841
- /** Custom logger for validation process */
3842
- logger?: ILogger;
3843
- /** Additional validation context */
3844
- context?: IWorkflowMetadata;
3845
- /** Enable auto-recovery suggestions */
3846
- enableAutoRecovery?: boolean;
3847
- }
3848
- /**
3849
- * Validation result
3850
- */
3851
- interface IValidationResult {
3852
- /** Overall validation success status */
3853
- isValid: boolean;
3854
- /** All validation issues found */
3855
- issues: IValidationIssue[];
3856
- /** Summary by severity */
3857
- summary: {
3858
- errorCount: number;
3859
- warningCount: number;
3860
- infoCount: number;
3861
- totalIssues: number;
3862
- };
3863
- /** Validation metadata */
3864
- metadata: {
3865
- /** Validation timestamp */
3866
- validatedAt: Date;
3867
- /** Processing time in milliseconds */
3868
- processingTime: number;
3869
- /** Validator used */
3870
- validator: string;
3871
- /** Validation rules applied */
3872
- rulesApplied: string[];
3873
- /** Data statistics */
3874
- dataStats: Record<string, string | number | boolean>;
3875
- /** Version */
3876
- version?: string;
3877
- /** Options */
3878
- options?: string | number | boolean | string[] | Date;
3879
- /** Additional metrics */
3880
- [key: string]: string | number | boolean | Date | string[] | Record<string, string | number | boolean> | undefined;
3881
- };
3882
- /** Auto-recovery suggestions (if enabled) */
3883
- recoveryOptions?: Array<{
3884
- description: string;
3885
- confidence: number;
3886
- action: () => Promise<IWorkflowConfig>;
3887
- }>;
3888
- }
3889
- /**
3890
- * Workflow Validator Interface
3891
- *
3892
- * Core interface for validating workflow data structures.
3893
- * All workflow validators must implement this interface.
3894
- *
3895
- * @template TWorkflowData - Type of workflow data to validate
3896
- */
3897
- interface IWorkflowValidator<TWorkflowData extends IWorkflowData> {
3898
- /** Validator name for identification */
3899
- readonly name: string;
3900
- /** Validator version */
3901
- readonly version: string;
3902
- /** Data format that this validator handles */
3903
- readonly dataFormat: string;
3904
- /** Available validation rules */
3905
- readonly availableRules: string[];
3906
- /**
3907
- * Validate workflow data
3908
- *
3909
- * @param data - Workflow data to validate
3910
- * @param options - Validation options
3911
- * @returns Promise resolving to validation result
3912
- */
3913
- validate(data: TWorkflowData, options?: IValidationOptions): Promise<IValidationResult>;
3914
- /**
3915
- * Validate specific aspect of workflow data
3916
- *
3917
- * @param data - Workflow data to validate
3918
- * @param rule - Specific rule to apply
3919
- * @param options - Validation options
3920
- * @returns Promise resolving to validation result for this rule
3921
- */
3922
- validateRule(data: TWorkflowData, rule: string, options?: IValidationOptions): Promise<IValidationResult>;
3923
- /**
3924
- * Check if validator can handle the given data format
3925
- *
3926
- * @param data - Data to check
3927
- * @returns True if validator can handle this data
3928
- */
3929
- canValidate(data: IWorkflowData): data is TWorkflowData;
3930
- /**
3931
- * Get available validation rules with descriptions
3932
- *
3933
- * @returns Map of rule names to descriptions
3934
- */
3935
- getRuleDescriptions(): Map<string, {
3936
- description: string;
3937
- severity: ValidationSeverity;
3938
- category: string;
3939
- enabled: boolean;
3940
- }>;
3941
- /**
3942
- * Enable or disable specific validation rules
3943
- *
3944
- * @param rules - Map of rule names to enabled status
3945
- */
3946
- configureRules(rules: Map<string, boolean>): void;
3947
- /**
3948
- * Perform automatic recovery for validation issues
3949
- *
3950
- * @param data - Original workflow data
3951
- * @param issues - Validation issues to recover from
3952
- * @returns Promise resolving to recovered data and recovery result
3953
- */
3954
- autoRecover(data: TWorkflowData, issues: IValidationIssue[]): Promise<{
3955
- recoveredData: TWorkflowData;
3956
- recoveryResult: {
3957
- success: boolean;
3958
- issuesFixed: IValidationIssue[];
3959
- remainingIssues: IValidationIssue[];
3960
- appliedFixes: string[];
3961
- };
3962
- }>;
3963
- /**
3964
- * Get validator statistics and metrics
3965
- *
3966
- * @returns Validator performance metrics
3967
- */
3968
- getStats(): {
3969
- totalValidations: number;
3970
- successfulValidations: number;
3971
- failedValidations: number;
3972
- averageProcessingTime: number;
3973
- averageIssueCount: number;
3974
- mostCommonIssues: Array<{
3975
- rule: string;
3976
- count: number;
3977
- severity: ValidationSeverity;
3978
- }>;
3979
- lastValidationAt?: Date;
3980
- };
3981
- /**
3982
- * Reset validator statistics
3983
- */
3984
- resetStats(): void;
3985
- }
3986
-
3987
- /**
3988
- * Configuration for execution proxy
3989
- */
3990
- interface IExecutionProxyConfig {
3991
- eventService: IEventService;
3992
- sourceType: 'agent' | 'team' | 'tool';
3993
- sourceId: string;
3994
- enabledEvents?: {
3995
- execution?: boolean;
3996
- toolCall?: boolean;
3997
- task?: boolean;
3998
- };
3999
- }
4000
- /**
4001
- * Metadata extractor function type
4002
- */
4003
- type TExecutionProxyTarget = Record<string, TUniversalValue>;
4004
- type TExecutionProxyArgs = TUniversalValue[];
4005
- type TMetadataExtractor = (target: TExecutionProxyTarget, methodName: string, args: TExecutionProxyArgs) => Record<string, TUniversalValue>;
4006
- /**
4007
- * Method configuration for proxy
4008
- */
4009
- interface IMethodConfig {
4010
- startEvent?: string;
4011
- completeEvent?: string;
4012
- errorEvent?: string;
4013
- extractMetadata?: TMetadataExtractor;
4014
- extractResult?: (result: TUniversalValue) => Record<string, TUniversalValue>;
4015
- }
4016
- /**
4017
- * ExecutionProxy - Automatic event emission using Proxy pattern
4018
- *
4019
- * This class wraps target objects and automatically emits events
4020
- * around method execution without modifying business logic.
4021
- *
4022
- * Benefits:
4023
- * - Zero business logic pollution
4024
- * - Automatic event emission
4025
- * - Configurable per method
4026
- * - AOP (Aspect-Oriented Programming) pattern
4027
- */
4028
- declare class ExecutionProxy<T extends object = object> {
4029
- private config;
4030
- private methodConfigs;
4031
- constructor(config: IExecutionProxyConfig);
4032
- /**
4033
- * Configure specific methods for event emission
4034
- */
4035
- configureMethod(methodName: string, config: IMethodConfig): this;
4036
- /**
4037
- * Configure multiple methods with standard patterns
4038
- */
4039
- configureStandardMethods(): this;
4040
- /**
4041
- * Create a proxy wrapper around the target object
4042
- */
4043
- wrap(target: T): T;
4044
- /**
4045
- * Emit event with standard ServiceEventData format
4046
- */
4047
- private emitEvent;
4048
- /**
4049
- * Generate unique execution ID
4050
- */
4051
- private generateExecutionId;
4052
- }
4053
- /**
4054
- * Factory function to create execution proxy with standard configuration
4055
- */
4056
- declare function createExecutionProxy<T extends object>(target: T, config: IExecutionProxyConfig): T;
4057
- /**
4058
- * Decorator function for automatic event emission
4059
- * Usage: @withEventEmission(eventService, 'agent', 'agent-id')
4060
- */
4061
- declare function withEventEmission(eventService: IEventService, sourceType: 'agent' | 'team' | 'tool', sourceId: string): <T extends object>(target: T) => T;
4062
-
4063
- /**
4064
- * Permission system types — Claude Code compatible permission model.
4065
- */
4066
- /**
4067
- * Permission modes (Claude Code compatible)
4068
- * - plan: read-only tools only
4069
- * - default: reads auto, writes/bash need approval
4070
- * - acceptEdits: reads + writes auto, bash needs approval
4071
- * - bypassPermissions: all tools auto
4072
- */
4073
- type TPermissionMode = 'plan' | 'default' | 'acceptEdits' | 'bypassPermissions';
4074
- /**
4075
- * Friendly trust level aliases
4076
- * - safe → plan
4077
- * - moderate → default
4078
- * - full → acceptEdits
4079
- */
4080
- type TTrustLevel = 'safe' | 'moderate' | 'full';
4081
- declare const TRUST_TO_MODE: Record<TTrustLevel, TPermissionMode>;
4082
- /**
4083
- * Outcome of a permission evaluation
4084
- * - auto: proceed without prompting
4085
- * - approve: prompt user for approval
4086
- * - deny: block the action
4087
- */
4088
- type TPermissionDecision = 'auto' | 'approve' | 'deny';
4089
-
4090
- /**
4091
- * Permission gate — evaluates whether a tool call is auto-approved, needs user approval, or denied.
4092
- *
4093
- * Three-step deterministic policy (in order of precedence):
4094
- * 1. Deny list match → deny
4095
- * 2. Allow list match → auto
4096
- * 3. Mode policy lookup
4097
- *
4098
- * Pattern syntax (same as Claude Code):
4099
- * - `Bash(pnpm *)` — Bash tool whose command starts with "pnpm "
4100
- * - `Read(/src/**)` — Read tool whose filePath is under /src/
4101
- * - `Write(*)` — Write tool with any argument
4102
- * - `ToolName` — match any invocation of that tool
4103
- */
4104
-
4105
- /**
4106
- * Tool arguments passed from the LLM invocation.
4107
- * The values relevant to permission matching are strings.
4108
- */
4109
- type TToolArgs = Record<string, string | number | boolean | object>;
4110
- /**
4111
- * Permission list entries (allow / deny).
4112
- * Each entry is a pattern string such as "Bash(pnpm *)" or "Read(/src/**)".
4113
- */
4114
- interface IPermissionLists {
4115
- allow?: string[];
4116
- deny?: string[];
4117
- }
4118
- /**
4119
- * Evaluate whether a tool invocation should be auto-approved, require user approval, or be denied.
4120
- *
4121
- * @param toolName Name of the tool being invoked (e.g. "Bash", "Write")
4122
- * @param toolArgs Arguments provided by the LLM
4123
- * @param mode Active permission mode
4124
- * @param permissions Optional allow/deny lists from config
4125
- */
4126
- declare function evaluatePermission(toolName: string, toolArgs: TToolArgs, mode: TPermissionMode, permissions?: IPermissionLists): TPermissionDecision;
4127
-
4128
- /**
4129
- * Permission mode definitions for Robota CLI
4130
- *
4131
- * Matches Claude Code-compatible permission modes:
4132
- * - plan: read-only tools only (Read, Glob, Grep auto; Write, Edit, Bash denied)
4133
- * - default: safe reads auto, writes and bash need approval
4134
- * - acceptEdits: reads + writes auto, bash needs approval
4135
- * - bypassPermissions: all tools auto
4136
- */
4137
-
4138
- /**
4139
- * Tool names known to the permission system
4140
- */
4141
- type TKnownToolName = 'Bash' | 'Read' | 'Write' | 'Edit' | 'Glob' | 'Grep';
4142
- /**
4143
- * Permission mode → tool policy matrix
4144
- * Maps each mode to a decision for each known tool.
4145
- */
4146
- declare const MODE_POLICY: Record<TPermissionMode, Record<TKnownToolName, TPermissionDecision>>;
4147
- /**
4148
- * Fallback decision when a tool name is not in the policy matrix.
4149
- * Unknown tools are treated as requiring approval (fail-safe).
4150
- */
4151
- declare const UNKNOWN_TOOL_FALLBACK: Record<TPermissionMode, TPermissionDecision>;
4152
-
4153
- /**
4154
- * Context window tracking types.
4155
- *
4156
- * These types are used by agent-sessions (and downstream packages) to
4157
- * track token usage and context window state across conversation turns.
4158
- */
4159
- /** Token usage from a single API call (Anthropic-style granularity) */
4160
- interface IContextTokenUsage {
4161
- inputTokens: number;
4162
- outputTokens: number;
4163
- cacheCreationTokens?: number;
4164
- cacheReadTokens?: number;
4165
- }
4166
- /** Context window state snapshot */
4167
- interface IContextWindowState {
4168
- /** Max tokens for the current model */
4169
- maxTokens: number;
4170
- /** Current estimated token usage (input + cache, excludes output) */
4171
- usedTokens: number;
4172
- /** Usage percentage (0-100) */
4173
- usedPercentage: number;
4174
- /** Remaining percentage (0-100) */
4175
- remainingPercentage: number;
4176
- }
4177
-
4178
- /**
4179
- * Hook system types — Claude Code compatible event/hook model.
4180
- */
4181
- /** Hook lifecycle events */
4182
- type THookEvent = 'PreToolUse' | 'PostToolUse' | 'SessionStart' | 'Stop' | 'PreCompact' | 'PostCompact';
4183
- /** A single hook definition */
4184
- interface IHookDefinition {
4185
- /** Shell command to execute */
4186
- type: 'command';
4187
- command: string;
4188
- }
4189
- /** A hook group — matcher + array of hook definitions */
4190
- interface IHookGroup {
4191
- /** Regex pattern to match tool name (empty string = match all) */
4192
- matcher: string;
4193
- hooks: IHookDefinition[];
4194
- }
4195
- /** Complete hooks configuration: event → array of hook groups */
4196
- type THooksConfig = Partial<Record<THookEvent, IHookGroup[]>>;
4197
- /** Input passed to hook commands via stdin */
4198
- interface IHookInput {
4199
- session_id: string;
4200
- cwd: string;
4201
- hook_event_name: THookEvent;
4202
- tool_name?: string;
4203
- tool_input?: Record<string, string | number | boolean | object>;
4204
- tool_output?: string;
4205
- /** Compaction trigger source (PreCompact/PostCompact only) */
4206
- trigger?: 'auto' | 'manual';
4207
- /** Compaction summary text (PostCompact only) */
4208
- compact_summary?: string;
4209
- }
4210
- /** Hook execution result */
4211
- interface IHookResult {
4212
- /** 0 = allow/proceed, 2 = block/deny, other = proceed with warning */
4213
- exitCode: number;
4214
- stdout: string;
4215
- stderr: string;
4216
- }
4217
-
4218
- /**
4219
- * Hook runner — executes shell command hooks for lifecycle events.
4220
- *
4221
- * Hooks receive JSON input on stdin and communicate results via exit codes:
4222
- * - 0: allow/proceed
4223
- * - 2: block/deny (stderr contains reason)
4224
- * - other: proceed (logged as warning)
4225
- */
4226
-
4227
- /**
4228
- * Run all hooks for a given event.
4229
- *
4230
- * For PreToolUse: if any hook returns exit code 2, the tool call is blocked.
4231
- * Returns { blocked: true, reason: string } if blocked, { blocked: false } otherwise.
4232
- */
4233
- declare function runHooks(config: THooksConfig | undefined, event: THookEvent, input: IHookInput): Promise<{
4234
- blocked: boolean;
4235
- reason?: string;
4236
- }>;
4237
-
4238
- export { AGENT_EVENTS, AGENT_EVENT_PREFIX, AbstractAIProvider, AbstractAgent, AbstractExecutor, AbstractManager, AbstractPlugin, AbstractTool, AgentFactory, AgentTemplates, AuthenticationError, CacheIntegrityError, CircuitBreakerOpenError, ConfigurationError, ConversationHistory, ConversationSession, EVENT_EMITTER_EVENTS, EXECUTION_EVENTS, EXECUTION_EVENT_PREFIX, ErrorUtils, EventEmitterPlugin, EventHistoryModule, ExecutionProxy, type IAIProvider, type IAIProviderInstance, type IAIProviderManager, type IAbstractTool, type IAbstractToolOptions, type IAgent, type IAgentConfig, type IAgentCreationOptions, type IAgentCreationStats, type IAgentEventData, type IAgentFactory, type IAgentFactoryOptions, type IAgentLifecycleEvents, type IAgentTemplate, type IAssistantMessage, type IBaseEventData, type IBaseMessage, type ICacheEntry, type ICacheKey, type ICacheOptions, type ICacheStats, type ICacheStorage, type IChatExecutionRequest, type IChatOptions, type IConfigValidationResult, type IContextOptions, type IContextTokenUsage, type IContextWindowState, type IConversationContext, type IConversationResponse, type IConversationService, type IConversationServiceOptions, type IEventContext, type IEventEmitterEventData, type IEventEmitterHierarchicalEventData, type IEventEmitterMetrics, type IEventEmitterMetricsSnapshot, type IEventEmitterPlugin, type IEventEmitterPluginOptions, type IEventHistoryModule, type IEventHistoryRecord, type IEventHistorySnapshot, type IEventService, type IEventServiceOwnerBinding, type IExecutionEventData, type IExecutionService, type IExecutionServiceOptions, type IExecutor, type IExecutorAwareProviderConfig, type IFunctionTool, type IHookDefinition, type IHookGroup, type IHookInput, type IHookResult, type IImageComposeRequest, type IImageEditRequest, type IImageGenerationProvider, type IImageGenerationRequest, type IImageGenerationResult, type IInlineImageInputSource, type IInlineImageMessagePart, type ILocalExecutorConfig, type ILogger, type IMCPToolConfig, type IMediaOutputRef, type IOpenAPIToolConfig, type IOwnerPathSegment, type IParameterSchema, type IParameterValidationResult, type IPermissionLists, type IPlugin, type IPluginConfig, type IPluginContext, type IPluginContract, type IPluginData, type IPluginErrorContext, type IPluginExecutionContext, type IPluginExecutionResult, type IPluginHooks, type IPluginOptions, type IPluginStats, type IProgressReportingTool, type IProviderConfig, type IProviderMediaError, type IProviderOptions, type IProviderRequest, type IProviderSpecificOptions, type IRawProviderResponse, type IRemoteExecutorConfig, type IRunOptions, type ISimpleValidationResult, type IStreamExecutionRequest, type IStreamingChunk, type ISystemMessage, type ITemplateApplicationResult, type ITextMessagePart, type ITokenUsage, type ITool, type IToolCall, type IToolContract, type IToolEventData, type IToolExecutionContext, type IToolExecutionRequest, type IToolExecutionResult, type IToolExecutionService, type IToolExecutionStep, type IToolFactory, type IToolManager, type IToolMessage, type IToolRegistry, type IToolResult, type IToolSchema, type IToolWithEventService, type IUniversalObjectValue, type IUriImageInputSource, type IUriImageMessagePart, type IUserMessage, type IUtilLogEntry, type IValidationIssue, type IValidationOptions, type IValidationResult, type IVideoGenerationProvider, type IVideoGenerationRequest, type IVideoJobAccepted, type IVideoJobSnapshot, type IWorkflowConfig, type IWorkflowConversionOptions, type IWorkflowConversionResult, type IWorkflowConverter, type IWorkflowData, type IWorkflowMetadata, type IWorkflowValidator, InMemoryEventEmitterMetrics, LocalExecutor, MODE_POLICY, MessageConverter, ModelNotAvailableError, NetworkError, PluginCategory, PluginError, PluginPriority, ProviderError, RateLimitError, Robota, RobotaError, SilentLogger, StorageError, type TAgentCreationMetadata, type TComplexConfigValue, type TConfigData, type TConfigValue, type TContextData, type TConversationContextMetadata, type TErrorContextData, type TErrorExternalInput, type TEventEmitterListener, type TEventListener, type TEventName, type TExecutionEventName, type TExecutionMetadata, type THookEvent, type THooksConfig, type TImageInputSource, type TJSONSchemaEnum, type TJSONSchemaKind, type TKnownToolName, type TLoggerData, type TManagerToolParameters, type TMetadata, type TMetadataValue, TOOL_EVENTS, TOOL_EVENT_PREFIX, type TParameterDefaultValue, type TPermissionDecision, type TPermissionMode, type TPrimitiveValue, type TProviderConfigValue, type TProviderLoggingData, type TProviderMediaResult, type TProviderOptionValueBase, TRUST_TO_MODE, type TResponseMetadata, type TTextDeltaCallback, type TTimerId, type TToolArgs, type TToolExecutionFunction, type TToolExecutionParameters, type TToolExecutor, type TToolMetadata, type TToolParameters, type TToolProgressCallback, type TTrustLevel, type TUniversalArrayValue, type TUniversalMessage, type TUniversalMessageMetadata, type TUniversalMessagePart, type TUniversalMessageRole, type TUniversalValue, type TUtilLogLevel, ToolExecutionError, UNKNOWN_TOOL_FALLBACK, ValidationError, ValidationSeverity, Validator, createExecutionProxy, createLogger, evaluatePermission, getGlobalLogLevel, getToolEstimatedDuration, getToolExecutionSteps, isAssistantMessage, isImageGenerationProvider, isProgressReportingTool, isSystemMessage, isToolMessage, isUserMessage, isVideoGenerationProvider, logger, runHooks, setGlobalLogLevel, setToolProgressCallback, startPeriodicTask, stopPeriodicTask, validateAgentConfig, validateApiKey, validateModelName, validateProviderName, validateUserInput, withEventEmission };