@bitfab/sdk 0.74.6 → 0.74.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.
package/dist/replayCli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as runRegistryMain, c as runSeedCli, i as runIfEntrypoint, n as parseRegistryCommandArgs, o as checkReplayCliArgs, r as resolveRegistry, s as runReplayCli, t as importRegistry } from "./registryCommand-DdNn4qGL.js";
2
+ import { a as runRegistryMain, c as runSeedCli, i as runIfEntrypoint, n as parseRegistryCommandArgs, o as checkReplayCliArgs, r as resolveRegistry, s as runReplayCli, t as importRegistry } from "./registryCommand-DdE8cNOX.js";
3
3
  //#region src/cloudReplayCli.ts
4
4
  const CLOUD_REPLAY_HINT = "Add --cloud to run the same replay on GitHub Actions; bitfab-replay --cloud --help explains it.";
5
5
  function isCloudReplayCommand(argv) {
package/dist/seedCli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as runRegistryMain, c as runSeedCli, i as runIfEntrypoint, n as parseRegistryCommandArgs, r as resolveRegistry, t as importRegistry } from "./registryCommand-DdNn4qGL.js";
2
+ import { a as runRegistryMain, c as runSeedCli, i as runIfEntrypoint, n as parseRegistryCommandArgs, r as resolveRegistry, t as importRegistry } from "./registryCommand-DdE8cNOX.js";
3
3
  //#region src/seedCli.ts
4
4
  const USAGE = "Usage: bitfab-seed --registry <path> <pipeline> --from-trace <id>[,<id>...]\n bitfab-seed --registry <path> <pipeline> --cases <cases.jsonl> [--run]\nRun bitfab-seed --registry <path> <pipeline> --help for details.";
