From f93ef8f32dcfa2c27b8caea81b6c58fc07f89be8 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 6 Jul 2026 14:35:20 +0200 Subject: [PATCH 1/2] ci: Typecheck test files and properly detect unused locals --- dev-packages/seinfeld/package.json | 1 + dev-packages/seinfeld/src/cassette.ts | 3 - dev-packages/seinfeld/tsconfig.json | 1 + integrations/browser-js/tsconfig.json | 1 + .../src/BraintrustCallbackHandler.fixtures.ts | 964 ------------------ .../src/BraintrustCallbackHandler.ts | 2 +- integrations/langchain-js/src/test/setup.ts | 1 - integrations/langchain-js/src/test/utils.ts | 30 - integrations/langchain-js/tsconfig.json | 1 + integrations/openai-agents-js/tsconfig.json | 1 + integrations/otel-js/package.json | 5 +- integrations/otel-js/src/otel-compat.test.ts | 112 +- integrations/otel-js/src/otel.ts | 2 - integrations/otel-js/tsconfig.json | 1 + integrations/otel-js/tsconfig.test.json | 14 + integrations/templates-nunjucks/package.json | 2 +- .../templates-nunjucks/src/index.test.ts | 98 +- integrations/templates-nunjucks/tsconfig.json | 1 + .../templates-nunjucks/tsconfig.test.json | 10 + integrations/temporal-js/package.json | 2 +- integrations/temporal-js/src/temporal.test.ts | 4 +- integrations/temporal-js/tsconfig.json | 1 + integrations/temporal-js/tsconfig.test.json | 10 + integrations/vercel-ai-sdk/tsconfig.json | 1 + js/package.json | 2 +- .../loader/mastra-observability-patch.ts | 2 +- .../loader/special-case-patches.ts | 4 +- .../patch-tracing-channel.test.ts | 2 +- js/src/cli/functions/upload.test.ts | 5 +- js/src/cli/functions/upload.ts | 10 +- js/src/cli/progress.ts | 1 - .../cli/util/external-packages-plugin.test.ts | 1 - js/src/edge-runtime-bootstrap.test.ts | 2 +- js/src/framework-types.ts | 19 - js/src/framework.test.ts | 5 +- js/src/framework.ts | 10 +- js/src/framework2.ts | 2 +- js/src/functions/invoke.test.ts | 2 +- .../instrumentation/braintrust-plugin.test.ts | 17 +- .../core/channel-definitions.ts | 2 +- .../instrumentation/core/channel-tracing.ts | 6 +- js/src/instrumentation/core/index.ts | 3 - js/src/instrumentation/core/stream-patcher.ts | 2 +- .../plugins/ai-sdk-plugin.streaming.test.ts | 4 +- .../plugins/ai-sdk-plugin.test.ts | 1 - .../instrumentation/plugins/ai-sdk-plugin.ts | 2 +- .../plugins/anthropic-plugin.test.ts | 82 +- .../plugins/bedrock-runtime-channels.ts | 2 +- .../plugins/bedrock-runtime-common.ts | 2 +- .../plugins/bedrock-runtime-plugin.test.ts | 10 +- .../claude-agent-sdk-local-tool-spans.ts | 2 +- .../plugins/cursor-sdk-plugin.test.ts | 4 +- .../plugins/google-adk-plugin.test.ts | 8 +- .../plugins/google-genai-plugin.test.ts | 14 +- .../instrumentation/plugins/groq-channels.ts | 3 - .../plugins/langchain-plugin.test.ts | 12 +- .../plugins/openai-agents-plugin.test.ts | 10 +- .../plugins/openai-channels.ts | 18 +- .../plugins/openai-plugin.test.ts | 30 +- .../plugins/openrouter-agent-plugin.test.ts | 12 +- .../plugins/openrouter-plugin.test.ts | 10 +- .../plugins/pi-coding-agent-plugin.test.ts | 22 +- .../plugins/strands-agent-sdk-plugin.test.ts | 2 +- js/src/isomorph.ts | 6 +- js/src/logger-misc.test.ts | 7 +- js/src/logger.test.ts | 71 +- js/src/logger.ts | 13 +- js/src/masking.test.ts | 9 +- js/src/parameters.test.ts | 2 +- js/src/prompt-cache/parameters-cache.ts | 2 +- js/src/prompt-cache/prompt-cache.test.ts | 2 +- js/src/runtime-async-local-storage.ts | 2 +- js/src/stackutil.ts | 2 +- js/src/template/renderer.ts | 2 - js/src/trace.ts | 8 +- js/src/typed-instrumentation-helpers.ts | 4 +- js/src/vendor-sdk-types/ai-sdk-common.ts | 8 +- .../vendor-sdk-types/ai-sdk-v7-telemetry.ts | 6 +- js/src/vendor-sdk-types/ai-sdk.ts | 22 - js/src/vendor-sdk-types/anthropic.ts | 4 +- js/src/vendor-sdk-types/cursor-sdk.ts | 11 +- js/src/vendor-sdk-types/google-adk.ts | 17 +- js/src/vendor-sdk-types/groq.ts | 9 +- js/src/vendor-sdk-types/huggingface.ts | 2 +- js/src/vendor-sdk-types/langchain.ts | 2 - js/src/vendor-sdk-types/openai-codex.ts | 15 +- js/src/vendor-sdk-types/openai-common.ts | 6 +- js/src/vendor-sdk-types/openai.ts | 2 - js/src/vendor-sdk-types/pi-coding-agent.ts | 2 +- js/src/wrappers/ai-sdk/ai-sdk.test.ts | 40 +- js/src/wrappers/anthropic-no-install.test.ts | 2 +- js/src/wrappers/bedrock-runtime.test.ts | 2 +- js/src/wrappers/cohere.test.ts | 10 +- js/src/wrappers/cursor-sdk.test.ts | 8 +- js/src/wrappers/cursor-sdk.ts | 3 - js/src/wrappers/exports.test.ts | 2 +- js/src/wrappers/genkit.test.ts | 17 +- js/src/wrappers/google-adk.test.ts | 4 +- js/src/wrappers/groq.test.ts | 4 +- js/src/wrappers/huggingface.test.ts | 12 +- js/src/wrappers/node-test/index.ts | 9 - js/src/wrappers/openai-codex.ts | 3 - js/src/wrappers/openai-promise-utils.ts | 2 +- js/src/wrappers/openrouter.test.ts | 22 +- js/src/wrappers/pi-coding-agent.test.ts | 2 +- js/src/wrappers/pi-coding-agent.ts | 2 - js/src/wrappers/strands-agent-sdk.test.ts | 12 +- js/src/wrappers/strands-agent-sdk.ts | 2 - js/src/wrappers/vitest-evals/reporter.test.ts | 6 +- js/src/wrappers/vitest/dataset-helpers.ts | 14 - js/src/wrappers/vitest/index.ts | 4 - js/src/wrappers/vitest/package.json | 1 + js/src/wrappers/vitest/tsconfig.json | 9 +- js/src/wrappers/vitest/types.ts | 17 - .../api-compatibility.test.ts | 113 -- .../error-handling.test.ts | 1 - .../function-behavior.test.ts | 3 +- .../import-require-in-the-middle.test.ts | 2 +- .../multiple-instrumentations.test.ts | 2 +- .../runtime-execution.test.ts | 1 - .../streaming-and-responses.test.ts | 2 +- js/tests/provider-wrappers.test.ts | 8 +- js/tests/type-shims/ai-sdk-openai.d.ts | 2 + js/tests/type-shims/ai.d.ts | 2 + js/tests/typecheck.d.ts | 3 + js/tsconfig.json | 1 + js/tsconfig.test.json | 30 + js/util/merge_row_batch.ts | 4 +- js/util/span_identifier_v1.ts | 2 - js/util/span_identifier_v2.ts | 2 - js/util/span_identifier_v3.ts | 4 +- js/util/span_identifier_v4.test.ts | 2 +- js/util/span_identifier_v4.ts | 2 +- knip.jsonc | 7 +- pnpm-lock.yaml | 3 + 135 files changed, 548 insertions(+), 1708 deletions(-) create mode 100644 integrations/otel-js/tsconfig.test.json create mode 100644 integrations/templates-nunjucks/tsconfig.test.json create mode 100644 integrations/temporal-js/tsconfig.test.json delete mode 100644 js/src/wrappers/vitest/dataset-helpers.ts create mode 100644 js/tests/type-shims/ai-sdk-openai.d.ts create mode 100644 js/tests/type-shims/ai.d.ts create mode 100644 js/tests/typecheck.d.ts create mode 100644 js/tsconfig.test.json diff --git a/dev-packages/seinfeld/package.json b/dev-packages/seinfeld/package.json index 98d8fea96..4ec7b366f 100644 --- a/dev-packages/seinfeld/package.json +++ b/dev-packages/seinfeld/package.json @@ -22,6 +22,7 @@ ], "scripts": { "build": "tsup", + "check:typings": "tsc --noEmit", "dev": "tsup --watch", "typecheck": "tsc --noEmit" }, diff --git a/dev-packages/seinfeld/src/cassette.ts b/dev-packages/seinfeld/src/cassette.ts index 2ca69b387..0fbf201ef 100644 --- a/dev-packages/seinfeld/src/cassette.ts +++ b/dev-packages/seinfeld/src/cassette.ts @@ -89,8 +89,5 @@ export interface CassetteFile { entries: CassetteEntry[]; } -/** @deprecated Use `CassetteFile` instead. */ -export type Cassette = CassetteFile; - /** The three execution modes used by the cassette server. */ export type CassetteMode = "replay" | "record" | "passthrough"; diff --git a/dev-packages/seinfeld/tsconfig.json b/dev-packages/seinfeld/tsconfig.json index b8a2e4867..6cb2a6d85 100644 --- a/dev-packages/seinfeld/tsconfig.json +++ b/dev-packages/seinfeld/tsconfig.json @@ -5,6 +5,7 @@ "moduleResolution": "bundler", "lib": ["ES2022", "DOM"], "strict": true, + "noUnusedLocals": true, "noUncheckedIndexedAccess": true, "noImplicitOverride": true, "noFallthroughCasesInSwitch": true, diff --git a/integrations/browser-js/tsconfig.json b/integrations/browser-js/tsconfig.json index 94649b1d8..7557cefcf 100644 --- a/integrations/browser-js/tsconfig.json +++ b/integrations/browser-js/tsconfig.json @@ -6,6 +6,7 @@ "target": "es2022", "moduleResolution": "bundler", "strict": true, + "noUnusedLocals": true, "esModuleInterop": true, "skipLibCheck": true, "resolveJsonModule": true diff --git a/integrations/langchain-js/src/BraintrustCallbackHandler.fixtures.ts b/integrations/langchain-js/src/BraintrustCallbackHandler.fixtures.ts index 75927db07..f7ec70434 100644 --- a/integrations/langchain-js/src/BraintrustCallbackHandler.fixtures.ts +++ b/integrations/langchain-js/src/BraintrustCallbackHandler.fixtures.ts @@ -198,970 +198,6 @@ export const CHAT_BEAR_POEM = { system_fingerprint: "fp_bba3c8e70b", }; -const EMBEDDING_HELLO_WORLD = { - object: "list", - data: [ - { - object: "embedding", - index: 0, - embedding: [ - -0.005540426, 0.0047363234, -0.015009919, -0.027093535, -0.015173893, - 0.015173893, -0.017608276, 0.009554634, -0.009422193, -0.030801868, - 0.026311506, 0.011169146, -0.023397814, -0.009510486, 0.007700467, - 0.010450183, 0.027572842, -0.012581844, 0.012783658, 0.014845945, - -0.007164398, -0.0033425451, 0.0026251592, 0.0071833185, -0.019777777, - -0.0039795204, 0.0106330775, -0.017456915, 0.028077379, -0.030928, - 0.0034119186, -0.0063855224, -0.0076437066, -0.019626416, 0.009478953, - -0.016977606, 0.0023050949, -0.01333234, 0.020067884, -0.01784793, - 0.007240079, 0.00963662, 0.012178216, -0.022590559, -0.032996595, - 0.010809665, 0.0024517253, -0.008911352, -0.002087514, 0.028909862, - 0.028279193, 0.0021127407, -0.017128967, 0.015287413, -0.016044216, - 0.008955498, -0.03163435, 0.028077379, 0.02790079, -0.021076953, - -0.0008253879, 0.00485615, -0.006584183, 0.003654726, 0.009491567, - 0.015110826, 0.0037240996, 0.007555413, -0.016573979, 0.01878132, - 0.019613802, 0.009554634, -0.0034749855, -0.00752388, 0.018718252, - -0.00055971864, -0.017583048, 0.00076468603, 0.0060954145, 0.0029073835, - 0.035494044, -0.02603401, -0.00948526, 0.015363093, 0.020774232, - 0.0036421127, -0.003049284, 0.020004816, -0.015981149, -0.024444725, - 0.012033162, 0.014959466, 0.009132085, 0.0097123, -0.012884565, - 0.00034962705, -0.007902281, 0.017696569, 0.0039038404, -0.04760289, - -0.01411437, 0.00015096636, -0.017696569, -0.014177436, -0.009705994, - -0.005275545, -0.0073914393, 0.00031178692, 0.023196, 0.0009286599, - -0.010002408, 0.01594331, -0.017885769, -0.0341318, 0.005594033, - -0.0050485046, 0.0061647883, -0.0062247016, -0.019891296, -0.023296908, - 0.013773808, 0.036023807, 0.017267713, -0.025226755, 0.0077572274, - 0.008097788, -0.042103454, -0.014467544, -0.005414292, -0.01230435, - 0.043490924, 0.005622413, 0.013168366, -0.010330356, -0.029237809, - 0.016107284, -0.007309452, 0.027068308, -0.011907028, -0.01765873, - 0.0028222431, 0.027572842, 0.018365078, -0.0132818865, -0.0029988305, - 0.001986607, 0.0039038404, -0.022464426, 0.009724914, -0.01845337, - 0.011585387, 0.021392288, -0.0011312623, 0.004074121, 0.0132818865, - 0.012443097, -0.0018588965, 0.027371028, 0.008526643, -0.0053417655, - 0.0060481145, 0.003232178, -0.004055201, -0.037360825, 0.012846725, - 0.02822874, 0.029237809, -0.006918438, 0.00033464868, -0.027244896, - -0.012499857, 0.010059169, -0.037335597, 0.019752549, -0.016145123, - 0.005039044, -0.003866, 0.022880666, -0.013471087, -0.014833332, - -0.03188662, 0.014845945, 0.0053606853, 0.0247979, 0.006956278, - 0.0011832925, 0.014038689, -0.0052030184, 0.0031123508, -0.02035799, - 0.01523696, 0.028026925, 0.03218934, 0.00858971, -0.6861677, - -0.009731221, 0.018226331, 0.020938206, 0.015400934, 0.007996881, - 0.014076529, 0.029742343, 0.0054332125, 0.032391153, -0.012424177, - 0.02095082, -0.008545564, -0.007820294, -0.0055561927, -0.007826601, - 0.0023555483, -0.02426814, -0.020067884, 0.017381234, -0.0012912945, - 0.030700961, -0.02110218, -0.013988236, 0.006205782, 0.0067796903, - 0.007883361, -0.0072905323, -0.016750565, 0.025327662, -0.008614937, - 0.020042656, -0.0023066713, 0.0026566926, 0.069676295, 0.021392288, - -0.0020938206, 0.018957905, 0.001981877, 0.031129817, -0.0118628815, - -0.013912556, 0.0014757651, -0.017267713, 0.0049822843, 0.009239299, - 0.0108159715, -0.0042696283, -0.00091131654, 0.010639384, 0.024381658, - -0.014354023, 0.018793933, 0.015829789, 0.0011438756, 0.010021328, - 0.01683886, 0.010267289, -0.002582589, 0.0033961518, 0.0012140375, - 0.021354448, -0.005606646, 0.0008892431, -0.011787201, 0.025378115, - -0.023473496, 0.006300382, -0.0054805125, -0.010557397, 0.00059558795, - -0.0030918543, -0.020257084, -0.014429704, 0.019702096, 0.033248864, - 0.0057548536, -0.012480937, -0.013773808, 0.020219244, 0.011818735, - 0.003925914, -0.020635486, -0.025567316, 0.01900836, -0.016233416, - -0.03342545, -0.013117912, -0.0011194373, 0.005477359, 0.029742343, - 0.0020039503, -0.009535713, -0.018390305, 0.026185371, -0.003333085, - -0.009907808, 0.008999645, 0.025088008, 0.003534899, 0.006912131, - 0.005521506, 0.0033772318, 0.008381589, 0.017053286, -0.011043012, - 0.0038407734, 0.022678852, 0.020812074, -0.02049674, 0.0072526922, - 0.0012203442, -0.034888603, 0.022325678, 0.011396186, -0.02868282, - -0.0017201493, 0.018920066, 0.0208373, -0.016801018, 0.019109268, - -0.0020197171, 0.01874348, 0.003525439, 0.0029657204, 0.008633857, - -0.0050295843, 0.0064706625, -0.0031959144, -0.009283446, 0.027799884, - -0.0036200394, 0.009359126, -0.0041088075, 0.00378086, -0.0030319407, - 0.0061584814, -0.0121466825, 0.0060039675, 0.017204646, -0.01236111, - -0.0080788685, -0.01127636, 0.010071782, 0.0059251343, -0.017204646, - -0.018756092, -0.010267289, 0.001608994, -0.0089302715, 0.010361889, - -0.01609467, -0.037335597, 0.03178571, -0.00761848, -0.004402069, - 0.005338612, -0.026942175, -0.04220436, -0.033854306, 0.009573554, - 0.014707198, -0.0101600755, 0.0029278803, -0.004231788, -0.027799884, - -0.025378115, 0.009327592, -0.00044580406, -0.026361959, 0.011761975, - -0.0052723917, -0.014026076, 0.00077454024, -0.0049381373, 0.02049674, - -0.015817175, -0.01051325, 0.005291312, -0.015627975, 0.0059314407, - -0.017759636, -0.021076953, 0.020194018, 0.014026076, -0.0046764095, - 0.003030364, 0.02969189, -0.010790745, 0.006729237, 0.015211733, - 0.0044903625, -0.018705638, 0.0014986269, 0.0046543363, -0.015855016, - 0.006483276, -0.0049980506, 0.0104438765, 0.014984692, 0.039858274, - 0.0015766722, 0.026866494, -0.022350905, 0.002048097, -0.016712725, - -0.0053985254, -0.020231858, 0.014278343, 0.022590559, 0.0069058244, - -0.01239895, -0.0015380437, 0.027421482, 0.008835671, 0.032466833, - -0.00008696332, -0.009586167, -0.021896824, 0.005546733, 0.0011218023, - 0.008186082, -0.008558176, -0.007895974, 0.022136478, 0.036578793, - 0.00016338266, 0.039858274, -0.0009460033, -0.024633925, -0.0327191, - 0.010052862, 0.011030398, 0.009945648, -0.01024837, 0.0021080107, - 0.008766297, -0.02401587, 0.027648523, 0.0036389595, -0.008305909, - 0.0064075957, 0.025239369, -0.021467969, 0.009018565, 0.03637698, - 0.007858134, -0.010431264, -0.001721726, 0.036730155, -0.003957447, - 0.00046196496, -0.008450963, 0.003175418, 0.0010051285, -0.0380924, - -0.0063792155, -0.015009919, 0.027976472, 0.032643422, 0.019260628, - 0.0020622872, -0.0009302366, -0.011377267, 0.010393423, -0.018667798, - 0.0070193447, -0.0154513875, 0.0024343817, -0.017482141, -0.00841943, - -0.0030823941, 0.012827805, -0.017608276, 0.00959878, -0.0076058665, - -0.004534509, -0.0045471224, -0.006773384, -0.0030335174, -0.016964993, - -0.017229874, 0.0019219634, 0.015035146, -0.0029326102, -0.023574403, - -0.031432535, -0.0020339072, 0.008205002, -0.002486412, -0.023624856, - 0.00834375, 0.02588265, -0.023423042, 0.0059755878, 0.005193558, - 0.021001274, -0.0008151395, -0.004487209, -0.011024092, 0.025857424, - 0.009087939, 0.0027260662, -0.020610258, 0.016637044, 0.0031722644, - -0.013546768, -0.021934664, -0.003607426, -0.0015750955, -0.0023161315, - 0.0012305926, -0.0049034506, 0.0023224382, 0.01815065, -0.0029199969, - -0.0018415531, 0.012096229, 0.024835741, -0.005502586, -0.010973639, - -0.0066977036, -0.02603401, -0.013017005, 0.07330895, 0.0040394343, - -0.003563279, 0.014631518, -0.008696924, -0.0034907523, -0.04510544, - -0.027572842, -0.0061837086, 0.0013953549, -0.0003389845, -0.0071454784, - 0.00001194206, 0.0208373, 0.026462866, 0.00074694847, 0.0012660677, - -0.0246087, -0.013571994, 0.0011218023, 0.004717403, 0.00566656, - -0.004525049, 0.016737953, 0.021203088, 0.0033456984, 0.005455286, - 0.018276785, -0.0013606681, 0.00016545203, 0.014467544, -0.006272002, - 0.016573979, 0.0077256938, 0.01792361, 0.014215277, 0.008312216, - 0.030902775, 0.00948526, -0.0054363655, 0.017557822, 0.00769416, - -0.003370925, -0.022325678, 0.017166806, 0.011175453, -0.0099708745, - 0.013042232, 0.0029184201, -0.03304705, 0.024280751, -0.0057044, - -0.011415106, -0.022678852, -0.012127763, 0.01434141, -0.0047142496, - -0.01430357, -0.010298823, -0.011616921, -0.0040615075, -0.010393423, - -0.015855016, -0.0046101897, -0.025050167, -0.026740361, -0.024898807, - 0.010853811, -0.014946853, -0.0039511407, -0.013912556, -0.038950108, - -0.0103492765, 0.009264526, 0.019815616, 0.0017784862, -0.0068364507, - -0.008097788, 0.00028458933, 0.013622448, 0.00034745914, -0.028203512, - 0.0008876664, 0.002376045, 0.015791949, 0.010008715, 0.007895974, - 0.0068238373, -0.014467544, 0.026235824, 0.012733204, 0.0013709165, - 0.02759807, -0.009207766, 0.026361959, 0.0021679243, 0.0071013314, - -0.0070382645, -0.013597221, 0.006325609, 0.00066023145, -0.01434141, - -0.008923965, 0.0032116813, 0.0030839709, 0.016611818, 0.0145053845, - 0.022350905, -0.027017854, -0.005921981, 0.03163435, -0.0283801, - 0.019361535, -0.012171909, -0.0029042303, 0.016271258, 0.02087514, - 0.030297333, -0.005537273, -0.027118761, -0.012310657, -0.024671767, - 0.0018573198, 0.017633501, 0.020345379, -0.0038786137, 0.0061931685, - -0.01967687, -0.00662833, -0.016864086, -0.015791949, 0.024734834, - -0.0016854625, -0.014631518, -0.02853146, -0.01321882, -0.0074418928, - -0.0016791559, -0.00969338, -0.014543224, -0.019727323, -0.0056634066, - -0.0014395018, -0.010778131, -0.041422334, -0.04881377, -0.014215277, - 0.004594423, -0.00959878, 0.015665814, -0.008715844, 0.0024643387, - -0.015665814, -0.00860863, -0.00834375, -0.0132945, 0.007435586, - -0.010450183, 0.028178286, 0.025907878, 0.03466156, 0.006565263, - 0.0007757227, 0.014845945, -0.005310232, -0.020509351, 0.0032920914, - -0.017986676, -0.014946853, 0.009794287, 0.018642573, 0.0305496, - 0.0027528696, 0.020105723, 0.0009034332, 0.0004891626, -0.015804563, - -0.0008774181, -0.016788406, -0.01441709, -0.016611818, 0.0046385694, - 0.002948377, 0.011206986, 0.018314624, -0.0000070827073, 0.022199545, - 0.014089143, 0.020433672, 0.003727253, 0.036023807, -0.020130951, - 0.026210599, 0.0034749855, 0.0073851324, -0.009668154, 0.006174248, - -0.0013551498, 0.010298823, 0.017128967, 0.01512344, 0.024179844, - -0.017772248, -0.015148667, -0.0034466053, 0.029994613, 0.0066913967, - 0.007858134, 0.006265695, -0.013836876, 0.0040867343, -0.015527068, - 0.0073472923, -0.013319727, 0.008520337, -0.005130491, -0.026261052, - 0.028985541, -0.009554634, -0.024924034, -0.0047836234, 0.0009018565, - 0.042456627, 0.0020417904, 0.010052862, 0.019411989, 0.0051588714, - -0.0072211586, 0.022010343, -0.02557993, -0.0042822417, 0.03367772, - 0.00063263974, 0.0037524798, -0.01912188, 0.0061174883, 0.002784403, - -0.01613251, -0.02860714, 0.01683886, 0.021631943, -0.0033267783, - -0.020698553, 0.013963009, -0.03367772, 0.015590135, 0.0004233365, - -0.013080073, -0.022300452, 0.0050138175, -0.012953939, 0.010500637, - -0.02853146, 0.02274192, 0.02426814, -0.0059945076, -0.011143919, - -0.00472371, 0.004496669, 0.0009909385, -0.013420634, 0.025680836, - -0.006672477, 0.015564908, 0.008766297, 0.00484669, -0.028657593, - -0.0026393493, -0.0014670935, 0.017797476, -0.021240927, 0.0015735188, - -0.008179775, 0.011434027, 0.006987811, 0.017494755, -0.008488803, - -0.0061332546, -0.004209715, -0.00096413505, 0.021531036, -0.013950395, - -0.006044961, -0.015678428, -0.013130526, -0.029490076, -0.0359229, - 0.0043074684, 0.0033173184, -0.031962298, -0.00843835, -0.008293295, - -0.0030887008, 0.02255272, 0.007971655, -0.010286209, 0.005231398, - 0.02251488, -0.023574403, -0.004569196, 0.011301586, 0.016674886, - -0.021064341, 0.023952805, -0.0030082904, -0.015766721, 0.004449369, - -0.016851472, -0.0064485893, 0.010639384, 0.009724914, 0.0055183526, - 0.0032826315, 0.0038943803, 0.027345803, 0.025907878, 0.008425736, - -0.010563703, -0.0019850302, 0.030373013, -0.007448199, 0.0024974488, - -0.0059251343, -0.00662833, 0.008766297, -0.009699687, -0.0037051796, - 0.00030508605, -0.0359229, -0.0097816745, -0.0034308387, 0.0095231, - 0.005758007, -0.015955923, -0.03024688, -0.019020973, -0.03506519, - 0.0029625671, 0.0029657204, -0.021480583, 0.01635955, 0.004212868, - 0.010670917, 0.0016097823, 0.006265695, -0.015110826, -0.024520406, - -0.008526643, -0.017292941, -0.011358347, -0.011591694, 0.023170775, - 0.0060638813, -0.008312216, -0.016460458, -0.006344529, -0.03410657, - -0.021076953, -0.011793508, 0.0041340343, -0.009119472, 0.0166875, - -0.009844741, 0.032315474, 0.0051494115, 0.0029893704, 0.0019361534, - -0.02573129, 0.012121456, -0.0037840132, 0.026563773, -0.005499433, - -0.026160145, -0.006218395, 0.008066255, 0.0131809795, -0.008520337, - 0.012373723, -0.013344954, -0.0052440115, -0.009201459, 0.0031517677, - -0.001259761, 0.0060481145, 0.024406886, -0.011591694, -0.0014182166, - -0.0016381624, -0.0060544214, 0.0057643135, -0.00019373359, 0.015363093, - -0.009813208, 0.02565561, -0.016069442, -0.004979131, -0.00092314155, - -0.021165248, 0.020194018, -0.021543648, 0.008968111, 0.024255525, - 0.009844741, 0.00066417316, -0.0023445114, 0.0014134867, -0.004449369, - 0.0070004244, 0.00000887494, -0.01321882, 0.0053070784, -0.007271612, - -0.015791949, -0.03849603, 0.0037335597, -0.024230298, -0.013912556, - 0.0011580657, 0.026462866, 0.014051302, -0.03226502, -0.010027635, - -0.017482141, 0.014480158, 0.008110402, -0.009958262, 0.0067923036, - -0.0033488518, -0.0047583967, 0.019575963, -0.021215701, -0.008425736, - 0.0092140725, 0.018163264, -0.0036294993, 0.037991494, 0.2401587, - -0.019639028, -0.008205002, 0.02285544, 0.02143013, 0.016952379, - 0.0031628045, 0.0028900402, 0.0037051796, 0.009825821, -0.006007121, - 0.00022428161, -0.012720591, 0.009415886, 0.0044525224, 0.007057185, - -0.02001743, -0.025151074, -0.027698977, -0.02573129, 0.008936578, - -0.028354872, -0.022994187, -0.017166806, 0.016447844, -0.012367417, - -0.012512471, -0.00674185, 0.030978454, 0.011692601, 0.0042160214, - -0.018415531, 0.014782879, 0.0017784862, -0.02367531, -0.013609834, - 0.026008785, 0.005915674, 0.026891721, 0.012411564, -0.013168366, - -0.0061931685, -0.0122412825, -0.014480158, 0.003478139, 0.011774587, - 0.0028411632, -0.029363943, 0.019311082, 0.032466833, 0.006013428, - 0.013988236, 0.02143013, 0.03312273, 0.0027780964, -0.005606646, - 0.00571386, 0.018617345, -0.01220975, -0.0022641013, -0.007845521, - 0.03715901, 0.004118268, 0.03685629, -0.019184947, 0.0028395867, - -0.026261052, -0.00956094, 0.008949191, -0.008394203, -0.01900836, - -0.0034024585, 0.007050878, -0.009573554, -0.026841268, -0.021985117, - 0.008501416, 0.006420209, 0.036452662, 0.036023807, -0.007202239, - 0.0020654406, 0.00018762398, -0.025668222, -0.03466156, -0.04003486, - -0.00024872003, -0.006912131, -0.011572774, -0.023662696, -0.008425736, - -0.018503824, -0.004058354, -0.0073220655, 0.016498297, 0.019361535, - 0.0009893618, 0.007372519, -0.010683531, 0.014858559, -0.011339426, - 0.011055625, 0.006931051, 0.0011407223, -0.00042018315, 0.011799815, - -0.0038849204, -0.0014008733, 0.00011480144, -0.012480937, -0.018629959, - -0.013496314, 0.008261763, 0.00475209, -0.009346513, 0.008299602, - -0.017696569, -0.0026109691, 0.00020398197, -0.0018021363, -0.006398136, - -0.013761194, -0.0061837086, 0.0011415107, 0.0003108015, -0.020231858, - -0.0065400363, 0.0073031457, 0.0147954915, -0.033475906, 0.0029184201, - -0.0030240573, 0.010910572, 0.005758007, -0.0062467754, 0.0012211326, - 0.016637044, -0.0012676445, -0.015993763, -0.0020685939, -0.005155718, - -0.0053890655, 0.0027449862, -0.008987032, -0.010078088, -0.0055088927, - 0.03693197, -0.022136478, -0.020433672, 0.0064958893, -0.039252833, - -0.012039469, -0.0058936006, -0.012562924, 0.023032028, -0.018024517, - -0.02180853, -0.014959466, -0.00081592787, 0.0045471224, -0.01152232, - 0.021795915, 0.028001698, -0.0059850477, -0.031609125, -0.019437214, - -0.16185486, 0.018869612, 0.016700111, -0.010803358, 0.021165248, - 0.015464, 0.028430553, -0.0039984407, -0.008892431, 0.010027635, - 0.0015924389, -0.011364653, -0.021745462, -0.017456915, 0.0005624778, - -0.020698553, -0.00067402737, 0.024671767, 0.039000563, 0.028758502, - 0.035746314, -0.0045092823, 0.0064706625, -0.011919642, 0.0084572695, - -0.0011123422, 0.0029278803, 0.027522389, -0.0098762745, -0.006067035, - -0.012846725, -0.0305496, 0.029111676, 0.007826601, 0.014290957, - -0.0054079858, 0.008116708, -0.039278056, -0.0027102996, 0.024205072, - 0.026891721, 0.0134837, 0.008110402, -0.015640588, -0.017974064, - -0.00023157372, 0.017683955, 0.011206986, 0.0194246, 0.0016555059, - 0.0058715274, 0.000562872, 0.006435976, 0.0004891626, 0.024205072, - 0.026462866, 0.010134849, 0.019840842, 0.010178995, -0.011894415, - -0.007492346, -0.00969338, 0.00033760493, -0.009863662, 0.010122236, - -0.0035538191, -0.002347665, 0.0136602875, -0.006880597, 0.020345379, - -0.009169925, -0.022022957, -0.009895194, -0.024810513, 0.011881801, - -0.00047339583, -0.04190164, 0.027799884, -0.003478139, -0.00078754773, - -0.0034024585, 0.0190462, -0.0036452662, 0.0026188525, -0.012462017, - 0.0035758924, -0.0012321693, 0.009933035, -0.024406886, -0.028001698, - 0.009106859, -0.0147954915, -0.016700111, -0.018529052, 0.004594423, - 0.0077256938, 0.018138036, 0.021594102, -0.0038975338, -0.012480937, - 0.0019125034, 0.012184523, -0.011024092, 0.0073662126, 0.015918082, - -0.01133312, 0.019512895, 0.0125187775, 0.014013463, -0.029439623, - -0.02296896, 0.007858134, 0.0104438765, 0.019916523, 0.013420634, - 0.025794357, -0.012253896, -0.010904265, 0.004266475, -0.011459254, - 0.050276924, 0.001933, -0.038622163, -0.0021032807, 0.004212868, - 0.008507723, -0.07583162, -0.04011054, 0.00473317, 0.01605683, - -0.00026842844, 0.029893706, -0.003117081, 0.005070578, 0.0143161835, - 0.0059629744, 0.0043169283, -0.026765587, -0.021240927, -0.011692601, - 0.0412962, -0.020484125, 0.0038187, -0.0019850302, -0.03241638, - 0.021152634, -0.012480937, 0.001238476, 0.00025719465, -0.004616496, - -0.026992628, 0.004540816, -0.02348611, 0.03514087, 0.0095924735, - -0.009251912, -0.023435656, -0.016195577, -0.0131809795, -0.0036736461, - -0.019500282, 0.016334323, -0.039858274, 0.03009552, 0.008331136, - -0.03241638, 0.03506519, 0.008753684, -0.011112385, -0.050428282, - -0.0070824116, 0.009151005, 0.0097816745, 0.039580777, 0.014921625, - -0.013395407, -0.014656745, -0.032239795, -0.027825112, 0.008242842, - 0.019285854, -0.0059282873, 0.009037485, 0.03498951, -0.012676445, - 0.008703231, 0.005915674, 0.003506519, -0.03562018, 0.016044216, - -0.010702451, 0.008135629, -0.023145547, 0.017255101, 0.015577521, - 0.0060764947, -0.017797476, 0.02457086, 0.0050674244, 0.011181759, - -0.0380924, 0.0015601171, -0.012127763, -0.024305979, 0.015325254, - -0.009251912, -0.032542516, -0.021240927, -0.0020449439, -0.0065904898, - 0.031205496, 0.013950395, -0.002915267, 0.0042160214, -0.0132945, - -0.03032256, -0.022590559, 0.00954202, 0.0081734685, -0.0113898795, - 0.005376452, 0.0046984833, -0.012335883, 0.002096974, 0.0119511755, - 0.020849913, -0.021606715, -0.015955923, -0.066901356, 0.022275224, - -0.012089922, -0.014202663, 0.011358347, -0.013849488, 0.010904265, - -0.025907878, 0.0018147497, -0.0092140725, -0.02195989, -0.0059377477, - 0.0011115539, 0.005953514, -0.02580697, 0.0069751977, 0.024432112, - 0.014366637, 0.013143139, -0.00032282362, 0.0045534293, -0.026639454, - -0.019437214, 0.00841943, -0.01765873, 0.0102546755, -0.029136902, - 0.0046543363, -0.004241248, -0.012443097, 0.0020843607, -0.043314338, - -0.00007848871, 0.033299316, 0.002342935, -0.010910572, -0.003150191, - 0.015741495, 0.010229449, 0.020383218, -0.036276072, -0.021076953, - 0.017192034, -0.003199068, -0.0028017466, -0.0035916592, -0.0034213786, - -0.0146945845, 0.018579505, 0.016750565, -0.0032037979, 0.030524373, - -0.0246087, -0.0094032725, -0.023032028, -0.008015801, -0.020294925, - -0.0077446136, -0.009163619, -0.04197732, 0.020332765, 0.0017942529, - 0.01594331, -0.0073914393, 0.0064769695, 0.0025715523, -0.019790389, - -0.0019692637, -0.016309097, -0.028001698, -0.0056003397, -0.0067229304, - 0.006319302, 0.012216056, 0.023650084, 0.018655185, -0.01220975, - 0.019475054, -0.039883498, 0.0363013, 0.017986676, 0.026160145, - -0.025756517, -0.000762321, 0.02931349, 0.006388676, -0.009964569, - -0.009510486, -0.005786387, 0.006521116, -0.030347787, -0.017860543, - 0.0044745957, 0.033375, -0.005606646, 0.003025634, 0.019348921, - 0.009264526, 0.022905894, 0.018238943, 0.003459219, 0.0067796903, - -0.0072905323, 0.0028301266, -0.018617345, -0.0015522338, -0.005448979, - -0.03947987, -0.004707943, 0.01628387, 0.009144698, 0.019462442, - -0.0009877852, 0.011837655, -0.029590983, -0.0056823264, 0.022767147, - -0.012348496, -0.03256774, 0.034712017, -0.0064485893, -0.0036452662, - 0.027043082, -0.027825112, 0.011989015, 0.0020607105, -0.0030855474, - -0.0039763674, 0.018655185, -0.0020906674, 0.017721795, -0.003323625, - -0.012707978, -0.019803002, -0.0092140725, -0.0001313565, -0.009983488, - 0.024142005, -0.009289753, 0.059585594, -0.0038596934, -0.0059566675, - 0.014391864, 0.01624603, 0.019954363, 0.013382793, 0.022653626, - -0.007454506, -0.02352395, -0.013597221, 0.010412343, -0.0053323056, - -0.020433672, -0.01262599, 0.00066456734, -0.020156177, -0.0038123934, - -0.010027635, 0.009775368, 0.023246454, 0.006026041, 0.00948526, - 0.012443097, -0.019966977, -0.016788406, 0.006987811, 0.009378046, - -0.018440759, -0.032618195, 0.01617035, 0.003136001, -0.0021647708, - -0.0069373576, 0.0016618125, -0.0004698483, -0.005108418, -0.0052818516, - 0.0083626695, 0.011932255, 0.015085599, 0.005061118, -0.01620819, - -0.030726187, 0.013761194, 0.0053354586, -0.031079363, -0.0152748, - -0.0070824116, - ], - }, - { - object: "embedding", - index: 1, - embedding: [ - 0.004755357, -0.0061093355, 0.0076572094, -0.0033225059, -0.0232674, - 0.004886811, -0.0229782, 0.0006506985, -0.010529485, -0.020086206, - 0.027894588, 0.023950962, 0.0076769274, 0.0055802325, 0.016773561, - -0.0040389313, 0.03007673, -0.0017384823, 0.017733177, 0.010128549, - -0.0054192008, 0.01686558, 0.009957658, -0.0002961828, -0.016247744, - -0.0109435655, 0.001574986, -0.02140075, 0.020559443, -0.028525569, - 0.01410504, -0.004738925, -0.024266452, -0.011232764, -0.009497569, - -0.016076853, -0.021492768, -0.01873223, 0.012231817, -0.011659991, - 0.0016029201, 0.006888202, -0.005540796, -0.0015905963, -0.03812173, - 0.014407384, 0.02050686, 0.0058694314, -0.006710739, 0.013316314, - 0.013868422, 0.0052647423, -0.023030782, -0.0079727, -0.027894588, - 0.016300324, -0.032732103, 0.014644002, 0.018088102, -0.007532328, - 0.012547307, -0.019954752, -0.016050562, 0.018166976, -0.0004785756, - 0.0094449865, 0.010516339, 0.0005751123, -0.042039067, 0.018535048, - 0.012212099, 0.012599888, 0.013618659, -0.0017861344, 0.012948242, - -0.0046304753, -0.011160465, 0.0076769274, 0.0075389002, -0.0028788478, - 0.0231228, -0.039909504, -0.028315242, 0.01456513, 0.02760539, - -0.0013211151, -0.015445873, 0.005908868, -0.009438414, -0.02232093, - 0.008091008, 0.019810153, 0.0020013908, 0.02855186, -0.018482465, - 0.009247806, -0.010516339, 0.034861665, 0.008938888, -0.032732103, - -0.004075081, -0.009668459, -0.01789092, -0.009734186, -0.0065069846, - -0.013059978, 0.0048999568, -0.008682553, 0.022360366, -0.010089112, - -0.016931305, 0.023280546, 0.0023415287, -0.024739686, 0.009543577, - -0.010457184, 0.0027950457, -0.0031532585, -0.024134997, -0.019718135, - 0.013631804, 0.030549964, 0.021663658, -0.038989328, 0.010115404, - -0.0009793341, -0.01783834, -0.021545349, 0.006382103, -0.0018091389, - 0.026790373, 0.0046206163, 0.022426093, -0.009076915, -0.004535171, - 0.0061093355, -0.00094400573, 0.018377302, -0.0017286232, 0.0015766292, - 0.026369719, 0.03473021, 0.009563296, -0.02513405, -0.011147319, - 0.014170767, -0.004052077, -0.007282565, 0.008130444, -0.01459142, - 0.028446697, 0.0076506366, 0.013986731, -0.011042156, 0.028972514, - 0.01873223, -0.022767873, 0.01001024, 0.0016037417, -0.0032091266, - 0.008754852, -0.0009251092, 0.0006938319, -0.026527464, 0.018206412, - 0.018140685, 0.020914368, -0.0013170071, -0.00075052155, -0.022583839, - -0.008820579, 0.017746322, -0.03199596, 0.0071971193, -0.024345325, - 0.042012773, 0.0044102897, 0.0033372943, -0.0046896297, -0.022767873, - -0.03231145, 0.010075967, 0.009997095, 0.02639601, 0.011134174, - 0.016392343, 0.008590534, -0.009247806, 0.011824309, -0.025081469, - 0.0054257736, 0.023885235, 0.012507871, 0.0014805034, -0.67683154, - -0.009458132, 0.025896484, 0.007920118, 0.0077492273, -0.0034572463, - 0.042985536, 0.022268347, 0.01124591, 0.022018585, -0.019915316, - 0.010680657, -0.023780072, -0.016379198, -0.012047781, -0.00581685, - -0.0041802446, -0.035282318, -0.0022396515, 0.012402707, -0.0007521647, - 0.035466354, 0.00006136243, -0.0039206226, 0.010936992, -0.01505151, - -0.00831448, -0.020099353, -0.010969856, -0.0014295648, -0.012028063, - 0.013684386, -0.028709605, -0.0051037106, 0.06735715, 0.00799899, - 0.012547307, -0.0043609943, 0.0034605328, 0.016852433, -0.005629528, - -0.012928524, 0.010424321, 0.011311637, -0.0030020862, -0.004331417, - 0.013349177, -0.008215889, 0.0012340266, -0.010457184, 0.0030365929, - -0.011410228, 0.025436394, 0.017825194, -0.0028361252, 0.020953806, - 0.025804466, -0.0006568604, -0.0060074585, -0.0017253369, 0.004314985, - 0.006152058, -0.008899452, 0.00313847, -0.020888079, 0.024687106, - -0.007394301, 0.024555651, 0.012672189, -0.011370791, 0.0017023324, - 0.021335023, -0.016418634, 0.0022692287, 0.023911526, 0.021887131, - 0.0073154285, -0.016615815, -0.011719145, 0.013342605, 0.021663658, - -0.015064656, 0.001071352, -0.009615878, 0.013842131, -0.021821404, - -0.016773561, -0.0068093296, -0.020612024, 0.0036741458, 0.0039271954, - 0.012271253, -0.0036708596, -0.011042156, 0.01597169, 0.0023152377, - -0.020059917, 0.010135122, 0.024148144, 0.0065628528, -0.0023300264, - 0.0032715674, 0.0086365435, -0.00620464, -0.008899452, -0.0013128992, - -0.011988627, 0.012225244, 0.019481517, -0.022307783, 0.004804652, - 0.002614296, -0.004673198, 0.01691816, 0.008886307, -0.02559414, - 0.0070130834, 0.00079242256, 0.00239904, -0.024437342, 0.0063755303, - 0.012823361, 0.019612972, -0.0013309742, 0.0022150038, -0.000016483129, - 0.00352626, 0.0082816165, -0.035150863, 0.0006470013, 0.0068553383, - -0.020191371, 0.010391457, -0.00489667, 0.0014238138, -0.0036807186, - 0.014013021, -0.011784872, 0.0017992798, 0.02050686, -0.008064717, - -0.019902172, -0.026264556, 0.0040159267, 0.014946347, -0.021624222, - 0.0020523292, -0.0021377746, -0.016523797, -0.0055933776, 0.029366877, - -0.007394301, -0.010996147, 0.022610128, 0.0021443472, -0.018495612, - -0.010779248, -0.016563233, -0.04440524, -0.008984897, 0.037990276, - 0.019021427, -0.010161413, -0.004975543, -0.011765154, -0.014144476, - -0.01110131, 0.007598055, -0.014197057, -0.023398854, 0.010161413, - -0.019481517, -0.015866525, 0.005616382, 0.0015100805, 0.010726666, - -0.013526641, -0.024844851, -0.005136574, -0.0133951865, 0.0008758138, - -0.007091956, -0.023372563, 0.0046797707, 0.012639325, -0.016734125, - 0.0017187642, 0.037333004, -0.02220262, 0.012284398, 0.029629786, - 0.025252359, -0.030208183, -0.011022437, 0.012836507, -0.007847818, - 0.006293372, 0.0047750752, 0.014381093, 0.011890036, 0.018666502, - -0.0018157116, 0.015774509, -0.0035426917, 0.022255203, -0.026593192, - 0.00025613036, -0.027789425, -0.0049229614, 0.015905963, -0.004883525, - 0.009970804, -0.0077229366, 0.02821008, -0.004308413, 0.0462456, - 0.015025219, -0.0029987998, -0.016497506, -0.00553751, -0.0019898885, - 0.006408394, -0.002124629, 0.0057314048, 0.0026570188, 0.016852433, - -0.0012981106, 0.03323163, 0.0083867805, -0.043064408, -0.024437342, - -0.019573536, 0.016274035, 0.006510271, -0.009050624, -0.0052614557, - 0.016957596, -0.012862797, 0.032390323, -0.004449726, -0.020980095, - 0.008084436, 0.020427989, 0.00045844665, -0.012277826, 0.029235423, - 0.007992418, -0.012402707, -0.0046797707, 0.02002048, -0.020441134, - 0.00991165, -0.016707834, 0.015774509, 0.0076769274, -0.0078083817, - 0.0018452888, -0.004137522, 0.01919232, 0.03199596, -0.001892941, - 0.006510271, 0.008268472, 0.0024039694, -0.009464705, -0.02237351, - 0.021124696, -0.013138851, 0.0112722, -0.008491944, -0.017049614, - -0.0073088557, 0.0059975996, -0.014157621, 0.030287055, 0.00236289, - 0.0148280375, -0.017443977, -0.011436518, 0.0023760353, 0.007900399, - -0.009661886, -0.0009390762, 0.025725594, -0.0128956605, -0.034572463, - -0.015169819, 0.005567087, -0.001265247, -0.00028591297, -0.029866403, - 0.022859892, -0.0018551479, 0.014486257, -0.018981991, -0.010036531, - 0.010923847, -0.012034635, 0.0021739244, 0.022018585, 0.008472226, - 0.016366052, 0.014867474, -0.016208308, 0.001247172, 0.008807434, - -0.0035887007, -0.010220567, -0.00017828481, -0.0125012975, - -0.0061257672, -0.020572588, -0.010812111, -0.018114394, 0.010016813, - -0.001597169, -0.016812997, 0.013671241, 0.02947204, 0.015261836, - -0.008767998, -0.01117361, -0.01139051, -0.01294167, 0.10048362, - 0.014394239, -0.02401669, 0.022623274, -0.012836507, 0.010213994, - -0.029971566, -0.034362137, -0.0038581819, 0.0075060367, -0.008491944, - 0.005225306, 0.0011839097, 0.02122986, 0.01754914, -0.0007620238, - 0.0027293186, -0.0017532709, 0.0063032308, 0.0077426545, -0.0035426917, - 0.013027115, -0.017194213, 0.02128244, 0.013007397, 0.001219238, - -0.01265247, 0.014893765, -0.0025633576, -0.012014917, 0.016786706, - 0.0004995261, 0.0017664162, 0.0037037232, -0.013802695, 0.027263608, - 0.02122986, 0.022176329, 0.006750175, -0.017299378, 0.025554704, - 0.004965684, -0.0064511164, -0.01919232, -0.011535109, -0.002576503, - -0.019691845, 0.010345449, -0.010043103, -0.027579099, 0.034914244, - -0.0049525383, -0.016681543, -0.02763168, -0.0032929287, 0.015932253, - -0.0122515345, -0.013710677, -0.010174558, -0.0004913102, -0.008505089, - -0.026133101, -0.023964107, -0.0074468823, -0.016957596, -0.039830633, - -0.03136498, -0.011495673, -0.04406346, -0.013736968, 0.015564182, - -0.033336796, -0.024752833, 0.008728561, 0.011594264, 0.008018709, - 0.004479303, -0.016497506, 0.0023316694, 0.0057544094, -0.002198572, - -0.028578151, -0.0038581819, -0.0010006954, 0.005162865, 0.020125644, - -0.0014468182, -0.00061578094, -0.03383632, 0.03509828, 0.016826142, - -0.0025157055, 0.021164132, -0.010812111, 0.024424197, -0.0022971628, - 0.011357646, 0.0071642557, -0.014183912, 0.010016813, 0.014118185, - -0.004295267, -0.01456513, 0.0027638252, -0.0012636038, 0.018390447, - 0.018535048, 0.022925619, -0.009490996, 0.0029051385, 0.024200724, - -0.025699303, -0.002242938, -0.010950138, -0.002686596, 0.013158569, - 0.016379198, 0.028709605, 0.0048440886, -0.009668459, -0.004755357, - -0.023359418, -0.0071971193, 0.00947785, 0.0030053724, -0.0049722563, - 0.004709348, -0.022294639, -0.014078748, 0.0016308541, -0.01424964, - 0.017772613, -0.0050248383, -0.01631347, -0.024437342, -0.00993794, - -0.0034703917, 0.0016481074, -0.010851547, -0.018719083, -0.01827214, - 0.0010828542, -0.014197057, 0.007374583, -0.026698355, -0.036570568, - -0.0050905654, 0.015367, 0.0029347157, 0.017746322, -0.02125615, - 0.0058464273, -0.007946408, 0.0047750752, -0.0062835123, -0.026461737, - -0.018219557, -0.02105897, 0.011226192, 0.027237318, 0.023043927, - 0.014407384, 0.00479808, 0.025186632, 0.011909754, -0.009372687, - -0.0017894208, -0.016878724, -0.015340709, 0.02168995, 0.0044825897, - 0.00736801, 0.00384175, 0.001911016, 0.0028196934, -0.00043749614, - -0.004147381, -0.019139737, -0.0015347282, -0.0072168377, -0.009983949, - -0.016260888, -0.009832777, 0.0073482916, -0.00035431024, 0.0005915441, - 0.03383632, -0.0004950074, -0.0046107573, 0.0042032492, 0.011022437, - -0.019389499, 0.030734, -0.000022208576, 0.008215889, -0.027763134, - 0.0121069355, 0.020086206, 0.0059220134, 0.025081469, -0.005327183, - 0.016615815, -0.024923723, -0.0099445125, 0.009293814, 0.014788602, - 0.0046600527, -0.0034671056, 0.0041835313, 0.0005151363, 0.0021706382, - -0.02668521, -0.013441196, -0.021979148, -0.016536944, -0.0030037293, - -0.0043445625, 0.03381003, -0.019915316, -0.030576255, -0.010213994, - -0.0030678133, 0.027815716, -0.007939836, 0.026882391, 0.009458132, - -0.016129434, -0.006552994, 0.021124696, -0.013750114, -0.00002291463, - 0.032442905, -0.012757634, 0.0028279093, -0.0058037047, -0.008886307, - 0.029498331, -0.00712482, -0.035150863, 0.01413133, 0.009142642, - 0.008728561, -0.008623398, -0.008669407, -0.010575493, 0.026632627, - -0.005044556, -0.012731343, -0.022242056, -0.00017982529, 0.0070065106, - 0.016208308, -0.033284213, 0.038910452, 0.02530494, -0.019350063, - 0.005297606, 0.0045844666, 0.009352969, -0.0074205915, -0.01582709, - 0.026264556, 0.0034309556, -0.009287242, -0.004055363, -0.01766745, - -0.010798966, 0.013224296, 0.010181131, 0.013513495, -0.01958668, - -0.0057576955, -0.020612024, 0.0046567665, 0.016339762, 0.009642168, - -0.009537005, -0.01936321, -0.008702271, -0.013027115, 0.02792088, - -0.003084245, -0.008590534, -0.014512547, -0.015485309, -0.036439113, - -0.0069210655, 0.0014821466, 0.014801747, -0.018692791, 0.00096208067, - -0.014328511, -0.0083867805, 0.034914244, 0.00073162495, 0.004561462, - -0.012961388, 0.014604566, -0.014841183, 0.012678761, 0.02004677, - 0.024279598, -0.015314419, -0.0024910579, -0.0014271, -0.0137895495, - 0.01243557, 0.0006400178, 0.0045121666, 0.008018709, 0.001519118, - -0.0073154285, 0.0021016246, -0.0013819126, 0.0036248507, 0.021558495, - 0.015301273, -0.025804466, -0.0080121355, 0.027447645, 0.0005734691, - 0.008873161, 0.0008938888, 0.0000558167, -0.011870317, -0.00025695196, - -0.017115341, 0.0025370668, -0.021755677, -0.007039374, 0.0011986983, - 0.028131207, 0.0033783738, -0.037595913, -0.029682366, -0.0013564434, - -0.007282565, 0.015787654, 0.011890036, -0.0004411933, 0.0065990025, - 0.02111155, 0.008445934, 0.003933768, 0.020454278, -0.006296658, - 0.0052121603, 0.0022462243, -0.017825194, -0.017706886, -0.0012636038, - 0.031443853, 0.0074271644, -0.0045121666, -0.0054060556, 0.009418696, - -0.010135122, 0.011646845, -0.012468434, 0.029340586, -0.0067567476, - 0.0068947747, -0.00048638068, 0.03596588, 0.011870317, 0.009918222, - 0.0054980735, -0.010332303, 0.0043741395, 0.018232703, 0.023504017, - 0.0045088804, -0.028972514, -0.007387728, 0.011837454, 0.0075126095, - -0.0082618985, 0.0036084189, 0.0017204073, -0.015800798, 0.0011017508, - -0.0047027753, -0.018587628, 0.013132278, 0.007801809, -0.009753904, - -0.007183974, 0.006875057, -0.0100496765, 0.026593192, -0.0031680472, - 0.009287242, -0.006066613, -0.004525312, -0.0061849216, 0.010936992, - 0.0126261795, -0.021177277, 0.0023398853, -0.017641159, 0.0026619483, - 0.038042855, 0.0017335528, -0.011896608, 0.017167924, -0.016379198, - -0.015090946, 0.008741707, 0.008084436, -0.020033626, 0.011324783, - -0.012402707, -0.019783862, -0.04322215, -0.000015006836, -0.024345325, - -0.01686558, -0.011581118, 0.01410504, 0.030313347, -0.03139127, - -0.0053600464, -0.016037418, 0.02140075, 0.0005434811, -0.014223348, - 0.008971752, -0.02884106, -0.021453332, 0.009983949, -0.021374458, - -0.015564182, 0.008393353, 0.012139799, 0.0033948056, 0.035545226, - 0.2410345, -0.02122986, -0.0025107758, 0.021466477, 0.013276878, - 0.024213871, -0.0059121544, -0.007906972, 0.006372244, -0.0004765216, - -0.013408332, 0.007690073, 0.002446692, -0.00013782155, 0.0073548644, - -0.0039206226, -0.04408975, -0.026842955, -0.017246796, -0.011364219, - -0.008222463, -0.025002595, -0.015905963, -0.0009957658, 0.024305888, - -0.014683438, -0.012488153, 0.0054290597, 0.02389838, 0.0056196684, - 0.015445873, -0.021992294, 0.0063393805, 0.014197057, -0.0014344944, - -0.017220505, 0.014670293, -0.015787654, 0.019967899, 0.02823637, - -0.030839164, 0.013592368, -0.008268472, -0.0112130465, -0.0054356325, - 0.019547245, -0.007992418, -0.011094738, -0.0014698227, 0.030050438, - -0.011285346, -0.00071889034, 0.019652408, 0.03538748, 0.010075967, - 0.012619606, -0.002068761, 0.014183912, -0.032469198, -0.0062375036, - -0.007387728, 0.018535048, -0.012823361, 0.0029527908, -0.028315242, - 0.018508757, -0.031259816, -0.0066614435, 0.028604442, 0.0004399609, - -0.009714468, -0.0034933963, -0.010772674, 0.013178287, -0.02947204, - -0.017470269, -0.003555837, 0.0072694193, 0.018758519, 0.019310627, - -0.020572588, 0.01488062, 0.006326235, -0.018653356, -0.014144476, - -0.04130292, 0.026553756, -0.013204578, 0.00044817678, -0.0022084313, - 0.009629022, -0.028131207, -0.011305064, -0.0049722563, 0.01864021, - 0.0231228, 0.0068553383, 0.0028837773, -0.015905963, 0.00034424578, - 0.011988627, -0.041118886, 0.00581685, -0.0064281123, -0.007065665, - -0.019547245, 0.003545978, 0.0077689453, 0.0009505784, -0.030576255, - -0.021834549, -0.014722874, 0.001615244, 0.005070847, -0.0042591174, - 0.014959492, -0.0014188841, 0.00831448, 0.00082446454, -0.012166089, - 0.021558495, -0.014157621, 0.008715416, -0.0017697026, -0.013184859, - -0.016642107, -0.005885863, -0.0037825957, 0.022570692, -0.025291795, - -0.0032666377, -0.0038746137, 0.03281098, -0.003983063, -0.013684386, - -0.004367567, 0.014013021, -0.009221515, -0.012396134, 0.015498455, - -0.012856225, 0.002122986, 0.009096633, -0.00507742, -0.004413576, - 0.0047750752, 0.02763168, -0.0037431594, -0.016878724, -0.0044102897, - -0.028104916, -0.016011126, -0.021992294, -0.010430894, 0.024555651, - -0.0053469012, -0.03194338, -0.020257099, -0.0123566985, 0.014841183, - -0.043432478, 0.0136449495, 0.030497383, 0.0014673579, -0.04025129, - -0.017706886, -0.16983888, 0.021387605, 0.014315367, 0.0016637177, - 0.038332056, 0.013250587, 0.017851485, 0.00877457, 0.00690792, - -0.009872213, 0.018206412, 0.0014024524, -0.011725718, 0.005494787, - 0.014394239, -0.020401698, -0.01752285, 0.026198829, 0.031496435, - 0.011508819, 0.012041208, -0.00076366693, 0.008307908, -0.0018995138, - 0.018074958, 0.008183026, 0.019442081, 0.029314294, -0.020073062, - 0.008577389, -0.021926567, -0.03883158, 0.033678576, 0.013973585, - 0.0198233, 0.010680657, -0.008998043, -0.02168995, -0.0062506488, - 0.0020983382, 0.02823637, 0.031154653, 0.009510714, 0.020717187, - -0.011252482, 0.0034933963, 0.0017779185, -0.0009390762, 0.014262784, - -0.015419582, 0.016523797, -0.0089257425, -0.01025343, -0.0037924547, - 0.008912597, 0.024161289, 0.0058365683, 0.011055301, -0.012468434, - 0.0087811425, -0.039620306, -0.003996209, -0.010141694, -0.006526703, - 0.002280731, -0.0054159146, 0.013605514, 0.018035522, -0.0030513816, - 0.015800798, 0.0026389437, -0.012902233, 0.028946223, -0.011502245, - 0.0069013475, 0.013868422, -0.022018585, 0.01754914, 0.012067499, - -0.012468434, -0.029419458, 0.02533123, -0.017154777, 0.0033455102, - 0.008321053, 0.0022675856, -0.0092806695, 0.0034933963, -0.029840112, - -0.017430833, 0.026777228, -0.02608052, -0.015840236, -0.00705252, - 0.0047619296, 0.022018585, -0.0014517477, 0.013736968, -0.012698479, - -0.0044464394, 0.0011609052, -0.004144095, -0.008038427, -0.0114825275, - 0.023201672, -0.019336918, 0.021085259, 0.003361942, 0.011298492, - -0.0045154532, -0.01987588, 0.009924795, 0.016707834, 0.02215004, - 0.0049196747, 0.01350035, -0.0051102834, 0.009983949, -0.0004469444, - 0.0008593821, 0.04840145, -0.012764206, -0.01674727, 0.012054353, - -0.0018715797, -0.0030612405, -0.095225446, -0.031233527, 0.003730014, - 0.015643055, -0.0070985286, 0.002012893, -0.009326678, 0.015774509, - -0.0018633638, 0.018377302, 0.00430184, -0.011646845, -0.045798656, - -0.009957658, 0.029314294, -0.018850537, 0.018114394, -0.004485876, - -0.011607409, 0.03940998, -0.0008947104, 0.0011962336, -0.012685333, - 0.012882515, -0.026882391, -0.0100496765, -0.026133101, 0.026619483, - 0.0084064985, -0.004715921, -0.025988502, -0.0115614, 0.00356241, - -0.011653418, -0.0012143085, 0.003996209, -0.028604442, 0.018403593, - 0.01599798, -0.04035645, 0.0155116, 0.016589524, -0.022741582, - -0.039567724, 0.00027194596, -0.012816788, 0.008327626, 0.01984959, - -0.0069999383, -0.01873223, -0.032679524, -0.039015617, -0.020993242, - 0.008321053, 0.022478674, -0.004699489, 0.0238458, 0.018482465, - -0.005678823, 0.020151934, 0.0042689764, -0.0018995138, -0.028683314, - 0.03785882, 0.0006474121, -0.005402769, -0.012304116, 0.014341657, - 0.022912472, 0.0037727365, -0.01396044, 0.03007673, 0.006953929, - 0.012737916, -0.032127414, -0.010496621, -0.013487205, -0.010490048, - 0.024134997, -0.0068487655, -0.019152882, -0.02358289, 0.008564243, - -0.0064511164, 0.015459018, 0.0069473563, 0.0030168747, -0.004903243, - -0.0017023324, -0.01645807, 0.0060929037, 0.013059978, 0.015104092, - -0.026842955, 0.0008749923, 0.01815383, -0.000597706, -0.0006014031, - 0.0069867927, 0.0016472859, -0.019179173, -0.0019898885, -0.05978539, - 0.03451988, -0.01873223, -0.021216713, 0.018692791, -0.014814893, - -0.010687229, -0.00007671587, -0.0235566, -0.0063492395, -0.011061874, - 0.012461862, 0.001469001, -0.0063656713, -0.033284213, -0.0038581819, - 0.020927515, 0.01296796, 0.022596983, 0.0039929226, 0.0050642747, - -0.0051004244, 0.0014057388, 0.0027523232, -0.022557547, -0.0042591174, - -0.036412824, 0.0063229487, 0.008721989, -0.025896484, 0.01783834, - -0.050425846, -0.010141694, 0.020822352, 0.005945018, 0.000049115617, - -0.032732103, 0.009352969, 0.01410504, 0.013986731, -0.040987432, - -0.03914707, 0.017943503, -0.016274035, 0.007322001, 0.0027227458, - -0.0061257672, -0.0013991661, 0.0033750874, 0.0265669, -0.0036577142, - 0.04035645, -0.01328345, 0.0043379897, -0.0026980983, 0.0009760477, - 0.008498516, 0.00845908, -0.012041208, -0.022136893, 0.019376354, - 0.027447645, 0.02510776, 0.00067493535, 0.004249258, 0.015813945, - -0.025370667, -0.02234722, -0.0341781, -0.04069823, -0.0052844603, - 0.014223348, 0.023964107, 0.022518111, 0.022846745, 0.0040323585, - -0.015248692, 0.028683314, -0.05799761, 0.0145388385, 0.016786706, - 0.0013975229, -0.03041851, 0.0049295337, 0.020401698, -0.010969856, - -0.014722874, -0.004729066, -0.009813059, 0.015564182, -0.03291614, - -0.012310689, 0.02889364, 0.011443092, -0.025515268, 0.0003797795, - 0.015367, 0.0039436272, 0.014473111, 0.0010409532, -0.012448716, - 0.018245848, -0.01936321, 0.004525312, -0.014262784, 0.026882391, - -0.019402646, -0.025646722, -0.0033372943, 0.014512547, 0.0009678318, - 0.03507199, 0.0059121544, 0.007985845, -0.013736968, 0.0109435655, - 0.0027457504, -0.00046748412, -0.028420405, 0.05271315, -0.0027309617, - 0.004413576, 0.030865455, 0.00053197885, 0.02030968, -0.014696583, - -0.03162789, -0.007821527, 0.015472163, -0.010075967, 0.014236494, - 0.0039501996, -0.017404541, -0.014551984, -0.0076703546, -0.010220567, - 0.003887759, 0.044773314, -0.010779248, 0.040908556, 0.016957596, - -0.0117783, 0.016300324, 0.01325716, 0.010634648, -0.0006387854, - 0.020138789, -0.026750937, -0.017996086, 0.01296796, -0.0013810911, - -0.00044489044, -0.013842131, -0.013539786, 0.00006752434, -0.024608232, - 0.0006852052, -0.010233712, 0.02263642, 0.034256972, -0.00013535678, - 0.026146248, 0.013684386, -0.02467396, -0.0026668778, -0.0014542125, - 0.0026652347, -0.0056919684, -0.029393166, 0.014236494, 0.0014928272, - 0.0069210655, -0.009103206, 0.024161289, -0.00489667, -0.0031072495, - -0.015235546, -0.013539786, 0.009537005, 0.018719083, -0.0068356204, - -0.02030968, -0.019665554, 0.01970499, 0.009845923, -0.026317138, - -0.018311575, -0.007795236, - ], - }, - ], - model: "text-embedding-ada-002", - usage: { - prompt_tokens: 5, - total_tokens: 5, - }, -}; - -const EMBEDDING_BYE_WORLD = { - object: "list", - data: [ - { - object: "embedding", - index: 0, - embedding: [ - -0.025122926, -0.019487135, -0.0280202, -0.031062996, -0.0247525, - 0.027543936, -0.012554849, -0.008420613, -0.017608538, -0.008347849, - 0.03251825, 0.0041871546, -0.02471281, -0.00062964414, 0.014129166, - -0.0015941615, 0.039397616, 0.0020753865, 0.027041212, -0.012409323, - -0.021048224, 0.008923335, 0.008394153, -0.0032677003, -0.005410888, - -0.009624502, 0.011165745, -0.0015660487, 0.0035554431, -0.023297248, - 0.0068661394, -0.007818667, -0.023905808, -0.008910106, 0.006846295, - -0.01370582, 0.009598043, -0.014115936, 0.02201398, -0.010517497, - 0.0033652682, -0.014671577, 0.0053348183, -0.014922939, -0.031803854, - 0.016298812, -0.005529954, -0.0066710035, -0.009763412, 0.034687895, - 0.02645911, 0.009121778, -0.019592972, -0.007924504, -0.0057250904, - -0.0057019386, -0.0135404505, 0.006300576, 0.00084669155, -0.03870968, - -0.0003724947, 0.019010872, -0.015518269, 0.018746281, -0.00024309309, - 0.010742399, 0.019235775, 0.0040217848, -0.004544352, 0.022146277, - 0.02532137, 0.01729103, 0.006905828, -0.018018655, 0.019143168, - -0.010927613, -0.007329174, -0.0054274253, -0.014618659, 0.0012601152, - 0.015915155, -0.025096467, -0.008499989, 0.013242785, 0.018971182, - 0.015161071, -0.021709701, 0.023879347, -0.009743568, -0.029025646, - -0.0017711067, 0.018005425, 0.008797655, 0.02500386, -0.021339273, - 0.002852623, -0.015002316, 0.03159218, -0.0018207176, -0.008189095, - -0.0013361851, 0.013758738, -0.00071398256, -0.004005248, -0.032385953, - -0.009512051, -0.012019051, -0.0073159444, 0.02382643, 0.010034618, - -0.0052521336, 0.026710473, -0.00253346, -0.044583604, -0.014856791, - -0.0066511594, -0.005255441, -0.003681124, -0.012217495, -0.020730713, - 0.016801536, 0.0021564176, 0.026776621, -0.0036248984, 0.021947833, - 0.004378983, -0.017383637, -0.016999979, 0.0045873486, -0.006429564, - 0.03357661, 0.00364805, -0.0038398786, -0.0044947416, -0.02051904, - 0.01934161, -0.02139219, 0.025122926, -0.039635748, -0.026882457, - -0.014459904, 0.032677002, -0.00031213483, -0.0036348205, -0.023456002, - 0.0085066045, 0.013256015, -0.0010542303, 0.00654863, -0.014393757, - 0.0008987829, 0.0012278681, 0.012257183, -0.0043988274, 0.0020555423, - 0.013639672, -0.01025952, 0.008453686, -0.006743766, -0.013242785, - -0.011926444, 0.0031155604, 0.012594537, -0.00879104, -0.010610104, - 0.023045886, 0.01759531, 0.016814765, -0.0013849691, -0.002988226, - 0.011430336, 0.011046679, -0.035217077, 0.02115406, 0.0025351136, - 0.0098031005, 0.018217098, 0.016034221, -0.02409102, -0.041567266, - -0.016232666, 0.00847353, 0.01934161, 0.03841863, -0.012720218, - 0.009366525, 0.017052898, 0.00967742, 0.0026839462, -0.020942386, - 0.008797655, 0.022463785, 0.033708908, -0.013256015, -0.7036007, - -0.00573832, 0.026564948, 0.009346681, 0.013560294, 0.048393715, - 0.025070008, 0.013236171, -0.022450557, 0.03778361, 0.012627611, - 0.017634997, 0.007236567, -0.009221001, 0.008817499, 0.0008437976, - -0.0034661435, -0.0032759688, 0.0060161403, 0.0020588497, -0.013070801, - 0.006813221, -0.020082466, 0.015346285, 0.0045873486, 0.0029948407, - 0.017013209, -0.007382092, -0.01265407, 0.02139219, -0.013427999, - 0.005817697, 0.0072431816, -0.004216921, 0.038947813, -0.003095716, - 0.0077855936, 0.02262254, 0.009174697, 0.03982096, -0.010682866, - -0.016775077, 0.003614976, -0.0023912422, 0.012316717, 0.0061848173, - -0.0012642494, -0.0009012635, -0.00037208127, -0.0077260607, - 0.014949398, -7.509452e-7, -0.022185965, 0.004961083, 0.005169449, - -0.0098957075, 0.016179746, -0.01815095, 0.003922563, 0.02378674, - 0.009485591, -0.0025450357, -0.016153287, -0.006985205, -0.014711266, - 0.0020538885, -0.013811656, -0.014989086, -0.005811082, 0.003150288, - -0.003912641, 0.014235002, -0.012270413, 0.003285891, 0.012766521, - 0.026988294, 0.01903733, -0.015306596, -0.0069521316, 0.009459132, - 0.0045774262, -0.007302715, -0.015690252, -0.013732279, 0.03540229, - -0.015108152, -0.024236547, 0.003922563, 0.0028989264, 0.010583645, - 0.027861444, 0.028655218, 0.0074548544, -0.024858335, -0.0037869604, - 0.00087563123, -0.027596854, 0.009432673, -0.0011286464, -0.02799374, - -0.0025185766, -0.00043533507, -0.012852513, -0.011734616, 0.034370385, - 0.009928782, -0.0243953, 0.039212402, 0.026035765, -0.018944724, - -0.0039258706, 0.0064659454, -0.008724892, 0.012574693, 0.00908209, - -0.026750162, -0.004335987, 0.015650565, 0.022066899, -0.026776621, - -0.006429564, 0.0006627181, 0.019024102, -0.0038498007, -0.0015032083, - 0.025850551, 0.0010079268, -0.007481314, -0.018137721, 0.009644346, - 0.016642781, -0.0020224683, 0.007970807, -0.014327609, 0.015518269, - -0.024620203, -0.002879082, -0.022675458, -0.0022556393, -0.005228982, - 0.004693185, 0.0036712016, -0.007481314, -0.005467114, 0.004600578, - -0.011820608, -0.006148436, -0.006360109, -0.001418043, 0.0031750933, - 0.010550571, 0.003214782, -0.004054859, 0.017661456, 0.022384409, - -0.016722158, 0.007706216, -0.012812825, -0.023733823, -0.008797655, - -0.007924504, 0.014486363, -0.023350166, -0.002035698, -0.007944348, - -0.027252885, 0.0037241199, 0.010087537, 0.005834234, -0.045959476, - 0.025334598, -0.020227991, -0.021828767, 0.014155624, 0.018997641, - 0.004888321, -0.011602321, 0.0044947416, -0.003193284, -0.013156793, - 0.008103102, -0.004504664, -0.008526449, 0.006095518, 0.026750162, - -0.0010095804, 0.0059301485, 0.02262254, -0.021524487, 0.018706592, - 0.012052125, 0.014076247, -0.014724496, 0.000096741125, 0.013771968, - 0.002364783, 0.0007193571, 0.009551739, 0.0060822885, 0.017357178, - 0.036248982, -0.014155624, 0.018362623, -0.022278572, -0.016312042, - -0.026723703, -0.0036678943, -0.015677024, 0.020201532, 0.025744716, - -0.006231121, -0.014367297, 0.0030047628, 0.0031403657, 0.025175845, - 0.035957932, -0.010603489, 0.007831897, -0.014327609, -0.0072233374, - -0.00152636, -0.010358742, 0.008248628, -0.0038167269, 0.0076665278, - 0.022900362, 0.014817103, 0.03251825, 0.005407581, -0.0015528192, - -0.014142395, 0.011099597, 0.009809716, 0.010590259, -0.00021994136, - -0.011589091, 0.013103875, -0.02143188, 0.03161864, -0.019976629, - -0.0011468371, 0.032094903, 0.03426455, -0.034291007, 0.0010418275, - 0.01668247, 0.008096488, 0.0046237297, 0.02383966, 0.026287127, - 0.0010203295, 0.0038927968, 0.002159725, -0.008566137, 0.0019050561, - -0.020360285, -0.011959518, 0.010034618, 0.015928386, 0.025202304, - 0.0018273324, 0.010993761, 0.006323728, -0.0009062246, 0.00999493, - 0.007494543, -0.00803034, -0.007679757, -0.0019232467, 0.0066908477, - 0.008149406, -0.0028708137, 0.03220074, -0.031036537, 0.023641216, - 0.007626839, -0.0039324854, 0.005162834, -0.016285583, -0.018058343, - -0.023323707, -0.026935376, 0.0044352086, 0.0107291695, 0.010061077, - -0.008261858, -0.053711995, 0.0008247801, 0.010557186, 0.016827995, - 0.007229952, 0.013103875, 0.028443545, -0.021789078, -0.0046997997, - 0.006436179, 0.03487311, -0.001515611, 0.0033536924, 0.011218663, - -0.00447159, 0.0003958531, 0.015743172, -0.01907702, -0.004643574, - 0.0050636125, -0.011238508, -0.01147664, 0.003409918, 0.0030709107, - -0.005228982, 0.015081693, -0.011238508, -0.002176262, 0.0029038875, - 0.0022275264, -0.020743944, -0.008552908, 0.02053227, -0.023363395, - -0.018005425, -0.009353296, -0.001055884, 0.010610104, 0.055458296, - 0.024858335, 0.0021927988, -0.01370582, 0.0011096289, 0.018918265, - -0.020413205, -0.013031112, -0.015094923, -0.018574296, 0.002234141, - -0.0093731405, -0.020995306, 0.030904243, 0.017383637, 0.0024110866, - 0.011231893, -0.0029700352, -0.003193284, 0.003219743, -0.004216921, - -0.013011268, 0.0050239237, 0.017701145, 0.022146277, -0.0071042716, - 0.017410096, 0.02263577, -0.00035244363, -0.014870021, -0.0036381278, - -0.00014304457, 0.012111658, 0.00847353, 0.012508545, 0.024487907, - -0.013719049, 0.014327609, 0.008367694, -0.0027567088, 0.01219765, - 0.012356405, 0.00996847, -0.02144511, 0.0010112341, -0.010166913, - -0.013930722, 0.024355613, -0.0068264506, -0.015015545, 0.034608517, - 0.002678985, -0.017211651, -0.016841225, -0.0037274272, 0.00624435, - -0.014036559, -0.006912443, -0.0069785905, -0.0025251915, 0.0005651501, - -0.020042777, -0.00062964414, 0.00566225, -0.029078564, -0.03990034, - -0.02620775, 0.00020330107, -0.0124291675, 0.008923335, -0.013368466, - -0.0062377355, -0.00894318, -0.011556017, 0.00094095216, 0.013547065, - 0.0006135206, -0.011536173, 0.02026768, 0.0059169186, -0.0014899787, - -0.032333035, -0.0017777216, -0.023654446, -0.0050801495, -0.0032131283, - -0.006780147, -0.004455053, -0.0108548505, 0.016735388, 0.025824092, - 0.016616322, -0.002798051, -0.0013725664, 0.009882478, -0.0025185766, - 0.013474302, 0.006045907, -0.012105043, -0.011562631, 0.011913215, - -0.005093379, -0.0066015483, -0.009042402, 0.017939277, 0.0020307368, - 0.012647456, 0.0259167, -0.0038994115, -0.01041166, 0.035058323, - -0.012733447, 0.017026437, -0.0019563206, -0.0045178933, 0.0067106923, - 0.0064064125, 0.029422533, -0.026392963, -0.014658348, 0.003214782, - -0.058262963, 0.017211651, 0.0072961, 0.006231121, 0.0011592398, - 0.019434217, -0.013011268, 0.0024805416, 0.0016983442, -0.0072167227, - 0.015571187, -0.008109718, -0.017463014, -0.031777393, -0.0058640004, - -0.012277028, 0.0027748994, -0.009267304, -0.036592953, -0.030136928, - -0.015108152, 0.0132494, -0.027543936, -0.018389082, -0.047150135, - -0.0050404607, 0.005807775, -0.00034210805, 0.013679361, -0.006608163, - 0.010074306, -0.027305802, -0.028231872, -0.00862567, -0.024302693, - -0.0020952309, -0.0045939633, 0.038577385, 0.028787514, 0.015703483, - 0.012164577, 0.008903491, -0.005867308, 0.0036447425, 0.018256787, - -0.00075573835, 0.0041110846, -0.010233061, 0.01457897, 0.025757944, - 0.031962607, 0.004772562, -0.012164577, 0.008308161, 0.013758738, - -0.006938902, -0.0000560189, -0.0056357905, -0.019526824, -0.01311049, - 0.0017992196, -0.01189337, 0.0046832627, 0.012964965, -0.009168082, - 0.026154831, 0.027729148, 0.031115916, 0.0013717395, 0.030004632, - -0.01117236, 0.030719029, 0.010305824, 0.017926048, 0.019473907, - -0.014380527, -0.016814765, -0.018719822, 0.009796486, -0.001347761, - 0.020492582, -0.01518753, -0.007679757, -0.017343948, 0.029660664, - -0.012601152, -0.008519834, -0.006661081, -0.010266135, -0.012878972, - -0.03908011, -0.014671577, -0.008447072, 0.004620422, 0.0002681052, - -0.01670893, 0.03336494, -0.02200075, -0.018349394, 0.0025533042, - -0.006439486, 0.021048224, -0.0012278681, 0.014856791, 0.0111326715, - -0.022992969, -0.028787514, -0.0001331224, -0.011642009, -0.014671577, - 0.02084978, 0.0009856019, 0.0011104558, -0.018018655, 0.00028753612, - -0.0103918165, -0.017410096, -0.009333451, 0.012574693, 0.017608538, - -0.00894318, -0.019844333, -0.004296298, -0.02139219, 0.026578177, - 0.010352127, -0.0107622435, -0.008797655, 0.004488127, -0.014168854, - 0.019487135, -0.012382864, 0.00984279, 0.023403084, -0.017317489, - -0.017171964, 0.0059896815, -0.01875951, 0.0145922, -0.0074680843, - 0.014962628, -0.012105043, 0.0019249003, 0.014645118, -0.0076069944, - -0.03130113, -0.012157962, -0.0020671182, 0.02645911, -0.025096467, - 0.015690252, -0.0038134195, 0.000048060494, 0.014354068, 0.0009302031, - -0.012627611, -0.028655218, -0.020161843, -0.0011608935, 0.026035765, - 0.010696095, -0.0025103083, -0.0035190617, -0.0029485372, -0.026247438, - -0.034132253, 0.008757966, 0.002468966, -0.00090209034, -0.01222411, - -0.013877804, -0.0032329727, 0.008996098, 0.014340838, -0.026432652, - 0.025149386, 0.015346285, -0.032385953, -0.0048949355, -0.004785792, - -0.009221001, -0.029872337, 0.013090645, -0.005288515, -0.019526824, - 0.010080921, -0.017515931, -0.020056006, 0.015015545, 0.012660685, - 0.011575861, 0.013891034, 0.007818667, 0.0172778, 0.018098032, - 0.0060095256, -0.0080435695, -0.01963266, 0.01237625, -0.018746281, - 0.012449012, -0.007329174, -0.011833837, 0.021220207, -0.016007762, - 0.019222545, 0.006965361, -0.023125263, -0.0020059315, -0.0003061402, - -0.0007234913, -0.017926048, -0.006429564, -0.002435892, -0.011589091, - -0.023456002, 0.00758715, 0.011516328, -0.012151347, 0.01578286, - -0.004580734, -0.0023366702, 0.0028840431, -0.0035322914, - -0.00060318504, -0.008122947, -0.011992592, -0.0058375415, -0.009492206, - 0.0004758506, 0.032094903, 0.010841621, -0.024302693, -0.01877274, - 0.009029171, -0.019182855, -0.008519834, -0.005906997, 0.0011716426, - 0.01934161, 0.01788636, 0.005758164, 0.017079357, -0.008843958, - 0.020505812, -0.02029414, -0.0068595246, 0.014645118, 0.009121778, - 0.013679361, -0.007302715, -0.018534608, -0.03304743, 0.008070029, - 0.0013874497, -0.010874695, 0.019513594, -0.011926444, -0.018534608, - -0.013904263, 0.008215554, -0.028443545, -0.007838512, 0.031221751, - -0.024620203, 0.00028608914, 0.0103918165, -0.020889468, -0.0017231497, - -0.017198423, 0.0015238795, -0.0016966906, 0.016576633, -0.005526647, - -0.004736181, 0.02233149, -0.031698015, 0.020770403, 0.008857188, - -0.017463014, 0.031142375, -0.0033057353, 0.0068992134, -0.016788306, - 0.0048783985, -0.014023329, 0.000500656, 0.014221773, -0.01759531, - -0.025202304, -0.030877784, -0.02173616, -0.021233438, 0.0120587405, - -0.030480897, -0.0017926048, -0.001986087, 0.018005425, 0.0009748529, - -0.008903491, -0.013229555, -0.010451349, -0.017767293, 0.010292594, - -0.009498821, 0.014856791, -0.0010575376, 0.00027699381, 0.011384033, - -0.018243557, -0.01819064, 0.007573921, -0.0010542303, 0.01578286, - 0.026340045, 0.2099795, -0.013454458, -0.0063138055, 0.047785155, - 0.017132275, 0.012912046, 0.013785197, 0.013408155, -0.0047394885, - 0.03519062, -0.016020993, 0.011899985, -0.016325273, 0.0057879305, - 0.014870021, 0.0041739247, -0.025030319, -0.01819064, -0.023363395, - -0.001959628, -0.0072762556, -0.010537341, -0.021577405, -0.015266907, - 0.036275443, 0.00047130292, -0.009822945, -0.00003178194, 0.008896876, - 0.0030891013, -0.020161843, -0.037889447, 0.007911274, 0.010239677, - -0.0056258687, -0.002614491, 0.0077855936, 0.0027864752, 0.03095716, - 0.0051959082, 0.0020290832, -0.0063501867, 0.0034132253, -0.0052819, - -0.014830332, -0.0034727585, -0.0054042735, -0.01693383, -0.0013518953, - 0.021286355, -0.033285562, 0.006780147, 0.024606973, 0.034767274, - 0.005136375, 0.000035657788, 0.0055332617, 0.0058375415, -0.010451349, - 0.007573921, -0.018031884, 0.03368245, -0.0053480477, 0.014526052, - -0.029105023, 0.007957578, -0.004051551, 0.00009979012, 0.008843958, - -0.008996098, -0.018547837, -0.014949398, 0.006469253, -0.0037439642, - -0.015438892, -0.034132253, 0.015968073, 0.01637819, 0.023680905, - 0.015875466, 0.004600578, 0.0006271636, -0.0070711975, -0.022543162, - -0.011192204, -0.021101141, 0.0027302497, 0.019553283, 0.0017297644, - -0.0047394885, -0.0018653674, -0.015677024, -0.0065023266, 0.011509714, - 0.02266223, 0.013183252, 0.0036447425, 0.018613985, -0.019262234, - 0.024990631, -0.02561242, -0.007481314, -0.006846295, 0.01370582, - -0.0085396785, 0.019712038, 0.0034562214, 0.00031564894, 0.001320475, - -0.017224882, -0.019844333, -0.01636496, -0.0021299585, -0.006360109, - 0.019420987, 0.008744736, 0.012025666, -0.009141623, 0.0012278681, - 0.009902323, 0.013050957, -0.005546491, 0.002462351, -0.001126166, - -0.008447072, -0.015849007, -0.01881243, -0.0042896834, 0.0076599126, - -0.030454438, -0.0055233394, -0.011205434, 0.026128372, -0.005622561, - -0.013189867, -0.005245519, 0.0009293763, 0.00040866924, -0.005467114, - 0.016894143, 0.00039109873, -0.020929158, 0.0027153664, 0.017727604, - -0.007805438, -0.025638878, 0.025149386, -0.020757172, -0.011569247, - 0.0016231011, -0.020386746, 0.0029898796, -0.0076731425, 0.0010980532, - 0.030666111, -0.003912641, -0.031459883, -0.033285562, -0.0010633256, - -0.0072828704, -0.005397659, -0.001976165, 0.018785968, 0.003181708, - -0.021670012, -0.025241992, -0.17261924, 0.049028732, 0.005830927, - -0.02676339, 0.020413205, 0.01789959, 0.023389855, -0.0012485393, - 0.00037538866, 0.013335392, 0.015901927, 0.00039667997, -0.03482019, - -0.0038564154, -0.01264084, -0.007653298, 0.017317489, 0.006733844, - 0.0044186716, 0.034396846, 0.03781007, -0.024845107, 0.0030411442, - -0.0021299585, 0.008380923, -0.0047560255, 0.007421781, 0.018785968, - 0.012025666, 0.0021448417, -0.021273125, -0.0144995935, 0.018865347, - 0.011423721, 0.011714771, 0.0035587505, 0.0031866692, -0.024501137, - -0.012951735, 0.022887131, 0.02619452, 0.030533815, 0.007884815, - -0.017502703, -0.014248231, 0.014565741, 0.016801536, 0.010385201, - 0.015359514, -0.017701145, 0.0099817, -0.009227615, 0.005073535, - 0.0004828788, 0.021961063, 0.003605054, 0.0031486342, 0.016034221, - 0.01693383, 0.0002031977, -0.012019051, -0.0049313167, 0.019103479, - -0.005996296, 0.0107291695, -0.015200759, -0.011602321, 0.018627215, - -0.014115936, 0.028496463, 0.007957578, -0.03844509, 0.0036116687, - -0.04053536, 0.021034993, 0.01881243, -0.023310477, 0.007236567, - -0.016563404, -0.006505634, -0.021339273, 0.011284811, -0.00966419, - 0.006932287, 0.006532093, 0.0017711067, 0.010901154, -0.0027285959, - -0.020307368, -0.03714859, 0.021894915, -0.013189867, -0.004448438, - -0.020730713, 0.017529162, 0.006227813, 0.010087537, 0.01430115, - -0.01580932, -0.0041110846, 0.008420613, -0.0027203273, -0.018415542, - 0.016576633, 0.024884794, -0.019579742, 0.01903733, 0.022291802, - 0.008989483, -0.020360285, -0.0052819, 0.007653298, 0.012462242, - 0.033312023, 0.0018918265, 0.012587923, -0.0011253391, -0.0075606913, - 0.0037108904, -0.016867684, 0.041858315, -0.013295704, -0.0072762556, - -0.010702711, -0.0046303445, 0.005986374, -0.12192359, -0.03654003, - 0.0015056888, 0.015015545, -0.022159506, 0.033470776, 0.010815162, - 0.007362248, -0.0136661315, 0.040350147, -0.011959518, -0.025599191, - -0.029740041, 0.0028344323, 0.020399975, -0.01370582, -0.015253678, - -0.008195709, -0.005093379, 0.004752718, 0.0014602122, -0.002348246, - 0.0075805355, -0.007362248, -0.004574119, -0.0013560294, 0.002262254, - 0.022529934, 0.017026437, -0.013586754, 0.009359911, -0.033100348, - 0.013229555, -0.01431438, -0.0052488265, 0.0025963003, -0.04947854, - 0.022093358, 0.018071573, -0.026392963, 0.019897252, 0.012660685, - 0.0036976608, -0.042599168, 0.011218663, -0.021405421, -0.010649792, - 0.03508478, 0.009135008, -0.0014676538, -0.030507356, -0.015888697, - -0.034449764, -0.008400768, 0.027623313, -0.0019000949, 0.014235002, - 0.019500365, -0.012819439, 0.021841997, 0.010861466, 0.0055200323, - -0.0049346243, 0.028655218, -0.0071968785, -0.021789078, -0.012859128, - 0.005109916, 0.00050809764, -0.010074306, -0.00862567, -0.00002751851, - -0.014790643, 0.012594537, -0.02620775, 0.013090645, -0.025136156, - -0.019249003, 0.004071396, -0.025956389, -0.028417086, -0.015650565, - 0.016841225, -0.0025417283, 0.0135404505, -0.0007561518, -0.0028294711, - -0.0120587405, -0.0034396844, -0.032941595, -0.0032428948, - -0.0039655594, 0.009366525, -0.004445131, 0.012310102, 0.02029414, - -0.005979759, -0.008843958, 0.016192976, 0.009730338, -0.01850815, - -0.008665359, -0.062337667, 0.03786299, -0.004081318, 0.005639098, - 0.010199987, 0.000003908145, 0.020876238, -0.010471193, -0.009531895, - -0.01610037, -0.021246666, -0.0008355291, -0.0068992134, 0.0056754793, - -0.03312681, -0.0066743107, 0.016259125, 0.002252332, 0.020902699, - 0.01131127, 0.007415166, -0.020426434, 0.013745508, -0.007765749, - -0.0032131283, 0.016470797, -0.017529162, 0.014750955, 0.01670893, - -0.011436951, 0.004005248, -0.02947545, 0.017793752, 0.015663793, - 0.0049676984, -0.0022672152, 0.00714396, 0.015359514, -0.004848632, - 0.01670893, -0.027438099, -0.02590347, 0.008817499, -0.0025136156, - 0.008400768, 0.010312439, -0.00026149044, -0.005179371, 0.012415938, - 0.006872754, 0.0047262586, 0.008996098, -0.023191411, -0.008830728, - -0.017912818, 0.00012826467, -0.0029154634, 0.009512051, -0.0016966906, - -0.011073139, 0.017952507, 0.0075805355, 0.013176638, -0.00041507732, - 0.0057813157, 0.004378983, -0.01934161, -0.010524112, 0.009174697, - -0.03011047, -0.022887131, -0.0077260607, -0.010940842, -0.00086157484, - 0.024580514, 0.009631117, -0.0028129343, 0.023125263, -0.017965736, - 0.028390627, 0.013877804, 0.0077591343, -0.039741587, -0.0020638106, - 0.021220207, 0.028681677, -0.0107291695, 0.0015511654, -0.006756996, - 0.01881243, -0.022847442, -0.016285583, 0.007679757, 0.011436951, - -0.010874695, -0.009723724, -0.0022176043, -0.0020902697, 0.02645911, - 0.022873903, 0.014777414, 0.004974313, -0.008162636, -0.01850815, - 0.0030031092, -0.0026442574, -0.021921374, -0.04463652, -0.010252906, - 0.013480918, 0.01935484, 0.0072564115, 0.01265407, 0.018905034, - -0.01427469, 0.005314974, -0.011575861, -0.009108549, -0.03296805, - 0.032624085, 0.004964391, -0.0030179925, 0.021670012, -0.015981304, - 0.026340045, -0.006760303, -0.006327035, -0.0056126392, 0.010894539, - -0.0024772342, 0.009611272, -0.010676252, -0.010682866, -0.019738497, - -0.021299584, 0.00984279, -0.00035492418, 0.02738518, -0.020743944, - 0.06694155, -0.011278196, -0.0065354006, 0.010907768, 0.011542788, - 0.020466123, 0.007593765, 0.005076842, -0.014671577, -0.0068396805, - -0.004848632, -0.014340838, -0.013474302, 0.00032267714, -0.018878575, - 0.0076136095, -0.011198819, 0.01579609, -0.021286355, 0.0043227575, - 0.01252839, -0.012872358, 0.013216326, -0.00715719, -0.0073424033, - -0.010596874, 0.00035451076, 0.0017479551, -0.03153926, -0.015094923, - 0.0042499946, 0.00015865131, -0.01789959, -0.011291426, 0.020571958, - -0.019500365, -0.004491434, -0.023072345, -0.0076996014, 0.0055200323, - 0.011926444, 0.0051231454, -0.020810092, -0.023548609, 0.029052105, - 0.002386281, -0.016444338, -0.00505369, -0.006002911, - ], - }, - ], - model: "text-embedding-ada-002", - usage: { - prompt_tokens: 1, - total_tokens: 1, - }, -}; - export const CHAT_SAY_HELLO = { id: "chatcmpl-AbFX2khtngBETl7qtntuXawF6RFPt", object: "chat.completion", diff --git a/integrations/langchain-js/src/BraintrustCallbackHandler.ts b/integrations/langchain-js/src/BraintrustCallbackHandler.ts index 2ad59cb03..d53b5ef69 100644 --- a/integrations/langchain-js/src/BraintrustCallbackHandler.ts +++ b/integrations/langchain-js/src/BraintrustCallbackHandler.ts @@ -11,7 +11,7 @@ import { type LangChainCallbackHandlerOptions, } from "braintrust"; -export type BraintrustCallbackHandlerOptions = +type BraintrustCallbackHandlerOptions = LangChainCallbackHandlerOptions; /** diff --git a/integrations/langchain-js/src/test/setup.ts b/integrations/langchain-js/src/test/setup.ts index 0bf80d2a4..440a1435b 100644 --- a/integrations/langchain-js/src/test/setup.ts +++ b/integrations/langchain-js/src/test/setup.ts @@ -35,7 +35,6 @@ export const server = setupServer( ); beforeAll(() => { - // comment out specific to use bypassAndLog process.env.BRAINTRUST_API_KEY = "braintrust-api-key"; process.env.BRAINTRUST_APP_URL = "http://braintrust.local"; process.env.BRAINTRUST_ORG_NAME = "braintrustdata.com"; diff --git a/integrations/langchain-js/src/test/utils.ts b/integrations/langchain-js/src/test/utils.ts index f49a0b14e..e27f8e4b0 100644 --- a/integrations/langchain-js/src/test/utils.ts +++ b/integrations/langchain-js/src/test/utils.ts @@ -1,37 +1,7 @@ import { mergeDicts } from "braintrust/util"; import { BaseCallbackHandler } from "@langchain/core/callbacks/base"; -import { bypass, HttpResponse, JsonBodyType } from "msw"; -import { TransformStream } from "stream/web"; import { LogsRequest } from "./types"; -const decoder = new TextDecoder(); -// comment out process.env overriding in setup.ts for this to be helpful -const bypassAndLog = async (request: Request): Promise => { - console.log(request.method, request.url); - const res = await fetch(bypass(request)); - - // If it's not a stream, handle as before - if (!res.body || !res.headers.get("content-type")?.includes("stream")) { - // eslint-disable-next-line @typescript-eslint/consistent-type-assertions - const json = (await res.json()) as JsonBodyType; - console.log(JSON.stringify(json, null, 2)); - return HttpResponse.json(json); - } - - const spy = new TransformStream({ - transform(chunk, controller) { - console.log(decoder.decode(chunk)); - controller.enqueue(chunk); - }, - }); - - return new Response(res.body.pipeThrough(spy), { - headers: res.headers, - status: res.status, - statusText: res.statusText, - }); -}; - export const logsToSpans = (logs: LogsRequest[]) => { if (logs.length === 0) { throw new Error("No logs to convert to spans"); diff --git a/integrations/langchain-js/tsconfig.json b/integrations/langchain-js/tsconfig.json index 357391770..ea6ad1861 100644 --- a/integrations/langchain-js/tsconfig.json +++ b/integrations/langchain-js/tsconfig.json @@ -6,6 +6,7 @@ "target": "es2022", "moduleResolution": "node", "strict": true, + "noUnusedLocals": true, "esModuleInterop": true, "skipLibCheck": true }, diff --git a/integrations/openai-agents-js/tsconfig.json b/integrations/openai-agents-js/tsconfig.json index 357391770..ea6ad1861 100644 --- a/integrations/openai-agents-js/tsconfig.json +++ b/integrations/openai-agents-js/tsconfig.json @@ -6,6 +6,7 @@ "target": "es2022", "moduleResolution": "node", "strict": true, + "noUnusedLocals": true, "esModuleInterop": true, "skipLibCheck": true }, diff --git a/integrations/otel-js/package.json b/integrations/otel-js/package.json index f345797f7..82fd3333a 100644 --- a/integrations/otel-js/package.json +++ b/integrations/otel-js/package.json @@ -16,7 +16,7 @@ }, "scripts": { "build": "tsup", - "check:typings": "tsc --noEmit", + "check:typings": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json", "watch": "tsup --watch", "clean": "rm -r dist/*", "test": "pnpm test:v1 && pnpm test:v2", @@ -32,7 +32,8 @@ "braintrust": "workspace:*", "tsup": "^8.5.0", "typedoc": "^0.28.15", - "typescript": "5.5.4" + "typescript": "5.5.4", + "vitest": "4.1.5" }, "peerDependencies": { "@opentelemetry/api": ">=1.9.0", diff --git a/integrations/otel-js/src/otel-compat.test.ts b/integrations/otel-js/src/otel-compat.test.ts index 932ac406a..6564da531 100644 --- a/integrations/otel-js/src/otel-compat.test.ts +++ b/integrations/otel-js/src/otel-compat.test.ts @@ -104,7 +104,7 @@ describe("OTEL compatibility mode", () => { async (span1) => { expect(currentSpan()).toBe(span1); - await tracer.startActiveSpan("otel-span-2", async (otelSpan2) => { + await tracer.startActiveSpan("otel-span-2", async (otelSpan2: any) => { await logger.traced( async (span3) => { expect(currentSpan()).toBe(span3); @@ -143,7 +143,7 @@ describe("OTEL compatibility mode", () => { ); const logger = initLogger({ projectName: "mixed-tracing-otel-first" }); - await tracer.startActiveSpan("otel-span-1", async (otelSpan1) => { + await tracer.startActiveSpan("otel-span-1", async (otelSpan1: any) => { await logger.traced( async (span2) => { expect(currentSpan()).toBe(span2); @@ -154,9 +154,12 @@ describe("OTEL compatibility mode", () => { expect(span2.rootSpanId).toBe(otelTraceId); - await tracer.startActiveSpan("otel-span-3", async (otelSpan3) => { - otelSpan3.end(); - }); + await tracer.startActiveSpan( + "otel-span-3", + async (otelSpan3: any) => { + otelSpan3.end(); + }, + ); }, { name: "bt-span-2" }, ); @@ -176,7 +179,7 @@ describe("OTEL compatibility mode", () => { setupOtelFixture("bt-inherits-otel"); const logger = initLogger({ projectName: "bt-inherits-otel" }); - await tracer.startActiveSpan("otel-parent", async (otelParent) => { + await tracer.startActiveSpan("otel-parent", async (otelParent: any) => { const btSpan = logger.startSpan({ name: "bt-child" }); const otelContext = otelParent.spanContext(); @@ -212,7 +215,7 @@ describe("OTEL compatibility mode", () => { await cm.runInContext(span1, async () => { expect(currentSpan()).toBe(span1); - await tracer.startActiveSpan("otel-span-2", async (otelSpan2) => { + await tracer.startActiveSpan("otel-span-2", async (otelSpan2: any) => { const span3 = logger.startSpan({ name: "bt-span-3" }); await cm.runInContext(span3, async () => { @@ -295,7 +298,7 @@ describe("OTEL compatibility mode", () => { await logger.traced( async () => { - await tracer.startActiveSpan("otel-child", async (otelChild) => { + await tracer.startActiveSpan("otel-child", async (otelChild: any) => { // Verify the span context is created expect(otelChild.spanContext().traceId).toBeDefined(); otelChild.end(); @@ -332,7 +335,7 @@ describe("OTEL compatibility mode", () => { ); let trace2Id: string | undefined; - await tracer.startActiveSpan("otel-trace-2", async (otelSpan2) => { + await tracer.startActiveSpan("otel-trace-2", async (otelSpan2: any) => { const otelContext = otelSpan2.spanContext(); trace2Id = otelContext.traceId.toString().padStart(32, "0"); otelSpan2.setAttribute("test", "second_trace"); @@ -340,21 +343,24 @@ describe("OTEL compatibility mode", () => { }); let trace3Id: string | undefined; - await tracer.startActiveSpan("otel-trace-3-root", async (otelSpan3) => { - const otelContext = otelSpan3.spanContext(); - trace3Id = otelContext.traceId.toString().padStart(32, "0"); - - await logger.traced( - async (btSpan3) => { - // BT span inside OTEL should inherit OTEL trace ID - expect(btSpan3.rootSpanId).toBe(trace3Id); - expect(btSpan3.rootSpanId).not.toBe(trace1Id); - }, - { name: "bt-inside-otel-3" }, - ); - - otelSpan3.end(); - }); + await tracer.startActiveSpan( + "otel-trace-3-root", + async (otelSpan3: any) => { + const otelContext = otelSpan3.spanContext(); + trace3Id = otelContext.traceId.toString().padStart(32, "0"); + + await logger.traced( + async (btSpan3) => { + // BT span inside OTEL should inherit OTEL trace ID + expect(btSpan3.rootSpanId).toBe(trace3Id); + expect(btSpan3.rootSpanId).not.toBe(trace1Id); + }, + { name: "bt-inside-otel-3" }, + ); + + otelSpan3.end(); + }, + ); // Verify we have 3 separate traces expect(trace1Id).toBeDefined(); @@ -391,10 +397,13 @@ describe("OTEL compatibility mode", () => { } // Create an OTEL span inside the eval task - await tracer.startActiveSpan("otel-compute", async (otelSpan) => { - otelSpan.setAttribute("computation", input * 2); - otelSpan.end(); - }); + await tracer.startActiveSpan( + "otel-compute", + async (otelSpan: any) => { + otelSpan.setAttribute("computation", input * 2); + otelSpan.end(); + }, + ); return input * 2; }, scores: [], @@ -453,7 +462,7 @@ describe("OTEL compatibility mode", () => { await logger.traced( async () => { - await tracer.startActiveSpan("otel-child", async (otelSpan) => { + await tracer.startActiveSpan("otel-child", async (otelSpan: any) => { const ctx = otelSpan.spanContext(); otelSpanCreated = true; otelSpanHasValidContext = @@ -489,7 +498,7 @@ describe("OTEL compatibility mode", () => { btTraceId = btSpan.rootSpanId; btSpanId = btSpan.spanId; - await tracer.startActiveSpan("otel-child", async (otelSpan) => { + await tracer.startActiveSpan("otel-child", async (otelSpan: any) => { const ctx = otelSpan.spanContext(); otelTraceId = ctx.traceId.toString().padStart(32, "0"); otelSpan.end(); @@ -534,7 +543,7 @@ describe("OTEL compatibility mode", () => { async (btSpan1) => { spanIds.push(btSpan1.spanId); - await tracer.startActiveSpan("otel-span-1", async (otelSpan1) => { + await tracer.startActiveSpan("otel-span-1", async (otelSpan1: any) => { spanIds.push( otelSpan1.spanContext().spanId.toString().padStart(16, "0"), ); @@ -543,12 +552,15 @@ describe("OTEL compatibility mode", () => { async (btSpan2) => { spanIds.push(btSpan2.spanId); - await tracer.startActiveSpan("otel-span-2", async (otelSpan2) => { - spanIds.push( - otelSpan2.spanContext().spanId.toString().padStart(16, "0"), - ); - otelSpan2.end(); - }); + await tracer.startActiveSpan( + "otel-span-2", + async (otelSpan2: any) => { + spanIds.push( + otelSpan2.spanContext().spanId.toString().padStart(16, "0"), + ); + otelSpan2.end(); + }, + ); }, { name: "bt-span-2" }, ); @@ -596,10 +608,13 @@ describe("OTEL compatibility mode", () => { await logger.traced( async () => { - await tracer.startActiveSpan("otel-with-attrs", async (otelSpan) => { - otelSpan.setAttribute("custom.attribute", "test-value"); - otelSpan.end(); - }); + await tracer.startActiveSpan( + "otel-with-attrs", + async (otelSpan: any) => { + otelSpan.setAttribute("custom.attribute", "test-value"); + otelSpan.end(); + }, + ); }, { name: "bt-parent" }, ); @@ -1001,10 +1016,13 @@ describe("Distributed Tracing (BT → OTEL)", () => { // Use context.with() to run code in the imported context await context.with(ctx, async () => { - await tracer.startActiveSpan("service_b_span", async (serviceBSpan) => { - serviceBSpan.setAttribute("service", "service_b"); - serviceBSpan.end(); - }); + await tracer.startActiveSpan( + "service_b_span", + async (serviceBSpan: any) => { + serviceBSpan.setAttribute("service", "service_b"); + serviceBSpan.end(); + }, + ); }); await processor.forceFlush(); @@ -1024,8 +1042,8 @@ describe("Distributed Tracing (BT → OTEL)", () => { expect(serviceBTraceId).toBe(serviceATraceId); // Service B span should have Service A span as parent - if (serviceBSpan.parentSpanId) { - expect(serviceBSpan.parentSpanId).toBe(serviceASpanId); + if ((serviceBSpan as any).parentSpanId) { + expect((serviceBSpan as any).parentSpanId).toBe(serviceASpanId); } // Note: In distributed tracing, the braintrust.parent attribute is NOT diff --git a/integrations/otel-js/src/otel.ts b/integrations/otel-js/src/otel.ts index e588248d5..3a9d0f874 100644 --- a/integrations/otel-js/src/otel.ts +++ b/integrations/otel-js/src/otel.ts @@ -768,8 +768,6 @@ export function getOtelParentFromSpan( */ export class BraintrustExporter { private readonly processor: BraintrustSpanProcessor; - private readonly spans: ReadableSpan[] = []; - private readonly callbacks: Array<(result: unknown) => void> = []; constructor(options: BraintrustSpanProcessorOptions = {}) { // Use BraintrustSpanProcessor under the hood diff --git a/integrations/otel-js/tsconfig.json b/integrations/otel-js/tsconfig.json index fbe98f0ae..8cfc6d9ae 100644 --- a/integrations/otel-js/tsconfig.json +++ b/integrations/otel-js/tsconfig.json @@ -6,6 +6,7 @@ "target": "es2022", "moduleResolution": "node", "strict": true, + "noUnusedLocals": true, "esModuleInterop": true, "skipLibCheck": true }, diff --git a/integrations/otel-js/tsconfig.test.json b/integrations/otel-js/tsconfig.test.json new file mode 100644 index 000000000..eff2845e0 --- /dev/null +++ b/integrations/otel-js/tsconfig.test.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "declaration": false, + "noEmit": true, + "types": ["node"], + "baseUrl": ".", + "paths": { + "@braintrust/otel": ["src/index.ts"] + } + }, + "include": ["src/**/*.test.ts", "tests/**/*.ts"], + "exclude": ["node_modules/**", "**/dist/**", "otel-v1/**", "otel-v2/**"] +} diff --git a/integrations/templates-nunjucks/package.json b/integrations/templates-nunjucks/package.json index 94e2cd530..2ca0c8a91 100644 --- a/integrations/templates-nunjucks/package.json +++ b/integrations/templates-nunjucks/package.json @@ -19,7 +19,7 @@ ], "scripts": { "build": "tsup", - "check:typings": "tsc --noEmit", + "check:typings": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json", "watch": "tsup --watch", "clean": "rm -r dist/*", "test": "vitest run --exclude 'smoke/scenarios/**'", diff --git a/integrations/templates-nunjucks/src/index.test.ts b/integrations/templates-nunjucks/src/index.test.ts index 60bee39c1..7323d1224 100644 --- a/integrations/templates-nunjucks/src/index.test.ts +++ b/integrations/templates-nunjucks/src/index.test.ts @@ -2,6 +2,8 @@ import { describe, test, expect, beforeAll } from "vitest"; import { registerTemplatePlugin, Prompt } from "braintrust"; import { nunjucksPlugin } from "./index"; +const promptRow = (row: unknown) => row as any; + // Register and activate the plugin for all tests beforeAll(() => { // registerTemplatePlugin will auto-activate using the plugin's @@ -12,7 +14,7 @@ beforeAll(() => { describe("nunjucks rendering via Prompt", () => { test("renders variable and control structures", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -28,7 +30,7 @@ describe("nunjucks rendering via Prompt", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -42,7 +44,7 @@ describe("nunjucks rendering via Prompt", () => { test("loops render", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -57,7 +59,7 @@ describe("nunjucks rendering via Prompt", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -71,7 +73,7 @@ describe("nunjucks rendering via Prompt", () => { test("strict mode throws for missing top-level variable", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -86,7 +88,7 @@ describe("nunjucks rendering via Prompt", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -98,7 +100,7 @@ describe("nunjucks rendering via Prompt", () => { test("strict mode passes for defined variable and filters", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -113,7 +115,7 @@ describe("nunjucks rendering via Prompt", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -128,7 +130,7 @@ describe("nunjucks rendering via Prompt", () => { test("strict mode: for over undefined is empty (does not throw)", () => { const prompt1 = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -143,7 +145,7 @@ describe("nunjucks rendering via Prompt", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -162,7 +164,7 @@ describe("nunjucks rendering via Prompt", () => { test("strict mode: nested path with numeric index using brackets", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -177,7 +179,7 @@ describe("nunjucks rendering via Prompt", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -195,7 +197,7 @@ describe("nunjucks rendering via Prompt", () => { test("renders nested object properties", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -210,7 +212,7 @@ describe("nunjucks rendering via Prompt", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -224,7 +226,7 @@ describe("nunjucks rendering via Prompt", () => { test("renders multiple variables with context", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -240,7 +242,7 @@ describe("nunjucks rendering via Prompt", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -254,7 +256,7 @@ describe("nunjucks rendering via Prompt", () => { test("renders with string concatenation", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -269,7 +271,7 @@ describe("nunjucks rendering via Prompt", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -283,7 +285,7 @@ describe("nunjucks rendering via Prompt", () => { test("renders numeric operations", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -298,7 +300,7 @@ describe("nunjucks rendering via Prompt", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -312,7 +314,7 @@ describe("nunjucks rendering via Prompt", () => { test("renders with filters and context", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -327,7 +329,7 @@ describe("nunjucks rendering via Prompt", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -341,7 +343,7 @@ describe("nunjucks rendering via Prompt", () => { test("renders array elements with index", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -356,7 +358,7 @@ describe("nunjucks rendering via Prompt", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -370,7 +372,7 @@ describe("nunjucks rendering via Prompt", () => { test("renders nested arrays and objects", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -385,7 +387,7 @@ describe("nunjucks rendering via Prompt", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -404,7 +406,7 @@ describe("nunjucks rendering via Prompt", () => { test("renders with default filter", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -419,7 +421,7 @@ describe("nunjucks rendering via Prompt", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -436,7 +438,7 @@ describe("nunjucks rendering via Prompt", () => { test("renders ternary expressions", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -451,7 +453,7 @@ describe("nunjucks rendering via Prompt", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -468,7 +470,7 @@ describe("nunjucks rendering via Prompt", () => { test("renders with multiple filters chained", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -483,7 +485,7 @@ describe("nunjucks rendering via Prompt", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -497,7 +499,7 @@ describe("nunjucks rendering via Prompt", () => { test("renders complex nested context", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -513,7 +515,7 @@ describe("nunjucks rendering via Prompt", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -533,7 +535,7 @@ describe("nunjucks rendering via Prompt", () => { test("renders with length filter on arrays", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -548,7 +550,7 @@ describe("nunjucks rendering via Prompt", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -562,7 +564,7 @@ describe("nunjucks rendering via Prompt", () => { test("renders with join filter", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -577,7 +579,7 @@ describe("nunjucks rendering via Prompt", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -593,7 +595,7 @@ describe("nunjucks rendering via Prompt", () => { describe("nunjucks linting", () => { test("lint throws for missing variable", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -608,7 +610,7 @@ describe("nunjucks linting", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -620,7 +622,7 @@ describe("nunjucks linting", () => { test("lint passes for valid template with loops", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -635,7 +637,7 @@ describe("nunjucks linting", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -647,7 +649,7 @@ describe("nunjucks linting", () => { test("lint passes for valid template with conditionals", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -662,7 +664,7 @@ describe("nunjucks linting", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -674,7 +676,7 @@ describe("nunjucks linting", () => { test("lint throws for invalid template syntax", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -689,7 +691,7 @@ describe("nunjucks linting", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); @@ -701,7 +703,7 @@ describe("nunjucks linting", () => { test("lint throws for mismatched tags", () => { const prompt = new Prompt( - { + promptRow({ name: "test-prompt", slug: "test-prompt", prompt_data: { @@ -716,7 +718,7 @@ describe("nunjucks linting", () => { }, options: { model: "gpt-4" }, }, - }, + }), {}, false, ); diff --git a/integrations/templates-nunjucks/tsconfig.json b/integrations/templates-nunjucks/tsconfig.json index 3de755f6d..e0b228935 100644 --- a/integrations/templates-nunjucks/tsconfig.json +++ b/integrations/templates-nunjucks/tsconfig.json @@ -6,6 +6,7 @@ "target": "es2022", "moduleResolution": "node", "strict": true, + "noUnusedLocals": true, "esModuleInterop": true, "skipLibCheck": true }, diff --git a/integrations/templates-nunjucks/tsconfig.test.json b/integrations/templates-nunjucks/tsconfig.test.json new file mode 100644 index 000000000..057f10bf7 --- /dev/null +++ b/integrations/templates-nunjucks/tsconfig.test.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "declaration": false, + "noEmit": true, + "types": ["node", "vitest/globals"] + }, + "include": ["src/**/*.test.ts"], + "exclude": ["node_modules/**", "**/dist/**", "smoke/**"] +} diff --git a/integrations/temporal-js/package.json b/integrations/temporal-js/package.json index fc2e9dbef..c1189021f 100644 --- a/integrations/temporal-js/package.json +++ b/integrations/temporal-js/package.json @@ -22,7 +22,7 @@ }, "scripts": { "build": "tsup", - "check:typings": "tsc --noEmit", + "check:typings": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json", "watch": "tsup --watch", "clean": "rm -r dist/*", "test": "vitest run", diff --git a/integrations/temporal-js/src/temporal.test.ts b/integrations/temporal-js/src/temporal.test.ts index 80f932acf..866be96d4 100644 --- a/integrations/temporal-js/src/temporal.test.ts +++ b/integrations/temporal-js/src/temporal.test.ts @@ -210,7 +210,7 @@ describe("BraintrustTemporalPlugin", () => { expect(configured.interceptors).toBeDefined(); expect(configured.interceptors?.workflow).toBeDefined(); expect(Array.isArray(configured.interceptors?.workflow)).toBe(true); - expect(configured.interceptors?.workflow?.length).toBe(1); + expect((configured.interceptors?.workflow as any[]).length).toBe(1); }); test("configureClient preserves existing interceptors", () => { @@ -224,7 +224,7 @@ describe("BraintrustTemporalPlugin", () => { // eslint-disable-next-line @typescript-eslint/no-explicit-any const configured = plugin.configureClient(options as any); - expect(configured.interceptors?.workflow?.length).toBe(2); + expect((configured.interceptors?.workflow as any[]).length).toBe(2); }); test("configureWorker adds activity interceptor and sinks", () => { diff --git a/integrations/temporal-js/tsconfig.json b/integrations/temporal-js/tsconfig.json index fbe98f0ae..8cfc6d9ae 100644 --- a/integrations/temporal-js/tsconfig.json +++ b/integrations/temporal-js/tsconfig.json @@ -6,6 +6,7 @@ "target": "es2022", "moduleResolution": "node", "strict": true, + "noUnusedLocals": true, "esModuleInterop": true, "skipLibCheck": true }, diff --git a/integrations/temporal-js/tsconfig.test.json b/integrations/temporal-js/tsconfig.test.json new file mode 100644 index 000000000..b72b61c42 --- /dev/null +++ b/integrations/temporal-js/tsconfig.test.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "declaration": false, + "noEmit": true, + "types": ["node", "vitest/globals"] + }, + "include": ["src/**/*.test.ts"], + "exclude": ["node_modules/**", "**/dist/**"] +} diff --git a/integrations/vercel-ai-sdk/tsconfig.json b/integrations/vercel-ai-sdk/tsconfig.json index 357391770..ea6ad1861 100644 --- a/integrations/vercel-ai-sdk/tsconfig.json +++ b/integrations/vercel-ai-sdk/tsconfig.json @@ -6,6 +6,7 @@ "target": "es2022", "moduleResolution": "node", "strict": true, + "noUnusedLocals": true, "esModuleInterop": true, "skipLibCheck": true }, diff --git a/js/package.json b/js/package.json index bf669af17..573969f9f 100644 --- a/js/package.json +++ b/js/package.json @@ -144,7 +144,7 @@ "scripts": { "postinstall": "node ./scripts/install.js", "build": "cross-env NODE_OPTIONS=\"--max-old-space-size=8192\" tsup", - "check:typings": "tsc --noEmit", + "check:typings": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json", "watch": "tsup --watch", "clean": "rm -r dist/* && rm -r dev/dist/* && rm -r util/dist/*", "docs": "typedoc --options typedoc.json src/node/index.ts", diff --git a/js/src/auto-instrumentations/loader/mastra-observability-patch.ts b/js/src/auto-instrumentations/loader/mastra-observability-patch.ts index 578b7a48c..95b8f1aa1 100644 --- a/js/src/auto-instrumentations/loader/mastra-observability-patch.ts +++ b/js/src/auto-instrumentations/loader/mastra-observability-patch.ts @@ -80,7 +80,7 @@ const MASTRA_OBSERVABILITY_ENTRY_PATHS = new Set([ "dist/index.cjs", ]); -export type MastraTargetKind = "core" | "observability"; +type MastraTargetKind = "core" | "observability"; export type MastraModuleFormat = "esm" | "cjs"; export function classifyMastraTarget( diff --git a/js/src/auto-instrumentations/loader/special-case-patches.ts b/js/src/auto-instrumentations/loader/special-case-patches.ts index 502b0af51..4b984c158 100644 --- a/js/src/auto-instrumentations/loader/special-case-patches.ts +++ b/js/src/auto-instrumentations/loader/special-case-patches.ts @@ -37,9 +37,9 @@ import { } from "./mastra-observability-patch.js"; import { OPENAI_API_PROMISE_PATCH } from "./openai-api-promise-patch.js"; -export type SpecialCaseFormat = MastraModuleFormat; +type SpecialCaseFormat = MastraModuleFormat; -export interface SpecialCaseInput { +interface SpecialCaseInput { packageName: string; /** Forward-slash-normalized path inside the package, e.g. `dist/index.js`. */ modulePath: string; diff --git a/js/src/auto-instrumentations/patch-tracing-channel.test.ts b/js/src/auto-instrumentations/patch-tracing-channel.test.ts index a78b9e082..e346717a6 100644 --- a/js/src/auto-instrumentations/patch-tracing-channel.test.ts +++ b/js/src/auto-instrumentations/patch-tracing-channel.test.ts @@ -194,7 +194,7 @@ describe("patchTracingChannel", () => { const apiPromise = new MockAPIPromise(Promise.resolve("hello")); const traced = channel.tracePromise(() => apiPromise, {}, null); - const withResponse = await traced.withResponse(); + const withResponse = await (traced as any).withResponse(); expect(traced).toBe(apiPromise); expect(withResponse.data).toBe("hello"); diff --git a/js/src/cli/functions/upload.test.ts b/js/src/cli/functions/upload.test.ts index 8917e1572..f0ecde997 100644 --- a/js/src/cli/functions/upload.test.ts +++ b/js/src/cli/functions/upload.test.ts @@ -1,6 +1,5 @@ import { describe, expect, test, vi } from "vitest"; import { buildBundledFunctionEntry } from "./upload"; -import { findCodeDefinition } from "./infer-source"; vi.mock("./infer-source", () => ({ findCodeDefinition: vi.fn(), @@ -61,7 +60,7 @@ describe("buildBundledFunctionEntry", () => { }, }, }); - expect(entry.function_data.data.preview).toBeUndefined(); + expect(((entry.function_data as any).data as any).preview).toBeUndefined(); }); test("does not invent tags when they are omitted", async () => { @@ -108,7 +107,7 @@ describe("buildBundledFunctionEntry", () => { }); expect(entry.function_type).toBe("classifier"); - expect(entry.function_data.data.location).toEqual({ + expect(((entry.function_data as any).data as any).location).toEqual({ type: "experiment", eval_name: "eval-1", position: { diff --git a/js/src/cli/functions/upload.ts b/js/src/cli/functions/upload.ts index f4951dd76..da513f503 100644 --- a/js/src/cli/functions/upload.ts +++ b/js/src/cli/functions/upload.ts @@ -3,7 +3,7 @@ import { type FunctionType as FunctionObject, type IfExistsType as IfExists, } from "../../generated_types"; -import type { BuildSuccess, EvaluatorState, FileHandle } from "../types"; +import type { BuildSuccess, FileHandle } from "../types"; import { classifierName, scorerName, warning } from "../../framework"; import { _internalGetGlobalState, @@ -27,14 +27,6 @@ import { serializeRemoteEvalParametersContainer, } from "../../framework2"; -export type EvaluatorMap = Record< - string, - { - evaluator: EvaluatorState["evaluators"][number]; - experiment: Experiment; - } ->; - interface BundledFunctionSpec { project_id: string; name: string; diff --git a/js/src/cli/progress.ts b/js/src/cli/progress.ts index a9cbf4f9e..befab92f6 100644 --- a/js/src/cli/progress.ts +++ b/js/src/cli/progress.ts @@ -1,2 +1 @@ -export type { ProgressReporter } from "../reporters/types"; export { BarProgressReporter } from "./reporters/progress"; diff --git a/js/src/cli/util/external-packages-plugin.test.ts b/js/src/cli/util/external-packages-plugin.test.ts index 95e4b2a69..34011d05f 100644 --- a/js/src/cli/util/external-packages-plugin.test.ts +++ b/js/src/cli/util/external-packages-plugin.test.ts @@ -1,5 +1,4 @@ import { describe, it, expect, vi } from "vitest"; -import * as esbuild from "esbuild"; import { createMarkKnownPackagesExternalPlugin } from "./external-packages-plugin"; describe("External Packages Plugin", () => { diff --git a/js/src/edge-runtime-bootstrap.test.ts b/js/src/edge-runtime-bootstrap.test.ts index b3e81a2ac..737f22dcb 100644 --- a/js/src/edge-runtime-bootstrap.test.ts +++ b/js/src/edge-runtime-bootstrap.test.ts @@ -142,7 +142,7 @@ describe.each([ }); const spans = await backgroundLogger.drain(); - const spanNames = spans.map((span) => span.span_attributes?.name); + const spanNames = spans.map((span: any) => span.span_attributes?.name); expect(spanNames).toContain("root"); expect(spanNames).toContain("generateText"); diff --git a/js/src/framework-types.ts b/js/src/framework-types.ts index db3e477c3..b5183cc7d 100644 --- a/js/src/framework-types.ts +++ b/js/src/framework-types.ts @@ -1,20 +1,9 @@ import { type IfExistsType as IfExists } from "./generated_types"; -import { z } from "zod/v3"; - -// Type to accept both regular Zod schemas and OpenAPI-extended ones -type ZodSchema = - | z.ZodType - | (z.ZodType & { openapi?: any }); export type GenericFunction = | ((input: Input) => Output) | ((input: Input) => Promise); -export type Schema = Partial<{ - parameters: ZodSchema; - returns: ZodSchema; -}>; - export interface BaseFnOpts { name: string; slug: string; @@ -23,11 +12,3 @@ export interface BaseFnOpts { tags?: string[]; metadata?: Record; } - -export type ToolOpts< - Params, - Returns, - Fn extends GenericFunction, -> = Partial & { - handler: Fn; -} & Schema; diff --git a/js/src/framework.test.ts b/js/src/framework.test.ts index 49eb1b091..6048d9f4f 100644 --- a/js/src/framework.test.ts +++ b/js/src/framework.test.ts @@ -323,7 +323,10 @@ describe("runEvaluator", () => { evalName: "eval", data, task: async (input: number, hooks) => { - hooks.reportProgress({ object_type: "progress", progress: 0.5 }); + hooks.reportProgress({ + object_type: "progress", + progress: 0.5, + } as any); return input * 2; }, scores: [], diff --git a/js/src/framework.ts b/js/src/framework.ts index 3a86339c1..adc2c3a3e 100644 --- a/js/src/framework.ts +++ b/js/src/framework.ts @@ -189,7 +189,7 @@ export type EvalScorer< args: EvalScorerArgs, ) => OneOrMoreScores | Promise; -export type OneOrMoreClassifications = Classification | Classification[] | null; +type OneOrMoreClassifications = Classification | Classification[] | null; export type EvalClassifier< Input, @@ -405,11 +405,7 @@ export class EvalResultWithSummary< } } -export type { - ReporterOpts, - ReporterBody, - ReporterDef, -} from "./reporters/types"; +export type { ReporterBody, ReporterDef } from "./reporters/types"; async function getPersistedBaseExperimentId( experiment: Experiment, @@ -566,7 +562,7 @@ globalThis._evals = { reporters: {}, }; -export interface EvalOptions { +interface EvalOptions { /** * A `Reporter` which you can use to summarize progress after an Eval() runs. */ diff --git a/js/src/framework2.ts b/js/src/framework2.ts index 9a4ae5905..47994f5f1 100644 --- a/js/src/framework2.ts +++ b/js/src/framework2.ts @@ -630,7 +630,7 @@ export class PromptBuilder { } } -export interface ParametersOpts { +interface ParametersOpts { name: string; slug?: string; description?: string; diff --git a/js/src/functions/invoke.test.ts b/js/src/functions/invoke.test.ts index 653d48ddb..4dd5deef6 100644 --- a/js/src/functions/invoke.test.ts +++ b/js/src/functions/invoke.test.ts @@ -1,4 +1,4 @@ -import { describe, expect, test, beforeEach, afterEach, vi } from "vitest"; +import { describe, expect, test, beforeEach, afterEach } from "vitest"; import { initFunction } from "./invoke"; import { _internalGetGlobalState, _exportsForTestingOnly } from "../logger"; import { configureNode } from "../node/config"; diff --git a/js/src/instrumentation/braintrust-plugin.test.ts b/js/src/instrumentation/braintrust-plugin.test.ts index 394a6b0f7..067c1f85f 100644 --- a/js/src/instrumentation/braintrust-plugin.test.ts +++ b/js/src/instrumentation/braintrust-plugin.test.ts @@ -1277,7 +1277,7 @@ describe("aggregateChatCompletionChunks", () => { }, ]; - const result = aggregateChatCompletionChunks(chunks); + const result = aggregateChatCompletionChunks(chunks as any); expect(result.output).toEqual([ { @@ -1304,7 +1304,7 @@ describe("aggregateChatCompletionChunks", () => { }, ]; - const result = aggregateChatCompletionChunks(chunks); + const result = aggregateChatCompletionChunks(chunks as any); expect(result.output[0].message.role).toBe("assistant"); }); @@ -1442,15 +1442,16 @@ describe("aggregateChatCompletionChunks", () => { }, ]; - const result = aggregateChatCompletionChunks(chunks); + const result = aggregateChatCompletionChunks(chunks as any); + const output = result.output as any[]; - expect(result.output[0].message.tool_calls).toHaveLength(2); - expect(result.output[0].message.tool_calls[0]).toEqual({ + expect(output[0].message.tool_calls).toHaveLength(2); + expect(output[0].message.tool_calls[0]).toEqual({ id: "call_1", type: "function", function: { name: "tool1", arguments: '{"a":1}' }, }); - expect(result.output[0].message.tool_calls[1]).toEqual({ + expect(output[0].message.tool_calls[1]).toEqual({ id: "call_2", type: "function", function: { name: "tool2", arguments: '{"b":2}' }, @@ -1472,7 +1473,7 @@ describe("aggregateChatCompletionChunks", () => { }, ]; - const result = aggregateChatCompletionChunks(chunks); + const result = aggregateChatCompletionChunks(chunks as any); expect(result.metrics).toEqual({ prompt_tokens: 10, @@ -1533,7 +1534,7 @@ describe("aggregateChatCompletionChunks", () => { { choices: [{ delta: { content: "Hi" } }] }, ]; - const result = aggregateChatCompletionChunks(chunks); + const result = aggregateChatCompletionChunks(chunks as any); expect(result.output[0].message.content).toBe("Hi"); }); diff --git a/js/src/instrumentation/core/channel-definitions.ts b/js/src/instrumentation/core/channel-definitions.ts index ef68bb2a3..67a9c855e 100644 --- a/js/src/instrumentation/core/channel-definitions.ts +++ b/js/src/instrumentation/core/channel-definitions.ts @@ -24,7 +24,7 @@ type ChannelTypeInfo< __chunk?: TChunk; }; -export type ChannelSpec< +type ChannelSpec< TArgs extends EventArguments, TResult, TExtra extends object = Record, diff --git a/js/src/instrumentation/core/channel-tracing.ts b/js/src/instrumentation/core/channel-tracing.ts index 2f2d49e62..e41269b14 100644 --- a/js/src/instrumentation/core/channel-tracing.ts +++ b/js/src/instrumentation/core/channel-tracing.ts @@ -32,7 +32,7 @@ type SpanState = { startTime: number; }; -export type AsyncChannelSpanConfig = +type AsyncChannelSpanConfig = ChannelConfig & { extractInput: ( args: [...ArgsOf, ...any[]], @@ -62,7 +62,7 @@ type StreamingResult = Exclude< AsyncIterable >; -export type StreamingChannelSpanConfig = +type StreamingChannelSpanConfig = ChannelConfig & { extractInput: ( args: [...ArgsOf, ...any[]], @@ -115,7 +115,7 @@ export type StreamingChannelSpanConfig = }) => void; }; -export type SyncStreamChannelSpanConfig = +type SyncStreamChannelSpanConfig = ChannelConfig & { extractInput: ( args: [...ArgsOf, ...any[]], diff --git a/js/src/instrumentation/core/index.ts b/js/src/instrumentation/core/index.ts index 0e4e1e830..6e2d2d61c 100644 --- a/js/src/instrumentation/core/index.ts +++ b/js/src/instrumentation/core/index.ts @@ -18,13 +18,10 @@ export { } from "./channel"; export type { BaseContext, - ChannelSpanInfo, StartEvent, EndEvent, ErrorEvent, AsyncStartEvent, AsyncEndEvent, ChannelHandlers, - SpanInfoCarrier, } from "./types"; -export type { StreamPatchOptions } from "./stream-patcher"; diff --git a/js/src/instrumentation/core/stream-patcher.ts b/js/src/instrumentation/core/stream-patcher.ts index 6796f5ccb..8bb25d80b 100644 --- a/js/src/instrumentation/core/stream-patcher.ts +++ b/js/src/instrumentation/core/stream-patcher.ts @@ -23,7 +23,7 @@ export function isAsyncIterable( /** * Options for stream patching. */ -export interface StreamPatchOptions { +interface StreamPatchOptions { /** * Called for each chunk as it's yielded. * Optional - if not provided, chunks are just collected. diff --git a/js/src/instrumentation/plugins/ai-sdk-plugin.streaming.test.ts b/js/src/instrumentation/plugins/ai-sdk-plugin.streaming.test.ts index 3fd0371a6..2db61464e 100644 --- a/js/src/instrumentation/plugins/ai-sdk-plugin.streaming.test.ts +++ b/js/src/instrumentation/plugins/ai-sdk-plugin.streaming.test.ts @@ -13,7 +13,6 @@ import { configureNode } from "../../node/config"; import { _exportsForTestingOnly, initLogger, - Logger, TestBackgroundLogger, } from "../../logger"; import { wrapAISDK } from "../../wrappers/ai-sdk"; @@ -28,7 +27,6 @@ const sleep = (ms: number) => describe("AI SDK streaming instrumentation", () => { let backgroundLogger: TestBackgroundLogger; - let _logger: Logger; beforeAll(async () => { await _exportsForTestingOnly.simulateLoginForTests(); @@ -36,7 +34,7 @@ describe("AI SDK streaming instrumentation", () => { beforeEach(() => { backgroundLogger = _exportsForTestingOnly.useTestBackgroundLogger(); - _logger = initLogger({ + initLogger({ projectName: "ai-sdk-plugin.streaming.test.ts", projectId: "test-project-id", }); diff --git a/js/src/instrumentation/plugins/ai-sdk-plugin.test.ts b/js/src/instrumentation/plugins/ai-sdk-plugin.test.ts index d1ed8f7e8..959d9ec52 100644 --- a/js/src/instrumentation/plugins/ai-sdk-plugin.test.ts +++ b/js/src/instrumentation/plugins/ai-sdk-plugin.test.ts @@ -21,7 +21,6 @@ vi.mock("../../wrappers/ai-sdk/telemetry", () => ({ })); import { AISDKPlugin } from "./ai-sdk-plugin"; -import { Attachment } from "../../logger"; import iso from "../../isomorph"; import { serializeAISDKToolsForLogging } from "../../wrappers/ai-sdk/tool-serialization"; diff --git a/js/src/instrumentation/plugins/ai-sdk-plugin.ts b/js/src/instrumentation/plugins/ai-sdk-plugin.ts index 2c53704ed..199ccf6f2 100644 --- a/js/src/instrumentation/plugins/ai-sdk-plugin.ts +++ b/js/src/instrumentation/plugins/ai-sdk-plugin.ts @@ -43,7 +43,7 @@ import type { } from "../../vendor-sdk-types/ai-sdk"; import type { AISDKV7Telemetry } from "../../vendor-sdk-types/ai-sdk-v7-telemetry"; -export interface AISDKPluginConfig { +interface AISDKPluginConfig { /** * List of JSON paths to remove from output field. * Uses dot notation with array wildcards: "roundtrips[].request.body" diff --git a/js/src/instrumentation/plugins/anthropic-plugin.test.ts b/js/src/instrumentation/plugins/anthropic-plugin.test.ts index efe50aedb..c8aa0b955 100644 --- a/js/src/instrumentation/plugins/anthropic-plugin.test.ts +++ b/js/src/instrumentation/plugins/anthropic-plugin.test.ts @@ -1,4 +1,4 @@ -import { describe, it, expect, vi, beforeEach, afterEach } from "vitest"; +import { describe, it, expect, vi } from "vitest"; // Mock iso's newTracingChannel - must be before any imports that use it vi.mock("../../isomorph", () => ({ @@ -8,17 +8,17 @@ vi.mock("../../isomorph", () => ({ })); import { - AnthropicPlugin, parseMetricsFromUsage, aggregateAnthropicStreamChunks, processAttachmentsInInput, coalesceInput, } from "./anthropic-plugin"; -import type { StartEvent } from "../core"; import { Attachment } from "../../logger"; -import iso from "../../isomorph"; -const mockNewTracingChannel = iso.newTracingChannel as ReturnType; +const parseMetricsFromUsageForTest = (usage: unknown) => + parseMetricsFromUsage(usage as any); +const aggregateAnthropicStreamChunksForTest = (chunks: unknown[]) => + aggregateAnthropicStreamChunks(chunks as any); // Mock startSpan from logger vi.mock("../../logger", () => ({ @@ -40,11 +40,11 @@ vi.mock("../../logger", () => ({ describe("parseMetricsFromUsage", () => { it("should return empty object for null usage", () => { - expect(parseMetricsFromUsage(null)).toEqual({}); + expect(parseMetricsFromUsageForTest(null)).toEqual({}); }); it("should return empty object for undefined usage", () => { - expect(parseMetricsFromUsage(undefined)).toEqual({}); + expect(parseMetricsFromUsageForTest(undefined)).toEqual({}); }); it("should map Anthropic token names to Braintrust names", () => { @@ -53,7 +53,7 @@ describe("parseMetricsFromUsage", () => { output_tokens: 50, }; - const result = parseMetricsFromUsage(usage); + const result = parseMetricsFromUsageForTest(usage); expect(result).toEqual({ prompt_tokens: 100, @@ -68,7 +68,7 @@ describe("parseMetricsFromUsage", () => { cache_read_input_tokens: 25, }; - const result = parseMetricsFromUsage(usage); + const result = parseMetricsFromUsageForTest(usage); expect(result).toEqual({ prompt_tokens: 100, @@ -84,7 +84,7 @@ describe("parseMetricsFromUsage", () => { cache_creation_input_tokens: 30, }; - const result = parseMetricsFromUsage(usage); + const result = parseMetricsFromUsageForTest(usage); expect(result).toEqual({ prompt_tokens: 100, @@ -101,7 +101,7 @@ describe("parseMetricsFromUsage", () => { cache_creation_input_tokens: 30, }; - const result = parseMetricsFromUsage(usage); + const result = parseMetricsFromUsageForTest(usage); expect(result).toEqual({ prompt_tokens: 100, @@ -118,7 +118,7 @@ describe("parseMetricsFromUsage", () => { cache_read_input_tokens: null, }; - const result = parseMetricsFromUsage(usage); + const result = parseMetricsFromUsageForTest(usage); expect(result).toEqual({ completion_tokens: 50, @@ -126,7 +126,7 @@ describe("parseMetricsFromUsage", () => { }); it("should handle empty usage object", () => { - expect(parseMetricsFromUsage({})).toEqual({}); + expect(parseMetricsFromUsageForTest({})).toEqual({}); }); it("should flatten server_tool_use metrics", () => { @@ -139,7 +139,7 @@ describe("parseMetricsFromUsage", () => { }, }; - const result = parseMetricsFromUsage(usage); + const result = parseMetricsFromUsageForTest(usage); expect(result).toEqual({ prompt_tokens: 100, @@ -158,7 +158,7 @@ describe("parseMetricsFromUsage", () => { }, }; - const result = parseMetricsFromUsage(usage); + const result = parseMetricsFromUsageForTest(usage); expect(result).toEqual({ prompt_tokens: 100, @@ -203,7 +203,7 @@ describe("aggregateAnthropicStreamChunks", () => { }, ]; - const result = aggregateAnthropicStreamChunks(chunks); + const result = aggregateAnthropicStreamChunksForTest(chunks); expect(result.output).toBe("Hello world"); expect(result.metrics).toMatchObject({ @@ -225,7 +225,7 @@ describe("aggregateAnthropicStreamChunks", () => { }, ]; - const result = aggregateAnthropicStreamChunks(chunks); + const result = aggregateAnthropicStreamChunksForTest(chunks); // finalizeAnthropicTokens adds all cache tokens to prompt_tokens expect(result.metrics).toMatchObject({ @@ -255,7 +255,7 @@ describe("aggregateAnthropicStreamChunks", () => { }, ]; - const result = aggregateAnthropicStreamChunks(chunks); + const result = aggregateAnthropicStreamChunksForTest(chunks); expect(result.output).toBe("The quick brown fox"); }); @@ -282,7 +282,7 @@ describe("aggregateAnthropicStreamChunks", () => { }, ]; - const result = aggregateAnthropicStreamChunks(chunks); + const result = aggregateAnthropicStreamChunksForTest(chunks); expect(result.metrics).toMatchObject({ prompt_tokens: 100, @@ -304,7 +304,7 @@ describe("aggregateAnthropicStreamChunks", () => { }, ]; - const result = aggregateAnthropicStreamChunks(chunks); + const result = aggregateAnthropicStreamChunksForTest(chunks); expect(result.metadata).toEqual({ stop_reason: "end_turn", @@ -322,7 +322,7 @@ describe("aggregateAnthropicStreamChunks", () => { }, ]; - const result = aggregateAnthropicStreamChunks(chunks); + const result = aggregateAnthropicStreamChunksForTest(chunks); expect(result.metadata).toEqual({ stop_reason: "stop_sequence", @@ -331,7 +331,7 @@ describe("aggregateAnthropicStreamChunks", () => { }); it("should handle empty chunks array", () => { - const result = aggregateAnthropicStreamChunks([]); + const result = aggregateAnthropicStreamChunksForTest([]); expect(result.output).toBe(""); // finalizeAnthropicTokens always adds prompt_tokens and tokens @@ -358,7 +358,7 @@ describe("aggregateAnthropicStreamChunks", () => { }, ]; - const result = aggregateAnthropicStreamChunks(chunks); + const result = aggregateAnthropicStreamChunksForTest(chunks); expect(result.output).toBe("Hello world"); }); @@ -409,7 +409,7 @@ describe("aggregateAnthropicStreamChunks", () => { }, ]; - const result = aggregateAnthropicStreamChunks(chunks); + const result = aggregateAnthropicStreamChunksForTest(chunks); expect(result.output).toEqual({ role: "assistant", @@ -445,7 +445,7 @@ describe("aggregateAnthropicStreamChunks", () => { { type: "message_stop" }, ]; - const result = aggregateAnthropicStreamChunks(chunks); + const result = aggregateAnthropicStreamChunksForTest(chunks); expect(result.output).toBe("Hi"); }); @@ -481,7 +481,7 @@ describe("aggregateAnthropicStreamChunks", () => { { type: "content_block_stop", index: 1 }, ]; - const result = aggregateAnthropicStreamChunks(chunks); + const result = aggregateAnthropicStreamChunksForTest(chunks); expect(result.output).toEqual({ content: [ @@ -518,7 +518,7 @@ describe("aggregateAnthropicStreamChunks", () => { { type: "content_block_stop", index: 0 }, ]; - const result = aggregateAnthropicStreamChunks(chunks); + const result = aggregateAnthropicStreamChunksForTest(chunks); expect(result.output).toEqual({ content: [ @@ -546,7 +546,7 @@ describe("aggregateAnthropicStreamChunks", () => { { type: "content_block_stop", index: 0 }, ]; - const result = aggregateAnthropicStreamChunks(chunks); + const result = aggregateAnthropicStreamChunksForTest(chunks); expect(result.output).toEqual({ content: [ @@ -591,7 +591,7 @@ describe("aggregateAnthropicStreamChunks", () => { { type: "content_block_stop", index: 0 }, ]; - const result = aggregateAnthropicStreamChunks(chunks); + const result = aggregateAnthropicStreamChunksForTest(chunks); expect(result.output).toEqual({ content: [ @@ -625,7 +625,7 @@ describe("aggregateAnthropicStreamChunks", () => { { type: "content_block_stop", index: 0 }, ]; - const result = aggregateAnthropicStreamChunks(chunks); + const result = aggregateAnthropicStreamChunksForTest(chunks); expect(result.output).toEqual({ content: [ @@ -654,7 +654,7 @@ describe("aggregateAnthropicStreamChunks", () => { { type: "content_block_stop", index: 0 }, ]; - const result = aggregateAnthropicStreamChunks(chunks); + const result = aggregateAnthropicStreamChunksForTest(chunks); expect(result.output).toEqual({ content: [{ type: "some_future_type", data: "value" }], @@ -708,7 +708,7 @@ describe("aggregateAnthropicStreamChunks", () => { { type: "content_block_stop", index: 2 }, ]; - const result = aggregateAnthropicStreamChunks(chunks); + const result = aggregateAnthropicStreamChunksForTest(chunks); expect(result.output).toEqual({ content: [ @@ -737,7 +737,7 @@ describe("processAttachmentsInInput", () => { }, ]; - const result = processAttachmentsInInput(input); + const result = processAttachmentsInInput(input) as any; expect(result[0].type).toBe("image"); expect(result[0].source.type).toBe("base64"); @@ -762,7 +762,7 @@ describe("processAttachmentsInInput", () => { }, ]; - const result = processAttachmentsInInput(input); + const result = processAttachmentsInInput(input) as any; expect(result[0].type).toBe("document"); expect(result[0].source.data).toBeInstanceOf(Attachment); @@ -787,7 +787,7 @@ describe("processAttachmentsInInput", () => { }, ]; - const result = processAttachmentsInInput(input); + const result = processAttachmentsInInput(input) as any; const attachment = result[0].source.data as Attachment; expect(attachment.reference.filename).toBe("image.gif"); @@ -808,7 +808,7 @@ describe("processAttachmentsInInput", () => { }, ]; - const result = processAttachmentsInInput(input); + const result = processAttachmentsInInput(input) as any; const attachment = result[0].source.data as Attachment; expect(attachment.reference.filename).toBe("image.png"); @@ -837,7 +837,7 @@ describe("processAttachmentsInInput", () => { ], }; - const result = processAttachmentsInInput(input); + const result = processAttachmentsInInput(input) as any; expect(result.messages[0].content[0].type).toBe("text"); expect(result.messages[0].content[1].source.data).toBeInstanceOf( @@ -861,7 +861,7 @@ describe("processAttachmentsInInput", () => { { type: "text", text: "World" }, ]; - const result = processAttachmentsInInput(input); + const result = processAttachmentsInInput(input) as any; expect(result[0]).toEqual({ type: "text", text: "Hello" }); expect(result[1].source.data).toBeInstanceOf(Attachment); @@ -874,7 +874,7 @@ describe("processAttachmentsInInput", () => { { type: "custom", data: "some data" }, ]; - const result = processAttachmentsInInput(input); + const result = processAttachmentsInInput(input) as any; expect(result).toEqual(input); }); @@ -897,7 +897,7 @@ describe("processAttachmentsInInput", () => { }, ]; - const result = processAttachmentsInInput(input); + const result = processAttachmentsInInput(input) as any; expect(result).toEqual(input); }); @@ -913,7 +913,7 @@ describe("processAttachmentsInInput", () => { }, ]; - const result = processAttachmentsInInput(input); + const result = processAttachmentsInInput(input) as any; // Should not crash, just return as-is or with minimal processing expect(result[0].type).toBe("image"); diff --git a/js/src/instrumentation/plugins/bedrock-runtime-channels.ts b/js/src/instrumentation/plugins/bedrock-runtime-channels.ts index e884b7bd3..49c410e55 100644 --- a/js/src/instrumentation/plugins/bedrock-runtime-channels.ts +++ b/js/src/instrumentation/plugins/bedrock-runtime-channels.ts @@ -7,7 +7,7 @@ import type { BedrockRuntimeSendResult, } from "../../vendor-sdk-types/bedrock-runtime"; -export type BedrockRuntimeStreamEvent = +type BedrockRuntimeStreamEvent = | BedrockRuntimeConverseStreamEvent | BedrockRuntimeResponseStreamEvent; diff --git a/js/src/instrumentation/plugins/bedrock-runtime-common.ts b/js/src/instrumentation/plugins/bedrock-runtime-common.ts index 3bd463d4a..413e5eb3a 100644 --- a/js/src/instrumentation/plugins/bedrock-runtime-common.ts +++ b/js/src/instrumentation/plugins/bedrock-runtime-common.ts @@ -4,7 +4,7 @@ import type { BedrockRuntimeCommandName, } from "../../vendor-sdk-types/bedrock-runtime"; -export type BedrockRuntimeOperation = +type BedrockRuntimeOperation = | "converse" | "converseStream" | "invokeModel" diff --git a/js/src/instrumentation/plugins/bedrock-runtime-plugin.test.ts b/js/src/instrumentation/plugins/bedrock-runtime-plugin.test.ts index 255db2cb0..fc74a9068 100644 --- a/js/src/instrumentation/plugins/bedrock-runtime-plugin.test.ts +++ b/js/src/instrumentation/plugins/bedrock-runtime-plugin.test.ts @@ -72,7 +72,7 @@ describe("BedrockRuntimePlugin", () => { new ConverseCommand({ messages: [{ role: "user", content: [{ text: "OK" }] }], modelId: "us.amazon.nova-lite-v1:0", - }), + }) as any, ], }, ); @@ -86,7 +86,7 @@ describe("BedrockRuntimePlugin", () => { () => {}, ], }; - tracingChannel.start.publish(callbackEvent); + tracingChannel.start!.publish(callbackEvent); callbackEvent.result = { output: { message: { @@ -95,7 +95,7 @@ describe("BedrockRuntimePlugin", () => { }, }, }; - tracingChannel.asyncEnd.publish(callbackEvent); + tracingChannel.asyncEnd!.publish(callbackEvent); const spans = await backgroundLogger.drain(); expect(spans).toEqual( @@ -149,7 +149,7 @@ describe("BedrockRuntimePlugin", () => { new GetObjectCommand({ Bucket: "not-bedrock", Key: "object.txt", - }), + }) as any, ], }, ); @@ -206,7 +206,7 @@ describe("BedrockRuntimePlugin", () => { new InvokeModelWithBidirectionalStreamCommand({ body: undefined, modelId: "us.amazon.nova-lite-v1:0", - }), + }) as any, ], }, ); diff --git a/js/src/instrumentation/plugins/claude-agent-sdk-local-tool-spans.ts b/js/src/instrumentation/plugins/claude-agent-sdk-local-tool-spans.ts index 28026770b..d9a70dcb7 100644 --- a/js/src/instrumentation/plugins/claude-agent-sdk-local-tool-spans.ts +++ b/js/src/instrumentation/plugins/claude-agent-sdk-local-tool-spans.ts @@ -3,7 +3,7 @@ import { SpanTypeAttribute, isPromiseLike } from "../../../util/index"; import { toLoggedError } from "../core"; import { getClaudeLocalToolParentResolver } from "./claude-agent-sdk-local-tool-context"; -export type LocalToolSpanMetadata = { +type LocalToolSpanMetadata = { serverName?: string; toolName: string; }; diff --git a/js/src/instrumentation/plugins/cursor-sdk-plugin.test.ts b/js/src/instrumentation/plugins/cursor-sdk-plugin.test.ts index 909fceb02..b22052c8c 100644 --- a/js/src/instrumentation/plugins/cursor-sdk-plugin.test.ts +++ b/js/src/instrumentation/plugins/cursor-sdk-plugin.test.ts @@ -84,7 +84,7 @@ describe("CursorSDKPlugin", () => { ); const run = makeRun(); const originalSend = vi.fn(async () => run); - const agent = { + const agent: any = { agentId: "agent-1", send: originalSend, }; @@ -169,7 +169,7 @@ describe("CursorSDKPlugin", () => { }; sendHandlers.start(event); - await event.arguments[1].onDelta({ + await (event.arguments[1] as any).onDelta({ update: { type: "turn-ended", usage: { diff --git a/js/src/instrumentation/plugins/google-adk-plugin.test.ts b/js/src/instrumentation/plugins/google-adk-plugin.test.ts index c0f7f7240..cca8c650e 100644 --- a/js/src/instrumentation/plugins/google-adk-plugin.test.ts +++ b/js/src/instrumentation/plugins/google-adk-plugin.test.ts @@ -28,9 +28,9 @@ const mockStartSpan = vi.fn(() => ({ })); vi.mock("../../logger", () => ({ - startSpan: (...args: any[]) => mockStartSpan(...args), + startSpan: (...args: any[]) => (mockStartSpan as any)(...args), _internalGetGlobalState: (...args: any[]) => - mockInternalGetGlobalState(...args), + (mockInternalGetGlobalState as any)(...args), BRAINTRUST_CURRENT_SPAN_STORE: MOCK_CURRENT_SPAN_STORE_SYMBOL, Attachment: class MockAttachment { reference: any; @@ -225,7 +225,7 @@ describe("GoogleADKPlugin", () => { [MOCK_CURRENT_SPAN_STORE_SYMBOL]: currentSpanStore, wrapSpanForStore, }, - }); + } as any); plugin.enable(); @@ -351,7 +351,7 @@ describe("GoogleADKPlugin", () => { [MOCK_CURRENT_SPAN_STORE_SYMBOL]: currentSpanStore, wrapSpanForStore, }, - }); + } as any); plugin.enable(); diff --git a/js/src/instrumentation/plugins/google-genai-plugin.test.ts b/js/src/instrumentation/plugins/google-genai-plugin.test.ts index 6987a18eb..81db9ee93 100644 --- a/js/src/instrumentation/plugins/google-genai-plugin.test.ts +++ b/js/src/instrumentation/plugins/google-genai-plugin.test.ts @@ -26,7 +26,7 @@ vi.mock("../../isomorph", () => ({ })); import { GoogleGenAIPlugin } from "./google-genai-plugin"; -import { Attachment, startSpan } from "../../logger"; +import { startSpan } from "../../logger"; import iso from "../../isomorph"; const mockNewTracingChannel = iso.newTracingChannel as ReturnType; @@ -546,7 +546,7 @@ describe("Google GenAI serialization functions", () => { }); it("should handle missing usage metadata", () => { - const response = {}; + const response: any = {}; expect(response.usageMetadata).toBeUndefined(); }); @@ -735,8 +735,8 @@ describe("Google GenAI serialization functions", () => { ]; const lastChunk = chunks[chunks.length - 1]; - expect(lastChunk.usageMetadata).toBeDefined(); - expect(lastChunk.usageMetadata.totalTokenCount).toBe(15); + expect(lastChunk?.usageMetadata).toBeDefined(); + expect(lastChunk?.usageMetadata?.totalTokenCount).toBe(15); }); it("should include finish reason and safety ratings", () => { @@ -827,8 +827,6 @@ describe("Google GenAI serialization functions", () => { describe("inline data to attachment conversion", () => { it("should create proper attachment structure for base64 image", () => { - const base64Data = - "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8DwHwAFBQIAX8jx0gAAAABJRU5ErkJggg=="; const mimeType = "image/png"; // Simulate attachment creation @@ -848,7 +846,7 @@ describe("Google GenAI serialization functions", () => { }); it("should use default extension for unknown mime types", () => { - const mimeType = undefined; + const mimeType = undefined as string | undefined; const extension = mimeType ? mimeType.split("/")[1] : "bin"; expect(extension).toBe("bin"); }); @@ -894,7 +892,7 @@ describe("Google GenAI serialization functions", () => { }); it("should handle null tools config", () => { - const config = { + const config: any = { temperature: 0.7, }; diff --git a/js/src/instrumentation/plugins/groq-channels.ts b/js/src/instrumentation/plugins/groq-channels.ts index 638afcbff..6c3eee796 100644 --- a/js/src/instrumentation/plugins/groq-channels.ts +++ b/js/src/instrumentation/plugins/groq-channels.ts @@ -1,6 +1,5 @@ import { channel, defineChannels } from "../core/channel-definitions"; import type { - GroqChatChoice, GroqChatCompletion, GroqChatCompletionChunk, GroqChatCreateParams, @@ -29,5 +28,3 @@ export const groqChannels = defineChannels("groq-sdk", { }, ), }); - -export type GroqChatResultChoice = GroqChatChoice; diff --git a/js/src/instrumentation/plugins/langchain-plugin.test.ts b/js/src/instrumentation/plugins/langchain-plugin.test.ts index df9e663a4..a098977fd 100644 --- a/js/src/instrumentation/plugins/langchain-plugin.test.ts +++ b/js/src/instrumentation/plugins/langchain-plugin.test.ts @@ -19,25 +19,25 @@ function createManager(handlers: unknown[] = []) { } function traceConfigureResult(result: unknown) { - return langChainChannels.configure.traceSync(() => result, { + return langChainChannels.configure.traceSync(() => result as any, { arguments: [], }); } function traceConfigureArguments(args: unknown[]) { - return langChainChannels.configure.traceSync(() => args, { - arguments: args, + return langChainChannels.configure.traceSync(() => args as any, { + arguments: args as any, }); } function traceConfigureArgumentsObject(args: IArguments) { - return langChainChannels.configure.traceSync(() => args, { - arguments: args, + return langChainChannels.configure.traceSync(() => args as any, { + arguments: args as any, }); } function createArgumentsObject(...args: unknown[]): IArguments { - return (function getArgumentsObject() { + return (function getArgumentsObject(..._args: unknown[]) { return arguments; })(...args); } diff --git a/js/src/instrumentation/plugins/openai-agents-plugin.test.ts b/js/src/instrumentation/plugins/openai-agents-plugin.test.ts index 354c1bad7..3ad3c0987 100644 --- a/js/src/instrumentation/plugins/openai-agents-plugin.test.ts +++ b/js/src/instrumentation/plugins/openai-agents-plugin.test.ts @@ -68,22 +68,22 @@ describe("OpenAIAgentsPlugin", () => { await openAIAgentsCoreChannels.onTraceStart.tracePromise( async () => undefined, - { arguments: [trace] }, + { arguments: [trace as any] }, ); await openAIAgentsCoreChannels.onSpanStart.tracePromise( async () => undefined, - { arguments: [span] }, + { arguments: [span as any] }, ); await openAIAgentsCoreChannels.onSpanEnd.tracePromise( async () => undefined, - { arguments: [span] }, + { arguments: [span as any] }, ); await openAIAgentsCoreChannels.onTraceEnd.tracePromise( async () => undefined, - { arguments: [trace] }, + { arguments: [trace as any] }, ); - const spans = await backgroundLogger.drain(); + const spans = (await backgroundLogger.drain()) as any[]; const taskSpan = spans.find( (s) => s.span_attributes?.name === "Agent workflow", ); diff --git a/js/src/instrumentation/plugins/openai-channels.ts b/js/src/instrumentation/plugins/openai-channels.ts index 4347e55b3..d246509a2 100644 --- a/js/src/instrumentation/plugins/openai-channels.ts +++ b/js/src/instrumentation/plugins/openai-channels.ts @@ -1,6 +1,6 @@ import type { CompiledPrompt } from "../../logger"; import { channel, defineChannels } from "../core/channel-definitions"; -import type { AsyncEndOf, StartOf } from "../core/channel-definitions"; +import type { StartOf } from "../core/channel-definitions"; import type { ChannelSpanInfo, SpanInfoCarrier } from "../core/types"; import type { OpenAIChatCompletion, @@ -19,14 +19,13 @@ import type { type OpenAIChatSpanInfo = NonNullable["span_info"]>; -export type OpenAIChannelExtras< - TSpanInfo extends ChannelSpanInfo = ChannelSpanInfo, -> = SpanInfoCarrier & { - response?: Response; -}; +type OpenAIChannelExtras = + SpanInfoCarrier & { + response?: Response; + }; -export type OpenAIChatChannelExtras = OpenAIChannelExtras; -export type OpenAIResponsesChannelExtras = OpenAIChannelExtras; +type OpenAIChatChannelExtras = OpenAIChannelExtras; +type OpenAIResponsesChannelExtras = OpenAIChannelExtras; export const openAIChannels = defineChannels("openai", { chatCompletionsCreate: channel< @@ -123,6 +122,3 @@ export type OpenAIAsyncChannel = Extract; export type OpenAIStartContext = StartOf; -export type OpenAIAsyncEndEvent< - TChannel extends OpenAIAsyncChannel = OpenAIAsyncChannel, -> = AsyncEndOf; diff --git a/js/src/instrumentation/plugins/openai-plugin.test.ts b/js/src/instrumentation/plugins/openai-plugin.test.ts index a4c0d6484..5f2b237fa 100644 --- a/js/src/instrumentation/plugins/openai-plugin.test.ts +++ b/js/src/instrumentation/plugins/openai-plugin.test.ts @@ -311,7 +311,7 @@ describe("aggregateChatCompletionChunks", () => { }, ]; - const result = aggregateChatCompletionChunks(chunks); + const result = aggregateChatCompletionChunks(chunks as any); expect(result.output).toEqual([ { @@ -358,7 +358,7 @@ describe("aggregateChatCompletionChunks", () => { }, ]; - const result = aggregateChatCompletionChunks(chunks); + const result = aggregateChatCompletionChunks(chunks as any); expect(result.output[0].message.role).toBe("assistant"); }); @@ -376,7 +376,7 @@ describe("aggregateChatCompletionChunks", () => { }, ]; - const result = aggregateChatCompletionChunks(chunks); + const result = aggregateChatCompletionChunks(chunks as any); expect(result.output[0].message.role).toBe("assistant"); }); @@ -399,7 +399,7 @@ describe("aggregateChatCompletionChunks", () => { }, ]; - const result = aggregateChatCompletionChunks(chunks); + const result = aggregateChatCompletionChunks(chunks as any); expect(result.output[0].message.content).toBe("Hello world!"); }); @@ -560,15 +560,16 @@ describe("aggregateChatCompletionChunks", () => { }, ]; - const result = aggregateChatCompletionChunks(chunks); + const result = aggregateChatCompletionChunks(chunks as any); + const output = result.output as any[]; - expect(result.output[0].message.tool_calls).toHaveLength(2); - expect(result.output[0].message.tool_calls[0]).toEqual({ + expect(output[0].message.tool_calls).toHaveLength(2); + expect(output[0].message.tool_calls[0]).toEqual({ id: "call_1", type: "function", function: { name: "tool1", arguments: '{"a":1}' }, }); - expect(result.output[0].message.tool_calls[1]).toEqual({ + expect(output[0].message.tool_calls[1]).toEqual({ id: "call_2", type: "function", function: { name: "tool2", arguments: '{"b":2}' }, @@ -607,10 +608,11 @@ describe("aggregateChatCompletionChunks", () => { }, ]; - const result = aggregateChatCompletionChunks(chunks); + const result = aggregateChatCompletionChunks(chunks as any); + const output = result.output as any[]; - expect(result.output[0].message.tool_calls).toHaveLength(1); - expect(result.output[0].message.tool_calls[0].function.arguments).toBe( + expect(output[0].message.tool_calls).toHaveLength(1); + expect(output[0].message.tool_calls[0].function.arguments).toBe( '{"a":1}', ); }); @@ -627,7 +629,7 @@ describe("aggregateChatCompletionChunks", () => { }, ]; - const result = aggregateChatCompletionChunks(chunks); + const result = aggregateChatCompletionChunks(chunks as any); expect(result.output[0].finish_reason).toBe("stop"); }); @@ -787,7 +789,7 @@ describe("aggregateChatCompletionChunks", () => { { choices: [{ delta: { content: "Hi" } }] }, ]; - const result = aggregateChatCompletionChunks(chunks); + const result = aggregateChatCompletionChunks(chunks as any); expect(result.output[0].message.content).toBe("Hi"); }); @@ -798,7 +800,7 @@ describe("aggregateChatCompletionChunks", () => { { choices: [{ delta: { content: "Hi" } }] }, ]; - const result = aggregateChatCompletionChunks(chunks); + const result = aggregateChatCompletionChunks(chunks as any); expect(result.output[0].message.content).toBe("Hi"); }); diff --git a/js/src/instrumentation/plugins/openrouter-agent-plugin.test.ts b/js/src/instrumentation/plugins/openrouter-agent-plugin.test.ts index 94a4c6968..85d66d51c 100644 --- a/js/src/instrumentation/plugins/openrouter-agent-plugin.test.ts +++ b/js/src/instrumentation/plugins/openrouter-agent-plugin.test.ts @@ -462,7 +462,7 @@ describe("OpenRouter Agent Plugin", () => { const result = openRouterAgentChannels.callModel.traceSync( () => { const modelResult = { - allToolExecutionRounds: [], + allToolExecutionRounds: [] as any[], finalResponse, resolvedRequest: { input: @@ -490,7 +490,9 @@ describe("OpenRouter Agent Plugin", () => { }, async getText() { const currentResponse = await modelResult.getInitialResponse(); - const toolResult = await request.tools[0].function.execute( + const toolResult = await ( + request.tools[0].function.execute as any + )( { city: "Vienna" }, { toolCall: { @@ -514,7 +516,7 @@ describe("OpenRouter Agent Plugin", () => { return modelResult; }, { - arguments: [request], + arguments: [request as any], }, ); expect(request.tools[0]).not.toBe(tool); @@ -522,7 +524,7 @@ describe("OpenRouter Agent Plugin", () => { await expect(result.getText()).resolves.toBe("Sunny in Vienna"); expect(request.tools[0]).not.toBe(tool); - const spans = await backgroundLogger.drain(); + const spans = (await backgroundLogger.drain()) as any[]; expect(spans).toHaveLength(4); const callModelSpan = spans.find( (span) => span.span_attributes?.name === "openrouter.callModel", @@ -649,7 +651,7 @@ describe("OpenRouter Agent Plugin", () => { await expect(result.getText()).resolves.toBe("ok"); - const spans = await backgroundLogger.drain(); + const spans = (await backgroundLogger.drain()) as any[]; const callModelSpan = spans.find( (span) => span.span_attributes?.name === "openrouter.callModel", ) as Record | undefined; diff --git a/js/src/instrumentation/plugins/openrouter-plugin.test.ts b/js/src/instrumentation/plugins/openrouter-plugin.test.ts index e4a841436..93627512e 100644 --- a/js/src/instrumentation/plugins/openrouter-plugin.test.ts +++ b/js/src/instrumentation/plugins/openrouter-plugin.test.ts @@ -463,7 +463,7 @@ describe("OpenRouter Plugin", () => { const result = openRouterChannels.callModel.traceSync( () => { const modelResult = { - allToolExecutionRounds: [], + allToolExecutionRounds: [] as any[], finalResponse, resolvedRequest: { input: @@ -491,7 +491,9 @@ describe("OpenRouter Plugin", () => { }, async getText() { const currentResponse = await modelResult.getInitialResponse(); - const toolResult = await request.tools[0].function.execute( + const toolResult = await ( + request.tools[0].function.execute as any + )( { city: "Vienna" }, { toolCall: { @@ -514,14 +516,14 @@ describe("OpenRouter Plugin", () => { return modelResult; }, - { arguments: [request] }, + { arguments: [request as any] }, ); expect(request.tools[0]).not.toBe(tool); await expect(result.getText()).resolves.toBe("Sunny in Vienna"); expect(request.tools[0]).not.toBe(tool); - const spans = await backgroundLogger.drain(); + const spans = (await backgroundLogger.drain()) as any[]; expect(spans).toHaveLength(4); const callModelSpan = spans.find( (span) => span.span_attributes?.name === "openrouter.callModel", diff --git a/js/src/instrumentation/plugins/pi-coding-agent-plugin.test.ts b/js/src/instrumentation/plugins/pi-coding-agent-plugin.test.ts index c52c7b2ab..50f445e5c 100644 --- a/js/src/instrumentation/plugins/pi-coding-agent-plugin.test.ts +++ b/js/src/instrumentation/plugins/pi-coding-agent-plugin.test.ts @@ -123,7 +123,7 @@ describe("PiCodingAgentPlugin", () => { return stream; }); const unsubscribe = vi.fn(); - const agent = { + const agent: any = { state: { model: anthropicModel(), tools: [bashTool()] }, streamFn: originalStreamFn, subscribe: vi.fn(() => unsubscribe), @@ -211,7 +211,7 @@ describe("PiCodingAgentPlugin", () => { "orchestrion:@earendil-works/pi-coding-agent:AgentSession.prompt", ); let listener: any; - const agent = { + const agent: any = { state: { model: anthropicModel() }, streamFn: vi.fn(), subscribe: vi.fn((nextListener) => { @@ -268,7 +268,7 @@ describe("PiCodingAgentPlugin", () => { "orchestrion:@earendil-works/pi-coding-agent:AgentSession.prompt", ); let listener: any; - const agent = { + const agent: any = { state: { model: anthropicModel() }, streamFn: vi.fn(async () => makeStream(makeAssistantMessage("done"))), subscribe: vi.fn((nextListener) => { @@ -315,7 +315,7 @@ describe("PiCodingAgentPlugin", () => { ); const stream = makeStream(makeAssistantMessage("done")); const originalStreamFn = vi.fn(async () => stream); - const agent = { + const agent: any = { state: { model: anthropicModel() }, streamFn: originalStreamFn, subscribe: vi.fn(() => vi.fn()), @@ -364,7 +364,7 @@ describe("PiCodingAgentPlugin", () => { { partial: finalMessage, type: "start" }, { message: finalMessage, type: "done" }, ]); - const agent = { + const agent: any = { state: { model: anthropicModel() }, streamFn: vi.fn(async () => stream), subscribe: vi.fn(() => vi.fn()), @@ -411,7 +411,7 @@ describe("PiCodingAgentPlugin", () => { const { iterator, stream } = makeIteratorBackedStream([ { partial: finalMessage, type: "start" }, ]); - const agent = { + const agent: any = { state: { model: anthropicModel() }, streamFn: vi.fn(async () => stream), subscribe: vi.fn(() => vi.fn()), @@ -449,7 +449,7 @@ describe("PiCodingAgentPlugin", () => { const { iterator, stream } = makeIteratorBackedStream([ { partial: finalMessage, type: "start" }, ]); - const agent = { + const agent: any = { state: { model: anthropicModel() }, streamFn: vi.fn(async () => stream), subscribe: vi.fn(() => vi.fn()), @@ -492,7 +492,7 @@ describe("PiCodingAgentPlugin", () => { const { iterator, stream } = makeIteratorBackedStream([]); const nextError = new Error("stream next failed"); iterator.next.mockRejectedValueOnce(nextError); - const agent = { + const agent: any = { state: { model: anthropicModel() }, streamFn: vi.fn(async () => stream), subscribe: vi.fn(() => vi.fn()), @@ -536,7 +536,7 @@ describe("PiCodingAgentPlugin", () => { const originalStreamFn = vi.fn(async () => makeStream(makeAssistantMessage("done")), ); - const agent = { + const agent: any = { state: { model: anthropicModel() }, streamFn: originalStreamFn, subscribe: vi.fn((listener) => { @@ -642,7 +642,7 @@ describe("PiCodingAgentPlugin", () => { ); const unsubscribe = vi.fn(); const originalStreamFn = vi.fn(); - const agent = { + const agent: any = { state: { model: anthropicModel() }, streamFn: originalStreamFn, subscribe: vi.fn(() => unsubscribe), @@ -750,7 +750,7 @@ function makeStream(message: ReturnType) { function makeIteratorBackedStream(events: any[]) { const pendingEvents = [...events]; const result = vi.fn(async () => makeAssistantMessage("done")); - const iterator = { + const iterator: any = { next: vi.fn(async () => { const event = pendingEvents.shift(); if (!event) { diff --git a/js/src/instrumentation/plugins/strands-agent-sdk-plugin.test.ts b/js/src/instrumentation/plugins/strands-agent-sdk-plugin.test.ts index abc3d1c0e..6542c432e 100644 --- a/js/src/instrumentation/plugins/strands-agent-sdk-plugin.test.ts +++ b/js/src/instrumentation/plugins/strands-agent-sdk-plugin.test.ts @@ -227,7 +227,7 @@ describe("StrandsAgentSDKPlugin", () => { handlers.start(event); handlers.end(event); - const chunks = []; + const chunks: unknown[] = []; for await (const chunk of stream) { chunks.push(chunk); } diff --git a/js/src/isomorph.ts b/js/src/isomorph.ts index 65876e87a..8a1462ced 100644 --- a/js/src/isomorph.ts +++ b/js/src/isomorph.ts @@ -16,12 +16,12 @@ export interface IsoAsyncLocalStorage { } // eslint-disable-next-line @typescript-eslint/no-explicit-any -export type IsoMessageFunction = ( +type IsoMessageFunction = ( message: M, name: N, ) => void; -export type IsoTransformFunction = (message: M) => S; +type IsoTransformFunction = (message: M) => S; /** * Channel interface matching the shared node:diagnostics_channel and dc-browser API. @@ -224,7 +224,7 @@ class DefaultTracingChannel implements IsoTracingChannel { } } -export interface Common { +interface Common { buildType: | "browser" // deprecated, use /workerd or /edge-light entrypoints for edge environments | "browser-js" // @braintrust/browser package diff --git a/js/src/logger-misc.test.ts b/js/src/logger-misc.test.ts index 7382f1f67..ce25578a5 100644 --- a/js/src/logger-misc.test.ts +++ b/js/src/logger-misc.test.ts @@ -10,7 +10,6 @@ import { BaseAttachment, Attachment, ExternalAttachment, - initDataset, initExperiment, initLogger, NOOP_SPAN, @@ -411,7 +410,7 @@ describe("span.link", () => { }); test("span.link handles missing experiment id", async () => { - const _state = await _exportsForTestingOnly.simulateLoginForTests(); + await _exportsForTestingOnly.simulateLoginForTests(); const experiment = initExperiment("test-experiment"); const span = experiment.startSpan({ name: "test-span" }); span.end(); @@ -425,7 +424,7 @@ describe("span.link", () => { }); test("span.link handles missing project id and name", async () => { - const _state = await _exportsForTestingOnly.simulateLoginForTests(); + await _exportsForTestingOnly.simulateLoginForTests(); const logger = initLogger({}); const span = logger.startSpan({ name: "test-span" }); span.end(); @@ -441,7 +440,7 @@ describe("span.link", () => { }); test("span.link handles playground logs", async () => { - const _state = await _exportsForTestingOnly.simulateLoginForTests(); + await _exportsForTestingOnly.simulateLoginForTests(); const logger = initLogger({}); const span = logger.startSpan({ name: "test-span" }); span.end(); diff --git a/js/src/logger.test.ts b/js/src/logger.test.ts index f4d31e336..ef3f60d5e 100644 --- a/js/src/logger.test.ts +++ b/js/src/logger.test.ts @@ -526,7 +526,7 @@ test.each(initGitMetadataSettingsCases)( try { state.gitMetadataSettings = orgSettings; - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); const getRepoInfo = vi .spyOn(_exportsForTestingOnly.isomorph, "getRepoInfo") .mockResolvedValue(undefined); @@ -569,7 +569,7 @@ test("init forwards dataset _internal_btql to experiment register", async () => const state = await _exportsForTestingOnly.simulateLoginForTests(); try { - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); mockInitGitMetadata(); const datasetFilter = { @@ -649,7 +649,7 @@ test("dataset fetch forwards _internal_btql filter arrays to btql", async () => const state = await _exportsForTestingOnly.simulateLoginForTests(); try { - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); const datasetFilter = { filter: [ @@ -721,7 +721,7 @@ test("initDataset applies bt eval internal BTQL runtime value to eval data", asy globalThis.__bt_eval_internal_btql = { sample: 5 }; try { - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); vi.spyOn(state.appConn(), "post_json").mockResolvedValue({ project: { id: "00000000-0000-0000-0000-000000000001", @@ -758,7 +758,7 @@ test("legacy initDataset applies bt eval internal BTQL runtime value", async () globalThis.__bt_eval_internal_btql = { sample: 5 }; try { - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); vi.spyOn(state.appConn(), "post_json").mockResolvedValue({ project: { id: "00000000-0000-0000-0000-000000000001", @@ -797,7 +797,7 @@ test("initDataset merges bt eval internal BTQL with existing _internal_btql", as }; try { - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); vi.spyOn(state.appConn(), "post_json").mockResolvedValue({ project: { id: "00000000-0000-0000-0000-000000000001", @@ -842,7 +842,7 @@ test("initDataset preserves explicit _internal_btql sample", async () => { }; try { - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); vi.spyOn(state.appConn(), "post_json").mockResolvedValue({ project: { id: "00000000-0000-0000-0000-000000000001", @@ -885,7 +885,7 @@ test("initDataset keeps eval data unchanged without bt eval internal BTQL runtim globalThis.__bt_eval_internal_btql = undefined; try { - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); vi.spyOn(state.appConn(), "post_json").mockResolvedValue({ project: { id: "00000000-0000-0000-0000-000000000001", @@ -919,7 +919,7 @@ test("dataset fetch forwards bt eval internal BTQL runtime value to btql", async globalThis.__bt_eval_internal_btql = { sample: 5 }; try { - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); vi.spyOn(state.appConn(), "post_json").mockResolvedValue({ project: { id: "00000000-0000-0000-0000-000000000001", @@ -970,7 +970,7 @@ test("dataset fetch forwards bt eval internal BTQL runtime value to btql", async test("initDataset prefers version over environment in eval data", async () => { const state = await _exportsForTestingOnly.simulateLoginForTests(); - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); vi.spyOn(state.appConn(), "post_json").mockResolvedValue({ project: { id: "00000000-0000-0000-0000-000000000001", @@ -1001,7 +1001,7 @@ test("initDataset prefers version over environment in eval data", async () => { test("dataset.toEvalData preserves dataset_environment", async () => { const state = await _exportsForTestingOnly.simulateLoginForTests(); - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); vi.spyOn(state.apiConn(), "get_json").mockResolvedValue({ object_version: "123", }); @@ -1034,7 +1034,7 @@ test("dataset.toEvalData preserves dataset_environment", async () => { test("dataset.toEvalData preserves dataset_snapshot_name", async () => { const state = await _exportsForTestingOnly.simulateLoginForTests(); - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); const postJson = vi .spyOn(state.appConn(), "post_json") .mockResolvedValueOnce({ @@ -1127,7 +1127,7 @@ test("experiment.summarize resolves explicit comparison experiment name", async test("dataset.version preserves pinned-version fast path", async () => { const state = await _exportsForTestingOnly.simulateLoginForTests(); - const login = vi.spyOn(state, "login").mockResolvedValue(state); + const login = vi.spyOn(state, "login").mockResolvedValue(state as any); const postJson = vi.spyOn(state.appConn(), "post_json"); const dataset = initDataset({ @@ -1147,7 +1147,7 @@ test("dataset.version preserves pinned-version fast path", async () => { test("dataset.createSnapshot forwards update when requested", async () => { const state = await _exportsForTestingOnly.simulateLoginForTests(); - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); const postJson = vi .spyOn(state.appConn(), "post_json") .mockResolvedValueOnce({ @@ -1204,7 +1204,7 @@ test("dataset.createSnapshot forwards update when requested", async () => { test("dataset.getSnapshot looks up snapshots by name", async () => { const state = await _exportsForTestingOnly.simulateLoginForTests(); - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); const postJson = vi .spyOn(state.appConn(), "post_json") .mockResolvedValueOnce({ @@ -1255,7 +1255,7 @@ test("dataset.getSnapshot looks up snapshots by name", async () => { test("dataset.getSnapshot looks up snapshots by xact id", async () => { const state = await _exportsForTestingOnly.simulateLoginForTests(); - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); const postJson = vi .spyOn(state.appConn(), "post_json") .mockResolvedValueOnce({ @@ -1306,7 +1306,7 @@ test("dataset.getSnapshot looks up snapshots by xact id", async () => { test("dataset.updateSnapshot patches snapshot metadata by id", async () => { const state = await _exportsForTestingOnly.simulateLoginForTests(); - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); const postJson = vi .spyOn(state.appConn(), "post_json") .mockResolvedValueOnce({ @@ -1357,7 +1357,7 @@ test("dataset.updateSnapshot patches snapshot metadata by id", async () => { test("dataset.restorePreview posts restore preview request", async () => { const state = await _exportsForTestingOnly.simulateLoginForTests(); - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); vi.spyOn(state.appConn(), "post_json").mockResolvedValueOnce({ project: { id: "00000000-0000-0000-0000-000000000001", @@ -1404,7 +1404,7 @@ test("dataset.restorePreview posts restore preview request", async () => { test("dataset.restore posts restore request", async () => { const state = await _exportsForTestingOnly.simulateLoginForTests(); - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); vi.spyOn(state.appConn(), "post_json").mockResolvedValueOnce({ project: { id: "00000000-0000-0000-0000-000000000001", @@ -1453,7 +1453,7 @@ test("dataset.restore posts restore request", async () => { test("init keeps plain dataset refs attached to the experiment", async () => { const state = await _exportsForTestingOnly.simulateLoginForTests(); - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); mockInitGitMetadata(); vi.spyOn(state.appConn(), "post_json").mockResolvedValue({ project: { @@ -1489,7 +1489,7 @@ test("init keeps plain dataset refs attached to the experiment", async () => { test("init resolves dataset version from Dataset instances before experiment registration", async () => { const state = await _exportsForTestingOnly.simulateLoginForTests(); - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); mockInitGitMetadata(); const postJson = vi .spyOn(state.appConn(), "post_json") @@ -1549,7 +1549,7 @@ test("init resolves dataset version from Dataset instances before experiment reg test("init resolves dataset environment before experiment registration", async () => { const state = await _exportsForTestingOnly.simulateLoginForTests(); - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); mockInitGitMetadata(); const getJson = vi.spyOn(state.apiConn(), "get_json").mockResolvedValue({ object_version: "123", @@ -1605,7 +1605,7 @@ test("init resolves dataset environment before experiment registration", async ( test("init resolves dataset environment without org_name when orgName is unset", async () => { const state = await _exportsForTestingOnly.simulateLoginForTests(); state.orgName = null; - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); mockInitGitMetadata(); const getJson = vi.spyOn(state.apiConn(), "get_json").mockResolvedValue({ object_version: "123", @@ -1653,7 +1653,7 @@ test("init resolves dataset environment without org_name when orgName is unset", test("init prefers dataset version over environment before experiment registration", async () => { const state = await _exportsForTestingOnly.simulateLoginForTests(); - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); mockInitGitMetadata(); const getJson = vi.spyOn(state.apiConn(), "get_json"); const postJson = vi.spyOn(state.appConn(), "post_json").mockResolvedValue({ @@ -1698,7 +1698,7 @@ test("init prefers dataset version over environment before experiment registrati test("init resolves dataset snapshots before experiment registration", async () => { const state = await _exportsForTestingOnly.simulateLoginForTests(); - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); mockInitGitMetadata(); const postJson = vi .spyOn(state.appConn(), "post_json") @@ -1757,7 +1757,7 @@ test("init resolves dataset snapshots before experiment registration", async () test("init surfaces dataset environment lookup errors instead of falling back to latest", async () => { const state = await _exportsForTestingOnly.simulateLoginForTests(); - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); mockInitGitMetadata(); vi.spyOn(state.apiConn(), "get_json").mockRejectedValue( new Error("environment lookup failed"), @@ -1860,7 +1860,7 @@ describe("loader version precedence", () => { beforeEach(async () => { state = await _exportsForTestingOnly.simulateLoginForTests(); - vi.spyOn(state, "login").mockResolvedValue(state); + vi.spyOn(state, "login").mockResolvedValue(state as any); getJson = vi.spyOn(state.apiConn(), "get_json"); }); @@ -2403,7 +2403,7 @@ describe("wrapTraced generator support", () => { } }); - const results = []; + const results: number[] = []; for (const value of tracedSyncGen(3)) { results.push(value); } @@ -2430,7 +2430,7 @@ describe("wrapTraced generator support", () => { throw new Error("Generator failed"); }); - const results = []; + const results: string[] = []; expect(() => { for (const value of failingGenerator()) { results.push(value); @@ -2460,7 +2460,7 @@ describe("wrapTraced generator support", () => { } }); - const results = []; + const results: number[] = []; for await (const value of tracedAsyncGen(3)) { results.push(value); } @@ -2488,7 +2488,7 @@ describe("wrapTraced generator support", () => { }, ); - const results = []; + const results: number[] = []; await expect(async () => { for await (const value of failingAsyncGenerator()) { results.push(value); @@ -2755,7 +2755,7 @@ describe("wrapTraced generator support", () => { const tasks = []; for (let i = 0; i < numLoops; i++) { tasks.push( - new Promise((resolve) => { + new Promise((resolve) => { setTimeout(() => resolve(i * 2), 1); }), ); @@ -2983,11 +2983,10 @@ test("attachment with readable path returns data", async () => { describe("sensitive data redaction", () => { let logger: any; let state: BraintrustState; - let memoryLogger: any; beforeEach(async () => { state = await _exportsForTestingOnly.simulateLoginForTests(); - memoryLogger = _exportsForTestingOnly.useTestBackgroundLogger(); + _exportsForTestingOnly.useTestBackgroundLogger(); logger = initLogger({ projectName: "test", projectId: "test-id" }); }); @@ -3031,7 +3030,9 @@ describe("sensitive data redaction", () => { test("BraintrustState redacts loginToken and connections", () => { // Test custom inspect method - const inspectResult = state[Symbol.for("nodejs.util.inspect.custom")](); + const inspectResult = (state as any)[ + Symbol.for("nodejs.util.inspect.custom") + ](); expect(inspectResult).toContain("BraintrustState"); expect(inspectResult).toContain("orgId:"); expect(inspectResult).toContain("orgName:"); diff --git a/js/src/logger.ts b/js/src/logger.ts index e9cfdcce6..d99f2e04d 100644 --- a/js/src/logger.ts +++ b/js/src/logger.ts @@ -6730,7 +6730,6 @@ interface ResolvedSpanIds { /** * Resolve all span IDs (span_id, root_span_id, span_parents) from explicit values, parent info, or context. - * Matches the Python implementation in logger.py::_resolve_span_ids. * * @param spanId - Optional explicit span_id (from public API) * @param parentSpanIds - Optional explicit parent span IDs (from parent string or parent span) @@ -7325,6 +7324,7 @@ export class Dataset< ) as WithTransactionId>, _internal_btql, ); + void this.__braintrust_dataset_marker; this.lazyMetadata = lazyMetadata; this.lazyPinnedVersion = pinState?.lazyPinnedVersion; this.pinnedEnvironment = pinState?.pinnedEnvironment; @@ -8118,7 +8118,9 @@ export class Prompt< private metadata: PromptRowWithId | PromptSessionEvent, private defaults: DefaultPromptArgs, private noTrace: boolean, - ) {} + ) { + void this.__braintrust_prompt_marker; + } public get id(): HasId extends true ? string : string | undefined { // eslint-disable-next-line @typescript-eslint/consistent-type-assertions @@ -8462,7 +8464,9 @@ export class RemoteEvalParameters< > { private readonly __braintrust_parameters_marker = true; - constructor(private metadata: ParametersRow) {} + constructor(private metadata: ParametersRow) { + void this.__braintrust_parameters_marker; + } public get id(): HasId extends true ? string : string | undefined { // eslint-disable-next-line @typescript-eslint/consistent-type-assertions @@ -8751,5 +8755,6 @@ export const _exportsForTestingOnly = { isAsyncGeneratorFunction, resetIdGenStateForTests, validateTags, - isomorph: iso, // Expose isomorph for build type detection + // eslint-disable-next-line @typescript-eslint/no-explicit-any + isomorph: iso as any, // Expose isomorph for build type detection }; diff --git a/js/src/masking.test.ts b/js/src/masking.test.ts index cb4c977f8..b11605046 100644 --- a/js/src/masking.test.ts +++ b/js/src/masking.test.ts @@ -1,10 +1,7 @@ -import { vi, expect, test, describe, beforeEach, afterEach } from "vitest"; +import { expect, test, describe, beforeEach, afterEach } from "vitest"; import { _exportsForTestingOnly, - init, initLogger, - initExperiment, - initDataset, wrapTraced, currentSpan, setMaskingFunction, @@ -315,7 +312,7 @@ describe("masking functionality", () => { if (key === "secrets" && Array.isArray(value)) { masked[key] = value.map(() => "REDACTED"); } else if (key === "tokens" && typeof value === "object") { - masked[key] = Object.keys(value).reduce((acc: any, k) => { + masked[key] = Object.keys(value ?? {}).reduce((acc: any, k) => { acc[k] = "REDACTED"; return acc; }, {}); @@ -499,7 +496,7 @@ describe("masking functionality", () => { for (const [key, value] of Object.entries(data)) { if (key === "secret" && typeof value === "string") { // Another type of error - const result = 1 / 0; // This will be Infinity, not an error + 1 / 0; // This will be Infinity, not an error throw new Error("Division by zero error"); } else if (key === "complex" && Array.isArray(value)) { // Try to access non-existent index diff --git a/js/src/parameters.test.ts b/js/src/parameters.test.ts index 8c0426f6e..b22953561 100644 --- a/js/src/parameters.test.ts +++ b/js/src/parameters.test.ts @@ -138,7 +138,7 @@ test("remote prompt parameter is rehydrated correctly", async () => { const validated = await validateParameters({}, parameters); - expect(validated.main.build({ input: "test input" })).toMatchObject({ + expect((validated.main as any).build({ input: "test input" })).toMatchObject({ messages: [{ role: "user", content: "test input" }], model: "gpt-5-mini", }); diff --git a/js/src/prompt-cache/parameters-cache.ts b/js/src/prompt-cache/parameters-cache.ts index 75fad987a..57d637983 100644 --- a/js/src/prompt-cache/parameters-cache.ts +++ b/js/src/prompt-cache/parameters-cache.ts @@ -2,7 +2,7 @@ import { RemoteEvalParameters } from "../logger"; import { LRUCache } from "./lru-cache"; import { DiskCache } from "./disk-cache"; -export interface ParametersKey { +interface ParametersKey { slug?: string; version?: string; projectId?: string; diff --git a/js/src/prompt-cache/prompt-cache.test.ts b/js/src/prompt-cache/prompt-cache.test.ts index e8716f268..615763c5e 100644 --- a/js/src/prompt-cache/prompt-cache.test.ts +++ b/js/src/prompt-cache/prompt-cache.test.ts @@ -379,7 +379,7 @@ describe("PromptCache", () => { // Modify the prompt stored by ID const modifiedPrompt = new Prompt( { - ...testPrompt.metadata, + ...(testPrompt as any).metadata, name: "modified-prompt", }, {}, diff --git a/js/src/runtime-async-local-storage.ts b/js/src/runtime-async-local-storage.ts index a903eb135..05166cf3b 100644 --- a/js/src/runtime-async-local-storage.ts +++ b/js/src/runtime-async-local-storage.ts @@ -1,6 +1,6 @@ import type { AsyncLocalStorage as NodeAsyncLocalStorage } from "node:async_hooks"; -export type RuntimeAsyncLocalStorageConstructor = new < +type RuntimeAsyncLocalStorageConstructor = new < T, >() => NodeAsyncLocalStorage; diff --git a/js/src/stackutil.ts b/js/src/stackutil.ts index 71d9ae9ba..13933f8bf 100644 --- a/js/src/stackutil.ts +++ b/js/src/stackutil.ts @@ -1,6 +1,6 @@ import iso, { CallerLocation } from "./isomorph"; -export interface StackTraceEntry { +interface StackTraceEntry { functionName: string; fileName: string; lineNo: number; diff --git a/js/src/template/renderer.ts b/js/src/template/renderer.ts index 4fc34203c..e9b450600 100644 --- a/js/src/template/renderer.ts +++ b/js/src/template/renderer.ts @@ -1,7 +1,5 @@ import { getTemplateRenderer, type TemplateFormat } from "./registry"; -export type { TemplateFormat } from "./registry"; - export function isTemplateFormat(v: unknown): v is TemplateFormat { return v === "mustache" || v === "nunjucks" || v === "none"; } diff --git a/js/src/trace.ts b/js/src/trace.ts index 5c0547896..58fe258be 100644 --- a/js/src/trace.ts +++ b/js/src/trace.ts @@ -1,7 +1,7 @@ import { BraintrustState, ObjectFetcher, WithTransactionId } from "./logger"; import { invoke } from "./functions/invoke"; -export interface TraceOptions { +interface TraceOptions { objectType: "experiment" | "project_logs" | "playground_logs"; objectId: string; rootSpanId: string; @@ -20,9 +20,9 @@ export class SpanFetcher extends ObjectFetcher { constructor( objectType: "experiment" | "project_logs" | "playground_logs", private readonly _objectId: string, - private readonly rootSpanId: string, + rootSpanId: string, private readonly _state: BraintrustState, - private readonly spanTypeFilter?: string[], + spanTypeFilter?: string[], includeScorers = false, brainstoreRealtime = true, ) { @@ -122,7 +122,7 @@ export interface SpanData { export type SpanFetchFn = ( spanType: string[] | undefined, ) => Promise; -export type SpanFetchWithOptionsFn = ( +type SpanFetchWithOptionsFn = ( spanType: string[] | undefined, includeScorers: boolean, ) => Promise; diff --git a/js/src/typed-instrumentation-helpers.ts b/js/src/typed-instrumentation-helpers.ts index 9cb44cdcb..b1c588320 100644 --- a/js/src/typed-instrumentation-helpers.ts +++ b/js/src/typed-instrumentation-helpers.ts @@ -1,7 +1,7 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any -export type AnyFn = (this: any, ...args: any[]) => any; +type AnyFn = (this: any, ...args: any[]) => any; -export type TypedApplyProxyHandler = Omit< +type TypedApplyProxyHandler = Omit< ProxyHandler, "apply" > & { diff --git a/js/src/vendor-sdk-types/ai-sdk-common.ts b/js/src/vendor-sdk-types/ai-sdk-common.ts index f2cb9311f..6aead9821 100644 --- a/js/src/vendor-sdk-types/ai-sdk-common.ts +++ b/js/src/vendor-sdk-types/ai-sdk-common.ts @@ -4,7 +4,7 @@ * These are intentionally small and only model the surface Braintrust reads. */ -export interface AISDKTokenBucket { +interface AISDKTokenBucket { total?: number; cacheRead?: number; cacheWrite?: number; @@ -50,13 +50,13 @@ export interface AISDKUsage { completion_audio_tokens?: number; } -export interface AISDKGatewayRouting { +interface AISDKGatewayRouting { resolvedProvider?: string; finalProvider?: string; resolvedProviderApiModelId?: string; } -export interface AISDKGatewayMetadata { +interface AISDKGatewayMetadata { routing?: AISDKGatewayRouting; cost?: number | string; marketCost?: number | string; @@ -72,7 +72,7 @@ export interface AISDKStepResult { [key: string]: unknown; } -export interface AISDKGeneratedFile { +interface AISDKGeneratedFile { mediaType?: string; base64?: string; uint8Array?: Uint8Array; diff --git a/js/src/vendor-sdk-types/ai-sdk-v7-telemetry.ts b/js/src/vendor-sdk-types/ai-sdk-v7-telemetry.ts index 49b621f0d..569356f48 100644 --- a/js/src/vendor-sdk-types/ai-sdk-v7-telemetry.ts +++ b/js/src/vendor-sdk-types/ai-sdk-v7-telemetry.ts @@ -12,7 +12,7 @@ export interface AISDKV7TelemetryOptions { functionId?: string; } -export interface AISDKV7ModelInfo { +interface AISDKV7ModelInfo { provider?: string; modelId?: string; } @@ -98,7 +98,7 @@ export interface AISDKV7RerankEndEvent [key: string]: unknown; } -export interface AISDKV7ToolCall { +interface AISDKV7ToolCall { toolCallId?: string; toolName?: string; input?: unknown; @@ -112,7 +112,7 @@ export interface AISDKV7ToolExecutionStartEvent extends AISDKV7TelemetryOptions [key: string]: unknown; } -export interface AISDKV7ToolOutput { +interface AISDKV7ToolOutput { type?: "tool-result" | "tool-error" | string; output?: unknown; error?: unknown; diff --git a/js/src/vendor-sdk-types/ai-sdk.ts b/js/src/vendor-sdk-types/ai-sdk.ts index 6bc261a08..ab10ee211 100644 --- a/js/src/vendor-sdk-types/ai-sdk.ts +++ b/js/src/vendor-sdk-types/ai-sdk.ts @@ -5,30 +5,19 @@ import type { AISDKEmbedFunction, AISDKEmbedParams, AISDKEmbeddingResult, - AISDKGeneratedFile, AISDKGenerateFunction, AISDKLanguageModel, - AISDKMessage, AISDKModel, AISDKModelStreamChunk, - AISDKNamespaceBase, AISDKOutputObject, AISDKOutputResponseFormat, - AISDKProviderMetadata, - AISDKProviderResolver, - AISDKRerankEntry, AISDKRerankFunction, AISDKRerankParams, - AISDKRerankResponse, AISDKRerankResult, AISDKResult, - AISDKStepResult, AISDKStreamFunction, - AISDKSyncOutputObject, - AISDKAsyncOutputObject, AISDKTool, AISDKTools, - AISDKTokenBucket, AISDKUsage, } from "./ai-sdk-common"; import type { AISDKV3 } from "./ai-sdk-v3"; @@ -47,33 +36,22 @@ export type AISDK = AISDKVersion["sdk"]; export type { AISDKAgentClass, AISDKAgentInstance, - AISDKAsyncOutputObject, AISDKCallParams, AISDKEmbedFunction, AISDKEmbedParams, AISDKEmbeddingResult, - AISDKGeneratedFile, AISDKGenerateFunction, AISDKLanguageModel, - AISDKMessage, AISDKModel, AISDKModelStreamChunk, - AISDKNamespaceBase, AISDKOutputObject, AISDKOutputResponseFormat, - AISDKProviderMetadata, - AISDKProviderResolver, - AISDKRerankEntry, AISDKRerankFunction, AISDKRerankParams, - AISDKRerankResponse, AISDKRerankResult, AISDKResult, - AISDKStepResult, AISDKStreamFunction, - AISDKSyncOutputObject, AISDKTool, AISDKTools, - AISDKTokenBucket, AISDKUsage, }; diff --git a/js/src/vendor-sdk-types/anthropic.ts b/js/src/vendor-sdk-types/anthropic.ts index 5069c0f10..316b1dedf 100644 --- a/js/src/vendor-sdk-types/anthropic.ts +++ b/js/src/vendor-sdk-types/anthropic.ts @@ -33,7 +33,7 @@ export interface AnthropicAPIPromise extends Promise { withResponse(): Promise>; } -export interface AnthropicWithResponse { +interface AnthropicWithResponse { data: T; } @@ -128,7 +128,7 @@ export interface AnthropicServerToolUseContentBlock { input: Record; } -export interface AnthropicWebSearchResultContentBlock { +interface AnthropicWebSearchResultContentBlock { type: string; [key: string]: unknown; } diff --git a/js/src/vendor-sdk-types/cursor-sdk.ts b/js/src/vendor-sdk-types/cursor-sdk.ts index a8bf1bb70..b11c0f630 100644 --- a/js/src/vendor-sdk-types/cursor-sdk.ts +++ b/js/src/vendor-sdk-types/cursor-sdk.ts @@ -5,11 +5,6 @@ * users and should only cover fields we read, wrap, or log. */ -export interface CursorSDKModule { - Agent: CursorSDKAgentClass; - [key: string]: unknown; -} - export interface CursorSDKAgentClass { create(options: CursorSDKAgentOptions): Promise; resume( @@ -102,7 +97,7 @@ export type CursorSDKImage = [key: string]: unknown; }; -export interface CursorSDKImageDimension { +interface CursorSDKImageDimension { width?: number; height?: number; } @@ -230,12 +225,12 @@ export interface CursorSDKRequestMessage { request_id?: string; } -export interface CursorSDKTextBlock { +interface CursorSDKTextBlock { type?: "text"; text?: string; } -export interface CursorSDKToolUseBlock { +interface CursorSDKToolUseBlock { type?: "tool_use"; id?: string; name?: string; diff --git a/js/src/vendor-sdk-types/google-adk.ts b/js/src/vendor-sdk-types/google-adk.ts index d7bfda393..20b82e874 100644 --- a/js/src/vendor-sdk-types/google-adk.ts +++ b/js/src/vendor-sdk-types/google-adk.ts @@ -112,7 +112,7 @@ export interface GoogleADKContent { parts?: GoogleADKPart[]; } -export interface GoogleADKPart { +interface GoogleADKPart { text?: string; thought?: boolean; functionCall?: { @@ -142,18 +142,3 @@ export interface GoogleADKUsageMetadata { cachedContentTokenCount?: number; thoughtsTokenCount?: number; } - -// ---- Module shape ---- - -export interface GoogleADKModule { - Runner: GoogleADKRunnerConstructor; - InMemoryRunner: GoogleADKInMemoryRunnerConstructor; - LlmAgent: new (config: unknown) => GoogleADKLlmAgent; - Agent: new (config: unknown) => GoogleADKLlmAgent; - BaseAgent: new (config: unknown) => GoogleADKBaseAgent; - SequentialAgent: new (config: unknown) => GoogleADKBaseAgent; - ParallelAgent: new (config: unknown) => GoogleADKBaseAgent; - LoopAgent: new (config: unknown) => GoogleADKBaseAgent; - FunctionTool: new (config: unknown) => GoogleADKBaseTool; - [key: string]: unknown; -} diff --git a/js/src/vendor-sdk-types/groq.ts b/js/src/vendor-sdk-types/groq.ts index a59a72019..ecf3252ff 100644 --- a/js/src/vendor-sdk-types/groq.ts +++ b/js/src/vendor-sdk-types/groq.ts @@ -3,7 +3,6 @@ import type { OpenAIChatChoice, OpenAIChatCompletionChunk, OpenAIChatCreateParams, - OpenAIChatLogprobs, OpenAIChatStream, OpenAIEmbeddingCreateParams, OpenAIUsage, @@ -29,8 +28,6 @@ export interface GroqChatCompletion { [key: string]: unknown; } -export type GroqChatChoice = OpenAIChatChoice; -export type GroqChatLogprobs = OpenAIChatLogprobs; export type GroqChatCompletionChunk = OpenAIChatCompletionChunk & { usage?: GroqUsage; }; @@ -50,7 +47,7 @@ export interface GroqEmbeddingResponse { [key: string]: unknown; } -export interface GroqTranscriptionCreateParams { +interface GroqTranscriptionCreateParams { file?: unknown; language?: string | null; model: string; @@ -62,7 +59,7 @@ export interface GroqTranscriptionCreateParams { [key: string]: unknown; } -export interface GroqTranscription { +interface GroqTranscription { text?: string; [key: string]: unknown; } @@ -85,7 +82,7 @@ export interface GroqEmbeddings { ) => OpenAIAPIPromise; } -export interface GroqAudioTranscriptions { +interface GroqAudioTranscriptions { create: ( params: GroqTranscriptionCreateParams, options?: unknown, diff --git a/js/src/vendor-sdk-types/huggingface.ts b/js/src/vendor-sdk-types/huggingface.ts index 1b4c46c07..aad5073e9 100644 --- a/js/src/vendor-sdk-types/huggingface.ts +++ b/js/src/vendor-sdk-types/huggingface.ts @@ -100,7 +100,7 @@ export interface HuggingFaceUsage { [key: string]: unknown; } -export interface HuggingFaceChatMessage { +interface HuggingFaceChatMessage { role?: string; content?: string | null | unknown[]; tool_calls?: unknown; diff --git a/js/src/vendor-sdk-types/langchain.ts b/js/src/vendor-sdk-types/langchain.ts index 904b1030a..a4ffdc909 100644 --- a/js/src/vendor-sdk-types/langchain.ts +++ b/js/src/vendor-sdk-types/langchain.ts @@ -6,8 +6,6 @@ export type LangChainSerialized = { name?: string; }; -export type LangChainRunnableConfig = Record; - export type LangChainCallbackManager = { handlers?: unknown[]; addHandler?: (handler: unknown, inherit?: boolean) => void; diff --git a/js/src/vendor-sdk-types/openai-codex.ts b/js/src/vendor-sdk-types/openai-codex.ts index 3f34cde3e..b422c666a 100644 --- a/js/src/vendor-sdk-types/openai-codex.ts +++ b/js/src/vendor-sdk-types/openai-codex.ts @@ -5,12 +5,6 @@ * users and should only cover fields we read, wrap, or log. */ -export interface OpenAICodexSDKModule { - Codex: OpenAICodexClass; - Thread?: OpenAICodexThreadClass; - [key: string]: unknown; -} - export interface OpenAICodexClass { new (options?: OpenAICodexOptions): OpenAICodexClient; [key: string]: unknown; @@ -25,11 +19,6 @@ export interface OpenAICodexClient { [key: string]: unknown; } -export interface OpenAICodexThreadClass { - new (...args: unknown[]): OpenAICodexThread; - [key: string]: unknown; -} - export interface OpenAICodexThread { readonly id?: string | null; run( @@ -51,14 +40,14 @@ export interface OpenAICodexOptions { env?: Record; } -export type OpenAICodexConfigValue = +type OpenAICodexConfigValue = | string | number | boolean | OpenAICodexConfigValue[] | OpenAICodexConfigObject; -export interface OpenAICodexConfigObject { +interface OpenAICodexConfigObject { [key: string]: OpenAICodexConfigValue; } diff --git a/js/src/vendor-sdk-types/openai-common.ts b/js/src/vendor-sdk-types/openai-common.ts index dafa95b4e..d2dca2323 100644 --- a/js/src/vendor-sdk-types/openai-common.ts +++ b/js/src/vendor-sdk-types/openai-common.ts @@ -58,13 +58,13 @@ export interface OpenAIUsage { [key: string]: number | Record | undefined; } -export interface OpenAIChatToolFunction { +interface OpenAIChatToolFunction { arguments: string; name?: string; [key: string]: unknown; } -export interface OpenAIChatToolCall { +interface OpenAIChatToolCall { id?: string; type?: string; function: OpenAIChatToolFunction; @@ -107,7 +107,7 @@ export interface OpenAIChatCompletion { [key: string]: unknown; } -export interface OpenAIChatDelta { +interface OpenAIChatDelta { role?: string; content?: string; refusal?: string; diff --git a/js/src/vendor-sdk-types/openai.ts b/js/src/vendor-sdk-types/openai.ts index 231d6300e..cdbb8a2d6 100644 --- a/js/src/vendor-sdk-types/openai.ts +++ b/js/src/vendor-sdk-types/openai.ts @@ -11,7 +11,6 @@ import type { OpenAIModerationResponse, OpenAIResponse, OpenAIResponseCompactParams, - OpenAIResponseCompletedEvent, OpenAIResponseCreateParams, OpenAIResponseStreamEvent, } from "./openai-common"; @@ -39,7 +38,6 @@ export type { OpenAIModerationResponse, OpenAIResponse, OpenAIResponseCompactParams, - OpenAIResponseCompletedEvent, OpenAIResponseCreateParams, OpenAIResponseStreamEvent, }; diff --git a/js/src/vendor-sdk-types/pi-coding-agent.ts b/js/src/vendor-sdk-types/pi-coding-agent.ts index 74364f67d..13df2a1b9 100644 --- a/js/src/vendor-sdk-types/pi-coding-agent.ts +++ b/js/src/vendor-sdk-types/pi-coding-agent.ts @@ -156,7 +156,7 @@ export interface PiUserMessage { [key: string]: unknown; } -export type PiUserContent = PiTextContent | PiImageContent; +type PiUserContent = PiTextContent | PiImageContent; export interface PiTextContent { type: "text"; diff --git a/js/src/wrappers/ai-sdk/ai-sdk.test.ts b/js/src/wrappers/ai-sdk/ai-sdk.test.ts index cc21d77a4..cc07edbdd 100644 --- a/js/src/wrappers/ai-sdk/ai-sdk.test.ts +++ b/js/src/wrappers/ai-sdk/ai-sdk.test.ts @@ -17,7 +17,6 @@ import { openai } from "@ai-sdk/openai"; import { _exportsForTestingOnly, initLogger, - Logger, TestBackgroundLogger, } from "../../logger"; import { wrapAISDK, wrapAgentClass } from "./ai-sdk"; @@ -41,7 +40,6 @@ test("ai sdk is installed", () => { describe("ai sdk client unit tests", TEST_SUITE_OPTIONS, () => { let wrappedAI: typeof ai; let backgroundLogger: TestBackgroundLogger; - let _logger: Logger; beforeAll(async () => { await _exportsForTestingOnly.simulateLoginForTests(); @@ -50,7 +48,7 @@ describe("ai sdk client unit tests", TEST_SUITE_OPTIONS, () => { beforeEach(() => { backgroundLogger = _exportsForTestingOnly.useTestBackgroundLogger(); wrappedAI = wrapAISDK(ai); - _logger = initLogger({ + initLogger({ projectName: "ai-sdk.test.ts", projectId: "test-project-id", }); @@ -1181,7 +1179,7 @@ describe("ai sdk client unit tests", TEST_SUITE_OPTIONS, () => { }; const paths = ["request.body", "response.body"]; - const result = omit(testObj, paths); + const result = omit(testObj, paths) as any; // Root-level body should NOT be omitted expect(result.body).toBe("This should NOT be omitted"); @@ -1212,7 +1210,7 @@ describe("ai sdk client unit tests", TEST_SUITE_OPTIONS, () => { }; const paths = ["a.b.c.d", "x.y.z", "a.nonexistent"]; - const result = omit(testObj, paths); + const result = omit(testObj, paths) as any; // Non-existent paths should not affect the output expect(result).toEqual({ @@ -1252,7 +1250,7 @@ describe("ai sdk client unit tests", TEST_SUITE_OPTIONS, () => { }; const paths = ["request.body", "response.body"]; - const result = omit(testObj, paths); + const result = omit(testObj, paths) as any; // request.body doesn't exist, so request should be unchanged expect(result.request).toEqual({ @@ -1272,7 +1270,7 @@ describe("ai sdk client unit tests", TEST_SUITE_OPTIONS, () => { test("omit function handles root-level primitives", () => { const obj = { a: { b: 2 }, c: 3, d: 4 }; - const result = omit(obj, ["a.b", "c"]); + const result = omit(obj, ["a.b", "c"]) as any; expect(result).toEqual({ a: { b: "" }, @@ -1289,7 +1287,7 @@ describe("ai sdk client unit tests", TEST_SUITE_OPTIONS, () => { }, }; - const result = omit(testObj, ["items", "nested.arr"]); + const result = omit(testObj, ["items", "nested.arr"]) as any; expect(result.items).toBe(""); expect(result.nested.arr).toBe(""); @@ -1309,7 +1307,7 @@ describe("ai sdk client unit tests", TEST_SUITE_OPTIONS, () => { key3: "value3", }; - const result = omit(testObj, ["key1", "key3"]); + const result = omit(testObj, ["key1", "key3"]) as any; expect(result.key1).toBe(""); expect(result.key2).toEqual({ nested: "value2" }); @@ -1332,7 +1330,7 @@ describe("ai sdk client unit tests", TEST_SUITE_OPTIONS, () => { "boolean", "nullValue", "obj.nested", - ]); + ]) as any; expect(result.string).toBe(""); expect(result.number).toBe(""); @@ -1347,7 +1345,7 @@ describe("ai sdk client unit tests", TEST_SUITE_OPTIONS, () => { a: [{ b: 1 }, { b: 2 }, { b: 3 }], }; - const result = omit(testObj, ["a[].b"]); + const result = omit(testObj, ["a[].b"]) as any; expect(result.a).toEqual([ { b: "" }, @@ -1521,7 +1519,7 @@ describe("ai sdk client unit tests", TEST_SUITE_OPTIONS, () => { return; } - const AgentClass = wrappedAI.Agent || wrappedAI.Experimental_Agent; + const AgentClass = (wrappedAI.Agent || wrappedAI.Experimental_Agent) as any; const model = openai(TEST_MODEL); // Create a custom Agent subclass @@ -1531,7 +1529,7 @@ describe("ai sdk client unit tests", TEST_SUITE_OPTIONS, () => { } } - const agent = new CustomAgent({ + const agent = new (CustomAgent as any)({ model, system: "You are a helpful assistant.", }); @@ -1555,7 +1553,7 @@ describe("ai sdk client unit tests", TEST_SUITE_OPTIONS, () => { expect(result.text.toLowerCase()).toContain("hello"); // Verify tracing still works with proper span structure - const spans = await backgroundLogger.drain(); + const spans = (await backgroundLogger.drain()) as any[]; expect(spans.length).toBeGreaterThanOrEqual(1); const span = spans[0]; @@ -2349,6 +2347,7 @@ describe("ai sdk client unit tests", TEST_SUITE_OPTIONS, () => { }); for await (const chunk of stream.textStream) { + void chunk; } const spans = (await backgroundLogger.drain()) as any[]; @@ -2454,6 +2453,7 @@ describe("ai sdk client unit tests", TEST_SUITE_OPTIONS, () => { }); for await (const chunk of stream.textStream) { + void chunk; } const spans = (await backgroundLogger.drain()) as any[]; @@ -2913,7 +2913,7 @@ describe("extractTokenMetrics", () => { }); // Every value should be a number or not present (undefined) - for (const [key, value] of Object.entries(result)) { + for (const value of Object.values(result)) { expect(typeof value === "number" || value === undefined).toBe(true); } }); @@ -3013,7 +3013,7 @@ describe("wrapAISDK with ES module namespace objects", () => { // Simulate an ES module namespace object with non-configurable properties // This mimics what happens in strict ESM environments - const mockAISDK = {}; + const mockAISDK: any = {}; // Define non-configurable properties like ES module namespaces have Object.defineProperty(mockAISDK, "generateText", { @@ -3049,7 +3049,7 @@ describe("wrapAISDK with ES module namespace objects", () => { test("prototype chain approach preserves all properties including non-enumerable", () => { // Simulate an ES module namespace object with both enumerable and non-enumerable properties - const mockAISDK = {}; + const mockAISDK: any = {}; Object.defineProperty(mockAISDK, "generateText", { value: async () => ({ text: "mock" }), @@ -3079,7 +3079,7 @@ describe("wrapAISDK with ES module namespace objects", () => { expect("hiddenProperty" in spreadSDK).toBe(false); // Lost! // Approach 2: Prototype chain (preserves everything) - const protoSDK = Object.setPrototypeOf({}, mockAISDK); + const protoSDK: any = Object.setPrototypeOf({}, mockAISDK); expect("generateText" in protoSDK).toBe(true); expect("hiddenProperty" in protoSDK).toBe(true); // Preserved! expect(protoSDK.hiddenProperty).toBe("secret"); @@ -3117,7 +3117,7 @@ describe("wrapAISDK with ES module namespace objects", () => { }).not.toThrow(); // ModuleRecord-like object (strict ESM environments) - const moduleRecord = {}; + const moduleRecord: any = {}; Object.defineProperty(moduleRecord, "generateText", { value: async () => ({ text: "mock" }), writable: false, @@ -3141,7 +3141,7 @@ describe("wrapAISDK with ES module namespace objects", () => { test("detects objects with constructor.name === 'Module'", () => { // Create a mock object that looks like a Module class Module {} - const mockModule = new Module(); + const mockModule: any = new Module(); // Add some properties Object.defineProperty(mockModule, "generateText", { diff --git a/js/src/wrappers/anthropic-no-install.test.ts b/js/src/wrappers/anthropic-no-install.test.ts index ce9742a1e..2b7568f00 100644 --- a/js/src/wrappers/anthropic-no-install.test.ts +++ b/js/src/wrappers/anthropic-no-install.test.ts @@ -6,7 +6,7 @@ test("wrapAnthropic works even if not installed", () => { expect(wrapAnthropic).toBeInstanceOf(Function); try { - const Anthropic = require("@anthropic-ai/sdk"); + require("@anthropic-ai/sdk"); } catch (e) { // anthropic should not be installed when this test runs // so make sure it's a no-op diff --git a/js/src/wrappers/bedrock-runtime.test.ts b/js/src/wrappers/bedrock-runtime.test.ts index 233287bdb..e2a8d606a 100644 --- a/js/src/wrappers/bedrock-runtime.test.ts +++ b/js/src/wrappers/bedrock-runtime.test.ts @@ -176,7 +176,7 @@ describe("bedrock runtime wrapper", () => { modelId: "us.amazon.nova-lite-v1:0", }), ); - for await (const _chunk of response.stream) { + for await (const _chunk of (response as any).stream) { // Consume the stream so chunk aggregation runs. } diff --git a/js/src/wrappers/cohere.test.ts b/js/src/wrappers/cohere.test.ts index b5a473a70..5c585b948 100644 --- a/js/src/wrappers/cohere.test.ts +++ b/js/src/wrappers/cohere.test.ts @@ -62,7 +62,7 @@ describe("cohere wrapper", () => { }, text: "OK", })), - }); + } as any) as any; await client.chat({ message: "Reply with exactly OK.", @@ -115,7 +115,7 @@ describe("cohere wrapper", () => { const client = wrapCohere({ chatStream: vi.fn(async () => stream()), - }); + } as any) as any; const chunks: unknown[] = []; const result = await client.chatStream({ @@ -174,7 +174,7 @@ describe("cohere wrapper", () => { ); const client = wrapCohere({ chatStream: vi.fn(() => rawPromise), - }); + } as any) as any; const resultPromise = client.chatStream({ message: "Say OK", @@ -220,7 +220,7 @@ describe("cohere wrapper", () => { }, ], })), - }); + } as any) as any; await client.embed({ inputType: "search_document", @@ -290,7 +290,7 @@ describe("cohere wrapper", () => { const client = wrapCohere({ chat: vi.fn(), v2: rawV2Client, - }); + } as any) as any; expect(client.v2).toBe(client.v2); diff --git a/js/src/wrappers/cursor-sdk.test.ts b/js/src/wrappers/cursor-sdk.test.ts index 28ef5a0fe..c238fba96 100644 --- a/js/src/wrappers/cursor-sdk.test.ts +++ b/js/src/wrappers/cursor-sdk.test.ts @@ -47,7 +47,7 @@ describe("wrapCursorSDK", () => { }, }; - const wrapped = wrapCursorSDK(sdk); + const wrapped = wrapCursorSDK(sdk as any) as any; const created = await wrapped.Agent.create({ local: { cwd: "/tmp/repo" } }); const result = await created.send("hello", { onDelta: vi.fn(), @@ -81,7 +81,7 @@ describe("wrapCursorSDK", () => { }, }; - const wrapped = wrapCursorSDK(sdk); + const wrapped = wrapCursorSDK(sdk as any) as any; const agent = await wrapped.Agent.resume("agent-2"); await expect(agent.send("hello")).resolves.toMatchObject({ id: "run-1" }); @@ -97,7 +97,7 @@ describe("wrapCursorSDK", () => { }, }; - const wrapped = wrapCursorSDK(sdk); + const wrapped = wrapCursorSDK(sdk as any) as any; await expect(wrapped.Agent.prompt("hello")).resolves.toMatchObject({ result: "hello", }); @@ -117,7 +117,7 @@ describe("wrapCursorSDK", () => { writable: false, }); - const wrapped = wrapCursorSDK(sdk as { Agent: typeof Agent }); + const wrapped = wrapCursorSDK(sdk as any) as any; await expect(wrapped.Agent.prompt("hello")).resolves.toMatchObject({ status: "finished", diff --git a/js/src/wrappers/cursor-sdk.ts b/js/src/wrappers/cursor-sdk.ts index a35d0f090..e20f41fba 100644 --- a/js/src/wrappers/cursor-sdk.ts +++ b/js/src/wrappers/cursor-sdk.ts @@ -3,7 +3,6 @@ import type { CursorSDKAgent, CursorSDKAgentClass, CursorSDKAgentOptions, - CursorSDKModule, CursorSDKRunResult, CursorSDKSendOptions, CursorSDKUserMessage, @@ -178,5 +177,3 @@ function wrapCursorAgent(agent: CursorSDKAgent): CursorSDKAgent { return proxy as CursorSDKAgent; } - -export type { CursorSDKModule }; diff --git a/js/src/wrappers/exports.test.ts b/js/src/wrappers/exports.test.ts index 5454bb724..66850a3b3 100644 --- a/js/src/wrappers/exports.test.ts +++ b/js/src/wrappers/exports.test.ts @@ -1,4 +1,4 @@ -import { describe, it, expect, vi } from "vitest"; +import { describe, it, expect } from "vitest"; import { BraintrustMiddleware } from "./ai-sdk"; describe("ai-sdk exports", () => { diff --git a/js/src/wrappers/genkit.test.ts b/js/src/wrappers/genkit.test.ts index 9b737d28a..5363a64eb 100644 --- a/js/src/wrappers/genkit.test.ts +++ b/js/src/wrappers/genkit.test.ts @@ -54,7 +54,7 @@ describe("wrapGenkit", () => { name: "summarizeCity", }, }, - ) as GenkitAction; + ) as unknown as GenkitAction; const lookupAction = vi.fn(async () => originalTool); class FakeRegistry { lookupAction = lookupAction; @@ -71,21 +71,24 @@ describe("wrapGenkit", () => { typeof input === "object" && input !== null && !Array.isArray(input) ? input : {}; - const toolRef = Array.isArray(options.tools) - ? options.tools[0] + const typedOptions = options as any; + const toolRef = Array.isArray(typedOptions.tools) + ? typedOptions.tools[0] : undefined; if (typeof toolRef !== "string") { throw new Error("Expected a tool name"); } - const childRegistry = FakeRegistry.withParent(registry); - const tool = await childRegistry.lookupAction(`/tool/${toolRef}`); - return tool({ city: "Vienna" }); + const childRegistry = (FakeRegistry.withParent as any)(registry); + const tool = await (childRegistry.lookupAction as any)( + `/tool/${toolRef}`, + ); + return (tool as any)({ city: "Vienna" }); }, registry, }; - const wrapped = wrapGenkit(genkitInstance); + const wrapped = wrapGenkit(genkitInstance as any) as any; wrapped.defineTool( { name: "summarizeCity", diff --git a/js/src/wrappers/google-adk.test.ts b/js/src/wrappers/google-adk.test.ts index 39040130d..cda99043f 100644 --- a/js/src/wrappers/google-adk.test.ts +++ b/js/src/wrappers/google-adk.test.ts @@ -1,4 +1,4 @@ -import { describe, it, expect, vi, beforeEach, afterEach } from "vitest"; +import { describe, it, expect, vi, afterEach } from "vitest"; // Mock iso's newTracingChannel vi.mock("../isomorph", () => { @@ -154,8 +154,6 @@ describe("wrapGoogleADK", () => { }); it("should wrap Runner.runAsync to call traceSync channel", async () => { - let traceSyncCalled = false; - class FakeRunner { constructor(_input: any) {} async *runAsync(_params: any): AsyncGenerator { diff --git a/js/src/wrappers/groq.test.ts b/js/src/wrappers/groq.test.ts index 976d727af..796db91ee 100644 --- a/js/src/wrappers/groq.test.ts +++ b/js/src/wrappers/groq.test.ts @@ -130,11 +130,11 @@ describe("groq wrapper", () => { model: "llama-3.3-70b-versatile", stream: true, }); - for await (const _chunk of streamed) { + for await (const _chunk of streamed as any) { // Consume the stream so chunk aggregation runs. } - await wrapped.embeddings.create({ + await (wrapped.embeddings.create as any)({ input: "braintrust tracing", model: "nomic-embed-text-v1_5", }); diff --git a/js/src/wrappers/huggingface.test.ts b/js/src/wrappers/huggingface.test.ts index dc0805cb9..7adc5a99b 100644 --- a/js/src/wrappers/huggingface.test.ts +++ b/js/src/wrappers/huggingface.test.ts @@ -10,7 +10,6 @@ import { configureNode } from "../node/config"; import { _exportsForTestingOnly, initLogger, - Logger, TestBackgroundLogger, } from "../logger"; import { wrapHuggingFace } from "./huggingface"; @@ -222,7 +221,6 @@ async function collectAsync(records: AsyncIterable) { describe("wrapHuggingFace", () => { let backgroundLogger: TestBackgroundLogger; - let _logger: Logger; beforeAll(async () => { await _exportsForTestingOnly.simulateLoginForTests(); @@ -230,7 +228,7 @@ describe("wrapHuggingFace", () => { beforeEach(() => { backgroundLogger = _exportsForTestingOnly.useTestBackgroundLogger(); - _logger = initLogger({ + initLogger({ projectName: "huggingface.test.ts", projectId: "test-project-id", }); @@ -241,7 +239,7 @@ describe("wrapHuggingFace", () => { }); test("wraps InferenceClient chatCompletion calls", async () => { - const { InferenceClient } = wrapHuggingFace(buildModernModule()); + const { InferenceClient } = wrapHuggingFace(buildModernModule()) as any; const client = new InferenceClient("hf_test"); await client.chatCompletion({ @@ -277,7 +275,7 @@ describe("wrapHuggingFace", () => { }); test("wraps direct textGenerationStream exports", async () => { - const huggingFace = wrapHuggingFace(buildModernModule()); + const huggingFace = wrapHuggingFace(buildModernModule()) as any; const stream = huggingFace.textGenerationStream!( { @@ -315,7 +313,7 @@ describe("wrapHuggingFace", () => { }); test("supports legacy HfInference exports and feature extraction", async () => { - const huggingFace = wrapHuggingFace(buildLegacyModule()); + const huggingFace = wrapHuggingFace(buildLegacyModule()) as any; const client = new huggingFace.HfInference!("hf_test"); await client.endpoint("https://example.invalid").chatCompletion({ @@ -358,7 +356,7 @@ describe("wrapHuggingFace", () => { test("wraps completion-style textGenerationStream chunks", async () => { const huggingFace = wrapHuggingFace( buildCompletionStyleTextGenerationModule(), - ); + ) as any; const stream = huggingFace.textGenerationStream!( { diff --git a/js/src/wrappers/node-test/index.ts b/js/src/wrappers/node-test/index.ts index 65ff07353..25f9a4afc 100644 --- a/js/src/wrappers/node-test/index.ts +++ b/js/src/wrappers/node-test/index.ts @@ -1,10 +1 @@ export { initNodeTestSuite } from "./suite"; -export type { - NodeTestSuiteConfig, - NodeTestProgressEvent, - EvalConfig, - EvalContext, - MinimalTestContext, - NodeTestSuite, - ScorerFunction, -} from "./types"; diff --git a/js/src/wrappers/openai-codex.ts b/js/src/wrappers/openai-codex.ts index e5dbc175b..8b5a435b3 100644 --- a/js/src/wrappers/openai-codex.ts +++ b/js/src/wrappers/openai-codex.ts @@ -3,7 +3,6 @@ import type { OpenAICodexClass, OpenAICodexClient, OpenAICodexInput, - OpenAICodexSDKModule, OpenAICodexStreamedTurn, OpenAICodexThread, OpenAICodexThreadOptions, @@ -182,5 +181,3 @@ function wrapCodexThread(thread: OpenAICodexThread): OpenAICodexThread { }, }); } - -export type { OpenAICodexSDKModule }; diff --git a/js/src/wrappers/openai-promise-utils.ts b/js/src/wrappers/openai-promise-utils.ts index 0f9d1fc95..afa23586c 100644 --- a/js/src/wrappers/openai-promise-utils.ts +++ b/js/src/wrappers/openai-promise-utils.ts @@ -17,7 +17,7 @@ export interface APIPromise extends Promise { withResponse(): Promise>; } -export type ChannelContext = +type ChannelContext = OpenAIStartContext; type ChannelParam = ArgsOf[0]; diff --git a/js/src/wrappers/openrouter.test.ts b/js/src/wrappers/openrouter.test.ts index 74a8bb43b..4ee88ea24 100644 --- a/js/src/wrappers/openrouter.test.ts +++ b/js/src/wrappers/openrouter.test.ts @@ -92,7 +92,7 @@ describe("openrouter wrapper", () => { const client = wrapOpenRouter({ chat: { send }, embeddings: { generate: vi.fn() }, - }); + } as any) as any; const result = await client.chat.send(request, options); expect(result).toMatchObject({ @@ -105,7 +105,7 @@ describe("openrouter wrapper", () => { ], }); - const spans = await backgroundLogger.drain(); + const spans = (await backgroundLogger.drain()) as any[]; expect(spans).toHaveLength(1); const span = spans[0] as Record; expect(span.span_attributes).toMatchObject({ @@ -186,7 +186,7 @@ describe("openrouter wrapper", () => { const client = wrapOpenRouter({ chat: { send }, embeddings: { generate: vi.fn() }, - }); + } as any) as any; const result = await client.chat.send({ chatGenerationParams: { @@ -267,7 +267,7 @@ describe("openrouter wrapper", () => { embeddings: { generate: embeddingsGenerate, }, - }); + } as any) as any; await client.beta.responses.send({ openResponsesRequest: { @@ -284,7 +284,7 @@ describe("openrouter wrapper", () => { }, }); - const spans = await backgroundLogger.drain(); + const spans = (await backgroundLogger.drain()) as any[]; expect(spans).toHaveLength(2); const responseSpan = spans.find( @@ -357,7 +357,7 @@ describe("openrouter wrapper", () => { rerank: { rerank: rerankFn, }, - }); + } as any) as any; await client.rerank.rerank({ requestBody: { @@ -438,7 +438,7 @@ describe("openrouter wrapper", () => { }; const callModel = vi.fn((request) => { const result = { - allToolExecutionRounds: [], + allToolExecutionRounds: [] as any[], finalResponse, resolvedRequest: { input: @@ -493,7 +493,7 @@ describe("openrouter wrapper", () => { const client = wrapOpenRouter({ callModel, - }); + } as any) as any; const result = client.callModel({ input: @@ -515,7 +515,7 @@ describe("openrouter wrapper", () => { await expect(result.getText()).resolves.toBe("Sunny in Vienna"); - const spans = await backgroundLogger.drain(); + const spans = (await backgroundLogger.drain()) as any[]; expect(spans).toHaveLength(4); const callModelSpan = spans.find( (span) => span.span_attributes?.name === "openrouter.callModel", @@ -632,7 +632,7 @@ describe("openrouter wrapper", () => { const client = wrapOpenRouter({ callModel, - }); + } as any) as any; const result = client.callModel({ model: TEST_MODEL, @@ -656,7 +656,7 @@ describe("openrouter wrapper", () => { } expect(chunks).toHaveLength(2); - const spans = await backgroundLogger.drain(); + const spans = (await backgroundLogger.drain()) as any[]; expect(spans).toHaveLength(2); const callModelSpan = spans.find( (span) => span.span_attributes?.name === "openrouter.callModel", diff --git a/js/src/wrappers/pi-coding-agent.test.ts b/js/src/wrappers/pi-coding-agent.test.ts index 544927f8a..7c89bf481 100644 --- a/js/src/wrappers/pi-coding-agent.test.ts +++ b/js/src/wrappers/pi-coding-agent.test.ts @@ -1,7 +1,7 @@ import { afterEach, describe, expect, it, vi } from "vitest"; const { tracePromise } = vi.hoisted(() => ({ - tracePromise: vi.fn((fn: () => Promise) => fn()), + tracePromise: vi.fn((fn: () => Promise, _event?: unknown) => fn()), })); vi.mock("../isomorph", () => ({ diff --git a/js/src/wrappers/pi-coding-agent.ts b/js/src/wrappers/pi-coding-agent.ts index 8a468b47a..064b08ec9 100644 --- a/js/src/wrappers/pi-coding-agent.ts +++ b/js/src/wrappers/pi-coding-agent.ts @@ -70,5 +70,3 @@ function patchAgentSessionClass(AgentSession: PiAgentSessionClass): void { value: true, }); } - -export type { PiCodingAgentModule }; diff --git a/js/src/wrappers/strands-agent-sdk.test.ts b/js/src/wrappers/strands-agent-sdk.test.ts index 57103b46a..f811800d4 100644 --- a/js/src/wrappers/strands-agent-sdk.test.ts +++ b/js/src/wrappers/strands-agent-sdk.test.ts @@ -1,7 +1,7 @@ import { afterEach, describe, expect, it, vi } from "vitest"; const { traceSync } = vi.hoisted(() => ({ - traceSync: vi.fn((fn: () => unknown) => fn()), + traceSync: vi.fn((fn: () => unknown, _event?: unknown) => fn()), })); vi.mock("../isomorph", () => ({ @@ -49,7 +49,7 @@ describe("wrapStrandsAgentSDK", () => { } } - const wrapped = wrapStrandsAgentSDK({ Agent }); + const wrapped = wrapStrandsAgentSDK({ Agent }) as any; const agent = new wrapped.Agent(); const chunks = []; for await (const chunk of agent.stream("hello")) { @@ -93,7 +93,7 @@ describe("wrapStrandsAgentSDK", () => { } } - const wrapped = wrapStrandsAgentSDK({ Graph, Swarm }); + const wrapped = wrapStrandsAgentSDK({ Graph, Swarm }) as any; await expect(new wrapped.Graph().invoke("graph")).resolves.toMatchObject({ status: "COMPLETED", @@ -121,7 +121,9 @@ describe("wrapStrandsAgentSDK", () => { } } - const wrapped = wrapStrandsAgentSDK(wrapStrandsAgentSDK({ Agent })); + const wrapped = wrapStrandsAgentSDK( + wrapStrandsAgentSDK({ Agent }) as any, + ) as any; await new wrapped.Agent().invoke("hello"); expect(traceSync).toHaveBeenCalledTimes(1); @@ -144,7 +146,7 @@ describe("wrapStrandsAgentSDK", () => { } } - const wrapped = wrapStrandsAgentSDK({ Agent }); + const wrapped = wrapStrandsAgentSDK({ Agent }) as any; const agent = new wrapped.Agent(); expect(agent.read()).toBe("secret"); diff --git a/js/src/wrappers/strands-agent-sdk.ts b/js/src/wrappers/strands-agent-sdk.ts index 1b0bc1130..6c6173034 100644 --- a/js/src/wrappers/strands-agent-sdk.ts +++ b/js/src/wrappers/strands-agent-sdk.ts @@ -255,5 +255,3 @@ async function consumeAsyncGenerator( } return result.value; } - -export type { StrandsAgentSDKModule }; diff --git a/js/src/wrappers/vitest-evals/reporter.test.ts b/js/src/wrappers/vitest-evals/reporter.test.ts index 175023d09..23075f5d1 100644 --- a/js/src/wrappers/vitest-evals/reporter.test.ts +++ b/js/src/wrappers/vitest-evals/reporter.test.ts @@ -153,7 +153,7 @@ describe("Braintrust vitest-evals reporter", () => { await reporter.onTestRunEnd([module] as any); await backgroundLogger.flush(); - const rows = await backgroundLogger.drain(); + const rows = (await backgroundLogger.drain()) as any[]; const root = rows.find((row: any) => row.scores?.FactualityJudge === 0.8); expect(root).toMatchObject({ @@ -261,7 +261,7 @@ describe("Braintrust vitest-evals reporter", () => { ] as any); await backgroundLogger.flush(); - const rows = await backgroundLogger.drain(); + const rows = (await backgroundLogger.drain()) as any[]; const root = rows.find((row: any) => row.scores?.StatusJudge === 0); expect(root?.scores).toMatchObject({ @@ -345,7 +345,7 @@ describe("Braintrust vitest-evals reporter", () => { ] as any); await backgroundLogger.flush(); - const rows = await backgroundLogger.drain(); + const rows = (await backgroundLogger.drain()) as any[]; const toolSpan = rows.find( (row: any) => row.span_attributes?.name === "searchDocs", ); diff --git a/js/src/wrappers/vitest/dataset-helpers.ts b/js/src/wrappers/vitest/dataset-helpers.ts deleted file mode 100644 index b10e3d57d..000000000 --- a/js/src/wrappers/vitest/dataset-helpers.ts +++ /dev/null @@ -1,14 +0,0 @@ -export interface DatasetOptions { - project: string; - dataset: string; - version?: string; - description?: string; -} - -export interface DatasetRecord { - id: string; - input: unknown; - expected?: unknown; - metadata?: Record; - tags?: string[]; -} diff --git a/js/src/wrappers/vitest/index.ts b/js/src/wrappers/vitest/index.ts index 5ff41b157..6e2c24fdd 100644 --- a/js/src/wrappers/vitest/index.ts +++ b/js/src/wrappers/vitest/index.ts @@ -4,10 +4,6 @@ import { summarizeAndFlush } from "../shared/flush"; import { logOutputs, logFeedback, getCurrentSpan } from "../shared/logging"; import type { VitestMethods, BraintrustVitest, WrapperConfig } from "./types"; -export type { Score } from "../../../util/score"; -export type { TestConfig, TestContext, ScorerFunction } from "./types"; -export type { DatasetOptions, DatasetRecord } from "./dataset-helpers"; - /** * Wraps Vitest methods with Braintrust experiment tracking. This automatically creates * datasets and experiments from your Vitest tests, tracking pass/fail rates and evaluation metrics. diff --git a/js/src/wrappers/vitest/package.json b/js/src/wrappers/vitest/package.json index f3fdf0fd4..859397f14 100644 --- a/js/src/wrappers/vitest/package.json +++ b/js/src/wrappers/vitest/package.json @@ -3,6 +3,7 @@ "private": true, "description": "Test infrastructure for Vitest wrapper", "scripts": { + "check:typings": "tsc --noEmit -p tsconfig.json", "test": "vitest run" }, "devDependencies": { diff --git a/js/src/wrappers/vitest/tsconfig.json b/js/src/wrappers/vitest/tsconfig.json index 7ba7125c3..d11ccd7c5 100644 --- a/js/src/wrappers/vitest/tsconfig.json +++ b/js/src/wrappers/vitest/tsconfig.json @@ -1,13 +1,18 @@ { "extends": "../../../tsconfig.json", "compilerOptions": { + "module": "es2022", + "noEmit": true, + "noUnusedLocals": true, "rootDir": "../../..", - "outDir": "./dist" + "outDir": "./dist", + "types": ["node", "vitest/globals"] }, - "include": ["./**/*.ts", "../../../src/**/*.ts"], + "include": ["./**/*.ts"], "exclude": [ "node_modules/**", "dist/**", + "../../../src/**/*.test.ts", "../../../vendor/**", "**/vendor/**" ] diff --git a/js/src/wrappers/vitest/types.ts b/js/src/wrappers/vitest/types.ts index 2dfd0b4eb..a587417e5 100644 --- a/js/src/wrappers/vitest/types.ts +++ b/js/src/wrappers/vitest/types.ts @@ -1,7 +1,5 @@ import type { Span } from "../../logger"; -// Re-export from shared -export type { ScorerFunction, ProgressEvent } from "../shared/types"; import type { ScorerFunction, ProgressEvent } from "../shared/types"; // Braintrust-specific test config properties @@ -105,21 +103,6 @@ export interface VitestMethods< afterEach?: (fn: (context: VitestContext) => void | Promise) => void; } -export interface DatasetOptions { - project: string; - dataset: string; - version?: string; - description?: string; -} - -export interface DatasetRecord { - id: string; - input: unknown; - expected?: unknown; - metadata?: Record; - tags?: string[]; -} - export interface BraintrustVitest< VitestContext = unknown, ExpectType extends (...args: unknown[]) => unknown = ( diff --git a/js/tests/api-compatibility/api-compatibility.test.ts b/js/tests/api-compatibility/api-compatibility.test.ts index a261da7a7..214e00996 100644 --- a/js/tests/api-compatibility/api-compatibility.test.ts +++ b/js/tests/api-compatibility/api-compatibility.test.ts @@ -1989,119 +1989,6 @@ function areParsedClassMembersCompatible( return false; } -/** - * Compares method parameter lists, allowing optional field additions - */ -function areMethodParamsCompatible( - oldParams: string, - newParams: string, -): boolean { - // If they're the same, compatible - if (oldParams === newParams) { - return true; - } - - // Count parameters - const countParams = (params: string): number => { - if (!params.trim()) return 0; - let depth = 0; - let count = 0; - for (let i = 0; i < params.length; i++) { - const char = params[i]; - if (char === "<" || char === "{" || char === "(") { - depth++; - } else if (char === ">" || char === "}" || char === ")") { - depth--; - } else if (char === "," && depth === 0) { - count++; - } - } - return count + 1; - }; - - const oldCount = countParams(oldParams); - const newCount = countParams(newParams); - - // Same number of params or new has one more (adding optional param) - if (newCount >= oldCount && newCount <= oldCount + 1) { - // Check if it's just adding optional fields to object types - // Normalize by removing optional markers and defaults - const normalizeParams = (p: string) => { - return p - .replace(/\?:\s*/g, ": ") - .replace(/=\s*\{[^}]*\}/g, "= {}") - .replace(/=\s*[^,)}]+/g, ""); - }; - - const oldNorm = normalizeParams(oldParams); - const newNorm = normalizeParams(newParams); - - // If normalized versions are similar (one contains the other), - // it's likely just optional field additions - if (newNorm.includes(oldNorm) || oldNorm.includes(newNorm)) { - return true; - } - - // Check if only optional fields were added to object types - // This is a heuristic: if the structure is similar, allow it - // Extract object type content for comparison - const extractObjectContent = (p: string): string[] => { - const objects: string[] = []; - let depth = 0; - let current = ""; - let inObject = false; - for (let i = 0; i < p.length; i++) { - const char = p[i]; - if (char === "{") { - if (depth === 0) { - inObject = true; - current = ""; - } - depth++; - } else if (char === "}") { - depth--; - if (depth === 0 && inObject) { - objects.push(current); - inObject = false; - } - } else if (inObject) { - current += char; - } - } - return objects; - }; - - const oldObjects = extractObjectContent(oldParams); - const newObjects = extractObjectContent(newParams); - - // If we have object types and new has same or more fields, likely compatible - if (oldObjects.length > 0 && newObjects.length >= oldObjects.length) { - // For now, be permissive - if object types exist and count increased, - // assume it's just adding optional fields - return true; - } - } - - // If we can't determine, be conservative but allow if counts are similar - // This handles cases where optional fields are added to object types - return newCount === oldCount || newCount === oldCount + 1; -} - -/** - * Truncates a signature for display, showing first N chars and - * handling multiline signatures better - */ -function truncateSignature(sig: string, maxLength: number = 150): string { - // Normalize whitespace - const normalized = sig.replace(/\s+/g, " ").trim(); - - if (normalized.length <= maxLength) { - return normalized; - } - - return normalized.substring(0, maxLength) + "..."; -} - /** * Finds the first difference between two strings */ diff --git a/js/tests/auto-instrumentations/error-handling.test.ts b/js/tests/auto-instrumentations/error-handling.test.ts index 52eb876f3..62f4430e8 100644 --- a/js/tests/auto-instrumentations/error-handling.test.ts +++ b/js/tests/auto-instrumentations/error-handling.test.ts @@ -21,7 +21,6 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url)); const fixturesDir = path.join(__dirname, "fixtures"); const testFilesDir = path.join(fixturesDir, "test-files"); const outputDir = path.join(__dirname, "output-error-handling"); -const nodeModulesDir = path.join(fixturesDir, "node_modules"); describe("Error Handling", () => { let collector: ReturnType; diff --git a/js/tests/auto-instrumentations/function-behavior.test.ts b/js/tests/auto-instrumentations/function-behavior.test.ts index 8f2fd32b5..e04d9db0f 100644 --- a/js/tests/auto-instrumentations/function-behavior.test.ts +++ b/js/tests/auto-instrumentations/function-behavior.test.ts @@ -21,7 +21,6 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url)); const fixturesDir = path.join(__dirname, "fixtures"); const testFilesDir = path.join(fixturesDir, "test-files"); const outputDir = path.join(__dirname, "output-function-behavior"); -const nodeModulesDir = path.join(fixturesDir, "node_modules"); describe("Function Behavior Preservation", () => { beforeAll(() => { @@ -518,7 +517,7 @@ describe("Function Behavior Preservation", () => { expect(results[2].model).toBe("gpt-4-turbo"); // Verify each got a unique ID - const ids = results.map((r) => r.id); + const ids = results.map((r: any) => r.id); expect(new Set(ids).size).toBe(3); }); }); diff --git a/js/tests/auto-instrumentations/import-require-in-the-middle.test.ts b/js/tests/auto-instrumentations/import-require-in-the-middle.test.ts index f1bac474f..551c0804f 100644 --- a/js/tests/auto-instrumentations/import-require-in-the-middle.test.ts +++ b/js/tests/auto-instrumentations/import-require-in-the-middle.test.ts @@ -68,7 +68,7 @@ function runNode({ child.on("error", reject); child.on("exit", (code) => { if (code === 0) { - resolve(); + resolve(undefined); } else { reject( new Error( diff --git a/js/tests/auto-instrumentations/multiple-instrumentations.test.ts b/js/tests/auto-instrumentations/multiple-instrumentations.test.ts index eabe2b0cd..88d3a39d7 100644 --- a/js/tests/auto-instrumentations/multiple-instrumentations.test.ts +++ b/js/tests/auto-instrumentations/multiple-instrumentations.test.ts @@ -10,7 +10,7 @@ * Tests use mock modules that simulate having multiple instrumented methods. */ -import { describe, it, expect, beforeAll, afterAll, beforeEach } from "vitest"; +import { describe, it, expect, beforeAll, afterAll } from "vitest"; import * as esbuild from "esbuild"; import * as fs from "node:fs"; import * as path from "node:path"; diff --git a/js/tests/auto-instrumentations/runtime-execution.test.ts b/js/tests/auto-instrumentations/runtime-execution.test.ts index f8641611b..eb5e349ac 100644 --- a/js/tests/auto-instrumentations/runtime-execution.test.ts +++ b/js/tests/auto-instrumentations/runtime-execution.test.ts @@ -23,7 +23,6 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url)); const fixturesDir = path.join(__dirname, "fixtures"); const testFilesDir = path.join(fixturesDir, "test-files"); const outputDir = path.join(__dirname, "output-runtime-execution"); -const nodeModulesDir = path.join(fixturesDir, "node_modules"); describe("Runtime Execution of Bundled Code", () => { beforeAll(() => { diff --git a/js/tests/auto-instrumentations/streaming-and-responses.test.ts b/js/tests/auto-instrumentations/streaming-and-responses.test.ts index 8d4a40ff5..e994de00e 100644 --- a/js/tests/auto-instrumentations/streaming-and-responses.test.ts +++ b/js/tests/auto-instrumentations/streaming-and-responses.test.ts @@ -11,7 +11,7 @@ * - Responses API channels (responses.create, responses.stream, responses.parse) */ -import { describe, it, expect, beforeAll, afterAll, beforeEach } from "vitest"; +import { describe, it, expect, beforeAll, afterAll } from "vitest"; import * as esbuild from "esbuild"; import * as fs from "node:fs"; import * as path from "node:path"; diff --git a/js/tests/provider-wrappers.test.ts b/js/tests/provider-wrappers.test.ts index 919207a49..6fea43660 100644 --- a/js/tests/provider-wrappers.test.ts +++ b/js/tests/provider-wrappers.test.ts @@ -313,7 +313,7 @@ describe("provider wrapper", () => { tokens: 6, }, }); - expect(rawEvents[1].metrics.end).toBeUndefined(); + expect((rawEvents[1] as any).metrics.end).toBeUndefined(); expect(rawEvents[2]).toMatchObject({ _is_merge: true, metrics: { end: expect.any(Number) }, @@ -400,7 +400,7 @@ describe("provider wrapper", () => { (generator as any).interrupt = interrupt; return generator; }, - }); + } as any) as any; const result = wrappedSDK.query({ prompt: "test" }) as any; if (startIteration) { @@ -423,10 +423,10 @@ describe("provider wrapper", () => { (generator as any).customMethod = () => "custom-value"; return generator; }, - }); + } as any) as any; const result = wrappedSDK.query({ prompt: "test" }) as any; - const messages = []; + const messages: any[] = []; for await (const message of result) { messages.push(message); } diff --git a/js/tests/type-shims/ai-sdk-openai.d.ts b/js/tests/type-shims/ai-sdk-openai.d.ts new file mode 100644 index 000000000..eb6e15b94 --- /dev/null +++ b/js/tests/type-shims/ai-sdk-openai.d.ts @@ -0,0 +1,2 @@ +export const createOpenAI: any; +export const openai: any; diff --git a/js/tests/type-shims/ai.d.ts b/js/tests/type-shims/ai.d.ts new file mode 100644 index 000000000..56666ea71 --- /dev/null +++ b/js/tests/type-shims/ai.d.ts @@ -0,0 +1,2 @@ +declare const ai: any; +export = ai; diff --git a/js/tests/typecheck.d.ts b/js/tests/typecheck.d.ts new file mode 100644 index 000000000..5cb6f1a5a --- /dev/null +++ b/js/tests/typecheck.d.ts @@ -0,0 +1,3 @@ +declare module "esquery"; +declare module "module-details-from-path"; +declare module "semifies"; diff --git a/js/tsconfig.json b/js/tsconfig.json index 3be431096..de86073ac 100644 --- a/js/tsconfig.json +++ b/js/tsconfig.json @@ -12,6 +12,7 @@ ] }, "strict": true, + "noUnusedLocals": true, "esModuleInterop": true, "skipLibCheck": true }, diff --git a/js/tsconfig.test.json b/js/tsconfig.test.json new file mode 100644 index 000000000..22ea8b173 --- /dev/null +++ b/js/tsconfig.test.json @@ -0,0 +1,30 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "declaration": false, + "module": "es2022", + "noEmit": true, + "types": ["node", "vitest/globals"], + "paths": { + "@apm-js-collab/code-transformer": [ + "src/auto-instrumentations/orchestrion-js/index.ts" + ], + "@ai-sdk/openai": ["tests/type-shims/ai-sdk-openai.d.ts"], + "ai": ["tests/type-shims/ai.d.ts"], + "braintrust": ["src/node/index.ts"] + } + }, + "include": [ + "src/**/*.test.ts", + "tests/**/*.test.ts", + "tests/typecheck.d.ts", + "util/**/*.test.ts" + ], + "exclude": [ + "node_modules/**", + "**/dist/**", + "vendor/**", + "**/smoke/**", + "src/wrappers/vitest/**" + ] +} diff --git a/js/util/merge_row_batch.ts b/js/util/merge_row_batch.ts index c0c5a3d66..de05927b4 100644 --- a/js/util/merge_row_batch.ts +++ b/js/util/merge_row_batch.ts @@ -1,6 +1,4 @@ -// Mirror of the functions in py/src/braintrust/merge_row_batch.py. - -import { IS_MERGE_FIELD, PARENT_ID_FIELD } from "./db_fields"; +import { IS_MERGE_FIELD } from "./db_fields"; import { mergeDicts } from "./object_util"; function generateMergedRowKey(row: Record) { diff --git a/js/util/span_identifier_v1.ts b/js/util/span_identifier_v1.ts index 8d3a6803d..50d6289e8 100644 --- a/js/util/span_identifier_v1.ts +++ b/js/util/span_identifier_v1.ts @@ -1,5 +1,3 @@ -// Mirror of py/src/braintrust/span_identifier_v1.py. - import * as uuid from "uuid"; import { ParentExperimentIds, ParentProjectLogIds } from "./object"; import { z } from "zod/v3"; diff --git a/js/util/span_identifier_v2.ts b/js/util/span_identifier_v2.ts index 43a056ec0..2e37eb053 100644 --- a/js/util/span_identifier_v2.ts +++ b/js/util/span_identifier_v2.ts @@ -1,5 +1,3 @@ -// Mirror of py/src/braintrust/span_identifier_v2.py. - import * as uuid from "uuid"; import { ParentExperimentIds, ParentProjectLogIds } from "./object"; import { SpanComponentsV1 } from "./span_identifier_v1"; diff --git a/js/util/span_identifier_v3.ts b/js/util/span_identifier_v3.ts index 21f821069..f057f798b 100644 --- a/js/util/span_identifier_v3.ts +++ b/js/util/span_identifier_v3.ts @@ -1,5 +1,3 @@ -// Mirror of py/src/braintrust/span_identifier_v3.py. - import * as uuid from "uuid"; import { ParentExperimentIds, @@ -239,7 +237,7 @@ export class SpanComponentsV3 { case SpanObjectTypeV3.PLAYGROUND_LOGS: return { prompt_session_id: this.data.object_id, log_id: "x" }; default: - const _: never = this.data.object_type; + this.data.object_type satisfies never; throw new Error("Impossible"); } } diff --git a/js/util/span_identifier_v4.test.ts b/js/util/span_identifier_v4.test.ts index ce7076a98..6084607d8 100644 --- a/js/util/span_identifier_v4.test.ts +++ b/js/util/span_identifier_v4.test.ts @@ -1,4 +1,4 @@ -import { vi, expect, test, describe, beforeEach, afterEach } from "vitest"; +import { expect, test, describe } from "vitest"; import { SpanComponentsV4, SpanComponentsV4Data, diff --git a/js/util/span_identifier_v4.ts b/js/util/span_identifier_v4.ts index 8988087a4..e92e3eddf 100644 --- a/js/util/span_identifier_v4.ts +++ b/js/util/span_identifier_v4.ts @@ -278,7 +278,7 @@ export class SpanComponentsV4 { case SpanObjectTypeV3.PLAYGROUND_LOGS: return { prompt_session_id: this.data.object_id, log_id: "x" }; default: - const _: never = this.data.object_type; + this.data.object_type satisfies never; throw new Error(`Invalid object_type ${this.data.object_type}`); } } diff --git a/knip.jsonc b/knip.jsonc index 99bf84691..9752cb9a2 100644 --- a/knip.jsonc +++ b/knip.jsonc @@ -1,6 +1,6 @@ { "$schema": "node_modules/knip/schema-jsonc.json", - "include": ["files", "exports"], + "include": ["files", "exports", "types"], "ignoreFiles": [ ".context/**", ".changeset/changelog.cjs", @@ -45,6 +45,11 @@ }, "js": { "entry": [ + "src/node/index.ts", + "src/browser/index.ts", + "src/edge-light/index.ts", + "src/workerd/index.ts", + "src/instrumentation/index.ts", "src/auto-instrumentations/bundler/*.ts", "tests/**/*.{ts,tsx,mts,cts,cjs,mjs}", "scripts/**/*.ts", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f63ca9702..ce6d6ea1c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -249,6 +249,9 @@ importers: typescript: specifier: 5.5.4 version: 5.5.4 + vitest: + specifier: 4.1.5 + version: 4.1.5(@opentelemetry/api@1.9.0)(@types/node@22.19.1)(msw@2.13.6(@types/node@22.19.1)(typescript@5.5.4))(vite@6.4.3(@types/node@22.19.1)(jiti@2.6.1)(terser@5.44.1)(tsx@4.21.0)(yaml@2.9.0)) integrations/templates-nunjucks: dependencies: From 7bfef2dafdd4fa50d0560ccaa2e3aa17124e2c54 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 6 Jul 2026 20:16:19 +0200 Subject: [PATCH 2/2] less obnoxious --- js/src/trace.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/src/trace.ts b/js/src/trace.ts index 58fe258be..d3e6b7610 100644 --- a/js/src/trace.ts +++ b/js/src/trace.ts @@ -20,9 +20,11 @@ export class SpanFetcher extends ObjectFetcher { constructor( objectType: "experiment" | "project_logs" | "playground_logs", private readonly _objectId: string, - rootSpanId: string, + // @ts-expect-error unused + private readonly rootSpanId: string, private readonly _state: BraintrustState, - spanTypeFilter?: string[], + // @ts-expect-error unused + private readonly spanTypeFilter?: string[], includeScorers = false, brainstoreRealtime = true, ) {