@vertesia/common 0.24.0-dev.202601221707

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 (388) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +53 -0
  3. package/lib/cjs/Progress.js +61 -0
  4. package/lib/cjs/Progress.js.map +1 -0
  5. package/lib/cjs/access-control.js +56 -0
  6. package/lib/cjs/access-control.js.map +1 -0
  7. package/lib/cjs/analytics.js +3 -0
  8. package/lib/cjs/analytics.js.map +1 -0
  9. package/lib/cjs/apikey.js +16 -0
  10. package/lib/cjs/apikey.js.map +1 -0
  11. package/lib/cjs/apps.js +35 -0
  12. package/lib/cjs/apps.js.map +1 -0
  13. package/lib/cjs/ask-user.js +8 -0
  14. package/lib/cjs/ask-user.js.map +1 -0
  15. package/lib/cjs/channels.js +63 -0
  16. package/lib/cjs/channels.js.map +1 -0
  17. package/lib/cjs/common.js +3 -0
  18. package/lib/cjs/common.js.map +1 -0
  19. package/lib/cjs/data-platform.js +127 -0
  20. package/lib/cjs/data-platform.js.map +1 -0
  21. package/lib/cjs/email.js +20 -0
  22. package/lib/cjs/email.js.map +1 -0
  23. package/lib/cjs/environment.js +44 -0
  24. package/lib/cjs/environment.js.map +1 -0
  25. package/lib/cjs/facets.js +3 -0
  26. package/lib/cjs/facets.js.map +1 -0
  27. package/lib/cjs/group.js +5 -0
  28. package/lib/cjs/group.js.map +1 -0
  29. package/lib/cjs/index.js +55 -0
  30. package/lib/cjs/index.js.map +1 -0
  31. package/lib/cjs/integrations.js +14 -0
  32. package/lib/cjs/integrations.js.map +1 -0
  33. package/lib/cjs/interaction.js +97 -0
  34. package/lib/cjs/interaction.js.map +1 -0
  35. package/lib/cjs/json-schema.js +3 -0
  36. package/lib/cjs/json-schema.js.map +1 -0
  37. package/lib/cjs/json.js +3 -0
  38. package/lib/cjs/json.js.map +1 -0
  39. package/lib/cjs/meters.js +13 -0
  40. package/lib/cjs/meters.js.map +1 -0
  41. package/lib/cjs/model_utility.js +6 -0
  42. package/lib/cjs/model_utility.js.map +1 -0
  43. package/lib/cjs/package.json +3 -0
  44. package/lib/cjs/payload.js +3 -0
  45. package/lib/cjs/payload.js.map +1 -0
  46. package/lib/cjs/pending-asks.js +7 -0
  47. package/lib/cjs/pending-asks.js.map +1 -0
  48. package/lib/cjs/project.js +107 -0
  49. package/lib/cjs/project.js.map +1 -0
  50. package/lib/cjs/prompt.js +21 -0
  51. package/lib/cjs/prompt.js.map +1 -0
  52. package/lib/cjs/query.js +3 -0
  53. package/lib/cjs/query.js.map +1 -0
  54. package/lib/cjs/rate-limiter.js +6 -0
  55. package/lib/cjs/rate-limiter.js.map +1 -0
  56. package/lib/cjs/refs.js +14 -0
  57. package/lib/cjs/refs.js.map +1 -0
  58. package/lib/cjs/runs.js +3 -0
  59. package/lib/cjs/runs.js.map +1 -0
  60. package/lib/cjs/skill.js +14 -0
  61. package/lib/cjs/skill.js.map +1 -0
  62. package/lib/cjs/store/activity-catalog.js +3 -0
  63. package/lib/cjs/store/activity-catalog.js.map +1 -0
  64. package/lib/cjs/store/collections.js +9 -0
  65. package/lib/cjs/store/collections.js.map +1 -0
  66. package/lib/cjs/store/common.js +3 -0
  67. package/lib/cjs/store/common.js.map +1 -0
  68. package/lib/cjs/store/conversation-state.js +3 -0
  69. package/lib/cjs/store/conversation-state.js.map +1 -0
  70. package/lib/cjs/store/doc-analyzer.js +3 -0
  71. package/lib/cjs/store/doc-analyzer.js.map +1 -0
  72. package/lib/cjs/store/dsl-workflow.js +5 -0
  73. package/lib/cjs/store/dsl-workflow.js.map +1 -0
  74. package/lib/cjs/store/index.js +30 -0
  75. package/lib/cjs/store/index.js.map +1 -0
  76. package/lib/cjs/store/object-types.js +98 -0
  77. package/lib/cjs/store/object-types.js.map +1 -0
  78. package/lib/cjs/store/schedule.js +32 -0
  79. package/lib/cjs/store/schedule.js.map +1 -0
  80. package/lib/cjs/store/signals.js +3 -0
  81. package/lib/cjs/store/signals.js.map +1 -0
  82. package/lib/cjs/store/store.js +166 -0
  83. package/lib/cjs/store/store.js.map +1 -0
  84. package/lib/cjs/store/temporalio.js +44 -0
  85. package/lib/cjs/store/temporalio.js.map +1 -0
  86. package/lib/cjs/store/worker.js +3 -0
  87. package/lib/cjs/store/worker.js.map +1 -0
  88. package/lib/cjs/store/workflow.js +241 -0
  89. package/lib/cjs/store/workflow.js.map +1 -0
  90. package/lib/cjs/sts-token-types.js +32 -0
  91. package/lib/cjs/sts-token-types.js.map +1 -0
  92. package/lib/cjs/tenant.js +3 -0
  93. package/lib/cjs/tenant.js.map +1 -0
  94. package/lib/cjs/tool-execution.js +6 -0
  95. package/lib/cjs/tool-execution.js.map +1 -0
  96. package/lib/cjs/training.js +14 -0
  97. package/lib/cjs/training.js.map +1 -0
  98. package/lib/cjs/transient-tokens.js +9 -0
  99. package/lib/cjs/transient-tokens.js.map +1 -0
  100. package/lib/cjs/user.js +25 -0
  101. package/lib/cjs/user.js.map +1 -0
  102. package/lib/cjs/utils/auth.js +15 -0
  103. package/lib/cjs/utils/auth.js.map +1 -0
  104. package/lib/cjs/utils/schemas.js +114 -0
  105. package/lib/cjs/utils/schemas.js.map +1 -0
  106. package/lib/cjs/utils/type-helpers.js +3 -0
  107. package/lib/cjs/utils/type-helpers.js.map +1 -0
  108. package/lib/cjs/versions.js +8 -0
  109. package/lib/cjs/versions.js.map +1 -0
  110. package/lib/cjs/workflow-analytics.js +52 -0
  111. package/lib/cjs/workflow-analytics.js.map +1 -0
  112. package/lib/esm/Progress.js +57 -0
  113. package/lib/esm/Progress.js.map +1 -0
  114. package/lib/esm/access-control.js +53 -0
  115. package/lib/esm/access-control.js.map +1 -0
  116. package/lib/esm/analytics.js +2 -0
  117. package/lib/esm/analytics.js.map +1 -0
  118. package/lib/esm/apikey.js +13 -0
  119. package/lib/esm/apikey.js.map +1 -0
  120. package/lib/esm/apps.js +32 -0
  121. package/lib/esm/apps.js.map +1 -0
  122. package/lib/esm/ask-user.js +7 -0
  123. package/lib/esm/ask-user.js.map +1 -0
  124. package/lib/esm/channels.js +57 -0
  125. package/lib/esm/channels.js.map +1 -0
  126. package/lib/esm/common.js +2 -0
  127. package/lib/esm/common.js.map +1 -0
  128. package/lib/esm/data-platform.js +124 -0
  129. package/lib/esm/data-platform.js.map +1 -0
  130. package/lib/esm/email.js +16 -0
  131. package/lib/esm/email.js.map +1 -0
  132. package/lib/esm/environment.js +41 -0
  133. package/lib/esm/environment.js.map +1 -0
  134. package/lib/esm/facets.js +2 -0
  135. package/lib/esm/facets.js.map +1 -0
  136. package/lib/esm/group.js +2 -0
  137. package/lib/esm/group.js.map +1 -0
  138. package/lib/esm/index.js +39 -0
  139. package/lib/esm/index.js.map +1 -0
  140. package/lib/esm/integrations.js +11 -0
  141. package/lib/esm/integrations.js.map +1 -0
  142. package/lib/esm/interaction.js +92 -0
  143. package/lib/esm/interaction.js.map +1 -0
  144. package/lib/esm/json-schema.js +2 -0
  145. package/lib/esm/json-schema.js.map +1 -0
  146. package/lib/esm/json.js +2 -0
  147. package/lib/esm/json.js.map +1 -0
  148. package/lib/esm/meters.js +10 -0
  149. package/lib/esm/meters.js.map +1 -0
  150. package/lib/esm/model_utility.js +2 -0
  151. package/lib/esm/model_utility.js.map +1 -0
  152. package/lib/esm/payload.js +2 -0
  153. package/lib/esm/payload.js.map +1 -0
  154. package/lib/esm/pending-asks.js +6 -0
  155. package/lib/esm/pending-asks.js.map +1 -0
  156. package/lib/esm/project.js +102 -0
  157. package/lib/esm/project.js.map +1 -0
  158. package/lib/esm/prompt.js +18 -0
  159. package/lib/esm/prompt.js.map +1 -0
  160. package/lib/esm/query.js +2 -0
  161. package/lib/esm/query.js.map +1 -0
  162. package/lib/esm/rate-limiter.js +5 -0
  163. package/lib/esm/rate-limiter.js.map +1 -0
  164. package/lib/esm/refs.js +11 -0
  165. package/lib/esm/refs.js.map +1 -0
  166. package/lib/esm/runs.js +2 -0
  167. package/lib/esm/runs.js.map +1 -0
  168. package/lib/esm/skill.js +13 -0
  169. package/lib/esm/skill.js.map +1 -0
  170. package/lib/esm/store/activity-catalog.js +2 -0
  171. package/lib/esm/store/activity-catalog.js.map +1 -0
  172. package/lib/esm/store/collections.js +6 -0
  173. package/lib/esm/store/collections.js.map +1 -0
  174. package/lib/esm/store/common.js +2 -0
  175. package/lib/esm/store/common.js.map +1 -0
  176. package/lib/esm/store/conversation-state.js +2 -0
  177. package/lib/esm/store/conversation-state.js.map +1 -0
  178. package/lib/esm/store/doc-analyzer.js +2 -0
  179. package/lib/esm/store/doc-analyzer.js.map +1 -0
  180. package/lib/esm/store/dsl-workflow.js +2 -0
  181. package/lib/esm/store/dsl-workflow.js.map +1 -0
  182. package/lib/esm/store/index.js +14 -0
  183. package/lib/esm/store/index.js.map +1 -0
  184. package/lib/esm/store/object-types.js +95 -0
  185. package/lib/esm/store/object-types.js.map +1 -0
  186. package/lib/esm/store/schedule.js +29 -0
  187. package/lib/esm/store/schedule.js.map +1 -0
  188. package/lib/esm/store/signals.js +2 -0
  189. package/lib/esm/store/signals.js.map +1 -0
  190. package/lib/esm/store/store.js +160 -0
  191. package/lib/esm/store/store.js.map +1 -0
  192. package/lib/esm/store/temporalio.js +41 -0
  193. package/lib/esm/store/temporalio.js.map +1 -0
  194. package/lib/esm/store/worker.js +2 -0
  195. package/lib/esm/store/worker.js.map +1 -0
  196. package/lib/esm/store/workflow.js +228 -0
  197. package/lib/esm/store/workflow.js.map +1 -0
  198. package/lib/esm/sts-token-types.js +24 -0
  199. package/lib/esm/sts-token-types.js.map +1 -0
  200. package/lib/esm/tenant.js +2 -0
  201. package/lib/esm/tenant.js.map +1 -0
  202. package/lib/esm/tool-execution.js +5 -0
  203. package/lib/esm/tool-execution.js.map +1 -0
  204. package/lib/esm/training.js +11 -0
  205. package/lib/esm/training.js.map +1 -0
  206. package/lib/esm/transient-tokens.js +6 -0
  207. package/lib/esm/transient-tokens.js.map +1 -0
  208. package/lib/esm/user.js +22 -0
  209. package/lib/esm/user.js.map +1 -0
  210. package/lib/esm/utils/auth.js +11 -0
  211. package/lib/esm/utils/auth.js.map +1 -0
  212. package/lib/esm/utils/schemas.js +107 -0
  213. package/lib/esm/utils/schemas.js.map +1 -0
  214. package/lib/esm/utils/type-helpers.js +2 -0
  215. package/lib/esm/utils/type-helpers.js.map +1 -0
  216. package/lib/esm/versions.js +5 -0
  217. package/lib/esm/versions.js.map +1 -0
  218. package/lib/esm/workflow-analytics.js +49 -0
  219. package/lib/esm/workflow-analytics.js.map +1 -0
  220. package/lib/tsconfig.tsbuildinfo +1 -0
  221. package/lib/types/Progress.d.ts +21 -0
  222. package/lib/types/Progress.d.ts.map +1 -0
  223. package/lib/types/access-control.d.ts +73 -0
  224. package/lib/types/access-control.d.ts.map +1 -0
  225. package/lib/types/analytics.d.ts +87 -0
  226. package/lib/types/analytics.d.ts.map +1 -0
  227. package/lib/types/apikey.d.ts +98 -0
  228. package/lib/types/apikey.d.ts.map +1 -0
  229. package/lib/types/apps.d.ts +236 -0
  230. package/lib/types/apps.d.ts.map +1 -0
  231. package/lib/types/ask-user.d.ts +32 -0
  232. package/lib/types/ask-user.d.ts.map +1 -0
  233. package/lib/types/channels.d.ts +21 -0
  234. package/lib/types/channels.d.ts.map +1 -0
  235. package/lib/types/common.d.ts +31 -0
  236. package/lib/types/common.d.ts.map +1 -0
  237. package/lib/types/data-platform.d.ts +860 -0
  238. package/lib/types/data-platform.d.ts.map +1 -0
  239. package/lib/types/email.d.ts +66 -0
  240. package/lib/types/email.d.ts.map +1 -0
  241. package/lib/types/environment.d.ts +106 -0
  242. package/lib/types/environment.d.ts.map +1 -0
  243. package/lib/types/facets.d.ts +34 -0
  244. package/lib/types/facets.d.ts.map +1 -0
  245. package/lib/types/group.d.ts +21 -0
  246. package/lib/types/group.d.ts.map +1 -0
  247. package/lib/types/index.d.ts +39 -0
  248. package/lib/types/index.d.ts.map +1 -0
  249. package/lib/types/integrations.d.ts +60 -0
  250. package/lib/types/integrations.d.ts.map +1 -0
  251. package/lib/types/interaction.d.ts +958 -0
  252. package/lib/types/interaction.d.ts.map +1 -0
  253. package/lib/types/json-schema.d.ts +1 -0
  254. package/lib/types/json-schema.d.ts.map +1 -0
  255. package/lib/types/json.d.ts +1 -0
  256. package/lib/types/json.d.ts.map +1 -0
  257. package/lib/types/meters.d.ts +23 -0
  258. package/lib/types/meters.d.ts.map +1 -0
  259. package/lib/types/model_utility.d.ts +1 -0
  260. package/lib/types/model_utility.d.ts.map +1 -0
  261. package/lib/types/payload.d.ts +60 -0
  262. package/lib/types/payload.d.ts.map +1 -0
  263. package/lib/types/pending-asks.d.ts +93 -0
  264. package/lib/types/pending-asks.d.ts.map +1 -0
  265. package/lib/types/project.d.ts +179 -0
  266. package/lib/types/project.d.ts.map +1 -0
  267. package/lib/types/prompt.d.ts +78 -0
  268. package/lib/types/prompt.d.ts.map +1 -0
  269. package/lib/types/query.d.ts +118 -0
  270. package/lib/types/query.d.ts.map +1 -0
  271. package/lib/types/rate-limiter.d.ts +28 -0
  272. package/lib/types/rate-limiter.d.ts.map +1 -0
  273. package/lib/types/refs.d.ts +22 -0
  274. package/lib/types/refs.d.ts.map +1 -0
  275. package/lib/types/runs.d.ts +32 -0
  276. package/lib/types/runs.d.ts.map +1 -0
  277. package/lib/types/skill.d.ts +78 -0
  278. package/lib/types/skill.d.ts.map +1 -0
  279. package/lib/types/store/activity-catalog.d.ts +26 -0
  280. package/lib/types/store/activity-catalog.d.ts.map +1 -0
  281. package/lib/types/store/collections.d.ts +78 -0
  282. package/lib/types/store/collections.d.ts.map +1 -0
  283. package/lib/types/store/common.d.ts +22 -0
  284. package/lib/types/store/common.d.ts.map +1 -0
  285. package/lib/types/store/conversation-state.d.ts +120 -0
  286. package/lib/types/store/conversation-state.d.ts.map +1 -0
  287. package/lib/types/store/doc-analyzer.d.ts +140 -0
  288. package/lib/types/store/doc-analyzer.d.ts.map +1 -0
  289. package/lib/types/store/dsl-workflow.d.ts +244 -0
  290. package/lib/types/store/dsl-workflow.d.ts.map +1 -0
  291. package/lib/types/store/index.d.ts +13 -0
  292. package/lib/types/store/index.d.ts.map +1 -0
  293. package/lib/types/store/object-types.d.ts +23 -0
  294. package/lib/types/store/object-types.d.ts.map +1 -0
  295. package/lib/types/store/schedule.d.ts +182 -0
  296. package/lib/types/store/schedule.d.ts.map +1 -0
  297. package/lib/types/store/signals.d.ts +24 -0
  298. package/lib/types/store/signals.d.ts.map +1 -0
  299. package/lib/types/store/store.d.ts +407 -0
  300. package/lib/types/store/store.d.ts.map +1 -0
  301. package/lib/types/store/temporalio.d.ts +16 -0
  302. package/lib/types/store/temporalio.d.ts.map +1 -0
  303. package/lib/types/store/worker.d.ts +18 -0
  304. package/lib/types/store/worker.d.ts.map +1 -0
  305. package/lib/types/store/workflow.d.ts +730 -0
  306. package/lib/types/store/workflow.d.ts.map +1 -0
  307. package/lib/types/sts-token-types.d.ts +72 -0
  308. package/lib/types/sts-token-types.d.ts.map +1 -0
  309. package/lib/types/tenant.d.ts +10 -0
  310. package/lib/types/tenant.d.ts.map +1 -0
  311. package/lib/types/tool-execution.d.ts +45 -0
  312. package/lib/types/tool-execution.d.ts.map +1 -0
  313. package/lib/types/training.d.ts +38 -0
  314. package/lib/types/training.d.ts.map +1 -0
  315. package/lib/types/transient-tokens.d.ts +24 -0
  316. package/lib/types/transient-tokens.d.ts.map +1 -0
  317. package/lib/types/user.d.ts +116 -0
  318. package/lib/types/user.d.ts.map +1 -0
  319. package/lib/types/utils/auth.d.ts +3 -0
  320. package/lib/types/utils/auth.d.ts.map +1 -0
  321. package/lib/types/utils/schemas.d.ts +9 -0
  322. package/lib/types/utils/schemas.d.ts.map +1 -0
  323. package/lib/types/utils/type-helpers.d.ts +3 -0
  324. package/lib/types/utils/type-helpers.d.ts.map +1 -0
  325. package/lib/types/versions.d.ts +3 -0
  326. package/lib/types/versions.d.ts.map +1 -0
  327. package/lib/types/workflow-analytics.d.ts +777 -0
  328. package/lib/types/workflow-analytics.d.ts.map +1 -0
  329. package/lib/vertesia-common.js +2 -0
  330. package/lib/vertesia-common.js.map +1 -0
  331. package/package.json +54 -0
  332. package/src/Progress.ts +57 -0
  333. package/src/access-control.ts +98 -0
  334. package/src/analytics.ts +106 -0
  335. package/src/apikey.ts +116 -0
  336. package/src/apps.ts +296 -0
  337. package/src/ask-user.ts +35 -0
  338. package/src/channels.ts +70 -0
  339. package/src/common.ts +37 -0
  340. package/src/data-platform.ts +976 -0
  341. package/src/email.ts +80 -0
  342. package/src/environment.ts +137 -0
  343. package/src/facets.ts +44 -0
  344. package/src/group.ts +26 -0
  345. package/src/index.ts +40 -0
  346. package/src/integrations.ts +72 -0
  347. package/src/interaction.ts +1182 -0
  348. package/src/json-schema.ts +7 -0
  349. package/src/json.ts +4 -0
  350. package/src/meters.ts +30 -0
  351. package/src/model_utility.ts +1 -0
  352. package/src/payload.ts +83 -0
  353. package/src/pending-asks.ts +106 -0
  354. package/src/project.ts +263 -0
  355. package/src/prompt.ts +103 -0
  356. package/src/query.ts +137 -0
  357. package/src/rate-limiter.ts +34 -0
  358. package/src/refs.ts +30 -0
  359. package/src/runs.ts +36 -0
  360. package/src/skill.ts +90 -0
  361. package/src/store/activity-catalog.ts +44 -0
  362. package/src/store/collections.ts +87 -0
  363. package/src/store/common.ts +30 -0
  364. package/src/store/conversation-state.ts +146 -0
  365. package/src/store/doc-analyzer.ts +161 -0
  366. package/src/store/dsl-workflow.ts +288 -0
  367. package/src/store/index.ts +14 -0
  368. package/src/store/ms.d.ts +11 -0
  369. package/src/store/object-types.ts +127 -0
  370. package/src/store/schedule.ts +238 -0
  371. package/src/store/signals.ts +25 -0
  372. package/src/store/store.ts +579 -0
  373. package/src/store/temporalio.ts +54 -0
  374. package/src/store/worker.ts +19 -0
  375. package/src/store/workflow.test.ts +578 -0
  376. package/src/store/workflow.ts +973 -0
  377. package/src/sts-token-types.ts +117 -0
  378. package/src/tenant.ts +10 -0
  379. package/src/tool-execution.ts +47 -0
  380. package/src/training.ts +44 -0
  381. package/src/transient-tokens.ts +30 -0
  382. package/src/user.ts +153 -0
  383. package/src/utils/auth.ts +12 -0
  384. package/src/utils/schemas.ts +108 -0
  385. package/src/utils/type-helpers.ts +6 -0
  386. package/src/versions.ts +3 -0
  387. package/src/workflow-analytics.ts +925 -0
  388. package/tsconfig.dist.json +20 -0
