@fetchbrain.com/sdk 0.12.0 → 0.12.2

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.mjs CHANGED
@@ -768,10 +768,14 @@ var FetchBrainClient = class {
768
768
  query: question,
769
769
  answer: opts?.answer,
770
770
  limit: opts?.limit,
771
- model: opts?.model
771
+ model: opts?.model,
772
+ memory: opts?.memory,
773
+ versions: opts?.versions
772
774
  };
773
775
  const platformBuildId = getPlatformBuildId();
774
- if (this.config.refreshOnRebuild && platformBuildId) {
776
+ if (opts?.build !== void 0) {
777
+ askBody.build = opts.build;
778
+ } else if (this.config.refreshOnRebuild && platformBuildId) {
775
779
  askBody.build = platformBuildId;
776
780
  }
777
781
  try {
@@ -1182,7 +1186,7 @@ var FetchBrainClient = class {
1182
1186
  // src/enhance.ts
1183
1187
  var collectorModule;
1184
1188
  function loadCollector() {
1185
- return collectorModule ?? (collectorModule = import('./collector-3OZRBCM4.mjs').catch(() => {
1189
+ return collectorModule ?? (collectorModule = import('./collector-DEELPRDD.mjs').catch(() => {
1186
1190
  collectorModule = void 0;
1187
1191
  return void 0;
1188
1192
  }));
@@ -1227,7 +1231,7 @@ function nextRunId() {
1227
1231
  return n === 1 ? id : `${id}-${n}`;
1228
1232
  }
1229
1233
  function labelText(label) {
1230
- if (typeof label === "string") return label.replace(/^[\s~]+/, "");
1234
+ if (typeof label === "string") return label;
1231
1235
  if (typeof label === "number" || typeof label === "boolean") return String(label);
1232
1236
  return void 0;
1233
1237
  }
@@ -1235,6 +1239,12 @@ function reportLabel(label) {
1235
1239
  const trimmed = (labelText(label) ?? "").trim().slice(0, REPORT_LABEL_MAX_CHARS);
1236
1240
  return trimmed || NO_LABEL;
1237
1241
  }
1242
+ function analyticsLabelText(label) {
1243
+ return (labelText(label) ?? "").replace(/^[\s~]+/, "").trim().slice(0, REPORT_LABEL_MAX_CHARS);
1244
+ }
1245
+ function analyticsLabel(label) {
1246
+ return analyticsLabelText(label) || NO_LABEL;
1247
+ }
1238
1248
  var pct = (rate) => `${Math.round(rate * 100)}%`;
1239
1249
  function describeDrift(d) {
1240
1250
  const detail = d.kind === "type_changed" ? `type ${clipText(d.from, 32)} \u2192 ${clipText(d.to, 32)}` : `filled ${pct(Number(d.from))} \u2192 ${pct(Number(d.to))}`;
@@ -1347,8 +1357,7 @@ function childLabelOf(r) {
1347
1357
  if (!r || typeof r !== "object") return DEFAULT_CHILD_LABEL;
1348
1358
  try {
1349
1359
  const o = r;
1350
- const text = labelText(o.label ?? o.userData?.label)?.trim().slice(0, REPORT_LABEL_MAX_CHARS);
1351
- return text || DEFAULT_CHILD_LABEL;
1360
+ return analyticsLabelText(o.label ?? o.userData?.label) || DEFAULT_CHILD_LABEL;
1352
1361
  } catch {
1353
1362
  return DEFAULT_CHILD_LABEL;
1354
1363
  }
@@ -1542,7 +1551,7 @@ var FetchBrain = class {
1542
1551
  const blockedAttempts = blockedByRequest.get(key) ?? 0;
1543
1552
  if (blockedAttempts) blockedByRequest.delete(key);
1544
1553
  c.request({
1545
- label: reportLabel(request.label),
1554
+ label: analyticsLabel(request.label),
1546
1555
  outcome,
1547
1556
  retries: typeof request.retryCount === "number" ? request.retryCount : 0,
1548
1557
  url: request.url,
@@ -1776,7 +1785,7 @@ var FetchBrain = class {
1776
1785
  const url = request.url;
1777
1786
  const label = request.label;
1778
1787
  runStats.totalRequests++;
1779
- const aLabel = collector ? reportLabel(label) : NO_LABEL;
1788
+ const aLabel = collector ? analyticsLabel(label) : NO_LABEL;
1780
1789
  if (skipLabels && skipLabels.has(label || "default")) {
1781
1790
  runStats.bypassed++;
1782
1791
  if (config.debug) {
@@ -2055,7 +2064,7 @@ var FetchBrain = class {
2055
2064
  const ctx = args[0];
2056
2065
  const { a, blockType } = noteFailure(c, ctx, args[1]);
2057
2066
  const req = ctx.request;
2058
- c.error(reportLabel(req.label), args[1], contextFor(c, a, req));
2067
+ c.error(analyticsLabel(req.label), args[1], contextFor(c, a, req));
2059
2068
  emitRequest(c, ctx, a, blockType ? "blocked" : "failed", blockType);
2060
2069
  } catch (analyticsErr) {
2061
2070
  logger.debug(`Analytics skipped: ${analyticsErr}`);