bitfab 0.54.9 → 0.54.11

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 (35) hide show
  1. package/dist/{chunk-5EW5MV2Z.js → chunk-2C7M3Y3H.js} +3 -3
  2. package/dist/chunk-2C7M3Y3H.js.map +1 -0
  3. package/dist/{chunk-7HXFT6JR.js → chunk-FMUJONTQ.js} +6 -4
  4. package/dist/chunk-FMUJONTQ.js.map +1 -0
  5. package/dist/{chunk-VT5IUVBY.js → chunk-G4LWALQ7.js} +85 -40
  6. package/dist/chunk-G4LWALQ7.js.map +1 -0
  7. package/dist/{chunk-UKKR2PF4.js → chunk-MEJOPEKV.js} +710 -16
  8. package/dist/chunk-MEJOPEKV.js.map +1 -0
  9. package/dist/{chunk-TOCJX6OP.js → chunk-RUBVHBIK.js} +4 -3
  10. package/dist/chunk-RUBVHBIK.js.map +1 -0
  11. package/dist/{http-WQ6YWRTW.js → http-AXPT27DO.js} +2 -2
  12. package/dist/{http-HYJYQTX2.js → http-JQN2LHHF.js} +2 -2
  13. package/dist/index.cjs +801 -47
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +130 -2
  16. package/dist/index.d.ts +130 -2
  17. package/dist/index.js +5 -3
  18. package/dist/node.cjs +801 -47
  19. package/dist/node.cjs.map +1 -1
  20. package/dist/node.d.cts +1 -1
  21. package/dist/node.d.ts +1 -1
  22. package/dist/node.js +5 -3
  23. package/dist/node.js.map +1 -1
  24. package/dist/{replay-MISWCCCG.js → replay-DOG4KV7I.js} +3 -3
  25. package/dist/replayCli.js +2 -2
  26. package/dist/seedCli.js +2 -2
  27. package/package.json +1 -1
  28. package/dist/chunk-5EW5MV2Z.js.map +0 -1
  29. package/dist/chunk-7HXFT6JR.js.map +0 -1
  30. package/dist/chunk-TOCJX6OP.js.map +0 -1
  31. package/dist/chunk-UKKR2PF4.js.map +0 -1
  32. package/dist/chunk-VT5IUVBY.js.map +0 -1
  33. /package/dist/{http-HYJYQTX2.js.map → http-AXPT27DO.js.map} +0 -0
  34. /package/dist/{http-WQ6YWRTW.js.map → http-JQN2LHHF.js.map} +0 -0
  35. /package/dist/{replay-MISWCCCG.js.map → replay-DOG4KV7I.js.map} +0 -0
package/dist/index.cjs CHANGED
@@ -51,7 +51,7 @@ var __version__, __packageName__;
51
51
  var init_version_generated = __esm({
52
52
  "src/version.generated.ts"() {
53
53
  "use strict";
54
- __version__ = "0.54.9";
54
+ __version__ = "0.54.11";
55
55
  __packageName__ = "bitfab";
56
56
  }
57
57
  });
