@bitfab/sdk 0.76.5 → 0.76.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/{autoTrace-pZKu5Nk2.cjs → autoTrace-BtiEpHTN.cjs} +76 -4
  2. package/dist/autoTrace-BtiEpHTN.cjs.map +1 -0
  3. package/dist/{autoTrace-BgN0zCQf.js → autoTrace-RWUOk1WF.js} +47 -5
  4. package/dist/autoTrace-RWUOk1WF.js.map +1 -0
  5. package/dist/autoTrace.cjs +1 -1
  6. package/dist/autoTrace.js +1 -1
  7. package/dist/{babelPlugin-tupc_WZS.js → babelPlugin-398AO0eD.js} +6 -2
  8. package/dist/babelPlugin-398AO0eD.js.map +1 -0
  9. package/dist/{babelPlugin-C4ERQ8DW.cjs → babelPlugin-Btzkfl62.cjs} +6 -2
  10. package/dist/babelPlugin-Btzkfl62.cjs.map +1 -0
  11. package/dist/{http-BXQZC6_Y.cjs → http-7FhAoWen.cjs} +3 -3
  12. package/dist/{http-BXQZC6_Y.cjs.map → http-7FhAoWen.cjs.map} +1 -1
  13. package/dist/{http-BLyaXOOY.js → http-DoS4PUm6.js} +3 -3
  14. package/dist/{http-BLyaXOOY.js.map → http-DoS4PUm6.js.map} +1 -1
  15. package/dist/{index-QVRAlE4o.d.cts → index-C-3LPlPg.d.cts} +58 -2
  16. package/dist/{index-QVRAlE4o.d.ts → index-C-3LPlPg.d.ts} +58 -2
  17. package/dist/index.cjs +2 -2
  18. package/dist/index.d.cts +2 -2
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.js +2 -2
  21. package/dist/node.cjs +3 -3
  22. package/dist/node.d.cts +2 -2
  23. package/dist/node.d.ts +2 -2
  24. package/dist/node.js +3 -3
  25. package/dist/{registryCommand-M1u4H9PI.js → registryCommand-D9EkYtKh.js} +34 -3
  26. package/dist/registryCommand-D9EkYtKh.js.map +1 -0
  27. package/dist/replayCli.js +1 -1
  28. package/dist/seedCli.js +1 -1
  29. package/dist/{src-CWmTGb52.cjs → src-C0Mz9eoA.cjs} +119 -62
  30. package/dist/src-C0Mz9eoA.cjs.map +1 -0
  31. package/dist/{src-B_e7xNzm.js → src-Cm9Jdgfh.js} +119 -62
  32. package/dist/src-Cm9Jdgfh.js.map +1 -0
  33. package/dist/transform/babel.cjs +1 -1
  34. package/dist/transform/babel.js +1 -1
  35. package/dist/transform/loaderRuntime.cjs +2 -2
  36. package/dist/transform/loaderRuntime.js +2 -2
  37. package/dist/transform/nodeLoader.js +5 -1
  38. package/dist/transform/nodeLoader.js.map +1 -1
  39. package/dist/transform/swc.cjs +1 -1
  40. package/dist/transform/swc.js +1 -1
  41. package/dist/transform/unplugin.cjs +2 -2
  42. package/dist/transform/unplugin.js +2 -2
  43. package/dist/{transform-mb6EwHsJ.js → transform-BBlyY-tA.js} +2 -2
  44. package/dist/{transform-mb6EwHsJ.js.map → transform-BBlyY-tA.js.map} +1 -1
  45. package/dist/{transform-CcNCVr8A.cjs → transform-CclhVghC.cjs} +2 -2
  46. package/dist/{transform-CcNCVr8A.cjs.map → transform-CclhVghC.cjs.map} +1 -1
  47. package/package.json +1 -1
  48. package/dist/autoTrace-BgN0zCQf.js.map +0 -1
  49. package/dist/autoTrace-pZKu5Nk2.cjs.map +0 -1
  50. package/dist/babelPlugin-C4ERQ8DW.cjs.map +0 -1
  51. package/dist/babelPlugin-tupc_WZS.js.map +0 -1
  52. package/dist/registryCommand-M1u4H9PI.js.map +0 -1
  53. package/dist/src-B_e7xNzm.js.map +0 -1
  54. package/dist/src-CWmTGb52.cjs.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
