@bitfab/sdk 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
@@ -21,7 +21,7 @@ import {
21
21
  getCurrentTrace,
22
22
  reseedFromRegistry,
23
23
  seedFromRegistry
24
- } from "./chunk-3F7SICKD.js";
24
+ } from "./chunk-JEFU6FTD.js";
25
25
  import "./chunk-EGWJYCNT.js";
26
26
  import {
27
27
  BITFAB_PROGRESS_PREFIX,
@@ -30,7 +30,7 @@ import {
30
30
  ReplayError,
31
31
  reportReplayProgress,
32
32
  serializeReplayResult
33
- } from "./chunk-VJOLQ7UY.js";
33
+ } from "./chunk-XTUINMAL.js";
34
34
  import {
35
35
  BitfabError,
36
36
  DEFAULT_SERVICE_URL,
@@ -38,7 +38,7 @@ import {
38
38
  MixedTracingError,
39
39
  __version__,
40
40
  flushTraces
41
- } from "./chunk-XREH4NJT.js";
41
+ } from "./chunk-I5NJU64I.js";
42
42
  import "./chunk-VCRFFCLY.js";
43
43
  export {
44
44
  AssertionCategoriesClient,
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.10";
91
+ __version__ = "0.54.12";
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;
@@ -6985,6 +6985,83 @@ var BitfabOpenAIAgentHandler = class {
6985
6985
  }
6986
6986
  };
6987
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
+
6988
7065
  // src/client.ts
6989
7066
  init_policyRefresh();
6990
7067
  init_randomUuid();
@@ -7134,18 +7211,42 @@ var RIVET_TOP_LEVEL_EFFECTS = [
7134
7211
  "broadcast",
7135
7212
  "saveState",
7136
7213
  "sleep",
7137
- "destroy"
7214
+ "destroy",
7215
+ "step",
7216
+ "tryStep",
7217
+ "try",
7218
+ "loop",
7219
+ "sleepUntil",
7220
+ "rollbackCheckpoint",
7221
+ "join",
7222
+ "race",
7223
+ "removed",
7224
+ "getVersion"
7138
7225
  ];
7139
7226
  var TOP_LEVEL_UNAVAILABLE_CAPABILITIES = /* @__PURE__ */ new Set([
7140
7227
  "conn",
7141
7228
  "conns",
7142
- "log",
7143
7229
  "request",
7144
7230
  "actorRuntimeSocket",
7145
7231
  "keepAwake",
7146
7232
  "waitUntil",
7147
7233
  "client"
7148
7234
  ]);
7235
+ var replayLog = () => void 0;
7236
+ var replayLogger = {
7237
+ level: "silent",
7238
+ msgPrefix: void 0,
7239
+ fatal: replayLog,
7240
+ trace: replayLog,
7241
+ silent: replayLog,
7242
+ debug: replayLog,
7243
+ info: replayLog,
7244
+ warn: replayLog,
7245
+ error: replayLog,
7246
+ child: () => replayLogger,
7247
+ bindings: () => ({}),
7248
+ isLevelEnabled: () => false
7249
+ };
7149
7250
  var SYNC_VOID_EFFECTS = /* @__PURE__ */ new Set([
7150
7251
  "broadcast",
7151
7252
  "sleep",
@@ -7175,16 +7276,28 @@ function snapshotContext(context) {
7175
7276
  "state",
7176
7277
  "vars",
7177
7278
  "actorId",
7279
+ "workflowId",
7178
7280
  "name",
7179
7281
  "key",
7180
- "region",
7181
- "aborted"
7282
+ "region"
7182
7283
  ]) {
7183
7284
  const value = readProperty(source, property);
7184
7285
  if (value !== void 0) {
7185
7286
  snapshot[property] = value;
7186
7287
  }
7187
7288
  }
7289
+ const aborted = readProperty(source, "aborted");
7290
+ if (typeof aborted === "boolean") {
7291
+ snapshot.aborted = aborted;
7292
+ } else {
7293
+ const abortSignal = readProperty(source, "abortSignal");
7294
+ if (isRecord5(abortSignal)) {
7295
+ const signalAborted = readProperty(abortSignal, "aborted");
7296
+ if (typeof signalAborted === "boolean") {
7297
+ snapshot.aborted = signalAborted;
7298
+ }
7299
+ }
7300
+ }
7188
7301
  return snapshot;
7189
7302
  }
