@resolveio/server-lib 22.0.20 → 22.0.21

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.
@@ -498,6 +498,7 @@ var AI_ASSISTANT_SYSTEM_PROMPT = [
498
498
  '- For invoice data, set permissionView to an invoice-capable route (ex: /invoice/list).',
499
499
  '- Do not use /report/* routes as permissionView for data directives; use a module route that matches the collection.',
500
500
  '- For revenue/sales/billing questions, use invoices and sum paid_total (fallback to grand_total) with date_paid and Paid/Closed status when available.',
501
+ '- For blend ticket summaries, use product = blend_name (fallback chemical), total volume = chemical_recipe_quantity, and unit = lb when blend_in_pounds is true otherwise gal.',
501
502
  '- For revenue answers, always state the metric/date basis used (paid_total/date_paid vs grand_total/date_invoice). If tool verification warns about ambiguity or partial months, call that out before totals.',
502
503
  '- For time-based "last/past N" breakdowns, use full completed calendar-period windows in UTC aligned to the requested grain (day/week/month/quarter/year) by default, and present concrete start/end dates.',
503
504
  '- For relative date ranges (last/past/recent), include an upper bound <= $$NOW unless the user specifies a future end date.',
@@ -3978,7 +3979,7 @@ function applyAssistantVerificationNotes(value, toolResult) {
3978
3979
  return content || value || '';
3979
3980
  }
3980
3981
  var normalizedLower = String(content || '').toLowerCase();
3981
- var missing = warnings.filter(function (warning) { return !normalizedLower.includes(String(warning).toLowerCase()); });
3982
+ var missing = warnings.filter(function (warning) { return !hasAssistantEquivalentVerificationWarning(normalizedLower, warning); });
3982
3983
  if (!missing.length) {
3983
3984
  return content || value || '';
3984
3985
  }
@@ -3989,6 +3990,29 @@ function applyAssistantVerificationNotes(value, toolResult) {
3989
3990
  }
3990
3991
  return "".concat(content, "\n\n").concat(noteLines.join('\n')).trim();
3991
3992
  }
3993
+ function hasAssistantEquivalentVerificationWarning(contentLower, warning) {
3994
+ var warningLower = normalizeOptionalString(warning).toLowerCase();
3995
+ if (!warningLower) {
3996
+ return false;
3997
+ }
3998
+ if (contentLower.includes(warningLower)) {
3999
+ return true;
4000
+ }
4001
+ if (!warningLower.includes('changes monthly totals by')) {
4002
+ return false;
4003
+ }
4004
+ var pctMatch = warningLower.match(/([0-9]+(?:\.[0-9]+)?)%/);
4005
+ if (!pctMatch) {
4006
+ return false;
4007
+ }
4008
+ if (!/date[_\s-]?paid/.test(warningLower) || !/date[_\s-]?invoice/.test(warningLower)) {
4009
+ return false;
4010
+ }
4011
+ return contentLower.includes('changes monthly totals by')
4012
+ && contentLower.includes("".concat(pctMatch[1], "%"))
4013
+ && /date[_\s-]?paid/.test(contentLower)
4014
+ && /date[_\s-]?invoice/.test(contentLower);
4015
+ }
3992
4016
  function applyAssistantDatedReportWindow(value, toolResult) {
3993
4017
  var content = normalizeOptionalString(value);
3994
4018
  var window = resolveAssistantDatedReportWindow(toolResult);
@@ -5826,12 +5850,31 @@ function resolveAssistantNumericValue(value) {
5826
5850
  return value;
5827
5851
  }
5828
5852
  if (typeof value === 'string') {
5829
- var cleaned = value.replace(/[^0-9.+-]/g, '');
5830
- if (!cleaned) {
5853
+ var trimmed = value.trim();
5854
+ if (!trimmed) {
5855
+ return null;
5856
+ }
5857
+ var negative = false;
5858
+ var candidate = trimmed;
5859
+ var accountingMatch = candidate.match(/^\((.+)\)$/);
5860
+ if (accountingMatch === null || accountingMatch === void 0 ? void 0 : accountingMatch[1]) {
5861
+ negative = true;
5862
+ candidate = accountingMatch[1].trim();
5863
+ }
5864
+ candidate = candidate.replace(/^\$/, '').replace(/,/g, '');
5865
+ if (!candidate || !/^[+-]?(?:\d+|\d*\.\d+)%?$/.test(candidate) || !/[0-9]/.test(candidate)) {
5866
+ return null;
5867
+ }
5868
+ var normalized = candidate.endsWith('%') ? candidate.slice(0, -1) : candidate;
5869
+ var parsed = Number(normalized);
5870
+ if (!Number.isFinite(parsed)) {
5871
+ return null;
5872
+ }
5873
+ var signed = negative ? -parsed : parsed;
5874
+ if (!Number.isFinite(signed)) {
5831
5875
  return null;
5832
5876
  }
5833
- var parsed = Number(cleaned);
5834
- return Number.isFinite(parsed) ? parsed : null;
5877
+ return signed;
5835
5878
  }
5836
5879
  return null;
5837
5880
  }