@anvia/core 1.1.2 → 1.2.0

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 (598) hide show
  1. package/README.md +226 -0
  2. package/dist/agent/agent-stream.js +7 -0
  3. package/dist/agent/agent-stream.js.map +1 -0
  4. package/dist/agent/agent-tool.js +24 -0
  5. package/dist/agent/agent-tool.js.map +1 -0
  6. package/dist/agent/agent.js +89 -0
  7. package/dist/agent/agent.js.map +1 -0
  8. package/dist/agent/errors.js +17 -0
  9. package/dist/agent/errors.js.map +1 -0
  10. package/dist/agent/ids.js +7 -0
  11. package/dist/agent/ids.js.map +1 -0
  12. package/dist/agent/index.d.ts +127 -9
  13. package/dist/agent/index.js +103 -21
  14. package/dist/agent/interactions/index.js +2 -2
  15. package/dist/agent/interactions.js +22 -0
  16. package/dist/agent/interactions.js.map +1 -0
  17. package/dist/agent/lifecycle.js +9 -0
  18. package/dist/agent/lifecycle.js.map +1 -0
  19. package/dist/agent/output-schema.js +10 -0
  20. package/dist/agent/output-schema.js.map +1 -0
  21. package/dist/agent/resolve-options.js +46 -0
  22. package/dist/agent/resolve-options.js.map +1 -0
  23. package/dist/agent/resolved-agent.js +92 -0
  24. package/dist/agent/resolved-agent.js.map +1 -0
  25. package/dist/agent/run-types.js +1 -0
  26. package/dist/agent/run-types.js.map +1 -0
  27. package/dist/agent/snapshot.js +17 -0
  28. package/dist/agent/snapshot.js.map +1 -0
  29. package/dist/agent/team/agent-team.js +98 -0
  30. package/dist/agent/team/agent-team.js.map +1 -0
  31. package/dist/agent/team/errors.js +9 -0
  32. package/dist/agent/team/errors.js.map +1 -0
  33. package/dist/agent/team/index.js +104 -0
  34. package/dist/agent/team/index.js.map +1 -0
  35. package/dist/agent/team/types.js +1 -0
  36. package/dist/agent/team/types.js.map +1 -0
  37. package/dist/agent/tool-catalog.js +37 -0
  38. package/dist/agent/tool-catalog.js.map +1 -0
  39. package/dist/agent/tool-state.js +11 -0
  40. package/dist/agent/tool-state.js.map +1 -0
  41. package/dist/agent/types.js +1 -0
  42. package/dist/agent/types.js.map +1 -0
  43. package/dist/agent/vector-context.js +10 -0
  44. package/dist/agent/vector-context.js.map +1 -0
  45. package/dist/{agent-DTmzs1Qr.d.ts → agent-C9VhENdj.d.ts} +2 -3
  46. package/dist/{chunk-2QZJTG2E.js → chunk-23GEYG2X.js} +11 -71
  47. package/dist/chunk-23GEYG2X.js.map +1 -0
  48. package/dist/{chunk-I3Q7XSBB.js → chunk-23LRXKQX.js} +6 -4
  49. package/dist/{chunk-I3Q7XSBB.js.map → chunk-23LRXKQX.js.map} +1 -1
  50. package/dist/{chunk-YK4WAAS4.js → chunk-2NLINXRF.js} +1 -1
  51. package/dist/{chunk-SPD4XVR7.js → chunk-2XSMGVBG.js} +1 -1
  52. package/dist/chunk-3J2CSVPR.js +1 -0
  53. package/dist/chunk-3J2CSVPR.js.map +1 -0
  54. package/dist/chunk-3P3YVJ7V.js +1 -0
  55. package/dist/chunk-3P3YVJ7V.js.map +1 -0
  56. package/dist/chunk-3TAQXJBC.js +107 -0
  57. package/dist/chunk-3TAQXJBC.js.map +1 -0
  58. package/dist/chunk-47NTHIVB.js +76 -0
  59. package/dist/chunk-47NTHIVB.js.map +1 -0
  60. package/dist/chunk-4AW2633B.js +9 -0
  61. package/dist/chunk-4AW2633B.js.map +1 -0
  62. package/dist/{chunk-3XQGVDU5.js → chunk-4C7AXYOM.js} +1 -1
  63. package/dist/{chunk-IZNOP6JG.js → chunk-4FIVU53H.js} +1 -1
  64. package/dist/chunk-4ITAV7YA.js +1 -0
  65. package/dist/chunk-4ITAV7YA.js.map +1 -0
  66. package/dist/{chunk-7JLAIN6E.js → chunk-4ONUNWGC.js} +2 -2
  67. package/dist/chunk-4UUIGAIX.js +1 -0
  68. package/dist/chunk-4UUIGAIX.js.map +1 -0
  69. package/dist/chunk-53TPAXYR.js +1 -0
  70. package/dist/chunk-53TPAXYR.js.map +1 -0
  71. package/dist/chunk-5AETKC4L.js +107 -0
  72. package/dist/chunk-5AETKC4L.js.map +1 -0
  73. package/dist/chunk-5I2NVRHC.js +146 -0
  74. package/dist/chunk-5I2NVRHC.js.map +1 -0
  75. package/dist/chunk-5IURMWFN.js +53 -0
  76. package/dist/chunk-5IURMWFN.js.map +1 -0
  77. package/dist/chunk-5M6GTA3T.js +1 -0
  78. package/dist/chunk-5M6GTA3T.js.map +1 -0
  79. package/dist/chunk-5N5W7CX7.js +18 -0
  80. package/dist/chunk-5N5W7CX7.js.map +1 -0
  81. package/dist/chunk-5P2YOQSA.js +355 -0
  82. package/dist/chunk-5P2YOQSA.js.map +1 -0
  83. package/dist/chunk-5S7T2URX.js +1 -0
  84. package/dist/chunk-5S7T2URX.js.map +1 -0
  85. package/dist/chunk-5V533R7F.js +19 -0
  86. package/dist/chunk-5V533R7F.js.map +1 -0
  87. package/dist/chunk-5WLIHNNJ.js +56 -0
  88. package/dist/chunk-5WLIHNNJ.js.map +1 -0
  89. package/dist/chunk-6BTJC3ES.js +37 -0
  90. package/dist/chunk-6BTJC3ES.js.map +1 -0
  91. package/dist/chunk-6N4ENZO4.js +24 -0
  92. package/dist/chunk-6N4ENZO4.js.map +1 -0
  93. package/dist/{chunk-4UQALF5Y.js → chunk-6RQYWZI3.js} +2 -36
  94. package/dist/chunk-6RQYWZI3.js.map +1 -0
  95. package/dist/chunk-6TAWRKFK.js +86 -0
  96. package/dist/chunk-6TAWRKFK.js.map +1 -0
  97. package/dist/chunk-7F53DOML.js +53 -0
  98. package/dist/chunk-7F53DOML.js.map +1 -0
  99. package/dist/chunk-7KAGWJ5M.js +112 -0
  100. package/dist/chunk-7KAGWJ5M.js.map +1 -0
  101. package/dist/chunk-7LBPRXZP.js +1 -0
  102. package/dist/chunk-7LBPRXZP.js.map +1 -0
  103. package/dist/chunk-A7BXVZXZ.js +25 -0
  104. package/dist/chunk-A7BXVZXZ.js.map +1 -0
  105. package/dist/chunk-B47EXUHL.js +67 -0
  106. package/dist/chunk-B47EXUHL.js.map +1 -0
  107. package/dist/chunk-B5JQDR33.js +14 -0
  108. package/dist/chunk-B5JQDR33.js.map +1 -0
  109. package/dist/chunk-B5YTCKUJ.js +158 -0
  110. package/dist/chunk-B5YTCKUJ.js.map +1 -0
  111. package/dist/chunk-BDDC72GF.js +189 -0
  112. package/dist/chunk-BDDC72GF.js.map +1 -0
  113. package/dist/chunk-BDKFFFVX.js +342 -0
  114. package/dist/chunk-BDKFFFVX.js.map +1 -0
  115. package/dist/{chunk-QGX73TSQ.js → chunk-BONQTXRQ.js} +3 -12
  116. package/dist/chunk-BONQTXRQ.js.map +1 -0
  117. package/dist/chunk-BUPC72Y2.js +1007 -0
  118. package/dist/chunk-BUPC72Y2.js.map +1 -0
  119. package/dist/chunk-CKKNO4XB.js +70 -0
  120. package/dist/chunk-CKKNO4XB.js.map +1 -0
  121. package/dist/chunk-CX7ZVTO5.js +22 -0
  122. package/dist/chunk-CX7ZVTO5.js.map +1 -0
  123. package/dist/chunk-DU4WA6LQ.js +1 -0
  124. package/dist/chunk-DU4WA6LQ.js.map +1 -0
  125. package/dist/chunk-EJR6VVB3.js +63 -0
  126. package/dist/chunk-EJR6VVB3.js.map +1 -0
  127. package/dist/chunk-EKZRAWBP.js +110 -0
  128. package/dist/chunk-EKZRAWBP.js.map +1 -0
  129. package/dist/chunk-ENZ2XX27.js +26 -0
  130. package/dist/chunk-ENZ2XX27.js.map +1 -0
  131. package/dist/chunk-EOAJBBII.js +1 -0
  132. package/dist/chunk-EOAJBBII.js.map +1 -0
  133. package/dist/chunk-ERN7P6Q4.js +1 -0
  134. package/dist/chunk-ERN7P6Q4.js.map +1 -0
  135. package/dist/chunk-ESOFEAYK.js +57 -0
  136. package/dist/chunk-ESOFEAYK.js.map +1 -0
  137. package/dist/chunk-ETYB5JO6.js +175 -0
  138. package/dist/chunk-ETYB5JO6.js.map +1 -0
  139. package/dist/chunk-EZR5AV3J.js +74 -0
  140. package/dist/chunk-EZR5AV3J.js.map +1 -0
  141. package/dist/chunk-F2OKLHGB.js +9 -0
  142. package/dist/chunk-F2OKLHGB.js.map +1 -0
  143. package/dist/chunk-F3E2RLC7.js +342 -0
  144. package/dist/chunk-F3E2RLC7.js.map +1 -0
  145. package/dist/chunk-FAPIZJS2.js +54 -0
  146. package/dist/chunk-FAPIZJS2.js.map +1 -0
  147. package/dist/chunk-GDJNOZ47.js +1 -0
  148. package/dist/chunk-GDJNOZ47.js.map +1 -0
  149. package/dist/chunk-GDY2Z2SZ.js +83 -0
  150. package/dist/chunk-GDY2Z2SZ.js.map +1 -0
  151. package/dist/chunk-GLMYZ6OA.js +20 -0
  152. package/dist/chunk-GLMYZ6OA.js.map +1 -0
  153. package/dist/{chunk-XEVOC433.js → chunk-GPVXCY5I.js} +2 -73
  154. package/dist/chunk-GPVXCY5I.js.map +1 -0
  155. package/dist/{chunk-KSKST3KP.js → chunk-H3H74RWJ.js} +1 -1
  156. package/dist/chunk-HAAGSIZH.js +89 -0
  157. package/dist/chunk-HAAGSIZH.js.map +1 -0
  158. package/dist/{chunk-K5L7R7XM.js → chunk-HHMLE3TZ.js} +6 -54
  159. package/dist/chunk-HHMLE3TZ.js.map +1 -0
  160. package/dist/{chunk-JLJMVRRE.js → chunk-HP34GRQX.js} +10 -83
  161. package/dist/chunk-HP34GRQX.js.map +1 -0
  162. package/dist/chunk-HTI343NP.js +1 -0
  163. package/dist/chunk-HTI343NP.js.map +1 -0
  164. package/dist/{chunk-T2C3CGDQ.js → chunk-HTI7DZJM.js} +6 -4
  165. package/dist/{chunk-T2C3CGDQ.js.map → chunk-HTI7DZJM.js.map} +1 -1
  166. package/dist/chunk-IDNL6IH4.js +294 -0
  167. package/dist/chunk-IDNL6IH4.js.map +1 -0
  168. package/dist/chunk-IV6YQTY2.js +47 -0
  169. package/dist/chunk-IV6YQTY2.js.map +1 -0
  170. package/dist/chunk-J4SINPUA.js +939 -0
  171. package/dist/chunk-J4SINPUA.js.map +1 -0
  172. package/dist/chunk-J6S6MT7O.js +32 -0
  173. package/dist/chunk-J6S6MT7O.js.map +1 -0
  174. package/dist/chunk-JB3RFK6K.js +168 -0
  175. package/dist/chunk-JB3RFK6K.js.map +1 -0
  176. package/dist/chunk-JBQNCUXA.js +34 -0
  177. package/dist/chunk-JBQNCUXA.js.map +1 -0
  178. package/dist/chunk-JMJFK3A4.js +1 -0
  179. package/dist/chunk-JMJFK3A4.js.map +1 -0
  180. package/dist/chunk-JMMZICU7.js +74 -0
  181. package/dist/chunk-JMMZICU7.js.map +1 -0
  182. package/dist/chunk-JOQ2T3QP.js +663 -0
  183. package/dist/chunk-JOQ2T3QP.js.map +1 -0
  184. package/dist/chunk-K4IBS7VB.js +55 -0
  185. package/dist/chunk-K4IBS7VB.js.map +1 -0
  186. package/dist/chunk-KBBQSP4M.js +16 -0
  187. package/dist/chunk-KBBQSP4M.js.map +1 -0
  188. package/dist/chunk-KFAVEL5F.js +68 -0
  189. package/dist/chunk-KFAVEL5F.js.map +1 -0
  190. package/dist/chunk-KITX3HDN.js +17 -0
  191. package/dist/chunk-KITX3HDN.js.map +1 -0
  192. package/dist/chunk-KO5NMTAM.js +1 -0
  193. package/dist/chunk-KO5NMTAM.js.map +1 -0
  194. package/dist/chunk-KY4VXIN2.js +118 -0
  195. package/dist/chunk-KY4VXIN2.js.map +1 -0
  196. package/dist/chunk-KZGSXJKU.js +29 -0
  197. package/dist/chunk-KZGSXJKU.js.map +1 -0
  198. package/dist/chunk-LAIATEUB.js +24 -0
  199. package/dist/chunk-LAIATEUB.js.map +1 -0
  200. package/dist/{chunk-OJBFDBLG.js → chunk-LBYJPMHC.js} +2 -2
  201. package/dist/chunk-LKIABZNR.js +49 -0
  202. package/dist/chunk-LKIABZNR.js.map +1 -0
  203. package/dist/chunk-LQJ4KHMY.js +23 -0
  204. package/dist/chunk-LQJ4KHMY.js.map +1 -0
  205. package/dist/chunk-MEN4AFDZ.js +1 -0
  206. package/dist/chunk-MEN4AFDZ.js.map +1 -0
  207. package/dist/chunk-MHOJJYDK.js +93 -0
  208. package/dist/chunk-MHOJJYDK.js.map +1 -0
  209. package/dist/chunk-MJCMKZFP.js +30 -0
  210. package/dist/chunk-MJCMKZFP.js.map +1 -0
  211. package/dist/chunk-MT3BLVYN.js +31 -0
  212. package/dist/chunk-MT3BLVYN.js.map +1 -0
  213. package/dist/chunk-NF6WBPFG.js +37 -0
  214. package/dist/chunk-NF6WBPFG.js.map +1 -0
  215. package/dist/chunk-NNEKBZSM.js +66 -0
  216. package/dist/chunk-NNEKBZSM.js.map +1 -0
  217. package/dist/chunk-NPJ2T3L5.js +19 -0
  218. package/dist/chunk-NPJ2T3L5.js.map +1 -0
  219. package/dist/chunk-NVALGVQG.js +150 -0
  220. package/dist/chunk-NVALGVQG.js.map +1 -0
  221. package/dist/chunk-OJF67RNM.js +1 -0
  222. package/dist/chunk-OJF67RNM.js.map +1 -0
  223. package/dist/chunk-PHLGGRHC.js +89 -0
  224. package/dist/chunk-PHLGGRHC.js.map +1 -0
  225. package/dist/chunk-PIMD4DYG.js +104 -0
  226. package/dist/chunk-PIMD4DYG.js.map +1 -0
  227. package/dist/chunk-PJNE75WC.js +1 -0
  228. package/dist/chunk-PJNE75WC.js.map +1 -0
  229. package/dist/{chunk-J6LVLV6P.js → chunk-PLDJCCVL.js} +1 -1
  230. package/dist/{chunk-3RWESPUG.js → chunk-POXHJF3H.js} +6 -51
  231. package/dist/chunk-POXHJF3H.js.map +1 -0
  232. package/dist/chunk-PPJ7SYQL.js +81 -0
  233. package/dist/chunk-PPJ7SYQL.js.map +1 -0
  234. package/dist/chunk-PT777EQ3.js +48 -0
  235. package/dist/chunk-PT777EQ3.js.map +1 -0
  236. package/dist/chunk-PYLPLFJZ.js +318 -0
  237. package/dist/chunk-PYLPLFJZ.js.map +1 -0
  238. package/dist/chunk-QEPBHHAP.js +41 -0
  239. package/dist/chunk-QEPBHHAP.js.map +1 -0
  240. package/dist/chunk-QHGYCYV6.js +91 -0
  241. package/dist/chunk-QHGYCYV6.js.map +1 -0
  242. package/dist/chunk-R6722CIU.js +28 -0
  243. package/dist/chunk-R6722CIU.js.map +1 -0
  244. package/dist/chunk-RA4YVN43.js +1 -0
  245. package/dist/chunk-RA4YVN43.js.map +1 -0
  246. package/dist/chunk-RT5LUEO3.js +2339 -0
  247. package/dist/chunk-RT5LUEO3.js.map +1 -0
  248. package/dist/chunk-RXKUIJ77.js +236 -0
  249. package/dist/chunk-RXKUIJ77.js.map +1 -0
  250. package/dist/chunk-SC4SUIEY.js +1 -0
  251. package/dist/chunk-SC4SUIEY.js.map +1 -0
  252. package/dist/chunk-SQAAVYJG.js +12 -0
  253. package/dist/chunk-SQAAVYJG.js.map +1 -0
  254. package/dist/chunk-SXE4J43E.js +59 -0
  255. package/dist/chunk-SXE4J43E.js.map +1 -0
  256. package/dist/{chunk-EFLT7XZD.js → chunk-SYULMZGL.js} +6 -4
  257. package/dist/{chunk-EFLT7XZD.js.map → chunk-SYULMZGL.js.map} +1 -1
  258. package/dist/chunk-T4KS577P.js +58 -0
  259. package/dist/chunk-T4KS577P.js.map +1 -0
  260. package/dist/chunk-TFIOU6UR.js +78 -0
  261. package/dist/chunk-TFIOU6UR.js.map +1 -0
  262. package/dist/chunk-TIZGADU4.js +375 -0
  263. package/dist/chunk-TIZGADU4.js.map +1 -0
  264. package/dist/chunk-TP3MCUXS.js +1 -0
  265. package/dist/chunk-TP3MCUXS.js.map +1 -0
  266. package/dist/chunk-TSPQD5HW.js +613 -0
  267. package/dist/chunk-TSPQD5HW.js.map +1 -0
  268. package/dist/{chunk-JTJU56ZV.js → chunk-UOGM62JL.js} +11 -7
  269. package/dist/{chunk-JTJU56ZV.js.map → chunk-UOGM62JL.js.map} +1 -1
  270. package/dist/chunk-USRKPEQN.js +55 -0
  271. package/dist/chunk-USRKPEQN.js.map +1 -0
  272. package/dist/chunk-UTAB3XQI.js +667 -0
  273. package/dist/chunk-UTAB3XQI.js.map +1 -0
  274. package/dist/chunk-V3FFZWF3.js +182 -0
  275. package/dist/chunk-V3FFZWF3.js.map +1 -0
  276. package/dist/chunk-V4OZ7ISA.js +9 -0
  277. package/dist/chunk-V4OZ7ISA.js.map +1 -0
  278. package/dist/chunk-VZ5ZZBNX.js +139 -0
  279. package/dist/chunk-VZ5ZZBNX.js.map +1 -0
  280. package/dist/{chunk-AHLKV6KP.js → chunk-WN6AVBO4.js} +1 -1
  281. package/dist/chunk-WXR5CWSC.js +1 -0
  282. package/dist/chunk-WXR5CWSC.js.map +1 -0
  283. package/dist/chunk-X6WS3XWL.js +36 -0
  284. package/dist/chunk-X6WS3XWL.js.map +1 -0
  285. package/dist/{chunk-Q5BCNYED.js → chunk-XJRNBTIV.js} +7 -4
  286. package/dist/chunk-XQV3XNVT.js +225 -0
  287. package/dist/chunk-XQV3XNVT.js.map +1 -0
  288. package/dist/chunk-XV3DH5GC.js +58 -0
  289. package/dist/chunk-XV3DH5GC.js.map +1 -0
  290. package/dist/chunk-YWRXOPHC.js +43 -0
  291. package/dist/chunk-YWRXOPHC.js.map +1 -0
  292. package/dist/chunk-YZVFIW5D.js +27 -0
  293. package/dist/chunk-YZVFIW5D.js.map +1 -0
  294. package/dist/chunk-ZHC5CD6J.js +33 -0
  295. package/dist/chunk-ZHC5CD6J.js.map +1 -0
  296. package/dist/chunk-ZPJFXRQZ.js +23 -0
  297. package/dist/chunk-ZPJFXRQZ.js.map +1 -0
  298. package/dist/chunk-ZPXOBQDS.js +57 -0
  299. package/dist/chunk-ZPXOBQDS.js.map +1 -0
  300. package/dist/chunk-ZUFS6R7L.js +155 -0
  301. package/dist/chunk-ZUFS6R7L.js.map +1 -0
  302. package/dist/chunk-ZXLCTQUX.js +62 -0
  303. package/dist/chunk-ZXLCTQUX.js.map +1 -0
  304. package/dist/chunk-ZYXMWEL4.js +59 -0
  305. package/dist/chunk-ZYXMWEL4.js.map +1 -0
  306. package/dist/completion/controls.js +11 -0
  307. package/dist/completion/controls.js.map +1 -0
  308. package/dist/completion/documents.js +9 -0
  309. package/dist/completion/documents.js.map +1 -0
  310. package/dist/completion/generate-completion.js +23 -0
  311. package/dist/completion/generate-completion.js.map +1 -0
  312. package/dist/completion/index.js +23 -12
  313. package/dist/completion/json.js +7 -0
  314. package/dist/completion/json.js.map +1 -0
  315. package/dist/completion/message-schema.js +18 -0
  316. package/dist/completion/message-schema.js.map +1 -0
  317. package/dist/completion/provider-output-error.js +12 -0
  318. package/dist/completion/provider-output-error.js.map +1 -0
  319. package/dist/completion/stream-accumulator.js +10 -0
  320. package/dist/completion/stream-accumulator.js.map +1 -0
  321. package/dist/completion/types.js +28 -0
  322. package/dist/completion/types.js.map +1 -0
  323. package/dist/documents/chunk-text.js +7 -0
  324. package/dist/documents/chunk-text.js.map +1 -0
  325. package/dist/documents/index.js +5 -2
  326. package/dist/documents/text-document.js +8 -0
  327. package/dist/documents/text-document.js.map +1 -0
  328. package/dist/embeddings/distance.js +17 -0
  329. package/dist/embeddings/distance.js.map +1 -0
  330. package/dist/embeddings/embed.js +18 -0
  331. package/dist/embeddings/embed.js.map +1 -0
  332. package/dist/embeddings/index.js +11 -6
  333. package/dist/embeddings/types.js +2 -0
  334. package/dist/embeddings/types.js.map +1 -0
  335. package/dist/evals/advanced-metrics.js +46 -0
  336. package/dist/evals/advanced-metrics.js.map +1 -0
  337. package/dist/evals/agent-target.js +10 -0
  338. package/dist/evals/agent-target.js.map +1 -0
  339. package/dist/evals/cli.js +40 -0
  340. package/dist/evals/cli.js.map +1 -0
  341. package/dist/evals/execution.js +15 -0
  342. package/dist/evals/execution.js.map +1 -0
  343. package/dist/evals/format.js +13 -0
  344. package/dist/evals/format.js.map +1 -0
  345. package/dist/evals/index.d.ts +4 -4
  346. package/dist/evals/index.js +87 -2660
  347. package/dist/evals/index.js.map +1 -1
  348. package/dist/evals/judge.js +27 -0
  349. package/dist/evals/judge.js.map +1 -0
  350. package/dist/evals/metric.js +7 -0
  351. package/dist/evals/metric.js.map +1 -0
  352. package/dist/evals/metrics.js +53 -0
  353. package/dist/evals/metrics.js.map +1 -0
  354. package/dist/evals/outcome.js +7 -0
  355. package/dist/evals/outcome.js.map +1 -0
  356. package/dist/evals/reporting.js +11 -0
  357. package/dist/evals/reporting.js.map +1 -0
  358. package/dist/evals/runner.js +29 -0
  359. package/dist/evals/runner.js.map +1 -0
  360. package/dist/evals/selectors.js +18 -0
  361. package/dist/evals/selectors.js.map +1 -0
  362. package/dist/evals/suite.js +11 -0
  363. package/dist/evals/suite.js.map +1 -0
  364. package/dist/evals/types.js +1 -0
  365. package/dist/evals/types.js.map +1 -0
  366. package/dist/extractor/extractor.js +23 -0
  367. package/dist/extractor/extractor.js.map +1 -0
  368. package/dist/extractor/index.js +16 -7
  369. package/dist/guardrails/actions.js +13 -0
  370. package/dist/guardrails/actions.js.map +1 -0
  371. package/dist/guardrails/index.d.ts +3 -4
  372. package/dist/guardrails/index.js +15 -7
  373. package/dist/guardrails/message.js +9 -0
  374. package/dist/guardrails/message.js.map +1 -0
  375. package/dist/guardrails/policy.js +17 -0
  376. package/dist/guardrails/policy.js.map +1 -0
  377. package/dist/guardrails/runtime.js +11 -0
  378. package/dist/guardrails/runtime.js.map +1 -0
  379. package/dist/guardrails/text.js +9 -0
  380. package/dist/guardrails/text.js.map +1 -0
  381. package/dist/guardrails/types.js +1 -0
  382. package/dist/guardrails/types.js.map +1 -0
  383. package/dist/hooks/control.js +17 -0
  384. package/dist/hooks/control.js.map +1 -0
  385. package/dist/hooks/index.js +19 -0
  386. package/dist/hooks/index.js.map +1 -0
  387. package/dist/hooks/types.js +2 -0
  388. package/dist/hooks/types.js.map +1 -0
  389. package/dist/image-generation/generate-image.js +11 -0
  390. package/dist/image-generation/generate-image.js.map +1 -0
  391. package/dist/image-generation/index.js +7 -4
  392. package/dist/image-generation/types.js +2 -0
  393. package/dist/image-generation/types.js.map +1 -0
  394. package/dist/index.d.ts +5 -7
  395. package/dist/index.js +163 -57
  396. package/dist/internal/abort.js +13 -0
  397. package/dist/internal/abort.js.map +1 -0
  398. package/dist/internal/agent-runtime/agent-run.js +81 -0
  399. package/dist/internal/agent-runtime/agent-run.js.map +1 -0
  400. package/dist/internal/agent-runtime/approval-request.js +1 -0
  401. package/dist/internal/agent-runtime/approval-request.js.map +1 -0
  402. package/dist/internal/agent-runtime/approval-requirement.js +9 -0
  403. package/dist/internal/agent-runtime/approval-requirement.js.map +1 -0
  404. package/dist/internal/agent-runtime/continuation-state.js +26 -0
  405. package/dist/internal/agent-runtime/continuation-state.js.map +1 -0
  406. package/dist/internal/agent-runtime/interaction-suspension.js +25 -0
  407. package/dist/internal/agent-runtime/interaction-suspension.js.map +1 -0
  408. package/dist/internal/agent-runtime/memory-scope.js +8 -0
  409. package/dist/internal/agent-runtime/memory-scope.js.map +1 -0
  410. package/dist/internal/agent-runtime/memory.js +24 -0
  411. package/dist/internal/agent-runtime/memory.js.map +1 -0
  412. package/dist/internal/agent-runtime/prepared-tool-call.js +19 -0
  413. package/dist/internal/agent-runtime/prepared-tool-call.js.map +1 -0
  414. package/dist/internal/agent-runtime/retrieval.js +35 -0
  415. package/dist/internal/agent-runtime/retrieval.js.map +1 -0
  416. package/dist/internal/agent-runtime/run-options.js +9 -0
  417. package/dist/internal/agent-runtime/run-options.js.map +1 -0
  418. package/dist/internal/agent-runtime/run-validation.js +9 -0
  419. package/dist/internal/agent-runtime/run-validation.js.map +1 -0
  420. package/dist/internal/agent-runtime/stream-events.js +11 -0
  421. package/dist/internal/agent-runtime/stream-events.js.map +1 -0
  422. package/dist/internal/agent-runtime/structured-output.js +13 -0
  423. package/dist/internal/agent-runtime/structured-output.js.map +1 -0
  424. package/dist/internal/agent-runtime/tool-execution.js +55 -0
  425. package/dist/internal/agent-runtime/tool-execution.js.map +1 -0
  426. package/dist/internal/agent.d.ts +5 -5
  427. package/dist/internal/agent.js +93 -57
  428. package/dist/internal/agent.js.map +1 -1
  429. package/dist/internal/async-queue.js +7 -0
  430. package/dist/internal/async-queue.js.map +1 -0
  431. package/dist/internal/completion-request.js +11 -0
  432. package/dist/internal/completion-request.js.map +1 -0
  433. package/dist/internal/concurrency.js +7 -0
  434. package/dist/internal/concurrency.js.map +1 -0
  435. package/dist/internal/json-object.js +8 -0
  436. package/dist/internal/json-object.js.map +1 -0
  437. package/dist/internal/rag-text.js +7 -0
  438. package/dist/internal/rag-text.js.map +1 -0
  439. package/dist/internal/record.js +7 -0
  440. package/dist/internal/record.js.map +1 -0
  441. package/dist/internal/team-runtime/coordination.js +12 -0
  442. package/dist/internal/team-runtime/coordination.js.map +1 -0
  443. package/dist/internal/team-runtime/member.js +26 -0
  444. package/dist/internal/team-runtime/member.js.map +1 -0
  445. package/dist/internal/team-runtime/policy.js +7 -0
  446. package/dist/internal/team-runtime/policy.js.map +1 -0
  447. package/dist/internal/team-runtime/run.js +95 -0
  448. package/dist/internal/team-runtime/run.js.map +1 -0
  449. package/dist/internal/team-runtime/stream.js +9 -0
  450. package/dist/internal/team-runtime/stream.js.map +1 -0
  451. package/dist/internal/team-runtime/tools.js +17 -0
  452. package/dist/internal/team-runtime/tools.js.map +1 -0
  453. package/dist/internal/type-utils.js +1 -0
  454. package/dist/internal/type-utils.js.map +1 -0
  455. package/dist/internal/vector-search-options.js +9 -0
  456. package/dist/internal/vector-search-options.js.map +1 -0
  457. package/dist/mcp/index.js +3 -1
  458. package/dist/mcp/tool.js +7 -0
  459. package/dist/mcp/tool.js.map +1 -0
  460. package/dist/mcp/types.js +2 -0
  461. package/dist/mcp/types.js.map +1 -0
  462. package/dist/memory/assert.js +11 -0
  463. package/dist/memory/assert.js.map +1 -0
  464. package/dist/memory/compaction.js +26 -0
  465. package/dist/memory/compaction.js.map +1 -0
  466. package/dist/memory/errors.js +9 -0
  467. package/dist/memory/errors.js.map +1 -0
  468. package/dist/memory/index.js +23 -10
  469. package/dist/memory/options.js +10 -0
  470. package/dist/memory/options.js.map +1 -0
  471. package/dist/memory/scope-key.js +7 -0
  472. package/dist/memory/scope-key.js.map +1 -0
  473. package/dist/memory/types.js +2 -0
  474. package/dist/memory/types.js.map +1 -0
  475. package/dist/{types-CRda8x7p.d.ts → middleware-CWjnMbiH.d.ts} +64 -5
  476. package/dist/model-call-options.js +1 -0
  477. package/dist/model-call-options.js.map +1 -0
  478. package/dist/model-listing/errors.js +7 -0
  479. package/dist/model-listing/errors.js.map +1 -0
  480. package/dist/model-listing/index.js +4 -13
  481. package/dist/model-listing/index.js.map +1 -1
  482. package/dist/model-listing/types.js +2 -0
  483. package/dist/model-listing/types.js.map +1 -0
  484. package/dist/observability/group.js +30 -0
  485. package/dist/observability/group.js.map +1 -0
  486. package/dist/observability/index.d.ts +4 -6
  487. package/dist/observability/index.js +16 -8
  488. package/dist/observability/snapshot.js +7 -0
  489. package/dist/observability/snapshot.js.map +1 -0
  490. package/dist/observability/types.js +1 -0
  491. package/dist/observability/types.js.map +1 -0
  492. package/dist/pipeline/errors.js +9 -0
  493. package/dist/pipeline/errors.js.map +1 -0
  494. package/dist/pipeline/graph.js +21 -0
  495. package/dist/pipeline/graph.js.map +1 -0
  496. package/dist/pipeline/index.d.ts +4 -6
  497. package/dist/pipeline/index.js +27 -805
  498. package/dist/pipeline/index.js.map +1 -1
  499. package/dist/pipeline/observability.js +15 -0
  500. package/dist/pipeline/observability.js.map +1 -0
  501. package/dist/pipeline/pipeline.js +30 -0
  502. package/dist/pipeline/pipeline.js.map +1 -0
  503. package/dist/pipeline/runtime.js +17 -0
  504. package/dist/pipeline/runtime.js.map +1 -0
  505. package/dist/pipeline/types.js +1 -0
  506. package/dist/pipeline/types.js.map +1 -0
  507. package/dist/retry.js +20 -0
  508. package/dist/retry.js.map +1 -0
  509. package/dist/schema/index.js +1 -0
  510. package/dist/schema/index.js.map +1 -0
  511. package/dist/schema/zod-schema.js +7 -0
  512. package/dist/schema/zod-schema.js.map +1 -0
  513. package/dist/skills/index.js +41 -12
  514. package/dist/skills/instructions.js +7 -0
  515. package/dist/skills/instructions.js.map +1 -0
  516. package/dist/skills/load.js +39 -0
  517. package/dist/skills/load.js.map +1 -0
  518. package/dist/skills/local.js +9 -0
  519. package/dist/skills/local.js.map +1 -0
  520. package/dist/skills/tools.js +37 -0
  521. package/dist/skills/tools.js.map +1 -0
  522. package/dist/skills/types.js +7 -0
  523. package/dist/skills/types.js.map +1 -0
  524. package/dist/speech-generation/generate-speech.js +11 -0
  525. package/dist/speech-generation/generate-speech.js.map +1 -0
  526. package/dist/speech-generation/index.js +7 -4
  527. package/dist/speech-generation/types.js +2 -0
  528. package/dist/speech-generation/types.js.map +1 -0
  529. package/dist/streaming/index.js +3 -37
  530. package/dist/streaming/index.js.map +1 -1
  531. package/dist/streaming/readable-stream.js +7 -0
  532. package/dist/streaming/readable-stream.js.map +1 -0
  533. package/dist/{text-CmjXxakS.d.ts → text-GbW4WYMg.d.ts} +1 -1
  534. package/dist/tool/create-tool.js +14 -0
  535. package/dist/tool/create-tool.js.map +1 -0
  536. package/dist/tool/dynamic-tools.js +35 -0
  537. package/dist/tool/dynamic-tools.js.map +1 -0
  538. package/dist/tool/errors.js +11 -0
  539. package/dist/tool/errors.js.map +1 -0
  540. package/dist/tool/index.d.ts +3 -2
  541. package/dist/tool/index.js +41 -15
  542. package/dist/tool/middleware.js +7 -0
  543. package/dist/tool/middleware.js.map +1 -0
  544. package/dist/tool/question-tool.js +17 -0
  545. package/dist/tool/question-tool.js.map +1 -0
  546. package/dist/tool/skill-tool-marker.js +9 -0
  547. package/dist/tool/skill-tool-marker.js.map +1 -0
  548. package/dist/tool/think-tool.js +15 -0
  549. package/dist/tool/think-tool.js.map +1 -0
  550. package/dist/tool/tool.js +17 -0
  551. package/dist/tool/tool.js.map +1 -0
  552. package/dist/transcription/index.js +7 -4
  553. package/dist/transcription/transcribe.js +11 -0
  554. package/dist/transcription/transcribe.js.map +1 -0
  555. package/dist/transcription/types.js +2 -0
  556. package/dist/transcription/types.js.map +1 -0
  557. package/dist/{types-h0EL6Xn0.d.ts → types-Bqw0AuFl.d.ts} +6 -2
  558. package/dist/vector-store/filter.js +9 -0
  559. package/dist/vector-store/filter.js.map +1 -0
  560. package/dist/vector-store/index.js +31 -11
  561. package/dist/vector-store/ingest.js +19 -0
  562. package/dist/vector-store/ingest.js.map +1 -0
  563. package/dist/vector-store/lsh.js +7 -0
  564. package/dist/vector-store/lsh.js.map +1 -0
  565. package/dist/vector-store/retrieve.js +15 -0
  566. package/dist/vector-store/retrieve.js.map +1 -0
  567. package/dist/vector-store/types.js +1 -0
  568. package/dist/vector-store/types.js.map +1 -0
  569. package/package.json +2 -2
  570. package/dist/chunk-2QZJTG2E.js.map +0 -1
  571. package/dist/chunk-3RWESPUG.js.map +0 -1
  572. package/dist/chunk-4UQALF5Y.js.map +0 -1
  573. package/dist/chunk-AZB6N7P4.js +0 -320
  574. package/dist/chunk-AZB6N7P4.js.map +0 -1
  575. package/dist/chunk-JLJMVRRE.js.map +0 -1
  576. package/dist/chunk-K5L7R7XM.js.map +0 -1
  577. package/dist/chunk-OI3LSMJG.js +0 -1545
  578. package/dist/chunk-OI3LSMJG.js.map +0 -1
  579. package/dist/chunk-QGX73TSQ.js.map +0 -1
  580. package/dist/chunk-XC3LVC4K.js +0 -753
  581. package/dist/chunk-XC3LVC4K.js.map +0 -1
  582. package/dist/chunk-XEVOC433.js.map +0 -1
  583. package/dist/chunk-XSV5C4R5.js +0 -400
  584. package/dist/chunk-XSV5C4R5.js.map +0 -1
  585. package/dist/chunk-XU54PLSD.js +0 -4786
  586. package/dist/chunk-XU54PLSD.js.map +0 -1
  587. package/dist/middleware-mY_lpjDp.d.ts +0 -59
  588. package/dist/type-utils-CtHVDRn_.d.ts +0 -6
  589. /package/dist/{chunk-YK4WAAS4.js.map → chunk-2NLINXRF.js.map} +0 -0
  590. /package/dist/{chunk-SPD4XVR7.js.map → chunk-2XSMGVBG.js.map} +0 -0
  591. /package/dist/{chunk-3XQGVDU5.js.map → chunk-4C7AXYOM.js.map} +0 -0
  592. /package/dist/{chunk-IZNOP6JG.js.map → chunk-4FIVU53H.js.map} +0 -0
  593. /package/dist/{chunk-7JLAIN6E.js.map → chunk-4ONUNWGC.js.map} +0 -0
  594. /package/dist/{chunk-KSKST3KP.js.map → chunk-H3H74RWJ.js.map} +0 -0
  595. /package/dist/{chunk-OJBFDBLG.js.map → chunk-LBYJPMHC.js.map} +0 -0
  596. /package/dist/{chunk-J6LVLV6P.js.map → chunk-PLDJCCVL.js.map} +0 -0
  597. /package/dist/{chunk-AHLKV6KP.js.map → chunk-WN6AVBO4.js.map} +0 -0
  598. /package/dist/{chunk-Q5BCNYED.js.map → chunk-XJRNBTIV.js.map} +0 -0