- import { C as BitfabError, D as readEnv$1, E as serializeError, O as __version__, S as gitRunner, T as describeError, _ as MAX_SPAN_CARRIER_BYTES, b as replayContextReady, c as recordCallerTraceMetadata, f as ROOT_TRACE_FUNCTION_KEY_FIELD, g as MAX_COMPRESSIBLE_SPAN_CARRIER_BYTES, h as makeSpanOrigin, i as flushTraces, l as retireTraceMetadata, m as isFrameworkInstrumentation, n as SPAN_TYPES, o as unrefTimer, p as SimulationPlan, r as experimentIdWireFields, s as callerTraceMetadata, t as HttpClient, v as byteLength, w as MixedTracingError, x as runWithReplayContext, y as getReplayContext } from "./http-BLyaXOOY.js";
3
- import { A as recordWatchedClientCall, B as installLangChainRunScopes, C as OPENAI_RESPONSES, D as clientCallStreams, E as clientCallProvider, F as mapOpenAiAgentsTrace, G as isCaptureSuppressed, I as openAiAgentsParentSpanId, J as asyncStorageReady, K as runWithCaptureSuppressed, L as openAiAgentsSpanChain, M as watchClientCall, N as StreamFinalizationError, O as frameworkRecordsClientCall, P as endOpenAiAgentsSpan, R as unmapOpenAiAgentsTrace, S as OPENAI_EMBEDDINGS, T as OPENROUTER, U as warnOnce, V as markLangChainRunRecorded, W as writeOnce, X as isAsyncStorageInitDone, Y as createAsyncLocalStorage, _ as runWithAutoTraceNodeConfiguration, b as GEMINI, d as currentAutoTraceEntries, g as runWithAutoTraceFramesAt, h as runWithAutoTraceEntry, j as sharedClientCallStreamRecording, k as recordAutoTracedClientCall, m as runAsAutoTraceRootFunction, p as invokeThroughAutoTraceEntries, s as __bitfabAutoTraceActive, u as clearAutoTraceNodeConfiguration, v as runWithAutoTraceRootContext, w as OPENAI_TRANSCRIPTIONS, x as OPENAI_CHAT, y as ANTHROPIC, z as forgetLangChainRun } from "./autoTrace-BgN0zCQf.js";
2
+ import { C as BitfabError, D as readEnv$1, E as serializeError, O as __version__, S as gitRunner, T as describeError, _ as MAX_SPAN_CARRIER_BYTES, b as replayContextReady, c as recordCallerTraceMetadata, f as ROOT_TRACE_FUNCTION_KEY_FIELD, g as MAX_COMPRESSIBLE_SPAN_CARRIER_BYTES, h as makeSpanOrigin, i as flushTraces, l as retireTraceMetadata, m as isFrameworkInstrumentation, n as SPAN_TYPES, o as unrefTimer, p as SimulationPlan, r as experimentIdWireFields, s as callerTraceMetadata, t as HttpClient, v as byteLength, w as MixedTracingError, x as runWithReplayContext, y as getReplayContext } from "./http-DoS4PUm6.js";
3
+ import { $ as asyncStorageReady, A as frameworkRecordsClientCall, B as mapOpenAiAgentsTrace, C as OPENAI_EMBEDDINGS, D as clientCallProvider, E as OPENROUTER, F as sharedClientCallStreamRecording, G as installLangChainRunScopes, H as openAiAgentsSpanChain, I as watchClientCall, J as warnOnce, K as markLangChainRunRecorded, L as StreamFinalizationError, M as isOpenRouterBaseUrl, N as recordAutoTracedClientCall, O as clientCallProviderForUsage, P as recordWatchedClientCall, R as MODEL_CALL_SPAN_TYPES, S as OPENAI_CHAT, T as OPENAI_TRANSCRIPTIONS, U as unmapOpenAiAgentsTrace, V as openAiAgentsParentSpanId, W as forgetLangChainRun, X as isCaptureSuppressed, Y as writeOnce, Z as runWithCaptureSuppressed, _ as runWithAutoTraceNodeConfiguration, b as GEMINI, d as currentAutoTraceEntries, et as createAsyncLocalStorage, g as runWithAutoTraceFramesAt, h as runWithAutoTraceEntry, j as isAnthropicBaseUrl, k as clientCallStreams, m as runAsAutoTraceRootFunction, p as invokeThroughAutoTraceEntries, s as __bitfabAutoTraceActive, tt as isAsyncStorageInitDone, u as clearAutoTraceNodeConfiguration, v as runWithAutoTraceRootContext, w as OPENAI_RESPONSES, x as GEMINI_EMBEDDINGS, y as ANTHROPIC, z as endOpenAiAgentsSpan } from "./autoTrace-RWUOk1WF.js";
4
4
  import { t as importOptionalPeer } from "./optionalPeer-CczrzrXx.js";
5
5
  import { n as loadBamlModule, t as isSharedBamlModule } from "./bamlPeer-CWPgBSlJ.js";
6
6
  import superjson from "superjson";
