promptfoo 0.125.0 → 0.125.1
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.
- package/README.md +3 -3
- package/dist/src/accounts-BOxNYxVN.js +229 -0
- package/dist/src/accounts-BezXLdAW.cjs +276 -0
- package/dist/src/accounts-CPISMNlh.js +227 -0
- package/dist/src/accounts-vJBPs89d.js +222 -0
- package/dist/src/agentWorkspace-Bom7SpF2.js +592 -0
- package/dist/src/agentWorkspace-CEomAcws.cjs +619 -0
- package/dist/src/agentWorkspace-DPtMLrlI.js +593 -0
- package/dist/src/agentWorkspace-DkAeEYLz.js +592 -0
- package/dist/src/agentic-utils-121v7mJo.js +197 -0
- package/dist/src/agentic-utils-CBWD_rcd.cjs +237 -0
- package/dist/src/agentic-utils-D8wyQwPG.js +198 -0
- package/dist/src/agentic-utils-EP1QkQCs.js +197 -0
- package/dist/src/agents-Br3ah8iA.js +778 -0
- package/dist/src/agents-C5wj_UTv.js +777 -0
- package/dist/src/agents-C9Efp4mC.js +266 -0
- package/dist/src/agents-CQYwaVCO.js +267 -0
- package/dist/src/agents-CjCd4Vo8.js +777 -0
- package/dist/src/agents-DRWiCHYz.js +266 -0
- package/dist/src/agents-F2rhx0iL.cjs +266 -0
- package/dist/src/agents-RTYyy69h.cjs +777 -0
- package/dist/src/agents-api-CY72O86e.js +711 -0
- package/dist/src/agents-api-CsSsC21b.js +710 -0
- package/dist/src/agents-api-DN-ibDc8.js +710 -0
- package/dist/src/agents-api-cNDsCCv1.cjs +710 -0
- package/dist/src/ai.studio-Bj6Dyi6o.js +2 -0
- package/dist/src/ai.studio-C-e0LzyW.js +369 -0
- package/dist/src/ai.studio-CR8M6Aqf.cjs +391 -0
- package/dist/src/ai.studio-YKk7F0tv.js +374 -0
- package/dist/src/aimlapi-BGunsuTu.js +30 -0
- package/dist/src/aimlapi-BkzcfBsL.js +29 -0
- package/dist/src/aimlapi-DXFcEdP8.js +28 -0
- package/dist/src/aimlapi-r-8iCcAw.cjs +29 -0
- package/dist/src/anthropicMessages-7-YNRgQR.js +114 -0
- package/dist/src/anthropicMessages-C8m9Whrd.cjs +114 -0
- package/dist/src/anthropicMessages-DS1vXD0f.js +115 -0
- package/dist/src/anthropicMessages-DmvGkz-0.js +114 -0
- package/dist/src/app/assets/index-CrdXWTXm.js +392 -0
- package/dist/src/app/browser-inventory.json +4 -4
- package/dist/src/app/index.html +1 -1
- package/dist/src/audio-BLgFgyw-.cjs +104 -0
- package/dist/src/audio-C2sibT7Q.js +104 -0
- package/dist/src/audio-DXEXb03H.js +104 -0
- package/dist/src/audio-TkvojpwO.js +105 -0
- package/dist/src/authoritativeMarkupInjection-BAT9B-Wj.js +79 -0
- package/dist/src/authoritativeMarkupInjection-B_yHETKT.js +78 -0
- package/dist/src/authoritativeMarkupInjection-BfjecQ3Q.cjs +78 -0
- package/dist/src/authoritativeMarkupInjection-D-hDKrhD.js +78 -0
- package/dist/src/aws-B_9unI_-.js +1149 -0
- package/dist/src/aws-D0FY3qkc.js +2433 -0
- package/dist/src/aws-Dh1-a90n.js +2433 -0
- package/dist/src/aws-qskKGczY.cjs +2454 -0
- package/dist/src/base-CaWlBkVz.js +462 -0
- package/dist/src/base-CcViNwVs.js +255 -0
- package/dist/src/base-CsVbPJkU.cjs +467 -0
- package/dist/src/base-DNK9py25.js +255 -0
- package/dist/src/base-DlH5tjEZ.js +463 -0
- package/dist/src/base-DyLOZ_iX.js +256 -0
- package/dist/src/base-RRYXfG7l.cjs +305 -0
- package/dist/src/base-oXVgvtVn.js +462 -0
- package/dist/src/bedrock-BP17ZXbR.cjs +2 -0
- package/dist/src/bedrock-CsjM1dOt.js +1300 -0
- package/dist/src/bedrock-CzPwj8GO.js +1 -0
- package/dist/src/bedrock-eGXZw8oh.js +1 -0
- package/dist/src/bedrock-tSWjmXdj.js +2 -0
- package/dist/src/bestOfN-BQ93nUKV.js +160 -0
- package/dist/src/bestOfN-ByGGwlcb.cjs +161 -0
- package/dist/src/bestOfN-CbP7csHr.js +159 -0
- package/dist/src/bestOfN-xn6i2Xs2.js +159 -0
- package/dist/src/cache-CHq9hPz9.js +2 -0
- package/dist/src/cache-D-9eZN3I.js +754 -0
- package/dist/src/cache-DSm6t1MZ.js +741 -0
- package/dist/src/cache-DeF5zIEN.js +782 -0
- package/dist/src/cache-iG87oYan.cjs +856 -0
- package/dist/src/cerebras-CTtM4yMH.js +98 -0
- package/dist/src/cerebras-CogcJ3ce.cjs +97 -0
- package/dist/src/cerebras-DmkRypTh.js +97 -0
- package/dist/src/cerebras-GUp0B8JY.js +97 -0
- package/dist/src/chat-B4ihd3fw.js +226 -0
- package/dist/src/chat-B9cAQ_rS.js +227 -0
- package/dist/src/chat-BU7EB4R-.cjs +76 -0
- package/dist/src/chat-C8yxJ2-s.cjs +226 -0
- package/dist/src/chat-ClTFM3qq.js +934 -0
- package/dist/src/chat-Cnq0Is68.js +123 -0
- package/dist/src/chat-CwrurR57.cjs +987 -0
- package/dist/src/chat-D0lsojPv.js +124 -0
- package/dist/src/chat-D7_8yFIx.js +76 -0
- package/dist/src/chat-DCoETlLG.js +226 -0
- package/dist/src/chat-DHE7xaTR.js +76 -0
- package/dist/src/chat-DmhT6rz2.cjs +123 -0
- package/dist/src/chat-DvfMe8KI.js +123 -0
- package/dist/src/chat-DwP5kVnl.js +935 -0
- package/dist/src/chat-MB7U-QE2.js +77 -0
- package/dist/src/chat-zCWuBKAj.js +934 -0
- package/dist/src/claude-agent-sdk-23bIVI75.js +999 -0
- package/dist/src/claude-agent-sdk-BACpnIJi.cjs +1005 -0
- package/dist/src/claude-agent-sdk-BlYlmcEr.js +999 -0
- package/dist/src/claude-agent-sdk-Cr-jqJZl.js +1000 -0
- package/dist/src/client-BktbiPx9.cjs +357 -0
- package/dist/src/client-CjztEBmW.js +351 -0
- package/dist/src/client-mRs2UvH9.js +351 -0
- package/dist/src/client-uCz0ydjC.js +352 -0
- package/dist/src/cloud-BtYF555L.js +2 -0
- package/dist/src/cloud-CVSUEmAy.js +287 -0
- package/dist/src/cloud-D7Ifb-Fl.js +599 -0
- package/dist/src/cloud-DB5oK5NX.cjs +666 -0
- package/dist/src/cloud-ecu989Em.js +657 -0
- package/dist/src/cloud-ramjGURF.js +599 -0
- package/dist/src/cloudflare-ai-BfDkIjO8.js +133 -0
- package/dist/src/cloudflare-ai-D9HaXz1M.js +134 -0
- package/dist/src/cloudflare-ai-HrD5WUK8.js +132 -0
- package/dist/src/cloudflare-ai-Qdj8aKP2.cjs +133 -0
- package/dist/src/cloudflare-gateway-C81uKETQ.js +276 -0
- package/dist/src/cloudflare-gateway-CX5Z9X0k.js +276 -0
- package/dist/src/cloudflare-gateway-DW-og8gb.js +277 -0
- package/dist/src/cloudflare-gateway-iRyXo9n2.cjs +276 -0
- package/dist/src/codex-app-server-BFIrSgdy.js +2155 -0
- package/dist/src/codex-app-server-By1eDVD4.js +2 -0
- package/dist/src/codex-app-server-DKsF4qmY.js +2156 -0
- package/dist/src/codex-app-server-n7n4uZzC.cjs +2162 -0
- package/dist/src/codex-app-server-xAoELVxu.js +2155 -0
- package/dist/src/codex-sdk-C2ZLxa6r.js +1552 -0
- package/dist/src/codex-sdk-CzG02tQt.cjs +1588 -0
- package/dist/src/codex-sdk-DNxAOhiV.js +2 -0
- package/dist/src/codex-sdk-DT3aQezK.js +1557 -0
- package/dist/src/codex-sdk-pw9DpcJP.js +1557 -0
- package/dist/src/codex-security-B0bLmXJF.js +406 -0
- package/dist/src/codex-security-BhYs-3iY.js +406 -0
- package/dist/src/codex-security-DQcOfxYW.js +407 -0
- package/dist/src/codex-security-DsCWr6GZ.cjs +411 -0
- package/dist/src/cometapi-B16asPLX.cjs +55 -0
- package/dist/src/cometapi-MgTbZA_H.js +53 -0
- package/dist/src/cometapi-i33vKzPV.js +55 -0
- package/dist/src/cometapi-wK2UWK0X.js +56 -0
- package/dist/src/compatible-COj8ZCy9.js +24 -0
- package/dist/src/compatible-CRSsIUGb.cjs +24 -0
- package/dist/src/compatible-Dy1vCcNF.js +25 -0
- package/dist/src/compatible-aUItQrpk.js +24 -0
- package/dist/src/completion-Bn7COFMk.js +119 -0
- package/dist/src/completion-Bub2N48b.js +118 -0
- package/dist/src/completion-Cf2G9OlM.cjs +123 -0
- package/dist/src/conversationScoring-BiTYJ9MD.js +374 -0
- package/dist/src/conversationScoring-CKL47uIu.js +373 -0
- package/dist/src/conversationScoring-DCvQKp6k.cjs +398 -0
- package/dist/src/conversationScoring-DLNJtDZI.js +373 -0
- package/dist/src/crescendo-5iLk9WiJ.cjs +734 -0
- package/dist/src/crescendo-B5ylG7kW.js +733 -0
- package/dist/src/crescendo-BD7k6TIx.js +730 -0
- package/dist/src/crescendo-DqO2Ch0P.js +732 -0
- package/dist/src/custom-8rv_aG2K.js +617 -0
- package/dist/src/custom-BOtrIHFN.js +619 -0
- package/dist/src/custom-BvN8seCs.cjs +620 -0
- package/dist/src/custom-Cld9v_Y4.js +618 -0
- package/dist/src/dataUrl-BdHUey2l.cjs +3187 -0
- package/dist/src/dataUrl-DBMifX6C.js +3133 -0
- package/dist/src/dataUrl-DUSr-ZvI.js +2868 -0
- package/dist/src/decisions-CLazADTw.js +516 -0
- package/dist/src/decisions-D5X93awq.js +515 -0
- package/dist/src/decisions-DmaeArEn.js +515 -0
- package/dist/src/decisions-DyQJyHJz.cjs +514 -0
- package/dist/src/docker-C9NYQFeu.js +94 -0
- package/dist/src/docker-CGq3mMol.cjs +94 -0
- package/dist/src/docker-DOm7nmpl.js +95 -0
- package/dist/src/docker-skFN-Kfo.js +93 -0
- package/dist/src/embedding-0UbzkTk9.js +82 -0
- package/dist/src/embedding-DTrSDt7k.cjs +86 -0
- package/dist/src/embedding-j2ORNl5H.js +81 -0
- package/dist/src/envoy-BvS8XTQO.js +60 -0
- package/dist/src/envoy-Cn6Hzw0e.js +60 -0
- package/dist/src/envoy-DC3KWcUY.cjs +60 -0
- package/dist/src/envoy-DetHjo5B.js +61 -0
- package/dist/src/eval-Cer9dPe9.js +1920 -0
- package/dist/src/eval-CytYmI2Z.js +2 -0
- package/dist/src/evalResult-DzOq5wt9.js +1300 -0
- package/dist/src/evaluator-BxCmvGtv.js +10578 -0
- package/dist/src/evaluator-Ct7YDELm.js +2 -0
- package/dist/src/evaluatorHelpers-B_AwIrsl.js +600 -0
- package/dist/src/evaluatorHelpers-D1Tpc7gd.js +601 -0
- package/dist/src/evaluatorHelpers-DRR3rLq0.cjs +622 -0
- package/dist/src/fetch-B5KxZuKu.js +1559 -0
- package/dist/src/fetch-BG_Jl7ty.js +1556 -0
- package/dist/src/fetch-BKlgUg08.cjs +1853 -0
- package/dist/src/fetch-C9Fsja0R.js +2 -0
- package/dist/src/fetch-CM7P8KWA.cjs +14 -0
- package/dist/src/fetch-D0FkIB3G.js +9 -0
- package/dist/src/fetch-RXHsZF-J.js +1280 -0
- package/dist/src/fetch-rSECy8jR.js +10 -0
- package/dist/src/functionCallbackUtils-BB9tmf6a.cjs +262 -0
- package/dist/src/functionCallbackUtils-BXk2iY01.js +246 -0
- package/dist/src/functionCallbackUtils-B_cYp7P5.js +245 -0
- package/dist/src/functionCallbackUtils-BfXnPo0o.js +245 -0
- package/dist/src/gemini-image-BXLMADDz.js +471 -0
- package/dist/src/gemini-image-BYUZyEUx.js +472 -0
- package/dist/src/gemini-image-DSt1QubZ.cjs +471 -0
- package/dist/src/gemini-image-DdNDMiZ_.js +471 -0
- package/dist/src/goat-9b-uU_k6.js +514 -0
- package/dist/src/goat-BCJuiDd0.js +515 -0
- package/dist/src/goat-CmAHbemm.js +512 -0
- package/dist/src/goat-DdOTdyoS.cjs +515 -0
- package/dist/src/goblin-Bp5C5lyb.js +22 -0
- package/dist/src/goblin-Dmr7GItI.js +23 -0
- package/dist/src/goblin-DpM8wxlf.cjs +22 -0
- package/dist/src/goblin-cJyH6Pq-.js +22 -0
- package/dist/src/google-B6eaPAbE.js +142 -0
- package/dist/src/google-D-FStdN6.cjs +142 -0
- package/dist/src/google-DAC7BsCW.js +142 -0
- package/dist/src/google-Id18H0Va.js +143 -0
- package/dist/src/graders-BjNQWkaB.js +2 -0
- package/dist/src/graders-CqdIp_vl.js +15470 -0
- package/dist/src/hydra-6Ouh74DE.js +610 -0
- package/dist/src/hydra-BHjhZnLB.cjs +612 -0
- package/dist/src/hydra-BL6k2REV.js +2 -0
- package/dist/src/hydra-BWUc0o67.js +613 -0
- package/dist/src/hydra-CUkEOLKw.js +612 -0
- package/dist/src/image-B6hG_xhb.js +481 -0
- package/dist/src/image-BFaq7Krd.cjs +209 -0
- package/dist/src/image-Bql5C0N9.cjs +504 -0
- package/dist/src/image-BtZfI2pT.js +163 -0
- package/dist/src/image-CIM4oN7Z.cjs +163 -0
- package/dist/src/image-CbAl7Jpu.js +209 -0
- package/dist/src/image-CiYm_yFw.js +209 -0
- package/dist/src/image-DCMNvBiV.js +163 -0
- package/dist/src/image-DL7pIuUZ.js +210 -0
- package/dist/src/image-ey0kxF8o.js +164 -0
- package/dist/src/image-smgIk3rE.js +482 -0
- package/dist/src/index.cjs +27 -27
- package/dist/src/index.d.cts +8 -8
- package/dist/src/index.js +27 -27
- package/dist/src/indirectWebPwn-B_-UpWY5.js +285 -0
- package/dist/src/indirectWebPwn-Cz3SLiEq.js +434 -0
- package/dist/src/indirectWebPwn-D2s8zGiM.cjs +463 -0
- package/dist/src/indirectWebPwn-DXbj2wGu.cjs +285 -0
- package/dist/src/indirectWebPwn-D_4H44E6.js +285 -0
- package/dist/src/indirectWebPwn-L044SrpV.js +434 -0
- package/dist/src/indirectWebPwn-cnmvdavH.js +435 -0
- package/dist/src/indirectWebPwn-zUBzsqTt.js +286 -0
- package/dist/src/interactions-Bu3oVQ-j.js +850 -0
- package/dist/src/interactions-CND010Lh.cjs +850 -0
- package/dist/src/interactions-DAx7tqUz.js +851 -0
- package/dist/src/interactions-DPkIumeh.js +850 -0
- package/dist/src/iterative-BO4JRnpG.js +545 -0
- package/dist/src/iterative-CAK-k9rz.js +548 -0
- package/dist/src/iterative-CDgHc0xO.cjs +549 -0
- package/dist/src/iterative-CXJlHLl9.js +547 -0
- package/dist/src/iterativeImage-BEdGKSmh.cjs +419 -0
- package/dist/src/iterativeImage-BfL0QZw5.js +417 -0
- package/dist/src/iterativeImage-C9KhnibC.js +417 -0
- package/dist/src/iterativeImage-btjkOfWG.js +418 -0
- package/dist/src/iterativeMeta-B5Bdw6QA.js +437 -0
- package/dist/src/iterativeMeta-C3mI4gpT.js +440 -0
- package/dist/src/iterativeMeta-Co2BKyqS.cjs +439 -0
- package/dist/src/iterativeMeta-DD8ihRWD.js +439 -0
- package/dist/src/iterativeTree-AMi4GV2O.js +878 -0
- package/dist/src/iterativeTree-C8FJOEje.cjs +879 -0
- package/dist/src/iterativeTree-CvrY1f2Z.js +877 -0
- package/dist/src/iterativeTree-bPtESmaD.js +876 -0
- package/dist/src/knowledgeBase-Cf5871e3.js +163 -0
- package/dist/src/knowledgeBase-D2PQhqLH.js +164 -0
- package/dist/src/knowledgeBase-DpoMw1IH.cjs +163 -0
- package/dist/src/knowledgeBase-npGFl763.js +163 -0
- package/dist/src/litellm-BBB5DQdt.cjs +146 -0
- package/dist/src/litellm-Bo43ow7r.js +145 -0
- package/dist/src/litellm-CaU8CMLS.js +146 -0
- package/dist/src/litellm-wY7Unh8o.js +147 -0
- package/dist/src/live-5g2w-M-E.js +891 -0
- package/dist/src/live-BfaXsDyD.cjs +891 -0
- package/dist/src/live-C1xewnGD.js +2 -0
- package/dist/src/live-DaF7nYy5.js +892 -0
- package/dist/src/live-lp3urLUw.js +891 -0
- package/dist/src/luma-ray-B7zvKGVG.js +309 -0
- package/dist/src/luma-ray-DCf5fnrz.cjs +309 -0
- package/dist/src/luma-ray-DepBcn6z.js +309 -0
- package/dist/src/luma-ray-XQC4M1pt.js +310 -0
- package/dist/src/main.js +26 -26
- package/dist/src/mantleChat-7xm95vSV.js +154 -0
- package/dist/src/mantleChat-CXhAs5RD.js +155 -0
- package/dist/src/mantleChat-CcE-zjfj.cjs +154 -0
- package/dist/src/mantleChat-Cpefl7Zm.js +154 -0
- package/dist/src/mcp-B0V0ikdM.js +84 -0
- package/dist/src/mcp-CV2k2gwj.js +85 -0
- package/dist/src/memoryPoisoning-BC5FQQWZ.js +111 -0
- package/dist/src/memoryPoisoning-BDwrtZKX.js +111 -0
- package/dist/src/memoryPoisoning-BFemS_FF.js +112 -0
- package/dist/src/memoryPoisoning-DRs2rbVV.cjs +111 -0
- package/dist/src/messages-Bc5oZoAJ.js +1128 -0
- package/dist/src/messages-BkaH8fRW.js +1127 -0
- package/dist/src/messages-CoHlziS5.js +1127 -0
- package/dist/src/messages-Cv_m6kYs.cjs +1161 -0
- package/dist/src/mischievousUser-BcyFxrqJ.js +51 -0
- package/dist/src/mischievousUser-BlhOQSd2.js +52 -0
- package/dist/src/mischievousUser-BuQiKE8D.js +51 -0
- package/dist/src/mischievousUser-ChIOk6cT.cjs +51 -0
- package/dist/src/modelslab-BXIWBTgX.js +171 -0
- package/dist/src/modelslab-ChVsUiaJ.js +170 -0
- package/dist/src/modelslab-DZ6BFlDv.js +170 -0
- package/dist/src/modelslab-DhRr-vyo.cjs +170 -0
- package/dist/src/nova-reel-BL8DrN4_.js +272 -0
- package/dist/src/nova-reel-BiOMUm5q.cjs +272 -0
- package/dist/src/nova-reel-CTsya1hV.js +273 -0
- package/dist/src/nova-reel-kgBY4Svd.js +272 -0
- package/dist/src/nova-sonic-CaSSA3Jq.cjs +374 -0
- package/dist/src/nova-sonic-DLpmoGsR.js +375 -0
- package/dist/src/nova-sonic-DwWc4SoN.js +374 -0
- package/dist/src/nova-sonic-qnReTaXm.js +374 -0
- package/dist/src/novita-B5mAt3Ui.js +114 -0
- package/dist/src/novita-D57vCjDD.js +116 -0
- package/dist/src/novita-ITRtG8IJ.js +115 -0
- package/dist/src/novita-Rh3T13YO.cjs +115 -0
- package/dist/src/nscale-8V7iZ_pI.js +210 -0
- package/dist/src/nscale-BQnMv4pH.cjs +209 -0
- package/dist/src/nscale-BWZXHZVF.js +209 -0
- package/dist/src/nscale-BqrHiUqU.js +207 -0
- package/dist/src/openaiResponses-BMtGTu8R.js +317 -0
- package/dist/src/openaiResponses-CvcI_viE.js +318 -0
- package/dist/src/openaiResponses-DYPZEMX1.cjs +318 -0
- package/dist/src/openaiResponses-DZTg1-kb.js +319 -0
- package/dist/src/openclaw-BeKuig4g.js +1338 -0
- package/dist/src/openclaw-COkdQ83y.js +1337 -0
- package/dist/src/openclaw-CSoX_HQ5.cjs +1344 -0
- package/dist/src/openclaw-DJlhPGCb.js +1336 -0
- package/dist/src/opencode-sdk-BEJftEs6.cjs +1018 -0
- package/dist/src/opencode-sdk-DMvBB3V7.js +1013 -0
- package/dist/src/opencode-sdk-Df7hMjLO.js +1012 -0
- package/dist/src/opencode-sdk-bQp5Xf3W.js +1012 -0
- package/dist/src/openinterpreter-B3GgVZjK.js +431 -0
- package/dist/src/openinterpreter-BiGcU-HN.cjs +435 -0
- package/dist/src/openinterpreter-Buj2l3Eh.js +432 -0
- package/dist/src/openinterpreter-C3_Cg5b_.js +431 -0
- package/dist/src/pricing-0Pampf0q.cjs +999 -0
- package/dist/src/pricing-B8VdhEhY.js +976 -0
- package/dist/src/pricing-CtLA-rKA.js +976 -0
- package/dist/src/promptfoo-4OkHtH9P.cjs +341 -0
- package/dist/src/promptfoo-Bhpm7sH6.js +286 -0
- package/dist/src/promptfoo-BqV8ogVA.js +285 -0
- package/dist/src/promptfoo-S1Q9OHk_.js +286 -0
- package/dist/src/providers-B5zs1ZRv.js +24437 -0
- package/dist/src/providers-Cd6CJh6m.js +2 -0
- package/dist/src/providers-CpJlgHET.js +24039 -0
- package/dist/src/providers-CzvLvK6G.cjs +24180 -0
- package/dist/src/quiverai-1E_IvLHn.js +325 -0
- package/dist/src/quiverai-BXH004Vv.js +325 -0
- package/dist/src/quiverai-Ccya2z8Y.cjs +325 -0
- package/dist/src/quiverai-Cez57oe-.js +326 -0
- package/dist/src/registry-3zX_M9Ik.js +131 -0
- package/dist/src/registry-AuCrKTvS.js +132 -0
- package/dist/src/registry-CxXWKtQG.js +131 -0
- package/dist/src/registry-DG3o66JQ.cjs +131 -0
- package/dist/src/remoteGeneration-CAtvamG6.js +370 -0
- package/dist/src/remoteGeneration-CF225pDl.cjs +482 -0
- package/dist/src/remoteGeneration-DtnqocnL.js +370 -0
- package/dist/src/remoteGeneration-g3KvW-sP.js +371 -0
- package/dist/src/responses-BMbaUXQI.js +1098 -0
- package/dist/src/responses-B_TOSof-.js +1099 -0
- package/dist/src/responses-v-yANwTA.cjs +1109 -0
- package/dist/src/runtimeTransform-BBZv-oUZ.js +156 -0
- package/dist/src/runtimeTransform-DT2v5ovW.js +156 -0
- package/dist/src/runtimeTransform-GXXEIXdS.cjs +161 -0
- package/dist/src/runtimeTransform-JTwBQc-P.js +157 -0
- package/dist/src/sagemaker-B8D0L4rj.cjs +716 -0
- package/dist/src/sagemaker-CR2_AGdB.js +713 -0
- package/dist/src/sagemaker-Cd9qSQUV.js +714 -0
- package/dist/src/sagemaker-mKlltN4p.js +713 -0
- package/dist/src/scanner-PG_8lh8r.js +1971 -0
- package/dist/src/server/index.js +55 -55
- package/dist/src/server-Bmh7sd9F.js +155 -0
- package/dist/src/server-C7b8z6aC.js +63 -0
- package/dist/src/server-CAcovgtL.js +2 -0
- package/dist/src/server-CuuMfKlh.cjs +74 -0
- package/dist/src/server-DMPCj9jy.js +189 -0
- package/dist/src/session-BksXvRH_.cjs +69 -0
- package/dist/src/session-DOxUjqGQ.js +63 -0
- package/dist/src/session-Dujsc-b9.js +62 -0
- package/dist/src/session-VjtIxREd.js +62 -0
- package/dist/src/shared-Bkyz_7e5.cjs +2185 -0
- package/dist/src/shared-DDJg8ycC.js +1929 -0
- package/dist/src/shared-Dh3yfRBd.js +1927 -0
- package/dist/src/shared-tfPT8Tna.js +1928 -0
- package/dist/src/simulatedUser-6JdkyL3k.cjs +252 -0
- package/dist/src/simulatedUser-CFr2mr3M.js +248 -0
- package/dist/src/simulatedUser-DjwwUqx-.js +247 -0
- package/dist/src/slack-C_gIYiUs.js +144 -0
- package/dist/src/slack-DhNbz9CM.cjs +144 -0
- package/dist/src/slack-Dm2iI1zu.js +145 -0
- package/dist/src/strategies-BIY-bNul.js +2248 -0
- package/dist/src/strategies-C1KQQj9G.cjs +2420 -0
- package/dist/src/strategies-DM_3mReG.js +2385 -0
- package/dist/src/telemetry-BhMTibZO.js +2 -0
- package/dist/src/telemetry-C04d25BM.cjs +216 -0
- package/dist/src/telemetry-CIqy4fSC.js +201 -0
- package/dist/src/telemetry-CXozp_6C.js +205 -0
- package/dist/src/telemetry-g7PkBxmY.js +205 -0
- package/dist/src/togetherai-BvCim68-.js +50 -0
- package/dist/src/togetherai-CWyDCA9m.cjs +49 -0
- package/dist/src/togetherai-CeSE31vK.js +49 -0
- package/dist/src/togetherai-_2W0URf8.js +48 -0
- package/dist/src/traceContext-Brw3Oe41.js +1016 -0
- package/dist/src/traceContext-DpAYv27G.js +1015 -0
- package/dist/src/traceContext-KSqhzZI2.cjs +1032 -0
- package/dist/src/transcription-BySopazW.js +175 -0
- package/dist/src/transcription-DO4UPkRI.cjs +178 -0
- package/dist/src/transcription-RJGBa-pC.js +176 -0
- package/dist/src/transcription-fZenF3G5.js +175 -0
- package/dist/src/transform-BzhRc5z2.js +125 -0
- package/dist/src/transform-CPQu05u6.cjs +154 -0
- package/dist/src/transform-DAED8imp.js +126 -0
- package/dist/src/transform-DIOIQDmM.js +125 -0
- package/dist/src/typesafe-ByE0Kxfg.js +253 -0
- package/dist/src/typesafe-CFqGFY34.js +253 -0
- package/dist/src/typesafe-DCWIw-CP.cjs +253 -0
- package/dist/src/typesafe-DyHFV5Qk.js +254 -0
- package/dist/src/util-BHkj9joz.js +2049 -0
- package/dist/src/util-CICwIpmu.cjs +934 -0
- package/dist/src/util-CePiY2xZ.js +286 -0
- package/dist/src/util-CgT3uf4p.js +743 -0
- package/dist/src/util-Cj9drvOY.js +1770 -0
- package/dist/src/util-ClJRjlQA.cjs +357 -0
- package/dist/src/util-Cxf8VF2M.js +395 -0
- package/dist/src/util-D7RdV7rS.js +395 -0
- package/dist/src/util-DMNFhk47.js +351 -0
- package/dist/src/util-DNzh3M0z.js +396 -0
- package/dist/src/util-Df7rfMGb.cjs +2305 -0
- package/dist/src/util-Kf0KnG_6.js +2051 -0
- package/dist/src/util-LEbeiYw_.js +743 -0
- package/dist/src/util-WH8CgVs4.js +352 -0
- package/dist/src/util-cx6Xw8Lw.cjs +478 -0
- package/dist/src/util-qzBqirBH.js +2050 -0
- package/dist/src/vertex-CBAMfRz3.js +854 -0
- package/dist/src/vertex-CMP2IpN9.js +2 -0
- package/dist/src/vertex-CZ5YOotT.js +848 -0
- package/dist/src/vertex-DNsh1F1M.cjs +871 -0
- package/dist/src/vertexLive-BTXYj3-F.js +55 -0
- package/dist/src/vertexLive-Ba_LAqEF.cjs +55 -0
- package/dist/src/vertexLive-DM4sFaaj.js +56 -0
- package/dist/src/vertexLive-JqZOw7HC.js +55 -0
- package/dist/src/video-BY7Q2Gii.cjs +706 -0
- package/dist/src/video-CYElP-CK.js +703 -0
- package/dist/src/video-C_AdEDH0.js +702 -0
- package/dist/src/video-DGvjQ_4j.js +702 -0
- package/package.json +1 -1
- package/dist/src/accounts-Dpb43yde.cjs +0 -276
- package/dist/src/accounts-GKrO1olH.js +0 -229
- package/dist/src/accounts-e4FGOsji.js +0 -227
- package/dist/src/accounts-sUiEJfkB.js +0 -222
- package/dist/src/agentWorkspace-B8A_wuMR.cjs +0 -619
- package/dist/src/agentWorkspace-DSPIscXR.js +0 -593
- package/dist/src/agentWorkspace-DxUqd-XK.js +0 -592
- package/dist/src/agentWorkspace-n0uOJXhD.js +0 -592
- package/dist/src/agentic-utils-9bCj4twQ.js +0 -197
- package/dist/src/agentic-utils-CyCLuLoj.js +0 -197
- package/dist/src/agentic-utils-D23qtOlx.cjs +0 -237
- package/dist/src/agentic-utils-DuBMMNCw.js +0 -198
- package/dist/src/agents-6hDRNoYD.js +0 -777
- package/dist/src/agents-B8w2o7Sc.cjs +0 -777
- package/dist/src/agents-Ck0NXl7v.js +0 -777
- package/dist/src/agents-CwT3B1qB.js +0 -778
- package/dist/src/agents-DOLjfOEq.js +0 -266
- package/dist/src/agents-OcF9hq--.js +0 -267
- package/dist/src/agents-api-CnZZt8bn.cjs +0 -710
- package/dist/src/agents-api-D04u3bmL.js +0 -711
- package/dist/src/agents-api-DWw0_Vio.js +0 -710
- package/dist/src/agents-api-IWHEwp8i.js +0 -710
- package/dist/src/agents-mHt2Mh9O.cjs +0 -266
- package/dist/src/agents-sICccZCA.js +0 -266
- package/dist/src/ai.studio-Ci4rypDT.js +0 -2
- package/dist/src/ai.studio-KkQ6KaHa.js +0 -369
- package/dist/src/ai.studio-gSXK2cGI.js +0 -374
- package/dist/src/ai.studio-nQF_B4DH.cjs +0 -391
- package/dist/src/aimlapi-BeSk5BDV.js +0 -30
- package/dist/src/aimlapi-CzNUhdKu.cjs +0 -29
- package/dist/src/aimlapi-DCkazDPI.js +0 -29
- package/dist/src/aimlapi-WeH5B6K1.js +0 -28
- package/dist/src/anthropicMessages-AcNWTpYO.js +0 -115
- package/dist/src/anthropicMessages-BUtvzbpL.js +0 -114
- package/dist/src/anthropicMessages-DTWhZDCd.js +0 -114
- package/dist/src/anthropicMessages-lGVnSgyx.cjs +0 -114
- package/dist/src/app/assets/index-CyEI5aDN.js +0 -392
- package/dist/src/audio-BE_Duiu1.js +0 -104
- package/dist/src/audio-CiUd00k2.cjs +0 -104
- package/dist/src/audio-Dop6omna.js +0 -105
- package/dist/src/audio-EZNTInr_.js +0 -104
- package/dist/src/authoritativeMarkupInjection-BUqH6hNk.js +0 -78
- package/dist/src/authoritativeMarkupInjection-BmbJdJO0.cjs +0 -78
- package/dist/src/authoritativeMarkupInjection-Cpz12Y3w.js +0 -78
- package/dist/src/authoritativeMarkupInjection-W4XfcH91.js +0 -79
- package/dist/src/aws-B2Jqbnet.js +0 -2433
- package/dist/src/aws-DHtuUIzQ.js +0 -1149
- package/dist/src/aws-DLqXP6wY.js +0 -2433
- package/dist/src/aws-DfduhmwL.cjs +0 -2454
- package/dist/src/base-B9L2Xvpc.js +0 -255
- package/dist/src/base-BTZnIsuH.cjs +0 -305
- package/dist/src/base-BhaWNQPJ.js +0 -462
- package/dist/src/base-Br-G_Xou.js +0 -256
- package/dist/src/base-Bzo8hiUS.cjs +0 -467
- package/dist/src/base-C82fd2jq.js +0 -463
- package/dist/src/base-CRdQwC1W.js +0 -462
- package/dist/src/base-CjGwZNOQ.js +0 -255
- package/dist/src/bedrock-BdMru_ro.js +0 -1300
- package/dist/src/bedrock-CBUmfLX1.cjs +0 -2
- package/dist/src/bedrock-DBDxBaF9.js +0 -2
- package/dist/src/bedrock-DDrECM21.js +0 -1
- package/dist/src/bedrock-DVwkgvRS.js +0 -1
- package/dist/src/bestOfN-AKF5beq4.js +0 -159
- package/dist/src/bestOfN-C1UIVGJV.js +0 -160
- package/dist/src/bestOfN-DlkETbXy.cjs +0 -161
- package/dist/src/bestOfN-XIfEgU-g.js +0 -159
- package/dist/src/cache-BZaVoKaA.js +0 -2
- package/dist/src/cache-CEYhFUsH.js +0 -741
- package/dist/src/cache-Cbw1zH6q.js +0 -782
- package/dist/src/cache-CdaZNb75.js +0 -754
- package/dist/src/cache-DpuIzPxh.cjs +0 -856
- package/dist/src/cerebras-Bpn6FPkJ.js +0 -97
- package/dist/src/cerebras-CqJ0BRCJ.cjs +0 -97
- package/dist/src/cerebras-D4ILa_TY.js +0 -97
- package/dist/src/cerebras-DR8uc7ee.js +0 -98
- package/dist/src/chat-B7PZfaYp.cjs +0 -987
- package/dist/src/chat-BVuSjdEb.js +0 -227
- package/dist/src/chat-BsaZRjXN.js +0 -76
- package/dist/src/chat-C5liqe3Y.js +0 -226
- package/dist/src/chat-C9hyHf5B.js +0 -124
- package/dist/src/chat-CFLalAck.js +0 -226
- package/dist/src/chat-CN8JGrHu.js +0 -76
- package/dist/src/chat-CaHBBpCb.js +0 -123
- package/dist/src/chat-CcbLSghx.js +0 -123
- package/dist/src/chat-CoSN6sr2.js +0 -934
- package/dist/src/chat-CsJRFX8a.cjs +0 -226
- package/dist/src/chat-DFoZLvO_.js +0 -934
- package/dist/src/chat-DiLQvL7r.js +0 -77
- package/dist/src/chat-F6qVSDk3.cjs +0 -123
- package/dist/src/chat-Oq4FaJgI.cjs +0 -76
- package/dist/src/chat-knMfQUKz.js +0 -935
- package/dist/src/claude-agent-sdk-CJkOLpnI.js +0 -999
- package/dist/src/claude-agent-sdk-Ckn76PRD.js +0 -999
- package/dist/src/claude-agent-sdk-DX0gTr11.cjs +0 -1005
- package/dist/src/claude-agent-sdk-LMeikxoR.js +0 -1000
- package/dist/src/client-BFf1r6Z8.js +0 -352
- package/dist/src/client-CdXyDdDi.js +0 -351
- package/dist/src/client-DV8XMu7i.js +0 -351
- package/dist/src/client-iEXtOBKW.cjs +0 -357
- package/dist/src/cloud-B02qcpjf.js +0 -2
- package/dist/src/cloud-BlHP-g1v.cjs +0 -666
- package/dist/src/cloud-C9BI4isF.js +0 -287
- package/dist/src/cloud-CTTLNdvj.js +0 -657
- package/dist/src/cloud-D5X5yQ_d.js +0 -599
- package/dist/src/cloud-QxPkpsHA.js +0 -599
- package/dist/src/cloudflare-ai-DRTRT1fc.js +0 -132
- package/dist/src/cloudflare-ai-DgaXapAV.cjs +0 -133
- package/dist/src/cloudflare-ai-DkuJXijS.js +0 -134
- package/dist/src/cloudflare-ai-wy9QCHku.js +0 -133
- package/dist/src/cloudflare-gateway-9cAN8g29.cjs +0 -276
- package/dist/src/cloudflare-gateway-BVFMD292.js +0 -277
- package/dist/src/cloudflare-gateway-BuUI4p6I.js +0 -276
- package/dist/src/cloudflare-gateway-TlYHizbW.js +0 -276
- package/dist/src/codex-app-server-BPz_feug.cjs +0 -2162
- package/dist/src/codex-app-server-C9noXM9C.js +0 -2155
- package/dist/src/codex-app-server-CEmD-Y5U.js +0 -2
- package/dist/src/codex-app-server-DZolc18r.js +0 -2156
- package/dist/src/codex-app-server-Dd0A37nO.js +0 -2155
- package/dist/src/codex-sdk-BbxjBvBk.cjs +0 -1588
- package/dist/src/codex-sdk-BpXeIs-_.js +0 -1557
- package/dist/src/codex-sdk-BtQp5X0f.js +0 -1552
- package/dist/src/codex-sdk-CH0v9Bk1.js +0 -2
- package/dist/src/codex-sdk-CgrN7JB8.js +0 -1557
- package/dist/src/codex-security-B5fENNUr.js +0 -406
- package/dist/src/codex-security-C6uuJx-y.cjs +0 -411
- package/dist/src/codex-security-CifWtZR_.js +0 -407
- package/dist/src/codex-security-Kg2bOEKy.js +0 -406
- package/dist/src/cometapi-BFpIDLIx.js +0 -55
- package/dist/src/cometapi-C6O2PIrN.js +0 -56
- package/dist/src/cometapi-D5Yupc6F.js +0 -53
- package/dist/src/cometapi-DzgIwJzJ.cjs +0 -55
- package/dist/src/compatible-0jhmVfOp.js +0 -25
- package/dist/src/compatible-DdtwWdJi.cjs +0 -24
- package/dist/src/compatible-Di4nR3sU.js +0 -24
- package/dist/src/compatible-iJKLWdnf.js +0 -24
- package/dist/src/completion-B0_hVUDG.js +0 -119
- package/dist/src/completion-BdI6v0-Q.cjs +0 -123
- package/dist/src/completion-CWcJscwv.js +0 -118
- package/dist/src/conversationScoring-99EOPJRa.js +0 -373
- package/dist/src/conversationScoring-BIq4J0Cq.js +0 -374
- package/dist/src/conversationScoring-DARyeATr.cjs +0 -398
- package/dist/src/conversationScoring-DS48t4Hb.js +0 -373
- package/dist/src/crescendo-CebvXIu4.js +0 -730
- package/dist/src/crescendo-CxrLS0oo.js +0 -732
- package/dist/src/crescendo-DZQXBSkj.js +0 -733
- package/dist/src/crescendo-wjEx68uD.cjs +0 -734
- package/dist/src/custom-BiQ-aUNw.cjs +0 -620
- package/dist/src/custom-ByyB5Z93.js +0 -619
- package/dist/src/custom-C5jOevNb.js +0 -617
- package/dist/src/custom-CCrsCz8o.js +0 -618
- package/dist/src/dataUrl-C9J7wz9H.js +0 -3133
- package/dist/src/dataUrl-CGsBT7UZ.cjs +0 -3187
- package/dist/src/dataUrl-CzKvvWNO.js +0 -2868
- package/dist/src/decisions-BTusXCUx.cjs +0 -514
- package/dist/src/decisions-BYtL9edD.js +0 -515
- package/dist/src/decisions-jYix_gCF.js +0 -515
- package/dist/src/decisions-nxxfHRAN.js +0 -516
- package/dist/src/docker-DDIv4zkg.js +0 -93
- package/dist/src/docker-DVLp_5OG.js +0 -94
- package/dist/src/docker-INm9w0SY.cjs +0 -94
- package/dist/src/docker-sGuoCul_.js +0 -95
- package/dist/src/embedding-CAhqLLrR.js +0 -82
- package/dist/src/embedding-D94GAsti.cjs +0 -86
- package/dist/src/embedding-zb4MAzQy.js +0 -81
- package/dist/src/envoy-BMPszwEa.cjs +0 -60
- package/dist/src/envoy-Bp-s39_8.js +0 -60
- package/dist/src/envoy-BswDt-Ou.js +0 -61
- package/dist/src/envoy-rVbYcV80.js +0 -60
- package/dist/src/eval-B1-XfrC7.js +0 -2
- package/dist/src/eval-pC4qCvLw.js +0 -1920
- package/dist/src/evalResult-CzjCb5bd.js +0 -1300
- package/dist/src/evaluator-CNq2K7J_.js +0 -10578
- package/dist/src/evaluator-LtfxdxEu.js +0 -2
- package/dist/src/evaluatorHelpers-C5J0NYpQ.js +0 -601
- package/dist/src/evaluatorHelpers-DcdCglCs.cjs +0 -622
- package/dist/src/evaluatorHelpers-Rvb88W6B.js +0 -600
- package/dist/src/fetch-5HtnNhHg.js +0 -1556
- package/dist/src/fetch-BCwjoIFd.js +0 -1559
- package/dist/src/fetch-BhfUnKen.js +0 -1280
- package/dist/src/fetch-C08w4vVl.js +0 -9
- package/dist/src/fetch-DBxy8Tlb.cjs +0 -14
- package/dist/src/fetch-DYte6oQX.cjs +0 -1853
- package/dist/src/fetch-ElpfcAVG.js +0 -10
- package/dist/src/fetch-lM1OIaSt.js +0 -2
- package/dist/src/functionCallbackUtils-BCAdWfHO.js +0 -246
- package/dist/src/functionCallbackUtils-BYq9qOhG.js +0 -245
- package/dist/src/functionCallbackUtils-ByWkmVud.cjs +0 -262
- package/dist/src/functionCallbackUtils-D_C_JaFd.js +0 -245
- package/dist/src/gemini-image-CAlwaJhZ.js +0 -471
- package/dist/src/gemini-image-DJoVoOnZ.cjs +0 -471
- package/dist/src/gemini-image-Waio-9Xx.js +0 -472
- package/dist/src/gemini-image-vbY6Ftbf.js +0 -471
- package/dist/src/goat-BWbtyY9c.js +0 -512
- package/dist/src/goat-CXzzeCOQ.cjs +0 -515
- package/dist/src/goat-CfgvzSgZ.js +0 -514
- package/dist/src/goat-DLeoIHBp.js +0 -515
- package/dist/src/goblin-CmfCfwqk.cjs +0 -22
- package/dist/src/goblin-CtcaORRH.js +0 -22
- package/dist/src/goblin-DF6DDhM-.js +0 -22
- package/dist/src/goblin-Nai0xxBV.js +0 -23
- package/dist/src/google-ClpkLtKL.cjs +0 -142
- package/dist/src/google-CrFgKu9k.js +0 -143
- package/dist/src/google-Dj_EIBqS.js +0 -142
- package/dist/src/google-e4-vARv6.js +0 -142
- package/dist/src/graders-BN1IIa71.js +0 -15470
- package/dist/src/graders-C5sCfSP5.js +0 -2
- package/dist/src/hydra-B7RfXVBK.js +0 -2
- package/dist/src/hydra-C1cFN-Jg.js +0 -613
- package/dist/src/hydra-CK6Uc1ia.js +0 -612
- package/dist/src/hydra-Dg65rAP_.js +0 -610
- package/dist/src/hydra-Fqx8l_Xu.cjs +0 -612
- package/dist/src/image-BdlUDAtp.js +0 -163
- package/dist/src/image-C-KwEhwt.cjs +0 -163
- package/dist/src/image-C76fp6NK.cjs +0 -209
- package/dist/src/image-D75ehv3D.js +0 -482
- package/dist/src/image-DKtc5v5W.js +0 -209
- package/dist/src/image-DT_xOkJY.js +0 -163
- package/dist/src/image-DVpdllEE.js +0 -209
- package/dist/src/image-DXZ8AzMf.js +0 -481
- package/dist/src/image-DZl_1mvy.js +0 -164
- package/dist/src/image-DcTD7Ak0.cjs +0 -504
- package/dist/src/image-ndxEvBKB.js +0 -210
- package/dist/src/indirectWebPwn-70WA5x_q.js +0 -435
- package/dist/src/indirectWebPwn-BRVyd3qV.cjs +0 -463
- package/dist/src/indirectWebPwn-BsJVsu0q.js +0 -285
- package/dist/src/indirectWebPwn-Cw6yJu0i.js +0 -285
- package/dist/src/indirectWebPwn-D-PhJzo4.js +0 -286
- package/dist/src/indirectWebPwn-DRPHt2I8.js +0 -434
- package/dist/src/indirectWebPwn-DXtfFhd9.cjs +0 -285
- package/dist/src/indirectWebPwn-DvpNouzc.js +0 -434
- package/dist/src/interactions-5ixfW7Cl.js +0 -850
- package/dist/src/interactions-BOUzfmg1.cjs +0 -850
- package/dist/src/interactions-CSSXcGNc.js +0 -851
- package/dist/src/interactions-WB_sgkN0.js +0 -850
- package/dist/src/iterative-BShRNqjC.cjs +0 -549
- package/dist/src/iterative-BcW_ELtB.js +0 -548
- package/dist/src/iterative-BpHbHz8B.js +0 -547
- package/dist/src/iterative-YcchP12d.js +0 -545
- package/dist/src/iterativeImage-BMFE5Hl7.cjs +0 -419
- package/dist/src/iterativeImage-CkSaYLMY.js +0 -417
- package/dist/src/iterativeImage-DAEUlQX_.js +0 -418
- package/dist/src/iterativeImage-DeUSkEnj.js +0 -417
- package/dist/src/iterativeMeta-DbdaKdEO.cjs +0 -439
- package/dist/src/iterativeMeta-DcF9JWEK.js +0 -437
- package/dist/src/iterativeMeta-DkfPqWIC.js +0 -439
- package/dist/src/iterativeMeta-DkrpnVSs.js +0 -440
- package/dist/src/iterativeTree-CEMY1FhE.cjs +0 -879
- package/dist/src/iterativeTree-Cv5W4tX9.js +0 -877
- package/dist/src/iterativeTree-DGvomd3M.js +0 -876
- package/dist/src/iterativeTree-KbtC2Mkz.js +0 -878
- package/dist/src/knowledgeBase-AYRXn4wO.js +0 -163
- package/dist/src/knowledgeBase-BNqQfx01.js +0 -163
- package/dist/src/knowledgeBase-C0IaCCVs.js +0 -164
- package/dist/src/knowledgeBase-C2uj6wK4.cjs +0 -163
- package/dist/src/litellm-CN1ScAwZ.js +0 -147
- package/dist/src/litellm-CTjwiKSa.js +0 -146
- package/dist/src/litellm-Cd4Nj5ue.js +0 -145
- package/dist/src/litellm-DMqLpEBg.cjs +0 -146
- package/dist/src/live-Bt50-InO.cjs +0 -891
- package/dist/src/live-Bu2ujadG.js +0 -2
- package/dist/src/live-C3M52i3p.js +0 -891
- package/dist/src/live-CRfHMO3B.js +0 -892
- package/dist/src/live-iCIpO14m.js +0 -891
- package/dist/src/luma-ray-B8eHC4c8.cjs +0 -309
- package/dist/src/luma-ray-BIvkPw0s.js +0 -309
- package/dist/src/luma-ray-ChsiBxMA.js +0 -309
- package/dist/src/luma-ray-DAvKrInz.js +0 -310
- package/dist/src/mantleChat-5YeEXAZI.js +0 -154
- package/dist/src/mantleChat-D--mW3hl.js +0 -154
- package/dist/src/mantleChat-DHP3siNg.cjs +0 -154
- package/dist/src/mantleChat-wBfAX46o.js +0 -155
- package/dist/src/mcp-49jlEcTQ.js +0 -85
- package/dist/src/mcp-__PIz81I.js +0 -84
- package/dist/src/memoryPoisoning-Chxge74M.js +0 -111
- package/dist/src/memoryPoisoning-QH6NCUVE.js +0 -112
- package/dist/src/memoryPoisoning-tCxZt8Nz.js +0 -111
- package/dist/src/memoryPoisoning-ymrRItRR.cjs +0 -111
- package/dist/src/messages-BE_eZ7NA.js +0 -1127
- package/dist/src/messages-Bo638ShI.js +0 -1127
- package/dist/src/messages-BzR0-NQ1.js +0 -1128
- package/dist/src/messages-Cbg5Pfd0.cjs +0 -1161
- package/dist/src/mischievousUser-BtED2Z5Z.cjs +0 -51
- package/dist/src/mischievousUser-KqSOjrDJ.js +0 -51
- package/dist/src/mischievousUser-YMD41YNZ.js +0 -51
- package/dist/src/mischievousUser-zBxlNdCu.js +0 -52
- package/dist/src/modelslab-B8gZxtfE.js +0 -171
- package/dist/src/modelslab-C7bmVpTB.js +0 -170
- package/dist/src/modelslab-CCeQCTZg.js +0 -170
- package/dist/src/modelslab-CvBJGv7y.cjs +0 -170
- package/dist/src/nova-reel-BOEWsEKA.cjs +0 -272
- package/dist/src/nova-reel-BtyBXq5M.js +0 -273
- package/dist/src/nova-reel-C1eF3-EE.js +0 -272
- package/dist/src/nova-reel-YhgrxEKT.js +0 -272
- package/dist/src/nova-sonic-BaERP20w.js +0 -374
- package/dist/src/nova-sonic-CxgM3O-P.cjs +0 -374
- package/dist/src/nova-sonic-DJS22fC3.js +0 -375
- package/dist/src/nova-sonic-DwvwHyRX.js +0 -374
- package/dist/src/novita-D1l2tG0O.js +0 -116
- package/dist/src/novita-D84VM3v0.cjs +0 -115
- package/dist/src/novita-DGInvwfR.js +0 -115
- package/dist/src/novita-vXHkXhTg.js +0 -114
- package/dist/src/nscale-CU0Ldr00.js +0 -209
- package/dist/src/nscale-ClfKlQeM.cjs +0 -209
- package/dist/src/nscale-DxaVnF0x.js +0 -210
- package/dist/src/nscale-_poVxIrO.js +0 -207
- package/dist/src/openaiResponses-CJGsneNj.js +0 -317
- package/dist/src/openaiResponses-CKSl5Sdg.js +0 -319
- package/dist/src/openaiResponses-DC8rzFUc.js +0 -318
- package/dist/src/openaiResponses-rMHIA3dV.cjs +0 -318
- package/dist/src/openclaw-CCbvsNFW.cjs +0 -1344
- package/dist/src/openclaw-CZw1lCDZ.js +0 -1336
- package/dist/src/openclaw-ChFLgC-a.js +0 -1338
- package/dist/src/openclaw-DrPMoRrH.js +0 -1337
- package/dist/src/opencode-sdk-2EfIDhFp.cjs +0 -1018
- package/dist/src/opencode-sdk-CHw3F845.js +0 -1013
- package/dist/src/opencode-sdk-D0EGGxvy.js +0 -1012
- package/dist/src/opencode-sdk-jSS7NI2Q.js +0 -1012
- package/dist/src/openinterpreter-CY622xHC.js +0 -431
- package/dist/src/openinterpreter-DATyhuhP.js +0 -432
- package/dist/src/openinterpreter-DDUMyIf1.js +0 -431
- package/dist/src/openinterpreter-s5Tz6Lid.cjs +0 -435
- package/dist/src/pricing-C498twd2.js +0 -976
- package/dist/src/pricing-DBd_bMIh.cjs +0 -999
- package/dist/src/pricing-ISrMCskv.js +0 -976
- package/dist/src/promptfoo-6p0WG2ih.js +0 -286
- package/dist/src/promptfoo-BQRfgNs_.js +0 -285
- package/dist/src/promptfoo-Bqo88z20.cjs +0 -341
- package/dist/src/promptfoo-Cq5AVI3I.js +0 -286
- package/dist/src/providers-ATbeMX5E.cjs +0 -24180
- package/dist/src/providers-B7F1FiNI.js +0 -2
- package/dist/src/providers-DazIw8mI.js +0 -24039
- package/dist/src/providers-QvGlNAD0.js +0 -24437
- package/dist/src/quiverai-BPlNcLkV.cjs +0 -325
- package/dist/src/quiverai-By99-YmJ.js +0 -325
- package/dist/src/quiverai-CmmByDqo.js +0 -325
- package/dist/src/quiverai-HZkoJJqw.js +0 -326
- package/dist/src/registry-BLTnTfjT.cjs +0 -131
- package/dist/src/registry-BMC-COHT.js +0 -132
- package/dist/src/registry-C8UZtmBp.js +0 -131
- package/dist/src/registry-CfwEUYXG.js +0 -131
- package/dist/src/remoteGeneration-Bgg6kC5V.js +0 -370
- package/dist/src/remoteGeneration-CKJFE960.cjs +0 -482
- package/dist/src/remoteGeneration-DaxwJDKv.js +0 -370
- package/dist/src/remoteGeneration-vHMGVKr1.js +0 -371
- package/dist/src/responses-BvnyIHrq.js +0 -1099
- package/dist/src/responses-CERAgvf-.js +0 -1098
- package/dist/src/responses-CwgjeuOg.cjs +0 -1109
- package/dist/src/runtimeTransform-3RF9Avyg.cjs +0 -161
- package/dist/src/runtimeTransform-C51Z5j4H.js +0 -156
- package/dist/src/runtimeTransform-CKE_Iyv8.js +0 -157
- package/dist/src/runtimeTransform-Cs11xJpj.js +0 -156
- package/dist/src/sagemaker-BJ4dOCxE.js +0 -713
- package/dist/src/sagemaker-Bt3JUAWq.js +0 -714
- package/dist/src/sagemaker-QVKyLgLF.cjs +0 -716
- package/dist/src/sagemaker-l3IB8iTs.js +0 -713
- package/dist/src/scanner-DGjIiTZ1.js +0 -1971
- package/dist/src/server-BNaLZH6u.js +0 -63
- package/dist/src/server-CBMuQul3.js +0 -189
- package/dist/src/server-CMKKIzKv.cjs +0 -74
- package/dist/src/server-CN2IS9Cs.js +0 -155
- package/dist/src/server-ua4cqbjC.js +0 -2
- package/dist/src/session-CQIjq_HZ.cjs +0 -69
- package/dist/src/session-FTlg8sEu.js +0 -62
- package/dist/src/session-GBQXtPWp.js +0 -63
- package/dist/src/session-_0-rTdwY.js +0 -62
- package/dist/src/shared-BtuO-OAM.js +0 -1927
- package/dist/src/shared-Ci78wTZX.js +0 -1928
- package/dist/src/shared-Dd3rimdM.js +0 -1929
- package/dist/src/shared-KAjFxRre.cjs +0 -2185
- package/dist/src/simulatedUser--OjW6xCx.js +0 -247
- package/dist/src/simulatedUser-D0-slRye.cjs +0 -252
- package/dist/src/simulatedUser-D1Kh_cwA.js +0 -248
- package/dist/src/slack-BX0FUevO.js +0 -144
- package/dist/src/slack-CcwXFiJE.cjs +0 -144
- package/dist/src/slack-CnfqKfXp.js +0 -145
- package/dist/src/strategies-2ntcK4tN.js +0 -2248
- package/dist/src/strategies-DZIW7Zcs.js +0 -2385
- package/dist/src/strategies-YRDF2j-N.cjs +0 -2420
- package/dist/src/telemetry-CL8CVA4p.js +0 -205
- package/dist/src/telemetry-Cix90qqz.js +0 -201
- package/dist/src/telemetry-CkmlqTjV.js +0 -205
- package/dist/src/telemetry-DQH7l5bb.js +0 -2
- package/dist/src/telemetry-DUCXc1-r.cjs +0 -216
- package/dist/src/togetherai-3yUt5Ck7.js +0 -49
- package/dist/src/togetherai-BJUByLwt.cjs +0 -49
- package/dist/src/togetherai-Bh6KZkmd.js +0 -50
- package/dist/src/togetherai-DDl9yk3b.js +0 -48
- package/dist/src/traceContext-BiJVppjT.cjs +0 -1032
- package/dist/src/traceContext-CKKluULP.js +0 -1016
- package/dist/src/traceContext-D3Sk8fO-.js +0 -1015
- package/dist/src/transcription-BoVQKIVz.js +0 -175
- package/dist/src/transcription-Bs5u8780.js +0 -175
- package/dist/src/transcription-Dl654d1p.cjs +0 -178
- package/dist/src/transcription-VEvhM1Fu.js +0 -176
- package/dist/src/transform-BAbkGpvl.js +0 -125
- package/dist/src/transform-C_j4hUH8.js +0 -126
- package/dist/src/transform-Da86hs4M.cjs +0 -154
- package/dist/src/transform-_i1raQNo.js +0 -125
- package/dist/src/typesafe-CKXBeh82.cjs +0 -253
- package/dist/src/typesafe-D3VaGeNm.js +0 -253
- package/dist/src/typesafe-DYM-SFNH.js +0 -253
- package/dist/src/typesafe-LXmSbw8F.js +0 -254
- package/dist/src/util-41rb0XHX.js +0 -743
- package/dist/src/util-B0WlHYFM.js +0 -2049
- package/dist/src/util-BD1R_PsR.js +0 -1770
- package/dist/src/util-BLbM_ItC.js +0 -395
- package/dist/src/util-C72P0iIa.js +0 -352
- package/dist/src/util-C7MpGlJ6.cjs +0 -2305
- package/dist/src/util-CCtqagKc.js +0 -286
- package/dist/src/util-CM2Ec_uY.js +0 -2051
- package/dist/src/util-CSSAWO8v.js +0 -351
- package/dist/src/util-CkQc-fx3.cjs +0 -934
- package/dist/src/util-DcOlFTFa.cjs +0 -478
- package/dist/src/util-DluGTGVB.js +0 -395
- package/dist/src/util-PfQ60chz.js +0 -743
- package/dist/src/util-f14-CPij.js +0 -396
- package/dist/src/util-l9pXX3Eu.cjs +0 -357
- package/dist/src/util-o_BnlYqS.js +0 -2050
- package/dist/src/vertex-B_-gQgzc.js +0 -2
- package/dist/src/vertex-CU4gqoYa.js +0 -854
- package/dist/src/vertex-DZ42UHb3.js +0 -848
- package/dist/src/vertex-DsYQJA0T.cjs +0 -871
- package/dist/src/vertexLive-BvIaHKGB.js +0 -55
- package/dist/src/vertexLive-CTULqNx7.js +0 -56
- package/dist/src/vertexLive-DjJ_YQBe.cjs +0 -55
- package/dist/src/vertexLive-STUGcteB.js +0 -55
- package/dist/src/video-CAQGmtEV.js +0 -703
- package/dist/src/video-_FSTWlwX.js +0 -702
- package/dist/src/video-aBPJPWdt.js +0 -702
- package/dist/src/video-gDjkWv5m.cjs +0 -706
|
@@ -0,0 +1,1016 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { c as logger } from "./logger-pCNnmVuz.js";
|
|
3
|
+
import { r as fetchWithProxy } from "./fetch-RXHsZF-J.js";
|
|
4
|
+
import { Rt as hasTraceCredentialPath } from "./tables-BONxKPrt.js";
|
|
5
|
+
import { c as getToolNameFromAttributes, l as sanitizeTraceAttributes, n as getTraceStore, s as getNormalizedToolAttributes } from "./store-DFoDZ_D2.js";
|
|
6
|
+
//#region src/tracing/providers/types.ts
|
|
7
|
+
var TraceProviderError = class extends Error {
|
|
8
|
+
statusCode;
|
|
9
|
+
retryable;
|
|
10
|
+
constructor(message, options = {}) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "TraceProviderError";
|
|
13
|
+
this.statusCode = options.statusCode;
|
|
14
|
+
this.retryable = options.retryable ?? false;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/tracing/providers/fetch.ts
|
|
19
|
+
const MAX_TRACE_RESPONSE_BYTES = 10485760;
|
|
20
|
+
function validateTraceProviderEndpoint(endpoint, providerName) {
|
|
21
|
+
let url;
|
|
22
|
+
try {
|
|
23
|
+
url = new URL(endpoint);
|
|
24
|
+
} catch {
|
|
25
|
+
throw new Error(`${providerName} provider endpoint must be a valid HTTP or HTTPS URL`);
|
|
26
|
+
}
|
|
27
|
+
const hasCredentialPath = hasTraceCredentialPath(url.pathname);
|
|
28
|
+
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password || url.search || url.hash || hasCredentialPath) throw new Error(`${providerName} provider endpoint must be an HTTP or HTTPS URL without credentials, query parameters, or fragments`);
|
|
29
|
+
}
|
|
30
|
+
async function releaseResponse(response, providerName) {
|
|
31
|
+
try {
|
|
32
|
+
await response.body?.cancel();
|
|
33
|
+
} catch (error) {
|
|
34
|
+
logger.debug(`[${providerName}Provider] Failed to release response body: ${error}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async function readLimitedResponse(response, providerName, maxResponseBytes = MAX_TRACE_RESPONSE_BYTES) {
|
|
38
|
+
const reader = response.body?.getReader();
|
|
39
|
+
if (!reader) return "";
|
|
40
|
+
const decoder = new TextDecoder();
|
|
41
|
+
let byteLength = 0;
|
|
42
|
+
let body = "";
|
|
43
|
+
while (true) {
|
|
44
|
+
const { done, value } = await reader.read();
|
|
45
|
+
if (done) return body + decoder.decode();
|
|
46
|
+
byteLength += value.byteLength;
|
|
47
|
+
if (byteLength > maxResponseBytes) {
|
|
48
|
+
await reader.cancel();
|
|
49
|
+
throw new TraceProviderError(`${providerName} trace exceeds the maximum response size`);
|
|
50
|
+
}
|
|
51
|
+
body += decoder.decode(value, { stream: true });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/tracing/providers/braintrust.ts
|
|
56
|
+
const MAX_SPANS$2 = 1e4;
|
|
57
|
+
const TRACE_ID_PATTERN$2 = /^[0-9a-f]{32}$/i;
|
|
58
|
+
const PROJECT_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
59
|
+
function timestampMs(value) {
|
|
60
|
+
if (typeof value === "number" && Number.isFinite(value)) return value < 1e10 ? Math.round(value * 1e3) : Math.round(value);
|
|
61
|
+
if (typeof value === "string") {
|
|
62
|
+
const parsed = Date.parse(value);
|
|
63
|
+
return Number.isNaN(parsed) ? void 0 : parsed;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function transformSpan$1(row, options) {
|
|
67
|
+
const spanId = row.span_id || row.id;
|
|
68
|
+
const startTime = timestampMs(row.metrics?.start) ?? timestampMs(row.created);
|
|
69
|
+
if (!spanId || startTime === void 0) return null;
|
|
70
|
+
if (options?.earliestStartTime !== void 0 && startTime < options.earliestStartTime) return null;
|
|
71
|
+
const parentSpanId = row.span_parents?.slice().reverse().find((parent) => parent && parent !== spanId);
|
|
72
|
+
const name = typeof row.span_attributes?.name === "string" ? row.span_attributes.name : "braintrust.span";
|
|
73
|
+
const isToolSpan = row.span_attributes?.type === "tool";
|
|
74
|
+
const attributes = {
|
|
75
|
+
...row.metadata,
|
|
76
|
+
...row.span_attributes,
|
|
77
|
+
...row.metrics && { "braintrust.metrics": row.metrics },
|
|
78
|
+
...row.input !== void 0 && { "braintrust.input": row.input },
|
|
79
|
+
...row.output !== void 0 && { "braintrust.output": row.output },
|
|
80
|
+
...typeof row.span_attributes?.type === "string" && { "braintrust.span.type": row.span_attributes.type },
|
|
81
|
+
...isToolSpan && getNormalizedToolAttributes(name, row.input)
|
|
82
|
+
};
|
|
83
|
+
return {
|
|
84
|
+
spanId,
|
|
85
|
+
...parentSpanId && { parentSpanId },
|
|
86
|
+
name,
|
|
87
|
+
startTime,
|
|
88
|
+
...timestampMs(row.metrics?.end) !== void 0 && { endTime: timestampMs(row.metrics?.end) },
|
|
89
|
+
attributes,
|
|
90
|
+
statusCode: row.error ? 2 : 1,
|
|
91
|
+
...row.error ? { statusMessage: String(row.error) } : {}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/** Retrieve Braintrust project traces correlated with an OpenTelemetry trace ID. */
|
|
95
|
+
var BraintrustProvider = class {
|
|
96
|
+
config;
|
|
97
|
+
id = "braintrust";
|
|
98
|
+
baseUrl;
|
|
99
|
+
projectId;
|
|
100
|
+
token;
|
|
101
|
+
constructor(config) {
|
|
102
|
+
this.config = config;
|
|
103
|
+
if (!config.endpoint) throw new Error("Braintrust provider requires endpoint configuration");
|
|
104
|
+
if (!config.projectId || !PROJECT_ID_PATTERN.test(config.projectId)) throw new Error("Braintrust provider requires a valid projectId");
|
|
105
|
+
if (!config.auth?.token) throw new Error("Braintrust provider requires an auth token");
|
|
106
|
+
validateTraceProviderEndpoint(config.endpoint, "Braintrust");
|
|
107
|
+
if (config.timeout !== void 0 && (!Number.isSafeInteger(config.timeout) || config.timeout <= 0)) throw new Error("Braintrust provider timeout must be a positive integer");
|
|
108
|
+
this.baseUrl = config.endpoint.replace(/\/$/, "");
|
|
109
|
+
this.projectId = config.projectId;
|
|
110
|
+
this.token = config.auth.token;
|
|
111
|
+
}
|
|
112
|
+
buildHeaders() {
|
|
113
|
+
const headers = { ...this.config.headers };
|
|
114
|
+
for (const header of Object.keys(headers)) if ([
|
|
115
|
+
"accept",
|
|
116
|
+
"authorization",
|
|
117
|
+
"content-type"
|
|
118
|
+
].includes(header.toLowerCase())) delete headers[header];
|
|
119
|
+
return {
|
|
120
|
+
...headers,
|
|
121
|
+
Accept: "application/json",
|
|
122
|
+
"Content-Type": "application/json",
|
|
123
|
+
Authorization: `Bearer ${this.token}`
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
async fetchTrace(traceId, options) {
|
|
127
|
+
if (!TRACE_ID_PATTERN$2.test(traceId) || /^0+$/.test(traceId)) throw new TraceProviderError("Trace ID must contain 32 hexadecimal characters");
|
|
128
|
+
const normalizedTraceId = traceId.toLowerCase();
|
|
129
|
+
const maxSpans = Math.min(options?.maxSpans ?? MAX_SPANS$2, MAX_SPANS$2);
|
|
130
|
+
const query = [
|
|
131
|
+
"SELECT id, span_id, root_span_id, span_parents, created, input, output,",
|
|
132
|
+
" error, metadata, metrics, span_attributes",
|
|
133
|
+
`FROM project_logs('${this.projectId}', shape => 'traces')`,
|
|
134
|
+
"WHERE created >= now() - INTERVAL 1 DAY",
|
|
135
|
+
` AND (metadata.trace_id = '${normalizedTraceId}'`,
|
|
136
|
+
` OR metadata.promptfoo_trace_id = '${normalizedTraceId}'`,
|
|
137
|
+
` OR metadata."promptfoo.trace_id" = '${normalizedTraceId}'`,
|
|
138
|
+
` OR root_span_id = '${normalizedTraceId}')`,
|
|
139
|
+
`LIMIT ${maxSpans}`
|
|
140
|
+
].join("\n");
|
|
141
|
+
const timeoutSignal = AbortSignal.timeout(this.config.timeout ?? 1e4);
|
|
142
|
+
const signal = options?.abortSignal ? AbortSignal.any([timeoutSignal, options.abortSignal]) : timeoutSignal;
|
|
143
|
+
const response = await fetchWithProxy(`${this.baseUrl}/btql`, {
|
|
144
|
+
disableTransientRetries: true,
|
|
145
|
+
method: "POST",
|
|
146
|
+
headers: this.buildHeaders(),
|
|
147
|
+
body: JSON.stringify({
|
|
148
|
+
query,
|
|
149
|
+
fmt: "json"
|
|
150
|
+
}),
|
|
151
|
+
redirect: "error",
|
|
152
|
+
signal
|
|
153
|
+
});
|
|
154
|
+
if (response.status === 404) {
|
|
155
|
+
await releaseResponse(response, "Braintrust");
|
|
156
|
+
throw new TraceProviderError("Braintrust BTQL endpoint returned HTTP 404; check the endpoint and project configuration", { statusCode: response.status });
|
|
157
|
+
}
|
|
158
|
+
if (!response.ok) {
|
|
159
|
+
await releaseResponse(response, "Braintrust");
|
|
160
|
+
throw new TraceProviderError(`Braintrust returned HTTP ${response.status}`, {
|
|
161
|
+
statusCode: response.status,
|
|
162
|
+
retryable: response.status === 408 || response.status === 429 || response.status >= 500
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
if (Number(response.headers.get("content-length")) > 10485760) {
|
|
166
|
+
await releaseResponse(response, "Braintrust");
|
|
167
|
+
throw new TraceProviderError("Braintrust trace exceeds the maximum response size");
|
|
168
|
+
}
|
|
169
|
+
const body = await readLimitedResponse(response, "Braintrust");
|
|
170
|
+
const result = JSON.parse(body);
|
|
171
|
+
const rows = result.rows ?? result.data;
|
|
172
|
+
if (!Array.isArray(rows)) throw new TraceProviderError("Braintrust returned an invalid query response");
|
|
173
|
+
if (rows.length === 0) return null;
|
|
174
|
+
const spans = [];
|
|
175
|
+
for (const row of rows) {
|
|
176
|
+
if (spans.length >= maxSpans) break;
|
|
177
|
+
const span = transformSpan$1(row, options);
|
|
178
|
+
if (!span) {
|
|
179
|
+
logger.warn("[BraintrustProvider] Skipping malformed span");
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
spans.push(span);
|
|
183
|
+
}
|
|
184
|
+
return spans.length > 0 ? {
|
|
185
|
+
spans,
|
|
186
|
+
fetchedAt: Date.now()
|
|
187
|
+
} : null;
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/tracing/providers/langfuse.ts
|
|
192
|
+
const MAX_SPANS$1 = 1e4;
|
|
193
|
+
const MAX_PAGE_SIZE = 1e3;
|
|
194
|
+
const TRACE_ID_PATTERN$1 = /^[0-9a-f]{32}$/i;
|
|
195
|
+
const RESERVED_ATTRIBUTE_KEY_SEGMENTS = /* @__PURE__ */ new Set([
|
|
196
|
+
"__proto__",
|
|
197
|
+
"constructor",
|
|
198
|
+
"prototype"
|
|
199
|
+
]);
|
|
200
|
+
const GEN_AI_OPERATION_NAMES = {
|
|
201
|
+
AGENT: "invoke_agent",
|
|
202
|
+
CHAIN: "invoke_workflow",
|
|
203
|
+
EMBEDDING: "embeddings",
|
|
204
|
+
GENERATION: "chat",
|
|
205
|
+
RETRIEVER: "retrieval",
|
|
206
|
+
TOOL: "execute_tool"
|
|
207
|
+
};
|
|
208
|
+
const GEN_AI_MODEL_PARAMETER_NAMES = {
|
|
209
|
+
frequency_penalty: "gen_ai.request.frequency_penalty",
|
|
210
|
+
frequencyPenalty: "gen_ai.request.frequency_penalty",
|
|
211
|
+
max_tokens: "gen_ai.request.max_tokens",
|
|
212
|
+
maxTokens: "gen_ai.request.max_tokens",
|
|
213
|
+
presence_penalty: "gen_ai.request.presence_penalty",
|
|
214
|
+
presencePenalty: "gen_ai.request.presence_penalty",
|
|
215
|
+
seed: "gen_ai.request.seed",
|
|
216
|
+
temperature: "gen_ai.request.temperature",
|
|
217
|
+
top_k: "gen_ai.request.top_k",
|
|
218
|
+
top_p: "gen_ai.request.top_p",
|
|
219
|
+
topK: "gen_ai.request.top_k",
|
|
220
|
+
topP: "gen_ai.request.top_p"
|
|
221
|
+
};
|
|
222
|
+
function parseJsonValue(value) {
|
|
223
|
+
if (typeof value !== "string") return value;
|
|
224
|
+
try {
|
|
225
|
+
return JSON.parse(value);
|
|
226
|
+
} catch {
|
|
227
|
+
return value;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
function safeAttributes(value) {
|
|
231
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
232
|
+
return Object.fromEntries(Object.entries(value).filter(([key]) => !key.split(".").some((segment) => RESERVED_ATTRIBUTE_KEY_SEGMENTS.has(segment))));
|
|
233
|
+
}
|
|
234
|
+
function firstNumericValue(...values) {
|
|
235
|
+
return values.find((value) => typeof value === "number" && Number.isFinite(value));
|
|
236
|
+
}
|
|
237
|
+
function normalizedModelParameters(value) {
|
|
238
|
+
const attributes = {};
|
|
239
|
+
for (const [name, parameter] of Object.entries(safeAttributes(value))) if (Object.prototype.hasOwnProperty.call(GEN_AI_MODEL_PARAMETER_NAMES, name) && typeof parameter === "number" && Number.isFinite(parameter)) attributes[GEN_AI_MODEL_PARAMETER_NAMES[name]] = parameter;
|
|
240
|
+
return attributes;
|
|
241
|
+
}
|
|
242
|
+
function observationOperationName(observation, attributes) {
|
|
243
|
+
const originalOperation = attributes["gen_ai.operation.name"];
|
|
244
|
+
if (typeof originalOperation === "string" && originalOperation.trim()) return originalOperation;
|
|
245
|
+
if (typeof observation.type !== "string") return;
|
|
246
|
+
if (observation.type === "GENERATION" && typeof observation.name === "string") {
|
|
247
|
+
const normalizedName = observation.name.trim().toLowerCase();
|
|
248
|
+
if (/^text[ _-]completion(?:\b|$)/.test(normalizedName)) return "text_completion";
|
|
249
|
+
if (/^generate[ _-]content(?:\b|$)/.test(normalizedName)) return "generate_content";
|
|
250
|
+
}
|
|
251
|
+
return GEN_AI_OPERATION_NAMES[observation.type];
|
|
252
|
+
}
|
|
253
|
+
function observationAttributes(observation) {
|
|
254
|
+
const metadata = safeAttributes(observation.metadata);
|
|
255
|
+
const resourceAttributes = safeAttributes(metadata.resourceAttributes);
|
|
256
|
+
const telemetryAttributes = safeAttributes(metadata.attributes);
|
|
257
|
+
const usageDetails = safeAttributes(observation.usageDetails);
|
|
258
|
+
const costDetails = safeAttributes(observation.costDetails);
|
|
259
|
+
const inputCost = costDetails.input ?? observation.calculatedInputCost ?? observation.inputCost;
|
|
260
|
+
const outputCost = costDetails.output ?? observation.calculatedOutputCost ?? observation.outputCost;
|
|
261
|
+
const totalCost = costDetails.total ?? observation.calculatedTotalCost ?? observation.totalCost;
|
|
262
|
+
const inputTokens = firstNumericValue(observation.inputUsage, usageDetails.input, usageDetails.input_tokens, usageDetails.prompt_tokens);
|
|
263
|
+
const outputTokens = firstNumericValue(observation.outputUsage, usageDetails.output, usageDetails.output_tokens, usageDetails.completion_tokens);
|
|
264
|
+
const totalTokens = firstNumericValue(observation.totalUsage, usageDetails.total, usageDetails.total_tokens);
|
|
265
|
+
const reasoningTokens = firstNumericValue(usageDetails.reasoning, usageDetails.reasoning_tokens);
|
|
266
|
+
const cacheReadTokens = firstNumericValue(usageDetails.cache_read_input_tokens, usageDetails.cached_tokens);
|
|
267
|
+
const cacheCreationTokens = firstNumericValue(usageDetails.cache_creation_input_tokens);
|
|
268
|
+
const operationName = observationOperationName(observation, {
|
|
269
|
+
...metadata,
|
|
270
|
+
...telemetryAttributes
|
|
271
|
+
});
|
|
272
|
+
const parsedInput = parseJsonValue(observation.input);
|
|
273
|
+
const parsedOutput = parseJsonValue(observation.output);
|
|
274
|
+
const observationName = typeof observation.name === "string" && observation.name.trim() ? observation.name : void 0;
|
|
275
|
+
return {
|
|
276
|
+
...resourceAttributes,
|
|
277
|
+
...metadata,
|
|
278
|
+
...normalizedModelParameters(observation.modelParameters),
|
|
279
|
+
...operationName && { "gen_ai.operation.name": operationName },
|
|
280
|
+
...typeof observation.type === "string" && { "langfuse.observation.type": observation.type },
|
|
281
|
+
...observation.input !== void 0 && { "langfuse.input": parsedInput },
|
|
282
|
+
...observation.type === "TOOL" && observationName && {
|
|
283
|
+
...getNormalizedToolAttributes(observationName, parsedInput),
|
|
284
|
+
...observation.input !== void 0 && { "gen_ai.tool.call.arguments": parsedInput },
|
|
285
|
+
...observation.output !== void 0 && { "gen_ai.tool.call.result": parsedOutput }
|
|
286
|
+
},
|
|
287
|
+
...observation.type === "AGENT" && observationName && { "gen_ai.agent.name": observationName },
|
|
288
|
+
...observation.type === "CHAIN" && observationName && { "gen_ai.workflow.name": observationName },
|
|
289
|
+
...observation.type === "EVALUATOR" && observationName && { "gen_ai.evaluation.name": observationName },
|
|
290
|
+
...observation.type === "GUARDRAIL" && observationName && { "guardrail.name": observationName },
|
|
291
|
+
...observation.output !== void 0 && { "langfuse.output": parsedOutput },
|
|
292
|
+
...typeof observation.providedModelName === "string" && { "gen_ai.request.model": observation.providedModelName },
|
|
293
|
+
...observation.modelParameters !== void 0 && observation.modelParameters !== null && { "langfuse.model.parameters": observation.modelParameters },
|
|
294
|
+
...observation.usageDetails !== void 0 && observation.usageDetails !== null && { "langfuse.usage": observation.usageDetails },
|
|
295
|
+
...inputTokens !== void 0 && { "gen_ai.usage.input_tokens": inputTokens },
|
|
296
|
+
...outputTokens !== void 0 && { "gen_ai.usage.output_tokens": outputTokens },
|
|
297
|
+
...totalTokens !== void 0 && {
|
|
298
|
+
"langfuse.usage.total_tokens": totalTokens,
|
|
299
|
+
"promptfoo.usage.total_tokens": totalTokens
|
|
300
|
+
},
|
|
301
|
+
...reasoningTokens !== void 0 && { "gen_ai.usage.reasoning.output_tokens": reasoningTokens },
|
|
302
|
+
...cacheReadTokens !== void 0 && { "gen_ai.usage.cache_read.input_tokens": cacheReadTokens },
|
|
303
|
+
...cacheCreationTokens !== void 0 && { "gen_ai.usage.cache_creation.input_tokens": cacheCreationTokens },
|
|
304
|
+
...typeof inputCost === "number" && { "langfuse.cost.input": inputCost },
|
|
305
|
+
...typeof outputCost === "number" && { "langfuse.cost.output": outputCost },
|
|
306
|
+
...typeof totalCost === "number" && { "langfuse.cost.total": totalCost },
|
|
307
|
+
...telemetryAttributes
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
function transformObservation(observation, traceId, options) {
|
|
311
|
+
if (typeof observation.id !== "string" || !observation.id || typeof observation.traceId !== "string" || observation.traceId.toLowerCase() !== traceId || typeof observation.startTime !== "string") return null;
|
|
312
|
+
const startTime = Date.parse(observation.startTime);
|
|
313
|
+
if (Number.isNaN(startTime) || options?.earliestStartTime !== void 0 && startTime < options.earliestStartTime) return null;
|
|
314
|
+
const endTime = typeof observation.endTime === "string" ? Date.parse(observation.endTime) : NaN;
|
|
315
|
+
if (observation.endTime != null && (Number.isNaN(endTime) || endTime < startTime)) return null;
|
|
316
|
+
if (observation.parentObservationId != null && (typeof observation.parentObservationId !== "string" || !observation.parentObservationId || observation.parentObservationId === observation.id)) return null;
|
|
317
|
+
return {
|
|
318
|
+
spanId: observation.id,
|
|
319
|
+
...typeof observation.parentObservationId === "string" && { parentSpanId: observation.parentObservationId },
|
|
320
|
+
name: typeof observation.name === "string" && observation.name.trim() ? observation.name : "langfuse.observation",
|
|
321
|
+
startTime,
|
|
322
|
+
...Number.isFinite(endTime) && { endTime },
|
|
323
|
+
attributes: observationAttributes(observation),
|
|
324
|
+
statusCode: observation.level === "ERROR" ? 2 : 1,
|
|
325
|
+
...typeof observation.statusMessage === "string" && observation.statusMessage && { statusMessage: observation.statusMessage }
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function addObservations(observations, spans, seenSpanIds, traceId, maxSpans, options) {
|
|
329
|
+
for (const observation of observations) {
|
|
330
|
+
if (!observation || typeof observation !== "object" || Array.isArray(observation)) {
|
|
331
|
+
logger.warn("[LangfuseProvider] Skipping malformed observation");
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
const span = transformObservation(observation, traceId, options);
|
|
335
|
+
if (!span) {
|
|
336
|
+
logger.warn("[LangfuseProvider] Skipping malformed or unrelated observation");
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
if (!seenSpanIds.has(span.spanId)) {
|
|
340
|
+
seenSpanIds.add(span.spanId);
|
|
341
|
+
spans.push(span);
|
|
342
|
+
}
|
|
343
|
+
if (spans.length >= maxSpans) return;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
function getNextCursor(response, seenCursors) {
|
|
347
|
+
const cursor = response.meta?.cursor;
|
|
348
|
+
if (cursor == null) return;
|
|
349
|
+
if (typeof cursor !== "string" || !cursor) throw new TraceProviderError("Langfuse returned an invalid pagination cursor");
|
|
350
|
+
if (seenCursors.has(cursor)) throw new TraceProviderError("Langfuse returned a repeated pagination cursor");
|
|
351
|
+
seenCursors.add(cursor);
|
|
352
|
+
return cursor;
|
|
353
|
+
}
|
|
354
|
+
function getNextPage(response) {
|
|
355
|
+
const { page, totalPages } = response.meta ?? {};
|
|
356
|
+
if (page == null && totalPages == null) return;
|
|
357
|
+
if (page === 1 && totalPages === 0 && Array.isArray(response.data) && response.data.length === 0) return;
|
|
358
|
+
if (typeof page !== "number" || !Number.isSafeInteger(page) || page < 1 || typeof totalPages !== "number" || !Number.isSafeInteger(totalPages) || totalPages < page) throw new TraceProviderError("Langfuse returned invalid pagination metadata");
|
|
359
|
+
return page < totalPages ? page + 1 : void 0;
|
|
360
|
+
}
|
|
361
|
+
/** Retrieve trace observations from Langfuse's public v2 Observations API. */
|
|
362
|
+
var LangfuseProvider = class {
|
|
363
|
+
config;
|
|
364
|
+
id = "langfuse";
|
|
365
|
+
baseUrl;
|
|
366
|
+
authorization;
|
|
367
|
+
constructor(config) {
|
|
368
|
+
this.config = config;
|
|
369
|
+
if (!config.endpoint) throw new Error("Langfuse provider requires endpoint configuration");
|
|
370
|
+
if (!config.auth?.username || !config.auth.password || config.auth.token) throw new Error("Langfuse provider requires public and secret keys as basic-auth credentials");
|
|
371
|
+
validateTraceProviderEndpoint(config.endpoint, "Langfuse");
|
|
372
|
+
if (config.timeout !== void 0 && (!Number.isSafeInteger(config.timeout) || config.timeout <= 0)) throw new Error("Langfuse provider timeout must be a positive integer");
|
|
373
|
+
this.baseUrl = config.endpoint.replace(/\/$/, "");
|
|
374
|
+
this.authorization = `Basic ${Buffer.from(`${config.auth.username}:${config.auth.password}`).toString("base64")}`;
|
|
375
|
+
}
|
|
376
|
+
buildHeaders() {
|
|
377
|
+
return {
|
|
378
|
+
...Object.fromEntries(Object.entries(this.config.headers ?? {}).filter(([name]) => !["accept", "authorization"].includes(name.toLowerCase()))),
|
|
379
|
+
Accept: "application/json",
|
|
380
|
+
Authorization: this.authorization
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
async fetchTrace(traceId, options) {
|
|
384
|
+
if (!TRACE_ID_PATTERN$1.test(traceId) || /^0+$/.test(traceId)) throw new TraceProviderError("Trace ID must contain 32 hexadecimal characters");
|
|
385
|
+
const normalizedTraceId = traceId.toLowerCase();
|
|
386
|
+
const maxSpans = Math.min(Math.max(options?.maxSpans ?? MAX_SPANS$1, 1), MAX_SPANS$1);
|
|
387
|
+
const pageSize = Math.min(maxSpans, MAX_PAGE_SIZE);
|
|
388
|
+
const timeoutSignal = AbortSignal.timeout(this.config.timeout ?? 1e4);
|
|
389
|
+
const signal = options?.abortSignal ? AbortSignal.any([timeoutSignal, options.abortSignal]) : timeoutSignal;
|
|
390
|
+
const spans = [];
|
|
391
|
+
const seenSpanIds = /* @__PURE__ */ new Set();
|
|
392
|
+
const seenCursors = /* @__PURE__ */ new Set();
|
|
393
|
+
let page;
|
|
394
|
+
let cursor;
|
|
395
|
+
let remainingBytes = MAX_TRACE_RESPONSE_BYTES;
|
|
396
|
+
do {
|
|
397
|
+
const url = new URL(`${this.baseUrl}/api/public/v2/observations`);
|
|
398
|
+
url.searchParams.set("traceId", normalizedTraceId);
|
|
399
|
+
url.searchParams.set("fields", "core,basic,io,metadata,model,usage");
|
|
400
|
+
url.searchParams.set("limit", String(pageSize));
|
|
401
|
+
if (options?.earliestStartTime !== void 0) url.searchParams.set("fromStartTime", new Date(options.earliestStartTime).toISOString());
|
|
402
|
+
if (cursor) url.searchParams.set("cursor", cursor);
|
|
403
|
+
if (page) url.searchParams.set("page", String(page));
|
|
404
|
+
const response = await fetchWithProxy(url.toString(), {
|
|
405
|
+
disableTransientRetries: true,
|
|
406
|
+
method: "GET",
|
|
407
|
+
headers: this.buildHeaders(),
|
|
408
|
+
redirect: "error",
|
|
409
|
+
signal
|
|
410
|
+
});
|
|
411
|
+
if (response.status === 404) {
|
|
412
|
+
await releaseResponse(response, "Langfuse");
|
|
413
|
+
return null;
|
|
414
|
+
}
|
|
415
|
+
if (!response.ok) {
|
|
416
|
+
await releaseResponse(response, "Langfuse");
|
|
417
|
+
throw new TraceProviderError(`Langfuse returned HTTP ${response.status}`, {
|
|
418
|
+
statusCode: response.status,
|
|
419
|
+
retryable: response.status === 408 || response.status === 429 || response.status >= 500
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
if (Number(response.headers.get("content-length")) > remainingBytes) {
|
|
423
|
+
await releaseResponse(response, "Langfuse");
|
|
424
|
+
throw new TraceProviderError("Langfuse trace exceeds the maximum response size");
|
|
425
|
+
}
|
|
426
|
+
const body = await readLimitedResponse(response, "Langfuse", remainingBytes);
|
|
427
|
+
remainingBytes -= new TextEncoder().encode(body).byteLength;
|
|
428
|
+
const result = JSON.parse(body);
|
|
429
|
+
if (!Array.isArray(result.data)) throw new TraceProviderError("Langfuse returned an invalid observations response");
|
|
430
|
+
addObservations(result.data, spans, seenSpanIds, normalizedTraceId, maxSpans, options);
|
|
431
|
+
page = getNextPage(result);
|
|
432
|
+
cursor = page ? void 0 : getNextCursor(result, seenCursors);
|
|
433
|
+
} while ((page || cursor) && spans.length < maxSpans);
|
|
434
|
+
if (spans.length === 0) return null;
|
|
435
|
+
return {
|
|
436
|
+
spans,
|
|
437
|
+
fetchedAt: Date.now()
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
//#endregion
|
|
442
|
+
//#region src/tracing/providers/tempo.ts
|
|
443
|
+
const MAX_SPANS = 1e4;
|
|
444
|
+
const SPAN_KIND_NAMES = [
|
|
445
|
+
"unspecified",
|
|
446
|
+
"internal",
|
|
447
|
+
"server",
|
|
448
|
+
"client",
|
|
449
|
+
"producer",
|
|
450
|
+
"consumer"
|
|
451
|
+
];
|
|
452
|
+
const TRACE_ID_PATTERN = /^[0-9a-f]{32}$/i;
|
|
453
|
+
const BASE64_TRACE_ID_PATTERN = /^[A-Za-z0-9+/]{22}(?:==)?$/;
|
|
454
|
+
const SPAN_ID_PATTERN = /^[0-9a-f]{16}$/i;
|
|
455
|
+
const BASE64_SPAN_ID_PATTERN = /^[A-Za-z0-9+/]{11}=?$/;
|
|
456
|
+
function nanoToMs(value) {
|
|
457
|
+
const milliseconds = BigInt(value) / 1000000n;
|
|
458
|
+
if (milliseconds < 0n || milliseconds > BigInt(Number.MAX_SAFE_INTEGER)) throw new Error("Span timestamp is outside the supported range");
|
|
459
|
+
return Number.parseInt(milliseconds.toString(), 10);
|
|
460
|
+
}
|
|
461
|
+
function extractAttributeValue(value) {
|
|
462
|
+
if (value.stringValue !== void 0) return value.stringValue;
|
|
463
|
+
if (value.intValue !== void 0) {
|
|
464
|
+
const number = Number(value.intValue);
|
|
465
|
+
return Number.isSafeInteger(number) ? number : value.intValue;
|
|
466
|
+
}
|
|
467
|
+
if (value.doubleValue !== void 0) return value.doubleValue;
|
|
468
|
+
if (value.boolValue !== void 0) return value.boolValue;
|
|
469
|
+
if (value.bytesValue !== void 0) return value.bytesValue;
|
|
470
|
+
if (value.arrayValue) return (value.arrayValue.values ?? []).map(extractAttributeValue);
|
|
471
|
+
if (value.kvlistValue) return attributesToRecord(value.kvlistValue.values);
|
|
472
|
+
}
|
|
473
|
+
function attributesToRecord(attributes) {
|
|
474
|
+
return Object.fromEntries((attributes ?? []).map(({ key, value }) => [key, extractAttributeValue(value)]));
|
|
475
|
+
}
|
|
476
|
+
function decodeId(id, hexPattern, base64Pattern, byteLength) {
|
|
477
|
+
if (!id) return;
|
|
478
|
+
if (hexPattern.test(id)) return /^0+$/.test(id) ? void 0 : id.toLowerCase();
|
|
479
|
+
if (!base64Pattern.test(id)) return;
|
|
480
|
+
const decoded = Buffer.from(id, "base64");
|
|
481
|
+
if (decoded.length !== byteLength || decoded.toString("base64").replace(/=+$/, "") !== id.replace(/=+$/, "")) return;
|
|
482
|
+
const hexId = decoded.toString("hex");
|
|
483
|
+
return /^0+$/.test(hexId) ? void 0 : hexId;
|
|
484
|
+
}
|
|
485
|
+
function normalizeStatusCode(code) {
|
|
486
|
+
if (typeof code === "number") return code;
|
|
487
|
+
if (!code) return;
|
|
488
|
+
const numeric = Number(code);
|
|
489
|
+
if (!Number.isNaN(numeric)) return numeric;
|
|
490
|
+
switch (code.toUpperCase()) {
|
|
491
|
+
case "STATUS_CODE_OK":
|
|
492
|
+
case "OK": return 1;
|
|
493
|
+
case "STATUS_CODE_ERROR":
|
|
494
|
+
case "ERROR": return 2;
|
|
495
|
+
case "STATUS_CODE_UNSET":
|
|
496
|
+
case "UNSET": return 0;
|
|
497
|
+
default: return;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
function transformSpan(span, traceId, resourceAttributes, scopeName) {
|
|
501
|
+
if (decodeId(span.traceId, TRACE_ID_PATTERN, BASE64_TRACE_ID_PATTERN, 16) !== traceId.toLowerCase()) throw new Error("Span trace ID must match the requested trace");
|
|
502
|
+
const spanId = decodeId(span.spanId, SPAN_ID_PATTERN, BASE64_SPAN_ID_PATTERN, 8);
|
|
503
|
+
if (!spanId) throw new Error("Span ID must be a valid nonzero eight-byte identifier");
|
|
504
|
+
const parentSpanId = decodeId(span.parentSpanId, SPAN_ID_PATTERN, BASE64_SPAN_ID_PATTERN, 8);
|
|
505
|
+
if (span.parentSpanId && !parentSpanId) throw new Error("Parent span ID must be a valid nonzero eight-byte identifier");
|
|
506
|
+
if (typeof span.name !== "string" || span.name.trim().length === 0) throw new Error("Span name must be a nonempty string");
|
|
507
|
+
if (span.status?.message !== void 0 && typeof span.status.message !== "string") throw new Error("Span status message must be a string");
|
|
508
|
+
const startTime = nanoToMs(span.startTimeUnixNano);
|
|
509
|
+
const endTimeUnixNano = span.endTimeUnixNano;
|
|
510
|
+
const endTime = endTimeUnixNano ? nanoToMs(endTimeUnixNano) : void 0;
|
|
511
|
+
if (endTimeUnixNano && BigInt(endTimeUnixNano) < BigInt(span.startTimeUnixNano)) throw new Error("Span end time must not precede its start time");
|
|
512
|
+
return {
|
|
513
|
+
spanId,
|
|
514
|
+
parentSpanId,
|
|
515
|
+
name: span.name,
|
|
516
|
+
startTime,
|
|
517
|
+
endTime,
|
|
518
|
+
attributes: {
|
|
519
|
+
...resourceAttributes,
|
|
520
|
+
...attributesToRecord(span.attributes),
|
|
521
|
+
...scopeName && { "otel.scope.name": scopeName },
|
|
522
|
+
...typeof span.kind === "number" && {
|
|
523
|
+
"otel.span.kind": SPAN_KIND_NAMES[span.kind] ?? "unspecified",
|
|
524
|
+
"otel.span.kind_code": span.kind
|
|
525
|
+
},
|
|
526
|
+
...typeof span.kind === "string" && { "otel.span.kind": span.kind.replace(/^SPAN_KIND_/i, "").toLowerCase() }
|
|
527
|
+
},
|
|
528
|
+
statusCode: normalizeStatusCode(span.status?.code),
|
|
529
|
+
statusMessage: span.status?.message
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
var TempoProvider = class {
|
|
533
|
+
config;
|
|
534
|
+
id = "tempo";
|
|
535
|
+
baseUrl;
|
|
536
|
+
constructor(config) {
|
|
537
|
+
this.config = config;
|
|
538
|
+
if (!config.endpoint) throw new Error("Tempo provider requires endpoint configuration");
|
|
539
|
+
validateTraceProviderEndpoint(config.endpoint, "Tempo");
|
|
540
|
+
if (config.timeout !== void 0 && (!Number.isSafeInteger(config.timeout) || config.timeout <= 0)) throw new Error("Tempo provider timeout must be a positive integer");
|
|
541
|
+
this.baseUrl = config.endpoint.replace(/\/$/, "");
|
|
542
|
+
}
|
|
543
|
+
buildHeaders() {
|
|
544
|
+
const headers = { ...this.config.headers };
|
|
545
|
+
const hasConfiguredAuthentication = Boolean(this.config.auth?.token || this.config.auth?.username && this.config.auth?.password);
|
|
546
|
+
for (const header of Object.keys(headers)) {
|
|
547
|
+
const normalizedHeader = header.toLowerCase();
|
|
548
|
+
if (normalizedHeader === "accept" || hasConfiguredAuthentication && normalizedHeader === "authorization") delete headers[header];
|
|
549
|
+
}
|
|
550
|
+
headers.Accept = "application/json";
|
|
551
|
+
if (this.config.auth?.token) headers.Authorization = `Bearer ${this.config.auth.token}`;
|
|
552
|
+
else if (this.config.auth?.username && this.config.auth?.password) headers.Authorization = `Basic ${Buffer.from(`${this.config.auth.username}:${this.config.auth.password}`).toString("base64")}`;
|
|
553
|
+
return headers;
|
|
554
|
+
}
|
|
555
|
+
transformSpans(data, traceId) {
|
|
556
|
+
const spans = [];
|
|
557
|
+
const seenSpanIds = /* @__PURE__ */ new Set();
|
|
558
|
+
let malformedSpans = 0;
|
|
559
|
+
for (const batch of data.batches ?? []) {
|
|
560
|
+
if (!batch || !Array.isArray(batch.scopeSpans)) {
|
|
561
|
+
malformedSpans++;
|
|
562
|
+
continue;
|
|
563
|
+
}
|
|
564
|
+
const resourceAttributes = attributesToRecord(batch.resource?.attributes);
|
|
565
|
+
for (const scopeSpan of batch.scopeSpans) {
|
|
566
|
+
if (!scopeSpan || !Array.isArray(scopeSpan.spans)) {
|
|
567
|
+
malformedSpans++;
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
for (const span of scopeSpan.spans) {
|
|
571
|
+
if (spans.length >= MAX_SPANS) return spans;
|
|
572
|
+
try {
|
|
573
|
+
const normalizedSpan = transformSpan(span, traceId, resourceAttributes, scopeSpan.scope?.name);
|
|
574
|
+
if (normalizedSpan && !seenSpanIds.has(normalizedSpan.spanId)) {
|
|
575
|
+
seenSpanIds.add(normalizedSpan.spanId);
|
|
576
|
+
spans.push(normalizedSpan);
|
|
577
|
+
}
|
|
578
|
+
} catch {
|
|
579
|
+
malformedSpans++;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
if (malformedSpans > 0) logger.warn(`[TempoProvider] Skipped ${malformedSpans} malformed spans`);
|
|
585
|
+
return spans;
|
|
586
|
+
}
|
|
587
|
+
async fetchTrace(traceId, options) {
|
|
588
|
+
if (!TRACE_ID_PATTERN.test(traceId) || /^0+$/.test(traceId)) throw new TraceProviderError("Trace ID must contain 32 hexadecimal characters");
|
|
589
|
+
const timeoutSignal = AbortSignal.timeout(this.config.timeout ?? 1e4);
|
|
590
|
+
const signal = options?.abortSignal ? AbortSignal.any([timeoutSignal, options.abortSignal]) : timeoutSignal;
|
|
591
|
+
const response = await fetchWithProxy(`${this.baseUrl}/api/traces/${traceId}`, {
|
|
592
|
+
disableTransientRetries: true,
|
|
593
|
+
method: "GET",
|
|
594
|
+
headers: this.buildHeaders(),
|
|
595
|
+
redirect: "error",
|
|
596
|
+
signal
|
|
597
|
+
});
|
|
598
|
+
if (response.status === 404) {
|
|
599
|
+
await releaseResponse(response, "Tempo");
|
|
600
|
+
return null;
|
|
601
|
+
}
|
|
602
|
+
if (!response.ok) {
|
|
603
|
+
await releaseResponse(response, "Tempo");
|
|
604
|
+
throw new TraceProviderError(`Tempo returned HTTP ${response.status}`, {
|
|
605
|
+
statusCode: response.status,
|
|
606
|
+
retryable: response.status === 408 || response.status === 429 || response.status >= 500
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
if (Number(response.headers.get("content-length")) > 10485760) {
|
|
610
|
+
await releaseResponse(response, "Tempo");
|
|
611
|
+
throw new TraceProviderError("Tempo trace exceeds the maximum response size");
|
|
612
|
+
}
|
|
613
|
+
const body = await readLimitedResponse(response, "Tempo");
|
|
614
|
+
const data = JSON.parse(body);
|
|
615
|
+
if (!Array.isArray(data.batches)) throw new TraceProviderError("Tempo returned an invalid trace response");
|
|
616
|
+
return {
|
|
617
|
+
spans: this.transformSpans(data, traceId),
|
|
618
|
+
fetchedAt: Date.now()
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
};
|
|
622
|
+
//#endregion
|
|
623
|
+
//#region src/tracing/providers/index.ts
|
|
624
|
+
/**
|
|
625
|
+
* Create a trace provider instance based on configuration.
|
|
626
|
+
*
|
|
627
|
+
* @param config - Provider configuration specifying type and connection details
|
|
628
|
+
* @returns A TraceProvider instance for the specified backend
|
|
629
|
+
* @throws Error if the provider type is not supported or misconfigured
|
|
630
|
+
*/
|
|
631
|
+
function createTraceProvider(config) {
|
|
632
|
+
switch (config.id) {
|
|
633
|
+
case "braintrust": return new BraintrustProvider(config);
|
|
634
|
+
case "langfuse": return new LangfuseProvider(config);
|
|
635
|
+
case "tempo": return new TempoProvider(config);
|
|
636
|
+
case "local": throw new Error("Local provider id should use TraceStore directly, not createTraceProvider()");
|
|
637
|
+
default: throw new Error(`Unknown trace provider id: ${config.id}`);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Check if a provider configuration specifies an external backend.
|
|
642
|
+
* Returns true if the config has an id other than 'local' and has an endpoint.
|
|
643
|
+
*
|
|
644
|
+
* @param config - Optional provider configuration
|
|
645
|
+
* @returns true if this is an external provider (Tempo, Jaeger, etc.)
|
|
646
|
+
*/
|
|
647
|
+
function isExternalTraceProvider(config) {
|
|
648
|
+
return !!config && config.id !== "local" && !!config.endpoint;
|
|
649
|
+
}
|
|
650
|
+
//#endregion
|
|
651
|
+
//#region src/tracing/traceContext.ts
|
|
652
|
+
const DEFAULT_MAX_RETRIES = 3;
|
|
653
|
+
const DEFAULT_RETRY_DELAY_MS = 500;
|
|
654
|
+
const DEFAULT_QUERY_DELAY_MS = 3e3;
|
|
655
|
+
const EXTERNAL_SPAN_BATCH_SIZE = 500;
|
|
656
|
+
const inFlightExternalFetches = /* @__PURE__ */ new WeakMap();
|
|
657
|
+
const SPAN_KIND_MAP = {
|
|
658
|
+
0: "unspecified",
|
|
659
|
+
1: "internal",
|
|
660
|
+
2: "server",
|
|
661
|
+
3: "client",
|
|
662
|
+
4: "producer",
|
|
663
|
+
5: "consumer"
|
|
664
|
+
};
|
|
665
|
+
function resolveSpanKind(span) {
|
|
666
|
+
const attributes = span.attributes || {};
|
|
667
|
+
const attributeKind = attributes["span.kind"] || attributes["otel.span.kind"] || attributes["spanKind"] || attributes["kind"];
|
|
668
|
+
if (attributeKind) return `${attributeKind}`.toLowerCase();
|
|
669
|
+
const numericKind = attributes["otel.span.kind_code"];
|
|
670
|
+
if (typeof numericKind === "number" && numericKind in SPAN_KIND_MAP) return SPAN_KIND_MAP[numericKind];
|
|
671
|
+
return "unspecified";
|
|
672
|
+
}
|
|
673
|
+
function mapStatusCode(span) {
|
|
674
|
+
switch (span.statusCode) {
|
|
675
|
+
case 1: return "ok";
|
|
676
|
+
case 2: return "error";
|
|
677
|
+
default: return "unset";
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
function createTraceSpans(spans) {
|
|
681
|
+
const spansById = new Map(spans.map((span) => [span.spanId, span]));
|
|
682
|
+
const depthMap = /* @__PURE__ */ new Map();
|
|
683
|
+
return spans.map((span) => {
|
|
684
|
+
const durationMs = Math.max(0, (span.endTime ?? span.startTime) - span.startTime);
|
|
685
|
+
return {
|
|
686
|
+
spanId: span.spanId,
|
|
687
|
+
parentSpanId: span.parentSpanId,
|
|
688
|
+
name: span.name,
|
|
689
|
+
kind: resolveSpanKind(span),
|
|
690
|
+
startTime: span.startTime,
|
|
691
|
+
endTime: span.endTime,
|
|
692
|
+
durationMs,
|
|
693
|
+
attributes: span.attributes || {},
|
|
694
|
+
status: {
|
|
695
|
+
code: mapStatusCode(span),
|
|
696
|
+
message: span.statusMessage
|
|
697
|
+
},
|
|
698
|
+
depth: computeSpanDepth(span, spansById, depthMap) ?? 0,
|
|
699
|
+
events: []
|
|
700
|
+
};
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
function deriveInsights(traceSpans) {
|
|
704
|
+
if (traceSpans.length === 0) return [];
|
|
705
|
+
const insights = [];
|
|
706
|
+
traceSpans.filter((span) => span.status.code === "error").forEach((span) => {
|
|
707
|
+
const statusMessage = span.status.message ? `: ${span.status.message}` : "";
|
|
708
|
+
insights.push(`Error span "${span.name}" (${span.spanId.slice(0, 8)})${statusMessage}`);
|
|
709
|
+
});
|
|
710
|
+
traceSpans.map((span) => ({
|
|
711
|
+
span,
|
|
712
|
+
toolName: getToolNameFromAttributes(span.attributes)
|
|
713
|
+
})).filter((entry) => entry.toolName).forEach(({ span, toolName }) => {
|
|
714
|
+
insights.push(`Tool call ${toolName} via "${span.name}" (duration ${span.durationMs ?? 0}ms)`);
|
|
715
|
+
});
|
|
716
|
+
traceSpans.filter((span) => span.attributes["guardrail.name"] || span.attributes["guardrails.decision"]).forEach((span) => {
|
|
717
|
+
const decision = span.attributes["guardrails.decision"] ?? span.attributes["guardrail.decision"];
|
|
718
|
+
insights.push(`Guardrail ${span.attributes["guardrail.name"] ?? span.name} decision: ${decision ?? "unknown"}`);
|
|
719
|
+
});
|
|
720
|
+
return insights.slice(0, 20);
|
|
721
|
+
}
|
|
722
|
+
function extractTraceIdFromTraceparent(traceparent) {
|
|
723
|
+
if (!traceparent) return null;
|
|
724
|
+
const parts = traceparent.split("-");
|
|
725
|
+
const [version, traceId, parentSpanId, flags] = parts;
|
|
726
|
+
const validPartCount = version?.toLowerCase() === "00" ? parts.length === 4 : parts.length >= 4;
|
|
727
|
+
if (!/^[0-9a-f]{2}$/i.test(version) || version.toLowerCase() === "ff" || !validPartCount || !/^[0-9a-f]{32}$/i.test(traceId) || /^0+$/.test(traceId) || !/^[0-9a-f]{16}$/i.test(parentSpanId) || /^0+$/.test(parentSpanId) || !/^[0-9a-f]{2}$/i.test(flags)) return null;
|
|
728
|
+
return traceId.toLowerCase();
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Compute the depth of a span in the span tree, rejecting cyclic parent chains.
|
|
732
|
+
*/
|
|
733
|
+
function computeSpanDepth(span, spanMap, depthCache) {
|
|
734
|
+
const ancestors = [];
|
|
735
|
+
const visited = /* @__PURE__ */ new Set();
|
|
736
|
+
let current = span;
|
|
737
|
+
let depth = -1;
|
|
738
|
+
while (current) {
|
|
739
|
+
const cachedDepth = depthCache.get(current.spanId);
|
|
740
|
+
if (cachedDepth !== void 0) {
|
|
741
|
+
if (cachedDepth === null) {
|
|
742
|
+
for (const ancestor of ancestors) depthCache.set(ancestor.spanId, null);
|
|
743
|
+
return null;
|
|
744
|
+
}
|
|
745
|
+
depth = cachedDepth;
|
|
746
|
+
break;
|
|
747
|
+
}
|
|
748
|
+
if (visited.has(current.spanId)) {
|
|
749
|
+
for (const ancestor of ancestors) depthCache.set(ancestor.spanId, null);
|
|
750
|
+
return null;
|
|
751
|
+
}
|
|
752
|
+
visited.add(current.spanId);
|
|
753
|
+
ancestors.push(current);
|
|
754
|
+
current = current.parentSpanId ? spanMap.get(current.parentSpanId) : void 0;
|
|
755
|
+
}
|
|
756
|
+
for (let index = ancestors.length - 1; index >= 0; index--) {
|
|
757
|
+
depth += 1;
|
|
758
|
+
depthCache.set(ancestors[index].spanId, depth);
|
|
759
|
+
}
|
|
760
|
+
return depth;
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Drop malformed parent cycles before persisting or processing external spans.
|
|
764
|
+
*/
|
|
765
|
+
function discardCyclicExternalSpans(spans) {
|
|
766
|
+
const spanMap = new Map(spans.map((span) => [span.spanId, span]));
|
|
767
|
+
const depthCache = /* @__PURE__ */ new Map();
|
|
768
|
+
const cyclicSpanIds = /* @__PURE__ */ new Set();
|
|
769
|
+
const validSpans = spans.filter((span) => {
|
|
770
|
+
if (computeSpanDepth(span, spanMap, depthCache) === null) {
|
|
771
|
+
cyclicSpanIds.add(span.spanId);
|
|
772
|
+
return false;
|
|
773
|
+
}
|
|
774
|
+
return true;
|
|
775
|
+
});
|
|
776
|
+
if (cyclicSpanIds.size > 0) logger.warn(`[TraceContext] Skipping ${cyclicSpanIds.size} spans with cyclic parent relationships`);
|
|
777
|
+
return validSpans;
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* Store spans fetched from an external provider in the local database.
|
|
781
|
+
* This allows the spans to be displayed in the UI and persisted.
|
|
782
|
+
*/
|
|
783
|
+
async function storeExternalSpans(traceId, spans) {
|
|
784
|
+
try {
|
|
785
|
+
const traceStore = getTraceStore();
|
|
786
|
+
for (let index = 0; index < spans.length; index += EXTERNAL_SPAN_BATCH_SIZE) if (!(await traceStore.addSpans(traceId, spans.slice(index, index + EXTERNAL_SPAN_BATCH_SIZE), {
|
|
787
|
+
warnIfMissingTrace: false,
|
|
788
|
+
...index > 0 && { skipTraceCheck: true }
|
|
789
|
+
})).stored) return false;
|
|
790
|
+
logger.debug(`[TraceContext] Stored ${spans.length} spans from external provider`);
|
|
791
|
+
return true;
|
|
792
|
+
} catch (error) {
|
|
793
|
+
logger.warn(`[TraceContext] Failed to store external spans: ${error}`);
|
|
794
|
+
return false;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
function redactExternalSpan(span, redactAttributes) {
|
|
798
|
+
const attributes = span.attributes ?? {};
|
|
799
|
+
const sanitizedAttributes = sanitizeTraceAttributes(attributes, {
|
|
800
|
+
redactAttributes,
|
|
801
|
+
sanitizeSensitiveAttributes: false,
|
|
802
|
+
truncateValues: false
|
|
803
|
+
});
|
|
804
|
+
const redactedValues = /* @__PURE__ */ new Set();
|
|
805
|
+
const pendingValues = [{
|
|
806
|
+
original: attributes,
|
|
807
|
+
sanitized: sanitizedAttributes
|
|
808
|
+
}];
|
|
809
|
+
while (pendingValues.length > 0) {
|
|
810
|
+
const { original, sanitized } = pendingValues.pop();
|
|
811
|
+
if (typeof original !== "object") {
|
|
812
|
+
if (original !== void 0 && sanitized === "[REDACTED]") {
|
|
813
|
+
const value = String(original);
|
|
814
|
+
if (value.length > 0) redactedValues.add(value);
|
|
815
|
+
}
|
|
816
|
+
continue;
|
|
817
|
+
}
|
|
818
|
+
if (!original) continue;
|
|
819
|
+
if (Array.isArray(original)) {
|
|
820
|
+
for (let index = 0; index < original.length; index++) pendingValues.push({
|
|
821
|
+
original: original[index],
|
|
822
|
+
sanitized: sanitized === "[REDACTED]" ? sanitized : sanitized?.[index]
|
|
823
|
+
});
|
|
824
|
+
continue;
|
|
825
|
+
}
|
|
826
|
+
for (const [key, value] of Object.entries(original)) pendingValues.push({
|
|
827
|
+
original: value,
|
|
828
|
+
sanitized: sanitized === "[REDACTED]" ? sanitized : sanitized?.[key]
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
const orderedRedactedValues = [...redactedValues].sort((left, right) => right.length - left.length);
|
|
832
|
+
const scrubEcho = (value) => {
|
|
833
|
+
if (typeof value !== "string") return value;
|
|
834
|
+
let sanitizedValue = value;
|
|
835
|
+
for (const redactedValue of orderedRedactedValues) sanitizedValue = sanitizedValue.split(redactedValue).join("[REDACTED]");
|
|
836
|
+
return sanitizedValue;
|
|
837
|
+
};
|
|
838
|
+
return {
|
|
839
|
+
...span,
|
|
840
|
+
name: scrubEcho(span.name),
|
|
841
|
+
statusMessage: scrubEcho(span.statusMessage),
|
|
842
|
+
attributes: sanitizedAttributes
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
function getProviderFetchOptions(spanOptions, abortSignal) {
|
|
846
|
+
const requiresPostFetchFiltering = spanOptions.includeInternalSpans === false || Boolean(spanOptions.spanFilter?.length);
|
|
847
|
+
const providerOptions = {
|
|
848
|
+
...spanOptions.earliestStartTime !== void 0 && { earliestStartTime: spanOptions.earliestStartTime },
|
|
849
|
+
...spanOptions.maxSpans !== void 0 && !requiresPostFetchFiltering && { maxSpans: spanOptions.maxSpans },
|
|
850
|
+
...abortSignal && { abortSignal }
|
|
851
|
+
};
|
|
852
|
+
return Object.keys(providerOptions).length > 0 ? providerOptions : void 0;
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Fetch trace context from an external provider (Tempo, Jaeger, etc.)
|
|
856
|
+
*/
|
|
857
|
+
async function fetchFromExternalProvider(traceId, providerConfig, options) {
|
|
858
|
+
const { queryDelay, maxRetries, retryDelayMs, redactAttributes, abortSignal, ...spanOptions } = options;
|
|
859
|
+
const providerFetchOptions = getProviderFetchOptions(spanOptions, abortSignal);
|
|
860
|
+
let provider;
|
|
861
|
+
try {
|
|
862
|
+
provider = createTraceProvider(providerConfig);
|
|
863
|
+
} catch (error) {
|
|
864
|
+
logger.warn(`[TraceContext] Failed to initialize trace provider: ${error}`);
|
|
865
|
+
return null;
|
|
866
|
+
}
|
|
867
|
+
if (queryDelay > 0) {
|
|
868
|
+
logger.debug(`[TraceContext] Waiting ${queryDelay}ms for spans to arrive at external backend`);
|
|
869
|
+
await waitForRetry(queryDelay, abortSignal);
|
|
870
|
+
}
|
|
871
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
872
|
+
if (abortSignal?.aborted) throw createTraceAbortError(abortSignal);
|
|
873
|
+
try {
|
|
874
|
+
const result = await provider.fetchTrace(traceId, providerFetchOptions);
|
|
875
|
+
const validSpans = result ? discardCyclicExternalSpans(result.spans) : [];
|
|
876
|
+
if (!result || validSpans.length === 0) {
|
|
877
|
+
if (attempt === maxRetries) {
|
|
878
|
+
logger.debug(`[TraceContext] No spans found for trace ${traceId} from ${provider.id} after ${attempt + 1} attempts`);
|
|
879
|
+
return null;
|
|
880
|
+
}
|
|
881
|
+
logger.debug(`[TraceContext] No spans yet for trace ${traceId} from ${provider.id}, retrying in ${retryDelayMs}ms (attempt ${attempt + 1}/${maxRetries})`);
|
|
882
|
+
await waitForRetry(retryDelayMs, abortSignal);
|
|
883
|
+
continue;
|
|
884
|
+
}
|
|
885
|
+
if (!await storeExternalSpans(traceId, redactAttributes?.length ? validSpans.map((span) => redactExternalSpan(span, redactAttributes)) : validSpans)) return null;
|
|
886
|
+
const spans = await getTraceStore().getSpans(traceId, spanOptions);
|
|
887
|
+
if (spans.length === 0) return null;
|
|
888
|
+
const traceSpans = createTraceSpans(spans);
|
|
889
|
+
const insights = deriveInsights(traceSpans);
|
|
890
|
+
logger.debug(`[TraceContext] Resolved ${traceSpans.length} spans for trace ${traceId} from ${provider.id} with ${insights.length} insights`);
|
|
891
|
+
return {
|
|
892
|
+
traceId,
|
|
893
|
+
spans: traceSpans,
|
|
894
|
+
insights,
|
|
895
|
+
fetchedAt: result.fetchedAt
|
|
896
|
+
};
|
|
897
|
+
} catch (error) {
|
|
898
|
+
if (abortSignal?.aborted) throw createTraceAbortError(abortSignal);
|
|
899
|
+
logger.error(`[TraceContext] Failed to fetch from ${provider.id}: ${error}`);
|
|
900
|
+
if (attempt === maxRetries || error instanceof TraceProviderError && !error.retryable) return null;
|
|
901
|
+
await waitForRetry(retryDelayMs, abortSignal);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
return null;
|
|
905
|
+
}
|
|
906
|
+
function createTraceAbortError(signal) {
|
|
907
|
+
const error = /* @__PURE__ */ new Error("cancelled by user");
|
|
908
|
+
error.cause = signal?.reason;
|
|
909
|
+
error.name = "AbortError";
|
|
910
|
+
return error;
|
|
911
|
+
}
|
|
912
|
+
async function waitForRetry(delay, signal) {
|
|
913
|
+
if (signal?.aborted) throw createTraceAbortError(signal);
|
|
914
|
+
await new Promise((resolve, reject) => {
|
|
915
|
+
const onAbort = () => {
|
|
916
|
+
clearTimeout(timeout);
|
|
917
|
+
reject(createTraceAbortError(signal));
|
|
918
|
+
};
|
|
919
|
+
const timeout = setTimeout(() => {
|
|
920
|
+
signal?.removeEventListener("abort", onAbort);
|
|
921
|
+
resolve();
|
|
922
|
+
}, delay);
|
|
923
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Fetch trace context from local TraceStore (SQLite)
|
|
928
|
+
*/
|
|
929
|
+
async function fetchFromLocalStore(traceId, options) {
|
|
930
|
+
const { maxRetries, retryDelayMs, abortSignal, redactAttributes, ...spanOptions } = options;
|
|
931
|
+
const traceStore = getTraceStore();
|
|
932
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
933
|
+
if (abortSignal?.aborted) throw createTraceAbortError(abortSignal);
|
|
934
|
+
try {
|
|
935
|
+
const spans = await traceStore.getSpans(traceId, spanOptions);
|
|
936
|
+
if (spans.length === 0) {
|
|
937
|
+
if (attempt === maxRetries) {
|
|
938
|
+
logger.debug(`[TraceContext] No spans found for trace ${traceId} after ${attempt + 1} attempts`);
|
|
939
|
+
return null;
|
|
940
|
+
}
|
|
941
|
+
logger.debug(`[TraceContext] No spans yet for trace ${traceId}, retrying in ${retryDelayMs}ms (attempt ${attempt + 1}/${maxRetries})`);
|
|
942
|
+
await waitForRetry(retryDelayMs, abortSignal);
|
|
943
|
+
continue;
|
|
944
|
+
}
|
|
945
|
+
const traceSpans = createTraceSpans(redactAttributes?.length ? spans.map((span) => ({
|
|
946
|
+
...span,
|
|
947
|
+
attributes: sanitizeTraceAttributes(span.attributes, {
|
|
948
|
+
redactAttributes,
|
|
949
|
+
sanitizeSensitiveAttributes: spanOptions.sanitizeAttributes
|
|
950
|
+
})
|
|
951
|
+
})) : spans);
|
|
952
|
+
const insights = deriveInsights(traceSpans);
|
|
953
|
+
const context = {
|
|
954
|
+
traceId,
|
|
955
|
+
spans: traceSpans,
|
|
956
|
+
insights,
|
|
957
|
+
fetchedAt: Date.now()
|
|
958
|
+
};
|
|
959
|
+
logger.debug(`[TraceContext] Resolved ${traceSpans.length} spans for trace ${traceId} with ${insights.length} insights`);
|
|
960
|
+
return context;
|
|
961
|
+
} catch (error) {
|
|
962
|
+
if (abortSignal?.aborted) throw createTraceAbortError(abortSignal);
|
|
963
|
+
logger.error(`[TraceContext] Failed to fetch spans for trace ${traceId}: ${error}`);
|
|
964
|
+
if (attempt === maxRetries) return null;
|
|
965
|
+
await waitForRetry(retryDelayMs, abortSignal);
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
return null;
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* Fetch trace context for a given trace ID.
|
|
972
|
+
*
|
|
973
|
+
* If an external provider is configured (Tempo, Jaeger, etc.), fetches from that backend.
|
|
974
|
+
* Otherwise, fetches from the local TraceStore (SQLite).
|
|
975
|
+
*
|
|
976
|
+
* @param traceId - The W3C trace ID (32 hex chars)
|
|
977
|
+
* @param options - Fetch options including provider config
|
|
978
|
+
* @returns TraceContextData or null if not found
|
|
979
|
+
*/
|
|
980
|
+
async function fetchTraceContext(traceId, options = {}) {
|
|
981
|
+
const { includeInternalSpans = true, sanitizeAttributes = true, maxRetries = DEFAULT_MAX_RETRIES, retryDelayMs = DEFAULT_RETRY_DELAY_MS, providerConfig, queryDelay = DEFAULT_QUERY_DELAY_MS, ...spanOptions } = options;
|
|
982
|
+
const fetchOptions = {
|
|
983
|
+
maxRetries,
|
|
984
|
+
retryDelayMs,
|
|
985
|
+
includeInternalSpans,
|
|
986
|
+
sanitizeAttributes,
|
|
987
|
+
...spanOptions
|
|
988
|
+
};
|
|
989
|
+
if (isExternalTraceProvider(providerConfig)) {
|
|
990
|
+
const externalConfig = providerConfig;
|
|
991
|
+
const requestOptions = {
|
|
992
|
+
queryDelay,
|
|
993
|
+
...fetchOptions
|
|
994
|
+
};
|
|
995
|
+
if (requestOptions.abortSignal) return fetchFromExternalProvider(traceId, externalConfig, requestOptions);
|
|
996
|
+
const key = JSON.stringify({
|
|
997
|
+
traceId,
|
|
998
|
+
...requestOptions
|
|
999
|
+
});
|
|
1000
|
+
let pending = inFlightExternalFetches.get(externalConfig);
|
|
1001
|
+
if (!pending) {
|
|
1002
|
+
pending = /* @__PURE__ */ new Map();
|
|
1003
|
+
inFlightExternalFetches.set(externalConfig, pending);
|
|
1004
|
+
}
|
|
1005
|
+
const existing = pending.get(key);
|
|
1006
|
+
if (existing) return existing;
|
|
1007
|
+
const request = fetchFromExternalProvider(traceId, externalConfig, requestOptions).finally(() => pending.delete(key));
|
|
1008
|
+
pending.set(key, request);
|
|
1009
|
+
return request;
|
|
1010
|
+
}
|
|
1011
|
+
return fetchFromLocalStore(traceId, fetchOptions);
|
|
1012
|
+
}
|
|
1013
|
+
//#endregion
|
|
1014
|
+
export { fetchTraceContext as n, isExternalTraceProvider as r, extractTraceIdFromTraceparent as t };
|
|
1015
|
+
|
|
1016
|
+
//# sourceMappingURL=traceContext-Brw3Oe41.js.map
|