@bitfab/sdk 0.64.30 → 0.65.1

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.
Files changed (97) hide show
  1. package/dist/autoTrace.cjs +28 -0
  2. package/dist/autoTrace.cjs.map +1 -1
  3. package/dist/autoTrace.d.cts +2 -1
  4. package/dist/autoTrace.d.ts +2 -1
  5. package/dist/autoTrace.js +3 -1
  6. package/dist/{chunk-BTCJ5XGH.js → chunk-4O5APMS4.js} +65 -21
  7. package/dist/chunk-4O5APMS4.js.map +1 -0
  8. package/dist/{chunk-5H2UZ2LR.js → chunk-4RU4RZSM.js} +2 -2
  9. package/dist/chunk-4RU4RZSM.js.map +1 -0
  10. package/dist/{chunk-N3CG4AHU.js → chunk-7OR34NXC.js} +2 -2
  11. package/dist/{chunk-GSHCHCB5.js → chunk-LXBV37XY.js} +2 -39
  12. package/dist/chunk-LXBV37XY.js.map +1 -0
  13. package/dist/{chunk-IBWW3SP4.js → chunk-P7JUVRYZ.js} +2 -2
  14. package/dist/{chunk-YWXQM6J3.js → chunk-QRNHRY7F.js} +28 -1
  15. package/dist/chunk-QRNHRY7F.js.map +1 -0
  16. package/dist/{chunk-PIMCRSR2.js → chunk-S2EYDTUH.js} +2 -2
  17. package/dist/{chunk-DARYURT3.js → chunk-SXNYSDXU.js} +2 -2
  18. package/dist/chunk-SXNYSDXU.js.map +1 -0
  19. package/dist/{chunk-MN3E2RUU.js → chunk-VS36LW4L.js} +3 -3
  20. package/dist/{chunk-GLBBZLG2.js → chunk-VYIIDV2D.js} +4 -4
  21. package/dist/chunk-VYIIDV2D.js.map +1 -0
  22. package/dist/{http-JI7TADRE.js → http-2R2LUIGH.js} +2 -2
  23. package/dist/{http-5HVQJKA7.js → http-NWJPWZF5.js} +2 -2
  24. package/dist/index.cjs +74 -15
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +76 -43
  27. package/dist/index.d.ts +76 -43
  28. package/dist/index.js +6 -4
  29. package/dist/node.cjs +74 -15
  30. package/dist/node.cjs.map +1 -1
  31. package/dist/node.d.cts +1 -1
  32. package/dist/node.d.ts +1 -1
  33. package/dist/node.js +6 -4
  34. package/dist/node.js.map +1 -1
  35. package/dist/{replay-FRGREQBV.js → replay-3GJHADDC.js} +3 -3
  36. package/dist/{replay-WL7ZJP3A.js → replay-Z5ND6EVB.js} +3 -3
  37. package/dist/replayCli.js +3 -3
  38. package/dist/seedCli.js +3 -3
  39. package/dist/transform/babel.cjs +1 -38
  40. package/dist/transform/babel.cjs.map +1 -1
  41. package/dist/transform/babel.js +1 -1
  42. package/dist/transform/bun.cjs +1 -38
  43. package/dist/transform/bun.cjs.map +1 -1
  44. package/dist/transform/bun.js +3 -3
  45. package/dist/transform/esbuild.cjs +1 -38
  46. package/dist/transform/esbuild.cjs.map +1 -1
  47. package/dist/transform/esbuild.js +3 -3
  48. package/dist/transform/loaderRuntime.cjs +1 -38
  49. package/dist/transform/loaderRuntime.cjs.map +1 -1
  50. package/dist/transform/loaderRuntime.js +2 -2
  51. package/dist/transform/nest.cjs +1 -38
  52. package/dist/transform/nest.cjs.map +1 -1
  53. package/dist/transform/nest.js +3 -3
  54. package/dist/transform/next.cjs +1 -38
  55. package/dist/transform/next.cjs.map +1 -1
  56. package/dist/transform/next.js +3 -3
  57. package/dist/transform/nodeLoader.js +1 -38
  58. package/dist/transform/nodeLoader.js.map +1 -1
  59. package/dist/transform/rolldown.cjs +1 -38
  60. package/dist/transform/rolldown.cjs.map +1 -1
  61. package/dist/transform/rolldown.js +3 -3
  62. package/dist/transform/rollup.cjs +1 -38
  63. package/dist/transform/rollup.cjs.map +1 -1
  64. package/dist/transform/rollup.js +3 -3
  65. package/dist/transform/rsbuild.cjs +1 -38
  66. package/dist/transform/rsbuild.cjs.map +1 -1
  67. package/dist/transform/rsbuild.js +3 -3
  68. package/dist/transform/rspack.cjs +1 -38
  69. package/dist/transform/rspack.cjs.map +1 -1
  70. package/dist/transform/rspack.js +3 -3
  71. package/dist/transform/swc.cjs +1 -38
  72. package/dist/transform/swc.cjs.map +1 -1
  73. package/dist/transform/swc.js +2 -2
  74. package/dist/transform/unplugin.cjs +1 -38
  75. package/dist/transform/unplugin.cjs.map +1 -1
  76. package/dist/transform/unplugin.js +3 -3
  77. package/dist/transform/vite.cjs +1 -38
  78. package/dist/transform/vite.cjs.map +1 -1
  79. package/dist/transform/vite.js +3 -3
  80. package/dist/transform/webpack.cjs +1 -38
  81. package/dist/transform/webpack.cjs.map +1 -1
  82. package/dist/transform/webpack.js +3 -3
  83. package/package.json +1 -1
  84. package/dist/chunk-5H2UZ2LR.js.map +0 -1
  85. package/dist/chunk-BTCJ5XGH.js.map +0 -1
  86. package/dist/chunk-DARYURT3.js.map +0 -1
  87. package/dist/chunk-GLBBZLG2.js.map +0 -1
  88. package/dist/chunk-GSHCHCB5.js.map +0 -1
  89. package/dist/chunk-YWXQM6J3.js.map +0 -1
  90. /package/dist/{chunk-N3CG4AHU.js.map → chunk-7OR34NXC.js.map} +0 -0
  91. /package/dist/{chunk-IBWW3SP4.js.map → chunk-P7JUVRYZ.js.map} +0 -0
  92. /package/dist/{chunk-PIMCRSR2.js.map → chunk-S2EYDTUH.js.map} +0 -0
  93. /package/dist/{chunk-MN3E2RUU.js.map → chunk-VS36LW4L.js.map} +0 -0
  94. /package/dist/{http-5HVQJKA7.js.map → http-2R2LUIGH.js.map} +0 -0
  95. /package/dist/{http-JI7TADRE.js.map → http-NWJPWZF5.js.map} +0 -0
  96. /package/dist/{replay-FRGREQBV.js.map → replay-3GJHADDC.js.map} +0 -0
  97. /package/dist/{replay-WL7ZJP3A.js.map → replay-Z5ND6EVB.js.map} +0 -0
