@resolveio/server-lib 22.3.212 → 22.3.214

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.
@@ -7411,7 +7411,7 @@ function extractAssistantDataIntentCustomerText(message) {
7411
7411
  value = value.replace(/\b(?:last|past|previous|over\s+the\s+last)\s+(?:few|couple|couple\s+of|several)\s+(?:days?|weeks?|months?|years?)\b/gi, ' ');
7412
7412
  value = value.replace(/\b(?:last|past)\s+[0-9]+\s+(?:days?|weeks?|months?)\b/gi, ' ');
7413
7413
  value = value.replace(/\b(?:this|current)\s+(?:week|month|quarter|year)\b/gi, ' ');
7414
- value = value.replace(/\b(?:last|past)\s+(?:week|month|quarter|year)\b/gi, ' ');
7414
+ value = value.replace(/\b(?:last|past|previous|over\s+the\s+last)\s+(?:week|month|quarter|year)\b/gi, ' ');
7415
7415
  value = value.replace(/\byear\s+to\s+date\b/gi, ' ');
7416
7416
  value = value.replace(/\b(how|many|much|number|numbers|count|counts|summarize|summary|show|list|give|pull|find|tell|me|about|of|the|a|an|and|or|with|without|amount|quantity|qty|total|totals|for|to|them|their|we|our|us|right|now|by|what|which|were|was|is|are|has|have|had|been|did|do|does|get|report|all)\b/gi, ' ');
7417
7417
  value = value.replace(/\b(work\s*orders?|wos?|jobs?|invoices?|invoice|invoiced|invoicing|billed|billing|revenue|charged|chemicals?|chemical|sent|shipped|shipment|shipments|delivered|planned|inventory|on\s+hand|stock|ytd|status|state|open|completed|reviewed|closed|monthly|month)\b/gi, ' ');
@@ -7438,6 +7438,69 @@ function removeAssistantLiteralPhrase(value, phrase) {
7438
7438
  }
7439
7439
  return value.replace(new RegExp("\\b".concat(escapeRegexValue(normalizedPhrase).replace(/\s+/g, '\\s+'), "\\b"), 'gi'), ' ');
7440
7440
  }
