@bitfab/sdk 0.69.0 → 0.71.0
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/cloudReplay.py +49 -27
- package/dist/{http-C9icRaA3.cjs → http-D2Rgpq7_.cjs} +4 -3
- package/dist/http-D2Rgpq7_.cjs.map +1 -0
- package/dist/{http-CzKW7TgN.js → http-Dh6NfOpj.js} +4 -3
- package/dist/http-Dh6NfOpj.js.map +1 -0
- package/dist/{index-D7y_bwZC.d.cts → index-CEhjDPxK.d.cts} +36 -17
- package/dist/{index-D7y_bwZC.d.ts → index-CEhjDPxK.d.ts} +36 -17
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/node.cjs +2 -2
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +2 -2
- package/dist/{registryCommand-CWxt6kPp.js → registryCommand-jPTSRgL9.js} +39 -16
- package/dist/registryCommand-jPTSRgL9.js.map +1 -0
- package/dist/replayCli.js +2 -2
- package/dist/replayCli.js.map +1 -1
- package/dist/seedCli.js +1 -1
- package/dist/{src-4VpSvoAt.cjs → src-C2OX1CHX.cjs} +70 -44
- package/dist/src-C2OX1CHX.cjs.map +1 -0
- package/dist/{src-Cn--d1sW.js → src-gqUT-PNr.js} +70 -44
- package/dist/src-gqUT-PNr.js.map +1 -0
- package/package.json +1 -1
- package/dist/http-C9icRaA3.cjs.map +0 -1
- package/dist/http-CzKW7TgN.js.map +0 -1
- package/dist/registryCommand-CWxt6kPp.js.map +0 -1
- package/dist/src-4VpSvoAt.cjs.map +0 -1
- package/dist/src-Cn--d1sW.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
|
-
import { C as BitfabError, E as __version__, S as gitRunner, T as readEnv$1, _ as MAX_SPAN_CARRIER_BYTES, b as replayContextReady, c as recordCallerTraceMetadata, f as ROOT_TRACE_FUNCTION_KEY_FIELD, g as MAX_COMPRESSIBLE_SPAN_CARRIER_BYTES, h as makeSpanOrigin, i as flushTraces, l as retireTraceMetadata, m as isFrameworkInstrumentation, n as SPAN_TYPES, o as unrefTimer, p as SimulationPlan, r as experimentIdWireFields, s as callerTraceMetadata, t as HttpClient, v as byteLength, w as MixedTracingError, x as runWithReplayContext, y as getReplayContext } from "./http-
|
|
2
|
+
import { C as BitfabError, E as __version__, S as gitRunner, T as readEnv$1, _ as MAX_SPAN_CARRIER_BYTES, b as replayContextReady, c as recordCallerTraceMetadata, f as ROOT_TRACE_FUNCTION_KEY_FIELD, g as MAX_COMPRESSIBLE_SPAN_CARRIER_BYTES, h as makeSpanOrigin, i as flushTraces, l as retireTraceMetadata, m as isFrameworkInstrumentation, n as SPAN_TYPES, o as unrefTimer, p as SimulationPlan, r as experimentIdWireFields, s as callerTraceMetadata, t as HttpClient, v as byteLength, w as MixedTracingError, x as runWithReplayContext, y as getReplayContext } from "./http-Dh6NfOpj.js";
|
|
3
3
|
import { A as unmapOpenAiAgentsTrace, B as asyncStorageReady, C as recordAutoTracedClientCall, D as mapOpenAiAgentsTrace, E as endOpenAiAgentsSpan, F as warnOnce, H as isAsyncStorageInitDone, I as writeOnce, L as isCaptureSuppressed, M as installLangChainRunScopes, N as markLangChainRunRecorded, O as openAiAgentsParentSpanId, R as runWithCaptureSuppressed, S as frameworkRecordsClientCall, T as watchClientCall, V as createAsyncLocalStorage, _ as runWithAutoTraceRootContext, b as OPENROUTER, f as invokeThroughAutoTraceEntries, g as runWithAutoTraceNodeConfiguration, h as runWithAutoTraceFramesAt, j as forgetLangChainRun, k as openAiAgentsSpanChain, l as clearAutoTraceNodeConfiguration, m as runWithAutoTraceEntry, o as __bitfabAutoTraceActive, p as runAsAutoTraceRootFunction, u as currentAutoTraceEntries, v as ANTHROPIC, w as recordWatchedClientCall, x as clientCallProvider, y as OPENAI_RESPONSES } from "./autoTrace-kHOBg49M.js";
|
|
4
4
|
import { t as importOptionalPeer } from "./optionalPeer-CczrzrXx.js";
|
|
5
5
|
import { t as loadBamlModule } from "./bamlPeer-Dyeb3e5o.js";
|
|
@@ -3006,17 +3006,57 @@ var BitfabPiIntegration = class {
|
|
|
3006
3006
|
};
|
|
3007
3007
|
//#endregion
|
|
3008
3008
|
//#region src/codeChange.ts
|
|
3009
|
+
const CODE_CHANGE_TYPES = [
|
|
3010
|
+
"working-tree",
|
|
3011
|
+
"last-branch",
|
|
3012
|
+
"default-branch",
|
|
3013
|
+
"skip",
|
|
3014
|
+
"manual"
|
|
3015
|
+
];
|
|
3016
|
+
const CODE_CHANGE_CHOICES = "\"working-tree\" (uncommitted changes vs HEAD), \"last-branch\" (the diff against the branch this one was cut from), \"default-branch\" (the diff against the default branch), \"skip\" (no code change), or \"manual\" (pass the files yourself)";
|
|
3017
|
+
function isCodeChangeType(value) {
|
|
3018
|
+
return CODE_CHANGE_TYPES.includes(value);
|
|
3019
|
+
}
|
|
3020
|
+
function validateCodeChange(request) {
|
|
3021
|
+
const { codeChange, codeChangeDescription, codeChangeFiles } = request;
|
|
3022
|
+
if (codeChange === void 0 || codeChange === null) throw new BitfabError(`replay needs a codeChange naming the code this run tests: ${CODE_CHANGE_CHOICES}.`);
|
|
3023
|
+
if (!isCodeChangeType(codeChange)) throw new BitfabError(`Unknown codeChange ${JSON.stringify(codeChange)}. Pass ${CODE_CHANGE_CHOICES}.`);
|
|
3024
|
+
const hasFiles = codeChangeFiles !== void 0 && codeChangeFiles !== null;
|
|
3025
|
+
if (codeChange === "manual" && !hasFiles) throw new BitfabError("codeChange \"manual\" needs codeChangeFiles: the path and before/after contents of each edited file.");
|
|
3026
|
+
if (codeChange !== "manual" && hasFiles) throw new BitfabError(`codeChangeFiles only applies with codeChange "manual" (got "${codeChange}").`);
|
|
3027
|
+
if (codeChange === "skip" && codeChangeDescription !== void 0 && codeChangeDescription !== null) throw new BitfabError("codeChange \"skip\" attaches no code change, so it cannot take a codeChangeDescription.");
|
|
3028
|
+
return codeChange;
|
|
3029
|
+
}
|
|
3030
|
+
async function resolveCodeChange(request, label) {
|
|
3031
|
+
const codeChange = validateCodeChange(request);
|
|
3032
|
+
const description = request.codeChangeDescription ?? void 0;
|
|
3033
|
+
if (codeChange === "skip") return {};
|
|
3034
|
+
if (codeChange === "manual") return {
|
|
3035
|
+
description,
|
|
3036
|
+
files: request.codeChangeFiles ?? []
|
|
3037
|
+
};
|
|
3038
|
+
const captured = await captureCodeChange(codeChange, label);
|
|
3039
|
+
if (captured?.files === void 0 || captured.files.length === 0) {
|
|
3040
|
+
try {
|
|
3041
|
+
console.warn(`Bitfab: codeChange "${codeChange}" found no changed files, so this replay has no code change attached.`);
|
|
3042
|
+
} catch {}
|
|
3043
|
+
return { description };
|
|
3044
|
+
}
|
|
3045
|
+
return {
|
|
3046
|
+
description: description ?? captured.description,
|
|
3047
|
+
files: captured.files
|
|
3048
|
+
};
|
|
3049
|
+
}
|
|
3009
3050
|
const MAX_FILES = 60;
|
|
3010
3051
|
const MAX_FILE_BYTES = 5e5;
|
|
3011
3052
|
const MAX_TOTAL_BYTES = 2e6;
|
|
3012
3053
|
const MAX_BRANCH_WALK = 1e3;
|
|
3013
3054
|
const NUL = String.fromCharCode(0);
|
|
3014
|
-
async function
|
|
3055
|
+
async function captureCodeChange(type, label) {
|
|
3015
3056
|
if (typeof process === "undefined") return null;
|
|
3016
|
-
if (process.env?.BITFAB_DISABLE_CODE_CHANGE_CAPTURE) return null;
|
|
3017
3057
|
const fromEnv = await readCodeChangeFile();
|
|
3018
3058
|
if (fromEnv) return fromEnv;
|
|
3019
|
-
return captureCodeChangeFromGit(process.cwd?.() ?? ".", label);
|
|
3059
|
+
return captureCodeChangeFromGit(process.cwd?.() ?? ".", type, label);
|
|
3020
3060
|
}
|
|
3021
3061
|
async function readCodeChangeFile() {
|
|
3022
3062
|
const path = process.env?.BITFAB_CODE_CHANGE_PATH;
|
|
@@ -3035,7 +3075,7 @@ async function readCodeChangeFile() {
|
|
|
3035
3075
|
return null;
|
|
3036
3076
|
}
|
|
3037
3077
|
}
|
|
3038
|
-
async function captureCodeChangeFromGit(cwd, label) {
|
|
3078
|
+
async function captureCodeChangeFromGit(cwd, type, label) {
|
|
3039
3079
|
let readFile;
|
|
3040
3080
|
try {
|
|
3041
3081
|
({readFile} = await import("fs/promises"));
|
|
@@ -3051,16 +3091,9 @@ async function captureCodeChangeFromGit(cwd, label) {
|
|
|
3051
3091
|
try {
|
|
3052
3092
|
const root = (await git(cwd, ["rev-parse", "--show-toplevel"]))?.trim();
|
|
3053
3093
|
if (!root) return null;
|
|
3054
|
-
|
|
3094
|
+
const resolved = await resolveBase(git, root, type);
|
|
3055
3095
|
if (!resolved) return null;
|
|
3056
|
-
|
|
3057
|
-
if (entries.length === 0 && resolved.base === "HEAD") {
|
|
3058
|
-
const branchPoint = await resolveBranchPoint(git, root);
|
|
3059
|
-
if (branchPoint) {
|
|
3060
|
-
resolved = branchPoint;
|
|
3061
|
-
entries = await listChanges(git, root, branchPoint.base);
|
|
3062
|
-
}
|
|
3063
|
-
}
|
|
3096
|
+
const entries = await listChanges(git, root, resolved.base);
|
|
3064
3097
|
if (entries.length === 0) return null;
|
|
3065
3098
|
const { base, against } = resolved;
|
|
3066
3099
|
const blobBytes = async (ref, path) => {
|
|
@@ -3239,23 +3272,22 @@ async function resolveBranchPoint(git, root) {
|
|
|
3239
3272
|
against: `vs ${defaultBranch}`
|
|
3240
3273
|
} : null;
|
|
3241
3274
|
}
|
|
3242
|
-
async function
|
|
3243
|
-
const
|
|
3244
|
-
if (
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
}
|
|
3275
|
+
async function resolveDefaultBranchPoint(git, root) {
|
|
3276
|
+
const defaultBranch = await resolveDefaultBranch(git, root);
|
|
3277
|
+
if (!defaultBranch) return null;
|
|
3278
|
+
const base = (await git(root, [
|
|
3279
|
+
"merge-base",
|
|
3280
|
+
"HEAD",
|
|
3281
|
+
defaultBranch
|
|
3282
|
+
]))?.trim();
|
|
3283
|
+
return base ? {
|
|
3284
|
+
base,
|
|
3285
|
+
against: `vs ${defaultBranch}`
|
|
3286
|
+
} : null;
|
|
3287
|
+
}
|
|
3288
|
+
async function resolveBase(git, root, type) {
|
|
3289
|
+
if (type === "last-branch") return resolveBranchPoint(git, root);
|
|
3290
|
+
if (type === "default-branch") return resolveDefaultBranchPoint(git, root);
|
|
3259
3291
|
return await refExists(git, root, "HEAD") ? {
|
|
3260
3292
|
base: "HEAD",
|
|
3261
3293
|
against: "uncommitted (vs HEAD)"
|
|
@@ -3777,6 +3809,7 @@ const REPLAY_OPTION_NAMES = [
|
|
|
3777
3809
|
"notes",
|
|
3778
3810
|
"metadata",
|
|
3779
3811
|
"maxConcurrency",
|
|
3812
|
+
"codeChange",
|
|
3780
3813
|
"codeChangeDescription",
|
|
3781
3814
|
"codeChangeFiles",
|
|
3782
3815
|
"mock",
|
|
@@ -4144,6 +4177,7 @@ function warnJudgeAssertionsDeprecated(write = console.warn) {
|
|
|
4144
4177
|
writeOnce("judgeAssertions-deprecated", JUDGE_ASSERTIONS_DEPRECATION_WARNING, write);
|
|
4145
4178
|
}
|
|
4146
4179
|
async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, registeredOverrides = []) {
|
|
4180
|
+
const codeChangeType = validateCodeChange(options ?? {});
|
|
4147
4181
|
if (options?.judgeAssertions !== void 0) warnJudgeAssertionsDeprecated();
|
|
4148
4182
|
if (options?.resume !== void 0) validateResume(options.resume, options);
|
|
4149
4183
|
else if (options?.force === true) throw new BitfabError("force only applies when resuming an experiment. Pass it together with resume.");
|
|
@@ -4164,19 +4198,11 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
4164
4198
|
const maxConcurrency = options?.maxConcurrency ?? 10;
|
|
4165
4199
|
if (!Number.isInteger(maxConcurrency) || maxConcurrency < 1) throw new BitfabError(`maxConcurrency must be a positive integer (got ${maxConcurrency}).`);
|
|
4166
4200
|
await replayContextReady;
|
|
4167
|
-
|
|
4168
|
-
let codeChangeFiles = options?.codeChangeFiles;
|
|
4169
|
-
if (codeChangeFiles === void 0) {
|
|
4170
|
-
const captured = await resolveAutoCodeChange(options?.name);
|
|
4171
|
-
if (captured) {
|
|
4172
|
-
codeChangeFiles = captured.files;
|
|
4173
|
-
if (codeChangeDescription === void 0) codeChangeDescription = captured.description;
|
|
4174
|
-
}
|
|
4175
|
-
}
|
|
4201
|
+
const { description: codeChangeDescription, files: codeChangeFiles } = await resolveCodeChange(options, options.name);
|
|
4176
4202
|
const includeDbBranchLease = dbBranchEnabled(options?.dbBranch) && options?.dryRun !== true;
|
|
4177
4203
|
let session;
|
|
4178
4204
|
if (options?.resume === void 0) {
|
|
4179
|
-
const started = await httpClient.startReplay(traceFunctionKey, options?.traceIds ? void 0 : options?.limit ?? 5, options?.traceIds, options?.name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, options?.experimentGroupId, datasetIds, options?.graderIds, resolveDbBranchSettings(options?.dbBranch), requestedAttempts, options?.adaptInputs !== void 0, options?.onlyWithAssertions, options?.skipAssertionJudging === true || options?.judgeAssertions === false, options?.experimentalSelectiveReplay, options?.notes, options?.metadata, options?.dryRun === true, options?.experimentGroupName, safeReplayInvocation(() => buildReplayInvocation(Object.entries(cliFlags(options) ?? explicitReplayOptions(options)))));
|
|
4205
|
+
const started = await httpClient.startReplay(traceFunctionKey, options?.traceIds ? void 0 : options?.limit ?? 5, options?.traceIds, options?.name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, options?.experimentGroupId, datasetIds, options?.graderIds, resolveDbBranchSettings(options?.dbBranch), requestedAttempts, options?.adaptInputs !== void 0, options?.onlyWithAssertions, options?.skipAssertionJudging === true || options?.judgeAssertions === false, options?.experimentalSelectiveReplay, options?.notes, options?.metadata, options?.dryRun === true, options?.experimentGroupName, safeReplayInvocation(() => buildReplayInvocation(Object.entries(cliFlags(options) ?? explicitReplayOptions(options)))), codeChangeType);
|
|
4180
4206
|
if (started.items.length === 0) try {
|
|
4181
4207
|
console.warn(`Bitfab: no traces matched "${traceFunctionKey}", so this replay ran nothing. Capture a trace, or seed one with seedTrace, before replaying.`);
|
|
4182
4208
|
} catch {}
|
|
@@ -7012,7 +7038,7 @@ var Bitfab = class {
|
|
|
7012
7038
|
await runWithSeedContext({ traceId }, async () => target(...args));
|
|
7013
7039
|
} finally {
|
|
7014
7040
|
try {
|
|
7015
|
-
const { flushTraces } = await import("./http-
|
|
7041
|
+
const { flushTraces } = await import("./http-Dh6NfOpj.js").then((n) => n.a);
|
|
7016
7042
|
await flushTraces(3e4);
|
|
7017
7043
|
} finally {
|
|
7018
7044
|
unrecorded = activeTraceStates.delete(traceId);
|
|
@@ -7218,7 +7244,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
|
|
|
7218
7244
|
metadata: seedCase.metadata,
|
|
7219
7245
|
sessionId: seedCase.sessionId
|
|
7220
7246
|
}));
|
|
7221
|
-
const { flushTraces } = await import("./http-
|
|
7247
|
+
const { flushTraces } = await import("./http-Dh6NfOpj.js").then((n) => n.a);
|
|
7222
7248
|
await flushTraces(3e4);
|
|
7223
7249
|
return {
|
|
7224
7250
|
pipeline,
|
|
@@ -7235,4 +7261,4 @@ function resolveTraceFunctionKey(registration) {
|
|
|
7235
7261
|
//#endregion
|
|
7236
7262
|
export { VerdictsClient as A, OrganizationMembersClient as C, BitfabLangGraphCallbackHandler as D, BitfabLangGraphIntegration as E, GraderRerunTimeoutError as F, BitfabClaudeAgentHandler as I, DEFAULT_SERVICE_URL as L, SUPPORTED_PROVIDERS as M, DatasetsClient as N, GradersClient as O, GraderRerunError as P, AssertionCategoriesClient as R, BitfabPiIntegration as S, NO_MOCK_OVERRIDE as T, BITFAB_PROGRESS_PREFIX as _, Bitfab as a, reportReplayProgress as b, getCurrentSpan as c, BitfabOpenAITracingProcessor as d, AssertionGenerationError as f, BitfabRivetIntegration as g, SpansClient as h, finalizers as i, ExperimentsClient as j, LabelsClient as k, getCurrentTrace as l, TracesClient as m, reseedFromRegistry as n, BitfabFunction as o, AssertionGenerationTimeoutError as p, seedFromRegistry as r, getCurrentReplayBranch as s, defineReplayRegistry as t, BitfabVercelAiHandler as u, DbBranchReplayError as v, BitfabOpenAIAgentHandler as w, serializeReplayResult as x, ReplayError as y, CategoriesClient as z };
|
|
7237
7263
|
|
|
7238
|
-
//# sourceMappingURL=src-
|
|
7264
|
+
//# sourceMappingURL=src-gqUT-PNr.js.map
|