5
5
  async function runSeedCommand(argv, io = {}, importer = importRegistry) {
@@ -1,5 +1,5 @@
1
1
  const require_bamlPeer = require("./bamlPeer-5Ohpq8q9.cjs");
2
- const require_http = require("./http-C_f9vk_C.cjs");
2
+ const require_http = require("./http-sX8XbCY8.cjs");
3
3
  const require_autoTrace = require("./autoTrace-DPWV1Xzr.cjs");
4
4
  const require_optionalPeer = require("./optionalPeer-CUH756lt.cjs");
5
5
  let superjson = require("superjson");
@@ -315,7 +315,7 @@ function finalizeSpanPayload(payload, extraDropped) {
315
315
  function finalizeTracePayload(payload) {
316
316
  const { safe, dropped } = toJsonSafeReport(payload);
317
317
  const collapsed = safe === null || typeof safe !== "object" || Array.isArray(safe);
318
- const result = collapsed ? rebuildEnvelope(payload, "externalTrace", safe) : safe;
318
+ const result = collapsed ? rebuildEnvelope(payload, "rawTrace", safe) : safe;
319
319
  if (dropped.length > 0 || collapsed) {
320
320
  const names = dropped.length > 0 ? [...new Set(dropped)].sort().join(", ") : "trace";
321
321
  require_autoTrace.warnOnce(`finalizeTrace:${names.replace(/\d+/g, "N")}`, `a trace held non-serializable value(s) (${names}); they were captured as placeholders, so the trace may not be replayable.`);
@@ -501,7 +501,7 @@ var BitfabClaudeAgentHandler = class {
501
501
  rawSpan
502
502
  }, spanInfo.dropped);
503
503
  try {
504
- this.httpClient.sendExternalSpan(finalized);
504
+ this.httpClient.sendSpanPayload(finalized);
505
505
  } catch {}
506
506
  }
507
507
  sendTraceCompletion(endedAt, metadata) {
@@ -510,22 +510,22 @@ var BitfabClaudeAgentHandler = class {
510
510
  const completed = this.activeContext === null;
511
511
  const traceId = this.traceId;
512
512
  this.traceId = null;
513
- const externalTrace = {
513
+ const rawTrace = {
514
514
  id: traceId,
515
515
  started_at: this.traceStartedAt ?? nowIso$1(),
516
516
  ended_at: endedAt ?? nowIso$1()
517
517
  };
518
- if (metadata) externalTrace.metadata = metadata;
518
+ if (metadata) rawTrace.metadata = metadata;
519
519
  const finalized = finalizeTracePayload({
520
520
  id: traceId,
521
521
  type: "sdk-function",
522
522
  source: "typescript-sdk-claude-agent-sdk",
523
523
  traceFunctionKey: this.traceFunctionKey,
524
- externalTrace,
524
+ rawTrace,
525
525
  completed
526
526
  });
527
527
  try {
528
- this.httpClient.sendExternalTrace(finalized);
528
+ this.httpClient.sendTracePayload(finalized);
529
529
  } catch {}
530
530
  }
531
531
  async preToolUseHook(inputData, toolUseId, _context) {
@@ -1968,7 +1968,7 @@ var BitfabLangGraphCallbackHandler = class {
1968
1968
  rawSpan
1969
1969
  }, spanInfo.dropped);
1970
1970
  try {
1971
- this.httpClient.sendExternalSpan(finalized);
1971
+ this.httpClient.sendSpanPayload(finalized);
1972
1972
  } catch {}
1973
1973
  }
1974
1974
  sendTraceCompletion(rootSpan, activeContext) {
@@ -1979,7 +1979,7 @@ var BitfabLangGraphCallbackHandler = class {
1979
1979
  type: "sdk-function",
1980
1980
  source: "typescript-sdk-langgraph",
1981
1981
  traceFunctionKey: this.traceFunctionKey,
1982
- externalTrace: {
1982
+ rawTrace: {
1983
1983
  id: rootSpan.traceId,
1984
1984
  started_at: rootSpan.startedAt,
1985
1985
  ended_at: rootSpan.endedAt ?? nowIso()
@@ -1987,7 +1987,7 @@ var BitfabLangGraphCallbackHandler = class {
1987
1987
  completed
1988
1988
  });
1989
1989
  try {
1990
- this.httpClient.sendExternalTrace(finalized);
1990
+ this.httpClient.sendTracePayload(finalized);
1991
1991
  } catch {}
1992
1992
  }
1993
1993
  sendTraceStart(rootSpan) {
@@ -1997,14 +1997,14 @@ var BitfabLangGraphCallbackHandler = class {
1997
1997
  type: "sdk-function",
1998
1998
  source: "typescript-sdk-langgraph",
1999
1999
  traceFunctionKey: this.traceFunctionKey,
2000
- externalTrace: {
2000
+ rawTrace: {
2001
2001
  id: rootSpan.traceId,
2002
2002
  started_at: rootSpan.startedAt
2003
2003
  },
2004
2004
  completed: false
2005
2005
  });
2006
2006
  try {
2007
- this.httpClient.sendExternalTrace(finalized);
2007
+ this.httpClient.sendTracePayload(finalized);
2008
2008
  } catch {}
2009
2009
  }
2010
2010
  async handleChainStart(chain, inputs, runId, parentRunIdOrRunType, tags, metadata, runTypeOrRunName, runNameOrParentRunId) {
@@ -4094,7 +4094,7 @@ function buildMockTree(rootNode) {
4094
4094
  counters.set(counterKey, index + 1);
4095
4095
  spans.set(`${counterKey}:${index}`, {
4096
4096
  sourceSpanId: node.sourceSpanId,
4097
- externalSpanId: node.externalSpanId,
4097
+ spanId: node.spanId ?? node.externalSpanId,
4098
4098
  output: node.output,
4099
4099
  outputMeta: node.outputMeta
4100
4100
  });
@@ -4138,7 +4138,7 @@ async function processItem(httpClient, serverItem, fn, experimentId, mockStrateg
4138
4138
  if (serverItem.selectiveReplayPlan === void 0) throw new require_http.BitfabError("Server did not return a selective replay plan. Update the server or disable experimentalSelectiveReplay.");
4139
4139
  selectiveReplay = new SelectiveReplayRuntime(serverItem.selectiveReplayPlan, selectiveOptions);
4140
4140
  }
4141
- const span = await httpClient.getExternalSpan(originalSpanId, { view: "replay" });
4141
+ const span = await httpClient.getSpanRaw(originalSpanId, { view: "replay" });
4142
4142
  const spanData = span.rawData?.span_data ?? {};
4143
4143
  inputs = deserializeInputs(spanData);
4144
4144
  originalOutput = deserializeOutput(spanData);
@@ -4169,11 +4169,11 @@ async function processItem(httpClient, serverItem, fn, experimentId, mockStrateg
4169
4169
  mockTree = { spans: /* @__PURE__ */ new Map() };
4170
4170
  }
4171
4171
  const outputCache = /* @__PURE__ */ new Map();
4172
- const fetchSpanOutput = mockTree && !includeOutputs ? (externalSpanId) => {
4173
- let pending = outputCache.get(externalSpanId);
4172
+ const fetchSpanOutput = mockTree && !includeOutputs ? (spanId) => {
4173
+ let pending = outputCache.get(spanId);
4174
4174
  if (!pending) {
4175
- pending = httpClient.getExternalSpan(externalSpanId, { view: "replay" }).then((s) => deserializeOutput(s.rawData?.span_data ?? {}));
4176
- outputCache.set(externalSpanId, pending);
4175
+ pending = httpClient.getSpanRaw(spanId, { view: "replay" }).then((s) => deserializeOutput(s.rawData?.span_data ?? {}));
4176
+ outputCache.set(spanId, pending);
4177
4177
  }
4178
4178
  return pending;
4179
4179
  } : void 0;
@@ -4206,7 +4206,7 @@ async function processItem(httpClient, serverItem, fn, experimentId, mockStrateg
4206
4206
  experimentId,
4207
4207
  traceId: replayedTraceId,
4208
4208
  inputSourceSpanId: span.id,
4209
- inputSourceTraceId: span.externalTraceId,
4209
+ inputSourceTraceId: span.traceId ?? span.externalTraceId,
4210
4210
  sourceBitfabTraceId: originalTraceId,
4211
4211
  replayAttempt: attempt,
4212
4212
  mockTree,
@@ -5319,11 +5319,11 @@ var BitfabOpenAITracingProcessor = class {
5319
5319
  try {
5320
5320
  const traceData = trace.toJSON();
5321
5321
  if (options.sourceTraceId) traceData.id = options.sourceTraceId;
5322
- this.httpClient.sendExternalTrace({
5322
+ this.httpClient.sendTracePayload({
5323
5323
  ...options.id && { id: options.id },
5324
5324
  type: "openai",
5325
5325
  source: "typescript-sdk-openai-tracing",
5326
- externalTrace: traceData,
5326
+ rawTrace: traceData,
5327
5327
  completed: options.completed ?? false
5328
5328
  });
5329
5329
  } catch {}
@@ -5405,7 +5405,7 @@ var BitfabOpenAITracingProcessor = class {
5405
5405
  const payload = this.buildSpanPayload(serializedSpan, errors);
5406
5406
  const canonicalTraceId = span.traceId ? this.getCanonicalTraceId(span.traceId) : void 0;
5407
5407
  if (canonicalTraceId) payload.traceId = canonicalTraceId;
5408
- this.httpClient.sendExternalSpan(payload);
5408
+ this.httpClient.sendSpanPayload(payload);
5409
5409
  }
5410
5410
  };
5411
5411
  //#endregion
@@ -6025,9 +6025,9 @@ var Bitfab = class {
6025
6025
  getSimulationPlan: () => this.httpClient.getSimulationPlan(),
6026
6026
  canRead: () => this.canReadSimulationPlan()
6027
6027
  }, config.simulationPlan ?? true);
6028
- this.httpClient.externalSpanTransform = (payload, submit, drop) => this.applySimulationPlan(payload, submit, drop);
6029
- this.httpClient.externalTraceTransform = (payload, submit) => this.simulationPlan.sendTrace(payload, submit);
6030
- this.httpClient.releaseHeldExternalSpans = (timeoutMs) => this.simulationPlan.release(timeoutMs);
6028
+ this.httpClient.spanPayloadTransform = (payload, submit, drop) => this.applySimulationPlan(payload, submit, drop);
6029
+ this.httpClient.tracePayloadTransform = (payload, submit) => this.simulationPlan.sendTrace(payload, submit);
6030
+ this.httpClient.releaseHeldSpans = (timeoutMs) => this.simulationPlan.release(timeoutMs);
6031
6031
  this.httpClient.stopSimulationPlan = () => this.simulationPlan.stop();
6032
6032
  if (this.findApiKey(false) !== void 0) this.simulationPlan.refresh();
6033
6033
  this.datasets = new DatasetsClient(this.httpClient);
@@ -6841,7 +6841,7 @@ var Bitfab = class {
6841
6841
  })();
6842
6842
  };
6843
6843
  const resolveRecordedOutput = () => {
6844
- if (!(mockSpan?.output !== void 0 || mockSpan?.outputMeta !== void 0) && replayCtxForMock.fetchSpanOutput && mockSpan?.externalSpanId) return replayCtxForMock.fetchSpanOutput(mockSpan.externalSpanId);
6844
+ if (!(mockSpan?.output !== void 0 || mockSpan?.outputMeta !== void 0) && replayCtxForMock.fetchSpanOutput && mockSpan?.spanId) return replayCtxForMock.fetchSpanOutput(mockSpan.spanId);
6845
6845
  if (!mockSpan) return Promise.reject(new require_http.BitfabError(`No recorded span to source output for "${traceFunctionKey}".`));
6846
6846
  let output = mockSpan.output;
6847
6847
  if (mockSpan.outputMeta !== void 0 && mockSpan.outputMeta !== null) output = deserializeValue({
@@ -7007,12 +7007,12 @@ var Bitfab = class {
7007
7007
  accessed: params.dbSnapshotUsage.accessed,
7008
7008
  ...params.dbSnapshotUsage.timings && { timings: params.dbSnapshotUsage.timings }
7009
7009
  };
7010
- this.httpClient.sendExternalTrace({
7010
+ this.httpClient.sendTracePayload({
7011
7011
  id: params.traceId,
7012
7012
  type: "sdk-function",
7013
7013
  source: "typescript-sdk-function",
7014
7014
  traceFunctionKey: params.traceFunctionKey,
7015
- externalTrace: rawTrace,
7015
+ rawTrace,
7016
7016
  completed: true,
7017
7017
  ...params.dropped && { dropped: true },
7018
7018
  ...params.sessionId && { sessionId: params.sessionId },
@@ -7038,7 +7038,7 @@ var Bitfab = class {
7038
7038
  const buildsContent = params.captureContent && !contentOff;
7039
7039
  const serializedInputs = buildsContent ? serializeValue(params.inputs) : void 0;
7040
7040
  const serializedResult = buildsContent ? serializeValue(params.result) : void 0;
7041
- const externalSpan = {
7041
+ const rawSpan = {
7042
7042
  id: params.spanId,
7043
7043
  trace_id: params.traceId,
7044
7044
  started_at: params.startedAt,
@@ -7085,10 +7085,10 @@ var Bitfab = class {
7085
7085
  ...contentOff && { ["content_off_by_simulation_plan"]: true }
7086
7086
  }
7087
7087
  };
7088
- if (params.parentSpanId) externalSpan.parent_id = params.parentSpanId;
7089
- if (params.nearestCapturedAncestorSpanId !== void 0 && params.nearestCapturedAncestorSpanId !== null && params.nearestCapturedAncestorSpanId !== params.parentSpanId) externalSpan.nearest_captured_ancestor_id = params.nearestCapturedAncestorSpanId;
7090
- if (params.inputSourceSpanId) externalSpan.input_source_span_id = params.inputSourceSpanId;
7091
- this.httpClient.sendExternalSpan({
7088
+ if (params.parentSpanId) rawSpan.parent_id = params.parentSpanId;
7089
+ if (params.nearestCapturedAncestorSpanId !== void 0 && params.nearestCapturedAncestorSpanId !== null && params.nearestCapturedAncestorSpanId !== params.parentSpanId) rawSpan.nearest_captured_ancestor_id = params.nearestCapturedAncestorSpanId;
7090
+ if (params.inputSourceSpanId) rawSpan.input_source_span_id = params.inputSourceSpanId;
7091
+ this.httpClient.sendSpanPayload({
7092
7092
  id: params.spanId,
7093
7093
  traceId: params.traceId,
7094
7094
  type: "sdk-function",
@@ -7097,7 +7097,7 @@ var Bitfab = class {
7097
7097
  traceFunctionKey: params.traceFunctionKey,
7098
7098
  ...params.rootTraceFunctionKey !== void 0 && { ["rootTraceFunctionKey"]: params.rootTraceFunctionKey },
7099
7099
  ...params.declaredNode === true && { ["declaredNode"]: true },
7100
- rawSpan: externalSpan,
7100
+ rawSpan,
7101
7101
  ...params.experimentId !== void 0 && require_http.experimentIdWireFields(params.experimentId),
7102
7102
  ...params.mocked && { mocked: true },
7103
7103
  ...params.mockTarget && { mockTarget: params.mockTarget },
@@ -7214,7 +7214,7 @@ var Bitfab = class {
7214
7214
  await runWithSeedContext({ traceId }, async () => target(...args));
7215
7215
  } finally {
7216
7216
  try {
7217
- const { flushTraces } = await Promise.resolve().then(() => require("./http-C_f9vk_C.cjs")).then((n) => n.http_exports);
7217
+ const { flushTraces } = await Promise.resolve().then(() => require("./http-sX8XbCY8.cjs")).then((n) => n.http_exports);
7218
7218
  await flushTraces(3e4);
7219
7219
  } finally {
7220
7220
  unrecorded = activeTraceStates.delete(traceId);
@@ -7420,7 +7420,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
7420
7420
  metadata: seedCase.metadata,
7421
7421
  sessionId: seedCase.sessionId
7422
7422
  }));
7423
- const { flushTraces } = await Promise.resolve().then(() => require("./http-C_f9vk_C.cjs")).then((n) => n.http_exports);
7423
+ const { flushTraces } = await Promise.resolve().then(() => require("./http-sX8XbCY8.cjs")).then((n) => n.http_exports);
7424
7424
  await flushTraces(3e4);
7425
7425
  return {
7426
7426
  pipeline,
@@ -7670,4 +7670,4 @@ Object.defineProperty(exports, "serializeReplayResult", {
7670
7670
  }
7671
7671
  });
7672
7672
 
7673
- //# sourceMappingURL=src-atyS216N.cjs.map
7673
+ //# sourceMappingURL=src-CmcfwC6Z.cjs.map