@bitfab/sdk 0.74.3 → 0.74.5

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/replayCli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as runRegistryMain, c as runSeedCli, i as runIfEntrypoint, n as parseRegistryCommandArgs, o as checkReplayCliArgs, r as resolveRegistry, s as runReplayCli, t as importRegistry } from "./registryCommand-BQcyBmhN.js";
2
+ import { a as runRegistryMain, c as runSeedCli, i as runIfEntrypoint, n as parseRegistryCommandArgs, o as checkReplayCliArgs, r as resolveRegistry, s as runReplayCli, t as importRegistry } from "./registryCommand-Bm2-Peq8.js";
3
3
  //#region src/cloudReplayCli.ts
4
4
  const CLOUD_REPLAY_HINT = "Add --cloud to run the same replay on GitHub Actions; bitfab-replay --cloud --help explains it.";
5
5
  function isCloudReplayCommand(argv) {
package/dist/seedCli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as runRegistryMain, c as runSeedCli, i as runIfEntrypoint, n as parseRegistryCommandArgs, r as resolveRegistry, t as importRegistry } from "./registryCommand-BQcyBmhN.js";
2
+ import { a as runRegistryMain, c as runSeedCli, i as runIfEntrypoint, n as parseRegistryCommandArgs, r as resolveRegistry, t as importRegistry } from "./registryCommand-Bm2-Peq8.js";
3
3
  //#region src/seedCli.ts
4
4
  const USAGE = "Usage: bitfab-seed --registry <path> <pipeline> --from-trace <id>[,<id>...]\n bitfab-seed --registry <path> <pipeline> --cases <cases.jsonl> [--run]\nRun bitfab-seed --registry <path> <pipeline> --help for details.";
5
5
  async function runSeedCommand(argv, io = {}, importer = importRegistry) {
@@ -1,5 +1,5 @@
1
1
  const require_bamlPeer = require("./bamlPeer-5Ohpq8q9.cjs");
2
- const require_http = require("./http-BHgwaBjv.cjs");
2
+ const require_http = require("./http-DNmzk2gf.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");
@@ -3735,6 +3735,7 @@ const RESUME_CONFLICTING_OPTIONS = [
3735
3735
  "attempts",
3736
3736
  "graderIds",
3737
3737
  "onlyWithAssertions",
3738
+ "categoryIds",
3738
3739
  "dryRun",
3739
3740
  "experimentalSelectiveReplay"
3740
3741
  ];
@@ -3842,6 +3843,7 @@ const REPLAY_OPTION_NAMES = [
3842
3843
  "datasetIds",
3843
3844
  "graderIds",
3844
3845
  "onlyWithAssertions",
3846
+ "categoryIds",
3845
3847
  "skipAssertionJudging",
3846
3848
  "judgeAssertions",
3847
3849
  "adaptInputs",
@@ -4212,6 +4214,10 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4212
4214
  if (options.traceIds.length > 100) throw new require_http.BitfabError(`traceIds supports at most 100 trace IDs per replay (got ${options.traceIds.length}).`);
4213
4215
  }
4214
4216
  const datasetIds = resolveDatasetIds(options);
4217
+ if (options?.categoryIds !== void 0) {
4218
+ if (options.categoryIds.length === 0) throw new require_http.BitfabError("categoryIds must contain at least one category ID.");
4219
+ if (options.traceIds === void 0 && datasetIds === void 0) throw new require_http.BitfabError("categoryIds narrows a trace ID or dataset selection. Pass it with traceIds, datasetId or datasetIds.");
4220
+ }
4215
4221
  if (options?.limit !== void 0 && options?.traceIds !== void 0) try {
4216
4222
  console.warn("Bitfab: limit is ignored when traceIds is passed: the explicit trace ID list already determines how many traces replay.");
4217
4223
  } catch {}
@@ -4223,7 +4229,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
4223
4229
  const includeDbBranchLease = dbBranchEnabled(options?.dbBranch) && options?.dryRun !== true;
4224
4230
  let session;
4225
4231
  if (options?.resume === void 0) {
4226
- 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);
4232
+ 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, options?.categoryIds);
4227
4233
  if (started.items.length === 0) try {
4228
4234
  console.warn(`Bitfab: no traces matched "${traceFunctionKey}", so this replay ran nothing. Capture a trace, or seed one with seedTrace, before replaying.`);
4229
4235
  } catch {}
