@probelabs/visor 0.1.183-ee → 0.1.184-ee

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 (241) hide show
  1. package/dist/agent-protocol/task-live-update-slack.d.ts +24 -0
  2. package/dist/agent-protocol/task-live-update-slack.d.ts.map +1 -0
  3. package/dist/agent-protocol/task-live-update-teams.d.ts +25 -0
  4. package/dist/agent-protocol/task-live-update-teams.d.ts.map +1 -0
  5. package/dist/agent-protocol/task-live-update-telegram.d.ts +25 -0
  6. package/dist/agent-protocol/task-live-update-telegram.d.ts.map +1 -0
  7. package/dist/agent-protocol/task-live-updates.d.ts +102 -0
  8. package/dist/agent-protocol/task-live-updates.d.ts.map +1 -0
  9. package/dist/agent-protocol/task-progress-tool.d.ts.map +1 -1
  10. package/dist/agent-protocol/task-trace-resolution.d.ts +11 -0
  11. package/dist/agent-protocol/task-trace-resolution.d.ts.map +1 -0
  12. package/dist/agent-protocol/trace-serializer.d.ts.map +1 -1
  13. package/dist/agent-protocol/track-execution.d.ts +8 -0
  14. package/dist/agent-protocol/track-execution.d.ts.map +1 -1
  15. package/dist/cli-main.d.ts.map +1 -1
  16. package/dist/cli.d.ts.map +1 -1
  17. package/dist/config.d.ts.map +1 -1
  18. package/dist/frontends/slack-frontend.d.ts +2 -0
  19. package/dist/frontends/slack-frontend.d.ts.map +1 -1
  20. package/dist/frontends/teams-frontend.d.ts.map +1 -1
  21. package/dist/frontends/telegram-frontend.d.ts.map +1 -1
  22. package/dist/generated/config-schema.d.ts +110 -6
  23. package/dist/generated/config-schema.d.ts.map +1 -1
  24. package/dist/index.js +2239 -261
  25. package/dist/logger.d.ts +4 -1
  26. package/dist/logger.d.ts.map +1 -1
  27. package/dist/mcp-job-manager.d.ts +70 -0
  28. package/dist/mcp-job-manager.d.ts.map +1 -0
  29. package/dist/mcp-server.d.ts +6 -0
  30. package/dist/mcp-server.d.ts.map +1 -1
  31. package/dist/runners/mcp-server-runner.d.ts +4 -0
  32. package/dist/runners/mcp-server-runner.d.ts.map +1 -1
  33. package/dist/runners/runner-factory.d.ts.map +1 -1
  34. package/dist/sdk/{a2a-frontend-5YDHFQXD.mjs → a2a-frontend-OI4OVSKC.mjs} +4 -4
  35. package/dist/sdk/check-provider-registry-RITJW67U.mjs +32 -0
  36. package/dist/sdk/check-provider-registry-ZZ6N4GDP.mjs +32 -0
  37. package/dist/sdk/{chunk-4BN2XI4X.mjs → chunk-4HIWZA6M.mjs} +2 -2
  38. package/dist/sdk/{chunk-RI4ONH5X.mjs → chunk-4MHHELVZ.mjs} +2 -2
  39. package/dist/sdk/{chunk-J27D43HS.mjs → chunk-4ZLYHSN4.mjs} +2 -2
  40. package/dist/sdk/{chunk-ZPYODGYA.mjs → chunk-6E625R3C.mjs} +19 -4
  41. package/dist/sdk/chunk-6E625R3C.mjs.map +1 -0
  42. package/dist/sdk/{chunk-GA2TYKSR.mjs → chunk-7XKHFRPN.mjs} +4 -4
  43. package/dist/sdk/{chunk-6C3R6E42.mjs → chunk-IY5PQ5EN.mjs} +30 -6
  44. package/dist/sdk/chunk-IY5PQ5EN.mjs.map +1 -0
  45. package/dist/sdk/{chunk-MFXPJUUE.mjs → chunk-PUHU6UY6.mjs} +4 -3
  46. package/dist/sdk/chunk-PUHU6UY6.mjs.map +1 -0
  47. package/dist/sdk/{chunk-XOAEKFKB.mjs → chunk-QLT42TX7.mjs} +2 -2
  48. package/dist/sdk/chunk-SRU5TFNY.mjs +620 -0
  49. package/dist/sdk/chunk-SRU5TFNY.mjs.map +1 -0
  50. package/dist/sdk/{chunk-P2K4VOMU.mjs → chunk-TSX3YS3F.mjs} +3 -3
  51. package/dist/sdk/{chunk-WKLJ57WF.mjs → chunk-UM7LGO2P.mjs} +6 -6
  52. package/dist/sdk/{chunk-7VTZDC2X.mjs → chunk-VPPBOKBQ.mjs} +2 -2
  53. package/dist/sdk/chunk-WZQMTD7W.mjs +33 -0
  54. package/dist/sdk/chunk-WZQMTD7W.mjs.map +1 -0
  55. package/dist/sdk/{chunk-ZOF5QT6U.mjs → chunk-YBXNG75V.mjs} +118 -10
  56. package/dist/sdk/chunk-YBXNG75V.mjs.map +1 -0
  57. package/dist/sdk/{chunk-UXB4XWEE.mjs → chunk-YYFSAAD6.mjs} +53 -51
  58. package/dist/sdk/chunk-YYFSAAD6.mjs.map +1 -0
  59. package/dist/sdk/{chunk-RHKPFJLG.mjs → chunk-ZNKL6ESZ.mjs} +2 -2
  60. package/dist/sdk/{chunk-IDL3AA3G.mjs → chunk-ZYDRR6PZ.mjs} +1150 -403
  61. package/dist/sdk/chunk-ZYDRR6PZ.mjs.map +1 -0
  62. package/dist/sdk/{command-executor-YNJOS77A.mjs → command-executor-LHUW77GR.mjs} +3 -3
  63. package/dist/sdk/{config-PCP6O6Y6.mjs → config-TVU5RWR5.mjs} +3 -3
  64. package/dist/sdk/{dist-3UGGEZB3.mjs → dist-PN5UHL6A.mjs} +429 -429
  65. package/dist/sdk/dist-PN5UHL6A.mjs.map +1 -0
  66. package/dist/sdk/{email-frontend-WSNADJPI.mjs → email-frontend-ECHQCFTR.mjs} +2 -2
  67. package/dist/sdk/{failure-condition-evaluator-IRFKTYZD.mjs → failure-condition-evaluator-USY3ISVA.mjs} +6 -6
  68. package/dist/sdk/{github-auth-BJQBLK2V.mjs → github-auth-UO4DMNCC.mjs} +2 -2
  69. package/dist/sdk/{github-frontend-DECYOBRN.mjs → github-frontend-2T5PWYD5.mjs} +6 -6
  70. package/dist/sdk/{host-CFM2ASDI.mjs → host-OJSMCLKK.mjs} +6 -6
  71. package/dist/sdk/{host-T4LNVU2H.mjs → host-RM6UJEPP.mjs} +7 -7
  72. package/dist/sdk/{knex-store-OEWSZEBY.mjs → knex-store-KCMFAMH5.mjs} +2 -2
  73. package/dist/sdk/{liquid-extensions-E3AKRX7P.mjs → liquid-extensions-KZIRR4OY.mjs} +4 -4
  74. package/dist/sdk/{loader-WRGI244P.mjs → loader-35YWX5UQ.mjs} +4 -4
  75. package/dist/sdk/{memory-store-OHUIXCWJ.mjs → memory-store-3JONK7AF.mjs} +3 -3
  76. package/dist/sdk/{opa-policy-engine-IVMCGVNA.mjs → opa-policy-engine-FY5D45YS.mjs} +2 -2
  77. package/dist/sdk/{prompt-state-LN57DQF3.mjs → prompt-state-VVJMONT3.mjs} +3 -3
  78. package/dist/sdk/{renderer-schema-BT2IXMLW.mjs → renderer-schema-JZRRU5CW.mjs} +2 -2
  79. package/dist/sdk/{routing-H2PQ57OA.mjs → routing-NNQQSLWA.mjs} +8 -8
  80. package/dist/sdk/{schedule-tool-2DPNSU63.mjs → schedule-tool-ADZ2ON4I.mjs} +15 -14
  81. package/dist/sdk/schedule-tool-EMNF3FPQ.mjs +38 -0
  82. package/dist/sdk/{schedule-tool-handler-NBEO46RV.mjs → schedule-tool-handler-3R3IC6VA.mjs} +15 -14
  83. package/dist/sdk/{schedule-tool-handler-KLHE2SOW.mjs → schedule-tool-handler-F76ZD2WU.mjs} +17 -16
  84. package/dist/sdk/sdk.d.mts +40 -0
  85. package/dist/sdk/sdk.d.ts +40 -0
  86. package/dist/sdk/sdk.js +1154 -176
  87. package/dist/sdk/sdk.js.map +1 -1
  88. package/dist/sdk/sdk.mjs +14 -13
  89. package/dist/sdk/sdk.mjs.map +1 -1
  90. package/dist/sdk/{slack-frontend-DF5VL4OF.mjs → slack-frontend-K3TPGERM.mjs} +65 -9
  91. package/dist/sdk/slack-frontend-K3TPGERM.mjs.map +1 -0
  92. package/dist/sdk/{task-evaluator-OVMG7S56.mjs → task-evaluator-H3BXC7SE.mjs} +3 -3
  93. package/dist/sdk/{teams-frontend-DNW5GZP3.mjs → teams-frontend-6RRW533K.mjs} +54 -1
  94. package/dist/sdk/teams-frontend-6RRW533K.mjs.map +1 -0
  95. package/dist/sdk/{telegram-frontend-GA7OLADB.mjs → telegram-frontend-5UA77YAT.mjs} +48 -1
  96. package/dist/sdk/telegram-frontend-5UA77YAT.mjs.map +1 -0
  97. package/dist/sdk/{trace-helpers-26ZCAE2V.mjs → trace-helpers-OMF4C24T.mjs} +3 -3
  98. package/dist/sdk/{trace-serializer-KKBJHM7J.mjs → trace-serializer-EBHTHZYT.mjs} +3 -3
  99. package/dist/sdk/track-execution-3CHMGEPH.mjs +249 -0
  100. package/dist/sdk/track-execution-3CHMGEPH.mjs.map +1 -0
  101. package/dist/sdk/{utcp-check-provider-WI3QZ3W6.mjs → utcp-check-provider-Q4PD5EP2.mjs} +5 -5
  102. package/dist/sdk/workflow-check-provider-TC2G33WF.mjs +32 -0
  103. package/dist/sdk/workflow-check-provider-U4UXZ5YS.mjs +32 -0
  104. package/dist/sdk/{workflow-registry-YCZ3FCJC.mjs → workflow-registry-K56UTX36.mjs} +3 -3
  105. package/dist/slack/client.d.ts +14 -0
  106. package/dist/slack/client.d.ts.map +1 -1
  107. package/dist/slack/socket-runner.d.ts.map +1 -1
  108. package/dist/teams/client.d.ts +16 -0
  109. package/dist/teams/client.d.ts.map +1 -1
  110. package/dist/teams/webhook-runner.d.ts.map +1 -1
  111. package/dist/telegram/client.d.ts +17 -0
  112. package/dist/telegram/client.d.ts.map +1 -1
  113. package/dist/telegram/polling-runner.d.ts.map +1 -1
  114. package/dist/types/cli.d.ts +2 -0
  115. package/dist/types/cli.d.ts.map +1 -1
  116. package/dist/types/config.d.ts +40 -0
  117. package/dist/types/config.d.ts.map +1 -1
  118. package/package.json +4 -3
  119. package/dist/generated/config-schema.json +0 -4027
  120. package/dist/sdk/a2a-frontend-6LWBIPMS.mjs +0 -1734
  121. package/dist/sdk/a2a-frontend-6LWBIPMS.mjs.map +0 -1
  122. package/dist/sdk/check-provider-registry-WSEVHJEV.mjs +0 -31
  123. package/dist/sdk/check-provider-registry-YRADEEQY.mjs +0 -31
  124. package/dist/sdk/chunk-34QX63WK.mjs +0 -244
  125. package/dist/sdk/chunk-34QX63WK.mjs.map +0 -1
  126. package/dist/sdk/chunk-54KOAC4W.mjs +0 -665
  127. package/dist/sdk/chunk-6C3R6E42.mjs.map +0 -1
  128. package/dist/sdk/chunk-7W5QCO4Y.mjs +0 -5943
  129. package/dist/sdk/chunk-7W5QCO4Y.mjs.map +0 -1
  130. package/dist/sdk/chunk-7XRSCOKE.mjs +0 -825
  131. package/dist/sdk/chunk-FT3I25QV.mjs +0 -251
  132. package/dist/sdk/chunk-FT3I25QV.mjs.map +0 -1
  133. package/dist/sdk/chunk-G7GSN3SK.mjs +0 -390
  134. package/dist/sdk/chunk-G7GSN3SK.mjs.map +0 -1
  135. package/dist/sdk/chunk-IDL3AA3G.mjs.map +0 -1
  136. package/dist/sdk/chunk-J27D43HS.mjs.map +0 -1
  137. package/dist/sdk/chunk-MEB2TTIE.mjs +0 -157
  138. package/dist/sdk/chunk-MEB2TTIE.mjs.map +0 -1
  139. package/dist/sdk/chunk-MFXPJUUE.mjs.map +0 -1
  140. package/dist/sdk/chunk-NPSLGKXB.mjs +0 -1502
  141. package/dist/sdk/chunk-P2K4VOMU.mjs.map +0 -1
  142. package/dist/sdk/chunk-PQWZ6NFL.mjs +0 -459
  143. package/dist/sdk/chunk-PQWZ6NFL.mjs.map +0 -1
  144. package/dist/sdk/chunk-S5FSRHMY.mjs +0 -139
  145. package/dist/sdk/chunk-S5FSRHMY.mjs.map +0 -1
  146. package/dist/sdk/chunk-TFUQ2D5L.mjs +0 -307
  147. package/dist/sdk/chunk-TFUQ2D5L.mjs.map +0 -1
  148. package/dist/sdk/chunk-UCMJJ3IM.mjs +0 -227
  149. package/dist/sdk/chunk-UCMJJ3IM.mjs.map +0 -1
  150. package/dist/sdk/chunk-UFHOIB3R.mjs +0 -482
  151. package/dist/sdk/chunk-UFHOIB3R.mjs.map +0 -1
  152. package/dist/sdk/chunk-UXB4XWEE.mjs.map +0 -1
  153. package/dist/sdk/chunk-V45TITKX.mjs +0 -739
  154. package/dist/sdk/chunk-V45TITKX.mjs.map +0 -1
  155. package/dist/sdk/chunk-WKLJ57WF.mjs.map +0 -1
  156. package/dist/sdk/chunk-ZOF5QT6U.mjs.map +0 -1
  157. package/dist/sdk/chunk-ZPYODGYA.mjs.map +0 -1
  158. package/dist/sdk/command-executor-3AHGIYQG.mjs +0 -14
  159. package/dist/sdk/config-JE4HKTWW.mjs +0 -16
  160. package/dist/sdk/dist-3UGGEZB3.mjs.map +0 -1
  161. package/dist/sdk/failure-condition-evaluator-H3PBFBYT.mjs +0 -18
  162. package/dist/sdk/github-auth-27SZGPEC.mjs +0 -196
  163. package/dist/sdk/github-auth-BJQBLK2V.mjs.map +0 -1
  164. package/dist/sdk/github-frontend-TZRBOQCN.mjs +0 -1394
  165. package/dist/sdk/github-frontend-TZRBOQCN.mjs.map +0 -1
  166. package/dist/sdk/lazy-otel-5NH4ZJJM.mjs +0 -24
  167. package/dist/sdk/liquid-extensions-P6KDYILF.mjs +0 -25
  168. package/dist/sdk/memory-store-K5N7MC7U.mjs +0 -12
  169. package/dist/sdk/metrics-JTOG2HNO.mjs +0 -41
  170. package/dist/sdk/prompt-state-YPICX7PI.mjs +0 -16
  171. package/dist/sdk/renderer-schema-KOIH75RZ.mjs +0 -51
  172. package/dist/sdk/renderer-schema-KOIH75RZ.mjs.map +0 -1
  173. package/dist/sdk/routing-JMZ7HDCC.mjs +0 -26
  174. package/dist/sdk/schedule-tool-4M45RK3E.mjs +0 -37
  175. package/dist/sdk/schedule-tool-4M45RK3E.mjs.map +0 -1
  176. package/dist/sdk/schedule-tool-handler-KLHE2SOW.mjs.map +0 -1
  177. package/dist/sdk/schedule-tool-handler-NBEO46RV.mjs.map +0 -1
  178. package/dist/sdk/slack-frontend-BPWXNIHE.mjs +0 -929
  179. package/dist/sdk/slack-frontend-BPWXNIHE.mjs.map +0 -1
  180. package/dist/sdk/slack-frontend-DF5VL4OF.mjs.map +0 -1
  181. package/dist/sdk/task-evaluator-GQYDOSGT.mjs +0 -1392
  182. package/dist/sdk/task-evaluator-GQYDOSGT.mjs.map +0 -1
  183. package/dist/sdk/teams-frontend-DNW5GZP3.mjs.map +0 -1
  184. package/dist/sdk/telegram-frontend-GA7OLADB.mjs.map +0 -1
  185. package/dist/sdk/trace-helpers-26ZCAE2V.mjs.map +0 -1
  186. package/dist/sdk/trace-helpers-XV5GAX5L.mjs +0 -29
  187. package/dist/sdk/trace-helpers-XV5GAX5L.mjs.map +0 -1
  188. package/dist/sdk/trace-serializer-KKBJHM7J.mjs.map +0 -1
  189. package/dist/sdk/track-execution-3EC24C2X.mjs +0 -163
  190. package/dist/sdk/track-execution-3EC24C2X.mjs.map +0 -1
  191. package/dist/sdk/track-execution-66RLL6QT.mjs +0 -143
  192. package/dist/sdk/track-execution-66RLL6QT.mjs.map +0 -1
  193. package/dist/sdk/utcp-check-provider-JLIYF5HH.mjs +0 -16
  194. package/dist/sdk/utcp-check-provider-JLIYF5HH.mjs.map +0 -1
  195. package/dist/sdk/utcp-check-provider-WI3QZ3W6.mjs.map +0 -1
  196. package/dist/sdk/workflow-check-provider-X2UREEH7.mjs +0 -31
  197. package/dist/sdk/workflow-check-provider-X2UREEH7.mjs.map +0 -1
  198. package/dist/sdk/workflow-check-provider-YXALZNAQ.mjs +0 -31
  199. package/dist/sdk/workflow-check-provider-YXALZNAQ.mjs.map +0 -1
  200. package/dist/sdk/workflow-registry-X2IPY35M.mjs +0 -12
  201. package/dist/sdk/workflow-registry-X2IPY35M.mjs.map +0 -1
  202. package/dist/sdk/workflow-registry-YCZ3FCJC.mjs.map +0 -1
  203. /package/dist/sdk/{a2a-frontend-5YDHFQXD.mjs.map → a2a-frontend-OI4OVSKC.mjs.map} +0 -0
  204. /package/dist/sdk/{check-provider-registry-WSEVHJEV.mjs.map → check-provider-registry-RITJW67U.mjs.map} +0 -0
  205. /package/dist/sdk/{check-provider-registry-YRADEEQY.mjs.map → check-provider-registry-ZZ6N4GDP.mjs.map} +0 -0
  206. /package/dist/sdk/{chunk-4BN2XI4X.mjs.map → chunk-4HIWZA6M.mjs.map} +0 -0
  207. /package/dist/sdk/{chunk-RI4ONH5X.mjs.map → chunk-4MHHELVZ.mjs.map} +0 -0
  208. /package/dist/sdk/{chunk-54KOAC4W.mjs.map → chunk-4ZLYHSN4.mjs.map} +0 -0
  209. /package/dist/sdk/{chunk-GA2TYKSR.mjs.map → chunk-7XKHFRPN.mjs.map} +0 -0
  210. /package/dist/sdk/{chunk-XOAEKFKB.mjs.map → chunk-QLT42TX7.mjs.map} +0 -0
  211. /package/dist/sdk/{chunk-7XRSCOKE.mjs.map → chunk-TSX3YS3F.mjs.map} +0 -0
  212. /package/dist/sdk/{chunk-NPSLGKXB.mjs.map → chunk-UM7LGO2P.mjs.map} +0 -0
  213. /package/dist/sdk/{chunk-7VTZDC2X.mjs.map → chunk-VPPBOKBQ.mjs.map} +0 -0
  214. /package/dist/sdk/{chunk-RHKPFJLG.mjs.map → chunk-ZNKL6ESZ.mjs.map} +0 -0
  215. /package/dist/sdk/{command-executor-3AHGIYQG.mjs.map → command-executor-LHUW77GR.mjs.map} +0 -0
  216. /package/dist/sdk/{command-executor-YNJOS77A.mjs.map → config-TVU5RWR5.mjs.map} +0 -0
  217. /package/dist/sdk/{email-frontend-WSNADJPI.mjs.map → email-frontend-ECHQCFTR.mjs.map} +0 -0
  218. /package/dist/sdk/{config-JE4HKTWW.mjs.map → failure-condition-evaluator-USY3ISVA.mjs.map} +0 -0
  219. /package/dist/sdk/{github-auth-27SZGPEC.mjs.map → github-auth-UO4DMNCC.mjs.map} +0 -0
  220. /package/dist/sdk/{github-frontend-DECYOBRN.mjs.map → github-frontend-2T5PWYD5.mjs.map} +0 -0
  221. /package/dist/sdk/{host-CFM2ASDI.mjs.map → host-OJSMCLKK.mjs.map} +0 -0
  222. /package/dist/sdk/{host-T4LNVU2H.mjs.map → host-RM6UJEPP.mjs.map} +0 -0
  223. /package/dist/sdk/{knex-store-OEWSZEBY.mjs.map → knex-store-KCMFAMH5.mjs.map} +0 -0
  224. /package/dist/sdk/{config-PCP6O6Y6.mjs.map → liquid-extensions-KZIRR4OY.mjs.map} +0 -0
  225. /package/dist/sdk/{loader-WRGI244P.mjs.map → loader-35YWX5UQ.mjs.map} +0 -0
  226. /package/dist/sdk/{failure-condition-evaluator-H3PBFBYT.mjs.map → memory-store-3JONK7AF.mjs.map} +0 -0
  227. /package/dist/sdk/{opa-policy-engine-IVMCGVNA.mjs.map → opa-policy-engine-FY5D45YS.mjs.map} +0 -0
  228. /package/dist/sdk/{failure-condition-evaluator-IRFKTYZD.mjs.map → prompt-state-VVJMONT3.mjs.map} +0 -0
  229. /package/dist/sdk/{renderer-schema-BT2IXMLW.mjs.map → renderer-schema-JZRRU5CW.mjs.map} +0 -0
  230. /package/dist/sdk/{lazy-otel-5NH4ZJJM.mjs.map → routing-NNQQSLWA.mjs.map} +0 -0
  231. /package/dist/sdk/{liquid-extensions-E3AKRX7P.mjs.map → schedule-tool-ADZ2ON4I.mjs.map} +0 -0
  232. /package/dist/sdk/{liquid-extensions-P6KDYILF.mjs.map → schedule-tool-EMNF3FPQ.mjs.map} +0 -0
  233. /package/dist/sdk/{memory-store-K5N7MC7U.mjs.map → schedule-tool-handler-3R3IC6VA.mjs.map} +0 -0
  234. /package/dist/sdk/{memory-store-OHUIXCWJ.mjs.map → schedule-tool-handler-F76ZD2WU.mjs.map} +0 -0
  235. /package/dist/sdk/{task-evaluator-OVMG7S56.mjs.map → task-evaluator-H3BXC7SE.mjs.map} +0 -0
  236. /package/dist/sdk/{metrics-JTOG2HNO.mjs.map → trace-helpers-OMF4C24T.mjs.map} +0 -0
  237. /package/dist/sdk/{prompt-state-LN57DQF3.mjs.map → trace-serializer-EBHTHZYT.mjs.map} +0 -0
  238. /package/dist/sdk/{prompt-state-YPICX7PI.mjs.map → utcp-check-provider-Q4PD5EP2.mjs.map} +0 -0
  239. /package/dist/sdk/{routing-H2PQ57OA.mjs.map → workflow-check-provider-TC2G33WF.mjs.map} +0 -0
  240. /package/dist/sdk/{routing-JMZ7HDCC.mjs.map → workflow-check-provider-U4UXZ5YS.mjs.map} +0 -0
  241. /package/dist/sdk/{schedule-tool-2DPNSU63.mjs.map → workflow-registry-K56UTX36.mjs.map} +0 -0
