@bitfab/sdk 0.68.11 → 0.70.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-BN_Ry7Wf.cjs → http-C6NC-zwf.cjs} +2 -2
- package/dist/http-C6NC-zwf.cjs.map +1 -0
- package/dist/{http-BiyOTH78.js → http-DcEhqOUu.js} +2 -2
- package/dist/{http-BN_Ry7Wf.cjs.map → http-DcEhqOUu.js.map} +1 -1
- package/dist/{index-Bg-oKbVP.d.cts → index-C9WPpeEU.d.cts} +116 -17
- package/dist/{index-Bg-oKbVP.d.ts → index-C9WPpeEU.d.ts} +116 -17
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/node.cjs +2 -2
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- 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-G_mEK3GW.cjs → src-Cwzg-mER.cjs} +72 -43
- package/dist/src-Cwzg-mER.cjs.map +1 -0
- package/dist/{src-B3hT_cMM.js → src-D-21-G6z.js} +72 -43
- package/dist/src-D-21-G6z.js.map +1 -0
- package/package.json +1 -1
- package/dist/http-BiyOTH78.js.map +0 -1
- package/dist/registryCommand-CWxt6kPp.js.map +0 -1
- package/dist/src-B3hT_cMM.js.map +0 -1
- package/dist/src-G_mEK3GW.cjs.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-DcEhqOUu.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";
|
|
@@ -1234,6 +1234,9 @@ var ExperimentsClient = class {
|
|
|
1234
1234
|
async getRollup(id) {
|
|
1235
1235
|
return this.httpClient.get(`${EXPERIMENTS_PATH}/${encodeURIComponent(id)}/rollup`);
|
|
1236
1236
|
}
|
|
1237
|
+
async getSummary(id) {
|
|
1238
|
+
return this.httpClient.get(`${EXPERIMENTS_PATH}/${encodeURIComponent(id)}/summary`);
|
|
1239
|
+
}
|
|
1237
1240
|
async getRollupAll(ids) {
|
|
1238
1241
|
if (ids.length === 0) return [];
|
|
1239
1242
|
const query = new URLSearchParams({ experimentIds: ids.join(",") });
|
|
@@ -3003,17 +3006,57 @@ var BitfabPiIntegration = class {
|
|
|
3003
3006
|
};
|
|
3004
3007
|
//#endregion
|
|
3005
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
|
+
}
|
|
3006
3050
|
const MAX_FILES = 60;
|
|
3007
3051
|
const MAX_FILE_BYTES = 5e5;
|
|
3008
3052
|
const MAX_TOTAL_BYTES = 2e6;
|
|
3009
3053
|
const MAX_BRANCH_WALK = 1e3;
|
|
3010
3054
|
const NUL = String.fromCharCode(0);
|
|
3011
|
-
async function
|
|
3055
|
+
async function captureCodeChange(type, label) {
|
|
3012
3056
|
if (typeof process === "undefined") return null;
|
|
3013
|
-
if (process.env?.BITFAB_DISABLE_CODE_CHANGE_CAPTURE) return null;
|
|
3014
3057
|
const fromEnv = await readCodeChangeFile();
|
|
3015
3058
|
if (fromEnv) return fromEnv;
|
|
3016
|
-
return captureCodeChangeFromGit(process.cwd?.() ?? ".", label);
|
|
3059
|
+
return captureCodeChangeFromGit(process.cwd?.() ?? ".", type, label);
|
|
3017
3060
|
}
|
|
3018
3061
|
async function readCodeChangeFile() {
|
|
3019
3062
|
const path = process.env?.BITFAB_CODE_CHANGE_PATH;
|
|
@@ -3032,7 +3075,7 @@ async function readCodeChangeFile() {
|
|
|
3032
3075
|
return null;
|
|
3033
3076
|
}
|
|
3034
3077
|
}
|
|
3035
|
-
async function captureCodeChangeFromGit(cwd, label) {
|
|
3078
|
+
async function captureCodeChangeFromGit(cwd, type, label) {
|
|
3036
3079
|
let readFile;
|
|
3037
3080
|
try {
|
|
3038
3081
|
({readFile} = await import("fs/promises"));
|
|
@@ -3048,16 +3091,9 @@ async function captureCodeChangeFromGit(cwd, label) {
|
|
|
3048
3091
|
try {
|
|
3049
3092
|
const root = (await git(cwd, ["rev-parse", "--show-toplevel"]))?.trim();
|
|
3050
3093
|
if (!root) return null;
|
|
3051
|
-
|
|
3094
|
+
const resolved = await resolveBase(git, root, type);
|
|
3052
3095
|
if (!resolved) return null;
|
|
3053
|
-
|
|
3054
|
-
if (entries.length === 0 && resolved.base === "HEAD") {
|
|
3055
|
-
const branchPoint = await resolveBranchPoint(git, root);
|
|
3056
|
-
if (branchPoint) {
|
|
3057
|
-
resolved = branchPoint;
|
|
3058
|
-
entries = await listChanges(git, root, branchPoint.base);
|
|
3059
|
-
}
|
|
3060
|
-
}
|
|
3096
|
+
const entries = await listChanges(git, root, resolved.base);
|
|
3061
3097
|
if (entries.length === 0) return null;
|
|
3062
3098
|
const { base, against } = resolved;
|
|
3063
3099
|
const blobBytes = async (ref, path) => {
|
|
@@ -3236,23 +3272,22 @@ async function resolveBranchPoint(git, root) {
|
|
|
3236
3272
|
against: `vs ${defaultBranch}`
|
|
3237
3273
|
} : null;
|
|
3238
3274
|
}
|
|
3239
|
-
async function
|
|
3240
|
-
const
|
|
3241
|
-
if (
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
}
|
|
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);
|
|
3256
3291
|
return await refExists(git, root, "HEAD") ? {
|
|
3257
3292
|
base: "HEAD",
|
|
3258
3293
|
against: "uncommitted (vs HEAD)"
|
|
@@ -3774,6 +3809,7 @@ const REPLAY_OPTION_NAMES = [
|
|
|
3774
3809
|
"notes",
|
|
3775
3810
|
"metadata",
|
|
3776
3811
|
"maxConcurrency",
|
|
3812
|
+
"codeChange",
|
|
3777
3813
|
"codeChangeDescription",
|
|
3778
3814
|
"codeChangeFiles",
|
|
3779
3815
|
"mock",
|
|
@@ -4141,6 +4177,7 @@ function warnJudgeAssertionsDeprecated(write = console.warn) {
|
|
|
4141
4177
|
writeOnce("judgeAssertions-deprecated", JUDGE_ASSERTIONS_DEPRECATION_WARNING, write);
|
|
4142
4178
|
}
|
|
4143
4179
|
async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, registeredOverrides = []) {
|
|
4180
|
+
validateCodeChange(options ?? {});
|
|
4144
4181
|
if (options?.judgeAssertions !== void 0) warnJudgeAssertionsDeprecated();
|
|
4145
4182
|
if (options?.resume !== void 0) validateResume(options.resume, options);
|
|
4146
4183
|
else if (options?.force === true) throw new BitfabError("force only applies when resuming an experiment. Pass it together with resume.");
|
|
@@ -4161,15 +4198,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
4161
4198
|
const maxConcurrency = options?.maxConcurrency ?? 10;
|
|
4162
4199
|
if (!Number.isInteger(maxConcurrency) || maxConcurrency < 1) throw new BitfabError(`maxConcurrency must be a positive integer (got ${maxConcurrency}).`);
|
|
4163
4200
|
await replayContextReady;
|
|
4164
|
-
|
|
4165
|
-
let codeChangeFiles = options?.codeChangeFiles;
|
|
4166
|
-
if (codeChangeFiles === void 0) {
|
|
4167
|
-
const captured = await resolveAutoCodeChange(options?.name);
|
|
4168
|
-
if (captured) {
|
|
4169
|
-
codeChangeFiles = captured.files;
|
|
4170
|
-
if (codeChangeDescription === void 0) codeChangeDescription = captured.description;
|
|
4171
|
-
}
|
|
4172
|
-
}
|
|
4201
|
+
const { description: codeChangeDescription, files: codeChangeFiles } = await resolveCodeChange(options, options.name);
|
|
4173
4202
|
const includeDbBranchLease = dbBranchEnabled(options?.dbBranch) && options?.dryRun !== true;
|
|
4174
4203
|
let session;
|
|
4175
4204
|
if (options?.resume === void 0) {
|
|
@@ -7009,7 +7038,7 @@ var Bitfab = class {
|
|
|
7009
7038
|
await runWithSeedContext({ traceId }, async () => target(...args));
|
|
7010
7039
|
} finally {
|
|
7011
7040
|
try {
|
|
7012
|
-
const { flushTraces } = await import("./http-
|
|
7041
|
+
const { flushTraces } = await import("./http-DcEhqOUu.js").then((n) => n.a);
|
|
7013
7042
|
await flushTraces(3e4);
|
|
7014
7043
|
} finally {
|
|
7015
7044
|
unrecorded = activeTraceStates.delete(traceId);
|
|
@@ -7215,7 +7244,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
|
|
|
7215
7244
|
metadata: seedCase.metadata,
|
|
7216
7245
|
sessionId: seedCase.sessionId
|
|
7217
7246
|
}));
|
|
7218
|
-
const { flushTraces } = await import("./http-
|
|
7247
|
+
const { flushTraces } = await import("./http-DcEhqOUu.js").then((n) => n.a);
|
|
7219
7248
|
await flushTraces(3e4);
|
|
7220
7249
|
return {
|
|
7221
7250
|
pipeline,
|
|
@@ -7232,4 +7261,4 @@ function resolveTraceFunctionKey(registration) {
|
|
|
7232
7261
|
//#endregion
|
|
7233
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 };
|
|
7234
7263
|
|
|
7235
|
-
//# sourceMappingURL=src-
|
|
7264
|
+
//# sourceMappingURL=src-D-21-G6z.js.map
|