7441
+ function isAssistantPersonFilterCandidate(candidate) {
7442
+ var terms = __spreadArray(__spreadArray([
7443
+ candidate.id
7444
+ ], __read((candidate.terms || [])), false), __read((candidate.fields || [])), false).map(function (term) { return cleanAssistantRequestedDimensionText(term); })
7445
+ .filter(Boolean);
7446
+ return terms.some(function (term) { return [
7447
+ 'driver',
7448
+ 'drivers',
7449
+ 'user',
7450
+ 'users',
7451
+ 'employee',
7452
+ 'employees',
7453
+ 'person',
7454
+ 'people',
7455
+ 'name',
7456
+ 'id user',
7457
+ 'id_user'
7458
+ ].includes(term); });
7459
+ }
7460
+ function intentHasAssistantPersonFilter(intent) {
7461
+ return buildAssistantAppDataFilterCandidates(intent).some(function (candidate) { return isAssistantPersonFilterCandidate(candidate); });
7462
+ }
7463
+ function extractAssistantLeadingPersonFilterText(message, intent) {
7464
+ var e_5, _a;
7465
+ if (!intentHasAssistantPersonFilter(intent)) {
7466
+ return '';
7467
+ }
7468
+ var text = normalizeOptionalString(message);
7469
+ if (!text) {
7470
+ return '';
7471
+ }
7472
+ var terms = mergeAssistantHintValues(intent.terms || [])
7473
+ .sort(function (a, b) { return b.length - a.length; });
7474
+ try {
7475
+ for (var terms_1 = __values(terms), terms_1_1 = terms_1.next(); !terms_1_1.done; terms_1_1 = terms_1.next()) {
7476
+ var term = terms_1_1.value;
7477
+ var normalizedTerm = normalizeOptionalString(term);
7478
+ if (!normalizedTerm) {
7479
+ continue;
7480
+ }
7481
+ var regex = new RegExp("\\b".concat(escapeRegexValue(normalizedTerm).replace(/\s+/g, '\\s+'), "\\b"), 'i');
7482
+ var match = regex.exec(text);
7483
+ if (!match || match.index <= 0) {
7484
+ continue;
7485
+ }
7486
+ var prefix = normalizeOptionalString(text.slice(0, match.index)
7487
+ .replace(/\b(how|many|much|number|numbers|count|counts|summarize|summary|show|list|give|pull|find|tell|me|about|of|the|a|an|and|or|with|without|in|from|over|amount|quantity|qty|volume|total|totals|for|to|by|what|which|get|report|reports|all|break\s+down|breakdown)\b/gi, ' ')
7488
+ .replace(/[^a-z0-9%&.' -]+/gi, ' ')
7489
+ .replace(/\s+/g, ' '));
7490
+ if (prefix && (prefix.split(/\s+/).filter(Boolean).length >= 1)) {
7491
+ return prefix;
7492
+ }
7493
+ }
7494
+ }
7495
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
7496
+ finally {
7497
+ try {
7498
+ if (terms_1_1 && !terms_1_1.done && (_a = terms_1.return)) _a.call(terms_1);
7499
+ }
7500
+ finally { if (e_5) throw e_5.error; }
7501
+ }
7502
+ return '';
7503
+ }
7441
7504
  function extractAssistantDataIntentLikelyFilterText(message, intent) {
7442
7505
  var value = normalizeOptionalString(message);
7443
7506
  if (!value) {
@@ -7448,11 +7511,11 @@ function extractAssistantDataIntentLikelyFilterText(message, intent) {
7448
7511
  value = value.replace(/\b(?:last|past|previous|over\s+the\s+last)\s+(?:few|couple|couple\s+of|several)\s+(?:days?|weeks?|months?|years?)\b/gi, ' ');
7449
7512
  value = value.replace(/\b(?:last|past)\s+[0-9]+\s+(?:days?|weeks?|months?)\b/gi, ' ');
7450
7513
  value = value.replace(/\b(?:this|current)\s+(?:week|month|quarter|year)\b/gi, ' ');
7451
- value = value.replace(/\b(?:last|past)\s+(?:week|month|quarter|year)\b/gi, ' ');
7514
+ value = value.replace(/\b(?:last|past|previous|over\s+the\s+last)\s+(?:week|month|quarter|year)\b/gi, ' ');
7452
7515
  value = value.replace(/\b(?:until|through|since)\s+[a-z]+\s+[0-9]{1,2}\b/gi, ' ');
7453
7516
  value = value.replace(/\byear\s+to\s+date\b/gi, ' ');
7454
7517
  value = value.replace(/\b(?:by|per|group(?:ed)?(?:\s+by)?|split(?:\s+by)?)\s+[a-z0-9 _/-]+\b/gi, ' ');
7455
- value = value.replace(/\b(how|many|much|number|numbers|count|counts|summarize|summary|show|list|give|pull|find|tell|me|about|of|the|a|an|and|or|with|without|in|from|amount|quantity|qty|volume|total|totals|for|to|them|their|we|our|us|right|now|by|what|which|were|was|is|are|has|have|had|been|did|do|does|get|report|reports|all|break\s+down|breakdown|activity|activities|transactions?|movement|movements?|chemicals?|chemical|products?|product|inventory|invoices?|invoice|invoiced|invoicing|billed|billing|revenue|charged|usage|monthly|month|current|jobs?|work\s+orders?|blends?|blended|blending|planned|sent|shipped|shipment|shipments|delivered|created|increased?|decreased?|positive|negative|open|closed|completed|reviewed|this)\b/gi, ' ');
7518
+ value = value.replace(/\b(how|many|much|number|numbers|count|counts|summarize|summary|show|list|give|pull|find|tell|me|about|of|the|a|an|and|or|with|without|in|from|over|amount|quantity|qty|volume|total|totals|for|to|them|their|we|our|us|right|now|by|what|which|were|was|is|are|has|have|had|been|did|do|does|get|report|reports|all|break\s+down|breakdown|activity|activities|transactions?|movement|movements?|chemicals?|chemical|products?|product|inventory|invoices?|invoice|invoiced|invoicing|billed|billing|revenue|charged|usage|monthly|month|current|jobs?|work\s+orders?|blends?|blended|blending|planned|sent|shipped|shipment|shipments|delivered|created|increased?|decreased?|positive|negative|open|closed|completed|reviewed|this)\b/gi, ' ');
7456
7519
  var filterTerms = new Set();
7457
7520
  buildAssistantAppDataFilterCandidates(intent).forEach(function (filterField) {
7458
7521
  (filterField.terms || []).forEach(function (term) { return filterTerms.add(normalizeOptionalString(term).toLowerCase()); });
@@ -7466,6 +7529,9 @@ function extractAssistantDataIntentLikelyFilterText(message, intent) {
7466
7529
  });
7467
7530
  value = value.replace(/[^a-z0-9%&.' -]+/gi, ' ');
7468
7531
  value = normalizeOptionalString(value.replace(/\s+/g, ' '));
7532
+ if (!value) {
7533
+ value = extractAssistantLeadingPersonFilterText(message, intent);
7534
+ }
7469
7535
  if (!value || /^(activity|transactions?|movement|movements?|chemicals?|products?|inventory|invoices?|jobs?|work orders?|blends?)$/i.test(value)) {
7470
7536
  return '';
7471
7537
  }
@@ -8047,12 +8113,15 @@ function resolveAssistantDataIntentDateWindow(message) {
8047
8113
  year: now.getUTCFullYear()
8048
8114
  };
8049
8115
  }
8050
- var lastWindowMatch = text.match(/\b(?:last|past)\s+([0-9]+)\s+(days?|weeks?|months?)\b/);
8116
+ var lastWindowMatch = text.match(/\b(?:last|past|previous|over\s+the\s+last)\s+([0-9]+)\s+(days?|weeks?|months?|years?)\b/);
8051
8117
  if (lastWindowMatch) {
8052
8118
  var amount = Math.max(1, Math.min(Number(lastWindowMatch[1]) || 1, 36));
8053
8119
  var unit = lastWindowMatch[2];
8054
8120
  var start = new Date(now.getTime());
8055
- if (/week/.test(unit)) {
8121
+ if (/year/.test(unit)) {
8122
+ start.setUTCFullYear(start.getUTCFullYear() - amount);
8123
+ }
8124
+ else if (/week/.test(unit)) {
8056
8125
  start.setUTCDate(start.getUTCDate() - (amount * 7));
8057
8126
  }
8058
8127
  else if (/month/.test(unit)) {
@@ -8068,6 +8137,24 @@ function resolveAssistantDataIntentDateWindow(message) {
8068
8137
  year: now.getUTCFullYear()
8069
8138
  };
8070
8139
  }
8140
+ if (/\b(?:over\s+the\s+last|past)\s+year\b/.test(text)) {
8141
+ var start = new Date(now.getTime());
8142
+ start.setUTCFullYear(start.getUTCFullYear() - 1);
8143
+ start.setUTCHours(0, 0, 0, 0);
8144
+ return {
8145
+ start: start.toISOString(),
8146
+ end: new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), 23, 59, 59, 999)).toISOString(),
8147
+ year: now.getUTCFullYear()
8148
+ };
8149
+ }
8150
+ if (/\b(?:last|previous)\s+year\b/.test(text)) {
8151
+ var year_5 = now.getUTCFullYear() - 1;
8152
+ return {
8153
+ start: new Date(Date.UTC(year_5, 0, 1, 0, 0, 0, 0)).toISOString(),
8154
+ end: new Date(Date.UTC(year_5, 11, 31, 23, 59, 59, 999)).toISOString(),
8155
+ year: year_5
8156
+ };
8157
+ }
8071
8158
  if (/\b(?:this|current)\s+month\b/.test(text)) {
8072
8159
  return {
8073
8160
  start: new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1, 0, 0, 0, 0)).toISOString(),
@@ -8250,7 +8337,7 @@ function cleanAssistantRequestedDimensionText(value) {
8250
8337
  return normalizeOptionalString(text.replace(/\s+/g, ' ')).toLowerCase();
8251
8338
  }
8252
8339
  function extractAssistantRequestedBreakdownDimensionTexts(message) {
8253
- var e_5, _a;
8340
+ var e_6, _a;
8254
8341
  var text = normalizeOptionalString(message).toLowerCase();
8255
8342
  if (!text) {
8256
8343
  return [];
@@ -8277,12 +8364,12 @@ function extractAssistantRequestedBreakdownDimensionTexts(message) {
8277
8364
  }
8278
8365
  }
8279
8366
  }
8280
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
8367
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
8281
8368
  finally {
8282
8369
  try {
8283
8370
  if (patterns_2_1 && !patterns_2_1.done && (_a = patterns_2.return)) _a.call(patterns_2);
8284
8371
  }
8285
- finally { if (e_5) throw e_5.error; }
8372
+ finally { if (e_6) throw e_6.error; }
8286
8373
  }
8287
8374
  return mergeAssistantHintValues(results);
8288
8375
  }
@@ -9717,6 +9804,25 @@ function buildAssistantDataRequestUnderstanding(message, intent, dateWindow, cla
9717
9804
  ? clampAssistantConfidence(normalizedClassifierContract === null || normalizedClassifierContract === void 0 ? void 0 : normalizedClassifierContract.confidence, 0.65)
9718
9805
  : clampAssistantConfidence(normalizedClassifierContract === null || normalizedClassifierContract === void 0 ? void 0 : normalizedClassifierContract.confidence, 0.75);
9719
9806
  var filters = appendAssistantImplicitStatusConstraintFilters(message, intent, appendAssistantImplicitNumericConstraintFilters(message, intent, removeAssistantGenericBreakdownEntityFilters(preserveAssistantDataIntentFilterQualifiers(message, intent, (normalizedClassifierContract === null || normalizedClassifierContract === void 0 ? void 0 : normalizedClassifierContract.filters) || []), requestedBreakdowns)));
9807
+ if (!filters.length) {
9808
+ var personText = extractAssistantLeadingPersonFilterText(message, intent);
9809
+ var personCandidate = personText
9810
+ ? buildAssistantAppDataFilterCandidates(intent).find(function (candidate) { return isAssistantPersonFilterCandidate(candidate); })
9811
+ : null;
9812
+ if (personText && personCandidate) {
9813
+ var operator = personCandidate.operators.includes('contains') || !personCandidate.operators.length
9814
+ ? 'contains'
9815
+ : personCandidate.operators.includes('eq')
9816
+ ? 'eq'
9817
+ : personCandidate.operators[0];
9818
+ filters = [{
9819
+ field: personCandidate.id,
9820
+ operator: operator,
9821
+ value: personText,
9822
+ source: 'leading_person_filter_text'
9823
+ }];
9824
+ }
9825
+ }
9720
9826
  var effectiveDateRange = (dateWindow.start || dateWindow.end)
9721
9827
  ? __assign({}, dateWindow) : ((normalizedClassifierContract === null || normalizedClassifierContract === void 0 ? void 0 : normalizedClassifierContract.date_range) || null);
9722
9828
  return {
@@ -9740,7 +9846,7 @@ function buildAssistantDataRequestUnderstanding(message, intent, dateWindow, cla
9740
9846
  };
9741
9847
  }
9742
9848
  function inferAssistantDateWindowYear(value) {
9743
- var e_6, _a;
9849
+ var e_7, _a;
9744
9850
  if (!value) {
9745
9851
  return undefined;
9746
9852
  }
@@ -9756,12 +9862,12 @@ function inferAssistantDateWindowYear(value) {
9756
9862
  }
9757
9863
  }
9758
9864
  }
9759
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
9865
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
9760
9866
  finally {
9761
9867
  try {
9762
9868
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
9763
9869
  }
9764
- finally { if (e_6) throw e_6.error; }
9870
+ finally { if (e_7) throw e_7.error; }
9765
9871
  }
9766
9872
  return undefined;
9767
9873
  }
@@ -9911,7 +10017,7 @@ function normalizeAssistantContractFilterOperator(value) {
9911
10017
  return normalized || 'eq';
9912
10018
  }
9913
10019
  function extractAssistantFilterObjectValue(value) {
9914
- var e_7, _a;
10020
+ var e_8, _a;
9915
10021
  if (!value || typeof value !== 'object' || Array.isArray(value) || value instanceof Date) {
9916
10022
  return {
9917
10023
  operator: 'eq',
@@ -9935,12 +10041,12 @@ function extractAssistantFilterObjectValue(value) {
9935
10041
  };
9936
10042
  }
9937
10043
  }
9938
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
10044
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
9939
10045
  finally {
9940
10046
  try {
9941
10047
  if (operatorKeys_1_1 && !operatorKeys_1_1.done && (_a = operatorKeys_1.return)) _a.call(operatorKeys_1);
9942
10048
  }
9943
- finally { if (e_7) throw e_7.error; }
10049
+ finally { if (e_8) throw e_8.error; }
9944
10050
  }
9945
10051
  return {
9946
10052
  operator: 'eq',
@@ -10167,7 +10273,15 @@ function buildAssistantFieldFilterCondition(value, operator, type) {
10167
10273
  if (type === 'boolean') {
10168
10274
  return coerced;
10169
10275
  }
10170
- var escaped = escapeRegexValue(String(coerced));
10276
+ var rawString = String(coerced);
10277
+ var escaped = normalizedOperator === 'contains'
10278
+ ? rawString
10279
+ .split(/[^a-z0-9%&]+/i)
10280
+ .map(function (token) { return normalizeOptionalString(token); })
10281
+ .filter(function (token) { return token.length > 1 || /[0-9%&]/.test(token); })
10282
+ .map(function (token) { return escapeRegexValue(token); })
10283
+ .join('.*')
10284
+ : escapeRegexValue(rawString);
10171
10285
  if (!escaped) {
10172
10286
  return undefined;
10173
10287
  }
@@ -10182,15 +10296,37 @@ function normalizeAssistantFieldAwareFilterValue(value, candidate) {
10182
10296
  ], __read((candidate.terms || [])), false), __read((candidate.fields || [])), false).map(function (term) { return cleanAssistantRequestedDimensionText(term); })
10183
10297
  .filter(Boolean);
10184
10298
  var isDivisionCandidate = candidateTerms.some(function (term) { return term === 'division' || term === 'divisions' || term.endsWith(' division'); });
10185
- if (!isDivisionCandidate) {
10299
+ var isPersonCandidate = candidateTerms.some(function (term) { return [
10300
+ 'driver',
10301
+ 'drivers',
10302
+ 'user',
10303
+ 'users',
10304
+ 'employee',
10305
+ 'employees',
10306
+ 'person',
10307
+ 'people',
10308
+ 'name',
10309
+ 'id user',
10310
+ 'id_user'
10311
+ ].includes(term); });
10312
+ if (!isDivisionCandidate && !isPersonCandidate) {
10186
10313
  return value;
10187
10314
  }
10188
10315
  var text = normalizeOptionalString(value);
10189
10316
  if (!text) {
10190
10317
  return value;
10191
10318
  }
10192
- var normalized = normalizeOptionalString(text
10193
- .replace(/\bdivision(?:s)?\b/gi, ' ')
10319
+ var normalizedText = text;
10320
+ if (isDivisionCandidate) {
10321
+ normalizedText = normalizedText.replace(/\bdivision(?:s)?\b/gi, ' ');
10322
+ }
10323
+ if (isPersonCandidate) {
10324
+ normalizedText = normalizedText
10325
+ .replace(/\b([a-z][a-z0-9.'-]*)'s\b/gi, '$1')
10326
+ .replace(/\bs\b/gi, ' ')
10327
+ .replace(/\b(?:ats|pay|pays|settlement|settlements|driver|drivers|user|users|employee|employees|over)\b/gi, ' ');
10328
+ }
10329
+ var normalized = normalizeOptionalString(normalizedText
10194
10330
  .replace(/\s+/g, ' '));
10195
10331
  return normalized || value;
10196
10332
  }
@@ -10836,7 +10972,7 @@ function ensureAssistantDisplayColumns(display, requestedColumns) {
10836
10972
  return __assign(__assign({}, display), { columns: columns, rows: rows });
10837
10973
  }
10838
10974
  function resolveAssistantPipelineTimeGrain(pipeline) {
10839
- var e_8, _a;
10975
+ var e_9, _a;
10840
10976
  if (!Array.isArray(pipeline) || !pipeline.length) {
10841
10977
  return null;
10842
10978
  }
@@ -10898,12 +11034,12 @@ function resolveAssistantPipelineTimeGrain(pipeline) {
10898
11034
  }
10899
11035
  }
10900
11036
  }
10901
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
11037
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
10902
11038
  finally {
10903
11039
  try {
10904
11040
  if (priority_1_1 && !priority_1_1.done && (_a = priority_1.return)) _a.call(priority_1);
10905
11041
  }
10906
- finally { if (e_8) throw e_8.error; }
11042
+ finally { if (e_9) throw e_9.error; }
10907
11043
  }
10908
11044
  return null;
10909
11045
  }
@@ -11897,7 +12033,7 @@ function applyAssistantDatedReportWindow(value, toolResult) {
11897
12033
  return "".concat(line, "\n\n").concat(content).trim();
11898
12034
  }
11899
12035
  function resolveAssistantDatedReportWindow(toolResult) {
11900
- var e_9, _a;
12036
+ var e_10, _a;
11901
12037
  var _b, _c, _d, _e, _f, _g, _h, _j;
11902
12038
  var verificationWindow = (_d = (_c = (_b = toolResult === null || toolResult === void 0 ? void 0 : toolResult.output) === null || _b === void 0 ? void 0 : _b.verification) === null || _c === void 0 ? void 0 : _c.metrics) === null || _d === void 0 ? void 0 : _d.window;
11903
12039
  var verificationStart = normalizeOptionalString(verificationWindow === null || verificationWindow === void 0 ? void 0 : verificationWindow.startDate);
@@ -11963,12 +12099,12 @@ function resolveAssistantDatedReportWindow(toolResult) {
11963
12099
  };
11964
12100
  }
11965
12101
  }
11966
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
12102
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
11967
12103
  finally {
11968
12104
  try {
11969
12105
  if (pipelineCandidates_1_1 && !pipelineCandidates_1_1.done && (_a = pipelineCandidates_1.return)) _a.call(pipelineCandidates_1);
11970
12106
  }
11971
- finally { if (e_9) throw e_9.error; }
12107
+ finally { if (e_10) throw e_10.error; }
11972
12108
  }
11973
12109
  return null;
11974
12110
  }
@@ -12679,7 +12815,7 @@ function getValueAtPath(obj, path) {
12679
12815
  return walk(obj, 0);
12680
12816
  }
12681
12817
  function hasArrayValueAtPath(docs, path) {
12682
- var e_10, _a;
12818
+ var e_11, _a;
12683
12819
  if (!Array.isArray(docs) || !docs.length || !path) {
12684
12820
  return false;
12685
12821
  }
@@ -12692,17 +12828,17 @@ function hasArrayValueAtPath(docs, path) {
12692
12828
  }
12693
12829
  }
12694
12830
  }
12695
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
12831
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
12696
12832
  finally {
12697
12833
  try {
12698
12834
  if (docs_1_1 && !docs_1_1.done && (_a = docs_1.return)) _a.call(docs_1);
12699
12835
  }
12700
- finally { if (e_10) throw e_10.error; }
12836
+ finally { if (e_11) throw e_11.error; }
12701
12837
  }
12702
12838
  return false;
12703
12839
  }
12704
12840
  function inferIdFieldStorageTypeFromDocs(docs, fieldPath) {
12705
- var e_11, _a, e_12, _b;
12841
+ var e_12, _a, e_13, _b;
12706
12842
  if (!Array.isArray(docs) || !fieldPath) {
12707
12843
  return 'unknown';
12708
12844
  }
@@ -12715,7 +12851,7 @@ function inferIdFieldStorageTypeFromDocs(docs, fieldPath) {
12715
12851
  : doc === null || doc === void 0 ? void 0 : doc[fieldPath];
12716
12852
  var queue = Array.isArray(value) ? value : [value];
12717
12853
  try {
12718
- for (var queue_1 = (e_12 = void 0, __values(queue)), queue_1_1 = queue_1.next(); !queue_1_1.done; queue_1_1 = queue_1.next()) {
12854
+ for (var queue_1 = (e_13 = void 0, __values(queue)), queue_1_1 = queue_1.next(); !queue_1_1.done; queue_1_1 = queue_1.next()) {
12719
12855
  var entry = queue_1_1.value;
12720
12856
  if (entry === null || entry === undefined) {
12721
12857
  continue;
@@ -12728,21 +12864,21 @@ function inferIdFieldStorageTypeFromDocs(docs, fieldPath) {
12728
12864
  }
12729
12865
  }
12730
12866
  }
12731
- catch (e_12_1) { e_12 = { error: e_12_1 }; }
12867
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
12732
12868
  finally {
12733
12869
  try {
12734
12870
  if (queue_1_1 && !queue_1_1.done && (_b = queue_1.return)) _b.call(queue_1);
12735
12871
  }
12736
- finally { if (e_12) throw e_12.error; }
12872
+ finally { if (e_13) throw e_13.error; }
12737
12873
  }
12738
12874
  }
12739
12875
  }
12740
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
12876
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
12741
12877
  finally {
12742
12878
  try {
12743
12879
  if (docs_2_1 && !docs_2_1.done && (_a = docs_2.return)) _a.call(docs_2);
12744
12880
  }
12745
- finally { if (e_11) throw e_11.error; }
12881
+ finally { if (e_12) throw e_12.error; }
12746
12882
  }
12747
12883
  return sawString ? 'string' : 'unknown';
12748
12884
  }
@@ -12837,7 +12973,7 @@ function normalizeLookupKeyValue(value) {
12837
12973
  return '';
12838
12974
  }
12839
12975
  function collectTopLevelIdFieldValues(docs, options) {
12840
- var e_13, _a, e_14, _b;
12976
+ var e_14, _a, e_15, _b;
12841
12977
  if (!Array.isArray(docs) || !docs.length) {
12842
12978
  return [];
12843
12979
  }
@@ -12885,26 +13021,26 @@ function collectTopLevelIdFieldValues(docs, options) {
12885
13021
  });
12886
13022
  };
12887
13023
  try {
12888
- for (var keys_1 = (e_14 = void 0, __values(keys)), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
13024
+ for (var keys_1 = (e_15 = void 0, __values(keys)), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
12889
13025
  var key = keys_1_1.value;
12890
13026
  _loop_3(key);
12891
13027
  }
12892
13028
  }
12893
- catch (e_14_1) { e_14 = { error: e_14_1 }; }
13029
+ catch (e_15_1) { e_15 = { error: e_15_1 }; }
12894
13030
  finally {
12895
13031
  try {
12896
13032
  if (keys_1_1 && !keys_1_1.done && (_b = keys_1.return)) _b.call(keys_1);
12897
13033
  }
12898
- finally { if (e_14) throw e_14.error; }
13034
+ finally { if (e_15) throw e_15.error; }
12899
13035
  }
12900
13036
  }
12901
13037
  }
12902
- catch (e_13_1) { e_13 = { error: e_13_1 }; }
13038
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
12903
13039
  finally {
12904
13040
  try {
12905
13041
  if (docs_3_1 && !docs_3_1.done && (_a = docs_3.return)) _a.call(docs_3);
12906
13042
  }
12907
- finally { if (e_13) throw e_13.error; }
13043
+ finally { if (e_14) throw e_14.error; }
12908
13044
  }
12909
13045
  return Array.from(fieldMap.entries()).map(function (_a) {
12910
13046
  var _b = __read(_a, 2), field = _b[0], values = _b[1];
@@ -13025,8 +13161,8 @@ function resolveLookupMappingsForField(field, mappings) {
13025
13161
  }
13026
13162
  function applyIdLookupDisplayEnrichment(params) {
13027
13163
  return __awaiter(this, void 0, void 0, function () {
13028
- var docs, collection, db, dbName, idClient, idCustomer, isSuperAdmin, idFields, lookupMappings, allCollections, collectionProbeCache, collectionSchemaCache, lookupMeta, enrichedDocs, _loop_4, idFields_1, idFields_1_1, fieldEntry, e_15_1;
13029
- var e_15, _a;
13164
+ var docs, collection, db, dbName, idClient, idCustomer, isSuperAdmin, idFields, lookupMappings, allCollections, collectionProbeCache, collectionSchemaCache, lookupMeta, enrichedDocs, _loop_4, idFields_1, idFields_1_1, fieldEntry, e_16_1;
13165
+ var e_16, _a;
13030
13166
  return __generator(this, function (_b) {
13031
13167
  switch (_b.label) {
13032
13168
  case 0:
@@ -13050,8 +13186,8 @@ function applyIdLookupDisplayEnrichment(params) {
13050
13186
  lookupMeta = [];
13051
13187
  enrichedDocs = docs.map(function (doc) { return (__assign({}, doc)); });
13052
13188
  _loop_4 = function (fieldEntry) {
13053
- var values, baseToken, mappingMatches, candidateCollections, filteredCandidates, _loop_5, filteredCandidates_1, filteredCandidates_1_1, candidate, state_3, e_16_1;
13054
- var e_16, _c;
13189
+ var values, baseToken, mappingMatches, candidateCollections, filteredCandidates, _loop_5, filteredCandidates_1, filteredCandidates_1_1, candidate, state_3, e_17_1;
13190
+ var e_17, _c;
13055
13191
  return __generator(this, function (_d) {
13056
13192
  switch (_d.label) {
13057
13193
  case 0:
@@ -13225,7 +13361,7 @@ function applyIdLookupDisplayEnrichment(params) {
13225
13361
  _d.label = 1;
13226
13362
  case 1:
13227
13363
  _d.trys.push([1, 6, 7, 8]);
13228
- filteredCandidates_1 = (e_16 = void 0, __values(filteredCandidates)), filteredCandidates_1_1 = filteredCandidates_1.next();
13364
+ filteredCandidates_1 = (e_17 = void 0, __values(filteredCandidates)), filteredCandidates_1_1 = filteredCandidates_1.next();
13229
13365
  _d.label = 2;
13230
13366
  case 2:
13231
13367
  if (!!filteredCandidates_1_1.done) return [3 /*break*/, 5];
@@ -13241,14 +13377,14 @@ function applyIdLookupDisplayEnrichment(params) {
13241
13377
  return [3 /*break*/, 2];
13242
13378
  case 5: return [3 /*break*/, 8];
13243
13379
  case 6:
13244
- e_16_1 = _d.sent();
13245
- e_16 = { error: e_16_1 };
13380
+ e_17_1 = _d.sent();
13381
+ e_17 = { error: e_17_1 };
13246
13382
  return [3 /*break*/, 8];
13247
13383
  case 7:
13248
13384
  try {
13249
13385
  if (filteredCandidates_1_1 && !filteredCandidates_1_1.done && (_c = filteredCandidates_1.return)) _c.call(filteredCandidates_1);
13250
13386
  }
13251
- finally { if (e_16) throw e_16.error; }
13387
+ finally { if (e_17) throw e_17.error; }
13252
13388
  return [7 /*endfinally*/];
13253
13389
  case 8: return [2 /*return*/];
13254
13390
  }
@@ -13271,14 +13407,14 @@ function applyIdLookupDisplayEnrichment(params) {
13271
13407
  return [3 /*break*/, 3];
13272
13408
  case 6: return [3 /*break*/, 9];
13273
13409
  case 7:
13274
- e_15_1 = _b.sent();
13275
- e_15 = { error: e_15_1 };
13410
+ e_16_1 = _b.sent();
13411
+ e_16 = { error: e_16_1 };
13276
13412
  return [3 /*break*/, 9];
13277
13413
  case 8:
13278
13414
  try {
13279
13415
  if (idFields_1_1 && !idFields_1_1.done && (_a = idFields_1.return)) _a.call(idFields_1);
13280
13416
  }
13281
- finally { if (e_15) throw e_15.error; }
13417
+ finally { if (e_16) throw e_16.error; }
13282
13418
  return [7 /*endfinally*/];
13283
13419
  case 9:
13284
13420
  if (!lookupMeta.length) {
@@ -13297,7 +13433,7 @@ function applyIdLookupDisplayEnrichment(params) {
13297
13433
  });
13298
13434
  }
13299
13435
  function hasNonEmptyValue(docs, fieldPath, options) {
13300
- var e_17, _a;
13436
+ var e_18, _a;
13301
13437
  if (!Array.isArray(docs) || !fieldPath) {
13302
13438
  return false;
13303
13439
  }
@@ -13314,12 +13450,12 @@ function hasNonEmptyValue(docs, fieldPath, options) {
13314
13450
  }
13315
13451
  }
13316
13452
  }
13317
- catch (e_17_1) { e_17 = { error: e_17_1 }; }
13453
+ catch (e_18_1) { e_18 = { error: e_18_1 }; }
13318
13454
  finally {
13319
13455
  try {
13320
13456
  if (docs_4_1 && !docs_4_1.done && (_a = docs_4.return)) _a.call(docs_4);
13321
13457
  }
13322
- finally { if (e_17) throw e_17.error; }
13458
+ finally { if (e_18) throw e_18.error; }
13323
13459
  }
13324
13460
  return false;
13325
13461
  }
@@ -15935,7 +16071,7 @@ function flattenAssistantExprClauses(expr) {
15935
16071
  return [expr];
15936
16072
  }
15937
16073
  function detectAssistantMonthWindowInExpr(expr, allowedDateFields) {
15938
- var e_18, _a;
16074
+ var e_19, _a;
15939
16075
  var clauses = flattenAssistantExprClauses(expr);
15940
16076
  if (!clauses.length) {
15941
16077
  return null;
@@ -16009,12 +16145,12 @@ function detectAssistantMonthWindowInExpr(expr, allowedDateFields) {
16009
16145
  return state_4.value;
16010
16146
  }
16011
16147
  }
16012
- catch (e_18_1) { e_18 = { error: e_18_1 }; }
16148
+ catch (e_19_1) { e_19 = { error: e_19_1 }; }
16013
16149
  finally {
16014
16150
  try {
16015
16151
  if (lowerClauses_1_1 && !lowerClauses_1_1.done && (_a = lowerClauses_1.return)) _a.call(lowerClauses_1);
16016
16152
  }
16017
- finally { if (e_18) throw e_18.error; }
16153
+ finally { if (e_19) throw e_19.error; }
16018
16154
  }
16019
16155
  return null;
16020
16156
  }
@@ -16077,7 +16213,7 @@ function resolveAssistantMonthlyGroupDateFields(pipeline) {
16077
16213
  return fields;
16078
16214
  }
16079
16215
  function detectAssistantMonthWindowFromPipeline(pipeline) {
16080
- var e_19, _a;
16216
+ var e_20, _a;
16081
16217
  var _b;
16082
16218
  var monthlyFields = resolveAssistantMonthlyGroupDateFields(pipeline);
16083
16219
  var scanMatch = function (match) {
@@ -16105,12 +16241,12 @@ function detectAssistantMonthWindowFromPipeline(pipeline) {
16105
16241
  }
16106
16242
  }
16107
16243
  }
16108
- catch (e_19_1) { e_19 = { error: e_19_1 }; }
16244
+ catch (e_20_1) { e_20 = { error: e_20_1 }; }
16109
16245
  finally {
16110
16246
  try {
16111
16247
  if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
16112
16248
  }
16113
- finally { if (e_19) throw e_19.error; }
16249
+ finally { if (e_20) throw e_20.error; }
16114
16250
  }
16115
16251
  return null;
16116
16252
  }
@@ -16390,7 +16526,7 @@ function normalizeAssistantCustomerLookupProjectionPipeline(pipeline) {
16390
16526
  var nextProject = __assign({}, project);
16391
16527
  var stageChanged = false;
16392
16528
  Object.keys(nextProject).forEach(function (field) {
16393
- var e_20, _a;
16529
+ var e_21, _a;
16394
16530
  var expression = nextProject[field];
16395
16531
  if (typeof expression !== 'string') {
16396
16532
  return;
@@ -16426,12 +16562,12 @@ function normalizeAssistantCustomerLookupProjectionPipeline(pipeline) {
16426
16562
  break;
16427
16563
  }
16428
16564
  }
16429
- catch (e_20_1) { e_20 = { error: e_20_1 }; }
16565
+ catch (e_21_1) { e_21 = { error: e_21_1 }; }
16430
16566
  finally {
16431
16567
  try {
16432
16568
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
16433
16569
  }
16434
- finally { if (e_20) throw e_20.error; }
16570
+ finally { if (e_21) throw e_21.error; }
16435
16571
  }
16436
16572
  });
16437
16573
  if (stageChanged) {
@@ -16604,7 +16740,7 @@ function matchContainsField(value, field) {
16604
16740
  });
16605
16741
  }
16606
16742
  function resolveAggregateCompletionFallback(pipeline) {
16607
- var e_21, _a;
16743
+ var e_22, _a;
16608
16744
  if (!Array.isArray(pipeline)) {
16609
16745
  return null;
16610
16746
  }
@@ -16617,7 +16753,7 @@ function resolveAggregateCompletionFallback(pipeline) {
16617
16753
  }
16618
16754
  var addFields = stage.$addFields;
16619
16755
  try {
16620
- for (var _b = (e_21 = void 0, __values(Object.keys(addFields))), _c = _b.next(); !_c.done; _c = _b.next()) {
16756
+ for (var _b = (e_22 = void 0, __values(Object.keys(addFields))), _c = _b.next(); !_c.done; _c = _b.next()) {
16621
16757
  var key = _c.value;
16622
16758
  if (!isCompletionFieldName(key)) {
16623
16759
  continue;
@@ -16631,12 +16767,12 @@ function resolveAggregateCompletionFallback(pipeline) {
16631
16767
  }
16632
16768
  }
16633
16769
  }
16634
- catch (e_21_1) { e_21 = { error: e_21_1 }; }
16770
+ catch (e_22_1) { e_22 = { error: e_22_1 }; }
16635
16771
  finally {
16636
16772
  try {
16637
16773
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
16638
16774
  }
16639
- finally { if (e_21) throw e_21.error; }
16775
+ finally { if (e_22) throw e_22.error; }
16640
16776
  }
16641
16777
  if (candidateField) {
16642
16778
  break;
@@ -16792,7 +16928,7 @@ function buildCompletionFallbackSources(field) {
16792
16928
  ]);
16793
16929
  }
16794
16930
  function resolveAggregateCompletionExprFallback(pipeline) {
16795
- var e_22, _a;
16931
+ var e_23, _a;
16796
16932
  if (!Array.isArray(pipeline)) {
16797
16933
  return null;
16798
16934
  }
@@ -16812,7 +16948,7 @@ function resolveAggregateCompletionExprFallback(pipeline) {
16812
16948
  }
16813
16949
  if (!candidateField) {
16814
16950
  try {
16815
- for (var _b = (e_22 = void 0, __values(Object.keys(matchStage))), _c = _b.next(); !_c.done; _c = _b.next()) {
16951
+ for (var _b = (e_23 = void 0, __values(Object.keys(matchStage))), _c = _b.next(); !_c.done; _c = _b.next()) {
16816
16952
  var key = _c.value;
16817
16953
  if (key.startsWith('$')) {
16818
16954
  continue;
@@ -16827,12 +16963,12 @@ function resolveAggregateCompletionExprFallback(pipeline) {
16827
16963
  }
16828
16964
  }
16829
16965
  }
16830
- catch (e_22_1) { e_22 = { error: e_22_1 }; }
16966
+ catch (e_23_1) { e_23 = { error: e_23_1 }; }
16831
16967
  finally {
16832
16968
  try {
16833
16969
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
16834
16970
  }
16835
- finally { if (e_22) throw e_22.error; }
16971
+ finally { if (e_23) throw e_23.error; }
16836
16972
  }
16837
16973
  }
16838
16974
  if (!candidateField) {
@@ -17034,7 +17170,7 @@ function hasAssistantDateGroupingOperator(value) {
17034
17170
  return Object.keys(value).some(function (key) { return hasAssistantDateGroupingOperator(value[key]); });
17035
17171
  }
17036
17172
  function isGroupFieldDerivedFromDateExpression(pipeline, groupIndex, groupPaths) {
17037
- var e_23, _a, e_24, _b;
17173
+ var e_24, _a, e_25, _b;
17038
17174
  if (!Array.isArray(pipeline) || groupIndex <= 0 || !groupPaths.length) {
17039
17175
  return false;
17040
17176
  }
@@ -17060,14 +17196,14 @@ function isGroupFieldDerivedFromDateExpression(pipeline, groupIndex, groupPaths)
17060
17196
  continue;
17061
17197
  }
17062
17198
  try {
17063
- for (var stageKeys_1 = (e_23 = void 0, __values(stageKeys)), stageKeys_1_1 = stageKeys_1.next(); !stageKeys_1_1.done; stageKeys_1_1 = stageKeys_1.next()) {
17199
+ for (var stageKeys_1 = (e_24 = void 0, __values(stageKeys)), stageKeys_1_1 = stageKeys_1.next(); !stageKeys_1_1.done; stageKeys_1_1 = stageKeys_1.next()) {
17064
17200
  var stageKey = stageKeys_1_1.value;
17065
17201
  var payload = stage[stageKey];
17066
17202
  if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
17067
17203
  continue;
17068
17204
  }
17069
17205
  try {
17070
- for (var groupFields_1 = (e_24 = void 0, __values(groupFields)), groupFields_1_1 = groupFields_1.next(); !groupFields_1_1.done; groupFields_1_1 = groupFields_1.next()) {
17206
+ for (var groupFields_1 = (e_25 = void 0, __values(groupFields)), groupFields_1_1 = groupFields_1.next(); !groupFields_1_1.done; groupFields_1_1 = groupFields_1.next()) {
17071
17207
  var groupField = groupFields_1_1.value;
17072
17208
  if (!Object.prototype.hasOwnProperty.call(payload, groupField)) {
17073
17209
  continue;
@@ -17077,21 +17213,21 @@ function isGroupFieldDerivedFromDateExpression(pipeline, groupIndex, groupPaths)
17077
17213
  }
17078
17214
  }
17079
17215
  }
17080
- catch (e_24_1) { e_24 = { error: e_24_1 }; }
17216
+ catch (e_25_1) { e_25 = { error: e_25_1 }; }
17081
17217
  finally {
17082
17218
  try {
17083
17219
  if (groupFields_1_1 && !groupFields_1_1.done && (_b = groupFields_1.return)) _b.call(groupFields_1);
17084
17220
  }
17085
- finally { if (e_24) throw e_24.error; }
17221
+ finally { if (e_25) throw e_25.error; }
17086
17222
  }
17087
17223
  }
17088
17224
  }
17089
- catch (e_23_1) { e_23 = { error: e_23_1 }; }
17225
+ catch (e_24_1) { e_24 = { error: e_24_1 }; }
17090
17226
  finally {
17091
17227
  try {
17092
17228
  if (stageKeys_1_1 && !stageKeys_1_1.done && (_a = stageKeys_1.return)) _a.call(stageKeys_1);
17093
17229
  }
17094
- finally { if (e_23) throw e_23.error; }
17230
+ finally { if (e_24) throw e_24.error; }
17095
17231
  }
17096
17232
  }
17097
17233
  return false;
@@ -17198,7 +17334,7 @@ function isRegexMatchCondition(value) {
17198
17334
  return false;
17199
17335
  }
17200
17336
  function findRegexMatchInMatchObject(match, prefix) {
17201
- var e_25, _a, e_26, _b;
17337
+ var e_26, _a, e_27, _b;
17202
17338
  if (prefix === void 0) { prefix = ''; }
17203
17339
  if (Array.isArray(match)) {
17204
17340
  try {
@@ -17210,12 +17346,12 @@ function findRegexMatchInMatchObject(match, prefix) {
17210
17346
  }
17211
17347
  }
17212
17348
  }
17213
- catch (e_25_1) { e_25 = { error: e_25_1 }; }
17349
+ catch (e_26_1) { e_26 = { error: e_26_1 }; }
17214
17350
  finally {
17215
17351
  try {
17216
17352
  if (match_1_1 && !match_1_1.done && (_a = match_1.return)) _a.call(match_1);
17217
17353
  }
17218
- finally { if (e_25) throw e_25.error; }
17354
+ finally { if (e_26) throw e_26.error; }
17219
17355
  }
17220
17356
  return null;
17221
17357
  }
@@ -17246,12 +17382,12 @@ function findRegexMatchInMatchObject(match, prefix) {
17246
17382
  }
17247
17383
  }
17248
17384
  }
17249
- catch (e_26_1) { e_26 = { error: e_26_1 }; }
17385
+ catch (e_27_1) { e_27 = { error: e_27_1 }; }
17250
17386
  finally {
17251
17387
  try {
17252
17388
  if (keys_2_1 && !keys_2_1.done && (_b = keys_2.return)) _b.call(keys_2);
17253
17389
  }
17254
- finally { if (e_26) throw e_26.error; }
17390
+ finally { if (e_27) throw e_27.error; }
17255
17391
  }
17256
17392
  return null;
17257
17393
  }
@@ -17640,7 +17776,7 @@ function collectMatchFieldsByCondition(match, predicate, prefix) {
17640
17776
  return results;
17641
17777
  }
17642
17778
  function findMatchConditionForField(match, targetField, prefix) {
17643
- var e_27, _a, e_28, _b;
17779
+ var e_28, _a, e_29, _b;
17644
17780
  if (prefix === void 0) { prefix = ''; }
17645
17781
  if (!match || typeof match !== 'object') {
17646
17782
  return undefined;
@@ -17655,12 +17791,12 @@ function findMatchConditionForField(match, targetField, prefix) {
17655
17791
  }
17656
17792
  }
17657
17793
  }
17658
- catch (e_27_1) { e_27 = { error: e_27_1 }; }
17794
+ catch (e_28_1) { e_28 = { error: e_28_1 }; }
17659
17795
  finally {
17660
17796
  try {
17661
17797
  if (match_2_1 && !match_2_1.done && (_a = match_2.return)) _a.call(match_2);
17662
17798
  }
17663
- finally { if (e_27) throw e_27.error; }
17799
+ finally { if (e_28) throw e_28.error; }
17664
17800
  }
17665
17801
  return undefined;
17666
17802
  }
@@ -17687,12 +17823,12 @@ function findMatchConditionForField(match, targetField, prefix) {
17687
17823
  }
17688
17824
  }
17689
17825
  }
17690
- catch (e_28_1) { e_28 = { error: e_28_1 }; }
17826
+ catch (e_29_1) { e_29 = { error: e_29_1 }; }
17691
17827
  finally {
17692
17828
  try {
17693
17829
  if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
17694
17830
  }
17695
- finally { if (e_28) throw e_28.error; }
17831
+ finally { if (e_29) throw e_29.error; }
17696
17832
  }
17697
17833
  return undefined;
17698
17834
  }
@@ -17925,7 +18061,7 @@ function detectIdLikeValue(value) {
17925
18061
  return false;
17926
18062
  }
17927
18063
  function detectChemicalIdFromProbe(probeDocs, fields) {
17928
- var e_29, _a, e_30, _b;
18064
+ var e_30, _a, e_31, _b;
17929
18065
  if (!Array.isArray(probeDocs) || !probeDocs.length) {
17930
18066
  return false;
17931
18067
  }
@@ -17937,7 +18073,7 @@ function detectChemicalIdFromProbe(probeDocs, fields) {
17937
18073
  for (var probeDocs_1 = __values(probeDocs), probeDocs_1_1 = probeDocs_1.next(); !probeDocs_1_1.done; probeDocs_1_1 = probeDocs_1.next()) {
17938
18074
  var doc = probeDocs_1_1.value;
17939
18075
  try {
17940
- for (var targets_1 = (e_30 = void 0, __values(targets)), targets_1_1 = targets_1.next(); !targets_1_1.done; targets_1_1 = targets_1.next()) {
18076
+ for (var targets_1 = (e_31 = void 0, __values(targets)), targets_1_1 = targets_1.next(); !targets_1_1.done; targets_1_1 = targets_1.next()) {
17941
18077
  var field = targets_1_1.value;
17942
18078
  var value = getValueAtPath(doc, field);
17943
18079
  if (Array.isArray(value)) {
@@ -17950,21 +18086,21 @@ function detectChemicalIdFromProbe(probeDocs, fields) {
17950
18086
  }
17951
18087
  }
17952
18088
  }
17953
- catch (e_30_1) { e_30 = { error: e_30_1 }; }
18089
+ catch (e_31_1) { e_31 = { error: e_31_1 }; }
17954
18090
  finally {
17955
18091
  try {
17956
18092
  if (targets_1_1 && !targets_1_1.done && (_b = targets_1.return)) _b.call(targets_1);
17957
18093
  }
17958
- finally { if (e_30) throw e_30.error; }
18094
+ finally { if (e_31) throw e_31.error; }
17959
18095
  }
17960
18096
  }
17961
18097
  }
17962
- catch (e_29_1) { e_29 = { error: e_29_1 }; }
18098
+ catch (e_30_1) { e_30 = { error: e_30_1 }; }
17963
18099
  finally {
17964
18100
  try {
17965
18101
  if (probeDocs_1_1 && !probeDocs_1_1.done && (_a = probeDocs_1.return)) _a.call(probeDocs_1);
17966
18102
  }
17967
- finally { if (e_29) throw e_29.error; }
18103
+ finally { if (e_30) throw e_30.error; }
17968
18104
  }
17969
18105
  return false;
17970
18106
  }
@@ -18185,8 +18321,8 @@ function buildChemicalIdFieldCandidates(field) {
18185
18321
  }
18186
18322
  function applyChemicalNameLookupFallbackToQuery(params) {
18187
18323
  return __awaiter(this, void 0, void 0, function () {
18188
- var query, db, dbName, idClient, idCustomer, isSuperAdmin, probeDocs, chemicalFields, targetField, condition, regex, sampleDocs, collectionNames, candidates, _loop_8, candidates_1, candidates_1_1, candidate, state_5, e_31_1;
18189
- var e_31, _a;
18324
+ var query, db, dbName, idClient, idCustomer, isSuperAdmin, probeDocs, chemicalFields, targetField, condition, regex, sampleDocs, collectionNames, candidates, _loop_8, candidates_1, candidates_1_1, candidate, state_5, e_32_1;
18325
+ var e_32, _a;
18190
18326
  var _b;
18191
18327
  return __generator(this, function (_c) {
18192
18328
  switch (_c.label) {
@@ -18299,14 +18435,14 @@ function applyChemicalNameLookupFallbackToQuery(params) {
18299
18435
  return [3 /*break*/, 3];
18300
18436
  case 6: return [3 /*break*/, 9];
18301
18437
  case 7:
18302
- e_31_1 = _c.sent();
18303
- e_31 = { error: e_31_1 };
18438
+ e_32_1 = _c.sent();
18439
+ e_32 = { error: e_32_1 };
18304
18440
  return [3 /*break*/, 9];
18305
18441
  case 8:
18306
18442
  try {
18307
18443
  if (candidates_1_1 && !candidates_1_1.done && (_a = candidates_1.return)) _a.call(candidates_1);
18308
18444
  }
18309
- finally { if (e_31) throw e_31.error; }
18445
+ finally { if (e_32) throw e_32.error; }
18310
18446
  return [7 /*endfinally*/];
18311
18447
  case 9: return [2 /*return*/, null];
18312
18448
  }
@@ -18406,8 +18542,8 @@ function lookupIdsForNameMatch(params) {
18406
18542
  }
18407
18543
  function applyIdLookupFallbackToQuery(params) {
18408
18544
  return __awaiter(this, void 0, void 0, function () {
18409
- var query, db, dbName, idClient, idCustomer, isSuperAdmin, probeDocs, conditions, collectionNames, _a, conditions_1, conditions_1_1, condition, regex, baseToken, targetFieldType, nextValue, localNameField, candidates, candidates_2, candidates_2_1, candidate, candidateHasClientScope, _b, candidateProbe, lookup, targetFieldType, normalizedIds, idsForQuery, e_32_1, e_33_1;
18410
- var e_33, _c, e_32, _d;
18545
+ var query, db, dbName, idClient, idCustomer, isSuperAdmin, probeDocs, conditions, collectionNames, _a, conditions_1, conditions_1_1, condition, regex, baseToken, targetFieldType, nextValue, localNameField, candidates, candidates_2, candidates_2_1, candidate, candidateHasClientScope, _b, candidateProbe, lookup, targetFieldType, normalizedIds, idsForQuery, e_33_1, e_34_1;
18546
+ var e_34, _c, e_33, _d;
18411
18547
  var _e;
18412
18548
  return __generator(this, function (_f) {
18413
18549
  switch (_f.label) {
@@ -18477,7 +18613,7 @@ function applyIdLookupFallbackToQuery(params) {
18477
18613
  _f.label = 5;
18478
18614
  case 5:
18479
18615
  _f.trys.push([5, 14, 15, 16]);
18480
- candidates_2 = (e_32 = void 0, __values(candidates)), candidates_2_1 = candidates_2.next();
18616
+ candidates_2 = (e_33 = void 0, __values(candidates)), candidates_2_1 = candidates_2.next();
18481
18617
  _f.label = 6;
18482
18618
  case 6:
18483
18619
  if (!!candidates_2_1.done) return [3 /*break*/, 13];
@@ -18544,28 +18680,28 @@ function applyIdLookupFallbackToQuery(params) {
18544
18680
  return [3 /*break*/, 6];
18545
18681
  case 13: return [3 /*break*/, 16];
18546
18682
  case 14:
18547
- e_32_1 = _f.sent();
18548
- e_32 = { error: e_32_1 };
18683
+ e_33_1 = _f.sent();
18684
+ e_33 = { error: e_33_1 };
18549
18685
  return [3 /*break*/, 16];
18550
18686
  case 15:
18551
18687
  try {
18552
18688
  if (candidates_2_1 && !candidates_2_1.done && (_d = candidates_2.return)) _d.call(candidates_2);
18553
18689
  }
18554
- finally { if (e_32) throw e_32.error; }
18690
+ finally { if (e_33) throw e_33.error; }
18555
18691
  return [7 /*endfinally*/];
18556
18692
  case 16:
18557
18693
  conditions_1_1 = conditions_1.next();
18558
18694
  return [3 /*break*/, 4];
18559
18695
  case 17: return [3 /*break*/, 20];
18560
18696
  case 18:
18561
- e_33_1 = _f.sent();
18562
- e_33 = { error: e_33_1 };
18697
+ e_34_1 = _f.sent();
18698
+ e_34 = { error: e_34_1 };
18563
18699
  return [3 /*break*/, 20];
18564
18700
  case 19:
18565
18701
  try {
18566
18702
  if (conditions_1_1 && !conditions_1_1.done && (_c = conditions_1.return)) _c.call(conditions_1);
18567
18703
  }
18568
- finally { if (e_33) throw e_33.error; }
18704
+ finally { if (e_34) throw e_34.error; }
18569
18705
  return [7 /*endfinally*/];
18570
18706
  case 20: return [2 /*return*/, null];
18571
18707
  }
@@ -19010,8 +19146,8 @@ function resolveAssistantSurfaceFileCandidates(baseName) {
19010
19146
  }
19011
19147
  function readFirstAssistantSurfaceFile(candidates) {
19012
19148
  return __awaiter(this, void 0, void 0, function () {
19013
- var candidates_3, candidates_3_1, candidate, normalized, _a, e_34_1;
19014
- var e_34, _b;
19149
+ var candidates_3, candidates_3_1, candidate, normalized, _a, e_35_1;
19150
+ var e_35, _b;
19015
19151
  return __generator(this, function (_c) {
19016
19152
  switch (_c.label) {
19017
19153
  case 0:
@@ -19038,14 +19174,14 @@ function readFirstAssistantSurfaceFile(candidates) {
19038
19174
  return [3 /*break*/, 1];
19039
19175
  case 6: return [3 /*break*/, 9];
19040
19176
  case 7:
19041
- e_34_1 = _c.sent();
19042
- e_34 = { error: e_34_1 };
19177
+ e_35_1 = _c.sent();
19178
+ e_35 = { error: e_35_1 };
19043
19179
  return [3 /*break*/, 9];
19044
19180
  case 8:
19045
19181
  try {
19046
19182
  if (candidates_3_1 && !candidates_3_1.done && (_b = candidates_3.return)) _b.call(candidates_3);
19047
19183
  }
19048
- finally { if (e_34) throw e_34.error; }
19184
+ finally { if (e_35) throw e_35.error; }
19049
19185
  return [7 /*endfinally*/];
19050
19186
  case 9: return [2 /*return*/, ''];
19051
19187
  }
@@ -20780,7 +20916,7 @@ function doesAssistantPreserveAnyTermMatch(text, terms) {
20780
20916
  return (Array.isArray(terms) ? terms : []).some(function (term) { return doesAssistantPreserveTermMatch(text, term); });
20781
20917
  }
20782
20918
  function shouldPreserveAssistantCollectionForRouteFromRules(params) {
20783
- var e_35, _a;
20919
+ var e_36, _a;
20784
20920
  var _b, _c, _d, _e, _f, _g, _h;
20785
20921
  var routePreferred = normalizeAssistantCollectionOverrideName(params.routePreferredName);
20786
20922
  var requested = normalizeAssistantCollectionOverrideName(params.requestedCollection);
@@ -20812,12 +20948,12 @@ function shouldPreserveAssistantCollectionForRouteFromRules(params) {
20812
20948
  return true;
20813
20949
  }
20814
20950
  }
20815
- catch (e_35_1) { e_35 = { error: e_35_1 }; }
20951
+ catch (e_36_1) { e_36 = { error: e_36_1 }; }
20816
20952
  finally {
20817
20953
  try {
20818
20954
  if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
20819
20955
  }
20820
- finally { if (e_35) throw e_35.error; }
20956
+ finally { if (e_36) throw e_36.error; }
20821
20957
  }
20822
20958
  return false;
20823
20959
  }
@@ -21708,7 +21844,7 @@ function resolveAssistantNestedPrefixCollectionCandidates(params) {
21708
21844
  function resolveAssistantNestedAggregateFallbacks(params) {
21709
21845
  return __awaiter(this, void 0, void 0, function () {
21710
21846
  var prefixes, collectionNames, fallbacks, seen, prefixes_1, prefixes_1_1, prefix, rewrite, candidates, candidates_4, candidates_4_1, candidate, normalizedPipeline, key;
21711
- var e_36, _a, e_37, _b;
21847
+ var e_37, _a, e_38, _b;
21712
21848
  return __generator(this, function (_c) {
21713
21849
  switch (_c.label) {
21714
21850
  case 0:
@@ -21738,7 +21874,7 @@ function resolveAssistantNestedAggregateFallbacks(params) {
21738
21874
  triedCollections: params.triedCollections
21739
21875
  });
21740
21876
  try {
21741
- for (candidates_4 = (e_37 = void 0, __values(candidates)), candidates_4_1 = candidates_4.next(); !candidates_4_1.done; candidates_4_1 = candidates_4.next()) {
21877
+ for (candidates_4 = (e_38 = void 0, __values(candidates)), candidates_4_1 = candidates_4.next(); !candidates_4_1.done; candidates_4_1 = candidates_4.next()) {
21742
21878
  candidate = candidates_4_1.value;
21743
21879
  normalizedPipeline = normalizeAssistantAggregatePipeline(rewrite.pipeline, candidate);
21744
21880
  if (!normalizedPipeline.length || containsForbiddenMongoOperators(normalizedPipeline)) {
@@ -21760,21 +21896,21 @@ function resolveAssistantNestedAggregateFallbacks(params) {
21760
21896
  }
21761
21897
  }
21762
21898
  }
21763
- catch (e_37_1) { e_37 = { error: e_37_1 }; }
21899
+ catch (e_38_1) { e_38 = { error: e_38_1 }; }
21764
21900
  finally {
21765
21901
  try {
21766
21902
  if (candidates_4_1 && !candidates_4_1.done && (_b = candidates_4.return)) _b.call(candidates_4);
21767
21903
  }
21768
- finally { if (e_37) throw e_37.error; }
21904
+ finally { if (e_38) throw e_38.error; }
21769
21905
  }
21770
21906
  }
21771
21907
  }
21772
- catch (e_36_1) { e_36 = { error: e_36_1 }; }
21908
+ catch (e_37_1) { e_37 = { error: e_37_1 }; }
21773
21909
  finally {
21774
21910
  try {
21775
21911
  if (prefixes_1_1 && !prefixes_1_1.done && (_a = prefixes_1.return)) _a.call(prefixes_1);
21776
21912
  }
21777
- finally { if (e_36) throw e_36.error; }
21913
+ finally { if (e_37) throw e_37.error; }
21778
21914
  }
21779
21915
  return [2 /*return*/, fallbacks];
21780
21916
  }
@@ -21906,8 +22042,8 @@ function resolveAssistantBridgeCollectionHintCandidates(requestedCollection, req
21906
22042
  }
21907
22043
  function resolveAssistantReportBuilderBridgeCollection(collection_1, db_1) {
21908
22044
  return __awaiter(this, arguments, void 0, function (collection, db, dbName, options) {
21909
- var normalized, resolutionPath, pushResolutionStep, finalizeResolution, requestHints, appId, requestedTokens, requestedTokenWeights, aliasCandidates, hintCandidates, alias, manager, hasManager, configuredCollectionNames, isConfiguredCollection, candidates, pushCandidate, base, reportCandidate, candidates_5, candidates_5_1, candidate, model, candidates_6, candidates_6_1, candidate, primaryCollectionHint, resolverTargets, resolverErrorLogged, resolverTargets_1, resolverTargets_1_1, resolverTarget, resolved, resolvedName, resolvedScore, resolvedModel, _a, e_38_1, candidates_7, candidates_7_1, candidate, e_39_1, candidates_8, candidates_8_1, candidate;
21910
- var e_40, _b, e_41, _c, e_38, _d, e_39, _e, e_42, _f;
22045
+ var normalized, resolutionPath, pushResolutionStep, finalizeResolution, requestHints, appId, requestedTokens, requestedTokenWeights, aliasCandidates, hintCandidates, alias, manager, hasManager, configuredCollectionNames, isConfiguredCollection, candidates, pushCandidate, base, reportCandidate, candidates_5, candidates_5_1, candidate, model, candidates_6, candidates_6_1, candidate, primaryCollectionHint, resolverTargets, resolverErrorLogged, resolverTargets_1, resolverTargets_1_1, resolverTarget, resolved, resolvedName, resolvedScore, resolvedModel, _a, e_39_1, candidates_7, candidates_7_1, candidate, e_40_1, candidates_8, candidates_8_1, candidate;
22046
+ var e_41, _b, e_42, _c, e_39, _d, e_40, _e, e_43, _f;
21911
22047
  var _g, _h;
21912
22048
  if (dbName === void 0) { dbName = ''; }
21913
22049
  return __generator(this, function (_j) {
@@ -21981,12 +22117,12 @@ function resolveAssistantReportBuilderBridgeCollection(collection_1, db_1) {
21981
22117
  }
21982
22118
  }
21983
22119
  }
21984
- catch (e_40_1) { e_40 = { error: e_40_1 }; }
22120
+ catch (e_41_1) { e_41 = { error: e_41_1 }; }
21985
22121
  finally {
21986
22122
  try {
21987
22123
  if (candidates_5_1 && !candidates_5_1.done && (_b = candidates_5.return)) _b.call(candidates_5);
21988
22124
  }
21989
- finally { if (e_40) throw e_40.error; }
22125
+ finally { if (e_41) throw e_41.error; }
21990
22126
  }
21991
22127
  }
21992
22128
  if (configuredCollectionNames.length) {
@@ -22001,12 +22137,12 @@ function resolveAssistantReportBuilderBridgeCollection(collection_1, db_1) {
22001
22137
  }
22002
22138
  }
22003
22139
  }
22004
- catch (e_41_1) { e_41 = { error: e_41_1 }; }
22140
+ catch (e_42_1) { e_42 = { error: e_42_1 }; }
22005
22141
  finally {
22006
22142
  try {
22007
22143
  if (candidates_6_1 && !candidates_6_1.done && (_c = candidates_6.return)) _c.call(candidates_6);
22008
22144
  }
22009
- finally { if (e_41) throw e_41.error; }
22145
+ finally { if (e_42) throw e_42.error; }
22010
22146
  }
22011
22147
  }
22012
22148
  primaryCollectionHint = normalizeOptionalString((_h = requestHints === null || requestHints === void 0 ? void 0 : requestHints.collectionHints) === null || _h === void 0 ? void 0 : _h[0]);
@@ -22067,14 +22203,14 @@ function resolveAssistantReportBuilderBridgeCollection(collection_1, db_1) {
22067
22203
  return [3 /*break*/, 2];
22068
22204
  case 7: return [3 /*break*/, 10];
22069
22205
  case 8:
22070
- e_38_1 = _j.sent();
22071
- e_38 = { error: e_38_1 };
22206
+ e_39_1 = _j.sent();
22207
+ e_39 = { error: e_39_1 };
22072
22208
  return [3 /*break*/, 10];
22073
22209
  case 9:
22074
22210
  try {
22075
22211
  if (resolverTargets_1_1 && !resolverTargets_1_1.done && (_d = resolverTargets_1.return)) _d.call(resolverTargets_1);
22076
22212
  }
22077
- finally { if (e_38) throw e_38.error; }
22213
+ finally { if (e_39) throw e_39.error; }
22078
22214
  return [7 /*endfinally*/];
22079
22215
  case 10:
22080
22216
  if (!db) return [3 /*break*/, 18];
@@ -22100,14 +22236,14 @@ function resolveAssistantReportBuilderBridgeCollection(collection_1, db_1) {
22100
22236
  return [3 /*break*/, 12];
22101
22237
  case 15: return [3 /*break*/, 18];
22102
22238
  case 16:
22103
- e_39_1 = _j.sent();
22104
- e_39 = { error: e_39_1 };
22239
+ e_40_1 = _j.sent();
22240
+ e_40 = { error: e_40_1 };
22105
22241
  return [3 /*break*/, 18];
22106
22242
  case 17:
22107
22243
  try {
22108
22244
  if (candidates_7_1 && !candidates_7_1.done && (_e = candidates_7.return)) _e.call(candidates_7);
22109
22245
  }
22110
- finally { if (e_39) throw e_39.error; }
22246
+ finally { if (e_40) throw e_40.error; }
22111
22247
  return [7 /*endfinally*/];
22112
22248
  case 18:
22113
22249
  try {
@@ -22118,12 +22254,12 @@ function resolveAssistantReportBuilderBridgeCollection(collection_1, db_1) {
22118
22254
  }
22119
22255
  }
22120
22256
  }
22121
- catch (e_42_1) { e_42 = { error: e_42_1 }; }
22257
+ catch (e_43_1) { e_43 = { error: e_43_1 }; }
22122
22258
  finally {
22123
22259
  try {
22124
22260
  if (candidates_8_1 && !candidates_8_1.done && (_f = candidates_8.return)) _f.call(candidates_8);
22125
22261
  }
22126
- finally { if (e_42) throw e_42.error; }
22262
+ finally { if (e_43) throw e_43.error; }
22127
22263
  }
22128
22264
  throw new Error('AI assistant report builder bridge: No queryable collection could be resolved.');
22129
22265
  }
@@ -22131,7 +22267,7 @@ function resolveAssistantReportBuilderBridgeCollection(collection_1, db_1) {
22131
22267
  });
22132
22268
  }
22133
22269
  function findQueryDateField(query) {
22134
- var e_43, _a, e_44, _b;
22270
+ var e_44, _a, e_45, _b;
22135
22271
  if (!query || typeof query !== 'object') {
22136
22272
  return null;
22137
22273
  }
@@ -22145,12 +22281,12 @@ function findQueryDateField(query) {
22145
22281
  }
22146
22282
  }
22147
22283
  }
22148
- catch (e_43_1) { e_43 = { error: e_43_1 }; }
22284
+ catch (e_44_1) { e_44 = { error: e_44_1 }; }
22149
22285
  finally {
22150
22286
  try {
22151
22287
  if (query_1_1 && !query_1_1.done && (_a = query_1.return)) _a.call(query_1);
22152
22288
  }
22153
- finally { if (e_43) throw e_43.error; }
22289
+ finally { if (e_44) throw e_44.error; }
22154
22290
  }
22155
22291
  return null;
22156
22292
  }
@@ -22169,12 +22305,12 @@ function findQueryDateField(query) {
22169
22305
  }
22170
22306
  }
22171
22307
  }
22172
- catch (e_44_1) { e_44 = { error: e_44_1 }; }
22308
+ catch (e_45_1) { e_45 = { error: e_45_1 }; }
22173
22309
  finally {
22174
22310
  try {
22175
22311
  if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
22176
22312
  }
22177
- finally { if (e_44) throw e_44.error; }
22313
+ finally { if (e_45) throw e_45.error; }
22178
22314
  }
22179
22315
  return null;
22180
22316
  }
@@ -22462,7 +22598,7 @@ function resolveQueryDateFieldFallback(query) {
22462
22598
  return { from: dateField, to: fallback };
22463
22599
  }
22464
22600
  function containsForbiddenMongoOperators(value) {
22465
- var e_45, _a;
22601
+ var e_46, _a;
22466
22602
  if (!value || typeof value !== 'object') {
22467
22603
  return false;
22468
22604
  }
@@ -22481,12 +22617,12 @@ function containsForbiddenMongoOperators(value) {
22481
22617
  }
22482
22618
  }
22483
22619
  }
22484
- catch (e_45_1) { e_45 = { error: e_45_1 }; }
22620
+ catch (e_46_1) { e_46 = { error: e_46_1 }; }
22485
22621
  finally {
22486
22622
  try {
22487
22623
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
22488
22624
  }
22489
- finally { if (e_45) throw e_45.error; }
22625
+ finally { if (e_46) throw e_46.error; }
22490
22626
  }
22491
22627
  return false;
22492
22628
  }
@@ -22671,7 +22807,7 @@ function splitAssistantPermissionTokenSets(value) {
22671
22807
  };
22672
22808
  }
22673
22809
  function isAssistantTokenSetSubset(subset, superset) {
22674
- var e_46, _a;
22810
+ var e_47, _a;
22675
22811
  if (!subset.size) {
22676
22812
  return false;
22677
22813
  }
@@ -22683,12 +22819,12 @@ function isAssistantTokenSetSubset(subset, superset) {
22683
22819
  }
22684
22820
  }
22685
22821
  }
22686
- catch (e_46_1) { e_46 = { error: e_46_1 }; }
22822
+ catch (e_47_1) { e_47 = { error: e_47_1 }; }
22687
22823
  finally {
22688
22824
  try {
22689
22825
  if (subset_1_1 && !subset_1_1.done && (_a = subset_1.return)) _a.call(subset_1);
22690
22826
  }
22691
- finally { if (e_46) throw e_46.error; }
22827
+ finally { if (e_47) throw e_47.error; }
22692
22828
  }
22693
22829
  return true;
22694
22830
  }
@@ -23223,8 +23359,8 @@ function applyCodexStreamStatusHandler(runOptions, streamStatusHandler) {
23223
23359
  }
23224
23360
  function waitForCodexWorkerMessage(worker, streamStatusHandler) {
23225
23361
  return __awaiter(this, void 0, void 0, function () {
23226
- var _a, _b, _c, _d, message, payload, status_1, e_47_1;
23227
- var _e, e_47, _f, _g;
23362
+ var _a, _b, _c, _d, message, payload, status_1, e_48_1;
23363
+ var _e, e_48, _f, _g;
23228
23364
  return __generator(this, function (_h) {
23229
23365
  switch (_h.label) {
23230
23366
  case 0:
@@ -23251,8 +23387,8 @@ function waitForCodexWorkerMessage(worker, streamStatusHandler) {
23251
23387
  return [3 /*break*/, 1];
23252
23388
  case 4: return [3 /*break*/, 11];
23253
23389
  case 5:
23254
- e_47_1 = _h.sent();
23255
- e_47 = { error: e_47_1 };
23390
+ e_48_1 = _h.sent();
23391
+ e_48 = { error: e_48_1 };
23256
23392
  return [3 /*break*/, 11];
23257
23393
  case 6:
23258
23394
  _h.trys.push([6, , 9, 10]);
@@ -23263,7 +23399,7 @@ function waitForCodexWorkerMessage(worker, streamStatusHandler) {
23263
23399
  _h.label = 8;
23264
23400
  case 8: return [3 /*break*/, 10];
23265
23401
  case 9:
23266
- if (e_47) throw e_47.error;
23402
+ if (e_48) throw e_48.error;
23267
23403
  return [7 /*endfinally*/];
23268
23404
  case 10: return [7 /*endfinally*/];
23269
23405
  case 11: throw new CodexWorkerBootstrapError('AI worker exited before completing.');
@@ -23607,8 +23743,8 @@ function buildAssistantWorkspaceRootCandidates(params) {
23607
23743
  }
23608
23744
  function resolveAssistantWorkspaceRoot() {
23609
23745
  return __awaiter(this, void 0, void 0, function () {
23610
- var candidates, firstExisting, firstNestedGitRoot, candidates_9, candidates_9_1, candidate, _a, gitRoot, nestedGitRoots, e_48_1;
23611
- var e_48, _b;
23746
+ var candidates, firstExisting, firstNestedGitRoot, candidates_9, candidates_9_1, candidate, _a, gitRoot, nestedGitRoots, e_49_1;
23747
+ var e_49, _b;
23612
23748
  return __generator(this, function (_c) {
23613
23749
  switch (_c.label) {
23614
23750
  case 0:
@@ -23655,14 +23791,14 @@ function resolveAssistantWorkspaceRoot() {
23655
23791
  return [3 /*break*/, 2];
23656
23792
  case 8: return [3 /*break*/, 11];
23657
23793
  case 9:
23658
- e_48_1 = _c.sent();
23659
- e_48 = { error: e_48_1 };
23794
+ e_49_1 = _c.sent();
23795
+ e_49 = { error: e_49_1 };
23660
23796
  return [3 /*break*/, 11];
23661
23797
  case 10:
23662
23798
  try {
23663
23799
  if (candidates_9_1 && !candidates_9_1.done && (_b = candidates_9.return)) _b.call(candidates_9);
23664
23800
  }
23665
- finally { if (e_48) throw e_48.error; }
23801
+ finally { if (e_49) throw e_49.error; }
23666
23802
  return [7 /*endfinally*/];
23667
23803
  case 11:
23668
23804
  if (firstNestedGitRoot) {
@@ -24105,7 +24241,7 @@ var AI_ASSISTANT_BREAKDOWN_DIMENSION_STOPWORDS = new Set([
24105
24241
  'by'
24106
24242
  ]);
24107
24243
  function normalizeAssistantBreakdownDimension(value) {
24108
- var e_49, _a;
24244
+ var e_50, _a;
24109
24245
  var normalized = normalizeOptionalString(value)
24110
24246
  .toLowerCase()
24111
24247
  .replace(/[^a-z0-9_\s-]+/g, ' ')
@@ -24137,12 +24273,12 @@ function normalizeAssistantBreakdownDimension(value) {
24137
24273
  }
24138
24274
  }
24139
24275
  }
24140
- catch (e_49_1) { e_49 = { error: e_49_1 }; }
24276
+ catch (e_50_1) { e_50 = { error: e_50_1 }; }
24141
24277
  finally {
24142
24278
  try {
24143
24279
  if (tokens_1_1 && !tokens_1_1.done && (_a = tokens_1.return)) _a.call(tokens_1);
24144
24280
  }
24145
- finally { if (e_49) throw e_49.error; }
24281
+ finally { if (e_50) throw e_50.error; }
24146
24282
  }
24147
24283
  if (!kept.length) {
24148
24284
  return '';
@@ -24347,7 +24483,7 @@ function resolveAssistantPlannerEnabled(config) {
24347
24483
  return raw === undefined ? false : raw === true;
24348
24484
  }
24349
24485
  function resolveAssistantPlannerKnownRoutes(user, isSuperAdmin) {
24350
- var e_50, _a;
24486
+ var e_51, _a;
24351
24487
  var _b;
24352
24488
  if (isSuperAdmin === void 0) { isSuperAdmin = false; }
24353
24489
  var routes = ((_b = resolveio_server_app_1.ResolveIOServer.getClientRoutes) === null || _b === void 0 ? void 0 : _b.call(resolveio_server_app_1.ResolveIOServer)) || [];
@@ -24361,12 +24497,12 @@ function resolveAssistantPlannerKnownRoutes(user, isSuperAdmin) {
24361
24497
  }
24362
24498
  }
24363
24499
  }
24364
- catch (e_50_1) { e_50 = { error: e_50_1 }; }
24500
+ catch (e_51_1) { e_51 = { error: e_51_1 }; }
24365
24501
  finally {
24366
24502
  try {
24367
24503
  if (routes_1_1 && !routes_1_1.done && (_a = routes_1.return)) _a.call(routes_1);
24368
24504
  }
24369
- finally { if (e_50) throw e_50.error; }
24505
+ finally { if (e_51) throw e_51.error; }
24370
24506
  }
24371
24507
  var normalizedRoutes = Array.from(unique);
24372
24508
  var allowedRoutes = collectAssistantAllowedRoutesForUser(user, normalizedRoutes, isSuperAdmin);
@@ -24742,7 +24878,7 @@ function normalizeRouteMatchKey(value) {
24742
24878
  return normalizeRouteKey(value).toLowerCase();
24743
24879
  }
24744
24880
  function buildClientRouteIndex() {
24745
- var e_51, _a;
24881
+ var e_52, _a;
24746
24882
  var _b;
24747
24883
  var routes = mergeAssistantHintValues(((_b = resolveio_server_app_1.ResolveIOServer.getClientRoutes) === null || _b === void 0 ? void 0 : _b.call(resolveio_server_app_1.ResolveIOServer)) || [], AI_ASSISTANT_CORE_PUBLIC_ROUTES);
24748
24884
  var set = new Set();
@@ -24761,12 +24897,12 @@ function buildClientRouteIndex() {
24761
24897
  }
24762
24898
  }
24763
24899
  }
24764
- catch (e_51_1) { e_51 = { error: e_51_1 }; }
24900
+ catch (e_52_1) { e_52 = { error: e_52_1 }; }
24765
24901
  finally {
24766
24902
  try {
24767
24903
  if (routes_2_1 && !routes_2_1.done && (_a = routes_2.return)) _a.call(routes_2);
24768
24904
  }
24769
- finally { if (e_51) throw e_51.error; }
24905
+ finally { if (e_52) throw e_52.error; }
24770
24906
  }
24771
24907
  return { set: set, map: map, size: routes.length };
24772
24908
  }
@@ -25657,8 +25793,8 @@ function shouldSkipAssistantGitDiscoveryDirectory(name) {
25657
25793
  }
25658
25794
  function resolveAssistantWorkspaceGitRoots(workspaceRoot) {
25659
25795
  return __awaiter(this, void 0, void 0, function () {
25660
- var roots, seen, push, _a, configuredRoots, configuredRoots_1, configuredRoots_1_1, configuredRoot, _b, e_52_1, queue, queued, enqueue, next, entries, _c, entries_1, entries_1_1, entry, childName, candidate, gitPath, _d, e_53_1;
25661
- var e_52, _e, e_53, _f;
25796
+ var roots, seen, push, _a, configuredRoots, configuredRoots_1, configuredRoots_1_1, configuredRoot, _b, e_53_1, queue, queued, enqueue, next, entries, _c, entries_1, entries_1_1, entry, childName, candidate, gitPath, _d, e_54_1;
25797
+ var e_53, _e, e_54, _f;
25662
25798
  var _g;
25663
25799
  return __generator(this, function (_h) {
25664
25800
  switch (_h.label) {
@@ -25703,14 +25839,14 @@ function resolveAssistantWorkspaceGitRoots(workspaceRoot) {
25703
25839
  return [3 /*break*/, 3];
25704
25840
  case 6: return [3 /*break*/, 9];
25705
25841
  case 7:
25706
- e_52_1 = _h.sent();
25707
- e_52 = { error: e_52_1 };
25842
+ e_53_1 = _h.sent();
25843
+ e_53 = { error: e_53_1 };
25708
25844
  return [3 /*break*/, 9];
25709
25845
  case 8:
25710
25846
  try {
25711
25847
  if (configuredRoots_1_1 && !configuredRoots_1_1.done && (_e = configuredRoots_1.return)) _e.call(configuredRoots_1);
25712
25848
  }
25713
- finally { if (e_52) throw e_52.error; }
25849
+ finally { if (e_53) throw e_53.error; }
25714
25850
  return [7 /*endfinally*/];
25715
25851
  case 9:
25716
25852
  queue = [];
@@ -25750,7 +25886,7 @@ function resolveAssistantWorkspaceGitRoots(workspaceRoot) {
25750
25886
  return [3 /*break*/, 14];
25751
25887
  case 14:
25752
25888
  _h.trys.push([14, 21, 22, 23]);
25753
- entries_1 = (e_53 = void 0, __values(entries)), entries_1_1 = entries_1.next();
25889
+ entries_1 = (e_54 = void 0, __values(entries)), entries_1_1 = entries_1.next();
25754
25890
  _h.label = 15;
25755
25891
  case 15:
25756
25892
  if (!!entries_1_1.done) return [3 /*break*/, 20];
@@ -25789,14 +25925,14 @@ function resolveAssistantWorkspaceGitRoots(workspaceRoot) {
25789
25925
  return [3 /*break*/, 15];
25790
25926
  case 20: return [3 /*break*/, 23];
25791
25927
  case 21:
25792
- e_53_1 = _h.sent();
25793
- e_53 = { error: e_53_1 };
25928
+ e_54_1 = _h.sent();
25929
+ e_54 = { error: e_54_1 };
25794
25930
  return [3 /*break*/, 23];
25795
25931
  case 22:
25796
25932
  try {
25797
25933
  if (entries_1_1 && !entries_1_1.done && (_f = entries_1.return)) _f.call(entries_1);
25798
25934
  }
25799
- finally { if (e_53) throw e_53.error; }
25935
+ finally { if (e_54) throw e_54.error; }
25800
25936
  return [7 /*endfinally*/];
25801
25937
  case 23: return [3 /*break*/, 10];
25802
25938
  case 24: return [2 /*return*/, roots];
@@ -26136,8 +26272,8 @@ function syncAssistantGitMirror(repoUrl) {
26136
26272
  }
26137
26273
  function resolveAssistantChangeHistoryGitRoots(workspaceRoot) {
26138
26274
  return __awaiter(this, void 0, void 0, function () {
26139
- var roots, repoUrls, mirroredRoots, repoUrls_1, repoUrls_1_1, repoUrl, mirrorRoot, e_54_1;
26140
- var e_54, _a;
26275
+ var roots, repoUrls, mirroredRoots, repoUrls_1, repoUrls_1_1, repoUrl, mirrorRoot, e_55_1;
26276
+ var e_55, _a;
26141
26277
  return __generator(this, function (_b) {
26142
26278
  switch (_b.label) {
26143
26279
  case 0: return [4 /*yield*/, resolveAssistantWorkspaceGitRoots(workspaceRoot)];
@@ -26171,14 +26307,14 @@ function resolveAssistantChangeHistoryGitRoots(workspaceRoot) {
26171
26307
  return [3 /*break*/, 3];
26172
26308
  case 6: return [3 /*break*/, 9];
26173
26309
  case 7:
26174
- e_54_1 = _b.sent();
26175
- e_54 = { error: e_54_1 };
26310
+ e_55_1 = _b.sent();
26311
+ e_55 = { error: e_55_1 };
26176
26312
  return [3 /*break*/, 9];
26177
26313
  case 8:
26178
26314
  try {
26179
26315
  if (repoUrls_1_1 && !repoUrls_1_1.done && (_a = repoUrls_1.return)) _a.call(repoUrls_1);
26180
26316
  }
26181
- finally { if (e_54) throw e_54.error; }
26317
+ finally { if (e_55) throw e_55.error; }
26182
26318
  return [7 /*endfinally*/];
26183
26319
  case 9: return [2 /*return*/, mirroredRoots];
26184
26320
  }
@@ -26187,8 +26323,8 @@ function resolveAssistantChangeHistoryGitRoots(workspaceRoot) {
26187
26323
  }
26188
26324
  function resolveAssistantChangeHistoryFastPathResponse(params) {
26189
26325
  return __awaiter(this, void 0, void 0, function () {
26190
- var workspaceRoot, _a, gitRoots, featureKeywords, sawExecutionError, bestFallback, gitRoots_1, gitRoots_1_1, gitRoot, _b, branch, _c, _d, limit, historyDepth, rawHistory, commits, summary, hasKeywordMatches, _e, e_55_1;
26191
- var e_55, _f;
26326
+ var workspaceRoot, _a, gitRoots, featureKeywords, sawExecutionError, bestFallback, gitRoots_1, gitRoots_1_1, gitRoot, _b, branch, _c, _d, limit, historyDepth, rawHistory, commits, summary, hasKeywordMatches, _e, e_56_1;
26327
+ var e_56, _f;
26192
26328
  return __generator(this, function (_g) {
26193
26329
  switch (_g.label) {
26194
26330
  case 0:
@@ -26310,14 +26446,14 @@ function resolveAssistantChangeHistoryFastPathResponse(params) {
26310
26446
  return [3 /*break*/, 7];
26311
26447
  case 20: return [3 /*break*/, 23];
26312
26448
  case 21:
26313
- e_55_1 = _g.sent();
26314
- e_55 = { error: e_55_1 };
26449
+ e_56_1 = _g.sent();
26450
+ e_56 = { error: e_56_1 };
26315
26451
  return [3 /*break*/, 23];
26316
26452
  case 22:
26317
26453
  try {
26318
26454
  if (gitRoots_1_1 && !gitRoots_1_1.done && (_f = gitRoots_1.return)) _f.call(gitRoots_1);
26319
26455
  }
26320
- finally { if (e_55) throw e_55.error; }
26456
+ finally { if (e_56) throw e_56.error; }
26321
26457
  return [7 /*endfinally*/];
26322
26458
  case 23:
26323
26459
  if (bestFallback) {
@@ -26498,7 +26634,7 @@ function sanitizeAssistantResponse(value) {
26498
26634
  return normalizeAssistantRoutes(normalizedCurrency);
26499
26635
  }
26500
26636
  function evaluateAssistantGuardrails(message) {
26501
- var e_56, _a;
26637
+ var e_57, _a;
26502
26638
  var normalized = String(message || '').toLowerCase();
26503
26639
  var identityGuardrail = evaluateAssistantIdentityDisclosureGuardrail(normalized);
26504
26640
  if (identityGuardrail === null || identityGuardrail === void 0 ? void 0 : identityGuardrail.blocked) {
@@ -26543,12 +26679,12 @@ function evaluateAssistantGuardrails(message) {
26543
26679
  }
26544
26680
  }
26545
26681
  }
26546
- catch (e_56_1) { e_56 = { error: e_56_1 }; }
26682
+ catch (e_57_1) { e_57 = { error: e_57_1 }; }
26547
26683
  finally {
26548
26684
  try {
26549
26685
  if (patterns_3_1 && !patterns_3_1.done && (_a = patterns_3.return)) _a.call(patterns_3);
26550
26686
  }
26551
- finally { if (e_56) throw e_56.error; }
26687
+ finally { if (e_57) throw e_57.error; }
26552
26688
  }
26553
26689
  return null;
26554
26690
  }
@@ -26653,7 +26789,7 @@ function tokenizeArithmeticExpression(expression) {
26653
26789
  return tokens;
26654
26790
  }
26655
26791
  function evaluateArithmeticExpression(expression) {
26656
- var e_57, _a, e_58, _b;
26792
+ var e_58, _a, e_59, _b;
26657
26793
  var tokens = tokenizeArithmeticExpression(expression);
26658
26794
  if (!tokens || !tokens.length) {
26659
26795
  return null;
@@ -26710,12 +26846,12 @@ function evaluateArithmeticExpression(expression) {
26710
26846
  prevToken = token;
26711
26847
  }
26712
26848
  }
26713
- catch (e_57_1) { e_57 = { error: e_57_1 }; }
26849
+ catch (e_58_1) { e_58 = { error: e_58_1 }; }
26714
26850
  finally {
26715
26851
  try {
26716
26852
  if (tokens_2_1 && !tokens_2_1.done && (_a = tokens_2.return)) _a.call(tokens_2);
26717
26853
  }
26718
- finally { if (e_57) throw e_57.error; }
26854
+ finally { if (e_58) throw e_58.error; }
26719
26855
  }
26720
26856
  while (ops.length) {
26721
26857
  var op = ops.pop();
@@ -26755,12 +26891,12 @@ function evaluateArithmeticExpression(expression) {
26755
26891
  stack.push(Number(token));
26756
26892
  }
26757
26893
  }
26758
- catch (e_58_1) { e_58 = { error: e_58_1 }; }
26894
+ catch (e_59_1) { e_59 = { error: e_59_1 }; }
26759
26895
  finally {
26760
26896
  try {
26761
26897
  if (output_1_1 && !output_1_1.done && (_b = output_1.return)) _b.call(output_1);
26762
26898
  }
26763
- finally { if (e_58) throw e_58.error; }
26899
+ finally { if (e_59) throw e_59.error; }
26764
26900
  }
26765
26901
  if (stack.length !== 1 || Number.isNaN(stack[0])) {
26766
26902
  return null;
@@ -26944,8 +27080,8 @@ function handleCodexUpload(id_conversation, file_name, content_base64, size, con
26944
27080
  }
26945
27081
  function readAttachmentContents(attachments) {
26946
27082
  return __awaiter(this, void 0, void 0, function () {
26947
- var limits, totalBytes, totalChars, chunks, cleaned, attachments_1, attachments_1_1, attachment, localPath, safe, stat, ext, name_1, type, readable, content, _a, e_59_1;
26948
- var e_59, _b;
27083
+ var limits, totalBytes, totalChars, chunks, cleaned, attachments_1, attachments_1_1, attachment, localPath, safe, stat, ext, name_1, type, readable, content, _a, e_60_1;
27084
+ var e_60, _b;
26949
27085
  return __generator(this, function (_c) {
26950
27086
  switch (_c.label) {
26951
27087
  case 0:
@@ -27024,14 +27160,14 @@ function readAttachmentContents(attachments) {
27024
27160
  return [3 /*break*/, 2];
27025
27161
  case 10: return [3 /*break*/, 13];
27026
27162
  case 11:
27027
- e_59_1 = _c.sent();
27028
- e_59 = { error: e_59_1 };
27163
+ e_60_1 = _c.sent();
27164
+ e_60 = { error: e_60_1 };
27029
27165
  return [3 /*break*/, 13];
27030
27166
  case 12:
27031
27167
  try {
27032
27168
  if (attachments_1_1 && !attachments_1_1.done && (_b = attachments_1.return)) _b.call(attachments_1);
27033
27169
  }
27034
- finally { if (e_59) throw e_59.error; }
27170
+ finally { if (e_60) throw e_60.error; }
27035
27171
  return [7 /*endfinally*/];
27036
27172
  case 13: return [2 /*return*/, {
27037
27173
  promptText: chunks.length ? "\n\nAttachments:\n".concat(chunks.join('\n\n')) : '',
@@ -27456,7 +27592,7 @@ function sanitizeAssistantMessageSetPayload(setPayload) {
27456
27592
  return next;
27457
27593
  }
27458
27594
  function sanitizeMongoSafeObject(value) {
27459
- var e_60, _a;
27595
+ var e_61, _a;
27460
27596
  if (value === null || value === undefined) {
27461
27597
  return value;
27462
27598
  }
@@ -27480,17 +27616,17 @@ function sanitizeMongoSafeObject(value) {
27480
27616
  out[key] = sanitizeMongoSafeObject(rawValue);
27481
27617
  }
27482
27618
  }
27483
- catch (e_60_1) { e_60 = { error: e_60_1 }; }
27619
+ catch (e_61_1) { e_61 = { error: e_61_1 }; }
27484
27620
  finally {
27485
27621
  try {
27486
27622
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
27487
27623
  }
27488
- finally { if (e_60) throw e_60.error; }
27624
+ finally { if (e_61) throw e_61.error; }
27489
27625
  }
27490
27626
  return out;
27491
27627
  }
27492
27628
  function restoreMongoSafeObject(value) {
27493
- var e_61, _a;
27629
+ var e_62, _a;
27494
27630
  if (value === null || value === undefined) {
27495
27631
  return value;
27496
27632
  }
@@ -27514,12 +27650,12 @@ function restoreMongoSafeObject(value) {
27514
27650
  out[key] = restoreMongoSafeObject(rawValue);
27515
27651
  }
27516
27652
  }
27517
- catch (e_61_1) { e_61 = { error: e_61_1 }; }
27653
+ catch (e_62_1) { e_62 = { error: e_62_1 }; }
27518
27654
  finally {
27519
27655
  try {
27520
27656
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
27521
27657
  }
27522
- finally { if (e_61) throw e_61.error; }
27658
+ finally { if (e_62) throw e_62.error; }
27523
27659
  }
27524
27660
  return out;
27525
27661
  }
@@ -27697,7 +27833,7 @@ function recordAssistantAnswerAIRun(input) {
27697
27833
  });
27698
27834
  }
27699
27835
  function evaluateGuardrails(message) {
27700
- var e_62, _a;
27836
+ var e_63, _a;
27701
27837
  var normalized = String(message || '').toLowerCase();
27702
27838
  var identityGuardrail = evaluateAssistantIdentityDisclosureGuardrail(normalized);
27703
27839
  if (identityGuardrail === null || identityGuardrail === void 0 ? void 0 : identityGuardrail.blocked) {
@@ -27723,12 +27859,12 @@ function evaluateGuardrails(message) {
27723
27859
  }
27724
27860
  }
27725
27861
  }
27726
- catch (e_62_1) { e_62 = { error: e_62_1 }; }
27862
+ catch (e_63_1) { e_63 = { error: e_63_1 }; }
27727
27863
  finally {
27728
27864
  try {
27729
27865
  if (patterns_4_1 && !patterns_4_1.done && (_a = patterns_4.return)) _a.call(patterns_4);
27730
27866
  }
27731
- finally { if (e_62) throw e_62.error; }
27867
+ finally { if (e_63) throw e_63.error; }
27732
27868
  }
27733
27869
  return null;
27734
27870
  }