@@ -77,20 +77,20 @@ var init_traceCompletion = __esm({
77
77
  this.closed = /* @__PURE__ */ new Map();
78
78
  }
79
79
  state(traceId) {
80
- let state = this.traces.get(traceId);
81
- if (state === void 0) {
82
- state = { spanIds: /* @__PURE__ */ new Set(), active: /* @__PURE__ */ new Set() };
83
- this.traces.set(traceId, state);
80
+ let state2 = this.traces.get(traceId);
81
+ if (state2 === void 0) {
82
+ state2 = { spanIds: /* @__PURE__ */ new Set(), active: /* @__PURE__ */ new Set() };
83
+ this.traces.set(traceId, state2);
84
84
  }
85
- return state;
85
+ return state2;
86
86
  }
87
87
  start(traceId, spanId) {
88
88
  if (this.closed.has(traceId)) {
89
89
  return;
90
90
  }
91
- const state = this.state(traceId);
92
- state.spanIds.add(spanId);
93
- state.active.add(spanId);
91
+ const state2 = this.state(traceId);
92
+ state2.spanIds.add(spanId);
93
+ state2.active.add(spanId);
94
94
  }
95
95
  open(traceId) {
96
96
  if (!this.closed.has(traceId)) {
@@ -106,24 +106,24 @@ var init_traceCompletion = __esm({
106
106
  }
107
107
  }
108
108
  end(traceId, spanId) {
109
- const state = this.traces.get(traceId);
110
- if (state !== void 0) {
111
- state.active.delete(spanId);
112
- this.drain(traceId, state);
109
+ const state2 = this.traces.get(traceId);
110
+ if (state2 !== void 0) {
111
+ state2.active.delete(spanId);
112
+ this.drain(traceId, state2);
113
113
  }
114
114
  }
115
115
  abort(traceId, spanId) {
116
- const state = this.traces.get(traceId);
117
- if (state === void 0) {
116
+ const state2 = this.traces.get(traceId);
117
+ if (state2 === void 0) {
118
118
  return;
119
119
  }
120
- state.active.delete(spanId);
121
- state.spanIds.delete(spanId);
122
- if (state.active.size === 0 && state.spanIds.size === 0 && state.complete === void 0) {
120
+ state2.active.delete(spanId);
121
+ state2.spanIds.delete(spanId);
122
+ if (state2.active.size === 0 && state2.spanIds.size === 0 && state2.complete === void 0) {
123
123
  this.traces.delete(traceId);
124
124
  return;
125
125
  }
126
- this.drain(traceId, state);
126
+ this.drain(traceId, state2);
127
127
  }
128
128
  close(traceId, complete, dropped = false) {
129
129
  const count = this.closed.get(traceId);
@@ -131,29 +131,29 @@ var init_traceCompletion = __esm({
131
131
  complete(count);
132
132
  return;
133
133
  }
134
- const state = this.traces.get(traceId);
135
- if (state === void 0) {
134
+ const state2 = this.traces.get(traceId);
135
+ if (state2 === void 0) {
136
136
  return;
137
137
  }
138
- state.complete = complete;
138
+ state2.complete = complete;
139
139
  if (dropped) {
140
- state.active.clear();
140
+ state2.active.clear();
141
141
  }
142
- this.drain(traceId, state);
142
+ this.drain(traceId, state2);
143
143
  }
144
- drain(traceId, state) {
145
- if (state.active.size !== 0 || state.complete === void 0) {
144
+ drain(traceId, state2) {
145
+ if (state2.active.size !== 0 || state2.complete === void 0) {
146
146
  return;
147
147
  }
148
148
  this.traces.delete(traceId);
149
- this.closed.set(traceId, state.spanIds.size);
149
+ this.closed.set(traceId, state2.spanIds.size);
150
150
  if (this.closed.size > 1024) {
151
151
  const oldest = this.closed.keys().next().value;
152
152
  if (oldest !== void 0) {
153
153
  this.closed.delete(oldest);
154
154
  }
155
155
  }
156
- state.complete(state.spanIds.size);
156
+ state2.complete(state2.spanIds.size);
157
157
  }
158
158
  };
159
159
  }
@@ -404,8 +404,8 @@ function text(value) {
404
404
  const trimmed = value?.trim();
405
405
  return trimmed ? trimmed : null;
406
406
  }
407
- function isEmptyGitState(state) {
408
- return Object.values(state).every((value) => value === null);
407
+ function isEmptyGitState(state2) {
408
+ return Object.values(state2).every((value) => value === null);
409
409
  }
410
410
  async function resolveGitState(cwd) {
411
411
  const git = await gitRunner({
@@ -426,14 +426,14 @@ async function resolveGitState(cwd) {
426
426
  if (!root) {
427
427
  return null;
428
428
  }
429
- const state = {
429
+ const state2 = {
430
430
  githubEmail: text(email),
431
431
  branch: text(branch),
432
432
  commitSha: sha(commitSha),
433
433
  baseSha: sha(baseSha),
434
434
  experimentSha: await resolveWorkingTreeSha(run, root.trim())
435
435
  };
436
- return isEmptyGitState(state) ? null : state;
436
+ return isEmptyGitState(state2) ? null : state2;
437
437
  }
438
438
  async function resolveWorkingTreeSha(run, root) {
439
439
  let indexPath;
@@ -836,8 +836,8 @@ function encodePayloadBody(payload) {
836
836
  const marker = { error: `payload_serialize_failed: ${message}` };
837
837
  return { body: JSON.stringify(marker), dropped, value: marker };
838
838
  }
839
- const isRecord4 = typeof sanitized === "object" && sanitized !== null && !Array.isArray(sanitized);
840
- if (dropped.length > 0 && isRecord4) {
839
+ const isRecord6 = typeof sanitized === "object" && sanitized !== null && !Array.isArray(sanitized);
840
+ if (dropped.length > 0 && isRecord6) {
841
841
  const obj = sanitized;
842
842
  const existing = Array.isArray(obj.errors) ? obj.errors : [];
843
843
  obj.errors = [
@@ -854,7 +854,7 @@ function encodePayloadBody(payload) {
854
854
  return {
855
855
  body: JSON.stringify(sanitized),
856
856
  dropped,
857
- value: isRecord4 ? sanitized : void 0
857
+ value: isRecord6 ? sanitized : void 0
858
858
  };
859
859
  }
860
860
  }
@@ -956,13 +956,15 @@ var init_spanOrigin = __esm({
956
956
  "openai-agents",
957
957
  "langgraph",
958
958
  "claude-agent-sdk",
959
- "vercel-ai"
959
+ "vercel-ai",
960
+ "rivet"
960
961
  ];
961
962
  FRAMEWORK_INSTRUMENTATIONS = [
962
963
  "openai-agents",
963
964
  "langgraph",
964
965
  "claude-agent-sdk",
965
- "vercel-ai"
966
+ "vercel-ai",
967
+ "rivet"
966
968
  ];
967
969
  FRAMEWORK_INSTRUMENTATION_SET = new Set(
968
970
  FRAMEWORK_INSTRUMENTATIONS
@@ -3466,6 +3468,55 @@ var init_codeChange = __esm({
3466
3468
  }
3467
3469
  });
3468
3470
 
3471
+ // src/integrationFixture.ts
3472
+ function isRecord4(value) {
3473
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3474
+ }
3475
+ function createIntegrationFixtureContext(name, value) {
3476
+ const serialized = serializeValue(value);
3477
+ return {
3478
+ [INTEGRATION_FIXTURE_CONTEXT_KEY]: {
3479
+ version: INTEGRATION_FIXTURE_VERSION,
3480
+ name,
3481
+ value: serialized.json,
3482
+ ...serialized.meta !== void 0 && { valueMeta: serialized.meta }
3483
+ }
3484
+ };
3485
+ }
3486
+ function extractIntegrationFixtures(spanData) {
3487
+ const contexts = spanData.contexts;
3488
+ if (!Array.isArray(contexts)) {
3489
+ return void 0;
3490
+ }
3491
+ const fixtures = /* @__PURE__ */ new Map();
3492
+ for (const context of contexts) {
3493
+ if (!isRecord4(context)) {
3494
+ continue;
3495
+ }
3496
+ const fixture = context[INTEGRATION_FIXTURE_CONTEXT_KEY];
3497
+ if (!isRecord4(fixture) || fixture.version !== INTEGRATION_FIXTURE_VERSION || typeof fixture.name !== "string") {
3498
+ continue;
3499
+ }
3500
+ fixtures.set(
3501
+ fixture.name,
3502
+ deserializeValue({
3503
+ json: fixture.value,
3504
+ ...fixture.valueMeta !== void 0 && { meta: fixture.valueMeta }
3505
+ })
3506
+ );
3507
+ }
3508
+ return fixtures.size > 0 ? fixtures : void 0;
3509
+ }
3510
+ var INTEGRATION_FIXTURE_CONTEXT_KEY, INTEGRATION_FIXTURE_VERSION;
3511
+ var init_integrationFixture = __esm({
3512
+ "src/integrationFixture.ts"() {
3513
+ "use strict";
3514
+ init_serialize();
3515
+ INTEGRATION_FIXTURE_CONTEXT_KEY = "__bitfabIntegrationFixture";
3516
+ INTEGRATION_FIXTURE_VERSION = 1;
3517
+ }
3518
+ });
3519
+
3469
3520
  // src/replay.ts
3470
3521
  var replay_exports = {};
3471
3522
  __export(replay_exports, {
@@ -3690,6 +3741,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
3690
3741
  const spanData = span.rawData?.span_data ?? {};
3691
3742
  inputs = deserializeInputs(spanData);
3692
3743
  originalOutput = deserializeOutput(spanData);
3744
+ const integrationFixtures = extractIntegrationFixtures(spanData);
3693
3745
  if (adaptInputs) {
3694
3746
  const originalMetadata = serverItem.originalMetadata;
3695
3747
  inputs = adaptInputs(inputs, {
@@ -3781,6 +3833,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
3781
3833
  mockStrategy,
3782
3834
  mockOverrides: hasOverrides ? resolvedOverrides : void 0,
3783
3835
  fetchSpanOutput,
3836
+ integrationFixtures,
3784
3837
  dbBranchLease: lease,
3785
3838
  dbBranchTimings
3786
3839
  },
@@ -4261,6 +4314,7 @@ var init_replay = __esm({
4261
4314
  init_codeChange();
4262
4315
  init_errors();
4263
4316
  init_http();
4317
+ init_integrationFixture();
4264
4318
  init_mockOverride();
4265
4319
  init_randomUuid();
4266
4320
  init_replayContext();
@@ -4304,6 +4358,7 @@ __export(index_exports, {
4304
4358
  BitfabLangGraphIntegration: () => BitfabLangGraphIntegration,
4305
4359
  BitfabOpenAIAgentHandler: () => BitfabOpenAIAgentHandler,
4306
4360
  BitfabOpenAITracingProcessor: () => BitfabOpenAITracingProcessor,
4361
+ BitfabRivetIntegration: () => BitfabRivetIntegration,
4307
4362
  BitfabVercelAiHandler: () => BitfabVercelAiHandler,
4308
4363
  DEFAULT_SERVICE_URL: () => DEFAULT_SERVICE_URL,
4309
4364
  DatasetsClient: () => DatasetsClient,
@@ -6925,6 +6980,83 @@ var BitfabOpenAIAgentHandler = class {
6925
6980
  }
6926
6981
  };
6927
6982
 
6983
+ // src/openaiAgentsSpanContext.ts
6984
+ var OPENAI_AGENTS_CONTEXT_STORAGE = /* @__PURE__ */ Symbol.for(
6985
+ "openai.agents.core.asyncLocalStorage"
6986
+ );
6987
+ var MAX_OPENAI_AGENTS_SPAN_CHAIN = 64;
6988
+ var spanGlobal = globalThis;
6989
+ var state = spanGlobal.__bitfabOpenAiAgentsSpansV1 ?? {
6990
+ bitfabTraceIds: /* @__PURE__ */ new Map(),
6991
+ endedSpanIds: /* @__PURE__ */ new Map()
6992
+ };
6993
+ spanGlobal.__bitfabOpenAiAgentsSpansV1 = state;
6994
+ function mapOpenAiAgentsTrace(agentsTraceId, bitfabTraceId) {
6995
+ state.bitfabTraceIds.set(agentsTraceId, bitfabTraceId);
6996
+ }
6997
+ function unmapOpenAiAgentsTrace(agentsTraceId) {
6998
+ state.bitfabTraceIds.delete(agentsTraceId);
6999
+ state.endedSpanIds.delete(agentsTraceId);
7000
+ }
7001
+ function endOpenAiAgentsSpan(agentsTraceId, spanId) {
7002
+ if (!state.bitfabTraceIds.has(agentsTraceId)) {
7003
+ return;
7004
+ }
7005
+ const ended = state.endedSpanIds.get(agentsTraceId) ?? /* @__PURE__ */ new Set();
7006
+ ended.add(spanId);
7007
+ state.endedSpanIds.set(agentsTraceId, ended);
7008
+ }
7009
+ function isOpenAiAgentsContextStorage(value) {
7010
+ return value !== null && typeof value === "object" && typeof value.getStore === "function";
7011
+ }
7012
+ function currentOpenAiAgentsSpan() {
7013
+ const storage2 = spanGlobal[OPENAI_AGENTS_CONTEXT_STORAGE];
7014
+ if (!isOpenAiAgentsContextStorage(storage2)) {
7015
+ return void 0;
7016
+ }
7017
+ try {
7018
+ const store = storage2.getStore();
7019
+ return store?.active === true ? store.span ?? void 0 : void 0;
7020
+ } catch {
7021
+ return void 0;
7022
+ }
7023
+ }
7024
+ function currentOpenAiAgentsSpans() {
7025
+ const spans = [];
7026
+ let span = currentOpenAiAgentsSpan();
7027
+ while (span !== void 0 && spans.length < MAX_OPENAI_AGENTS_SPAN_CHAIN) {
7028
+ spans.push(span);
7029
+ span = span.previousSpan ?? void 0;
7030
+ }
7031
+ return spans;
7032
+ }
7033
+ function openAiAgentsSpanChain() {
7034
+ if (state.bitfabTraceIds.size === 0) {
7035
+ return [];
7036
+ }
7037
+ return currentOpenAiAgentsSpans().map((span) => span.spanId).filter((spanId) => typeof spanId === "string");
7038
+ }
7039
+ function openAiAgentsParentSpanId(bitfabTraceId, enclosingSpanIds) {
7040
+ if (state.bitfabTraceIds.size === 0) {
7041
+ return void 0;
7042
+ }
7043
+ for (const span of currentOpenAiAgentsSpans()) {
7044
+ if (typeof span.spanId !== "string" || typeof span.traceId !== "string") {
7045
+ return void 0;
7046
+ }
7047
+ if (state.bitfabTraceIds.get(span.traceId) !== bitfabTraceId) {
7048
+ return void 0;
7049
+ }
7050
+ if (enclosingSpanIds?.includes(span.spanId)) {
7051
+ return void 0;
7052
+ }
7053
+ if (!state.endedSpanIds.get(span.traceId)?.has(span.spanId)) {
7054
+ return span.spanId;
7055
+ }
7056
+ }
7057
+ return void 0;
7058
+ }
7059
+
6928
7060
  // src/client.ts
6929
7061
  init_policyRefresh();
6930
7062
  init_randomUuid();
@@ -6978,6 +7110,533 @@ _context = new WeakMap();
6978
7110
  // src/client.ts
6979
7111
  init_replayContext();
6980
7112
 
7113
+ // src/rivetIntegration.ts
7114
+ init_errors();
7115
+ init_integrationFixture();
7116
+ init_replayContext();
7117
+
7118
+ // src/rivetContext.ts
7119
+ init_asyncStorage();
7120
+ var storage = null;
7121
+ var browserBinding = null;
7122
+ var STORAGE_SYMBOL = /* @__PURE__ */ Symbol.for("bitfab.rivetContextStorage");
7123
+ function initializeStorage() {
7124
+ if (storage) {
7125
+ return;
7126
+ }
7127
+ const shared = globalThis;
7128
+ const existing = shared[STORAGE_SYMBOL];
7129
+ if (existing) {
7130
+ storage = existing;
7131
+ return;
7132
+ }
7133
+ const created = createAsyncLocalStorage();
7134
+ if (created) {
7135
+ shared[STORAGE_SYMBOL] = created;
7136
+ storage = created;
7137
+ }
7138
+ }
7139
+ var rivetContextReady = asyncStorageReady.then(() => {
7140
+ initializeStorage();
7141
+ });
7142
+ function getRivetContextBinding() {
7143
+ initializeStorage();
7144
+ return storage?.getStore() ?? browserBinding ?? void 0;
7145
+ }
7146
+ function runWithBrowserBinding(binding, fn) {
7147
+ const previous = browserBinding;
7148
+ browserBinding = binding;
7149
+ try {
7150
+ const result = fn();
7151
+ if (result instanceof Promise) {
7152
+ return result.finally(() => {
7153
+ browserBinding = previous;
7154
+ });
7155
+ }
7156
+ browserBinding = previous;
7157
+ return result;
7158
+ } catch (error) {
7159
+ browserBinding = previous;
7160
+ throw error;
7161
+ }
7162
+ }
7163
+ function runWithRivetContext(binding, fn) {
7164
+ initializeStorage();
7165
+ if (!storage && !isAsyncStorageInitDone()) {
7166
+ return rivetContextReady.then(() => runWithRivetContext(binding, fn));
7167
+ }
7168
+ if (storage) {
7169
+ return storage.run(binding, fn);
7170
+ }
7171
+ return runWithBrowserBinding(binding, fn);
7172
+ }
7173
+
7174
+ // src/rivetIntegration.ts
7175
+ var RIVET_DOCS_URL = "https://docs.bitfab.ai/frameworks/rivet";
7176
+ var RIVET_GROUP_EFFECT_METHODS = {
7177
+ db: ["execute", "nativeMetrics", "close"],
7178
+ kv: [
7179
+ "get",
7180
+ "put",
7181
+ "delete",
7182
+ "batchPut",
7183
+ "batchGet",
7184
+ "batchDelete",
7185
+ "deleteRange",
7186
+ "listPrefix",
7187
+ "listRange",
7188
+ "list"
7189
+ ],
7190
+ schedule: ["after", "at", "cancel", "get", "list"],
7191
+ cron: ["set", "every", "get", "list", "delete", "history"],
7192
+ queue: [
7193
+ "send",
7194
+ "next",
7195
+ "nextBatch",
7196
+ "waitForNames",
7197
+ "waitForAvailable",
7198
+ "complete",
7199
+ "enqueueAndWait",
7200
+ "tryNext",
7201
+ "tryNextBatch"
7202
+ ],
7203
+ run: ["setWakeAt"]
7204
+ };
7205
+ var RIVET_TOP_LEVEL_EFFECTS = [
7206
+ "broadcast",
7207
+ "saveState",
7208
+ "sleep",
7209
+ "destroy"
7210
+ ];
7211
+ var TOP_LEVEL_UNAVAILABLE_CAPABILITIES = /* @__PURE__ */ new Set([
7212
+ "conn",
7213
+ "conns",
7214
+ "log",
7215
+ "request",
7216
+ "actorRuntimeSocket",
7217
+ "keepAwake",
7218
+ "waitUntil",
7219
+ "client"
7220
+ ]);
7221
+ var SYNC_VOID_EFFECTS = /* @__PURE__ */ new Set([
7222
+ "broadcast",
7223
+ "sleep",
7224
+ "destroy"
7225
+ ]);
7226
+ var QUEUE_MESSAGE_EFFECTS = /* @__PURE__ */ new Set([
7227
+ "queue.next",
7228
+ "queue.nextBatch",
7229
+ "queue.waitForNames",
7230
+ "queue.tryNext",
7231
+ "queue.tryNextBatch"
7232
+ ]);
7233
+ function isRecord5(value) {
7234
+ return typeof value === "object" && value !== null;
7235
+ }
7236
+ function readProperty(value, property) {
7237
+ try {
7238
+ return Reflect.get(value, property, value);
7239
+ } catch {
7240
+ return void 0;
7241
+ }
7242
+ }
7243
+ function snapshotContext(context) {
7244
+ const source = context;
7245
+ const snapshot = {};
7246
+ for (const property of [
7247
+ "state",
7248
+ "vars",
7249
+ "actorId",
7250
+ "name",
7251
+ "key",
7252
+ "region",
7253
+ "aborted"
7254
+ ]) {
7255
+ const value = readProperty(source, property);
7256
+ if (value !== void 0) {
7257
+ snapshot[property] = value;
7258
+ }
7259
+ }
7260
+ return snapshot;
7261
+ }
7262
+ function unavailableCapability(path) {
7263
+ return new BitfabError(
7264
+ `Rivet context capability "${path}" is unavailable during replay. Add first-class support for that public context path before replaying code that uses it.`,
7265
+ RIVET_DOCS_URL
7266
+ );
7267
+ }
7268
+ function effectNode(traceFunctionKey, effect, mockSpanId) {
7269
+ return {
7270
+ traceFunctionKey,
7271
+ spanName: effect,
7272
+ type: "function",
7273
+ originalSpanId: mockSpanId
7274
+ };
7275
+ }
7276
+ function replayEffectStatus(replay2, traceFunctionKey, effect, marked) {
7277
+ const counterKey = `${traceFunctionKey}:${effect}`;
7278
+ const callIndex = replay2.callCounters?.get(counterKey) ?? 0;
7279
+ const mockSpan = replay2.mockTree?.spans.get(`${counterKey}:${callIndex}`);
7280
+ const hasOverride = replay2.mockOverrides?.some(
7281
+ (override) => override.match(
7282
+ effectNode(traceFunctionKey, effect, mockSpan?.sourceSpanId)
7283
+ )
7284
+ ) ?? false;
7285
+ return {
7286
+ willMock: hasOverride || replay2.mockStrategy === "all" || replay2.mockStrategy === "marked" && marked,
7287
+ hasRecordedSpan: mockSpan !== void 0,
7288
+ hasOverride,
7289
+ callIndex
7290
+ };
7291
+ }
7292
+ function assertReplayEffectAvailable(replay2, traceFunctionKey, effect, marked) {
7293
+ if (!replay2) {
7294
+ return;
7295
+ }
7296
+ const status = replayEffectStatus(replay2, traceFunctionKey, effect, marked);
7297
+ if (!status.willMock) {
7298
+ throw new BitfabError(
7299
+ `Rivet effect "${effect}" has no live actor context during replay. Add "${effect}" to mockOnReplay or provide a replay override.`,
7300
+ RIVET_DOCS_URL
7301
+ );
7302
+ }
7303
+ if (!status.hasRecordedSpan && !status.hasOverride) {
7304
+ throw new BitfabError(
7305
+ `No recorded Rivet effect "${effect}" exists at call ${status.callIndex + 1}; the live effect was not executed.`,
7306
+ RIVET_DOCS_URL
7307
+ );
7308
+ }
7309
+ }
7310
+ function fixtureName(traceFunctionKey) {
7311
+ return `rivet:${traceFunctionKey}`;
7312
+ }
7313
+ function snapshotFromReplay(traceFunctionKey, replay2) {
7314
+ const fixture = replay2.integrationFixtures?.get(fixtureName(traceFunctionKey));
7315
+ if (!isRecord5(fixture)) {
7316
+ throw new BitfabError(
7317
+ `Trace "${traceFunctionKey}" has no Rivet context fixture. Capture a fresh trace with the Rivet integration before replaying it.`,
7318
+ RIVET_DOCS_URL
7319
+ );
7320
+ }
7321
+ return fixture;
7322
+ }
7323
+ var BitfabRivetIntegration = class {
7324
+ /** @internal Constructed by `Bitfab.getRivetIntegration()`. */
7325
+ constructor(traceFunctionKey, runtime, options = {}) {
7326
+ this.traceFunctionKey = traceFunctionKey;
7327
+ this.runtime = runtime;
7328
+ this.replayProxies = /* @__PURE__ */ new WeakMap();
7329
+ this.markedEffects = new Set(options.mockOnReplay ?? []);
7330
+ }
7331
+ /**
7332
+ * Run a callback with a live Rivet context bound to the current async chain.
7333
+ * This binds context only; it creates no trace or span.
7334
+ */
7335
+ withContext(context, fn) {
7336
+ if (!isRecord5(context)) {
7337
+ throw new BitfabError("Rivet withContext requires a context object");
7338
+ }
7339
+ const binding = {
7340
+ context,
7341
+ fixtureContext: createIntegrationFixtureContext(
7342
+ fixtureName(this.traceFunctionKey),
7343
+ snapshotContext(context)
7344
+ ),
7345
+ recordedRoots: /* @__PURE__ */ new Set()
7346
+ };
7347
+ return runWithRivetContext(binding, fn);
7348
+ }
7349
+ /**
7350
+ * Adapt a traced function into a Rivet handler whose first argument is the
7351
+ * live actor context. The context is not added to the traced root's inputs.
7352
+ */
7353
+ bind(fn) {
7354
+ const integration = this;
7355
+ return function(context, ...args) {
7356
+ return integration.withContext(context, () => fn.apply(this, args));
7357
+ };
7358
+ }
7359
+ /**
7360
+ * Return the current Rivet context proxy. In production it delegates to the
7361
+ * bound live context. During replay it hydrates recorded actor state and
7362
+ * intercepts supported effects without requiring a live Rivet actor.
7363
+ */
7364
+ getContext() {
7365
+ const replay2 = getReplayContext();
7366
+ if (replay2) {
7367
+ const existing = this.replayProxies.get(replay2);
7368
+ if (existing) {
7369
+ return existing;
7370
+ }
7371
+ const proxy = this.createContextProxy(
7372
+ snapshotFromReplay(this.traceFunctionKey, replay2),
7373
+ void 0
7374
+ );
7375
+ this.replayProxies.set(replay2, proxy);
7376
+ return proxy;
7377
+ }
7378
+ const binding = getRivetContextBinding();
7379
+ if (!binding) {
7380
+ throw new BitfabError(
7381
+ "No Rivet context is bound. Call rivet.bind(handler) or rivet.withContext(context, callback) at the Rivet boundary.",
7382
+ RIVET_DOCS_URL
7383
+ );
7384
+ }
7385
+ this.runtime.recordRootFixture(
7386
+ binding.fixtureContext,
7387
+ binding.recordedRoots
7388
+ );
7389
+ if (!binding.proxy) {
7390
+ binding.proxy = this.createContextProxy(
7391
+ binding.context,
7392
+ binding
7393
+ );
7394
+ }
7395
+ return binding.proxy;
7396
+ }
7397
+ createContextProxy(target, binding) {
7398
+ const replay2 = getReplayContext();
7399
+ const dbProxy = this.createDbProxy(binding, replay2);
7400
+ const groupProxies = /* @__PURE__ */ new Map();
7401
+ for (const group of Object.keys(
7402
+ RIVET_GROUP_EFFECT_METHODS
7403
+ )) {
7404
+ if (group !== "db") {
7405
+ groupProxies.set(group, this.createGroupProxy(group, binding, replay2));
7406
+ }
7407
+ }
7408
+ const topLevelEffects = /* @__PURE__ */ new Map();
7409
+ for (const effect of RIVET_TOP_LEVEL_EFFECTS) {
7410
+ topLevelEffects.set(
7411
+ effect,
7412
+ this.createEffect(
7413
+ effect,
7414
+ () => binding?.context,
7415
+ effect,
7416
+ replay2
7417
+ )
7418
+ );
7419
+ }
7420
+ const replayTarget = replay2 ? { ...target } : target;
7421
+ if (replay2) {
7422
+ const controller = new AbortController();
7423
+ if (target.aborted === true) {
7424
+ controller.abort();
7425
+ }
7426
+ replayTarget.abortSignal = controller.signal;
7427
+ }
7428
+ return new Proxy(replayTarget, {
7429
+ get: (source, property) => {
7430
+ if (property === "db") {
7431
+ return dbProxy;
7432
+ }
7433
+ if (typeof property === "string") {
7434
+ const group = groupProxies.get(property);
7435
+ if (group) {
7436
+ return group;
7437
+ }
7438
+ const effect = topLevelEffects.get(property);
7439
+ if (effect) {
7440
+ return effect;
7441
+ }
7442
+ }
7443
+ if (property === "setPreventSleep" && replay2) {
7444
+ return (_preventSleep) => void 0;
7445
+ }
7446
+ if (replay2 && typeof property === "string" && TOP_LEVEL_UNAVAILABLE_CAPABILITIES.has(property)) {
7447
+ throw unavailableCapability(property);
7448
+ }
7449
+ const value = Reflect.get(source, property, source);
7450
+ return typeof value === "function" ? value.bind(source) : value;
7451
+ }
7452
+ });
7453
+ }
7454
+ createDbProxy(binding, replay2) {
7455
+ const proxy = this.createGroupProxy("db", binding, replay2);
7456
+ return new Proxy(proxy, {
7457
+ get: (source, property) => property === "transaction" ? this.createTransaction(binding, replay2) : Reflect.get(source, property, source)
7458
+ });
7459
+ }
7460
+ createGroupProxy(group, binding, replay2) {
7461
+ const targetProvider = () => {
7462
+ if (!binding) {
7463
+ return void 0;
7464
+ }
7465
+ const context = binding.context;
7466
+ const target = readProperty(context, group);
7467
+ return isRecord5(target) ? target : void 0;
7468
+ };
7469
+ const proxy = this.createMethodProxy(
7470
+ targetProvider,
7471
+ group,
7472
+ RIVET_GROUP_EFFECT_METHODS[group],
7473
+ replay2
7474
+ );
7475
+ if (group !== "queue") {
7476
+ return proxy;
7477
+ }
7478
+ return new Proxy(proxy, {
7479
+ get: (source, property) => property === "iter" ? (options) => this.createQueueIterator(source, options) : Reflect.get(source, property, source)
7480
+ });
7481
+ }
7482
+ createMethodProxy(targetProvider, prefix, methods, replay2) {
7483
+ const effects = /* @__PURE__ */ new Map();
7484
+ for (const method of methods) {
7485
+ const effect = `${prefix}.${method}`;
7486
+ effects.set(
7487
+ method,
7488
+ this.createEffect(effect, targetProvider, method, replay2)
7489
+ );
7490
+ }
7491
+ return new Proxy(
7492
+ {},
7493
+ {
7494
+ get: (_source, property) => {
7495
+ if (typeof property === "string") {
7496
+ const effect = effects.get(property);
7497
+ if (effect) {
7498
+ return effect;
7499
+ }
7500
+ if (replay2) {
7501
+ throw unavailableCapability(`${prefix}.${property}`);
7502
+ }
7503
+ }
7504
+ const target = targetProvider();
7505
+ if (!target) {
7506
+ return void 0;
7507
+ }
7508
+ const value = Reflect.get(target, property, target);
7509
+ return typeof value === "function" ? value.bind(target) : value;
7510
+ }
7511
+ }
7512
+ );
7513
+ }
7514
+ createEffect(effect, targetProvider, methodName, replay2) {
7515
+ const marked = this.markedEffects.has(effect);
7516
+ const invoke = (...args) => {
7517
+ assertReplayEffectAvailable(
7518
+ getReplayContext(),
7519
+ this.traceFunctionKey,
7520
+ effect,
7521
+ marked
7522
+ );
7523
+ const target = targetProvider();
7524
+ const method = target ? readProperty(target, methodName) : void 0;
7525
+ if (typeof method !== "function") {
7526
+ throw unavailableCapability(effect);
7527
+ }
7528
+ return method.apply(target, args);
7529
+ };
7530
+ const wrapped = SYNC_VOID_EFFECTS.has(effect) ? this.runtime.wrapEffect(
7531
+ effect,
7532
+ marked,
7533
+ invoke,
7534
+ replay2 ? () => void 0 : void 0
7535
+ ) : this.runtime.wrapEffect(effect, marked, async (...args) => {
7536
+ return await invoke(...args);
7537
+ });
7538
+ return (...args) => {
7539
+ if (replay2) {
7540
+ assertReplayEffectAvailable(
7541
+ replay2,
7542
+ this.traceFunctionKey,
7543
+ effect,
7544
+ marked
7545
+ );
7546
+ }
7547
+ const result = wrapped(...args);
7548
+ if (!QUEUE_MESSAGE_EFFECTS.has(effect) || !(result instanceof Promise)) {
7549
+ return result;
7550
+ }
7551
+ return result.then(
7552
+ (value) => this.decorateQueueMessages(value, effect, args, replay2)
7553
+ );
7554
+ };
7555
+ }
7556
+ createTransaction(binding, replay2) {
7557
+ return async (callback, options) => {
7558
+ if (typeof callback !== "function") {
7559
+ throw new BitfabError("Rivet db.transaction requires a callback");
7560
+ }
7561
+ if (replay2) {
7562
+ return await callback(
7563
+ this.createMethodProxy(
7564
+ () => void 0,
7565
+ "db.transaction",
7566
+ ["execute"],
7567
+ replay2
7568
+ )
7569
+ );
7570
+ }
7571
+ const context = binding?.context;
7572
+ const db = context ? readProperty(context, "db") : void 0;
7573
+ const transaction = isRecord5(db) ? readProperty(db, "transaction") : void 0;
7574
+ if (!isRecord5(db) || typeof transaction !== "function") {
7575
+ throw unavailableCapability("db.transaction");
7576
+ }
7577
+ return await transaction.call(
7578
+ db,
7579
+ async (transactionDb) => {
7580
+ if (!isRecord5(transactionDb)) {
7581
+ throw unavailableCapability("db.transaction.execute");
7582
+ }
7583
+ return await callback(
7584
+ this.createMethodProxy(
7585
+ () => transactionDb,
7586
+ "db.transaction",
7587
+ ["execute"],
7588
+ replay2
7589
+ )
7590
+ );
7591
+ },
7592
+ options
7593
+ );
7594
+ };
7595
+ }
7596
+ decorateQueueMessages(value, effect, args, replay2) {
7597
+ if (!this.queueCallIsCompletable(effect, args)) {
7598
+ return value;
7599
+ }
7600
+ if (Array.isArray(value)) {
7601
+ return value.map((message) => this.decorateQueueMessage(message, replay2));
7602
+ }
7603
+ return this.decorateQueueMessage(value, replay2);
7604
+ }
7605
+ decorateQueueMessage(value, replay2) {
7606
+ if (!isRecord5(value)) {
7607
+ return value;
7608
+ }
7609
+ const originalComplete = readProperty(value, "complete");
7610
+ const complete = this.createEffect(
7611
+ "queue.message.complete",
7612
+ () => typeof originalComplete === "function" ? { complete: originalComplete.bind(value) } : void 0,
7613
+ "complete",
7614
+ replay2
7615
+ );
7616
+ return { ...value, complete };
7617
+ }
7618
+ queueCallIsCompletable(effect, args) {
7619
+ const options = effect === "queue.waitForNames" ? args[1] : args[0];
7620
+ return isRecord5(options) && options.completable === true;
7621
+ }
7622
+ createQueueIterator(queue, options) {
7623
+ return {
7624
+ async *[Symbol.asyncIterator]() {
7625
+ for (; ; ) {
7626
+ const next = Reflect.get(queue, "next", queue);
7627
+ if (typeof next !== "function") {
7628
+ throw unavailableCapability("queue.next");
7629
+ }
7630
+ const message = await next.call(queue, options);
7631
+ if (message !== void 0 && message !== null) {
7632
+ yield message;
7633
+ }
7634
+ }
7635
+ }
7636
+ };
7637
+ }
7638
+ };
7639
+
6981
7640
  // src/seedContext.ts
6982
7641
  init_asyncStorage();
6983
7642
  var seedContextStorage = null;
@@ -7121,6 +7780,9 @@ var BitfabOpenAITracingProcessor = class {
7121
7780
  const activeContext = this.getActiveSpanContext?.();
7122
7781
  if (activeContext) {
7123
7782
  this.activeSpanMappings[trace.traceId] = activeContext;
7783
+ if (this.shouldRecord()) {
7784
+ mapOpenAiAgentsTrace(trace.traceId, activeContext.traceId);
7785
+ }
7124
7786
  }
7125
7787
  const canonicalTraceId = activeContext?.traceId ?? this.getCanonicalTraceId(trace.traceId);
7126
7788
  this.canonicalTraceIds[trace.traceId] = canonicalTraceId;
@@ -7158,6 +7820,7 @@ var BitfabOpenAITracingProcessor = class {
7158
7820
  }
7159
7821
  this.endedTraces.delete(traceId);
7160
7822
  delete this.activeSpanMappings[traceId];
7823
+ unmapOpenAiAgentsTrace(traceId);
7161
7824
  delete this.canonicalTraceIds[traceId];
7162
7825
  delete this.activeTraces[traceId];
7163
7826
  }
@@ -7182,6 +7845,9 @@ var BitfabOpenAITracingProcessor = class {
7182
7845
  async onSpanEnd(span) {
7183
7846
  const originalTraceId = span.traceId ?? "";
7184
7847
  const traceId = this.activeSpanMappings[originalTraceId]?.traceId ?? originalTraceId;
7848
+ if (span.spanId !== void 0) {
7849
+ endOpenAiAgentsSpan(originalTraceId, span.spanId);
7850
+ }
7185
7851
  try {
7186
7852
  this.sendSpan(span);
7187
7853
  } finally {
@@ -7202,6 +7868,9 @@ var BitfabOpenAITracingProcessor = class {
7202
7868
  * Called when the trace processor is shutting down.
7203
7869
  */
7204
7870
  async shutdown(timeout) {
7871
+ for (const traceId of Object.keys(this.activeSpanMappings)) {
7872
+ unmapOpenAiAgentsTrace(traceId);
7873
+ }
7205
7874
  this.activeTraces = {};
7206
7875
  this.activeSpanMappings = {};
7207
7876
  this.canonicalTraceIds = {};
@@ -8359,16 +9028,16 @@ var Bitfab = class {
8359
9028
  this.simulationPlan.send(payload, rootTraceFunctionKeyOf(payload), submit);
8360
9029
  }
8361
9030
  refreshAutoTraceCapturePolicy(traceFunctionKey) {
8362
- const state = this.autoTracePolicyRefreshes.get(traceFunctionKey) ?? new PolicyRefresh();
8363
- this.autoTracePolicyRefreshes.set(traceFunctionKey, state);
8364
- state.run(
9031
+ const state2 = this.autoTracePolicyRefreshes.get(traceFunctionKey) ?? new PolicyRefresh();
9032
+ this.autoTracePolicyRefreshes.set(traceFunctionKey, state2);
9033
+ state2.run(
8365
9034
  () => this.httpClient.getAutoTracePolicy(
8366
9035
  traceFunctionKey,
8367
9036
  AUTO_TRACE_PROTOCOL
8368
9037
  ),
8369
9038
  (policy) => {
8370
9039
  if (policy.protocol !== AUTO_TRACE_PROTOCOL) {
8371
- state.hold(AUTO_TRACE_POLICY_RETRY_MS);
9040
+ state2.hold(AUTO_TRACE_POLICY_RETRY_MS);
8372
9041
  return;
8373
9042
  }
8374
9043
  const functionIds = Array.isArray(policy.functionIds) ? policy.functionIds.filter(
@@ -8379,10 +9048,10 @@ var Bitfab = class {
8379
9048
  traceFunctionKey,
8380
9049
  policy.revision === null ? void 0 : functionIds
8381
9050
  );
8382
- state.hold(AUTO_TRACE_POLICY_REFRESH_MS);
9051
+ state2.hold(AUTO_TRACE_POLICY_REFRESH_MS);
8383
9052
  },
8384
9053
  () => {
8385
- state.hold(AUTO_TRACE_POLICY_RETRY_MS);
9054
+ state2.hold(AUTO_TRACE_POLICY_RETRY_MS);
8386
9055
  }
8387
9056
  );
8388
9057
  }
@@ -8687,6 +9356,47 @@ var Bitfab = class {
8687
9356
  options
8688
9357
  });
8689
9358
  }
9359
+ /**
9360
+ * Get the first-class Rivet actor-context integration for an existing trace
9361
+ * root. The integration binds context and records effect spans; it never
9362
+ * creates another root.
9363
+ *
9364
+ * @param traceFunctionKey - Key used by the enclosing `withTrace()` root
9365
+ * @param options - Explicit per-context-path replay mocking policy
9366
+ * @experimental This API may change before it is stable.
9367
+ */
9368
+ getRivetIntegration(traceFunctionKey, options) {
9369
+ return new BitfabRivetIntegration(
9370
+ traceFunctionKey,
9371
+ {
9372
+ wrapEffect: (effect, mockOnReplay, fn, replayOutput) => {
9373
+ const spanOptions = {
9374
+ name: effect,
9375
+ type: "function",
9376
+ captureWhen: "nested",
9377
+ mockOnReplay,
9378
+ surface: "inherit",
9379
+ instrumentation: "rivet",
9380
+ ...replayOutput !== void 0 && { replayOutput }
9381
+ };
9382
+ return this.withSpan(traceFunctionKey, spanOptions, fn);
9383
+ },
9384
+ recordRootFixture: (context, recordedRoots) => {
9385
+ const root = getSpanStack()[0];
9386
+ if (!root) {
9387
+ return;
9388
+ }
9389
+ const rootId = `${root.traceId}:${root.spanId}`;
9390
+ if (recordedRoots.has(rootId)) {
9391
+ return;
9392
+ }
9393
+ root.contexts.push(context);
9394
+ recordedRoots.add(rootId);
9395
+ }
9396
+ },
9397
+ options
9398
+ );
9399
+ }
8690
9400
  /**
8691
9401
  * Get a Claude Agent SDK handler for tracing.
8692
9402
  *
@@ -8952,7 +9662,11 @@ var Bitfab = class {
8952
9662
  const seedCtxForTraceId = parentContext ? null : getSeedContext();
8953
9663
  const traceId = parentContext?.traceId ?? replayCtxForTraceId?.traceId ?? seedCtxForTraceId?.traceId ?? randomUuid();
8954
9664
  const spanId = randomUuid();
8955
- const parentSpanId = parentContext?.spanId ?? null;
9665
+ const openAiAgentsParent = parentContext !== void 0 && options.instrumentation === "trace" ? openAiAgentsParentSpanId(
9666
+ parentContext.traceId,
9667
+ parentContext.openAiAgentsSpanIds
9668
+ ) : void 0;
9669
+ const parentSpanId = openAiAgentsParent ?? parentContext?.spanId ?? null;
8956
9670
  const isRootSpan = parentSpanId === null;
8957
9671
  if (options.enclosingTrace !== void 0) {
8958
9672
  options.enclosingTrace.link.traceId = traceId;
@@ -8966,11 +9680,13 @@ var Bitfab = class {
8966
9680
  parentContext?.surface,
8967
9681
  traceFunctionKey
8968
9682
  );
9683
+ const openAiAgentsSpanIds = openAiAgentsSpanChain();
8969
9684
  const newContext = {
8970
9685
  traceId,
8971
9686
  spanId,
8972
9687
  contexts: [],
8973
- ...surface !== void 0 && { surface }
9688
+ ...surface !== void 0 && { surface },
9689
+ ...openAiAgentsSpanIds.length > 0 && { openAiAgentsSpanIds }
8974
9690
  };
8975
9691
  newStack = [...currentStack, newContext];
8976
9692
  const inputs = args;
@@ -9185,6 +9901,7 @@ var Bitfab = class {
9185
9901
  }
9186
9902
  return output;
9187
9903
  };
9904
+ const resolveBaseOutput = () => options.replayOutput !== void 0 ? options.replayOutput() : resolveRecordedOutput();
9188
9905
  const shouldMockWithBaseStrategy = replayCtxForMock.mockStrategy === "all" || replayCtxForMock.mockStrategy === "marked" && options.mockOnReplay === true;
9189
9906
  if (replayCtxForMock.mockOverrides?.length) {
9190
9907
  const nodeMeta = {
@@ -9241,7 +9958,7 @@ var Bitfab = class {
9241
9958
  }
9242
9959
  if (shouldMockWithBaseStrategy) {
9243
9960
  const output = await resolveMockOrAbort(
9244
- () => resolveRecordedOutput()
9961
+ () => resolveBaseOutput()
9245
9962
  );
9246
9963
  void sendSpan({
9247
9964
  result: output,
@@ -9264,7 +9981,7 @@ var Bitfab = class {
9264
9981
  );
9265
9982
  }
9266
9983
  if (shouldMockWithBaseStrategy) {
9267
- const recorded = resolveRecordedOutput();
9984
+ const recorded = resolveBaseOutput();
9268
9985
  if (recorded instanceof Promise) {
9269
9986
  return emitMockAsync(recorded, "recorded");
9270
9987
  }
@@ -9866,6 +10583,28 @@ var BitfabFunction = class {
9866
10583
  span(options = {}) {
9867
10584
  return this.client.span(this.traceFunctionKey, options);
9868
10585
  }
10586
+ withTrace(optionsOrFn, maybeFn) {
10587
+ if (typeof optionsOrFn === "function") {
10588
+ return this.client.withTrace(this.traceFunctionKey, optionsOrFn);
10589
+ }
10590
+ if (!maybeFn) {
10591
+ throw new BitfabError("BitfabFunction.withTrace requires a function");
10592
+ }
10593
+ return this.client.withTrace(this.traceFunctionKey, optionsOrFn, maybeFn);
10594
+ }
10595
+ /**
10596
+ * Create a trace method decorator bound to this function's key.
10597
+ *
10598
+ * Equivalent to `client.trace(key, options)` but reuses the key bound on
10599
+ * this handle.
10600
+ *
10601
+ * @param options - Trace configuration applied to the decorated method
10602
+ * @returns A method decorator configured for this key
10603
+ * @experimental Automatic child-call instrumentation is experimental.
10604
+ */
10605
+ trace(options = {}) {
10606
+ return this.client.trace(this.traceFunctionKey, options);
10607
+ }
9869
10608
  /**
9870
10609
  * Get a Vercel AI SDK language-model middleware bound to this function's key.
9871
10610
  *
@@ -9963,6 +10702,20 @@ var BitfabFunction = class {
9963
10702
  getLangGraphIntegration(options) {
9964
10703
  return this.client.getLangGraphIntegration(this.traceFunctionKey, options);
9965
10704
  }
10705
+ /**
10706
+ * Get the first-class Rivet actor-context integration bound to this key.
10707
+ * Use its `bind()` or `withContext()` outside this handle's `withTrace()`
10708
+ * root, then call `getContext()` inside the root.
10709
+ *
10710
+ * @param options - Explicit per-context-path replay mocking policy
10711
+ * @experimental This API may change before it is stable.
10712
+ */
10713
+ getRivetIntegration(options) {
10714
+ return this.client.getRivetIntegration(
10715
+ this.traceFunctionKey,
10716
+ options
10717
+ );
10718
+ }
9966
10719
  /**
9967
10720
  * Wrap a BAML client method to automatically capture prompt and LLM metadata.
9968
10721
  * Delegates to the parent client's wrapBAML method.
@@ -10124,6 +10877,7 @@ function resolveTraceFunctionKey(registration) {
10124
10877
  BitfabLangGraphIntegration,
10125
10878
  BitfabOpenAIAgentHandler,
10126
10879
  BitfabOpenAITracingProcessor,
10880
+ BitfabRivetIntegration,
10127
10881
  BitfabVercelAiHandler,
10128
10882
  DEFAULT_SERVICE_URL,
10129
10883
  DatasetsClient,