7190
7303
  function unavailableCapability(path) {
@@ -7276,7 +7389,8 @@ var BitfabRivetIntegration = class {
7276
7389
  }
7277
7390
  /**
7278
7391
  * Adapt a traced function into a Rivet handler whose first argument is the
7279
- * live actor context. The context is not added to the traced root's inputs.
7392
+ * live actor or workflow context. The context is not added to the traced
7393
+ * root's inputs.
7280
7394
  */
7281
7395
  bind(fn) {
7282
7396
  const integration = this;
@@ -7287,7 +7401,8 @@ var BitfabRivetIntegration = class {
7287
7401
  /**
7288
7402
  * Return the current Rivet context proxy. In production it delegates to the
7289
7403
  * bound live context. During replay it hydrates recorded actor state and
7290
- * intercepts supported effects without requiring a live Rivet actor.
7404
+ * intercepts supported effects without requiring a live Rivet actor or
7405
+ * workflow.
7291
7406
  */
7292
7407
  getContext() {
7293
7408
  const replay2 = getReplayContext();
@@ -7371,6 +7486,12 @@ var BitfabRivetIntegration = class {
7371
7486
  if (property === "setPreventSleep" && replay2) {
7372
7487
  return (_preventSleep) => void 0;
7373
7488
  }
7489
+ if (property === "isEvicted" && replay2) {
7490
+ return () => replayTarget.abortSignal?.aborted === true;
7491
+ }
7492
+ if (property === "log" && replay2) {
7493
+ return replayLogger;
7494
+ }
7374
7495
  if (replay2 && typeof property === "string" && TOP_LEVEL_UNAVAILABLE_CAPABILITIES.has(property)) {
7375
7496
  throw unavailableCapability(property);
7376
7497
  }
@@ -7544,7 +7665,7 @@ var BitfabRivetIntegration = class {
7544
7665
  return { ...value, complete };
7545
7666
  }
7546
7667
  queueCallIsCompletable(effect, args) {
7547
- const options = effect === "queue.waitForNames" ? args[1] : args[0];
7668
+ const options = effect === "queue.waitForNames" || (effect === "queue.next" || effect === "queue.nextBatch") && typeof args[0] === "string" ? args[1] : args[0];
7548
7669
  return isRecord5(options) && options.completable === true;
7549
7670
  }
7550
7671
  createQueueIterator(queue, options) {
@@ -7708,6 +7829,9 @@ var BitfabOpenAITracingProcessor = class {
7708
7829
  const activeContext = this.getActiveSpanContext?.();
7709
7830
  if (activeContext) {
7710
7831
  this.activeSpanMappings[trace.traceId] = activeContext;
7832
+ if (this.shouldRecord()) {
7833
+ mapOpenAiAgentsTrace(trace.traceId, activeContext.traceId);
7834
+ }
7711
7835
  }
7712
7836
  const canonicalTraceId = activeContext?.traceId ?? this.getCanonicalTraceId(trace.traceId);
7713
7837
  this.canonicalTraceIds[trace.traceId] = canonicalTraceId;
@@ -7745,6 +7869,7 @@ var BitfabOpenAITracingProcessor = class {
7745
7869
  }
7746
7870
  this.endedTraces.delete(traceId);
7747
7871
  delete this.activeSpanMappings[traceId];
7872
+ unmapOpenAiAgentsTrace(traceId);
7748
7873
  delete this.canonicalTraceIds[traceId];
7749
7874
  delete this.activeTraces[traceId];
7750
7875
  }
@@ -7769,6 +7894,9 @@ var BitfabOpenAITracingProcessor = class {
7769
7894
  async onSpanEnd(span) {
7770
7895
  const originalTraceId = span.traceId ?? "";
7771
7896
  const traceId = this.activeSpanMappings[originalTraceId]?.traceId ?? originalTraceId;
7897
+ if (span.spanId !== void 0) {
7898
+ endOpenAiAgentsSpan(originalTraceId, span.spanId);
7899
+ }
7772
7900
  try {
7773
7901
  this.sendSpan(span);
7774
7902
  } finally {
@@ -7789,6 +7917,9 @@ var BitfabOpenAITracingProcessor = class {
7789
7917
  * Called when the trace processor is shutting down.
7790
7918
  */
7791
7919
  async shutdown(timeout) {
7920
+ for (const traceId of Object.keys(this.activeSpanMappings)) {
7921
+ unmapOpenAiAgentsTrace(traceId);
7922
+ }
7792
7923
  this.activeTraces = {};
7793
7924
  this.activeSpanMappings = {};
7794
7925
  this.canonicalTraceIds = {};
@@ -8946,16 +9077,16 @@ var Bitfab = class {
8946
9077
  this.simulationPlan.send(payload, rootTraceFunctionKeyOf(payload), submit);
8947
9078
  }
8948
9079
  refreshAutoTraceCapturePolicy(traceFunctionKey) {
8949
- const state = this.autoTracePolicyRefreshes.get(traceFunctionKey) ?? new PolicyRefresh();
8950
- this.autoTracePolicyRefreshes.set(traceFunctionKey, state);
8951
- state.run(
9080
+ const state2 = this.autoTracePolicyRefreshes.get(traceFunctionKey) ?? new PolicyRefresh();
9081
+ this.autoTracePolicyRefreshes.set(traceFunctionKey, state2);
9082
+ state2.run(
8952
9083
  () => this.httpClient.getAutoTracePolicy(
8953
9084
  traceFunctionKey,
8954
9085
  AUTO_TRACE_PROTOCOL
8955
9086
  ),
8956
9087
  (policy) => {
8957
9088
  if (policy.protocol !== AUTO_TRACE_PROTOCOL) {
8958
- state.hold(AUTO_TRACE_POLICY_RETRY_MS);
9089
+ state2.hold(AUTO_TRACE_POLICY_RETRY_MS);
8959
9090
  return;
8960
9091
  }
8961
9092
  const functionIds = Array.isArray(policy.functionIds) ? policy.functionIds.filter(
@@ -8966,10 +9097,10 @@ var Bitfab = class {
8966
9097
  traceFunctionKey,
8967
9098
  policy.revision === null ? void 0 : functionIds
8968
9099
  );
8969
- state.hold(AUTO_TRACE_POLICY_REFRESH_MS);
9100
+ state2.hold(AUTO_TRACE_POLICY_REFRESH_MS);
8970
9101
  },
8971
9102
  () => {
8972
- state.hold(AUTO_TRACE_POLICY_RETRY_MS);
9103
+ state2.hold(AUTO_TRACE_POLICY_RETRY_MS);
8973
9104
  }
8974
9105
  );
8975
9106
  }
@@ -9275,9 +9406,9 @@ var Bitfab = class {
9275
9406
  });
9276
9407
  }
9277
9408
  /**
9278
- * Get the first-class Rivet actor-context integration for an existing trace
9279
- * root. The integration binds context and records effect spans; it never
9280
- * creates another root.
9409
+ * Get the first-class Rivet actor/workflow-context integration for an
9410
+ * existing trace root. The integration binds context and records effect
9411
+ * spans; it never creates another root.
9281
9412
  *
9282
9413
  * @param traceFunctionKey - Key used by the enclosing `withTrace()` root
9283
9414
  * @param options - Explicit per-context-path replay mocking policy
@@ -9580,7 +9711,11 @@ var Bitfab = class {
9580
9711
  const seedCtxForTraceId = parentContext ? null : getSeedContext();
9581
9712
  const traceId = parentContext?.traceId ?? replayCtxForTraceId?.traceId ?? seedCtxForTraceId?.traceId ?? randomUuid();
9582
9713
  const spanId = randomUuid();
9583
- const parentSpanId = parentContext?.spanId ?? null;
9714
+ const openAiAgentsParent = parentContext !== void 0 && options.instrumentation === "trace" ? openAiAgentsParentSpanId(
9715
+ parentContext.traceId,
9716
+ parentContext.openAiAgentsSpanIds
9717
+ ) : void 0;
9718
+ const parentSpanId = openAiAgentsParent ?? parentContext?.spanId ?? null;
9584
9719
  const isRootSpan = parentSpanId === null;
9585
9720
  if (options.enclosingTrace !== void 0) {
9586
9721
  options.enclosingTrace.link.traceId = traceId;
@@ -9594,11 +9729,13 @@ var Bitfab = class {
9594
9729
  parentContext?.surface,
9595
9730
  traceFunctionKey
9596
9731
  );
9732
+ const openAiAgentsSpanIds = openAiAgentsSpanChain();
9597
9733
  const newContext = {
9598
9734
  traceId,
9599
9735
  spanId,
9600
9736
  contexts: [],
9601
- ...surface !== void 0 && { surface }
9737
+ ...surface !== void 0 && { surface },
9738
+ ...openAiAgentsSpanIds.length > 0 && { openAiAgentsSpanIds }
9602
9739
  };
9603
9740
  newStack = [...currentStack, newContext];
9604
9741
  const inputs = args;