@@ -8,7 +8,7 @@ import {
8
8
  flushTraces,
9
9
  parseRetryAfterMs,
10
10
  serializePayloadBody
11
- } from "./chunk-5H2UZ2LR.js";
11
+ } from "./chunk-4RU4RZSM.js";
12
12
  export {
13
13
  BitfabError,
14
14
  HttpClient,
@@ -20,4 +20,4 @@ export {
20
20
  parseRetryAfterMs,
21
21
  serializePayloadBody
22
22
  };
23
- //# sourceMappingURL=http-JI7TADRE.js.map
23
+ //# sourceMappingURL=http-2R2LUIGH.js.map
@@ -8,7 +8,7 @@ import {
8
8
  flushTraces,
9
9
  parseRetryAfterMs,
10
10
  serializePayloadBody
11
- } from "./chunk-DARYURT3.js";
11
+ } from "./chunk-SXNYSDXU.js";
12
12
  import "./chunk-MT36GJMW.js";
13
13
  export {
14
14
  BitfabError,
@@ -21,4 +21,4 @@ export {
21
21
  parseRetryAfterMs,
22
22
  serializePayloadBody
23
23
  };
24
- //# sourceMappingURL=http-5HVQJKA7.js.map
24
+ //# sourceMappingURL=http-NWJPWZF5.js.map
package/dist/index.cjs CHANGED
@@ -42,7 +42,7 @@ var __version__, __packageName__;
42
42
  var init_version_generated = __esm({
43
43
  "src/version.generated.ts"() {
44
44
  "use strict";
45
- __version__ = "0.64.30";
45
+ __version__ = "0.65.1";
46
46
  __packageName__ = "@bitfab/sdk";
47
47
  }
48
48
  });
@@ -5367,6 +5367,7 @@ __export(index_exports, {
5367
5367
  BitfabOpenAITracingProcessor: () => BitfabOpenAITracingProcessor,
5368
5368
  BitfabRivetIntegration: () => BitfabRivetIntegration,
5369
5369
  BitfabVercelAiHandler: () => BitfabVercelAiHandler,
5370
+ CategoriesClient: () => CategoriesClient,
5370
5371
  DEFAULT_SERVICE_URL: () => DEFAULT_SERVICE_URL,
5371
5372
  DatasetsClient: () => DatasetsClient,
5372
5373
  DbBranchReplayError: () => DbBranchReplayError,
@@ -5397,9 +5398,9 @@ __export(index_exports, {
5397
5398
  });
5398
5399
  module.exports = __toCommonJS(index_exports);
5399
5400
 
5400
- // src/assertionCategories.ts
5401
- var CATEGORIES_PATH = "/api/sdk/assertionCategories";
5402
- var AssertionCategoriesClient = class {
5401
+ // src/categories.ts
5402
+ var CATEGORIES_PATH = "/api/sdk/categories";
5403
+ var CategoriesClient = class {
5403
5404
  constructor(httpClient) {
5404
5405
  this.httpClient = httpClient;
5405
5406
  }
@@ -5426,6 +5427,7 @@ var AssertionCategoriesClient = class {
5426
5427
  return response.category;
5427
5428
  }
5428
5429
  };
5430
+ var AssertionCategoriesClient = CategoriesClient;
5429
5431
 
5430
5432
  // src/claudeAgentSdk.ts
5431
5433
  init_constants();
@@ -6134,6 +6136,21 @@ function runWithAutoTraceNodeConfiguration(nodeConfiguration, fn) {
6134
6136
  }
6135
6137
  return result;
6136
6138
  }
6139
+ function runAsAutoTraceRootFunction(functionName, fn) {
6140
+ const scope = currentAutoTraceScope();
6141
+ if (!scope || scope.entries.length === 0 || functionName === "") {
6142
+ return fn();
6143
+ }
6144
+ const rootFunction = {
6145
+ name: functionName,
6146
+ entering: true
6147
+ };
6148
+ try {
6149
+ return runWithAutoTraceScope({ ...scope, rootFunction }, fn);
6150
+ } finally {
6151
+ rootFunction.entering = false;
6152
+ }
6153
+ }
6137
6154
  var SUBTREE_TRACING_DOCS_URL = "https://docs.bitfab.ai/typescript-sdk#experimental-subtree-tracing";
6138
6155
  function transformInstalled() {
6139
6156
  return autoTraceGlobal.__bitfab_auto_trace_transformed_v1__ === true;
@@ -9025,6 +9042,27 @@ function draftsInGenerationOrder(assertions, assertionIds) {
9025
9042
  return assertion === void 0 ? [] : [assertion];
9026
9043
  });
9027
9044
  }
9045
+ function withCategoryId(assertion) {
9046
+ const categoryId = assertion.category_id ?? assertion.category_assertion_id ?? null;
9047
+ return {
9048
+ ...assertion,
9049
+ category_id: categoryId,
9050
+ category_assertion_id: categoryId
9051
+ };
9052
+ }
9053
+ function withCategoryIds(assertions) {
9054
+ return assertions.map(withCategoryId);
9055
+ }
9056
+ function toWireAssertion({
9057
+ category_assertion_id,
9058
+ ...assertion
9059
+ }) {
9060
+ const categoryId = assertion.category_id === void 0 ? category_assertion_id : assertion.category_id;
9061
+ if (categoryId === void 0) {
9062
+ return assertion;
9063
+ }
9064
+ return { ...assertion, category_id: categoryId };
9065
+ }
9028
9066
  function traceAssertionsPath(traceId, suffix = "") {
9029
9067
  return `/api/sdk/traces/${encodeURIComponent(traceId)}/assertions${suffix}`;
9030
9068
  }
@@ -9039,9 +9077,10 @@ var TracesClient = class {
9039
9077
  return this.httpClient.request(SEARCH_PATH, params);
9040
9078
  }
9041
9079
  async getAssertions(traceId) {
9042
- return this.httpClient.get(
9080
+ const result = await this.httpClient.get(
9043
9081
  traceAssertionsPath(traceId)
9044
9082
  );
9083
+ return { ...result, assertions: withCategoryIds(result.assertions) };
9045
9084
  }
9046
9085
  async saveAssertions(params) {
9047
9086
  return this.saveAssertionsAll({
@@ -9054,10 +9093,13 @@ var TracesClient = class {
9054
9093
  return [];
9055
9094
  }
9056
9095
  const response = await this.httpClient.request(ASSERTIONS_PATH, {
9057
- updates: params.updates,
9096
+ updates: params.updates.map((update) => ({
9097
+ ...update,
9098
+ assertions: update.assertions.map(toWireAssertion)
9099
+ })),
9058
9100
  source: params.source ?? "agent"
9059
9101
  });
9060
- return response.assertions;
9102
+ return withCategoryIds(response.assertions);
9061
9103
  }
9062
9104
  async generateAssertions(traceId, options = {}) {
9063
9105
  const started = await this.httpClient.request(
@@ -9069,7 +9111,7 @@ var TracesClient = class {
9069
9111
  }
9070
9112
  );
9071
9113
  if (isGenerationFinished(traceId, started.generation)) {
9072
- return started.assertions;
9114
+ return withCategoryIds(started.assertions);
9073
9115
  }
9074
9116
  const timeoutMs = options.timeoutMs ?? DEFAULT_GENERATION_TIMEOUT_MS;
9075
9117
  const deadline = Date.now() + timeoutMs;
@@ -10017,6 +10059,11 @@ function readBooleanEnv(name) {
10017
10059
  );
10018
10060
  return void 0;
10019
10061
  }
10062
+ var AUTO_TRACE_NODE_FUNCTION_NAMES = /* @__PURE__ */ new WeakMap();
10063
+ function registerAutoTraceNode(configured, functionName) {
10064
+ AUTO_TRACE_NODE_FUNCTION_NAMES.set(configured, functionName);
10065
+ return configured;
10066
+ }
10020
10067
  var DEFAULT_AUTO_TRACE_MAX_DEPTH = 30;
10021
10068
  var DEFAULT_AUTO_TRACE_MAX_CAPTURED_SUBTREE_SPANS = 500;
10022
10069
  function spanOwnerName(receiver) {
@@ -10092,7 +10139,8 @@ var Bitfab = class {
10092
10139
  this.simulationPlan.refresh();
10093
10140
  }
10094
10141
  this.datasets = new DatasetsClient(this.httpClient);
10095
- this.assertionCategories = new AssertionCategoriesClient(this.httpClient);
10142
+ this.categories = new CategoriesClient(this.httpClient);
10143
+ this.assertionCategories = this.categories;
10096
10144
  this.organizationMembers = new OrganizationMembersClient(this.httpClient);
10097
10145
  this.traces = new TracesClient(this.httpClient);
10098
10146
  this.spans = new SpansClient(this.httpClient);
@@ -10151,7 +10199,13 @@ var Bitfab = class {
10151
10199
  throw new BitfabError("bitfab.withTrace requires a function");
10152
10200
  }
10153
10201
  const name = fn.name !== "" ? fn.name : traceFunctionKey;
10154
- return this.createAutoTraceRoot(traceFunctionKey, name, options, fn);
10202
+ return this.createAutoTraceRoot(
10203
+ traceFunctionKey,
10204
+ name,
10205
+ options,
10206
+ fn,
10207
+ AUTO_TRACE_NODE_FUNCTION_NAMES.get(fn) ?? fn.name.replace(/^bound /, "")
10208
+ );
10155
10209
  }
10156
10210
  /**
10157
10211
  * Configure a transformed class method when it is discovered beneath a
@@ -10232,7 +10286,7 @@ var Bitfab = class {
10232
10286
  }
10233
10287
  createAutoTraceNode(configuration, fn, functionName) {
10234
10288
  const nodeConfiguration = { ...configuration, functionName };
10235
- return function(...args) {
10289
+ return registerAutoTraceNode(function(...args) {
10236
10290
  if (!__bitfabAutoTraceActive()) {
10237
10291
  if (enclosingSurface() === "opt-in") {
10238
10292
  throw mixedTracingError("node()", "opt-out", "opt-in");
@@ -10243,11 +10297,15 @@ var Bitfab = class {
10243
10297
  nodeConfiguration,
10244
10298
  () => fn.apply(this, args)
10245
10299
  );
10246
- };
10300
+ }, functionName);
10247
10301
  }
10248
- createAutoTraceRoot(traceFunctionKey, name, options, fn) {
10302
+ createAutoTraceRoot(traceFunctionKey, name, options, fn, rootFunctionName = "") {
10249
10303
  const self = this;
10250
10304
  self.simulationPlan.refresh();
10305
+ const runRootFunction = (receiver, args) => runAsAutoTraceRootFunction(
10306
+ rootFunctionName,
10307
+ () => fn.apply(receiver, args)
10308
+ );
10251
10309
  const maxDepth = autoTraceLimit(
10252
10310
  options.maxDepth,
10253
10311
  DEFAULT_AUTO_TRACE_MAX_DEPTH
@@ -10410,7 +10468,7 @@ var Bitfab = class {
10410
10468
  return runWithAutoTraceRootContext(
10411
10469
  autoTraceContext,
10412
10470
  getSpanStack(),
10413
- () => fn.apply(this, args)
10471
+ () => runRootFunction(this, args)
10414
10472
  );
10415
10473
  }
10416
10474
  );
@@ -10443,7 +10501,7 @@ var Bitfab = class {
10443
10501
  ),
10444
10502
  () => {
10445
10503
  if (link === void 0) {
10446
- return fn.apply(this, args);
10504
+ return runRootFunction(this, args);
10447
10505
  }
10448
10506
  const innermost = enclosing[enclosing.length - 1];
10449
10507
  const innermostNow = currentAutoTraceEntries().find(
@@ -12411,6 +12469,7 @@ function resolveTraceFunctionKey(registration) {
12411
12469
  BitfabOpenAITracingProcessor,
12412
12470
  BitfabRivetIntegration,
12413
12471
  BitfabVercelAiHandler,
12472
+ CategoriesClient,
12414
12473
  DEFAULT_SERVICE_URL,
12415
12474
  DatasetsClient,
12416
12475
  DbBranchReplayError,