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/node.cjs CHANGED
@@ -97,7 +97,7 @@ var __version__, __packageName__;
97
97
  var init_version_generated = __esm({
98
98
  "src/version.generated.ts"() {
99
99
  "use strict";
100
- __version__ = "0.54.9";
100
+ __version__ = "0.54.11";
101
101
  __packageName__ = "bitfab";
102
102
  }
103
103
  });
@@ -123,20 +123,20 @@ var init_traceCompletion = __esm({
123
123
  this.closed = /* @__PURE__ */ new Map();
124
124
  }
125
125
  state(traceId) {
126
- let state = this.traces.get(traceId);
127
- if (state === void 0) {
128
- state = { spanIds: /* @__PURE__ */ new Set(), active: /* @__PURE__ */ new Set() };
129
- this.traces.set(traceId, state);
126
+ let state2 = this.traces.get(traceId);
127
+ if (state2 === void 0) {
128
+ state2 = { spanIds: /* @__PURE__ */ new Set(), active: /* @__PURE__ */ new Set() };
129
+ this.traces.set(traceId, state2);
130
130
  }
131
- return state;
131
+ return state2;
132
132
  }
133
133
  start(traceId, spanId) {
134
134
  if (this.closed.has(traceId)) {
135
135
  return;
136
136
  }
137
- const state = this.state(traceId);
138
- state.spanIds.add(spanId);
139
- state.active.add(spanId);
137
+ const state2 = this.state(traceId);
138
+ state2.spanIds.add(spanId);
139
+ state2.active.add(spanId);
140
140
  }
141
141
  open(traceId) {
142
142
  if (!this.closed.has(traceId)) {
@@ -152,24 +152,24 @@ var init_traceCompletion = __esm({
152
152
  }
153
153
  }
154
154
  end(traceId, spanId) {
155
- const state = this.traces.get(traceId);
156
- if (state !== void 0) {
157
- state.active.delete(spanId);
158
- this.drain(traceId, state);
155
+ const state2 = this.traces.get(traceId);
156
+ if (state2 !== void 0) {
157
+ state2.active.delete(spanId);
158
+ this.drain(traceId, state2);
159
159
  }
160
160
  }
161
161
  abort(traceId, spanId) {
162
- const state = this.traces.get(traceId);
163
- if (state === void 0) {
162
+ const state2 = this.traces.get(traceId);
163
+ if (state2 === void 0) {
164
164
  return;
165
165
  }
166
- state.active.delete(spanId);
167
- state.spanIds.delete(spanId);
168
- if (state.active.size === 0 && state.spanIds.size === 0 && state.complete === void 0) {
166
+ state2.active.delete(spanId);
167
+ state2.spanIds.delete(spanId);
168
+ if (state2.active.size === 0 && state2.spanIds.size === 0 && state2.complete === void 0) {
169
169
  this.traces.delete(traceId);
170
170
  return;
171
171
  }
172
- this.drain(traceId, state);
172
+ this.drain(traceId, state2);
173
173
  }
174
174
  close(traceId, complete, dropped = false) {
175
175
  const count = this.closed.get(traceId);
@@ -177,29 +177,29 @@ var init_traceCompletion = __esm({
177
177
  complete(count);
178
178
  return;
179
179
  }
180
- const state = this.traces.get(traceId);
181
- if (state === void 0) {
180
+ const state2 = this.traces.get(traceId);
181
+ if (state2 === void 0) {
182
182
  return;
183
183
  }
184
- state.complete = complete;
184
+ state2.complete = complete;
185
185
  if (dropped) {
186
- state.active.clear();
186
+ state2.active.clear();
187
187
  }
188
- this.drain(traceId, state);
188
+ this.drain(traceId, state2);
189
189
  }
190
- drain(traceId, state) {
191
- if (state.active.size !== 0 || state.complete === void 0) {
190
+ drain(traceId, state2) {
191
+ if (state2.active.size !== 0 || state2.complete === void 0) {
192
192
  return;
193
193
  }
194
194
  this.traces.delete(traceId);
195
- this.closed.set(traceId, state.spanIds.size);
195
+ this.closed.set(traceId, state2.spanIds.size);
196
196
  if (this.closed.size > 1024) {
197
197
  const oldest = this.closed.keys().next().value;
198
198
  if (oldest !== void 0) {
199
199
  this.closed.delete(oldest);
200
200
  }
201
201
  }
202
- state.complete(state.spanIds.size);
202
+ state2.complete(state2.spanIds.size);
203
203
  }
204
204
  };
205
205
  }
@@ -450,8 +450,8 @@ function text(value) {
450
450
  const trimmed = value?.trim();
451
451
  return trimmed ? trimmed : null;
452
452
  }
453
- function isEmptyGitState(state) {
454
- return Object.values(state).every((value) => value === null);
453
+ function isEmptyGitState(state2) {
454
+ return Object.values(state2).every((value) => value === null);
455
455
  }
456
456
  async function resolveGitState(cwd) {
457
457
  const git = await gitRunner({
@@ -472,14 +472,14 @@ async function resolveGitState(cwd) {
472
472
  if (!root) {
473
473
  return null;
474
474
  }
475
- const state = {
475
+ const state2 = {
476
476
  githubEmail: text(email),
477
477
  branch: text(branch),
478
478
  commitSha: sha(commitSha),
479
479
  baseSha: sha(baseSha),
480
480
  experimentSha: await resolveWorkingTreeSha(run, root.trim())
481
481
  };
482
- return isEmptyGitState(state) ? null : state;
482
+ return isEmptyGitState(state2) ? null : state2;
483
483
  }
484
484
  async function resolveWorkingTreeSha(run, root) {
485
485
  let indexPath;
@@ -843,8 +843,8 @@ function encodePayloadBody(payload) {
843
843
  const marker = { error: `payload_serialize_failed: ${message}` };
844
844
  return { body: JSON.stringify(marker), dropped, value: marker };
845
845
  }
846
- const isRecord4 = typeof sanitized === "object" && sanitized !== null && !Array.isArray(sanitized);
847
- if (dropped.length > 0 && isRecord4) {
846
+ const isRecord6 = typeof sanitized === "object" && sanitized !== null && !Array.isArray(sanitized);
847
+ if (dropped.length > 0 && isRecord6) {
848
848
  const obj = sanitized;
849
849
  const existing = Array.isArray(obj.errors) ? obj.errors : [];
850
850
  obj.errors = [
@@ -861,7 +861,7 @@ function encodePayloadBody(payload) {
861
861
  return {
862
862
  body: JSON.stringify(sanitized),
863
863
  dropped,
864
- value: isRecord4 ? sanitized : void 0
864
+ value: isRecord6 ? sanitized : void 0
865
865
  };
866
866
  }
867
867
  }
@@ -963,13 +963,15 @@ var init_spanOrigin = __esm({
963
963
  "openai-agents",
964
964
  "langgraph",
965
965
  "claude-agent-sdk",
966
- "vercel-ai"
966
+ "vercel-ai",
967
+ "rivet"
967
968
  ];
968
969
  FRAMEWORK_INSTRUMENTATIONS = [
969
970
  "openai-agents",
970
971
  "langgraph",
971
972
  "claude-agent-sdk",
972
- "vercel-ai"
973
+ "vercel-ai",
974
+ "rivet"
973
975
  ];
974
976
  FRAMEWORK_INSTRUMENTATION_SET = new Set(
975
977
  FRAMEWORK_INSTRUMENTATIONS
@@ -3473,6 +3475,55 @@ var init_codeChange = __esm({
3473
3475
  }
3474
3476
  });
3475
3477
 
3478
+ // src/integrationFixture.ts
3479
+ function isRecord4(value) {
3480
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3481
+ }
3482
+ function createIntegrationFixtureContext(name, value) {
3483
+ const serialized = serializeValue(value);
3484
+ return {
3485
+ [INTEGRATION_FIXTURE_CONTEXT_KEY]: {
3486
+ version: INTEGRATION_FIXTURE_VERSION,
3487
+ name,
3488
+ value: serialized.json,
3489
+ ...serialized.meta !== void 0 && { valueMeta: serialized.meta }
3490
+ }
3491
+ };
3492
+ }
3493
+ function extractIntegrationFixtures(spanData) {
3494
+ const contexts = spanData.contexts;
3495
+ if (!Array.isArray(contexts)) {
3496
+ return void 0;
3497
+ }
3498
+ const fixtures = /* @__PURE__ */ new Map();
3499
+ for (const context of contexts) {
3500
+ if (!isRecord4(context)) {
3501
+ continue;
3502
+ }
3503
+ const fixture = context[INTEGRATION_FIXTURE_CONTEXT_KEY];
3504
+ if (!isRecord4(fixture) || fixture.version !== INTEGRATION_FIXTURE_VERSION || typeof fixture.name !== "string") {
3505
+ continue;
3506
+ }
3507
+ fixtures.set(
3508
+ fixture.name,
3509
+ deserializeValue({
3510
+ json: fixture.value,
3511
+ ...fixture.valueMeta !== void 0 && { meta: fixture.valueMeta }
3512
+ })
3513
+ );
3514
+ }
3515
+ return fixtures.size > 0 ? fixtures : void 0;
3516
+ }
3517
+ var INTEGRATION_FIXTURE_CONTEXT_KEY, INTEGRATION_FIXTURE_VERSION;
3518
+ var init_integrationFixture = __esm({
3519
+ "src/integrationFixture.ts"() {
3520
+ "use strict";
3521
+ init_serialize();
3522
+ INTEGRATION_FIXTURE_CONTEXT_KEY = "__bitfabIntegrationFixture";
3523
+ INTEGRATION_FIXTURE_VERSION = 1;
3524
+ }
3525
+ });
3526
+
3476
3527
  // src/replay.ts
3477
3528
  var replay_exports = {};
3478
3529
  __export(replay_exports, {
@@ -3697,6 +3748,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
3697
3748
  const spanData = span.rawData?.span_data ?? {};
3698
3749
  inputs = deserializeInputs(spanData);
3699
3750
  originalOutput = deserializeOutput(spanData);
3751
+ const integrationFixtures = extractIntegrationFixtures(spanData);
3700
3752
  if (adaptInputs) {
3701
3753
  const originalMetadata = serverItem.originalMetadata;
3702
3754
  inputs = adaptInputs(inputs, {
@@ -3788,6 +3840,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
3788
3840
  mockStrategy,
3789
3841
  mockOverrides: hasOverrides ? resolvedOverrides : void 0,
3790
3842
  fetchSpanOutput,
3843
+ integrationFixtures,
3791
3844
  dbBranchLease: lease,
3792
3845
  dbBranchTimings
3793
3846
  },
@@ -4268,6 +4321,7 @@ var init_replay = __esm({
4268
4321
  init_codeChange();
4269
4322
  init_errors();
4270
4323
  init_http();
4324
+ init_integrationFixture();
4271
4325
  init_mockOverride();
4272
4326
  init_randomUuid();
4273
4327
  init_replayContext();
@@ -4311,6 +4365,7 @@ __export(node_exports, {
4311
4365
  BitfabLangGraphIntegration: () => BitfabLangGraphIntegration,
4312
4366
  BitfabOpenAIAgentHandler: () => BitfabOpenAIAgentHandler,
4313
4367
  BitfabOpenAITracingProcessor: () => BitfabOpenAITracingProcessor,
4368
+ BitfabRivetIntegration: () => BitfabRivetIntegration,
4314
4369
  BitfabVercelAiHandler: () => BitfabVercelAiHandler,
4315
4370
  DEFAULT_SERVICE_URL: () => DEFAULT_SERVICE_URL,
4316
4371
  DatasetsClient: () => DatasetsClient,
@@ -6939,6 +6994,83 @@ var BitfabOpenAIAgentHandler = class {
6939
6994
  }
6940
6995
  };
6941
6996
 
6997
+ // src/openaiAgentsSpanContext.ts
6998
+ var OPENAI_AGENTS_CONTEXT_STORAGE = /* @__PURE__ */ Symbol.for(
6999
+ "openai.agents.core.asyncLocalStorage"
7000
+ );
7001
+ var MAX_OPENAI_AGENTS_SPAN_CHAIN = 64;
7002
+ var spanGlobal = globalThis;
7003
+ var state = spanGlobal.__bitfabOpenAiAgentsSpansV1 ?? {
7004
+ bitfabTraceIds: /* @__PURE__ */ new Map(),
7005
+ endedSpanIds: /* @__PURE__ */ new Map()
7006
+ };
7007
+ spanGlobal.__bitfabOpenAiAgentsSpansV1 = state;
7008
+ function mapOpenAiAgentsTrace(agentsTraceId, bitfabTraceId) {
7009
+ state.bitfabTraceIds.set(agentsTraceId, bitfabTraceId);
7010
+ }
7011
+ function unmapOpenAiAgentsTrace(agentsTraceId) {
7012
+ state.bitfabTraceIds.delete(agentsTraceId);
7013
+ state.endedSpanIds.delete(agentsTraceId);
7014
+ }
7015
+ function endOpenAiAgentsSpan(agentsTraceId, spanId) {
7016
+ if (!state.bitfabTraceIds.has(agentsTraceId)) {
7017
+ return;
7018
+ }
7019
+ const ended = state.endedSpanIds.get(agentsTraceId) ?? /* @__PURE__ */ new Set();
7020
+ ended.add(spanId);
7021
+ state.endedSpanIds.set(agentsTraceId, ended);
7022
+ }
7023
+ function isOpenAiAgentsContextStorage(value) {
7024
+ return value !== null && typeof value === "object" && typeof value.getStore === "function";
7025
+ }
7026
+ function currentOpenAiAgentsSpan() {
7027
+ const storage2 = spanGlobal[OPENAI_AGENTS_CONTEXT_STORAGE];
7028
+ if (!isOpenAiAgentsContextStorage(storage2)) {
7029
+ return void 0;
7030
+ }
7031
+ try {
7032
+ const store = storage2.getStore();
7033
+ return store?.active === true ? store.span ?? void 0 : void 0;
7034
+ } catch {
7035
+ return void 0;
7036
+ }
7037
+ }
7038
+ function currentOpenAiAgentsSpans() {
7039
+ const spans = [];
7040
+ let span = currentOpenAiAgentsSpan();
7041
+ while (span !== void 0 && spans.length < MAX_OPENAI_AGENTS_SPAN_CHAIN) {
7042
+ spans.push(span);
7043
+ span = span.previousSpan ?? void 0;
7044
+ }
7045
+ return spans;
7046
+ }
7047
+ function openAiAgentsSpanChain() {
7048
+ if (state.bitfabTraceIds.size === 0) {
7049
+ return [];
7050
+ }
7051
+ return currentOpenAiAgentsSpans().map((span) => span.spanId).filter((spanId) => typeof spanId === "string");
7052
+ }
7053
+ function openAiAgentsParentSpanId(bitfabTraceId, enclosingSpanIds) {
7054
+ if (state.bitfabTraceIds.size === 0) {
7055
+ return void 0;
7056
+ }
7057
+ for (const span of currentOpenAiAgentsSpans()) {
7058
+ if (typeof span.spanId !== "string" || typeof span.traceId !== "string") {
7059
+ return void 0;
7060
+ }
7061
+ if (state.bitfabTraceIds.get(span.traceId) !== bitfabTraceId) {
7062
+ return void 0;
7063
+ }
7064
+ if (enclosingSpanIds?.includes(span.spanId)) {
7065
+ return void 0;
7066
+ }
7067
+ if (!state.endedSpanIds.get(span.traceId)?.has(span.spanId)) {
7068
+ return span.spanId;
7069
+ }
7070
+ }
7071
+ return void 0;
7072
+ }
7073
+
6942
7074
  // src/client.ts
6943
7075
  init_policyRefresh();
6944
7076
  init_randomUuid();
@@ -6992,6 +7124,533 @@ _context = new WeakMap();
6992
7124
  // src/client.ts
6993
7125
  init_replayContext();
6994
7126
 
7127
+ // src/rivetIntegration.ts
7128
+ init_errors();
7129
+ init_integrationFixture();
7130
+ init_replayContext();
7131
+
7132
+ // src/rivetContext.ts
7133
+ init_asyncStorage();
7134
+ var storage = null;
7135
+ var browserBinding = null;
7136
+ var STORAGE_SYMBOL = /* @__PURE__ */ Symbol.for("bitfab.rivetContextStorage");
7137
+ function initializeStorage() {
7138
+ if (storage) {
7139
+ return;
7140
+ }
7141
+ const shared = globalThis;
7142
+ const existing = shared[STORAGE_SYMBOL];
7143
+ if (existing) {
7144
+ storage = existing;
7145
+ return;
7146
+ }
7147
+ const created = createAsyncLocalStorage();
7148
+ if (created) {
7149
+ shared[STORAGE_SYMBOL] = created;
7150
+ storage = created;
7151
+ }
7152
+ }
7153
+ var rivetContextReady = asyncStorageReady.then(() => {
7154
+ initializeStorage();
7155
+ });
7156
+ function getRivetContextBinding() {
7157
+ initializeStorage();
7158
+ return storage?.getStore() ?? browserBinding ?? void 0;
7159
+ }
7160
+ function runWithBrowserBinding(binding, fn) {
7161
+ const previous = browserBinding;
7162
+ browserBinding = binding;
7163
+ try {
7164
+ const result = fn();
7165
+ if (result instanceof Promise) {
7166
+ return result.finally(() => {
7167
+ browserBinding = previous;
7168
+ });
7169
+ }
7170
+ browserBinding = previous;
7171
+ return result;
7172
+ } catch (error) {
7173
+ browserBinding = previous;
7174
+ throw error;
7175
+ }
7176
+ }
7177
+ function runWithRivetContext(binding, fn) {
7178
+ initializeStorage();
7179
+ if (!storage && !isAsyncStorageInitDone()) {
7180
+ return rivetContextReady.then(() => runWithRivetContext(binding, fn));
7181
+ }
7182
+ if (storage) {
7183
+ return storage.run(binding, fn);
7184
+ }
7185
+ return runWithBrowserBinding(binding, fn);
7186
+ }
7187
+
7188
+ // src/rivetIntegration.ts
7189
+ var RIVET_DOCS_URL = "https://docs.bitfab.ai/frameworks/rivet";
7190
+ var RIVET_GROUP_EFFECT_METHODS = {
7191
+ db: ["execute", "nativeMetrics", "close"],
7192
+ kv: [
7193
+ "get",
7194
+ "put",
7195
+ "delete",
7196
+ "batchPut",
7197
+ "batchGet",
7198
+ "batchDelete",
7199
+ "deleteRange",
7200
+ "listPrefix",
7201
+ "listRange",
7202
+ "list"
7203
+ ],
7204
+ schedule: ["after", "at", "cancel", "get", "list"],
7205
+ cron: ["set", "every", "get", "list", "delete", "history"],
7206
+ queue: [
7207
+ "send",
7208
+ "next",
7209
+ "nextBatch",
7210
+ "waitForNames",
7211
+ "waitForAvailable",
7212
+ "complete",
7213
+ "enqueueAndWait",
7214
+ "tryNext",
7215
+ "tryNextBatch"
7216
+ ],
7217
+ run: ["setWakeAt"]
7218
+ };
7219
+ var RIVET_TOP_LEVEL_EFFECTS = [
7220
+ "broadcast",
7221
+ "saveState",
7222
+ "sleep",
7223
+ "destroy"
7224
+ ];
7225
+ var TOP_LEVEL_UNAVAILABLE_CAPABILITIES = /* @__PURE__ */ new Set([
7226
+ "conn",
7227
+ "conns",
7228
+ "log",
7229
+ "request",
7230
+ "actorRuntimeSocket",
7231
+ "keepAwake",
7232
+ "waitUntil",
7233
+ "client"
7234
+ ]);
7235
+ var SYNC_VOID_EFFECTS = /* @__PURE__ */ new Set([
7236
+ "broadcast",
7237
+ "sleep",
7238
+ "destroy"
7239
+ ]);
7240
+ var QUEUE_MESSAGE_EFFECTS = /* @__PURE__ */ new Set([
7241
+ "queue.next",
7242
+ "queue.nextBatch",
7243
+ "queue.waitForNames",
7244
+ "queue.tryNext",
7245
+ "queue.tryNextBatch"
7246
+ ]);
7247
+ function isRecord5(value) {
7248
+ return typeof value === "object" && value !== null;
7249
+ }
7250
+ function readProperty(value, property) {
7251
+ try {
7252
+ return Reflect.get(value, property, value);
7253
+ } catch {
7254
+ return void 0;
7255
+ }
7256
+ }
7257
+ function snapshotContext(context) {
7258
+ const source = context;
7259
+ const snapshot = {};
7260
+ for (const property of [
7261
+ "state",
7262
+ "vars",
7263
+ "actorId",
7264
+ "name",
7265
+ "key",
7266
+ "region",
7267
+ "aborted"
7268
+ ]) {
7269
+ const value = readProperty(source, property);
7270
+ if (value !== void 0) {
7271
+ snapshot[property] = value;
7272
+ }
7273
+ }
7274
+ return snapshot;
7275
+ }
7276
+ function unavailableCapability(path) {
7277
+ return new BitfabError(
7278
+ `Rivet context capability "${path}" is unavailable during replay. Add first-class support for that public context path before replaying code that uses it.`,
7279
+ RIVET_DOCS_URL
7280
+ );
7281
+ }
7282
+ function effectNode(traceFunctionKey, effect, mockSpanId) {
7283
+ return {
7284
+ traceFunctionKey,
7285
+ spanName: effect,
7286
+ type: "function",
7287
+ originalSpanId: mockSpanId
7288
+ };
7289
+ }
7290
+ function replayEffectStatus(replay2, traceFunctionKey, effect, marked) {
7291
+ const counterKey = `${traceFunctionKey}:${effect}`;
7292
+ const callIndex = replay2.callCounters?.get(counterKey) ?? 0;
7293
+ const mockSpan = replay2.mockTree?.spans.get(`${counterKey}:${callIndex}`);
7294
+ const hasOverride = replay2.mockOverrides?.some(
7295
+ (override) => override.match(
7296
+ effectNode(traceFunctionKey, effect, mockSpan?.sourceSpanId)
7297
+ )
7298
+ ) ?? false;
7299
+ return {
7300
+ willMock: hasOverride || replay2.mockStrategy === "all" || replay2.mockStrategy === "marked" && marked,
7301
+ hasRecordedSpan: mockSpan !== void 0,
7302
+ hasOverride,
7303
+ callIndex
7304
+ };
7305
+ }
7306
+ function assertReplayEffectAvailable(replay2, traceFunctionKey, effect, marked) {
7307
+ if (!replay2) {
7308
+ return;
7309
+ }
7310
+ const status = replayEffectStatus(replay2, traceFunctionKey, effect, marked);
7311
+ if (!status.willMock) {
7312
+ throw new BitfabError(
7313
+ `Rivet effect "${effect}" has no live actor context during replay. Add "${effect}" to mockOnReplay or provide a replay override.`,
7314
+ RIVET_DOCS_URL
7315
+ );
7316
+ }
7317
+ if (!status.hasRecordedSpan && !status.hasOverride) {
7318
+ throw new BitfabError(
7319
+ `No recorded Rivet effect "${effect}" exists at call ${status.callIndex + 1}; the live effect was not executed.`,
7320
+ RIVET_DOCS_URL
7321
+ );
7322
+ }
7323
+ }
7324
+ function fixtureName(traceFunctionKey) {
7325
+ return `rivet:${traceFunctionKey}`;
7326
+ }
7327
+ function snapshotFromReplay(traceFunctionKey, replay2) {
7328
+ const fixture = replay2.integrationFixtures?.get(fixtureName(traceFunctionKey));
7329
+ if (!isRecord5(fixture)) {
7330
+ throw new BitfabError(
7331
+ `Trace "${traceFunctionKey}" has no Rivet context fixture. Capture a fresh trace with the Rivet integration before replaying it.`,
7332
+ RIVET_DOCS_URL
7333
+ );
7334
+ }
7335
+ return fixture;
7336
+ }
7337
+ var BitfabRivetIntegration = class {
7338
+ /** @internal Constructed by `Bitfab.getRivetIntegration()`. */
7339
+ constructor(traceFunctionKey, runtime, options = {}) {
7340
+ this.traceFunctionKey = traceFunctionKey;
7341
+ this.runtime = runtime;
7342
+ this.replayProxies = /* @__PURE__ */ new WeakMap();
7343
+ this.markedEffects = new Set(options.mockOnReplay ?? []);
7344
+ }
7345
+ /**
7346
+ * Run a callback with a live Rivet context bound to the current async chain.
7347
+ * This binds context only; it creates no trace or span.
7348
+ */
7349
+ withContext(context, fn) {
7350
+ if (!isRecord5(context)) {
7351
+ throw new BitfabError("Rivet withContext requires a context object");
7352
+ }
7353
+ const binding = {
7354
+ context,
7355
+ fixtureContext: createIntegrationFixtureContext(
7356
+ fixtureName(this.traceFunctionKey),
7357
+ snapshotContext(context)
7358
+ ),
7359
+ recordedRoots: /* @__PURE__ */ new Set()
7360
+ };
7361
+ return runWithRivetContext(binding, fn);
7362
+ }
7363
+ /**
7364
+ * Adapt a traced function into a Rivet handler whose first argument is the
7365
+ * live actor context. The context is not added to the traced root's inputs.
7366
+ */
7367
+ bind(fn) {
7368
+ const integration = this;
7369
+ return function(context, ...args) {
7370
+ return integration.withContext(context, () => fn.apply(this, args));
7371
+ };
7372
+ }
7373
+ /**
7374
+ * Return the current Rivet context proxy. In production it delegates to the
7375
+ * bound live context. During replay it hydrates recorded actor state and
7376
+ * intercepts supported effects without requiring a live Rivet actor.
7377
+ */
7378
+ getContext() {
7379
+ const replay2 = getReplayContext();
7380
+ if (replay2) {
7381
+ const existing = this.replayProxies.get(replay2);
7382
+ if (existing) {
7383
+ return existing;
7384
+ }
7385
+ const proxy = this.createContextProxy(
7386
+ snapshotFromReplay(this.traceFunctionKey, replay2),
7387
+ void 0
7388
+ );
7389
+ this.replayProxies.set(replay2, proxy);
7390
+ return proxy;
7391
+ }
7392
+ const binding = getRivetContextBinding();
7393
+ if (!binding) {
7394
+ throw new BitfabError(
7395
+ "No Rivet context is bound. Call rivet.bind(handler) or rivet.withContext(context, callback) at the Rivet boundary.",
7396
+ RIVET_DOCS_URL
7397
+ );
7398
+ }
7399
+ this.runtime.recordRootFixture(
7400
+ binding.fixtureContext,
7401
+ binding.recordedRoots
7402
+ );
7403
+ if (!binding.proxy) {
7404
+ binding.proxy = this.createContextProxy(
7405
+ binding.context,
7406
+ binding
7407
+ );
7408
+ }
7409
+ return binding.proxy;
7410
+ }
7411
+ createContextProxy(target, binding) {
7412
+ const replay2 = getReplayContext();
7413
+ const dbProxy = this.createDbProxy(binding, replay2);
7414
+ const groupProxies = /* @__PURE__ */ new Map();
7415
+ for (const group of Object.keys(
7416
+ RIVET_GROUP_EFFECT_METHODS
7417
+ )) {
7418
+ if (group !== "db") {
7419
+ groupProxies.set(group, this.createGroupProxy(group, binding, replay2));
7420
+ }
7421
+ }
7422
+ const topLevelEffects = /* @__PURE__ */ new Map();
7423
+ for (const effect of RIVET_TOP_LEVEL_EFFECTS) {
7424
+ topLevelEffects.set(
7425
+ effect,
7426
+ this.createEffect(
7427
+ effect,
7428
+ () => binding?.context,
7429
+ effect,
7430
+ replay2
7431
+ )
7432
+ );
7433
+ }
7434
+ const replayTarget = replay2 ? { ...target } : target;
7435
+ if (replay2) {
7436
+ const controller = new AbortController();
7437
+ if (target.aborted === true) {
7438
+ controller.abort();
7439
+ }
7440
+ replayTarget.abortSignal = controller.signal;
7441
+ }
7442
+ return new Proxy(replayTarget, {
7443
+ get: (source, property) => {
7444
+ if (property === "db") {
7445
+ return dbProxy;
7446
+ }
7447
+ if (typeof property === "string") {
7448
+ const group = groupProxies.get(property);
7449
+ if (group) {
7450
+ return group;
7451
+ }
7452
+ const effect = topLevelEffects.get(property);
7453
+ if (effect) {
7454
+ return effect;
7455
+ }
7456
+ }
7457
+ if (property === "setPreventSleep" && replay2) {
7458
+ return (_preventSleep) => void 0;
7459
+ }
7460
+ if (replay2 && typeof property === "string" && TOP_LEVEL_UNAVAILABLE_CAPABILITIES.has(property)) {
7461
+ throw unavailableCapability(property);
7462
+ }
7463
+ const value = Reflect.get(source, property, source);
7464
+ return typeof value === "function" ? value.bind(source) : value;
7465
+ }
7466
+ });
7467
+ }
7468
+ createDbProxy(binding, replay2) {
7469
+ const proxy = this.createGroupProxy("db", binding, replay2);
7470
+ return new Proxy(proxy, {
7471
+ get: (source, property) => property === "transaction" ? this.createTransaction(binding, replay2) : Reflect.get(source, property, source)
7472
+ });
7473
+ }
7474
+ createGroupProxy(group, binding, replay2) {
7475
+ const targetProvider = () => {
7476
+ if (!binding) {
7477
+ return void 0;
7478
+ }
7479
+ const context = binding.context;
7480
+ const target = readProperty(context, group);
7481
+ return isRecord5(target) ? target : void 0;
7482
+ };
7483
+ const proxy = this.createMethodProxy(
7484
+ targetProvider,
7485
+ group,
7486
+ RIVET_GROUP_EFFECT_METHODS[group],
7487
+ replay2
7488
+ );
7489
+ if (group !== "queue") {
7490
+ return proxy;
7491
+ }
7492
+ return new Proxy(proxy, {
7493
+ get: (source, property) => property === "iter" ? (options) => this.createQueueIterator(source, options) : Reflect.get(source, property, source)
7494
+ });
7495
+ }
7496
+ createMethodProxy(targetProvider, prefix, methods, replay2) {
7497
+ const effects = /* @__PURE__ */ new Map();
7498
+ for (const method of methods) {
7499
+ const effect = `${prefix}.${method}`;
7500
+ effects.set(
7501
+ method,
7502
+ this.createEffect(effect, targetProvider, method, replay2)
7503
+ );
7504
+ }
7505
+ return new Proxy(
7506
+ {},
7507
+ {
7508
+ get: (_source, property) => {
7509
+ if (typeof property === "string") {
7510
+ const effect = effects.get(property);
7511
+ if (effect) {
7512
+ return effect;
7513
+ }
7514
+ if (replay2) {
7515
+ throw unavailableCapability(`${prefix}.${property}`);
7516
+ }
7517
+ }
7518
+ const target = targetProvider();
7519
+ if (!target) {
7520
+ return void 0;
7521
+ }
7522
+ const value = Reflect.get(target, property, target);
7523
+ return typeof value === "function" ? value.bind(target) : value;
7524
+ }
7525
+ }
7526
+ );
7527
+ }
7528
+ createEffect(effect, targetProvider, methodName, replay2) {
7529
+ const marked = this.markedEffects.has(effect);
7530
+ const invoke = (...args) => {
7531
+ assertReplayEffectAvailable(
7532
+ getReplayContext(),
7533
+ this.traceFunctionKey,
7534
+ effect,
7535
+ marked
7536
+ );
7537
+ const target = targetProvider();
7538
+ const method = target ? readProperty(target, methodName) : void 0;
7539
+ if (typeof method !== "function") {
7540
+ throw unavailableCapability(effect);
7541
+ }
7542
+ return method.apply(target, args);
7543
+ };
7544
+ const wrapped = SYNC_VOID_EFFECTS.has(effect) ? this.runtime.wrapEffect(
7545
+ effect,
7546
+ marked,
7547
+ invoke,
7548
+ replay2 ? () => void 0 : void 0
7549
+ ) : this.runtime.wrapEffect(effect, marked, async (...args) => {
7550
+ return await invoke(...args);
7551
+ });
7552
+ return (...args) => {
7553
+ if (replay2) {
7554
+ assertReplayEffectAvailable(
7555
+ replay2,
7556
+ this.traceFunctionKey,
7557
+ effect,
7558
+ marked
7559
+ );
7560
+ }
7561
+ const result = wrapped(...args);
7562
+ if (!QUEUE_MESSAGE_EFFECTS.has(effect) || !(result instanceof Promise)) {
7563
+ return result;
7564
+ }
7565
+ return result.then(
7566
+ (value) => this.decorateQueueMessages(value, effect, args, replay2)
7567
+ );
7568
+ };
7569
+ }
7570
+ createTransaction(binding, replay2) {
7571
+ return async (callback, options) => {
7572
+ if (typeof callback !== "function") {
7573
+ throw new BitfabError("Rivet db.transaction requires a callback");
7574
+ }
7575
+ if (replay2) {
7576
+ return await callback(
7577
+ this.createMethodProxy(
7578
+ () => void 0,
7579
+ "db.transaction",
7580
+ ["execute"],
7581
+ replay2
7582
+ )
7583
+ );
7584
+ }
7585
+ const context = binding?.context;
7586
+ const db = context ? readProperty(context, "db") : void 0;
7587
+ const transaction = isRecord5(db) ? readProperty(db, "transaction") : void 0;
7588
+ if (!isRecord5(db) || typeof transaction !== "function") {
7589
+ throw unavailableCapability("db.transaction");
7590
+ }
7591
+ return await transaction.call(
7592
+ db,
7593
+ async (transactionDb) => {
7594
+ if (!isRecord5(transactionDb)) {
7595
+ throw unavailableCapability("db.transaction.execute");
7596
+ }
7597
+ return await callback(
7598
+ this.createMethodProxy(
7599
+ () => transactionDb,
7600
+ "db.transaction",
7601
+ ["execute"],
7602
+ replay2
7603
+ )
7604
+ );
7605
+ },
7606
+ options
7607
+ );
7608
+ };
7609
+ }
7610
+ decorateQueueMessages(value, effect, args, replay2) {
7611
+ if (!this.queueCallIsCompletable(effect, args)) {
7612
+ return value;
7613
+ }
7614
+ if (Array.isArray(value)) {
7615
+ return value.map((message) => this.decorateQueueMessage(message, replay2));
7616
+ }
7617
+ return this.decorateQueueMessage(value, replay2);
7618
+ }
7619
+ decorateQueueMessage(value, replay2) {
7620
+ if (!isRecord5(value)) {
7621
+ return value;
7622
+ }
7623
+ const originalComplete = readProperty(value, "complete");
7624
+ const complete = this.createEffect(
7625
+ "queue.message.complete",
7626
+ () => typeof originalComplete === "function" ? { complete: originalComplete.bind(value) } : void 0,
7627
+ "complete",
7628
+ replay2
7629
+ );
7630
+ return { ...value, complete };
7631
+ }
7632
+ queueCallIsCompletable(effect, args) {
7633
+ const options = effect === "queue.waitForNames" ? args[1] : args[0];
7634
+ return isRecord5(options) && options.completable === true;
7635
+ }
7636
+ createQueueIterator(queue, options) {
7637
+ return {
7638
+ async *[Symbol.asyncIterator]() {
7639
+ for (; ; ) {
7640
+ const next = Reflect.get(queue, "next", queue);
7641
+ if (typeof next !== "function") {
7642
+ throw unavailableCapability("queue.next");
7643
+ }
7644
+ const message = await next.call(queue, options);
7645
+ if (message !== void 0 && message !== null) {
7646
+ yield message;
7647
+ }
7648
+ }
7649
+ }
7650
+ };
7651
+ }
7652
+ };
7653
+
6995
7654
  // src/seedContext.ts
6996
7655
  init_asyncStorage();
6997
7656
  var seedContextStorage = null;
@@ -7135,6 +7794,9 @@ var BitfabOpenAITracingProcessor = class {
7135
7794
  const activeContext = this.getActiveSpanContext?.();
7136
7795
  if (activeContext) {
7137
7796
  this.activeSpanMappings[trace.traceId] = activeContext;
7797
+ if (this.shouldRecord()) {
7798
+ mapOpenAiAgentsTrace(trace.traceId, activeContext.traceId);
7799
+ }
7138
7800
  }
7139
7801
  const canonicalTraceId = activeContext?.traceId ?? this.getCanonicalTraceId(trace.traceId);
7140
7802
  this.canonicalTraceIds[trace.traceId] = canonicalTraceId;
@@ -7172,6 +7834,7 @@ var BitfabOpenAITracingProcessor = class {
7172
7834
  }
7173
7835
  this.endedTraces.delete(traceId);
7174
7836
  delete this.activeSpanMappings[traceId];
7837
+ unmapOpenAiAgentsTrace(traceId);
7175
7838
  delete this.canonicalTraceIds[traceId];
7176
7839
  delete this.activeTraces[traceId];
7177
7840
  }
@@ -7196,6 +7859,9 @@ var BitfabOpenAITracingProcessor = class {
7196
7859
  async onSpanEnd(span) {
7197
7860
  const originalTraceId = span.traceId ?? "";
7198
7861
  const traceId = this.activeSpanMappings[originalTraceId]?.traceId ?? originalTraceId;
7862
+ if (span.spanId !== void 0) {
7863
+ endOpenAiAgentsSpan(originalTraceId, span.spanId);
7864
+ }
7199
7865
  try {
7200
7866
  this.sendSpan(span);
7201
7867
  } finally {
@@ -7216,6 +7882,9 @@ var BitfabOpenAITracingProcessor = class {
7216
7882
  * Called when the trace processor is shutting down.
7217
7883
  */
7218
7884
  async shutdown(timeout) {
7885
+ for (const traceId of Object.keys(this.activeSpanMappings)) {
7886
+ unmapOpenAiAgentsTrace(traceId);
7887
+ }
7219
7888
  this.activeTraces = {};
7220
7889
  this.activeSpanMappings = {};
7221
7890
  this.canonicalTraceIds = {};
@@ -8373,16 +9042,16 @@ var Bitfab = class {
8373
9042
  this.simulationPlan.send(payload, rootTraceFunctionKeyOf(payload), submit);
8374
9043
  }
8375
9044
  refreshAutoTraceCapturePolicy(traceFunctionKey) {
8376
- const state = this.autoTracePolicyRefreshes.get(traceFunctionKey) ?? new PolicyRefresh();
8377
- this.autoTracePolicyRefreshes.set(traceFunctionKey, state);
8378
- state.run(
9045
+ const state2 = this.autoTracePolicyRefreshes.get(traceFunctionKey) ?? new PolicyRefresh();
9046
+ this.autoTracePolicyRefreshes.set(traceFunctionKey, state2);
9047
+ state2.run(
8379
9048
  () => this.httpClient.getAutoTracePolicy(
8380
9049
  traceFunctionKey,
8381
9050
  AUTO_TRACE_PROTOCOL
8382
9051
  ),
8383
9052
  (policy) => {
8384
9053
  if (policy.protocol !== AUTO_TRACE_PROTOCOL) {
8385
- state.hold(AUTO_TRACE_POLICY_RETRY_MS);
9054
+ state2.hold(AUTO_TRACE_POLICY_RETRY_MS);
8386
9055
  return;
8387
9056
  }
8388
9057
  const functionIds = Array.isArray(policy.functionIds) ? policy.functionIds.filter(
@@ -8393,10 +9062,10 @@ var Bitfab = class {
8393
9062
  traceFunctionKey,
8394
9063
  policy.revision === null ? void 0 : functionIds
8395
9064
  );
8396
- state.hold(AUTO_TRACE_POLICY_REFRESH_MS);
9065
+ state2.hold(AUTO_TRACE_POLICY_REFRESH_MS);
8397
9066
  },
8398
9067
  () => {
8399
- state.hold(AUTO_TRACE_POLICY_RETRY_MS);
9068
+ state2.hold(AUTO_TRACE_POLICY_RETRY_MS);
8400
9069
  }
8401
9070
  );
8402
9071
  }
@@ -8701,6 +9370,47 @@ var Bitfab = class {
8701
9370
  options
8702
9371
  });
8703
9372
  }
9373
+ /**
9374
+ * Get the first-class Rivet actor-context integration for an existing trace
9375
+ * root. The integration binds context and records effect spans; it never
9376
+ * creates another root.
9377
+ *
9378
+ * @param traceFunctionKey - Key used by the enclosing `withTrace()` root
9379
+ * @param options - Explicit per-context-path replay mocking policy
9380
+ * @experimental This API may change before it is stable.
9381
+ */
9382
+ getRivetIntegration(traceFunctionKey, options) {
9383
+ return new BitfabRivetIntegration(
9384
+ traceFunctionKey,
9385
+ {
9386
+ wrapEffect: (effect, mockOnReplay, fn, replayOutput) => {
9387
+ const spanOptions = {
9388
+ name: effect,
9389
+ type: "function",
9390
+ captureWhen: "nested",
9391
+ mockOnReplay,
9392
+ surface: "inherit",
9393
+ instrumentation: "rivet",
9394
+ ...replayOutput !== void 0 && { replayOutput }
9395
+ };
9396
+ return this.withSpan(traceFunctionKey, spanOptions, fn);
9397
+ },
9398
+ recordRootFixture: (context, recordedRoots) => {
9399
+ const root = getSpanStack()[0];
9400
+ if (!root) {
9401
+ return;
9402
+ }
9403
+ const rootId = `${root.traceId}:${root.spanId}`;
9404
+ if (recordedRoots.has(rootId)) {
9405
+ return;
9406
+ }
9407
+ root.contexts.push(context);
9408
+ recordedRoots.add(rootId);
9409
+ }
9410
+ },
9411
+ options
9412
+ );
9413
+ }
8704
9414
  /**
8705
9415
  * Get a Claude Agent SDK handler for tracing.
8706
9416
  *
@@ -8966,7 +9676,11 @@ var Bitfab = class {
8966
9676
  const seedCtxForTraceId = parentContext ? null : getSeedContext();
8967
9677
  const traceId = parentContext?.traceId ?? replayCtxForTraceId?.traceId ?? seedCtxForTraceId?.traceId ?? randomUuid();
8968
9678
  const spanId = randomUuid();
8969
- const parentSpanId = parentContext?.spanId ?? null;
9679
+ const openAiAgentsParent = parentContext !== void 0 && options.instrumentation === "trace" ? openAiAgentsParentSpanId(
9680
+ parentContext.traceId,
9681
+ parentContext.openAiAgentsSpanIds
9682
+ ) : void 0;
9683
+ const parentSpanId = openAiAgentsParent ?? parentContext?.spanId ?? null;
8970
9684
  const isRootSpan = parentSpanId === null;
8971
9685
  if (options.enclosingTrace !== void 0) {
8972
9686
  options.enclosingTrace.link.traceId = traceId;
@@ -8980,11 +9694,13 @@ var Bitfab = class {
8980
9694
  parentContext?.surface,
8981
9695
  traceFunctionKey
8982
9696
  );
9697
+ const openAiAgentsSpanIds = openAiAgentsSpanChain();
8983
9698
  const newContext = {
8984
9699
  traceId,
8985
9700
  spanId,
8986
9701
  contexts: [],
8987
- ...surface !== void 0 && { surface }
9702
+ ...surface !== void 0 && { surface },
9703
+ ...openAiAgentsSpanIds.length > 0 && { openAiAgentsSpanIds }
8988
9704
  };
8989
9705
  newStack = [...currentStack, newContext];
8990
9706
  const inputs = args;
@@ -9199,6 +9915,7 @@ var Bitfab = class {
9199
9915
  }
9200
9916
  return output;
9201
9917
  };
9918
+ const resolveBaseOutput = () => options.replayOutput !== void 0 ? options.replayOutput() : resolveRecordedOutput();
9202
9919
  const shouldMockWithBaseStrategy = replayCtxForMock.mockStrategy === "all" || replayCtxForMock.mockStrategy === "marked" && options.mockOnReplay === true;
9203
9920
  if (replayCtxForMock.mockOverrides?.length) {
9204
9921
  const nodeMeta = {
@@ -9255,7 +9972,7 @@ var Bitfab = class {
9255
9972
  }
9256
9973
  if (shouldMockWithBaseStrategy) {
9257
9974
  const output = await resolveMockOrAbort(
9258
- () => resolveRecordedOutput()
9975
+ () => resolveBaseOutput()
9259
9976
  );
9260
9977
  void sendSpan({
9261
9978
  result: output,
@@ -9278,7 +9995,7 @@ var Bitfab = class {
9278
9995
  );
9279
9996
  }
9280
9997
  if (shouldMockWithBaseStrategy) {
9281
- const recorded = resolveRecordedOutput();
9998
+ const recorded = resolveBaseOutput();
9282
9999
  if (recorded instanceof Promise) {
9283
10000
  return emitMockAsync(recorded, "recorded");
9284
10001
  }
@@ -9880,6 +10597,28 @@ var BitfabFunction = class {
9880
10597
  span(options = {}) {
9881
10598
  return this.client.span(this.traceFunctionKey, options);
9882
10599
  }
10600
+ withTrace(optionsOrFn, maybeFn) {
10601
+ if (typeof optionsOrFn === "function") {
10602
+ return this.client.withTrace(this.traceFunctionKey, optionsOrFn);
10603
+ }
10604
+ if (!maybeFn) {
10605
+ throw new BitfabError("BitfabFunction.withTrace requires a function");
10606
+ }
10607
+ return this.client.withTrace(this.traceFunctionKey, optionsOrFn, maybeFn);
10608
+ }
10609
+ /**
10610
+ * Create a trace method decorator bound to this function's key.
10611
+ *
10612
+ * Equivalent to `client.trace(key, options)` but reuses the key bound on
10613
+ * this handle.
10614
+ *
10615
+ * @param options - Trace configuration applied to the decorated method
10616
+ * @returns A method decorator configured for this key
10617
+ * @experimental Automatic child-call instrumentation is experimental.
10618
+ */
10619
+ trace(options = {}) {
10620
+ return this.client.trace(this.traceFunctionKey, options);
10621
+ }
9883
10622
  /**
9884
10623
  * Get a Vercel AI SDK language-model middleware bound to this function's key.
9885
10624
  *
@@ -9977,6 +10716,20 @@ var BitfabFunction = class {
9977
10716
  getLangGraphIntegration(options) {
9978
10717
  return this.client.getLangGraphIntegration(this.traceFunctionKey, options);
9979
10718
  }
10719
+ /**
10720
+ * Get the first-class Rivet actor-context integration bound to this key.
10721
+ * Use its `bind()` or `withContext()` outside this handle's `withTrace()`
10722
+ * root, then call `getContext()` inside the root.
10723
+ *
10724
+ * @param options - Explicit per-context-path replay mocking policy
10725
+ * @experimental This API may change before it is stable.
10726
+ */
10727
+ getRivetIntegration(options) {
10728
+ return this.client.getRivetIntegration(
10729
+ this.traceFunctionKey,
10730
+ options
10731
+ );
10732
+ }
9980
10733
  /**
9981
10734
  * Wrap a BAML client method to automatically capture prompt and LLM metadata.
9982
10735
  * Delegates to the parent client's wrapBAML method.
@@ -10142,6 +10895,7 @@ assertAsyncStorageRegistered();
10142
10895
  BitfabLangGraphIntegration,
10143
10896
  BitfabOpenAIAgentHandler,
10144
10897
  BitfabOpenAITracingProcessor,
10898
+ BitfabRivetIntegration,
10145
10899
  BitfabVercelAiHandler,
10146
10900
  DEFAULT_SERVICE_URL,
10147
10901
  DatasetsClient,