@@ -1,1392 +0,0 @@
1
- import {
2
- init_logger,
3
- logger
4
- } from "./chunk-FT3I25QV.mjs";
5
- import "./chunk-UCMJJ3IM.mjs";
6
- import {
7
- __esm,
8
- __require
9
- } from "./chunk-J7LXIPZS.mjs";
10
-
11
- // src/agent-protocol/trace-serializer.ts
12
- import * as fs from "fs";
13
- import * as readline from "readline";
14
- import * as path from "path";
15
- function resolveBackendConfig(overrides) {
16
- const explicit = process.env.VISOR_TRACE_BACKEND;
17
- return {
18
- type: overrides?.type || explicit || "auto",
19
- grafanaUrl: overrides?.grafanaUrl || process.env.GRAFANA_URL,
20
- grafanaDatasourceId: overrides?.grafanaDatasourceId || process.env.GRAFANA_TEMPO_DATASOURCE_ID,
21
- jaegerUrl: overrides?.jaegerUrl || process.env.JAEGER_URL,
22
- traceDir: overrides?.traceDir || process.env.VISOR_TRACE_DIR || "output/traces",
23
- authToken: overrides?.authToken || process.env.GRAFANA_TOKEN
24
- };
25
- }
26
- function parseOTLPResponse(data) {
27
- const spans = [];
28
- if (data.batches) {
29
- for (const batch of data.batches) {
30
- for (const ss of batch.scopeSpans || []) {
31
- for (const s of ss.spans || []) {
32
- spans.push(normalizeOTLPSpan(s));
33
- }
34
- }
35
- }
36
- return spans;
37
- }
38
- if (data.data && Array.isArray(data.data)) {
39
- for (const trace of data.data) {
40
- for (const s of trace.spans || []) {
41
- spans.push(normalizeJaegerSpan(s, trace.traceID));
42
- }
43
- }
44
- return spans;
45
- }
46
- return spans;
47
- }
48
- function normalizeOTLPSpan(s) {
49
- const startNs = parseInt(s.startTimeUnixNano || "0", 10);
50
- const endNs = parseInt(s.endTimeUnixNano || "0", 10);
51
- const traceId = decodeOTLPId(s.traceId);
52
- const spanId = decodeOTLPId(s.spanId);
53
- const parentSpanId = s.parentSpanId ? decodeOTLPId(s.parentSpanId) : void 0;
54
- const attributes = {};
55
- for (const attr of s.attributes || []) {
56
- const val = attr.value;
57
- if (val.stringValue !== void 0) attributes[attr.key] = val.stringValue;
58
- else if (val.intValue !== void 0) attributes[attr.key] = parseInt(val.intValue, 10);
59
- else if (val.boolValue !== void 0) attributes[attr.key] = val.boolValue;
60
- else if (val.doubleValue !== void 0) attributes[attr.key] = val.doubleValue;
61
- }
62
- const events = [];
63
- for (const evt of s.events || []) {
64
- const evtAttrs = {};
65
- for (const a of evt.attributes || []) {
66
- const v = a.value;
67
- if (v.stringValue !== void 0) evtAttrs[a.key] = v.stringValue;
68
- else if (v.intValue !== void 0) evtAttrs[a.key] = parseInt(v.intValue, 10);
69
- }
70
- events.push({ name: evt.name, attributes: evtAttrs });
71
- }
72
- return {
73
- traceId,
74
- spanId,
75
- parentSpanId,
76
- name: s.name || "unknown",
77
- startTimeMs: startNs / 1e6,
78
- endTimeMs: endNs / 1e6,
79
- durationMs: (endNs - startNs) / 1e6,
80
- attributes,
81
- events,
82
- status: s.status?.code === 2 ? "error" : "ok"
83
- };
84
- }
85
- function normalizeJaegerSpan(s, traceId) {
86
- const attributes = {};
87
- for (const tag of s.tags || []) {
88
- attributes[tag.key] = tag.value;
89
- }
90
- const events = [];
91
- for (const log of s.logs || []) {
92
- const evtAttrs = {};
93
- for (const f of log.fields || []) evtAttrs[f.key] = f.value;
94
- events.push({ name: evtAttrs["event"] || "log", attributes: evtAttrs });
95
- }
96
- const startUs = s.startTime || 0;
97
- const durationUs = s.duration || 0;
98
- return {
99
- traceId,
100
- spanId: s.spanID,
101
- parentSpanId: s.references?.find((r) => r.refType === "CHILD_OF")?.spanID,
102
- name: s.operationName || "unknown",
103
- startTimeMs: startUs / 1e3,
104
- endTimeMs: (startUs + durationUs) / 1e3,
105
- durationMs: durationUs / 1e3,
106
- attributes,
107
- events,
108
- status: attributes["otel.status_code"] === "ERROR" || attributes["error"] === true ? "error" : "ok"
109
- };
110
- }
111
- function decodeOTLPId(id) {
112
- if (!id) return "";
113
- if (/^[0-9a-f]+$/i.test(id)) return id.toLowerCase();
114
- try {
115
- return Buffer.from(id, "base64").toString("hex");
116
- } catch {
117
- return id;
118
- }
119
- }
120
- function parseLocalNDJSONSpans(spans) {
121
- return spans.map((s) => {
122
- const startMs = timeValueToMs(s.startTime || [0, 0]);
123
- const endMs = timeValueToMs(s.endTime || s.startTime || [0, 0]);
124
- const events = (s.events || []).map((e) => ({
125
- name: e.name,
126
- attributes: e.attributes || {}
127
- }));
128
- return {
129
- traceId: s.traceId || "",
130
- spanId: s.spanId || "",
131
- parentSpanId: s.parentSpanId || void 0,
132
- name: s.name || "unknown",
133
- startTimeMs: startMs,
134
- endTimeMs: endMs,
135
- durationMs: endMs - startMs,
136
- attributes: s.attributes || {},
137
- events,
138
- status: s.status?.code === 2 ? "error" : "ok"
139
- };
140
- });
141
- }
142
- function timeValueToMs(tv) {
143
- return tv[0] * 1e3 + tv[1] / 1e6;
144
- }
145
- async function fetchTraceSpans(traceId, config) {
146
- const cfg = resolveBackendConfig(config);
147
- const tryGrafana = cfg.type === "grafana" || cfg.type === "auto";
148
- const tryJaeger = cfg.type === "jaeger" || cfg.type === "auto";
149
- const tryFile = cfg.type === "file" || cfg.type === "auto";
150
- if (tryGrafana) {
151
- const spans = await fetchFromGrafanaTempo(traceId, cfg);
152
- if (spans && spans.length > 0) return spans;
153
- }
154
- if (tryJaeger) {
155
- const spans = await fetchFromJaeger(traceId, cfg);
156
- if (spans && spans.length > 0) return spans;
157
- }
158
- if (tryFile) {
159
- const spans = await fetchFromLocalFiles(traceId, cfg);
160
- if (spans && spans.length > 0) return spans;
161
- }
162
- return [];
163
- }
164
- async function fetchFromGrafanaTempo(traceId, cfg) {
165
- let grafanaUrl = cfg.grafanaUrl;
166
- if (!grafanaUrl) {
167
- const otlpEndpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT;
168
- if (otlpEndpoint) {
169
- const url = new URL(otlpEndpoint);
170
- const host = url.hostname;
171
- for (const port of ["3000", "8001", "80"]) {
172
- try {
173
- const testUrl = `http://${host}:${port}/api/health`;
174
- const resp = await httpGet(testUrl, cfg.authToken, 2e3);
175
- if (resp && resp.includes('"database"')) {
176
- grafanaUrl = `http://${host}:${port}`;
177
- break;
178
- }
179
- } catch {
180
- }
181
- }
182
- }
183
- }
184
- if (!grafanaUrl) return null;
185
- try {
186
- let dsId = cfg.grafanaDatasourceId;
187
- if (!dsId) {
188
- const dsResp = await httpGet(`${grafanaUrl}/api/datasources`, cfg.authToken);
189
- if (dsResp) {
190
- const datasources = JSON.parse(dsResp);
191
- const tempo = datasources.find((d) => d.type === "tempo");
192
- if (tempo) dsId = tempo.id;
193
- }
194
- }
195
- if (!dsId) return null;
196
- const traceUrl = `${grafanaUrl}/api/datasources/proxy/${dsId}/api/traces/${traceId}`;
197
- const resp = await httpGet(traceUrl, cfg.authToken);
198
- if (!resp) return null;
199
- const data = JSON.parse(resp);
200
- return parseOTLPResponse(data);
201
- } catch (err) {
202
- logger.debug(`[TraceSerializer] Grafana Tempo fetch failed: ${err}`);
203
- return null;
204
- }
205
- }
206
- async function fetchFromJaeger(traceId, cfg) {
207
- let jaegerUrl = cfg.jaegerUrl;
208
- if (!jaegerUrl) {
209
- const otlpEndpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT;
210
- const host = otlpEndpoint ? new URL(otlpEndpoint).hostname : "localhost";
211
- for (const port of ["16686"]) {
212
- try {
213
- const testUrl = `http://${host}:${port}/api/services`;
214
- const resp = await httpGet(testUrl, void 0, 2e3);
215
- if (resp && resp.includes('"data"')) {
216
- jaegerUrl = `http://${host}:${port}`;
217
- break;
218
- }
219
- } catch {
220
- }
221
- }
222
- }
223
- if (!jaegerUrl) return null;
224
- try {
225
- const traceUrl = `${jaegerUrl}/api/traces/${traceId}`;
226
- const resp = await httpGet(traceUrl, cfg.authToken);
227
- if (!resp) return null;
228
- const data = JSON.parse(resp);
229
- return parseOTLPResponse(data);
230
- } catch (err) {
231
- logger.debug(`[TraceSerializer] Jaeger fetch failed: ${err}`);
232
- return null;
233
- }
234
- }
235
- async function fetchFromLocalFiles(traceId, cfg) {
236
- const traceFile = await findTraceFile(traceId, cfg.traceDir);
237
- if (!traceFile) return null;
238
- try {
239
- const { parseNDJSONTrace } = await import("./trace-reader-OVE4DL2D.mjs");
240
- const trace = await parseNDJSONTrace(traceFile);
241
- return parseLocalNDJSONSpans(trace.spans);
242
- } catch (err) {
243
- logger.debug(`[TraceSerializer] Local file parse failed: ${err}`);
244
- return null;
245
- }
246
- }
247
- async function httpGet(url, authToken, timeoutMs) {
248
- try {
249
- const controller = new AbortController();
250
- const timeout = setTimeout(() => controller.abort(), timeoutMs || 1e4);
251
- const headers = {};
252
- if (authToken) headers["Authorization"] = `Bearer ${authToken}`;
253
- const resp = await fetch(url, {
254
- signal: controller.signal,
255
- headers
256
- });
257
- clearTimeout(timeout);
258
- if (!resp.ok) return null;
259
- return await resp.text();
260
- } catch {
261
- return null;
262
- }
263
- }
264
- async function findTraceFile(traceId, traceDir) {
265
- const dir = traceDir || process.env.VISOR_TRACE_DIR || "output/traces";
266
- if (!fs.existsSync(dir)) return null;
267
- const files = fs.readdirSync(dir).filter((f) => f.endsWith(".ndjson"));
268
- for (const file of files) {
269
- const filePath = path.join(dir, file);
270
- try {
271
- const firstLine = await readFirstLine(filePath);
272
- if (!firstLine) continue;
273
- const parsed = JSON.parse(firstLine);
274
- if (parsed.traceId === traceId) return filePath;
275
- } catch {
276
- }
277
- }
278
- return null;
279
- }
280
- async function readFirstLine(filePath) {
281
- return new Promise((resolve, reject) => {
282
- const stream = fs.createReadStream(filePath, { encoding: "utf-8" });
283
- const rl = readline.createInterface({ input: stream, crlfDelay: Infinity });
284
- let resolved = false;
285
- rl.on("line", (line) => {
286
- if (!resolved) {
287
- resolved = true;
288
- rl.close();
289
- stream.destroy();
290
- resolve(line.trim() || null);
291
- }
292
- });
293
- rl.on("close", () => {
294
- if (!resolved) resolve(null);
295
- });
296
- rl.on("error", reject);
297
- });
298
- }
299
- function isNoiseSpan(span) {
300
- return NOISE_SPAN_NAMES.has(span.name);
301
- }
302
- function isWrapperSpan(span) {
303
- return WRAPPER_SPAN_NAMES.has(span.name);
304
- }
305
- function buildSpanTree(spans) {
306
- const filtered = spans.filter((s) => !isNoiseSpan(s));
307
- const nodeMap = /* @__PURE__ */ new Map();
308
- for (const span of filtered) {
309
- nodeMap.set(span.spanId, { span, children: [] });
310
- }
311
- let root;
312
- const orphans = [];
313
- for (const span of filtered) {
314
- const node = nodeMap.get(span.spanId);
315
- if (!span.parentSpanId) {
316
- root = node;
317
- } else {
318
- let parentId = span.parentSpanId;
319
- while (parentId && !nodeMap.has(parentId)) {
320
- const parentSpan = spans.find((s) => s.spanId === parentId);
321
- parentId = parentSpan?.parentSpanId;
322
- }
323
- if (parentId) {
324
- const parent = nodeMap.get(parentId);
325
- if (parent) parent.children.push(node);
326
- } else if (!root) {
327
- root = node;
328
- } else {
329
- orphans.push(node);
330
- }
331
- }
332
- }
333
- if (!root) {
334
- const sorted = [...nodeMap.values()].sort((a, b) => b.span.durationMs - a.span.durationMs);
335
- root = sorted[0] || { span: filtered[0], children: [] };
336
- }
337
- if (orphans.length > 0) {
338
- root.children.push(...orphans);
339
- }
340
- const sortChildren = (node) => {
341
- node.children.sort((a, b) => a.span.startTimeMs - b.span.startTimeMs);
342
- node.children.forEach(sortChildren);
343
- };
344
- sortChildren(root);
345
- const unwrap = (node) => {
346
- node.children = node.children.map(unwrap);
347
- const newChildren = [];
348
- for (const child of node.children) {
349
- if (isWrapperSpan(child.span)) {
350
- newChildren.push(...child.children);
351
- } else {
352
- newChildren.push(child);
353
- }
354
- }
355
- node.children = newChildren;
356
- return node;
357
- };
358
- unwrap(root);
359
- const removeDelegateEchos = (node) => {
360
- const hasDelegateChild = node.children.some((c) => c.span.name === "search.delegate");
361
- if (hasDelegateChild) {
362
- node.children = node.children.filter((c) => {
363
- if (c.span.name !== "probe.event.tool.result") return true;
364
- const toolName = c.span.attributes["tool.name"];
365
- return toolName !== "search";
366
- });
367
- }
368
- node.children.forEach(removeDelegateEchos);
369
- };
370
- removeDelegateEchos(root);
371
- return root;
372
- }
373
- function dedupeKey(text) {
374
- return text.replace(/\s+/g, " ").trim().slice(0, 100).toLowerCase();
375
- }
376
- function dedupeOrRegister(ctx, kind, text, spanName) {
377
- if (!text || text.length < 20) return null;
378
- const key = dedupeKey(text);
379
- if (!key) return null;
380
- const map = ctx[kind];
381
- const existing = map.get(key);
382
- if (existing && existing !== spanName) {
383
- return existing;
384
- }
385
- const otherMap = kind === "outputs" ? ctx.intents : ctx.outputs;
386
- const crossRef = otherMap.get(key);
387
- if (crossRef && crossRef !== spanName) {
388
- map.set(key, spanName);
389
- return crossRef;
390
- }
391
- map.set(key, spanName);
392
- return null;
393
- }
394
- async function serializeTraceForPrompt(traceIdOrPath, maxChars, backendConfig, taskResponse, fallbackTraceId) {
395
- let spans = [];
396
- const isFilePath = traceIdOrPath.includes("/") || traceIdOrPath.endsWith(".ndjson");
397
- const remoteTraceId = fallbackTraceId || (!isFilePath ? traceIdOrPath : void 0);
398
- if (remoteTraceId) {
399
- spans = await fetchTraceSpans(remoteTraceId, backendConfig);
400
- }
401
- if (spans.length === 0 && isFilePath) {
402
- try {
403
- const { parseNDJSONTrace } = await import("./trace-reader-OVE4DL2D.mjs");
404
- const trace = await parseNDJSONTrace(traceIdOrPath);
405
- spans = parseLocalNDJSONSpans(trace.spans);
406
- } catch {
407
- }
408
- }
409
- if (spans.length === 0 && !remoteTraceId && !isFilePath) {
410
- spans = await fetchTraceSpans(traceIdOrPath, backendConfig);
411
- }
412
- if (spans.length === 0) {
413
- return "(no trace data available)";
414
- }
415
- const tree = buildSpanTree(spans);
416
- const routeIntentTopic = extractRouteIntentTopic(spans);
417
- const fullOutput = (maxChars ?? 4e3) > 1e5;
418
- return renderSpanYaml(tree, spans, {
419
- maxChars: maxChars ?? 4e3,
420
- fallbackIntent: routeIntentTopic,
421
- fullOutput,
422
- taskResponse
423
- });
424
- }
425
- function renderSpanYaml(tree, allSpans, opts) {
426
- const fullOutput = opts?.fullOutput ?? false;
427
- const maxLen = fullOutput ? 1e5 : 120;
428
- const dedup = { outputs: /* @__PURE__ */ new Map(), intents: /* @__PURE__ */ new Map() };
429
- const lines = [];
430
- renderYamlNode(tree, 0, lines, dedup, opts?.fallbackIntent, fullOutput, maxLen);
431
- if (opts?.taskResponse) {
432
- while (lines.length > 0 && /^\s*output:\s*=\s*\S+/.test(lines[lines.length - 1])) {
433
- lines.pop();
434
- }
435
- const ml = fullOutput ? 1e5 : 500;
436
- const text = opts.taskResponse.replace(/\*\*/g, "").replace(/`/g, "").trim();
437
- if (fullOutput) {
438
- lines.push(" response: |");
439
- for (const line of text.split("\n")) {
440
- lines.push(` ${line}`);
441
- }
442
- } else {
443
- const truncated = truncate(text.replace(/\n/g, " "), ml);
444
- lines.push(` response: ${truncated}`);
445
- if (text.length > ml) {
446
- lines.push(" # use --full for complete response");
447
- }
448
- }
449
- }
450
- return lines.join("\n");
451
- }
452
- function renderYamlNode(node, indent, lines, dedup, fallbackIntent, fullOutput, maxLen, parentSpan) {
453
- const pad = " ".repeat(indent);
454
- const attrs = node.span.attributes;
455
- const duration = formatDurationMs(node.span.durationMs);
456
- const name = node.span.name;
457
- const ml = maxLen ?? 120;
458
- const parentCheckId = parentSpan?.attributes["visor.check.id"];
459
- const parentCheckName = parentCheckId ? String(parentCheckId).replace(/^visor\.check\./, "") : void 0;
460
- const displayName = name === "ai.request" && parentCheckName ? parentCheckName : String(attrs["visor.check.id"] || name).replace(/^visor\.check\./, "");
461
- const toolName = attrs["tool.name"] || attrs["visor.tool.name"];
462
- if (toolName) {
463
- const toolInput = extractToolInput(String(toolName), attrs);
464
- const toolResultLen = attrs["tool.result.length"] || attrs["tool.result.count"];
465
- const tn = String(toolName);
466
- const isSearchTool = tn === "search" || tn === "searchCode" || tn === "search_code";
467
- const numLen = toolResultLen ? Number(toolResultLen) : -1;
468
- const noResults = isSearchTool && numLen >= 0 && numLen < 500;
469
- const resultSize = noResults ? " \u2192 no results" : toolResultLen ? ` \u2192 ${formatSize(numLen)}` : "";
470
- const successMark = attrs["tool.success"] === false ? " \u2717" : "";
471
- lines.push(`${pad}- ${tn}(${toolInput})${resultSize}${successMark}`);
472
- return;
473
- }
474
- if (name === "search.delegate.dedup") {
475
- const query = attrs["dedup.query"] || "";
476
- const action = attrs["dedup.action"] || "?";
477
- const reason = attrs["dedup.reason"] || "";
478
- const rewritten = attrs["dedup.rewritten"] || "";
479
- const prevCount = attrs["dedup.previous_count"] || "0";
480
- let detail = `${action}`;
481
- if (rewritten) detail += ` \u2192 "${truncate(String(rewritten), 60)}"`;
482
- if (reason) detail += ` (${truncate(String(reason), 80)})`;
483
- lines.push(
484
- `${pad}dedup("${truncate(String(query), 60)}") [${prevCount} prior]: ${detail} \u2014 ${duration}`
485
- );
486
- return;
487
- }
488
- if (name === "search.delegate") {
489
- const query = attrs["search.query"] || "";
490
- const rewritten = attrs["search.query.rewritten"] || "";
491
- const output = attrs["search.delegate.output"] || "";
492
- const outputLen = attrs["search.delegate.output_length"] || "";
493
- let header = `search.delegate("${truncate(String(query), 80)}")`;
494
- if (rewritten) header += ` \u2192 rewritten: "${truncate(String(rewritten), 60)}"`;
495
- header += ` \u2014 ${duration}`;
496
- lines.push(`${pad}${header}:`);
497
- if (output) {
498
- try {
499
- const parsed = JSON.parse(String(output));
500
- if (parsed.confidence) {
501
- let confLine = `confidence: ${parsed.confidence}`;
502
- if (parsed.reason) confLine += ` \u2014 ${truncate(String(parsed.reason), 100)}`;
503
- lines.push(`${pad} ${confLine}`);
504
- }
505
- if (parsed.searches && Array.isArray(parsed.searches) && parsed.searches.length > 0) {
506
- lines.push(`${pad} searches (${parsed.searches.length}):`);
507
- for (const s of parsed.searches) {
508
- const outcome = s.had_results ? "\u2713" : "\u2717";
509
- lines.push(
510
- `${pad} ${outcome} "${truncate(String(s.query || ""), 60)}" in ${truncate(String(s.path || "."), 40)}`
511
- );
512
- }
513
- }
514
- if (parsed.groups && Array.isArray(parsed.groups) && parsed.groups.length > 0) {
515
- lines.push(`${pad} groups (${parsed.groups.length}):`);
516
- for (const g of parsed.groups) {
517
- const fileCount = g.files?.length || 0;
518
- lines.push(`${pad} - ${truncate(String(g.reason || ""), 80)} (${fileCount} files)`);
519
- }
520
- }
521
- } catch {
522
- if (outputLen) lines.push(`${pad} output: ${outputLen} chars`);
523
- }
524
- }
525
- for (const child of node.children) {
526
- renderYamlNode(
527
- child,
528
- indent + 1,
529
- lines,
530
- dedup,
531
- fallbackIntent,
532
- fullOutput,
533
- maxLen,
534
- node.span
535
- );
536
- }
537
- return;
538
- }
539
- if (name === "ai.request") {
540
- const model = attrs["ai.model"] || attrs["gen_ai.request.model"] || "?";
541
- const tokensIn = attrs["ai.input_length"] || attrs["gen_ai.usage.input_tokens"] || "";
542
- const tokensOut = attrs["gen_ai.usage.output_tokens"] || "";
543
- const tokenParts = [];
544
- if (tokensIn) tokenParts.push(`${tokensIn} in`);
545
- if (tokensOut) tokenParts.push(`${tokensOut} out`);
546
- const tokenStr = tokenParts.length > 0 ? ` \u2014 ${tokenParts.join(", ")}` : "";
547
- const hasChildren2 = node.children.length > 0;
548
- lines.push(`${pad}ai: ${model} \u2014 ${duration}${tokenStr}${hasChildren2 ? ":" : ""}`);
549
- const aiInput = String(attrs["ai.input"] || "");
550
- let intent = extractAIIntent(aiInput, ml);
551
- if (!intent && parentSpan) {
552
- const promptPreview = String(
553
- parentSpan.attributes["visor.provider.request.prompt.preview"] || ""
554
- );
555
- if (promptPreview) intent = extractAIIntent(promptPreview, ml);
556
- if (!intent) {
557
- const inputOutputs = String(parentSpan.attributes["visor.check.input.outputs"] || "");
558
- if (inputOutputs) {
559
- try {
560
- const o = JSON.parse(inputOutputs);
561
- const t = o["route-intent"]?.topic;
562
- if (t) intent = truncate(String(t), ml);
563
- } catch {
564
- }
565
- }
566
- }
567
- }
568
- if (!intent && fallbackIntent && parentSpan?.name !== "search.delegate") {
569
- intent = fallbackIntent;
570
- }
571
- if (intent) {
572
- const intentRef = dedupeOrRegister(dedup, "intents", intent, displayName);
573
- if (intentRef) {
574
- lines.push(`${pad} intent: = ${intentRef}`);
575
- } else {
576
- lines.push(`${pad} intent: ${intent}`);
577
- }
578
- }
579
- for (const child of node.children) {
580
- renderYamlNode(
581
- child,
582
- indent + 1,
583
- lines,
584
- dedup,
585
- fallbackIntent,
586
- fullOutput,
587
- maxLen,
588
- node.span
589
- );
590
- }
591
- if (parentSpan) {
592
- const checkOutput = String(parentSpan.attributes["visor.check.output"] || "");
593
- if (checkOutput) {
594
- renderYamlOutput(
595
- checkOutput,
596
- `${pad} `,
597
- "output",
598
- displayName,
599
- dedup,
600
- lines,
601
- fullOutput,
602
- ml
603
- );
604
- }
605
- }
606
- return;
607
- }
608
- if (name === "visor.run") {
609
- const source = attrs["visor.run.source"] || "";
610
- const visorVersion = attrs["visor.version"] || "";
611
- const probeVersion = attrs["probe.version"] || "";
612
- const slackUser = attrs["slack.user_id"] || "";
613
- lines.push(`${pad}visor.run:`);
614
- lines.push(`${pad} trace_id: ${node.span.traceId}`);
615
- if (visorVersion) lines.push(`${pad} visor: ${visorVersion}`);
616
- if (probeVersion) lines.push(`${pad} probe: ${probeVersion}`);
617
- if (source) lines.push(`${pad} source: ${source}`);
618
- if (slackUser) lines.push(`${pad} slack_user: ${slackUser}`);
619
- lines.push(`${pad} duration: ${duration}`);
620
- for (const child of node.children) {
621
- renderYamlNode(
622
- child,
623
- indent + 1,
624
- lines,
625
- dedup,
626
- fallbackIntent,
627
- fullOutput,
628
- maxLen,
629
- node.span
630
- );
631
- }
632
- return;
633
- }
634
- const checkId = attrs["visor.check.id"];
635
- const checkType = attrs["visor.check.type"];
636
- if (checkId || name.startsWith("visor.check.")) {
637
- const cleanName = String(checkId || name).replace(/^visor\.check\./, "");
638
- const errMark2 = node.span.status === "error" ? " \u2717" : "";
639
- lines.push(`${pad}${cleanName}:${errMark2}`);
640
- if (checkType) lines.push(`${pad} type: ${checkType}`);
641
- lines.push(`${pad} duration: ${duration}`);
642
- const inputContext = String(attrs["visor.check.input.context"] || "");
643
- const inputOutputs = String(attrs["visor.check.input.outputs"] || "");
644
- const question = extractQuestionFromContext(inputContext, inputOutputs);
645
- if (question || inputOutputs && inputOutputs !== "{}") {
646
- renderYamlInput(inputOutputs, `${pad} `, lines, fullOutput, ml, question);
647
- }
648
- for (const child of node.children) {
649
- renderYamlNode(
650
- child,
651
- indent + 1,
652
- lines,
653
- dedup,
654
- fallbackIntent,
655
- fullOutput,
656
- maxLen,
657
- node.span
658
- );
659
- }
660
- const hasDirectAiChild = node.children.some((c) => c.span.name === "ai.request");
661
- if (!hasDirectAiChild) {
662
- const output = String(attrs["visor.check.output"] || "");
663
- if (output) {
664
- renderYamlOutput(output, `${pad} `, "output", cleanName, dedup, lines, fullOutput, ml);
665
- }
666
- }
667
- return;
668
- }
669
- const errMark = node.span.status === "error" ? " \u2717" : "";
670
- const hasChildren = node.children.length > 0;
671
- lines.push(`${pad}${name} \u2014 ${duration}${errMark}${hasChildren ? ":" : ""}`);
672
- for (const child of node.children) {
673
- renderYamlNode(child, indent + 1, lines, dedup, fallbackIntent, fullOutput, maxLen, node.span);
674
- }
675
- }
676
- function renderYamlOutput(rawOutput, pad, label, spanName, dedup, lines, fullOutput, maxLen) {
677
- const ml = maxLen ?? 120;
678
- let obj;
679
- try {
680
- obj = JSON.parse(rawOutput);
681
- } catch {
682
- obj = parseTruncatedJson(rawOutput);
683
- }
684
- if (obj === null || obj === void 0 || typeof obj !== "object") return;
685
- if (typeof obj === "object" && !Array.isArray(obj)) {
686
- const keys = Object.keys(obj);
687
- if (keys.length === 1 && typeof obj[keys[0]] === "object" && obj[keys[0]] !== null) {
688
- obj = obj[keys[0]];
689
- }
690
- const objKeys = Object.keys(obj);
691
- if (objKeys.length === 1 && objKeys[0] === "text" && typeof obj.text === "string") {
692
- const text = obj.text.replace(/\*\*/g, "").replace(/`/g, "").trim();
693
- const flat = text.replace(/\n/g, " ");
694
- const preview2 = fullOutput ? flat : truncate(flat, ml);
695
- const ref2 = dedupeOrRegister(dedup, "outputs", truncate(flat, 100), spanName);
696
- if (ref2) {
697
- lines.push(`${pad}${label}: = ${ref2}`);
698
- } else {
699
- lines.push(`${pad}${label}: ${preview2}`);
700
- }
701
- return;
702
- }
703
- }
704
- const preview = formatJsonPreview(obj, 200);
705
- if (!preview) return;
706
- const ref = dedupeOrRegister(dedup, "outputs", preview, spanName);
707
- if (ref) {
708
- lines.push(`${pad}${label}: = ${ref}`);
709
- return;
710
- }
711
- renderYamlValue(obj, pad, label, lines, fullOutput, ml);
712
- }
713
- function renderYamlValue(val, pad, key, lines, fullOutput, maxLen, depth) {
714
- const ml = maxLen ?? 120;
715
- const d = depth ?? 0;
716
- if (val === null || val === void 0) return;
717
- if (typeof val === "boolean" || typeof val === "number") {
718
- lines.push(`${pad}${key}: ${val}`);
719
- return;
720
- }
721
- if (typeof val === "string") {
722
- if (val.startsWith("{") || val.startsWith("[")) return;
723
- const clean = val.replace(/\*\*/g, "").replace(/`/g, "").trim();
724
- if (fullOutput && clean.length > 100 && clean.includes("\n")) {
725
- lines.push(`${pad}${key}: |`);
726
- for (const line of clean.split("\n").slice(0, fullOutput ? 500 : 5)) {
727
- lines.push(`${pad} ${line}`);
728
- }
729
- } else {
730
- const flat = clean.replace(/\n/g, " ");
731
- const truncVal = fullOutput ? flat : truncate(flat, ml);
732
- lines.push(`${pad}${key}: ${truncVal}`);
733
- }
734
- return;
735
- }
736
- if (Array.isArray(val)) {
737
- if (val.length === 0) {
738
- lines.push(`${pad}${key}: []`);
739
- return;
740
- }
741
- if (val.every((v) => typeof v === "string") && val.join(", ").length < ml) {
742
- lines.push(`${pad}${key}: [${val.join(", ")}]`);
743
- return;
744
- }
745
- const maxItems = fullOutput ? 20 : 3;
746
- lines.push(`${pad}${key}:`);
747
- for (let i = 0; i < Math.min(val.length, maxItems); i++) {
748
- const item = val[i];
749
- if (typeof item === "object" && item !== null) {
750
- const entries = Object.entries(item).filter(([k]) => k !== "raw" && k !== "tags");
751
- if (entries.length > 0) {
752
- const [firstKey, firstVal] = entries[0];
753
- if (firstVal === null || firstVal === void 0 || typeof firstVal !== "object") {
754
- const sv = typeof firstVal === "string" ? fullOutput ? firstVal.split("\n")[0] : truncate(firstVal.split("\n")[0], ml) : String(firstVal ?? "");
755
- lines.push(`${pad} - ${firstKey}: ${sv}`);
756
- } else {
757
- lines.push(`${pad} - ${firstKey}:`);
758
- for (const [ck, cv] of Object.entries(firstVal)) {
759
- if (ck === "raw" || ck === "skills" || ck === "tags") continue;
760
- renderYamlValue(cv, `${pad} `, ck, lines, fullOutput, ml, d + 2);
761
- }
762
- }
763
- for (let j = 1; j < entries.length; j++) {
764
- const [k, v] = entries[j];
765
- renderYamlValue(v, `${pad} `, k, lines, fullOutput, ml, d + 1);
766
- }
767
- }
768
- } else {
769
- lines.push(`${pad} - ${truncate(String(item), ml)}`);
770
- }
771
- }
772
- if (val.length > maxItems) {
773
- lines.push(`${pad} # ... ${val.length - maxItems} more`);
774
- }
775
- return;
776
- }
777
- if (typeof val === "object") {
778
- if (d > 3) {
779
- const keys = Object.keys(val);
780
- lines.push(`${pad}${key}: {${keys.slice(0, 4).join(", ")}${keys.length > 4 ? ", ..." : ""}}`);
781
- return;
782
- }
783
- lines.push(`${pad}${key}:`);
784
- for (const [k, v] of Object.entries(val)) {
785
- if (k === "raw" || k === "tags") continue;
786
- renderYamlValue(v, `${pad} `, k, lines, fullOutput, ml, d + 1);
787
- }
788
- }
789
- }
790
- function extractQuestionFromContext(contextStr, inputOutputsStr) {
791
- if (!contextStr) return void 0;
792
- try {
793
- const ctx = JSON.parse(contextStr);
794
- const outputs = ctx.outputs || {};
795
- const routeIntent = outputs["route-intent"];
796
- if (routeIntent) {
797
- const topic = routeIntent.topic || routeIntent.intent || routeIntent.question;
798
- if (topic && typeof topic === "string") return topic;
799
- if (typeof routeIntent === "string") return routeIntent;
800
- }
801
- const args = ctx.args || {};
802
- if (args.topic && typeof args.topic === "string") return args.topic;
803
- if (args.question && typeof args.question === "string") return args.question;
804
- if (args.intent && typeof args.intent === "string") return args.intent;
805
- for (const key of Object.keys(outputs)) {
806
- const val = outputs[key];
807
- if (typeof val === "object" && val !== null) {
808
- if (val.topic && typeof val.topic === "string") {
809
- try {
810
- const depOutputs = JSON.parse(inputOutputsStr);
811
- if (depOutputs[key]) continue;
812
- } catch {
813
- }
814
- return val.topic;
815
- }
816
- }
817
- }
818
- } catch {
819
- const topicMatch = contextStr.match(/"topic"\s*:\s*"([^"]+)"/);
820
- if (topicMatch) return topicMatch[1];
821
- }
822
- return void 0;
823
- }
824
- function renderYamlInput(inputOutputsStr, pad, lines, fullOutput, maxLen, question) {
825
- const ml = maxLen ?? 120;
826
- if (question) {
827
- lines.push(`${pad}input: ${truncate(question, fullOutput ? 1e5 : ml)}`);
828
- }
829
- try {
830
- const inputs = JSON.parse(inputOutputsStr);
831
- if (typeof inputs !== "object" || inputs === null) return;
832
- const keys = Object.keys(inputs);
833
- if (keys.length === 0) return;
834
- if (!question) lines.push(`${pad}input:`);
835
- for (const key of keys) {
836
- const val = inputs[key];
837
- if (typeof val === "object" && val !== null) {
838
- renderYamlValue(val, `${pad} `, key, lines, fullOutput, ml, 0);
839
- } else {
840
- lines.push(`${pad} ${key}: ${truncate(String(val), ml)}`);
841
- }
842
- }
843
- } catch {
844
- }
845
- }
846
- function parseWorkspacePath(fullPath) {
847
- const wsMatch = fullPath.match(/\/visor-workspaces\/[^/]+\/([^/]+)(?:\/(.+))?/);
848
- if (wsMatch) {
849
- return { repo: wsMatch[1], filePath: wsMatch[2] };
850
- }
851
- const wtMatch = fullPath.match(/\.visor\/worktrees\/worktrees\/[^/]+\/(.+)/);
852
- if (wtMatch) {
853
- const segs = wtMatch[1].split("/");
854
- return { repo: segs[0], filePath: segs.length > 1 ? segs.slice(1).join("/") : void 0 };
855
- }
856
- return null;
857
- }
858
- function extractToolInput(toolName, attrs) {
859
- const result = String(attrs["tool.result"] || "");
860
- const explicitInput = String(attrs["tool.input"] || "");
861
- if (explicitInput) return truncate(explicitInput, 80);
862
- switch (toolName) {
863
- case "search": {
864
- const patMatch = result.match(/Pattern: (.+)/);
865
- const pathMatch = result.match(/Path: (\S+)/);
866
- const pattern = patMatch ? patMatch[1].trim() : "";
867
- const workspace = pathMatch ? parseWorkspacePath(pathMatch[1]) : null;
868
- const parts = [];
869
- if (pattern) parts.push(`"${truncate(pattern, 50)}"`);
870
- if (workspace?.repo) parts.push(workspace.repo);
871
- return parts.join(", ");
872
- }
873
- case "extract": {
874
- const fileMatch = result.match(/Files to extract:\n\s*(\S+)/);
875
- if (fileMatch) {
876
- const fullPath = fileMatch[1];
877
- const workspace = parseWorkspacePath(fullPath);
878
- if (workspace) {
879
- const parts = [];
880
- parts.push(workspace.filePath || workspace.repo || fullPath.split("/").pop() || "");
881
- if (workspace.repo) parts.push(workspace.repo);
882
- return parts.join(", ");
883
- }
884
- const segs = fullPath.split("/");
885
- return segs.length > 2 ? segs.slice(-2).join("/") : segs[segs.length - 1];
886
- }
887
- return "";
888
- }
889
- case "bash": {
890
- const cmdMatch = result.match(/^Command: (.+)/);
891
- if (cmdMatch) {
892
- let cmd = cmdMatch[1].trim();
893
- const pipes = cmd.split(/\s*\|\s*/);
894
- if (pipes.length > 2) {
895
- cmd = `${pipes[0]} | ... (${pipes.length} stages)`;
896
- }
897
- return truncate(cmd, 80);
898
- }
899
- const deniedMatch = result.match(/^Permission denied: Component "([^"]+)"/);
900
- if (deniedMatch) {
901
- return truncate(deniedMatch[1], 60) + " [denied]";
902
- }
903
- return "";
904
- }
905
- case "listFiles": {
906
- const pathMatch = result.match(/^(\S+):/);
907
- if (pathMatch) {
908
- const parts = pathMatch[1].split("/");
909
- return parts[parts.length - 1] || "";
910
- }
911
- return "";
912
- }
913
- default:
914
- return truncate(explicitInput, 60);
915
- }
916
- }
917
- function extractAIIntent(input, maxLen = 150) {
918
- if (!input || input.length < 20) return "";
919
- const qMatch = input.match(/<question>([\s\S]*?)<\/question>/);
920
- if (qMatch) return truncate(qMatch[1].trim(), maxLen);
921
- const crMatch = input.match(/## Current Request\s*\n(?:User: )?(.+)/);
922
- if (crMatch) return truncate(crMatch[1].trim(), maxLen);
923
- const userMatch = input.match(/(?:^|\n)User: (.+)/);
924
- if (userMatch) return truncate(userMatch[1].trim(), maxLen);
925
- const pmMatch = input.match(/Primary message[^:]*:\s*\n(.+)/);
926
- if (pmMatch) return truncate(pmMatch[1].trim(), maxLen);
927
- return "";
928
- }
929
- function formatJsonPreview(obj, maxLen) {
930
- if (obj === null || obj === void 0) return "";
931
- if (typeof obj !== "object") return truncate(String(obj), maxLen);
932
- if (Array.isArray(obj)) {
933
- if (obj.length === 0) return "[]";
934
- const first = typeof obj[0] === "object" && obj[0] !== null ? obj[0].project_id || obj[0].id || obj[0].name || Object.keys(obj[0])[0] || "..." : String(obj[0]);
935
- return `[${obj.length}] ${truncate(String(first), 30)}${obj.length > 1 ? ", ..." : ""}`;
936
- }
937
- const parts = [];
938
- let len = 2;
939
- for (const [key, val] of Object.entries(obj)) {
940
- if (key === "raw" || key === "skills" || key === "tags") continue;
941
- let valStr;
942
- if (val === null || val === void 0) continue;
943
- if (typeof val === "boolean") valStr = String(val);
944
- else if (typeof val === "number") valStr = String(val);
945
- else if (typeof val === "string") {
946
- if (val.startsWith("{") || val.startsWith("[")) continue;
947
- const clean = val.replace(/\*\*/g, "").replace(/^#+\s*/gm, "").replace(/`/g, "").trim();
948
- valStr = `"${truncate(clean.split("\n")[0], Math.min(80, maxLen / 3))}"`;
949
- } else if (Array.isArray(val)) valStr = `[${val.length}]`;
950
- else if (typeof val === "object") valStr = `{${Object.keys(val).length} keys}`;
951
- else valStr = "...";
952
- const part = `${key}: ${valStr}`;
953
- if (len + part.length + 2 > maxLen) {
954
- parts.push("...");
955
- break;
956
- }
957
- parts.push(part);
958
- len += part.length + 2;
959
- }
960
- return `{${parts.join(", ")}}`;
961
- }
962
- function parseTruncatedJson(input) {
963
- let pos = 0;
964
- const len = input.length;
965
- function skipWhitespace() {
966
- while (pos < len && " \n\r".includes(input[pos])) pos++;
967
- }
968
- function parseString() {
969
- if (input[pos] !== '"') return "";
970
- pos++;
971
- let result = "";
972
- while (pos < len) {
973
- const ch = input[pos];
974
- if (ch === "\\" && pos + 1 < len) {
975
- const next = input[pos + 1];
976
- if (next === "n") {
977
- result += "\n";
978
- pos += 2;
979
- continue;
980
- }
981
- if (next === "t") {
982
- result += " ";
983
- pos += 2;
984
- continue;
985
- }
986
- if (next === '"') {
987
- result += '"';
988
- pos += 2;
989
- continue;
990
- }
991
- if (next === "\\") {
992
- result += "\\";
993
- pos += 2;
994
- continue;
995
- }
996
- result += next;
997
- pos += 2;
998
- continue;
999
- }
1000
- if (ch === '"') {
1001
- pos++;
1002
- return result;
1003
- }
1004
- result += ch;
1005
- pos++;
1006
- }
1007
- return result;
1008
- }
1009
- function parseNumber() {
1010
- const start = pos;
1011
- if (input[pos] === "-") pos++;
1012
- while (pos < len && input[pos] >= "0" && input[pos] <= "9") pos++;
1013
- if (pos < len && input[pos] === ".") {
1014
- pos++;
1015
- while (pos < len && input[pos] >= "0" && input[pos] <= "9") pos++;
1016
- }
1017
- return Number(input.slice(start, pos));
1018
- }
1019
- function parseValue() {
1020
- skipWhitespace();
1021
- if (pos >= len) return void 0;
1022
- const ch = input[pos];
1023
- if (ch === '"') return parseString();
1024
- if (ch === "{") return parseObject();
1025
- if (ch === "[") return parseArray();
1026
- if (ch === "t" && input.slice(pos, pos + 4) === "true") {
1027
- pos += 4;
1028
- return true;
1029
- }
1030
- if (ch === "f" && input.slice(pos, pos + 5) === "false") {
1031
- pos += 5;
1032
- return false;
1033
- }
1034
- if (ch === "n" && input.slice(pos, pos + 4) === "null") {
1035
- pos += 4;
1036
- return null;
1037
- }
1038
- if (ch === "-" || ch >= "0" && ch <= "9") return parseNumber();
1039
- return void 0;
1040
- }
1041
- function parseObject() {
1042
- const obj = {};
1043
- pos++;
1044
- skipWhitespace();
1045
- while (pos < len && input[pos] !== "}") {
1046
- skipWhitespace();
1047
- if (pos >= len || input[pos] !== '"') break;
1048
- const key = parseString();
1049
- skipWhitespace();
1050
- if (pos >= len || input[pos] !== ":") {
1051
- obj[key] = void 0;
1052
- break;
1053
- }
1054
- pos++;
1055
- const val = parseValue();
1056
- if (val !== void 0) obj[key] = val;
1057
- skipWhitespace();
1058
- if (pos < len && input[pos] === ",") pos++;
1059
- }
1060
- if (pos < len && input[pos] === "}") pos++;
1061
- return obj;
1062
- }
1063
- function parseArray() {
1064
- const arr = [];
1065
- pos++;
1066
- skipWhitespace();
1067
- while (pos < len && input[pos] !== "]") {
1068
- const val = parseValue();
1069
- if (val !== void 0) arr.push(val);
1070
- else break;
1071
- skipWhitespace();
1072
- if (pos < len && input[pos] === ",") pos++;
1073
- skipWhitespace();
1074
- }
1075
- if (pos < len && input[pos] === "]") pos++;
1076
- return arr;
1077
- }
1078
- return parseValue();
1079
- }
1080
- function extractRouteIntentTopic(spans) {
1081
- const riSpan = spans.find((s) => s.attributes["visor.check.id"] === "route-intent");
1082
- if (riSpan) {
1083
- const output = String(riSpan.attributes["visor.check.output"] || "");
1084
- if (output) {
1085
- try {
1086
- const obj = JSON.parse(output);
1087
- if (obj.topic) return truncate(String(obj.topic), 150);
1088
- } catch {
1089
- }
1090
- }
1091
- }
1092
- const classifySpan = spans.find((s) => s.attributes["visor.check.id"] === "classify");
1093
- if (classifySpan) {
1094
- const output = String(classifySpan.attributes["visor.check.output"] || "");
1095
- if (output) {
1096
- try {
1097
- const obj = JSON.parse(output);
1098
- if (obj.topic) return truncate(String(obj.topic), 150);
1099
- } catch {
1100
- }
1101
- }
1102
- }
1103
- return void 0;
1104
- }
1105
- function formatSize(chars) {
1106
- if (chars < 1e3) return `${chars} chars`;
1107
- return `${(chars / 1e3).toFixed(1)}k chars`;
1108
- }
1109
- function formatDurationMs(ms) {
1110
- if (ms < 0) return "0ms";
1111
- if (ms < 1e3) return `${Math.round(ms)}ms`;
1112
- if (ms < 6e4) return `${(ms / 1e3).toFixed(1)}s`;
1113
- const mins = Math.floor(ms / 6e4);
1114
- const secs = Math.round(ms % 6e4 / 1e3);
1115
- return `${mins}m ${secs}s`;
1116
- }
1117
- function truncate(str, max) {
1118
- if (typeof str !== "string") return "";
1119
- if (str.length <= max) return str;
1120
- const tail = Math.min(100, Math.floor(max / 3));
1121
- const head = max - tail - 19;
1122
- if (head < 10) return str.slice(0, max - 3) + "...";
1123
- return str.slice(0, head) + " ...[truncated]... " + str.slice(-tail);
1124
- }
1125
- var NOISE_SPAN_NAMES, WRAPPER_SPAN_NAMES;
1126
- var init_trace_serializer = __esm({
1127
- "src/agent-protocol/trace-serializer.ts"() {
1128
- "use strict";
1129
- init_logger();
1130
- NOISE_SPAN_NAMES = /* @__PURE__ */ new Set([
1131
- "engine.state.init",
1132
- "engine.state.waveplanning",
1133
- "engine.state.planready",
1134
- "visor.sandbox.stopAll"
1135
- ]);
1136
- WRAPPER_SPAN_NAMES = /* @__PURE__ */ new Set([
1137
- "engine.state.leveldispatch",
1138
- "visor.ai_check",
1139
- "probe.delegation"
1140
- ]);
1141
- }
1142
- });
1143
-
1144
- // src/agent-protocol/task-evaluator.ts
1145
- import crypto from "crypto";
1146
- function buildEvaluationSchema(includeExecution) {
1147
- const schema = {
1148
- type: "object",
1149
- required: ["response_quality", "overall_rating", "summary"],
1150
- properties: {
1151
- response_quality: {
1152
- type: "object",
1153
- required: ["rating", "category", "relevance", "completeness", "actionable", "reasoning"],
1154
- properties: {
1155
- rating: { type: "integer", minimum: 1, maximum: 5 },
1156
- category: {
1157
- type: "string",
1158
- enum: ["excellent", "good", "adequate", "poor", "off-topic", "error"]
1159
- },
1160
- relevance: { type: "boolean" },
1161
- completeness: { type: "boolean" },
1162
- actionable: { type: "boolean" },
1163
- reasoning: { type: "string" }
1164
- }
1165
- },
1166
- overall_rating: { type: "integer", minimum: 1, maximum: 5 },
1167
- summary: { type: "string" }
1168
- }
1169
- };
1170
- if (includeExecution) {
1171
- schema.required.push("execution_quality");
1172
- schema.properties.execution_quality = {
1173
- type: "object",
1174
- required: ["rating", "category", "reasoning"],
1175
- properties: {
1176
- rating: { type: "integer", minimum: 1, maximum: 5 },
1177
- category: { type: "string", enum: ["efficient", "adequate", "wasteful", "error"] },
1178
- unnecessary_tool_calls: { type: "integer" },
1179
- reasoning: { type: "string" }
1180
- }
1181
- };
1182
- }
1183
- return schema;
1184
- }
1185
- async function evaluateTask(taskId, store, config) {
1186
- const { rows } = store.listTasksRaw({ limit: 500 });
1187
- const match = rows.find((r) => r.id === taskId || r.id.startsWith(taskId));
1188
- if (!match) {
1189
- throw new Error(`Task not found: ${taskId}`);
1190
- }
1191
- const fullTask = store.getTask(match.id);
1192
- if (!fullTask) {
1193
- throw new Error(`Task data not found: ${match.id}`);
1194
- }
1195
- const requestText = match.request_message || "No request text available";
1196
- let responseText = "No response available";
1197
- if (fullTask.status?.message) {
1198
- const parts = fullTask.status.message.parts ?? [];
1199
- const textPart = parts.find((p) => typeof p.text === "string");
1200
- if (textPart) {
1201
- responseText = textPart.text;
1202
- }
1203
- }
1204
- if (fullTask.status.state === "failed" && responseText === "No response available") {
1205
- return {
1206
- response_quality: {
1207
- rating: 1,
1208
- category: "error",
1209
- relevance: false,
1210
- completeness: false,
1211
- actionable: false,
1212
- reasoning: "Task failed without producing a response."
1213
- },
1214
- overall_rating: 1,
1215
- summary: "Task failed without producing a response."
1216
- };
1217
- }
1218
- let traceTree;
1219
- const traceId = match.metadata?.trace_id;
1220
- const traceFile = match.metadata?.trace_file;
1221
- if (traceFile || traceId) {
1222
- try {
1223
- const traceRef = traceFile || traceId;
1224
- traceTree = await serializeTraceForPrompt(
1225
- traceRef,
1226
- 1e6,
1227
- { traceDir: config?.traceDir },
1228
- responseText !== "No response available" ? responseText : void 0,
1229
- traceId
1230
- );
1231
- if (traceTree === "(no trace data available)") {
1232
- traceTree = void 0;
1233
- }
1234
- } catch (err) {
1235
- logger.debug(
1236
- `[TaskEvaluator] Failed to load trace: ${err instanceof Error ? err.message : err}`
1237
- );
1238
- }
1239
- }
1240
- const systemPrompt = config?.prompt || process.env.VISOR_EVAL_PROMPT || DEFAULT_EVALUATION_PROMPT;
1241
- const hasTrace = !!traceTree;
1242
- let userPrompt;
1243
- if (traceTree) {
1244
- userPrompt = `<user_request>
1245
- ${requestText}
1246
- </user_request>
1247
-
1248
- <execution_trace>
1249
- ${traceTree}
1250
- </execution_trace>`;
1251
- } else {
1252
- userPrompt = `<user_request>
1253
- ${requestText}
1254
- </user_request>
1255
-
1256
- <agent_response>
1257
- ${responseText}
1258
- </agent_response>`;
1259
- }
1260
- const { ProbeAgent } = __require("@probelabs/probe");
1261
- const model = config?.model || process.env.VISOR_EVAL_MODEL || process.env.VISOR_JUDGE_MODEL || void 0;
1262
- const provider = config?.provider || process.env.VISOR_EVAL_PROVIDER || void 0;
1263
- const agentOptions = {
1264
- sessionId: `visor-task-eval-${Date.now()}`,
1265
- systemPrompt,
1266
- maxIterations: 1,
1267
- disableTools: true
1268
- };
1269
- if (model) agentOptions.model = model;
1270
- if (provider) agentOptions.provider = provider;
1271
- if (config?.apiKey) {
1272
- const envKey = provider === "openai" ? "OPENAI_API_KEY" : provider === "anthropic" ? "ANTHROPIC_API_KEY" : "GOOGLE_API_KEY";
1273
- process.env[envKey] = config.apiKey;
1274
- }
1275
- const agent = new ProbeAgent(agentOptions);
1276
- if (typeof agent.initialize === "function") {
1277
- await agent.initialize();
1278
- }
1279
- const jsonSchema = buildEvaluationSchema(hasTrace);
1280
- const schemaStr = JSON.stringify(jsonSchema);
1281
- const response = await agent.answer(userPrompt, void 0, { schema: schemaStr });
1282
- let result;
1283
- try {
1284
- const cleaned = response.replace(/^```(?:json)?\s*\n?/m, "").replace(/\n?```\s*$/m, "").trim();
1285
- result = JSON.parse(cleaned);
1286
- } catch {
1287
- const jsonMatch = response.match(/\{[\s\S]*\}/);
1288
- if (jsonMatch) {
1289
- result = JSON.parse(jsonMatch[0]);
1290
- } else {
1291
- throw new Error(`Failed to parse evaluation response as JSON: ${response.slice(0, 200)}`);
1292
- }
1293
- }
1294
- if (!hasTrace) {
1295
- const MAX_RATING_WITHOUT_TRACE = 4;
1296
- if (result.overall_rating > MAX_RATING_WITHOUT_TRACE) {
1297
- result.overall_rating = MAX_RATING_WITHOUT_TRACE;
1298
- }
1299
- result.trace_available = false;
1300
- result.summary = `[No trace available \u2014 execution quality not assessed, rating capped at ${MAX_RATING_WITHOUT_TRACE}/5] ${result.summary}`;
1301
- } else {
1302
- result.trace_available = true;
1303
- }
1304
- return result;
1305
- }
1306
- async function evaluateAndStore(taskId, store, config) {
1307
- const result = await evaluateTask(taskId, store, config);
1308
- const { rows } = store.listTasksRaw({ limit: 500 });
1309
- const match = rows.find((r) => r.id === taskId || r.id.startsWith(taskId));
1310
- if (match) {
1311
- store.addArtifact(match.id, {
1312
- artifact_id: crypto.randomUUID(),
1313
- name: "evaluation",
1314
- parts: [{ text: JSON.stringify(result), media_type: "application/json" }]
1315
- });
1316
- }
1317
- return result;
1318
- }
1319
- var DEFAULT_EVALUATION_PROMPT;
1320
- var init_task_evaluator = __esm({
1321
- "src/agent-protocol/task-evaluator.ts"() {
1322
- init_logger();
1323
- init_trace_serializer();
1324
- DEFAULT_EVALUATION_PROMPT = `You are a task response quality evaluator for an AI agent system called Visor.
1325
-
1326
- You will receive the user's original request and an execution trace inside <execution_trace> tags. The trace is a YAML-formatted view of the entire agent execution, including the final response. When no trace is available, the agent response is provided directly.
1327
-
1328
- ## How to Read the Execution Trace
1329
-
1330
- The trace is a tree of spans representing the agent's execution pipeline:
1331
-
1332
- **Top-level: \`visor.run\`** \u2014 The root span with metadata:
1333
- - \`trace_id\`: Unique execution identifier
1334
- - \`visor\` / \`probe\`: Software versions
1335
- - \`source\`: Where the request came from (e.g., "slack", "cli")
1336
- - \`duration\`: Total wall-clock time
1337
-
1338
- **Checks** \u2014 Named processing steps (e.g., \`route-intent\`, \`explore-code\`, \`generate-response\`):
1339
- - \`type\`: "ai" (LLM-powered), "script" (deterministic), or "workflow" (sub-pipeline)
1340
- - \`duration\`: How long this step took
1341
- - \`input\`: What was passed to this check \u2014 may include an \`intent\` (the user's question as understood by the router) and dependency outputs
1342
- - \`output\`: The check's result \u2014 may be structured JSON or plain text
1343
-
1344
- **AI blocks** (\`ai: model-name\`) \u2014 Individual LLM calls within checks:
1345
- - Shows model used, duration, and token counts (input/output)
1346
- - \`intent\`: The question or instruction sent to the LLM
1347
-
1348
- **Tool calls** \u2014 Listed as \`- toolName(input) \u2192 size\`:
1349
- - \`search("query" in repo)\`: Code search. "\u2192 no results" means nothing was found; otherwise shows result size
1350
- - \`extract(file/path)\`: File content extraction with result size
1351
- - \`listFiles(dir)\`: Directory listing
1352
- - \`bash()\`: Shell command execution
1353
-
1354
- **Delegations** (\`search.delegate("query")\`) \u2014 Sub-agent searches:
1355
- - Contains their own AI blocks and tool calls
1356
- - Used for complex multi-step code exploration
1357
-
1358
- **The \`response\` field** at the end of the trace is the final answer sent back to the user. This is the primary output to evaluate.
1359
-
1360
- **Symbols:**
1361
- - \`\u2717\` marks failed/error spans
1362
- - \`= check-name\` means output is identical to that check's output (deduplication)
1363
-
1364
- ## Evaluation Criteria
1365
-
1366
- **Response Quality** (1-5):
1367
- - **Relevance**: Does the response directly address what the user asked? A response about the wrong topic or that misunderstands the question scores low.
1368
- - **Completeness**: Does it fully answer the question? Partial answers, missing key details, or surface-level responses score lower.
1369
- - **Actionable**: Can the user act on this information? Vague or generic advice scores lower than specific, concrete answers with code references.
1370
- - Rating: 5=excellent (thorough, specific, directly useful), 4=good (answers well but minor gaps), 3=adequate (addresses question but lacks depth), 2=poor (partially relevant or very incomplete), 1=off-topic or error
1371
-
1372
- **Execution Quality** (1-5, only when trace is provided):
1373
- - **Efficiency**: Were tool calls necessary and well-targeted? Good search queries that find results on the first try score high.
1374
- - **Redundancy**: Were there duplicate searches, unnecessary re-searches with slightly different queries, or tools called for information already available?
1375
- - **Extract-then-search anti-pattern**: If a file was already extracted (e.g., \`extract(docs/config.mdx) \u2192 3.3k chars\`), then a subsequent \`search("term" in config.mdx)\` is redundant \u2014 the agent already has the file content and should parse it from context instead of making another tool call. Flag every instance of this pattern.
1376
- - **Search-reformulation waste**: If a search returns "no results" and the agent immediately retries with a minor query variation (e.g., \`"audit store_type"\` \u2192 \`"audit "store_type""\` \u2192 \`"store_type"\`), that's usually wasteful. A single well-crafted query should suffice; reformulating 3+ times for the same concept is a red flag.
1377
- - **Delegation quality**: Were search delegations productive? Did they explore relevant code paths?
1378
- - **Token usage**: Was input context kept reasonable, or did the agent load excessive amounts of code?
1379
- - Rating: 5=efficient (minimal, targeted tool use), 4=adequate (minor redundancy), 3=some waste (noticeable unnecessary calls), 2=wasteful (many redundant searches or delegations), 1=error/broken execution
1380
-
1381
- **Overall Rating** (1-5): Weighted combination \u2014 response quality matters most, execution quality is secondary. A perfect response from a wasteful execution still scores 3-4 overall.
1382
-
1383
- You MUST respond with valid JSON matching the provided schema. Be specific in your reasoning \u2014 reference actual check names, tool calls, or response content.`;
1384
- }
1385
- });
1386
- init_task_evaluator();
1387
- export {
1388
- DEFAULT_EVALUATION_PROMPT,
1389
- evaluateAndStore,
1390
- evaluateTask
1391
- };
1392
- //# sourceMappingURL=task-evaluator-GQYDOSGT.mjs.map