@brainbase-labs/cli 0.25.0-eng1209.9 → 0.25.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/dist/index.js +113 -22
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -36008,7 +36008,7 @@ function padStart(s, n) {
|
|
|
36008
36008
|
// package.json
|
|
36009
36009
|
var package_default = {
|
|
36010
36010
|
name: "@brainbase-labs/cli",
|
|
36011
|
-
version: "0.25.0
|
|
36011
|
+
version: "0.25.0",
|
|
36012
36012
|
description: "Pack, share, and install agent templates across harnesses (Claude Code, Codex, ...).",
|
|
36013
36013
|
type: "module",
|
|
36014
36014
|
bin: {
|
|
@@ -78485,6 +78485,8 @@ var MAX_TRAJECTORY_BYTES = 100 * 1024 * 1024;
|
|
|
78485
78485
|
var MAX_REMOTE_INPUT_BYTES = 2 * 1024 * 1024 * 1024;
|
|
78486
78486
|
var MAX_ARCHIVE_EXTRACTED_BYTES = 2 * 1024 * 1024 * 1024;
|
|
78487
78487
|
var MAX_ARCHIVE_SCAN_BYTES = 2 * 1024 * 1024 * 1024;
|
|
78488
|
+
var MAX_HYDRATE_COMMANDS = 150;
|
|
78489
|
+
var MAX_PHASE_RESULT_BYTES = 32 * 1024 * 1024;
|
|
78488
78490
|
var MAX_SANDBOX_COMMANDS = 20;
|
|
78489
78491
|
var MAX_CRITERIA_PER_EVALUATOR = 200;
|
|
78490
78492
|
var MAX_CRITERIA_RESULT_BYTES = 24 * 1024 * 1024;
|
|
@@ -78496,6 +78498,7 @@ var MAX_ALLOWED_EVIDENCE_IDS = 1e4;
|
|
|
78496
78498
|
var COMMAND_PROCESS_MARKER_ENV = "BRAINBASE_BENCHMARK_COMMAND_MARKER";
|
|
78497
78499
|
var COMMAND_PROCESS_POLL_MS = 10;
|
|
78498
78500
|
var COMMAND_PROCESS_CLEANUP_MS = 500;
|
|
78501
|
+
var JUDGE_ERROR_PREFIX = "BRAINBASE_BENCHMARK_JUDGE_ERROR_V1:";
|
|
78499
78502
|
var RESERVED_WORKSPACE_PATHS = new Set([
|
|
78500
78503
|
".brainbase",
|
|
78501
78504
|
".git",
|
|
@@ -78662,7 +78665,7 @@ var TrajectoryEvidenceSchema = EvidenceFileSchema.extend({
|
|
|
78662
78665
|
var HydrateSpecSchema = BaseSpecSchema.extend({
|
|
78663
78666
|
phase: exports_external.literal("hydrate"),
|
|
78664
78667
|
materials: exports_external.array(MaterialSchema).max(1e4).default([]),
|
|
78665
|
-
setup_commands: exports_external.array(CommandSchema).max(
|
|
78668
|
+
setup_commands: exports_external.array(CommandSchema).max(MAX_HYDRATE_COMMANDS).default([])
|
|
78666
78669
|
}).strict();
|
|
78667
78670
|
var CandidateOutputSchema = exports_external.object({
|
|
78668
78671
|
id: IdSchema,
|
|
@@ -78803,12 +78806,12 @@ var BenchmarkSpecSchema = exports_external.discriminatedUnion("phase", [
|
|
|
78803
78806
|
{ items: value.candidate_outputs, path: "candidate_outputs" }
|
|
78804
78807
|
];
|
|
78805
78808
|
for (const { items, path: issuePath } of uniqueLists) {
|
|
78806
|
-
const ids = items.map((item) => item.id);
|
|
78809
|
+
const ids = items.map((item) => issuePath === "candidate_outputs" ? item.id.toLowerCase() : item.id);
|
|
78807
78810
|
if (new Set(ids).size !== ids.length) {
|
|
78808
78811
|
context.addIssue({
|
|
78809
78812
|
code: exports_external.ZodIssueCode.custom,
|
|
78810
78813
|
path: [issuePath],
|
|
78811
|
-
message: `${issuePath} ids must be unique`
|
|
78814
|
+
message: `${issuePath} ids must be unique${issuePath === "candidate_outputs" ? " ignoring case" : ""}`
|
|
78812
78815
|
});
|
|
78813
78816
|
}
|
|
78814
78817
|
}
|
|
@@ -78871,6 +78874,7 @@ var BENCHMARK_CAPABILITIES = {
|
|
|
78871
78874
|
"remote_input_references_v1",
|
|
78872
78875
|
"archive_file_materials_v1",
|
|
78873
78876
|
"structured_criterion_results_v1",
|
|
78877
|
+
"structured_judge_errors_v1",
|
|
78874
78878
|
"multiple_sandbox_commands_v1",
|
|
78875
78879
|
"sandbox_command_workspace_modes_v1",
|
|
78876
78880
|
"candidate_outputs_v1",
|
|
@@ -78884,6 +78888,8 @@ var BENCHMARK_CAPABILITIES = {
|
|
|
78884
78888
|
],
|
|
78885
78889
|
limits: {
|
|
78886
78890
|
max_secret_bindings: 100,
|
|
78891
|
+
max_hydrate_commands: MAX_HYDRATE_COMMANDS,
|
|
78892
|
+
max_phase_result_bytes: MAX_PHASE_RESULT_BYTES,
|
|
78887
78893
|
max_evaluators: 1000,
|
|
78888
78894
|
max_sandbox_commands: MAX_SANDBOX_COMMANDS,
|
|
78889
78895
|
max_criteria_per_evaluator: MAX_CRITERIA_PER_EVALUATOR
|
|
@@ -80683,6 +80689,29 @@ var CriteriaResultFileSchema = exports_external.object({
|
|
|
80683
80689
|
});
|
|
80684
80690
|
}
|
|
80685
80691
|
});
|
|
80692
|
+
var JudgeErrorSchema = exports_external.object({
|
|
80693
|
+
code: exports_external.enum([
|
|
80694
|
+
"judge_provider_quota_exhausted",
|
|
80695
|
+
"judge_rate_limited",
|
|
80696
|
+
"judge_provider_authentication_failed",
|
|
80697
|
+
"judge_provider_unavailable",
|
|
80698
|
+
"judge_request_failed"
|
|
80699
|
+
]),
|
|
80700
|
+
message: exports_external.string().min(1).max(500)
|
|
80701
|
+
}).strict();
|
|
80702
|
+
function structuredJudgeError(stderr) {
|
|
80703
|
+
for (const line of stderr.toString("utf8").split(/\r?\n/).reverse()) {
|
|
80704
|
+
const marker = line.indexOf(JUDGE_ERROR_PREFIX);
|
|
80705
|
+
if (marker < 0)
|
|
80706
|
+
continue;
|
|
80707
|
+
try {
|
|
80708
|
+
const parsed = JudgeErrorSchema.safeParse(JSON.parse(line.slice(marker + JUDGE_ERROR_PREFIX.length)));
|
|
80709
|
+
if (parsed.success)
|
|
80710
|
+
return parsed.data;
|
|
80711
|
+
} catch {}
|
|
80712
|
+
}
|
|
80713
|
+
return null;
|
|
80714
|
+
}
|
|
80686
80715
|
function readCriterionResults(resultPath, criterionKeys, allowedEvidenceIds, spec, additionalSecrets = []) {
|
|
80687
80716
|
let opened;
|
|
80688
80717
|
try {
|
|
@@ -80929,7 +80958,13 @@ async function evaluateOne(evaluator, spec, manifest, frozenWorkspaceRoot, final
|
|
|
80929
80958
|
try {
|
|
80930
80959
|
criterionResults = evaluator.criterion_keys && criterionResultPath ? readCriterionResults(criterionResultPath, evaluator.criterion_keys, evaluator.allowed_evidence_ids ?? [], spec, result2.redactions) : undefined;
|
|
80931
80960
|
} catch (error2) {
|
|
80932
|
-
|
|
80961
|
+
let normalized = stableError(error2);
|
|
80962
|
+
if (normalized?.code === "missing_criterion_result" && result2.exitCode !== 0) {
|
|
80963
|
+
normalized = structuredJudgeError(result2.stderr) ?? {
|
|
80964
|
+
code: "command_terminated",
|
|
80965
|
+
message: "sandbox evaluator terminated before writing its criterion result"
|
|
80966
|
+
};
|
|
80967
|
+
}
|
|
80933
80968
|
return {
|
|
80934
80969
|
...base2,
|
|
80935
80970
|
status: "errored",
|
|
@@ -81165,6 +81200,67 @@ function stableError(error2) {
|
|
|
81165
81200
|
message: error2 instanceof Error ? error2.message : "unknown benchmark phase failure"
|
|
81166
81201
|
};
|
|
81167
81202
|
}
|
|
81203
|
+
function compactOversizedResult(result2) {
|
|
81204
|
+
const actualBytes = Buffer.byteLength(`${JSON.stringify(result2, null, 2)}
|
|
81205
|
+
`);
|
|
81206
|
+
if (actualBytes <= MAX_PHASE_RESULT_BYTES)
|
|
81207
|
+
return result2;
|
|
81208
|
+
return {
|
|
81209
|
+
schema_version: result2.schema_version,
|
|
81210
|
+
cli_version: result2.cli_version,
|
|
81211
|
+
phase: result2.phase,
|
|
81212
|
+
attempt_id: result2.attempt_id,
|
|
81213
|
+
phase_id: result2.phase_id,
|
|
81214
|
+
spec_digest: result2.spec_digest,
|
|
81215
|
+
status: "failed",
|
|
81216
|
+
started_at: result2.started_at,
|
|
81217
|
+
completed_at: result2.completed_at,
|
|
81218
|
+
duration_ms: result2.duration_ms,
|
|
81219
|
+
steps: [],
|
|
81220
|
+
inputs: [],
|
|
81221
|
+
outputs: [],
|
|
81222
|
+
error: {
|
|
81223
|
+
code: "result_too_large",
|
|
81224
|
+
message: "benchmark phase result exceeds the 32 MiB contract limit",
|
|
81225
|
+
details: {
|
|
81226
|
+
actual_bytes: actualBytes,
|
|
81227
|
+
max_bytes: MAX_PHASE_RESULT_BYTES,
|
|
81228
|
+
step_count: result2.steps.length,
|
|
81229
|
+
input_count: result2.inputs.length,
|
|
81230
|
+
output_count: result2.outputs.length,
|
|
81231
|
+
evaluator_count: result2.evaluators?.length ?? 0
|
|
81232
|
+
}
|
|
81233
|
+
}
|
|
81234
|
+
};
|
|
81235
|
+
}
|
|
81236
|
+
function readCachedPhaseResult(resultPath) {
|
|
81237
|
+
let opened;
|
|
81238
|
+
try {
|
|
81239
|
+
opened = openRegularFileNoFollow(resultPath, "cached benchmark phase result");
|
|
81240
|
+
} catch {
|
|
81241
|
+
return;
|
|
81242
|
+
}
|
|
81243
|
+
try {
|
|
81244
|
+
if (opened.stat.size > MAX_PHASE_RESULT_BYTES)
|
|
81245
|
+
return;
|
|
81246
|
+
const chunks = [];
|
|
81247
|
+
let offset = 0;
|
|
81248
|
+
while (offset <= MAX_PHASE_RESULT_BYTES) {
|
|
81249
|
+
const buffer = Buffer.alloc(Math.min(64 * 1024, MAX_PHASE_RESULT_BYTES + 1 - offset));
|
|
81250
|
+
const bytesRead = fs81.readSync(opened.fd, buffer, 0, buffer.length, offset);
|
|
81251
|
+
if (bytesRead === 0) {
|
|
81252
|
+
return JSON.parse(Buffer.concat(chunks, offset).toString("utf8"));
|
|
81253
|
+
}
|
|
81254
|
+
chunks.push(buffer.subarray(0, bytesRead));
|
|
81255
|
+
offset += bytesRead;
|
|
81256
|
+
}
|
|
81257
|
+
return;
|
|
81258
|
+
} catch {
|
|
81259
|
+
return;
|
|
81260
|
+
} finally {
|
|
81261
|
+
fs81.closeSync(opened.fd);
|
|
81262
|
+
}
|
|
81263
|
+
}
|
|
81168
81264
|
function rawIdentity(value) {
|
|
81169
81265
|
if (!value || typeof value !== "object") {
|
|
81170
81266
|
return { phase: "unknown", attemptId: null, phaseId: null };
|
|
@@ -81237,13 +81333,9 @@ function prepareBenchmarkPhaseInvocation(specPathInput, resultPathInput, expecte
|
|
|
81237
81333
|
timeout_ms: spec.budget.timeout_ms
|
|
81238
81334
|
};
|
|
81239
81335
|
let cachedResult;
|
|
81240
|
-
|
|
81241
|
-
|
|
81242
|
-
|
|
81243
|
-
if (cached2.schema_version === SCHEMA_VERSION && cached2.phase === spec.phase && cached2.attempt_id === spec.attempt_id && cached2.phase_id === spec.phase_id && cached2.spec_digest === digest && cached2.status === "succeeded") {
|
|
81244
|
-
cachedResult = cached2;
|
|
81245
|
-
}
|
|
81246
|
-
} catch {}
|
|
81336
|
+
const cached2 = readCachedPhaseResult(resultPath);
|
|
81337
|
+
if (cached2?.schema_version === SCHEMA_VERSION && cached2.phase === spec.phase && cached2.attempt_id === spec.attempt_id && cached2.phase_id === spec.phase_id && cached2.spec_digest === digest && cached2.status === "succeeded") {
|
|
81338
|
+
cachedResult = cached2;
|
|
81247
81339
|
}
|
|
81248
81340
|
if (cachedResult) {
|
|
81249
81341
|
if (spec.phase === "hydrate") {
|
|
@@ -81260,7 +81352,7 @@ function prepareBenchmarkPhaseInvocation(specPathInput, resultPathInput, expecte
|
|
|
81260
81352
|
} catch (error2) {
|
|
81261
81353
|
return {
|
|
81262
81354
|
ok: false,
|
|
81263
|
-
result: {
|
|
81355
|
+
result: compactOversizedResult({
|
|
81264
81356
|
schema_version: SCHEMA_VERSION,
|
|
81265
81357
|
cli_version: VERSION,
|
|
81266
81358
|
phase: identity2.phase === "unknown" ? expectedPhase : identity2.phase,
|
|
@@ -81275,7 +81367,7 @@ function prepareBenchmarkPhaseInvocation(specPathInput, resultPathInput, expecte
|
|
|
81275
81367
|
inputs: [],
|
|
81276
81368
|
outputs: [],
|
|
81277
81369
|
error: stableError(error2)
|
|
81278
|
-
}
|
|
81370
|
+
})
|
|
81279
81371
|
};
|
|
81280
81372
|
}
|
|
81281
81373
|
}
|
|
@@ -81355,13 +81447,9 @@ async function runBenchmarkPhase(specPathInput, resultPathInput, expectedPhase,
|
|
|
81355
81447
|
}
|
|
81356
81448
|
resultPathValidated = true;
|
|
81357
81449
|
let cachedResult;
|
|
81358
|
-
|
|
81359
|
-
|
|
81360
|
-
|
|
81361
|
-
if (cached2.schema_version === SCHEMA_VERSION && cached2.phase === spec.phase && cached2.attempt_id === spec.attempt_id && cached2.phase_id === spec.phase_id && cached2.spec_digest === digest && cached2.status === "succeeded") {
|
|
81362
|
-
cachedResult = cached2;
|
|
81363
|
-
}
|
|
81364
|
-
} catch {}
|
|
81450
|
+
const cached2 = readCachedPhaseResult(resultPath);
|
|
81451
|
+
if (cached2?.schema_version === SCHEMA_VERSION && cached2.phase === spec.phase && cached2.attempt_id === spec.attempt_id && cached2.phase_id === spec.phase_id && cached2.spec_digest === digest && cached2.status === "succeeded") {
|
|
81452
|
+
cachedResult = cached2;
|
|
81365
81453
|
}
|
|
81366
81454
|
if (cachedResult) {
|
|
81367
81455
|
if (spec.phase === "hydrate") {
|
|
@@ -81404,7 +81492,7 @@ async function runBenchmarkPhase(specPathInput, resultPathInput, expectedPhase,
|
|
|
81404
81492
|
fs81.rmSync(temporary, { recursive: true, force: true });
|
|
81405
81493
|
}
|
|
81406
81494
|
}
|
|
81407
|
-
|
|
81495
|
+
let result2 = {
|
|
81408
81496
|
schema_version: SCHEMA_VERSION,
|
|
81409
81497
|
cli_version: VERSION,
|
|
81410
81498
|
phase: identity2.phase === "unknown" && expectedPhase ? expectedPhase : identity2.phase,
|
|
@@ -81422,6 +81510,7 @@ async function runBenchmarkPhase(specPathInput, resultPathInput, expectedPhase,
|
|
|
81422
81510
|
...error2 ? { error: error2 } : {}
|
|
81423
81511
|
};
|
|
81424
81512
|
if (!resultPathValidated || !context?.logsOwned) {
|
|
81513
|
+
result2 = compactOversizedResult(result2);
|
|
81425
81514
|
return { exitCode: status === "succeeded" ? 0 : 1, result: result2 };
|
|
81426
81515
|
}
|
|
81427
81516
|
if (status === "succeeded" && validatedSpec?.phase === "evaluate") {
|
|
@@ -81435,6 +81524,8 @@ async function runBenchmarkPhase(specPathInput, resultPathInput, expectedPhase,
|
|
|
81435
81524
|
result2.error = stableError(budgetError);
|
|
81436
81525
|
}
|
|
81437
81526
|
}
|
|
81527
|
+
result2 = compactOversizedResult(result2);
|
|
81528
|
+
status = result2.status;
|
|
81438
81529
|
try {
|
|
81439
81530
|
writeJsonAtomic(resultPath, result2);
|
|
81440
81531
|
} catch (writeError) {
|