@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
package/dist/node.cjs CHANGED
@@ -88,7 +88,7 @@ var __version__, __packageName__;
88
88
  var init_version_generated = __esm({
89
89
  "src/version.generated.ts"() {
90
90
  "use strict";
91
- __version__ = "0.64.30";
91
+ __version__ = "0.65.1";
92
92
  __packageName__ = "@bitfab/sdk";
93
93
  }
94
94
  });
@@ -5374,6 +5374,7 @@ __export(node_exports, {
5374
5374
  BitfabOpenAITracingProcessor: () => BitfabOpenAITracingProcessor,
5375
5375
  BitfabRivetIntegration: () => BitfabRivetIntegration,
5376
5376
  BitfabVercelAiHandler: () => BitfabVercelAiHandler,
5377
+ CategoriesClient: () => CategoriesClient,
5377
5378
  DEFAULT_SERVICE_URL: () => DEFAULT_SERVICE_URL,
5378
5379
  DatasetsClient: () => DatasetsClient,
5379
5380
  DbBranchReplayError: () => DbBranchReplayError,
@@ -5411,9 +5412,9 @@ registerAsyncLocalStorageClass(
5411
5412
  import_node_async_hooks.AsyncLocalStorage
5412
5413
  );
5413
5414
 
5414
- // src/assertionCategories.ts
5415
- var CATEGORIES_PATH = "/api/sdk/assertionCategories";
5416
- var AssertionCategoriesClient = class {
5415
+ // src/categories.ts
5416
+ var CATEGORIES_PATH = "/api/sdk/categories";
5417
+ var CategoriesClient = class {
5417
5418
  constructor(httpClient) {
5418
5419
  this.httpClient = httpClient;
5419
5420
  }
@@ -5440,6 +5441,7 @@ var AssertionCategoriesClient = class {
5440
5441
  return response.category;
5441
5442
  }
5442
5443
  };
5444
+ var AssertionCategoriesClient = CategoriesClient;
5443
5445
 
5444
5446
  // src/claudeAgentSdk.ts
5445
5447
  init_constants();
@@ -6148,6 +6150,21 @@ function runWithAutoTraceNodeConfiguration(nodeConfiguration, fn) {
6148
6150
  }
6149
6151
  return result;
6150
6152
  }
6153
+ function runAsAutoTraceRootFunction(functionName, fn) {
6154
+ const scope = currentAutoTraceScope();
6155
+ if (!scope || scope.entries.length === 0 || functionName === "") {
6156
+ return fn();
6157
+ }
6158
+ const rootFunction = {
6159
+ name: functionName,
6160
+ entering: true
6161
+ };
6162
+ try {
6163
+ return runWithAutoTraceScope({ ...scope, rootFunction }, fn);
6164
+ } finally {
6165
+ rootFunction.entering = false;
6166
+ }
6167
+ }
6151
6168
  var SUBTREE_TRACING_DOCS_URL = "https://docs.bitfab.ai/typescript-sdk#experimental-subtree-tracing";
6152
6169
  function transformInstalled() {
6153
6170
  return autoTraceGlobal.__bitfab_auto_trace_transformed_v1__ === true;
@@ -9039,6 +9056,27 @@ function draftsInGenerationOrder(assertions, assertionIds) {
9039
9056
  return assertion === void 0 ? [] : [assertion];
9040
9057
  });
9041
9058
  }
9059
+ function withCategoryId(assertion) {
9060
+ const categoryId = assertion.category_id ?? assertion.category_assertion_id ?? null;
9061
+ return {
9062
+ ...assertion,
9063
+ category_id: categoryId,
9064
+ category_assertion_id: categoryId
9065
+ };
9066
+ }
9067
+ function withCategoryIds(assertions) {
9068
+ return assertions.map(withCategoryId);
9069
+ }
9070
+ function toWireAssertion({
9071
+ category_assertion_id,
9072
+ ...assertion
9073
+ }) {
9074
+ const categoryId = assertion.category_id === void 0 ? category_assertion_id : assertion.category_id;
9075
+ if (categoryId === void 0) {
9076
+ return assertion;
9077
+ }
9078
+ return { ...assertion, category_id: categoryId };
9079
+ }
9042
9080
  function traceAssertionsPath(traceId, suffix = "") {
9043
9081
  return `/api/sdk/traces/${encodeURIComponent(traceId)}/assertions${suffix}`;
9044
9082
  }
@@ -9053,9 +9091,10 @@ var TracesClient = class {
9053
9091
  return this.httpClient.request(SEARCH_PATH, params);
9054
9092
  }
9055
9093
  async getAssertions(traceId) {
9056
- return this.httpClient.get(
9094
+ const result = await this.httpClient.get(
9057
9095
  traceAssertionsPath(traceId)
9058
9096
  );
9097
+ return { ...result, assertions: withCategoryIds(result.assertions) };
9059
9098
  }
9060
9099
  async saveAssertions(params) {
9061
9100
  return this.saveAssertionsAll({
@@ -9068,10 +9107,13 @@ var TracesClient = class {
9068
9107
  return [];
9069
9108
  }
9070
9109
  const response = await this.httpClient.request(ASSERTIONS_PATH, {
9071
- updates: params.updates,
9110
+ updates: params.updates.map((update) => ({
9111
+ ...update,
9112
+ assertions: update.assertions.map(toWireAssertion)
9113
+ })),
9072
9114
  source: params.source ?? "agent"
9073
9115
  });
9074
- return response.assertions;
9116
+ return withCategoryIds(response.assertions);
9075
9117
  }
9076
9118
  async generateAssertions(traceId, options = {}) {
9077
9119
  const started = await this.httpClient.request(
@@ -9083,7 +9125,7 @@ var TracesClient = class {
9083
9125
  }
9084
9126
  );
9085
9127
  if (isGenerationFinished(traceId, started.generation)) {
9086
- return started.assertions;
9128
+ return withCategoryIds(started.assertions);
9087
9129
  }
9088
9130
  const timeoutMs = options.timeoutMs ?? DEFAULT_GENERATION_TIMEOUT_MS;
9089
9131
  const deadline = Date.now() + timeoutMs;
@@ -10031,6 +10073,11 @@ function readBooleanEnv(name) {
10031
10073
  );
10032
10074
  return void 0;
10033
10075
  }
10076
+ var AUTO_TRACE_NODE_FUNCTION_NAMES = /* @__PURE__ */ new WeakMap();
10077
+ function registerAutoTraceNode(configured, functionName) {
10078
+ AUTO_TRACE_NODE_FUNCTION_NAMES.set(configured, functionName);
10079
+ return configured;
10080
+ }
10034
10081
  var DEFAULT_AUTO_TRACE_MAX_DEPTH = 30;
10035
10082
  var DEFAULT_AUTO_TRACE_MAX_CAPTURED_SUBTREE_SPANS = 500;
10036
10083
  function spanOwnerName(receiver) {
@@ -10106,7 +10153,8 @@ var Bitfab = class {
10106
10153
  this.simulationPlan.refresh();
10107
10154
  }
10108
10155
  this.datasets = new DatasetsClient(this.httpClient);
10109
- this.assertionCategories = new AssertionCategoriesClient(this.httpClient);
10156
+ this.categories = new CategoriesClient(this.httpClient);
10157
+ this.assertionCategories = this.categories;
10110
10158
  this.organizationMembers = new OrganizationMembersClient(this.httpClient);
10111
10159
  this.traces = new TracesClient(this.httpClient);
10112
10160
  this.spans = new SpansClient(this.httpClient);
@@ -10165,7 +10213,13 @@ var Bitfab = class {
10165
10213
  throw new BitfabError("bitfab.withTrace requires a function");
10166
10214
  }
10167
10215
  const name = fn.name !== "" ? fn.name : traceFunctionKey;
10168
- return this.createAutoTraceRoot(traceFunctionKey, name, options, fn);
10216
+ return this.createAutoTraceRoot(
10217
+ traceFunctionKey,
10218
+ name,
10219
+ options,
10220
+ fn,
10221
+ AUTO_TRACE_NODE_FUNCTION_NAMES.get(fn) ?? fn.name.replace(/^bound /, "")
10222
+ );
10169
10223
  }
10170
10224
  /**
10171
10225
  * Configure a transformed class method when it is discovered beneath a
@@ -10246,7 +10300,7 @@ var Bitfab = class {
10246
10300
  }
10247
10301
  createAutoTraceNode(configuration, fn, functionName) {
10248
10302
  const nodeConfiguration = { ...configuration, functionName };
10249
- return function(...args) {
10303
+ return registerAutoTraceNode(function(...args) {
10250
10304
  if (!__bitfabAutoTraceActive()) {
10251
10305
  if (enclosingSurface() === "opt-in") {
10252
10306
  throw mixedTracingError("node()", "opt-out", "opt-in");
@@ -10257,11 +10311,15 @@ var Bitfab = class {
10257
10311
  nodeConfiguration,
10258
10312
  () => fn.apply(this, args)
10259
10313
  );
10260
- };
10314
+ }, functionName);
10261
10315
  }
10262
- createAutoTraceRoot(traceFunctionKey, name, options, fn) {
10316
+ createAutoTraceRoot(traceFunctionKey, name, options, fn, rootFunctionName = "") {
10263
10317
  const self = this;
10264
10318
  self.simulationPlan.refresh();
10319
+ const runRootFunction = (receiver, args) => runAsAutoTraceRootFunction(
10320
+ rootFunctionName,
10321
+ () => fn.apply(receiver, args)
10322
+ );
10265
10323
  const maxDepth = autoTraceLimit(
10266
10324
  options.maxDepth,
10267
10325
  DEFAULT_AUTO_TRACE_MAX_DEPTH
@@ -10424,7 +10482,7 @@ var Bitfab = class {
10424
10482
  return runWithAutoTraceRootContext(
10425
10483
  autoTraceContext,
10426
10484
  getSpanStack(),
10427
- () => fn.apply(this, args)
10485
+ () => runRootFunction(this, args)
10428
10486
  );
10429
10487
  }
10430
10488
  );
@@ -10457,7 +10515,7 @@ var Bitfab = class {
10457
10515
  ),
10458
10516
  () => {
10459
10517
  if (link === void 0) {
10460
- return fn.apply(this, args);
10518
+ return runRootFunction(this, args);
10461
10519
  }
10462
10520
  const innermost = enclosing[enclosing.length - 1];
10463
10521
  const innermostNow = currentAutoTraceEntries().find(
@@ -12429,6 +12487,7 @@ assertAsyncStorageRegistered();
12429
12487
  BitfabOpenAITracingProcessor,
12430
12488
  BitfabRivetIntegration,
12431
12489
  BitfabVercelAiHandler,
12490
+ CategoriesClient,
12432
12491
  DEFAULT_SERVICE_URL,
12433
12492
  DatasetsClient,
12434
12493
  DbBranchReplayError,