@@ -4952,6 +4958,7 @@ var SpansClient = class {
4952
4958
  //#region src/traces.ts
4953
4959
  const ASSERTIONS_PATH = "/api/sdk/traces/assertions";
4954
4960
  const SEARCH_PATH = "/api/sdk/traces/search";
4961
+ const CODE_DRAFT_SAVE_TIMEOUT_MS = 3e5;
4955
4962
  const DEFAULT_GENERATION_TIMEOUT_MS = 6e5;
4956
4963
  const GENERATION_POLL_INTERVAL_MS = 2e3;
4957
4964
  var AssertionGenerationError = class extends Error {
@@ -5001,6 +5008,9 @@ function toWireAssertion({ category_assertion_id, ...assertion }) {
5001
5008
  category_id: categoryId
5002
5009
  };
5003
5010
  }
5011
+ function asksBitfabToWriteCode(assertion) {
5012
+ return (assertion.kind === "code" || assertion.kind === "hybrid") && assertion.code === void 0;
5013
+ }
5004
5014
  function traceAssertionsPath(traceId, suffix = "") {
5005
5015
  return `/api/sdk/traces/${encodeURIComponent(traceId)}/assertions${suffix}`;
5006
5016
  }
@@ -5033,14 +5043,15 @@ var TracesClient = class {
5033
5043
  }
5034
5044
  async saveAssertionsAll(params) {
5035
5045
  if (params.updates.length === 0) return [];
5036
- return withCategoryIds((await this.httpClient.request(ASSERTIONS_PATH, {
5046
+ const body = {
5037
5047
  updates: params.updates.map((update) => ({
5038
5048
  ...update,
5039
5049
  assertions: update.assertions.map(toWireAssertion)
5040
5050
  })),
5041
5051
  source: params.source ?? "agent",
5042
5052
  guidedRewrite: params.skipGuidedRewrite !== true
5043
- })).assertions);
5053
+ };
5054
+ return withCategoryIds((params.updates.some((update) => update.assertions.some(asksBitfabToWriteCode)) ? await this.httpClient.request(ASSERTIONS_PATH, body, { timeout: CODE_DRAFT_SAVE_TIMEOUT_MS }) : await this.httpClient.request(ASSERTIONS_PATH, body)).assertions);
5044
5055
  }
5045
5056
  async generateAssertions(traceId, options = {}) {
5046
5057
  const started = await this.httpClient.request(traceAssertionsPath(traceId, "/generate"), {
@@ -7073,7 +7084,7 @@ var Bitfab = class {
7073
7084
  await runWithSeedContext({ traceId }, async () => target(...args));
7074
7085
  } finally {
7075
7086
  try {
7076
- const { flushTraces } = await Promise.resolve().then(() => require("./http-BHgwaBjv.cjs")).then((n) => n.http_exports);
7087
+ const { flushTraces } = await Promise.resolve().then(() => require("./http-DNmzk2gf.cjs")).then((n) => n.http_exports);
7077
7088
  await flushTraces(3e4);
7078
7089
  } finally {
7079
7090
  unrecorded = activeTraceStates.delete(traceId);
@@ -7279,7 +7290,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
7279
7290
  metadata: seedCase.metadata,
7280
7291
  sessionId: seedCase.sessionId
7281
7292
  }));
7282
- const { flushTraces } = await Promise.resolve().then(() => require("./http-BHgwaBjv.cjs")).then((n) => n.http_exports);
7293
+ const { flushTraces } = await Promise.resolve().then(() => require("./http-DNmzk2gf.cjs")).then((n) => n.http_exports);
7283
7294
  await flushTraces(3e4);
7284
7295
  return {
7285
7296
  pipeline,
@@ -7529,4 +7540,4 @@ Object.defineProperty(exports, "serializeReplayResult", {
7529
7540
  }
7530
7541
  });
7531
7542
 
7532
- //# sourceMappingURL=src-KAtu1Cmn.cjs.map
7543
+ //# sourceMappingURL=src-B7Xv4aR2.cjs.map