@@ -1545,11 +1545,11 @@ var GradersClient = class {
1545
1545
  const JEV_PROVIDER = "typesafe";
1546
1546
  const JEV_WATCH_STORAGE_SYMBOL = Symbol.for("bitfab.jevWatchStorage");
1547
1547
  const repliesRecordedByAutoTrace = /* @__PURE__ */ new WeakSet();
1548
- function isRecord$5(value) {
1548
+ function isRecord$6(value) {
1549
1549
  return typeof value === "object" && value !== null;
1550
1550
  }
1551
1551
  function isJevReply(value) {
1552
- return isRecord$5(value) && typeof value.model === "string" && isRecord$5(value.usage);
1552
+ return isRecord$6(value) && typeof value.model === "string" && isRecord$6(value.usage);
1553
1553
  }
1554
1554
  function tokenCount(usage, key) {
1555
1555
  const count = usage[key];
@@ -1608,7 +1608,7 @@ function recordWatchedJevReply(span, watch, reply, durationMs) {
1608
1608
  markEnclosingWatches(watch);
1609
1609
  }
1610
1610
  function isRecordedByAutoTrace(reply) {
1611
- return isRecord$5(reply) && repliesRecordedByAutoTrace.has(reply);
1611
+ return isRecord$6(reply) && repliesRecordedByAutoTrace.has(reply);
1612
1612
  }
1613
1613
  function recordAutoTracedJev(invokeFn, span) {
1614
1614
  const startedAt = Date.now();
@@ -2121,7 +2121,7 @@ var BitfabLangGraphCallbackHandler = class {
2121
2121
  //#region src/integrationFixture.ts
2122
2122
  const INTEGRATION_FIXTURE_CONTEXT_KEY = "__bitfabIntegrationFixture";
2123
2123
  const INTEGRATION_FIXTURE_VERSION = 1;
2124
- function isRecord$4(value) {
2124
+ function isRecord$5(value) {
2125
2125
  return typeof value === "object" && value !== null && !Array.isArray(value);
2126
2126
  }
2127
2127
  function createIntegrationFixtureContext(name, value) {
@@ -2135,8 +2135,8 @@ function createIntegrationFixtureContext(name, value) {
2135
2135
  }
2136
2136
  function hasIntegrationFixture(contexts, name) {
2137
2137
  return contexts.some((context) => {
2138
- const fixture = isRecord$4(context) ? context[INTEGRATION_FIXTURE_CONTEXT_KEY] : void 0;
2139
- return isRecord$4(fixture) && fixture.version === INTEGRATION_FIXTURE_VERSION && fixture.name === name;
2138
+ const fixture = isRecord$5(context) ? context[INTEGRATION_FIXTURE_CONTEXT_KEY] : void 0;
2139
+ return isRecord$5(fixture) && fixture.version === INTEGRATION_FIXTURE_VERSION && fixture.name === name;
2140
2140
  });
2141
2141
  }
2142
2142
  function extractIntegrationFixtures(spanData) {
@@ -2144,9 +2144,9 @@ function extractIntegrationFixtures(spanData) {
2144
2144
  if (!Array.isArray(contexts)) return;
2145
2145
  const fixtures = /* @__PURE__ */ new Map();
2146
2146
  for (const context of contexts) {
2147
- if (!isRecord$4(context)) continue;
2147
+ if (!isRecord$5(context)) continue;
2148
2148
  const fixture = context[INTEGRATION_FIXTURE_CONTEXT_KEY];
2149
- if (!isRecord$4(fixture) || fixture.version !== INTEGRATION_FIXTURE_VERSION || typeof fixture.name !== "string" || fixtures.has(fixture.name)) continue;
2149
+ if (!isRecord$5(fixture) || fixture.version !== INTEGRATION_FIXTURE_VERSION || typeof fixture.name !== "string" || fixtures.has(fixture.name)) continue;
2150
2150
  fixtures.set(fixture.name, deserializeValue({
2151
2151
  json: fixture.value,
2152
2152
  ...fixture.valueMeta !== void 0 && { meta: fixture.valueMeta }
@@ -2165,7 +2165,7 @@ const THREAD_CONFIG_KEYS = [
2165
2165
  "checkpoint_ns",
2166
2166
  "checkpoint_id"
2167
2167
  ];
2168
- function isRecord$3(value) {
2168
+ function isRecord$4(value) {
2169
2169
  return typeof value === "object" && value !== null;
2170
2170
  }
2171
2171
  function toBase64(bytes) {
@@ -2192,12 +2192,12 @@ async function newMemorySaver() {
2192
2192
  return new MemorySaver();
2193
2193
  }
2194
2194
  async function unstoredDeltaChannels(graph, tuple) {
2195
- const channels = isRecord$3(graph) ? graph.channels : void 0;
2196
- if (!isRecord$3(channels)) return [];
2195
+ const channels = isRecord$4(graph) ? graph.channels : void 0;
2196
+ if (!isRecord$4(channels)) return [];
2197
2197
  const { DeltaChannel } = await loadLangGraphPeer();
2198
2198
  if (DeltaChannel === void 0) return [];
2199
- const versions = isRecord$3(tuple.checkpoint.channel_versions) ? tuple.checkpoint.channel_versions : {};
2200
- const values = isRecord$3(tuple.checkpoint.channel_values) ? tuple.checkpoint.channel_values : {};
2199
+ const versions = isRecord$4(tuple.checkpoint.channel_versions) ? tuple.checkpoint.channel_versions : {};
2200
+ const values = isRecord$4(tuple.checkpoint.channel_values) ? tuple.checkpoint.channel_values : {};
2201
2201
  return Object.entries(channels).filter(([name, spec]) => spec instanceof DeltaChannel && name in versions && !(name in values)).map(([name]) => name);
2202
2202
  }
2203
2203
  async function selfContained(graph, checkpointer, tuple) {
@@ -2210,27 +2210,27 @@ async function selfContained(graph, checkpointer, tuple) {
2210
2210
  checkpoint: {
2211
2211
  ...tuple.checkpoint,
2212
2212
  channel_values: {
2213
- ...isRecord$3(tuple.checkpoint.channel_values) ? tuple.checkpoint.channel_values : {},
2213
+ ...isRecord$4(tuple.checkpoint.channel_values) ? tuple.checkpoint.channel_values : {},
2214
2214
  ...Object.fromEntries(names.filter((name) => name in values).map((name) => [name, values[name]]))
2215
2215
  }
2216
2216
  }
2217
2217
  };
2218
2218
  }
2219
2219
  function savingCheckpointer(graph) {
2220
- const own = isRecord$3(graph) ? graph.checkpointer : void 0;
2221
- const inner = isRecord$3(graph) && isRecord$3(graph.graph) ? graph.graph.checkpointer : void 0;
2220
+ const own = isRecord$4(graph) ? graph.checkpointer : void 0;
2221
+ const inner = isRecord$4(graph) && isRecord$4(graph.graph) ? graph.graph.checkpointer : void 0;
2222
2222
  const checkpointer = own ?? inner;
2223
- return isRecord$3(checkpointer) && typeof checkpointer.getTuple === "function" ? checkpointer : null;
2223
+ return isRecord$4(checkpointer) && typeof checkpointer.getTuple === "function" ? checkpointer : null;
2224
2224
  }
2225
2225
  function threadConfig(config) {
2226
- const configurable = isRecord$3(config?.configurable) ? config.configurable : {};
2226
+ const configurable = isRecord$4(config?.configurable) ? config.configurable : {};
2227
2227
  return Object.fromEntries(THREAD_CONFIG_KEYS.filter((key) => key in configurable).map((key) => [key, configurable[key]]));
2228
2228
  }
2229
2229
  function withConfigurable(config, values) {
2230
2230
  return {
2231
2231
  ...config ?? {},
2232
2232
  configurable: {
2233
- ...isRecord$3(config?.configurable) ? config.configurable : {},
2233
+ ...isRecord$4(config?.configurable) ? config.configurable : {},
2234
2234
  ...values
2235
2235
  }
2236
2236
  };
@@ -2367,7 +2367,7 @@ var GraphRun = class {
2367
2367
  }
2368
2368
  async restoreThread(replay) {
2369
2369
  const { saver, thread } = await restoredCheckpointer(replay.integrationFixtures?.get(this.fixtureName) ?? null);
2370
- const configurable = isRecord$3(this.config?.configurable) ? this.config.configurable : {};
2370
+ const configurable = isRecord$4(this.config?.configurable) ? this.config.configurable : {};
2371
2371
  return {
2372
2372
  saver,
2373
2373
  thread: {
@@ -2381,19 +2381,19 @@ var GraphRun = class {
2381
2381
  //#region src/langgraphIntegration.ts
2382
2382
  const TOOL_RESULT_TAG = "__bitfabLangGraphToolResult";
2383
2383
  const AGENT_MIDDLEWARE_BRAND = Symbol.for("AgentMiddleware");
2384
- function isRecord$2(value) {
2384
+ function isRecord$3(value) {
2385
2385
  return typeof value === "object" && value !== null;
2386
2386
  }
2387
2387
  function isToolMessage(value) {
2388
- return isRecord$2(value) && value.lc_direct_tool_output === true && value.type === "tool" && (typeof value.content === "string" || Array.isArray(value.content));
2388
+ return isRecord$3(value) && value.lc_direct_tool_output === true && value.type === "tool" && (typeof value.content === "string" || Array.isArray(value.content));
2389
2389
  }
2390
2390
  function isCommand(value) {
2391
- return isRecord$2(value) && value.lg_name === "Command";
2391
+ return isRecord$3(value) && value.lg_name === "Command";
2392
2392
  }
2393
2393
  function encodeNested(value) {
2394
2394
  if (isToolMessage(value) || isCommand(value)) return encodeNativeToolResult(value);
2395
2395
  if (Array.isArray(value)) return value.map(encodeNested);
2396
- if (isRecord$2(value)) return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, encodeNested(entry)]));
2396
+ if (isRecord$3(value)) return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, encodeNested(entry)]));
2397
2397
  return value;
2398
2398
  }
2399
2399
  function encodeNativeToolResult(value) {
@@ -2410,17 +2410,17 @@ function encodeNativeToolResult(value) {
2410
2410
  };
2411
2411
  return {
2412
2412
  [TOOL_RESULT_TAG]: "command",
2413
- graph: isRecord$2(value) && typeof value.graph === "string" ? value.graph : void 0,
2414
- update: isRecord$2(value) ? encodeNested(value.update) : void 0,
2415
- resume: isRecord$2(value) ? encodeNested(value.resume) : void 0,
2416
- goto: isRecord$2(value) ? encodeNested(value.goto) : void 0
2413
+ graph: isRecord$3(value) && typeof value.graph === "string" ? value.graph : void 0,
2414
+ update: isRecord$3(value) ? encodeNested(value.update) : void 0,
2415
+ resume: isRecord$3(value) ? encodeNested(value.resume) : void 0,
2416
+ goto: isRecord$3(value) ? encodeNested(value.goto) : void 0
2417
2417
  };
2418
2418
  }
2419
2419
  function finalizeToolResult(value) {
2420
2420
  return isToolMessage(value) || isCommand(value) ? encodeNativeToolResult(value) : value;
2421
2421
  }
2422
2422
  function isEncodedToolResult(value) {
2423
- return isRecord$2(value) && typeof value[TOOL_RESULT_TAG] === "string";
2423
+ return isRecord$3(value) && typeof value[TOOL_RESULT_TAG] === "string";
2424
2424
  }
2425
2425
  async function loadPeer(specifierParts, packageName, docsPath) {
2426
2426
  try {
@@ -2450,7 +2450,7 @@ async function loadLangGraph() {
2450
2450
  async function reviveNested(value, toolCallId) {
2451
2451
  if (isEncodedToolResult(value)) return reviveToolResult(value, toolCallId);
2452
2452
  if (Array.isArray(value)) return Promise.all(value.map((entry) => reviveNested(entry, toolCallId)));
2453
- if (isRecord$2(value)) {
2453
+ if (isRecord$3(value)) {
2454
2454
  const entries = await Promise.all(Object.entries(value).map(async ([key, entry]) => [key, await reviveNested(entry, toolCallId)]));
2455
2455
  return Object.fromEntries(entries);
2456
2456
  }
@@ -2466,9 +2466,9 @@ async function reviveToolResult(value, toolCallId) {
2466
2466
  ...typeof value.id === "string" && { id: value.id },
2467
2467
  ...(value.status === "success" || value.status === "error") && { status: value.status },
2468
2468
  ...value.artifact !== void 0 && { artifact: await reviveNested(value.artifact, toolCallId) },
2469
- ...isRecord$2(value.metadata) && { metadata: await reviveNested(value.metadata, toolCallId) },
2470
- ...isRecord$2(value.additionalKwargs) && { additional_kwargs: await reviveNested(value.additionalKwargs, toolCallId) },
2471
- ...isRecord$2(value.responseMetadata) && { response_metadata: await reviveNested(value.responseMetadata, toolCallId) }
2469
+ ...isRecord$3(value.metadata) && { metadata: await reviveNested(value.metadata, toolCallId) },
2470
+ ...isRecord$3(value.additionalKwargs) && { additional_kwargs: await reviveNested(value.additionalKwargs, toolCallId) },
2471
+ ...isRecord$3(value.responseMetadata) && { response_metadata: await reviveNested(value.responseMetadata, toolCallId) }
2472
2472
  });
2473
2473
  }
2474
2474
  const { Command } = await loadLangGraph();
@@ -2545,7 +2545,7 @@ var BitfabLangGraphIntegration = class {
2545
2545
  return middleware.includes(this.middleware) ? [...middleware] : [...middleware, this.middleware];
2546
2546
  }
2547
2547
  withSubagentMiddleware(spec) {
2548
- if (!isRecord$2(spec) || "runnable" in spec || "graphId" in spec) return spec;
2548
+ if (!isRecord$3(spec) || "runnable" in spec || "graphId" in spec) return spec;
2549
2549
  return {
2550
2550
  ...spec,
2551
2551
  middleware: this.withMiddleware(Array.isArray(spec.middleware) ? spec.middleware : [])
@@ -2562,7 +2562,7 @@ var BitfabLangGraphIntegration = class {
2562
2562
  return await this.runClaimedToolCall(traceId, toolCallId, toolName, shouldMock, request.toolCall.args, async () => await handler(request), stepSpanId);
2563
2563
  }
2564
2564
  stepSpanIdFor(config, traceId) {
2565
- const namespace = isRecord$2(config) && isRecord$2(config.configurable) ? config.configurable.checkpoint_ns : void 0;
2565
+ const namespace = isRecord$3(config) && isRecord$3(config.configurable) ? config.configurable.checkpoint_ns : void 0;
2566
2566
  return typeof namespace === "string" ? this.callbackHandler.visibleStepSpanId(namespace, traceId) : null;
2567
2567
  }
2568
2568
  recordingTraceId(toolName) {
@@ -2609,8 +2609,8 @@ var BitfabLangGraphIntegration = class {
2609
2609
  const originalInvoke = tool.invoke.bind(tool);
2610
2610
  return new Proxy(tool, { get: (target, property) => {
2611
2611
  if (property === "invoke") return async (input, ...rest) => {
2612
- const toolCallId = isRecord$2(input) && typeof input.id === "string" ? input.id : "";
2613
- const args = isRecord$2(input) && "args" in input ? input.args : input;
2612
+ const toolCallId = isRecord$3(input) && typeof input.id === "string" ? input.id : "";
2613
+ const args = isRecord$3(input) && "args" in input ? input.args : input;
2614
2614
  this.assertReplayToolResultExists(toolName, shouldMock);
2615
2615
  const traceId = this.getActiveSpan()?.traceId ?? null;
2616
2616
  const run = async () => await originalInvoke(input, ...rest);
@@ -2728,7 +2728,7 @@ function transcriptFixtureName(traceFunctionKey) {
2728
2728
  return `pi-transcript:${traceFunctionKey}`;
2729
2729
  }
2730
2730
  function isTranscriptFixture(value) {
2731
- return isRecord$1(value) && (value.method === "prompt" || value.method === "continue") && Array.isArray(value.messages);
2731
+ return isRecord$2(value) && (value.method === "prompt" || value.method === "continue") && Array.isArray(value.messages);
2732
2732
  }
2733
2733
  function conversationMessages(messages) {
2734
2734
  return messages.filter((message) => message?.role !== "system");
@@ -2788,17 +2788,17 @@ async function rethrowingKept(work) {
2788
2788
  throw error;
2789
2789
  }
2790
2790
  }
2791
- function isRecord$1(value) {
2791
+ function isRecord$2(value) {
2792
2792
  return typeof value === "object" && value !== null;
2793
2793
  }
2794
2794
  function isAgentLike(value) {
2795
- return isRecord$1(value) && typeof value.prompt === "function" && typeof value.continue === "function" && isRecord$1(value.state) && Array.isArray(value.state.messages);
2795
+ return isRecord$2(value) && typeof value.prompt === "function" && typeof value.continue === "function" && isRecord$2(value.state) && Array.isArray(value.state.messages);
2796
2796
  }
2797
2797
  function isSessionLike(value) {
2798
- return isRecord$1(value) && typeof value.prompt === "function" && isAgentLike(value.agent);
2798
+ return isRecord$2(value) && typeof value.prompt === "function" && isAgentLike(value.agent);
2799
2799
  }
2800
2800
  function isEventStream(value) {
2801
- return isRecord$1(value) && typeof value.result === "function" && typeof value[Symbol.asyncIterator] === "function";
2801
+ return isRecord$2(value) && typeof value.result === "function" && typeof value[Symbol.asyncIterator] === "function";
2802
2802
  }
2803
2803
  function failed(message) {
2804
2804
  return typeof message?.stopReason === "string" && FAILED_STOP_REASONS.has(message.stopReason);
@@ -2827,7 +2827,7 @@ function usageContext(message, model) {
2827
2827
  const modelName = message.model ?? model.id;
2828
2828
  if (typeof modelName === "string") context.model = modelName;
2829
2829
  const usage = message.usage;
2830
- if (!isRecord$1(usage)) return context;
2830
+ if (!isRecord$2(usage)) return context;
2831
2831
  const entries = {
2832
2832
  inputTokens: wholePromptTokens(usage),
2833
2833
  outputTokens: asCount(usage.output),
@@ -2838,7 +2838,7 @@ function usageContext(message, model) {
2838
2838
  return context;
2839
2839
  }
2840
2840
  function toolDeclarations(tools) {
2841
- return tools.filter(isRecord$1).map((tool) => ({
2841
+ return tools.filter(isRecord$2).map((tool) => ({
2842
2842
  name: tool.name,
2843
2843
  description: tool.description,
2844
2844
  parameters: tool.parameters
@@ -2919,7 +2919,7 @@ var BitfabPiIntegration = class {
2919
2919
  });
2920
2920
  const value = Reflect.get(target, property, proxy);
2921
2921
  if (STREAM_FN_PROPERTY_NAMES_BY_RELEASE.has(property) && typeof value === "function") return this.wrapStreamFn(value);
2922
- if (STATE_PROPERTIES.has(property) && isRecord$1(value)) return this.toolWrappingState(value);
2922
+ if (STATE_PROPERTIES.has(property) && isRecord$2(value)) return this.toolWrappingState(value);
2923
2923
  if (HOOKS_RETURNING_CONTEXT.has(property) && typeof value === "function") return this.toolWrappingHook(value);
2924
2924
  return value;
2925
2925
  } });
@@ -2943,7 +2943,7 @@ var BitfabPiIntegration = class {
2943
2943
  if (existing !== void 0) return existing;
2944
2944
  const wrapped = async (...args) => {
2945
2945
  const update = await hook(...args);
2946
- if (!isRecord$1(update) || !isRecord$1(update.context)) return update;
2946
+ if (!isRecord$2(update) || !isRecord$2(update.context)) return update;
2947
2947
  const tools = update.context.tools;
2948
2948
  if (!Array.isArray(tools)) return update;
2949
2949
  return {
@@ -3101,7 +3101,7 @@ var BitfabPiIntegration = class {
3101
3101
  return this.originalTools.get(tool) ?? tool;
3102
3102
  }
3103
3103
  wrapTool(tool) {
3104
- if (!isRecord$1(tool) || typeof tool.execute !== "function" || wrappersByAnyIntegration.has(tool)) return tool;
3104
+ if (!isRecord$2(tool) || typeof tool.execute !== "function" || wrappersByAnyIntegration.has(tool)) return tool;
3105
3105
  const existing = this.wrappedTools.get(tool);
3106
3106
  if (existing !== void 0) return existing;
3107
3107
  const execute = tool.execute;
@@ -4785,7 +4785,7 @@ const QUEUE_MESSAGE_EFFECTS = /* @__PURE__ */ new Set([
4785
4785
  "queue.tryNext",
4786
4786
  "queue.tryNextBatch"
4787
4787
  ]);
4788
- function isRecord(value) {
4788
+ function isRecord$1(value) {
4789
4789
  return typeof value === "object" && value !== null;
4790
4790
  }
4791
4791
  function readProperty(value, property) {
@@ -4814,7 +4814,7 @@ function snapshotContext(context) {
4814
4814
  if (typeof aborted === "boolean") snapshot.aborted = aborted;
4815
4815
  else {
4816
4816
  const abortSignal = readProperty(source, "abortSignal");
4817
- if (isRecord(abortSignal)) {
4817
+ if (isRecord$1(abortSignal)) {
4818
4818
  const signalAborted = readProperty(abortSignal, "aborted");
4819
4819
  if (typeof signalAborted === "boolean") snapshot.aborted = signalAborted;
4820
4820
  }
@@ -4855,7 +4855,7 @@ function fixtureName(traceFunctionKey) {
4855
4855
  }
4856
4856
  function snapshotFromReplay(traceFunctionKey, replay) {
4857
4857
  const fixture = replay.integrationFixtures?.get(fixtureName(traceFunctionKey));
4858
- if (!isRecord(fixture)) throw new BitfabError(`Trace "${traceFunctionKey}" has no Rivet context fixture. Capture a fresh trace with the Rivet integration before replaying it.`, RIVET_DOCS_URL);
4858
+ if (!isRecord$1(fixture)) throw new BitfabError(`Trace "${traceFunctionKey}" has no Rivet context fixture. Capture a fresh trace with the Rivet integration before replaying it.`, RIVET_DOCS_URL);
4859
4859
  return fixture;
4860
4860
  }
4861
4861
  var BitfabRivetIntegration = class {
@@ -4866,7 +4866,7 @@ var BitfabRivetIntegration = class {
4866
4866
  this.markedEffects = new Set(options.mockOnReplay ?? []);
4867
4867
  }
4868
4868
  withContext(context, fn) {
4869
- if (!isRecord(context)) throw new BitfabError("Rivet withContext requires a context object");
4869
+ if (!isRecord$1(context)) throw new BitfabError("Rivet withContext requires a context object");
4870
4870
  return runWithRivetContext({
4871
4871
  context,
4872
4872
  fixtureContext: createIntegrationFixtureContext(fixtureName(this.traceFunctionKey), snapshotContext(context)),
@@ -4932,7 +4932,7 @@ var BitfabRivetIntegration = class {
4932
4932
  if (!binding) return;
4933
4933
  const context = binding.context;
4934
4934
  const target = readProperty(context, group);
4935
- return isRecord(target) ? target : void 0;
4935
+ return isRecord$1(target) ? target : void 0;
4936
4936
  };
4937
4937
  const proxy = this.createMethodProxy(targetProvider, group, RIVET_GROUP_EFFECT_METHODS[group], replay);
4938
4938
  if (group !== "queue") return proxy;
@@ -4981,10 +4981,10 @@ var BitfabRivetIntegration = class {
4981
4981
  if (replay) return await callback(this.createMethodProxy(() => void 0, "db.transaction", ["execute"], replay));
4982
4982
  const context = binding?.context;
4983
4983
  const db = context ? readProperty(context, "db") : void 0;
4984
- const transaction = isRecord(db) ? readProperty(db, "transaction") : void 0;
4985
- if (!isRecord(db) || typeof transaction !== "function") throw unavailableCapability("db.transaction");
4984
+ const transaction = isRecord$1(db) ? readProperty(db, "transaction") : void 0;
4985
+ if (!isRecord$1(db) || typeof transaction !== "function") throw unavailableCapability("db.transaction");
4986
4986
  return await transaction.call(db, async (transactionDb) => {
4987
- if (!isRecord(transactionDb)) throw unavailableCapability("db.transaction.execute");
4987
+ if (!isRecord$1(transactionDb)) throw unavailableCapability("db.transaction.execute");
4988
4988
  return await callback(this.createMethodProxy(() => transactionDb, "db.transaction", ["execute"], replay));
4989
4989
  }, options);
4990
4990
  };
@@ -4995,7 +4995,7 @@ var BitfabRivetIntegration = class {
4995
4995
  return this.decorateQueueMessage(value, replay);
4996
4996
  }
4997
4997
  decorateQueueMessage(value, replay) {
4998
- if (!isRecord(value)) return value;
4998
+ if (!isRecord$1(value)) return value;
4999
4999
  const originalComplete = readProperty(value, "complete");
5000
5000
  const complete = this.createEffect("queue.message.complete", () => typeof originalComplete === "function" ? { complete: originalComplete.bind(value) } : void 0, "complete", replay);
5001
5001
  return {
@@ -5005,7 +5005,7 @@ var BitfabRivetIntegration = class {
5005
5005
  }
5006
5006
  queueCallIsCompletable(effect, args) {
5007
5007
  const options = effect === "queue.waitForNames" || (effect === "queue.next" || effect === "queue.nextBatch") && typeof args[0] === "string" ? args[1] : args[0];
5008
- return isRecord(options) && options.completable === true;
5008
+ return isRecord$1(options) && options.completable === true;
5009
5009
  }
5010
5010
  createQueueIterator(queue, options) {
5011
5011
  return { async *[Symbol.asyncIterator]() {
@@ -5197,6 +5197,56 @@ function withoutDataRecords(edit) {
5197
5197
  };
5198
5198
  }
5199
5199
  //#endregion
5200
+ //#region src/openaiAgentsUsage.ts
5201
+ const TOKEN_CONTEXT_KEYS = [
5202
+ "inputTokens",
5203
+ "outputTokens",
5204
+ "cachedInputTokens",
5205
+ "cacheReadTokens",
5206
+ "costUsd"
5207
+ ];
5208
+ function isRecord(value) {
5209
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5210
+ }
5211
+ function modelResponses(spanData) {
5212
+ const firstOutput = Array.isArray(spanData.output) ? spanData.output[0] : void 0;
5213
+ return [
5214
+ spanData,
5215
+ spanData.response,
5216
+ firstOutput
5217
+ ].filter(isRecord);
5218
+ }
5219
+ function modelCallModel(spanData) {
5220
+ return modelResponses(spanData).map((candidate) => candidate.model).find((model) => typeof model === "string" && model !== "");
5221
+ }
5222
+ function modelCallProvider(spanData, call) {
5223
+ const baseUrl = isRecord(spanData.model_config) ? spanData.model_config.base_url : void 0;
5224
+ if (isOpenRouterBaseUrl(baseUrl)) return "openrouter";
5225
+ return isAnthropicBaseUrl(baseUrl) ? "anthropic" : call.provider;
5226
+ }
5227
+ function hasTokenUsage(context) {
5228
+ return isRecord(context) && TOKEN_CONTEXT_KEYS.some((key) => typeof context[key] === "number" && Number.isFinite(context[key]));
5229
+ }
5230
+ function openAiAgentsUsageContext(spanData) {
5231
+ if (!isRecord(spanData) || !MODEL_CALL_SPAN_TYPES.has(String(spanData.type))) return null;
5232
+ const response = modelResponses(spanData).find((candidate) => isRecord(candidate.usage));
5233
+ if (response === void 0 || !isRecord(response.usage)) return null;
5234
+ const call = clientCallProviderForUsage(response.usage);
5235
+ const usage = Object.fromEntries(Object.entries(call.usage({ model: modelCallModel(spanData) }, response)).filter(([, value]) => value !== void 0));
5236
+ if (usage.inputTokens === void 0 && usage.outputTokens === void 0) return null;
5237
+ return {
5238
+ provider: modelCallProvider(spanData, call),
5239
+ ...usage
5240
+ };
5241
+ }
5242
+ function addOpenAiAgentsUsageContext(spanData) {
5243
+ const existing = Array.isArray(spanData.contexts) ? spanData.contexts : [];
5244
+ if (existing.some(hasTokenUsage)) return;
5245
+ const context = openAiAgentsUsageContext(spanData);
5246
+ if (context === null) return;
5247
+ spanData.contexts = [...existing, context];
5248
+ }
5249
+ //#endregion
5200
5250
  //#region src/tracing.ts
5201
5251
  var BitfabOpenAITracingProcessor = class {
5202
5252
  getCanonicalTraceId(sourceTraceId) {
@@ -5376,6 +5426,7 @@ var BitfabOpenAITracingProcessor = class {
5376
5426
  const [serializedSpan, exportErrors] = this.exportSpan(span);
5377
5427
  errors.push(...exportErrors);
5378
5428
  this.extractSpanInputResponse(span, serializedSpan, errors);
5429
+ addOpenAiAgentsUsageContext(serializedSpan.span_data);
5379
5430
  this.applySpanOverrides(serializedSpan, span.traceId ?? "");
5380
5431
  const payload = this.buildSpanPayload(serializedSpan, errors);
5381
5432
  const canonicalTraceId = span.traceId ? this.getCanonicalTraceId(span.traceId) : void 0;
@@ -6573,6 +6624,9 @@ var Bitfab = class {
6573
6624
  wrapGemini(method, options) {
6574
6625
  return this.wrapClientCall(GEMINI, method, options, unboundName(method) ?? "generateContent");
6575
6626
  }
6627
+ wrapGeminiEmbeddings(method, options) {
6628
+ return this.wrapClientCall(GEMINI_EMBEDDINGS, method, options, unboundName(method) ?? "embedContent");
6629
+ }
6576
6630
  wrapClientCall(provider, method, options, name) {
6577
6631
  const wrappedFn = async (...args) => {
6578
6632
  const span = getCurrentSpan();
@@ -7237,7 +7291,7 @@ var Bitfab = class {
7237
7291
  await runWithSeedContext({ traceId }, async () => target(...args));
7238
7292
  } finally {
7239
7293
  try {
7240
- const { flushTraces } = await import("./http-BLyaXOOY.js").then((n) => n.a);
7294
+ const { flushTraces } = await import("./http-DoS4PUm6.js").then((n) => n.a);
7241
7295
  await flushTraces(3e4);
7242
7296
  } finally {
7243
7297
  unrecorded = activeTraceStates.delete(traceId);
@@ -7353,6 +7407,9 @@ var BitfabFunction = class {
7353
7407
  wrapGemini(method, options) {
7354
7408
  return this.client.wrapGemini(method, options);
7355
7409
  }
7410
+ wrapGeminiEmbeddings(method, options) {
7411
+ return this.client.wrapGeminiEmbeddings(method, options);
7412
+ }
7356
7413
  };
7357
7414
  //#endregion
7358
7415
  //#region src/finalizers.ts
@@ -7455,7 +7512,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
7455
7512
  metadata: seedCase.metadata,
7456
7513
  sessionId: seedCase.sessionId
7457
7514
  }));
7458
- const { flushTraces } = await import("./http-BLyaXOOY.js").then((n) => n.a);
7515
+ const { flushTraces } = await import("./http-DoS4PUm6.js").then((n) => n.a);
7459
7516
  await flushTraces(3e4);
7460
7517
  return {
7461
7518
  pipeline,
@@ -7472,4 +7529,4 @@ function resolveTraceFunctionKey(registration) {
7472
7529
  //#endregion
7473
7530
  export { VerdictsClient as A, OrganizationMembersClient as C, BitfabLangGraphCallbackHandler as D, BitfabLangGraphIntegration as E, GraderRerunTimeoutError as F, BitfabClaudeAgentHandler as I, DEFAULT_SERVICE_URL as L, SUPPORTED_PROVIDERS as M, DatasetsClient as N, GradersClient as O, GraderRerunError as P, AssertionCategoriesClient as R, BitfabPiIntegration as S, NO_MOCK_OVERRIDE as T, BITFAB_PROGRESS_PREFIX as _, Bitfab as a, reportReplayProgress as b, getCurrentSpan as c, BitfabOpenAITracingProcessor as d, AssertionGenerationError as f, BitfabRivetIntegration as g, SpansClient as h, finalizers as i, ExperimentsClient as j, LabelsClient as k, getCurrentTrace as l, TracesClient as m, reseedFromRegistry as n, BitfabFunction as o, AssertionGenerationTimeoutError as p, seedFromRegistry as r, getCurrentReplayBranch as s, defineReplayRegistry as t, BitfabVercelAiHandler as u, DbBranchReplayError as v, BitfabOpenAIAgentHandler as w, serializeReplayResult as x, ReplayError as y, CategoriesClient as z };
7474
7531
 
7475
- //# sourceMappingURL=src-B_e7xNzm.js.map
7532
+ //# sourceMappingURL=src-Cm9Jdgfh.js.map