@@ -0,0 +1,925 @@
1
+ /**
2
+ * Agent Observability Telemetry Types
3
+ *
4
+ * These types define the event-based model for agent observability.
5
+ */
6
+
7
+ // ============================================================================
8
+ // Enums
9
+ // ============================================================================
10
+
11
+ /**
12
+ * Types of telemetry events
13
+ */
14
+ export enum AgentEventType {
15
+ AgentRunStarted = 'agent_run_started',
16
+ AgentRunCompleted = 'agent_run_completed',
17
+ LlmCall = 'llm_call',
18
+ ToolCall = 'tool_call'
19
+ }
20
+
21
+ /**
22
+ * Types of LLM calls in a conversation
23
+ */
24
+ export enum LlmCallType {
25
+ /** Initial conversation start */
26
+ Start = 'start',
27
+ /** Resuming with tool results */
28
+ ResumeTools = 'resume_tools',
29
+ /** Resuming with user message */
30
+ ResumeUser = 'resume_user',
31
+ /** Checkpoint resume (after conversation summarization) */
32
+ Checkpoint = 'checkpoint',
33
+ /** Nested interaction call from within tools */
34
+ NestedInteraction = 'nested_interaction',
35
+
36
+ }
37
+
38
+ /**
39
+ * Types of tools that can be called
40
+ */
41
+ export enum TelemetryToolType {
42
+ /** Built-in tools (e.g., plan, search) */
43
+ Builtin = 'builtin',
44
+ /** Interaction-based tools */
45
+ Interaction = 'interaction',
46
+ /** Remote/MCP tools */
47
+ Remote = 'remote',
48
+ /** Skill tools */
49
+ Skill = 'skill',
50
+ }
51
+
52
+ // ============================================================================
53
+ // Base Event
54
+ // ============================================================================
55
+
56
+ /**
57
+ * Base interface for all telemetry events
58
+ */
59
+ export interface BaseAgentEvent {
60
+ /** Type of the event */
61
+ eventType: string;
62
+ /** ISO 8601 timestamp */
63
+ timestamp: string;
64
+ /** Globally unique ID for this agent run */
65
+ runId: string;
66
+ /** LLM model identifier (e.g., "claude-3-5-sonnet", "gemini-1.5-pro") */
67
+ model: string;
68
+ /** Environment ID (MongoDB ObjectId of the environment) */
69
+ environmentId: string;
70
+ /** Environment type/driver (e.g., "vertexai", "bedrock", "openai") */
71
+ environmentType: string;
72
+ /** Interaction ID (MongoDB ObjectId of the interaction) */
73
+ interactionId: string;
74
+ /** Immediate parent run ID (if this is a child workflow) */
75
+ parentRunId?: string;
76
+ /** Ancestor run IDs from root to immediate parent (for hierarchical aggregation) */
77
+ ancestorRunIds?: string[];
78
+ }
79
+
80
+ // ============================================================================
81
+ // Agent Run Events
82
+ // ============================================================================
83
+
84
+ /**
85
+ * Emitted when an agent run starts
86
+ */
87
+ export interface AgentRunStartedEvent extends BaseAgentEvent {
88
+ eventType: AgentEventType.AgentRunStarted;
89
+ /** Whether this is an interactive conversation */
90
+ interactive: boolean;
91
+ /** Task ID if part of a multi-workstream execution */
92
+ taskId?: string;
93
+ /** User channels enabled for this run (email, interactive, etc.) */
94
+ userChannels?: string[];
95
+ }
96
+
97
+ /**
98
+ * Emitted when an agent run completes (success or failure)
99
+ */
100
+ export interface AgentRunCompletedEvent extends BaseAgentEvent {
101
+ eventType: AgentEventType.AgentRunCompleted;
102
+ /** Whether the run succeeded */
103
+ success: boolean;
104
+ /** Total duration in milliseconds */
105
+ durationMs: number;
106
+ /** Error type if failed */
107
+ errorType?: string;
108
+ /** Error message if failed */
109
+ errorMessage?: string;
110
+ /** Total iterations in the conversation loop */
111
+ totalIterations: number;
112
+ /** Total tool calls made */
113
+ totalToolCalls: number;
114
+ /** Total LLM calls made */
115
+ totalLlmCalls: number;
116
+ /** Cumulative token usage */
117
+ totalTokens?: {
118
+ input: number;
119
+ output: number;
120
+ total: number;
121
+ };
122
+ /** If conversation was ended via end_conversation tool */
123
+ endConversation?: {
124
+ /** Status provided by the agent */
125
+ status: 'success' | 'failure';
126
+ /** Reason provided by the agent (especially for failures) */
127
+ reason?: string;
128
+ };
129
+ }
130
+
131
+ // ============================================================================
132
+ // LLM Call Events
133
+ // ============================================================================
134
+
135
+ /**
136
+ * Emitted for each LLM call (start/resume conversation)
137
+ * Note: model, environmentId, environmentType are required (override base optional)
138
+ */
139
+ export interface LlmCallEvent extends BaseAgentEvent {
140
+ eventType: AgentEventType.LlmCall;
141
+ /** Number of input/prompt tokens */
142
+ promptTokens: number;
143
+ /** Number of output/completion tokens */
144
+ completionTokens: number;
145
+ /** Total tokens used */
146
+ totalTokens: number;
147
+ /** Duration of the LLM call in milliseconds */
148
+ durationMs: number;
149
+ /** Whether the call succeeded */
150
+ success: boolean;
151
+ /** Whether streaming was enabled */
152
+ streamingEnabled: boolean;
153
+ /** Number of tool uses returned by the LLM */
154
+ toolUseCount: number;
155
+ /** Type of call: 'start' for initial, 'resume_tools' for tool results, 'resume_user' for user message */
156
+ callType: LlmCallType;
157
+ /** Activity attempt number (for retries) */
158
+ attemptNumber?: number;
159
+ /** Error type if failed */
160
+ errorType?: string;
161
+ }
162
+
163
+ // ============================================================================
164
+ // Tool Call Events
165
+ // ============================================================================
166
+
167
+ /**
168
+ * Emitted when a tool call completes (success or failure).
169
+ * Contains all information about the tool execution including parameters and results.
170
+ */
171
+ export interface ToolCallEvent extends BaseAgentEvent {
172
+ eventType: AgentEventType.ToolCall;
173
+ /** Name of the tool being called */
174
+ toolName: string;
175
+ /** Tool use ID from the LLM */
176
+ toolUseId: string;
177
+ /** Whether this is a built-in tool, interaction tool, or remote tool */
178
+ toolType: TelemetryToolType;
179
+ /** Current iteration number */
180
+ iteration: number;
181
+ /** Parameters passed to the tool (sanitized - no secrets) */
182
+ parameters?: Record<string, unknown>;
183
+ /** Size of parameters in bytes */
184
+ parametersSizeBytes?: number;
185
+ /** Whether the tool call succeeded */
186
+ success: boolean;
187
+ /** Duration in milliseconds */
188
+ durationMs: number;
189
+ /** Size of result in bytes */
190
+ resultSizeBytes?: number;
191
+ /** Error type if failed */
192
+ errorType?: string;
193
+ /** Error message if failed (truncated) */
194
+ errorMessage?: string;
195
+ /** Whether this tool spawned a child workflow */
196
+ spawnedChildWorkflow?: boolean;
197
+ }
198
+
199
+ // ============================================================================
200
+ // Checkpoint Events
201
+ // ============================================================================
202
+
203
+ /**
204
+ * Emitted when a checkpoint is created.
205
+ * Extends LlmCallEvent since checkpoint creation involves an LLM call.
206
+ */
207
+ export interface CheckpointCreatedEvent extends LlmCallEvent {
208
+ callType: LlmCallType.Checkpoint;
209
+ /** Token count that triggered the checkpoint (before this LLM call) */
210
+ tokenCountAtCheckpoint: number;
211
+ /** Checkpoint threshold configured */
212
+ checkpointThreshold: number;
213
+ /** Current iteration number */
214
+ iteration: number;
215
+ }
216
+
217
+ // ============================================================================
218
+ // Nested Interaction Execution Events
219
+ // ============================================================================
220
+
221
+ /**
222
+ * Emitted when a nested interaction is called from within a tool.
223
+ * Extends LlmCallEvent since nested interaction execution involves an LLM call.
224
+ */
225
+ export interface NestedInteractionEvent extends LlmCallEvent {
226
+ callType: LlmCallType.NestedInteraction;
227
+ /** The interaction being called (e.g., "sys:AnalyzeDocument") */
228
+ nestedInteractionId: string;
229
+ /** Tool that triggered this call - same pattern as ToolCallEvent */
230
+ toolName: string;
231
+ /** Tool type - same pattern as ToolCallEvent */
232
+ toolType: TelemetryToolType;
233
+ }
234
+
235
+
236
+ // ============================================================================
237
+ // Union type for all events
238
+ // ============================================================================
239
+
240
+ export type AgentEvent =
241
+ | AgentRunStartedEvent
242
+ | AgentRunCompletedEvent
243
+ | LlmCallEvent
244
+ | ToolCallEvent
245
+ | CheckpointCreatedEvent
246
+ | NestedInteractionEvent;
247
+
248
+ /**
249
+ * Workflow Analytics Types
250
+ *
251
+ * Types for querying and presenting workflow telemetry analytics.
252
+ * Designed for end-user facing dashboards with aggregated metrics.
253
+ */
254
+
255
+ // ============================================================================
256
+ // Query Types
257
+ // ============================================================================
258
+
259
+ /**
260
+ * Time resolution for analytics aggregation
261
+ */
262
+ export type WorkflowAnalyticsResolution = 'minute' | 'hour' | 'day' | 'week' | 'month';
263
+
264
+ /**
265
+ * Dimensions to group analytics by
266
+ */
267
+ export type WorkflowAnalyticsGroupBy =
268
+ | 'model' // Group by LLM model (claude-3-5-sonnet, gemini-1.5-pro, etc.)
269
+ | 'environment' // Group by environment/driver (vertexai, bedrock, openai)
270
+ | 'tool' // Group by tool name
271
+ | 'toolType' // Group by tool type (builtin, interaction, remote, skill)
272
+ | 'agent' // Group by agent/interaction name
273
+ | 'errorType'; // Group by error type
274
+
275
+ /**
276
+ * Filter criteria for workflow analytics queries
277
+ */
278
+ export interface WorkflowAnalyticsFilter {
279
+ /** Filter by specific agent/interaction names */
280
+ agents?: string[];
281
+ /** Filter by LLM models */
282
+ models?: string[];
283
+ /** Filter by environments/drivers */
284
+ environments?: string[];
285
+ /** Filter by tool names */
286
+ tools?: string[];
287
+ /** Filter by tool types */
288
+ toolTypes?: ('builtin' | 'interaction' | 'remote' | 'skill')[];
289
+ /** Filter by success/failure status */
290
+ success?: boolean;
291
+ /** Filter by specific workflow run IDs */
292
+ runIds?: string[];
293
+ /** Filter by principal IDs (users or API keys) */
294
+ principals?: string[];
295
+ }
296
+
297
+ /**
298
+ * Base query parameters for all workflow analytics endpoints
299
+ */
300
+ export interface WorkflowAnalyticsQueryBase {
301
+ /** Start time (ISO 8601 or Unix timestamp) */
302
+ from?: string | number;
303
+ /** End time (ISO 8601 or Unix timestamp) */
304
+ to?: string | number;
305
+ /** Filters to apply */
306
+ filter?: WorkflowAnalyticsFilter;
307
+ }
308
+
309
+ /**
310
+ * Query for time-series analytics (metrics over time)
311
+ */
312
+ export interface WorkflowAnalyticsTimeSeriesQuery extends WorkflowAnalyticsQueryBase {
313
+ /** Time bucket resolution */
314
+ resolution?: WorkflowAnalyticsResolution;
315
+ /** Resolution step size (e.g., 2 means 2-hour buckets when resolution is 'hour'). Defaults to 1. */
316
+ resolutionStep?: number;
317
+ /** Optional grouping dimension */
318
+ groupBy?: WorkflowAnalyticsGroupBy;
319
+ }
320
+
321
+ /**
322
+ * Query for summary/aggregate analytics
323
+ */
324
+ export interface WorkflowAnalyticsSummaryQuery extends WorkflowAnalyticsQueryBase {
325
+ /** Dimension to group results by */
326
+ groupBy?: WorkflowAnalyticsGroupBy;
327
+ /** Maximum number of groups to return (for top-N queries) */
328
+ limit?: number;
329
+ }
330
+
331
+ /**
332
+ * Query for tool parameter analytics
333
+ */
334
+ export interface WorkflowToolParametersQuery extends WorkflowAnalyticsQueryBase {
335
+ /** Specific tool to analyze parameters for (required) */
336
+ toolName: string;
337
+ /** Maximum number of parameter patterns to return */
338
+ limit?: number;
339
+ }
340
+
341
+ // ============================================================================
342
+ // Result Types - Token Usage
343
+ // ============================================================================
344
+
345
+ /**
346
+ * Token usage metrics
347
+ */
348
+ export interface TokenUsageMetrics {
349
+ /** Total input/prompt tokens */
350
+ inputTokens: number;
351
+ /** Total output/completion tokens */
352
+ outputTokens: number;
353
+ /** Total tokens (input + output) */
354
+ totalTokens: number;
355
+ /** Average tokens per LLM call */
356
+ avgTokensPerCall?: number;
357
+ }
358
+
359
+ /**
360
+ * Token usage aggregated by dimension
361
+ */
362
+ export interface TokenUsageByDimension {
363
+ /** The dimension value (model name, tool name, etc.) */
364
+ dimension: string;
365
+ /** Token usage metrics */
366
+ usage: TokenUsageMetrics;
367
+ /** Number of LLM calls */
368
+ callCount: number;
369
+ /** Percentage of total tokens */
370
+ percentageOfTotal?: number;
371
+ }
372
+
373
+ /**
374
+ * Token usage time series data point
375
+ */
376
+ export interface TokenUsageTimeSeriesPoint {
377
+ /** Timestamp bucket start (ISO 8601) */
378
+ timestamp: string;
379
+ /** Timestamp bucket end (ISO 8601) */
380
+ timestampEnd: string;
381
+ /** Token usage metrics for this bucket */
382
+ usage: TokenUsageMetrics;
383
+ /** Number of LLM calls in this bucket */
384
+ callCount: number;
385
+ /** Optional group value if groupBy was specified */
386
+ group?: string;
387
+ }
388
+
389
+ // ============================================================================
390
+ // Result Types - Latency/Duration
391
+ // ============================================================================
392
+
393
+ /**
394
+ * Duration/latency statistics
395
+ */
396
+ export interface DurationStats {
397
+ /** Average duration in milliseconds */
398
+ avgMs: number;
399
+ /** Minimum duration in milliseconds */
400
+ minMs: number;
401
+ /** Maximum duration in milliseconds */
402
+ maxMs: number;
403
+ /** Median duration in milliseconds (p50) */
404
+ medianMs?: number;
405
+ /** 95th percentile duration in milliseconds */
406
+ p95Ms?: number;
407
+ /** 99th percentile duration in milliseconds */
408
+ p99Ms?: number;
409
+ }
410
+
411
+ /**
412
+ * Latency metrics for a specific dimension
413
+ */
414
+ export interface LatencyByDimension {
415
+ /** The dimension value (model name, tool name, agent name, etc.) */
416
+ dimension: string;
417
+ /** Duration statistics */
418
+ duration: DurationStats;
419
+ /** Number of executions */
420
+ count: number;
421
+ /** Success rate (0-1) */
422
+ successRate: number;
423
+ }
424
+
425
+ /**
426
+ * Latency time series data point
427
+ */
428
+ export interface LatencyTimeSeriesPoint {
429
+ /** Timestamp bucket start (ISO 8601) */
430
+ timestamp: string;
431
+ /** Timestamp bucket end (ISO 8601) */
432
+ timestampEnd: string;
433
+ /** Duration statistics for this bucket */
434
+ duration: DurationStats;
435
+ /** Number of executions in this bucket */
436
+ count: number;
437
+ /** Success rate in this bucket (0-1) */
438
+ successRate: number;
439
+ /** Optional group value if groupBy was specified */
440
+ group?: string;
441
+ }
442
+
443
+ // ============================================================================
444
+ // Result Types - Error Analytics
445
+ // ============================================================================
446
+
447
+ /**
448
+ * Error rate metrics
449
+ */
450
+ export interface ErrorMetrics {
451
+ /** Total number of executions */
452
+ totalCount: number;
453
+ /** Number of successful executions */
454
+ successCount: number;
455
+ /** Number of failed executions */
456
+ errorCount: number;
457
+ /** Error rate (0-1) */
458
+ errorRate: number;
459
+ /** Number of LLM call errors */
460
+ llmErrorCount?: number;
461
+ /** Number of tool call errors */
462
+ toolErrorCount?: number;
463
+ }
464
+
465
+ /**
466
+ * Error breakdown by type
467
+ */
468
+ export interface ErrorByType {
469
+ /** Error type (e.g., "timeout", "rate_limit", "invalid_response") */
470
+ errorType: string;
471
+ /** Number of occurrences */
472
+ count: number;
473
+ /** Percentage of total errors */
474
+ percentageOfErrors: number;
475
+ /** Example error message (truncated) */
476
+ exampleMessage?: string;
477
+ }
478
+
479
+ /**
480
+ * Error analytics by dimension
481
+ */
482
+ export interface ErrorByDimension {
483
+ /** The dimension value (model name, tool name, etc.) */
484
+ dimension: string;
485
+ /** Error metrics */
486
+ metrics: ErrorMetrics;
487
+ /** Breakdown by error type */
488
+ errorTypes?: ErrorByType[];
489
+ }
490
+
491
+ /**
492
+ * Error time series data point
493
+ */
494
+ export interface ErrorTimeSeriesPoint {
495
+ /** Timestamp bucket start (ISO 8601) */
496
+ timestamp: string;
497
+ /** Timestamp bucket end (ISO 8601) */
498
+ timestampEnd: string;
499
+ /** Error metrics for this bucket */
500
+ metrics: ErrorMetrics;
501
+ /** Optional group value if groupBy was specified */
502
+ group?: string;
503
+ }
504
+
505
+ // ============================================================================
506
+ // Result Types - Tool Analytics
507
+ // ============================================================================
508
+
509
+ /**
510
+ * Tool usage metrics
511
+ */
512
+ export interface ToolUsageMetrics {
513
+ /** Tool name */
514
+ toolName: string;
515
+ /** Tool type */
516
+ toolType: 'builtin' | 'interaction' | 'remote' | 'skill';
517
+ /** Number of invocations */
518
+ invocationCount: number;
519
+ /** Success rate (0-1) */
520
+ successRate: number;
521
+ /** Duration statistics */
522
+ duration: DurationStats;
523
+ /** Average input size in bytes */
524
+ avgInputSizeBytes?: number;
525
+ /** Average output size in bytes */
526
+ avgOutputSizeBytes?: number;
527
+ }
528
+
529
+ /**
530
+ * Parameter value distribution for a tool
531
+ */
532
+ export interface ToolParameterValue {
533
+ /** Parameter name */
534
+ parameterName: string;
535
+ /** Parameter value (stringified) */
536
+ value: string;
537
+ /** Number of times this value was used */
538
+ count: number;
539
+ /** Percentage of total invocations */
540
+ percentage: number;
541
+ }
542
+
543
+ /**
544
+ * Tool parameter analytics
545
+ */
546
+ export interface ToolParameterAnalytics {
547
+ /** Tool name */
548
+ toolName: string;
549
+ /** Total invocations analyzed */
550
+ totalInvocations: number;
551
+ /** Parameter value distributions */
552
+ parameters: {
553
+ [parameterName: string]: {
554
+ /** Top values for this parameter */
555
+ topValues: ToolParameterValue[];
556
+ /** Number of unique values */
557
+ uniqueValueCount: number;
558
+ };
559
+ };
560
+ }
561
+
562
+ // ============================================================================
563
+ // Result Types - Summary/Overview
564
+ // ============================================================================
565
+
566
+ /**
567
+ * Overall workflow analytics summary
568
+ */
569
+ export interface WorkflowAnalyticsSummary {
570
+ /** Time range of the data */
571
+ timeRange: {
572
+ from: string;
573
+ to: string;
574
+ };
575
+ /** Total workflow runs */
576
+ totalRuns: number;
577
+ /** Successful runs */
578
+ successfulRuns: number;
579
+ /** Failed runs */
580
+ failedRuns: number;
581
+ /** Ongoing runs (started but not yet completed) */
582
+ ongoingRuns: number;
583
+ /** Overall success rate (0-1) */
584
+ successRate: number;
585
+ /** Total token usage */
586
+ tokenUsage: TokenUsageMetrics;
587
+ /** Token usage from nested interaction calls (e.g., sys:AnalyzeDocument) */
588
+ nestedInteractionTokens: TokenUsageMetrics;
589
+ /** Average run duration (non-interactive runs only) */
590
+ avgRunDurationMs: number;
591
+ /** 95th percentile run duration (non-interactive runs only) */
592
+ p95RunDurationMs: number;
593
+ /** Number of non-interactive runs used for duration calculation */
594
+ nonInteractiveRunCount: number;
595
+ /** Total LLM calls */
596
+ totalLlmCalls: number;
597
+ /** Total tool calls */
598
+ totalToolCalls: number;
599
+ /** Unique models used */
600
+ uniqueModels: string[];
601
+ /** Unique tools used */
602
+ uniqueTools: string[];
603
+ }
604
+
605
+ // ============================================================================
606
+ // API Response Types
607
+ // ============================================================================
608
+
609
+ /**
610
+ * Response for token usage analytics
611
+ */
612
+ export interface TokenUsageAnalyticsResponse {
613
+ /** Summary metrics */
614
+ summary: TokenUsageMetrics;
615
+ /** Breakdown by requested dimension */
616
+ byDimension?: TokenUsageByDimension[];
617
+ /** Time series data if resolution was specified */
618
+ timeSeries?: TokenUsageTimeSeriesPoint[];
619
+ }
620
+
621
+ /**
622
+ * Response for latency analytics
623
+ */
624
+ export interface LatencyAnalyticsResponse {
625
+ /** Summary metrics */
626
+ summary: DurationStats & { count: number; successRate: number };
627
+ /** Breakdown by requested dimension */
628
+ byDimension?: LatencyByDimension[];
629
+ /** Time series data if resolution was specified */
630
+ timeSeries?: LatencyTimeSeriesPoint[];
631
+ }
632
+
633
+ /**
634
+ * Response for error analytics
635
+ */
636
+ export interface ErrorAnalyticsResponse {
637
+ /** Summary metrics */
638
+ summary: ErrorMetrics;
639
+ /** Breakdown by error type */
640
+ byErrorType?: ErrorByType[];
641
+ /** Breakdown by requested dimension */
642
+ byDimension?: ErrorByDimension[];
643
+ /** Time series data if resolution was specified */
644
+ timeSeries?: ErrorTimeSeriesPoint[];
645
+ }
646
+
647
+ /**
648
+ * Response for tool analytics
649
+ */
650
+ export interface ToolAnalyticsResponse {
651
+ /** Tool usage metrics */
652
+ tools: ToolUsageMetrics[];
653
+ /** Total tool invocations */
654
+ totalInvocations: number;
655
+ }
656
+
657
+ /**
658
+ * Response for tool parameter analytics
659
+ */
660
+ export interface ToolParameterAnalyticsResponse {
661
+ /** Tool parameter analytics */
662
+ analytics: ToolParameterAnalytics;
663
+ }
664
+
665
+ /**
666
+ * Response for overall summary analytics
667
+ */
668
+ export interface WorkflowAnalyticsSummaryResponse {
669
+ /** Summary data */
670
+ summary: WorkflowAnalyticsSummary;
671
+ }
672
+
673
+ /**
674
+ * Agent/interaction reference with id and display name
675
+ */
676
+ export interface AgentFilterOption {
677
+ /** The agent/interaction ID (used for filtering) */
678
+ id: string;
679
+ /** The display name (resolved from interaction) */
680
+ name: string;
681
+ }
682
+
683
+ /**
684
+ * Environment reference with id and display name
685
+ */
686
+ export interface EnvironmentFilterOption {
687
+ /** The environment ID (used for filtering) */
688
+ id: string;
689
+ /** The display name (resolved from environment) */
690
+ name: string;
691
+ }
692
+
693
+ /**
694
+ * Environment-model pair from telemetry data
695
+ */
696
+ export interface EnvironmentModelPair {
697
+ /** Environment ID */
698
+ environmentId: string;
699
+ /** Environment display name */
700
+ environmentName: string;
701
+ /** Model ID (used for filtering) */
702
+ modelId: string;
703
+ /** Model display name (human-readable) */
704
+ modelName: string;
705
+ }
706
+
707
+ /**
708
+ * Principal (user/API key) filter option
709
+ */
710
+ export interface PrincipalFilterOption {
711
+ /** The principal ID (user ID or API key ID) */
712
+ id: string;
713
+ /** The principal type (user, apikey, service_account, agent) */
714
+ type: string;
715
+ /** The display name (user email/name, API key name, etc.) */
716
+ name: string;
717
+ }
718
+
719
+ /**
720
+ * Response for available filter options (unique values from telemetry data)
721
+ */
722
+ export interface WorkflowAnalyticsFilterOptionsResponse {
723
+ /** Unique agent/interaction options with id and name */
724
+ agents: AgentFilterOption[];
725
+ /** Environment-model pairs (since models are environment-specific) */
726
+ environmentModels: EnvironmentModelPair[];
727
+ /** Unique principals (users and API keys) that have triggered agent runs */
728
+ principals: PrincipalFilterOption[];
729
+ }
730
+
731
+ // ============================================================================
732
+ // Prompt Size Analytics
733
+ // ============================================================================
734
+
735
+ /**
736
+ * Summary of prompt size metrics across all agents
737
+ */
738
+ export interface PromptSizeSummary {
739
+ /** Average prompt/input tokens for start calls across all agents */
740
+ avgPromptTokens: number;
741
+ /** 95th percentile of prompt/input tokens */
742
+ p95PromptTokens: number;
743
+ /** Total number of start calls */
744
+ totalStartCalls: number;
745
+ }
746
+
747
+ /**
748
+ * Prompt size metrics for a single agent
749
+ */
750
+ export interface PromptSizeByAgent {
751
+ /** Agent ID (to be resolved to name by the API) */
752
+ agentId: string;
753
+ /** Agent display name (resolved from interaction) */
754
+ agentName: string;
755
+ /** Average prompt/input tokens for start calls */
756
+ avgPromptTokens: number;
757
+ /** Number of start calls */
758
+ startCallCount: number;
759
+ }
760
+
761
+ /**
762
+ * Response for prompt size analytics by agent
763
+ */
764
+ export interface PromptSizeAnalyticsResponse {
765
+ /** Summary metrics across all agents */
766
+ summary: PromptSizeSummary;
767
+ /** Prompt size metrics by agent */
768
+ byAgent: PromptSizeByAgent[];
769
+ }
770
+
771
+ // ============================================================================
772
+ // Top Principals Analytics
773
+ // ============================================================================
774
+
775
+ /**
776
+ * Top principal (user/API key/service account) metrics
777
+ */
778
+ export interface TopPrincipal {
779
+ /** Principal ID (user ID, API key ID, etc.) */
780
+ principalId: string;
781
+ /** Principal type (user, apikey, service_account, agent) */
782
+ principalType: string;
783
+ /** Display name (user email/name, API key name, etc.) */
784
+ displayName: string;
785
+ /** Number of agent runs started by this principal */
786
+ runCount: number;
787
+ }
788
+
789
+ /**
790
+ * Response for top principals analytics (most active users/principals)
791
+ */
792
+ export interface TopPrincipalsAnalyticsResponse {
793
+ /** List of top principals sorted by run count descending */
794
+ principals: TopPrincipal[];
795
+ /** Total number of runs in the period */
796
+ totalRuns: number;
797
+ }
798
+
799
+ // ============================================================================
800
+ // Runs by Agent Analytics
801
+ // ============================================================================
802
+
803
+ /**
804
+ * Agent run distribution metrics
805
+ */
806
+ export interface AgentRunDistribution {
807
+ /** Agent/interaction ID */
808
+ agentId: string;
809
+ /** Agent display name (resolved from interaction) */
810
+ agentName: string;
811
+ /** Number of runs for this agent */
812
+ runCount: number;
813
+ /** Percentage of total runs */
814
+ percentage: number;
815
+ }
816
+
817
+ /**
818
+ * Response for runs by agent analytics
819
+ */
820
+ export interface RunsByAgentAnalyticsResponse {
821
+ /** List of agents sorted by run count descending */
822
+ agents: AgentRunDistribution[];
823
+ /** Total number of runs in the period */
824
+ totalRuns: number;
825
+ }
826
+
827
+ // ============================================================================
828
+ // Time to First Response Analytics
829
+ // ============================================================================
830
+
831
+ /**
832
+ * Time to first response metrics
833
+ * Measures the time from agent run start to the completion of the first LLM call
834
+ */
835
+ export interface TimeToFirstResponseMetrics {
836
+ /** Average time to first response in milliseconds */
837
+ avgMs: number;
838
+ /** Minimum time to first response in milliseconds */
839
+ minMs: number;
840
+ /** Maximum time to first response in milliseconds */
841
+ maxMs: number;
842
+ /** Median time to first response in milliseconds (p50) */
843
+ medianMs: number;
844
+ /** 95th percentile time to first response in milliseconds */
845
+ p95Ms: number;
846
+ /** 99th percentile time to first response in milliseconds */
847
+ p99Ms: number;
848
+ /** Number of agent runs analyzed */
849
+ runCount: number;
850
+ }
851
+
852
+ /**
853
+ * Time to first response time series data point
854
+ */
855
+ export interface TimeToFirstResponseTimeSeriesPoint {
856
+ /** Timestamp bucket start (ISO 8601) */
857
+ timestamp: string;
858
+ /** Timestamp bucket end (ISO 8601) */
859
+ timestampEnd: string;
860
+ /** Average time to first response in this bucket (ms) */
861
+ avgMs: number;
862
+ /** Number of runs in this bucket */
863
+ count: number;
864
+ }
865
+
866
+ /**
867
+ * Response for time to first response analytics
868
+ */
869
+ export interface TimeToFirstResponseAnalyticsResponse {
870
+ /** Summary metrics */
871
+ summary: TimeToFirstResponseMetrics;
872
+ /** Time series data if resolution was specified */
873
+ timeSeries?: TimeToFirstResponseTimeSeriesPoint[];
874
+ }
875
+
876
+ // ============================================================================
877
+ // First Response Behavior Analytics
878
+ // ============================================================================
879
+
880
+ /**
881
+ * First response behavior metrics
882
+ * Analyzes the agent's first LLM response (callType = 'start') behavior
883
+ */
884
+ export interface FirstResponseBehaviorMetrics {
885
+ /** Total number of agent runs analyzed */
886
+ totalRuns: number;
887
+ /** Number of runs where the first response used a plan tool */
888
+ runsWithPlanTool: number;
889
+ /** Percentage of runs that start with a plan tool (0-100) */
890
+ planToolPercentage: number;
891
+ /** Number of runs where the first response had no tool calls */
892
+ runsWithNoTools: number;
893
+ /** Percentage of runs that start with no tool calls (0-100) */
894
+ noToolsPercentage: number;
895
+ /** Number of runs where the first response had tool calls (excluding plan only) */
896
+ runsWithOtherTools: number;
897
+ /** Percentage of runs that start with other tool calls (0-100) */
898
+ otherToolsPercentage: number;
899
+ }
900
+
901
+ /**
902
+ * First response behavior time series data point
903
+ */
904
+ export interface FirstResponseBehaviorTimeSeriesPoint {
905
+ /** Timestamp bucket start (ISO 8601) */
906
+ timestamp: string;
907
+ /** Timestamp bucket end (ISO 8601) */
908
+ timestampEnd: string;
909
+ /** Total runs in this bucket */
910
+ totalRuns: number;
911
+ /** Runs with plan tool in this bucket */
912
+ runsWithPlanTool: number;
913
+ /** Runs with no tools in this bucket */
914
+ runsWithNoTools: number;
915
+ }
916
+
917
+ /**
918
+ * Response for first response behavior analytics
919
+ */
920
+ export interface FirstResponseBehaviorAnalyticsResponse {
921
+ /** Summary metrics */
922
+ summary: FirstResponseBehaviorMetrics;
923
+ /** Time series data if resolution was specified */
924
+ timeSeries?: FirstResponseBehaviorTimeSeriesPoint[];
925
+ }