bitfab 0.54.10 → 0.54.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -2214,18 +2214,18 @@ declare const RIVET_GROUP_EFFECT_METHODS: {
2214
2214
  readonly queue: readonly ["send", "next", "nextBatch", "waitForNames", "waitForAvailable", "complete", "enqueueAndWait", "tryNext", "tryNextBatch"];
2215
2215
  readonly run: readonly ["setWakeAt"];
2216
2216
  };
2217
- declare const RIVET_TOP_LEVEL_EFFECTS: readonly ["broadcast", "saveState", "sleep", "destroy"];
2217
+ declare const RIVET_TOP_LEVEL_EFFECTS: readonly ["broadcast", "saveState", "sleep", "destroy", "step", "tryStep", "try", "loop", "sleepUntil", "rollbackCheckpoint", "join", "race", "removed", "getVersion"];
2218
2218
  type RivetGroup = keyof typeof RIVET_GROUP_EFFECT_METHODS;
2219
2219
  type RivetGroupEffectType = {
2220
2220
  [TGroup in RivetGroup]: `${TGroup}.${(typeof RIVET_GROUP_EFFECT_METHODS)[TGroup][number]}`;
2221
2221
  }[RivetGroup];
2222
- /** Finite Rivet context operations supported as replay effects. */
2222
+ /** Rivet context operations supported as replay effects. */
2223
2223
  type RivetEffectType = RivetGroupEffectType | (typeof RIVET_TOP_LEVEL_EFFECTS)[number] | "db.transaction.execute" | "queue.message.complete";
2224
2224
  /** Configuration for {@link BitfabRivetIntegration}. */
2225
2225
  interface RivetIntegrationOptions {
2226
2226
  /**
2227
2227
  * Context operations whose recorded outputs replay should serve instead of
2228
- * executing against a live actor. Nothing is marked by default.
2228
+ * executing against a live actor or workflow. Nothing is marked by default.
2229
2229
  */
2230
2230
  mockOnReplay?: readonly RivetEffectType[];
2231
2231
  }
@@ -2246,8 +2246,8 @@ interface RivetIntegrationRuntime {
2246
2246
  recordRootFixture(context: Record<string, unknown>, recordedRoots: Set<string>): void;
2247
2247
  }
2248
2248
  /**
2249
- * Binds a live Rivet actor context to an existing traced function and exposes
2250
- * replay-aware proxies for supported context operations.
2249
+ * Binds a live Rivet actor or workflow context to an existing traced function
2250
+ * and exposes replay-aware proxies for supported context operations.
2251
2251
  *
2252
2252
  * The integration never creates a trace root. Use it with the same
2253
2253
  * `BitfabFunction` handle whose `withTrace()` wrapper is the production and
@@ -2267,13 +2267,15 @@ declare class BitfabRivetIntegration<TContext extends object = RivetContextLike>
2267
2267
  withContext<TReturn>(context: TContext, fn: () => TReturn): TReturn;
2268
2268
  /**
2269
2269
  * Adapt a traced function into a Rivet handler whose first argument is the
2270
- * live actor context. The context is not added to the traced root's inputs.
2270
+ * live actor or workflow context. The context is not added to the traced
2271
+ * root's inputs.
2271
2272
  */
2272
2273
  bind<This, TArgs extends unknown[], TReturn>(fn: (this: This, ...args: TArgs) => TReturn): (this: This, context: TContext, ...args: TArgs) => TReturn;
2273
2274
  /**
2274
2275
  * Return the current Rivet context proxy. In production it delegates to the
2275
2276
  * bound live context. During replay it hydrates recorded actor state and
2276
- * intercepts supported effects without requiring a live Rivet actor.
2277
+ * intercepts supported effects without requiring a live Rivet actor or
2278
+ * workflow.
2277
2279
  */
2278
2280
  getContext(): TContext;
2279
2281
  private createContextProxy;