@@ -0,0 +1,93 @@
1
+ import {
2
+ normalizeToolResultOutput,
3
+ parseToolArgs
4
+ } from "./chunk-47NTHIVB.js";
5
+ import {
6
+ ToolCallError,
7
+ ToolJsonError
8
+ } from "./chunk-J6S6MT7O.js";
9
+
10
+ // src/internal/agent-runtime/prepared-tool-call.ts
11
+ var preparedToolInputSymbol = /* @__PURE__ */ Symbol("preparedToolInput");
12
+ var preparedToolOwnerSymbol = /* @__PURE__ */ Symbol("preparedToolOwner");
13
+ function attachPreparedToolOwner(tool, owner) {
14
+ Object.defineProperty(tool, preparedToolOwnerSymbol, {
15
+ configurable: false,
16
+ enumerable: true,
17
+ value: owner,
18
+ writable: false
19
+ });
20
+ return tool;
21
+ }
22
+ function preparedToolInput(context, owner) {
23
+ if (context === void 0 || !(preparedToolInputSymbol in context)) {
24
+ return void 0;
25
+ }
26
+ const prepared = context[preparedToolInputSymbol];
27
+ return prepared?.owner === owner ? { input: prepared.input } : void 0;
28
+ }
29
+ function withoutPreparedToolInput(context) {
30
+ if (!(preparedToolInputSymbol in context)) {
31
+ return context;
32
+ }
33
+ const { [preparedToolInputSymbol]: _prepared, ...publicContext } = context;
34
+ return publicContext;
35
+ }
36
+ function prepareToolCall(tool, args) {
37
+ let rawInput;
38
+ try {
39
+ rawInput = parseToolArgs(args);
40
+ } catch (error) {
41
+ throw new ToolJsonError(`Invalid JSON arguments for tool ${tool.name}`, error);
42
+ }
43
+ let input;
44
+ try {
45
+ input = tool.parseInput === void 0 ? rawInput : tool.parseInput(rawInput);
46
+ } catch (error) {
47
+ throw asToolCallError(tool.name, error);
48
+ }
49
+ return prepareToolCallFromInput(tool, input);
50
+ }
51
+ function prepareToolCallFromInput(tool, input) {
52
+ return {
53
+ input,
54
+ async call(context) {
55
+ try {
56
+ const owner = tool[preparedToolOwnerSymbol];
57
+ return normalizeToolResultOutput(
58
+ await tool.call(
59
+ input,
60
+ owner === void 0 ? context : withPreparedToolInput(context, owner, input)
61
+ )
62
+ );
63
+ } catch (error) {
64
+ throw asToolCallError(tool.name, error);
65
+ }
66
+ }
67
+ };
68
+ }
69
+ function withPreparedToolInput(context, owner, input) {
70
+ const preparedContext = { ...context };
71
+ Object.defineProperty(preparedContext, preparedToolInputSymbol, {
72
+ configurable: false,
73
+ enumerable: true,
74
+ value: { owner, input },
75
+ writable: false
76
+ });
77
+ return preparedContext;
78
+ }
79
+ function asToolCallError(toolName, error) {
80
+ if (error instanceof ToolCallError) {
81
+ return error;
82
+ }
83
+ return error instanceof Error ? new ToolCallError(error.message, error) : new ToolCallError(`Tool ${toolName} failed`, error);
84
+ }
85
+
86
+ export {
87
+ attachPreparedToolOwner,
88
+ preparedToolInput,
89
+ withoutPreparedToolInput,
90
+ prepareToolCall,
91
+ prepareToolCallFromInput
92
+ };
93
+ //# sourceMappingURL=chunk-MHOJJYDK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internal/agent-runtime/prepared-tool-call.ts"],"sourcesContent":["import { ToolCallError, ToolJsonError } from \"../../tool/errors\";\nimport {\n type AnyTool,\n type NormalizedToolOutput,\n normalizeToolResultOutput,\n parseToolArgs,\n type ToolCallContext,\n} from \"../../tool/tool\";\n\nconst preparedToolInputSymbol = Symbol(\"preparedToolInput\");\nconst preparedToolOwnerSymbol = Symbol(\"preparedToolOwner\");\n\nexport type PreparedToolCall = {\n input: unknown;\n call(context: ToolCallContext): Promise<NormalizedToolOutput>;\n};\n\ntype PreparedToolCallContext = ToolCallContext & {\n [preparedToolInputSymbol]?: { owner: object; input: unknown };\n};\n\ntype ToolWithPreparedOwner = AnyTool & {\n [preparedToolOwnerSymbol]?: object;\n};\n\nexport function attachPreparedToolOwner<T extends AnyTool>(tool: T, owner: object): T {\n Object.defineProperty(tool, preparedToolOwnerSymbol, {\n configurable: false,\n enumerable: true,\n value: owner,\n writable: false,\n });\n return tool;\n}\n\nexport function preparedToolInput(\n context: ToolCallContext | undefined,\n owner: object,\n): { input: unknown } | undefined {\n if (context === undefined || !(preparedToolInputSymbol in context)) {\n return undefined;\n }\n const prepared = (context as PreparedToolCallContext)[preparedToolInputSymbol];\n return prepared?.owner === owner ? { input: prepared.input } : undefined;\n}\n\nexport function withoutPreparedToolInput(context: ToolCallContext): ToolCallContext {\n if (!(preparedToolInputSymbol in context)) {\n return context;\n }\n const { [preparedToolInputSymbol]: _prepared, ...publicContext } =\n context as PreparedToolCallContext;\n return publicContext;\n}\n\nexport function prepareToolCall(tool: AnyTool, args: string): PreparedToolCall {\n let rawInput: ReturnType<typeof parseToolArgs>;\n try {\n rawInput = parseToolArgs(args);\n } catch (error) {\n throw new ToolJsonError(`Invalid JSON arguments for tool ${tool.name}`, error);\n }\n\n let input: unknown;\n try {\n input = tool.parseInput === undefined ? rawInput : tool.parseInput(rawInput);\n } catch (error) {\n throw asToolCallError(tool.name, error);\n }\n\n return prepareToolCallFromInput(tool, input);\n}\n\nexport function prepareToolCallFromInput(tool: AnyTool, input: unknown): PreparedToolCall {\n return {\n input,\n async call(context) {\n try {\n const owner = (tool as ToolWithPreparedOwner)[preparedToolOwnerSymbol];\n return normalizeToolResultOutput(\n await tool.call(\n input,\n owner === undefined ? context : withPreparedToolInput(context, owner, input),\n ),\n );\n } catch (error) {\n throw asToolCallError(tool.name, error);\n }\n },\n };\n}\n\nfunction withPreparedToolInput(\n context: ToolCallContext,\n owner: object,\n input: unknown,\n): ToolCallContext {\n const preparedContext: PreparedToolCallContext = { ...context };\n Object.defineProperty(preparedContext, preparedToolInputSymbol, {\n configurable: false,\n enumerable: true,\n value: { owner, input },\n writable: false,\n });\n return preparedContext;\n}\n\nfunction asToolCallError(toolName: string, error: unknown): ToolCallError {\n if (error instanceof ToolCallError) {\n return error;\n }\n return error instanceof Error\n ? new ToolCallError(error.message, error)\n : new ToolCallError(`Tool ${toolName} failed`, error);\n}\n"],"mappings":";;;;;;;;;;AASA,IAAM,0BAA0B,uBAAO,mBAAmB;AAC1D,IAAM,0BAA0B,uBAAO,mBAAmB;AAenD,SAAS,wBAA2C,MAAS,OAAkB;AACpF,SAAO,eAAe,MAAM,yBAAyB;AAAA,IACnD,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,UAAU;AAAA,EACZ,CAAC;AACD,SAAO;AACT;AAEO,SAAS,kBACd,SACA,OACgC;AAChC,MAAI,YAAY,UAAa,EAAE,2BAA2B,UAAU;AAClE,WAAO;AAAA,EACT;AACA,QAAM,WAAY,QAAoC,uBAAuB;AAC7E,SAAO,UAAU,UAAU,QAAQ,EAAE,OAAO,SAAS,MAAM,IAAI;AACjE;AAEO,SAAS,yBAAyB,SAA2C;AAClF,MAAI,EAAE,2BAA2B,UAAU;AACzC,WAAO;AAAA,EACT;AACA,QAAM,EAAE,CAAC,uBAAuB,GAAG,WAAW,GAAG,cAAc,IAC7D;AACF,SAAO;AACT;AAEO,SAAS,gBAAgB,MAAe,MAAgC;AAC7E,MAAI;AACJ,MAAI;AACF,eAAW,cAAc,IAAI;AAAA,EAC/B,SAAS,OAAO;AACd,UAAM,IAAI,cAAc,mCAAmC,KAAK,IAAI,IAAI,KAAK;AAAA,EAC/E;AAEA,MAAI;AACJ,MAAI;AACF,YAAQ,KAAK,eAAe,SAAY,WAAW,KAAK,WAAW,QAAQ;AAAA,EAC7E,SAAS,OAAO;AACd,UAAM,gBAAgB,KAAK,MAAM,KAAK;AAAA,EACxC;AAEA,SAAO,yBAAyB,MAAM,KAAK;AAC7C;AAEO,SAAS,yBAAyB,MAAe,OAAkC;AACxF,SAAO;AAAA,IACL;AAAA,IACA,MAAM,KAAK,SAAS;AAClB,UAAI;AACF,cAAM,QAAS,KAA+B,uBAAuB;AACrE,eAAO;AAAA,UACL,MAAM,KAAK;AAAA,YACT;AAAA,YACA,UAAU,SAAY,UAAU,sBAAsB,SAAS,OAAO,KAAK;AAAA,UAC7E;AAAA,QACF;AAAA,MACF,SAAS,OAAO;AACd,cAAM,gBAAgB,KAAK,MAAM,KAAK;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,sBACP,SACA,OACA,OACiB;AACjB,QAAM,kBAA2C,EAAE,GAAG,QAAQ;AAC9D,SAAO,eAAe,iBAAiB,yBAAyB;AAAA,IAC9D,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,OAAO,EAAE,OAAO,MAAM;AAAA,IACtB,UAAU;AAAA,EACZ,CAAC;AACD,SAAO;AACT;AAEA,SAAS,gBAAgB,UAAkB,OAA+B;AACxE,MAAI,iBAAiB,eAAe;AAClC,WAAO;AAAA,EACT;AACA,SAAO,iBAAiB,QACpB,IAAI,cAAc,MAAM,SAAS,KAAK,IACtC,IAAI,cAAc,QAAQ,QAAQ,WAAW,KAAK;AACxD;","names":[]}
@@ -0,0 +1,30 @@
1
+ // src/internal/rag-text.ts
2
+ function extractRagText(message) {
3
+ if (message.role === "user") {
4
+ if (typeof message.content === "string") {
5
+ return message.content;
6
+ }
7
+ return message.content.flatMap((item) => item.type === "text" ? [item.text] : []).join("\n");
8
+ }
9
+ if (message.role === "tool") {
10
+ return message.content.flatMap((item) => {
11
+ if (item.type !== "tool-result") {
12
+ return [];
13
+ }
14
+ const output = item.output;
15
+ if (output.type === "text" || output.type === "error-text") {
16
+ return [output.value];
17
+ }
18
+ if (output.type === "content") {
19
+ return output.value.flatMap((part) => part.type === "text" ? [part.text] : []);
20
+ }
21
+ return [];
22
+ }).join("\n");
23
+ }
24
+ return void 0;
25
+ }
26
+
27
+ export {
28
+ extractRagText
29
+ };
30
+ //# sourceMappingURL=chunk-MJCMKZFP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internal/rag-text.ts"],"sourcesContent":["import type { Message as MessageType } from \"../completion/index\";\n\nexport function extractRagText(message: MessageType): string | undefined {\n if (message.role === \"user\") {\n if (typeof message.content === \"string\") {\n return message.content;\n }\n return message.content.flatMap((item) => (item.type === \"text\" ? [item.text] : [])).join(\"\\n\");\n }\n\n if (message.role === \"tool\") {\n return message.content\n .flatMap((item) => {\n if (item.type !== \"tool-result\") {\n return [];\n }\n const output = item.output;\n if (output.type === \"text\" || output.type === \"error-text\") {\n return [output.value];\n }\n if (output.type === \"content\") {\n return output.value.flatMap((part) => (part.type === \"text\" ? [part.text] : []));\n }\n return [];\n })\n .join(\"\\n\");\n }\n\n return undefined;\n}\n"],"mappings":";AAEO,SAAS,eAAe,SAA0C;AACvE,MAAI,QAAQ,SAAS,QAAQ;AAC3B,QAAI,OAAO,QAAQ,YAAY,UAAU;AACvC,aAAO,QAAQ;AAAA,IACjB;AACA,WAAO,QAAQ,QAAQ,QAAQ,CAAC,SAAU,KAAK,SAAS,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC,CAAE,EAAE,KAAK,IAAI;AAAA,EAC/F;AAEA,MAAI,QAAQ,SAAS,QAAQ;AAC3B,WAAO,QAAQ,QACZ,QAAQ,CAAC,SAAS;AACjB,UAAI,KAAK,SAAS,eAAe;AAC/B,eAAO,CAAC;AAAA,MACV;AACA,YAAM,SAAS,KAAK;AACpB,UAAI,OAAO,SAAS,UAAU,OAAO,SAAS,cAAc;AAC1D,eAAO,CAAC,OAAO,KAAK;AAAA,MACtB;AACA,UAAI,OAAO,SAAS,WAAW;AAC7B,eAAO,OAAO,MAAM,QAAQ,CAAC,SAAU,KAAK,SAAS,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC,CAAE;AAAA,MACjF;AACA,aAAO,CAAC;AAAA,IACV,CAAC,EACA,KAAK,IAAI;AAAA,EACd;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,31 @@
1
+ // src/guardrails/actions.ts
2
+ function allow(options = {}) {
3
+ return { action: "allow", ...options };
4
+ }
5
+ function block(options) {
6
+ return { action: "block", ...options };
7
+ }
8
+ var commonActions = {
9
+ allow,
10
+ block
11
+ };
12
+ var inputActions = {
13
+ ...commonActions,
14
+ rewrite(options) {
15
+ return { action: "rewrite", ...options };
16
+ }
17
+ };
18
+ var outputActions = {
19
+ ...commonActions,
20
+ rewrite(options) {
21
+ return { action: "rewrite", ...options };
22
+ }
23
+ };
24
+
25
+ export {
26
+ allow,
27
+ block,
28
+ inputActions,
29
+ outputActions
30
+ };
31
+ //# sourceMappingURL=chunk-MT3BLVYN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/guardrails/actions.ts"],"sourcesContent":["import type {\n GuardrailActionBase,\n GuardrailAllow,\n GuardrailBlock,\n GuardrailCommonActions,\n InputGuardrailActions,\n OutputGuardrailActions,\n} from \"./types\";\n\nexport function allow(options: GuardrailActionBase = {}): GuardrailAllow {\n return { action: \"allow\", ...options };\n}\n\nexport function block(options: Omit<GuardrailBlock, \"action\">): GuardrailBlock {\n return { action: \"block\", ...options };\n}\n\nconst commonActions: GuardrailCommonActions = {\n allow,\n block,\n};\n\nexport const inputActions: InputGuardrailActions = {\n ...commonActions,\n rewrite(options) {\n return { action: \"rewrite\", ...options };\n },\n};\n\nexport const outputActions: OutputGuardrailActions = {\n ...commonActions,\n rewrite(options) {\n return { action: \"rewrite\", ...options };\n },\n};\n"],"mappings":";AASO,SAAS,MAAM,UAA+B,CAAC,GAAmB;AACvE,SAAO,EAAE,QAAQ,SAAS,GAAG,QAAQ;AACvC;AAEO,SAAS,MAAM,SAAyD;AAC7E,SAAO,EAAE,QAAQ,SAAS,GAAG,QAAQ;AACvC;AAEA,IAAM,gBAAwC;AAAA,EAC5C;AAAA,EACA;AACF;AAEO,IAAM,eAAsC;AAAA,EACjD,GAAG;AAAA,EACH,QAAQ,SAAS;AACf,WAAO,EAAE,QAAQ,WAAW,GAAG,QAAQ;AAAA,EACzC;AACF;AAEO,IAAM,gBAAwC;AAAA,EACnD,GAAG;AAAA,EACH,QAAQ,SAAS;AACf,WAAO,EAAE,QAAQ,WAAW,GAAG,QAAQ;AAAA,EACzC;AACF;","names":[]}
@@ -0,0 +1,37 @@
1
+ // src/completion/documents.ts
2
+ function normalizeDocuments(documents) {
3
+ if (documents.length === 0) {
4
+ return void 0;
5
+ }
6
+ return { role: "user", content: documents.map(formatDocument).join("\n") };
7
+ }
8
+ function formatDocument(document) {
9
+ return `<file id: ${document.id}>
10
+ ${formatDocumentBody(document)}
11
+ </file>
12
+ `;
13
+ }
14
+ function formatDocumentBody(document) {
15
+ const metadata = formatMetadata(document.additionalProps);
16
+ return metadata === void 0 ? document.text : `${metadata}
17
+ ${document.text}`;
18
+ }
19
+ function formatMetadata(additionalProps) {
20
+ if (additionalProps === void 0) {
21
+ return void 0;
22
+ }
23
+ const entries = Object.entries(additionalProps).sort(
24
+ ([left], [right]) => left.localeCompare(right)
25
+ );
26
+ if (entries.length === 0) {
27
+ return void 0;
28
+ }
29
+ const metadata = entries.map(([key, value]) => `${key}: ${JSON.stringify(value)}`).join(" ");
30
+ return `<metadata ${metadata} />`;
31
+ }
32
+
33
+ export {
34
+ normalizeDocuments,
35
+ formatDocument
36
+ };
37
+ //# sourceMappingURL=chunk-NF6WBPFG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/completion/documents.ts"],"sourcesContent":["import type { Document, Message } from \"./types\";\n\nexport function normalizeDocuments(documents: Document[]): Message | undefined {\n if (documents.length === 0) {\n return undefined;\n }\n\n return { role: \"user\", content: documents.map(formatDocument).join(\"\\n\") };\n}\n\nexport function formatDocument(document: Document): string {\n return `<file id: ${document.id}>\\n${formatDocumentBody(document)}\\n</file>\\n`;\n}\n\nfunction formatDocumentBody(document: Document): string {\n const metadata = formatMetadata(document.additionalProps);\n return metadata === undefined ? document.text : `${metadata}\\n${document.text}`;\n}\n\nfunction formatMetadata(additionalProps: Record<string, string> | undefined): string | undefined {\n if (additionalProps === undefined) {\n return undefined;\n }\n\n const entries = Object.entries(additionalProps).sort(([left], [right]) =>\n left.localeCompare(right),\n );\n if (entries.length === 0) {\n return undefined;\n }\n\n const metadata = entries.map(([key, value]) => `${key}: ${JSON.stringify(value)}`).join(\" \");\n return `<metadata ${metadata} />`;\n}\n"],"mappings":";AAEO,SAAS,mBAAmB,WAA4C;AAC7E,MAAI,UAAU,WAAW,GAAG;AAC1B,WAAO;AAAA,EACT;AAEA,SAAO,EAAE,MAAM,QAAQ,SAAS,UAAU,IAAI,cAAc,EAAE,KAAK,IAAI,EAAE;AAC3E;AAEO,SAAS,eAAe,UAA4B;AACzD,SAAO,aAAa,SAAS,EAAE;AAAA,EAAM,mBAAmB,QAAQ,CAAC;AAAA;AAAA;AACnE;AAEA,SAAS,mBAAmB,UAA4B;AACtD,QAAM,WAAW,eAAe,SAAS,eAAe;AACxD,SAAO,aAAa,SAAY,SAAS,OAAO,GAAG,QAAQ;AAAA,EAAK,SAAS,IAAI;AAC/E;AAEA,SAAS,eAAe,iBAAyE;AAC/F,MAAI,oBAAoB,QAAW;AACjC,WAAO;AAAA,EACT;AAEA,QAAM,UAAU,OAAO,QAAQ,eAAe,EAAE;AAAA,IAAK,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,MAClE,KAAK,cAAc,KAAK;AAAA,EAC1B;AACA,MAAI,QAAQ,WAAW,GAAG;AACxB,WAAO;AAAA,EACT;AAEA,QAAM,WAAW,QAAQ,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,GAAG,GAAG,KAAK,KAAK,UAAU,KAAK,CAAC,EAAE,EAAE,KAAK,GAAG;AAC3F,SAAO,aAAa,QAAQ;AAC9B;","names":[]}
@@ -0,0 +1,66 @@
1
+ import {
2
+ AgentRunBlockedError
3
+ } from "./chunk-WN6AVBO4.js";
4
+
5
+ // src/evals/agent-target.ts
6
+ var AgentEvalSuspensionError = class extends Error {
7
+ constructor(result, message = "Agent eval target suspended without an interaction responder.") {
8
+ super(message);
9
+ this.result = result;
10
+ this.name = "AgentEvalSuspensionError";
11
+ }
12
+ result;
13
+ };
14
+ function agentEvalTarget(options) {
15
+ return async (input, testCase) => {
16
+ const maxResponses = options.interactions?.maxResponses ?? 10;
17
+ if (!Number.isSafeInteger(maxResponses) || maxResponses < 1) {
18
+ throw new TypeError("Agent eval interactions.maxResponses must be a positive integer.");
19
+ }
20
+ const request = await options.request({ input, testCase });
21
+ const runSettings = agentRunSettings(request);
22
+ let response = await options.agent.generate(request);
23
+ let phase = 0;
24
+ while (response.type === "interaction") {
25
+ if (options.interactions === void 0) {
26
+ throw new AgentEvalSuspensionError(response);
27
+ }
28
+ if (phase >= maxResponses) {
29
+ throw new AgentEvalSuspensionError(
30
+ response,
31
+ `Agent eval target exceeded the interaction response limit of ${maxResponses}.`
32
+ );
33
+ }
34
+ phase += 1;
35
+ const interactionResponse = await options.interactions.respond({
36
+ interaction: response.interaction,
37
+ testCase,
38
+ phase
39
+ });
40
+ response = await options.agent.generate({
41
+ continuation: response.continuation,
42
+ response: interactionResponse,
43
+ ...runSettings
44
+ });
45
+ }
46
+ if (response.type === "blocked") throw new AgentRunBlockedError(response);
47
+ return options.output === void 0 ? response : await options.output({ response, testCase });
48
+ };
49
+ }
50
+ function agentRunSettings(request) {
51
+ const {
52
+ prompt: _prompt,
53
+ messages: _messages,
54
+ session: _session,
55
+ continuation: _continuation,
56
+ response: _response,
57
+ ...settings
58
+ } = request;
59
+ return settings;
60
+ }
61
+
62
+ export {
63
+ AgentEvalSuspensionError,
64
+ agentEvalTarget
65
+ };
66
+ //# sourceMappingURL=chunk-NNEKBZSM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/evals/agent-target.ts"],"sourcesContent":["import { AgentRunBlockedError } from \"../agent/errors\";\nimport type { AgentInteractionRequest, AgentInteractionResponse } from \"../agent/interactions\";\nimport type {\n AgentInteractionOutcome,\n AgentOutcome,\n AgentResponse,\n AgentRunOptions,\n AgentRunSettings,\n} from \"../agent/run-types\";\nimport type { EvalCase, EvalTarget } from \"./types\";\n\ntype EvaluableAgent<Output> = {\n generate(input: AgentRunOptions<Output>): Promise<AgentOutcome<Output>>;\n};\n\ntype IsAny<Value> = 0 extends 1 & Value ? true : false;\ntype IsExactly<Left, Right> =\n IsAny<Left> extends true\n ? false\n : [Left] extends [Right]\n ? [Right] extends [Left]\n ? true\n : false\n : false;\n\nexport type AgentEvalTargetOptions<\n Input,\n AgentOutput = string,\n Output = AgentResponse<AgentOutput>,\n Expected = unknown,\n> = {\n agent: EvaluableAgent<AgentOutput>;\n request(args: {\n input: Input;\n testCase: EvalCase<Input, Expected>;\n }): AgentRunOptions<AgentOutput> | Promise<AgentRunOptions<AgentOutput>>;\n interactions?:\n | {\n maxResponses?: number | undefined;\n respond(args: {\n interaction: AgentInteractionRequest;\n testCase: EvalCase<Input, Expected>;\n phase: number;\n }): AgentInteractionResponse | Promise<AgentInteractionResponse>;\n }\n | undefined;\n} & (IsExactly<Output, AgentResponse<AgentOutput>> extends true\n ? {\n output?(args: {\n response: AgentResponse<AgentOutput>;\n testCase: EvalCase<Input, Expected>;\n }): Output | Promise<Output>;\n }\n : {\n output(args: {\n response: AgentResponse<AgentOutput>;\n testCase: EvalCase<Input, Expected>;\n }): Output | Promise<Output>;\n });\n\nexport class AgentEvalSuspensionError extends Error {\n constructor(\n readonly result: AgentInteractionOutcome,\n message = \"Agent eval target suspended without an interaction responder.\",\n ) {\n super(message);\n this.name = \"AgentEvalSuspensionError\";\n }\n}\n\nexport function agentEvalTarget<\n Input,\n AgentOutput = string,\n Output = AgentResponse<AgentOutput>,\n Expected = unknown,\n>(\n options: AgentEvalTargetOptions<Input, AgentOutput, Output, Expected>,\n): EvalTarget<Input, Output, Expected> {\n return async (input, testCase) => {\n const maxResponses = options.interactions?.maxResponses ?? 10;\n if (!Number.isSafeInteger(maxResponses) || maxResponses < 1) {\n throw new TypeError(\"Agent eval interactions.maxResponses must be a positive integer.\");\n }\n const request = await options.request({ input, testCase });\n const runSettings = agentRunSettings(request);\n let response = await options.agent.generate(request);\n let phase = 0;\n while (response.type === \"interaction\") {\n if (options.interactions === undefined) {\n throw new AgentEvalSuspensionError(response);\n }\n if (phase >= maxResponses) {\n throw new AgentEvalSuspensionError(\n response,\n `Agent eval target exceeded the interaction response limit of ${maxResponses}.`,\n );\n }\n phase += 1;\n const interactionResponse = await options.interactions.respond({\n interaction: response.interaction,\n testCase,\n phase,\n });\n response = await options.agent.generate({\n continuation: response.continuation,\n response: interactionResponse,\n ...runSettings,\n });\n }\n if (response.type === \"blocked\") throw new AgentRunBlockedError(response);\n return options.output === undefined\n ? (response as Output)\n : await options.output({ response, testCase });\n };\n}\n\nfunction agentRunSettings<Output>(request: AgentRunOptions<Output>): AgentRunSettings<Output> {\n const {\n prompt: _prompt,\n messages: _messages,\n session: _session,\n continuation: _continuation,\n response: _response,\n ...settings\n } = request;\n return settings;\n}\n"],"mappings":";;;;;AA4DO,IAAM,2BAAN,cAAuC,MAAM;AAAA,EAClD,YACW,QACT,UAAU,iEACV;AACA,UAAM,OAAO;AAHJ;AAIT,SAAK,OAAO;AAAA,EACd;AAAA,EALW;AAMb;AAEO,SAAS,gBAMd,SACqC;AACrC,SAAO,OAAO,OAAO,aAAa;AAChC,UAAM,eAAe,QAAQ,cAAc,gBAAgB;AAC3D,QAAI,CAAC,OAAO,cAAc,YAAY,KAAK,eAAe,GAAG;AAC3D,YAAM,IAAI,UAAU,kEAAkE;AAAA,IACxF;AACA,UAAM,UAAU,MAAM,QAAQ,QAAQ,EAAE,OAAO,SAAS,CAAC;AACzD,UAAM,cAAc,iBAAiB,OAAO;AAC5C,QAAI,WAAW,MAAM,QAAQ,MAAM,SAAS,OAAO;AACnD,QAAI,QAAQ;AACZ,WAAO,SAAS,SAAS,eAAe;AACtC,UAAI,QAAQ,iBAAiB,QAAW;AACtC,cAAM,IAAI,yBAAyB,QAAQ;AAAA,MAC7C;AACA,UAAI,SAAS,cAAc;AACzB,cAAM,IAAI;AAAA,UACR;AAAA,UACA,gEAAgE,YAAY;AAAA,QAC9E;AAAA,MACF;AACA,eAAS;AACT,YAAM,sBAAsB,MAAM,QAAQ,aAAa,QAAQ;AAAA,QAC7D,aAAa,SAAS;AAAA,QACtB;AAAA,QACA;AAAA,MACF,CAAC;AACD,iBAAW,MAAM,QAAQ,MAAM,SAAS;AAAA,QACtC,cAAc,SAAS;AAAA,QACvB,UAAU;AAAA,QACV,GAAG;AAAA,MACL,CAAC;AAAA,IACH;AACA,QAAI,SAAS,SAAS,UAAW,OAAM,IAAI,qBAAqB,QAAQ;AACxE,WAAO,QAAQ,WAAW,SACrB,WACD,MAAM,QAAQ,OAAO,EAAE,UAAU,SAAS,CAAC;AAAA,EACjD;AACF;AAEA,SAAS,iBAAyB,SAA4D;AAC5F,QAAM;AAAA,IACJ,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,SAAS;AAAA,IACT,cAAc;AAAA,IACd,UAAU;AAAA,IACV,GAAG;AAAA,EACL,IAAI;AACJ,SAAO;AACT;","names":[]}
@@ -0,0 +1,19 @@
1
+ // src/internal/agent-runtime/run-validation.ts
2
+ function assertNonnegativeSafeInteger(value, name) {
3
+ if (!Number.isSafeInteger(value) || value < 0) {
4
+ throw new TypeError(`${name} must be a nonnegative safe integer.`);
5
+ }
6
+ return value;
7
+ }
8
+ function assertPositiveSafeInteger(value, name) {
9
+ if (!Number.isSafeInteger(value) || value <= 0) {
10
+ throw new TypeError(`${name} must be a positive safe integer.`);
11
+ }
12
+ return value;
13
+ }
14
+
15
+ export {
16
+ assertNonnegativeSafeInteger,
17
+ assertPositiveSafeInteger
18
+ };
19
+ //# sourceMappingURL=chunk-NPJ2T3L5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internal/agent-runtime/run-validation.ts"],"sourcesContent":["export function assertNonnegativeSafeInteger(value: number, name: string): number {\n if (!Number.isSafeInteger(value) || value < 0) {\n throw new TypeError(`${name} must be a nonnegative safe integer.`);\n }\n return value;\n}\n\nexport function assertPositiveSafeInteger(value: number, name: string): number {\n if (!Number.isSafeInteger(value) || value <= 0) {\n throw new TypeError(`${name} must be a positive safe integer.`);\n }\n return value;\n}\n"],"mappings":";AAAO,SAAS,6BAA6B,OAAe,MAAsB;AAChF,MAAI,CAAC,OAAO,cAAc,KAAK,KAAK,QAAQ,GAAG;AAC7C,UAAM,IAAI,UAAU,GAAG,IAAI,sCAAsC;AAAA,EACnE;AACA,SAAO;AACT;AAEO,SAAS,0BAA0B,OAAe,MAAsB;AAC7E,MAAI,CAAC,OAAO,cAAc,KAAK,KAAK,SAAS,GAAG;AAC9C,UAAM,IAAI,UAAU,GAAG,IAAI,mCAAmC;AAAA,EAChE;AACA,SAAO;AACT;","names":[]}
@@ -0,0 +1,150 @@
1
+ import {
2
+ isVectorContext
3
+ } from "./chunk-ZHC5CD6J.js";
4
+ import {
5
+ assertFiniteMinScore,
6
+ assertPositiveSearchLimit
7
+ } from "./chunk-5V533R7F.js";
8
+
9
+ // src/agent/snapshot.ts
10
+ function snapshotAgentContext(inputs) {
11
+ const context = (inputs ?? []).map(snapshotContextInput);
12
+ for (const input of context) {
13
+ if (!isVectorContext(input)) continue;
14
+ assertPositiveSearchLimit(input.topK);
15
+ assertFiniteMinScore(input.minScore);
16
+ }
17
+ return Object.freeze(context);
18
+ }
19
+ function snapshotAgentObservability(observability) {
20
+ if (observability === void 0) return void 0;
21
+ const observers = {};
22
+ for (const [name, observer] of Object.entries(observability.observers)) {
23
+ if (name.trim().length === 0) {
24
+ throw new TypeError("Agent observer names must not be empty.");
25
+ }
26
+ if (typeof observer !== "object" || observer === null || typeof observer.startRun !== "function") {
27
+ throw new TypeError(`Agent observer "${name}" must implement startRun().`);
28
+ }
29
+ observers[name] = observer;
30
+ }
31
+ if (observability.primaryTrace !== void 0 && !(observability.primaryTrace in observers)) {
32
+ throw new TypeError(
33
+ `Agent primaryTrace "${observability.primaryTrace}" must name a configured observer.`
34
+ );
35
+ }
36
+ const errorPolicy = observability.errorPolicy ?? "ignore";
37
+ if (errorPolicy !== "ignore" && errorPolicy !== "throw") {
38
+ throw new TypeError('Agent observability.errorPolicy must be "ignore" or "throw".');
39
+ }
40
+ let snapshot = {
41
+ observers: Object.freeze(observers),
42
+ errorPolicy
43
+ };
44
+ if (observability.primaryTrace !== void 0) {
45
+ snapshot = { ...snapshot, primaryTrace: observability.primaryTrace };
46
+ }
47
+ return Object.freeze(snapshot);
48
+ }
49
+ function snapshotGuardrailPolicies(policies) {
50
+ return Object.freeze((policies ?? []).map(snapshotGuardrailPolicy));
51
+ }
52
+ function snapshotAgentMemory(memory) {
53
+ if (memory === void 0) {
54
+ return void 0;
55
+ }
56
+ const compaction = memory.compaction === void 0 ? void 0 : Object.freeze({
57
+ ...memory.compaction,
58
+ trigger: Object.freeze({ ...memory.compaction.trigger }),
59
+ retention: Object.freeze({ ...memory.compaction.retention }),
60
+ conflictRetries: memory.compaction.conflictRetries === false ? false : Object.freeze({ ...memory.compaction.conflictRetries })
61
+ });
62
+ let snapshot = {
63
+ store: memory.store,
64
+ savePolicy: memory.savePolicy
65
+ };
66
+ if (compaction !== void 0) {
67
+ snapshot = { ...snapshot, compaction };
68
+ }
69
+ return Object.freeze(snapshot);
70
+ }
71
+ function cloneFrozenPlainData(value) {
72
+ if (Array.isArray(value)) {
73
+ return Object.freeze(value.map(cloneFrozenPlainData));
74
+ }
75
+ if (typeof value !== "object" || value === null) {
76
+ return value;
77
+ }
78
+ const prototype = Object.getPrototypeOf(value);
79
+ if (prototype !== Object.prototype && prototype !== null) {
80
+ return value;
81
+ }
82
+ const clone = Object.fromEntries(
83
+ Object.entries(value).map(([key, item]) => [key, cloneFrozenPlainData(item)])
84
+ );
85
+ return Object.freeze(clone);
86
+ }
87
+ function snapshotContextInput(input) {
88
+ if (!isVectorContext(input)) {
89
+ let document = {
90
+ id: input.id,
91
+ text: input.text
92
+ };
93
+ if (input.additionalProps !== void 0) {
94
+ document = {
95
+ ...document,
96
+ additionalProps: cloneFrozenPlainData(input.additionalProps)
97
+ };
98
+ }
99
+ return Object.freeze(document);
100
+ }
101
+ const format = input.format;
102
+ let shared = {
103
+ kind: "vector-context",
104
+ store: input.store,
105
+ topK: input.topK
106
+ };
107
+ if (input.minScore !== void 0) {
108
+ shared = { ...shared, minScore: input.minScore };
109
+ }
110
+ if (input.filter !== void 0) {
111
+ shared = { ...shared, filter: cloneFrozenPlainData(input.filter) };
112
+ }
113
+ if (input.retries !== void 0) {
114
+ shared = { ...shared, retries: cloneFrozenPlainData(input.retries) };
115
+ }
116
+ if (format !== void 0) {
117
+ shared = {
118
+ ...shared,
119
+ format: (result) => format.call(input, result)
120
+ };
121
+ }
122
+ if (!("models" in input) || input.models === void 0) {
123
+ return Object.freeze({ ...shared, store: input.store, model: input.model });
124
+ }
125
+ let context = {
126
+ ...shared,
127
+ store: input.store,
128
+ models: input.models
129
+ };
130
+ if (input.fusion !== void 0) {
131
+ context = { ...context, fusion: input.fusion };
132
+ }
133
+ return Object.freeze(context);
134
+ }
135
+ function snapshotGuardrailPolicy(policy) {
136
+ return Object.freeze({
137
+ ...policy,
138
+ input: Object.freeze([...policy.input]),
139
+ output: Object.freeze([...policy.output])
140
+ });
141
+ }
142
+
143
+ export {
144
+ snapshotAgentContext,
145
+ snapshotAgentObservability,
146
+ snapshotGuardrailPolicies,
147
+ snapshotAgentMemory,
148
+ cloneFrozenPlainData
149
+ };
150
+ //# sourceMappingURL=chunk-NVALGVQG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/agent/snapshot.ts"],"sourcesContent":["import type { GuardrailPolicy } from \"../guardrails\";\nimport { assertFiniteMinScore, assertPositiveSearchLimit } from \"../internal/vector-search-options\";\nimport type { AgentObservabilityOptions, AgentObserverMap } from \"../observability\";\nimport type { VectorSearchResult } from \"../vector-store\";\nimport type { AgentContextInput, AgentMemory } from \"./types\";\nimport {\n isVectorContext,\n type VectorContext,\n type VectorContextBaseOptions,\n} from \"./vector-context\";\n\nexport function snapshotAgentContext<T>(\n inputs: readonly AgentContextInput<T>[] | undefined,\n): readonly AgentContextInput<T>[] {\n const context = (inputs ?? []).map(snapshotContextInput);\n for (const input of context) {\n if (!isVectorContext(input)) continue;\n assertPositiveSearchLimit(input.topK);\n assertFiniteMinScore(input.minScore);\n }\n return Object.freeze(context);\n}\n\nexport function snapshotAgentObservability(\n observability: AgentObservabilityOptions | undefined,\n): AgentObservabilityOptions | undefined {\n if (observability === undefined) return undefined;\n const observers: Record<string, AgentObserverMap[string]> = {};\n for (const [name, observer] of Object.entries(observability.observers)) {\n if (name.trim().length === 0) {\n throw new TypeError(\"Agent observer names must not be empty.\");\n }\n if (\n typeof observer !== \"object\" ||\n observer === null ||\n typeof observer.startRun !== \"function\"\n ) {\n throw new TypeError(`Agent observer \"${name}\" must implement startRun().`);\n }\n observers[name] = observer;\n }\n if (observability.primaryTrace !== undefined && !(observability.primaryTrace in observers)) {\n throw new TypeError(\n `Agent primaryTrace \"${observability.primaryTrace}\" must name a configured observer.`,\n );\n }\n const errorPolicy = observability.errorPolicy ?? \"ignore\";\n if (errorPolicy !== \"ignore\" && errorPolicy !== \"throw\") {\n throw new TypeError('Agent observability.errorPolicy must be \"ignore\" or \"throw\".');\n }\n let snapshot: AgentObservabilityOptions = {\n observers: Object.freeze(observers),\n errorPolicy,\n };\n if (observability.primaryTrace !== undefined) {\n snapshot = { ...snapshot, primaryTrace: observability.primaryTrace };\n }\n return Object.freeze(snapshot);\n}\n\nexport function snapshotGuardrailPolicies(\n policies: readonly GuardrailPolicy[] | undefined,\n): readonly GuardrailPolicy[] {\n return Object.freeze((policies ?? []).map(snapshotGuardrailPolicy));\n}\n\nexport function snapshotAgentMemory(memory: AgentMemory | undefined): AgentMemory | undefined {\n if (memory === undefined) {\n return undefined;\n }\n const compaction =\n memory.compaction === undefined\n ? undefined\n : Object.freeze({\n ...memory.compaction,\n trigger: Object.freeze({ ...memory.compaction.trigger }),\n retention: Object.freeze({ ...memory.compaction.retention }),\n conflictRetries:\n memory.compaction.conflictRetries === false\n ? false\n : Object.freeze({ ...memory.compaction.conflictRetries }),\n });\n let snapshot: AgentMemory = {\n store: memory.store,\n savePolicy: memory.savePolicy,\n };\n if (compaction !== undefined) {\n snapshot = { ...snapshot, compaction };\n }\n return Object.freeze(snapshot);\n}\n\nexport function cloneFrozenPlainData<T>(value: T): T {\n if (Array.isArray(value)) {\n return Object.freeze(value.map(cloneFrozenPlainData)) as T;\n }\n if (typeof value !== \"object\" || value === null) {\n return value;\n }\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n return value;\n }\n const clone = Object.fromEntries(\n Object.entries(value).map(([key, item]) => [key, cloneFrozenPlainData(item)]),\n );\n return Object.freeze(clone) as T;\n}\n\nfunction snapshotContextInput<T>(input: AgentContextInput<T>): AgentContextInput<T> {\n if (!isVectorContext(input)) {\n let document: AgentContextInput<T> = {\n id: input.id,\n text: input.text,\n };\n if (input.additionalProps !== undefined) {\n document = {\n ...document,\n additionalProps: cloneFrozenPlainData(input.additionalProps),\n };\n }\n return Object.freeze(document);\n }\n const format = input.format;\n let shared: VectorContextBaseOptions<T> & {\n kind: \"vector-context\";\n store: VectorContext<T>[\"store\"];\n } = {\n kind: \"vector-context\" as const,\n store: input.store,\n topK: input.topK,\n };\n if (input.minScore !== undefined) {\n shared = { ...shared, minScore: input.minScore };\n }\n if (input.filter !== undefined) {\n shared = { ...shared, filter: cloneFrozenPlainData(input.filter) };\n }\n if (input.retries !== undefined) {\n shared = { ...shared, retries: cloneFrozenPlainData(input.retries) };\n }\n if (format !== undefined) {\n shared = {\n ...shared,\n format: (result: VectorSearchResult<T>) => format.call(input, result),\n };\n }\n if (!(\"models\" in input) || input.models === undefined) {\n return Object.freeze<VectorContext<T>>({ ...shared, store: input.store, model: input.model });\n }\n let context: VectorContext<T> = {\n ...shared,\n store: input.store,\n models: input.models,\n };\n if (input.fusion !== undefined) {\n context = { ...context, fusion: input.fusion };\n }\n return Object.freeze(context);\n}\n\nfunction snapshotGuardrailPolicy(policy: GuardrailPolicy): GuardrailPolicy {\n return Object.freeze({\n ...policy,\n input: Object.freeze([...policy.input]),\n output: Object.freeze([...policy.output]),\n }) as GuardrailPolicy;\n}\n"],"mappings":"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","names":[]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-OJF67RNM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,89 @@
1
+ // src/evals/reporting.ts
2
+ function projectEvalOutcome(outcome, dataType, projectScore) {
3
+ const value = projectScoreValue(outcome, dataType, projectScore);
4
+ const projection = {
5
+ outcome: outcome.outcome,
6
+ value,
7
+ label: typeof value === "string" ? value : outcome.outcome
8
+ };
9
+ if (typeof value === "number") projection.numericValue = value;
10
+ if (typeof value === "string") projection.categoricalValue = value;
11
+ const explanation = outcome.comment ?? (outcome.outcome === "invalid" ? outcome.reason : void 0);
12
+ if (explanation !== void 0) projection.explanation = explanation;
13
+ return projection;
14
+ }
15
+ function resolveEvalTraceRef(args) {
16
+ return traceFromCarrier(args.output) ?? traceFromCarrier(args.input) ?? traceFromMetadata(args.metadata);
17
+ }
18
+ function defaultEvalTraceSelector(args) {
19
+ return resolveEvalTraceRef({
20
+ output: args.output,
21
+ input: args.case.input,
22
+ metadata: args.case.metadata
23
+ });
24
+ }
25
+ function projectScoreValue(outcome, dataType, projectScore) {
26
+ const score = outcome.score;
27
+ if (score !== void 0 && projectScore !== void 0) {
28
+ const projected = projectScore(score);
29
+ if (typeof projected === "boolean") return projected ? 1 : 0;
30
+ return projected;
31
+ }
32
+ if (dataType === "CATEGORICAL") {
33
+ if (typeof score === "string") return score;
34
+ if (typeof score === "number") return String(score);
35
+ if (typeof score === "boolean") return score ? "true" : "false";
36
+ if (score === null || score === void 0) return outcome.outcome;
37
+ try {
38
+ return JSON.stringify(score) ?? outcome.outcome;
39
+ } catch {
40
+ return outcome.outcome;
41
+ }
42
+ }
43
+ if (dataType === "BOOLEAN") {
44
+ if (typeof score === "boolean") return score ? 1 : 0;
45
+ if (typeof score === "number") return score === 0 ? 0 : 1;
46
+ return outcome.outcome === "pass" ? 1 : 0;
47
+ }
48
+ if (typeof score === "number") return score;
49
+ if (typeof score === "boolean") return score ? 1 : 0;
50
+ if (typeof score === "object" && score !== null && "score" in score && typeof score.score === "number") {
51
+ return score.score;
52
+ }
53
+ return outcome.outcome === "pass" ? 1 : 0;
54
+ }
55
+ function traceFromCarrier(value) {
56
+ if (typeof value !== "object" || value === null || !("trace" in value)) return void 0;
57
+ return readTraceRef(value.trace);
58
+ }
59
+ function traceFromMetadata(metadata) {
60
+ if (metadata === void 0) return void 0;
61
+ return readTraceRef({
62
+ observer: metadata.traceObserver,
63
+ traceId: metadata.traceId,
64
+ observationId: metadata.observationId,
65
+ responseId: metadata.responseId
66
+ });
67
+ }
68
+ function readTraceRef(value) {
69
+ if (typeof value !== "object" || value === null) return void 0;
70
+ const traceId = value.traceId;
71
+ if (typeof traceId !== "string" || traceId.length === 0) return void 0;
72
+ const observer = value.observer;
73
+ const observationId = value.observationId;
74
+ const responseId = value.responseId;
75
+ const trace = { traceId };
76
+ if (typeof observer === "string" && observer.length > 0) trace.observer = observer;
77
+ if (typeof observationId === "string" && observationId.length > 0) {
78
+ trace.observationId = observationId;
79
+ }
80
+ if (typeof responseId === "string" && responseId.length > 0) trace.responseId = responseId;
81
+ return trace;
82
+ }
83
+
84
+ export {
85
+ projectEvalOutcome,
86
+ resolveEvalTraceRef,
87
+ defaultEvalTraceSelector
88
+ };
89
+ //# sourceMappingURL=chunk-PHLGGRHC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/evals/reporting.ts"],"sourcesContent":["import type { EvalOutcome } from \"./outcome\";\nimport type {\n EvalMetadata,\n EvalMetric,\n EvalScoreProjection,\n EvalTraceRef,\n EvalTraceSelectorArgs,\n} from \"./types\";\n\nexport function projectEvalOutcome<Score>(\n outcome: EvalOutcome<Score>,\n dataType: EvalMetric<unknown, unknown>[\"dataType\"],\n projectScore?: ((score: Score) => number | string | boolean) | undefined,\n): EvalScoreProjection {\n const value = projectScoreValue(outcome, dataType, projectScore);\n const projection: EvalScoreProjection = {\n outcome: outcome.outcome,\n value,\n label: typeof value === \"string\" ? value : outcome.outcome,\n };\n if (typeof value === \"number\") projection.numericValue = value;\n if (typeof value === \"string\") projection.categoricalValue = value;\n const explanation =\n outcome.comment ?? (outcome.outcome === \"invalid\" ? outcome.reason : undefined);\n if (explanation !== undefined) projection.explanation = explanation;\n return projection;\n}\n\nexport function resolveEvalTraceRef(args: {\n output?: unknown;\n input?: unknown;\n metadata?: EvalMetadata | undefined;\n}): EvalTraceRef | undefined {\n return (\n traceFromCarrier(args.output) ??\n traceFromCarrier(args.input) ??\n traceFromMetadata(args.metadata)\n );\n}\n\nexport function defaultEvalTraceSelector<Input, Output, Expected>(\n args: EvalTraceSelectorArgs<Input, Output, Expected>,\n): EvalTraceRef | undefined {\n return resolveEvalTraceRef({\n output: args.output,\n input: args.case.input,\n metadata: args.case.metadata,\n });\n}\n\nfunction projectScoreValue<Score>(\n outcome: EvalOutcome<Score>,\n dataType: EvalMetric<unknown, unknown>[\"dataType\"],\n projectScore: ((score: Score) => number | string | boolean) | undefined,\n): number | string {\n const score = outcome.score;\n if (score !== undefined && projectScore !== undefined) {\n const projected = projectScore(score);\n if (typeof projected === \"boolean\") return projected ? 1 : 0;\n return projected;\n }\n if (dataType === \"CATEGORICAL\") {\n if (typeof score === \"string\") return score;\n if (typeof score === \"number\") return String(score);\n if (typeof score === \"boolean\") return score ? \"true\" : \"false\";\n if (score === null || score === undefined) return outcome.outcome;\n try {\n return JSON.stringify(score) ?? outcome.outcome;\n } catch {\n return outcome.outcome;\n }\n }\n if (dataType === \"BOOLEAN\") {\n if (typeof score === \"boolean\") return score ? 1 : 0;\n if (typeof score === \"number\") return score === 0 ? 0 : 1;\n return outcome.outcome === \"pass\" ? 1 : 0;\n }\n if (typeof score === \"number\") return score;\n if (typeof score === \"boolean\") return score ? 1 : 0;\n if (\n typeof score === \"object\" &&\n score !== null &&\n \"score\" in score &&\n typeof (score as { score?: unknown }).score === \"number\"\n ) {\n return (score as { score: number }).score;\n }\n return outcome.outcome === \"pass\" ? 1 : 0;\n}\n\nfunction traceFromCarrier(value: unknown): EvalTraceRef | undefined {\n if (typeof value !== \"object\" || value === null || !(\"trace\" in value)) return undefined;\n return readTraceRef((value as { trace?: unknown }).trace);\n}\n\nfunction traceFromMetadata(metadata: EvalMetadata | undefined): EvalTraceRef | undefined {\n if (metadata === undefined) return undefined;\n return readTraceRef({\n observer: metadata.traceObserver,\n traceId: metadata.traceId,\n observationId: metadata.observationId,\n responseId: metadata.responseId,\n });\n}\n\nfunction readTraceRef(value: unknown): EvalTraceRef | undefined {\n if (typeof value !== \"object\" || value === null) return undefined;\n const traceId = (value as { traceId?: unknown }).traceId;\n if (typeof traceId !== \"string\" || traceId.length === 0) return undefined;\n const observer = (value as { observer?: unknown }).observer;\n const observationId = (value as { observationId?: unknown }).observationId;\n const responseId = (value as { responseId?: unknown }).responseId;\n const trace: EvalTraceRef = { traceId };\n if (typeof observer === \"string\" && observer.length > 0) trace.observer = observer;\n if (typeof observationId === \"string\" && observationId.length > 0) {\n trace.observationId = observationId;\n }\n if (typeof responseId === \"string\" && responseId.length > 0) trace.responseId = responseId;\n return trace;\n}\n"],"mappings":"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","names":[]}