@bitfab/sdk 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-RNIFPMQM.js → chunk-EG2BK73V.js} +3 -3
  2. package/dist/chunk-EG2BK73V.js.map +1 -0
  3. package/dist/{chunk-UL4D3J5B.js → chunk-GQNLAY72.js} +4 -3
  4. package/dist/chunk-GQNLAY72.js.map +1 -0
  5. package/dist/{chunk-B7CO654C.js → chunk-MC2NKYDY.js} +6 -4
  6. package/dist/chunk-MC2NKYDY.js.map +1 -0
  7. package/dist/{chunk-I5Z3CTO6.js → chunk-NLJLEF7Q.js} +710 -16
  8. package/dist/chunk-NLJLEF7Q.js.map +1 -0
  9. package/dist/{chunk-4PMIFWUB.js → chunk-WEUG3N7A.js} +85 -40
  10. package/dist/chunk-WEUG3N7A.js.map +1 -0
  11. package/dist/{http-ARMDS4NC.js → http-3NVEDIBT.js} +2 -2
  12. package/dist/{http-FQNKAPY2.js → http-L357FQLN.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-TTZS5HU2.js → replay-ZXA5AA2M.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-4PMIFWUB.js.map +0 -1
  29. package/dist/chunk-B7CO654C.js.map +0 -1
  30. package/dist/chunk-I5Z3CTO6.js.map +0 -1
  31. package/dist/chunk-RNIFPMQM.js.map +0 -1
  32. package/dist/chunk-UL4D3J5B.js.map +0 -1
  33. /package/dist/{http-ARMDS4NC.js.map → http-3NVEDIBT.js.map} +0 -0
  34. /package/dist/{http-FQNKAPY2.js.map → http-L357FQLN.js.map} +0 -0
  35. /package/dist/{replay-TTZS5HU2.js.map → replay-ZXA5AA2M.js.map} +0 -0
package/dist/node.cjs CHANGED
@@ -88,7 +88,7 @@ var __version__, __packageName__;
88
88
  var init_version_generated = __esm({
89
89
  "src/version.generated.ts"() {
90
90
  "use strict";
91
- __version__ = "0.54.9";
91
+ __version__ = "0.54.11";
92
92
  __packageName__ = "@bitfab/sdk";
93
93
  }
94
94
  });
@@ -114,20 +114,20 @@ var init_traceCompletion = __esm({
114
114
  this.closed = /* @__PURE__ */ new Map();
115
115
  }
116
116
  state(traceId) {
117
- let state = this.traces.get(traceId);
118
- if (state === void 0) {
119
- state = { spanIds: /* @__PURE__ */ new Set(), active: /* @__PURE__ */ new Set() };
120
- this.traces.set(traceId, state);
117
+ let state2 = this.traces.get(traceId);
118
+ if (state2 === void 0) {
119
+ state2 = { spanIds: /* @__PURE__ */ new Set(), active: /* @__PURE__ */ new Set() };
120
+ this.traces.set(traceId, state2);
121
121
  }
122
- return state;
122
+ return state2;
123
123
  }
124
124
  start(traceId, spanId) {
125
125
  if (this.closed.has(traceId)) {
126
126
  return;
127
127
  }
128
- const state = this.state(traceId);
129
- state.spanIds.add(spanId);
130
- state.active.add(spanId);
128
+ const state2 = this.state(traceId);
129
+ state2.spanIds.add(spanId);
130
+ state2.active.add(spanId);
131
131
  }
132
132
  open(traceId) {
133
133
  if (!this.closed.has(traceId)) {
@@ -143,24 +143,24 @@ var init_traceCompletion = __esm({
143
143
  }
144
144
  }
145
145
  end(traceId, spanId) {
146
- const state = this.traces.get(traceId);
147
- if (state !== void 0) {
148
- state.active.delete(spanId);
149
- this.drain(traceId, state);
146
+ const state2 = this.traces.get(traceId);
147
+ if (state2 !== void 0) {
148
+ state2.active.delete(spanId);
149
+ this.drain(traceId, state2);
150
150
  }
151
151
  }
152
152
  abort(traceId, spanId) {
153
- const state = this.traces.get(traceId);
154
- if (state === void 0) {
153
+ const state2 = this.traces.get(traceId);
154
+ if (state2 === void 0) {
155
155
  return;
156
156
  }
157
- state.active.delete(spanId);
158
- state.spanIds.delete(spanId);
159
- if (state.active.size === 0 && state.spanIds.size === 0 && state.complete === void 0) {
157
+ state2.active.delete(spanId);
158
+ state2.spanIds.delete(spanId);
159
+ if (state2.active.size === 0 && state2.spanIds.size === 0 && state2.complete === void 0) {
160
160
  this.traces.delete(traceId);
161
161
  return;
162
162
  }
163
- this.drain(traceId, state);
163
+ this.drain(traceId, state2);
164
164
  }
165
165
  close(traceId, complete, dropped = false) {
166
166
  const count = this.closed.get(traceId);
@@ -168,29 +168,29 @@ var init_traceCompletion = __esm({
168
168
  complete(count);
169
169
  return;
170
170
  }
171
- const state = this.traces.get(traceId);
172
- if (state === void 0) {
171
+ const state2 = this.traces.get(traceId);
172
+ if (state2 === void 0) {
173
173
  return;
174
174
  }
175
- state.complete = complete;
175
+ state2.complete = complete;
176
176
  if (dropped) {
177
- state.active.clear();
177
+ state2.active.clear();
178
178
  }
179
- this.drain(traceId, state);
179
+ this.drain(traceId, state2);
180
180
  }
181
- drain(traceId, state) {
182
- if (state.active.size !== 0 || state.complete === void 0) {
181
+ drain(traceId, state2) {
182
+ if (state2.active.size !== 0 || state2.complete === void 0) {
183
183
  return;
184
184
  }
185
185
  this.traces.delete(traceId);
186
- this.closed.set(traceId, state.spanIds.size);
186
+ this.closed.set(traceId, state2.spanIds.size);
187
187
  if (this.closed.size > 1024) {
188
188
  const oldest = this.closed.keys().next().value;
189
189
  if (oldest !== void 0) {
190
190
  this.closed.delete(oldest);
191
191
  }
192
192
  }
193
- state.complete(state.spanIds.size);
193
+ state2.complete(state2.spanIds.size);
194
194
  }
195
195
  };
196
196
  }
@@ -441,8 +441,8 @@ function text(value) {
441
441
  const trimmed = value?.trim();
442
442
  return trimmed ? trimmed : null;
443
443
  }
444
- function isEmptyGitState(state) {
445
- return Object.values(state).every((value) => value === null);
444
+ function isEmptyGitState(state2) {
445
+ return Object.values(state2).every((value) => value === null);
446
446
  }
447
447
  async function resolveGitState(cwd) {
448
448
  const git = await gitRunner({
@@ -463,14 +463,14 @@ async function resolveGitState(cwd) {
463
463
  if (!root) {
464
464
  return null;
465
465
  }
466
- const state = {
466
+ const state2 = {
467
467
  githubEmail: text(email),
468
468
  branch: text(branch),
469
469
  commitSha: sha(commitSha),
470
470
  baseSha: sha(baseSha),
471
471
  experimentSha: await resolveWorkingTreeSha(run, root.trim())
472
472
  };
473
- return isEmptyGitState(state) ? null : state;
473
+ return isEmptyGitState(state2) ? null : state2;
474
474
  }
475
475
  async function resolveWorkingTreeSha(run, root) {
476
476
  let indexPath;
@@ -834,8 +834,8 @@ function encodePayloadBody(payload) {
834
834
  const marker = { error: `payload_serialize_failed: ${message}` };
835
835
  return { body: JSON.stringify(marker), dropped, value: marker };
836
836
  }
837
- const isRecord4 = typeof sanitized === "object" && sanitized !== null && !Array.isArray(sanitized);
838
- if (dropped.length > 0 && isRecord4) {
837
+ const isRecord6 = typeof sanitized === "object" && sanitized !== null && !Array.isArray(sanitized);
838
+ if (dropped.length > 0 && isRecord6) {
839
839
  const obj = sanitized;
840
840
  const existing = Array.isArray(obj.errors) ? obj.errors : [];
841
841
  obj.errors = [
@@ -852,7 +852,7 @@ function encodePayloadBody(payload) {
852
852
  return {
853
853
  body: JSON.stringify(sanitized),
854
854
  dropped,
855
- value: isRecord4 ? sanitized : void 0
855
+ value: isRecord6 ? sanitized : void 0
856
856
  };
857
857
  }
858
858
  }
@@ -954,13 +954,15 @@ var init_spanOrigin = __esm({
954
954
  "openai-agents",
955
955
  "langgraph",
956
956
  "claude-agent-sdk",
957
- "vercel-ai"
957
+ "vercel-ai",
958
+ "rivet"
958
959
  ];
959
960
  FRAMEWORK_INSTRUMENTATIONS = [
960
961
  "openai-agents",
961
962
  "langgraph",
962
963
  "claude-agent-sdk",
963
- "vercel-ai"
964
+ "vercel-ai",
965
+ "rivet"
964
966
  ];
965
967
  FRAMEWORK_INSTRUMENTATION_SET = new Set(
966
968
  FRAMEWORK_INSTRUMENTATIONS
@@ -3464,6 +3466,55 @@ var init_codeChange = __esm({
3464
3466
  }
3465
3467
  });
3466
3468
 
3469
+ // src/integrationFixture.ts
3470
+ function isRecord4(value) {
3471
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3472
+ }
3473
+ function createIntegrationFixtureContext(name, value) {
3474
+ const serialized = serializeValue(value);
3475
+ return {
3476
+ [INTEGRATION_FIXTURE_CONTEXT_KEY]: {
3477
+ version: INTEGRATION_FIXTURE_VERSION,
3478
+ name,
3479
+ value: serialized.json,
3480
+ ...serialized.meta !== void 0 && { valueMeta: serialized.meta }
3481
+ }
3482
+ };
3483
+ }
3484
+ function extractIntegrationFixtures(spanData) {
3485
+ const contexts = spanData.contexts;
3486
+ if (!Array.isArray(contexts)) {
3487
+ return void 0;
3488
+ }
3489
+ const fixtures = /* @__PURE__ */ new Map();
3490
+ for (const context of contexts) {
3491
+ if (!isRecord4(context)) {
3492
+ continue;
3493
+ }
3494
+ const fixture = context[INTEGRATION_FIXTURE_CONTEXT_KEY];
3495
+ if (!isRecord4(fixture) || fixture.version !== INTEGRATION_FIXTURE_VERSION || typeof fixture.name !== "string") {
3496
+ continue;
3497
+ }
3498
+ fixtures.set(
3499
+ fixture.name,
3500
+ deserializeValue({
3501
+ json: fixture.value,
3502
+ ...fixture.valueMeta !== void 0 && { meta: fixture.valueMeta }
3503
+ })
3504
+ );
3505
+ }
3506
+ return fixtures.size > 0 ? fixtures : void 0;
3507
+ }
3508
+ var INTEGRATION_FIXTURE_CONTEXT_KEY, INTEGRATION_FIXTURE_VERSION;
3509
+ var init_integrationFixture = __esm({
3510
+ "src/integrationFixture.ts"() {
3511
+ "use strict";
3512
+ init_serialize();
3513
+ INTEGRATION_FIXTURE_CONTEXT_KEY = "__bitfabIntegrationFixture";
3514
+ INTEGRATION_FIXTURE_VERSION = 1;
3515
+ }
3516
+ });
3517
+
3467
3518
  // src/replay.ts
3468
3519
  var replay_exports = {};
3469
3520
  __export(replay_exports, {
@@ -3688,6 +3739,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
3688
3739
  const spanData = span.rawData?.span_data ?? {};
3689
3740
  inputs = deserializeInputs(spanData);
3690
3741
  originalOutput = deserializeOutput(spanData);
3742
+ const integrationFixtures = extractIntegrationFixtures(spanData);
3691
3743
  if (adaptInputs) {
3692
3744
  const originalMetadata = serverItem.originalMetadata;
3693
3745
  inputs = adaptInputs(inputs, {
@@ -3779,6 +3831,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
3779
3831
  mockStrategy,
3780
3832
  mockOverrides: hasOverrides ? resolvedOverrides : void 0,
3781
3833
  fetchSpanOutput,
3834
+ integrationFixtures,
3782
3835
  dbBranchLease: lease,
3783
3836
  dbBranchTimings
3784
3837
  },
@@ -4259,6 +4312,7 @@ var init_replay = __esm({
4259
4312
  init_codeChange();
4260
4313
  init_errors();
4261
4314
  init_http();
4315
+ init_integrationFixture();
4262
4316
  init_mockOverride();
4263
4317
  init_randomUuid();
4264
4318
  init_replayContext();
@@ -4302,6 +4356,7 @@ __export(node_exports, {
4302
4356
  BitfabLangGraphIntegration: () => BitfabLangGraphIntegration,
4303
4357
  BitfabOpenAIAgentHandler: () => BitfabOpenAIAgentHandler,
4304
4358
  BitfabOpenAITracingProcessor: () => BitfabOpenAITracingProcessor,
4359
+ BitfabRivetIntegration: () => BitfabRivetIntegration,
4305
4360
  BitfabVercelAiHandler: () => BitfabVercelAiHandler,
4306
4361
  DEFAULT_SERVICE_URL: () => DEFAULT_SERVICE_URL,
4307
4362
  DatasetsClient: () => DatasetsClient,
@@ -6930,6 +6985,83 @@ var BitfabOpenAIAgentHandler = class {
6930
6985
  }
6931
6986
  };
6932
6987
 
6988
+ // src/openaiAgentsSpanContext.ts
6989
+ var OPENAI_AGENTS_CONTEXT_STORAGE = /* @__PURE__ */ Symbol.for(
6990
+ "openai.agents.core.asyncLocalStorage"
6991
+ );
6992
+ var MAX_OPENAI_AGENTS_SPAN_CHAIN = 64;
6993
+ var spanGlobal = globalThis;
6994
+ var state = spanGlobal.__bitfabOpenAiAgentsSpansV1 ?? {
6995
+ bitfabTraceIds: /* @__PURE__ */ new Map(),
6996
+ endedSpanIds: /* @__PURE__ */ new Map()
6997
+ };
6998
+ spanGlobal.__bitfabOpenAiAgentsSpansV1 = state;
6999
+ function mapOpenAiAgentsTrace(agentsTraceId, bitfabTraceId) {
7000
+ state.bitfabTraceIds.set(agentsTraceId, bitfabTraceId);
7001
+ }
7002
+ function unmapOpenAiAgentsTrace(agentsTraceId) {
7003
+ state.bitfabTraceIds.delete(agentsTraceId);
7004
+ state.endedSpanIds.delete(agentsTraceId);
7005
+ }
7006
+ function endOpenAiAgentsSpan(agentsTraceId, spanId) {
7007
+ if (!state.bitfabTraceIds.has(agentsTraceId)) {
7008
+ return;
7009
+ }
7010
+ const ended = state.endedSpanIds.get(agentsTraceId) ?? /* @__PURE__ */ new Set();
7011
+ ended.add(spanId);
7012
+ state.endedSpanIds.set(agentsTraceId, ended);
7013
+ }
7014
+ function isOpenAiAgentsContextStorage(value) {
7015
+ return value !== null && typeof value === "object" && typeof value.getStore === "function";
7016
+ }
7017
+ function currentOpenAiAgentsSpan() {
7018
+ const storage2 = spanGlobal[OPENAI_AGENTS_CONTEXT_STORAGE];
7019
+ if (!isOpenAiAgentsContextStorage(storage2)) {
7020
+ return void 0;
7021
+ }
7022
+ try {
7023
+ const store = storage2.getStore();
7024
+ return store?.active === true ? store.span ?? void 0 : void 0;
7025
+ } catch {
7026
+ return void 0;
7027
+ }
7028
+ }
7029
+ function currentOpenAiAgentsSpans() {
7030
+ const spans = [];
7031
+ let span = currentOpenAiAgentsSpan();
7032
+ while (span !== void 0 && spans.length < MAX_OPENAI_AGENTS_SPAN_CHAIN) {
7033
+ spans.push(span);
7034
+ span = span.previousSpan ?? void 0;
7035
+ }
7036
+ return spans;
7037
+ }
7038
+ function openAiAgentsSpanChain() {
7039
+ if (state.bitfabTraceIds.size === 0) {
7040
+ return [];
7041
+ }
7042
+ return currentOpenAiAgentsSpans().map((span) => span.spanId).filter((spanId) => typeof spanId === "string");
7043
+ }
7044
+ function openAiAgentsParentSpanId(bitfabTraceId, enclosingSpanIds) {
7045
+ if (state.bitfabTraceIds.size === 0) {
7046
+ return void 0;
7047
+ }
7048
+ for (const span of currentOpenAiAgentsSpans()) {
7049
+ if (typeof span.spanId !== "string" || typeof span.traceId !== "string") {
7050
+ return void 0;
7051
+ }
7052
+ if (state.bitfabTraceIds.get(span.traceId) !== bitfabTraceId) {
7053
+ return void 0;
7054
+ }
7055
+ if (enclosingSpanIds?.includes(span.spanId)) {
7056
+ return void 0;
7057
+ }
7058
+ if (!state.endedSpanIds.get(span.traceId)?.has(span.spanId)) {
7059
+ return span.spanId;
7060
+ }
7061
+ }
7062
+ return void 0;
7063
+ }
7064
+
6933
7065
  // src/client.ts
6934
7066
  init_policyRefresh();
6935
7067
  init_randomUuid();
@@ -6983,6 +7115,533 @@ _context = new WeakMap();
6983
7115
  // src/client.ts
6984
7116
  init_replayContext();
6985
7117
 
7118
+ // src/rivetIntegration.ts
7119
+ init_errors();
7120
+ init_integrationFixture();
7121
+ init_replayContext();
7122
+
7123
+ // src/rivetContext.ts
7124
+ init_asyncStorage();
7125
+ var storage = null;
7126
+ var browserBinding = null;
7127
+ var STORAGE_SYMBOL = /* @__PURE__ */ Symbol.for("bitfab.rivetContextStorage");
7128
+ function initializeStorage() {
7129
+ if (storage) {
7130
+ return;
7131
+ }
7132
+ const shared = globalThis;
7133
+ const existing = shared[STORAGE_SYMBOL];
7134
+ if (existing) {
7135
+ storage = existing;
7136
+ return;
7137
+ }
7138
+ const created = createAsyncLocalStorage();
7139
+ if (created) {
7140
+ shared[STORAGE_SYMBOL] = created;
7141
+ storage = created;
7142
+ }
7143
+ }
7144
+ var rivetContextReady = asyncStorageReady.then(() => {
7145
+ initializeStorage();
7146
+ });
7147
+ function getRivetContextBinding() {
7148
+ initializeStorage();
7149
+ return storage?.getStore() ?? browserBinding ?? void 0;
7150
+ }
7151
+ function runWithBrowserBinding(binding, fn) {
7152
+ const previous = browserBinding;
7153
+ browserBinding = binding;
7154
+ try {
7155
+ const result = fn();
7156
+ if (result instanceof Promise) {
7157
+ return result.finally(() => {
7158
+ browserBinding = previous;
7159
+ });
7160
+ }
7161
+ browserBinding = previous;
7162
+ return result;
7163
+ } catch (error) {
7164
+ browserBinding = previous;
7165
+ throw error;
7166
+ }
7167
+ }
7168
+ function runWithRivetContext(binding, fn) {
7169
+ initializeStorage();
7170
+ if (!storage && !isAsyncStorageInitDone()) {
7171
+ return rivetContextReady.then(() => runWithRivetContext(binding, fn));
7172
+ }
7173
+ if (storage) {
7174
+ return storage.run(binding, fn);
7175
+ }
7176
+ return runWithBrowserBinding(binding, fn);
7177
+ }
7178
+
7179
+ // src/rivetIntegration.ts
7180
+ var RIVET_DOCS_URL = "https://docs.bitfab.ai/frameworks/rivet";
7181
+ var RIVET_GROUP_EFFECT_METHODS = {
7182
+ db: ["execute", "nativeMetrics", "close"],
7183
+ kv: [
7184
+ "get",
7185
+ "put",
7186
+ "delete",
7187
+ "batchPut",
7188
+ "batchGet",
7189
+ "batchDelete",
7190
+ "deleteRange",
7191
+ "listPrefix",
7192
+ "listRange",
7193
+ "list"
7194
+ ],
7195
+ schedule: ["after", "at", "cancel", "get", "list"],
7196
+ cron: ["set", "every", "get", "list", "delete", "history"],
7197
+ queue: [
7198
+ "send",
7199
+ "next",
7200
+ "nextBatch",
7201
+ "waitForNames",
7202
+ "waitForAvailable",
7203
+ "complete",
7204
+ "enqueueAndWait",
7205
+ "tryNext",
7206
+ "tryNextBatch"
7207
+ ],
7208
+ run: ["setWakeAt"]
7209
+ };
7210
+ var RIVET_TOP_LEVEL_EFFECTS = [
7211
+ "broadcast",
7212
+ "saveState",
7213
+ "sleep",
7214
+ "destroy"
7215
+ ];
7216
+ var TOP_LEVEL_UNAVAILABLE_CAPABILITIES = /* @__PURE__ */ new Set([
7217
+ "conn",
7218
+ "conns",
7219
+ "log",
7220
+ "request",
7221
+ "actorRuntimeSocket",
7222
+ "keepAwake",
7223
+ "waitUntil",
7224
+ "client"
7225
+ ]);
7226
+ var SYNC_VOID_EFFECTS = /* @__PURE__ */ new Set([
7227
+ "broadcast",
7228
+ "sleep",
7229
+ "destroy"
7230
+ ]);
7231
+ var QUEUE_MESSAGE_EFFECTS = /* @__PURE__ */ new Set([
7232
+ "queue.next",
7233
+ "queue.nextBatch",
7234
+ "queue.waitForNames",
7235
+ "queue.tryNext",
7236
+ "queue.tryNextBatch"
7237
+ ]);
7238
+ function isRecord5(value) {
7239
+ return typeof value === "object" && value !== null;
7240
+ }
7241
+ function readProperty(value, property) {
7242
+ try {
7243
+ return Reflect.get(value, property, value);
7244
+ } catch {
7245
+ return void 0;
7246
+ }
7247
+ }
7248
+ function snapshotContext(context) {
7249
+ const source = context;
7250
+ const snapshot = {};
7251
+ for (const property of [
7252
+ "state",
7253
+ "vars",
7254
+ "actorId",
7255
+ "name",
7256
+ "key",
7257
+ "region",
7258
+ "aborted"
7259
+ ]) {
7260
+ const value = readProperty(source, property);
7261
+ if (value !== void 0) {
7262
+ snapshot[property] = value;
7263
+ }
7264
+ }
7265
+ return snapshot;
7266
+ }
7267
+ function unavailableCapability(path) {
7268
+ return new BitfabError(
7269
+ `Rivet context capability "${path}" is unavailable during replay. Add first-class support for that public context path before replaying code that uses it.`,
7270
+ RIVET_DOCS_URL
7271
+ );
7272
+ }
7273
+ function effectNode(traceFunctionKey, effect, mockSpanId) {
7274
+ return {
7275
+ traceFunctionKey,
7276
+ spanName: effect,
7277
+ type: "function",
7278
+ originalSpanId: mockSpanId
7279
+ };
7280
+ }
7281
+ function replayEffectStatus(replay2, traceFunctionKey, effect, marked) {
7282
+ const counterKey = `${traceFunctionKey}:${effect}`;
7283
+ const callIndex = replay2.callCounters?.get(counterKey) ?? 0;
7284
+ const mockSpan = replay2.mockTree?.spans.get(`${counterKey}:${callIndex}`);
7285
+ const hasOverride = replay2.mockOverrides?.some(
7286
+ (override) => override.match(
7287
+ effectNode(traceFunctionKey, effect, mockSpan?.sourceSpanId)
7288
+ )
7289
+ ) ?? false;
7290
+ return {
7291
+ willMock: hasOverride || replay2.mockStrategy === "all" || replay2.mockStrategy === "marked" && marked,
7292
+ hasRecordedSpan: mockSpan !== void 0,
7293
+ hasOverride,
7294
+ callIndex
7295
+ };
7296
+ }
7297
+ function assertReplayEffectAvailable(replay2, traceFunctionKey, effect, marked) {
7298
+ if (!replay2) {
7299
+ return;
7300
+ }
7301
+ const status = replayEffectStatus(replay2, traceFunctionKey, effect, marked);
7302
+ if (!status.willMock) {
7303
+ throw new BitfabError(
7304
+ `Rivet effect "${effect}" has no live actor context during replay. Add "${effect}" to mockOnReplay or provide a replay override.`,
7305
+ RIVET_DOCS_URL
7306
+ );
7307
+ }
7308
+ if (!status.hasRecordedSpan && !status.hasOverride) {
7309
+ throw new BitfabError(
7310
+ `No recorded Rivet effect "${effect}" exists at call ${status.callIndex + 1}; the live effect was not executed.`,
7311
+ RIVET_DOCS_URL
7312
+ );
7313
+ }
7314
+ }
7315
+ function fixtureName(traceFunctionKey) {
7316
+ return `rivet:${traceFunctionKey}`;
7317
+ }
7318
+ function snapshotFromReplay(traceFunctionKey, replay2) {
7319
+ const fixture = replay2.integrationFixtures?.get(fixtureName(traceFunctionKey));
7320
+ if (!isRecord5(fixture)) {
7321
+ throw new BitfabError(
7322
+ `Trace "${traceFunctionKey}" has no Rivet context fixture. Capture a fresh trace with the Rivet integration before replaying it.`,
7323
+ RIVET_DOCS_URL
7324
+ );
7325
+ }
7326
+ return fixture;
7327
+ }
7328
+ var BitfabRivetIntegration = class {
7329
+ /** @internal Constructed by `Bitfab.getRivetIntegration()`. */
7330
+ constructor(traceFunctionKey, runtime, options = {}) {
7331
+ this.traceFunctionKey = traceFunctionKey;
7332
+ this.runtime = runtime;
7333
+ this.replayProxies = /* @__PURE__ */ new WeakMap();
7334
+ this.markedEffects = new Set(options.mockOnReplay ?? []);
7335
+ }
7336
+ /**
7337
+ * Run a callback with a live Rivet context bound to the current async chain.
7338
+ * This binds context only; it creates no trace or span.
7339
+ */
7340
+ withContext(context, fn) {
7341
+ if (!isRecord5(context)) {
7342
+ throw new BitfabError("Rivet withContext requires a context object");
7343
+ }
7344
+ const binding = {
7345
+ context,
7346
+ fixtureContext: createIntegrationFixtureContext(
7347
+ fixtureName(this.traceFunctionKey),
7348
+ snapshotContext(context)
7349
+ ),
7350
+ recordedRoots: /* @__PURE__ */ new Set()
7351
+ };
7352
+ return runWithRivetContext(binding, fn);
7353
+ }
7354
+ /**
7355
+ * Adapt a traced function into a Rivet handler whose first argument is the
7356
+ * live actor context. The context is not added to the traced root's inputs.
7357
+ */
7358
+ bind(fn) {
7359
+ const integration = this;
7360
+ return function(context, ...args) {
7361
+ return integration.withContext(context, () => fn.apply(this, args));
7362
+ };
7363
+ }
7364
+ /**
7365
+ * Return the current Rivet context proxy. In production it delegates to the
7366
+ * bound live context. During replay it hydrates recorded actor state and
7367
+ * intercepts supported effects without requiring a live Rivet actor.
7368
+ */
7369
+ getContext() {
7370
+ const replay2 = getReplayContext();
7371
+ if (replay2) {
7372
+ const existing = this.replayProxies.get(replay2);
7373
+ if (existing) {
7374
+ return existing;
7375
+ }
7376
+ const proxy = this.createContextProxy(
7377
+ snapshotFromReplay(this.traceFunctionKey, replay2),
7378
+ void 0
7379
+ );
7380
+ this.replayProxies.set(replay2, proxy);
7381
+ return proxy;
7382
+ }
7383
+ const binding = getRivetContextBinding();
7384
+ if (!binding) {
7385
+ throw new BitfabError(
7386
+ "No Rivet context is bound. Call rivet.bind(handler) or rivet.withContext(context, callback) at the Rivet boundary.",
7387
+ RIVET_DOCS_URL
7388
+ );
7389
+ }
7390
+ this.runtime.recordRootFixture(
7391
+ binding.fixtureContext,
7392
+ binding.recordedRoots
7393
+ );
7394
+ if (!binding.proxy) {
7395
+ binding.proxy = this.createContextProxy(
7396
+ binding.context,
7397
+ binding
7398
+ );
7399
+ }
7400
+ return binding.proxy;
7401
+ }
7402
+ createContextProxy(target, binding) {
7403
+ const replay2 = getReplayContext();
7404
+ const dbProxy = this.createDbProxy(binding, replay2);
7405
+ const groupProxies = /* @__PURE__ */ new Map();
7406
+ for (const group of Object.keys(
7407
+ RIVET_GROUP_EFFECT_METHODS
7408
+ )) {
7409
+ if (group !== "db") {
7410
+ groupProxies.set(group, this.createGroupProxy(group, binding, replay2));
7411
+ }
7412
+ }
7413
+ const topLevelEffects = /* @__PURE__ */ new Map();
7414
+ for (const effect of RIVET_TOP_LEVEL_EFFECTS) {
7415
+ topLevelEffects.set(
7416
+ effect,
7417
+ this.createEffect(
7418
+ effect,
7419
+ () => binding?.context,
7420
+ effect,
7421
+ replay2
7422
+ )
7423
+ );
7424
+ }
7425
+ const replayTarget = replay2 ? { ...target } : target;
7426
+ if (replay2) {
7427
+ const controller = new AbortController();
7428
+ if (target.aborted === true) {
7429
+ controller.abort();
7430
+ }
7431
+ replayTarget.abortSignal = controller.signal;
7432
+ }
7433
+ return new Proxy(replayTarget, {
7434
+ get: (source, property) => {
7435
+ if (property === "db") {
7436
+ return dbProxy;
7437
+ }
7438
+ if (typeof property === "string") {
7439
+ const group = groupProxies.get(property);
7440
+ if (group) {
7441
+ return group;
7442
+ }
7443
+ const effect = topLevelEffects.get(property);
7444
+ if (effect) {
7445
+ return effect;
7446
+ }
7447
+ }
7448
+ if (property === "setPreventSleep" && replay2) {
7449
+ return (_preventSleep) => void 0;
7450
+ }
7451
+ if (replay2 && typeof property === "string" && TOP_LEVEL_UNAVAILABLE_CAPABILITIES.has(property)) {
7452
+ throw unavailableCapability(property);
7453
+ }
7454
+ const value = Reflect.get(source, property, source);
7455
+ return typeof value === "function" ? value.bind(source) : value;
7456
+ }
7457
+ });
7458
+ }
7459
+ createDbProxy(binding, replay2) {
7460
+ const proxy = this.createGroupProxy("db", binding, replay2);
7461
+ return new Proxy(proxy, {
7462
+ get: (source, property) => property === "transaction" ? this.createTransaction(binding, replay2) : Reflect.get(source, property, source)
7463
+ });
7464
+ }
7465
+ createGroupProxy(group, binding, replay2) {
7466
+ const targetProvider = () => {
7467
+ if (!binding) {
7468
+ return void 0;
7469
+ }
7470
+ const context = binding.context;
7471
+ const target = readProperty(context, group);
7472
+ return isRecord5(target) ? target : void 0;
7473
+ };
7474
+ const proxy = this.createMethodProxy(
7475
+ targetProvider,
7476
+ group,
7477
+ RIVET_GROUP_EFFECT_METHODS[group],
7478
+ replay2
7479
+ );
7480
+ if (group !== "queue") {
7481
+ return proxy;
7482
+ }
7483
+ return new Proxy(proxy, {
7484
+ get: (source, property) => property === "iter" ? (options) => this.createQueueIterator(source, options) : Reflect.get(source, property, source)
7485
+ });
7486
+ }
7487
+ createMethodProxy(targetProvider, prefix, methods, replay2) {
7488
+ const effects = /* @__PURE__ */ new Map();
7489
+ for (const method of methods) {
7490
+ const effect = `${prefix}.${method}`;
7491
+ effects.set(
7492
+ method,
7493
+ this.createEffect(effect, targetProvider, method, replay2)
7494
+ );
7495
+ }
7496
+ return new Proxy(
7497
+ {},
7498
+ {
7499
+ get: (_source, property) => {
7500
+ if (typeof property === "string") {
7501
+ const effect = effects.get(property);
7502
+ if (effect) {
7503
+ return effect;
7504
+ }
7505
+ if (replay2) {
7506
+ throw unavailableCapability(`${prefix}.${property}`);
7507
+ }
7508
+ }
7509
+ const target = targetProvider();
7510
+ if (!target) {
7511
+ return void 0;
7512
+ }
7513
+ const value = Reflect.get(target, property, target);
7514
+ return typeof value === "function" ? value.bind(target) : value;
7515
+ }
7516
+ }
7517
+ );
7518
+ }
7519
+ createEffect(effect, targetProvider, methodName, replay2) {
7520
+ const marked = this.markedEffects.has(effect);
7521
+ const invoke = (...args) => {
7522
+ assertReplayEffectAvailable(
7523
+ getReplayContext(),
7524
+ this.traceFunctionKey,
7525
+ effect,
7526
+ marked
7527
+ );
7528
+ const target = targetProvider();
7529
+ const method = target ? readProperty(target, methodName) : void 0;
7530
+ if (typeof method !== "function") {
7531
+ throw unavailableCapability(effect);
7532
+ }
7533
+ return method.apply(target, args);
7534
+ };
7535
+ const wrapped = SYNC_VOID_EFFECTS.has(effect) ? this.runtime.wrapEffect(
7536
+ effect,
7537
+ marked,
7538
+ invoke,
7539
+ replay2 ? () => void 0 : void 0
7540
+ ) : this.runtime.wrapEffect(effect, marked, async (...args) => {
7541
+ return await invoke(...args);
7542
+ });
7543
+ return (...args) => {
7544
+ if (replay2) {
7545
+ assertReplayEffectAvailable(
7546
+ replay2,
7547
+ this.traceFunctionKey,
7548
+ effect,
7549
+ marked
7550
+ );
7551
+ }
7552
+ const result = wrapped(...args);
7553
+ if (!QUEUE_MESSAGE_EFFECTS.has(effect) || !(result instanceof Promise)) {
7554
+ return result;
7555
+ }
7556
+ return result.then(
7557
+ (value) => this.decorateQueueMessages(value, effect, args, replay2)
7558
+ );
7559
+ };
7560
+ }
7561
+ createTransaction(binding, replay2) {
7562
+ return async (callback, options) => {
7563
+ if (typeof callback !== "function") {
7564
+ throw new BitfabError("Rivet db.transaction requires a callback");
7565
+ }
7566
+ if (replay2) {
7567
+ return await callback(
7568
+ this.createMethodProxy(
7569
+ () => void 0,
7570
+ "db.transaction",
7571
+ ["execute"],
7572
+ replay2
7573
+ )
7574
+ );
7575
+ }
7576
+ const context = binding?.context;
7577
+ const db = context ? readProperty(context, "db") : void 0;
7578
+ const transaction = isRecord5(db) ? readProperty(db, "transaction") : void 0;
7579
+ if (!isRecord5(db) || typeof transaction !== "function") {
7580
+ throw unavailableCapability("db.transaction");
7581
+ }
7582
+ return await transaction.call(
7583
+ db,
7584
+ async (transactionDb) => {
7585
+ if (!isRecord5(transactionDb)) {
7586
+ throw unavailableCapability("db.transaction.execute");
7587
+ }
7588
+ return await callback(
7589
+ this.createMethodProxy(
7590
+ () => transactionDb,
7591
+ "db.transaction",
7592
+ ["execute"],
7593
+ replay2
7594
+ )
7595
+ );
7596
+ },
7597
+ options
7598
+ );
7599
+ };
7600
+ }
7601
+ decorateQueueMessages(value, effect, args, replay2) {
7602
+ if (!this.queueCallIsCompletable(effect, args)) {
7603
+ return value;
7604
+ }
7605
+ if (Array.isArray(value)) {
7606
+ return value.map((message) => this.decorateQueueMessage(message, replay2));
7607
+ }
7608
+ return this.decorateQueueMessage(value, replay2);
7609
+ }
7610
+ decorateQueueMessage(value, replay2) {
7611
+ if (!isRecord5(value)) {
7612
+ return value;
7613
+ }
7614
+ const originalComplete = readProperty(value, "complete");
7615
+ const complete = this.createEffect(
7616
+ "queue.message.complete",
7617
+ () => typeof originalComplete === "function" ? { complete: originalComplete.bind(value) } : void 0,
7618
+ "complete",
7619
+ replay2
7620
+ );
7621
+ return { ...value, complete };
7622
+ }
7623
+ queueCallIsCompletable(effect, args) {
7624
+ const options = effect === "queue.waitForNames" ? args[1] : args[0];
7625
+ return isRecord5(options) && options.completable === true;
7626
+ }
7627
+ createQueueIterator(queue, options) {
7628
+ return {
7629
+ async *[Symbol.asyncIterator]() {
7630
+ for (; ; ) {
7631
+ const next = Reflect.get(queue, "next", queue);
7632
+ if (typeof next !== "function") {
7633
+ throw unavailableCapability("queue.next");
7634
+ }
7635
+ const message = await next.call(queue, options);
7636
+ if (message !== void 0 && message !== null) {
7637
+ yield message;
7638
+ }
7639
+ }
7640
+ }
7641
+ };
7642
+ }
7643
+ };
7644
+
6986
7645
  // src/seedContext.ts
6987
7646
  init_asyncStorage();
6988
7647
  var seedContextStorage = null;
@@ -7126,6 +7785,9 @@ var BitfabOpenAITracingProcessor = class {
7126
7785
  const activeContext = this.getActiveSpanContext?.();
7127
7786
  if (activeContext) {
7128
7787
  this.activeSpanMappings[trace.traceId] = activeContext;
7788
+ if (this.shouldRecord()) {
7789
+ mapOpenAiAgentsTrace(trace.traceId, activeContext.traceId);
7790
+ }
7129
7791
  }
7130
7792
  const canonicalTraceId = activeContext?.traceId ?? this.getCanonicalTraceId(trace.traceId);
7131
7793
  this.canonicalTraceIds[trace.traceId] = canonicalTraceId;
@@ -7163,6 +7825,7 @@ var BitfabOpenAITracingProcessor = class {
7163
7825
  }
7164
7826
  this.endedTraces.delete(traceId);
7165
7827
  delete this.activeSpanMappings[traceId];
7828
+ unmapOpenAiAgentsTrace(traceId);
7166
7829
  delete this.canonicalTraceIds[traceId];
7167
7830
  delete this.activeTraces[traceId];
7168
7831
  }
@@ -7187,6 +7850,9 @@ var BitfabOpenAITracingProcessor = class {
7187
7850
  async onSpanEnd(span) {
7188
7851
  const originalTraceId = span.traceId ?? "";
7189
7852
  const traceId = this.activeSpanMappings[originalTraceId]?.traceId ?? originalTraceId;
7853
+ if (span.spanId !== void 0) {
7854
+ endOpenAiAgentsSpan(originalTraceId, span.spanId);
7855
+ }
7190
7856
  try {
7191
7857
  this.sendSpan(span);
7192
7858
  } finally {
@@ -7207,6 +7873,9 @@ var BitfabOpenAITracingProcessor = class {
7207
7873
  * Called when the trace processor is shutting down.
7208
7874
  */
7209
7875
  async shutdown(timeout) {
7876
+ for (const traceId of Object.keys(this.activeSpanMappings)) {
7877
+ unmapOpenAiAgentsTrace(traceId);
7878
+ }
7210
7879
  this.activeTraces = {};
7211
7880
  this.activeSpanMappings = {};
7212
7881
  this.canonicalTraceIds = {};
@@ -8364,16 +9033,16 @@ var Bitfab = class {
8364
9033
  this.simulationPlan.send(payload, rootTraceFunctionKeyOf(payload), submit);
8365
9034
  }
8366
9035
  refreshAutoTraceCapturePolicy(traceFunctionKey) {
8367
- const state = this.autoTracePolicyRefreshes.get(traceFunctionKey) ?? new PolicyRefresh();
8368
- this.autoTracePolicyRefreshes.set(traceFunctionKey, state);
8369
- state.run(
9036
+ const state2 = this.autoTracePolicyRefreshes.get(traceFunctionKey) ?? new PolicyRefresh();
9037
+ this.autoTracePolicyRefreshes.set(traceFunctionKey, state2);
9038
+ state2.run(
8370
9039
  () => this.httpClient.getAutoTracePolicy(
8371
9040
  traceFunctionKey,
8372
9041
  AUTO_TRACE_PROTOCOL
8373
9042
  ),
8374
9043
  (policy) => {
8375
9044
  if (policy.protocol !== AUTO_TRACE_PROTOCOL) {
8376
- state.hold(AUTO_TRACE_POLICY_RETRY_MS);
9045
+ state2.hold(AUTO_TRACE_POLICY_RETRY_MS);
8377
9046
  return;
8378
9047
  }
8379
9048
  const functionIds = Array.isArray(policy.functionIds) ? policy.functionIds.filter(
@@ -8384,10 +9053,10 @@ var Bitfab = class {
8384
9053
  traceFunctionKey,
8385
9054
  policy.revision === null ? void 0 : functionIds
8386
9055
  );
8387
- state.hold(AUTO_TRACE_POLICY_REFRESH_MS);
9056
+ state2.hold(AUTO_TRACE_POLICY_REFRESH_MS);
8388
9057
  },
8389
9058
  () => {
8390
- state.hold(AUTO_TRACE_POLICY_RETRY_MS);
9059
+ state2.hold(AUTO_TRACE_POLICY_RETRY_MS);
8391
9060
  }
8392
9061
  );
8393
9062
  }
@@ -8692,6 +9361,47 @@ var Bitfab = class {
8692
9361
  options
8693
9362
  });
8694
9363
  }
9364
+ /**
9365
+ * Get the first-class Rivet actor-context integration for an existing trace
9366
+ * root. The integration binds context and records effect spans; it never
9367
+ * creates another root.
9368
+ *
9369
+ * @param traceFunctionKey - Key used by the enclosing `withTrace()` root
9370
+ * @param options - Explicit per-context-path replay mocking policy
9371
+ * @experimental This API may change before it is stable.
9372
+ */
9373
+ getRivetIntegration(traceFunctionKey, options) {
9374
+ return new BitfabRivetIntegration(
9375
+ traceFunctionKey,
9376
+ {
9377
+ wrapEffect: (effect, mockOnReplay, fn, replayOutput) => {
9378
+ const spanOptions = {
9379
+ name: effect,
9380
+ type: "function",
9381
+ captureWhen: "nested",
9382
+ mockOnReplay,
9383
+ surface: "inherit",
9384
+ instrumentation: "rivet",
9385
+ ...replayOutput !== void 0 && { replayOutput }
9386
+ };
9387
+ return this.withSpan(traceFunctionKey, spanOptions, fn);
9388
+ },
9389
+ recordRootFixture: (context, recordedRoots) => {
9390
+ const root = getSpanStack()[0];
9391
+ if (!root) {
9392
+ return;
9393
+ }
9394
+ const rootId = `${root.traceId}:${root.spanId}`;
9395
+ if (recordedRoots.has(rootId)) {
9396
+ return;
9397
+ }
9398
+ root.contexts.push(context);
9399
+ recordedRoots.add(rootId);
9400
+ }
9401
+ },
9402
+ options
9403
+ );
9404
+ }
8695
9405
  /**
8696
9406
  * Get a Claude Agent SDK handler for tracing.
8697
9407
  *
@@ -8957,7 +9667,11 @@ var Bitfab = class {
8957
9667
  const seedCtxForTraceId = parentContext ? null : getSeedContext();
8958
9668
  const traceId = parentContext?.traceId ?? replayCtxForTraceId?.traceId ?? seedCtxForTraceId?.traceId ?? randomUuid();
8959
9669
  const spanId = randomUuid();
8960
- const parentSpanId = parentContext?.spanId ?? null;
9670
+ const openAiAgentsParent = parentContext !== void 0 && options.instrumentation === "trace" ? openAiAgentsParentSpanId(
9671
+ parentContext.traceId,
9672
+ parentContext.openAiAgentsSpanIds
9673
+ ) : void 0;
9674
+ const parentSpanId = openAiAgentsParent ?? parentContext?.spanId ?? null;
8961
9675
  const isRootSpan = parentSpanId === null;
8962
9676
  if (options.enclosingTrace !== void 0) {
8963
9677
  options.enclosingTrace.link.traceId = traceId;
@@ -8971,11 +9685,13 @@ var Bitfab = class {
8971
9685
  parentContext?.surface,
8972
9686
  traceFunctionKey
8973
9687
  );
9688
+ const openAiAgentsSpanIds = openAiAgentsSpanChain();
8974
9689
  const newContext = {
8975
9690
  traceId,
8976
9691
  spanId,
8977
9692
  contexts: [],
8978
- ...surface !== void 0 && { surface }
9693
+ ...surface !== void 0 && { surface },
9694
+ ...openAiAgentsSpanIds.length > 0 && { openAiAgentsSpanIds }
8979
9695
  };
8980
9696
  newStack = [...currentStack, newContext];
8981
9697
  const inputs = args;
@@ -9190,6 +9906,7 @@ var Bitfab = class {
9190
9906
  }
9191
9907
  return output;
9192
9908
  };
9909
+ const resolveBaseOutput = () => options.replayOutput !== void 0 ? options.replayOutput() : resolveRecordedOutput();
9193
9910
  const shouldMockWithBaseStrategy = replayCtxForMock.mockStrategy === "all" || replayCtxForMock.mockStrategy === "marked" && options.mockOnReplay === true;
9194
9911
  if (replayCtxForMock.mockOverrides?.length) {
9195
9912
  const nodeMeta = {
@@ -9246,7 +9963,7 @@ var Bitfab = class {
9246
9963
  }
9247
9964
  if (shouldMockWithBaseStrategy) {
9248
9965
  const output = await resolveMockOrAbort(
9249
- () => resolveRecordedOutput()
9966
+ () => resolveBaseOutput()
9250
9967
  );
9251
9968
  void sendSpan({
9252
9969
  result: output,
@@ -9269,7 +9986,7 @@ var Bitfab = class {
9269
9986
  );
9270
9987
  }
9271
9988
  if (shouldMockWithBaseStrategy) {
9272
- const recorded = resolveRecordedOutput();
9989
+ const recorded = resolveBaseOutput();
9273
9990
  if (recorded instanceof Promise) {
9274
9991
  return emitMockAsync(recorded, "recorded");
9275
9992
  }
@@ -9871,6 +10588,28 @@ var BitfabFunction = class {
9871
10588
  span(options = {}) {
9872
10589
  return this.client.span(this.traceFunctionKey, options);
9873
10590
  }
10591
+ withTrace(optionsOrFn, maybeFn) {
10592
+ if (typeof optionsOrFn === "function") {
10593
+ return this.client.withTrace(this.traceFunctionKey, optionsOrFn);
10594
+ }
10595
+ if (!maybeFn) {
10596
+ throw new BitfabError("BitfabFunction.withTrace requires a function");
10597
+ }
10598
+ return this.client.withTrace(this.traceFunctionKey, optionsOrFn, maybeFn);
10599
+ }
10600
+ /**
10601
+ * Create a trace method decorator bound to this function's key.
10602
+ *
10603
+ * Equivalent to `client.trace(key, options)` but reuses the key bound on
10604
+ * this handle.
10605
+ *
10606
+ * @param options - Trace configuration applied to the decorated method
10607
+ * @returns A method decorator configured for this key
10608
+ * @experimental Automatic child-call instrumentation is experimental.
10609
+ */
10610
+ trace(options = {}) {
10611
+ return this.client.trace(this.traceFunctionKey, options);
10612
+ }
9874
10613
  /**
9875
10614
  * Get a Vercel AI SDK language-model middleware bound to this function's key.
9876
10615
  *
@@ -9968,6 +10707,20 @@ var BitfabFunction = class {
9968
10707
  getLangGraphIntegration(options) {
9969
10708
  return this.client.getLangGraphIntegration(this.traceFunctionKey, options);
9970
10709
  }
10710
+ /**
10711
+ * Get the first-class Rivet actor-context integration bound to this key.
10712
+ * Use its `bind()` or `withContext()` outside this handle's `withTrace()`
10713
+ * root, then call `getContext()` inside the root.
10714
+ *
10715
+ * @param options - Explicit per-context-path replay mocking policy
10716
+ * @experimental This API may change before it is stable.
10717
+ */
10718
+ getRivetIntegration(options) {
10719
+ return this.client.getRivetIntegration(
10720
+ this.traceFunctionKey,
10721
+ options
10722
+ );
10723
+ }
9971
10724
  /**
9972
10725
  * Wrap a BAML client method to automatically capture prompt and LLM metadata.
9973
10726
  * Delegates to the parent client's wrapBAML method.
@@ -10133,6 +10886,7 @@ assertAsyncStorageRegistered();
10133
10886
  BitfabLangGraphIntegration,
10134
10887
  BitfabOpenAIAgentHandler,
10135
10888
  BitfabOpenAITracingProcessor,
10889
+ BitfabRivetIntegration,
10136
10890
  BitfabVercelAiHandler,
10137
10891
  DEFAULT_SERVICE_URL,
10138
10892
  DatasetsClient,