@@ -3123,9 +3125,9 @@ declare class Bitfab {
3123
3125
  */
3124
3126
  getLangGraphIntegration(traceFunctionKey: string, options?: LangGraphIntegrationOptions): BitfabLangGraphIntegration;
3125
3127
  /**
3126
- * Get the first-class Rivet actor-context integration for an existing trace
3127
- * root. The integration binds context and records effect spans; it never
3128
- * creates another root.
3128
+ * Get the first-class Rivet actor/workflow-context integration for an
3129
+ * existing trace root. The integration binds context and records effect
3130
+ * spans; it never creates another root.
3129
3131
  *
3130
3132
  * @param traceFunctionKey - Key used by the enclosing `withTrace()` root
3131
3133
  * @param options - Explicit per-context-path replay mocking policy
@@ -3602,7 +3604,7 @@ interface CommitRef {
3602
3604
  /**
3603
3605
  * SDK version from package.json (injected at build time)
3604
3606
  */
3605
- declare const __version__ = "0.54.10";
3607
+ declare const __version__ = "0.54.12";
3606
3608
 
3607
3609
  /**
3608
3610
  * Constants for the Bitfab SDK.
package/dist/index.d.ts CHANGED
@@ -2214,18 +2214,18 @@ declare const RIVET_GROUP_EFFECT_METHODS: {
2214
2214
  readonly queue: readonly ["send", "next", "nextBatch", "waitForNames", "waitForAvailable", "complete", "enqueueAndWait", "tryNext", "tryNextBatch"];
2215
2215
  readonly run: readonly ["setWakeAt"];
2216
2216
  };
2217
- declare const RIVET_TOP_LEVEL_EFFECTS: readonly ["broadcast", "saveState", "sleep", "destroy"];
2217
+ declare const RIVET_TOP_LEVEL_EFFECTS: readonly ["broadcast", "saveState", "sleep", "destroy", "step", "tryStep", "try", "loop", "sleepUntil", "rollbackCheckpoint", "join", "race", "removed", "getVersion"];
2218
2218
  type RivetGroup = keyof typeof RIVET_GROUP_EFFECT_METHODS;
2219
2219
  type RivetGroupEffectType = {
2220
2220
  [TGroup in RivetGroup]: `${TGroup}.${(typeof RIVET_GROUP_EFFECT_METHODS)[TGroup][number]}`;
2221
2221
  }[RivetGroup];
2222
- /** Finite Rivet context operations supported as replay effects. */
2222
+ /** Rivet context operations supported as replay effects. */
2223
2223
  type RivetEffectType = RivetGroupEffectType | (typeof RIVET_TOP_LEVEL_EFFECTS)[number] | "db.transaction.execute" | "queue.message.complete";
2224
2224
  /** Configuration for {@link BitfabRivetIntegration}. */
2225
2225
  interface RivetIntegrationOptions {
2226
2226
  /**
2227
2227
  * Context operations whose recorded outputs replay should serve instead of
2228
- * executing against a live actor. Nothing is marked by default.
2228
+ * executing against a live actor or workflow. Nothing is marked by default.
2229
2229
  */
2230
2230
  mockOnReplay?: readonly RivetEffectType[];
2231
2231
  }
@@ -2246,8 +2246,8 @@ interface RivetIntegrationRuntime {
2246
2246
  recordRootFixture(context: Record<string, unknown>, recordedRoots: Set<string>): void;
2247
2247
  }
2248
2248
  /**
2249
- * Binds a live Rivet actor context to an existing traced function and exposes
2250
- * replay-aware proxies for supported context operations.
2249
+ * Binds a live Rivet actor or workflow context to an existing traced function
2250
+ * and exposes replay-aware proxies for supported context operations.
2251
2251
  *
2252
2252
  * The integration never creates a trace root. Use it with the same
2253
2253
  * `BitfabFunction` handle whose `withTrace()` wrapper is the production and
@@ -2267,13 +2267,15 @@ declare class BitfabRivetIntegration<TContext extends object = RivetContextLike>
2267
2267
  withContext<TReturn>(context: TContext, fn: () => TReturn): TReturn;
2268
2268
  /**
2269
2269
  * Adapt a traced function into a Rivet handler whose first argument is the
2270
- * live actor context. The context is not added to the traced root's inputs.
2270
+ * live actor or workflow context. The context is not added to the traced
2271
+ * root's inputs.
2271
2272
  */
2272
2273
  bind<This, TArgs extends unknown[], TReturn>(fn: (this: This, ...args: TArgs) => TReturn): (this: This, context: TContext, ...args: TArgs) => TReturn;
2273
2274
  /**
2274
2275
  * Return the current Rivet context proxy. In production it delegates to the
2275
2276
  * bound live context. During replay it hydrates recorded actor state and
2276
- * intercepts supported effects without requiring a live Rivet actor.
2277
+ * intercepts supported effects without requiring a live Rivet actor or
2278
+ * workflow.
2277
2279
  */
2278
2280
  getContext(): TContext;
2279
2281
  private createContextProxy;
@@ -3123,9 +3125,9 @@ declare class Bitfab {
3123
3125
  */
3124
3126
  getLangGraphIntegration(traceFunctionKey: string, options?: LangGraphIntegrationOptions): BitfabLangGraphIntegration;
3125
3127
  /**
3126
- * Get the first-class Rivet actor-context integration for an existing trace
3127
- * root. The integration binds context and records effect spans; it never
3128
- * creates another root.
3128
+ * Get the first-class Rivet actor/workflow-context integration for an
3129
+ * existing trace root. The integration binds context and records effect
3130
+ * spans; it never creates another root.
3129
3131
  *
3130
3132
  * @param traceFunctionKey - Key used by the enclosing `withTrace()` root
3131
3133
  * @param options - Explicit per-context-path replay mocking policy
@@ -3602,7 +3604,7 @@ interface CommitRef {
3602
3604
  /**
3603
3605
  * SDK version from package.json (injected at build time)
3604
3606
  */
3605
- declare const __version__ = "0.54.10";
3607
+ declare const __version__ = "0.54.12";
3606
3608
 
3607
3609
  /**
3608
3610
  * Constants for the Bitfab SDK.
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ import {
30
30
  getCurrentTrace,
31
31
  reseedFromRegistry,
32
32
  seedFromRegistry
33
- } from "./chunk-A3OBQOLV.js";
33
+ } from "./chunk-YY5BB2YS.js";
34
34
  import "./chunk-EGWJYCNT.js";
35
35
  import {
36
36
  BITFAB_PROGRESS_PREFIX,
@@ -39,7 +39,7 @@ import {
39
39
  ReplayError,
40
40
  reportReplayProgress,
41
41
  serializeReplayResult
42
- } from "./chunk-PRXW4B5X.js";
42
+ } from "./chunk-ZR4HGK6G.js";
43
43
  import {
44
44
  BitfabError,
45
45
  DEFAULT_SERVICE_URL,
@@ -47,7 +47,7 @@ import {
47
47
  MixedTracingError,
48
48
  __version__,
49
49
  flushTraces
50
- } from "./chunk-B2O33DBH.js";
50
+ } from "./chunk-WKXLCFLT.js";
51
51
  import "./chunk-VCRFFCLY.js";
52
52
  export {
53
53
  AssertionCategoriesClient,
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.10";
100
+ __version__ = "0.54.12";
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;
@@ -6994,6 +6994,83 @@ var BitfabOpenAIAgentHandler = class {
6994
6994
  }
6995
6995
  };
6996
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
+
6997
7074
  // src/client.ts
6998
7075
  init_policyRefresh();
6999
7076
  init_randomUuid();
@@ -7143,18 +7220,42 @@ var RIVET_TOP_LEVEL_EFFECTS = [
7143
7220
  "broadcast",
7144
7221
  "saveState",
7145
7222
  "sleep",
7146
- "destroy"
7223
+ "destroy",
7224
+ "step",
7225
+ "tryStep",
7226
+ "try",
7227
+ "loop",
7228
+ "sleepUntil",
7229
+ "rollbackCheckpoint",
7230
+ "join",
7231
+ "race",
7232
+ "removed",
7233
+ "getVersion"
7147
7234
  ];
7148
7235
  var TOP_LEVEL_UNAVAILABLE_CAPABILITIES = /* @__PURE__ */ new Set([
7149
7236
  "conn",
7150
7237
  "conns",
7151
- "log",
7152
7238
  "request",
7153
7239
  "actorRuntimeSocket",
7154
7240
  "keepAwake",
7155
7241
  "waitUntil",
7156
7242
  "client"
7157
7243
  ]);
7244
+ var replayLog = () => void 0;
7245
+ var replayLogger = {
7246
+ level: "silent",
7247
+ msgPrefix: void 0,
7248
+ fatal: replayLog,
7249
+ trace: replayLog,
7250
+ silent: replayLog,
7251
+ debug: replayLog,
7252
+ info: replayLog,
7253
+ warn: replayLog,
7254
+ error: replayLog,
7255
+ child: () => replayLogger,
7256
+ bindings: () => ({}),
7257
+ isLevelEnabled: () => false
7258
+ };
7158
7259
  var SYNC_VOID_EFFECTS = /* @__PURE__ */ new Set([
7159
7260
  "broadcast",
7160
7261
  "sleep",
@@ -7184,16 +7285,28 @@ function snapshotContext(context) {
7184
7285
  "state",
7185
7286
  "vars",
7186
7287
  "actorId",
7288
+ "workflowId",
7187
7289
  "name",
7188
7290
  "key",
7189
- "region",
7190
- "aborted"
7291
+ "region"
7191
7292
  ]) {
7192
7293
  const value = readProperty(source, property);
7193
7294
  if (value !== void 0) {
7194
7295
  snapshot[property] = value;
7195
7296
  }
7196
7297
  }
7298
+ const aborted = readProperty(source, "aborted");
7299
+ if (typeof aborted === "boolean") {
7300
+ snapshot.aborted = aborted;
7301
+ } else {
7302
+ const abortSignal = readProperty(source, "abortSignal");
7303
+ if (isRecord5(abortSignal)) {
7304
+ const signalAborted = readProperty(abortSignal, "aborted");
7305
+ if (typeof signalAborted === "boolean") {
7306
+ snapshot.aborted = signalAborted;
7307
+ }
7308
+ }
7309
+ }
7197
7310
  return snapshot;
7198
7311
  }
7199
7312
  function unavailableCapability(path) {
@@ -7285,7 +7398,8 @@ var BitfabRivetIntegration = class {
7285
7398
  }
7286
7399
  /**
7287
7400
  * Adapt a traced function into a Rivet handler whose first argument is the
7288
- * live actor context. The context is not added to the traced root's inputs.
7401
+ * live actor or workflow context. The context is not added to the traced
7402
+ * root's inputs.
7289
7403
  */
7290
7404
  bind(fn) {
7291
7405
  const integration = this;
@@ -7296,7 +7410,8 @@ var BitfabRivetIntegration = class {
7296
7410
  /**
7297
7411
  * Return the current Rivet context proxy. In production it delegates to the
7298
7412
  * bound live context. During replay it hydrates recorded actor state and
7299
- * intercepts supported effects without requiring a live Rivet actor.
7413
+ * intercepts supported effects without requiring a live Rivet actor or
7414
+ * workflow.
7300
7415
  */
7301
7416
  getContext() {
7302
7417
  const replay2 = getReplayContext();
@@ -7380,6 +7495,12 @@ var BitfabRivetIntegration = class {
7380
7495
  if (property === "setPreventSleep" && replay2) {
7381
7496
  return (_preventSleep) => void 0;
7382
7497
  }
7498
+ if (property === "isEvicted" && replay2) {
7499
+ return () => replayTarget.abortSignal?.aborted === true;
7500
+ }
7501
+ if (property === "log" && replay2) {
7502
+ return replayLogger;
7503
+ }
7383
7504
  if (replay2 && typeof property === "string" && TOP_LEVEL_UNAVAILABLE_CAPABILITIES.has(property)) {
7384
7505
  throw unavailableCapability(property);
7385
7506
  }
@@ -7553,7 +7674,7 @@ var BitfabRivetIntegration = class {
7553
7674
  return { ...value, complete };
7554
7675
  }
7555
7676
  queueCallIsCompletable(effect, args) {
7556
- const options = effect === "queue.waitForNames" ? args[1] : args[0];
7677
+ const options = effect === "queue.waitForNames" || (effect === "queue.next" || effect === "queue.nextBatch") && typeof args[0] === "string" ? args[1] : args[0];
7557
7678
  return isRecord5(options) && options.completable === true;
7558
7679
  }
7559
7680
  createQueueIterator(queue, options) {
@@ -7717,6 +7838,9 @@ var BitfabOpenAITracingProcessor = class {
7717
7838
  const activeContext = this.getActiveSpanContext?.();
7718
7839
  if (activeContext) {
7719
7840
  this.activeSpanMappings[trace.traceId] = activeContext;
7841
+ if (this.shouldRecord()) {
7842
+ mapOpenAiAgentsTrace(trace.traceId, activeContext.traceId);
7843
+ }
7720
7844
  }
7721
7845
  const canonicalTraceId = activeContext?.traceId ?? this.getCanonicalTraceId(trace.traceId);
7722
7846
  this.canonicalTraceIds[trace.traceId] = canonicalTraceId;
@@ -7754,6 +7878,7 @@ var BitfabOpenAITracingProcessor = class {
7754
7878
  }
7755
7879
  this.endedTraces.delete(traceId);
7756
7880
  delete this.activeSpanMappings[traceId];
7881
+ unmapOpenAiAgentsTrace(traceId);
7757
7882
  delete this.canonicalTraceIds[traceId];
7758
7883
  delete this.activeTraces[traceId];
7759
7884
  }
@@ -7778,6 +7903,9 @@ var BitfabOpenAITracingProcessor = class {
7778
7903
  async onSpanEnd(span) {
7779
7904
  const originalTraceId = span.traceId ?? "";
7780
7905
  const traceId = this.activeSpanMappings[originalTraceId]?.traceId ?? originalTraceId;
7906
+ if (span.spanId !== void 0) {
7907
+ endOpenAiAgentsSpan(originalTraceId, span.spanId);
7908
+ }
7781
7909
  try {
7782
7910
  this.sendSpan(span);
7783
7911
  } finally {
@@ -7798,6 +7926,9 @@ var BitfabOpenAITracingProcessor = class {
7798
7926
  * Called when the trace processor is shutting down.
7799
7927
  */
7800
7928
  async shutdown(timeout) {
7929
+ for (const traceId of Object.keys(this.activeSpanMappings)) {
7930
+ unmapOpenAiAgentsTrace(traceId);
7931
+ }
7801
7932
  this.activeTraces = {};
7802
7933
  this.activeSpanMappings = {};
7803
7934
  this.canonicalTraceIds = {};
@@ -8955,16 +9086,16 @@ var Bitfab = class {
8955
9086
  this.simulationPlan.send(payload, rootTraceFunctionKeyOf(payload), submit);
8956
9087
  }
8957
9088
  refreshAutoTraceCapturePolicy(traceFunctionKey) {
8958
- const state = this.autoTracePolicyRefreshes.get(traceFunctionKey) ?? new PolicyRefresh();
8959
- this.autoTracePolicyRefreshes.set(traceFunctionKey, state);
8960
- state.run(
9089
+ const state2 = this.autoTracePolicyRefreshes.get(traceFunctionKey) ?? new PolicyRefresh();
9090
+ this.autoTracePolicyRefreshes.set(traceFunctionKey, state2);
9091
+ state2.run(
8961
9092
  () => this.httpClient.getAutoTracePolicy(
8962
9093
  traceFunctionKey,
8963
9094
  AUTO_TRACE_PROTOCOL
8964
9095
  ),
8965
9096
  (policy) => {
8966
9097
  if (policy.protocol !== AUTO_TRACE_PROTOCOL) {
8967
- state.hold(AUTO_TRACE_POLICY_RETRY_MS);
9098
+ state2.hold(AUTO_TRACE_POLICY_RETRY_MS);
8968
9099
  return;
8969
9100
  }
8970
9101
  const functionIds = Array.isArray(policy.functionIds) ? policy.functionIds.filter(
@@ -8975,10 +9106,10 @@ var Bitfab = class {
8975
9106
  traceFunctionKey,
8976
9107
  policy.revision === null ? void 0 : functionIds
8977
9108
  );
8978
- state.hold(AUTO_TRACE_POLICY_REFRESH_MS);
9109
+ state2.hold(AUTO_TRACE_POLICY_REFRESH_MS);
8979
9110
  },
8980
9111
  () => {
8981
- state.hold(AUTO_TRACE_POLICY_RETRY_MS);
9112
+ state2.hold(AUTO_TRACE_POLICY_RETRY_MS);
8982
9113
  }
8983
9114
  );
8984
9115
  }
@@ -9284,9 +9415,9 @@ var Bitfab = class {
9284
9415
  });
9285
9416
  }
9286
9417
  /**
9287
- * Get the first-class Rivet actor-context integration for an existing trace
9288
- * root. The integration binds context and records effect spans; it never
9289
- * creates another root.
9418
+ * Get the first-class Rivet actor/workflow-context integration for an
9419
+ * existing trace root. The integration binds context and records effect
9420
+ * spans; it never creates another root.
9290
9421
  *
9291
9422
  * @param traceFunctionKey - Key used by the enclosing `withTrace()` root
9292
9423
  * @param options - Explicit per-context-path replay mocking policy
@@ -9589,7 +9720,11 @@ var Bitfab = class {
9589
9720
  const seedCtxForTraceId = parentContext ? null : getSeedContext();
9590
9721
  const traceId = parentContext?.traceId ?? replayCtxForTraceId?.traceId ?? seedCtxForTraceId?.traceId ?? randomUuid();
9591
9722
  const spanId = randomUuid();
9592
- const parentSpanId = parentContext?.spanId ?? null;
9723
+ const openAiAgentsParent = parentContext !== void 0 && options.instrumentation === "trace" ? openAiAgentsParentSpanId(
9724
+ parentContext.traceId,
9725
+ parentContext.openAiAgentsSpanIds
9726
+ ) : void 0;
9727
+ const parentSpanId = openAiAgentsParent ?? parentContext?.spanId ?? null;
9593
9728
  const isRootSpan = parentSpanId === null;
9594
9729
  if (options.enclosingTrace !== void 0) {
9595
9730
  options.enclosingTrace.link.traceId = traceId;
@@ -9603,11 +9738,13 @@ var Bitfab = class {
9603
9738
  parentContext?.surface,
9604
9739
  traceFunctionKey
9605
9740
  );
9741
+ const openAiAgentsSpanIds = openAiAgentsSpanChain();
9606
9742
  const newContext = {
9607
9743
  traceId,
9608
9744
  spanId,
9609
9745
  contexts: [],
9610
- ...surface !== void 0 && { surface }
9746
+ ...surface !== void 0 && { surface },
9747
+ ...openAiAgentsSpanIds.length > 0 && { openAiAgentsSpanIds }
9611
9748
  };
9612
9749
  newStack = [...currentStack, newContext];
9613
9750
  const inputs = args;