@resolveio/server-lib 22.3.207 → 22.3.209
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/methods/ai-terminal.js +106 -20
- package/methods/ai-terminal.js.map +1 -1
- package/package.json +1 -1
package/methods/ai-terminal.js
CHANGED
|
@@ -3432,7 +3432,8 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
3432
3432
|
});
|
|
3433
3433
|
}); });
|
|
3434
3434
|
return [2 /*return*/, {
|
|
3435
|
-
conversation: conversation
|
|
3435
|
+
conversation: conversation,
|
|
3436
|
+
message: __assign(__assign({}, assistantDoc), { _id: assistantMessageId })
|
|
3436
3437
|
}];
|
|
3437
3438
|
}
|
|
3438
3439
|
});
|
|
@@ -7407,6 +7408,7 @@ function extractAssistantDataIntentCustomerText(message) {
|
|
|
7407
7408
|
return '';
|
|
7408
7409
|
}
|
|
7409
7410
|
value = value.replace(/\b(january|jan|february|feb|march|mar|april|apr|may|june|jun|july|jul|august|aug|september|sep|october|oct|november|nov|december|dec)\s+[0-9]{4}\b/gi, ' ');
|
|
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, ' ');
|
|
7410
7412
|
value = value.replace(/\b(?:last|past)\s+[0-9]+\s+(?:days?|weeks?|months?)\b/gi, ' ');
|
|
7411
7413
|
value = value.replace(/\b(?:this|current)\s+(?:week|month|quarter|year)\b/gi, ' ');
|
|
7412
7414
|
value = value.replace(/\b(?:last|past)\s+(?:week|month|quarter|year)\b/gi, ' ');
|
|
@@ -7443,6 +7445,7 @@ function extractAssistantDataIntentLikelyFilterText(message, intent) {
|
|
|
7443
7445
|
}
|
|
7444
7446
|
value = value.replace(/\b(january|jan|february|feb|march|mar|april|apr|may|june|jun|july|jul|august|aug|september|sep|october|oct|november|nov|december)\s+[0-9]{4}\b/gi, ' ');
|
|
7445
7447
|
value = value.replace(/\b(january|jan|february|feb|march|mar|april|apr|may|june|jun|july|jul|august|aug|september|sep|october|oct|november|nov|december)\b/gi, ' ');
|
|
7448
|
+
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, ' ');
|
|
7446
7449
|
value = value.replace(/\b(?:last|past)\s+[0-9]+\s+(?:days?|weeks?|months?)\b/gi, ' ');
|
|
7447
7450
|
value = value.replace(/\b(?:this|current)\s+(?:week|month|quarter|year)\b/gi, ' ');
|
|
7448
7451
|
value = value.replace(/\b(?:last|past)\s+(?:week|month|quarter|year)\b/gi, ' ');
|
|
@@ -8004,6 +8007,35 @@ function resolveAssistantDataIntentDateWindow(message) {
|
|
|
8004
8007
|
year: now.getUTCFullYear()
|
|
8005
8008
|
};
|
|
8006
8009
|
}
|
|
8010
|
+
var approximateLastWindowMatch = text.match(/\b(?:last|past|previous|over\s+the\s+last)\s+(few|couple|couple\s+of|several)\s+(days?|weeks?|months?|years?)\b/);
|
|
8011
|
+
if (approximateLastWindowMatch) {
|
|
8012
|
+
var amountText = approximateLastWindowMatch[1];
|
|
8013
|
+
var amount = amountText.includes('couple')
|
|
8014
|
+
? 2
|
|
8015
|
+
: amountText === 'several'
|
|
8016
|
+
? 6
|
|
8017
|
+
: 3;
|
|
8018
|
+
var unit = approximateLastWindowMatch[2];
|
|
8019
|
+
var start = new Date(now.getTime());
|
|
8020
|
+
if (/year/.test(unit)) {
|
|
8021
|
+
start.setUTCFullYear(start.getUTCFullYear() - amount);
|
|
8022
|
+
}
|
|
8023
|
+
else if (/month/.test(unit)) {
|
|
8024
|
+
start.setUTCMonth(start.getUTCMonth() - amount);
|
|
8025
|
+
}
|
|
8026
|
+
else if (/week/.test(unit)) {
|
|
8027
|
+
start.setUTCDate(start.getUTCDate() - (amount * 7));
|
|
8028
|
+
}
|
|
8029
|
+
else {
|
|
8030
|
+
start.setUTCDate(start.getUTCDate() - amount);
|
|
8031
|
+
}
|
|
8032
|
+
start.setUTCHours(0, 0, 0, 0);
|
|
8033
|
+
return {
|
|
8034
|
+
start: start.toISOString(),
|
|
8035
|
+
end: new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), 23, 59, 59, 999)).toISOString(),
|
|
8036
|
+
year: now.getUTCFullYear()
|
|
8037
|
+
};
|
|
8038
|
+
}
|
|
8007
8039
|
var lastWindowMatch = text.match(/\b(?:last|past)\s+([0-9]+)\s+(days?|weeks?|months?)\b/);
|
|
8008
8040
|
if (lastWindowMatch) {
|
|
8009
8041
|
var amount = Math.max(1, Math.min(Number(lastWindowMatch[1]) || 1, 36));
|
|
@@ -8338,7 +8370,7 @@ function buildAssistantDataIntentTimeDimension(requestedDimensionText, intent) {
|
|
|
8338
8370
|
_b[id] = "$_id.".concat(id),
|
|
8339
8371
|
_b),
|
|
8340
8372
|
sort: (_c = {},
|
|
8341
|
-
_c[id] = 1,
|
|
8373
|
+
_c[id] = -1,
|
|
8342
8374
|
_c)
|
|
8343
8375
|
};
|
|
8344
8376
|
}
|
|
@@ -10280,6 +10312,56 @@ function mergeAssistantMatchClauses(existingMatch, clauses) {
|
|
|
10280
10312
|
], __read(cleanClauses), false)
|
|
10281
10313
|
};
|
|
10282
10314
|
}
|
|
10315
|
+
function hasAssistantMeaningfulSortStage(pipeline) {
|
|
10316
|
+
return (Array.isArray(pipeline) ? pipeline : []).some(function (stage) { return ((stage === null || stage === void 0 ? void 0 : stage.$sort)
|
|
10317
|
+
&& typeof stage.$sort === 'object'
|
|
10318
|
+
&& !Array.isArray(stage.$sort)
|
|
10319
|
+
&& Object.keys(stage.$sort).length > 0); });
|
|
10320
|
+
}
|
|
10321
|
+
function applyAssistantDefaultRecencySortToPipeline(pipeline) {
|
|
10322
|
+
var _a;
|
|
10323
|
+
var _b;
|
|
10324
|
+
if (!Array.isArray(pipeline) || !pipeline.length || hasAssistantMeaningfulSortStage(pipeline)) {
|
|
10325
|
+
return pipeline;
|
|
10326
|
+
}
|
|
10327
|
+
var next = (0, common_1.deepCopy)(pipeline);
|
|
10328
|
+
var groupIndex = findAggregateGroupIndex(next);
|
|
10329
|
+
if (groupIndex > -1) {
|
|
10330
|
+
var groupStage = (_b = next[groupIndex]) === null || _b === void 0 ? void 0 : _b.$group;
|
|
10331
|
+
if (!groupStage || typeof groupStage !== 'object' || Array.isArray(groupStage)) {
|
|
10332
|
+
return next;
|
|
10333
|
+
}
|
|
10334
|
+
var updatedSortField = '__assistant_sort_updatedAt';
|
|
10335
|
+
var createdSortField = '__assistant_sort_createdAt';
|
|
10336
|
+
if (!Object.prototype.hasOwnProperty.call(groupStage, updatedSortField)) {
|
|
10337
|
+
groupStage[updatedSortField] = { $max: '$updatedAt' };
|
|
10338
|
+
}
|
|
10339
|
+
if (!Object.prototype.hasOwnProperty.call(groupStage, createdSortField)) {
|
|
10340
|
+
groupStage[createdSortField] = { $max: '$createdAt' };
|
|
10341
|
+
}
|
|
10342
|
+
var projectIndex = next.findIndex(function (stage, index) { return index > groupIndex && !!(stage === null || stage === void 0 ? void 0 : stage.$project); });
|
|
10343
|
+
var insertIndex_1 = projectIndex > -1 ? projectIndex : groupIndex + 1;
|
|
10344
|
+
next.splice(insertIndex_1, 0, {
|
|
10345
|
+
$sort: (_a = {},
|
|
10346
|
+
_a[updatedSortField] = -1,
|
|
10347
|
+
_a[createdSortField] = -1,
|
|
10348
|
+
_a)
|
|
10349
|
+
});
|
|
10350
|
+
if (projectIndex === -1) {
|
|
10351
|
+
next.splice(insertIndex_1 + 1, 0, { $unset: [updatedSortField, createdSortField] });
|
|
10352
|
+
}
|
|
10353
|
+
return next;
|
|
10354
|
+
}
|
|
10355
|
+
var insertIndex = next.findIndex(function (stage) { return !!((stage === null || stage === void 0 ? void 0 : stage.$project) || (stage === null || stage === void 0 ? void 0 : stage.$limit) || (stage === null || stage === void 0 ? void 0 : stage.$skip) || (stage === null || stage === void 0 ? void 0 : stage.$count) || (stage === null || stage === void 0 ? void 0 : stage.$facet)); });
|
|
10356
|
+
next.splice(insertIndex > -1 ? insertIndex : next.length, 0, {
|
|
10357
|
+
$sort: {
|
|
10358
|
+
updatedAt: -1,
|
|
10359
|
+
createdAt: -1,
|
|
10360
|
+
_id: -1
|
|
10361
|
+
}
|
|
10362
|
+
});
|
|
10363
|
+
return next;
|
|
10364
|
+
}
|
|
10283
10365
|
function applyAssistantDataIntentContractFiltersToPipeline(pipeline, intent, requestContract) {
|
|
10284
10366
|
var _a;
|
|
10285
10367
|
var filters = Array.isArray(requestContract === null || requestContract === void 0 ? void 0 : requestContract.filters) ? requestContract.filters : [];
|
|
@@ -10468,21 +10550,25 @@ function applyAssistantDataIntentDimensionsToPipeline(pipeline, dimensions) {
|
|
|
10468
10550
|
}
|
|
10469
10551
|
});
|
|
10470
10552
|
}
|
|
10471
|
-
var
|
|
10472
|
-
|
|
10473
|
-
|
|
10474
|
-
|
|
10475
|
-
|
|
10476
|
-
Object.
|
|
10477
|
-
|
|
10478
|
-
|
|
10479
|
-
|
|
10480
|
-
|
|
10481
|
-
|
|
10482
|
-
|
|
10483
|
-
});
|
|
10484
|
-
if (
|
|
10485
|
-
next[sortIndex].$sort =
|
|
10553
|
+
var combinedSort = {};
|
|
10554
|
+
selectedDimensions.forEach(function (dimension) {
|
|
10555
|
+
if (dimension.sort && typeof dimension.sort === 'object' && !Array.isArray(dimension.sort)) {
|
|
10556
|
+
Object.keys(dimension.sort).forEach(function (key) {
|
|
10557
|
+
var _a;
|
|
10558
|
+
if (!Object.prototype.hasOwnProperty.call(combinedSort, key)) {
|
|
10559
|
+
combinedSort[key] = (0, common_1.deepCopy)((_a = dimension.sort) === null || _a === void 0 ? void 0 : _a[key]);
|
|
10560
|
+
}
|
|
10561
|
+
});
|
|
10562
|
+
}
|
|
10563
|
+
});
|
|
10564
|
+
if (Object.keys(combinedSort).length) {
|
|
10565
|
+
var sortIndex = next.findIndex(function (stage, index) { return index > groupIndex && !!(stage === null || stage === void 0 ? void 0 : stage.$sort); });
|
|
10566
|
+
if (sortIndex > -1) {
|
|
10567
|
+
next[sortIndex].$sort = combinedSort;
|
|
10568
|
+
}
|
|
10569
|
+
else {
|
|
10570
|
+
var insertIndex = projectIndex > -1 ? projectIndex + 1 : groupIndex + 1;
|
|
10571
|
+
next.splice(insertIndex, 0, { $sort: combinedSort });
|
|
10486
10572
|
}
|
|
10487
10573
|
}
|
|
10488
10574
|
return next;
|
|
@@ -10536,7 +10622,7 @@ function buildAssistantAppDataIntentDirective(message, collectionNames, appId, o
|
|
|
10536
10622
|
: buildAssistantGenericDataIntentPipeline(intent, customerText, dateWindow);
|
|
10537
10623
|
var dimensionPipeline = applyAssistantDataIntentDimensionsToPipeline(pipeline, templatedDimensions);
|
|
10538
10624
|
var filterApplication = applyAssistantDataIntentContractFiltersToPipeline(dimensionPipeline, intent, requestUnderstanding.contract);
|
|
10539
|
-
var finalPipeline = filterApplication.pipeline;
|
|
10625
|
+
var finalPipeline = applyAssistantDefaultRecencySortToPipeline(filterApplication.pipeline);
|
|
10540
10626
|
var planValidationStart = Date.now();
|
|
10541
10627
|
var droppedBreakdownAmbiguities = resolveAssistantDroppedBreakdownAmbiguities(requestUnderstanding.contract, finalPipeline);
|
|
10542
10628
|
var droppedFilterAmbiguities = resolveAssistantDroppedFilterAmbiguities(requestUnderstanding.contract, finalPipeline, filterApplication.appliedFilterKeys);
|
|
@@ -10860,7 +10946,7 @@ function buildAssistantDatedPivotDisplay(display, expectedMonths) {
|
|
|
10860
10946
|
.filter(Boolean)
|
|
10861
10947
|
: [];
|
|
10862
10948
|
expectedMonthBuckets.forEach(function (month) { return monthSet.add(month); });
|
|
10863
|
-
var months = Array.from(monthSet).sort(function (a, b) { return
|
|
10949
|
+
var months = Array.from(monthSet).sort(function (a, b) { return b.localeCompare(a); });
|
|
10864
10950
|
if (!months.length) {
|
|
10865
10951
|
return null;
|
|
10866
10952
|
}
|
|
@@ -12318,7 +12404,7 @@ function createAssistantProgressTracker(messageId, initialProgress) {
|
|
|
12318
12404
|
if (!next.length) {
|
|
12319
12405
|
return;
|
|
12320
12406
|
}
|
|
12321
|
-
progress = next;
|
|
12407
|
+
progress = normalizeAssistantProgress(__spreadArray(__spreadArray([], __read(progress), false), __read(next), false));
|
|
12322
12408
|
progressSource = normalizeOptionalString(source) || progressSource;
|
|
12323
12409
|
queueProgressUpdate();
|
|
12324
12410
|
},
|