@bitfab/sdk 0.68.9 → 0.68.10

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.
@@ -1,5 +1,5 @@
1
1
  const require_bamlPeer = require("./bamlPeer-5Ohpq8q9.cjs");
2
- const require_http = require("./http-CxIFBucn.cjs");
2
+ const require_http = require("./http-7phqgMvk.cjs");
3
3
  const require_autoTrace = require("./autoTrace-DPWV1Xzr.cjs");
4
4
  const require_optionalPeer = require("./optionalPeer-CUH756lt.cjs");
5
5
  let superjson = require("superjson");
@@ -2615,7 +2615,7 @@ function leadingSystemMessages(messages) {
2615
2615
  }
2616
2616
  function serializedBytes(value) {
2617
2617
  try {
2618
- return JSON.stringify(value)?.length;
2618
+ return require_http.byteLength(JSON.stringify(value) ?? "");
2619
2619
  } catch {
2620
2620
  return;
2621
2621
  }
@@ -2835,7 +2835,11 @@ var BitfabPiIntegration = class {
2835
2835
  }
2836
2836
  restoreIntoSession(session, messages) {
2837
2837
  const store = session.sessionManager;
2838
- if (store?.isPersisted?.() !== false || typeof store.appendMessage !== "function") {
2838
+ if (typeof store?.isPersisted !== "function" || typeof store.appendMessage !== "function") {
2839
+ require_autoTrace.warnOnce(`pi-replay-session-unknown-store:${this.traceFunctionKey}`, `A replayed "${this.traceFunctionKey}" run used an AgentSession whose session manager has no isPersisted() or appendMessage() method, so Bitfab could not tell whether it is saved to disk and did not restore the recorded conversation into it. Build the session in your replay function with SessionManager.inMemory() to replay each turn with its history.`);
2840
+ return;
2841
+ }
2842
+ if (store.isPersisted()) {
2839
2843
  require_autoTrace.warnOnce(`pi-replay-session-persisted:${this.traceFunctionKey}`, `A replayed "${this.traceFunctionKey}" run used an AgentSession saved to disk, so Bitfab did not restore the recorded conversation into it. Build the session in your replay function with SessionManager.inMemory() to replay each turn with its history.`);
2840
2844
  return;
2841
2845
  }
@@ -2905,15 +2909,17 @@ var BitfabPiIntegration = class {
2905
2909
  const replaysContinue = this.restoredTranscript(run)?.method === "continue" && callsWithoutArguments(callArgs);
2906
2910
  const calledMethod = replaysContinue ? "continue" : method;
2907
2911
  if (require_http.getReplayContext() === null) this.recordTranscript(method, run.state());
2908
- await Reflect.get(target, calledMethod, target).apply(receiver, replaysContinue ? [] : callArgs);
2912
+ const original = Reflect.get(target, calledMethod, target);
2913
+ const start = run.state().messages.length;
2914
+ await original.apply(receiver, replaysContinue ? [] : callArgs);
2909
2915
  throwKeptReplayFailure();
2916
+ return start;
2910
2917
  };
2911
- if (this.host.activeRootTraceFunctionKey() === this.traceFunctionKey) return call(...args);
2918
+ if (this.host.activeRootTraceFunctionKey() === this.traceFunctionKey) return call(...args).then(() => void 0);
2912
2919
  const callReturningFinalMessage = async (...callArgs) => {
2913
2920
  const sessionId = run.sessionId();
2914
2921
  if (typeof sessionId === "string" && sessionId.length > 0) this.host.setTraceSessionId(sessionId);
2915
- const start = run.state().messages.length;
2916
- await call(...callArgs);
2922
+ const start = await call(...callArgs);
2917
2923
  return lastAssistantMessageSince(run.state(), start);
2918
2924
  };
2919
2925
  return this.host.withSpan(this.traceFunctionKey, {
@@ -7003,7 +7009,7 @@ var Bitfab = class {
7003
7009
  await runWithSeedContext({ traceId }, async () => target(...args));
7004
7010
  } finally {
7005
7011
  try {
7006
- const { flushTraces } = await Promise.resolve().then(() => require("./http-CxIFBucn.cjs")).then((n) => n.http_exports);
7012
+ const { flushTraces } = await Promise.resolve().then(() => require("./http-7phqgMvk.cjs")).then((n) => n.http_exports);
7007
7013
  await flushTraces(3e4);
7008
7014
  } finally {
7009
7015
  unrecorded = activeTraceStates.delete(traceId);
@@ -7209,7 +7215,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
7209
7215
  metadata: seedCase.metadata,
7210
7216
  sessionId: seedCase.sessionId
7211
7217
  }));
7212
- const { flushTraces } = await Promise.resolve().then(() => require("./http-CxIFBucn.cjs")).then((n) => n.http_exports);
7218
+ const { flushTraces } = await Promise.resolve().then(() => require("./http-7phqgMvk.cjs")).then((n) => n.http_exports);
7213
7219
  await flushTraces(3e4);
7214
7220
  return {
7215
7221
  pipeline,
@@ -7459,4 +7465,4 @@ Object.defineProperty(exports, "serializeReplayResult", {
7459
7465
  }
7460
7466
  });
7461
7467
 
7462
- //# sourceMappingURL=src-yzu_ogdm.cjs.map
7468
+ //# sourceMappingURL=src-CWLtmzX2.cjs.map